1 ;;; gnus-sum.el --- summary mode commands for gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Katsumi Yamaoka <yamaoka@jpl.org>
9 ;; Keywords: mail, news, MIME
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
34 (defvar tool-bar-map))
50 (autoload 'pgg-decrypt-region "pgg" nil t)
51 (autoload 'pgg-verify-region "pgg" nil t))
53 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
54 (autoload 'gnus-cache-write-active "gnus-cache")
55 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
56 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
57 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
58 (autoload 'mm-uu-dissect "mm-uu")
59 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
60 "Deuglify broken Outlook (Express) articles and redisplay."
62 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
63 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
64 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
66 (defcustom gnus-kill-summary-on-exit t
67 "*If non-nil, kill the summary buffer when you exit from it.
68 If nil, the summary will become a \"*Dead Summary*\" buffer, and
69 it will be killed sometime later."
70 :group 'gnus-summary-exit
73 (defcustom gnus-fetch-old-headers nil
74 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
75 If an unread article in the group refers to an older, already
76 read (or just marked as read) article, the old article will not
77 normally be displayed in the Summary buffer. If this variable is
78 t, Gnus will attempt to grab the headers to the old articles, and
79 thereby build complete threads. If it has the value `some', all
80 old headers will be fetched but only enough headers to connect
81 otherwise loose threads will be displayed. This variable can
82 also be a number. In that case, no more than that number of old
83 headers will be fetched. If it has the value `invisible', all
84 old headers will be fetched, but none will be displayed.
86 The server has to support NOV for any of this to work.
88 This feature can seriously impact performance it ignores all
89 locally cached header entries."
91 :type '(choice (const :tag "off" nil)
96 (sexp :menu-tag "other" t)))
98 (defcustom gnus-refer-thread-limit 200
99 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
100 If t, fetch all the available old headers."
102 :type '(choice number
103 (sexp :menu-tag "other" t)))
105 (defcustom gnus-summary-make-false-root 'adopt
106 "*nil means that Gnus won't gather loose threads.
107 If the root of a thread has expired or been read in a previous
108 session, the information necessary to build a complete thread has been
109 lost. Instead of having many small sub-threads from this original thread
110 scattered all over the summary buffer, Gnus can gather them.
112 If non-nil, Gnus will try to gather all loose sub-threads from an
113 original thread into one large thread.
115 If this variable is non-nil, it should be one of `none', `adopt',
118 If this variable is `none', Gnus will not make a false root, but just
119 present the sub-threads after another.
120 If this variable is `dummy', Gnus will create a dummy root that will
121 have all the sub-threads as children.
122 If this variable is `adopt', Gnus will make one of the \"children\"
123 the parent and mark all the step-children as such.
124 If this variable is `empty', the \"children\" are printed with empty
125 subject fields. (Or rather, they will be printed with a string
126 given by the `gnus-summary-same-subject' variable.)"
128 :type '(choice (const :tag "off" nil)
134 (defcustom gnus-summary-make-false-root-always nil
135 "Always make a false dummy root."
140 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
141 "*A regexp to match subjects to be excluded from loose thread gathering.
142 As loose thread gathering is done on subjects only, that means that
143 there can be many false gatherings performed. By rooting out certain
144 common subjects, gathering might become saner."
148 (defcustom gnus-summary-gather-subject-limit nil
149 "*Maximum length of subject comparisons when gathering loose threads.
150 Use nil to compare full subjects. Setting this variable to a low
151 number will help gather threads that have been corrupted by
152 newsreaders chopping off subject lines, but it might also mean that
153 unrelated articles that have subject that happen to begin with the
154 same few characters will be incorrectly gathered.
156 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
159 :type '(choice (const :tag "off" nil)
161 (sexp :menu-tag "on" t)))
163 (defcustom gnus-simplify-subject-functions nil
164 "List of functions taking a string argument that simplify subjects.
165 The functions are applied recursively.
167 Useful functions to put in this list include:
168 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
169 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
171 :type '(repeat function))
173 (defcustom gnus-simplify-ignored-prefixes nil
174 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
176 :type '(choice (const :tag "off" nil)
179 (defcustom gnus-build-sparse-threads nil
180 "*If non-nil, fill in the gaps in threads.
181 If `some', only fill in the gaps that are needed to tie loose threads
182 together. If `more', fill in all leaf nodes that Gnus can find. If
183 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
185 :type '(choice (const :tag "off" nil)
188 (sexp :menu-tag "all" t)))
190 (defcustom gnus-summary-thread-gathering-function
191 'gnus-gather-threads-by-subject
192 "*Function used for gathering loose threads.
193 There are two pre-defined functions: `gnus-gather-threads-by-subject',
194 which only takes Subjects into consideration; and
195 `gnus-gather-threads-by-references', which compared the References
196 headers of the articles to find matches."
198 :type '(radio (function-item gnus-gather-threads-by-subject)
199 (function-item gnus-gather-threads-by-references)
200 (function :tag "other")))
202 (defcustom gnus-summary-same-subject ""
203 "*String indicating that the current article has the same subject as the previous.
204 This variable will only be used if the value of
205 `gnus-summary-make-false-root' is `empty'."
206 :group 'gnus-summary-format
209 (defcustom gnus-summary-goto-unread t
210 "*If t, many commands will go to the next unread article.
211 This applies to marking commands as well as other commands that
212 \"naturally\" select the next article, like, for instance, `SPC' at
213 the end of an article.
215 If nil, the marking commands do NOT go to the next unread article
216 \(they go to the next article instead). If `never', commands that
217 usually go to the next unread article, will go to the next article,
218 whether it is read or not."
219 :group 'gnus-summary-marks
220 :link '(custom-manual "(gnus)Setting Marks")
221 :type '(choice (const :tag "off" nil)
223 (sexp :menu-tag "on" t)))
225 (defcustom gnus-summary-default-score 0
226 "*Default article score level.
227 All scores generated by the score files will be added to this score.
228 If this variable is nil, scoring will be disabled."
229 :group 'gnus-score-default
230 :type '(choice (const :tag "disable")
233 (defcustom gnus-summary-default-high-score 0
234 "*Default threshold for a high scored article.
235 An article will be highlighted as high scored if its score is greater
238 :group 'gnus-score-default
241 (defcustom gnus-summary-default-low-score 0
242 "*Default threshold for a low scored article.
243 An article will be highlighted as low scored if its score is smaller
246 :group 'gnus-score-default
249 (defcustom gnus-summary-zcore-fuzz 0
250 "*Fuzziness factor for the zcore in the summary buffer.
251 Articles with scores closer than this to `gnus-summary-default-score'
253 :group 'gnus-summary-format
256 (defcustom gnus-simplify-subject-fuzzy-regexp nil
257 "*Strings to be removed when doing fuzzy matches.
258 This can either be a regular expression or list of regular expressions
259 that will be removed from subject strings if fuzzy subject
260 simplification is selected."
262 :type '(repeat regexp))
264 (defcustom gnus-show-threads t
265 "*If non-nil, display threads in summary mode."
269 (defcustom gnus-thread-hide-subtree nil
270 "*If non-nil, hide all threads initially.
271 This can be a predicate specifier which says which threads to hide.
272 If threads are hidden, you have to run the command
273 `gnus-summary-show-thread' by hand or or select an article."
275 :type '(radio (sexp :format "Non-nil\n"
276 :match (lambda (widget value)
277 (not (or (consp value) (functionp value))))
280 (sexp :tag "Predicate specifier")))
282 (defcustom gnus-thread-hide-killed t
283 "*If non-nil, hide killed threads automatically."
287 (defcustom gnus-thread-ignore-subject t
288 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
289 If nil, articles that have different subjects from their parents will
290 start separate threads."
294 (defcustom gnus-thread-operation-ignore-subject t
295 "*If non-nil, subjects will be ignored when doing thread commands.
296 This affects commands like `gnus-summary-kill-thread' and
297 `gnus-summary-lower-thread'.
299 If this variable is nil, articles in the same thread with different
300 subjects will not be included in the operation in question. If this
301 variable is `fuzzy', only articles that have subjects that are fuzzily
302 equal will be included."
304 :type '(choice (const :tag "off" nil)
308 (defcustom gnus-thread-indent-level 4
309 "*Number that says how much each sub-thread should be indented."
313 (defcustom gnus-auto-extend-newsgroup t
314 "*If non-nil, extend newsgroup forward and backward when requested."
315 :group 'gnus-summary-choose
318 (defcustom gnus-auto-select-first t
319 "*If non-nil, select the article under point.
320 Which article this is is controlled by the `gnus-auto-select-subject'
323 If you want to prevent automatic selection of articles in some
324 newsgroups, set the variable to nil in `gnus-select-group-hook'."
325 :group 'gnus-group-select
326 :type '(choice (const :tag "none" nil)
327 (sexp :menu-tag "first" t)))
329 (defcustom gnus-auto-select-subject 'unread
330 "*Says what subject to place under point when entering a group.
332 This variable can either be the symbols `first' (place point on the
333 first subject), `unread' (place point on the subject line of the first
334 unread article), `best' (place point on the subject line of the
335 higest-scored article), `unseen' (place point on the subject line of
336 the first unseen article), `unseen-or-unread' (place point on the subject
337 line of the first unseen article or, if all article have been seen, on the
338 subject line of the first unread article), or a function to be called to
339 place point on some subject line."
341 :group 'gnus-group-select
342 :type '(choice (const best)
346 (const unseen-or-unread)))
348 (defcustom gnus-dont-select-after-jump-to-other-group nil
349 "If non-nil, don't select the first unread article after entering the
350 other group by the command `gnus-summary-jump-to-other-group'. If nil,
351 it is depend on the value of `gnus-auto-select-first' whether to select
353 :group 'gnus-group-select
356 (defcustom gnus-auto-select-next t
357 "*If non-nil, offer to go to the next group from the end of the previous.
358 If the value is t and the next newsgroup is empty, Gnus will exit
359 summary mode and go back to group mode. If the value is neither nil
360 nor t, Gnus will select the following unread newsgroup. In
361 particular, if the value is the symbol `quietly', the next unread
362 newsgroup will be selected without any confirmation, and if it is
363 `almost-quietly', the next group will be selected without any
364 confirmation if you are located on the last article in the group.
365 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
366 will go to the next group without confirmation."
367 :group 'gnus-summary-maneuvering
368 :type '(choice (const :tag "off" nil)
370 (const almost-quietly)
371 (const slightly-quietly)
372 (sexp :menu-tag "on" t)))
374 (defcustom gnus-auto-select-same nil
375 "*If non-nil, select the next article with the same subject.
376 If there are no more articles with the same subject, go to
377 the first unread article."
378 :group 'gnus-summary-maneuvering
381 (defcustom gnus-auto-goto-ignores 'unfetched
382 "*Says how to handle unfetched articles when maneuvering.
384 This variable can either be the symbols nil (maneuver to any
385 article), `undownloaded' (maneuvering while unplugged ignores articles
386 that have not been fetched), `always-undownloaded' (maneuvering always
387 ignores articles that have not been fetched), `unfetched' (maneuvering
388 ignores articles whose headers have not been fetched).
390 NOTE: The list of unfetched articles will always be nil when plugged
391 and, when unplugged, a subset of the undownloaded article list."
393 :group 'gnus-summary-maneuvering
394 :type '(choice (const :tag "None" nil)
395 (const :tag "Undownloaded when unplugged" undownloaded)
396 (const :tag "Undownloaded" always-undownloaded)
397 (const :tag "Unfetched" unfetched)))
399 (defcustom gnus-summary-check-current nil
400 "*If non-nil, consider the current article when moving.
401 The \"unread\" movement commands will stay on the same line if the
402 current article is unread."
403 :group 'gnus-summary-maneuvering
406 (defcustom gnus-auto-center-summary 2
407 "*If non-nil, always center the current summary buffer.
408 In particular, if `vertical' do only vertical recentering. If non-nil
409 and non-`vertical', do both horizontal and vertical recentering."
410 :group 'gnus-summary-maneuvering
411 :type '(choice (const :tag "none" nil)
413 (integer :tag "height")
414 (sexp :menu-tag "both" t)))
416 (defvar gnus-auto-center-group t
417 "*If non-nil, always center the group buffer.")
419 (defcustom gnus-show-all-headers nil
420 "*If non-nil, don't hide any headers."
421 :group 'gnus-article-hiding
422 :group 'gnus-article-headers
425 (defcustom gnus-summary-ignore-duplicates nil
426 "*If non-nil, ignore articles with identical Message-ID headers."
430 (defcustom gnus-single-article-buffer t
431 "*If non-nil, display all articles in the same buffer.
432 If nil, each group will get its own article buffer."
433 :group 'gnus-article-various
436 (defcustom gnus-break-pages t
437 "*If non-nil, do page breaking on articles.
438 The page delimiter is specified by the `gnus-page-delimiter'
440 :group 'gnus-article-various
443 (defcustom gnus-show-mime t
444 "*If non-nil, do mime processing of articles.
445 The articles will simply be fed to the function given by
446 `gnus-article-display-method-for-mime'."
447 :group 'gnus-article-mime
450 (defcustom gnus-move-split-methods nil
451 "*Variable used to suggest where articles are to be moved to.
452 It uses the same syntax as the `gnus-split-methods' variable.
453 However, whereas `gnus-split-methods' specifies file names as targets,
454 this variable specifies group names."
455 :group 'gnus-summary-mail
456 :type '(repeat (choice (list :value (fun) function)
457 (cons :value ("" "") regexp (repeat string))
460 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
461 "Function used to compute default prefix for article move/copy/etc prompts.
462 The function should take one argument, a group name, and return a
463 string with the suggested prefix."
464 :group 'gnus-summary-mail
467 ;; FIXME: Although the custom type is `character' for the following variables,
468 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
470 (defcustom gnus-unread-mark ?\ ;;;Whitespace
471 "*Mark used for unread articles."
472 :group 'gnus-summary-marks
475 (defcustom gnus-ticked-mark ?!
476 "*Mark used for ticked articles."
477 :group 'gnus-summary-marks
480 (defcustom gnus-dormant-mark ??
481 "*Mark used for dormant articles."
482 :group 'gnus-summary-marks
485 (defcustom gnus-del-mark ?r
486 "*Mark used for del'd articles."
487 :group 'gnus-summary-marks
490 (defcustom gnus-read-mark ?R
491 "*Mark used for read articles."
492 :group 'gnus-summary-marks
495 (defcustom gnus-expirable-mark ?E
496 "*Mark used for expirable articles."
497 :group 'gnus-summary-marks
500 (defcustom gnus-killed-mark ?K
501 "*Mark used for killed articles."
502 :group 'gnus-summary-marks
505 (defcustom gnus-spam-mark ?$
506 "*Mark used for spam articles."
508 :group 'gnus-summary-marks
511 (defcustom gnus-souped-mark ?F
512 "*Mark used for souped articles."
513 :group 'gnus-summary-marks
516 (defcustom gnus-kill-file-mark ?X
517 "*Mark used for articles killed by kill files."
518 :group 'gnus-summary-marks
521 (defcustom gnus-low-score-mark ?Y
522 "*Mark used for articles with a low score."
523 :group 'gnus-summary-marks
526 (defcustom gnus-catchup-mark ?C
527 "*Mark used for articles that are caught up."
528 :group 'gnus-summary-marks
531 (defcustom gnus-replied-mark ?A
532 "*Mark used for articles that have been replied to."
533 :group 'gnus-summary-marks
536 (defcustom gnus-forwarded-mark ?F
537 "*Mark used for articles that have been forwarded."
539 :group 'gnus-summary-marks
542 (defcustom gnus-recent-mark ?N
543 "*Mark used for articles that are recent."
545 :group 'gnus-summary-marks
548 (defcustom gnus-cached-mark ?*
549 "*Mark used for articles that are in the cache."
550 :group 'gnus-summary-marks
553 (defcustom gnus-saved-mark ?S
554 "*Mark used for articles that have been saved."
555 :group 'gnus-summary-marks
558 (defcustom gnus-unseen-mark ?.
559 "*Mark used for articles that haven't been seen."
561 :group 'gnus-summary-marks
564 (defcustom gnus-no-mark ?\ ;;;Whitespace
565 "*Mark used for articles that have no other secondary mark."
567 :group 'gnus-summary-marks
570 (defcustom gnus-ancient-mark ?O
571 "*Mark used for ancient articles."
572 :group 'gnus-summary-marks
575 (defcustom gnus-sparse-mark ?Q
576 "*Mark used for sparsely reffed articles."
577 :group 'gnus-summary-marks
580 (defcustom gnus-canceled-mark ?G
581 "*Mark used for canceled articles."
582 :group 'gnus-summary-marks
585 (defcustom gnus-duplicate-mark ?M
586 "*Mark used for duplicate articles."
587 :group 'gnus-summary-marks
590 (defcustom gnus-undownloaded-mark ?-
591 "*Mark used for articles that weren't downloaded."
593 :group 'gnus-summary-marks
596 (defcustom gnus-downloaded-mark ?+
597 "*Mark used for articles that were downloaded."
598 :group 'gnus-summary-marks
601 (defcustom gnus-downloadable-mark ?%
602 "*Mark used for articles that are to be downloaded."
603 :group 'gnus-summary-marks
606 (defcustom gnus-unsendable-mark ?=
607 "*Mark used for articles that won't be sent."
608 :group 'gnus-summary-marks
611 (defcustom gnus-score-over-mark ?+
612 "*Score mark used for articles with high scores."
613 :group 'gnus-summary-marks
616 (defcustom gnus-score-below-mark ?-
617 "*Score mark used for articles with low scores."
618 :group 'gnus-summary-marks
621 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
622 "*There is no thread under the article."
623 :group 'gnus-summary-marks
626 (defcustom gnus-not-empty-thread-mark ?=
627 "*There is a thread under the article."
628 :group 'gnus-summary-marks
631 (defcustom gnus-view-pseudo-asynchronously nil
632 "*If non-nil, Gnus will view pseudo-articles asynchronously."
633 :group 'gnus-extract-view
636 (defcustom gnus-auto-expirable-marks
637 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
638 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
639 gnus-souped-mark gnus-duplicate-mark)
640 "*The list of marks converted into expiration if a group is auto-expirable."
643 :type '(repeat character))
645 (defcustom gnus-inhibit-user-auto-expire t
646 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
651 (defcustom gnus-view-pseudos nil
652 "*If `automatic', pseudo-articles will be viewed automatically.
653 If `not-confirm', pseudos will be viewed automatically, and the user
654 will not be asked to confirm the command."
655 :group 'gnus-extract-view
656 :type '(choice (const :tag "off" nil)
658 (const not-confirm)))
660 (defcustom gnus-view-pseudos-separately t
661 "*If non-nil, one pseudo-article will be created for each file to be viewed.
662 If nil, all files that use the same viewing command will be given as a
663 list of parameters to that command."
664 :group 'gnus-extract-view
667 (defcustom gnus-insert-pseudo-articles t
668 "*If non-nil, insert pseudo-articles when decoding articles."
669 :group 'gnus-extract-view
672 (defcustom gnus-summary-dummy-line-format
674 "*The format specification for the dummy roots in the summary buffer.
675 It works along the same lines as a normal formatting string,
676 with some simple extensions.
680 General format specifiers can also be used.
681 See `(gnus)Formatting Variables'."
682 :link '(custom-manual "(gnus)Formatting Variables")
683 :group 'gnus-threading
686 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
687 "*The format specification for the summary mode line.
688 It works along the same lines as a normal formatting string,
689 with some simple extensions:
692 %p Unprefixed group name
693 %A Current article number
694 %z Current article score
696 %U Number of unread articles in the group
697 %e Number of unselected articles in the group
698 %Z A string with unread/unselected article counts
699 %g Shortish group name
700 %S Subject of the current article
702 %s Current score file name
703 %d Number of dormant articles
704 %r Number of articles that have been marked as read in this session
705 %E Number of articles expunged by the score files"
706 :group 'gnus-summary-format
709 (defcustom gnus-list-identifiers nil
710 "Regexp that matches list identifiers to be removed from subject.
711 This can also be a list of regexps."
713 :group 'gnus-summary-format
714 :group 'gnus-article-hiding
715 :type '(choice (const :tag "none" nil)
717 (repeat :value (".*") regexp)))
719 (defcustom gnus-summary-mark-below 0
720 "*Mark all articles with a score below this variable as read.
721 This variable is local to each summary buffer and usually set by the
723 :group 'gnus-score-default
726 (defun gnus-widget-reversible-match (widget value)
727 "Ignoring WIDGET, convert VALUE to internal form.
728 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
732 (eq (length value) 2)
733 (eq (nth 0 value) 'not)
734 (symbolp (nth 1 value)))))
736 (defun gnus-widget-reversible-to-internal (widget value)
737 "Ignoring WIDGET, convert VALUE to internal form.
738 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
739 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
743 (list (nth 1 value) t)))
745 (defun gnus-widget-reversible-to-external (widget value)
746 "Ignoring WIDGET, convert VALUE to external form.
747 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
748 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
751 (list 'not (nth 0 value))
754 (define-widget 'gnus-widget-reversible 'group
755 "A `group' that convert values."
756 :match 'gnus-widget-reversible-match
757 :value-to-internal 'gnus-widget-reversible-to-internal
758 :value-to-external 'gnus-widget-reversible-to-external)
760 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
761 "*List of functions used for sorting articles in the summary buffer.
763 Each function takes two articles and returns non-nil if the first
764 article should be sorted before the other. If you use more than one
765 function, the primary sort function should be the last. You should
766 probably always include `gnus-article-sort-by-number' in the list of
767 sorting functions -- preferably first. Also note that sorting by date
768 is often much slower than sorting by number, and the sorting order is
769 very similar. (Sorting by date means sorting by the time the message
770 was sent, sorting by number means sorting by arrival time.)
772 Each item can also be a list `(not F)' where F is a function;
773 this reverses the sort order.
775 Ready-made functions include `gnus-article-sort-by-number',
776 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
777 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
778 and `gnus-article-sort-by-score'.
780 When threading is turned on, the variable `gnus-thread-sort-functions'
781 controls how articles are sorted."
782 :group 'gnus-summary-sort
783 :type '(repeat (gnus-widget-reversible
784 (choice (function-item gnus-article-sort-by-number)
785 (function-item gnus-article-sort-by-author)
786 (function-item gnus-article-sort-by-subject)
787 (function-item gnus-article-sort-by-date)
788 (function-item gnus-article-sort-by-score)
789 (function-item gnus-article-sort-by-random)
790 (function :tag "other"))
791 (boolean :tag "Reverse order"))))
794 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
795 "*List of functions used for sorting threads in the summary buffer.
796 By default, threads are sorted by article number.
798 Each function takes two threads and returns non-nil if the first
799 thread should be sorted before the other. If you use more than one
800 function, the primary sort function should be the last. You should
801 probably always include `gnus-thread-sort-by-number' in the list of
802 sorting functions -- preferably first. Also note that sorting by date
803 is often much slower than sorting by number, and the sorting order is
804 very similar. (Sorting by date means sorting by the time the message
805 was sent, sorting by number means sorting by arrival time.)
807 Each list item can also be a list `(not F)' where F is a
808 function; this specifies reversed sort order.
810 Ready-made functions include `gnus-thread-sort-by-number',
811 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
812 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
813 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
814 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
815 and `gnus-thread-sort-by-total-score' (see
816 `gnus-thread-score-function').
818 When threading is turned off, the variable
819 `gnus-article-sort-functions' controls how articles are sorted."
820 :group 'gnus-summary-sort
822 (gnus-widget-reversible
823 (choice (function-item gnus-thread-sort-by-number)
824 (function-item gnus-thread-sort-by-author)
825 (function-item gnus-thread-sort-by-recipient)
826 (function-item gnus-thread-sort-by-subject)
827 (function-item gnus-thread-sort-by-date)
828 (function-item gnus-thread-sort-by-score)
829 (function-item gnus-thread-sort-by-most-recent-number)
830 (function-item gnus-thread-sort-by-most-recent-date)
831 (function-item gnus-thread-sort-by-random)
832 (function-item gnus-thread-sort-by-total-score)
833 (function :tag "other"))
834 (boolean :tag "Reverse order"))))
836 (defcustom gnus-thread-score-function '+
837 "*Function used for calculating the total score of a thread.
839 The function is called with the scores of the article and each
840 subthread and should then return the score of the thread.
842 Some functions you can use are `+', `max', or `min'."
843 :group 'gnus-summary-sort
846 (defcustom gnus-summary-expunge-below nil
847 "All articles that have a score less than this variable will be expunged.
848 This variable is local to the summary buffers."
849 :group 'gnus-score-default
850 :type '(choice (const :tag "off" nil)
853 (defcustom gnus-thread-expunge-below nil
854 "All threads that have a total score less than this variable will be expunged.
855 See `gnus-thread-score-function' for en explanation of what a
858 This variable is local to the summary buffers."
859 :group 'gnus-threading
860 :group 'gnus-score-default
861 :type '(choice (const :tag "off" nil)
864 (defcustom gnus-summary-mode-hook nil
865 "*A hook for Gnus summary mode.
866 This hook is run before any variables are set in the summary buffer."
867 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
868 :group 'gnus-summary-various
871 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
872 (when (featurep 'xemacs)
873 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
874 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
875 (add-hook 'gnus-summary-mode-hook
876 'gnus-xmas-switch-horizontal-scrollbar-off))
878 (defcustom gnus-summary-menu-hook nil
879 "*Hook run after the creation of the summary mode menu."
880 :group 'gnus-summary-visual
883 (defcustom gnus-summary-exit-hook nil
884 "*A hook called on exit from the summary buffer.
885 It will be called with point in the group buffer."
886 :group 'gnus-summary-exit
889 (defcustom gnus-summary-prepare-hook nil
890 "*A hook called after the summary buffer has been generated.
891 If you want to modify the summary buffer, you can use this hook."
892 :group 'gnus-summary-various
895 (defcustom gnus-summary-prepared-hook nil
896 "*A hook called as the last thing after the summary buffer has been generated."
897 :group 'gnus-summary-various
900 (defcustom gnus-summary-generate-hook nil
901 "*A hook run just before generating the summary buffer.
902 This hook is commonly used to customize threading variables and the
904 :group 'gnus-summary-various
907 (defcustom gnus-select-group-hook nil
908 "*A hook called when a newsgroup is selected.
910 If you'd like to simplify subjects like the
911 `gnus-summary-next-same-subject' command does, you can use the
914 (add-hook gnus-select-group-hook
916 (mapcar (lambda (header)
917 (mail-header-set-subject
919 (gnus-simplify-subject
920 (mail-header-subject header) 're-only)))
921 gnus-newsgroup-headers)))"
922 :group 'gnus-group-select
925 (defcustom gnus-select-article-hook nil
926 "*A hook called when an article is selected."
927 :group 'gnus-summary-choose
928 :options '(gnus-agent-fetch-selected-article)
931 (defcustom gnus-visual-mark-article-hook
932 (list 'gnus-highlight-selected-summary)
933 "*Hook run after selecting an article in the summary buffer.
934 It is meant to be used for highlighting the article in some way. It
935 is not run if `gnus-visual' is nil."
936 :group 'gnus-summary-visual
939 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
940 "*A hook called before parsing the headers."
944 (defcustom gnus-exit-group-hook nil
945 "*A hook called when exiting summary mode.
946 This hook is not called from the non-updating exit commands like `Q'."
950 (defcustom gnus-summary-update-hook
951 (list 'gnus-summary-highlight-line)
952 "*A hook called when a summary line is changed.
953 The hook will not be called if `gnus-visual' is nil.
955 The default function `gnus-summary-highlight-line' will
956 highlight the line according to the `gnus-summary-highlight'
958 :group 'gnus-summary-visual
961 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
962 "*A hook called when an article is selected for the first time.
963 The hook is intended to mark an article as read (or unread)
964 automatically when it is selected."
965 :group 'gnus-summary-choose
968 (defcustom gnus-group-no-more-groups-hook nil
969 "*A hook run when returning to group mode having no more (unread) groups."
970 :group 'gnus-group-select
973 (defcustom gnus-ps-print-hook nil
974 "*A hook run before ps-printing something from Gnus."
978 (defcustom gnus-summary-article-move-hook nil
979 "*A hook called after an article is moved, copied, respooled, or crossposted."
984 (defcustom gnus-summary-article-delete-hook nil
985 "*A hook called after an article is deleted."
990 (defcustom gnus-summary-article-expire-hook nil
991 "*A hook called after an article is expired."
996 (defcustom gnus-summary-display-arrow
997 (and (fboundp 'display-graphic-p)
999 "*If non-nil, display an arrow highlighting the current article."
1001 :group 'gnus-summary
1004 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1005 "Face used for highlighting the current article in the summary buffer."
1006 :group 'gnus-summary-visual
1009 (defvar gnus-tmp-downloaded nil)
1011 (defcustom gnus-summary-highlight
1012 '(((eq mark gnus-canceled-mark)
1013 . gnus-summary-cancelled)
1014 ((and uncached (> score default-high))
1015 . gnus-summary-high-undownloaded)
1016 ((and uncached (< score default-low))
1017 . gnus-summary-low-undownloaded)
1019 . gnus-summary-normal-undownloaded)
1020 ((and (> score default-high)
1021 (or (eq mark gnus-dormant-mark)
1022 (eq mark gnus-ticked-mark)))
1023 . gnus-summary-high-ticked)
1024 ((and (< score default-low)
1025 (or (eq mark gnus-dormant-mark)
1026 (eq mark gnus-ticked-mark)))
1027 . gnus-summary-low-ticked)
1028 ((or (eq mark gnus-dormant-mark)
1029 (eq mark gnus-ticked-mark))
1030 . gnus-summary-normal-ticked)
1031 ((and (> score default-high) (eq mark gnus-ancient-mark))
1032 . gnus-summary-high-ancient)
1033 ((and (< score default-low) (eq mark gnus-ancient-mark))
1034 . gnus-summary-low-ancient)
1035 ((eq mark gnus-ancient-mark)
1036 . gnus-summary-normal-ancient)
1037 ((and (> score default-high) (eq mark gnus-unread-mark))
1038 . gnus-summary-high-unread)
1039 ((and (< score default-low) (eq mark gnus-unread-mark))
1040 . gnus-summary-low-unread)
1041 ((eq mark gnus-unread-mark)
1042 . gnus-summary-normal-unread)
1043 ((> score default-high)
1044 . gnus-summary-high-read)
1045 ((< score default-low)
1046 . gnus-summary-low-read)
1048 . gnus-summary-normal-read))
1049 "*Controls the highlighting of summary buffer lines.
1051 A list of (FORM . FACE) pairs. When deciding how a a particular
1052 summary line should be displayed, each form is evaluated. The content
1053 of the face field after the first true form is used. You can change
1054 how those summary lines are displayed, by editing the face field.
1056 You can use the following variables in the FORM field.
1058 score: The article's score
1059 default: The default article score.
1060 default-high: The default score for high scored articles.
1061 default-low: The default score for low scored articles.
1062 below: The score below which articles are automatically marked as read.
1063 mark: The article's mark.
1064 uncached: Non-nil if the article is uncached."
1065 :group 'gnus-summary-visual
1066 :type '(repeat (cons (sexp :tag "Form" nil)
1069 (defcustom gnus-alter-header-function nil
1070 "Function called to allow alteration of article header structures.
1071 The function is called with one parameter, the article header vector,
1072 which it may alter in any way."
1073 :type '(choice (const :tag "None" nil)
1075 :group 'gnus-summary)
1077 (defvar gnus-decode-encoded-word-function
1078 (mime-find-field-decoder 'From 'nov)
1079 "Variable that says which function should be used to decode a string with encoded words.")
1081 (defcustom gnus-extra-headers '(To Newsgroups)
1082 "*Extra headers to parse."
1084 :group 'gnus-summary
1085 :type '(repeat symbol))
1087 (defcustom gnus-ignored-from-addresses
1088 (and user-mail-address
1089 (not (string= user-mail-address ""))
1090 (regexp-quote user-mail-address))
1091 "*Regexp of From headers that may be suppressed in favor of To headers."
1093 :group 'gnus-summary
1096 (defcustom gnus-summary-to-prefix "-> "
1097 "*String prefixed to the To field in the summary line when
1098 using `gnus-ignored-from-addresses'."
1100 :group 'gnus-summary
1103 (defcustom gnus-summary-newsgroup-prefix "=> "
1104 "*String prefixed to the Newsgroup field in the summary
1105 line when using `gnus-ignored-from-addresses'."
1107 :group 'gnus-summary
1110 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1111 "List of charsets that should be ignored.
1112 When these charsets are used in the \"charset\" parameter, the
1113 default charset will be used instead."
1115 :type '(repeat symbol)
1116 :group 'gnus-charset)
1118 (gnus-define-group-parameter
1122 "Return the ignored charsets of GROUP."
1123 :variable gnus-group-ignored-charsets-alist
1125 '(("alt\\.chinese\\.text" iso-8859-1))
1127 "Alist of regexps (to match group names) and charsets that should be ignored.
1128 When these charsets are used in the \"charset\" parameter, the
1129 default charset will be used instead."
1130 :variable-group gnus-charset
1131 :variable-type '(repeat (cons (regexp :tag "Group")
1133 :parameter-type '(choice :tag "Ignored charsets"
1136 :parameter-document "\
1137 List of charsets that should be ignored.
1139 When these charsets are used in the \"charset\" parameter, the
1140 default charset will be used instead.")
1142 (defcustom gnus-group-highlight-words-alist nil
1143 "Alist of group regexps and highlight regexps.
1144 This variable uses the same syntax as `gnus-emphasis-alist'."
1146 :type '(repeat (cons (regexp :tag "Group")
1147 (repeat (list (regexp :tag "Highlight regexp")
1148 (number :tag "Group for entire word" 0)
1149 (number :tag "Group for displayed part" 0)
1151 gnus-emphasis-highlight-words)))))
1152 :group 'gnus-summary-visual)
1154 (defcustom gnus-use-wheel nil
1155 "Use Intelli-mouse on summary movement"
1157 :group 'gnus-summary-maneuvering)
1159 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1160 "Amount to scroll messages by spinning the mouse wheel.
1161 This is actually a cons cell, where the first item is the amount to scroll
1162 on a normal wheel event, and the second is the amount to scroll when the
1163 wheel is moved with the shift key depressed."
1164 :type '(cons (integer :tag "Shift") integer)
1165 :group 'gnus-summary-maneuvering)
1167 (defcustom gnus-wheel-edge-resistance 2
1168 "How hard it should be to change the current article
1169 by moving the mouse over the edge of the article window."
1171 :group 'gnus-summary-maneuvering)
1173 (defcustom gnus-summary-show-article-charset-alist
1175 "Alist of number and charset.
1176 The article will be shown with the charset corresponding to the
1178 For example: ((1 . cn-gb-2312) (2 . big5))."
1180 :type '(repeat (cons (number :tag "Argument" 1)
1181 (symbol :tag "Charset")))
1182 :group 'gnus-charset)
1184 (defcustom gnus-preserve-marks t
1185 "Whether marks are preserved when moving, copying and respooling messages."
1188 :group 'gnus-summary-marks)
1190 (defcustom gnus-alter-articles-to-read-function nil
1191 "Function to be called to alter the list of articles to be selected."
1192 :type '(choice (const nil) function)
1193 :group 'gnus-summary)
1195 (defcustom gnus-orphan-score nil
1196 "*All orphans get this score added. Set in the score file."
1197 :group 'gnus-score-default
1198 :type '(choice (const nil)
1201 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1202 "*A regexp to match MIME parts when saving multiple parts of a
1203 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1204 This regexp will be used by default when prompting the user for which
1205 type of files to save."
1206 :group 'gnus-summary
1209 (defcustom gnus-read-all-available-headers nil
1210 "Whether Gnus should parse all headers made available to it.
1211 This is mostly relevant for slow back ends where the user may
1212 wish to widen the summary buffer to include all headers
1213 that were fetched. Say, for nnultimate groups."
1215 :group 'gnus-summary
1216 :type '(choice boolean regexp))
1218 (defcustom gnus-summary-muttprint-program "muttprint"
1219 "Command (and optional arguments) used to run Muttprint."
1221 :group 'gnus-summary
1224 (defcustom gnus-article-loose-mime t
1225 "If non-nil, don't require MIME-Version header.
1226 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1227 supply the MIME-Version header or deliberately strip it from the mail.
1228 If non-nil (the default), Gnus will treat some articles as MIME
1229 even if the MIME-Version header is missing."
1232 :group 'gnus-article-mime)
1234 (defcustom gnus-article-emulate-mime t
1235 "If non-nil, use MIME emulation for uuencode and the like.
1236 This means that Gnus will search message bodies for text that look
1237 like uuencoded bits, yEncoded bits, and so on, and present that using
1238 the normal Gnus MIME machinery."
1241 :group 'gnus-article-mime)
1243 ;;; Internal variables
1245 (defvar gnus-summary-display-cache nil)
1246 (defvar gnus-article-mime-handles nil)
1247 (defvar gnus-article-decoded-p nil)
1248 (defvar gnus-article-charset nil)
1249 (defvar gnus-article-ignored-charsets nil)
1250 (defvar gnus-scores-exclude-files nil)
1251 (defvar gnus-page-broken nil)
1253 (defvar gnus-original-article nil)
1254 (defvar gnus-article-internal-prepare-hook nil)
1255 (defvar gnus-newsgroup-process-stack nil)
1257 (defvar gnus-thread-indent-array nil)
1258 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1259 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1260 "Function called to sort the articles within a thread after it has been gathered together.")
1262 (defvar gnus-summary-save-parts-type-history nil)
1263 (defvar gnus-summary-save-parts-last-directory nil)
1265 ;; Avoid highlighting in kill files.
1266 (defvar gnus-summary-inhibit-highlight nil)
1267 (defvar gnus-newsgroup-selected-overlay nil)
1268 (defvar gnus-inhibit-limiting nil)
1269 (defvar gnus-newsgroup-adaptive-score-file nil)
1270 (defvar gnus-current-score-file nil)
1271 (defvar gnus-current-move-group nil)
1272 (defvar gnus-current-copy-group nil)
1273 (defvar gnus-current-crosspost-group nil)
1274 (defvar gnus-newsgroup-display nil)
1276 (defvar gnus-newsgroup-dependencies nil)
1277 (defvar gnus-newsgroup-adaptive nil)
1278 (defvar gnus-summary-display-article-function nil)
1279 (defvar gnus-summary-highlight-line-function nil
1280 "Function called after highlighting a summary line.")
1282 (defvar gnus-summary-line-format-alist
1283 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1284 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1285 (?s gnus-tmp-subject-or-nil ?s)
1286 (?n gnus-tmp-name ?s)
1287 (?A (std11-address-string
1288 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1289 (?a (or (std11-full-name-string
1290 (car (mime-entity-read-field gnus-tmp-header 'From)))
1292 (?F gnus-tmp-from ?s)
1293 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1294 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1295 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1296 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1297 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1298 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1299 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1300 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1301 (?L gnus-tmp-lines ?s)
1302 (?O gnus-tmp-downloaded ?c)
1303 (?I gnus-tmp-indentation ?s)
1304 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1305 (?R gnus-tmp-replied ?c)
1306 (?\[ gnus-tmp-opening-bracket ?c)
1307 (?\] gnus-tmp-closing-bracket ?c)
1308 (?\> (make-string gnus-tmp-level ? ) ?s)
1309 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1310 (?i gnus-tmp-score ?d)
1311 (?z gnus-tmp-score-char ?c)
1312 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1313 (?U gnus-tmp-unread ?c)
1314 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1316 (?t (gnus-summary-number-of-articles-in-thread
1317 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1319 (?e (gnus-summary-number-of-articles-in-thread
1320 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1322 (?u gnus-tmp-user-defined ?s)
1323 (?P (gnus-pick-line-number) ?d)
1324 (?B gnus-tmp-thread-tree-header-string ?s)
1325 (user-date (gnus-user-date
1326 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1327 "An alist of format specifications that can appear in summary lines.
1328 These are paired with what variables they correspond with, along with
1329 the type of the variable (string, integer, character, etc).")
1331 (defvar gnus-summary-dummy-line-format-alist
1332 `((?S gnus-tmp-subject ?s)
1333 (?N gnus-tmp-number ?d)
1334 (?u gnus-tmp-user-defined ?s)))
1336 (defvar gnus-summary-mode-line-format-alist
1337 `((?G gnus-tmp-group-name ?s)
1338 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1339 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1340 (?A gnus-tmp-article-number ?d)
1341 (?Z gnus-tmp-unread-and-unselected ?s)
1342 (?V gnus-version ?s)
1343 (?U gnus-tmp-unread-and-unticked ?d)
1344 (?S gnus-tmp-subject ?s)
1345 (?e gnus-tmp-unselected ?d)
1346 (?u gnus-tmp-user-defined ?s)
1347 (?d (length gnus-newsgroup-dormant) ?d)
1348 (?t (length gnus-newsgroup-marked) ?d)
1349 (?h (length gnus-newsgroup-spam-marked) ?d)
1350 (?r (length gnus-newsgroup-reads) ?d)
1351 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1352 (?E gnus-newsgroup-expunged-tally ?d)
1353 (?s (gnus-current-score-file-nondirectory) ?s)))
1355 (defvar gnus-last-search-regexp nil
1356 "Default regexp for article search command.")
1358 (defvar gnus-summary-search-article-matched-data nil
1359 "Last matched data of article search command. It is the local variable
1360 in `gnus-article-buffer' which consists of the list of start position,
1361 end position and text.")
1363 (defvar gnus-last-shell-command nil
1364 "Default shell command on article.")
1366 (defvar gnus-newsgroup-agentized nil
1367 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1368 (defvar gnus-newsgroup-begin nil)
1369 (defvar gnus-newsgroup-end nil)
1370 (defvar gnus-newsgroup-last-rmail nil)
1371 (defvar gnus-newsgroup-last-mail nil)
1372 (defvar gnus-newsgroup-last-folder nil)
1373 (defvar gnus-newsgroup-last-file nil)
1374 (defvar gnus-newsgroup-auto-expire nil)
1375 (defvar gnus-newsgroup-active nil)
1377 (defvar gnus-newsgroup-data nil)
1378 (defvar gnus-newsgroup-data-reverse nil)
1379 (defvar gnus-newsgroup-limit nil)
1380 (defvar gnus-newsgroup-limits nil)
1381 (defvar gnus-summary-use-undownloaded-faces nil)
1383 (defvar gnus-newsgroup-unreads nil
1384 "Sorted list of unread articles in the current newsgroup.")
1386 (defvar gnus-newsgroup-unselected nil
1387 "Sorted list of unselected unread articles in the current newsgroup.")
1389 (defvar gnus-newsgroup-reads nil
1390 "Alist of read articles and article marks in the current newsgroup.")
1392 (defvar gnus-newsgroup-expunged-tally nil)
1394 (defvar gnus-newsgroup-marked nil
1395 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1397 (defvar gnus-newsgroup-spam-marked nil
1398 "List of ranges of articles that have been marked as spam.")
1400 (defvar gnus-newsgroup-killed nil
1401 "List of ranges of articles that have been through the scoring process.")
1403 (defvar gnus-newsgroup-cached nil
1404 "Sorted list of articles that come from the article cache.")
1406 (defvar gnus-newsgroup-saved nil
1407 "List of articles that have been saved.")
1409 (defvar gnus-newsgroup-kill-headers nil)
1411 (defvar gnus-newsgroup-replied nil
1412 "List of articles that have been replied to in the current newsgroup.")
1414 (defvar gnus-newsgroup-forwarded nil
1415 "List of articles that have been forwarded in the current newsgroup.")
1417 (defvar gnus-newsgroup-recent nil
1418 "List of articles that have are recent in the current newsgroup.")
1420 (defvar gnus-newsgroup-expirable nil
1421 "Sorted list of articles in the current newsgroup that can be expired.")
1423 (defvar gnus-newsgroup-processable nil
1424 "List of articles in the current newsgroup that can be processed.")
1426 (defvar gnus-newsgroup-downloadable nil
1427 "Sorted list of articles in the current newsgroup that can be processed.")
1429 (defvar gnus-newsgroup-unfetched nil
1430 "Sorted list of articles in the current newsgroup whose headers have
1431 not been fetched into the agent.
1433 This list will always be a subset of gnus-newsgroup-undownloaded.")
1435 (defvar gnus-newsgroup-undownloaded nil
1436 "List of articles in the current newsgroup that haven't been downloaded.")
1438 (defvar gnus-newsgroup-unsendable nil
1439 "List of articles in the current newsgroup that won't be sent.")
1441 (defvar gnus-newsgroup-bookmarks nil
1442 "List of articles in the current newsgroup that have bookmarks.")
1444 (defvar gnus-newsgroup-dormant nil
1445 "Sorted list of dormant articles in the current newsgroup.")
1447 (defvar gnus-newsgroup-unseen nil
1448 "List of unseen articles in the current newsgroup.")
1450 (defvar gnus-newsgroup-seen nil
1451 "Range of seen articles in the current newsgroup.")
1453 (defvar gnus-newsgroup-articles nil
1454 "List of articles in the current newsgroup.")
1456 (defvar gnus-newsgroup-scored nil
1457 "List of scored articles in the current newsgroup.")
1459 (defvar gnus-newsgroup-incorporated nil
1460 "List of incorporated articles in the current newsgroup.")
1462 (defvar gnus-newsgroup-headers nil
1463 "List of article headers in the current newsgroup.")
1465 (defvar gnus-newsgroup-threads nil)
1467 (defvar gnus-newsgroup-prepared nil
1468 "Whether the current group has been prepared properly.")
1470 (defvar gnus-newsgroup-ancient nil
1471 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1473 (defvar gnus-newsgroup-sparse nil)
1475 (defvar gnus-current-article nil)
1476 (defvar gnus-article-current nil)
1477 (defvar gnus-current-headers nil)
1478 (defvar gnus-have-all-headers nil)
1479 (defvar gnus-last-article nil)
1480 (defvar gnus-newsgroup-history nil)
1481 (defvar gnus-newsgroup-charset nil)
1482 (defvar gnus-newsgroup-ephemeral-charset nil)
1483 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1485 (defvar gnus-article-before-search nil)
1487 (defvar gnus-summary-local-variables
1488 '(gnus-newsgroup-name
1489 gnus-newsgroup-begin gnus-newsgroup-end
1490 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1491 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1492 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1493 gnus-newsgroup-unselected gnus-newsgroup-marked
1494 gnus-newsgroup-spam-marked
1495 gnus-newsgroup-reads gnus-newsgroup-saved
1496 gnus-newsgroup-replied gnus-newsgroup-forwarded
1497 gnus-newsgroup-recent
1498 gnus-newsgroup-expirable
1499 gnus-newsgroup-processable gnus-newsgroup-killed
1500 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1501 gnus-newsgroup-unfetched
1502 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1503 gnus-newsgroup-seen gnus-newsgroup-articles
1504 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1505 gnus-newsgroup-headers gnus-newsgroup-threads
1506 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1507 gnus-current-article gnus-current-headers gnus-have-all-headers
1508 gnus-last-article gnus-article-internal-prepare-hook
1509 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1510 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1511 gnus-thread-expunge-below
1512 gnus-score-alist gnus-current-score-file
1513 (gnus-summary-expunge-below . global)
1514 (gnus-summary-mark-below . global)
1515 (gnus-orphan-score . global)
1516 gnus-newsgroup-active gnus-scores-exclude-files
1517 gnus-newsgroup-history gnus-newsgroup-ancient
1518 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1519 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1520 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1521 (gnus-newsgroup-expunged-tally . 0)
1522 gnus-cache-removable-articles gnus-newsgroup-cached
1523 gnus-newsgroup-data gnus-newsgroup-data-reverse
1524 gnus-newsgroup-limit gnus-newsgroup-limits
1525 gnus-newsgroup-charset gnus-newsgroup-display
1526 gnus-summary-use-undownloaded-faces
1527 gnus-newsgroup-incorporated)
1528 "Variables that are buffer-local to the summary buffers.")
1530 (defvar gnus-newsgroup-variables nil
1531 "A list of variables that have separate values in different newsgroups.
1532 A list of newsgroup (summary buffer) local variables, or cons of
1533 variables and their default expressions to be evalled (when the default
1534 values are not nil), that should be made global while the summary buffer
1537 Note: The default expressions will be evaluated (using function `eval')
1538 before assignment to the local variable rather than just assigned to it.
1539 If the default expression is the symbol `global', that symbol will not
1540 be evaluated but the global value of the local variable will be used
1543 These variables can be used to set variables in the group parameters
1544 while still allowing them to affect operations done in other buffers.
1547 \(setq gnus-newsgroup-variables
1548 '(message-use-followup-to
1549 (gnus-visible-headers .
1550 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1553 ;; Byte-compiler warning.
1555 ;; Bind features so that require will believe that gnus-sum has
1556 ;; already been loaded (avoids infinite recursion)
1557 (let ((features (cons 'gnus-sum features)))
1558 ;; Several of the declarations in gnus-sum are needed to load the
1559 ;; following files. Right now, these definitions have been
1560 ;; compiled but not defined (evaluated). We could either do a
1561 ;; eval-and-compile about all of the declarations or evaluate the
1563 (if (boundp 'gnus-newsgroup-variables)
1565 (load "gnus-sum.el" t t t))
1567 (require 'gnus-art)))
1569 ;; Subject simplification.
1571 (defun gnus-simplify-whitespace (str)
1572 "Remove excessive whitespace from STR."
1574 (while (string-match "[ \t][ \t]+" str)
1575 (setq str (concat (substring str 0 (match-beginning 0))
1577 (substring str (match-end 0)))))
1579 (when (string-match "^[ \t]+" str)
1580 (setq str (substring str (match-end 0))))
1582 (when (string-match "[ \t]+$" str)
1583 (setq str (substring str 0 (match-beginning 0))))
1586 (defun gnus-simplify-all-whitespace (str)
1587 "Remove all whitespace from STR."
1588 (while (string-match "[ \t\n]+" str)
1589 (setq str (replace-match "" nil nil str)))
1592 (defsubst gnus-simplify-subject-re (subject)
1593 "Remove \"Re:\" from subject lines."
1594 (if (string-match message-subject-re-regexp subject)
1595 (substring subject (match-end 0))
1598 (defun gnus-simplify-subject (subject &optional re-only)
1599 "Remove `Re:' and words in parentheses.
1600 If RE-ONLY is non-nil, strip leading `Re:'s only."
1601 (let ((case-fold-search t)) ;Ignore case.
1602 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1603 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1604 (setq subject (substring subject (match-end 0))))
1605 ;; Remove uninteresting prefixes.
1606 (when (and (not re-only)
1607 gnus-simplify-ignored-prefixes
1608 (string-match gnus-simplify-ignored-prefixes subject))
1609 (setq subject (substring subject (match-end 0))))
1610 ;; Remove words in parentheses from end.
1612 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1613 (setq subject (substring subject 0 (match-beginning 0)))))
1614 ;; Return subject string.
1617 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1619 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1620 (goto-char (point-min))
1621 (while (re-search-forward regexp nil t)
1622 (replace-match (or newtext ""))))
1624 (defun gnus-simplify-buffer-fuzzy ()
1625 "Simplify string in the buffer fuzzily.
1626 The string in the accessible portion of the current buffer is simplified.
1627 It is assumed to be a single-line subject.
1628 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1629 matter is removed. Additional things can be deleted by setting
1630 `gnus-simplify-subject-fuzzy-regexp'."
1631 (let ((case-fold-search t)
1633 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1635 (while (not (eq modified-tick (buffer-modified-tick)))
1636 (setq modified-tick (buffer-modified-tick))
1638 ((listp gnus-simplify-subject-fuzzy-regexp)
1639 (mapcar 'gnus-simplify-buffer-fuzzy-step
1640 gnus-simplify-subject-fuzzy-regexp))
1641 (gnus-simplify-subject-fuzzy-regexp
1642 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1643 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1644 (gnus-simplify-buffer-fuzzy-step
1645 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1646 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1648 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1649 (gnus-simplify-buffer-fuzzy-step " +" " ")
1650 (gnus-simplify-buffer-fuzzy-step " $")
1651 (gnus-simplify-buffer-fuzzy-step "^ +")))
1653 (defun gnus-simplify-subject-fuzzy (subject)
1654 "Simplify a subject string fuzzily.
1655 See `gnus-simplify-buffer-fuzzy' for details."
1657 (gnus-set-work-buffer)
1658 (let ((case-fold-search t))
1659 ;; Remove uninteresting prefixes.
1660 (when (and gnus-simplify-ignored-prefixes
1661 (string-match gnus-simplify-ignored-prefixes subject))
1662 (setq subject (substring subject (match-end 0))))
1664 (inline (gnus-simplify-buffer-fuzzy))
1667 (defsubst gnus-simplify-subject-fully (subject)
1668 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1670 (gnus-simplify-subject-functions
1671 (gnus-map-function gnus-simplify-subject-functions subject))
1672 ((null gnus-summary-gather-subject-limit)
1673 (gnus-simplify-subject-re subject))
1674 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1675 (gnus-simplify-subject-fuzzy subject))
1676 ((numberp gnus-summary-gather-subject-limit)
1677 (gnus-limit-string (gnus-simplify-subject-re subject)
1678 gnus-summary-gather-subject-limit))
1682 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1683 "Check whether two subjects are equal.
1684 If optional argument SIMPLE-FIRST is t, first argument is already
1687 ((null simple-first)
1688 (equal (gnus-simplify-subject-fully s1)
1689 (gnus-simplify-subject-fully s2)))
1692 (gnus-simplify-subject-fully s2)))))
1694 (defun gnus-summary-bubble-group ()
1695 "Increase the score of the current group.
1696 This is a handy function to add to `gnus-summary-exit-hook' to
1697 increase the score of each group you read."
1698 (gnus-group-add-score gnus-newsgroup-name))
1702 ;;; Gnus summary mode
1705 (put 'gnus-summary-mode 'mode-class 'special)
1707 (defvar gnus-article-commands-menu)
1709 ;; Non-orthogonal keys
1711 (gnus-define-keys gnus-summary-mode-map
1712 " " gnus-summary-next-page
1713 "\177" gnus-summary-prev-page
1714 [delete] gnus-summary-prev-page
1715 [backspace] gnus-summary-prev-page
1716 "\r" gnus-summary-scroll-up
1717 "\M-\r" gnus-summary-scroll-down
1718 "n" gnus-summary-next-unread-article
1719 "p" gnus-summary-prev-unread-article
1720 "N" gnus-summary-next-article
1721 "P" gnus-summary-prev-article
1722 "\M-\C-n" gnus-summary-next-same-subject
1723 "\M-\C-p" gnus-summary-prev-same-subject
1724 "\M-n" gnus-summary-next-unread-subject
1725 "\M-p" gnus-summary-prev-unread-subject
1726 "." gnus-summary-first-unread-article
1727 "," gnus-summary-best-unread-article
1728 "\M-s" gnus-summary-search-article-forward
1729 "\M-r" gnus-summary-search-article-backward
1730 "<" gnus-summary-beginning-of-article
1731 ">" gnus-summary-end-of-article
1732 "j" gnus-summary-goto-article
1733 "^" gnus-summary-refer-parent-article
1734 "\M-^" gnus-summary-refer-article
1735 "u" gnus-summary-tick-article-forward
1736 "!" gnus-summary-tick-article-forward
1737 "U" gnus-summary-tick-article-backward
1738 "d" gnus-summary-mark-as-read-forward
1739 "D" gnus-summary-mark-as-read-backward
1740 "E" gnus-summary-mark-as-expirable
1741 "\M-u" gnus-summary-clear-mark-forward
1742 "\M-U" gnus-summary-clear-mark-backward
1743 "k" gnus-summary-kill-same-subject-and-select
1744 "\C-k" gnus-summary-kill-same-subject
1745 "\M-\C-k" gnus-summary-kill-thread
1746 "\M-\C-l" gnus-summary-lower-thread
1747 "e" gnus-summary-edit-article
1748 "#" gnus-summary-mark-as-processable
1749 "\M-#" gnus-summary-unmark-as-processable
1750 "\M-\C-t" gnus-summary-toggle-threads
1751 "\M-\C-s" gnus-summary-show-thread
1752 "\M-\C-h" gnus-summary-hide-thread
1753 "\M-\C-f" gnus-summary-next-thread
1754 "\M-\C-b" gnus-summary-prev-thread
1755 [(meta down)] gnus-summary-next-thread
1756 [(meta up)] gnus-summary-prev-thread
1757 "\M-\C-u" gnus-summary-up-thread
1758 "\M-\C-d" gnus-summary-down-thread
1759 "&" gnus-summary-execute-command
1760 "c" gnus-summary-catchup-and-exit
1761 "\C-w" gnus-summary-mark-region-as-read
1762 "\C-t" gnus-summary-toggle-truncation
1763 "?" gnus-summary-mark-as-dormant
1764 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1765 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1766 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1767 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1768 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1769 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1770 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1771 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1772 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1773 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1774 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1775 "=" gnus-summary-expand-window
1776 "\C-x\C-s" gnus-summary-reselect-current-group
1777 "\M-g" gnus-summary-rescan-group
1778 "w" gnus-summary-stop-page-breaking
1779 "\C-c\C-r" gnus-summary-caesar-message
1780 "\M-t" gnus-summary-toggle-mime
1781 "f" gnus-summary-followup
1782 "F" gnus-summary-followup-with-original
1783 "C" gnus-summary-cancel-article
1784 "r" gnus-summary-reply
1785 "R" gnus-summary-reply-with-original
1786 "\C-c\C-f" gnus-summary-mail-forward
1787 "o" gnus-summary-save-article
1788 "\C-o" gnus-summary-save-article-mail
1789 "|" gnus-summary-pipe-output
1790 "\M-k" gnus-summary-edit-local-kill
1791 "\M-K" gnus-summary-edit-global-kill
1793 "\C-c\C-d" gnus-summary-describe-group
1794 "q" gnus-summary-exit
1795 "Q" gnus-summary-exit-no-update
1796 "\C-c\C-i" gnus-info-find-node
1797 gnus-mouse-2 gnus-mouse-pick-article
1798 [follow-link] mouse-face
1799 "m" gnus-summary-mail-other-window
1800 "a" gnus-summary-post-news
1801 "i" gnus-summary-news-other-window
1802 "x" gnus-summary-limit-to-unread
1803 "s" gnus-summary-isearch-article
1804 "t" gnus-summary-toggle-header
1805 "g" gnus-summary-show-article
1806 "l" gnus-summary-goto-last-article
1807 "v" gnus-summary-preview-mime-message
1808 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1809 "\C-d" gnus-summary-enter-digest-group
1810 "\M-\C-d" gnus-summary-read-document
1811 "\M-\C-e" gnus-summary-edit-parameters
1812 "\M-\C-a" gnus-summary-customize-parameters
1814 "\C-c\C-n" gnus-namazu-search
1815 "*" gnus-cache-enter-article
1816 "\M-*" gnus-cache-remove-article
1817 "\M-&" gnus-summary-universal-argument
1818 "\C-l" gnus-recenter
1819 "I" gnus-summary-increase-score
1820 "L" gnus-summary-lower-score
1821 "\M-i" gnus-symbolic-argument
1822 "h" gnus-summary-select-article-buffer
1824 "V" gnus-summary-score-map
1825 "X" gnus-uu-extract-map
1826 "S" gnus-summary-send-map)
1828 ;; Sort of orthogonal keymap
1829 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1830 "t" gnus-summary-tick-article-forward
1831 "!" gnus-summary-tick-article-forward
1832 "d" gnus-summary-mark-as-read-forward
1833 "r" gnus-summary-mark-as-read-forward
1834 "c" gnus-summary-clear-mark-forward
1835 " " gnus-summary-clear-mark-forward
1836 "e" gnus-summary-mark-as-expirable
1837 "x" gnus-summary-mark-as-expirable
1838 "?" gnus-summary-mark-as-dormant
1839 "b" gnus-summary-set-bookmark
1840 "B" gnus-summary-remove-bookmark
1841 "#" gnus-summary-mark-as-processable
1842 "\M-#" gnus-summary-unmark-as-processable
1843 "S" gnus-summary-limit-include-expunged
1844 "C" gnus-summary-catchup
1845 "H" gnus-summary-catchup-to-here
1846 "h" gnus-summary-catchup-from-here
1847 "\C-c" gnus-summary-catchup-all
1848 "k" gnus-summary-kill-same-subject-and-select
1849 "K" gnus-summary-kill-same-subject
1850 "P" gnus-uu-mark-map)
1852 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1853 "c" gnus-summary-clear-above
1854 "u" gnus-summary-tick-above
1855 "m" gnus-summary-mark-above
1856 "k" gnus-summary-kill-below)
1858 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1859 "/" gnus-summary-limit-to-subject
1860 "n" gnus-summary-limit-to-articles
1861 "w" gnus-summary-pop-limit
1862 "s" gnus-summary-limit-to-subject
1863 "a" gnus-summary-limit-to-author
1864 "u" gnus-summary-limit-to-unread
1865 "m" gnus-summary-limit-to-marks
1866 "M" gnus-summary-limit-exclude-marks
1867 "v" gnus-summary-limit-to-score
1868 "*" gnus-summary-limit-include-cached
1869 "D" gnus-summary-limit-include-dormant
1870 "T" gnus-summary-limit-include-thread
1871 "d" gnus-summary-limit-exclude-dormant
1872 "t" gnus-summary-limit-to-age
1873 "." gnus-summary-limit-to-unseen
1874 "x" gnus-summary-limit-to-extra
1875 "p" gnus-summary-limit-to-display-predicate
1876 "E" gnus-summary-limit-include-expunged
1877 "c" gnus-summary-limit-exclude-childless-dormant
1878 "C" gnus-summary-limit-mark-excluded-as-read
1879 "o" gnus-summary-insert-old-articles
1880 "N" gnus-summary-insert-new-articles
1881 "r" gnus-summary-limit-to-replied
1882 "R" gnus-summary-limit-to-recipient)
1884 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1885 "n" gnus-summary-next-unread-article
1886 "p" gnus-summary-prev-unread-article
1887 "N" gnus-summary-next-article
1888 "P" gnus-summary-prev-article
1889 "\C-n" gnus-summary-next-same-subject
1890 "\C-p" gnus-summary-prev-same-subject
1891 "\M-n" gnus-summary-next-unread-subject
1892 "\M-p" gnus-summary-prev-unread-subject
1893 "f" gnus-summary-first-unread-article
1894 "b" gnus-summary-best-unread-article
1895 "j" gnus-summary-goto-article
1896 "g" gnus-summary-goto-subject
1897 "l" gnus-summary-goto-last-article
1898 "o" gnus-summary-pop-article)
1900 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1901 "k" gnus-summary-kill-thread
1902 "l" gnus-summary-lower-thread
1903 "i" gnus-summary-raise-thread
1904 "T" gnus-summary-toggle-threads
1905 "t" gnus-summary-rethread-current
1906 "^" gnus-summary-reparent-thread
1907 "s" gnus-summary-show-thread
1908 "S" gnus-summary-show-all-threads
1909 "h" gnus-summary-hide-thread
1910 "H" gnus-summary-hide-all-threads
1911 "n" gnus-summary-next-thread
1912 "p" gnus-summary-prev-thread
1913 "u" gnus-summary-up-thread
1914 "o" gnus-summary-top-thread
1915 "d" gnus-summary-down-thread
1916 "#" gnus-uu-mark-thread
1917 "\M-#" gnus-uu-unmark-thread)
1919 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1920 "g" gnus-summary-prepare
1921 "c" gnus-summary-insert-cached-articles
1922 "d" gnus-summary-insert-dormant-articles)
1924 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1925 "c" gnus-summary-catchup-and-exit
1926 "C" gnus-summary-catchup-all-and-exit
1927 "E" gnus-summary-exit-no-update
1928 "J" gnus-summary-jump-to-other-group
1929 "Q" gnus-summary-exit
1930 "Z" gnus-summary-exit
1931 "n" gnus-summary-catchup-and-goto-next-group
1932 "p" gnus-summary-catchup-and-goto-prev-group
1933 "R" gnus-summary-reselect-current-group
1934 "G" gnus-summary-rescan-group
1935 "N" gnus-summary-next-group
1936 "s" gnus-summary-save-newsrc
1937 "P" gnus-summary-prev-group)
1939 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1940 " " gnus-summary-next-page
1941 "n" gnus-summary-next-page
1942 "\177" gnus-summary-prev-page
1943 [delete] gnus-summary-prev-page
1944 "p" gnus-summary-prev-page
1945 "\r" gnus-summary-scroll-up
1946 "\M-\r" gnus-summary-scroll-down
1947 "<" gnus-summary-beginning-of-article
1948 ">" gnus-summary-end-of-article
1949 "b" gnus-summary-beginning-of-article
1950 "e" gnus-summary-end-of-article
1951 "^" gnus-summary-refer-parent-article
1952 "r" gnus-summary-refer-parent-article
1953 "D" gnus-summary-enter-digest-group
1954 "R" gnus-summary-refer-references
1955 "T" gnus-summary-refer-thread
1956 "g" gnus-summary-show-article
1957 "s" gnus-summary-isearch-article
1958 "P" gnus-summary-print-article
1959 "M" gnus-mailing-list-insinuate
1960 "t" gnus-article-babel)
1962 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1963 "b" gnus-article-add-buttons
1964 "B" gnus-article-add-buttons-to-head
1965 "o" gnus-article-treat-overstrike
1966 "e" gnus-article-emphasize
1967 "w" gnus-article-fill-cited-article
1968 "Q" gnus-article-fill-long-lines
1969 "C" gnus-article-capitalize-sentences
1970 "c" gnus-article-remove-cr
1971 "Z" gnus-article-decode-HZ
1972 "A" gnus-article-treat-ansi-sequences
1973 "h" gnus-article-wash-html
1974 "u" gnus-article-unsplit-urls
1975 "f" gnus-article-display-x-face
1976 "l" gnus-summary-stop-page-breaking
1977 "r" gnus-summary-caesar-message
1978 "m" gnus-summary-morse-message
1979 "t" gnus-summary-toggle-header
1980 "g" gnus-treat-smiley
1981 "v" gnus-summary-verbose-headers
1982 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1983 "p" gnus-article-verify-x-pgp-sig
1984 "d" gnus-article-treat-dumbquotes
1985 "i" gnus-summary-idna-message)
1987 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1988 ;; mnemonic: deuglif*Y*
1989 "u" gnus-article-outlook-unwrap-lines
1990 "a" gnus-article-outlook-repair-attribution
1991 "c" gnus-article-outlook-rearrange-citation
1992 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1994 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1995 "a" gnus-article-hide
1996 "h" gnus-article-hide-headers
1997 "b" gnus-article-hide-boring-headers
1998 "s" gnus-article-hide-signature
1999 "c" gnus-article-hide-citation
2000 "C" gnus-article-hide-citation-in-followups
2001 "l" gnus-article-hide-list-identifiers
2002 "B" gnus-article-strip-banner
2003 "P" gnus-article-hide-pem
2004 "\C-c" gnus-article-hide-citation-maybe)
2006 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2007 "a" gnus-article-highlight
2008 "h" gnus-article-highlight-headers
2009 "c" gnus-article-highlight-citation
2010 "s" gnus-article-highlight-signature)
2012 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2013 "f" gnus-article-treat-fold-headers
2014 "u" gnus-article-treat-unfold-headers
2015 "n" gnus-article-treat-fold-newsgroups)
2017 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2018 "x" gnus-article-display-x-face
2019 "d" gnus-article-display-face
2020 "s" gnus-treat-smiley
2021 "D" gnus-article-remove-images
2022 "f" gnus-treat-from-picon
2023 "m" gnus-treat-mail-picon
2024 "n" gnus-treat-newsgroups-picon)
2026 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2027 "z" gnus-article-date-ut
2028 "u" gnus-article-date-ut
2029 "l" gnus-article-date-local
2030 "p" gnus-article-date-english
2031 "e" gnus-article-date-lapsed
2032 "o" gnus-article-date-original
2033 "i" gnus-article-date-iso8601
2034 "s" gnus-article-date-user)
2036 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2037 "t" gnus-article-remove-trailing-blank-lines
2038 "l" gnus-article-strip-leading-blank-lines
2039 "m" gnus-article-strip-multiple-blank-lines
2040 "a" gnus-article-strip-blank-lines
2041 "A" gnus-article-strip-all-blank-lines
2042 "s" gnus-article-strip-leading-space
2043 "e" gnus-article-strip-trailing-space
2044 "w" gnus-article-remove-leading-whitespace)
2046 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2048 "f" gnus-summary-fetch-faq
2049 "d" gnus-summary-describe-group
2050 "h" gnus-summary-describe-briefly
2051 "i" gnus-info-find-node
2052 "c" gnus-group-fetch-charter
2053 "C" gnus-group-fetch-control)
2055 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2056 "e" gnus-summary-expire-articles
2057 "\M-\C-e" gnus-summary-expire-articles-now
2058 "\177" gnus-summary-delete-article
2059 [delete] gnus-summary-delete-article
2060 [backspace] gnus-summary-delete-article
2061 "m" gnus-summary-move-article
2062 "r" gnus-summary-respool-article
2063 "w" gnus-summary-edit-article
2064 "c" gnus-summary-copy-article
2065 "B" gnus-summary-crosspost-article
2066 "q" gnus-summary-respool-query
2067 "t" gnus-summary-respool-trace
2068 "i" gnus-summary-import-article
2069 "I" gnus-summary-create-article
2070 "p" gnus-summary-article-posted-p)
2072 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2073 "o" gnus-summary-save-article
2074 "m" gnus-summary-save-article-mail
2075 "F" gnus-summary-write-article-file
2076 "r" gnus-summary-save-article-rmail
2077 "f" gnus-summary-save-article-file
2078 "b" gnus-summary-save-article-body-file
2079 "h" gnus-summary-save-article-folder
2080 "v" gnus-summary-save-article-vm
2081 "p" gnus-summary-pipe-output
2082 "P" gnus-summary-muttprint
2083 "s" gnus-soup-add-article)
2085 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2086 "b" gnus-summary-display-buttonized
2087 "m" gnus-summary-repair-multipart
2088 "v" gnus-article-view-part
2089 "o" gnus-article-save-part
2090 "O" gnus-article-save-part-and-strip
2091 "r" gnus-article-replace-part
2092 "d" gnus-article-delete-part
2093 "j" gnus-article-jump-to-part
2094 "c" gnus-article-copy-part
2095 "C" gnus-article-view-part-as-charset
2096 "e" gnus-article-view-part-externally
2097 "E" gnus-article-encrypt-body
2098 "i" gnus-article-inline-part
2099 "|" gnus-article-pipe-part)
2101 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2102 "p" gnus-summary-mark-as-processable
2103 "u" gnus-summary-unmark-as-processable
2104 "U" gnus-summary-unmark-all-processable
2105 "v" gnus-uu-mark-over
2106 "s" gnus-uu-mark-series
2107 "r" gnus-uu-mark-region
2108 "g" gnus-uu-unmark-region
2109 "R" gnus-uu-mark-by-regexp
2110 "G" gnus-uu-unmark-by-regexp
2111 "t" gnus-uu-mark-thread
2112 "T" gnus-uu-unmark-thread
2113 "a" gnus-uu-mark-all
2114 "b" gnus-uu-mark-buffer
2115 "S" gnus-uu-mark-sparse
2116 "k" gnus-summary-kill-process-mark
2117 "y" gnus-summary-yank-process-mark
2118 "w" gnus-summary-save-process-mark
2119 "i" gnus-uu-invert-processable)
2121 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2122 ;;"x" gnus-uu-extract-any
2123 "m" gnus-summary-save-parts
2124 "u" gnus-uu-decode-uu
2125 "U" gnus-uu-decode-uu-and-save
2126 "s" gnus-uu-decode-unshar
2127 "S" gnus-uu-decode-unshar-and-save
2128 "o" gnus-uu-decode-save
2129 "O" gnus-uu-decode-save
2130 "b" gnus-uu-decode-binhex
2131 "B" gnus-uu-decode-binhex
2132 "p" gnus-uu-decode-postscript
2133 "P" gnus-uu-decode-postscript-and-save)
2136 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2137 "u" gnus-uu-decode-uu-view
2138 "U" gnus-uu-decode-uu-and-save-view
2139 "s" gnus-uu-decode-unshar-view
2140 "S" gnus-uu-decode-unshar-and-save-view
2141 "o" gnus-uu-decode-save-view
2142 "O" gnus-uu-decode-save-view
2143 "b" gnus-uu-decode-binhex-view
2144 "B" gnus-uu-decode-binhex-view
2145 "p" gnus-uu-decode-postscript-view
2146 "P" gnus-uu-decode-postscript-and-save-view)
2148 (defvar gnus-article-post-menu nil)
2150 (defconst gnus-summary-menu-maxlen 20)
2152 (defun gnus-summary-menu-split (menu)
2153 ;; If we have lots of elements, divide them into groups of 20
2154 ;; and make a pane (or submenu) for each one.
2155 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2156 (let ((menu menu) sublists next
2159 ;; Pull off the next gnus-summary-menu-maxlen elements
2160 ;; and make them the next element of sublist.
2161 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2163 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2165 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2166 (aref (car (last menu)) 0)) menu)
2170 (nreverse sublists))
2171 ;; Few elements--put them all in one pane.
2174 (defun gnus-summary-make-menu-bar ()
2175 (gnus-turn-off-edit-menu 'summary)
2177 (unless (boundp 'gnus-summary-misc-menu)
2180 gnus-summary-kill-menu gnus-summary-mode-map ""
2185 ["Customize" gnus-score-customize t])
2186 (gnus-make-score-map 'increase)
2187 (gnus-make-score-map 'lower)
2189 ["Kill below" gnus-summary-kill-below t]
2190 ["Mark above" gnus-summary-mark-above t]
2191 ["Tick above" gnus-summary-tick-above t]
2192 ["Clear above" gnus-summary-clear-above t])
2193 ["Current score" gnus-summary-current-score t]
2194 ["Set score" gnus-summary-set-score t]
2195 ["Switch current score file..." gnus-score-change-score-file t]
2196 ["Set mark below..." gnus-score-set-mark-below t]
2197 ["Set expunge below..." gnus-score-set-expunge-below t]
2198 ["Edit current score file" gnus-score-edit-current-scores t]
2199 ["Edit score file" gnus-score-edit-file t]
2200 ["Trace score" gnus-score-find-trace t]
2201 ["Find words" gnus-score-find-favourite-words t]
2202 ["Rescore buffer" gnus-summary-rescore t]
2203 ["Increase score..." gnus-summary-increase-score t]
2204 ["Lower score..." gnus-summary-lower-score t]))))
2206 ;; Define both the Article menu in the summary buffer and the
2207 ;; equivalent Commands menu in the article buffer here for
2211 ["All" gnus-article-hide t]
2212 ["Headers" gnus-article-hide-headers t]
2213 ["Signature" gnus-article-hide-signature t]
2214 ["Citation" gnus-article-hide-citation t]
2215 ["List identifiers" gnus-article-hide-list-identifiers t]
2216 ["Banner" gnus-article-strip-banner t]
2217 ["Boring headers" gnus-article-hide-boring-headers t])
2219 ["All" gnus-article-highlight t]
2220 ["Headers" gnus-article-highlight-headers t]
2221 ["Signature" gnus-article-highlight-signature t]
2222 ["Citation" gnus-article-highlight-citation t])
2224 ["Local" gnus-article-date-local t]
2225 ["ISO8601" gnus-article-date-iso8601 t]
2226 ["UT" gnus-article-date-ut t]
2227 ["Original" gnus-article-date-original t]
2228 ["Lapsed" gnus-article-date-lapsed t]
2229 ["User-defined" gnus-article-date-user t])
2231 ["Remove images" gnus-article-remove-images t]
2232 ["Toggle smiley" gnus-treat-smiley t]
2233 ["Show X-Face" gnus-article-display-x-face t]
2234 ["Show picons in From" gnus-treat-from-picon t]
2235 ["Show picons in mail headers" gnus-treat-mail-picon t]
2236 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2237 ("View as different encoding"
2238 ,@(gnus-summary-menu-split
2241 ;; Since easymenu under Emacs doesn't allow
2242 ;; lambda forms for menu commands, we should
2243 ;; provide intern'ed function symbols.
2244 (let ((command (intern (format "\
2245 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2249 (let ((gnus-summary-show-article-charset-alist
2251 (gnus-summary-show-article 1))))
2252 `[,(symbol-name cs) ,command t]))
2253 (sort (if (fboundp 'coding-system-list)
2254 (coding-system-list)
2255 ;;(mapcar 'car mm-mime-mule-charset-alist)
2260 ["Leading" gnus-article-strip-leading-blank-lines t]
2261 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2262 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2263 ["All of the above" gnus-article-strip-blank-lines t]
2264 ["All" gnus-article-strip-all-blank-lines t]
2265 ["Leading space" gnus-article-strip-leading-space t]
2266 ["Trailing space" gnus-article-strip-trailing-space t]
2267 ["Leading space in headers"
2268 gnus-article-remove-leading-whitespace t])
2269 ["Overstrike" gnus-article-treat-overstrike t]
2270 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2271 ["Emphasis" gnus-article-emphasize t]
2272 ["Word wrap" gnus-article-fill-cited-article t]
2273 ["Fill long lines" gnus-article-fill-long-lines t]
2274 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2275 ["Remove CR" gnus-article-remove-cr t]
2276 ["Rot 13" gnus-summary-caesar-message
2277 ,@(if (featurep 'xemacs) '(t)
2278 '(:help "\"Caesar rotate\" article by 13"))]
2279 ["De-IDNA" gnus-summary-idna-message t]
2280 ["Morse decode" gnus-summary-morse-message t]
2281 ["Unix pipe..." gnus-summary-pipe-message t]
2282 ["Add buttons" gnus-article-add-buttons t]
2283 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2284 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2285 ["Toggle MIME" gnus-summary-toggle-mime t]
2286 ["Verbose header" gnus-summary-verbose-headers t]
2287 ["Toggle header" gnus-summary-toggle-header t]
2288 ["Unfold headers" gnus-article-treat-unfold-headers t]
2289 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2290 ["Html" gnus-article-wash-html t]
2291 ["Unsplit URLs" gnus-article-unsplit-urls t]
2292 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2293 ["Decode HZ" gnus-article-decode-HZ t]
2294 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2295 ("(Outlook) Deuglify"
2296 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2297 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2298 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2299 ["Full (Outlook) deuglify"
2300 gnus-article-outlook-deuglify-article t])
2303 ["Save in default format..." gnus-summary-save-article
2304 ,@(if (featurep 'xemacs) '(t)
2305 '(:help "Save article using default method"))]
2306 ["Save in file..." gnus-summary-save-article-file
2307 ,@(if (featurep 'xemacs) '(t)
2308 '(:help "Save article in file"))]
2309 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2310 ["Save in MH folder..." gnus-summary-save-article-folder t]
2311 ["Save in VM folder..." gnus-summary-save-article-vm t]
2312 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2313 ["Save body in file..." gnus-summary-save-article-body-file t]
2314 ["Pipe through a filter..." gnus-summary-pipe-output t]
2315 ["Add to SOUP packet" gnus-soup-add-article t]
2316 ["Print with Muttprint..." gnus-summary-muttprint t]
2317 ["Print" gnus-summary-print-article
2318 ,@(if (featurep 'xemacs) '(t)
2319 '(:help "Generate and print a PostScript image"))])
2320 ("Copy, move,... (Backend)"
2321 ,@(if (featurep 'xemacs) nil
2322 '(:help "Copying, moving, expiring articles..."))
2323 ["Respool article..." gnus-summary-respool-article t]
2324 ["Move article..." gnus-summary-move-article
2325 (gnus-check-backend-function
2326 'request-move-article gnus-newsgroup-name)]
2327 ["Copy article..." gnus-summary-copy-article t]
2328 ["Crosspost article..." gnus-summary-crosspost-article
2329 (gnus-check-backend-function
2330 'request-replace-article gnus-newsgroup-name)]
2331 ["Import file..." gnus-summary-import-article
2332 (gnus-check-backend-function
2333 'request-accept-article gnus-newsgroup-name)]
2334 ["Create article..." gnus-summary-create-article
2335 (gnus-check-backend-function
2336 'request-accept-article gnus-newsgroup-name)]
2337 ["Check if posted" gnus-summary-article-posted-p t]
2338 ["Edit article" gnus-summary-edit-article
2339 (not (gnus-group-read-only-p))]
2340 ["Delete article" gnus-summary-delete-article
2341 (gnus-check-backend-function
2342 'request-expire-articles gnus-newsgroup-name)]
2343 ["Query respool" gnus-summary-respool-query t]
2344 ["Trace respool" gnus-summary-respool-trace t]
2345 ["Delete expirable articles" gnus-summary-expire-articles-now
2346 (gnus-check-backend-function
2347 'request-expire-articles gnus-newsgroup-name)])
2349 ["Uudecode" gnus-uu-decode-uu
2350 ,@(if (featurep 'xemacs) '(t)
2351 '(:help "Decode uuencoded article(s)"))]
2352 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2353 ["Unshar" gnus-uu-decode-unshar t]
2354 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2355 ["Save" gnus-uu-decode-save t]
2356 ["Binhex" gnus-uu-decode-binhex t]
2357 ["Postscript" gnus-uu-decode-postscript t])
2359 ["Enter article" gnus-cache-enter-article t]
2360 ["Remove article" gnus-cache-remove-article t])
2361 ["Translate" gnus-article-babel t]
2362 ["Select article buffer" gnus-summary-select-article-buffer t]
2363 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2364 ["Isearch article..." gnus-summary-isearch-article t]
2365 ["Beginning of the article" gnus-summary-beginning-of-article t]
2366 ["End of the article" gnus-summary-end-of-article t]
2367 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2368 ["Fetch referenced articles" gnus-summary-refer-references t]
2369 ["Fetch current thread" gnus-summary-refer-thread t]
2370 ["Fetch article with id..." gnus-summary-refer-article t]
2371 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2372 ["Redisplay" gnus-summary-show-article t]
2373 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2375 gnus-summary-article-menu gnus-summary-mode-map ""
2376 (cons "Article" innards))
2378 (if (not (keymapp gnus-summary-article-menu))
2380 gnus-article-commands-menu gnus-article-mode-map ""
2381 (cons "Commands" innards))
2382 ;; in Emacs, don't share menu.
2383 (setq gnus-article-commands-menu
2384 (copy-keymap gnus-summary-article-menu))
2385 (define-key gnus-article-mode-map [menu-bar commands]
2386 (cons "Commands" gnus-article-commands-menu))))
2389 gnus-summary-thread-menu gnus-summary-mode-map ""
2391 ["Find all messages in thread" gnus-summary-refer-thread t]
2392 ["Toggle threading" gnus-summary-toggle-threads t]
2393 ["Hide threads" gnus-summary-hide-all-threads t]
2394 ["Show threads" gnus-summary-show-all-threads t]
2395 ["Hide thread" gnus-summary-hide-thread t]
2396 ["Show thread" gnus-summary-show-thread t]
2397 ["Go to next thread" gnus-summary-next-thread t]
2398 ["Go to previous thread" gnus-summary-prev-thread t]
2399 ["Go down thread" gnus-summary-down-thread t]
2400 ["Go up thread" gnus-summary-up-thread t]
2401 ["Top of thread" gnus-summary-top-thread t]
2402 ["Mark thread as read" gnus-summary-kill-thread t]
2403 ["Lower thread score" gnus-summary-lower-thread t]
2404 ["Raise thread score" gnus-summary-raise-thread t]
2405 ["Rethread current" gnus-summary-rethread-current t]))
2408 gnus-summary-post-menu gnus-summary-mode-map ""
2410 ["Send a message (mail or news)" gnus-summary-post-news
2411 ,@(if (featurep 'xemacs) '(t)
2412 '(:help "Compose a new message (mail or news)"))]
2413 ["Followup" gnus-summary-followup
2414 ,@(if (featurep 'xemacs) '(t)
2415 '(:help "Post followup to this article"))]
2416 ["Followup and yank" gnus-summary-followup-with-original
2417 ,@(if (featurep 'xemacs) '(t)
2418 '(:help "Post followup to this article, quoting its contents"))]
2419 ["Supersede article" gnus-summary-supersede-article t]
2420 ["Cancel article" gnus-summary-cancel-article
2421 ,@(if (featurep 'xemacs) '(t)
2422 '(:help "Cancel an article you posted"))]
2423 ["Reply" gnus-summary-reply t]
2424 ["Reply and yank" gnus-summary-reply-with-original t]
2425 ["Wide reply" gnus-summary-wide-reply t]
2426 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2427 ,@(if (featurep 'xemacs) '(t)
2428 '(:help "Mail a reply, quoting this article"))]
2429 ["Very wide reply" gnus-summary-very-wide-reply t]
2430 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2431 ,@(if (featurep 'xemacs) '(t)
2432 '(:help "Mail a very wide reply, quoting this article"))]
2433 ["Mail forward" gnus-summary-mail-forward t]
2434 ["Post forward" gnus-summary-post-forward t]
2435 ["Digest and mail" gnus-summary-digest-mail-forward t]
2436 ["Digest and post" gnus-summary-digest-post-forward t]
2437 ["Resend message" gnus-summary-resend-message t]
2438 ["Resend message edit" gnus-summary-resend-message-edit t]
2439 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2440 ["Send a mail" gnus-summary-mail-other-window t]
2441 ["Create a local message" gnus-summary-news-other-window t]
2442 ["Uuencode and post" gnus-uu-post-news
2443 ,@(if (featurep 'xemacs) '(t)
2444 '(:help "Post a uuencoded article"))]
2445 ["Followup via news" gnus-summary-followup-to-mail t]
2446 ["Followup via news and yank"
2447 gnus-summary-followup-to-mail-with-original t]
2449 ;;["Send" gnus-summary-send-draft t]
2450 ;;["Send bounced" gnus-resend-bounced-mail t])
2454 ((not (keymapp gnus-summary-post-menu))
2455 (setq gnus-article-post-menu gnus-summary-post-menu))
2456 ((not gnus-article-post-menu)
2457 ;; Don't share post menu.
2458 (setq gnus-article-post-menu
2459 (copy-keymap gnus-summary-post-menu))))
2460 (define-key gnus-article-mode-map [menu-bar post]
2461 (cons "Post" gnus-article-post-menu))
2464 gnus-summary-misc-menu gnus-summary-mode-map ""
2467 ["Mark as read" gnus-summary-mark-as-read-forward t]
2468 ["Mark same subject and select"
2469 gnus-summary-kill-same-subject-and-select t]
2470 ["Mark same subject" gnus-summary-kill-same-subject t]
2471 ["Catchup" gnus-summary-catchup
2472 ,@(if (featurep 'xemacs) '(t)
2473 '(:help "Mark unread articles in this group as read"))]
2474 ["Catchup all" gnus-summary-catchup-all t]
2475 ["Catchup to here" gnus-summary-catchup-to-here t]
2476 ["Catchup from here" gnus-summary-catchup-from-here t]
2477 ["Catchup region" gnus-summary-mark-region-as-read
2478 (gnus-mark-active-p)]
2479 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2481 ["Tick" gnus-summary-tick-article-forward t]
2482 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2483 ["Remove marks" gnus-summary-clear-mark-forward t]
2484 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2485 ["Set bookmark" gnus-summary-set-bookmark t]
2486 ["Remove bookmark" gnus-summary-remove-bookmark t])
2488 ["Marks..." gnus-summary-limit-to-marks t]
2489 ["Subject..." gnus-summary-limit-to-subject t]
2490 ["Author..." gnus-summary-limit-to-author t]
2491 ["Recipient..." gnus-summary-limit-to-recipient t]
2492 ["Age..." gnus-summary-limit-to-age t]
2493 ["Extra..." gnus-summary-limit-to-extra t]
2494 ["Score..." gnus-summary-limit-to-score t]
2495 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2496 ["Unread" gnus-summary-limit-to-unread t]
2497 ["Unseen" gnus-summary-limit-to-unseen t]
2498 ["Replied" gnus-summary-limit-to-replied t]
2499 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2500 ["Next articles" gnus-summary-limit-to-articles t]
2501 ["Pop limit" gnus-summary-pop-limit t]
2502 ["Show dormant" gnus-summary-limit-include-dormant t]
2503 ["Hide childless dormant"
2504 gnus-summary-limit-exclude-childless-dormant t]
2505 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2506 ["Hide marked" gnus-summary-limit-exclude-marks t]
2507 ["Show expunged" gnus-summary-limit-include-expunged t])
2509 ["Set mark" gnus-summary-mark-as-processable t]
2510 ["Remove mark" gnus-summary-unmark-as-processable t]
2511 ["Remove all marks" gnus-summary-unmark-all-processable t]
2512 ["Invert marks" gnus-uu-invert-processable t]
2513 ["Mark above" gnus-uu-mark-over t]
2514 ["Mark series" gnus-uu-mark-series t]
2515 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2516 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2517 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2518 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2519 ["Mark all" gnus-uu-mark-all t]
2520 ["Mark buffer" gnus-uu-mark-buffer t]
2521 ["Mark sparse" gnus-uu-mark-sparse t]
2522 ["Mark thread" gnus-uu-mark-thread t]
2523 ["Unmark thread" gnus-uu-unmark-thread t]
2524 ("Process Mark Sets"
2525 ["Kill" gnus-summary-kill-process-mark t]
2526 ["Yank" gnus-summary-yank-process-mark
2527 gnus-newsgroup-process-stack]
2528 ["Save" gnus-summary-save-process-mark t]
2529 ["Run command on marked..." gnus-summary-universal-argument t]))
2531 ["Page forward" gnus-summary-next-page
2532 ,@(if (featurep 'xemacs) '(t)
2533 '(:help "Show next page of article"))]
2534 ["Page backward" gnus-summary-prev-page
2535 ,@(if (featurep 'xemacs) '(t)
2536 '(:help "Show previous page of article"))]
2537 ["Line forward" gnus-summary-scroll-up t])
2539 ["Next unread article" gnus-summary-next-unread-article t]
2540 ["Previous unread article" gnus-summary-prev-unread-article t]
2541 ["Next article" gnus-summary-next-article t]
2542 ["Previous article" gnus-summary-prev-article t]
2543 ["Next unread subject" gnus-summary-next-unread-subject t]
2544 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2545 ["Next article same subject" gnus-summary-next-same-subject t]
2546 ["Previous article same subject" gnus-summary-prev-same-subject t]
2547 ["First unread article" gnus-summary-first-unread-article t]
2548 ["Best unread article" gnus-summary-best-unread-article t]
2549 ["Go to subject number..." gnus-summary-goto-subject t]
2550 ["Go to article number..." gnus-summary-goto-article t]
2551 ["Go to the last article" gnus-summary-goto-last-article t]
2552 ["Pop article off history" gnus-summary-pop-article t])
2554 ["Sort by number" gnus-summary-sort-by-number t]
2555 ["Sort by author" gnus-summary-sort-by-author t]
2556 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2557 ["Sort by subject" gnus-summary-sort-by-subject t]
2558 ["Sort by date" gnus-summary-sort-by-date t]
2559 ["Sort by score" gnus-summary-sort-by-score t]
2560 ["Sort by lines" gnus-summary-sort-by-lines t]
2561 ["Sort by characters" gnus-summary-sort-by-chars t]
2562 ["Randomize" gnus-summary-sort-by-random t]
2563 ["Original sort" gnus-summary-sort-by-original t])
2565 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2566 ["Describe group" gnus-summary-describe-group t]
2567 ["Fetch charter" gnus-group-fetch-charter
2568 ,@(if (featurep 'xemacs) nil
2569 '(:help "Display the charter of the current group"))]
2570 ["Fetch control message" gnus-group-fetch-control
2571 ,@(if (featurep 'xemacs) nil
2572 '(:help "Display the archived control message for the current group"))]
2573 ["Read manual" gnus-info-find-node t])
2575 ["Pick and read" gnus-pick-mode t]
2576 ["Binary" gnus-binary-mode t])
2578 ["Regenerate" gnus-summary-prepare t]
2579 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2580 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2581 ["Toggle threading" gnus-summary-toggle-threads t])
2582 ["See old articles" gnus-summary-insert-old-articles t]
2583 ["See new articles" gnus-summary-insert-new-articles t]
2584 ["Filter articles..." gnus-summary-execute-command t]
2585 ["Run command on articles..." gnus-summary-universal-argument t]
2586 ["Search articles forward..." gnus-summary-search-article-forward t]
2587 ["Search articles backward..." gnus-summary-search-article-backward t]
2588 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2589 ["Expand window" gnus-summary-expand-window t]
2590 ["Expire expirable articles" gnus-summary-expire-articles
2591 (gnus-check-backend-function
2592 'request-expire-articles gnus-newsgroup-name)]
2593 ["Edit local kill file" gnus-summary-edit-local-kill t]
2594 ["Edit main kill file" gnus-summary-edit-global-kill t]
2595 ["Edit group parameters" gnus-summary-edit-parameters t]
2596 ["Customize group parameters" gnus-summary-customize-parameters t]
2597 ["Send a bug report" gnus-bug t]
2599 ["Catchup and exit" gnus-summary-catchup-and-exit
2600 ,@(if (featurep 'xemacs) '(t)
2601 '(:help "Mark unread articles in this group as read, then exit"))]
2602 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2603 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2604 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2605 ["Exit group" gnus-summary-exit
2606 ,@(if (featurep 'xemacs) '(t)
2607 '(:help "Exit current group, return to group selection mode"))]
2608 ["Exit group without updating" gnus-summary-exit-no-update t]
2609 ["Exit and goto next group" gnus-summary-next-group t]
2610 ["Exit and goto prev group" gnus-summary-prev-group t]
2611 ["Reselect group" gnus-summary-reselect-current-group t]
2612 ["Rescan group" gnus-summary-rescan-group t]
2613 ["Update dribble" gnus-summary-save-newsrc t])))
2615 (gnus-run-hooks 'gnus-summary-menu-hook)))
2617 (defvar gnus-summary-tool-bar-map nil)
2619 ;; Emacs 21 tool bar. Should be no-op otherwise.
2620 (defun gnus-summary-make-tool-bar ()
2621 (if (and (fboundp 'tool-bar-add-item-from-menu)
2622 (default-value 'tool-bar-mode)
2623 (not gnus-summary-tool-bar-map))
2624 (setq gnus-summary-tool-bar-map
2625 (let ((tool-bar-map (make-sparse-keymap))
2626 (load-path (mm-image-load-path)))
2627 (tool-bar-add-item-from-menu
2628 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2629 (tool-bar-add-item-from-menu
2630 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2631 (tool-bar-add-item-from-menu
2632 'gnus-summary-post-news "post" gnus-summary-mode-map)
2633 (tool-bar-add-item-from-menu
2634 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2635 (tool-bar-add-item-from-menu
2636 'gnus-summary-followup "followup" gnus-summary-mode-map)
2637 (tool-bar-add-item-from-menu
2638 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2639 (tool-bar-add-item-from-menu
2640 'gnus-summary-reply "reply" gnus-summary-mode-map)
2641 (tool-bar-add-item-from-menu
2642 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2643 (tool-bar-add-item-from-menu
2644 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2645 (tool-bar-add-item-from-menu
2646 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2647 (tool-bar-add-item-from-menu
2648 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2649 (tool-bar-add-item-from-menu
2650 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2651 (tool-bar-add-item-from-menu
2652 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2653 (tool-bar-add-item-from-menu
2654 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2655 (tool-bar-add-item-from-menu
2656 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2657 (tool-bar-add-item-from-menu
2658 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2660 (if gnus-summary-tool-bar-map
2661 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2663 (defun gnus-score-set-default (var value)
2664 "A version of set that updates the GNU Emacs menu-bar."
2666 ;; It is the message that forces the active status to be updated.
2669 (defun gnus-make-score-map (type)
2670 "Make a summary score map of type TYPE."
2673 (let ((headers '(("author" "from" string)
2674 ("subject" "subject" string)
2675 ("article body" "body" string)
2676 ("article head" "head" string)
2677 ("xref" "xref" string)
2678 ("extra header" "extra" string)
2679 ("lines" "lines" number)
2680 ("followups to author" "followup" string)))
2681 (types '((number ("less than" <)
2684 (string ("substring" s)
2688 (perms '(("temporary" (current-time-string))
2696 (if (eq type 'lower)
2701 (setq header (car headers))
2707 (let ((ts (cdr (assoc (nth 2 header) types)))
2723 'gnus-summary-score-entry
2725 (if (or (string= (nth 1 header)
2727 (string= (nth 1 header)
2730 (list 'gnus-summary-header
2732 (list 'quote (nth 1 (car ts)))
2733 (list 'gnus-score-delta-default
2740 (list (nreverse outp))))
2743 (list (nreverse outt))))
2745 (setq headers (cdr headers)))
2746 (list (nreverse outh))))))))
2750 (defun gnus-summary-mode (&optional group)
2751 "Major mode for reading articles.
2753 All normal editing commands are switched off.
2754 \\<gnus-summary-mode-map>
2755 Each line in this buffer represents one article. To read an
2756 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2757 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2760 You can also post articles and send mail from this buffer. To
2761 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2762 of an article, type `\\[gnus-summary-reply]'.
2764 There are approx. one gazillion commands you can execute in this
2765 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2767 The following commands are available:
2769 \\{gnus-summary-mode-map}"
2771 (kill-all-local-variables)
2772 (when (gnus-visual-p 'summary-menu 'menu)
2773 (gnus-summary-make-menu-bar)
2774 (gnus-summary-make-tool-bar))
2775 (gnus-summary-make-local-variables)
2776 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2777 (gnus-summary-make-local-variables))
2778 (gnus-make-thread-indent-array)
2779 (gnus-simplify-mode-line)
2780 (setq major-mode 'gnus-summary-mode)
2781 (setq mode-name "Summary")
2782 (make-local-variable 'minor-mode-alist)
2783 (use-local-map gnus-summary-mode-map)
2784 (buffer-disable-undo)
2785 (setq buffer-read-only t ;Disable modification
2786 show-trailing-whitespace nil)
2787 (setq truncate-lines t)
2788 (setq selective-display t)
2789 (setq selective-display-ellipses t) ;Display `...'
2790 (gnus-summary-set-display-table)
2791 (gnus-set-default-directory)
2792 (setq gnus-newsgroup-name group)
2793 (unless (gnus-news-group-p group)
2794 (setq gnus-newsgroup-incorporated
2795 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2796 (make-local-variable 'gnus-summary-line-format)
2797 (make-local-variable 'gnus-summary-line-format-spec)
2798 (make-local-variable 'gnus-summary-dummy-line-format)
2799 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2800 (make-local-variable 'gnus-summary-mark-positions)
2801 (gnus-make-local-hook 'pre-command-hook)
2802 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2803 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2804 (turn-on-gnus-mailing-list-mode)
2805 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2806 (gnus-update-summary-mark-positions))
2808 (defun gnus-summary-make-local-variables ()
2809 "Make all the local summary buffer variables."
2811 (dolist (local gnus-summary-local-variables)
2814 (if (eq (cdr local) 'global)
2815 ;; Copy the global value of the variable.
2816 (setq global (symbol-value (car local)))
2817 ;; Use the value from the list.
2818 (setq global (eval (cdr local))))
2819 (set (make-local-variable (car local)) global))
2820 ;; Simple nil-valued local variable.
2821 (set (make-local-variable local) nil)))))
2823 (defun gnus-summary-clear-local-variables ()
2824 (let ((locals gnus-summary-local-variables))
2826 (if (consp (car locals))
2827 (and (symbolp (caar locals))
2828 (set (caar locals) nil))
2829 (and (symbolp (car locals))
2830 (set (car locals) nil)))
2831 (setq locals (cdr locals)))))
2833 ;; Summary data functions.
2835 (defmacro gnus-data-number (data)
2838 (defmacro gnus-data-set-number (data number)
2839 `(setcar ,data ,number))
2841 (defmacro gnus-data-mark (data)
2844 (defmacro gnus-data-set-mark (data mark)
2845 `(setcar (nthcdr 1 ,data) ,mark))
2847 (defmacro gnus-data-pos (data)
2850 (defmacro gnus-data-set-pos (data pos)
2851 `(setcar (nthcdr 2 ,data) ,pos))
2853 (defmacro gnus-data-header (data)
2856 (defmacro gnus-data-set-header (data header)
2857 `(setcar (nthcdr 3 ,data) ,header))
2859 (defmacro gnus-data-level (data)
2862 (defmacro gnus-data-unread-p (data)
2863 `(= (nth 1 ,data) gnus-unread-mark))
2865 (defmacro gnus-data-read-p (data)
2866 `(/= (nth 1 ,data) gnus-unread-mark))
2868 (defmacro gnus-data-pseudo-p (data)
2869 `(consp (nth 3 ,data)))
2871 (defmacro gnus-data-find (number)
2872 `(assq ,number gnus-newsgroup-data))
2874 (defmacro gnus-data-find-list (number &optional data)
2875 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2876 (memq (assq ,number bdata)
2879 (defmacro gnus-data-make (number mark pos header level)
2880 `(list ,number ,mark ,pos ,header ,level))
2882 (defun gnus-data-enter (after-article number mark pos header level offset)
2883 (let ((data (gnus-data-find-list after-article)))
2885 (error "No such article: %d" after-article))
2886 (setcdr data (cons (gnus-data-make number mark pos header level)
2888 (setq gnus-newsgroup-data-reverse nil)
2889 (gnus-data-update-list (cddr data) offset)))
2891 (defun gnus-data-enter-list (after-article list &optional offset)
2893 (let ((data (and after-article (gnus-data-find-list after-article)))
2897 (let ((odata gnus-newsgroup-data))
2898 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2900 (gnus-data-update-list odata offset)))
2901 ;; Find the last element in the list to be spliced into the main
2903 (setq list (last list))
2906 (setcdr list gnus-newsgroup-data)
2907 (setq gnus-newsgroup-data ilist)
2909 (gnus-data-update-list (cdr list) offset)))
2910 (setcdr list (cdr data))
2913 (gnus-data-update-list (cdr list) offset))))
2914 (setq gnus-newsgroup-data-reverse nil))))
2916 (defun gnus-data-remove (article &optional offset)
2917 (let ((data gnus-newsgroup-data))
2918 (if (= (gnus-data-number (car data)) article)
2920 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2921 gnus-newsgroup-data-reverse nil)
2923 (gnus-data-update-list gnus-newsgroup-data offset)))
2925 (when (= (gnus-data-number (cadr data)) article)
2926 (setcdr data (cddr data))
2928 (gnus-data-update-list (cdr data) offset))
2930 gnus-newsgroup-data-reverse nil))
2931 (setq data (cdr data))))))
2933 (defmacro gnus-data-list (backward)
2935 (or gnus-newsgroup-data-reverse
2936 (setq gnus-newsgroup-data-reverse
2937 (reverse gnus-newsgroup-data)))
2938 gnus-newsgroup-data))
2940 (defun gnus-data-update-list (data offset)
2941 "Add OFFSET to the POS of all data entries in DATA."
2942 (setq gnus-newsgroup-data-reverse nil)
2944 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2945 (setq data (cdr data))))
2947 (defun gnus-summary-article-pseudo-p (article)
2948 "Say whether this article is a pseudo article or not."
2949 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2951 (defmacro gnus-summary-article-sparse-p (article)
2952 "Say whether this article is a sparse article or not."
2953 `(memq ,article gnus-newsgroup-sparse))
2955 (defmacro gnus-summary-article-ancient-p (article)
2956 "Say whether this article is a sparse article or not."
2957 `(memq ,article gnus-newsgroup-ancient))
2959 (defun gnus-article-parent-p (number)
2960 "Say whether this article is a parent or not."
2961 (let ((data (gnus-data-find-list number)))
2962 (and (cdr data) ; There has to be an article after...
2963 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2964 (gnus-data-level (nth 1 data))))))
2966 (defun gnus-article-children (number)
2967 "Return a list of all children to NUMBER."
2968 (let* ((data (gnus-data-find-list number))
2969 (level (gnus-data-level (car data)))
2971 (setq data (cdr data))
2973 (= (gnus-data-level (car data)) (1+ level)))
2974 (push (gnus-data-number (car data)) children)
2975 (setq data (cdr data)))
2978 (defmacro gnus-summary-skip-intangible ()
2979 "If the current article is intangible, then jump to a different article."
2980 '(let ((to (get-text-property (point) 'gnus-intangible)))
2981 (and to (gnus-summary-goto-subject to))))
2983 (defmacro gnus-summary-article-intangible-p ()
2984 "Say whether this article is intangible or not."
2985 '(get-text-property (point) 'gnus-intangible))
2987 (defun gnus-article-read-p (article)
2988 "Say whether ARTICLE is read or not."
2989 (not (or (memq article gnus-newsgroup-marked)
2990 (memq article gnus-newsgroup-spam-marked)
2991 (memq article gnus-newsgroup-unreads)
2992 (memq article gnus-newsgroup-unselected)
2993 (memq article gnus-newsgroup-dormant))))
2995 ;; Some summary mode macros.
2997 (defmacro gnus-summary-article-number ()
2998 "The article number of the article on the current line.
2999 If there isn't an article number here, then we return the current
3002 (gnus-summary-skip-intangible)
3003 (or (get-text-property (point) 'gnus-number)
3004 (gnus-summary-last-subject))))
3006 (defmacro gnus-summary-article-header (&optional number)
3007 "Return the header of article NUMBER."
3008 `(gnus-data-header (gnus-data-find
3009 ,(or number '(gnus-summary-article-number)))))
3011 (defmacro gnus-summary-thread-level (&optional number)
3012 "Return the level of thread that starts with article NUMBER."
3013 `(if (and (eq gnus-summary-make-false-root 'dummy)
3014 (get-text-property (point) 'gnus-intangible))
3016 (gnus-data-level (gnus-data-find
3017 ,(or number '(gnus-summary-article-number))))))
3019 (defmacro gnus-summary-article-mark (&optional number)
3020 "Return the mark of article NUMBER."
3021 `(gnus-data-mark (gnus-data-find
3022 ,(or number '(gnus-summary-article-number)))))
3024 (defmacro gnus-summary-article-pos (&optional number)
3025 "Return the position of the line of article NUMBER."
3026 `(gnus-data-pos (gnus-data-find
3027 ,(or number '(gnus-summary-article-number)))))
3029 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3030 (defmacro gnus-summary-article-subject (&optional number)
3031 "Return current subject string or nil if nothing."
3034 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3035 '(gnus-data-header (assq (gnus-summary-article-number)
3036 gnus-newsgroup-data)))))
3039 (mail-header-subject headers))))
3041 (defmacro gnus-summary-article-score (&optional number)
3042 "Return current article score."
3043 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3044 gnus-newsgroup-scored))
3045 gnus-summary-default-score 0))
3047 (defun gnus-summary-article-children (&optional number)
3048 "Return a list of article numbers that are children of article NUMBER."
3049 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3050 (level (gnus-data-level (car data)))
3052 (while (and (setq data (cdr data))
3053 (> (setq l (gnus-data-level (car data))) level))
3054 (and (= (1+ level) l)
3055 (push (gnus-data-number (car data))
3057 (nreverse children)))
3059 (defun gnus-summary-article-parent (&optional number)
3060 "Return the article number of the parent of article NUMBER."
3061 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3062 (gnus-data-list t)))
3063 (level (gnus-data-level (car data))))
3065 () ; This is a root.
3066 ;; We search until we find an article with a level less than
3067 ;; this one. That function has to be the parent.
3068 (while (and (setq data (cdr data))
3069 (not (< (gnus-data-level (car data)) level))))
3070 (and data (gnus-data-number (car data))))))
3072 (defun gnus-unread-mark-p (mark)
3073 "Say whether MARK is the unread mark."
3074 (= mark gnus-unread-mark))
3076 (defun gnus-read-mark-p (mark)
3077 "Say whether MARK is one of the marks that mark as read.
3078 This is all marks except unread, ticked, dormant, and expirable."
3079 (not (or (= mark gnus-unread-mark)
3080 (= mark gnus-ticked-mark)
3081 (= mark gnus-spam-mark)
3082 (= mark gnus-dormant-mark)
3083 (= mark gnus-expirable-mark))))
3085 (defmacro gnus-article-mark (number)
3086 "Return the MARK of article NUMBER.
3087 This macro should only be used when computing the mark the \"first\"
3088 time; i.e., when generating the summary lines. After that,
3089 `gnus-summary-article-mark' should be used to examine the
3092 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3093 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3094 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3095 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3096 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3097 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3098 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3099 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3100 gnus-ancient-mark))))
3102 ;; Saving hidden threads.
3104 (defmacro gnus-save-hidden-threads (&rest forms)
3105 "Save hidden threads, eval FORMS, and restore the hidden threads."
3106 (let ((config (make-symbol "config")))
3107 `(let ((,config (gnus-hidden-threads-configuration)))
3111 (gnus-restore-hidden-threads-configuration ,config)))))
3112 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3113 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3115 (defun gnus-data-compute-positions ()
3116 "Compute the positions of all articles."
3117 (setq gnus-newsgroup-data-reverse nil)
3118 (let ((data gnus-newsgroup-data))
3120 (gnus-save-hidden-threads
3121 (gnus-summary-show-all-threads)
3122 (goto-char (point-min))
3124 (while (get-text-property (point) 'gnus-intangible)
3126 (gnus-data-set-pos (car data) (+ (point) 3))
3127 (setq data (cdr data))
3128 (forward-line 1))))))
3130 (defun gnus-hidden-threads-configuration ()
3131 "Return the current hidden threads configuration."
3134 (goto-char (point-min))
3135 (while (search-forward "\r" nil t)
3136 (push (1- (point)) config))
3139 (defun gnus-restore-hidden-threads-configuration (config)
3140 "Restore hidden threads configuration from CONFIG."
3142 (let (point buffer-read-only)
3143 (while (setq point (pop config))
3144 (when (and (< point (point-max))
3146 (eq (char-after) ?\n))
3147 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3149 ;; Various summary mode internalish functions.
3151 (defun gnus-mouse-pick-article (e)
3154 (gnus-summary-next-page nil t))
3156 (defun gnus-summary-set-display-table ()
3157 "Change the display table.
3158 Odd characters have a tendency to mess
3159 up nicely formatted displays - we make all possible glyphs
3160 display only a single character."
3162 ;; We start from the standard display table, if any.
3163 (let ((table (or (copy-sequence standard-display-table)
3164 (make-display-table)))
3166 ;; Nix out all the control chars...
3167 (while (>= (setq i (1- i)) 0)
3168 (aset table i [??]))
3169 ;; ... but not newline and cr, of course. (cr is necessary for the
3170 ;; selective display).
3171 (aset table ?\n nil)
3172 (aset table ?\r nil)
3173 ;; We keep TAB as well.
3174 (aset table ?\t nil)
3175 ;; We nix out any glyphs over 126 that are not set already.
3177 (while (>= (setq i (1- i)) 127)
3178 ;; Only modify if the entry is nil.
3179 (unless (aref table i)
3180 (aset table i [??]))))
3181 (setq buffer-display-table table)))
3183 (defun gnus-summary-set-article-display-arrow (pos)
3184 "Update the overlay arrow to point to line at position POS."
3185 (when (and gnus-summary-display-arrow
3186 (boundp 'overlay-arrow-position)
3187 (boundp 'overlay-arrow-string))
3191 (unless overlay-arrow-position
3192 (setq overlay-arrow-position (make-marker)))
3193 (setq overlay-arrow-string "=>"
3194 overlay-arrow-position (set-marker overlay-arrow-position
3196 (current-buffer))))))
3198 (defun gnus-summary-setup-buffer (group)
3199 "Initialize summary buffer."
3200 (let ((buffer (gnus-summary-buffer-name group))
3201 (dead-name (concat "*Dead Summary "
3202 (gnus-group-decoded-name group) "*")))
3203 ;; If a dead summary buffer exists, we kill it.
3204 (when (gnus-buffer-live-p dead-name)
3205 (gnus-kill-buffer dead-name))
3206 (if (get-buffer buffer)
3209 (setq gnus-summary-buffer (current-buffer))
3210 (not gnus-newsgroup-prepared))
3211 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3212 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3213 (gnus-summary-mode group)
3215 (gnus-carpal-setup-buffer 'summary))
3216 (unless gnus-single-article-buffer
3217 (make-local-variable 'gnus-article-buffer)
3218 (make-local-variable 'gnus-article-current)
3219 (make-local-variable 'gnus-original-article-buffer))
3220 (setq gnus-newsgroup-name group)
3221 ;; Set any local variables in the group parameters.
3222 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3225 (defun gnus-set-global-variables ()
3226 "Set the global equivalents of the buffer-local variables.
3227 They are set to the latest values they had. These reflect the summary
3228 buffer that was in action when the last article was fetched."
3229 (when (eq major-mode 'gnus-summary-mode)
3230 (setq gnus-summary-buffer (current-buffer))
3231 (let ((name gnus-newsgroup-name)
3232 (marked gnus-newsgroup-marked)
3233 (spam gnus-newsgroup-spam-marked)
3234 (unread gnus-newsgroup-unreads)
3235 (headers gnus-current-headers)
3236 (data gnus-newsgroup-data)
3237 (summary gnus-summary-buffer)
3238 (article-buffer gnus-article-buffer)
3239 (original gnus-original-article-buffer)
3240 (gac gnus-article-current)
3241 (reffed gnus-reffed-article-number)
3242 (score-file gnus-current-score-file)
3243 (default-charset gnus-newsgroup-charset)
3245 (let ((locals gnus-newsgroup-variables))
3247 (if (consp (car locals))
3248 (push (eval (caar locals)) vlist)
3249 (push (eval (car locals)) vlist))
3250 (setq locals (cdr locals)))
3251 (setq vlist (nreverse vlist)))
3252 (with-current-buffer gnus-group-buffer
3253 (setq gnus-newsgroup-name name
3254 gnus-newsgroup-marked marked
3255 gnus-newsgroup-spam-marked spam
3256 gnus-newsgroup-unreads unread
3257 gnus-current-headers headers
3258 gnus-newsgroup-data data
3259 gnus-article-current gac
3260 gnus-summary-buffer summary
3261 gnus-article-buffer article-buffer
3262 gnus-original-article-buffer original
3263 gnus-reffed-article-number reffed
3264 gnus-current-score-file score-file
3265 gnus-newsgroup-charset default-charset)
3266 (let ((locals gnus-newsgroup-variables))
3268 (if (consp (car locals))
3269 (set (caar locals) (pop vlist))
3270 (set (car locals) (pop vlist)))
3271 (setq locals (cdr locals))))
3272 ;; The article buffer also has local variables.
3273 (when (gnus-buffer-live-p gnus-article-buffer)
3274 (set-buffer gnus-article-buffer)
3275 (setq gnus-summary-buffer summary))))))
3277 (defun gnus-summary-article-unread-p (article)
3278 "Say whether ARTICLE is unread or not."
3279 (memq article gnus-newsgroup-unreads))
3281 (defun gnus-summary-first-article-p (&optional article)
3282 "Return whether ARTICLE is the first article in the buffer."
3283 (if (not (setq article (or article (gnus-summary-article-number))))
3285 (eq article (caar gnus-newsgroup-data))))
3287 (defun gnus-summary-last-article-p (&optional article)
3288 "Return whether ARTICLE is the last article in the buffer."
3289 (if (not (setq article (or article (gnus-summary-article-number))))
3290 ;; All non-existent numbers are the last article. :-)
3292 (not (cdr (gnus-data-find-list article)))))
3294 (defun gnus-make-thread-indent-array ()
3296 (unless (and gnus-thread-indent-array
3297 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3298 (setq gnus-thread-indent-array (make-vector 201 "")
3299 gnus-thread-indent-array-level gnus-thread-indent-level)
3301 (aset gnus-thread-indent-array n
3302 (make-string (* n gnus-thread-indent-level) ? ))
3305 (defun gnus-update-summary-mark-positions ()
3306 "Compute where the summary marks are to go."
3308 (when (gnus-buffer-exists-p gnus-summary-buffer)
3309 (set-buffer gnus-summary-buffer))
3310 (let ((spec gnus-summary-line-format-spec)
3313 (gnus-set-work-buffer)
3314 (let ((gnus-tmp-unread ?Z)
3315 (gnus-replied-mark ?Z)
3316 (gnus-score-below-mark ?Z)
3317 (gnus-score-over-mark ?Z)
3318 (gnus-undownloaded-mark ?Z)
3319 (gnus-summary-line-format-spec spec)
3320 (gnus-newsgroup-downloadable '(0))
3322 (make-full-mail-header
3323 0 "" "nobody" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil))
3324 case-fold-search ignores)
3325 ;; Here, all marks are bound to Z.
3326 (gnus-summary-insert-line header
3327 0 nil t gnus-tmp-unread t nil "" nil 1)
3328 (goto-char (point-min))
3329 ;; Memorize the positions of the same characters as dummy marks.
3330 (while (re-search-forward "[A-D]" nil t)
3331 (push (point) ignores))
3333 ;; We use A-D as dummy marks in order to know column positions
3334 ;; where marks should be inserted.
3335 (setq gnus-tmp-unread ?A
3336 gnus-replied-mark ?B
3337 gnus-score-below-mark ?C
3338 gnus-score-over-mark ?C
3339 gnus-undownloaded-mark ?D)
3340 (gnus-summary-insert-line header
3341 0 nil t gnus-tmp-unread t nil "" nil 1)
3342 ;; Ignore characters which aren't dummy marks.
3344 (delete-region (goto-char (1- p)) p)
3346 (goto-char (point-min))
3347 (setq pos (list (cons 'unread
3348 (and (search-forward "A" nil t)
3349 (- (point) (point-min) 1)))))
3350 (goto-char (point-min))
3351 (push (cons 'replied (and (search-forward "B" nil t)
3352 (- (point) (point-min) 1)))
3354 (goto-char (point-min))
3355 (push (cons 'score (and (search-forward "C" nil t)
3356 (- (point) (point-min) 1)))
3358 (goto-char (point-min))
3359 (push (cons 'download (and (search-forward "D" nil t)
3360 (- (point) (point-min) 1)))
3362 (setq gnus-summary-mark-positions pos))))
3364 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3365 "Insert a dummy root in the summary buffer."
3367 (gnus-add-text-properties
3368 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3369 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3371 (defun gnus-summary-extract-address-component (from)
3372 (or (car (funcall gnus-extract-address-components from))
3375 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3376 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3377 default-mime-charset)))
3378 ;; Is it really necessary to do this next part for each summary line?
3379 ;; Luckily, doesn't seem to slow things down much.
3381 (and gnus-ignored-from-addresses
3382 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3383 (let ((extra-headers (mail-header-extra header))
3387 ((setq to (cdr (assq 'To extra-headers)))
3388 (concat gnus-summary-to-prefix
3390 (gnus-summary-extract-address-component
3391 (funcall gnus-decode-encoded-word-function to)))))
3392 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3393 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3394 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3396 (defun gnus-summary-insert-line (gnus-tmp-header
3397 gnus-tmp-level gnus-tmp-current
3398 undownloaded gnus-tmp-unread gnus-tmp-replied
3399 gnus-tmp-expirable gnus-tmp-subject-or-nil
3400 &optional gnus-tmp-dummy gnus-tmp-score
3402 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3403 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3404 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3405 (gnus-tmp-score-char
3406 (if (or (null gnus-summary-default-score)
3407 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3408 gnus-summary-zcore-fuzz))
3410 (if (< gnus-tmp-score gnus-summary-default-score)
3411 gnus-score-below-mark gnus-score-over-mark)))
3412 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3414 (cond (gnus-tmp-process gnus-process-mark)
3415 ((memq gnus-tmp-current gnus-newsgroup-cached)
3417 (gnus-tmp-replied gnus-replied-mark)
3418 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3419 gnus-forwarded-mark)
3420 ((memq gnus-tmp-current gnus-newsgroup-saved)
3422 ((memq gnus-tmp-number gnus-newsgroup-recent)
3424 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3427 (gnus-tmp-downloaded
3429 gnus-undownloaded-mark)
3430 (gnus-newsgroup-agentized
3431 gnus-downloaded-mark)
3434 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3437 ((string-match "<[^>]+> *$" gnus-tmp-from)
3438 (let ((beg (match-beginning 0)))
3439 (or (and (string-match "^\".+\"" gnus-tmp-from)
3440 (substring gnus-tmp-from 1 (1- (match-end 0))))
3441 (substring gnus-tmp-from 0 beg))))
3442 ((string-match "(.+)" gnus-tmp-from)
3443 (substring gnus-tmp-from
3444 (1+ (match-beginning 0)) (1- (match-end 0))))
3446 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3447 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3448 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3449 (buffer-read-only nil))
3450 (when (string= gnus-tmp-name "")
3451 (setq gnus-tmp-name gnus-tmp-from))
3452 (unless (numberp gnus-tmp-lines)
3453 (setq gnus-tmp-lines -1))
3454 (if (= gnus-tmp-lines -1)
3455 (setq gnus-tmp-lines "?")
3456 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3457 (gnus-put-text-property-excluding-characters-with-faces
3459 (progn (eval gnus-summary-line-format-spec) (point))
3460 'gnus-number gnus-tmp-number)
3461 (when (gnus-visual-p 'summary-highlight 'highlight)
3463 (gnus-run-hooks 'gnus-summary-update-hook)
3466 (defun gnus-summary-update-line (&optional dont-update)
3467 "Update summary line after change."
3468 (when (and gnus-summary-default-score
3469 (not gnus-summary-inhibit-highlight))
3470 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3471 (article (gnus-summary-article-number))
3472 (score (gnus-summary-article-score article)))
3474 (if (and gnus-summary-mark-below
3475 (< (gnus-summary-article-score)
3476 gnus-summary-mark-below))
3477 ;; This article has a low score, so we mark it as read.
3478 (when (memq article gnus-newsgroup-unreads)
3479 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3480 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3481 ;; This article was previously marked as read on account
3482 ;; of a low score, but now it has risen, so we mark it as
3484 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3485 (gnus-summary-update-mark
3486 (if (or (null gnus-summary-default-score)
3487 (<= (abs (- score gnus-summary-default-score))
3488 gnus-summary-zcore-fuzz))
3490 (if (< score gnus-summary-default-score)
3491 gnus-score-below-mark gnus-score-over-mark))
3493 ;; Do visual highlighting.
3494 (when (gnus-visual-p 'summary-highlight 'highlight)
3495 (gnus-run-hooks 'gnus-summary-update-hook)))))
3497 (defvar gnus-tmp-new-adopts nil)
3499 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3500 "Return the number of articles in THREAD.
3501 This may be 0 in some cases -- if none of the articles in
3502 the thread are to be displayed."
3504 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3506 ((not (listp thread))
3508 ((and (consp thread) (cdr thread))
3511 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3514 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3517 (when (and level (zerop level) gnus-tmp-new-adopts)
3520 'gnus-summary-number-of-articles-in-thread
3521 gnus-tmp-new-adopts))))
3523 (if (> number 1) gnus-not-empty-thread-mark
3524 gnus-empty-thread-mark)
3527 (defsubst gnus-summary-line-message-size (head)
3528 "Return pretty-printed version of message size.
3529 This function is intended to be used in
3530 `gnus-summary-line-format-alist'."
3531 (let ((c (or (mail-header-chars head) -1)))
3532 (cond ((< c 0) "n/a") ; chars not available
3533 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3534 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3535 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3536 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3539 (defun gnus-summary-set-local-parameters (group)
3540 "Go through the local params of GROUP and set all variable specs in that list."
3541 (let ((vars '(quit-config))) ; Ignore quit-config.
3542 (dolist (elem (gnus-group-find-parameter group))
3543 (and (consp elem) ; Has to be a cons.
3544 (consp (cdr elem)) ; The cdr has to be a list.
3545 (symbolp (car elem)) ; Has to be a symbol in there.
3546 (not (memq (car elem) vars))
3547 (ignore-errors ; So we set it.
3548 (push (car elem) vars)
3549 (make-local-variable (car elem))
3550 (set (car elem) (eval (nth 1 elem))))))))
3552 (defun gnus-summary-read-group (group &optional show-all no-article
3553 kill-buffer no-display backward
3555 "Start reading news in newsgroup GROUP.
3556 If SHOW-ALL is non-nil, already read articles are also listed.
3557 If NO-ARTICLE is non-nil, no article is selected initially.
3558 If NO-DISPLAY, don't generate a summary buffer."
3562 (let ((gnus-auto-select-next nil))
3563 (or (gnus-summary-read-group-1
3564 group show-all no-article
3565 kill-buffer no-display
3568 select-articles nil)))))
3569 (eq gnus-auto-select-next 'quietly))
3570 (set-buffer gnus-group-buffer)
3571 ;; The entry function called above goes to the next
3572 ;; group automatically, so we go two groups back
3573 ;; if we are searching for the previous group.
3575 (gnus-group-prev-unread-group 2))
3576 (if (not (equal group (gnus-group-group-name)))
3577 (setq group (gnus-group-group-name))
3581 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3582 "Directly jump to the other GROUP from summary buffer.
3583 If SHOW-ALL is non-nil, already read articles are also listed."
3585 (if (eq gnus-summary-buffer (current-buffer))
3586 (list (completing-read
3587 "Group: " gnus-active-hashtb nil t
3588 (when (and gnus-newsgroup-name
3589 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3590 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3591 'gnus-group-history)
3593 (error "%s must be invoked from a gnus summary buffer." this-command)))
3594 (unless (or (zerop (length group))
3595 (and gnus-newsgroup-name
3596 (string-equal gnus-newsgroup-name group)))
3598 (gnus-summary-read-group group show-all
3599 gnus-dont-select-after-jump-to-other-group)))
3601 (defun gnus-summary-read-group-1 (group show-all no-article
3602 kill-buffer no-display
3603 &optional select-articles)
3604 ;; Killed foreign groups can't be entered.
3605 ;; (when (and (not (gnus-group-native-p group))
3606 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3607 ;; (error "Dead non-native groups can't be entered"))
3608 (gnus-message 5 "Retrieving newsgroup: %s..."
3609 (gnus-group-decoded-name group))
3610 (let* ((new-group (gnus-summary-setup-buffer group))
3611 (quit-config (gnus-group-quit-config group))
3612 (did-select (and new-group (gnus-select-newsgroup
3613 group show-all select-articles))))
3615 ;; This summary buffer exists already, so we just select it.
3617 (gnus-set-global-variables)
3619 (gnus-kill-or-deaden-summary kill-buffer))
3620 (gnus-configure-windows 'summary 'force)
3621 (gnus-set-mode-line 'summary)
3622 (gnus-summary-position-point)
3625 ;; We couldn't select this group.
3627 (when (and (eq major-mode 'gnus-summary-mode)
3628 (not (equal (current-buffer) kill-buffer)))
3629 (kill-buffer (current-buffer))
3630 (if (not quit-config)
3632 ;; Update the info -- marks might need to be removed,
3634 (gnus-summary-update-info)
3635 (set-buffer gnus-group-buffer)
3636 (gnus-group-jump-to-group group)
3637 (gnus-group-next-unread-group 1))
3638 (gnus-handle-ephemeral-exit quit-config)))
3639 (let ((grpinfo (gnus-get-info group)))
3640 (if (null (gnus-info-read grpinfo))
3641 (gnus-message 3 "Group %s contains no messages"
3642 (gnus-group-decoded-name group))
3643 (gnus-message 3 "Can't select group")))
3645 ;; The user did a `C-g' while prompting for number of articles,
3646 ;; so we exit this group.
3647 ((eq did-select 'quit)
3648 (and (eq major-mode 'gnus-summary-mode)
3649 (not (equal (current-buffer) kill-buffer))
3650 (kill-buffer (current-buffer)))
3652 (gnus-kill-or-deaden-summary kill-buffer))
3653 (if (not quit-config)
3655 (set-buffer gnus-group-buffer)
3656 (gnus-group-jump-to-group group)
3657 (gnus-group-next-unread-group 1)
3658 (gnus-configure-windows 'group 'force))
3659 (gnus-handle-ephemeral-exit quit-config))
3660 ;; Finally signal the quit.
3662 ;; The group was successfully selected.
3664 (gnus-set-global-variables)
3665 ;; Save the active value in effect when the group was entered.
3666 (setq gnus-newsgroup-active
3668 (gnus-active gnus-newsgroup-name)))
3669 ;; You can change the summary buffer in some way with this hook.
3670 (gnus-run-hooks 'gnus-select-group-hook)
3671 (when (memq 'summary (gnus-update-format-specifications
3672 nil 'summary 'summary-mode 'summary-dummy))
3673 ;; The format specification for the summary line was updated,
3674 ;; so we need to update the mark positions as well.
3675 (gnus-update-summary-mark-positions))
3676 ;; Do score processing.
3677 (when gnus-use-scoring
3678 (gnus-possibly-score-headers))
3679 ;; Check whether to fill in the gaps in the threads.
3680 (when gnus-build-sparse-threads
3681 (gnus-build-sparse-threads))
3682 ;; Find the initial limit.
3684 (let ((gnus-newsgroup-dormant nil))
3685 (gnus-summary-initial-limit show-all))
3686 (gnus-summary-initial-limit show-all))
3687 ;; Generate the summary buffer.
3689 (gnus-summary-prepare))
3690 (when gnus-use-trees
3691 (gnus-tree-open group)
3692 (setq gnus-summary-highlight-line-function
3693 'gnus-tree-highlight-article))
3694 ;; If the summary buffer is empty, but there are some low-scored
3695 ;; articles or some excluded dormants, we include these in the
3697 (when (and (zerop (buffer-size))
3699 (cond (gnus-newsgroup-dormant
3700 (gnus-summary-limit-include-dormant))
3701 ((and gnus-newsgroup-scored show-all)
3702 (gnus-summary-limit-include-expunged t))))
3703 ;; Function `gnus-apply-kill-file' must be called in this hook.
3704 (gnus-run-hooks 'gnus-apply-kill-hook)
3705 (if (and (zerop (buffer-size))
3708 ;; This newsgroup is empty.
3709 (gnus-summary-catchup-and-exit nil t)
3710 (gnus-message 6 "No unread news")
3712 (gnus-kill-or-deaden-summary kill-buffer))
3713 ;; Return nil from this function.
3715 ;; Hide conversation thread subtrees. We cannot do this in
3716 ;; gnus-summary-prepare-hook since kill processing may not
3717 ;; work with hidden articles.
3718 (gnus-summary-maybe-hide-threads)
3720 (gnus-kill-or-deaden-summary kill-buffer))
3721 (gnus-summary-auto-select-subject)
3722 ;; Show first unread article if requested.
3723 (if (and (not no-article)
3725 gnus-newsgroup-unreads
3726 gnus-auto-select-first)
3728 (gnus-configure-windows 'summary)
3729 (let ((art (gnus-summary-article-number)))
3730 (unless (and (not gnus-plugged)
3731 (or (memq art gnus-newsgroup-undownloaded)
3732 (memq art gnus-newsgroup-downloadable)))
3733 (gnus-summary-goto-article art))))
3734 ;; Don't select any articles.
3735 (gnus-summary-position-point)
3736 (gnus-configure-windows 'summary 'force)
3737 (gnus-set-mode-line 'summary))
3738 (when (and gnus-auto-center-group
3739 (get-buffer-window gnus-group-buffer t))
3740 ;; Gotta use windows, because recenter does weird stuff if
3741 ;; the current buffer ain't the displayed window.
3742 (let ((owin (selected-window)))
3743 (select-window (get-buffer-window gnus-group-buffer t))
3744 (when (gnus-group-goto-group group)
3746 (select-window owin)))
3747 ;; Mark this buffer as "prepared".
3748 (setq gnus-newsgroup-prepared t)
3749 (gnus-run-hooks 'gnus-summary-prepared-hook)
3750 (unless (gnus-ephemeral-group-p group)
3751 (gnus-group-update-group group))
3754 (defun gnus-summary-auto-select-subject ()
3755 "Select the subject line on initial group entry."
3756 (goto-char (point-min))
3758 ((eq gnus-auto-select-subject 'best)
3759 (gnus-summary-best-unread-subject))
3760 ((eq gnus-auto-select-subject 'unread)
3761 (gnus-summary-first-unread-subject))
3762 ((eq gnus-auto-select-subject 'unseen)
3763 (gnus-summary-first-unseen-subject))
3764 ((eq gnus-auto-select-subject 'unseen-or-unread)
3765 (gnus-summary-first-unseen-or-unread-subject))
3766 ((eq gnus-auto-select-subject 'first)
3769 ((functionp gnus-auto-select-subject)
3770 (funcall gnus-auto-select-subject))))
3772 (defun gnus-summary-prepare ()
3773 "Generate the summary buffer."
3775 (let ((buffer-read-only nil))
3777 (setq gnus-newsgroup-data nil
3778 gnus-newsgroup-data-reverse nil)
3779 (gnus-run-hooks 'gnus-summary-generate-hook)
3780 ;; Generate the buffer, either with threads or without.
3781 (when gnus-newsgroup-headers
3782 (gnus-summary-prepare-threads
3783 (if gnus-show-threads
3784 (gnus-sort-gathered-threads
3785 (funcall gnus-summary-thread-gathering-function
3787 (gnus-cut-threads (gnus-make-threads)))))
3788 ;; Unthreaded display.
3789 (gnus-sort-articles gnus-newsgroup-headers))))
3790 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3791 ;; Call hooks for modifying summary buffer.
3792 (goto-char (point-min))
3793 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3795 (defsubst gnus-general-simplify-subject (subject)
3796 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3799 ;; Truncate the subject.
3800 (gnus-simplify-subject-functions
3801 (gnus-map-function gnus-simplify-subject-functions subject))
3802 ((numberp gnus-summary-gather-subject-limit)
3803 (setq subject (gnus-simplify-subject-re subject))
3804 (if (> (length subject) gnus-summary-gather-subject-limit)
3805 (substring subject 0 gnus-summary-gather-subject-limit)
3807 ;; Fuzzily simplify it.
3808 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3809 (gnus-simplify-subject-fuzzy subject))
3810 ;; Just remove the leading "Re:".
3812 (gnus-simplify-subject-re subject))))
3814 (if (and gnus-summary-gather-exclude-subject
3815 (string-match gnus-summary-gather-exclude-subject subject))
3816 nil ; This article shouldn't be gathered
3819 (defun gnus-summary-simplify-subject-query ()
3820 "Query where the respool algorithm would put this article."
3822 (gnus-summary-select-article)
3824 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3826 (defun gnus-gather-threads-by-subject (threads)
3827 "Gather threads by looking at Subject headers."
3828 (if (not gnus-summary-make-false-root)
3830 (let ((hashtb (gnus-make-hashtable 1024))
3833 subject hthread whole-subject)
3835 (setq subject (gnus-general-simplify-subject
3836 (setq whole-subject (mail-header-subject
3839 (if (setq hthread (gnus-gethash subject hashtb))
3841 ;; We enter a dummy root into the thread, if we
3842 ;; haven't done that already.
3843 (unless (stringp (caar hthread))
3844 (setcar hthread (list whole-subject (car hthread))))
3845 ;; We add this new gathered thread to this gathered
3847 (setcdr (car hthread)
3848 (nconc (cdar hthread) (list (car threads))))
3849 ;; Remove it from the list of threads.
3850 (setcdr prev (cdr threads))
3851 (setq threads prev))
3852 ;; Enter this thread into the hash table.
3853 (gnus-sethash subject
3854 (if gnus-summary-make-false-root-always
3856 ;; If you want a dummy root above all
3858 (setcar threads (list whole-subject
3864 (setq threads (cdr threads)))
3867 (defun gnus-gather-threads-by-references (threads)
3868 "Gather threads by looking at References headers."
3869 (let ((idhashtb (gnus-make-hashtable 1024))
3870 (thhashtb (gnus-make-hashtable 1024))
3873 ids references id gthread gid entered ref)
3875 (when (setq references (mail-header-references (caar threads)))
3876 (setq id (mail-header-id (caar threads))
3877 ids (inline (gnus-split-references references))
3879 (while (setq ref (pop ids))
3880 (setq ids (delete ref ids))
3881 (if (not (setq gid (gnus-gethash ref idhashtb)))
3883 (gnus-sethash ref id idhashtb)
3884 (gnus-sethash id threads thhashtb))
3885 (setq gthread (gnus-gethash gid thhashtb))
3887 ;; We enter a dummy root into the thread, if we
3888 ;; haven't done that already.
3889 (unless (stringp (caar gthread))
3890 (setcar gthread (list (mail-header-subject (caar gthread))
3892 ;; We add this new gathered thread to this gathered
3894 (setcdr (car gthread)
3895 (nconc (cdar gthread) (list (car threads)))))
3896 ;; Add it into the thread hash table.
3897 (gnus-sethash id gthread thhashtb)
3899 ;; Remove it from the list of threads.
3900 (setcdr prev (cdr threads))
3901 (setq threads prev))))
3903 (setq threads (cdr threads)))
3906 (defun gnus-sort-gathered-threads (threads)
3907 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3908 (let ((result threads))
3910 (when (stringp (caar threads))
3911 (setcdr (car threads)
3912 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3913 (setq threads (cdr threads)))
3916 (defun gnus-thread-loop-p (root thread)
3917 "Say whether ROOT is in THREAD."
3918 (let ((stack (list thread))
3921 (while (setq thread (pop stack))
3922 (setq th (cdr thread))
3924 (not (eq (caar th) root)))
3927 ;; We have found a loop.
3929 (setcdr thread (delq (car th) (cdr thread)))
3930 (if (boundp (setq ref-dep (intern "none"
3931 gnus-newsgroup-dependencies)))
3932 (setcdr (symbol-value ref-dep)
3933 (nconc (cdr (symbol-value ref-dep))
3935 (set ref-dep (list nil (car th))))
3938 ;; Push all the subthreads onto the stack.
3939 (push (cdr thread) stack)))
3942 (defun gnus-make-threads ()
3943 "Go through the dependency hashtb and find the roots. Return all threads."
3945 (while (catch 'infloop
3948 ;; Deal with self-referencing References loops.
3949 (when (and (car (symbol-value refs))
3956 (car (symbol-value refs)) thread))
3957 (cdr (symbol-value refs)))))))
3960 (unless (car (symbol-value refs))
3961 ;; These threads do not refer back to any other articles,
3962 ;; so they're roots.
3963 (setq threads (append (cdr (symbol-value refs)) threads))))
3964 gnus-newsgroup-dependencies)))
3967 ;; Build the thread tree.
3968 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3969 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3971 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3972 if it was already present.
3974 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3975 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3976 Message-IDs will be renamed to a unique Message-ID before being
3979 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3980 (let* ((id (mail-header-id header))
3981 (id-dep (and id (intern id dependencies)))
3982 parent-id ref ref-dep ref-header replaced)
3983 ;; Enter this `header' in the `dependencies' table.
3987 ;; The first two cases do the normal part: enter a new `header'
3988 ;; in the `dependencies' table.
3989 ((not (boundp id-dep))
3990 (set id-dep (list header)))
3991 ((null (car (symbol-value id-dep)))
3992 (setcar (symbol-value id-dep) header))
3994 ;; From here the `header' was already present in the
3995 ;; `dependencies' table.
3997 ;; Overrides an existing entry;
3998 ;; just set the header part of the entry.
3999 (setcar (symbol-value id-dep) header)
4002 ;; Renames the existing `header' to a unique Message-ID.
4003 ((not gnus-summary-ignore-duplicates)
4004 ;; An article with this Message-ID has already been seen.
4005 ;; We rename the Message-ID.
4006 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4008 (mail-header-set-id header id))
4010 ;; The last case ignores an existing entry, except it adds any
4011 ;; additional Xrefs (in case the two articles came from different
4013 ;; Also sets `header' to `nil' meaning that the `dependencies'
4014 ;; table was *not* modified.
4016 (mail-header-set-xref
4017 (car (symbol-value id-dep))
4018 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4020 (or (mail-header-xref header) "")))
4023 (when (and header (not replaced))
4024 ;; First check that we are not creating a References loop.
4025 (setq parent-id (gnus-parent-id (mail-header-references header)))
4026 (setq ref parent-id)
4028 (setq ref-dep (intern-soft ref dependencies))
4030 (setq ref-header (car (symbol-value ref-dep))))
4031 (if (string= id ref)
4032 ;; Yuk! This is a reference loop. Make the article be a
4035 (mail-header-set-references (car (symbol-value id-dep)) "none")
4037 (setq parent-id nil))
4038 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4039 (setq ref-dep (intern (or parent-id "none") dependencies))
4040 (if (boundp ref-dep)
4041 (setcdr (symbol-value ref-dep)
4042 (nconc (cdr (symbol-value ref-dep))
4043 (list (symbol-value id-dep))))
4044 (set ref-dep (list nil (symbol-value id-dep)))))
4047 (defun gnus-extract-message-id-from-in-reply-to (string)
4048 (if (string-match "<[^>]+>" string)
4049 (substring string (match-beginning 0) (match-end 0))
4052 (defun gnus-build-sparse-threads ()
4053 (let ((headers gnus-newsgroup-headers)
4054 (mail-parse-charset gnus-newsgroup-charset)
4055 (gnus-summary-ignore-duplicates t)
4056 header references generation relations
4057 subject child end new-child date)
4058 ;; First we create an alist of generations/relations, where
4059 ;; generations is how much we trust the relation, and the relation
4061 (gnus-message 7 "Making sparse threads...")
4063 (nnheader-set-temp-buffer " *gnus sparse threads*")
4064 (while (setq header (pop headers))
4065 (when (and (setq references (mail-header-references header))
4066 (not (string= references "")))
4068 (setq child (mail-header-id header)
4069 subject (mail-header-subject header)
4070 date (mail-header-date header)
4072 (while (search-backward ">" nil t)
4073 (setq end (1+ (point)))
4074 (when (search-backward "<" nil t)
4075 (setq new-child (buffer-substring (point) end))
4076 (push (list (incf generation)
4077 child (setq child new-child)
4081 (push (list (1+ generation) child nil subject) relations))
4083 (kill-buffer (current-buffer)))
4084 ;; Sort over trustworthiness.
4087 (when (gnus-dependencies-add-header
4088 (make-full-mail-header-from-decoded-header
4089 gnus-reffed-article-number
4090 (nth 3 relation) "" (or (nth 4 relation) "")
4092 (or (nth 2 relation) "") 0 0 "")
4093 gnus-newsgroup-dependencies nil)
4094 (push gnus-reffed-article-number gnus-newsgroup-limit)
4095 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4096 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4097 gnus-newsgroup-reads)
4098 (decf gnus-reffed-article-number)))
4099 (sort relations 'car-less-than-car))
4100 (gnus-message 7 "Making sparse threads...done")))
4102 (defun gnus-build-old-threads ()
4103 ;; Look at all the articles that refer back to old articles, and
4104 ;; fetch the headers for the articles that aren't there. This will
4105 ;; build complete threads - if the roots haven't been expired by the
4107 (let ((mail-parse-charset gnus-newsgroup-charset)
4111 (when (not (car (symbol-value refs)))
4112 (setq heads (cdr (symbol-value refs)))
4114 (if (memq (mail-header-number (caar heads))
4115 gnus-newsgroup-dormant)
4116 (setq heads (cdr heads))
4117 (setq id (symbol-name refs))
4118 (while (and (setq id (gnus-build-get-header id))
4119 (not (car (gnus-id-to-thread id)))))
4120 (setq heads nil)))))
4121 gnus-newsgroup-dependencies)))
4123 (defsubst gnus-remove-odd-characters (string)
4124 "Translate STRING into something that doesn't contain weird characters."
4125 (mm-subst-char-in-string
4127 (mm-subst-char-in-string ?\n ?\- string t) t))
4129 ;; This function has to be called with point after the article number
4130 ;; on the beginning of the line.
4131 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4132 (let ((eol (point-at-eol))
4133 (buffer (current-buffer))
4134 header references in-reply-to)
4136 ;; overview: [num subject from date id refs chars lines misc]
4139 (narrow-to-region (point) eol)
4144 (make-full-mail-header
4146 (nnheader-nov-field) ; subject
4147 (nnheader-nov-field) ; from
4148 (nnheader-nov-field) ; date
4149 (nnheader-nov-read-message-id number) ; id
4150 (setq references (nnheader-nov-field)) ; refs
4151 (nnheader-nov-read-integer) ; chars
4152 (nnheader-nov-read-integer) ; lines
4154 (if (looking-at "Xref: ")
4155 (goto-char (match-end 0)))
4156 (nnheader-nov-field)) ; Xref
4157 (nnheader-nov-parse-extra)))) ; extra
4161 (when (and (string= references "")
4162 (setq in-reply-to (mail-header-extra header))
4163 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4164 (mail-header-set-references
4165 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4167 (when gnus-alter-header-function
4168 (funcall gnus-alter-header-function header))
4169 (gnus-dependencies-add-header header dependencies force-new)))
4171 (defun gnus-build-get-header (id)
4172 "Look through the buffer of NOV lines and find the header to ID.
4173 Enter this line into the dependencies hash table, and return
4174 the id of the parent article (if any)."
4175 (let ((deps gnus-newsgroup-dependencies)
4179 (set-buffer nntp-server-buffer)
4180 (let ((case-fold-search nil))
4181 (goto-char (point-min))
4182 (while (and (not found)
4183 (search-forward id nil t))
4185 (setq found (looking-at
4186 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4187 (regexp-quote id))))
4188 (or found (beginning-of-line 2)))
4192 (setq header (gnus-nov-parse-line
4193 (read (current-buffer)) deps))
4194 (gnus-parent-id (mail-header-references header))))))
4196 (let ((number (mail-header-number header)))
4197 (push number gnus-newsgroup-limit)
4198 (push header gnus-newsgroup-headers)
4199 (if (memq number gnus-newsgroup-unselected)
4201 (setq gnus-newsgroup-unreads
4202 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4204 (setq gnus-newsgroup-unselected
4205 (delq number gnus-newsgroup-unselected)))
4206 (push number gnus-newsgroup-ancient)))))))
4208 (defun gnus-build-all-threads ()
4209 "Read all the headers."
4210 (let ((gnus-summary-ignore-duplicates t)
4211 (mail-parse-charset gnus-newsgroup-charset)
4212 (dependencies gnus-newsgroup-dependencies)
4215 (set-buffer nntp-server-buffer)
4216 (let ((case-fold-search nil))
4217 (goto-char (point-min))
4220 (setq article (read (current-buffer))
4221 header (gnus-nov-parse-line article dependencies)))
4223 (with-current-buffer gnus-summary-buffer
4224 (push header gnus-newsgroup-headers)
4225 (if (memq (setq article (mail-header-number header))
4226 gnus-newsgroup-unselected)
4228 (setq gnus-newsgroup-unreads
4229 (gnus-add-to-sorted-list
4230 gnus-newsgroup-unreads article))
4231 (setq gnus-newsgroup-unselected
4232 (delq article gnus-newsgroup-unselected)))
4233 (push article gnus-newsgroup-ancient)))
4234 (forward-line 1)))))))
4236 (defun gnus-summary-update-article-line (article header)
4237 "Update the line for ARTICLE using HEADER."
4238 (let* ((id (mail-header-id header))
4239 (thread (gnus-id-to-thread id)))
4241 (error "Article in no thread"))
4242 ;; Update the thread.
4243 (setcar thread header)
4244 (gnus-summary-goto-subject article)
4245 (let* ((datal (gnus-data-find-list article))
4247 (buffer-read-only nil)
4248 (level (gnus-summary-thread-level)))
4250 (let ((inserted (- (point)
4252 (gnus-summary-insert-line
4254 (memq article gnus-newsgroup-undownloaded)
4255 (gnus-article-mark article)
4256 (memq article gnus-newsgroup-replied)
4257 (memq article gnus-newsgroup-expirable)
4258 ;; Only insert the Subject string when it's different
4259 ;; from the previous Subject string.
4264 (mail-header-subject
4267 (gnus-data-find-list
4269 (gnus-data-list t)))))
4270 ;; Error on the side of excessive subjects.
4272 (mail-header-subject header)))
4274 (mail-header-subject header))
4275 nil (cdr (assq article gnus-newsgroup-scored))
4276 (memq article gnus-newsgroup-processable))
4279 (gnus-data-update-list
4281 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4283 (defun gnus-summary-update-article (article &optional iheader)
4284 "Update ARTICLE in the summary buffer."
4285 (set-buffer gnus-summary-buffer)
4286 (let* ((header (gnus-summary-article-header article))
4287 (id (mail-header-id header))
4288 (data (gnus-data-find article))
4289 (thread (gnus-id-to-thread id))
4290 (references (mail-header-references header))
4294 (when (and references
4295 (not (equal "" references)))
4298 (buffer-read-only nil)
4304 (delq thread parent)))
4305 (if (gnus-summary-insert-subject id header)
4306 ;; Set the (possibly) new article number in the data structure.
4307 (gnus-data-set-number data (gnus-id-to-article id))
4311 (defun gnus-rebuild-thread (id &optional line)
4312 "Rebuild the thread containing ID.
4313 If LINE, insert the rebuilt thread starting on line LINE."
4314 (let ((buffer-read-only nil)
4315 old-pos current thread data)
4316 (if (not gnus-show-threads)
4317 (setq thread (list (car (gnus-id-to-thread id))))
4318 ;; Get the thread this article is part of.
4319 (setq thread (gnus-remove-thread id)))
4320 (setq old-pos (point-at-bol))
4321 (setq current (save-excursion
4322 (and (re-search-backward "[\r\n]" nil t)
4323 (gnus-summary-article-number))))
4324 ;; If this is a gathered thread, we have to go some re-gathering.
4325 (when (stringp (car thread))
4326 (let ((subject (car thread))
4328 (setq thread (cdr thread))
4330 (unless (memq (setq thr (gnus-id-to-thread
4332 (mail-header-id (caar thread)))))
4335 (setq thread (cdr thread)))
4336 ;; We now have all (unique) roots.
4337 (if (= (length roots) 1)
4338 ;; All the loose roots are now one solid root.
4339 (setq thread (car roots))
4340 (setq thread (cons subject (gnus-sort-threads roots))))))
4342 ;; We then insert this thread into the summary buffer.
4344 (goto-char (point-min))
4345 (forward-line (1- line)))
4346 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4347 (if gnus-show-threads
4348 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4349 (gnus-summary-prepare-unthreaded thread))
4350 (setq data (nreverse gnus-newsgroup-data))
4351 (setq threads gnus-newsgroup-threads))
4352 ;; We splice the new data into the data structure.
4353 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4354 ;;!!! then we want to insert at the beginning of the buffer.
4355 ;;!!! That happens to be true with Gnus now, but that may
4356 ;;!!! change in the future. Perhaps.
4357 (gnus-data-enter-list
4358 (if line nil current) data (- (point) old-pos))
4359 (setq gnus-newsgroup-threads
4360 (nconc threads gnus-newsgroup-threads))
4361 (gnus-data-compute-positions))))
4363 (defun gnus-number-to-header (number)
4364 "Return the header for article NUMBER."
4365 (let ((headers gnus-newsgroup-headers))
4367 (not (= number (mail-header-number (car headers)))))
4372 (defun gnus-parent-headers (in-headers &optional generation)
4373 "Return the headers of the GENERATIONeth parent of HEADERS."
4375 (setq generation 1))
4377 (headers in-headers)
4380 (not (zerop generation))
4381 (setq references (mail-header-references headers)))
4382 (setq headers (if (and references
4383 (setq parent (gnus-parent-id references)))
4384 (car (gnus-id-to-thread parent))
4387 (and (not (eq headers in-headers))
4390 (defun gnus-id-to-thread (id)
4391 "Return the (sub-)thread where ID appears."
4392 (gnus-gethash id gnus-newsgroup-dependencies))
4394 (defun gnus-id-to-article (id)
4395 "Return the article number of ID."
4396 (let ((thread (gnus-id-to-thread id)))
4399 (mail-header-number (car thread)))))
4401 (defun gnus-id-to-header (id)
4402 "Return the article headers of ID."
4403 (car (gnus-id-to-thread id)))
4405 (defun gnus-article-displayed-root-p (article)
4406 "Say whether ARTICLE is a root(ish) article."
4407 (let ((level (gnus-summary-thread-level article))
4408 (refs (mail-header-references (gnus-summary-article-header article)))
4414 ((null (gnus-parent-id refs)) t)
4416 (null (setq particle (gnus-id-to-article
4417 (gnus-parent-id refs))))
4418 (null (gnus-summary-thread-level particle)))))))
4420 (defun gnus-root-id (id)
4421 "Return the id of the root of the thread where ID appears."
4423 (while (and id (setq prev (car (gnus-id-to-thread id))))
4425 id (gnus-parent-id (mail-header-references prev))))
4428 (defun gnus-articles-in-thread (thread)
4429 "Return the list of articles in THREAD."
4430 (cons (mail-header-number (car thread))
4431 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4433 (defun gnus-remove-thread (id &optional dont-remove)
4434 "Remove the thread that has ID in it."
4435 (let (headers thread last-id)
4436 ;; First go up in this thread until we find the root.
4437 (setq last-id (gnus-root-id id)
4438 headers (message-flatten-list (gnus-id-to-thread last-id)))
4439 ;; We have now found the real root of this thread. It might have
4440 ;; been gathered into some loose thread, so we have to search
4441 ;; through the threads to find the thread we wanted.
4442 (let ((threads gnus-newsgroup-threads)
4445 (setq sub (car threads))
4446 (if (stringp (car sub))
4447 ;; This is a gathered thread, so we look at the roots
4448 ;; below it to find whether this article is in this
4451 (setq sub (cdr sub))
4453 (when (member (caar sub) headers)
4454 (setq thread (car threads)
4457 (setq sub (cdr sub))))
4458 ;; It's an ordinary thread, so we check it.
4459 (when (eq (car sub) (car headers))
4462 (setq threads (cdr threads)))
4463 ;; If this article is in no thread, then it's a root.
4466 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4467 (setq thread (gnus-id-to-thread last-id)))
4470 thread ; We return this thread.
4472 (if (stringp (car thread))
4474 ;; If we use dummy roots, then we have to remove the
4475 ;; dummy root as well.
4476 (when (eq gnus-summary-make-false-root 'dummy)
4477 ;; We go to the dummy root by going to
4478 ;; the first sub-"thread", and then one line up.
4479 (gnus-summary-goto-article
4480 (mail-header-number (caadr thread)))
4483 (gnus-data-compute-positions))
4484 (setq thread (cdr thread))
4486 (gnus-remove-thread-1 (car thread))
4487 (setq thread (cdr thread))))
4488 (gnus-remove-thread-1 thread))))))))
4490 (defun gnus-remove-thread-1 (thread)
4491 "Remove the thread THREAD recursively."
4492 (let ((number (mail-header-number (pop thread)))
4494 (setq thread (reverse thread))
4496 (gnus-remove-thread-1 (pop thread)))
4497 (when (setq d (gnus-data-find number))
4498 (goto-char (gnus-data-pos d))
4499 (gnus-summary-show-thread)
4505 (gnus-delete-line)))))))
4507 (defun gnus-sort-threads-1 (threads func)
4508 (sort (mapcar (lambda (thread)
4511 (gnus-sort-threads-1 (cdr thread) func))))
4514 (defun gnus-sort-threads (threads)
4516 (if (not gnus-thread-sort-functions)
4518 (gnus-message 8 "Sorting threads...")
4519 (let ((max-lisp-eval-depth 5000))
4520 (prog1 (gnus-sort-threads-1
4522 (gnus-make-sort-function gnus-thread-sort-functions))
4523 (gnus-message 8 "Sorting threads...done")))))
4525 (defun gnus-sort-articles (articles)
4527 (when gnus-article-sort-functions
4528 (gnus-message 7 "Sorting articles...")
4530 (setq gnus-newsgroup-headers
4531 (sort articles (gnus-make-sort-function
4532 gnus-article-sort-functions)))
4533 (gnus-message 7 "Sorting articles...done"))))
4535 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4536 (defmacro gnus-thread-header (thread)
4537 "Return header of first article in THREAD.
4538 Note that THREAD must never, ever be anything else than a variable -
4539 using some other form will lead to serious barfage."
4540 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4541 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4542 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4545 (defsubst gnus-article-sort-by-number (h1 h2)
4546 "Sort articles by article number."
4547 (< (mail-header-number h1)
4548 (mail-header-number h2)))
4550 (defun gnus-thread-sort-by-number (h1 h2)
4551 "Sort threads by root article number."
4552 (gnus-article-sort-by-number
4553 (gnus-thread-header h1) (gnus-thread-header h2)))
4555 (defsubst gnus-article-sort-by-random (h1 h2)
4556 "Sort articles by article number."
4559 (defun gnus-thread-sort-by-random (h1 h2)
4560 "Sort threads by root article number."
4561 (gnus-article-sort-by-random
4562 (gnus-thread-header h1) (gnus-thread-header h2)))
4564 (defsubst gnus-article-sort-by-lines (h1 h2)
4565 "Sort articles by article Lines header."
4566 (< (mail-header-lines h1)
4567 (mail-header-lines h2)))
4569 (defun gnus-thread-sort-by-lines (h1 h2)
4570 "Sort threads by root article Lines header."
4571 (gnus-article-sort-by-lines
4572 (gnus-thread-header h1) (gnus-thread-header h2)))
4574 (defsubst gnus-article-sort-by-chars (h1 h2)
4575 "Sort articles by octet length."
4576 (< (mail-header-chars h1)
4577 (mail-header-chars h2)))
4579 (defun gnus-thread-sort-by-chars (h1 h2)
4580 "Sort threads by root article octet length."
4581 (gnus-article-sort-by-chars
4582 (gnus-thread-header h1) (gnus-thread-header h2)))
4584 (defsubst gnus-article-sort-by-author (h1 h2)
4585 "Sort articles by root author."
4587 (let ((addr (car (mime-entity-read-field h1 'From))))
4588 (or (std11-full-name-string addr)
4589 (std11-address-string addr)
4591 (let ((addr (car (mime-entity-read-field h2 'From))))
4592 (or (std11-full-name-string addr)
4593 (std11-address-string addr)
4597 (defun gnus-thread-sort-by-author (h1 h2)
4598 "Sort threads by root author."
4599 (gnus-article-sort-by-author
4600 (gnus-thread-header h1) (gnus-thread-header h2)))
4602 (defsubst gnus-article-sort-by-recipient (h1 h2)
4603 "Sort articles by recipient."
4605 (let ((extract (funcall
4606 gnus-extract-address-components
4607 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4608 (or (car extract) (cadr extract)))
4609 (let ((extract (funcall
4610 gnus-extract-address-components
4611 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4612 (or (car extract) (cadr extract)))))
4614 (defun gnus-thread-sort-by-recipient (h1 h2)
4615 "Sort threads by root recipient."
4616 (gnus-article-sort-by-recipient
4617 (gnus-thread-header h1) (gnus-thread-header h2)))
4619 (defsubst gnus-article-sort-by-subject (h1 h2)
4620 "Sort articles by root subject."
4622 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4623 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4625 (defun gnus-thread-sort-by-subject (h1 h2)
4626 "Sort threads by root subject."
4627 (gnus-article-sort-by-subject
4628 (gnus-thread-header h1) (gnus-thread-header h2)))
4630 (defsubst gnus-article-sort-by-date (h1 h2)
4631 "Sort articles by root article date."
4633 (gnus-date-get-time (mail-header-date h1))
4634 (gnus-date-get-time (mail-header-date h2))))
4636 (defun gnus-thread-sort-by-date (h1 h2)
4637 "Sort threads by root article date."
4638 (gnus-article-sort-by-date
4639 (gnus-thread-header h1) (gnus-thread-header h2)))
4641 (defsubst gnus-article-sort-by-score (h1 h2)
4642 "Sort articles by root article score.
4643 Unscored articles will be counted as having a score of zero."
4644 (> (or (cdr (assq (mail-header-number h1)
4645 gnus-newsgroup-scored))
4646 gnus-summary-default-score 0)
4647 (or (cdr (assq (mail-header-number h2)
4648 gnus-newsgroup-scored))
4649 gnus-summary-default-score 0)))
4651 (defun gnus-thread-sort-by-score (h1 h2)
4652 "Sort threads by root article score."
4653 (gnus-article-sort-by-score
4654 (gnus-thread-header h1) (gnus-thread-header h2)))
4656 (defun gnus-thread-sort-by-total-score (h1 h2)
4657 "Sort threads by the sum of all scores in the thread.
4658 Unscored articles will be counted as having a score of zero."
4659 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4661 (defun gnus-thread-total-score (thread)
4662 ;; This function find the total score of THREAD.
4667 (if (stringp (car thread))
4668 (apply gnus-thread-score-function 0
4669 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4670 (gnus-thread-total-score-1 thread)))
4672 (gnus-thread-total-score-1 (list thread)))))
4674 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4675 "Sort threads such that the thread with the most recently arrived article comes first."
4676 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4678 (defun gnus-thread-highest-number (thread)
4679 "Return the highest article number in THREAD."
4680 (apply 'max (mapcar (lambda (header)
4681 (mail-header-number header))
4682 (message-flatten-list thread))))
4684 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4685 "Sort threads such that the thread with the most recently dated article comes first."
4686 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4688 (defun gnus-thread-latest-date (thread)
4689 "Return the highest article date in THREAD."
4690 (let ((previous-time 0))
4696 (time-to-seconds (mail-header-parse-date
4697 (mail-header-date header)))
4698 (error previous-time))))
4700 (message-flatten-list thread)
4702 (< (mail-header-number h1)
4703 (mail-header-number h2))))))))
4705 (defun gnus-thread-total-score-1 (root)
4706 ;; This function find the total score of the thread below ROOT.
4707 (setq root (car root))
4708 (apply gnus-thread-score-function
4710 (mapcar 'gnus-thread-total-score
4711 (cdr (gnus-id-to-thread (mail-header-id root))))
4712 (when (> (mail-header-number root) 0)
4713 (list (or (cdr (assq (mail-header-number root)
4714 gnus-newsgroup-scored))
4715 gnus-summary-default-score 0))))
4716 (list gnus-summary-default-score)
4719 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4720 (defvar gnus-tmp-prev-subject nil)
4721 (defvar gnus-tmp-false-parent nil)
4722 (defvar gnus-tmp-root-expunged nil)
4723 (defvar gnus-tmp-dummy-line nil)
4725 (eval-when-compile (defvar gnus-tmp-header))
4726 (defun gnus-extra-header (type &optional header)
4727 "Return the extra header of TYPE."
4728 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4731 (defvar gnus-tmp-thread-tree-header-string "")
4733 (defcustom gnus-sum-thread-tree-root "> "
4734 "With %B spec, used for the root of a thread.
4735 If nil, use subject instead."
4737 :type '(radio (const :format "%v " nil) string)
4738 :group 'gnus-thread)
4740 (defcustom gnus-sum-thread-tree-false-root "> "
4741 "With %B spec, used for a false root of a thread.
4742 If nil, use subject instead."
4744 :type '(radio (const :format "%v " nil) string)
4745 :group 'gnus-thread)
4747 (defcustom gnus-sum-thread-tree-single-indent ""
4748 "With %B spec, used for a thread with just one message.
4749 If nil, use subject instead."
4751 :type '(radio (const :format "%v " nil) string)
4752 :group 'gnus-thread)
4754 (defcustom gnus-sum-thread-tree-vertical "| "
4755 "With %B spec, used for drawing a vertical line."
4758 :group 'gnus-thread)
4760 (defcustom gnus-sum-thread-tree-indent " "
4761 "With %B spec, used for indenting."
4764 :group 'gnus-thread)
4766 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4767 "With %B spec, used for a leaf with brothers."
4770 :group 'gnus-thread)
4772 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4773 "With %B spec, used for a leaf without brothers."
4776 :group 'gnus-thread)
4778 (defun gnus-summary-prepare-threads (threads)
4779 "Prepare summary buffer from THREADS and indentation LEVEL.
4780 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4781 or a straight list of headers."
4782 (gnus-message 7 "Generating summary...")
4784 (setq gnus-newsgroup-threads threads)
4787 (let ((gnus-tmp-level 0)
4788 (default-score (or gnus-summary-default-score 0))
4789 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4790 (building-line-count gnus-summary-display-while-building)
4791 (building-count (integerp gnus-summary-display-while-building))
4792 thread number subject stack state gnus-tmp-gathered beg-match
4793 new-roots gnus-tmp-new-adopts thread-end simp-subject
4794 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4795 gnus-tmp-replied gnus-tmp-subject-or-nil
4796 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4797 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4798 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4801 (setq gnus-tmp-prev-subject nil
4802 gnus-tmp-thread-tree-header-string "")
4804 (if (vectorp (car threads))
4805 ;; If this is a straight (sic) list of headers, then a
4806 ;; threaded summary display isn't required, so we just create
4807 ;; an unthreaded one.
4808 (gnus-summary-prepare-unthreaded threads)
4810 ;; Do the threaded display.
4812 (if gnus-summary-display-while-building
4813 (switch-to-buffer (buffer-name)))
4814 (while (or threads stack gnus-tmp-new-adopts new-roots)
4816 (if (and (= gnus-tmp-level 0)
4819 (not gnus-tmp-false-parent)
4820 (or gnus-tmp-new-adopts new-roots))
4821 (if gnus-tmp-new-adopts
4822 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4823 thread (list (car gnus-tmp-new-adopts))
4824 gnus-tmp-header (caar thread)
4825 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4827 (setq thread (list (car new-roots))
4828 gnus-tmp-header (caar thread)
4829 new-roots (cdr new-roots))))
4832 ;; If there are some threads, we do them before the
4833 ;; threads on the stack.
4834 (setq thread threads
4835 gnus-tmp-header (caar thread))
4836 ;; There were no current threads, so we pop something off
4838 (setq state (car stack)
4839 gnus-tmp-level (car state)
4840 tree-stack (cadr state)
4841 thread (caddr state)
4843 gnus-tmp-header (caar thread))))
4845 (setq gnus-tmp-false-parent nil)
4846 (setq gnus-tmp-root-expunged nil)
4847 (setq thread-end nil)
4849 (if (stringp gnus-tmp-header)
4850 ;; The header is a dummy root.
4852 ((eq gnus-summary-make-false-root 'adopt)
4853 ;; We let the first article adopt the rest.
4854 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4856 (setq gnus-tmp-gathered
4858 (lambda (h) (mail-header-number (car h)))
4861 (setq thread (cons (list (caar thread)
4864 (setq gnus-tmp-level -1
4865 gnus-tmp-false-parent t))
4866 ((eq gnus-summary-make-false-root 'empty)
4867 ;; We print adopted articles with empty subject fields.
4868 (setq gnus-tmp-gathered
4870 (lambda (h) (mail-header-number (car h)))
4873 (setq gnus-tmp-level -1))
4874 ((eq gnus-summary-make-false-root 'dummy)
4875 ;; We remember that we probably want to output a dummy
4877 (setq gnus-tmp-dummy-line gnus-tmp-header)
4878 (setq gnus-tmp-prev-subject gnus-tmp-header))
4880 ;; We do not make a root for the gathered
4881 ;; sub-threads at all.
4882 (setq gnus-tmp-level -1)))
4884 (setq number (mail-header-number gnus-tmp-header)
4885 subject (mail-header-subject gnus-tmp-header)
4886 simp-subject (gnus-simplify-subject-fully subject))
4889 ;; If the thread has changed subject, we might want to make
4890 ;; this subthread into a root.
4891 ((and (null gnus-thread-ignore-subject)
4892 (not (zerop gnus-tmp-level))
4893 gnus-tmp-prev-subject
4894 (not (string= gnus-tmp-prev-subject simp-subject)))
4895 (setq new-roots (nconc new-roots (list (car thread)))
4897 gnus-tmp-header nil))
4898 ;; If the article lies outside the current limit,
4899 ;; then we do not display it.
4900 ((not (memq number gnus-newsgroup-limit))
4901 (setq gnus-tmp-gathered
4903 (lambda (h) (mail-header-number (car h)))
4906 (setq gnus-tmp-new-adopts (if (cdar thread)
4907 (append gnus-tmp-new-adopts
4909 gnus-tmp-new-adopts)
4911 gnus-tmp-header nil)
4912 (when (zerop gnus-tmp-level)
4913 (setq gnus-tmp-root-expunged t)))
4914 ;; Perhaps this article is to be marked as read?
4915 ((and gnus-summary-mark-below
4916 (< (or (cdr (assq number gnus-newsgroup-scored))
4918 gnus-summary-mark-below)
4919 ;; Don't touch sparse articles.
4920 (not (gnus-summary-article-sparse-p number))
4921 (not (gnus-summary-article-ancient-p number)))
4922 (setq gnus-newsgroup-unreads
4923 (delq number gnus-newsgroup-unreads))
4924 (if gnus-newsgroup-auto-expire
4925 (setq gnus-newsgroup-expirable
4926 (gnus-add-to-sorted-list
4927 gnus-newsgroup-expirable number))
4928 (push (cons number gnus-low-score-mark)
4929 gnus-newsgroup-reads))))
4931 (when gnus-tmp-header
4932 ;; We may have an old dummy line to output before this
4934 (when (and gnus-tmp-dummy-line
4937 (mail-header-subject gnus-tmp-header)))
4938 (gnus-summary-insert-dummy-line
4939 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4940 (setq gnus-tmp-dummy-line nil))
4942 ;; Compute the mark.
4943 (setq gnus-tmp-unread (gnus-article-mark number))
4945 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4946 gnus-tmp-header gnus-tmp-level)
4947 gnus-newsgroup-data)
4949 ;; Actually insert the line.
4951 gnus-tmp-subject-or-nil
4953 ((and gnus-thread-ignore-subject
4954 gnus-tmp-prev-subject
4955 (not (string= gnus-tmp-prev-subject simp-subject)))
4957 ((zerop gnus-tmp-level)
4958 (if (and (eq gnus-summary-make-false-root 'empty)
4959 (memq number gnus-tmp-gathered)
4960 gnus-tmp-prev-subject
4961 (string= gnus-tmp-prev-subject simp-subject))
4962 gnus-summary-same-subject
4964 (t gnus-summary-same-subject)))
4965 (if (and (eq gnus-summary-make-false-root 'adopt)
4966 (= gnus-tmp-level 1)
4967 (memq number gnus-tmp-gathered))
4968 (setq gnus-tmp-opening-bracket ?\<
4969 gnus-tmp-closing-bracket ?\>)
4970 (setq gnus-tmp-opening-bracket ?\[
4971 gnus-tmp-closing-bracket ?\]))
4973 gnus-tmp-indentation
4974 (aref gnus-thread-indent-array gnus-tmp-level)
4975 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4976 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4977 gnus-summary-default-score 0)
4979 (if (or (null gnus-summary-default-score)
4980 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4981 gnus-summary-zcore-fuzz))
4983 (if (< gnus-tmp-score gnus-summary-default-score)
4984 gnus-score-below-mark gnus-score-over-mark))
4986 (cond ((memq number gnus-newsgroup-processable)
4988 ((memq number gnus-newsgroup-cached)
4990 ((memq number gnus-newsgroup-replied)
4992 ((memq number gnus-newsgroup-forwarded)
4993 gnus-forwarded-mark)
4994 ((memq number gnus-newsgroup-saved)
4996 ((memq number gnus-newsgroup-recent)
4998 ((memq number gnus-newsgroup-unseen)
5002 (cond ((memq number gnus-newsgroup-undownloaded)
5003 gnus-undownloaded-mark)
5004 (gnus-newsgroup-agentized
5005 gnus-downloaded-mark)
5008 gnus-tmp-from (mail-header-from gnus-tmp-header)
5011 ((string-match "<[^>]+> *$" gnus-tmp-from)
5012 (setq beg-match (match-beginning 0))
5013 (or (and (string-match "^\".+\"" gnus-tmp-from)
5014 (substring gnus-tmp-from 1 (1- (match-end 0))))
5015 (substring gnus-tmp-from 0 beg-match)))
5016 ((string-match "(.+)" gnus-tmp-from)
5017 (substring gnus-tmp-from
5018 (1+ (match-beginning 0)) (1- (match-end 0))))
5022 gnus-tmp-thread-tree-header-string
5024 ((not gnus-show-threads) "")
5025 ((zerop gnus-tmp-level)
5026 (cond ((cdar thread)
5027 (or gnus-sum-thread-tree-root subject))
5028 (gnus-tmp-new-adopts
5029 (or gnus-sum-thread-tree-false-root subject))
5031 (or gnus-sum-thread-tree-single-indent subject))))
5033 (concat (apply 'concat
5034 (mapcar (lambda (item)
5036 gnus-sum-thread-tree-vertical
5037 gnus-sum-thread-tree-indent))
5038 (cdr (reverse tree-stack))))
5040 gnus-sum-thread-tree-leaf-with-other
5041 gnus-sum-thread-tree-single-leaf)))))
5042 (when (string= gnus-tmp-name "")
5043 (setq gnus-tmp-name gnus-tmp-from))
5044 (unless (numberp gnus-tmp-lines)
5045 (setq gnus-tmp-lines -1))
5046 (if (= gnus-tmp-lines -1)
5047 (setq gnus-tmp-lines "?")
5048 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5049 (gnus-put-text-property
5051 (progn (eval gnus-summary-line-format-spec) (point))
5052 'gnus-number number)
5055 (gnus-run-hooks 'gnus-summary-update-hook)
5058 (setq gnus-tmp-prev-subject simp-subject)))
5060 (when (nth 1 thread)
5061 (push (list (max 0 gnus-tmp-level)
5062 (copy-sequence tree-stack)
5065 (push (if (nth 1 thread) 1 0) tree-stack)
5066 (incf gnus-tmp-level)
5067 (setq threads (if thread-end nil (cdar thread)))
5068 (if gnus-summary-display-while-building
5071 ;; use a set frequency
5072 (setq building-line-count (1- building-line-count))
5073 (when (= building-line-count 0)
5075 (setq building-line-count
5076 gnus-summary-display-while-building)))
5080 (setq gnus-tmp-level 0)))))
5081 (gnus-message 7 "Generating summary...done"))
5083 (defun gnus-summary-prepare-unthreaded (headers)
5084 "Generate an unthreaded summary buffer based on HEADERS."
5085 (let (header number mark)
5090 ;; We may have to root out some bad articles...
5091 (when (memq (setq number (mail-header-number
5092 (setq header (pop headers))))
5093 gnus-newsgroup-limit)
5094 ;; Mark article as read when it has a low score.
5095 (when (and gnus-summary-mark-below
5096 (< (or (cdr (assq number gnus-newsgroup-scored))
5097 gnus-summary-default-score 0)
5098 gnus-summary-mark-below)
5099 (not (gnus-summary-article-ancient-p number)))
5100 (setq gnus-newsgroup-unreads
5101 (delq number gnus-newsgroup-unreads))
5102 (if gnus-newsgroup-auto-expire
5103 (push number gnus-newsgroup-expirable)
5104 (push (cons number gnus-low-score-mark)
5105 gnus-newsgroup-reads)))
5107 (setq mark (gnus-article-mark number))
5108 (push (gnus-data-make number mark (1+ (point)) header 0)
5109 gnus-newsgroup-data)
5110 (gnus-summary-insert-line
5112 (memq number gnus-newsgroup-undownloaded)
5113 mark (memq number gnus-newsgroup-replied)
5114 (memq number gnus-newsgroup-expirable)
5115 (mail-header-subject header) nil
5116 (cdr (assq number gnus-newsgroup-scored))
5117 (memq number gnus-newsgroup-processable))))))
5119 (defun gnus-summary-remove-list-identifiers ()
5120 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5121 (let ((regexp (if (consp gnus-list-identifiers)
5122 (mapconcat 'identity gnus-list-identifiers " *\\|")
5123 gnus-list-identifiers))
5126 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5127 (dolist (header gnus-newsgroup-headers)
5128 (setq subject (mail-header-subject header)
5130 (while (string-match regexp subject)
5132 (concat (substring subject 0 (match-beginning 1))
5133 (substring subject (match-end 0)))
5136 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5138 (concat (substring subject 0 (match-beginning 1))
5139 (substring subject (match-end 1)))))
5140 (mail-header-set-subject header subject))))))
5142 (defun gnus-fetch-headers (articles)
5143 "Fetch headers of ARTICLES."
5144 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5145 (gnus-message 5 "Fetching headers for %s..." name)
5148 (setq gnus-headers-retrieved-by
5149 (gnus-retrieve-headers
5150 articles gnus-newsgroup-name
5151 ;; We might want to fetch old headers, but
5152 ;; not if there is only 1 article.
5154 (not (eq gnus-fetch-old-headers 'some))
5155 (not (numberp gnus-fetch-old-headers)))
5156 (> (length articles) 1))
5157 gnus-fetch-old-headers))))
5158 (gnus-get-newsgroup-headers-xover
5159 articles nil nil gnus-newsgroup-name t)
5160 (gnus-get-newsgroup-headers))
5161 (gnus-message 5 "Fetching headers for %s...done" name))))
5163 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5164 "Select newsgroup GROUP.
5165 If READ-ALL is non-nil, all articles in the group are selected.
5166 If SELECT-ARTICLES, only select those articles from GROUP."
5167 (let* ((entry (gnus-group-entry group))
5168 ;;!!! Dirty hack; should be removed.
5169 (gnus-summary-ignore-duplicates
5170 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5172 gnus-summary-ignore-duplicates))
5173 (info (nth 2 entry))
5174 articles fetched-articles cached)
5176 (unless (gnus-check-server
5177 (set (make-local-variable 'gnus-current-select-method)
5178 (gnus-find-method-for-group group)))
5179 (error "Couldn't open server"))
5181 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5182 (gnus-activate-group group) ; Or we can activate it...
5183 (progn ; Or we bug out.
5184 (when (equal major-mode 'gnus-summary-mode)
5185 (gnus-kill-buffer (current-buffer)))
5186 (error "Couldn't activate group %s: %s"
5187 group (gnus-status-message group))))
5189 (unless (gnus-request-group group t)
5190 (when (equal major-mode 'gnus-summary-mode)
5191 (gnus-kill-buffer (current-buffer)))
5192 (error "Couldn't request group %s: %s"
5193 group (gnus-status-message group)))
5196 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5198 (setq gnus-summary-use-undownloaded-faces
5199 (gnus-agent-find-parameter
5201 'agent-enable-undownloaded-faces)))
5203 (setq gnus-newsgroup-name group
5204 gnus-newsgroup-unselected nil
5205 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5207 (let ((display (gnus-group-find-parameter group 'display)))
5208 (setq gnus-newsgroup-display
5210 ((not (zerop (or (car-safe read-all) 0)))
5211 ;; The user entered the group with C-u SPC/RET, let's show
5217 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5219 ;; The following is probably the "correct" solution, but
5220 ;; it makes Gnus fetch all headers and then limit the
5221 ;; articles (which is slow), so instead we hack the
5222 ;; select-articles parameter instead. -- Simon Josefsson
5225 ;; (gnus-byte-compile
5226 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5228 (setq select-articles
5229 (gnus-uncompress-range
5230 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5234 (cdr (gnus-active group)))))
5239 (gnus-summary-setup-default-charset)
5241 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5242 (when (gnus-virtual-group-p group)
5243 (setq cached gnus-newsgroup-cached))
5245 (setq gnus-newsgroup-unreads
5246 (gnus-sorted-ndifference
5247 (gnus-sorted-ndifference gnus-newsgroup-unreads
5248 gnus-newsgroup-marked)
5249 gnus-newsgroup-dormant))
5251 (setq gnus-newsgroup-processable nil)
5253 (gnus-update-read-articles group gnus-newsgroup-unreads)
5255 ;; Adjust and set lists of article marks.
5257 (gnus-adjust-marked-articles info))
5258 (if (setq articles select-articles)
5259 (setq gnus-newsgroup-unselected
5260 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5261 (setq articles (gnus-articles-to-read group read-all)))
5265 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5267 ((eq articles 0) nil)
5269 ;; Init the dependencies hash table.
5270 (setq gnus-newsgroup-dependencies
5271 (gnus-make-hashtable (length articles)))
5272 (gnus-set-global-variables)
5273 ;; Retrieve the headers and read them in.
5275 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5277 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5279 (setq gnus-newsgroup-cached cached))
5281 ;; Suppress duplicates?
5282 (when gnus-suppress-duplicates
5283 (gnus-dup-suppress-articles))
5285 ;; Set the initial limit.
5286 (setq gnus-newsgroup-limit (copy-sequence articles))
5287 ;; Remove canceled articles from the list of unread articles.
5288 (setq fetched-articles
5289 (mapcar (lambda (headers) (mail-header-number headers))
5290 gnus-newsgroup-headers))
5291 (setq gnus-newsgroup-articles fetched-articles)
5292 (setq gnus-newsgroup-unreads
5293 (gnus-sorted-nintersection
5294 gnus-newsgroup-unreads fetched-articles))
5295 (gnus-compute-unseen-list)
5297 ;; Removed marked articles that do not exist.
5298 (gnus-update-missing-marks
5299 (gnus-sorted-difference articles fetched-articles))
5300 ;; We might want to build some more threads first.
5301 (when (and gnus-fetch-old-headers
5302 (eq gnus-headers-retrieved-by 'nov))
5303 (if (eq gnus-fetch-old-headers 'invisible)
5304 (gnus-build-all-threads)
5305 (gnus-build-old-threads)))
5306 ;; Let the Gnus agent mark articles as read.
5308 (gnus-agent-get-undownloaded-list))
5309 ;; Remove list identifiers from subject
5310 (when gnus-list-identifiers
5311 (gnus-summary-remove-list-identifiers))
5312 ;; Check whether auto-expire is to be done in this group.
5313 (setq gnus-newsgroup-auto-expire
5314 (gnus-group-auto-expirable-p group))
5315 ;; Set up the article buffer now, if necessary.
5316 (unless gnus-single-article-buffer
5317 (gnus-article-setup-buffer))
5318 ;; First and last article in this newsgroup.
5319 (when gnus-newsgroup-headers
5320 (setq gnus-newsgroup-begin
5321 (mail-header-number (car gnus-newsgroup-headers))
5324 (gnus-last-element gnus-newsgroup-headers))))
5325 ;; GROUP is successfully selected.
5326 (or gnus-newsgroup-headers t)))))
5328 (defun gnus-compute-unseen-list ()
5329 ;; The `seen' marks are treated specially.
5330 (if (not gnus-newsgroup-seen)
5331 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5332 (setq gnus-newsgroup-unseen
5333 (gnus-inverse-list-range-intersection
5334 gnus-newsgroup-articles gnus-newsgroup-seen))))
5336 (defun gnus-summary-display-make-predicate (display)
5337 (require 'gnus-agent)
5338 (when (= (length display) 1)
5339 (setq display (car display)))
5340 (unless gnus-summary-display-cache
5341 (dolist (elem (append '((unread . unread)
5344 gnus-article-mark-lists))
5345 (push (cons (cdr elem)
5347 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5348 gnus-summary-display-cache)))
5349 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5350 (gnus-category-predicate-cache gnus-summary-display-cache))
5351 (gnus-get-predicate display)))
5353 ;; Uses the dynamically bound `number' variable.
5356 (defun gnus-article-marked-p (type &optional article)
5357 (let ((article (or article number)))
5360 (memq article gnus-newsgroup-marked))
5362 (memq article gnus-newsgroup-spam-marked))
5364 (memq article gnus-newsgroup-unsendable))
5365 ((eq type 'undownload)
5366 (memq article gnus-newsgroup-undownloaded))
5367 ((eq type 'download)
5368 (memq article gnus-newsgroup-downloadable))
5370 (memq article gnus-newsgroup-unreads))
5372 (memq article gnus-newsgroup-reads))
5374 (memq article gnus-newsgroup-dormant) )
5376 (memq article gnus-newsgroup-expirable))
5378 (memq article gnus-newsgroup-replied))
5380 (memq article gnus-newsgroup-killed))
5381 ((eq type 'bookmark)
5382 (assq article gnus-newsgroup-bookmarks))
5384 (assq article gnus-newsgroup-scored))
5386 (memq article gnus-newsgroup-saved))
5388 (memq article gnus-newsgroup-cached))
5390 (memq article gnus-newsgroup-forwarded))
5392 (not (memq article gnus-newsgroup-unseen)))
5394 (memq article gnus-newsgroup-recent))
5397 (defun gnus-articles-to-read (group &optional read-all)
5398 "Find out what articles the user wants to read."
5400 ;; Select all articles if `read-all' is non-nil, or if there
5401 ;; are no unread articles.
5403 (and (zerop (length gnus-newsgroup-marked))
5404 (zerop (length gnus-newsgroup-unreads)))
5405 ;; Fetch all if the predicate is non-nil.
5406 gnus-newsgroup-display)
5407 ;; We want to select the headers for all the articles in
5408 ;; the group, so we select either all the active
5409 ;; articles in the group, or (if that's nil), the
5410 ;; articles in the cache.
5412 (gnus-uncompress-range (gnus-active group))
5413 (gnus-cache-articles-in-group group))
5414 ;; Select only the "normal" subset of articles.
5416 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5417 gnus-newsgroup-unreads)))
5418 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5419 (scored (length scored-list))
5420 (number (length articles))
5421 (marked (+ (length gnus-newsgroup-marked)
5422 (length gnus-newsgroup-dormant)))
5427 ((numberp gnus-newsgroup-display)
5428 gnus-newsgroup-display)
5432 ((and (or (<= scored marked) (= scored number))
5433 (numberp gnus-large-newsgroup)
5434 (> number gnus-large-newsgroup))
5435 (let* ((cursor-in-echo-area nil)
5436 (initial (gnus-parameter-large-newsgroup-initial
5437 gnus-newsgroup-name))
5441 "How many articles from %s (%s %d): "
5443 (gnus-group-decoded-name gnus-newsgroup-name)
5445 (if initial "max" "default")
5448 (cons (number-to-string initial)
5450 (if (string-match "^[ \t]*$" input) number input)))
5451 ((and (> scored marked) (< scored number)
5452 (> (- scored number) 20))
5455 (format "%s %s (%d scored, %d total): "
5456 "How many articles from"
5457 (gnus-group-decoded-name group)
5459 (if (string-match "^[ \t]*$" input)
5463 (message "Quit getting the articles to read")
5465 (setq select (if (stringp select) (string-to-number select) select))
5466 (if (or (null select) (zerop select))
5468 (if (and (not (zerop scored)) (<= (abs select) scored))
5470 (setq articles (sort scored-list '<))
5471 (setq number (length articles)))
5472 (setq articles (copy-sequence articles)))
5474 (when (< (abs select) number)
5476 ;; Select the N oldest articles.
5477 (setcdr (nthcdr (1- (abs select)) articles) nil)
5478 ;; Select the N most recent articles.
5479 (setq articles (nthcdr (- number select) articles))))
5480 (setq gnus-newsgroup-unselected
5481 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5482 (when gnus-alter-articles-to-read-function
5485 (funcall gnus-alter-articles-to-read-function
5486 gnus-newsgroup-name articles)
5490 (defun gnus-killed-articles (killed articles)
5493 (when (inline (gnus-member-of-range (car articles) killed))
5494 (push (car articles) out))
5495 (setq articles (cdr articles)))
5498 (defun gnus-uncompress-marks (marks)
5499 "Uncompress the mark ranges in MARKS."
5500 (let ((uncompressed '(score bookmark))
5503 (if (memq (caar marks) uncompressed)
5504 (push (car marks) out)
5505 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5506 (setq marks (cdr marks)))
5509 (defun gnus-article-mark-to-type (mark)
5510 "Return the type of MARK."
5511 (or (cadr (assq mark gnus-article-special-mark-lists))
5514 (defun gnus-article-unpropagatable-p (mark)
5515 "Return whether MARK should be propagated to back end."
5516 (memq mark gnus-article-unpropagated-mark-lists))
5518 (defun gnus-adjust-marked-articles (info)
5519 "Set all article lists and remove all marks that are no longer valid."
5520 (let* ((marked-lists (gnus-info-marks info))
5521 (active (gnus-active (gnus-info-group info)))
5524 (types gnus-article-mark-lists)
5525 marks var articles article mark mark-type
5528 (dolist (marks marked-lists)
5529 (setq mark (car marks)
5530 mark-type (gnus-article-mark-to-type mark)
5531 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5533 ;; We set the variable according to the type of the marks list,
5534 ;; and then adjust the marks to a subset of the active articles.
5536 ;; Adjust "simple" lists - compressed yet unsorted
5537 ((eq mark-type 'list)
5538 ;; Simultaneously uncompress and clip to active range
5539 ;; See gnus-uncompress-range for a description of possible marks
5541 (if (not (cadr marks))
5543 (setq articles (if (numberp (cddr marks))
5549 (while (setq article (pop articles))
5550 (cond ((consp article)
5551 (setq bgn (max (car article) min)
5552 end (min (cdr article) max))
5554 (setq l (setcdr l (cons bgn nil))
5556 ((and (<= min article)
5558 (setq l (setcdr l (cons article nil))))))
5559 (set var (cdr lh)))))
5561 ((eq mark-type 'tuple)
5562 (set var (setq articles (cdr marks)))
5563 (when (not (listp (cdr (symbol-value var))))
5564 (set var (list (symbol-value var))))
5565 (when (not (listp (cdr articles)))
5566 (setq articles (list articles)))
5568 (when (or (not (consp (setq article (pop articles))))
5569 (< (car article) min)
5570 (> (car article) max))
5571 (set var (delq article (symbol-value var))))))
5572 ;; Adjust ranges (sloppily).
5573 ((eq mark-type 'range)
5576 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5577 ;; It should be (seen (NUM1 . NUM2)).
5578 (when (numberp (cddr marks))
5579 (setcdr marks (list (cdr marks))))
5580 (setq articles (cdr marks))
5581 (while (and articles
5582 (or (and (consp (car articles))
5583 (> min (cdar articles)))
5584 (and (numberp (car articles))
5585 (> min (car articles)))))
5587 (set var articles))))))))
5589 (defun gnus-update-missing-marks (missing)
5590 "Go through the list of MISSING articles and remove them from the mark lists."
5593 ;; Go through all types.
5594 (dolist (elem gnus-article-mark-lists)
5595 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5596 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5597 (when (symbol-value var)
5598 ;; This list has articles. So we delete all missing
5599 ;; articles from it.
5602 (set var (delq (pop m) (symbol-value var))))))))))
5604 (defun gnus-update-marks ()
5605 "Enter the various lists of marked articles into the newsgroup info list."
5606 (let ((types gnus-article-mark-lists)
5607 (info (gnus-get-info gnus-newsgroup-name))
5608 type list newmarked symbol delta-marks)
5610 ;; Add all marks lists to the list of marks lists.
5611 (while (setq type (pop types))
5612 (setq list (symbol-value
5614 (intern (format "gnus-newsgroup-%s" (car type))))))
5617 ;; Get rid of the entries of the articles that have the
5619 (when (and (eq (cdr type) 'score)
5623 (prev (cons nil list))
5626 (if (or (not (consp (car arts)))
5627 (= (cdar arts) gnus-summary-default-score))
5628 (setcdr prev (cdr arts))
5630 (setq arts (cdr arts)))
5631 (setq list (cdr all)))))
5633 (when (eq (cdr type) 'seen)
5634 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5636 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5637 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5639 (when (and (gnus-check-backend-function
5640 'request-set-mark gnus-newsgroup-name)
5641 (not (gnus-article-unpropagatable-p (cdr type))))
5642 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5643 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5644 (add (gnus-remove-from-range
5645 (gnus-copy-sequence list) old)))
5647 (push (list add 'add (list (cdr type))) delta-marks))
5649 (push (list del 'del (list (cdr type))) delta-marks))))
5652 (push (cons (cdr type) list) newmarked)))
5655 (unless (gnus-check-group gnus-newsgroup-name)
5656 (error "Can't open server for %s" gnus-newsgroup-name))
5657 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5659 ;; Enter these new marks into the info of the group.
5661 (setcar (nthcdr 3 info) newmarked)
5662 ;; Add the marks lists to the end of the info.
5664 (setcdr (nthcdr 2 info) (list newmarked))))
5666 ;; Cut off the end of the info if there's nothing else there.
5670 (when (nthcdr (decf i) info)
5671 (setcdr (nthcdr i info) nil)))))))
5673 (defun gnus-set-mode-line (where)
5674 "Set the mode line of the article or summary buffers.
5675 If WHERE is `summary', the summary mode line format will be used."
5676 ;; Is this mode line one we keep updated?
5677 (when (and (memq where gnus-updated-mode-lines)
5679 (intern (format "gnus-%s-mode-line-format-spec" where))))
5682 ;; We evaluate this in the summary buffer since these
5683 ;; variables are buffer-local to that buffer.
5684 (set-buffer gnus-summary-buffer)
5685 ;; We bind all these variables that are used in the `eval' form
5687 (let* ((mformat (symbol-value
5689 (format "gnus-%s-mode-line-format-spec" where))))
5690 (gnus-tmp-group-name (gnus-group-decoded-name
5691 gnus-newsgroup-name))
5692 (gnus-tmp-article-number (or gnus-current-article 0))
5693 (gnus-tmp-unread gnus-newsgroup-unreads)
5694 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5695 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5696 (gnus-tmp-unread-and-unselected
5697 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5698 (zerop gnus-tmp-unselected))
5700 ((zerop gnus-tmp-unselected)
5701 (format "{%d more}" gnus-tmp-unread-and-unticked))
5702 (t (format "{%d(+%d) more}"
5703 gnus-tmp-unread-and-unticked
5704 gnus-tmp-unselected))))
5706 (if (and gnus-current-headers
5707 (vectorp gnus-current-headers))
5708 (gnus-mode-string-quote
5709 (mail-header-subject gnus-current-headers))
5711 bufname-length max-len
5712 gnus-tmp-header);; passed as argument to any user-format-funcs
5713 (setq mode-string (eval mformat))
5714 (setq bufname-length (if (string-match "%b" mode-string)
5717 (if (eq where 'summary)
5719 (get-buffer gnus-article-buffer))))
5722 (setq max-len (max 4 (if gnus-mode-non-string-length
5724 gnus-mode-non-string-length
5726 (length mode-string))))
5727 ;; We might have to chop a bit of the string off...
5728 (when (> (length mode-string) max-len)
5730 (concat (gnus-truncate-string mode-string (- max-len 3))
5732 ;; Pad the mode string a bit.
5733 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5734 ;; Update the mode line.
5735 (setq mode-line-buffer-identification
5736 (gnus-mode-line-buffer-identification (list mode-string)))
5737 (set-buffer-modified-p t))))
5739 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5740 "Go through the HEADERS list and add all Xrefs to a hash table.
5741 The resulting hash table is returned, or nil if no Xrefs were found."
5742 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5743 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5744 (xref-hashtb (gnus-make-hashtable))
5745 start group entry number xrefs header)
5747 (setq header (pop headers))
5748 (when (and (setq xrefs (mail-header-xref header))
5749 (not (memq (setq number (mail-header-number header))
5752 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5753 (setq start (match-end 0))
5754 (setq group (if prefix
5755 (concat prefix (substring xrefs (match-beginning 1)
5757 (substring xrefs (match-beginning 1) (match-end 1))))
5759 (string-to-number (substring xrefs (match-beginning 2)
5761 (if (setq entry (gnus-gethash group xref-hashtb))
5762 (setcdr entry (cons number (cdr entry)))
5763 (gnus-sethash group (cons number nil) xref-hashtb)))))
5764 (and start xref-hashtb)))
5766 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5767 "Look through all the headers and mark the Xrefs as read."
5768 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5769 name info xref-hashtb idlist method nth4)
5771 (set-buffer gnus-group-buffer)
5772 (when (setq xref-hashtb
5773 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5776 (unless (string= from-newsgroup (setq name (symbol-name group)))
5777 (setq idlist (symbol-value group))
5778 ;; Dead groups are not updated.
5780 (setq info (gnus-get-info name))
5781 (when (stringp (setq nth4 (gnus-info-method info)))
5782 (setq nth4 (gnus-server-to-method nth4))))
5783 ;; Only do the xrefs if the group has the same
5784 ;; select method as the group we have just read.
5785 (or (gnus-methods-equal-p
5786 nth4 (gnus-find-method-for-group from-newsgroup))
5788 (equal nth4 (setq method (gnus-find-method-for-group
5790 (and (equal (car nth4) (car method))
5791 (equal (nth 1 nth4) (nth 1 method))))
5792 gnus-use-cross-reference
5793 (or (not (eq gnus-use-cross-reference t))
5795 ;; Only do cross-references on subscribed
5796 ;; groups, if that is what is wanted.
5797 (<= (gnus-info-level info) gnus-level-subscribed))
5798 (gnus-group-make-articles-read name idlist))))
5801 (defun gnus-compute-read-articles (group articles)
5802 (let* ((entry (gnus-group-entry group))
5803 (info (nth 2 entry))
5804 (active (gnus-active group))
5807 ;; First peel off all invalid article numbers.
5809 (let ((ids articles)
5811 (while (setq id (pop ids))
5812 (when (and first (> id (cdr active)))
5813 ;; We'll end up in this situation in one particular
5814 ;; obscure situation. If you re-scan a group and get
5815 ;; a new article that is cross-posted to a different
5816 ;; group that has not been re-scanned, you might get
5817 ;; crossposted article that has a higher number than
5818 ;; Gnus believes possible. So we re-activate this
5819 ;; group as well. This might mean doing the
5820 ;; crossposting thingy will *increase* the number
5821 ;; of articles in some groups. Tsk, tsk.
5822 (setq active (or (gnus-activate-group group) active)))
5823 (when (or (> id (cdr active))
5824 (< id (car active)))
5825 (setq articles (delq id articles))))))
5826 ;; If the read list is nil, we init it.
5828 (null (gnus-info-read info))
5830 (setq ninfo (cons 1 (1- (car active))))
5831 (setq ninfo (gnus-info-read info)))
5832 ;; Then we add the read articles to the range.
5834 ninfo (setq articles (sort articles '<))))))
5836 (defun gnus-group-make-articles-read (group articles)
5837 "Update the info of GROUP to say that ARTICLES are read."
5839 (entry (gnus-group-entry group))
5840 (info (nth 2 entry))
5841 (active (gnus-active group))
5844 (setq range (gnus-compute-read-articles group articles))
5845 (with-current-buffer gnus-group-buffer
5848 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5849 (gnus-info-set-read ',info ',(gnus-info-read info))
5850 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5851 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5852 (gnus-group-update-group ,group t))))
5853 ;; Add the read articles to the range.
5854 (gnus-info-set-read info range)
5855 (gnus-request-set-mark group (list (list range 'add '(read))))
5856 ;; Then we have to re-compute how many unread
5857 ;; articles there are in this group.
5861 (setq num (- (1+ (cdr active)) (car active))))
5862 ((not (listp (cdr range)))
5863 (setq num (- (cdr active) (- (1+ (cdr range))
5867 (if (numberp (car range))
5869 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5870 (setq range (cdr range)))
5871 (setq num (- (cdr active) num))))
5872 ;; Update the number of unread articles.
5874 ;; Update the group buffer.
5875 (unless (gnus-ephemeral-group-p group)
5876 (gnus-group-update-group group t))))))
5878 (defvar gnus-newsgroup-none-id 0)
5880 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5881 (let ((cur nntp-server-buffer)
5884 (with-current-buffer gnus-summary-buffer
5885 gnus-newsgroup-dependencies)))
5886 headers id end ref number
5887 (mail-parse-charset gnus-newsgroup-charset)
5888 (mail-parse-ignored-charsets
5889 (save-excursion (condition-case nil
5890 (set-buffer gnus-summary-buffer)
5892 gnus-newsgroup-ignored-charsets)))
5894 (set-buffer nntp-server-buffer)
5895 ;; Translate all TAB characters into SPACE characters.
5896 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5897 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5898 (ietf-drums-unfold-fws)
5899 (gnus-run-hooks 'gnus-parse-headers-hook)
5900 (let ((case-fold-search t)
5901 in-reply-to header p lines chars ctype)
5902 (goto-char (point-min))
5903 ;; Search to the beginning of the next header. Error messages
5904 ;; do not begin with 2 or 3.
5905 (while (re-search-forward "^[23][0-9]+ " nil t)
5908 ;; This implementation of this function, with nine
5909 ;; search-forwards instead of the one re-search-forward and
5910 ;; a case (which basically was the old function) is actually
5911 ;; about twice as fast, even though it looks messier. You
5912 ;; can't have everything, I guess. Speed and elegance
5913 ;; doesn't always go hand in hand.
5916 (make-full-mail-header
5919 (setq number (read cur))
5922 (narrow-to-region (point)
5923 (or (and (search-forward "\n.\n" nil t)
5929 (if (search-forward "\nsubject:" nil t)
5930 (nnheader-header-value)
5935 (if (search-forward "\nfrom:" nil t)
5936 (nnheader-header-value)
5941 (if (search-forward "\ndate:" nil t)
5942 (nnheader-header-value) ""))
5946 (setq id (if (re-search-forward
5947 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5948 ;; We do it this way to make sure the Message-ID
5949 ;; is (somewhat) syntactically valid.
5950 (buffer-substring (match-beginning 1)
5952 ;; If there was no message-id, we just fake one
5953 ;; to make subsequent routines simpler.
5954 (nnheader-generate-fake-message-id number))))
5958 (if (search-forward "\nreferences:" nil t)
5962 (nnheader-header-value)
5967 (search-backward ">" end t)
5970 (search-backward "<" end t)
5972 ;; Get the references from the in-reply-to header if there
5973 ;; were no references and the in-reply-to header looks
5975 (if (and (search-forward "\nin-reply-to:" nil t)
5976 (setq in-reply-to (nnheader-header-value))
5977 (string-match "<[^>]+>" in-reply-to))
5979 (setq ref (substring in-reply-to (match-beginning 0)
5981 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5982 (setq ref2 (substring in-reply-to (match-beginning 0)
5984 (when (> (length ref2) (length ref))
5991 (if (search-forward "\nchars: " nil t)
5992 (if (numberp (setq chars (ignore-errors (read cur))))
5998 (if (search-forward "\nlines: " nil t)
5999 (if (numberp (setq lines (ignore-errors (read cur))))
6005 (and (search-forward "\nxref:" nil t)
6006 (nnheader-header-value)))
6008 (when gnus-extra-headers
6009 (let ((extra gnus-extra-headers)
6013 (when (search-forward
6014 (concat "\n" (symbol-name (car extra)) ":") nil t)
6015 (push (cons (car extra) (nnheader-header-value)) out))
6019 (if (and (search-forward "\ncontent-type: " nil t)
6020 (setq ctype (nnheader-header-value)))
6021 (mime-entity-set-content-type-internal
6022 header (mime-parse-Content-Type ctype)))
6023 (when (equal id ref)
6026 (when gnus-alter-header-function
6027 (funcall gnus-alter-header-function header)
6028 (setq id (mail-header-id header)
6029 ref (gnus-parent-id (mail-header-references header))))
6032 (gnus-dependencies-add-header
6033 header dependencies force-new))
6034 (push header headers))
6035 (goto-char (point-max))
6037 (nreverse headers)))))
6039 ;; Goes through the xover lines and returns a list of vectors
6040 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6041 force-new dependencies
6042 group also-fetch-heads)
6043 "Parse the news overview data in the server buffer.
6044 Return a list of headers that match SEQUENCE (see
6045 `nntp-retrieve-headers')."
6046 ;; Get the Xref when the users reads the articles since most/some
6047 ;; NNTP servers do not include Xrefs when using XOVER.
6048 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6049 (let ((mail-parse-charset gnus-newsgroup-charset)
6050 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6051 (cur nntp-server-buffer)
6052 (dependencies (or dependencies gnus-newsgroup-dependencies))
6054 ((eq gnus-read-all-available-headers t)
6056 ((stringp gnus-read-all-available-headers)
6057 (string-match gnus-read-all-available-headers group))
6060 number headers header)
6062 (set-buffer nntp-server-buffer)
6063 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6064 ;; Allow the user to mangle the headers before parsing them.
6065 (gnus-run-hooks 'gnus-parse-headers-hook)
6066 (goto-char (point-min))
6067 (gnus-parse-without-error
6068 (while (and (or sequence allp)
6070 (setq number (read cur))
6072 (while (and sequence
6073 (< (car sequence) number))
6074 (setq sequence (cdr sequence))))
6077 (eq number (car sequence))))
6079 (setq sequence (cdr sequence))
6080 (setq header (inline
6081 (gnus-nov-parse-line
6082 number dependencies force-new)))))
6083 (push header headers))
6085 ;; A common bug in inn is that if you have posted an article and
6086 ;; then retrieves the active file, it will answer correctly --
6087 ;; the new article is included. However, a NOV entry for the
6088 ;; article may not have been generated yet, so this may fail.
6089 ;; We work around this problem by retrieving the last few
6090 ;; headers using HEAD.
6091 (if (or (not also-fetch-heads)
6093 ;; We (probably) got all the headers.
6095 (let ((gnus-nov-is-evil t))
6098 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6099 (gnus-get-newsgroup-headers))))))))
6101 (defun gnus-article-get-xrefs ()
6102 "Fill in the Xref value in `gnus-current-headers', if necessary.
6103 This is meant to be called in `gnus-article-internal-prepare-hook'."
6104 (let ((headers (with-current-buffer gnus-summary-buffer
6105 gnus-current-headers)))
6106 (or (not gnus-use-cross-reference)
6108 (and (mail-header-xref headers)
6109 (not (string= (mail-header-xref headers) "")))
6110 (let ((case-fold-search t)
6113 (nnheader-narrow-to-headers)
6114 (goto-char (point-min))
6115 (when (or (and (not (eobp))
6116 (eq (downcase (char-after)) ?x)
6117 (looking-at "Xref:"))
6118 (search-forward "\nXref:" nil t))
6119 (goto-char (1+ (match-end 0)))
6120 (setq xref (buffer-substring (point) (point-at-eol)))
6121 (mail-header-set-xref headers xref)))))))
6123 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6124 "Find article ID and insert the summary line for that article.
6125 OLD-HEADER can either be a header or a line number to insert
6126 the subject line on."
6127 (let* ((line (and (numberp old-header) old-header))
6128 (old-header (and (vectorp old-header) old-header))
6129 (header (cond ((and old-header use-old-header)
6132 (gnus-number-to-header id))
6133 (gnus-number-to-header id))
6135 (gnus-read-header id))))
6136 (number (and (numberp id) id))
6139 ;; Rebuild the thread that this article is part of and go to the
6140 ;; article we have fetched.
6141 (when (and (not gnus-show-threads)
6144 (setq d (gnus-data-find (mail-header-number old-header))))
6145 (goto-char (gnus-data-pos d))
6151 (gnus-delete-line))))))
6152 ;; Remove list identifiers from subject.
6153 (when gnus-list-identifiers
6154 (let ((gnus-newsgroup-headers (list header)))
6155 (gnus-summary-remove-list-identifiers)))
6157 (mail-header-set-number header (mail-header-number old-header)))
6158 (setq gnus-newsgroup-sparse
6159 (delq (setq number (mail-header-number header))
6160 gnus-newsgroup-sparse))
6161 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6162 (push number gnus-newsgroup-limit)
6163 (gnus-rebuild-thread (mail-header-id header) line)
6164 (gnus-summary-goto-subject number nil t))
6165 (when (and (numberp number)
6167 ;; We have to update the boundaries even if we can't fetch the
6168 ;; article if ID is a number -- so that the next `P' or `N'
6169 ;; command will fetch the previous (or next) article even
6170 ;; if the one we tried to fetch this time has been canceled.
6171 (when (> number gnus-newsgroup-end)
6172 (setq gnus-newsgroup-end number))
6173 (when (< number gnus-newsgroup-begin)
6174 (setq gnus-newsgroup-begin number))
6175 (setq gnus-newsgroup-unselected
6176 (delq number gnus-newsgroup-unselected)))
6177 ;; Report back a success?
6178 (and header (mail-header-number header))))
6180 ;;; Process/prefix in the summary buffer
6182 (defun gnus-summary-work-articles (n)
6183 "Return a list of articles to be worked upon.
6184 The prefix argument, the list of process marked articles, and the
6185 current article will be taken into consideration."
6187 (set-buffer gnus-summary-buffer)
6190 ;; A numerical prefix has been given.
6191 (setq n (prefix-numeric-value n))
6192 (let ((backward (< n 0))
6193 (n (abs (prefix-numeric-value n)))
6198 (push (setq article (gnus-summary-article-number))
6201 (gnus-summary-find-prev nil article)
6202 (gnus-summary-find-next nil article)))
6204 (nreverse articles)))
6205 ((and (gnus-region-active-p) (mark))
6206 (message "region active")
6207 ;; Work on the region between point and mark.
6208 (let ((max (max (point) (mark)))
6211 (goto-char (min (point) (mark)))
6214 (push (setq article (gnus-summary-article-number)) articles)
6215 (gnus-summary-find-next nil article)
6217 (nreverse articles))))
6218 (gnus-newsgroup-processable
6219 ;; There are process-marked articles present.
6220 ;; Save current state.
6221 (gnus-summary-save-process-mark)
6223 (reverse gnus-newsgroup-processable))
6225 ;; Just return the current article.
6226 (list (gnus-summary-article-number))))))
6228 (defmacro gnus-summary-iterate (arg &rest forms)
6229 "Iterate over the process/prefixed articles and do FORMS.
6230 ARG is the interactive prefix given to the command. FORMS will be
6231 executed with point over the summary line of the articles."
6232 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6233 `(let ((,articles (gnus-summary-work-articles ,arg)))
6235 (gnus-summary-goto-subject (car ,articles))
6239 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6240 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6242 (defun gnus-summary-save-process-mark ()
6243 "Push the current set of process marked articles on the stack."
6245 (push (copy-sequence gnus-newsgroup-processable)
6246 gnus-newsgroup-process-stack))
6248 (defun gnus-summary-kill-process-mark ()
6249 "Push the current set of process marked articles on the stack and unmark."
6251 (gnus-summary-save-process-mark)
6252 (gnus-summary-unmark-all-processable))
6254 (defun gnus-summary-yank-process-mark ()
6255 "Pop the last process mark state off the stack and restore it."
6257 (unless gnus-newsgroup-process-stack
6258 (error "Empty mark stack"))
6259 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6261 (defun gnus-summary-process-mark-set (set)
6262 "Make SET into the current process marked articles."
6263 (gnus-summary-unmark-all-processable)
6264 (mapc 'gnus-summary-set-process-mark set))
6266 ;;; Searching and stuff
6268 (defun gnus-summary-search-group (&optional backward use-level)
6269 "Search for next unread newsgroup.
6270 If optional argument BACKWARD is non-nil, search backward instead."
6272 (set-buffer gnus-group-buffer)
6273 (when (gnus-group-search-forward
6274 backward nil (if use-level (gnus-group-group-level) nil))
6275 (gnus-group-group-name))))
6277 (defun gnus-summary-best-group (&optional exclude-group)
6278 "Find the name of the best unread group.
6279 If EXCLUDE-GROUP, do not go to this group."
6280 (with-current-buffer gnus-group-buffer
6282 (gnus-group-best-unread-group exclude-group))))
6284 (defun gnus-summary-find-next (&optional unread article backward)
6286 (gnus-summary-find-prev unread article)
6287 (let* ((dummy (gnus-summary-article-intangible-p))
6288 (article (or article (gnus-summary-article-number)))
6289 (data (gnus-data-find-list article))
6291 (when (and (not dummy)
6292 (or (not gnus-summary-check-current)
6294 (not (gnus-data-unread-p (car data)))))
6295 (setq data (cdr data)))
6300 (unless (memq (gnus-data-number (car data))
6302 ((eq gnus-auto-goto-ignores
6303 'always-undownloaded)
6304 gnus-newsgroup-undownloaded)
6307 ((eq gnus-auto-goto-ignores
6309 gnus-newsgroup-unfetched)
6310 ((eq gnus-auto-goto-ignores
6312 gnus-newsgroup-undownloaded)))
6313 (when (gnus-data-unread-p (car data))
6314 (setq result (car data)
6316 (setq data (cdr data)))
6319 (goto-char (gnus-data-pos result))
6320 (gnus-data-number result)))))
6322 (defun gnus-summary-find-prev (&optional unread article)
6323 (let* ((eobp (eobp))
6324 (article (or article (gnus-summary-article-number)))
6325 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6327 (when (and (not eobp)
6328 (or (not gnus-summary-check-current)
6330 (not (gnus-data-unread-p (car data)))))
6331 (setq data (cdr data)))
6336 (unless (memq (gnus-data-number (car data))
6338 ((eq gnus-auto-goto-ignores
6339 'always-undownloaded)
6340 gnus-newsgroup-undownloaded)
6343 ((eq gnus-auto-goto-ignores
6345 gnus-newsgroup-unfetched)
6346 ((eq gnus-auto-goto-ignores
6348 gnus-newsgroup-undownloaded)))
6349 (when (gnus-data-unread-p (car data))
6350 (setq result (car data)
6352 (setq data (cdr data)))
6355 (goto-char (gnus-data-pos result))
6356 (gnus-data-number result))))
6358 (defun gnus-summary-find-subject (subject &optional unread backward article)
6359 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6360 (article (or article (gnus-summary-article-number)))
6361 (articles (gnus-data-list backward))
6362 (arts (gnus-data-find-list article articles))
6364 (when (or (not gnus-summary-check-current)
6366 (not (gnus-data-unread-p (car arts))))
6367 (setq arts (cdr arts)))
6369 (and (or (not unread)
6370 (gnus-data-unread-p (car arts)))
6371 (vectorp (gnus-data-header (car arts)))
6373 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6374 (setq result (car arts)
6376 (setq arts (cdr arts)))
6378 (goto-char (gnus-data-pos result))
6379 (gnus-data-number result))))
6381 (defun gnus-summary-search-forward (&optional unread subject backward)
6382 "Search forward for an article.
6383 If UNREAD, look for unread articles. If SUBJECT, look for
6384 articles with that subject. If BACKWARD, search backward instead."
6385 (cond (subject (gnus-summary-find-subject subject unread backward))
6386 (backward (gnus-summary-find-prev unread))
6387 (t (gnus-summary-find-next unread))))
6389 (defun gnus-recenter (&optional n)
6390 "Center point in window and redisplay frame.
6391 Also do horizontal recentering."
6393 (when (and gnus-auto-center-summary
6394 (not (eq gnus-auto-center-summary 'vertical)))
6395 (gnus-horizontal-recenter))
6398 (defun gnus-summary-recenter ()
6399 "Center point in the summary window.
6400 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6401 displayed, no centering will be performed."
6402 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6403 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6405 ;; The user has to want it.
6406 (when gnus-auto-center-summary
6407 (let* ((top (cond ((< (window-height) 4) 0)
6408 ((< (window-height) 7) 1)
6409 (t (if (numberp gnus-auto-center-summary)
6410 gnus-auto-center-summary
6411 (/ (1- (window-height)) 2)))))
6412 (height (1- (window-height)))
6413 (bottom (save-excursion (goto-char (point-max))
6414 (forward-line (- height))
6416 (window (get-buffer-window (current-buffer))))
6417 (when (get-buffer-window gnus-article-buffer)
6418 ;; Only do recentering when the article buffer is displayed,
6419 ;; Set the window start to either `bottom', which is the biggest
6420 ;; possible valid number, or the second line from the top,
6421 ;; whichever is the least.
6422 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6423 (if (> bottom top-pos)
6424 ;; Keep the second line from the top visible
6425 (set-window-start window top-pos t)
6426 ;; Try to keep the bottom line visible; if it's partially
6427 ;; obscured, either scroll one more line to make it fully
6428 ;; visible, or revert to using TOP-POS.
6430 (goto-char (point-max))
6432 (let ((last-line-start (point)))
6434 (set-window-start window (point) t)
6435 (when (not (pos-visible-in-window-p last-line-start window))
6437 (set-window-start window (min (point) top-pos) t)))))))
6438 ;; Do horizontal recentering while we're at it.
6439 (when (and (get-buffer-window (current-buffer) t)
6440 (not (eq gnus-auto-center-summary 'vertical)))
6441 (let ((selected (selected-window)))
6442 (select-window (get-buffer-window (current-buffer) t))
6443 (gnus-summary-position-point)
6444 (gnus-horizontal-recenter)
6445 (select-window selected))))))
6447 (defun gnus-summary-jump-to-group (newsgroup)
6448 "Move point to NEWSGROUP in group mode buffer."
6449 ;; Keep update point of group mode buffer if visible.
6450 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6451 (save-window-excursion
6452 ;; Take care of tree window mode.
6453 (when (get-buffer-window gnus-group-buffer)
6454 (pop-to-buffer gnus-group-buffer))
6455 (gnus-group-jump-to-group newsgroup))
6457 ;; Take care of tree window mode.
6458 (if (get-buffer-window gnus-group-buffer)
6459 (pop-to-buffer gnus-group-buffer)
6460 (set-buffer gnus-group-buffer))
6461 (gnus-group-jump-to-group newsgroup))))
6463 ;; This function returns a list of article numbers based on the
6464 ;; difference between the ranges of read articles in this group and
6465 ;; the range of active articles.
6466 (defun gnus-list-of-unread-articles (group)
6467 (let* ((read (gnus-info-read (gnus-get-info group)))
6468 (active (or (gnus-active group) (gnus-activate-group group)))
6469 (last (or (cdr active)
6470 (error "Group %s couldn't be activated " group)))
6472 ;; If none are read, then all are unread.
6474 (setq first (car active))
6475 ;; If the range of read articles is a single range, then the
6476 ;; first unread article is the article after the last read
6477 ;; article. Sounds logical, doesn't it?
6478 (if (and (not (listp (cdr read)))
6479 (or (< (car read) (car active))
6480 (progn (setq read (list read))
6482 (setq first (max (car active) (1+ (cdr read))))
6483 ;; `read' is a list of ranges.
6484 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6487 (setq first (car active)))
6490 (while (< first nlast)
6491 (setq unread (cons first unread)
6493 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6494 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6495 (setq read (cdr read)))))
6496 ;; And add the last unread articles.
6497 (while (<= first last)
6498 (setq unread (cons first unread)
6500 ;; Return the list of unread articles.
6501 (delq 0 (nreverse unread))))
6503 (defun gnus-list-of-read-articles (group)
6504 "Return a list of unread, unticked and non-dormant articles."
6505 (let* ((info (gnus-get-info group))
6506 (marked (gnus-info-marks info))
6507 (active (gnus-active group)))
6509 (gnus-list-range-difference
6510 (gnus-list-range-difference
6511 (gnus-sorted-complement
6512 (gnus-uncompress-range active)
6513 (gnus-list-of-unread-articles group))
6514 (cdr (assq 'dormant marked)))
6515 (cdr (assq 'tick marked))))))
6517 ;; This function returns a sequence of article numbers based on the
6518 ;; difference between the ranges of read articles in this group and
6519 ;; the range of active articles.
6520 (defun gnus-sequence-of-unread-articles (group)
6521 (let* ((read (gnus-info-read (gnus-get-info group)))
6522 (active (or (gnus-active group) (gnus-activate-group group)))
6525 ;; If none are read, then all are unread.
6527 (setq first (car active))
6528 ;; If the range of read articles is a single range, then the
6529 ;; first unread article is the article after the last read
6530 ;; article. Sounds logical, doesn't it?
6531 (if (and (not (listp (cdr read)))
6532 (or (< (car read) (car active))
6533 (progn (setq read (list read))
6535 (setq first (max (car active) (1+ (cdr read))))
6536 ;; `read' is a list of ranges.
6537 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6540 (setq first (car active)))
6543 (push (cons first nlast) unread))
6544 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6545 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6546 (setq read (cdr read)))))
6547 ;; And add the last unread articles.
6548 (cond ((< first last)
6549 (push (cons first last) unread))
6551 (push first unread)))
6552 ;; Return the sequence of unread articles.
6553 (delq 0 (nreverse unread))))
6555 ;; Various summary commands
6557 (defun gnus-summary-select-article-buffer ()
6558 "Reconfigure windows to show article buffer."
6560 (if (not (gnus-buffer-live-p gnus-article-buffer))
6561 (error "There is no article buffer for this summary buffer")
6562 (gnus-configure-windows 'article)
6563 (select-window (get-buffer-window gnus-article-buffer))))
6565 (defun gnus-summary-universal-argument (arg)
6566 "Perform any operation on all articles that are process/prefixed."
6568 (let ((articles (gnus-summary-work-articles arg))
6575 (substitute-command-keys
6576 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6578 (gnus-error 1 "Undefined key")
6581 (gnus-summary-goto-subject (setq article (pop articles)))
6582 (let (gnus-newsgroup-processable)
6583 (command-execute func))
6584 (gnus-summary-remove-process-mark article)))))
6585 (gnus-summary-position-point))
6587 (defun gnus-summary-toggle-truncation (&optional arg)
6588 "Toggle truncation of summary lines.
6589 With ARG, turn line truncation on if ARG is positive."
6591 (setq truncate-lines
6592 (if (null arg) (not truncate-lines)
6593 (> (prefix-numeric-value arg) 0)))
6596 (defun gnus-summary-find-for-reselect ()
6597 "Return the number of an article to stay on across a reselect.
6598 The current article is considered, then following articles, then previous
6599 articles. An article is sought which is not cancelled and isn't a temporary
6600 insertion from another group. If there's no such then return a dummy 0."
6602 (dolist (rev '(nil t))
6603 (unless found ; don't demand the reverse list if we don't need it
6604 (let ((data (gnus-data-find-list
6605 (gnus-summary-article-number) (gnus-data-list rev))))
6606 (while (and data (not found))
6607 (if (and (< 0 (gnus-data-number (car data)))
6608 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6609 (setq found (gnus-data-number (car data))))
6610 (setq data (cdr data))))))
6613 (defun gnus-summary-reselect-current-group (&optional all rescan)
6614 "Exit and then reselect the current newsgroup.
6615 The prefix argument ALL means to select all articles."
6617 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6618 (error "Ephemeral groups can't be reselected"))
6619 (let ((current-subject (gnus-summary-find-for-reselect))
6620 (group gnus-newsgroup-name))
6621 (setq gnus-newsgroup-begin nil)
6622 (gnus-summary-exit nil 'leave-hidden)
6623 ;; We have to adjust the point of group mode buffer because
6624 ;; point was moved to the next unread newsgroup by exiting.
6625 (gnus-summary-jump-to-group group)
6628 (save-window-excursion
6629 ;; Don't show group contents.
6630 (set-window-start (selected-window) (point-max))
6631 (gnus-group-get-new-news-this-group 1))))
6632 (gnus-group-read-group all t)
6633 (gnus-summary-goto-subject current-subject nil t)))
6635 (defun gnus-summary-rescan-group (&optional all)
6636 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6638 (gnus-summary-reselect-current-group all t))
6640 (defun gnus-summary-update-info (&optional non-destructive)
6642 (let ((group gnus-newsgroup-name))
6644 (when gnus-newsgroup-kill-headers
6645 (setq gnus-newsgroup-killed
6646 (gnus-compress-sequence
6648 (gnus-list-range-intersection
6649 gnus-newsgroup-unselected gnus-newsgroup-killed)
6650 gnus-newsgroup-unreads)
6652 (unless (listp (cdr gnus-newsgroup-killed))
6653 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6654 (let ((headers gnus-newsgroup-headers))
6655 ;; Set the new ranges of read articles.
6656 (with-current-buffer gnus-group-buffer
6657 (gnus-undo-force-boundary))
6658 (gnus-update-read-articles
6659 group (gnus-sorted-union
6660 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6661 ;; Set the current article marks.
6662 (let ((gnus-newsgroup-scored
6663 (if (and (not gnus-save-score)
6664 (not non-destructive))
6666 gnus-newsgroup-scored)))
6668 (gnus-update-marks)))
6669 ;; Do the cross-ref thing.
6670 (when gnus-use-cross-reference
6671 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6672 ;; Do not switch windows but change the buffer to work.
6673 (set-buffer gnus-group-buffer)
6674 (unless (gnus-ephemeral-group-p group)
6675 (gnus-group-update-group group)))))))
6677 (defun gnus-summary-save-newsrc (&optional force)
6678 "Save the current number of read/marked articles in the dribble buffer.
6679 The dribble buffer will then be saved.
6680 If FORCE (the prefix), also save the .newsrc file(s)."
6682 (gnus-summary-update-info t)
6684 (gnus-save-newsrc-file)
6685 (gnus-dribble-save)))
6687 (defun gnus-summary-exit (&optional temporary leave-hidden)
6688 "Exit reading current newsgroup, and then return to group selection mode.
6689 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6691 (gnus-set-global-variables)
6692 (gnus-kill-save-kill-buffer)
6693 (gnus-async-halt-prefetch)
6694 (let* ((group gnus-newsgroup-name)
6695 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6696 (gnus-group-is-exiting-p t)
6699 (buf (current-buffer)))
6701 ;; Do adaptive scoring, and possibly save score files.
6702 (when gnus-newsgroup-adaptive
6703 (gnus-score-adaptive))
6704 (when gnus-use-scoring
6706 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6707 ;; If we have several article buffers, we kill them at exit.
6708 (unless gnus-single-article-buffer
6709 (gnus-kill-buffer gnus-original-article-buffer)
6710 (setq gnus-article-current nil))
6711 (when gnus-use-cache
6712 (gnus-cache-possibly-remove-articles)
6713 (gnus-cache-save-buffers))
6714 (gnus-async-prefetch-remove-group group)
6715 (when gnus-suppress-duplicates
6716 (gnus-dup-enter-articles))
6717 (when gnus-use-trees
6718 (gnus-tree-close group))
6719 (when gnus-use-cache
6720 (gnus-cache-write-active))
6721 ;; Remove entries for this group.
6722 (nnmail-purge-split-history (gnus-group-real-name group))
6723 ;; Make all changes in this group permanent.
6725 (gnus-run-hooks 'gnus-exit-group-hook)
6726 (gnus-summary-update-info))
6727 (gnus-close-group group)
6728 ;; Make sure where we were, and go to next newsgroup.
6729 (set-buffer gnus-group-buffer)
6731 (gnus-group-jump-to-group group))
6732 (gnus-run-hooks 'gnus-summary-exit-hook)
6733 (unless (or quit-config
6734 ;; If this group has disappeared from the summary
6735 ;; buffer, don't skip forwards.
6736 (not (string= group (gnus-group-group-name))))
6737 (gnus-group-next-unread-group 1))
6738 (setq group-point (point))
6741 ;; If we have several article buffers, we kill them at exit.
6742 (unless gnus-single-article-buffer
6743 (gnus-kill-buffer gnus-article-buffer)
6744 (gnus-kill-buffer gnus-original-article-buffer)
6745 (setq gnus-article-current nil))
6747 (if (not gnus-kill-summary-on-exit)
6749 (gnus-deaden-summary)
6751 ;; We set all buffer-local variables to nil. It is unclear why
6752 ;; this is needed, but if we don't, buffer-local variables are
6753 ;; not garbage-collected, it seems. This would the lead to en
6754 ;; ever-growing Emacs.
6755 (gnus-summary-clear-local-variables)
6756 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6757 (gnus-summary-clear-local-variables))
6758 (when (get-buffer gnus-article-buffer)
6759 (bury-buffer gnus-article-buffer))
6760 ;; Return to group mode buffer.
6761 (when (eq mode 'gnus-summary-mode)
6762 (gnus-kill-buffer buf)))
6763 (setq gnus-current-select-method gnus-select-method)
6764 (set-buffer gnus-group-buffer)
6766 (gnus-handle-ephemeral-exit quit-config)
6767 (goto-char group-point)
6768 ;; If gnus-group-buffer is already displayed, make sure we also move
6769 ;; the cursor in the window that displays it.
6770 (let ((win (get-buffer-window (current-buffer) 0)))
6771 (if win (set-window-point win (point))))
6772 (unless leave-hidden
6773 (gnus-configure-windows 'group 'force))
6774 (unless (pos-visible-in-window-p)
6775 (forward-line (/ (static-if (featurep 'xemacs)
6776 (window-displayed-height)
6777 (1- (window-height)))
6779 (set-window-start (selected-window) (point))
6780 (goto-char group-point)))
6781 ;; Clear the current group name.
6783 (setq gnus-newsgroup-name nil)))))
6785 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6786 (defun gnus-summary-exit-no-update (&optional no-questions)
6787 "Quit reading current newsgroup without updating read article info."
6789 (let* ((group gnus-newsgroup-name)
6790 (gnus-group-is-exiting-p t)
6791 (gnus-group-is-exiting-without-update-p t)
6792 (quit-config (gnus-group-quit-config group)))
6793 (when (or no-questions
6795 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6796 (gnus-async-halt-prefetch)
6797 (run-hooks 'gnus-summary-prepare-exit-hook)
6798 ;; If we have several article buffers, we kill them at exit.
6799 (unless gnus-single-article-buffer
6800 (gnus-kill-buffer gnus-article-buffer)
6801 (gnus-kill-buffer gnus-original-article-buffer)
6802 (setq gnus-article-current nil))
6803 (if (not gnus-kill-summary-on-exit)
6804 (gnus-deaden-summary)
6805 (gnus-close-group group)
6806 (gnus-summary-clear-local-variables)
6807 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6808 (gnus-summary-clear-local-variables))
6809 (gnus-kill-buffer gnus-summary-buffer))
6810 (unless gnus-single-article-buffer
6811 (setq gnus-article-current nil))
6812 (when gnus-use-trees
6813 (gnus-tree-close group))
6814 (gnus-async-prefetch-remove-group group)
6815 (when (get-buffer gnus-article-buffer)
6816 (bury-buffer gnus-article-buffer))
6817 ;; Return to the group buffer.
6818 (gnus-configure-windows 'group 'force)
6819 ;; Clear the current group name.
6820 (setq gnus-newsgroup-name nil)
6821 (unless (gnus-ephemeral-group-p group)
6822 (gnus-group-update-group group))
6823 (when (equal (gnus-group-group-name) group)
6824 (gnus-group-next-unread-group 1))
6826 (gnus-handle-ephemeral-exit quit-config)))))
6828 (defun gnus-handle-ephemeral-exit (quit-config)
6829 "Handle movement when leaving an ephemeral group.
6830 The state which existed when entering the ephemeral is reset."
6831 (if (not (buffer-name (car quit-config)))
6832 (gnus-configure-windows 'group 'force)
6833 (set-buffer (car quit-config))
6834 (cond ((eq major-mode 'gnus-summary-mode)
6835 (gnus-set-global-variables))
6836 ((eq major-mode 'gnus-article-mode)
6838 ;; The `gnus-summary-buffer' variable may point
6839 ;; to the old summary buffer when using a single
6841 (unless (gnus-buffer-live-p gnus-summary-buffer)
6842 (set-buffer gnus-group-buffer))
6843 (set-buffer gnus-summary-buffer)
6844 (gnus-set-global-variables))))
6845 (if (or (eq (cdr quit-config) 'article)
6846 (eq (cdr quit-config) 'pick))
6848 ;; The current article may be from the ephemeral group
6849 ;; thus it is best that we reload this article
6851 ;; If we're exiting from a large digest, this can be
6852 ;; extremely slow. So, it's better not to reload it. -- jh.
6853 ;;(gnus-summary-show-article)
6854 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6855 (gnus-configure-windows 'pick 'force)
6856 (gnus-configure-windows (cdr quit-config) 'force)))
6857 (gnus-configure-windows (cdr quit-config) 'force))
6858 (when (eq major-mode 'gnus-summary-mode)
6859 (gnus-summary-next-subject 1 nil t)
6860 (gnus-summary-recenter)
6861 (gnus-summary-position-point))))
6863 (defun gnus-summary-preview-mime-message ()
6864 "MIME decode and play this message."
6866 (let ((gnus-break-pages nil)
6868 (gnus-summary-select-article gnus-show-all-headers t))
6869 (let ((w (get-buffer-window gnus-article-buffer)))
6871 (select-window (get-buffer-window gnus-article-buffer)))))
6875 (defvar gnus-dead-summary-mode-map nil)
6877 (unless gnus-dead-summary-mode-map
6878 (setq gnus-dead-summary-mode-map (make-keymap))
6879 (suppress-keymap gnus-dead-summary-mode-map)
6880 (substitute-key-definition
6881 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6882 (dolist (key '("\C-d" "\r" "\177" [delete]))
6883 (define-key gnus-dead-summary-mode-map
6884 key 'gnus-summary-wake-up-the-dead))
6885 (dolist (key '("q" "Q"))
6886 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6888 (defvar gnus-dead-summary-mode nil
6889 "Minor mode for Gnus summary buffers.")
6891 (defun gnus-dead-summary-mode (&optional arg)
6892 "Minor mode for Gnus summary buffers."
6894 (when (eq major-mode 'gnus-summary-mode)
6895 (make-local-variable 'gnus-dead-summary-mode)
6896 (setq gnus-dead-summary-mode
6897 (if (null arg) (not gnus-dead-summary-mode)
6898 (> (prefix-numeric-value arg) 0)))
6899 (when gnus-dead-summary-mode
6901 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6903 (defun gnus-deaden-summary ()
6904 "Make the current summary buffer into a dead summary buffer."
6905 ;; Kill any previous dead summary buffer.
6906 (when (and gnus-dead-summary
6907 (buffer-name gnus-dead-summary))
6908 (with-current-buffer gnus-dead-summary
6909 (when gnus-dead-summary-mode
6910 (kill-buffer (current-buffer)))))
6911 ;; Make this the current dead summary.
6912 (setq gnus-dead-summary (current-buffer))
6913 (gnus-dead-summary-mode 1)
6914 (let ((name (buffer-name)))
6915 (when (string-match "Summary" name)
6917 (concat (substring name 0 (match-beginning 0)) "Dead "
6918 (substring name (match-beginning 0)))
6922 (defun gnus-kill-or-deaden-summary (buffer)
6923 "Kill or deaden the summary BUFFER."
6925 (when (and (buffer-name buffer)
6926 (not gnus-single-article-buffer))
6927 (with-current-buffer buffer
6928 (gnus-kill-buffer gnus-article-buffer)
6929 (gnus-kill-buffer gnus-original-article-buffer)))
6932 (gnus-kill-summary-on-exit
6933 (when (and gnus-use-trees
6934 (gnus-buffer-exists-p buffer))
6937 (gnus-tree-close gnus-newsgroup-name)))
6938 (gnus-kill-buffer buffer))
6939 ;; Deaden the buffer.
6940 ((gnus-buffer-exists-p buffer)
6943 (gnus-deaden-summary))))))
6945 (defun gnus-summary-wake-up-the-dead (&rest args)
6946 "Wake up the dead summary buffer."
6948 (gnus-dead-summary-mode -1)
6949 (let ((name (buffer-name)))
6950 (when (string-match "Dead " name)
6952 (concat (substring name 0 (match-beginning 0))
6953 (substring name (match-end 0)))
6955 (gnus-message 3 "This dead summary is now alive again"))
6957 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6958 (defun gnus-summary-fetch-faq (&optional faq-dir)
6959 "Fetch the FAQ for the current group.
6960 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6964 (when current-prefix-arg
6966 "FAQ dir: " (and (listp gnus-group-faq-directory)
6968 gnus-group-faq-directory))))))
6969 (let (gnus-faq-buffer)
6970 (when (setq gnus-faq-buffer
6971 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6972 (gnus-configure-windows 'summary-faq))))
6974 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6975 (defun gnus-summary-describe-group (&optional force)
6976 "Describe the current newsgroup."
6978 (gnus-group-describe-group force gnus-newsgroup-name))
6980 (defun gnus-summary-describe-briefly ()
6981 "Describe summary mode commands briefly."
6983 (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")))
6985 ;; Walking around group mode buffer from summary mode.
6987 (defun gnus-summary-next-group (&optional no-article target-group backward)
6988 "Exit current newsgroup and then select next unread newsgroup.
6989 If prefix argument NO-ARTICLE is non-nil, no article is selected
6990 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6991 previous group instead."
6993 ;; Stop pre-fetching.
6994 (gnus-async-halt-prefetch)
6995 (let ((current-group gnus-newsgroup-name)
6996 (current-buffer (current-buffer))
6998 ;; First we semi-exit this group to update Xrefs and all variables.
6999 ;; We can't do a real exit, because the window conf must remain
7000 ;; the same in case the user is prompted for info, and we don't
7001 ;; want the window conf to change before that...
7002 (gnus-summary-exit t)
7003 (while (not entered)
7004 ;; Then we find what group we are supposed to enter.
7005 (set-buffer gnus-group-buffer)
7006 (gnus-group-jump-to-group current-group)
7009 (if (eq gnus-keep-same-level 'best)
7010 (gnus-summary-best-group gnus-newsgroup-name)
7011 (gnus-summary-search-group backward gnus-keep-same-level))))
7012 (if (not target-group)
7013 ;; There are no further groups, so we return to the group
7016 (gnus-message 5 "Returning to the group buffer")
7018 (when (gnus-buffer-live-p current-buffer)
7019 (set-buffer current-buffer)
7020 (gnus-summary-exit))
7021 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7022 ;; We try to enter the target group.
7023 (gnus-group-jump-to-group target-group)
7024 (let ((unreads (gnus-group-group-unread)))
7025 (if (and (or (eq t unreads)
7026 (and unreads (not (zerop unreads))))
7027 (gnus-summary-read-group
7028 target-group nil no-article
7029 (and (buffer-name current-buffer) current-buffer)
7032 (setq current-group target-group
7033 target-group nil)))))))
7035 (defun gnus-summary-prev-group (&optional no-article)
7036 "Exit current newsgroup and then select previous unread newsgroup.
7037 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7039 (gnus-summary-next-group no-article nil t))
7041 ;; Walking around summary lines.
7043 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7044 "Go to the first subject satisfying any non-nil constraint.
7045 If UNREAD is non-nil, the article should be unread.
7046 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7047 If UNSEEN is non-nil, the article should be unseen.
7048 Returns the article selected or nil if there are no matching articles."
7052 ((null gnus-newsgroup-data)
7053 (gnus-message 3 "No articles in the group")
7055 ;; Pick the first article.
7056 ((not (or unread undownloaded unseen))
7057 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7058 (gnus-data-number (car gnus-newsgroup-data)))
7059 ;; Find the first unread article.
7061 (let ((data gnus-newsgroup-data))
7063 (let ((num (gnus-data-number (car data))))
7064 (or (memq num gnus-newsgroup-unfetched)
7065 (not (or (and unread
7066 (memq num gnus-newsgroup-unreads))
7068 (memq num gnus-newsgroup-undownloaded))
7070 (memq num gnus-newsgroup-unseen)))))))
7071 (setq data (cdr data)))
7075 (goto-char (gnus-data-pos (car data)))
7076 (gnus-data-number (car data)))
7077 (gnus-message 3 "No more%s articles"
7078 (let* ((r (when unread " unread"))
7079 (d (when undownloaded " undownloaded"))
7080 (s (when unseen " unseen"))
7081 (l (delq nil (list r d s))))
7082 (cond ((= 3 (length l))
7083 (concat r "," d ", or" s))
7085 (concat (car l) ", or" (cadr l)))
7092 (gnus-summary-position-point))))))
7094 (defun gnus-summary-next-subject (n &optional unread dont-display)
7095 "Go to next N'th summary line.
7096 If N is negative, go to the previous N'th subject line.
7097 If UNREAD is non-nil, only unread articles are selected.
7098 The difference between N and the actual number of steps taken is
7101 (let ((backward (< n 0))
7105 (gnus-summary-find-prev unread)
7106 (gnus-summary-find-next unread)))
7107 (unless (zerop (setq n (1- n)))
7108 (gnus-summary-show-thread)))
7110 (gnus-message 7 "No more%s articles"
7111 (if unread " unread" "")))
7112 (unless dont-display
7113 (gnus-summary-recenter)
7114 (gnus-summary-position-point))
7117 (defun gnus-summary-next-unread-subject (n)
7118 "Go to next N'th unread summary line."
7120 (gnus-summary-next-subject n t))
7122 (defun gnus-summary-prev-subject (n &optional unread)
7123 "Go to previous N'th summary line.
7124 If optional argument UNREAD is non-nil, only unread article is selected."
7126 (gnus-summary-next-subject (- n) unread))
7128 (defun gnus-summary-prev-unread-subject (n)
7129 "Go to previous N'th unread summary line."
7131 (gnus-summary-next-subject (- n) t))
7133 (defun gnus-summary-goto-subjects (articles)
7134 "Insert the subject header for ARTICLES in the current buffer."
7136 (dolist (article articles)
7137 (gnus-summary-goto-subject article t)))
7138 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7139 (gnus-summary-position-point))
7141 (defun gnus-summary-goto-subject (article &optional force silent)
7142 "Go the subject line of ARTICLE.
7143 If FORCE, also allow jumping to articles not currently shown."
7144 (interactive "nArticle number: ")
7145 (unless (numberp article)
7146 (error "Article %s is not a number" article))
7148 (data (gnus-data-find article)))
7149 ;; We read in the article if we have to.
7152 (gnus-summary-insert-subject
7154 (if (or (numberp force) (vectorp force)) force)
7156 (setq data (gnus-data-find article)))
7161 (gnus-message 3 "Can't find article %d" article))
7163 (let ((pt (gnus-data-pos data)))
7165 (gnus-summary-set-article-display-arrow pt))
7166 (gnus-summary-position-point)
7169 ;; Walking around summary lines with displaying articles.
7171 (defun gnus-summary-expand-window (&optional arg)
7172 "Make the summary buffer take up the entire Emacs frame.
7173 Given a prefix, will force an `article' buffer configuration."
7176 (gnus-configure-windows 'article 'force)
7177 (gnus-configure-windows 'summary 'force)))
7179 (defun gnus-summary-display-article (article &optional all-header)
7180 "Display ARTICLE in article buffer."
7181 (when (gnus-buffer-live-p gnus-article-buffer)
7182 (with-current-buffer gnus-article-buffer
7183 (set-buffer-multibyte t)))
7184 (gnus-set-global-variables)
7185 (when (gnus-buffer-live-p gnus-article-buffer)
7186 (with-current-buffer gnus-article-buffer
7187 (setq gnus-article-charset gnus-newsgroup-charset)
7188 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7189 (set-buffer-multibyte t)))
7193 (if gnus-summary-display-article-function
7194 (funcall gnus-summary-display-article-function article all-header)
7195 (gnus-article-prepare article all-header))
7196 (with-current-buffer gnus-article-buffer
7197 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7199 (gnus-run-hooks 'gnus-select-article-hook)
7200 (when (and gnus-current-article
7201 (not (zerop gnus-current-article)))
7202 (gnus-summary-goto-subject gnus-current-article))
7203 (gnus-summary-recenter)
7204 (when (and gnus-use-trees gnus-show-threads)
7205 (gnus-possibly-generate-tree article)
7206 (gnus-highlight-selected-tree article))
7207 ;; Successfully display article.
7208 (gnus-article-set-window-start
7209 (cdr (assq article gnus-newsgroup-bookmarks))))))
7211 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7212 "Select the current article.
7213 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7214 non-nil, the article will be re-fetched even if it already present in
7215 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7217 ;; Make sure we are in the summary buffer to work around bbdb bug.
7218 (unless (eq major-mode 'gnus-summary-mode)
7219 (set-buffer gnus-summary-buffer))
7220 (let ((article (or article (gnus-summary-article-number)))
7221 (all-headers (not (not all-headers))) ;Must be T or NIL.
7222 gnus-summary-display-article-function)
7224 (gnus-summary-article-pseudo-p article)
7225 (error "This is a pseudo-article"))
7227 (set-buffer gnus-summary-buffer)
7228 (if (or (and gnus-single-article-buffer
7229 (or (null gnus-current-article)
7230 (null gnus-article-current)
7231 (null (get-buffer gnus-article-buffer))
7232 (not (eq article (cdr gnus-article-current)))
7233 (not (equal (car gnus-article-current)
7234 gnus-newsgroup-name))))
7235 (and (not gnus-single-article-buffer)
7236 (or (null gnus-current-article)
7237 (not (eq gnus-current-article article))))
7239 ;; The requested article is different from the current article.
7241 (gnus-summary-display-article article all-headers)
7242 (gnus-article-set-window-start
7243 (cdr (assq article gnus-newsgroup-bookmarks)))
7247 (defun gnus-summary-force-verify-and-decrypt ()
7248 "Display buttons for signed/encrypted parts and verify/decrypt them."
7250 (let ((mm-verify-option 'known)
7251 (mm-decrypt-option 'known)
7252 (gnus-article-emulate-mime t)
7253 (gnus-buttonized-mime-types (append (list "multipart/signed"
7254 "multipart/encrypted")
7255 gnus-buttonized-mime-types)))
7256 (gnus-summary-select-article nil 'force)))
7258 (defun gnus-summary-set-current-mark (&optional current-mark)
7259 "Obsolete function."
7262 (defun gnus-summary-next-article (&optional unread subject backward push)
7263 "Select the next article.
7264 If UNREAD, only unread articles are selected.
7265 If SUBJECT, only articles with SUBJECT are selected.
7266 If BACKWARD, the previous article is selected instead of the next."
7269 ;; Is there such an article?
7270 ((and (gnus-summary-search-forward unread subject backward)
7271 (or (gnus-summary-display-article (gnus-summary-article-number))
7272 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7273 (gnus-summary-position-point))
7274 ;; If not, we try the first unread, if that is wanted.
7276 gnus-auto-select-same
7277 (gnus-summary-first-unread-article))
7278 (gnus-summary-position-point)
7279 (gnus-message 6 "Wrapped"))
7280 ;; Try to get next/previous article not displayed in this group.
7281 ((and gnus-auto-extend-newsgroup
7282 (not unread) (not subject))
7283 (gnus-summary-goto-article
7284 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7285 nil (count-lines (point-min) (point))))
7286 ;; Go to next/previous group.
7288 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7289 (gnus-summary-jump-to-group gnus-newsgroup-name))
7290 (let ((cmd last-command-char)
7292 (with-current-buffer gnus-group-buffer
7295 (if (eq gnus-keep-same-level 'best)
7296 (gnus-summary-best-group gnus-newsgroup-name)
7297 (gnus-summary-search-group backward gnus-keep-same-level))))
7298 ;; For some reason, the group window gets selected. We change
7300 (select-window (get-buffer-window (current-buffer)))
7301 ;; Select next unread newsgroup automagically.
7303 ((or (not gnus-auto-select-next)
7305 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7306 ((or (eq gnus-auto-select-next 'quietly)
7307 (and (eq gnus-auto-select-next 'slightly-quietly)
7309 (and (eq gnus-auto-select-next 'almost-quietly)
7310 (gnus-summary-last-article-p)))
7312 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7314 (gnus-message 7 "No more%s articles (%s)..."
7315 (if unread " unread" "")
7316 (if group (concat "selecting " group)
7318 (gnus-summary-next-group nil group backward)))
7320 (when (gnus-key-press-event-p last-input-event)
7321 (gnus-summary-walk-group-buffer
7322 gnus-newsgroup-name cmd unread backward point))))))))
7324 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7325 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7326 (?\C-p (gnus-group-prev-unread-group 1))))
7327 (cursor-in-echo-area t)
7328 keve key group ended prompt)
7330 (set-buffer gnus-group-buffer)
7333 (if (eq gnus-keep-same-level 'best)
7334 (gnus-summary-best-group gnus-newsgroup-name)
7335 (gnus-summary-search-group backward gnus-keep-same-level))))
7339 "No more%s articles%s " (if unread " unread" "")
7341 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7342 (format " (Type %s for %s [%s])"
7343 (single-key-description cmd)
7344 (gnus-group-decoded-name group)
7345 (gnus-group-unread group))
7346 (format " (Type %s to exit %s)"
7347 (single-key-description cmd)
7348 (gnus-group-decoded-name gnus-newsgroup-name)))))
7349 ;; Confirm auto selection.
7350 (setq key (car (setq keve (gnus-read-event-char prompt)))
7353 ((assq key keystrokes)
7354 (let ((obuf (current-buffer)))
7355 (switch-to-buffer gnus-group-buffer)
7357 (gnus-group-jump-to-group group))
7358 (eval (cadr (assq key keystrokes)))
7359 (setq group (gnus-group-group-name))
7360 (switch-to-buffer obuf))
7364 (gnus-ephemeral-group-p gnus-newsgroup-name))
7366 (gnus-summary-next-group nil group backward)))
7368 (push (cdr keve) unread-command-events))))))
7370 (defun gnus-summary-next-unread-article ()
7371 "Select unread article after current one."
7373 (gnus-summary-next-article
7374 (or (not (eq gnus-summary-goto-unread 'never))
7375 (gnus-summary-last-article-p (gnus-summary-article-number)))
7376 (and gnus-auto-select-same
7377 (gnus-summary-article-subject))))
7379 (defun gnus-summary-prev-article (&optional unread subject)
7380 "Select the article after the current one.
7381 If UNREAD is non-nil, only unread articles are selected."
7383 (gnus-summary-next-article unread subject t))
7385 (defun gnus-summary-prev-unread-article ()
7386 "Select unread article before current one."
7388 (gnus-summary-prev-article
7389 (or (not (eq gnus-summary-goto-unread 'never))
7390 (gnus-summary-first-article-p (gnus-summary-article-number)))
7391 (and gnus-auto-select-same
7392 (gnus-summary-article-subject))))
7394 (defun gnus-summary-next-page (&optional lines circular stop)
7395 "Show next page of the selected article.
7396 If at the end of the current article, select the next article.
7397 LINES says how many lines should be scrolled up.
7399 If CIRCULAR is non-nil, go to the start of the article instead of
7400 selecting the next article when reaching the end of the current
7403 If STOP is non-nil, just stop when reaching the end of the message.
7405 Also see the variable `gnus-article-skip-boring'."
7407 (setq gnus-summary-buffer (current-buffer))
7408 (gnus-set-global-variables)
7409 (let ((article (gnus-summary-article-number))
7410 (article-window (get-buffer-window gnus-article-buffer t))
7412 ;; If the buffer is empty, we have no article.
7414 (error "No article to select"))
7415 (gnus-configure-windows 'article)
7416 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7417 (if (and (eq gnus-summary-goto-unread 'never)
7418 (not (gnus-summary-last-article-p article)))
7419 (gnus-summary-next-article)
7420 (gnus-summary-next-unread-article))
7421 (if (or (null gnus-current-article)
7422 (null gnus-article-current)
7423 (/= article (cdr gnus-article-current))
7424 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7425 ;; Selected subject is different from current article's.
7426 (gnus-summary-display-article article)
7427 (when article-window
7428 (gnus-eval-in-buffer-window gnus-article-buffer
7429 (setq endp (or (gnus-article-next-page lines)
7430 (gnus-article-only-boring-p))))
7433 (gnus-message 3 "End of message"))
7435 (gnus-summary-beginning-of-article))
7437 (gnus-message 3 "End of message"))
7439 (if (and (eq gnus-summary-goto-unread 'never)
7440 (not (gnus-summary-last-article-p article)))
7441 (gnus-summary-next-article)
7442 (gnus-summary-next-unread-article))))))))
7443 (gnus-summary-recenter)
7444 (gnus-summary-position-point)))
7446 (defun gnus-summary-prev-page (&optional lines move)
7447 "Show previous page of selected article.
7448 Argument LINES specifies lines to be scrolled down.
7449 If MOVE, move to the previous unread article if point is at
7450 the beginning of the buffer."
7452 (let ((article (gnus-summary-article-number))
7453 (article-window (get-buffer-window gnus-article-buffer t))
7455 (gnus-configure-windows 'article)
7456 (if (or (null gnus-current-article)
7457 (null gnus-article-current)
7458 (/= article (cdr gnus-article-current))
7459 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7460 ;; Selected subject is different from current article's.
7461 (gnus-summary-display-article article)
7462 (gnus-summary-recenter)
7463 (when article-window
7464 (gnus-eval-in-buffer-window gnus-article-buffer
7465 (setq endp (gnus-article-prev-page lines)))
7466 (when (and move endp)
7468 (gnus-message 3 "Beginning of message"))
7470 (if (and (eq gnus-summary-goto-unread 'never)
7471 (not (gnus-summary-first-article-p article)))
7472 (gnus-summary-prev-article)
7473 (gnus-summary-prev-unread-article))))))))
7474 (gnus-summary-position-point))
7476 (defun gnus-summary-prev-page-or-article (&optional lines)
7477 "Show previous page of selected article.
7478 Argument LINES specifies lines to be scrolled down.
7479 If at the beginning of the article, go to the next article."
7481 (gnus-summary-prev-page lines t))
7483 (defun gnus-summary-scroll-up (lines)
7484 "Scroll up (or down) one line current article.
7485 Argument LINES specifies lines to be scrolled up (or down if negative)."
7487 (gnus-configure-windows 'article)
7488 (gnus-summary-show-thread)
7489 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7490 (gnus-eval-in-buffer-window gnus-article-buffer
7492 (when (gnus-article-next-page lines)
7493 (gnus-message 3 "End of message")))
7495 (gnus-article-prev-page (- lines))))))
7496 (gnus-summary-recenter)
7497 (gnus-summary-position-point))
7499 (defun gnus-summary-scroll-down (lines)
7500 "Scroll down (or up) one line current article.
7501 Argument LINES specifies lines to be scrolled down (or up if negative)."
7503 (gnus-summary-scroll-up (- lines)))
7505 (defun gnus-summary-next-same-subject ()
7506 "Select next article which has the same subject as current one."
7508 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7510 (defun gnus-summary-prev-same-subject ()
7511 "Select previous article which has the same subject as current one."
7513 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7515 (defun gnus-summary-next-unread-same-subject ()
7516 "Select next unread article which has the same subject as current one."
7518 (gnus-summary-next-article t (gnus-summary-article-subject)))
7520 (defun gnus-summary-prev-unread-same-subject ()
7521 "Select previous unread article which has the same subject as current one."
7523 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7525 (defun gnus-summary-first-unread-article ()
7526 "Select the first unread article.
7527 Return nil if there are no unread articles."
7530 (when (gnus-summary-first-subject t)
7531 (gnus-summary-show-thread)
7532 (gnus-summary-first-subject t)
7533 (gnus-summary-display-article (gnus-summary-article-number)))
7534 (gnus-summary-position-point)))
7536 (defun gnus-summary-first-unread-subject ()
7537 "Place the point on the subject line of the first unread article.
7538 Return nil if there are no unread articles."
7541 (when (gnus-summary-first-subject t)
7542 (gnus-summary-show-thread)
7543 (gnus-summary-first-subject t))
7544 (gnus-summary-position-point)))
7546 (defun gnus-summary-first-unseen-subject ()
7547 "Place the point on the subject line of the first unseen article.
7548 Return nil if there are no unseen articles."
7551 (when (gnus-summary-first-subject nil nil t)
7552 (gnus-summary-show-thread)
7553 (gnus-summary-first-subject nil nil t))
7554 (gnus-summary-position-point)))
7556 (defun gnus-summary-first-unseen-or-unread-subject ()
7557 "Place the point on the subject line of the first unseen article or,
7558 if all article have been seen, on the subject line of the first unread
7562 (unless (when (gnus-summary-first-subject nil nil t)
7563 (gnus-summary-show-thread)
7564 (gnus-summary-first-subject nil nil t))
7565 (when (gnus-summary-first-subject t)
7566 (gnus-summary-show-thread)
7567 (gnus-summary-first-subject t)))
7568 (gnus-summary-position-point)))
7570 (defun gnus-summary-first-article ()
7571 "Select the first article.
7572 Return nil if there are no articles."
7575 (when (gnus-summary-first-subject)
7576 (gnus-summary-show-thread)
7577 (gnus-summary-first-subject)
7578 (gnus-summary-display-article (gnus-summary-article-number)))
7579 (gnus-summary-position-point)))
7581 (defun gnus-summary-best-unread-article (&optional arg)
7582 "Select the unread article with the highest score.
7583 If given a prefix argument, select the next unread article that has a
7584 score higher than the default score."
7586 (let ((article (if arg
7587 (gnus-summary-better-unread-subject)
7588 (gnus-summary-best-unread-subject))))
7590 (gnus-summary-goto-article article)
7591 (error "No unread articles"))))
7593 (defun gnus-summary-best-unread-subject ()
7594 "Select the unread subject with the highest score."
7596 (let ((best -1000000)
7597 (data gnus-newsgroup-data)
7600 (and (gnus-data-unread-p (car data))
7602 (gnus-summary-article-score (gnus-data-number (car data))))
7605 article (gnus-data-number (car data))))
7606 (setq data (cdr data)))
7608 (gnus-summary-goto-subject article))
7609 (gnus-summary-position-point)
7612 (defun gnus-summary-better-unread-subject ()
7613 "Select the first unread subject that has a score over the default score."
7615 (let ((data gnus-newsgroup-data)
7617 (while (and (setq article (gnus-data-number (car data)))
7618 (or (gnus-data-read-p (car data))
7619 (not (> (gnus-summary-article-score article)
7620 gnus-summary-default-score))))
7621 (setq data (cdr data)))
7623 (gnus-summary-goto-subject article))
7624 (gnus-summary-position-point)
7627 (defun gnus-summary-last-subject ()
7628 "Go to the last displayed subject line in the group."
7629 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7631 (gnus-summary-goto-subject article))))
7633 (defun gnus-summary-goto-article (article &optional all-headers force)
7634 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7635 If ALL-HEADERS is non-nil, no header lines are hidden.
7636 If FORCE, go to the article even if it isn't displayed. If FORCE
7637 is a number, it is the line the article is to be displayed on."
7641 "Article number or Message-ID: "
7642 (mapcar (lambda (number) (list (int-to-string number)))
7643 gnus-newsgroup-limit))
7647 (if (and (stringp article)
7648 (string-match "@\\|%40" article))
7649 (gnus-summary-refer-article article)
7650 (when (stringp article)
7651 (setq article (string-to-number article)))
7652 (if (gnus-summary-goto-subject article force)
7653 (gnus-summary-display-article article all-headers)
7654 (gnus-message 4 "Couldn't go to article %s" article) nil))
7655 (gnus-summary-position-point)))
7657 (defun gnus-summary-goto-last-article ()
7658 "Go to the previously read article."
7661 (when gnus-last-article
7662 (gnus-summary-goto-article gnus-last-article nil t))
7663 (gnus-summary-position-point)))
7665 (defun gnus-summary-pop-article (number)
7666 "Pop one article off the history and go to the previous.
7667 NUMBER articles will be popped off."
7670 (setq gnus-newsgroup-history
7671 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7673 (gnus-summary-goto-article (car to) nil t)
7674 (error "Article history empty")))
7675 (gnus-summary-position-point))
7677 ;; Summary commands and functions for limiting the summary buffer.
7679 (defun gnus-summary-limit-to-articles (n)
7680 "Limit the summary buffer to the next N articles.
7681 If not given a prefix, use the process marked articles instead."
7684 (let ((articles (gnus-summary-work-articles n)))
7685 (setq gnus-newsgroup-processable nil)
7686 (gnus-summary-limit articles))
7687 (gnus-summary-position-point)))
7689 (defun gnus-summary-pop-limit (&optional total)
7690 "Restore the previous limit.
7691 If given a prefix, remove all limits."
7694 (setq gnus-newsgroup-limits
7695 (list (mapcar (lambda (h) (mail-header-number h))
7696 gnus-newsgroup-headers))))
7697 (unless gnus-newsgroup-limits
7698 (error "No limit to pop"))
7700 (gnus-summary-limit nil 'pop)
7701 (gnus-summary-position-point)))
7703 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7704 "Limit the summary buffer to articles that have subjects that match a regexp.
7705 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7707 (list (read-string (if current-prefix-arg
7708 "Exclude subject (regexp): "
7709 "Limit to subject (regexp): "))
7710 nil current-prefix-arg))
7712 (setq header "subject"))
7713 (when (not (equal "" subject))
7715 (let ((articles (gnus-summary-find-matching
7716 (or header "subject") subject 'all nil nil
7719 (error "Found no matches for \"%s\"" subject))
7720 (gnus-summary-limit articles))
7721 (gnus-summary-position-point))))
7723 (defun gnus-summary-limit-to-author (from &optional not-matching)
7724 "Limit the summary buffer to articles that have authors that match a regexp.
7725 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7727 (list (read-string (if current-prefix-arg
7728 "Exclude author (regexp): "
7729 "Limit to author (regexp): "))
7730 current-prefix-arg))
7731 (gnus-summary-limit-to-subject from "from" not-matching))
7733 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
7734 "Limit the summary buffer to articles with the given RECIPIENT.
7736 If NOT-MATCHING, exclude RECIPIENT.
7738 To and Cc headers are checked. You need to include them in
7739 `nnmail-extra-headers'."
7740 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
7742 (list (read-string (format "%s recipient (regexp): "
7743 (if current-prefix-arg "Exclude" "Limit to")))
7744 current-prefix-arg))
7745 (when (not (equal "" recipient))
7747 (if (memq 'To nnmail-extra-headers)
7748 (gnus-summary-find-matching
7749 (cons 'extra 'To) recipient 'all nil nil
7752 1 "`To' isn't present in `nnmail-extra-headers'")
7756 (if (memq 'Cc nnmail-extra-headers)
7757 (gnus-summary-find-matching
7758 (cons 'extra 'Cc) recipient 'all nil nil
7761 1 "`Cc' isn't present in `nnmail-extra-headers'")
7766 ;; We need the numbers that are in both lists:
7768 (and (memq a to) a))
7772 (error "Found no matches for \"%s\"" recipient))
7773 (gnus-summary-limit articles))
7774 (gnus-summary-position-point))))
7776 (defun gnus-summary-limit-to-age (age &optional younger-p)
7777 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7778 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7779 articles that are younger than AGE days."
7781 (let ((younger current-prefix-arg)
7784 (while (not days-got)
7785 (setq days (if younger
7786 (read-string "Limit to articles younger than (in days, older when negative): ")
7788 "Limit to articles older than (in days, younger when negative): ")))
7789 (when (> (length days) 0)
7790 (setq days (read days)))
7795 (setq younger (not younger))
7796 (setq days (* days -1))))
7797 (message "Please enter a number.")
7799 (list days younger)))
7801 (let ((data gnus-newsgroup-data)
7802 (cutoff (days-to-time age))
7803 articles d date is-younger)
7804 (while (setq d (pop data))
7805 (when (and (vectorp (gnus-data-header d))
7806 (setq date (mail-header-date (gnus-data-header d))))
7807 (setq is-younger (time-less-p
7808 (time-since (condition-case ()
7815 (push (gnus-data-number d) articles))))
7816 (gnus-summary-limit (nreverse articles)))
7817 (gnus-summary-position-point)))
7819 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7820 "Limit the summary buffer to articles that match an 'extra' header."
7824 (gnus-completing-read-with-default
7825 (symbol-name (car gnus-extra-headers))
7826 (if current-prefix-arg
7827 "Exclude extra header"
7828 "Limit extra header")
7830 (cons (symbol-name x) x))
7835 (read-string (format "%s header %s (regexp): "
7836 (if current-prefix-arg "Exclude" "Limit to")
7838 current-prefix-arg)))
7839 (when (not (equal "" regexp))
7841 (let ((articles (gnus-summary-find-matching
7842 (cons 'extra header) regexp 'all nil nil
7845 (error "Found no matches for \"%s\"" regexp))
7846 (gnus-summary-limit articles))
7847 (gnus-summary-position-point))))
7849 (defun gnus-summary-limit-to-display-predicate ()
7850 "Limit the summary buffer to the predicated in the `display' group parameter."
7852 (unless gnus-newsgroup-display
7853 (error "There is no `display' group parameter"))
7855 (dolist (number gnus-newsgroup-articles)
7856 (when (funcall gnus-newsgroup-display)
7857 (push number articles)))
7858 (gnus-summary-limit articles))
7859 (gnus-summary-position-point))
7861 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7863 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7865 (defun gnus-summary-limit-to-unread (&optional all)
7866 "Limit the summary buffer to articles that are not marked as read.
7867 If ALL is non-nil, limit strictly to unread articles."
7870 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7871 (gnus-summary-limit-to-marks
7872 ;; Concat all the marks that say that an article is read and have
7874 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7875 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7876 gnus-low-score-mark gnus-expirable-mark
7877 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7878 gnus-duplicate-mark gnus-souped-mark)
7881 (defun gnus-summary-limit-to-replied (&optional unreplied)
7882 "Limit the summary buffer to replied articles.
7883 If UNREPLIED (the prefix), limit to unreplied articles."
7887 (gnus-set-difference gnus-newsgroup-articles
7888 gnus-newsgroup-replied))
7889 (gnus-summary-limit gnus-newsgroup-replied))
7890 (gnus-summary-position-point))
7892 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7893 (make-obsolete 'gnus-summary-delete-marked-with
7894 'gnus-summary-limit-exclude-marks)
7896 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7897 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7898 If REVERSE, limit the summary buffer to articles that are marked
7899 with MARKS. MARKS can either be a string of marks or a list of marks.
7900 Returns how many articles were removed."
7901 (interactive "sMarks: ")
7902 (gnus-summary-limit-to-marks marks t))
7904 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7905 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7906 If REVERSE (the prefix), limit the summary buffer to articles that are
7907 not marked with MARKS. MARKS can either be a string of marks or a
7909 Returns how many articles were removed."
7910 (interactive "sMarks: \nP")
7912 (let ((data gnus-newsgroup-data)
7913 (marks (if (listp marks) marks
7914 (append marks nil))) ; Transform to list.
7917 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7918 (memq (gnus-data-mark (car data)) marks))
7919 (push (gnus-data-number (car data)) articles))
7920 (setq data (cdr data)))
7921 (gnus-summary-limit articles))
7922 (gnus-summary-position-point)))
7924 (defun gnus-summary-limit-to-score (score)
7925 "Limit to articles with score at or above SCORE."
7926 (interactive "NLimit to articles with score of at least: ")
7927 (let ((data gnus-newsgroup-data)
7930 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7932 (push (gnus-data-number (car data)) articles))
7933 (setq data (cdr data)))
7935 (gnus-summary-limit articles)
7936 (gnus-summary-position-point))))
7938 (defun gnus-summary-limit-to-unseen ()
7939 "Limit to unseen articles."
7942 (gnus-summary-limit gnus-newsgroup-unseen)
7943 (gnus-summary-position-point)))
7945 (defun gnus-summary-limit-include-thread (id)
7946 "Display all the hidden articles that is in the thread with ID in it.
7947 When called interactively, ID is the Message-ID of the current
7949 (interactive (list (mail-header-id (gnus-summary-article-header))))
7950 (let ((articles (gnus-articles-in-thread
7951 (gnus-id-to-thread (gnus-root-id id)))))
7953 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7954 (gnus-summary-limit-include-matching-articles
7956 (regexp-quote (gnus-simplify-subject-re
7957 (mail-header-subject (gnus-id-to-header id)))))
7958 (gnus-summary-position-point))))
7960 (defun gnus-summary-limit-include-matching-articles (header regexp)
7961 "Display all the hidden articles that have HEADERs that match REGEXP."
7962 (interactive (list (read-string "Match on header: ")
7963 (read-string "Regexp: ")))
7964 (let ((articles (gnus-find-matching-articles header regexp)))
7966 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7967 (gnus-summary-position-point))))
7969 (defun gnus-summary-insert-dormant-articles ()
7970 "Insert all the dormant articles for this group into the current buffer."
7972 (let ((gnus-verbose (max 6 gnus-verbose)))
7973 (if (not gnus-newsgroup-dormant)
7974 (gnus-message 3 "No cached articles for this group")
7975 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7977 (defun gnus-summary-limit-include-dormant ()
7978 "Display all the hidden articles that are marked as dormant.
7979 Note that this command only works on a subset of the articles currently
7980 fetched for this group."
7982 (unless gnus-newsgroup-dormant
7983 (error "There are no dormant articles in this group"))
7985 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7986 (gnus-summary-position-point)))
7988 (defun gnus-summary-limit-exclude-dormant ()
7989 "Hide all dormant articles."
7992 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7993 (gnus-summary-position-point)))
7995 (defun gnus-summary-limit-exclude-childless-dormant ()
7996 "Hide all dormant articles that have no children."
7998 (let ((data (gnus-data-list t))
7999 articles d children)
8000 ;; Find all articles that are either not dormant or have
8002 (while (setq d (pop data))
8003 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8005 (gnus-article-children (gnus-data-number d)))
8008 (when (memq (car children) articles)
8013 (push (gnus-data-number d) articles)))
8016 (gnus-summary-limit articles)
8017 (gnus-summary-position-point))))
8019 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8020 "Mark all unread excluded articles as read.
8021 If ALL, mark even excluded ticked and dormants as read."
8023 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8024 (let ((articles (gnus-sorted-ndifference
8026 (mapcar (lambda (h) (mail-header-number h))
8027 gnus-newsgroup-headers)
8029 gnus-newsgroup-limit))
8031 (setq gnus-newsgroup-unreads
8032 (gnus-sorted-intersection gnus-newsgroup-unreads
8033 gnus-newsgroup-limit))
8035 (setq gnus-newsgroup-dormant nil
8036 gnus-newsgroup-marked nil
8037 gnus-newsgroup-reads
8039 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8040 gnus-newsgroup-reads))
8041 (while (setq article (pop articles))
8042 (unless (or (memq article gnus-newsgroup-dormant)
8043 (memq article gnus-newsgroup-marked))
8044 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8046 (defun gnus-summary-limit (articles &optional pop)
8048 ;; We pop the previous limit off the stack and use that.
8049 (setq articles (car gnus-newsgroup-limits)
8050 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8051 ;; We use the new limit, so we push the old limit on the stack.
8052 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8054 (setq gnus-newsgroup-limit articles)
8055 (let ((total (length gnus-newsgroup-data))
8056 (data (gnus-data-find-list (gnus-summary-article-number)))
8057 (gnus-summary-mark-below nil) ; Inhibit this.
8059 ;; This will do all the work of generating the new summary buffer
8060 ;; according to the new limit.
8061 (gnus-summary-prepare)
8062 ;; Hide any threads, possibly.
8063 (gnus-summary-maybe-hide-threads)
8064 ;; Try to return to the article you were at, or one in the
8067 ;; We try to find some article after the current one.
8069 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8072 (setq data (cdr data))))
8074 ;; If there is no data, that means that we were after the last
8075 ;; article. The same goes when we can't find any articles
8076 ;; after the current one.
8077 (goto-char (point-max))
8078 (gnus-summary-find-prev))
8079 (gnus-set-mode-line 'summary)
8080 ;; We return how many articles were removed from the summary
8081 ;; buffer as a result of the new limit.
8082 (- total (length gnus-newsgroup-data))))
8084 (defsubst gnus-invisible-cut-children (threads)
8087 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8092 (defsubst gnus-cut-thread (thread)
8093 "Go forwards in the thread until we find an article that we want to display."
8094 (when (or (eq gnus-fetch-old-headers 'some)
8095 (eq gnus-fetch-old-headers 'invisible)
8096 (numberp gnus-fetch-old-headers)
8097 (eq gnus-build-sparse-threads 'some)
8098 (eq gnus-build-sparse-threads 'more))
8099 ;; Deal with old-fetched headers and sparse threads.
8103 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8104 (gnus-summary-article-ancient-p
8105 (mail-header-number (car thread))))
8106 (if (or (<= (length (cdr thread)) 1)
8107 (eq gnus-fetch-old-headers 'invisible))
8108 (setq gnus-newsgroup-limit
8109 (delq (mail-header-number (car thread))
8110 gnus-newsgroup-limit)
8111 thread (cadr thread))
8112 (when (gnus-invisible-cut-children (cdr thread))
8113 (let ((th (cdr thread)))
8115 (if (memq (mail-header-number (caar th))
8116 gnus-newsgroup-limit)
8117 (setq thread (car th)
8119 (setq th (cdr th))))))))))
8122 (defun gnus-cut-threads (threads)
8123 "Cut off all uninteresting articles from the beginning of THREADS."
8124 (when (or (eq gnus-fetch-old-headers 'some)
8125 (eq gnus-fetch-old-headers 'invisible)
8126 (numberp gnus-fetch-old-headers)
8127 (eq gnus-build-sparse-threads 'some)
8128 (eq gnus-build-sparse-threads 'more))
8131 (setcar th (gnus-cut-thread (car th)))
8132 (setq th (cdr th)))))
8133 ;; Remove nixed out threads.
8136 (defun gnus-summary-initial-limit (&optional show-if-empty)
8137 "Figure out what the initial limit is supposed to be on group entry.
8138 This entails weeding out unwanted dormants, low-scored articles,
8139 fetch-old-headers verbiage, and so on."
8140 ;; Most groups have nothing to remove.
8141 (if (or gnus-inhibit-limiting
8142 (and (null gnus-newsgroup-dormant)
8143 (eq gnus-newsgroup-display 'gnus-not-ignore)
8144 (not (eq gnus-fetch-old-headers 'some))
8145 (not (numberp gnus-fetch-old-headers))
8146 (not (eq gnus-fetch-old-headers 'invisible))
8147 (null gnus-summary-expunge-below)
8148 (not (eq gnus-build-sparse-threads 'some))
8149 (not (eq gnus-build-sparse-threads 'more))
8150 (null gnus-thread-expunge-below)
8151 (not gnus-use-nocem)))
8153 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8154 (setq gnus-newsgroup-limit nil)
8157 (unless (car (symbol-value node))
8158 ;; These threads have no parents -- they are roots.
8159 (let ((nodes (cdr (symbol-value node)))
8162 (if (and gnus-thread-expunge-below
8163 (< (gnus-thread-total-score (car nodes))
8164 gnus-thread-expunge-below))
8165 (gnus-expunge-thread (pop nodes))
8166 (setq thread (pop nodes))
8167 (gnus-summary-limit-children thread))))))
8168 gnus-newsgroup-dependencies)
8169 ;; If this limitation resulted in an empty group, we might
8170 ;; pop the previous limit and use it instead.
8171 (when (and (not gnus-newsgroup-limit)
8173 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8174 gnus-newsgroup-limit))
8176 (defun gnus-summary-limit-children (thread)
8177 "Return 1 if this subthread is visible and 0 if it is not."
8178 ;; First we get the number of visible children to this thread. This
8179 ;; is done by recursing down the thread using this function, so this
8180 ;; will really go down to a leaf article first, before slowly
8181 ;; working its way up towards the root.
8183 (let* ((max-lisp-eval-depth 5000)
8186 (apply '+ (mapcar 'gnus-summary-limit-children
8189 (number (mail-header-number (car thread)))
8192 (not (memq number gnus-newsgroup-marked))
8194 ;; If this article is dormant and has absolutely no visible
8195 ;; children, then this article isn't visible.
8196 (and (memq number gnus-newsgroup-dormant)
8198 ;; If this is "fetch-old-headered" and there is no
8199 ;; visible children, then we don't want this article.
8200 (and (or (eq gnus-fetch-old-headers 'some)
8201 (numberp gnus-fetch-old-headers))
8202 (gnus-summary-article-ancient-p number)
8204 ;; If this is "fetch-old-headered" and `invisible', then
8205 ;; we don't want this article.
8206 (and (eq gnus-fetch-old-headers 'invisible)
8207 (gnus-summary-article-ancient-p number))
8208 ;; If this is a sparsely inserted article with no children,
8209 ;; we don't want it.
8210 (and (eq gnus-build-sparse-threads 'some)
8211 (gnus-summary-article-sparse-p number)
8213 ;; If we use expunging, and this article is really
8214 ;; low-scored, then we don't want this article.
8215 (when (and gnus-summary-expunge-below
8217 (or (cdr (assq number gnus-newsgroup-scored))
8218 gnus-summary-default-score))
8219 gnus-summary-expunge-below))
8220 ;; We increase the expunge-tally here, but that has
8221 ;; nothing to do with the limits, really.
8222 (incf gnus-newsgroup-expunged-tally)
8223 ;; We also mark as read here, if that's wanted.
8224 (when (and gnus-summary-mark-below
8225 (< score gnus-summary-mark-below))
8226 (setq gnus-newsgroup-unreads
8227 (delq number gnus-newsgroup-unreads))
8228 (if gnus-newsgroup-auto-expire
8229 (push number gnus-newsgroup-expirable)
8230 (push (cons number gnus-low-score-mark)
8231 gnus-newsgroup-reads)))
8233 ;; Do the `display' group parameter.
8234 (and gnus-newsgroup-display
8235 (not (funcall gnus-newsgroup-display)))
8236 ;; Check NoCeM things.
8237 (when (and gnus-use-nocem
8238 (gnus-nocem-unwanted-article-p
8239 (mail-header-id (car thread))))
8240 (setq gnus-newsgroup-unreads
8241 (delq number gnus-newsgroup-unreads))
8243 ;; Nope, invisible article.
8245 ;; Ok, this article is to be visible, so we add it to the limit
8247 (push number gnus-newsgroup-limit)
8250 (defun gnus-expunge-thread (thread)
8251 "Mark all articles in THREAD as read."
8252 (let* ((number (mail-header-number (car thread))))
8253 (incf gnus-newsgroup-expunged-tally)
8254 ;; We also mark as read here, if that's wanted.
8255 (setq gnus-newsgroup-unreads
8256 (delq number gnus-newsgroup-unreads))
8257 (if gnus-newsgroup-auto-expire
8258 (push number gnus-newsgroup-expirable)
8259 (push (cons number gnus-low-score-mark)
8260 gnus-newsgroup-reads)))
8261 ;; Go recursively through all subthreads.
8262 (mapcar 'gnus-expunge-thread (cdr thread)))
8264 ;; Summary article oriented commands
8266 (defun gnus-summary-refer-parent-article (n)
8267 "Refer parent article N times.
8268 If N is negative, go to ancestor -N instead.
8269 The difference between N and the number of articles fetched is returned."
8273 (when (not (natnump n))
8278 (setq header (gnus-summary-article-header))
8279 (if (and (eq (mail-header-number header)
8280 (cdr gnus-article-current))
8281 (equal gnus-newsgroup-name
8282 (car gnus-article-current)))
8283 ;; If we try to find the parent of the currently
8284 ;; displayed article, then we take a look at the actual
8285 ;; References header, since this is slightly more
8286 ;; reliable than the References field we got from the
8289 (set-buffer gnus-original-article-buffer)
8290 (nnheader-narrow-to-headers)
8291 (unless (setq ref (message-fetch-field "references"))
8292 (when (setq ref (message-fetch-field "in-reply-to"))
8293 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8296 ;; It's not the current article, so we take a bet on
8297 ;; the value we got from the server.
8298 (mail-header-references header)))
8300 (not (equal ref "")))
8301 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8302 (gnus-message 1 "Couldn't find parent"))
8303 (gnus-message 1 "No references in article %d"
8304 (gnus-summary-article-number))
8307 (gnus-summary-position-point)
8310 (defun gnus-summary-refer-references ()
8311 "Fetch all articles mentioned in the References header.
8312 Return the number of articles fetched."
8314 (let ((ref (mail-header-references (gnus-summary-article-header)))
8315 (current (gnus-summary-article-number))
8319 (error "No References in the current article")
8320 ;; For each Message-ID in the References header...
8321 (while (string-match "<[^>]*>" ref)
8323 ;; ... fetch that article.
8324 (gnus-summary-refer-article
8325 (prog1 (match-string 0 ref)
8326 (setq ref (substring ref (match-end 0))))))
8327 (gnus-summary-goto-subject current)
8328 (gnus-summary-position-point)
8331 (defun gnus-summary-refer-thread (&optional limit)
8332 "Fetch all articles in the current thread.
8333 If LIMIT (the numerical prefix), fetch that many old headers instead
8334 of what's specified by the `gnus-refer-thread-limit' variable."
8336 (let ((id (mail-header-id (gnus-summary-article-header)))
8337 (limit (if limit (prefix-numeric-value limit)
8338 gnus-refer-thread-limit)))
8339 (unless (eq gnus-fetch-old-headers 'invisible)
8340 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8341 ;; Retrieve the headers and read them in.
8342 (if (eq (if (numberp limit)
8343 (gnus-retrieve-headers
8345 (+ (mail-header-number
8346 (gnus-summary-article-header))
8348 gnus-newsgroup-end))
8349 gnus-newsgroup-name (* limit 2))
8350 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8352 (gnus-retrieve-headers (list gnus-newsgroup-end)
8353 gnus-newsgroup-name limit))
8355 (gnus-build-all-threads)
8356 (error "Can't fetch thread from back ends that don't support NOV"))
8357 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8358 (gnus-summary-limit-include-thread id)))
8360 (defun gnus-summary-refer-article (message-id)
8361 "Fetch an article specified by MESSAGE-ID."
8362 (interactive "sMessage-ID: ")
8363 (when (and (stringp message-id)
8364 (not (zerop (length message-id))))
8365 (setq message-id (gnus-replace-in-string message-id " " ""))
8366 ;; Construct the correct Message-ID if necessary.
8367 ;; Suggested by tale@pawl.rpi.edu.
8368 (unless (string-match "^<" message-id)
8369 (setq message-id (concat "<" message-id)))
8370 (unless (string-match ">$" message-id)
8371 (setq message-id (concat message-id ">")))
8372 ;; People often post MIDs from URLs, so unhex it:
8373 (unless (string-match "@" message-id)
8374 (setq message-id (gnus-url-unhex-string message-id)))
8375 (let* ((header (gnus-id-to-header message-id))
8377 (gnus-summary-article-sparse-p
8378 (mail-header-number header))
8379 (memq (mail-header-number header)
8380 gnus-newsgroup-limit)))
8383 ;; If the article is present in the buffer we just go to it.
8385 (or (not (gnus-summary-article-sparse-p
8386 (mail-header-number header)))
8389 (gnus-summary-goto-article
8390 (mail-header-number header) nil t)
8392 (gnus-summary-update-article (mail-header-number header)))))
8394 ;; We fetch the article.
8396 (dolist (gnus-override-method (gnus-refer-article-methods))
8397 (when (and (gnus-check-server gnus-override-method)
8398 ;; Fetch the header,
8399 (setq number (gnus-summary-insert-subject message-id)))
8400 ;; and display the article.
8401 (gnus-summary-select-article nil nil nil number)
8403 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8405 (defun gnus-refer-article-methods ()
8406 "Return a list of referable methods."
8408 ;; No method, so we default to current and native.
8409 ((null gnus-refer-article-method)
8410 (list gnus-current-select-method gnus-select-method))
8412 ((eq 'current gnus-refer-article-method)
8413 (list gnus-current-select-method))
8414 ;; List of select methods.
8415 ((not (and (symbolp (car gnus-refer-article-method))
8416 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8418 (dolist (method gnus-refer-article-method)
8419 (push (if (eq 'current method)
8420 gnus-current-select-method
8424 ;; One single select method.
8426 (list gnus-refer-article-method))))
8428 (defun gnus-summary-edit-parameters ()
8429 "Edit the group parameters of the current group."
8431 (gnus-group-edit-group gnus-newsgroup-name 'params))
8433 (defun gnus-summary-customize-parameters ()
8434 "Customize the group parameters of the current group."
8436 (gnus-group-customize gnus-newsgroup-name))
8438 (defun gnus-summary-enter-digest-group (&optional force)
8439 "Enter an nndoc group based on the current article.
8440 If FORCE, force a digest interpretation. If not, try
8441 to guess what the document format is."
8443 (let ((conf gnus-current-window-configuration))
8444 (save-window-excursion
8446 (let (gnus-article-prepare-hook
8447 gnus-display-mime-function
8449 (gnus-summary-select-article))))
8450 (setq gnus-current-window-configuration conf)
8451 (let* ((name (format "%s-%d"
8452 (gnus-group-prefixed-name
8453 gnus-newsgroup-name (list 'nndoc ""))
8454 (with-current-buffer gnus-summary-buffer
8455 gnus-current-article)))
8456 (ogroup gnus-newsgroup-name)
8457 (params (append (gnus-info-params (gnus-get-info ogroup))
8458 (list (cons 'to-group ogroup))
8459 (list (cons 'parent-group ogroup))
8460 (list (cons 'save-article-group ogroup))))
8461 (case-fold-search t)
8462 (buf (current-buffer))
8465 (set-buffer gnus-original-article-buffer)
8466 ;; Have the digest group inherit the main mail address of
8467 ;; the parent article.
8468 (when (setq to-address (or (gnus-fetch-field "reply-to")
8469 (gnus-fetch-field "from")))
8470 (setq params (append
8471 (list (cons 'to-address
8472 (funcall gnus-decode-encoded-word-function
8474 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8475 (insert-buffer-substring gnus-original-article-buffer)
8476 ;; Remove lines that may lead nndoc to misinterpret the
8479 (goto-char (point-min))
8480 (or (search-forward "\n\n" nil t) (point)))
8481 (goto-char (point-min))
8482 (delete-matching-lines "^Path:\\|^From ")
8485 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8486 (gnus-newsgroup-ephemeral-ignored-charsets
8487 gnus-newsgroup-ignored-charsets))
8488 (gnus-group-read-ephemeral-group
8489 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8491 ,(if force 'mbox 'guess)))
8493 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8495 ;; Make all postings to this group go to the parent group.
8496 (nconc (gnus-info-params (gnus-get-info name))
8498 ;; Couldn't select this doc group.
8499 (switch-to-buffer buf)
8500 (gnus-set-global-variables)
8501 (gnus-configure-windows 'summary)
8502 (gnus-message 3 "Article couldn't be entered?"))
8503 (kill-buffer dig)))))
8505 (defun gnus-summary-read-document (n)
8506 "Open a new group based on the current article(s).
8507 This will allow you to read digests and other similar
8508 documents as newsgroups.
8509 Obeys the standard process/prefix convention."
8511 (let* ((ogroup gnus-newsgroup-name)
8512 (params (append (gnus-info-params (gnus-get-info ogroup))
8513 (list (cons 'to-group ogroup))))
8514 group egroup groups vgroup)
8515 (dolist (article (gnus-summary-work-articles n))
8516 (setq group (format "%s-%d" gnus-newsgroup-name article))
8517 (gnus-summary-remove-process-mark article)
8518 (when (gnus-summary-display-article article)
8521 (insert-buffer-substring gnus-original-article-buffer)
8522 ;; Remove some headers that may lead nndoc to make
8524 (message-narrow-to-head)
8525 (goto-char (point-min))
8526 (delete-matching-lines "^Path:\\|^From ")
8529 (gnus-group-read-ephemeral-group
8530 group `(nndoc ,group (nndoc-address ,(current-buffer))
8531 (nndoc-article-type guess))
8534 ;; Make all postings to this group go to the parent group.
8535 (nconc (gnus-info-params (gnus-get-info egroup))
8537 (push egroup groups))
8538 ;; Couldn't select this doc group.
8539 (gnus-error 3 "Article couldn't be entered"))))))
8540 ;; Now we have selected all the documents.
8543 (error "None of the articles could be interpreted as documents"))
8544 ((gnus-group-read-ephemeral-group
8545 (setq vgroup (format
8546 "nnvirtual:%s-%s" gnus-newsgroup-name
8547 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8548 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8550 (cons (current-buffer) 'summary)))
8552 (error "Couldn't select virtual nndoc group")))))
8554 (defun gnus-summary-isearch-article (&optional regexp-p)
8555 "Do incremental search forward on the current article.
8556 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8558 (let* ((gnus-inhibit-treatment t)
8559 (old (gnus-summary-select-article)))
8560 (gnus-configure-windows 'article)
8561 (gnus-eval-in-buffer-window gnus-article-buffer
8565 (gnus-article-show-all-headers))
8566 (goto-char (point-min))
8567 (isearch-forward regexp-p)))))
8569 (defun gnus-summary-search-article-forward (regexp &optional backward)
8570 "Search for an article containing REGEXP forward.
8571 If BACKWARD, search backward instead."
8574 (format "Search article %s (regexp%s): "
8575 (if current-prefix-arg "backward" "forward")
8576 (if gnus-last-search-regexp
8577 (concat ", default " gnus-last-search-regexp)
8579 current-prefix-arg))
8580 (if (string-equal regexp "")
8581 (setq regexp (or gnus-last-search-regexp ""))
8582 (setq gnus-last-search-regexp regexp)
8583 (setq gnus-article-before-search gnus-current-article))
8584 ;; Intentionally set gnus-last-article.
8585 (setq gnus-last-article gnus-article-before-search)
8586 (let ((gnus-last-article gnus-last-article))
8587 (if (gnus-summary-search-article regexp backward)
8588 (gnus-summary-show-thread)
8589 (signal 'search-failed (list regexp)))))
8591 (defun gnus-summary-search-article-backward (regexp)
8592 "Search for an article containing REGEXP backward."
8595 (format "Search article backward (regexp%s): "
8596 (if gnus-last-search-regexp
8597 (concat ", default " gnus-last-search-regexp)
8599 (gnus-summary-search-article-forward regexp 'backward))
8602 (defmacro gnus-summary-search-article-position-point (regexp backward)
8603 "Dehighlight the last matched text and goto the beginning position."
8604 (` (if (and gnus-summary-search-article-matched-data
8605 (let ((text (caddr gnus-summary-search-article-matched-data))
8606 (inhibit-read-only t)
8609 (goto-char (car gnus-summary-search-article-matched-data))
8610 (cadr gnus-summary-search-article-matched-data))
8612 (string-match (, regexp) text)))
8613 (if (, backward) (beginning-of-line) (end-of-line))
8614 (goto-char (if (, backward) (point-max) (point-min))))))
8616 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8617 "Place point where X-Face image is displayed."
8618 (if (featurep 'xemacs)
8619 (` (let ((end (if (search-forward "\n\n" nil t)
8620 (goto-char (1- (point)))
8623 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8624 (unless (and (re-search-forward "^From:" end t)
8625 (setq extent (extent-at (point)))
8626 (extent-begin-glyph extent))
8627 (goto-char (, opoint)))))
8628 (` (let ((end (if (search-forward "\n\n" nil t)
8629 (goto-char (1- (point)))
8631 (start (or (search-backward "\n\n" nil t) (point-min))))
8633 (or (text-property-any start end 'x-face-image t);; x-face-e21
8636 (defmacro gnus-summary-search-article-highlight-matched-text
8637 (backward treated x-face)
8638 "Highlight matched text in the function `gnus-summary-search-article'."
8639 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8640 (end (set-marker (make-marker) (match-end 0)))
8641 (inhibit-read-only t)
8645 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8647 (lambda (item) (setq items (delq item items)))
8648 '(gnus-treat-buttonize
8649 gnus-treat-fill-article
8650 gnus-treat-fill-long-lines
8651 gnus-treat-emphasize
8652 gnus-treat-highlight-headers
8653 gnus-treat-highlight-citation
8654 gnus-treat-highlight-signature
8655 gnus-treat-overstrike
8656 gnus-treat-display-x-face
8657 gnus-treat-buttonize-head
8658 gnus-treat-decode-article-as-default-mime-charset))
8660 (gnus-treat-display-x-face
8661 (when (, x-face) gnus-treat-display-x-face)))
8662 (gnus-article-prepare-mime-display)))
8663 (goto-char (if (, backward) start end))
8665 (gnus-summary-search-article-highlight-goto-x-face (point)))
8666 (setq gnus-summary-search-article-matched-data
8667 (list start end (buffer-substring start end)))
8668 (unless (eq start end);; matched text has been deleted. :-<
8669 (put-text-property start end 'face
8670 (or (find-face 'isearch)
8671 'secondary-selection))))))
8674 (defun gnus-summary-search-article (regexp &optional backward)
8675 "Search for an article containing REGEXP.
8676 Optional argument BACKWARD means do search for backward.
8677 `gnus-select-article-hook' is not called during the search."
8678 ;; We have to require this here to make sure that the following
8679 ;; dynamic binding isn't shadowed by autoloading.
8680 (require 'gnus-async)
8682 (let ((gnus-select-article-hook nil) ;Disable hook.
8683 (gnus-article-prepare-hook nil)
8684 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8685 (gnus-use-article-prefetch nil)
8686 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8687 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8689 (gnus-keep-backlog nil)
8690 (gnus-break-pages nil)
8691 (gnus-summary-display-arrow nil)
8692 (gnus-updated-mode-lines nil)
8693 (gnus-auto-center-summary nil)
8694 (sum (current-buffer))
8697 (gnus-save-hidden-threads
8698 (static-if (featurep 'xemacs)
8699 (let ((gnus-inhibit-treatment t))
8700 (setq treated (eq 'old (gnus-summary-select-article)))
8702 (not (and (gnus-buffer-live-p gnus-article-buffer)
8703 (window-live-p (get-buffer-window
8704 gnus-article-buffer t)))))
8705 (gnus-summary-select-article nil t)
8706 (setq treated nil)))
8707 (let ((gnus-inhibit-treatment t))
8708 (setq treated (eq 'old (gnus-summary-select-article)))
8711 (and (gnus-buffer-live-p gnus-article-buffer)
8712 (window-live-p (get-buffer-window
8713 gnus-article-buffer t))
8714 (or (not (string-match "^\\^X-Face:" regexp))
8715 (with-current-buffer gnus-article-buffer
8716 gnus-summary-search-article-matched-data)))))
8717 (gnus-summary-select-article nil t)
8718 (setq treated nil))))
8719 (set-buffer gnus-article-buffer)
8723 (gnus-article-show-all-headers)
8724 (gnus-summary-search-article-position-point regexp backward))
8725 (goto-char (if backward (point-max) (point-min))))
8727 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8729 (re-search-backward regexp nil t)
8730 (re-search-forward regexp nil t))
8731 ;; We found the regexp.
8733 (gnus-summary-search-article-highlight-matched-text
8734 backward treated (string-match "^\\^X-Face:" regexp))
8737 (/ (- 2 (window-height
8738 (get-buffer-window gnus-article-buffer t)))
8741 (get-buffer-window (current-buffer))
8744 (setq point (point)))
8745 ;; We didn't find it, so we go to the next article.
8748 (while (eq found 'not)
8749 (if (not (if backward (gnus-summary-find-prev)
8750 (gnus-summary-find-next)))
8751 ;; No more articles.
8753 ;; Select the next article and adjust point.
8754 (unless (gnus-summary-article-sparse-p
8755 (gnus-summary-article-number))
8757 (let ((gnus-inhibit-treatment t))
8758 (gnus-summary-select-article))
8760 (set-buffer gnus-article-buffer)
8762 (goto-char (if backward (point-max) (point-min))))))))
8763 (gnus-message 7 ""))
8764 ;; Return whether we found the regexp.
8765 (when (eq found 'found)
8767 (gnus-summary-show-thread)
8768 (gnus-summary-goto-subject gnus-current-article)
8769 (gnus-summary-position-point)
8772 (defun gnus-find-matching-articles (header regexp)
8773 "Return a list of all articles that match REGEXP on HEADER.
8774 This search includes all articles in the current group that Gnus has
8775 fetched headers for, whether they are displayed or not."
8776 (let ((articles nil)
8777 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8778 (case-fold-search t))
8779 (dolist (header gnus-newsgroup-headers)
8780 (when (string-match regexp (funcall func header))
8781 (push (mail-header-number header) articles)))
8782 (nreverse articles)))
8784 (defun gnus-summary-find-matching (header regexp &optional backward unread
8785 not-case-fold not-matching)
8786 "Return a list of all articles that match REGEXP on HEADER.
8787 The search stars on the current article and goes forwards unless
8788 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8789 If UNREAD is non-nil, only unread articles will
8790 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8791 in the comparisons. If NOT-MATCHING, return a list of all articles that
8792 not match REGEXP on HEADER."
8793 (let ((case-fold-search (not not-case-fold))
8796 (if (eq (car header) 'extra)
8799 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8801 (error "%s is an invalid header" header))
8802 (unless (fboundp (intern (concat "mail-header-" header)))
8803 (error "%s is not a valid header" header))
8804 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8805 (dolist (d (if (eq backward 'all)
8807 (gnus-data-find-list
8808 (gnus-summary-article-number)
8809 (gnus-data-list backward))))
8810 (when (and (or (not unread) ; We want all articles...
8811 (gnus-data-unread-p d)) ; Or just unreads.
8812 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8816 (funcall func (gnus-data-header d))))
8817 (string-match regexp
8818 (funcall func (gnus-data-header d)))))
8819 (push (gnus-data-number d) articles))) ; Success!
8820 (nreverse articles)))
8822 (defun gnus-summary-execute-command (header regexp command &optional backward)
8823 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8824 If HEADER is an empty string (or nil), the match is done on the entire
8825 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8827 (list (let ((completion-ignore-case t))
8830 (mapcar (lambda (header) (list (format "%s" header)))
8832 '("Number" "Subject" "From" "Lines" "Date"
8833 "Message-ID" "Xref" "References" "Body")
8834 gnus-extra-headers))
8835 nil 'require-match))
8836 (read-string "Regexp: ")
8837 (read-key-sequence "Command: ")
8838 current-prefix-arg))
8839 (when (equal header "Body")
8841 ;; Hidden thread subtrees must be searched as well.
8842 (gnus-summary-show-all-threads)
8843 ;; We don't want to change current point nor window configuration.
8845 (save-window-excursion
8847 gnus-treat-strip-trailing-blank-lines
8848 gnus-treat-strip-leading-blank-lines
8849 gnus-treat-strip-multiple-blank-lines
8850 gnus-treat-hide-boring-headers
8851 gnus-treat-fold-newsgroups
8852 gnus-article-prepare-hook)
8853 (gnus-message 6 "Executing %s..." (key-description command))
8854 ;; We'd like to execute COMMAND interactively so as to give arguments.
8855 (gnus-execute header regexp
8856 `(call-interactively ',(key-binding command))
8858 (gnus-message 6 "Executing %s...done" (key-description command))))))
8860 (defun gnus-summary-beginning-of-article ()
8861 "Scroll the article back to the beginning."
8863 (gnus-summary-select-article)
8864 (gnus-configure-windows 'article)
8865 (gnus-eval-in-buffer-window gnus-article-buffer
8867 (goto-char (point-min))
8868 (when gnus-break-pages
8869 (gnus-narrow-to-page))))
8871 (defun gnus-summary-end-of-article ()
8872 "Scroll to the end of the article."
8874 (gnus-summary-select-article)
8875 (gnus-configure-windows 'article)
8876 (gnus-eval-in-buffer-window gnus-article-buffer
8878 (goto-char (point-max))
8880 (when gnus-break-pages
8881 (when (re-search-backward page-delimiter nil t)
8882 (narrow-to-region (match-end 0) (point-max)))
8883 (gnus-narrow-to-page))))
8885 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8886 "Truncate to LEN and quote all \"(\"'s in STRING."
8887 (gnus-replace-in-string (if (and len (> (length string) len))
8888 (substring string 0 len)
8892 (defun gnus-summary-print-article (&optional filename n)
8893 "Generate and print a PostScript image of the process-marked (mail) articles.
8895 If used interactively, print the current article if none are
8896 process-marked. With prefix arg, prompt the user for the name of the
8899 When used from Lisp, accept two optional args FILENAME and N. N means
8900 to print the next N articles. If N is negative, print the N previous
8901 articles. If N is nil and articles have been marked with the process
8902 mark, print these instead.
8904 If the optional first argument FILENAME is nil, send the image to the
8905 printer. If FILENAME is a string, save the PostScript image in a file with
8906 that name. If FILENAME is a number, prompt the user for the name of the file
8908 (interactive (list (ps-print-preprint current-prefix-arg)))
8909 (dolist (article (gnus-summary-work-articles n))
8910 (gnus-summary-select-article nil nil 'pseudo article)
8911 (gnus-eval-in-buffer-window gnus-article-buffer
8912 (gnus-print-buffer))
8913 (gnus-summary-remove-process-mark article))
8914 (ps-despool filename))
8916 (defun gnus-print-buffer ()
8917 (let ((buffer (generate-new-buffer " *print*")))
8920 (copy-to-buffer buffer (point-min) (point-max))
8922 (gnus-remove-text-with-property 'gnus-decoration)
8923 (when (gnus-visual-p 'article-highlight 'highlight)
8924 ;; Copy-to-buffer doesn't copy overlay. So redo
8926 (let ((gnus-article-buffer buffer))
8927 (gnus-article-highlight-citation t)
8928 (gnus-article-highlight-signature)
8929 (gnus-article-emphasize)
8930 (gnus-article-delete-invisible-text)))
8931 (let ((ps-left-header
8934 (gnus-summary-print-truncate-and-quote
8935 (mail-header-subject gnus-current-headers)
8938 (gnus-summary-print-truncate-and-quote
8939 (mail-header-from gnus-current-headers)
8943 "/pagenumberstring load"
8945 (mail-header-date gnus-current-headers) ")"))))
8946 (gnus-run-hooks 'gnus-ps-print-hook)
8949 (ps-spool-buffer-with-faces)
8950 (ps-spool-buffer)))))
8951 (kill-buffer buffer))))
8953 (defun gnus-summary-show-article (&optional arg)
8954 "Force redisplaying of the current article.
8955 If ARG (the prefix) is a number, show the article with the charset
8956 defined in `gnus-summary-show-article-charset-alist', or the charset
8958 If ARG (the prefix) is non-nil and not a number, show the raw article
8959 without any article massaging functions being run. Normally, the key
8960 strokes are `C-u g'."
8964 (gnus-summary-show-article t)
8965 (let* ((gnus-newsgroup-charset
8966 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8967 (mm-read-coding-system
8968 "View as charset: " ;; actually it is coding system.
8969 (with-current-buffer gnus-article-buffer
8970 (mm-detect-coding-region (point) (point-max))))))
8971 (default-mime-charset gnus-newsgroup-charset)
8972 (gnus-newsgroup-ignored-charsets 'gnus-all))
8973 (gnus-summary-select-article nil 'force)
8974 (let ((deps gnus-newsgroup-dependencies)
8977 (set-buffer gnus-original-article-buffer)
8979 (message-narrow-to-head)
8980 (setq head (buffer-string))
8981 (goto-char (point-min))
8982 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8983 (goto-char (point-max))
8985 (setq lines (1- (count-lines (point) (point-max))))))
8987 (insert (format "211 %d Article retrieved.\n"
8988 (cdr gnus-article-current)))
8990 (if lines (insert (format "Lines: %d\n" lines)))
8992 (let ((nntp-server-buffer (current-buffer)))
8993 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8994 (gnus-data-set-header
8995 (gnus-data-find (cdr gnus-article-current))
8997 (gnus-summary-update-article-line
8998 (cdr gnus-article-current) header)
8999 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9000 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9002 ;; Select the article the normal way.
9003 (gnus-summary-select-article nil 'force))
9005 ;; We have to require this here to make sure that the following
9006 ;; dynamic binding isn't shadowed by autoloading.
9007 (require 'gnus-async)
9009 ;; Bind the article treatment functions to nil.
9010 (let ((gnus-have-all-headers t)
9011 gnus-article-prepare-hook
9012 gnus-article-decode-hook
9015 (gnus-inhibit-treatment t))
9016 (gnus-summary-select-article nil 'force))))
9017 (gnus-summary-goto-subject gnus-current-article)
9018 (gnus-summary-position-point))
9020 (defun gnus-summary-show-raw-article ()
9021 "Show the raw article without any article massaging functions being run."
9023 (gnus-summary-show-article t))
9025 (defun gnus-summary-verbose-headers (&optional arg)
9026 "Toggle permanent full header display.
9027 If ARG is a positive number, turn header display on.
9028 If ARG is a negative number, turn header display off."
9030 (setq gnus-show-all-headers
9031 (cond ((or (not (numberp arg))
9033 (not gnus-show-all-headers))
9036 (gnus-summary-show-article))
9038 (defun gnus-summary-toggle-header (&optional arg)
9039 "Show the headers if they are hidden, or hide them if they are shown.
9040 If ARG is a positive number, show the entire header.
9041 If ARG is a negative number, hide the unwanted header lines."
9043 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9044 (get-buffer-window gnus-article-buffer t))))
9045 (with-current-buffer gnus-article-buffer
9047 (article-narrow-to-head)
9048 (let* ((buffer-read-only nil)
9049 (inhibit-point-motion-hooks t)
9050 (hidden (if (numberp arg)
9052 (or (not (looking-at "[^ \t\n]+:"))
9053 (gnus-article-hidden-text-p 'headers))))
9055 (delete-region (point-min) (point-max))
9056 (with-current-buffer gnus-original-article-buffer
9057 (goto-char (setq s (point-min)))
9058 (setq e (if (search-forward "\n\n" nil t)
9061 (insert-buffer-substring gnus-original-article-buffer s e)
9062 ;; In T-gnus, gnus-article-decode-hook doesn't contain
9063 ;; article-decode-encoded-words by default.
9064 (article-decode-encoded-words)
9065 (run-hooks 'gnus-article-decode-hook)
9067 (let ((gnus-treat-hide-headers nil)
9068 (gnus-treat-hide-boring-headers nil))
9069 (gnus-delete-wash-type 'headers)
9070 (gnus-treat-article 'head))
9071 (gnus-treat-article 'head))
9074 (set-window-start window (goto-char (point-min))))
9075 (if gnus-break-pages
9076 (gnus-narrow-to-page)
9077 (when (gnus-visual-p 'page-marker)
9078 (let ((buffer-read-only nil))
9079 (gnus-remove-text-with-property 'gnus-prev)
9080 (gnus-remove-text-with-property 'gnus-next))))
9081 (gnus-set-mode-line 'article)))))
9083 (defun gnus-summary-show-all-headers ()
9084 "Make all header lines visible."
9086 (gnus-summary-toggle-header 1))
9088 (defun gnus-summary-toggle-mime (&optional arg)
9089 "Toggle MIME processing.
9090 If ARG is a positive number, turn MIME processing on."
9092 (setq gnus-show-mime
9094 (not gnus-show-mime)
9095 (> (prefix-numeric-value arg) 0)))
9096 (gnus-summary-select-article t 'force))
9098 (defun gnus-summary-caesar-message (&optional arg)
9099 "Caesar rotate the current article by 13.
9100 The numerical prefix specifies how many places to rotate each letter
9103 (gnus-summary-select-article)
9104 (let ((mail-header-separator ""))
9105 (gnus-eval-in-buffer-window gnus-article-buffer
9108 (let ((start (window-start))
9110 (message-caesar-buffer-body arg)
9111 (set-window-start (get-buffer-window (current-buffer)) start)))))
9112 ;; Create buttons and stuff...
9113 (gnus-treat-article nil))
9115 (defun gnus-summary-idna-message (&optional arg)
9116 "Decode IDNA encoded domain names in the current articles.
9117 IDNA encoded domain names looks like `xn--bar'. If a string
9118 remain unencoded after running this function, it is likely an
9119 invalid IDNA string (`xn--bar' is invalid).
9121 You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9122 installed for this command to work."
9124 (if (not (and (condition-case nil (require 'idna)
9126 (mm-coding-system-p 'utf-8)
9127 (executable-find (symbol-value 'idna-program))))
9129 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9130 (gnus-summary-select-article)
9131 (let ((mail-header-separator ""))
9132 (gnus-eval-in-buffer-window gnus-article-buffer
9135 (let ((start (window-start))
9137 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9138 (replace-match (idna-to-unicode (match-string 1))))
9139 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9141 (autoload 'unmorse-region "morse"
9142 "Convert morse coded text in region to ordinary ASCII text."
9145 (defun gnus-summary-morse-message (&optional arg)
9146 "Morse decode the current article."
9148 (gnus-summary-select-article)
9149 (let ((mail-header-separator ""))
9150 (gnus-eval-in-buffer-window gnus-article-buffer
9154 (let ((pos (window-start))
9156 (goto-char (point-min))
9157 (when (message-goto-body)
9158 (gnus-narrow-to-body))
9159 (goto-char (point-min))
9160 (while (search-forward "·" (point-max) t)
9161 (replace-match "."))
9162 (unmorse-region (point-min) (point-max))
9164 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9166 (defun gnus-summary-stop-page-breaking ()
9167 "Stop page breaking in the current article."
9169 (gnus-summary-select-article)
9170 (gnus-eval-in-buffer-window gnus-article-buffer
9172 (when (gnus-visual-p 'page-marker)
9173 (let ((buffer-read-only nil))
9174 (gnus-remove-text-with-property 'gnus-prev)
9175 (gnus-remove-text-with-property 'gnus-next))
9176 (setq gnus-page-broken nil))))
9178 (defun gnus-summary-move-article (&optional n to-newsgroup
9179 select-method action)
9180 "Move the current article to a different newsgroup.
9181 If N is a positive number, move the N next articles.
9182 If N is a negative number, move the N previous articles.
9183 If N is nil and any articles have been marked with the process mark,
9184 move those articles instead.
9185 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9186 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9187 re-spool using this method.
9189 When called interactively with TO-NEWSGROUP being nil, the value of
9190 the variable `gnus-move-split-methods' is used for finding a default
9191 for the target newsgroup.
9193 For this function to work, both the current newsgroup and the
9194 newsgroup that you want to move to have to support the `request-move'
9195 and `request-accept' functions.
9197 ACTION can be either `move' (the default), `crosspost' or `copy'."
9200 (setq action 'move))
9201 ;; Check whether the source group supports the required functions.
9202 (cond ((and (eq action 'move)
9203 (not (gnus-check-backend-function
9204 'request-move-article gnus-newsgroup-name)))
9205 (error "The current group does not support article moving"))
9206 ((and (eq action 'crosspost)
9207 (not (gnus-check-backend-function
9208 'request-replace-article gnus-newsgroup-name)))
9209 (error "The current group does not support article editing")))
9210 (let ((articles (gnus-summary-work-articles n))
9211 (prefix (if (gnus-check-backend-function
9212 'request-move-article gnus-newsgroup-name)
9213 (funcall gnus-move-group-prefix-function
9214 gnus-newsgroup-name)
9216 (names '((move "Move" "Moving")
9217 (copy "Copy" "Copying")
9218 (crosspost "Crosspost" "Crossposting")))
9219 (copy-buf (save-excursion
9220 (nnheader-set-temp-buffer " *copy article*")))
9221 art-group to-method new-xref article to-groups articles-to-update-marks)
9222 (unless (assq action names)
9223 (error "Unknown action %s" action))
9224 ;; Read the newsgroup name.
9225 (when (and (not to-newsgroup)
9226 (not select-method))
9227 (if (and gnus-move-split-methods
9229 (and (memq gnus-current-article articles)
9230 (gnus-buffer-live-p gnus-original-article-buffer))))
9231 ;; When `gnus-move-split-methods' is non-nil, we have to
9232 ;; select an article to give `gnus-read-move-group-name' an
9233 ;; opportunity to suggest an appropriate default. However,
9234 ;; we needn't render or mark the article.
9235 (let ((gnus-display-mime-function nil)
9236 (gnus-article-prepare-hook nil)
9237 (gnus-mark-article-hook nil))
9238 (gnus-summary-select-article nil nil nil (car articles))))
9240 (gnus-read-move-group-name
9241 (cadr (assq action names))
9242 (symbol-value (intern (format "gnus-current-%s-group" action)))
9244 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9245 (setq to-method (or select-method
9246 (gnus-server-to-method
9247 (gnus-group-method to-newsgroup))))
9248 ;; Check the method we are to move this article to...
9249 (unless (gnus-check-backend-function
9250 'request-accept-article (car to-method))
9251 (error "%s does not support article copying" (car to-method)))
9252 (unless (gnus-check-server to-method)
9253 (error "Can't open server %s" (car to-method)))
9254 (gnus-message 6 "%s to %s: %s..."
9255 (caddr (assq action names))
9256 (or (car select-method) to-newsgroup) articles)
9258 (setq article (pop articles))
9262 ;; Move the article.
9264 ;; Remove this article from future suppression.
9265 (gnus-dup-unsuppress-article article)
9266 (let* ((from-method (gnus-find-method-for-group
9267 gnus-newsgroup-name))
9268 (to-method (gnus-find-method-for-group
9270 (move-is-internal (gnus-method-equal from-method to-method)))
9271 (gnus-request-move-article
9272 article ; Article to move
9273 gnus-newsgroup-name ; From newsgroup
9274 (nth 1 (gnus-find-method-for-group
9275 gnus-newsgroup-name)) ; Server
9276 (list 'gnus-request-accept-article
9277 to-newsgroup (list 'quote select-method)
9278 (not articles) t) ; Accept form
9279 (not articles) ; Only save nov last time
9280 move-is-internal))) ; is this move internal?
9281 ;; Copy the article.
9284 (set-buffer copy-buf)
9285 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9287 (nnheader-narrow-to-headers)
9288 (dolist (hdr gnus-copy-article-ignored-headers)
9289 (message-remove-header hdr t)))
9290 (gnus-request-accept-article
9291 to-newsgroup select-method (not articles) t))))
9292 ;; Crosspost the article.
9293 ((eq action 'crosspost)
9294 (let ((xref (message-tokenize-header
9295 (mail-header-xref (gnus-summary-article-header article))
9297 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9298 ":" (number-to-string article)))
9300 (setq xref (list (system-name))))
9303 (mapconcat 'identity
9304 (delete "Xref:" (delete new-xref xref))
9308 (set-buffer copy-buf)
9309 ;; First put the article in the destination group.
9310 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9311 (when (consp (setq art-group
9312 (gnus-request-accept-article
9313 to-newsgroup select-method (not articles))))
9314 (setq new-xref (concat new-xref " " (car art-group)
9316 (number-to-string (cdr art-group))))
9317 ;; Now we have the new Xrefs header, so we insert
9318 ;; it and replace the new article.
9319 (nnheader-replace-header "Xref" new-xref)
9320 (gnus-request-replace-article
9321 (cdr art-group) to-newsgroup (current-buffer))
9325 (gnus-message 1 "Couldn't %s article %s: %s"
9326 (cadr (assq action names)) article
9327 (nnheader-get-report (car to-method))))
9328 ((eq art-group 'junk)
9329 (when (eq action 'move)
9330 (gnus-summary-mark-article article gnus-canceled-mark)
9331 (gnus-message 4 "Deleted article %s" article)
9332 ;; run the delete hook
9333 (run-hook-with-args 'gnus-summary-article-delete-hook
9336 (assoc article (gnus-data-list nil)))
9337 gnus-newsgroup-name nil
9340 (let* ((pto-group (gnus-group-prefixed-name
9341 (car art-group) to-method))
9342 (info (gnus-get-info pto-group))
9343 (to-group (gnus-info-group info))
9345 ;; Update the group that has been moved to.
9347 (memq action '(move copy)))
9348 (unless (member to-group to-groups)
9349 (push to-group to-groups))
9351 (unless (memq article gnus-newsgroup-unreads)
9352 (push 'read to-marks)
9354 info (gnus-add-to-range (gnus-info-read info)
9355 (list (cdr art-group)))))
9357 ;; See whether the article is to be put in the cache.
9358 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9359 gnus-article-mark-lists
9360 (delete '(expirable . expire)
9361 (copy-sequence gnus-article-mark-lists))))
9362 (to-article (cdr art-group)))
9364 ;; Enter the article into the cache in the new group,
9365 ;; if that is required.
9366 (when gnus-use-cache
9367 (gnus-cache-possibly-enter-article
9369 (let ((header (copy-sequence
9370 (gnus-summary-article-header article))))
9371 (mail-header-set-number header to-article)
9373 (memq article gnus-newsgroup-marked)
9374 (memq article gnus-newsgroup-dormant)
9375 (memq article gnus-newsgroup-unreads)))
9377 (when gnus-preserve-marks
9378 ;; Copy any marks over to the new group.
9379 (when (and (equal to-group gnus-newsgroup-name)
9380 (not (memq article gnus-newsgroup-unreads)))
9381 ;; Mark this article as read in this group.
9382 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9383 (setcdr (gnus-active to-group) to-article)
9384 (setcdr gnus-newsgroup-active to-article))
9387 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9388 (when (memq article (symbol-value
9389 (intern (format "gnus-newsgroup-%s"
9391 (push (cdar marks) to-marks)
9392 ;; If the other group is the same as this group,
9393 ;; then we have to add the mark to the list.
9394 (when (equal to-group gnus-newsgroup-name)
9395 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9398 (intern (format "gnus-newsgroup-%s"
9400 ;; Copy the marks to other group.
9401 (gnus-add-marked-articles
9402 to-group (cdar marks) (list to-article) info)))
9403 (setq marks (cdr marks)))
9405 (gnus-request-set-mark
9406 to-group (list (list (list to-article) 'add to-marks))))
9409 (concat "(gnus-group-set-info '"
9410 (gnus-prin1-to-string (gnus-get-info to-group))
9413 ;; Update the Xref header in this article to point to
9414 ;; the new crossposted article we have just created.
9415 (when (eq action 'crosspost)
9417 (set-buffer copy-buf)
9418 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9419 (nnheader-replace-header "Xref" new-xref)
9420 (gnus-request-replace-article
9421 article gnus-newsgroup-name (current-buffer))))
9423 ;; run the move/copy/crosspost/respool hook
9424 (run-hook-with-args 'gnus-summary-article-move-hook
9427 (assoc article (gnus-data-list nil)))
9432 ;;;!!!Why is this necessary?
9433 (set-buffer gnus-summary-buffer)
9435 (gnus-summary-goto-subject article)
9436 (when (eq action 'move)
9437 (gnus-summary-mark-article article gnus-canceled-mark))))
9438 (push article articles-to-update-marks))
9440 (apply 'gnus-summary-remove-process-mark articles-to-update-marks)
9441 ;; Re-activate all groups that have been moved to.
9443 (set-buffer gnus-group-buffer)
9444 (let ((gnus-group-marked to-groups))
9445 (gnus-group-get-new-news-this-group nil t)))
9447 (gnus-kill-buffer copy-buf)
9448 (gnus-summary-position-point)
9449 (gnus-set-mode-line 'summary)))
9451 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9452 "Copy the current article to some other group.
9453 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9454 When called interactively, if TO-NEWSGROUP is nil, use the value of
9455 the variable `gnus-move-split-methods' for finding a default target
9457 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9458 re-spool using this method."
9460 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9462 (defun gnus-summary-crosspost-article (&optional n)
9463 "Crosspost the current article to some other group."
9465 (gnus-summary-move-article n nil nil 'crosspost))
9467 (defcustom gnus-summary-respool-default-method nil
9468 "Default method type for respooling an article.
9469 If nil, use to the current newsgroup method."
9471 :group 'gnus-summary-mail)
9473 (defcustom gnus-summary-display-while-building nil
9474 "If non-nil, show and update the summary buffer as it's being built.
9475 If the value is t, update the buffer after every line is inserted. If
9476 the value is an integer (N), update the display every N lines."
9479 :type '(choice (const :tag "off" nil)
9481 (const :tag "frequently" t)))
9483 (defun gnus-summary-respool-article (&optional n method)
9484 "Respool the current article.
9485 The article will be squeezed through the mail spooling process again,
9486 which means that it will be put in some mail newsgroup or other
9487 depending on `nnmail-split-methods'.
9488 If N is a positive number, respool the N next articles.
9489 If N is a negative number, respool the N previous articles.
9490 If N is nil and any articles have been marked with the process mark,
9491 respool those articles instead.
9493 Respooling can be done both from mail groups and \"real\" newsgroups.
9494 In the former case, the articles in question will be moved from the
9495 current group into whatever groups they are destined to. In the
9496 latter case, they will be copied into the relevant groups."
9498 (list current-prefix-arg
9499 (let* ((methods (gnus-methods-using 'respool))
9501 (symbol-name (or gnus-summary-respool-default-method
9502 (car (gnus-find-method-for-group
9503 gnus-newsgroup-name)))))
9505 (gnus-completing-read-with-default
9506 methname "Backend to use when respooling"
9507 methods nil t nil 'gnus-mail-method-history))
9510 ((zerop (length (setq ms (gnus-servers-using-backend
9512 (list (intern method) ""))
9516 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9517 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9520 (error "No method given for respooling"))
9521 (if (assoc (symbol-name
9522 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9523 (gnus-methods-using 'respool))
9524 (gnus-summary-move-article n nil method)
9525 (gnus-summary-copy-article n nil method)))
9527 (defun gnus-summary-import-article (file &optional edit)
9528 "Import an arbitrary file into a mail newsgroup."
9529 (interactive "fImport file: \nP")
9530 (let ((group gnus-newsgroup-name)
9531 (now (current-time))
9532 atts lines group-art)
9533 (unless (gnus-check-backend-function 'request-accept-article group)
9534 (error "%s does not support article importing" group))
9535 (or (file-readable-p file)
9536 (not (file-regular-p file))
9537 (error "Can't read %s" file))
9539 (set-buffer (gnus-get-buffer-create " *import file*"))
9541 (nnheader-insert-file-contents file)
9542 (goto-char (point-min))
9543 (if (nnheader-article-p)
9545 (goto-char (point-min))
9546 (search-forward "\n\n" nil t)
9547 (narrow-to-region (point-min) (1- (point)))
9548 (goto-char (point-min))
9549 (unless (re-search-forward "^date:" nil t)
9550 (goto-char (point-max))
9551 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9552 ;; This doesn't look like an article, so we fudge some headers.
9553 (setq atts (file-attributes file)
9554 lines (count-lines (point-min) (point-max)))
9555 (insert "From: " (read-string "From: ") "\n"
9556 "Subject: " (read-string "Subject: ") "\n"
9557 "Date: " (message-make-date (nth 5 atts)) "\n"
9558 "Message-ID: " (message-make-message-id) "\n"
9559 "Lines: " (int-to-string lines) "\n"
9560 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9561 (setq group-art (gnus-request-accept-article group nil t))
9562 (kill-buffer (current-buffer)))
9563 (setq gnus-newsgroup-active (gnus-activate-group group))
9565 (gnus-summary-goto-article (cdr group-art) nil t)
9567 (gnus-summary-edit-article))))
9569 (defun gnus-summary-create-article ()
9570 "Create an article in a mail newsgroup."
9572 (let ((group gnus-newsgroup-name)
9573 (now (current-time))
9575 (unless (gnus-check-backend-function 'request-accept-article group)
9576 (error "%s does not support article importing" group))
9578 (set-buffer (gnus-get-buffer-create " *import file*"))
9580 (goto-char (point-min))
9581 ;; This doesn't look like an article, so we fudge some headers.
9582 (insert "From: " (read-string "From: ") "\n"
9583 "Subject: " (read-string "Subject: ") "\n"
9584 "Date: " (message-make-date now) "\n"
9585 "Message-ID: " (message-make-message-id) "\n")
9586 (setq group-art (gnus-request-accept-article group nil t))
9587 (kill-buffer (current-buffer)))
9588 (setq gnus-newsgroup-active (gnus-activate-group group))
9590 (gnus-summary-goto-article (cdr group-art) nil t)
9591 (gnus-summary-edit-article)))
9593 (defun gnus-summary-article-posted-p ()
9594 "Say whether the current (mail) article is available from news as well.
9595 This will be the case if the article has both been mailed and posted."
9597 (let ((id (mail-header-references (gnus-summary-article-header)))
9598 (gnus-override-method (car (gnus-refer-article-methods))))
9599 (if (gnus-request-head id "")
9600 (gnus-message 2 "The current message was found on %s"
9601 gnus-override-method)
9602 (gnus-message 2 "The current message couldn't be found on %s"
9603 gnus-override-method)
9606 (defun gnus-summary-expire-articles (&optional now)
9607 "Expire all articles that are marked as expirable in the current group."
9609 (when (and (not gnus-group-is-exiting-without-update-p)
9610 (gnus-check-backend-function
9611 'request-expire-articles gnus-newsgroup-name))
9612 ;; This backend supports expiry.
9613 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9614 (expirable (if total
9616 ;; We need to update the info for
9617 ;; this group for `gnus-list-of-read-articles'
9618 ;; to give us the right answer.
9619 (gnus-run-hooks 'gnus-exit-group-hook)
9620 (gnus-summary-update-info)
9621 (gnus-list-of-read-articles gnus-newsgroup-name))
9622 (setq gnus-newsgroup-expirable
9623 (sort gnus-newsgroup-expirable '<))))
9624 (expiry-wait (if now 'immediate
9625 (gnus-group-find-parameter
9626 gnus-newsgroup-name 'expiry-wait)))
9627 (nnmail-expiry-target
9628 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9629 nnmail-expiry-target))
9632 ;; There are expirable articles in this group, so we run them
9633 ;; through the expiry process.
9634 (gnus-message 6 "Expiring articles...")
9635 (unless (gnus-check-group gnus-newsgroup-name)
9636 (error "Can't open server for %s" gnus-newsgroup-name))
9637 ;; The list of articles that weren't expired is returned.
9640 (let ((nnmail-expiry-wait-function nil)
9641 (nnmail-expiry-wait expiry-wait))
9642 (setq es (gnus-request-expire-articles
9643 expirable gnus-newsgroup-name)))
9644 (setq es (gnus-request-expire-articles
9645 expirable gnus-newsgroup-name)))
9647 (setq gnus-newsgroup-expirable es))
9648 ;; We go through the old list of expirable, and mark all
9649 ;; really expired articles as nonexistent.
9650 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9651 (let ((gnus-use-cache nil))
9652 (dolist (article expirable)
9653 (when (and (not (memq article es))
9654 (gnus-data-find article))
9655 (gnus-summary-mark-article article gnus-canceled-mark)
9656 (run-hook-with-args 'gnus-summary-article-expire-hook
9659 (assoc article (gnus-data-list nil)))
9663 (gnus-message 6 "Expiring articles...done")))))
9665 (defun gnus-summary-expire-articles-now ()
9666 "Expunge all expirable articles in the current group.
9667 This means that *all* articles that are marked as expirable will be
9668 deleted forever, right now."
9670 (or gnus-expert-user
9672 "Are you really, really, really sure you want to delete all these messages? ")
9674 (gnus-summary-expire-articles t))
9676 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9677 (defun gnus-summary-delete-article (&optional n)
9678 "Delete the N next (mail) articles.
9679 This command actually deletes articles. This is not a marking
9680 command. The article will disappear forever from your life, never to
9683 If N is negative, delete backwards.
9684 If N is nil and articles have been marked with the process mark,
9685 delete these instead.
9687 If `gnus-novice-user' is non-nil you will be asked for
9688 confirmation before the articles are deleted."
9690 (unless (gnus-check-backend-function 'request-expire-articles
9691 gnus-newsgroup-name)
9692 (error "The current newsgroup does not support article deletion"))
9693 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9694 (error "Couldn't open server"))
9695 ;; Compute the list of articles to delete.
9696 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9697 (nnmail-expiry-target 'delete)
9699 (if (and gnus-novice-user
9700 (not (gnus-yes-or-no-p
9701 (format "Do you really want to delete %s forever? "
9702 (if (> (length articles) 1)
9703 (format "these %s articles" (length articles))
9706 ;; Delete the articles.
9707 (setq not-deleted (gnus-request-expire-articles
9708 articles gnus-newsgroup-name 'force))
9710 (gnus-summary-remove-process-mark (car articles))
9711 ;; The backend might not have been able to delete the article
9713 (unless (memq (car articles) not-deleted)
9714 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9715 (let* ((article (car articles))
9716 (ghead (gnus-data-header
9717 (assoc article (gnus-data-list nil)))))
9718 (run-hook-with-args 'gnus-summary-article-delete-hook
9719 'delete ghead gnus-newsgroup-name nil
9721 (setq articles (cdr articles)))
9723 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9724 (gnus-summary-position-point)
9725 (gnus-set-mode-line 'summary)
9728 (defun gnus-summary-edit-article (&optional force)
9729 "Edit the current article.
9730 This will have permanent effect only in mail groups.
9731 If FORCE is non-nil, allow editing of articles even in read-only
9735 (set-buffer gnus-summary-buffer)
9736 (let ((mail-parse-charset gnus-newsgroup-charset)
9737 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9738 (gnus-set-global-variables)
9739 (when (and (not force)
9740 (gnus-group-read-only-p))
9741 (error "The current newsgroup does not support article editing"))
9742 (gnus-summary-show-article t)
9743 (gnus-article-edit-article
9745 `(lambda (no-highlight)
9746 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9747 (message-options message-options)
9748 (message-options-set-recipient)
9749 (mail-parse-ignored-charsets
9750 ',gnus-newsgroup-ignored-charsets))
9751 (gnus-summary-edit-article-done
9752 ,(or (mail-header-references gnus-current-headers) "")
9753 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9755 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9757 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9759 "Make edits to the current article permanent."
9762 ;; The buffer restriction contains the entire article if it exists.
9763 (when (article-goto-body)
9764 (let ((lines (count-lines (point) (point-max)))
9765 (length (- (point-max) (point)))
9766 (case-fold-search t)
9767 (body (copy-marker (point))))
9768 (goto-char (point-min))
9769 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9770 (delete-region (match-beginning 1) (match-end 1))
9771 (insert (number-to-string length)))
9772 (goto-char (point-min))
9773 (when (re-search-forward
9774 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9775 (delete-region (match-beginning 1) (match-end 1))
9776 (insert (number-to-string length)))
9777 (goto-char (point-min))
9778 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9779 (delete-region (match-beginning 1) (match-end 1))
9780 (insert (number-to-string lines))))))
9781 ;; Replace the article.
9782 (let ((buf (current-buffer)))
9784 (insert-buffer-substring buf)
9786 (if (and (not read-only)
9787 (not (gnus-request-replace-article
9788 (cdr gnus-article-current) (car gnus-article-current)
9789 (current-buffer) t)))
9790 (error "Couldn't replace article")
9791 ;; Update the summary buffer.
9793 (equal (message-tokenize-header references " ")
9794 (message-tokenize-header
9795 (or (message-fetch-field "references") "") " ")))
9796 ;; We only have to update this line.
9799 (message-narrow-to-head)
9800 (let ((head (buffer-substring-no-properties
9801 (point-min) (point-max)))
9804 (insert (format "211 %d Article retrieved.\n"
9805 (cdr gnus-article-current)))
9808 (let ((nntp-server-buffer (current-buffer)))
9809 (setq header (car (gnus-get-newsgroup-headers
9812 (set-buffer gnus-summary-buffer)
9813 (gnus-data-set-header
9814 (gnus-data-find (cdr gnus-article-current))
9816 (gnus-summary-update-article-line
9817 (cdr gnus-article-current) header)
9818 (if (gnus-summary-goto-subject
9819 (cdr gnus-article-current) nil t)
9820 (gnus-summary-update-secondary-mark
9821 (cdr gnus-article-current))))))))
9823 (set-buffer (or buffer gnus-summary-buffer))
9824 (gnus-summary-update-article (cdr gnus-article-current))
9825 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9826 (gnus-summary-update-secondary-mark
9827 (cdr gnus-article-current))))
9828 ;; Prettify the article buffer again.
9829 (unless no-highlight
9831 (set-buffer gnus-article-buffer)
9832 ;;;!!! Fix this -- article should be rehighlighted.
9833 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9834 (set-buffer gnus-original-article-buffer)
9835 (gnus-request-article
9836 (cdr gnus-article-current)
9837 (car gnus-article-current) (current-buffer))))
9838 ;; Prettify the summary buffer line.
9839 (when (gnus-visual-p 'summary-highlight 'highlight)
9840 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9842 (defun gnus-summary-edit-wash (key)
9843 "Perform editing command KEY in the article buffer."
9847 (message "%s" (concat (this-command-keys) "- "))
9850 (gnus-summary-edit-article)
9851 (execute-kbd-macro (concat (this-command-keys) key))
9852 (gnus-article-edit-done))
9856 (defun gnus-summary-respool-query (&optional silent trace)
9857 "Query where the respool algorithm would put this article."
9859 (let (gnus-mark-article-hook)
9860 (gnus-summary-select-article)
9862 (set-buffer gnus-original-article-buffer)
9863 (let ((groups (nnmail-article-group 'identity trace)))
9866 (message "This message would go to %s"
9867 (mapconcat 'car groups ", "))
9868 (message "This message would go to no groups"))
9871 (defun gnus-summary-respool-trace ()
9872 "Trace where the respool algorithm would put this article.
9873 Display a buffer showing all fancy splitting patterns which matched."
9875 (gnus-summary-respool-query nil t))
9877 ;; Summary marking commands.
9879 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9880 "Mark articles which has the same subject as read, and then select the next.
9881 If UNMARK is positive, remove any kind of mark.
9882 If UNMARK is negative, tick articles."
9885 (setq unmark (prefix-numeric-value unmark)))
9887 (gnus-summary-mark-same-subject
9888 (gnus-summary-article-subject) unmark)))
9889 ;; Select next unread article. If auto-select-same mode, should
9890 ;; select the first unread article.
9891 (gnus-summary-next-article t (and gnus-auto-select-same
9892 (gnus-summary-article-subject)))
9893 (gnus-message 7 "%d article%s marked as %s"
9894 count (if (= count 1) " is" "s are")
9895 (if unmark "unread" "read"))))
9897 (defun gnus-summary-kill-same-subject (&optional unmark)
9898 "Mark articles which has the same subject as read.
9899 If UNMARK is positive, remove any kind of mark.
9900 If UNMARK is negative, tick articles."
9903 (setq unmark (prefix-numeric-value unmark)))
9905 (gnus-summary-mark-same-subject
9906 (gnus-summary-article-subject) unmark)))
9907 ;; If marked as read, go to next unread subject.
9909 ;; Go to next unread subject.
9910 (gnus-summary-next-subject 1 t))
9911 (gnus-message 7 "%d articles are marked as %s"
9912 count (if unmark "unread" "read"))))
9914 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9915 "Mark articles with same SUBJECT as read, and return marked number.
9916 If optional argument UNMARK is positive, remove any kinds of marks.
9917 If optional argument UNMARK is negative, mark articles as unread instead."
9921 ((null unmark) ; Mark as read.
9924 (gnus-summary-mark-article-as-read gnus-killed-mark)
9925 (gnus-summary-show-thread) t)
9926 (gnus-summary-find-subject subject))
9927 (setq count (1+ count))))
9928 ((> unmark 0) ; Tick.
9931 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9932 (gnus-summary-show-thread) t)
9933 (gnus-summary-find-subject subject))
9934 (setq count (1+ count))))
9935 (t ; Mark as unread.
9938 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9939 (gnus-summary-show-thread) t)
9940 (gnus-summary-find-subject subject))
9941 (setq count (1+ count)))))
9942 (gnus-set-mode-line 'summary)
9943 ;; Return the number of marked articles.
9946 (defun gnus-summary-mark-as-processable (n &optional unmark)
9947 "Set the process mark on the next N articles.
9948 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9949 the process mark instead. The difference between N and the actual
9950 number of articles marked is returned."
9952 (if (and (null n) (gnus-region-active-p))
9953 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9954 (setq n (prefix-numeric-value n))
9955 (let ((backward (< n 0))
9960 (gnus-summary-remove-process-mark
9961 (gnus-summary-article-number))
9962 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9963 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9966 (gnus-message 7 "No more articles"))
9967 (gnus-summary-recenter)
9968 (gnus-summary-position-point)
9971 (defun gnus-summary-unmark-as-processable (n)
9972 "Remove the process mark from the next N articles.
9973 If N is negative, unmark backward instead. The difference between N and
9974 the actual number of articles unmarked is returned."
9976 (gnus-summary-mark-as-processable n t))
9978 (defun gnus-summary-unmark-all-processable ()
9979 "Remove the process mark from all articles."
9982 (while gnus-newsgroup-processable
9983 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9984 (gnus-summary-position-point))
9986 (defun gnus-summary-add-mark (article type)
9987 "Mark ARTICLE with a mark of TYPE."
9988 (let ((vtype (car (assq type gnus-article-mark-lists)))
9991 (error "No such mark type: %s" type)
9992 (setq var (intern (format "gnus-newsgroup-%s" type)))
9993 (set var (cons article (symbol-value var)))
9994 (if (memq type '(processable cached replied forwarded recent saved))
9995 (gnus-summary-update-secondary-mark article)
9996 ;;; !!! This is bogus. We should find out what primary
9997 ;;; !!! mark we want to set.
9998 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10000 (defun gnus-summary-mark-as-expirable (n)
10001 "Mark N articles forward as expirable.
10002 If N is negative, mark backward instead. The difference between N and
10003 the actual number of articles marked is returned."
10005 (gnus-summary-mark-forward n gnus-expirable-mark))
10007 (defun gnus-summary-mark-as-spam (n)
10008 "Mark N articles forward as spam.
10009 If N is negative, mark backward instead. The difference between N and
10010 the actual number of articles marked is returned."
10012 (gnus-summary-mark-forward n gnus-spam-mark))
10014 (defun gnus-summary-mark-article-as-replied (article)
10015 "Mark ARTICLE as replied to and update the summary line.
10016 ARTICLE can also be a list of articles."
10017 (interactive (list (gnus-summary-article-number)))
10018 (let ((articles (if (listp article) article (list article))))
10019 (dolist (article articles)
10020 (unless (numberp article)
10021 (error "%s is not a number" article))
10022 (push article gnus-newsgroup-replied)
10023 (let ((buffer-read-only nil))
10024 (when (gnus-summary-goto-subject article nil t)
10025 (gnus-summary-update-secondary-mark article))))))
10027 (defun gnus-summary-mark-article-as-forwarded (article)
10028 "Mark ARTICLE as forwarded and update the summary line.
10029 ARTICLE can also be a list of articles."
10030 (let ((articles (if (listp article) article (list article))))
10031 (dolist (article articles)
10032 (push article gnus-newsgroup-forwarded)
10033 (let ((buffer-read-only nil))
10034 (when (gnus-summary-goto-subject article nil t)
10035 (gnus-summary-update-secondary-mark article))))))
10037 (defun gnus-summary-set-bookmark (article)
10038 "Set a bookmark in current article."
10039 (interactive (list (gnus-summary-article-number)))
10040 (when (or (not (get-buffer gnus-article-buffer))
10041 (not gnus-current-article)
10042 (not gnus-article-current)
10043 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10044 (error "No current article selected"))
10045 ;; Remove old bookmark, if one exists.
10046 (gnus-pull article gnus-newsgroup-bookmarks)
10047 ;; Set the new bookmark, which is on the form
10048 ;; (article-number . line-number-in-body).
10051 (with-current-buffer gnus-article-buffer
10055 (article-goto-body)
10058 gnus-newsgroup-bookmarks)
10059 (gnus-message 6 "A bookmark has been added to the current article."))
10061 (defun gnus-summary-remove-bookmark (article)
10062 "Remove the bookmark from the current article."
10063 (interactive (list (gnus-summary-article-number)))
10064 ;; Remove old bookmark, if one exists.
10065 (if (not (assq article gnus-newsgroup-bookmarks))
10066 (gnus-message 6 "No bookmark in current article.")
10067 (gnus-pull article gnus-newsgroup-bookmarks)
10068 (gnus-message 6 "Removed bookmark.")))
10070 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10071 (defun gnus-summary-mark-as-dormant (n)
10072 "Mark N articles forward as dormant.
10073 If N is negative, mark backward instead. The difference between N and
10074 the actual number of articles marked is returned."
10076 (gnus-summary-mark-forward n gnus-dormant-mark))
10078 (defun gnus-summary-set-process-mark (article)
10079 "Set the process mark on ARTICLE and update the summary line."
10080 (setq gnus-newsgroup-processable
10082 (delq article gnus-newsgroup-processable)))
10083 (when (gnus-summary-goto-subject article)
10084 (gnus-summary-show-thread)
10085 (gnus-summary-goto-subject article)
10086 (gnus-summary-update-secondary-mark article)))
10088 (defun gnus-summary-remove-process-mark (&rest articles)
10089 "Remove the process mark from ARTICLES and update the summary line."
10090 (dolist (article articles)
10091 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10092 (when (gnus-summary-goto-subject article)
10093 (gnus-summary-show-thread)
10094 (gnus-summary-goto-subject article)
10095 (gnus-summary-update-secondary-mark article)))
10098 (defun gnus-summary-set-saved-mark (article)
10099 "Set the process mark on ARTICLE and update the summary line."
10100 (push article gnus-newsgroup-saved)
10101 (when (gnus-summary-goto-subject article)
10102 (gnus-summary-update-secondary-mark article)))
10104 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10105 "Mark N articles as read forwards.
10106 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10107 The difference between N and the actual number of articles marked is
10109 If NO-EXPIRE, auto-expiry will be inhibited."
10111 (gnus-summary-show-thread)
10112 (let ((backward (< n 0))
10113 (gnus-summary-goto-unread
10114 (and gnus-summary-goto-unread
10115 (not (eq gnus-summary-goto-unread 'never))
10116 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10117 gnus-ticked-mark gnus-dormant-mark)))))
10119 (mark (or mark gnus-del-mark)))
10120 (while (and (> n 0)
10121 (gnus-summary-mark-article nil mark no-expire)
10122 (zerop (gnus-summary-next-subject
10124 (and gnus-summary-goto-unread
10125 (not (eq gnus-summary-goto-unread 'never)))
10129 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10130 (gnus-summary-recenter)
10131 (gnus-summary-position-point)
10132 (gnus-set-mode-line 'summary)
10135 (defun gnus-summary-mark-article-as-read (mark)
10136 "Mark the current article quickly as read with MARK."
10137 (let ((article (gnus-summary-article-number)))
10138 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10139 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10140 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10141 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10142 (push (cons article mark) gnus-newsgroup-reads)
10143 ;; Possibly remove from cache, if that is used.
10144 (when gnus-use-cache
10145 (gnus-cache-enter-remove-article article))
10146 ;; Allow the backend to change the mark.
10147 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10148 ;; Check for auto-expiry.
10149 (when (and gnus-newsgroup-auto-expire
10150 (memq mark gnus-auto-expirable-marks))
10151 (setq mark gnus-expirable-mark)
10152 ;; Let the backend know about the mark change.
10153 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10154 (push article gnus-newsgroup-expirable))
10155 ;; Set the mark in the buffer.
10156 (gnus-summary-update-mark mark 'unread)
10159 (defun gnus-summary-mark-article-as-unread (mark)
10160 "Mark the current article quickly as unread with MARK."
10161 (let* ((article (gnus-summary-article-number))
10162 (old-mark (gnus-summary-article-mark article)))
10163 ;; Allow the backend to change the mark.
10164 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10165 (if (eq mark old-mark)
10169 (gnus-error 1 "Can't mark negative article numbers")
10171 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10172 (setq gnus-newsgroup-spam-marked
10173 (delq article gnus-newsgroup-spam-marked))
10174 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10175 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10176 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10177 (cond ((= mark gnus-ticked-mark)
10178 (setq gnus-newsgroup-marked
10179 (gnus-add-to-sorted-list gnus-newsgroup-marked
10181 ((= mark gnus-spam-mark)
10182 (setq gnus-newsgroup-spam-marked
10183 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10185 ((= mark gnus-dormant-mark)
10186 (setq gnus-newsgroup-dormant
10187 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10190 (setq gnus-newsgroup-unreads
10191 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10193 (gnus-pull article gnus-newsgroup-reads)
10195 ;; See whether the article is to be put in the cache.
10196 (and gnus-use-cache
10197 (vectorp (gnus-summary-article-header article))
10199 (gnus-cache-possibly-enter-article
10200 gnus-newsgroup-name article
10201 (gnus-summary-article-header article)
10202 (= mark gnus-ticked-mark)
10203 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10206 (gnus-summary-update-mark mark 'unread)
10209 (defun gnus-summary-mark-article (&optional article mark no-expire)
10210 "Mark ARTICLE with MARK. MARK can be any character.
10211 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10212 `??' (dormant) and `?E' (expirable).
10213 If MARK is nil, then the default character `?r' is used.
10214 If ARTICLE is nil, then the article on the current line will be
10216 If NO-EXPIRE, auto-expiry will be inhibited."
10217 ;; The mark might be a string.
10218 (when (stringp mark)
10219 (setq mark (aref mark 0)))
10220 ;; If no mark is given, then we check auto-expiring.
10222 (setq mark gnus-del-mark))
10223 (when (and (not no-expire)
10224 gnus-newsgroup-auto-expire
10225 (memq mark gnus-auto-expirable-marks))
10226 (setq mark gnus-expirable-mark))
10227 (let ((article (or article (gnus-summary-article-number)))
10228 (old-mark (gnus-summary-article-mark article)))
10229 ;; Allow the backend to change the mark.
10230 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10231 (if (eq mark old-mark)
10234 (error "No article on current line"))
10235 (if (not (if (or (= mark gnus-unread-mark)
10236 (= mark gnus-ticked-mark)
10237 (= mark gnus-spam-mark)
10238 (= mark gnus-dormant-mark))
10239 (gnus-mark-article-as-unread article mark)
10240 (gnus-mark-article-as-read article mark)))
10242 ;; See whether the article is to be put in the cache.
10243 (and gnus-use-cache
10244 (not (= mark gnus-canceled-mark))
10245 (vectorp (gnus-summary-article-header article))
10247 (gnus-cache-possibly-enter-article
10248 gnus-newsgroup-name article
10249 (gnus-summary-article-header article)
10250 (= mark gnus-ticked-mark)
10251 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10253 (when (gnus-summary-goto-subject article nil t)
10254 (let ((buffer-read-only nil))
10255 (gnus-summary-show-thread)
10257 (gnus-summary-update-mark mark 'unread)
10260 (defun gnus-summary-update-secondary-mark (article)
10261 "Update the secondary (read, process, cache) mark."
10262 (gnus-summary-update-mark
10263 (cond ((memq article gnus-newsgroup-processable)
10265 ((memq article gnus-newsgroup-cached)
10267 ((memq article gnus-newsgroup-replied)
10269 ((memq article gnus-newsgroup-forwarded)
10270 gnus-forwarded-mark)
10271 ((memq article gnus-newsgroup-saved)
10273 ((memq article gnus-newsgroup-recent)
10275 ((memq article gnus-newsgroup-unseen)
10279 (when (gnus-visual-p 'summary-highlight 'highlight)
10280 (gnus-run-hooks 'gnus-summary-update-hook))
10283 (defun gnus-summary-update-download-mark (article)
10284 "Update the download mark."
10285 (gnus-summary-update-mark
10286 (cond ((memq article gnus-newsgroup-undownloaded)
10287 gnus-undownloaded-mark)
10288 (gnus-newsgroup-agentized
10289 gnus-downloaded-mark)
10293 (gnus-summary-update-line t)
10296 (defun gnus-summary-update-mark (mark type)
10297 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10298 (buffer-read-only nil))
10299 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10301 (when (looking-at "\r")
10303 (when (<= (+ forward (point)) (point-max))
10304 ;; Go to the right position on the line.
10305 (goto-char (+ forward (point)))
10306 ;; Replace the old mark with the new mark.
10307 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10308 ;; Optionally update the marks by some user rule.
10309 (when (eq type 'unread)
10310 (gnus-data-set-mark
10311 (gnus-data-find (gnus-summary-article-number)) mark)
10312 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10314 (defun gnus-mark-article-as-read (article &optional mark)
10315 "Enter ARTICLE in the pertinent lists and remove it from others."
10316 ;; Make the article expirable.
10317 (let ((mark (or mark gnus-del-mark)))
10318 (setq gnus-newsgroup-expirable
10319 (if (= mark gnus-expirable-mark)
10320 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10321 (delq article gnus-newsgroup-expirable)))
10322 ;; Remove from unread and marked lists.
10323 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10324 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10325 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10326 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10327 (push (cons article mark) gnus-newsgroup-reads)
10328 ;; Possibly remove from cache, if that is used.
10329 (when gnus-use-cache
10330 (gnus-cache-enter-remove-article article))
10333 (defun gnus-mark-article-as-unread (article &optional mark)
10334 "Enter ARTICLE in the pertinent lists and remove it from others."
10335 (let ((mark (or mark gnus-ticked-mark)))
10338 (gnus-error 1 "Can't mark negative article numbers")
10340 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10341 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10342 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10343 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10344 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10346 ;; Unsuppress duplicates?
10347 (when gnus-suppress-duplicates
10348 (gnus-dup-unsuppress-article article))
10350 (cond ((= mark gnus-ticked-mark)
10351 (setq gnus-newsgroup-marked
10352 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10353 ((= mark gnus-spam-mark)
10354 (setq gnus-newsgroup-spam-marked
10355 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10357 ((= mark gnus-dormant-mark)
10358 (setq gnus-newsgroup-dormant
10359 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10361 (setq gnus-newsgroup-unreads
10362 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10363 (gnus-pull article gnus-newsgroup-reads)
10366 (defalias 'gnus-summary-mark-as-unread-forward
10367 'gnus-summary-tick-article-forward)
10368 (make-obsolete 'gnus-summary-mark-as-unread-forward
10369 'gnus-summary-tick-article-forward)
10370 (defun gnus-summary-tick-article-forward (n)
10371 "Tick N articles forwards.
10372 If N is negative, tick backwards instead.
10373 The difference between N and the number of articles ticked is returned."
10375 (gnus-summary-mark-forward n gnus-ticked-mark))
10377 (defalias 'gnus-summary-mark-as-unread-backward
10378 'gnus-summary-tick-article-backward)
10379 (make-obsolete 'gnus-summary-mark-as-unread-backward
10380 'gnus-summary-tick-article-backward)
10381 (defun gnus-summary-tick-article-backward (n)
10382 "Tick N articles backwards.
10383 The difference between N and the number of articles ticked is returned."
10385 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10387 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10388 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10389 (defun gnus-summary-tick-article (&optional article clear-mark)
10390 "Mark current article as unread.
10391 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10392 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10394 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10395 gnus-ticked-mark)))
10397 (defun gnus-summary-mark-as-read-forward (n)
10398 "Mark N articles as read forwards.
10399 If N is negative, mark backwards instead.
10400 The difference between N and the actual number of articles marked is
10403 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10405 (defun gnus-summary-mark-as-read-backward (n)
10406 "Mark the N articles as read backwards.
10407 The difference between N and the actual number of articles marked is
10410 (gnus-summary-mark-forward
10411 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10413 (defun gnus-summary-mark-as-read (&optional article mark)
10414 "Mark current article as read.
10415 ARTICLE specifies the article to be marked as read.
10416 MARK specifies a string to be inserted at the beginning of the line."
10417 (gnus-summary-mark-article article mark))
10419 (defun gnus-summary-clear-mark-forward (n)
10420 "Clear marks from N articles forward.
10421 If N is negative, clear backward instead.
10422 The difference between N and the number of marks cleared is returned."
10424 (gnus-summary-mark-forward n gnus-unread-mark))
10426 (defun gnus-summary-clear-mark-backward (n)
10427 "Clear marks from N articles backward.
10428 The difference between N and the number of marks cleared is returned."
10430 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10432 (defun gnus-summary-mark-unread-as-read ()
10433 "Intended to be used by `gnus-summary-mark-article-hook'."
10434 (when (memq gnus-current-article gnus-newsgroup-unreads)
10435 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10437 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10438 "Intended to be used by `gnus-summary-mark-article-hook'."
10439 (let ((mark (gnus-summary-article-mark)))
10440 (when (or (gnus-unread-mark-p mark)
10441 (gnus-read-mark-p mark))
10442 (gnus-summary-mark-article gnus-current-article
10443 (or new-mark gnus-read-mark)))))
10445 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10446 "Intended to be used by `gnus-summary-mark-article-hook'."
10447 (let ((mark (gnus-summary-article-mark)))
10448 (when (or (gnus-unread-mark-p mark)
10449 (gnus-read-mark-p mark))
10450 (gnus-summary-mark-article (gnus-summary-article-number)
10451 (or new-mark gnus-read-mark)))))
10453 (defun gnus-summary-mark-unread-as-ticked ()
10454 "Intended to be used by `gnus-summary-mark-article-hook'."
10455 (when (memq gnus-current-article gnus-newsgroup-unreads)
10456 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10458 (defun gnus-summary-mark-region-as-read (point mark all)
10459 "Mark all unread articles between point and mark as read.
10460 If given a prefix, mark all articles between point and mark as read,
10461 even ticked and dormant ones."
10462 (interactive "r\nP")
10466 (beginning-of-line)
10471 (memq (setq article (gnus-summary-article-number))
10472 gnus-newsgroup-unreads))
10473 (gnus-summary-mark-article article gnus-del-mark))
10475 (gnus-summary-find-next))))))
10477 (defun gnus-summary-mark-below (score mark)
10478 "Mark articles with score less than SCORE with MARK."
10479 (interactive "P\ncMark: ")
10480 (setq score (if score
10481 (prefix-numeric-value score)
10482 (or gnus-summary-default-score 0)))
10484 (set-buffer gnus-summary-buffer)
10485 (goto-char (point-min))
10488 (and (< (gnus-summary-article-score) score)
10489 (gnus-summary-mark-article nil mark))
10490 (gnus-summary-find-next)))))
10492 (defun gnus-summary-kill-below (&optional score)
10493 "Mark articles with score below SCORE as read."
10495 (gnus-summary-mark-below score gnus-killed-mark))
10497 (defun gnus-summary-clear-above (&optional score)
10498 "Clear all marks from articles with score above SCORE."
10500 (gnus-summary-mark-above score gnus-unread-mark))
10502 (defun gnus-summary-tick-above (&optional score)
10503 "Tick all articles with score above SCORE."
10505 (gnus-summary-mark-above score gnus-ticked-mark))
10507 (defun gnus-summary-mark-above (score mark)
10508 "Mark articles with score over SCORE with MARK."
10509 (interactive "P\ncMark: ")
10510 (setq score (if score
10511 (prefix-numeric-value score)
10512 (or gnus-summary-default-score 0)))
10514 (set-buffer gnus-summary-buffer)
10515 (goto-char (point-min))
10517 (when (> (gnus-summary-article-score) score)
10518 (gnus-summary-mark-article nil mark))
10520 (gnus-summary-find-next)))))
10522 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10523 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10524 (defun gnus-summary-limit-include-expunged (&optional no-error)
10525 "Display all the hidden articles that were expunged for low scores."
10527 (let ((buffer-read-only nil))
10528 (let ((scored gnus-newsgroup-scored)
10531 (unless (gnus-summary-article-header (caar scored))
10532 (and (setq h (gnus-number-to-header (caar scored)))
10533 (< (cdar scored) gnus-summary-expunge-below)
10535 (setq scored (cdr scored)))
10537 (when (not no-error)
10538 (error "No expunged articles hidden"))
10539 (goto-char (point-min))
10540 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10541 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10542 (mapcar (lambda (x) (push (mail-header-number x)
10543 gnus-newsgroup-limit))
10545 (gnus-summary-prepare-unthreaded (nreverse headers))
10546 (goto-char (point-min))
10547 (gnus-summary-position-point)
10550 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10551 "Mark all unread articles in this newsgroup as read.
10552 If prefix argument ALL is non-nil, ticked and dormant articles will
10553 also be marked as read.
10554 If QUIETLY is non-nil, no questions will be asked.
10556 If TO-HERE is non-nil, it should be a point in the buffer. All
10557 articles before (after, if REVERSE is set) this point will be marked
10560 Note that this function will only catch up the unread article
10561 in the current summary buffer limitation.
10563 The number of articles marked as read is returned."
10568 (not gnus-interactive-catchup) ;Without confirmation?
10572 "Mark absolutely all articles as read? "
10573 "Mark all unread articles as read? ")))
10575 (not gnus-newsgroup-adaptive)
10576 (not gnus-newsgroup-auto-expire)
10577 (not gnus-suppress-duplicates)
10578 (or (not gnus-use-cache)
10579 (eq gnus-use-cache 'passive)))
10582 (setq gnus-newsgroup-marked nil
10583 gnus-newsgroup-spam-marked nil
10584 gnus-newsgroup-dormant nil))
10585 (setq gnus-newsgroup-unreads
10586 (gnus-sorted-nunion
10587 (gnus-intersection gnus-newsgroup-unreads
10588 gnus-newsgroup-downloadable)
10589 gnus-newsgroup-unfetched)))
10590 ;; We actually mark all articles as canceled, which we
10591 ;; have to do when using auto-expiry or adaptive scoring.
10592 (gnus-summary-show-all-threads)
10593 (if (and to-here reverse)
10595 (goto-char to-here)
10596 (gnus-summary-mark-current-read-and-unread-as-read
10598 (while (gnus-summary-find-next (not all))
10599 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10600 (when (gnus-summary-first-subject (not all))
10602 (if to-here (< (point) to-here) t)
10603 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10604 (gnus-summary-find-next (not all))))))
10605 (gnus-set-mode-line 'summary))
10607 (gnus-summary-position-point)))
10609 (defun gnus-summary-catchup-to-here (&optional all)
10610 "Mark all unticked articles before the current one as read.
10611 If ALL is non-nil, also mark ticked and dormant articles as read."
10614 (gnus-save-hidden-threads
10615 (let ((beg (point)))
10616 ;; We check that there are unread articles.
10617 (when (or all (gnus-summary-find-prev))
10618 (gnus-summary-catchup all t beg)))))
10619 (gnus-summary-position-point))
10621 (defun gnus-summary-catchup-from-here (&optional all)
10622 "Mark all unticked articles after (and including) the current one as read.
10623 If ALL is non-nil, also mark ticked and dormant articles as read."
10626 (gnus-save-hidden-threads
10627 (let ((beg (point)))
10628 ;; We check that there are unread articles.
10629 (when (or all (gnus-summary-find-next))
10630 (gnus-summary-catchup all t beg nil t)))))
10631 (gnus-summary-position-point))
10633 (defun gnus-summary-catchup-all (&optional quietly)
10634 "Mark all articles in this newsgroup as read.
10635 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10636 instead, which marks only unread articles as read."
10638 (gnus-summary-catchup t quietly))
10640 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10641 "Mark all unread articles in this group as read, then exit.
10642 If prefix argument ALL is non-nil, all articles are marked as read.
10643 If QUIETLY is non-nil, no questions will be asked."
10645 (when (gnus-summary-catchup all quietly nil 'fast)
10646 ;; Select next newsgroup or exit.
10647 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10648 (eq gnus-auto-select-next 'quietly))
10649 (gnus-summary-next-group nil)
10650 (gnus-summary-exit))))
10652 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10653 "Mark all articles in this newsgroup as read, and then exit.
10654 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10655 instead, which marks only unread articles as read."
10657 (gnus-summary-catchup-and-exit t quietly))
10659 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10660 "Mark all articles in this group as read and select the next group.
10661 If given a prefix, mark all articles, unread as well as ticked, as
10665 (gnus-summary-catchup all))
10666 (gnus-summary-next-group))
10668 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
10669 "Mark all articles in this group as read and select the previous group.
10670 If given a prefix, mark all articles, unread as well as ticked, as
10674 (gnus-summary-catchup all))
10675 (gnus-summary-next-group nil nil t))
10681 (defmacro gnus-with-article (article &rest forms)
10682 "Select ARTICLE and perform FORMS in the original article buffer.
10683 Then replace the article with the result."
10685 ;; We don't want the article to be marked as read.
10686 (let (gnus-mark-article-hook)
10687 (gnus-summary-select-article t t nil ,article))
10688 (set-buffer gnus-original-article-buffer)
10690 (if (not (gnus-check-backend-function
10691 'request-replace-article (car gnus-article-current)))
10692 (gnus-message 5 "Read-only group; not replacing")
10693 (unless (gnus-request-replace-article
10694 ,article (car gnus-article-current)
10695 (current-buffer) t)
10696 (error "Couldn't replace article")))
10697 ;; The cache and backlog have to be flushed somewhat.
10698 (when gnus-keep-backlog
10699 (gnus-backlog-remove-article
10700 (car gnus-article-current) (cdr gnus-article-current)))
10701 (when gnus-use-cache
10702 (gnus-cache-update-article
10703 (car gnus-article-current) (cdr gnus-article-current)))))
10705 (put 'gnus-with-article 'lisp-indent-function 1)
10706 (put 'gnus-with-article 'edebug-form-spec '(form body))
10708 ;; Thread-based commands.
10710 (defun gnus-summary-articles-in-thread (&optional article)
10711 "Return a list of all articles in the current thread.
10712 If ARTICLE is non-nil, return all articles in the thread that starts
10713 with that article."
10714 (let* ((article (or article (gnus-summary-article-number)))
10715 (data (gnus-data-find-list article))
10716 (top-level (gnus-data-level (car data)))
10718 (cond ((null gnus-thread-operation-ignore-subject)
10719 (gnus-simplify-subject-re
10720 (mail-header-subject (gnus-data-header (car data)))))
10721 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10722 (gnus-simplify-subject-fuzzy
10723 (mail-header-subject (gnus-data-header (car data)))))
10725 (end-point (save-excursion
10726 (if (gnus-summary-go-to-next-thread)
10727 (point) (point-max))))
10730 (< (gnus-data-pos (car data)) end-point))
10731 (when (or (not top-subject)
10732 (string= top-subject
10733 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10734 (gnus-simplify-subject-fuzzy
10735 (mail-header-subject
10736 (gnus-data-header (car data))))
10737 (gnus-simplify-subject-re
10738 (mail-header-subject
10739 (gnus-data-header (car data)))))))
10740 (push (gnus-data-number (car data)) articles))
10741 (unless (and (setq data (cdr data))
10742 (> (gnus-data-level (car data)) top-level))
10744 ;; Return the list of articles.
10745 (nreverse articles)))
10747 (defun gnus-summary-rethread-current ()
10748 "Rethread the thread the current article is part of."
10750 (let* ((gnus-show-threads t)
10751 (article (gnus-summary-article-number))
10752 (id (mail-header-id (gnus-summary-article-header)))
10753 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10755 (error "No article on the current line"))
10756 (gnus-rebuild-thread id)
10757 (gnus-summary-goto-subject article)))
10759 (defun gnus-summary-reparent-thread ()
10760 "Make the current article child of the marked (or previous) article.
10762 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10763 is non-nil or the Subject: of both articles are the same."
10765 (unless (not (gnus-group-read-only-p))
10766 (error "The current newsgroup does not support article editing"))
10767 (unless (<= (length gnus-newsgroup-processable) 1)
10768 (error "No more than one article may be marked"))
10769 (save-window-excursion
10770 (let ((gnus-article-buffer " *reparent*")
10771 (current-article (gnus-summary-article-number))
10772 ;; First grab the marked article, otherwise one line up.
10773 (parent-article (if (not (null gnus-newsgroup-processable))
10774 (car gnus-newsgroup-processable)
10776 (if (eq (forward-line -1) 0)
10777 (gnus-summary-article-number)
10778 (error "Beginning of summary buffer"))))))
10779 (unless (not (eq current-article parent-article))
10780 (error "An article may not be self-referential"))
10781 (let ((message-id (mail-header-id
10782 (gnus-summary-article-header parent-article))))
10783 (unless (and message-id (not (equal message-id "")))
10784 (error "No message-id in desired parent"))
10785 (gnus-with-article current-article
10787 (goto-char (point-min))
10788 (message-narrow-to-head)
10789 (if (re-search-forward "^References: " nil t)
10791 (re-search-forward "^[^ \t]" nil t)
10794 (insert " " message-id))
10795 (insert "References: " message-id "\n"))))
10796 (set-buffer gnus-summary-buffer)
10797 (gnus-summary-unmark-all-processable)
10798 (gnus-summary-update-article current-article)
10799 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10800 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10801 (gnus-summary-rethread-current)
10802 (gnus-message 3 "Article %d is now the child of article %d"
10803 current-article parent-article)))))
10805 (defun gnus-summary-toggle-threads (&optional arg)
10806 "Toggle showing conversation threads.
10807 If ARG is positive number, turn showing conversation threads on."
10809 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10810 (setq gnus-show-threads
10811 (if (null arg) (not gnus-show-threads)
10812 (> (prefix-numeric-value arg) 0)))
10813 (gnus-summary-prepare)
10814 (gnus-summary-goto-subject current)
10815 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10816 (gnus-summary-position-point)))
10818 (defun gnus-summary-show-all-threads ()
10819 "Show all threads."
10822 (let ((buffer-read-only nil))
10823 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10824 (gnus-summary-position-point))
10826 (defun gnus-summary-show-thread ()
10827 "Show thread subtrees.
10828 Returns nil if no thread was there to be shown."
10830 (let ((buffer-read-only nil)
10832 (end (point-at-eol))
10833 ;; Leave point at bol
10834 (beg (progn (beginning-of-line) (point))))
10836 ;; Any hidden lines here?
10837 (search-forward "\r" end t)
10838 (subst-char-in-region beg end ?\^M ?\n t)
10840 (gnus-summary-position-point))))
10842 (defun gnus-summary-maybe-hide-threads ()
10843 "If requested, hide the threads that should be hidden."
10844 (when (and gnus-show-threads
10845 gnus-thread-hide-subtree)
10846 (gnus-summary-hide-all-threads
10847 (if (or (consp gnus-thread-hide-subtree)
10848 (functionp gnus-thread-hide-subtree))
10849 (gnus-make-predicate gnus-thread-hide-subtree)
10852 ;;; Hiding predicates.
10854 (defun gnus-article-unread-p (header)
10855 (memq (mail-header-number header) gnus-newsgroup-unreads))
10857 (defun gnus-article-unseen-p (header)
10858 (memq (mail-header-number header) gnus-newsgroup-unseen))
10860 (defun gnus-map-articles (predicate articles)
10861 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10862 (apply 'gnus-or (mapcar predicate
10863 (mapcar 'gnus-summary-article-header articles))))
10865 (defun gnus-summary-hide-all-threads (&optional predicate)
10866 "Hide all thread subtrees.
10867 If PREDICATE is supplied, threads that satisfy this predicate
10868 will not be hidden."
10871 (goto-char (point-min))
10874 (when (or (not predicate)
10876 predicate (gnus-summary-article-children)))
10877 (gnus-summary-hide-thread))
10878 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10879 (gnus-summary-position-point))
10881 (defun gnus-summary-hide-thread ()
10882 "Hide thread subtrees.
10883 If PREDICATE is supplied, threads that satisfy this predicate
10884 will not be hidden.
10885 Returns nil if no threads were there to be hidden."
10887 (let ((buffer-read-only nil)
10889 (article (gnus-summary-article-number)))
10891 ;; Go forward until either the buffer ends or the subthread
10893 (when (and (not (eobp))
10894 (or (zerop (gnus-summary-next-thread 1 t))
10895 (goto-char (point-max))))
10897 (if (and (> (point) start)
10898 (search-backward "\n" start t))
10900 (subst-char-in-region start (point) ?\n ?\^M)
10901 (gnus-summary-goto-subject article))
10905 (defun gnus-summary-go-to-next-thread (&optional previous)
10906 "Go to the same level (or less) next thread.
10907 If PREVIOUS is non-nil, go to previous thread instead.
10908 Return the article number moved to, or nil if moving was impossible."
10909 (let ((level (gnus-summary-thread-level))
10910 (way (if previous -1 1))
10913 (while (and (not (eobp))
10914 (< level (gnus-summary-thread-level)))
10915 (forward-line way))
10922 (gnus-summary-article-number)
10923 (goto-char beg)))))
10925 (defun gnus-summary-next-thread (n &optional silent)
10926 "Go to the same level next N'th thread.
10927 If N is negative, search backward instead.
10928 Returns the difference between N and the number of skips actually
10931 If SILENT, don't output messages."
10933 (let ((backward (< n 0))
10935 (while (and (> n 0)
10936 (gnus-summary-go-to-next-thread backward))
10939 (gnus-summary-position-point))
10940 (when (and (not silent) (/= 0 n))
10941 (gnus-message 7 "No more threads"))
10944 (defun gnus-summary-prev-thread (n)
10945 "Go to the same level previous N'th thread.
10946 Returns the difference between N and the number of skips actually
10949 (gnus-summary-next-thread (- n)))
10951 (defun gnus-summary-go-down-thread ()
10952 "Go down one level in the current thread."
10953 (let ((children (gnus-summary-article-children)))
10955 (gnus-summary-goto-subject (car children)))))
10957 (defun gnus-summary-go-up-thread ()
10958 "Go up one level in the current thread."
10959 (let ((parent (gnus-summary-article-parent)))
10961 (gnus-summary-goto-subject parent))))
10963 (defun gnus-summary-down-thread (n)
10964 "Go down thread N steps.
10965 If N is negative, go up instead.
10966 Returns the difference between N and how many steps down that were
10971 (while (and (> n 0)
10972 (if up (gnus-summary-go-up-thread)
10973 (gnus-summary-go-down-thread)))
10975 (gnus-summary-position-point)
10977 (gnus-message 7 "Can't go further"))
10980 (defun gnus-summary-up-thread (n)
10981 "Go up thread N steps.
10982 If N is negative, go down instead.
10983 Returns the difference between N and how many steps down that were
10986 (gnus-summary-down-thread (- n)))
10988 (defun gnus-summary-top-thread ()
10989 "Go to the top of the thread."
10991 (while (gnus-summary-go-up-thread))
10992 (gnus-summary-article-number))
10994 (defun gnus-summary-kill-thread (&optional unmark)
10995 "Mark articles under current thread as read.
10996 If the prefix argument is positive, remove any kinds of marks.
10997 If the prefix argument is negative, tick articles instead."
11000 (setq unmark (prefix-numeric-value unmark)))
11001 (let ((articles (gnus-summary-articles-in-thread)))
11003 ;; Expand the thread.
11004 (gnus-summary-show-thread)
11005 ;; Mark all the articles.
11007 (gnus-summary-goto-subject (car articles))
11008 (cond ((null unmark)
11009 (gnus-summary-mark-article-as-read gnus-killed-mark))
11011 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11013 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11014 (setq articles (cdr articles))))
11015 ;; Hide killed subtrees.
11017 gnus-thread-hide-killed
11018 (gnus-summary-hide-thread))
11019 ;; If marked as read, go to next unread subject.
11020 (when (null unmark)
11021 ;; Go to next unread subject.
11022 (gnus-summary-next-subject 1 t)))
11023 (gnus-set-mode-line 'summary))
11025 ;; Summary sorting commands
11027 (defun gnus-summary-sort-by-number (&optional reverse)
11028 "Sort the summary buffer by article number.
11029 Argument REVERSE means reverse order."
11031 (gnus-summary-sort 'number reverse))
11033 (defun gnus-summary-sort-by-random (&optional reverse)
11034 "Randomize the order in the summary buffer.
11035 Argument REVERSE means to randomize in reverse order."
11037 (gnus-summary-sort 'random reverse))
11039 (defun gnus-summary-sort-by-author (&optional reverse)
11040 "Sort the summary buffer by author name alphabetically.
11041 If `case-fold-search' is non-nil, case of letters is ignored.
11042 Argument REVERSE means reverse order."
11044 (gnus-summary-sort 'author reverse))
11046 (defun gnus-summary-sort-by-recipient (&optional reverse)
11047 "Sort the summary buffer by recipient name alphabetically.
11048 If `case-fold-search' is non-nil, case of letters is ignored.
11049 Argument REVERSE means reverse order."
11051 (gnus-summary-sort 'recipient reverse))
11053 (defun gnus-summary-sort-by-subject (&optional reverse)
11054 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11055 If `case-fold-search' is non-nil, case of letters is ignored.
11056 Argument REVERSE means reverse order."
11058 (gnus-summary-sort 'subject reverse))
11060 (defun gnus-summary-sort-by-date (&optional reverse)
11061 "Sort the summary buffer by date.
11062 Argument REVERSE means reverse order."
11064 (gnus-summary-sort 'date reverse))
11066 (defun gnus-summary-sort-by-score (&optional reverse)
11067 "Sort the summary buffer by score.
11068 Argument REVERSE means reverse order."
11070 (gnus-summary-sort 'score reverse))
11072 (defun gnus-summary-sort-by-lines (&optional reverse)
11073 "Sort the summary buffer by the number of lines.
11074 Argument REVERSE means reverse order."
11076 (gnus-summary-sort 'lines reverse))
11078 (defun gnus-summary-sort-by-chars (&optional reverse)
11079 "Sort the summary buffer by article length.
11080 Argument REVERSE means reverse order."
11082 (gnus-summary-sort 'chars reverse))
11084 (defun gnus-summary-sort-by-original (&optional reverse)
11085 "Sort the summary buffer using the default sorting method.
11086 Argument REVERSE means reverse order."
11088 (let* ((buffer-read-only)
11089 (gnus-summary-prepare-hook nil))
11090 ;; We do the sorting by regenerating the threads.
11091 (gnus-summary-prepare)
11092 ;; Hide subthreads if needed.
11093 (gnus-summary-maybe-hide-threads)))
11095 (defun gnus-summary-sort (predicate reverse)
11096 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11097 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11098 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11099 (gnus-thread-sort-functions
11104 (gnus-sort-gathered-threads-function
11105 gnus-thread-sort-functions)
11106 (gnus-article-sort-functions
11110 (,article t2 t1))))
11112 (gnus-summary-prepare-hook nil))
11113 ;; We do the sorting by regenerating the threads.
11114 (gnus-summary-prepare)
11115 ;; Hide subthreads if needed.
11116 (gnus-summary-maybe-hide-threads)))
11118 ;; Summary saving commands.
11120 (defun gnus-summary-save-article (&optional n not-saved)
11121 "Save the current article using the default saver function.
11122 If N is a positive number, save the N next articles.
11123 If N is a negative number, save the N previous articles.
11124 If N is nil and any articles have been marked with the process mark,
11125 save those articles instead.
11126 The variable `gnus-default-article-saver' specifies the saver function."
11128 (let* ((articles (gnus-summary-work-articles n))
11129 (save-buffer (save-excursion
11130 (nnheader-set-temp-buffer " *Gnus Save*")))
11131 (num (length articles))
11133 (dolist (article articles)
11134 (setq header (gnus-summary-article-header article))
11135 (if (not (vectorp header))
11136 ;; This is a pseudo-article.
11137 (if (assq 'name header)
11138 (gnus-copy-file (cdr (assq 'name header)))
11139 (gnus-message 1 "Article %d is unsaveable" article))
11140 ;; This is a real article.
11141 (save-window-excursion
11142 (let ((gnus-display-mime-function nil)
11143 (gnus-article-prepare-hook nil))
11144 (gnus-summary-select-article t nil nil article)))
11146 (set-buffer save-buffer)
11148 (insert-buffer-substring gnus-original-article-buffer))
11149 (setq file (gnus-article-save save-buffer file num))
11150 (gnus-summary-remove-process-mark article)
11152 (gnus-summary-set-saved-mark article))))
11153 (gnus-kill-buffer save-buffer)
11154 (gnus-summary-position-point)
11155 (gnus-set-mode-line 'summary)
11158 (defun gnus-summary-pipe-output (&optional arg headers)
11159 "Pipe the current article to a subprocess.
11160 If N is a positive number, pipe the N next articles.
11161 If N is a negative number, pipe the N previous articles.
11162 If N is nil and any articles have been marked with the process mark,
11163 pipe those articles instead.
11164 If HEADERS (the symbolic prefix), include the headers, too."
11165 (interactive (gnus-interactive "P\ny"))
11166 (require 'gnus-art)
11167 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11168 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11169 (gnus-summary-save-article arg t))
11170 (let ((buffer (get-buffer "*Shell Command Output*")))
11172 (not (zerop (buffer-size buffer))))
11173 (gnus-configure-windows 'pipe))))
11175 (defun gnus-summary-save-article-mail (&optional arg)
11176 "Append the current article to an mail file.
11177 If N is a positive number, save the N next articles.
11178 If N is a negative number, save the N previous articles.
11179 If N is nil and any articles have been marked with the process mark,
11180 save those articles instead."
11182 (require 'gnus-art)
11183 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11184 (gnus-summary-save-article arg)))
11186 (defun gnus-summary-save-article-rmail (&optional arg)
11187 "Append the current article to an rmail file.
11188 If N is a positive number, save the N next articles.
11189 If N is a negative number, save the N previous articles.
11190 If N is nil and any articles have been marked with the process mark,
11191 save those articles instead."
11193 (require 'gnus-art)
11194 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11195 (gnus-summary-save-article arg)))
11197 (defun gnus-summary-save-article-file (&optional arg)
11198 "Append the current article to a file.
11199 If N is a positive number, save the N next articles.
11200 If N is a negative number, save the N previous articles.
11201 If N is nil and any articles have been marked with the process mark,
11202 save those articles instead."
11204 (require 'gnus-art)
11205 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11206 (gnus-summary-save-article arg)))
11208 (defun gnus-summary-write-article-file (&optional arg)
11209 "Write the current article to a file, deleting the previous file.
11210 If N is a positive number, save the N next articles.
11211 If N is a negative number, save the N previous articles.
11212 If N is nil and any articles have been marked with the process mark,
11213 save those articles instead."
11215 (require 'gnus-art)
11216 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11217 (gnus-summary-save-article arg)))
11219 (defun gnus-summary-save-article-body-file (&optional arg)
11220 "Append the current article body to a file.
11221 If N is a positive number, save the N next articles.
11222 If N is a negative number, save the N previous articles.
11223 If N is nil and any articles have been marked with the process mark,
11224 save those articles instead."
11226 (require 'gnus-art)
11227 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11228 (gnus-summary-save-article arg)))
11230 (defun gnus-summary-muttprint (&optional arg)
11231 "Print the current article using Muttprint.
11232 If N is a positive number, save the N next articles.
11233 If N is a negative number, save the N previous articles.
11234 If N is nil and any articles have been marked with the process mark,
11235 save those articles instead."
11237 (require 'gnus-art)
11238 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11239 (gnus-summary-save-article arg t)))
11241 (defun gnus-summary-pipe-message (program)
11242 "Pipe the current article through PROGRAM."
11243 (interactive "sProgram: ")
11244 (gnus-summary-select-article)
11245 (let ((mail-header-separator ""))
11246 (gnus-eval-in-buffer-window gnus-article-buffer
11249 (let ((start (window-start))
11251 (message-pipe-buffer-body program)
11252 (set-window-start (get-buffer-window (current-buffer)) start))))))
11254 (defun gnus-get-split-value (methods)
11255 "Return a value based on the split METHODS."
11256 (let (split-name method result match)
11259 (set-buffer gnus-original-article-buffer)
11261 (nnheader-narrow-to-headers)
11262 (while (and methods (not split-name))
11263 (goto-char (point-min))
11264 (setq method (pop methods))
11265 (setq match (car method))
11268 ;; Regular expression.
11270 (re-search-forward match nil t)))
11275 (setq result (funcall match gnus-newsgroup-name))))
11280 (setq result (eval match)))))
11281 (setq split-name (cdr method))
11282 (cond ((stringp result)
11283 (push (expand-file-name
11284 result gnus-article-save-directory)
11287 (setq split-name (append result split-name)))))))))
11288 (nreverse split-name)))
11290 (defun gnus-valid-move-group-p (group)
11291 (and (boundp group)
11292 (symbol-name group)
11293 (symbol-value group)
11294 (gnus-get-function (gnus-find-method-for-group
11295 (symbol-name group)) 'request-accept-article t)))
11297 (defun gnus-read-move-group-name (prompt default articles prefix)
11298 "Read a group name."
11299 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11300 (minibuffer-confirm-incomplete nil) ; XEmacs
11304 (if (> (length articles) 1)
11305 (format "these %d articles" (length articles))
11310 (gnus-completing-read-with-default
11313 'gnus-valid-move-group-p
11315 'gnus-group-history))
11316 ((= 1 (length split-name))
11317 (gnus-completing-read-with-default
11318 (car split-name) prom
11320 'gnus-valid-move-group-p
11322 'gnus-group-history))
11324 (gnus-completing-read-with-default
11326 (mapcar 'list (nreverse split-name))
11328 'gnus-group-history))))
11329 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11331 (if (or (string= to-newsgroup "")
11332 (string= to-newsgroup prefix))
11333 (setq to-newsgroup default))
11334 (unless to-newsgroup
11335 (error "No group name entered"))
11336 (or (gnus-active to-newsgroup)
11337 (gnus-activate-group to-newsgroup nil nil to-method)
11338 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11340 (or (and (gnus-request-create-group to-newsgroup to-method)
11341 (gnus-activate-group
11342 to-newsgroup nil nil to-method)
11343 (gnus-subscribe-group to-newsgroup))
11344 (error "Couldn't create group %s" to-newsgroup)))
11345 (error "No such group: %s" to-newsgroup)))
11348 (defun gnus-summary-save-parts (type dir n &optional reverse)
11349 "Save parts matching TYPE to DIR.
11350 If REVERSE, save parts that do not match TYPE."
11352 (list (read-string "Save parts of type: "
11353 (or (car gnus-summary-save-parts-type-history)
11354 gnus-summary-save-parts-default-mime)
11355 'gnus-summary-save-parts-type-history)
11356 (setq gnus-summary-save-parts-last-directory
11357 (read-file-name "Save to directory: "
11358 gnus-summary-save-parts-last-directory
11360 current-prefix-arg))
11361 (gnus-summary-iterate n
11362 (let ((gnus-display-mime-function nil)
11363 (gnus-inhibit-treatment t))
11364 (gnus-summary-select-article))
11366 (set-buffer gnus-article-buffer)
11367 (let ((handles (or gnus-article-mime-handles
11368 (mm-dissect-buffer nil gnus-article-loose-mime)
11369 (and gnus-article-emulate-mime
11370 (mm-uu-dissect)))))
11372 (gnus-summary-save-parts-1 type dir handles reverse)
11373 (unless gnus-article-mime-handles ;; Don't destroy this case.
11374 (mm-destroy-parts handles)))))))
11376 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11377 (if (stringp (car handle))
11378 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11381 (not (string-match type (mm-handle-media-type handle)))
11382 (string-match type (mm-handle-media-type handle)))
11383 (let ((file (expand-file-name
11385 mm-file-name-rewrite-functions
11386 (file-name-nondirectory
11388 (mail-content-type-get
11389 (mm-handle-disposition handle) 'filename)
11390 (mail-content-type-get
11391 (mm-handle-type handle) 'name)
11392 (concat gnus-newsgroup-name
11393 "." (number-to-string
11394 (cdr gnus-article-current))))))
11396 (unless (file-exists-p file)
11397 (mm-save-part-to-file handle file))))))
11399 ;; Summary extract commands
11401 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11402 (let ((buffer-read-only nil)
11403 (article (gnus-summary-article-number))
11405 (unless (gnus-summary-goto-subject article)
11406 (error "No such article: %d" article))
11407 (gnus-summary-position-point)
11408 ;; If all commands are to be bunched up on one line, we collect
11410 (unless gnus-view-pseudos-separately
11411 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11414 (setq action (cdr (assq 'action (car ps))))
11415 (setq files (list (cdr (assq 'name (car ps)))))
11416 (while (and ps (cdr ps)
11417 (string= (or action "1")
11418 (or (cdr (assq 'action (cadr ps))) "2")))
11419 (push (cdr (assq 'name (cadr ps))) files)
11420 (setcdr ps (cddr ps)))
11422 (when (not (string-match "%s" action))
11425 (when (assq 'execute (car ps))
11426 (setcdr (assq 'execute (car ps))
11427 (funcall (if (string-match "%s" action)
11434 (shell-quote-argument f)))
11436 (setq ps (cdr ps)))))
11437 (if (and gnus-view-pseudos (not not-view))
11439 (when (assq 'execute (car pslist))
11440 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11441 (eq gnus-view-pseudos 'not-confirm)))
11442 (setq pslist (cdr pslist)))
11445 (setq after-article (or (cdr (assq 'article (car pslist)))
11446 (gnus-summary-article-number)))
11447 (gnus-summary-goto-subject after-article)
11450 (insert " " (file-name-nondirectory
11451 (cdr (assq 'name (car pslist))))
11452 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11454 (forward-line -1) ; back to `b'
11455 (gnus-add-text-properties
11456 b (1- e) (list 'gnus-number gnus-reffed-article-number
11457 gnus-mouse-face-prop gnus-mouse-face))
11459 after-article gnus-reffed-article-number
11460 gnus-unread-mark b (car pslist) 0 (- e b))
11461 (setq gnus-newsgroup-unreads
11462 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11463 gnus-reffed-article-number))
11464 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11465 (setq pslist (cdr pslist)))))))
11467 (defun gnus-pseudos< (p1 p2)
11468 (let ((c1 (cdr (assq 'action p1)))
11469 (c2 (cdr (assq 'action p2))))
11470 (and c1 c2 (string< c1 c2))))
11472 (defun gnus-request-pseudo-article (props)
11473 (cond ((assq 'execute props)
11474 (gnus-execute-command (cdr (assq 'execute props)))))
11475 (let ((gnus-current-article (gnus-summary-article-number)))
11476 (gnus-run-hooks 'gnus-mark-article-hook)))
11478 (defun gnus-execute-command (command &optional automatic)
11480 (gnus-article-setup-buffer)
11481 (set-buffer gnus-article-buffer)
11482 (setq buffer-read-only nil)
11483 (let ((command (if automatic command
11484 (read-string "Command: " (cons command 0)))))
11486 (insert "$ " command "\n\n")
11487 (if gnus-view-pseudo-asynchronously
11488 (start-process "gnus-execute" (current-buffer) shell-file-name
11489 shell-command-switch command)
11490 (call-process shell-file-name nil t nil
11491 shell-command-switch command)))))
11493 ;; Summary kill commands.
11495 (defun gnus-summary-edit-global-kill (article)
11496 "Edit the \"global\" kill file."
11497 (interactive (list (gnus-summary-article-number)))
11498 (gnus-group-edit-global-kill article))
11500 (defun gnus-summary-edit-local-kill ()
11501 "Edit a local kill file applied to the current newsgroup."
11503 (setq gnus-current-headers (gnus-summary-article-header))
11504 (gnus-group-edit-local-kill
11505 (gnus-summary-article-number) gnus-newsgroup-name))
11507 ;;; Header reading.
11509 (defun gnus-read-header (id &optional header)
11510 "Read the headers of article ID and enter them into the Gnus system."
11511 (let ((group gnus-newsgroup-name)
11512 (gnus-override-method
11514 gnus-override-method
11515 (and (gnus-news-group-p gnus-newsgroup-name)
11516 (car (gnus-refer-article-methods)))))
11518 ;; First we check to see whether the header in question is already
11521 ;; This is a Message-ID.
11522 (setq header (or header (gnus-id-to-header id)))
11523 ;; This is an article number.
11524 (setq header (or header (gnus-summary-article-header id))))
11526 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11527 ;; We have found the header.
11529 ;; We have to really fetch the header to this article.
11531 (set-buffer nntp-server-buffer)
11532 (when (setq where (gnus-request-head id group))
11533 (nnheader-fold-continuation-lines)
11534 (goto-char (point-max))
11536 (goto-char (point-min))
11540 ((cdr where) (cdr where))
11541 (header (mail-header-number header))
11542 (t gnus-reffed-article-number))
11544 (insert " Article retrieved.\n"))
11545 (if (or (not where)
11546 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11547 () ; Malformed head.
11548 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11549 (when (and (stringp id)
11550 (not (string= (gnus-group-real-name group)
11552 ;; If we fetched by Message-ID and the article came
11553 ;; from a different group, we fudge some bogus article
11554 ;; numbers for this article.
11555 (mail-header-set-number header gnus-reffed-article-number))
11557 (set-buffer gnus-summary-buffer)
11558 (decf gnus-reffed-article-number)
11559 (gnus-remove-header (mail-header-number header))
11560 (push header gnus-newsgroup-headers)
11561 (setq gnus-current-headers header)
11562 (push (mail-header-number header) gnus-newsgroup-limit)))
11565 (defun gnus-remove-header (number)
11566 "Remove header NUMBER from `gnus-newsgroup-headers'."
11567 (if (and gnus-newsgroup-headers
11568 (= number (mail-header-number (car gnus-newsgroup-headers))))
11569 (pop gnus-newsgroup-headers)
11570 (let ((headers gnus-newsgroup-headers))
11571 (while (and (cdr headers)
11572 (not (= number (mail-header-number (cadr headers)))))
11574 (when (cdr headers)
11575 (setcdr headers (cddr headers))))))
11578 ;;; summary highlights
11581 (defun gnus-highlight-selected-summary ()
11582 "Highlight selected article in summary buffer."
11583 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11584 (when gnus-summary-selected-face
11586 (let* ((beg (point-at-bol))
11587 (end (point-at-eol))
11588 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11589 (from (if (get-text-property beg gnus-mouse-face-prop)
11591 (or (next-single-property-change
11592 beg gnus-mouse-face-prop nil end)
11597 (or (next-single-property-change
11598 from gnus-mouse-face-prop nil end)
11600 ;; If no mouse-face prop on line we will have to = from = end,
11601 ;; so we highlight the entire line instead.
11602 (when (= (+ to 2) from)
11605 (if gnus-newsgroup-selected-overlay
11606 ;; Move old overlay.
11608 gnus-newsgroup-selected-overlay from to (current-buffer))
11609 ;; Create new overlay.
11611 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11612 'face gnus-summary-selected-face))))))
11614 (defvar gnus-summary-highlight-line-cached nil)
11615 (defvar gnus-summary-highlight-line-trigger nil)
11617 (defun gnus-summary-highlight-line-0 ()
11618 (if (and (eq gnus-summary-highlight-line-trigger
11619 gnus-summary-highlight)
11620 gnus-summary-highlight-line-cached)
11621 gnus-summary-highlight-line-cached
11622 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11623 gnus-summary-highlight-line-cached
11624 (let* ((cond (list 'cond))
11626 (list gnus-summary-highlight))
11628 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11632 (gnus-byte-compile (list 'lambda nil cond))))))
11634 (defun gnus-summary-highlight-line ()
11635 "Highlight current line according to `gnus-summary-highlight'."
11636 (let* ((beg (point-at-bol))
11637 (article (or (gnus-summary-article-number) gnus-current-article))
11638 (score (or (cdr (assq article
11639 gnus-newsgroup-scored))
11640 gnus-summary-default-score 0))
11641 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11642 (inhibit-read-only t)
11643 (default gnus-summary-default-score)
11644 (default-high gnus-summary-default-high-score)
11645 (default-low gnus-summary-default-low-score)
11646 (uncached (and gnus-summary-use-undownloaded-faces
11647 (memq article gnus-newsgroup-undownloaded)
11648 (not (memq article gnus-newsgroup-cached)))))
11649 (let ((face (funcall (gnus-summary-highlight-line-0))))
11650 (unless (eq face (get-text-property beg 'face))
11651 (gnus-put-text-property-excluding-characters-with-faces
11652 beg (point-at-eol) 'face
11653 (setq face (if (boundp face) (symbol-value face) face)))
11654 (when gnus-summary-highlight-line-function
11655 (funcall gnus-summary-highlight-line-function article face))))))
11657 (defun gnus-update-read-articles (group unread &optional compute)
11658 "Update the list of read articles in GROUP.
11659 UNREAD is a sorted list."
11660 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11661 (info (gnus-get-info group))
11664 (if (or (not info) (not active))
11665 ;; There is no info on this group if it was, in fact,
11666 ;; killed. Gnus stores no information on killed groups, so
11667 ;; there's nothing to be done.
11668 ;; One could store the information somewhere temporarily,
11669 ;; perhaps... Hmmm...
11671 ;; Remove any negative articles numbers.
11672 (while (and unread (< (car unread) 0))
11673 (setq unread (cdr unread)))
11674 ;; Remove any expired article numbers
11675 (while (and unread (< (car unread) (car active)))
11676 (setq unread (cdr unread)))
11677 ;; Compute the ranges of read articles by looking at the list of
11678 ;; unread articles.
11680 (when (/= (car unread) prev)
11681 (push (if (= prev (1- (car unread))) prev
11682 (cons prev (1- (car unread))))
11684 (setq prev (1+ (car unread)))
11685 (setq unread (cdr unread)))
11686 (when (<= prev (cdr active))
11687 (push (cons prev (cdr active)) read))
11688 (setq read (if (> (length read) 1) (nreverse read) read))
11693 ;; Propagate the read marks to the backend.
11694 (when (gnus-check-backend-function 'request-set-mark group)
11695 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11696 (add (gnus-remove-from-range read (gnus-info-read info))))
11698 (unless (gnus-check-group group)
11699 (error "Can't open server for %s" group))
11700 (gnus-request-set-mark
11701 group (delq nil (list (if add (list add 'add '(read)))
11702 (if del (list del 'del '(read))))))
11704 `(gnus-request-set-mark
11707 (if del (list del 'add '(read)))
11708 (if add (list add 'del '(read))))))))))
11709 (set-buffer gnus-group-buffer)
11710 (gnus-undo-register
11712 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11713 (gnus-info-set-read ',info ',(gnus-info-read info))
11714 (gnus-get-unread-articles-in-group ',info
11715 (gnus-active ,group))
11716 (gnus-group-update-group ,group t)
11718 ;; Enter this list into the group info.
11719 (gnus-info-set-read info read)
11720 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11721 (gnus-get-unread-articles-in-group info (gnus-active group))
11724 (defun gnus-offer-save-summaries ()
11725 "Offer to save all active summary buffers."
11727 ;; Go through all buffers and find all summaries.
11728 (dolist (buffer (buffer-list))
11729 (when (and (setq buffer (buffer-name buffer))
11730 (string-match "Summary" buffer)
11731 (with-current-buffer buffer
11732 ;; We check that this is, indeed, a summary buffer.
11733 (and (eq major-mode 'gnus-summary-mode)
11734 ;; Also make sure this isn't bogus.
11735 gnus-newsgroup-prepared
11736 ;; Also make sure that this isn't a
11737 ;; dead summary buffer.
11738 (not gnus-dead-summary-mode))))
11739 (push buffer buffers)))
11740 ;; Go through all these summary buffers and offer to save them.
11744 "Update summary buffer %s? "
11746 (switch-to-buffer buf)
11747 (gnus-summary-exit))
11751 ;;; @ for mime-partial
11754 (defun gnus-request-partial-message ()
11756 (let ((number (gnus-summary-article-number))
11757 (group gnus-newsgroup-name)
11758 (mother gnus-article-buffer))
11759 (set-buffer (get-buffer-create " *Partial Article*"))
11761 (setq mime-preview-buffer mother)
11762 (gnus-request-article-this-buffer number group)
11763 (mime-parse-buffer)
11766 (autoload 'mime-combine-message/partial-pieces-automatically
11768 "Internal method to combine message/partial messages automatically.")
11770 (mime-add-condition
11771 'action '((type . message)(subtype . partial)
11772 (major-mode . gnus-original-article-mode)
11773 (method . mime-combine-message/partial-pieces-automatically)
11774 (summary-buffer-exp . gnus-summary-buffer)
11775 (request-partial-message-method . gnus-request-partial-message)
11779 ;;; @ for message/rfc822
11782 (defun gnus-mime-extract-message/rfc822 (entity situation)
11783 "Burst a forwarded article."
11785 (set-buffer gnus-summary-buffer)
11786 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11787 gnus-newsgroup-name 'gnus-group-history))
11788 (gnus-group-marked (list group))
11791 (mime-insert-entity-content entity)
11792 (setq article (gnus-request-accept-article group)))
11793 (when (and (consp article)
11794 (numberp (setq article (cdr article))))
11795 (setq info (gnus-get-info group))
11796 (gnus-info-set-read info
11797 (gnus-remove-from-range (gnus-info-read info)
11799 (when (string-equal group gnus-newsgroup-name)
11801 (let (gnus-show-threads)
11802 (gnus-summary-goto-subject article t))
11803 (gnus-summary-clear-mark-forward 1))
11804 (set-buffer gnus-group-buffer)
11805 (gnus-group-get-new-news-this-group nil t)))))
11807 (mime-add-condition
11808 'action '((type . message)(subtype . rfc822)
11809 (major-mode . gnus-original-article-mode)
11810 (method . gnus-mime-extract-message/rfc822)
11814 (mime-add-condition
11815 'action '((type . message)(subtype . news)
11816 (major-mode . gnus-original-article-mode)
11817 (method . gnus-mime-extract-message/rfc822)
11821 (defun gnus-mime-extract-multipart (entity situation)
11822 (let ((children (mime-entity-children entity))
11823 mime-acting-situation-to-override
11826 (mime-play-entity (car children)
11827 (cons (assq 'mode situation)
11828 mime-acting-situation-to-override))
11829 (setq children (cdr children)))
11830 (if (setq f (cdr (assq 'after-method
11831 mime-acting-situation-to-override)))
11835 (mime-add-condition
11836 'action '((type . multipart)
11837 (method . gnus-mime-extract-multipart)
11846 (defun gnus-summary-inherit-default-charset ()
11847 "Import `default-mime-charset' from summary buffer.
11848 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11850 (if (buffer-live-p gnus-summary-buffer)
11851 (let (d-m-c d-m-c-u)
11852 (with-current-buffer gnus-summary-buffer
11853 (setq d-m-c (if (local-variable-p 'default-mime-charset
11854 gnus-summary-buffer)
11855 default-mime-charset
11858 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11859 gnus-summary-buffer)
11860 (symbol-value 'default-mime-charset-unlimited)
11863 (kill-local-variable 'default-mime-charset)
11864 (set (make-local-variable 'default-mime-charset) d-m-c))
11866 (kill-local-variable 'default-mime-charset-unlimited)
11867 (set (make-local-variable 'default-mime-charset-unlimited)
11870 (defun gnus-summary-setup-default-charset ()
11871 "Setup newsgroup default charset."
11872 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11874 (setq gnus-newsgroup-charset nil)
11875 (set (make-local-variable 'default-mime-charset) nil)
11876 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11877 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11878 (let ((ignored-charsets
11879 (or gnus-newsgroup-ephemeral-ignored-charsets
11881 (and gnus-newsgroup-name
11882 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11883 gnus-newsgroup-ignored-charsets)))
11885 (setq gnus-newsgroup-charset
11886 (or gnus-newsgroup-ephemeral-charset
11887 (when (and gnus-newsgroup-name
11888 (setq charset (gnus-parameter-charset
11889 gnus-newsgroup-name)))
11890 (make-local-variable 'default-mime-charset)
11891 (setq default-mime-charset charset))
11892 gnus-default-charset))
11893 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11894 ignored-charsets))))
11900 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11901 "Display the current article buffer fully MIME-buttonized.
11902 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11903 treated as multipart/mixed."
11905 (require 'gnus-art)
11906 (let ((gnus-unbuttonized-mime-types nil)
11907 (gnus-mime-display-multipart-as-mixed show-all-parts))
11908 (gnus-summary-show-article)))
11910 (defun gnus-summary-repair-multipart (article)
11911 "Add a Content-Type header to a multipart article without one."
11912 (interactive (list (gnus-summary-article-number)))
11913 (gnus-with-article article
11914 (message-narrow-to-head)
11915 (message-remove-header "Mime-Version")
11916 (goto-char (point-max))
11917 (insert "Mime-Version: 1.0\n")
11919 (when (search-forward "\n--" nil t)
11920 (let ((separator (buffer-substring (point) (point-at-eol))))
11921 (message-narrow-to-head)
11922 (message-remove-header "Content-Type")
11923 (goto-char (point-max))
11924 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11927 (let (gnus-mark-article-hook)
11928 (gnus-summary-select-article t t nil article)))
11930 (defun gnus-summary-toggle-display-buttonized ()
11931 "Toggle the buttonizing of the article buffer."
11933 (require 'gnus-art)
11934 (if (setq gnus-inhibit-mime-unbuttonizing
11935 (not gnus-inhibit-mime-unbuttonizing))
11936 (let ((gnus-unbuttonized-mime-types nil))
11937 (gnus-summary-show-article))
11938 (gnus-summary-show-article)))
11941 ;;; Intelli-mouse commmands
11944 (defun gnus-wheel-summary-scroll (event)
11946 (let ((amount (if (memq 'shift (event-modifiers event))
11947 (car gnus-wheel-scroll-amount)
11948 (cdr gnus-wheel-scroll-amount)))
11949 (direction (- (* (static-if (featurep 'xemacs)
11950 (event-button event)
11951 (cond ((eq 'mouse-4 (event-basic-type event))
11953 ((eq 'mouse-5 (event-basic-type event))
11957 (gnus-summary-scroll-up (* amount direction))
11958 (when (gnus-eval-in-buffer-window gnus-article-buffer
11961 (and (if (< 0 direction)
11962 (gnus-article-next-page 0)
11963 (gnus-article-prev-page 0)
11965 (if (setq edge (get-text-property
11966 (point-min) 'gnus-wheel-edge))
11967 (setq edge (* edge direction))
11970 (let ((buffer-read-only nil)
11971 (inhibit-read-only t))
11972 (put-text-property (point-min) (point-max)
11973 'gnus-wheel-edge direction)
11975 (or (> edge gnus-wheel-edge-resistance)
11976 (let ((buffer-read-only nil)
11977 (inhibit-read-only t))
11978 (put-text-property (point-min) (point-max)
11980 (* (1+ edge) direction))
11982 (eq last-command 'gnus-wheel-summary-scroll))))
11983 (gnus-summary-next-article nil nil (minusp direction)))))
11985 (defun gnus-wheel-install ()
11986 "Enable mouse wheel support on summary window."
11987 (when gnus-use-wheel
11989 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11991 (define-key gnus-summary-mode-map key
11992 'gnus-wheel-summary-scroll)))))
11994 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11997 ;;; Traditional PGP commmands
12000 (defun gnus-summary-decrypt-article (&optional force)
12001 "Decrypt the current article in traditional PGP way.
12002 This will have permanent effect only in mail groups.
12003 If FORCE is non-nil, allow editing of articles even in read-only
12006 (gnus-summary-select-article t)
12007 (gnus-eval-in-buffer-window gnus-article-buffer
12011 (goto-char (point-min))
12012 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
12013 (error "Not a traditional PGP message!"))
12014 (let ((armor-start (match-beginning 0)))
12015 (if (and (pgg-decrypt-region armor-start (point-max))
12016 (or force (not (gnus-group-read-only-p))))
12017 (let ((inhibit-read-only t)
12019 (delete-region armor-start
12021 (re-search-forward "^-+END PGP" nil t)
12022 (beginning-of-line 2)
12024 (insert-buffer-substring pgg-output-buffer))))))))
12026 (defun gnus-summary-verify-article ()
12027 "Verify the current article in traditional PGP way."
12030 (set-buffer gnus-original-article-buffer)
12031 (goto-char (point-min))
12032 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
12033 (error "Not a traditional PGP message!"))
12034 (re-search-forward "^-+END PGP" nil t)
12035 (beginning-of-line 2)
12036 (call-interactively (function pgg-verify-region))))
12039 ;;; Generic summary marking commands
12042 (defvar gnus-summary-marking-alist
12043 '((read gnus-del-mark "d")
12044 (unread gnus-unread-mark "u")
12045 (ticked gnus-ticked-mark "!")
12046 (dormant gnus-dormant-mark "?")
12047 (expirable gnus-expirable-mark "e"))
12048 "An alist of names/marks/keystrokes.")
12050 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12051 (defvar gnus-summary-mark-map)
12053 (defun gnus-summary-make-all-marking-commands ()
12054 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12055 (dolist (elem gnus-summary-marking-alist)
12056 (apply 'gnus-summary-make-marking-command elem)))
12058 (defun gnus-summary-make-marking-command (name mark keystroke)
12059 (let ((map (make-sparse-keymap)))
12060 (define-key gnus-summary-generic-mark-map keystroke map)
12061 (dolist (lway `((next "next" next nil "n")
12062 (next-unread "next unread" next t "N")
12063 (prev "previous" prev nil "p")
12064 (prev-unread "previous unread" prev t "P")
12065 (nomove "" nil nil ,keystroke)))
12066 (let ((func (gnus-summary-make-marking-command-1
12067 mark (car lway) lway name)))
12068 (setq func (eval func))
12069 (define-key map (nth 4 lway) func)))))
12071 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12073 (format "gnus-summary-put-mark-as-%s%s"
12074 name (if (eq way 'nomove)
12076 (concat "-" (symbol-name way)))))
12079 "Mark the current article as %s%s.
12080 If N, the prefix, then repeat N times.
12081 If N is negative, move in reverse order.
12082 The difference between N and the actual number of articles marked is
12084 name (car (cdr lway)))
12086 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12088 (defun gnus-summary-generic-mark (n mark move unread)
12089 "Mark N articles with MARK."
12090 (unless (eq major-mode 'gnus-summary-mode)
12091 (error "This command can only be used in the summary buffer"))
12092 (gnus-summary-show-thread)
12095 ((eq move 'next) 1)
12096 ((eq move 'prev) -1)
12098 (if (zerop nummove)
12102 nummove (* -1 nummove))))
12103 (while (and (> n 0)
12104 (gnus-summary-mark-article nil mark)
12105 (zerop (gnus-summary-next-subject nummove unread t)))
12108 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12109 (gnus-summary-recenter)
12110 (gnus-summary-position-point)
12111 (gnus-set-mode-line 'summary)
12114 (defun gnus-summary-insert-articles (articles)
12115 (when (setq articles
12116 (gnus-sorted-difference articles
12117 (mapcar (lambda (h)
12118 (mail-header-number h))
12119 gnus-newsgroup-headers)))
12120 (setq gnus-newsgroup-headers
12122 gnus-newsgroup-headers
12123 (gnus-fetch-headers articles)
12124 'gnus-article-sort-by-number))
12125 ;; Suppress duplicates?
12126 (when gnus-suppress-duplicates
12127 (gnus-dup-suppress-articles))
12129 ;; We might want to build some more threads first.
12130 (when (and gnus-fetch-old-headers
12131 (eq gnus-headers-retrieved-by 'nov))
12132 (if (eq gnus-fetch-old-headers 'invisible)
12133 (gnus-build-all-threads)
12134 (gnus-build-old-threads)))
12135 ;; Let the Gnus agent mark articles as read.
12137 (gnus-agent-get-undownloaded-list))
12138 ;; Remove list identifiers from subject
12139 (when gnus-list-identifiers
12140 (gnus-summary-remove-list-identifiers))
12141 ;; First and last article in this newsgroup.
12142 (when gnus-newsgroup-headers
12143 (setq gnus-newsgroup-begin
12144 (mail-header-number (car gnus-newsgroup-headers))
12146 (mail-header-number
12147 (gnus-last-element gnus-newsgroup-headers))))
12148 (when gnus-use-scoring
12149 (gnus-possibly-score-headers))))
12151 (defun gnus-summary-insert-old-articles (&optional all)
12152 "Insert all old articles in this group.
12153 If ALL is non-nil, already read articles become readable.
12154 If ALL is a number, fetch this number of articles."
12157 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12160 ;; Some nntp servers lie about their active range. When
12161 ;; this happens, the active range can be in the millions.
12162 ;; Use a compressed range to avoid creating a huge list.
12163 (gnus-range-difference (list gnus-newsgroup-active) old))
12164 (setq len (gnus-range-length older))
12169 (let ((older-range (nreverse older)))
12173 (let* ((r (pop older-range))
12174 (min (if (numberp r) r (car r)))
12175 (max (if (numberp r) r (cdr r))))
12176 (while (and (<= min max)
12181 (setq older (gnus-uncompress-range older))))
12183 (setq older (gnus-uncompress-range older)))
12185 (when (and (numberp gnus-large-newsgroup)
12186 (> len gnus-large-newsgroup))
12187 (let* ((cursor-in-echo-area nil)
12188 (initial (gnus-parameter-large-newsgroup-initial
12189 gnus-newsgroup-name))
12193 "How many articles from %s (%s %d): "
12195 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12196 (if initial "max" "default")
12199 (cons (number-to-string initial)
12201 (unless (string-match "^[ \t]*$" input)
12202 (setq all (string-to-number input))
12204 (let ((older-range (nreverse older)))
12208 (let* ((r (pop older-range))
12209 (min (if (numberp r) r (car r)))
12210 (max (if (numberp r) r (cdr r))))
12211 (while (and (<= min max)
12215 max (1- max))))))))))
12216 (setq older (gnus-uncompress-range older))))
12218 (message "No old news.")
12219 (gnus-summary-insert-articles older)
12220 (gnus-summary-limit (gnus-sorted-nunion old older))))
12221 (gnus-summary-position-point)))
12223 (defun gnus-summary-insert-new-articles ()
12224 "Insert all new articles in this group."
12227 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12228 (old-active gnus-newsgroup-active)
12229 (nnmail-fetched-sources (list t))
12231 (setq gnus-newsgroup-active
12232 (gnus-activate-group gnus-newsgroup-name 'scan))
12233 (setq i (cdr gnus-newsgroup-active))
12234 (while (> i (cdr old-active))
12238 (message "No gnus is bad news")
12239 (gnus-summary-insert-articles new)
12240 (setq gnus-newsgroup-unreads
12241 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12242 (gnus-summary-limit (gnus-sorted-nunion old new))))
12243 (gnus-summary-position-point)))
12245 (gnus-summary-make-all-marking-commands)
12247 (gnus-ems-redefine)
12249 (provide 'gnus-sum)
12251 (run-hooks 'gnus-sum-load-hook)
12253 ;; Local Variables:
12254 ;; coding: iso-8859-1
12257 ;;; gnus-sum.el ends here