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."
1185 :group 'gnus-summary
1186 :type '(choice boolean regexp))
1188 (defcustom gnus-summary-muttprint-program "muttprint"
1189 "Command (and optional arguments) used to run Muttprint."
1191 :group 'gnus-summary
1194 (defcustom gnus-article-loose-mime t
1195 "If non-nil, don't require MIME-Version header.
1196 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1197 supply the MIME-Version header or deliberately strip it from the mail.
1198 If non-nil (the default), Gnus will treat some articles as MIME
1199 even if the MIME-Version header is missing."
1202 :group 'gnus-article-mime)
1204 (defcustom gnus-article-emulate-mime t
1205 "If non-nil, use MIME emulation for uuencode and the like.
1206 This means that Gnus will search message bodies for text that look
1207 like uuencoded bits, yEncoded bits, and so on, and present that using
1208 the normal Gnus MIME machinery."
1211 :group 'gnus-article-mime)
1213 ;;; Internal variables
1215 (defvar gnus-summary-display-cache nil)
1216 (defvar gnus-article-mime-handles nil)
1217 (defvar gnus-article-decoded-p nil)
1218 (defvar gnus-article-charset nil)
1219 (defvar gnus-article-ignored-charsets nil)
1220 (defvar gnus-scores-exclude-files nil)
1221 (defvar gnus-page-broken nil)
1223 (defvar gnus-original-article nil)
1224 (defvar gnus-article-internal-prepare-hook nil)
1225 (defvar gnus-newsgroup-process-stack nil)
1227 (defvar gnus-thread-indent-array nil)
1228 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1229 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1230 "Function called to sort the articles within a thread after it has been gathered together.")
1232 (defvar gnus-summary-save-parts-type-history nil)
1233 (defvar gnus-summary-save-parts-last-directory nil)
1235 ;; Avoid highlighting in kill files.
1236 (defvar gnus-summary-inhibit-highlight nil)
1237 (defvar gnus-newsgroup-selected-overlay nil)
1238 (defvar gnus-inhibit-limiting nil)
1239 (defvar gnus-newsgroup-adaptive-score-file nil)
1240 (defvar gnus-current-score-file nil)
1241 (defvar gnus-current-move-group nil)
1242 (defvar gnus-current-copy-group nil)
1243 (defvar gnus-current-crosspost-group nil)
1244 (defvar gnus-newsgroup-display nil)
1246 (defvar gnus-newsgroup-dependencies nil)
1247 (defvar gnus-newsgroup-adaptive nil)
1248 (defvar gnus-summary-display-article-function nil)
1249 (defvar gnus-summary-highlight-line-function nil
1250 "Function called after highlighting a summary line.")
1252 (defvar gnus-summary-line-format-alist
1253 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1254 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1255 (?s gnus-tmp-subject-or-nil ?s)
1256 (?n gnus-tmp-name ?s)
1257 (?A (std11-address-string
1258 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1259 (?a (or (std11-full-name-string
1260 (car (mime-entity-read-field gnus-tmp-header 'From)))
1262 (?F gnus-tmp-from ?s)
1263 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1264 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1265 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1266 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1267 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1268 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1269 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1270 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1271 (?L gnus-tmp-lines ?s)
1272 (?O gnus-tmp-downloaded ?c)
1273 (?I gnus-tmp-indentation ?s)
1274 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1275 (?R gnus-tmp-replied ?c)
1276 (?\[ gnus-tmp-opening-bracket ?c)
1277 (?\] gnus-tmp-closing-bracket ?c)
1278 (?\> (make-string gnus-tmp-level ? ) ?s)
1279 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1280 (?i gnus-tmp-score ?d)
1281 (?z gnus-tmp-score-char ?c)
1282 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1283 (?U gnus-tmp-unread ?c)
1284 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1286 (?t (gnus-summary-number-of-articles-in-thread
1287 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1289 (?e (gnus-summary-number-of-articles-in-thread
1290 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1292 (?u gnus-tmp-user-defined ?s)
1293 (?P (gnus-pick-line-number) ?d)
1294 (?B gnus-tmp-thread-tree-header-string ?s)
1295 (user-date (gnus-user-date
1296 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1297 "An alist of format specifications that can appear in summary lines.
1298 These are paired with what variables they correspond with, along with
1299 the type of the variable (string, integer, character, etc).")
1301 (defvar gnus-summary-dummy-line-format-alist
1302 `((?S gnus-tmp-subject ?s)
1303 (?N gnus-tmp-number ?d)
1304 (?u gnus-tmp-user-defined ?s)))
1306 (defvar gnus-summary-mode-line-format-alist
1307 `((?G gnus-tmp-group-name ?s)
1308 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1309 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1310 (?A gnus-tmp-article-number ?d)
1311 (?Z gnus-tmp-unread-and-unselected ?s)
1312 (?V gnus-version ?s)
1313 (?U gnus-tmp-unread-and-unticked ?d)
1314 (?S gnus-tmp-subject ?s)
1315 (?e gnus-tmp-unselected ?d)
1316 (?u gnus-tmp-user-defined ?s)
1317 (?d (length gnus-newsgroup-dormant) ?d)
1318 (?t (length gnus-newsgroup-marked) ?d)
1319 (?h (length gnus-newsgroup-spam-marked) ?d)
1320 (?r (length gnus-newsgroup-reads) ?d)
1321 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1322 (?E gnus-newsgroup-expunged-tally ?d)
1323 (?s (gnus-current-score-file-nondirectory) ?s)))
1325 (defvar gnus-last-search-regexp nil
1326 "Default regexp for article search command.")
1328 (defvar gnus-summary-search-article-matched-data nil
1329 "Last matched data of article search command. It is the local variable
1330 in `gnus-article-buffer' which consists of the list of start position,
1331 end position and text.")
1333 (defvar gnus-last-shell-command nil
1334 "Default shell command on article.")
1336 (defvar gnus-newsgroup-agentized nil
1337 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1338 (defvar gnus-newsgroup-begin nil)
1339 (defvar gnus-newsgroup-end nil)
1340 (defvar gnus-newsgroup-last-rmail nil)
1341 (defvar gnus-newsgroup-last-mail nil)
1342 (defvar gnus-newsgroup-last-folder nil)
1343 (defvar gnus-newsgroup-last-file nil)
1344 (defvar gnus-newsgroup-auto-expire nil)
1345 (defvar gnus-newsgroup-active nil)
1347 (defvar gnus-newsgroup-data nil)
1348 (defvar gnus-newsgroup-data-reverse nil)
1349 (defvar gnus-newsgroup-limit nil)
1350 (defvar gnus-newsgroup-limits nil)
1351 (defvar gnus-summary-use-undownloaded-faces nil)
1353 (defvar gnus-newsgroup-unreads nil
1354 "Sorted list of unread articles in the current newsgroup.")
1356 (defvar gnus-newsgroup-unselected nil
1357 "Sorted list of unselected unread articles in the current newsgroup.")
1359 (defvar gnus-newsgroup-reads nil
1360 "Alist of read articles and article marks in the current newsgroup.")
1362 (defvar gnus-newsgroup-expunged-tally nil)
1364 (defvar gnus-newsgroup-marked nil
1365 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1367 (defvar gnus-newsgroup-spam-marked nil
1368 "List of ranges of articles that have been marked as spam.")
1370 (defvar gnus-newsgroup-killed nil
1371 "List of ranges of articles that have been through the scoring process.")
1373 (defvar gnus-newsgroup-cached nil
1374 "Sorted list of articles that come from the article cache.")
1376 (defvar gnus-newsgroup-saved nil
1377 "List of articles that have been saved.")
1379 (defvar gnus-newsgroup-kill-headers nil)
1381 (defvar gnus-newsgroup-replied nil
1382 "List of articles that have been replied to in the current newsgroup.")
1384 (defvar gnus-newsgroup-forwarded nil
1385 "List of articles that have been forwarded in the current newsgroup.")
1387 (defvar gnus-newsgroup-recent nil
1388 "List of articles that have are recent in the current newsgroup.")
1390 (defvar gnus-newsgroup-expirable nil
1391 "Sorted list of articles in the current newsgroup that can be expired.")
1393 (defvar gnus-newsgroup-processable nil
1394 "List of articles in the current newsgroup that can be processed.")
1396 (defvar gnus-newsgroup-downloadable nil
1397 "Sorted list of articles in the current newsgroup that can be processed.")
1399 (defvar gnus-newsgroup-unfetched nil
1400 "Sorted list of articles in the current newsgroup whose headers have
1401 not been fetched into the agent.
1403 This list will always be a subset of gnus-newsgroup-undownloaded.")
1405 (defvar gnus-newsgroup-undownloaded nil
1406 "List of articles in the current newsgroup that haven't been downloaded.")
1408 (defvar gnus-newsgroup-unsendable nil
1409 "List of articles in the current newsgroup that won't be sent.")
1411 (defvar gnus-newsgroup-bookmarks nil
1412 "List of articles in the current newsgroup that have bookmarks.")
1414 (defvar gnus-newsgroup-dormant nil
1415 "Sorted list of dormant articles in the current newsgroup.")
1417 (defvar gnus-newsgroup-unseen nil
1418 "List of unseen articles in the current newsgroup.")
1420 (defvar gnus-newsgroup-seen nil
1421 "Range of seen articles in the current newsgroup.")
1423 (defvar gnus-newsgroup-articles nil
1424 "List of articles in the current newsgroup.")
1426 (defvar gnus-newsgroup-scored nil
1427 "List of scored articles in the current newsgroup.")
1429 (defvar gnus-newsgroup-incorporated nil
1430 "List of incorporated articles in the current newsgroup.")
1432 (defvar gnus-newsgroup-headers nil
1433 "List of article headers in the current newsgroup.")
1435 (defvar gnus-newsgroup-threads nil)
1437 (defvar gnus-newsgroup-prepared nil
1438 "Whether the current group has been prepared properly.")
1440 (defvar gnus-newsgroup-ancient nil
1441 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1443 (defvar gnus-newsgroup-sparse nil)
1445 (defvar gnus-current-article nil)
1446 (defvar gnus-article-current nil)
1447 (defvar gnus-current-headers nil)
1448 (defvar gnus-have-all-headers nil)
1449 (defvar gnus-last-article nil)
1450 (defvar gnus-newsgroup-history nil)
1451 (defvar gnus-newsgroup-charset nil)
1452 (defvar gnus-newsgroup-ephemeral-charset nil)
1453 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1455 (defvar gnus-article-before-search nil)
1457 (defvar gnus-summary-local-variables
1458 '(gnus-newsgroup-name
1459 gnus-newsgroup-begin gnus-newsgroup-end
1460 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1461 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1462 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1463 gnus-newsgroup-unselected gnus-newsgroup-marked
1464 gnus-newsgroup-spam-marked
1465 gnus-newsgroup-reads gnus-newsgroup-saved
1466 gnus-newsgroup-replied gnus-newsgroup-forwarded
1467 gnus-newsgroup-recent
1468 gnus-newsgroup-expirable
1469 gnus-newsgroup-processable gnus-newsgroup-killed
1470 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1471 gnus-newsgroup-unfetched
1472 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1473 gnus-newsgroup-seen gnus-newsgroup-articles
1474 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1475 gnus-newsgroup-headers gnus-newsgroup-threads
1476 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1477 gnus-current-article gnus-current-headers gnus-have-all-headers
1478 gnus-last-article gnus-article-internal-prepare-hook
1479 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1480 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1481 gnus-thread-expunge-below
1482 gnus-score-alist gnus-current-score-file
1483 (gnus-summary-expunge-below . global)
1484 (gnus-summary-mark-below . global)
1485 (gnus-orphan-score . global)
1486 gnus-newsgroup-active gnus-scores-exclude-files
1487 gnus-newsgroup-history gnus-newsgroup-ancient
1488 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1489 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1490 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1491 (gnus-newsgroup-expunged-tally . 0)
1492 gnus-cache-removable-articles gnus-newsgroup-cached
1493 gnus-newsgroup-data gnus-newsgroup-data-reverse
1494 gnus-newsgroup-limit gnus-newsgroup-limits
1495 gnus-newsgroup-charset gnus-newsgroup-display
1496 gnus-summary-use-undownloaded-faces
1497 gnus-newsgroup-incorporated)
1498 "Variables that are buffer-local to the summary buffers.")
1500 (defvar gnus-newsgroup-variables nil
1501 "A list of variables that have separate values in different newsgroups.
1502 A list of newsgroup (summary buffer) local variables, or cons of
1503 variables and their default expressions to be evalled (when the default
1504 values are not nil), that should be made global while the summary buffer
1507 Note: The default expressions will be evaluated (using function `eval')
1508 before assignment to the local variable rather than just assigned to it.
1509 If the default expression is the symbol `global', that symbol will not
1510 be evaluated but the global value of the local variable will be used
1513 These variables can be used to set variables in the group parameters
1514 while still allowing them to affect operations done in other buffers.
1517 \(setq gnus-newsgroup-variables
1518 '(message-use-followup-to
1519 (gnus-visible-headers .
1520 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1523 ;; Byte-compiler warning.
1525 ;; Bind features so that require will believe that gnus-sum has
1526 ;; already been loaded (avoids infinite recursion)
1527 (let ((features (cons 'gnus-sum features)))
1528 ;; Several of the declarations in gnus-sum are needed to load the
1529 ;; following files. Right now, these definitions have been
1530 ;; compiled but not defined (evaluated). We could either do a
1531 ;; eval-and-compile about all of the declarations or evaluate the
1533 (if (boundp 'gnus-newsgroup-variables)
1535 (load "gnus-sum.el" t t t))
1537 (require 'gnus-art)))
1539 ;; Subject simplification.
1541 (defun gnus-simplify-whitespace (str)
1542 "Remove excessive whitespace from STR."
1544 (while (string-match "[ \t][ \t]+" str)
1545 (setq str (concat (substring str 0 (match-beginning 0))
1547 (substring str (match-end 0)))))
1549 (when (string-match "^[ \t]+" str)
1550 (setq str (substring str (match-end 0))))
1552 (when (string-match "[ \t]+$" str)
1553 (setq str (substring str 0 (match-beginning 0))))
1556 (defun gnus-simplify-all-whitespace (str)
1557 "Remove all whitespace from STR."
1558 (while (string-match "[ \t\n]+" str)
1559 (setq str (replace-match "" nil nil str)))
1562 (defsubst gnus-simplify-subject-re (subject)
1563 "Remove \"Re:\" from subject lines."
1564 (if (string-match message-subject-re-regexp subject)
1565 (substring subject (match-end 0))
1568 (defun gnus-simplify-subject (subject &optional re-only)
1569 "Remove `Re:' and words in parentheses.
1570 If RE-ONLY is non-nil, strip leading `Re:'s only."
1571 (let ((case-fold-search t)) ;Ignore case.
1572 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1573 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1574 (setq subject (substring subject (match-end 0))))
1575 ;; Remove uninteresting prefixes.
1576 (when (and (not re-only)
1577 gnus-simplify-ignored-prefixes
1578 (string-match gnus-simplify-ignored-prefixes subject))
1579 (setq subject (substring subject (match-end 0))))
1580 ;; Remove words in parentheses from end.
1582 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1583 (setq subject (substring subject 0 (match-beginning 0)))))
1584 ;; Return subject string.
1587 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1589 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1590 (goto-char (point-min))
1591 (while (re-search-forward regexp nil t)
1592 (replace-match (or newtext ""))))
1594 (defun gnus-simplify-buffer-fuzzy ()
1595 "Simplify string in the buffer fuzzily.
1596 The string in the accessible portion of the current buffer is simplified.
1597 It is assumed to be a single-line subject.
1598 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1599 matter is removed. Additional things can be deleted by setting
1600 `gnus-simplify-subject-fuzzy-regexp'."
1601 (let ((case-fold-search t)
1603 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1605 (while (not (eq modified-tick (buffer-modified-tick)))
1606 (setq modified-tick (buffer-modified-tick))
1608 ((listp gnus-simplify-subject-fuzzy-regexp)
1609 (mapcar 'gnus-simplify-buffer-fuzzy-step
1610 gnus-simplify-subject-fuzzy-regexp))
1611 (gnus-simplify-subject-fuzzy-regexp
1612 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1613 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1614 (gnus-simplify-buffer-fuzzy-step
1615 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1616 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1618 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1619 (gnus-simplify-buffer-fuzzy-step " +" " ")
1620 (gnus-simplify-buffer-fuzzy-step " $")
1621 (gnus-simplify-buffer-fuzzy-step "^ +")))
1623 (defun gnus-simplify-subject-fuzzy (subject)
1624 "Simplify a subject string fuzzily.
1625 See `gnus-simplify-buffer-fuzzy' for details."
1627 (gnus-set-work-buffer)
1628 (let ((case-fold-search t))
1629 ;; Remove uninteresting prefixes.
1630 (when (and gnus-simplify-ignored-prefixes
1631 (string-match gnus-simplify-ignored-prefixes subject))
1632 (setq subject (substring subject (match-end 0))))
1634 (inline (gnus-simplify-buffer-fuzzy))
1637 (defsubst gnus-simplify-subject-fully (subject)
1638 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1640 (gnus-simplify-subject-functions
1641 (gnus-map-function gnus-simplify-subject-functions subject))
1642 ((null gnus-summary-gather-subject-limit)
1643 (gnus-simplify-subject-re subject))
1644 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1645 (gnus-simplify-subject-fuzzy subject))
1646 ((numberp gnus-summary-gather-subject-limit)
1647 (gnus-limit-string (gnus-simplify-subject-re subject)
1648 gnus-summary-gather-subject-limit))
1652 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1653 "Check whether two subjects are equal.
1654 If optional argument SIMPLE-FIRST is t, first argument is already
1657 ((null simple-first)
1658 (equal (gnus-simplify-subject-fully s1)
1659 (gnus-simplify-subject-fully s2)))
1662 (gnus-simplify-subject-fully s2)))))
1664 (defun gnus-summary-bubble-group ()
1665 "Increase the score of the current group.
1666 This is a handy function to add to `gnus-summary-exit-hook' to
1667 increase the score of each group you read."
1668 (gnus-group-add-score gnus-newsgroup-name))
1672 ;;; Gnus summary mode
1675 (put 'gnus-summary-mode 'mode-class 'special)
1677 (defvar gnus-article-commands-menu)
1679 ;; Non-orthogonal keys
1681 (gnus-define-keys gnus-summary-mode-map
1682 " " gnus-summary-next-page
1683 "\177" gnus-summary-prev-page
1684 [delete] gnus-summary-prev-page
1685 [backspace] gnus-summary-prev-page
1686 "\r" gnus-summary-scroll-up
1687 "\M-\r" gnus-summary-scroll-down
1688 "n" gnus-summary-next-unread-article
1689 "p" gnus-summary-prev-unread-article
1690 "N" gnus-summary-next-article
1691 "P" gnus-summary-prev-article
1692 "\M-\C-n" gnus-summary-next-same-subject
1693 "\M-\C-p" gnus-summary-prev-same-subject
1694 "\M-n" gnus-summary-next-unread-subject
1695 "\M-p" gnus-summary-prev-unread-subject
1696 "." gnus-summary-first-unread-article
1697 "," gnus-summary-best-unread-article
1698 "\M-s" gnus-summary-search-article-forward
1699 "\M-r" gnus-summary-search-article-backward
1700 "<" gnus-summary-beginning-of-article
1701 ">" gnus-summary-end-of-article
1702 "j" gnus-summary-goto-article
1703 "^" gnus-summary-refer-parent-article
1704 "\M-^" gnus-summary-refer-article
1705 "u" gnus-summary-tick-article-forward
1706 "!" gnus-summary-tick-article-forward
1707 "U" gnus-summary-tick-article-backward
1708 "d" gnus-summary-mark-as-read-forward
1709 "D" gnus-summary-mark-as-read-backward
1710 "E" gnus-summary-mark-as-expirable
1711 "\M-u" gnus-summary-clear-mark-forward
1712 "\M-U" gnus-summary-clear-mark-backward
1713 "k" gnus-summary-kill-same-subject-and-select
1714 "\C-k" gnus-summary-kill-same-subject
1715 "\M-\C-k" gnus-summary-kill-thread
1716 "\M-\C-l" gnus-summary-lower-thread
1717 "e" gnus-summary-edit-article
1718 "#" gnus-summary-mark-as-processable
1719 "\M-#" gnus-summary-unmark-as-processable
1720 "\M-\C-t" gnus-summary-toggle-threads
1721 "\M-\C-s" gnus-summary-show-thread
1722 "\M-\C-h" gnus-summary-hide-thread
1723 "\M-\C-f" gnus-summary-next-thread
1724 "\M-\C-b" gnus-summary-prev-thread
1725 [(meta down)] gnus-summary-next-thread
1726 [(meta up)] gnus-summary-prev-thread
1727 "\M-\C-u" gnus-summary-up-thread
1728 "\M-\C-d" gnus-summary-down-thread
1729 "&" gnus-summary-execute-command
1730 "c" gnus-summary-catchup-and-exit
1731 "\C-w" gnus-summary-mark-region-as-read
1732 "\C-t" gnus-summary-toggle-truncation
1733 "?" gnus-summary-mark-as-dormant
1734 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1735 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1736 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1737 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1738 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1739 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1740 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1741 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1742 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1743 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1744 "=" gnus-summary-expand-window
1745 "\C-x\C-s" gnus-summary-reselect-current-group
1746 "\M-g" gnus-summary-rescan-group
1747 "w" gnus-summary-stop-page-breaking
1748 "\C-c\C-r" gnus-summary-caesar-message
1749 "\M-t" gnus-summary-toggle-mime
1750 "f" gnus-summary-followup
1751 "F" gnus-summary-followup-with-original
1752 "C" gnus-summary-cancel-article
1753 "r" gnus-summary-reply
1754 "R" gnus-summary-reply-with-original
1755 "\C-c\C-f" gnus-summary-mail-forward
1756 "o" gnus-summary-save-article
1757 "\C-o" gnus-summary-save-article-mail
1758 "|" gnus-summary-pipe-output
1759 "\M-k" gnus-summary-edit-local-kill
1760 "\M-K" gnus-summary-edit-global-kill
1762 "\C-c\C-d" gnus-summary-describe-group
1763 "q" gnus-summary-exit
1764 "Q" gnus-summary-exit-no-update
1765 "\C-c\C-i" gnus-info-find-node
1766 gnus-mouse-2 gnus-mouse-pick-article
1767 "m" gnus-summary-mail-other-window
1768 "a" gnus-summary-post-news
1769 "i" gnus-summary-news-other-window
1770 "x" gnus-summary-limit-to-unread
1771 "s" gnus-summary-isearch-article
1772 "t" gnus-summary-toggle-header
1773 "g" gnus-summary-show-article
1774 "l" gnus-summary-goto-last-article
1775 "v" gnus-summary-preview-mime-message
1776 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1777 "\C-d" gnus-summary-enter-digest-group
1778 "\M-\C-d" gnus-summary-read-document
1779 "\M-\C-e" gnus-summary-edit-parameters
1780 "\M-\C-a" gnus-summary-customize-parameters
1782 "\C-c\C-n" gnus-namazu-search
1783 "*" gnus-cache-enter-article
1784 "\M-*" gnus-cache-remove-article
1785 "\M-&" gnus-summary-universal-argument
1786 "\C-l" gnus-recenter
1787 "I" gnus-summary-increase-score
1788 "L" gnus-summary-lower-score
1789 "\M-i" gnus-symbolic-argument
1790 "h" gnus-summary-select-article-buffer
1792 "V" gnus-summary-score-map
1793 "X" gnus-uu-extract-map
1794 "S" gnus-summary-send-map)
1796 ;; Sort of orthogonal keymap
1797 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1798 "t" gnus-summary-tick-article-forward
1799 "!" gnus-summary-tick-article-forward
1800 "d" gnus-summary-mark-as-read-forward
1801 "r" gnus-summary-mark-as-read-forward
1802 "c" gnus-summary-clear-mark-forward
1803 " " gnus-summary-clear-mark-forward
1804 "e" gnus-summary-mark-as-expirable
1805 "x" gnus-summary-mark-as-expirable
1806 "?" gnus-summary-mark-as-dormant
1807 "b" gnus-summary-set-bookmark
1808 "B" gnus-summary-remove-bookmark
1809 "#" gnus-summary-mark-as-processable
1810 "\M-#" gnus-summary-unmark-as-processable
1811 "S" gnus-summary-limit-include-expunged
1812 "C" gnus-summary-catchup
1813 "H" gnus-summary-catchup-to-here
1814 "h" gnus-summary-catchup-from-here
1815 "\C-c" gnus-summary-catchup-all
1816 "k" gnus-summary-kill-same-subject-and-select
1817 "K" gnus-summary-kill-same-subject
1818 "P" gnus-uu-mark-map)
1820 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1821 "c" gnus-summary-clear-above
1822 "u" gnus-summary-tick-above
1823 "m" gnus-summary-mark-above
1824 "k" gnus-summary-kill-below)
1826 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1827 "/" gnus-summary-limit-to-subject
1828 "n" gnus-summary-limit-to-articles
1829 "w" gnus-summary-pop-limit
1830 "s" gnus-summary-limit-to-subject
1831 "a" gnus-summary-limit-to-author
1832 "u" gnus-summary-limit-to-unread
1833 "m" gnus-summary-limit-to-marks
1834 "M" gnus-summary-limit-exclude-marks
1835 "v" gnus-summary-limit-to-score
1836 "*" gnus-summary-limit-include-cached
1837 "D" gnus-summary-limit-include-dormant
1838 "T" gnus-summary-limit-include-thread
1839 "d" gnus-summary-limit-exclude-dormant
1840 "t" gnus-summary-limit-to-age
1841 "." gnus-summary-limit-to-unseen
1842 "x" gnus-summary-limit-to-extra
1843 "p" gnus-summary-limit-to-display-predicate
1844 "E" gnus-summary-limit-include-expunged
1845 "c" gnus-summary-limit-exclude-childless-dormant
1846 "C" gnus-summary-limit-mark-excluded-as-read
1847 "o" gnus-summary-insert-old-articles
1848 "N" gnus-summary-insert-new-articles
1849 "r" gnus-summary-limit-to-replied)
1851 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1852 "n" gnus-summary-next-unread-article
1853 "p" gnus-summary-prev-unread-article
1854 "N" gnus-summary-next-article
1855 "P" gnus-summary-prev-article
1856 "\C-n" gnus-summary-next-same-subject
1857 "\C-p" gnus-summary-prev-same-subject
1858 "\M-n" gnus-summary-next-unread-subject
1859 "\M-p" gnus-summary-prev-unread-subject
1860 "f" gnus-summary-first-unread-article
1861 "b" gnus-summary-best-unread-article
1862 "j" gnus-summary-goto-article
1863 "g" gnus-summary-goto-subject
1864 "l" gnus-summary-goto-last-article
1865 "o" gnus-summary-pop-article)
1867 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1868 "k" gnus-summary-kill-thread
1869 "l" gnus-summary-lower-thread
1870 "i" gnus-summary-raise-thread
1871 "T" gnus-summary-toggle-threads
1872 "t" gnus-summary-rethread-current
1873 "^" gnus-summary-reparent-thread
1874 "s" gnus-summary-show-thread
1875 "S" gnus-summary-show-all-threads
1876 "h" gnus-summary-hide-thread
1877 "H" gnus-summary-hide-all-threads
1878 "n" gnus-summary-next-thread
1879 "p" gnus-summary-prev-thread
1880 "u" gnus-summary-up-thread
1881 "o" gnus-summary-top-thread
1882 "d" gnus-summary-down-thread
1883 "#" gnus-uu-mark-thread
1884 "\M-#" gnus-uu-unmark-thread)
1886 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1887 "g" gnus-summary-prepare
1888 "c" gnus-summary-insert-cached-articles
1889 "d" gnus-summary-insert-dormant-articles)
1891 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1892 "c" gnus-summary-catchup-and-exit
1893 "C" gnus-summary-catchup-all-and-exit
1894 "E" gnus-summary-exit-no-update
1895 "J" gnus-summary-jump-to-other-group
1896 "Q" gnus-summary-exit
1897 "Z" gnus-summary-exit
1898 "n" gnus-summary-catchup-and-goto-next-group
1899 "R" gnus-summary-reselect-current-group
1900 "G" gnus-summary-rescan-group
1901 "N" gnus-summary-next-group
1902 "s" gnus-summary-save-newsrc
1903 "P" gnus-summary-prev-group)
1905 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1906 " " gnus-summary-next-page
1907 "n" gnus-summary-next-page
1908 "\177" gnus-summary-prev-page
1909 [delete] gnus-summary-prev-page
1910 "p" gnus-summary-prev-page
1911 "\r" gnus-summary-scroll-up
1912 "\M-\r" gnus-summary-scroll-down
1913 "<" gnus-summary-beginning-of-article
1914 ">" gnus-summary-end-of-article
1915 "b" gnus-summary-beginning-of-article
1916 "e" gnus-summary-end-of-article
1917 "^" gnus-summary-refer-parent-article
1918 "r" gnus-summary-refer-parent-article
1919 "D" gnus-summary-enter-digest-group
1920 "R" gnus-summary-refer-references
1921 "T" gnus-summary-refer-thread
1922 "g" gnus-summary-show-article
1923 "s" gnus-summary-isearch-article
1924 "P" gnus-summary-print-article
1925 "M" gnus-mailing-list-insinuate
1926 "t" gnus-article-babel)
1928 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1929 "b" gnus-article-add-buttons
1930 "B" gnus-article-add-buttons-to-head
1931 "o" gnus-article-treat-overstrike
1932 "e" gnus-article-emphasize
1933 "w" gnus-article-fill-cited-article
1934 "Q" gnus-article-fill-long-lines
1935 "C" gnus-article-capitalize-sentences
1936 "c" gnus-article-remove-cr
1937 "Z" gnus-article-decode-HZ
1938 "A" gnus-article-treat-ansi-sequences
1939 "h" gnus-article-wash-html
1940 "u" gnus-article-unsplit-urls
1941 "f" gnus-article-display-x-face
1942 "l" gnus-summary-stop-page-breaking
1943 "r" gnus-summary-caesar-message
1944 "m" gnus-summary-morse-message
1945 "t" gnus-summary-toggle-header
1946 "g" gnus-treat-smiley
1947 "v" gnus-summary-verbose-headers
1948 "m" gnus-summary-toggle-mime
1949 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1950 "p" gnus-article-verify-x-pgp-sig
1951 "d" gnus-article-treat-dumbquotes)
1953 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1954 ;; mnemonic: deuglif*Y*
1955 "u" gnus-article-outlook-unwrap-lines
1956 "a" gnus-article-outlook-repair-attribution
1957 "c" gnus-article-outlook-rearrange-citation
1958 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1960 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1961 "a" gnus-article-hide
1962 "h" gnus-article-hide-headers
1963 "b" gnus-article-hide-boring-headers
1964 "s" gnus-article-hide-signature
1965 "c" gnus-article-hide-citation
1966 "C" gnus-article-hide-citation-in-followups
1967 "l" gnus-article-hide-list-identifiers
1968 "B" gnus-article-strip-banner
1969 "P" gnus-article-hide-pem
1970 "\C-c" gnus-article-hide-citation-maybe)
1972 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1973 "a" gnus-article-highlight
1974 "h" gnus-article-highlight-headers
1975 "c" gnus-article-highlight-citation
1976 "s" gnus-article-highlight-signature)
1978 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1979 "f" gnus-article-treat-fold-headers
1980 "u" gnus-article-treat-unfold-headers
1981 "n" gnus-article-treat-fold-newsgroups)
1983 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1984 "x" gnus-article-display-x-face
1985 "d" gnus-article-display-face
1986 "s" gnus-treat-smiley
1987 "D" gnus-article-remove-images
1988 "f" gnus-treat-from-picon
1989 "m" gnus-treat-mail-picon
1990 "n" gnus-treat-newsgroups-picon)
1992 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1993 "z" gnus-article-date-ut
1994 "u" gnus-article-date-ut
1995 "l" gnus-article-date-local
1996 "p" gnus-article-date-english
1997 "e" gnus-article-date-lapsed
1998 "o" gnus-article-date-original
1999 "i" gnus-article-date-iso8601
2000 "s" gnus-article-date-user)
2002 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2003 "t" gnus-article-remove-trailing-blank-lines
2004 "l" gnus-article-strip-leading-blank-lines
2005 "m" gnus-article-strip-multiple-blank-lines
2006 "a" gnus-article-strip-blank-lines
2007 "A" gnus-article-strip-all-blank-lines
2008 "s" gnus-article-strip-leading-space
2009 "e" gnus-article-strip-trailing-space
2010 "w" gnus-article-remove-leading-whitespace)
2012 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2014 "f" gnus-summary-fetch-faq
2015 "d" gnus-summary-describe-group
2016 "h" gnus-summary-describe-briefly
2017 "i" gnus-info-find-node
2018 "c" gnus-group-fetch-charter
2019 "C" gnus-group-fetch-control)
2021 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2022 "e" gnus-summary-expire-articles
2023 "\M-\C-e" gnus-summary-expire-articles-now
2024 "\177" gnus-summary-delete-article
2025 [delete] gnus-summary-delete-article
2026 [backspace] gnus-summary-delete-article
2027 "m" gnus-summary-move-article
2028 "r" gnus-summary-respool-article
2029 "w" gnus-summary-edit-article
2030 "c" gnus-summary-copy-article
2031 "B" gnus-summary-crosspost-article
2032 "q" gnus-summary-respool-query
2033 "t" gnus-summary-respool-trace
2034 "i" gnus-summary-import-article
2035 "I" gnus-summary-create-article
2036 "p" gnus-summary-article-posted-p)
2038 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2039 "o" gnus-summary-save-article
2040 "m" gnus-summary-save-article-mail
2041 "F" gnus-summary-write-article-file
2042 "r" gnus-summary-save-article-rmail
2043 "f" gnus-summary-save-article-file
2044 "b" gnus-summary-save-article-body-file
2045 "h" gnus-summary-save-article-folder
2046 "v" gnus-summary-save-article-vm
2047 "p" gnus-summary-pipe-output
2048 "P" gnus-summary-muttprint
2049 "s" gnus-soup-add-article)
2051 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2052 "b" gnus-summary-display-buttonized
2053 "m" gnus-summary-repair-multipart
2054 "v" gnus-article-view-part
2055 "o" gnus-article-save-part
2056 "c" gnus-article-copy-part
2057 "C" gnus-article-view-part-as-charset
2058 "e" gnus-article-view-part-externally
2059 "E" gnus-article-encrypt-body
2060 "i" gnus-article-inline-part
2061 "|" gnus-article-pipe-part)
2063 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2064 "p" gnus-summary-mark-as-processable
2065 "u" gnus-summary-unmark-as-processable
2066 "U" gnus-summary-unmark-all-processable
2067 "v" gnus-uu-mark-over
2068 "s" gnus-uu-mark-series
2069 "r" gnus-uu-mark-region
2070 "g" gnus-uu-unmark-region
2071 "R" gnus-uu-mark-by-regexp
2072 "G" gnus-uu-unmark-by-regexp
2073 "t" gnus-uu-mark-thread
2074 "T" gnus-uu-unmark-thread
2075 "a" gnus-uu-mark-all
2076 "b" gnus-uu-mark-buffer
2077 "S" gnus-uu-mark-sparse
2078 "k" gnus-summary-kill-process-mark
2079 "y" gnus-summary-yank-process-mark
2080 "w" gnus-summary-save-process-mark
2081 "i" gnus-uu-invert-processable)
2083 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2084 ;;"x" gnus-uu-extract-any
2085 "m" gnus-summary-save-parts
2086 "u" gnus-uu-decode-uu
2087 "U" gnus-uu-decode-uu-and-save
2088 "s" gnus-uu-decode-unshar
2089 "S" gnus-uu-decode-unshar-and-save
2090 "o" gnus-uu-decode-save
2091 "O" gnus-uu-decode-save
2092 "b" gnus-uu-decode-binhex
2093 "B" gnus-uu-decode-binhex
2094 "p" gnus-uu-decode-postscript
2095 "P" gnus-uu-decode-postscript-and-save)
2098 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2099 "u" gnus-uu-decode-uu-view
2100 "U" gnus-uu-decode-uu-and-save-view
2101 "s" gnus-uu-decode-unshar-view
2102 "S" gnus-uu-decode-unshar-and-save-view
2103 "o" gnus-uu-decode-save-view
2104 "O" gnus-uu-decode-save-view
2105 "b" gnus-uu-decode-binhex-view
2106 "B" gnus-uu-decode-binhex-view
2107 "p" gnus-uu-decode-postscript-view
2108 "P" gnus-uu-decode-postscript-and-save-view)
2110 (defvar gnus-article-post-menu nil)
2112 (defconst gnus-summary-menu-maxlen 20)
2114 (defun gnus-summary-menu-split (menu)
2115 ;; If we have lots of elements, divide them into groups of 20
2116 ;; and make a pane (or submenu) for each one.
2117 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2118 (let ((menu menu) sublists next
2121 ;; Pull off the next gnus-summary-menu-maxlen elements
2122 ;; and make them the next element of sublist.
2123 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2125 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2127 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2128 (aref (car (last menu)) 0)) menu)
2132 (nreverse sublists))
2133 ;; Few elements--put them all in one pane.
2136 (defun gnus-summary-make-menu-bar ()
2137 (gnus-turn-off-edit-menu 'summary)
2139 (unless (boundp 'gnus-summary-misc-menu)
2142 gnus-summary-kill-menu gnus-summary-mode-map ""
2147 ["Customize" gnus-score-customize t])
2148 (gnus-make-score-map 'increase)
2149 (gnus-make-score-map 'lower)
2151 ["Kill below" gnus-summary-kill-below t]
2152 ["Mark above" gnus-summary-mark-above t]
2153 ["Tick above" gnus-summary-tick-above t]
2154 ["Clear above" gnus-summary-clear-above t])
2155 ["Current score" gnus-summary-current-score t]
2156 ["Set score" gnus-summary-set-score t]
2157 ["Switch current score file..." gnus-score-change-score-file t]
2158 ["Set mark below..." gnus-score-set-mark-below t]
2159 ["Set expunge below..." gnus-score-set-expunge-below t]
2160 ["Edit current score file" gnus-score-edit-current-scores t]
2161 ["Edit score file" gnus-score-edit-file t]
2162 ["Trace score" gnus-score-find-trace t]
2163 ["Find words" gnus-score-find-favourite-words t]
2164 ["Rescore buffer" gnus-summary-rescore t]
2165 ["Increase score..." gnus-summary-increase-score t]
2166 ["Lower score..." gnus-summary-lower-score t]))))
2168 ;; Define both the Article menu in the summary buffer and the
2169 ;; equivalent Commands menu in the article buffer here for
2173 ["All" gnus-article-hide t]
2174 ["Headers" gnus-article-hide-headers t]
2175 ["Signature" gnus-article-hide-signature t]
2176 ["Citation" gnus-article-hide-citation t]
2177 ["List identifiers" gnus-article-hide-list-identifiers t]
2178 ["Banner" gnus-article-strip-banner t]
2179 ["Boring headers" gnus-article-hide-boring-headers t])
2181 ["All" gnus-article-highlight t]
2182 ["Headers" gnus-article-highlight-headers t]
2183 ["Signature" gnus-article-highlight-signature t]
2184 ["Citation" gnus-article-highlight-citation t])
2186 ["Local" gnus-article-date-local t]
2187 ["ISO8601" gnus-article-date-iso8601 t]
2188 ["UT" gnus-article-date-ut t]
2189 ["Original" gnus-article-date-original t]
2190 ["Lapsed" gnus-article-date-lapsed t]
2191 ["User-defined" gnus-article-date-user t])
2193 ["Remove images" gnus-article-remove-images t]
2194 ["Toggle smiley" gnus-treat-smiley t]
2195 ["Show X-Face" gnus-article-display-x-face t]
2196 ["Show picons in From" gnus-treat-from-picon t]
2197 ["Show picons in mail headers" gnus-treat-mail-picon t]
2198 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2199 ("View as different encoding"
2200 ,@(gnus-summary-menu-split
2203 ;; Since easymenu under Emacs doesn't allow
2204 ;; lambda forms for menu commands, we should
2205 ;; provide intern'ed function symbols.
2206 (let ((command (intern (format "\
2207 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2211 (let ((gnus-summary-show-article-charset-alist
2213 (gnus-summary-show-article 1))))
2214 `[,(symbol-name cs) ,command t]))
2215 (sort (if (fboundp 'coding-system-list)
2216 (coding-system-list)
2217 ;;(mapcar 'car mm-mime-mule-charset-alist)
2222 ["Leading" gnus-article-strip-leading-blank-lines t]
2223 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2224 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2225 ["All of the above" gnus-article-strip-blank-lines t]
2226 ["All" gnus-article-strip-all-blank-lines t]
2227 ["Leading space" gnus-article-strip-leading-space t]
2228 ["Trailing space" gnus-article-strip-trailing-space t]
2229 ["Leading space in headers"
2230 gnus-article-remove-leading-whitespace t])
2231 ["Overstrike" gnus-article-treat-overstrike t]
2232 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2233 ["Emphasis" gnus-article-emphasize t]
2234 ["Word wrap" gnus-article-fill-cited-article t]
2235 ["Fill long lines" gnus-article-fill-long-lines t]
2236 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2237 ["Remove CR" gnus-article-remove-cr t]
2238 ["Rot 13" gnus-summary-caesar-message
2239 ,@(if (featurep 'xemacs) '(t)
2240 '(:help "\"Caesar rotate\" article by 13"))]
2241 ["Morse decode" gnus-summary-morse-message t]
2242 ["Unix pipe..." gnus-summary-pipe-message t]
2243 ["Add buttons" gnus-article-add-buttons t]
2244 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2245 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2246 ["Toggle MIME" gnus-summary-toggle-mime t]
2247 ["Verbose header" gnus-summary-verbose-headers t]
2248 ["Toggle header" gnus-summary-toggle-header t]
2249 ["Unfold headers" gnus-article-treat-unfold-headers t]
2250 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2251 ["Html" gnus-article-wash-html t]
2252 ["Unsplit URLs" gnus-article-unsplit-urls t]
2253 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2254 ["Decode HZ" gnus-article-decode-HZ t]
2255 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2256 ("(Outlook) Deuglify"
2257 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2258 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2259 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2260 ["Full (Outlook) deuglify"
2261 gnus-article-outlook-deuglify-article t])
2264 ["Save in default format..." gnus-summary-save-article
2265 ,@(if (featurep 'xemacs) '(t)
2266 '(:help "Save article using default method"))]
2267 ["Save in file..." gnus-summary-save-article-file
2268 ,@(if (featurep 'xemacs) '(t)
2269 '(:help "Save article in file"))]
2270 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2271 ["Save in MH folder..." gnus-summary-save-article-folder t]
2272 ["Save in VM folder..." gnus-summary-save-article-vm t]
2273 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2274 ["Save body in file..." gnus-summary-save-article-body-file t]
2275 ["Pipe through a filter..." gnus-summary-pipe-output t]
2276 ["Add to SOUP packet" gnus-soup-add-article t]
2277 ["Print with Muttprint..." gnus-summary-muttprint t]
2278 ["Print" gnus-summary-print-article
2279 ,@(if (featurep 'xemacs) '(t)
2280 '(:help "Generate and print a PostScript image"))])
2281 ("Copy, move,... (Backend)"
2282 ,@(if (featurep 'xemacs) nil
2283 '(:help "Copying, moving, expiring articles..."))
2284 ["Respool article..." gnus-summary-respool-article t]
2285 ["Move article..." gnus-summary-move-article
2286 (gnus-check-backend-function
2287 'request-move-article gnus-newsgroup-name)]
2288 ["Copy article..." gnus-summary-copy-article t]
2289 ["Crosspost article..." gnus-summary-crosspost-article
2290 (gnus-check-backend-function
2291 'request-replace-article gnus-newsgroup-name)]
2292 ["Import file..." gnus-summary-import-article
2293 (gnus-check-backend-function
2294 'request-accept-article gnus-newsgroup-name)]
2295 ["Create article..." gnus-summary-create-article
2296 (gnus-check-backend-function
2297 'request-accept-article gnus-newsgroup-name)]
2298 ["Check if posted" gnus-summary-article-posted-p t]
2299 ["Edit article" gnus-summary-edit-article
2300 (not (gnus-group-read-only-p))]
2301 ["Delete article" gnus-summary-delete-article
2302 (gnus-check-backend-function
2303 'request-expire-articles gnus-newsgroup-name)]
2304 ["Query respool" gnus-summary-respool-query t]
2305 ["Trace respool" gnus-summary-respool-trace t]
2306 ["Delete expirable articles" gnus-summary-expire-articles-now
2307 (gnus-check-backend-function
2308 'request-expire-articles gnus-newsgroup-name)])
2310 ["Uudecode" gnus-uu-decode-uu
2311 ,@(if (featurep 'xemacs) '(t)
2312 '(:help "Decode uuencoded article(s)"))]
2313 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2314 ["Unshar" gnus-uu-decode-unshar t]
2315 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2316 ["Save" gnus-uu-decode-save t]
2317 ["Binhex" gnus-uu-decode-binhex t]
2318 ["Postscript" gnus-uu-decode-postscript t])
2320 ["Enter article" gnus-cache-enter-article t]
2321 ["Remove article" gnus-cache-remove-article t])
2322 ["Translate" gnus-article-babel t]
2323 ["Select article buffer" gnus-summary-select-article-buffer t]
2324 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2325 ["Isearch article..." gnus-summary-isearch-article t]
2326 ["Beginning of the article" gnus-summary-beginning-of-article t]
2327 ["End of the article" gnus-summary-end-of-article t]
2328 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2329 ["Fetch referenced articles" gnus-summary-refer-references t]
2330 ["Fetch current thread" gnus-summary-refer-thread t]
2331 ["Fetch article with id..." gnus-summary-refer-article t]
2332 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2333 ["Redisplay" gnus-summary-show-article t]
2334 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2336 gnus-summary-article-menu gnus-summary-mode-map ""
2337 (cons "Article" innards))
2339 (if (not (keymapp gnus-summary-article-menu))
2341 gnus-article-commands-menu gnus-article-mode-map ""
2342 (cons "Commands" innards))
2343 ;; in Emacs, don't share menu.
2344 (setq gnus-article-commands-menu
2345 (copy-keymap gnus-summary-article-menu))
2346 (define-key gnus-article-mode-map [menu-bar commands]
2347 (cons "Commands" gnus-article-commands-menu))))
2350 gnus-summary-thread-menu gnus-summary-mode-map ""
2352 ["Find all messages in thread" gnus-summary-refer-thread t]
2353 ["Toggle threading" gnus-summary-toggle-threads t]
2354 ["Hide threads" gnus-summary-hide-all-threads t]
2355 ["Show threads" gnus-summary-show-all-threads t]
2356 ["Hide thread" gnus-summary-hide-thread t]
2357 ["Show thread" gnus-summary-show-thread t]
2358 ["Go to next thread" gnus-summary-next-thread t]
2359 ["Go to previous thread" gnus-summary-prev-thread t]
2360 ["Go down thread" gnus-summary-down-thread t]
2361 ["Go up thread" gnus-summary-up-thread t]
2362 ["Top of thread" gnus-summary-top-thread t]
2363 ["Mark thread as read" gnus-summary-kill-thread t]
2364 ["Lower thread score" gnus-summary-lower-thread t]
2365 ["Raise thread score" gnus-summary-raise-thread t]
2366 ["Rethread current" gnus-summary-rethread-current t]))
2369 gnus-summary-post-menu gnus-summary-mode-map ""
2371 ["Send a message (mail or news)" gnus-summary-post-news
2372 ,@(if (featurep 'xemacs) '(t)
2373 '(:help "Compose a new message (mail or news)"))]
2374 ["Followup" gnus-summary-followup
2375 ,@(if (featurep 'xemacs) '(t)
2376 '(:help "Post followup to this article"))]
2377 ["Followup and yank" gnus-summary-followup-with-original
2378 ,@(if (featurep 'xemacs) '(t)
2379 '(:help "Post followup to this article, quoting its contents"))]
2380 ["Supersede article" gnus-summary-supersede-article t]
2381 ["Cancel article" gnus-summary-cancel-article
2382 ,@(if (featurep 'xemacs) '(t)
2383 '(:help "Cancel an article you posted"))]
2384 ["Reply" gnus-summary-reply t]
2385 ["Reply and yank" gnus-summary-reply-with-original t]
2386 ["Wide reply" gnus-summary-wide-reply t]
2387 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2388 ,@(if (featurep 'xemacs) '(t)
2389 '(:help "Mail a reply, quoting this article"))]
2390 ["Very wide reply" gnus-summary-very-wide-reply t]
2391 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2392 ,@(if (featurep 'xemacs) '(t)
2393 '(:help "Mail a very wide reply, quoting this article"))]
2394 ["Mail forward" gnus-summary-mail-forward t]
2395 ["Post forward" gnus-summary-post-forward t]
2396 ["Digest and mail" gnus-summary-digest-mail-forward t]
2397 ["Digest and post" gnus-summary-digest-post-forward t]
2398 ["Resend message" gnus-summary-resend-message t]
2399 ["Resend message edit" gnus-summary-resend-message-edit t]
2400 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2401 ["Send a mail" gnus-summary-mail-other-window t]
2402 ["Create a local message" gnus-summary-news-other-window t]
2403 ["Uuencode and post" gnus-uu-post-news
2404 ,@(if (featurep 'xemacs) '(t)
2405 '(:help "Post a uuencoded article"))]
2406 ["Followup via news" gnus-summary-followup-to-mail t]
2407 ["Followup via news and yank"
2408 gnus-summary-followup-to-mail-with-original t]
2410 ;;["Send" gnus-summary-send-draft t]
2411 ;;["Send bounced" gnus-resend-bounced-mail t])
2415 ((not (keymapp gnus-summary-post-menu))
2416 (setq gnus-article-post-menu gnus-summary-post-menu))
2417 ((not gnus-article-post-menu)
2418 ;; Don't share post menu.
2419 (setq gnus-article-post-menu
2420 (copy-keymap gnus-summary-post-menu))))
2421 (define-key gnus-article-mode-map [menu-bar post]
2422 (cons "Post" gnus-article-post-menu))
2425 gnus-summary-misc-menu gnus-summary-mode-map ""
2428 ["Mark as read" gnus-summary-mark-as-read-forward t]
2429 ["Mark same subject and select"
2430 gnus-summary-kill-same-subject-and-select t]
2431 ["Mark same subject" gnus-summary-kill-same-subject t]
2432 ["Catchup" gnus-summary-catchup
2433 ,@(if (featurep 'xemacs) '(t)
2434 '(:help "Mark unread articles in this group as read"))]
2435 ["Catchup all" gnus-summary-catchup-all t]
2436 ["Catchup to here" gnus-summary-catchup-to-here t]
2437 ["Catchup from here" gnus-summary-catchup-from-here t]
2438 ["Catchup region" gnus-summary-mark-region-as-read
2439 (gnus-mark-active-p)]
2440 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2442 ["Tick" gnus-summary-tick-article-forward t]
2443 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2444 ["Remove marks" gnus-summary-clear-mark-forward t]
2445 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2446 ["Set bookmark" gnus-summary-set-bookmark t]
2447 ["Remove bookmark" gnus-summary-remove-bookmark t])
2449 ["Marks..." gnus-summary-limit-to-marks t]
2450 ["Subject..." gnus-summary-limit-to-subject t]
2451 ["Author..." gnus-summary-limit-to-author t]
2452 ["Age..." gnus-summary-limit-to-age t]
2453 ["Extra..." gnus-summary-limit-to-extra t]
2454 ["Score..." gnus-summary-limit-to-score t]
2455 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2456 ["Unread" gnus-summary-limit-to-unread t]
2457 ["Unseen" gnus-summary-limit-to-unseen t]
2458 ["Replied" gnus-summary-limit-to-replied t]
2459 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2460 ["Next articles" gnus-summary-limit-to-articles t]
2461 ["Pop limit" gnus-summary-pop-limit t]
2462 ["Show dormant" gnus-summary-limit-include-dormant t]
2463 ["Hide childless dormant"
2464 gnus-summary-limit-exclude-childless-dormant t]
2465 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2466 ["Hide marked" gnus-summary-limit-exclude-marks t]
2467 ["Show expunged" gnus-summary-limit-include-expunged t])
2469 ["Set mark" gnus-summary-mark-as-processable t]
2470 ["Remove mark" gnus-summary-unmark-as-processable t]
2471 ["Remove all marks" gnus-summary-unmark-all-processable t]
2472 ["Invert marks" gnus-uu-invert-processable t]
2473 ["Mark above" gnus-uu-mark-over t]
2474 ["Mark series" gnus-uu-mark-series t]
2475 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2476 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2477 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2478 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2479 ["Mark all" gnus-uu-mark-all t]
2480 ["Mark buffer" gnus-uu-mark-buffer t]
2481 ["Mark sparse" gnus-uu-mark-sparse t]
2482 ["Mark thread" gnus-uu-mark-thread t]
2483 ["Unmark thread" gnus-uu-unmark-thread t]
2484 ("Process Mark Sets"
2485 ["Kill" gnus-summary-kill-process-mark t]
2486 ["Yank" gnus-summary-yank-process-mark
2487 gnus-newsgroup-process-stack]
2488 ["Save" gnus-summary-save-process-mark t]
2489 ["Run command on marked..." gnus-summary-universal-argument t]))
2491 ["Page forward" gnus-summary-next-page
2492 ,@(if (featurep 'xemacs) '(t)
2493 '(:help "Show next page of article"))]
2494 ["Page backward" gnus-summary-prev-page
2495 ,@(if (featurep 'xemacs) '(t)
2496 '(:help "Show previous page of article"))]
2497 ["Line forward" gnus-summary-scroll-up t])
2499 ["Next unread article" gnus-summary-next-unread-article t]
2500 ["Previous unread article" gnus-summary-prev-unread-article t]
2501 ["Next article" gnus-summary-next-article t]
2502 ["Previous article" gnus-summary-prev-article t]
2503 ["Next unread subject" gnus-summary-next-unread-subject t]
2504 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2505 ["Next article same subject" gnus-summary-next-same-subject t]
2506 ["Previous article same subject" gnus-summary-prev-same-subject t]
2507 ["First unread article" gnus-summary-first-unread-article t]
2508 ["Best unread article" gnus-summary-best-unread-article t]
2509 ["Go to subject number..." gnus-summary-goto-subject t]
2510 ["Go to article number..." gnus-summary-goto-article t]
2511 ["Go to the last article" gnus-summary-goto-last-article t]
2512 ["Pop article off history" gnus-summary-pop-article t])
2514 ["Sort by number" gnus-summary-sort-by-number t]
2515 ["Sort by author" gnus-summary-sort-by-author t]
2516 ["Sort by subject" gnus-summary-sort-by-subject t]
2517 ["Sort by date" gnus-summary-sort-by-date t]
2518 ["Sort by score" gnus-summary-sort-by-score t]
2519 ["Sort by lines" gnus-summary-sort-by-lines t]
2520 ["Sort by characters" gnus-summary-sort-by-chars t]
2521 ["Randomize" gnus-summary-sort-by-random t]
2522 ["Original sort" gnus-summary-sort-by-original t])
2524 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2525 ["Describe group" gnus-summary-describe-group t]
2526 ["Fetch charter" gnus-group-fetch-charter
2527 ,@(if (featurep 'xemacs) nil
2528 '(:help "Display the charter of the current group"))]
2529 ["Fetch control message" gnus-group-fetch-control
2530 ,@(if (featurep 'xemacs) nil
2531 '(:help "Display the archived control message for the current group"))]
2532 ["Read manual" gnus-info-find-node t])
2534 ["Pick and read" gnus-pick-mode t]
2535 ["Binary" gnus-binary-mode t])
2537 ["Regenerate" gnus-summary-prepare t]
2538 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2539 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2540 ["Toggle threading" gnus-summary-toggle-threads t])
2541 ["See old articles" gnus-summary-insert-old-articles t]
2542 ["See new articles" gnus-summary-insert-new-articles t]
2543 ["Filter articles..." gnus-summary-execute-command t]
2544 ["Run command on articles..." gnus-summary-universal-argument t]
2545 ["Search articles forward..." gnus-summary-search-article-forward t]
2546 ["Search articles backward..." gnus-summary-search-article-backward t]
2547 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2548 ["Expand window" gnus-summary-expand-window t]
2549 ["Expire expirable articles" gnus-summary-expire-articles
2550 (gnus-check-backend-function
2551 'request-expire-articles gnus-newsgroup-name)]
2552 ["Edit local kill file" gnus-summary-edit-local-kill t]
2553 ["Edit main kill file" gnus-summary-edit-global-kill t]
2554 ["Edit group parameters" gnus-summary-edit-parameters t]
2555 ["Customize group parameters" gnus-summary-customize-parameters t]
2556 ["Send a bug report" gnus-bug t]
2558 ["Catchup and exit" gnus-summary-catchup-and-exit
2559 ,@(if (featurep 'xemacs) '(t)
2560 '(:help "Mark unread articles in this group as read, then exit"))]
2561 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2562 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2563 ["Exit group" gnus-summary-exit
2564 ,@(if (featurep 'xemacs) '(t)
2565 '(:help "Exit current group, return to group selection mode"))]
2566 ["Exit group without updating" gnus-summary-exit-no-update t]
2567 ["Exit and goto next group" gnus-summary-next-group t]
2568 ["Exit and goto prev group" gnus-summary-prev-group t]
2569 ["Reselect group" gnus-summary-reselect-current-group t]
2570 ["Rescan group" gnus-summary-rescan-group t]
2571 ["Update dribble" gnus-summary-save-newsrc t])))
2573 (gnus-run-hooks 'gnus-summary-menu-hook)))
2575 (defvar gnus-summary-tool-bar-map nil)
2577 ;; Emacs 21 tool bar. Should be no-op otherwise.
2578 (defun gnus-summary-make-tool-bar ()
2579 (if (and (fboundp 'tool-bar-add-item-from-menu)
2580 (default-value 'tool-bar-mode)
2581 (not gnus-summary-tool-bar-map))
2582 (setq gnus-summary-tool-bar-map
2583 (let ((tool-bar-map (make-sparse-keymap))
2584 (load-path (mm-image-load-path)))
2585 (tool-bar-add-item-from-menu
2586 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2587 (tool-bar-add-item-from-menu
2588 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2589 (tool-bar-add-item-from-menu
2590 'gnus-summary-post-news "post" gnus-summary-mode-map)
2591 (tool-bar-add-item-from-menu
2592 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2593 (tool-bar-add-item-from-menu
2594 'gnus-summary-followup "followup" gnus-summary-mode-map)
2595 (tool-bar-add-item-from-menu
2596 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2597 (tool-bar-add-item-from-menu
2598 'gnus-summary-reply "reply" gnus-summary-mode-map)
2599 (tool-bar-add-item-from-menu
2600 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2601 (tool-bar-add-item-from-menu
2602 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2603 (tool-bar-add-item-from-menu
2604 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2605 (tool-bar-add-item-from-menu
2606 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2607 (tool-bar-add-item-from-menu
2608 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2609 (tool-bar-add-item-from-menu
2610 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2611 (tool-bar-add-item-from-menu
2612 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2613 (tool-bar-add-item-from-menu
2614 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2615 (tool-bar-add-item-from-menu
2616 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2618 (if gnus-summary-tool-bar-map
2619 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2621 (defun gnus-score-set-default (var value)
2622 "A version of set that updates the GNU Emacs menu-bar."
2624 ;; It is the message that forces the active status to be updated.
2627 (defun gnus-make-score-map (type)
2628 "Make a summary score map of type TYPE."
2631 (let ((headers '(("author" "from" string)
2632 ("subject" "subject" string)
2633 ("article body" "body" string)
2634 ("article head" "head" string)
2635 ("xref" "xref" string)
2636 ("extra header" "extra" string)
2637 ("lines" "lines" number)
2638 ("followups to author" "followup" string)))
2639 (types '((number ("less than" <)
2642 (string ("substring" s)
2646 (perms '(("temporary" (current-time-string))
2654 (if (eq type 'lower)
2659 (setq header (car headers))
2665 (let ((ts (cdr (assoc (nth 2 header) types)))
2681 'gnus-summary-score-entry
2683 (if (or (string= (nth 1 header)
2685 (string= (nth 1 header)
2688 (list 'gnus-summary-header
2690 (list 'quote (nth 1 (car ts)))
2691 (list 'gnus-score-delta-default
2698 (list (nreverse outp))))
2701 (list (nreverse outt))))
2703 (setq headers (cdr headers)))
2704 (list (nreverse outh))))))))
2708 (defun gnus-summary-mode (&optional group)
2709 "Major mode for reading articles.
2711 All normal editing commands are switched off.
2712 \\<gnus-summary-mode-map>
2713 Each line in this buffer represents one article. To read an
2714 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2715 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2718 You can also post articles and send mail from this buffer. To
2719 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2720 of an article, type `\\[gnus-summary-reply]'.
2722 There are approx. one gazillion commands you can execute in this
2723 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2725 The following commands are available:
2727 \\{gnus-summary-mode-map}"
2729 (kill-all-local-variables)
2730 (when (gnus-visual-p 'summary-menu 'menu)
2731 (gnus-summary-make-menu-bar)
2732 (gnus-summary-make-tool-bar))
2733 (gnus-summary-make-local-variables)
2734 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2735 (gnus-summary-make-local-variables))
2736 (gnus-make-thread-indent-array)
2737 (gnus-simplify-mode-line)
2738 (setq major-mode 'gnus-summary-mode)
2739 (setq mode-name "Summary")
2740 (make-local-variable 'minor-mode-alist)
2741 (use-local-map gnus-summary-mode-map)
2742 (buffer-disable-undo)
2743 (setq buffer-read-only t ;Disable modification
2744 show-trailing-whitespace nil)
2745 (setq truncate-lines t)
2746 (setq selective-display t)
2747 (setq selective-display-ellipses t) ;Display `...'
2748 (gnus-summary-set-display-table)
2749 (gnus-set-default-directory)
2750 (setq gnus-newsgroup-name group)
2751 (unless (gnus-news-group-p group)
2752 (setq gnus-newsgroup-incorporated
2753 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2754 (make-local-variable 'gnus-summary-line-format)
2755 (make-local-variable 'gnus-summary-line-format-spec)
2756 (make-local-variable 'gnus-summary-dummy-line-format)
2757 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2758 (make-local-variable 'gnus-summary-mark-positions)
2759 (gnus-make-local-hook 'pre-command-hook)
2760 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2761 (gnus-run-hooks 'gnus-summary-mode-hook)
2762 (turn-on-gnus-mailing-list-mode)
2763 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2764 (gnus-update-summary-mark-positions))
2766 (defun gnus-summary-make-local-variables ()
2767 "Make all the local summary buffer variables."
2769 (dolist (local gnus-summary-local-variables)
2772 (if (eq (cdr local) 'global)
2773 ;; Copy the global value of the variable.
2774 (setq global (symbol-value (car local)))
2775 ;; Use the value from the list.
2776 (setq global (eval (cdr local))))
2777 (set (make-local-variable (car local)) global))
2778 ;; Simple nil-valued local variable.
2779 (set (make-local-variable local) nil)))))
2781 (defun gnus-summary-clear-local-variables ()
2782 (let ((locals gnus-summary-local-variables))
2784 (if (consp (car locals))
2785 (and (vectorp (caar locals))
2786 (set (caar locals) nil))
2787 (and (vectorp (car locals))
2788 (set (car locals) nil)))
2789 (setq locals (cdr locals)))))
2791 ;; Summary data functions.
2793 (defmacro gnus-data-number (data)
2796 (defmacro gnus-data-set-number (data number)
2797 `(setcar ,data ,number))
2799 (defmacro gnus-data-mark (data)
2802 (defmacro gnus-data-set-mark (data mark)
2803 `(setcar (nthcdr 1 ,data) ,mark))
2805 (defmacro gnus-data-pos (data)
2808 (defmacro gnus-data-set-pos (data pos)
2809 `(setcar (nthcdr 2 ,data) ,pos))
2811 (defmacro gnus-data-header (data)
2814 (defmacro gnus-data-set-header (data header)
2815 `(setcar (nthcdr 3 ,data) ,header))
2817 (defmacro gnus-data-level (data)
2820 (defmacro gnus-data-unread-p (data)
2821 `(= (nth 1 ,data) gnus-unread-mark))
2823 (defmacro gnus-data-read-p (data)
2824 `(/= (nth 1 ,data) gnus-unread-mark))
2826 (defmacro gnus-data-pseudo-p (data)
2827 `(consp (nth 3 ,data)))
2829 (defmacro gnus-data-find (number)
2830 `(assq ,number gnus-newsgroup-data))
2832 (defmacro gnus-data-find-list (number &optional data)
2833 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2834 (memq (assq ,number bdata)
2837 (defmacro gnus-data-make (number mark pos header level)
2838 `(list ,number ,mark ,pos ,header ,level))
2840 (defun gnus-data-enter (after-article number mark pos header level offset)
2841 (let ((data (gnus-data-find-list after-article)))
2843 (error "No such article: %d" after-article))
2844 (setcdr data (cons (gnus-data-make number mark pos header level)
2846 (setq gnus-newsgroup-data-reverse nil)
2847 (gnus-data-update-list (cddr data) offset)))
2849 (defun gnus-data-enter-list (after-article list &optional offset)
2851 (let ((data (and after-article (gnus-data-find-list after-article)))
2855 (let ((odata gnus-newsgroup-data))
2856 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2858 (gnus-data-update-list odata offset)))
2859 ;; Find the last element in the list to be spliced into the main
2861 (setq list (last 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 ((vars '(quit-config))) ; Ignore quit-config.
3479 (dolist (elem (gnus-group-find-parameter group))
3480 (and (consp elem) ; Has to be a cons.
3481 (consp (cdr elem)) ; The cdr has to be a list.
3482 (symbolp (car elem)) ; Has to be a symbol in there.
3483 (not (memq (car elem) vars))
3484 (ignore-errors ; So we set it.
3485 (push (car elem) vars)
3486 (make-local-variable (car elem))
3487 (set (car elem) (eval (nth 1 elem))))))))
3489 (defun gnus-summary-read-group (group &optional show-all no-article
3490 kill-buffer no-display backward
3492 "Start reading news in newsgroup GROUP.
3493 If SHOW-ALL is non-nil, already read articles are also listed.
3494 If NO-ARTICLE is non-nil, no article is selected initially.
3495 If NO-DISPLAY, don't generate a summary buffer."
3499 (let ((gnus-auto-select-next nil))
3500 (or (gnus-summary-read-group-1
3501 group show-all no-article
3502 kill-buffer no-display
3505 select-articles nil)))))
3506 (eq gnus-auto-select-next 'quietly))
3507 (set-buffer gnus-group-buffer)
3508 ;; The entry function called above goes to the next
3509 ;; group automatically, so we go two groups back
3510 ;; if we are searching for the previous group.
3512 (gnus-group-prev-unread-group 2))
3513 (if (not (equal group (gnus-group-group-name)))
3514 (setq group (gnus-group-group-name))
3518 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3519 "Directly jump to the other GROUP from summary buffer.
3520 If SHOW-ALL is non-nil, already read articles are also listed."
3522 (if (eq gnus-summary-buffer (current-buffer))
3523 (list (completing-read
3524 "Group: " gnus-active-hashtb nil t
3525 (when (and gnus-newsgroup-name
3526 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3527 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3528 'gnus-group-history)
3530 (error "%s must be invoked from a gnus summary buffer." this-command)))
3531 (unless (or (zerop (length group))
3532 (and gnus-newsgroup-name
3533 (string-equal gnus-newsgroup-name group)))
3535 (gnus-summary-read-group group show-all
3536 gnus-dont-select-after-jump-to-other-group)))
3538 (defun gnus-summary-read-group-1 (group show-all no-article
3539 kill-buffer no-display
3540 &optional select-articles)
3541 ;; Killed foreign groups can't be entered.
3542 ;; (when (and (not (gnus-group-native-p group))
3543 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3544 ;; (error "Dead non-native groups can't be entered"))
3545 (gnus-message 5 "Retrieving newsgroup: %s..."
3546 (gnus-group-decoded-name group))
3547 (let* ((new-group (gnus-summary-setup-buffer group))
3548 (quit-config (gnus-group-quit-config group))
3549 (did-select (and new-group (gnus-select-newsgroup
3550 group show-all select-articles))))
3552 ;; This summary buffer exists already, so we just select it.
3554 (gnus-set-global-variables)
3556 (gnus-kill-or-deaden-summary kill-buffer))
3557 (gnus-configure-windows 'summary 'force)
3558 (gnus-set-mode-line 'summary)
3559 (gnus-summary-position-point)
3562 ;; We couldn't select this group.
3564 (when (and (eq major-mode 'gnus-summary-mode)
3565 (not (equal (current-buffer) kill-buffer)))
3566 (kill-buffer (current-buffer))
3567 (if (not quit-config)
3569 ;; Update the info -- marks might need to be removed,
3571 (gnus-summary-update-info)
3572 (set-buffer gnus-group-buffer)
3573 (gnus-group-jump-to-group group)
3574 (gnus-group-next-unread-group 1))
3575 (gnus-handle-ephemeral-exit quit-config)))
3576 (let ((grpinfo (gnus-get-info group)))
3577 (if (null (gnus-info-read grpinfo))
3578 (gnus-message 3 "Group %s contains no messages"
3579 (gnus-group-decoded-name group))
3580 (gnus-message 3 "Can't select group")))
3582 ;; The user did a `C-g' while prompting for number of articles,
3583 ;; so we exit this group.
3584 ((eq did-select 'quit)
3585 (and (eq major-mode 'gnus-summary-mode)
3586 (not (equal (current-buffer) kill-buffer))
3587 (kill-buffer (current-buffer)))
3589 (gnus-kill-or-deaden-summary kill-buffer))
3590 (if (not quit-config)
3592 (set-buffer gnus-group-buffer)
3593 (gnus-group-jump-to-group group)
3594 (gnus-group-next-unread-group 1)
3595 (gnus-configure-windows 'group 'force))
3596 (gnus-handle-ephemeral-exit quit-config))
3597 ;; Finally signal the quit.
3599 ;; The group was successfully selected.
3601 (gnus-set-global-variables)
3602 ;; Save the active value in effect when the group was entered.
3603 (setq gnus-newsgroup-active
3605 (gnus-active gnus-newsgroup-name)))
3606 ;; You can change the summary buffer in some way with this hook.
3607 (gnus-run-hooks 'gnus-select-group-hook)
3608 (gnus-update-format-specifications
3609 nil 'summary 'summary-mode 'summary-dummy)
3610 (gnus-update-summary-mark-positions)
3611 ;; Do score processing.
3612 (when gnus-use-scoring
3613 (gnus-possibly-score-headers))
3614 ;; Check whether to fill in the gaps in the threads.
3615 (when gnus-build-sparse-threads
3616 (gnus-build-sparse-threads))
3617 ;; Find the initial limit.
3619 (let ((gnus-newsgroup-dormant nil))
3620 (gnus-summary-initial-limit show-all))
3621 (gnus-summary-initial-limit show-all))
3622 ;; Generate the summary buffer.
3624 (gnus-summary-prepare))
3625 (when gnus-use-trees
3626 (gnus-tree-open group)
3627 (setq gnus-summary-highlight-line-function
3628 'gnus-tree-highlight-article))
3629 ;; If the summary buffer is empty, but there are some low-scored
3630 ;; articles or some excluded dormants, we include these in the
3632 (when (and (zerop (buffer-size))
3634 (cond (gnus-newsgroup-dormant
3635 (gnus-summary-limit-include-dormant))
3636 ((and gnus-newsgroup-scored show-all)
3637 (gnus-summary-limit-include-expunged t))))
3638 ;; Function `gnus-apply-kill-file' must be called in this hook.
3639 (gnus-run-hooks 'gnus-apply-kill-hook)
3640 (if (and (zerop (buffer-size))
3643 ;; This newsgroup is empty.
3644 (gnus-summary-catchup-and-exit nil t)
3645 (gnus-message 6 "No unread news")
3647 (gnus-kill-or-deaden-summary kill-buffer))
3648 ;; Return nil from this function.
3650 ;; Hide conversation thread subtrees. We cannot do this in
3651 ;; gnus-summary-prepare-hook since kill processing may not
3652 ;; work with hidden articles.
3653 (gnus-summary-maybe-hide-threads)
3655 (gnus-kill-or-deaden-summary kill-buffer))
3656 (gnus-summary-auto-select-subject)
3657 ;; Show first unread article if requested.
3658 (if (and (not no-article)
3660 gnus-newsgroup-unreads
3661 gnus-auto-select-first)
3663 (gnus-configure-windows 'summary)
3664 (let ((art (gnus-summary-article-number)))
3665 (unless (and (not gnus-plugged)
3666 (or (memq art gnus-newsgroup-undownloaded)
3667 (memq art gnus-newsgroup-downloadable)))
3668 (gnus-summary-goto-article art))))
3669 ;; Don't select any articles.
3670 (gnus-summary-position-point)
3671 (gnus-configure-windows 'summary 'force)
3672 (gnus-set-mode-line 'summary))
3673 (when (and gnus-auto-center-group
3674 (get-buffer-window gnus-group-buffer t))
3675 ;; Gotta use windows, because recenter does weird stuff if
3676 ;; the current buffer ain't the displayed window.
3677 (let ((owin (selected-window)))
3678 (select-window (get-buffer-window gnus-group-buffer t))
3679 (when (gnus-group-goto-group group)
3681 (select-window owin)))
3682 ;; Mark this buffer as "prepared".
3683 (setq gnus-newsgroup-prepared t)
3684 (gnus-run-hooks 'gnus-summary-prepared-hook)
3685 (unless (gnus-ephemeral-group-p group)
3686 (gnus-group-update-group group))
3689 (defun gnus-summary-auto-select-subject ()
3690 "Select the subject line on initial group entry."
3691 (goto-char (point-min))
3693 ((eq gnus-auto-select-subject 'best)
3694 (gnus-summary-best-unread-subject))
3695 ((eq gnus-auto-select-subject 'unread)
3696 (gnus-summary-first-unread-subject))
3697 ((eq gnus-auto-select-subject 'unseen)
3698 (gnus-summary-first-unseen-subject))
3699 ((eq gnus-auto-select-subject 'unseen-or-unread)
3700 (gnus-summary-first-unseen-or-unread-subject))
3701 ((eq gnus-auto-select-subject 'first)
3704 ((functionp gnus-auto-select-subject)
3705 (funcall gnus-auto-select-subject))))
3707 (defun gnus-summary-prepare ()
3708 "Generate the summary buffer."
3710 (let ((buffer-read-only nil))
3712 (setq gnus-newsgroup-data nil
3713 gnus-newsgroup-data-reverse nil)
3714 (gnus-run-hooks 'gnus-summary-generate-hook)
3715 ;; Generate the buffer, either with threads or without.
3716 (when gnus-newsgroup-headers
3717 (gnus-summary-prepare-threads
3718 (if gnus-show-threads
3719 (gnus-sort-gathered-threads
3720 (funcall gnus-summary-thread-gathering-function
3722 (gnus-cut-threads (gnus-make-threads)))))
3723 ;; Unthreaded display.
3724 (gnus-sort-articles gnus-newsgroup-headers))))
3725 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3726 ;; Call hooks for modifying summary buffer.
3727 (goto-char (point-min))
3728 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3730 (defsubst gnus-general-simplify-subject (subject)
3731 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3734 ;; Truncate the subject.
3735 (gnus-simplify-subject-functions
3736 (gnus-map-function gnus-simplify-subject-functions subject))
3737 ((numberp gnus-summary-gather-subject-limit)
3738 (setq subject (gnus-simplify-subject-re subject))
3739 (if (> (length subject) gnus-summary-gather-subject-limit)
3740 (substring subject 0 gnus-summary-gather-subject-limit)
3742 ;; Fuzzily simplify it.
3743 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3744 (gnus-simplify-subject-fuzzy subject))
3745 ;; Just remove the leading "Re:".
3747 (gnus-simplify-subject-re subject))))
3749 (if (and gnus-summary-gather-exclude-subject
3750 (string-match gnus-summary-gather-exclude-subject subject))
3751 nil ; This article shouldn't be gathered
3754 (defun gnus-summary-simplify-subject-query ()
3755 "Query where the respool algorithm would put this article."
3757 (gnus-summary-select-article)
3759 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3761 (defun gnus-gather-threads-by-subject (threads)
3762 "Gather threads by looking at Subject headers."
3763 (if (not gnus-summary-make-false-root)
3765 (let ((hashtb (gnus-make-hashtable 1024))
3768 subject hthread whole-subject)
3770 (setq subject (gnus-general-simplify-subject
3771 (setq whole-subject (mail-header-subject
3774 (if (setq hthread (gnus-gethash subject hashtb))
3776 ;; We enter a dummy root into the thread, if we
3777 ;; haven't done that already.
3778 (unless (stringp (caar hthread))
3779 (setcar hthread (list whole-subject (car hthread))))
3780 ;; We add this new gathered thread to this gathered
3782 (setcdr (car hthread)
3783 (nconc (cdar hthread) (list (car threads))))
3784 ;; Remove it from the list of threads.
3785 (setcdr prev (cdr threads))
3786 (setq threads prev))
3787 ;; Enter this thread into the hash table.
3788 (gnus-sethash subject
3789 (if gnus-summary-make-false-root-always
3791 ;; If you want a dummy root above all
3793 (setcar threads (list whole-subject
3799 (setq threads (cdr threads)))
3802 (defun gnus-gather-threads-by-references (threads)
3803 "Gather threads by looking at References headers."
3804 (let ((idhashtb (gnus-make-hashtable 1024))
3805 (thhashtb (gnus-make-hashtable 1024))
3808 ids references id gthread gid entered ref)
3810 (when (setq references (mail-header-references (caar threads)))
3811 (setq id (mail-header-id (caar threads))
3812 ids (inline (gnus-split-references references))
3814 (while (setq ref (pop ids))
3815 (setq ids (delete ref ids))
3816 (if (not (setq gid (gnus-gethash ref idhashtb)))
3818 (gnus-sethash ref id idhashtb)
3819 (gnus-sethash id threads thhashtb))
3820 (setq gthread (gnus-gethash gid thhashtb))
3822 ;; We enter a dummy root into the thread, if we
3823 ;; haven't done that already.
3824 (unless (stringp (caar gthread))
3825 (setcar gthread (list (mail-header-subject (caar gthread))
3827 ;; We add this new gathered thread to this gathered
3829 (setcdr (car gthread)
3830 (nconc (cdar gthread) (list (car threads)))))
3831 ;; Add it into the thread hash table.
3832 (gnus-sethash id gthread thhashtb)
3834 ;; Remove it from the list of threads.
3835 (setcdr prev (cdr threads))
3836 (setq threads prev))))
3838 (setq threads (cdr threads)))
3841 (defun gnus-sort-gathered-threads (threads)
3842 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3843 (let ((result threads))
3845 (when (stringp (caar threads))
3846 (setcdr (car threads)
3847 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3848 (setq threads (cdr threads)))
3851 (defun gnus-thread-loop-p (root thread)
3852 "Say whether ROOT is in THREAD."
3853 (let ((stack (list thread))
3856 (while (setq thread (pop stack))
3857 (setq th (cdr thread))
3859 (not (eq (caar th) root)))
3862 ;; We have found a loop.
3864 (setcdr thread (delq (car th) (cdr thread)))
3865 (if (boundp (setq ref-dep (intern "none"
3866 gnus-newsgroup-dependencies)))
3867 (setcdr (symbol-value ref-dep)
3868 (nconc (cdr (symbol-value ref-dep))
3870 (set ref-dep (list nil (car th))))
3873 ;; Push all the subthreads onto the stack.
3874 (push (cdr thread) stack)))
3877 (defun gnus-make-threads ()
3878 "Go through the dependency hashtb and find the roots. Return all threads."
3880 (while (catch 'infloop
3883 ;; Deal with self-referencing References loops.
3884 (when (and (car (symbol-value refs))
3891 (car (symbol-value refs)) thread))
3892 (cdr (symbol-value refs)))))))
3895 (unless (car (symbol-value refs))
3896 ;; These threads do not refer back to any other articles,
3897 ;; so they're roots.
3898 (setq threads (append (cdr (symbol-value refs)) threads))))
3899 gnus-newsgroup-dependencies)))
3902 ;; Build the thread tree.
3903 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3904 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3906 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3907 if it was already present.
3909 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3910 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3911 Message-IDs will be renamed to a unique Message-ID before being
3914 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3915 (let* ((id (mail-header-id header))
3916 (id-dep (and id (intern id dependencies)))
3917 parent-id ref ref-dep ref-header replaced)
3918 ;; Enter this `header' in the `dependencies' table.
3922 ;; The first two cases do the normal part: enter a new `header'
3923 ;; in the `dependencies' table.
3924 ((not (boundp id-dep))
3925 (set id-dep (list header)))
3926 ((null (car (symbol-value id-dep)))
3927 (setcar (symbol-value id-dep) header))
3929 ;; From here the `header' was already present in the
3930 ;; `dependencies' table.
3932 ;; Overrides an existing entry;
3933 ;; just set the header part of the entry.
3934 (setcar (symbol-value id-dep) header)
3937 ;; Renames the existing `header' to a unique Message-ID.
3938 ((not gnus-summary-ignore-duplicates)
3939 ;; An article with this Message-ID has already been seen.
3940 ;; We rename the Message-ID.
3941 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3943 (mail-header-set-id header id))
3945 ;; The last case ignores an existing entry, except it adds any
3946 ;; additional Xrefs (in case the two articles came from different
3948 ;; Also sets `header' to `nil' meaning that the `dependencies'
3949 ;; table was *not* modified.
3951 (mail-header-set-xref
3952 (car (symbol-value id-dep))
3953 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3955 (or (mail-header-xref header) "")))
3958 (when (and header (not replaced))
3959 ;; First check that we are not creating a References loop.
3960 (setq parent-id (gnus-parent-id (mail-header-references header)))
3961 (setq ref parent-id)
3963 (setq ref-dep (intern-soft ref dependencies))
3965 (setq ref-header (car (symbol-value ref-dep))))
3966 (if (string= id ref)
3967 ;; Yuk! This is a reference loop. Make the article be a
3970 (mail-header-set-references (car (symbol-value id-dep)) "none")
3972 (setq parent-id nil))
3973 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3974 (setq ref-dep (intern (or parent-id "none") dependencies))
3975 (if (boundp ref-dep)
3976 (setcdr (symbol-value ref-dep)
3977 (nconc (cdr (symbol-value ref-dep))
3978 (list (symbol-value id-dep))))
3979 (set ref-dep (list nil (symbol-value id-dep)))))
3982 (defun gnus-extract-message-id-from-in-reply-to (string)
3983 (if (string-match "<[^>]+>" string)
3984 (substring string (match-beginning 0) (match-end 0))
3987 (defun gnus-build-sparse-threads ()
3988 (let ((headers gnus-newsgroup-headers)
3989 (mail-parse-charset gnus-newsgroup-charset)
3990 (gnus-summary-ignore-duplicates t)
3991 header references generation relations
3992 subject child end new-child date)
3993 ;; First we create an alist of generations/relations, where
3994 ;; generations is how much we trust the relation, and the relation
3996 (gnus-message 7 "Making sparse threads...")
3998 (nnheader-set-temp-buffer " *gnus sparse threads*")
3999 (while (setq header (pop headers))
4000 (when (and (setq references (mail-header-references header))
4001 (not (string= references "")))
4003 (setq child (mail-header-id header)
4004 subject (mail-header-subject header)
4005 date (mail-header-date header)
4007 (while (search-backward ">" nil t)
4008 (setq end (1+ (point)))
4009 (when (search-backward "<" nil t)
4010 (setq new-child (buffer-substring (point) end))
4011 (push (list (incf generation)
4012 child (setq child new-child)
4016 (push (list (1+ generation) child nil subject) relations))
4018 (kill-buffer (current-buffer)))
4019 ;; Sort over trustworthiness.
4022 (when (gnus-dependencies-add-header
4023 (make-full-mail-header-from-decoded-header
4024 gnus-reffed-article-number
4025 (nth 3 relation) "" (or (nth 4 relation) "")
4027 (or (nth 2 relation) "") 0 0 "")
4028 gnus-newsgroup-dependencies nil)
4029 (push gnus-reffed-article-number gnus-newsgroup-limit)
4030 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4031 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4032 gnus-newsgroup-reads)
4033 (decf gnus-reffed-article-number)))
4034 (sort relations 'car-less-than-car))
4035 (gnus-message 7 "Making sparse threads...done")))
4037 (defun gnus-build-old-threads ()
4038 ;; Look at all the articles that refer back to old articles, and
4039 ;; fetch the headers for the articles that aren't there. This will
4040 ;; build complete threads - if the roots haven't been expired by the
4042 (let ((mail-parse-charset gnus-newsgroup-charset)
4046 (when (not (car (symbol-value refs)))
4047 (setq heads (cdr (symbol-value refs)))
4049 (if (memq (mail-header-number (caar heads))
4050 gnus-newsgroup-dormant)
4051 (setq heads (cdr heads))
4052 (setq id (symbol-name refs))
4053 (while (and (setq id (gnus-build-get-header id))
4054 (not (car (gnus-id-to-thread id)))))
4055 (setq heads nil)))))
4056 gnus-newsgroup-dependencies)))
4058 (defsubst gnus-remove-odd-characters (string)
4059 "Translate STRING into something that doesn't contain weird characters."
4060 (mm-subst-char-in-string
4062 (mm-subst-char-in-string ?\n ?\- string t) t))
4064 ;; This function has to be called with point after the article number
4065 ;; on the beginning of the line.
4066 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4067 (let ((eol (point-at-eol))
4068 (buffer (current-buffer))
4069 header references in-reply-to)
4071 ;; overview: [num subject from date id refs chars lines misc]
4074 (narrow-to-region (point) eol)
4079 (make-full-mail-header
4081 (nnheader-nov-field) ; subject
4082 (nnheader-nov-field) ; from
4083 (nnheader-nov-field) ; date
4084 (nnheader-nov-read-message-id number) ; id
4085 (setq references (nnheader-nov-field)) ; refs
4086 (nnheader-nov-read-integer) ; chars
4087 (nnheader-nov-read-integer) ; lines
4089 (if (looking-at "Xref: ")
4090 (goto-char (match-end 0)))
4091 (nnheader-nov-field)) ; Xref
4092 (nnheader-nov-parse-extra)))) ; extra
4096 (when (and (string= references "")
4097 (setq in-reply-to (mail-header-extra header))
4098 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4099 (mail-header-set-references
4100 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4102 (when gnus-alter-header-function
4103 (funcall gnus-alter-header-function header))
4104 (gnus-dependencies-add-header header dependencies force-new)))
4106 (defun gnus-build-get-header (id)
4107 "Look through the buffer of NOV lines and find the header to ID.
4108 Enter this line into the dependencies hash table, and return
4109 the id of the parent article (if any)."
4110 (let ((deps gnus-newsgroup-dependencies)
4114 (set-buffer nntp-server-buffer)
4115 (let ((case-fold-search nil))
4116 (goto-char (point-min))
4117 (while (and (not found)
4118 (search-forward id nil t))
4120 (setq found (looking-at
4121 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4122 (regexp-quote id))))
4123 (or found (beginning-of-line 2)))
4127 (setq header (gnus-nov-parse-line
4128 (read (current-buffer)) deps))
4129 (gnus-parent-id (mail-header-references header))))))
4131 (let ((number (mail-header-number header)))
4132 (push number gnus-newsgroup-limit)
4133 (push header gnus-newsgroup-headers)
4134 (if (memq number gnus-newsgroup-unselected)
4136 (setq gnus-newsgroup-unreads
4137 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4139 (setq gnus-newsgroup-unselected
4140 (delq number gnus-newsgroup-unselected)))
4141 (push number gnus-newsgroup-ancient)))))))
4143 (defun gnus-build-all-threads ()
4144 "Read all the headers."
4145 (let ((gnus-summary-ignore-duplicates t)
4146 (mail-parse-charset gnus-newsgroup-charset)
4147 (dependencies gnus-newsgroup-dependencies)
4150 (set-buffer nntp-server-buffer)
4151 (let ((case-fold-search nil))
4152 (goto-char (point-min))
4155 (setq article (read (current-buffer))
4156 header (gnus-nov-parse-line article dependencies)))
4158 (with-current-buffer gnus-summary-buffer
4159 (push header gnus-newsgroup-headers)
4160 (if (memq (setq article (mail-header-number header))
4161 gnus-newsgroup-unselected)
4163 (setq gnus-newsgroup-unreads
4164 (gnus-add-to-sorted-list
4165 gnus-newsgroup-unreads article))
4166 (setq gnus-newsgroup-unselected
4167 (delq article gnus-newsgroup-unselected)))
4168 (push article gnus-newsgroup-ancient)))
4169 (forward-line 1)))))))
4171 (defun gnus-summary-update-article-line (article header)
4172 "Update the line for ARTICLE using HEADER."
4173 (let* ((id (mail-header-id header))
4174 (thread (gnus-id-to-thread id)))
4176 (error "Article in no thread"))
4177 ;; Update the thread.
4178 (setcar thread header)
4179 (gnus-summary-goto-subject article)
4180 (let* ((datal (gnus-data-find-list article))
4182 (buffer-read-only nil)
4183 (level (gnus-summary-thread-level)))
4185 (let ((inserted (- (point)
4187 (gnus-summary-insert-line
4189 (memq article gnus-newsgroup-undownloaded)
4190 (gnus-article-mark article)
4191 (memq article gnus-newsgroup-replied)
4192 (memq article gnus-newsgroup-expirable)
4193 ;; Only insert the Subject string when it's different
4194 ;; from the previous Subject string.
4199 (mail-header-subject
4202 (gnus-data-find-list
4204 (gnus-data-list t)))))
4205 ;; Error on the side of excessive subjects.
4207 (mail-header-subject header)))
4209 (mail-header-subject header))
4210 nil (cdr (assq article gnus-newsgroup-scored))
4211 (memq article gnus-newsgroup-processable))
4214 (gnus-data-update-list
4216 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4218 (defun gnus-summary-update-article (article &optional iheader)
4219 "Update ARTICLE in the summary buffer."
4220 (set-buffer gnus-summary-buffer)
4221 (let* ((header (gnus-summary-article-header article))
4222 (id (mail-header-id header))
4223 (data (gnus-data-find article))
4224 (thread (gnus-id-to-thread id))
4225 (references (mail-header-references header))
4229 (when (and references
4230 (not (equal "" references)))
4233 (buffer-read-only nil)
4239 (delq thread parent)))
4240 (if (gnus-summary-insert-subject id header)
4241 ;; Set the (possibly) new article number in the data structure.
4242 (gnus-data-set-number data (gnus-id-to-article id))
4246 (defun gnus-rebuild-thread (id &optional line)
4247 "Rebuild the thread containing ID.
4248 If LINE, insert the rebuilt thread starting on line LINE."
4249 (let ((buffer-read-only nil)
4250 old-pos current thread data)
4251 (if (not gnus-show-threads)
4252 (setq thread (list (car (gnus-id-to-thread id))))
4253 ;; Get the thread this article is part of.
4254 (setq thread (gnus-remove-thread id)))
4255 (setq old-pos (point-at-bol))
4256 (setq current (save-excursion
4257 (and (re-search-backward "[\r\n]" nil t)
4258 (gnus-summary-article-number))))
4259 ;; If this is a gathered thread, we have to go some re-gathering.
4260 (when (stringp (car thread))
4261 (let ((subject (car thread))
4263 (setq thread (cdr thread))
4265 (unless (memq (setq thr (gnus-id-to-thread
4267 (mail-header-id (caar thread)))))
4270 (setq thread (cdr thread)))
4271 ;; We now have all (unique) roots.
4272 (if (= (length roots) 1)
4273 ;; All the loose roots are now one solid root.
4274 (setq thread (car roots))
4275 (setq thread (cons subject (gnus-sort-threads roots))))))
4277 ;; We then insert this thread into the summary buffer.
4279 (goto-char (point-min))
4280 (forward-line (1- line)))
4281 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4282 (if gnus-show-threads
4283 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4284 (gnus-summary-prepare-unthreaded thread))
4285 (setq data (nreverse gnus-newsgroup-data))
4286 (setq threads gnus-newsgroup-threads))
4287 ;; We splice the new data into the data structure.
4288 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4289 ;;!!! then we want to insert at the beginning of the buffer.
4290 ;;!!! That happens to be true with Gnus now, but that may
4291 ;;!!! change in the future. Perhaps.
4292 (gnus-data-enter-list
4293 (if line nil current) data (- (point) old-pos))
4294 (setq gnus-newsgroup-threads
4295 (nconc threads gnus-newsgroup-threads))
4296 (gnus-data-compute-positions))))
4298 (defun gnus-number-to-header (number)
4299 "Return the header for article NUMBER."
4300 (let ((headers gnus-newsgroup-headers))
4302 (not (= number (mail-header-number (car headers)))))
4307 (defun gnus-parent-headers (in-headers &optional generation)
4308 "Return the headers of the GENERATIONeth parent of HEADERS."
4310 (setq generation 1))
4312 (headers in-headers)
4315 (not (zerop generation))
4316 (setq references (mail-header-references headers)))
4317 (setq headers (if (and references
4318 (setq parent (gnus-parent-id references)))
4319 (car (gnus-id-to-thread parent))
4322 (and (not (eq headers in-headers))
4325 (defun gnus-id-to-thread (id)
4326 "Return the (sub-)thread where ID appears."
4327 (gnus-gethash id gnus-newsgroup-dependencies))
4329 (defun gnus-id-to-article (id)
4330 "Return the article number of ID."
4331 (let ((thread (gnus-id-to-thread id)))
4334 (mail-header-number (car thread)))))
4336 (defun gnus-id-to-header (id)
4337 "Return the article headers of ID."
4338 (car (gnus-id-to-thread id)))
4340 (defun gnus-article-displayed-root-p (article)
4341 "Say whether ARTICLE is a root(ish) article."
4342 (let ((level (gnus-summary-thread-level article))
4343 (refs (mail-header-references (gnus-summary-article-header article)))
4349 ((null (gnus-parent-id refs)) t)
4351 (null (setq particle (gnus-id-to-article
4352 (gnus-parent-id refs))))
4353 (null (gnus-summary-thread-level particle)))))))
4355 (defun gnus-root-id (id)
4356 "Return the id of the root of the thread where ID appears."
4358 (while (and id (setq prev (car (gnus-id-to-thread id))))
4360 id (gnus-parent-id (mail-header-references prev))))
4363 (defun gnus-articles-in-thread (thread)
4364 "Return the list of articles in THREAD."
4365 (cons (mail-header-number (car thread))
4366 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4368 (defun gnus-remove-thread (id &optional dont-remove)
4369 "Remove the thread that has ID in it."
4370 (let (headers thread last-id)
4371 ;; First go up in this thread until we find the root.
4372 (setq last-id (gnus-root-id id)
4373 headers (message-flatten-list (gnus-id-to-thread last-id)))
4374 ;; We have now found the real root of this thread. It might have
4375 ;; been gathered into some loose thread, so we have to search
4376 ;; through the threads to find the thread we wanted.
4377 (let ((threads gnus-newsgroup-threads)
4380 (setq sub (car threads))
4381 (if (stringp (car sub))
4382 ;; This is a gathered thread, so we look at the roots
4383 ;; below it to find whether this article is in this
4386 (setq sub (cdr sub))
4388 (when (member (caar sub) headers)
4389 (setq thread (car threads)
4392 (setq sub (cdr sub))))
4393 ;; It's an ordinary thread, so we check it.
4394 (when (eq (car sub) (car headers))
4397 (setq threads (cdr threads)))
4398 ;; If this article is in no thread, then it's a root.
4401 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4402 (setq thread (gnus-id-to-thread last-id)))
4405 thread ; We return this thread.
4407 (if (stringp (car thread))
4409 ;; If we use dummy roots, then we have to remove the
4410 ;; dummy root as well.
4411 (when (eq gnus-summary-make-false-root 'dummy)
4412 ;; We go to the dummy root by going to
4413 ;; the first sub-"thread", and then one line up.
4414 (gnus-summary-goto-article
4415 (mail-header-number (caadr thread)))
4418 (gnus-data-compute-positions))
4419 (setq thread (cdr thread))
4421 (gnus-remove-thread-1 (car thread))
4422 (setq thread (cdr thread))))
4423 (gnus-remove-thread-1 thread))))))))
4425 (defun gnus-remove-thread-1 (thread)
4426 "Remove the thread THREAD recursively."
4427 (let ((number (mail-header-number (pop thread)))
4429 (setq thread (reverse thread))
4431 (gnus-remove-thread-1 (pop thread)))
4432 (when (setq d (gnus-data-find number))
4433 (goto-char (gnus-data-pos d))
4434 (gnus-summary-show-thread)
4440 (gnus-delete-line)))))))
4442 (defun gnus-sort-threads-1 (threads func)
4443 (sort (mapcar (lambda (thread)
4446 (gnus-sort-threads-1 (cdr thread) func))))
4449 (defun gnus-sort-threads (threads)
4451 (if (not gnus-thread-sort-functions)
4453 (gnus-message 8 "Sorting threads...")
4454 (let ((max-lisp-eval-depth 5000))
4455 (prog1 (gnus-sort-threads-1
4457 (gnus-make-sort-function gnus-thread-sort-functions))
4458 (gnus-message 8 "Sorting threads...done")))))
4460 (defun gnus-sort-articles (articles)
4462 (when gnus-article-sort-functions
4463 (gnus-message 7 "Sorting articles...")
4465 (setq gnus-newsgroup-headers
4466 (sort articles (gnus-make-sort-function
4467 gnus-article-sort-functions)))
4468 (gnus-message 7 "Sorting articles...done"))))
4470 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4471 (defmacro gnus-thread-header (thread)
4472 "Return header of first article in THREAD.
4473 Note that THREAD must never, ever be anything else than a variable -
4474 using some other form will lead to serious barfage."
4475 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4476 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4477 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4480 (defsubst gnus-article-sort-by-number (h1 h2)
4481 "Sort articles by article number."
4482 (< (mail-header-number h1)
4483 (mail-header-number h2)))
4485 (defun gnus-thread-sort-by-number (h1 h2)
4486 "Sort threads by root article number."
4487 (gnus-article-sort-by-number
4488 (gnus-thread-header h1) (gnus-thread-header h2)))
4490 (defsubst gnus-article-sort-by-random (h1 h2)
4491 "Sort articles by article number."
4494 (defun gnus-thread-sort-by-random (h1 h2)
4495 "Sort threads by root article number."
4496 (gnus-article-sort-by-random
4497 (gnus-thread-header h1) (gnus-thread-header h2)))
4499 (defsubst gnus-article-sort-by-lines (h1 h2)
4500 "Sort articles by article Lines header."
4501 (< (mail-header-lines h1)
4502 (mail-header-lines h2)))
4504 (defun gnus-thread-sort-by-lines (h1 h2)
4505 "Sort threads by root article Lines header."
4506 (gnus-article-sort-by-lines
4507 (gnus-thread-header h1) (gnus-thread-header h2)))
4509 (defsubst gnus-article-sort-by-chars (h1 h2)
4510 "Sort articles by octet length."
4511 (< (mail-header-chars h1)
4512 (mail-header-chars h2)))
4514 (defun gnus-thread-sort-by-chars (h1 h2)
4515 "Sort threads by root article octet length."
4516 (gnus-article-sort-by-chars
4517 (gnus-thread-header h1) (gnus-thread-header h2)))
4519 (defsubst gnus-article-sort-by-author (h1 h2)
4520 "Sort articles by root author."
4522 (let ((addr (car (mime-entity-read-field h1 'From))))
4523 (or (std11-full-name-string addr)
4524 (std11-address-string addr)
4526 (let ((addr (car (mime-entity-read-field h2 'From))))
4527 (or (std11-full-name-string addr)
4528 (std11-address-string addr)
4532 (defun gnus-thread-sort-by-author (h1 h2)
4533 "Sort threads by root author."
4534 (gnus-article-sort-by-author
4535 (gnus-thread-header h1) (gnus-thread-header h2)))
4537 (defsubst gnus-article-sort-by-subject (h1 h2)
4538 "Sort articles by root subject."
4540 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4541 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4543 (defun gnus-thread-sort-by-subject (h1 h2)
4544 "Sort threads by root subject."
4545 (gnus-article-sort-by-subject
4546 (gnus-thread-header h1) (gnus-thread-header h2)))
4548 (defsubst gnus-article-sort-by-date (h1 h2)
4549 "Sort articles by root article date."
4551 (gnus-date-get-time (mail-header-date h1))
4552 (gnus-date-get-time (mail-header-date h2))))
4554 (defun gnus-thread-sort-by-date (h1 h2)
4555 "Sort threads by root article date."
4556 (gnus-article-sort-by-date
4557 (gnus-thread-header h1) (gnus-thread-header h2)))
4559 (defsubst gnus-article-sort-by-score (h1 h2)
4560 "Sort articles by root article score.
4561 Unscored articles will be counted as having a score of zero."
4562 (> (or (cdr (assq (mail-header-number h1)
4563 gnus-newsgroup-scored))
4564 gnus-summary-default-score 0)
4565 (or (cdr (assq (mail-header-number h2)
4566 gnus-newsgroup-scored))
4567 gnus-summary-default-score 0)))
4569 (defun gnus-thread-sort-by-score (h1 h2)
4570 "Sort threads by root article score."
4571 (gnus-article-sort-by-score
4572 (gnus-thread-header h1) (gnus-thread-header h2)))
4574 (defun gnus-thread-sort-by-total-score (h1 h2)
4575 "Sort threads by the sum of all scores in the thread.
4576 Unscored articles will be counted as having a score of zero."
4577 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4579 (defun gnus-thread-total-score (thread)
4580 ;; This function find the total score of THREAD.
4585 (if (stringp (car thread))
4586 (apply gnus-thread-score-function 0
4587 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4588 (gnus-thread-total-score-1 thread)))
4590 (gnus-thread-total-score-1 (list thread)))))
4592 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4593 "Sort threads such that the thread with the most recently arrived article comes first."
4594 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4596 (defun gnus-thread-highest-number (thread)
4597 "Return the highest article number in THREAD."
4598 (apply 'max (mapcar (lambda (header)
4599 (mail-header-number header))
4600 (message-flatten-list thread))))
4602 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4603 "Sort threads such that the thread with the most recently dated article comes first."
4604 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4606 (defun gnus-thread-latest-date (thread)
4607 "Return the highest article date in THREAD."
4608 (let ((previous-time 0))
4614 (time-to-seconds (mail-header-parse-date
4615 (mail-header-date header)))
4616 (error previous-time))))
4618 (message-flatten-list thread)
4620 (< (mail-header-number h1)
4621 (mail-header-number h2))))))))
4623 (defun gnus-thread-total-score-1 (root)
4624 ;; This function find the total score of the thread below ROOT.
4625 (setq root (car root))
4626 (apply gnus-thread-score-function
4628 (mapcar 'gnus-thread-total-score
4629 (cdr (gnus-id-to-thread (mail-header-id root))))
4630 (when (> (mail-header-number root) 0)
4631 (list (or (cdr (assq (mail-header-number root)
4632 gnus-newsgroup-scored))
4633 gnus-summary-default-score 0))))
4634 (list gnus-summary-default-score)
4637 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4638 (defvar gnus-tmp-prev-subject nil)
4639 (defvar gnus-tmp-false-parent nil)
4640 (defvar gnus-tmp-root-expunged nil)
4641 (defvar gnus-tmp-dummy-line nil)
4643 (eval-when-compile (defvar gnus-tmp-header))
4644 (defun gnus-extra-header (type &optional header)
4645 "Return the extra header of TYPE."
4646 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4649 (defvar gnus-tmp-thread-tree-header-string "")
4651 (defcustom gnus-sum-thread-tree-root "> "
4652 "With %B spec, used for the root of a thread.
4653 If nil, use subject instead."
4655 :type '(radio (const :format "%v " nil) (string :size 0))
4656 :group 'gnus-thread)
4657 (defcustom gnus-sum-thread-tree-false-root "> "
4658 "With %B spec, used for a false root of a thread.
4659 If nil, use subject instead."
4661 :type '(radio (const :format "%v " nil) (string :size 0))
4662 :group 'gnus-thread)
4663 (defcustom gnus-sum-thread-tree-single-indent ""
4664 "With %B spec, used for a thread with just one message.
4665 If nil, use subject instead."
4667 :type '(radio (const :format "%v " nil) (string :size 0))
4668 :group 'gnus-thread)
4669 (defcustom gnus-sum-thread-tree-vertical "| "
4670 "With %B spec, used for drawing a vertical line."
4673 :group 'gnus-thread)
4674 (defcustom gnus-sum-thread-tree-indent " "
4675 "With %B spec, used for indenting."
4678 :group 'gnus-thread)
4679 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4680 "With %B spec, used for a leaf with brothers."
4683 :group 'gnus-thread)
4684 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4685 "With %B spec, used for a leaf without brothers."
4688 :group 'gnus-thread)
4690 (defun gnus-summary-prepare-threads (threads)
4691 "Prepare summary buffer from THREADS and indentation LEVEL.
4692 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4693 or a straight list of headers."
4694 (gnus-message 7 "Generating summary...")
4696 (setq gnus-newsgroup-threads threads)
4699 (let ((gnus-tmp-level 0)
4700 (default-score (or gnus-summary-default-score 0))
4701 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4702 (building-line-count gnus-summary-display-while-building)
4703 (building-count (integerp gnus-summary-display-while-building))
4704 thread number subject stack state gnus-tmp-gathered beg-match
4705 new-roots gnus-tmp-new-adopts thread-end simp-subject
4706 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4707 gnus-tmp-replied gnus-tmp-subject-or-nil
4708 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4709 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4710 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4713 (setq gnus-tmp-prev-subject nil
4714 gnus-tmp-thread-tree-header-string "")
4716 (if (vectorp (car threads))
4717 ;; If this is a straight (sic) list of headers, then a
4718 ;; threaded summary display isn't required, so we just create
4719 ;; an unthreaded one.
4720 (gnus-summary-prepare-unthreaded threads)
4722 ;; Do the threaded display.
4724 (if gnus-summary-display-while-building
4725 (switch-to-buffer (buffer-name)))
4726 (while (or threads stack gnus-tmp-new-adopts new-roots)
4728 (if (and (= gnus-tmp-level 0)
4731 (not gnus-tmp-false-parent)
4732 (or gnus-tmp-new-adopts new-roots))
4733 (if gnus-tmp-new-adopts
4734 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4735 thread (list (car gnus-tmp-new-adopts))
4736 gnus-tmp-header (caar thread)
4737 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4739 (setq thread (list (car new-roots))
4740 gnus-tmp-header (caar thread)
4741 new-roots (cdr new-roots))))
4744 ;; If there are some threads, we do them before the
4745 ;; threads on the stack.
4746 (setq thread threads
4747 gnus-tmp-header (caar thread))
4748 ;; There were no current threads, so we pop something off
4750 (setq state (car stack)
4751 gnus-tmp-level (car state)
4752 tree-stack (cadr state)
4753 thread (caddr state)
4755 gnus-tmp-header (caar thread))))
4757 (setq gnus-tmp-false-parent nil)
4758 (setq gnus-tmp-root-expunged nil)
4759 (setq thread-end nil)
4761 (if (stringp gnus-tmp-header)
4762 ;; The header is a dummy root.
4764 ((eq gnus-summary-make-false-root 'adopt)
4765 ;; We let the first article adopt the rest.
4766 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4768 (setq gnus-tmp-gathered
4770 (lambda (h) (mail-header-number (car h)))
4773 (setq thread (cons (list (caar thread)
4776 (setq gnus-tmp-level -1
4777 gnus-tmp-false-parent t))
4778 ((eq gnus-summary-make-false-root 'empty)
4779 ;; We print adopted articles with empty subject fields.
4780 (setq gnus-tmp-gathered
4782 (lambda (h) (mail-header-number (car h)))
4785 (setq gnus-tmp-level -1))
4786 ((eq gnus-summary-make-false-root 'dummy)
4787 ;; We remember that we probably want to output a dummy
4789 (setq gnus-tmp-dummy-line gnus-tmp-header)
4790 (setq gnus-tmp-prev-subject gnus-tmp-header))
4792 ;; We do not make a root for the gathered
4793 ;; sub-threads at all.
4794 (setq gnus-tmp-level -1)))
4796 (setq number (mail-header-number gnus-tmp-header)
4797 subject (mail-header-subject gnus-tmp-header)
4798 simp-subject (gnus-simplify-subject-fully subject))
4801 ;; If the thread has changed subject, we might want to make
4802 ;; this subthread into a root.
4803 ((and (null gnus-thread-ignore-subject)
4804 (not (zerop gnus-tmp-level))
4805 gnus-tmp-prev-subject
4806 (not (string= gnus-tmp-prev-subject simp-subject)))
4807 (setq new-roots (nconc new-roots (list (car thread)))
4809 gnus-tmp-header nil))
4810 ;; If the article lies outside the current limit,
4811 ;; then we do not display it.
4812 ((not (memq number gnus-newsgroup-limit))
4813 (setq gnus-tmp-gathered
4815 (lambda (h) (mail-header-number (car h)))
4818 (setq gnus-tmp-new-adopts (if (cdar thread)
4819 (append gnus-tmp-new-adopts
4821 gnus-tmp-new-adopts)
4823 gnus-tmp-header nil)
4824 (when (zerop gnus-tmp-level)
4825 (setq gnus-tmp-root-expunged t)))
4826 ;; Perhaps this article is to be marked as read?
4827 ((and gnus-summary-mark-below
4828 (< (or (cdr (assq number gnus-newsgroup-scored))
4830 gnus-summary-mark-below)
4831 ;; Don't touch sparse articles.
4832 (not (gnus-summary-article-sparse-p number))
4833 (not (gnus-summary-article-ancient-p number)))
4834 (setq gnus-newsgroup-unreads
4835 (delq number gnus-newsgroup-unreads))
4836 (if gnus-newsgroup-auto-expire
4837 (setq gnus-newsgroup-expirable
4838 (gnus-add-to-sorted-list
4839 gnus-newsgroup-expirable number))
4840 (push (cons number gnus-low-score-mark)
4841 gnus-newsgroup-reads))))
4843 (when gnus-tmp-header
4844 ;; We may have an old dummy line to output before this
4846 (when (and gnus-tmp-dummy-line
4849 (mail-header-subject gnus-tmp-header)))
4850 (gnus-summary-insert-dummy-line
4851 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4852 (setq gnus-tmp-dummy-line nil))
4854 ;; Compute the mark.
4855 (setq gnus-tmp-unread (gnus-article-mark number))
4857 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4858 gnus-tmp-header gnus-tmp-level)
4859 gnus-newsgroup-data)
4861 ;; Actually insert the line.
4863 gnus-tmp-subject-or-nil
4865 ((and gnus-thread-ignore-subject
4866 gnus-tmp-prev-subject
4867 (not (string= gnus-tmp-prev-subject simp-subject)))
4869 ((zerop gnus-tmp-level)
4870 (if (and (eq gnus-summary-make-false-root 'empty)
4871 (memq number gnus-tmp-gathered)
4872 gnus-tmp-prev-subject
4873 (string= gnus-tmp-prev-subject simp-subject))
4874 gnus-summary-same-subject
4876 (t gnus-summary-same-subject)))
4877 (if (and (eq gnus-summary-make-false-root 'adopt)
4878 (= gnus-tmp-level 1)
4879 (memq number gnus-tmp-gathered))
4880 (setq gnus-tmp-opening-bracket ?\<
4881 gnus-tmp-closing-bracket ?\>)
4882 (setq gnus-tmp-opening-bracket ?\[
4883 gnus-tmp-closing-bracket ?\]))
4885 gnus-tmp-indentation
4886 (aref gnus-thread-indent-array gnus-tmp-level)
4887 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4888 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4889 gnus-summary-default-score 0)
4891 (if (or (null gnus-summary-default-score)
4892 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4893 gnus-summary-zcore-fuzz))
4895 (if (< gnus-tmp-score gnus-summary-default-score)
4896 gnus-score-below-mark gnus-score-over-mark))
4898 (cond ((memq number gnus-newsgroup-processable)
4900 ((memq number gnus-newsgroup-cached)
4902 ((memq number gnus-newsgroup-replied)
4904 ((memq number gnus-newsgroup-forwarded)
4905 gnus-forwarded-mark)
4906 ((memq number gnus-newsgroup-saved)
4908 ((memq number gnus-newsgroup-recent)
4910 ((memq number gnus-newsgroup-unseen)
4914 (cond ((memq number gnus-newsgroup-undownloaded)
4915 gnus-undownloaded-mark)
4916 (gnus-newsgroup-agentized
4917 gnus-downloaded-mark)
4920 gnus-tmp-from (mail-header-from gnus-tmp-header)
4923 ((string-match "<[^>]+> *$" gnus-tmp-from)
4924 (setq beg-match (match-beginning 0))
4925 (or (and (string-match "^\".+\"" gnus-tmp-from)
4926 (substring gnus-tmp-from 1 (1- (match-end 0))))
4927 (substring gnus-tmp-from 0 beg-match)))
4928 ((string-match "(.+)" gnus-tmp-from)
4929 (substring gnus-tmp-from
4930 (1+ (match-beginning 0)) (1- (match-end 0))))
4934 gnus-tmp-thread-tree-header-string
4936 ((not gnus-show-threads) "")
4937 ((zerop gnus-tmp-level)
4938 (cond ((cdar thread)
4939 (or gnus-sum-thread-tree-root subject))
4940 (gnus-tmp-new-adopts
4941 (or gnus-sum-thread-tree-false-root subject))
4943 (or gnus-sum-thread-tree-single-indent subject))))
4945 (concat (apply 'concat
4946 (mapcar (lambda (item)
4948 gnus-sum-thread-tree-vertical
4949 gnus-sum-thread-tree-indent))
4950 (cdr (reverse tree-stack))))
4952 gnus-sum-thread-tree-leaf-with-other
4953 gnus-sum-thread-tree-single-leaf)))))
4954 (when (string= gnus-tmp-name "")
4955 (setq gnus-tmp-name gnus-tmp-from))
4956 (unless (numberp gnus-tmp-lines)
4957 (setq gnus-tmp-lines -1))
4958 (if (= gnus-tmp-lines -1)
4959 (setq gnus-tmp-lines "?")
4960 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4961 (gnus-put-text-property
4963 (progn (eval gnus-summary-line-format-spec) (point))
4964 'gnus-number number)
4967 (gnus-run-hooks 'gnus-summary-update-hook)
4970 (setq gnus-tmp-prev-subject simp-subject)))
4972 (when (nth 1 thread)
4973 (push (list (max 0 gnus-tmp-level)
4974 (copy-sequence tree-stack)
4977 (push (if (nth 1 thread) 1 0) tree-stack)
4978 (incf gnus-tmp-level)
4979 (setq threads (if thread-end nil (cdar thread)))
4980 (if gnus-summary-display-while-building
4983 ;; use a set frequency
4984 (setq building-line-count (1- building-line-count))
4985 (when (= building-line-count 0)
4987 (setq building-line-count
4988 gnus-summary-display-while-building)))
4992 (setq gnus-tmp-level 0)))))
4993 (gnus-message 7 "Generating summary...done"))
4995 (defun gnus-summary-prepare-unthreaded (headers)
4996 "Generate an unthreaded summary buffer based on HEADERS."
4997 (let (header number mark)
5002 ;; We may have to root out some bad articles...
5003 (when (memq (setq number (mail-header-number
5004 (setq header (pop headers))))
5005 gnus-newsgroup-limit)
5006 ;; Mark article as read when it has a low score.
5007 (when (and gnus-summary-mark-below
5008 (< (or (cdr (assq number gnus-newsgroup-scored))
5009 gnus-summary-default-score 0)
5010 gnus-summary-mark-below)
5011 (not (gnus-summary-article-ancient-p number)))
5012 (setq gnus-newsgroup-unreads
5013 (delq number gnus-newsgroup-unreads))
5014 (if gnus-newsgroup-auto-expire
5015 (push number gnus-newsgroup-expirable)
5016 (push (cons number gnus-low-score-mark)
5017 gnus-newsgroup-reads)))
5019 (setq mark (gnus-article-mark number))
5020 (push (gnus-data-make number mark (1+ (point)) header 0)
5021 gnus-newsgroup-data)
5022 (gnus-summary-insert-line
5024 (memq number gnus-newsgroup-undownloaded)
5025 mark (memq number gnus-newsgroup-replied)
5026 (memq number gnus-newsgroup-expirable)
5027 (mail-header-subject header) nil
5028 (cdr (assq number gnus-newsgroup-scored))
5029 (memq number gnus-newsgroup-processable))))))
5031 (defun gnus-summary-remove-list-identifiers ()
5032 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5033 (let ((regexp (if (consp gnus-list-identifiers)
5034 (mapconcat 'identity gnus-list-identifiers " *\\|")
5035 gnus-list-identifiers))
5038 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5039 (dolist (header gnus-newsgroup-headers)
5040 (setq subject (mail-header-subject header)
5042 (while (string-match regexp subject)
5044 (concat (substring subject 0 (match-beginning 1))
5045 (substring subject (match-end 0)))
5048 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5050 (concat (substring subject 0 (match-beginning 1))
5051 (substring subject (match-end 1)))))
5052 (mail-header-set-subject header subject))))))
5054 (defun gnus-fetch-headers (articles)
5055 "Fetch headers of ARTICLES."
5056 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5057 (gnus-message 5 "Fetching headers for %s..." name)
5060 (setq gnus-headers-retrieved-by
5061 (gnus-retrieve-headers
5062 articles gnus-newsgroup-name
5063 ;; We might want to fetch old headers, but
5064 ;; not if there is only 1 article.
5066 (not (eq gnus-fetch-old-headers 'some))
5067 (not (numberp gnus-fetch-old-headers)))
5068 (> (length articles) 1))
5069 gnus-fetch-old-headers))))
5070 (gnus-get-newsgroup-headers-xover
5071 articles nil nil gnus-newsgroup-name t)
5072 (gnus-get-newsgroup-headers))
5073 (gnus-message 5 "Fetching headers for %s...done" name))))
5075 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5076 "Select newsgroup GROUP.
5077 If READ-ALL is non-nil, all articles in the group are selected.
5078 If SELECT-ARTICLES, only select those articles from GROUP."
5079 (let* ((entry (gnus-group-entry group))
5080 ;;!!! Dirty hack; should be removed.
5081 (gnus-summary-ignore-duplicates
5082 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5084 gnus-summary-ignore-duplicates))
5085 (info (nth 2 entry))
5086 articles fetched-articles cached)
5088 (unless (gnus-check-server
5089 (set (make-local-variable 'gnus-current-select-method)
5090 (gnus-find-method-for-group group)))
5091 (error "Couldn't open server"))
5093 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5094 (gnus-activate-group group) ; Or we can activate it...
5095 (progn ; Or we bug out.
5096 (when (equal major-mode 'gnus-summary-mode)
5097 (gnus-kill-buffer (current-buffer)))
5098 (error "Couldn't activate group %s: %s"
5099 group (gnus-status-message group))))
5101 (unless (gnus-request-group group t)
5102 (when (equal major-mode 'gnus-summary-mode)
5103 (gnus-kill-buffer (current-buffer)))
5104 (error "Couldn't request group %s: %s"
5105 group (gnus-status-message group)))
5108 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5110 (setq gnus-summary-use-undownloaded-faces
5111 (gnus-agent-find-parameter
5113 'agent-enable-undownloaded-faces)))
5115 (setq gnus-newsgroup-name group
5116 gnus-newsgroup-unselected nil
5117 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5119 (let ((display (gnus-group-find-parameter group 'display)))
5120 (setq gnus-newsgroup-display
5122 ((not (zerop (or (car-safe read-all) 0)))
5123 ;; The user entered the group with C-u SPC/RET, let's show
5129 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5131 ;; The following is probably the "correct" solution, but
5132 ;; it makes Gnus fetch all headers and then limit the
5133 ;; articles (which is slow), so instead we hack the
5134 ;; select-articles parameter instead. -- Simon Josefsson
5137 ;; (gnus-byte-compile
5138 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5140 (setq select-articles
5141 (gnus-uncompress-range
5142 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5146 (cdr (gnus-active group)))))
5151 (gnus-summary-setup-default-charset)
5153 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5154 (when (gnus-virtual-group-p group)
5155 (setq cached gnus-newsgroup-cached))
5157 (setq gnus-newsgroup-unreads
5158 (gnus-sorted-ndifference
5159 (gnus-sorted-ndifference gnus-newsgroup-unreads
5160 gnus-newsgroup-marked)
5161 gnus-newsgroup-dormant))
5163 (setq gnus-newsgroup-processable nil)
5165 (gnus-update-read-articles group gnus-newsgroup-unreads)
5167 ;; Adjust and set lists of article marks.
5169 (gnus-adjust-marked-articles info))
5170 (if (setq articles select-articles)
5171 (setq gnus-newsgroup-unselected
5172 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5173 (setq articles (gnus-articles-to-read group read-all)))
5177 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5179 ((eq articles 0) nil)
5181 ;; Init the dependencies hash table.
5182 (setq gnus-newsgroup-dependencies
5183 (gnus-make-hashtable (length articles)))
5184 (gnus-set-global-variables)
5185 ;; Retrieve the headers and read them in.
5187 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5189 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5191 (setq gnus-newsgroup-cached cached))
5193 ;; Suppress duplicates?
5194 (when gnus-suppress-duplicates
5195 (gnus-dup-suppress-articles))
5197 ;; Set the initial limit.
5198 (setq gnus-newsgroup-limit (copy-sequence articles))
5199 ;; Remove canceled articles from the list of unread articles.
5200 (setq fetched-articles
5201 (mapcar (lambda (headers) (mail-header-number headers))
5202 gnus-newsgroup-headers))
5203 (setq gnus-newsgroup-articles fetched-articles)
5204 (setq gnus-newsgroup-unreads
5205 (gnus-sorted-nintersection
5206 gnus-newsgroup-unreads fetched-articles))
5207 (gnus-compute-unseen-list)
5209 ;; Removed marked articles that do not exist.
5210 (gnus-update-missing-marks
5211 (gnus-sorted-difference articles fetched-articles))
5212 ;; We might want to build some more threads first.
5213 (when (and gnus-fetch-old-headers
5214 (eq gnus-headers-retrieved-by 'nov))
5215 (if (eq gnus-fetch-old-headers 'invisible)
5216 (gnus-build-all-threads)
5217 (gnus-build-old-threads)))
5218 ;; Let the Gnus agent mark articles as read.
5220 (gnus-agent-get-undownloaded-list))
5221 ;; Remove list identifiers from subject
5222 (when gnus-list-identifiers
5223 (gnus-summary-remove-list-identifiers))
5224 ;; Check whether auto-expire is to be done in this group.
5225 (setq gnus-newsgroup-auto-expire
5226 (gnus-group-auto-expirable-p group))
5227 ;; Set up the article buffer now, if necessary.
5228 (unless gnus-single-article-buffer
5229 (gnus-article-setup-buffer))
5230 ;; First and last article in this newsgroup.
5231 (when gnus-newsgroup-headers
5232 (setq gnus-newsgroup-begin
5233 (mail-header-number (car gnus-newsgroup-headers))
5236 (gnus-last-element gnus-newsgroup-headers))))
5237 ;; GROUP is successfully selected.
5238 (or gnus-newsgroup-headers t)))))
5240 (defun gnus-compute-unseen-list ()
5241 ;; The `seen' marks are treated specially.
5242 (if (not gnus-newsgroup-seen)
5243 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5244 (setq gnus-newsgroup-unseen
5245 (gnus-inverse-list-range-intersection
5246 gnus-newsgroup-articles gnus-newsgroup-seen))))
5248 (defun gnus-summary-display-make-predicate (display)
5249 (require 'gnus-agent)
5250 (when (= (length display) 1)
5251 (setq display (car display)))
5252 (unless gnus-summary-display-cache
5253 (dolist (elem (append '((unread . unread)
5256 gnus-article-mark-lists))
5257 (push (cons (cdr elem)
5259 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5260 gnus-summary-display-cache)))
5261 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5262 (gnus-category-predicate-cache gnus-summary-display-cache))
5263 (gnus-get-predicate display)))
5265 ;; Uses the dynamically bound `number' variable.
5268 (defun gnus-article-marked-p (type &optional article)
5269 (let ((article (or article number)))
5272 (memq article gnus-newsgroup-marked))
5274 (memq article gnus-newsgroup-spam-marked))
5276 (memq article gnus-newsgroup-unsendable))
5277 ((eq type 'undownload)
5278 (memq article gnus-newsgroup-undownloaded))
5279 ((eq type 'download)
5280 (memq article gnus-newsgroup-downloadable))
5282 (memq article gnus-newsgroup-unreads))
5284 (memq article gnus-newsgroup-reads))
5286 (memq article gnus-newsgroup-dormant) )
5288 (memq article gnus-newsgroup-expirable))
5290 (memq article gnus-newsgroup-replied))
5292 (memq article gnus-newsgroup-killed))
5293 ((eq type 'bookmark)
5294 (assq article gnus-newsgroup-bookmarks))
5296 (assq article gnus-newsgroup-scored))
5298 (memq article gnus-newsgroup-saved))
5300 (memq article gnus-newsgroup-cached))
5302 (memq article gnus-newsgroup-forwarded))
5304 (not (memq article gnus-newsgroup-unseen)))
5306 (memq article gnus-newsgroup-recent))
5309 (defun gnus-articles-to-read (group &optional read-all)
5310 "Find out what articles the user wants to read."
5312 ;; Select all articles if `read-all' is non-nil, or if there
5313 ;; are no unread articles.
5315 (and (zerop (length gnus-newsgroup-marked))
5316 (zerop (length gnus-newsgroup-unreads)))
5317 ;; Fetch all if the predicate is non-nil.
5318 gnus-newsgroup-display)
5319 ;; We want to select the headers for all the articles in
5320 ;; the group, so we select either all the active
5321 ;; articles in the group, or (if that's nil), the
5322 ;; articles in the cache.
5324 (gnus-uncompress-range (gnus-active group))
5325 (gnus-cache-articles-in-group group))
5326 ;; Select only the "normal" subset of articles.
5328 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5329 gnus-newsgroup-unreads)))
5330 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5331 (scored (length scored-list))
5332 (number (length articles))
5333 (marked (+ (length gnus-newsgroup-marked)
5334 (length gnus-newsgroup-dormant)))
5339 ((numberp gnus-newsgroup-display)
5340 gnus-newsgroup-display)
5344 ((and (or (<= scored marked) (= scored number))
5345 (numberp gnus-large-newsgroup)
5346 (> number gnus-large-newsgroup))
5347 (let* ((cursor-in-echo-area nil)
5348 (initial (gnus-parameter-large-newsgroup-initial
5349 gnus-newsgroup-name))
5353 "How many articles from %s (%s %d): "
5355 (gnus-group-decoded-name gnus-newsgroup-name)
5357 (if initial "max" "default")
5360 (cons (number-to-string initial)
5362 (if (string-match "^[ \t]*$" input) number input)))
5363 ((and (> scored marked) (< scored number)
5364 (> (- scored number) 20))
5367 (format "%s %s (%d scored, %d total): "
5368 "How many articles from"
5369 (gnus-group-decoded-name group)
5371 (if (string-match "^[ \t]*$" input)
5375 (message "Quit getting the articles to read")
5377 (setq select (if (stringp select) (string-to-number select) select))
5378 (if (or (null select) (zerop select))
5380 (if (and (not (zerop scored)) (<= (abs select) scored))
5382 (setq articles (sort scored-list '<))
5383 (setq number (length articles)))
5384 (setq articles (copy-sequence articles)))
5386 (when (< (abs select) number)
5388 ;; Select the N oldest articles.
5389 (setcdr (nthcdr (1- (abs select)) articles) nil)
5390 ;; Select the N most recent articles.
5391 (setq articles (nthcdr (- number select) articles))))
5392 (setq gnus-newsgroup-unselected
5393 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5394 (when gnus-alter-articles-to-read-function
5397 (funcall gnus-alter-articles-to-read-function
5398 gnus-newsgroup-name articles)
5402 (defun gnus-killed-articles (killed articles)
5405 (when (inline (gnus-member-of-range (car articles) killed))
5406 (push (car articles) out))
5407 (setq articles (cdr articles)))
5410 (defun gnus-uncompress-marks (marks)
5411 "Uncompress the mark ranges in MARKS."
5412 (let ((uncompressed '(score bookmark))
5415 (if (memq (caar marks) uncompressed)
5416 (push (car marks) out)
5417 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5418 (setq marks (cdr marks)))
5421 (defun gnus-article-mark-to-type (mark)
5422 "Return the type of MARK."
5423 (or (cadr (assq mark gnus-article-special-mark-lists))
5426 (defun gnus-article-unpropagatable-p (mark)
5427 "Return whether MARK should be propagated to back end."
5428 (memq mark gnus-article-unpropagated-mark-lists))
5430 (defun gnus-adjust-marked-articles (info)
5431 "Set all article lists and remove all marks that are no longer valid."
5432 (let* ((marked-lists (gnus-info-marks info))
5433 (active (gnus-active (gnus-info-group info)))
5436 (types gnus-article-mark-lists)
5437 marks var articles article mark mark-type
5440 (dolist (marks marked-lists)
5441 (setq mark (car marks)
5442 mark-type (gnus-article-mark-to-type mark)
5443 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5445 ;; We set the variable according to the type of the marks list,
5446 ;; and then adjust the marks to a subset of the active articles.
5448 ;; Adjust "simple" lists - compressed yet unsorted
5449 ((eq mark-type 'list)
5450 ;; Simultaneously uncompress and clip to active range
5451 ;; See gnus-uncompress-range for a description of possible marks
5453 (if (not (cadr marks))
5455 (setq articles (if (numberp (cddr marks))
5461 (while (setq article (pop articles))
5462 (cond ((consp article)
5463 (setq bgn (max (car article) min)
5464 end (min (cdr article) max))
5466 (setq l (setcdr l (cons bgn nil))
5468 ((and (<= min article)
5470 (setq l (setcdr l (cons article nil))))))
5471 (set var (cdr lh)))))
5473 ((eq mark-type 'tuple)
5474 (set var (setq articles (cdr marks)))
5475 (when (not (listp (cdr (symbol-value var))))
5476 (set var (list (symbol-value var))))
5477 (when (not (listp (cdr articles)))
5478 (setq articles (list articles)))
5480 (when (or (not (consp (setq article (pop articles))))
5481 (< (car article) min)
5482 (> (car article) max))
5483 (set var (delq article (symbol-value var))))))
5484 ;; Adjust ranges (sloppily).
5485 ((eq mark-type 'range)
5488 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5489 ;; It should be (seen (NUM1 . NUM2)).
5490 (when (numberp (cddr marks))
5491 (setcdr marks (list (cdr marks))))
5492 (setq articles (cdr marks))
5493 (while (and articles
5494 (or (and (consp (car articles))
5495 (> min (cdar articles)))
5496 (and (numberp (car articles))
5497 (> min (car articles)))))
5499 (set var articles))))))))
5501 (defun gnus-update-missing-marks (missing)
5502 "Go through the list of MISSING articles and remove them from the mark lists."
5505 ;; Go through all types.
5506 (dolist (elem gnus-article-mark-lists)
5507 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5508 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5509 (when (symbol-value var)
5510 ;; This list has articles. So we delete all missing
5511 ;; articles from it.
5514 (set var (delq (pop m) (symbol-value var))))))))))
5516 (defun gnus-update-marks ()
5517 "Enter the various lists of marked articles into the newsgroup info list."
5518 (let ((types gnus-article-mark-lists)
5519 (info (gnus-get-info gnus-newsgroup-name))
5520 type list newmarked symbol delta-marks)
5522 ;; Add all marks lists to the list of marks lists.
5523 (while (setq type (pop types))
5524 (setq list (symbol-value
5526 (intern (format "gnus-newsgroup-%s" (car type))))))
5529 ;; Get rid of the entries of the articles that have the
5531 (when (and (eq (cdr type) 'score)
5535 (prev (cons nil list))
5538 (if (or (not (consp (car arts)))
5539 (= (cdar arts) gnus-summary-default-score))
5540 (setcdr prev (cdr arts))
5542 (setq arts (cdr arts)))
5543 (setq list (cdr all)))))
5545 (when (eq (cdr type) 'seen)
5546 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5548 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5549 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5551 (when (and (gnus-check-backend-function
5552 'request-set-mark gnus-newsgroup-name)
5553 (not (gnus-article-unpropagatable-p (cdr type))))
5554 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5555 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5556 (add (gnus-remove-from-range
5557 (gnus-copy-sequence list) old)))
5559 (push (list add 'add (list (cdr type))) delta-marks))
5561 (push (list del 'del (list (cdr type))) delta-marks))))
5564 (push (cons (cdr type) list) newmarked)))
5567 (unless (gnus-check-group gnus-newsgroup-name)
5568 (error "Can't open server for %s" gnus-newsgroup-name))
5569 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5571 ;; Enter these new marks into the info of the group.
5573 (setcar (nthcdr 3 info) newmarked)
5574 ;; Add the marks lists to the end of the info.
5576 (setcdr (nthcdr 2 info) (list newmarked))))
5578 ;; Cut off the end of the info if there's nothing else there.
5582 (when (nthcdr (decf i) info)
5583 (setcdr (nthcdr i info) nil)))))))
5585 (defun gnus-set-mode-line (where)
5586 "Set the mode line of the article or summary buffers.
5587 If WHERE is `summary', the summary mode line format will be used."
5588 ;; Is this mode line one we keep updated?
5589 (when (and (memq where gnus-updated-mode-lines)
5591 (intern (format "gnus-%s-mode-line-format-spec" where))))
5594 ;; We evaluate this in the summary buffer since these
5595 ;; variables are buffer-local to that buffer.
5596 (set-buffer gnus-summary-buffer)
5597 ;; We bind all these variables that are used in the `eval' form
5599 (let* ((mformat (symbol-value
5601 (format "gnus-%s-mode-line-format-spec" where))))
5602 (gnus-tmp-group-name (gnus-group-decoded-name
5603 gnus-newsgroup-name))
5604 (gnus-tmp-article-number (or gnus-current-article 0))
5605 (gnus-tmp-unread gnus-newsgroup-unreads)
5606 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5607 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5608 (gnus-tmp-unread-and-unselected
5609 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5610 (zerop gnus-tmp-unselected))
5612 ((zerop gnus-tmp-unselected)
5613 (format "{%d more}" gnus-tmp-unread-and-unticked))
5614 (t (format "{%d(+%d) more}"
5615 gnus-tmp-unread-and-unticked
5616 gnus-tmp-unselected))))
5618 (if (and gnus-current-headers
5619 (vectorp gnus-current-headers))
5620 (gnus-mode-string-quote
5621 (mail-header-subject gnus-current-headers))
5623 bufname-length max-len
5624 gnus-tmp-header);; passed as argument to any user-format-funcs
5625 (setq mode-string (eval mformat))
5626 (setq bufname-length (if (string-match "%b" mode-string)
5629 (if (eq where 'summary)
5631 (get-buffer gnus-article-buffer))))
5634 (setq max-len (max 4 (if gnus-mode-non-string-length
5636 gnus-mode-non-string-length
5638 (length mode-string))))
5639 ;; We might have to chop a bit of the string off...
5640 (when (> (length mode-string) max-len)
5642 (concat (gnus-truncate-string mode-string (- max-len 3))
5644 ;; Pad the mode string a bit.
5645 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5646 ;; Update the mode line.
5647 (setq mode-line-buffer-identification
5648 (gnus-mode-line-buffer-identification (list mode-string)))
5649 (set-buffer-modified-p t))))
5651 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5652 "Go through the HEADERS list and add all Xrefs to a hash table.
5653 The resulting hash table is returned, or nil if no Xrefs were found."
5654 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5655 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5656 (xref-hashtb (gnus-make-hashtable))
5657 start group entry number xrefs header)
5659 (setq header (pop headers))
5660 (when (and (setq xrefs (mail-header-xref header))
5661 (not (memq (setq number (mail-header-number header))
5664 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5665 (setq start (match-end 0))
5666 (setq group (if prefix
5667 (concat prefix (substring xrefs (match-beginning 1)
5669 (substring xrefs (match-beginning 1) (match-end 1))))
5671 (string-to-int (substring xrefs (match-beginning 2)
5673 (if (setq entry (gnus-gethash group xref-hashtb))
5674 (setcdr entry (cons number (cdr entry)))
5675 (gnus-sethash group (cons number nil) xref-hashtb)))))
5676 (and start xref-hashtb)))
5678 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5679 "Look through all the headers and mark the Xrefs as read."
5680 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5681 name info xref-hashtb idlist method nth4)
5683 (set-buffer gnus-group-buffer)
5684 (when (setq xref-hashtb
5685 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5688 (unless (string= from-newsgroup (setq name (symbol-name group)))
5689 (setq idlist (symbol-value group))
5690 ;; Dead groups are not updated.
5692 (setq info (gnus-get-info name))
5693 (when (stringp (setq nth4 (gnus-info-method info)))
5694 (setq nth4 (gnus-server-to-method nth4))))
5695 ;; Only do the xrefs if the group has the same
5696 ;; select method as the group we have just read.
5697 (or (gnus-methods-equal-p
5698 nth4 (gnus-find-method-for-group from-newsgroup))
5700 (equal nth4 (setq method (gnus-find-method-for-group
5702 (and (equal (car nth4) (car method))
5703 (equal (nth 1 nth4) (nth 1 method))))
5704 gnus-use-cross-reference
5705 (or (not (eq gnus-use-cross-reference t))
5707 ;; Only do cross-references on subscribed
5708 ;; groups, if that is what is wanted.
5709 (<= (gnus-info-level info) gnus-level-subscribed))
5710 (gnus-group-make-articles-read name idlist))))
5713 (defun gnus-compute-read-articles (group articles)
5714 (let* ((entry (gnus-group-entry group))
5715 (info (nth 2 entry))
5716 (active (gnus-active group))
5719 ;; First peel off all invalid article numbers.
5721 (let ((ids articles)
5723 (while (setq id (pop ids))
5724 (when (and first (> id (cdr active)))
5725 ;; We'll end up in this situation in one particular
5726 ;; obscure situation. If you re-scan a group and get
5727 ;; a new article that is cross-posted to a different
5728 ;; group that has not been re-scanned, you might get
5729 ;; crossposted article that has a higher number than
5730 ;; Gnus believes possible. So we re-activate this
5731 ;; group as well. This might mean doing the
5732 ;; crossposting thingy will *increase* the number
5733 ;; of articles in some groups. Tsk, tsk.
5734 (setq active (or (gnus-activate-group group) active)))
5735 (when (or (> id (cdr active))
5736 (< id (car active)))
5737 (setq articles (delq id articles))))))
5738 ;; If the read list is nil, we init it.
5740 (null (gnus-info-read info))
5742 (setq ninfo (cons 1 (1- (car active))))
5743 (setq ninfo (gnus-info-read info)))
5744 ;; Then we add the read articles to the range.
5746 ninfo (setq articles (sort articles '<))))))
5748 (defun gnus-group-make-articles-read (group articles)
5749 "Update the info of GROUP to say that ARTICLES are read."
5751 (entry (gnus-group-entry group))
5752 (info (nth 2 entry))
5753 (active (gnus-active group))
5756 (setq range (gnus-compute-read-articles group articles))
5757 (with-current-buffer gnus-group-buffer
5760 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5761 (gnus-info-set-read ',info ',(gnus-info-read info))
5762 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5763 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5764 (gnus-group-update-group ,group t))))
5765 ;; Add the read articles to the range.
5766 (gnus-info-set-read info range)
5767 (gnus-request-set-mark group (list (list range 'add '(read))))
5768 ;; Then we have to re-compute how many unread
5769 ;; articles there are in this group.
5773 (setq num (- (1+ (cdr active)) (car active))))
5774 ((not (listp (cdr range)))
5775 (setq num (- (cdr active) (- (1+ (cdr range))
5779 (if (numberp (car range))
5781 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5782 (setq range (cdr range)))
5783 (setq num (- (cdr active) num))))
5784 ;; Update the number of unread articles.
5786 ;; Update the group buffer.
5787 (unless (gnus-ephemeral-group-p group)
5788 (gnus-group-update-group group t))))))
5790 (defvar gnus-newsgroup-none-id 0)
5792 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5793 (let ((cur nntp-server-buffer)
5796 (with-current-buffer gnus-summary-buffer
5797 gnus-newsgroup-dependencies)))
5798 headers id end ref number
5799 (mail-parse-charset gnus-newsgroup-charset)
5800 (mail-parse-ignored-charsets
5801 (save-excursion (condition-case nil
5802 (set-buffer gnus-summary-buffer)
5804 gnus-newsgroup-ignored-charsets)))
5806 (set-buffer nntp-server-buffer)
5807 ;; Translate all TAB characters into SPACE characters.
5808 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5809 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5810 (ietf-drums-unfold-fws)
5811 (gnus-run-hooks 'gnus-parse-headers-hook)
5812 (let ((case-fold-search t)
5813 in-reply-to header p lines chars ctype)
5814 (goto-char (point-min))
5815 ;; Search to the beginning of the next header. Error messages
5816 ;; do not begin with 2 or 3.
5817 (while (re-search-forward "^[23][0-9]+ " nil t)
5820 ;; This implementation of this function, with nine
5821 ;; search-forwards instead of the one re-search-forward and
5822 ;; a case (which basically was the old function) is actually
5823 ;; about twice as fast, even though it looks messier. You
5824 ;; can't have everything, I guess. Speed and elegance
5825 ;; doesn't always go hand in hand.
5828 (make-full-mail-header
5831 (setq number (read cur))
5834 (narrow-to-region (point)
5835 (or (and (search-forward "\n.\n" nil t)
5841 (if (search-forward "\nsubject:" nil t)
5842 (nnheader-header-value)
5847 (if (search-forward "\nfrom:" nil t)
5848 (nnheader-header-value)
5853 (if (search-forward "\ndate:" nil t)
5854 (nnheader-header-value) ""))
5858 (setq id (if (re-search-forward
5859 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5860 ;; We do it this way to make sure the Message-ID
5861 ;; is (somewhat) syntactically valid.
5862 (buffer-substring (match-beginning 1)
5864 ;; If there was no message-id, we just fake one
5865 ;; to make subsequent routines simpler.
5866 (nnheader-generate-fake-message-id number))))
5870 (if (search-forward "\nreferences:" nil t)
5874 (nnheader-header-value)
5879 (search-backward ">" end t)
5882 (search-backward "<" end t)
5884 ;; Get the references from the in-reply-to header if there
5885 ;; were no references and the in-reply-to header looks
5887 (if (and (search-forward "\nin-reply-to:" nil t)
5888 (setq in-reply-to (nnheader-header-value))
5889 (string-match "<[^>]+>" in-reply-to))
5891 (setq ref (substring in-reply-to (match-beginning 0)
5893 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5894 (setq ref2 (substring in-reply-to (match-beginning 0)
5896 (when (> (length ref2) (length ref))
5903 (if (search-forward "\nchars: " nil t)
5904 (if (numberp (setq chars (ignore-errors (read cur))))
5910 (if (search-forward "\nlines: " nil t)
5911 (if (numberp (setq lines (ignore-errors (read cur))))
5917 (and (search-forward "\nxref:" nil t)
5918 (nnheader-header-value)))
5920 (when gnus-extra-headers
5921 (let ((extra gnus-extra-headers)
5925 (when (search-forward
5926 (concat "\n" (symbol-name (car extra)) ":") nil t)
5927 (push (cons (car extra) (nnheader-header-value)) out))
5931 (if (and (search-forward "\ncontent-type: " nil t)
5932 (setq ctype (nnheader-header-value)))
5933 (mime-entity-set-content-type-internal
5934 header (mime-parse-Content-Type ctype)))
5935 (when (equal id ref)
5938 (when gnus-alter-header-function
5939 (funcall gnus-alter-header-function header)
5940 (setq id (mail-header-id header)
5941 ref (gnus-parent-id (mail-header-references header))))
5944 (gnus-dependencies-add-header
5945 header dependencies force-new))
5946 (push header headers))
5947 (goto-char (point-max))
5949 (nreverse headers)))))
5951 ;; Goes through the xover lines and returns a list of vectors
5952 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5953 force-new dependencies
5954 group also-fetch-heads)
5955 "Parse the news overview data in the server buffer.
5956 Return a list of headers that match SEQUENCE (see
5957 `nntp-retrieve-headers')."
5958 ;; Get the Xref when the users reads the articles since most/some
5959 ;; NNTP servers do not include Xrefs when using XOVER.
5960 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5961 (let ((mail-parse-charset gnus-newsgroup-charset)
5962 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5963 (cur nntp-server-buffer)
5964 (dependencies (or dependencies gnus-newsgroup-dependencies))
5966 ((eq gnus-read-all-available-headers t)
5968 ((stringp gnus-read-all-available-headers)
5969 (string-match gnus-read-all-available-headers group))
5972 number headers header)
5974 (set-buffer nntp-server-buffer)
5975 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5976 ;; Allow the user to mangle the headers before parsing them.
5977 (gnus-run-hooks 'gnus-parse-headers-hook)
5978 (goto-char (point-min))
5979 (gnus-parse-without-error
5980 (while (and (or sequence allp)
5982 (setq number (read cur))
5984 (while (and sequence
5985 (< (car sequence) number))
5986 (setq sequence (cdr sequence))))
5989 (eq number (car sequence))))
5991 (setq sequence (cdr sequence))
5992 (setq header (inline
5993 (gnus-nov-parse-line
5994 number dependencies force-new)))))
5995 (push header headers))
5997 ;; A common bug in inn is that if you have posted an article and
5998 ;; then retrieves the active file, it will answer correctly --
5999 ;; the new article is included. However, a NOV entry for the
6000 ;; article may not have been generated yet, so this may fail.
6001 ;; We work around this problem by retrieving the last few
6002 ;; headers using HEAD.
6003 (if (or (not also-fetch-heads)
6005 ;; We (probably) got all the headers.
6007 (let ((gnus-nov-is-evil t))
6010 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6011 (gnus-get-newsgroup-headers))))))))
6013 (defun gnus-article-get-xrefs ()
6014 "Fill in the Xref value in `gnus-current-headers', if necessary.
6015 This is meant to be called in `gnus-article-internal-prepare-hook'."
6016 (let ((headers (with-current-buffer gnus-summary-buffer
6017 gnus-current-headers)))
6018 (or (not gnus-use-cross-reference)
6020 (and (mail-header-xref headers)
6021 (not (string= (mail-header-xref headers) "")))
6022 (let ((case-fold-search t)
6025 (nnheader-narrow-to-headers)
6026 (goto-char (point-min))
6027 (when (or (and (not (eobp))
6028 (eq (downcase (char-after)) ?x)
6029 (looking-at "Xref:"))
6030 (search-forward "\nXref:" nil t))
6031 (goto-char (1+ (match-end 0)))
6032 (setq xref (buffer-substring (point) (point-at-eol)))
6033 (mail-header-set-xref headers xref)))))))
6035 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6036 "Find article ID and insert the summary line for that article.
6037 OLD-HEADER can either be a header or a line number to insert
6038 the subject line on."
6039 (let* ((line (and (numberp old-header) old-header))
6040 (old-header (and (vectorp old-header) old-header))
6041 (header (cond ((and old-header use-old-header)
6044 (gnus-number-to-header id))
6045 (gnus-number-to-header id))
6047 (gnus-read-header id))))
6048 (number (and (numberp id) id))
6051 ;; Rebuild the thread that this article is part of and go to the
6052 ;; article we have fetched.
6053 (when (and (not gnus-show-threads)
6056 (setq d (gnus-data-find (mail-header-number old-header))))
6057 (goto-char (gnus-data-pos d))
6063 (gnus-delete-line))))))
6064 ;; Remove list identifiers from subject.
6065 (when gnus-list-identifiers
6066 (let ((gnus-newsgroup-headers (list header)))
6067 (gnus-summary-remove-list-identifiers)
6068 (setq header (car gnus-newsgroup-headers))))
6070 (mail-header-set-number header (mail-header-number old-header)))
6071 (setq gnus-newsgroup-sparse
6072 (delq (setq number (mail-header-number header))
6073 gnus-newsgroup-sparse))
6074 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6075 (push number gnus-newsgroup-limit)
6076 (gnus-rebuild-thread (mail-header-id header) line)
6077 (gnus-summary-goto-subject number nil t))
6078 (when (and (numberp number)
6080 ;; We have to update the boundaries even if we can't fetch the
6081 ;; article if ID is a number -- so that the next `P' or `N'
6082 ;; command will fetch the previous (or next) article even
6083 ;; if the one we tried to fetch this time has been canceled.
6084 (when (> number gnus-newsgroup-end)
6085 (setq gnus-newsgroup-end number))
6086 (when (< number gnus-newsgroup-begin)
6087 (setq gnus-newsgroup-begin number))
6088 (setq gnus-newsgroup-unselected
6089 (delq number gnus-newsgroup-unselected)))
6090 ;; Report back a success?
6091 (and header (mail-header-number header))))
6093 ;;; Process/prefix in the summary buffer
6095 (defun gnus-summary-work-articles (n)
6096 "Return a list of articles to be worked upon.
6097 The prefix argument, the list of process marked articles, and the
6098 current article will be taken into consideration."
6100 (set-buffer gnus-summary-buffer)
6103 ;; A numerical prefix has been given.
6104 (setq n (prefix-numeric-value n))
6105 (let ((backward (< n 0))
6106 (n (abs (prefix-numeric-value n)))
6111 (push (setq article (gnus-summary-article-number))
6114 (gnus-summary-find-prev nil article)
6115 (gnus-summary-find-next nil article)))
6117 (nreverse articles)))
6118 ((and (gnus-region-active-p) (mark))
6119 (message "region active")
6120 ;; Work on the region between point and mark.
6121 (let ((max (max (point) (mark)))
6124 (goto-char (min (point) (mark)))
6127 (push (setq article (gnus-summary-article-number)) articles)
6128 (gnus-summary-find-next nil article)
6130 (nreverse articles))))
6131 (gnus-newsgroup-processable
6132 ;; There are process-marked articles present.
6133 ;; Save current state.
6134 (gnus-summary-save-process-mark)
6136 (reverse gnus-newsgroup-processable))
6138 ;; Just return the current article.
6139 (list (gnus-summary-article-number))))))
6141 (defmacro gnus-summary-iterate (arg &rest forms)
6142 "Iterate over the process/prefixed articles and do FORMS.
6143 ARG is the interactive prefix given to the command. FORMS will be
6144 executed with point over the summary line of the articles."
6145 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6146 `(let ((,articles (gnus-summary-work-articles ,arg)))
6148 (gnus-summary-goto-subject (car ,articles))
6152 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6153 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6155 (defun gnus-summary-save-process-mark ()
6156 "Push the current set of process marked articles on the stack."
6158 (push (copy-sequence gnus-newsgroup-processable)
6159 gnus-newsgroup-process-stack))
6161 (defun gnus-summary-kill-process-mark ()
6162 "Push the current set of process marked articles on the stack and unmark."
6164 (gnus-summary-save-process-mark)
6165 (gnus-summary-unmark-all-processable))
6167 (defun gnus-summary-yank-process-mark ()
6168 "Pop the last process mark state off the stack and restore it."
6170 (unless gnus-newsgroup-process-stack
6171 (error "Empty mark stack"))
6172 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6174 (defun gnus-summary-process-mark-set (set)
6175 "Make SET into the current process marked articles."
6176 (gnus-summary-unmark-all-processable)
6177 (mapc 'gnus-summary-set-process-mark set))
6179 ;;; Searching and stuff
6181 (defun gnus-summary-search-group (&optional backward use-level)
6182 "Search for next unread newsgroup.
6183 If optional argument BACKWARD is non-nil, search backward instead."
6185 (set-buffer gnus-group-buffer)
6186 (when (gnus-group-search-forward
6187 backward nil (if use-level (gnus-group-group-level) nil))
6188 (gnus-group-group-name))))
6190 (defun gnus-summary-best-group (&optional exclude-group)
6191 "Find the name of the best unread group.
6192 If EXCLUDE-GROUP, do not go to this group."
6193 (with-current-buffer gnus-group-buffer
6195 (gnus-group-best-unread-group exclude-group))))
6197 (defun gnus-summary-find-next (&optional unread article backward)
6199 (gnus-summary-find-prev unread article)
6200 (let* ((dummy (gnus-summary-article-intangible-p))
6201 (article (or article (gnus-summary-article-number)))
6202 (data (gnus-data-find-list article))
6204 (when (and (not dummy)
6205 (or (not gnus-summary-check-current)
6207 (not (gnus-data-unread-p (car data)))))
6208 (setq data (cdr data)))
6213 (unless (memq (gnus-data-number (car data))
6215 ((eq gnus-auto-goto-ignores
6216 'always-undownloaded)
6217 gnus-newsgroup-undownloaded)
6220 ((eq gnus-auto-goto-ignores
6222 gnus-newsgroup-unfetched)
6223 ((eq gnus-auto-goto-ignores
6225 gnus-newsgroup-undownloaded)))
6226 (when (gnus-data-unread-p (car data))
6227 (setq result (car data)
6229 (setq data (cdr data)))
6232 (goto-char (gnus-data-pos result))
6233 (gnus-data-number result)))))
6235 (defun gnus-summary-find-prev (&optional unread article)
6236 (let* ((eobp (eobp))
6237 (article (or article (gnus-summary-article-number)))
6238 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6240 (when (and (not eobp)
6241 (or (not gnus-summary-check-current)
6243 (not (gnus-data-unread-p (car data)))))
6244 (setq data (cdr data)))
6249 (unless (memq (gnus-data-number (car data))
6251 ((eq gnus-auto-goto-ignores
6252 'always-undownloaded)
6253 gnus-newsgroup-undownloaded)
6256 ((eq gnus-auto-goto-ignores
6258 gnus-newsgroup-unfetched)
6259 ((eq gnus-auto-goto-ignores
6261 gnus-newsgroup-undownloaded)))
6262 (when (gnus-data-unread-p (car data))
6263 (setq result (car data)
6265 (setq data (cdr data)))
6268 (goto-char (gnus-data-pos result))
6269 (gnus-data-number result))))
6271 (defun gnus-summary-find-subject (subject &optional unread backward article)
6272 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6273 (article (or article (gnus-summary-article-number)))
6274 (articles (gnus-data-list backward))
6275 (arts (gnus-data-find-list article articles))
6277 (when (or (not gnus-summary-check-current)
6279 (not (gnus-data-unread-p (car arts))))
6280 (setq arts (cdr arts)))
6282 (and (or (not unread)
6283 (gnus-data-unread-p (car arts)))
6284 (vectorp (gnus-data-header (car arts)))
6286 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6287 (setq result (car arts)
6289 (setq arts (cdr arts)))
6291 (goto-char (gnus-data-pos result))
6292 (gnus-data-number result))))
6294 (defun gnus-summary-search-forward (&optional unread subject backward)
6295 "Search forward for an article.
6296 If UNREAD, look for unread articles. If SUBJECT, look for
6297 articles with that subject. If BACKWARD, search backward instead."
6298 (cond (subject (gnus-summary-find-subject subject unread backward))
6299 (backward (gnus-summary-find-prev unread))
6300 (t (gnus-summary-find-next unread))))
6302 (defun gnus-recenter (&optional n)
6303 "Center point in window and redisplay frame.
6304 Also do horizontal recentering."
6306 (when (and gnus-auto-center-summary
6307 (not (eq gnus-auto-center-summary 'vertical)))
6308 (gnus-horizontal-recenter))
6311 (defun gnus-summary-recenter ()
6312 "Center point in the summary window.
6313 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6314 displayed, no centering will be performed."
6315 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6316 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6318 ;; The user has to want it.
6319 (when gnus-auto-center-summary
6320 (let* ((top (cond ((< (window-height) 4) 0)
6321 ((< (window-height) 7) 1)
6322 (t (if (numberp gnus-auto-center-summary)
6323 gnus-auto-center-summary
6324 (/ (1- (window-height)) 2)))))
6325 (height (1- (window-height)))
6326 (bottom (save-excursion (goto-char (point-max))
6327 (forward-line (- height))
6329 (window (get-buffer-window (current-buffer))))
6330 (when (get-buffer-window gnus-article-buffer)
6331 ;; Only do recentering when the article buffer is displayed,
6332 ;; Set the window start to either `bottom', which is the biggest
6333 ;; possible valid number, or the second line from the top,
6334 ;; whichever is the least.
6335 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6336 (if (> bottom top-pos)
6337 ;; Keep the second line from the top visible
6338 (set-window-start window top-pos t)
6339 ;; Try to keep the bottom line visible; if it's partially
6340 ;; obscured, either scroll one more line to make it fully
6341 ;; visible, or revert to using TOP-POS.
6343 (goto-char (point-max))
6345 (let ((last-line-start (point)))
6347 (set-window-start window (point) t)
6348 (when (not (pos-visible-in-window-p last-line-start window))
6350 (set-window-start window (min (point) top-pos) t)))))))
6351 ;; Do horizontal recentering while we're at it.
6352 (when (and (get-buffer-window (current-buffer) t)
6353 (not (eq gnus-auto-center-summary 'vertical)))
6354 (let ((selected (selected-window)))
6355 (select-window (get-buffer-window (current-buffer) t))
6356 (gnus-summary-position-point)
6357 (gnus-horizontal-recenter)
6358 (select-window selected))))))
6360 (defun gnus-summary-jump-to-group (newsgroup)
6361 "Move point to NEWSGROUP in group mode buffer."
6362 ;; Keep update point of group mode buffer if visible.
6363 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6364 (save-window-excursion
6365 ;; Take care of tree window mode.
6366 (when (get-buffer-window gnus-group-buffer)
6367 (pop-to-buffer gnus-group-buffer))
6368 (gnus-group-jump-to-group newsgroup))
6370 ;; Take care of tree window mode.
6371 (if (get-buffer-window gnus-group-buffer)
6372 (pop-to-buffer gnus-group-buffer)
6373 (set-buffer gnus-group-buffer))
6374 (gnus-group-jump-to-group newsgroup))))
6376 ;; This function returns a list of article numbers based on the
6377 ;; difference between the ranges of read articles in this group and
6378 ;; the range of active articles.
6379 (defun gnus-list-of-unread-articles (group)
6380 (let* ((read (gnus-info-read (gnus-get-info group)))
6381 (active (or (gnus-active group) (gnus-activate-group group)))
6384 ;; If none are read, then all are unread.
6386 (setq first (car active))
6387 ;; If the range of read articles is a single range, then the
6388 ;; first unread article is the article after the last read
6389 ;; article. Sounds logical, doesn't it?
6390 (if (and (not (listp (cdr read)))
6391 (or (< (car read) (car active))
6392 (progn (setq read (list read))
6394 (setq first (max (car active) (1+ (cdr read))))
6395 ;; `read' is a list of ranges.
6396 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6399 (setq first (car active)))
6402 (while (< first nlast)
6403 (setq unread (cons first unread)
6405 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6406 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6407 (setq read (cdr read)))))
6408 ;; And add the last unread articles.
6409 (while (<= first last)
6410 (setq unread (cons first unread)
6412 ;; Return the list of unread articles.
6413 (delq 0 (nreverse unread))))
6415 (defun gnus-list-of-read-articles (group)
6416 "Return a list of unread, unticked and non-dormant articles."
6417 (let* ((info (gnus-get-info group))
6418 (marked (gnus-info-marks info))
6419 (active (gnus-active group)))
6421 (gnus-list-range-difference
6422 (gnus-list-range-difference
6423 (gnus-sorted-complement
6424 (gnus-uncompress-range active)
6425 (gnus-list-of-unread-articles group))
6426 (cdr (assq 'dormant marked)))
6427 (cdr (assq 'tick marked))))))
6429 ;; This function returns a sequence of article numbers based on the
6430 ;; difference between the ranges of read articles in this group and
6431 ;; the range of active articles.
6432 (defun gnus-sequence-of-unread-articles (group)
6433 (let* ((read (gnus-info-read (gnus-get-info group)))
6434 (active (or (gnus-active group) (gnus-activate-group group)))
6437 ;; If none are read, then all are unread.
6439 (setq first (car active))
6440 ;; If the range of read articles is a single range, then the
6441 ;; first unread article is the article after the last read
6442 ;; article. Sounds logical, doesn't it?
6443 (if (and (not (listp (cdr read)))
6444 (or (< (car read) (car active))
6445 (progn (setq read (list read))
6447 (setq first (max (car active) (1+ (cdr read))))
6448 ;; `read' is a list of ranges.
6449 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6452 (setq first (car active)))
6455 (push (cons first nlast) unread))
6456 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6457 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6458 (setq read (cdr read)))))
6459 ;; And add the last unread articles.
6460 (cond ((< first last)
6461 (push (cons first last) unread))
6463 (push first unread)))
6464 ;; Return the sequence of unread articles.
6465 (delq 0 (nreverse unread))))
6467 ;; Various summary commands
6469 (defun gnus-summary-select-article-buffer ()
6470 "Reconfigure windows to show article buffer."
6472 (if (not (gnus-buffer-live-p gnus-article-buffer))
6473 (error "There is no article buffer for this summary buffer")
6474 (gnus-configure-windows 'article)
6475 (select-window (get-buffer-window gnus-article-buffer))))
6477 (defun gnus-summary-universal-argument (arg)
6478 "Perform any operation on all articles that are process/prefixed."
6480 (let ((articles (gnus-summary-work-articles arg))
6487 (substitute-command-keys
6488 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6490 (gnus-error 1 "Undefined key")
6493 (gnus-summary-goto-subject (setq article (pop articles)))
6494 (let (gnus-newsgroup-processable)
6495 (command-execute func))
6496 (gnus-summary-remove-process-mark article)))))
6497 (gnus-summary-position-point))
6499 (defun gnus-summary-toggle-truncation (&optional arg)
6500 "Toggle truncation of summary lines.
6501 With ARG, turn line truncation on if ARG is positive."
6503 (setq truncate-lines
6504 (if (null arg) (not truncate-lines)
6505 (> (prefix-numeric-value arg) 0)))
6508 (defun gnus-summary-find-for-reselect ()
6509 "Return the number of an article to stay on across a reselect.
6510 The current article is considered, then following articles, then previous
6511 articles. An article is sought which is not cancelled and isn't a temporary
6512 insertion from another group. If there's no such then return a dummy 0."
6514 (dolist (rev '(nil t))
6515 (unless found ; don't demand the reverse list if we don't need it
6516 (let ((data (gnus-data-find-list
6517 (gnus-summary-article-number) (gnus-data-list rev))))
6518 (while (and data (not found))
6519 (if (and (< 0 (gnus-data-number (car data)))
6520 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6521 (setq found (gnus-data-number (car data))))
6522 (setq data (cdr data))))))
6525 (defun gnus-summary-reselect-current-group (&optional all rescan)
6526 "Exit and then reselect the current newsgroup.
6527 The prefix argument ALL means to select all articles."
6529 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6530 (error "Ephemeral groups can't be reselected"))
6531 (let ((current-subject (gnus-summary-find-for-reselect))
6532 (group gnus-newsgroup-name))
6533 (setq gnus-newsgroup-begin nil)
6534 (gnus-summary-exit nil 'leave-hidden)
6535 ;; We have to adjust the point of group mode buffer because
6536 ;; point was moved to the next unread newsgroup by exiting.
6537 (gnus-summary-jump-to-group group)
6540 (save-window-excursion
6541 ;; Don't show group contents.
6542 (set-window-start (selected-window) (point-max))
6543 (gnus-group-get-new-news-this-group 1))))
6544 (gnus-group-read-group all t)
6545 (gnus-summary-goto-subject current-subject nil t)))
6547 (defun gnus-summary-rescan-group (&optional all)
6548 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6550 (gnus-summary-reselect-current-group all t))
6552 (defun gnus-summary-update-info (&optional non-destructive)
6554 (let ((group gnus-newsgroup-name))
6556 (when gnus-newsgroup-kill-headers
6557 (setq gnus-newsgroup-killed
6558 (gnus-compress-sequence
6560 (gnus-list-range-intersection
6561 gnus-newsgroup-unselected gnus-newsgroup-killed)
6562 gnus-newsgroup-unreads)
6564 (unless (listp (cdr gnus-newsgroup-killed))
6565 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6566 (let ((headers gnus-newsgroup-headers))
6567 ;; Set the new ranges of read articles.
6568 (with-current-buffer gnus-group-buffer
6569 (gnus-undo-force-boundary))
6570 (gnus-update-read-articles
6571 group (gnus-sorted-union
6572 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6573 ;; Set the current article marks.
6574 (let ((gnus-newsgroup-scored
6575 (if (and (not gnus-save-score)
6576 (not non-destructive))
6578 gnus-newsgroup-scored)))
6580 (gnus-update-marks)))
6581 ;; Do the cross-ref thing.
6582 (when gnus-use-cross-reference
6583 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6584 ;; Do not switch windows but change the buffer to work.
6585 (set-buffer gnus-group-buffer)
6586 (unless (gnus-ephemeral-group-p group)
6587 (gnus-group-update-group group)))))))
6589 (defun gnus-summary-save-newsrc (&optional force)
6590 "Save the current number of read/marked articles in the dribble buffer.
6591 The dribble buffer will then be saved.
6592 If FORCE (the prefix), also save the .newsrc file(s)."
6594 (gnus-summary-update-info t)
6596 (gnus-save-newsrc-file)
6597 (gnus-dribble-save)))
6599 (defun gnus-summary-exit (&optional temporary leave-hidden)
6600 "Exit reading current newsgroup, and then return to group selection mode.
6601 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6603 (gnus-set-global-variables)
6604 (gnus-kill-save-kill-buffer)
6605 (gnus-async-halt-prefetch)
6606 (let* ((group gnus-newsgroup-name)
6607 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6608 (gnus-group-is-exiting-p t)
6611 (buf (current-buffer)))
6613 ;; Do adaptive scoring, and possibly save score files.
6614 (when gnus-newsgroup-adaptive
6615 (gnus-score-adaptive))
6616 (when gnus-use-scoring
6618 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6619 ;; If we have several article buffers, we kill them at exit.
6620 (unless gnus-single-article-buffer
6621 (gnus-kill-buffer gnus-original-article-buffer)
6622 (setq gnus-article-current nil))
6623 (when gnus-use-cache
6624 (gnus-cache-possibly-remove-articles)
6625 (gnus-cache-save-buffers))
6626 (gnus-async-prefetch-remove-group group)
6627 (when gnus-suppress-duplicates
6628 (gnus-dup-enter-articles))
6629 (when gnus-use-trees
6630 (gnus-tree-close group))
6631 (when gnus-use-cache
6632 (gnus-cache-write-active))
6633 ;; Remove entries for this group.
6634 (nnmail-purge-split-history (gnus-group-real-name group))
6635 ;; Make all changes in this group permanent.
6637 (gnus-run-hooks 'gnus-exit-group-hook)
6638 (gnus-summary-update-info))
6639 (gnus-close-group group)
6640 ;; Make sure where we were, and go to next newsgroup.
6641 (set-buffer gnus-group-buffer)
6643 (gnus-group-jump-to-group group))
6644 (gnus-run-hooks 'gnus-summary-exit-hook)
6645 (unless (or quit-config
6646 ;; If this group has disappeared from the summary
6647 ;; buffer, don't skip forwards.
6648 (not (string= group (gnus-group-group-name))))
6649 (gnus-group-next-unread-group 1))
6650 (setq group-point (point))
6653 ;; If we have several article buffers, we kill them at exit.
6654 (unless gnus-single-article-buffer
6655 (gnus-kill-buffer gnus-article-buffer)
6656 (gnus-kill-buffer gnus-original-article-buffer)
6657 (setq gnus-article-current nil))
6659 (if (not gnus-kill-summary-on-exit)
6661 (gnus-deaden-summary)
6663 ;; We set all buffer-local variables to nil. It is unclear why
6664 ;; this is needed, but if we don't, buffer-local variables are
6665 ;; not garbage-collected, it seems. This would the lead to en
6666 ;; ever-growing Emacs.
6667 (gnus-summary-clear-local-variables)
6668 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6669 (gnus-summary-clear-local-variables))
6670 (when (get-buffer gnus-article-buffer)
6671 (bury-buffer gnus-article-buffer))
6672 ;; We clear the global counterparts of the buffer-local
6673 ;; variables as well, just to be on the safe side.
6674 (set-buffer gnus-group-buffer)
6675 (gnus-summary-clear-local-variables)
6676 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6677 (gnus-summary-clear-local-variables))
6678 ;; Return to group mode buffer.
6679 (when (eq mode 'gnus-summary-mode)
6680 (gnus-kill-buffer buf)))
6681 (setq gnus-current-select-method gnus-select-method)
6683 (set-buffer gnus-group-buffer)
6684 (pop-to-buffer gnus-group-buffer))
6685 (if (not quit-config)
6687 (goto-char group-point)
6688 (unless leave-hidden
6689 (gnus-configure-windows 'group 'force))
6690 (unless (pos-visible-in-window-p)
6691 (forward-line (/ (static-if (featurep 'xemacs)
6692 (window-displayed-height)
6693 (1- (window-height)))
6695 (set-window-start (selected-window) (point))
6696 (goto-char group-point)))
6697 (gnus-handle-ephemeral-exit quit-config))
6698 ;; Clear the current group name.
6700 (setq gnus-newsgroup-name nil)))))
6702 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6703 (defun gnus-summary-exit-no-update (&optional no-questions)
6704 "Quit reading current newsgroup without updating read article info."
6706 (let* ((group gnus-newsgroup-name)
6707 (gnus-group-is-exiting-p t)
6708 (gnus-group-is-exiting-without-update-p t)
6709 (quit-config (gnus-group-quit-config group)))
6710 (when (or no-questions
6712 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6713 (gnus-async-halt-prefetch)
6714 (run-hooks 'gnus-summary-prepare-exit-hook)
6715 ;; If we have several article buffers, we kill them at exit.
6716 (unless gnus-single-article-buffer
6717 (gnus-kill-buffer gnus-article-buffer)
6718 (gnus-kill-buffer gnus-original-article-buffer)
6719 (setq gnus-article-current nil))
6720 (if (not gnus-kill-summary-on-exit)
6721 (gnus-deaden-summary)
6722 (gnus-close-group group)
6723 (gnus-summary-clear-local-variables)
6724 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6725 (gnus-summary-clear-local-variables))
6726 (set-buffer gnus-group-buffer)
6727 (gnus-summary-clear-local-variables)
6728 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6729 (gnus-summary-clear-local-variables))
6730 (gnus-kill-buffer gnus-summary-buffer))
6731 (unless gnus-single-article-buffer
6732 (setq gnus-article-current nil))
6733 (when gnus-use-trees
6734 (gnus-tree-close group))
6735 (gnus-async-prefetch-remove-group group)
6736 (when (get-buffer gnus-article-buffer)
6737 (bury-buffer gnus-article-buffer))
6738 ;; Return to the group buffer.
6739 (gnus-configure-windows 'group 'force)
6740 ;; Clear the current group name.
6741 (setq gnus-newsgroup-name nil)
6742 (unless (gnus-ephemeral-group-p group)
6743 (gnus-group-update-group group))
6744 (when (equal (gnus-group-group-name) group)
6745 (gnus-group-next-unread-group 1))
6747 (gnus-handle-ephemeral-exit quit-config)))))
6749 (defun gnus-handle-ephemeral-exit (quit-config)
6750 "Handle movement when leaving an ephemeral group.
6751 The state which existed when entering the ephemeral is reset."
6752 (if (not (buffer-name (car quit-config)))
6753 (gnus-configure-windows 'group 'force)
6754 (set-buffer (car quit-config))
6755 (cond ((eq major-mode 'gnus-summary-mode)
6756 (gnus-set-global-variables))
6757 ((eq major-mode 'gnus-article-mode)
6759 ;; The `gnus-summary-buffer' variable may point
6760 ;; to the old summary buffer when using a single
6762 (unless (gnus-buffer-live-p gnus-summary-buffer)
6763 (set-buffer gnus-group-buffer))
6764 (set-buffer gnus-summary-buffer)
6765 (gnus-set-global-variables))))
6766 (if (or (eq (cdr quit-config) 'article)
6767 (eq (cdr quit-config) 'pick))
6769 ;; The current article may be from the ephemeral group
6770 ;; thus it is best that we reload this article
6772 ;; If we're exiting from a large digest, this can be
6773 ;; extremely slow. So, it's better not to reload it. -- jh.
6774 ;;(gnus-summary-show-article)
6775 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6776 (gnus-configure-windows 'pick 'force)
6777 (gnus-configure-windows (cdr quit-config) 'force)))
6778 (gnus-configure-windows (cdr quit-config) 'force))
6779 (when (eq major-mode 'gnus-summary-mode)
6780 (gnus-summary-next-subject 1 nil t)
6781 (gnus-summary-recenter)
6782 (gnus-summary-position-point))))
6784 (defun gnus-summary-preview-mime-message ()
6785 "MIME decode and play this message."
6787 (let ((gnus-break-pages nil)
6789 (gnus-summary-select-article gnus-show-all-headers t))
6790 (let ((w (get-buffer-window gnus-article-buffer)))
6792 (select-window (get-buffer-window gnus-article-buffer)))))
6796 (defvar gnus-dead-summary-mode-map nil)
6798 (unless gnus-dead-summary-mode-map
6799 (setq gnus-dead-summary-mode-map (make-keymap))
6800 (suppress-keymap gnus-dead-summary-mode-map)
6801 (substitute-key-definition
6802 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6803 (dolist (key '("\C-d" "\r" "\177" [delete]))
6804 (define-key gnus-dead-summary-mode-map
6805 key 'gnus-summary-wake-up-the-dead))
6806 (dolist (key '("q" "Q"))
6807 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6809 (defvar gnus-dead-summary-mode nil
6810 "Minor mode for Gnus summary buffers.")
6812 (defun gnus-dead-summary-mode (&optional arg)
6813 "Minor mode for Gnus summary buffers."
6815 (when (eq major-mode 'gnus-summary-mode)
6816 (make-local-variable 'gnus-dead-summary-mode)
6817 (setq gnus-dead-summary-mode
6818 (if (null arg) (not gnus-dead-summary-mode)
6819 (> (prefix-numeric-value arg) 0)))
6820 (when gnus-dead-summary-mode
6822 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6824 (defun gnus-deaden-summary ()
6825 "Make the current summary buffer into a dead summary buffer."
6826 ;; Kill any previous dead summary buffer.
6827 (when (and gnus-dead-summary
6828 (buffer-name gnus-dead-summary))
6829 (with-current-buffer gnus-dead-summary
6830 (when gnus-dead-summary-mode
6831 (kill-buffer (current-buffer)))))
6832 ;; Make this the current dead summary.
6833 (setq gnus-dead-summary (current-buffer))
6834 (gnus-dead-summary-mode 1)
6835 (let ((name (buffer-name)))
6836 (when (string-match "Summary" name)
6838 (concat (substring name 0 (match-beginning 0)) "Dead "
6839 (substring name (match-beginning 0)))
6843 (defun gnus-kill-or-deaden-summary (buffer)
6844 "Kill or deaden the summary BUFFER."
6846 (when (and (buffer-name buffer)
6847 (not gnus-single-article-buffer))
6848 (with-current-buffer buffer
6849 (gnus-kill-buffer gnus-article-buffer)
6850 (gnus-kill-buffer gnus-original-article-buffer)))
6853 (gnus-kill-summary-on-exit
6854 (when (and gnus-use-trees
6855 (gnus-buffer-exists-p buffer))
6858 (gnus-tree-close gnus-newsgroup-name)))
6859 (gnus-kill-buffer buffer))
6860 ;; Deaden the buffer.
6861 ((gnus-buffer-exists-p buffer)
6864 (gnus-deaden-summary))))))
6866 (defun gnus-summary-wake-up-the-dead (&rest args)
6867 "Wake up the dead summary buffer."
6869 (gnus-dead-summary-mode -1)
6870 (let ((name (buffer-name)))
6871 (when (string-match "Dead " name)
6873 (concat (substring name 0 (match-beginning 0))
6874 (substring name (match-end 0)))
6876 (gnus-message 3 "This dead summary is now alive again"))
6878 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6879 (defun gnus-summary-fetch-faq (&optional faq-dir)
6880 "Fetch the FAQ for the current group.
6881 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6885 (when current-prefix-arg
6887 "FAQ dir: " (and (listp gnus-group-faq-directory)
6889 gnus-group-faq-directory))))))
6890 (let (gnus-faq-buffer)
6891 (when (setq gnus-faq-buffer
6892 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6893 (gnus-configure-windows 'summary-faq))))
6895 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6896 (defun gnus-summary-describe-group (&optional force)
6897 "Describe the current newsgroup."
6899 (gnus-group-describe-group force gnus-newsgroup-name))
6901 (defun gnus-summary-describe-briefly ()
6902 "Describe summary mode commands briefly."
6904 (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")))
6906 ;; Walking around group mode buffer from summary mode.
6908 (defun gnus-summary-next-group (&optional no-article target-group backward)
6909 "Exit current newsgroup and then select next unread newsgroup.
6910 If prefix argument NO-ARTICLE is non-nil, no article is selected
6911 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6912 previous group instead."
6914 ;; Stop pre-fetching.
6915 (gnus-async-halt-prefetch)
6916 (let ((current-group gnus-newsgroup-name)
6917 (current-buffer (current-buffer))
6919 ;; First we semi-exit this group to update Xrefs and all variables.
6920 ;; We can't do a real exit, because the window conf must remain
6921 ;; the same in case the user is prompted for info, and we don't
6922 ;; want the window conf to change before that...
6923 (gnus-summary-exit t)
6924 (while (not entered)
6925 ;; Then we find what group we are supposed to enter.
6926 (set-buffer gnus-group-buffer)
6927 (gnus-group-jump-to-group current-group)
6930 (if (eq gnus-keep-same-level 'best)
6931 (gnus-summary-best-group gnus-newsgroup-name)
6932 (gnus-summary-search-group backward gnus-keep-same-level))))
6933 (if (not target-group)
6934 ;; There are no further groups, so we return to the group
6937 (gnus-message 5 "Returning to the group buffer")
6939 (when (gnus-buffer-live-p current-buffer)
6940 (set-buffer current-buffer)
6941 (gnus-summary-exit))
6942 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6943 ;; We try to enter the target group.
6944 (gnus-group-jump-to-group target-group)
6945 (let ((unreads (gnus-group-group-unread)))
6946 (if (and (or (eq t unreads)
6947 (and unreads (not (zerop unreads))))
6948 (gnus-summary-read-group
6949 target-group nil no-article
6950 (and (buffer-name current-buffer) current-buffer)
6953 (setq current-group target-group
6954 target-group nil)))))))
6956 (defun gnus-summary-prev-group (&optional no-article)
6957 "Exit current newsgroup and then select previous unread newsgroup.
6958 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6960 (gnus-summary-next-group no-article nil t))
6962 ;; Walking around summary lines.
6964 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6965 "Go to the first subject satisfying any non-nil constraint.
6966 If UNREAD is non-nil, the article should be unread.
6967 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6968 If UNSEEN is non-nil, the article should be unseen.
6969 Returns the article selected or nil if there are no matching articles."
6973 ((null gnus-newsgroup-data)
6974 (gnus-message 3 "No articles in the group")
6976 ;; Pick the first article.
6977 ((not (or unread undownloaded unseen))
6978 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6979 (gnus-data-number (car gnus-newsgroup-data)))
6980 ;; Find the first unread article.
6982 (let ((data gnus-newsgroup-data))
6984 (let ((num (gnus-data-number (car data))))
6985 (or (memq num gnus-newsgroup-unfetched)
6986 (not (or (and unread
6987 (memq num gnus-newsgroup-unreads))
6989 (memq num gnus-newsgroup-undownloaded))
6991 (memq num gnus-newsgroup-unseen)))))))
6992 (setq data (cdr data)))
6996 (goto-char (gnus-data-pos (car data)))
6997 (gnus-data-number (car data)))
6998 (gnus-message 3 "No more%s articles"
6999 (let* ((r (when unread " unread"))
7000 (d (when undownloaded " undownloaded"))
7001 (s (when unseen " unseen"))
7002 (l (delq nil (list r d s))))
7003 (cond ((= 3 (length l))
7004 (concat r "," d ", or" s))
7006 (concat (car l) ", or" (cadr l)))
7013 (gnus-summary-position-point))))))
7015 (defun gnus-summary-next-subject (n &optional unread dont-display)
7016 "Go to next N'th summary line.
7017 If N is negative, go to the previous N'th subject line.
7018 If UNREAD is non-nil, only unread articles are selected.
7019 The difference between N and the actual number of steps taken is
7022 (let ((backward (< n 0))
7026 (gnus-summary-find-prev unread)
7027 (gnus-summary-find-next unread)))
7028 (unless (zerop (setq n (1- n)))
7029 (gnus-summary-show-thread)))
7031 (gnus-message 7 "No more%s articles"
7032 (if unread " unread" "")))
7033 (unless dont-display
7034 (gnus-summary-recenter)
7035 (gnus-summary-position-point))
7038 (defun gnus-summary-next-unread-subject (n)
7039 "Go to next N'th unread summary line."
7041 (gnus-summary-next-subject n t))
7043 (defun gnus-summary-prev-subject (n &optional unread)
7044 "Go to previous N'th summary line.
7045 If optional argument UNREAD is non-nil, only unread article is selected."
7047 (gnus-summary-next-subject (- n) unread))
7049 (defun gnus-summary-prev-unread-subject (n)
7050 "Go to previous N'th unread summary line."
7052 (gnus-summary-next-subject (- n) t))
7054 (defun gnus-summary-goto-subjects (articles)
7055 "Insert the subject header for ARTICLES in the current buffer."
7057 (dolist (article articles)
7058 (gnus-summary-goto-subject article t)))
7059 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7060 (gnus-summary-position-point))
7062 (defun gnus-summary-goto-subject (article &optional force silent)
7063 "Go the subject line of ARTICLE.
7064 If FORCE, also allow jumping to articles not currently shown."
7065 (interactive "nArticle number: ")
7066 (unless (numberp article)
7067 (error "Article %s is not a number" article))
7069 (data (gnus-data-find article)))
7070 ;; We read in the article if we have to.
7073 (gnus-summary-insert-subject
7075 (if (or (numberp force) (vectorp force)) force)
7077 (setq data (gnus-data-find article)))
7082 (gnus-message 3 "Can't find article %d" article))
7084 (let ((pt (gnus-data-pos data)))
7086 (gnus-summary-set-article-display-arrow pt))
7087 (gnus-summary-position-point)
7090 ;; Walking around summary lines with displaying articles.
7092 (defun gnus-summary-expand-window (&optional arg)
7093 "Make the summary buffer take up the entire Emacs frame.
7094 Given a prefix, will force an `article' buffer configuration."
7097 (gnus-configure-windows 'article 'force)
7098 (gnus-configure-windows 'summary 'force)))
7100 (defun gnus-summary-display-article (article &optional all-header)
7101 "Display ARTICLE in article buffer."
7102 (when (gnus-buffer-live-p gnus-article-buffer)
7103 (with-current-buffer gnus-article-buffer
7104 (set-buffer-multibyte t)))
7105 (gnus-set-global-variables)
7106 (when (gnus-buffer-live-p gnus-article-buffer)
7107 (with-current-buffer gnus-article-buffer
7108 (setq gnus-article-charset gnus-newsgroup-charset)
7109 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7110 (set-buffer-multibyte t)))
7114 (if gnus-summary-display-article-function
7115 (funcall gnus-summary-display-article-function article all-header)
7116 (gnus-article-prepare article all-header))
7117 (with-current-buffer gnus-article-buffer
7118 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7120 (gnus-run-hooks 'gnus-select-article-hook)
7121 (when (and gnus-current-article
7122 (not (zerop gnus-current-article)))
7123 (gnus-summary-goto-subject gnus-current-article))
7124 (gnus-summary-recenter)
7125 (when (and gnus-use-trees gnus-show-threads)
7126 (gnus-possibly-generate-tree article)
7127 (gnus-highlight-selected-tree article))
7128 ;; Successfully display article.
7129 (gnus-article-set-window-start
7130 (cdr (assq article gnus-newsgroup-bookmarks))))))
7132 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7133 "Select the current article.
7134 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7135 non-nil, the article will be re-fetched even if it already present in
7136 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7138 ;; Make sure we are in the summary buffer to work around bbdb bug.
7139 (unless (eq major-mode 'gnus-summary-mode)
7140 (set-buffer gnus-summary-buffer))
7141 (let ((article (or article (gnus-summary-article-number)))
7142 (all-headers (not (not all-headers))) ;Must be T or NIL.
7143 gnus-summary-display-article-function)
7145 (gnus-summary-article-pseudo-p article)
7146 (error "This is a pseudo-article"))
7148 (set-buffer gnus-summary-buffer)
7149 (if (or (and gnus-single-article-buffer
7150 (or (null gnus-current-article)
7151 (null gnus-article-current)
7152 (null (get-buffer gnus-article-buffer))
7153 (not (eq article (cdr gnus-article-current)))
7154 (not (equal (car gnus-article-current)
7155 gnus-newsgroup-name))))
7156 (and (not gnus-single-article-buffer)
7157 (or (null gnus-current-article)
7158 (not (eq gnus-current-article article))))
7160 ;; The requested article is different from the current article.
7162 (gnus-summary-display-article article all-headers)
7163 (gnus-article-set-window-start
7164 (cdr (assq article gnus-newsgroup-bookmarks)))
7168 (defun gnus-summary-force-verify-and-decrypt ()
7169 "Display buttons for signed/encrypted parts and verify/decrypt them."
7171 (let ((mm-verify-option 'known)
7172 (mm-decrypt-option 'known)
7173 (gnus-article-emulate-mime t)
7174 (mm-fill-flowed nil)
7175 (gnus-buttonized-mime-types (append (list "multipart/signed"
7176 "multipart/encrypted")
7177 gnus-buttonized-mime-types)))
7178 (gnus-summary-select-article nil 'force)))
7180 (defun gnus-summary-set-current-mark (&optional current-mark)
7181 "Obsolete function."
7184 (defun gnus-summary-next-article (&optional unread subject backward push)
7185 "Select the next article.
7186 If UNREAD, only unread articles are selected.
7187 If SUBJECT, only articles with SUBJECT are selected.
7188 If BACKWARD, the previous article is selected instead of the next."
7191 ;; Is there such an article?
7192 ((and (gnus-summary-search-forward unread subject backward)
7193 (or (gnus-summary-display-article (gnus-summary-article-number))
7194 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7195 (gnus-summary-position-point))
7196 ;; If not, we try the first unread, if that is wanted.
7198 gnus-auto-select-same
7199 (gnus-summary-first-unread-article))
7200 (gnus-summary-position-point)
7201 (gnus-message 6 "Wrapped"))
7202 ;; Try to get next/previous article not displayed in this group.
7203 ((and gnus-auto-extend-newsgroup
7204 (not unread) (not subject))
7205 (gnus-summary-goto-article
7206 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7207 nil (count-lines (point-min) (point))))
7208 ;; Go to next/previous group.
7210 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7211 (gnus-summary-jump-to-group gnus-newsgroup-name))
7212 (let ((cmd last-command-char)
7214 (with-current-buffer gnus-group-buffer
7217 (if (eq gnus-keep-same-level 'best)
7218 (gnus-summary-best-group gnus-newsgroup-name)
7219 (gnus-summary-search-group backward gnus-keep-same-level))))
7220 ;; For some reason, the group window gets selected. We change
7222 (select-window (get-buffer-window (current-buffer)))
7223 ;; Select next unread newsgroup automagically.
7225 ((or (not gnus-auto-select-next)
7227 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7228 ((or (eq gnus-auto-select-next 'quietly)
7229 (and (eq gnus-auto-select-next 'slightly-quietly)
7231 (and (eq gnus-auto-select-next 'almost-quietly)
7232 (gnus-summary-last-article-p)))
7234 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7236 (gnus-message 7 "No more%s articles (%s)..."
7237 (if unread " unread" "")
7238 (if group (concat "selecting " group)
7240 (gnus-summary-next-group nil group backward)))
7242 (when (gnus-key-press-event-p last-input-event)
7243 (gnus-summary-walk-group-buffer
7244 gnus-newsgroup-name cmd unread backward point))))))))
7246 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7247 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7248 (?\C-p (gnus-group-prev-unread-group 1))))
7249 (cursor-in-echo-area t)
7250 keve key group ended prompt)
7252 (set-buffer gnus-group-buffer)
7255 (if (eq gnus-keep-same-level 'best)
7256 (gnus-summary-best-group gnus-newsgroup-name)
7257 (gnus-summary-search-group backward gnus-keep-same-level))))
7261 "No more%s articles%s " (if unread " unread" "")
7263 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7264 (format " (Type %s for %s [%s])"
7265 (single-key-description cmd) group
7266 (gnus-group-unread group))
7267 (format " (Type %s to exit %s)"
7268 (single-key-description cmd)
7269 gnus-newsgroup-name))))
7270 ;; Confirm auto selection.
7271 (setq key (car (setq keve (gnus-read-event-char prompt)))
7274 ((assq key keystrokes)
7275 (let ((obuf (current-buffer)))
7276 (switch-to-buffer gnus-group-buffer)
7278 (gnus-group-jump-to-group group))
7279 (eval (cadr (assq key keystrokes)))
7280 (setq group (gnus-group-group-name))
7281 (switch-to-buffer obuf))
7285 (gnus-ephemeral-group-p gnus-newsgroup-name))
7287 (gnus-summary-next-group nil group backward)))
7289 (push (cdr keve) unread-command-events))))))
7291 (defun gnus-summary-next-unread-article ()
7292 "Select unread article after current one."
7294 (gnus-summary-next-article
7295 (or (not (eq gnus-summary-goto-unread 'never))
7296 (gnus-summary-last-article-p (gnus-summary-article-number)))
7297 (and gnus-auto-select-same
7298 (gnus-summary-article-subject))))
7300 (defun gnus-summary-prev-article (&optional unread subject)
7301 "Select the article after the current one.
7302 If UNREAD is non-nil, only unread articles are selected."
7304 (gnus-summary-next-article unread subject t))
7306 (defun gnus-summary-prev-unread-article ()
7307 "Select unread article before current one."
7309 (gnus-summary-prev-article
7310 (or (not (eq gnus-summary-goto-unread 'never))
7311 (gnus-summary-first-article-p (gnus-summary-article-number)))
7312 (and gnus-auto-select-same
7313 (gnus-summary-article-subject))))
7315 (defun gnus-summary-next-page (&optional lines circular stop)
7316 "Show next page of the selected article.
7317 If at the end of the current article, select the next article.
7318 LINES says how many lines should be scrolled up.
7320 If CIRCULAR is non-nil, go to the start of the article instead of
7321 selecting the next article when reaching the end of the current
7324 If STOP is non-nil, just stop when reaching the end of the message.
7326 Also see the variable `gnus-article-skip-boring'."
7328 (setq gnus-summary-buffer (current-buffer))
7329 (gnus-set-global-variables)
7330 (let ((article (gnus-summary-article-number))
7331 (article-window (get-buffer-window gnus-article-buffer t))
7333 ;; If the buffer is empty, we have no article.
7335 (error "No article to select"))
7336 (gnus-configure-windows 'article)
7337 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7338 (if (and (eq gnus-summary-goto-unread 'never)
7339 (not (gnus-summary-last-article-p article)))
7340 (gnus-summary-next-article)
7341 (gnus-summary-next-unread-article))
7342 (if (or (null gnus-current-article)
7343 (null gnus-article-current)
7344 (/= article (cdr gnus-article-current))
7345 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7346 ;; Selected subject is different from current article's.
7347 (gnus-summary-display-article article)
7348 (when article-window
7349 (gnus-eval-in-buffer-window gnus-article-buffer
7350 (setq endp (or (gnus-article-next-page lines)
7351 (gnus-article-only-boring-p))))
7354 (gnus-message 3 "End of message"))
7356 (gnus-summary-beginning-of-article))
7358 (gnus-message 3 "End of message"))
7360 (if (and (eq gnus-summary-goto-unread 'never)
7361 (not (gnus-summary-last-article-p article)))
7362 (gnus-summary-next-article)
7363 (gnus-summary-next-unread-article))))))))
7364 (gnus-summary-recenter)
7365 (gnus-summary-position-point)))
7367 (defun gnus-summary-prev-page (&optional lines move)
7368 "Show previous page of selected article.
7369 Argument LINES specifies lines to be scrolled down.
7370 If MOVE, move to the previous unread article if point is at
7371 the beginning of the buffer."
7373 (let ((article (gnus-summary-article-number))
7374 (article-window (get-buffer-window gnus-article-buffer t))
7376 (gnus-configure-windows 'article)
7377 (if (or (null gnus-current-article)
7378 (null gnus-article-current)
7379 (/= article (cdr gnus-article-current))
7380 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7381 ;; Selected subject is different from current article's.
7382 (gnus-summary-display-article article)
7383 (gnus-summary-recenter)
7384 (when article-window
7385 (gnus-eval-in-buffer-window gnus-article-buffer
7386 (setq endp (gnus-article-prev-page lines)))
7387 (when (and move endp)
7389 (gnus-message 3 "Beginning of message"))
7391 (if (and (eq gnus-summary-goto-unread 'never)
7392 (not (gnus-summary-first-article-p article)))
7393 (gnus-summary-prev-article)
7394 (gnus-summary-prev-unread-article))))))))
7395 (gnus-summary-position-point))
7397 (defun gnus-summary-prev-page-or-article (&optional lines)
7398 "Show previous page of selected article.
7399 Argument LINES specifies lines to be scrolled down.
7400 If at the beginning of the article, go to the next article."
7402 (gnus-summary-prev-page lines t))
7404 (defun gnus-summary-scroll-up (lines)
7405 "Scroll up (or down) one line current article.
7406 Argument LINES specifies lines to be scrolled up (or down if negative)."
7408 (gnus-configure-windows 'article)
7409 (gnus-summary-show-thread)
7410 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7411 (gnus-eval-in-buffer-window gnus-article-buffer
7413 (when (gnus-article-next-page lines)
7414 (gnus-message 3 "End of message")))
7416 (gnus-article-prev-page (- lines))))))
7417 (gnus-summary-recenter)
7418 (gnus-summary-position-point))
7420 (defun gnus-summary-scroll-down (lines)
7421 "Scroll down (or up) one line current article.
7422 Argument LINES specifies lines to be scrolled down (or up if negative)."
7424 (gnus-summary-scroll-up (- lines)))
7426 (defun gnus-summary-next-same-subject ()
7427 "Select next article which has the same subject as current one."
7429 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7431 (defun gnus-summary-prev-same-subject ()
7432 "Select previous article which has the same subject as current one."
7434 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7436 (defun gnus-summary-next-unread-same-subject ()
7437 "Select next unread article which has the same subject as current one."
7439 (gnus-summary-next-article t (gnus-summary-article-subject)))
7441 (defun gnus-summary-prev-unread-same-subject ()
7442 "Select previous unread article which has the same subject as current one."
7444 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7446 (defun gnus-summary-first-unread-article ()
7447 "Select the first unread article.
7448 Return nil if there are no unread articles."
7451 (when (gnus-summary-first-subject t)
7452 (gnus-summary-show-thread)
7453 (gnus-summary-first-subject t)
7454 (gnus-summary-display-article (gnus-summary-article-number)))
7455 (gnus-summary-position-point)))
7457 (defun gnus-summary-first-unread-subject ()
7458 "Place the point on the subject line of the first unread article.
7459 Return nil if there are no unread articles."
7462 (when (gnus-summary-first-subject t)
7463 (gnus-summary-show-thread)
7464 (gnus-summary-first-subject t))
7465 (gnus-summary-position-point)))
7467 (defun gnus-summary-first-unseen-subject ()
7468 "Place the point on the subject line of the first unseen article.
7469 Return nil if there are no unseen articles."
7472 (when (gnus-summary-first-subject nil nil t)
7473 (gnus-summary-show-thread)
7474 (gnus-summary-first-subject nil nil t))
7475 (gnus-summary-position-point)))
7477 (defun gnus-summary-first-unseen-or-unread-subject ()
7478 "Place the point on the subject line of the first unseen article or,
7479 if all article have been seen, on the subject line of the first unread
7483 (unless (when (gnus-summary-first-subject nil nil t)
7484 (gnus-summary-show-thread)
7485 (gnus-summary-first-subject nil nil t))
7486 (when (gnus-summary-first-subject t)
7487 (gnus-summary-show-thread)
7488 (gnus-summary-first-subject t)))
7489 (gnus-summary-position-point)))
7491 (defun gnus-summary-first-article ()
7492 "Select the first article.
7493 Return nil if there are no articles."
7496 (when (gnus-summary-first-subject)
7497 (gnus-summary-show-thread)
7498 (gnus-summary-first-subject)
7499 (gnus-summary-display-article (gnus-summary-article-number)))
7500 (gnus-summary-position-point)))
7502 (defun gnus-summary-best-unread-article (&optional arg)
7503 "Select the unread article with the highest score.
7504 If given a prefix argument, select the next unread article that has a
7505 score higher than the default score."
7507 (let ((article (if arg
7508 (gnus-summary-better-unread-subject)
7509 (gnus-summary-best-unread-subject))))
7511 (gnus-summary-goto-article article)
7512 (error "No unread articles"))))
7514 (defun gnus-summary-best-unread-subject ()
7515 "Select the unread subject with the highest score."
7517 (let ((best -1000000)
7518 (data gnus-newsgroup-data)
7521 (and (gnus-data-unread-p (car data))
7523 (gnus-summary-article-score (gnus-data-number (car data))))
7526 article (gnus-data-number (car data))))
7527 (setq data (cdr data)))
7529 (gnus-summary-goto-subject article))
7530 (gnus-summary-position-point)
7533 (defun gnus-summary-better-unread-subject ()
7534 "Select the first unread subject that has a score over the default score."
7536 (let ((data gnus-newsgroup-data)
7538 (while (and (setq article (gnus-data-number (car data)))
7539 (or (gnus-data-read-p (car data))
7540 (not (> (gnus-summary-article-score article)
7541 gnus-summary-default-score))))
7542 (setq data (cdr data)))
7544 (gnus-summary-goto-subject article))
7545 (gnus-summary-position-point)
7548 (defun gnus-summary-last-subject ()
7549 "Go to the last displayed subject line in the group."
7550 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7552 (gnus-summary-goto-subject article))))
7554 (defun gnus-summary-goto-article (article &optional all-headers force)
7555 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7556 If ALL-HEADERS is non-nil, no header lines are hidden.
7557 If FORCE, go to the article even if it isn't displayed. If FORCE
7558 is a number, it is the line the article is to be displayed on."
7562 "Article number or Message-ID: "
7563 (mapcar (lambda (number) (list (int-to-string number)))
7564 gnus-newsgroup-limit))
7568 (if (and (stringp article)
7569 (string-match "@\\|%40" article))
7570 (gnus-summary-refer-article article)
7571 (when (stringp article)
7572 (setq article (string-to-number article)))
7573 (if (gnus-summary-goto-subject article force)
7574 (gnus-summary-display-article article all-headers)
7575 (gnus-message 4 "Couldn't go to article %s" article) nil))
7576 (gnus-summary-position-point)))
7578 (defun gnus-summary-goto-last-article ()
7579 "Go to the previously read article."
7582 (when gnus-last-article
7583 (gnus-summary-goto-article gnus-last-article nil t))
7584 (gnus-summary-position-point)))
7586 (defun gnus-summary-pop-article (number)
7587 "Pop one article off the history and go to the previous.
7588 NUMBER articles will be popped off."
7591 (setq gnus-newsgroup-history
7592 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7594 (gnus-summary-goto-article (car to) nil t)
7595 (error "Article history empty")))
7596 (gnus-summary-position-point))
7598 ;; Summary commands and functions for limiting the summary buffer.
7600 (defun gnus-summary-limit-to-articles (n)
7601 "Limit the summary buffer to the next N articles.
7602 If not given a prefix, use the process marked articles instead."
7605 (let ((articles (gnus-summary-work-articles n)))
7606 (setq gnus-newsgroup-processable nil)
7607 (gnus-summary-limit articles))
7608 (gnus-summary-position-point)))
7610 (defun gnus-summary-pop-limit (&optional total)
7611 "Restore the previous limit.
7612 If given a prefix, remove all limits."
7615 (setq gnus-newsgroup-limits
7616 (list (mapcar (lambda (h) (mail-header-number h))
7617 gnus-newsgroup-headers))))
7618 (unless gnus-newsgroup-limits
7619 (error "No limit to pop"))
7621 (gnus-summary-limit nil 'pop)
7622 (gnus-summary-position-point)))
7624 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7625 "Limit the summary buffer to articles that have subjects that match a regexp.
7626 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7628 (list (read-string (if current-prefix-arg
7629 "Exclude subject (regexp): "
7630 "Limit to subject (regexp): "))
7631 nil current-prefix-arg))
7633 (setq header "subject"))
7634 (when (not (equal "" subject))
7636 (let ((articles (gnus-summary-find-matching
7637 (or header "subject") subject 'all nil nil
7640 (error "Found no matches for \"%s\"" subject))
7641 (gnus-summary-limit articles))
7642 (gnus-summary-position-point))))
7644 (defun gnus-summary-limit-to-author (from &optional not-matching)
7645 "Limit the summary buffer to articles that have authors that match a regexp.
7646 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7648 (list (read-string (if current-prefix-arg
7649 "Exclude author (regexp): "
7650 "Limit to author (regexp): "))
7651 current-prefix-arg))
7652 (gnus-summary-limit-to-subject from "from" not-matching))
7654 (defun gnus-summary-limit-to-age (age &optional younger-p)
7655 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7656 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7657 articles that are younger than AGE days."
7659 (let ((younger current-prefix-arg)
7662 (while (not days-got)
7663 (setq days (if younger
7664 (read-string "Limit to articles younger than (in days, older when negative): ")
7666 "Limit to articles older than (in days, younger when negative): ")))
7667 (when (> (length days) 0)
7668 (setq days (read days)))
7673 (setq younger (not younger))
7674 (setq days (* days -1))))
7675 (message "Please enter a number.")
7677 (list days younger)))
7679 (let ((data gnus-newsgroup-data)
7680 (cutoff (days-to-time age))
7681 articles d date is-younger)
7682 (while (setq d (pop data))
7683 (when (and (vectorp (gnus-data-header d))
7684 (setq date (mail-header-date (gnus-data-header d))))
7685 (setq is-younger (time-less-p
7686 (time-since (condition-case ()
7693 (push (gnus-data-number d) articles))))
7694 (gnus-summary-limit (nreverse articles)))
7695 (gnus-summary-position-point)))
7697 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7698 "Limit the summary buffer to articles that match an 'extra' header."
7702 (gnus-completing-read-with-default
7703 (symbol-name (car gnus-extra-headers))
7704 (if current-prefix-arg
7705 "Exclude extra header:"
7706 "Limit extra header:")
7708 (cons (symbol-name x) x))
7713 (read-string (format "%s header %s (regexp): "
7714 (if current-prefix-arg "Exclude" "Limit to")
7716 current-prefix-arg)))
7717 (when (not (equal "" regexp))
7719 (let ((articles (gnus-summary-find-matching
7720 (cons 'extra header) regexp 'all nil nil
7723 (error "Found no matches for \"%s\"" regexp))
7724 (gnus-summary-limit articles))
7725 (gnus-summary-position-point))))
7727 (defun gnus-summary-limit-to-display-predicate ()
7728 "Limit the summary buffer to the predicated in the `display' group parameter."
7730 (unless gnus-newsgroup-display
7731 (error "There is no `display' group parameter"))
7733 (dolist (number gnus-newsgroup-articles)
7734 (when (funcall gnus-newsgroup-display)
7735 (push number articles)))
7736 (gnus-summary-limit articles))
7737 (gnus-summary-position-point))
7739 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7741 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7743 (defun gnus-summary-limit-to-unread (&optional all)
7744 "Limit the summary buffer to articles that are not marked as read.
7745 If ALL is non-nil, limit strictly to unread articles."
7748 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7749 (gnus-summary-limit-to-marks
7750 ;; Concat all the marks that say that an article is read and have
7752 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7753 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7754 gnus-low-score-mark gnus-expirable-mark
7755 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7756 gnus-duplicate-mark gnus-souped-mark)
7759 (defun gnus-summary-limit-to-replied (&optional unreplied)
7760 "Limit the summary buffer to replied articles.
7761 If UNREPLIED (the prefix), limit to unreplied articles."
7765 (gnus-set-difference gnus-newsgroup-articles
7766 gnus-newsgroup-replied))
7767 (gnus-summary-limit gnus-newsgroup-replied))
7768 (gnus-summary-position-point))
7770 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7771 (make-obsolete 'gnus-summary-delete-marked-with
7772 'gnus-summary-limit-exclude-marks)
7774 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7775 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7776 If REVERSE, limit the summary buffer to articles that are marked
7777 with MARKS. MARKS can either be a string of marks or a list of marks.
7778 Returns how many articles were removed."
7779 (interactive "sMarks: ")
7780 (gnus-summary-limit-to-marks marks t))
7782 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7783 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7784 If REVERSE (the prefix), limit the summary buffer to articles that are
7785 not marked with MARKS. MARKS can either be a string of marks or a
7787 Returns how many articles were removed."
7788 (interactive "sMarks: \nP")
7790 (let ((data gnus-newsgroup-data)
7791 (marks (if (listp marks) marks
7792 (append marks nil))) ; Transform to list.
7795 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7796 (memq (gnus-data-mark (car data)) marks))
7797 (push (gnus-data-number (car data)) articles))
7798 (setq data (cdr data)))
7799 (gnus-summary-limit articles))
7800 (gnus-summary-position-point)))
7802 (defun gnus-summary-limit-to-score (score)
7803 "Limit to articles with score at or above SCORE."
7804 (interactive "NLimit to articles with score of at least: ")
7805 (let ((data gnus-newsgroup-data)
7808 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7810 (push (gnus-data-number (car data)) articles))
7811 (setq data (cdr data)))
7813 (gnus-summary-limit articles)
7814 (gnus-summary-position-point))))
7816 (defun gnus-summary-limit-to-unseen ()
7817 "Limit to unseen articles."
7820 (gnus-summary-limit gnus-newsgroup-unseen)
7821 (gnus-summary-position-point)))
7823 (defun gnus-summary-limit-include-thread (id)
7824 "Display all the hidden articles that is in the thread with ID in it.
7825 When called interactively, ID is the Message-ID of the current
7827 (interactive (list (mail-header-id (gnus-summary-article-header))))
7828 (let ((articles (gnus-articles-in-thread
7829 (gnus-id-to-thread (gnus-root-id id)))))
7831 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7832 (gnus-summary-limit-include-matching-articles
7834 (regexp-quote (gnus-simplify-subject-re
7835 (mail-header-subject (gnus-id-to-header id)))))
7836 (gnus-summary-position-point))))
7838 (defun gnus-summary-limit-include-matching-articles (header regexp)
7839 "Display all the hidden articles that have HEADERs that match REGEXP."
7840 (interactive (list (read-string "Match on header: ")
7841 (read-string "Regexp: ")))
7842 (let ((articles (gnus-find-matching-articles header regexp)))
7844 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7845 (gnus-summary-position-point))))
7847 (defun gnus-summary-insert-dormant-articles ()
7848 "Insert all the dormant articles for this group into the current buffer."
7850 (let ((gnus-verbose (max 6 gnus-verbose)))
7851 (if (not gnus-newsgroup-dormant)
7852 (gnus-message 3 "No cached articles for this group")
7853 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7855 (defun gnus-summary-limit-include-dormant ()
7856 "Display all the hidden articles that are marked as dormant.
7857 Note that this command only works on a subset of the articles currently
7858 fetched for this group."
7860 (unless gnus-newsgroup-dormant
7861 (error "There are no dormant articles in this group"))
7863 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7864 (gnus-summary-position-point)))
7866 (defun gnus-summary-limit-exclude-dormant ()
7867 "Hide all dormant articles."
7870 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7871 (gnus-summary-position-point)))
7873 (defun gnus-summary-limit-exclude-childless-dormant ()
7874 "Hide all dormant articles that have no children."
7876 (let ((data (gnus-data-list t))
7877 articles d children)
7878 ;; Find all articles that are either not dormant or have
7880 (while (setq d (pop data))
7881 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7883 (gnus-article-children (gnus-data-number d)))
7886 (when (memq (car children) articles)
7891 (push (gnus-data-number d) articles)))
7894 (gnus-summary-limit articles)
7895 (gnus-summary-position-point))))
7897 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7898 "Mark all unread excluded articles as read.
7899 If ALL, mark even excluded ticked and dormants as read."
7901 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7902 (let ((articles (gnus-sorted-ndifference
7904 (mapcar (lambda (h) (mail-header-number h))
7905 gnus-newsgroup-headers)
7907 gnus-newsgroup-limit))
7909 (setq gnus-newsgroup-unreads
7910 (gnus-sorted-intersection gnus-newsgroup-unreads
7911 gnus-newsgroup-limit))
7913 (setq gnus-newsgroup-dormant nil
7914 gnus-newsgroup-marked nil
7915 gnus-newsgroup-reads
7917 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7918 gnus-newsgroup-reads))
7919 (while (setq article (pop articles))
7920 (unless (or (memq article gnus-newsgroup-dormant)
7921 (memq article gnus-newsgroup-marked))
7922 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7924 (defun gnus-summary-limit (articles &optional pop)
7926 ;; We pop the previous limit off the stack and use that.
7927 (setq articles (car gnus-newsgroup-limits)
7928 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7929 ;; We use the new limit, so we push the old limit on the stack.
7930 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7932 (setq gnus-newsgroup-limit articles)
7933 (let ((total (length gnus-newsgroup-data))
7934 (data (gnus-data-find-list (gnus-summary-article-number)))
7935 (gnus-summary-mark-below nil) ; Inhibit this.
7937 ;; This will do all the work of generating the new summary buffer
7938 ;; according to the new limit.
7939 (gnus-summary-prepare)
7940 ;; Hide any threads, possibly.
7941 (gnus-summary-maybe-hide-threads)
7942 ;; Try to return to the article you were at, or one in the
7945 ;; We try to find some article after the current one.
7947 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7950 (setq data (cdr data))))
7952 ;; If there is no data, that means that we were after the last
7953 ;; article. The same goes when we can't find any articles
7954 ;; after the current one.
7955 (goto-char (point-max))
7956 (gnus-summary-find-prev))
7957 (gnus-set-mode-line 'summary)
7958 ;; We return how many articles were removed from the summary
7959 ;; buffer as a result of the new limit.
7960 (- total (length gnus-newsgroup-data))))
7962 (defsubst gnus-invisible-cut-children (threads)
7965 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7970 (defsubst gnus-cut-thread (thread)
7971 "Go forwards in the thread until we find an article that we want to display."
7972 (when (or (eq gnus-fetch-old-headers 'some)
7973 (eq gnus-fetch-old-headers 'invisible)
7974 (numberp gnus-fetch-old-headers)
7975 (eq gnus-build-sparse-threads 'some)
7976 (eq gnus-build-sparse-threads 'more))
7977 ;; Deal with old-fetched headers and sparse threads.
7981 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7982 (gnus-summary-article-ancient-p
7983 (mail-header-number (car thread))))
7984 (if (or (<= (length (cdr thread)) 1)
7985 (eq gnus-fetch-old-headers 'invisible))
7986 (setq gnus-newsgroup-limit
7987 (delq (mail-header-number (car thread))
7988 gnus-newsgroup-limit)
7989 thread (cadr thread))
7990 (when (gnus-invisible-cut-children (cdr thread))
7991 (let ((th (cdr thread)))
7993 (if (memq (mail-header-number (caar th))
7994 gnus-newsgroup-limit)
7995 (setq thread (car th)
7997 (setq th (cdr th))))))))))
8000 (defun gnus-cut-threads (threads)
8001 "Cut off all uninteresting articles from the beginning of THREADS."
8002 (when (or (eq gnus-fetch-old-headers 'some)
8003 (eq gnus-fetch-old-headers 'invisible)
8004 (numberp gnus-fetch-old-headers)
8005 (eq gnus-build-sparse-threads 'some)
8006 (eq gnus-build-sparse-threads 'more))
8009 (setcar th (gnus-cut-thread (car th)))
8010 (setq th (cdr th)))))
8011 ;; Remove nixed out threads.
8014 (defun gnus-summary-initial-limit (&optional show-if-empty)
8015 "Figure out what the initial limit is supposed to be on group entry.
8016 This entails weeding out unwanted dormants, low-scored articles,
8017 fetch-old-headers verbiage, and so on."
8018 ;; Most groups have nothing to remove.
8019 (if (or gnus-inhibit-limiting
8020 (and (null gnus-newsgroup-dormant)
8021 (eq gnus-newsgroup-display 'gnus-not-ignore)
8022 (not (eq gnus-fetch-old-headers 'some))
8023 (not (numberp gnus-fetch-old-headers))
8024 (not (eq gnus-fetch-old-headers 'invisible))
8025 (null gnus-summary-expunge-below)
8026 (not (eq gnus-build-sparse-threads 'some))
8027 (not (eq gnus-build-sparse-threads 'more))
8028 (null gnus-thread-expunge-below)
8029 (not gnus-use-nocem)))
8031 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8032 (setq gnus-newsgroup-limit nil)
8035 (unless (car (symbol-value node))
8036 ;; These threads have no parents -- they are roots.
8037 (let ((nodes (cdr (symbol-value node)))
8040 (if (and gnus-thread-expunge-below
8041 (< (gnus-thread-total-score (car nodes))
8042 gnus-thread-expunge-below))
8043 (gnus-expunge-thread (pop nodes))
8044 (setq thread (pop nodes))
8045 (gnus-summary-limit-children thread))))))
8046 gnus-newsgroup-dependencies)
8047 ;; If this limitation resulted in an empty group, we might
8048 ;; pop the previous limit and use it instead.
8049 (when (and (not gnus-newsgroup-limit)
8051 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8052 gnus-newsgroup-limit))
8054 (defun gnus-summary-limit-children (thread)
8055 "Return 1 if this subthread is visible and 0 if it is not."
8056 ;; First we get the number of visible children to this thread. This
8057 ;; is done by recursing down the thread using this function, so this
8058 ;; will really go down to a leaf article first, before slowly
8059 ;; working its way up towards the root.
8061 (let* ((max-lisp-eval-depth 5000)
8064 (apply '+ (mapcar 'gnus-summary-limit-children
8067 (number (mail-header-number (car thread)))
8070 (not (memq number gnus-newsgroup-marked))
8072 ;; If this article is dormant and has absolutely no visible
8073 ;; children, then this article isn't visible.
8074 (and (memq number gnus-newsgroup-dormant)
8076 ;; If this is "fetch-old-headered" and there is no
8077 ;; visible children, then we don't want this article.
8078 (and (or (eq gnus-fetch-old-headers 'some)
8079 (numberp gnus-fetch-old-headers))
8080 (gnus-summary-article-ancient-p number)
8082 ;; If this is "fetch-old-headered" and `invisible', then
8083 ;; we don't want this article.
8084 (and (eq gnus-fetch-old-headers 'invisible)
8085 (gnus-summary-article-ancient-p number))
8086 ;; If this is a sparsely inserted article with no children,
8087 ;; we don't want it.
8088 (and (eq gnus-build-sparse-threads 'some)
8089 (gnus-summary-article-sparse-p number)
8091 ;; If we use expunging, and this article is really
8092 ;; low-scored, then we don't want this article.
8093 (when (and gnus-summary-expunge-below
8095 (or (cdr (assq number gnus-newsgroup-scored))
8096 gnus-summary-default-score))
8097 gnus-summary-expunge-below))
8098 ;; We increase the expunge-tally here, but that has
8099 ;; nothing to do with the limits, really.
8100 (incf gnus-newsgroup-expunged-tally)
8101 ;; We also mark as read here, if that's wanted.
8102 (when (and gnus-summary-mark-below
8103 (< score gnus-summary-mark-below))
8104 (setq gnus-newsgroup-unreads
8105 (delq number gnus-newsgroup-unreads))
8106 (if gnus-newsgroup-auto-expire
8107 (push number gnus-newsgroup-expirable)
8108 (push (cons number gnus-low-score-mark)
8109 gnus-newsgroup-reads)))
8111 ;; Do the `display' group parameter.
8112 (and gnus-newsgroup-display
8113 (not (funcall gnus-newsgroup-display)))
8114 ;; Check NoCeM things.
8115 (when (and gnus-use-nocem
8116 (gnus-nocem-unwanted-article-p
8117 (mail-header-id (car thread))))
8118 (setq gnus-newsgroup-unreads
8119 (delq number gnus-newsgroup-unreads))
8121 ;; Nope, invisible article.
8123 ;; Ok, this article is to be visible, so we add it to the limit
8125 (push number gnus-newsgroup-limit)
8128 (defun gnus-expunge-thread (thread)
8129 "Mark all articles in THREAD as read."
8130 (let* ((number (mail-header-number (car thread))))
8131 (incf gnus-newsgroup-expunged-tally)
8132 ;; We also mark as read here, if that's wanted.
8133 (setq gnus-newsgroup-unreads
8134 (delq number gnus-newsgroup-unreads))
8135 (if gnus-newsgroup-auto-expire
8136 (push number gnus-newsgroup-expirable)
8137 (push (cons number gnus-low-score-mark)
8138 gnus-newsgroup-reads)))
8139 ;; Go recursively through all subthreads.
8140 (mapcar 'gnus-expunge-thread (cdr thread)))
8142 ;; Summary article oriented commands
8144 (defun gnus-summary-refer-parent-article (n)
8145 "Refer parent article N times.
8146 If N is negative, go to ancestor -N instead.
8147 The difference between N and the number of articles fetched is returned."
8151 (when (not (natnump n))
8156 (setq header (gnus-summary-article-header))
8157 (if (and (eq (mail-header-number header)
8158 (cdr gnus-article-current))
8159 (equal gnus-newsgroup-name
8160 (car gnus-article-current)))
8161 ;; If we try to find the parent of the currently
8162 ;; displayed article, then we take a look at the actual
8163 ;; References header, since this is slightly more
8164 ;; reliable than the References field we got from the
8167 (set-buffer gnus-original-article-buffer)
8168 (nnheader-narrow-to-headers)
8169 (unless (setq ref (message-fetch-field "references"))
8170 (when (setq ref (message-fetch-field "in-reply-to"))
8171 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8174 ;; It's not the current article, so we take a bet on
8175 ;; the value we got from the server.
8176 (mail-header-references header)))
8178 (not (equal ref "")))
8179 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8180 (gnus-message 1 "Couldn't find parent"))
8181 (gnus-message 1 "No references in article %d"
8182 (gnus-summary-article-number))
8185 (gnus-summary-position-point)
8188 (defun gnus-summary-refer-references ()
8189 "Fetch all articles mentioned in the References header.
8190 Return the number of articles fetched."
8192 (let ((ref (mail-header-references (gnus-summary-article-header)))
8193 (current (gnus-summary-article-number))
8197 (error "No References in the current article")
8198 ;; For each Message-ID in the References header...
8199 (while (string-match "<[^>]*>" ref)
8201 ;; ... fetch that article.
8202 (gnus-summary-refer-article
8203 (prog1 (match-string 0 ref)
8204 (setq ref (substring ref (match-end 0))))))
8205 (gnus-summary-goto-subject current)
8206 (gnus-summary-position-point)
8209 (defun gnus-summary-refer-thread (&optional limit)
8210 "Fetch all articles in the current thread.
8211 If LIMIT (the numerical prefix), fetch that many old headers instead
8212 of what's specified by the `gnus-refer-thread-limit' variable."
8214 (let ((id (mail-header-id (gnus-summary-article-header)))
8215 (limit (if limit (prefix-numeric-value limit)
8216 gnus-refer-thread-limit)))
8217 (unless (eq gnus-fetch-old-headers 'invisible)
8218 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8219 ;; Retrieve the headers and read them in.
8220 (if (eq (if (numberp limit)
8221 (gnus-retrieve-headers
8223 (+ (mail-header-number
8224 (gnus-summary-article-header))
8226 gnus-newsgroup-end))
8227 gnus-newsgroup-name (* limit 2))
8228 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8230 (gnus-retrieve-headers (list gnus-newsgroup-end)
8231 gnus-newsgroup-name limit))
8233 (gnus-build-all-threads)
8234 (error "Can't fetch thread from back ends that don't support NOV"))
8235 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8236 (gnus-summary-limit-include-thread id)))
8238 (defun gnus-summary-refer-article (message-id)
8239 "Fetch an article specified by MESSAGE-ID."
8240 (interactive "sMessage-ID: ")
8241 (when (and (stringp message-id)
8242 (not (zerop (length message-id))))
8243 (setq message-id (gnus-replace-in-string message-id " " ""))
8244 ;; Construct the correct Message-ID if necessary.
8245 ;; Suggested by tale@pawl.rpi.edu.
8246 (unless (string-match "^<" message-id)
8247 (setq message-id (concat "<" message-id)))
8248 (unless (string-match ">$" message-id)
8249 (setq message-id (concat message-id ">")))
8250 ;; People often post MIDs from URLs, so unhex it:
8251 (unless (string-match "@" message-id)
8252 (setq message-id (gnus-url-unhex-string message-id)))
8253 (let* ((header (gnus-id-to-header message-id))
8255 (gnus-summary-article-sparse-p
8256 (mail-header-number header))
8257 (memq (mail-header-number header)
8258 gnus-newsgroup-limit)))
8261 ;; If the article is present in the buffer we just go to it.
8263 (or (not (gnus-summary-article-sparse-p
8264 (mail-header-number header)))
8267 (gnus-summary-goto-article
8268 (mail-header-number header) nil t)
8270 (gnus-summary-update-article (mail-header-number header)))))
8272 ;; We fetch the article.
8274 (dolist (gnus-override-method (gnus-refer-article-methods))
8275 (when (and (gnus-check-server gnus-override-method)
8276 ;; Fetch the header,
8277 (setq number (gnus-summary-insert-subject message-id)))
8278 ;; and display the article.
8279 (gnus-summary-select-article nil nil nil number)
8281 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8283 (defun gnus-refer-article-methods ()
8284 "Return a list of referable methods."
8286 ;; No method, so we default to current and native.
8287 ((null gnus-refer-article-method)
8288 (list gnus-current-select-method gnus-select-method))
8290 ((eq 'current gnus-refer-article-method)
8291 (list gnus-current-select-method))
8292 ;; List of select methods.
8293 ((not (and (symbolp (car gnus-refer-article-method))
8294 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8296 (dolist (method gnus-refer-article-method)
8297 (push (if (eq 'current method)
8298 gnus-current-select-method
8302 ;; One single select method.
8304 (list gnus-refer-article-method))))
8306 (defun gnus-summary-edit-parameters ()
8307 "Edit the group parameters of the current group."
8309 (gnus-group-edit-group gnus-newsgroup-name 'params))
8311 (defun gnus-summary-customize-parameters ()
8312 "Customize the group parameters of the current group."
8314 (gnus-group-customize gnus-newsgroup-name))
8316 (defun gnus-summary-enter-digest-group (&optional force)
8317 "Enter an nndoc group based on the current article.
8318 If FORCE, force a digest interpretation. If not, try
8319 to guess what the document format is."
8321 (let ((conf gnus-current-window-configuration))
8322 (save-window-excursion
8324 (let (gnus-article-prepare-hook
8325 gnus-display-mime-function
8327 (gnus-summary-select-article))))
8328 (setq gnus-current-window-configuration conf)
8329 (let* ((name (format "%s-%d"
8330 (gnus-group-prefixed-name
8331 gnus-newsgroup-name (list 'nndoc ""))
8332 (with-current-buffer gnus-summary-buffer
8333 gnus-current-article)))
8334 (ogroup gnus-newsgroup-name)
8335 (params (append (gnus-info-params (gnus-get-info ogroup))
8336 (list (cons 'to-group ogroup))
8337 (list (cons 'parent-group ogroup))
8338 (list (cons 'save-article-group ogroup))))
8339 (case-fold-search t)
8340 (buf (current-buffer))
8343 (set-buffer gnus-original-article-buffer)
8344 ;; Have the digest group inherit the main mail address of
8345 ;; the parent article.
8346 (when (setq to-address (or (gnus-fetch-field "reply-to")
8347 (gnus-fetch-field "from")))
8348 (setq params (append
8349 (list (cons 'to-address
8350 (funcall gnus-decode-encoded-word-function
8352 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8353 (insert-buffer-substring gnus-original-article-buffer)
8354 ;; Remove lines that may lead nndoc to misinterpret the
8357 (goto-char (point-min))
8358 (or (search-forward "\n\n" nil t) (point)))
8359 (goto-char (point-min))
8360 (delete-matching-lines "^Path:\\|^From ")
8363 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8364 (gnus-newsgroup-ephemeral-ignored-charsets
8365 gnus-newsgroup-ignored-charsets))
8366 (gnus-group-read-ephemeral-group
8367 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8369 ,(if force 'mbox 'guess)))
8371 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8373 ;; Make all postings to this group go to the parent group.
8374 (nconc (gnus-info-params (gnus-get-info name))
8376 ;; Couldn't select this doc group.
8377 (switch-to-buffer buf)
8378 (gnus-set-global-variables)
8379 (gnus-configure-windows 'summary)
8380 (gnus-message 3 "Article couldn't be entered?"))
8381 (kill-buffer dig)))))
8383 (defun gnus-summary-read-document (n)
8384 "Open a new group based on the current article(s).
8385 This will allow you to read digests and other similar
8386 documents as newsgroups.
8387 Obeys the standard process/prefix convention."
8389 (let* ((ogroup gnus-newsgroup-name)
8390 (params (append (gnus-info-params (gnus-get-info ogroup))
8391 (list (cons 'to-group ogroup))))
8392 group egroup groups vgroup)
8393 (dolist (article (gnus-summary-work-articles n))
8394 (setq group (format "%s-%d" gnus-newsgroup-name article))
8395 (gnus-summary-remove-process-mark article)
8396 (when (gnus-summary-display-article article)
8399 (insert-buffer-substring gnus-original-article-buffer)
8400 ;; Remove some headers that may lead nndoc to make
8402 (message-narrow-to-head)
8403 (goto-char (point-min))
8404 (delete-matching-lines "^Path:\\|^From ")
8407 (gnus-group-read-ephemeral-group
8408 group `(nndoc ,group (nndoc-address ,(current-buffer))
8409 (nndoc-article-type guess))
8412 ;; Make all postings to this group go to the parent group.
8413 (nconc (gnus-info-params (gnus-get-info egroup))
8415 (push egroup groups))
8416 ;; Couldn't select this doc group.
8417 (gnus-error 3 "Article couldn't be entered"))))))
8418 ;; Now we have selected all the documents.
8421 (error "None of the articles could be interpreted as documents"))
8422 ((gnus-group-read-ephemeral-group
8423 (setq vgroup (format
8424 "nnvirtual:%s-%s" gnus-newsgroup-name
8425 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8426 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8428 (cons (current-buffer) 'summary)))
8430 (error "Couldn't select virtual nndoc group")))))
8432 (defun gnus-summary-isearch-article (&optional regexp-p)
8433 "Do incremental search forward on the current article.
8434 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8436 (let* ((gnus-inhibit-treatment t)
8437 (old (gnus-summary-select-article)))
8438 (gnus-configure-windows 'article)
8439 (gnus-eval-in-buffer-window gnus-article-buffer
8443 (gnus-article-show-all-headers))
8444 (goto-char (point-min))
8445 (isearch-forward regexp-p)))))
8447 (defun gnus-summary-search-article-forward (regexp &optional backward)
8448 "Search for an article containing REGEXP forward.
8449 If BACKWARD, search backward instead."
8452 (format "Search article %s (regexp%s): "
8453 (if current-prefix-arg "backward" "forward")
8454 (if gnus-last-search-regexp
8455 (concat ", default " gnus-last-search-regexp)
8457 current-prefix-arg))
8458 (if (string-equal regexp "")
8459 (setq regexp (or gnus-last-search-regexp ""))
8460 (setq gnus-last-search-regexp regexp)
8461 (setq gnus-article-before-search gnus-current-article))
8462 ;; Intentionally set gnus-last-article.
8463 (setq gnus-last-article gnus-article-before-search)
8464 (let ((gnus-last-article gnus-last-article))
8465 (if (gnus-summary-search-article regexp backward)
8466 (gnus-summary-show-thread)
8467 (signal 'search-failed (list regexp)))))
8469 (defun gnus-summary-search-article-backward (regexp)
8470 "Search for an article containing REGEXP backward."
8473 (format "Search article backward (regexp%s): "
8474 (if gnus-last-search-regexp
8475 (concat ", default " gnus-last-search-regexp)
8477 (gnus-summary-search-article-forward regexp 'backward))
8480 (defmacro gnus-summary-search-article-position-point (regexp backward)
8481 "Dehighlight the last matched text and goto the beginning position."
8482 (` (if (and gnus-summary-search-article-matched-data
8483 (let ((text (caddr gnus-summary-search-article-matched-data))
8484 (inhibit-read-only t)
8487 (goto-char (car gnus-summary-search-article-matched-data))
8488 (cadr gnus-summary-search-article-matched-data))
8490 (string-match (, regexp) text)))
8491 (if (, backward) (beginning-of-line) (end-of-line))
8492 (goto-char (if (, backward) (point-max) (point-min))))))
8494 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8495 "Place point where X-Face image is displayed."
8496 (if (featurep 'xemacs)
8497 (` (let ((end (if (search-forward "\n\n" nil t)
8498 (goto-char (1- (point)))
8501 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8502 (unless (and (re-search-forward "^From:" end t)
8503 (setq extent (extent-at (point)))
8504 (extent-begin-glyph extent))
8505 (goto-char (, opoint)))))
8506 (` (let ((end (if (search-forward "\n\n" nil t)
8507 (goto-char (1- (point)))
8509 (start (or (search-backward "\n\n" nil t) (point-min))))
8511 (or (text-property-any start end 'x-face-image t);; x-face-e21
8512 (text-property-any start end 'x-face-mule-bitmap-image t)
8515 (defmacro gnus-summary-search-article-highlight-matched-text
8516 (backward treated x-face)
8517 "Highlight matched text in the function `gnus-summary-search-article'."
8518 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8519 (end (set-marker (make-marker) (match-end 0)))
8520 (inhibit-read-only t)
8524 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8526 (lambda (item) (setq items (delq item items)))
8527 '(gnus-treat-buttonize
8528 gnus-treat-fill-article
8529 gnus-treat-fill-long-lines
8530 gnus-treat-emphasize
8531 gnus-treat-highlight-headers
8532 gnus-treat-highlight-citation
8533 gnus-treat-highlight-signature
8534 gnus-treat-overstrike
8535 gnus-treat-display-x-face
8536 gnus-treat-buttonize-head
8537 gnus-treat-decode-article-as-default-mime-charset))
8538 (static-if (featurep 'xemacs)
8540 (cons '(x-face-mule-delete-x-face-field
8543 (gnus-treat-display-x-face
8544 (when (, x-face) gnus-treat-display-x-face)))
8545 (gnus-article-prepare-mime-display)))
8546 (goto-char (if (, backward) start end))
8548 (gnus-summary-search-article-highlight-goto-x-face (point)))
8549 (setq gnus-summary-search-article-matched-data
8550 (list start end (buffer-substring start end)))
8551 (unless (eq start end);; matched text has been deleted. :-<
8552 (put-text-property start end 'face
8553 (or (find-face 'isearch)
8554 'secondary-selection))))))
8557 (defun gnus-summary-search-article (regexp &optional backward)
8558 "Search for an article containing REGEXP.
8559 Optional argument BACKWARD means do search for backward.
8560 `gnus-select-article-hook' is not called during the search."
8561 ;; We have to require this here to make sure that the following
8562 ;; dynamic binding isn't shadowed by autoloading.
8563 (require 'gnus-async)
8565 (let ((gnus-select-article-hook nil) ;Disable hook.
8566 (gnus-article-prepare-hook nil)
8567 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8568 (gnus-use-article-prefetch nil)
8569 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8570 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8572 (gnus-keep-backlog nil)
8573 (gnus-break-pages nil)
8574 (gnus-summary-display-arrow nil)
8575 (gnus-updated-mode-lines nil)
8576 (gnus-auto-center-summary nil)
8577 (sum (current-buffer))
8580 (gnus-save-hidden-threads
8581 (static-if (featurep 'xemacs)
8582 (let ((gnus-inhibit-treatment t))
8583 (setq treated (eq 'old (gnus-summary-select-article)))
8585 (not (and (gnus-buffer-live-p gnus-article-buffer)
8586 (window-live-p (get-buffer-window
8587 gnus-article-buffer t)))))
8588 (gnus-summary-select-article nil t)
8589 (setq treated nil)))
8590 (let ((gnus-inhibit-treatment t)
8591 (x-face-mule-delete-x-face-field 'never))
8592 (setq treated (eq 'old (gnus-summary-select-article)))
8595 (and (gnus-buffer-live-p gnus-article-buffer)
8596 (window-live-p (get-buffer-window
8597 gnus-article-buffer t))
8598 (or (not (string-match "^\\^X-Face:" regexp))
8599 (with-current-buffer gnus-article-buffer
8600 gnus-summary-search-article-matched-data)))))
8601 (gnus-summary-select-article nil t)
8602 (setq treated nil))))
8603 (set-buffer gnus-article-buffer)
8607 (gnus-article-show-all-headers)
8608 (gnus-summary-search-article-position-point regexp backward))
8609 (goto-char (if backward (point-max) (point-min))))
8611 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8613 (re-search-backward regexp nil t)
8614 (re-search-forward regexp nil t))
8615 ;; We found the regexp.
8617 (gnus-summary-search-article-highlight-matched-text
8618 backward treated (string-match "^\\^X-Face:" regexp))
8621 (/ (- 2 (window-height
8622 (get-buffer-window gnus-article-buffer t)))
8625 (get-buffer-window (current-buffer))
8628 (setq point (point)))
8629 ;; We didn't find it, so we go to the next article.
8632 (while (eq found 'not)
8633 (if (not (if backward (gnus-summary-find-prev)
8634 (gnus-summary-find-next)))
8635 ;; No more articles.
8637 ;; Select the next article and adjust point.
8638 (unless (gnus-summary-article-sparse-p
8639 (gnus-summary-article-number))
8641 (let ((gnus-inhibit-treatment t))
8642 (gnus-summary-select-article))
8644 (set-buffer gnus-article-buffer)
8646 (goto-char (if backward (point-max) (point-min))))))))
8647 (gnus-message 7 ""))
8648 ;; Return whether we found the regexp.
8649 (when (eq found 'found)
8651 (gnus-summary-show-thread)
8652 (gnus-summary-goto-subject gnus-current-article)
8653 (gnus-summary-position-point)
8656 (defun gnus-find-matching-articles (header regexp)
8657 "Return a list of all articles that match REGEXP on HEADER.
8658 This search includes all articles in the current group that Gnus has
8659 fetched headers for, whether they are displayed or not."
8660 (let ((articles nil)
8661 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8662 (case-fold-search t))
8663 (dolist (header gnus-newsgroup-headers)
8664 (when (string-match regexp (funcall func header))
8665 (push (mail-header-number header) articles)))
8666 (nreverse articles)))
8668 (defun gnus-summary-find-matching (header regexp &optional backward unread
8669 not-case-fold not-matching)
8670 "Return a list of all articles that match REGEXP on HEADER.
8671 The search stars on the current article and goes forwards unless
8672 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8673 If UNREAD is non-nil, only unread articles will
8674 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8675 in the comparisons. If NOT-MATCHING, return a list of all articles that
8676 not match REGEXP on HEADER."
8677 (let ((case-fold-search (not not-case-fold))
8680 (if (eq (car header) 'extra)
8683 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8685 (error "%s is an invalid header" header))
8686 (unless (fboundp (intern (concat "mail-header-" header)))
8687 (error "%s is not a valid header" header))
8688 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8689 (dolist (d (if (eq backward 'all)
8691 (gnus-data-find-list
8692 (gnus-summary-article-number)
8693 (gnus-data-list backward))))
8694 (when (and (or (not unread) ; We want all articles...
8695 (gnus-data-unread-p d)) ; Or just unreads.
8696 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8700 (funcall func (gnus-data-header d))))
8701 (string-match regexp
8702 (funcall func (gnus-data-header d)))))
8703 (push (gnus-data-number d) articles))) ; Success!
8704 (nreverse articles)))
8706 (defun gnus-summary-execute-command (header regexp command &optional backward)
8707 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8708 If HEADER is an empty string (or nil), the match is done on the entire
8709 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8711 (list (let ((completion-ignore-case t))
8714 (mapcar (lambda (header) (list (format "%s" header)))
8716 '("Number" "Subject" "From" "Lines" "Date"
8717 "Message-ID" "Xref" "References" "Body")
8718 gnus-extra-headers))
8719 nil 'require-match))
8720 (read-string "Regexp: ")
8721 (read-key-sequence "Command: ")
8722 current-prefix-arg))
8723 (when (equal header "Body")
8725 ;; Hidden thread subtrees must be searched as well.
8726 (gnus-summary-show-all-threads)
8727 ;; We don't want to change current point nor window configuration.
8729 (save-window-excursion
8731 gnus-treat-strip-trailing-blank-lines
8732 gnus-treat-strip-leading-blank-lines
8733 gnus-treat-strip-multiple-blank-lines
8734 gnus-treat-hide-boring-headers
8735 gnus-treat-fold-newsgroups
8736 gnus-article-prepare-hook)
8737 (gnus-message 6 "Executing %s..." (key-description command))
8738 ;; We'd like to execute COMMAND interactively so as to give arguments.
8739 (gnus-execute header regexp
8740 `(call-interactively ',(key-binding command))
8742 (gnus-message 6 "Executing %s...done" (key-description command))))))
8744 (defun gnus-summary-beginning-of-article ()
8745 "Scroll the article back to the beginning."
8747 (gnus-summary-select-article)
8748 (gnus-configure-windows 'article)
8749 (gnus-eval-in-buffer-window gnus-article-buffer
8751 (goto-char (point-min))
8752 (when gnus-break-pages
8753 (gnus-narrow-to-page))))
8755 (defun gnus-summary-end-of-article ()
8756 "Scroll to the end of the article."
8758 (gnus-summary-select-article)
8759 (gnus-configure-windows 'article)
8760 (gnus-eval-in-buffer-window gnus-article-buffer
8762 (goto-char (point-max))
8764 (when gnus-break-pages
8765 (when (re-search-backward page-delimiter nil t)
8766 (narrow-to-region (match-end 0) (point-max)))
8767 (gnus-narrow-to-page))))
8769 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8770 "Truncate to LEN and quote all \"(\"'s in STRING."
8771 (gnus-replace-in-string (if (and len (> (length string) len))
8772 (substring string 0 len)
8776 (defun gnus-summary-print-article (&optional filename n)
8777 "Generate and print a PostScript image of the process-marked (mail) articles.
8779 If used interactively, print the current article if none are
8780 process-marked. With prefix arg, prompt the user for the name of the
8783 When used from Lisp, accept two optional args FILENAME and N. N means
8784 to print the next N articles. If N is negative, print the N previous
8785 articles. If N is nil and articles have been marked with the process
8786 mark, print these instead.
8788 If the optional first argument FILENAME is nil, send the image to the
8789 printer. If FILENAME is a string, save the PostScript image in a file with
8790 that name. If FILENAME is a number, prompt the user for the name of the file
8792 (interactive (list (ps-print-preprint current-prefix-arg)))
8793 (dolist (article (gnus-summary-work-articles n))
8794 (gnus-summary-select-article nil nil 'pseudo article)
8795 (gnus-eval-in-buffer-window gnus-article-buffer
8796 (gnus-print-buffer))
8797 (gnus-summary-remove-process-mark article))
8798 (ps-despool filename))
8800 (defun gnus-print-buffer ()
8801 (let ((buffer (generate-new-buffer " *print*")))
8804 (copy-to-buffer buffer (point-min) (point-max))
8806 (gnus-remove-text-with-property 'gnus-decoration)
8807 (when (gnus-visual-p 'article-highlight 'highlight)
8808 ;; Copy-to-buffer doesn't copy overlay. So redo
8810 (let ((gnus-article-buffer buffer))
8811 (gnus-article-highlight-citation t)
8812 (gnus-article-highlight-signature)
8813 (gnus-article-emphasize)
8814 (gnus-article-delete-invisible-text)))
8815 (let ((ps-left-header
8818 (gnus-summary-print-truncate-and-quote
8819 (mail-header-subject gnus-current-headers)
8822 (gnus-summary-print-truncate-and-quote
8823 (mail-header-from gnus-current-headers)
8827 "/pagenumberstring load"
8829 (mail-header-date gnus-current-headers) ")"))))
8830 (gnus-run-hooks 'gnus-ps-print-hook)
8833 (ps-spool-buffer-with-faces)
8834 (ps-spool-buffer)))))
8835 (kill-buffer buffer))))
8837 (defun gnus-summary-show-article (&optional arg)
8838 "Force redisplaying of the current article.
8839 If ARG (the prefix) is a number, show the article with the charset
8840 defined in `gnus-summary-show-article-charset-alist', or the charset
8842 If ARG (the prefix) is non-nil and not a number, show the raw article
8843 without any article massaging functions being run. Normally, the key
8844 strokes are `C-u g'."
8848 (gnus-summary-show-article t)
8849 (let* ((gnus-newsgroup-charset
8850 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8851 (mm-read-coding-system
8852 "View as charset: " ;; actually it is coding system.
8853 (with-current-buffer gnus-article-buffer
8854 (mm-detect-coding-region (point) (point-max))))))
8855 (default-mime-charset gnus-newsgroup-charset)
8856 (gnus-newsgroup-ignored-charsets 'gnus-all))
8857 (gnus-summary-select-article nil 'force)
8858 (let ((deps gnus-newsgroup-dependencies)
8861 (set-buffer gnus-original-article-buffer)
8863 (message-narrow-to-head)
8864 (setq head (buffer-string))
8865 (goto-char (point-min))
8866 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8867 (goto-char (point-max))
8869 (setq lines (1- (count-lines (point) (point-max))))))
8871 (insert (format "211 %d Article retrieved.\n"
8872 (cdr gnus-article-current)))
8874 (if lines (insert (format "Lines: %d\n" lines)))
8876 (let ((nntp-server-buffer (current-buffer)))
8877 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8878 (gnus-data-set-header
8879 (gnus-data-find (cdr gnus-article-current))
8881 (gnus-summary-update-article-line
8882 (cdr gnus-article-current) header)
8883 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8884 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8886 ;; Select the article the normal way.
8887 (gnus-summary-select-article nil 'force))
8889 ;; We have to require this here to make sure that the following
8890 ;; dynamic binding isn't shadowed by autoloading.
8891 (require 'gnus-async)
8893 ;; Bind the article treatment functions to nil.
8894 (let ((gnus-have-all-headers t)
8895 gnus-article-prepare-hook
8896 gnus-article-decode-hook
8899 (gnus-inhibit-treatment t))
8900 (gnus-summary-select-article nil 'force))))
8901 (gnus-summary-goto-subject gnus-current-article)
8902 (gnus-summary-position-point))
8904 (defun gnus-summary-show-raw-article ()
8905 "Show the raw article without any article massaging functions being run."
8907 (gnus-summary-show-article t))
8909 (defun gnus-summary-verbose-headers (&optional arg)
8910 "Toggle permanent full header display.
8911 If ARG is a positive number, turn header display on.
8912 If ARG is a negative number, turn header display off."
8914 (setq gnus-show-all-headers
8915 (cond ((or (not (numberp arg))
8917 (not gnus-show-all-headers))
8920 (gnus-summary-show-article))
8922 (defun gnus-summary-toggle-header (&optional arg)
8923 "Show the headers if they are hidden, or hide them if they are shown.
8924 If ARG is a positive number, show the entire header.
8925 If ARG is a negative number, hide the unwanted header lines."
8927 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8928 (get-buffer-window gnus-article-buffer t))))
8929 (with-current-buffer gnus-article-buffer
8931 (article-narrow-to-head)
8932 (let* ((buffer-read-only nil)
8933 (inhibit-point-motion-hooks t)
8934 (hidden (if (numberp arg)
8936 (or (not (looking-at "[^ \t\n]+:"))
8937 (gnus-article-hidden-text-p 'headers))))
8939 (delete-region (point-min) (point-max))
8940 (with-current-buffer gnus-original-article-buffer
8941 (goto-char (setq s (point-min)))
8942 (setq e (if (search-forward "\n\n" nil t)
8945 (insert-buffer-substring gnus-original-article-buffer s e)
8946 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8947 ;; article-decode-encoded-words by default.
8948 (article-decode-encoded-words)
8949 (run-hooks 'gnus-article-decode-hook)
8951 (let ((gnus-treat-hide-headers nil)
8952 (gnus-treat-hide-boring-headers nil))
8953 (gnus-delete-wash-type 'headers)
8954 (gnus-treat-article 'head))
8955 (gnus-treat-article 'head))
8958 (set-window-start window (goto-char (point-min))))
8959 (if gnus-break-pages
8960 (gnus-narrow-to-page)
8961 (when (gnus-visual-p 'page-marker)
8962 (let ((buffer-read-only nil))
8963 (gnus-remove-text-with-property 'gnus-prev)
8964 (gnus-remove-text-with-property 'gnus-next))))
8965 (gnus-set-mode-line 'article)))))
8967 (defun gnus-summary-show-all-headers ()
8968 "Make all header lines visible."
8970 (gnus-summary-toggle-header 1))
8972 (defun gnus-summary-toggle-mime (&optional arg)
8973 "Toggle MIME processing.
8974 If ARG is a positive number, turn MIME processing on."
8976 (setq gnus-show-mime
8978 (not gnus-show-mime)
8979 (> (prefix-numeric-value arg) 0)))
8980 (gnus-summary-select-article t 'force))
8982 (defun gnus-summary-caesar-message (&optional arg)
8983 "Caesar rotate the current article by 13.
8984 The numerical prefix specifies how many places to rotate each letter
8987 (gnus-summary-select-article)
8988 (let ((mail-header-separator ""))
8989 (gnus-eval-in-buffer-window gnus-article-buffer
8992 (let ((start (window-start))
8994 (message-caesar-buffer-body arg)
8995 (set-window-start (get-buffer-window (current-buffer)) start))))))
8997 (autoload 'unmorse-region "morse"
8998 "Convert morse coded text in region to ordinary ASCII text."
9001 (defun gnus-summary-morse-message (&optional arg)
9002 "Morse decode the current article."
9004 (gnus-summary-select-article)
9005 (let ((mail-header-separator ""))
9006 (gnus-eval-in-buffer-window gnus-article-buffer
9010 (let ((pos (window-start))
9012 (goto-char (point-min))
9013 (when (message-goto-body)
9014 (gnus-narrow-to-body))
9015 (goto-char (point-min))
9016 (while (search-forward "·" (point-max) t)
9017 (replace-match "."))
9018 (unmorse-region (point-min) (point-max))
9020 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9022 (defun gnus-summary-stop-page-breaking ()
9023 "Stop page breaking in the current article."
9025 (gnus-summary-select-article)
9026 (gnus-eval-in-buffer-window gnus-article-buffer
9028 (when (gnus-visual-p 'page-marker)
9029 (let ((buffer-read-only nil))
9030 (gnus-remove-text-with-property 'gnus-prev)
9031 (gnus-remove-text-with-property 'gnus-next))
9032 (setq gnus-page-broken nil))))
9034 (defun gnus-summary-move-article (&optional n to-newsgroup
9035 select-method action)
9036 "Move the current article to a different newsgroup.
9037 If N is a positive number, move the N next articles.
9038 If N is a negative number, move the N previous articles.
9039 If N is nil and any articles have been marked with the process mark,
9040 move those articles instead.
9041 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9042 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9043 re-spool using this method.
9045 When called interactively with TO-NEWSGROUP being nil, the value of
9046 the variable `gnus-move-split-methods' is used for finding a default
9047 for the target newsgroup.
9049 For this function to work, both the current newsgroup and the
9050 newsgroup that you want to move to have to support the `request-move'
9051 and `request-accept' functions.
9053 ACTION can be either `move' (the default), `crosspost' or `copy'."
9056 (setq action 'move))
9057 ;; Check whether the source group supports the required functions.
9058 (cond ((and (eq action 'move)
9059 (not (gnus-check-backend-function
9060 'request-move-article gnus-newsgroup-name)))
9061 (error "The current group does not support article moving"))
9062 ((and (eq action 'crosspost)
9063 (not (gnus-check-backend-function
9064 'request-replace-article gnus-newsgroup-name)))
9065 (error "The current group does not support article editing")))
9066 (let ((articles (gnus-summary-work-articles n))
9067 (prefix (if (gnus-check-backend-function
9068 'request-move-article gnus-newsgroup-name)
9069 (funcall gnus-move-group-prefix-function
9070 gnus-newsgroup-name)
9072 (names '((move "Move" "Moving")
9073 (copy "Copy" "Copying")
9074 (crosspost "Crosspost" "Crossposting")))
9075 (copy-buf (save-excursion
9076 (nnheader-set-temp-buffer " *copy article*")))
9077 art-group to-method new-xref article to-groups)
9078 (unless (assq action names)
9079 (error "Unknown action %s" action))
9080 ;; Read the newsgroup name.
9081 (when (and (not to-newsgroup)
9082 (not select-method))
9083 (if (and gnus-move-split-methods
9085 (and (memq gnus-current-article articles)
9086 (gnus-buffer-live-p gnus-original-article-buffer))))
9087 ;; When `gnus-move-split-methods' is non-nil, we have to
9088 ;; select an article to give `gnus-read-move-group-name' an
9089 ;; opportunity to suggest an appropriate default. However,
9090 ;; we needn't render or mark the article.
9091 (let ((gnus-display-mime-function nil)
9092 (gnus-article-prepare-hook nil)
9093 (gnus-mark-article-hook nil))
9094 (gnus-summary-select-article nil nil nil (car articles))))
9096 (gnus-read-move-group-name
9097 (cadr (assq action names))
9098 (symbol-value (intern (format "gnus-current-%s-group" action)))
9100 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9101 (setq to-method (or select-method
9102 (gnus-server-to-method
9103 (gnus-group-method to-newsgroup))))
9104 ;; Check the method we are to move this article to...
9105 (unless (gnus-check-backend-function
9106 'request-accept-article (car to-method))
9107 (error "%s does not support article copying" (car to-method)))
9108 (unless (gnus-check-server to-method)
9109 (error "Can't open server %s" (car to-method)))
9110 (gnus-message 6 "%s to %s: %s..."
9111 (caddr (assq action names))
9112 (or (car select-method) to-newsgroup) articles)
9114 (setq article (pop articles))
9118 ;; Move the article.
9120 ;; Remove this article from future suppression.
9121 (gnus-dup-unsuppress-article article)
9122 (gnus-request-move-article
9123 article ; Article to move
9124 gnus-newsgroup-name ; From newsgroup
9125 (nth 1 (gnus-find-method-for-group
9126 gnus-newsgroup-name)) ; Server
9127 (list 'gnus-request-accept-article
9128 to-newsgroup (list 'quote select-method)
9129 (not articles) t) ; Accept form
9130 (not articles))) ; Only save nov last time
9131 ;; Copy the article.
9134 (set-buffer copy-buf)
9135 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9136 (gnus-request-accept-article
9137 to-newsgroup select-method (not articles) t))))
9138 ;; Crosspost the article.
9139 ((eq action 'crosspost)
9140 (let ((xref (message-tokenize-header
9141 (mail-header-xref (gnus-summary-article-header article))
9143 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9144 ":" (number-to-string article)))
9146 (setq xref (list (system-name))))
9149 (mapconcat 'identity
9150 (delete "Xref:" (delete new-xref xref))
9154 (set-buffer copy-buf)
9155 ;; First put the article in the destination group.
9156 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9157 (when (consp (setq art-group
9158 (gnus-request-accept-article
9159 to-newsgroup select-method (not articles))))
9160 (setq new-xref (concat new-xref " " (car art-group)
9162 (number-to-string (cdr art-group))))
9163 ;; Now we have the new Xrefs header, so we insert
9164 ;; it and replace the new article.
9165 (nnheader-replace-header "Xref" new-xref)
9166 (gnus-request-replace-article
9167 (cdr art-group) to-newsgroup (current-buffer))
9171 (gnus-message 1 "Couldn't %s article %s: %s"
9172 (cadr (assq action names)) article
9173 (nnheader-get-report (car to-method))))
9174 ((eq art-group 'junk)
9175 (when (eq action 'move)
9176 (gnus-summary-mark-article article gnus-canceled-mark)
9177 (gnus-message 4 "Deleted article %s" article)
9178 ;; run the delete hook
9179 (run-hook-with-args 'gnus-summary-article-delete-hook
9182 (assoc article (gnus-data-list nil)))
9183 gnus-newsgroup-name nil
9186 (let* ((pto-group (gnus-group-prefixed-name
9187 (car art-group) to-method))
9188 (info (gnus-get-info pto-group))
9189 (to-group (gnus-info-group info))
9191 ;; Update the group that has been moved to.
9193 (memq action '(move copy)))
9194 (unless (member to-group to-groups)
9195 (push to-group to-groups))
9197 (unless (memq article gnus-newsgroup-unreads)
9198 (push 'read to-marks)
9200 info (gnus-add-to-range (gnus-info-read info)
9201 (list (cdr art-group)))))
9203 ;; See whether the article is to be put in the cache.
9204 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9205 gnus-article-mark-lists
9206 (delete '(expirable . expire)
9207 (copy-sequence gnus-article-mark-lists))))
9208 (to-article (cdr art-group)))
9210 ;; Enter the article into the cache in the new group,
9211 ;; if that is required.
9212 (when gnus-use-cache
9213 (gnus-cache-possibly-enter-article
9215 (let ((header (copy-sequence
9216 (gnus-summary-article-header article))))
9217 (mail-header-set-number header to-article)
9219 (memq article gnus-newsgroup-marked)
9220 (memq article gnus-newsgroup-dormant)
9221 (memq article gnus-newsgroup-unreads)))
9223 (when gnus-preserve-marks
9224 ;; Copy any marks over to the new group.
9225 (when (and (equal to-group gnus-newsgroup-name)
9226 (not (memq article gnus-newsgroup-unreads)))
9227 ;; Mark this article as read in this group.
9228 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9229 (setcdr (gnus-active to-group) to-article)
9230 (setcdr gnus-newsgroup-active to-article))
9233 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9234 (when (memq article (symbol-value
9235 (intern (format "gnus-newsgroup-%s"
9237 (push (cdar marks) to-marks)
9238 ;; If the other group is the same as this group,
9239 ;; then we have to add the mark to the list.
9240 (when (equal to-group gnus-newsgroup-name)
9241 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9244 (intern (format "gnus-newsgroup-%s"
9246 ;; Copy the marks to other group.
9247 (gnus-add-marked-articles
9248 to-group (cdar marks) (list to-article) info)))
9249 (setq marks (cdr marks)))
9251 (gnus-request-set-mark
9252 to-group (list (list (list to-article) 'add to-marks))))
9255 (concat "(gnus-group-set-info '"
9256 (gnus-prin1-to-string (gnus-get-info to-group))
9259 ;; Update the Xref header in this article to point to
9260 ;; the new crossposted article we have just created.
9261 (when (eq action 'crosspost)
9263 (set-buffer copy-buf)
9264 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9265 (nnheader-replace-header "Xref" new-xref)
9266 (gnus-request-replace-article
9267 article gnus-newsgroup-name (current-buffer))))
9269 ;; run the move/copy/crosspost/respool hook
9270 (run-hook-with-args 'gnus-summary-article-move-hook
9273 (assoc article (gnus-data-list nil)))
9278 ;;;!!!Why is this necessary?
9279 (set-buffer gnus-summary-buffer)
9281 (gnus-summary-goto-subject article)
9282 (when (eq action 'move)
9283 (gnus-summary-mark-article article gnus-canceled-mark))))
9284 (gnus-summary-remove-process-mark article))
9285 ;; Re-activate all groups that have been moved to.
9287 (set-buffer gnus-group-buffer)
9288 (let ((gnus-group-marked to-groups))
9289 (gnus-group-get-new-news-this-group nil t)))
9291 (gnus-kill-buffer copy-buf)
9292 (gnus-summary-position-point)
9293 (gnus-set-mode-line 'summary)))
9295 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9296 "Copy the current article to some other group.
9297 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9298 When called interactively, if TO-NEWSGROUP is nil, use the value of
9299 the variable `gnus-move-split-methods' for finding a default target
9301 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9302 re-spool using this method."
9304 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9306 (defun gnus-summary-crosspost-article (&optional n)
9307 "Crosspost the current article to some other group."
9309 (gnus-summary-move-article n nil nil 'crosspost))
9311 (defcustom gnus-summary-respool-default-method nil
9312 "Default method type for respooling an article.
9313 If nil, use to the current newsgroup method."
9315 :group 'gnus-summary-mail)
9317 (defcustom gnus-summary-display-while-building nil
9318 "If non-nil, show and update the summary buffer as it's being built.
9319 If the value is t, update the buffer after every line is inserted. If
9320 the value is an integer (N), update the display every N lines."
9322 :type '(choice (const :tag "off" nil)
9324 (const :tag "frequently" t)))
9326 (defun gnus-summary-respool-article (&optional n method)
9327 "Respool the current article.
9328 The article will be squeezed through the mail spooling process again,
9329 which means that it will be put in some mail newsgroup or other
9330 depending on `nnmail-split-methods'.
9331 If N is a positive number, respool the N next articles.
9332 If N is a negative number, respool the N previous articles.
9333 If N is nil and any articles have been marked with the process mark,
9334 respool those articles instead.
9336 Respooling can be done both from mail groups and \"real\" newsgroups.
9337 In the former case, the articles in question will be moved from the
9338 current group into whatever groups they are destined to. In the
9339 latter case, they will be copied into the relevant groups."
9341 (list current-prefix-arg
9342 (let* ((methods (gnus-methods-using 'respool))
9344 (symbol-name (or gnus-summary-respool-default-method
9345 (car (gnus-find-method-for-group
9346 gnus-newsgroup-name)))))
9348 (gnus-completing-read-with-default
9349 methname "What backend do you want to use when respooling?"
9350 methods nil t nil 'gnus-mail-method-history))
9353 ((zerop (length (setq ms (gnus-servers-using-backend
9355 (list (intern method) ""))
9359 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9360 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9363 (error "No method given for respooling"))
9364 (if (assoc (symbol-name
9365 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9366 (gnus-methods-using 'respool))
9367 (gnus-summary-move-article n nil method)
9368 (gnus-summary-copy-article n nil method)))
9370 (defun gnus-summary-import-article (file &optional edit)
9371 "Import an arbitrary file into a mail newsgroup."
9372 (interactive "fImport file: \nP")
9373 (let ((group gnus-newsgroup-name)
9374 (now (current-time))
9375 atts lines group-art)
9376 (unless (gnus-check-backend-function 'request-accept-article group)
9377 (error "%s does not support article importing" group))
9378 (or (file-readable-p file)
9379 (not (file-regular-p file))
9380 (error "Can't read %s" file))
9382 (set-buffer (gnus-get-buffer-create " *import file*"))
9384 (nnheader-insert-file-contents file)
9385 (goto-char (point-min))
9386 (if (nnheader-article-p)
9388 (goto-char (point-min))
9389 (search-forward "\n\n" nil t)
9390 (narrow-to-region (point-min) (1- (point)))
9391 (goto-char (point-min))
9392 (unless (re-search-forward "^date:" nil t)
9393 (goto-char (point-max))
9394 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9395 ;; This doesn't look like an article, so we fudge some headers.
9396 (setq atts (file-attributes file)
9397 lines (count-lines (point-min) (point-max)))
9398 (insert "From: " (read-string "From: ") "\n"
9399 "Subject: " (read-string "Subject: ") "\n"
9400 "Date: " (message-make-date (nth 5 atts)) "\n"
9401 "Message-ID: " (message-make-message-id) "\n"
9402 "Lines: " (int-to-string lines) "\n"
9403 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9404 (setq group-art (gnus-request-accept-article group nil t))
9405 (kill-buffer (current-buffer)))
9406 (setq gnus-newsgroup-active (gnus-activate-group group))
9408 (gnus-summary-goto-article (cdr group-art) nil t)
9410 (gnus-summary-edit-article))))
9412 (defun gnus-summary-create-article ()
9413 "Create an article in a mail newsgroup."
9415 (let ((group gnus-newsgroup-name)
9416 (now (current-time))
9418 (unless (gnus-check-backend-function 'request-accept-article group)
9419 (error "%s does not support article importing" group))
9421 (set-buffer (gnus-get-buffer-create " *import file*"))
9423 (goto-char (point-min))
9424 ;; This doesn't look like an article, so we fudge some headers.
9425 (insert "From: " (read-string "From: ") "\n"
9426 "Subject: " (read-string "Subject: ") "\n"
9427 "Date: " (message-make-date now) "\n"
9428 "Message-ID: " (message-make-message-id) "\n")
9429 (setq group-art (gnus-request-accept-article group nil t))
9430 (kill-buffer (current-buffer)))
9431 (setq gnus-newsgroup-active (gnus-activate-group group))
9433 (gnus-summary-goto-article (cdr group-art) nil t)
9434 (gnus-summary-edit-article)))
9436 (defun gnus-summary-article-posted-p ()
9437 "Say whether the current (mail) article is available from news as well.
9438 This will be the case if the article has both been mailed and posted."
9440 (let ((id (mail-header-references (gnus-summary-article-header)))
9441 (gnus-override-method (car (gnus-refer-article-methods))))
9442 (if (gnus-request-head id "")
9443 (gnus-message 2 "The current message was found on %s"
9444 gnus-override-method)
9445 (gnus-message 2 "The current message couldn't be found on %s"
9446 gnus-override-method)
9449 (defun gnus-summary-expire-articles (&optional now)
9450 "Expire all articles that are marked as expirable in the current group."
9452 (when (and (not gnus-group-is-exiting-without-update-p)
9453 (gnus-check-backend-function
9454 'request-expire-articles gnus-newsgroup-name))
9455 ;; This backend supports expiry.
9456 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9457 (expirable (if total
9459 ;; We need to update the info for
9460 ;; this group for `gnus-list-of-read-articles'
9461 ;; to give us the right answer.
9462 (gnus-run-hooks 'gnus-exit-group-hook)
9463 (gnus-summary-update-info)
9464 (gnus-list-of-read-articles gnus-newsgroup-name))
9465 (setq gnus-newsgroup-expirable
9466 (sort gnus-newsgroup-expirable '<))))
9467 (expiry-wait (if now 'immediate
9468 (gnus-group-find-parameter
9469 gnus-newsgroup-name 'expiry-wait)))
9470 (nnmail-expiry-target
9471 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9472 nnmail-expiry-target))
9475 ;; There are expirable articles in this group, so we run them
9476 ;; through the expiry process.
9477 (gnus-message 6 "Expiring articles...")
9478 (unless (gnus-check-group gnus-newsgroup-name)
9479 (error "Can't open server for %s" gnus-newsgroup-name))
9480 ;; The list of articles that weren't expired is returned.
9483 (let ((nnmail-expiry-wait-function nil)
9484 (nnmail-expiry-wait expiry-wait))
9485 (setq es (gnus-request-expire-articles
9486 expirable gnus-newsgroup-name)))
9487 (setq es (gnus-request-expire-articles
9488 expirable gnus-newsgroup-name)))
9490 (setq gnus-newsgroup-expirable es))
9491 ;; We go through the old list of expirable, and mark all
9492 ;; really expired articles as nonexistent.
9493 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9494 (let ((gnus-use-cache nil))
9495 (dolist (article expirable)
9496 (when (and (not (memq article es))
9497 (gnus-data-find article))
9498 (gnus-summary-mark-article article gnus-canceled-mark)
9499 (run-hook-with-args 'gnus-summary-article-expire-hook
9502 (assoc article (gnus-data-list nil)))
9506 (gnus-message 6 "Expiring articles...done")))))
9508 (defun gnus-summary-expire-articles-now ()
9509 "Expunge all expirable articles in the current group.
9510 This means that *all* articles that are marked as expirable will be
9511 deleted forever, right now."
9513 (or gnus-expert-user
9515 "Are you really, really, really sure you want to delete all these messages? ")
9517 (gnus-summary-expire-articles t))
9519 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9520 (defun gnus-summary-delete-article (&optional n)
9521 "Delete the N next (mail) articles.
9522 This command actually deletes articles. This is not a marking
9523 command. The article will disappear forever from your life, never to
9526 If N is negative, delete backwards.
9527 If N is nil and articles have been marked with the process mark,
9528 delete these instead.
9530 If `gnus-novice-user' is non-nil you will be asked for
9531 confirmation before the articles are deleted."
9533 (unless (gnus-check-backend-function 'request-expire-articles
9534 gnus-newsgroup-name)
9535 (error "The current newsgroup does not support article deletion"))
9536 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9537 (error "Couldn't open server"))
9538 ;; Compute the list of articles to delete.
9539 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9540 (nnmail-expiry-target 'delete)
9542 (if (and gnus-novice-user
9543 (not (gnus-yes-or-no-p
9544 (format "Do you really want to delete %s forever? "
9545 (if (> (length articles) 1)
9546 (format "these %s articles" (length articles))
9549 ;; Delete the articles.
9550 (setq not-deleted (gnus-request-expire-articles
9551 articles gnus-newsgroup-name 'force))
9553 (gnus-summary-remove-process-mark (car articles))
9554 ;; The backend might not have been able to delete the article
9556 (unless (memq (car articles) not-deleted)
9557 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9558 (let* ((article (car articles))
9559 (ghead (gnus-data-header
9560 (assoc article (gnus-data-list nil)))))
9561 (run-hook-with-args 'gnus-summary-article-delete-hook
9562 'delete ghead gnus-newsgroup-name nil
9564 (setq articles (cdr articles)))
9566 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9567 (gnus-summary-position-point)
9568 (gnus-set-mode-line 'summary)
9571 (defun gnus-summary-edit-article (&optional force)
9572 "Edit the current article.
9573 This will have permanent effect only in mail groups.
9574 If FORCE is non-nil, allow editing of articles even in read-only
9578 (set-buffer gnus-summary-buffer)
9579 (let ((mail-parse-charset gnus-newsgroup-charset)
9580 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9581 (gnus-set-global-variables)
9582 (when (and (not force)
9583 (gnus-group-read-only-p))
9584 (error "The current newsgroup does not support article editing"))
9585 (gnus-summary-show-article t)
9586 (gnus-article-edit-article
9588 `(lambda (no-highlight)
9589 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9590 (message-options message-options)
9591 (message-options-set-recipient)
9592 (mail-parse-ignored-charsets
9593 ',gnus-newsgroup-ignored-charsets))
9594 (gnus-summary-edit-article-done
9595 ,(or (mail-header-references gnus-current-headers) "")
9596 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9598 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9600 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9602 "Make edits to the current article permanent."
9605 ;; The buffer restriction contains the entire article if it exists.
9606 (when (article-goto-body)
9607 (let ((lines (count-lines (point) (point-max)))
9608 (length (- (point-max) (point)))
9609 (case-fold-search t)
9610 (body (copy-marker (point))))
9611 (goto-char (point-min))
9612 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9613 (delete-region (match-beginning 1) (match-end 1))
9614 (insert (number-to-string length)))
9615 (goto-char (point-min))
9616 (when (re-search-forward
9617 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9618 (delete-region (match-beginning 1) (match-end 1))
9619 (insert (number-to-string length)))
9620 (goto-char (point-min))
9621 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9622 (delete-region (match-beginning 1) (match-end 1))
9623 (insert (number-to-string lines))))))
9624 ;; Replace the article.
9625 (let ((buf (current-buffer)))
9627 (insert-buffer-substring buf)
9629 (if (and (not read-only)
9630 (not (gnus-request-replace-article
9631 (cdr gnus-article-current) (car gnus-article-current)
9632 (current-buffer) t)))
9633 (error "Couldn't replace article")
9634 ;; Update the summary buffer.
9636 (equal (message-tokenize-header references " ")
9637 (message-tokenize-header
9638 (or (message-fetch-field "references") "") " ")))
9639 ;; We only have to update this line.
9642 (message-narrow-to-head)
9643 (let ((head (buffer-string))
9646 (insert (format "211 %d Article retrieved.\n"
9647 (cdr gnus-article-current)))
9650 (let ((nntp-server-buffer (current-buffer)))
9651 (setq header (car (gnus-get-newsgroup-headers
9654 (set-buffer gnus-summary-buffer)
9655 (gnus-data-set-header
9656 (gnus-data-find (cdr gnus-article-current))
9658 (gnus-summary-update-article-line
9659 (cdr gnus-article-current) header)
9660 (if (gnus-summary-goto-subject
9661 (cdr gnus-article-current) nil t)
9662 (gnus-summary-update-secondary-mark
9663 (cdr gnus-article-current))))))))
9665 (set-buffer (or buffer gnus-summary-buffer))
9666 (gnus-summary-update-article (cdr gnus-article-current))
9667 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9668 (gnus-summary-update-secondary-mark
9669 (cdr gnus-article-current))))
9670 ;; Prettify the article buffer again.
9671 (unless no-highlight
9673 (set-buffer gnus-article-buffer)
9674 ;;;!!! Fix this -- article should be rehighlighted.
9675 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9676 (set-buffer gnus-original-article-buffer)
9677 (gnus-request-article
9678 (cdr gnus-article-current)
9679 (car gnus-article-current) (current-buffer))))
9680 ;; Prettify the summary buffer line.
9681 (when (gnus-visual-p 'summary-highlight 'highlight)
9682 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9684 (defun gnus-summary-edit-wash (key)
9685 "Perform editing command KEY in the article buffer."
9689 (message "%s" (concat (this-command-keys) "- "))
9692 (gnus-summary-edit-article)
9693 (execute-kbd-macro (concat (this-command-keys) key))
9694 (gnus-article-edit-done))
9698 (defun gnus-summary-respool-query (&optional silent trace)
9699 "Query where the respool algorithm would put this article."
9701 (let (gnus-mark-article-hook)
9702 (gnus-summary-select-article)
9704 (set-buffer gnus-original-article-buffer)
9705 (let ((groups (nnmail-article-group 'identity trace)))
9708 (message "This message would go to %s"
9709 (mapconcat 'car groups ", "))
9710 (message "This message would go to no groups"))
9713 (defun gnus-summary-respool-trace ()
9714 "Trace where the respool algorithm would put this article.
9715 Display a buffer showing all fancy splitting patterns which matched."
9717 (gnus-summary-respool-query nil t))
9719 ;; Summary marking commands.
9721 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9722 "Mark articles which has the same subject as read, and then select the next.
9723 If UNMARK is positive, remove any kind of mark.
9724 If UNMARK is negative, tick articles."
9727 (setq unmark (prefix-numeric-value unmark)))
9729 (gnus-summary-mark-same-subject
9730 (gnus-summary-article-subject) unmark)))
9731 ;; Select next unread article. If auto-select-same mode, should
9732 ;; select the first unread article.
9733 (gnus-summary-next-article t (and gnus-auto-select-same
9734 (gnus-summary-article-subject)))
9735 (gnus-message 7 "%d article%s marked as %s"
9736 count (if (= count 1) " is" "s are")
9737 (if unmark "unread" "read"))))
9739 (defun gnus-summary-kill-same-subject (&optional unmark)
9740 "Mark articles which has the same subject as read.
9741 If UNMARK is positive, remove any kind of mark.
9742 If UNMARK is negative, tick articles."
9745 (setq unmark (prefix-numeric-value unmark)))
9747 (gnus-summary-mark-same-subject
9748 (gnus-summary-article-subject) unmark)))
9749 ;; If marked as read, go to next unread subject.
9751 ;; Go to next unread subject.
9752 (gnus-summary-next-subject 1 t))
9753 (gnus-message 7 "%d articles are marked as %s"
9754 count (if unmark "unread" "read"))))
9756 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9757 "Mark articles with same SUBJECT as read, and return marked number.
9758 If optional argument UNMARK is positive, remove any kinds of marks.
9759 If optional argument UNMARK is negative, mark articles as unread instead."
9763 ((null unmark) ; Mark as read.
9766 (gnus-summary-mark-article-as-read gnus-killed-mark)
9767 (gnus-summary-show-thread) t)
9768 (gnus-summary-find-subject subject))
9769 (setq count (1+ count))))
9770 ((> unmark 0) ; Tick.
9773 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9774 (gnus-summary-show-thread) t)
9775 (gnus-summary-find-subject subject))
9776 (setq count (1+ count))))
9777 (t ; Mark as unread.
9780 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9781 (gnus-summary-show-thread) t)
9782 (gnus-summary-find-subject subject))
9783 (setq count (1+ count)))))
9784 (gnus-set-mode-line 'summary)
9785 ;; Return the number of marked articles.
9788 (defun gnus-summary-mark-as-processable (n &optional unmark)
9789 "Set the process mark on the next N articles.
9790 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9791 the process mark instead. The difference between N and the actual
9792 number of articles marked is returned."
9794 (if (and (null n) (gnus-region-active-p))
9795 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9796 (setq n (prefix-numeric-value n))
9797 (let ((backward (< n 0))
9802 (gnus-summary-remove-process-mark
9803 (gnus-summary-article-number))
9804 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9805 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9808 (gnus-message 7 "No more articles"))
9809 (gnus-summary-recenter)
9810 (gnus-summary-position-point)
9813 (defun gnus-summary-unmark-as-processable (n)
9814 "Remove the process mark from the next N articles.
9815 If N is negative, unmark backward instead. The difference between N and
9816 the actual number of articles unmarked is returned."
9818 (gnus-summary-mark-as-processable n t))
9820 (defun gnus-summary-unmark-all-processable ()
9821 "Remove the process mark from all articles."
9824 (while gnus-newsgroup-processable
9825 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9826 (gnus-summary-position-point))
9828 (defun gnus-summary-add-mark (article type)
9829 "Mark ARTICLE with a mark of TYPE."
9830 (let ((vtype (car (assq type gnus-article-mark-lists)))
9833 (error "No such mark type: %s" type)
9834 (setq var (intern (format "gnus-newsgroup-%s" type)))
9835 (set var (cons article (symbol-value var)))
9836 (if (memq type '(processable cached replied forwarded recent saved))
9837 (gnus-summary-update-secondary-mark article)
9838 ;;; !!! This is bogus. We should find out what primary
9839 ;;; !!! mark we want to set.
9840 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9842 (defun gnus-summary-mark-as-expirable (n)
9843 "Mark N articles forward as expirable.
9844 If N is negative, mark backward instead. The difference between N and
9845 the actual number of articles marked is returned."
9847 (gnus-summary-mark-forward n gnus-expirable-mark))
9849 (defun gnus-summary-mark-as-spam (n)
9850 "Mark N articles forward as spam.
9851 If N is negative, mark backward instead. The difference between N and
9852 the actual number of articles marked is returned."
9854 (gnus-summary-mark-forward n gnus-spam-mark))
9856 (defun gnus-summary-mark-article-as-replied (article)
9857 "Mark ARTICLE as replied to and update the summary line.
9858 ARTICLE can also be a list of articles."
9859 (interactive (list (gnus-summary-article-number)))
9860 (let ((articles (if (listp article) article (list article))))
9861 (dolist (article articles)
9862 (unless (numberp article)
9863 (error "%s is not a number" article))
9864 (push article gnus-newsgroup-replied)
9865 (let ((buffer-read-only nil))
9866 (when (gnus-summary-goto-subject article nil t)
9867 (gnus-summary-update-secondary-mark article))))))
9869 (defun gnus-summary-mark-article-as-forwarded (article)
9870 "Mark ARTICLE as forwarded and update the summary line.
9871 ARTICLE can also be a list of articles."
9872 (let ((articles (if (listp article) article (list article))))
9873 (dolist (article articles)
9874 (push article gnus-newsgroup-forwarded)
9875 (let ((buffer-read-only nil))
9876 (when (gnus-summary-goto-subject article nil t)
9877 (gnus-summary-update-secondary-mark article))))))
9879 (defun gnus-summary-set-bookmark (article)
9880 "Set a bookmark in current article."
9881 (interactive (list (gnus-summary-article-number)))
9882 (when (or (not (get-buffer gnus-article-buffer))
9883 (not gnus-current-article)
9884 (not gnus-article-current)
9885 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9886 (error "No current article selected"))
9887 ;; Remove old bookmark, if one exists.
9888 (gnus-pull article gnus-newsgroup-bookmarks)
9889 ;; Set the new bookmark, which is on the form
9890 ;; (article-number . line-number-in-body).
9893 (with-current-buffer gnus-article-buffer
9900 gnus-newsgroup-bookmarks)
9901 (gnus-message 6 "A bookmark has been added to the current article."))
9903 (defun gnus-summary-remove-bookmark (article)
9904 "Remove the bookmark from the current article."
9905 (interactive (list (gnus-summary-article-number)))
9906 ;; Remove old bookmark, if one exists.
9907 (if (not (assq article gnus-newsgroup-bookmarks))
9908 (gnus-message 6 "No bookmark in current article.")
9909 (gnus-pull article gnus-newsgroup-bookmarks)
9910 (gnus-message 6 "Removed bookmark.")))
9912 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9913 (defun gnus-summary-mark-as-dormant (n)
9914 "Mark N articles forward as dormant.
9915 If N is negative, mark backward instead. The difference between N and
9916 the actual number of articles marked is returned."
9918 (gnus-summary-mark-forward n gnus-dormant-mark))
9920 (defun gnus-summary-set-process-mark (article)
9921 "Set the process mark on ARTICLE and update the summary line."
9922 (setq gnus-newsgroup-processable
9924 (delq article gnus-newsgroup-processable)))
9925 (when (gnus-summary-goto-subject article)
9926 (gnus-summary-show-thread)
9927 (gnus-summary-goto-subject article)
9928 (gnus-summary-update-secondary-mark article)))
9930 (defun gnus-summary-remove-process-mark (article)
9931 "Remove the process mark from ARTICLE and update the summary line."
9932 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9933 (when (gnus-summary-goto-subject article)
9934 (gnus-summary-show-thread)
9935 (gnus-summary-goto-subject article)
9936 (gnus-summary-update-secondary-mark article)))
9938 (defun gnus-summary-set-saved-mark (article)
9939 "Set the process mark on ARTICLE and update the summary line."
9940 (push article gnus-newsgroup-saved)
9941 (when (gnus-summary-goto-subject article)
9942 (gnus-summary-update-secondary-mark article)))
9944 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9945 "Mark N articles as read forwards.
9946 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9947 The difference between N and the actual number of articles marked is
9949 If NO-EXPIRE, auto-expiry will be inhibited."
9951 (gnus-summary-show-thread)
9952 (let ((backward (< n 0))
9953 (gnus-summary-goto-unread
9954 (and gnus-summary-goto-unread
9955 (not (eq gnus-summary-goto-unread 'never))
9956 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9957 gnus-ticked-mark gnus-dormant-mark)))))
9959 (mark (or mark gnus-del-mark)))
9961 (gnus-summary-mark-article nil mark no-expire)
9962 (zerop (gnus-summary-next-subject
9964 (and gnus-summary-goto-unread
9965 (not (eq gnus-summary-goto-unread 'never)))
9969 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9970 (gnus-summary-recenter)
9971 (gnus-summary-position-point)
9972 (gnus-set-mode-line 'summary)
9975 (defun gnus-summary-mark-article-as-read (mark)
9976 "Mark the current article quickly as read with MARK."
9977 (let ((article (gnus-summary-article-number)))
9978 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9979 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9980 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9981 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9982 (push (cons article mark) gnus-newsgroup-reads)
9983 ;; Possibly remove from cache, if that is used.
9984 (when gnus-use-cache
9985 (gnus-cache-enter-remove-article article))
9986 ;; Allow the backend to change the mark.
9987 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9988 ;; Check for auto-expiry.
9989 (when (and gnus-newsgroup-auto-expire
9990 (memq mark gnus-auto-expirable-marks))
9991 (setq mark gnus-expirable-mark)
9992 ;; Let the backend know about the mark change.
9993 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9994 (push article gnus-newsgroup-expirable))
9995 ;; Set the mark in the buffer.
9996 (gnus-summary-update-mark mark 'unread)
9999 (defun gnus-summary-mark-article-as-unread (mark)
10000 "Mark the current article quickly as unread with MARK."
10001 (let* ((article (gnus-summary-article-number))
10002 (old-mark (gnus-summary-article-mark article)))
10003 ;; Allow the backend to change the mark.
10004 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10005 (if (eq mark old-mark)
10009 (gnus-error 1 "Can't mark negative article numbers")
10011 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10012 (setq gnus-newsgroup-spam-marked
10013 (delq article gnus-newsgroup-spam-marked))
10014 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10015 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10016 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10017 (cond ((= mark gnus-ticked-mark)
10018 (setq gnus-newsgroup-marked
10019 (gnus-add-to-sorted-list gnus-newsgroup-marked
10021 ((= mark gnus-spam-mark)
10022 (setq gnus-newsgroup-spam-marked
10023 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10025 ((= mark gnus-dormant-mark)
10026 (setq gnus-newsgroup-dormant
10027 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10030 (setq gnus-newsgroup-unreads
10031 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10033 (gnus-pull article gnus-newsgroup-reads)
10035 ;; See whether the article is to be put in the cache.
10036 (and gnus-use-cache
10037 (vectorp (gnus-summary-article-header article))
10039 (gnus-cache-possibly-enter-article
10040 gnus-newsgroup-name article
10041 (gnus-summary-article-header article)
10042 (= mark gnus-ticked-mark)
10043 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10046 (gnus-summary-update-mark mark 'unread)
10049 (defun gnus-summary-mark-article (&optional article mark no-expire)
10050 "Mark ARTICLE with MARK. MARK can be any character.
10051 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10052 `??' (dormant) and `?E' (expirable).
10053 If MARK is nil, then the default character `?r' is used.
10054 If ARTICLE is nil, then the article on the current line will be
10056 If NO-EXPIRE, auto-expiry will be inhibited."
10057 ;; The mark might be a string.
10058 (when (stringp mark)
10059 (setq mark (aref mark 0)))
10060 ;; If no mark is given, then we check auto-expiring.
10062 (setq mark gnus-del-mark))
10063 (when (and (not no-expire)
10064 gnus-newsgroup-auto-expire
10065 (memq mark gnus-auto-expirable-marks))
10066 (setq mark gnus-expirable-mark))
10067 (let ((article (or article (gnus-summary-article-number)))
10068 (old-mark (gnus-summary-article-mark article)))
10069 ;; Allow the backend to change the mark.
10070 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10071 (if (eq mark old-mark)
10074 (error "No article on current line"))
10075 (if (not (if (or (= mark gnus-unread-mark)
10076 (= mark gnus-ticked-mark)
10077 (= mark gnus-spam-mark)
10078 (= mark gnus-dormant-mark))
10079 (gnus-mark-article-as-unread article mark)
10080 (gnus-mark-article-as-read article mark)))
10082 ;; See whether the article is to be put in the cache.
10083 (and gnus-use-cache
10084 (not (= mark gnus-canceled-mark))
10085 (vectorp (gnus-summary-article-header article))
10087 (gnus-cache-possibly-enter-article
10088 gnus-newsgroup-name article
10089 (gnus-summary-article-header article)
10090 (= mark gnus-ticked-mark)
10091 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10093 (when (gnus-summary-goto-subject article nil t)
10094 (let ((buffer-read-only nil))
10095 (gnus-summary-show-thread)
10097 (gnus-summary-update-mark mark 'unread)
10100 (defun gnus-summary-update-secondary-mark (article)
10101 "Update the secondary (read, process, cache) mark."
10102 (gnus-summary-update-mark
10103 (cond ((memq article gnus-newsgroup-processable)
10105 ((memq article gnus-newsgroup-cached)
10107 ((memq article gnus-newsgroup-replied)
10109 ((memq article gnus-newsgroup-forwarded)
10110 gnus-forwarded-mark)
10111 ((memq article gnus-newsgroup-saved)
10113 ((memq article gnus-newsgroup-recent)
10115 ((memq article gnus-newsgroup-unseen)
10119 (when (gnus-visual-p 'summary-highlight 'highlight)
10120 (gnus-run-hooks 'gnus-summary-update-hook))
10123 (defun gnus-summary-update-download-mark (article)
10124 "Update the download mark."
10125 (gnus-summary-update-mark
10126 (cond ((memq article gnus-newsgroup-undownloaded)
10127 gnus-undownloaded-mark)
10128 (gnus-newsgroup-agentized
10129 gnus-downloaded-mark)
10133 (gnus-summary-update-line t)
10136 (defun gnus-summary-update-mark (mark type)
10137 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10138 (buffer-read-only nil))
10139 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10141 (when (looking-at "\r")
10143 (when (<= (+ forward (point)) (point-max))
10144 ;; Go to the right position on the line.
10145 (goto-char (+ forward (point)))
10146 ;; Replace the old mark with the new mark.
10147 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10148 ;; Optionally update the marks by some user rule.
10149 (when (eq type 'unread)
10150 (gnus-data-set-mark
10151 (gnus-data-find (gnus-summary-article-number)) mark)
10152 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10154 (defun gnus-mark-article-as-read (article &optional mark)
10155 "Enter ARTICLE in the pertinent lists and remove it from others."
10156 ;; Make the article expirable.
10157 (let ((mark (or mark gnus-del-mark)))
10158 (setq gnus-newsgroup-expirable
10159 (if (= mark gnus-expirable-mark)
10160 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10161 (delq article gnus-newsgroup-expirable)))
10162 ;; Remove from unread and marked lists.
10163 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10164 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10165 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10166 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10167 (push (cons article mark) gnus-newsgroup-reads)
10168 ;; Possibly remove from cache, if that is used.
10169 (when gnus-use-cache
10170 (gnus-cache-enter-remove-article article))
10173 (defun gnus-mark-article-as-unread (article &optional mark)
10174 "Enter ARTICLE in the pertinent lists and remove it from others."
10175 (let ((mark (or mark gnus-ticked-mark)))
10178 (gnus-error 1 "Can't mark negative article numbers")
10180 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10181 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10182 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10183 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10184 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10186 ;; Unsuppress duplicates?
10187 (when gnus-suppress-duplicates
10188 (gnus-dup-unsuppress-article article))
10190 (cond ((= mark gnus-ticked-mark)
10191 (setq gnus-newsgroup-marked
10192 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10193 ((= mark gnus-spam-mark)
10194 (setq gnus-newsgroup-spam-marked
10195 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10197 ((= mark gnus-dormant-mark)
10198 (setq gnus-newsgroup-dormant
10199 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10201 (setq gnus-newsgroup-unreads
10202 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10203 (gnus-pull article gnus-newsgroup-reads)
10206 (defalias 'gnus-summary-mark-as-unread-forward
10207 'gnus-summary-tick-article-forward)
10208 (make-obsolete 'gnus-summary-mark-as-unread-forward
10209 'gnus-summary-tick-article-forward)
10210 (defun gnus-summary-tick-article-forward (n)
10211 "Tick N articles forwards.
10212 If N is negative, tick backwards instead.
10213 The difference between N and the number of articles ticked is returned."
10215 (gnus-summary-mark-forward n gnus-ticked-mark))
10217 (defalias 'gnus-summary-mark-as-unread-backward
10218 'gnus-summary-tick-article-backward)
10219 (make-obsolete 'gnus-summary-mark-as-unread-backward
10220 'gnus-summary-tick-article-backward)
10221 (defun gnus-summary-tick-article-backward (n)
10222 "Tick N articles backwards.
10223 The difference between N and the number of articles ticked is returned."
10225 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10227 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10228 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10229 (defun gnus-summary-tick-article (&optional article clear-mark)
10230 "Mark current article as unread.
10231 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10232 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10234 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10235 gnus-ticked-mark)))
10237 (defun gnus-summary-mark-as-read-forward (n)
10238 "Mark N articles as read forwards.
10239 If N is negative, mark backwards instead.
10240 The difference between N and the actual number of articles marked is
10243 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10245 (defun gnus-summary-mark-as-read-backward (n)
10246 "Mark the N articles as read backwards.
10247 The difference between N and the actual number of articles marked is
10250 (gnus-summary-mark-forward
10251 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10253 (defun gnus-summary-mark-as-read (&optional article mark)
10254 "Mark current article as read.
10255 ARTICLE specifies the article to be marked as read.
10256 MARK specifies a string to be inserted at the beginning of the line."
10257 (gnus-summary-mark-article article mark))
10259 (defun gnus-summary-clear-mark-forward (n)
10260 "Clear marks from N articles forward.
10261 If N is negative, clear backward instead.
10262 The difference between N and the number of marks cleared is returned."
10264 (gnus-summary-mark-forward n gnus-unread-mark))
10266 (defun gnus-summary-clear-mark-backward (n)
10267 "Clear marks from N articles backward.
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-mark-unread-as-read ()
10273 "Intended to be used by `gnus-summary-mark-article-hook'."
10274 (when (memq gnus-current-article gnus-newsgroup-unreads)
10275 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10277 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10278 "Intended to be used by `gnus-summary-mark-article-hook'."
10279 (let ((mark (gnus-summary-article-mark)))
10280 (when (or (gnus-unread-mark-p mark)
10281 (gnus-read-mark-p mark))
10282 (gnus-summary-mark-article gnus-current-article
10283 (or new-mark gnus-read-mark)))))
10285 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10286 "Intended to be used by `gnus-summary-mark-article-hook'."
10287 (let ((mark (gnus-summary-article-mark)))
10288 (when (or (gnus-unread-mark-p mark)
10289 (gnus-read-mark-p mark))
10290 (gnus-summary-mark-article (gnus-summary-article-number)
10291 (or new-mark gnus-read-mark)))))
10293 (defun gnus-summary-mark-unread-as-ticked ()
10294 "Intended to be used by `gnus-summary-mark-article-hook'."
10295 (when (memq gnus-current-article gnus-newsgroup-unreads)
10296 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10298 (defun gnus-summary-mark-region-as-read (point mark all)
10299 "Mark all unread articles between point and mark as read.
10300 If given a prefix, mark all articles between point and mark as read,
10301 even ticked and dormant ones."
10302 (interactive "r\nP")
10306 (beginning-of-line)
10311 (memq (setq article (gnus-summary-article-number))
10312 gnus-newsgroup-unreads))
10313 (gnus-summary-mark-article article gnus-del-mark))
10315 (gnus-summary-find-next))))))
10317 (defun gnus-summary-mark-below (score mark)
10318 "Mark articles with score less than SCORE with MARK."
10319 (interactive "P\ncMark: ")
10320 (setq score (if score
10321 (prefix-numeric-value score)
10322 (or gnus-summary-default-score 0)))
10324 (set-buffer gnus-summary-buffer)
10325 (goto-char (point-min))
10328 (and (< (gnus-summary-article-score) score)
10329 (gnus-summary-mark-article nil mark))
10330 (gnus-summary-find-next)))))
10332 (defun gnus-summary-kill-below (&optional score)
10333 "Mark articles with score below SCORE as read."
10335 (gnus-summary-mark-below score gnus-killed-mark))
10337 (defun gnus-summary-clear-above (&optional score)
10338 "Clear all marks from articles with score above SCORE."
10340 (gnus-summary-mark-above score gnus-unread-mark))
10342 (defun gnus-summary-tick-above (&optional score)
10343 "Tick all articles with score above SCORE."
10345 (gnus-summary-mark-above score gnus-ticked-mark))
10347 (defun gnus-summary-mark-above (score mark)
10348 "Mark articles with score over SCORE with MARK."
10349 (interactive "P\ncMark: ")
10350 (setq score (if score
10351 (prefix-numeric-value score)
10352 (or gnus-summary-default-score 0)))
10354 (set-buffer gnus-summary-buffer)
10355 (goto-char (point-min))
10357 (when (> (gnus-summary-article-score) score)
10358 (gnus-summary-mark-article nil mark))
10360 (gnus-summary-find-next)))))
10362 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10363 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10364 (defun gnus-summary-limit-include-expunged (&optional no-error)
10365 "Display all the hidden articles that were expunged for low scores."
10367 (let ((buffer-read-only nil))
10368 (let ((scored gnus-newsgroup-scored)
10371 (unless (gnus-summary-article-header (caar scored))
10372 (and (setq h (gnus-number-to-header (caar scored)))
10373 (< (cdar scored) gnus-summary-expunge-below)
10375 (setq scored (cdr scored)))
10377 (when (not no-error)
10378 (error "No expunged articles hidden"))
10379 (goto-char (point-min))
10380 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10381 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10382 (mapcar (lambda (x) (push (mail-header-number x)
10383 gnus-newsgroup-limit))
10385 (gnus-summary-prepare-unthreaded (nreverse headers))
10386 (goto-char (point-min))
10387 (gnus-summary-position-point)
10390 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10391 "Mark all unread articles in this newsgroup as read.
10392 If prefix argument ALL is non-nil, ticked and dormant articles will
10393 also be marked as read.
10394 If QUIETLY is non-nil, no questions will be asked.
10396 If TO-HERE is non-nil, it should be a point in the buffer. All
10397 articles before (after, if REVERSE is set) this point will be marked
10400 Note that this function will only catch up the unread article
10401 in the current summary buffer limitation.
10403 The number of articles marked as read is returned."
10408 (not gnus-interactive-catchup) ;Without confirmation?
10412 "Mark absolutely all articles as read? "
10413 "Mark all unread articles as read? ")))
10415 (not gnus-newsgroup-adaptive)
10416 (not gnus-newsgroup-auto-expire)
10417 (not gnus-suppress-duplicates)
10418 (or (not gnus-use-cache)
10419 (eq gnus-use-cache 'passive)))
10422 (setq gnus-newsgroup-marked nil
10423 gnus-newsgroup-spam-marked nil
10424 gnus-newsgroup-dormant nil))
10425 (setq gnus-newsgroup-unreads
10426 (gnus-sorted-nunion
10427 (gnus-intersection gnus-newsgroup-unreads
10428 gnus-newsgroup-downloadable)
10429 gnus-newsgroup-unfetched)))
10430 ;; We actually mark all articles as canceled, which we
10431 ;; have to do when using auto-expiry or adaptive scoring.
10432 (gnus-summary-show-all-threads)
10433 (if (and to-here reverse)
10435 (goto-char to-here)
10436 (gnus-summary-mark-current-read-and-unread-as-read
10438 (while (gnus-summary-find-next (not all))
10439 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10440 (when (gnus-summary-first-subject (not all))
10442 (if to-here (< (point) to-here) t)
10443 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10444 (gnus-summary-find-next (not all))))))
10445 (gnus-set-mode-line 'summary))
10447 (gnus-summary-position-point)))
10449 (defun gnus-summary-catchup-to-here (&optional all)
10450 "Mark all unticked articles before the current one as read.
10451 If ALL is non-nil, also mark ticked and dormant articles as read."
10454 (gnus-save-hidden-threads
10455 (let ((beg (point)))
10456 ;; We check that there are unread articles.
10457 (when (or all (gnus-summary-find-prev))
10458 (gnus-summary-catchup all t beg)))))
10459 (gnus-summary-position-point))
10461 (defun gnus-summary-catchup-from-here (&optional all)
10462 "Mark all unticked articles after (and including) the current one as read.
10463 If ALL is non-nil, also mark ticked and dormant articles as read."
10466 (gnus-save-hidden-threads
10467 (let ((beg (point)))
10468 ;; We check that there are unread articles.
10469 (when (or all (gnus-summary-find-next))
10470 (gnus-summary-catchup all t beg nil t)))))
10471 (gnus-summary-position-point))
10473 (defun gnus-summary-catchup-all (&optional quietly)
10474 "Mark all articles in this newsgroup as read.
10475 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10476 instead, which marks only unread articles as read."
10478 (gnus-summary-catchup t quietly))
10480 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10481 "Mark all unread articles in this group as read, then exit.
10482 If prefix argument ALL is non-nil, all articles are marked as read.
10483 If QUIETLY is non-nil, no questions will be asked."
10485 (when (gnus-summary-catchup all quietly nil 'fast)
10486 ;; Select next newsgroup or exit.
10487 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10488 (eq gnus-auto-select-next 'quietly))
10489 (gnus-summary-next-group nil)
10490 (gnus-summary-exit))))
10492 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10493 "Mark all articles in this newsgroup as read, and then exit.
10494 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10495 instead, which marks only unread articles as read."
10497 (gnus-summary-catchup-and-exit t quietly))
10499 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10500 "Mark all articles in this group as read and select the next group.
10501 If given a prefix, mark all articles, unread as well as ticked, as
10505 (gnus-summary-catchup all))
10506 (gnus-summary-next-group))
10512 (defmacro gnus-with-article (article &rest forms)
10513 "Select ARTICLE and perform FORMS in the original article buffer.
10514 Then replace the article with the result."
10516 ;; We don't want the article to be marked as read.
10517 (let (gnus-mark-article-hook)
10518 (gnus-summary-select-article t t nil ,article))
10519 (set-buffer gnus-original-article-buffer)
10521 (if (not (gnus-check-backend-function
10522 'request-replace-article (car gnus-article-current)))
10523 (gnus-message 5 "Read-only group; not replacing")
10524 (unless (gnus-request-replace-article
10525 ,article (car gnus-article-current)
10526 (current-buffer) t)
10527 (error "Couldn't replace article")))
10528 ;; The cache and backlog have to be flushed somewhat.
10529 (when gnus-keep-backlog
10530 (gnus-backlog-remove-article
10531 (car gnus-article-current) (cdr gnus-article-current)))
10532 (when gnus-use-cache
10533 (gnus-cache-update-article
10534 (car gnus-article-current) (cdr gnus-article-current)))))
10536 (put 'gnus-with-article 'lisp-indent-function 1)
10537 (put 'gnus-with-article 'edebug-form-spec '(form body))
10539 ;; Thread-based commands.
10541 (defun gnus-summary-articles-in-thread (&optional article)
10542 "Return a list of all articles in the current thread.
10543 If ARTICLE is non-nil, return all articles in the thread that starts
10544 with that article."
10545 (let* ((article (or article (gnus-summary-article-number)))
10546 (data (gnus-data-find-list article))
10547 (top-level (gnus-data-level (car data)))
10549 (cond ((null gnus-thread-operation-ignore-subject)
10550 (gnus-simplify-subject-re
10551 (mail-header-subject (gnus-data-header (car data)))))
10552 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10553 (gnus-simplify-subject-fuzzy
10554 (mail-header-subject (gnus-data-header (car data)))))
10556 (end-point (save-excursion
10557 (if (gnus-summary-go-to-next-thread)
10558 (point) (point-max))))
10561 (< (gnus-data-pos (car data)) end-point))
10562 (when (or (not top-subject)
10563 (string= top-subject
10564 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10565 (gnus-simplify-subject-fuzzy
10566 (mail-header-subject
10567 (gnus-data-header (car data))))
10568 (gnus-simplify-subject-re
10569 (mail-header-subject
10570 (gnus-data-header (car data)))))))
10571 (push (gnus-data-number (car data)) articles))
10572 (unless (and (setq data (cdr data))
10573 (> (gnus-data-level (car data)) top-level))
10575 ;; Return the list of articles.
10576 (nreverse articles)))
10578 (defun gnus-summary-rethread-current ()
10579 "Rethread the thread the current article is part of."
10581 (let* ((gnus-show-threads t)
10582 (article (gnus-summary-article-number))
10583 (id (mail-header-id (gnus-summary-article-header)))
10584 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10586 (error "No article on the current line"))
10587 (gnus-rebuild-thread id)
10588 (gnus-summary-goto-subject article)))
10590 (defun gnus-summary-reparent-thread ()
10591 "Make the current article child of the marked (or previous) article.
10593 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10594 is non-nil or the Subject: of both articles are the same."
10596 (unless (not (gnus-group-read-only-p))
10597 (error "The current newsgroup does not support article editing"))
10598 (unless (<= (length gnus-newsgroup-processable) 1)
10599 (error "No more than one article may be marked"))
10600 (save-window-excursion
10601 (let ((gnus-article-buffer " *reparent*")
10602 (current-article (gnus-summary-article-number))
10603 ;; First grab the marked article, otherwise one line up.
10604 (parent-article (if (not (null gnus-newsgroup-processable))
10605 (car gnus-newsgroup-processable)
10607 (if (eq (forward-line -1) 0)
10608 (gnus-summary-article-number)
10609 (error "Beginning of summary buffer"))))))
10610 (unless (not (eq current-article parent-article))
10611 (error "An article may not be self-referential"))
10612 (let ((message-id (mail-header-id
10613 (gnus-summary-article-header parent-article))))
10614 (unless (and message-id (not (equal message-id "")))
10615 (error "No message-id in desired parent"))
10616 (gnus-with-article current-article
10618 (goto-char (point-min))
10619 (message-narrow-to-head)
10620 (if (re-search-forward "^References: " nil t)
10622 (re-search-forward "^[^ \t]" nil t)
10625 (insert " " message-id))
10626 (insert "References: " message-id "\n"))))
10627 (set-buffer gnus-summary-buffer)
10628 (gnus-summary-unmark-all-processable)
10629 (gnus-summary-update-article current-article)
10630 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10631 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10632 (gnus-summary-rethread-current)
10633 (gnus-message 3 "Article %d is now the child of article %d"
10634 current-article parent-article)))))
10636 (defun gnus-summary-toggle-threads (&optional arg)
10637 "Toggle showing conversation threads.
10638 If ARG is positive number, turn showing conversation threads on."
10640 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10641 (setq gnus-show-threads
10642 (if (null arg) (not gnus-show-threads)
10643 (> (prefix-numeric-value arg) 0)))
10644 (gnus-summary-prepare)
10645 (gnus-summary-goto-subject current)
10646 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10647 (gnus-summary-position-point)))
10649 (defun gnus-summary-show-all-threads ()
10650 "Show all threads."
10653 (let ((buffer-read-only nil))
10654 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10655 (gnus-summary-position-point))
10657 (defun gnus-summary-show-thread ()
10658 "Show thread subtrees.
10659 Returns nil if no thread was there to be shown."
10661 (let ((buffer-read-only nil)
10663 (end (point-at-eol))
10664 ;; Leave point at bol
10665 (beg (progn (beginning-of-line) (point))))
10667 ;; Any hidden lines here?
10668 (search-forward "\r" end t)
10669 (subst-char-in-region beg end ?\^M ?\n t)
10671 (gnus-summary-position-point))))
10673 (defun gnus-summary-maybe-hide-threads ()
10674 "If requested, hide the threads that should be hidden."
10675 (when (and gnus-show-threads
10676 gnus-thread-hide-subtree)
10677 (gnus-summary-hide-all-threads
10678 (if (or (consp gnus-thread-hide-subtree)
10679 (functionp gnus-thread-hide-subtree))
10680 (gnus-make-predicate gnus-thread-hide-subtree)
10683 ;;; Hiding predicates.
10685 (defun gnus-article-unread-p (header)
10686 (memq (mail-header-number header) gnus-newsgroup-unreads))
10688 (defun gnus-article-unseen-p (header)
10689 (memq (mail-header-number header) gnus-newsgroup-unseen))
10691 (defun gnus-map-articles (predicate articles)
10692 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10693 (apply 'gnus-or (mapcar predicate
10694 (mapcar 'gnus-summary-article-header articles))))
10696 (defun gnus-summary-hide-all-threads (&optional predicate)
10697 "Hide all thread subtrees.
10698 If PREDICATE is supplied, threads that satisfy this predicate
10699 will not be hidden."
10702 (goto-char (point-min))
10705 (when (or (not predicate)
10707 predicate (gnus-summary-article-children)))
10708 (gnus-summary-hide-thread))
10709 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10710 (gnus-summary-position-point))
10712 (defun gnus-summary-hide-thread ()
10713 "Hide thread subtrees.
10714 If PREDICATE is supplied, threads that satisfy this predicate
10715 will not be hidden.
10716 Returns nil if no threads were there to be hidden."
10718 (let ((buffer-read-only nil)
10720 (article (gnus-summary-article-number)))
10722 ;; Go forward until either the buffer ends or the subthread
10724 (when (and (not (eobp))
10725 (or (zerop (gnus-summary-next-thread 1 t))
10726 (goto-char (point-max))))
10728 (if (and (> (point) start)
10729 (search-backward "\n" start t))
10731 (subst-char-in-region start (point) ?\n ?\^M)
10732 (gnus-summary-goto-subject article))
10736 (defun gnus-summary-go-to-next-thread (&optional previous)
10737 "Go to the same level (or less) next thread.
10738 If PREVIOUS is non-nil, go to previous thread instead.
10739 Return the article number moved to, or nil if moving was impossible."
10740 (let ((level (gnus-summary-thread-level))
10741 (way (if previous -1 1))
10744 (while (and (not (eobp))
10745 (< level (gnus-summary-thread-level)))
10746 (forward-line way))
10753 (gnus-summary-article-number)
10754 (goto-char beg)))))
10756 (defun gnus-summary-next-thread (n &optional silent)
10757 "Go to the same level next N'th thread.
10758 If N is negative, search backward instead.
10759 Returns the difference between N and the number of skips actually
10762 If SILENT, don't output messages."
10764 (let ((backward (< n 0))
10766 (while (and (> n 0)
10767 (gnus-summary-go-to-next-thread backward))
10770 (gnus-summary-position-point))
10771 (when (and (not silent) (/= 0 n))
10772 (gnus-message 7 "No more threads"))
10775 (defun gnus-summary-prev-thread (n)
10776 "Go to the same level previous N'th thread.
10777 Returns the difference between N and the number of skips actually
10780 (gnus-summary-next-thread (- n)))
10782 (defun gnus-summary-go-down-thread ()
10783 "Go down one level in the current thread."
10784 (let ((children (gnus-summary-article-children)))
10786 (gnus-summary-goto-subject (car children)))))
10788 (defun gnus-summary-go-up-thread ()
10789 "Go up one level in the current thread."
10790 (let ((parent (gnus-summary-article-parent)))
10792 (gnus-summary-goto-subject parent))))
10794 (defun gnus-summary-down-thread (n)
10795 "Go down thread N steps.
10796 If N is negative, go up instead.
10797 Returns the difference between N and how many steps down that were
10802 (while (and (> n 0)
10803 (if up (gnus-summary-go-up-thread)
10804 (gnus-summary-go-down-thread)))
10806 (gnus-summary-position-point)
10808 (gnus-message 7 "Can't go further"))
10811 (defun gnus-summary-up-thread (n)
10812 "Go up thread N steps.
10813 If N is negative, go down instead.
10814 Returns the difference between N and how many steps down that were
10817 (gnus-summary-down-thread (- n)))
10819 (defun gnus-summary-top-thread ()
10820 "Go to the top of the thread."
10822 (while (gnus-summary-go-up-thread))
10823 (gnus-summary-article-number))
10825 (defun gnus-summary-kill-thread (&optional unmark)
10826 "Mark articles under current thread as read.
10827 If the prefix argument is positive, remove any kinds of marks.
10828 If the prefix argument is negative, tick articles instead."
10831 (setq unmark (prefix-numeric-value unmark)))
10832 (let ((articles (gnus-summary-articles-in-thread)))
10834 ;; Expand the thread.
10835 (gnus-summary-show-thread)
10836 ;; Mark all the articles.
10838 (gnus-summary-goto-subject (car articles))
10839 (cond ((null unmark)
10840 (gnus-summary-mark-article-as-read gnus-killed-mark))
10842 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10844 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10845 (setq articles (cdr articles))))
10846 ;; Hide killed subtrees.
10848 gnus-thread-hide-killed
10849 (gnus-summary-hide-thread))
10850 ;; If marked as read, go to next unread subject.
10851 (when (null unmark)
10852 ;; Go to next unread subject.
10853 (gnus-summary-next-subject 1 t)))
10854 (gnus-set-mode-line 'summary))
10856 ;; Summary sorting commands
10858 (defun gnus-summary-sort-by-number (&optional reverse)
10859 "Sort the summary buffer by article number.
10860 Argument REVERSE means reverse order."
10862 (gnus-summary-sort 'number reverse))
10864 (defun gnus-summary-sort-by-random (&optional reverse)
10865 "Randomize the order in the summary buffer.
10866 Argument REVERSE means to randomize in reverse order."
10868 (gnus-summary-sort 'random reverse))
10870 (defun gnus-summary-sort-by-author (&optional reverse)
10871 "Sort the summary buffer by author name alphabetically.
10872 If `case-fold-search' is non-nil, case of letters is ignored.
10873 Argument REVERSE means reverse order."
10875 (gnus-summary-sort 'author reverse))
10877 (defun gnus-summary-sort-by-subject (&optional reverse)
10878 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10879 If `case-fold-search' is non-nil, case of letters is ignored.
10880 Argument REVERSE means reverse order."
10882 (gnus-summary-sort 'subject reverse))
10884 (defun gnus-summary-sort-by-date (&optional reverse)
10885 "Sort the summary buffer by date.
10886 Argument REVERSE means reverse order."
10888 (gnus-summary-sort 'date reverse))
10890 (defun gnus-summary-sort-by-score (&optional reverse)
10891 "Sort the summary buffer by score.
10892 Argument REVERSE means reverse order."
10894 (gnus-summary-sort 'score reverse))
10896 (defun gnus-summary-sort-by-lines (&optional reverse)
10897 "Sort the summary buffer by the number of lines.
10898 Argument REVERSE means reverse order."
10900 (gnus-summary-sort 'lines reverse))
10902 (defun gnus-summary-sort-by-chars (&optional reverse)
10903 "Sort the summary buffer by article length.
10904 Argument REVERSE means reverse order."
10906 (gnus-summary-sort 'chars reverse))
10908 (defun gnus-summary-sort-by-original (&optional reverse)
10909 "Sort the summary buffer using the default sorting method.
10910 Argument REVERSE means reverse order."
10912 (let* ((buffer-read-only)
10913 (gnus-summary-prepare-hook nil))
10914 ;; We do the sorting by regenerating the threads.
10915 (gnus-summary-prepare)
10916 ;; Hide subthreads if needed.
10917 (gnus-summary-maybe-hide-threads)))
10919 (defun gnus-summary-sort (predicate reverse)
10920 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10921 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10922 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10923 (gnus-thread-sort-functions
10928 (gnus-sort-gathered-threads-function
10929 gnus-thread-sort-functions)
10930 (gnus-article-sort-functions
10934 (,article t2 t1))))
10936 (gnus-summary-prepare-hook nil))
10937 ;; We do the sorting by regenerating the threads.
10938 (gnus-summary-prepare)
10939 ;; Hide subthreads if needed.
10940 (gnus-summary-maybe-hide-threads)))
10942 ;; Summary saving commands.
10944 (defun gnus-summary-save-article (&optional n not-saved)
10945 "Save the current article using the default saver function.
10946 If N is a positive number, save the N next articles.
10947 If N is a negative number, save the N previous articles.
10948 If N is nil and any articles have been marked with the process mark,
10949 save those articles instead.
10950 The variable `gnus-default-article-saver' specifies the saver function."
10952 (let* ((articles (gnus-summary-work-articles n))
10953 (save-buffer (save-excursion
10954 (nnheader-set-temp-buffer " *Gnus Save*")))
10955 (num (length articles))
10957 (dolist (article articles)
10958 (setq header (gnus-summary-article-header article))
10959 (if (not (vectorp header))
10960 ;; This is a pseudo-article.
10961 (if (assq 'name header)
10962 (gnus-copy-file (cdr (assq 'name header)))
10963 (gnus-message 1 "Article %d is unsaveable" article))
10964 ;; This is a real article.
10965 (save-window-excursion
10966 (let ((gnus-display-mime-function nil)
10967 (gnus-article-prepare-hook nil))
10968 (gnus-summary-select-article t nil nil article)))
10970 (set-buffer save-buffer)
10972 (insert-buffer-substring gnus-original-article-buffer))
10973 (setq file (gnus-article-save save-buffer file num))
10974 (gnus-summary-remove-process-mark article)
10976 (gnus-summary-set-saved-mark article))))
10977 (gnus-kill-buffer save-buffer)
10978 (gnus-summary-position-point)
10979 (gnus-set-mode-line 'summary)
10982 (defun gnus-summary-pipe-output (&optional arg headers)
10983 "Pipe the current article to a subprocess.
10984 If N is a positive number, pipe the N next articles.
10985 If N is a negative number, pipe the N previous articles.
10986 If N is nil and any articles have been marked with the process mark,
10987 pipe those articles instead.
10988 If HEADERS (the symbolic prefix), include the headers, too."
10989 (interactive (gnus-interactive "P\ny"))
10990 (require 'gnus-art)
10991 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10992 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10993 (gnus-summary-save-article arg t))
10994 (let ((buffer (get-buffer "*Shell Command Output*")))
10996 (not (zerop (buffer-size buffer))))
10997 (gnus-configure-windows 'pipe))))
10999 (defun gnus-summary-save-article-mail (&optional arg)
11000 "Append the current article to an mail file.
11001 If N is a positive number, save the N next articles.
11002 If N is a negative number, save the N previous articles.
11003 If N is nil and any articles have been marked with the process mark,
11004 save those articles instead."
11006 (require 'gnus-art)
11007 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11008 (gnus-summary-save-article arg)))
11010 (defun gnus-summary-save-article-rmail (&optional arg)
11011 "Append the current article to an rmail file.
11012 If N is a positive number, save the N next articles.
11013 If N is a negative number, save the N previous articles.
11014 If N is nil and any articles have been marked with the process mark,
11015 save those articles instead."
11017 (require 'gnus-art)
11018 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11019 (gnus-summary-save-article arg)))
11021 (defun gnus-summary-save-article-file (&optional arg)
11022 "Append the current article to a file.
11023 If N is a positive number, save the N next articles.
11024 If N is a negative number, save the N previous articles.
11025 If N is nil and any articles have been marked with the process mark,
11026 save those articles instead."
11028 (require 'gnus-art)
11029 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11030 (gnus-summary-save-article arg)))
11032 (defun gnus-summary-write-article-file (&optional arg)
11033 "Write the current article to a file, deleting the previous file.
11034 If N is a positive number, save the N next articles.
11035 If N is a negative number, save the N previous articles.
11036 If N is nil and any articles have been marked with the process mark,
11037 save those articles instead."
11039 (require 'gnus-art)
11040 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11041 (gnus-summary-save-article arg)))
11043 (defun gnus-summary-save-article-body-file (&optional arg)
11044 "Append the current article body to a file.
11045 If N is a positive number, save the N next articles.
11046 If N is a negative number, save the N previous articles.
11047 If N is nil and any articles have been marked with the process mark,
11048 save those articles instead."
11050 (require 'gnus-art)
11051 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11052 (gnus-summary-save-article arg)))
11054 (defun gnus-summary-muttprint (&optional arg)
11055 "Print the current article using Muttprint.
11056 If N is a positive number, save the N next articles.
11057 If N is a negative number, save the N previous articles.
11058 If N is nil and any articles have been marked with the process mark,
11059 save those articles instead."
11061 (require 'gnus-art)
11062 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11063 (gnus-summary-save-article arg t)))
11065 (defun gnus-summary-pipe-message (program)
11066 "Pipe the current article through PROGRAM."
11067 (interactive "sProgram: ")
11068 (gnus-summary-select-article)
11069 (let ((mail-header-separator ""))
11070 (gnus-eval-in-buffer-window gnus-article-buffer
11073 (let ((start (window-start))
11075 (message-pipe-buffer-body program)
11076 (set-window-start (get-buffer-window (current-buffer)) start))))))
11078 (defun gnus-get-split-value (methods)
11079 "Return a value based on the split METHODS."
11080 (let (split-name method result match)
11083 (set-buffer gnus-original-article-buffer)
11085 (nnheader-narrow-to-headers)
11086 (while (and methods (not split-name))
11087 (goto-char (point-min))
11088 (setq method (pop methods))
11089 (setq match (car method))
11092 ;; Regular expression.
11094 (re-search-forward match nil t)))
11099 (setq result (funcall match gnus-newsgroup-name))))
11104 (setq result (eval match)))))
11105 (setq split-name (cdr method))
11106 (cond ((stringp result)
11107 (push (expand-file-name
11108 result gnus-article-save-directory)
11111 (setq split-name (append result split-name)))))))))
11112 (nreverse split-name)))
11114 (defun gnus-valid-move-group-p (group)
11115 (and (boundp group)
11116 (symbol-name group)
11117 (symbol-value group)
11118 (gnus-get-function (gnus-find-method-for-group
11119 (symbol-name group)) 'request-accept-article t)))
11121 (defun gnus-read-move-group-name (prompt default articles prefix)
11122 "Read a group name."
11123 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11124 (minibuffer-confirm-incomplete nil) ; XEmacs
11126 (format "%s %s to:"
11128 (if (> (length articles) 1)
11129 (format "these %d articles" (length articles))
11134 (gnus-completing-read-with-default
11137 'gnus-valid-move-group-p
11139 'gnus-group-history))
11140 ((= 1 (length split-name))
11141 (gnus-completing-read-with-default
11142 (car split-name) prom
11144 'gnus-valid-move-group-p
11146 'gnus-group-history))
11148 (gnus-completing-read-with-default
11150 (mapcar 'list (nreverse split-name))
11152 'gnus-group-history))))
11153 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11155 (if (or (string= to-newsgroup "")
11156 (string= to-newsgroup prefix))
11157 (setq to-newsgroup default))
11158 (unless to-newsgroup
11159 (error "No group name entered"))
11160 (or (gnus-active to-newsgroup)
11161 (gnus-activate-group to-newsgroup nil nil to-method)
11162 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11164 (or (and (gnus-request-create-group to-newsgroup to-method)
11165 (gnus-activate-group
11166 to-newsgroup nil nil to-method)
11167 (gnus-subscribe-group to-newsgroup))
11168 (error "Couldn't create group %s" to-newsgroup)))
11169 (error "No such group: %s" to-newsgroup)))
11172 (defun gnus-summary-save-parts (type dir n &optional reverse)
11173 "Save parts matching TYPE to DIR.
11174 If REVERSE, save parts that do not match TYPE."
11176 (list (read-string "Save parts of type: "
11177 (or (car gnus-summary-save-parts-type-history)
11178 gnus-summary-save-parts-default-mime)
11179 'gnus-summary-save-parts-type-history)
11180 (setq gnus-summary-save-parts-last-directory
11181 (read-file-name "Save to directory: "
11182 gnus-summary-save-parts-last-directory
11184 current-prefix-arg))
11185 (gnus-summary-iterate n
11186 (let ((gnus-display-mime-function nil)
11187 (gnus-inhibit-treatment t))
11188 (gnus-summary-select-article))
11190 (set-buffer gnus-article-buffer)
11191 (let ((handles (or gnus-article-mime-handles
11192 (mm-dissect-buffer nil gnus-article-loose-mime)
11193 (and gnus-article-emulate-mime
11194 (mm-uu-dissect)))))
11196 (gnus-summary-save-parts-1 type dir handles reverse)
11197 (unless gnus-article-mime-handles ;; Don't destroy this case.
11198 (mm-destroy-parts handles)))))))
11200 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11201 (if (stringp (car handle))
11202 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11205 (not (string-match type (mm-handle-media-type handle)))
11206 (string-match type (mm-handle-media-type handle)))
11207 (let ((file (expand-file-name
11209 mm-file-name-rewrite-functions
11210 (file-name-nondirectory
11212 (mail-content-type-get
11213 (mm-handle-disposition handle) 'filename)
11214 (mail-content-type-get
11215 (mm-handle-type handle) 'name)
11216 (concat gnus-newsgroup-name
11217 "." (number-to-string
11218 (cdr gnus-article-current))))))
11220 (unless (file-exists-p file)
11221 (mm-save-part-to-file handle file))))))
11223 ;; Summary extract commands
11225 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11226 (let ((buffer-read-only nil)
11227 (article (gnus-summary-article-number))
11229 (unless (gnus-summary-goto-subject article)
11230 (error "No such article: %d" article))
11231 (gnus-summary-position-point)
11232 ;; If all commands are to be bunched up on one line, we collect
11234 (unless gnus-view-pseudos-separately
11235 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11238 (setq action (cdr (assq 'action (car ps))))
11239 (setq files (list (cdr (assq 'name (car ps)))))
11240 (while (and ps (cdr ps)
11241 (string= (or action "1")
11242 (or (cdr (assq 'action (cadr ps))) "2")))
11243 (push (cdr (assq 'name (cadr ps))) files)
11244 (setcdr ps (cddr ps)))
11246 (when (not (string-match "%s" action))
11249 (when (assq 'execute (car ps))
11250 (setcdr (assq 'execute (car ps))
11251 (funcall (if (string-match "%s" action)
11258 (shell-quote-argument f)))
11260 (setq ps (cdr ps)))))
11261 (if (and gnus-view-pseudos (not not-view))
11263 (when (assq 'execute (car pslist))
11264 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11265 (eq gnus-view-pseudos 'not-confirm)))
11266 (setq pslist (cdr pslist)))
11269 (setq after-article (or (cdr (assq 'article (car pslist)))
11270 (gnus-summary-article-number)))
11271 (gnus-summary-goto-subject after-article)
11274 (insert " " (file-name-nondirectory
11275 (cdr (assq 'name (car pslist))))
11276 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11278 (forward-line -1) ; back to `b'
11279 (gnus-add-text-properties
11280 b (1- e) (list 'gnus-number gnus-reffed-article-number
11281 gnus-mouse-face-prop gnus-mouse-face))
11283 after-article gnus-reffed-article-number
11284 gnus-unread-mark b (car pslist) 0 (- e b))
11285 (setq gnus-newsgroup-unreads
11286 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11287 gnus-reffed-article-number))
11288 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11289 (setq pslist (cdr pslist)))))))
11291 (defun gnus-pseudos< (p1 p2)
11292 (let ((c1 (cdr (assq 'action p1)))
11293 (c2 (cdr (assq 'action p2))))
11294 (and c1 c2 (string< c1 c2))))
11296 (defun gnus-request-pseudo-article (props)
11297 (cond ((assq 'execute props)
11298 (gnus-execute-command (cdr (assq 'execute props)))))
11299 (let ((gnus-current-article (gnus-summary-article-number)))
11300 (gnus-run-hooks 'gnus-mark-article-hook)))
11302 (defun gnus-execute-command (command &optional automatic)
11304 (gnus-article-setup-buffer)
11305 (set-buffer gnus-article-buffer)
11306 (setq buffer-read-only nil)
11307 (let ((command (if automatic command
11308 (read-string "Command: " (cons command 0)))))
11310 (insert "$ " command "\n\n")
11311 (if gnus-view-pseudo-asynchronously
11312 (start-process "gnus-execute" (current-buffer) shell-file-name
11313 shell-command-switch command)
11314 (call-process shell-file-name nil t nil
11315 shell-command-switch command)))))
11317 ;; Summary kill commands.
11319 (defun gnus-summary-edit-global-kill (article)
11320 "Edit the \"global\" kill file."
11321 (interactive (list (gnus-summary-article-number)))
11322 (gnus-group-edit-global-kill article))
11324 (defun gnus-summary-edit-local-kill ()
11325 "Edit a local kill file applied to the current newsgroup."
11327 (setq gnus-current-headers (gnus-summary-article-header))
11328 (gnus-group-edit-local-kill
11329 (gnus-summary-article-number) gnus-newsgroup-name))
11331 ;;; Header reading.
11333 (defun gnus-read-header (id &optional header)
11334 "Read the headers of article ID and enter them into the Gnus system."
11335 (let ((group gnus-newsgroup-name)
11336 (gnus-override-method
11338 gnus-override-method
11339 (and (gnus-news-group-p gnus-newsgroup-name)
11340 (car (gnus-refer-article-methods)))))
11342 ;; First we check to see whether the header in question is already
11345 ;; This is a Message-ID.
11346 (setq header (or header (gnus-id-to-header id)))
11347 ;; This is an article number.
11348 (setq header (or header (gnus-summary-article-header id))))
11350 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11351 ;; We have found the header.
11353 ;; We have to really fetch the header to this article.
11355 (set-buffer nntp-server-buffer)
11356 (when (setq where (gnus-request-head id group))
11357 (nnheader-fold-continuation-lines)
11358 (goto-char (point-max))
11360 (goto-char (point-min))
11364 ((cdr where) (cdr where))
11365 (header (mail-header-number header))
11366 (t gnus-reffed-article-number))
11368 (insert " Article retrieved.\n"))
11369 (if (or (not where)
11370 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11371 () ; Malformed head.
11372 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11373 (when (and (stringp id)
11374 (not (string= (gnus-group-real-name group)
11376 ;; If we fetched by Message-ID and the article came
11377 ;; from a different group, we fudge some bogus article
11378 ;; numbers for this article.
11379 (mail-header-set-number header gnus-reffed-article-number))
11381 (set-buffer gnus-summary-buffer)
11382 (decf gnus-reffed-article-number)
11383 (gnus-remove-header (mail-header-number header))
11384 (push header gnus-newsgroup-headers)
11385 (setq gnus-current-headers header)
11386 (push (mail-header-number header) gnus-newsgroup-limit)))
11389 (defun gnus-remove-header (number)
11390 "Remove header NUMBER from `gnus-newsgroup-headers'."
11391 (if (and gnus-newsgroup-headers
11392 (= number (mail-header-number (car gnus-newsgroup-headers))))
11393 (pop gnus-newsgroup-headers)
11394 (let ((headers gnus-newsgroup-headers))
11395 (while (and (cdr headers)
11396 (not (= number (mail-header-number (cadr headers)))))
11398 (when (cdr headers)
11399 (setcdr headers (cddr headers))))))
11402 ;;; summary highlights
11405 (defun gnus-highlight-selected-summary ()
11406 "Highlight selected article in summary buffer."
11407 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11408 (when gnus-summary-selected-face
11410 (let* ((beg (point-at-bol))
11411 (end (point-at-eol))
11412 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11413 (from (if (get-text-property beg gnus-mouse-face-prop)
11415 (or (next-single-property-change
11416 beg gnus-mouse-face-prop nil end)
11421 (or (next-single-property-change
11422 from gnus-mouse-face-prop nil end)
11424 ;; If no mouse-face prop on line we will have to = from = end,
11425 ;; so we highlight the entire line instead.
11426 (when (= (+ to 2) from)
11429 (if gnus-newsgroup-selected-overlay
11430 ;; Move old overlay.
11432 gnus-newsgroup-selected-overlay from to (current-buffer))
11433 ;; Create new overlay.
11435 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11436 'face gnus-summary-selected-face))))))
11438 (defvar gnus-summary-highlight-line-cached nil)
11439 (defvar gnus-summary-highlight-line-trigger nil)
11441 (defun gnus-summary-highlight-line-0 ()
11442 (if (and (eq gnus-summary-highlight-line-trigger
11443 gnus-summary-highlight)
11444 gnus-summary-highlight-line-cached)
11445 gnus-summary-highlight-line-cached
11446 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11447 gnus-summary-highlight-line-cached
11448 (let* ((cond (list 'cond))
11450 (list gnus-summary-highlight))
11452 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11456 (gnus-byte-compile (list 'lambda nil cond))))))
11458 (defun gnus-summary-highlight-line ()
11459 "Highlight current line according to `gnus-summary-highlight'."
11460 (let* ((beg (point-at-bol))
11461 (article (or (gnus-summary-article-number) gnus-current-article))
11462 (score (or (cdr (assq article
11463 gnus-newsgroup-scored))
11464 gnus-summary-default-score 0))
11465 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11466 (inhibit-read-only t)
11467 (default gnus-summary-default-score)
11468 (default-high gnus-summary-default-high-score)
11469 (default-low gnus-summary-default-low-score)
11470 (uncached (and gnus-summary-use-undownloaded-faces
11471 (memq article gnus-newsgroup-undownloaded)
11472 (not (memq article gnus-newsgroup-cached)))))
11473 (let ((face (funcall (gnus-summary-highlight-line-0))))
11474 (unless (eq face (get-text-property beg 'face))
11475 (gnus-put-text-property-excluding-characters-with-faces
11476 beg (point-at-eol) 'face
11477 (setq face (if (boundp face) (symbol-value face) face)))
11478 (when gnus-summary-highlight-line-function
11479 (funcall gnus-summary-highlight-line-function article face))))))
11481 (defun gnus-update-read-articles (group unread &optional compute)
11482 "Update the list of read articles in GROUP.
11483 UNREAD is a sorted list."
11484 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11485 (info (gnus-get-info group))
11488 (if (or (not info) (not active))
11489 ;; There is no info on this group if it was, in fact,
11490 ;; killed. Gnus stores no information on killed groups, so
11491 ;; there's nothing to be done.
11492 ;; One could store the information somewhere temporarily,
11493 ;; perhaps... Hmmm...
11495 ;; Remove any negative articles numbers.
11496 (while (and unread (< (car unread) 0))
11497 (setq unread (cdr unread)))
11498 ;; Remove any expired article numbers
11499 (while (and unread (< (car unread) (car active)))
11500 (setq unread (cdr unread)))
11501 ;; Compute the ranges of read articles by looking at the list of
11502 ;; unread articles.
11504 (when (/= (car unread) prev)
11505 (push (if (= prev (1- (car unread))) prev
11506 (cons prev (1- (car unread))))
11508 (setq prev (1+ (car unread)))
11509 (setq unread (cdr unread)))
11510 (when (<= prev (cdr active))
11511 (push (cons prev (cdr active)) read))
11512 (setq read (if (> (length read) 1) (nreverse read) read))
11517 ;; Propagate the read marks to the backend.
11518 (when (gnus-check-backend-function 'request-set-mark group)
11519 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11520 (add (gnus-remove-from-range read (gnus-info-read info))))
11522 (unless (gnus-check-group group)
11523 (error "Can't open server for %s" group))
11524 (gnus-request-set-mark
11525 group (delq nil (list (if add (list add 'add '(read)))
11526 (if del (list del 'del '(read))))))
11528 `(gnus-request-set-mark
11531 (if del (list del 'add '(read)))
11532 (if add (list add 'del '(read))))))))))
11533 (set-buffer gnus-group-buffer)
11534 (gnus-undo-register
11536 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11537 (gnus-info-set-read ',info ',(gnus-info-read info))
11538 (gnus-get-unread-articles-in-group ',info
11539 (gnus-active ,group))
11540 (gnus-group-update-group ,group t)
11542 ;; Enter this list into the group info.
11543 (gnus-info-set-read info read)
11544 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11545 (gnus-get-unread-articles-in-group info (gnus-active group))
11548 (defun gnus-offer-save-summaries ()
11549 "Offer to save all active summary buffers."
11551 ;; Go through all buffers and find all summaries.
11552 (dolist (buffer (buffer-list))
11553 (when (and (setq buffer (buffer-name buffer))
11554 (string-match "Summary" buffer)
11555 (with-current-buffer buffer
11556 ;; We check that this is, indeed, a summary buffer.
11557 (and (eq major-mode 'gnus-summary-mode)
11558 ;; Also make sure this isn't bogus.
11559 gnus-newsgroup-prepared
11560 ;; Also make sure that this isn't a
11561 ;; dead summary buffer.
11562 (not gnus-dead-summary-mode))))
11563 (push buffer buffers)))
11564 ;; Go through all these summary buffers and offer to save them.
11568 "Update summary buffer %s? "
11570 (switch-to-buffer buf)
11571 (gnus-summary-exit))
11575 ;;; @ for mime-partial
11578 (defun gnus-request-partial-message ()
11580 (let ((number (gnus-summary-article-number))
11581 (group gnus-newsgroup-name)
11582 (mother gnus-article-buffer))
11583 (set-buffer (get-buffer-create " *Partial Article*"))
11585 (setq mime-preview-buffer mother)
11586 (gnus-request-article-this-buffer number group)
11587 (mime-parse-buffer)
11590 (autoload 'mime-combine-message/partial-pieces-automatically
11592 "Internal method to combine message/partial messages automatically.")
11594 (mime-add-condition
11595 'action '((type . message)(subtype . partial)
11596 (major-mode . gnus-original-article-mode)
11597 (method . mime-combine-message/partial-pieces-automatically)
11598 (summary-buffer-exp . gnus-summary-buffer)
11599 (request-partial-message-method . gnus-request-partial-message)
11603 ;;; @ for message/rfc822
11606 (defun gnus-mime-extract-message/rfc822 (entity situation)
11607 "Burst a forwarded article."
11609 (set-buffer gnus-summary-buffer)
11610 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11611 gnus-newsgroup-name 'gnus-group-history))
11612 (gnus-group-marked (list group))
11615 (mime-insert-entity-content entity)
11616 (setq article (gnus-request-accept-article group)))
11617 (when (and (consp article)
11618 (numberp (setq article (cdr article))))
11619 (setq info (gnus-get-info group))
11620 (gnus-info-set-read info
11621 (gnus-remove-from-range (gnus-info-read info)
11623 (when (string-equal group gnus-newsgroup-name)
11625 (let (gnus-show-threads)
11626 (gnus-summary-goto-subject article t))
11627 (gnus-summary-clear-mark-forward 1))
11628 (set-buffer gnus-group-buffer)
11629 (gnus-group-get-new-news-this-group nil t)))))
11631 (mime-add-condition
11632 'action '((type . message)(subtype . rfc822)
11633 (major-mode . gnus-original-article-mode)
11634 (method . gnus-mime-extract-message/rfc822)
11638 (mime-add-condition
11639 'action '((type . message)(subtype . news)
11640 (major-mode . gnus-original-article-mode)
11641 (method . gnus-mime-extract-message/rfc822)
11645 (defun gnus-mime-extract-multipart (entity situation)
11646 (let ((children (mime-entity-children entity))
11647 mime-acting-situation-to-override
11650 (mime-play-entity (car children)
11651 (cons (assq 'mode situation)
11652 mime-acting-situation-to-override))
11653 (setq children (cdr children)))
11654 (if (setq f (cdr (assq 'after-method
11655 mime-acting-situation-to-override)))
11659 (mime-add-condition
11660 'action '((type . multipart)
11661 (method . gnus-mime-extract-multipart)
11670 (defun gnus-summary-inherit-default-charset ()
11671 "Import `default-mime-charset' from summary buffer.
11672 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11674 (if (buffer-live-p gnus-summary-buffer)
11675 (let (d-m-c d-m-c-u)
11676 (with-current-buffer gnus-summary-buffer
11677 (setq d-m-c (if (local-variable-p 'default-mime-charset
11678 gnus-summary-buffer)
11679 default-mime-charset
11682 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11683 gnus-summary-buffer)
11684 (symbol-value 'default-mime-charset-unlimited)
11687 (kill-local-variable 'default-mime-charset)
11688 (set (make-local-variable 'default-mime-charset) d-m-c))
11690 (kill-local-variable 'default-mime-charset-unlimited)
11691 (set (make-local-variable 'default-mime-charset-unlimited)
11694 (defun gnus-summary-setup-default-charset ()
11695 "Setup newsgroup default charset."
11696 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11698 (setq gnus-newsgroup-charset nil)
11699 (set (make-local-variable 'default-mime-charset) nil)
11700 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11701 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11702 (let ((ignored-charsets
11703 (or gnus-newsgroup-ephemeral-ignored-charsets
11705 (and gnus-newsgroup-name
11706 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11707 gnus-newsgroup-ignored-charsets)))
11709 (setq gnus-newsgroup-charset
11710 (or gnus-newsgroup-ephemeral-charset
11711 (when (and gnus-newsgroup-name
11712 (setq charset (gnus-parameter-charset
11713 gnus-newsgroup-name)))
11714 (make-local-variable 'default-mime-charset)
11715 (setq default-mime-charset charset))
11716 gnus-default-charset))
11717 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11718 ignored-charsets))))
11724 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11725 "Display the current article buffer fully MIME-buttonized.
11726 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11727 treated as multipart/mixed."
11729 (require 'gnus-art)
11730 (let ((gnus-unbuttonized-mime-types nil)
11731 (gnus-mime-display-multipart-as-mixed show-all-parts))
11732 (gnus-summary-show-article)))
11734 (defun gnus-summary-repair-multipart (article)
11735 "Add a Content-Type header to a multipart article without one."
11736 (interactive (list (gnus-summary-article-number)))
11737 (gnus-with-article article
11738 (message-narrow-to-head)
11739 (message-remove-header "Mime-Version")
11740 (goto-char (point-max))
11741 (insert "Mime-Version: 1.0\n")
11743 (when (search-forward "\n--" nil t)
11744 (let ((separator (buffer-substring (point) (point-at-eol))))
11745 (message-narrow-to-head)
11746 (message-remove-header "Content-Type")
11747 (goto-char (point-max))
11748 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11751 (let (gnus-mark-article-hook)
11752 (gnus-summary-select-article t t nil article)))
11754 (defun gnus-summary-toggle-display-buttonized ()
11755 "Toggle the buttonizing of the article buffer."
11757 (require 'gnus-art)
11758 (if (setq gnus-inhibit-mime-unbuttonizing
11759 (not gnus-inhibit-mime-unbuttonizing))
11760 (let ((gnus-unbuttonized-mime-types nil))
11761 (gnus-summary-show-article))
11762 (gnus-summary-show-article)))
11765 ;;; Intelli-mouse commmands
11768 (defun gnus-wheel-summary-scroll (event)
11770 (let ((amount (if (memq 'shift (event-modifiers event))
11771 (car gnus-wheel-scroll-amount)
11772 (cdr gnus-wheel-scroll-amount)))
11773 (direction (- (* (static-if (featurep 'xemacs)
11774 (event-button event)
11775 (cond ((eq 'mouse-4 (event-basic-type event))
11777 ((eq 'mouse-5 (event-basic-type event))
11781 (gnus-summary-scroll-up (* amount direction))
11782 (when (gnus-eval-in-buffer-window gnus-article-buffer
11785 (and (if (< 0 direction)
11786 (gnus-article-next-page 0)
11787 (gnus-article-prev-page 0)
11789 (if (setq edge (get-text-property
11790 (point-min) 'gnus-wheel-edge))
11791 (setq edge (* edge direction))
11794 (let ((buffer-read-only nil)
11795 (inhibit-read-only t))
11796 (put-text-property (point-min) (point-max)
11797 'gnus-wheel-edge direction)
11799 (or (> edge gnus-wheel-edge-resistance)
11800 (let ((buffer-read-only nil)
11801 (inhibit-read-only t))
11802 (put-text-property (point-min) (point-max)
11804 (* (1+ edge) direction))
11806 (eq last-command 'gnus-wheel-summary-scroll))))
11807 (gnus-summary-next-article nil nil (minusp direction)))))
11809 (defun gnus-wheel-install ()
11810 "Enable mouse wheel support on summary window."
11811 (when gnus-use-wheel
11813 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11815 (define-key gnus-summary-mode-map key
11816 'gnus-wheel-summary-scroll)))))
11818 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11821 ;;; Traditional PGP commmands
11824 (defun gnus-summary-decrypt-article (&optional force)
11825 "Decrypt the current article in traditional PGP way.
11826 This will have permanent effect only in mail groups.
11827 If FORCE is non-nil, allow editing of articles even in read-only
11830 (gnus-summary-select-article t)
11831 (gnus-eval-in-buffer-window gnus-article-buffer
11835 (goto-char (point-min))
11836 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11837 (error "Not a traditional PGP message!"))
11838 (let ((armor-start (match-beginning 0)))
11839 (if (and (pgg-decrypt-region armor-start (point-max))
11840 (or force (not (gnus-group-read-only-p))))
11841 (let ((inhibit-read-only t)
11843 (delete-region armor-start
11845 (re-search-forward "^-+END PGP" nil t)
11846 (beginning-of-line 2)
11848 (insert-buffer-substring pgg-output-buffer))))))))
11850 (defun gnus-summary-verify-article ()
11851 "Verify the current article in traditional PGP way."
11854 (set-buffer gnus-original-article-buffer)
11855 (goto-char (point-min))
11856 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11857 (error "Not a traditional PGP message!"))
11858 (re-search-forward "^-+END PGP" nil t)
11859 (beginning-of-line 2)
11860 (call-interactively (function pgg-verify-region))))
11863 ;;; Generic summary marking commands
11866 (defvar gnus-summary-marking-alist
11867 '((read gnus-del-mark "d")
11868 (unread gnus-unread-mark "u")
11869 (ticked gnus-ticked-mark "!")
11870 (dormant gnus-dormant-mark "?")
11871 (expirable gnus-expirable-mark "e"))
11872 "An alist of names/marks/keystrokes.")
11874 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11875 (defvar gnus-summary-mark-map)
11877 (defun gnus-summary-make-all-marking-commands ()
11878 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11879 (dolist (elem gnus-summary-marking-alist)
11880 (apply 'gnus-summary-make-marking-command elem)))
11882 (defun gnus-summary-make-marking-command (name mark keystroke)
11883 (let ((map (make-sparse-keymap)))
11884 (define-key gnus-summary-generic-mark-map keystroke map)
11885 (dolist (lway `((next "next" next nil "n")
11886 (next-unread "next unread" next t "N")
11887 (prev "previous" prev nil "p")
11888 (prev-unread "previous unread" prev t "P")
11889 (nomove "" nil nil ,keystroke)))
11890 (let ((func (gnus-summary-make-marking-command-1
11891 mark (car lway) lway name)))
11892 (setq func (eval func))
11893 (define-key map (nth 4 lway) func)))))
11895 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11897 (format "gnus-summary-put-mark-as-%s%s"
11898 name (if (eq way 'nomove)
11900 (concat "-" (symbol-name way)))))
11903 "Mark the current article as %s%s.
11904 If N, the prefix, then repeat N times.
11905 If N is negative, move in reverse order.
11906 The difference between N and the actual number of articles marked is
11908 name (car (cdr lway)))
11910 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11912 (defun gnus-summary-generic-mark (n mark move unread)
11913 "Mark N articles with MARK."
11914 (unless (eq major-mode 'gnus-summary-mode)
11915 (error "This command can only be used in the summary buffer"))
11916 (gnus-summary-show-thread)
11919 ((eq move 'next) 1)
11920 ((eq move 'prev) -1)
11922 (if (zerop nummove)
11926 nummove (* -1 nummove))))
11927 (while (and (> n 0)
11928 (gnus-summary-mark-article nil mark)
11929 (zerop (gnus-summary-next-subject nummove unread t)))
11932 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11933 (gnus-summary-recenter)
11934 (gnus-summary-position-point)
11935 (gnus-set-mode-line 'summary)
11938 (defun gnus-summary-insert-articles (articles)
11939 (when (setq articles
11940 (gnus-sorted-difference articles
11941 (mapcar (lambda (h)
11942 (mail-header-number h))
11943 gnus-newsgroup-headers)))
11944 (setq gnus-newsgroup-headers
11946 gnus-newsgroup-headers
11947 (gnus-fetch-headers articles)
11948 'gnus-article-sort-by-number))
11949 ;; Suppress duplicates?
11950 (when gnus-suppress-duplicates
11951 (gnus-dup-suppress-articles))
11953 ;; We might want to build some more threads first.
11954 (when (and gnus-fetch-old-headers
11955 (eq gnus-headers-retrieved-by 'nov))
11956 (if (eq gnus-fetch-old-headers 'invisible)
11957 (gnus-build-all-threads)
11958 (gnus-build-old-threads)))
11959 ;; Let the Gnus agent mark articles as read.
11961 (gnus-agent-get-undownloaded-list))
11962 ;; Remove list identifiers from subject
11963 (when gnus-list-identifiers
11964 (gnus-summary-remove-list-identifiers))
11965 ;; First and last article in this newsgroup.
11966 (when gnus-newsgroup-headers
11967 (setq gnus-newsgroup-begin
11968 (mail-header-number (car gnus-newsgroup-headers))
11970 (mail-header-number
11971 (gnus-last-element gnus-newsgroup-headers))))
11972 (when gnus-use-scoring
11973 (gnus-possibly-score-headers))))
11975 (defun gnus-summary-insert-old-articles (&optional all)
11976 "Insert all old articles in this group.
11977 If ALL is non-nil, already read articles become readable.
11978 If ALL is a number, fetch this number of articles."
11981 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11984 ;; Some nntp servers lie about their active range. When
11985 ;; this happens, the active range can be in the millions.
11986 ;; Use a compressed range to avoid creating a huge list.
11987 (gnus-range-difference (list gnus-newsgroup-active) old))
11988 (setq len (gnus-range-length older))
11993 (let ((older-range (nreverse older)))
11997 (let* ((r (pop older-range))
11998 (min (if (numberp r) r (car r)))
11999 (max (if (numberp r) r (cdr r))))
12000 (while (and (<= min max)
12005 (setq older (gnus-uncompress-range older))))
12007 (setq older (gnus-uncompress-range older)))
12009 (when (and (numberp gnus-large-newsgroup)
12010 (> len gnus-large-newsgroup))
12011 (let* ((cursor-in-echo-area nil)
12012 (initial (gnus-parameter-large-newsgroup-initial
12013 gnus-newsgroup-name))
12017 "How many articles from %s (%s %d): "
12019 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12020 (if initial "max" "default")
12023 (cons (number-to-string initial)
12025 (unless (string-match "^[ \t]*$" input)
12026 (setq all (string-to-number input))
12028 (let ((older-range (nreverse older)))
12032 (let* ((r (pop older-range))
12033 (min (if (numberp r) r (car r)))
12034 (max (if (numberp r) r (cdr r))))
12035 (while (and (<= min max)
12039 max (1- max))))))))))
12040 (setq older (gnus-uncompress-range older))))
12042 (message "No old news.")
12043 (gnus-summary-insert-articles older)
12044 (gnus-summary-limit (gnus-sorted-nunion old older))))
12045 (gnus-summary-position-point)))
12047 (defun gnus-summary-insert-new-articles ()
12048 "Insert all new articles in this group."
12051 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12052 (old-active gnus-newsgroup-active)
12053 (nnmail-fetched-sources (list t))
12055 (setq gnus-newsgroup-active
12056 (gnus-activate-group gnus-newsgroup-name 'scan))
12057 (setq i (cdr gnus-newsgroup-active))
12058 (while (> i (cdr old-active))
12062 (message "No gnus is bad news")
12063 (gnus-summary-insert-articles new)
12064 (setq gnus-newsgroup-unreads
12065 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12066 (gnus-summary-limit (gnus-sorted-nunion old new))))
12067 (gnus-summary-position-point)))
12069 (gnus-summary-make-all-marking-commands)
12071 (gnus-ems-redefine)
12073 (provide 'gnus-sum)
12075 (run-hooks 'gnus-sum-load-hook)
12077 ;; Local Variables:
12078 ;; coding: iso-8859-1
12081 ;;; gnus-sum.el ends here