1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
33 (defvar tool-bar-map))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
57 (autoload 'mm-uu-dissect "mm-uu")
58 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
59 "Deuglify broken Outlook (Express) articles and redisplay."
61 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
62 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
63 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-fetch-old-headers nil
73 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
74 If an unread article in the group refers to an older, already read (or
75 just marked as read) article, the old article will not normally be
76 displayed in the Summary buffer. If this variable is t, Gnus
77 will attempt to grab the headers to the old articles, and thereby
78 build complete threads. If it has the value `some', only enough
79 headers to connect otherwise loose threads will be displayed. This
80 variable can also be a number. In that case, no more than that number
81 of old headers will be fetched. If it has the value `invisible', all
82 old headers will be fetched, but none will be displayed.
84 The server has to support NOV for any of this to work."
86 :type '(choice (const :tag "off" nil)
91 (sexp :menu-tag "other" t)))
93 (defcustom gnus-refer-thread-limit 200
94 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
95 If t, fetch all the available old headers."
98 (sexp :menu-tag "other" t)))
100 (defcustom gnus-summary-make-false-root 'adopt
101 "*nil means that Gnus won't gather loose threads.
102 If the root of a thread has expired or been read in a previous
103 session, the information necessary to build a complete thread has been
104 lost. Instead of having many small sub-threads from this original thread
105 scattered all over the summary buffer, Gnus can gather them.
107 If non-nil, Gnus will try to gather all loose sub-threads from an
108 original thread into one large thread.
110 If this variable is non-nil, it should be one of `none', `adopt',
113 If this variable is `none', Gnus will not make a false root, but just
114 present the sub-threads after another.
115 If this variable is `dummy', Gnus will create a dummy root that will
116 have all the sub-threads as children.
117 If this variable is `adopt', Gnus will make one of the \"children\"
118 the parent and mark all the step-children as such.
119 If this variable is `empty', the \"children\" are printed with empty
120 subject fields. (Or rather, they will be printed with a string
121 given by the `gnus-summary-same-subject' variable.)"
123 :type '(choice (const :tag "off" nil)
129 (defcustom gnus-summary-make-false-root-always nil
130 "Always make a false dummy root."
135 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
136 "*A regexp to match subjects to be excluded from loose thread gathering.
137 As loose thread gathering is done on subjects only, that means that
138 there can be many false gatherings performed. By rooting out certain
139 common subjects, gathering might become saner."
143 (defcustom gnus-summary-gather-subject-limit nil
144 "*Maximum length of subject comparisons when gathering loose threads.
145 Use nil to compare full subjects. Setting this variable to a low
146 number will help gather threads that have been corrupted by
147 newsreaders chopping off subject lines, but it might also mean that
148 unrelated articles that have subject that happen to begin with the
149 same few characters will be incorrectly gathered.
151 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
154 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "on" t)))
158 (defcustom gnus-simplify-subject-functions nil
159 "List of functions taking a string argument that simplify subjects.
160 The functions are applied recursively.
162 Useful functions to put in this list include:
163 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
164 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
166 :type '(repeat function))
168 (defcustom gnus-simplify-ignored-prefixes nil
169 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
171 :type '(choice (const :tag "off" nil)
174 (defcustom gnus-build-sparse-threads nil
175 "*If non-nil, fill in the gaps in threads.
176 If `some', only fill in the gaps that are needed to tie loose threads
177 together. If `more', fill in all leaf nodes that Gnus can find. If
178 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
180 :type '(choice (const :tag "off" nil)
183 (sexp :menu-tag "all" t)))
185 (defcustom gnus-summary-thread-gathering-function
186 'gnus-gather-threads-by-subject
187 "*Function used for gathering loose threads.
188 There are two pre-defined functions: `gnus-gather-threads-by-subject',
189 which only takes Subjects into consideration; and
190 `gnus-gather-threads-by-references', which compared the References
191 headers of the articles to find matches."
193 :type '(radio (function-item gnus-gather-threads-by-subject)
194 (function-item gnus-gather-threads-by-references)
195 (function :tag "other")))
197 (defcustom gnus-summary-same-subject ""
198 "*String indicating that the current article has the same subject as the previous.
199 This variable will only be used if the value of
200 `gnus-summary-make-false-root' is `empty'."
201 :group 'gnus-summary-format
204 (defcustom gnus-summary-goto-unread t
205 "*If t, many commands will go to the next unread article.
206 This applies to marking commands as well as other commands that
207 \"naturally\" select the next article, like, for instance, `SPC' at
208 the end of an article.
210 If nil, the marking commands do NOT go to the next unread article
211 \(they go to the next article instead). If `never', commands that
212 usually go to the next unread article, will go to the next article,
213 whether it is read or not."
214 :group 'gnus-summary-marks
215 :link '(custom-manual "(gnus)Setting Marks")
216 :type '(choice (const :tag "off" nil)
218 (sexp :menu-tag "on" t)))
220 (defcustom gnus-summary-default-score 0
221 "*Default article score level.
222 All scores generated by the score files will be added to this score.
223 If this variable is nil, scoring will be disabled."
224 :group 'gnus-score-default
225 :type '(choice (const :tag "disable")
228 (defcustom gnus-summary-default-high-score 0
229 "*Default threshold for a high scored article.
230 An article will be highlighted as high scored if its score is greater
233 :group 'gnus-score-default
236 (defcustom gnus-summary-default-low-score 0
237 "*Default threshold for a low scored article.
238 An article will be highlighted as low scored if its score is smaller
241 :group 'gnus-score-default
244 (defcustom gnus-summary-zcore-fuzz 0
245 "*Fuzziness factor for the zcore in the summary buffer.
246 Articles with scores closer than this to `gnus-summary-default-score'
248 :group 'gnus-summary-format
251 (defcustom gnus-simplify-subject-fuzzy-regexp nil
252 "*Strings to be removed when doing fuzzy matches.
253 This can either be a regular expression or list of regular expressions
254 that will be removed from subject strings if fuzzy subject
255 simplification is selected."
257 :type '(repeat regexp))
259 (defcustom gnus-show-threads t
260 "*If non-nil, display threads in summary mode."
264 (defcustom gnus-thread-hide-subtree nil
265 "*If non-nil, hide all threads initially.
266 This can be a predicate specifier which says which threads to hide.
267 If threads are hidden, you have to run the command
268 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
269 to expose hidden threads."
271 :type '(radio (sexp :format "Non-nil\n"
272 :match (lambda (widget value)
273 (not (or (consp value) (functionp value))))
276 (sexp :tag "Predicate specifier")))
278 (defcustom gnus-thread-hide-killed t
279 "*If non-nil, hide killed threads automatically."
283 (defcustom gnus-thread-ignore-subject t
284 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
285 If nil, articles that have different subjects from their parents will
286 start separate threads."
290 (defcustom gnus-thread-operation-ignore-subject t
291 "*If non-nil, subjects will be ignored when doing thread commands.
292 This affects commands like `gnus-summary-kill-thread' and
293 `gnus-summary-lower-thread'.
295 If this variable is nil, articles in the same thread with different
296 subjects will not be included in the operation in question. If this
297 variable is `fuzzy', only articles that have subjects that are fuzzily
298 equal will be included."
300 :type '(choice (const :tag "off" nil)
304 (defcustom gnus-thread-indent-level 4
305 "*Number that says how much each sub-thread should be indented."
309 (defcustom gnus-auto-extend-newsgroup t
310 "*If non-nil, extend newsgroup forward and backward when requested."
311 :group 'gnus-summary-choose
314 (defcustom gnus-auto-select-first t
315 "*If non-nil, select the article under point.
316 Which article this is is controlled by the `gnus-auto-select-subject'
319 If you want to prevent automatic selection of articles in some
320 newsgroups, set the variable to nil in `gnus-select-group-hook'."
321 :group 'gnus-group-select
322 :type '(choice (const :tag "none" nil)
323 (sexp :menu-tag "first" t)))
325 (defcustom gnus-auto-select-subject 'unread
326 "*Says what subject to place under point when entering a group.
328 This variable can either be the symbols `first' (place point on the
329 first subject), `unread' (place point on the subject line of the first
330 unread article), `best' (place point on the subject line of the
331 higest-scored article), `unseen' (place point on the subject line of
332 the first unseen article), 'unseen-or-unread' (place point on the subject
333 line of the first unseen article or, if all article have been seen, on the
334 subject line of the first unread article), or a function to be called to
335 place point on some subject line."
337 :group 'gnus-group-select
338 :type '(choice (const best)
342 (const unseen-or-unread)))
344 (defcustom gnus-dont-select-after-jump-to-other-group nil
345 "If non-nil, don't select the first unread article after entering the
346 other group by the command `gnus-summary-jump-to-other-group'. If nil,
347 it is depend on the value of `gnus-auto-select-first' whether to select
349 :group 'gnus-group-select
352 (defcustom gnus-auto-select-next t
353 "*If non-nil, offer to go to the next group from the end of the previous.
354 If the value is t and the next newsgroup is empty, Gnus will exit
355 summary mode and go back to group mode. If the value is neither nil
356 nor t, Gnus will select the following unread newsgroup. In
357 particular, if the value is the symbol `quietly', the next unread
358 newsgroup will be selected without any confirmation, and if it is
359 `almost-quietly', the next group will be selected without any
360 confirmation if you are located on the last article in the group.
361 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
362 will go to the next group without confirmation."
363 :group 'gnus-summary-maneuvering
364 :type '(choice (const :tag "off" nil)
366 (const almost-quietly)
367 (const slightly-quietly)
368 (sexp :menu-tag "on" t)))
370 (defcustom gnus-auto-select-same nil
371 "*If non-nil, select the next article with the same subject.
372 If there are no more articles with the same subject, go to
373 the first unread article."
374 :group 'gnus-summary-maneuvering
377 (defcustom gnus-auto-goto-ignores 'unfetched
378 "*Says how to handle unfetched articles when maneuvering.
380 This variable can either be the symbols nil (maneuver to any
381 article), `undownloaded' (maneuvering while unplugged ignores articles
382 that have not been fetched), `always-undownloaded' (maneuvering always
383 ignores articles that have not been fetched), `unfetched' (maneuvering
384 ignores articles whose headers have not been fetched).
386 NOTE: The list of unfetched articles will always be nil when plugged
387 and, when unplugged, a subset of the undownloaded article list."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "None" nil)
391 (const :tag "Undownloaded when unplugged" undownloaded)
392 (const :tag "Undownloaded" always-undownloaded)
393 (const :tag "Unfetched" unfetched)))
395 (defcustom gnus-summary-check-current nil
396 "*If non-nil, consider the current article when moving.
397 The \"unread\" movement commands will stay on the same line if the
398 current article is unread."
399 :group 'gnus-summary-maneuvering
402 (defcustom gnus-auto-center-summary 2
403 "*If non-nil, always center the current summary buffer.
404 In particular, if `vertical' do only vertical recentering. If non-nil
405 and non-`vertical', do both horizontal and vertical recentering."
406 :group 'gnus-summary-maneuvering
407 :type '(choice (const :tag "none" nil)
409 (integer :tag "height")
410 (sexp :menu-tag "both" t)))
412 (defvar gnus-auto-center-group t
413 "*If non-nil, always center the group buffer.")
415 (defcustom gnus-show-all-headers nil
416 "*If non-nil, don't hide any headers."
417 :group 'gnus-article-hiding
418 :group 'gnus-article-headers
421 (defcustom gnus-summary-ignore-duplicates nil
422 "*If non-nil, ignore articles with identical Message-ID headers."
426 (defcustom gnus-single-article-buffer t
427 "*If non-nil, display all articles in the same buffer.
428 If nil, each group will get its own article buffer."
429 :group 'gnus-article-various
432 (defcustom gnus-break-pages t
433 "*If non-nil, do page breaking on articles.
434 The page delimiter is specified by the `gnus-page-delimiter'
436 :group 'gnus-article-various
439 (defcustom gnus-show-mime t
440 "*If non-nil, do mime processing of articles.
441 The articles will simply be fed to the function given by
442 `gnus-article-display-method-for-mime'."
443 :group 'gnus-article-mime
446 (defcustom gnus-move-split-methods nil
447 "*Variable used to suggest where articles are to be moved to.
448 It uses the same syntax as the `gnus-split-methods' variable.
449 However, whereas `gnus-split-methods' specifies file names as targets,
450 this variable specifies group names."
451 :group 'gnus-summary-mail
452 :type '(repeat (choice (list :value (fun) function)
453 (cons :value ("" "") regexp (repeat string))
456 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
457 "Function used to compute default prefix for article move/copy/etc prompts.
458 The function should take one argument, a group name, and return a
459 string with the suggested prefix."
460 :group 'gnus-summary-mail
463 ;; FIXME: Although the custom type is `character' for the following variables,
464 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
466 (defcustom gnus-unread-mark ?\ ;;;Whitespace
467 "*Mark used for unread articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-ticked-mark ?!
472 "*Mark used for ticked articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-dormant-mark ??
477 "*Mark used for dormant articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-del-mark ?r
482 "*Mark used for del'd articles."
483 :group 'gnus-summary-marks
486 (defcustom gnus-read-mark ?R
487 "*Mark used for read articles."
488 :group 'gnus-summary-marks
491 (defcustom gnus-expirable-mark ?E
492 "*Mark used for expirable articles."
493 :group 'gnus-summary-marks
496 (defcustom gnus-killed-mark ?K
497 "*Mark used for killed articles."
498 :group 'gnus-summary-marks
501 (defcustom gnus-spam-mark ?$
502 "*Mark used for spam articles."
504 :group 'gnus-summary-marks
507 (defcustom gnus-souped-mark ?F
508 "*Mark used for souped articles."
509 :group 'gnus-summary-marks
512 (defcustom gnus-kill-file-mark ?X
513 "*Mark used for articles killed by kill files."
514 :group 'gnus-summary-marks
517 (defcustom gnus-low-score-mark ?Y
518 "*Mark used for articles with a low score."
519 :group 'gnus-summary-marks
522 (defcustom gnus-catchup-mark ?C
523 "*Mark used for articles that are caught up."
524 :group 'gnus-summary-marks
527 (defcustom gnus-replied-mark ?A
528 "*Mark used for articles that have been replied to."
529 :group 'gnus-summary-marks
532 (defcustom gnus-forwarded-mark ?F
533 "*Mark used for articles that have been forwarded."
535 :group 'gnus-summary-marks
538 (defcustom gnus-recent-mark ?N
539 "*Mark used for articles that are recent."
541 :group 'gnus-summary-marks
544 (defcustom gnus-cached-mark ?*
545 "*Mark used for articles that are in the cache."
546 :group 'gnus-summary-marks
549 (defcustom gnus-saved-mark ?S
550 "*Mark used for articles that have been saved."
551 :group 'gnus-summary-marks
554 (defcustom gnus-unseen-mark ?.
555 "*Mark used for articles that haven't been seen."
557 :group 'gnus-summary-marks
560 (defcustom gnus-no-mark ?\ ;;;Whitespace
561 "*Mark used for articles that have no other secondary mark."
563 :group 'gnus-summary-marks
566 (defcustom gnus-ancient-mark ?O
567 "*Mark used for ancient articles."
568 :group 'gnus-summary-marks
571 (defcustom gnus-sparse-mark ?Q
572 "*Mark used for sparsely reffed articles."
573 :group 'gnus-summary-marks
576 (defcustom gnus-canceled-mark ?G
577 "*Mark used for canceled articles."
578 :group 'gnus-summary-marks
581 (defcustom gnus-duplicate-mark ?M
582 "*Mark used for duplicate articles."
583 :group 'gnus-summary-marks
586 (defcustom gnus-undownloaded-mark ?-
587 "*Mark used for articles that weren't downloaded."
589 :group 'gnus-summary-marks
592 (defcustom gnus-downloaded-mark ?+
593 "*Mark used for articles that were downloaded."
594 :group 'gnus-summary-marks
597 (defcustom gnus-downloadable-mark ?%
598 "*Mark used for articles that are to be downloaded."
599 :group 'gnus-summary-marks
602 (defcustom gnus-unsendable-mark ?=
603 "*Mark used for articles that won't be sent."
604 :group 'gnus-summary-marks
607 (defcustom gnus-score-over-mark ?+
608 "*Score mark used for articles with high scores."
609 :group 'gnus-summary-marks
612 (defcustom gnus-score-below-mark ?-
613 "*Score mark used for articles with low scores."
614 :group 'gnus-summary-marks
617 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
618 "*There is no thread under the article."
619 :group 'gnus-summary-marks
622 (defcustom gnus-not-empty-thread-mark ?=
623 "*There is a thread under the article."
624 :group 'gnus-summary-marks
627 (defcustom gnus-view-pseudo-asynchronously nil
628 "*If non-nil, Gnus will view pseudo-articles asynchronously."
629 :group 'gnus-extract-view
632 (defcustom gnus-auto-expirable-marks
633 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
634 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
635 gnus-souped-mark gnus-duplicate-mark)
636 "*The list of marks converted into expiration if a group is auto-expirable."
639 :type '(repeat character))
641 (defcustom gnus-inhibit-user-auto-expire t
642 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
647 (defcustom gnus-view-pseudos nil
648 "*If `automatic', pseudo-articles will be viewed automatically.
649 If `not-confirm', pseudos will be viewed automatically, and the user
650 will not be asked to confirm the command."
651 :group 'gnus-extract-view
652 :type '(choice (const :tag "off" nil)
654 (const not-confirm)))
656 (defcustom gnus-view-pseudos-separately t
657 "*If non-nil, one pseudo-article will be created for each file to be viewed.
658 If nil, all files that use the same viewing command will be given as a
659 list of parameters to that command."
660 :group 'gnus-extract-view
663 (defcustom gnus-insert-pseudo-articles t
664 "*If non-nil, insert pseudo-articles when decoding articles."
665 :group 'gnus-extract-view
668 (defcustom gnus-summary-dummy-line-format
670 "*The format specification for the dummy roots in the summary buffer.
671 It works along the same lines as a normal formatting string,
672 with some simple extensions.
676 General format specifiers can also be used.
677 See `(gnus)Formatting Variables'."
678 :link '(custom-manual "(gnus)Formatting Variables")
679 :group 'gnus-threading
682 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
683 "*The format specification for the summary mode line.
684 It works along the same lines as a normal formatting string,
685 with some simple extensions:
688 %p Unprefixed group name
689 %A Current article number
690 %z Current article score
692 %U Number of unread articles in the group
693 %e Number of unselected articles in the group
694 %Z A string with unread/unselected article counts
695 %g Shortish group name
696 %S Subject of the current article
698 %s Current score file name
699 %d Number of dormant articles
700 %r Number of articles that have been marked as read in this session
701 %E Number of articles expunged by the score files"
702 :group 'gnus-summary-format
705 (defcustom gnus-list-identifiers nil
706 "Regexp that matches list identifiers to be removed from subject.
707 This can also be a list of regexps."
709 :group 'gnus-summary-format
710 :group 'gnus-article-hiding
711 :type '(choice (const :tag "none" nil)
713 (repeat :value (".*") regexp)))
715 (defcustom gnus-summary-mark-below 0
716 "*Mark all articles with a score below this variable as read.
717 This variable is local to each summary buffer and usually set by the
719 :group 'gnus-score-default
722 (defun gnus-widget-reversible-match (widget value)
723 "Ignoring WIDGET, convert VALUE to internal form.
724 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
728 (eq (length value) 2)
729 (eq (nth 0 value) 'not)
730 (symbolp (nth 1 value)))))
732 (defun gnus-widget-reversible-to-internal (widget value)
733 "Ignoring WIDGET, convert VALUE to internal form.
734 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
735 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
739 (list (nth 1 value) t)))
741 (defun gnus-widget-reversible-to-external (widget value)
742 "Ignoring WIDGET, convert VALUE to external form.
743 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
744 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
747 (list 'not (nth 0 value))
750 (define-widget 'gnus-widget-reversible 'group
751 "A `group' that convert values."
752 :match 'gnus-widget-reversible-match
753 :value-to-internal 'gnus-widget-reversible-to-internal
754 :value-to-external 'gnus-widget-reversible-to-external)
756 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
757 "*List of functions used for sorting articles in the summary buffer.
759 Each function takes two articles and returns non-nil if the first
760 article should be sorted before the other. If you use more than one
761 function, the primary sort function should be the last. You should
762 probably always include `gnus-article-sort-by-number' in the list of
763 sorting functions -- preferably first. Also note that sorting by date
764 is often much slower than sorting by number, and the sorting order is
765 very similar. (Sorting by date means sorting by the time the message
766 was sent, sorting by number means sorting by arrival time.)
768 Each item can also be a list `(not F)' where F is a function;
769 this reverses the sort order.
771 Ready-made functions include `gnus-article-sort-by-number',
772 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
773 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
774 and `gnus-article-sort-by-score'.
776 When threading is turned on, the variable `gnus-thread-sort-functions'
777 controls how articles are sorted."
778 :group 'gnus-summary-sort
779 :type '(repeat (gnus-widget-reversible
780 (choice (function-item gnus-article-sort-by-number)
781 (function-item gnus-article-sort-by-author)
782 (function-item gnus-article-sort-by-subject)
783 (function-item gnus-article-sort-by-date)
784 (function-item gnus-article-sort-by-score)
785 (function-item gnus-article-sort-by-random)
786 (function :tag "other"))
787 (boolean :tag "Reverse order"))))
790 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
791 "*List of functions used for sorting threads in the summary buffer.
792 By default, threads are sorted by article number.
794 Each function takes two threads and returns non-nil if the first
795 thread should be sorted before the other. If you use more than one
796 function, the primary sort function should be the last. You should
797 probably always include `gnus-thread-sort-by-number' in the list of
798 sorting functions -- preferably first. Also note that sorting by date
799 is often much slower than sorting by number, and the sorting order is
800 very similar. (Sorting by date means sorting by the time the message
801 was sent, sorting by number means sorting by arrival time.)
803 Each list item can also be a list `(not F)' where F is a
804 function; this specifies reversed sort order.
806 Ready-made functions include `gnus-thread-sort-by-number',
807 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
808 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
809 `gnus-thread-sort-by-most-recent-number',
810 `gnus-thread-sort-by-most-recent-date',
811 `gnus-thread-sort-by-random', and
812 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
814 When threading is turned off, the variable
815 `gnus-article-sort-functions' controls how articles are sorted."
816 :group 'gnus-summary-sort
818 (gnus-widget-reversible
819 (choice (function-item gnus-thread-sort-by-number)
820 (function-item gnus-thread-sort-by-author)
821 (function-item gnus-thread-sort-by-subject)
822 (function-item gnus-thread-sort-by-date)
823 (function-item gnus-thread-sort-by-score)
824 (function-item gnus-thread-sort-by-most-recent-number)
825 (function-item gnus-thread-sort-by-most-recent-date)
826 (function-item gnus-thread-sort-by-random)
827 (function-item gnus-thread-sort-by-total-score)
828 (function :tag "other"))
829 (boolean :tag "Reverse order"))))
831 (defcustom gnus-thread-score-function '+
832 "*Function used for calculating the total score of a thread.
834 The function is called with the scores of the article and each
835 subthread and should then return the score of the thread.
837 Some functions you can use are `+', `max', or `min'."
838 :group 'gnus-summary-sort
841 (defcustom gnus-summary-expunge-below nil
842 "All articles that have a score less than this variable will be expunged.
843 This variable is local to the summary buffers."
844 :group 'gnus-score-default
845 :type '(choice (const :tag "off" nil)
848 (defcustom gnus-thread-expunge-below nil
849 "All threads that have a total score less than this variable will be expunged.
850 See `gnus-thread-score-function' for en explanation of what a
853 This variable is local to the summary buffers."
854 :group 'gnus-threading
855 :group 'gnus-score-default
856 :type '(choice (const :tag "off" nil)
859 (defcustom gnus-summary-mode-hook nil
860 "*A hook for Gnus summary mode.
861 This hook is run before any variables are set in the summary buffer."
862 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
863 :group 'gnus-summary-various
866 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
867 (when (featurep 'xemacs)
868 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
869 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
870 (add-hook 'gnus-summary-mode-hook
871 'gnus-xmas-switch-horizontal-scrollbar-off))
873 (defcustom gnus-summary-menu-hook nil
874 "*Hook run after the creation of the summary mode menu."
875 :group 'gnus-summary-visual
878 (defcustom gnus-summary-exit-hook nil
879 "*A hook called on exit from the summary buffer.
880 It will be called with point in the group buffer."
881 :group 'gnus-summary-exit
884 (defcustom gnus-summary-prepare-hook nil
885 "*A hook called after the summary buffer has been generated.
886 If you want to modify the summary buffer, you can use this hook."
887 :group 'gnus-summary-various
890 (defcustom gnus-summary-prepared-hook nil
891 "*A hook called as the last thing after the summary buffer has been generated."
892 :group 'gnus-summary-various
895 (defcustom gnus-summary-generate-hook nil
896 "*A hook run just before generating the summary buffer.
897 This hook is commonly used to customize threading variables and the
899 :group 'gnus-summary-various
902 (defcustom gnus-select-group-hook nil
903 "*A hook called when a newsgroup is selected.
905 If you'd like to simplify subjects like the
906 `gnus-summary-next-same-subject' command does, you can use the
909 (add-hook gnus-select-group-hook
911 (mapcar (lambda (header)
912 (mail-header-set-subject
914 (gnus-simplify-subject
915 (mail-header-subject header) 're-only)))
916 gnus-newsgroup-headers)))"
917 :group 'gnus-group-select
920 (defcustom gnus-select-article-hook nil
921 "*A hook called when an article is selected."
922 :group 'gnus-summary-choose
923 :options '(gnus-agent-fetch-selected-article)
926 (defcustom gnus-visual-mark-article-hook
927 (list 'gnus-highlight-selected-summary)
928 "*Hook run after selecting an article in the summary buffer.
929 It is meant to be used for highlighting the article in some way. It
930 is not run if `gnus-visual' is nil."
931 :group 'gnus-summary-visual
934 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
935 "*A hook called before parsing the headers."
939 (defcustom gnus-exit-group-hook nil
940 "*A hook called when exiting summary mode.
941 This hook is not called from the non-updating exit commands like `Q'."
945 (defcustom gnus-summary-update-hook
946 (list 'gnus-summary-highlight-line)
947 "*A hook called when a summary line is changed.
948 The hook will not be called if `gnus-visual' is nil.
950 The default function `gnus-summary-highlight-line' will
951 highlight the line according to the `gnus-summary-highlight'
953 :group 'gnus-summary-visual
956 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
957 "*A hook called when an article is selected for the first time.
958 The hook is intended to mark an article as read (or unread)
959 automatically when it is selected."
960 :group 'gnus-summary-choose
963 (defcustom gnus-group-no-more-groups-hook nil
964 "*A hook run when returning to group mode having no more (unread) groups."
965 :group 'gnus-group-select
968 (defcustom gnus-ps-print-hook nil
969 "*A hook run before ps-printing something from Gnus."
973 (defcustom gnus-summary-article-move-hook nil
974 "*A hook called after an article is moved, copied, respooled, or crossposted."
979 (defcustom gnus-summary-article-delete-hook nil
980 "*A hook called after an article is deleted."
985 (defcustom gnus-summary-article-expire-hook nil
986 "*A hook called after an article is expired."
991 (defcustom gnus-summary-display-arrow
992 (and (fboundp 'display-graphic-p)
994 "*If non-nil, display an arrow highlighting the current article."
999 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
1000 "Face used for highlighting the current article in the summary buffer."
1001 :group 'gnus-summary-visual
1004 (defvar gnus-tmp-downloaded nil)
1006 (defcustom gnus-summary-highlight
1007 '(((eq mark gnus-canceled-mark)
1008 . gnus-summary-cancelled-face)
1009 ((and uncached (> score default-high))
1010 . gnus-summary-high-undownloaded-face)
1011 ((and uncached (< score default-low))
1012 . gnus-summary-low-undownloaded-face)
1014 . gnus-summary-normal-undownloaded-face)
1015 ((and (> score default-high)
1016 (or (eq mark gnus-dormant-mark)
1017 (eq mark gnus-ticked-mark)))
1018 . gnus-summary-high-ticked-face)
1019 ((and (< score default-low)
1020 (or (eq mark gnus-dormant-mark)
1021 (eq mark gnus-ticked-mark)))
1022 . gnus-summary-low-ticked-face)
1023 ((or (eq mark gnus-dormant-mark)
1024 (eq mark gnus-ticked-mark))
1025 . gnus-summary-normal-ticked-face)
1026 ((and (> score default-high) (eq mark gnus-ancient-mark))
1027 . gnus-summary-high-ancient-face)
1028 ((and (< score default-low) (eq mark gnus-ancient-mark))
1029 . gnus-summary-low-ancient-face)
1030 ((eq mark gnus-ancient-mark)
1031 . gnus-summary-normal-ancient-face)
1032 ((and (> score default-high) (eq mark gnus-unread-mark))
1033 . gnus-summary-high-unread-face)
1034 ((and (< score default-low) (eq mark gnus-unread-mark))
1035 . gnus-summary-low-unread-face)
1036 ((eq mark gnus-unread-mark)
1037 . gnus-summary-normal-unread-face)
1038 ((> score default-high)
1039 . gnus-summary-high-read-face)
1040 ((< score default-low)
1041 . gnus-summary-low-read-face)
1043 . gnus-summary-normal-read-face))
1044 "*Controls the highlighting of summary buffer lines.
1046 A list of (FORM . FACE) pairs. When deciding how a a particular
1047 summary line should be displayed, each form is evaluated. The content
1048 of the face field after the first true form is used. You can change
1049 how those summary lines are displayed, by editing the face field.
1051 You can use the following variables in the FORM field.
1053 score: The article's score
1054 default: The default article score.
1055 default-high: The default score for high scored articles.
1056 default-low: The default score for low scored articles.
1057 below: The score below which articles are automatically marked as read.
1058 mark: The article's mark.
1059 uncached: Non-nil if the article is uncached."
1060 :group 'gnus-summary-visual
1061 :type '(repeat (cons (sexp :tag "Form" nil)
1064 (defcustom gnus-alter-header-function nil
1065 "Function called to allow alteration of article header structures.
1066 The function is called with one parameter, the article header vector,
1067 which it may alter in any way."
1068 :type '(choice (const :tag "None" nil)
1070 :group 'gnus-summary)
1072 (defvar gnus-decode-encoded-word-function
1073 (mime-find-field-decoder 'From 'nov)
1074 "Variable that says which function should be used to decode a string with encoded words.")
1076 (defcustom gnus-extra-headers '(To Newsgroups)
1077 "*Extra headers to parse."
1079 :group 'gnus-summary
1080 :type '(repeat symbol))
1082 (defcustom gnus-ignored-from-addresses
1083 (and user-mail-address (regexp-quote user-mail-address))
1084 "*Regexp of From headers that may be suppressed in favor of To headers."
1086 :group 'gnus-summary
1089 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1090 "List of charsets that should be ignored.
1091 When these charsets are used in the \"charset\" parameter, the
1092 default charset will be used instead."
1094 :type '(repeat symbol)
1095 :group 'gnus-charset)
1097 (gnus-define-group-parameter
1101 "Return the ignored charsets of GROUP."
1102 :variable gnus-group-ignored-charsets-alist
1104 '(("alt\\.chinese\\.text" iso-8859-1))
1106 "Alist of regexps (to match group names) and charsets that should be ignored.
1107 When these charsets are used in the \"charset\" parameter, the
1108 default charset will be used instead."
1109 :variable-group gnus-charset
1110 :variable-type '(repeat (cons (regexp :tag "Group")
1112 :parameter-type '(choice :tag "Ignored charsets"
1115 :parameter-document "\
1116 List of charsets that should be ignored.
1118 When these charsets are used in the \"charset\" parameter, the
1119 default charset will be used instead.")
1121 (defcustom gnus-group-highlight-words-alist nil
1122 "Alist of group regexps and highlight regexps.
1123 This variable uses the same syntax as `gnus-emphasis-alist'."
1125 :type '(repeat (cons (regexp :tag "Group")
1126 (repeat (list (regexp :tag "Highlight regexp")
1127 (number :tag "Group for entire word" 0)
1128 (number :tag "Group for displayed part" 0)
1130 gnus-emphasis-highlight-words)))))
1131 :group 'gnus-summary-visual)
1133 (defcustom gnus-use-wheel nil
1134 "Use Intelli-mouse on summary movement"
1136 :group 'gnus-summary-maneuvering)
1138 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1139 "Amount to scroll messages by spinning the mouse wheel.
1140 This is actually a cons cell, where the first item is the amount to scroll
1141 on a normal wheel event, and the second is the amount to scroll when the
1142 wheel is moved with the shift key depressed."
1143 :type '(cons (integer :tag "Shift") integer)
1144 :group 'gnus-summary-maneuvering)
1146 (defcustom gnus-wheel-edge-resistance 2
1147 "How hard it should be to change the current article
1148 by moving the mouse over the edge of the article window."
1150 :group 'gnus-summary-maneuvering)
1152 (defcustom gnus-summary-show-article-charset-alist
1154 "Alist of number and charset.
1155 The article will be shown with the charset corresponding to the
1157 For example: ((1 . cn-gb-2312) (2 . big5))."
1159 :type '(repeat (cons (number :tag "Argument" 1)
1160 (symbol :tag "Charset")))
1161 :group 'gnus-charset)
1163 (defcustom gnus-preserve-marks t
1164 "Whether marks are preserved when moving, copying and respooling messages."
1167 :group 'gnus-summary-marks)
1169 (defcustom gnus-alter-articles-to-read-function nil
1170 "Function to be called to alter the list of articles to be selected."
1171 :type '(choice (const nil) function)
1172 :group 'gnus-summary)
1174 (defcustom gnus-orphan-score nil
1175 "*All orphans get this score added. Set in the score file."
1176 :group 'gnus-score-default
1177 :type '(choice (const nil)
1180 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1181 "*A regexp to match MIME parts when saving multiple parts of a
1182 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1183 This regexp will be used by default when prompting the user for which
1184 type of files to save."
1185 :group 'gnus-summary
1188 (defcustom gnus-read-all-available-headers nil
1189 "Whether Gnus should parse all headers made available to it.
1190 This is mostly relevant for slow back ends where the user may
1191 wish to widen the summary buffer to include all headers
1192 that were fetched. Say, for nnultimate groups."
1194 :group 'gnus-summary
1195 :type '(choice boolean regexp))
1197 (defcustom gnus-summary-muttprint-program "muttprint"
1198 "Command (and optional arguments) used to run Muttprint."
1200 :group 'gnus-summary
1203 (defcustom gnus-article-loose-mime t
1204 "If non-nil, don't require MIME-Version header.
1205 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1206 supply the MIME-Version header or deliberately strip it from the mail.
1207 If non-nil (the default), Gnus will treat some articles as MIME
1208 even if the MIME-Version header is missing."
1211 :group 'gnus-article-mime)
1213 (defcustom gnus-article-emulate-mime t
1214 "If non-nil, use MIME emulation for uuencode and the like.
1215 This means that Gnus will search message bodies for text that look
1216 like uuencoded bits, yEncoded bits, and so on, and present that using
1217 the normal Gnus MIME machinery."
1220 :group 'gnus-article-mime)
1222 ;;; Internal variables
1224 (defvar gnus-summary-display-cache nil)
1225 (defvar gnus-article-mime-handles nil)
1226 (defvar gnus-article-decoded-p nil)
1227 (defvar gnus-article-charset nil)
1228 (defvar gnus-article-ignored-charsets nil)
1229 (defvar gnus-scores-exclude-files nil)
1230 (defvar gnus-page-broken nil)
1232 (defvar gnus-original-article nil)
1233 (defvar gnus-article-internal-prepare-hook nil)
1234 (defvar gnus-newsgroup-process-stack nil)
1236 (defvar gnus-thread-indent-array nil)
1237 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1238 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1239 "Function called to sort the articles within a thread after it has been gathered together.")
1241 (defvar gnus-summary-save-parts-type-history nil)
1242 (defvar gnus-summary-save-parts-last-directory nil)
1244 ;; Avoid highlighting in kill files.
1245 (defvar gnus-summary-inhibit-highlight nil)
1246 (defvar gnus-newsgroup-selected-overlay nil)
1247 (defvar gnus-inhibit-limiting nil)
1248 (defvar gnus-newsgroup-adaptive-score-file nil)
1249 (defvar gnus-current-score-file nil)
1250 (defvar gnus-current-move-group nil)
1251 (defvar gnus-current-copy-group nil)
1252 (defvar gnus-current-crosspost-group nil)
1253 (defvar gnus-newsgroup-display nil)
1255 (defvar gnus-newsgroup-dependencies nil)
1256 (defvar gnus-newsgroup-adaptive nil)
1257 (defvar gnus-summary-display-article-function nil)
1258 (defvar gnus-summary-highlight-line-function nil
1259 "Function called after highlighting a summary line.")
1261 (defvar gnus-summary-line-format-alist
1262 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1263 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1264 (?s gnus-tmp-subject-or-nil ?s)
1265 (?n gnus-tmp-name ?s)
1266 (?A (std11-address-string
1267 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1268 (?a (or (std11-full-name-string
1269 (car (mime-entity-read-field gnus-tmp-header 'From)))
1271 (?F gnus-tmp-from ?s)
1272 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1273 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1274 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1275 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1276 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1277 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1278 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1279 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1280 (?L gnus-tmp-lines ?s)
1281 (?O gnus-tmp-downloaded ?c)
1282 (?I gnus-tmp-indentation ?s)
1283 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1284 (?R gnus-tmp-replied ?c)
1285 (?\[ gnus-tmp-opening-bracket ?c)
1286 (?\] gnus-tmp-closing-bracket ?c)
1287 (?\> (make-string gnus-tmp-level ? ) ?s)
1288 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1289 (?i gnus-tmp-score ?d)
1290 (?z gnus-tmp-score-char ?c)
1291 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1292 (?U gnus-tmp-unread ?c)
1293 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1295 (?t (gnus-summary-number-of-articles-in-thread
1296 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1298 (?e (gnus-summary-number-of-articles-in-thread
1299 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1301 (?u gnus-tmp-user-defined ?s)
1302 (?P (gnus-pick-line-number) ?d)
1303 (?B gnus-tmp-thread-tree-header-string ?s)
1304 (user-date (gnus-user-date
1305 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1306 "An alist of format specifications that can appear in summary lines.
1307 These are paired with what variables they correspond with, along with
1308 the type of the variable (string, integer, character, etc).")
1310 (defvar gnus-summary-dummy-line-format-alist
1311 `((?S gnus-tmp-subject ?s)
1312 (?N gnus-tmp-number ?d)
1313 (?u gnus-tmp-user-defined ?s)))
1315 (defvar gnus-summary-mode-line-format-alist
1316 `((?G gnus-tmp-group-name ?s)
1317 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1318 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1319 (?A gnus-tmp-article-number ?d)
1320 (?Z gnus-tmp-unread-and-unselected ?s)
1321 (?V gnus-version ?s)
1322 (?U gnus-tmp-unread-and-unticked ?d)
1323 (?S gnus-tmp-subject ?s)
1324 (?e gnus-tmp-unselected ?d)
1325 (?u gnus-tmp-user-defined ?s)
1326 (?d (length gnus-newsgroup-dormant) ?d)
1327 (?t (length gnus-newsgroup-marked) ?d)
1328 (?h (length gnus-newsgroup-spam-marked) ?d)
1329 (?r (length gnus-newsgroup-reads) ?d)
1330 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1331 (?E gnus-newsgroup-expunged-tally ?d)
1332 (?s (gnus-current-score-file-nondirectory) ?s)))
1334 (defvar gnus-last-search-regexp nil
1335 "Default regexp for article search command.")
1337 (defvar gnus-summary-search-article-matched-data nil
1338 "Last matched data of article search command. It is the local variable
1339 in `gnus-article-buffer' which consists of the list of start position,
1340 end position and text.")
1342 (defvar gnus-last-shell-command nil
1343 "Default shell command on article.")
1345 (defvar gnus-newsgroup-agentized nil
1346 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1347 (defvar gnus-newsgroup-begin nil)
1348 (defvar gnus-newsgroup-end nil)
1349 (defvar gnus-newsgroup-last-rmail nil)
1350 (defvar gnus-newsgroup-last-mail nil)
1351 (defvar gnus-newsgroup-last-folder nil)
1352 (defvar gnus-newsgroup-last-file nil)
1353 (defvar gnus-newsgroup-auto-expire nil)
1354 (defvar gnus-newsgroup-active nil)
1356 (defvar gnus-newsgroup-data nil)
1357 (defvar gnus-newsgroup-data-reverse nil)
1358 (defvar gnus-newsgroup-limit nil)
1359 (defvar gnus-newsgroup-limits nil)
1360 (defvar gnus-summary-use-undownloaded-faces nil)
1362 (defvar gnus-newsgroup-unreads nil
1363 "Sorted list of unread articles in the current newsgroup.")
1365 (defvar gnus-newsgroup-unselected nil
1366 "Sorted list of unselected unread articles in the current newsgroup.")
1368 (defvar gnus-newsgroup-reads nil
1369 "Alist of read articles and article marks in the current newsgroup.")
1371 (defvar gnus-newsgroup-expunged-tally nil)
1373 (defvar gnus-newsgroup-marked nil
1374 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1376 (defvar gnus-newsgroup-spam-marked nil
1377 "List of ranges of articles that have been marked as spam.")
1379 (defvar gnus-newsgroup-killed nil
1380 "List of ranges of articles that have been through the scoring process.")
1382 (defvar gnus-newsgroup-cached nil
1383 "Sorted list of articles that come from the article cache.")
1385 (defvar gnus-newsgroup-saved nil
1386 "List of articles that have been saved.")
1388 (defvar gnus-newsgroup-kill-headers nil)
1390 (defvar gnus-newsgroup-replied nil
1391 "List of articles that have been replied to in the current newsgroup.")
1393 (defvar gnus-newsgroup-forwarded nil
1394 "List of articles that have been forwarded in the current newsgroup.")
1396 (defvar gnus-newsgroup-recent nil
1397 "List of articles that have are recent in the current newsgroup.")
1399 (defvar gnus-newsgroup-expirable nil
1400 "Sorted list of articles in the current newsgroup that can be expired.")
1402 (defvar gnus-newsgroup-processable nil
1403 "List of articles in the current newsgroup that can be processed.")
1405 (defvar gnus-newsgroup-downloadable nil
1406 "Sorted list of articles in the current newsgroup that can be processed.")
1408 (defvar gnus-newsgroup-unfetched nil
1409 "Sorted list of articles in the current newsgroup whose headers have
1410 not been fetched into the agent.
1412 This list will always be a subset of gnus-newsgroup-undownloaded.")
1414 (defvar gnus-newsgroup-undownloaded nil
1415 "List of articles in the current newsgroup that haven't been downloaded.")
1417 (defvar gnus-newsgroup-unsendable nil
1418 "List of articles in the current newsgroup that won't be sent.")
1420 (defvar gnus-newsgroup-bookmarks nil
1421 "List of articles in the current newsgroup that have bookmarks.")
1423 (defvar gnus-newsgroup-dormant nil
1424 "Sorted list of dormant articles in the current newsgroup.")
1426 (defvar gnus-newsgroup-unseen nil
1427 "List of unseen articles in the current newsgroup.")
1429 (defvar gnus-newsgroup-seen nil
1430 "Range of seen articles in the current newsgroup.")
1432 (defvar gnus-newsgroup-articles nil
1433 "List of articles in the current newsgroup.")
1435 (defvar gnus-newsgroup-scored nil
1436 "List of scored articles in the current newsgroup.")
1438 (defvar gnus-newsgroup-incorporated nil
1439 "List of incorporated articles in the current newsgroup.")
1441 (defvar gnus-newsgroup-headers nil
1442 "List of article headers in the current newsgroup.")
1444 (defvar gnus-newsgroup-threads nil)
1446 (defvar gnus-newsgroup-prepared nil
1447 "Whether the current group has been prepared properly.")
1449 (defvar gnus-newsgroup-ancient nil
1450 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1452 (defvar gnus-newsgroup-sparse nil)
1454 (defvar gnus-current-article nil)
1455 (defvar gnus-article-current nil)
1456 (defvar gnus-current-headers nil)
1457 (defvar gnus-have-all-headers nil)
1458 (defvar gnus-last-article nil)
1459 (defvar gnus-newsgroup-history nil)
1460 (defvar gnus-newsgroup-charset nil)
1461 (defvar gnus-newsgroup-ephemeral-charset nil)
1462 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1464 (defvar gnus-article-before-search nil)
1466 (defvar gnus-summary-local-variables
1467 '(gnus-newsgroup-name
1468 gnus-newsgroup-begin gnus-newsgroup-end
1469 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1470 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1471 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1472 gnus-newsgroup-unselected gnus-newsgroup-marked
1473 gnus-newsgroup-spam-marked
1474 gnus-newsgroup-reads gnus-newsgroup-saved
1475 gnus-newsgroup-replied gnus-newsgroup-forwarded
1476 gnus-newsgroup-recent
1477 gnus-newsgroup-expirable
1478 gnus-newsgroup-processable gnus-newsgroup-killed
1479 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1480 gnus-newsgroup-unfetched
1481 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1482 gnus-newsgroup-seen gnus-newsgroup-articles
1483 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1484 gnus-newsgroup-headers gnus-newsgroup-threads
1485 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1486 gnus-current-article gnus-current-headers gnus-have-all-headers
1487 gnus-last-article gnus-article-internal-prepare-hook
1488 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1489 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1490 gnus-thread-expunge-below
1491 gnus-score-alist gnus-current-score-file
1492 (gnus-summary-expunge-below . global)
1493 (gnus-summary-mark-below . global)
1494 (gnus-orphan-score . global)
1495 gnus-newsgroup-active gnus-scores-exclude-files
1496 gnus-newsgroup-history gnus-newsgroup-ancient
1497 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1498 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1499 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1500 (gnus-newsgroup-expunged-tally . 0)
1501 gnus-cache-removable-articles gnus-newsgroup-cached
1502 gnus-newsgroup-data gnus-newsgroup-data-reverse
1503 gnus-newsgroup-limit gnus-newsgroup-limits
1504 gnus-newsgroup-charset gnus-newsgroup-display
1505 gnus-summary-use-undownloaded-faces
1506 gnus-newsgroup-incorporated)
1507 "Variables that are buffer-local to the summary buffers.")
1509 (defvar gnus-newsgroup-variables nil
1510 "A list of variables that have separate values in different newsgroups.
1511 A list of newsgroup (summary buffer) local variables, or cons of
1512 variables and their default expressions to be evalled (when the default
1513 values are not nil), that should be made global while the summary buffer
1516 Note: The default expressions will be evaluated (using function `eval')
1517 before assignment to the local variable rather than just assigned to it.
1518 If the default expression is the symbol `global', that symbol will not
1519 be evaluated but the global value of the local variable will be used
1522 These variables can be used to set variables in the group parameters
1523 while still allowing them to affect operations done in other buffers.
1526 \(setq gnus-newsgroup-variables
1527 '(message-use-followup-to
1528 (gnus-visible-headers .
1529 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1532 ;; Byte-compiler warning.
1534 ;; Bind features so that require will believe that gnus-sum has
1535 ;; already been loaded (avoids infinite recursion)
1536 (let ((features (cons 'gnus-sum features)))
1537 ;; Several of the declarations in gnus-sum are needed to load the
1538 ;; following files. Right now, these definitions have been
1539 ;; compiled but not defined (evaluated). We could either do a
1540 ;; eval-and-compile about all of the declarations or evaluate the
1542 (if (boundp 'gnus-newsgroup-variables)
1544 (load "gnus-sum.el" t t t))
1546 (require 'gnus-art)))
1548 ;; Subject simplification.
1550 (defun gnus-simplify-whitespace (str)
1551 "Remove excessive whitespace from STR."
1553 (while (string-match "[ \t][ \t]+" str)
1554 (setq str (concat (substring str 0 (match-beginning 0))
1556 (substring str (match-end 0)))))
1558 (when (string-match "^[ \t]+" str)
1559 (setq str (substring str (match-end 0))))
1561 (when (string-match "[ \t]+$" str)
1562 (setq str (substring str 0 (match-beginning 0))))
1565 (defun gnus-simplify-all-whitespace (str)
1566 "Remove all whitespace from STR."
1567 (while (string-match "[ \t\n]+" str)
1568 (setq str (replace-match "" nil nil str)))
1571 (defsubst gnus-simplify-subject-re (subject)
1572 "Remove \"Re:\" from subject lines."
1573 (if (string-match message-subject-re-regexp subject)
1574 (substring subject (match-end 0))
1577 (defun gnus-simplify-subject (subject &optional re-only)
1578 "Remove `Re:' and words in parentheses.
1579 If RE-ONLY is non-nil, strip leading `Re:'s only."
1580 (let ((case-fold-search t)) ;Ignore case.
1581 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1582 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1583 (setq subject (substring subject (match-end 0))))
1584 ;; Remove uninteresting prefixes.
1585 (when (and (not re-only)
1586 gnus-simplify-ignored-prefixes
1587 (string-match gnus-simplify-ignored-prefixes subject))
1588 (setq subject (substring subject (match-end 0))))
1589 ;; Remove words in parentheses from end.
1591 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1592 (setq subject (substring subject 0 (match-beginning 0)))))
1593 ;; Return subject string.
1596 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1598 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1599 (goto-char (point-min))
1600 (while (re-search-forward regexp nil t)
1601 (replace-match (or newtext ""))))
1603 (defun gnus-simplify-buffer-fuzzy ()
1604 "Simplify string in the buffer fuzzily.
1605 The string in the accessible portion of the current buffer is simplified.
1606 It is assumed to be a single-line subject.
1607 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1608 matter is removed. Additional things can be deleted by setting
1609 `gnus-simplify-subject-fuzzy-regexp'."
1610 (let ((case-fold-search t)
1612 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1614 (while (not (eq modified-tick (buffer-modified-tick)))
1615 (setq modified-tick (buffer-modified-tick))
1617 ((listp gnus-simplify-subject-fuzzy-regexp)
1618 (mapcar 'gnus-simplify-buffer-fuzzy-step
1619 gnus-simplify-subject-fuzzy-regexp))
1620 (gnus-simplify-subject-fuzzy-regexp
1621 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1622 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1623 (gnus-simplify-buffer-fuzzy-step
1624 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1625 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1627 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1628 (gnus-simplify-buffer-fuzzy-step " +" " ")
1629 (gnus-simplify-buffer-fuzzy-step " $")
1630 (gnus-simplify-buffer-fuzzy-step "^ +")))
1632 (defun gnus-simplify-subject-fuzzy (subject)
1633 "Simplify a subject string fuzzily.
1634 See `gnus-simplify-buffer-fuzzy' for details."
1636 (gnus-set-work-buffer)
1637 (let ((case-fold-search t))
1638 ;; Remove uninteresting prefixes.
1639 (when (and gnus-simplify-ignored-prefixes
1640 (string-match gnus-simplify-ignored-prefixes subject))
1641 (setq subject (substring subject (match-end 0))))
1643 (inline (gnus-simplify-buffer-fuzzy))
1646 (defsubst gnus-simplify-subject-fully (subject)
1647 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1649 (gnus-simplify-subject-functions
1650 (gnus-map-function gnus-simplify-subject-functions subject))
1651 ((null gnus-summary-gather-subject-limit)
1652 (gnus-simplify-subject-re subject))
1653 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1654 (gnus-simplify-subject-fuzzy subject))
1655 ((numberp gnus-summary-gather-subject-limit)
1656 (gnus-limit-string (gnus-simplify-subject-re subject)
1657 gnus-summary-gather-subject-limit))
1661 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1662 "Check whether two subjects are equal.
1663 If optional argument SIMPLE-FIRST is t, first argument is already
1666 ((null simple-first)
1667 (equal (gnus-simplify-subject-fully s1)
1668 (gnus-simplify-subject-fully s2)))
1671 (gnus-simplify-subject-fully s2)))))
1673 (defun gnus-summary-bubble-group ()
1674 "Increase the score of the current group.
1675 This is a handy function to add to `gnus-summary-exit-hook' to
1676 increase the score of each group you read."
1677 (gnus-group-add-score gnus-newsgroup-name))
1681 ;;; Gnus summary mode
1684 (put 'gnus-summary-mode 'mode-class 'special)
1686 (defvar gnus-article-commands-menu)
1688 ;; Non-orthogonal keys
1690 (gnus-define-keys gnus-summary-mode-map
1691 " " gnus-summary-next-page
1692 "\177" gnus-summary-prev-page
1693 [delete] gnus-summary-prev-page
1694 [backspace] gnus-summary-prev-page
1695 "\r" gnus-summary-scroll-up
1696 "\M-\r" gnus-summary-scroll-down
1697 "n" gnus-summary-next-unread-article
1698 "p" gnus-summary-prev-unread-article
1699 "N" gnus-summary-next-article
1700 "P" gnus-summary-prev-article
1701 "\M-\C-n" gnus-summary-next-same-subject
1702 "\M-\C-p" gnus-summary-prev-same-subject
1703 "\M-n" gnus-summary-next-unread-subject
1704 "\M-p" gnus-summary-prev-unread-subject
1705 "." gnus-summary-first-unread-article
1706 "," gnus-summary-best-unread-article
1707 "\M-s" gnus-summary-search-article-forward
1708 "\M-r" gnus-summary-search-article-backward
1709 "<" gnus-summary-beginning-of-article
1710 ">" gnus-summary-end-of-article
1711 "j" gnus-summary-goto-article
1712 "^" gnus-summary-refer-parent-article
1713 "\M-^" gnus-summary-refer-article
1714 "u" gnus-summary-tick-article-forward
1715 "!" gnus-summary-tick-article-forward
1716 "U" gnus-summary-tick-article-backward
1717 "d" gnus-summary-mark-as-read-forward
1718 "D" gnus-summary-mark-as-read-backward
1719 "E" gnus-summary-mark-as-expirable
1720 "\M-u" gnus-summary-clear-mark-forward
1721 "\M-U" gnus-summary-clear-mark-backward
1722 "k" gnus-summary-kill-same-subject-and-select
1723 "\C-k" gnus-summary-kill-same-subject
1724 "\M-\C-k" gnus-summary-kill-thread
1725 "\M-\C-l" gnus-summary-lower-thread
1726 "e" gnus-summary-edit-article
1727 "#" gnus-summary-mark-as-processable
1728 "\M-#" gnus-summary-unmark-as-processable
1729 "\M-\C-t" gnus-summary-toggle-threads
1730 "\M-\C-s" gnus-summary-show-thread
1731 "\M-\C-h" gnus-summary-hide-thread
1732 "\M-\C-f" gnus-summary-next-thread
1733 "\M-\C-b" gnus-summary-prev-thread
1734 [(meta down)] gnus-summary-next-thread
1735 [(meta up)] gnus-summary-prev-thread
1736 "\M-\C-u" gnus-summary-up-thread
1737 "\M-\C-d" gnus-summary-down-thread
1738 "&" gnus-summary-execute-command
1739 "c" gnus-summary-catchup-and-exit
1740 "\C-w" gnus-summary-mark-region-as-read
1741 "\C-t" gnus-summary-toggle-truncation
1742 "?" gnus-summary-mark-as-dormant
1743 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1744 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1745 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1746 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1747 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1748 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1749 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1750 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1751 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1752 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1753 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1754 "=" gnus-summary-expand-window
1755 "\C-x\C-s" gnus-summary-reselect-current-group
1756 "\M-g" gnus-summary-rescan-group
1757 "w" gnus-summary-stop-page-breaking
1758 "\C-c\C-r" gnus-summary-caesar-message
1759 "\M-t" gnus-summary-toggle-mime
1760 "f" gnus-summary-followup
1761 "F" gnus-summary-followup-with-original
1762 "C" gnus-summary-cancel-article
1763 "r" gnus-summary-reply
1764 "R" gnus-summary-reply-with-original
1765 "\C-c\C-f" gnus-summary-mail-forward
1766 "o" gnus-summary-save-article
1767 "\C-o" gnus-summary-save-article-mail
1768 "|" gnus-summary-pipe-output
1769 "\M-k" gnus-summary-edit-local-kill
1770 "\M-K" gnus-summary-edit-global-kill
1772 "\C-c\C-d" gnus-summary-describe-group
1773 "q" gnus-summary-exit
1774 "Q" gnus-summary-exit-no-update
1775 "\C-c\C-i" gnus-info-find-node
1776 gnus-mouse-2 gnus-mouse-pick-article
1777 "m" gnus-summary-mail-other-window
1778 "a" gnus-summary-post-news
1779 "i" gnus-summary-news-other-window
1780 "x" gnus-summary-limit-to-unread
1781 "s" gnus-summary-isearch-article
1782 "t" gnus-summary-toggle-header
1783 "g" gnus-summary-show-article
1784 "l" gnus-summary-goto-last-article
1785 "v" gnus-summary-preview-mime-message
1786 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1787 "\C-d" gnus-summary-enter-digest-group
1788 "\M-\C-d" gnus-summary-read-document
1789 "\M-\C-e" gnus-summary-edit-parameters
1790 "\M-\C-a" gnus-summary-customize-parameters
1792 "\C-c\C-n" gnus-namazu-search
1793 "*" gnus-cache-enter-article
1794 "\M-*" gnus-cache-remove-article
1795 "\M-&" gnus-summary-universal-argument
1796 "\C-l" gnus-recenter
1797 "I" gnus-summary-increase-score
1798 "L" gnus-summary-lower-score
1799 "\M-i" gnus-symbolic-argument
1800 "h" gnus-summary-select-article-buffer
1802 "V" gnus-summary-score-map
1803 "X" gnus-uu-extract-map
1804 "S" gnus-summary-send-map)
1806 ;; Sort of orthogonal keymap
1807 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1808 "t" gnus-summary-tick-article-forward
1809 "!" gnus-summary-tick-article-forward
1810 "d" gnus-summary-mark-as-read-forward
1811 "r" gnus-summary-mark-as-read-forward
1812 "c" gnus-summary-clear-mark-forward
1813 " " gnus-summary-clear-mark-forward
1814 "e" gnus-summary-mark-as-expirable
1815 "x" gnus-summary-mark-as-expirable
1816 "?" gnus-summary-mark-as-dormant
1817 "b" gnus-summary-set-bookmark
1818 "B" gnus-summary-remove-bookmark
1819 "#" gnus-summary-mark-as-processable
1820 "\M-#" gnus-summary-unmark-as-processable
1821 "S" gnus-summary-limit-include-expunged
1822 "C" gnus-summary-catchup
1823 "H" gnus-summary-catchup-to-here
1824 "h" gnus-summary-catchup-from-here
1825 "\C-c" gnus-summary-catchup-all
1826 "k" gnus-summary-kill-same-subject-and-select
1827 "K" gnus-summary-kill-same-subject
1828 "P" gnus-uu-mark-map)
1830 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1831 "c" gnus-summary-clear-above
1832 "u" gnus-summary-tick-above
1833 "m" gnus-summary-mark-above
1834 "k" gnus-summary-kill-below)
1836 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1837 "/" gnus-summary-limit-to-subject
1838 "n" gnus-summary-limit-to-articles
1839 "w" gnus-summary-pop-limit
1840 "s" gnus-summary-limit-to-subject
1841 "a" gnus-summary-limit-to-author
1842 "u" gnus-summary-limit-to-unread
1843 "m" gnus-summary-limit-to-marks
1844 "M" gnus-summary-limit-exclude-marks
1845 "v" gnus-summary-limit-to-score
1846 "*" gnus-summary-limit-include-cached
1847 "D" gnus-summary-limit-include-dormant
1848 "T" gnus-summary-limit-include-thread
1849 "d" gnus-summary-limit-exclude-dormant
1850 "t" gnus-summary-limit-to-age
1851 "." gnus-summary-limit-to-unseen
1852 "x" gnus-summary-limit-to-extra
1853 "p" gnus-summary-limit-to-display-predicate
1854 "E" gnus-summary-limit-include-expunged
1855 "c" gnus-summary-limit-exclude-childless-dormant
1856 "C" gnus-summary-limit-mark-excluded-as-read
1857 "o" gnus-summary-insert-old-articles
1858 "N" gnus-summary-insert-new-articles
1859 "r" gnus-summary-limit-to-replied
1860 "R" gnus-summary-limit-to-recipient)
1862 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1863 "n" gnus-summary-next-unread-article
1864 "p" gnus-summary-prev-unread-article
1865 "N" gnus-summary-next-article
1866 "P" gnus-summary-prev-article
1867 "\C-n" gnus-summary-next-same-subject
1868 "\C-p" gnus-summary-prev-same-subject
1869 "\M-n" gnus-summary-next-unread-subject
1870 "\M-p" gnus-summary-prev-unread-subject
1871 "f" gnus-summary-first-unread-article
1872 "b" gnus-summary-best-unread-article
1873 "j" gnus-summary-goto-article
1874 "g" gnus-summary-goto-subject
1875 "l" gnus-summary-goto-last-article
1876 "o" gnus-summary-pop-article)
1878 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1879 "k" gnus-summary-kill-thread
1880 "l" gnus-summary-lower-thread
1881 "i" gnus-summary-raise-thread
1882 "T" gnus-summary-toggle-threads
1883 "t" gnus-summary-rethread-current
1884 "^" gnus-summary-reparent-thread
1885 "s" gnus-summary-show-thread
1886 "S" gnus-summary-show-all-threads
1887 "h" gnus-summary-hide-thread
1888 "H" gnus-summary-hide-all-threads
1889 "n" gnus-summary-next-thread
1890 "p" gnus-summary-prev-thread
1891 "u" gnus-summary-up-thread
1892 "o" gnus-summary-top-thread
1893 "d" gnus-summary-down-thread
1894 "#" gnus-uu-mark-thread
1895 "\M-#" gnus-uu-unmark-thread)
1897 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1898 "g" gnus-summary-prepare
1899 "c" gnus-summary-insert-cached-articles
1900 "d" gnus-summary-insert-dormant-articles)
1902 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1903 "c" gnus-summary-catchup-and-exit
1904 "C" gnus-summary-catchup-all-and-exit
1905 "E" gnus-summary-exit-no-update
1906 "J" gnus-summary-jump-to-other-group
1907 "Q" gnus-summary-exit
1908 "Z" gnus-summary-exit
1909 "n" gnus-summary-catchup-and-goto-next-group
1910 "R" gnus-summary-reselect-current-group
1911 "G" gnus-summary-rescan-group
1912 "N" gnus-summary-next-group
1913 "s" gnus-summary-save-newsrc
1914 "P" gnus-summary-prev-group)
1916 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1917 " " gnus-summary-next-page
1918 "n" gnus-summary-next-page
1919 "\177" gnus-summary-prev-page
1920 [delete] gnus-summary-prev-page
1921 "p" gnus-summary-prev-page
1922 "\r" gnus-summary-scroll-up
1923 "\M-\r" gnus-summary-scroll-down
1924 "<" gnus-summary-beginning-of-article
1925 ">" gnus-summary-end-of-article
1926 "b" gnus-summary-beginning-of-article
1927 "e" gnus-summary-end-of-article
1928 "^" gnus-summary-refer-parent-article
1929 "r" gnus-summary-refer-parent-article
1930 "D" gnus-summary-enter-digest-group
1931 "R" gnus-summary-refer-references
1932 "T" gnus-summary-refer-thread
1933 "g" gnus-summary-show-article
1934 "s" gnus-summary-isearch-article
1935 "P" gnus-summary-print-article
1936 "M" gnus-mailing-list-insinuate
1937 "t" gnus-article-babel)
1939 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1940 "b" gnus-article-add-buttons
1941 "B" gnus-article-add-buttons-to-head
1942 "o" gnus-article-treat-overstrike
1943 "e" gnus-article-emphasize
1944 "w" gnus-article-fill-cited-article
1945 "Q" gnus-article-fill-long-lines
1946 "C" gnus-article-capitalize-sentences
1947 "c" gnus-article-remove-cr
1948 "Z" gnus-article-decode-HZ
1949 "A" gnus-article-treat-ansi-sequences
1950 "h" gnus-article-wash-html
1951 "u" gnus-article-unsplit-urls
1952 "f" gnus-article-display-x-face
1953 "l" gnus-summary-stop-page-breaking
1954 "r" gnus-summary-caesar-message
1955 "m" gnus-summary-morse-message
1956 "t" gnus-summary-toggle-header
1957 "g" gnus-treat-smiley
1958 "v" gnus-summary-verbose-headers
1959 "m" gnus-summary-toggle-mime
1960 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1961 "p" gnus-article-verify-x-pgp-sig
1962 "d" gnus-article-treat-dumbquotes)
1964 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1965 ;; mnemonic: deuglif*Y*
1966 "u" gnus-article-outlook-unwrap-lines
1967 "a" gnus-article-outlook-repair-attribution
1968 "c" gnus-article-outlook-rearrange-citation
1969 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1971 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1972 "a" gnus-article-hide
1973 "h" gnus-article-hide-headers
1974 "b" gnus-article-hide-boring-headers
1975 "s" gnus-article-hide-signature
1976 "c" gnus-article-hide-citation
1977 "C" gnus-article-hide-citation-in-followups
1978 "l" gnus-article-hide-list-identifiers
1979 "B" gnus-article-strip-banner
1980 "P" gnus-article-hide-pem
1981 "\C-c" gnus-article-hide-citation-maybe)
1983 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1984 "a" gnus-article-highlight
1985 "h" gnus-article-highlight-headers
1986 "c" gnus-article-highlight-citation
1987 "s" gnus-article-highlight-signature)
1989 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1990 "f" gnus-article-treat-fold-headers
1991 "u" gnus-article-treat-unfold-headers
1992 "n" gnus-article-treat-fold-newsgroups)
1994 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1995 "x" gnus-article-display-x-face
1996 "d" gnus-article-display-face
1997 "s" gnus-treat-smiley
1998 "D" gnus-article-remove-images
1999 "f" gnus-treat-from-picon
2000 "m" gnus-treat-mail-picon
2001 "n" gnus-treat-newsgroups-picon)
2003 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2004 "z" gnus-article-date-ut
2005 "u" gnus-article-date-ut
2006 "l" gnus-article-date-local
2007 "p" gnus-article-date-english
2008 "e" gnus-article-date-lapsed
2009 "o" gnus-article-date-original
2010 "i" gnus-article-date-iso8601
2011 "s" gnus-article-date-user)
2013 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2014 "t" gnus-article-remove-trailing-blank-lines
2015 "l" gnus-article-strip-leading-blank-lines
2016 "m" gnus-article-strip-multiple-blank-lines
2017 "a" gnus-article-strip-blank-lines
2018 "A" gnus-article-strip-all-blank-lines
2019 "s" gnus-article-strip-leading-space
2020 "e" gnus-article-strip-trailing-space
2021 "w" gnus-article-remove-leading-whitespace)
2023 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2025 "f" gnus-summary-fetch-faq
2026 "d" gnus-summary-describe-group
2027 "h" gnus-summary-describe-briefly
2028 "i" gnus-info-find-node
2029 "c" gnus-group-fetch-charter
2030 "C" gnus-group-fetch-control)
2032 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2033 "e" gnus-summary-expire-articles
2034 "\M-\C-e" gnus-summary-expire-articles-now
2035 "\177" gnus-summary-delete-article
2036 [delete] gnus-summary-delete-article
2037 [backspace] gnus-summary-delete-article
2038 "m" gnus-summary-move-article
2039 "r" gnus-summary-respool-article
2040 "w" gnus-summary-edit-article
2041 "c" gnus-summary-copy-article
2042 "B" gnus-summary-crosspost-article
2043 "q" gnus-summary-respool-query
2044 "t" gnus-summary-respool-trace
2045 "i" gnus-summary-import-article
2046 "I" gnus-summary-create-article
2047 "p" gnus-summary-article-posted-p)
2049 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2050 "o" gnus-summary-save-article
2051 "m" gnus-summary-save-article-mail
2052 "F" gnus-summary-write-article-file
2053 "r" gnus-summary-save-article-rmail
2054 "f" gnus-summary-save-article-file
2055 "b" gnus-summary-save-article-body-file
2056 "h" gnus-summary-save-article-folder
2057 "v" gnus-summary-save-article-vm
2058 "p" gnus-summary-pipe-output
2059 "P" gnus-summary-muttprint
2060 "s" gnus-soup-add-article)
2062 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2063 "b" gnus-summary-display-buttonized
2064 "m" gnus-summary-repair-multipart
2065 "v" gnus-article-view-part
2066 "o" gnus-article-save-part
2067 "c" gnus-article-copy-part
2068 "C" gnus-article-view-part-as-charset
2069 "e" gnus-article-view-part-externally
2070 "E" gnus-article-encrypt-body
2071 "i" gnus-article-inline-part
2072 "|" gnus-article-pipe-part)
2074 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2075 "p" gnus-summary-mark-as-processable
2076 "u" gnus-summary-unmark-as-processable
2077 "U" gnus-summary-unmark-all-processable
2078 "v" gnus-uu-mark-over
2079 "s" gnus-uu-mark-series
2080 "r" gnus-uu-mark-region
2081 "g" gnus-uu-unmark-region
2082 "R" gnus-uu-mark-by-regexp
2083 "G" gnus-uu-unmark-by-regexp
2084 "t" gnus-uu-mark-thread
2085 "T" gnus-uu-unmark-thread
2086 "a" gnus-uu-mark-all
2087 "b" gnus-uu-mark-buffer
2088 "S" gnus-uu-mark-sparse
2089 "k" gnus-summary-kill-process-mark
2090 "y" gnus-summary-yank-process-mark
2091 "w" gnus-summary-save-process-mark
2092 "i" gnus-uu-invert-processable)
2094 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2095 ;;"x" gnus-uu-extract-any
2096 "m" gnus-summary-save-parts
2097 "u" gnus-uu-decode-uu
2098 "U" gnus-uu-decode-uu-and-save
2099 "s" gnus-uu-decode-unshar
2100 "S" gnus-uu-decode-unshar-and-save
2101 "o" gnus-uu-decode-save
2102 "O" gnus-uu-decode-save
2103 "b" gnus-uu-decode-binhex
2104 "B" gnus-uu-decode-binhex
2105 "p" gnus-uu-decode-postscript
2106 "P" gnus-uu-decode-postscript-and-save)
2109 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2110 "u" gnus-uu-decode-uu-view
2111 "U" gnus-uu-decode-uu-and-save-view
2112 "s" gnus-uu-decode-unshar-view
2113 "S" gnus-uu-decode-unshar-and-save-view
2114 "o" gnus-uu-decode-save-view
2115 "O" gnus-uu-decode-save-view
2116 "b" gnus-uu-decode-binhex-view
2117 "B" gnus-uu-decode-binhex-view
2118 "p" gnus-uu-decode-postscript-view
2119 "P" gnus-uu-decode-postscript-and-save-view)
2121 (defvar gnus-article-post-menu nil)
2123 (defconst gnus-summary-menu-maxlen 20)
2125 (defun gnus-summary-menu-split (menu)
2126 ;; If we have lots of elements, divide them into groups of 20
2127 ;; and make a pane (or submenu) for each one.
2128 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2129 (let ((menu menu) sublists next
2132 ;; Pull off the next gnus-summary-menu-maxlen elements
2133 ;; and make them the next element of sublist.
2134 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2136 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2138 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2139 (aref (car (last menu)) 0)) menu)
2143 (nreverse sublists))
2144 ;; Few elements--put them all in one pane.
2147 (defun gnus-summary-make-menu-bar ()
2148 (gnus-turn-off-edit-menu 'summary)
2150 (unless (boundp 'gnus-summary-misc-menu)
2153 gnus-summary-kill-menu gnus-summary-mode-map ""
2158 ["Customize" gnus-score-customize t])
2159 (gnus-make-score-map 'increase)
2160 (gnus-make-score-map 'lower)
2162 ["Kill below" gnus-summary-kill-below t]
2163 ["Mark above" gnus-summary-mark-above t]
2164 ["Tick above" gnus-summary-tick-above t]
2165 ["Clear above" gnus-summary-clear-above t])
2166 ["Current score" gnus-summary-current-score t]
2167 ["Set score" gnus-summary-set-score t]
2168 ["Switch current score file..." gnus-score-change-score-file t]
2169 ["Set mark below..." gnus-score-set-mark-below t]
2170 ["Set expunge below..." gnus-score-set-expunge-below t]
2171 ["Edit current score file" gnus-score-edit-current-scores t]
2172 ["Edit score file" gnus-score-edit-file t]
2173 ["Trace score" gnus-score-find-trace t]
2174 ["Find words" gnus-score-find-favourite-words t]
2175 ["Rescore buffer" gnus-summary-rescore t]
2176 ["Increase score..." gnus-summary-increase-score t]
2177 ["Lower score..." gnus-summary-lower-score t]))))
2179 ;; Define both the Article menu in the summary buffer and the
2180 ;; equivalent Commands menu in the article buffer here for
2184 ["All" gnus-article-hide t]
2185 ["Headers" gnus-article-hide-headers t]
2186 ["Signature" gnus-article-hide-signature t]
2187 ["Citation" gnus-article-hide-citation t]
2188 ["List identifiers" gnus-article-hide-list-identifiers t]
2189 ["Banner" gnus-article-strip-banner t]
2190 ["Boring headers" gnus-article-hide-boring-headers t])
2192 ["All" gnus-article-highlight t]
2193 ["Headers" gnus-article-highlight-headers t]
2194 ["Signature" gnus-article-highlight-signature t]
2195 ["Citation" gnus-article-highlight-citation t])
2197 ["Local" gnus-article-date-local t]
2198 ["ISO8601" gnus-article-date-iso8601 t]
2199 ["UT" gnus-article-date-ut t]
2200 ["Original" gnus-article-date-original t]
2201 ["Lapsed" gnus-article-date-lapsed t]
2202 ["User-defined" gnus-article-date-user t])
2204 ["Remove images" gnus-article-remove-images t]
2205 ["Toggle smiley" gnus-treat-smiley t]
2206 ["Show X-Face" gnus-article-display-x-face t]
2207 ["Show picons in From" gnus-treat-from-picon t]
2208 ["Show picons in mail headers" gnus-treat-mail-picon t]
2209 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2210 ("View as different encoding"
2211 ,@(gnus-summary-menu-split
2214 ;; Since easymenu under Emacs doesn't allow
2215 ;; lambda forms for menu commands, we should
2216 ;; provide intern'ed function symbols.
2217 (let ((command (intern (format "\
2218 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2222 (let ((gnus-summary-show-article-charset-alist
2224 (gnus-summary-show-article 1))))
2225 `[,(symbol-name cs) ,command t]))
2226 (sort (if (fboundp 'coding-system-list)
2227 (coding-system-list)
2228 ;;(mapcar 'car mm-mime-mule-charset-alist)
2233 ["Leading" gnus-article-strip-leading-blank-lines t]
2234 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2235 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2236 ["All of the above" gnus-article-strip-blank-lines t]
2237 ["All" gnus-article-strip-all-blank-lines t]
2238 ["Leading space" gnus-article-strip-leading-space t]
2239 ["Trailing space" gnus-article-strip-trailing-space t]
2240 ["Leading space in headers"
2241 gnus-article-remove-leading-whitespace t])
2242 ["Overstrike" gnus-article-treat-overstrike t]
2243 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2244 ["Emphasis" gnus-article-emphasize t]
2245 ["Word wrap" gnus-article-fill-cited-article t]
2246 ["Fill long lines" gnus-article-fill-long-lines t]
2247 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2248 ["Remove CR" gnus-article-remove-cr t]
2249 ["Rot 13" gnus-summary-caesar-message
2250 ,@(if (featurep 'xemacs) '(t)
2251 '(:help "\"Caesar rotate\" article by 13"))]
2252 ["Morse decode" gnus-summary-morse-message t]
2253 ["Unix pipe..." gnus-summary-pipe-message t]
2254 ["Add buttons" gnus-article-add-buttons t]
2255 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2256 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2257 ["Toggle MIME" gnus-summary-toggle-mime t]
2258 ["Verbose header" gnus-summary-verbose-headers t]
2259 ["Toggle header" gnus-summary-toggle-header t]
2260 ["Unfold headers" gnus-article-treat-unfold-headers t]
2261 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2262 ["Html" gnus-article-wash-html t]
2263 ["Unsplit URLs" gnus-article-unsplit-urls t]
2264 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2265 ["Decode HZ" gnus-article-decode-HZ t]
2266 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2267 ("(Outlook) Deuglify"
2268 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2269 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2270 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2271 ["Full (Outlook) deuglify"
2272 gnus-article-outlook-deuglify-article t])
2275 ["Save in default format..." gnus-summary-save-article
2276 ,@(if (featurep 'xemacs) '(t)
2277 '(:help "Save article using default method"))]
2278 ["Save in file..." gnus-summary-save-article-file
2279 ,@(if (featurep 'xemacs) '(t)
2280 '(:help "Save article in file"))]
2281 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2282 ["Save in MH folder..." gnus-summary-save-article-folder t]
2283 ["Save in VM folder..." gnus-summary-save-article-vm t]
2284 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2285 ["Save body in file..." gnus-summary-save-article-body-file t]
2286 ["Pipe through a filter..." gnus-summary-pipe-output t]
2287 ["Add to SOUP packet" gnus-soup-add-article t]
2288 ["Print with Muttprint..." gnus-summary-muttprint t]
2289 ["Print" gnus-summary-print-article
2290 ,@(if (featurep 'xemacs) '(t)
2291 '(:help "Generate and print a PostScript image"))])
2292 ("Copy, move,... (Backend)"
2293 ,@(if (featurep 'xemacs) nil
2294 '(:help "Copying, moving, expiring articles..."))
2295 ["Respool article..." gnus-summary-respool-article t]
2296 ["Move article..." gnus-summary-move-article
2297 (gnus-check-backend-function
2298 'request-move-article gnus-newsgroup-name)]
2299 ["Copy article..." gnus-summary-copy-article t]
2300 ["Crosspost article..." gnus-summary-crosspost-article
2301 (gnus-check-backend-function
2302 'request-replace-article gnus-newsgroup-name)]
2303 ["Import file..." gnus-summary-import-article
2304 (gnus-check-backend-function
2305 'request-accept-article gnus-newsgroup-name)]
2306 ["Create article..." gnus-summary-create-article
2307 (gnus-check-backend-function
2308 'request-accept-article gnus-newsgroup-name)]
2309 ["Check if posted" gnus-summary-article-posted-p t]
2310 ["Edit article" gnus-summary-edit-article
2311 (not (gnus-group-read-only-p))]
2312 ["Delete article" gnus-summary-delete-article
2313 (gnus-check-backend-function
2314 'request-expire-articles gnus-newsgroup-name)]
2315 ["Query respool" gnus-summary-respool-query t]
2316 ["Trace respool" gnus-summary-respool-trace t]
2317 ["Delete expirable articles" gnus-summary-expire-articles-now
2318 (gnus-check-backend-function
2319 'request-expire-articles gnus-newsgroup-name)])
2321 ["Uudecode" gnus-uu-decode-uu
2322 ,@(if (featurep 'xemacs) '(t)
2323 '(:help "Decode uuencoded article(s)"))]
2324 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2325 ["Unshar" gnus-uu-decode-unshar t]
2326 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2327 ["Save" gnus-uu-decode-save t]
2328 ["Binhex" gnus-uu-decode-binhex t]
2329 ["Postscript" gnus-uu-decode-postscript t])
2331 ["Enter article" gnus-cache-enter-article t]
2332 ["Remove article" gnus-cache-remove-article t])
2333 ["Translate" gnus-article-babel t]
2334 ["Select article buffer" gnus-summary-select-article-buffer t]
2335 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2336 ["Isearch article..." gnus-summary-isearch-article t]
2337 ["Beginning of the article" gnus-summary-beginning-of-article t]
2338 ["End of the article" gnus-summary-end-of-article t]
2339 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2340 ["Fetch referenced articles" gnus-summary-refer-references t]
2341 ["Fetch current thread" gnus-summary-refer-thread t]
2342 ["Fetch article with id..." gnus-summary-refer-article t]
2343 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2344 ["Redisplay" gnus-summary-show-article t]
2345 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2347 gnus-summary-article-menu gnus-summary-mode-map ""
2348 (cons "Article" innards))
2350 (if (not (keymapp gnus-summary-article-menu))
2352 gnus-article-commands-menu gnus-article-mode-map ""
2353 (cons "Commands" innards))
2354 ;; in Emacs, don't share menu.
2355 (setq gnus-article-commands-menu
2356 (copy-keymap gnus-summary-article-menu))
2357 (define-key gnus-article-mode-map [menu-bar commands]
2358 (cons "Commands" gnus-article-commands-menu))))
2361 gnus-summary-thread-menu gnus-summary-mode-map ""
2363 ["Find all messages in thread" gnus-summary-refer-thread t]
2364 ["Toggle threading" gnus-summary-toggle-threads t]
2365 ["Hide threads" gnus-summary-hide-all-threads t]
2366 ["Show threads" gnus-summary-show-all-threads t]
2367 ["Hide thread" gnus-summary-hide-thread t]
2368 ["Show thread" gnus-summary-show-thread t]
2369 ["Go to next thread" gnus-summary-next-thread t]
2370 ["Go to previous thread" gnus-summary-prev-thread t]
2371 ["Go down thread" gnus-summary-down-thread t]
2372 ["Go up thread" gnus-summary-up-thread t]
2373 ["Top of thread" gnus-summary-top-thread t]
2374 ["Mark thread as read" gnus-summary-kill-thread t]
2375 ["Lower thread score" gnus-summary-lower-thread t]
2376 ["Raise thread score" gnus-summary-raise-thread t]
2377 ["Rethread current" gnus-summary-rethread-current t]))
2380 gnus-summary-post-menu gnus-summary-mode-map ""
2382 ["Send a message (mail or news)" gnus-summary-post-news
2383 ,@(if (featurep 'xemacs) '(t)
2384 '(:help "Compose a new message (mail or news)"))]
2385 ["Followup" gnus-summary-followup
2386 ,@(if (featurep 'xemacs) '(t)
2387 '(:help "Post followup to this article"))]
2388 ["Followup and yank" gnus-summary-followup-with-original
2389 ,@(if (featurep 'xemacs) '(t)
2390 '(:help "Post followup to this article, quoting its contents"))]
2391 ["Supersede article" gnus-summary-supersede-article t]
2392 ["Cancel article" gnus-summary-cancel-article
2393 ,@(if (featurep 'xemacs) '(t)
2394 '(:help "Cancel an article you posted"))]
2395 ["Reply" gnus-summary-reply t]
2396 ["Reply and yank" gnus-summary-reply-with-original t]
2397 ["Wide reply" gnus-summary-wide-reply t]
2398 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2399 ,@(if (featurep 'xemacs) '(t)
2400 '(:help "Mail a reply, quoting this article"))]
2401 ["Very wide reply" gnus-summary-very-wide-reply t]
2402 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2403 ,@(if (featurep 'xemacs) '(t)
2404 '(:help "Mail a very wide reply, quoting this article"))]
2405 ["Mail forward" gnus-summary-mail-forward t]
2406 ["Post forward" gnus-summary-post-forward t]
2407 ["Digest and mail" gnus-summary-digest-mail-forward t]
2408 ["Digest and post" gnus-summary-digest-post-forward t]
2409 ["Resend message" gnus-summary-resend-message t]
2410 ["Resend message edit" gnus-summary-resend-message-edit t]
2411 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2412 ["Send a mail" gnus-summary-mail-other-window t]
2413 ["Create a local message" gnus-summary-news-other-window t]
2414 ["Uuencode and post" gnus-uu-post-news
2415 ,@(if (featurep 'xemacs) '(t)
2416 '(:help "Post a uuencoded article"))]
2417 ["Followup via news" gnus-summary-followup-to-mail t]
2418 ["Followup via news and yank"
2419 gnus-summary-followup-to-mail-with-original t]
2421 ;;["Send" gnus-summary-send-draft t]
2422 ;;["Send bounced" gnus-resend-bounced-mail t])
2426 ((not (keymapp gnus-summary-post-menu))
2427 (setq gnus-article-post-menu gnus-summary-post-menu))
2428 ((not gnus-article-post-menu)
2429 ;; Don't share post menu.
2430 (setq gnus-article-post-menu
2431 (copy-keymap gnus-summary-post-menu))))
2432 (define-key gnus-article-mode-map [menu-bar post]
2433 (cons "Post" gnus-article-post-menu))
2436 gnus-summary-misc-menu gnus-summary-mode-map ""
2439 ["Mark as read" gnus-summary-mark-as-read-forward t]
2440 ["Mark same subject and select"
2441 gnus-summary-kill-same-subject-and-select t]
2442 ["Mark same subject" gnus-summary-kill-same-subject t]
2443 ["Catchup" gnus-summary-catchup
2444 ,@(if (featurep 'xemacs) '(t)
2445 '(:help "Mark unread articles in this group as read"))]
2446 ["Catchup all" gnus-summary-catchup-all t]
2447 ["Catchup to here" gnus-summary-catchup-to-here t]
2448 ["Catchup from here" gnus-summary-catchup-from-here t]
2449 ["Catchup region" gnus-summary-mark-region-as-read
2450 (gnus-mark-active-p)]
2451 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2453 ["Tick" gnus-summary-tick-article-forward t]
2454 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2455 ["Remove marks" gnus-summary-clear-mark-forward t]
2456 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2457 ["Set bookmark" gnus-summary-set-bookmark t]
2458 ["Remove bookmark" gnus-summary-remove-bookmark t])
2460 ["Marks..." gnus-summary-limit-to-marks t]
2461 ["Subject..." gnus-summary-limit-to-subject t]
2462 ["Author..." gnus-summary-limit-to-author t]
2463 ["Recipient..." gnus-summary-limit-to-recipient t]
2464 ["Age..." gnus-summary-limit-to-age t]
2465 ["Extra..." gnus-summary-limit-to-extra t]
2466 ["Score..." gnus-summary-limit-to-score t]
2467 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2468 ["Unread" gnus-summary-limit-to-unread t]
2469 ["Unseen" gnus-summary-limit-to-unseen t]
2470 ["Replied" gnus-summary-limit-to-replied t]
2471 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2472 ["Next articles" gnus-summary-limit-to-articles t]
2473 ["Pop limit" gnus-summary-pop-limit t]
2474 ["Show dormant" gnus-summary-limit-include-dormant t]
2475 ["Hide childless dormant"
2476 gnus-summary-limit-exclude-childless-dormant t]
2477 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2478 ["Hide marked" gnus-summary-limit-exclude-marks t]
2479 ["Show expunged" gnus-summary-limit-include-expunged t])
2481 ["Set mark" gnus-summary-mark-as-processable t]
2482 ["Remove mark" gnus-summary-unmark-as-processable t]
2483 ["Remove all marks" gnus-summary-unmark-all-processable t]
2484 ["Invert marks" gnus-uu-invert-processable t]
2485 ["Mark above" gnus-uu-mark-over t]
2486 ["Mark series" gnus-uu-mark-series t]
2487 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2488 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2489 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2490 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2491 ["Mark all" gnus-uu-mark-all t]
2492 ["Mark buffer" gnus-uu-mark-buffer t]
2493 ["Mark sparse" gnus-uu-mark-sparse t]
2494 ["Mark thread" gnus-uu-mark-thread t]
2495 ["Unmark thread" gnus-uu-unmark-thread t]
2496 ("Process Mark Sets"
2497 ["Kill" gnus-summary-kill-process-mark t]
2498 ["Yank" gnus-summary-yank-process-mark
2499 gnus-newsgroup-process-stack]
2500 ["Save" gnus-summary-save-process-mark t]
2501 ["Run command on marked..." gnus-summary-universal-argument t]))
2503 ["Page forward" gnus-summary-next-page
2504 ,@(if (featurep 'xemacs) '(t)
2505 '(:help "Show next page of article"))]
2506 ["Page backward" gnus-summary-prev-page
2507 ,@(if (featurep 'xemacs) '(t)
2508 '(:help "Show previous page of article"))]
2509 ["Line forward" gnus-summary-scroll-up t])
2511 ["Next unread article" gnus-summary-next-unread-article t]
2512 ["Previous unread article" gnus-summary-prev-unread-article t]
2513 ["Next article" gnus-summary-next-article t]
2514 ["Previous article" gnus-summary-prev-article t]
2515 ["Next unread subject" gnus-summary-next-unread-subject t]
2516 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2517 ["Next article same subject" gnus-summary-next-same-subject t]
2518 ["Previous article same subject" gnus-summary-prev-same-subject t]
2519 ["First unread article" gnus-summary-first-unread-article t]
2520 ["Best unread article" gnus-summary-best-unread-article t]
2521 ["Go to subject number..." gnus-summary-goto-subject t]
2522 ["Go to article number..." gnus-summary-goto-article t]
2523 ["Go to the last article" gnus-summary-goto-last-article t]
2524 ["Pop article off history" gnus-summary-pop-article t])
2526 ["Sort by number" gnus-summary-sort-by-number t]
2527 ["Sort by author" gnus-summary-sort-by-author t]
2528 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2529 ["Sort by subject" gnus-summary-sort-by-subject t]
2530 ["Sort by date" gnus-summary-sort-by-date t]
2531 ["Sort by score" gnus-summary-sort-by-score t]
2532 ["Sort by lines" gnus-summary-sort-by-lines t]
2533 ["Sort by characters" gnus-summary-sort-by-chars t]
2534 ["Randomize" gnus-summary-sort-by-random t]
2535 ["Original sort" gnus-summary-sort-by-original t])
2537 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2538 ["Describe group" gnus-summary-describe-group t]
2539 ["Fetch charter" gnus-group-fetch-charter
2540 ,@(if (featurep 'xemacs) nil
2541 '(:help "Display the charter of the current group"))]
2542 ["Fetch control message" gnus-group-fetch-control
2543 ,@(if (featurep 'xemacs) nil
2544 '(:help "Display the archived control message for the current group"))]
2545 ["Read manual" gnus-info-find-node t])
2547 ["Pick and read" gnus-pick-mode t]
2548 ["Binary" gnus-binary-mode t])
2550 ["Regenerate" gnus-summary-prepare t]
2551 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2552 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2553 ["Toggle threading" gnus-summary-toggle-threads t])
2554 ["See old articles" gnus-summary-insert-old-articles t]
2555 ["See new articles" gnus-summary-insert-new-articles t]
2556 ["Filter articles..." gnus-summary-execute-command t]
2557 ["Run command on articles..." gnus-summary-universal-argument t]
2558 ["Search articles forward..." gnus-summary-search-article-forward t]
2559 ["Search articles backward..." gnus-summary-search-article-backward t]
2560 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2561 ["Expand window" gnus-summary-expand-window t]
2562 ["Expire expirable articles" gnus-summary-expire-articles
2563 (gnus-check-backend-function
2564 'request-expire-articles gnus-newsgroup-name)]
2565 ["Edit local kill file" gnus-summary-edit-local-kill t]
2566 ["Edit main kill file" gnus-summary-edit-global-kill t]
2567 ["Edit group parameters" gnus-summary-edit-parameters t]
2568 ["Customize group parameters" gnus-summary-customize-parameters t]
2569 ["Send a bug report" gnus-bug t]
2571 ["Catchup and exit" gnus-summary-catchup-and-exit
2572 ,@(if (featurep 'xemacs) '(t)
2573 '(:help "Mark unread articles in this group as read, then exit"))]
2574 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2575 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2576 ["Exit group" gnus-summary-exit
2577 ,@(if (featurep 'xemacs) '(t)
2578 '(:help "Exit current group, return to group selection mode"))]
2579 ["Exit group without updating" gnus-summary-exit-no-update t]
2580 ["Exit and goto next group" gnus-summary-next-group t]
2581 ["Exit and goto prev group" gnus-summary-prev-group t]
2582 ["Reselect group" gnus-summary-reselect-current-group t]
2583 ["Rescan group" gnus-summary-rescan-group t]
2584 ["Update dribble" gnus-summary-save-newsrc t])))
2586 (gnus-run-hooks 'gnus-summary-menu-hook)))
2588 (defvar gnus-summary-tool-bar-map nil)
2590 ;; Emacs 21 tool bar. Should be no-op otherwise.
2591 (defun gnus-summary-make-tool-bar ()
2592 (if (and (fboundp 'tool-bar-add-item-from-menu)
2593 (default-value 'tool-bar-mode)
2594 (not gnus-summary-tool-bar-map))
2595 (setq gnus-summary-tool-bar-map
2596 (let ((tool-bar-map (make-sparse-keymap))
2597 (load-path (mm-image-load-path)))
2598 (tool-bar-add-item-from-menu
2599 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2600 (tool-bar-add-item-from-menu
2601 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2602 (tool-bar-add-item-from-menu
2603 'gnus-summary-post-news "post" gnus-summary-mode-map)
2604 (tool-bar-add-item-from-menu
2605 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2606 (tool-bar-add-item-from-menu
2607 'gnus-summary-followup "followup" gnus-summary-mode-map)
2608 (tool-bar-add-item-from-menu
2609 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2610 (tool-bar-add-item-from-menu
2611 'gnus-summary-reply "reply" gnus-summary-mode-map)
2612 (tool-bar-add-item-from-menu
2613 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2614 (tool-bar-add-item-from-menu
2615 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2616 (tool-bar-add-item-from-menu
2617 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2618 (tool-bar-add-item-from-menu
2619 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2620 (tool-bar-add-item-from-menu
2621 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2622 (tool-bar-add-item-from-menu
2623 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2624 (tool-bar-add-item-from-menu
2625 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2626 (tool-bar-add-item-from-menu
2627 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2628 (tool-bar-add-item-from-menu
2629 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2631 (if gnus-summary-tool-bar-map
2632 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2634 (defun gnus-score-set-default (var value)
2635 "A version of set that updates the GNU Emacs menu-bar."
2637 ;; It is the message that forces the active status to be updated.
2640 (defun gnus-make-score-map (type)
2641 "Make a summary score map of type TYPE."
2644 (let ((headers '(("author" "from" string)
2645 ("subject" "subject" string)
2646 ("article body" "body" string)
2647 ("article head" "head" string)
2648 ("xref" "xref" string)
2649 ("extra header" "extra" string)
2650 ("lines" "lines" number)
2651 ("followups to author" "followup" string)))
2652 (types '((number ("less than" <)
2655 (string ("substring" s)
2659 (perms '(("temporary" (current-time-string))
2667 (if (eq type 'lower)
2672 (setq header (car headers))
2678 (let ((ts (cdr (assoc (nth 2 header) types)))
2694 'gnus-summary-score-entry
2696 (if (or (string= (nth 1 header)
2698 (string= (nth 1 header)
2701 (list 'gnus-summary-header
2703 (list 'quote (nth 1 (car ts)))
2704 (list 'gnus-score-delta-default
2711 (list (nreverse outp))))
2714 (list (nreverse outt))))
2716 (setq headers (cdr headers)))
2717 (list (nreverse outh))))))))
2721 (defun gnus-summary-mode (&optional group)
2722 "Major mode for reading articles.
2724 All normal editing commands are switched off.
2725 \\<gnus-summary-mode-map>
2726 Each line in this buffer represents one article. To read an
2727 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2728 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2731 You can also post articles and send mail from this buffer. To
2732 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2733 of an article, type `\\[gnus-summary-reply]'.
2735 There are approx. one gazillion commands you can execute in this
2736 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2738 The following commands are available:
2740 \\{gnus-summary-mode-map}"
2742 (kill-all-local-variables)
2743 (when (gnus-visual-p 'summary-menu 'menu)
2744 (gnus-summary-make-menu-bar)
2745 (gnus-summary-make-tool-bar))
2746 (gnus-summary-make-local-variables)
2747 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2748 (gnus-summary-make-local-variables))
2749 (gnus-make-thread-indent-array)
2750 (gnus-simplify-mode-line)
2751 (setq major-mode 'gnus-summary-mode)
2752 (setq mode-name "Summary")
2753 (make-local-variable 'minor-mode-alist)
2754 (use-local-map gnus-summary-mode-map)
2755 (buffer-disable-undo)
2756 (setq buffer-read-only t ;Disable modification
2757 show-trailing-whitespace nil)
2758 (setq truncate-lines t)
2759 (setq selective-display t)
2760 (setq selective-display-ellipses t) ;Display `...'
2761 (gnus-summary-set-display-table)
2762 (gnus-set-default-directory)
2763 (setq gnus-newsgroup-name group)
2764 (unless (gnus-news-group-p group)
2765 (setq gnus-newsgroup-incorporated
2766 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2767 (make-local-variable 'gnus-summary-line-format)
2768 (make-local-variable 'gnus-summary-line-format-spec)
2769 (make-local-variable 'gnus-summary-dummy-line-format)
2770 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2771 (make-local-variable 'gnus-summary-mark-positions)
2772 (gnus-make-local-hook 'pre-command-hook)
2773 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2774 (gnus-run-hooks 'gnus-summary-mode-hook)
2775 (turn-on-gnus-mailing-list-mode)
2776 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2777 (gnus-update-summary-mark-positions))
2779 (defun gnus-summary-make-local-variables ()
2780 "Make all the local summary buffer variables."
2782 (dolist (local gnus-summary-local-variables)
2785 (if (eq (cdr local) 'global)
2786 ;; Copy the global value of the variable.
2787 (setq global (symbol-value (car local)))
2788 ;; Use the value from the list.
2789 (setq global (eval (cdr local))))
2790 (set (make-local-variable (car local)) global))
2791 ;; Simple nil-valued local variable.
2792 (set (make-local-variable local) nil)))))
2794 (defun gnus-summary-clear-local-variables ()
2795 (let ((locals gnus-summary-local-variables))
2797 (if (consp (car locals))
2798 (and (symbolp (caar locals))
2799 (set (caar locals) nil))
2800 (and (symbolp (car locals))
2801 (set (car locals) nil)))
2802 (setq locals (cdr locals)))))
2804 ;; Summary data functions.
2806 (defmacro gnus-data-number (data)
2809 (defmacro gnus-data-set-number (data number)
2810 `(setcar ,data ,number))
2812 (defmacro gnus-data-mark (data)
2815 (defmacro gnus-data-set-mark (data mark)
2816 `(setcar (nthcdr 1 ,data) ,mark))
2818 (defmacro gnus-data-pos (data)
2821 (defmacro gnus-data-set-pos (data pos)
2822 `(setcar (nthcdr 2 ,data) ,pos))
2824 (defmacro gnus-data-header (data)
2827 (defmacro gnus-data-set-header (data header)
2828 `(setcar (nthcdr 3 ,data) ,header))
2830 (defmacro gnus-data-level (data)
2833 (defmacro gnus-data-unread-p (data)
2834 `(= (nth 1 ,data) gnus-unread-mark))
2836 (defmacro gnus-data-read-p (data)
2837 `(/= (nth 1 ,data) gnus-unread-mark))
2839 (defmacro gnus-data-pseudo-p (data)
2840 `(consp (nth 3 ,data)))
2842 (defmacro gnus-data-find (number)
2843 `(assq ,number gnus-newsgroup-data))
2845 (defmacro gnus-data-find-list (number &optional data)
2846 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2847 (memq (assq ,number bdata)
2850 (defmacro gnus-data-make (number mark pos header level)
2851 `(list ,number ,mark ,pos ,header ,level))
2853 (defun gnus-data-enter (after-article number mark pos header level offset)
2854 (let ((data (gnus-data-find-list after-article)))
2856 (error "No such article: %d" after-article))
2857 (setcdr data (cons (gnus-data-make number mark pos header level)
2859 (setq gnus-newsgroup-data-reverse nil)
2860 (gnus-data-update-list (cddr data) offset)))
2862 (defun gnus-data-enter-list (after-article list &optional offset)
2864 (let ((data (and after-article (gnus-data-find-list after-article)))
2868 (let ((odata gnus-newsgroup-data))
2869 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2871 (gnus-data-update-list odata offset)))
2872 ;; Find the last element in the list to be spliced into the main
2874 (setq list (last list))
2877 (setcdr list gnus-newsgroup-data)
2878 (setq gnus-newsgroup-data ilist)
2880 (gnus-data-update-list (cdr list) offset)))
2881 (setcdr list (cdr data))
2884 (gnus-data-update-list (cdr list) offset))))
2885 (setq gnus-newsgroup-data-reverse nil))))
2887 (defun gnus-data-remove (article &optional offset)
2888 (let ((data gnus-newsgroup-data))
2889 (if (= (gnus-data-number (car data)) article)
2891 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2892 gnus-newsgroup-data-reverse nil)
2894 (gnus-data-update-list gnus-newsgroup-data offset)))
2896 (when (= (gnus-data-number (cadr data)) article)
2897 (setcdr data (cddr data))
2899 (gnus-data-update-list (cdr data) offset))
2901 gnus-newsgroup-data-reverse nil))
2902 (setq data (cdr data))))))
2904 (defmacro gnus-data-list (backward)
2906 (or gnus-newsgroup-data-reverse
2907 (setq gnus-newsgroup-data-reverse
2908 (reverse gnus-newsgroup-data)))
2909 gnus-newsgroup-data))
2911 (defun gnus-data-update-list (data offset)
2912 "Add OFFSET to the POS of all data entries in DATA."
2913 (setq gnus-newsgroup-data-reverse nil)
2915 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2916 (setq data (cdr data))))
2918 (defun gnus-summary-article-pseudo-p (article)
2919 "Say whether this article is a pseudo article or not."
2920 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2922 (defmacro gnus-summary-article-sparse-p (article)
2923 "Say whether this article is a sparse article or not."
2924 `(memq ,article gnus-newsgroup-sparse))
2926 (defmacro gnus-summary-article-ancient-p (article)
2927 "Say whether this article is a sparse article or not."
2928 `(memq ,article gnus-newsgroup-ancient))
2930 (defun gnus-article-parent-p (number)
2931 "Say whether this article is a parent or not."
2932 (let ((data (gnus-data-find-list number)))
2933 (and (cdr data) ; There has to be an article after...
2934 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2935 (gnus-data-level (nth 1 data))))))
2937 (defun gnus-article-children (number)
2938 "Return a list of all children to NUMBER."
2939 (let* ((data (gnus-data-find-list number))
2940 (level (gnus-data-level (car data)))
2942 (setq data (cdr data))
2944 (= (gnus-data-level (car data)) (1+ level)))
2945 (push (gnus-data-number (car data)) children)
2946 (setq data (cdr data)))
2949 (defmacro gnus-summary-skip-intangible ()
2950 "If the current article is intangible, then jump to a different article."
2951 '(let ((to (get-text-property (point) 'gnus-intangible)))
2952 (and to (gnus-summary-goto-subject to))))
2954 (defmacro gnus-summary-article-intangible-p ()
2955 "Say whether this article is intangible or not."
2956 '(get-text-property (point) 'gnus-intangible))
2958 (defun gnus-article-read-p (article)
2959 "Say whether ARTICLE is read or not."
2960 (not (or (memq article gnus-newsgroup-marked)
2961 (memq article gnus-newsgroup-spam-marked)
2962 (memq article gnus-newsgroup-unreads)
2963 (memq article gnus-newsgroup-unselected)
2964 (memq article gnus-newsgroup-dormant))))
2966 ;; Some summary mode macros.
2968 (defmacro gnus-summary-article-number ()
2969 "The article number of the article on the current line.
2970 If there isn't an article number here, then we return the current
2973 (gnus-summary-skip-intangible)
2974 (or (get-text-property (point) 'gnus-number)
2975 (gnus-summary-last-subject))))
2977 (defmacro gnus-summary-article-header (&optional number)
2978 "Return the header of article NUMBER."
2979 `(gnus-data-header (gnus-data-find
2980 ,(or number '(gnus-summary-article-number)))))
2982 (defmacro gnus-summary-thread-level (&optional number)
2983 "Return the level of thread that starts with article NUMBER."
2984 `(if (and (eq gnus-summary-make-false-root 'dummy)
2985 (get-text-property (point) 'gnus-intangible))
2987 (gnus-data-level (gnus-data-find
2988 ,(or number '(gnus-summary-article-number))))))
2990 (defmacro gnus-summary-article-mark (&optional number)
2991 "Return the mark of article NUMBER."
2992 `(gnus-data-mark (gnus-data-find
2993 ,(or number '(gnus-summary-article-number)))))
2995 (defmacro gnus-summary-article-pos (&optional number)
2996 "Return the position of the line of article NUMBER."
2997 `(gnus-data-pos (gnus-data-find
2998 ,(or number '(gnus-summary-article-number)))))
3000 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3001 (defmacro gnus-summary-article-subject (&optional number)
3002 "Return current subject string or nil if nothing."
3005 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3006 '(gnus-data-header (assq (gnus-summary-article-number)
3007 gnus-newsgroup-data)))))
3010 (mail-header-subject headers))))
3012 (defmacro gnus-summary-article-score (&optional number)
3013 "Return current article score."
3014 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3015 gnus-newsgroup-scored))
3016 gnus-summary-default-score 0))
3018 (defun gnus-summary-article-children (&optional number)
3019 "Return a list of article numbers that are children of article NUMBER."
3020 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3021 (level (gnus-data-level (car data)))
3023 (while (and (setq data (cdr data))
3024 (> (setq l (gnus-data-level (car data))) level))
3025 (and (= (1+ level) l)
3026 (push (gnus-data-number (car data))
3028 (nreverse children)))
3030 (defun gnus-summary-article-parent (&optional number)
3031 "Return the article number of the parent of article NUMBER."
3032 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3033 (gnus-data-list t)))
3034 (level (gnus-data-level (car data))))
3036 () ; This is a root.
3037 ;; We search until we find an article with a level less than
3038 ;; this one. That function has to be the parent.
3039 (while (and (setq data (cdr data))
3040 (not (< (gnus-data-level (car data)) level))))
3041 (and data (gnus-data-number (car data))))))
3043 (defun gnus-unread-mark-p (mark)
3044 "Say whether MARK is the unread mark."
3045 (= mark gnus-unread-mark))
3047 (defun gnus-read-mark-p (mark)
3048 "Say whether MARK is one of the marks that mark as read.
3049 This is all marks except unread, ticked, dormant, and expirable."
3050 (not (or (= mark gnus-unread-mark)
3051 (= mark gnus-ticked-mark)
3052 (= mark gnus-spam-mark)
3053 (= mark gnus-dormant-mark)
3054 (= mark gnus-expirable-mark))))
3056 (defmacro gnus-article-mark (number)
3057 "Return the MARK of article NUMBER.
3058 This macro should only be used when computing the mark the \"first\"
3059 time; i.e., when generating the summary lines. After that,
3060 `gnus-summary-article-mark' should be used to examine the
3063 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3064 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3065 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3066 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3067 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3068 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3069 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3070 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3071 gnus-ancient-mark))))
3073 ;; Saving hidden threads.
3075 (defmacro gnus-save-hidden-threads (&rest forms)
3076 "Save hidden threads, eval FORMS, and restore the hidden threads."
3077 (let ((config (make-symbol "config")))
3078 `(let ((,config (gnus-hidden-threads-configuration)))
3082 (gnus-restore-hidden-threads-configuration ,config)))))
3083 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3084 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3086 (defun gnus-data-compute-positions ()
3087 "Compute the positions of all articles."
3088 (setq gnus-newsgroup-data-reverse nil)
3089 (let ((data gnus-newsgroup-data))
3091 (gnus-save-hidden-threads
3092 (gnus-summary-show-all-threads)
3093 (goto-char (point-min))
3095 (while (get-text-property (point) 'gnus-intangible)
3097 (gnus-data-set-pos (car data) (+ (point) 3))
3098 (setq data (cdr data))
3099 (forward-line 1))))))
3101 (defun gnus-hidden-threads-configuration ()
3102 "Return the current hidden threads configuration."
3105 (goto-char (point-min))
3106 (while (search-forward "\r" nil t)
3107 (push (1- (point)) config))
3110 (defun gnus-restore-hidden-threads-configuration (config)
3111 "Restore hidden threads configuration from CONFIG."
3113 (let (point buffer-read-only)
3114 (while (setq point (pop config))
3115 (when (and (< point (point-max))
3117 (eq (char-after) ?\n))
3118 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3120 ;; Various summary mode internalish functions.
3122 (defun gnus-mouse-pick-article (e)
3125 (gnus-summary-next-page nil t))
3127 (defun gnus-summary-set-display-table ()
3128 "Change the display table.
3129 Odd characters have a tendency to mess
3130 up nicely formatted displays - we make all possible glyphs
3131 display only a single character."
3133 ;; We start from the standard display table, if any.
3134 (let ((table (or (copy-sequence standard-display-table)
3135 (make-display-table)))
3137 ;; Nix out all the control chars...
3138 (while (>= (setq i (1- i)) 0)
3139 (aset table i [??]))
3140 ;; ... but not newline and cr, of course. (cr is necessary for the
3141 ;; selective display).
3142 (aset table ?\n nil)
3143 (aset table ?\r nil)
3144 ;; We keep TAB as well.
3145 (aset table ?\t nil)
3146 ;; We nix out any glyphs over 126 that are not set already.
3148 (while (>= (setq i (1- i)) 127)
3149 ;; Only modify if the entry is nil.
3150 (unless (aref table i)
3151 (aset table i [??]))))
3152 (setq buffer-display-table table)))
3154 (defun gnus-summary-set-article-display-arrow (pos)
3155 "Update the overlay arrow to point to line at position POS."
3156 (when (and gnus-summary-display-arrow
3157 (boundp 'overlay-arrow-position)
3158 (boundp 'overlay-arrow-string))
3162 (unless overlay-arrow-position
3163 (setq overlay-arrow-position (make-marker)))
3164 (setq overlay-arrow-string "=>"
3165 overlay-arrow-position (set-marker overlay-arrow-position
3167 (current-buffer))))))
3169 (defun gnus-summary-setup-buffer (group)
3170 "Initialize summary buffer."
3171 (let ((buffer (gnus-summary-buffer-name group))
3172 (dead-name (concat "*Dead Summary "
3173 (gnus-group-decoded-name group) "*")))
3174 ;; If a dead summary buffer exists, we kill it.
3175 (when (gnus-buffer-live-p dead-name)
3176 (gnus-kill-buffer dead-name))
3177 (if (get-buffer buffer)
3180 (setq gnus-summary-buffer (current-buffer))
3181 (not gnus-newsgroup-prepared))
3182 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3183 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3184 (gnus-summary-mode group)
3186 (gnus-carpal-setup-buffer 'summary))
3187 (unless gnus-single-article-buffer
3188 (make-local-variable 'gnus-article-buffer)
3189 (make-local-variable 'gnus-article-current)
3190 (make-local-variable 'gnus-original-article-buffer))
3191 (setq gnus-newsgroup-name group)
3192 ;; Set any local variables in the group parameters.
3193 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3196 (defun gnus-set-global-variables ()
3197 "Set the global equivalents of the buffer-local variables.
3198 They are set to the latest values they had. These reflect the summary
3199 buffer that was in action when the last article was fetched."
3200 (when (eq major-mode 'gnus-summary-mode)
3201 (setq gnus-summary-buffer (current-buffer))
3202 (let ((name gnus-newsgroup-name)
3203 (marked gnus-newsgroup-marked)
3204 (spam gnus-newsgroup-spam-marked)
3205 (unread gnus-newsgroup-unreads)
3206 (headers gnus-current-headers)
3207 (data gnus-newsgroup-data)
3208 (summary gnus-summary-buffer)
3209 (article-buffer gnus-article-buffer)
3210 (original gnus-original-article-buffer)
3211 (gac gnus-article-current)
3212 (reffed gnus-reffed-article-number)
3213 (score-file gnus-current-score-file)
3214 (default-charset gnus-newsgroup-charset)
3216 (let ((locals gnus-newsgroup-variables))
3218 (if (consp (car locals))
3219 (push (eval (caar locals)) vlist)
3220 (push (eval (car locals)) vlist))
3221 (setq locals (cdr locals)))
3222 (setq vlist (nreverse vlist)))
3223 (with-current-buffer gnus-group-buffer
3224 (setq gnus-newsgroup-name name
3225 gnus-newsgroup-marked marked
3226 gnus-newsgroup-spam-marked spam
3227 gnus-newsgroup-unreads unread
3228 gnus-current-headers headers
3229 gnus-newsgroup-data data
3230 gnus-article-current gac
3231 gnus-summary-buffer summary
3232 gnus-article-buffer article-buffer
3233 gnus-original-article-buffer original
3234 gnus-reffed-article-number reffed
3235 gnus-current-score-file score-file
3236 gnus-newsgroup-charset default-charset)
3237 (let ((locals gnus-newsgroup-variables))
3239 (if (consp (car locals))
3240 (set (caar locals) (pop vlist))
3241 (set (car locals) (pop vlist)))
3242 (setq locals (cdr locals))))
3243 ;; The article buffer also has local variables.
3244 (when (gnus-buffer-live-p gnus-article-buffer)
3245 (set-buffer gnus-article-buffer)
3246 (setq gnus-summary-buffer summary))))))
3248 (defun gnus-summary-article-unread-p (article)
3249 "Say whether ARTICLE is unread or not."
3250 (memq article gnus-newsgroup-unreads))
3252 (defun gnus-summary-first-article-p (&optional article)
3253 "Return whether ARTICLE is the first article in the buffer."
3254 (if (not (setq article (or article (gnus-summary-article-number))))
3256 (eq article (caar gnus-newsgroup-data))))
3258 (defun gnus-summary-last-article-p (&optional article)
3259 "Return whether ARTICLE is the last article in the buffer."
3260 (if (not (setq article (or article (gnus-summary-article-number))))
3261 ;; All non-existent numbers are the last article. :-)
3263 (not (cdr (gnus-data-find-list article)))))
3265 (defun gnus-make-thread-indent-array ()
3267 (unless (and gnus-thread-indent-array
3268 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3269 (setq gnus-thread-indent-array (make-vector 201 "")
3270 gnus-thread-indent-array-level gnus-thread-indent-level)
3272 (aset gnus-thread-indent-array n
3273 (make-string (* n gnus-thread-indent-level) ? ))
3276 (defun gnus-update-summary-mark-positions ()
3277 "Compute where the summary marks are to go."
3279 (when (gnus-buffer-exists-p gnus-summary-buffer)
3280 (set-buffer gnus-summary-buffer))
3281 (let ((spec gnus-summary-line-format-spec)
3284 (gnus-set-work-buffer)
3285 (let ((gnus-tmp-unread ?Z)
3286 (gnus-replied-mark ?Z)
3287 (gnus-score-below-mark ?Z)
3288 (gnus-score-over-mark ?Z)
3289 (gnus-undownloaded-mark ?Z)
3290 (gnus-summary-line-format-spec spec)
3291 (gnus-newsgroup-downloadable '(0))
3293 (make-full-mail-header
3294 0 "" "nobody" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil))
3295 case-fold-search ignores)
3296 ;; Here, all marks are bound to Z.
3297 (gnus-summary-insert-line header
3298 0 nil t gnus-tmp-unread t nil "" nil 1)
3299 (goto-char (point-min))
3300 ;; Memorize the positions of the same characters as dummy marks.
3301 (while (re-search-forward "[A-D]" nil t)
3302 (push (point) ignores))
3304 ;; We use A-D as dummy marks in order to know column positions
3305 ;; where marks should be inserted.
3306 (setq gnus-tmp-unread ?A
3307 gnus-replied-mark ?B
3308 gnus-score-below-mark ?C
3309 gnus-score-over-mark ?C
3310 gnus-undownloaded-mark ?D)
3311 (gnus-summary-insert-line header
3312 0 nil t gnus-tmp-unread t nil "" nil 1)
3313 ;; Ignore characters which aren't dummy marks.
3315 (delete-region (goto-char (1- p)) p)
3317 (goto-char (point-min))
3318 (setq pos (list (cons 'unread
3319 (and (search-forward "A" nil t)
3320 (- (point) (point-min) 1)))))
3321 (goto-char (point-min))
3322 (push (cons 'replied (and (search-forward "B" nil t)
3323 (- (point) (point-min) 1)))
3325 (goto-char (point-min))
3326 (push (cons 'score (and (search-forward "C" nil t)
3327 (- (point) (point-min) 1)))
3329 (goto-char (point-min))
3330 (push (cons 'download (and (search-forward "D" nil t)
3331 (- (point) (point-min) 1)))
3333 (setq gnus-summary-mark-positions pos))))
3335 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3336 "Insert a dummy root in the summary buffer."
3338 (gnus-add-text-properties
3339 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3340 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3342 (defun gnus-summary-extract-address-component (from)
3343 (or (car (funcall gnus-extract-address-components from))
3346 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3347 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3348 default-mime-charset)))
3349 ;; Is it really necessary to do this next part for each summary line?
3350 ;; Luckily, doesn't seem to slow things down much.
3352 (and gnus-ignored-from-addresses
3353 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3354 (let ((extra-headers (mail-header-extra header))
3358 ((setq to (cdr (assq 'To extra-headers)))
3361 (gnus-summary-extract-address-component
3362 (funcall gnus-decode-encoded-word-function to)))))
3363 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3364 (concat "=> " newsgroups)))))
3365 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3367 (defun gnus-summary-insert-line (gnus-tmp-header
3368 gnus-tmp-level gnus-tmp-current
3369 undownloaded gnus-tmp-unread gnus-tmp-replied
3370 gnus-tmp-expirable gnus-tmp-subject-or-nil
3371 &optional gnus-tmp-dummy gnus-tmp-score
3373 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3374 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3375 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3376 (gnus-tmp-score-char
3377 (if (or (null gnus-summary-default-score)
3378 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3379 gnus-summary-zcore-fuzz))
3381 (if (< gnus-tmp-score gnus-summary-default-score)
3382 gnus-score-below-mark gnus-score-over-mark)))
3383 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3385 (cond (gnus-tmp-process gnus-process-mark)
3386 ((memq gnus-tmp-current gnus-newsgroup-cached)
3388 (gnus-tmp-replied gnus-replied-mark)
3389 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3390 gnus-forwarded-mark)
3391 ((memq gnus-tmp-current gnus-newsgroup-saved)
3393 ((memq gnus-tmp-number gnus-newsgroup-recent)
3395 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3398 (gnus-tmp-downloaded
3400 gnus-undownloaded-mark)
3401 (gnus-newsgroup-agentized
3402 gnus-downloaded-mark)
3405 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3408 ((string-match "<[^>]+> *$" gnus-tmp-from)
3409 (let ((beg (match-beginning 0)))
3410 (or (and (string-match "^\".+\"" gnus-tmp-from)
3411 (substring gnus-tmp-from 1 (1- (match-end 0))))
3412 (substring gnus-tmp-from 0 beg))))
3413 ((string-match "(.+)" gnus-tmp-from)
3414 (substring gnus-tmp-from
3415 (1+ (match-beginning 0)) (1- (match-end 0))))
3417 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3418 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3419 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3420 (buffer-read-only nil))
3421 (when (string= gnus-tmp-name "")
3422 (setq gnus-tmp-name gnus-tmp-from))
3423 (unless (numberp gnus-tmp-lines)
3424 (setq gnus-tmp-lines -1))
3425 (if (= gnus-tmp-lines -1)
3426 (setq gnus-tmp-lines "?")
3427 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3428 (gnus-put-text-property-excluding-characters-with-faces
3430 (progn (eval gnus-summary-line-format-spec) (point))
3431 'gnus-number gnus-tmp-number)
3432 (when (gnus-visual-p 'summary-highlight 'highlight)
3434 (gnus-run-hooks 'gnus-summary-update-hook)
3437 (defun gnus-summary-update-line (&optional dont-update)
3438 "Update summary line after change."
3439 (when (and gnus-summary-default-score
3440 (not gnus-summary-inhibit-highlight))
3441 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3442 (article (gnus-summary-article-number))
3443 (score (gnus-summary-article-score article)))
3445 (if (and gnus-summary-mark-below
3446 (< (gnus-summary-article-score)
3447 gnus-summary-mark-below))
3448 ;; This article has a low score, so we mark it as read.
3449 (when (memq article gnus-newsgroup-unreads)
3450 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3451 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3452 ;; This article was previously marked as read on account
3453 ;; of a low score, but now it has risen, so we mark it as
3455 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3456 (gnus-summary-update-mark
3457 (if (or (null gnus-summary-default-score)
3458 (<= (abs (- score gnus-summary-default-score))
3459 gnus-summary-zcore-fuzz))
3461 (if (< score gnus-summary-default-score)
3462 gnus-score-below-mark gnus-score-over-mark))
3464 ;; Do visual highlighting.
3465 (when (gnus-visual-p 'summary-highlight 'highlight)
3466 (gnus-run-hooks 'gnus-summary-update-hook)))))
3468 (defvar gnus-tmp-new-adopts nil)
3470 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3471 "Return the number of articles in THREAD.
3472 This may be 0 in some cases -- if none of the articles in
3473 the thread are to be displayed."
3475 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3477 ((not (listp thread))
3479 ((and (consp thread) (cdr thread))
3482 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3485 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3488 (when (and level (zerop level) gnus-tmp-new-adopts)
3491 'gnus-summary-number-of-articles-in-thread
3492 gnus-tmp-new-adopts))))
3494 (if (> number 1) gnus-not-empty-thread-mark
3495 gnus-empty-thread-mark)
3498 (defsubst gnus-summary-line-message-size (head)
3499 "Return pretty-printed version of message size.
3500 This function is intended to be used in
3501 `gnus-summary-line-format-alist'."
3502 (let ((c (or (mail-header-chars head) -1)))
3503 (cond ((< c 0) "n/a") ; chars not available
3504 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3505 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3506 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3507 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3510 (defun gnus-summary-set-local-parameters (group)
3511 "Go through the local params of GROUP and set all variable specs in that list."
3512 (let ((vars '(quit-config))) ; Ignore quit-config.
3513 (dolist (elem (gnus-group-find-parameter group))
3514 (and (consp elem) ; Has to be a cons.
3515 (consp (cdr elem)) ; The cdr has to be a list.
3516 (symbolp (car elem)) ; Has to be a symbol in there.
3517 (not (memq (car elem) vars))
3518 (ignore-errors ; So we set it.
3519 (push (car elem) vars)
3520 (make-local-variable (car elem))
3521 (set (car elem) (eval (nth 1 elem))))))))
3523 (defun gnus-summary-read-group (group &optional show-all no-article
3524 kill-buffer no-display backward
3526 "Start reading news in newsgroup GROUP.
3527 If SHOW-ALL is non-nil, already read articles are also listed.
3528 If NO-ARTICLE is non-nil, no article is selected initially.
3529 If NO-DISPLAY, don't generate a summary buffer."
3533 (let ((gnus-auto-select-next nil))
3534 (or (gnus-summary-read-group-1
3535 group show-all no-article
3536 kill-buffer no-display
3539 select-articles nil)))))
3540 (eq gnus-auto-select-next 'quietly))
3541 (set-buffer gnus-group-buffer)
3542 ;; The entry function called above goes to the next
3543 ;; group automatically, so we go two groups back
3544 ;; if we are searching for the previous group.
3546 (gnus-group-prev-unread-group 2))
3547 (if (not (equal group (gnus-group-group-name)))
3548 (setq group (gnus-group-group-name))
3552 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3553 "Directly jump to the other GROUP from summary buffer.
3554 If SHOW-ALL is non-nil, already read articles are also listed."
3556 (if (eq gnus-summary-buffer (current-buffer))
3557 (list (completing-read
3558 "Group: " gnus-active-hashtb nil t
3559 (when (and gnus-newsgroup-name
3560 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3561 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3562 'gnus-group-history)
3564 (error "%s must be invoked from a gnus summary buffer." this-command)))
3565 (unless (or (zerop (length group))
3566 (and gnus-newsgroup-name
3567 (string-equal gnus-newsgroup-name group)))
3569 (gnus-summary-read-group group show-all
3570 gnus-dont-select-after-jump-to-other-group)))
3572 (defun gnus-summary-read-group-1 (group show-all no-article
3573 kill-buffer no-display
3574 &optional select-articles)
3575 ;; Killed foreign groups can't be entered.
3576 ;; (when (and (not (gnus-group-native-p group))
3577 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3578 ;; (error "Dead non-native groups can't be entered"))
3579 (gnus-message 5 "Retrieving newsgroup: %s..."
3580 (gnus-group-decoded-name group))
3581 (let* ((new-group (gnus-summary-setup-buffer group))
3582 (quit-config (gnus-group-quit-config group))
3583 (did-select (and new-group (gnus-select-newsgroup
3584 group show-all select-articles))))
3586 ;; This summary buffer exists already, so we just select it.
3588 (gnus-set-global-variables)
3590 (gnus-kill-or-deaden-summary kill-buffer))
3591 (gnus-configure-windows 'summary 'force)
3592 (gnus-set-mode-line 'summary)
3593 (gnus-summary-position-point)
3596 ;; We couldn't select this group.
3598 (when (and (eq major-mode 'gnus-summary-mode)
3599 (not (equal (current-buffer) kill-buffer)))
3600 (kill-buffer (current-buffer))
3601 (if (not quit-config)
3603 ;; Update the info -- marks might need to be removed,
3605 (gnus-summary-update-info)
3606 (set-buffer gnus-group-buffer)
3607 (gnus-group-jump-to-group group)
3608 (gnus-group-next-unread-group 1))
3609 (gnus-handle-ephemeral-exit quit-config)))
3610 (let ((grpinfo (gnus-get-info group)))
3611 (if (null (gnus-info-read grpinfo))
3612 (gnus-message 3 "Group %s contains no messages"
3613 (gnus-group-decoded-name group))
3614 (gnus-message 3 "Can't select group")))
3616 ;; The user did a `C-g' while prompting for number of articles,
3617 ;; so we exit this group.
3618 ((eq did-select 'quit)
3619 (and (eq major-mode 'gnus-summary-mode)
3620 (not (equal (current-buffer) kill-buffer))
3621 (kill-buffer (current-buffer)))
3623 (gnus-kill-or-deaden-summary kill-buffer))
3624 (if (not quit-config)
3626 (set-buffer gnus-group-buffer)
3627 (gnus-group-jump-to-group group)
3628 (gnus-group-next-unread-group 1)
3629 (gnus-configure-windows 'group 'force))
3630 (gnus-handle-ephemeral-exit quit-config))
3631 ;; Finally signal the quit.
3633 ;; The group was successfully selected.
3635 (gnus-set-global-variables)
3636 ;; Save the active value in effect when the group was entered.
3637 (setq gnus-newsgroup-active
3639 (gnus-active gnus-newsgroup-name)))
3640 ;; You can change the summary buffer in some way with this hook.
3641 (gnus-run-hooks 'gnus-select-group-hook)
3642 (when (memq 'summary (gnus-update-format-specifications
3643 nil 'summary 'summary-mode 'summary-dummy))
3644 ;; The format specification for the summary line was updated,
3645 ;; so we need to update the mark positions as well.
3646 (gnus-update-summary-mark-positions))
3647 ;; Do score processing.
3648 (when gnus-use-scoring
3649 (gnus-possibly-score-headers))
3650 ;; Check whether to fill in the gaps in the threads.
3651 (when gnus-build-sparse-threads
3652 (gnus-build-sparse-threads))
3653 ;; Find the initial limit.
3655 (let ((gnus-newsgroup-dormant nil))
3656 (gnus-summary-initial-limit show-all))
3657 (gnus-summary-initial-limit show-all))
3658 ;; Generate the summary buffer.
3660 (gnus-summary-prepare))
3661 (when gnus-use-trees
3662 (gnus-tree-open group)
3663 (setq gnus-summary-highlight-line-function
3664 'gnus-tree-highlight-article))
3665 ;; If the summary buffer is empty, but there are some low-scored
3666 ;; articles or some excluded dormants, we include these in the
3668 (when (and (zerop (buffer-size))
3670 (cond (gnus-newsgroup-dormant
3671 (gnus-summary-limit-include-dormant))
3672 ((and gnus-newsgroup-scored show-all)
3673 (gnus-summary-limit-include-expunged t))))
3674 ;; Function `gnus-apply-kill-file' must be called in this hook.
3675 (gnus-run-hooks 'gnus-apply-kill-hook)
3676 (if (and (zerop (buffer-size))
3679 ;; This newsgroup is empty.
3680 (gnus-summary-catchup-and-exit nil t)
3681 (gnus-message 6 "No unread news")
3683 (gnus-kill-or-deaden-summary kill-buffer))
3684 ;; Return nil from this function.
3686 ;; Hide conversation thread subtrees. We cannot do this in
3687 ;; gnus-summary-prepare-hook since kill processing may not
3688 ;; work with hidden articles.
3689 (gnus-summary-maybe-hide-threads)
3691 (gnus-kill-or-deaden-summary kill-buffer))
3692 (gnus-summary-auto-select-subject)
3693 ;; Show first unread article if requested.
3694 (if (and (not no-article)
3696 gnus-newsgroup-unreads
3697 gnus-auto-select-first)
3699 (gnus-configure-windows 'summary)
3700 (let ((art (gnus-summary-article-number)))
3701 (unless (and (not gnus-plugged)
3702 (or (memq art gnus-newsgroup-undownloaded)
3703 (memq art gnus-newsgroup-downloadable)))
3704 (gnus-summary-goto-article art))))
3705 ;; Don't select any articles.
3706 (gnus-summary-position-point)
3707 (gnus-configure-windows 'summary 'force)
3708 (gnus-set-mode-line 'summary))
3709 (when (and gnus-auto-center-group
3710 (get-buffer-window gnus-group-buffer t))
3711 ;; Gotta use windows, because recenter does weird stuff if
3712 ;; the current buffer ain't the displayed window.
3713 (let ((owin (selected-window)))
3714 (select-window (get-buffer-window gnus-group-buffer t))
3715 (when (gnus-group-goto-group group)
3717 (select-window owin)))
3718 ;; Mark this buffer as "prepared".
3719 (setq gnus-newsgroup-prepared t)
3720 (gnus-run-hooks 'gnus-summary-prepared-hook)
3721 (unless (gnus-ephemeral-group-p group)
3722 (gnus-group-update-group group))
3725 (defun gnus-summary-auto-select-subject ()
3726 "Select the subject line on initial group entry."
3727 (goto-char (point-min))
3729 ((eq gnus-auto-select-subject 'best)
3730 (gnus-summary-best-unread-subject))
3731 ((eq gnus-auto-select-subject 'unread)
3732 (gnus-summary-first-unread-subject))
3733 ((eq gnus-auto-select-subject 'unseen)
3734 (gnus-summary-first-unseen-subject))
3735 ((eq gnus-auto-select-subject 'unseen-or-unread)
3736 (gnus-summary-first-unseen-or-unread-subject))
3737 ((eq gnus-auto-select-subject 'first)
3740 ((functionp gnus-auto-select-subject)
3741 (funcall gnus-auto-select-subject))))
3743 (defun gnus-summary-prepare ()
3744 "Generate the summary buffer."
3746 (let ((buffer-read-only nil))
3748 (setq gnus-newsgroup-data nil
3749 gnus-newsgroup-data-reverse nil)
3750 (gnus-run-hooks 'gnus-summary-generate-hook)
3751 ;; Generate the buffer, either with threads or without.
3752 (when gnus-newsgroup-headers
3753 (gnus-summary-prepare-threads
3754 (if gnus-show-threads
3755 (gnus-sort-gathered-threads
3756 (funcall gnus-summary-thread-gathering-function
3758 (gnus-cut-threads (gnus-make-threads)))))
3759 ;; Unthreaded display.
3760 (gnus-sort-articles gnus-newsgroup-headers))))
3761 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3762 ;; Call hooks for modifying summary buffer.
3763 (goto-char (point-min))
3764 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3766 (defsubst gnus-general-simplify-subject (subject)
3767 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3770 ;; Truncate the subject.
3771 (gnus-simplify-subject-functions
3772 (gnus-map-function gnus-simplify-subject-functions subject))
3773 ((numberp gnus-summary-gather-subject-limit)
3774 (setq subject (gnus-simplify-subject-re subject))
3775 (if (> (length subject) gnus-summary-gather-subject-limit)
3776 (substring subject 0 gnus-summary-gather-subject-limit)
3778 ;; Fuzzily simplify it.
3779 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3780 (gnus-simplify-subject-fuzzy subject))
3781 ;; Just remove the leading "Re:".
3783 (gnus-simplify-subject-re subject))))
3785 (if (and gnus-summary-gather-exclude-subject
3786 (string-match gnus-summary-gather-exclude-subject subject))
3787 nil ; This article shouldn't be gathered
3790 (defun gnus-summary-simplify-subject-query ()
3791 "Query where the respool algorithm would put this article."
3793 (gnus-summary-select-article)
3795 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3797 (defun gnus-gather-threads-by-subject (threads)
3798 "Gather threads by looking at Subject headers."
3799 (if (not gnus-summary-make-false-root)
3801 (let ((hashtb (gnus-make-hashtable 1024))
3804 subject hthread whole-subject)
3806 (setq subject (gnus-general-simplify-subject
3807 (setq whole-subject (mail-header-subject
3810 (if (setq hthread (gnus-gethash subject hashtb))
3812 ;; We enter a dummy root into the thread, if we
3813 ;; haven't done that already.
3814 (unless (stringp (caar hthread))
3815 (setcar hthread (list whole-subject (car hthread))))
3816 ;; We add this new gathered thread to this gathered
3818 (setcdr (car hthread)
3819 (nconc (cdar hthread) (list (car threads))))
3820 ;; Remove it from the list of threads.
3821 (setcdr prev (cdr threads))
3822 (setq threads prev))
3823 ;; Enter this thread into the hash table.
3824 (gnus-sethash subject
3825 (if gnus-summary-make-false-root-always
3827 ;; If you want a dummy root above all
3829 (setcar threads (list whole-subject
3835 (setq threads (cdr threads)))
3838 (defun gnus-gather-threads-by-references (threads)
3839 "Gather threads by looking at References headers."
3840 (let ((idhashtb (gnus-make-hashtable 1024))
3841 (thhashtb (gnus-make-hashtable 1024))
3844 ids references id gthread gid entered ref)
3846 (when (setq references (mail-header-references (caar threads)))
3847 (setq id (mail-header-id (caar threads))
3848 ids (inline (gnus-split-references references))
3850 (while (setq ref (pop ids))
3851 (setq ids (delete ref ids))
3852 (if (not (setq gid (gnus-gethash ref idhashtb)))
3854 (gnus-sethash ref id idhashtb)
3855 (gnus-sethash id threads thhashtb))
3856 (setq gthread (gnus-gethash gid thhashtb))
3858 ;; We enter a dummy root into the thread, if we
3859 ;; haven't done that already.
3860 (unless (stringp (caar gthread))
3861 (setcar gthread (list (mail-header-subject (caar gthread))
3863 ;; We add this new gathered thread to this gathered
3865 (setcdr (car gthread)
3866 (nconc (cdar gthread) (list (car threads)))))
3867 ;; Add it into the thread hash table.
3868 (gnus-sethash id gthread thhashtb)
3870 ;; Remove it from the list of threads.
3871 (setcdr prev (cdr threads))
3872 (setq threads prev))))
3874 (setq threads (cdr threads)))
3877 (defun gnus-sort-gathered-threads (threads)
3878 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3879 (let ((result threads))
3881 (when (stringp (caar threads))
3882 (setcdr (car threads)
3883 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3884 (setq threads (cdr threads)))
3887 (defun gnus-thread-loop-p (root thread)
3888 "Say whether ROOT is in THREAD."
3889 (let ((stack (list thread))
3892 (while (setq thread (pop stack))
3893 (setq th (cdr thread))
3895 (not (eq (caar th) root)))
3898 ;; We have found a loop.
3900 (setcdr thread (delq (car th) (cdr thread)))
3901 (if (boundp (setq ref-dep (intern "none"
3902 gnus-newsgroup-dependencies)))
3903 (setcdr (symbol-value ref-dep)
3904 (nconc (cdr (symbol-value ref-dep))
3906 (set ref-dep (list nil (car th))))
3909 ;; Push all the subthreads onto the stack.
3910 (push (cdr thread) stack)))
3913 (defun gnus-make-threads ()
3914 "Go through the dependency hashtb and find the roots. Return all threads."
3916 (while (catch 'infloop
3919 ;; Deal with self-referencing References loops.
3920 (when (and (car (symbol-value refs))
3927 (car (symbol-value refs)) thread))
3928 (cdr (symbol-value refs)))))))
3931 (unless (car (symbol-value refs))
3932 ;; These threads do not refer back to any other articles,
3933 ;; so they're roots.
3934 (setq threads (append (cdr (symbol-value refs)) threads))))
3935 gnus-newsgroup-dependencies)))
3938 ;; Build the thread tree.
3939 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3940 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3942 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3943 if it was already present.
3945 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3946 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3947 Message-IDs will be renamed to a unique Message-ID before being
3950 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3951 (let* ((id (mail-header-id header))
3952 (id-dep (and id (intern id dependencies)))
3953 parent-id ref ref-dep ref-header replaced)
3954 ;; Enter this `header' in the `dependencies' table.
3958 ;; The first two cases do the normal part: enter a new `header'
3959 ;; in the `dependencies' table.
3960 ((not (boundp id-dep))
3961 (set id-dep (list header)))
3962 ((null (car (symbol-value id-dep)))
3963 (setcar (symbol-value id-dep) header))
3965 ;; From here the `header' was already present in the
3966 ;; `dependencies' table.
3968 ;; Overrides an existing entry;
3969 ;; just set the header part of the entry.
3970 (setcar (symbol-value id-dep) header)
3973 ;; Renames the existing `header' to a unique Message-ID.
3974 ((not gnus-summary-ignore-duplicates)
3975 ;; An article with this Message-ID has already been seen.
3976 ;; We rename the Message-ID.
3977 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3979 (mail-header-set-id header id))
3981 ;; The last case ignores an existing entry, except it adds any
3982 ;; additional Xrefs (in case the two articles came from different
3984 ;; Also sets `header' to `nil' meaning that the `dependencies'
3985 ;; table was *not* modified.
3987 (mail-header-set-xref
3988 (car (symbol-value id-dep))
3989 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3991 (or (mail-header-xref header) "")))
3994 (when (and header (not replaced))
3995 ;; First check that we are not creating a References loop.
3996 (setq parent-id (gnus-parent-id (mail-header-references header)))
3997 (setq ref parent-id)
3999 (setq ref-dep (intern-soft ref dependencies))
4001 (setq ref-header (car (symbol-value ref-dep))))
4002 (if (string= id ref)
4003 ;; Yuk! This is a reference loop. Make the article be a
4006 (mail-header-set-references (car (symbol-value id-dep)) "none")
4008 (setq parent-id nil))
4009 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4010 (setq ref-dep (intern (or parent-id "none") dependencies))
4011 (if (boundp ref-dep)
4012 (setcdr (symbol-value ref-dep)
4013 (nconc (cdr (symbol-value ref-dep))
4014 (list (symbol-value id-dep))))
4015 (set ref-dep (list nil (symbol-value id-dep)))))
4018 (defun gnus-extract-message-id-from-in-reply-to (string)
4019 (if (string-match "<[^>]+>" string)
4020 (substring string (match-beginning 0) (match-end 0))
4023 (defun gnus-build-sparse-threads ()
4024 (let ((headers gnus-newsgroup-headers)
4025 (mail-parse-charset gnus-newsgroup-charset)
4026 (gnus-summary-ignore-duplicates t)
4027 header references generation relations
4028 subject child end new-child date)
4029 ;; First we create an alist of generations/relations, where
4030 ;; generations is how much we trust the relation, and the relation
4032 (gnus-message 7 "Making sparse threads...")
4034 (nnheader-set-temp-buffer " *gnus sparse threads*")
4035 (while (setq header (pop headers))
4036 (when (and (setq references (mail-header-references header))
4037 (not (string= references "")))
4039 (setq child (mail-header-id header)
4040 subject (mail-header-subject header)
4041 date (mail-header-date header)
4043 (while (search-backward ">" nil t)
4044 (setq end (1+ (point)))
4045 (when (search-backward "<" nil t)
4046 (setq new-child (buffer-substring (point) end))
4047 (push (list (incf generation)
4048 child (setq child new-child)
4052 (push (list (1+ generation) child nil subject) relations))
4054 (kill-buffer (current-buffer)))
4055 ;; Sort over trustworthiness.
4058 (when (gnus-dependencies-add-header
4059 (make-full-mail-header-from-decoded-header
4060 gnus-reffed-article-number
4061 (nth 3 relation) "" (or (nth 4 relation) "")
4063 (or (nth 2 relation) "") 0 0 "")
4064 gnus-newsgroup-dependencies nil)
4065 (push gnus-reffed-article-number gnus-newsgroup-limit)
4066 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4067 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4068 gnus-newsgroup-reads)
4069 (decf gnus-reffed-article-number)))
4070 (sort relations 'car-less-than-car))
4071 (gnus-message 7 "Making sparse threads...done")))
4073 (defun gnus-build-old-threads ()
4074 ;; Look at all the articles that refer back to old articles, and
4075 ;; fetch the headers for the articles that aren't there. This will
4076 ;; build complete threads - if the roots haven't been expired by the
4078 (let ((mail-parse-charset gnus-newsgroup-charset)
4082 (when (not (car (symbol-value refs)))
4083 (setq heads (cdr (symbol-value refs)))
4085 (if (memq (mail-header-number (caar heads))
4086 gnus-newsgroup-dormant)
4087 (setq heads (cdr heads))
4088 (setq id (symbol-name refs))
4089 (while (and (setq id (gnus-build-get-header id))
4090 (not (car (gnus-id-to-thread id)))))
4091 (setq heads nil)))))
4092 gnus-newsgroup-dependencies)))
4094 (defsubst gnus-remove-odd-characters (string)
4095 "Translate STRING into something that doesn't contain weird characters."
4096 (mm-subst-char-in-string
4098 (mm-subst-char-in-string ?\n ?\- string t) t))
4100 ;; This function has to be called with point after the article number
4101 ;; on the beginning of the line.
4102 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4103 (let ((eol (point-at-eol))
4104 (buffer (current-buffer))
4105 header references in-reply-to)
4107 ;; overview: [num subject from date id refs chars lines misc]
4110 (narrow-to-region (point) eol)
4115 (make-full-mail-header
4117 (nnheader-nov-field) ; subject
4118 (nnheader-nov-field) ; from
4119 (nnheader-nov-field) ; date
4120 (nnheader-nov-read-message-id number) ; id
4121 (setq references (nnheader-nov-field)) ; refs
4122 (nnheader-nov-read-integer) ; chars
4123 (nnheader-nov-read-integer) ; lines
4125 (if (looking-at "Xref: ")
4126 (goto-char (match-end 0)))
4127 (nnheader-nov-field)) ; Xref
4128 (nnheader-nov-parse-extra)))) ; extra
4132 (when (and (string= references "")
4133 (setq in-reply-to (mail-header-extra header))
4134 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4135 (mail-header-set-references
4136 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4138 (when gnus-alter-header-function
4139 (funcall gnus-alter-header-function header))
4140 (gnus-dependencies-add-header header dependencies force-new)))
4142 (defun gnus-build-get-header (id)
4143 "Look through the buffer of NOV lines and find the header to ID.
4144 Enter this line into the dependencies hash table, and return
4145 the id of the parent article (if any)."
4146 (let ((deps gnus-newsgroup-dependencies)
4150 (set-buffer nntp-server-buffer)
4151 (let ((case-fold-search nil))
4152 (goto-char (point-min))
4153 (while (and (not found)
4154 (search-forward id nil t))
4156 (setq found (looking-at
4157 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4158 (regexp-quote id))))
4159 (or found (beginning-of-line 2)))
4163 (setq header (gnus-nov-parse-line
4164 (read (current-buffer)) deps))
4165 (gnus-parent-id (mail-header-references header))))))
4167 (let ((number (mail-header-number header)))
4168 (push number gnus-newsgroup-limit)
4169 (push header gnus-newsgroup-headers)
4170 (if (memq number gnus-newsgroup-unselected)
4172 (setq gnus-newsgroup-unreads
4173 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4175 (setq gnus-newsgroup-unselected
4176 (delq number gnus-newsgroup-unselected)))
4177 (push number gnus-newsgroup-ancient)))))))
4179 (defun gnus-build-all-threads ()
4180 "Read all the headers."
4181 (let ((gnus-summary-ignore-duplicates t)
4182 (mail-parse-charset gnus-newsgroup-charset)
4183 (dependencies gnus-newsgroup-dependencies)
4186 (set-buffer nntp-server-buffer)
4187 (let ((case-fold-search nil))
4188 (goto-char (point-min))
4191 (setq article (read (current-buffer))
4192 header (gnus-nov-parse-line article dependencies)))
4194 (with-current-buffer gnus-summary-buffer
4195 (push header gnus-newsgroup-headers)
4196 (if (memq (setq article (mail-header-number header))
4197 gnus-newsgroup-unselected)
4199 (setq gnus-newsgroup-unreads
4200 (gnus-add-to-sorted-list
4201 gnus-newsgroup-unreads article))
4202 (setq gnus-newsgroup-unselected
4203 (delq article gnus-newsgroup-unselected)))
4204 (push article gnus-newsgroup-ancient)))
4205 (forward-line 1)))))))
4207 (defun gnus-summary-update-article-line (article header)
4208 "Update the line for ARTICLE using HEADER."
4209 (let* ((id (mail-header-id header))
4210 (thread (gnus-id-to-thread id)))
4212 (error "Article in no thread"))
4213 ;; Update the thread.
4214 (setcar thread header)
4215 (gnus-summary-goto-subject article)
4216 (let* ((datal (gnus-data-find-list article))
4218 (buffer-read-only nil)
4219 (level (gnus-summary-thread-level)))
4221 (let ((inserted (- (point)
4223 (gnus-summary-insert-line
4225 (memq article gnus-newsgroup-undownloaded)
4226 (gnus-article-mark article)
4227 (memq article gnus-newsgroup-replied)
4228 (memq article gnus-newsgroup-expirable)
4229 ;; Only insert the Subject string when it's different
4230 ;; from the previous Subject string.
4235 (mail-header-subject
4238 (gnus-data-find-list
4240 (gnus-data-list t)))))
4241 ;; Error on the side of excessive subjects.
4243 (mail-header-subject header)))
4245 (mail-header-subject header))
4246 nil (cdr (assq article gnus-newsgroup-scored))
4247 (memq article gnus-newsgroup-processable))
4250 (gnus-data-update-list
4252 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4254 (defun gnus-summary-update-article (article &optional iheader)
4255 "Update ARTICLE in the summary buffer."
4256 (set-buffer gnus-summary-buffer)
4257 (let* ((header (gnus-summary-article-header article))
4258 (id (mail-header-id header))
4259 (data (gnus-data-find article))
4260 (thread (gnus-id-to-thread id))
4261 (references (mail-header-references header))
4265 (when (and references
4266 (not (equal "" references)))
4269 (buffer-read-only nil)
4275 (delq thread parent)))
4276 (if (gnus-summary-insert-subject id header)
4277 ;; Set the (possibly) new article number in the data structure.
4278 (gnus-data-set-number data (gnus-id-to-article id))
4282 (defun gnus-rebuild-thread (id &optional line)
4283 "Rebuild the thread containing ID.
4284 If LINE, insert the rebuilt thread starting on line LINE."
4285 (let ((buffer-read-only nil)
4286 old-pos current thread data)
4287 (if (not gnus-show-threads)
4288 (setq thread (list (car (gnus-id-to-thread id))))
4289 ;; Get the thread this article is part of.
4290 (setq thread (gnus-remove-thread id)))
4291 (setq old-pos (point-at-bol))
4292 (setq current (save-excursion
4293 (and (re-search-backward "[\r\n]" nil t)
4294 (gnus-summary-article-number))))
4295 ;; If this is a gathered thread, we have to go some re-gathering.
4296 (when (stringp (car thread))
4297 (let ((subject (car thread))
4299 (setq thread (cdr thread))
4301 (unless (memq (setq thr (gnus-id-to-thread
4303 (mail-header-id (caar thread)))))
4306 (setq thread (cdr thread)))
4307 ;; We now have all (unique) roots.
4308 (if (= (length roots) 1)
4309 ;; All the loose roots are now one solid root.
4310 (setq thread (car roots))
4311 (setq thread (cons subject (gnus-sort-threads roots))))))
4313 ;; We then insert this thread into the summary buffer.
4315 (goto-char (point-min))
4316 (forward-line (1- line)))
4317 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4318 (if gnus-show-threads
4319 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4320 (gnus-summary-prepare-unthreaded thread))
4321 (setq data (nreverse gnus-newsgroup-data))
4322 (setq threads gnus-newsgroup-threads))
4323 ;; We splice the new data into the data structure.
4324 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4325 ;;!!! then we want to insert at the beginning of the buffer.
4326 ;;!!! That happens to be true with Gnus now, but that may
4327 ;;!!! change in the future. Perhaps.
4328 (gnus-data-enter-list
4329 (if line nil current) data (- (point) old-pos))
4330 (setq gnus-newsgroup-threads
4331 (nconc threads gnus-newsgroup-threads))
4332 (gnus-data-compute-positions))))
4334 (defun gnus-number-to-header (number)
4335 "Return the header for article NUMBER."
4336 (let ((headers gnus-newsgroup-headers))
4338 (not (= number (mail-header-number (car headers)))))
4343 (defun gnus-parent-headers (in-headers &optional generation)
4344 "Return the headers of the GENERATIONeth parent of HEADERS."
4346 (setq generation 1))
4348 (headers in-headers)
4351 (not (zerop generation))
4352 (setq references (mail-header-references headers)))
4353 (setq headers (if (and references
4354 (setq parent (gnus-parent-id references)))
4355 (car (gnus-id-to-thread parent))
4358 (and (not (eq headers in-headers))
4361 (defun gnus-id-to-thread (id)
4362 "Return the (sub-)thread where ID appears."
4363 (gnus-gethash id gnus-newsgroup-dependencies))
4365 (defun gnus-id-to-article (id)
4366 "Return the article number of ID."
4367 (let ((thread (gnus-id-to-thread id)))
4370 (mail-header-number (car thread)))))
4372 (defun gnus-id-to-header (id)
4373 "Return the article headers of ID."
4374 (car (gnus-id-to-thread id)))
4376 (defun gnus-article-displayed-root-p (article)
4377 "Say whether ARTICLE is a root(ish) article."
4378 (let ((level (gnus-summary-thread-level article))
4379 (refs (mail-header-references (gnus-summary-article-header article)))
4385 ((null (gnus-parent-id refs)) t)
4387 (null (setq particle (gnus-id-to-article
4388 (gnus-parent-id refs))))
4389 (null (gnus-summary-thread-level particle)))))))
4391 (defun gnus-root-id (id)
4392 "Return the id of the root of the thread where ID appears."
4394 (while (and id (setq prev (car (gnus-id-to-thread id))))
4396 id (gnus-parent-id (mail-header-references prev))))
4399 (defun gnus-articles-in-thread (thread)
4400 "Return the list of articles in THREAD."
4401 (cons (mail-header-number (car thread))
4402 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4404 (defun gnus-remove-thread (id &optional dont-remove)
4405 "Remove the thread that has ID in it."
4406 (let (headers thread last-id)
4407 ;; First go up in this thread until we find the root.
4408 (setq last-id (gnus-root-id id)
4409 headers (message-flatten-list (gnus-id-to-thread last-id)))
4410 ;; We have now found the real root of this thread. It might have
4411 ;; been gathered into some loose thread, so we have to search
4412 ;; through the threads to find the thread we wanted.
4413 (let ((threads gnus-newsgroup-threads)
4416 (setq sub (car threads))
4417 (if (stringp (car sub))
4418 ;; This is a gathered thread, so we look at the roots
4419 ;; below it to find whether this article is in this
4422 (setq sub (cdr sub))
4424 (when (member (caar sub) headers)
4425 (setq thread (car threads)
4428 (setq sub (cdr sub))))
4429 ;; It's an ordinary thread, so we check it.
4430 (when (eq (car sub) (car headers))
4433 (setq threads (cdr threads)))
4434 ;; If this article is in no thread, then it's a root.
4437 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4438 (setq thread (gnus-id-to-thread last-id)))
4441 thread ; We return this thread.
4443 (if (stringp (car thread))
4445 ;; If we use dummy roots, then we have to remove the
4446 ;; dummy root as well.
4447 (when (eq gnus-summary-make-false-root 'dummy)
4448 ;; We go to the dummy root by going to
4449 ;; the first sub-"thread", and then one line up.
4450 (gnus-summary-goto-article
4451 (mail-header-number (caadr thread)))
4454 (gnus-data-compute-positions))
4455 (setq thread (cdr thread))
4457 (gnus-remove-thread-1 (car thread))
4458 (setq thread (cdr thread))))
4459 (gnus-remove-thread-1 thread))))))))
4461 (defun gnus-remove-thread-1 (thread)
4462 "Remove the thread THREAD recursively."
4463 (let ((number (mail-header-number (pop thread)))
4465 (setq thread (reverse thread))
4467 (gnus-remove-thread-1 (pop thread)))
4468 (when (setq d (gnus-data-find number))
4469 (goto-char (gnus-data-pos d))
4470 (gnus-summary-show-thread)
4476 (gnus-delete-line)))))))
4478 (defun gnus-sort-threads-1 (threads func)
4479 (sort (mapcar (lambda (thread)
4482 (gnus-sort-threads-1 (cdr thread) func))))
4485 (defun gnus-sort-threads (threads)
4487 (if (not gnus-thread-sort-functions)
4489 (gnus-message 8 "Sorting threads...")
4490 (let ((max-lisp-eval-depth 5000))
4491 (prog1 (gnus-sort-threads-1
4493 (gnus-make-sort-function gnus-thread-sort-functions))
4494 (gnus-message 8 "Sorting threads...done")))))
4496 (defun gnus-sort-articles (articles)
4498 (when gnus-article-sort-functions
4499 (gnus-message 7 "Sorting articles...")
4501 (setq gnus-newsgroup-headers
4502 (sort articles (gnus-make-sort-function
4503 gnus-article-sort-functions)))
4504 (gnus-message 7 "Sorting articles...done"))))
4506 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4507 (defmacro gnus-thread-header (thread)
4508 "Return header of first article in THREAD.
4509 Note that THREAD must never, ever be anything else than a variable -
4510 using some other form will lead to serious barfage."
4511 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4512 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4513 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4516 (defsubst gnus-article-sort-by-number (h1 h2)
4517 "Sort articles by article number."
4518 (< (mail-header-number h1)
4519 (mail-header-number h2)))
4521 (defun gnus-thread-sort-by-number (h1 h2)
4522 "Sort threads by root article number."
4523 (gnus-article-sort-by-number
4524 (gnus-thread-header h1) (gnus-thread-header h2)))
4526 (defsubst gnus-article-sort-by-random (h1 h2)
4527 "Sort articles by article number."
4530 (defun gnus-thread-sort-by-random (h1 h2)
4531 "Sort threads by root article number."
4532 (gnus-article-sort-by-random
4533 (gnus-thread-header h1) (gnus-thread-header h2)))
4535 (defsubst gnus-article-sort-by-lines (h1 h2)
4536 "Sort articles by article Lines header."
4537 (< (mail-header-lines h1)
4538 (mail-header-lines h2)))
4540 (defun gnus-thread-sort-by-lines (h1 h2)
4541 "Sort threads by root article Lines header."
4542 (gnus-article-sort-by-lines
4543 (gnus-thread-header h1) (gnus-thread-header h2)))
4545 (defsubst gnus-article-sort-by-chars (h1 h2)
4546 "Sort articles by octet length."
4547 (< (mail-header-chars h1)
4548 (mail-header-chars h2)))
4550 (defun gnus-thread-sort-by-chars (h1 h2)
4551 "Sort threads by root article octet length."
4552 (gnus-article-sort-by-chars
4553 (gnus-thread-header h1) (gnus-thread-header h2)))
4555 (defsubst gnus-article-sort-by-author (h1 h2)
4556 "Sort articles by root author."
4558 (let ((addr (car (mime-entity-read-field h1 'From))))
4559 (or (std11-full-name-string addr)
4560 (std11-address-string addr)
4562 (let ((addr (car (mime-entity-read-field h2 'From))))
4563 (or (std11-full-name-string addr)
4564 (std11-address-string addr)
4568 (defun gnus-thread-sort-by-author (h1 h2)
4569 "Sort threads by root author."
4570 (gnus-article-sort-by-author
4571 (gnus-thread-header h1) (gnus-thread-header h2)))
4573 (defsubst gnus-article-sort-by-recipient (h1 h2)
4574 "Sort articles by recipient."
4576 (let ((extract (funcall
4577 gnus-extract-address-components
4578 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4579 (or (car extract) (cadr extract)))
4580 (let ((extract (funcall
4581 gnus-extract-address-components
4582 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4583 (or (car extract) (cadr extract)))))
4585 (defsubst gnus-article-sort-by-subject (h1 h2)
4586 "Sort articles by root subject."
4588 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4589 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4591 (defun gnus-thread-sort-by-subject (h1 h2)
4592 "Sort threads by root subject."
4593 (gnus-article-sort-by-subject
4594 (gnus-thread-header h1) (gnus-thread-header h2)))
4596 (defsubst gnus-article-sort-by-date (h1 h2)
4597 "Sort articles by root article date."
4599 (gnus-date-get-time (mail-header-date h1))
4600 (gnus-date-get-time (mail-header-date h2))))
4602 (defun gnus-thread-sort-by-date (h1 h2)
4603 "Sort threads by root article date."
4604 (gnus-article-sort-by-date
4605 (gnus-thread-header h1) (gnus-thread-header h2)))
4607 (defsubst gnus-article-sort-by-score (h1 h2)
4608 "Sort articles by root article score.
4609 Unscored articles will be counted as having a score of zero."
4610 (> (or (cdr (assq (mail-header-number h1)
4611 gnus-newsgroup-scored))
4612 gnus-summary-default-score 0)
4613 (or (cdr (assq (mail-header-number h2)
4614 gnus-newsgroup-scored))
4615 gnus-summary-default-score 0)))
4617 (defun gnus-thread-sort-by-score (h1 h2)
4618 "Sort threads by root article score."
4619 (gnus-article-sort-by-score
4620 (gnus-thread-header h1) (gnus-thread-header h2)))
4622 (defun gnus-thread-sort-by-total-score (h1 h2)
4623 "Sort threads by the sum of all scores in the thread.
4624 Unscored articles will be counted as having a score of zero."
4625 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4627 (defun gnus-thread-total-score (thread)
4628 ;; This function find the total score of THREAD.
4633 (if (stringp (car thread))
4634 (apply gnus-thread-score-function 0
4635 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4636 (gnus-thread-total-score-1 thread)))
4638 (gnus-thread-total-score-1 (list thread)))))
4640 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4641 "Sort threads such that the thread with the most recently arrived article comes first."
4642 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4644 (defun gnus-thread-highest-number (thread)
4645 "Return the highest article number in THREAD."
4646 (apply 'max (mapcar (lambda (header)
4647 (mail-header-number header))
4648 (message-flatten-list thread))))
4650 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4651 "Sort threads such that the thread with the most recently dated article comes first."
4652 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4654 (defun gnus-thread-latest-date (thread)
4655 "Return the highest article date in THREAD."
4656 (let ((previous-time 0))
4662 (time-to-seconds (mail-header-parse-date
4663 (mail-header-date header)))
4664 (error previous-time))))
4666 (message-flatten-list thread)
4668 (< (mail-header-number h1)
4669 (mail-header-number h2))))))))
4671 (defun gnus-thread-total-score-1 (root)
4672 ;; This function find the total score of the thread below ROOT.
4673 (setq root (car root))
4674 (apply gnus-thread-score-function
4676 (mapcar 'gnus-thread-total-score
4677 (cdr (gnus-id-to-thread (mail-header-id root))))
4678 (when (> (mail-header-number root) 0)
4679 (list (or (cdr (assq (mail-header-number root)
4680 gnus-newsgroup-scored))
4681 gnus-summary-default-score 0))))
4682 (list gnus-summary-default-score)
4685 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4686 (defvar gnus-tmp-prev-subject nil)
4687 (defvar gnus-tmp-false-parent nil)
4688 (defvar gnus-tmp-root-expunged nil)
4689 (defvar gnus-tmp-dummy-line nil)
4691 (eval-when-compile (defvar gnus-tmp-header))
4692 (defun gnus-extra-header (type &optional header)
4693 "Return the extra header of TYPE."
4694 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4697 (defvar gnus-tmp-thread-tree-header-string "")
4699 (defcustom gnus-sum-thread-tree-root "> "
4700 "With %B spec, used for the root of a thread.
4701 If nil, use subject instead."
4703 :type '(radio (const :format "%v " nil) string)
4704 :group 'gnus-thread)
4705 (defcustom gnus-sum-thread-tree-false-root "> "
4706 "With %B spec, used for a false root of a thread.
4707 If nil, use subject instead."
4709 :type '(radio (const :format "%v " nil) string)
4710 :group 'gnus-thread)
4711 (defcustom gnus-sum-thread-tree-single-indent ""
4712 "With %B spec, used for a thread with just one message.
4713 If nil, use subject instead."
4715 :type '(radio (const :format "%v " nil) string)
4716 :group 'gnus-thread)
4717 (defcustom gnus-sum-thread-tree-vertical "| "
4718 "With %B spec, used for drawing a vertical line."
4721 :group 'gnus-thread)
4722 (defcustom gnus-sum-thread-tree-indent " "
4723 "With %B spec, used for indenting."
4726 :group 'gnus-thread)
4727 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4728 "With %B spec, used for a leaf with brothers."
4731 :group 'gnus-thread)
4732 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4733 "With %B spec, used for a leaf without brothers."
4736 :group 'gnus-thread)
4738 (defun gnus-summary-prepare-threads (threads)
4739 "Prepare summary buffer from THREADS and indentation LEVEL.
4740 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4741 or a straight list of headers."
4742 (gnus-message 7 "Generating summary...")
4744 (setq gnus-newsgroup-threads threads)
4747 (let ((gnus-tmp-level 0)
4748 (default-score (or gnus-summary-default-score 0))
4749 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4750 (building-line-count gnus-summary-display-while-building)
4751 (building-count (integerp gnus-summary-display-while-building))
4752 thread number subject stack state gnus-tmp-gathered beg-match
4753 new-roots gnus-tmp-new-adopts thread-end simp-subject
4754 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4755 gnus-tmp-replied gnus-tmp-subject-or-nil
4756 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4757 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4758 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4761 (setq gnus-tmp-prev-subject nil
4762 gnus-tmp-thread-tree-header-string "")
4764 (if (vectorp (car threads))
4765 ;; If this is a straight (sic) list of headers, then a
4766 ;; threaded summary display isn't required, so we just create
4767 ;; an unthreaded one.
4768 (gnus-summary-prepare-unthreaded threads)
4770 ;; Do the threaded display.
4772 (if gnus-summary-display-while-building
4773 (switch-to-buffer (buffer-name)))
4774 (while (or threads stack gnus-tmp-new-adopts new-roots)
4776 (if (and (= gnus-tmp-level 0)
4779 (not gnus-tmp-false-parent)
4780 (or gnus-tmp-new-adopts new-roots))
4781 (if gnus-tmp-new-adopts
4782 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4783 thread (list (car gnus-tmp-new-adopts))
4784 gnus-tmp-header (caar thread)
4785 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4787 (setq thread (list (car new-roots))
4788 gnus-tmp-header (caar thread)
4789 new-roots (cdr new-roots))))
4792 ;; If there are some threads, we do them before the
4793 ;; threads on the stack.
4794 (setq thread threads
4795 gnus-tmp-header (caar thread))
4796 ;; There were no current threads, so we pop something off
4798 (setq state (car stack)
4799 gnus-tmp-level (car state)
4800 tree-stack (cadr state)
4801 thread (caddr state)
4803 gnus-tmp-header (caar thread))))
4805 (setq gnus-tmp-false-parent nil)
4806 (setq gnus-tmp-root-expunged nil)
4807 (setq thread-end nil)
4809 (if (stringp gnus-tmp-header)
4810 ;; The header is a dummy root.
4812 ((eq gnus-summary-make-false-root 'adopt)
4813 ;; We let the first article adopt the rest.
4814 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4816 (setq gnus-tmp-gathered
4818 (lambda (h) (mail-header-number (car h)))
4821 (setq thread (cons (list (caar thread)
4824 (setq gnus-tmp-level -1
4825 gnus-tmp-false-parent t))
4826 ((eq gnus-summary-make-false-root 'empty)
4827 ;; We print adopted articles with empty subject fields.
4828 (setq gnus-tmp-gathered
4830 (lambda (h) (mail-header-number (car h)))
4833 (setq gnus-tmp-level -1))
4834 ((eq gnus-summary-make-false-root 'dummy)
4835 ;; We remember that we probably want to output a dummy
4837 (setq gnus-tmp-dummy-line gnus-tmp-header)
4838 (setq gnus-tmp-prev-subject gnus-tmp-header))
4840 ;; We do not make a root for the gathered
4841 ;; sub-threads at all.
4842 (setq gnus-tmp-level -1)))
4844 (setq number (mail-header-number gnus-tmp-header)
4845 subject (mail-header-subject gnus-tmp-header)
4846 simp-subject (gnus-simplify-subject-fully subject))
4849 ;; If the thread has changed subject, we might want to make
4850 ;; this subthread into a root.
4851 ((and (null gnus-thread-ignore-subject)
4852 (not (zerop gnus-tmp-level))
4853 gnus-tmp-prev-subject
4854 (not (string= gnus-tmp-prev-subject simp-subject)))
4855 (setq new-roots (nconc new-roots (list (car thread)))
4857 gnus-tmp-header nil))
4858 ;; If the article lies outside the current limit,
4859 ;; then we do not display it.
4860 ((not (memq number gnus-newsgroup-limit))
4861 (setq gnus-tmp-gathered
4863 (lambda (h) (mail-header-number (car h)))
4866 (setq gnus-tmp-new-adopts (if (cdar thread)
4867 (append gnus-tmp-new-adopts
4869 gnus-tmp-new-adopts)
4871 gnus-tmp-header nil)
4872 (when (zerop gnus-tmp-level)
4873 (setq gnus-tmp-root-expunged t)))
4874 ;; Perhaps this article is to be marked as read?
4875 ((and gnus-summary-mark-below
4876 (< (or (cdr (assq number gnus-newsgroup-scored))
4878 gnus-summary-mark-below)
4879 ;; Don't touch sparse articles.
4880 (not (gnus-summary-article-sparse-p number))
4881 (not (gnus-summary-article-ancient-p number)))
4882 (setq gnus-newsgroup-unreads
4883 (delq number gnus-newsgroup-unreads))
4884 (if gnus-newsgroup-auto-expire
4885 (setq gnus-newsgroup-expirable
4886 (gnus-add-to-sorted-list
4887 gnus-newsgroup-expirable number))
4888 (push (cons number gnus-low-score-mark)
4889 gnus-newsgroup-reads))))
4891 (when gnus-tmp-header
4892 ;; We may have an old dummy line to output before this
4894 (when (and gnus-tmp-dummy-line
4897 (mail-header-subject gnus-tmp-header)))
4898 (gnus-summary-insert-dummy-line
4899 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4900 (setq gnus-tmp-dummy-line nil))
4902 ;; Compute the mark.
4903 (setq gnus-tmp-unread (gnus-article-mark number))
4905 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4906 gnus-tmp-header gnus-tmp-level)
4907 gnus-newsgroup-data)
4909 ;; Actually insert the line.
4911 gnus-tmp-subject-or-nil
4913 ((and gnus-thread-ignore-subject
4914 gnus-tmp-prev-subject
4915 (not (string= gnus-tmp-prev-subject simp-subject)))
4917 ((zerop gnus-tmp-level)
4918 (if (and (eq gnus-summary-make-false-root 'empty)
4919 (memq number gnus-tmp-gathered)
4920 gnus-tmp-prev-subject
4921 (string= gnus-tmp-prev-subject simp-subject))
4922 gnus-summary-same-subject
4924 (t gnus-summary-same-subject)))
4925 (if (and (eq gnus-summary-make-false-root 'adopt)
4926 (= gnus-tmp-level 1)
4927 (memq number gnus-tmp-gathered))
4928 (setq gnus-tmp-opening-bracket ?\<
4929 gnus-tmp-closing-bracket ?\>)
4930 (setq gnus-tmp-opening-bracket ?\[
4931 gnus-tmp-closing-bracket ?\]))
4933 gnus-tmp-indentation
4934 (aref gnus-thread-indent-array gnus-tmp-level)
4935 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4936 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4937 gnus-summary-default-score 0)
4939 (if (or (null gnus-summary-default-score)
4940 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4941 gnus-summary-zcore-fuzz))
4943 (if (< gnus-tmp-score gnus-summary-default-score)
4944 gnus-score-below-mark gnus-score-over-mark))
4946 (cond ((memq number gnus-newsgroup-processable)
4948 ((memq number gnus-newsgroup-cached)
4950 ((memq number gnus-newsgroup-replied)
4952 ((memq number gnus-newsgroup-forwarded)
4953 gnus-forwarded-mark)
4954 ((memq number gnus-newsgroup-saved)
4956 ((memq number gnus-newsgroup-recent)
4958 ((memq number gnus-newsgroup-unseen)
4962 (cond ((memq number gnus-newsgroup-undownloaded)
4963 gnus-undownloaded-mark)
4964 (gnus-newsgroup-agentized
4965 gnus-downloaded-mark)
4968 gnus-tmp-from (mail-header-from gnus-tmp-header)
4971 ((string-match "<[^>]+> *$" gnus-tmp-from)
4972 (setq beg-match (match-beginning 0))
4973 (or (and (string-match "^\".+\"" gnus-tmp-from)
4974 (substring gnus-tmp-from 1 (1- (match-end 0))))
4975 (substring gnus-tmp-from 0 beg-match)))
4976 ((string-match "(.+)" gnus-tmp-from)
4977 (substring gnus-tmp-from
4978 (1+ (match-beginning 0)) (1- (match-end 0))))
4982 gnus-tmp-thread-tree-header-string
4984 ((not gnus-show-threads) "")
4985 ((zerop gnus-tmp-level)
4986 (cond ((cdar thread)
4987 (or gnus-sum-thread-tree-root subject))
4988 (gnus-tmp-new-adopts
4989 (or gnus-sum-thread-tree-false-root subject))
4991 (or gnus-sum-thread-tree-single-indent subject))))
4993 (concat (apply 'concat
4994 (mapcar (lambda (item)
4996 gnus-sum-thread-tree-vertical
4997 gnus-sum-thread-tree-indent))
4998 (cdr (reverse tree-stack))))
5000 gnus-sum-thread-tree-leaf-with-other
5001 gnus-sum-thread-tree-single-leaf)))))
5002 (when (string= gnus-tmp-name "")
5003 (setq gnus-tmp-name gnus-tmp-from))
5004 (unless (numberp gnus-tmp-lines)
5005 (setq gnus-tmp-lines -1))
5006 (if (= gnus-tmp-lines -1)
5007 (setq gnus-tmp-lines "?")
5008 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5009 (gnus-put-text-property
5011 (progn (eval gnus-summary-line-format-spec) (point))
5012 'gnus-number number)
5015 (gnus-run-hooks 'gnus-summary-update-hook)
5018 (setq gnus-tmp-prev-subject simp-subject)))
5020 (when (nth 1 thread)
5021 (push (list (max 0 gnus-tmp-level)
5022 (copy-sequence tree-stack)
5025 (push (if (nth 1 thread) 1 0) tree-stack)
5026 (incf gnus-tmp-level)
5027 (setq threads (if thread-end nil (cdar thread)))
5028 (if gnus-summary-display-while-building
5031 ;; use a set frequency
5032 (setq building-line-count (1- building-line-count))
5033 (when (= building-line-count 0)
5035 (setq building-line-count
5036 gnus-summary-display-while-building)))
5040 (setq gnus-tmp-level 0)))))
5041 (gnus-message 7 "Generating summary...done"))
5043 (defun gnus-summary-prepare-unthreaded (headers)
5044 "Generate an unthreaded summary buffer based on HEADERS."
5045 (let (header number mark)
5050 ;; We may have to root out some bad articles...
5051 (when (memq (setq number (mail-header-number
5052 (setq header (pop headers))))
5053 gnus-newsgroup-limit)
5054 ;; Mark article as read when it has a low score.
5055 (when (and gnus-summary-mark-below
5056 (< (or (cdr (assq number gnus-newsgroup-scored))
5057 gnus-summary-default-score 0)
5058 gnus-summary-mark-below)
5059 (not (gnus-summary-article-ancient-p number)))
5060 (setq gnus-newsgroup-unreads
5061 (delq number gnus-newsgroup-unreads))
5062 (if gnus-newsgroup-auto-expire
5063 (push number gnus-newsgroup-expirable)
5064 (push (cons number gnus-low-score-mark)
5065 gnus-newsgroup-reads)))
5067 (setq mark (gnus-article-mark number))
5068 (push (gnus-data-make number mark (1+ (point)) header 0)
5069 gnus-newsgroup-data)
5070 (gnus-summary-insert-line
5072 (memq number gnus-newsgroup-undownloaded)
5073 mark (memq number gnus-newsgroup-replied)
5074 (memq number gnus-newsgroup-expirable)
5075 (mail-header-subject header) nil
5076 (cdr (assq number gnus-newsgroup-scored))
5077 (memq number gnus-newsgroup-processable))))))
5079 (defun gnus-summary-remove-list-identifiers ()
5080 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5081 (let ((regexp (if (consp gnus-list-identifiers)
5082 (mapconcat 'identity gnus-list-identifiers " *\\|")
5083 gnus-list-identifiers))
5086 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5087 (dolist (header gnus-newsgroup-headers)
5088 (setq subject (mail-header-subject header)
5090 (while (string-match regexp subject)
5092 (concat (substring subject 0 (match-beginning 1))
5093 (substring subject (match-end 0)))
5096 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5098 (concat (substring subject 0 (match-beginning 1))
5099 (substring subject (match-end 1)))))
5100 (mail-header-set-subject header subject))))))
5102 (defun gnus-fetch-headers (articles)
5103 "Fetch headers of ARTICLES."
5104 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5105 (gnus-message 5 "Fetching headers for %s..." name)
5108 (setq gnus-headers-retrieved-by
5109 (gnus-retrieve-headers
5110 articles gnus-newsgroup-name
5111 ;; We might want to fetch old headers, but
5112 ;; not if there is only 1 article.
5114 (not (eq gnus-fetch-old-headers 'some))
5115 (not (numberp gnus-fetch-old-headers)))
5116 (> (length articles) 1))
5117 gnus-fetch-old-headers))))
5118 (gnus-get-newsgroup-headers-xover
5119 articles nil nil gnus-newsgroup-name t)
5120 (gnus-get-newsgroup-headers))
5121 (gnus-message 5 "Fetching headers for %s...done" name))))
5123 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5124 "Select newsgroup GROUP.
5125 If READ-ALL is non-nil, all articles in the group are selected.
5126 If SELECT-ARTICLES, only select those articles from GROUP."
5127 (let* ((entry (gnus-group-entry group))
5128 ;;!!! Dirty hack; should be removed.
5129 (gnus-summary-ignore-duplicates
5130 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5132 gnus-summary-ignore-duplicates))
5133 (info (nth 2 entry))
5134 articles fetched-articles cached)
5136 (unless (gnus-check-server
5137 (set (make-local-variable 'gnus-current-select-method)
5138 (gnus-find-method-for-group group)))
5139 (error "Couldn't open server"))
5141 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5142 (gnus-activate-group group) ; Or we can activate it...
5143 (progn ; Or we bug out.
5144 (when (equal major-mode 'gnus-summary-mode)
5145 (gnus-kill-buffer (current-buffer)))
5146 (error "Couldn't activate group %s: %s"
5147 group (gnus-status-message group))))
5149 (unless (gnus-request-group group t)
5150 (when (equal major-mode 'gnus-summary-mode)
5151 (gnus-kill-buffer (current-buffer)))
5152 (error "Couldn't request group %s: %s"
5153 group (gnus-status-message group)))
5156 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5158 (setq gnus-summary-use-undownloaded-faces
5159 (gnus-agent-find-parameter
5161 'agent-enable-undownloaded-faces)))
5163 (setq gnus-newsgroup-name group
5164 gnus-newsgroup-unselected nil
5165 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5167 (let ((display (gnus-group-find-parameter group 'display)))
5168 (setq gnus-newsgroup-display
5170 ((not (zerop (or (car-safe read-all) 0)))
5171 ;; The user entered the group with C-u SPC/RET, let's show
5177 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5179 ;; The following is probably the "correct" solution, but
5180 ;; it makes Gnus fetch all headers and then limit the
5181 ;; articles (which is slow), so instead we hack the
5182 ;; select-articles parameter instead. -- Simon Josefsson
5185 ;; (gnus-byte-compile
5186 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5188 (setq select-articles
5189 (gnus-uncompress-range
5190 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5194 (cdr (gnus-active group)))))
5199 (gnus-summary-setup-default-charset)
5201 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5202 (when (gnus-virtual-group-p group)
5203 (setq cached gnus-newsgroup-cached))
5205 (setq gnus-newsgroup-unreads
5206 (gnus-sorted-ndifference
5207 (gnus-sorted-ndifference gnus-newsgroup-unreads
5208 gnus-newsgroup-marked)
5209 gnus-newsgroup-dormant))
5211 (setq gnus-newsgroup-processable nil)
5213 (gnus-update-read-articles group gnus-newsgroup-unreads)
5215 ;; Adjust and set lists of article marks.
5217 (gnus-adjust-marked-articles info))
5218 (if (setq articles select-articles)
5219 (setq gnus-newsgroup-unselected
5220 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5221 (setq articles (gnus-articles-to-read group read-all)))
5225 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5227 ((eq articles 0) nil)
5229 ;; Init the dependencies hash table.
5230 (setq gnus-newsgroup-dependencies
5231 (gnus-make-hashtable (length articles)))
5232 (gnus-set-global-variables)
5233 ;; Retrieve the headers and read them in.
5235 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5237 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5239 (setq gnus-newsgroup-cached cached))
5241 ;; Suppress duplicates?
5242 (when gnus-suppress-duplicates
5243 (gnus-dup-suppress-articles))
5245 ;; Set the initial limit.
5246 (setq gnus-newsgroup-limit (copy-sequence articles))
5247 ;; Remove canceled articles from the list of unread articles.
5248 (setq fetched-articles
5249 (mapcar (lambda (headers) (mail-header-number headers))
5250 gnus-newsgroup-headers))
5251 (setq gnus-newsgroup-articles fetched-articles)
5252 (setq gnus-newsgroup-unreads
5253 (gnus-sorted-nintersection
5254 gnus-newsgroup-unreads fetched-articles))
5255 (gnus-compute-unseen-list)
5257 ;; Removed marked articles that do not exist.
5258 (gnus-update-missing-marks
5259 (gnus-sorted-difference articles fetched-articles))
5260 ;; We might want to build some more threads first.
5261 (when (and gnus-fetch-old-headers
5262 (eq gnus-headers-retrieved-by 'nov))
5263 (if (eq gnus-fetch-old-headers 'invisible)
5264 (gnus-build-all-threads)
5265 (gnus-build-old-threads)))
5266 ;; Let the Gnus agent mark articles as read.
5268 (gnus-agent-get-undownloaded-list))
5269 ;; Remove list identifiers from subject
5270 (when gnus-list-identifiers
5271 (gnus-summary-remove-list-identifiers))
5272 ;; Check whether auto-expire is to be done in this group.
5273 (setq gnus-newsgroup-auto-expire
5274 (gnus-group-auto-expirable-p group))
5275 ;; Set up the article buffer now, if necessary.
5276 (unless gnus-single-article-buffer
5277 (gnus-article-setup-buffer))
5278 ;; First and last article in this newsgroup.
5279 (when gnus-newsgroup-headers
5280 (setq gnus-newsgroup-begin
5281 (mail-header-number (car gnus-newsgroup-headers))
5284 (gnus-last-element gnus-newsgroup-headers))))
5285 ;; GROUP is successfully selected.
5286 (or gnus-newsgroup-headers t)))))
5288 (defun gnus-compute-unseen-list ()
5289 ;; The `seen' marks are treated specially.
5290 (if (not gnus-newsgroup-seen)
5291 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5292 (setq gnus-newsgroup-unseen
5293 (gnus-inverse-list-range-intersection
5294 gnus-newsgroup-articles gnus-newsgroup-seen))))
5296 (defun gnus-summary-display-make-predicate (display)
5297 (require 'gnus-agent)
5298 (when (= (length display) 1)
5299 (setq display (car display)))
5300 (unless gnus-summary-display-cache
5301 (dolist (elem (append '((unread . unread)
5304 gnus-article-mark-lists))
5305 (push (cons (cdr elem)
5307 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5308 gnus-summary-display-cache)))
5309 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5310 (gnus-category-predicate-cache gnus-summary-display-cache))
5311 (gnus-get-predicate display)))
5313 ;; Uses the dynamically bound `number' variable.
5316 (defun gnus-article-marked-p (type &optional article)
5317 (let ((article (or article number)))
5320 (memq article gnus-newsgroup-marked))
5322 (memq article gnus-newsgroup-spam-marked))
5324 (memq article gnus-newsgroup-unsendable))
5325 ((eq type 'undownload)
5326 (memq article gnus-newsgroup-undownloaded))
5327 ((eq type 'download)
5328 (memq article gnus-newsgroup-downloadable))
5330 (memq article gnus-newsgroup-unreads))
5332 (memq article gnus-newsgroup-reads))
5334 (memq article gnus-newsgroup-dormant) )
5336 (memq article gnus-newsgroup-expirable))
5338 (memq article gnus-newsgroup-replied))
5340 (memq article gnus-newsgroup-killed))
5341 ((eq type 'bookmark)
5342 (assq article gnus-newsgroup-bookmarks))
5344 (assq article gnus-newsgroup-scored))
5346 (memq article gnus-newsgroup-saved))
5348 (memq article gnus-newsgroup-cached))
5350 (memq article gnus-newsgroup-forwarded))
5352 (not (memq article gnus-newsgroup-unseen)))
5354 (memq article gnus-newsgroup-recent))
5357 (defun gnus-articles-to-read (group &optional read-all)
5358 "Find out what articles the user wants to read."
5360 ;; Select all articles if `read-all' is non-nil, or if there
5361 ;; are no unread articles.
5363 (and (zerop (length gnus-newsgroup-marked))
5364 (zerop (length gnus-newsgroup-unreads)))
5365 ;; Fetch all if the predicate is non-nil.
5366 gnus-newsgroup-display)
5367 ;; We want to select the headers for all the articles in
5368 ;; the group, so we select either all the active
5369 ;; articles in the group, or (if that's nil), the
5370 ;; articles in the cache.
5372 (gnus-uncompress-range (gnus-active group))
5373 (gnus-cache-articles-in-group group))
5374 ;; Select only the "normal" subset of articles.
5376 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5377 gnus-newsgroup-unreads)))
5378 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5379 (scored (length scored-list))
5380 (number (length articles))
5381 (marked (+ (length gnus-newsgroup-marked)
5382 (length gnus-newsgroup-dormant)))
5387 ((numberp gnus-newsgroup-display)
5388 gnus-newsgroup-display)
5392 ((and (or (<= scored marked) (= scored number))
5393 (numberp gnus-large-newsgroup)
5394 (> number gnus-large-newsgroup))
5395 (let* ((cursor-in-echo-area nil)
5396 (initial (gnus-parameter-large-newsgroup-initial
5397 gnus-newsgroup-name))
5401 "How many articles from %s (%s %d): "
5403 (gnus-group-decoded-name gnus-newsgroup-name)
5405 (if initial "max" "default")
5408 (cons (number-to-string initial)
5410 (if (string-match "^[ \t]*$" input) number input)))
5411 ((and (> scored marked) (< scored number)
5412 (> (- scored number) 20))
5415 (format "%s %s (%d scored, %d total): "
5416 "How many articles from"
5417 (gnus-group-decoded-name group)
5419 (if (string-match "^[ \t]*$" input)
5423 (message "Quit getting the articles to read")
5425 (setq select (if (stringp select) (string-to-number select) select))
5426 (if (or (null select) (zerop select))
5428 (if (and (not (zerop scored)) (<= (abs select) scored))
5430 (setq articles (sort scored-list '<))
5431 (setq number (length articles)))
5432 (setq articles (copy-sequence articles)))
5434 (when (< (abs select) number)
5436 ;; Select the N oldest articles.
5437 (setcdr (nthcdr (1- (abs select)) articles) nil)
5438 ;; Select the N most recent articles.
5439 (setq articles (nthcdr (- number select) articles))))
5440 (setq gnus-newsgroup-unselected
5441 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5442 (when gnus-alter-articles-to-read-function
5445 (funcall gnus-alter-articles-to-read-function
5446 gnus-newsgroup-name articles)
5450 (defun gnus-killed-articles (killed articles)
5453 (when (inline (gnus-member-of-range (car articles) killed))
5454 (push (car articles) out))
5455 (setq articles (cdr articles)))
5458 (defun gnus-uncompress-marks (marks)
5459 "Uncompress the mark ranges in MARKS."
5460 (let ((uncompressed '(score bookmark))
5463 (if (memq (caar marks) uncompressed)
5464 (push (car marks) out)
5465 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5466 (setq marks (cdr marks)))
5469 (defun gnus-article-mark-to-type (mark)
5470 "Return the type of MARK."
5471 (or (cadr (assq mark gnus-article-special-mark-lists))
5474 (defun gnus-article-unpropagatable-p (mark)
5475 "Return whether MARK should be propagated to back end."
5476 (memq mark gnus-article-unpropagated-mark-lists))
5478 (defun gnus-adjust-marked-articles (info)
5479 "Set all article lists and remove all marks that are no longer valid."
5480 (let* ((marked-lists (gnus-info-marks info))
5481 (active (gnus-active (gnus-info-group info)))
5484 (types gnus-article-mark-lists)
5485 marks var articles article mark mark-type
5488 (dolist (marks marked-lists)
5489 (setq mark (car marks)
5490 mark-type (gnus-article-mark-to-type mark)
5491 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5493 ;; We set the variable according to the type of the marks list,
5494 ;; and then adjust the marks to a subset of the active articles.
5496 ;; Adjust "simple" lists - compressed yet unsorted
5497 ((eq mark-type 'list)
5498 ;; Simultaneously uncompress and clip to active range
5499 ;; See gnus-uncompress-range for a description of possible marks
5501 (if (not (cadr marks))
5503 (setq articles (if (numberp (cddr marks))
5509 (while (setq article (pop articles))
5510 (cond ((consp article)
5511 (setq bgn (max (car article) min)
5512 end (min (cdr article) max))
5514 (setq l (setcdr l (cons bgn nil))
5516 ((and (<= min article)
5518 (setq l (setcdr l (cons article nil))))))
5519 (set var (cdr lh)))))
5521 ((eq mark-type 'tuple)
5522 (set var (setq articles (cdr marks)))
5523 (when (not (listp (cdr (symbol-value var))))
5524 (set var (list (symbol-value var))))
5525 (when (not (listp (cdr articles)))
5526 (setq articles (list articles)))
5528 (when (or (not (consp (setq article (pop articles))))
5529 (< (car article) min)
5530 (> (car article) max))
5531 (set var (delq article (symbol-value var))))))
5532 ;; Adjust ranges (sloppily).
5533 ((eq mark-type 'range)
5536 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5537 ;; It should be (seen (NUM1 . NUM2)).
5538 (when (numberp (cddr marks))
5539 (setcdr marks (list (cdr marks))))
5540 (setq articles (cdr marks))
5541 (while (and articles
5542 (or (and (consp (car articles))
5543 (> min (cdar articles)))
5544 (and (numberp (car articles))
5545 (> min (car articles)))))
5547 (set var articles))))))))
5549 (defun gnus-update-missing-marks (missing)
5550 "Go through the list of MISSING articles and remove them from the mark lists."
5553 ;; Go through all types.
5554 (dolist (elem gnus-article-mark-lists)
5555 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5556 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5557 (when (symbol-value var)
5558 ;; This list has articles. So we delete all missing
5559 ;; articles from it.
5562 (set var (delq (pop m) (symbol-value var))))))))))
5564 (defun gnus-update-marks ()
5565 "Enter the various lists of marked articles into the newsgroup info list."
5566 (let ((types gnus-article-mark-lists)
5567 (info (gnus-get-info gnus-newsgroup-name))
5568 type list newmarked symbol delta-marks)
5570 ;; Add all marks lists to the list of marks lists.
5571 (while (setq type (pop types))
5572 (setq list (symbol-value
5574 (intern (format "gnus-newsgroup-%s" (car type))))))
5577 ;; Get rid of the entries of the articles that have the
5579 (when (and (eq (cdr type) 'score)
5583 (prev (cons nil list))
5586 (if (or (not (consp (car arts)))
5587 (= (cdar arts) gnus-summary-default-score))
5588 (setcdr prev (cdr arts))
5590 (setq arts (cdr arts)))
5591 (setq list (cdr all)))))
5593 (when (eq (cdr type) 'seen)
5594 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5596 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5597 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5599 (when (and (gnus-check-backend-function
5600 'request-set-mark gnus-newsgroup-name)
5601 (not (gnus-article-unpropagatable-p (cdr type))))
5602 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5603 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5604 (add (gnus-remove-from-range
5605 (gnus-copy-sequence list) old)))
5607 (push (list add 'add (list (cdr type))) delta-marks))
5609 (push (list del 'del (list (cdr type))) delta-marks))))
5612 (push (cons (cdr type) list) newmarked)))
5615 (unless (gnus-check-group gnus-newsgroup-name)
5616 (error "Can't open server for %s" gnus-newsgroup-name))
5617 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5619 ;; Enter these new marks into the info of the group.
5621 (setcar (nthcdr 3 info) newmarked)
5622 ;; Add the marks lists to the end of the info.
5624 (setcdr (nthcdr 2 info) (list newmarked))))
5626 ;; Cut off the end of the info if there's nothing else there.
5630 (when (nthcdr (decf i) info)
5631 (setcdr (nthcdr i info) nil)))))))
5633 (defun gnus-set-mode-line (where)
5634 "Set the mode line of the article or summary buffers.
5635 If WHERE is `summary', the summary mode line format will be used."
5636 ;; Is this mode line one we keep updated?
5637 (when (and (memq where gnus-updated-mode-lines)
5639 (intern (format "gnus-%s-mode-line-format-spec" where))))
5642 ;; We evaluate this in the summary buffer since these
5643 ;; variables are buffer-local to that buffer.
5644 (set-buffer gnus-summary-buffer)
5645 ;; We bind all these variables that are used in the `eval' form
5647 (let* ((mformat (symbol-value
5649 (format "gnus-%s-mode-line-format-spec" where))))
5650 (gnus-tmp-group-name (gnus-group-decoded-name
5651 gnus-newsgroup-name))
5652 (gnus-tmp-article-number (or gnus-current-article 0))
5653 (gnus-tmp-unread gnus-newsgroup-unreads)
5654 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5655 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5656 (gnus-tmp-unread-and-unselected
5657 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5658 (zerop gnus-tmp-unselected))
5660 ((zerop gnus-tmp-unselected)
5661 (format "{%d more}" gnus-tmp-unread-and-unticked))
5662 (t (format "{%d(+%d) more}"
5663 gnus-tmp-unread-and-unticked
5664 gnus-tmp-unselected))))
5666 (if (and gnus-current-headers
5667 (vectorp gnus-current-headers))
5668 (gnus-mode-string-quote
5669 (mail-header-subject gnus-current-headers))
5671 bufname-length max-len
5672 gnus-tmp-header);; passed as argument to any user-format-funcs
5673 (setq mode-string (eval mformat))
5674 (setq bufname-length (if (string-match "%b" mode-string)
5677 (if (eq where 'summary)
5679 (get-buffer gnus-article-buffer))))
5682 (setq max-len (max 4 (if gnus-mode-non-string-length
5684 gnus-mode-non-string-length
5686 (length mode-string))))
5687 ;; We might have to chop a bit of the string off...
5688 (when (> (length mode-string) max-len)
5690 (concat (gnus-truncate-string mode-string (- max-len 3))
5692 ;; Pad the mode string a bit.
5693 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5694 ;; Update the mode line.
5695 (setq mode-line-buffer-identification
5696 (gnus-mode-line-buffer-identification (list mode-string)))
5697 (set-buffer-modified-p t))))
5699 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5700 "Go through the HEADERS list and add all Xrefs to a hash table.
5701 The resulting hash table is returned, or nil if no Xrefs were found."
5702 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5703 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5704 (xref-hashtb (gnus-make-hashtable))
5705 start group entry number xrefs header)
5707 (setq header (pop headers))
5708 (when (and (setq xrefs (mail-header-xref header))
5709 (not (memq (setq number (mail-header-number header))
5712 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5713 (setq start (match-end 0))
5714 (setq group (if prefix
5715 (concat prefix (substring xrefs (match-beginning 1)
5717 (substring xrefs (match-beginning 1) (match-end 1))))
5719 (string-to-int (substring xrefs (match-beginning 2)
5721 (if (setq entry (gnus-gethash group xref-hashtb))
5722 (setcdr entry (cons number (cdr entry)))
5723 (gnus-sethash group (cons number nil) xref-hashtb)))))
5724 (and start xref-hashtb)))
5726 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5727 "Look through all the headers and mark the Xrefs as read."
5728 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5729 name info xref-hashtb idlist method nth4)
5731 (set-buffer gnus-group-buffer)
5732 (when (setq xref-hashtb
5733 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5736 (unless (string= from-newsgroup (setq name (symbol-name group)))
5737 (setq idlist (symbol-value group))
5738 ;; Dead groups are not updated.
5740 (setq info (gnus-get-info name))
5741 (when (stringp (setq nth4 (gnus-info-method info)))
5742 (setq nth4 (gnus-server-to-method nth4))))
5743 ;; Only do the xrefs if the group has the same
5744 ;; select method as the group we have just read.
5745 (or (gnus-methods-equal-p
5746 nth4 (gnus-find-method-for-group from-newsgroup))
5748 (equal nth4 (setq method (gnus-find-method-for-group
5750 (and (equal (car nth4) (car method))
5751 (equal (nth 1 nth4) (nth 1 method))))
5752 gnus-use-cross-reference
5753 (or (not (eq gnus-use-cross-reference t))
5755 ;; Only do cross-references on subscribed
5756 ;; groups, if that is what is wanted.
5757 (<= (gnus-info-level info) gnus-level-subscribed))
5758 (gnus-group-make-articles-read name idlist))))
5761 (defun gnus-compute-read-articles (group articles)
5762 (let* ((entry (gnus-group-entry group))
5763 (info (nth 2 entry))
5764 (active (gnus-active group))
5767 ;; First peel off all invalid article numbers.
5769 (let ((ids articles)
5771 (while (setq id (pop ids))
5772 (when (and first (> id (cdr active)))
5773 ;; We'll end up in this situation in one particular
5774 ;; obscure situation. If you re-scan a group and get
5775 ;; a new article that is cross-posted to a different
5776 ;; group that has not been re-scanned, you might get
5777 ;; crossposted article that has a higher number than
5778 ;; Gnus believes possible. So we re-activate this
5779 ;; group as well. This might mean doing the
5780 ;; crossposting thingy will *increase* the number
5781 ;; of articles in some groups. Tsk, tsk.
5782 (setq active (or (gnus-activate-group group) active)))
5783 (when (or (> id (cdr active))
5784 (< id (car active)))
5785 (setq articles (delq id articles))))))
5786 ;; If the read list is nil, we init it.
5788 (null (gnus-info-read info))
5790 (setq ninfo (cons 1 (1- (car active))))
5791 (setq ninfo (gnus-info-read info)))
5792 ;; Then we add the read articles to the range.
5794 ninfo (setq articles (sort articles '<))))))
5796 (defun gnus-group-make-articles-read (group articles)
5797 "Update the info of GROUP to say that ARTICLES are read."
5799 (entry (gnus-group-entry group))
5800 (info (nth 2 entry))
5801 (active (gnus-active group))
5804 (setq range (gnus-compute-read-articles group articles))
5805 (with-current-buffer gnus-group-buffer
5808 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5809 (gnus-info-set-read ',info ',(gnus-info-read info))
5810 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5811 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5812 (gnus-group-update-group ,group t))))
5813 ;; Add the read articles to the range.
5814 (gnus-info-set-read info range)
5815 (gnus-request-set-mark group (list (list range 'add '(read))))
5816 ;; Then we have to re-compute how many unread
5817 ;; articles there are in this group.
5821 (setq num (- (1+ (cdr active)) (car active))))
5822 ((not (listp (cdr range)))
5823 (setq num (- (cdr active) (- (1+ (cdr range))
5827 (if (numberp (car range))
5829 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5830 (setq range (cdr range)))
5831 (setq num (- (cdr active) num))))
5832 ;; Update the number of unread articles.
5834 ;; Update the group buffer.
5835 (unless (gnus-ephemeral-group-p group)
5836 (gnus-group-update-group group t))))))
5838 (defvar gnus-newsgroup-none-id 0)
5840 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5841 (let ((cur nntp-server-buffer)
5844 (with-current-buffer gnus-summary-buffer
5845 gnus-newsgroup-dependencies)))
5846 headers id end ref number
5847 (mail-parse-charset gnus-newsgroup-charset)
5848 (mail-parse-ignored-charsets
5849 (save-excursion (condition-case nil
5850 (set-buffer gnus-summary-buffer)
5852 gnus-newsgroup-ignored-charsets)))
5854 (set-buffer nntp-server-buffer)
5855 ;; Translate all TAB characters into SPACE characters.
5856 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5857 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5858 (ietf-drums-unfold-fws)
5859 (gnus-run-hooks 'gnus-parse-headers-hook)
5860 (let ((case-fold-search t)
5861 in-reply-to header p lines chars ctype)
5862 (goto-char (point-min))
5863 ;; Search to the beginning of the next header. Error messages
5864 ;; do not begin with 2 or 3.
5865 (while (re-search-forward "^[23][0-9]+ " nil t)
5868 ;; This implementation of this function, with nine
5869 ;; search-forwards instead of the one re-search-forward and
5870 ;; a case (which basically was the old function) is actually
5871 ;; about twice as fast, even though it looks messier. You
5872 ;; can't have everything, I guess. Speed and elegance
5873 ;; doesn't always go hand in hand.
5876 (make-full-mail-header
5879 (setq number (read cur))
5882 (narrow-to-region (point)
5883 (or (and (search-forward "\n.\n" nil t)
5889 (if (search-forward "\nsubject:" nil t)
5890 (nnheader-header-value)
5895 (if (search-forward "\nfrom:" nil t)
5896 (nnheader-header-value)
5901 (if (search-forward "\ndate:" nil t)
5902 (nnheader-header-value) ""))
5906 (setq id (if (re-search-forward
5907 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5908 ;; We do it this way to make sure the Message-ID
5909 ;; is (somewhat) syntactically valid.
5910 (buffer-substring (match-beginning 1)
5912 ;; If there was no message-id, we just fake one
5913 ;; to make subsequent routines simpler.
5914 (nnheader-generate-fake-message-id number))))
5918 (if (search-forward "\nreferences:" nil t)
5922 (nnheader-header-value)
5927 (search-backward ">" end t)
5930 (search-backward "<" end t)
5932 ;; Get the references from the in-reply-to header if there
5933 ;; were no references and the in-reply-to header looks
5935 (if (and (search-forward "\nin-reply-to:" nil t)
5936 (setq in-reply-to (nnheader-header-value))
5937 (string-match "<[^>]+>" in-reply-to))
5939 (setq ref (substring in-reply-to (match-beginning 0)
5941 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5942 (setq ref2 (substring in-reply-to (match-beginning 0)
5944 (when (> (length ref2) (length ref))
5951 (if (search-forward "\nchars: " nil t)
5952 (if (numberp (setq chars (ignore-errors (read cur))))
5958 (if (search-forward "\nlines: " nil t)
5959 (if (numberp (setq lines (ignore-errors (read cur))))
5965 (and (search-forward "\nxref:" nil t)
5966 (nnheader-header-value)))
5968 (when gnus-extra-headers
5969 (let ((extra gnus-extra-headers)
5973 (when (search-forward
5974 (concat "\n" (symbol-name (car extra)) ":") nil t)
5975 (push (cons (car extra) (nnheader-header-value)) out))
5979 (if (and (search-forward "\ncontent-type: " nil t)
5980 (setq ctype (nnheader-header-value)))
5981 (mime-entity-set-content-type-internal
5982 header (mime-parse-Content-Type ctype)))
5983 (when (equal id ref)
5986 (when gnus-alter-header-function
5987 (funcall gnus-alter-header-function header)
5988 (setq id (mail-header-id header)
5989 ref (gnus-parent-id (mail-header-references header))))
5992 (gnus-dependencies-add-header
5993 header dependencies force-new))
5994 (push header headers))
5995 (goto-char (point-max))
5997 (nreverse headers)))))
5999 ;; Goes through the xover lines and returns a list of vectors
6000 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6001 force-new dependencies
6002 group also-fetch-heads)
6003 "Parse the news overview data in the server buffer.
6004 Return a list of headers that match SEQUENCE (see
6005 `nntp-retrieve-headers')."
6006 ;; Get the Xref when the users reads the articles since most/some
6007 ;; NNTP servers do not include Xrefs when using XOVER.
6008 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6009 (let ((mail-parse-charset gnus-newsgroup-charset)
6010 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6011 (cur nntp-server-buffer)
6012 (dependencies (or dependencies gnus-newsgroup-dependencies))
6014 ((eq gnus-read-all-available-headers t)
6016 ((stringp gnus-read-all-available-headers)
6017 (string-match gnus-read-all-available-headers group))
6020 number headers header)
6022 (set-buffer nntp-server-buffer)
6023 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6024 ;; Allow the user to mangle the headers before parsing them.
6025 (gnus-run-hooks 'gnus-parse-headers-hook)
6026 (goto-char (point-min))
6027 (gnus-parse-without-error
6028 (while (and (or sequence allp)
6030 (setq number (read cur))
6032 (while (and sequence
6033 (< (car sequence) number))
6034 (setq sequence (cdr sequence))))
6037 (eq number (car sequence))))
6039 (setq sequence (cdr sequence))
6040 (setq header (inline
6041 (gnus-nov-parse-line
6042 number dependencies force-new)))))
6043 (push header headers))
6045 ;; A common bug in inn is that if you have posted an article and
6046 ;; then retrieves the active file, it will answer correctly --
6047 ;; the new article is included. However, a NOV entry for the
6048 ;; article may not have been generated yet, so this may fail.
6049 ;; We work around this problem by retrieving the last few
6050 ;; headers using HEAD.
6051 (if (or (not also-fetch-heads)
6053 ;; We (probably) got all the headers.
6055 (let ((gnus-nov-is-evil t))
6058 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6059 (gnus-get-newsgroup-headers))))))))
6061 (defun gnus-article-get-xrefs ()
6062 "Fill in the Xref value in `gnus-current-headers', if necessary.
6063 This is meant to be called in `gnus-article-internal-prepare-hook'."
6064 (let ((headers (with-current-buffer gnus-summary-buffer
6065 gnus-current-headers)))
6066 (or (not gnus-use-cross-reference)
6068 (and (mail-header-xref headers)
6069 (not (string= (mail-header-xref headers) "")))
6070 (let ((case-fold-search t)
6073 (nnheader-narrow-to-headers)
6074 (goto-char (point-min))
6075 (when (or (and (not (eobp))
6076 (eq (downcase (char-after)) ?x)
6077 (looking-at "Xref:"))
6078 (search-forward "\nXref:" nil t))
6079 (goto-char (1+ (match-end 0)))
6080 (setq xref (buffer-substring (point) (point-at-eol)))
6081 (mail-header-set-xref headers xref)))))))
6083 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6084 "Find article ID and insert the summary line for that article.
6085 OLD-HEADER can either be a header or a line number to insert
6086 the subject line on."
6087 (let* ((line (and (numberp old-header) old-header))
6088 (old-header (and (vectorp old-header) old-header))
6089 (header (cond ((and old-header use-old-header)
6092 (gnus-number-to-header id))
6093 (gnus-number-to-header id))
6095 (gnus-read-header id))))
6096 (number (and (numberp id) id))
6099 ;; Rebuild the thread that this article is part of and go to the
6100 ;; article we have fetched.
6101 (when (and (not gnus-show-threads)
6104 (setq d (gnus-data-find (mail-header-number old-header))))
6105 (goto-char (gnus-data-pos d))
6111 (gnus-delete-line))))))
6112 ;; Remove list identifiers from subject.
6113 (when gnus-list-identifiers
6114 (let ((gnus-newsgroup-headers (list header)))
6115 (gnus-summary-remove-list-identifiers)))
6117 (mail-header-set-number header (mail-header-number old-header)))
6118 (setq gnus-newsgroup-sparse
6119 (delq (setq number (mail-header-number header))
6120 gnus-newsgroup-sparse))
6121 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6122 (push number gnus-newsgroup-limit)
6123 (gnus-rebuild-thread (mail-header-id header) line)
6124 (gnus-summary-goto-subject number nil t))
6125 (when (and (numberp number)
6127 ;; We have to update the boundaries even if we can't fetch the
6128 ;; article if ID is a number -- so that the next `P' or `N'
6129 ;; command will fetch the previous (or next) article even
6130 ;; if the one we tried to fetch this time has been canceled.
6131 (when (> number gnus-newsgroup-end)
6132 (setq gnus-newsgroup-end number))
6133 (when (< number gnus-newsgroup-begin)
6134 (setq gnus-newsgroup-begin number))
6135 (setq gnus-newsgroup-unselected
6136 (delq number gnus-newsgroup-unselected)))
6137 ;; Report back a success?
6138 (and header (mail-header-number header))))
6140 ;;; Process/prefix in the summary buffer
6142 (defun gnus-summary-work-articles (n)
6143 "Return a list of articles to be worked upon.
6144 The prefix argument, the list of process marked articles, and the
6145 current article will be taken into consideration."
6147 (set-buffer gnus-summary-buffer)
6150 ;; A numerical prefix has been given.
6151 (setq n (prefix-numeric-value n))
6152 (let ((backward (< n 0))
6153 (n (abs (prefix-numeric-value n)))
6158 (push (setq article (gnus-summary-article-number))
6161 (gnus-summary-find-prev nil article)
6162 (gnus-summary-find-next nil article)))
6164 (nreverse articles)))
6165 ((and (gnus-region-active-p) (mark))
6166 (message "region active")
6167 ;; Work on the region between point and mark.
6168 (let ((max (max (point) (mark)))
6171 (goto-char (min (point) (mark)))
6174 (push (setq article (gnus-summary-article-number)) articles)
6175 (gnus-summary-find-next nil article)
6177 (nreverse articles))))
6178 (gnus-newsgroup-processable
6179 ;; There are process-marked articles present.
6180 ;; Save current state.
6181 (gnus-summary-save-process-mark)
6183 (reverse gnus-newsgroup-processable))
6185 ;; Just return the current article.
6186 (list (gnus-summary-article-number))))))
6188 (defmacro gnus-summary-iterate (arg &rest forms)
6189 "Iterate over the process/prefixed articles and do FORMS.
6190 ARG is the interactive prefix given to the command. FORMS will be
6191 executed with point over the summary line of the articles."
6192 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6193 `(let ((,articles (gnus-summary-work-articles ,arg)))
6195 (gnus-summary-goto-subject (car ,articles))
6199 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6200 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6202 (defun gnus-summary-save-process-mark ()
6203 "Push the current set of process marked articles on the stack."
6205 (push (copy-sequence gnus-newsgroup-processable)
6206 gnus-newsgroup-process-stack))
6208 (defun gnus-summary-kill-process-mark ()
6209 "Push the current set of process marked articles on the stack and unmark."
6211 (gnus-summary-save-process-mark)
6212 (gnus-summary-unmark-all-processable))
6214 (defun gnus-summary-yank-process-mark ()
6215 "Pop the last process mark state off the stack and restore it."
6217 (unless gnus-newsgroup-process-stack
6218 (error "Empty mark stack"))
6219 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6221 (defun gnus-summary-process-mark-set (set)
6222 "Make SET into the current process marked articles."
6223 (gnus-summary-unmark-all-processable)
6224 (mapc 'gnus-summary-set-process-mark set))
6226 ;;; Searching and stuff
6228 (defun gnus-summary-search-group (&optional backward use-level)
6229 "Search for next unread newsgroup.
6230 If optional argument BACKWARD is non-nil, search backward instead."
6232 (set-buffer gnus-group-buffer)
6233 (when (gnus-group-search-forward
6234 backward nil (if use-level (gnus-group-group-level) nil))
6235 (gnus-group-group-name))))
6237 (defun gnus-summary-best-group (&optional exclude-group)
6238 "Find the name of the best unread group.
6239 If EXCLUDE-GROUP, do not go to this group."
6240 (with-current-buffer gnus-group-buffer
6242 (gnus-group-best-unread-group exclude-group))))
6244 (defun gnus-summary-find-next (&optional unread article backward)
6246 (gnus-summary-find-prev unread article)
6247 (let* ((dummy (gnus-summary-article-intangible-p))
6248 (article (or article (gnus-summary-article-number)))
6249 (data (gnus-data-find-list article))
6251 (when (and (not dummy)
6252 (or (not gnus-summary-check-current)
6254 (not (gnus-data-unread-p (car data)))))
6255 (setq data (cdr data)))
6260 (unless (memq (gnus-data-number (car data))
6262 ((eq gnus-auto-goto-ignores
6263 'always-undownloaded)
6264 gnus-newsgroup-undownloaded)
6267 ((eq gnus-auto-goto-ignores
6269 gnus-newsgroup-unfetched)
6270 ((eq gnus-auto-goto-ignores
6272 gnus-newsgroup-undownloaded)))
6273 (when (gnus-data-unread-p (car data))
6274 (setq result (car data)
6276 (setq data (cdr data)))
6279 (goto-char (gnus-data-pos result))
6280 (gnus-data-number result)))))
6282 (defun gnus-summary-find-prev (&optional unread article)
6283 (let* ((eobp (eobp))
6284 (article (or article (gnus-summary-article-number)))
6285 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6287 (when (and (not eobp)
6288 (or (not gnus-summary-check-current)
6290 (not (gnus-data-unread-p (car data)))))
6291 (setq data (cdr data)))
6296 (unless (memq (gnus-data-number (car data))
6298 ((eq gnus-auto-goto-ignores
6299 'always-undownloaded)
6300 gnus-newsgroup-undownloaded)
6303 ((eq gnus-auto-goto-ignores
6305 gnus-newsgroup-unfetched)
6306 ((eq gnus-auto-goto-ignores
6308 gnus-newsgroup-undownloaded)))
6309 (when (gnus-data-unread-p (car data))
6310 (setq result (car data)
6312 (setq data (cdr data)))
6315 (goto-char (gnus-data-pos result))
6316 (gnus-data-number result))))
6318 (defun gnus-summary-find-subject (subject &optional unread backward article)
6319 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6320 (article (or article (gnus-summary-article-number)))
6321 (articles (gnus-data-list backward))
6322 (arts (gnus-data-find-list article articles))
6324 (when (or (not gnus-summary-check-current)
6326 (not (gnus-data-unread-p (car arts))))
6327 (setq arts (cdr arts)))
6329 (and (or (not unread)
6330 (gnus-data-unread-p (car arts)))
6331 (vectorp (gnus-data-header (car arts)))
6333 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6334 (setq result (car arts)
6336 (setq arts (cdr arts)))
6338 (goto-char (gnus-data-pos result))
6339 (gnus-data-number result))))
6341 (defun gnus-summary-search-forward (&optional unread subject backward)
6342 "Search forward for an article.
6343 If UNREAD, look for unread articles. If SUBJECT, look for
6344 articles with that subject. If BACKWARD, search backward instead."
6345 (cond (subject (gnus-summary-find-subject subject unread backward))
6346 (backward (gnus-summary-find-prev unread))
6347 (t (gnus-summary-find-next unread))))
6349 (defun gnus-recenter (&optional n)
6350 "Center point in window and redisplay frame.
6351 Also do horizontal recentering."
6353 (when (and gnus-auto-center-summary
6354 (not (eq gnus-auto-center-summary 'vertical)))
6355 (gnus-horizontal-recenter))
6358 (defun gnus-summary-recenter ()
6359 "Center point in the summary window.
6360 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6361 displayed, no centering will be performed."
6362 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6363 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6365 ;; The user has to want it.
6366 (when gnus-auto-center-summary
6367 (let* ((top (cond ((< (window-height) 4) 0)
6368 ((< (window-height) 7) 1)
6369 (t (if (numberp gnus-auto-center-summary)
6370 gnus-auto-center-summary
6371 (/ (1- (window-height)) 2)))))
6372 (height (1- (window-height)))
6373 (bottom (save-excursion (goto-char (point-max))
6374 (forward-line (- height))
6376 (window (get-buffer-window (current-buffer))))
6377 (when (get-buffer-window gnus-article-buffer)
6378 ;; Only do recentering when the article buffer is displayed,
6379 ;; Set the window start to either `bottom', which is the biggest
6380 ;; possible valid number, or the second line from the top,
6381 ;; whichever is the least.
6382 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6383 (if (> bottom top-pos)
6384 ;; Keep the second line from the top visible
6385 (set-window-start window top-pos t)
6386 ;; Try to keep the bottom line visible; if it's partially
6387 ;; obscured, either scroll one more line to make it fully
6388 ;; visible, or revert to using TOP-POS.
6390 (goto-char (point-max))
6392 (let ((last-line-start (point)))
6394 (set-window-start window (point) t)
6395 (when (not (pos-visible-in-window-p last-line-start window))
6397 (set-window-start window (min (point) top-pos) t)))))))
6398 ;; Do horizontal recentering while we're at it.
6399 (when (and (get-buffer-window (current-buffer) t)
6400 (not (eq gnus-auto-center-summary 'vertical)))
6401 (let ((selected (selected-window)))
6402 (select-window (get-buffer-window (current-buffer) t))
6403 (gnus-summary-position-point)
6404 (gnus-horizontal-recenter)
6405 (select-window selected))))))
6407 (defun gnus-summary-jump-to-group (newsgroup)
6408 "Move point to NEWSGROUP in group mode buffer."
6409 ;; Keep update point of group mode buffer if visible.
6410 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6411 (save-window-excursion
6412 ;; Take care of tree window mode.
6413 (when (get-buffer-window gnus-group-buffer)
6414 (pop-to-buffer gnus-group-buffer))
6415 (gnus-group-jump-to-group newsgroup))
6417 ;; Take care of tree window mode.
6418 (if (get-buffer-window gnus-group-buffer)
6419 (pop-to-buffer gnus-group-buffer)
6420 (set-buffer gnus-group-buffer))
6421 (gnus-group-jump-to-group newsgroup))))
6423 ;; This function returns a list of article numbers based on the
6424 ;; difference between the ranges of read articles in this group and
6425 ;; the range of active articles.
6426 (defun gnus-list-of-unread-articles (group)
6427 (let* ((read (gnus-info-read (gnus-get-info group)))
6428 (active (or (gnus-active group) (gnus-activate-group group)))
6431 ;; If none are read, then all are unread.
6433 (setq first (car active))
6434 ;; If the range of read articles is a single range, then the
6435 ;; first unread article is the article after the last read
6436 ;; article. Sounds logical, doesn't it?
6437 (if (and (not (listp (cdr read)))
6438 (or (< (car read) (car active))
6439 (progn (setq read (list read))
6441 (setq first (max (car active) (1+ (cdr read))))
6442 ;; `read' is a list of ranges.
6443 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6446 (setq first (car active)))
6449 (while (< first nlast)
6450 (setq unread (cons first unread)
6452 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6453 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6454 (setq read (cdr read)))))
6455 ;; And add the last unread articles.
6456 (while (<= first last)
6457 (setq unread (cons first unread)
6459 ;; Return the list of unread articles.
6460 (delq 0 (nreverse unread))))
6462 (defun gnus-list-of-read-articles (group)
6463 "Return a list of unread, unticked and non-dormant articles."
6464 (let* ((info (gnus-get-info group))
6465 (marked (gnus-info-marks info))
6466 (active (gnus-active group)))
6468 (gnus-list-range-difference
6469 (gnus-list-range-difference
6470 (gnus-sorted-complement
6471 (gnus-uncompress-range active)
6472 (gnus-list-of-unread-articles group))
6473 (cdr (assq 'dormant marked)))
6474 (cdr (assq 'tick marked))))))
6476 ;; This function returns a sequence of article numbers based on the
6477 ;; difference between the ranges of read articles in this group and
6478 ;; the range of active articles.
6479 (defun gnus-sequence-of-unread-articles (group)
6480 (let* ((read (gnus-info-read (gnus-get-info group)))
6481 (active (or (gnus-active group) (gnus-activate-group group)))
6484 ;; If none are read, then all are unread.
6486 (setq first (car active))
6487 ;; If the range of read articles is a single range, then the
6488 ;; first unread article is the article after the last read
6489 ;; article. Sounds logical, doesn't it?
6490 (if (and (not (listp (cdr read)))
6491 (or (< (car read) (car active))
6492 (progn (setq read (list read))
6494 (setq first (max (car active) (1+ (cdr read))))
6495 ;; `read' is a list of ranges.
6496 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6499 (setq first (car active)))
6502 (push (cons first nlast) unread))
6503 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6504 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6505 (setq read (cdr read)))))
6506 ;; And add the last unread articles.
6507 (cond ((< first last)
6508 (push (cons first last) unread))
6510 (push first unread)))
6511 ;; Return the sequence of unread articles.
6512 (delq 0 (nreverse unread))))
6514 ;; Various summary commands
6516 (defun gnus-summary-select-article-buffer ()
6517 "Reconfigure windows to show article buffer."
6519 (if (not (gnus-buffer-live-p gnus-article-buffer))
6520 (error "There is no article buffer for this summary buffer")
6521 (gnus-configure-windows 'article)
6522 (select-window (get-buffer-window gnus-article-buffer))))
6524 (defun gnus-summary-universal-argument (arg)
6525 "Perform any operation on all articles that are process/prefixed."
6527 (let ((articles (gnus-summary-work-articles arg))
6534 (substitute-command-keys
6535 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6537 (gnus-error 1 "Undefined key")
6540 (gnus-summary-goto-subject (setq article (pop articles)))
6541 (let (gnus-newsgroup-processable)
6542 (command-execute func))
6543 (gnus-summary-remove-process-mark article)))))
6544 (gnus-summary-position-point))
6546 (defun gnus-summary-toggle-truncation (&optional arg)
6547 "Toggle truncation of summary lines.
6548 With ARG, turn line truncation on if ARG is positive."
6550 (setq truncate-lines
6551 (if (null arg) (not truncate-lines)
6552 (> (prefix-numeric-value arg) 0)))
6555 (defun gnus-summary-find-for-reselect ()
6556 "Return the number of an article to stay on across a reselect.
6557 The current article is considered, then following articles, then previous
6558 articles. An article is sought which is not cancelled and isn't a temporary
6559 insertion from another group. If there's no such then return a dummy 0."
6561 (dolist (rev '(nil t))
6562 (unless found ; don't demand the reverse list if we don't need it
6563 (let ((data (gnus-data-find-list
6564 (gnus-summary-article-number) (gnus-data-list rev))))
6565 (while (and data (not found))
6566 (if (and (< 0 (gnus-data-number (car data)))
6567 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6568 (setq found (gnus-data-number (car data))))
6569 (setq data (cdr data))))))
6572 (defun gnus-summary-reselect-current-group (&optional all rescan)
6573 "Exit and then reselect the current newsgroup.
6574 The prefix argument ALL means to select all articles."
6576 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6577 (error "Ephemeral groups can't be reselected"))
6578 (let ((current-subject (gnus-summary-find-for-reselect))
6579 (group gnus-newsgroup-name))
6580 (setq gnus-newsgroup-begin nil)
6581 (gnus-summary-exit nil 'leave-hidden)
6582 ;; We have to adjust the point of group mode buffer because
6583 ;; point was moved to the next unread newsgroup by exiting.
6584 (gnus-summary-jump-to-group group)
6587 (save-window-excursion
6588 ;; Don't show group contents.
6589 (set-window-start (selected-window) (point-max))
6590 (gnus-group-get-new-news-this-group 1))))
6591 (gnus-group-read-group all t)
6592 (gnus-summary-goto-subject current-subject nil t)))
6594 (defun gnus-summary-rescan-group (&optional all)
6595 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6597 (gnus-summary-reselect-current-group all t))
6599 (defun gnus-summary-update-info (&optional non-destructive)
6601 (let ((group gnus-newsgroup-name))
6603 (when gnus-newsgroup-kill-headers
6604 (setq gnus-newsgroup-killed
6605 (gnus-compress-sequence
6607 (gnus-list-range-intersection
6608 gnus-newsgroup-unselected gnus-newsgroup-killed)
6609 gnus-newsgroup-unreads)
6611 (unless (listp (cdr gnus-newsgroup-killed))
6612 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6613 (let ((headers gnus-newsgroup-headers))
6614 ;; Set the new ranges of read articles.
6615 (with-current-buffer gnus-group-buffer
6616 (gnus-undo-force-boundary))
6617 (gnus-update-read-articles
6618 group (gnus-sorted-union
6619 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6620 ;; Set the current article marks.
6621 (let ((gnus-newsgroup-scored
6622 (if (and (not gnus-save-score)
6623 (not non-destructive))
6625 gnus-newsgroup-scored)))
6627 (gnus-update-marks)))
6628 ;; Do the cross-ref thing.
6629 (when gnus-use-cross-reference
6630 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6631 ;; Do not switch windows but change the buffer to work.
6632 (set-buffer gnus-group-buffer)
6633 (unless (gnus-ephemeral-group-p group)
6634 (gnus-group-update-group group)))))))
6636 (defun gnus-summary-save-newsrc (&optional force)
6637 "Save the current number of read/marked articles in the dribble buffer.
6638 The dribble buffer will then be saved.
6639 If FORCE (the prefix), also save the .newsrc file(s)."
6641 (gnus-summary-update-info t)
6643 (gnus-save-newsrc-file)
6644 (gnus-dribble-save)))
6646 (defun gnus-summary-exit (&optional temporary leave-hidden)
6647 "Exit reading current newsgroup, and then return to group selection mode.
6648 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6650 (gnus-set-global-variables)
6651 (gnus-kill-save-kill-buffer)
6652 (gnus-async-halt-prefetch)
6653 (let* ((group gnus-newsgroup-name)
6654 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6655 (gnus-group-is-exiting-p t)
6658 (buf (current-buffer)))
6660 ;; Do adaptive scoring, and possibly save score files.
6661 (when gnus-newsgroup-adaptive
6662 (gnus-score-adaptive))
6663 (when gnus-use-scoring
6665 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6666 ;; If we have several article buffers, we kill them at exit.
6667 (unless gnus-single-article-buffer
6668 (gnus-kill-buffer gnus-original-article-buffer)
6669 (setq gnus-article-current nil))
6670 (when gnus-use-cache
6671 (gnus-cache-possibly-remove-articles)
6672 (gnus-cache-save-buffers))
6673 (gnus-async-prefetch-remove-group group)
6674 (when gnus-suppress-duplicates
6675 (gnus-dup-enter-articles))
6676 (when gnus-use-trees
6677 (gnus-tree-close group))
6678 (when gnus-use-cache
6679 (gnus-cache-write-active))
6680 ;; Remove entries for this group.
6681 (nnmail-purge-split-history (gnus-group-real-name group))
6682 ;; Make all changes in this group permanent.
6684 (gnus-run-hooks 'gnus-exit-group-hook)
6685 (gnus-summary-update-info))
6686 (gnus-close-group group)
6687 ;; Make sure where we were, and go to next newsgroup.
6688 (set-buffer gnus-group-buffer)
6690 (gnus-group-jump-to-group group))
6691 (gnus-run-hooks 'gnus-summary-exit-hook)
6692 (unless (or quit-config
6693 ;; If this group has disappeared from the summary
6694 ;; buffer, don't skip forwards.
6695 (not (string= group (gnus-group-group-name))))
6696 (gnus-group-next-unread-group 1))
6697 (setq group-point (point))
6700 ;; If we have several article buffers, we kill them at exit.
6701 (unless gnus-single-article-buffer
6702 (gnus-kill-buffer gnus-article-buffer)
6703 (gnus-kill-buffer gnus-original-article-buffer)
6704 (setq gnus-article-current nil))
6706 (if (not gnus-kill-summary-on-exit)
6708 (gnus-deaden-summary)
6710 ;; We set all buffer-local variables to nil. It is unclear why
6711 ;; this is needed, but if we don't, buffer-local variables are
6712 ;; not garbage-collected, it seems. This would the lead to en
6713 ;; ever-growing Emacs.
6714 (gnus-summary-clear-local-variables)
6715 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6716 (gnus-summary-clear-local-variables))
6717 (when (get-buffer gnus-article-buffer)
6718 (bury-buffer gnus-article-buffer))
6719 ;; Return to group mode buffer.
6720 (when (eq mode 'gnus-summary-mode)
6721 (gnus-kill-buffer buf)))
6722 (setq gnus-current-select-method gnus-select-method)
6723 (set-buffer gnus-group-buffer)
6725 (gnus-handle-ephemeral-exit quit-config)
6726 (goto-char group-point)
6727 (unless leave-hidden
6728 (gnus-configure-windows 'group 'force))
6729 (unless (pos-visible-in-window-p)
6730 (forward-line (/ (static-if (featurep 'xemacs)
6731 (window-displayed-height)
6732 (1- (window-height)))
6734 (set-window-start (selected-window) (point))
6735 (goto-char group-point)))
6736 ;; Clear the current group name.
6738 (setq gnus-newsgroup-name nil)))))
6740 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6741 (defun gnus-summary-exit-no-update (&optional no-questions)
6742 "Quit reading current newsgroup without updating read article info."
6744 (let* ((group gnus-newsgroup-name)
6745 (gnus-group-is-exiting-p t)
6746 (gnus-group-is-exiting-without-update-p t)
6747 (quit-config (gnus-group-quit-config group)))
6748 (when (or no-questions
6750 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6751 (gnus-async-halt-prefetch)
6752 (run-hooks 'gnus-summary-prepare-exit-hook)
6753 ;; If we have several article buffers, we kill them at exit.
6754 (unless gnus-single-article-buffer
6755 (gnus-kill-buffer gnus-article-buffer)
6756 (gnus-kill-buffer gnus-original-article-buffer)
6757 (setq gnus-article-current nil))
6758 (if (not gnus-kill-summary-on-exit)
6759 (gnus-deaden-summary)
6760 (gnus-close-group group)
6761 (gnus-summary-clear-local-variables)
6762 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6763 (gnus-summary-clear-local-variables))
6764 (gnus-kill-buffer gnus-summary-buffer))
6765 (unless gnus-single-article-buffer
6766 (setq gnus-article-current nil))
6767 (when gnus-use-trees
6768 (gnus-tree-close group))
6769 (gnus-async-prefetch-remove-group group)
6770 (when (get-buffer gnus-article-buffer)
6771 (bury-buffer gnus-article-buffer))
6772 ;; Return to the group buffer.
6773 (gnus-configure-windows 'group 'force)
6774 ;; Clear the current group name.
6775 (setq gnus-newsgroup-name nil)
6776 (unless (gnus-ephemeral-group-p group)
6777 (gnus-group-update-group group))
6778 (when (equal (gnus-group-group-name) group)
6779 (gnus-group-next-unread-group 1))
6781 (gnus-handle-ephemeral-exit quit-config)))))
6783 (defun gnus-handle-ephemeral-exit (quit-config)
6784 "Handle movement when leaving an ephemeral group.
6785 The state which existed when entering the ephemeral is reset."
6786 (if (not (buffer-name (car quit-config)))
6787 (gnus-configure-windows 'group 'force)
6788 (set-buffer (car quit-config))
6789 (cond ((eq major-mode 'gnus-summary-mode)
6790 (gnus-set-global-variables))
6791 ((eq major-mode 'gnus-article-mode)
6793 ;; The `gnus-summary-buffer' variable may point
6794 ;; to the old summary buffer when using a single
6796 (unless (gnus-buffer-live-p gnus-summary-buffer)
6797 (set-buffer gnus-group-buffer))
6798 (set-buffer gnus-summary-buffer)
6799 (gnus-set-global-variables))))
6800 (if (or (eq (cdr quit-config) 'article)
6801 (eq (cdr quit-config) 'pick))
6803 ;; The current article may be from the ephemeral group
6804 ;; thus it is best that we reload this article
6806 ;; If we're exiting from a large digest, this can be
6807 ;; extremely slow. So, it's better not to reload it. -- jh.
6808 ;;(gnus-summary-show-article)
6809 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6810 (gnus-configure-windows 'pick 'force)
6811 (gnus-configure-windows (cdr quit-config) 'force)))
6812 (gnus-configure-windows (cdr quit-config) 'force))
6813 (when (eq major-mode 'gnus-summary-mode)
6814 (gnus-summary-next-subject 1 nil t)
6815 (gnus-summary-recenter)
6816 (gnus-summary-position-point))))
6818 (defun gnus-summary-preview-mime-message ()
6819 "MIME decode and play this message."
6821 (let ((gnus-break-pages nil)
6823 (gnus-summary-select-article gnus-show-all-headers t))
6824 (let ((w (get-buffer-window gnus-article-buffer)))
6826 (select-window (get-buffer-window gnus-article-buffer)))))
6830 (defvar gnus-dead-summary-mode-map nil)
6832 (unless gnus-dead-summary-mode-map
6833 (setq gnus-dead-summary-mode-map (make-keymap))
6834 (suppress-keymap gnus-dead-summary-mode-map)
6835 (substitute-key-definition
6836 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6837 (dolist (key '("\C-d" "\r" "\177" [delete]))
6838 (define-key gnus-dead-summary-mode-map
6839 key 'gnus-summary-wake-up-the-dead))
6840 (dolist (key '("q" "Q"))
6841 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6843 (defvar gnus-dead-summary-mode nil
6844 "Minor mode for Gnus summary buffers.")
6846 (defun gnus-dead-summary-mode (&optional arg)
6847 "Minor mode for Gnus summary buffers."
6849 (when (eq major-mode 'gnus-summary-mode)
6850 (make-local-variable 'gnus-dead-summary-mode)
6851 (setq gnus-dead-summary-mode
6852 (if (null arg) (not gnus-dead-summary-mode)
6853 (> (prefix-numeric-value arg) 0)))
6854 (when gnus-dead-summary-mode
6856 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6858 (defun gnus-deaden-summary ()
6859 "Make the current summary buffer into a dead summary buffer."
6860 ;; Kill any previous dead summary buffer.
6861 (when (and gnus-dead-summary
6862 (buffer-name gnus-dead-summary))
6863 (with-current-buffer gnus-dead-summary
6864 (when gnus-dead-summary-mode
6865 (kill-buffer (current-buffer)))))
6866 ;; Make this the current dead summary.
6867 (setq gnus-dead-summary (current-buffer))
6868 (gnus-dead-summary-mode 1)
6869 (let ((name (buffer-name)))
6870 (when (string-match "Summary" name)
6872 (concat (substring name 0 (match-beginning 0)) "Dead "
6873 (substring name (match-beginning 0)))
6877 (defun gnus-kill-or-deaden-summary (buffer)
6878 "Kill or deaden the summary BUFFER."
6880 (when (and (buffer-name buffer)
6881 (not gnus-single-article-buffer))
6882 (with-current-buffer buffer
6883 (gnus-kill-buffer gnus-article-buffer)
6884 (gnus-kill-buffer gnus-original-article-buffer)))
6887 (gnus-kill-summary-on-exit
6888 (when (and gnus-use-trees
6889 (gnus-buffer-exists-p buffer))
6892 (gnus-tree-close gnus-newsgroup-name)))
6893 (gnus-kill-buffer buffer))
6894 ;; Deaden the buffer.
6895 ((gnus-buffer-exists-p buffer)
6898 (gnus-deaden-summary))))))
6900 (defun gnus-summary-wake-up-the-dead (&rest args)
6901 "Wake up the dead summary buffer."
6903 (gnus-dead-summary-mode -1)
6904 (let ((name (buffer-name)))
6905 (when (string-match "Dead " name)
6907 (concat (substring name 0 (match-beginning 0))
6908 (substring name (match-end 0)))
6910 (gnus-message 3 "This dead summary is now alive again"))
6912 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6913 (defun gnus-summary-fetch-faq (&optional faq-dir)
6914 "Fetch the FAQ for the current group.
6915 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6919 (when current-prefix-arg
6921 "FAQ dir: " (and (listp gnus-group-faq-directory)
6923 gnus-group-faq-directory))))))
6924 (let (gnus-faq-buffer)
6925 (when (setq gnus-faq-buffer
6926 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6927 (gnus-configure-windows 'summary-faq))))
6929 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6930 (defun gnus-summary-describe-group (&optional force)
6931 "Describe the current newsgroup."
6933 (gnus-group-describe-group force gnus-newsgroup-name))
6935 (defun gnus-summary-describe-briefly ()
6936 "Describe summary mode commands briefly."
6938 (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")))
6940 ;; Walking around group mode buffer from summary mode.
6942 (defun gnus-summary-next-group (&optional no-article target-group backward)
6943 "Exit current newsgroup and then select next unread newsgroup.
6944 If prefix argument NO-ARTICLE is non-nil, no article is selected
6945 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6946 previous group instead."
6948 ;; Stop pre-fetching.
6949 (gnus-async-halt-prefetch)
6950 (let ((current-group gnus-newsgroup-name)
6951 (current-buffer (current-buffer))
6953 ;; First we semi-exit this group to update Xrefs and all variables.
6954 ;; We can't do a real exit, because the window conf must remain
6955 ;; the same in case the user is prompted for info, and we don't
6956 ;; want the window conf to change before that...
6957 (gnus-summary-exit t)
6958 (while (not entered)
6959 ;; Then we find what group we are supposed to enter.
6960 (set-buffer gnus-group-buffer)
6961 (gnus-group-jump-to-group current-group)
6964 (if (eq gnus-keep-same-level 'best)
6965 (gnus-summary-best-group gnus-newsgroup-name)
6966 (gnus-summary-search-group backward gnus-keep-same-level))))
6967 (if (not target-group)
6968 ;; There are no further groups, so we return to the group
6971 (gnus-message 5 "Returning to the group buffer")
6973 (when (gnus-buffer-live-p current-buffer)
6974 (set-buffer current-buffer)
6975 (gnus-summary-exit))
6976 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6977 ;; We try to enter the target group.
6978 (gnus-group-jump-to-group target-group)
6979 (let ((unreads (gnus-group-group-unread)))
6980 (if (and (or (eq t unreads)
6981 (and unreads (not (zerop unreads))))
6982 (gnus-summary-read-group
6983 target-group nil no-article
6984 (and (buffer-name current-buffer) current-buffer)
6987 (setq current-group target-group
6988 target-group nil)))))))
6990 (defun gnus-summary-prev-group (&optional no-article)
6991 "Exit current newsgroup and then select previous unread newsgroup.
6992 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6994 (gnus-summary-next-group no-article nil t))
6996 ;; Walking around summary lines.
6998 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6999 "Go to the first subject satisfying any non-nil constraint.
7000 If UNREAD is non-nil, the article should be unread.
7001 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7002 If UNSEEN is non-nil, the article should be unseen.
7003 Returns the article selected or nil if there are no matching articles."
7007 ((null gnus-newsgroup-data)
7008 (gnus-message 3 "No articles in the group")
7010 ;; Pick the first article.
7011 ((not (or unread undownloaded unseen))
7012 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7013 (gnus-data-number (car gnus-newsgroup-data)))
7014 ;; Find the first unread article.
7016 (let ((data gnus-newsgroup-data))
7018 (let ((num (gnus-data-number (car data))))
7019 (or (memq num gnus-newsgroup-unfetched)
7020 (not (or (and unread
7021 (memq num gnus-newsgroup-unreads))
7023 (memq num gnus-newsgroup-undownloaded))
7025 (memq num gnus-newsgroup-unseen)))))))
7026 (setq data (cdr data)))
7030 (goto-char (gnus-data-pos (car data)))
7031 (gnus-data-number (car data)))
7032 (gnus-message 3 "No more%s articles"
7033 (let* ((r (when unread " unread"))
7034 (d (when undownloaded " undownloaded"))
7035 (s (when unseen " unseen"))
7036 (l (delq nil (list r d s))))
7037 (cond ((= 3 (length l))
7038 (concat r "," d ", or" s))
7040 (concat (car l) ", or" (cadr l)))
7047 (gnus-summary-position-point))))))
7049 (defun gnus-summary-next-subject (n &optional unread dont-display)
7050 "Go to next N'th summary line.
7051 If N is negative, go to the previous N'th subject line.
7052 If UNREAD is non-nil, only unread articles are selected.
7053 The difference between N and the actual number of steps taken is
7056 (let ((backward (< n 0))
7060 (gnus-summary-find-prev unread)
7061 (gnus-summary-find-next unread)))
7062 (unless (zerop (setq n (1- n)))
7063 (gnus-summary-show-thread)))
7065 (gnus-message 7 "No more%s articles"
7066 (if unread " unread" "")))
7067 (unless dont-display
7068 (gnus-summary-recenter)
7069 (gnus-summary-position-point))
7072 (defun gnus-summary-next-unread-subject (n)
7073 "Go to next N'th unread summary line."
7075 (gnus-summary-next-subject n t))
7077 (defun gnus-summary-prev-subject (n &optional unread)
7078 "Go to previous N'th summary line.
7079 If optional argument UNREAD is non-nil, only unread article is selected."
7081 (gnus-summary-next-subject (- n) unread))
7083 (defun gnus-summary-prev-unread-subject (n)
7084 "Go to previous N'th unread summary line."
7086 (gnus-summary-next-subject (- n) t))
7088 (defun gnus-summary-goto-subjects (articles)
7089 "Insert the subject header for ARTICLES in the current buffer."
7091 (dolist (article articles)
7092 (gnus-summary-goto-subject article t)))
7093 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7094 (gnus-summary-position-point))
7096 (defun gnus-summary-goto-subject (article &optional force silent)
7097 "Go the subject line of ARTICLE.
7098 If FORCE, also allow jumping to articles not currently shown."
7099 (interactive "nArticle number: ")
7100 (unless (numberp article)
7101 (error "Article %s is not a number" article))
7103 (data (gnus-data-find article)))
7104 ;; We read in the article if we have to.
7107 (gnus-summary-insert-subject
7109 (if (or (numberp force) (vectorp force)) force)
7111 (setq data (gnus-data-find article)))
7116 (gnus-message 3 "Can't find article %d" article))
7118 (let ((pt (gnus-data-pos data)))
7120 (gnus-summary-set-article-display-arrow pt))
7121 (gnus-summary-position-point)
7124 ;; Walking around summary lines with displaying articles.
7126 (defun gnus-summary-expand-window (&optional arg)
7127 "Make the summary buffer take up the entire Emacs frame.
7128 Given a prefix, will force an `article' buffer configuration."
7131 (gnus-configure-windows 'article 'force)
7132 (gnus-configure-windows 'summary 'force)))
7134 (defun gnus-summary-display-article (article &optional all-header)
7135 "Display ARTICLE in article buffer."
7136 (when (gnus-buffer-live-p gnus-article-buffer)
7137 (with-current-buffer gnus-article-buffer
7138 (set-buffer-multibyte t)))
7139 (gnus-set-global-variables)
7140 (when (gnus-buffer-live-p gnus-article-buffer)
7141 (with-current-buffer gnus-article-buffer
7142 (setq gnus-article-charset gnus-newsgroup-charset)
7143 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7144 (set-buffer-multibyte t)))
7148 (if gnus-summary-display-article-function
7149 (funcall gnus-summary-display-article-function article all-header)
7150 (gnus-article-prepare article all-header))
7151 (with-current-buffer gnus-article-buffer
7152 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7154 (gnus-run-hooks 'gnus-select-article-hook)
7155 (when (and gnus-current-article
7156 (not (zerop gnus-current-article)))
7157 (gnus-summary-goto-subject gnus-current-article))
7158 (gnus-summary-recenter)
7159 (when (and gnus-use-trees gnus-show-threads)
7160 (gnus-possibly-generate-tree article)
7161 (gnus-highlight-selected-tree article))
7162 ;; Successfully display article.
7163 (gnus-article-set-window-start
7164 (cdr (assq article gnus-newsgroup-bookmarks))))))
7166 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7167 "Select the current article.
7168 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7169 non-nil, the article will be re-fetched even if it already present in
7170 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7172 ;; Make sure we are in the summary buffer to work around bbdb bug.
7173 (unless (eq major-mode 'gnus-summary-mode)
7174 (set-buffer gnus-summary-buffer))
7175 (let ((article (or article (gnus-summary-article-number)))
7176 (all-headers (not (not all-headers))) ;Must be T or NIL.
7177 gnus-summary-display-article-function)
7179 (gnus-summary-article-pseudo-p article)
7180 (error "This is a pseudo-article"))
7182 (set-buffer gnus-summary-buffer)
7183 (if (or (and gnus-single-article-buffer
7184 (or (null gnus-current-article)
7185 (null gnus-article-current)
7186 (null (get-buffer gnus-article-buffer))
7187 (not (eq article (cdr gnus-article-current)))
7188 (not (equal (car gnus-article-current)
7189 gnus-newsgroup-name))))
7190 (and (not gnus-single-article-buffer)
7191 (or (null gnus-current-article)
7192 (not (eq gnus-current-article article))))
7194 ;; The requested article is different from the current article.
7196 (gnus-summary-display-article article all-headers)
7197 (gnus-article-set-window-start
7198 (cdr (assq article gnus-newsgroup-bookmarks)))
7202 (defun gnus-summary-force-verify-and-decrypt ()
7203 "Display buttons for signed/encrypted parts and verify/decrypt them."
7205 (let ((mm-verify-option 'known)
7206 (mm-decrypt-option 'known)
7207 (gnus-article-emulate-mime t)
7208 (gnus-buttonized-mime-types (append (list "multipart/signed"
7209 "multipart/encrypted")
7210 gnus-buttonized-mime-types)))
7211 (gnus-summary-select-article nil 'force)))
7213 (defun gnus-summary-set-current-mark (&optional current-mark)
7214 "Obsolete function."
7217 (defun gnus-summary-next-article (&optional unread subject backward push)
7218 "Select the next article.
7219 If UNREAD, only unread articles are selected.
7220 If SUBJECT, only articles with SUBJECT are selected.
7221 If BACKWARD, the previous article is selected instead of the next."
7224 ;; Is there such an article?
7225 ((and (gnus-summary-search-forward unread subject backward)
7226 (or (gnus-summary-display-article (gnus-summary-article-number))
7227 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7228 (gnus-summary-position-point))
7229 ;; If not, we try the first unread, if that is wanted.
7231 gnus-auto-select-same
7232 (gnus-summary-first-unread-article))
7233 (gnus-summary-position-point)
7234 (gnus-message 6 "Wrapped"))
7235 ;; Try to get next/previous article not displayed in this group.
7236 ((and gnus-auto-extend-newsgroup
7237 (not unread) (not subject))
7238 (gnus-summary-goto-article
7239 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7240 nil (count-lines (point-min) (point))))
7241 ;; Go to next/previous group.
7243 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7244 (gnus-summary-jump-to-group gnus-newsgroup-name))
7245 (let ((cmd last-command-char)
7247 (with-current-buffer gnus-group-buffer
7250 (if (eq gnus-keep-same-level 'best)
7251 (gnus-summary-best-group gnus-newsgroup-name)
7252 (gnus-summary-search-group backward gnus-keep-same-level))))
7253 ;; For some reason, the group window gets selected. We change
7255 (select-window (get-buffer-window (current-buffer)))
7256 ;; Select next unread newsgroup automagically.
7258 ((or (not gnus-auto-select-next)
7260 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7261 ((or (eq gnus-auto-select-next 'quietly)
7262 (and (eq gnus-auto-select-next 'slightly-quietly)
7264 (and (eq gnus-auto-select-next 'almost-quietly)
7265 (gnus-summary-last-article-p)))
7267 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7269 (gnus-message 7 "No more%s articles (%s)..."
7270 (if unread " unread" "")
7271 (if group (concat "selecting " group)
7273 (gnus-summary-next-group nil group backward)))
7275 (when (gnus-key-press-event-p last-input-event)
7276 (gnus-summary-walk-group-buffer
7277 gnus-newsgroup-name cmd unread backward point))))))))
7279 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7280 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7281 (?\C-p (gnus-group-prev-unread-group 1))))
7282 (cursor-in-echo-area t)
7283 keve key group ended prompt)
7285 (set-buffer gnus-group-buffer)
7288 (if (eq gnus-keep-same-level 'best)
7289 (gnus-summary-best-group gnus-newsgroup-name)
7290 (gnus-summary-search-group backward gnus-keep-same-level))))
7294 "No more%s articles%s " (if unread " unread" "")
7296 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7297 (format " (Type %s for %s [%s])"
7298 (single-key-description cmd)
7299 (gnus-group-decoded-name group)
7300 (gnus-group-unread group))
7301 (format " (Type %s to exit %s)"
7302 (single-key-description cmd)
7303 (gnus-group-decoded-name gnus-newsgroup-name)))))
7304 ;; Confirm auto selection.
7305 (setq key (car (setq keve (gnus-read-event-char prompt)))
7308 ((assq key keystrokes)
7309 (let ((obuf (current-buffer)))
7310 (switch-to-buffer gnus-group-buffer)
7312 (gnus-group-jump-to-group group))
7313 (eval (cadr (assq key keystrokes)))
7314 (setq group (gnus-group-group-name))
7315 (switch-to-buffer obuf))
7319 (gnus-ephemeral-group-p gnus-newsgroup-name))
7321 (gnus-summary-next-group nil group backward)))
7323 (push (cdr keve) unread-command-events))))))
7325 (defun gnus-summary-next-unread-article ()
7326 "Select unread article after current one."
7328 (gnus-summary-next-article
7329 (or (not (eq gnus-summary-goto-unread 'never))
7330 (gnus-summary-last-article-p (gnus-summary-article-number)))
7331 (and gnus-auto-select-same
7332 (gnus-summary-article-subject))))
7334 (defun gnus-summary-prev-article (&optional unread subject)
7335 "Select the article after the current one.
7336 If UNREAD is non-nil, only unread articles are selected."
7338 (gnus-summary-next-article unread subject t))
7340 (defun gnus-summary-prev-unread-article ()
7341 "Select unread article before current one."
7343 (gnus-summary-prev-article
7344 (or (not (eq gnus-summary-goto-unread 'never))
7345 (gnus-summary-first-article-p (gnus-summary-article-number)))
7346 (and gnus-auto-select-same
7347 (gnus-summary-article-subject))))
7349 (defun gnus-summary-next-page (&optional lines circular stop)
7350 "Show next page of the selected article.
7351 If at the end of the current article, select the next article.
7352 LINES says how many lines should be scrolled up.
7354 If CIRCULAR is non-nil, go to the start of the article instead of
7355 selecting the next article when reaching the end of the current
7358 If STOP is non-nil, just stop when reaching the end of the message.
7360 Also see the variable `gnus-article-skip-boring'."
7362 (setq gnus-summary-buffer (current-buffer))
7363 (gnus-set-global-variables)
7364 (let ((article (gnus-summary-article-number))
7365 (article-window (get-buffer-window gnus-article-buffer t))
7367 ;; If the buffer is empty, we have no article.
7369 (error "No article to select"))
7370 (gnus-configure-windows 'article)
7371 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7372 (if (and (eq gnus-summary-goto-unread 'never)
7373 (not (gnus-summary-last-article-p article)))
7374 (gnus-summary-next-article)
7375 (gnus-summary-next-unread-article))
7376 (if (or (null gnus-current-article)
7377 (null gnus-article-current)
7378 (/= article (cdr gnus-article-current))
7379 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7380 ;; Selected subject is different from current article's.
7381 (gnus-summary-display-article article)
7382 (when article-window
7383 (gnus-eval-in-buffer-window gnus-article-buffer
7384 (setq endp (or (gnus-article-next-page lines)
7385 (gnus-article-only-boring-p))))
7388 (gnus-message 3 "End of message"))
7390 (gnus-summary-beginning-of-article))
7392 (gnus-message 3 "End of message"))
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 (gnus-summary-recenter)
7399 (gnus-summary-position-point)))
7401 (defun gnus-summary-prev-page (&optional lines move)
7402 "Show previous page of selected article.
7403 Argument LINES specifies lines to be scrolled down.
7404 If MOVE, move to the previous unread article if point is at
7405 the beginning of the buffer."
7407 (let ((article (gnus-summary-article-number))
7408 (article-window (get-buffer-window gnus-article-buffer t))
7410 (gnus-configure-windows 'article)
7411 (if (or (null gnus-current-article)
7412 (null gnus-article-current)
7413 (/= article (cdr gnus-article-current))
7414 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7415 ;; Selected subject is different from current article's.
7416 (gnus-summary-display-article article)
7417 (gnus-summary-recenter)
7418 (when article-window
7419 (gnus-eval-in-buffer-window gnus-article-buffer
7420 (setq endp (gnus-article-prev-page lines)))
7421 (when (and move endp)
7423 (gnus-message 3 "Beginning of message"))
7425 (if (and (eq gnus-summary-goto-unread 'never)
7426 (not (gnus-summary-first-article-p article)))
7427 (gnus-summary-prev-article)
7428 (gnus-summary-prev-unread-article))))))))
7429 (gnus-summary-position-point))
7431 (defun gnus-summary-prev-page-or-article (&optional lines)
7432 "Show previous page of selected article.
7433 Argument LINES specifies lines to be scrolled down.
7434 If at the beginning of the article, go to the next article."
7436 (gnus-summary-prev-page lines t))
7438 (defun gnus-summary-scroll-up (lines)
7439 "Scroll up (or down) one line current article.
7440 Argument LINES specifies lines to be scrolled up (or down if negative)."
7442 (gnus-configure-windows 'article)
7443 (gnus-summary-show-thread)
7444 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7445 (gnus-eval-in-buffer-window gnus-article-buffer
7447 (when (gnus-article-next-page lines)
7448 (gnus-message 3 "End of message")))
7450 (gnus-article-prev-page (- lines))))))
7451 (gnus-summary-recenter)
7452 (gnus-summary-position-point))
7454 (defun gnus-summary-scroll-down (lines)
7455 "Scroll down (or up) one line current article.
7456 Argument LINES specifies lines to be scrolled down (or up if negative)."
7458 (gnus-summary-scroll-up (- lines)))
7460 (defun gnus-summary-next-same-subject ()
7461 "Select next article which has the same subject as current one."
7463 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7465 (defun gnus-summary-prev-same-subject ()
7466 "Select previous article which has the same subject as current one."
7468 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7470 (defun gnus-summary-next-unread-same-subject ()
7471 "Select next unread article which has the same subject as current one."
7473 (gnus-summary-next-article t (gnus-summary-article-subject)))
7475 (defun gnus-summary-prev-unread-same-subject ()
7476 "Select previous unread article which has the same subject as current one."
7478 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7480 (defun gnus-summary-first-unread-article ()
7481 "Select the first unread article.
7482 Return nil if there are no unread articles."
7485 (when (gnus-summary-first-subject t)
7486 (gnus-summary-show-thread)
7487 (gnus-summary-first-subject t)
7488 (gnus-summary-display-article (gnus-summary-article-number)))
7489 (gnus-summary-position-point)))
7491 (defun gnus-summary-first-unread-subject ()
7492 "Place the point on the subject line of the first unread article.
7493 Return nil if there are no unread articles."
7496 (when (gnus-summary-first-subject t)
7497 (gnus-summary-show-thread)
7498 (gnus-summary-first-subject t))
7499 (gnus-summary-position-point)))
7501 (defun gnus-summary-first-unseen-subject ()
7502 "Place the point on the subject line of the first unseen article.
7503 Return nil if there are no unseen articles."
7506 (when (gnus-summary-first-subject nil nil t)
7507 (gnus-summary-show-thread)
7508 (gnus-summary-first-subject nil nil t))
7509 (gnus-summary-position-point)))
7511 (defun gnus-summary-first-unseen-or-unread-subject ()
7512 "Place the point on the subject line of the first unseen article or,
7513 if all article have been seen, on the subject line of the first unread
7517 (unless (when (gnus-summary-first-subject nil nil t)
7518 (gnus-summary-show-thread)
7519 (gnus-summary-first-subject nil nil t))
7520 (when (gnus-summary-first-subject t)
7521 (gnus-summary-show-thread)
7522 (gnus-summary-first-subject t)))
7523 (gnus-summary-position-point)))
7525 (defun gnus-summary-first-article ()
7526 "Select the first article.
7527 Return nil if there are no articles."
7530 (when (gnus-summary-first-subject)
7531 (gnus-summary-show-thread)
7532 (gnus-summary-first-subject)
7533 (gnus-summary-display-article (gnus-summary-article-number)))
7534 (gnus-summary-position-point)))
7536 (defun gnus-summary-best-unread-article (&optional arg)
7537 "Select the unread article with the highest score.
7538 If given a prefix argument, select the next unread article that has a
7539 score higher than the default score."
7541 (let ((article (if arg
7542 (gnus-summary-better-unread-subject)
7543 (gnus-summary-best-unread-subject))))
7545 (gnus-summary-goto-article article)
7546 (error "No unread articles"))))
7548 (defun gnus-summary-best-unread-subject ()
7549 "Select the unread subject with the highest score."
7551 (let ((best -1000000)
7552 (data gnus-newsgroup-data)
7555 (and (gnus-data-unread-p (car data))
7557 (gnus-summary-article-score (gnus-data-number (car data))))
7560 article (gnus-data-number (car data))))
7561 (setq data (cdr data)))
7563 (gnus-summary-goto-subject article))
7564 (gnus-summary-position-point)
7567 (defun gnus-summary-better-unread-subject ()
7568 "Select the first unread subject that has a score over the default score."
7570 (let ((data gnus-newsgroup-data)
7572 (while (and (setq article (gnus-data-number (car data)))
7573 (or (gnus-data-read-p (car data))
7574 (not (> (gnus-summary-article-score article)
7575 gnus-summary-default-score))))
7576 (setq data (cdr data)))
7578 (gnus-summary-goto-subject article))
7579 (gnus-summary-position-point)
7582 (defun gnus-summary-last-subject ()
7583 "Go to the last displayed subject line in the group."
7584 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7586 (gnus-summary-goto-subject article))))
7588 (defun gnus-summary-goto-article (article &optional all-headers force)
7589 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7590 If ALL-HEADERS is non-nil, no header lines are hidden.
7591 If FORCE, go to the article even if it isn't displayed. If FORCE
7592 is a number, it is the line the article is to be displayed on."
7596 "Article number or Message-ID: "
7597 (mapcar (lambda (number) (list (int-to-string number)))
7598 gnus-newsgroup-limit))
7602 (if (and (stringp article)
7603 (string-match "@\\|%40" article))
7604 (gnus-summary-refer-article article)
7605 (when (stringp article)
7606 (setq article (string-to-number article)))
7607 (if (gnus-summary-goto-subject article force)
7608 (gnus-summary-display-article article all-headers)
7609 (gnus-message 4 "Couldn't go to article %s" article) nil))
7610 (gnus-summary-position-point)))
7612 (defun gnus-summary-goto-last-article ()
7613 "Go to the previously read article."
7616 (when gnus-last-article
7617 (gnus-summary-goto-article gnus-last-article nil t))
7618 (gnus-summary-position-point)))
7620 (defun gnus-summary-pop-article (number)
7621 "Pop one article off the history and go to the previous.
7622 NUMBER articles will be popped off."
7625 (setq gnus-newsgroup-history
7626 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7628 (gnus-summary-goto-article (car to) nil t)
7629 (error "Article history empty")))
7630 (gnus-summary-position-point))
7632 ;; Summary commands and functions for limiting the summary buffer.
7634 (defun gnus-summary-limit-to-articles (n)
7635 "Limit the summary buffer to the next N articles.
7636 If not given a prefix, use the process marked articles instead."
7639 (let ((articles (gnus-summary-work-articles n)))
7640 (setq gnus-newsgroup-processable nil)
7641 (gnus-summary-limit articles))
7642 (gnus-summary-position-point)))
7644 (defun gnus-summary-pop-limit (&optional total)
7645 "Restore the previous limit.
7646 If given a prefix, remove all limits."
7649 (setq gnus-newsgroup-limits
7650 (list (mapcar (lambda (h) (mail-header-number h))
7651 gnus-newsgroup-headers))))
7652 (unless gnus-newsgroup-limits
7653 (error "No limit to pop"))
7655 (gnus-summary-limit nil 'pop)
7656 (gnus-summary-position-point)))
7658 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7659 "Limit the summary buffer to articles that have subjects that match a regexp.
7660 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7662 (list (read-string (if current-prefix-arg
7663 "Exclude subject (regexp): "
7664 "Limit to subject (regexp): "))
7665 nil current-prefix-arg))
7667 (setq header "subject"))
7668 (when (not (equal "" subject))
7670 (let ((articles (gnus-summary-find-matching
7671 (or header "subject") subject 'all nil nil
7674 (error "Found no matches for \"%s\"" subject))
7675 (gnus-summary-limit articles))
7676 (gnus-summary-position-point))))
7678 (defun gnus-summary-limit-to-author (from &optional not-matching)
7679 "Limit the summary buffer to articles that have authors that match a regexp.
7680 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7682 (list (read-string (if current-prefix-arg
7683 "Exclude author (regexp): "
7684 "Limit to author (regexp): "))
7685 current-prefix-arg))
7686 (gnus-summary-limit-to-subject from "from" not-matching))
7688 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
7689 "Limit the summary buffer to articles with the given RECIPIENT.
7691 If NOT-MATCHING, exclude RECIPIENT.
7693 To and Cc headers are checked. You need to include them in
7694 `nnmail-extra-headers'."
7695 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
7697 (list (read-string (format "%s recipient (regexp): "
7698 (if current-prefix-arg "Exclude" "Limit to")))
7699 current-prefix-arg))
7700 (when (not (equal "" recipient))
7702 (if (memq 'To nnmail-extra-headers)
7703 (gnus-summary-find-matching
7704 (cons 'extra 'To) recipient 'all nil nil
7707 1 "`To' isn't present in `nnmail-extra-headers'")
7711 (if (memq 'Cc nnmail-extra-headers)
7712 (gnus-summary-find-matching
7713 (cons 'extra 'Cc) recipient 'all nil nil
7716 1 "`Cc' isn't present in `nnmail-extra-headers'")
7721 ;; We need the numbers that are in both lists:
7723 (and (memq a to) a))
7727 (error "Found no matches for \"%s\"" recipient))
7728 (gnus-summary-limit articles))
7729 (gnus-summary-position-point))))
7731 (defun gnus-summary-limit-to-age (age &optional younger-p)
7732 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7733 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7734 articles that are younger than AGE days."
7736 (let ((younger current-prefix-arg)
7739 (while (not days-got)
7740 (setq days (if younger
7741 (read-string "Limit to articles younger than (in days, older when negative): ")
7743 "Limit to articles older than (in days, younger when negative): ")))
7744 (when (> (length days) 0)
7745 (setq days (read days)))
7750 (setq younger (not younger))
7751 (setq days (* days -1))))
7752 (message "Please enter a number.")
7754 (list days younger)))
7756 (let ((data gnus-newsgroup-data)
7757 (cutoff (days-to-time age))
7758 articles d date is-younger)
7759 (while (setq d (pop data))
7760 (when (and (vectorp (gnus-data-header d))
7761 (setq date (mail-header-date (gnus-data-header d))))
7762 (setq is-younger (time-less-p
7763 (time-since (condition-case ()
7770 (push (gnus-data-number d) articles))))
7771 (gnus-summary-limit (nreverse articles)))
7772 (gnus-summary-position-point)))
7774 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7775 "Limit the summary buffer to articles that match an 'extra' header."
7779 (gnus-completing-read-with-default
7780 (symbol-name (car gnus-extra-headers))
7781 (if current-prefix-arg
7782 "Exclude extra header:"
7783 "Limit extra header:")
7785 (cons (symbol-name x) x))
7790 (read-string (format "%s header %s (regexp): "
7791 (if current-prefix-arg "Exclude" "Limit to")
7793 current-prefix-arg)))
7794 (when (not (equal "" regexp))
7796 (let ((articles (gnus-summary-find-matching
7797 (cons 'extra header) regexp 'all nil nil
7800 (error "Found no matches for \"%s\"" regexp))
7801 (gnus-summary-limit articles))
7802 (gnus-summary-position-point))))
7804 (defun gnus-summary-limit-to-display-predicate ()
7805 "Limit the summary buffer to the predicated in the `display' group parameter."
7807 (unless gnus-newsgroup-display
7808 (error "There is no `display' group parameter"))
7810 (dolist (number gnus-newsgroup-articles)
7811 (when (funcall gnus-newsgroup-display)
7812 (push number articles)))
7813 (gnus-summary-limit articles))
7814 (gnus-summary-position-point))
7816 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7818 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7820 (defun gnus-summary-limit-to-unread (&optional all)
7821 "Limit the summary buffer to articles that are not marked as read.
7822 If ALL is non-nil, limit strictly to unread articles."
7825 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7826 (gnus-summary-limit-to-marks
7827 ;; Concat all the marks that say that an article is read and have
7829 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7830 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7831 gnus-low-score-mark gnus-expirable-mark
7832 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7833 gnus-duplicate-mark gnus-souped-mark)
7836 (defun gnus-summary-limit-to-replied (&optional unreplied)
7837 "Limit the summary buffer to replied articles.
7838 If UNREPLIED (the prefix), limit to unreplied articles."
7842 (gnus-set-difference gnus-newsgroup-articles
7843 gnus-newsgroup-replied))
7844 (gnus-summary-limit gnus-newsgroup-replied))
7845 (gnus-summary-position-point))
7847 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7848 (make-obsolete 'gnus-summary-delete-marked-with
7849 'gnus-summary-limit-exclude-marks)
7851 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7852 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7853 If REVERSE, limit the summary buffer to articles that are marked
7854 with MARKS. MARKS can either be a string of marks or a list of marks.
7855 Returns how many articles were removed."
7856 (interactive "sMarks: ")
7857 (gnus-summary-limit-to-marks marks t))
7859 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7860 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7861 If REVERSE (the prefix), limit the summary buffer to articles that are
7862 not marked with MARKS. MARKS can either be a string of marks or a
7864 Returns how many articles were removed."
7865 (interactive "sMarks: \nP")
7867 (let ((data gnus-newsgroup-data)
7868 (marks (if (listp marks) marks
7869 (append marks nil))) ; Transform to list.
7872 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7873 (memq (gnus-data-mark (car data)) marks))
7874 (push (gnus-data-number (car data)) articles))
7875 (setq data (cdr data)))
7876 (gnus-summary-limit articles))
7877 (gnus-summary-position-point)))
7879 (defun gnus-summary-limit-to-score (score)
7880 "Limit to articles with score at or above SCORE."
7881 (interactive "NLimit to articles with score of at least: ")
7882 (let ((data gnus-newsgroup-data)
7885 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7887 (push (gnus-data-number (car data)) articles))
7888 (setq data (cdr data)))
7890 (gnus-summary-limit articles)
7891 (gnus-summary-position-point))))
7893 (defun gnus-summary-limit-to-unseen ()
7894 "Limit to unseen articles."
7897 (gnus-summary-limit gnus-newsgroup-unseen)
7898 (gnus-summary-position-point)))
7900 (defun gnus-summary-limit-include-thread (id)
7901 "Display all the hidden articles that is in the thread with ID in it.
7902 When called interactively, ID is the Message-ID of the current
7904 (interactive (list (mail-header-id (gnus-summary-article-header))))
7905 (let ((articles (gnus-articles-in-thread
7906 (gnus-id-to-thread (gnus-root-id id)))))
7908 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7909 (gnus-summary-limit-include-matching-articles
7911 (regexp-quote (gnus-simplify-subject-re
7912 (mail-header-subject (gnus-id-to-header id)))))
7913 (gnus-summary-position-point))))
7915 (defun gnus-summary-limit-include-matching-articles (header regexp)
7916 "Display all the hidden articles that have HEADERs that match REGEXP."
7917 (interactive (list (read-string "Match on header: ")
7918 (read-string "Regexp: ")))
7919 (let ((articles (gnus-find-matching-articles header regexp)))
7921 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7922 (gnus-summary-position-point))))
7924 (defun gnus-summary-insert-dormant-articles ()
7925 "Insert all the dormant articles for this group into the current buffer."
7927 (let ((gnus-verbose (max 6 gnus-verbose)))
7928 (if (not gnus-newsgroup-dormant)
7929 (gnus-message 3 "No cached articles for this group")
7930 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7932 (defun gnus-summary-limit-include-dormant ()
7933 "Display all the hidden articles that are marked as dormant.
7934 Note that this command only works on a subset of the articles currently
7935 fetched for this group."
7937 (unless gnus-newsgroup-dormant
7938 (error "There are no dormant articles in this group"))
7940 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7941 (gnus-summary-position-point)))
7943 (defun gnus-summary-limit-exclude-dormant ()
7944 "Hide all dormant articles."
7947 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7948 (gnus-summary-position-point)))
7950 (defun gnus-summary-limit-exclude-childless-dormant ()
7951 "Hide all dormant articles that have no children."
7953 (let ((data (gnus-data-list t))
7954 articles d children)
7955 ;; Find all articles that are either not dormant or have
7957 (while (setq d (pop data))
7958 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7960 (gnus-article-children (gnus-data-number d)))
7963 (when (memq (car children) articles)
7968 (push (gnus-data-number d) articles)))
7971 (gnus-summary-limit articles)
7972 (gnus-summary-position-point))))
7974 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7975 "Mark all unread excluded articles as read.
7976 If ALL, mark even excluded ticked and dormants as read."
7978 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7979 (let ((articles (gnus-sorted-ndifference
7981 (mapcar (lambda (h) (mail-header-number h))
7982 gnus-newsgroup-headers)
7984 gnus-newsgroup-limit))
7986 (setq gnus-newsgroup-unreads
7987 (gnus-sorted-intersection gnus-newsgroup-unreads
7988 gnus-newsgroup-limit))
7990 (setq gnus-newsgroup-dormant nil
7991 gnus-newsgroup-marked nil
7992 gnus-newsgroup-reads
7994 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7995 gnus-newsgroup-reads))
7996 (while (setq article (pop articles))
7997 (unless (or (memq article gnus-newsgroup-dormant)
7998 (memq article gnus-newsgroup-marked))
7999 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8001 (defun gnus-summary-limit (articles &optional pop)
8003 ;; We pop the previous limit off the stack and use that.
8004 (setq articles (car gnus-newsgroup-limits)
8005 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8006 ;; We use the new limit, so we push the old limit on the stack.
8007 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8009 (setq gnus-newsgroup-limit articles)
8010 (let ((total (length gnus-newsgroup-data))
8011 (data (gnus-data-find-list (gnus-summary-article-number)))
8012 (gnus-summary-mark-below nil) ; Inhibit this.
8014 ;; This will do all the work of generating the new summary buffer
8015 ;; according to the new limit.
8016 (gnus-summary-prepare)
8017 ;; Hide any threads, possibly.
8018 (gnus-summary-maybe-hide-threads)
8019 ;; Try to return to the article you were at, or one in the
8022 ;; We try to find some article after the current one.
8024 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8027 (setq data (cdr data))))
8029 ;; If there is no data, that means that we were after the last
8030 ;; article. The same goes when we can't find any articles
8031 ;; after the current one.
8032 (goto-char (point-max))
8033 (gnus-summary-find-prev))
8034 (gnus-set-mode-line 'summary)
8035 ;; We return how many articles were removed from the summary
8036 ;; buffer as a result of the new limit.
8037 (- total (length gnus-newsgroup-data))))
8039 (defsubst gnus-invisible-cut-children (threads)
8042 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8047 (defsubst gnus-cut-thread (thread)
8048 "Go forwards in the thread until we find an article that we want to display."
8049 (when (or (eq gnus-fetch-old-headers 'some)
8050 (eq gnus-fetch-old-headers 'invisible)
8051 (numberp gnus-fetch-old-headers)
8052 (eq gnus-build-sparse-threads 'some)
8053 (eq gnus-build-sparse-threads 'more))
8054 ;; Deal with old-fetched headers and sparse threads.
8058 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8059 (gnus-summary-article-ancient-p
8060 (mail-header-number (car thread))))
8061 (if (or (<= (length (cdr thread)) 1)
8062 (eq gnus-fetch-old-headers 'invisible))
8063 (setq gnus-newsgroup-limit
8064 (delq (mail-header-number (car thread))
8065 gnus-newsgroup-limit)
8066 thread (cadr thread))
8067 (when (gnus-invisible-cut-children (cdr thread))
8068 (let ((th (cdr thread)))
8070 (if (memq (mail-header-number (caar th))
8071 gnus-newsgroup-limit)
8072 (setq thread (car th)
8074 (setq th (cdr th))))))))))
8077 (defun gnus-cut-threads (threads)
8078 "Cut off all uninteresting articles from the beginning of THREADS."
8079 (when (or (eq gnus-fetch-old-headers 'some)
8080 (eq gnus-fetch-old-headers 'invisible)
8081 (numberp gnus-fetch-old-headers)
8082 (eq gnus-build-sparse-threads 'some)
8083 (eq gnus-build-sparse-threads 'more))
8086 (setcar th (gnus-cut-thread (car th)))
8087 (setq th (cdr th)))))
8088 ;; Remove nixed out threads.
8091 (defun gnus-summary-initial-limit (&optional show-if-empty)
8092 "Figure out what the initial limit is supposed to be on group entry.
8093 This entails weeding out unwanted dormants, low-scored articles,
8094 fetch-old-headers verbiage, and so on."
8095 ;; Most groups have nothing to remove.
8096 (if (or gnus-inhibit-limiting
8097 (and (null gnus-newsgroup-dormant)
8098 (eq gnus-newsgroup-display 'gnus-not-ignore)
8099 (not (eq gnus-fetch-old-headers 'some))
8100 (not (numberp gnus-fetch-old-headers))
8101 (not (eq gnus-fetch-old-headers 'invisible))
8102 (null gnus-summary-expunge-below)
8103 (not (eq gnus-build-sparse-threads 'some))
8104 (not (eq gnus-build-sparse-threads 'more))
8105 (null gnus-thread-expunge-below)
8106 (not gnus-use-nocem)))
8108 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8109 (setq gnus-newsgroup-limit nil)
8112 (unless (car (symbol-value node))
8113 ;; These threads have no parents -- they are roots.
8114 (let ((nodes (cdr (symbol-value node)))
8117 (if (and gnus-thread-expunge-below
8118 (< (gnus-thread-total-score (car nodes))
8119 gnus-thread-expunge-below))
8120 (gnus-expunge-thread (pop nodes))
8121 (setq thread (pop nodes))
8122 (gnus-summary-limit-children thread))))))
8123 gnus-newsgroup-dependencies)
8124 ;; If this limitation resulted in an empty group, we might
8125 ;; pop the previous limit and use it instead.
8126 (when (and (not gnus-newsgroup-limit)
8128 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8129 gnus-newsgroup-limit))
8131 (defun gnus-summary-limit-children (thread)
8132 "Return 1 if this subthread is visible and 0 if it is not."
8133 ;; First we get the number of visible children to this thread. This
8134 ;; is done by recursing down the thread using this function, so this
8135 ;; will really go down to a leaf article first, before slowly
8136 ;; working its way up towards the root.
8138 (let* ((max-lisp-eval-depth 5000)
8141 (apply '+ (mapcar 'gnus-summary-limit-children
8144 (number (mail-header-number (car thread)))
8147 (not (memq number gnus-newsgroup-marked))
8149 ;; If this article is dormant and has absolutely no visible
8150 ;; children, then this article isn't visible.
8151 (and (memq number gnus-newsgroup-dormant)
8153 ;; If this is "fetch-old-headered" and there is no
8154 ;; visible children, then we don't want this article.
8155 (and (or (eq gnus-fetch-old-headers 'some)
8156 (numberp gnus-fetch-old-headers))
8157 (gnus-summary-article-ancient-p number)
8159 ;; If this is "fetch-old-headered" and `invisible', then
8160 ;; we don't want this article.
8161 (and (eq gnus-fetch-old-headers 'invisible)
8162 (gnus-summary-article-ancient-p number))
8163 ;; If this is a sparsely inserted article with no children,
8164 ;; we don't want it.
8165 (and (eq gnus-build-sparse-threads 'some)
8166 (gnus-summary-article-sparse-p number)
8168 ;; If we use expunging, and this article is really
8169 ;; low-scored, then we don't want this article.
8170 (when (and gnus-summary-expunge-below
8172 (or (cdr (assq number gnus-newsgroup-scored))
8173 gnus-summary-default-score))
8174 gnus-summary-expunge-below))
8175 ;; We increase the expunge-tally here, but that has
8176 ;; nothing to do with the limits, really.
8177 (incf gnus-newsgroup-expunged-tally)
8178 ;; We also mark as read here, if that's wanted.
8179 (when (and gnus-summary-mark-below
8180 (< score gnus-summary-mark-below))
8181 (setq gnus-newsgroup-unreads
8182 (delq number gnus-newsgroup-unreads))
8183 (if gnus-newsgroup-auto-expire
8184 (push number gnus-newsgroup-expirable)
8185 (push (cons number gnus-low-score-mark)
8186 gnus-newsgroup-reads)))
8188 ;; Do the `display' group parameter.
8189 (and gnus-newsgroup-display
8190 (not (funcall gnus-newsgroup-display)))
8191 ;; Check NoCeM things.
8192 (when (and gnus-use-nocem
8193 (gnus-nocem-unwanted-article-p
8194 (mail-header-id (car thread))))
8195 (setq gnus-newsgroup-unreads
8196 (delq number gnus-newsgroup-unreads))
8198 ;; Nope, invisible article.
8200 ;; Ok, this article is to be visible, so we add it to the limit
8202 (push number gnus-newsgroup-limit)
8205 (defun gnus-expunge-thread (thread)
8206 "Mark all articles in THREAD as read."
8207 (let* ((number (mail-header-number (car thread))))
8208 (incf gnus-newsgroup-expunged-tally)
8209 ;; We also mark as read here, if that's wanted.
8210 (setq gnus-newsgroup-unreads
8211 (delq number gnus-newsgroup-unreads))
8212 (if gnus-newsgroup-auto-expire
8213 (push number gnus-newsgroup-expirable)
8214 (push (cons number gnus-low-score-mark)
8215 gnus-newsgroup-reads)))
8216 ;; Go recursively through all subthreads.
8217 (mapcar 'gnus-expunge-thread (cdr thread)))
8219 ;; Summary article oriented commands
8221 (defun gnus-summary-refer-parent-article (n)
8222 "Refer parent article N times.
8223 If N is negative, go to ancestor -N instead.
8224 The difference between N and the number of articles fetched is returned."
8228 (when (not (natnump n))
8233 (setq header (gnus-summary-article-header))
8234 (if (and (eq (mail-header-number header)
8235 (cdr gnus-article-current))
8236 (equal gnus-newsgroup-name
8237 (car gnus-article-current)))
8238 ;; If we try to find the parent of the currently
8239 ;; displayed article, then we take a look at the actual
8240 ;; References header, since this is slightly more
8241 ;; reliable than the References field we got from the
8244 (set-buffer gnus-original-article-buffer)
8245 (nnheader-narrow-to-headers)
8246 (unless (setq ref (message-fetch-field "references"))
8247 (when (setq ref (message-fetch-field "in-reply-to"))
8248 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8251 ;; It's not the current article, so we take a bet on
8252 ;; the value we got from the server.
8253 (mail-header-references header)))
8255 (not (equal ref "")))
8256 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8257 (gnus-message 1 "Couldn't find parent"))
8258 (gnus-message 1 "No references in article %d"
8259 (gnus-summary-article-number))
8262 (gnus-summary-position-point)
8265 (defun gnus-summary-refer-references ()
8266 "Fetch all articles mentioned in the References header.
8267 Return the number of articles fetched."
8269 (let ((ref (mail-header-references (gnus-summary-article-header)))
8270 (current (gnus-summary-article-number))
8274 (error "No References in the current article")
8275 ;; For each Message-ID in the References header...
8276 (while (string-match "<[^>]*>" ref)
8278 ;; ... fetch that article.
8279 (gnus-summary-refer-article
8280 (prog1 (match-string 0 ref)
8281 (setq ref (substring ref (match-end 0))))))
8282 (gnus-summary-goto-subject current)
8283 (gnus-summary-position-point)
8286 (defun gnus-summary-refer-thread (&optional limit)
8287 "Fetch all articles in the current thread.
8288 If LIMIT (the numerical prefix), fetch that many old headers instead
8289 of what's specified by the `gnus-refer-thread-limit' variable."
8291 (let ((id (mail-header-id (gnus-summary-article-header)))
8292 (limit (if limit (prefix-numeric-value limit)
8293 gnus-refer-thread-limit)))
8294 (unless (eq gnus-fetch-old-headers 'invisible)
8295 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8296 ;; Retrieve the headers and read them in.
8297 (if (eq (if (numberp limit)
8298 (gnus-retrieve-headers
8300 (+ (mail-header-number
8301 (gnus-summary-article-header))
8303 gnus-newsgroup-end))
8304 gnus-newsgroup-name (* limit 2))
8305 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8307 (gnus-retrieve-headers (list gnus-newsgroup-end)
8308 gnus-newsgroup-name limit))
8310 (gnus-build-all-threads)
8311 (error "Can't fetch thread from back ends that don't support NOV"))
8312 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8313 (gnus-summary-limit-include-thread id)))
8315 (defun gnus-summary-refer-article (message-id)
8316 "Fetch an article specified by MESSAGE-ID."
8317 (interactive "sMessage-ID: ")
8318 (when (and (stringp message-id)
8319 (not (zerop (length message-id))))
8320 (setq message-id (gnus-replace-in-string message-id " " ""))
8321 ;; Construct the correct Message-ID if necessary.
8322 ;; Suggested by tale@pawl.rpi.edu.
8323 (unless (string-match "^<" message-id)
8324 (setq message-id (concat "<" message-id)))
8325 (unless (string-match ">$" message-id)
8326 (setq message-id (concat message-id ">")))
8327 ;; People often post MIDs from URLs, so unhex it:
8328 (unless (string-match "@" message-id)
8329 (setq message-id (gnus-url-unhex-string message-id)))
8330 (let* ((header (gnus-id-to-header message-id))
8332 (gnus-summary-article-sparse-p
8333 (mail-header-number header))
8334 (memq (mail-header-number header)
8335 gnus-newsgroup-limit)))
8338 ;; If the article is present in the buffer we just go to it.
8340 (or (not (gnus-summary-article-sparse-p
8341 (mail-header-number header)))
8344 (gnus-summary-goto-article
8345 (mail-header-number header) nil t)
8347 (gnus-summary-update-article (mail-header-number header)))))
8349 ;; We fetch the article.
8351 (dolist (gnus-override-method (gnus-refer-article-methods))
8352 (when (and (gnus-check-server gnus-override-method)
8353 ;; Fetch the header,
8354 (setq number (gnus-summary-insert-subject message-id)))
8355 ;; and display the article.
8356 (gnus-summary-select-article nil nil nil number)
8358 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8360 (defun gnus-refer-article-methods ()
8361 "Return a list of referable methods."
8363 ;; No method, so we default to current and native.
8364 ((null gnus-refer-article-method)
8365 (list gnus-current-select-method gnus-select-method))
8367 ((eq 'current gnus-refer-article-method)
8368 (list gnus-current-select-method))
8369 ;; List of select methods.
8370 ((not (and (symbolp (car gnus-refer-article-method))
8371 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8373 (dolist (method gnus-refer-article-method)
8374 (push (if (eq 'current method)
8375 gnus-current-select-method
8379 ;; One single select method.
8381 (list gnus-refer-article-method))))
8383 (defun gnus-summary-edit-parameters ()
8384 "Edit the group parameters of the current group."
8386 (gnus-group-edit-group gnus-newsgroup-name 'params))
8388 (defun gnus-summary-customize-parameters ()
8389 "Customize the group parameters of the current group."
8391 (gnus-group-customize gnus-newsgroup-name))
8393 (defun gnus-summary-enter-digest-group (&optional force)
8394 "Enter an nndoc group based on the current article.
8395 If FORCE, force a digest interpretation. If not, try
8396 to guess what the document format is."
8398 (let ((conf gnus-current-window-configuration))
8399 (save-window-excursion
8401 (let (gnus-article-prepare-hook
8402 gnus-display-mime-function
8404 (gnus-summary-select-article))))
8405 (setq gnus-current-window-configuration conf)
8406 (let* ((name (format "%s-%d"
8407 (gnus-group-prefixed-name
8408 gnus-newsgroup-name (list 'nndoc ""))
8409 (with-current-buffer gnus-summary-buffer
8410 gnus-current-article)))
8411 (ogroup gnus-newsgroup-name)
8412 (params (append (gnus-info-params (gnus-get-info ogroup))
8413 (list (cons 'to-group ogroup))
8414 (list (cons 'parent-group ogroup))
8415 (list (cons 'save-article-group ogroup))))
8416 (case-fold-search t)
8417 (buf (current-buffer))
8420 (set-buffer gnus-original-article-buffer)
8421 ;; Have the digest group inherit the main mail address of
8422 ;; the parent article.
8423 (when (setq to-address (or (gnus-fetch-field "reply-to")
8424 (gnus-fetch-field "from")))
8425 (setq params (append
8426 (list (cons 'to-address
8427 (funcall gnus-decode-encoded-word-function
8429 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8430 (insert-buffer-substring gnus-original-article-buffer)
8431 ;; Remove lines that may lead nndoc to misinterpret the
8434 (goto-char (point-min))
8435 (or (search-forward "\n\n" nil t) (point)))
8436 (goto-char (point-min))
8437 (delete-matching-lines "^Path:\\|^From ")
8440 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8441 (gnus-newsgroup-ephemeral-ignored-charsets
8442 gnus-newsgroup-ignored-charsets))
8443 (gnus-group-read-ephemeral-group
8444 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8446 ,(if force 'mbox 'guess)))
8448 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8450 ;; Make all postings to this group go to the parent group.
8451 (nconc (gnus-info-params (gnus-get-info name))
8453 ;; Couldn't select this doc group.
8454 (switch-to-buffer buf)
8455 (gnus-set-global-variables)
8456 (gnus-configure-windows 'summary)
8457 (gnus-message 3 "Article couldn't be entered?"))
8458 (kill-buffer dig)))))
8460 (defun gnus-summary-read-document (n)
8461 "Open a new group based on the current article(s).
8462 This will allow you to read digests and other similar
8463 documents as newsgroups.
8464 Obeys the standard process/prefix convention."
8466 (let* ((ogroup gnus-newsgroup-name)
8467 (params (append (gnus-info-params (gnus-get-info ogroup))
8468 (list (cons 'to-group ogroup))))
8469 group egroup groups vgroup)
8470 (dolist (article (gnus-summary-work-articles n))
8471 (setq group (format "%s-%d" gnus-newsgroup-name article))
8472 (gnus-summary-remove-process-mark article)
8473 (when (gnus-summary-display-article article)
8476 (insert-buffer-substring gnus-original-article-buffer)
8477 ;; Remove some headers that may lead nndoc to make
8479 (message-narrow-to-head)
8480 (goto-char (point-min))
8481 (delete-matching-lines "^Path:\\|^From ")
8484 (gnus-group-read-ephemeral-group
8485 group `(nndoc ,group (nndoc-address ,(current-buffer))
8486 (nndoc-article-type guess))
8489 ;; Make all postings to this group go to the parent group.
8490 (nconc (gnus-info-params (gnus-get-info egroup))
8492 (push egroup groups))
8493 ;; Couldn't select this doc group.
8494 (gnus-error 3 "Article couldn't be entered"))))))
8495 ;; Now we have selected all the documents.
8498 (error "None of the articles could be interpreted as documents"))
8499 ((gnus-group-read-ephemeral-group
8500 (setq vgroup (format
8501 "nnvirtual:%s-%s" gnus-newsgroup-name
8502 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8503 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8505 (cons (current-buffer) 'summary)))
8507 (error "Couldn't select virtual nndoc group")))))
8509 (defun gnus-summary-isearch-article (&optional regexp-p)
8510 "Do incremental search forward on the current article.
8511 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8513 (let* ((gnus-inhibit-treatment t)
8514 (old (gnus-summary-select-article)))
8515 (gnus-configure-windows 'article)
8516 (gnus-eval-in-buffer-window gnus-article-buffer
8520 (gnus-article-show-all-headers))
8521 (goto-char (point-min))
8522 (isearch-forward regexp-p)))))
8524 (defun gnus-summary-search-article-forward (regexp &optional backward)
8525 "Search for an article containing REGEXP forward.
8526 If BACKWARD, search backward instead."
8529 (format "Search article %s (regexp%s): "
8530 (if current-prefix-arg "backward" "forward")
8531 (if gnus-last-search-regexp
8532 (concat ", default " gnus-last-search-regexp)
8534 current-prefix-arg))
8535 (if (string-equal regexp "")
8536 (setq regexp (or gnus-last-search-regexp ""))
8537 (setq gnus-last-search-regexp regexp)
8538 (setq gnus-article-before-search gnus-current-article))
8539 ;; Intentionally set gnus-last-article.
8540 (setq gnus-last-article gnus-article-before-search)
8541 (let ((gnus-last-article gnus-last-article))
8542 (if (gnus-summary-search-article regexp backward)
8543 (gnus-summary-show-thread)
8544 (signal 'search-failed (list regexp)))))
8546 (defun gnus-summary-search-article-backward (regexp)
8547 "Search for an article containing REGEXP backward."
8550 (format "Search article backward (regexp%s): "
8551 (if gnus-last-search-regexp
8552 (concat ", default " gnus-last-search-regexp)
8554 (gnus-summary-search-article-forward regexp 'backward))
8557 (defmacro gnus-summary-search-article-position-point (regexp backward)
8558 "Dehighlight the last matched text and goto the beginning position."
8559 (` (if (and gnus-summary-search-article-matched-data
8560 (let ((text (caddr gnus-summary-search-article-matched-data))
8561 (inhibit-read-only t)
8564 (goto-char (car gnus-summary-search-article-matched-data))
8565 (cadr gnus-summary-search-article-matched-data))
8567 (string-match (, regexp) text)))
8568 (if (, backward) (beginning-of-line) (end-of-line))
8569 (goto-char (if (, backward) (point-max) (point-min))))))
8571 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8572 "Place point where X-Face image is displayed."
8573 (if (featurep 'xemacs)
8574 (` (let ((end (if (search-forward "\n\n" nil t)
8575 (goto-char (1- (point)))
8578 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8579 (unless (and (re-search-forward "^From:" end t)
8580 (setq extent (extent-at (point)))
8581 (extent-begin-glyph extent))
8582 (goto-char (, opoint)))))
8583 (` (let ((end (if (search-forward "\n\n" nil t)
8584 (goto-char (1- (point)))
8586 (start (or (search-backward "\n\n" nil t) (point-min))))
8588 (or (text-property-any start end 'x-face-image t);; x-face-e21
8589 (text-property-any start end 'x-face-mule-bitmap-image t)
8592 (defmacro gnus-summary-search-article-highlight-matched-text
8593 (backward treated x-face)
8594 "Highlight matched text in the function `gnus-summary-search-article'."
8595 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8596 (end (set-marker (make-marker) (match-end 0)))
8597 (inhibit-read-only t)
8601 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8603 (lambda (item) (setq items (delq item items)))
8604 '(gnus-treat-buttonize
8605 gnus-treat-fill-article
8606 gnus-treat-fill-long-lines
8607 gnus-treat-emphasize
8608 gnus-treat-highlight-headers
8609 gnus-treat-highlight-citation
8610 gnus-treat-highlight-signature
8611 gnus-treat-overstrike
8612 gnus-treat-display-x-face
8613 gnus-treat-buttonize-head
8614 gnus-treat-decode-article-as-default-mime-charset))
8615 (static-if (featurep 'xemacs)
8617 (cons '(x-face-mule-delete-x-face-field
8620 (gnus-treat-display-x-face
8621 (when (, x-face) gnus-treat-display-x-face)))
8622 (gnus-article-prepare-mime-display)))
8623 (goto-char (if (, backward) start end))
8625 (gnus-summary-search-article-highlight-goto-x-face (point)))
8626 (setq gnus-summary-search-article-matched-data
8627 (list start end (buffer-substring start end)))
8628 (unless (eq start end);; matched text has been deleted. :-<
8629 (put-text-property start end 'face
8630 (or (find-face 'isearch)
8631 'secondary-selection))))))
8634 (defun gnus-summary-search-article (regexp &optional backward)
8635 "Search for an article containing REGEXP.
8636 Optional argument BACKWARD means do search for backward.
8637 `gnus-select-article-hook' is not called during the search."
8638 ;; We have to require this here to make sure that the following
8639 ;; dynamic binding isn't shadowed by autoloading.
8640 (require 'gnus-async)
8642 (let ((gnus-select-article-hook nil) ;Disable hook.
8643 (gnus-article-prepare-hook nil)
8644 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8645 (gnus-use-article-prefetch nil)
8646 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8647 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8649 (gnus-keep-backlog nil)
8650 (gnus-break-pages nil)
8651 (gnus-summary-display-arrow nil)
8652 (gnus-updated-mode-lines nil)
8653 (gnus-auto-center-summary nil)
8654 (sum (current-buffer))
8657 (gnus-save-hidden-threads
8658 (static-if (featurep 'xemacs)
8659 (let ((gnus-inhibit-treatment t))
8660 (setq treated (eq 'old (gnus-summary-select-article)))
8662 (not (and (gnus-buffer-live-p gnus-article-buffer)
8663 (window-live-p (get-buffer-window
8664 gnus-article-buffer t)))))
8665 (gnus-summary-select-article nil t)
8666 (setq treated nil)))
8667 (let ((gnus-inhibit-treatment t)
8668 (x-face-mule-delete-x-face-field 'never))
8669 (setq treated (eq 'old (gnus-summary-select-article)))
8672 (and (gnus-buffer-live-p gnus-article-buffer)
8673 (window-live-p (get-buffer-window
8674 gnus-article-buffer t))
8675 (or (not (string-match "^\\^X-Face:" regexp))
8676 (with-current-buffer gnus-article-buffer
8677 gnus-summary-search-article-matched-data)))))
8678 (gnus-summary-select-article nil t)
8679 (setq treated nil))))
8680 (set-buffer gnus-article-buffer)
8684 (gnus-article-show-all-headers)
8685 (gnus-summary-search-article-position-point regexp backward))
8686 (goto-char (if backward (point-max) (point-min))))
8688 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8690 (re-search-backward regexp nil t)
8691 (re-search-forward regexp nil t))
8692 ;; We found the regexp.
8694 (gnus-summary-search-article-highlight-matched-text
8695 backward treated (string-match "^\\^X-Face:" regexp))
8698 (/ (- 2 (window-height
8699 (get-buffer-window gnus-article-buffer t)))
8702 (get-buffer-window (current-buffer))
8705 (setq point (point)))
8706 ;; We didn't find it, so we go to the next article.
8709 (while (eq found 'not)
8710 (if (not (if backward (gnus-summary-find-prev)
8711 (gnus-summary-find-next)))
8712 ;; No more articles.
8714 ;; Select the next article and adjust point.
8715 (unless (gnus-summary-article-sparse-p
8716 (gnus-summary-article-number))
8718 (let ((gnus-inhibit-treatment t))
8719 (gnus-summary-select-article))
8721 (set-buffer gnus-article-buffer)
8723 (goto-char (if backward (point-max) (point-min))))))))
8724 (gnus-message 7 ""))
8725 ;; Return whether we found the regexp.
8726 (when (eq found 'found)
8728 (gnus-summary-show-thread)
8729 (gnus-summary-goto-subject gnus-current-article)
8730 (gnus-summary-position-point)
8733 (defun gnus-find-matching-articles (header regexp)
8734 "Return a list of all articles that match REGEXP on HEADER.
8735 This search includes all articles in the current group that Gnus has
8736 fetched headers for, whether they are displayed or not."
8737 (let ((articles nil)
8738 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8739 (case-fold-search t))
8740 (dolist (header gnus-newsgroup-headers)
8741 (when (string-match regexp (funcall func header))
8742 (push (mail-header-number header) articles)))
8743 (nreverse articles)))
8745 (defun gnus-summary-find-matching (header regexp &optional backward unread
8746 not-case-fold not-matching)
8747 "Return a list of all articles that match REGEXP on HEADER.
8748 The search stars on the current article and goes forwards unless
8749 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8750 If UNREAD is non-nil, only unread articles will
8751 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8752 in the comparisons. If NOT-MATCHING, return a list of all articles that
8753 not match REGEXP on HEADER."
8754 (let ((case-fold-search (not not-case-fold))
8757 (if (eq (car header) 'extra)
8760 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8762 (error "%s is an invalid header" header))
8763 (unless (fboundp (intern (concat "mail-header-" header)))
8764 (error "%s is not a valid header" header))
8765 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8766 (dolist (d (if (eq backward 'all)
8768 (gnus-data-find-list
8769 (gnus-summary-article-number)
8770 (gnus-data-list backward))))
8771 (when (and (or (not unread) ; We want all articles...
8772 (gnus-data-unread-p d)) ; Or just unreads.
8773 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8777 (funcall func (gnus-data-header d))))
8778 (string-match regexp
8779 (funcall func (gnus-data-header d)))))
8780 (push (gnus-data-number d) articles))) ; Success!
8781 (nreverse articles)))
8783 (defun gnus-summary-execute-command (header regexp command &optional backward)
8784 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8785 If HEADER is an empty string (or nil), the match is done on the entire
8786 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8788 (list (let ((completion-ignore-case t))
8791 (mapcar (lambda (header) (list (format "%s" header)))
8793 '("Number" "Subject" "From" "Lines" "Date"
8794 "Message-ID" "Xref" "References" "Body")
8795 gnus-extra-headers))
8796 nil 'require-match))
8797 (read-string "Regexp: ")
8798 (read-key-sequence "Command: ")
8799 current-prefix-arg))
8800 (when (equal header "Body")
8802 ;; Hidden thread subtrees must be searched as well.
8803 (gnus-summary-show-all-threads)
8804 ;; We don't want to change current point nor window configuration.
8806 (save-window-excursion
8808 gnus-treat-strip-trailing-blank-lines
8809 gnus-treat-strip-leading-blank-lines
8810 gnus-treat-strip-multiple-blank-lines
8811 gnus-treat-hide-boring-headers
8812 gnus-treat-fold-newsgroups
8813 gnus-article-prepare-hook)
8814 (gnus-message 6 "Executing %s..." (key-description command))
8815 ;; We'd like to execute COMMAND interactively so as to give arguments.
8816 (gnus-execute header regexp
8817 `(call-interactively ',(key-binding command))
8819 (gnus-message 6 "Executing %s...done" (key-description command))))))
8821 (defun gnus-summary-beginning-of-article ()
8822 "Scroll the article back to the beginning."
8824 (gnus-summary-select-article)
8825 (gnus-configure-windows 'article)
8826 (gnus-eval-in-buffer-window gnus-article-buffer
8828 (goto-char (point-min))
8829 (when gnus-break-pages
8830 (gnus-narrow-to-page))))
8832 (defun gnus-summary-end-of-article ()
8833 "Scroll to the end of the article."
8835 (gnus-summary-select-article)
8836 (gnus-configure-windows 'article)
8837 (gnus-eval-in-buffer-window gnus-article-buffer
8839 (goto-char (point-max))
8841 (when gnus-break-pages
8842 (when (re-search-backward page-delimiter nil t)
8843 (narrow-to-region (match-end 0) (point-max)))
8844 (gnus-narrow-to-page))))
8846 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8847 "Truncate to LEN and quote all \"(\"'s in STRING."
8848 (gnus-replace-in-string (if (and len (> (length string) len))
8849 (substring string 0 len)
8853 (defun gnus-summary-print-article (&optional filename n)
8854 "Generate and print a PostScript image of the process-marked (mail) articles.
8856 If used interactively, print the current article if none are
8857 process-marked. With prefix arg, prompt the user for the name of the
8860 When used from Lisp, accept two optional args FILENAME and N. N means
8861 to print the next N articles. If N is negative, print the N previous
8862 articles. If N is nil and articles have been marked with the process
8863 mark, print these instead.
8865 If the optional first argument FILENAME is nil, send the image to the
8866 printer. If FILENAME is a string, save the PostScript image in a file with
8867 that name. If FILENAME is a number, prompt the user for the name of the file
8869 (interactive (list (ps-print-preprint current-prefix-arg)))
8870 (dolist (article (gnus-summary-work-articles n))
8871 (gnus-summary-select-article nil nil 'pseudo article)
8872 (gnus-eval-in-buffer-window gnus-article-buffer
8873 (gnus-print-buffer))
8874 (gnus-summary-remove-process-mark article))
8875 (ps-despool filename))
8877 (defun gnus-print-buffer ()
8878 (let ((buffer (generate-new-buffer " *print*")))
8881 (copy-to-buffer buffer (point-min) (point-max))
8883 (gnus-remove-text-with-property 'gnus-decoration)
8884 (when (gnus-visual-p 'article-highlight 'highlight)
8885 ;; Copy-to-buffer doesn't copy overlay. So redo
8887 (let ((gnus-article-buffer buffer))
8888 (gnus-article-highlight-citation t)
8889 (gnus-article-highlight-signature)
8890 (gnus-article-emphasize)
8891 (gnus-article-delete-invisible-text)))
8892 (let ((ps-left-header
8895 (gnus-summary-print-truncate-and-quote
8896 (mail-header-subject gnus-current-headers)
8899 (gnus-summary-print-truncate-and-quote
8900 (mail-header-from gnus-current-headers)
8904 "/pagenumberstring load"
8906 (mail-header-date gnus-current-headers) ")"))))
8907 (gnus-run-hooks 'gnus-ps-print-hook)
8910 (ps-spool-buffer-with-faces)
8911 (ps-spool-buffer)))))
8912 (kill-buffer buffer))))
8914 (defun gnus-summary-show-article (&optional arg)
8915 "Force redisplaying of the current article.
8916 If ARG (the prefix) is a number, show the article with the charset
8917 defined in `gnus-summary-show-article-charset-alist', or the charset
8919 If ARG (the prefix) is non-nil and not a number, show the raw article
8920 without any article massaging functions being run. Normally, the key
8921 strokes are `C-u g'."
8925 (gnus-summary-show-article t)
8926 (let* ((gnus-newsgroup-charset
8927 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8928 (mm-read-coding-system
8929 "View as charset: " ;; actually it is coding system.
8930 (with-current-buffer gnus-article-buffer
8931 (mm-detect-coding-region (point) (point-max))))))
8932 (default-mime-charset gnus-newsgroup-charset)
8933 (gnus-newsgroup-ignored-charsets 'gnus-all))
8934 (gnus-summary-select-article nil 'force)
8935 (let ((deps gnus-newsgroup-dependencies)
8938 (set-buffer gnus-original-article-buffer)
8940 (message-narrow-to-head)
8941 (setq head (buffer-string))
8942 (goto-char (point-min))
8943 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8944 (goto-char (point-max))
8946 (setq lines (1- (count-lines (point) (point-max))))))
8948 (insert (format "211 %d Article retrieved.\n"
8949 (cdr gnus-article-current)))
8951 (if lines (insert (format "Lines: %d\n" lines)))
8953 (let ((nntp-server-buffer (current-buffer)))
8954 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8955 (gnus-data-set-header
8956 (gnus-data-find (cdr gnus-article-current))
8958 (gnus-summary-update-article-line
8959 (cdr gnus-article-current) header)
8960 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8961 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8963 ;; Select the article the normal way.
8964 (gnus-summary-select-article nil 'force))
8966 ;; We have to require this here to make sure that the following
8967 ;; dynamic binding isn't shadowed by autoloading.
8968 (require 'gnus-async)
8970 ;; Bind the article treatment functions to nil.
8971 (let ((gnus-have-all-headers t)
8972 gnus-article-prepare-hook
8973 gnus-article-decode-hook
8976 (gnus-inhibit-treatment t))
8977 (gnus-summary-select-article nil 'force))))
8978 (gnus-summary-goto-subject gnus-current-article)
8979 (gnus-summary-position-point))
8981 (defun gnus-summary-show-raw-article ()
8982 "Show the raw article without any article massaging functions being run."
8984 (gnus-summary-show-article t))
8986 (defun gnus-summary-verbose-headers (&optional arg)
8987 "Toggle permanent full header display.
8988 If ARG is a positive number, turn header display on.
8989 If ARG is a negative number, turn header display off."
8991 (setq gnus-show-all-headers
8992 (cond ((or (not (numberp arg))
8994 (not gnus-show-all-headers))
8997 (gnus-summary-show-article))
8999 (defun gnus-summary-toggle-header (&optional arg)
9000 "Show the headers if they are hidden, or hide them if they are shown.
9001 If ARG is a positive number, show the entire header.
9002 If ARG is a negative number, hide the unwanted header lines."
9004 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9005 (get-buffer-window gnus-article-buffer t))))
9006 (with-current-buffer gnus-article-buffer
9008 (article-narrow-to-head)
9009 (let* ((buffer-read-only nil)
9010 (inhibit-point-motion-hooks t)
9011 (hidden (if (numberp arg)
9013 (or (not (looking-at "[^ \t\n]+:"))
9014 (gnus-article-hidden-text-p 'headers))))
9016 (delete-region (point-min) (point-max))
9017 (with-current-buffer gnus-original-article-buffer
9018 (goto-char (setq s (point-min)))
9019 (setq e (if (search-forward "\n\n" nil t)
9022 (insert-buffer-substring gnus-original-article-buffer s e)
9023 ;; In T-gnus, gnus-article-decode-hook doesn't contain
9024 ;; article-decode-encoded-words by default.
9025 (article-decode-encoded-words)
9026 (run-hooks 'gnus-article-decode-hook)
9028 (let ((gnus-treat-hide-headers nil)
9029 (gnus-treat-hide-boring-headers nil))
9030 (gnus-delete-wash-type 'headers)
9031 (gnus-treat-article 'head))
9032 (gnus-treat-article 'head))
9035 (set-window-start window (goto-char (point-min))))
9036 (if gnus-break-pages
9037 (gnus-narrow-to-page)
9038 (when (gnus-visual-p 'page-marker)
9039 (let ((buffer-read-only nil))
9040 (gnus-remove-text-with-property 'gnus-prev)
9041 (gnus-remove-text-with-property 'gnus-next))))
9042 (gnus-set-mode-line 'article)))))
9044 (defun gnus-summary-show-all-headers ()
9045 "Make all header lines visible."
9047 (gnus-summary-toggle-header 1))
9049 (defun gnus-summary-toggle-mime (&optional arg)
9050 "Toggle MIME processing.
9051 If ARG is a positive number, turn MIME processing on."
9053 (setq gnus-show-mime
9055 (not gnus-show-mime)
9056 (> (prefix-numeric-value arg) 0)))
9057 (gnus-summary-select-article t 'force))
9059 (defun gnus-summary-caesar-message (&optional arg)
9060 "Caesar rotate the current article by 13.
9061 The numerical prefix specifies how many places to rotate each letter
9064 (gnus-summary-select-article)
9065 (let ((mail-header-separator ""))
9066 (gnus-eval-in-buffer-window gnus-article-buffer
9069 (let ((start (window-start))
9071 (message-caesar-buffer-body arg)
9072 (set-window-start (get-buffer-window (current-buffer)) start))))))
9074 (autoload 'unmorse-region "morse"
9075 "Convert morse coded text in region to ordinary ASCII text."
9078 (defun gnus-summary-morse-message (&optional arg)
9079 "Morse decode the current article."
9081 (gnus-summary-select-article)
9082 (let ((mail-header-separator ""))
9083 (gnus-eval-in-buffer-window gnus-article-buffer
9087 (let ((pos (window-start))
9089 (goto-char (point-min))
9090 (when (message-goto-body)
9091 (gnus-narrow-to-body))
9092 (goto-char (point-min))
9093 (while (search-forward "·" (point-max) t)
9094 (replace-match "."))
9095 (unmorse-region (point-min) (point-max))
9097 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9099 (defun gnus-summary-stop-page-breaking ()
9100 "Stop page breaking in the current article."
9102 (gnus-summary-select-article)
9103 (gnus-eval-in-buffer-window gnus-article-buffer
9105 (when (gnus-visual-p 'page-marker)
9106 (let ((buffer-read-only nil))
9107 (gnus-remove-text-with-property 'gnus-prev)
9108 (gnus-remove-text-with-property 'gnus-next))
9109 (setq gnus-page-broken nil))))
9111 (defun gnus-summary-move-article (&optional n to-newsgroup
9112 select-method action)
9113 "Move the current article to a different newsgroup.
9114 If N is a positive number, move the N next articles.
9115 If N is a negative number, move the N previous articles.
9116 If N is nil and any articles have been marked with the process mark,
9117 move those articles instead.
9118 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9119 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9120 re-spool using this method.
9122 When called interactively with TO-NEWSGROUP being nil, the value of
9123 the variable `gnus-move-split-methods' is used for finding a default
9124 for the target newsgroup.
9126 For this function to work, both the current newsgroup and the
9127 newsgroup that you want to move to have to support the `request-move'
9128 and `request-accept' functions.
9130 ACTION can be either `move' (the default), `crosspost' or `copy'."
9133 (setq action 'move))
9134 ;; Check whether the source group supports the required functions.
9135 (cond ((and (eq action 'move)
9136 (not (gnus-check-backend-function
9137 'request-move-article gnus-newsgroup-name)))
9138 (error "The current group does not support article moving"))
9139 ((and (eq action 'crosspost)
9140 (not (gnus-check-backend-function
9141 'request-replace-article gnus-newsgroup-name)))
9142 (error "The current group does not support article editing")))
9143 (let ((articles (gnus-summary-work-articles n))
9144 (prefix (if (gnus-check-backend-function
9145 'request-move-article gnus-newsgroup-name)
9146 (funcall gnus-move-group-prefix-function
9147 gnus-newsgroup-name)
9149 (names '((move "Move" "Moving")
9150 (copy "Copy" "Copying")
9151 (crosspost "Crosspost" "Crossposting")))
9152 (copy-buf (save-excursion
9153 (nnheader-set-temp-buffer " *copy article*")))
9154 art-group to-method new-xref article to-groups)
9155 (unless (assq action names)
9156 (error "Unknown action %s" action))
9157 ;; Read the newsgroup name.
9158 (when (and (not to-newsgroup)
9159 (not select-method))
9160 (if (and gnus-move-split-methods
9162 (and (memq gnus-current-article articles)
9163 (gnus-buffer-live-p gnus-original-article-buffer))))
9164 ;; When `gnus-move-split-methods' is non-nil, we have to
9165 ;; select an article to give `gnus-read-move-group-name' an
9166 ;; opportunity to suggest an appropriate default. However,
9167 ;; we needn't render or mark the article.
9168 (let ((gnus-display-mime-function nil)
9169 (gnus-article-prepare-hook nil)
9170 (gnus-mark-article-hook nil))
9171 (gnus-summary-select-article nil nil nil (car articles))))
9173 (gnus-read-move-group-name
9174 (cadr (assq action names))
9175 (symbol-value (intern (format "gnus-current-%s-group" action)))
9177 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9178 (setq to-method (or select-method
9179 (gnus-server-to-method
9180 (gnus-group-method to-newsgroup))))
9181 ;; Check the method we are to move this article to...
9182 (unless (gnus-check-backend-function
9183 'request-accept-article (car to-method))
9184 (error "%s does not support article copying" (car to-method)))
9185 (unless (gnus-check-server to-method)
9186 (error "Can't open server %s" (car to-method)))
9187 (gnus-message 6 "%s to %s: %s..."
9188 (caddr (assq action names))
9189 (or (car select-method) to-newsgroup) articles)
9191 (setq article (pop articles))
9195 ;; Move the article.
9197 ;; Remove this article from future suppression.
9198 (gnus-dup-unsuppress-article article)
9199 (gnus-request-move-article
9200 article ; Article to move
9201 gnus-newsgroup-name ; From newsgroup
9202 (nth 1 (gnus-find-method-for-group
9203 gnus-newsgroup-name)) ; Server
9204 (list 'gnus-request-accept-article
9205 to-newsgroup (list 'quote select-method)
9206 (not articles) t) ; Accept form
9207 (not articles))) ; Only save nov last time
9208 ;; Copy the article.
9211 (set-buffer copy-buf)
9212 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9214 (nnheader-narrow-to-headers)
9215 (dolist (hdr gnus-copy-article-ignored-headers)
9216 (message-remove-header hdr t)))
9217 (gnus-request-accept-article
9218 to-newsgroup select-method (not articles) t))))
9219 ;; Crosspost the article.
9220 ((eq action 'crosspost)
9221 (let ((xref (message-tokenize-header
9222 (mail-header-xref (gnus-summary-article-header article))
9224 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9225 ":" (number-to-string article)))
9227 (setq xref (list (system-name))))
9230 (mapconcat 'identity
9231 (delete "Xref:" (delete new-xref xref))
9235 (set-buffer copy-buf)
9236 ;; First put the article in the destination group.
9237 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9238 (when (consp (setq art-group
9239 (gnus-request-accept-article
9240 to-newsgroup select-method (not articles))))
9241 (setq new-xref (concat new-xref " " (car art-group)
9243 (number-to-string (cdr art-group))))
9244 ;; Now we have the new Xrefs header, so we insert
9245 ;; it and replace the new article.
9246 (nnheader-replace-header "Xref" new-xref)
9247 (gnus-request-replace-article
9248 (cdr art-group) to-newsgroup (current-buffer))
9252 (gnus-message 1 "Couldn't %s article %s: %s"
9253 (cadr (assq action names)) article
9254 (nnheader-get-report (car to-method))))
9255 ((eq art-group 'junk)
9256 (when (eq action 'move)
9257 (gnus-summary-mark-article article gnus-canceled-mark)
9258 (gnus-message 4 "Deleted article %s" article)
9259 ;; run the delete hook
9260 (run-hook-with-args 'gnus-summary-article-delete-hook
9263 (assoc article (gnus-data-list nil)))
9264 gnus-newsgroup-name nil
9267 (let* ((pto-group (gnus-group-prefixed-name
9268 (car art-group) to-method))
9269 (info (gnus-get-info pto-group))
9270 (to-group (gnus-info-group info))
9272 ;; Update the group that has been moved to.
9274 (memq action '(move copy)))
9275 (unless (member to-group to-groups)
9276 (push to-group to-groups))
9278 (unless (memq article gnus-newsgroup-unreads)
9279 (push 'read to-marks)
9281 info (gnus-add-to-range (gnus-info-read info)
9282 (list (cdr art-group)))))
9284 ;; See whether the article is to be put in the cache.
9285 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9286 gnus-article-mark-lists
9287 (delete '(expirable . expire)
9288 (copy-sequence gnus-article-mark-lists))))
9289 (to-article (cdr art-group)))
9291 ;; Enter the article into the cache in the new group,
9292 ;; if that is required.
9293 (when gnus-use-cache
9294 (gnus-cache-possibly-enter-article
9296 (let ((header (copy-sequence
9297 (gnus-summary-article-header article))))
9298 (mail-header-set-number header to-article)
9300 (memq article gnus-newsgroup-marked)
9301 (memq article gnus-newsgroup-dormant)
9302 (memq article gnus-newsgroup-unreads)))
9304 (when gnus-preserve-marks
9305 ;; Copy any marks over to the new group.
9306 (when (and (equal to-group gnus-newsgroup-name)
9307 (not (memq article gnus-newsgroup-unreads)))
9308 ;; Mark this article as read in this group.
9309 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9310 (setcdr (gnus-active to-group) to-article)
9311 (setcdr gnus-newsgroup-active to-article))
9314 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9315 (when (memq article (symbol-value
9316 (intern (format "gnus-newsgroup-%s"
9318 (push (cdar marks) to-marks)
9319 ;; If the other group is the same as this group,
9320 ;; then we have to add the mark to the list.
9321 (when (equal to-group gnus-newsgroup-name)
9322 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9325 (intern (format "gnus-newsgroup-%s"
9327 ;; Copy the marks to other group.
9328 (gnus-add-marked-articles
9329 to-group (cdar marks) (list to-article) info)))
9330 (setq marks (cdr marks)))
9332 (gnus-request-set-mark
9333 to-group (list (list (list to-article) 'add to-marks))))
9336 (concat "(gnus-group-set-info '"
9337 (gnus-prin1-to-string (gnus-get-info to-group))
9340 ;; Update the Xref header in this article to point to
9341 ;; the new crossposted article we have just created.
9342 (when (eq action 'crosspost)
9344 (set-buffer copy-buf)
9345 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9346 (nnheader-replace-header "Xref" new-xref)
9347 (gnus-request-replace-article
9348 article gnus-newsgroup-name (current-buffer))))
9350 ;; run the move/copy/crosspost/respool hook
9351 (run-hook-with-args 'gnus-summary-article-move-hook
9354 (assoc article (gnus-data-list nil)))
9359 ;;;!!!Why is this necessary?
9360 (set-buffer gnus-summary-buffer)
9362 (gnus-summary-goto-subject article)
9363 (when (eq action 'move)
9364 (gnus-summary-mark-article article gnus-canceled-mark))))
9365 (gnus-summary-remove-process-mark article))
9366 ;; Re-activate all groups that have been moved to.
9368 (set-buffer gnus-group-buffer)
9369 (let ((gnus-group-marked to-groups))
9370 (gnus-group-get-new-news-this-group nil t)))
9372 (gnus-kill-buffer copy-buf)
9373 (gnus-summary-position-point)
9374 (gnus-set-mode-line 'summary)))
9376 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9377 "Copy the current article to some other group.
9378 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9379 When called interactively, if TO-NEWSGROUP is nil, use the value of
9380 the variable `gnus-move-split-methods' for finding a default target
9382 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9383 re-spool using this method."
9385 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9387 (defun gnus-summary-crosspost-article (&optional n)
9388 "Crosspost the current article to some other group."
9390 (gnus-summary-move-article n nil nil 'crosspost))
9392 (defcustom gnus-summary-respool-default-method nil
9393 "Default method type for respooling an article.
9394 If nil, use to the current newsgroup method."
9396 :group 'gnus-summary-mail)
9398 (defcustom gnus-summary-display-while-building nil
9399 "If non-nil, show and update the summary buffer as it's being built.
9400 If the value is t, update the buffer after every line is inserted. If
9401 the value is an integer (N), update the display every N lines."
9404 :type '(choice (const :tag "off" nil)
9406 (const :tag "frequently" t)))
9408 (defun gnus-summary-respool-article (&optional n method)
9409 "Respool the current article.
9410 The article will be squeezed through the mail spooling process again,
9411 which means that it will be put in some mail newsgroup or other
9412 depending on `nnmail-split-methods'.
9413 If N is a positive number, respool the N next articles.
9414 If N is a negative number, respool the N previous articles.
9415 If N is nil and any articles have been marked with the process mark,
9416 respool those articles instead.
9418 Respooling can be done both from mail groups and \"real\" newsgroups.
9419 In the former case, the articles in question will be moved from the
9420 current group into whatever groups they are destined to. In the
9421 latter case, they will be copied into the relevant groups."
9423 (list current-prefix-arg
9424 (let* ((methods (gnus-methods-using 'respool))
9426 (symbol-name (or gnus-summary-respool-default-method
9427 (car (gnus-find-method-for-group
9428 gnus-newsgroup-name)))))
9430 (gnus-completing-read-with-default
9431 methname "What backend do you want to use when respooling?"
9432 methods nil t nil 'gnus-mail-method-history))
9435 ((zerop (length (setq ms (gnus-servers-using-backend
9437 (list (intern method) ""))
9441 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9442 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9445 (error "No method given for respooling"))
9446 (if (assoc (symbol-name
9447 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9448 (gnus-methods-using 'respool))
9449 (gnus-summary-move-article n nil method)
9450 (gnus-summary-copy-article n nil method)))
9452 (defun gnus-summary-import-article (file &optional edit)
9453 "Import an arbitrary file into a mail newsgroup."
9454 (interactive "fImport file: \nP")
9455 (let ((group gnus-newsgroup-name)
9456 (now (current-time))
9457 atts lines group-art)
9458 (unless (gnus-check-backend-function 'request-accept-article group)
9459 (error "%s does not support article importing" group))
9460 (or (file-readable-p file)
9461 (not (file-regular-p file))
9462 (error "Can't read %s" file))
9464 (set-buffer (gnus-get-buffer-create " *import file*"))
9466 (nnheader-insert-file-contents file)
9467 (goto-char (point-min))
9468 (if (nnheader-article-p)
9470 (goto-char (point-min))
9471 (search-forward "\n\n" nil t)
9472 (narrow-to-region (point-min) (1- (point)))
9473 (goto-char (point-min))
9474 (unless (re-search-forward "^date:" nil t)
9475 (goto-char (point-max))
9476 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9477 ;; This doesn't look like an article, so we fudge some headers.
9478 (setq atts (file-attributes file)
9479 lines (count-lines (point-min) (point-max)))
9480 (insert "From: " (read-string "From: ") "\n"
9481 "Subject: " (read-string "Subject: ") "\n"
9482 "Date: " (message-make-date (nth 5 atts)) "\n"
9483 "Message-ID: " (message-make-message-id) "\n"
9484 "Lines: " (int-to-string lines) "\n"
9485 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9486 (setq group-art (gnus-request-accept-article group nil t))
9487 (kill-buffer (current-buffer)))
9488 (setq gnus-newsgroup-active (gnus-activate-group group))
9490 (gnus-summary-goto-article (cdr group-art) nil t)
9492 (gnus-summary-edit-article))))
9494 (defun gnus-summary-create-article ()
9495 "Create an article in a mail newsgroup."
9497 (let ((group gnus-newsgroup-name)
9498 (now (current-time))
9500 (unless (gnus-check-backend-function 'request-accept-article group)
9501 (error "%s does not support article importing" group))
9503 (set-buffer (gnus-get-buffer-create " *import file*"))
9505 (goto-char (point-min))
9506 ;; This doesn't look like an article, so we fudge some headers.
9507 (insert "From: " (read-string "From: ") "\n"
9508 "Subject: " (read-string "Subject: ") "\n"
9509 "Date: " (message-make-date now) "\n"
9510 "Message-ID: " (message-make-message-id) "\n")
9511 (setq group-art (gnus-request-accept-article group nil t))
9512 (kill-buffer (current-buffer)))
9513 (setq gnus-newsgroup-active (gnus-activate-group group))
9515 (gnus-summary-goto-article (cdr group-art) nil t)
9516 (gnus-summary-edit-article)))
9518 (defun gnus-summary-article-posted-p ()
9519 "Say whether the current (mail) article is available from news as well.
9520 This will be the case if the article has both been mailed and posted."
9522 (let ((id (mail-header-references (gnus-summary-article-header)))
9523 (gnus-override-method (car (gnus-refer-article-methods))))
9524 (if (gnus-request-head id "")
9525 (gnus-message 2 "The current message was found on %s"
9526 gnus-override-method)
9527 (gnus-message 2 "The current message couldn't be found on %s"
9528 gnus-override-method)
9531 (defun gnus-summary-expire-articles (&optional now)
9532 "Expire all articles that are marked as expirable in the current group."
9534 (when (and (not gnus-group-is-exiting-without-update-p)
9535 (gnus-check-backend-function
9536 'request-expire-articles gnus-newsgroup-name))
9537 ;; This backend supports expiry.
9538 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9539 (expirable (if total
9541 ;; We need to update the info for
9542 ;; this group for `gnus-list-of-read-articles'
9543 ;; to give us the right answer.
9544 (gnus-run-hooks 'gnus-exit-group-hook)
9545 (gnus-summary-update-info)
9546 (gnus-list-of-read-articles gnus-newsgroup-name))
9547 (setq gnus-newsgroup-expirable
9548 (sort gnus-newsgroup-expirable '<))))
9549 (expiry-wait (if now 'immediate
9550 (gnus-group-find-parameter
9551 gnus-newsgroup-name 'expiry-wait)))
9552 (nnmail-expiry-target
9553 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9554 nnmail-expiry-target))
9557 ;; There are expirable articles in this group, so we run them
9558 ;; through the expiry process.
9559 (gnus-message 6 "Expiring articles...")
9560 (unless (gnus-check-group gnus-newsgroup-name)
9561 (error "Can't open server for %s" gnus-newsgroup-name))
9562 ;; The list of articles that weren't expired is returned.
9565 (let ((nnmail-expiry-wait-function nil)
9566 (nnmail-expiry-wait expiry-wait))
9567 (setq es (gnus-request-expire-articles
9568 expirable gnus-newsgroup-name)))
9569 (setq es (gnus-request-expire-articles
9570 expirable gnus-newsgroup-name)))
9572 (setq gnus-newsgroup-expirable es))
9573 ;; We go through the old list of expirable, and mark all
9574 ;; really expired articles as nonexistent.
9575 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9576 (let ((gnus-use-cache nil))
9577 (dolist (article expirable)
9578 (when (and (not (memq article es))
9579 (gnus-data-find article))
9580 (gnus-summary-mark-article article gnus-canceled-mark)
9581 (run-hook-with-args 'gnus-summary-article-expire-hook
9584 (assoc article (gnus-data-list nil)))
9588 (gnus-message 6 "Expiring articles...done")))))
9590 (defun gnus-summary-expire-articles-now ()
9591 "Expunge all expirable articles in the current group.
9592 This means that *all* articles that are marked as expirable will be
9593 deleted forever, right now."
9595 (or gnus-expert-user
9597 "Are you really, really, really sure you want to delete all these messages? ")
9599 (gnus-summary-expire-articles t))
9601 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9602 (defun gnus-summary-delete-article (&optional n)
9603 "Delete the N next (mail) articles.
9604 This command actually deletes articles. This is not a marking
9605 command. The article will disappear forever from your life, never to
9608 If N is negative, delete backwards.
9609 If N is nil and articles have been marked with the process mark,
9610 delete these instead.
9612 If `gnus-novice-user' is non-nil you will be asked for
9613 confirmation before the articles are deleted."
9615 (unless (gnus-check-backend-function 'request-expire-articles
9616 gnus-newsgroup-name)
9617 (error "The current newsgroup does not support article deletion"))
9618 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9619 (error "Couldn't open server"))
9620 ;; Compute the list of articles to delete.
9621 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9622 (nnmail-expiry-target 'delete)
9624 (if (and gnus-novice-user
9625 (not (gnus-yes-or-no-p
9626 (format "Do you really want to delete %s forever? "
9627 (if (> (length articles) 1)
9628 (format "these %s articles" (length articles))
9631 ;; Delete the articles.
9632 (setq not-deleted (gnus-request-expire-articles
9633 articles gnus-newsgroup-name 'force))
9635 (gnus-summary-remove-process-mark (car articles))
9636 ;; The backend might not have been able to delete the article
9638 (unless (memq (car articles) not-deleted)
9639 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9640 (let* ((article (car articles))
9641 (ghead (gnus-data-header
9642 (assoc article (gnus-data-list nil)))))
9643 (run-hook-with-args 'gnus-summary-article-delete-hook
9644 'delete ghead gnus-newsgroup-name nil
9646 (setq articles (cdr articles)))
9648 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9649 (gnus-summary-position-point)
9650 (gnus-set-mode-line 'summary)
9653 (defun gnus-summary-edit-article (&optional force)
9654 "Edit the current article.
9655 This will have permanent effect only in mail groups.
9656 If FORCE is non-nil, allow editing of articles even in read-only
9660 (set-buffer gnus-summary-buffer)
9661 (let ((mail-parse-charset gnus-newsgroup-charset)
9662 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9663 (gnus-set-global-variables)
9664 (when (and (not force)
9665 (gnus-group-read-only-p))
9666 (error "The current newsgroup does not support article editing"))
9667 (gnus-summary-show-article t)
9668 (gnus-article-edit-article
9670 `(lambda (no-highlight)
9671 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9672 (message-options message-options)
9673 (message-options-set-recipient)
9674 (mail-parse-ignored-charsets
9675 ',gnus-newsgroup-ignored-charsets))
9676 (gnus-summary-edit-article-done
9677 ,(or (mail-header-references gnus-current-headers) "")
9678 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9680 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9682 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9684 "Make edits to the current article permanent."
9687 ;; The buffer restriction contains the entire article if it exists.
9688 (when (article-goto-body)
9689 (let ((lines (count-lines (point) (point-max)))
9690 (length (- (point-max) (point)))
9691 (case-fold-search t)
9692 (body (copy-marker (point))))
9693 (goto-char (point-min))
9694 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9695 (delete-region (match-beginning 1) (match-end 1))
9696 (insert (number-to-string length)))
9697 (goto-char (point-min))
9698 (when (re-search-forward
9699 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9700 (delete-region (match-beginning 1) (match-end 1))
9701 (insert (number-to-string length)))
9702 (goto-char (point-min))
9703 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9704 (delete-region (match-beginning 1) (match-end 1))
9705 (insert (number-to-string lines))))))
9706 ;; Replace the article.
9707 (let ((buf (current-buffer)))
9709 (insert-buffer-substring buf)
9711 (if (and (not read-only)
9712 (not (gnus-request-replace-article
9713 (cdr gnus-article-current) (car gnus-article-current)
9714 (current-buffer) t)))
9715 (error "Couldn't replace article")
9716 ;; Update the summary buffer.
9718 (equal (message-tokenize-header references " ")
9719 (message-tokenize-header
9720 (or (message-fetch-field "references") "") " ")))
9721 ;; We only have to update this line.
9724 (message-narrow-to-head)
9725 (let ((head (buffer-string))
9728 (insert (format "211 %d Article retrieved.\n"
9729 (cdr gnus-article-current)))
9732 (let ((nntp-server-buffer (current-buffer)))
9733 (setq header (car (gnus-get-newsgroup-headers
9736 (set-buffer gnus-summary-buffer)
9737 (gnus-data-set-header
9738 (gnus-data-find (cdr gnus-article-current))
9740 (gnus-summary-update-article-line
9741 (cdr gnus-article-current) header)
9742 (if (gnus-summary-goto-subject
9743 (cdr gnus-article-current) nil t)
9744 (gnus-summary-update-secondary-mark
9745 (cdr gnus-article-current))))))))
9747 (set-buffer (or buffer gnus-summary-buffer))
9748 (gnus-summary-update-article (cdr gnus-article-current))
9749 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9750 (gnus-summary-update-secondary-mark
9751 (cdr gnus-article-current))))
9752 ;; Prettify the article buffer again.
9753 (unless no-highlight
9755 (set-buffer gnus-article-buffer)
9756 ;;;!!! Fix this -- article should be rehighlighted.
9757 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9758 (set-buffer gnus-original-article-buffer)
9759 (gnus-request-article
9760 (cdr gnus-article-current)
9761 (car gnus-article-current) (current-buffer))))
9762 ;; Prettify the summary buffer line.
9763 (when (gnus-visual-p 'summary-highlight 'highlight)
9764 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9766 (defun gnus-summary-edit-wash (key)
9767 "Perform editing command KEY in the article buffer."
9771 (message "%s" (concat (this-command-keys) "- "))
9774 (gnus-summary-edit-article)
9775 (execute-kbd-macro (concat (this-command-keys) key))
9776 (gnus-article-edit-done))
9780 (defun gnus-summary-respool-query (&optional silent trace)
9781 "Query where the respool algorithm would put this article."
9783 (let (gnus-mark-article-hook)
9784 (gnus-summary-select-article)
9786 (set-buffer gnus-original-article-buffer)
9787 (let ((groups (nnmail-article-group 'identity trace)))
9790 (message "This message would go to %s"
9791 (mapconcat 'car groups ", "))
9792 (message "This message would go to no groups"))
9795 (defun gnus-summary-respool-trace ()
9796 "Trace where the respool algorithm would put this article.
9797 Display a buffer showing all fancy splitting patterns which matched."
9799 (gnus-summary-respool-query nil t))
9801 ;; Summary marking commands.
9803 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9804 "Mark articles which has the same subject as read, and then select the next.
9805 If UNMARK is positive, remove any kind of mark.
9806 If UNMARK is negative, tick articles."
9809 (setq unmark (prefix-numeric-value unmark)))
9811 (gnus-summary-mark-same-subject
9812 (gnus-summary-article-subject) unmark)))
9813 ;; Select next unread article. If auto-select-same mode, should
9814 ;; select the first unread article.
9815 (gnus-summary-next-article t (and gnus-auto-select-same
9816 (gnus-summary-article-subject)))
9817 (gnus-message 7 "%d article%s marked as %s"
9818 count (if (= count 1) " is" "s are")
9819 (if unmark "unread" "read"))))
9821 (defun gnus-summary-kill-same-subject (&optional unmark)
9822 "Mark articles which has the same subject as read.
9823 If UNMARK is positive, remove any kind of mark.
9824 If UNMARK is negative, tick articles."
9827 (setq unmark (prefix-numeric-value unmark)))
9829 (gnus-summary-mark-same-subject
9830 (gnus-summary-article-subject) unmark)))
9831 ;; If marked as read, go to next unread subject.
9833 ;; Go to next unread subject.
9834 (gnus-summary-next-subject 1 t))
9835 (gnus-message 7 "%d articles are marked as %s"
9836 count (if unmark "unread" "read"))))
9838 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9839 "Mark articles with same SUBJECT as read, and return marked number.
9840 If optional argument UNMARK is positive, remove any kinds of marks.
9841 If optional argument UNMARK is negative, mark articles as unread instead."
9845 ((null unmark) ; Mark as read.
9848 (gnus-summary-mark-article-as-read gnus-killed-mark)
9849 (gnus-summary-show-thread) t)
9850 (gnus-summary-find-subject subject))
9851 (setq count (1+ count))))
9852 ((> unmark 0) ; Tick.
9855 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9856 (gnus-summary-show-thread) t)
9857 (gnus-summary-find-subject subject))
9858 (setq count (1+ count))))
9859 (t ; Mark as unread.
9862 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9863 (gnus-summary-show-thread) t)
9864 (gnus-summary-find-subject subject))
9865 (setq count (1+ count)))))
9866 (gnus-set-mode-line 'summary)
9867 ;; Return the number of marked articles.
9870 (defun gnus-summary-mark-as-processable (n &optional unmark)
9871 "Set the process mark on the next N articles.
9872 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9873 the process mark instead. The difference between N and the actual
9874 number of articles marked is returned."
9876 (if (and (null n) (gnus-region-active-p))
9877 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9878 (setq n (prefix-numeric-value n))
9879 (let ((backward (< n 0))
9884 (gnus-summary-remove-process-mark
9885 (gnus-summary-article-number))
9886 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9887 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9890 (gnus-message 7 "No more articles"))
9891 (gnus-summary-recenter)
9892 (gnus-summary-position-point)
9895 (defun gnus-summary-unmark-as-processable (n)
9896 "Remove the process mark from the next N articles.
9897 If N is negative, unmark backward instead. The difference between N and
9898 the actual number of articles unmarked is returned."
9900 (gnus-summary-mark-as-processable n t))
9902 (defun gnus-summary-unmark-all-processable ()
9903 "Remove the process mark from all articles."
9906 (while gnus-newsgroup-processable
9907 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9908 (gnus-summary-position-point))
9910 (defun gnus-summary-add-mark (article type)
9911 "Mark ARTICLE with a mark of TYPE."
9912 (let ((vtype (car (assq type gnus-article-mark-lists)))
9915 (error "No such mark type: %s" type)
9916 (setq var (intern (format "gnus-newsgroup-%s" type)))
9917 (set var (cons article (symbol-value var)))
9918 (if (memq type '(processable cached replied forwarded recent saved))
9919 (gnus-summary-update-secondary-mark article)
9920 ;;; !!! This is bogus. We should find out what primary
9921 ;;; !!! mark we want to set.
9922 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9924 (defun gnus-summary-mark-as-expirable (n)
9925 "Mark N articles forward as expirable.
9926 If N is negative, mark backward instead. The difference between N and
9927 the actual number of articles marked is returned."
9929 (gnus-summary-mark-forward n gnus-expirable-mark))
9931 (defun gnus-summary-mark-as-spam (n)
9932 "Mark N articles forward as spam.
9933 If N is negative, mark backward instead. The difference between N and
9934 the actual number of articles marked is returned."
9936 (gnus-summary-mark-forward n gnus-spam-mark))
9938 (defun gnus-summary-mark-article-as-replied (article)
9939 "Mark ARTICLE as replied to and update the summary line.
9940 ARTICLE can also be a list of articles."
9941 (interactive (list (gnus-summary-article-number)))
9942 (let ((articles (if (listp article) article (list article))))
9943 (dolist (article articles)
9944 (unless (numberp article)
9945 (error "%s is not a number" article))
9946 (push article gnus-newsgroup-replied)
9947 (let ((buffer-read-only nil))
9948 (when (gnus-summary-goto-subject article nil t)
9949 (gnus-summary-update-secondary-mark article))))))
9951 (defun gnus-summary-mark-article-as-forwarded (article)
9952 "Mark ARTICLE as forwarded and update the summary line.
9953 ARTICLE can also be a list of articles."
9954 (let ((articles (if (listp article) article (list article))))
9955 (dolist (article articles)
9956 (push article gnus-newsgroup-forwarded)
9957 (let ((buffer-read-only nil))
9958 (when (gnus-summary-goto-subject article nil t)
9959 (gnus-summary-update-secondary-mark article))))))
9961 (defun gnus-summary-set-bookmark (article)
9962 "Set a bookmark in current article."
9963 (interactive (list (gnus-summary-article-number)))
9964 (when (or (not (get-buffer gnus-article-buffer))
9965 (not gnus-current-article)
9966 (not gnus-article-current)
9967 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9968 (error "No current article selected"))
9969 ;; Remove old bookmark, if one exists.
9970 (gnus-pull article gnus-newsgroup-bookmarks)
9971 ;; Set the new bookmark, which is on the form
9972 ;; (article-number . line-number-in-body).
9975 (with-current-buffer gnus-article-buffer
9982 gnus-newsgroup-bookmarks)
9983 (gnus-message 6 "A bookmark has been added to the current article."))
9985 (defun gnus-summary-remove-bookmark (article)
9986 "Remove the bookmark from the current article."
9987 (interactive (list (gnus-summary-article-number)))
9988 ;; Remove old bookmark, if one exists.
9989 (if (not (assq article gnus-newsgroup-bookmarks))
9990 (gnus-message 6 "No bookmark in current article.")
9991 (gnus-pull article gnus-newsgroup-bookmarks)
9992 (gnus-message 6 "Removed bookmark.")))
9994 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9995 (defun gnus-summary-mark-as-dormant (n)
9996 "Mark N articles forward as dormant.
9997 If N is negative, mark backward instead. The difference between N and
9998 the actual number of articles marked is returned."
10000 (gnus-summary-mark-forward n gnus-dormant-mark))
10002 (defun gnus-summary-set-process-mark (article)
10003 "Set the process mark on ARTICLE and update the summary line."
10004 (setq gnus-newsgroup-processable
10006 (delq article gnus-newsgroup-processable)))
10007 (when (gnus-summary-goto-subject article)
10008 (gnus-summary-show-thread)
10009 (gnus-summary-goto-subject article)
10010 (gnus-summary-update-secondary-mark article)))
10012 (defun gnus-summary-remove-process-mark (article)
10013 "Remove the process mark from ARTICLE and update the summary line."
10014 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10015 (when (gnus-summary-goto-subject article)
10016 (gnus-summary-show-thread)
10017 (gnus-summary-goto-subject article)
10018 (gnus-summary-update-secondary-mark article)))
10020 (defun gnus-summary-set-saved-mark (article)
10021 "Set the process mark on ARTICLE and update the summary line."
10022 (push article gnus-newsgroup-saved)
10023 (when (gnus-summary-goto-subject article)
10024 (gnus-summary-update-secondary-mark article)))
10026 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10027 "Mark N articles as read forwards.
10028 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10029 The difference between N and the actual number of articles marked is
10031 If NO-EXPIRE, auto-expiry will be inhibited."
10033 (gnus-summary-show-thread)
10034 (let ((backward (< n 0))
10035 (gnus-summary-goto-unread
10036 (and gnus-summary-goto-unread
10037 (not (eq gnus-summary-goto-unread 'never))
10038 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10039 gnus-ticked-mark gnus-dormant-mark)))))
10041 (mark (or mark gnus-del-mark)))
10042 (while (and (> n 0)
10043 (gnus-summary-mark-article nil mark no-expire)
10044 (zerop (gnus-summary-next-subject
10046 (and gnus-summary-goto-unread
10047 (not (eq gnus-summary-goto-unread 'never)))
10051 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10052 (gnus-summary-recenter)
10053 (gnus-summary-position-point)
10054 (gnus-set-mode-line 'summary)
10057 (defun gnus-summary-mark-article-as-read (mark)
10058 "Mark the current article quickly as read with MARK."
10059 (let ((article (gnus-summary-article-number)))
10060 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10061 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10062 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10063 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10064 (push (cons article mark) gnus-newsgroup-reads)
10065 ;; Possibly remove from cache, if that is used.
10066 (when gnus-use-cache
10067 (gnus-cache-enter-remove-article article))
10068 ;; Allow the backend to change the mark.
10069 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10070 ;; Check for auto-expiry.
10071 (when (and gnus-newsgroup-auto-expire
10072 (memq mark gnus-auto-expirable-marks))
10073 (setq mark gnus-expirable-mark)
10074 ;; Let the backend know about the mark change.
10075 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10076 (push article gnus-newsgroup-expirable))
10077 ;; Set the mark in the buffer.
10078 (gnus-summary-update-mark mark 'unread)
10081 (defun gnus-summary-mark-article-as-unread (mark)
10082 "Mark the current article quickly as unread with MARK."
10083 (let* ((article (gnus-summary-article-number))
10084 (old-mark (gnus-summary-article-mark article)))
10085 ;; Allow the backend to change the mark.
10086 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10087 (if (eq mark old-mark)
10091 (gnus-error 1 "Can't mark negative article numbers")
10093 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10094 (setq gnus-newsgroup-spam-marked
10095 (delq article gnus-newsgroup-spam-marked))
10096 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10097 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10098 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10099 (cond ((= mark gnus-ticked-mark)
10100 (setq gnus-newsgroup-marked
10101 (gnus-add-to-sorted-list gnus-newsgroup-marked
10103 ((= mark gnus-spam-mark)
10104 (setq gnus-newsgroup-spam-marked
10105 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10107 ((= mark gnus-dormant-mark)
10108 (setq gnus-newsgroup-dormant
10109 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10112 (setq gnus-newsgroup-unreads
10113 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10115 (gnus-pull article gnus-newsgroup-reads)
10117 ;; See whether the article is to be put in the cache.
10118 (and gnus-use-cache
10119 (vectorp (gnus-summary-article-header article))
10121 (gnus-cache-possibly-enter-article
10122 gnus-newsgroup-name article
10123 (gnus-summary-article-header article)
10124 (= mark gnus-ticked-mark)
10125 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10128 (gnus-summary-update-mark mark 'unread)
10131 (defun gnus-summary-mark-article (&optional article mark no-expire)
10132 "Mark ARTICLE with MARK. MARK can be any character.
10133 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10134 `??' (dormant) and `?E' (expirable).
10135 If MARK is nil, then the default character `?r' is used.
10136 If ARTICLE is nil, then the article on the current line will be
10138 If NO-EXPIRE, auto-expiry will be inhibited."
10139 ;; The mark might be a string.
10140 (when (stringp mark)
10141 (setq mark (aref mark 0)))
10142 ;; If no mark is given, then we check auto-expiring.
10144 (setq mark gnus-del-mark))
10145 (when (and (not no-expire)
10146 gnus-newsgroup-auto-expire
10147 (memq mark gnus-auto-expirable-marks))
10148 (setq mark gnus-expirable-mark))
10149 (let ((article (or article (gnus-summary-article-number)))
10150 (old-mark (gnus-summary-article-mark article)))
10151 ;; Allow the backend to change the mark.
10152 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10153 (if (eq mark old-mark)
10156 (error "No article on current line"))
10157 (if (not (if (or (= mark gnus-unread-mark)
10158 (= mark gnus-ticked-mark)
10159 (= mark gnus-spam-mark)
10160 (= mark gnus-dormant-mark))
10161 (gnus-mark-article-as-unread article mark)
10162 (gnus-mark-article-as-read article mark)))
10164 ;; See whether the article is to be put in the cache.
10165 (and gnus-use-cache
10166 (not (= mark gnus-canceled-mark))
10167 (vectorp (gnus-summary-article-header article))
10169 (gnus-cache-possibly-enter-article
10170 gnus-newsgroup-name article
10171 (gnus-summary-article-header article)
10172 (= mark gnus-ticked-mark)
10173 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10175 (when (gnus-summary-goto-subject article nil t)
10176 (let ((buffer-read-only nil))
10177 (gnus-summary-show-thread)
10179 (gnus-summary-update-mark mark 'unread)
10182 (defun gnus-summary-update-secondary-mark (article)
10183 "Update the secondary (read, process, cache) mark."
10184 (gnus-summary-update-mark
10185 (cond ((memq article gnus-newsgroup-processable)
10187 ((memq article gnus-newsgroup-cached)
10189 ((memq article gnus-newsgroup-replied)
10191 ((memq article gnus-newsgroup-forwarded)
10192 gnus-forwarded-mark)
10193 ((memq article gnus-newsgroup-saved)
10195 ((memq article gnus-newsgroup-recent)
10197 ((memq article gnus-newsgroup-unseen)
10201 (when (gnus-visual-p 'summary-highlight 'highlight)
10202 (gnus-run-hooks 'gnus-summary-update-hook))
10205 (defun gnus-summary-update-download-mark (article)
10206 "Update the download mark."
10207 (gnus-summary-update-mark
10208 (cond ((memq article gnus-newsgroup-undownloaded)
10209 gnus-undownloaded-mark)
10210 (gnus-newsgroup-agentized
10211 gnus-downloaded-mark)
10215 (gnus-summary-update-line t)
10218 (defun gnus-summary-update-mark (mark type)
10219 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10220 (buffer-read-only nil))
10221 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10223 (when (looking-at "\r")
10225 (when (<= (+ forward (point)) (point-max))
10226 ;; Go to the right position on the line.
10227 (goto-char (+ forward (point)))
10228 ;; Replace the old mark with the new mark.
10229 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10230 ;; Optionally update the marks by some user rule.
10231 (when (eq type 'unread)
10232 (gnus-data-set-mark
10233 (gnus-data-find (gnus-summary-article-number)) mark)
10234 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10236 (defun gnus-mark-article-as-read (article &optional mark)
10237 "Enter ARTICLE in the pertinent lists and remove it from others."
10238 ;; Make the article expirable.
10239 (let ((mark (or mark gnus-del-mark)))
10240 (setq gnus-newsgroup-expirable
10241 (if (= mark gnus-expirable-mark)
10242 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10243 (delq article gnus-newsgroup-expirable)))
10244 ;; Remove from unread and marked lists.
10245 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10246 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10247 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10248 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10249 (push (cons article mark) gnus-newsgroup-reads)
10250 ;; Possibly remove from cache, if that is used.
10251 (when gnus-use-cache
10252 (gnus-cache-enter-remove-article article))
10255 (defun gnus-mark-article-as-unread (article &optional mark)
10256 "Enter ARTICLE in the pertinent lists and remove it from others."
10257 (let ((mark (or mark gnus-ticked-mark)))
10260 (gnus-error 1 "Can't mark negative article numbers")
10262 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10263 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10264 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10265 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10266 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10268 ;; Unsuppress duplicates?
10269 (when gnus-suppress-duplicates
10270 (gnus-dup-unsuppress-article article))
10272 (cond ((= mark gnus-ticked-mark)
10273 (setq gnus-newsgroup-marked
10274 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10275 ((= mark gnus-spam-mark)
10276 (setq gnus-newsgroup-spam-marked
10277 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10279 ((= mark gnus-dormant-mark)
10280 (setq gnus-newsgroup-dormant
10281 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10283 (setq gnus-newsgroup-unreads
10284 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10285 (gnus-pull article gnus-newsgroup-reads)
10288 (defalias 'gnus-summary-mark-as-unread-forward
10289 'gnus-summary-tick-article-forward)
10290 (make-obsolete 'gnus-summary-mark-as-unread-forward
10291 'gnus-summary-tick-article-forward)
10292 (defun gnus-summary-tick-article-forward (n)
10293 "Tick N articles forwards.
10294 If N is negative, tick backwards instead.
10295 The difference between N and the number of articles ticked is returned."
10297 (gnus-summary-mark-forward n gnus-ticked-mark))
10299 (defalias 'gnus-summary-mark-as-unread-backward
10300 'gnus-summary-tick-article-backward)
10301 (make-obsolete 'gnus-summary-mark-as-unread-backward
10302 'gnus-summary-tick-article-backward)
10303 (defun gnus-summary-tick-article-backward (n)
10304 "Tick N articles backwards.
10305 The difference between N and the number of articles ticked is returned."
10307 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10309 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10310 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10311 (defun gnus-summary-tick-article (&optional article clear-mark)
10312 "Mark current article as unread.
10313 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10314 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10316 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10317 gnus-ticked-mark)))
10319 (defun gnus-summary-mark-as-read-forward (n)
10320 "Mark N articles as read forwards.
10321 If N is negative, mark backwards instead.
10322 The difference between N and the actual number of articles marked is
10325 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10327 (defun gnus-summary-mark-as-read-backward (n)
10328 "Mark the N articles as read backwards.
10329 The difference between N and the actual number of articles marked is
10332 (gnus-summary-mark-forward
10333 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10335 (defun gnus-summary-mark-as-read (&optional article mark)
10336 "Mark current article as read.
10337 ARTICLE specifies the article to be marked as read.
10338 MARK specifies a string to be inserted at the beginning of the line."
10339 (gnus-summary-mark-article article mark))
10341 (defun gnus-summary-clear-mark-forward (n)
10342 "Clear marks from N articles forward.
10343 If N is negative, clear backward instead.
10344 The difference between N and the number of marks cleared is returned."
10346 (gnus-summary-mark-forward n gnus-unread-mark))
10348 (defun gnus-summary-clear-mark-backward (n)
10349 "Clear marks from N articles backward.
10350 The difference between N and the number of marks cleared is returned."
10352 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10354 (defun gnus-summary-mark-unread-as-read ()
10355 "Intended to be used by `gnus-summary-mark-article-hook'."
10356 (when (memq gnus-current-article gnus-newsgroup-unreads)
10357 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10359 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10360 "Intended to be used by `gnus-summary-mark-article-hook'."
10361 (let ((mark (gnus-summary-article-mark)))
10362 (when (or (gnus-unread-mark-p mark)
10363 (gnus-read-mark-p mark))
10364 (gnus-summary-mark-article gnus-current-article
10365 (or new-mark gnus-read-mark)))))
10367 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10368 "Intended to be used by `gnus-summary-mark-article-hook'."
10369 (let ((mark (gnus-summary-article-mark)))
10370 (when (or (gnus-unread-mark-p mark)
10371 (gnus-read-mark-p mark))
10372 (gnus-summary-mark-article (gnus-summary-article-number)
10373 (or new-mark gnus-read-mark)))))
10375 (defun gnus-summary-mark-unread-as-ticked ()
10376 "Intended to be used by `gnus-summary-mark-article-hook'."
10377 (when (memq gnus-current-article gnus-newsgroup-unreads)
10378 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10380 (defun gnus-summary-mark-region-as-read (point mark all)
10381 "Mark all unread articles between point and mark as read.
10382 If given a prefix, mark all articles between point and mark as read,
10383 even ticked and dormant ones."
10384 (interactive "r\nP")
10388 (beginning-of-line)
10393 (memq (setq article (gnus-summary-article-number))
10394 gnus-newsgroup-unreads))
10395 (gnus-summary-mark-article article gnus-del-mark))
10397 (gnus-summary-find-next))))))
10399 (defun gnus-summary-mark-below (score mark)
10400 "Mark articles with score less than SCORE with MARK."
10401 (interactive "P\ncMark: ")
10402 (setq score (if score
10403 (prefix-numeric-value score)
10404 (or gnus-summary-default-score 0)))
10406 (set-buffer gnus-summary-buffer)
10407 (goto-char (point-min))
10410 (and (< (gnus-summary-article-score) score)
10411 (gnus-summary-mark-article nil mark))
10412 (gnus-summary-find-next)))))
10414 (defun gnus-summary-kill-below (&optional score)
10415 "Mark articles with score below SCORE as read."
10417 (gnus-summary-mark-below score gnus-killed-mark))
10419 (defun gnus-summary-clear-above (&optional score)
10420 "Clear all marks from articles with score above SCORE."
10422 (gnus-summary-mark-above score gnus-unread-mark))
10424 (defun gnus-summary-tick-above (&optional score)
10425 "Tick all articles with score above SCORE."
10427 (gnus-summary-mark-above score gnus-ticked-mark))
10429 (defun gnus-summary-mark-above (score mark)
10430 "Mark articles with score over SCORE with MARK."
10431 (interactive "P\ncMark: ")
10432 (setq score (if score
10433 (prefix-numeric-value score)
10434 (or gnus-summary-default-score 0)))
10436 (set-buffer gnus-summary-buffer)
10437 (goto-char (point-min))
10439 (when (> (gnus-summary-article-score) score)
10440 (gnus-summary-mark-article nil mark))
10442 (gnus-summary-find-next)))))
10444 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10445 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10446 (defun gnus-summary-limit-include-expunged (&optional no-error)
10447 "Display all the hidden articles that were expunged for low scores."
10449 (let ((buffer-read-only nil))
10450 (let ((scored gnus-newsgroup-scored)
10453 (unless (gnus-summary-article-header (caar scored))
10454 (and (setq h (gnus-number-to-header (caar scored)))
10455 (< (cdar scored) gnus-summary-expunge-below)
10457 (setq scored (cdr scored)))
10459 (when (not no-error)
10460 (error "No expunged articles hidden"))
10461 (goto-char (point-min))
10462 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10463 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10464 (mapcar (lambda (x) (push (mail-header-number x)
10465 gnus-newsgroup-limit))
10467 (gnus-summary-prepare-unthreaded (nreverse headers))
10468 (goto-char (point-min))
10469 (gnus-summary-position-point)
10472 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10473 "Mark all unread articles in this newsgroup as read.
10474 If prefix argument ALL is non-nil, ticked and dormant articles will
10475 also be marked as read.
10476 If QUIETLY is non-nil, no questions will be asked.
10478 If TO-HERE is non-nil, it should be a point in the buffer. All
10479 articles before (after, if REVERSE is set) this point will be marked
10482 Note that this function will only catch up the unread article
10483 in the current summary buffer limitation.
10485 The number of articles marked as read is returned."
10490 (not gnus-interactive-catchup) ;Without confirmation?
10494 "Mark absolutely all articles as read? "
10495 "Mark all unread articles as read? ")))
10497 (not gnus-newsgroup-adaptive)
10498 (not gnus-newsgroup-auto-expire)
10499 (not gnus-suppress-duplicates)
10500 (or (not gnus-use-cache)
10501 (eq gnus-use-cache 'passive)))
10504 (setq gnus-newsgroup-marked nil
10505 gnus-newsgroup-spam-marked nil
10506 gnus-newsgroup-dormant nil))
10507 (setq gnus-newsgroup-unreads
10508 (gnus-sorted-nunion
10509 (gnus-intersection gnus-newsgroup-unreads
10510 gnus-newsgroup-downloadable)
10511 gnus-newsgroup-unfetched)))
10512 ;; We actually mark all articles as canceled, which we
10513 ;; have to do when using auto-expiry or adaptive scoring.
10514 (gnus-summary-show-all-threads)
10515 (if (and to-here reverse)
10517 (goto-char to-here)
10518 (gnus-summary-mark-current-read-and-unread-as-read
10520 (while (gnus-summary-find-next (not all))
10521 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10522 (when (gnus-summary-first-subject (not all))
10524 (if to-here (< (point) to-here) t)
10525 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10526 (gnus-summary-find-next (not all))))))
10527 (gnus-set-mode-line 'summary))
10529 (gnus-summary-position-point)))
10531 (defun gnus-summary-catchup-to-here (&optional all)
10532 "Mark all unticked articles before the current one as read.
10533 If ALL is non-nil, also mark ticked and dormant articles as read."
10536 (gnus-save-hidden-threads
10537 (let ((beg (point)))
10538 ;; We check that there are unread articles.
10539 (when (or all (gnus-summary-find-prev))
10540 (gnus-summary-catchup all t beg)))))
10541 (gnus-summary-position-point))
10543 (defun gnus-summary-catchup-from-here (&optional all)
10544 "Mark all unticked articles after (and including) the current one as read.
10545 If ALL is non-nil, also mark ticked and dormant articles as read."
10548 (gnus-save-hidden-threads
10549 (let ((beg (point)))
10550 ;; We check that there are unread articles.
10551 (when (or all (gnus-summary-find-next))
10552 (gnus-summary-catchup all t beg nil t)))))
10553 (gnus-summary-position-point))
10555 (defun gnus-summary-catchup-all (&optional quietly)
10556 "Mark all articles in this newsgroup as read.
10557 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10558 instead, which marks only unread articles as read."
10560 (gnus-summary-catchup t quietly))
10562 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10563 "Mark all unread articles in this group as read, then exit.
10564 If prefix argument ALL is non-nil, all articles are marked as read.
10565 If QUIETLY is non-nil, no questions will be asked."
10567 (when (gnus-summary-catchup all quietly nil 'fast)
10568 ;; Select next newsgroup or exit.
10569 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10570 (eq gnus-auto-select-next 'quietly))
10571 (gnus-summary-next-group nil)
10572 (gnus-summary-exit))))
10574 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10575 "Mark all articles in this newsgroup as read, and then exit.
10576 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10577 instead, which marks only unread articles as read."
10579 (gnus-summary-catchup-and-exit t quietly))
10581 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10582 "Mark all articles in this group as read and select the next group.
10583 If given a prefix, mark all articles, unread as well as ticked, as
10587 (gnus-summary-catchup all))
10588 (gnus-summary-next-group))
10594 (defmacro gnus-with-article (article &rest forms)
10595 "Select ARTICLE and perform FORMS in the original article buffer.
10596 Then replace the article with the result."
10598 ;; We don't want the article to be marked as read.
10599 (let (gnus-mark-article-hook)
10600 (gnus-summary-select-article t t nil ,article))
10601 (set-buffer gnus-original-article-buffer)
10603 (if (not (gnus-check-backend-function
10604 'request-replace-article (car gnus-article-current)))
10605 (gnus-message 5 "Read-only group; not replacing")
10606 (unless (gnus-request-replace-article
10607 ,article (car gnus-article-current)
10608 (current-buffer) t)
10609 (error "Couldn't replace article")))
10610 ;; The cache and backlog have to be flushed somewhat.
10611 (when gnus-keep-backlog
10612 (gnus-backlog-remove-article
10613 (car gnus-article-current) (cdr gnus-article-current)))
10614 (when gnus-use-cache
10615 (gnus-cache-update-article
10616 (car gnus-article-current) (cdr gnus-article-current)))))
10618 (put 'gnus-with-article 'lisp-indent-function 1)
10619 (put 'gnus-with-article 'edebug-form-spec '(form body))
10621 ;; Thread-based commands.
10623 (defun gnus-summary-articles-in-thread (&optional article)
10624 "Return a list of all articles in the current thread.
10625 If ARTICLE is non-nil, return all articles in the thread that starts
10626 with that article."
10627 (let* ((article (or article (gnus-summary-article-number)))
10628 (data (gnus-data-find-list article))
10629 (top-level (gnus-data-level (car data)))
10631 (cond ((null gnus-thread-operation-ignore-subject)
10632 (gnus-simplify-subject-re
10633 (mail-header-subject (gnus-data-header (car data)))))
10634 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10635 (gnus-simplify-subject-fuzzy
10636 (mail-header-subject (gnus-data-header (car data)))))
10638 (end-point (save-excursion
10639 (if (gnus-summary-go-to-next-thread)
10640 (point) (point-max))))
10643 (< (gnus-data-pos (car data)) end-point))
10644 (when (or (not top-subject)
10645 (string= top-subject
10646 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10647 (gnus-simplify-subject-fuzzy
10648 (mail-header-subject
10649 (gnus-data-header (car data))))
10650 (gnus-simplify-subject-re
10651 (mail-header-subject
10652 (gnus-data-header (car data)))))))
10653 (push (gnus-data-number (car data)) articles))
10654 (unless (and (setq data (cdr data))
10655 (> (gnus-data-level (car data)) top-level))
10657 ;; Return the list of articles.
10658 (nreverse articles)))
10660 (defun gnus-summary-rethread-current ()
10661 "Rethread the thread the current article is part of."
10663 (let* ((gnus-show-threads t)
10664 (article (gnus-summary-article-number))
10665 (id (mail-header-id (gnus-summary-article-header)))
10666 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10668 (error "No article on the current line"))
10669 (gnus-rebuild-thread id)
10670 (gnus-summary-goto-subject article)))
10672 (defun gnus-summary-reparent-thread ()
10673 "Make the current article child of the marked (or previous) article.
10675 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10676 is non-nil or the Subject: of both articles are the same."
10678 (unless (not (gnus-group-read-only-p))
10679 (error "The current newsgroup does not support article editing"))
10680 (unless (<= (length gnus-newsgroup-processable) 1)
10681 (error "No more than one article may be marked"))
10682 (save-window-excursion
10683 (let ((gnus-article-buffer " *reparent*")
10684 (current-article (gnus-summary-article-number))
10685 ;; First grab the marked article, otherwise one line up.
10686 (parent-article (if (not (null gnus-newsgroup-processable))
10687 (car gnus-newsgroup-processable)
10689 (if (eq (forward-line -1) 0)
10690 (gnus-summary-article-number)
10691 (error "Beginning of summary buffer"))))))
10692 (unless (not (eq current-article parent-article))
10693 (error "An article may not be self-referential"))
10694 (let ((message-id (mail-header-id
10695 (gnus-summary-article-header parent-article))))
10696 (unless (and message-id (not (equal message-id "")))
10697 (error "No message-id in desired parent"))
10698 (gnus-with-article current-article
10700 (goto-char (point-min))
10701 (message-narrow-to-head)
10702 (if (re-search-forward "^References: " nil t)
10704 (re-search-forward "^[^ \t]" nil t)
10707 (insert " " message-id))
10708 (insert "References: " message-id "\n"))))
10709 (set-buffer gnus-summary-buffer)
10710 (gnus-summary-unmark-all-processable)
10711 (gnus-summary-update-article current-article)
10712 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10713 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10714 (gnus-summary-rethread-current)
10715 (gnus-message 3 "Article %d is now the child of article %d"
10716 current-article parent-article)))))
10718 (defun gnus-summary-toggle-threads (&optional arg)
10719 "Toggle showing conversation threads.
10720 If ARG is positive number, turn showing conversation threads on."
10722 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10723 (setq gnus-show-threads
10724 (if (null arg) (not gnus-show-threads)
10725 (> (prefix-numeric-value arg) 0)))
10726 (gnus-summary-prepare)
10727 (gnus-summary-goto-subject current)
10728 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10729 (gnus-summary-position-point)))
10731 (defun gnus-summary-show-all-threads ()
10732 "Show all threads."
10735 (let ((buffer-read-only nil))
10736 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10737 (gnus-summary-position-point))
10739 (defun gnus-summary-show-thread ()
10740 "Show thread subtrees.
10741 Returns nil if no thread was there to be shown."
10743 (let ((buffer-read-only nil)
10745 (end (point-at-eol))
10746 ;; Leave point at bol
10747 (beg (progn (beginning-of-line) (point))))
10749 ;; Any hidden lines here?
10750 (search-forward "\r" end t)
10751 (subst-char-in-region beg end ?\^M ?\n t)
10753 (gnus-summary-position-point))))
10755 (defun gnus-summary-maybe-hide-threads ()
10756 "If requested, hide the threads that should be hidden."
10757 (when (and gnus-show-threads
10758 gnus-thread-hide-subtree)
10759 (gnus-summary-hide-all-threads
10760 (if (or (consp gnus-thread-hide-subtree)
10761 (functionp gnus-thread-hide-subtree))
10762 (gnus-make-predicate gnus-thread-hide-subtree)
10765 ;;; Hiding predicates.
10767 (defun gnus-article-unread-p (header)
10768 (memq (mail-header-number header) gnus-newsgroup-unreads))
10770 (defun gnus-article-unseen-p (header)
10771 (memq (mail-header-number header) gnus-newsgroup-unseen))
10773 (defun gnus-map-articles (predicate articles)
10774 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10775 (apply 'gnus-or (mapcar predicate
10776 (mapcar 'gnus-summary-article-header articles))))
10778 (defun gnus-summary-hide-all-threads (&optional predicate)
10779 "Hide all thread subtrees.
10780 If PREDICATE is supplied, threads that satisfy this predicate
10781 will not be hidden."
10784 (goto-char (point-min))
10787 (when (or (not predicate)
10789 predicate (gnus-summary-article-children)))
10790 (gnus-summary-hide-thread))
10791 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10792 (gnus-summary-position-point))
10794 (defun gnus-summary-hide-thread ()
10795 "Hide thread subtrees.
10796 If PREDICATE is supplied, threads that satisfy this predicate
10797 will not be hidden.
10798 Returns nil if no threads were there to be hidden."
10800 (let ((buffer-read-only nil)
10802 (article (gnus-summary-article-number)))
10804 ;; Go forward until either the buffer ends or the subthread
10806 (when (and (not (eobp))
10807 (or (zerop (gnus-summary-next-thread 1 t))
10808 (goto-char (point-max))))
10810 (if (and (> (point) start)
10811 (search-backward "\n" start t))
10813 (subst-char-in-region start (point) ?\n ?\^M)
10814 (gnus-summary-goto-subject article))
10818 (defun gnus-summary-go-to-next-thread (&optional previous)
10819 "Go to the same level (or less) next thread.
10820 If PREVIOUS is non-nil, go to previous thread instead.
10821 Return the article number moved to, or nil if moving was impossible."
10822 (let ((level (gnus-summary-thread-level))
10823 (way (if previous -1 1))
10826 (while (and (not (eobp))
10827 (< level (gnus-summary-thread-level)))
10828 (forward-line way))
10835 (gnus-summary-article-number)
10836 (goto-char beg)))))
10838 (defun gnus-summary-next-thread (n &optional silent)
10839 "Go to the same level next N'th thread.
10840 If N is negative, search backward instead.
10841 Returns the difference between N and the number of skips actually
10844 If SILENT, don't output messages."
10846 (let ((backward (< n 0))
10848 (while (and (> n 0)
10849 (gnus-summary-go-to-next-thread backward))
10852 (gnus-summary-position-point))
10853 (when (and (not silent) (/= 0 n))
10854 (gnus-message 7 "No more threads"))
10857 (defun gnus-summary-prev-thread (n)
10858 "Go to the same level previous N'th thread.
10859 Returns the difference between N and the number of skips actually
10862 (gnus-summary-next-thread (- n)))
10864 (defun gnus-summary-go-down-thread ()
10865 "Go down one level in the current thread."
10866 (let ((children (gnus-summary-article-children)))
10868 (gnus-summary-goto-subject (car children)))))
10870 (defun gnus-summary-go-up-thread ()
10871 "Go up one level in the current thread."
10872 (let ((parent (gnus-summary-article-parent)))
10874 (gnus-summary-goto-subject parent))))
10876 (defun gnus-summary-down-thread (n)
10877 "Go down thread N steps.
10878 If N is negative, go up instead.
10879 Returns the difference between N and how many steps down that were
10884 (while (and (> n 0)
10885 (if up (gnus-summary-go-up-thread)
10886 (gnus-summary-go-down-thread)))
10888 (gnus-summary-position-point)
10890 (gnus-message 7 "Can't go further"))
10893 (defun gnus-summary-up-thread (n)
10894 "Go up thread N steps.
10895 If N is negative, go down instead.
10896 Returns the difference between N and how many steps down that were
10899 (gnus-summary-down-thread (- n)))
10901 (defun gnus-summary-top-thread ()
10902 "Go to the top of the thread."
10904 (while (gnus-summary-go-up-thread))
10905 (gnus-summary-article-number))
10907 (defun gnus-summary-kill-thread (&optional unmark)
10908 "Mark articles under current thread as read.
10909 If the prefix argument is positive, remove any kinds of marks.
10910 If the prefix argument is negative, tick articles instead."
10913 (setq unmark (prefix-numeric-value unmark)))
10914 (let ((articles (gnus-summary-articles-in-thread)))
10916 ;; Expand the thread.
10917 (gnus-summary-show-thread)
10918 ;; Mark all the articles.
10920 (gnus-summary-goto-subject (car articles))
10921 (cond ((null unmark)
10922 (gnus-summary-mark-article-as-read gnus-killed-mark))
10924 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10926 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10927 (setq articles (cdr articles))))
10928 ;; Hide killed subtrees.
10930 gnus-thread-hide-killed
10931 (gnus-summary-hide-thread))
10932 ;; If marked as read, go to next unread subject.
10933 (when (null unmark)
10934 ;; Go to next unread subject.
10935 (gnus-summary-next-subject 1 t)))
10936 (gnus-set-mode-line 'summary))
10938 ;; Summary sorting commands
10940 (defun gnus-summary-sort-by-number (&optional reverse)
10941 "Sort the summary buffer by article number.
10942 Argument REVERSE means reverse order."
10944 (gnus-summary-sort 'number reverse))
10946 (defun gnus-summary-sort-by-random (&optional reverse)
10947 "Randomize the order in the summary buffer.
10948 Argument REVERSE means to randomize in reverse order."
10950 (gnus-summary-sort 'random reverse))
10952 (defun gnus-summary-sort-by-author (&optional reverse)
10953 "Sort the summary buffer by author name alphabetically.
10954 If `case-fold-search' is non-nil, case of letters is ignored.
10955 Argument REVERSE means reverse order."
10957 (gnus-summary-sort 'author reverse))
10959 (defun gnus-summary-sort-by-recipient (&optional reverse)
10960 "Sort the summary buffer by recipient name alphabetically.
10961 If `case-fold-search' is non-nil, case of letters is ignored.
10962 Argument REVERSE means reverse order."
10964 (gnus-summary-sort 'recipient reverse))
10966 (defun gnus-summary-sort-by-subject (&optional reverse)
10967 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10968 If `case-fold-search' is non-nil, case of letters is ignored.
10969 Argument REVERSE means reverse order."
10971 (gnus-summary-sort 'subject reverse))
10973 (defun gnus-summary-sort-by-date (&optional reverse)
10974 "Sort the summary buffer by date.
10975 Argument REVERSE means reverse order."
10977 (gnus-summary-sort 'date reverse))
10979 (defun gnus-summary-sort-by-score (&optional reverse)
10980 "Sort the summary buffer by score.
10981 Argument REVERSE means reverse order."
10983 (gnus-summary-sort 'score reverse))
10985 (defun gnus-summary-sort-by-lines (&optional reverse)
10986 "Sort the summary buffer by the number of lines.
10987 Argument REVERSE means reverse order."
10989 (gnus-summary-sort 'lines reverse))
10991 (defun gnus-summary-sort-by-chars (&optional reverse)
10992 "Sort the summary buffer by article length.
10993 Argument REVERSE means reverse order."
10995 (gnus-summary-sort 'chars reverse))
10997 (defun gnus-summary-sort-by-original (&optional reverse)
10998 "Sort the summary buffer using the default sorting method.
10999 Argument REVERSE means reverse order."
11001 (let* ((buffer-read-only)
11002 (gnus-summary-prepare-hook nil))
11003 ;; We do the sorting by regenerating the threads.
11004 (gnus-summary-prepare)
11005 ;; Hide subthreads if needed.
11006 (gnus-summary-maybe-hide-threads)))
11008 (defun gnus-summary-sort (predicate reverse)
11009 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11010 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11011 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11012 (gnus-thread-sort-functions
11017 (gnus-sort-gathered-threads-function
11018 gnus-thread-sort-functions)
11019 (gnus-article-sort-functions
11023 (,article t2 t1))))
11025 (gnus-summary-prepare-hook nil))
11026 ;; We do the sorting by regenerating the threads.
11027 (gnus-summary-prepare)
11028 ;; Hide subthreads if needed.
11029 (gnus-summary-maybe-hide-threads)))
11031 ;; Summary saving commands.
11033 (defun gnus-summary-save-article (&optional n not-saved)
11034 "Save the current article using the default saver function.
11035 If N is a positive number, save the N next articles.
11036 If N is a negative number, save the N previous articles.
11037 If N is nil and any articles have been marked with the process mark,
11038 save those articles instead.
11039 The variable `gnus-default-article-saver' specifies the saver function."
11041 (let* ((articles (gnus-summary-work-articles n))
11042 (save-buffer (save-excursion
11043 (nnheader-set-temp-buffer " *Gnus Save*")))
11044 (num (length articles))
11046 (dolist (article articles)
11047 (setq header (gnus-summary-article-header article))
11048 (if (not (vectorp header))
11049 ;; This is a pseudo-article.
11050 (if (assq 'name header)
11051 (gnus-copy-file (cdr (assq 'name header)))
11052 (gnus-message 1 "Article %d is unsaveable" article))
11053 ;; This is a real article.
11054 (save-window-excursion
11055 (let ((gnus-display-mime-function nil)
11056 (gnus-article-prepare-hook nil))
11057 (gnus-summary-select-article t nil nil article)))
11059 (set-buffer save-buffer)
11061 (insert-buffer-substring gnus-original-article-buffer))
11062 (setq file (gnus-article-save save-buffer file num))
11063 (gnus-summary-remove-process-mark article)
11065 (gnus-summary-set-saved-mark article))))
11066 (gnus-kill-buffer save-buffer)
11067 (gnus-summary-position-point)
11068 (gnus-set-mode-line 'summary)
11071 (defun gnus-summary-pipe-output (&optional arg headers)
11072 "Pipe the current article to a subprocess.
11073 If N is a positive number, pipe the N next articles.
11074 If N is a negative number, pipe the N previous articles.
11075 If N is nil and any articles have been marked with the process mark,
11076 pipe those articles instead.
11077 If HEADERS (the symbolic prefix), include the headers, too."
11078 (interactive (gnus-interactive "P\ny"))
11079 (require 'gnus-art)
11080 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11081 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11082 (gnus-summary-save-article arg t))
11083 (let ((buffer (get-buffer "*Shell Command Output*")))
11085 (not (zerop (buffer-size buffer))))
11086 (gnus-configure-windows 'pipe))))
11088 (defun gnus-summary-save-article-mail (&optional arg)
11089 "Append the current article to an mail file.
11090 If N is a positive number, save the N next articles.
11091 If N is a negative number, save the N previous articles.
11092 If N is nil and any articles have been marked with the process mark,
11093 save those articles instead."
11095 (require 'gnus-art)
11096 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11097 (gnus-summary-save-article arg)))
11099 (defun gnus-summary-save-article-rmail (&optional arg)
11100 "Append the current article to an rmail file.
11101 If N is a positive number, save the N next articles.
11102 If N is a negative number, save the N previous articles.
11103 If N is nil and any articles have been marked with the process mark,
11104 save those articles instead."
11106 (require 'gnus-art)
11107 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11108 (gnus-summary-save-article arg)))
11110 (defun gnus-summary-save-article-file (&optional arg)
11111 "Append the current article to a file.
11112 If N is a positive number, save the N next articles.
11113 If N is a negative number, save the N previous articles.
11114 If N is nil and any articles have been marked with the process mark,
11115 save those articles instead."
11117 (require 'gnus-art)
11118 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11119 (gnus-summary-save-article arg)))
11121 (defun gnus-summary-write-article-file (&optional arg)
11122 "Write the current article to a file, deleting the previous file.
11123 If N is a positive number, save the N next articles.
11124 If N is a negative number, save the N previous articles.
11125 If N is nil and any articles have been marked with the process mark,
11126 save those articles instead."
11128 (require 'gnus-art)
11129 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11130 (gnus-summary-save-article arg)))
11132 (defun gnus-summary-save-article-body-file (&optional arg)
11133 "Append the current article body to a file.
11134 If N is a positive number, save the N next articles.
11135 If N is a negative number, save the N previous articles.
11136 If N is nil and any articles have been marked with the process mark,
11137 save those articles instead."
11139 (require 'gnus-art)
11140 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11141 (gnus-summary-save-article arg)))
11143 (defun gnus-summary-muttprint (&optional arg)
11144 "Print the current article using Muttprint.
11145 If N is a positive number, save the N next articles.
11146 If N is a negative number, save the N previous articles.
11147 If N is nil and any articles have been marked with the process mark,
11148 save those articles instead."
11150 (require 'gnus-art)
11151 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11152 (gnus-summary-save-article arg t)))
11154 (defun gnus-summary-pipe-message (program)
11155 "Pipe the current article through PROGRAM."
11156 (interactive "sProgram: ")
11157 (gnus-summary-select-article)
11158 (let ((mail-header-separator ""))
11159 (gnus-eval-in-buffer-window gnus-article-buffer
11162 (let ((start (window-start))
11164 (message-pipe-buffer-body program)
11165 (set-window-start (get-buffer-window (current-buffer)) start))))))
11167 (defun gnus-get-split-value (methods)
11168 "Return a value based on the split METHODS."
11169 (let (split-name method result match)
11172 (set-buffer gnus-original-article-buffer)
11174 (nnheader-narrow-to-headers)
11175 (while (and methods (not split-name))
11176 (goto-char (point-min))
11177 (setq method (pop methods))
11178 (setq match (car method))
11181 ;; Regular expression.
11183 (re-search-forward match nil t)))
11188 (setq result (funcall match gnus-newsgroup-name))))
11193 (setq result (eval match)))))
11194 (setq split-name (cdr method))
11195 (cond ((stringp result)
11196 (push (expand-file-name
11197 result gnus-article-save-directory)
11200 (setq split-name (append result split-name)))))))))
11201 (nreverse split-name)))
11203 (defun gnus-valid-move-group-p (group)
11204 (and (boundp group)
11205 (symbol-name group)
11206 (symbol-value group)
11207 (gnus-get-function (gnus-find-method-for-group
11208 (symbol-name group)) 'request-accept-article t)))
11210 (defun gnus-read-move-group-name (prompt default articles prefix)
11211 "Read a group name."
11212 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11213 (minibuffer-confirm-incomplete nil) ; XEmacs
11215 (format "%s %s to:"
11217 (if (> (length articles) 1)
11218 (format "these %d articles" (length articles))
11223 (gnus-completing-read-with-default
11226 'gnus-valid-move-group-p
11228 'gnus-group-history))
11229 ((= 1 (length split-name))
11230 (gnus-completing-read-with-default
11231 (car split-name) prom
11233 'gnus-valid-move-group-p
11235 'gnus-group-history))
11237 (gnus-completing-read-with-default
11239 (mapcar 'list (nreverse split-name))
11241 'gnus-group-history))))
11242 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11244 (if (or (string= to-newsgroup "")
11245 (string= to-newsgroup prefix))
11246 (setq to-newsgroup default))
11247 (unless to-newsgroup
11248 (error "No group name entered"))
11249 (or (gnus-active to-newsgroup)
11250 (gnus-activate-group to-newsgroup nil nil to-method)
11251 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11253 (or (and (gnus-request-create-group to-newsgroup to-method)
11254 (gnus-activate-group
11255 to-newsgroup nil nil to-method)
11256 (gnus-subscribe-group to-newsgroup))
11257 (error "Couldn't create group %s" to-newsgroup)))
11258 (error "No such group: %s" to-newsgroup)))
11261 (defun gnus-summary-save-parts (type dir n &optional reverse)
11262 "Save parts matching TYPE to DIR.
11263 If REVERSE, save parts that do not match TYPE."
11265 (list (read-string "Save parts of type: "
11266 (or (car gnus-summary-save-parts-type-history)
11267 gnus-summary-save-parts-default-mime)
11268 'gnus-summary-save-parts-type-history)
11269 (setq gnus-summary-save-parts-last-directory
11270 (read-file-name "Save to directory: "
11271 gnus-summary-save-parts-last-directory
11273 current-prefix-arg))
11274 (gnus-summary-iterate n
11275 (let ((gnus-display-mime-function nil)
11276 (gnus-inhibit-treatment t))
11277 (gnus-summary-select-article))
11279 (set-buffer gnus-article-buffer)
11280 (let ((handles (or gnus-article-mime-handles
11281 (mm-dissect-buffer nil gnus-article-loose-mime)
11282 (and gnus-article-emulate-mime
11283 (mm-uu-dissect)))))
11285 (gnus-summary-save-parts-1 type dir handles reverse)
11286 (unless gnus-article-mime-handles ;; Don't destroy this case.
11287 (mm-destroy-parts handles)))))))
11289 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11290 (if (stringp (car handle))
11291 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11294 (not (string-match type (mm-handle-media-type handle)))
11295 (string-match type (mm-handle-media-type handle)))
11296 (let ((file (expand-file-name
11298 mm-file-name-rewrite-functions
11299 (file-name-nondirectory
11301 (mail-content-type-get
11302 (mm-handle-disposition handle) 'filename)
11303 (mail-content-type-get
11304 (mm-handle-type handle) 'name)
11305 (concat gnus-newsgroup-name
11306 "." (number-to-string
11307 (cdr gnus-article-current))))))
11309 (unless (file-exists-p file)
11310 (mm-save-part-to-file handle file))))))
11312 ;; Summary extract commands
11314 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11315 (let ((buffer-read-only nil)
11316 (article (gnus-summary-article-number))
11318 (unless (gnus-summary-goto-subject article)
11319 (error "No such article: %d" article))
11320 (gnus-summary-position-point)
11321 ;; If all commands are to be bunched up on one line, we collect
11323 (unless gnus-view-pseudos-separately
11324 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11327 (setq action (cdr (assq 'action (car ps))))
11328 (setq files (list (cdr (assq 'name (car ps)))))
11329 (while (and ps (cdr ps)
11330 (string= (or action "1")
11331 (or (cdr (assq 'action (cadr ps))) "2")))
11332 (push (cdr (assq 'name (cadr ps))) files)
11333 (setcdr ps (cddr ps)))
11335 (when (not (string-match "%s" action))
11338 (when (assq 'execute (car ps))
11339 (setcdr (assq 'execute (car ps))
11340 (funcall (if (string-match "%s" action)
11347 (shell-quote-argument f)))
11349 (setq ps (cdr ps)))))
11350 (if (and gnus-view-pseudos (not not-view))
11352 (when (assq 'execute (car pslist))
11353 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11354 (eq gnus-view-pseudos 'not-confirm)))
11355 (setq pslist (cdr pslist)))
11358 (setq after-article (or (cdr (assq 'article (car pslist)))
11359 (gnus-summary-article-number)))
11360 (gnus-summary-goto-subject after-article)
11363 (insert " " (file-name-nondirectory
11364 (cdr (assq 'name (car pslist))))
11365 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11367 (forward-line -1) ; back to `b'
11368 (gnus-add-text-properties
11369 b (1- e) (list 'gnus-number gnus-reffed-article-number
11370 gnus-mouse-face-prop gnus-mouse-face))
11372 after-article gnus-reffed-article-number
11373 gnus-unread-mark b (car pslist) 0 (- e b))
11374 (setq gnus-newsgroup-unreads
11375 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11376 gnus-reffed-article-number))
11377 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11378 (setq pslist (cdr pslist)))))))
11380 (defun gnus-pseudos< (p1 p2)
11381 (let ((c1 (cdr (assq 'action p1)))
11382 (c2 (cdr (assq 'action p2))))
11383 (and c1 c2 (string< c1 c2))))
11385 (defun gnus-request-pseudo-article (props)
11386 (cond ((assq 'execute props)
11387 (gnus-execute-command (cdr (assq 'execute props)))))
11388 (let ((gnus-current-article (gnus-summary-article-number)))
11389 (gnus-run-hooks 'gnus-mark-article-hook)))
11391 (defun gnus-execute-command (command &optional automatic)
11393 (gnus-article-setup-buffer)
11394 (set-buffer gnus-article-buffer)
11395 (setq buffer-read-only nil)
11396 (let ((command (if automatic command
11397 (read-string "Command: " (cons command 0)))))
11399 (insert "$ " command "\n\n")
11400 (if gnus-view-pseudo-asynchronously
11401 (start-process "gnus-execute" (current-buffer) shell-file-name
11402 shell-command-switch command)
11403 (call-process shell-file-name nil t nil
11404 shell-command-switch command)))))
11406 ;; Summary kill commands.
11408 (defun gnus-summary-edit-global-kill (article)
11409 "Edit the \"global\" kill file."
11410 (interactive (list (gnus-summary-article-number)))
11411 (gnus-group-edit-global-kill article))
11413 (defun gnus-summary-edit-local-kill ()
11414 "Edit a local kill file applied to the current newsgroup."
11416 (setq gnus-current-headers (gnus-summary-article-header))
11417 (gnus-group-edit-local-kill
11418 (gnus-summary-article-number) gnus-newsgroup-name))
11420 ;;; Header reading.
11422 (defun gnus-read-header (id &optional header)
11423 "Read the headers of article ID and enter them into the Gnus system."
11424 (let ((group gnus-newsgroup-name)
11425 (gnus-override-method
11427 gnus-override-method
11428 (and (gnus-news-group-p gnus-newsgroup-name)
11429 (car (gnus-refer-article-methods)))))
11431 ;; First we check to see whether the header in question is already
11434 ;; This is a Message-ID.
11435 (setq header (or header (gnus-id-to-header id)))
11436 ;; This is an article number.
11437 (setq header (or header (gnus-summary-article-header id))))
11439 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11440 ;; We have found the header.
11442 ;; We have to really fetch the header to this article.
11444 (set-buffer nntp-server-buffer)
11445 (when (setq where (gnus-request-head id group))
11446 (nnheader-fold-continuation-lines)
11447 (goto-char (point-max))
11449 (goto-char (point-min))
11453 ((cdr where) (cdr where))
11454 (header (mail-header-number header))
11455 (t gnus-reffed-article-number))
11457 (insert " Article retrieved.\n"))
11458 (if (or (not where)
11459 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11460 () ; Malformed head.
11461 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11462 (when (and (stringp id)
11463 (not (string= (gnus-group-real-name group)
11465 ;; If we fetched by Message-ID and the article came
11466 ;; from a different group, we fudge some bogus article
11467 ;; numbers for this article.
11468 (mail-header-set-number header gnus-reffed-article-number))
11470 (set-buffer gnus-summary-buffer)
11471 (decf gnus-reffed-article-number)
11472 (gnus-remove-header (mail-header-number header))
11473 (push header gnus-newsgroup-headers)
11474 (setq gnus-current-headers header)
11475 (push (mail-header-number header) gnus-newsgroup-limit)))
11478 (defun gnus-remove-header (number)
11479 "Remove header NUMBER from `gnus-newsgroup-headers'."
11480 (if (and gnus-newsgroup-headers
11481 (= number (mail-header-number (car gnus-newsgroup-headers))))
11482 (pop gnus-newsgroup-headers)
11483 (let ((headers gnus-newsgroup-headers))
11484 (while (and (cdr headers)
11485 (not (= number (mail-header-number (cadr headers)))))
11487 (when (cdr headers)
11488 (setcdr headers (cddr headers))))))
11491 ;;; summary highlights
11494 (defun gnus-highlight-selected-summary ()
11495 "Highlight selected article in summary buffer."
11496 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11497 (when gnus-summary-selected-face
11499 (let* ((beg (point-at-bol))
11500 (end (point-at-eol))
11501 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11502 (from (if (get-text-property beg gnus-mouse-face-prop)
11504 (or (next-single-property-change
11505 beg gnus-mouse-face-prop nil end)
11510 (or (next-single-property-change
11511 from gnus-mouse-face-prop nil end)
11513 ;; If no mouse-face prop on line we will have to = from = end,
11514 ;; so we highlight the entire line instead.
11515 (when (= (+ to 2) from)
11518 (if gnus-newsgroup-selected-overlay
11519 ;; Move old overlay.
11521 gnus-newsgroup-selected-overlay from to (current-buffer))
11522 ;; Create new overlay.
11524 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11525 'face gnus-summary-selected-face))))))
11527 (defvar gnus-summary-highlight-line-cached nil)
11528 (defvar gnus-summary-highlight-line-trigger nil)
11530 (defun gnus-summary-highlight-line-0 ()
11531 (if (and (eq gnus-summary-highlight-line-trigger
11532 gnus-summary-highlight)
11533 gnus-summary-highlight-line-cached)
11534 gnus-summary-highlight-line-cached
11535 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11536 gnus-summary-highlight-line-cached
11537 (let* ((cond (list 'cond))
11539 (list gnus-summary-highlight))
11541 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11545 (gnus-byte-compile (list 'lambda nil cond))))))
11547 (defun gnus-summary-highlight-line ()
11548 "Highlight current line according to `gnus-summary-highlight'."
11549 (let* ((beg (point-at-bol))
11550 (article (or (gnus-summary-article-number) gnus-current-article))
11551 (score (or (cdr (assq article
11552 gnus-newsgroup-scored))
11553 gnus-summary-default-score 0))
11554 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11555 (inhibit-read-only t)
11556 (default gnus-summary-default-score)
11557 (default-high gnus-summary-default-high-score)
11558 (default-low gnus-summary-default-low-score)
11559 (uncached (and gnus-summary-use-undownloaded-faces
11560 (memq article gnus-newsgroup-undownloaded)
11561 (not (memq article gnus-newsgroup-cached)))))
11562 (let ((face (funcall (gnus-summary-highlight-line-0))))
11563 (unless (eq face (get-text-property beg 'face))
11564 (gnus-put-text-property-excluding-characters-with-faces
11565 beg (point-at-eol) 'face
11566 (setq face (if (boundp face) (symbol-value face) face)))
11567 (when gnus-summary-highlight-line-function
11568 (funcall gnus-summary-highlight-line-function article face))))))
11570 (defun gnus-update-read-articles (group unread &optional compute)
11571 "Update the list of read articles in GROUP.
11572 UNREAD is a sorted list."
11573 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11574 (info (gnus-get-info group))
11577 (if (or (not info) (not active))
11578 ;; There is no info on this group if it was, in fact,
11579 ;; killed. Gnus stores no information on killed groups, so
11580 ;; there's nothing to be done.
11581 ;; One could store the information somewhere temporarily,
11582 ;; perhaps... Hmmm...
11584 ;; Remove any negative articles numbers.
11585 (while (and unread (< (car unread) 0))
11586 (setq unread (cdr unread)))
11587 ;; Remove any expired article numbers
11588 (while (and unread (< (car unread) (car active)))
11589 (setq unread (cdr unread)))
11590 ;; Compute the ranges of read articles by looking at the list of
11591 ;; unread articles.
11593 (when (/= (car unread) prev)
11594 (push (if (= prev (1- (car unread))) prev
11595 (cons prev (1- (car unread))))
11597 (setq prev (1+ (car unread)))
11598 (setq unread (cdr unread)))
11599 (when (<= prev (cdr active))
11600 (push (cons prev (cdr active)) read))
11601 (setq read (if (> (length read) 1) (nreverse read) read))
11606 ;; Propagate the read marks to the backend.
11607 (when (gnus-check-backend-function 'request-set-mark group)
11608 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11609 (add (gnus-remove-from-range read (gnus-info-read info))))
11611 (unless (gnus-check-group group)
11612 (error "Can't open server for %s" group))
11613 (gnus-request-set-mark
11614 group (delq nil (list (if add (list add 'add '(read)))
11615 (if del (list del 'del '(read))))))
11617 `(gnus-request-set-mark
11620 (if del (list del 'add '(read)))
11621 (if add (list add 'del '(read))))))))))
11622 (set-buffer gnus-group-buffer)
11623 (gnus-undo-register
11625 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11626 (gnus-info-set-read ',info ',(gnus-info-read info))
11627 (gnus-get-unread-articles-in-group ',info
11628 (gnus-active ,group))
11629 (gnus-group-update-group ,group t)
11631 ;; Enter this list into the group info.
11632 (gnus-info-set-read info read)
11633 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11634 (gnus-get-unread-articles-in-group info (gnus-active group))
11637 (defun gnus-offer-save-summaries ()
11638 "Offer to save all active summary buffers."
11640 ;; Go through all buffers and find all summaries.
11641 (dolist (buffer (buffer-list))
11642 (when (and (setq buffer (buffer-name buffer))
11643 (string-match "Summary" buffer)
11644 (with-current-buffer buffer
11645 ;; We check that this is, indeed, a summary buffer.
11646 (and (eq major-mode 'gnus-summary-mode)
11647 ;; Also make sure this isn't bogus.
11648 gnus-newsgroup-prepared
11649 ;; Also make sure that this isn't a
11650 ;; dead summary buffer.
11651 (not gnus-dead-summary-mode))))
11652 (push buffer buffers)))
11653 ;; Go through all these summary buffers and offer to save them.
11657 "Update summary buffer %s? "
11659 (switch-to-buffer buf)
11660 (gnus-summary-exit))
11664 ;;; @ for mime-partial
11667 (defun gnus-request-partial-message ()
11669 (let ((number (gnus-summary-article-number))
11670 (group gnus-newsgroup-name)
11671 (mother gnus-article-buffer))
11672 (set-buffer (get-buffer-create " *Partial Article*"))
11674 (setq mime-preview-buffer mother)
11675 (gnus-request-article-this-buffer number group)
11676 (mime-parse-buffer)
11679 (autoload 'mime-combine-message/partial-pieces-automatically
11681 "Internal method to combine message/partial messages automatically.")
11683 (mime-add-condition
11684 'action '((type . message)(subtype . partial)
11685 (major-mode . gnus-original-article-mode)
11686 (method . mime-combine-message/partial-pieces-automatically)
11687 (summary-buffer-exp . gnus-summary-buffer)
11688 (request-partial-message-method . gnus-request-partial-message)
11692 ;;; @ for message/rfc822
11695 (defun gnus-mime-extract-message/rfc822 (entity situation)
11696 "Burst a forwarded article."
11698 (set-buffer gnus-summary-buffer)
11699 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11700 gnus-newsgroup-name 'gnus-group-history))
11701 (gnus-group-marked (list group))
11704 (mime-insert-entity-content entity)
11705 (setq article (gnus-request-accept-article group)))
11706 (when (and (consp article)
11707 (numberp (setq article (cdr article))))
11708 (setq info (gnus-get-info group))
11709 (gnus-info-set-read info
11710 (gnus-remove-from-range (gnus-info-read info)
11712 (when (string-equal group gnus-newsgroup-name)
11714 (let (gnus-show-threads)
11715 (gnus-summary-goto-subject article t))
11716 (gnus-summary-clear-mark-forward 1))
11717 (set-buffer gnus-group-buffer)
11718 (gnus-group-get-new-news-this-group nil t)))))
11720 (mime-add-condition
11721 'action '((type . message)(subtype . rfc822)
11722 (major-mode . gnus-original-article-mode)
11723 (method . gnus-mime-extract-message/rfc822)
11727 (mime-add-condition
11728 'action '((type . message)(subtype . news)
11729 (major-mode . gnus-original-article-mode)
11730 (method . gnus-mime-extract-message/rfc822)
11734 (defun gnus-mime-extract-multipart (entity situation)
11735 (let ((children (mime-entity-children entity))
11736 mime-acting-situation-to-override
11739 (mime-play-entity (car children)
11740 (cons (assq 'mode situation)
11741 mime-acting-situation-to-override))
11742 (setq children (cdr children)))
11743 (if (setq f (cdr (assq 'after-method
11744 mime-acting-situation-to-override)))
11748 (mime-add-condition
11749 'action '((type . multipart)
11750 (method . gnus-mime-extract-multipart)
11759 (defun gnus-summary-inherit-default-charset ()
11760 "Import `default-mime-charset' from summary buffer.
11761 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11763 (if (buffer-live-p gnus-summary-buffer)
11764 (let (d-m-c d-m-c-u)
11765 (with-current-buffer gnus-summary-buffer
11766 (setq d-m-c (if (local-variable-p 'default-mime-charset
11767 gnus-summary-buffer)
11768 default-mime-charset
11771 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11772 gnus-summary-buffer)
11773 (symbol-value 'default-mime-charset-unlimited)
11776 (kill-local-variable 'default-mime-charset)
11777 (set (make-local-variable 'default-mime-charset) d-m-c))
11779 (kill-local-variable 'default-mime-charset-unlimited)
11780 (set (make-local-variable 'default-mime-charset-unlimited)
11783 (defun gnus-summary-setup-default-charset ()
11784 "Setup newsgroup default charset."
11785 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11787 (setq gnus-newsgroup-charset nil)
11788 (set (make-local-variable 'default-mime-charset) nil)
11789 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11790 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11791 (let ((ignored-charsets
11792 (or gnus-newsgroup-ephemeral-ignored-charsets
11794 (and gnus-newsgroup-name
11795 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11796 gnus-newsgroup-ignored-charsets)))
11798 (setq gnus-newsgroup-charset
11799 (or gnus-newsgroup-ephemeral-charset
11800 (when (and gnus-newsgroup-name
11801 (setq charset (gnus-parameter-charset
11802 gnus-newsgroup-name)))
11803 (make-local-variable 'default-mime-charset)
11804 (setq default-mime-charset charset))
11805 gnus-default-charset))
11806 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11807 ignored-charsets))))
11813 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11814 "Display the current article buffer fully MIME-buttonized.
11815 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11816 treated as multipart/mixed."
11818 (require 'gnus-art)
11819 (let ((gnus-unbuttonized-mime-types nil)
11820 (gnus-mime-display-multipart-as-mixed show-all-parts))
11821 (gnus-summary-show-article)))
11823 (defun gnus-summary-repair-multipart (article)
11824 "Add a Content-Type header to a multipart article without one."
11825 (interactive (list (gnus-summary-article-number)))
11826 (gnus-with-article article
11827 (message-narrow-to-head)
11828 (message-remove-header "Mime-Version")
11829 (goto-char (point-max))
11830 (insert "Mime-Version: 1.0\n")
11832 (when (search-forward "\n--" nil t)
11833 (let ((separator (buffer-substring (point) (point-at-eol))))
11834 (message-narrow-to-head)
11835 (message-remove-header "Content-Type")
11836 (goto-char (point-max))
11837 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11840 (let (gnus-mark-article-hook)
11841 (gnus-summary-select-article t t nil article)))
11843 (defun gnus-summary-toggle-display-buttonized ()
11844 "Toggle the buttonizing of the article buffer."
11846 (require 'gnus-art)
11847 (if (setq gnus-inhibit-mime-unbuttonizing
11848 (not gnus-inhibit-mime-unbuttonizing))
11849 (let ((gnus-unbuttonized-mime-types nil))
11850 (gnus-summary-show-article))
11851 (gnus-summary-show-article)))
11854 ;;; Intelli-mouse commmands
11857 (defun gnus-wheel-summary-scroll (event)
11859 (let ((amount (if (memq 'shift (event-modifiers event))
11860 (car gnus-wheel-scroll-amount)
11861 (cdr gnus-wheel-scroll-amount)))
11862 (direction (- (* (static-if (featurep 'xemacs)
11863 (event-button event)
11864 (cond ((eq 'mouse-4 (event-basic-type event))
11866 ((eq 'mouse-5 (event-basic-type event))
11870 (gnus-summary-scroll-up (* amount direction))
11871 (when (gnus-eval-in-buffer-window gnus-article-buffer
11874 (and (if (< 0 direction)
11875 (gnus-article-next-page 0)
11876 (gnus-article-prev-page 0)
11878 (if (setq edge (get-text-property
11879 (point-min) 'gnus-wheel-edge))
11880 (setq edge (* edge direction))
11883 (let ((buffer-read-only nil)
11884 (inhibit-read-only t))
11885 (put-text-property (point-min) (point-max)
11886 'gnus-wheel-edge direction)
11888 (or (> edge gnus-wheel-edge-resistance)
11889 (let ((buffer-read-only nil)
11890 (inhibit-read-only t))
11891 (put-text-property (point-min) (point-max)
11893 (* (1+ edge) direction))
11895 (eq last-command 'gnus-wheel-summary-scroll))))
11896 (gnus-summary-next-article nil nil (minusp direction)))))
11898 (defun gnus-wheel-install ()
11899 "Enable mouse wheel support on summary window."
11900 (when gnus-use-wheel
11902 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11904 (define-key gnus-summary-mode-map key
11905 'gnus-wheel-summary-scroll)))))
11907 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11910 ;;; Traditional PGP commmands
11913 (defun gnus-summary-decrypt-article (&optional force)
11914 "Decrypt the current article in traditional PGP way.
11915 This will have permanent effect only in mail groups.
11916 If FORCE is non-nil, allow editing of articles even in read-only
11919 (gnus-summary-select-article t)
11920 (gnus-eval-in-buffer-window gnus-article-buffer
11924 (goto-char (point-min))
11925 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11926 (error "Not a traditional PGP message!"))
11927 (let ((armor-start (match-beginning 0)))
11928 (if (and (pgg-decrypt-region armor-start (point-max))
11929 (or force (not (gnus-group-read-only-p))))
11930 (let ((inhibit-read-only t)
11932 (delete-region armor-start
11934 (re-search-forward "^-+END PGP" nil t)
11935 (beginning-of-line 2)
11937 (insert-buffer-substring pgg-output-buffer))))))))
11939 (defun gnus-summary-verify-article ()
11940 "Verify the current article in traditional PGP way."
11943 (set-buffer gnus-original-article-buffer)
11944 (goto-char (point-min))
11945 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11946 (error "Not a traditional PGP message!"))
11947 (re-search-forward "^-+END PGP" nil t)
11948 (beginning-of-line 2)
11949 (call-interactively (function pgg-verify-region))))
11952 ;;; Generic summary marking commands
11955 (defvar gnus-summary-marking-alist
11956 '((read gnus-del-mark "d")
11957 (unread gnus-unread-mark "u")
11958 (ticked gnus-ticked-mark "!")
11959 (dormant gnus-dormant-mark "?")
11960 (expirable gnus-expirable-mark "e"))
11961 "An alist of names/marks/keystrokes.")
11963 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11964 (defvar gnus-summary-mark-map)
11966 (defun gnus-summary-make-all-marking-commands ()
11967 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11968 (dolist (elem gnus-summary-marking-alist)
11969 (apply 'gnus-summary-make-marking-command elem)))
11971 (defun gnus-summary-make-marking-command (name mark keystroke)
11972 (let ((map (make-sparse-keymap)))
11973 (define-key gnus-summary-generic-mark-map keystroke map)
11974 (dolist (lway `((next "next" next nil "n")
11975 (next-unread "next unread" next t "N")
11976 (prev "previous" prev nil "p")
11977 (prev-unread "previous unread" prev t "P")
11978 (nomove "" nil nil ,keystroke)))
11979 (let ((func (gnus-summary-make-marking-command-1
11980 mark (car lway) lway name)))
11981 (setq func (eval func))
11982 (define-key map (nth 4 lway) func)))))
11984 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11986 (format "gnus-summary-put-mark-as-%s%s"
11987 name (if (eq way 'nomove)
11989 (concat "-" (symbol-name way)))))
11992 "Mark the current article as %s%s.
11993 If N, the prefix, then repeat N times.
11994 If N is negative, move in reverse order.
11995 The difference between N and the actual number of articles marked is
11997 name (car (cdr lway)))
11999 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12001 (defun gnus-summary-generic-mark (n mark move unread)
12002 "Mark N articles with MARK."
12003 (unless (eq major-mode 'gnus-summary-mode)
12004 (error "This command can only be used in the summary buffer"))
12005 (gnus-summary-show-thread)
12008 ((eq move 'next) 1)
12009 ((eq move 'prev) -1)
12011 (if (zerop nummove)
12015 nummove (* -1 nummove))))
12016 (while (and (> n 0)
12017 (gnus-summary-mark-article nil mark)
12018 (zerop (gnus-summary-next-subject nummove unread t)))
12021 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12022 (gnus-summary-recenter)
12023 (gnus-summary-position-point)
12024 (gnus-set-mode-line 'summary)
12027 (defun gnus-summary-insert-articles (articles)
12028 (when (setq articles
12029 (gnus-sorted-difference articles
12030 (mapcar (lambda (h)
12031 (mail-header-number h))
12032 gnus-newsgroup-headers)))
12033 (setq gnus-newsgroup-headers
12035 gnus-newsgroup-headers
12036 (gnus-fetch-headers articles)
12037 'gnus-article-sort-by-number))
12038 ;; Suppress duplicates?
12039 (when gnus-suppress-duplicates
12040 (gnus-dup-suppress-articles))
12042 ;; We might want to build some more threads first.
12043 (when (and gnus-fetch-old-headers
12044 (eq gnus-headers-retrieved-by 'nov))
12045 (if (eq gnus-fetch-old-headers 'invisible)
12046 (gnus-build-all-threads)
12047 (gnus-build-old-threads)))
12048 ;; Let the Gnus agent mark articles as read.
12050 (gnus-agent-get-undownloaded-list))
12051 ;; Remove list identifiers from subject
12052 (when gnus-list-identifiers
12053 (gnus-summary-remove-list-identifiers))
12054 ;; First and last article in this newsgroup.
12055 (when gnus-newsgroup-headers
12056 (setq gnus-newsgroup-begin
12057 (mail-header-number (car gnus-newsgroup-headers))
12059 (mail-header-number
12060 (gnus-last-element gnus-newsgroup-headers))))
12061 (when gnus-use-scoring
12062 (gnus-possibly-score-headers))))
12064 (defun gnus-summary-insert-old-articles (&optional all)
12065 "Insert all old articles in this group.
12066 If ALL is non-nil, already read articles become readable.
12067 If ALL is a number, fetch this number of articles."
12070 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12073 ;; Some nntp servers lie about their active range. When
12074 ;; this happens, the active range can be in the millions.
12075 ;; Use a compressed range to avoid creating a huge list.
12076 (gnus-range-difference (list gnus-newsgroup-active) old))
12077 (setq len (gnus-range-length older))
12082 (let ((older-range (nreverse older)))
12086 (let* ((r (pop older-range))
12087 (min (if (numberp r) r (car r)))
12088 (max (if (numberp r) r (cdr r))))
12089 (while (and (<= min max)
12094 (setq older (gnus-uncompress-range older))))
12096 (setq older (gnus-uncompress-range older)))
12098 (when (and (numberp gnus-large-newsgroup)
12099 (> len gnus-large-newsgroup))
12100 (let* ((cursor-in-echo-area nil)
12101 (initial (gnus-parameter-large-newsgroup-initial
12102 gnus-newsgroup-name))
12106 "How many articles from %s (%s %d): "
12108 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12109 (if initial "max" "default")
12112 (cons (number-to-string initial)
12114 (unless (string-match "^[ \t]*$" input)
12115 (setq all (string-to-number input))
12117 (let ((older-range (nreverse older)))
12121 (let* ((r (pop older-range))
12122 (min (if (numberp r) r (car r)))
12123 (max (if (numberp r) r (cdr r))))
12124 (while (and (<= min max)
12128 max (1- max))))))))))
12129 (setq older (gnus-uncompress-range older))))
12131 (message "No old news.")
12132 (gnus-summary-insert-articles older)
12133 (gnus-summary-limit (gnus-sorted-nunion old older))))
12134 (gnus-summary-position-point)))
12136 (defun gnus-summary-insert-new-articles ()
12137 "Insert all new articles in this group."
12140 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12141 (old-active gnus-newsgroup-active)
12142 (nnmail-fetched-sources (list t))
12144 (setq gnus-newsgroup-active
12145 (gnus-activate-group gnus-newsgroup-name 'scan))
12146 (setq i (cdr gnus-newsgroup-active))
12147 (while (> i (cdr old-active))
12151 (message "No gnus is bad news")
12152 (gnus-summary-insert-articles new)
12153 (setq gnus-newsgroup-unreads
12154 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12155 (gnus-summary-limit (gnus-sorted-nunion old new))))
12156 (gnus-summary-position-point)))
12158 (gnus-summary-make-all-marking-commands)
12160 (gnus-ems-redefine)
12162 (provide 'gnus-sum)
12164 (run-hooks 'gnus-sum-load-hook)
12166 ;; Local Variables:
12167 ;; coding: iso-8859-1
12170 ;;; gnus-sum.el ends here