1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
33 (defvar tool-bar-map))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
57 (autoload 'mm-uu-dissect "mm-uu")
58 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
59 "Deuglify broken Outlook (Express) articles and redisplay."
61 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
62 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
63 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-fetch-old-headers nil
73 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
74 If an unread article in the group refers to an older, already read (or
75 just marked as read) article, the old article will not normally be
76 displayed in the Summary buffer. If this variable is t, Gnus
77 will attempt to grab the headers to the old articles, and thereby
78 build complete threads. If it has the value `some', only enough
79 headers to connect otherwise loose threads will be displayed. This
80 variable can also be a number. In that case, no more than that number
81 of old headers will be fetched. If it has the value `invisible', all
82 old headers will be fetched, but none will be displayed.
84 The server has to support NOV for any of this to work."
86 :type '(choice (const :tag "off" nil)
91 (sexp :menu-tag "other" t)))
93 (defcustom gnus-refer-thread-limit 200
94 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
95 If t, fetch all the available old headers."
98 (sexp :menu-tag "other" t)))
100 (defcustom gnus-summary-make-false-root 'adopt
101 "*nil means that Gnus won't gather loose threads.
102 If the root of a thread has expired or been read in a previous
103 session, the information necessary to build a complete thread has been
104 lost. Instead of having many small sub-threads from this original thread
105 scattered all over the summary buffer, Gnus can gather them.
107 If non-nil, Gnus will try to gather all loose sub-threads from an
108 original thread into one large thread.
110 If this variable is non-nil, it should be one of `none', `adopt',
113 If this variable is `none', Gnus will not make a false root, but just
114 present the sub-threads after another.
115 If this variable is `dummy', Gnus will create a dummy root that will
116 have all the sub-threads as children.
117 If this variable is `adopt', Gnus will make one of the \"children\"
118 the parent and mark all the step-children as such.
119 If this variable is `empty', the \"children\" are printed with empty
120 subject fields. (Or rather, they will be printed with a string
121 given by the `gnus-summary-same-subject' variable.)"
123 :type '(choice (const :tag "off" nil)
129 (defcustom gnus-summary-make-false-root-always nil
130 "Always make a false dummy root."
135 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
136 "*A regexp to match subjects to be excluded from loose thread gathering.
137 As loose thread gathering is done on subjects only, that means that
138 there can be many false gatherings performed. By rooting out certain
139 common subjects, gathering might become saner."
143 (defcustom gnus-summary-gather-subject-limit nil
144 "*Maximum length of subject comparisons when gathering loose threads.
145 Use nil to compare full subjects. Setting this variable to a low
146 number will help gather threads that have been corrupted by
147 newsreaders chopping off subject lines, but it might also mean that
148 unrelated articles that have subject that happen to begin with the
149 same few characters will be incorrectly gathered.
151 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
154 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "on" t)))
158 (defcustom gnus-simplify-subject-functions nil
159 "List of functions taking a string argument that simplify subjects.
160 The functions are applied recursively.
162 Useful functions to put in this list include:
163 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
164 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
166 :type '(repeat function))
168 (defcustom gnus-simplify-ignored-prefixes nil
169 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
171 :type '(choice (const :tag "off" nil)
174 (defcustom gnus-build-sparse-threads nil
175 "*If non-nil, fill in the gaps in threads.
176 If `some', only fill in the gaps that are needed to tie loose threads
177 together. If `more', fill in all leaf nodes that Gnus can find. If
178 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
180 :type '(choice (const :tag "off" nil)
183 (sexp :menu-tag "all" t)))
185 (defcustom gnus-summary-thread-gathering-function
186 'gnus-gather-threads-by-subject
187 "*Function used for gathering loose threads.
188 There are two pre-defined functions: `gnus-gather-threads-by-subject',
189 which only takes Subjects into consideration; and
190 `gnus-gather-threads-by-references', which compared the References
191 headers of the articles to find matches."
193 :type '(radio (function-item gnus-gather-threads-by-subject)
194 (function-item gnus-gather-threads-by-references)
195 (function :tag "other")))
197 (defcustom gnus-summary-same-subject ""
198 "*String indicating that the current article has the same subject as the previous.
199 This variable will only be used if the value of
200 `gnus-summary-make-false-root' is `empty'."
201 :group 'gnus-summary-format
204 (defcustom gnus-summary-goto-unread t
205 "*If t, many commands will go to the next unread article.
206 This applies to marking commands as well as other commands that
207 \"naturally\" select the next article, like, for instance, `SPC' at
208 the end of an article.
210 If nil, the marking commands do NOT go to the next unread article
211 \(they go to the next article instead). If `never', commands that
212 usually go to the next unread article, will go to the next article,
213 whether it is read or not."
214 :group 'gnus-summary-marks
215 :link '(custom-manual "(gnus)Setting Marks")
216 :type '(choice (const :tag "off" nil)
218 (sexp :menu-tag "on" t)))
220 (defcustom gnus-summary-default-score 0
221 "*Default article score level.
222 All scores generated by the score files will be added to this score.
223 If this variable is nil, scoring will be disabled."
224 :group 'gnus-score-default
225 :type '(choice (const :tag "disable")
228 (defcustom gnus-summary-default-high-score 0
229 "*Default threshold for a high scored article.
230 An article will be highlighted as high scored if its score is greater
233 :group 'gnus-score-default
236 (defcustom gnus-summary-default-low-score 0
237 "*Default threshold for a low scored article.
238 An article will be highlighted as low scored if its score is smaller
241 :group 'gnus-score-default
244 (defcustom gnus-summary-zcore-fuzz 0
245 "*Fuzziness factor for the zcore in the summary buffer.
246 Articles with scores closer than this to `gnus-summary-default-score'
248 :group 'gnus-summary-format
251 (defcustom gnus-simplify-subject-fuzzy-regexp nil
252 "*Strings to be removed when doing fuzzy matches.
253 This can either be a regular expression or list of regular expressions
254 that will be removed from subject strings if fuzzy subject
255 simplification is selected."
257 :type '(repeat regexp))
259 (defcustom gnus-show-threads t
260 "*If non-nil, display threads in summary mode."
264 (defcustom gnus-thread-hide-subtree nil
265 "*If non-nil, hide all threads initially.
266 This can be a predicate specifier which says which threads to hide.
267 If threads are hidden, you have to run the command
268 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
269 to expose hidden threads."
271 :type '(radio (sexp :format "Non-nil\n"
272 :match (lambda (widget value)
273 (not (or (consp value) (functionp value))))
276 (sexp :tag "Predicate specifier" :size 0)))
278 (defcustom gnus-thread-hide-killed t
279 "*If non-nil, hide killed threads automatically."
283 (defcustom gnus-thread-ignore-subject t
284 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
285 If nil, articles that have different subjects from their parents will
286 start separate threads."
290 (defcustom gnus-thread-operation-ignore-subject t
291 "*If non-nil, subjects will be ignored when doing thread commands.
292 This affects commands like `gnus-summary-kill-thread' and
293 `gnus-summary-lower-thread'.
295 If this variable is nil, articles in the same thread with different
296 subjects will not be included in the operation in question. If this
297 variable is `fuzzy', only articles that have subjects that are fuzzily
298 equal will be included."
300 :type '(choice (const :tag "off" nil)
304 (defcustom gnus-thread-indent-level 4
305 "*Number that says how much each sub-thread should be indented."
309 (defcustom gnus-auto-extend-newsgroup t
310 "*If non-nil, extend newsgroup forward and backward when requested."
311 :group 'gnus-summary-choose
314 (defcustom gnus-auto-select-first t
315 "*If non-nil, select the article under point.
316 Which article this is is controlled by the `gnus-auto-select-subject'
319 If you want to prevent automatic selection of articles in some
320 newsgroups, set the variable to nil in `gnus-select-group-hook'."
321 :group 'gnus-group-select
322 :type '(choice (const :tag "none" nil)
323 (sexp :menu-tag "first" t)))
325 (defcustom gnus-auto-select-subject 'unread
326 "*Says what subject to place under point when entering a group.
328 This variable can either be the symbols `first' (place point on the
329 first subject), `unread' (place point on the subject line of the first
330 unread article), `best' (place point on the subject line of the
331 higest-scored article), `unseen' (place point on the subject line of
332 the first unseen article), 'unseen-or-unread' (place point on the subject
333 line of the first unseen article or, if all article have been seen, on the
334 subject line of the first unread article), or a function to be called to
335 place point on some subject line."
337 :group 'gnus-group-select
338 :type '(choice (const best)
342 (const unseen-or-unread)))
344 (defcustom gnus-dont-select-after-jump-to-other-group nil
345 "If non-nil, don't select the first unread article after entering the
346 other group by the command `gnus-summary-jump-to-other-group'. If nil,
347 it is depend on the value of `gnus-auto-select-first' whether to select
349 :group 'gnus-group-select
352 (defcustom gnus-auto-select-next t
353 "*If non-nil, offer to go to the next group from the end of the previous.
354 If the value is t and the next newsgroup is empty, Gnus will exit
355 summary mode and go back to group mode. If the value is neither nil
356 nor t, Gnus will select the following unread newsgroup. In
357 particular, if the value is the symbol `quietly', the next unread
358 newsgroup will be selected without any confirmation, and if it is
359 `almost-quietly', the next group will be selected without any
360 confirmation if you are located on the last article in the group.
361 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
362 will go to the next group without confirmation."
363 :group 'gnus-summary-maneuvering
364 :type '(choice (const :tag "off" nil)
366 (const almost-quietly)
367 (const slightly-quietly)
368 (sexp :menu-tag "on" t)))
370 (defcustom gnus-auto-select-same nil
371 "*If non-nil, select the next article with the same subject.
372 If there are no more articles with the same subject, go to
373 the first unread article."
374 :group 'gnus-summary-maneuvering
377 (defcustom gnus-auto-goto-ignores 'unfetched
378 "*Says how to handle unfetched articles when maneuvering.
380 This variable can either be the symbols nil (maneuver to any
381 article), `undownloaded' (maneuvering while unplugged ignores articles
382 that have not been fetched), `always-undownloaded' (maneuvering always
383 ignores articles that have not been fetched), `unfetched' (maneuvering
384 ignores articles whose headers have not been fetched).
386 NOTE: The list of unfetched articles will always be nil when plugged
387 and, when unplugged, a subset of the undownloaded article list."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "None" nil)
391 (const :tag "Undownloaded when unplugged" undownloaded)
392 (const :tag "Undownloaded" always-undownloaded)
393 (const :tag "Unfetched" unfetched)))
395 (defcustom gnus-summary-check-current nil
396 "*If non-nil, consider the current article when moving.
397 The \"unread\" movement commands will stay on the same line if the
398 current article is unread."
399 :group 'gnus-summary-maneuvering
402 (defcustom gnus-auto-center-summary 2
403 "*If non-nil, always center the current summary buffer.
404 In particular, if `vertical' do only vertical recentering. If non-nil
405 and non-`vertical', do both horizontal and vertical recentering."
406 :group 'gnus-summary-maneuvering
407 :type '(choice (const :tag "none" nil)
409 (integer :tag "height")
410 (sexp :menu-tag "both" t)))
412 (defvar gnus-auto-center-group t
413 "*If non-nil, always center the group buffer.")
415 (defcustom gnus-show-all-headers nil
416 "*If non-nil, don't hide any headers."
417 :group 'gnus-article-hiding
418 :group 'gnus-article-headers
421 (defcustom gnus-summary-ignore-duplicates nil
422 "*If non-nil, ignore articles with identical Message-ID headers."
426 (defcustom gnus-single-article-buffer t
427 "*If non-nil, display all articles in the same buffer.
428 If nil, each group will get its own article buffer."
429 :group 'gnus-article-various
432 (defcustom gnus-break-pages t
433 "*If non-nil, do page breaking on articles.
434 The page delimiter is specified by the `gnus-page-delimiter'
436 :group 'gnus-article-various
439 (defcustom gnus-show-mime t
440 "*If non-nil, do mime processing of articles.
441 The articles will simply be fed to the function given by
442 `gnus-article-display-method-for-mime'."
443 :group 'gnus-article-mime
446 (defcustom gnus-move-split-methods nil
447 "*Variable used to suggest where articles are to be moved to.
448 It uses the same syntax as the `gnus-split-methods' variable.
449 However, whereas `gnus-split-methods' specifies file names as targets,
450 this variable specifies group names."
451 :group 'gnus-summary-mail
452 :type '(repeat (choice (list :value (fun) function)
453 (cons :value ("" "") regexp (repeat string))
456 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
457 "Function used to compute default prefix for article move/copy/etc prompts.
458 The function should take one argument, a group name, and return a
459 string with the suggested prefix."
460 :group 'gnus-summary-mail
463 (defcustom gnus-unread-mark ?\ ;;;Whitespace
464 "*Mark used for unread articles."
465 :group 'gnus-summary-marks
468 (defcustom gnus-ticked-mark ?!
469 "*Mark used for ticked articles."
470 :group 'gnus-summary-marks
473 (defcustom gnus-dormant-mark ??
474 "*Mark used for dormant articles."
475 :group 'gnus-summary-marks
478 (defcustom gnus-del-mark ?r
479 "*Mark used for del'd articles."
480 :group 'gnus-summary-marks
483 (defcustom gnus-read-mark ?R
484 "*Mark used for read articles."
485 :group 'gnus-summary-marks
488 (defcustom gnus-expirable-mark ?E
489 "*Mark used for expirable articles."
490 :group 'gnus-summary-marks
493 (defcustom gnus-killed-mark ?K
494 "*Mark used for killed articles."
495 :group 'gnus-summary-marks
498 (defcustom gnus-spam-mark ?$
499 "*Mark used for spam articles."
500 :group 'gnus-summary-marks
503 (defcustom gnus-souped-mark ?F
504 "*Mark used for souped articles."
505 :group 'gnus-summary-marks
508 (defcustom gnus-kill-file-mark ?X
509 "*Mark used for articles killed by kill files."
510 :group 'gnus-summary-marks
513 (defcustom gnus-low-score-mark ?Y
514 "*Mark used for articles with a low score."
515 :group 'gnus-summary-marks
518 (defcustom gnus-catchup-mark ?C
519 "*Mark used for articles that are caught up."
520 :group 'gnus-summary-marks
523 (defcustom gnus-replied-mark ?A
524 "*Mark used for articles that have been replied to."
525 :group 'gnus-summary-marks
528 (defcustom gnus-forwarded-mark ?F
529 "*Mark used for articles that have been forwarded."
531 :group 'gnus-summary-marks
534 (defcustom gnus-recent-mark ?N
535 "*Mark used for articles that are recent."
536 :group 'gnus-summary-marks
539 (defcustom gnus-cached-mark ?*
540 "*Mark used for articles that are in the cache."
541 :group 'gnus-summary-marks
544 (defcustom gnus-saved-mark ?S
545 "*Mark used for articles that have been saved."
546 :group 'gnus-summary-marks
549 (defcustom gnus-unseen-mark ?.
550 "*Mark used for articles that haven't been seen."
552 :group 'gnus-summary-marks
555 (defcustom gnus-no-mark ?\ ;;;Whitespace
556 "*Mark used for articles that have no other secondary mark."
558 :group 'gnus-summary-marks
561 (defcustom gnus-ancient-mark ?O
562 "*Mark used for ancient articles."
563 :group 'gnus-summary-marks
566 (defcustom gnus-sparse-mark ?Q
567 "*Mark used for sparsely reffed articles."
568 :group 'gnus-summary-marks
571 (defcustom gnus-canceled-mark ?G
572 "*Mark used for canceled articles."
573 :group 'gnus-summary-marks
576 (defcustom gnus-duplicate-mark ?M
577 "*Mark used for duplicate articles."
578 :group 'gnus-summary-marks
581 (defcustom gnus-undownloaded-mark ?-
582 "*Mark used for articles that weren't downloaded."
583 :group 'gnus-summary-marks
586 (defcustom gnus-downloaded-mark ?+
587 "*Mark used for articles that were downloaded."
588 :group 'gnus-summary-marks
591 (defcustom gnus-downloadable-mark ?%
592 "*Mark used for articles that are to be downloaded."
593 :group 'gnus-summary-marks
596 (defcustom gnus-unsendable-mark ?=
597 "*Mark used for articles that won't be sent."
598 :group 'gnus-summary-marks
601 (defcustom gnus-score-over-mark ?+
602 "*Score mark used for articles with high scores."
603 :group 'gnus-summary-marks
606 (defcustom gnus-score-below-mark ?-
607 "*Score mark used for articles with low scores."
608 :group 'gnus-summary-marks
611 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
612 "*There is no thread under the article."
613 :group 'gnus-summary-marks
616 (defcustom gnus-not-empty-thread-mark ?=
617 "*There is a thread under the article."
618 :group 'gnus-summary-marks
621 (defcustom gnus-view-pseudo-asynchronously nil
622 "*If non-nil, Gnus will view pseudo-articles asynchronously."
623 :group 'gnus-extract-view
626 (defcustom gnus-auto-expirable-marks
627 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
628 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
629 gnus-souped-mark gnus-duplicate-mark)
630 "*The list of marks converted into expiration if a group is auto-expirable."
633 :type '(repeat character))
635 (defcustom gnus-inhibit-user-auto-expire t
636 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
641 (defcustom gnus-view-pseudos nil
642 "*If `automatic', pseudo-articles will be viewed automatically.
643 If `not-confirm', pseudos will be viewed automatically, and the user
644 will not be asked to confirm the command."
645 :group 'gnus-extract-view
646 :type '(choice (const :tag "off" nil)
648 (const not-confirm)))
650 (defcustom gnus-view-pseudos-separately t
651 "*If non-nil, one pseudo-article will be created for each file to be viewed.
652 If nil, all files that use the same viewing command will be given as a
653 list of parameters to that command."
654 :group 'gnus-extract-view
657 (defcustom gnus-insert-pseudo-articles t
658 "*If non-nil, insert pseudo-articles when decoding articles."
659 :group 'gnus-extract-view
662 (defcustom gnus-summary-dummy-line-format
664 "*The format specification for the dummy roots in the summary buffer.
665 It works along the same lines as a normal formatting string,
666 with some simple extensions.
670 General format specifiers can also be used.
671 See `(gnus)Formatting Variables'."
672 :link '(custom-manual "(gnus)Formatting Variables")
673 :group 'gnus-threading
676 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
677 "*The format specification for the summary mode line.
678 It works along the same lines as a normal formatting string,
679 with some simple extensions:
682 %p Unprefixed group name
683 %A Current article number
684 %z Current article score
686 %U Number of unread articles in the group
687 %e Number of unselected articles in the group
688 %Z A string with unread/unselected article counts
689 %g Shortish group name
690 %S Subject of the current article
692 %s Current score file name
693 %d Number of dormant articles
694 %r Number of articles that have been marked as read in this session
695 %E Number of articles expunged by the score files"
696 :group 'gnus-summary-format
699 (defcustom gnus-list-identifiers nil
700 "Regexp that matches list identifiers to be removed from subject.
701 This can also be a list of regexps."
703 :group 'gnus-summary-format
704 :group 'gnus-article-hiding
705 :type '(choice (const :tag "none" nil)
707 (repeat :value (".*") regexp)))
709 (defcustom gnus-summary-mark-below 0
710 "*Mark all articles with a score below this variable as read.
711 This variable is local to each summary buffer and usually set by the
713 :group 'gnus-score-default
716 (defun gnus-widget-reversible-match (widget value)
717 "Ignoring WIDGET, convert VALUE to internal form.
718 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
722 (eq (length value) 2)
723 (eq (nth 0 value) 'not)
724 (symbolp (nth 1 value)))))
726 (defun gnus-widget-reversible-to-internal (widget value)
727 "Ignoring WIDGET, convert VALUE to internal form.
728 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
729 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
733 (list (nth 1 value) t)))
735 (defun gnus-widget-reversible-to-external (widget value)
736 "Ignoring WIDGET, convert VALUE to external form.
737 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
738 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
741 (list 'not (nth 0 value))
744 (define-widget 'gnus-widget-reversible 'group
745 "A `group' that convert values."
746 :match 'gnus-widget-reversible-match
747 :value-to-internal 'gnus-widget-reversible-to-internal
748 :value-to-external 'gnus-widget-reversible-to-external)
750 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
751 "*List of functions used for sorting articles in the summary buffer.
753 Each function takes two articles and returns non-nil if the first
754 article should be sorted before the other. If you use more than one
755 function, the primary sort function should be the last. You should
756 probably always include `gnus-article-sort-by-number' in the list of
757 sorting functions -- preferably first. Also note that sorting by date
758 is often much slower than sorting by number, and the sorting order is
759 very similar. (Sorting by date means sorting by the time the message
760 was sent, sorting by number means sorting by arrival time.)
762 Each item can also be a list `(not F)' where F is a function;
763 this reverses the sort order.
765 Ready-made functions include `gnus-article-sort-by-number',
766 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
767 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
768 and `gnus-article-sort-by-score'.
770 When threading is turned on, the variable `gnus-thread-sort-functions'
771 controls how articles are sorted."
772 :group 'gnus-summary-sort
773 :type '(repeat (gnus-widget-reversible
774 (choice (function-item gnus-article-sort-by-number)
775 (function-item gnus-article-sort-by-author)
776 (function-item gnus-article-sort-by-subject)
777 (function-item gnus-article-sort-by-date)
778 (function-item gnus-article-sort-by-score)
779 (function-item gnus-article-sort-by-random)
780 (function :tag "other"))
781 (boolean :tag "Reverse order"))))
784 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
785 "*List of functions used for sorting threads in the summary buffer.
786 By default, threads are sorted by article number.
788 Each function takes two threads and returns non-nil if the first
789 thread should be sorted before the other. If you use more than one
790 function, the primary sort function should be the last. You should
791 probably always include `gnus-thread-sort-by-number' in the list of
792 sorting functions -- preferably first. Also note that sorting by date
793 is often much slower than sorting by number, and the sorting order is
794 very similar. (Sorting by date means sorting by the time the message
795 was sent, sorting by number means sorting by arrival time.)
797 Each list item can also be a list `(not F)' where F is a
798 function; this specifies reversed sort order.
800 Ready-made functions include `gnus-thread-sort-by-number',
801 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
802 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
803 `gnus-thread-sort-by-most-recent-number',
804 `gnus-thread-sort-by-most-recent-date',
805 `gnus-thread-sort-by-random', and
806 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
808 When threading is turned off, the variable
809 `gnus-article-sort-functions' controls how articles are sorted."
810 :group 'gnus-summary-sort
812 (gnus-widget-reversible
813 (choice (function-item gnus-thread-sort-by-number)
814 (function-item gnus-thread-sort-by-author)
815 (function-item gnus-thread-sort-by-subject)
816 (function-item gnus-thread-sort-by-date)
817 (function-item gnus-thread-sort-by-score)
818 (function-item gnus-thread-sort-by-most-recent-number)
819 (function-item gnus-thread-sort-by-most-recent-date)
820 (function-item gnus-thread-sort-by-random)
821 (function-item gnus-thread-sort-by-total-score)
822 (function :tag "other"))
823 (boolean :tag "Reverse order"))))
825 (defcustom gnus-thread-score-function '+
826 "*Function used for calculating the total score of a thread.
828 The function is called with the scores of the article and each
829 subthread and should then return the score of the thread.
831 Some functions you can use are `+', `max', or `min'."
832 :group 'gnus-summary-sort
835 (defcustom gnus-summary-expunge-below nil
836 "All articles that have a score less than this variable will be expunged.
837 This variable is local to the summary buffers."
838 :group 'gnus-score-default
839 :type '(choice (const :tag "off" nil)
842 (defcustom gnus-thread-expunge-below nil
843 "All threads that have a total score less than this variable will be expunged.
844 See `gnus-thread-score-function' for en explanation of what a
847 This variable is local to the summary buffers."
848 :group 'gnus-threading
849 :group 'gnus-score-default
850 :type '(choice (const :tag "off" nil)
853 (defcustom gnus-summary-mode-hook nil
854 "*A hook for Gnus summary mode.
855 This hook is run before any variables are set in the summary buffer."
856 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
857 :group 'gnus-summary-various
860 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
861 (when (featurep 'xemacs)
862 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
863 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
864 (add-hook 'gnus-summary-mode-hook
865 'gnus-xmas-switch-horizontal-scrollbar-off))
867 (defcustom gnus-summary-menu-hook nil
868 "*Hook run after the creation of the summary mode menu."
869 :group 'gnus-summary-visual
872 (defcustom gnus-summary-exit-hook nil
873 "*A hook called on exit from the summary buffer.
874 It will be called with point in the group buffer."
875 :group 'gnus-summary-exit
878 (defcustom gnus-summary-prepare-hook nil
879 "*A hook called after the summary buffer has been generated.
880 If you want to modify the summary buffer, you can use this hook."
881 :group 'gnus-summary-various
884 (defcustom gnus-summary-prepared-hook nil
885 "*A hook called as the last thing after the summary buffer has been generated."
886 :group 'gnus-summary-various
889 (defcustom gnus-summary-generate-hook nil
890 "*A hook run just before generating the summary buffer.
891 This hook is commonly used to customize threading variables and the
893 :group 'gnus-summary-various
896 (defcustom gnus-select-group-hook nil
897 "*A hook called when a newsgroup is selected.
899 If you'd like to simplify subjects like the
900 `gnus-summary-next-same-subject' command does, you can use the
903 (add-hook gnus-select-group-hook
905 (mapcar (lambda (header)
906 (mail-header-set-subject
908 (gnus-simplify-subject
909 (mail-header-subject header) 're-only)))
910 gnus-newsgroup-headers)))"
911 :group 'gnus-group-select
914 (defcustom gnus-select-article-hook nil
915 "*A hook called when an article is selected."
916 :group 'gnus-summary-choose
917 :options '(gnus-agent-fetch-selected-article)
920 (defcustom gnus-visual-mark-article-hook
921 (list 'gnus-highlight-selected-summary)
922 "*Hook run after selecting an article in the summary buffer.
923 It is meant to be used for highlighting the article in some way. It
924 is not run if `gnus-visual' is nil."
925 :group 'gnus-summary-visual
928 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
929 "*A hook called before parsing the headers."
933 (defcustom gnus-exit-group-hook nil
934 "*A hook called when exiting summary mode.
935 This hook is not called from the non-updating exit commands like `Q'."
939 (defcustom gnus-summary-update-hook
940 (list 'gnus-summary-highlight-line)
941 "*A hook called when a summary line is changed.
942 The hook will not be called if `gnus-visual' is nil.
944 The default function `gnus-summary-highlight-line' will
945 highlight the line according to the `gnus-summary-highlight'
947 :group 'gnus-summary-visual
950 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
951 "*A hook called when an article is selected for the first time.
952 The hook is intended to mark an article as read (or unread)
953 automatically when it is selected."
954 :group 'gnus-summary-choose
957 (defcustom gnus-group-no-more-groups-hook nil
958 "*A hook run when returning to group mode having no more (unread) groups."
959 :group 'gnus-group-select
962 (defcustom gnus-ps-print-hook nil
963 "*A hook run before ps-printing something from Gnus."
967 (defcustom gnus-summary-article-move-hook nil
968 "*A hook called after an article is moved, copied, respooled, or crossposted."
972 (defcustom gnus-summary-article-delete-hook nil
973 "*A hook called after an article is deleted."
977 (defcustom gnus-summary-article-expire-hook nil
978 "*A hook called after an article is expired."
982 (defcustom gnus-summary-display-arrow
983 (and (fboundp 'display-graphic-p)
985 "*If non-nil, display an arrow highlighting the current article."
990 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
991 "Face used for highlighting the current article in the summary buffer."
992 :group 'gnus-summary-visual
995 (defvar gnus-tmp-downloaded nil)
997 (defcustom gnus-summary-highlight
998 '(((eq mark gnus-canceled-mark)
999 . gnus-summary-cancelled-face)
1000 ((and uncached (> score default-high))
1001 . gnus-summary-high-undownloaded-face)
1002 ((and uncached (< score default-low))
1003 . gnus-summary-low-undownloaded-face)
1005 . gnus-summary-normal-undownloaded-face)
1006 ((and (> score default-high)
1007 (or (eq mark gnus-dormant-mark)
1008 (eq mark gnus-ticked-mark)))
1009 . gnus-summary-high-ticked-face)
1010 ((and (< score default-low)
1011 (or (eq mark gnus-dormant-mark)
1012 (eq mark gnus-ticked-mark)))
1013 . gnus-summary-low-ticked-face)
1014 ((or (eq mark gnus-dormant-mark)
1015 (eq mark gnus-ticked-mark))
1016 . gnus-summary-normal-ticked-face)
1017 ((and (> score default-high) (eq mark gnus-ancient-mark))
1018 . gnus-summary-high-ancient-face)
1019 ((and (< score default-low) (eq mark gnus-ancient-mark))
1020 . gnus-summary-low-ancient-face)
1021 ((eq mark gnus-ancient-mark)
1022 . gnus-summary-normal-ancient-face)
1023 ((and (> score default-high) (eq mark gnus-unread-mark))
1024 . gnus-summary-high-unread-face)
1025 ((and (< score default-low) (eq mark gnus-unread-mark))
1026 . gnus-summary-low-unread-face)
1027 ((eq mark gnus-unread-mark)
1028 . gnus-summary-normal-unread-face)
1029 ((> score default-high)
1030 . gnus-summary-high-read-face)
1031 ((< score default-low)
1032 . gnus-summary-low-read-face)
1034 . gnus-summary-normal-read-face))
1035 "*Controls the highlighting of summary buffer lines.
1037 A list of (FORM . FACE) pairs. When deciding how a a particular
1038 summary line should be displayed, each form is evaluated. The content
1039 of the face field after the first true form is used. You can change
1040 how those summary lines are displayed, by editing the face field.
1042 You can use the following variables in the FORM field.
1044 score: The article's score
1045 default: The default article score.
1046 default-high: The default score for high scored articles.
1047 default-low: The default score for low scored articles.
1048 below: The score below which articles are automatically marked as read.
1049 mark: The article's mark.
1050 uncached: Non-nil if the article is uncached."
1051 :group 'gnus-summary-visual
1052 :type '(repeat (cons (sexp :tag "Form" nil)
1055 (defcustom gnus-alter-header-function nil
1056 "Function called to allow alteration of article header structures.
1057 The function is called with one parameter, the article header vector,
1058 which it may alter in any way."
1059 :type '(choice (const :tag "None" nil)
1061 :group 'gnus-summary)
1063 (defvar gnus-decode-encoded-word-function
1064 (mime-find-field-decoder 'From 'nov)
1065 "Variable that says which function should be used to decode a string with encoded words.")
1067 (defcustom gnus-extra-headers '(To Newsgroups)
1068 "*Extra headers to parse."
1070 :group 'gnus-summary
1071 :type '(repeat symbol))
1073 (defcustom gnus-ignored-from-addresses
1074 (and user-mail-address (regexp-quote user-mail-address))
1075 "*Regexp of From headers that may be suppressed in favor of To headers."
1077 :group 'gnus-summary
1080 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1081 "List of charsets that should be ignored.
1082 When these charsets are used in the \"charset\" parameter, the
1083 default charset will be used instead."
1085 :type '(repeat symbol)
1086 :group 'gnus-charset)
1088 (gnus-define-group-parameter
1092 "Return the ignored charsets of GROUP."
1093 :variable gnus-group-ignored-charsets-alist
1095 '(("alt\\.chinese\\.text" iso-8859-1))
1097 "Alist of regexps (to match group names) and charsets that should be ignored.
1098 When these charsets are used in the \"charset\" parameter, the
1099 default charset will be used instead."
1100 :variable-group gnus-charset
1101 :variable-type '(repeat (cons (regexp :tag "Group")
1103 :parameter-type '(choice :tag "Ignored charsets"
1106 :parameter-document "\
1107 List of charsets that should be ignored.
1109 When these charsets are used in the \"charset\" parameter, the
1110 default charset will be used instead.")
1112 (defcustom gnus-group-highlight-words-alist nil
1113 "Alist of group regexps and highlight regexps.
1114 This variable uses the same syntax as `gnus-emphasis-alist'."
1116 :type '(repeat (cons (regexp :tag "Group")
1117 (repeat (list (regexp :tag "Highlight regexp")
1118 (number :tag "Group for entire word" 0)
1119 (number :tag "Group for displayed part" 0)
1121 gnus-emphasis-highlight-words)))))
1122 :group 'gnus-summary-visual)
1124 (defcustom gnus-use-wheel nil
1125 "Use Intelli-mouse on summary movement"
1127 :group 'gnus-summary-maneuvering)
1129 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1130 "Amount to scroll messages by spinning the mouse wheel.
1131 This is actually a cons cell, where the first item is the amount to scroll
1132 on a normal wheel event, and the second is the amount to scroll when the
1133 wheel is moved with the shift key depressed."
1134 :type '(cons (integer :tag "Shift") integer)
1135 :group 'gnus-summary-maneuvering)
1137 (defcustom gnus-wheel-edge-resistance 2
1138 "How hard it should be to change the current article
1139 by moving the mouse over the edge of the article window."
1141 :group 'gnus-summary-maneuvering)
1143 (defcustom gnus-summary-show-article-charset-alist
1145 "Alist of number and charset.
1146 The article will be shown with the charset corresponding to the
1148 For example: ((1 . cn-gb-2312) (2 . big5))."
1150 :type '(repeat (cons (number :tag "Argument" 1)
1151 (symbol :tag "Charset")))
1152 :group 'gnus-charset)
1154 (defcustom gnus-preserve-marks t
1155 "Whether marks are preserved when moving, copying and respooling messages."
1158 :group 'gnus-summary-marks)
1160 (defcustom gnus-alter-articles-to-read-function nil
1161 "Function to be called to alter the list of articles to be selected."
1162 :type '(choice (const nil) function)
1163 :group 'gnus-summary)
1165 (defcustom gnus-orphan-score nil
1166 "*All orphans get this score added. Set in the score file."
1167 :group 'gnus-score-default
1168 :type '(choice (const nil)
1171 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1172 "*A regexp to match MIME parts when saving multiple parts of a
1173 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1174 This regexp will be used by default when prompting the user for which
1175 type of files to save."
1176 :group 'gnus-summary
1179 (defcustom gnus-read-all-available-headers nil
1180 "Whether Gnus should parse all headers made available to it.
1181 This is mostly relevant for slow back ends where the user may
1182 wish to widen the summary buffer to include all headers
1183 that were fetched. Say, for nnultimate groups."
1184 :group 'gnus-summary
1185 :type '(choice boolean regexp))
1187 (defcustom gnus-summary-muttprint-program "muttprint"
1188 "Command (and optional arguments) used to run Muttprint."
1190 :group 'gnus-summary
1193 (defcustom gnus-article-loose-mime t
1194 "If non-nil, don't require MIME-Version header.
1195 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1196 supply the MIME-Version header or deliberately strip it from the mail.
1197 If non-nil (the default), Gnus will treat some articles as MIME
1198 even if the MIME-Version header is missing."
1201 :group 'gnus-article-mime)
1203 (defcustom gnus-article-emulate-mime t
1204 "If non-nil, use MIME emulation for uuencode and the like.
1205 This means that Gnus will search message bodies for text that look
1206 like uuencoded bits, yEncoded bits, and so on, and present that using
1207 the normal Gnus MIME machinery."
1210 :group 'gnus-article-mime)
1212 ;;; Internal variables
1214 (defvar gnus-summary-display-cache nil)
1215 (defvar gnus-article-mime-handles nil)
1216 (defvar gnus-article-decoded-p nil)
1217 (defvar gnus-article-charset nil)
1218 (defvar gnus-article-ignored-charsets nil)
1219 (defvar gnus-scores-exclude-files nil)
1220 (defvar gnus-page-broken nil)
1222 (defvar gnus-original-article nil)
1223 (defvar gnus-article-internal-prepare-hook nil)
1224 (defvar gnus-newsgroup-process-stack nil)
1226 (defvar gnus-thread-indent-array nil)
1227 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1228 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1229 "Function called to sort the articles within a thread after it has been gathered together.")
1231 (defvar gnus-summary-save-parts-type-history nil)
1232 (defvar gnus-summary-save-parts-last-directory nil)
1234 ;; Avoid highlighting in kill files.
1235 (defvar gnus-summary-inhibit-highlight nil)
1236 (defvar gnus-newsgroup-selected-overlay nil)
1237 (defvar gnus-inhibit-limiting nil)
1238 (defvar gnus-newsgroup-adaptive-score-file nil)
1239 (defvar gnus-current-score-file nil)
1240 (defvar gnus-current-move-group nil)
1241 (defvar gnus-current-copy-group nil)
1242 (defvar gnus-current-crosspost-group nil)
1243 (defvar gnus-newsgroup-display nil)
1245 (defvar gnus-newsgroup-dependencies nil)
1246 (defvar gnus-newsgroup-adaptive nil)
1247 (defvar gnus-summary-display-article-function nil)
1248 (defvar gnus-summary-highlight-line-function nil
1249 "Function called after highlighting a summary line.")
1251 (defvar gnus-summary-line-format-alist
1252 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1253 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1254 (?s gnus-tmp-subject-or-nil ?s)
1255 (?n gnus-tmp-name ?s)
1256 (?A (std11-address-string
1257 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1258 (?a (or (std11-full-name-string
1259 (car (mime-entity-read-field gnus-tmp-header 'From)))
1261 (?F gnus-tmp-from ?s)
1262 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1263 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1264 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1265 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1266 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1267 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1268 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1269 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1270 (?L gnus-tmp-lines ?s)
1271 (?O gnus-tmp-downloaded ?c)
1272 (?I gnus-tmp-indentation ?s)
1273 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1274 (?R gnus-tmp-replied ?c)
1275 (?\[ gnus-tmp-opening-bracket ?c)
1276 (?\] gnus-tmp-closing-bracket ?c)
1277 (?\> (make-string gnus-tmp-level ? ) ?s)
1278 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1279 (?i gnus-tmp-score ?d)
1280 (?z gnus-tmp-score-char ?c)
1281 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1282 (?U gnus-tmp-unread ?c)
1283 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1285 (?t (gnus-summary-number-of-articles-in-thread
1286 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1288 (?e (gnus-summary-number-of-articles-in-thread
1289 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1291 (?u gnus-tmp-user-defined ?s)
1292 (?P (gnus-pick-line-number) ?d)
1293 (?B gnus-tmp-thread-tree-header-string ?s)
1294 (user-date (gnus-user-date
1295 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1296 "An alist of format specifications that can appear in summary lines.
1297 These are paired with what variables they correspond with, along with
1298 the type of the variable (string, integer, character, etc).")
1300 (defvar gnus-summary-dummy-line-format-alist
1301 `((?S gnus-tmp-subject ?s)
1302 (?N gnus-tmp-number ?d)
1303 (?u gnus-tmp-user-defined ?s)))
1305 (defvar gnus-summary-mode-line-format-alist
1306 `((?G gnus-tmp-group-name ?s)
1307 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1308 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1309 (?A gnus-tmp-article-number ?d)
1310 (?Z gnus-tmp-unread-and-unselected ?s)
1311 (?V gnus-version ?s)
1312 (?U gnus-tmp-unread-and-unticked ?d)
1313 (?S gnus-tmp-subject ?s)
1314 (?e gnus-tmp-unselected ?d)
1315 (?u gnus-tmp-user-defined ?s)
1316 (?d (length gnus-newsgroup-dormant) ?d)
1317 (?t (length gnus-newsgroup-marked) ?d)
1318 (?h (length gnus-newsgroup-spam-marked) ?d)
1319 (?r (length gnus-newsgroup-reads) ?d)
1320 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1321 (?E gnus-newsgroup-expunged-tally ?d)
1322 (?s (gnus-current-score-file-nondirectory) ?s)))
1324 (defvar gnus-last-search-regexp nil
1325 "Default regexp for article search command.")
1327 (defvar gnus-summary-search-article-matched-data nil
1328 "Last matched data of article search command. It is the local variable
1329 in `gnus-article-buffer' which consists of the list of start position,
1330 end position and text.")
1332 (defvar gnus-last-shell-command nil
1333 "Default shell command on article.")
1335 (defvar gnus-newsgroup-agentized nil
1336 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1337 (defvar gnus-newsgroup-begin nil)
1338 (defvar gnus-newsgroup-end nil)
1339 (defvar gnus-newsgroup-last-rmail nil)
1340 (defvar gnus-newsgroup-last-mail nil)
1341 (defvar gnus-newsgroup-last-folder nil)
1342 (defvar gnus-newsgroup-last-file nil)
1343 (defvar gnus-newsgroup-auto-expire nil)
1344 (defvar gnus-newsgroup-active nil)
1346 (defvar gnus-newsgroup-data nil)
1347 (defvar gnus-newsgroup-data-reverse nil)
1348 (defvar gnus-newsgroup-limit nil)
1349 (defvar gnus-newsgroup-limits nil)
1350 (defvar gnus-summary-use-undownloaded-faces nil)
1352 (defvar gnus-newsgroup-unreads nil
1353 "Sorted list of unread articles in the current newsgroup.")
1355 (defvar gnus-newsgroup-unselected nil
1356 "Sorted list of unselected unread articles in the current newsgroup.")
1358 (defvar gnus-newsgroup-reads nil
1359 "Alist of read articles and article marks in the current newsgroup.")
1361 (defvar gnus-newsgroup-expunged-tally nil)
1363 (defvar gnus-newsgroup-marked nil
1364 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1366 (defvar gnus-newsgroup-spam-marked nil
1367 "List of ranges of articles that have been marked as spam.")
1369 (defvar gnus-newsgroup-killed nil
1370 "List of ranges of articles that have been through the scoring process.")
1372 (defvar gnus-newsgroup-cached nil
1373 "Sorted list of articles that come from the article cache.")
1375 (defvar gnus-newsgroup-saved nil
1376 "List of articles that have been saved.")
1378 (defvar gnus-newsgroup-kill-headers nil)
1380 (defvar gnus-newsgroup-replied nil
1381 "List of articles that have been replied to in the current newsgroup.")
1383 (defvar gnus-newsgroup-forwarded nil
1384 "List of articles that have been forwarded in the current newsgroup.")
1386 (defvar gnus-newsgroup-recent nil
1387 "List of articles that have are recent in the current newsgroup.")
1389 (defvar gnus-newsgroup-expirable nil
1390 "Sorted list of articles in the current newsgroup that can be expired.")
1392 (defvar gnus-newsgroup-processable nil
1393 "List of articles in the current newsgroup that can be processed.")
1395 (defvar gnus-newsgroup-downloadable nil
1396 "Sorted list of articles in the current newsgroup that can be processed.")
1398 (defvar gnus-newsgroup-unfetched nil
1399 "Sorted list of articles in the current newsgroup whose headers have
1400 not been fetched into the agent.
1402 This list will always be a subset of gnus-newsgroup-undownloaded.")
1404 (defvar gnus-newsgroup-undownloaded nil
1405 "List of articles in the current newsgroup that haven't been downloaded.")
1407 (defvar gnus-newsgroup-unsendable nil
1408 "List of articles in the current newsgroup that won't be sent.")
1410 (defvar gnus-newsgroup-bookmarks nil
1411 "List of articles in the current newsgroup that have bookmarks.")
1413 (defvar gnus-newsgroup-dormant nil
1414 "Sorted list of dormant articles in the current newsgroup.")
1416 (defvar gnus-newsgroup-unseen nil
1417 "List of unseen articles in the current newsgroup.")
1419 (defvar gnus-newsgroup-seen nil
1420 "Range of seen articles in the current newsgroup.")
1422 (defvar gnus-newsgroup-articles nil
1423 "List of articles in the current newsgroup.")
1425 (defvar gnus-newsgroup-scored nil
1426 "List of scored articles in the current newsgroup.")
1428 (defvar gnus-newsgroup-incorporated nil
1429 "List of incorporated articles in the current newsgroup.")
1431 (defvar gnus-newsgroup-headers nil
1432 "List of article headers in the current newsgroup.")
1434 (defvar gnus-newsgroup-threads nil)
1436 (defvar gnus-newsgroup-prepared nil
1437 "Whether the current group has been prepared properly.")
1439 (defvar gnus-newsgroup-ancient nil
1440 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1442 (defvar gnus-newsgroup-sparse nil)
1444 (defvar gnus-current-article nil)
1445 (defvar gnus-article-current nil)
1446 (defvar gnus-current-headers nil)
1447 (defvar gnus-have-all-headers nil)
1448 (defvar gnus-last-article nil)
1449 (defvar gnus-newsgroup-history nil)
1450 (defvar gnus-newsgroup-charset nil)
1451 (defvar gnus-newsgroup-ephemeral-charset nil)
1452 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1454 (defvar gnus-article-before-search nil)
1456 (defvar gnus-summary-local-variables
1457 '(gnus-newsgroup-name
1458 gnus-newsgroup-begin gnus-newsgroup-end
1459 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1460 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1461 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1462 gnus-newsgroup-unselected gnus-newsgroup-marked
1463 gnus-newsgroup-spam-marked
1464 gnus-newsgroup-reads gnus-newsgroup-saved
1465 gnus-newsgroup-replied gnus-newsgroup-forwarded
1466 gnus-newsgroup-recent
1467 gnus-newsgroup-expirable
1468 gnus-newsgroup-processable gnus-newsgroup-killed
1469 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1470 gnus-newsgroup-unfetched
1471 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1472 gnus-newsgroup-seen gnus-newsgroup-articles
1473 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1474 gnus-newsgroup-headers gnus-newsgroup-threads
1475 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1476 gnus-current-article gnus-current-headers gnus-have-all-headers
1477 gnus-last-article gnus-article-internal-prepare-hook
1478 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1479 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1480 gnus-thread-expunge-below
1481 gnus-score-alist gnus-current-score-file
1482 (gnus-summary-expunge-below . global)
1483 (gnus-summary-mark-below . global)
1484 (gnus-orphan-score . global)
1485 gnus-newsgroup-active gnus-scores-exclude-files
1486 gnus-newsgroup-history gnus-newsgroup-ancient
1487 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1488 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1489 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1490 (gnus-newsgroup-expunged-tally . 0)
1491 gnus-cache-removable-articles gnus-newsgroup-cached
1492 gnus-newsgroup-data gnus-newsgroup-data-reverse
1493 gnus-newsgroup-limit gnus-newsgroup-limits
1494 gnus-newsgroup-charset gnus-newsgroup-display
1495 gnus-summary-use-undownloaded-faces
1496 gnus-newsgroup-incorporated)
1497 "Variables that are buffer-local to the summary buffers.")
1499 (defvar gnus-newsgroup-variables nil
1500 "A list of variables that have separate values in different newsgroups.
1501 A list of newsgroup (summary buffer) local variables, or cons of
1502 variables and their default expressions to be evalled (when the default
1503 values are not nil), that should be made global while the summary buffer
1506 Note: The default expressions will be evaluated (using function `eval')
1507 before assignment to the local variable rather than just assigned to it.
1508 If the default expression is the symbol `global', that symbol will not
1509 be evaluated but the global value of the local variable will be used
1512 These variables can be used to set variables in the group parameters
1513 while still allowing them to affect operations done in other buffers.
1516 \(setq gnus-newsgroup-variables
1517 '(message-use-followup-to
1518 (gnus-visible-headers .
1519 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1522 ;; Byte-compiler warning.
1524 ;; Bind features so that require will believe that gnus-sum has
1525 ;; already been loaded (avoids infinite recursion)
1526 (let ((features (cons 'gnus-sum features)))
1527 ;; Several of the declarations in gnus-sum are needed to load the
1528 ;; following files. Right now, these definitions have been
1529 ;; compiled but not defined (evaluated). We could either do a
1530 ;; eval-and-compile about all of the declarations or evaluate the
1532 (if (boundp 'gnus-newsgroup-variables)
1534 (load "gnus-sum.el" t t t))
1536 (require 'gnus-art)))
1538 ;; Subject simplification.
1540 (defun gnus-simplify-whitespace (str)
1541 "Remove excessive whitespace from STR."
1543 (while (string-match "[ \t][ \t]+" str)
1544 (setq str (concat (substring str 0 (match-beginning 0))
1546 (substring str (match-end 0)))))
1548 (when (string-match "^[ \t]+" str)
1549 (setq str (substring str (match-end 0))))
1551 (when (string-match "[ \t]+$" str)
1552 (setq str (substring str 0 (match-beginning 0))))
1555 (defun gnus-simplify-all-whitespace (str)
1556 "Remove all whitespace from STR."
1557 (while (string-match "[ \t\n]+" str)
1558 (setq str (replace-match "" nil nil str)))
1561 (defsubst gnus-simplify-subject-re (subject)
1562 "Remove \"Re:\" from subject lines."
1563 (if (string-match message-subject-re-regexp subject)
1564 (substring subject (match-end 0))
1567 (defun gnus-simplify-subject (subject &optional re-only)
1568 "Remove `Re:' and words in parentheses.
1569 If RE-ONLY is non-nil, strip leading `Re:'s only."
1570 (let ((case-fold-search t)) ;Ignore case.
1571 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1572 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1573 (setq subject (substring subject (match-end 0))))
1574 ;; Remove uninteresting prefixes.
1575 (when (and (not re-only)
1576 gnus-simplify-ignored-prefixes
1577 (string-match gnus-simplify-ignored-prefixes subject))
1578 (setq subject (substring subject (match-end 0))))
1579 ;; Remove words in parentheses from end.
1581 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1582 (setq subject (substring subject 0 (match-beginning 0)))))
1583 ;; Return subject string.
1586 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1588 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1589 (goto-char (point-min))
1590 (while (re-search-forward regexp nil t)
1591 (replace-match (or newtext ""))))
1593 (defun gnus-simplify-buffer-fuzzy ()
1594 "Simplify string in the buffer fuzzily.
1595 The string in the accessible portion of the current buffer is simplified.
1596 It is assumed to be a single-line subject.
1597 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1598 matter is removed. Additional things can be deleted by setting
1599 `gnus-simplify-subject-fuzzy-regexp'."
1600 (let ((case-fold-search t)
1602 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1604 (while (not (eq modified-tick (buffer-modified-tick)))
1605 (setq modified-tick (buffer-modified-tick))
1607 ((listp gnus-simplify-subject-fuzzy-regexp)
1608 (mapcar 'gnus-simplify-buffer-fuzzy-step
1609 gnus-simplify-subject-fuzzy-regexp))
1610 (gnus-simplify-subject-fuzzy-regexp
1611 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1612 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1613 (gnus-simplify-buffer-fuzzy-step
1614 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1615 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1617 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1618 (gnus-simplify-buffer-fuzzy-step " +" " ")
1619 (gnus-simplify-buffer-fuzzy-step " $")
1620 (gnus-simplify-buffer-fuzzy-step "^ +")))
1622 (defun gnus-simplify-subject-fuzzy (subject)
1623 "Simplify a subject string fuzzily.
1624 See `gnus-simplify-buffer-fuzzy' for details."
1626 (gnus-set-work-buffer)
1627 (let ((case-fold-search t))
1628 ;; Remove uninteresting prefixes.
1629 (when (and gnus-simplify-ignored-prefixes
1630 (string-match gnus-simplify-ignored-prefixes subject))
1631 (setq subject (substring subject (match-end 0))))
1633 (inline (gnus-simplify-buffer-fuzzy))
1636 (defsubst gnus-simplify-subject-fully (subject)
1637 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1639 (gnus-simplify-subject-functions
1640 (gnus-map-function gnus-simplify-subject-functions subject))
1641 ((null gnus-summary-gather-subject-limit)
1642 (gnus-simplify-subject-re subject))
1643 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1644 (gnus-simplify-subject-fuzzy subject))
1645 ((numberp gnus-summary-gather-subject-limit)
1646 (gnus-limit-string (gnus-simplify-subject-re subject)
1647 gnus-summary-gather-subject-limit))
1651 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1652 "Check whether two subjects are equal.
1653 If optional argument SIMPLE-FIRST is t, first argument is already
1656 ((null simple-first)
1657 (equal (gnus-simplify-subject-fully s1)
1658 (gnus-simplify-subject-fully s2)))
1661 (gnus-simplify-subject-fully s2)))))
1663 (defun gnus-summary-bubble-group ()
1664 "Increase the score of the current group.
1665 This is a handy function to add to `gnus-summary-exit-hook' to
1666 increase the score of each group you read."
1667 (gnus-group-add-score gnus-newsgroup-name))
1671 ;;; Gnus summary mode
1674 (put 'gnus-summary-mode 'mode-class 'special)
1676 (defvar gnus-article-commands-menu)
1678 ;; Non-orthogonal keys
1680 (gnus-define-keys gnus-summary-mode-map
1681 " " gnus-summary-next-page
1682 "\177" gnus-summary-prev-page
1683 [delete] gnus-summary-prev-page
1684 [backspace] gnus-summary-prev-page
1685 "\r" gnus-summary-scroll-up
1686 "\M-\r" gnus-summary-scroll-down
1687 "n" gnus-summary-next-unread-article
1688 "p" gnus-summary-prev-unread-article
1689 "N" gnus-summary-next-article
1690 "P" gnus-summary-prev-article
1691 "\M-\C-n" gnus-summary-next-same-subject
1692 "\M-\C-p" gnus-summary-prev-same-subject
1693 "\M-n" gnus-summary-next-unread-subject
1694 "\M-p" gnus-summary-prev-unread-subject
1695 "." gnus-summary-first-unread-article
1696 "," gnus-summary-best-unread-article
1697 "\M-s" gnus-summary-search-article-forward
1698 "\M-r" gnus-summary-search-article-backward
1699 "<" gnus-summary-beginning-of-article
1700 ">" gnus-summary-end-of-article
1701 "j" gnus-summary-goto-article
1702 "^" gnus-summary-refer-parent-article
1703 "\M-^" gnus-summary-refer-article
1704 "u" gnus-summary-tick-article-forward
1705 "!" gnus-summary-tick-article-forward
1706 "U" gnus-summary-tick-article-backward
1707 "d" gnus-summary-mark-as-read-forward
1708 "D" gnus-summary-mark-as-read-backward
1709 "E" gnus-summary-mark-as-expirable
1710 "\M-u" gnus-summary-clear-mark-forward
1711 "\M-U" gnus-summary-clear-mark-backward
1712 "k" gnus-summary-kill-same-subject-and-select
1713 "\C-k" gnus-summary-kill-same-subject
1714 "\M-\C-k" gnus-summary-kill-thread
1715 "\M-\C-l" gnus-summary-lower-thread
1716 "e" gnus-summary-edit-article
1717 "#" gnus-summary-mark-as-processable
1718 "\M-#" gnus-summary-unmark-as-processable
1719 "\M-\C-t" gnus-summary-toggle-threads
1720 "\M-\C-s" gnus-summary-show-thread
1721 "\M-\C-h" gnus-summary-hide-thread
1722 "\M-\C-f" gnus-summary-next-thread
1723 "\M-\C-b" gnus-summary-prev-thread
1724 [(meta down)] gnus-summary-next-thread
1725 [(meta up)] gnus-summary-prev-thread
1726 "\M-\C-u" gnus-summary-up-thread
1727 "\M-\C-d" gnus-summary-down-thread
1728 "&" gnus-summary-execute-command
1729 "c" gnus-summary-catchup-and-exit
1730 "\C-w" gnus-summary-mark-region-as-read
1731 "\C-t" gnus-summary-toggle-truncation
1732 "?" gnus-summary-mark-as-dormant
1733 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1734 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1735 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1736 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1737 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1738 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1739 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1740 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1741 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1742 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1743 "=" gnus-summary-expand-window
1744 "\C-x\C-s" gnus-summary-reselect-current-group
1745 "\M-g" gnus-summary-rescan-group
1746 "w" gnus-summary-stop-page-breaking
1747 "\C-c\C-r" gnus-summary-caesar-message
1748 "\M-t" gnus-summary-toggle-mime
1749 "f" gnus-summary-followup
1750 "F" gnus-summary-followup-with-original
1751 "C" gnus-summary-cancel-article
1752 "r" gnus-summary-reply
1753 "R" gnus-summary-reply-with-original
1754 "\C-c\C-f" gnus-summary-mail-forward
1755 "o" gnus-summary-save-article
1756 "\C-o" gnus-summary-save-article-mail
1757 "|" gnus-summary-pipe-output
1758 "\M-k" gnus-summary-edit-local-kill
1759 "\M-K" gnus-summary-edit-global-kill
1761 "\C-c\C-d" gnus-summary-describe-group
1762 "q" gnus-summary-exit
1763 "Q" gnus-summary-exit-no-update
1764 "\C-c\C-i" gnus-info-find-node
1765 gnus-mouse-2 gnus-mouse-pick-article
1766 "m" gnus-summary-mail-other-window
1767 "a" gnus-summary-post-news
1768 "i" gnus-summary-news-other-window
1769 "x" gnus-summary-limit-to-unread
1770 "s" gnus-summary-isearch-article
1771 "t" gnus-summary-toggle-header
1772 "g" gnus-summary-show-article
1773 "l" gnus-summary-goto-last-article
1774 "v" gnus-summary-preview-mime-message
1775 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1776 "\C-d" gnus-summary-enter-digest-group
1777 "\M-\C-d" gnus-summary-read-document
1778 "\M-\C-e" gnus-summary-edit-parameters
1779 "\M-\C-a" gnus-summary-customize-parameters
1781 "\C-c\C-n" gnus-namazu-search
1782 "*" gnus-cache-enter-article
1783 "\M-*" gnus-cache-remove-article
1784 "\M-&" gnus-summary-universal-argument
1785 "\C-l" gnus-recenter
1786 "I" gnus-summary-increase-score
1787 "L" gnus-summary-lower-score
1788 "\M-i" gnus-symbolic-argument
1789 "h" gnus-summary-select-article-buffer
1791 "V" gnus-summary-score-map
1792 "X" gnus-uu-extract-map
1793 "S" gnus-summary-send-map)
1795 ;; Sort of orthogonal keymap
1796 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1797 "t" gnus-summary-tick-article-forward
1798 "!" gnus-summary-tick-article-forward
1799 "d" gnus-summary-mark-as-read-forward
1800 "r" gnus-summary-mark-as-read-forward
1801 "c" gnus-summary-clear-mark-forward
1802 " " gnus-summary-clear-mark-forward
1803 "e" gnus-summary-mark-as-expirable
1804 "x" gnus-summary-mark-as-expirable
1805 "?" gnus-summary-mark-as-dormant
1806 "b" gnus-summary-set-bookmark
1807 "B" gnus-summary-remove-bookmark
1808 "#" gnus-summary-mark-as-processable
1809 "\M-#" gnus-summary-unmark-as-processable
1810 "S" gnus-summary-limit-include-expunged
1811 "C" gnus-summary-catchup
1812 "H" gnus-summary-catchup-to-here
1813 "h" gnus-summary-catchup-from-here
1814 "\C-c" gnus-summary-catchup-all
1815 "k" gnus-summary-kill-same-subject-and-select
1816 "K" gnus-summary-kill-same-subject
1817 "P" gnus-uu-mark-map)
1819 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1820 "c" gnus-summary-clear-above
1821 "u" gnus-summary-tick-above
1822 "m" gnus-summary-mark-above
1823 "k" gnus-summary-kill-below)
1825 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1826 "/" gnus-summary-limit-to-subject
1827 "n" gnus-summary-limit-to-articles
1828 "w" gnus-summary-pop-limit
1829 "s" gnus-summary-limit-to-subject
1830 "a" gnus-summary-limit-to-author
1831 "u" gnus-summary-limit-to-unread
1832 "m" gnus-summary-limit-to-marks
1833 "M" gnus-summary-limit-exclude-marks
1834 "v" gnus-summary-limit-to-score
1835 "*" gnus-summary-limit-include-cached
1836 "D" gnus-summary-limit-include-dormant
1837 "T" gnus-summary-limit-include-thread
1838 "d" gnus-summary-limit-exclude-dormant
1839 "t" gnus-summary-limit-to-age
1840 "." gnus-summary-limit-to-unseen
1841 "x" gnus-summary-limit-to-extra
1842 "p" gnus-summary-limit-to-display-predicate
1843 "E" gnus-summary-limit-include-expunged
1844 "c" gnus-summary-limit-exclude-childless-dormant
1845 "C" gnus-summary-limit-mark-excluded-as-read
1846 "o" gnus-summary-insert-old-articles
1847 "N" gnus-summary-insert-new-articles
1848 "r" gnus-summary-limit-to-replied)
1850 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1851 "n" gnus-summary-next-unread-article
1852 "p" gnus-summary-prev-unread-article
1853 "N" gnus-summary-next-article
1854 "P" gnus-summary-prev-article
1855 "\C-n" gnus-summary-next-same-subject
1856 "\C-p" gnus-summary-prev-same-subject
1857 "\M-n" gnus-summary-next-unread-subject
1858 "\M-p" gnus-summary-prev-unread-subject
1859 "f" gnus-summary-first-unread-article
1860 "b" gnus-summary-best-unread-article
1861 "j" gnus-summary-goto-article
1862 "g" gnus-summary-goto-subject
1863 "l" gnus-summary-goto-last-article
1864 "o" gnus-summary-pop-article)
1866 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1867 "k" gnus-summary-kill-thread
1868 "l" gnus-summary-lower-thread
1869 "i" gnus-summary-raise-thread
1870 "T" gnus-summary-toggle-threads
1871 "t" gnus-summary-rethread-current
1872 "^" gnus-summary-reparent-thread
1873 "s" gnus-summary-show-thread
1874 "S" gnus-summary-show-all-threads
1875 "h" gnus-summary-hide-thread
1876 "H" gnus-summary-hide-all-threads
1877 "n" gnus-summary-next-thread
1878 "p" gnus-summary-prev-thread
1879 "u" gnus-summary-up-thread
1880 "o" gnus-summary-top-thread
1881 "d" gnus-summary-down-thread
1882 "#" gnus-uu-mark-thread
1883 "\M-#" gnus-uu-unmark-thread)
1885 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1886 "g" gnus-summary-prepare
1887 "c" gnus-summary-insert-cached-articles
1888 "d" gnus-summary-insert-dormant-articles)
1890 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1891 "c" gnus-summary-catchup-and-exit
1892 "C" gnus-summary-catchup-all-and-exit
1893 "E" gnus-summary-exit-no-update
1894 "J" gnus-summary-jump-to-other-group
1895 "Q" gnus-summary-exit
1896 "Z" gnus-summary-exit
1897 "n" gnus-summary-catchup-and-goto-next-group
1898 "R" gnus-summary-reselect-current-group
1899 "G" gnus-summary-rescan-group
1900 "N" gnus-summary-next-group
1901 "s" gnus-summary-save-newsrc
1902 "P" gnus-summary-prev-group)
1904 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1905 " " gnus-summary-next-page
1906 "n" gnus-summary-next-page
1907 "\177" gnus-summary-prev-page
1908 [delete] gnus-summary-prev-page
1909 "p" gnus-summary-prev-page
1910 "\r" gnus-summary-scroll-up
1911 "\M-\r" gnus-summary-scroll-down
1912 "<" gnus-summary-beginning-of-article
1913 ">" gnus-summary-end-of-article
1914 "b" gnus-summary-beginning-of-article
1915 "e" gnus-summary-end-of-article
1916 "^" gnus-summary-refer-parent-article
1917 "r" gnus-summary-refer-parent-article
1918 "D" gnus-summary-enter-digest-group
1919 "R" gnus-summary-refer-references
1920 "T" gnus-summary-refer-thread
1921 "g" gnus-summary-show-article
1922 "s" gnus-summary-isearch-article
1923 "P" gnus-summary-print-article
1924 "M" gnus-mailing-list-insinuate
1925 "t" gnus-article-babel)
1927 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1928 "b" gnus-article-add-buttons
1929 "B" gnus-article-add-buttons-to-head
1930 "o" gnus-article-treat-overstrike
1931 "e" gnus-article-emphasize
1932 "w" gnus-article-fill-cited-article
1933 "Q" gnus-article-fill-long-lines
1934 "C" gnus-article-capitalize-sentences
1935 "c" gnus-article-remove-cr
1936 "Z" gnus-article-decode-HZ
1937 "A" gnus-article-treat-ansi-sequences
1938 "h" gnus-article-wash-html
1939 "u" gnus-article-unsplit-urls
1940 "f" gnus-article-display-x-face
1941 "l" gnus-summary-stop-page-breaking
1942 "r" gnus-summary-caesar-message
1943 "m" gnus-summary-morse-message
1944 "t" gnus-summary-toggle-header
1945 "g" gnus-treat-smiley
1946 "v" gnus-summary-verbose-headers
1947 "m" gnus-summary-toggle-mime
1948 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1949 "p" gnus-article-verify-x-pgp-sig
1950 "d" gnus-article-treat-dumbquotes)
1952 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1953 ;; mnemonic: deuglif*Y*
1954 "u" gnus-article-outlook-unwrap-lines
1955 "a" gnus-article-outlook-repair-attribution
1956 "c" gnus-article-outlook-rearrange-citation
1957 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1959 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1960 "a" gnus-article-hide
1961 "h" gnus-article-hide-headers
1962 "b" gnus-article-hide-boring-headers
1963 "s" gnus-article-hide-signature
1964 "c" gnus-article-hide-citation
1965 "C" gnus-article-hide-citation-in-followups
1966 "l" gnus-article-hide-list-identifiers
1967 "B" gnus-article-strip-banner
1968 "P" gnus-article-hide-pem
1969 "\C-c" gnus-article-hide-citation-maybe)
1971 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1972 "a" gnus-article-highlight
1973 "h" gnus-article-highlight-headers
1974 "c" gnus-article-highlight-citation
1975 "s" gnus-article-highlight-signature)
1977 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1978 "f" gnus-article-treat-fold-headers
1979 "u" gnus-article-treat-unfold-headers
1980 "n" gnus-article-treat-fold-newsgroups)
1982 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1983 "x" gnus-article-display-x-face
1984 "d" gnus-article-display-face
1985 "s" gnus-treat-smiley
1986 "D" gnus-article-remove-images
1987 "f" gnus-treat-from-picon
1988 "m" gnus-treat-mail-picon
1989 "n" gnus-treat-newsgroups-picon)
1991 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1992 "z" gnus-article-date-ut
1993 "u" gnus-article-date-ut
1994 "l" gnus-article-date-local
1995 "p" gnus-article-date-english
1996 "e" gnus-article-date-lapsed
1997 "o" gnus-article-date-original
1998 "i" gnus-article-date-iso8601
1999 "s" gnus-article-date-user)
2001 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2002 "t" gnus-article-remove-trailing-blank-lines
2003 "l" gnus-article-strip-leading-blank-lines
2004 "m" gnus-article-strip-multiple-blank-lines
2005 "a" gnus-article-strip-blank-lines
2006 "A" gnus-article-strip-all-blank-lines
2007 "s" gnus-article-strip-leading-space
2008 "e" gnus-article-strip-trailing-space
2009 "w" gnus-article-remove-leading-whitespace)
2011 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2013 "f" gnus-summary-fetch-faq
2014 "d" gnus-summary-describe-group
2015 "h" gnus-summary-describe-briefly
2016 "i" gnus-info-find-node
2017 "c" gnus-group-fetch-charter
2018 "C" gnus-group-fetch-control)
2020 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2021 "e" gnus-summary-expire-articles
2022 "\M-\C-e" gnus-summary-expire-articles-now
2023 "\177" gnus-summary-delete-article
2024 [delete] gnus-summary-delete-article
2025 [backspace] gnus-summary-delete-article
2026 "m" gnus-summary-move-article
2027 "r" gnus-summary-respool-article
2028 "w" gnus-summary-edit-article
2029 "c" gnus-summary-copy-article
2030 "B" gnus-summary-crosspost-article
2031 "q" gnus-summary-respool-query
2032 "t" gnus-summary-respool-trace
2033 "i" gnus-summary-import-article
2034 "I" gnus-summary-create-article
2035 "p" gnus-summary-article-posted-p)
2037 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2038 "o" gnus-summary-save-article
2039 "m" gnus-summary-save-article-mail
2040 "F" gnus-summary-write-article-file
2041 "r" gnus-summary-save-article-rmail
2042 "f" gnus-summary-save-article-file
2043 "b" gnus-summary-save-article-body-file
2044 "h" gnus-summary-save-article-folder
2045 "v" gnus-summary-save-article-vm
2046 "p" gnus-summary-pipe-output
2047 "P" gnus-summary-muttprint
2048 "s" gnus-soup-add-article)
2050 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2051 "b" gnus-summary-display-buttonized
2052 "m" gnus-summary-repair-multipart
2053 "v" gnus-article-view-part
2054 "o" gnus-article-save-part
2055 "c" gnus-article-copy-part
2056 "C" gnus-article-view-part-as-charset
2057 "e" gnus-article-view-part-externally
2058 "E" gnus-article-encrypt-body
2059 "i" gnus-article-inline-part
2060 "|" gnus-article-pipe-part)
2062 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2063 "p" gnus-summary-mark-as-processable
2064 "u" gnus-summary-unmark-as-processable
2065 "U" gnus-summary-unmark-all-processable
2066 "v" gnus-uu-mark-over
2067 "s" gnus-uu-mark-series
2068 "r" gnus-uu-mark-region
2069 "g" gnus-uu-unmark-region
2070 "R" gnus-uu-mark-by-regexp
2071 "G" gnus-uu-unmark-by-regexp
2072 "t" gnus-uu-mark-thread
2073 "T" gnus-uu-unmark-thread
2074 "a" gnus-uu-mark-all
2075 "b" gnus-uu-mark-buffer
2076 "S" gnus-uu-mark-sparse
2077 "k" gnus-summary-kill-process-mark
2078 "y" gnus-summary-yank-process-mark
2079 "w" gnus-summary-save-process-mark
2080 "i" gnus-uu-invert-processable)
2082 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2083 ;;"x" gnus-uu-extract-any
2084 "m" gnus-summary-save-parts
2085 "u" gnus-uu-decode-uu
2086 "U" gnus-uu-decode-uu-and-save
2087 "s" gnus-uu-decode-unshar
2088 "S" gnus-uu-decode-unshar-and-save
2089 "o" gnus-uu-decode-save
2090 "O" gnus-uu-decode-save
2091 "b" gnus-uu-decode-binhex
2092 "B" gnus-uu-decode-binhex
2093 "p" gnus-uu-decode-postscript
2094 "P" gnus-uu-decode-postscript-and-save)
2097 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2098 "u" gnus-uu-decode-uu-view
2099 "U" gnus-uu-decode-uu-and-save-view
2100 "s" gnus-uu-decode-unshar-view
2101 "S" gnus-uu-decode-unshar-and-save-view
2102 "o" gnus-uu-decode-save-view
2103 "O" gnus-uu-decode-save-view
2104 "b" gnus-uu-decode-binhex-view
2105 "B" gnus-uu-decode-binhex-view
2106 "p" gnus-uu-decode-postscript-view
2107 "P" gnus-uu-decode-postscript-and-save-view)
2109 (defvar gnus-article-post-menu nil)
2111 (defconst gnus-summary-menu-maxlen 20)
2113 (defun gnus-summary-menu-split (menu)
2114 ;; If we have lots of elements, divide them into groups of 20
2115 ;; and make a pane (or submenu) for each one.
2116 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2117 (let ((menu menu) sublists next
2120 ;; Pull off the next gnus-summary-menu-maxlen elements
2121 ;; and make them the next element of sublist.
2122 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2124 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2126 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2127 (aref (car (last menu)) 0)) menu)
2131 (nreverse sublists))
2132 ;; Few elements--put them all in one pane.
2135 (defun gnus-summary-make-menu-bar ()
2136 (gnus-turn-off-edit-menu 'summary)
2138 (unless (boundp 'gnus-summary-misc-menu)
2141 gnus-summary-kill-menu gnus-summary-mode-map ""
2146 ["Customize" gnus-score-customize t])
2147 (gnus-make-score-map 'increase)
2148 (gnus-make-score-map 'lower)
2150 ["Kill below" gnus-summary-kill-below t]
2151 ["Mark above" gnus-summary-mark-above t]
2152 ["Tick above" gnus-summary-tick-above t]
2153 ["Clear above" gnus-summary-clear-above t])
2154 ["Current score" gnus-summary-current-score t]
2155 ["Set score" gnus-summary-set-score t]
2156 ["Switch current score file..." gnus-score-change-score-file t]
2157 ["Set mark below..." gnus-score-set-mark-below t]
2158 ["Set expunge below..." gnus-score-set-expunge-below t]
2159 ["Edit current score file" gnus-score-edit-current-scores t]
2160 ["Edit score file" gnus-score-edit-file t]
2161 ["Trace score" gnus-score-find-trace t]
2162 ["Find words" gnus-score-find-favourite-words t]
2163 ["Rescore buffer" gnus-summary-rescore t]
2164 ["Increase score..." gnus-summary-increase-score t]
2165 ["Lower score..." gnus-summary-lower-score t]))))
2167 ;; Define both the Article menu in the summary buffer and the
2168 ;; equivalent Commands menu in the article buffer here for
2172 ["All" gnus-article-hide t]
2173 ["Headers" gnus-article-hide-headers t]
2174 ["Signature" gnus-article-hide-signature t]
2175 ["Citation" gnus-article-hide-citation t]
2176 ["List identifiers" gnus-article-hide-list-identifiers t]
2177 ["Banner" gnus-article-strip-banner t]
2178 ["Boring headers" gnus-article-hide-boring-headers t])
2180 ["All" gnus-article-highlight t]
2181 ["Headers" gnus-article-highlight-headers t]
2182 ["Signature" gnus-article-highlight-signature t]
2183 ["Citation" gnus-article-highlight-citation t])
2185 ["Local" gnus-article-date-local t]
2186 ["ISO8601" gnus-article-date-iso8601 t]
2187 ["UT" gnus-article-date-ut t]
2188 ["Original" gnus-article-date-original t]
2189 ["Lapsed" gnus-article-date-lapsed t]
2190 ["User-defined" gnus-article-date-user t])
2192 ["Remove images" gnus-article-remove-images t]
2193 ["Toggle smiley" gnus-treat-smiley t]
2194 ["Show X-Face" gnus-article-display-x-face t]
2195 ["Show picons in From" gnus-treat-from-picon t]
2196 ["Show picons in mail headers" gnus-treat-mail-picon t]
2197 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2198 ("View as different encoding"
2199 ,@(gnus-summary-menu-split
2202 ;; Since easymenu under Emacs doesn't allow
2203 ;; lambda forms for menu commands, we should
2204 ;; provide intern'ed function symbols.
2205 (let ((command (intern (format "\
2206 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2210 (let ((gnus-summary-show-article-charset-alist
2212 (gnus-summary-show-article 1))))
2213 `[,(symbol-name cs) ,command t]))
2214 (sort (if (fboundp 'coding-system-list)
2215 (coding-system-list)
2216 ;;(mapcar 'car mm-mime-mule-charset-alist)
2221 ["Leading" gnus-article-strip-leading-blank-lines t]
2222 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2223 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2224 ["All of the above" gnus-article-strip-blank-lines t]
2225 ["All" gnus-article-strip-all-blank-lines t]
2226 ["Leading space" gnus-article-strip-leading-space t]
2227 ["Trailing space" gnus-article-strip-trailing-space t]
2228 ["Leading space in headers"
2229 gnus-article-remove-leading-whitespace t])
2230 ["Overstrike" gnus-article-treat-overstrike t]
2231 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2232 ["Emphasis" gnus-article-emphasize t]
2233 ["Word wrap" gnus-article-fill-cited-article t]
2234 ["Fill long lines" gnus-article-fill-long-lines t]
2235 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2236 ["Remove CR" gnus-article-remove-cr t]
2237 ["Rot 13" gnus-summary-caesar-message
2238 ,@(if (featurep 'xemacs) '(t)
2239 '(:help "\"Caesar rotate\" article by 13"))]
2240 ["Morse decode" gnus-summary-morse-message t]
2241 ["Unix pipe..." gnus-summary-pipe-message t]
2242 ["Add buttons" gnus-article-add-buttons t]
2243 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2244 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2245 ["Toggle MIME" gnus-summary-toggle-mime t]
2246 ["Verbose header" gnus-summary-verbose-headers t]
2247 ["Toggle header" gnus-summary-toggle-header t]
2248 ["Unfold headers" gnus-article-treat-unfold-headers t]
2249 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2250 ["Html" gnus-article-wash-html t]
2251 ["Unsplit URLs" gnus-article-unsplit-urls t]
2252 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2253 ["Decode HZ" gnus-article-decode-HZ t]
2254 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2255 ("(Outlook) Deuglify"
2256 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2257 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2258 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2259 ["Full (Outlook) deuglify"
2260 gnus-article-outlook-deuglify-article t])
2263 ["Save in default format..." gnus-summary-save-article
2264 ,@(if (featurep 'xemacs) '(t)
2265 '(:help "Save article using default method"))]
2266 ["Save in file..." gnus-summary-save-article-file
2267 ,@(if (featurep 'xemacs) '(t)
2268 '(:help "Save article in file"))]
2269 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2270 ["Save in MH folder..." gnus-summary-save-article-folder t]
2271 ["Save in VM folder..." gnus-summary-save-article-vm t]
2272 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2273 ["Save body in file..." gnus-summary-save-article-body-file t]
2274 ["Pipe through a filter..." gnus-summary-pipe-output t]
2275 ["Add to SOUP packet" gnus-soup-add-article t]
2276 ["Print with Muttprint..." gnus-summary-muttprint t]
2277 ["Print" gnus-summary-print-article
2278 ,@(if (featurep 'xemacs) '(t)
2279 '(:help "Generate and print a PostScript image"))])
2280 ("Copy, move,... (Backend)"
2281 ,@(if (featurep 'xemacs) nil
2282 '(:help "Copying, moving, expiring articles..."))
2283 ["Respool article..." gnus-summary-respool-article t]
2284 ["Move article..." gnus-summary-move-article
2285 (gnus-check-backend-function
2286 'request-move-article gnus-newsgroup-name)]
2287 ["Copy article..." gnus-summary-copy-article t]
2288 ["Crosspost article..." gnus-summary-crosspost-article
2289 (gnus-check-backend-function
2290 'request-replace-article gnus-newsgroup-name)]
2291 ["Import file..." gnus-summary-import-article
2292 (gnus-check-backend-function
2293 'request-accept-article gnus-newsgroup-name)]
2294 ["Create article..." gnus-summary-create-article
2295 (gnus-check-backend-function
2296 'request-accept-article gnus-newsgroup-name)]
2297 ["Check if posted" gnus-summary-article-posted-p t]
2298 ["Edit article" gnus-summary-edit-article
2299 (not (gnus-group-read-only-p))]
2300 ["Delete article" gnus-summary-delete-article
2301 (gnus-check-backend-function
2302 'request-expire-articles gnus-newsgroup-name)]
2303 ["Query respool" gnus-summary-respool-query t]
2304 ["Trace respool" gnus-summary-respool-trace t]
2305 ["Delete expirable articles" gnus-summary-expire-articles-now
2306 (gnus-check-backend-function
2307 'request-expire-articles gnus-newsgroup-name)])
2309 ["Uudecode" gnus-uu-decode-uu
2310 ,@(if (featurep 'xemacs) '(t)
2311 '(:help "Decode uuencoded article(s)"))]
2312 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2313 ["Unshar" gnus-uu-decode-unshar t]
2314 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2315 ["Save" gnus-uu-decode-save t]
2316 ["Binhex" gnus-uu-decode-binhex t]
2317 ["Postscript" gnus-uu-decode-postscript t])
2319 ["Enter article" gnus-cache-enter-article t]
2320 ["Remove article" gnus-cache-remove-article t])
2321 ["Translate" gnus-article-babel t]
2322 ["Select article buffer" gnus-summary-select-article-buffer t]
2323 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2324 ["Isearch article..." gnus-summary-isearch-article t]
2325 ["Beginning of the article" gnus-summary-beginning-of-article t]
2326 ["End of the article" gnus-summary-end-of-article t]
2327 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2328 ["Fetch referenced articles" gnus-summary-refer-references t]
2329 ["Fetch current thread" gnus-summary-refer-thread t]
2330 ["Fetch article with id..." gnus-summary-refer-article t]
2331 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2332 ["Redisplay" gnus-summary-show-article t]
2333 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2335 gnus-summary-article-menu gnus-summary-mode-map ""
2336 (cons "Article" innards))
2338 (if (not (keymapp gnus-summary-article-menu))
2340 gnus-article-commands-menu gnus-article-mode-map ""
2341 (cons "Commands" innards))
2342 ;; in Emacs, don't share menu.
2343 (setq gnus-article-commands-menu
2344 (copy-keymap gnus-summary-article-menu))
2345 (define-key gnus-article-mode-map [menu-bar commands]
2346 (cons "Commands" gnus-article-commands-menu))))
2349 gnus-summary-thread-menu gnus-summary-mode-map ""
2351 ["Find all messages in thread" gnus-summary-refer-thread t]
2352 ["Toggle threading" gnus-summary-toggle-threads t]
2353 ["Hide threads" gnus-summary-hide-all-threads t]
2354 ["Show threads" gnus-summary-show-all-threads t]
2355 ["Hide thread" gnus-summary-hide-thread t]
2356 ["Show thread" gnus-summary-show-thread t]
2357 ["Go to next thread" gnus-summary-next-thread t]
2358 ["Go to previous thread" gnus-summary-prev-thread t]
2359 ["Go down thread" gnus-summary-down-thread t]
2360 ["Go up thread" gnus-summary-up-thread t]
2361 ["Top of thread" gnus-summary-top-thread t]
2362 ["Mark thread as read" gnus-summary-kill-thread t]
2363 ["Lower thread score" gnus-summary-lower-thread t]
2364 ["Raise thread score" gnus-summary-raise-thread t]
2365 ["Rethread current" gnus-summary-rethread-current t]))
2368 gnus-summary-post-menu gnus-summary-mode-map ""
2370 ["Send a message (mail or news)" gnus-summary-post-news
2371 ,@(if (featurep 'xemacs) '(t)
2372 '(:help "Compose a new message (mail or news)"))]
2373 ["Followup" gnus-summary-followup
2374 ,@(if (featurep 'xemacs) '(t)
2375 '(:help "Post followup to this article"))]
2376 ["Followup and yank" gnus-summary-followup-with-original
2377 ,@(if (featurep 'xemacs) '(t)
2378 '(:help "Post followup to this article, quoting its contents"))]
2379 ["Supersede article" gnus-summary-supersede-article t]
2380 ["Cancel article" gnus-summary-cancel-article
2381 ,@(if (featurep 'xemacs) '(t)
2382 '(:help "Cancel an article you posted"))]
2383 ["Reply" gnus-summary-reply t]
2384 ["Reply and yank" gnus-summary-reply-with-original t]
2385 ["Wide reply" gnus-summary-wide-reply t]
2386 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2387 ,@(if (featurep 'xemacs) '(t)
2388 '(:help "Mail a reply, quoting this article"))]
2389 ["Very wide reply" gnus-summary-very-wide-reply t]
2390 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2391 ,@(if (featurep 'xemacs) '(t)
2392 '(:help "Mail a very wide reply, quoting this article"))]
2393 ["Mail forward" gnus-summary-mail-forward t]
2394 ["Post forward" gnus-summary-post-forward t]
2395 ["Digest and mail" gnus-summary-digest-mail-forward t]
2396 ["Digest and post" gnus-summary-digest-post-forward t]
2397 ["Resend message" gnus-summary-resend-message t]
2398 ["Resend message edit" gnus-summary-resend-message-edit t]
2399 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2400 ["Send a mail" gnus-summary-mail-other-window t]
2401 ["Create a local message" gnus-summary-news-other-window t]
2402 ["Uuencode and post" gnus-uu-post-news
2403 ,@(if (featurep 'xemacs) '(t)
2404 '(:help "Post a uuencoded article"))]
2405 ["Followup via news" gnus-summary-followup-to-mail t]
2406 ["Followup via news and yank"
2407 gnus-summary-followup-to-mail-with-original t]
2409 ;;["Send" gnus-summary-send-draft t]
2410 ;;["Send bounced" gnus-resend-bounced-mail t])
2414 ((not (keymapp gnus-summary-post-menu))
2415 (setq gnus-article-post-menu gnus-summary-post-menu))
2416 ((not gnus-article-post-menu)
2417 ;; Don't share post menu.
2418 (setq gnus-article-post-menu
2419 (copy-keymap gnus-summary-post-menu))))
2420 (define-key gnus-article-mode-map [menu-bar post]
2421 (cons "Post" gnus-article-post-menu))
2424 gnus-summary-misc-menu gnus-summary-mode-map ""
2427 ["Mark as read" gnus-summary-mark-as-read-forward t]
2428 ["Mark same subject and select"
2429 gnus-summary-kill-same-subject-and-select t]
2430 ["Mark same subject" gnus-summary-kill-same-subject t]
2431 ["Catchup" gnus-summary-catchup
2432 ,@(if (featurep 'xemacs) '(t)
2433 '(:help "Mark unread articles in this group as read"))]
2434 ["Catchup all" gnus-summary-catchup-all t]
2435 ["Catchup to here" gnus-summary-catchup-to-here t]
2436 ["Catchup from here" gnus-summary-catchup-from-here t]
2437 ["Catchup region" gnus-summary-mark-region-as-read
2438 (gnus-mark-active-p)]
2439 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2441 ["Tick" gnus-summary-tick-article-forward t]
2442 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2443 ["Remove marks" gnus-summary-clear-mark-forward t]
2444 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2445 ["Set bookmark" gnus-summary-set-bookmark t]
2446 ["Remove bookmark" gnus-summary-remove-bookmark t])
2448 ["Marks..." gnus-summary-limit-to-marks t]
2449 ["Subject..." gnus-summary-limit-to-subject t]
2450 ["Author..." gnus-summary-limit-to-author t]
2451 ["Age..." gnus-summary-limit-to-age t]
2452 ["Extra..." gnus-summary-limit-to-extra t]
2453 ["Score..." gnus-summary-limit-to-score t]
2454 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2455 ["Unread" gnus-summary-limit-to-unread t]
2456 ["Unseen" gnus-summary-limit-to-unseen t]
2457 ["Replied" gnus-summary-limit-to-replied t]
2458 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2459 ["Next articles" gnus-summary-limit-to-articles t]
2460 ["Pop limit" gnus-summary-pop-limit t]
2461 ["Show dormant" gnus-summary-limit-include-dormant t]
2462 ["Hide childless dormant"
2463 gnus-summary-limit-exclude-childless-dormant t]
2464 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2465 ["Hide marked" gnus-summary-limit-exclude-marks t]
2466 ["Show expunged" gnus-summary-limit-include-expunged t])
2468 ["Set mark" gnus-summary-mark-as-processable t]
2469 ["Remove mark" gnus-summary-unmark-as-processable t]
2470 ["Remove all marks" gnus-summary-unmark-all-processable t]
2471 ["Invert marks" gnus-uu-invert-processable t]
2472 ["Mark above" gnus-uu-mark-over t]
2473 ["Mark series" gnus-uu-mark-series t]
2474 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2475 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2476 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2477 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2478 ["Mark all" gnus-uu-mark-all t]
2479 ["Mark buffer" gnus-uu-mark-buffer t]
2480 ["Mark sparse" gnus-uu-mark-sparse t]
2481 ["Mark thread" gnus-uu-mark-thread t]
2482 ["Unmark thread" gnus-uu-unmark-thread t]
2483 ("Process Mark Sets"
2484 ["Kill" gnus-summary-kill-process-mark t]
2485 ["Yank" gnus-summary-yank-process-mark
2486 gnus-newsgroup-process-stack]
2487 ["Save" gnus-summary-save-process-mark t]
2488 ["Run command on marked..." gnus-summary-universal-argument t]))
2490 ["Page forward" gnus-summary-next-page
2491 ,@(if (featurep 'xemacs) '(t)
2492 '(:help "Show next page of article"))]
2493 ["Page backward" gnus-summary-prev-page
2494 ,@(if (featurep 'xemacs) '(t)
2495 '(:help "Show previous page of article"))]
2496 ["Line forward" gnus-summary-scroll-up t])
2498 ["Next unread article" gnus-summary-next-unread-article t]
2499 ["Previous unread article" gnus-summary-prev-unread-article t]
2500 ["Next article" gnus-summary-next-article t]
2501 ["Previous article" gnus-summary-prev-article t]
2502 ["Next unread subject" gnus-summary-next-unread-subject t]
2503 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2504 ["Next article same subject" gnus-summary-next-same-subject t]
2505 ["Previous article same subject" gnus-summary-prev-same-subject t]
2506 ["First unread article" gnus-summary-first-unread-article t]
2507 ["Best unread article" gnus-summary-best-unread-article t]
2508 ["Go to subject number..." gnus-summary-goto-subject t]
2509 ["Go to article number..." gnus-summary-goto-article t]
2510 ["Go to the last article" gnus-summary-goto-last-article t]
2511 ["Pop article off history" gnus-summary-pop-article t])
2513 ["Sort by number" gnus-summary-sort-by-number t]
2514 ["Sort by author" gnus-summary-sort-by-author t]
2515 ["Sort by subject" gnus-summary-sort-by-subject t]
2516 ["Sort by date" gnus-summary-sort-by-date t]
2517 ["Sort by score" gnus-summary-sort-by-score t]
2518 ["Sort by lines" gnus-summary-sort-by-lines t]
2519 ["Sort by characters" gnus-summary-sort-by-chars t]
2520 ["Randomize" gnus-summary-sort-by-random t]
2521 ["Original sort" gnus-summary-sort-by-original t])
2523 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2524 ["Describe group" gnus-summary-describe-group t]
2525 ["Fetch charter" gnus-group-fetch-charter
2526 ,@(if (featurep 'xemacs) nil
2527 '(:help "Display the charter of the current group"))]
2528 ["Fetch control message" gnus-group-fetch-control
2529 ,@(if (featurep 'xemacs) nil
2530 '(:help "Display the archived control message for the current group"))]
2531 ["Read manual" gnus-info-find-node t])
2533 ["Pick and read" gnus-pick-mode t]
2534 ["Binary" gnus-binary-mode t])
2536 ["Regenerate" gnus-summary-prepare t]
2537 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2538 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2539 ["Toggle threading" gnus-summary-toggle-threads t])
2540 ["See old articles" gnus-summary-insert-old-articles t]
2541 ["See new articles" gnus-summary-insert-new-articles t]
2542 ["Filter articles..." gnus-summary-execute-command t]
2543 ["Run command on articles..." gnus-summary-universal-argument t]
2544 ["Search articles forward..." gnus-summary-search-article-forward t]
2545 ["Search articles backward..." gnus-summary-search-article-backward t]
2546 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2547 ["Expand window" gnus-summary-expand-window t]
2548 ["Expire expirable articles" gnus-summary-expire-articles
2549 (gnus-check-backend-function
2550 'request-expire-articles gnus-newsgroup-name)]
2551 ["Edit local kill file" gnus-summary-edit-local-kill t]
2552 ["Edit main kill file" gnus-summary-edit-global-kill t]
2553 ["Edit group parameters" gnus-summary-edit-parameters t]
2554 ["Customize group parameters" gnus-summary-customize-parameters t]
2555 ["Send a bug report" gnus-bug t]
2557 ["Catchup and exit" gnus-summary-catchup-and-exit
2558 ,@(if (featurep 'xemacs) '(t)
2559 '(:help "Mark unread articles in this group as read, then exit"))]
2560 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2561 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2562 ["Exit group" gnus-summary-exit
2563 ,@(if (featurep 'xemacs) '(t)
2564 '(:help "Exit current group, return to group selection mode"))]
2565 ["Exit group without updating" gnus-summary-exit-no-update t]
2566 ["Exit and goto next group" gnus-summary-next-group t]
2567 ["Exit and goto prev group" gnus-summary-prev-group t]
2568 ["Reselect group" gnus-summary-reselect-current-group t]
2569 ["Rescan group" gnus-summary-rescan-group t]
2570 ["Update dribble" gnus-summary-save-newsrc t])))
2572 (gnus-run-hooks 'gnus-summary-menu-hook)))
2574 (defvar gnus-summary-tool-bar-map nil)
2576 ;; Emacs 21 tool bar. Should be no-op otherwise.
2577 (defun gnus-summary-make-tool-bar ()
2578 (if (and (fboundp 'tool-bar-add-item-from-menu)
2579 (default-value 'tool-bar-mode)
2580 (not gnus-summary-tool-bar-map))
2581 (setq gnus-summary-tool-bar-map
2582 (let ((tool-bar-map (make-sparse-keymap))
2583 (load-path (mm-image-load-path)))
2584 (tool-bar-add-item-from-menu
2585 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2586 (tool-bar-add-item-from-menu
2587 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2588 (tool-bar-add-item-from-menu
2589 'gnus-summary-post-news "post" gnus-summary-mode-map)
2590 (tool-bar-add-item-from-menu
2591 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2592 (tool-bar-add-item-from-menu
2593 'gnus-summary-followup "followup" gnus-summary-mode-map)
2594 (tool-bar-add-item-from-menu
2595 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2596 (tool-bar-add-item-from-menu
2597 'gnus-summary-reply "reply" gnus-summary-mode-map)
2598 (tool-bar-add-item-from-menu
2599 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2600 (tool-bar-add-item-from-menu
2601 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2602 (tool-bar-add-item-from-menu
2603 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2604 (tool-bar-add-item-from-menu
2605 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2606 (tool-bar-add-item-from-menu
2607 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2608 (tool-bar-add-item-from-menu
2609 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2610 (tool-bar-add-item-from-menu
2611 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2612 (tool-bar-add-item-from-menu
2613 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2614 (tool-bar-add-item-from-menu
2615 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2617 (if gnus-summary-tool-bar-map
2618 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2620 (defun gnus-score-set-default (var value)
2621 "A version of set that updates the GNU Emacs menu-bar."
2623 ;; It is the message that forces the active status to be updated.
2626 (defun gnus-make-score-map (type)
2627 "Make a summary score map of type TYPE."
2630 (let ((headers '(("author" "from" string)
2631 ("subject" "subject" string)
2632 ("article body" "body" string)
2633 ("article head" "head" string)
2634 ("xref" "xref" string)
2635 ("extra header" "extra" string)
2636 ("lines" "lines" number)
2637 ("followups to author" "followup" string)))
2638 (types '((number ("less than" <)
2641 (string ("substring" s)
2645 (perms '(("temporary" (current-time-string))
2653 (if (eq type 'lower)
2658 (setq header (car headers))
2664 (let ((ts (cdr (assoc (nth 2 header) types)))
2680 'gnus-summary-score-entry
2682 (if (or (string= (nth 1 header)
2684 (string= (nth 1 header)
2687 (list 'gnus-summary-header
2689 (list 'quote (nth 1 (car ts)))
2690 (list 'gnus-score-delta-default
2697 (list (nreverse outp))))
2700 (list (nreverse outt))))
2702 (setq headers (cdr headers)))
2703 (list (nreverse outh))))))))
2707 (defun gnus-summary-mode (&optional group)
2708 "Major mode for reading articles.
2710 All normal editing commands are switched off.
2711 \\<gnus-summary-mode-map>
2712 Each line in this buffer represents one article. To read an
2713 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2714 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2717 You can also post articles and send mail from this buffer. To
2718 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2719 of an article, type `\\[gnus-summary-reply]'.
2721 There are approx. one gazillion commands you can execute in this
2722 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2724 The following commands are available:
2726 \\{gnus-summary-mode-map}"
2728 (kill-all-local-variables)
2729 (when (gnus-visual-p 'summary-menu 'menu)
2730 (gnus-summary-make-menu-bar)
2731 (gnus-summary-make-tool-bar))
2732 (gnus-summary-make-local-variables)
2733 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2734 (gnus-summary-make-local-variables))
2735 (gnus-make-thread-indent-array)
2736 (gnus-simplify-mode-line)
2737 (setq major-mode 'gnus-summary-mode)
2738 (setq mode-name "Summary")
2739 (make-local-variable 'minor-mode-alist)
2740 (use-local-map gnus-summary-mode-map)
2741 (buffer-disable-undo)
2742 (setq buffer-read-only t ;Disable modification
2743 show-trailing-whitespace nil)
2744 (setq truncate-lines t)
2745 (setq selective-display t)
2746 (setq selective-display-ellipses t) ;Display `...'
2747 (gnus-summary-set-display-table)
2748 (gnus-set-default-directory)
2749 (setq gnus-newsgroup-name group)
2750 (unless (gnus-news-group-p group)
2751 (setq gnus-newsgroup-incorporated
2752 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2753 (make-local-variable 'gnus-summary-line-format)
2754 (make-local-variable 'gnus-summary-line-format-spec)
2755 (make-local-variable 'gnus-summary-dummy-line-format)
2756 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2757 (make-local-variable 'gnus-summary-mark-positions)
2758 (gnus-make-local-hook 'pre-command-hook)
2759 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2760 (gnus-run-hooks 'gnus-summary-mode-hook)
2761 (turn-on-gnus-mailing-list-mode)
2762 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2763 (gnus-update-summary-mark-positions))
2765 (defun gnus-summary-make-local-variables ()
2766 "Make all the local summary buffer variables."
2768 (dolist (local gnus-summary-local-variables)
2771 (if (eq (cdr local) 'global)
2772 ;; Copy the global value of the variable.
2773 (setq global (symbol-value (car local)))
2774 ;; Use the value from the list.
2775 (setq global (eval (cdr local))))
2776 (set (make-local-variable (car local)) global))
2777 ;; Simple nil-valued local variable.
2778 (set (make-local-variable local) nil)))))
2780 (defun gnus-summary-clear-local-variables ()
2781 (let ((locals gnus-summary-local-variables))
2783 (if (consp (car locals))
2784 (and (vectorp (caar locals))
2785 (set (caar locals) nil))
2786 (and (vectorp (car locals))
2787 (set (car locals) nil)))
2788 (setq locals (cdr locals)))))
2790 ;; Summary data functions.
2792 (defmacro gnus-data-number (data)
2795 (defmacro gnus-data-set-number (data number)
2796 `(setcar ,data ,number))
2798 (defmacro gnus-data-mark (data)
2801 (defmacro gnus-data-set-mark (data mark)
2802 `(setcar (nthcdr 1 ,data) ,mark))
2804 (defmacro gnus-data-pos (data)
2807 (defmacro gnus-data-set-pos (data pos)
2808 `(setcar (nthcdr 2 ,data) ,pos))
2810 (defmacro gnus-data-header (data)
2813 (defmacro gnus-data-set-header (data header)
2814 `(setcar (nthcdr 3 ,data) ,header))
2816 (defmacro gnus-data-level (data)
2819 (defmacro gnus-data-unread-p (data)
2820 `(= (nth 1 ,data) gnus-unread-mark))
2822 (defmacro gnus-data-read-p (data)
2823 `(/= (nth 1 ,data) gnus-unread-mark))
2825 (defmacro gnus-data-pseudo-p (data)
2826 `(consp (nth 3 ,data)))
2828 (defmacro gnus-data-find (number)
2829 `(assq ,number gnus-newsgroup-data))
2831 (defmacro gnus-data-find-list (number &optional data)
2832 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2833 (memq (assq ,number bdata)
2836 (defmacro gnus-data-make (number mark pos header level)
2837 `(list ,number ,mark ,pos ,header ,level))
2839 (defun gnus-data-enter (after-article number mark pos header level offset)
2840 (let ((data (gnus-data-find-list after-article)))
2842 (error "No such article: %d" after-article))
2843 (setcdr data (cons (gnus-data-make number mark pos header level)
2845 (setq gnus-newsgroup-data-reverse nil)
2846 (gnus-data-update-list (cddr data) offset)))
2848 (defun gnus-data-enter-list (after-article list &optional offset)
2850 (let ((data (and after-article (gnus-data-find-list after-article)))
2854 (let ((odata gnus-newsgroup-data))
2855 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2857 (gnus-data-update-list odata offset)))
2858 ;; Find the last element in the list to be spliced into the main
2861 (setq list (cdr list)))
2864 (setcdr list gnus-newsgroup-data)
2865 (setq gnus-newsgroup-data ilist)
2867 (gnus-data-update-list (cdr list) offset)))
2868 (setcdr list (cdr data))
2871 (gnus-data-update-list (cdr list) offset))))
2872 (setq gnus-newsgroup-data-reverse nil))))
2874 (defun gnus-data-remove (article &optional offset)
2875 (let ((data gnus-newsgroup-data))
2876 (if (= (gnus-data-number (car data)) article)
2878 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2879 gnus-newsgroup-data-reverse nil)
2881 (gnus-data-update-list gnus-newsgroup-data offset)))
2883 (when (= (gnus-data-number (cadr data)) article)
2884 (setcdr data (cddr data))
2886 (gnus-data-update-list (cdr data) offset))
2888 gnus-newsgroup-data-reverse nil))
2889 (setq data (cdr data))))))
2891 (defmacro gnus-data-list (backward)
2893 (or gnus-newsgroup-data-reverse
2894 (setq gnus-newsgroup-data-reverse
2895 (reverse gnus-newsgroup-data)))
2896 gnus-newsgroup-data))
2898 (defun gnus-data-update-list (data offset)
2899 "Add OFFSET to the POS of all data entries in DATA."
2900 (setq gnus-newsgroup-data-reverse nil)
2902 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2903 (setq data (cdr data))))
2905 (defun gnus-summary-article-pseudo-p (article)
2906 "Say whether this article is a pseudo article or not."
2907 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2909 (defmacro gnus-summary-article-sparse-p (article)
2910 "Say whether this article is a sparse article or not."
2911 `(memq ,article gnus-newsgroup-sparse))
2913 (defmacro gnus-summary-article-ancient-p (article)
2914 "Say whether this article is a sparse article or not."
2915 `(memq ,article gnus-newsgroup-ancient))
2917 (defun gnus-article-parent-p (number)
2918 "Say whether this article is a parent or not."
2919 (let ((data (gnus-data-find-list number)))
2920 (and (cdr data) ; There has to be an article after...
2921 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2922 (gnus-data-level (nth 1 data))))))
2924 (defun gnus-article-children (number)
2925 "Return a list of all children to NUMBER."
2926 (let* ((data (gnus-data-find-list number))
2927 (level (gnus-data-level (car data)))
2929 (setq data (cdr data))
2931 (= (gnus-data-level (car data)) (1+ level)))
2932 (push (gnus-data-number (car data)) children)
2933 (setq data (cdr data)))
2936 (defmacro gnus-summary-skip-intangible ()
2937 "If the current article is intangible, then jump to a different article."
2938 '(let ((to (get-text-property (point) 'gnus-intangible)))
2939 (and to (gnus-summary-goto-subject to))))
2941 (defmacro gnus-summary-article-intangible-p ()
2942 "Say whether this article is intangible or not."
2943 '(get-text-property (point) 'gnus-intangible))
2945 (defun gnus-article-read-p (article)
2946 "Say whether ARTICLE is read or not."
2947 (not (or (memq article gnus-newsgroup-marked)
2948 (memq article gnus-newsgroup-spam-marked)
2949 (memq article gnus-newsgroup-unreads)
2950 (memq article gnus-newsgroup-unselected)
2951 (memq article gnus-newsgroup-dormant))))
2953 ;; Some summary mode macros.
2955 (defmacro gnus-summary-article-number ()
2956 "The article number of the article on the current line.
2957 If there isn't an article number here, then we return the current
2960 (gnus-summary-skip-intangible)
2961 (or (get-text-property (point) 'gnus-number)
2962 (gnus-summary-last-subject))))
2964 (defmacro gnus-summary-article-header (&optional number)
2965 "Return the header of article NUMBER."
2966 `(gnus-data-header (gnus-data-find
2967 ,(or number '(gnus-summary-article-number)))))
2969 (defmacro gnus-summary-thread-level (&optional number)
2970 "Return the level of thread that starts with article NUMBER."
2971 `(if (and (eq gnus-summary-make-false-root 'dummy)
2972 (get-text-property (point) 'gnus-intangible))
2974 (gnus-data-level (gnus-data-find
2975 ,(or number '(gnus-summary-article-number))))))
2977 (defmacro gnus-summary-article-mark (&optional number)
2978 "Return the mark of article NUMBER."
2979 `(gnus-data-mark (gnus-data-find
2980 ,(or number '(gnus-summary-article-number)))))
2982 (defmacro gnus-summary-article-pos (&optional number)
2983 "Return the position of the line of article NUMBER."
2984 `(gnus-data-pos (gnus-data-find
2985 ,(or number '(gnus-summary-article-number)))))
2987 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2988 (defmacro gnus-summary-article-subject (&optional number)
2989 "Return current subject string or nil if nothing."
2992 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2993 '(gnus-data-header (assq (gnus-summary-article-number)
2994 gnus-newsgroup-data)))))
2997 (mail-header-subject headers))))
2999 (defmacro gnus-summary-article-score (&optional number)
3000 "Return current article score."
3001 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3002 gnus-newsgroup-scored))
3003 gnus-summary-default-score 0))
3005 (defun gnus-summary-article-children (&optional number)
3006 "Return a list of article numbers that are children of article NUMBER."
3007 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3008 (level (gnus-data-level (car data)))
3010 (while (and (setq data (cdr data))
3011 (> (setq l (gnus-data-level (car data))) level))
3012 (and (= (1+ level) l)
3013 (push (gnus-data-number (car data))
3015 (nreverse children)))
3017 (defun gnus-summary-article-parent (&optional number)
3018 "Return the article number of the parent of article NUMBER."
3019 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3020 (gnus-data-list t)))
3021 (level (gnus-data-level (car data))))
3023 () ; This is a root.
3024 ;; We search until we find an article with a level less than
3025 ;; this one. That function has to be the parent.
3026 (while (and (setq data (cdr data))
3027 (not (< (gnus-data-level (car data)) level))))
3028 (and data (gnus-data-number (car data))))))
3030 (defun gnus-unread-mark-p (mark)
3031 "Say whether MARK is the unread mark."
3032 (= mark gnus-unread-mark))
3034 (defun gnus-read-mark-p (mark)
3035 "Say whether MARK is one of the marks that mark as read.
3036 This is all marks except unread, ticked, dormant, and expirable."
3037 (not (or (= mark gnus-unread-mark)
3038 (= mark gnus-ticked-mark)
3039 (= mark gnus-spam-mark)
3040 (= mark gnus-dormant-mark)
3041 (= mark gnus-expirable-mark))))
3043 (defmacro gnus-article-mark (number)
3044 "Return the MARK of article NUMBER.
3045 This macro should only be used when computing the mark the \"first\"
3046 time; i.e., when generating the summary lines. After that,
3047 `gnus-summary-article-mark' should be used to examine the
3050 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3051 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3052 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3053 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3054 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3055 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3056 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3057 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3058 gnus-ancient-mark))))
3060 ;; Saving hidden threads.
3062 (defmacro gnus-save-hidden-threads (&rest forms)
3063 "Save hidden threads, eval FORMS, and restore the hidden threads."
3064 (let ((config (make-symbol "config")))
3065 `(let ((,config (gnus-hidden-threads-configuration)))
3069 (gnus-restore-hidden-threads-configuration ,config)))))
3070 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3071 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3073 (defun gnus-data-compute-positions ()
3074 "Compute the positions of all articles."
3075 (setq gnus-newsgroup-data-reverse nil)
3076 (let ((data gnus-newsgroup-data))
3078 (gnus-save-hidden-threads
3079 (gnus-summary-show-all-threads)
3080 (goto-char (point-min))
3082 (while (get-text-property (point) 'gnus-intangible)
3084 (gnus-data-set-pos (car data) (+ (point) 3))
3085 (setq data (cdr data))
3086 (forward-line 1))))))
3088 (defun gnus-hidden-threads-configuration ()
3089 "Return the current hidden threads configuration."
3092 (goto-char (point-min))
3093 (while (search-forward "\r" nil t)
3094 (push (1- (point)) config))
3097 (defun gnus-restore-hidden-threads-configuration (config)
3098 "Restore hidden threads configuration from CONFIG."
3100 (let (point buffer-read-only)
3101 (while (setq point (pop config))
3102 (when (and (< point (point-max))
3104 (eq (char-after) ?\n))
3105 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3107 ;; Various summary mode internalish functions.
3109 (defun gnus-mouse-pick-article (e)
3112 (gnus-summary-next-page nil t))
3114 (defun gnus-summary-set-display-table ()
3115 "Change the display table.
3116 Odd characters have a tendency to mess
3117 up nicely formatted displays - we make all possible glyphs
3118 display only a single character."
3120 ;; We start from the standard display table, if any.
3121 (let ((table (or (copy-sequence standard-display-table)
3122 (make-display-table)))
3124 ;; Nix out all the control chars...
3125 (while (>= (setq i (1- i)) 0)
3126 (aset table i [??]))
3127 ;; ... but not newline and cr, of course. (cr is necessary for the
3128 ;; selective display).
3129 (aset table ?\n nil)
3130 (aset table ?\r nil)
3131 ;; We keep TAB as well.
3132 (aset table ?\t nil)
3133 ;; We nix out any glyphs over 126 that are not set already.
3135 (while (>= (setq i (1- i)) 127)
3136 ;; Only modify if the entry is nil.
3137 (unless (aref table i)
3138 (aset table i [??]))))
3139 (setq buffer-display-table table)))
3141 (defun gnus-summary-set-article-display-arrow (pos)
3142 "Update the overlay arrow to point to line at position POS."
3143 (when (and gnus-summary-display-arrow
3144 (boundp 'overlay-arrow-position)
3145 (boundp 'overlay-arrow-string))
3149 (unless overlay-arrow-position
3150 (setq overlay-arrow-position (make-marker)))
3151 (setq overlay-arrow-string "=>"
3152 overlay-arrow-position (set-marker overlay-arrow-position
3154 (current-buffer))))))
3156 (defun gnus-summary-setup-buffer (group)
3157 "Initialize summary buffer."
3158 (let ((buffer (gnus-summary-buffer-name group))
3159 (dead-name (concat "*Dead Summary "
3160 (gnus-group-decoded-name group) "*")))
3161 ;; If a dead summary buffer exists, we kill it.
3162 (when (gnus-buffer-live-p dead-name)
3163 (gnus-kill-buffer dead-name))
3164 (if (get-buffer buffer)
3167 (setq gnus-summary-buffer (current-buffer))
3168 (not gnus-newsgroup-prepared))
3169 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3170 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3171 (gnus-summary-mode group)
3173 (gnus-carpal-setup-buffer 'summary))
3174 (unless gnus-single-article-buffer
3175 (make-local-variable 'gnus-article-buffer)
3176 (make-local-variable 'gnus-article-current)
3177 (make-local-variable 'gnus-original-article-buffer))
3178 (setq gnus-newsgroup-name group)
3179 ;; Set any local variables in the group parameters.
3180 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3183 (defun gnus-set-global-variables ()
3184 "Set the global equivalents of the buffer-local variables.
3185 They are set to the latest values they had. These reflect the summary
3186 buffer that was in action when the last article was fetched."
3187 (when (eq major-mode 'gnus-summary-mode)
3188 (setq gnus-summary-buffer (current-buffer))
3189 (let ((name gnus-newsgroup-name)
3190 (marked gnus-newsgroup-marked)
3191 (spam gnus-newsgroup-spam-marked)
3192 (unread gnus-newsgroup-unreads)
3193 (headers gnus-current-headers)
3194 (data gnus-newsgroup-data)
3195 (summary gnus-summary-buffer)
3196 (article-buffer gnus-article-buffer)
3197 (original gnus-original-article-buffer)
3198 (gac gnus-article-current)
3199 (reffed gnus-reffed-article-number)
3200 (score-file gnus-current-score-file)
3201 (default-charset gnus-newsgroup-charset)
3203 (let ((locals gnus-newsgroup-variables))
3205 (if (consp (car locals))
3206 (push (eval (caar locals)) vlist)
3207 (push (eval (car locals)) vlist))
3208 (setq locals (cdr locals)))
3209 (setq vlist (nreverse vlist)))
3210 (with-current-buffer gnus-group-buffer
3211 (setq gnus-newsgroup-name name
3212 gnus-newsgroup-marked marked
3213 gnus-newsgroup-spam-marked spam
3214 gnus-newsgroup-unreads unread
3215 gnus-current-headers headers
3216 gnus-newsgroup-data data
3217 gnus-article-current gac
3218 gnus-summary-buffer summary
3219 gnus-article-buffer article-buffer
3220 gnus-original-article-buffer original
3221 gnus-reffed-article-number reffed
3222 gnus-current-score-file score-file
3223 gnus-newsgroup-charset default-charset)
3224 (let ((locals gnus-newsgroup-variables))
3226 (if (consp (car locals))
3227 (set (caar locals) (pop vlist))
3228 (set (car locals) (pop vlist)))
3229 (setq locals (cdr locals))))
3230 ;; The article buffer also has local variables.
3231 (when (gnus-buffer-live-p gnus-article-buffer)
3232 (set-buffer gnus-article-buffer)
3233 (setq gnus-summary-buffer summary))))))
3235 (defun gnus-summary-article-unread-p (article)
3236 "Say whether ARTICLE is unread or not."
3237 (memq article gnus-newsgroup-unreads))
3239 (defun gnus-summary-first-article-p (&optional article)
3240 "Return whether ARTICLE is the first article in the buffer."
3241 (if (not (setq article (or article (gnus-summary-article-number))))
3243 (eq article (caar gnus-newsgroup-data))))
3245 (defun gnus-summary-last-article-p (&optional article)
3246 "Return whether ARTICLE is the last article in the buffer."
3247 (if (not (setq article (or article (gnus-summary-article-number))))
3248 ;; All non-existent numbers are the last article. :-)
3250 (not (cdr (gnus-data-find-list article)))))
3252 (defun gnus-make-thread-indent-array ()
3254 (unless (and gnus-thread-indent-array
3255 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3256 (setq gnus-thread-indent-array (make-vector 201 "")
3257 gnus-thread-indent-array-level gnus-thread-indent-level)
3259 (aset gnus-thread-indent-array n
3260 (make-string (* n gnus-thread-indent-level) ? ))
3263 (defun gnus-update-summary-mark-positions ()
3264 "Compute where the summary marks are to go."
3266 (when (gnus-buffer-exists-p gnus-summary-buffer)
3267 (set-buffer gnus-summary-buffer))
3268 (let ((gnus-replied-mark 129)
3269 (gnus-score-below-mark 130)
3270 (gnus-score-over-mark 130)
3271 (gnus-undownloaded-mark 131)
3272 (spec gnus-summary-line-format-spec)
3275 (gnus-set-work-buffer)
3276 (let ((gnus-summary-line-format-spec spec)
3277 (gnus-newsgroup-downloadable '(0)))
3278 (gnus-summary-insert-line
3279 (make-full-mail-header 0 "" "nobody"
3280 "05 Apr 2001 23:33:09 +0400"
3282 0 nil t 128 t nil "" nil 1)
3283 (goto-char (point-min))
3284 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3285 (- (point) (point-min) 1)))))
3286 (goto-char (point-min))
3287 (push (cons 'replied (and (search-forward "\201" nil t)
3288 (- (point) (point-min) 1)))
3290 (goto-char (point-min))
3291 (push (cons 'score (and (search-forward "\202" nil t)
3292 (- (point) (point-min) 1)))
3294 (goto-char (point-min))
3295 (push (cons 'download
3296 (and (search-forward "\203" nil t)
3297 (- (point) (point-min) 1)))
3299 (setq gnus-summary-mark-positions pos))))
3301 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3302 "Insert a dummy root in the summary buffer."
3304 (gnus-add-text-properties
3305 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3306 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3308 (defun gnus-summary-extract-address-component (from)
3309 (or (car (funcall gnus-extract-address-components from))
3312 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3313 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3314 default-mime-charset)))
3315 ;; Is it really necessary to do this next part for each summary line?
3316 ;; Luckily, doesn't seem to slow things down much.
3318 (and gnus-ignored-from-addresses
3319 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3320 (let ((extra-headers (mail-header-extra header))
3324 ((setq to (cdr (assq 'To extra-headers)))
3327 (gnus-summary-extract-address-component
3328 (funcall gnus-decode-encoded-word-function to)))))
3329 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3330 (concat "=> " newsgroups)))))
3331 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3333 (defun gnus-summary-insert-line (gnus-tmp-header
3334 gnus-tmp-level gnus-tmp-current
3335 undownloaded gnus-tmp-unread gnus-tmp-replied
3336 gnus-tmp-expirable gnus-tmp-subject-or-nil
3337 &optional gnus-tmp-dummy gnus-tmp-score
3339 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3340 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3341 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3342 (gnus-tmp-score-char
3343 (if (or (null gnus-summary-default-score)
3344 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3345 gnus-summary-zcore-fuzz))
3347 (if (< gnus-tmp-score gnus-summary-default-score)
3348 gnus-score-below-mark gnus-score-over-mark)))
3349 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3351 (cond (gnus-tmp-process gnus-process-mark)
3352 ((memq gnus-tmp-current gnus-newsgroup-cached)
3354 (gnus-tmp-replied gnus-replied-mark)
3355 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3356 gnus-forwarded-mark)
3357 ((memq gnus-tmp-current gnus-newsgroup-saved)
3359 ((memq gnus-tmp-number gnus-newsgroup-recent)
3361 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3364 (gnus-tmp-downloaded
3366 gnus-undownloaded-mark)
3367 (gnus-newsgroup-agentized
3368 gnus-downloaded-mark)
3371 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3374 ((string-match "<[^>]+> *$" gnus-tmp-from)
3375 (let ((beg (match-beginning 0)))
3376 (or (and (string-match "^\".+\"" gnus-tmp-from)
3377 (substring gnus-tmp-from 1 (1- (match-end 0))))
3378 (substring gnus-tmp-from 0 beg))))
3379 ((string-match "(.+)" gnus-tmp-from)
3380 (substring gnus-tmp-from
3381 (1+ (match-beginning 0)) (1- (match-end 0))))
3383 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3384 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3385 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3386 (buffer-read-only nil))
3387 (when (string= gnus-tmp-name "")
3388 (setq gnus-tmp-name gnus-tmp-from))
3389 (unless (numberp gnus-tmp-lines)
3390 (setq gnus-tmp-lines -1))
3391 (if (= gnus-tmp-lines -1)
3392 (setq gnus-tmp-lines "?")
3393 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3394 (gnus-put-text-property-excluding-characters-with-faces
3396 (progn (eval gnus-summary-line-format-spec) (point))
3397 'gnus-number gnus-tmp-number)
3398 (when (gnus-visual-p 'summary-highlight 'highlight)
3400 (gnus-run-hooks 'gnus-summary-update-hook)
3403 (defun gnus-summary-update-line (&optional dont-update)
3404 "Update summary line after change."
3405 (when (and gnus-summary-default-score
3406 (not gnus-summary-inhibit-highlight))
3407 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3408 (article (gnus-summary-article-number))
3409 (score (gnus-summary-article-score article)))
3411 (if (and gnus-summary-mark-below
3412 (< (gnus-summary-article-score)
3413 gnus-summary-mark-below))
3414 ;; This article has a low score, so we mark it as read.
3415 (when (memq article gnus-newsgroup-unreads)
3416 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3417 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3418 ;; This article was previously marked as read on account
3419 ;; of a low score, but now it has risen, so we mark it as
3421 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3422 (gnus-summary-update-mark
3423 (if (or (null gnus-summary-default-score)
3424 (<= (abs (- score gnus-summary-default-score))
3425 gnus-summary-zcore-fuzz))
3427 (if (< score gnus-summary-default-score)
3428 gnus-score-below-mark gnus-score-over-mark))
3430 ;; Do visual highlighting.
3431 (when (gnus-visual-p 'summary-highlight 'highlight)
3432 (gnus-run-hooks 'gnus-summary-update-hook)))))
3434 (defvar gnus-tmp-new-adopts nil)
3436 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3437 "Return the number of articles in THREAD.
3438 This may be 0 in some cases -- if none of the articles in
3439 the thread are to be displayed."
3441 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3443 ((not (listp thread))
3445 ((and (consp thread) (cdr thread))
3448 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3451 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3454 (when (and level (zerop level) gnus-tmp-new-adopts)
3457 'gnus-summary-number-of-articles-in-thread
3458 gnus-tmp-new-adopts))))
3460 (if (> number 1) gnus-not-empty-thread-mark
3461 gnus-empty-thread-mark)
3464 (defsubst gnus-summary-line-message-size (head)
3465 "Return pretty-printed version of message size.
3466 This function is intended to be used in
3467 `gnus-summary-line-format-alist'."
3468 (let ((c (or (mail-header-chars head) -1)))
3469 (cond ((< c 0) "n/a") ; chars not available
3470 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3471 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3472 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3473 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3476 (defun gnus-summary-set-local-parameters (group)
3477 "Go through the local params of GROUP and set all variable specs in that list."
3478 (let ((params (gnus-group-find-parameter group))
3479 (vars '(quit-config)) ; Ignore quit-config.
3482 (setq elem (car params)
3483 params (cdr params))
3484 (and (consp elem) ; Has to be a cons.
3485 (consp (cdr elem)) ; The cdr has to be a list.
3486 (symbolp (car elem)) ; Has to be a symbol in there.
3487 (not (memq (car elem) vars))
3488 (ignore-errors ; So we set it.
3489 (push (car elem) vars)
3490 (make-local-variable (car elem))
3491 (set (car elem) (eval (nth 1 elem))))))))
3493 (defun gnus-summary-read-group (group &optional show-all no-article
3494 kill-buffer no-display backward
3496 "Start reading news in newsgroup GROUP.
3497 If SHOW-ALL is non-nil, already read articles are also listed.
3498 If NO-ARTICLE is non-nil, no article is selected initially.
3499 If NO-DISPLAY, don't generate a summary buffer."
3503 (let ((gnus-auto-select-next nil))
3504 (or (gnus-summary-read-group-1
3505 group show-all no-article
3506 kill-buffer no-display
3509 select-articles nil)))))
3510 (eq gnus-auto-select-next 'quietly))
3511 (set-buffer gnus-group-buffer)
3512 ;; The entry function called above goes to the next
3513 ;; group automatically, so we go two groups back
3514 ;; if we are searching for the previous group.
3516 (gnus-group-prev-unread-group 2))
3517 (if (not (equal group (gnus-group-group-name)))
3518 (setq group (gnus-group-group-name))
3522 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3523 "Directly jump to the other GROUP from summary buffer.
3524 If SHOW-ALL is non-nil, already read articles are also listed."
3526 (if (eq gnus-summary-buffer (current-buffer))
3527 (list (completing-read
3528 "Group: " gnus-active-hashtb nil t
3529 (when (and gnus-newsgroup-name
3530 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3531 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3532 'gnus-group-history)
3534 (error "%s must be invoked from a gnus summary buffer." this-command)))
3535 (unless (or (zerop (length group))
3536 (and gnus-newsgroup-name
3537 (string-equal gnus-newsgroup-name group)))
3539 (gnus-summary-read-group group show-all
3540 gnus-dont-select-after-jump-to-other-group)))
3542 (defun gnus-summary-read-group-1 (group show-all no-article
3543 kill-buffer no-display
3544 &optional select-articles)
3545 ;; Killed foreign groups can't be entered.
3546 ;; (when (and (not (gnus-group-native-p group))
3547 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3548 ;; (error "Dead non-native groups can't be entered"))
3549 (gnus-message 5 "Retrieving newsgroup: %s..."
3550 (gnus-group-decoded-name group))
3551 (let* ((new-group (gnus-summary-setup-buffer group))
3552 (quit-config (gnus-group-quit-config group))
3553 (did-select (and new-group (gnus-select-newsgroup
3554 group show-all select-articles))))
3556 ;; This summary buffer exists already, so we just select it.
3558 (gnus-set-global-variables)
3560 (gnus-kill-or-deaden-summary kill-buffer))
3561 (gnus-configure-windows 'summary 'force)
3562 (gnus-set-mode-line 'summary)
3563 (gnus-summary-position-point)
3566 ;; We couldn't select this group.
3568 (when (and (eq major-mode 'gnus-summary-mode)
3569 (not (equal (current-buffer) kill-buffer)))
3570 (kill-buffer (current-buffer))
3571 (if (not quit-config)
3573 ;; Update the info -- marks might need to be removed,
3575 (gnus-summary-update-info)
3576 (set-buffer gnus-group-buffer)
3577 (gnus-group-jump-to-group group)
3578 (gnus-group-next-unread-group 1))
3579 (gnus-handle-ephemeral-exit quit-config)))
3580 (let ((grpinfo (gnus-get-info group)))
3581 (if (null (gnus-info-read grpinfo))
3582 (gnus-message 3 "Group %s contains no messages"
3583 (gnus-group-decoded-name group))
3584 (gnus-message 3 "Can't select group")))
3586 ;; The user did a `C-g' while prompting for number of articles,
3587 ;; so we exit this group.
3588 ((eq did-select 'quit)
3589 (and (eq major-mode 'gnus-summary-mode)
3590 (not (equal (current-buffer) kill-buffer))
3591 (kill-buffer (current-buffer)))
3593 (gnus-kill-or-deaden-summary kill-buffer))
3594 (if (not quit-config)
3596 (set-buffer gnus-group-buffer)
3597 (gnus-group-jump-to-group group)
3598 (gnus-group-next-unread-group 1)
3599 (gnus-configure-windows 'group 'force))
3600 (gnus-handle-ephemeral-exit quit-config))
3601 ;; Finally signal the quit.
3603 ;; The group was successfully selected.
3605 (gnus-set-global-variables)
3606 ;; Save the active value in effect when the group was entered.
3607 (setq gnus-newsgroup-active
3609 (gnus-active gnus-newsgroup-name)))
3610 ;; You can change the summary buffer in some way with this hook.
3611 (gnus-run-hooks 'gnus-select-group-hook)
3612 (gnus-update-format-specifications
3613 nil 'summary 'summary-mode 'summary-dummy)
3614 (gnus-update-summary-mark-positions)
3615 ;; Do score processing.
3616 (when gnus-use-scoring
3617 (gnus-possibly-score-headers))
3618 ;; Check whether to fill in the gaps in the threads.
3619 (when gnus-build-sparse-threads
3620 (gnus-build-sparse-threads))
3621 ;; Find the initial limit.
3623 (let ((gnus-newsgroup-dormant nil))
3624 (gnus-summary-initial-limit show-all))
3625 (gnus-summary-initial-limit show-all))
3626 ;; Generate the summary buffer.
3628 (gnus-summary-prepare))
3629 (when gnus-use-trees
3630 (gnus-tree-open group)
3631 (setq gnus-summary-highlight-line-function
3632 'gnus-tree-highlight-article))
3633 ;; If the summary buffer is empty, but there are some low-scored
3634 ;; articles or some excluded dormants, we include these in the
3636 (when (and (zerop (buffer-size))
3638 (cond (gnus-newsgroup-dormant
3639 (gnus-summary-limit-include-dormant))
3640 ((and gnus-newsgroup-scored show-all)
3641 (gnus-summary-limit-include-expunged t))))
3642 ;; Function `gnus-apply-kill-file' must be called in this hook.
3643 (gnus-run-hooks 'gnus-apply-kill-hook)
3644 (if (and (zerop (buffer-size))
3647 ;; This newsgroup is empty.
3648 (gnus-summary-catchup-and-exit nil t)
3649 (gnus-message 6 "No unread news")
3651 (gnus-kill-or-deaden-summary kill-buffer))
3652 ;; Return nil from this function.
3654 ;; Hide conversation thread subtrees. We cannot do this in
3655 ;; gnus-summary-prepare-hook since kill processing may not
3656 ;; work with hidden articles.
3657 (gnus-summary-maybe-hide-threads)
3659 (gnus-kill-or-deaden-summary kill-buffer))
3660 (gnus-summary-auto-select-subject)
3661 ;; Show first unread article if requested.
3662 (if (and (not no-article)
3664 gnus-newsgroup-unreads
3665 gnus-auto-select-first)
3667 (gnus-configure-windows 'summary)
3668 (let ((art (gnus-summary-article-number)))
3669 (unless (and (not gnus-plugged)
3670 (or (memq art gnus-newsgroup-undownloaded)
3671 (memq art gnus-newsgroup-downloadable)))
3672 (gnus-summary-goto-article art))))
3673 ;; Don't select any articles.
3674 (gnus-summary-position-point)
3675 (gnus-configure-windows 'summary 'force)
3676 (gnus-set-mode-line 'summary))
3677 (when (and gnus-auto-center-group
3678 (get-buffer-window gnus-group-buffer t))
3679 ;; Gotta use windows, because recenter does weird stuff if
3680 ;; the current buffer ain't the displayed window.
3681 (let ((owin (selected-window)))
3682 (select-window (get-buffer-window gnus-group-buffer t))
3683 (when (gnus-group-goto-group group)
3685 (select-window owin)))
3686 ;; Mark this buffer as "prepared".
3687 (setq gnus-newsgroup-prepared t)
3688 (gnus-run-hooks 'gnus-summary-prepared-hook)
3689 (unless (gnus-ephemeral-group-p group)
3690 (gnus-group-update-group group))
3693 (defun gnus-summary-auto-select-subject ()
3694 "Select the subject line on initial group entry."
3695 (goto-char (point-min))
3697 ((eq gnus-auto-select-subject 'best)
3698 (gnus-summary-best-unread-subject))
3699 ((eq gnus-auto-select-subject 'unread)
3700 (gnus-summary-first-unread-subject))
3701 ((eq gnus-auto-select-subject 'unseen)
3702 (gnus-summary-first-unseen-subject))
3703 ((eq gnus-auto-select-subject 'unseen-or-unread)
3704 (gnus-summary-first-unseen-or-unread-subject))
3705 ((eq gnus-auto-select-subject 'first)
3708 ((functionp gnus-auto-select-subject)
3709 (funcall gnus-auto-select-subject))))
3711 (defun gnus-summary-prepare ()
3712 "Generate the summary buffer."
3714 (let ((buffer-read-only nil))
3716 (setq gnus-newsgroup-data nil
3717 gnus-newsgroup-data-reverse nil)
3718 (gnus-run-hooks 'gnus-summary-generate-hook)
3719 ;; Generate the buffer, either with threads or without.
3720 (when gnus-newsgroup-headers
3721 (gnus-summary-prepare-threads
3722 (if gnus-show-threads
3723 (gnus-sort-gathered-threads
3724 (funcall gnus-summary-thread-gathering-function
3726 (gnus-cut-threads (gnus-make-threads)))))
3727 ;; Unthreaded display.
3728 (gnus-sort-articles gnus-newsgroup-headers))))
3729 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3730 ;; Call hooks for modifying summary buffer.
3731 (goto-char (point-min))
3732 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3734 (defsubst gnus-general-simplify-subject (subject)
3735 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3738 ;; Truncate the subject.
3739 (gnus-simplify-subject-functions
3740 (gnus-map-function gnus-simplify-subject-functions subject))
3741 ((numberp gnus-summary-gather-subject-limit)
3742 (setq subject (gnus-simplify-subject-re subject))
3743 (if (> (length subject) gnus-summary-gather-subject-limit)
3744 (substring subject 0 gnus-summary-gather-subject-limit)
3746 ;; Fuzzily simplify it.
3747 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3748 (gnus-simplify-subject-fuzzy subject))
3749 ;; Just remove the leading "Re:".
3751 (gnus-simplify-subject-re subject))))
3753 (if (and gnus-summary-gather-exclude-subject
3754 (string-match gnus-summary-gather-exclude-subject subject))
3755 nil ; This article shouldn't be gathered
3758 (defun gnus-summary-simplify-subject-query ()
3759 "Query where the respool algorithm would put this article."
3761 (gnus-summary-select-article)
3763 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3765 (defun gnus-gather-threads-by-subject (threads)
3766 "Gather threads by looking at Subject headers."
3767 (if (not gnus-summary-make-false-root)
3769 (let ((hashtb (gnus-make-hashtable 1024))
3772 subject hthread whole-subject)
3774 (setq subject (gnus-general-simplify-subject
3775 (setq whole-subject (mail-header-subject
3778 (if (setq hthread (gnus-gethash subject hashtb))
3780 ;; We enter a dummy root into the thread, if we
3781 ;; haven't done that already.
3782 (unless (stringp (caar hthread))
3783 (setcar hthread (list whole-subject (car hthread))))
3784 ;; We add this new gathered thread to this gathered
3786 (setcdr (car hthread)
3787 (nconc (cdar hthread) (list (car threads))))
3788 ;; Remove it from the list of threads.
3789 (setcdr prev (cdr threads))
3790 (setq threads prev))
3791 ;; Enter this thread into the hash table.
3792 (gnus-sethash subject
3793 (if gnus-summary-make-false-root-always
3795 ;; If you want a dummy root above all
3797 (setcar threads (list whole-subject
3803 (setq threads (cdr threads)))
3806 (defun gnus-gather-threads-by-references (threads)
3807 "Gather threads by looking at References headers."
3808 (let ((idhashtb (gnus-make-hashtable 1024))
3809 (thhashtb (gnus-make-hashtable 1024))
3812 ids references id gthread gid entered ref)
3814 (when (setq references (mail-header-references (caar threads)))
3815 (setq id (mail-header-id (caar threads))
3816 ids (inline (gnus-split-references references))
3818 (while (setq ref (pop ids))
3819 (setq ids (delete ref ids))
3820 (if (not (setq gid (gnus-gethash ref idhashtb)))
3822 (gnus-sethash ref id idhashtb)
3823 (gnus-sethash id threads thhashtb))
3824 (setq gthread (gnus-gethash gid thhashtb))
3826 ;; We enter a dummy root into the thread, if we
3827 ;; haven't done that already.
3828 (unless (stringp (caar gthread))
3829 (setcar gthread (list (mail-header-subject (caar gthread))
3831 ;; We add this new gathered thread to this gathered
3833 (setcdr (car gthread)
3834 (nconc (cdar gthread) (list (car threads)))))
3835 ;; Add it into the thread hash table.
3836 (gnus-sethash id gthread thhashtb)
3838 ;; Remove it from the list of threads.
3839 (setcdr prev (cdr threads))
3840 (setq threads prev))))
3842 (setq threads (cdr threads)))
3845 (defun gnus-sort-gathered-threads (threads)
3846 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3847 (let ((result threads))
3849 (when (stringp (caar threads))
3850 (setcdr (car threads)
3851 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3852 (setq threads (cdr threads)))
3855 (defun gnus-thread-loop-p (root thread)
3856 "Say whether ROOT is in THREAD."
3857 (let ((stack (list thread))
3860 (while (setq thread (pop stack))
3861 (setq th (cdr thread))
3863 (not (eq (caar th) root)))
3866 ;; We have found a loop.
3868 (setcdr thread (delq (car th) (cdr thread)))
3869 (if (boundp (setq ref-dep (intern "none"
3870 gnus-newsgroup-dependencies)))
3871 (setcdr (symbol-value ref-dep)
3872 (nconc (cdr (symbol-value ref-dep))
3874 (set ref-dep (list nil (car th))))
3877 ;; Push all the subthreads onto the stack.
3878 (push (cdr thread) stack)))
3881 (defun gnus-make-threads ()
3882 "Go through the dependency hashtb and find the roots. Return all threads."
3884 (while (catch 'infloop
3887 ;; Deal with self-referencing References loops.
3888 (when (and (car (symbol-value refs))
3895 (car (symbol-value refs)) thread))
3896 (cdr (symbol-value refs)))))))
3899 (unless (car (symbol-value refs))
3900 ;; These threads do not refer back to any other articles,
3901 ;; so they're roots.
3902 (setq threads (append (cdr (symbol-value refs)) threads))))
3903 gnus-newsgroup-dependencies)))
3906 ;; Build the thread tree.
3907 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3908 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3910 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3911 if it was already present.
3913 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3914 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3915 Message-IDs will be renamed to a unique Message-ID before being
3918 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3919 (let* ((id (mail-header-id header))
3920 (id-dep (and id (intern id dependencies)))
3921 parent-id ref ref-dep ref-header replaced)
3922 ;; Enter this `header' in the `dependencies' table.
3926 ;; The first two cases do the normal part: enter a new `header'
3927 ;; in the `dependencies' table.
3928 ((not (boundp id-dep))
3929 (set id-dep (list header)))
3930 ((null (car (symbol-value id-dep)))
3931 (setcar (symbol-value id-dep) header))
3933 ;; From here the `header' was already present in the
3934 ;; `dependencies' table.
3936 ;; Overrides an existing entry;
3937 ;; just set the header part of the entry.
3938 (setcar (symbol-value id-dep) header)
3941 ;; Renames the existing `header' to a unique Message-ID.
3942 ((not gnus-summary-ignore-duplicates)
3943 ;; An article with this Message-ID has already been seen.
3944 ;; We rename the Message-ID.
3945 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3947 (mail-header-set-id header id))
3949 ;; The last case ignores an existing entry, except it adds any
3950 ;; additional Xrefs (in case the two articles came from different
3952 ;; Also sets `header' to `nil' meaning that the `dependencies'
3953 ;; table was *not* modified.
3955 (mail-header-set-xref
3956 (car (symbol-value id-dep))
3957 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3959 (or (mail-header-xref header) "")))
3962 (when (and header (not replaced))
3963 ;; First check that we are not creating a References loop.
3964 (setq parent-id (gnus-parent-id (mail-header-references header)))
3965 (setq ref parent-id)
3967 (setq ref-dep (intern-soft ref dependencies))
3969 (setq ref-header (car (symbol-value ref-dep))))
3970 (if (string= id ref)
3971 ;; Yuk! This is a reference loop. Make the article be a
3974 (mail-header-set-references (car (symbol-value id-dep)) "none")
3976 (setq parent-id nil))
3977 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3978 (setq ref-dep (intern (or parent-id "none") dependencies))
3979 (if (boundp ref-dep)
3980 (setcdr (symbol-value ref-dep)
3981 (nconc (cdr (symbol-value ref-dep))
3982 (list (symbol-value id-dep))))
3983 (set ref-dep (list nil (symbol-value id-dep)))))
3986 (defun gnus-extract-message-id-from-in-reply-to (string)
3987 (if (string-match "<[^>]+>" string)
3988 (substring string (match-beginning 0) (match-end 0))
3991 (defun gnus-build-sparse-threads ()
3992 (let ((headers gnus-newsgroup-headers)
3993 (mail-parse-charset gnus-newsgroup-charset)
3994 (gnus-summary-ignore-duplicates t)
3995 header references generation relations
3996 subject child end new-child date)
3997 ;; First we create an alist of generations/relations, where
3998 ;; generations is how much we trust the relation, and the relation
4000 (gnus-message 7 "Making sparse threads...")
4002 (nnheader-set-temp-buffer " *gnus sparse threads*")
4003 (while (setq header (pop headers))
4004 (when (and (setq references (mail-header-references header))
4005 (not (string= references "")))
4007 (setq child (mail-header-id header)
4008 subject (mail-header-subject header)
4009 date (mail-header-date header)
4011 (while (search-backward ">" nil t)
4012 (setq end (1+ (point)))
4013 (when (search-backward "<" nil t)
4014 (setq new-child (buffer-substring (point) end))
4015 (push (list (incf generation)
4016 child (setq child new-child)
4020 (push (list (1+ generation) child nil subject) relations))
4022 (kill-buffer (current-buffer)))
4023 ;; Sort over trustworthiness.
4026 (when (gnus-dependencies-add-header
4027 (make-full-mail-header-from-decoded-header
4028 gnus-reffed-article-number
4029 (nth 3 relation) "" (or (nth 4 relation) "")
4031 (or (nth 2 relation) "") 0 0 "")
4032 gnus-newsgroup-dependencies nil)
4033 (push gnus-reffed-article-number gnus-newsgroup-limit)
4034 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4035 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4036 gnus-newsgroup-reads)
4037 (decf gnus-reffed-article-number)))
4038 (sort relations 'car-less-than-car))
4039 (gnus-message 7 "Making sparse threads...done")))
4041 (defun gnus-build-old-threads ()
4042 ;; Look at all the articles that refer back to old articles, and
4043 ;; fetch the headers for the articles that aren't there. This will
4044 ;; build complete threads - if the roots haven't been expired by the
4046 (let ((mail-parse-charset gnus-newsgroup-charset)
4050 (when (not (car (symbol-value refs)))
4051 (setq heads (cdr (symbol-value refs)))
4053 (if (memq (mail-header-number (caar heads))
4054 gnus-newsgroup-dormant)
4055 (setq heads (cdr heads))
4056 (setq id (symbol-name refs))
4057 (while (and (setq id (gnus-build-get-header id))
4058 (not (car (gnus-id-to-thread id)))))
4059 (setq heads nil)))))
4060 gnus-newsgroup-dependencies)))
4062 (defsubst gnus-remove-odd-characters (string)
4063 "Translate STRING into something that doesn't contain weird characters."
4064 (mm-subst-char-in-string
4066 (mm-subst-char-in-string ?\n ?\- string t) t))
4068 ;; This function has to be called with point after the article number
4069 ;; on the beginning of the line.
4070 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4071 (let ((eol (point-at-eol))
4072 (buffer (current-buffer))
4073 header references in-reply-to)
4075 ;; overview: [num subject from date id refs chars lines misc]
4078 (narrow-to-region (point) eol)
4083 (make-full-mail-header
4085 (nnheader-nov-field) ; subject
4086 (nnheader-nov-field) ; from
4087 (nnheader-nov-field) ; date
4088 (nnheader-nov-read-message-id number) ; id
4089 (setq references (nnheader-nov-field)) ; refs
4090 (nnheader-nov-read-integer) ; chars
4091 (nnheader-nov-read-integer) ; lines
4093 (if (looking-at "Xref: ")
4094 (goto-char (match-end 0)))
4095 (nnheader-nov-field)) ; Xref
4096 (nnheader-nov-parse-extra)))) ; extra
4100 (when (and (string= references "")
4101 (setq in-reply-to (mail-header-extra header))
4102 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4103 (mail-header-set-references
4104 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4106 (when gnus-alter-header-function
4107 (funcall gnus-alter-header-function header))
4108 (gnus-dependencies-add-header header dependencies force-new)))
4110 (defun gnus-build-get-header (id)
4111 "Look through the buffer of NOV lines and find the header to ID.
4112 Enter this line into the dependencies hash table, and return
4113 the id of the parent article (if any)."
4114 (let ((deps gnus-newsgroup-dependencies)
4118 (set-buffer nntp-server-buffer)
4119 (let ((case-fold-search nil))
4120 (goto-char (point-min))
4121 (while (and (not found)
4122 (search-forward id nil t))
4124 (setq found (looking-at
4125 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4126 (regexp-quote id))))
4127 (or found (beginning-of-line 2)))
4131 (setq header (gnus-nov-parse-line
4132 (read (current-buffer)) deps))
4133 (gnus-parent-id (mail-header-references header))))))
4135 (let ((number (mail-header-number header)))
4136 (push number gnus-newsgroup-limit)
4137 (push header gnus-newsgroup-headers)
4138 (if (memq number gnus-newsgroup-unselected)
4140 (setq gnus-newsgroup-unreads
4141 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4143 (setq gnus-newsgroup-unselected
4144 (delq number gnus-newsgroup-unselected)))
4145 (push number gnus-newsgroup-ancient)))))))
4147 (defun gnus-build-all-threads ()
4148 "Read all the headers."
4149 (let ((gnus-summary-ignore-duplicates t)
4150 (mail-parse-charset gnus-newsgroup-charset)
4151 (dependencies gnus-newsgroup-dependencies)
4154 (set-buffer nntp-server-buffer)
4155 (let ((case-fold-search nil))
4156 (goto-char (point-min))
4159 (setq article (read (current-buffer))
4160 header (gnus-nov-parse-line article dependencies)))
4162 (with-current-buffer gnus-summary-buffer
4163 (push header gnus-newsgroup-headers)
4164 (if (memq (setq article (mail-header-number header))
4165 gnus-newsgroup-unselected)
4167 (setq gnus-newsgroup-unreads
4168 (gnus-add-to-sorted-list
4169 gnus-newsgroup-unreads article))
4170 (setq gnus-newsgroup-unselected
4171 (delq article gnus-newsgroup-unselected)))
4172 (push article gnus-newsgroup-ancient)))
4173 (forward-line 1)))))))
4175 (defun gnus-summary-update-article-line (article header)
4176 "Update the line for ARTICLE using HEADER."
4177 (let* ((id (mail-header-id header))
4178 (thread (gnus-id-to-thread id)))
4180 (error "Article in no thread"))
4181 ;; Update the thread.
4182 (setcar thread header)
4183 (gnus-summary-goto-subject article)
4184 (let* ((datal (gnus-data-find-list article))
4186 (buffer-read-only nil)
4187 (level (gnus-summary-thread-level)))
4189 (let ((inserted (- (point)
4191 (gnus-summary-insert-line
4193 (memq article gnus-newsgroup-undownloaded)
4194 (gnus-article-mark article)
4195 (memq article gnus-newsgroup-replied)
4196 (memq article gnus-newsgroup-expirable)
4197 ;; Only insert the Subject string when it's different
4198 ;; from the previous Subject string.
4203 (mail-header-subject
4206 (gnus-data-find-list
4208 (gnus-data-list t)))))
4209 ;; Error on the side of excessive subjects.
4211 (mail-header-subject header)))
4213 (mail-header-subject header))
4214 nil (cdr (assq article gnus-newsgroup-scored))
4215 (memq article gnus-newsgroup-processable))
4218 (gnus-data-update-list
4220 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4222 (defun gnus-summary-update-article (article &optional iheader)
4223 "Update ARTICLE in the summary buffer."
4224 (set-buffer gnus-summary-buffer)
4225 (let* ((header (gnus-summary-article-header article))
4226 (id (mail-header-id header))
4227 (data (gnus-data-find article))
4228 (thread (gnus-id-to-thread id))
4229 (references (mail-header-references header))
4233 (when (and references
4234 (not (equal "" references)))
4237 (buffer-read-only nil)
4243 (delq thread parent)))
4244 (if (gnus-summary-insert-subject id header)
4245 ;; Set the (possibly) new article number in the data structure.
4246 (gnus-data-set-number data (gnus-id-to-article id))
4250 (defun gnus-rebuild-thread (id &optional line)
4251 "Rebuild the thread containing ID.
4252 If LINE, insert the rebuilt thread starting on line LINE."
4253 (let ((buffer-read-only nil)
4254 old-pos current thread data)
4255 (if (not gnus-show-threads)
4256 (setq thread (list (car (gnus-id-to-thread id))))
4257 ;; Get the thread this article is part of.
4258 (setq thread (gnus-remove-thread id)))
4259 (setq old-pos (point-at-bol))
4260 (setq current (save-excursion
4261 (and (re-search-backward "[\r\n]" nil t)
4262 (gnus-summary-article-number))))
4263 ;; If this is a gathered thread, we have to go some re-gathering.
4264 (when (stringp (car thread))
4265 (let ((subject (car thread))
4267 (setq thread (cdr thread))
4269 (unless (memq (setq thr (gnus-id-to-thread
4271 (mail-header-id (caar thread)))))
4274 (setq thread (cdr thread)))
4275 ;; We now have all (unique) roots.
4276 (if (= (length roots) 1)
4277 ;; All the loose roots are now one solid root.
4278 (setq thread (car roots))
4279 (setq thread (cons subject (gnus-sort-threads roots))))))
4281 ;; We then insert this thread into the summary buffer.
4283 (goto-char (point-min))
4284 (forward-line (1- line)))
4285 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4286 (if gnus-show-threads
4287 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4288 (gnus-summary-prepare-unthreaded thread))
4289 (setq data (nreverse gnus-newsgroup-data))
4290 (setq threads gnus-newsgroup-threads))
4291 ;; We splice the new data into the data structure.
4292 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4293 ;;!!! then we want to insert at the beginning of the buffer.
4294 ;;!!! That happens to be true with Gnus now, but that may
4295 ;;!!! change in the future. Perhaps.
4296 (gnus-data-enter-list
4297 (if line nil current) data (- (point) old-pos))
4298 (setq gnus-newsgroup-threads
4299 (nconc threads gnus-newsgroup-threads))
4300 (gnus-data-compute-positions))))
4302 (defun gnus-number-to-header (number)
4303 "Return the header for article NUMBER."
4304 (let ((headers gnus-newsgroup-headers))
4306 (not (= number (mail-header-number (car headers)))))
4311 (defun gnus-parent-headers (in-headers &optional generation)
4312 "Return the headers of the GENERATIONeth parent of HEADERS."
4314 (setq generation 1))
4316 (headers in-headers)
4319 (not (zerop generation))
4320 (setq references (mail-header-references headers)))
4321 (setq headers (if (and references
4322 (setq parent (gnus-parent-id references)))
4323 (car (gnus-id-to-thread parent))
4326 (and (not (eq headers in-headers))
4329 (defun gnus-id-to-thread (id)
4330 "Return the (sub-)thread where ID appears."
4331 (gnus-gethash id gnus-newsgroup-dependencies))
4333 (defun gnus-id-to-article (id)
4334 "Return the article number of ID."
4335 (let ((thread (gnus-id-to-thread id)))
4338 (mail-header-number (car thread)))))
4340 (defun gnus-id-to-header (id)
4341 "Return the article headers of ID."
4342 (car (gnus-id-to-thread id)))
4344 (defun gnus-article-displayed-root-p (article)
4345 "Say whether ARTICLE is a root(ish) article."
4346 (let ((level (gnus-summary-thread-level article))
4347 (refs (mail-header-references (gnus-summary-article-header article)))
4353 ((null (gnus-parent-id refs)) t)
4355 (null (setq particle (gnus-id-to-article
4356 (gnus-parent-id refs))))
4357 (null (gnus-summary-thread-level particle)))))))
4359 (defun gnus-root-id (id)
4360 "Return the id of the root of the thread where ID appears."
4362 (while (and id (setq prev (car (gnus-id-to-thread id))))
4364 id (gnus-parent-id (mail-header-references prev))))
4367 (defun gnus-articles-in-thread (thread)
4368 "Return the list of articles in THREAD."
4369 (cons (mail-header-number (car thread))
4370 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4372 (defun gnus-remove-thread (id &optional dont-remove)
4373 "Remove the thread that has ID in it."
4374 (let (headers thread last-id)
4375 ;; First go up in this thread until we find the root.
4376 (setq last-id (gnus-root-id id)
4377 headers (message-flatten-list (gnus-id-to-thread last-id)))
4378 ;; We have now found the real root of this thread. It might have
4379 ;; been gathered into some loose thread, so we have to search
4380 ;; through the threads to find the thread we wanted.
4381 (let ((threads gnus-newsgroup-threads)
4384 (setq sub (car threads))
4385 (if (stringp (car sub))
4386 ;; This is a gathered thread, so we look at the roots
4387 ;; below it to find whether this article is in this
4390 (setq sub (cdr sub))
4392 (when (member (caar sub) headers)
4393 (setq thread (car threads)
4396 (setq sub (cdr sub))))
4397 ;; It's an ordinary thread, so we check it.
4398 (when (eq (car sub) (car headers))
4401 (setq threads (cdr threads)))
4402 ;; If this article is in no thread, then it's a root.
4405 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4406 (setq thread (gnus-id-to-thread last-id)))
4409 thread ; We return this thread.
4411 (if (stringp (car thread))
4413 ;; If we use dummy roots, then we have to remove the
4414 ;; dummy root as well.
4415 (when (eq gnus-summary-make-false-root 'dummy)
4416 ;; We go to the dummy root by going to
4417 ;; the first sub-"thread", and then one line up.
4418 (gnus-summary-goto-article
4419 (mail-header-number (caadr thread)))
4422 (gnus-data-compute-positions))
4423 (setq thread (cdr thread))
4425 (gnus-remove-thread-1 (car thread))
4426 (setq thread (cdr thread))))
4427 (gnus-remove-thread-1 thread))))))))
4429 (defun gnus-remove-thread-1 (thread)
4430 "Remove the thread THREAD recursively."
4431 (let ((number (mail-header-number (pop thread)))
4433 (setq thread (reverse thread))
4435 (gnus-remove-thread-1 (pop thread)))
4436 (when (setq d (gnus-data-find number))
4437 (goto-char (gnus-data-pos d))
4438 (gnus-summary-show-thread)
4444 (gnus-delete-line)))))))
4446 (defun gnus-sort-threads-1 (threads func)
4447 (sort (mapcar (lambda (thread)
4450 (gnus-sort-threads-1 (cdr thread) func))))
4453 (defun gnus-sort-threads (threads)
4455 (if (not gnus-thread-sort-functions)
4457 (gnus-message 8 "Sorting threads...")
4458 (let ((max-lisp-eval-depth 5000))
4459 (prog1 (gnus-sort-threads-1
4461 (gnus-make-sort-function gnus-thread-sort-functions))
4462 (gnus-message 8 "Sorting threads...done")))))
4464 (defun gnus-sort-articles (articles)
4466 (when gnus-article-sort-functions
4467 (gnus-message 7 "Sorting articles...")
4469 (setq gnus-newsgroup-headers
4470 (sort articles (gnus-make-sort-function
4471 gnus-article-sort-functions)))
4472 (gnus-message 7 "Sorting articles...done"))))
4474 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4475 (defmacro gnus-thread-header (thread)
4476 "Return header of first article in THREAD.
4477 Note that THREAD must never, ever be anything else than a variable -
4478 using some other form will lead to serious barfage."
4479 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4480 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4481 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4484 (defsubst gnus-article-sort-by-number (h1 h2)
4485 "Sort articles by article number."
4486 (< (mail-header-number h1)
4487 (mail-header-number h2)))
4489 (defun gnus-thread-sort-by-number (h1 h2)
4490 "Sort threads by root article number."
4491 (gnus-article-sort-by-number
4492 (gnus-thread-header h1) (gnus-thread-header h2)))
4494 (defsubst gnus-article-sort-by-random (h1 h2)
4495 "Sort articles by article number."
4498 (defun gnus-thread-sort-by-random (h1 h2)
4499 "Sort threads by root article number."
4500 (gnus-article-sort-by-random
4501 (gnus-thread-header h1) (gnus-thread-header h2)))
4503 (defsubst gnus-article-sort-by-lines (h1 h2)
4504 "Sort articles by article Lines header."
4505 (< (mail-header-lines h1)
4506 (mail-header-lines h2)))
4508 (defun gnus-thread-sort-by-lines (h1 h2)
4509 "Sort threads by root article Lines header."
4510 (gnus-article-sort-by-lines
4511 (gnus-thread-header h1) (gnus-thread-header h2)))
4513 (defsubst gnus-article-sort-by-chars (h1 h2)
4514 "Sort articles by octet length."
4515 (< (mail-header-chars h1)
4516 (mail-header-chars h2)))
4518 (defun gnus-thread-sort-by-chars (h1 h2)
4519 "Sort threads by root article octet length."
4520 (gnus-article-sort-by-chars
4521 (gnus-thread-header h1) (gnus-thread-header h2)))
4523 (defsubst gnus-article-sort-by-author (h1 h2)
4524 "Sort articles by root author."
4526 (let ((addr (car (mime-entity-read-field h1 'From))))
4527 (or (std11-full-name-string addr)
4528 (std11-address-string addr)
4530 (let ((addr (car (mime-entity-read-field h2 'From))))
4531 (or (std11-full-name-string addr)
4532 (std11-address-string addr)
4536 (defun gnus-thread-sort-by-author (h1 h2)
4537 "Sort threads by root author."
4538 (gnus-article-sort-by-author
4539 (gnus-thread-header h1) (gnus-thread-header h2)))
4541 (defsubst gnus-article-sort-by-subject (h1 h2)
4542 "Sort articles by root subject."
4544 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4545 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4547 (defun gnus-thread-sort-by-subject (h1 h2)
4548 "Sort threads by root subject."
4549 (gnus-article-sort-by-subject
4550 (gnus-thread-header h1) (gnus-thread-header h2)))
4552 (defsubst gnus-article-sort-by-date (h1 h2)
4553 "Sort articles by root article date."
4555 (gnus-date-get-time (mail-header-date h1))
4556 (gnus-date-get-time (mail-header-date h2))))
4558 (defun gnus-thread-sort-by-date (h1 h2)
4559 "Sort threads by root article date."
4560 (gnus-article-sort-by-date
4561 (gnus-thread-header h1) (gnus-thread-header h2)))
4563 (defsubst gnus-article-sort-by-score (h1 h2)
4564 "Sort articles by root article score.
4565 Unscored articles will be counted as having a score of zero."
4566 (> (or (cdr (assq (mail-header-number h1)
4567 gnus-newsgroup-scored))
4568 gnus-summary-default-score 0)
4569 (or (cdr (assq (mail-header-number h2)
4570 gnus-newsgroup-scored))
4571 gnus-summary-default-score 0)))
4573 (defun gnus-thread-sort-by-score (h1 h2)
4574 "Sort threads by root article score."
4575 (gnus-article-sort-by-score
4576 (gnus-thread-header h1) (gnus-thread-header h2)))
4578 (defun gnus-thread-sort-by-total-score (h1 h2)
4579 "Sort threads by the sum of all scores in the thread.
4580 Unscored articles will be counted as having a score of zero."
4581 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4583 (defun gnus-thread-total-score (thread)
4584 ;; This function find the total score of THREAD.
4589 (if (stringp (car thread))
4590 (apply gnus-thread-score-function 0
4591 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4592 (gnus-thread-total-score-1 thread)))
4594 (gnus-thread-total-score-1 (list thread)))))
4596 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4597 "Sort threads such that the thread with the most recently arrived article comes first."
4598 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4600 (defun gnus-thread-highest-number (thread)
4601 "Return the highest article number in THREAD."
4602 (apply 'max (mapcar (lambda (header)
4603 (mail-header-number header))
4604 (message-flatten-list thread))))
4606 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4607 "Sort threads such that the thread with the most recently dated article comes first."
4608 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4610 (defun gnus-thread-latest-date (thread)
4611 "Return the highest article date in THREAD."
4612 (let ((previous-time 0))
4618 (time-to-seconds (mail-header-parse-date
4619 (mail-header-date header)))
4620 (error previous-time))))
4622 (message-flatten-list thread)
4624 (< (mail-header-number h1)
4625 (mail-header-number h2))))))))
4627 (defun gnus-thread-total-score-1 (root)
4628 ;; This function find the total score of the thread below ROOT.
4629 (setq root (car root))
4630 (apply gnus-thread-score-function
4632 (mapcar 'gnus-thread-total-score
4633 (cdr (gnus-id-to-thread (mail-header-id root))))
4634 (when (> (mail-header-number root) 0)
4635 (list (or (cdr (assq (mail-header-number root)
4636 gnus-newsgroup-scored))
4637 gnus-summary-default-score 0))))
4638 (list gnus-summary-default-score)
4641 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4642 (defvar gnus-tmp-prev-subject nil)
4643 (defvar gnus-tmp-false-parent nil)
4644 (defvar gnus-tmp-root-expunged nil)
4645 (defvar gnus-tmp-dummy-line nil)
4647 (eval-when-compile (defvar gnus-tmp-header))
4648 (defun gnus-extra-header (type &optional header)
4649 "Return the extra header of TYPE."
4650 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4653 (defvar gnus-tmp-thread-tree-header-string "")
4655 (defcustom gnus-sum-thread-tree-root "> "
4656 "With %B spec, used for the root of a thread.
4657 If nil, use subject instead."
4659 :type '(radio (const :format "%v " nil) (string :size 0))
4660 :group 'gnus-thread)
4661 (defcustom gnus-sum-thread-tree-false-root "> "
4662 "With %B spec, used for a false root of a thread.
4663 If nil, use subject instead."
4665 :type '(radio (const :format "%v " nil) (string :size 0))
4666 :group 'gnus-thread)
4667 (defcustom gnus-sum-thread-tree-single-indent ""
4668 "With %B spec, used for a thread with just one message.
4669 If nil, use subject instead."
4671 :type '(radio (const :format "%v " nil) (string :size 0))
4672 :group 'gnus-thread)
4673 (defcustom gnus-sum-thread-tree-vertical "| "
4674 "With %B spec, used for drawing a vertical line."
4677 :group 'gnus-thread)
4678 (defcustom gnus-sum-thread-tree-indent " "
4679 "With %B spec, used for indenting."
4682 :group 'gnus-thread)
4683 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4684 "With %B spec, used for a leaf with brothers."
4687 :group 'gnus-thread)
4688 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4689 "With %B spec, used for a leaf without brothers."
4692 :group 'gnus-thread)
4694 (defun gnus-summary-prepare-threads (threads)
4695 "Prepare summary buffer from THREADS and indentation LEVEL.
4696 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4697 or a straight list of headers."
4698 (gnus-message 7 "Generating summary...")
4700 (setq gnus-newsgroup-threads threads)
4703 (let ((gnus-tmp-level 0)
4704 (default-score (or gnus-summary-default-score 0))
4705 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4706 (building-line-count gnus-summary-display-while-building)
4707 (building-count (integerp gnus-summary-display-while-building))
4708 thread number subject stack state gnus-tmp-gathered beg-match
4709 new-roots gnus-tmp-new-adopts thread-end simp-subject
4710 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4711 gnus-tmp-replied gnus-tmp-subject-or-nil
4712 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4713 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4714 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4717 (setq gnus-tmp-prev-subject nil
4718 gnus-tmp-thread-tree-header-string "")
4720 (if (vectorp (car threads))
4721 ;; If this is a straight (sic) list of headers, then a
4722 ;; threaded summary display isn't required, so we just create
4723 ;; an unthreaded one.
4724 (gnus-summary-prepare-unthreaded threads)
4726 ;; Do the threaded display.
4728 (if gnus-summary-display-while-building
4729 (switch-to-buffer (buffer-name)))
4730 (while (or threads stack gnus-tmp-new-adopts new-roots)
4732 (if (and (= gnus-tmp-level 0)
4735 (not gnus-tmp-false-parent)
4736 (or gnus-tmp-new-adopts new-roots))
4737 (if gnus-tmp-new-adopts
4738 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4739 thread (list (car gnus-tmp-new-adopts))
4740 gnus-tmp-header (caar thread)
4741 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4743 (setq thread (list (car new-roots))
4744 gnus-tmp-header (caar thread)
4745 new-roots (cdr new-roots))))
4748 ;; If there are some threads, we do them before the
4749 ;; threads on the stack.
4750 (setq thread threads
4751 gnus-tmp-header (caar thread))
4752 ;; There were no current threads, so we pop something off
4754 (setq state (car stack)
4755 gnus-tmp-level (car state)
4756 tree-stack (cadr state)
4757 thread (caddr state)
4759 gnus-tmp-header (caar thread))))
4761 (setq gnus-tmp-false-parent nil)
4762 (setq gnus-tmp-root-expunged nil)
4763 (setq thread-end nil)
4765 (if (stringp gnus-tmp-header)
4766 ;; The header is a dummy root.
4768 ((eq gnus-summary-make-false-root 'adopt)
4769 ;; We let the first article adopt the rest.
4770 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4772 (setq gnus-tmp-gathered
4774 (lambda (h) (mail-header-number (car h)))
4777 (setq thread (cons (list (caar thread)
4780 (setq gnus-tmp-level -1
4781 gnus-tmp-false-parent t))
4782 ((eq gnus-summary-make-false-root 'empty)
4783 ;; We print adopted articles with empty subject fields.
4784 (setq gnus-tmp-gathered
4786 (lambda (h) (mail-header-number (car h)))
4789 (setq gnus-tmp-level -1))
4790 ((eq gnus-summary-make-false-root 'dummy)
4791 ;; We remember that we probably want to output a dummy
4793 (setq gnus-tmp-dummy-line gnus-tmp-header)
4794 (setq gnus-tmp-prev-subject gnus-tmp-header))
4796 ;; We do not make a root for the gathered
4797 ;; sub-threads at all.
4798 (setq gnus-tmp-level -1)))
4800 (setq number (mail-header-number gnus-tmp-header)
4801 subject (mail-header-subject gnus-tmp-header)
4802 simp-subject (gnus-simplify-subject-fully subject))
4805 ;; If the thread has changed subject, we might want to make
4806 ;; this subthread into a root.
4807 ((and (null gnus-thread-ignore-subject)
4808 (not (zerop gnus-tmp-level))
4809 gnus-tmp-prev-subject
4810 (not (string= gnus-tmp-prev-subject simp-subject)))
4811 (setq new-roots (nconc new-roots (list (car thread)))
4813 gnus-tmp-header nil))
4814 ;; If the article lies outside the current limit,
4815 ;; then we do not display it.
4816 ((not (memq number gnus-newsgroup-limit))
4817 (setq gnus-tmp-gathered
4819 (lambda (h) (mail-header-number (car h)))
4822 (setq gnus-tmp-new-adopts (if (cdar thread)
4823 (append gnus-tmp-new-adopts
4825 gnus-tmp-new-adopts)
4827 gnus-tmp-header nil)
4828 (when (zerop gnus-tmp-level)
4829 (setq gnus-tmp-root-expunged t)))
4830 ;; Perhaps this article is to be marked as read?
4831 ((and gnus-summary-mark-below
4832 (< (or (cdr (assq number gnus-newsgroup-scored))
4834 gnus-summary-mark-below)
4835 ;; Don't touch sparse articles.
4836 (not (gnus-summary-article-sparse-p number))
4837 (not (gnus-summary-article-ancient-p number)))
4838 (setq gnus-newsgroup-unreads
4839 (delq number gnus-newsgroup-unreads))
4840 (if gnus-newsgroup-auto-expire
4841 (setq gnus-newsgroup-expirable
4842 (gnus-add-to-sorted-list
4843 gnus-newsgroup-expirable number))
4844 (push (cons number gnus-low-score-mark)
4845 gnus-newsgroup-reads))))
4847 (when gnus-tmp-header
4848 ;; We may have an old dummy line to output before this
4850 (when (and gnus-tmp-dummy-line
4853 (mail-header-subject gnus-tmp-header)))
4854 (gnus-summary-insert-dummy-line
4855 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4856 (setq gnus-tmp-dummy-line nil))
4858 ;; Compute the mark.
4859 (setq gnus-tmp-unread (gnus-article-mark number))
4861 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4862 gnus-tmp-header gnus-tmp-level)
4863 gnus-newsgroup-data)
4865 ;; Actually insert the line.
4867 gnus-tmp-subject-or-nil
4869 ((and gnus-thread-ignore-subject
4870 gnus-tmp-prev-subject
4871 (not (string= gnus-tmp-prev-subject simp-subject)))
4873 ((zerop gnus-tmp-level)
4874 (if (and (eq gnus-summary-make-false-root 'empty)
4875 (memq number gnus-tmp-gathered)
4876 gnus-tmp-prev-subject
4877 (string= gnus-tmp-prev-subject simp-subject))
4878 gnus-summary-same-subject
4880 (t gnus-summary-same-subject)))
4881 (if (and (eq gnus-summary-make-false-root 'adopt)
4882 (= gnus-tmp-level 1)
4883 (memq number gnus-tmp-gathered))
4884 (setq gnus-tmp-opening-bracket ?\<
4885 gnus-tmp-closing-bracket ?\>)
4886 (setq gnus-tmp-opening-bracket ?\[
4887 gnus-tmp-closing-bracket ?\]))
4889 gnus-tmp-indentation
4890 (aref gnus-thread-indent-array gnus-tmp-level)
4891 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4892 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4893 gnus-summary-default-score 0)
4895 (if (or (null gnus-summary-default-score)
4896 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4897 gnus-summary-zcore-fuzz))
4899 (if (< gnus-tmp-score gnus-summary-default-score)
4900 gnus-score-below-mark gnus-score-over-mark))
4902 (cond ((memq number gnus-newsgroup-processable)
4904 ((memq number gnus-newsgroup-cached)
4906 ((memq number gnus-newsgroup-replied)
4908 ((memq number gnus-newsgroup-forwarded)
4909 gnus-forwarded-mark)
4910 ((memq number gnus-newsgroup-saved)
4912 ((memq number gnus-newsgroup-recent)
4914 ((memq number gnus-newsgroup-unseen)
4918 (cond ((memq number gnus-newsgroup-undownloaded)
4919 gnus-undownloaded-mark)
4920 (gnus-newsgroup-agentized
4921 gnus-downloaded-mark)
4924 gnus-tmp-from (mail-header-from gnus-tmp-header)
4927 ((string-match "<[^>]+> *$" gnus-tmp-from)
4928 (setq beg-match (match-beginning 0))
4929 (or (and (string-match "^\".+\"" gnus-tmp-from)
4930 (substring gnus-tmp-from 1 (1- (match-end 0))))
4931 (substring gnus-tmp-from 0 beg-match)))
4932 ((string-match "(.+)" gnus-tmp-from)
4933 (substring gnus-tmp-from
4934 (1+ (match-beginning 0)) (1- (match-end 0))))
4938 gnus-tmp-thread-tree-header-string
4940 ((not gnus-show-threads) "")
4941 ((zerop gnus-tmp-level)
4942 (cond ((cdar thread)
4943 (or gnus-sum-thread-tree-root subject))
4944 (gnus-tmp-new-adopts
4945 (or gnus-sum-thread-tree-false-root subject))
4947 (or gnus-sum-thread-tree-single-indent subject))))
4949 (concat (apply 'concat
4950 (mapcar (lambda (item)
4952 gnus-sum-thread-tree-vertical
4953 gnus-sum-thread-tree-indent))
4954 (cdr (reverse tree-stack))))
4956 gnus-sum-thread-tree-leaf-with-other
4957 gnus-sum-thread-tree-single-leaf)))))
4958 (when (string= gnus-tmp-name "")
4959 (setq gnus-tmp-name gnus-tmp-from))
4960 (unless (numberp gnus-tmp-lines)
4961 (setq gnus-tmp-lines -1))
4962 (if (= gnus-tmp-lines -1)
4963 (setq gnus-tmp-lines "?")
4964 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4965 (gnus-put-text-property
4967 (progn (eval gnus-summary-line-format-spec) (point))
4968 'gnus-number number)
4971 (gnus-run-hooks 'gnus-summary-update-hook)
4974 (setq gnus-tmp-prev-subject simp-subject)))
4976 (when (nth 1 thread)
4977 (push (list (max 0 gnus-tmp-level)
4978 (copy-sequence tree-stack)
4981 (push (if (nth 1 thread) 1 0) tree-stack)
4982 (incf gnus-tmp-level)
4983 (setq threads (if thread-end nil (cdar thread)))
4984 (if gnus-summary-display-while-building
4987 ;; use a set frequency
4988 (setq building-line-count (1- building-line-count))
4989 (when (= building-line-count 0)
4991 (setq building-line-count
4992 gnus-summary-display-while-building)))
4996 (setq gnus-tmp-level 0)))))
4997 (gnus-message 7 "Generating summary...done"))
4999 (defun gnus-summary-prepare-unthreaded (headers)
5000 "Generate an unthreaded summary buffer based on HEADERS."
5001 (let (header number mark)
5006 ;; We may have to root out some bad articles...
5007 (when (memq (setq number (mail-header-number
5008 (setq header (pop headers))))
5009 gnus-newsgroup-limit)
5010 ;; Mark article as read when it has a low score.
5011 (when (and gnus-summary-mark-below
5012 (< (or (cdr (assq number gnus-newsgroup-scored))
5013 gnus-summary-default-score 0)
5014 gnus-summary-mark-below)
5015 (not (gnus-summary-article-ancient-p number)))
5016 (setq gnus-newsgroup-unreads
5017 (delq number gnus-newsgroup-unreads))
5018 (if gnus-newsgroup-auto-expire
5019 (push number gnus-newsgroup-expirable)
5020 (push (cons number gnus-low-score-mark)
5021 gnus-newsgroup-reads)))
5023 (setq mark (gnus-article-mark number))
5024 (push (gnus-data-make number mark (1+ (point)) header 0)
5025 gnus-newsgroup-data)
5026 (gnus-summary-insert-line
5028 (memq number gnus-newsgroup-undownloaded)
5029 mark (memq number gnus-newsgroup-replied)
5030 (memq number gnus-newsgroup-expirable)
5031 (mail-header-subject header) nil
5032 (cdr (assq number gnus-newsgroup-scored))
5033 (memq number gnus-newsgroup-processable))))))
5035 (defun gnus-summary-remove-list-identifiers ()
5036 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5037 (let ((regexp (if (consp gnus-list-identifiers)
5038 (mapconcat 'identity gnus-list-identifiers " *\\|")
5039 gnus-list-identifiers))
5042 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5043 (dolist (header gnus-newsgroup-headers)
5044 (setq subject (mail-header-subject header)
5046 (while (string-match regexp subject)
5048 (concat (substring subject 0 (match-beginning 1))
5049 (substring subject (match-end 0)))
5052 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5054 (concat (substring subject 0 (match-beginning 1))
5055 (substring subject (match-end 1)))))
5056 (mail-header-set-subject header subject))))))
5058 (defun gnus-fetch-headers (articles)
5059 "Fetch headers of ARTICLES."
5060 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5061 (gnus-message 5 "Fetching headers for %s..." name)
5064 (setq gnus-headers-retrieved-by
5065 (gnus-retrieve-headers
5066 articles gnus-newsgroup-name
5067 ;; We might want to fetch old headers, but
5068 ;; not if there is only 1 article.
5070 (not (eq gnus-fetch-old-headers 'some))
5071 (not (numberp gnus-fetch-old-headers)))
5072 (> (length articles) 1))
5073 gnus-fetch-old-headers))))
5074 (gnus-get-newsgroup-headers-xover
5075 articles nil nil gnus-newsgroup-name t)
5076 (gnus-get-newsgroup-headers))
5077 (gnus-message 5 "Fetching headers for %s...done" name))))
5079 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5080 "Select newsgroup GROUP.
5081 If READ-ALL is non-nil, all articles in the group are selected.
5082 If SELECT-ARTICLES, only select those articles from GROUP."
5083 (let* ((entry (gnus-group-entry group))
5084 ;;!!! Dirty hack; should be removed.
5085 (gnus-summary-ignore-duplicates
5086 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5088 gnus-summary-ignore-duplicates))
5089 (info (nth 2 entry))
5090 articles fetched-articles cached)
5092 (unless (gnus-check-server
5093 (set (make-local-variable 'gnus-current-select-method)
5094 (gnus-find-method-for-group group)))
5095 (error "Couldn't open server"))
5097 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5098 (gnus-activate-group group) ; Or we can activate it...
5099 (progn ; Or we bug out.
5100 (when (equal major-mode 'gnus-summary-mode)
5101 (gnus-kill-buffer (current-buffer)))
5102 (error "Couldn't activate group %s: %s"
5103 group (gnus-status-message group))))
5105 (unless (gnus-request-group group t)
5106 (when (equal major-mode 'gnus-summary-mode)
5107 (gnus-kill-buffer (current-buffer)))
5108 (error "Couldn't request group %s: %s"
5109 group (gnus-status-message group)))
5112 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5114 (setq gnus-summary-use-undownloaded-faces
5115 (gnus-agent-find-parameter
5117 'agent-enable-undownloaded-faces)))
5119 (setq gnus-newsgroup-name group
5120 gnus-newsgroup-unselected nil
5121 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5123 (let ((display (gnus-group-find-parameter group 'display)))
5124 (setq gnus-newsgroup-display
5126 ((not (zerop (or (car-safe read-all) 0)))
5127 ;; The user entered the group with C-u SPC/RET, let's show
5133 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5135 ;; The following is probably the "correct" solution, but
5136 ;; it makes Gnus fetch all headers and then limit the
5137 ;; articles (which is slow), so instead we hack the
5138 ;; select-articles parameter instead. -- Simon Josefsson
5141 ;; (gnus-byte-compile
5142 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5144 (setq select-articles
5145 (gnus-uncompress-range
5146 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5150 (cdr (gnus-active group)))))
5155 (gnus-summary-setup-default-charset)
5157 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5158 (when (gnus-virtual-group-p group)
5159 (setq cached gnus-newsgroup-cached))
5161 (setq gnus-newsgroup-unreads
5162 (gnus-sorted-ndifference
5163 (gnus-sorted-ndifference gnus-newsgroup-unreads
5164 gnus-newsgroup-marked)
5165 gnus-newsgroup-dormant))
5167 (setq gnus-newsgroup-processable nil)
5169 (gnus-update-read-articles group gnus-newsgroup-unreads)
5171 ;; Adjust and set lists of article marks.
5173 (gnus-adjust-marked-articles info))
5174 (if (setq articles select-articles)
5175 (setq gnus-newsgroup-unselected
5176 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5177 (setq articles (gnus-articles-to-read group read-all)))
5181 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5183 ((eq articles 0) nil)
5185 ;; Init the dependencies hash table.
5186 (setq gnus-newsgroup-dependencies
5187 (gnus-make-hashtable (length articles)))
5188 (gnus-set-global-variables)
5189 ;; Retrieve the headers and read them in.
5191 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5193 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5195 (setq gnus-newsgroup-cached cached))
5197 ;; Suppress duplicates?
5198 (when gnus-suppress-duplicates
5199 (gnus-dup-suppress-articles))
5201 ;; Set the initial limit.
5202 (setq gnus-newsgroup-limit (copy-sequence articles))
5203 ;; Remove canceled articles from the list of unread articles.
5204 (setq fetched-articles
5205 (mapcar (lambda (headers) (mail-header-number headers))
5206 gnus-newsgroup-headers))
5207 (setq gnus-newsgroup-articles fetched-articles)
5208 (setq gnus-newsgroup-unreads
5209 (gnus-sorted-nintersection
5210 gnus-newsgroup-unreads fetched-articles))
5211 (gnus-compute-unseen-list)
5213 ;; Removed marked articles that do not exist.
5214 (gnus-update-missing-marks
5215 (gnus-sorted-difference articles fetched-articles))
5216 ;; We might want to build some more threads first.
5217 (when (and gnus-fetch-old-headers
5218 (eq gnus-headers-retrieved-by 'nov))
5219 (if (eq gnus-fetch-old-headers 'invisible)
5220 (gnus-build-all-threads)
5221 (gnus-build-old-threads)))
5222 ;; Let the Gnus agent mark articles as read.
5224 (gnus-agent-get-undownloaded-list))
5225 ;; Remove list identifiers from subject
5226 (when gnus-list-identifiers
5227 (gnus-summary-remove-list-identifiers))
5228 ;; Check whether auto-expire is to be done in this group.
5229 (setq gnus-newsgroup-auto-expire
5230 (gnus-group-auto-expirable-p group))
5231 ;; Set up the article buffer now, if necessary.
5232 (unless gnus-single-article-buffer
5233 (gnus-article-setup-buffer))
5234 ;; First and last article in this newsgroup.
5235 (when gnus-newsgroup-headers
5236 (setq gnus-newsgroup-begin
5237 (mail-header-number (car gnus-newsgroup-headers))
5240 (gnus-last-element gnus-newsgroup-headers))))
5241 ;; GROUP is successfully selected.
5242 (or gnus-newsgroup-headers t)))))
5244 (defun gnus-compute-unseen-list ()
5245 ;; The `seen' marks are treated specially.
5246 (if (not gnus-newsgroup-seen)
5247 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5248 (setq gnus-newsgroup-unseen
5249 (gnus-inverse-list-range-intersection
5250 gnus-newsgroup-articles gnus-newsgroup-seen))))
5252 (defun gnus-summary-display-make-predicate (display)
5253 (require 'gnus-agent)
5254 (when (= (length display) 1)
5255 (setq display (car display)))
5256 (unless gnus-summary-display-cache
5257 (dolist (elem (append '((unread . unread)
5260 gnus-article-mark-lists))
5261 (push (cons (cdr elem)
5263 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5264 gnus-summary-display-cache)))
5265 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5266 (gnus-category-predicate-cache gnus-summary-display-cache))
5267 (gnus-get-predicate display)))
5269 ;; Uses the dynamically bound `number' variable.
5272 (defun gnus-article-marked-p (type &optional article)
5273 (let ((article (or article number)))
5276 (memq article gnus-newsgroup-marked))
5278 (memq article gnus-newsgroup-spam-marked))
5280 (memq article gnus-newsgroup-unsendable))
5281 ((eq type 'undownload)
5282 (memq article gnus-newsgroup-undownloaded))
5283 ((eq type 'download)
5284 (memq article gnus-newsgroup-downloadable))
5286 (memq article gnus-newsgroup-unreads))
5288 (memq article gnus-newsgroup-reads))
5290 (memq article gnus-newsgroup-dormant) )
5292 (memq article gnus-newsgroup-expirable))
5294 (memq article gnus-newsgroup-replied))
5296 (memq article gnus-newsgroup-killed))
5297 ((eq type 'bookmark)
5298 (assq article gnus-newsgroup-bookmarks))
5300 (assq article gnus-newsgroup-scored))
5302 (memq article gnus-newsgroup-saved))
5304 (memq article gnus-newsgroup-cached))
5306 (memq article gnus-newsgroup-forwarded))
5308 (not (memq article gnus-newsgroup-unseen)))
5310 (memq article gnus-newsgroup-recent))
5313 (defun gnus-articles-to-read (group &optional read-all)
5314 "Find out what articles the user wants to read."
5316 ;; Select all articles if `read-all' is non-nil, or if there
5317 ;; are no unread articles.
5319 (and (zerop (length gnus-newsgroup-marked))
5320 (zerop (length gnus-newsgroup-unreads)))
5321 ;; Fetch all if the predicate is non-nil.
5322 gnus-newsgroup-display)
5323 ;; We want to select the headers for all the articles in
5324 ;; the group, so we select either all the active
5325 ;; articles in the group, or (if that's nil), the
5326 ;; articles in the cache.
5328 (gnus-uncompress-range (gnus-active group))
5329 (gnus-cache-articles-in-group group))
5330 ;; Select only the "normal" subset of articles.
5332 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5333 gnus-newsgroup-unreads)))
5334 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5335 (scored (length scored-list))
5336 (number (length articles))
5337 (marked (+ (length gnus-newsgroup-marked)
5338 (length gnus-newsgroup-dormant)))
5343 ((numberp gnus-newsgroup-display)
5344 gnus-newsgroup-display)
5348 ((and (or (<= scored marked) (= scored number))
5349 (numberp gnus-large-newsgroup)
5350 (> number gnus-large-newsgroup))
5351 (let* ((cursor-in-echo-area nil)
5352 (initial (gnus-parameter-large-newsgroup-initial
5353 gnus-newsgroup-name))
5357 "How many articles from %s (%s %d): "
5359 (gnus-group-decoded-name gnus-newsgroup-name)
5361 (if initial "max" "default")
5364 (cons (number-to-string initial)
5366 (if (string-match "^[ \t]*$" input) number input)))
5367 ((and (> scored marked) (< scored number)
5368 (> (- scored number) 20))
5371 (format "%s %s (%d scored, %d total): "
5372 "How many articles from"
5373 (gnus-group-decoded-name group)
5375 (if (string-match "^[ \t]*$" input)
5379 (message "Quit getting the articles to read")
5381 (setq select (if (stringp select) (string-to-number select) select))
5382 (if (or (null select) (zerop select))
5384 (if (and (not (zerop scored)) (<= (abs select) scored))
5386 (setq articles (sort scored-list '<))
5387 (setq number (length articles)))
5388 (setq articles (copy-sequence articles)))
5390 (when (< (abs select) number)
5392 ;; Select the N oldest articles.
5393 (setcdr (nthcdr (1- (abs select)) articles) nil)
5394 ;; Select the N most recent articles.
5395 (setq articles (nthcdr (- number select) articles))))
5396 (setq gnus-newsgroup-unselected
5397 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5398 (when gnus-alter-articles-to-read-function
5401 (funcall gnus-alter-articles-to-read-function
5402 gnus-newsgroup-name articles)
5406 (defun gnus-killed-articles (killed articles)
5409 (when (inline (gnus-member-of-range (car articles) killed))
5410 (push (car articles) out))
5411 (setq articles (cdr articles)))
5414 (defun gnus-uncompress-marks (marks)
5415 "Uncompress the mark ranges in MARKS."
5416 (let ((uncompressed '(score bookmark))
5419 (if (memq (caar marks) uncompressed)
5420 (push (car marks) out)
5421 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5422 (setq marks (cdr marks)))
5425 (defun gnus-article-mark-to-type (mark)
5426 "Return the type of MARK."
5427 (or (cadr (assq mark gnus-article-special-mark-lists))
5430 (defun gnus-article-unpropagatable-p (mark)
5431 "Return whether MARK should be propagated to back end."
5432 (memq mark gnus-article-unpropagated-mark-lists))
5434 (defun gnus-adjust-marked-articles (info)
5435 "Set all article lists and remove all marks that are no longer valid."
5436 (let* ((marked-lists (gnus-info-marks info))
5437 (active (gnus-active (gnus-info-group info)))
5440 (types gnus-article-mark-lists)
5441 marks var articles article mark mark-type
5444 (dolist (marks marked-lists)
5445 (setq mark (car marks)
5446 mark-type (gnus-article-mark-to-type mark)
5447 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5449 ;; We set the variable according to the type of the marks list,
5450 ;; and then adjust the marks to a subset of the active articles.
5452 ;; Adjust "simple" lists - compressed yet unsorted
5453 ((eq mark-type 'list)
5454 ;; Simultaneously uncompress and clip to active range
5455 ;; See gnus-uncompress-range for a description of possible marks
5457 (if (not (cadr marks))
5459 (setq articles (if (numberp (cddr marks))
5465 (while (setq article (pop articles))
5466 (cond ((consp article)
5467 (setq bgn (max (car article) min)
5468 end (min (cdr article) max))
5470 (setq l (setcdr l (cons bgn nil))
5472 ((and (<= min article)
5474 (setq l (setcdr l (cons article nil))))))
5475 (set var (cdr lh)))))
5477 ((eq mark-type 'tuple)
5478 (set var (setq articles (cdr marks)))
5479 (when (not (listp (cdr (symbol-value var))))
5480 (set var (list (symbol-value var))))
5481 (when (not (listp (cdr articles)))
5482 (setq articles (list articles)))
5484 (when (or (not (consp (setq article (pop articles))))
5485 (< (car article) min)
5486 (> (car article) max))
5487 (set var (delq article (symbol-value var))))))
5488 ;; Adjust ranges (sloppily).
5489 ((eq mark-type 'range)
5492 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5493 ;; It should be (seen (NUM1 . NUM2)).
5494 (when (numberp (cddr marks))
5495 (setcdr marks (list (cdr marks))))
5496 (setq articles (cdr marks))
5497 (while (and articles
5498 (or (and (consp (car articles))
5499 (> min (cdar articles)))
5500 (and (numberp (car articles))
5501 (> min (car articles)))))
5503 (set var articles))))))))
5505 (defun gnus-update-missing-marks (missing)
5506 "Go through the list of MISSING articles and remove them from the mark lists."
5509 ;; Go through all types.
5510 (dolist (elem gnus-article-mark-lists)
5511 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5512 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5513 (when (symbol-value var)
5514 ;; This list has articles. So we delete all missing
5515 ;; articles from it.
5518 (set var (delq (pop m) (symbol-value var))))))))))
5520 (defun gnus-update-marks ()
5521 "Enter the various lists of marked articles into the newsgroup info list."
5522 (let ((types gnus-article-mark-lists)
5523 (info (gnus-get-info gnus-newsgroup-name))
5524 type list newmarked symbol delta-marks)
5526 ;; Add all marks lists to the list of marks lists.
5527 (while (setq type (pop types))
5528 (setq list (symbol-value
5530 (intern (format "gnus-newsgroup-%s" (car type))))))
5533 ;; Get rid of the entries of the articles that have the
5535 (when (and (eq (cdr type) 'score)
5539 (prev (cons nil list))
5542 (if (or (not (consp (car arts)))
5543 (= (cdar arts) gnus-summary-default-score))
5544 (setcdr prev (cdr arts))
5546 (setq arts (cdr arts)))
5547 (setq list (cdr all)))))
5549 (when (eq (cdr type) 'seen)
5550 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5552 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5553 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5555 (when (and (gnus-check-backend-function
5556 'request-set-mark gnus-newsgroup-name)
5557 (not (gnus-article-unpropagatable-p (cdr type))))
5558 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5559 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5560 (add (gnus-remove-from-range
5561 (gnus-copy-sequence list) old)))
5563 (push (list add 'add (list (cdr type))) delta-marks))
5565 (push (list del 'del (list (cdr type))) delta-marks))))
5568 (push (cons (cdr type) list) newmarked)))
5571 (unless (gnus-check-group gnus-newsgroup-name)
5572 (error "Can't open server for %s" gnus-newsgroup-name))
5573 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5575 ;; Enter these new marks into the info of the group.
5577 (setcar (nthcdr 3 info) newmarked)
5578 ;; Add the marks lists to the end of the info.
5580 (setcdr (nthcdr 2 info) (list newmarked))))
5582 ;; Cut off the end of the info if there's nothing else there.
5586 (when (nthcdr (decf i) info)
5587 (setcdr (nthcdr i info) nil)))))))
5589 (defun gnus-set-mode-line (where)
5590 "Set the mode line of the article or summary buffers.
5591 If WHERE is `summary', the summary mode line format will be used."
5592 ;; Is this mode line one we keep updated?
5593 (when (and (memq where gnus-updated-mode-lines)
5595 (intern (format "gnus-%s-mode-line-format-spec" where))))
5598 ;; We evaluate this in the summary buffer since these
5599 ;; variables are buffer-local to that buffer.
5600 (set-buffer gnus-summary-buffer)
5601 ;; We bind all these variables that are used in the `eval' form
5603 (let* ((mformat (symbol-value
5605 (format "gnus-%s-mode-line-format-spec" where))))
5606 (gnus-tmp-group-name (gnus-group-decoded-name
5607 gnus-newsgroup-name))
5608 (gnus-tmp-article-number (or gnus-current-article 0))
5609 (gnus-tmp-unread gnus-newsgroup-unreads)
5610 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5611 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5612 (gnus-tmp-unread-and-unselected
5613 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5614 (zerop gnus-tmp-unselected))
5616 ((zerop gnus-tmp-unselected)
5617 (format "{%d more}" gnus-tmp-unread-and-unticked))
5618 (t (format "{%d(+%d) more}"
5619 gnus-tmp-unread-and-unticked
5620 gnus-tmp-unselected))))
5622 (if (and gnus-current-headers
5623 (vectorp gnus-current-headers))
5624 (gnus-mode-string-quote
5625 (mail-header-subject gnus-current-headers))
5627 bufname-length max-len
5628 gnus-tmp-header);; passed as argument to any user-format-funcs
5629 (setq mode-string (eval mformat))
5630 (setq bufname-length (if (string-match "%b" mode-string)
5633 (if (eq where 'summary)
5635 (get-buffer gnus-article-buffer))))
5638 (setq max-len (max 4 (if gnus-mode-non-string-length
5640 gnus-mode-non-string-length
5642 (length mode-string))))
5643 ;; We might have to chop a bit of the string off...
5644 (when (> (length mode-string) max-len)
5646 (concat (gnus-truncate-string mode-string (- max-len 3))
5648 ;; Pad the mode string a bit.
5649 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5650 ;; Update the mode line.
5651 (setq mode-line-buffer-identification
5652 (gnus-mode-line-buffer-identification (list mode-string)))
5653 (set-buffer-modified-p t))))
5655 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5656 "Go through the HEADERS list and add all Xrefs to a hash table.
5657 The resulting hash table is returned, or nil if no Xrefs were found."
5658 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5659 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5660 (xref-hashtb (gnus-make-hashtable))
5661 start group entry number xrefs header)
5663 (setq header (pop headers))
5664 (when (and (setq xrefs (mail-header-xref header))
5665 (not (memq (setq number (mail-header-number header))
5668 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5669 (setq start (match-end 0))
5670 (setq group (if prefix
5671 (concat prefix (substring xrefs (match-beginning 1)
5673 (substring xrefs (match-beginning 1) (match-end 1))))
5675 (string-to-int (substring xrefs (match-beginning 2)
5677 (if (setq entry (gnus-gethash group xref-hashtb))
5678 (setcdr entry (cons number (cdr entry)))
5679 (gnus-sethash group (cons number nil) xref-hashtb)))))
5680 (and start xref-hashtb)))
5682 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5683 "Look through all the headers and mark the Xrefs as read."
5684 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5685 name info xref-hashtb idlist method nth4)
5687 (set-buffer gnus-group-buffer)
5688 (when (setq xref-hashtb
5689 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5692 (unless (string= from-newsgroup (setq name (symbol-name group)))
5693 (setq idlist (symbol-value group))
5694 ;; Dead groups are not updated.
5696 (setq info (gnus-get-info name))
5697 (when (stringp (setq nth4 (gnus-info-method info)))
5698 (setq nth4 (gnus-server-to-method nth4))))
5699 ;; Only do the xrefs if the group has the same
5700 ;; select method as the group we have just read.
5701 (or (gnus-methods-equal-p
5702 nth4 (gnus-find-method-for-group from-newsgroup))
5704 (equal nth4 (setq method (gnus-find-method-for-group
5706 (and (equal (car nth4) (car method))
5707 (equal (nth 1 nth4) (nth 1 method))))
5708 gnus-use-cross-reference
5709 (or (not (eq gnus-use-cross-reference t))
5711 ;; Only do cross-references on subscribed
5712 ;; groups, if that is what is wanted.
5713 (<= (gnus-info-level info) gnus-level-subscribed))
5714 (gnus-group-make-articles-read name idlist))))
5717 (defun gnus-compute-read-articles (group articles)
5718 (let* ((entry (gnus-group-entry group))
5719 (info (nth 2 entry))
5720 (active (gnus-active group))
5723 ;; First peel off all invalid article numbers.
5725 (let ((ids articles)
5727 (while (setq id (pop ids))
5728 (when (and first (> id (cdr active)))
5729 ;; We'll end up in this situation in one particular
5730 ;; obscure situation. If you re-scan a group and get
5731 ;; a new article that is cross-posted to a different
5732 ;; group that has not been re-scanned, you might get
5733 ;; crossposted article that has a higher number than
5734 ;; Gnus believes possible. So we re-activate this
5735 ;; group as well. This might mean doing the
5736 ;; crossposting thingy will *increase* the number
5737 ;; of articles in some groups. Tsk, tsk.
5738 (setq active (or (gnus-activate-group group) active)))
5739 (when (or (> id (cdr active))
5740 (< id (car active)))
5741 (setq articles (delq id articles))))))
5742 ;; If the read list is nil, we init it.
5744 (null (gnus-info-read info))
5746 (setq ninfo (cons 1 (1- (car active))))
5747 (setq ninfo (gnus-info-read info)))
5748 ;; Then we add the read articles to the range.
5750 ninfo (setq articles (sort articles '<))))))
5752 (defun gnus-group-make-articles-read (group articles)
5753 "Update the info of GROUP to say that ARTICLES are read."
5755 (entry (gnus-group-entry group))
5756 (info (nth 2 entry))
5757 (active (gnus-active group))
5760 (setq range (gnus-compute-read-articles group articles))
5761 (with-current-buffer gnus-group-buffer
5764 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5765 (gnus-info-set-read ',info ',(gnus-info-read info))
5766 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5767 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5768 (gnus-group-update-group ,group t))))
5769 ;; Add the read articles to the range.
5770 (gnus-info-set-read info range)
5771 (gnus-request-set-mark group (list (list range 'add '(read))))
5772 ;; Then we have to re-compute how many unread
5773 ;; articles there are in this group.
5777 (setq num (- (1+ (cdr active)) (car active))))
5778 ((not (listp (cdr range)))
5779 (setq num (- (cdr active) (- (1+ (cdr range))
5783 (if (numberp (car range))
5785 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5786 (setq range (cdr range)))
5787 (setq num (- (cdr active) num))))
5788 ;; Update the number of unread articles.
5790 ;; Update the group buffer.
5791 (unless (gnus-ephemeral-group-p group)
5792 (gnus-group-update-group group t))))))
5794 (defvar gnus-newsgroup-none-id 0)
5796 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5797 (let ((cur nntp-server-buffer)
5800 (with-current-buffer gnus-summary-buffer
5801 gnus-newsgroup-dependencies)))
5802 headers id end ref number
5803 (mail-parse-charset gnus-newsgroup-charset)
5804 (mail-parse-ignored-charsets
5805 (save-excursion (condition-case nil
5806 (set-buffer gnus-summary-buffer)
5808 gnus-newsgroup-ignored-charsets)))
5810 (set-buffer nntp-server-buffer)
5811 ;; Translate all TAB characters into SPACE characters.
5812 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5813 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5814 (ietf-drums-unfold-fws)
5815 (gnus-run-hooks 'gnus-parse-headers-hook)
5816 (let ((case-fold-search t)
5817 in-reply-to header p lines chars ctype)
5818 (goto-char (point-min))
5819 ;; Search to the beginning of the next header. Error messages
5820 ;; do not begin with 2 or 3.
5821 (while (re-search-forward "^[23][0-9]+ " nil t)
5824 ;; This implementation of this function, with nine
5825 ;; search-forwards instead of the one re-search-forward and
5826 ;; a case (which basically was the old function) is actually
5827 ;; about twice as fast, even though it looks messier. You
5828 ;; can't have everything, I guess. Speed and elegance
5829 ;; doesn't always go hand in hand.
5832 (make-full-mail-header
5835 (setq number (read cur))
5838 (narrow-to-region (point)
5839 (or (and (search-forward "\n.\n" nil t)
5845 (if (search-forward "\nsubject:" nil t)
5846 (nnheader-header-value)
5851 (if (search-forward "\nfrom:" nil t)
5852 (nnheader-header-value)
5857 (if (search-forward "\ndate:" nil t)
5858 (nnheader-header-value) ""))
5862 (setq id (if (re-search-forward
5863 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5864 ;; We do it this way to make sure the Message-ID
5865 ;; is (somewhat) syntactically valid.
5866 (buffer-substring (match-beginning 1)
5868 ;; If there was no message-id, we just fake one
5869 ;; to make subsequent routines simpler.
5870 (nnheader-generate-fake-message-id number))))
5874 (if (search-forward "\nreferences:" nil t)
5878 (nnheader-header-value)
5883 (search-backward ">" end t)
5886 (search-backward "<" end t)
5888 ;; Get the references from the in-reply-to header if there
5889 ;; were no references and the in-reply-to header looks
5891 (if (and (search-forward "\nin-reply-to:" nil t)
5892 (setq in-reply-to (nnheader-header-value))
5893 (string-match "<[^>]+>" in-reply-to))
5895 (setq ref (substring in-reply-to (match-beginning 0)
5897 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5898 (setq ref2 (substring in-reply-to (match-beginning 0)
5900 (when (> (length ref2) (length ref))
5907 (if (search-forward "\nchars: " nil t)
5908 (if (numberp (setq chars (ignore-errors (read cur))))
5914 (if (search-forward "\nlines: " nil t)
5915 (if (numberp (setq lines (ignore-errors (read cur))))
5921 (and (search-forward "\nxref:" nil t)
5922 (nnheader-header-value)))
5924 (when gnus-extra-headers
5925 (let ((extra gnus-extra-headers)
5929 (when (search-forward
5930 (concat "\n" (symbol-name (car extra)) ":") nil t)
5931 (push (cons (car extra) (nnheader-header-value)) out))
5935 (if (and (search-forward "\ncontent-type: " nil t)
5936 (setq ctype (nnheader-header-value)))
5937 (mime-entity-set-content-type-internal
5938 header (mime-parse-Content-Type ctype)))
5939 (when (equal id ref)
5942 (when gnus-alter-header-function
5943 (funcall gnus-alter-header-function header)
5944 (setq id (mail-header-id header)
5945 ref (gnus-parent-id (mail-header-references header))))
5948 (gnus-dependencies-add-header
5949 header dependencies force-new))
5950 (push header headers))
5951 (goto-char (point-max))
5953 (nreverse headers)))))
5955 ;; Goes through the xover lines and returns a list of vectors
5956 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5957 force-new dependencies
5958 group also-fetch-heads)
5959 "Parse the news overview data in the server buffer.
5960 Return a list of headers that match SEQUENCE (see
5961 `nntp-retrieve-headers')."
5962 ;; Get the Xref when the users reads the articles since most/some
5963 ;; NNTP servers do not include Xrefs when using XOVER.
5964 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5965 (let ((mail-parse-charset gnus-newsgroup-charset)
5966 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5967 (cur nntp-server-buffer)
5968 (dependencies (or dependencies gnus-newsgroup-dependencies))
5970 ((eq gnus-read-all-available-headers t)
5972 ((stringp gnus-read-all-available-headers)
5973 (string-match gnus-read-all-available-headers group))
5976 number headers header)
5978 (set-buffer nntp-server-buffer)
5979 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5980 ;; Allow the user to mangle the headers before parsing them.
5981 (gnus-run-hooks 'gnus-parse-headers-hook)
5982 (goto-char (point-min))
5983 (gnus-parse-without-error
5984 (while (and (or sequence allp)
5986 (setq number (read cur))
5988 (while (and sequence
5989 (< (car sequence) number))
5990 (setq sequence (cdr sequence))))
5993 (eq number (car sequence))))
5995 (setq sequence (cdr sequence))
5996 (setq header (inline
5997 (gnus-nov-parse-line
5998 number dependencies force-new)))))
5999 (push header headers))
6001 ;; A common bug in inn is that if you have posted an article and
6002 ;; then retrieves the active file, it will answer correctly --
6003 ;; the new article is included. However, a NOV entry for the
6004 ;; article may not have been generated yet, so this may fail.
6005 ;; We work around this problem by retrieving the last few
6006 ;; headers using HEAD.
6007 (if (or (not also-fetch-heads)
6009 ;; We (probably) got all the headers.
6011 (let ((gnus-nov-is-evil t))
6014 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6015 (gnus-get-newsgroup-headers))))))))
6017 (defun gnus-article-get-xrefs ()
6018 "Fill in the Xref value in `gnus-current-headers', if necessary.
6019 This is meant to be called in `gnus-article-internal-prepare-hook'."
6020 (let ((headers (with-current-buffer gnus-summary-buffer
6021 gnus-current-headers)))
6022 (or (not gnus-use-cross-reference)
6024 (and (mail-header-xref headers)
6025 (not (string= (mail-header-xref headers) "")))
6026 (let ((case-fold-search t)
6029 (nnheader-narrow-to-headers)
6030 (goto-char (point-min))
6031 (when (or (and (not (eobp))
6032 (eq (downcase (char-after)) ?x)
6033 (looking-at "Xref:"))
6034 (search-forward "\nXref:" nil t))
6035 (goto-char (1+ (match-end 0)))
6036 (setq xref (buffer-substring (point) (point-at-eol)))
6037 (mail-header-set-xref headers xref)))))))
6039 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6040 "Find article ID and insert the summary line for that article.
6041 OLD-HEADER can either be a header or a line number to insert
6042 the subject line on."
6043 (let* ((line (and (numberp old-header) old-header))
6044 (old-header (and (vectorp old-header) old-header))
6045 (header (cond ((and old-header use-old-header)
6048 (gnus-number-to-header id))
6049 (gnus-number-to-header id))
6051 (gnus-read-header id))))
6052 (number (and (numberp id) id))
6055 ;; Rebuild the thread that this article is part of and go to the
6056 ;; article we have fetched.
6057 (when (and (not gnus-show-threads)
6060 (setq d (gnus-data-find (mail-header-number old-header))))
6061 (goto-char (gnus-data-pos d))
6067 (gnus-delete-line))))))
6068 ;; Remove list identifiers from subject.
6069 (when gnus-list-identifiers
6070 (let ((gnus-newsgroup-headers (list header)))
6071 (gnus-summary-remove-list-identifiers)
6072 (setq header (car gnus-newsgroup-headers))))
6074 (mail-header-set-number header (mail-header-number old-header)))
6075 (setq gnus-newsgroup-sparse
6076 (delq (setq number (mail-header-number header))
6077 gnus-newsgroup-sparse))
6078 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6079 (push number gnus-newsgroup-limit)
6080 (gnus-rebuild-thread (mail-header-id header) line)
6081 (gnus-summary-goto-subject number nil t))
6082 (when (and (numberp number)
6084 ;; We have to update the boundaries even if we can't fetch the
6085 ;; article if ID is a number -- so that the next `P' or `N'
6086 ;; command will fetch the previous (or next) article even
6087 ;; if the one we tried to fetch this time has been canceled.
6088 (when (> number gnus-newsgroup-end)
6089 (setq gnus-newsgroup-end number))
6090 (when (< number gnus-newsgroup-begin)
6091 (setq gnus-newsgroup-begin number))
6092 (setq gnus-newsgroup-unselected
6093 (delq number gnus-newsgroup-unselected)))
6094 ;; Report back a success?
6095 (and header (mail-header-number header))))
6097 ;;; Process/prefix in the summary buffer
6099 (defun gnus-summary-work-articles (n)
6100 "Return a list of articles to be worked upon.
6101 The prefix argument, the list of process marked articles, and the
6102 current article will be taken into consideration."
6104 (set-buffer gnus-summary-buffer)
6107 ;; A numerical prefix has been given.
6108 (setq n (prefix-numeric-value n))
6109 (let ((backward (< n 0))
6110 (n (abs (prefix-numeric-value n)))
6115 (push (setq article (gnus-summary-article-number))
6118 (gnus-summary-find-prev nil article)
6119 (gnus-summary-find-next nil article)))
6121 (nreverse articles)))
6122 ((and (gnus-region-active-p) (mark))
6123 (message "region active")
6124 ;; Work on the region between point and mark.
6125 (let ((max (max (point) (mark)))
6128 (goto-char (min (point) (mark)))
6131 (push (setq article (gnus-summary-article-number)) articles)
6132 (gnus-summary-find-next nil article)
6134 (nreverse articles))))
6135 (gnus-newsgroup-processable
6136 ;; There are process-marked articles present.
6137 ;; Save current state.
6138 (gnus-summary-save-process-mark)
6140 (reverse gnus-newsgroup-processable))
6142 ;; Just return the current article.
6143 (list (gnus-summary-article-number))))))
6145 (defmacro gnus-summary-iterate (arg &rest forms)
6146 "Iterate over the process/prefixed articles and do FORMS.
6147 ARG is the interactive prefix given to the command. FORMS will be
6148 executed with point over the summary line of the articles."
6149 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6150 `(let ((,articles (gnus-summary-work-articles ,arg)))
6152 (gnus-summary-goto-subject (car ,articles))
6156 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6157 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6159 (defun gnus-summary-save-process-mark ()
6160 "Push the current set of process marked articles on the stack."
6162 (push (copy-sequence gnus-newsgroup-processable)
6163 gnus-newsgroup-process-stack))
6165 (defun gnus-summary-kill-process-mark ()
6166 "Push the current set of process marked articles on the stack and unmark."
6168 (gnus-summary-save-process-mark)
6169 (gnus-summary-unmark-all-processable))
6171 (defun gnus-summary-yank-process-mark ()
6172 "Pop the last process mark state off the stack and restore it."
6174 (unless gnus-newsgroup-process-stack
6175 (error "Empty mark stack"))
6176 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6178 (defun gnus-summary-process-mark-set (set)
6179 "Make SET into the current process marked articles."
6180 (gnus-summary-unmark-all-processable)
6182 (gnus-summary-set-process-mark (pop set))))
6184 ;;; Searching and stuff
6186 (defun gnus-summary-search-group (&optional backward use-level)
6187 "Search for next unread newsgroup.
6188 If optional argument BACKWARD is non-nil, search backward instead."
6190 (set-buffer gnus-group-buffer)
6191 (when (gnus-group-search-forward
6192 backward nil (if use-level (gnus-group-group-level) nil))
6193 (gnus-group-group-name))))
6195 (defun gnus-summary-best-group (&optional exclude-group)
6196 "Find the name of the best unread group.
6197 If EXCLUDE-GROUP, do not go to this group."
6198 (with-current-buffer gnus-group-buffer
6200 (gnus-group-best-unread-group exclude-group))))
6202 (defun gnus-summary-find-next (&optional unread article backward)
6204 (gnus-summary-find-prev unread article)
6205 (let* ((dummy (gnus-summary-article-intangible-p))
6206 (article (or article (gnus-summary-article-number)))
6207 (data (gnus-data-find-list article))
6209 (when (and (not dummy)
6210 (or (not gnus-summary-check-current)
6212 (not (gnus-data-unread-p (car data)))))
6213 (setq data (cdr data)))
6218 (unless (memq (gnus-data-number (car data))
6220 ((eq gnus-auto-goto-ignores
6221 'always-undownloaded)
6222 gnus-newsgroup-undownloaded)
6225 ((eq gnus-auto-goto-ignores
6227 gnus-newsgroup-unfetched)
6228 ((eq gnus-auto-goto-ignores
6230 gnus-newsgroup-undownloaded)))
6231 (when (gnus-data-unread-p (car data))
6232 (setq result (car data)
6234 (setq data (cdr data)))
6237 (goto-char (gnus-data-pos result))
6238 (gnus-data-number result)))))
6240 (defun gnus-summary-find-prev (&optional unread article)
6241 (let* ((eobp (eobp))
6242 (article (or article (gnus-summary-article-number)))
6243 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6245 (when (and (not eobp)
6246 (or (not gnus-summary-check-current)
6248 (not (gnus-data-unread-p (car data)))))
6249 (setq data (cdr data)))
6254 (unless (memq (gnus-data-number (car data))
6256 ((eq gnus-auto-goto-ignores
6257 'always-undownloaded)
6258 gnus-newsgroup-undownloaded)
6261 ((eq gnus-auto-goto-ignores
6263 gnus-newsgroup-unfetched)
6264 ((eq gnus-auto-goto-ignores
6266 gnus-newsgroup-undownloaded)))
6267 (when (gnus-data-unread-p (car data))
6268 (setq result (car data)
6270 (setq data (cdr data)))
6273 (goto-char (gnus-data-pos result))
6274 (gnus-data-number result))))
6276 (defun gnus-summary-find-subject (subject &optional unread backward article)
6277 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6278 (article (or article (gnus-summary-article-number)))
6279 (articles (gnus-data-list backward))
6280 (arts (gnus-data-find-list article articles))
6282 (when (or (not gnus-summary-check-current)
6284 (not (gnus-data-unread-p (car arts))))
6285 (setq arts (cdr arts)))
6287 (and (or (not unread)
6288 (gnus-data-unread-p (car arts)))
6289 (vectorp (gnus-data-header (car arts)))
6291 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6292 (setq result (car arts)
6294 (setq arts (cdr arts)))
6296 (goto-char (gnus-data-pos result))
6297 (gnus-data-number result))))
6299 (defun gnus-summary-search-forward (&optional unread subject backward)
6300 "Search forward for an article.
6301 If UNREAD, look for unread articles. If SUBJECT, look for
6302 articles with that subject. If BACKWARD, search backward instead."
6303 (cond (subject (gnus-summary-find-subject subject unread backward))
6304 (backward (gnus-summary-find-prev unread))
6305 (t (gnus-summary-find-next unread))))
6307 (defun gnus-recenter (&optional n)
6308 "Center point in window and redisplay frame.
6309 Also do horizontal recentering."
6311 (when (and gnus-auto-center-summary
6312 (not (eq gnus-auto-center-summary 'vertical)))
6313 (gnus-horizontal-recenter))
6316 (defun gnus-summary-recenter ()
6317 "Center point in the summary window.
6318 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6319 displayed, no centering will be performed."
6320 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6321 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6323 ;; The user has to want it.
6324 (when gnus-auto-center-summary
6325 (let* ((top (cond ((< (window-height) 4) 0)
6326 ((< (window-height) 7) 1)
6327 (t (if (numberp gnus-auto-center-summary)
6328 gnus-auto-center-summary
6329 (/ (1- (window-height)) 2)))))
6330 (height (1- (window-height)))
6331 (bottom (save-excursion (goto-char (point-max))
6332 (forward-line (- height))
6334 (window (get-buffer-window (current-buffer))))
6335 (when (get-buffer-window gnus-article-buffer)
6336 ;; Only do recentering when the article buffer is displayed,
6337 ;; Set the window start to either `bottom', which is the biggest
6338 ;; possible valid number, or the second line from the top,
6339 ;; whichever is the least.
6340 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6341 (if (> bottom top-pos)
6342 ;; Keep the second line from the top visible
6343 (set-window-start window top-pos t)
6344 ;; Try to keep the bottom line visible; if it's partially
6345 ;; obscured, either scroll one more line to make it fully
6346 ;; visible, or revert to using TOP-POS.
6348 (goto-char (point-max))
6350 (let ((last-line-start (point)))
6352 (set-window-start window (point) t)
6353 (when (not (pos-visible-in-window-p last-line-start window))
6355 (set-window-start window (min (point) top-pos) t)))))))
6356 ;; Do horizontal recentering while we're at it.
6357 (when (and (get-buffer-window (current-buffer) t)
6358 (not (eq gnus-auto-center-summary 'vertical)))
6359 (let ((selected (selected-window)))
6360 (select-window (get-buffer-window (current-buffer) t))
6361 (gnus-summary-position-point)
6362 (gnus-horizontal-recenter)
6363 (select-window selected))))))
6365 (defun gnus-summary-jump-to-group (newsgroup)
6366 "Move point to NEWSGROUP in group mode buffer."
6367 ;; Keep update point of group mode buffer if visible.
6368 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6369 (save-window-excursion
6370 ;; Take care of tree window mode.
6371 (when (get-buffer-window gnus-group-buffer)
6372 (pop-to-buffer gnus-group-buffer))
6373 (gnus-group-jump-to-group newsgroup))
6375 ;; Take care of tree window mode.
6376 (if (get-buffer-window gnus-group-buffer)
6377 (pop-to-buffer gnus-group-buffer)
6378 (set-buffer gnus-group-buffer))
6379 (gnus-group-jump-to-group newsgroup))))
6381 ;; This function returns a list of article numbers based on the
6382 ;; difference between the ranges of read articles in this group and
6383 ;; the range of active articles.
6384 (defun gnus-list-of-unread-articles (group)
6385 (let* ((read (gnus-info-read (gnus-get-info group)))
6386 (active (or (gnus-active group) (gnus-activate-group group)))
6389 ;; If none are read, then all are unread.
6391 (setq first (car active))
6392 ;; If the range of read articles is a single range, then the
6393 ;; first unread article is the article after the last read
6394 ;; article. Sounds logical, doesn't it?
6395 (if (and (not (listp (cdr read)))
6396 (or (< (car read) (car active))
6397 (progn (setq read (list read))
6399 (setq first (max (car active) (1+ (cdr read))))
6400 ;; `read' is a list of ranges.
6401 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6404 (setq first (car active)))
6407 (while (< first nlast)
6408 (setq unread (cons first unread)
6410 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6411 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6412 (setq read (cdr read)))))
6413 ;; And add the last unread articles.
6414 (while (<= first last)
6415 (setq unread (cons first unread)
6417 ;; Return the list of unread articles.
6418 (delq 0 (nreverse unread))))
6420 (defun gnus-list-of-read-articles (group)
6421 "Return a list of unread, unticked and non-dormant articles."
6422 (let* ((info (gnus-get-info group))
6423 (marked (gnus-info-marks info))
6424 (active (gnus-active group)))
6426 (gnus-list-range-difference
6427 (gnus-list-range-difference
6428 (gnus-sorted-complement
6429 (gnus-uncompress-range active)
6430 (gnus-list-of-unread-articles group))
6431 (cdr (assq 'dormant marked)))
6432 (cdr (assq 'tick marked))))))
6434 ;; This function returns a sequence of article numbers based on the
6435 ;; difference between the ranges of read articles in this group and
6436 ;; the range of active articles.
6437 (defun gnus-sequence-of-unread-articles (group)
6438 (let* ((read (gnus-info-read (gnus-get-info group)))
6439 (active (or (gnus-active group) (gnus-activate-group group)))
6442 ;; If none are read, then all are unread.
6444 (setq first (car active))
6445 ;; If the range of read articles is a single range, then the
6446 ;; first unread article is the article after the last read
6447 ;; article. Sounds logical, doesn't it?
6448 (if (and (not (listp (cdr read)))
6449 (or (< (car read) (car active))
6450 (progn (setq read (list read))
6452 (setq first (max (car active) (1+ (cdr read))))
6453 ;; `read' is a list of ranges.
6454 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6457 (setq first (car active)))
6460 (push (cons first nlast) unread))
6461 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6462 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6463 (setq read (cdr read)))))
6464 ;; And add the last unread articles.
6465 (cond ((< first last)
6466 (push (cons first last) unread))
6468 (push first unread)))
6469 ;; Return the sequence of unread articles.
6470 (delq 0 (nreverse unread))))
6472 ;; Various summary commands
6474 (defun gnus-summary-select-article-buffer ()
6475 "Reconfigure windows to show article buffer."
6477 (if (not (gnus-buffer-live-p gnus-article-buffer))
6478 (error "There is no article buffer for this summary buffer")
6479 (gnus-configure-windows 'article)
6480 (select-window (get-buffer-window gnus-article-buffer))))
6482 (defun gnus-summary-universal-argument (arg)
6483 "Perform any operation on all articles that are process/prefixed."
6485 (let ((articles (gnus-summary-work-articles arg))
6492 (substitute-command-keys
6493 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6495 (gnus-error 1 "Undefined key")
6498 (gnus-summary-goto-subject (setq article (pop articles)))
6499 (let (gnus-newsgroup-processable)
6500 (command-execute func))
6501 (gnus-summary-remove-process-mark article)))))
6502 (gnus-summary-position-point))
6504 (defun gnus-summary-toggle-truncation (&optional arg)
6505 "Toggle truncation of summary lines.
6506 With ARG, turn line truncation on if ARG is positive."
6508 (setq truncate-lines
6509 (if (null arg) (not truncate-lines)
6510 (> (prefix-numeric-value arg) 0)))
6513 (defun gnus-summary-find-for-reselect ()
6514 "Return the number of an article to stay on across a reselect.
6515 The current article is considered, then following articles, then previous
6516 articles. An article is sought which is not cancelled and isn't a temporary
6517 insertion from another group. If there's no such then return a dummy 0."
6519 (dolist (rev '(nil t))
6520 (unless found ; don't demand the reverse list if we don't need it
6521 (let ((data (gnus-data-find-list
6522 (gnus-summary-article-number) (gnus-data-list rev))))
6523 (while (and data (not found))
6524 (if (and (< 0 (gnus-data-number (car data)))
6525 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6526 (setq found (gnus-data-number (car data))))
6527 (setq data (cdr data))))))
6530 (defun gnus-summary-reselect-current-group (&optional all rescan)
6531 "Exit and then reselect the current newsgroup.
6532 The prefix argument ALL means to select all articles."
6534 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6535 (error "Ephemeral groups can't be reselected"))
6536 (let ((current-subject (gnus-summary-find-for-reselect))
6537 (group gnus-newsgroup-name))
6538 (setq gnus-newsgroup-begin nil)
6539 (gnus-summary-exit nil 'leave-hidden)
6540 ;; We have to adjust the point of group mode buffer because
6541 ;; point was moved to the next unread newsgroup by exiting.
6542 (gnus-summary-jump-to-group group)
6545 (save-window-excursion
6546 ;; Don't show group contents.
6547 (set-window-start (selected-window) (point-max))
6548 (gnus-group-get-new-news-this-group 1))))
6549 (gnus-group-read-group all t)
6550 (gnus-summary-goto-subject current-subject nil t)))
6552 (defun gnus-summary-rescan-group (&optional all)
6553 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6555 (gnus-summary-reselect-current-group all t))
6557 (defun gnus-summary-update-info (&optional non-destructive)
6559 (let ((group gnus-newsgroup-name))
6561 (when gnus-newsgroup-kill-headers
6562 (setq gnus-newsgroup-killed
6563 (gnus-compress-sequence
6565 (gnus-list-range-intersection
6566 gnus-newsgroup-unselected gnus-newsgroup-killed)
6567 gnus-newsgroup-unreads)
6569 (unless (listp (cdr gnus-newsgroup-killed))
6570 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6571 (let ((headers gnus-newsgroup-headers))
6572 ;; Set the new ranges of read articles.
6573 (with-current-buffer gnus-group-buffer
6574 (gnus-undo-force-boundary))
6575 (gnus-update-read-articles
6576 group (gnus-sorted-union
6577 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6578 ;; Set the current article marks.
6579 (let ((gnus-newsgroup-scored
6580 (if (and (not gnus-save-score)
6581 (not non-destructive))
6583 gnus-newsgroup-scored)))
6585 (gnus-update-marks)))
6586 ;; Do the cross-ref thing.
6587 (when gnus-use-cross-reference
6588 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6589 ;; Do not switch windows but change the buffer to work.
6590 (set-buffer gnus-group-buffer)
6591 (unless (gnus-ephemeral-group-p group)
6592 (gnus-group-update-group group)))))))
6594 (defun gnus-summary-save-newsrc (&optional force)
6595 "Save the current number of read/marked articles in the dribble buffer.
6596 The dribble buffer will then be saved.
6597 If FORCE (the prefix), also save the .newsrc file(s)."
6599 (gnus-summary-update-info t)
6601 (gnus-save-newsrc-file)
6602 (gnus-dribble-save)))
6604 (defun gnus-summary-exit (&optional temporary leave-hidden)
6605 "Exit reading current newsgroup, and then return to group selection mode.
6606 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6608 (gnus-set-global-variables)
6609 (gnus-kill-save-kill-buffer)
6610 (gnus-async-halt-prefetch)
6611 (let* ((group gnus-newsgroup-name)
6612 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6613 (gnus-group-is-exiting-p t)
6616 (buf (current-buffer)))
6618 ;; Do adaptive scoring, and possibly save score files.
6619 (when gnus-newsgroup-adaptive
6620 (gnus-score-adaptive))
6621 (when gnus-use-scoring
6623 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6624 ;; If we have several article buffers, we kill them at exit.
6625 (unless gnus-single-article-buffer
6626 (gnus-kill-buffer gnus-original-article-buffer)
6627 (setq gnus-article-current nil))
6628 (when gnus-use-cache
6629 (gnus-cache-possibly-remove-articles)
6630 (gnus-cache-save-buffers))
6631 (gnus-async-prefetch-remove-group group)
6632 (when gnus-suppress-duplicates
6633 (gnus-dup-enter-articles))
6634 (when gnus-use-trees
6635 (gnus-tree-close group))
6636 (when gnus-use-cache
6637 (gnus-cache-write-active))
6638 ;; Remove entries for this group.
6639 (nnmail-purge-split-history (gnus-group-real-name group))
6640 ;; Make all changes in this group permanent.
6642 (gnus-run-hooks 'gnus-exit-group-hook)
6643 (gnus-summary-update-info))
6644 (gnus-close-group group)
6645 ;; Make sure where we were, and go to next newsgroup.
6646 (set-buffer gnus-group-buffer)
6648 (gnus-group-jump-to-group group))
6649 (gnus-run-hooks 'gnus-summary-exit-hook)
6650 (unless (or quit-config
6651 ;; If this group has disappeared from the summary
6652 ;; buffer, don't skip forwards.
6653 (not (string= group (gnus-group-group-name))))
6654 (gnus-group-next-unread-group 1))
6655 (setq group-point (point))
6658 ;; If we have several article buffers, we kill them at exit.
6659 (unless gnus-single-article-buffer
6660 (gnus-kill-buffer gnus-article-buffer)
6661 (gnus-kill-buffer gnus-original-article-buffer)
6662 (setq gnus-article-current nil))
6664 (if (not gnus-kill-summary-on-exit)
6666 (gnus-deaden-summary)
6668 ;; We set all buffer-local variables to nil. It is unclear why
6669 ;; this is needed, but if we don't, buffer-local variables are
6670 ;; not garbage-collected, it seems. This would the lead to en
6671 ;; ever-growing Emacs.
6672 (gnus-summary-clear-local-variables)
6673 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6674 (gnus-summary-clear-local-variables))
6675 (when (get-buffer gnus-article-buffer)
6676 (bury-buffer gnus-article-buffer))
6677 ;; We clear the global counterparts of the buffer-local
6678 ;; variables as well, just to be on the safe side.
6679 (set-buffer gnus-group-buffer)
6680 (gnus-summary-clear-local-variables)
6681 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6682 (gnus-summary-clear-local-variables))
6683 ;; Return to group mode buffer.
6684 (when (eq mode 'gnus-summary-mode)
6685 (gnus-kill-buffer buf)))
6686 (setq gnus-current-select-method gnus-select-method)
6688 (set-buffer gnus-group-buffer)
6689 (pop-to-buffer gnus-group-buffer))
6690 (if (not quit-config)
6692 (goto-char group-point)
6693 (unless leave-hidden
6694 (gnus-configure-windows 'group 'force))
6695 (unless (pos-visible-in-window-p)
6696 (forward-line (/ (static-if (featurep 'xemacs)
6697 (window-displayed-height)
6698 (1- (window-height)))
6700 (set-window-start (selected-window) (point))
6701 (goto-char group-point)))
6702 (gnus-handle-ephemeral-exit quit-config))
6703 ;; Clear the current group name.
6705 (setq gnus-newsgroup-name nil)))))
6707 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6708 (defun gnus-summary-exit-no-update (&optional no-questions)
6709 "Quit reading current newsgroup without updating read article info."
6711 (let* ((group gnus-newsgroup-name)
6712 (gnus-group-is-exiting-p t)
6713 (gnus-group-is-exiting-without-update-p t)
6714 (quit-config (gnus-group-quit-config group)))
6715 (when (or no-questions
6717 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6718 (gnus-async-halt-prefetch)
6719 (run-hooks 'gnus-summary-prepare-exit-hook)
6720 ;; If we have several article buffers, we kill them at exit.
6721 (unless gnus-single-article-buffer
6722 (gnus-kill-buffer gnus-article-buffer)
6723 (gnus-kill-buffer gnus-original-article-buffer)
6724 (setq gnus-article-current nil))
6725 (if (not gnus-kill-summary-on-exit)
6726 (gnus-deaden-summary)
6727 (gnus-close-group group)
6728 (gnus-summary-clear-local-variables)
6729 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6730 (gnus-summary-clear-local-variables))
6731 (set-buffer gnus-group-buffer)
6732 (gnus-summary-clear-local-variables)
6733 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6734 (gnus-summary-clear-local-variables))
6735 (gnus-kill-buffer gnus-summary-buffer))
6736 (unless gnus-single-article-buffer
6737 (setq gnus-article-current nil))
6738 (when gnus-use-trees
6739 (gnus-tree-close group))
6740 (gnus-async-prefetch-remove-group group)
6741 (when (get-buffer gnus-article-buffer)
6742 (bury-buffer gnus-article-buffer))
6743 ;; Return to the group buffer.
6744 (gnus-configure-windows 'group 'force)
6745 ;; Clear the current group name.
6746 (setq gnus-newsgroup-name nil)
6747 (unless (gnus-ephemeral-group-p group)
6748 (gnus-group-update-group group))
6749 (when (equal (gnus-group-group-name) group)
6750 (gnus-group-next-unread-group 1))
6752 (gnus-handle-ephemeral-exit quit-config)))))
6754 (defun gnus-handle-ephemeral-exit (quit-config)
6755 "Handle movement when leaving an ephemeral group.
6756 The state which existed when entering the ephemeral is reset."
6757 (if (not (buffer-name (car quit-config)))
6758 (gnus-configure-windows 'group 'force)
6759 (set-buffer (car quit-config))
6760 (cond ((eq major-mode 'gnus-summary-mode)
6761 (gnus-set-global-variables))
6762 ((eq major-mode 'gnus-article-mode)
6764 ;; The `gnus-summary-buffer' variable may point
6765 ;; to the old summary buffer when using a single
6767 (unless (gnus-buffer-live-p gnus-summary-buffer)
6768 (set-buffer gnus-group-buffer))
6769 (set-buffer gnus-summary-buffer)
6770 (gnus-set-global-variables))))
6771 (if (or (eq (cdr quit-config) 'article)
6772 (eq (cdr quit-config) 'pick))
6774 ;; The current article may be from the ephemeral group
6775 ;; thus it is best that we reload this article
6777 ;; If we're exiting from a large digest, this can be
6778 ;; extremely slow. So, it's better not to reload it. -- jh.
6779 ;;(gnus-summary-show-article)
6780 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6781 (gnus-configure-windows 'pick 'force)
6782 (gnus-configure-windows (cdr quit-config) 'force)))
6783 (gnus-configure-windows (cdr quit-config) 'force))
6784 (when (eq major-mode 'gnus-summary-mode)
6785 (gnus-summary-next-subject 1 nil t)
6786 (gnus-summary-recenter)
6787 (gnus-summary-position-point))))
6789 (defun gnus-summary-preview-mime-message ()
6790 "MIME decode and play this message."
6792 (let ((gnus-break-pages nil)
6794 (gnus-summary-select-article gnus-show-all-headers t))
6795 (let ((w (get-buffer-window gnus-article-buffer)))
6797 (select-window (get-buffer-window gnus-article-buffer)))))
6801 (defvar gnus-dead-summary-mode-map nil)
6803 (unless gnus-dead-summary-mode-map
6804 (setq gnus-dead-summary-mode-map (make-keymap))
6805 (suppress-keymap gnus-dead-summary-mode-map)
6806 (substitute-key-definition
6807 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6808 (dolist (key '("\C-d" "\r" "\177" [delete]))
6809 (define-key gnus-dead-summary-mode-map
6810 key 'gnus-summary-wake-up-the-dead))
6811 (dolist (key '("q" "Q"))
6812 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6814 (defvar gnus-dead-summary-mode nil
6815 "Minor mode for Gnus summary buffers.")
6817 (defun gnus-dead-summary-mode (&optional arg)
6818 "Minor mode for Gnus summary buffers."
6820 (when (eq major-mode 'gnus-summary-mode)
6821 (make-local-variable 'gnus-dead-summary-mode)
6822 (setq gnus-dead-summary-mode
6823 (if (null arg) (not gnus-dead-summary-mode)
6824 (> (prefix-numeric-value arg) 0)))
6825 (when gnus-dead-summary-mode
6827 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6829 (defun gnus-deaden-summary ()
6830 "Make the current summary buffer into a dead summary buffer."
6831 ;; Kill any previous dead summary buffer.
6832 (when (and gnus-dead-summary
6833 (buffer-name gnus-dead-summary))
6834 (with-current-buffer gnus-dead-summary
6835 (when gnus-dead-summary-mode
6836 (kill-buffer (current-buffer)))))
6837 ;; Make this the current dead summary.
6838 (setq gnus-dead-summary (current-buffer))
6839 (gnus-dead-summary-mode 1)
6840 (let ((name (buffer-name)))
6841 (when (string-match "Summary" name)
6843 (concat (substring name 0 (match-beginning 0)) "Dead "
6844 (substring name (match-beginning 0)))
6848 (defun gnus-kill-or-deaden-summary (buffer)
6849 "Kill or deaden the summary BUFFER."
6851 (when (and (buffer-name buffer)
6852 (not gnus-single-article-buffer))
6853 (with-current-buffer buffer
6854 (gnus-kill-buffer gnus-article-buffer)
6855 (gnus-kill-buffer gnus-original-article-buffer)))
6858 (gnus-kill-summary-on-exit
6859 (when (and gnus-use-trees
6860 (gnus-buffer-exists-p buffer))
6863 (gnus-tree-close gnus-newsgroup-name)))
6864 (gnus-kill-buffer buffer))
6865 ;; Deaden the buffer.
6866 ((gnus-buffer-exists-p buffer)
6869 (gnus-deaden-summary))))))
6871 (defun gnus-summary-wake-up-the-dead (&rest args)
6872 "Wake up the dead summary buffer."
6874 (gnus-dead-summary-mode -1)
6875 (let ((name (buffer-name)))
6876 (when (string-match "Dead " name)
6878 (concat (substring name 0 (match-beginning 0))
6879 (substring name (match-end 0)))
6881 (gnus-message 3 "This dead summary is now alive again"))
6883 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6884 (defun gnus-summary-fetch-faq (&optional faq-dir)
6885 "Fetch the FAQ for the current group.
6886 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6890 (when current-prefix-arg
6892 "FAQ dir: " (and (listp gnus-group-faq-directory)
6894 gnus-group-faq-directory))))))
6895 (let (gnus-faq-buffer)
6896 (when (setq gnus-faq-buffer
6897 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6898 (gnus-configure-windows 'summary-faq))))
6900 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6901 (defun gnus-summary-describe-group (&optional force)
6902 "Describe the current newsgroup."
6904 (gnus-group-describe-group force gnus-newsgroup-name))
6906 (defun gnus-summary-describe-briefly ()
6907 "Describe summary mode commands briefly."
6909 (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")))
6911 ;; Walking around group mode buffer from summary mode.
6913 (defun gnus-summary-next-group (&optional no-article target-group backward)
6914 "Exit current newsgroup and then select next unread newsgroup.
6915 If prefix argument NO-ARTICLE is non-nil, no article is selected
6916 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6917 previous group instead."
6919 ;; Stop pre-fetching.
6920 (gnus-async-halt-prefetch)
6921 (let ((current-group gnus-newsgroup-name)
6922 (current-buffer (current-buffer))
6924 ;; First we semi-exit this group to update Xrefs and all variables.
6925 ;; We can't do a real exit, because the window conf must remain
6926 ;; the same in case the user is prompted for info, and we don't
6927 ;; want the window conf to change before that...
6928 (gnus-summary-exit t)
6929 (while (not entered)
6930 ;; Then we find what group we are supposed to enter.
6931 (set-buffer gnus-group-buffer)
6932 (gnus-group-jump-to-group current-group)
6935 (if (eq gnus-keep-same-level 'best)
6936 (gnus-summary-best-group gnus-newsgroup-name)
6937 (gnus-summary-search-group backward gnus-keep-same-level))))
6938 (if (not target-group)
6939 ;; There are no further groups, so we return to the group
6942 (gnus-message 5 "Returning to the group buffer")
6944 (when (gnus-buffer-live-p current-buffer)
6945 (set-buffer current-buffer)
6946 (gnus-summary-exit))
6947 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6948 ;; We try to enter the target group.
6949 (gnus-group-jump-to-group target-group)
6950 (let ((unreads (gnus-group-group-unread)))
6951 (if (and (or (eq t unreads)
6952 (and unreads (not (zerop unreads))))
6953 (gnus-summary-read-group
6954 target-group nil no-article
6955 (and (buffer-name current-buffer) current-buffer)
6958 (setq current-group target-group
6959 target-group nil)))))))
6961 (defun gnus-summary-prev-group (&optional no-article)
6962 "Exit current newsgroup and then select previous unread newsgroup.
6963 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6965 (gnus-summary-next-group no-article nil t))
6967 ;; Walking around summary lines.
6969 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6970 "Go to the first subject satisfying any non-nil constraint.
6971 If UNREAD is non-nil, the article should be unread.
6972 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6973 If UNSEEN is non-nil, the article should be unseen.
6974 Returns the article selected or nil if there are no matching articles."
6978 ((null gnus-newsgroup-data)
6979 (gnus-message 3 "No articles in the group")
6981 ;; Pick the first article.
6982 ((not (or unread undownloaded unseen))
6983 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6984 (gnus-data-number (car gnus-newsgroup-data)))
6985 ;; Find the first unread article.
6987 (let ((data gnus-newsgroup-data))
6989 (let ((num (gnus-data-number (car data))))
6990 (or (memq num gnus-newsgroup-unfetched)
6991 (not (or (and unread
6992 (memq num gnus-newsgroup-unreads))
6994 (memq num gnus-newsgroup-undownloaded))
6996 (memq num gnus-newsgroup-unseen)))))))
6997 (setq data (cdr data)))
7001 (goto-char (gnus-data-pos (car data)))
7002 (gnus-data-number (car data)))
7003 (gnus-message 3 "No more%s articles"
7004 (let* ((r (when unread " unread"))
7005 (d (when undownloaded " undownloaded"))
7006 (s (when unseen " unseen"))
7007 (l (delq nil (list r d s))))
7008 (cond ((= 3 (length l))
7009 (concat r "," d ", or" s))
7011 (concat (car l) ", or" (cadr l)))
7018 (gnus-summary-position-point))))))
7020 (defun gnus-summary-next-subject (n &optional unread dont-display)
7021 "Go to next N'th summary line.
7022 If N is negative, go to the previous N'th subject line.
7023 If UNREAD is non-nil, only unread articles are selected.
7024 The difference between N and the actual number of steps taken is
7027 (let ((backward (< n 0))
7031 (gnus-summary-find-prev unread)
7032 (gnus-summary-find-next unread)))
7033 (unless (zerop (setq n (1- n)))
7034 (gnus-summary-show-thread)))
7036 (gnus-message 7 "No more%s articles"
7037 (if unread " unread" "")))
7038 (unless dont-display
7039 (gnus-summary-recenter)
7040 (gnus-summary-position-point))
7043 (defun gnus-summary-next-unread-subject (n)
7044 "Go to next N'th unread summary line."
7046 (gnus-summary-next-subject n t))
7048 (defun gnus-summary-prev-subject (n &optional unread)
7049 "Go to previous N'th summary line.
7050 If optional argument UNREAD is non-nil, only unread article is selected."
7052 (gnus-summary-next-subject (- n) unread))
7054 (defun gnus-summary-prev-unread-subject (n)
7055 "Go to previous N'th unread summary line."
7057 (gnus-summary-next-subject (- n) t))
7059 (defun gnus-summary-goto-subjects (articles)
7060 "Insert the subject header for ARTICLES in the current buffer."
7062 (dolist (article articles)
7063 (gnus-summary-goto-subject article t)))
7064 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7065 (gnus-summary-position-point))
7067 (defun gnus-summary-goto-subject (article &optional force silent)
7068 "Go the subject line of ARTICLE.
7069 If FORCE, also allow jumping to articles not currently shown."
7070 (interactive "nArticle number: ")
7071 (unless (numberp article)
7072 (error "Article %s is not a number" article))
7074 (data (gnus-data-find article)))
7075 ;; We read in the article if we have to.
7078 (gnus-summary-insert-subject
7080 (if (or (numberp force) (vectorp force)) force)
7082 (setq data (gnus-data-find article)))
7087 (gnus-message 3 "Can't find article %d" article))
7089 (let ((pt (gnus-data-pos data)))
7091 (gnus-summary-set-article-display-arrow pt))
7092 (gnus-summary-position-point)
7095 ;; Walking around summary lines with displaying articles.
7097 (defun gnus-summary-expand-window (&optional arg)
7098 "Make the summary buffer take up the entire Emacs frame.
7099 Given a prefix, will force an `article' buffer configuration."
7102 (gnus-configure-windows 'article 'force)
7103 (gnus-configure-windows 'summary 'force)))
7105 (defun gnus-summary-display-article (article &optional all-header)
7106 "Display ARTICLE in article buffer."
7107 (when (gnus-buffer-live-p gnus-article-buffer)
7108 (with-current-buffer gnus-article-buffer
7109 (set-buffer-multibyte t)))
7110 (gnus-set-global-variables)
7111 (when (gnus-buffer-live-p gnus-article-buffer)
7112 (with-current-buffer gnus-article-buffer
7113 (setq gnus-article-charset gnus-newsgroup-charset)
7114 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7115 (set-buffer-multibyte t)))
7119 (if gnus-summary-display-article-function
7120 (funcall gnus-summary-display-article-function article all-header)
7121 (gnus-article-prepare article all-header))
7122 (with-current-buffer gnus-article-buffer
7123 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7125 (gnus-run-hooks 'gnus-select-article-hook)
7126 (when (and gnus-current-article
7127 (not (zerop gnus-current-article)))
7128 (gnus-summary-goto-subject gnus-current-article))
7129 (gnus-summary-recenter)
7130 (when (and gnus-use-trees gnus-show-threads)
7131 (gnus-possibly-generate-tree article)
7132 (gnus-highlight-selected-tree article))
7133 ;; Successfully display article.
7134 (gnus-article-set-window-start
7135 (cdr (assq article gnus-newsgroup-bookmarks))))))
7137 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7138 "Select the current article.
7139 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7140 non-nil, the article will be re-fetched even if it already present in
7141 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7143 ;; Make sure we are in the summary buffer to work around bbdb bug.
7144 (unless (eq major-mode 'gnus-summary-mode)
7145 (set-buffer gnus-summary-buffer))
7146 (let ((article (or article (gnus-summary-article-number)))
7147 (all-headers (not (not all-headers))) ;Must be T or NIL.
7148 gnus-summary-display-article-function)
7150 (gnus-summary-article-pseudo-p article)
7151 (error "This is a pseudo-article"))
7153 (set-buffer gnus-summary-buffer)
7154 (if (or (and gnus-single-article-buffer
7155 (or (null gnus-current-article)
7156 (null gnus-article-current)
7157 (null (get-buffer gnus-article-buffer))
7158 (not (eq article (cdr gnus-article-current)))
7159 (not (equal (car gnus-article-current)
7160 gnus-newsgroup-name))))
7161 (and (not gnus-single-article-buffer)
7162 (or (null gnus-current-article)
7163 (not (eq gnus-current-article article))))
7165 ;; The requested article is different from the current article.
7167 (gnus-summary-display-article article all-headers)
7168 (gnus-article-set-window-start
7169 (cdr (assq article gnus-newsgroup-bookmarks)))
7173 (defun gnus-summary-force-verify-and-decrypt ()
7174 "Display buttons for signed/encrypted parts and verify/decrypt them."
7176 (let ((mm-verify-option 'known)
7177 (mm-decrypt-option 'known)
7178 (gnus-article-emulate-mime t)
7179 (mm-fill-flowed nil)
7180 (gnus-buttonized-mime-types (append (list "multipart/signed"
7181 "multipart/encrypted")
7182 gnus-buttonized-mime-types)))
7183 (gnus-summary-select-article nil 'force)))
7185 (defun gnus-summary-set-current-mark (&optional current-mark)
7186 "Obsolete function."
7189 (defun gnus-summary-next-article (&optional unread subject backward push)
7190 "Select the next article.
7191 If UNREAD, only unread articles are selected.
7192 If SUBJECT, only articles with SUBJECT are selected.
7193 If BACKWARD, the previous article is selected instead of the next."
7196 ;; Is there such an article?
7197 ((and (gnus-summary-search-forward unread subject backward)
7198 (or (gnus-summary-display-article (gnus-summary-article-number))
7199 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7200 (gnus-summary-position-point))
7201 ;; If not, we try the first unread, if that is wanted.
7203 gnus-auto-select-same
7204 (gnus-summary-first-unread-article))
7205 (gnus-summary-position-point)
7206 (gnus-message 6 "Wrapped"))
7207 ;; Try to get next/previous article not displayed in this group.
7208 ((and gnus-auto-extend-newsgroup
7209 (not unread) (not subject))
7210 (gnus-summary-goto-article
7211 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7212 nil (count-lines (point-min) (point))))
7213 ;; Go to next/previous group.
7215 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7216 (gnus-summary-jump-to-group gnus-newsgroup-name))
7217 (let ((cmd last-command-char)
7219 (with-current-buffer gnus-group-buffer
7222 (if (eq gnus-keep-same-level 'best)
7223 (gnus-summary-best-group gnus-newsgroup-name)
7224 (gnus-summary-search-group backward gnus-keep-same-level))))
7225 ;; For some reason, the group window gets selected. We change
7227 (select-window (get-buffer-window (current-buffer)))
7228 ;; Select next unread newsgroup automagically.
7230 ((or (not gnus-auto-select-next)
7232 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7233 ((or (eq gnus-auto-select-next 'quietly)
7234 (and (eq gnus-auto-select-next 'slightly-quietly)
7236 (and (eq gnus-auto-select-next 'almost-quietly)
7237 (gnus-summary-last-article-p)))
7239 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7241 (gnus-message 7 "No more%s articles (%s)..."
7242 (if unread " unread" "")
7243 (if group (concat "selecting " group)
7245 (gnus-summary-next-group nil group backward)))
7247 (when (gnus-key-press-event-p last-input-event)
7248 (gnus-summary-walk-group-buffer
7249 gnus-newsgroup-name cmd unread backward point))))))))
7251 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7252 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7253 (?\C-p (gnus-group-prev-unread-group 1))))
7254 (cursor-in-echo-area t)
7255 keve key group ended prompt)
7257 (set-buffer gnus-group-buffer)
7260 (if (eq gnus-keep-same-level 'best)
7261 (gnus-summary-best-group gnus-newsgroup-name)
7262 (gnus-summary-search-group backward gnus-keep-same-level))))
7266 "No more%s articles%s " (if unread " unread" "")
7268 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7269 (format " (Type %s for %s [%s])"
7270 (single-key-description cmd) group
7271 (gnus-group-unread group))
7272 (format " (Type %s to exit %s)"
7273 (single-key-description cmd)
7274 gnus-newsgroup-name))))
7275 ;; Confirm auto selection.
7276 (setq key (car (setq keve (gnus-read-event-char prompt)))
7279 ((assq key keystrokes)
7280 (let ((obuf (current-buffer)))
7281 (switch-to-buffer gnus-group-buffer)
7283 (gnus-group-jump-to-group group))
7284 (eval (cadr (assq key keystrokes)))
7285 (setq group (gnus-group-group-name))
7286 (switch-to-buffer obuf))
7290 (gnus-ephemeral-group-p gnus-newsgroup-name))
7292 (gnus-summary-next-group nil group backward)))
7294 (push (cdr keve) unread-command-events))))))
7296 (defun gnus-summary-next-unread-article ()
7297 "Select unread article after current one."
7299 (gnus-summary-next-article
7300 (or (not (eq gnus-summary-goto-unread 'never))
7301 (gnus-summary-last-article-p (gnus-summary-article-number)))
7302 (and gnus-auto-select-same
7303 (gnus-summary-article-subject))))
7305 (defun gnus-summary-prev-article (&optional unread subject)
7306 "Select the article after the current one.
7307 If UNREAD is non-nil, only unread articles are selected."
7309 (gnus-summary-next-article unread subject t))
7311 (defun gnus-summary-prev-unread-article ()
7312 "Select unread article before current one."
7314 (gnus-summary-prev-article
7315 (or (not (eq gnus-summary-goto-unread 'never))
7316 (gnus-summary-first-article-p (gnus-summary-article-number)))
7317 (and gnus-auto-select-same
7318 (gnus-summary-article-subject))))
7320 (defun gnus-summary-next-page (&optional lines circular stop)
7321 "Show next page of the selected article.
7322 If at the end of the current article, select the next article.
7323 LINES says how many lines should be scrolled up.
7325 If CIRCULAR is non-nil, go to the start of the article instead of
7326 selecting the next article when reaching the end of the current
7329 If STOP is non-nil, just stop when reaching the end of the message.
7331 Also see the variable `gnus-article-skip-boring'."
7333 (setq gnus-summary-buffer (current-buffer))
7334 (gnus-set-global-variables)
7335 (let ((article (gnus-summary-article-number))
7336 (article-window (get-buffer-window gnus-article-buffer t))
7338 ;; If the buffer is empty, we have no article.
7340 (error "No article to select"))
7341 (gnus-configure-windows 'article)
7342 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7343 (if (and (eq gnus-summary-goto-unread 'never)
7344 (not (gnus-summary-last-article-p article)))
7345 (gnus-summary-next-article)
7346 (gnus-summary-next-unread-article))
7347 (if (or (null gnus-current-article)
7348 (null gnus-article-current)
7349 (/= article (cdr gnus-article-current))
7350 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7351 ;; Selected subject is different from current article's.
7352 (gnus-summary-display-article article)
7353 (when article-window
7354 (gnus-eval-in-buffer-window gnus-article-buffer
7355 (setq endp (or (gnus-article-next-page lines)
7356 (gnus-article-only-boring-p))))
7359 (gnus-message 3 "End of message"))
7361 (gnus-summary-beginning-of-article))
7363 (gnus-message 3 "End of message"))
7365 (if (and (eq gnus-summary-goto-unread 'never)
7366 (not (gnus-summary-last-article-p article)))
7367 (gnus-summary-next-article)
7368 (gnus-summary-next-unread-article))))))))
7369 (gnus-summary-recenter)
7370 (gnus-summary-position-point)))
7372 (defun gnus-summary-prev-page (&optional lines move)
7373 "Show previous page of selected article.
7374 Argument LINES specifies lines to be scrolled down.
7375 If MOVE, move to the previous unread article if point is at
7376 the beginning of the buffer."
7378 (let ((article (gnus-summary-article-number))
7379 (article-window (get-buffer-window gnus-article-buffer t))
7381 (gnus-configure-windows 'article)
7382 (if (or (null gnus-current-article)
7383 (null gnus-article-current)
7384 (/= article (cdr gnus-article-current))
7385 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7386 ;; Selected subject is different from current article's.
7387 (gnus-summary-display-article article)
7388 (gnus-summary-recenter)
7389 (when article-window
7390 (gnus-eval-in-buffer-window gnus-article-buffer
7391 (setq endp (gnus-article-prev-page lines)))
7392 (when (and move endp)
7394 (gnus-message 3 "Beginning of message"))
7396 (if (and (eq gnus-summary-goto-unread 'never)
7397 (not (gnus-summary-first-article-p article)))
7398 (gnus-summary-prev-article)
7399 (gnus-summary-prev-unread-article))))))))
7400 (gnus-summary-position-point))
7402 (defun gnus-summary-prev-page-or-article (&optional lines)
7403 "Show previous page of selected article.
7404 Argument LINES specifies lines to be scrolled down.
7405 If at the beginning of the article, go to the next article."
7407 (gnus-summary-prev-page lines t))
7409 (defun gnus-summary-scroll-up (lines)
7410 "Scroll up (or down) one line current article.
7411 Argument LINES specifies lines to be scrolled up (or down if negative)."
7413 (gnus-configure-windows 'article)
7414 (gnus-summary-show-thread)
7415 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7416 (gnus-eval-in-buffer-window gnus-article-buffer
7418 (when (gnus-article-next-page lines)
7419 (gnus-message 3 "End of message")))
7421 (gnus-article-prev-page (- lines))))))
7422 (gnus-summary-recenter)
7423 (gnus-summary-position-point))
7425 (defun gnus-summary-scroll-down (lines)
7426 "Scroll down (or up) one line current article.
7427 Argument LINES specifies lines to be scrolled down (or up if negative)."
7429 (gnus-summary-scroll-up (- lines)))
7431 (defun gnus-summary-next-same-subject ()
7432 "Select next article which has the same subject as current one."
7434 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7436 (defun gnus-summary-prev-same-subject ()
7437 "Select previous article which has the same subject as current one."
7439 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7441 (defun gnus-summary-next-unread-same-subject ()
7442 "Select next unread article which has the same subject as current one."
7444 (gnus-summary-next-article t (gnus-summary-article-subject)))
7446 (defun gnus-summary-prev-unread-same-subject ()
7447 "Select previous unread article which has the same subject as current one."
7449 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7451 (defun gnus-summary-first-unread-article ()
7452 "Select the first unread article.
7453 Return nil if there are no unread articles."
7456 (when (gnus-summary-first-subject t)
7457 (gnus-summary-show-thread)
7458 (gnus-summary-first-subject t)
7459 (gnus-summary-display-article (gnus-summary-article-number)))
7460 (gnus-summary-position-point)))
7462 (defun gnus-summary-first-unread-subject ()
7463 "Place the point on the subject line of the first unread article.
7464 Return nil if there are no unread articles."
7467 (when (gnus-summary-first-subject t)
7468 (gnus-summary-show-thread)
7469 (gnus-summary-first-subject t))
7470 (gnus-summary-position-point)))
7472 (defun gnus-summary-first-unseen-subject ()
7473 "Place the point on the subject line of the first unseen article.
7474 Return nil if there are no unseen articles."
7477 (when (gnus-summary-first-subject nil nil t)
7478 (gnus-summary-show-thread)
7479 (gnus-summary-first-subject nil nil t))
7480 (gnus-summary-position-point)))
7482 (defun gnus-summary-first-unseen-or-unread-subject ()
7483 "Place the point on the subject line of the first unseen article or,
7484 if all article have been seen, on the subject line of the first unread
7488 (unless (when (gnus-summary-first-subject nil nil t)
7489 (gnus-summary-show-thread)
7490 (gnus-summary-first-subject nil nil t))
7491 (when (gnus-summary-first-subject t)
7492 (gnus-summary-show-thread)
7493 (gnus-summary-first-subject t)))
7494 (gnus-summary-position-point)))
7496 (defun gnus-summary-first-article ()
7497 "Select the first article.
7498 Return nil if there are no articles."
7501 (when (gnus-summary-first-subject)
7502 (gnus-summary-show-thread)
7503 (gnus-summary-first-subject)
7504 (gnus-summary-display-article (gnus-summary-article-number)))
7505 (gnus-summary-position-point)))
7507 (defun gnus-summary-best-unread-article (&optional arg)
7508 "Select the unread article with the highest score.
7509 If given a prefix argument, select the next unread article that has a
7510 score higher than the default score."
7512 (let ((article (if arg
7513 (gnus-summary-better-unread-subject)
7514 (gnus-summary-best-unread-subject))))
7516 (gnus-summary-goto-article article)
7517 (error "No unread articles"))))
7519 (defun gnus-summary-best-unread-subject ()
7520 "Select the unread subject with the highest score."
7522 (let ((best -1000000)
7523 (data gnus-newsgroup-data)
7526 (and (gnus-data-unread-p (car data))
7528 (gnus-summary-article-score (gnus-data-number (car data))))
7531 article (gnus-data-number (car data))))
7532 (setq data (cdr data)))
7534 (gnus-summary-goto-subject article))
7535 (gnus-summary-position-point)
7538 (defun gnus-summary-better-unread-subject ()
7539 "Select the first unread subject that has a score over the default score."
7541 (let ((data gnus-newsgroup-data)
7543 (while (and (setq article (gnus-data-number (car data)))
7544 (or (gnus-data-read-p (car data))
7545 (not (> (gnus-summary-article-score article)
7546 gnus-summary-default-score))))
7547 (setq data (cdr data)))
7549 (gnus-summary-goto-subject article))
7550 (gnus-summary-position-point)
7553 (defun gnus-summary-last-subject ()
7554 "Go to the last displayed subject line in the group."
7555 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7557 (gnus-summary-goto-subject article))))
7559 (defun gnus-summary-goto-article (article &optional all-headers force)
7560 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7561 If ALL-HEADERS is non-nil, no header lines are hidden.
7562 If FORCE, go to the article even if it isn't displayed. If FORCE
7563 is a number, it is the line the article is to be displayed on."
7567 "Article number or Message-ID: "
7568 (mapcar (lambda (number) (list (int-to-string number)))
7569 gnus-newsgroup-limit))
7573 (if (and (stringp article)
7574 (string-match "@\\|%40" article))
7575 (gnus-summary-refer-article article)
7576 (when (stringp article)
7577 (setq article (string-to-number article)))
7578 (if (gnus-summary-goto-subject article force)
7579 (gnus-summary-display-article article all-headers)
7580 (gnus-message 4 "Couldn't go to article %s" article) nil))
7581 (gnus-summary-position-point)))
7583 (defun gnus-summary-goto-last-article ()
7584 "Go to the previously read article."
7587 (when gnus-last-article
7588 (gnus-summary-goto-article gnus-last-article nil t))
7589 (gnus-summary-position-point)))
7591 (defun gnus-summary-pop-article (number)
7592 "Pop one article off the history and go to the previous.
7593 NUMBER articles will be popped off."
7596 (setq gnus-newsgroup-history
7597 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7599 (gnus-summary-goto-article (car to) nil t)
7600 (error "Article history empty")))
7601 (gnus-summary-position-point))
7603 ;; Summary commands and functions for limiting the summary buffer.
7605 (defun gnus-summary-limit-to-articles (n)
7606 "Limit the summary buffer to the next N articles.
7607 If not given a prefix, use the process marked articles instead."
7610 (let ((articles (gnus-summary-work-articles n)))
7611 (setq gnus-newsgroup-processable nil)
7612 (gnus-summary-limit articles))
7613 (gnus-summary-position-point)))
7615 (defun gnus-summary-pop-limit (&optional total)
7616 "Restore the previous limit.
7617 If given a prefix, remove all limits."
7620 (setq gnus-newsgroup-limits
7621 (list (mapcar (lambda (h) (mail-header-number h))
7622 gnus-newsgroup-headers))))
7623 (unless gnus-newsgroup-limits
7624 (error "No limit to pop"))
7626 (gnus-summary-limit nil 'pop)
7627 (gnus-summary-position-point)))
7629 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7630 "Limit the summary buffer to articles that have subjects that match a regexp.
7631 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7633 (list (read-string (if current-prefix-arg
7634 "Exclude subject (regexp): "
7635 "Limit to subject (regexp): "))
7636 nil current-prefix-arg))
7638 (setq header "subject"))
7639 (when (not (equal "" subject))
7641 (let ((articles (gnus-summary-find-matching
7642 (or header "subject") subject 'all nil nil
7645 (error "Found no matches for \"%s\"" subject))
7646 (gnus-summary-limit articles))
7647 (gnus-summary-position-point))))
7649 (defun gnus-summary-limit-to-author (from &optional not-matching)
7650 "Limit the summary buffer to articles that have authors that match a regexp.
7651 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7653 (list (read-string (if current-prefix-arg
7654 "Exclude author (regexp): "
7655 "Limit to author (regexp): "))
7656 current-prefix-arg))
7657 (gnus-summary-limit-to-subject from "from" not-matching))
7659 (defun gnus-summary-limit-to-age (age &optional younger-p)
7660 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7661 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7662 articles that are younger than AGE days."
7664 (let ((younger current-prefix-arg)
7667 (while (not days-got)
7668 (setq days (if younger
7669 (read-string "Limit to articles younger than (in days, older when negative): ")
7671 "Limit to articles older than (in days, younger when negative): ")))
7672 (when (> (length days) 0)
7673 (setq days (read days)))
7678 (setq younger (not younger))
7679 (setq days (* days -1))))
7680 (message "Please enter a number.")
7682 (list days younger)))
7684 (let ((data gnus-newsgroup-data)
7685 (cutoff (days-to-time age))
7686 articles d date is-younger)
7687 (while (setq d (pop data))
7688 (when (and (vectorp (gnus-data-header d))
7689 (setq date (mail-header-date (gnus-data-header d))))
7690 (setq is-younger (time-less-p
7691 (time-since (condition-case ()
7698 (push (gnus-data-number d) articles))))
7699 (gnus-summary-limit (nreverse articles)))
7700 (gnus-summary-position-point)))
7702 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7703 "Limit the summary buffer to articles that match an 'extra' header."
7707 (gnus-completing-read-with-default
7708 (symbol-name (car gnus-extra-headers))
7709 (if current-prefix-arg
7710 "Exclude extra header:"
7711 "Limit extra header:")
7713 (cons (symbol-name x) x))
7718 (read-string (format "%s header %s (regexp): "
7719 (if current-prefix-arg "Exclude" "Limit to")
7721 current-prefix-arg)))
7722 (when (not (equal "" regexp))
7724 (let ((articles (gnus-summary-find-matching
7725 (cons 'extra header) regexp 'all nil nil
7728 (error "Found no matches for \"%s\"" regexp))
7729 (gnus-summary-limit articles))
7730 (gnus-summary-position-point))))
7732 (defun gnus-summary-limit-to-display-predicate ()
7733 "Limit the summary buffer to the predicated in the `display' group parameter."
7735 (unless gnus-newsgroup-display
7736 (error "There is no `display' group parameter"))
7738 (dolist (number gnus-newsgroup-articles)
7739 (when (funcall gnus-newsgroup-display)
7740 (push number articles)))
7741 (gnus-summary-limit articles))
7742 (gnus-summary-position-point))
7744 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7746 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7748 (defun gnus-summary-limit-to-unread (&optional all)
7749 "Limit the summary buffer to articles that are not marked as read.
7750 If ALL is non-nil, limit strictly to unread articles."
7753 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7754 (gnus-summary-limit-to-marks
7755 ;; Concat all the marks that say that an article is read and have
7757 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7758 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7759 gnus-low-score-mark gnus-expirable-mark
7760 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7761 gnus-duplicate-mark gnus-souped-mark)
7764 (defun gnus-summary-limit-to-replied (&optional unreplied)
7765 "Limit the summary buffer to replied articles.
7766 If UNREPLIED (the prefix), limit to unreplied articles."
7770 (gnus-set-difference gnus-newsgroup-articles
7771 gnus-newsgroup-replied))
7772 (gnus-summary-limit gnus-newsgroup-replied))
7773 (gnus-summary-position-point))
7775 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7776 (make-obsolete 'gnus-summary-delete-marked-with
7777 'gnus-summary-limit-exclude-marks)
7779 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7780 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7781 If REVERSE, limit the summary buffer to articles that are marked
7782 with MARKS. MARKS can either be a string of marks or a list of marks.
7783 Returns how many articles were removed."
7784 (interactive "sMarks: ")
7785 (gnus-summary-limit-to-marks marks t))
7787 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7788 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7789 If REVERSE (the prefix), limit the summary buffer to articles that are
7790 not marked with MARKS. MARKS can either be a string of marks or a
7792 Returns how many articles were removed."
7793 (interactive "sMarks: \nP")
7795 (let ((data gnus-newsgroup-data)
7796 (marks (if (listp marks) marks
7797 (append marks nil))) ; Transform to list.
7800 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7801 (memq (gnus-data-mark (car data)) marks))
7802 (push (gnus-data-number (car data)) articles))
7803 (setq data (cdr data)))
7804 (gnus-summary-limit articles))
7805 (gnus-summary-position-point)))
7807 (defun gnus-summary-limit-to-score (score)
7808 "Limit to articles with score at or above SCORE."
7809 (interactive "NLimit to articles with score of at least: ")
7810 (let ((data gnus-newsgroup-data)
7813 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7815 (push (gnus-data-number (car data)) articles))
7816 (setq data (cdr data)))
7818 (gnus-summary-limit articles)
7819 (gnus-summary-position-point))))
7821 (defun gnus-summary-limit-to-unseen ()
7822 "Limit to unseen articles."
7825 (gnus-summary-limit gnus-newsgroup-unseen)
7826 (gnus-summary-position-point)))
7828 (defun gnus-summary-limit-include-thread (id)
7829 "Display all the hidden articles that is in the thread with ID in it.
7830 When called interactively, ID is the Message-ID of the current
7832 (interactive (list (mail-header-id (gnus-summary-article-header))))
7833 (let ((articles (gnus-articles-in-thread
7834 (gnus-id-to-thread (gnus-root-id id)))))
7836 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7837 (gnus-summary-limit-include-matching-articles
7839 (regexp-quote (gnus-simplify-subject-re
7840 (mail-header-subject (gnus-id-to-header id)))))
7841 (gnus-summary-position-point))))
7843 (defun gnus-summary-limit-include-matching-articles (header regexp)
7844 "Display all the hidden articles that have HEADERs that match REGEXP."
7845 (interactive (list (read-string "Match on header: ")
7846 (read-string "Regexp: ")))
7847 (let ((articles (gnus-find-matching-articles header regexp)))
7849 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7850 (gnus-summary-position-point))))
7852 (defun gnus-summary-insert-dormant-articles ()
7853 "Insert all the dormant articles for this group into the current buffer."
7855 (let ((gnus-verbose (max 6 gnus-verbose)))
7856 (if (not gnus-newsgroup-dormant)
7857 (gnus-message 3 "No cached articles for this group")
7858 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7860 (defun gnus-summary-limit-include-dormant ()
7861 "Display all the hidden articles that are marked as dormant.
7862 Note that this command only works on a subset of the articles currently
7863 fetched for this group."
7865 (unless gnus-newsgroup-dormant
7866 (error "There are no dormant articles in this group"))
7868 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7869 (gnus-summary-position-point)))
7871 (defun gnus-summary-limit-exclude-dormant ()
7872 "Hide all dormant articles."
7875 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7876 (gnus-summary-position-point)))
7878 (defun gnus-summary-limit-exclude-childless-dormant ()
7879 "Hide all dormant articles that have no children."
7881 (let ((data (gnus-data-list t))
7882 articles d children)
7883 ;; Find all articles that are either not dormant or have
7885 (while (setq d (pop data))
7886 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7888 (gnus-article-children (gnus-data-number d)))
7891 (when (memq (car children) articles)
7896 (push (gnus-data-number d) articles)))
7899 (gnus-summary-limit articles)
7900 (gnus-summary-position-point))))
7902 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7903 "Mark all unread excluded articles as read.
7904 If ALL, mark even excluded ticked and dormants as read."
7906 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7907 (let ((articles (gnus-sorted-ndifference
7909 (mapcar (lambda (h) (mail-header-number h))
7910 gnus-newsgroup-headers)
7912 gnus-newsgroup-limit))
7914 (setq gnus-newsgroup-unreads
7915 (gnus-sorted-intersection gnus-newsgroup-unreads
7916 gnus-newsgroup-limit))
7918 (setq gnus-newsgroup-dormant nil
7919 gnus-newsgroup-marked nil
7920 gnus-newsgroup-reads
7922 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7923 gnus-newsgroup-reads))
7924 (while (setq article (pop articles))
7925 (unless (or (memq article gnus-newsgroup-dormant)
7926 (memq article gnus-newsgroup-marked))
7927 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7929 (defun gnus-summary-limit (articles &optional pop)
7931 ;; We pop the previous limit off the stack and use that.
7932 (setq articles (car gnus-newsgroup-limits)
7933 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7934 ;; We use the new limit, so we push the old limit on the stack.
7935 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7937 (setq gnus-newsgroup-limit articles)
7938 (let ((total (length gnus-newsgroup-data))
7939 (data (gnus-data-find-list (gnus-summary-article-number)))
7940 (gnus-summary-mark-below nil) ; Inhibit this.
7942 ;; This will do all the work of generating the new summary buffer
7943 ;; according to the new limit.
7944 (gnus-summary-prepare)
7945 ;; Hide any threads, possibly.
7946 (gnus-summary-maybe-hide-threads)
7947 ;; Try to return to the article you were at, or one in the
7950 ;; We try to find some article after the current one.
7952 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7955 (setq data (cdr data))))
7957 ;; If there is no data, that means that we were after the last
7958 ;; article. The same goes when we can't find any articles
7959 ;; after the current one.
7960 (goto-char (point-max))
7961 (gnus-summary-find-prev))
7962 (gnus-set-mode-line 'summary)
7963 ;; We return how many articles were removed from the summary
7964 ;; buffer as a result of the new limit.
7965 (- total (length gnus-newsgroup-data))))
7967 (defsubst gnus-invisible-cut-children (threads)
7970 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7975 (defsubst gnus-cut-thread (thread)
7976 "Go forwards in the thread until we find an article that we want to display."
7977 (when (or (eq gnus-fetch-old-headers 'some)
7978 (eq gnus-fetch-old-headers 'invisible)
7979 (numberp gnus-fetch-old-headers)
7980 (eq gnus-build-sparse-threads 'some)
7981 (eq gnus-build-sparse-threads 'more))
7982 ;; Deal with old-fetched headers and sparse threads.
7986 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7987 (gnus-summary-article-ancient-p
7988 (mail-header-number (car thread))))
7989 (if (or (<= (length (cdr thread)) 1)
7990 (eq gnus-fetch-old-headers 'invisible))
7991 (setq gnus-newsgroup-limit
7992 (delq (mail-header-number (car thread))
7993 gnus-newsgroup-limit)
7994 thread (cadr thread))
7995 (when (gnus-invisible-cut-children (cdr thread))
7996 (let ((th (cdr thread)))
7998 (if (memq (mail-header-number (caar th))
7999 gnus-newsgroup-limit)
8000 (setq thread (car th)
8002 (setq th (cdr th))))))))))
8005 (defun gnus-cut-threads (threads)
8006 "Cut off all uninteresting articles from the beginning of THREADS."
8007 (when (or (eq gnus-fetch-old-headers 'some)
8008 (eq gnus-fetch-old-headers 'invisible)
8009 (numberp gnus-fetch-old-headers)
8010 (eq gnus-build-sparse-threads 'some)
8011 (eq gnus-build-sparse-threads 'more))
8014 (setcar th (gnus-cut-thread (car th)))
8015 (setq th (cdr th)))))
8016 ;; Remove nixed out threads.
8019 (defun gnus-summary-initial-limit (&optional show-if-empty)
8020 "Figure out what the initial limit is supposed to be on group entry.
8021 This entails weeding out unwanted dormants, low-scored articles,
8022 fetch-old-headers verbiage, and so on."
8023 ;; Most groups have nothing to remove.
8024 (if (or gnus-inhibit-limiting
8025 (and (null gnus-newsgroup-dormant)
8026 (eq gnus-newsgroup-display 'gnus-not-ignore)
8027 (not (eq gnus-fetch-old-headers 'some))
8028 (not (numberp gnus-fetch-old-headers))
8029 (not (eq gnus-fetch-old-headers 'invisible))
8030 (null gnus-summary-expunge-below)
8031 (not (eq gnus-build-sparse-threads 'some))
8032 (not (eq gnus-build-sparse-threads 'more))
8033 (null gnus-thread-expunge-below)
8034 (not gnus-use-nocem)))
8036 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8037 (setq gnus-newsgroup-limit nil)
8040 (unless (car (symbol-value node))
8041 ;; These threads have no parents -- they are roots.
8042 (let ((nodes (cdr (symbol-value node)))
8045 (if (and gnus-thread-expunge-below
8046 (< (gnus-thread-total-score (car nodes))
8047 gnus-thread-expunge-below))
8048 (gnus-expunge-thread (pop nodes))
8049 (setq thread (pop nodes))
8050 (gnus-summary-limit-children thread))))))
8051 gnus-newsgroup-dependencies)
8052 ;; If this limitation resulted in an empty group, we might
8053 ;; pop the previous limit and use it instead.
8054 (when (and (not gnus-newsgroup-limit)
8056 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8057 gnus-newsgroup-limit))
8059 (defun gnus-summary-limit-children (thread)
8060 "Return 1 if this subthread is visible and 0 if it is not."
8061 ;; First we get the number of visible children to this thread. This
8062 ;; is done by recursing down the thread using this function, so this
8063 ;; will really go down to a leaf article first, before slowly
8064 ;; working its way up towards the root.
8066 (let* ((max-lisp-eval-depth 5000)
8069 (apply '+ (mapcar 'gnus-summary-limit-children
8072 (number (mail-header-number (car thread)))
8075 (not (memq number gnus-newsgroup-marked))
8077 ;; If this article is dormant and has absolutely no visible
8078 ;; children, then this article isn't visible.
8079 (and (memq number gnus-newsgroup-dormant)
8081 ;; If this is "fetch-old-headered" and there is no
8082 ;; visible children, then we don't want this article.
8083 (and (or (eq gnus-fetch-old-headers 'some)
8084 (numberp gnus-fetch-old-headers))
8085 (gnus-summary-article-ancient-p number)
8087 ;; If this is "fetch-old-headered" and `invisible', then
8088 ;; we don't want this article.
8089 (and (eq gnus-fetch-old-headers 'invisible)
8090 (gnus-summary-article-ancient-p number))
8091 ;; If this is a sparsely inserted article with no children,
8092 ;; we don't want it.
8093 (and (eq gnus-build-sparse-threads 'some)
8094 (gnus-summary-article-sparse-p number)
8096 ;; If we use expunging, and this article is really
8097 ;; low-scored, then we don't want this article.
8098 (when (and gnus-summary-expunge-below
8100 (or (cdr (assq number gnus-newsgroup-scored))
8101 gnus-summary-default-score))
8102 gnus-summary-expunge-below))
8103 ;; We increase the expunge-tally here, but that has
8104 ;; nothing to do with the limits, really.
8105 (incf gnus-newsgroup-expunged-tally)
8106 ;; We also mark as read here, if that's wanted.
8107 (when (and gnus-summary-mark-below
8108 (< score gnus-summary-mark-below))
8109 (setq gnus-newsgroup-unreads
8110 (delq number gnus-newsgroup-unreads))
8111 (if gnus-newsgroup-auto-expire
8112 (push number gnus-newsgroup-expirable)
8113 (push (cons number gnus-low-score-mark)
8114 gnus-newsgroup-reads)))
8116 ;; Do the `display' group parameter.
8117 (and gnus-newsgroup-display
8118 (not (funcall gnus-newsgroup-display)))
8119 ;; Check NoCeM things.
8120 (when (and gnus-use-nocem
8121 (gnus-nocem-unwanted-article-p
8122 (mail-header-id (car thread))))
8123 (setq gnus-newsgroup-unreads
8124 (delq number gnus-newsgroup-unreads))
8126 ;; Nope, invisible article.
8128 ;; Ok, this article is to be visible, so we add it to the limit
8130 (push number gnus-newsgroup-limit)
8133 (defun gnus-expunge-thread (thread)
8134 "Mark all articles in THREAD as read."
8135 (let* ((number (mail-header-number (car thread))))
8136 (incf gnus-newsgroup-expunged-tally)
8137 ;; We also mark as read here, if that's wanted.
8138 (setq gnus-newsgroup-unreads
8139 (delq number gnus-newsgroup-unreads))
8140 (if gnus-newsgroup-auto-expire
8141 (push number gnus-newsgroup-expirable)
8142 (push (cons number gnus-low-score-mark)
8143 gnus-newsgroup-reads)))
8144 ;; Go recursively through all subthreads.
8145 (mapcar 'gnus-expunge-thread (cdr thread)))
8147 ;; Summary article oriented commands
8149 (defun gnus-summary-refer-parent-article (n)
8150 "Refer parent article N times.
8151 If N is negative, go to ancestor -N instead.
8152 The difference between N and the number of articles fetched is returned."
8156 (when (not (natnump n))
8161 (setq header (gnus-summary-article-header))
8162 (if (and (eq (mail-header-number header)
8163 (cdr gnus-article-current))
8164 (equal gnus-newsgroup-name
8165 (car gnus-article-current)))
8166 ;; If we try to find the parent of the currently
8167 ;; displayed article, then we take a look at the actual
8168 ;; References header, since this is slightly more
8169 ;; reliable than the References field we got from the
8172 (set-buffer gnus-original-article-buffer)
8173 (nnheader-narrow-to-headers)
8174 (unless (setq ref (message-fetch-field "references"))
8175 (when (setq ref (message-fetch-field "in-reply-to"))
8176 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8179 ;; It's not the current article, so we take a bet on
8180 ;; the value we got from the server.
8181 (mail-header-references header)))
8183 (not (equal ref "")))
8184 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8185 (gnus-message 1 "Couldn't find parent"))
8186 (gnus-message 1 "No references in article %d"
8187 (gnus-summary-article-number))
8190 (gnus-summary-position-point)
8193 (defun gnus-summary-refer-references ()
8194 "Fetch all articles mentioned in the References header.
8195 Return the number of articles fetched."
8197 (let ((ref (mail-header-references (gnus-summary-article-header)))
8198 (current (gnus-summary-article-number))
8202 (error "No References in the current article")
8203 ;; For each Message-ID in the References header...
8204 (while (string-match "<[^>]*>" ref)
8206 ;; ... fetch that article.
8207 (gnus-summary-refer-article
8208 (prog1 (match-string 0 ref)
8209 (setq ref (substring ref (match-end 0))))))
8210 (gnus-summary-goto-subject current)
8211 (gnus-summary-position-point)
8214 (defun gnus-summary-refer-thread (&optional limit)
8215 "Fetch all articles in the current thread.
8216 If LIMIT (the numerical prefix), fetch that many old headers instead
8217 of what's specified by the `gnus-refer-thread-limit' variable."
8219 (let ((id (mail-header-id (gnus-summary-article-header)))
8220 (limit (if limit (prefix-numeric-value limit)
8221 gnus-refer-thread-limit)))
8222 (unless (eq gnus-fetch-old-headers 'invisible)
8223 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8224 ;; Retrieve the headers and read them in.
8225 (if (eq (if (numberp limit)
8226 (gnus-retrieve-headers
8228 (+ (mail-header-number
8229 (gnus-summary-article-header))
8231 gnus-newsgroup-end))
8232 gnus-newsgroup-name (* limit 2))
8233 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8235 (gnus-retrieve-headers (list gnus-newsgroup-end)
8236 gnus-newsgroup-name limit))
8238 (gnus-build-all-threads)
8239 (error "Can't fetch thread from back ends that don't support NOV"))
8240 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8241 (gnus-summary-limit-include-thread id)))
8243 (defun gnus-summary-refer-article (message-id)
8244 "Fetch an article specified by MESSAGE-ID."
8245 (interactive "sMessage-ID: ")
8246 (when (and (stringp message-id)
8247 (not (zerop (length message-id))))
8248 (setq message-id (gnus-replace-in-string message-id " " ""))
8249 ;; Construct the correct Message-ID if necessary.
8250 ;; Suggested by tale@pawl.rpi.edu.
8251 (unless (string-match "^<" message-id)
8252 (setq message-id (concat "<" message-id)))
8253 (unless (string-match ">$" message-id)
8254 (setq message-id (concat message-id ">")))
8255 ;; People often post MIDs from URLs, so unhex it:
8256 (unless (string-match "@" message-id)
8257 (setq message-id (gnus-url-unhex-string message-id)))
8258 (let* ((header (gnus-id-to-header message-id))
8260 (gnus-summary-article-sparse-p
8261 (mail-header-number header))
8262 (memq (mail-header-number header)
8263 gnus-newsgroup-limit)))
8266 ;; If the article is present in the buffer we just go to it.
8268 (or (not (gnus-summary-article-sparse-p
8269 (mail-header-number header)))
8272 (gnus-summary-goto-article
8273 (mail-header-number header) nil t)
8275 (gnus-summary-update-article (mail-header-number header)))))
8277 ;; We fetch the article.
8279 (dolist (gnus-override-method (gnus-refer-article-methods))
8280 (when (and (gnus-check-server gnus-override-method)
8281 ;; Fetch the header,
8282 (setq number (gnus-summary-insert-subject message-id)))
8283 ;; and display the article.
8284 (gnus-summary-select-article nil nil nil number)
8286 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8288 (defun gnus-refer-article-methods ()
8289 "Return a list of referable methods."
8291 ;; No method, so we default to current and native.
8292 ((null gnus-refer-article-method)
8293 (list gnus-current-select-method gnus-select-method))
8295 ((eq 'current gnus-refer-article-method)
8296 (list gnus-current-select-method))
8297 ;; List of select methods.
8298 ((not (and (symbolp (car gnus-refer-article-method))
8299 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8301 (dolist (method gnus-refer-article-method)
8302 (push (if (eq 'current method)
8303 gnus-current-select-method
8307 ;; One single select method.
8309 (list gnus-refer-article-method))))
8311 (defun gnus-summary-edit-parameters ()
8312 "Edit the group parameters of the current group."
8314 (gnus-group-edit-group gnus-newsgroup-name 'params))
8316 (defun gnus-summary-customize-parameters ()
8317 "Customize the group parameters of the current group."
8319 (gnus-group-customize gnus-newsgroup-name))
8321 (defun gnus-summary-enter-digest-group (&optional force)
8322 "Enter an nndoc group based on the current article.
8323 If FORCE, force a digest interpretation. If not, try
8324 to guess what the document format is."
8326 (let ((conf gnus-current-window-configuration))
8327 (save-window-excursion
8329 (let (gnus-article-prepare-hook
8330 gnus-display-mime-function
8332 (gnus-summary-select-article))))
8333 (setq gnus-current-window-configuration conf)
8334 (let* ((name (format "%s-%d"
8335 (gnus-group-prefixed-name
8336 gnus-newsgroup-name (list 'nndoc ""))
8337 (with-current-buffer gnus-summary-buffer
8338 gnus-current-article)))
8339 (ogroup gnus-newsgroup-name)
8340 (params (append (gnus-info-params (gnus-get-info ogroup))
8341 (list (cons 'to-group ogroup))
8342 (list (cons 'parent-group ogroup))
8343 (list (cons 'save-article-group ogroup))))
8344 (case-fold-search t)
8345 (buf (current-buffer))
8348 (set-buffer gnus-original-article-buffer)
8349 ;; Have the digest group inherit the main mail address of
8350 ;; the parent article.
8351 (when (setq to-address (or (gnus-fetch-field "reply-to")
8352 (gnus-fetch-field "from")))
8353 (setq params (append
8354 (list (cons 'to-address
8355 (funcall gnus-decode-encoded-word-function
8357 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8358 (insert-buffer-substring gnus-original-article-buffer)
8359 ;; Remove lines that may lead nndoc to misinterpret the
8362 (goto-char (point-min))
8363 (or (search-forward "\n\n" nil t) (point)))
8364 (goto-char (point-min))
8365 (delete-matching-lines "^Path:\\|^From ")
8368 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8369 (gnus-newsgroup-ephemeral-ignored-charsets
8370 gnus-newsgroup-ignored-charsets))
8371 (gnus-group-read-ephemeral-group
8372 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8374 ,(if force 'mbox 'guess)))
8376 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8378 ;; Make all postings to this group go to the parent group.
8379 (nconc (gnus-info-params (gnus-get-info name))
8381 ;; Couldn't select this doc group.
8382 (switch-to-buffer buf)
8383 (gnus-set-global-variables)
8384 (gnus-configure-windows 'summary)
8385 (gnus-message 3 "Article couldn't be entered?"))
8386 (kill-buffer dig)))))
8388 (defun gnus-summary-read-document (n)
8389 "Open a new group based on the current article(s).
8390 This will allow you to read digests and other similar
8391 documents as newsgroups.
8392 Obeys the standard process/prefix convention."
8394 (let* ((articles (gnus-summary-work-articles n))
8395 (ogroup gnus-newsgroup-name)
8396 (params (append (gnus-info-params (gnus-get-info ogroup))
8397 (list (cons 'to-group ogroup))))
8398 article group egroup groups vgroup)
8399 (while (setq article (pop articles))
8400 (setq group (format "%s-%d" gnus-newsgroup-name article))
8401 (gnus-summary-remove-process-mark article)
8402 (when (gnus-summary-display-article article)
8405 (insert-buffer-substring gnus-original-article-buffer)
8406 ;; Remove some headers that may lead nndoc to make
8408 (message-narrow-to-head)
8409 (goto-char (point-min))
8410 (delete-matching-lines "^Path:\\|^From ")
8413 (gnus-group-read-ephemeral-group
8414 group `(nndoc ,group (nndoc-address ,(current-buffer))
8415 (nndoc-article-type guess))
8418 ;; Make all postings to this group go to the parent group.
8419 (nconc (gnus-info-params (gnus-get-info egroup))
8421 (push egroup groups))
8422 ;; Couldn't select this doc group.
8423 (gnus-error 3 "Article couldn't be entered"))))))
8424 ;; Now we have selected all the documents.
8427 (error "None of the articles could be interpreted as documents"))
8428 ((gnus-group-read-ephemeral-group
8429 (setq vgroup (format
8430 "nnvirtual:%s-%s" gnus-newsgroup-name
8431 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8432 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8434 (cons (current-buffer) 'summary)))
8436 (error "Couldn't select virtual nndoc group")))))
8438 (defun gnus-summary-isearch-article (&optional regexp-p)
8439 "Do incremental search forward on the current article.
8440 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8442 (let* ((gnus-inhibit-treatment t)
8443 (old (gnus-summary-select-article)))
8444 (gnus-configure-windows 'article)
8445 (gnus-eval-in-buffer-window gnus-article-buffer
8449 (gnus-article-show-all-headers))
8450 (goto-char (point-min))
8451 (isearch-forward regexp-p)))))
8453 (defun gnus-summary-search-article-forward (regexp &optional backward)
8454 "Search for an article containing REGEXP forward.
8455 If BACKWARD, search backward instead."
8458 (format "Search article %s (regexp%s): "
8459 (if current-prefix-arg "backward" "forward")
8460 (if gnus-last-search-regexp
8461 (concat ", default " gnus-last-search-regexp)
8463 current-prefix-arg))
8464 (if (string-equal regexp "")
8465 (setq regexp (or gnus-last-search-regexp ""))
8466 (setq gnus-last-search-regexp regexp)
8467 (setq gnus-article-before-search gnus-current-article))
8468 ;; Intentionally set gnus-last-article.
8469 (setq gnus-last-article gnus-article-before-search)
8470 (let ((gnus-last-article gnus-last-article))
8471 (if (gnus-summary-search-article regexp backward)
8472 (gnus-summary-show-thread)
8473 (signal 'search-failed (list regexp)))))
8475 (defun gnus-summary-search-article-backward (regexp)
8476 "Search for an article containing REGEXP backward."
8479 (format "Search article backward (regexp%s): "
8480 (if gnus-last-search-regexp
8481 (concat ", default " gnus-last-search-regexp)
8483 (gnus-summary-search-article-forward regexp 'backward))
8486 (defmacro gnus-summary-search-article-position-point (regexp backward)
8487 "Dehighlight the last matched text and goto the beginning position."
8488 (` (if (and gnus-summary-search-article-matched-data
8489 (let ((text (caddr gnus-summary-search-article-matched-data))
8490 (inhibit-read-only t)
8493 (goto-char (car gnus-summary-search-article-matched-data))
8494 (cadr gnus-summary-search-article-matched-data))
8496 (string-match (, regexp) text)))
8497 (if (, backward) (beginning-of-line) (end-of-line))
8498 (goto-char (if (, backward) (point-max) (point-min))))))
8500 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8501 "Place point where X-Face image is displayed."
8502 (if (featurep 'xemacs)
8503 (` (let ((end (if (search-forward "\n\n" nil t)
8504 (goto-char (1- (point)))
8507 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8508 (unless (and (re-search-forward "^From:" end t)
8509 (setq extent (extent-at (point)))
8510 (extent-begin-glyph extent))
8511 (goto-char (, opoint)))))
8512 (` (let ((end (if (search-forward "\n\n" nil t)
8513 (goto-char (1- (point)))
8515 (start (or (search-backward "\n\n" nil t) (point-min))))
8517 (or (text-property-any start end 'x-face-image t);; x-face-e21
8518 (text-property-any start end 'x-face-mule-bitmap-image t)
8521 (defmacro gnus-summary-search-article-highlight-matched-text
8522 (backward treated x-face)
8523 "Highlight matched text in the function `gnus-summary-search-article'."
8524 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8525 (end (set-marker (make-marker) (match-end 0)))
8526 (inhibit-read-only t)
8530 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8532 (lambda (item) (setq items (delq item items)))
8533 '(gnus-treat-buttonize
8534 gnus-treat-fill-article
8535 gnus-treat-fill-long-lines
8536 gnus-treat-emphasize
8537 gnus-treat-highlight-headers
8538 gnus-treat-highlight-citation
8539 gnus-treat-highlight-signature
8540 gnus-treat-overstrike
8541 gnus-treat-display-x-face
8542 gnus-treat-buttonize-head
8543 gnus-treat-decode-article-as-default-mime-charset))
8544 (static-if (featurep 'xemacs)
8546 (cons '(x-face-mule-delete-x-face-field
8549 (gnus-treat-display-x-face
8550 (when (, x-face) gnus-treat-display-x-face)))
8551 (gnus-article-prepare-mime-display)))
8552 (goto-char (if (, backward) start end))
8554 (gnus-summary-search-article-highlight-goto-x-face (point)))
8555 (setq gnus-summary-search-article-matched-data
8556 (list start end (buffer-substring start end)))
8557 (unless (eq start end);; matched text has been deleted. :-<
8558 (put-text-property start end 'face
8559 (or (find-face 'isearch)
8560 'secondary-selection))))))
8563 (defun gnus-summary-search-article (regexp &optional backward)
8564 "Search for an article containing REGEXP.
8565 Optional argument BACKWARD means do search for backward.
8566 `gnus-select-article-hook' is not called during the search."
8567 ;; We have to require this here to make sure that the following
8568 ;; dynamic binding isn't shadowed by autoloading.
8569 (require 'gnus-async)
8571 (let ((gnus-select-article-hook nil) ;Disable hook.
8572 (gnus-article-prepare-hook nil)
8573 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8574 (gnus-use-article-prefetch nil)
8575 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8576 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8578 (gnus-keep-backlog nil)
8579 (gnus-break-pages nil)
8580 (gnus-summary-display-arrow nil)
8581 (gnus-updated-mode-lines nil)
8582 (gnus-auto-center-summary nil)
8583 (sum (current-buffer))
8586 (gnus-save-hidden-threads
8587 (static-if (featurep 'xemacs)
8588 (let ((gnus-inhibit-treatment t))
8589 (setq treated (eq 'old (gnus-summary-select-article)))
8591 (not (and (gnus-buffer-live-p gnus-article-buffer)
8592 (window-live-p (get-buffer-window
8593 gnus-article-buffer t)))))
8594 (gnus-summary-select-article nil t)
8595 (setq treated nil)))
8596 (let ((gnus-inhibit-treatment t)
8597 (x-face-mule-delete-x-face-field 'never))
8598 (setq treated (eq 'old (gnus-summary-select-article)))
8601 (and (gnus-buffer-live-p gnus-article-buffer)
8602 (window-live-p (get-buffer-window
8603 gnus-article-buffer t))
8604 (or (not (string-match "^\\^X-Face:" regexp))
8605 (with-current-buffer gnus-article-buffer
8606 gnus-summary-search-article-matched-data)))))
8607 (gnus-summary-select-article nil t)
8608 (setq treated nil))))
8609 (set-buffer gnus-article-buffer)
8613 (gnus-article-show-all-headers)
8614 (gnus-summary-search-article-position-point regexp backward))
8615 (goto-char (if backward (point-max) (point-min))))
8617 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8619 (re-search-backward regexp nil t)
8620 (re-search-forward regexp nil t))
8621 ;; We found the regexp.
8623 (gnus-summary-search-article-highlight-matched-text
8624 backward treated (string-match "^\\^X-Face:" regexp))
8627 (/ (- 2 (window-height
8628 (get-buffer-window gnus-article-buffer t)))
8631 (get-buffer-window (current-buffer))
8634 (setq point (point)))
8635 ;; We didn't find it, so we go to the next article.
8638 (while (eq found 'not)
8639 (if (not (if backward (gnus-summary-find-prev)
8640 (gnus-summary-find-next)))
8641 ;; No more articles.
8643 ;; Select the next article and adjust point.
8644 (unless (gnus-summary-article-sparse-p
8645 (gnus-summary-article-number))
8647 (let ((gnus-inhibit-treatment t))
8648 (gnus-summary-select-article))
8650 (set-buffer gnus-article-buffer)
8652 (goto-char (if backward (point-max) (point-min))))))))
8653 (gnus-message 7 ""))
8654 ;; Return whether we found the regexp.
8655 (when (eq found 'found)
8657 (gnus-summary-show-thread)
8658 (gnus-summary-goto-subject gnus-current-article)
8659 (gnus-summary-position-point)
8662 (defun gnus-find-matching-articles (header regexp)
8663 "Return a list of all articles that match REGEXP on HEADER.
8664 This search includes all articles in the current group that Gnus has
8665 fetched headers for, whether they are displayed or not."
8666 (let ((articles nil)
8667 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8668 (case-fold-search t))
8669 (dolist (header gnus-newsgroup-headers)
8670 (when (string-match regexp (funcall func header))
8671 (push (mail-header-number header) articles)))
8672 (nreverse articles)))
8674 (defun gnus-summary-find-matching (header regexp &optional backward unread
8675 not-case-fold not-matching)
8676 "Return a list of all articles that match REGEXP on HEADER.
8677 The search stars on the current article and goes forwards unless
8678 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8679 If UNREAD is non-nil, only unread articles will
8680 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8681 in the comparisons. If NOT-MATCHING, return a list of all articles that
8682 not match REGEXP on HEADER."
8683 (let ((case-fold-search (not not-case-fold))
8686 (if (eq (car header) 'extra)
8689 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8691 (error "%s is an invalid header" header))
8692 (unless (fboundp (intern (concat "mail-header-" header)))
8693 (error "%s is not a valid header" header))
8694 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8695 (dolist (d (if (eq backward 'all)
8697 (gnus-data-find-list
8698 (gnus-summary-article-number)
8699 (gnus-data-list backward))))
8700 (when (and (or (not unread) ; We want all articles...
8701 (gnus-data-unread-p d)) ; Or just unreads.
8702 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8706 (funcall func (gnus-data-header d))))
8707 (string-match regexp
8708 (funcall func (gnus-data-header d)))))
8709 (push (gnus-data-number d) articles))) ; Success!
8710 (nreverse articles)))
8712 (defun gnus-summary-execute-command (header regexp command &optional backward)
8713 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8714 If HEADER is an empty string (or nil), the match is done on the entire
8715 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8717 (list (let ((completion-ignore-case t))
8720 (mapcar (lambda (header) (list (format "%s" header)))
8722 '("Number" "Subject" "From" "Lines" "Date"
8723 "Message-ID" "Xref" "References" "Body")
8724 gnus-extra-headers))
8725 nil 'require-match))
8726 (read-string "Regexp: ")
8727 (read-key-sequence "Command: ")
8728 current-prefix-arg))
8729 (when (equal header "Body")
8731 ;; Hidden thread subtrees must be searched as well.
8732 (gnus-summary-show-all-threads)
8733 ;; We don't want to change current point nor window configuration.
8735 (save-window-excursion
8737 gnus-treat-strip-trailing-blank-lines
8738 gnus-treat-strip-leading-blank-lines
8739 gnus-treat-strip-multiple-blank-lines
8740 gnus-treat-hide-boring-headers
8741 gnus-treat-fold-newsgroups
8742 gnus-article-prepare-hook)
8743 (gnus-message 6 "Executing %s..." (key-description command))
8744 ;; We'd like to execute COMMAND interactively so as to give arguments.
8745 (gnus-execute header regexp
8746 `(call-interactively ',(key-binding command))
8748 (gnus-message 6 "Executing %s...done" (key-description command))))))
8750 (defun gnus-summary-beginning-of-article ()
8751 "Scroll the article back to the beginning."
8753 (gnus-summary-select-article)
8754 (gnus-configure-windows 'article)
8755 (gnus-eval-in-buffer-window gnus-article-buffer
8757 (goto-char (point-min))
8758 (when gnus-break-pages
8759 (gnus-narrow-to-page))))
8761 (defun gnus-summary-end-of-article ()
8762 "Scroll to the end of the article."
8764 (gnus-summary-select-article)
8765 (gnus-configure-windows 'article)
8766 (gnus-eval-in-buffer-window gnus-article-buffer
8768 (goto-char (point-max))
8770 (when gnus-break-pages
8771 (when (re-search-backward page-delimiter nil t)
8772 (narrow-to-region (match-end 0) (point-max)))
8773 (gnus-narrow-to-page))))
8775 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8776 "Truncate to LEN and quote all \"(\"'s in STRING."
8777 (gnus-replace-in-string (if (and len (> (length string) len))
8778 (substring string 0 len)
8782 (defun gnus-summary-print-article (&optional filename n)
8783 "Generate and print a PostScript image of the process-marked (mail) articles.
8785 If used interactively, print the current article if none are
8786 process-marked. With prefix arg, prompt the user for the name of the
8789 When used from Lisp, accept two optional args FILENAME and N. N means
8790 to print the next N articles. If N is negative, print the N previous
8791 articles. If N is nil and articles have been marked with the process
8792 mark, print these instead.
8794 If the optional first argument FILENAME is nil, send the image to the
8795 printer. If FILENAME is a string, save the PostScript image in a file with
8796 that name. If FILENAME is a number, prompt the user for the name of the file
8798 (interactive (list (ps-print-preprint current-prefix-arg)))
8799 (dolist (article (gnus-summary-work-articles n))
8800 (gnus-summary-select-article nil nil 'pseudo article)
8801 (gnus-eval-in-buffer-window gnus-article-buffer
8802 (gnus-print-buffer))
8803 (gnus-summary-remove-process-mark article))
8804 (ps-despool filename))
8806 (defun gnus-print-buffer ()
8807 (let ((buffer (generate-new-buffer " *print*")))
8810 (copy-to-buffer buffer (point-min) (point-max))
8812 (gnus-remove-text-with-property 'gnus-decoration)
8813 (when (gnus-visual-p 'article-highlight 'highlight)
8814 ;; Copy-to-buffer doesn't copy overlay. So redo
8816 (let ((gnus-article-buffer buffer))
8817 (gnus-article-highlight-citation t)
8818 (gnus-article-highlight-signature)
8819 (gnus-article-emphasize)
8820 (gnus-article-delete-invisible-text)))
8821 (let ((ps-left-header
8824 (gnus-summary-print-truncate-and-quote
8825 (mail-header-subject gnus-current-headers)
8828 (gnus-summary-print-truncate-and-quote
8829 (mail-header-from gnus-current-headers)
8833 "/pagenumberstring load"
8835 (mail-header-date gnus-current-headers) ")"))))
8836 (gnus-run-hooks 'gnus-ps-print-hook)
8839 (ps-spool-buffer-with-faces)
8840 (ps-spool-buffer)))))
8841 (kill-buffer buffer))))
8843 (defun gnus-summary-show-article (&optional arg)
8844 "Force redisplaying of the current article.
8845 If ARG (the prefix) is a number, show the article with the charset
8846 defined in `gnus-summary-show-article-charset-alist', or the charset
8848 If ARG (the prefix) is non-nil and not a number, show the raw article
8849 without any article massaging functions being run. Normally, the key
8850 strokes are `C-u g'."
8854 (gnus-summary-show-article t)
8855 (let* ((gnus-newsgroup-charset
8856 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8857 (mm-read-coding-system
8858 "View as charset: " ;; actually it is coding system.
8860 (set-buffer gnus-article-buffer)
8861 (mm-detect-coding-region (point) (point-max))))))
8862 (default-mime-charset gnus-newsgroup-charset)
8863 (gnus-newsgroup-ignored-charsets 'gnus-all))
8864 (gnus-summary-select-article nil 'force)
8865 (let ((deps gnus-newsgroup-dependencies)
8868 (set-buffer gnus-original-article-buffer)
8870 (message-narrow-to-head)
8871 (setq head (buffer-string))
8872 (goto-char (point-min))
8873 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8874 (goto-char (point-max))
8876 (setq lines (1- (count-lines (point) (point-max))))))
8878 (insert (format "211 %d Article retrieved.\n"
8879 (cdr gnus-article-current)))
8881 (if lines (insert (format "Lines: %d\n" lines)))
8883 (let ((nntp-server-buffer (current-buffer)))
8884 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8885 (gnus-data-set-header
8886 (gnus-data-find (cdr gnus-article-current))
8888 (gnus-summary-update-article-line
8889 (cdr gnus-article-current) header)
8890 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8891 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8893 ;; Select the article the normal way.
8894 (gnus-summary-select-article nil 'force))
8896 ;; We have to require this here to make sure that the following
8897 ;; dynamic binding isn't shadowed by autoloading.
8898 (require 'gnus-async)
8900 ;; Bind the article treatment functions to nil.
8901 (let ((gnus-have-all-headers t)
8902 gnus-article-prepare-hook
8903 gnus-article-decode-hook
8906 (gnus-inhibit-treatment t))
8907 (gnus-summary-select-article nil 'force))))
8908 (gnus-summary-goto-subject gnus-current-article)
8909 (gnus-summary-position-point))
8911 (defun gnus-summary-show-raw-article ()
8912 "Show the raw article without any article massaging functions being run."
8914 (gnus-summary-show-article t))
8916 (defun gnus-summary-verbose-headers (&optional arg)
8917 "Toggle permanent full header display.
8918 If ARG is a positive number, turn header display on.
8919 If ARG is a negative number, turn header display off."
8921 (setq gnus-show-all-headers
8922 (cond ((or (not (numberp arg))
8924 (not gnus-show-all-headers))
8927 (gnus-summary-show-article))
8929 (defun gnus-summary-toggle-header (&optional arg)
8930 "Show the headers if they are hidden, or hide them if they are shown.
8931 If ARG is a positive number, show the entire header.
8932 If ARG is a negative number, hide the unwanted header lines."
8934 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8935 (get-buffer-window gnus-article-buffer t))))
8936 (with-current-buffer gnus-article-buffer
8938 (article-narrow-to-head)
8939 (let* ((buffer-read-only nil)
8940 (inhibit-point-motion-hooks t)
8941 (hidden (if (numberp arg)
8943 (gnus-article-hidden-text-p 'headers)))
8945 (delete-region (point-min) (point-max))
8946 (with-current-buffer gnus-original-article-buffer
8947 (goto-char (setq s (point-min)))
8948 (setq e (if (search-forward "\n\n" nil t)
8951 (insert-buffer-substring gnus-original-article-buffer s e)
8952 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8953 ;; article-decode-encoded-words by default.
8954 (article-decode-encoded-words)
8955 (run-hooks 'gnus-article-decode-hook)
8957 (let ((gnus-treat-hide-headers nil)
8958 (gnus-treat-hide-boring-headers nil))
8959 (gnus-delete-wash-type 'headers)
8960 (gnus-treat-article 'head))
8961 (gnus-treat-article 'head))
8964 (set-window-start window (goto-char (point-min))))
8965 (if gnus-break-pages
8966 (gnus-narrow-to-page)
8967 (when (gnus-visual-p 'page-marker)
8968 (let ((buffer-read-only nil))
8969 (gnus-remove-text-with-property 'gnus-prev)
8970 (gnus-remove-text-with-property 'gnus-next))))
8971 (gnus-set-mode-line 'article)))))
8973 (defun gnus-summary-show-all-headers ()
8974 "Make all header lines visible."
8976 (gnus-summary-toggle-header 1))
8978 (defun gnus-summary-toggle-mime (&optional arg)
8979 "Toggle MIME processing.
8980 If ARG is a positive number, turn MIME processing on."
8982 (setq gnus-show-mime
8984 (not gnus-show-mime)
8985 (> (prefix-numeric-value arg) 0)))
8986 (gnus-summary-select-article t 'force))
8988 (defun gnus-summary-caesar-message (&optional arg)
8989 "Caesar rotate the current article by 13.
8990 The numerical prefix specifies how many places to rotate each letter
8993 (gnus-summary-select-article)
8994 (let ((mail-header-separator ""))
8995 (gnus-eval-in-buffer-window gnus-article-buffer
8998 (let ((start (window-start))
9000 (message-caesar-buffer-body arg)
9001 (set-window-start (get-buffer-window (current-buffer)) start))))))
9003 (autoload 'unmorse-region "morse"
9004 "Convert morse coded text in region to ordinary ASCII text."
9007 (defun gnus-summary-morse-message (&optional arg)
9008 "Morse decode the current article."
9010 (gnus-summary-select-article)
9011 (let ((mail-header-separator ""))
9012 (gnus-eval-in-buffer-window gnus-article-buffer
9016 (let ((pos (window-start))
9018 (goto-char (point-min))
9019 (when (message-goto-body)
9020 (gnus-narrow-to-body))
9021 (goto-char (point-min))
9022 (while (search-forward "·" (point-max) t)
9023 (replace-match "."))
9024 (unmorse-region (point-min) (point-max))
9026 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9028 (defun gnus-summary-stop-page-breaking ()
9029 "Stop page breaking in the current article."
9031 (gnus-summary-select-article)
9032 (gnus-eval-in-buffer-window gnus-article-buffer
9034 (when (gnus-visual-p 'page-marker)
9035 (let ((buffer-read-only nil))
9036 (gnus-remove-text-with-property 'gnus-prev)
9037 (gnus-remove-text-with-property 'gnus-next))
9038 (setq gnus-page-broken nil))))
9040 (defun gnus-summary-move-article (&optional n to-newsgroup
9041 select-method action)
9042 "Move the current article to a different newsgroup.
9043 If N is a positive number, move the N next articles.
9044 If N is a negative number, move the N previous articles.
9045 If N is nil and any articles have been marked with the process mark,
9046 move those articles instead.
9047 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9048 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9049 re-spool using this method.
9051 When called interactively with TO-NEWSGROUP being nil, the value of
9052 the variable `gnus-move-split-methods' is used for finding a default
9053 for the target newsgroup.
9055 For this function to work, both the current newsgroup and the
9056 newsgroup that you want to move to have to support the `request-move'
9057 and `request-accept' functions.
9059 ACTION can be either `move' (the default), `crosspost' or `copy'."
9062 (setq action 'move))
9063 ;; Check whether the source group supports the required functions.
9064 (cond ((and (eq action 'move)
9065 (not (gnus-check-backend-function
9066 'request-move-article gnus-newsgroup-name)))
9067 (error "The current group does not support article moving"))
9068 ((and (eq action 'crosspost)
9069 (not (gnus-check-backend-function
9070 'request-replace-article gnus-newsgroup-name)))
9071 (error "The current group does not support article editing")))
9072 (let ((articles (gnus-summary-work-articles n))
9073 (prefix (if (gnus-check-backend-function
9074 'request-move-article gnus-newsgroup-name)
9075 (funcall gnus-move-group-prefix-function
9076 gnus-newsgroup-name)
9078 (names '((move "Move" "Moving")
9079 (copy "Copy" "Copying")
9080 (crosspost "Crosspost" "Crossposting")))
9081 (copy-buf (save-excursion
9082 (nnheader-set-temp-buffer " *copy article*")))
9083 art-group to-method new-xref article to-groups)
9084 (unless (assq action names)
9085 (error "Unknown action %s" action))
9086 ;; Read the newsgroup name.
9087 (when (and (not to-newsgroup)
9088 (not select-method))
9089 (if (and gnus-move-split-methods
9091 (and (memq gnus-current-article articles)
9092 (gnus-buffer-live-p gnus-original-article-buffer))))
9093 ;; When `gnus-move-split-methods' is non-nil, we have to
9094 ;; select an article to give `gnus-read-move-group-name' an
9095 ;; opportunity to suggest an appropriate default. However,
9096 ;; we needn't render or mark the article.
9097 (let ((gnus-display-mime-function nil)
9098 (gnus-article-prepare-hook nil)
9099 (gnus-mark-article-hook nil))
9100 (gnus-summary-select-article nil nil nil (car articles))))
9102 (gnus-read-move-group-name
9103 (cadr (assq action names))
9104 (symbol-value (intern (format "gnus-current-%s-group" action)))
9106 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9107 (setq to-method (or select-method
9108 (gnus-server-to-method
9109 (gnus-group-method to-newsgroup))))
9110 ;; Check the method we are to move this article to...
9111 (unless (gnus-check-backend-function
9112 'request-accept-article (car to-method))
9113 (error "%s does not support article copying" (car to-method)))
9114 (unless (gnus-check-server to-method)
9115 (error "Can't open server %s" (car to-method)))
9116 (gnus-message 6 "%s to %s: %s..."
9117 (caddr (assq action names))
9118 (or (car select-method) to-newsgroup) articles)
9120 (setq article (pop articles))
9124 ;; Move the article.
9126 ;; Remove this article from future suppression.
9127 (gnus-dup-unsuppress-article article)
9128 (gnus-request-move-article
9129 article ; Article to move
9130 gnus-newsgroup-name ; From newsgroup
9131 (nth 1 (gnus-find-method-for-group
9132 gnus-newsgroup-name)) ; Server
9133 (list 'gnus-request-accept-article
9134 to-newsgroup (list 'quote select-method)
9135 (not articles) t) ; Accept form
9136 (not articles))) ; Only save nov last time
9137 ;; Copy the article.
9140 (set-buffer copy-buf)
9141 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9142 (gnus-request-accept-article
9143 to-newsgroup select-method (not articles) t))))
9144 ;; Crosspost the article.
9145 ((eq action 'crosspost)
9146 (let ((xref (message-tokenize-header
9147 (mail-header-xref (gnus-summary-article-header article))
9149 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9150 ":" (number-to-string article)))
9152 (setq xref (list (system-name))))
9155 (mapconcat 'identity
9156 (delete "Xref:" (delete new-xref xref))
9160 (set-buffer copy-buf)
9161 ;; First put the article in the destination group.
9162 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9163 (when (consp (setq art-group
9164 (gnus-request-accept-article
9165 to-newsgroup select-method (not articles))))
9166 (setq new-xref (concat new-xref " " (car art-group)
9168 (number-to-string (cdr art-group))))
9169 ;; Now we have the new Xrefs header, so we insert
9170 ;; it and replace the new article.
9171 (nnheader-replace-header "Xref" new-xref)
9172 (gnus-request-replace-article
9173 (cdr art-group) to-newsgroup (current-buffer))
9177 (gnus-message 1 "Couldn't %s article %s: %s"
9178 (cadr (assq action names)) article
9179 (nnheader-get-report (car to-method))))
9180 ((eq art-group 'junk)
9181 (when (eq action 'move)
9182 (gnus-summary-mark-article article gnus-canceled-mark)
9183 (gnus-message 4 "Deleted article %s" article)
9184 ;; run the delete hook
9185 (run-hook-with-args 'gnus-summary-article-delete-hook
9188 (assoc article (gnus-data-list nil)))
9189 gnus-newsgroup-name nil
9192 (let* ((pto-group (gnus-group-prefixed-name
9193 (car art-group) to-method))
9194 (info (gnus-get-info pto-group))
9195 (to-group (gnus-info-group info))
9197 ;; Update the group that has been moved to.
9199 (memq action '(move copy)))
9200 (unless (member to-group to-groups)
9201 (push to-group to-groups))
9203 (unless (memq article gnus-newsgroup-unreads)
9204 (push 'read to-marks)
9206 info (gnus-add-to-range (gnus-info-read info)
9207 (list (cdr art-group)))))
9209 ;; See whether the article is to be put in the cache.
9210 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9211 gnus-article-mark-lists
9212 (delete '(expirable . expire)
9213 (copy-sequence gnus-article-mark-lists))))
9214 (to-article (cdr art-group)))
9216 ;; Enter the article into the cache in the new group,
9217 ;; if that is required.
9218 (when gnus-use-cache
9219 (gnus-cache-possibly-enter-article
9221 (let ((header (copy-sequence
9222 (gnus-summary-article-header article))))
9223 (mail-header-set-number header to-article)
9225 (memq article gnus-newsgroup-marked)
9226 (memq article gnus-newsgroup-dormant)
9227 (memq article gnus-newsgroup-unreads)))
9229 (when gnus-preserve-marks
9230 ;; Copy any marks over to the new group.
9231 (when (and (equal to-group gnus-newsgroup-name)
9232 (not (memq article gnus-newsgroup-unreads)))
9233 ;; Mark this article as read in this group.
9234 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9235 (setcdr (gnus-active to-group) to-article)
9236 (setcdr gnus-newsgroup-active to-article))
9239 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9240 (when (memq article (symbol-value
9241 (intern (format "gnus-newsgroup-%s"
9243 (push (cdar marks) to-marks)
9244 ;; If the other group is the same as this group,
9245 ;; then we have to add the mark to the list.
9246 (when (equal to-group gnus-newsgroup-name)
9247 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9250 (intern (format "gnus-newsgroup-%s"
9252 ;; Copy the marks to other group.
9253 (gnus-add-marked-articles
9254 to-group (cdar marks) (list to-article) info)))
9255 (setq marks (cdr marks)))
9257 (gnus-request-set-mark
9258 to-group (list (list (list to-article) 'add to-marks))))
9261 (concat "(gnus-group-set-info '"
9262 (gnus-prin1-to-string (gnus-get-info to-group))
9265 ;; Update the Xref header in this article to point to
9266 ;; the new crossposted article we have just created.
9267 (when (eq action 'crosspost)
9269 (set-buffer copy-buf)
9270 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9271 (nnheader-replace-header "Xref" new-xref)
9272 (gnus-request-replace-article
9273 article gnus-newsgroup-name (current-buffer))))
9275 ;; run the move/copy/crosspost/respool hook
9276 (run-hook-with-args 'gnus-summary-article-move-hook
9279 (assoc article (gnus-data-list nil)))
9284 ;;;!!!Why is this necessary?
9285 (set-buffer gnus-summary-buffer)
9287 (gnus-summary-goto-subject article)
9288 (when (eq action 'move)
9289 (gnus-summary-mark-article article gnus-canceled-mark))))
9290 (gnus-summary-remove-process-mark article))
9291 ;; Re-activate all groups that have been moved to.
9293 (set-buffer gnus-group-buffer)
9294 (let ((gnus-group-marked to-groups))
9295 (gnus-group-get-new-news-this-group nil t)))
9297 (gnus-kill-buffer copy-buf)
9298 (gnus-summary-position-point)
9299 (gnus-set-mode-line 'summary)))
9301 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9302 "Copy the current article to some other group.
9303 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9304 When called interactively, if TO-NEWSGROUP is nil, use the value of
9305 the variable `gnus-move-split-methods' for finding a default target
9307 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9308 re-spool using this method."
9310 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9312 (defun gnus-summary-crosspost-article (&optional n)
9313 "Crosspost the current article to some other group."
9315 (gnus-summary-move-article n nil nil 'crosspost))
9317 (defcustom gnus-summary-respool-default-method nil
9318 "Default method type for respooling an article.
9319 If nil, use to the current newsgroup method."
9321 :group 'gnus-summary-mail)
9323 (defcustom gnus-summary-display-while-building nil
9324 "If non-nil, show and update the summary buffer as it's being built.
9325 If the value is t, update the buffer after every line is inserted. If
9326 the value is an integer (N), update the display every N lines."
9328 :type '(choice (const :tag "off" nil)
9330 (const :tag "frequently" t)))
9332 (defun gnus-summary-respool-article (&optional n method)
9333 "Respool the current article.
9334 The article will be squeezed through the mail spooling process again,
9335 which means that it will be put in some mail newsgroup or other
9336 depending on `nnmail-split-methods'.
9337 If N is a positive number, respool the N next articles.
9338 If N is a negative number, respool the N previous articles.
9339 If N is nil and any articles have been marked with the process mark,
9340 respool those articles instead.
9342 Respooling can be done both from mail groups and \"real\" newsgroups.
9343 In the former case, the articles in question will be moved from the
9344 current group into whatever groups they are destined to. In the
9345 latter case, they will be copied into the relevant groups."
9347 (list current-prefix-arg
9348 (let* ((methods (gnus-methods-using 'respool))
9350 (symbol-name (or gnus-summary-respool-default-method
9351 (car (gnus-find-method-for-group
9352 gnus-newsgroup-name)))))
9354 (gnus-completing-read-with-default
9355 methname "What backend do you want to use when respooling?"
9356 methods nil t nil 'gnus-mail-method-history))
9359 ((zerop (length (setq ms (gnus-servers-using-backend
9361 (list (intern method) ""))
9365 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9366 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9369 (error "No method given for respooling"))
9370 (if (assoc (symbol-name
9371 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9372 (gnus-methods-using 'respool))
9373 (gnus-summary-move-article n nil method)
9374 (gnus-summary-copy-article n nil method)))
9376 (defun gnus-summary-import-article (file &optional edit)
9377 "Import an arbitrary file into a mail newsgroup."
9378 (interactive "fImport file: \nP")
9379 (let ((group gnus-newsgroup-name)
9380 (now (current-time))
9381 atts lines group-art)
9382 (unless (gnus-check-backend-function 'request-accept-article group)
9383 (error "%s does not support article importing" group))
9384 (or (file-readable-p file)
9385 (not (file-regular-p file))
9386 (error "Can't read %s" file))
9388 (set-buffer (gnus-get-buffer-create " *import file*"))
9390 (nnheader-insert-file-contents file)
9391 (goto-char (point-min))
9392 (if (nnheader-article-p)
9394 (goto-char (point-min))
9395 (search-forward "\n\n" nil t)
9396 (narrow-to-region (point-min) (1- (point)))
9397 (goto-char (point-min))
9398 (unless (re-search-forward "^date:" nil t)
9399 (goto-char (point-max))
9400 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9401 ;; This doesn't look like an article, so we fudge some headers.
9402 (setq atts (file-attributes file)
9403 lines (count-lines (point-min) (point-max)))
9404 (insert "From: " (read-string "From: ") "\n"
9405 "Subject: " (read-string "Subject: ") "\n"
9406 "Date: " (message-make-date (nth 5 atts)) "\n"
9407 "Message-ID: " (message-make-message-id) "\n"
9408 "Lines: " (int-to-string lines) "\n"
9409 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9410 (setq group-art (gnus-request-accept-article group nil t))
9411 (kill-buffer (current-buffer)))
9412 (setq gnus-newsgroup-active (gnus-activate-group group))
9414 (gnus-summary-goto-article (cdr group-art) nil t)
9416 (gnus-summary-edit-article))))
9418 (defun gnus-summary-create-article ()
9419 "Create an article in a mail newsgroup."
9421 (let ((group gnus-newsgroup-name)
9422 (now (current-time))
9424 (unless (gnus-check-backend-function 'request-accept-article group)
9425 (error "%s does not support article importing" group))
9427 (set-buffer (gnus-get-buffer-create " *import file*"))
9429 (goto-char (point-min))
9430 ;; This doesn't look like an article, so we fudge some headers.
9431 (insert "From: " (read-string "From: ") "\n"
9432 "Subject: " (read-string "Subject: ") "\n"
9433 "Date: " (message-make-date now) "\n"
9434 "Message-ID: " (message-make-message-id) "\n")
9435 (setq group-art (gnus-request-accept-article group nil t))
9436 (kill-buffer (current-buffer)))
9437 (setq gnus-newsgroup-active (gnus-activate-group group))
9439 (gnus-summary-goto-article (cdr group-art) nil t)
9440 (gnus-summary-edit-article)))
9442 (defun gnus-summary-article-posted-p ()
9443 "Say whether the current (mail) article is available from news as well.
9444 This will be the case if the article has both been mailed and posted."
9446 (let ((id (mail-header-references (gnus-summary-article-header)))
9447 (gnus-override-method (car (gnus-refer-article-methods))))
9448 (if (gnus-request-head id "")
9449 (gnus-message 2 "The current message was found on %s"
9450 gnus-override-method)
9451 (gnus-message 2 "The current message couldn't be found on %s"
9452 gnus-override-method)
9455 (defun gnus-summary-expire-articles (&optional now)
9456 "Expire all articles that are marked as expirable in the current group."
9458 (when (and (not gnus-group-is-exiting-without-update-p)
9459 (gnus-check-backend-function
9460 'request-expire-articles gnus-newsgroup-name))
9461 ;; This backend supports expiry.
9462 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9463 (expirable (if total
9465 ;; We need to update the info for
9466 ;; this group for `gnus-list-of-read-articles'
9467 ;; to give us the right answer.
9468 (gnus-run-hooks 'gnus-exit-group-hook)
9469 (gnus-summary-update-info)
9470 (gnus-list-of-read-articles gnus-newsgroup-name))
9471 (setq gnus-newsgroup-expirable
9472 (sort gnus-newsgroup-expirable '<))))
9473 (expiry-wait (if now 'immediate
9474 (gnus-group-find-parameter
9475 gnus-newsgroup-name 'expiry-wait)))
9476 (nnmail-expiry-target
9477 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9478 nnmail-expiry-target))
9481 ;; There are expirable articles in this group, so we run them
9482 ;; through the expiry process.
9483 (gnus-message 6 "Expiring articles...")
9484 (unless (gnus-check-group gnus-newsgroup-name)
9485 (error "Can't open server for %s" gnus-newsgroup-name))
9486 ;; The list of articles that weren't expired is returned.
9489 (let ((nnmail-expiry-wait-function nil)
9490 (nnmail-expiry-wait expiry-wait))
9491 (setq es (gnus-request-expire-articles
9492 expirable gnus-newsgroup-name)))
9493 (setq es (gnus-request-expire-articles
9494 expirable gnus-newsgroup-name)))
9496 (setq gnus-newsgroup-expirable es))
9497 ;; We go through the old list of expirable, and mark all
9498 ;; really expired articles as nonexistent.
9499 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9500 (let ((gnus-use-cache nil))
9501 (dolist (article expirable)
9502 (when (and (not (memq article es))
9503 (gnus-data-find article))
9504 (gnus-summary-mark-article article gnus-canceled-mark)
9505 (run-hook-with-args 'gnus-summary-article-expire-hook
9508 (assoc article (gnus-data-list nil)))
9512 (gnus-message 6 "Expiring articles...done")))))
9514 (defun gnus-summary-expire-articles-now ()
9515 "Expunge all expirable articles in the current group.
9516 This means that *all* articles that are marked as expirable will be
9517 deleted forever, right now."
9519 (or gnus-expert-user
9521 "Are you really, really, really sure you want to delete all these messages? ")
9523 (gnus-summary-expire-articles t))
9525 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9526 (defun gnus-summary-delete-article (&optional n)
9527 "Delete the N next (mail) articles.
9528 This command actually deletes articles. This is not a marking
9529 command. The article will disappear forever from your life, never to
9532 If N is negative, delete backwards.
9533 If N is nil and articles have been marked with the process mark,
9534 delete these instead.
9536 If `gnus-novice-user' is non-nil you will be asked for
9537 confirmation before the articles are deleted."
9539 (unless (gnus-check-backend-function 'request-expire-articles
9540 gnus-newsgroup-name)
9541 (error "The current newsgroup does not support article deletion"))
9542 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9543 (error "Couldn't open server"))
9544 ;; Compute the list of articles to delete.
9545 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9546 (nnmail-expiry-target 'delete)
9548 (if (and gnus-novice-user
9549 (not (gnus-yes-or-no-p
9550 (format "Do you really want to delete %s forever? "
9551 (if (> (length articles) 1)
9552 (format "these %s articles" (length articles))
9555 ;; Delete the articles.
9556 (setq not-deleted (gnus-request-expire-articles
9557 articles gnus-newsgroup-name 'force))
9559 (gnus-summary-remove-process-mark (car articles))
9560 ;; The backend might not have been able to delete the article
9562 (unless (memq (car articles) not-deleted)
9563 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9564 (let* ((article (car articles))
9565 (ghead (gnus-data-header
9566 (assoc article (gnus-data-list nil)))))
9567 (run-hook-with-args 'gnus-summary-article-delete-hook
9568 'delete ghead gnus-newsgroup-name nil
9570 (setq articles (cdr articles)))
9572 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9573 (gnus-summary-position-point)
9574 (gnus-set-mode-line 'summary)
9577 (defun gnus-summary-edit-article (&optional force)
9578 "Edit the current article.
9579 This will have permanent effect only in mail groups.
9580 If FORCE is non-nil, allow editing of articles even in read-only
9584 (set-buffer gnus-summary-buffer)
9585 (let ((mail-parse-charset gnus-newsgroup-charset)
9586 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9587 (gnus-set-global-variables)
9588 (when (and (not force)
9589 (gnus-group-read-only-p))
9590 (error "The current newsgroup does not support article editing"))
9591 (gnus-summary-show-article t)
9592 (gnus-article-edit-article
9594 `(lambda (no-highlight)
9595 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9596 (message-options message-options)
9597 (message-options-set-recipient)
9598 (mail-parse-ignored-charsets
9599 ',gnus-newsgroup-ignored-charsets))
9600 (gnus-summary-edit-article-done
9601 ,(or (mail-header-references gnus-current-headers) "")
9602 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9604 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9606 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9608 "Make edits to the current article permanent."
9611 ;; The buffer restriction contains the entire article if it exists.
9612 (when (article-goto-body)
9613 (let ((lines (count-lines (point) (point-max)))
9614 (length (- (point-max) (point)))
9615 (case-fold-search t)
9616 (body (copy-marker (point))))
9617 (goto-char (point-min))
9618 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9619 (delete-region (match-beginning 1) (match-end 1))
9620 (insert (number-to-string length)))
9621 (goto-char (point-min))
9622 (when (re-search-forward
9623 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9624 (delete-region (match-beginning 1) (match-end 1))
9625 (insert (number-to-string length)))
9626 (goto-char (point-min))
9627 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9628 (delete-region (match-beginning 1) (match-end 1))
9629 (insert (number-to-string lines))))))
9630 ;; Replace the article.
9631 (let ((buf (current-buffer)))
9633 (insert-buffer-substring buf)
9635 (if (and (not read-only)
9636 (not (gnus-request-replace-article
9637 (cdr gnus-article-current) (car gnus-article-current)
9638 (current-buffer) t)))
9639 (error "Couldn't replace article")
9640 ;; Update the summary buffer.
9642 (equal (message-tokenize-header references " ")
9643 (message-tokenize-header
9644 (or (message-fetch-field "references") "") " ")))
9645 ;; We only have to update this line.
9648 (message-narrow-to-head)
9649 (let ((head (buffer-string))
9652 (insert (format "211 %d Article retrieved.\n"
9653 (cdr gnus-article-current)))
9656 (let ((nntp-server-buffer (current-buffer)))
9657 (setq header (car (gnus-get-newsgroup-headers
9660 (set-buffer gnus-summary-buffer)
9661 (gnus-data-set-header
9662 (gnus-data-find (cdr gnus-article-current))
9664 (gnus-summary-update-article-line
9665 (cdr gnus-article-current) header)
9666 (if (gnus-summary-goto-subject
9667 (cdr gnus-article-current) nil t)
9668 (gnus-summary-update-secondary-mark
9669 (cdr gnus-article-current))))))))
9671 (set-buffer (or buffer gnus-summary-buffer))
9672 (gnus-summary-update-article (cdr gnus-article-current))
9673 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9674 (gnus-summary-update-secondary-mark
9675 (cdr gnus-article-current))))
9676 ;; Prettify the article buffer again.
9677 (unless no-highlight
9679 (set-buffer gnus-article-buffer)
9680 ;;;!!! Fix this -- article should be rehighlighted.
9681 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9682 (set-buffer gnus-original-article-buffer)
9683 (gnus-request-article
9684 (cdr gnus-article-current)
9685 (car gnus-article-current) (current-buffer))))
9686 ;; Prettify the summary buffer line.
9687 (when (gnus-visual-p 'summary-highlight 'highlight)
9688 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9690 (defun gnus-summary-edit-wash (key)
9691 "Perform editing command KEY in the article buffer."
9695 (message "%s" (concat (this-command-keys) "- "))
9698 (gnus-summary-edit-article)
9699 (execute-kbd-macro (concat (this-command-keys) key))
9700 (gnus-article-edit-done))
9704 (defun gnus-summary-respool-query (&optional silent trace)
9705 "Query where the respool algorithm would put this article."
9707 (let (gnus-mark-article-hook)
9708 (gnus-summary-select-article)
9710 (set-buffer gnus-original-article-buffer)
9711 (let ((groups (nnmail-article-group 'identity trace)))
9714 (message "This message would go to %s"
9715 (mapconcat 'car groups ", "))
9716 (message "This message would go to no groups"))
9719 (defun gnus-summary-respool-trace ()
9720 "Trace where the respool algorithm would put this article.
9721 Display a buffer showing all fancy splitting patterns which matched."
9723 (gnus-summary-respool-query nil t))
9725 ;; Summary marking commands.
9727 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9728 "Mark articles which has the same subject as read, and then select the next.
9729 If UNMARK is positive, remove any kind of mark.
9730 If UNMARK is negative, tick articles."
9733 (setq unmark (prefix-numeric-value unmark)))
9735 (gnus-summary-mark-same-subject
9736 (gnus-summary-article-subject) unmark)))
9737 ;; Select next unread article. If auto-select-same mode, should
9738 ;; select the first unread article.
9739 (gnus-summary-next-article t (and gnus-auto-select-same
9740 (gnus-summary-article-subject)))
9741 (gnus-message 7 "%d article%s marked as %s"
9742 count (if (= count 1) " is" "s are")
9743 (if unmark "unread" "read"))))
9745 (defun gnus-summary-kill-same-subject (&optional unmark)
9746 "Mark articles which has the same subject as read.
9747 If UNMARK is positive, remove any kind of mark.
9748 If UNMARK is negative, tick articles."
9751 (setq unmark (prefix-numeric-value unmark)))
9753 (gnus-summary-mark-same-subject
9754 (gnus-summary-article-subject) unmark)))
9755 ;; If marked as read, go to next unread subject.
9757 ;; Go to next unread subject.
9758 (gnus-summary-next-subject 1 t))
9759 (gnus-message 7 "%d articles are marked as %s"
9760 count (if unmark "unread" "read"))))
9762 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9763 "Mark articles with same SUBJECT as read, and return marked number.
9764 If optional argument UNMARK is positive, remove any kinds of marks.
9765 If optional argument UNMARK is negative, mark articles as unread instead."
9769 ((null unmark) ; Mark as read.
9772 (gnus-summary-mark-article-as-read gnus-killed-mark)
9773 (gnus-summary-show-thread) t)
9774 (gnus-summary-find-subject subject))
9775 (setq count (1+ count))))
9776 ((> unmark 0) ; Tick.
9779 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9780 (gnus-summary-show-thread) t)
9781 (gnus-summary-find-subject subject))
9782 (setq count (1+ count))))
9783 (t ; Mark as unread.
9786 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9787 (gnus-summary-show-thread) t)
9788 (gnus-summary-find-subject subject))
9789 (setq count (1+ count)))))
9790 (gnus-set-mode-line 'summary)
9791 ;; Return the number of marked articles.
9794 (defun gnus-summary-mark-as-processable (n &optional unmark)
9795 "Set the process mark on the next N articles.
9796 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9797 the process mark instead. The difference between N and the actual
9798 number of articles marked is returned."
9800 (if (and (null n) (gnus-region-active-p))
9801 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9802 (setq n (prefix-numeric-value n))
9803 (let ((backward (< n 0))
9808 (gnus-summary-remove-process-mark
9809 (gnus-summary-article-number))
9810 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9811 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9814 (gnus-message 7 "No more articles"))
9815 (gnus-summary-recenter)
9816 (gnus-summary-position-point)
9819 (defun gnus-summary-unmark-as-processable (n)
9820 "Remove the process mark from the next N articles.
9821 If N is negative, unmark backward instead. The difference between N and
9822 the actual number of articles unmarked is returned."
9824 (gnus-summary-mark-as-processable n t))
9826 (defun gnus-summary-unmark-all-processable ()
9827 "Remove the process mark from all articles."
9830 (while gnus-newsgroup-processable
9831 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9832 (gnus-summary-position-point))
9834 (defun gnus-summary-add-mark (article type)
9835 "Mark ARTICLE with a mark of TYPE."
9836 (let ((vtype (car (assq type gnus-article-mark-lists)))
9839 (error "No such mark type: %s" type)
9840 (setq var (intern (format "gnus-newsgroup-%s" type)))
9841 (set var (cons article (symbol-value var)))
9842 (if (memq type '(processable cached replied forwarded recent saved))
9843 (gnus-summary-update-secondary-mark article)
9844 ;;; !!! This is bogus. We should find out what primary
9845 ;;; !!! mark we want to set.
9846 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9848 (defun gnus-summary-mark-as-expirable (n)
9849 "Mark N articles forward as expirable.
9850 If N is negative, mark backward instead. The difference between N and
9851 the actual number of articles marked is returned."
9853 (gnus-summary-mark-forward n gnus-expirable-mark))
9855 (defun gnus-summary-mark-as-spam (n)
9856 "Mark N articles forward as spam.
9857 If N is negative, mark backward instead. The difference between N and
9858 the actual number of articles marked is returned."
9860 (gnus-summary-mark-forward n gnus-spam-mark))
9862 (defun gnus-summary-mark-article-as-replied (article)
9863 "Mark ARTICLE as replied to and update the summary line.
9864 ARTICLE can also be a list of articles."
9865 (interactive (list (gnus-summary-article-number)))
9866 (let ((articles (if (listp article) article (list article))))
9867 (dolist (article articles)
9868 (unless (numberp article)
9869 (error "%s is not a number" article))
9870 (push article gnus-newsgroup-replied)
9871 (let ((buffer-read-only nil))
9872 (when (gnus-summary-goto-subject article nil t)
9873 (gnus-summary-update-secondary-mark article))))))
9875 (defun gnus-summary-mark-article-as-forwarded (article)
9876 "Mark ARTICLE as forwarded and update the summary line.
9877 ARTICLE can also be a list of articles."
9878 (let ((articles (if (listp article) article (list article))))
9879 (dolist (article articles)
9880 (push article gnus-newsgroup-forwarded)
9881 (let ((buffer-read-only nil))
9882 (when (gnus-summary-goto-subject article nil t)
9883 (gnus-summary-update-secondary-mark article))))))
9885 (defun gnus-summary-set-bookmark (article)
9886 "Set a bookmark in current article."
9887 (interactive (list (gnus-summary-article-number)))
9888 (when (or (not (get-buffer gnus-article-buffer))
9889 (not gnus-current-article)
9890 (not gnus-article-current)
9891 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9892 (error "No current article selected"))
9893 ;; Remove old bookmark, if one exists.
9894 (gnus-pull article gnus-newsgroup-bookmarks)
9895 ;; Set the new bookmark, which is on the form
9896 ;; (article-number . line-number-in-body).
9899 (with-current-buffer gnus-article-buffer
9906 gnus-newsgroup-bookmarks)
9907 (gnus-message 6 "A bookmark has been added to the current article."))
9909 (defun gnus-summary-remove-bookmark (article)
9910 "Remove the bookmark from the current article."
9911 (interactive (list (gnus-summary-article-number)))
9912 ;; Remove old bookmark, if one exists.
9913 (if (not (assq article gnus-newsgroup-bookmarks))
9914 (gnus-message 6 "No bookmark in current article.")
9915 (gnus-pull article gnus-newsgroup-bookmarks)
9916 (gnus-message 6 "Removed bookmark.")))
9918 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9919 (defun gnus-summary-mark-as-dormant (n)
9920 "Mark N articles forward as dormant.
9921 If N is negative, mark backward instead. The difference between N and
9922 the actual number of articles marked is returned."
9924 (gnus-summary-mark-forward n gnus-dormant-mark))
9926 (defun gnus-summary-set-process-mark (article)
9927 "Set the process mark on ARTICLE and update the summary line."
9928 (setq gnus-newsgroup-processable
9930 (delq article gnus-newsgroup-processable)))
9931 (when (gnus-summary-goto-subject article)
9932 (gnus-summary-show-thread)
9933 (gnus-summary-goto-subject article)
9934 (gnus-summary-update-secondary-mark article)))
9936 (defun gnus-summary-remove-process-mark (article)
9937 "Remove the process mark from ARTICLE and update the summary line."
9938 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9939 (when (gnus-summary-goto-subject article)
9940 (gnus-summary-show-thread)
9941 (gnus-summary-goto-subject article)
9942 (gnus-summary-update-secondary-mark article)))
9944 (defun gnus-summary-set-saved-mark (article)
9945 "Set the process mark on ARTICLE and update the summary line."
9946 (push article gnus-newsgroup-saved)
9947 (when (gnus-summary-goto-subject article)
9948 (gnus-summary-update-secondary-mark article)))
9950 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9951 "Mark N articles as read forwards.
9952 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9953 The difference between N and the actual number of articles marked is
9955 If NO-EXPIRE, auto-expiry will be inhibited."
9957 (gnus-summary-show-thread)
9958 (let ((backward (< n 0))
9959 (gnus-summary-goto-unread
9960 (and gnus-summary-goto-unread
9961 (not (eq gnus-summary-goto-unread 'never))
9962 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9963 gnus-ticked-mark gnus-dormant-mark)))))
9965 (mark (or mark gnus-del-mark)))
9967 (gnus-summary-mark-article nil mark no-expire)
9968 (zerop (gnus-summary-next-subject
9970 (and gnus-summary-goto-unread
9971 (not (eq gnus-summary-goto-unread 'never)))
9975 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9976 (gnus-summary-recenter)
9977 (gnus-summary-position-point)
9978 (gnus-set-mode-line 'summary)
9981 (defun gnus-summary-mark-article-as-read (mark)
9982 "Mark the current article quickly as read with MARK."
9983 (let ((article (gnus-summary-article-number)))
9984 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9985 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9986 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9987 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9988 (push (cons article mark) gnus-newsgroup-reads)
9989 ;; Possibly remove from cache, if that is used.
9990 (when gnus-use-cache
9991 (gnus-cache-enter-remove-article article))
9992 ;; Allow the backend to change the mark.
9993 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9994 ;; Check for auto-expiry.
9995 (when (and gnus-newsgroup-auto-expire
9996 (memq mark gnus-auto-expirable-marks))
9997 (setq mark gnus-expirable-mark)
9998 ;; Let the backend know about the mark change.
9999 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10000 (push article gnus-newsgroup-expirable))
10001 ;; Set the mark in the buffer.
10002 (gnus-summary-update-mark mark 'unread)
10005 (defun gnus-summary-mark-article-as-unread (mark)
10006 "Mark the current article quickly as unread with MARK."
10007 (let* ((article (gnus-summary-article-number))
10008 (old-mark (gnus-summary-article-mark article)))
10009 ;; Allow the backend to change the mark.
10010 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10011 (if (eq mark old-mark)
10015 (gnus-error 1 "Can't mark negative article numbers")
10017 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10018 (setq gnus-newsgroup-spam-marked
10019 (delq article gnus-newsgroup-spam-marked))
10020 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10021 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10022 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10023 (cond ((= mark gnus-ticked-mark)
10024 (setq gnus-newsgroup-marked
10025 (gnus-add-to-sorted-list gnus-newsgroup-marked
10027 ((= mark gnus-spam-mark)
10028 (setq gnus-newsgroup-spam-marked
10029 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10031 ((= mark gnus-dormant-mark)
10032 (setq gnus-newsgroup-dormant
10033 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10036 (setq gnus-newsgroup-unreads
10037 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10039 (gnus-pull article gnus-newsgroup-reads)
10041 ;; See whether the article is to be put in the cache.
10042 (and gnus-use-cache
10043 (vectorp (gnus-summary-article-header article))
10045 (gnus-cache-possibly-enter-article
10046 gnus-newsgroup-name article
10047 (gnus-summary-article-header article)
10048 (= mark gnus-ticked-mark)
10049 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10052 (gnus-summary-update-mark mark 'unread)
10055 (defun gnus-summary-mark-article (&optional article mark no-expire)
10056 "Mark ARTICLE with MARK. MARK can be any character.
10057 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10058 `??' (dormant) and `?E' (expirable).
10059 If MARK is nil, then the default character `?r' is used.
10060 If ARTICLE is nil, then the article on the current line will be
10062 If NO-EXPIRE, auto-expiry will be inhibited."
10063 ;; The mark might be a string.
10064 (when (stringp mark)
10065 (setq mark (aref mark 0)))
10066 ;; If no mark is given, then we check auto-expiring.
10068 (setq mark gnus-del-mark))
10069 (when (and (not no-expire)
10070 gnus-newsgroup-auto-expire
10071 (memq mark gnus-auto-expirable-marks))
10072 (setq mark gnus-expirable-mark))
10073 (let ((article (or article (gnus-summary-article-number)))
10074 (old-mark (gnus-summary-article-mark article)))
10075 ;; Allow the backend to change the mark.
10076 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10077 (if (eq mark old-mark)
10080 (error "No article on current line"))
10081 (if (not (if (or (= mark gnus-unread-mark)
10082 (= mark gnus-ticked-mark)
10083 (= mark gnus-spam-mark)
10084 (= mark gnus-dormant-mark))
10085 (gnus-mark-article-as-unread article mark)
10086 (gnus-mark-article-as-read article mark)))
10088 ;; See whether the article is to be put in the cache.
10089 (and gnus-use-cache
10090 (not (= mark gnus-canceled-mark))
10091 (vectorp (gnus-summary-article-header article))
10093 (gnus-cache-possibly-enter-article
10094 gnus-newsgroup-name article
10095 (gnus-summary-article-header article)
10096 (= mark gnus-ticked-mark)
10097 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10099 (when (gnus-summary-goto-subject article nil t)
10100 (let ((buffer-read-only nil))
10101 (gnus-summary-show-thread)
10103 (gnus-summary-update-mark mark 'unread)
10106 (defun gnus-summary-update-secondary-mark (article)
10107 "Update the secondary (read, process, cache) mark."
10108 (gnus-summary-update-mark
10109 (cond ((memq article gnus-newsgroup-processable)
10111 ((memq article gnus-newsgroup-cached)
10113 ((memq article gnus-newsgroup-replied)
10115 ((memq article gnus-newsgroup-forwarded)
10116 gnus-forwarded-mark)
10117 ((memq article gnus-newsgroup-saved)
10119 ((memq article gnus-newsgroup-recent)
10121 ((memq article gnus-newsgroup-unseen)
10125 (when (gnus-visual-p 'summary-highlight 'highlight)
10126 (gnus-run-hooks 'gnus-summary-update-hook))
10129 (defun gnus-summary-update-download-mark (article)
10130 "Update the download mark."
10131 (gnus-summary-update-mark
10132 (cond ((memq article gnus-newsgroup-undownloaded)
10133 gnus-undownloaded-mark)
10134 (gnus-newsgroup-agentized
10135 gnus-downloaded-mark)
10139 (gnus-summary-update-line t)
10142 (defun gnus-summary-update-mark (mark type)
10143 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10144 (buffer-read-only nil))
10145 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10147 (when (looking-at "\r")
10149 (when (<= (+ forward (point)) (point-max))
10150 ;; Go to the right position on the line.
10151 (goto-char (+ forward (point)))
10152 ;; Replace the old mark with the new mark.
10153 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10154 ;; Optionally update the marks by some user rule.
10155 (when (eq type 'unread)
10156 (gnus-data-set-mark
10157 (gnus-data-find (gnus-summary-article-number)) mark)
10158 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10160 (defun gnus-mark-article-as-read (article &optional mark)
10161 "Enter ARTICLE in the pertinent lists and remove it from others."
10162 ;; Make the article expirable.
10163 (let ((mark (or mark gnus-del-mark)))
10164 (setq gnus-newsgroup-expirable
10165 (if (= mark gnus-expirable-mark)
10166 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10167 (delq article gnus-newsgroup-expirable)))
10168 ;; Remove from unread and marked lists.
10169 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10170 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10171 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10172 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10173 (push (cons article mark) gnus-newsgroup-reads)
10174 ;; Possibly remove from cache, if that is used.
10175 (when gnus-use-cache
10176 (gnus-cache-enter-remove-article article))
10179 (defun gnus-mark-article-as-unread (article &optional mark)
10180 "Enter ARTICLE in the pertinent lists and remove it from others."
10181 (let ((mark (or mark gnus-ticked-mark)))
10184 (gnus-error 1 "Can't mark negative article numbers")
10186 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10187 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10188 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10189 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10190 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10192 ;; Unsuppress duplicates?
10193 (when gnus-suppress-duplicates
10194 (gnus-dup-unsuppress-article article))
10196 (cond ((= mark gnus-ticked-mark)
10197 (setq gnus-newsgroup-marked
10198 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10199 ((= mark gnus-spam-mark)
10200 (setq gnus-newsgroup-spam-marked
10201 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10203 ((= mark gnus-dormant-mark)
10204 (setq gnus-newsgroup-dormant
10205 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10207 (setq gnus-newsgroup-unreads
10208 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10209 (gnus-pull article gnus-newsgroup-reads)
10212 (defalias 'gnus-summary-mark-as-unread-forward
10213 'gnus-summary-tick-article-forward)
10214 (make-obsolete 'gnus-summary-mark-as-unread-forward
10215 'gnus-summary-tick-article-forward)
10216 (defun gnus-summary-tick-article-forward (n)
10217 "Tick N articles forwards.
10218 If N is negative, tick backwards instead.
10219 The difference between N and the number of articles ticked is returned."
10221 (gnus-summary-mark-forward n gnus-ticked-mark))
10223 (defalias 'gnus-summary-mark-as-unread-backward
10224 'gnus-summary-tick-article-backward)
10225 (make-obsolete 'gnus-summary-mark-as-unread-backward
10226 'gnus-summary-tick-article-backward)
10227 (defun gnus-summary-tick-article-backward (n)
10228 "Tick N articles backwards.
10229 The difference between N and the number of articles ticked is returned."
10231 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10233 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10234 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10235 (defun gnus-summary-tick-article (&optional article clear-mark)
10236 "Mark current article as unread.
10237 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10238 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10240 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10241 gnus-ticked-mark)))
10243 (defun gnus-summary-mark-as-read-forward (n)
10244 "Mark N articles as read forwards.
10245 If N is negative, mark backwards instead.
10246 The difference between N and the actual number of articles marked is
10249 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10251 (defun gnus-summary-mark-as-read-backward (n)
10252 "Mark the N articles as read backwards.
10253 The difference between N and the actual number of articles marked is
10256 (gnus-summary-mark-forward
10257 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10259 (defun gnus-summary-mark-as-read (&optional article mark)
10260 "Mark current article as read.
10261 ARTICLE specifies the article to be marked as read.
10262 MARK specifies a string to be inserted at the beginning of the line."
10263 (gnus-summary-mark-article article mark))
10265 (defun gnus-summary-clear-mark-forward (n)
10266 "Clear marks from N articles forward.
10267 If N is negative, clear backward instead.
10268 The difference between N and the number of marks cleared is returned."
10270 (gnus-summary-mark-forward n gnus-unread-mark))
10272 (defun gnus-summary-clear-mark-backward (n)
10273 "Clear marks from N articles backward.
10274 The difference between N and the number of marks cleared is returned."
10276 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10278 (defun gnus-summary-mark-unread-as-read ()
10279 "Intended to be used by `gnus-summary-mark-article-hook'."
10280 (when (memq gnus-current-article gnus-newsgroup-unreads)
10281 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10283 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10284 "Intended to be used by `gnus-summary-mark-article-hook'."
10285 (let ((mark (gnus-summary-article-mark)))
10286 (when (or (gnus-unread-mark-p mark)
10287 (gnus-read-mark-p mark))
10288 (gnus-summary-mark-article gnus-current-article
10289 (or new-mark gnus-read-mark)))))
10291 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10292 "Intended to be used by `gnus-summary-mark-article-hook'."
10293 (let ((mark (gnus-summary-article-mark)))
10294 (when (or (gnus-unread-mark-p mark)
10295 (gnus-read-mark-p mark))
10296 (gnus-summary-mark-article (gnus-summary-article-number)
10297 (or new-mark gnus-read-mark)))))
10299 (defun gnus-summary-mark-unread-as-ticked ()
10300 "Intended to be used by `gnus-summary-mark-article-hook'."
10301 (when (memq gnus-current-article gnus-newsgroup-unreads)
10302 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10304 (defun gnus-summary-mark-region-as-read (point mark all)
10305 "Mark all unread articles between point and mark as read.
10306 If given a prefix, mark all articles between point and mark as read,
10307 even ticked and dormant ones."
10308 (interactive "r\nP")
10312 (beginning-of-line)
10317 (memq (setq article (gnus-summary-article-number))
10318 gnus-newsgroup-unreads))
10319 (gnus-summary-mark-article article gnus-del-mark))
10321 (gnus-summary-find-next))))))
10323 (defun gnus-summary-mark-below (score mark)
10324 "Mark articles with score less than SCORE with MARK."
10325 (interactive "P\ncMark: ")
10326 (setq score (if score
10327 (prefix-numeric-value score)
10328 (or gnus-summary-default-score 0)))
10330 (set-buffer gnus-summary-buffer)
10331 (goto-char (point-min))
10334 (and (< (gnus-summary-article-score) score)
10335 (gnus-summary-mark-article nil mark))
10336 (gnus-summary-find-next)))))
10338 (defun gnus-summary-kill-below (&optional score)
10339 "Mark articles with score below SCORE as read."
10341 (gnus-summary-mark-below score gnus-killed-mark))
10343 (defun gnus-summary-clear-above (&optional score)
10344 "Clear all marks from articles with score above SCORE."
10346 (gnus-summary-mark-above score gnus-unread-mark))
10348 (defun gnus-summary-tick-above (&optional score)
10349 "Tick all articles with score above SCORE."
10351 (gnus-summary-mark-above score gnus-ticked-mark))
10353 (defun gnus-summary-mark-above (score mark)
10354 "Mark articles with score over SCORE with MARK."
10355 (interactive "P\ncMark: ")
10356 (setq score (if score
10357 (prefix-numeric-value score)
10358 (or gnus-summary-default-score 0)))
10360 (set-buffer gnus-summary-buffer)
10361 (goto-char (point-min))
10363 (when (> (gnus-summary-article-score) score)
10364 (gnus-summary-mark-article nil mark))
10366 (gnus-summary-find-next)))))
10368 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10369 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10370 (defun gnus-summary-limit-include-expunged (&optional no-error)
10371 "Display all the hidden articles that were expunged for low scores."
10373 (let ((buffer-read-only nil))
10374 (let ((scored gnus-newsgroup-scored)
10377 (unless (gnus-summary-article-header (caar scored))
10378 (and (setq h (gnus-number-to-header (caar scored)))
10379 (< (cdar scored) gnus-summary-expunge-below)
10381 (setq scored (cdr scored)))
10383 (when (not no-error)
10384 (error "No expunged articles hidden"))
10385 (goto-char (point-min))
10386 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10387 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10388 (mapcar (lambda (x) (push (mail-header-number x)
10389 gnus-newsgroup-limit))
10391 (gnus-summary-prepare-unthreaded (nreverse headers))
10392 (goto-char (point-min))
10393 (gnus-summary-position-point)
10396 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10397 "Mark all unread articles in this newsgroup as read.
10398 If prefix argument ALL is non-nil, ticked and dormant articles will
10399 also be marked as read.
10400 If QUIETLY is non-nil, no questions will be asked.
10402 If TO-HERE is non-nil, it should be a point in the buffer. All
10403 articles before (after, if REVERSE is set) this point will be marked
10406 Note that this function will only catch up the unread article
10407 in the current summary buffer limitation.
10409 The number of articles marked as read is returned."
10414 (not gnus-interactive-catchup) ;Without confirmation?
10418 "Mark absolutely all articles as read? "
10419 "Mark all unread articles as read? ")))
10421 (not gnus-newsgroup-adaptive)
10422 (not gnus-newsgroup-auto-expire)
10423 (not gnus-suppress-duplicates)
10424 (or (not gnus-use-cache)
10425 (eq gnus-use-cache 'passive)))
10428 (setq gnus-newsgroup-marked nil
10429 gnus-newsgroup-spam-marked nil
10430 gnus-newsgroup-dormant nil))
10431 (setq gnus-newsgroup-unreads
10432 (gnus-sorted-nunion
10433 (gnus-intersection gnus-newsgroup-unreads
10434 gnus-newsgroup-downloadable)
10435 gnus-newsgroup-unfetched)))
10436 ;; We actually mark all articles as canceled, which we
10437 ;; have to do when using auto-expiry or adaptive scoring.
10438 (gnus-summary-show-all-threads)
10439 (if (and to-here reverse)
10441 (goto-char to-here)
10442 (gnus-summary-mark-current-read-and-unread-as-read
10444 (while (gnus-summary-find-next (not all))
10445 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10446 (when (gnus-summary-first-subject (not all))
10448 (if to-here (< (point) to-here) t)
10449 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10450 (gnus-summary-find-next (not all))))))
10451 (gnus-set-mode-line 'summary))
10453 (gnus-summary-position-point)))
10455 (defun gnus-summary-catchup-to-here (&optional all)
10456 "Mark all unticked articles before the current one as read.
10457 If ALL is non-nil, also mark ticked and dormant articles as read."
10460 (gnus-save-hidden-threads
10461 (let ((beg (point)))
10462 ;; We check that there are unread articles.
10463 (when (or all (gnus-summary-find-prev))
10464 (gnus-summary-catchup all t beg)))))
10465 (gnus-summary-position-point))
10467 (defun gnus-summary-catchup-from-here (&optional all)
10468 "Mark all unticked articles after (and including) the current one as read.
10469 If ALL is non-nil, also mark ticked and dormant articles as read."
10472 (gnus-save-hidden-threads
10473 (let ((beg (point)))
10474 ;; We check that there are unread articles.
10475 (when (or all (gnus-summary-find-next))
10476 (gnus-summary-catchup all t beg nil t)))))
10477 (gnus-summary-position-point))
10479 (defun gnus-summary-catchup-all (&optional quietly)
10480 "Mark all articles in this newsgroup as read.
10481 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10482 instead, which marks only unread articles as read."
10484 (gnus-summary-catchup t quietly))
10486 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10487 "Mark all unread articles in this group as read, then exit.
10488 If prefix argument ALL is non-nil, all articles are marked as read.
10489 If QUIETLY is non-nil, no questions will be asked."
10491 (when (gnus-summary-catchup all quietly nil 'fast)
10492 ;; Select next newsgroup or exit.
10493 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10494 (eq gnus-auto-select-next 'quietly))
10495 (gnus-summary-next-group nil)
10496 (gnus-summary-exit))))
10498 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10499 "Mark all articles in this newsgroup as read, and then exit.
10500 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10501 instead, which marks only unread articles as read."
10503 (gnus-summary-catchup-and-exit t quietly))
10505 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10506 "Mark all articles in this group as read and select the next group.
10507 If given a prefix, mark all articles, unread as well as ticked, as
10511 (gnus-summary-catchup all))
10512 (gnus-summary-next-group))
10518 (defmacro gnus-with-article (article &rest forms)
10519 "Select ARTICLE and perform FORMS in the original article buffer.
10520 Then replace the article with the result."
10522 ;; We don't want the article to be marked as read.
10523 (let (gnus-mark-article-hook)
10524 (gnus-summary-select-article t t nil ,article))
10525 (set-buffer gnus-original-article-buffer)
10527 (if (not (gnus-check-backend-function
10528 'request-replace-article (car gnus-article-current)))
10529 (gnus-message 5 "Read-only group; not replacing")
10530 (unless (gnus-request-replace-article
10531 ,article (car gnus-article-current)
10532 (current-buffer) t)
10533 (error "Couldn't replace article")))
10534 ;; The cache and backlog have to be flushed somewhat.
10535 (when gnus-keep-backlog
10536 (gnus-backlog-remove-article
10537 (car gnus-article-current) (cdr gnus-article-current)))
10538 (when gnus-use-cache
10539 (gnus-cache-update-article
10540 (car gnus-article-current) (cdr gnus-article-current)))))
10542 (put 'gnus-with-article 'lisp-indent-function 1)
10543 (put 'gnus-with-article 'edebug-form-spec '(form body))
10545 ;; Thread-based commands.
10547 (defun gnus-summary-articles-in-thread (&optional article)
10548 "Return a list of all articles in the current thread.
10549 If ARTICLE is non-nil, return all articles in the thread that starts
10550 with that article."
10551 (let* ((article (or article (gnus-summary-article-number)))
10552 (data (gnus-data-find-list article))
10553 (top-level (gnus-data-level (car data)))
10555 (cond ((null gnus-thread-operation-ignore-subject)
10556 (gnus-simplify-subject-re
10557 (mail-header-subject (gnus-data-header (car data)))))
10558 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10559 (gnus-simplify-subject-fuzzy
10560 (mail-header-subject (gnus-data-header (car data)))))
10562 (end-point (save-excursion
10563 (if (gnus-summary-go-to-next-thread)
10564 (point) (point-max))))
10567 (< (gnus-data-pos (car data)) end-point))
10568 (when (or (not top-subject)
10569 (string= top-subject
10570 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10571 (gnus-simplify-subject-fuzzy
10572 (mail-header-subject
10573 (gnus-data-header (car data))))
10574 (gnus-simplify-subject-re
10575 (mail-header-subject
10576 (gnus-data-header (car data)))))))
10577 (push (gnus-data-number (car data)) articles))
10578 (unless (and (setq data (cdr data))
10579 (> (gnus-data-level (car data)) top-level))
10581 ;; Return the list of articles.
10582 (nreverse articles)))
10584 (defun gnus-summary-rethread-current ()
10585 "Rethread the thread the current article is part of."
10587 (let* ((gnus-show-threads t)
10588 (article (gnus-summary-article-number))
10589 (id (mail-header-id (gnus-summary-article-header)))
10590 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10592 (error "No article on the current line"))
10593 (gnus-rebuild-thread id)
10594 (gnus-summary-goto-subject article)))
10596 (defun gnus-summary-reparent-thread ()
10597 "Make the current article child of the marked (or previous) article.
10599 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10600 is non-nil or the Subject: of both articles are the same."
10602 (unless (not (gnus-group-read-only-p))
10603 (error "The current newsgroup does not support article editing"))
10604 (unless (<= (length gnus-newsgroup-processable) 1)
10605 (error "No more than one article may be marked"))
10606 (save-window-excursion
10607 (let ((gnus-article-buffer " *reparent*")
10608 (current-article (gnus-summary-article-number))
10609 ;; First grab the marked article, otherwise one line up.
10610 (parent-article (if (not (null gnus-newsgroup-processable))
10611 (car gnus-newsgroup-processable)
10613 (if (eq (forward-line -1) 0)
10614 (gnus-summary-article-number)
10615 (error "Beginning of summary buffer"))))))
10616 (unless (not (eq current-article parent-article))
10617 (error "An article may not be self-referential"))
10618 (let ((message-id (mail-header-id
10619 (gnus-summary-article-header parent-article))))
10620 (unless (and message-id (not (equal message-id "")))
10621 (error "No message-id in desired parent"))
10622 (gnus-with-article current-article
10624 (goto-char (point-min))
10625 (message-narrow-to-head)
10626 (if (re-search-forward "^References: " nil t)
10628 (re-search-forward "^[^ \t]" nil t)
10631 (insert " " message-id))
10632 (insert "References: " message-id "\n"))))
10633 (set-buffer gnus-summary-buffer)
10634 (gnus-summary-unmark-all-processable)
10635 (gnus-summary-update-article current-article)
10636 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10637 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10638 (gnus-summary-rethread-current)
10639 (gnus-message 3 "Article %d is now the child of article %d"
10640 current-article parent-article)))))
10642 (defun gnus-summary-toggle-threads (&optional arg)
10643 "Toggle showing conversation threads.
10644 If ARG is positive number, turn showing conversation threads on."
10646 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10647 (setq gnus-show-threads
10648 (if (null arg) (not gnus-show-threads)
10649 (> (prefix-numeric-value arg) 0)))
10650 (gnus-summary-prepare)
10651 (gnus-summary-goto-subject current)
10652 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10653 (gnus-summary-position-point)))
10655 (defun gnus-summary-show-all-threads ()
10656 "Show all threads."
10659 (let ((buffer-read-only nil))
10660 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10661 (gnus-summary-position-point))
10663 (defun gnus-summary-show-thread ()
10664 "Show thread subtrees.
10665 Returns nil if no thread was there to be shown."
10667 (let ((buffer-read-only nil)
10669 (end (point-at-eol))
10670 ;; Leave point at bol
10671 (beg (progn (beginning-of-line) (point))))
10673 ;; Any hidden lines here?
10674 (search-forward "\r" end t)
10675 (subst-char-in-region beg end ?\^M ?\n t)
10677 (gnus-summary-position-point))))
10679 (defun gnus-summary-maybe-hide-threads ()
10680 "If requested, hide the threads that should be hidden."
10681 (when (and gnus-show-threads
10682 gnus-thread-hide-subtree)
10683 (gnus-summary-hide-all-threads
10684 (if (or (consp gnus-thread-hide-subtree)
10685 (functionp gnus-thread-hide-subtree))
10686 (gnus-make-predicate gnus-thread-hide-subtree)
10689 ;;; Hiding predicates.
10691 (defun gnus-article-unread-p (header)
10692 (memq (mail-header-number header) gnus-newsgroup-unreads))
10694 (defun gnus-article-unseen-p (header)
10695 (memq (mail-header-number header) gnus-newsgroup-unseen))
10697 (defun gnus-map-articles (predicate articles)
10698 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10699 (apply 'gnus-or (mapcar predicate
10700 (mapcar 'gnus-summary-article-header articles))))
10702 (defun gnus-summary-hide-all-threads (&optional predicate)
10703 "Hide all thread subtrees.
10704 If PREDICATE is supplied, threads that satisfy this predicate
10705 will not be hidden."
10708 (goto-char (point-min))
10711 (when (or (not predicate)
10713 predicate (gnus-summary-article-children)))
10714 (gnus-summary-hide-thread))
10715 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10716 (gnus-summary-position-point))
10718 (defun gnus-summary-hide-thread ()
10719 "Hide thread subtrees.
10720 If PREDICATE is supplied, threads that satisfy this predicate
10721 will not be hidden.
10722 Returns nil if no threads were there to be hidden."
10724 (let ((buffer-read-only nil)
10726 (article (gnus-summary-article-number)))
10728 ;; Go forward until either the buffer ends or the subthread
10730 (when (and (not (eobp))
10731 (or (zerop (gnus-summary-next-thread 1 t))
10732 (goto-char (point-max))))
10734 (if (and (> (point) start)
10735 (search-backward "\n" start t))
10737 (subst-char-in-region start (point) ?\n ?\^M)
10738 (gnus-summary-goto-subject article))
10742 (defun gnus-summary-go-to-next-thread (&optional previous)
10743 "Go to the same level (or less) next thread.
10744 If PREVIOUS is non-nil, go to previous thread instead.
10745 Return the article number moved to, or nil if moving was impossible."
10746 (let ((level (gnus-summary-thread-level))
10747 (way (if previous -1 1))
10750 (while (and (not (eobp))
10751 (< level (gnus-summary-thread-level)))
10752 (forward-line way))
10759 (gnus-summary-article-number)
10760 (goto-char beg)))))
10762 (defun gnus-summary-next-thread (n &optional silent)
10763 "Go to the same level next N'th thread.
10764 If N is negative, search backward instead.
10765 Returns the difference between N and the number of skips actually
10768 If SILENT, don't output messages."
10770 (let ((backward (< n 0))
10772 (while (and (> n 0)
10773 (gnus-summary-go-to-next-thread backward))
10776 (gnus-summary-position-point))
10777 (when (and (not silent) (/= 0 n))
10778 (gnus-message 7 "No more threads"))
10781 (defun gnus-summary-prev-thread (n)
10782 "Go to the same level previous N'th thread.
10783 Returns the difference between N and the number of skips actually
10786 (gnus-summary-next-thread (- n)))
10788 (defun gnus-summary-go-down-thread ()
10789 "Go down one level in the current thread."
10790 (let ((children (gnus-summary-article-children)))
10792 (gnus-summary-goto-subject (car children)))))
10794 (defun gnus-summary-go-up-thread ()
10795 "Go up one level in the current thread."
10796 (let ((parent (gnus-summary-article-parent)))
10798 (gnus-summary-goto-subject parent))))
10800 (defun gnus-summary-down-thread (n)
10801 "Go down thread N steps.
10802 If N is negative, go up instead.
10803 Returns the difference between N and how many steps down that were
10808 (while (and (> n 0)
10809 (if up (gnus-summary-go-up-thread)
10810 (gnus-summary-go-down-thread)))
10812 (gnus-summary-position-point)
10814 (gnus-message 7 "Can't go further"))
10817 (defun gnus-summary-up-thread (n)
10818 "Go up thread N steps.
10819 If N is negative, go down instead.
10820 Returns the difference between N and how many steps down that were
10823 (gnus-summary-down-thread (- n)))
10825 (defun gnus-summary-top-thread ()
10826 "Go to the top of the thread."
10828 (while (gnus-summary-go-up-thread))
10829 (gnus-summary-article-number))
10831 (defun gnus-summary-kill-thread (&optional unmark)
10832 "Mark articles under current thread as read.
10833 If the prefix argument is positive, remove any kinds of marks.
10834 If the prefix argument is negative, tick articles instead."
10837 (setq unmark (prefix-numeric-value unmark)))
10838 (let ((articles (gnus-summary-articles-in-thread)))
10840 ;; Expand the thread.
10841 (gnus-summary-show-thread)
10842 ;; Mark all the articles.
10844 (gnus-summary-goto-subject (car articles))
10845 (cond ((null unmark)
10846 (gnus-summary-mark-article-as-read gnus-killed-mark))
10848 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10850 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10851 (setq articles (cdr articles))))
10852 ;; Hide killed subtrees.
10854 gnus-thread-hide-killed
10855 (gnus-summary-hide-thread))
10856 ;; If marked as read, go to next unread subject.
10857 (when (null unmark)
10858 ;; Go to next unread subject.
10859 (gnus-summary-next-subject 1 t)))
10860 (gnus-set-mode-line 'summary))
10862 ;; Summary sorting commands
10864 (defun gnus-summary-sort-by-number (&optional reverse)
10865 "Sort the summary buffer by article number.
10866 Argument REVERSE means reverse order."
10868 (gnus-summary-sort 'number reverse))
10870 (defun gnus-summary-sort-by-random (&optional reverse)
10871 "Randomize the order in the summary buffer.
10872 Argument REVERSE means to randomize in reverse order."
10874 (gnus-summary-sort 'random reverse))
10876 (defun gnus-summary-sort-by-author (&optional reverse)
10877 "Sort the summary buffer by author name alphabetically.
10878 If `case-fold-search' is non-nil, case of letters is ignored.
10879 Argument REVERSE means reverse order."
10881 (gnus-summary-sort 'author reverse))
10883 (defun gnus-summary-sort-by-subject (&optional reverse)
10884 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10885 If `case-fold-search' is non-nil, case of letters is ignored.
10886 Argument REVERSE means reverse order."
10888 (gnus-summary-sort 'subject reverse))
10890 (defun gnus-summary-sort-by-date (&optional reverse)
10891 "Sort the summary buffer by date.
10892 Argument REVERSE means reverse order."
10894 (gnus-summary-sort 'date reverse))
10896 (defun gnus-summary-sort-by-score (&optional reverse)
10897 "Sort the summary buffer by score.
10898 Argument REVERSE means reverse order."
10900 (gnus-summary-sort 'score reverse))
10902 (defun gnus-summary-sort-by-lines (&optional reverse)
10903 "Sort the summary buffer by the number of lines.
10904 Argument REVERSE means reverse order."
10906 (gnus-summary-sort 'lines reverse))
10908 (defun gnus-summary-sort-by-chars (&optional reverse)
10909 "Sort the summary buffer by article length.
10910 Argument REVERSE means reverse order."
10912 (gnus-summary-sort 'chars reverse))
10914 (defun gnus-summary-sort-by-original (&optional reverse)
10915 "Sort the summary buffer using the default sorting method.
10916 Argument REVERSE means reverse order."
10918 (let* ((buffer-read-only)
10919 (gnus-summary-prepare-hook nil))
10920 ;; We do the sorting by regenerating the threads.
10921 (gnus-summary-prepare)
10922 ;; Hide subthreads if needed.
10923 (gnus-summary-maybe-hide-threads)))
10925 (defun gnus-summary-sort (predicate reverse)
10926 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10927 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10928 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10929 (gnus-thread-sort-functions
10934 (gnus-sort-gathered-threads-function
10935 gnus-thread-sort-functions)
10936 (gnus-article-sort-functions
10940 (,article t2 t1))))
10942 (gnus-summary-prepare-hook nil))
10943 ;; We do the sorting by regenerating the threads.
10944 (gnus-summary-prepare)
10945 ;; Hide subthreads if needed.
10946 (gnus-summary-maybe-hide-threads)))
10948 ;; Summary saving commands.
10950 (defun gnus-summary-save-article (&optional n not-saved)
10951 "Save the current article using the default saver function.
10952 If N is a positive number, save the N next articles.
10953 If N is a negative number, save the N previous articles.
10954 If N is nil and any articles have been marked with the process mark,
10955 save those articles instead.
10956 The variable `gnus-default-article-saver' specifies the saver function."
10958 (let* ((articles (gnus-summary-work-articles n))
10959 (save-buffer (save-excursion
10960 (nnheader-set-temp-buffer " *Gnus Save*")))
10961 (num (length articles))
10963 (dolist (article articles)
10964 (setq header (gnus-summary-article-header article))
10965 (if (not (vectorp header))
10966 ;; This is a pseudo-article.
10967 (if (assq 'name header)
10968 (gnus-copy-file (cdr (assq 'name header)))
10969 (gnus-message 1 "Article %d is unsaveable" article))
10970 ;; This is a real article.
10971 (save-window-excursion
10972 (let ((gnus-display-mime-function nil)
10973 (gnus-article-prepare-hook nil))
10974 (gnus-summary-select-article t nil nil article)))
10976 (set-buffer save-buffer)
10978 (insert-buffer-substring gnus-original-article-buffer))
10979 (setq file (gnus-article-save save-buffer file num))
10980 (gnus-summary-remove-process-mark article)
10982 (gnus-summary-set-saved-mark article))))
10983 (gnus-kill-buffer save-buffer)
10984 (gnus-summary-position-point)
10985 (gnus-set-mode-line 'summary)
10988 (defun gnus-summary-pipe-output (&optional arg headers)
10989 "Pipe the current article to a subprocess.
10990 If N is a positive number, pipe the N next articles.
10991 If N is a negative number, pipe the N previous articles.
10992 If N is nil and any articles have been marked with the process mark,
10993 pipe those articles instead.
10994 If HEADERS (the symbolic prefix), include the headers, too."
10995 (interactive (gnus-interactive "P\ny"))
10996 (require 'gnus-art)
10997 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10998 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10999 (gnus-summary-save-article arg t))
11000 (let ((buffer (get-buffer "*Shell Command Output*")))
11002 (not (zerop (buffer-size buffer))))
11003 (gnus-configure-windows 'pipe))))
11005 (defun gnus-summary-save-article-mail (&optional arg)
11006 "Append the current article to an mail file.
11007 If N is a positive number, save the N next articles.
11008 If N is a negative number, save the N previous articles.
11009 If N is nil and any articles have been marked with the process mark,
11010 save those articles instead."
11012 (require 'gnus-art)
11013 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11014 (gnus-summary-save-article arg)))
11016 (defun gnus-summary-save-article-rmail (&optional arg)
11017 "Append the current article to an rmail file.
11018 If N is a positive number, save the N next articles.
11019 If N is a negative number, save the N previous articles.
11020 If N is nil and any articles have been marked with the process mark,
11021 save those articles instead."
11023 (require 'gnus-art)
11024 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11025 (gnus-summary-save-article arg)))
11027 (defun gnus-summary-save-article-file (&optional arg)
11028 "Append the current article to a file.
11029 If N is a positive number, save the N next articles.
11030 If N is a negative number, save the N previous articles.
11031 If N is nil and any articles have been marked with the process mark,
11032 save those articles instead."
11034 (require 'gnus-art)
11035 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11036 (gnus-summary-save-article arg)))
11038 (defun gnus-summary-write-article-file (&optional arg)
11039 "Write the current article to a file, deleting the previous file.
11040 If N is a positive number, save the N next articles.
11041 If N is a negative number, save the N previous articles.
11042 If N is nil and any articles have been marked with the process mark,
11043 save those articles instead."
11045 (require 'gnus-art)
11046 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11047 (gnus-summary-save-article arg)))
11049 (defun gnus-summary-save-article-body-file (&optional arg)
11050 "Append the current article body to a file.
11051 If N is a positive number, save the N next articles.
11052 If N is a negative number, save the N previous articles.
11053 If N is nil and any articles have been marked with the process mark,
11054 save those articles instead."
11056 (require 'gnus-art)
11057 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11058 (gnus-summary-save-article arg)))
11060 (defun gnus-summary-muttprint (&optional arg)
11061 "Print the current article using Muttprint.
11062 If N is a positive number, save the N next articles.
11063 If N is a negative number, save the N previous articles.
11064 If N is nil and any articles have been marked with the process mark,
11065 save those articles instead."
11067 (require 'gnus-art)
11068 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11069 (gnus-summary-save-article arg t)))
11071 (defun gnus-summary-pipe-message (program)
11072 "Pipe the current article through PROGRAM."
11073 (interactive "sProgram: ")
11074 (gnus-summary-select-article)
11075 (let ((mail-header-separator ""))
11076 (gnus-eval-in-buffer-window gnus-article-buffer
11079 (let ((start (window-start))
11081 (message-pipe-buffer-body program)
11082 (set-window-start (get-buffer-window (current-buffer)) start))))))
11084 (defun gnus-get-split-value (methods)
11085 "Return a value based on the split METHODS."
11086 (let (split-name method result match)
11089 (set-buffer gnus-original-article-buffer)
11091 (nnheader-narrow-to-headers)
11092 (while (and methods (not split-name))
11093 (goto-char (point-min))
11094 (setq method (pop methods))
11095 (setq match (car method))
11098 ;; Regular expression.
11100 (re-search-forward match nil t)))
11105 (setq result (funcall match gnus-newsgroup-name))))
11110 (setq result (eval match)))))
11111 (setq split-name (cdr method))
11112 (cond ((stringp result)
11113 (push (expand-file-name
11114 result gnus-article-save-directory)
11117 (setq split-name (append result split-name)))))))))
11118 (nreverse split-name)))
11120 (defun gnus-valid-move-group-p (group)
11121 (and (boundp group)
11122 (symbol-name group)
11123 (symbol-value group)
11124 (gnus-get-function (gnus-find-method-for-group
11125 (symbol-name group)) 'request-accept-article t)))
11127 (defun gnus-read-move-group-name (prompt default articles prefix)
11128 "Read a group name."
11129 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11130 (minibuffer-confirm-incomplete nil) ; XEmacs
11132 (format "%s %s to:"
11134 (if (> (length articles) 1)
11135 (format "these %d articles" (length articles))
11140 (gnus-completing-read-with-default
11143 'gnus-valid-move-group-p
11145 'gnus-group-history))
11146 ((= 1 (length split-name))
11147 (gnus-completing-read-with-default
11148 (car split-name) prom
11150 'gnus-valid-move-group-p
11152 'gnus-group-history))
11154 (gnus-completing-read-with-default
11156 (mapcar 'list (nreverse split-name))
11158 'gnus-group-history))))
11159 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11161 (if (or (string= to-newsgroup "")
11162 (string= to-newsgroup prefix))
11163 (setq to-newsgroup default))
11164 (unless to-newsgroup
11165 (error "No group name entered"))
11166 (or (gnus-active to-newsgroup)
11167 (gnus-activate-group to-newsgroup nil nil to-method)
11168 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11170 (or (and (gnus-request-create-group to-newsgroup to-method)
11171 (gnus-activate-group
11172 to-newsgroup nil nil to-method)
11173 (gnus-subscribe-group to-newsgroup))
11174 (error "Couldn't create group %s" to-newsgroup)))
11175 (error "No such group: %s" to-newsgroup)))
11178 (defun gnus-summary-save-parts (type dir n &optional reverse)
11179 "Save parts matching TYPE to DIR.
11180 If REVERSE, save parts that do not match TYPE."
11182 (list (read-string "Save parts of type: "
11183 (or (car gnus-summary-save-parts-type-history)
11184 gnus-summary-save-parts-default-mime)
11185 'gnus-summary-save-parts-type-history)
11186 (setq gnus-summary-save-parts-last-directory
11187 (read-file-name "Save to directory: "
11188 gnus-summary-save-parts-last-directory
11190 current-prefix-arg))
11191 (gnus-summary-iterate n
11192 (let ((gnus-display-mime-function nil)
11193 (gnus-inhibit-treatment t))
11194 (gnus-summary-select-article))
11196 (set-buffer gnus-article-buffer)
11197 (let ((handles (or gnus-article-mime-handles
11198 (mm-dissect-buffer nil gnus-article-loose-mime)
11199 (and gnus-article-emulate-mime
11200 (mm-uu-dissect)))))
11202 (gnus-summary-save-parts-1 type dir handles reverse)
11203 (unless gnus-article-mime-handles ;; Don't destroy this case.
11204 (mm-destroy-parts handles)))))))
11206 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11207 (if (stringp (car handle))
11208 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11211 (not (string-match type (mm-handle-media-type handle)))
11212 (string-match type (mm-handle-media-type handle)))
11213 (let ((file (expand-file-name
11215 mm-file-name-rewrite-functions
11216 (file-name-nondirectory
11218 (mail-content-type-get
11219 (mm-handle-disposition handle) 'filename)
11220 (mail-content-type-get
11221 (mm-handle-type handle) 'name)
11222 (concat gnus-newsgroup-name
11223 "." (number-to-string
11224 (cdr gnus-article-current))))))
11226 (unless (file-exists-p file)
11227 (mm-save-part-to-file handle file))))))
11229 ;; Summary extract commands
11231 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11232 (let ((buffer-read-only nil)
11233 (article (gnus-summary-article-number))
11235 (unless (gnus-summary-goto-subject article)
11236 (error "No such article: %d" article))
11237 (gnus-summary-position-point)
11238 ;; If all commands are to be bunched up on one line, we collect
11240 (unless gnus-view-pseudos-separately
11241 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11244 (setq action (cdr (assq 'action (car ps))))
11245 (setq files (list (cdr (assq 'name (car ps)))))
11246 (while (and ps (cdr ps)
11247 (string= (or action "1")
11248 (or (cdr (assq 'action (cadr ps))) "2")))
11249 (push (cdr (assq 'name (cadr ps))) files)
11250 (setcdr ps (cddr ps)))
11252 (when (not (string-match "%s" action))
11255 (when (assq 'execute (car ps))
11256 (setcdr (assq 'execute (car ps))
11257 (funcall (if (string-match "%s" action)
11264 (shell-quote-argument f)))
11266 (setq ps (cdr ps)))))
11267 (if (and gnus-view-pseudos (not not-view))
11269 (when (assq 'execute (car pslist))
11270 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11271 (eq gnus-view-pseudos 'not-confirm)))
11272 (setq pslist (cdr pslist)))
11275 (setq after-article (or (cdr (assq 'article (car pslist)))
11276 (gnus-summary-article-number)))
11277 (gnus-summary-goto-subject after-article)
11280 (insert " " (file-name-nondirectory
11281 (cdr (assq 'name (car pslist))))
11282 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11284 (forward-line -1) ; back to `b'
11285 (gnus-add-text-properties
11286 b (1- e) (list 'gnus-number gnus-reffed-article-number
11287 gnus-mouse-face-prop gnus-mouse-face))
11289 after-article gnus-reffed-article-number
11290 gnus-unread-mark b (car pslist) 0 (- e b))
11291 (setq gnus-newsgroup-unreads
11292 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11293 gnus-reffed-article-number))
11294 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11295 (setq pslist (cdr pslist)))))))
11297 (defun gnus-pseudos< (p1 p2)
11298 (let ((c1 (cdr (assq 'action p1)))
11299 (c2 (cdr (assq 'action p2))))
11300 (and c1 c2 (string< c1 c2))))
11302 (defun gnus-request-pseudo-article (props)
11303 (cond ((assq 'execute props)
11304 (gnus-execute-command (cdr (assq 'execute props)))))
11305 (let ((gnus-current-article (gnus-summary-article-number)))
11306 (gnus-run-hooks 'gnus-mark-article-hook)))
11308 (defun gnus-execute-command (command &optional automatic)
11310 (gnus-article-setup-buffer)
11311 (set-buffer gnus-article-buffer)
11312 (setq buffer-read-only nil)
11313 (let ((command (if automatic command
11314 (read-string "Command: " (cons command 0)))))
11316 (insert "$ " command "\n\n")
11317 (if gnus-view-pseudo-asynchronously
11318 (start-process "gnus-execute" (current-buffer) shell-file-name
11319 shell-command-switch command)
11320 (call-process shell-file-name nil t nil
11321 shell-command-switch command)))))
11323 ;; Summary kill commands.
11325 (defun gnus-summary-edit-global-kill (article)
11326 "Edit the \"global\" kill file."
11327 (interactive (list (gnus-summary-article-number)))
11328 (gnus-group-edit-global-kill article))
11330 (defun gnus-summary-edit-local-kill ()
11331 "Edit a local kill file applied to the current newsgroup."
11333 (setq gnus-current-headers (gnus-summary-article-header))
11334 (gnus-group-edit-local-kill
11335 (gnus-summary-article-number) gnus-newsgroup-name))
11337 ;;; Header reading.
11339 (defun gnus-read-header (id &optional header)
11340 "Read the headers of article ID and enter them into the Gnus system."
11341 (let ((group gnus-newsgroup-name)
11342 (gnus-override-method
11344 gnus-override-method
11345 (and (gnus-news-group-p gnus-newsgroup-name)
11346 (car (gnus-refer-article-methods)))))
11348 ;; First we check to see whether the header in question is already
11351 ;; This is a Message-ID.
11352 (setq header (or header (gnus-id-to-header id)))
11353 ;; This is an article number.
11354 (setq header (or header (gnus-summary-article-header id))))
11356 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11357 ;; We have found the header.
11359 ;; We have to really fetch the header to this article.
11361 (set-buffer nntp-server-buffer)
11362 (when (setq where (gnus-request-head id group))
11363 (nnheader-fold-continuation-lines)
11364 (goto-char (point-max))
11366 (goto-char (point-min))
11370 ((cdr where) (cdr where))
11371 (header (mail-header-number header))
11372 (t gnus-reffed-article-number))
11374 (insert " Article retrieved.\n"))
11375 (if (or (not where)
11376 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11377 () ; Malformed head.
11378 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11379 (when (and (stringp id)
11380 (not (string= (gnus-group-real-name group)
11382 ;; If we fetched by Message-ID and the article came
11383 ;; from a different group, we fudge some bogus article
11384 ;; numbers for this article.
11385 (mail-header-set-number header gnus-reffed-article-number))
11387 (set-buffer gnus-summary-buffer)
11388 (decf gnus-reffed-article-number)
11389 (gnus-remove-header (mail-header-number header))
11390 (push header gnus-newsgroup-headers)
11391 (setq gnus-current-headers header)
11392 (push (mail-header-number header) gnus-newsgroup-limit)))
11395 (defun gnus-remove-header (number)
11396 "Remove header NUMBER from `gnus-newsgroup-headers'."
11397 (if (and gnus-newsgroup-headers
11398 (= number (mail-header-number (car gnus-newsgroup-headers))))
11399 (pop gnus-newsgroup-headers)
11400 (let ((headers gnus-newsgroup-headers))
11401 (while (and (cdr headers)
11402 (not (= number (mail-header-number (cadr headers)))))
11404 (when (cdr headers)
11405 (setcdr headers (cddr headers))))))
11408 ;;; summary highlights
11411 (defun gnus-highlight-selected-summary ()
11412 "Highlight selected article in summary buffer."
11413 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11414 (when gnus-summary-selected-face
11416 (let* ((beg (point-at-bol))
11417 (end (point-at-eol))
11418 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11419 (from (if (get-text-property beg gnus-mouse-face-prop)
11421 (or (next-single-property-change
11422 beg gnus-mouse-face-prop nil end)
11427 (or (next-single-property-change
11428 from gnus-mouse-face-prop nil end)
11430 ;; If no mouse-face prop on line we will have to = from = end,
11431 ;; so we highlight the entire line instead.
11432 (when (= (+ to 2) from)
11435 (if gnus-newsgroup-selected-overlay
11436 ;; Move old overlay.
11438 gnus-newsgroup-selected-overlay from to (current-buffer))
11439 ;; Create new overlay.
11441 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11442 'face gnus-summary-selected-face))))))
11444 (defvar gnus-summary-highlight-line-cached nil)
11445 (defvar gnus-summary-highlight-line-trigger nil)
11447 (defun gnus-summary-highlight-line-0 ()
11448 (if (and (eq gnus-summary-highlight-line-trigger
11449 gnus-summary-highlight)
11450 gnus-summary-highlight-line-cached)
11451 gnus-summary-highlight-line-cached
11452 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11453 gnus-summary-highlight-line-cached
11454 (let* ((cond (list 'cond))
11456 (list gnus-summary-highlight))
11458 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11462 (gnus-byte-compile (list 'lambda nil cond))))))
11464 (defun gnus-summary-highlight-line ()
11465 "Highlight current line according to `gnus-summary-highlight'."
11466 (let* ((beg (point-at-bol))
11467 (article (or (gnus-summary-article-number) gnus-current-article))
11468 (score (or (cdr (assq article
11469 gnus-newsgroup-scored))
11470 gnus-summary-default-score 0))
11471 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11472 (inhibit-read-only t)
11473 (default gnus-summary-default-score)
11474 (default-high gnus-summary-default-high-score)
11475 (default-low gnus-summary-default-low-score)
11476 (uncached (and gnus-summary-use-undownloaded-faces
11477 (memq article gnus-newsgroup-undownloaded)
11478 (not (memq article gnus-newsgroup-cached)))))
11479 (let ((face (funcall (gnus-summary-highlight-line-0))))
11480 (unless (eq face (get-text-property beg 'face))
11481 (gnus-put-text-property-excluding-characters-with-faces
11482 beg (point-at-eol) 'face
11483 (setq face (if (boundp face) (symbol-value face) face)))
11484 (when gnus-summary-highlight-line-function
11485 (funcall gnus-summary-highlight-line-function article face))))))
11487 (defun gnus-update-read-articles (group unread &optional compute)
11488 "Update the list of read articles in GROUP.
11489 UNREAD is a sorted list."
11490 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11491 (info (gnus-get-info group))
11494 (if (or (not info) (not active))
11495 ;; There is no info on this group if it was, in fact,
11496 ;; killed. Gnus stores no information on killed groups, so
11497 ;; there's nothing to be done.
11498 ;; One could store the information somewhere temporarily,
11499 ;; perhaps... Hmmm...
11501 ;; Remove any negative articles numbers.
11502 (while (and unread (< (car unread) 0))
11503 (setq unread (cdr unread)))
11504 ;; Remove any expired article numbers
11505 (while (and unread (< (car unread) (car active)))
11506 (setq unread (cdr unread)))
11507 ;; Compute the ranges of read articles by looking at the list of
11508 ;; unread articles.
11510 (when (/= (car unread) prev)
11511 (push (if (= prev (1- (car unread))) prev
11512 (cons prev (1- (car unread))))
11514 (setq prev (1+ (car unread)))
11515 (setq unread (cdr unread)))
11516 (when (<= prev (cdr active))
11517 (push (cons prev (cdr active)) read))
11518 (setq read (if (> (length read) 1) (nreverse read) read))
11523 ;; Propagate the read marks to the backend.
11524 (when (gnus-check-backend-function 'request-set-mark group)
11525 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11526 (add (gnus-remove-from-range read (gnus-info-read info))))
11528 (unless (gnus-check-group group)
11529 (error "Can't open server for %s" group))
11530 (gnus-request-set-mark
11531 group (delq nil (list (if add (list add 'add '(read)))
11532 (if del (list del 'del '(read))))))
11534 `(gnus-request-set-mark
11537 (if del (list del 'add '(read)))
11538 (if add (list add 'del '(read))))))))))
11539 (set-buffer gnus-group-buffer)
11540 (gnus-undo-register
11542 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11543 (gnus-info-set-read ',info ',(gnus-info-read info))
11544 (gnus-get-unread-articles-in-group ',info
11545 (gnus-active ,group))
11546 (gnus-group-update-group ,group t)
11548 ;; Enter this list into the group info.
11549 (gnus-info-set-read info read)
11550 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11551 (gnus-get-unread-articles-in-group info (gnus-active group))
11554 (defun gnus-offer-save-summaries ()
11555 "Offer to save all active summary buffers."
11557 ;; Go through all buffers and find all summaries.
11558 (dolist (buffer (buffer-list))
11559 (when (and (setq buffer (buffer-name buffer))
11560 (string-match "Summary" buffer)
11561 (with-current-buffer buffer
11562 ;; We check that this is, indeed, a summary buffer.
11563 (and (eq major-mode 'gnus-summary-mode)
11564 ;; Also make sure this isn't bogus.
11565 gnus-newsgroup-prepared
11566 ;; Also make sure that this isn't a
11567 ;; dead summary buffer.
11568 (not gnus-dead-summary-mode))))
11569 (push buffer buffers)))
11570 ;; Go through all these summary buffers and offer to save them.
11574 "Update summary buffer %s? "
11576 (switch-to-buffer buf)
11577 (gnus-summary-exit))
11581 ;;; @ for mime-partial
11584 (defun gnus-request-partial-message ()
11586 (let ((number (gnus-summary-article-number))
11587 (group gnus-newsgroup-name)
11588 (mother gnus-article-buffer))
11589 (set-buffer (get-buffer-create " *Partial Article*"))
11591 (setq mime-preview-buffer mother)
11592 (gnus-request-article-this-buffer number group)
11593 (mime-parse-buffer)
11596 (autoload 'mime-combine-message/partial-pieces-automatically
11598 "Internal method to combine message/partial messages automatically.")
11600 (mime-add-condition
11601 'action '((type . message)(subtype . partial)
11602 (major-mode . gnus-original-article-mode)
11603 (method . mime-combine-message/partial-pieces-automatically)
11604 (summary-buffer-exp . gnus-summary-buffer)
11605 (request-partial-message-method . gnus-request-partial-message)
11609 ;;; @ for message/rfc822
11612 (defun gnus-mime-extract-message/rfc822 (entity situation)
11613 "Burst a forwarded article."
11615 (set-buffer gnus-summary-buffer)
11616 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11617 gnus-newsgroup-name 'gnus-group-history))
11618 (gnus-group-marked (list group))
11621 (mime-insert-entity-content entity)
11622 (setq article (gnus-request-accept-article group)))
11623 (when (and (consp article)
11624 (numberp (setq article (cdr article))))
11625 (setq info (gnus-get-info group))
11626 (gnus-info-set-read info
11627 (gnus-remove-from-range (gnus-info-read info)
11629 (when (string-equal group gnus-newsgroup-name)
11631 (let (gnus-show-threads)
11632 (gnus-summary-goto-subject article t))
11633 (gnus-summary-clear-mark-forward 1))
11634 (set-buffer gnus-group-buffer)
11635 (gnus-group-get-new-news-this-group nil t)))))
11637 (mime-add-condition
11638 'action '((type . message)(subtype . rfc822)
11639 (major-mode . gnus-original-article-mode)
11640 (method . gnus-mime-extract-message/rfc822)
11644 (mime-add-condition
11645 'action '((type . message)(subtype . news)
11646 (major-mode . gnus-original-article-mode)
11647 (method . gnus-mime-extract-message/rfc822)
11651 (defun gnus-mime-extract-multipart (entity situation)
11652 (let ((children (mime-entity-children entity))
11653 mime-acting-situation-to-override
11656 (mime-play-entity (car children)
11657 (cons (assq 'mode situation)
11658 mime-acting-situation-to-override))
11659 (setq children (cdr children)))
11660 (if (setq f (cdr (assq 'after-method
11661 mime-acting-situation-to-override)))
11665 (mime-add-condition
11666 'action '((type . multipart)
11667 (method . gnus-mime-extract-multipart)
11676 (defun gnus-summary-inherit-default-charset ()
11677 "Import `default-mime-charset' from summary buffer.
11678 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11680 (if (buffer-live-p gnus-summary-buffer)
11681 (let (d-m-c d-m-c-u)
11682 (with-current-buffer gnus-summary-buffer
11683 (setq d-m-c (if (local-variable-p 'default-mime-charset
11684 gnus-summary-buffer)
11685 default-mime-charset
11688 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11689 gnus-summary-buffer)
11690 (symbol-value 'default-mime-charset-unlimited)
11693 (kill-local-variable 'default-mime-charset)
11694 (set (make-local-variable 'default-mime-charset) d-m-c))
11696 (kill-local-variable 'default-mime-charset-unlimited)
11697 (set (make-local-variable 'default-mime-charset-unlimited)
11700 (defun gnus-summary-setup-default-charset ()
11701 "Setup newsgroup default charset."
11702 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11704 (setq gnus-newsgroup-charset nil)
11705 (set (make-local-variable 'default-mime-charset) nil)
11706 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11707 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11708 (let ((ignored-charsets
11709 (or gnus-newsgroup-ephemeral-ignored-charsets
11711 (and gnus-newsgroup-name
11712 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11713 gnus-newsgroup-ignored-charsets)))
11715 (setq gnus-newsgroup-charset
11716 (or gnus-newsgroup-ephemeral-charset
11717 (when (and gnus-newsgroup-name
11718 (setq charset (gnus-parameter-charset
11719 gnus-newsgroup-name)))
11720 (make-local-variable 'default-mime-charset)
11721 (setq default-mime-charset charset))
11722 gnus-default-charset))
11723 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11724 ignored-charsets))))
11730 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11731 "Display the current article buffer fully MIME-buttonized.
11732 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11733 treated as multipart/mixed."
11735 (require 'gnus-art)
11736 (let ((gnus-unbuttonized-mime-types nil)
11737 (gnus-mime-display-multipart-as-mixed show-all-parts))
11738 (gnus-summary-show-article)))
11740 (defun gnus-summary-repair-multipart (article)
11741 "Add a Content-Type header to a multipart article without one."
11742 (interactive (list (gnus-summary-article-number)))
11743 (gnus-with-article article
11744 (message-narrow-to-head)
11745 (message-remove-header "Mime-Version")
11746 (goto-char (point-max))
11747 (insert "Mime-Version: 1.0\n")
11749 (when (search-forward "\n--" nil t)
11750 (let ((separator (buffer-substring (point) (point-at-eol))))
11751 (message-narrow-to-head)
11752 (message-remove-header "Content-Type")
11753 (goto-char (point-max))
11754 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11757 (let (gnus-mark-article-hook)
11758 (gnus-summary-select-article t t nil article)))
11760 (defun gnus-summary-toggle-display-buttonized ()
11761 "Toggle the buttonizing of the article buffer."
11763 (require 'gnus-art)
11764 (if (setq gnus-inhibit-mime-unbuttonizing
11765 (not gnus-inhibit-mime-unbuttonizing))
11766 (let ((gnus-unbuttonized-mime-types nil))
11767 (gnus-summary-show-article))
11768 (gnus-summary-show-article)))
11771 ;;; Intelli-mouse commmands
11774 (defun gnus-wheel-summary-scroll (event)
11776 (let ((amount (if (memq 'shift (event-modifiers event))
11777 (car gnus-wheel-scroll-amount)
11778 (cdr gnus-wheel-scroll-amount)))
11779 (direction (- (* (static-if (featurep 'xemacs)
11780 (event-button event)
11781 (cond ((eq 'mouse-4 (event-basic-type event))
11783 ((eq 'mouse-5 (event-basic-type event))
11787 (gnus-summary-scroll-up (* amount direction))
11788 (when (gnus-eval-in-buffer-window gnus-article-buffer
11791 (and (if (< 0 direction)
11792 (gnus-article-next-page 0)
11793 (gnus-article-prev-page 0)
11795 (if (setq edge (get-text-property
11796 (point-min) 'gnus-wheel-edge))
11797 (setq edge (* edge direction))
11800 (let ((buffer-read-only nil)
11801 (inhibit-read-only t))
11802 (put-text-property (point-min) (point-max)
11803 'gnus-wheel-edge direction)
11805 (or (> edge gnus-wheel-edge-resistance)
11806 (let ((buffer-read-only nil)
11807 (inhibit-read-only t))
11808 (put-text-property (point-min) (point-max)
11810 (* (1+ edge) direction))
11812 (eq last-command 'gnus-wheel-summary-scroll))))
11813 (gnus-summary-next-article nil nil (minusp direction)))))
11815 (defun gnus-wheel-install ()
11816 "Enable mouse wheel support on summary window."
11817 (when gnus-use-wheel
11819 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11821 (define-key gnus-summary-mode-map key
11822 'gnus-wheel-summary-scroll)))))
11824 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11827 ;;; Traditional PGP commmands
11830 (defun gnus-summary-decrypt-article (&optional force)
11831 "Decrypt the current article in traditional PGP way.
11832 This will have permanent effect only in mail groups.
11833 If FORCE is non-nil, allow editing of articles even in read-only
11836 (gnus-summary-select-article t)
11837 (gnus-eval-in-buffer-window gnus-article-buffer
11841 (goto-char (point-min))
11842 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11843 (error "Not a traditional PGP message!"))
11844 (let ((armor-start (match-beginning 0)))
11845 (if (and (pgg-decrypt-region armor-start (point-max))
11846 (or force (not (gnus-group-read-only-p))))
11847 (let ((inhibit-read-only t)
11849 (delete-region armor-start
11851 (re-search-forward "^-+END PGP" nil t)
11852 (beginning-of-line 2)
11854 (insert-buffer-substring pgg-output-buffer))))))))
11856 (defun gnus-summary-verify-article ()
11857 "Verify the current article in traditional PGP way."
11860 (set-buffer gnus-original-article-buffer)
11861 (goto-char (point-min))
11862 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11863 (error "Not a traditional PGP message!"))
11864 (re-search-forward "^-+END PGP" nil t)
11865 (beginning-of-line 2)
11866 (call-interactively (function pgg-verify-region))))
11869 ;;; Generic summary marking commands
11872 (defvar gnus-summary-marking-alist
11873 '((read gnus-del-mark "d")
11874 (unread gnus-unread-mark "u")
11875 (ticked gnus-ticked-mark "!")
11876 (dormant gnus-dormant-mark "?")
11877 (expirable gnus-expirable-mark "e"))
11878 "An alist of names/marks/keystrokes.")
11880 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11881 (defvar gnus-summary-mark-map)
11883 (defun gnus-summary-make-all-marking-commands ()
11884 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11885 (dolist (elem gnus-summary-marking-alist)
11886 (apply 'gnus-summary-make-marking-command elem)))
11888 (defun gnus-summary-make-marking-command (name mark keystroke)
11889 (let ((map (make-sparse-keymap)))
11890 (define-key gnus-summary-generic-mark-map keystroke map)
11891 (dolist (lway `((next "next" next nil "n")
11892 (next-unread "next unread" next t "N")
11893 (prev "previous" prev nil "p")
11894 (prev-unread "previous unread" prev t "P")
11895 (nomove "" nil nil ,keystroke)))
11896 (let ((func (gnus-summary-make-marking-command-1
11897 mark (car lway) lway name)))
11898 (setq func (eval func))
11899 (define-key map (nth 4 lway) func)))))
11901 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11903 (format "gnus-summary-put-mark-as-%s%s"
11904 name (if (eq way 'nomove)
11906 (concat "-" (symbol-name way)))))
11909 "Mark the current article as %s%s.
11910 If N, the prefix, then repeat N times.
11911 If N is negative, move in reverse order.
11912 The difference between N and the actual number of articles marked is
11914 name (car (cdr lway)))
11916 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11918 (defun gnus-summary-generic-mark (n mark move unread)
11919 "Mark N articles with MARK."
11920 (unless (eq major-mode 'gnus-summary-mode)
11921 (error "This command can only be used in the summary buffer"))
11922 (gnus-summary-show-thread)
11925 ((eq move 'next) 1)
11926 ((eq move 'prev) -1)
11928 (if (zerop nummove)
11932 nummove (* -1 nummove))))
11933 (while (and (> n 0)
11934 (gnus-summary-mark-article nil mark)
11935 (zerop (gnus-summary-next-subject nummove unread t)))
11938 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11939 (gnus-summary-recenter)
11940 (gnus-summary-position-point)
11941 (gnus-set-mode-line 'summary)
11944 (defun gnus-summary-insert-articles (articles)
11945 (when (setq articles
11946 (gnus-sorted-difference articles
11947 (mapcar (lambda (h)
11948 (mail-header-number h))
11949 gnus-newsgroup-headers)))
11950 (setq gnus-newsgroup-headers
11952 gnus-newsgroup-headers
11953 (gnus-fetch-headers articles)
11954 'gnus-article-sort-by-number))
11955 ;; Suppress duplicates?
11956 (when gnus-suppress-duplicates
11957 (gnus-dup-suppress-articles))
11959 ;; We might want to build some more threads first.
11960 (when (and gnus-fetch-old-headers
11961 (eq gnus-headers-retrieved-by 'nov))
11962 (if (eq gnus-fetch-old-headers 'invisible)
11963 (gnus-build-all-threads)
11964 (gnus-build-old-threads)))
11965 ;; Let the Gnus agent mark articles as read.
11967 (gnus-agent-get-undownloaded-list))
11968 ;; Remove list identifiers from subject
11969 (when gnus-list-identifiers
11970 (gnus-summary-remove-list-identifiers))
11971 ;; First and last article in this newsgroup.
11972 (when gnus-newsgroup-headers
11973 (setq gnus-newsgroup-begin
11974 (mail-header-number (car gnus-newsgroup-headers))
11976 (mail-header-number
11977 (gnus-last-element gnus-newsgroup-headers))))
11978 (when gnus-use-scoring
11979 (gnus-possibly-score-headers))))
11981 (defun gnus-summary-insert-old-articles (&optional all)
11982 "Insert all old articles in this group.
11983 If ALL is non-nil, already read articles become readable.
11984 If ALL is a number, fetch this number of articles."
11987 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11990 ;; Some nntp servers lie about their active range. When
11991 ;; this happens, the active range can be in the millions.
11992 ;; Use a compressed range to avoid creating a huge list.
11993 (gnus-range-difference (list gnus-newsgroup-active) old))
11994 (setq len (gnus-range-length older))
11999 (let ((older-range (nreverse older)))
12003 (let* ((r (pop older-range))
12004 (min (if (numberp r) r (car r)))
12005 (max (if (numberp r) r (cdr r))))
12006 (while (and (<= min max)
12011 (setq older (gnus-uncompress-range older))))
12013 (setq older (gnus-uncompress-range older)))
12015 (when (and (numberp gnus-large-newsgroup)
12016 (> len gnus-large-newsgroup))
12017 (let* ((cursor-in-echo-area nil)
12018 (initial (gnus-parameter-large-newsgroup-initial
12019 gnus-newsgroup-name))
12023 "How many articles from %s (%s %d): "
12025 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12026 (if initial "max" "default")
12029 (cons (number-to-string initial)
12031 (unless (string-match "^[ \t]*$" input)
12032 (setq all (string-to-number input))
12034 (let ((older-range (nreverse older)))
12038 (let* ((r (pop older-range))
12039 (min (if (numberp r) r (car r)))
12040 (max (if (numberp r) r (cdr r))))
12041 (while (and (<= min max)
12045 max (1- max))))))))))
12046 (setq older (gnus-uncompress-range older))))
12048 (message "No old news.")
12049 (gnus-summary-insert-articles older)
12050 (gnus-summary-limit (gnus-sorted-nunion old older))))
12051 (gnus-summary-position-point)))
12053 (defun gnus-summary-insert-new-articles ()
12054 "Insert all new articles in this group."
12057 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12058 (old-active gnus-newsgroup-active)
12059 (nnmail-fetched-sources (list t))
12061 (setq gnus-newsgroup-active
12062 (gnus-activate-group gnus-newsgroup-name 'scan))
12063 (setq i (cdr gnus-newsgroup-active))
12064 (while (> i (cdr old-active))
12068 (message "No gnus is bad news")
12069 (gnus-summary-insert-articles new)
12070 (setq gnus-newsgroup-unreads
12071 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12072 (gnus-summary-limit (gnus-sorted-nunion old new))))
12073 (gnus-summary-position-point)))
12075 (gnus-summary-make-all-marking-commands)
12077 (gnus-ems-redefine)
12079 (provide 'gnus-sum)
12081 (run-hooks 'gnus-sum-load-hook)
12083 ;; Local Variables:
12084 ;; coding: iso-8859-1
12087 ;;; gnus-sum.el ends here