1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
33 (defvar tool-bar-map))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
57 (autoload 'mm-uu-dissect "mm-uu")
58 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
59 "Deuglify broken Outlook (Express) articles and redisplay."
61 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
62 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
63 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-fetch-old-headers nil
73 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
74 If an unread article in the group refers to an older, already read (or
75 just marked as read) article, the old article will not normally be
76 displayed in the Summary buffer. If this variable is t, Gnus
77 will attempt to grab the headers to the old articles, and thereby
78 build complete threads. If it has the value `some', only enough
79 headers to connect otherwise loose threads will be displayed. This
80 variable can also be a number. In that case, no more than that number
81 of old headers will be fetched. If it has the value `invisible', all
82 old headers will be fetched, but none will be displayed.
84 The server has to support NOV for any of this to work."
86 :type '(choice (const :tag "off" nil)
91 (sexp :menu-tag "other" t)))
93 (defcustom gnus-refer-thread-limit 200
94 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
95 If t, fetch all the available old headers."
98 (sexp :menu-tag "other" t)))
100 (defcustom gnus-summary-make-false-root 'adopt
101 "*nil means that Gnus won't gather loose threads.
102 If the root of a thread has expired or been read in a previous
103 session, the information necessary to build a complete thread has been
104 lost. Instead of having many small sub-threads from this original thread
105 scattered all over the summary buffer, Gnus can gather them.
107 If non-nil, Gnus will try to gather all loose sub-threads from an
108 original thread into one large thread.
110 If this variable is non-nil, it should be one of `none', `adopt',
113 If this variable is `none', Gnus will not make a false root, but just
114 present the sub-threads after another.
115 If this variable is `dummy', Gnus will create a dummy root that will
116 have all the sub-threads as children.
117 If this variable is `adopt', Gnus will make one of the \"children\"
118 the parent and mark all the step-children as such.
119 If this variable is `empty', the \"children\" are printed with empty
120 subject fields. (Or rather, they will be printed with a string
121 given by the `gnus-summary-same-subject' variable.)"
123 :type '(choice (const :tag "off" nil)
129 (defcustom gnus-summary-make-false-root-always nil
130 "Always make a false dummy root."
135 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
136 "*A regexp to match subjects to be excluded from loose thread gathering.
137 As loose thread gathering is done on subjects only, that means that
138 there can be many false gatherings performed. By rooting out certain
139 common subjects, gathering might become saner."
143 (defcustom gnus-summary-gather-subject-limit nil
144 "*Maximum length of subject comparisons when gathering loose threads.
145 Use nil to compare full subjects. Setting this variable to a low
146 number will help gather threads that have been corrupted by
147 newsreaders chopping off subject lines, but it might also mean that
148 unrelated articles that have subject that happen to begin with the
149 same few characters will be incorrectly gathered.
151 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
154 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "on" t)))
158 (defcustom gnus-simplify-subject-functions nil
159 "List of functions taking a string argument that simplify subjects.
160 The functions are applied recursively.
162 Useful functions to put in this list include:
163 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
164 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
166 :type '(repeat function))
168 (defcustom gnus-simplify-ignored-prefixes nil
169 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
171 :type '(choice (const :tag "off" nil)
174 (defcustom gnus-build-sparse-threads nil
175 "*If non-nil, fill in the gaps in threads.
176 If `some', only fill in the gaps that are needed to tie loose threads
177 together. If `more', fill in all leaf nodes that Gnus can find. If
178 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
180 :type '(choice (const :tag "off" nil)
183 (sexp :menu-tag "all" t)))
185 (defcustom gnus-summary-thread-gathering-function
186 'gnus-gather-threads-by-subject
187 "*Function used for gathering loose threads.
188 There are two pre-defined functions: `gnus-gather-threads-by-subject',
189 which only takes Subjects into consideration; and
190 `gnus-gather-threads-by-references', which compared the References
191 headers of the articles to find matches."
193 :type '(radio (function-item gnus-gather-threads-by-subject)
194 (function-item gnus-gather-threads-by-references)
195 (function :tag "other")))
197 (defcustom gnus-summary-same-subject ""
198 "*String indicating that the current article has the same subject as the previous.
199 This variable will only be used if the value of
200 `gnus-summary-make-false-root' is `empty'."
201 :group 'gnus-summary-format
204 (defcustom gnus-summary-goto-unread t
205 "*If t, many commands will go to the next unread article.
206 This applies to marking commands as well as other commands that
207 \"naturally\" select the next article, like, for instance, `SPC' at
208 the end of an article.
210 If nil, the marking commands do NOT go to the next unread article
211 \(they go to the next article instead). If `never', commands that
212 usually go to the next unread article, will go to the next article,
213 whether it is read or not."
214 :group 'gnus-summary-marks
215 :link '(custom-manual "(gnus)Setting Marks")
216 :type '(choice (const :tag "off" nil)
218 (sexp :menu-tag "on" t)))
220 (defcustom gnus-summary-default-score 0
221 "*Default article score level.
222 All scores generated by the score files will be added to this score.
223 If this variable is nil, scoring will be disabled."
224 :group 'gnus-score-default
225 :type '(choice (const :tag "disable")
228 (defcustom gnus-summary-default-high-score 0
229 "*Default threshold for a high scored article.
230 An article will be highlighted as high scored if its score is greater
233 :group 'gnus-score-default
236 (defcustom gnus-summary-default-low-score 0
237 "*Default threshold for a low scored article.
238 An article will be highlighted as low scored if its score is smaller
241 :group 'gnus-score-default
244 (defcustom gnus-summary-zcore-fuzz 0
245 "*Fuzziness factor for the zcore in the summary buffer.
246 Articles with scores closer than this to `gnus-summary-default-score'
248 :group 'gnus-summary-format
251 (defcustom gnus-simplify-subject-fuzzy-regexp nil
252 "*Strings to be removed when doing fuzzy matches.
253 This can either be a regular expression or list of regular expressions
254 that will be removed from subject strings if fuzzy subject
255 simplification is selected."
257 :type '(repeat regexp))
259 (defcustom gnus-show-threads t
260 "*If non-nil, display threads in summary mode."
264 (defcustom gnus-thread-hide-subtree nil
265 "*If non-nil, hide all threads initially.
266 This can be a predicate specifier which says which threads to hide.
267 If threads are hidden, you have to run the command
268 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
269 to expose hidden threads."
271 :type '(radio (sexp :format "Non-nil\n"
272 :match (lambda (widget value)
273 (not (or (consp value) (functionp value))))
276 (sexp :tag "Predicate specifier" :size 0)))
278 (defcustom gnus-thread-hide-killed t
279 "*If non-nil, hide killed threads automatically."
283 (defcustom gnus-thread-ignore-subject t
284 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
285 If nil, articles that have different subjects from their parents will
286 start separate threads."
290 (defcustom gnus-thread-operation-ignore-subject t
291 "*If non-nil, subjects will be ignored when doing thread commands.
292 This affects commands like `gnus-summary-kill-thread' and
293 `gnus-summary-lower-thread'.
295 If this variable is nil, articles in the same thread with different
296 subjects will not be included in the operation in question. If this
297 variable is `fuzzy', only articles that have subjects that are fuzzily
298 equal will be included."
300 :type '(choice (const :tag "off" nil)
304 (defcustom gnus-thread-indent-level 4
305 "*Number that says how much each sub-thread should be indented."
309 (defcustom gnus-auto-extend-newsgroup t
310 "*If non-nil, extend newsgroup forward and backward when requested."
311 :group 'gnus-summary-choose
314 (defcustom gnus-auto-select-first t
315 "*If non-nil, select the article under point.
316 Which article this is is controlled by the `gnus-auto-select-subject'
319 If you want to prevent automatic selection of articles in some
320 newsgroups, set the variable to nil in `gnus-select-group-hook'."
321 :group 'gnus-group-select
322 :type '(choice (const :tag "none" nil)
323 (sexp :menu-tag "first" t)))
325 (defcustom gnus-auto-select-subject 'unread
326 "*Says what subject to place under point when entering a group.
328 This variable can either be the symbols `first' (place point on the
329 first subject), `unread' (place point on the subject line of the first
330 unread article), `best' (place point on the subject line of the
331 higest-scored article), `unseen' (place point on the subject line of
332 the first unseen article), 'unseen-or-unread' (place point on the subject
333 line of the first unseen article or, if all article have been seen, on the
334 subject line of the first unread article), or a function to be called to
335 place point on some subject line."
337 :group 'gnus-group-select
338 :type '(choice (const best)
342 (const unseen-or-unread)))
344 (defcustom gnus-dont-select-after-jump-to-other-group nil
345 "If non-nil, don't select the first unread article after entering the
346 other group by the command `gnus-summary-jump-to-other-group'. If nil,
347 it is depend on the value of `gnus-auto-select-first' whether to select
349 :group 'gnus-group-select
352 (defcustom gnus-auto-select-next t
353 "*If non-nil, offer to go to the next group from the end of the previous.
354 If the value is t and the next newsgroup is empty, Gnus will exit
355 summary mode and go back to group mode. If the value is neither nil
356 nor t, Gnus will select the following unread newsgroup. In
357 particular, if the value is the symbol `quietly', the next unread
358 newsgroup will be selected without any confirmation, and if it is
359 `almost-quietly', the next group will be selected without any
360 confirmation if you are located on the last article in the group.
361 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
362 will go to the next group without confirmation."
363 :group 'gnus-summary-maneuvering
364 :type '(choice (const :tag "off" nil)
366 (const almost-quietly)
367 (const slightly-quietly)
368 (sexp :menu-tag "on" t)))
370 (defcustom gnus-auto-select-same nil
371 "*If non-nil, select the next article with the same subject.
372 If there are no more articles with the same subject, go to
373 the first unread article."
374 :group 'gnus-summary-maneuvering
377 (defcustom gnus-auto-goto-ignores 'unfetched
378 "*Says how to handle unfetched articles when maneuvering.
380 This variable can either be the symbols nil (maneuver to any
381 article), `undownloaded' (maneuvering while unplugged ignores articles
382 that have not been fetched), `always-undownloaded' (maneuvering always
383 ignores articles that have not been fetched), `unfetched' (maneuvering
384 ignores articles whose headers have not been fetched).
386 NOTE: The list of unfetched articles will always be nil when plugged
387 and, when unplugged, a subset of the undownloaded article list."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "None" nil)
391 (const :tag "Undownloaded when unplugged" undownloaded)
392 (const :tag "Undownloaded" always-undownloaded)
393 (const :tag "Unfetched" unfetched)))
395 (defcustom gnus-summary-check-current nil
396 "*If non-nil, consider the current article when moving.
397 The \"unread\" movement commands will stay on the same line if the
398 current article is unread."
399 :group 'gnus-summary-maneuvering
402 (defcustom gnus-auto-center-summary 2
403 "*If non-nil, always center the current summary buffer.
404 In particular, if `vertical' do only vertical recentering. If non-nil
405 and non-`vertical', do both horizontal and vertical recentering."
406 :group 'gnus-summary-maneuvering
407 :type '(choice (const :tag "none" nil)
409 (integer :tag "height")
410 (sexp :menu-tag "both" t)))
412 (defvar gnus-auto-center-group t
413 "*If non-nil, always center the group buffer.")
415 (defcustom gnus-show-all-headers nil
416 "*If non-nil, don't hide any headers."
417 :group 'gnus-article-hiding
418 :group 'gnus-article-headers
421 (defcustom gnus-summary-ignore-duplicates nil
422 "*If non-nil, ignore articles with identical Message-ID headers."
426 (defcustom gnus-single-article-buffer t
427 "*If non-nil, display all articles in the same buffer.
428 If nil, each group will get its own article buffer."
429 :group 'gnus-article-various
432 (defcustom gnus-break-pages t
433 "*If non-nil, do page breaking on articles.
434 The page delimiter is specified by the `gnus-page-delimiter'
436 :group 'gnus-article-various
439 (defcustom gnus-show-mime t
440 "*If non-nil, do mime processing of articles.
441 The articles will simply be fed to the function given by
442 `gnus-article-display-method-for-mime'."
443 :group 'gnus-article-mime
446 (defcustom gnus-move-split-methods nil
447 "*Variable used to suggest where articles are to be moved to.
448 It uses the same syntax as the `gnus-split-methods' variable.
449 However, whereas `gnus-split-methods' specifies file names as targets,
450 this variable specifies group names."
451 :group 'gnus-summary-mail
452 :type '(repeat (choice (list :value (fun) function)
453 (cons :value ("" "") regexp (repeat string))
456 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
457 "Function used to compute default prefix for article move/copy/etc prompts.
458 The function should take one argument, a group name, and return a
459 string with the suggested prefix."
460 :group 'gnus-summary-mail
463 ;; FIXME: Although the custom type is `character' for the following variables,
464 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
466 (defcustom gnus-unread-mark ?\ ;;;Whitespace
467 "*Mark used for unread articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-ticked-mark ?!
472 "*Mark used for ticked articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-dormant-mark ??
477 "*Mark used for dormant articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-del-mark ?r
482 "*Mark used for del'd articles."
483 :group 'gnus-summary-marks
486 (defcustom gnus-read-mark ?R
487 "*Mark used for read articles."
488 :group 'gnus-summary-marks
491 (defcustom gnus-expirable-mark ?E
492 "*Mark used for expirable articles."
493 :group 'gnus-summary-marks
496 (defcustom gnus-killed-mark ?K
497 "*Mark used for killed articles."
498 :group 'gnus-summary-marks
501 (defcustom gnus-spam-mark ?$
502 "*Mark used for spam articles."
503 :group 'gnus-summary-marks
506 (defcustom gnus-souped-mark ?F
507 "*Mark used for souped articles."
508 :group 'gnus-summary-marks
511 (defcustom gnus-kill-file-mark ?X
512 "*Mark used for articles killed by kill files."
513 :group 'gnus-summary-marks
516 (defcustom gnus-low-score-mark ?Y
517 "*Mark used for articles with a low score."
518 :group 'gnus-summary-marks
521 (defcustom gnus-catchup-mark ?C
522 "*Mark used for articles that are caught up."
523 :group 'gnus-summary-marks
526 (defcustom gnus-replied-mark ?A
527 "*Mark used for articles that have been replied to."
528 :group 'gnus-summary-marks
531 (defcustom gnus-forwarded-mark ?F
532 "*Mark used for articles that have been forwarded."
534 :group 'gnus-summary-marks
537 (defcustom gnus-recent-mark ?N
538 "*Mark used for articles that are recent."
539 :group 'gnus-summary-marks
542 (defcustom gnus-cached-mark ?*
543 "*Mark used for articles that are in the cache."
544 :group 'gnus-summary-marks
547 (defcustom gnus-saved-mark ?S
548 "*Mark used for articles that have been saved."
549 :group 'gnus-summary-marks
552 (defcustom gnus-unseen-mark ?.
553 "*Mark used for articles that haven't been seen."
555 :group 'gnus-summary-marks
558 (defcustom gnus-no-mark ?\ ;;;Whitespace
559 "*Mark used for articles that have no other secondary mark."
561 :group 'gnus-summary-marks
564 (defcustom gnus-ancient-mark ?O
565 "*Mark used for ancient articles."
566 :group 'gnus-summary-marks
569 (defcustom gnus-sparse-mark ?Q
570 "*Mark used for sparsely reffed articles."
571 :group 'gnus-summary-marks
574 (defcustom gnus-canceled-mark ?G
575 "*Mark used for canceled articles."
576 :group 'gnus-summary-marks
579 (defcustom gnus-duplicate-mark ?M
580 "*Mark used for duplicate articles."
581 :group 'gnus-summary-marks
584 (defcustom gnus-undownloaded-mark ?-
585 "*Mark used for articles that weren't downloaded."
586 :group 'gnus-summary-marks
589 (defcustom gnus-downloaded-mark ?+
590 "*Mark used for articles that were downloaded."
591 :group 'gnus-summary-marks
594 (defcustom gnus-downloadable-mark ?%
595 "*Mark used for articles that are to be downloaded."
596 :group 'gnus-summary-marks
599 (defcustom gnus-unsendable-mark ?=
600 "*Mark used for articles that won't be sent."
601 :group 'gnus-summary-marks
604 (defcustom gnus-score-over-mark ?+
605 "*Score mark used for articles with high scores."
606 :group 'gnus-summary-marks
609 (defcustom gnus-score-below-mark ?-
610 "*Score mark used for articles with low scores."
611 :group 'gnus-summary-marks
614 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
615 "*There is no thread under the article."
616 :group 'gnus-summary-marks
619 (defcustom gnus-not-empty-thread-mark ?=
620 "*There is a thread under the article."
621 :group 'gnus-summary-marks
624 (defcustom gnus-view-pseudo-asynchronously nil
625 "*If non-nil, Gnus will view pseudo-articles asynchronously."
626 :group 'gnus-extract-view
629 (defcustom gnus-auto-expirable-marks
630 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
631 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
632 gnus-souped-mark gnus-duplicate-mark)
633 "*The list of marks converted into expiration if a group is auto-expirable."
636 :type '(repeat character))
638 (defcustom gnus-inhibit-user-auto-expire t
639 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
644 (defcustom gnus-view-pseudos nil
645 "*If `automatic', pseudo-articles will be viewed automatically.
646 If `not-confirm', pseudos will be viewed automatically, and the user
647 will not be asked to confirm the command."
648 :group 'gnus-extract-view
649 :type '(choice (const :tag "off" nil)
651 (const not-confirm)))
653 (defcustom gnus-view-pseudos-separately t
654 "*If non-nil, one pseudo-article will be created for each file to be viewed.
655 If nil, all files that use the same viewing command will be given as a
656 list of parameters to that command."
657 :group 'gnus-extract-view
660 (defcustom gnus-insert-pseudo-articles t
661 "*If non-nil, insert pseudo-articles when decoding articles."
662 :group 'gnus-extract-view
665 (defcustom gnus-summary-dummy-line-format
667 "*The format specification for the dummy roots in the summary buffer.
668 It works along the same lines as a normal formatting string,
669 with some simple extensions.
673 General format specifiers can also be used.
674 See `(gnus)Formatting Variables'."
675 :link '(custom-manual "(gnus)Formatting Variables")
676 :group 'gnus-threading
679 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
680 "*The format specification for the summary mode line.
681 It works along the same lines as a normal formatting string,
682 with some simple extensions:
685 %p Unprefixed group name
686 %A Current article number
687 %z Current article score
689 %U Number of unread articles in the group
690 %e Number of unselected articles in the group
691 %Z A string with unread/unselected article counts
692 %g Shortish group name
693 %S Subject of the current article
695 %s Current score file name
696 %d Number of dormant articles
697 %r Number of articles that have been marked as read in this session
698 %E Number of articles expunged by the score files"
699 :group 'gnus-summary-format
702 (defcustom gnus-list-identifiers nil
703 "Regexp that matches list identifiers to be removed from subject.
704 This can also be a list of regexps."
706 :group 'gnus-summary-format
707 :group 'gnus-article-hiding
708 :type '(choice (const :tag "none" nil)
710 (repeat :value (".*") regexp)))
712 (defcustom gnus-summary-mark-below 0
713 "*Mark all articles with a score below this variable as read.
714 This variable is local to each summary buffer and usually set by the
716 :group 'gnus-score-default
719 (defun gnus-widget-reversible-match (widget value)
720 "Ignoring WIDGET, convert VALUE to internal form.
721 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
725 (eq (length value) 2)
726 (eq (nth 0 value) 'not)
727 (symbolp (nth 1 value)))))
729 (defun gnus-widget-reversible-to-internal (widget value)
730 "Ignoring WIDGET, convert VALUE to internal form.
731 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
732 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
736 (list (nth 1 value) t)))
738 (defun gnus-widget-reversible-to-external (widget value)
739 "Ignoring WIDGET, convert VALUE to external form.
740 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
741 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
744 (list 'not (nth 0 value))
747 (define-widget 'gnus-widget-reversible 'group
748 "A `group' that convert values."
749 :match 'gnus-widget-reversible-match
750 :value-to-internal 'gnus-widget-reversible-to-internal
751 :value-to-external 'gnus-widget-reversible-to-external)
753 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
754 "*List of functions used for sorting articles in the summary buffer.
756 Each function takes two articles and returns non-nil if the first
757 article should be sorted before the other. If you use more than one
758 function, the primary sort function should be the last. You should
759 probably always include `gnus-article-sort-by-number' in the list of
760 sorting functions -- preferably first. Also note that sorting by date
761 is often much slower than sorting by number, and the sorting order is
762 very similar. (Sorting by date means sorting by the time the message
763 was sent, sorting by number means sorting by arrival time.)
765 Each item can also be a list `(not F)' where F is a function;
766 this reverses the sort order.
768 Ready-made functions include `gnus-article-sort-by-number',
769 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
770 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
771 and `gnus-article-sort-by-score'.
773 When threading is turned on, the variable `gnus-thread-sort-functions'
774 controls how articles are sorted."
775 :group 'gnus-summary-sort
776 :type '(repeat (gnus-widget-reversible
777 (choice (function-item gnus-article-sort-by-number)
778 (function-item gnus-article-sort-by-author)
779 (function-item gnus-article-sort-by-subject)
780 (function-item gnus-article-sort-by-date)
781 (function-item gnus-article-sort-by-score)
782 (function-item gnus-article-sort-by-random)
783 (function :tag "other"))
784 (boolean :tag "Reverse order"))))
787 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
788 "*List of functions used for sorting threads in the summary buffer.
789 By default, threads are sorted by article number.
791 Each function takes two threads and returns non-nil if the first
792 thread should be sorted before the other. If you use more than one
793 function, the primary sort function should be the last. You should
794 probably always include `gnus-thread-sort-by-number' in the list of
795 sorting functions -- preferably first. Also note that sorting by date
796 is often much slower than sorting by number, and the sorting order is
797 very similar. (Sorting by date means sorting by the time the message
798 was sent, sorting by number means sorting by arrival time.)
800 Each list item can also be a list `(not F)' where F is a
801 function; this specifies reversed sort order.
803 Ready-made functions include `gnus-thread-sort-by-number',
804 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
805 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
806 `gnus-thread-sort-by-most-recent-number',
807 `gnus-thread-sort-by-most-recent-date',
808 `gnus-thread-sort-by-random', and
809 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
811 When threading is turned off, the variable
812 `gnus-article-sort-functions' controls how articles are sorted."
813 :group 'gnus-summary-sort
815 (gnus-widget-reversible
816 (choice (function-item gnus-thread-sort-by-number)
817 (function-item gnus-thread-sort-by-author)
818 (function-item gnus-thread-sort-by-subject)
819 (function-item gnus-thread-sort-by-date)
820 (function-item gnus-thread-sort-by-score)
821 (function-item gnus-thread-sort-by-most-recent-number)
822 (function-item gnus-thread-sort-by-most-recent-date)
823 (function-item gnus-thread-sort-by-random)
824 (function-item gnus-thread-sort-by-total-score)
825 (function :tag "other"))
826 (boolean :tag "Reverse order"))))
828 (defcustom gnus-thread-score-function '+
829 "*Function used for calculating the total score of a thread.
831 The function is called with the scores of the article and each
832 subthread and should then return the score of the thread.
834 Some functions you can use are `+', `max', or `min'."
835 :group 'gnus-summary-sort
838 (defcustom gnus-summary-expunge-below nil
839 "All articles that have a score less than this variable will be expunged.
840 This variable is local to the summary buffers."
841 :group 'gnus-score-default
842 :type '(choice (const :tag "off" nil)
845 (defcustom gnus-thread-expunge-below nil
846 "All threads that have a total score less than this variable will be expunged.
847 See `gnus-thread-score-function' for en explanation of what a
850 This variable is local to the summary buffers."
851 :group 'gnus-threading
852 :group 'gnus-score-default
853 :type '(choice (const :tag "off" nil)
856 (defcustom gnus-summary-mode-hook nil
857 "*A hook for Gnus summary mode.
858 This hook is run before any variables are set in the summary buffer."
859 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
860 :group 'gnus-summary-various
863 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
864 (when (featurep 'xemacs)
865 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
866 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
867 (add-hook 'gnus-summary-mode-hook
868 'gnus-xmas-switch-horizontal-scrollbar-off))
870 (defcustom gnus-summary-menu-hook nil
871 "*Hook run after the creation of the summary mode menu."
872 :group 'gnus-summary-visual
875 (defcustom gnus-summary-exit-hook nil
876 "*A hook called on exit from the summary buffer.
877 It will be called with point in the group buffer."
878 :group 'gnus-summary-exit
881 (defcustom gnus-summary-prepare-hook nil
882 "*A hook called after the summary buffer has been generated.
883 If you want to modify the summary buffer, you can use this hook."
884 :group 'gnus-summary-various
887 (defcustom gnus-summary-prepared-hook nil
888 "*A hook called as the last thing after the summary buffer has been generated."
889 :group 'gnus-summary-various
892 (defcustom gnus-summary-generate-hook nil
893 "*A hook run just before generating the summary buffer.
894 This hook is commonly used to customize threading variables and the
896 :group 'gnus-summary-various
899 (defcustom gnus-select-group-hook nil
900 "*A hook called when a newsgroup is selected.
902 If you'd like to simplify subjects like the
903 `gnus-summary-next-same-subject' command does, you can use the
906 (add-hook gnus-select-group-hook
908 (mapcar (lambda (header)
909 (mail-header-set-subject
911 (gnus-simplify-subject
912 (mail-header-subject header) 're-only)))
913 gnus-newsgroup-headers)))"
914 :group 'gnus-group-select
917 (defcustom gnus-select-article-hook nil
918 "*A hook called when an article is selected."
919 :group 'gnus-summary-choose
920 :options '(gnus-agent-fetch-selected-article)
923 (defcustom gnus-visual-mark-article-hook
924 (list 'gnus-highlight-selected-summary)
925 "*Hook run after selecting an article in the summary buffer.
926 It is meant to be used for highlighting the article in some way. It
927 is not run if `gnus-visual' is nil."
928 :group 'gnus-summary-visual
931 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
932 "*A hook called before parsing the headers."
936 (defcustom gnus-exit-group-hook nil
937 "*A hook called when exiting summary mode.
938 This hook is not called from the non-updating exit commands like `Q'."
942 (defcustom gnus-summary-update-hook
943 (list 'gnus-summary-highlight-line)
944 "*A hook called when a summary line is changed.
945 The hook will not be called if `gnus-visual' is nil.
947 The default function `gnus-summary-highlight-line' will
948 highlight the line according to the `gnus-summary-highlight'
950 :group 'gnus-summary-visual
953 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
954 "*A hook called when an article is selected for the first time.
955 The hook is intended to mark an article as read (or unread)
956 automatically when it is selected."
957 :group 'gnus-summary-choose
960 (defcustom gnus-group-no-more-groups-hook nil
961 "*A hook run when returning to group mode having no more (unread) groups."
962 :group 'gnus-group-select
965 (defcustom gnus-ps-print-hook nil
966 "*A hook run before ps-printing something from Gnus."
970 (defcustom gnus-summary-article-move-hook nil
971 "*A hook called after an article is moved, copied, respooled, or crossposted."
975 (defcustom gnus-summary-article-delete-hook nil
976 "*A hook called after an article is deleted."
980 (defcustom gnus-summary-article-expire-hook nil
981 "*A hook called after an article is expired."
985 (defcustom gnus-summary-display-arrow
986 (and (fboundp 'display-graphic-p)
988 "*If non-nil, display an arrow highlighting the current article."
993 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
994 "Face used for highlighting the current article in the summary buffer."
995 :group 'gnus-summary-visual
998 (defvar gnus-tmp-downloaded nil)
1000 (defcustom gnus-summary-highlight
1001 '(((eq mark gnus-canceled-mark)
1002 . gnus-summary-cancelled-face)
1003 ((and uncached (> score default-high))
1004 . gnus-summary-high-undownloaded-face)
1005 ((and uncached (< score default-low))
1006 . gnus-summary-low-undownloaded-face)
1008 . gnus-summary-normal-undownloaded-face)
1009 ((and (> score default-high)
1010 (or (eq mark gnus-dormant-mark)
1011 (eq mark gnus-ticked-mark)))
1012 . gnus-summary-high-ticked-face)
1013 ((and (< score default-low)
1014 (or (eq mark gnus-dormant-mark)
1015 (eq mark gnus-ticked-mark)))
1016 . gnus-summary-low-ticked-face)
1017 ((or (eq mark gnus-dormant-mark)
1018 (eq mark gnus-ticked-mark))
1019 . gnus-summary-normal-ticked-face)
1020 ((and (> score default-high) (eq mark gnus-ancient-mark))
1021 . gnus-summary-high-ancient-face)
1022 ((and (< score default-low) (eq mark gnus-ancient-mark))
1023 . gnus-summary-low-ancient-face)
1024 ((eq mark gnus-ancient-mark)
1025 . gnus-summary-normal-ancient-face)
1026 ((and (> score default-high) (eq mark gnus-unread-mark))
1027 . gnus-summary-high-unread-face)
1028 ((and (< score default-low) (eq mark gnus-unread-mark))
1029 . gnus-summary-low-unread-face)
1030 ((eq mark gnus-unread-mark)
1031 . gnus-summary-normal-unread-face)
1032 ((> score default-high)
1033 . gnus-summary-high-read-face)
1034 ((< score default-low)
1035 . gnus-summary-low-read-face)
1037 . gnus-summary-normal-read-face))
1038 "*Controls the highlighting of summary buffer lines.
1040 A list of (FORM . FACE) pairs. When deciding how a a particular
1041 summary line should be displayed, each form is evaluated. The content
1042 of the face field after the first true form is used. You can change
1043 how those summary lines are displayed, by editing the face field.
1045 You can use the following variables in the FORM field.
1047 score: The article's score
1048 default: The default article score.
1049 default-high: The default score for high scored articles.
1050 default-low: The default score for low scored articles.
1051 below: The score below which articles are automatically marked as read.
1052 mark: The article's mark.
1053 uncached: Non-nil if the article is uncached."
1054 :group 'gnus-summary-visual
1055 :type '(repeat (cons (sexp :tag "Form" nil)
1058 (defcustom gnus-alter-header-function nil
1059 "Function called to allow alteration of article header structures.
1060 The function is called with one parameter, the article header vector,
1061 which it may alter in any way."
1062 :type '(choice (const :tag "None" nil)
1064 :group 'gnus-summary)
1066 (defvar gnus-decode-encoded-word-function
1067 (mime-find-field-decoder 'From 'nov)
1068 "Variable that says which function should be used to decode a string with encoded words.")
1070 (defcustom gnus-extra-headers '(To Newsgroups)
1071 "*Extra headers to parse."
1073 :group 'gnus-summary
1074 :type '(repeat symbol))
1076 (defcustom gnus-ignored-from-addresses
1077 (and user-mail-address (regexp-quote user-mail-address))
1078 "*Regexp of From headers that may be suppressed in favor of To headers."
1080 :group 'gnus-summary
1083 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1084 "List of charsets that should be ignored.
1085 When these charsets are used in the \"charset\" parameter, the
1086 default charset will be used instead."
1088 :type '(repeat symbol)
1089 :group 'gnus-charset)
1091 (gnus-define-group-parameter
1095 "Return the ignored charsets of GROUP."
1096 :variable gnus-group-ignored-charsets-alist
1098 '(("alt\\.chinese\\.text" iso-8859-1))
1100 "Alist of regexps (to match group names) and charsets that should be ignored.
1101 When these charsets are used in the \"charset\" parameter, the
1102 default charset will be used instead."
1103 :variable-group gnus-charset
1104 :variable-type '(repeat (cons (regexp :tag "Group")
1106 :parameter-type '(choice :tag "Ignored charsets"
1109 :parameter-document "\
1110 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 (defcustom gnus-group-highlight-words-alist nil
1116 "Alist of group regexps and highlight regexps.
1117 This variable uses the same syntax as `gnus-emphasis-alist'."
1119 :type '(repeat (cons (regexp :tag "Group")
1120 (repeat (list (regexp :tag "Highlight regexp")
1121 (number :tag "Group for entire word" 0)
1122 (number :tag "Group for displayed part" 0)
1124 gnus-emphasis-highlight-words)))))
1125 :group 'gnus-summary-visual)
1127 (defcustom gnus-use-wheel nil
1128 "Use Intelli-mouse on summary movement"
1130 :group 'gnus-summary-maneuvering)
1132 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1133 "Amount to scroll messages by spinning the mouse wheel.
1134 This is actually a cons cell, where the first item is the amount to scroll
1135 on a normal wheel event, and the second is the amount to scroll when the
1136 wheel is moved with the shift key depressed."
1137 :type '(cons (integer :tag "Shift") integer)
1138 :group 'gnus-summary-maneuvering)
1140 (defcustom gnus-wheel-edge-resistance 2
1141 "How hard it should be to change the current article
1142 by moving the mouse over the edge of the article window."
1144 :group 'gnus-summary-maneuvering)
1146 (defcustom gnus-summary-show-article-charset-alist
1148 "Alist of number and charset.
1149 The article will be shown with the charset corresponding to the
1151 For example: ((1 . cn-gb-2312) (2 . big5))."
1153 :type '(repeat (cons (number :tag "Argument" 1)
1154 (symbol :tag "Charset")))
1155 :group 'gnus-charset)
1157 (defcustom gnus-preserve-marks t
1158 "Whether marks are preserved when moving, copying and respooling messages."
1161 :group 'gnus-summary-marks)
1163 (defcustom gnus-alter-articles-to-read-function nil
1164 "Function to be called to alter the list of articles to be selected."
1165 :type '(choice (const nil) function)
1166 :group 'gnus-summary)
1168 (defcustom gnus-orphan-score nil
1169 "*All orphans get this score added. Set in the score file."
1170 :group 'gnus-score-default
1171 :type '(choice (const nil)
1174 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1175 "*A regexp to match MIME parts when saving multiple parts of a
1176 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1177 This regexp will be used by default when prompting the user for which
1178 type of files to save."
1179 :group 'gnus-summary
1182 (defcustom gnus-read-all-available-headers nil
1183 "Whether Gnus should parse all headers made available to it.
1184 This is mostly relevant for slow back ends where the user may
1185 wish to widen the summary buffer to include all headers
1186 that were fetched. Say, for nnultimate groups."
1188 :group 'gnus-summary
1189 :type '(choice boolean regexp))
1191 (defcustom gnus-summary-muttprint-program "muttprint"
1192 "Command (and optional arguments) used to run Muttprint."
1194 :group 'gnus-summary
1197 (defcustom gnus-article-loose-mime t
1198 "If non-nil, don't require MIME-Version header.
1199 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1200 supply the MIME-Version header or deliberately strip it from the mail.
1201 If non-nil (the default), Gnus will treat some articles as MIME
1202 even if the MIME-Version header is missing."
1205 :group 'gnus-article-mime)
1207 (defcustom gnus-article-emulate-mime t
1208 "If non-nil, use MIME emulation for uuencode and the like.
1209 This means that Gnus will search message bodies for text that look
1210 like uuencoded bits, yEncoded bits, and so on, and present that using
1211 the normal Gnus MIME machinery."
1214 :group 'gnus-article-mime)
1216 ;;; Internal variables
1218 (defvar gnus-summary-display-cache nil)
1219 (defvar gnus-article-mime-handles nil)
1220 (defvar gnus-article-decoded-p nil)
1221 (defvar gnus-article-charset nil)
1222 (defvar gnus-article-ignored-charsets nil)
1223 (defvar gnus-scores-exclude-files nil)
1224 (defvar gnus-page-broken nil)
1226 (defvar gnus-original-article nil)
1227 (defvar gnus-article-internal-prepare-hook nil)
1228 (defvar gnus-newsgroup-process-stack nil)
1230 (defvar gnus-thread-indent-array nil)
1231 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1232 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1233 "Function called to sort the articles within a thread after it has been gathered together.")
1235 (defvar gnus-summary-save-parts-type-history nil)
1236 (defvar gnus-summary-save-parts-last-directory nil)
1238 ;; Avoid highlighting in kill files.
1239 (defvar gnus-summary-inhibit-highlight nil)
1240 (defvar gnus-newsgroup-selected-overlay nil)
1241 (defvar gnus-inhibit-limiting nil)
1242 (defvar gnus-newsgroup-adaptive-score-file nil)
1243 (defvar gnus-current-score-file nil)
1244 (defvar gnus-current-move-group nil)
1245 (defvar gnus-current-copy-group nil)
1246 (defvar gnus-current-crosspost-group nil)
1247 (defvar gnus-newsgroup-display nil)
1249 (defvar gnus-newsgroup-dependencies nil)
1250 (defvar gnus-newsgroup-adaptive nil)
1251 (defvar gnus-summary-display-article-function nil)
1252 (defvar gnus-summary-highlight-line-function nil
1253 "Function called after highlighting a summary line.")
1255 (defvar gnus-summary-line-format-alist
1256 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1257 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1258 (?s gnus-tmp-subject-or-nil ?s)
1259 (?n gnus-tmp-name ?s)
1260 (?A (std11-address-string
1261 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1262 (?a (or (std11-full-name-string
1263 (car (mime-entity-read-field gnus-tmp-header 'From)))
1265 (?F gnus-tmp-from ?s)
1266 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1267 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1268 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1269 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1270 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1271 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1272 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1273 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1274 (?L gnus-tmp-lines ?s)
1275 (?O gnus-tmp-downloaded ?c)
1276 (?I gnus-tmp-indentation ?s)
1277 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1278 (?R gnus-tmp-replied ?c)
1279 (?\[ gnus-tmp-opening-bracket ?c)
1280 (?\] gnus-tmp-closing-bracket ?c)
1281 (?\> (make-string gnus-tmp-level ? ) ?s)
1282 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1283 (?i gnus-tmp-score ?d)
1284 (?z gnus-tmp-score-char ?c)
1285 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1286 (?U gnus-tmp-unread ?c)
1287 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1289 (?t (gnus-summary-number-of-articles-in-thread
1290 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1292 (?e (gnus-summary-number-of-articles-in-thread
1293 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1295 (?u gnus-tmp-user-defined ?s)
1296 (?P (gnus-pick-line-number) ?d)
1297 (?B gnus-tmp-thread-tree-header-string ?s)
1298 (user-date (gnus-user-date
1299 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1300 "An alist of format specifications that can appear in summary lines.
1301 These are paired with what variables they correspond with, along with
1302 the type of the variable (string, integer, character, etc).")
1304 (defvar gnus-summary-dummy-line-format-alist
1305 `((?S gnus-tmp-subject ?s)
1306 (?N gnus-tmp-number ?d)
1307 (?u gnus-tmp-user-defined ?s)))
1309 (defvar gnus-summary-mode-line-format-alist
1310 `((?G gnus-tmp-group-name ?s)
1311 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1312 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1313 (?A gnus-tmp-article-number ?d)
1314 (?Z gnus-tmp-unread-and-unselected ?s)
1315 (?V gnus-version ?s)
1316 (?U gnus-tmp-unread-and-unticked ?d)
1317 (?S gnus-tmp-subject ?s)
1318 (?e gnus-tmp-unselected ?d)
1319 (?u gnus-tmp-user-defined ?s)
1320 (?d (length gnus-newsgroup-dormant) ?d)
1321 (?t (length gnus-newsgroup-marked) ?d)
1322 (?h (length gnus-newsgroup-spam-marked) ?d)
1323 (?r (length gnus-newsgroup-reads) ?d)
1324 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1325 (?E gnus-newsgroup-expunged-tally ?d)
1326 (?s (gnus-current-score-file-nondirectory) ?s)))
1328 (defvar gnus-last-search-regexp nil
1329 "Default regexp for article search command.")
1331 (defvar gnus-summary-search-article-matched-data nil
1332 "Last matched data of article search command. It is the local variable
1333 in `gnus-article-buffer' which consists of the list of start position,
1334 end position and text.")
1336 (defvar gnus-last-shell-command nil
1337 "Default shell command on article.")
1339 (defvar gnus-newsgroup-agentized nil
1340 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1341 (defvar gnus-newsgroup-begin nil)
1342 (defvar gnus-newsgroup-end nil)
1343 (defvar gnus-newsgroup-last-rmail nil)
1344 (defvar gnus-newsgroup-last-mail nil)
1345 (defvar gnus-newsgroup-last-folder nil)
1346 (defvar gnus-newsgroup-last-file nil)
1347 (defvar gnus-newsgroup-auto-expire nil)
1348 (defvar gnus-newsgroup-active nil)
1350 (defvar gnus-newsgroup-data nil)
1351 (defvar gnus-newsgroup-data-reverse nil)
1352 (defvar gnus-newsgroup-limit nil)
1353 (defvar gnus-newsgroup-limits nil)
1354 (defvar gnus-summary-use-undownloaded-faces nil)
1356 (defvar gnus-newsgroup-unreads nil
1357 "Sorted list of unread articles in the current newsgroup.")
1359 (defvar gnus-newsgroup-unselected nil
1360 "Sorted list of unselected unread articles in the current newsgroup.")
1362 (defvar gnus-newsgroup-reads nil
1363 "Alist of read articles and article marks in the current newsgroup.")
1365 (defvar gnus-newsgroup-expunged-tally nil)
1367 (defvar gnus-newsgroup-marked nil
1368 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1370 (defvar gnus-newsgroup-spam-marked nil
1371 "List of ranges of articles that have been marked as spam.")
1373 (defvar gnus-newsgroup-killed nil
1374 "List of ranges of articles that have been through the scoring process.")
1376 (defvar gnus-newsgroup-cached nil
1377 "Sorted list of articles that come from the article cache.")
1379 (defvar gnus-newsgroup-saved nil
1380 "List of articles that have been saved.")
1382 (defvar gnus-newsgroup-kill-headers nil)
1384 (defvar gnus-newsgroup-replied nil
1385 "List of articles that have been replied to in the current newsgroup.")
1387 (defvar gnus-newsgroup-forwarded nil
1388 "List of articles that have been forwarded in the current newsgroup.")
1390 (defvar gnus-newsgroup-recent nil
1391 "List of articles that have are recent in the current newsgroup.")
1393 (defvar gnus-newsgroup-expirable nil
1394 "Sorted list of articles in the current newsgroup that can be expired.")
1396 (defvar gnus-newsgroup-processable nil
1397 "List of articles in the current newsgroup that can be processed.")
1399 (defvar gnus-newsgroup-downloadable nil
1400 "Sorted list of articles in the current newsgroup that can be processed.")
1402 (defvar gnus-newsgroup-unfetched nil
1403 "Sorted list of articles in the current newsgroup whose headers have
1404 not been fetched into the agent.
1406 This list will always be a subset of gnus-newsgroup-undownloaded.")
1408 (defvar gnus-newsgroup-undownloaded nil
1409 "List of articles in the current newsgroup that haven't been downloaded.")
1411 (defvar gnus-newsgroup-unsendable nil
1412 "List of articles in the current newsgroup that won't be sent.")
1414 (defvar gnus-newsgroup-bookmarks nil
1415 "List of articles in the current newsgroup that have bookmarks.")
1417 (defvar gnus-newsgroup-dormant nil
1418 "Sorted list of dormant articles in the current newsgroup.")
1420 (defvar gnus-newsgroup-unseen nil
1421 "List of unseen articles in the current newsgroup.")
1423 (defvar gnus-newsgroup-seen nil
1424 "Range of seen articles in the current newsgroup.")
1426 (defvar gnus-newsgroup-articles nil
1427 "List of articles in the current newsgroup.")
1429 (defvar gnus-newsgroup-scored nil
1430 "List of scored articles in the current newsgroup.")
1432 (defvar gnus-newsgroup-incorporated nil
1433 "List of incorporated articles in the current newsgroup.")
1435 (defvar gnus-newsgroup-headers nil
1436 "List of article headers in the current newsgroup.")
1438 (defvar gnus-newsgroup-threads nil)
1440 (defvar gnus-newsgroup-prepared nil
1441 "Whether the current group has been prepared properly.")
1443 (defvar gnus-newsgroup-ancient nil
1444 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1446 (defvar gnus-newsgroup-sparse nil)
1448 (defvar gnus-current-article nil)
1449 (defvar gnus-article-current nil)
1450 (defvar gnus-current-headers nil)
1451 (defvar gnus-have-all-headers nil)
1452 (defvar gnus-last-article nil)
1453 (defvar gnus-newsgroup-history nil)
1454 (defvar gnus-newsgroup-charset nil)
1455 (defvar gnus-newsgroup-ephemeral-charset nil)
1456 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1458 (defvar gnus-article-before-search nil)
1460 (defvar gnus-summary-local-variables
1461 '(gnus-newsgroup-name
1462 gnus-newsgroup-begin gnus-newsgroup-end
1463 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1464 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1465 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1466 gnus-newsgroup-unselected gnus-newsgroup-marked
1467 gnus-newsgroup-spam-marked
1468 gnus-newsgroup-reads gnus-newsgroup-saved
1469 gnus-newsgroup-replied gnus-newsgroup-forwarded
1470 gnus-newsgroup-recent
1471 gnus-newsgroup-expirable
1472 gnus-newsgroup-processable gnus-newsgroup-killed
1473 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1474 gnus-newsgroup-unfetched
1475 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1476 gnus-newsgroup-seen gnus-newsgroup-articles
1477 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1478 gnus-newsgroup-headers gnus-newsgroup-threads
1479 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1480 gnus-current-article gnus-current-headers gnus-have-all-headers
1481 gnus-last-article gnus-article-internal-prepare-hook
1482 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1483 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1484 gnus-thread-expunge-below
1485 gnus-score-alist gnus-current-score-file
1486 (gnus-summary-expunge-below . global)
1487 (gnus-summary-mark-below . global)
1488 (gnus-orphan-score . global)
1489 gnus-newsgroup-active gnus-scores-exclude-files
1490 gnus-newsgroup-history gnus-newsgroup-ancient
1491 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1492 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1493 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1494 (gnus-newsgroup-expunged-tally . 0)
1495 gnus-cache-removable-articles gnus-newsgroup-cached
1496 gnus-newsgroup-data gnus-newsgroup-data-reverse
1497 gnus-newsgroup-limit gnus-newsgroup-limits
1498 gnus-newsgroup-charset gnus-newsgroup-display
1499 gnus-summary-use-undownloaded-faces
1500 gnus-newsgroup-incorporated)
1501 "Variables that are buffer-local to the summary buffers.")
1503 (defvar gnus-newsgroup-variables nil
1504 "A list of variables that have separate values in different newsgroups.
1505 A list of newsgroup (summary buffer) local variables, or cons of
1506 variables and their default expressions to be evalled (when the default
1507 values are not nil), that should be made global while the summary buffer
1510 Note: The default expressions will be evaluated (using function `eval')
1511 before assignment to the local variable rather than just assigned to it.
1512 If the default expression is the symbol `global', that symbol will not
1513 be evaluated but the global value of the local variable will be used
1516 These variables can be used to set variables in the group parameters
1517 while still allowing them to affect operations done in other buffers.
1520 \(setq gnus-newsgroup-variables
1521 '(message-use-followup-to
1522 (gnus-visible-headers .
1523 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1526 ;; Byte-compiler warning.
1528 ;; Bind features so that require will believe that gnus-sum has
1529 ;; already been loaded (avoids infinite recursion)
1530 (let ((features (cons 'gnus-sum features)))
1531 ;; Several of the declarations in gnus-sum are needed to load the
1532 ;; following files. Right now, these definitions have been
1533 ;; compiled but not defined (evaluated). We could either do a
1534 ;; eval-and-compile about all of the declarations or evaluate the
1536 (if (boundp 'gnus-newsgroup-variables)
1538 (load "gnus-sum.el" t t t))
1540 (require 'gnus-art)))
1542 ;; Subject simplification.
1544 (defun gnus-simplify-whitespace (str)
1545 "Remove excessive whitespace from STR."
1547 (while (string-match "[ \t][ \t]+" str)
1548 (setq str (concat (substring str 0 (match-beginning 0))
1550 (substring str (match-end 0)))))
1552 (when (string-match "^[ \t]+" str)
1553 (setq str (substring str (match-end 0))))
1555 (when (string-match "[ \t]+$" str)
1556 (setq str (substring str 0 (match-beginning 0))))
1559 (defun gnus-simplify-all-whitespace (str)
1560 "Remove all whitespace from STR."
1561 (while (string-match "[ \t\n]+" str)
1562 (setq str (replace-match "" nil nil str)))
1565 (defsubst gnus-simplify-subject-re (subject)
1566 "Remove \"Re:\" from subject lines."
1567 (if (string-match message-subject-re-regexp subject)
1568 (substring subject (match-end 0))
1571 (defun gnus-simplify-subject (subject &optional re-only)
1572 "Remove `Re:' and words in parentheses.
1573 If RE-ONLY is non-nil, strip leading `Re:'s only."
1574 (let ((case-fold-search t)) ;Ignore case.
1575 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1576 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1577 (setq subject (substring subject (match-end 0))))
1578 ;; Remove uninteresting prefixes.
1579 (when (and (not re-only)
1580 gnus-simplify-ignored-prefixes
1581 (string-match gnus-simplify-ignored-prefixes subject))
1582 (setq subject (substring subject (match-end 0))))
1583 ;; Remove words in parentheses from end.
1585 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1586 (setq subject (substring subject 0 (match-beginning 0)))))
1587 ;; Return subject string.
1590 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1592 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1593 (goto-char (point-min))
1594 (while (re-search-forward regexp nil t)
1595 (replace-match (or newtext ""))))
1597 (defun gnus-simplify-buffer-fuzzy ()
1598 "Simplify string in the buffer fuzzily.
1599 The string in the accessible portion of the current buffer is simplified.
1600 It is assumed to be a single-line subject.
1601 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1602 matter is removed. Additional things can be deleted by setting
1603 `gnus-simplify-subject-fuzzy-regexp'."
1604 (let ((case-fold-search t)
1606 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1608 (while (not (eq modified-tick (buffer-modified-tick)))
1609 (setq modified-tick (buffer-modified-tick))
1611 ((listp gnus-simplify-subject-fuzzy-regexp)
1612 (mapcar 'gnus-simplify-buffer-fuzzy-step
1613 gnus-simplify-subject-fuzzy-regexp))
1614 (gnus-simplify-subject-fuzzy-regexp
1615 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1616 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1617 (gnus-simplify-buffer-fuzzy-step
1618 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1619 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1621 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1622 (gnus-simplify-buffer-fuzzy-step " +" " ")
1623 (gnus-simplify-buffer-fuzzy-step " $")
1624 (gnus-simplify-buffer-fuzzy-step "^ +")))
1626 (defun gnus-simplify-subject-fuzzy (subject)
1627 "Simplify a subject string fuzzily.
1628 See `gnus-simplify-buffer-fuzzy' for details."
1630 (gnus-set-work-buffer)
1631 (let ((case-fold-search t))
1632 ;; Remove uninteresting prefixes.
1633 (when (and gnus-simplify-ignored-prefixes
1634 (string-match gnus-simplify-ignored-prefixes subject))
1635 (setq subject (substring subject (match-end 0))))
1637 (inline (gnus-simplify-buffer-fuzzy))
1640 (defsubst gnus-simplify-subject-fully (subject)
1641 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1643 (gnus-simplify-subject-functions
1644 (gnus-map-function gnus-simplify-subject-functions subject))
1645 ((null gnus-summary-gather-subject-limit)
1646 (gnus-simplify-subject-re subject))
1647 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1648 (gnus-simplify-subject-fuzzy subject))
1649 ((numberp gnus-summary-gather-subject-limit)
1650 (gnus-limit-string (gnus-simplify-subject-re subject)
1651 gnus-summary-gather-subject-limit))
1655 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1656 "Check whether two subjects are equal.
1657 If optional argument SIMPLE-FIRST is t, first argument is already
1660 ((null simple-first)
1661 (equal (gnus-simplify-subject-fully s1)
1662 (gnus-simplify-subject-fully s2)))
1665 (gnus-simplify-subject-fully s2)))))
1667 (defun gnus-summary-bubble-group ()
1668 "Increase the score of the current group.
1669 This is a handy function to add to `gnus-summary-exit-hook' to
1670 increase the score of each group you read."
1671 (gnus-group-add-score gnus-newsgroup-name))
1675 ;;; Gnus summary mode
1678 (put 'gnus-summary-mode 'mode-class 'special)
1680 (defvar gnus-article-commands-menu)
1682 ;; Non-orthogonal keys
1684 (gnus-define-keys gnus-summary-mode-map
1685 " " gnus-summary-next-page
1686 "\177" gnus-summary-prev-page
1687 [delete] gnus-summary-prev-page
1688 [backspace] gnus-summary-prev-page
1689 "\r" gnus-summary-scroll-up
1690 "\M-\r" gnus-summary-scroll-down
1691 "n" gnus-summary-next-unread-article
1692 "p" gnus-summary-prev-unread-article
1693 "N" gnus-summary-next-article
1694 "P" gnus-summary-prev-article
1695 "\M-\C-n" gnus-summary-next-same-subject
1696 "\M-\C-p" gnus-summary-prev-same-subject
1697 "\M-n" gnus-summary-next-unread-subject
1698 "\M-p" gnus-summary-prev-unread-subject
1699 "." gnus-summary-first-unread-article
1700 "," gnus-summary-best-unread-article
1701 "\M-s" gnus-summary-search-article-forward
1702 "\M-r" gnus-summary-search-article-backward
1703 "<" gnus-summary-beginning-of-article
1704 ">" gnus-summary-end-of-article
1705 "j" gnus-summary-goto-article
1706 "^" gnus-summary-refer-parent-article
1707 "\M-^" gnus-summary-refer-article
1708 "u" gnus-summary-tick-article-forward
1709 "!" gnus-summary-tick-article-forward
1710 "U" gnus-summary-tick-article-backward
1711 "d" gnus-summary-mark-as-read-forward
1712 "D" gnus-summary-mark-as-read-backward
1713 "E" gnus-summary-mark-as-expirable
1714 "\M-u" gnus-summary-clear-mark-forward
1715 "\M-U" gnus-summary-clear-mark-backward
1716 "k" gnus-summary-kill-same-subject-and-select
1717 "\C-k" gnus-summary-kill-same-subject
1718 "\M-\C-k" gnus-summary-kill-thread
1719 "\M-\C-l" gnus-summary-lower-thread
1720 "e" gnus-summary-edit-article
1721 "#" gnus-summary-mark-as-processable
1722 "\M-#" gnus-summary-unmark-as-processable
1723 "\M-\C-t" gnus-summary-toggle-threads
1724 "\M-\C-s" gnus-summary-show-thread
1725 "\M-\C-h" gnus-summary-hide-thread
1726 "\M-\C-f" gnus-summary-next-thread
1727 "\M-\C-b" gnus-summary-prev-thread
1728 [(meta down)] gnus-summary-next-thread
1729 [(meta up)] gnus-summary-prev-thread
1730 "\M-\C-u" gnus-summary-up-thread
1731 "\M-\C-d" gnus-summary-down-thread
1732 "&" gnus-summary-execute-command
1733 "c" gnus-summary-catchup-and-exit
1734 "\C-w" gnus-summary-mark-region-as-read
1735 "\C-t" gnus-summary-toggle-truncation
1736 "?" gnus-summary-mark-as-dormant
1737 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1738 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1739 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1740 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1741 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1742 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1743 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1744 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1745 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1746 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1747 "=" gnus-summary-expand-window
1748 "\C-x\C-s" gnus-summary-reselect-current-group
1749 "\M-g" gnus-summary-rescan-group
1750 "w" gnus-summary-stop-page-breaking
1751 "\C-c\C-r" gnus-summary-caesar-message
1752 "\M-t" gnus-summary-toggle-mime
1753 "f" gnus-summary-followup
1754 "F" gnus-summary-followup-with-original
1755 "C" gnus-summary-cancel-article
1756 "r" gnus-summary-reply
1757 "R" gnus-summary-reply-with-original
1758 "\C-c\C-f" gnus-summary-mail-forward
1759 "o" gnus-summary-save-article
1760 "\C-o" gnus-summary-save-article-mail
1761 "|" gnus-summary-pipe-output
1762 "\M-k" gnus-summary-edit-local-kill
1763 "\M-K" gnus-summary-edit-global-kill
1765 "\C-c\C-d" gnus-summary-describe-group
1766 "q" gnus-summary-exit
1767 "Q" gnus-summary-exit-no-update
1768 "\C-c\C-i" gnus-info-find-node
1769 gnus-mouse-2 gnus-mouse-pick-article
1770 "m" gnus-summary-mail-other-window
1771 "a" gnus-summary-post-news
1772 "i" gnus-summary-news-other-window
1773 "x" gnus-summary-limit-to-unread
1774 "s" gnus-summary-isearch-article
1775 "t" gnus-summary-toggle-header
1776 "g" gnus-summary-show-article
1777 "l" gnus-summary-goto-last-article
1778 "v" gnus-summary-preview-mime-message
1779 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1780 "\C-d" gnus-summary-enter-digest-group
1781 "\M-\C-d" gnus-summary-read-document
1782 "\M-\C-e" gnus-summary-edit-parameters
1783 "\M-\C-a" gnus-summary-customize-parameters
1785 "\C-c\C-n" gnus-namazu-search
1786 "*" gnus-cache-enter-article
1787 "\M-*" gnus-cache-remove-article
1788 "\M-&" gnus-summary-universal-argument
1789 "\C-l" gnus-recenter
1790 "I" gnus-summary-increase-score
1791 "L" gnus-summary-lower-score
1792 "\M-i" gnus-symbolic-argument
1793 "h" gnus-summary-select-article-buffer
1795 "V" gnus-summary-score-map
1796 "X" gnus-uu-extract-map
1797 "S" gnus-summary-send-map)
1799 ;; Sort of orthogonal keymap
1800 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1801 "t" gnus-summary-tick-article-forward
1802 "!" gnus-summary-tick-article-forward
1803 "d" gnus-summary-mark-as-read-forward
1804 "r" gnus-summary-mark-as-read-forward
1805 "c" gnus-summary-clear-mark-forward
1806 " " gnus-summary-clear-mark-forward
1807 "e" gnus-summary-mark-as-expirable
1808 "x" gnus-summary-mark-as-expirable
1809 "?" gnus-summary-mark-as-dormant
1810 "b" gnus-summary-set-bookmark
1811 "B" gnus-summary-remove-bookmark
1812 "#" gnus-summary-mark-as-processable
1813 "\M-#" gnus-summary-unmark-as-processable
1814 "S" gnus-summary-limit-include-expunged
1815 "C" gnus-summary-catchup
1816 "H" gnus-summary-catchup-to-here
1817 "h" gnus-summary-catchup-from-here
1818 "\C-c" gnus-summary-catchup-all
1819 "k" gnus-summary-kill-same-subject-and-select
1820 "K" gnus-summary-kill-same-subject
1821 "P" gnus-uu-mark-map)
1823 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1824 "c" gnus-summary-clear-above
1825 "u" gnus-summary-tick-above
1826 "m" gnus-summary-mark-above
1827 "k" gnus-summary-kill-below)
1829 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1830 "/" gnus-summary-limit-to-subject
1831 "n" gnus-summary-limit-to-articles
1832 "w" gnus-summary-pop-limit
1833 "s" gnus-summary-limit-to-subject
1834 "a" gnus-summary-limit-to-author
1835 "u" gnus-summary-limit-to-unread
1836 "m" gnus-summary-limit-to-marks
1837 "M" gnus-summary-limit-exclude-marks
1838 "v" gnus-summary-limit-to-score
1839 "*" gnus-summary-limit-include-cached
1840 "D" gnus-summary-limit-include-dormant
1841 "T" gnus-summary-limit-include-thread
1842 "d" gnus-summary-limit-exclude-dormant
1843 "t" gnus-summary-limit-to-age
1844 "." gnus-summary-limit-to-unseen
1845 "x" gnus-summary-limit-to-extra
1846 "p" gnus-summary-limit-to-display-predicate
1847 "E" gnus-summary-limit-include-expunged
1848 "c" gnus-summary-limit-exclude-childless-dormant
1849 "C" gnus-summary-limit-mark-excluded-as-read
1850 "o" gnus-summary-insert-old-articles
1851 "N" gnus-summary-insert-new-articles
1852 "r" gnus-summary-limit-to-replied)
1854 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1855 "n" gnus-summary-next-unread-article
1856 "p" gnus-summary-prev-unread-article
1857 "N" gnus-summary-next-article
1858 "P" gnus-summary-prev-article
1859 "\C-n" gnus-summary-next-same-subject
1860 "\C-p" gnus-summary-prev-same-subject
1861 "\M-n" gnus-summary-next-unread-subject
1862 "\M-p" gnus-summary-prev-unread-subject
1863 "f" gnus-summary-first-unread-article
1864 "b" gnus-summary-best-unread-article
1865 "j" gnus-summary-goto-article
1866 "g" gnus-summary-goto-subject
1867 "l" gnus-summary-goto-last-article
1868 "o" gnus-summary-pop-article)
1870 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1871 "k" gnus-summary-kill-thread
1872 "l" gnus-summary-lower-thread
1873 "i" gnus-summary-raise-thread
1874 "T" gnus-summary-toggle-threads
1875 "t" gnus-summary-rethread-current
1876 "^" gnus-summary-reparent-thread
1877 "s" gnus-summary-show-thread
1878 "S" gnus-summary-show-all-threads
1879 "h" gnus-summary-hide-thread
1880 "H" gnus-summary-hide-all-threads
1881 "n" gnus-summary-next-thread
1882 "p" gnus-summary-prev-thread
1883 "u" gnus-summary-up-thread
1884 "o" gnus-summary-top-thread
1885 "d" gnus-summary-down-thread
1886 "#" gnus-uu-mark-thread
1887 "\M-#" gnus-uu-unmark-thread)
1889 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1890 "g" gnus-summary-prepare
1891 "c" gnus-summary-insert-cached-articles
1892 "d" gnus-summary-insert-dormant-articles)
1894 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1895 "c" gnus-summary-catchup-and-exit
1896 "C" gnus-summary-catchup-all-and-exit
1897 "E" gnus-summary-exit-no-update
1898 "J" gnus-summary-jump-to-other-group
1899 "Q" gnus-summary-exit
1900 "Z" gnus-summary-exit
1901 "n" gnus-summary-catchup-and-goto-next-group
1902 "R" gnus-summary-reselect-current-group
1903 "G" gnus-summary-rescan-group
1904 "N" gnus-summary-next-group
1905 "s" gnus-summary-save-newsrc
1906 "P" gnus-summary-prev-group)
1908 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1909 " " gnus-summary-next-page
1910 "n" gnus-summary-next-page
1911 "\177" gnus-summary-prev-page
1912 [delete] gnus-summary-prev-page
1913 "p" gnus-summary-prev-page
1914 "\r" gnus-summary-scroll-up
1915 "\M-\r" gnus-summary-scroll-down
1916 "<" gnus-summary-beginning-of-article
1917 ">" gnus-summary-end-of-article
1918 "b" gnus-summary-beginning-of-article
1919 "e" gnus-summary-end-of-article
1920 "^" gnus-summary-refer-parent-article
1921 "r" gnus-summary-refer-parent-article
1922 "D" gnus-summary-enter-digest-group
1923 "R" gnus-summary-refer-references
1924 "T" gnus-summary-refer-thread
1925 "g" gnus-summary-show-article
1926 "s" gnus-summary-isearch-article
1927 "P" gnus-summary-print-article
1928 "M" gnus-mailing-list-insinuate
1929 "t" gnus-article-babel)
1931 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1932 "b" gnus-article-add-buttons
1933 "B" gnus-article-add-buttons-to-head
1934 "o" gnus-article-treat-overstrike
1935 "e" gnus-article-emphasize
1936 "w" gnus-article-fill-cited-article
1937 "Q" gnus-article-fill-long-lines
1938 "C" gnus-article-capitalize-sentences
1939 "c" gnus-article-remove-cr
1940 "Z" gnus-article-decode-HZ
1941 "A" gnus-article-treat-ansi-sequences
1942 "h" gnus-article-wash-html
1943 "u" gnus-article-unsplit-urls
1944 "f" gnus-article-display-x-face
1945 "l" gnus-summary-stop-page-breaking
1946 "r" gnus-summary-caesar-message
1947 "m" gnus-summary-morse-message
1948 "t" gnus-summary-toggle-header
1949 "g" gnus-treat-smiley
1950 "v" gnus-summary-verbose-headers
1951 "m" gnus-summary-toggle-mime
1952 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1953 "p" gnus-article-verify-x-pgp-sig
1954 "d" gnus-article-treat-dumbquotes)
1956 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1957 ;; mnemonic: deuglif*Y*
1958 "u" gnus-article-outlook-unwrap-lines
1959 "a" gnus-article-outlook-repair-attribution
1960 "c" gnus-article-outlook-rearrange-citation
1961 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1963 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1964 "a" gnus-article-hide
1965 "h" gnus-article-hide-headers
1966 "b" gnus-article-hide-boring-headers
1967 "s" gnus-article-hide-signature
1968 "c" gnus-article-hide-citation
1969 "C" gnus-article-hide-citation-in-followups
1970 "l" gnus-article-hide-list-identifiers
1971 "B" gnus-article-strip-banner
1972 "P" gnus-article-hide-pem
1973 "\C-c" gnus-article-hide-citation-maybe)
1975 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1976 "a" gnus-article-highlight
1977 "h" gnus-article-highlight-headers
1978 "c" gnus-article-highlight-citation
1979 "s" gnus-article-highlight-signature)
1981 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1982 "f" gnus-article-treat-fold-headers
1983 "u" gnus-article-treat-unfold-headers
1984 "n" gnus-article-treat-fold-newsgroups)
1986 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1987 "x" gnus-article-display-x-face
1988 "d" gnus-article-display-face
1989 "s" gnus-treat-smiley
1990 "D" gnus-article-remove-images
1991 "f" gnus-treat-from-picon
1992 "m" gnus-treat-mail-picon
1993 "n" gnus-treat-newsgroups-picon)
1995 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1996 "z" gnus-article-date-ut
1997 "u" gnus-article-date-ut
1998 "l" gnus-article-date-local
1999 "p" gnus-article-date-english
2000 "e" gnus-article-date-lapsed
2001 "o" gnus-article-date-original
2002 "i" gnus-article-date-iso8601
2003 "s" gnus-article-date-user)
2005 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2006 "t" gnus-article-remove-trailing-blank-lines
2007 "l" gnus-article-strip-leading-blank-lines
2008 "m" gnus-article-strip-multiple-blank-lines
2009 "a" gnus-article-strip-blank-lines
2010 "A" gnus-article-strip-all-blank-lines
2011 "s" gnus-article-strip-leading-space
2012 "e" gnus-article-strip-trailing-space
2013 "w" gnus-article-remove-leading-whitespace)
2015 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2017 "f" gnus-summary-fetch-faq
2018 "d" gnus-summary-describe-group
2019 "h" gnus-summary-describe-briefly
2020 "i" gnus-info-find-node
2021 "c" gnus-group-fetch-charter
2022 "C" gnus-group-fetch-control)
2024 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2025 "e" gnus-summary-expire-articles
2026 "\M-\C-e" gnus-summary-expire-articles-now
2027 "\177" gnus-summary-delete-article
2028 [delete] gnus-summary-delete-article
2029 [backspace] gnus-summary-delete-article
2030 "m" gnus-summary-move-article
2031 "r" gnus-summary-respool-article
2032 "w" gnus-summary-edit-article
2033 "c" gnus-summary-copy-article
2034 "B" gnus-summary-crosspost-article
2035 "q" gnus-summary-respool-query
2036 "t" gnus-summary-respool-trace
2037 "i" gnus-summary-import-article
2038 "I" gnus-summary-create-article
2039 "p" gnus-summary-article-posted-p)
2041 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2042 "o" gnus-summary-save-article
2043 "m" gnus-summary-save-article-mail
2044 "F" gnus-summary-write-article-file
2045 "r" gnus-summary-save-article-rmail
2046 "f" gnus-summary-save-article-file
2047 "b" gnus-summary-save-article-body-file
2048 "h" gnus-summary-save-article-folder
2049 "v" gnus-summary-save-article-vm
2050 "p" gnus-summary-pipe-output
2051 "P" gnus-summary-muttprint
2052 "s" gnus-soup-add-article)
2054 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2055 "b" gnus-summary-display-buttonized
2056 "m" gnus-summary-repair-multipart
2057 "v" gnus-article-view-part
2058 "o" gnus-article-save-part
2059 "c" gnus-article-copy-part
2060 "C" gnus-article-view-part-as-charset
2061 "e" gnus-article-view-part-externally
2062 "E" gnus-article-encrypt-body
2063 "i" gnus-article-inline-part
2064 "|" gnus-article-pipe-part)
2066 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2067 "p" gnus-summary-mark-as-processable
2068 "u" gnus-summary-unmark-as-processable
2069 "U" gnus-summary-unmark-all-processable
2070 "v" gnus-uu-mark-over
2071 "s" gnus-uu-mark-series
2072 "r" gnus-uu-mark-region
2073 "g" gnus-uu-unmark-region
2074 "R" gnus-uu-mark-by-regexp
2075 "G" gnus-uu-unmark-by-regexp
2076 "t" gnus-uu-mark-thread
2077 "T" gnus-uu-unmark-thread
2078 "a" gnus-uu-mark-all
2079 "b" gnus-uu-mark-buffer
2080 "S" gnus-uu-mark-sparse
2081 "k" gnus-summary-kill-process-mark
2082 "y" gnus-summary-yank-process-mark
2083 "w" gnus-summary-save-process-mark
2084 "i" gnus-uu-invert-processable)
2086 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2087 ;;"x" gnus-uu-extract-any
2088 "m" gnus-summary-save-parts
2089 "u" gnus-uu-decode-uu
2090 "U" gnus-uu-decode-uu-and-save
2091 "s" gnus-uu-decode-unshar
2092 "S" gnus-uu-decode-unshar-and-save
2093 "o" gnus-uu-decode-save
2094 "O" gnus-uu-decode-save
2095 "b" gnus-uu-decode-binhex
2096 "B" gnus-uu-decode-binhex
2097 "p" gnus-uu-decode-postscript
2098 "P" gnus-uu-decode-postscript-and-save)
2101 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2102 "u" gnus-uu-decode-uu-view
2103 "U" gnus-uu-decode-uu-and-save-view
2104 "s" gnus-uu-decode-unshar-view
2105 "S" gnus-uu-decode-unshar-and-save-view
2106 "o" gnus-uu-decode-save-view
2107 "O" gnus-uu-decode-save-view
2108 "b" gnus-uu-decode-binhex-view
2109 "B" gnus-uu-decode-binhex-view
2110 "p" gnus-uu-decode-postscript-view
2111 "P" gnus-uu-decode-postscript-and-save-view)
2113 (defvar gnus-article-post-menu nil)
2115 (defconst gnus-summary-menu-maxlen 20)
2117 (defun gnus-summary-menu-split (menu)
2118 ;; If we have lots of elements, divide them into groups of 20
2119 ;; and make a pane (or submenu) for each one.
2120 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2121 (let ((menu menu) sublists next
2124 ;; Pull off the next gnus-summary-menu-maxlen elements
2125 ;; and make them the next element of sublist.
2126 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2128 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2130 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2131 (aref (car (last menu)) 0)) menu)
2135 (nreverse sublists))
2136 ;; Few elements--put them all in one pane.
2139 (defun gnus-summary-make-menu-bar ()
2140 (gnus-turn-off-edit-menu 'summary)
2142 (unless (boundp 'gnus-summary-misc-menu)
2145 gnus-summary-kill-menu gnus-summary-mode-map ""
2150 ["Customize" gnus-score-customize t])
2151 (gnus-make-score-map 'increase)
2152 (gnus-make-score-map 'lower)
2154 ["Kill below" gnus-summary-kill-below t]
2155 ["Mark above" gnus-summary-mark-above t]
2156 ["Tick above" gnus-summary-tick-above t]
2157 ["Clear above" gnus-summary-clear-above t])
2158 ["Current score" gnus-summary-current-score t]
2159 ["Set score" gnus-summary-set-score t]
2160 ["Switch current score file..." gnus-score-change-score-file t]
2161 ["Set mark below..." gnus-score-set-mark-below t]
2162 ["Set expunge below..." gnus-score-set-expunge-below t]
2163 ["Edit current score file" gnus-score-edit-current-scores t]
2164 ["Edit score file" gnus-score-edit-file t]
2165 ["Trace score" gnus-score-find-trace t]
2166 ["Find words" gnus-score-find-favourite-words t]
2167 ["Rescore buffer" gnus-summary-rescore t]
2168 ["Increase score..." gnus-summary-increase-score t]
2169 ["Lower score..." gnus-summary-lower-score t]))))
2171 ;; Define both the Article menu in the summary buffer and the
2172 ;; equivalent Commands menu in the article buffer here for
2176 ["All" gnus-article-hide t]
2177 ["Headers" gnus-article-hide-headers t]
2178 ["Signature" gnus-article-hide-signature t]
2179 ["Citation" gnus-article-hide-citation t]
2180 ["List identifiers" gnus-article-hide-list-identifiers t]
2181 ["Banner" gnus-article-strip-banner t]
2182 ["Boring headers" gnus-article-hide-boring-headers t])
2184 ["All" gnus-article-highlight t]
2185 ["Headers" gnus-article-highlight-headers t]
2186 ["Signature" gnus-article-highlight-signature t]
2187 ["Citation" gnus-article-highlight-citation t])
2189 ["Local" gnus-article-date-local t]
2190 ["ISO8601" gnus-article-date-iso8601 t]
2191 ["UT" gnus-article-date-ut t]
2192 ["Original" gnus-article-date-original t]
2193 ["Lapsed" gnus-article-date-lapsed t]
2194 ["User-defined" gnus-article-date-user t])
2196 ["Remove images" gnus-article-remove-images t]
2197 ["Toggle smiley" gnus-treat-smiley t]
2198 ["Show X-Face" gnus-article-display-x-face t]
2199 ["Show picons in From" gnus-treat-from-picon t]
2200 ["Show picons in mail headers" gnus-treat-mail-picon t]
2201 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2202 ("View as different encoding"
2203 ,@(gnus-summary-menu-split
2206 ;; Since easymenu under Emacs doesn't allow
2207 ;; lambda forms for menu commands, we should
2208 ;; provide intern'ed function symbols.
2209 (let ((command (intern (format "\
2210 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2214 (let ((gnus-summary-show-article-charset-alist
2216 (gnus-summary-show-article 1))))
2217 `[,(symbol-name cs) ,command t]))
2218 (sort (if (fboundp 'coding-system-list)
2219 (coding-system-list)
2220 ;;(mapcar 'car mm-mime-mule-charset-alist)
2225 ["Leading" gnus-article-strip-leading-blank-lines t]
2226 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2227 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2228 ["All of the above" gnus-article-strip-blank-lines t]
2229 ["All" gnus-article-strip-all-blank-lines t]
2230 ["Leading space" gnus-article-strip-leading-space t]
2231 ["Trailing space" gnus-article-strip-trailing-space t]
2232 ["Leading space in headers"
2233 gnus-article-remove-leading-whitespace t])
2234 ["Overstrike" gnus-article-treat-overstrike t]
2235 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2236 ["Emphasis" gnus-article-emphasize t]
2237 ["Word wrap" gnus-article-fill-cited-article t]
2238 ["Fill long lines" gnus-article-fill-long-lines t]
2239 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2240 ["Remove CR" gnus-article-remove-cr t]
2241 ["Rot 13" gnus-summary-caesar-message
2242 ,@(if (featurep 'xemacs) '(t)
2243 '(:help "\"Caesar rotate\" article by 13"))]
2244 ["Morse decode" gnus-summary-morse-message t]
2245 ["Unix pipe..." gnus-summary-pipe-message t]
2246 ["Add buttons" gnus-article-add-buttons t]
2247 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2248 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2249 ["Toggle MIME" gnus-summary-toggle-mime t]
2250 ["Verbose header" gnus-summary-verbose-headers t]
2251 ["Toggle header" gnus-summary-toggle-header t]
2252 ["Unfold headers" gnus-article-treat-unfold-headers t]
2253 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2254 ["Html" gnus-article-wash-html t]
2255 ["Unsplit URLs" gnus-article-unsplit-urls t]
2256 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2257 ["Decode HZ" gnus-article-decode-HZ t]
2258 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2259 ("(Outlook) Deuglify"
2260 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2261 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2262 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2263 ["Full (Outlook) deuglify"
2264 gnus-article-outlook-deuglify-article t])
2267 ["Save in default format..." gnus-summary-save-article
2268 ,@(if (featurep 'xemacs) '(t)
2269 '(:help "Save article using default method"))]
2270 ["Save in file..." gnus-summary-save-article-file
2271 ,@(if (featurep 'xemacs) '(t)
2272 '(:help "Save article in file"))]
2273 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2274 ["Save in MH folder..." gnus-summary-save-article-folder t]
2275 ["Save in VM folder..." gnus-summary-save-article-vm t]
2276 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2277 ["Save body in file..." gnus-summary-save-article-body-file t]
2278 ["Pipe through a filter..." gnus-summary-pipe-output t]
2279 ["Add to SOUP packet" gnus-soup-add-article t]
2280 ["Print with Muttprint..." gnus-summary-muttprint t]
2281 ["Print" gnus-summary-print-article
2282 ,@(if (featurep 'xemacs) '(t)
2283 '(:help "Generate and print a PostScript image"))])
2284 ("Copy, move,... (Backend)"
2285 ,@(if (featurep 'xemacs) nil
2286 '(:help "Copying, moving, expiring articles..."))
2287 ["Respool article..." gnus-summary-respool-article t]
2288 ["Move article..." gnus-summary-move-article
2289 (gnus-check-backend-function
2290 'request-move-article gnus-newsgroup-name)]
2291 ["Copy article..." gnus-summary-copy-article t]
2292 ["Crosspost article..." gnus-summary-crosspost-article
2293 (gnus-check-backend-function
2294 'request-replace-article gnus-newsgroup-name)]
2295 ["Import file..." gnus-summary-import-article
2296 (gnus-check-backend-function
2297 'request-accept-article gnus-newsgroup-name)]
2298 ["Create article..." gnus-summary-create-article
2299 (gnus-check-backend-function
2300 'request-accept-article gnus-newsgroup-name)]
2301 ["Check if posted" gnus-summary-article-posted-p t]
2302 ["Edit article" gnus-summary-edit-article
2303 (not (gnus-group-read-only-p))]
2304 ["Delete article" gnus-summary-delete-article
2305 (gnus-check-backend-function
2306 'request-expire-articles gnus-newsgroup-name)]
2307 ["Query respool" gnus-summary-respool-query t]
2308 ["Trace respool" gnus-summary-respool-trace t]
2309 ["Delete expirable articles" gnus-summary-expire-articles-now
2310 (gnus-check-backend-function
2311 'request-expire-articles gnus-newsgroup-name)])
2313 ["Uudecode" gnus-uu-decode-uu
2314 ,@(if (featurep 'xemacs) '(t)
2315 '(:help "Decode uuencoded article(s)"))]
2316 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2317 ["Unshar" gnus-uu-decode-unshar t]
2318 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2319 ["Save" gnus-uu-decode-save t]
2320 ["Binhex" gnus-uu-decode-binhex t]
2321 ["Postscript" gnus-uu-decode-postscript t])
2323 ["Enter article" gnus-cache-enter-article t]
2324 ["Remove article" gnus-cache-remove-article t])
2325 ["Translate" gnus-article-babel t]
2326 ["Select article buffer" gnus-summary-select-article-buffer t]
2327 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2328 ["Isearch article..." gnus-summary-isearch-article t]
2329 ["Beginning of the article" gnus-summary-beginning-of-article t]
2330 ["End of the article" gnus-summary-end-of-article t]
2331 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2332 ["Fetch referenced articles" gnus-summary-refer-references t]
2333 ["Fetch current thread" gnus-summary-refer-thread t]
2334 ["Fetch article with id..." gnus-summary-refer-article t]
2335 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2336 ["Redisplay" gnus-summary-show-article t]
2337 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2339 gnus-summary-article-menu gnus-summary-mode-map ""
2340 (cons "Article" innards))
2342 (if (not (keymapp gnus-summary-article-menu))
2344 gnus-article-commands-menu gnus-article-mode-map ""
2345 (cons "Commands" innards))
2346 ;; in Emacs, don't share menu.
2347 (setq gnus-article-commands-menu
2348 (copy-keymap gnus-summary-article-menu))
2349 (define-key gnus-article-mode-map [menu-bar commands]
2350 (cons "Commands" gnus-article-commands-menu))))
2353 gnus-summary-thread-menu gnus-summary-mode-map ""
2355 ["Find all messages in thread" gnus-summary-refer-thread t]
2356 ["Toggle threading" gnus-summary-toggle-threads t]
2357 ["Hide threads" gnus-summary-hide-all-threads t]
2358 ["Show threads" gnus-summary-show-all-threads t]
2359 ["Hide thread" gnus-summary-hide-thread t]
2360 ["Show thread" gnus-summary-show-thread t]
2361 ["Go to next thread" gnus-summary-next-thread t]
2362 ["Go to previous thread" gnus-summary-prev-thread t]
2363 ["Go down thread" gnus-summary-down-thread t]
2364 ["Go up thread" gnus-summary-up-thread t]
2365 ["Top of thread" gnus-summary-top-thread t]
2366 ["Mark thread as read" gnus-summary-kill-thread t]
2367 ["Lower thread score" gnus-summary-lower-thread t]
2368 ["Raise thread score" gnus-summary-raise-thread t]
2369 ["Rethread current" gnus-summary-rethread-current t]))
2372 gnus-summary-post-menu gnus-summary-mode-map ""
2374 ["Send a message (mail or news)" gnus-summary-post-news
2375 ,@(if (featurep 'xemacs) '(t)
2376 '(:help "Compose a new message (mail or news)"))]
2377 ["Followup" gnus-summary-followup
2378 ,@(if (featurep 'xemacs) '(t)
2379 '(:help "Post followup to this article"))]
2380 ["Followup and yank" gnus-summary-followup-with-original
2381 ,@(if (featurep 'xemacs) '(t)
2382 '(:help "Post followup to this article, quoting its contents"))]
2383 ["Supersede article" gnus-summary-supersede-article t]
2384 ["Cancel article" gnus-summary-cancel-article
2385 ,@(if (featurep 'xemacs) '(t)
2386 '(:help "Cancel an article you posted"))]
2387 ["Reply" gnus-summary-reply t]
2388 ["Reply and yank" gnus-summary-reply-with-original t]
2389 ["Wide reply" gnus-summary-wide-reply t]
2390 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2391 ,@(if (featurep 'xemacs) '(t)
2392 '(:help "Mail a reply, quoting this article"))]
2393 ["Very wide reply" gnus-summary-very-wide-reply t]
2394 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2395 ,@(if (featurep 'xemacs) '(t)
2396 '(:help "Mail a very wide reply, quoting this article"))]
2397 ["Mail forward" gnus-summary-mail-forward t]
2398 ["Post forward" gnus-summary-post-forward t]
2399 ["Digest and mail" gnus-summary-digest-mail-forward t]
2400 ["Digest and post" gnus-summary-digest-post-forward t]
2401 ["Resend message" gnus-summary-resend-message t]
2402 ["Resend message edit" gnus-summary-resend-message-edit t]
2403 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2404 ["Send a mail" gnus-summary-mail-other-window t]
2405 ["Create a local message" gnus-summary-news-other-window t]
2406 ["Uuencode and post" gnus-uu-post-news
2407 ,@(if (featurep 'xemacs) '(t)
2408 '(:help "Post a uuencoded article"))]
2409 ["Followup via news" gnus-summary-followup-to-mail t]
2410 ["Followup via news and yank"
2411 gnus-summary-followup-to-mail-with-original t]
2413 ;;["Send" gnus-summary-send-draft t]
2414 ;;["Send bounced" gnus-resend-bounced-mail t])
2418 ((not (keymapp gnus-summary-post-menu))
2419 (setq gnus-article-post-menu gnus-summary-post-menu))
2420 ((not gnus-article-post-menu)
2421 ;; Don't share post menu.
2422 (setq gnus-article-post-menu
2423 (copy-keymap gnus-summary-post-menu))))
2424 (define-key gnus-article-mode-map [menu-bar post]
2425 (cons "Post" gnus-article-post-menu))
2428 gnus-summary-misc-menu gnus-summary-mode-map ""
2431 ["Mark as read" gnus-summary-mark-as-read-forward t]
2432 ["Mark same subject and select"
2433 gnus-summary-kill-same-subject-and-select t]
2434 ["Mark same subject" gnus-summary-kill-same-subject t]
2435 ["Catchup" gnus-summary-catchup
2436 ,@(if (featurep 'xemacs) '(t)
2437 '(:help "Mark unread articles in this group as read"))]
2438 ["Catchup all" gnus-summary-catchup-all t]
2439 ["Catchup to here" gnus-summary-catchup-to-here t]
2440 ["Catchup from here" gnus-summary-catchup-from-here t]
2441 ["Catchup region" gnus-summary-mark-region-as-read
2442 (gnus-mark-active-p)]
2443 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2445 ["Tick" gnus-summary-tick-article-forward t]
2446 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2447 ["Remove marks" gnus-summary-clear-mark-forward t]
2448 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2449 ["Set bookmark" gnus-summary-set-bookmark t]
2450 ["Remove bookmark" gnus-summary-remove-bookmark t])
2452 ["Marks..." gnus-summary-limit-to-marks t]
2453 ["Subject..." gnus-summary-limit-to-subject t]
2454 ["Author..." gnus-summary-limit-to-author t]
2455 ["Age..." gnus-summary-limit-to-age t]
2456 ["Extra..." gnus-summary-limit-to-extra t]
2457 ["Score..." gnus-summary-limit-to-score t]
2458 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2459 ["Unread" gnus-summary-limit-to-unread t]
2460 ["Unseen" gnus-summary-limit-to-unseen t]
2461 ["Replied" gnus-summary-limit-to-replied t]
2462 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2463 ["Next articles" gnus-summary-limit-to-articles t]
2464 ["Pop limit" gnus-summary-pop-limit t]
2465 ["Show dormant" gnus-summary-limit-include-dormant t]
2466 ["Hide childless dormant"
2467 gnus-summary-limit-exclude-childless-dormant t]
2468 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2469 ["Hide marked" gnus-summary-limit-exclude-marks t]
2470 ["Show expunged" gnus-summary-limit-include-expunged t])
2472 ["Set mark" gnus-summary-mark-as-processable t]
2473 ["Remove mark" gnus-summary-unmark-as-processable t]
2474 ["Remove all marks" gnus-summary-unmark-all-processable t]
2475 ["Invert marks" gnus-uu-invert-processable t]
2476 ["Mark above" gnus-uu-mark-over t]
2477 ["Mark series" gnus-uu-mark-series t]
2478 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2479 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2480 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2481 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2482 ["Mark all" gnus-uu-mark-all t]
2483 ["Mark buffer" gnus-uu-mark-buffer t]
2484 ["Mark sparse" gnus-uu-mark-sparse t]
2485 ["Mark thread" gnus-uu-mark-thread t]
2486 ["Unmark thread" gnus-uu-unmark-thread t]
2487 ("Process Mark Sets"
2488 ["Kill" gnus-summary-kill-process-mark t]
2489 ["Yank" gnus-summary-yank-process-mark
2490 gnus-newsgroup-process-stack]
2491 ["Save" gnus-summary-save-process-mark t]
2492 ["Run command on marked..." gnus-summary-universal-argument t]))
2494 ["Page forward" gnus-summary-next-page
2495 ,@(if (featurep 'xemacs) '(t)
2496 '(:help "Show next page of article"))]
2497 ["Page backward" gnus-summary-prev-page
2498 ,@(if (featurep 'xemacs) '(t)
2499 '(:help "Show previous page of article"))]
2500 ["Line forward" gnus-summary-scroll-up t])
2502 ["Next unread article" gnus-summary-next-unread-article t]
2503 ["Previous unread article" gnus-summary-prev-unread-article t]
2504 ["Next article" gnus-summary-next-article t]
2505 ["Previous article" gnus-summary-prev-article t]
2506 ["Next unread subject" gnus-summary-next-unread-subject t]
2507 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2508 ["Next article same subject" gnus-summary-next-same-subject t]
2509 ["Previous article same subject" gnus-summary-prev-same-subject t]
2510 ["First unread article" gnus-summary-first-unread-article t]
2511 ["Best unread article" gnus-summary-best-unread-article t]
2512 ["Go to subject number..." gnus-summary-goto-subject t]
2513 ["Go to article number..." gnus-summary-goto-article t]
2514 ["Go to the last article" gnus-summary-goto-last-article t]
2515 ["Pop article off history" gnus-summary-pop-article t])
2517 ["Sort by number" gnus-summary-sort-by-number t]
2518 ["Sort by author" gnus-summary-sort-by-author t]
2519 ["Sort by subject" gnus-summary-sort-by-subject t]
2520 ["Sort by date" gnus-summary-sort-by-date t]
2521 ["Sort by score" gnus-summary-sort-by-score t]
2522 ["Sort by lines" gnus-summary-sort-by-lines t]
2523 ["Sort by characters" gnus-summary-sort-by-chars t]
2524 ["Randomize" gnus-summary-sort-by-random t]
2525 ["Original sort" gnus-summary-sort-by-original t])
2527 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2528 ["Describe group" gnus-summary-describe-group t]
2529 ["Fetch charter" gnus-group-fetch-charter
2530 ,@(if (featurep 'xemacs) nil
2531 '(:help "Display the charter of the current group"))]
2532 ["Fetch control message" gnus-group-fetch-control
2533 ,@(if (featurep 'xemacs) nil
2534 '(:help "Display the archived control message for the current group"))]
2535 ["Read manual" gnus-info-find-node t])
2537 ["Pick and read" gnus-pick-mode t]
2538 ["Binary" gnus-binary-mode t])
2540 ["Regenerate" gnus-summary-prepare t]
2541 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2542 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2543 ["Toggle threading" gnus-summary-toggle-threads t])
2544 ["See old articles" gnus-summary-insert-old-articles t]
2545 ["See new articles" gnus-summary-insert-new-articles t]
2546 ["Filter articles..." gnus-summary-execute-command t]
2547 ["Run command on articles..." gnus-summary-universal-argument t]
2548 ["Search articles forward..." gnus-summary-search-article-forward t]
2549 ["Search articles backward..." gnus-summary-search-article-backward t]
2550 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2551 ["Expand window" gnus-summary-expand-window t]
2552 ["Expire expirable articles" gnus-summary-expire-articles
2553 (gnus-check-backend-function
2554 'request-expire-articles gnus-newsgroup-name)]
2555 ["Edit local kill file" gnus-summary-edit-local-kill t]
2556 ["Edit main kill file" gnus-summary-edit-global-kill t]
2557 ["Edit group parameters" gnus-summary-edit-parameters t]
2558 ["Customize group parameters" gnus-summary-customize-parameters t]
2559 ["Send a bug report" gnus-bug t]
2561 ["Catchup and exit" gnus-summary-catchup-and-exit
2562 ,@(if (featurep 'xemacs) '(t)
2563 '(:help "Mark unread articles in this group as read, then exit"))]
2564 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2565 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2566 ["Exit group" gnus-summary-exit
2567 ,@(if (featurep 'xemacs) '(t)
2568 '(:help "Exit current group, return to group selection mode"))]
2569 ["Exit group without updating" gnus-summary-exit-no-update t]
2570 ["Exit and goto next group" gnus-summary-next-group t]
2571 ["Exit and goto prev group" gnus-summary-prev-group t]
2572 ["Reselect group" gnus-summary-reselect-current-group t]
2573 ["Rescan group" gnus-summary-rescan-group t]
2574 ["Update dribble" gnus-summary-save-newsrc t])))
2576 (gnus-run-hooks 'gnus-summary-menu-hook)))
2578 (defvar gnus-summary-tool-bar-map nil)
2580 ;; Emacs 21 tool bar. Should be no-op otherwise.
2581 (defun gnus-summary-make-tool-bar ()
2582 (if (and (fboundp 'tool-bar-add-item-from-menu)
2583 (default-value 'tool-bar-mode)
2584 (not gnus-summary-tool-bar-map))
2585 (setq gnus-summary-tool-bar-map
2586 (let ((tool-bar-map (make-sparse-keymap))
2587 (load-path (mm-image-load-path)))
2588 (tool-bar-add-item-from-menu
2589 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2590 (tool-bar-add-item-from-menu
2591 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2592 (tool-bar-add-item-from-menu
2593 'gnus-summary-post-news "post" gnus-summary-mode-map)
2594 (tool-bar-add-item-from-menu
2595 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2596 (tool-bar-add-item-from-menu
2597 'gnus-summary-followup "followup" gnus-summary-mode-map)
2598 (tool-bar-add-item-from-menu
2599 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2600 (tool-bar-add-item-from-menu
2601 'gnus-summary-reply "reply" gnus-summary-mode-map)
2602 (tool-bar-add-item-from-menu
2603 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2604 (tool-bar-add-item-from-menu
2605 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2606 (tool-bar-add-item-from-menu
2607 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2608 (tool-bar-add-item-from-menu
2609 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2610 (tool-bar-add-item-from-menu
2611 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2612 (tool-bar-add-item-from-menu
2613 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2614 (tool-bar-add-item-from-menu
2615 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2616 (tool-bar-add-item-from-menu
2617 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2618 (tool-bar-add-item-from-menu
2619 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2621 (if gnus-summary-tool-bar-map
2622 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2624 (defun gnus-score-set-default (var value)
2625 "A version of set that updates the GNU Emacs menu-bar."
2627 ;; It is the message that forces the active status to be updated.
2630 (defun gnus-make-score-map (type)
2631 "Make a summary score map of type TYPE."
2634 (let ((headers '(("author" "from" string)
2635 ("subject" "subject" string)
2636 ("article body" "body" string)
2637 ("article head" "head" string)
2638 ("xref" "xref" string)
2639 ("extra header" "extra" string)
2640 ("lines" "lines" number)
2641 ("followups to author" "followup" string)))
2642 (types '((number ("less than" <)
2645 (string ("substring" s)
2649 (perms '(("temporary" (current-time-string))
2657 (if (eq type 'lower)
2662 (setq header (car headers))
2668 (let ((ts (cdr (assoc (nth 2 header) types)))
2684 'gnus-summary-score-entry
2686 (if (or (string= (nth 1 header)
2688 (string= (nth 1 header)
2691 (list 'gnus-summary-header
2693 (list 'quote (nth 1 (car ts)))
2694 (list 'gnus-score-delta-default
2701 (list (nreverse outp))))
2704 (list (nreverse outt))))
2706 (setq headers (cdr headers)))
2707 (list (nreverse outh))))))))
2711 (defun gnus-summary-mode (&optional group)
2712 "Major mode for reading articles.
2714 All normal editing commands are switched off.
2715 \\<gnus-summary-mode-map>
2716 Each line in this buffer represents one article. To read an
2717 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2718 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2721 You can also post articles and send mail from this buffer. To
2722 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2723 of an article, type `\\[gnus-summary-reply]'.
2725 There are approx. one gazillion commands you can execute in this
2726 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2728 The following commands are available:
2730 \\{gnus-summary-mode-map}"
2732 (kill-all-local-variables)
2733 (when (gnus-visual-p 'summary-menu 'menu)
2734 (gnus-summary-make-menu-bar)
2735 (gnus-summary-make-tool-bar))
2736 (gnus-summary-make-local-variables)
2737 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2738 (gnus-summary-make-local-variables))
2739 (gnus-make-thread-indent-array)
2740 (gnus-simplify-mode-line)
2741 (setq major-mode 'gnus-summary-mode)
2742 (setq mode-name "Summary")
2743 (make-local-variable 'minor-mode-alist)
2744 (use-local-map gnus-summary-mode-map)
2745 (buffer-disable-undo)
2746 (setq buffer-read-only t ;Disable modification
2747 show-trailing-whitespace nil)
2748 (setq truncate-lines t)
2749 (setq selective-display t)
2750 (setq selective-display-ellipses t) ;Display `...'
2751 (gnus-summary-set-display-table)
2752 (gnus-set-default-directory)
2753 (setq gnus-newsgroup-name group)
2754 (unless (gnus-news-group-p group)
2755 (setq gnus-newsgroup-incorporated
2756 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2757 (make-local-variable 'gnus-summary-line-format)
2758 (make-local-variable 'gnus-summary-line-format-spec)
2759 (make-local-variable 'gnus-summary-dummy-line-format)
2760 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2761 (make-local-variable 'gnus-summary-mark-positions)
2762 (gnus-make-local-hook 'pre-command-hook)
2763 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2764 (gnus-run-hooks 'gnus-summary-mode-hook)
2765 (turn-on-gnus-mailing-list-mode)
2766 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2767 (gnus-update-summary-mark-positions))
2769 (defun gnus-summary-make-local-variables ()
2770 "Make all the local summary buffer variables."
2772 (dolist (local gnus-summary-local-variables)
2775 (if (eq (cdr local) 'global)
2776 ;; Copy the global value of the variable.
2777 (setq global (symbol-value (car local)))
2778 ;; Use the value from the list.
2779 (setq global (eval (cdr local))))
2780 (set (make-local-variable (car local)) global))
2781 ;; Simple nil-valued local variable.
2782 (set (make-local-variable local) nil)))))
2784 (defun gnus-summary-clear-local-variables ()
2785 (let ((locals gnus-summary-local-variables))
2787 (if (consp (car locals))
2788 (and (vectorp (caar locals))
2789 (set (caar locals) nil))
2790 (and (vectorp (car locals))
2791 (set (car locals) nil)))
2792 (setq locals (cdr locals)))))
2794 ;; Summary data functions.
2796 (defmacro gnus-data-number (data)
2799 (defmacro gnus-data-set-number (data number)
2800 `(setcar ,data ,number))
2802 (defmacro gnus-data-mark (data)
2805 (defmacro gnus-data-set-mark (data mark)
2806 `(setcar (nthcdr 1 ,data) ,mark))
2808 (defmacro gnus-data-pos (data)
2811 (defmacro gnus-data-set-pos (data pos)
2812 `(setcar (nthcdr 2 ,data) ,pos))
2814 (defmacro gnus-data-header (data)
2817 (defmacro gnus-data-set-header (data header)
2818 `(setcar (nthcdr 3 ,data) ,header))
2820 (defmacro gnus-data-level (data)
2823 (defmacro gnus-data-unread-p (data)
2824 `(= (nth 1 ,data) gnus-unread-mark))
2826 (defmacro gnus-data-read-p (data)
2827 `(/= (nth 1 ,data) gnus-unread-mark))
2829 (defmacro gnus-data-pseudo-p (data)
2830 `(consp (nth 3 ,data)))
2832 (defmacro gnus-data-find (number)
2833 `(assq ,number gnus-newsgroup-data))
2835 (defmacro gnus-data-find-list (number &optional data)
2836 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2837 (memq (assq ,number bdata)
2840 (defmacro gnus-data-make (number mark pos header level)
2841 `(list ,number ,mark ,pos ,header ,level))
2843 (defun gnus-data-enter (after-article number mark pos header level offset)
2844 (let ((data (gnus-data-find-list after-article)))
2846 (error "No such article: %d" after-article))
2847 (setcdr data (cons (gnus-data-make number mark pos header level)
2849 (setq gnus-newsgroup-data-reverse nil)
2850 (gnus-data-update-list (cddr data) offset)))
2852 (defun gnus-data-enter-list (after-article list &optional offset)
2854 (let ((data (and after-article (gnus-data-find-list after-article)))
2858 (let ((odata gnus-newsgroup-data))
2859 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2861 (gnus-data-update-list odata offset)))
2862 ;; Find the last element in the list to be spliced into the main
2864 (setq list (last list))
2867 (setcdr list gnus-newsgroup-data)
2868 (setq gnus-newsgroup-data ilist)
2870 (gnus-data-update-list (cdr list) offset)))
2871 (setcdr list (cdr data))
2874 (gnus-data-update-list (cdr list) offset))))
2875 (setq gnus-newsgroup-data-reverse nil))))
2877 (defun gnus-data-remove (article &optional offset)
2878 (let ((data gnus-newsgroup-data))
2879 (if (= (gnus-data-number (car data)) article)
2881 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2882 gnus-newsgroup-data-reverse nil)
2884 (gnus-data-update-list gnus-newsgroup-data offset)))
2886 (when (= (gnus-data-number (cadr data)) article)
2887 (setcdr data (cddr data))
2889 (gnus-data-update-list (cdr data) offset))
2891 gnus-newsgroup-data-reverse nil))
2892 (setq data (cdr data))))))
2894 (defmacro gnus-data-list (backward)
2896 (or gnus-newsgroup-data-reverse
2897 (setq gnus-newsgroup-data-reverse
2898 (reverse gnus-newsgroup-data)))
2899 gnus-newsgroup-data))
2901 (defun gnus-data-update-list (data offset)
2902 "Add OFFSET to the POS of all data entries in DATA."
2903 (setq gnus-newsgroup-data-reverse nil)
2905 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2906 (setq data (cdr data))))
2908 (defun gnus-summary-article-pseudo-p (article)
2909 "Say whether this article is a pseudo article or not."
2910 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2912 (defmacro gnus-summary-article-sparse-p (article)
2913 "Say whether this article is a sparse article or not."
2914 `(memq ,article gnus-newsgroup-sparse))
2916 (defmacro gnus-summary-article-ancient-p (article)
2917 "Say whether this article is a sparse article or not."
2918 `(memq ,article gnus-newsgroup-ancient))
2920 (defun gnus-article-parent-p (number)
2921 "Say whether this article is a parent or not."
2922 (let ((data (gnus-data-find-list number)))
2923 (and (cdr data) ; There has to be an article after...
2924 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2925 (gnus-data-level (nth 1 data))))))
2927 (defun gnus-article-children (number)
2928 "Return a list of all children to NUMBER."
2929 (let* ((data (gnus-data-find-list number))
2930 (level (gnus-data-level (car data)))
2932 (setq data (cdr data))
2934 (= (gnus-data-level (car data)) (1+ level)))
2935 (push (gnus-data-number (car data)) children)
2936 (setq data (cdr data)))
2939 (defmacro gnus-summary-skip-intangible ()
2940 "If the current article is intangible, then jump to a different article."
2941 '(let ((to (get-text-property (point) 'gnus-intangible)))
2942 (and to (gnus-summary-goto-subject to))))
2944 (defmacro gnus-summary-article-intangible-p ()
2945 "Say whether this article is intangible or not."
2946 '(get-text-property (point) 'gnus-intangible))
2948 (defun gnus-article-read-p (article)
2949 "Say whether ARTICLE is read or not."
2950 (not (or (memq article gnus-newsgroup-marked)
2951 (memq article gnus-newsgroup-spam-marked)
2952 (memq article gnus-newsgroup-unreads)
2953 (memq article gnus-newsgroup-unselected)
2954 (memq article gnus-newsgroup-dormant))))
2956 ;; Some summary mode macros.
2958 (defmacro gnus-summary-article-number ()
2959 "The article number of the article on the current line.
2960 If there isn't an article number here, then we return the current
2963 (gnus-summary-skip-intangible)
2964 (or (get-text-property (point) 'gnus-number)
2965 (gnus-summary-last-subject))))
2967 (defmacro gnus-summary-article-header (&optional number)
2968 "Return the header of article NUMBER."
2969 `(gnus-data-header (gnus-data-find
2970 ,(or number '(gnus-summary-article-number)))))
2972 (defmacro gnus-summary-thread-level (&optional number)
2973 "Return the level of thread that starts with article NUMBER."
2974 `(if (and (eq gnus-summary-make-false-root 'dummy)
2975 (get-text-property (point) 'gnus-intangible))
2977 (gnus-data-level (gnus-data-find
2978 ,(or number '(gnus-summary-article-number))))))
2980 (defmacro gnus-summary-article-mark (&optional number)
2981 "Return the mark of article NUMBER."
2982 `(gnus-data-mark (gnus-data-find
2983 ,(or number '(gnus-summary-article-number)))))
2985 (defmacro gnus-summary-article-pos (&optional number)
2986 "Return the position of the line of article NUMBER."
2987 `(gnus-data-pos (gnus-data-find
2988 ,(or number '(gnus-summary-article-number)))))
2990 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2991 (defmacro gnus-summary-article-subject (&optional number)
2992 "Return current subject string or nil if nothing."
2995 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2996 '(gnus-data-header (assq (gnus-summary-article-number)
2997 gnus-newsgroup-data)))))
3000 (mail-header-subject headers))))
3002 (defmacro gnus-summary-article-score (&optional number)
3003 "Return current article score."
3004 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3005 gnus-newsgroup-scored))
3006 gnus-summary-default-score 0))
3008 (defun gnus-summary-article-children (&optional number)
3009 "Return a list of article numbers that are children of article NUMBER."
3010 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3011 (level (gnus-data-level (car data)))
3013 (while (and (setq data (cdr data))
3014 (> (setq l (gnus-data-level (car data))) level))
3015 (and (= (1+ level) l)
3016 (push (gnus-data-number (car data))
3018 (nreverse children)))
3020 (defun gnus-summary-article-parent (&optional number)
3021 "Return the article number of the parent of article NUMBER."
3022 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3023 (gnus-data-list t)))
3024 (level (gnus-data-level (car data))))
3026 () ; This is a root.
3027 ;; We search until we find an article with a level less than
3028 ;; this one. That function has to be the parent.
3029 (while (and (setq data (cdr data))
3030 (not (< (gnus-data-level (car data)) level))))
3031 (and data (gnus-data-number (car data))))))
3033 (defun gnus-unread-mark-p (mark)
3034 "Say whether MARK is the unread mark."
3035 (= mark gnus-unread-mark))
3037 (defun gnus-read-mark-p (mark)
3038 "Say whether MARK is one of the marks that mark as read.
3039 This is all marks except unread, ticked, dormant, and expirable."
3040 (not (or (= mark gnus-unread-mark)
3041 (= mark gnus-ticked-mark)
3042 (= mark gnus-spam-mark)
3043 (= mark gnus-dormant-mark)
3044 (= mark gnus-expirable-mark))))
3046 (defmacro gnus-article-mark (number)
3047 "Return the MARK of article NUMBER.
3048 This macro should only be used when computing the mark the \"first\"
3049 time; i.e., when generating the summary lines. After that,
3050 `gnus-summary-article-mark' should be used to examine the
3053 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3054 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3055 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3056 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3057 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3058 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3059 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3060 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3061 gnus-ancient-mark))))
3063 ;; Saving hidden threads.
3065 (defmacro gnus-save-hidden-threads (&rest forms)
3066 "Save hidden threads, eval FORMS, and restore the hidden threads."
3067 (let ((config (make-symbol "config")))
3068 `(let ((,config (gnus-hidden-threads-configuration)))
3072 (gnus-restore-hidden-threads-configuration ,config)))))
3073 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3074 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3076 (defun gnus-data-compute-positions ()
3077 "Compute the positions of all articles."
3078 (setq gnus-newsgroup-data-reverse nil)
3079 (let ((data gnus-newsgroup-data))
3081 (gnus-save-hidden-threads
3082 (gnus-summary-show-all-threads)
3083 (goto-char (point-min))
3085 (while (get-text-property (point) 'gnus-intangible)
3087 (gnus-data-set-pos (car data) (+ (point) 3))
3088 (setq data (cdr data))
3089 (forward-line 1))))))
3091 (defun gnus-hidden-threads-configuration ()
3092 "Return the current hidden threads configuration."
3095 (goto-char (point-min))
3096 (while (search-forward "\r" nil t)
3097 (push (1- (point)) config))
3100 (defun gnus-restore-hidden-threads-configuration (config)
3101 "Restore hidden threads configuration from CONFIG."
3103 (let (point buffer-read-only)
3104 (while (setq point (pop config))
3105 (when (and (< point (point-max))
3107 (eq (char-after) ?\n))
3108 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3110 ;; Various summary mode internalish functions.
3112 (defun gnus-mouse-pick-article (e)
3115 (gnus-summary-next-page nil t))
3117 (defun gnus-summary-set-display-table ()
3118 "Change the display table.
3119 Odd characters have a tendency to mess
3120 up nicely formatted displays - we make all possible glyphs
3121 display only a single character."
3123 ;; We start from the standard display table, if any.
3124 (let ((table (or (copy-sequence standard-display-table)
3125 (make-display-table)))
3127 ;; Nix out all the control chars...
3128 (while (>= (setq i (1- i)) 0)
3129 (aset table i [??]))
3130 ;; ... but not newline and cr, of course. (cr is necessary for the
3131 ;; selective display).
3132 (aset table ?\n nil)
3133 (aset table ?\r nil)
3134 ;; We keep TAB as well.
3135 (aset table ?\t nil)
3136 ;; We nix out any glyphs over 126 that are not set already.
3138 (while (>= (setq i (1- i)) 127)
3139 ;; Only modify if the entry is nil.
3140 (unless (aref table i)
3141 (aset table i [??]))))
3142 (setq buffer-display-table table)))
3144 (defun gnus-summary-set-article-display-arrow (pos)
3145 "Update the overlay arrow to point to line at position POS."
3146 (when (and gnus-summary-display-arrow
3147 (boundp 'overlay-arrow-position)
3148 (boundp 'overlay-arrow-string))
3152 (unless overlay-arrow-position
3153 (setq overlay-arrow-position (make-marker)))
3154 (setq overlay-arrow-string "=>"
3155 overlay-arrow-position (set-marker overlay-arrow-position
3157 (current-buffer))))))
3159 (defun gnus-summary-setup-buffer (group)
3160 "Initialize summary buffer."
3161 (let ((buffer (gnus-summary-buffer-name group))
3162 (dead-name (concat "*Dead Summary "
3163 (gnus-group-decoded-name group) "*")))
3164 ;; If a dead summary buffer exists, we kill it.
3165 (when (gnus-buffer-live-p dead-name)
3166 (gnus-kill-buffer dead-name))
3167 (if (get-buffer buffer)
3170 (setq gnus-summary-buffer (current-buffer))
3171 (not gnus-newsgroup-prepared))
3172 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3173 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3174 (gnus-summary-mode group)
3176 (gnus-carpal-setup-buffer 'summary))
3177 (unless gnus-single-article-buffer
3178 (make-local-variable 'gnus-article-buffer)
3179 (make-local-variable 'gnus-article-current)
3180 (make-local-variable 'gnus-original-article-buffer))
3181 (setq gnus-newsgroup-name group)
3182 ;; Set any local variables in the group parameters.
3183 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3186 (defun gnus-set-global-variables ()
3187 "Set the global equivalents of the buffer-local variables.
3188 They are set to the latest values they had. These reflect the summary
3189 buffer that was in action when the last article was fetched."
3190 (when (eq major-mode 'gnus-summary-mode)
3191 (setq gnus-summary-buffer (current-buffer))
3192 (let ((name gnus-newsgroup-name)
3193 (marked gnus-newsgroup-marked)
3194 (spam gnus-newsgroup-spam-marked)
3195 (unread gnus-newsgroup-unreads)
3196 (headers gnus-current-headers)
3197 (data gnus-newsgroup-data)
3198 (summary gnus-summary-buffer)
3199 (article-buffer gnus-article-buffer)
3200 (original gnus-original-article-buffer)
3201 (gac gnus-article-current)
3202 (reffed gnus-reffed-article-number)
3203 (score-file gnus-current-score-file)
3204 (default-charset gnus-newsgroup-charset)
3206 (let ((locals gnus-newsgroup-variables))
3208 (if (consp (car locals))
3209 (push (eval (caar locals)) vlist)
3210 (push (eval (car locals)) vlist))
3211 (setq locals (cdr locals)))
3212 (setq vlist (nreverse vlist)))
3213 (with-current-buffer gnus-group-buffer
3214 (setq gnus-newsgroup-name name
3215 gnus-newsgroup-marked marked
3216 gnus-newsgroup-spam-marked spam
3217 gnus-newsgroup-unreads unread
3218 gnus-current-headers headers
3219 gnus-newsgroup-data data
3220 gnus-article-current gac
3221 gnus-summary-buffer summary
3222 gnus-article-buffer article-buffer
3223 gnus-original-article-buffer original
3224 gnus-reffed-article-number reffed
3225 gnus-current-score-file score-file
3226 gnus-newsgroup-charset default-charset)
3227 (let ((locals gnus-newsgroup-variables))
3229 (if (consp (car locals))
3230 (set (caar locals) (pop vlist))
3231 (set (car locals) (pop vlist)))
3232 (setq locals (cdr locals))))
3233 ;; The article buffer also has local variables.
3234 (when (gnus-buffer-live-p gnus-article-buffer)
3235 (set-buffer gnus-article-buffer)
3236 (setq gnus-summary-buffer summary))))))
3238 (defun gnus-summary-article-unread-p (article)
3239 "Say whether ARTICLE is unread or not."
3240 (memq article gnus-newsgroup-unreads))
3242 (defun gnus-summary-first-article-p (&optional article)
3243 "Return whether ARTICLE is the first article in the buffer."
3244 (if (not (setq article (or article (gnus-summary-article-number))))
3246 (eq article (caar gnus-newsgroup-data))))
3248 (defun gnus-summary-last-article-p (&optional article)
3249 "Return whether ARTICLE is the last article in the buffer."
3250 (if (not (setq article (or article (gnus-summary-article-number))))
3251 ;; All non-existent numbers are the last article. :-)
3253 (not (cdr (gnus-data-find-list article)))))
3255 (defun gnus-make-thread-indent-array ()
3257 (unless (and gnus-thread-indent-array
3258 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3259 (setq gnus-thread-indent-array (make-vector 201 "")
3260 gnus-thread-indent-array-level gnus-thread-indent-level)
3262 (aset gnus-thread-indent-array n
3263 (make-string (* n gnus-thread-indent-level) ? ))
3266 (defun gnus-update-summary-mark-positions ()
3267 "Compute where the summary marks are to go."
3269 (when (gnus-buffer-exists-p gnus-summary-buffer)
3270 (set-buffer gnus-summary-buffer))
3271 (let ((spec gnus-summary-line-format-spec)
3274 (gnus-set-work-buffer)
3275 (let ((gnus-tmp-unread ?Z)
3276 (gnus-replied-mark ?Z)
3277 (gnus-score-below-mark ?Z)
3278 (gnus-score-over-mark ?Z)
3279 (gnus-undownloaded-mark ?Z)
3280 (gnus-summary-line-format-spec spec)
3281 (gnus-newsgroup-downloadable '(0))
3283 (make-full-mail-header
3284 0 "" "nobody" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil))
3285 case-fold-search ignores)
3286 ;; Here, all marks are bound to Z.
3287 (gnus-summary-insert-line header
3288 0 nil t gnus-tmp-unread t nil "" nil 1)
3289 (goto-char (point-min))
3290 ;; Memorize the positions of the same characters as dummy marks.
3291 (while (re-search-forward "[A-D]" nil t)
3292 (push (point) ignores))
3294 ;; We use A-D as dummy marks in order to know column positions
3295 ;; where marks should be inserted.
3296 (setq gnus-tmp-unread ?A
3297 gnus-replied-mark ?B
3298 gnus-score-below-mark ?C
3299 gnus-score-over-mark ?C
3300 gnus-undownloaded-mark ?D)
3301 (gnus-summary-insert-line header
3302 0 nil t gnus-tmp-unread t nil "" nil 1)
3303 ;; Ignore characters which aren't dummy marks.
3305 (delete-region (goto-char (1- p)) p)
3307 (goto-char (point-min))
3308 (setq pos (list (cons 'unread
3309 (and (search-forward "A" nil t)
3310 (- (point) (point-min) 1)))))
3311 (goto-char (point-min))
3312 (push (cons 'replied (and (search-forward "B" nil t)
3313 (- (point) (point-min) 1)))
3315 (goto-char (point-min))
3316 (push (cons 'score (and (search-forward "C" nil t)
3317 (- (point) (point-min) 1)))
3319 (goto-char (point-min))
3320 (push (cons 'download (and (search-forward "D" nil t)
3321 (- (point) (point-min) 1)))
3323 (setq gnus-summary-mark-positions pos))))
3325 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3326 "Insert a dummy root in the summary buffer."
3328 (gnus-add-text-properties
3329 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3330 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3332 (defun gnus-summary-extract-address-component (from)
3333 (or (car (funcall gnus-extract-address-components from))
3336 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3337 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3338 default-mime-charset)))
3339 ;; Is it really necessary to do this next part for each summary line?
3340 ;; Luckily, doesn't seem to slow things down much.
3342 (and gnus-ignored-from-addresses
3343 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3344 (let ((extra-headers (mail-header-extra header))
3348 ((setq to (cdr (assq 'To extra-headers)))
3351 (gnus-summary-extract-address-component
3352 (funcall gnus-decode-encoded-word-function to)))))
3353 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3354 (concat "=> " newsgroups)))))
3355 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3357 (defun gnus-summary-insert-line (gnus-tmp-header
3358 gnus-tmp-level gnus-tmp-current
3359 undownloaded gnus-tmp-unread gnus-tmp-replied
3360 gnus-tmp-expirable gnus-tmp-subject-or-nil
3361 &optional gnus-tmp-dummy gnus-tmp-score
3363 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3364 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3365 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3366 (gnus-tmp-score-char
3367 (if (or (null gnus-summary-default-score)
3368 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3369 gnus-summary-zcore-fuzz))
3371 (if (< gnus-tmp-score gnus-summary-default-score)
3372 gnus-score-below-mark gnus-score-over-mark)))
3373 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3375 (cond (gnus-tmp-process gnus-process-mark)
3376 ((memq gnus-tmp-current gnus-newsgroup-cached)
3378 (gnus-tmp-replied gnus-replied-mark)
3379 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3380 gnus-forwarded-mark)
3381 ((memq gnus-tmp-current gnus-newsgroup-saved)
3383 ((memq gnus-tmp-number gnus-newsgroup-recent)
3385 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3388 (gnus-tmp-downloaded
3390 gnus-undownloaded-mark)
3391 (gnus-newsgroup-agentized
3392 gnus-downloaded-mark)
3395 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3398 ((string-match "<[^>]+> *$" gnus-tmp-from)
3399 (let ((beg (match-beginning 0)))
3400 (or (and (string-match "^\".+\"" gnus-tmp-from)
3401 (substring gnus-tmp-from 1 (1- (match-end 0))))
3402 (substring gnus-tmp-from 0 beg))))
3403 ((string-match "(.+)" gnus-tmp-from)
3404 (substring gnus-tmp-from
3405 (1+ (match-beginning 0)) (1- (match-end 0))))
3407 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3408 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3409 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3410 (buffer-read-only nil))
3411 (when (string= gnus-tmp-name "")
3412 (setq gnus-tmp-name gnus-tmp-from))
3413 (unless (numberp gnus-tmp-lines)
3414 (setq gnus-tmp-lines -1))
3415 (if (= gnus-tmp-lines -1)
3416 (setq gnus-tmp-lines "?")
3417 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3418 (gnus-put-text-property-excluding-characters-with-faces
3420 (progn (eval gnus-summary-line-format-spec) (point))
3421 'gnus-number gnus-tmp-number)
3422 (when (gnus-visual-p 'summary-highlight 'highlight)
3424 (gnus-run-hooks 'gnus-summary-update-hook)
3427 (defun gnus-summary-update-line (&optional dont-update)
3428 "Update summary line after change."
3429 (when (and gnus-summary-default-score
3430 (not gnus-summary-inhibit-highlight))
3431 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3432 (article (gnus-summary-article-number))
3433 (score (gnus-summary-article-score article)))
3435 (if (and gnus-summary-mark-below
3436 (< (gnus-summary-article-score)
3437 gnus-summary-mark-below))
3438 ;; This article has a low score, so we mark it as read.
3439 (when (memq article gnus-newsgroup-unreads)
3440 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3441 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3442 ;; This article was previously marked as read on account
3443 ;; of a low score, but now it has risen, so we mark it as
3445 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3446 (gnus-summary-update-mark
3447 (if (or (null gnus-summary-default-score)
3448 (<= (abs (- score gnus-summary-default-score))
3449 gnus-summary-zcore-fuzz))
3451 (if (< score gnus-summary-default-score)
3452 gnus-score-below-mark gnus-score-over-mark))
3454 ;; Do visual highlighting.
3455 (when (gnus-visual-p 'summary-highlight 'highlight)
3456 (gnus-run-hooks 'gnus-summary-update-hook)))))
3458 (defvar gnus-tmp-new-adopts nil)
3460 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3461 "Return the number of articles in THREAD.
3462 This may be 0 in some cases -- if none of the articles in
3463 the thread are to be displayed."
3465 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3467 ((not (listp thread))
3469 ((and (consp thread) (cdr thread))
3472 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3475 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3478 (when (and level (zerop level) gnus-tmp-new-adopts)
3481 'gnus-summary-number-of-articles-in-thread
3482 gnus-tmp-new-adopts))))
3484 (if (> number 1) gnus-not-empty-thread-mark
3485 gnus-empty-thread-mark)
3488 (defsubst gnus-summary-line-message-size (head)
3489 "Return pretty-printed version of message size.
3490 This function is intended to be used in
3491 `gnus-summary-line-format-alist'."
3492 (let ((c (or (mail-header-chars head) -1)))
3493 (cond ((< c 0) "n/a") ; chars not available
3494 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3495 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3496 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3497 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3500 (defun gnus-summary-set-local-parameters (group)
3501 "Go through the local params of GROUP and set all variable specs in that list."
3502 (let ((vars '(quit-config))) ; Ignore quit-config.
3503 (dolist (elem (gnus-group-find-parameter group))
3504 (and (consp elem) ; Has to be a cons.
3505 (consp (cdr elem)) ; The cdr has to be a list.
3506 (symbolp (car elem)) ; Has to be a symbol in there.
3507 (not (memq (car elem) vars))
3508 (ignore-errors ; So we set it.
3509 (push (car elem) vars)
3510 (make-local-variable (car elem))
3511 (set (car elem) (eval (nth 1 elem))))))))
3513 (defun gnus-summary-read-group (group &optional show-all no-article
3514 kill-buffer no-display backward
3516 "Start reading news in newsgroup GROUP.
3517 If SHOW-ALL is non-nil, already read articles are also listed.
3518 If NO-ARTICLE is non-nil, no article is selected initially.
3519 If NO-DISPLAY, don't generate a summary buffer."
3523 (let ((gnus-auto-select-next nil))
3524 (or (gnus-summary-read-group-1
3525 group show-all no-article
3526 kill-buffer no-display
3529 select-articles nil)))))
3530 (eq gnus-auto-select-next 'quietly))
3531 (set-buffer gnus-group-buffer)
3532 ;; The entry function called above goes to the next
3533 ;; group automatically, so we go two groups back
3534 ;; if we are searching for the previous group.
3536 (gnus-group-prev-unread-group 2))
3537 (if (not (equal group (gnus-group-group-name)))
3538 (setq group (gnus-group-group-name))
3542 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3543 "Directly jump to the other GROUP from summary buffer.
3544 If SHOW-ALL is non-nil, already read articles are also listed."
3546 (if (eq gnus-summary-buffer (current-buffer))
3547 (list (completing-read
3548 "Group: " gnus-active-hashtb nil t
3549 (when (and gnus-newsgroup-name
3550 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3551 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3552 'gnus-group-history)
3554 (error "%s must be invoked from a gnus summary buffer." this-command)))
3555 (unless (or (zerop (length group))
3556 (and gnus-newsgroup-name
3557 (string-equal gnus-newsgroup-name group)))
3559 (gnus-summary-read-group group show-all
3560 gnus-dont-select-after-jump-to-other-group)))
3562 (defun gnus-summary-read-group-1 (group show-all no-article
3563 kill-buffer no-display
3564 &optional select-articles)
3565 ;; Killed foreign groups can't be entered.
3566 ;; (when (and (not (gnus-group-native-p group))
3567 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3568 ;; (error "Dead non-native groups can't be entered"))
3569 (gnus-message 5 "Retrieving newsgroup: %s..."
3570 (gnus-group-decoded-name group))
3571 (let* ((new-group (gnus-summary-setup-buffer group))
3572 (quit-config (gnus-group-quit-config group))
3573 (did-select (and new-group (gnus-select-newsgroup
3574 group show-all select-articles))))
3576 ;; This summary buffer exists already, so we just select it.
3578 (gnus-set-global-variables)
3580 (gnus-kill-or-deaden-summary kill-buffer))
3581 (gnus-configure-windows 'summary 'force)
3582 (gnus-set-mode-line 'summary)
3583 (gnus-summary-position-point)
3586 ;; We couldn't select this group.
3588 (when (and (eq major-mode 'gnus-summary-mode)
3589 (not (equal (current-buffer) kill-buffer)))
3590 (kill-buffer (current-buffer))
3591 (if (not quit-config)
3593 ;; Update the info -- marks might need to be removed,
3595 (gnus-summary-update-info)
3596 (set-buffer gnus-group-buffer)
3597 (gnus-group-jump-to-group group)
3598 (gnus-group-next-unread-group 1))
3599 (gnus-handle-ephemeral-exit quit-config)))
3600 (let ((grpinfo (gnus-get-info group)))
3601 (if (null (gnus-info-read grpinfo))
3602 (gnus-message 3 "Group %s contains no messages"
3603 (gnus-group-decoded-name group))
3604 (gnus-message 3 "Can't select group")))
3606 ;; The user did a `C-g' while prompting for number of articles,
3607 ;; so we exit this group.
3608 ((eq did-select 'quit)
3609 (and (eq major-mode 'gnus-summary-mode)
3610 (not (equal (current-buffer) kill-buffer))
3611 (kill-buffer (current-buffer)))
3613 (gnus-kill-or-deaden-summary kill-buffer))
3614 (if (not quit-config)
3616 (set-buffer gnus-group-buffer)
3617 (gnus-group-jump-to-group group)
3618 (gnus-group-next-unread-group 1)
3619 (gnus-configure-windows 'group 'force))
3620 (gnus-handle-ephemeral-exit quit-config))
3621 ;; Finally signal the quit.
3623 ;; The group was successfully selected.
3625 (gnus-set-global-variables)
3626 ;; Save the active value in effect when the group was entered.
3627 (setq gnus-newsgroup-active
3629 (gnus-active gnus-newsgroup-name)))
3630 ;; You can change the summary buffer in some way with this hook.
3631 (gnus-run-hooks 'gnus-select-group-hook)
3632 (when (memq 'summary (gnus-update-format-specifications
3633 nil 'summary 'summary-mode 'summary-dummy))
3634 ;; The format specification for the summary line was updated,
3635 ;; so we need to update the mark positions as well.
3636 (gnus-update-summary-mark-positions))
3637 ;; Do score processing.
3638 (when gnus-use-scoring
3639 (gnus-possibly-score-headers))
3640 ;; Check whether to fill in the gaps in the threads.
3641 (when gnus-build-sparse-threads
3642 (gnus-build-sparse-threads))
3643 ;; Find the initial limit.
3645 (let ((gnus-newsgroup-dormant nil))
3646 (gnus-summary-initial-limit show-all))
3647 (gnus-summary-initial-limit show-all))
3648 ;; Generate the summary buffer.
3650 (gnus-summary-prepare))
3651 (when gnus-use-trees
3652 (gnus-tree-open group)
3653 (setq gnus-summary-highlight-line-function
3654 'gnus-tree-highlight-article))
3655 ;; If the summary buffer is empty, but there are some low-scored
3656 ;; articles or some excluded dormants, we include these in the
3658 (when (and (zerop (buffer-size))
3660 (cond (gnus-newsgroup-dormant
3661 (gnus-summary-limit-include-dormant))
3662 ((and gnus-newsgroup-scored show-all)
3663 (gnus-summary-limit-include-expunged t))))
3664 ;; Function `gnus-apply-kill-file' must be called in this hook.
3665 (gnus-run-hooks 'gnus-apply-kill-hook)
3666 (if (and (zerop (buffer-size))
3669 ;; This newsgroup is empty.
3670 (gnus-summary-catchup-and-exit nil t)
3671 (gnus-message 6 "No unread news")
3673 (gnus-kill-or-deaden-summary kill-buffer))
3674 ;; Return nil from this function.
3676 ;; Hide conversation thread subtrees. We cannot do this in
3677 ;; gnus-summary-prepare-hook since kill processing may not
3678 ;; work with hidden articles.
3679 (gnus-summary-maybe-hide-threads)
3681 (gnus-kill-or-deaden-summary kill-buffer))
3682 (gnus-summary-auto-select-subject)
3683 ;; Show first unread article if requested.
3684 (if (and (not no-article)
3686 gnus-newsgroup-unreads
3687 gnus-auto-select-first)
3689 (gnus-configure-windows 'summary)
3690 (let ((art (gnus-summary-article-number)))
3691 (unless (and (not gnus-plugged)
3692 (or (memq art gnus-newsgroup-undownloaded)
3693 (memq art gnus-newsgroup-downloadable)))
3694 (gnus-summary-goto-article art))))
3695 ;; Don't select any articles.
3696 (gnus-summary-position-point)
3697 (gnus-configure-windows 'summary 'force)
3698 (gnus-set-mode-line 'summary))
3699 (when (and gnus-auto-center-group
3700 (get-buffer-window gnus-group-buffer t))
3701 ;; Gotta use windows, because recenter does weird stuff if
3702 ;; the current buffer ain't the displayed window.
3703 (let ((owin (selected-window)))
3704 (select-window (get-buffer-window gnus-group-buffer t))
3705 (when (gnus-group-goto-group group)
3707 (select-window owin)))
3708 ;; Mark this buffer as "prepared".
3709 (setq gnus-newsgroup-prepared t)
3710 (gnus-run-hooks 'gnus-summary-prepared-hook)
3711 (unless (gnus-ephemeral-group-p group)
3712 (gnus-group-update-group group))
3715 (defun gnus-summary-auto-select-subject ()
3716 "Select the subject line on initial group entry."
3717 (goto-char (point-min))
3719 ((eq gnus-auto-select-subject 'best)
3720 (gnus-summary-best-unread-subject))
3721 ((eq gnus-auto-select-subject 'unread)
3722 (gnus-summary-first-unread-subject))
3723 ((eq gnus-auto-select-subject 'unseen)
3724 (gnus-summary-first-unseen-subject))
3725 ((eq gnus-auto-select-subject 'unseen-or-unread)
3726 (gnus-summary-first-unseen-or-unread-subject))
3727 ((eq gnus-auto-select-subject 'first)
3730 ((functionp gnus-auto-select-subject)
3731 (funcall gnus-auto-select-subject))))
3733 (defun gnus-summary-prepare ()
3734 "Generate the summary buffer."
3736 (let ((buffer-read-only nil))
3738 (setq gnus-newsgroup-data nil
3739 gnus-newsgroup-data-reverse nil)
3740 (gnus-run-hooks 'gnus-summary-generate-hook)
3741 ;; Generate the buffer, either with threads or without.
3742 (when gnus-newsgroup-headers
3743 (gnus-summary-prepare-threads
3744 (if gnus-show-threads
3745 (gnus-sort-gathered-threads
3746 (funcall gnus-summary-thread-gathering-function
3748 (gnus-cut-threads (gnus-make-threads)))))
3749 ;; Unthreaded display.
3750 (gnus-sort-articles gnus-newsgroup-headers))))
3751 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3752 ;; Call hooks for modifying summary buffer.
3753 (goto-char (point-min))
3754 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3756 (defsubst gnus-general-simplify-subject (subject)
3757 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3760 ;; Truncate the subject.
3761 (gnus-simplify-subject-functions
3762 (gnus-map-function gnus-simplify-subject-functions subject))
3763 ((numberp gnus-summary-gather-subject-limit)
3764 (setq subject (gnus-simplify-subject-re subject))
3765 (if (> (length subject) gnus-summary-gather-subject-limit)
3766 (substring subject 0 gnus-summary-gather-subject-limit)
3768 ;; Fuzzily simplify it.
3769 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3770 (gnus-simplify-subject-fuzzy subject))
3771 ;; Just remove the leading "Re:".
3773 (gnus-simplify-subject-re subject))))
3775 (if (and gnus-summary-gather-exclude-subject
3776 (string-match gnus-summary-gather-exclude-subject subject))
3777 nil ; This article shouldn't be gathered
3780 (defun gnus-summary-simplify-subject-query ()
3781 "Query where the respool algorithm would put this article."
3783 (gnus-summary-select-article)
3785 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3787 (defun gnus-gather-threads-by-subject (threads)
3788 "Gather threads by looking at Subject headers."
3789 (if (not gnus-summary-make-false-root)
3791 (let ((hashtb (gnus-make-hashtable 1024))
3794 subject hthread whole-subject)
3796 (setq subject (gnus-general-simplify-subject
3797 (setq whole-subject (mail-header-subject
3800 (if (setq hthread (gnus-gethash subject hashtb))
3802 ;; We enter a dummy root into the thread, if we
3803 ;; haven't done that already.
3804 (unless (stringp (caar hthread))
3805 (setcar hthread (list whole-subject (car hthread))))
3806 ;; We add this new gathered thread to this gathered
3808 (setcdr (car hthread)
3809 (nconc (cdar hthread) (list (car threads))))
3810 ;; Remove it from the list of threads.
3811 (setcdr prev (cdr threads))
3812 (setq threads prev))
3813 ;; Enter this thread into the hash table.
3814 (gnus-sethash subject
3815 (if gnus-summary-make-false-root-always
3817 ;; If you want a dummy root above all
3819 (setcar threads (list whole-subject
3825 (setq threads (cdr threads)))
3828 (defun gnus-gather-threads-by-references (threads)
3829 "Gather threads by looking at References headers."
3830 (let ((idhashtb (gnus-make-hashtable 1024))
3831 (thhashtb (gnus-make-hashtable 1024))
3834 ids references id gthread gid entered ref)
3836 (when (setq references (mail-header-references (caar threads)))
3837 (setq id (mail-header-id (caar threads))
3838 ids (inline (gnus-split-references references))
3840 (while (setq ref (pop ids))
3841 (setq ids (delete ref ids))
3842 (if (not (setq gid (gnus-gethash ref idhashtb)))
3844 (gnus-sethash ref id idhashtb)
3845 (gnus-sethash id threads thhashtb))
3846 (setq gthread (gnus-gethash gid thhashtb))
3848 ;; We enter a dummy root into the thread, if we
3849 ;; haven't done that already.
3850 (unless (stringp (caar gthread))
3851 (setcar gthread (list (mail-header-subject (caar gthread))
3853 ;; We add this new gathered thread to this gathered
3855 (setcdr (car gthread)
3856 (nconc (cdar gthread) (list (car threads)))))
3857 ;; Add it into the thread hash table.
3858 (gnus-sethash id gthread thhashtb)
3860 ;; Remove it from the list of threads.
3861 (setcdr prev (cdr threads))
3862 (setq threads prev))))
3864 (setq threads (cdr threads)))
3867 (defun gnus-sort-gathered-threads (threads)
3868 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3869 (let ((result threads))
3871 (when (stringp (caar threads))
3872 (setcdr (car threads)
3873 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3874 (setq threads (cdr threads)))
3877 (defun gnus-thread-loop-p (root thread)
3878 "Say whether ROOT is in THREAD."
3879 (let ((stack (list thread))
3882 (while (setq thread (pop stack))
3883 (setq th (cdr thread))
3885 (not (eq (caar th) root)))
3888 ;; We have found a loop.
3890 (setcdr thread (delq (car th) (cdr thread)))
3891 (if (boundp (setq ref-dep (intern "none"
3892 gnus-newsgroup-dependencies)))
3893 (setcdr (symbol-value ref-dep)
3894 (nconc (cdr (symbol-value ref-dep))
3896 (set ref-dep (list nil (car th))))
3899 ;; Push all the subthreads onto the stack.
3900 (push (cdr thread) stack)))
3903 (defun gnus-make-threads ()
3904 "Go through the dependency hashtb and find the roots. Return all threads."
3906 (while (catch 'infloop
3909 ;; Deal with self-referencing References loops.
3910 (when (and (car (symbol-value refs))
3917 (car (symbol-value refs)) thread))
3918 (cdr (symbol-value refs)))))))
3921 (unless (car (symbol-value refs))
3922 ;; These threads do not refer back to any other articles,
3923 ;; so they're roots.
3924 (setq threads (append (cdr (symbol-value refs)) threads))))
3925 gnus-newsgroup-dependencies)))
3928 ;; Build the thread tree.
3929 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3930 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3932 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3933 if it was already present.
3935 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3936 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3937 Message-IDs will be renamed to a unique Message-ID before being
3940 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3941 (let* ((id (mail-header-id header))
3942 (id-dep (and id (intern id dependencies)))
3943 parent-id ref ref-dep ref-header replaced)
3944 ;; Enter this `header' in the `dependencies' table.
3948 ;; The first two cases do the normal part: enter a new `header'
3949 ;; in the `dependencies' table.
3950 ((not (boundp id-dep))
3951 (set id-dep (list header)))
3952 ((null (car (symbol-value id-dep)))
3953 (setcar (symbol-value id-dep) header))
3955 ;; From here the `header' was already present in the
3956 ;; `dependencies' table.
3958 ;; Overrides an existing entry;
3959 ;; just set the header part of the entry.
3960 (setcar (symbol-value id-dep) header)
3963 ;; Renames the existing `header' to a unique Message-ID.
3964 ((not gnus-summary-ignore-duplicates)
3965 ;; An article with this Message-ID has already been seen.
3966 ;; We rename the Message-ID.
3967 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3969 (mail-header-set-id header id))
3971 ;; The last case ignores an existing entry, except it adds any
3972 ;; additional Xrefs (in case the two articles came from different
3974 ;; Also sets `header' to `nil' meaning that the `dependencies'
3975 ;; table was *not* modified.
3977 (mail-header-set-xref
3978 (car (symbol-value id-dep))
3979 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3981 (or (mail-header-xref header) "")))
3984 (when (and header (not replaced))
3985 ;; First check that we are not creating a References loop.
3986 (setq parent-id (gnus-parent-id (mail-header-references header)))
3987 (setq ref parent-id)
3989 (setq ref-dep (intern-soft ref dependencies))
3991 (setq ref-header (car (symbol-value ref-dep))))
3992 (if (string= id ref)
3993 ;; Yuk! This is a reference loop. Make the article be a
3996 (mail-header-set-references (car (symbol-value id-dep)) "none")
3998 (setq parent-id nil))
3999 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4000 (setq ref-dep (intern (or parent-id "none") dependencies))
4001 (if (boundp ref-dep)
4002 (setcdr (symbol-value ref-dep)
4003 (nconc (cdr (symbol-value ref-dep))
4004 (list (symbol-value id-dep))))
4005 (set ref-dep (list nil (symbol-value id-dep)))))
4008 (defun gnus-extract-message-id-from-in-reply-to (string)
4009 (if (string-match "<[^>]+>" string)
4010 (substring string (match-beginning 0) (match-end 0))
4013 (defun gnus-build-sparse-threads ()
4014 (let ((headers gnus-newsgroup-headers)
4015 (mail-parse-charset gnus-newsgroup-charset)
4016 (gnus-summary-ignore-duplicates t)
4017 header references generation relations
4018 subject child end new-child date)
4019 ;; First we create an alist of generations/relations, where
4020 ;; generations is how much we trust the relation, and the relation
4022 (gnus-message 7 "Making sparse threads...")
4024 (nnheader-set-temp-buffer " *gnus sparse threads*")
4025 (while (setq header (pop headers))
4026 (when (and (setq references (mail-header-references header))
4027 (not (string= references "")))
4029 (setq child (mail-header-id header)
4030 subject (mail-header-subject header)
4031 date (mail-header-date header)
4033 (while (search-backward ">" nil t)
4034 (setq end (1+ (point)))
4035 (when (search-backward "<" nil t)
4036 (setq new-child (buffer-substring (point) end))
4037 (push (list (incf generation)
4038 child (setq child new-child)
4042 (push (list (1+ generation) child nil subject) relations))
4044 (kill-buffer (current-buffer)))
4045 ;; Sort over trustworthiness.
4048 (when (gnus-dependencies-add-header
4049 (make-full-mail-header-from-decoded-header
4050 gnus-reffed-article-number
4051 (nth 3 relation) "" (or (nth 4 relation) "")
4053 (or (nth 2 relation) "") 0 0 "")
4054 gnus-newsgroup-dependencies nil)
4055 (push gnus-reffed-article-number gnus-newsgroup-limit)
4056 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4057 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4058 gnus-newsgroup-reads)
4059 (decf gnus-reffed-article-number)))
4060 (sort relations 'car-less-than-car))
4061 (gnus-message 7 "Making sparse threads...done")))
4063 (defun gnus-build-old-threads ()
4064 ;; Look at all the articles that refer back to old articles, and
4065 ;; fetch the headers for the articles that aren't there. This will
4066 ;; build complete threads - if the roots haven't been expired by the
4068 (let ((mail-parse-charset gnus-newsgroup-charset)
4072 (when (not (car (symbol-value refs)))
4073 (setq heads (cdr (symbol-value refs)))
4075 (if (memq (mail-header-number (caar heads))
4076 gnus-newsgroup-dormant)
4077 (setq heads (cdr heads))
4078 (setq id (symbol-name refs))
4079 (while (and (setq id (gnus-build-get-header id))
4080 (not (car (gnus-id-to-thread id)))))
4081 (setq heads nil)))))
4082 gnus-newsgroup-dependencies)))
4084 (defsubst gnus-remove-odd-characters (string)
4085 "Translate STRING into something that doesn't contain weird characters."
4086 (mm-subst-char-in-string
4088 (mm-subst-char-in-string ?\n ?\- string t) t))
4090 ;; This function has to be called with point after the article number
4091 ;; on the beginning of the line.
4092 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4093 (let ((eol (point-at-eol))
4094 (buffer (current-buffer))
4095 header references in-reply-to)
4097 ;; overview: [num subject from date id refs chars lines misc]
4100 (narrow-to-region (point) eol)
4105 (make-full-mail-header
4107 (nnheader-nov-field) ; subject
4108 (nnheader-nov-field) ; from
4109 (nnheader-nov-field) ; date
4110 (nnheader-nov-read-message-id number) ; id
4111 (setq references (nnheader-nov-field)) ; refs
4112 (nnheader-nov-read-integer) ; chars
4113 (nnheader-nov-read-integer) ; lines
4115 (if (looking-at "Xref: ")
4116 (goto-char (match-end 0)))
4117 (nnheader-nov-field)) ; Xref
4118 (nnheader-nov-parse-extra)))) ; extra
4122 (when (and (string= references "")
4123 (setq in-reply-to (mail-header-extra header))
4124 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4125 (mail-header-set-references
4126 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4128 (when gnus-alter-header-function
4129 (funcall gnus-alter-header-function header))
4130 (gnus-dependencies-add-header header dependencies force-new)))
4132 (defun gnus-build-get-header (id)
4133 "Look through the buffer of NOV lines and find the header to ID.
4134 Enter this line into the dependencies hash table, and return
4135 the id of the parent article (if any)."
4136 (let ((deps gnus-newsgroup-dependencies)
4140 (set-buffer nntp-server-buffer)
4141 (let ((case-fold-search nil))
4142 (goto-char (point-min))
4143 (while (and (not found)
4144 (search-forward id nil t))
4146 (setq found (looking-at
4147 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4148 (regexp-quote id))))
4149 (or found (beginning-of-line 2)))
4153 (setq header (gnus-nov-parse-line
4154 (read (current-buffer)) deps))
4155 (gnus-parent-id (mail-header-references header))))))
4157 (let ((number (mail-header-number header)))
4158 (push number gnus-newsgroup-limit)
4159 (push header gnus-newsgroup-headers)
4160 (if (memq number gnus-newsgroup-unselected)
4162 (setq gnus-newsgroup-unreads
4163 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4165 (setq gnus-newsgroup-unselected
4166 (delq number gnus-newsgroup-unselected)))
4167 (push number gnus-newsgroup-ancient)))))))
4169 (defun gnus-build-all-threads ()
4170 "Read all the headers."
4171 (let ((gnus-summary-ignore-duplicates t)
4172 (mail-parse-charset gnus-newsgroup-charset)
4173 (dependencies gnus-newsgroup-dependencies)
4176 (set-buffer nntp-server-buffer)
4177 (let ((case-fold-search nil))
4178 (goto-char (point-min))
4181 (setq article (read (current-buffer))
4182 header (gnus-nov-parse-line article dependencies)))
4184 (with-current-buffer gnus-summary-buffer
4185 (push header gnus-newsgroup-headers)
4186 (if (memq (setq article (mail-header-number header))
4187 gnus-newsgroup-unselected)
4189 (setq gnus-newsgroup-unreads
4190 (gnus-add-to-sorted-list
4191 gnus-newsgroup-unreads article))
4192 (setq gnus-newsgroup-unselected
4193 (delq article gnus-newsgroup-unselected)))
4194 (push article gnus-newsgroup-ancient)))
4195 (forward-line 1)))))))
4197 (defun gnus-summary-update-article-line (article header)
4198 "Update the line for ARTICLE using HEADER."
4199 (let* ((id (mail-header-id header))
4200 (thread (gnus-id-to-thread id)))
4202 (error "Article in no thread"))
4203 ;; Update the thread.
4204 (setcar thread header)
4205 (gnus-summary-goto-subject article)
4206 (let* ((datal (gnus-data-find-list article))
4208 (buffer-read-only nil)
4209 (level (gnus-summary-thread-level)))
4211 (let ((inserted (- (point)
4213 (gnus-summary-insert-line
4215 (memq article gnus-newsgroup-undownloaded)
4216 (gnus-article-mark article)
4217 (memq article gnus-newsgroup-replied)
4218 (memq article gnus-newsgroup-expirable)
4219 ;; Only insert the Subject string when it's different
4220 ;; from the previous Subject string.
4225 (mail-header-subject
4228 (gnus-data-find-list
4230 (gnus-data-list t)))))
4231 ;; Error on the side of excessive subjects.
4233 (mail-header-subject header)))
4235 (mail-header-subject header))
4236 nil (cdr (assq article gnus-newsgroup-scored))
4237 (memq article gnus-newsgroup-processable))
4240 (gnus-data-update-list
4242 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4244 (defun gnus-summary-update-article (article &optional iheader)
4245 "Update ARTICLE in the summary buffer."
4246 (set-buffer gnus-summary-buffer)
4247 (let* ((header (gnus-summary-article-header article))
4248 (id (mail-header-id header))
4249 (data (gnus-data-find article))
4250 (thread (gnus-id-to-thread id))
4251 (references (mail-header-references header))
4255 (when (and references
4256 (not (equal "" references)))
4259 (buffer-read-only nil)
4265 (delq thread parent)))
4266 (if (gnus-summary-insert-subject id header)
4267 ;; Set the (possibly) new article number in the data structure.
4268 (gnus-data-set-number data (gnus-id-to-article id))
4272 (defun gnus-rebuild-thread (id &optional line)
4273 "Rebuild the thread containing ID.
4274 If LINE, insert the rebuilt thread starting on line LINE."
4275 (let ((buffer-read-only nil)
4276 old-pos current thread data)
4277 (if (not gnus-show-threads)
4278 (setq thread (list (car (gnus-id-to-thread id))))
4279 ;; Get the thread this article is part of.
4280 (setq thread (gnus-remove-thread id)))
4281 (setq old-pos (point-at-bol))
4282 (setq current (save-excursion
4283 (and (re-search-backward "[\r\n]" nil t)
4284 (gnus-summary-article-number))))
4285 ;; If this is a gathered thread, we have to go some re-gathering.
4286 (when (stringp (car thread))
4287 (let ((subject (car thread))
4289 (setq thread (cdr thread))
4291 (unless (memq (setq thr (gnus-id-to-thread
4293 (mail-header-id (caar thread)))))
4296 (setq thread (cdr thread)))
4297 ;; We now have all (unique) roots.
4298 (if (= (length roots) 1)
4299 ;; All the loose roots are now one solid root.
4300 (setq thread (car roots))
4301 (setq thread (cons subject (gnus-sort-threads roots))))))
4303 ;; We then insert this thread into the summary buffer.
4305 (goto-char (point-min))
4306 (forward-line (1- line)))
4307 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4308 (if gnus-show-threads
4309 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4310 (gnus-summary-prepare-unthreaded thread))
4311 (setq data (nreverse gnus-newsgroup-data))
4312 (setq threads gnus-newsgroup-threads))
4313 ;; We splice the new data into the data structure.
4314 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4315 ;;!!! then we want to insert at the beginning of the buffer.
4316 ;;!!! That happens to be true with Gnus now, but that may
4317 ;;!!! change in the future. Perhaps.
4318 (gnus-data-enter-list
4319 (if line nil current) data (- (point) old-pos))
4320 (setq gnus-newsgroup-threads
4321 (nconc threads gnus-newsgroup-threads))
4322 (gnus-data-compute-positions))))
4324 (defun gnus-number-to-header (number)
4325 "Return the header for article NUMBER."
4326 (let ((headers gnus-newsgroup-headers))
4328 (not (= number (mail-header-number (car headers)))))
4333 (defun gnus-parent-headers (in-headers &optional generation)
4334 "Return the headers of the GENERATIONeth parent of HEADERS."
4336 (setq generation 1))
4338 (headers in-headers)
4341 (not (zerop generation))
4342 (setq references (mail-header-references headers)))
4343 (setq headers (if (and references
4344 (setq parent (gnus-parent-id references)))
4345 (car (gnus-id-to-thread parent))
4348 (and (not (eq headers in-headers))
4351 (defun gnus-id-to-thread (id)
4352 "Return the (sub-)thread where ID appears."
4353 (gnus-gethash id gnus-newsgroup-dependencies))
4355 (defun gnus-id-to-article (id)
4356 "Return the article number of ID."
4357 (let ((thread (gnus-id-to-thread id)))
4360 (mail-header-number (car thread)))))
4362 (defun gnus-id-to-header (id)
4363 "Return the article headers of ID."
4364 (car (gnus-id-to-thread id)))
4366 (defun gnus-article-displayed-root-p (article)
4367 "Say whether ARTICLE is a root(ish) article."
4368 (let ((level (gnus-summary-thread-level article))
4369 (refs (mail-header-references (gnus-summary-article-header article)))
4375 ((null (gnus-parent-id refs)) t)
4377 (null (setq particle (gnus-id-to-article
4378 (gnus-parent-id refs))))
4379 (null (gnus-summary-thread-level particle)))))))
4381 (defun gnus-root-id (id)
4382 "Return the id of the root of the thread where ID appears."
4384 (while (and id (setq prev (car (gnus-id-to-thread id))))
4386 id (gnus-parent-id (mail-header-references prev))))
4389 (defun gnus-articles-in-thread (thread)
4390 "Return the list of articles in THREAD."
4391 (cons (mail-header-number (car thread))
4392 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4394 (defun gnus-remove-thread (id &optional dont-remove)
4395 "Remove the thread that has ID in it."
4396 (let (headers thread last-id)
4397 ;; First go up in this thread until we find the root.
4398 (setq last-id (gnus-root-id id)
4399 headers (message-flatten-list (gnus-id-to-thread last-id)))
4400 ;; We have now found the real root of this thread. It might have
4401 ;; been gathered into some loose thread, so we have to search
4402 ;; through the threads to find the thread we wanted.
4403 (let ((threads gnus-newsgroup-threads)
4406 (setq sub (car threads))
4407 (if (stringp (car sub))
4408 ;; This is a gathered thread, so we look at the roots
4409 ;; below it to find whether this article is in this
4412 (setq sub (cdr sub))
4414 (when (member (caar sub) headers)
4415 (setq thread (car threads)
4418 (setq sub (cdr sub))))
4419 ;; It's an ordinary thread, so we check it.
4420 (when (eq (car sub) (car headers))
4423 (setq threads (cdr threads)))
4424 ;; If this article is in no thread, then it's a root.
4427 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4428 (setq thread (gnus-id-to-thread last-id)))
4431 thread ; We return this thread.
4433 (if (stringp (car thread))
4435 ;; If we use dummy roots, then we have to remove the
4436 ;; dummy root as well.
4437 (when (eq gnus-summary-make-false-root 'dummy)
4438 ;; We go to the dummy root by going to
4439 ;; the first sub-"thread", and then one line up.
4440 (gnus-summary-goto-article
4441 (mail-header-number (caadr thread)))
4444 (gnus-data-compute-positions))
4445 (setq thread (cdr thread))
4447 (gnus-remove-thread-1 (car thread))
4448 (setq thread (cdr thread))))
4449 (gnus-remove-thread-1 thread))))))))
4451 (defun gnus-remove-thread-1 (thread)
4452 "Remove the thread THREAD recursively."
4453 (let ((number (mail-header-number (pop thread)))
4455 (setq thread (reverse thread))
4457 (gnus-remove-thread-1 (pop thread)))
4458 (when (setq d (gnus-data-find number))
4459 (goto-char (gnus-data-pos d))
4460 (gnus-summary-show-thread)
4466 (gnus-delete-line)))))))
4468 (defun gnus-sort-threads-1 (threads func)
4469 (sort (mapcar (lambda (thread)
4472 (gnus-sort-threads-1 (cdr thread) func))))
4475 (defun gnus-sort-threads (threads)
4477 (if (not gnus-thread-sort-functions)
4479 (gnus-message 8 "Sorting threads...")
4480 (let ((max-lisp-eval-depth 5000))
4481 (prog1 (gnus-sort-threads-1
4483 (gnus-make-sort-function gnus-thread-sort-functions))
4484 (gnus-message 8 "Sorting threads...done")))))
4486 (defun gnus-sort-articles (articles)
4488 (when gnus-article-sort-functions
4489 (gnus-message 7 "Sorting articles...")
4491 (setq gnus-newsgroup-headers
4492 (sort articles (gnus-make-sort-function
4493 gnus-article-sort-functions)))
4494 (gnus-message 7 "Sorting articles...done"))))
4496 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4497 (defmacro gnus-thread-header (thread)
4498 "Return header of first article in THREAD.
4499 Note that THREAD must never, ever be anything else than a variable -
4500 using some other form will lead to serious barfage."
4501 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4502 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4503 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4506 (defsubst gnus-article-sort-by-number (h1 h2)
4507 "Sort articles by article number."
4508 (< (mail-header-number h1)
4509 (mail-header-number h2)))
4511 (defun gnus-thread-sort-by-number (h1 h2)
4512 "Sort threads by root article number."
4513 (gnus-article-sort-by-number
4514 (gnus-thread-header h1) (gnus-thread-header h2)))
4516 (defsubst gnus-article-sort-by-random (h1 h2)
4517 "Sort articles by article number."
4520 (defun gnus-thread-sort-by-random (h1 h2)
4521 "Sort threads by root article number."
4522 (gnus-article-sort-by-random
4523 (gnus-thread-header h1) (gnus-thread-header h2)))
4525 (defsubst gnus-article-sort-by-lines (h1 h2)
4526 "Sort articles by article Lines header."
4527 (< (mail-header-lines h1)
4528 (mail-header-lines h2)))
4530 (defun gnus-thread-sort-by-lines (h1 h2)
4531 "Sort threads by root article Lines header."
4532 (gnus-article-sort-by-lines
4533 (gnus-thread-header h1) (gnus-thread-header h2)))
4535 (defsubst gnus-article-sort-by-chars (h1 h2)
4536 "Sort articles by octet length."
4537 (< (mail-header-chars h1)
4538 (mail-header-chars h2)))
4540 (defun gnus-thread-sort-by-chars (h1 h2)
4541 "Sort threads by root article octet length."
4542 (gnus-article-sort-by-chars
4543 (gnus-thread-header h1) (gnus-thread-header h2)))
4545 (defsubst gnus-article-sort-by-author (h1 h2)
4546 "Sort articles by root author."
4548 (let ((addr (car (mime-entity-read-field h1 'From))))
4549 (or (std11-full-name-string addr)
4550 (std11-address-string addr)
4552 (let ((addr (car (mime-entity-read-field h2 'From))))
4553 (or (std11-full-name-string addr)
4554 (std11-address-string addr)
4558 (defun gnus-thread-sort-by-author (h1 h2)
4559 "Sort threads by root author."
4560 (gnus-article-sort-by-author
4561 (gnus-thread-header h1) (gnus-thread-header h2)))
4563 (defsubst gnus-article-sort-by-subject (h1 h2)
4564 "Sort articles by root subject."
4566 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4567 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4569 (defun gnus-thread-sort-by-subject (h1 h2)
4570 "Sort threads by root subject."
4571 (gnus-article-sort-by-subject
4572 (gnus-thread-header h1) (gnus-thread-header h2)))
4574 (defsubst gnus-article-sort-by-date (h1 h2)
4575 "Sort articles by root article date."
4577 (gnus-date-get-time (mail-header-date h1))
4578 (gnus-date-get-time (mail-header-date h2))))
4580 (defun gnus-thread-sort-by-date (h1 h2)
4581 "Sort threads by root article date."
4582 (gnus-article-sort-by-date
4583 (gnus-thread-header h1) (gnus-thread-header h2)))
4585 (defsubst gnus-article-sort-by-score (h1 h2)
4586 "Sort articles by root article score.
4587 Unscored articles will be counted as having a score of zero."
4588 (> (or (cdr (assq (mail-header-number h1)
4589 gnus-newsgroup-scored))
4590 gnus-summary-default-score 0)
4591 (or (cdr (assq (mail-header-number h2)
4592 gnus-newsgroup-scored))
4593 gnus-summary-default-score 0)))
4595 (defun gnus-thread-sort-by-score (h1 h2)
4596 "Sort threads by root article score."
4597 (gnus-article-sort-by-score
4598 (gnus-thread-header h1) (gnus-thread-header h2)))
4600 (defun gnus-thread-sort-by-total-score (h1 h2)
4601 "Sort threads by the sum of all scores in the thread.
4602 Unscored articles will be counted as having a score of zero."
4603 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4605 (defun gnus-thread-total-score (thread)
4606 ;; This function find the total score of THREAD.
4611 (if (stringp (car thread))
4612 (apply gnus-thread-score-function 0
4613 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4614 (gnus-thread-total-score-1 thread)))
4616 (gnus-thread-total-score-1 (list thread)))))
4618 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4619 "Sort threads such that the thread with the most recently arrived article comes first."
4620 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4622 (defun gnus-thread-highest-number (thread)
4623 "Return the highest article number in THREAD."
4624 (apply 'max (mapcar (lambda (header)
4625 (mail-header-number header))
4626 (message-flatten-list thread))))
4628 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4629 "Sort threads such that the thread with the most recently dated article comes first."
4630 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4632 (defun gnus-thread-latest-date (thread)
4633 "Return the highest article date in THREAD."
4634 (let ((previous-time 0))
4640 (time-to-seconds (mail-header-parse-date
4641 (mail-header-date header)))
4642 (error previous-time))))
4644 (message-flatten-list thread)
4646 (< (mail-header-number h1)
4647 (mail-header-number h2))))))))
4649 (defun gnus-thread-total-score-1 (root)
4650 ;; This function find the total score of the thread below ROOT.
4651 (setq root (car root))
4652 (apply gnus-thread-score-function
4654 (mapcar 'gnus-thread-total-score
4655 (cdr (gnus-id-to-thread (mail-header-id root))))
4656 (when (> (mail-header-number root) 0)
4657 (list (or (cdr (assq (mail-header-number root)
4658 gnus-newsgroup-scored))
4659 gnus-summary-default-score 0))))
4660 (list gnus-summary-default-score)
4663 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4664 (defvar gnus-tmp-prev-subject nil)
4665 (defvar gnus-tmp-false-parent nil)
4666 (defvar gnus-tmp-root-expunged nil)
4667 (defvar gnus-tmp-dummy-line nil)
4669 (eval-when-compile (defvar gnus-tmp-header))
4670 (defun gnus-extra-header (type &optional header)
4671 "Return the extra header of TYPE."
4672 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4675 (defvar gnus-tmp-thread-tree-header-string "")
4677 (defcustom gnus-sum-thread-tree-root "> "
4678 "With %B spec, used for the root of a thread.
4679 If nil, use subject instead."
4681 :type '(radio (const :format "%v " nil) (string :size 0))
4682 :group 'gnus-thread)
4683 (defcustom gnus-sum-thread-tree-false-root "> "
4684 "With %B spec, used for a false root of a thread.
4685 If nil, use subject instead."
4687 :type '(radio (const :format "%v " nil) (string :size 0))
4688 :group 'gnus-thread)
4689 (defcustom gnus-sum-thread-tree-single-indent ""
4690 "With %B spec, used for a thread with just one message.
4691 If nil, use subject instead."
4693 :type '(radio (const :format "%v " nil) (string :size 0))
4694 :group 'gnus-thread)
4695 (defcustom gnus-sum-thread-tree-vertical "| "
4696 "With %B spec, used for drawing a vertical line."
4699 :group 'gnus-thread)
4700 (defcustom gnus-sum-thread-tree-indent " "
4701 "With %B spec, used for indenting."
4704 :group 'gnus-thread)
4705 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4706 "With %B spec, used for a leaf with brothers."
4709 :group 'gnus-thread)
4710 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4711 "With %B spec, used for a leaf without brothers."
4714 :group 'gnus-thread)
4716 (defun gnus-summary-prepare-threads (threads)
4717 "Prepare summary buffer from THREADS and indentation LEVEL.
4718 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4719 or a straight list of headers."
4720 (gnus-message 7 "Generating summary...")
4722 (setq gnus-newsgroup-threads threads)
4725 (let ((gnus-tmp-level 0)
4726 (default-score (or gnus-summary-default-score 0))
4727 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4728 (building-line-count gnus-summary-display-while-building)
4729 (building-count (integerp gnus-summary-display-while-building))
4730 thread number subject stack state gnus-tmp-gathered beg-match
4731 new-roots gnus-tmp-new-adopts thread-end simp-subject
4732 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4733 gnus-tmp-replied gnus-tmp-subject-or-nil
4734 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4735 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4736 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4739 (setq gnus-tmp-prev-subject nil
4740 gnus-tmp-thread-tree-header-string "")
4742 (if (vectorp (car threads))
4743 ;; If this is a straight (sic) list of headers, then a
4744 ;; threaded summary display isn't required, so we just create
4745 ;; an unthreaded one.
4746 (gnus-summary-prepare-unthreaded threads)
4748 ;; Do the threaded display.
4750 (if gnus-summary-display-while-building
4751 (switch-to-buffer (buffer-name)))
4752 (while (or threads stack gnus-tmp-new-adopts new-roots)
4754 (if (and (= gnus-tmp-level 0)
4757 (not gnus-tmp-false-parent)
4758 (or gnus-tmp-new-adopts new-roots))
4759 (if gnus-tmp-new-adopts
4760 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4761 thread (list (car gnus-tmp-new-adopts))
4762 gnus-tmp-header (caar thread)
4763 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4765 (setq thread (list (car new-roots))
4766 gnus-tmp-header (caar thread)
4767 new-roots (cdr new-roots))))
4770 ;; If there are some threads, we do them before the
4771 ;; threads on the stack.
4772 (setq thread threads
4773 gnus-tmp-header (caar thread))
4774 ;; There were no current threads, so we pop something off
4776 (setq state (car stack)
4777 gnus-tmp-level (car state)
4778 tree-stack (cadr state)
4779 thread (caddr state)
4781 gnus-tmp-header (caar thread))))
4783 (setq gnus-tmp-false-parent nil)
4784 (setq gnus-tmp-root-expunged nil)
4785 (setq thread-end nil)
4787 (if (stringp gnus-tmp-header)
4788 ;; The header is a dummy root.
4790 ((eq gnus-summary-make-false-root 'adopt)
4791 ;; We let the first article adopt the rest.
4792 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4794 (setq gnus-tmp-gathered
4796 (lambda (h) (mail-header-number (car h)))
4799 (setq thread (cons (list (caar thread)
4802 (setq gnus-tmp-level -1
4803 gnus-tmp-false-parent t))
4804 ((eq gnus-summary-make-false-root 'empty)
4805 ;; We print adopted articles with empty subject fields.
4806 (setq gnus-tmp-gathered
4808 (lambda (h) (mail-header-number (car h)))
4811 (setq gnus-tmp-level -1))
4812 ((eq gnus-summary-make-false-root 'dummy)
4813 ;; We remember that we probably want to output a dummy
4815 (setq gnus-tmp-dummy-line gnus-tmp-header)
4816 (setq gnus-tmp-prev-subject gnus-tmp-header))
4818 ;; We do not make a root for the gathered
4819 ;; sub-threads at all.
4820 (setq gnus-tmp-level -1)))
4822 (setq number (mail-header-number gnus-tmp-header)
4823 subject (mail-header-subject gnus-tmp-header)
4824 simp-subject (gnus-simplify-subject-fully subject))
4827 ;; If the thread has changed subject, we might want to make
4828 ;; this subthread into a root.
4829 ((and (null gnus-thread-ignore-subject)
4830 (not (zerop gnus-tmp-level))
4831 gnus-tmp-prev-subject
4832 (not (string= gnus-tmp-prev-subject simp-subject)))
4833 (setq new-roots (nconc new-roots (list (car thread)))
4835 gnus-tmp-header nil))
4836 ;; If the article lies outside the current limit,
4837 ;; then we do not display it.
4838 ((not (memq number gnus-newsgroup-limit))
4839 (setq gnus-tmp-gathered
4841 (lambda (h) (mail-header-number (car h)))
4844 (setq gnus-tmp-new-adopts (if (cdar thread)
4845 (append gnus-tmp-new-adopts
4847 gnus-tmp-new-adopts)
4849 gnus-tmp-header nil)
4850 (when (zerop gnus-tmp-level)
4851 (setq gnus-tmp-root-expunged t)))
4852 ;; Perhaps this article is to be marked as read?
4853 ((and gnus-summary-mark-below
4854 (< (or (cdr (assq number gnus-newsgroup-scored))
4856 gnus-summary-mark-below)
4857 ;; Don't touch sparse articles.
4858 (not (gnus-summary-article-sparse-p number))
4859 (not (gnus-summary-article-ancient-p number)))
4860 (setq gnus-newsgroup-unreads
4861 (delq number gnus-newsgroup-unreads))
4862 (if gnus-newsgroup-auto-expire
4863 (setq gnus-newsgroup-expirable
4864 (gnus-add-to-sorted-list
4865 gnus-newsgroup-expirable number))
4866 (push (cons number gnus-low-score-mark)
4867 gnus-newsgroup-reads))))
4869 (when gnus-tmp-header
4870 ;; We may have an old dummy line to output before this
4872 (when (and gnus-tmp-dummy-line
4875 (mail-header-subject gnus-tmp-header)))
4876 (gnus-summary-insert-dummy-line
4877 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4878 (setq gnus-tmp-dummy-line nil))
4880 ;; Compute the mark.
4881 (setq gnus-tmp-unread (gnus-article-mark number))
4883 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4884 gnus-tmp-header gnus-tmp-level)
4885 gnus-newsgroup-data)
4887 ;; Actually insert the line.
4889 gnus-tmp-subject-or-nil
4891 ((and gnus-thread-ignore-subject
4892 gnus-tmp-prev-subject
4893 (not (string= gnus-tmp-prev-subject simp-subject)))
4895 ((zerop gnus-tmp-level)
4896 (if (and (eq gnus-summary-make-false-root 'empty)
4897 (memq number gnus-tmp-gathered)
4898 gnus-tmp-prev-subject
4899 (string= gnus-tmp-prev-subject simp-subject))
4900 gnus-summary-same-subject
4902 (t gnus-summary-same-subject)))
4903 (if (and (eq gnus-summary-make-false-root 'adopt)
4904 (= gnus-tmp-level 1)
4905 (memq number gnus-tmp-gathered))
4906 (setq gnus-tmp-opening-bracket ?\<
4907 gnus-tmp-closing-bracket ?\>)
4908 (setq gnus-tmp-opening-bracket ?\[
4909 gnus-tmp-closing-bracket ?\]))
4911 gnus-tmp-indentation
4912 (aref gnus-thread-indent-array gnus-tmp-level)
4913 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4914 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4915 gnus-summary-default-score 0)
4917 (if (or (null gnus-summary-default-score)
4918 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4919 gnus-summary-zcore-fuzz))
4921 (if (< gnus-tmp-score gnus-summary-default-score)
4922 gnus-score-below-mark gnus-score-over-mark))
4924 (cond ((memq number gnus-newsgroup-processable)
4926 ((memq number gnus-newsgroup-cached)
4928 ((memq number gnus-newsgroup-replied)
4930 ((memq number gnus-newsgroup-forwarded)
4931 gnus-forwarded-mark)
4932 ((memq number gnus-newsgroup-saved)
4934 ((memq number gnus-newsgroup-recent)
4936 ((memq number gnus-newsgroup-unseen)
4940 (cond ((memq number gnus-newsgroup-undownloaded)
4941 gnus-undownloaded-mark)
4942 (gnus-newsgroup-agentized
4943 gnus-downloaded-mark)
4946 gnus-tmp-from (mail-header-from gnus-tmp-header)
4949 ((string-match "<[^>]+> *$" gnus-tmp-from)
4950 (setq beg-match (match-beginning 0))
4951 (or (and (string-match "^\".+\"" gnus-tmp-from)
4952 (substring gnus-tmp-from 1 (1- (match-end 0))))
4953 (substring gnus-tmp-from 0 beg-match)))
4954 ((string-match "(.+)" gnus-tmp-from)
4955 (substring gnus-tmp-from
4956 (1+ (match-beginning 0)) (1- (match-end 0))))
4960 gnus-tmp-thread-tree-header-string
4962 ((not gnus-show-threads) "")
4963 ((zerop gnus-tmp-level)
4964 (cond ((cdar thread)
4965 (or gnus-sum-thread-tree-root subject))
4966 (gnus-tmp-new-adopts
4967 (or gnus-sum-thread-tree-false-root subject))
4969 (or gnus-sum-thread-tree-single-indent subject))))
4971 (concat (apply 'concat
4972 (mapcar (lambda (item)
4974 gnus-sum-thread-tree-vertical
4975 gnus-sum-thread-tree-indent))
4976 (cdr (reverse tree-stack))))
4978 gnus-sum-thread-tree-leaf-with-other
4979 gnus-sum-thread-tree-single-leaf)))))
4980 (when (string= gnus-tmp-name "")
4981 (setq gnus-tmp-name gnus-tmp-from))
4982 (unless (numberp gnus-tmp-lines)
4983 (setq gnus-tmp-lines -1))
4984 (if (= gnus-tmp-lines -1)
4985 (setq gnus-tmp-lines "?")
4986 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4987 (gnus-put-text-property
4989 (progn (eval gnus-summary-line-format-spec) (point))
4990 'gnus-number number)
4993 (gnus-run-hooks 'gnus-summary-update-hook)
4996 (setq gnus-tmp-prev-subject simp-subject)))
4998 (when (nth 1 thread)
4999 (push (list (max 0 gnus-tmp-level)
5000 (copy-sequence tree-stack)
5003 (push (if (nth 1 thread) 1 0) tree-stack)
5004 (incf gnus-tmp-level)
5005 (setq threads (if thread-end nil (cdar thread)))
5006 (if gnus-summary-display-while-building
5009 ;; use a set frequency
5010 (setq building-line-count (1- building-line-count))
5011 (when (= building-line-count 0)
5013 (setq building-line-count
5014 gnus-summary-display-while-building)))
5018 (setq gnus-tmp-level 0)))))
5019 (gnus-message 7 "Generating summary...done"))
5021 (defun gnus-summary-prepare-unthreaded (headers)
5022 "Generate an unthreaded summary buffer based on HEADERS."
5023 (let (header number mark)
5028 ;; We may have to root out some bad articles...
5029 (when (memq (setq number (mail-header-number
5030 (setq header (pop headers))))
5031 gnus-newsgroup-limit)
5032 ;; Mark article as read when it has a low score.
5033 (when (and gnus-summary-mark-below
5034 (< (or (cdr (assq number gnus-newsgroup-scored))
5035 gnus-summary-default-score 0)
5036 gnus-summary-mark-below)
5037 (not (gnus-summary-article-ancient-p number)))
5038 (setq gnus-newsgroup-unreads
5039 (delq number gnus-newsgroup-unreads))
5040 (if gnus-newsgroup-auto-expire
5041 (push number gnus-newsgroup-expirable)
5042 (push (cons number gnus-low-score-mark)
5043 gnus-newsgroup-reads)))
5045 (setq mark (gnus-article-mark number))
5046 (push (gnus-data-make number mark (1+ (point)) header 0)
5047 gnus-newsgroup-data)
5048 (gnus-summary-insert-line
5050 (memq number gnus-newsgroup-undownloaded)
5051 mark (memq number gnus-newsgroup-replied)
5052 (memq number gnus-newsgroup-expirable)
5053 (mail-header-subject header) nil
5054 (cdr (assq number gnus-newsgroup-scored))
5055 (memq number gnus-newsgroup-processable))))))
5057 (defun gnus-summary-remove-list-identifiers ()
5058 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5059 (let ((regexp (if (consp gnus-list-identifiers)
5060 (mapconcat 'identity gnus-list-identifiers " *\\|")
5061 gnus-list-identifiers))
5064 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5065 (dolist (header gnus-newsgroup-headers)
5066 (setq subject (mail-header-subject header)
5068 (while (string-match regexp subject)
5070 (concat (substring subject 0 (match-beginning 1))
5071 (substring subject (match-end 0)))
5074 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5076 (concat (substring subject 0 (match-beginning 1))
5077 (substring subject (match-end 1)))))
5078 (mail-header-set-subject header subject))))))
5080 (defun gnus-fetch-headers (articles)
5081 "Fetch headers of ARTICLES."
5082 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5083 (gnus-message 5 "Fetching headers for %s..." name)
5086 (setq gnus-headers-retrieved-by
5087 (gnus-retrieve-headers
5088 articles gnus-newsgroup-name
5089 ;; We might want to fetch old headers, but
5090 ;; not if there is only 1 article.
5092 (not (eq gnus-fetch-old-headers 'some))
5093 (not (numberp gnus-fetch-old-headers)))
5094 (> (length articles) 1))
5095 gnus-fetch-old-headers))))
5096 (gnus-get-newsgroup-headers-xover
5097 articles nil nil gnus-newsgroup-name t)
5098 (gnus-get-newsgroup-headers))
5099 (gnus-message 5 "Fetching headers for %s...done" name))))
5101 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5102 "Select newsgroup GROUP.
5103 If READ-ALL is non-nil, all articles in the group are selected.
5104 If SELECT-ARTICLES, only select those articles from GROUP."
5105 (let* ((entry (gnus-group-entry group))
5106 ;;!!! Dirty hack; should be removed.
5107 (gnus-summary-ignore-duplicates
5108 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5110 gnus-summary-ignore-duplicates))
5111 (info (nth 2 entry))
5112 articles fetched-articles cached)
5114 (unless (gnus-check-server
5115 (set (make-local-variable 'gnus-current-select-method)
5116 (gnus-find-method-for-group group)))
5117 (error "Couldn't open server"))
5119 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5120 (gnus-activate-group group) ; Or we can activate it...
5121 (progn ; Or we bug out.
5122 (when (equal major-mode 'gnus-summary-mode)
5123 (gnus-kill-buffer (current-buffer)))
5124 (error "Couldn't activate group %s: %s"
5125 group (gnus-status-message group))))
5127 (unless (gnus-request-group group t)
5128 (when (equal major-mode 'gnus-summary-mode)
5129 (gnus-kill-buffer (current-buffer)))
5130 (error "Couldn't request group %s: %s"
5131 group (gnus-status-message group)))
5134 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5136 (setq gnus-summary-use-undownloaded-faces
5137 (gnus-agent-find-parameter
5139 'agent-enable-undownloaded-faces)))
5141 (setq gnus-newsgroup-name group
5142 gnus-newsgroup-unselected nil
5143 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5145 (let ((display (gnus-group-find-parameter group 'display)))
5146 (setq gnus-newsgroup-display
5148 ((not (zerop (or (car-safe read-all) 0)))
5149 ;; The user entered the group with C-u SPC/RET, let's show
5155 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5157 ;; The following is probably the "correct" solution, but
5158 ;; it makes Gnus fetch all headers and then limit the
5159 ;; articles (which is slow), so instead we hack the
5160 ;; select-articles parameter instead. -- Simon Josefsson
5163 ;; (gnus-byte-compile
5164 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5166 (setq select-articles
5167 (gnus-uncompress-range
5168 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5172 (cdr (gnus-active group)))))
5177 (gnus-summary-setup-default-charset)
5179 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5180 (when (gnus-virtual-group-p group)
5181 (setq cached gnus-newsgroup-cached))
5183 (setq gnus-newsgroup-unreads
5184 (gnus-sorted-ndifference
5185 (gnus-sorted-ndifference gnus-newsgroup-unreads
5186 gnus-newsgroup-marked)
5187 gnus-newsgroup-dormant))
5189 (setq gnus-newsgroup-processable nil)
5191 (gnus-update-read-articles group gnus-newsgroup-unreads)
5193 ;; Adjust and set lists of article marks.
5195 (gnus-adjust-marked-articles info))
5196 (if (setq articles select-articles)
5197 (setq gnus-newsgroup-unselected
5198 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5199 (setq articles (gnus-articles-to-read group read-all)))
5203 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5205 ((eq articles 0) nil)
5207 ;; Init the dependencies hash table.
5208 (setq gnus-newsgroup-dependencies
5209 (gnus-make-hashtable (length articles)))
5210 (gnus-set-global-variables)
5211 ;; Retrieve the headers and read them in.
5213 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5215 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5217 (setq gnus-newsgroup-cached cached))
5219 ;; Suppress duplicates?
5220 (when gnus-suppress-duplicates
5221 (gnus-dup-suppress-articles))
5223 ;; Set the initial limit.
5224 (setq gnus-newsgroup-limit (copy-sequence articles))
5225 ;; Remove canceled articles from the list of unread articles.
5226 (setq fetched-articles
5227 (mapcar (lambda (headers) (mail-header-number headers))
5228 gnus-newsgroup-headers))
5229 (setq gnus-newsgroup-articles fetched-articles)
5230 (setq gnus-newsgroup-unreads
5231 (gnus-sorted-nintersection
5232 gnus-newsgroup-unreads fetched-articles))
5233 (gnus-compute-unseen-list)
5235 ;; Removed marked articles that do not exist.
5236 (gnus-update-missing-marks
5237 (gnus-sorted-difference articles fetched-articles))
5238 ;; We might want to build some more threads first.
5239 (when (and gnus-fetch-old-headers
5240 (eq gnus-headers-retrieved-by 'nov))
5241 (if (eq gnus-fetch-old-headers 'invisible)
5242 (gnus-build-all-threads)
5243 (gnus-build-old-threads)))
5244 ;; Let the Gnus agent mark articles as read.
5246 (gnus-agent-get-undownloaded-list))
5247 ;; Remove list identifiers from subject
5248 (when gnus-list-identifiers
5249 (gnus-summary-remove-list-identifiers))
5250 ;; Check whether auto-expire is to be done in this group.
5251 (setq gnus-newsgroup-auto-expire
5252 (gnus-group-auto-expirable-p group))
5253 ;; Set up the article buffer now, if necessary.
5254 (unless gnus-single-article-buffer
5255 (gnus-article-setup-buffer))
5256 ;; First and last article in this newsgroup.
5257 (when gnus-newsgroup-headers
5258 (setq gnus-newsgroup-begin
5259 (mail-header-number (car gnus-newsgroup-headers))
5262 (gnus-last-element gnus-newsgroup-headers))))
5263 ;; GROUP is successfully selected.
5264 (or gnus-newsgroup-headers t)))))
5266 (defun gnus-compute-unseen-list ()
5267 ;; The `seen' marks are treated specially.
5268 (if (not gnus-newsgroup-seen)
5269 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5270 (setq gnus-newsgroup-unseen
5271 (gnus-inverse-list-range-intersection
5272 gnus-newsgroup-articles gnus-newsgroup-seen))))
5274 (defun gnus-summary-display-make-predicate (display)
5275 (require 'gnus-agent)
5276 (when (= (length display) 1)
5277 (setq display (car display)))
5278 (unless gnus-summary-display-cache
5279 (dolist (elem (append '((unread . unread)
5282 gnus-article-mark-lists))
5283 (push (cons (cdr elem)
5285 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5286 gnus-summary-display-cache)))
5287 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5288 (gnus-category-predicate-cache gnus-summary-display-cache))
5289 (gnus-get-predicate display)))
5291 ;; Uses the dynamically bound `number' variable.
5294 (defun gnus-article-marked-p (type &optional article)
5295 (let ((article (or article number)))
5298 (memq article gnus-newsgroup-marked))
5300 (memq article gnus-newsgroup-spam-marked))
5302 (memq article gnus-newsgroup-unsendable))
5303 ((eq type 'undownload)
5304 (memq article gnus-newsgroup-undownloaded))
5305 ((eq type 'download)
5306 (memq article gnus-newsgroup-downloadable))
5308 (memq article gnus-newsgroup-unreads))
5310 (memq article gnus-newsgroup-reads))
5312 (memq article gnus-newsgroup-dormant) )
5314 (memq article gnus-newsgroup-expirable))
5316 (memq article gnus-newsgroup-replied))
5318 (memq article gnus-newsgroup-killed))
5319 ((eq type 'bookmark)
5320 (assq article gnus-newsgroup-bookmarks))
5322 (assq article gnus-newsgroup-scored))
5324 (memq article gnus-newsgroup-saved))
5326 (memq article gnus-newsgroup-cached))
5328 (memq article gnus-newsgroup-forwarded))
5330 (not (memq article gnus-newsgroup-unseen)))
5332 (memq article gnus-newsgroup-recent))
5335 (defun gnus-articles-to-read (group &optional read-all)
5336 "Find out what articles the user wants to read."
5338 ;; Select all articles if `read-all' is non-nil, or if there
5339 ;; are no unread articles.
5341 (and (zerop (length gnus-newsgroup-marked))
5342 (zerop (length gnus-newsgroup-unreads)))
5343 ;; Fetch all if the predicate is non-nil.
5344 gnus-newsgroup-display)
5345 ;; We want to select the headers for all the articles in
5346 ;; the group, so we select either all the active
5347 ;; articles in the group, or (if that's nil), the
5348 ;; articles in the cache.
5350 (gnus-uncompress-range (gnus-active group))
5351 (gnus-cache-articles-in-group group))
5352 ;; Select only the "normal" subset of articles.
5354 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5355 gnus-newsgroup-unreads)))
5356 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5357 (scored (length scored-list))
5358 (number (length articles))
5359 (marked (+ (length gnus-newsgroup-marked)
5360 (length gnus-newsgroup-dormant)))
5365 ((numberp gnus-newsgroup-display)
5366 gnus-newsgroup-display)
5370 ((and (or (<= scored marked) (= scored number))
5371 (numberp gnus-large-newsgroup)
5372 (> number gnus-large-newsgroup))
5373 (let* ((cursor-in-echo-area nil)
5374 (initial (gnus-parameter-large-newsgroup-initial
5375 gnus-newsgroup-name))
5379 "How many articles from %s (%s %d): "
5381 (gnus-group-decoded-name gnus-newsgroup-name)
5383 (if initial "max" "default")
5386 (cons (number-to-string initial)
5388 (if (string-match "^[ \t]*$" input) number input)))
5389 ((and (> scored marked) (< scored number)
5390 (> (- scored number) 20))
5393 (format "%s %s (%d scored, %d total): "
5394 "How many articles from"
5395 (gnus-group-decoded-name group)
5397 (if (string-match "^[ \t]*$" input)
5401 (message "Quit getting the articles to read")
5403 (setq select (if (stringp select) (string-to-number select) select))
5404 (if (or (null select) (zerop select))
5406 (if (and (not (zerop scored)) (<= (abs select) scored))
5408 (setq articles (sort scored-list '<))
5409 (setq number (length articles)))
5410 (setq articles (copy-sequence articles)))
5412 (when (< (abs select) number)
5414 ;; Select the N oldest articles.
5415 (setcdr (nthcdr (1- (abs select)) articles) nil)
5416 ;; Select the N most recent articles.
5417 (setq articles (nthcdr (- number select) articles))))
5418 (setq gnus-newsgroup-unselected
5419 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5420 (when gnus-alter-articles-to-read-function
5423 (funcall gnus-alter-articles-to-read-function
5424 gnus-newsgroup-name articles)
5428 (defun gnus-killed-articles (killed articles)
5431 (when (inline (gnus-member-of-range (car articles) killed))
5432 (push (car articles) out))
5433 (setq articles (cdr articles)))
5436 (defun gnus-uncompress-marks (marks)
5437 "Uncompress the mark ranges in MARKS."
5438 (let ((uncompressed '(score bookmark))
5441 (if (memq (caar marks) uncompressed)
5442 (push (car marks) out)
5443 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5444 (setq marks (cdr marks)))
5447 (defun gnus-article-mark-to-type (mark)
5448 "Return the type of MARK."
5449 (or (cadr (assq mark gnus-article-special-mark-lists))
5452 (defun gnus-article-unpropagatable-p (mark)
5453 "Return whether MARK should be propagated to back end."
5454 (memq mark gnus-article-unpropagated-mark-lists))
5456 (defun gnus-adjust-marked-articles (info)
5457 "Set all article lists and remove all marks that are no longer valid."
5458 (let* ((marked-lists (gnus-info-marks info))
5459 (active (gnus-active (gnus-info-group info)))
5462 (types gnus-article-mark-lists)
5463 marks var articles article mark mark-type
5466 (dolist (marks marked-lists)
5467 (setq mark (car marks)
5468 mark-type (gnus-article-mark-to-type mark)
5469 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5471 ;; We set the variable according to the type of the marks list,
5472 ;; and then adjust the marks to a subset of the active articles.
5474 ;; Adjust "simple" lists - compressed yet unsorted
5475 ((eq mark-type 'list)
5476 ;; Simultaneously uncompress and clip to active range
5477 ;; See gnus-uncompress-range for a description of possible marks
5479 (if (not (cadr marks))
5481 (setq articles (if (numberp (cddr marks))
5487 (while (setq article (pop articles))
5488 (cond ((consp article)
5489 (setq bgn (max (car article) min)
5490 end (min (cdr article) max))
5492 (setq l (setcdr l (cons bgn nil))
5494 ((and (<= min article)
5496 (setq l (setcdr l (cons article nil))))))
5497 (set var (cdr lh)))))
5499 ((eq mark-type 'tuple)
5500 (set var (setq articles (cdr marks)))
5501 (when (not (listp (cdr (symbol-value var))))
5502 (set var (list (symbol-value var))))
5503 (when (not (listp (cdr articles)))
5504 (setq articles (list articles)))
5506 (when (or (not (consp (setq article (pop articles))))
5507 (< (car article) min)
5508 (> (car article) max))
5509 (set var (delq article (symbol-value var))))))
5510 ;; Adjust ranges (sloppily).
5511 ((eq mark-type 'range)
5514 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5515 ;; It should be (seen (NUM1 . NUM2)).
5516 (when (numberp (cddr marks))
5517 (setcdr marks (list (cdr marks))))
5518 (setq articles (cdr marks))
5519 (while (and articles
5520 (or (and (consp (car articles))
5521 (> min (cdar articles)))
5522 (and (numberp (car articles))
5523 (> min (car articles)))))
5525 (set var articles))))))))
5527 (defun gnus-update-missing-marks (missing)
5528 "Go through the list of MISSING articles and remove them from the mark lists."
5531 ;; Go through all types.
5532 (dolist (elem gnus-article-mark-lists)
5533 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5534 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5535 (when (symbol-value var)
5536 ;; This list has articles. So we delete all missing
5537 ;; articles from it.
5540 (set var (delq (pop m) (symbol-value var))))))))))
5542 (defun gnus-update-marks ()
5543 "Enter the various lists of marked articles into the newsgroup info list."
5544 (let ((types gnus-article-mark-lists)
5545 (info (gnus-get-info gnus-newsgroup-name))
5546 type list newmarked symbol delta-marks)
5548 ;; Add all marks lists to the list of marks lists.
5549 (while (setq type (pop types))
5550 (setq list (symbol-value
5552 (intern (format "gnus-newsgroup-%s" (car type))))))
5555 ;; Get rid of the entries of the articles that have the
5557 (when (and (eq (cdr type) 'score)
5561 (prev (cons nil list))
5564 (if (or (not (consp (car arts)))
5565 (= (cdar arts) gnus-summary-default-score))
5566 (setcdr prev (cdr arts))
5568 (setq arts (cdr arts)))
5569 (setq list (cdr all)))))
5571 (when (eq (cdr type) 'seen)
5572 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5574 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5575 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5577 (when (and (gnus-check-backend-function
5578 'request-set-mark gnus-newsgroup-name)
5579 (not (gnus-article-unpropagatable-p (cdr type))))
5580 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5581 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5582 (add (gnus-remove-from-range
5583 (gnus-copy-sequence list) old)))
5585 (push (list add 'add (list (cdr type))) delta-marks))
5587 (push (list del 'del (list (cdr type))) delta-marks))))
5590 (push (cons (cdr type) list) newmarked)))
5593 (unless (gnus-check-group gnus-newsgroup-name)
5594 (error "Can't open server for %s" gnus-newsgroup-name))
5595 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5597 ;; Enter these new marks into the info of the group.
5599 (setcar (nthcdr 3 info) newmarked)
5600 ;; Add the marks lists to the end of the info.
5602 (setcdr (nthcdr 2 info) (list newmarked))))
5604 ;; Cut off the end of the info if there's nothing else there.
5608 (when (nthcdr (decf i) info)
5609 (setcdr (nthcdr i info) nil)))))))
5611 (defun gnus-set-mode-line (where)
5612 "Set the mode line of the article or summary buffers.
5613 If WHERE is `summary', the summary mode line format will be used."
5614 ;; Is this mode line one we keep updated?
5615 (when (and (memq where gnus-updated-mode-lines)
5617 (intern (format "gnus-%s-mode-line-format-spec" where))))
5620 ;; We evaluate this in the summary buffer since these
5621 ;; variables are buffer-local to that buffer.
5622 (set-buffer gnus-summary-buffer)
5623 ;; We bind all these variables that are used in the `eval' form
5625 (let* ((mformat (symbol-value
5627 (format "gnus-%s-mode-line-format-spec" where))))
5628 (gnus-tmp-group-name (gnus-group-decoded-name
5629 gnus-newsgroup-name))
5630 (gnus-tmp-article-number (or gnus-current-article 0))
5631 (gnus-tmp-unread gnus-newsgroup-unreads)
5632 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5633 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5634 (gnus-tmp-unread-and-unselected
5635 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5636 (zerop gnus-tmp-unselected))
5638 ((zerop gnus-tmp-unselected)
5639 (format "{%d more}" gnus-tmp-unread-and-unticked))
5640 (t (format "{%d(+%d) more}"
5641 gnus-tmp-unread-and-unticked
5642 gnus-tmp-unselected))))
5644 (if (and gnus-current-headers
5645 (vectorp gnus-current-headers))
5646 (gnus-mode-string-quote
5647 (mail-header-subject gnus-current-headers))
5649 bufname-length max-len
5650 gnus-tmp-header);; passed as argument to any user-format-funcs
5651 (setq mode-string (eval mformat))
5652 (setq bufname-length (if (string-match "%b" mode-string)
5655 (if (eq where 'summary)
5657 (get-buffer gnus-article-buffer))))
5660 (setq max-len (max 4 (if gnus-mode-non-string-length
5662 gnus-mode-non-string-length
5664 (length mode-string))))
5665 ;; We might have to chop a bit of the string off...
5666 (when (> (length mode-string) max-len)
5668 (concat (gnus-truncate-string mode-string (- max-len 3))
5670 ;; Pad the mode string a bit.
5671 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5672 ;; Update the mode line.
5673 (setq mode-line-buffer-identification
5674 (gnus-mode-line-buffer-identification (list mode-string)))
5675 (set-buffer-modified-p t))))
5677 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5678 "Go through the HEADERS list and add all Xrefs to a hash table.
5679 The resulting hash table is returned, or nil if no Xrefs were found."
5680 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5681 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5682 (xref-hashtb (gnus-make-hashtable))
5683 start group entry number xrefs header)
5685 (setq header (pop headers))
5686 (when (and (setq xrefs (mail-header-xref header))
5687 (not (memq (setq number (mail-header-number header))
5690 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5691 (setq start (match-end 0))
5692 (setq group (if prefix
5693 (concat prefix (substring xrefs (match-beginning 1)
5695 (substring xrefs (match-beginning 1) (match-end 1))))
5697 (string-to-int (substring xrefs (match-beginning 2)
5699 (if (setq entry (gnus-gethash group xref-hashtb))
5700 (setcdr entry (cons number (cdr entry)))
5701 (gnus-sethash group (cons number nil) xref-hashtb)))))
5702 (and start xref-hashtb)))
5704 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5705 "Look through all the headers and mark the Xrefs as read."
5706 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5707 name info xref-hashtb idlist method nth4)
5709 (set-buffer gnus-group-buffer)
5710 (when (setq xref-hashtb
5711 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5714 (unless (string= from-newsgroup (setq name (symbol-name group)))
5715 (setq idlist (symbol-value group))
5716 ;; Dead groups are not updated.
5718 (setq info (gnus-get-info name))
5719 (when (stringp (setq nth4 (gnus-info-method info)))
5720 (setq nth4 (gnus-server-to-method nth4))))
5721 ;; Only do the xrefs if the group has the same
5722 ;; select method as the group we have just read.
5723 (or (gnus-methods-equal-p
5724 nth4 (gnus-find-method-for-group from-newsgroup))
5726 (equal nth4 (setq method (gnus-find-method-for-group
5728 (and (equal (car nth4) (car method))
5729 (equal (nth 1 nth4) (nth 1 method))))
5730 gnus-use-cross-reference
5731 (or (not (eq gnus-use-cross-reference t))
5733 ;; Only do cross-references on subscribed
5734 ;; groups, if that is what is wanted.
5735 (<= (gnus-info-level info) gnus-level-subscribed))
5736 (gnus-group-make-articles-read name idlist))))
5739 (defun gnus-compute-read-articles (group articles)
5740 (let* ((entry (gnus-group-entry group))
5741 (info (nth 2 entry))
5742 (active (gnus-active group))
5745 ;; First peel off all invalid article numbers.
5747 (let ((ids articles)
5749 (while (setq id (pop ids))
5750 (when (and first (> id (cdr active)))
5751 ;; We'll end up in this situation in one particular
5752 ;; obscure situation. If you re-scan a group and get
5753 ;; a new article that is cross-posted to a different
5754 ;; group that has not been re-scanned, you might get
5755 ;; crossposted article that has a higher number than
5756 ;; Gnus believes possible. So we re-activate this
5757 ;; group as well. This might mean doing the
5758 ;; crossposting thingy will *increase* the number
5759 ;; of articles in some groups. Tsk, tsk.
5760 (setq active (or (gnus-activate-group group) active)))
5761 (when (or (> id (cdr active))
5762 (< id (car active)))
5763 (setq articles (delq id articles))))))
5764 ;; If the read list is nil, we init it.
5766 (null (gnus-info-read info))
5768 (setq ninfo (cons 1 (1- (car active))))
5769 (setq ninfo (gnus-info-read info)))
5770 ;; Then we add the read articles to the range.
5772 ninfo (setq articles (sort articles '<))))))
5774 (defun gnus-group-make-articles-read (group articles)
5775 "Update the info of GROUP to say that ARTICLES are read."
5777 (entry (gnus-group-entry group))
5778 (info (nth 2 entry))
5779 (active (gnus-active group))
5782 (setq range (gnus-compute-read-articles group articles))
5783 (with-current-buffer gnus-group-buffer
5786 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5787 (gnus-info-set-read ',info ',(gnus-info-read info))
5788 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5789 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5790 (gnus-group-update-group ,group t))))
5791 ;; Add the read articles to the range.
5792 (gnus-info-set-read info range)
5793 (gnus-request-set-mark group (list (list range 'add '(read))))
5794 ;; Then we have to re-compute how many unread
5795 ;; articles there are in this group.
5799 (setq num (- (1+ (cdr active)) (car active))))
5800 ((not (listp (cdr range)))
5801 (setq num (- (cdr active) (- (1+ (cdr range))
5805 (if (numberp (car range))
5807 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5808 (setq range (cdr range)))
5809 (setq num (- (cdr active) num))))
5810 ;; Update the number of unread articles.
5812 ;; Update the group buffer.
5813 (unless (gnus-ephemeral-group-p group)
5814 (gnus-group-update-group group t))))))
5816 (defvar gnus-newsgroup-none-id 0)
5818 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5819 (let ((cur nntp-server-buffer)
5822 (with-current-buffer gnus-summary-buffer
5823 gnus-newsgroup-dependencies)))
5824 headers id end ref number
5825 (mail-parse-charset gnus-newsgroup-charset)
5826 (mail-parse-ignored-charsets
5827 (save-excursion (condition-case nil
5828 (set-buffer gnus-summary-buffer)
5830 gnus-newsgroup-ignored-charsets)))
5832 (set-buffer nntp-server-buffer)
5833 ;; Translate all TAB characters into SPACE characters.
5834 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5835 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5836 (ietf-drums-unfold-fws)
5837 (gnus-run-hooks 'gnus-parse-headers-hook)
5838 (let ((case-fold-search t)
5839 in-reply-to header p lines chars ctype)
5840 (goto-char (point-min))
5841 ;; Search to the beginning of the next header. Error messages
5842 ;; do not begin with 2 or 3.
5843 (while (re-search-forward "^[23][0-9]+ " nil t)
5846 ;; This implementation of this function, with nine
5847 ;; search-forwards instead of the one re-search-forward and
5848 ;; a case (which basically was the old function) is actually
5849 ;; about twice as fast, even though it looks messier. You
5850 ;; can't have everything, I guess. Speed and elegance
5851 ;; doesn't always go hand in hand.
5854 (make-full-mail-header
5857 (setq number (read cur))
5860 (narrow-to-region (point)
5861 (or (and (search-forward "\n.\n" nil t)
5867 (if (search-forward "\nsubject:" nil t)
5868 (nnheader-header-value)
5873 (if (search-forward "\nfrom:" nil t)
5874 (nnheader-header-value)
5879 (if (search-forward "\ndate:" nil t)
5880 (nnheader-header-value) ""))
5884 (setq id (if (re-search-forward
5885 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5886 ;; We do it this way to make sure the Message-ID
5887 ;; is (somewhat) syntactically valid.
5888 (buffer-substring (match-beginning 1)
5890 ;; If there was no message-id, we just fake one
5891 ;; to make subsequent routines simpler.
5892 (nnheader-generate-fake-message-id number))))
5896 (if (search-forward "\nreferences:" nil t)
5900 (nnheader-header-value)
5905 (search-backward ">" end t)
5908 (search-backward "<" end t)
5910 ;; Get the references from the in-reply-to header if there
5911 ;; were no references and the in-reply-to header looks
5913 (if (and (search-forward "\nin-reply-to:" nil t)
5914 (setq in-reply-to (nnheader-header-value))
5915 (string-match "<[^>]+>" in-reply-to))
5917 (setq ref (substring in-reply-to (match-beginning 0)
5919 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5920 (setq ref2 (substring in-reply-to (match-beginning 0)
5922 (when (> (length ref2) (length ref))
5929 (if (search-forward "\nchars: " nil t)
5930 (if (numberp (setq chars (ignore-errors (read cur))))
5936 (if (search-forward "\nlines: " nil t)
5937 (if (numberp (setq lines (ignore-errors (read cur))))
5943 (and (search-forward "\nxref:" nil t)
5944 (nnheader-header-value)))
5946 (when gnus-extra-headers
5947 (let ((extra gnus-extra-headers)
5951 (when (search-forward
5952 (concat "\n" (symbol-name (car extra)) ":") nil t)
5953 (push (cons (car extra) (nnheader-header-value)) out))
5957 (if (and (search-forward "\ncontent-type: " nil t)
5958 (setq ctype (nnheader-header-value)))
5959 (mime-entity-set-content-type-internal
5960 header (mime-parse-Content-Type ctype)))
5961 (when (equal id ref)
5964 (when gnus-alter-header-function
5965 (funcall gnus-alter-header-function header)
5966 (setq id (mail-header-id header)
5967 ref (gnus-parent-id (mail-header-references header))))
5970 (gnus-dependencies-add-header
5971 header dependencies force-new))
5972 (push header headers))
5973 (goto-char (point-max))
5975 (nreverse headers)))))
5977 ;; Goes through the xover lines and returns a list of vectors
5978 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5979 force-new dependencies
5980 group also-fetch-heads)
5981 "Parse the news overview data in the server buffer.
5982 Return a list of headers that match SEQUENCE (see
5983 `nntp-retrieve-headers')."
5984 ;; Get the Xref when the users reads the articles since most/some
5985 ;; NNTP servers do not include Xrefs when using XOVER.
5986 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5987 (let ((mail-parse-charset gnus-newsgroup-charset)
5988 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5989 (cur nntp-server-buffer)
5990 (dependencies (or dependencies gnus-newsgroup-dependencies))
5992 ((eq gnus-read-all-available-headers t)
5994 ((stringp gnus-read-all-available-headers)
5995 (string-match gnus-read-all-available-headers group))
5998 number headers header)
6000 (set-buffer nntp-server-buffer)
6001 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6002 ;; Allow the user to mangle the headers before parsing them.
6003 (gnus-run-hooks 'gnus-parse-headers-hook)
6004 (goto-char (point-min))
6005 (gnus-parse-without-error
6006 (while (and (or sequence allp)
6008 (setq number (read cur))
6010 (while (and sequence
6011 (< (car sequence) number))
6012 (setq sequence (cdr sequence))))
6015 (eq number (car sequence))))
6017 (setq sequence (cdr sequence))
6018 (setq header (inline
6019 (gnus-nov-parse-line
6020 number dependencies force-new)))))
6021 (push header headers))
6023 ;; A common bug in inn is that if you have posted an article and
6024 ;; then retrieves the active file, it will answer correctly --
6025 ;; the new article is included. However, a NOV entry for the
6026 ;; article may not have been generated yet, so this may fail.
6027 ;; We work around this problem by retrieving the last few
6028 ;; headers using HEAD.
6029 (if (or (not also-fetch-heads)
6031 ;; We (probably) got all the headers.
6033 (let ((gnus-nov-is-evil t))
6036 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6037 (gnus-get-newsgroup-headers))))))))
6039 (defun gnus-article-get-xrefs ()
6040 "Fill in the Xref value in `gnus-current-headers', if necessary.
6041 This is meant to be called in `gnus-article-internal-prepare-hook'."
6042 (let ((headers (with-current-buffer gnus-summary-buffer
6043 gnus-current-headers)))
6044 (or (not gnus-use-cross-reference)
6046 (and (mail-header-xref headers)
6047 (not (string= (mail-header-xref headers) "")))
6048 (let ((case-fold-search t)
6051 (nnheader-narrow-to-headers)
6052 (goto-char (point-min))
6053 (when (or (and (not (eobp))
6054 (eq (downcase (char-after)) ?x)
6055 (looking-at "Xref:"))
6056 (search-forward "\nXref:" nil t))
6057 (goto-char (1+ (match-end 0)))
6058 (setq xref (buffer-substring (point) (point-at-eol)))
6059 (mail-header-set-xref headers xref)))))))
6061 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6062 "Find article ID and insert the summary line for that article.
6063 OLD-HEADER can either be a header or a line number to insert
6064 the subject line on."
6065 (let* ((line (and (numberp old-header) old-header))
6066 (old-header (and (vectorp old-header) old-header))
6067 (header (cond ((and old-header use-old-header)
6070 (gnus-number-to-header id))
6071 (gnus-number-to-header id))
6073 (gnus-read-header id))))
6074 (number (and (numberp id) id))
6077 ;; Rebuild the thread that this article is part of and go to the
6078 ;; article we have fetched.
6079 (when (and (not gnus-show-threads)
6082 (setq d (gnus-data-find (mail-header-number old-header))))
6083 (goto-char (gnus-data-pos d))
6089 (gnus-delete-line))))))
6090 ;; Remove list identifiers from subject.
6091 (when gnus-list-identifiers
6092 (let ((gnus-newsgroup-headers (list header)))
6093 (gnus-summary-remove-list-identifiers)))
6095 (mail-header-set-number header (mail-header-number old-header)))
6096 (setq gnus-newsgroup-sparse
6097 (delq (setq number (mail-header-number header))
6098 gnus-newsgroup-sparse))
6099 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6100 (push number gnus-newsgroup-limit)
6101 (gnus-rebuild-thread (mail-header-id header) line)
6102 (gnus-summary-goto-subject number nil t))
6103 (when (and (numberp number)
6105 ;; We have to update the boundaries even if we can't fetch the
6106 ;; article if ID is a number -- so that the next `P' or `N'
6107 ;; command will fetch the previous (or next) article even
6108 ;; if the one we tried to fetch this time has been canceled.
6109 (when (> number gnus-newsgroup-end)
6110 (setq gnus-newsgroup-end number))
6111 (when (< number gnus-newsgroup-begin)
6112 (setq gnus-newsgroup-begin number))
6113 (setq gnus-newsgroup-unselected
6114 (delq number gnus-newsgroup-unselected)))
6115 ;; Report back a success?
6116 (and header (mail-header-number header))))
6118 ;;; Process/prefix in the summary buffer
6120 (defun gnus-summary-work-articles (n)
6121 "Return a list of articles to be worked upon.
6122 The prefix argument, the list of process marked articles, and the
6123 current article will be taken into consideration."
6125 (set-buffer gnus-summary-buffer)
6128 ;; A numerical prefix has been given.
6129 (setq n (prefix-numeric-value n))
6130 (let ((backward (< n 0))
6131 (n (abs (prefix-numeric-value n)))
6136 (push (setq article (gnus-summary-article-number))
6139 (gnus-summary-find-prev nil article)
6140 (gnus-summary-find-next nil article)))
6142 (nreverse articles)))
6143 ((and (gnus-region-active-p) (mark))
6144 (message "region active")
6145 ;; Work on the region between point and mark.
6146 (let ((max (max (point) (mark)))
6149 (goto-char (min (point) (mark)))
6152 (push (setq article (gnus-summary-article-number)) articles)
6153 (gnus-summary-find-next nil article)
6155 (nreverse articles))))
6156 (gnus-newsgroup-processable
6157 ;; There are process-marked articles present.
6158 ;; Save current state.
6159 (gnus-summary-save-process-mark)
6161 (reverse gnus-newsgroup-processable))
6163 ;; Just return the current article.
6164 (list (gnus-summary-article-number))))))
6166 (defmacro gnus-summary-iterate (arg &rest forms)
6167 "Iterate over the process/prefixed articles and do FORMS.
6168 ARG is the interactive prefix given to the command. FORMS will be
6169 executed with point over the summary line of the articles."
6170 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6171 `(let ((,articles (gnus-summary-work-articles ,arg)))
6173 (gnus-summary-goto-subject (car ,articles))
6177 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6178 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6180 (defun gnus-summary-save-process-mark ()
6181 "Push the current set of process marked articles on the stack."
6183 (push (copy-sequence gnus-newsgroup-processable)
6184 gnus-newsgroup-process-stack))
6186 (defun gnus-summary-kill-process-mark ()
6187 "Push the current set of process marked articles on the stack and unmark."
6189 (gnus-summary-save-process-mark)
6190 (gnus-summary-unmark-all-processable))
6192 (defun gnus-summary-yank-process-mark ()
6193 "Pop the last process mark state off the stack and restore it."
6195 (unless gnus-newsgroup-process-stack
6196 (error "Empty mark stack"))
6197 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6199 (defun gnus-summary-process-mark-set (set)
6200 "Make SET into the current process marked articles."
6201 (gnus-summary-unmark-all-processable)
6202 (mapc 'gnus-summary-set-process-mark set))
6204 ;;; Searching and stuff
6206 (defun gnus-summary-search-group (&optional backward use-level)
6207 "Search for next unread newsgroup.
6208 If optional argument BACKWARD is non-nil, search backward instead."
6210 (set-buffer gnus-group-buffer)
6211 (when (gnus-group-search-forward
6212 backward nil (if use-level (gnus-group-group-level) nil))
6213 (gnus-group-group-name))))
6215 (defun gnus-summary-best-group (&optional exclude-group)
6216 "Find the name of the best unread group.
6217 If EXCLUDE-GROUP, do not go to this group."
6218 (with-current-buffer gnus-group-buffer
6220 (gnus-group-best-unread-group exclude-group))))
6222 (defun gnus-summary-find-next (&optional unread article backward)
6224 (gnus-summary-find-prev unread article)
6225 (let* ((dummy (gnus-summary-article-intangible-p))
6226 (article (or article (gnus-summary-article-number)))
6227 (data (gnus-data-find-list article))
6229 (when (and (not dummy)
6230 (or (not gnus-summary-check-current)
6232 (not (gnus-data-unread-p (car data)))))
6233 (setq data (cdr data)))
6238 (unless (memq (gnus-data-number (car data))
6240 ((eq gnus-auto-goto-ignores
6241 'always-undownloaded)
6242 gnus-newsgroup-undownloaded)
6245 ((eq gnus-auto-goto-ignores
6247 gnus-newsgroup-unfetched)
6248 ((eq gnus-auto-goto-ignores
6250 gnus-newsgroup-undownloaded)))
6251 (when (gnus-data-unread-p (car data))
6252 (setq result (car data)
6254 (setq data (cdr data)))
6257 (goto-char (gnus-data-pos result))
6258 (gnus-data-number result)))))
6260 (defun gnus-summary-find-prev (&optional unread article)
6261 (let* ((eobp (eobp))
6262 (article (or article (gnus-summary-article-number)))
6263 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6265 (when (and (not eobp)
6266 (or (not gnus-summary-check-current)
6268 (not (gnus-data-unread-p (car data)))))
6269 (setq data (cdr data)))
6274 (unless (memq (gnus-data-number (car data))
6276 ((eq gnus-auto-goto-ignores
6277 'always-undownloaded)
6278 gnus-newsgroup-undownloaded)
6281 ((eq gnus-auto-goto-ignores
6283 gnus-newsgroup-unfetched)
6284 ((eq gnus-auto-goto-ignores
6286 gnus-newsgroup-undownloaded)))
6287 (when (gnus-data-unread-p (car data))
6288 (setq result (car data)
6290 (setq data (cdr data)))
6293 (goto-char (gnus-data-pos result))
6294 (gnus-data-number result))))
6296 (defun gnus-summary-find-subject (subject &optional unread backward article)
6297 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6298 (article (or article (gnus-summary-article-number)))
6299 (articles (gnus-data-list backward))
6300 (arts (gnus-data-find-list article articles))
6302 (when (or (not gnus-summary-check-current)
6304 (not (gnus-data-unread-p (car arts))))
6305 (setq arts (cdr arts)))
6307 (and (or (not unread)
6308 (gnus-data-unread-p (car arts)))
6309 (vectorp (gnus-data-header (car arts)))
6311 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6312 (setq result (car arts)
6314 (setq arts (cdr arts)))
6316 (goto-char (gnus-data-pos result))
6317 (gnus-data-number result))))
6319 (defun gnus-summary-search-forward (&optional unread subject backward)
6320 "Search forward for an article.
6321 If UNREAD, look for unread articles. If SUBJECT, look for
6322 articles with that subject. If BACKWARD, search backward instead."
6323 (cond (subject (gnus-summary-find-subject subject unread backward))
6324 (backward (gnus-summary-find-prev unread))
6325 (t (gnus-summary-find-next unread))))
6327 (defun gnus-recenter (&optional n)
6328 "Center point in window and redisplay frame.
6329 Also do horizontal recentering."
6331 (when (and gnus-auto-center-summary
6332 (not (eq gnus-auto-center-summary 'vertical)))
6333 (gnus-horizontal-recenter))
6336 (defun gnus-summary-recenter ()
6337 "Center point in the summary window.
6338 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6339 displayed, no centering will be performed."
6340 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6341 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6343 ;; The user has to want it.
6344 (when gnus-auto-center-summary
6345 (let* ((top (cond ((< (window-height) 4) 0)
6346 ((< (window-height) 7) 1)
6347 (t (if (numberp gnus-auto-center-summary)
6348 gnus-auto-center-summary
6349 (/ (1- (window-height)) 2)))))
6350 (height (1- (window-height)))
6351 (bottom (save-excursion (goto-char (point-max))
6352 (forward-line (- height))
6354 (window (get-buffer-window (current-buffer))))
6355 (when (get-buffer-window gnus-article-buffer)
6356 ;; Only do recentering when the article buffer is displayed,
6357 ;; Set the window start to either `bottom', which is the biggest
6358 ;; possible valid number, or the second line from the top,
6359 ;; whichever is the least.
6360 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6361 (if (> bottom top-pos)
6362 ;; Keep the second line from the top visible
6363 (set-window-start window top-pos t)
6364 ;; Try to keep the bottom line visible; if it's partially
6365 ;; obscured, either scroll one more line to make it fully
6366 ;; visible, or revert to using TOP-POS.
6368 (goto-char (point-max))
6370 (let ((last-line-start (point)))
6372 (set-window-start window (point) t)
6373 (when (not (pos-visible-in-window-p last-line-start window))
6375 (set-window-start window (min (point) top-pos) t)))))))
6376 ;; Do horizontal recentering while we're at it.
6377 (when (and (get-buffer-window (current-buffer) t)
6378 (not (eq gnus-auto-center-summary 'vertical)))
6379 (let ((selected (selected-window)))
6380 (select-window (get-buffer-window (current-buffer) t))
6381 (gnus-summary-position-point)
6382 (gnus-horizontal-recenter)
6383 (select-window selected))))))
6385 (defun gnus-summary-jump-to-group (newsgroup)
6386 "Move point to NEWSGROUP in group mode buffer."
6387 ;; Keep update point of group mode buffer if visible.
6388 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6389 (save-window-excursion
6390 ;; Take care of tree window mode.
6391 (when (get-buffer-window gnus-group-buffer)
6392 (pop-to-buffer gnus-group-buffer))
6393 (gnus-group-jump-to-group newsgroup))
6395 ;; Take care of tree window mode.
6396 (if (get-buffer-window gnus-group-buffer)
6397 (pop-to-buffer gnus-group-buffer)
6398 (set-buffer gnus-group-buffer))
6399 (gnus-group-jump-to-group newsgroup))))
6401 ;; This function returns a list of article numbers based on the
6402 ;; difference between the ranges of read articles in this group and
6403 ;; the range of active articles.
6404 (defun gnus-list-of-unread-articles (group)
6405 (let* ((read (gnus-info-read (gnus-get-info group)))
6406 (active (or (gnus-active group) (gnus-activate-group group)))
6409 ;; If none are read, then all are unread.
6411 (setq first (car active))
6412 ;; If the range of read articles is a single range, then the
6413 ;; first unread article is the article after the last read
6414 ;; article. Sounds logical, doesn't it?
6415 (if (and (not (listp (cdr read)))
6416 (or (< (car read) (car active))
6417 (progn (setq read (list read))
6419 (setq first (max (car active) (1+ (cdr read))))
6420 ;; `read' is a list of ranges.
6421 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6424 (setq first (car active)))
6427 (while (< first nlast)
6428 (setq unread (cons first unread)
6430 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6431 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6432 (setq read (cdr read)))))
6433 ;; And add the last unread articles.
6434 (while (<= first last)
6435 (setq unread (cons first unread)
6437 ;; Return the list of unread articles.
6438 (delq 0 (nreverse unread))))
6440 (defun gnus-list-of-read-articles (group)
6441 "Return a list of unread, unticked and non-dormant articles."
6442 (let* ((info (gnus-get-info group))
6443 (marked (gnus-info-marks info))
6444 (active (gnus-active group)))
6446 (gnus-list-range-difference
6447 (gnus-list-range-difference
6448 (gnus-sorted-complement
6449 (gnus-uncompress-range active)
6450 (gnus-list-of-unread-articles group))
6451 (cdr (assq 'dormant marked)))
6452 (cdr (assq 'tick marked))))))
6454 ;; This function returns a sequence of article numbers based on the
6455 ;; difference between the ranges of read articles in this group and
6456 ;; the range of active articles.
6457 (defun gnus-sequence-of-unread-articles (group)
6458 (let* ((read (gnus-info-read (gnus-get-info group)))
6459 (active (or (gnus-active group) (gnus-activate-group group)))
6462 ;; If none are read, then all are unread.
6464 (setq first (car active))
6465 ;; If the range of read articles is a single range, then the
6466 ;; first unread article is the article after the last read
6467 ;; article. Sounds logical, doesn't it?
6468 (if (and (not (listp (cdr read)))
6469 (or (< (car read) (car active))
6470 (progn (setq read (list read))
6472 (setq first (max (car active) (1+ (cdr read))))
6473 ;; `read' is a list of ranges.
6474 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6477 (setq first (car active)))
6480 (push (cons first nlast) unread))
6481 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6482 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6483 (setq read (cdr read)))))
6484 ;; And add the last unread articles.
6485 (cond ((< first last)
6486 (push (cons first last) unread))
6488 (push first unread)))
6489 ;; Return the sequence of unread articles.
6490 (delq 0 (nreverse unread))))
6492 ;; Various summary commands
6494 (defun gnus-summary-select-article-buffer ()
6495 "Reconfigure windows to show article buffer."
6497 (if (not (gnus-buffer-live-p gnus-article-buffer))
6498 (error "There is no article buffer for this summary buffer")
6499 (gnus-configure-windows 'article)
6500 (select-window (get-buffer-window gnus-article-buffer))))
6502 (defun gnus-summary-universal-argument (arg)
6503 "Perform any operation on all articles that are process/prefixed."
6505 (let ((articles (gnus-summary-work-articles arg))
6512 (substitute-command-keys
6513 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6515 (gnus-error 1 "Undefined key")
6518 (gnus-summary-goto-subject (setq article (pop articles)))
6519 (let (gnus-newsgroup-processable)
6520 (command-execute func))
6521 (gnus-summary-remove-process-mark article)))))
6522 (gnus-summary-position-point))
6524 (defun gnus-summary-toggle-truncation (&optional arg)
6525 "Toggle truncation of summary lines.
6526 With ARG, turn line truncation on if ARG is positive."
6528 (setq truncate-lines
6529 (if (null arg) (not truncate-lines)
6530 (> (prefix-numeric-value arg) 0)))
6533 (defun gnus-summary-find-for-reselect ()
6534 "Return the number of an article to stay on across a reselect.
6535 The current article is considered, then following articles, then previous
6536 articles. An article is sought which is not cancelled and isn't a temporary
6537 insertion from another group. If there's no such then return a dummy 0."
6539 (dolist (rev '(nil t))
6540 (unless found ; don't demand the reverse list if we don't need it
6541 (let ((data (gnus-data-find-list
6542 (gnus-summary-article-number) (gnus-data-list rev))))
6543 (while (and data (not found))
6544 (if (and (< 0 (gnus-data-number (car data)))
6545 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6546 (setq found (gnus-data-number (car data))))
6547 (setq data (cdr data))))))
6550 (defun gnus-summary-reselect-current-group (&optional all rescan)
6551 "Exit and then reselect the current newsgroup.
6552 The prefix argument ALL means to select all articles."
6554 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6555 (error "Ephemeral groups can't be reselected"))
6556 (let ((current-subject (gnus-summary-find-for-reselect))
6557 (group gnus-newsgroup-name))
6558 (setq gnus-newsgroup-begin nil)
6559 (gnus-summary-exit nil 'leave-hidden)
6560 ;; We have to adjust the point of group mode buffer because
6561 ;; point was moved to the next unread newsgroup by exiting.
6562 (gnus-summary-jump-to-group group)
6565 (save-window-excursion
6566 ;; Don't show group contents.
6567 (set-window-start (selected-window) (point-max))
6568 (gnus-group-get-new-news-this-group 1))))
6569 (gnus-group-read-group all t)
6570 (gnus-summary-goto-subject current-subject nil t)))
6572 (defun gnus-summary-rescan-group (&optional all)
6573 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6575 (gnus-summary-reselect-current-group all t))
6577 (defun gnus-summary-update-info (&optional non-destructive)
6579 (let ((group gnus-newsgroup-name))
6581 (when gnus-newsgroup-kill-headers
6582 (setq gnus-newsgroup-killed
6583 (gnus-compress-sequence
6585 (gnus-list-range-intersection
6586 gnus-newsgroup-unselected gnus-newsgroup-killed)
6587 gnus-newsgroup-unreads)
6589 (unless (listp (cdr gnus-newsgroup-killed))
6590 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6591 (let ((headers gnus-newsgroup-headers))
6592 ;; Set the new ranges of read articles.
6593 (with-current-buffer gnus-group-buffer
6594 (gnus-undo-force-boundary))
6595 (gnus-update-read-articles
6596 group (gnus-sorted-union
6597 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6598 ;; Set the current article marks.
6599 (let ((gnus-newsgroup-scored
6600 (if (and (not gnus-save-score)
6601 (not non-destructive))
6603 gnus-newsgroup-scored)))
6605 (gnus-update-marks)))
6606 ;; Do the cross-ref thing.
6607 (when gnus-use-cross-reference
6608 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6609 ;; Do not switch windows but change the buffer to work.
6610 (set-buffer gnus-group-buffer)
6611 (unless (gnus-ephemeral-group-p group)
6612 (gnus-group-update-group group)))))))
6614 (defun gnus-summary-save-newsrc (&optional force)
6615 "Save the current number of read/marked articles in the dribble buffer.
6616 The dribble buffer will then be saved.
6617 If FORCE (the prefix), also save the .newsrc file(s)."
6619 (gnus-summary-update-info t)
6621 (gnus-save-newsrc-file)
6622 (gnus-dribble-save)))
6624 (defun gnus-summary-exit (&optional temporary leave-hidden)
6625 "Exit reading current newsgroup, and then return to group selection mode.
6626 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6628 (gnus-set-global-variables)
6629 (gnus-kill-save-kill-buffer)
6630 (gnus-async-halt-prefetch)
6631 (let* ((group gnus-newsgroup-name)
6632 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6633 (gnus-group-is-exiting-p t)
6636 (buf (current-buffer)))
6638 ;; Do adaptive scoring, and possibly save score files.
6639 (when gnus-newsgroup-adaptive
6640 (gnus-score-adaptive))
6641 (when gnus-use-scoring
6643 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6644 ;; If we have several article buffers, we kill them at exit.
6645 (unless gnus-single-article-buffer
6646 (gnus-kill-buffer gnus-original-article-buffer)
6647 (setq gnus-article-current nil))
6648 (when gnus-use-cache
6649 (gnus-cache-possibly-remove-articles)
6650 (gnus-cache-save-buffers))
6651 (gnus-async-prefetch-remove-group group)
6652 (when gnus-suppress-duplicates
6653 (gnus-dup-enter-articles))
6654 (when gnus-use-trees
6655 (gnus-tree-close group))
6656 (when gnus-use-cache
6657 (gnus-cache-write-active))
6658 ;; Remove entries for this group.
6659 (nnmail-purge-split-history (gnus-group-real-name group))
6660 ;; Make all changes in this group permanent.
6662 (gnus-run-hooks 'gnus-exit-group-hook)
6663 (gnus-summary-update-info))
6664 (gnus-close-group group)
6665 ;; Make sure where we were, and go to next newsgroup.
6666 (set-buffer gnus-group-buffer)
6668 (gnus-group-jump-to-group group))
6669 (gnus-run-hooks 'gnus-summary-exit-hook)
6670 (unless (or quit-config
6671 ;; If this group has disappeared from the summary
6672 ;; buffer, don't skip forwards.
6673 (not (string= group (gnus-group-group-name))))
6674 (gnus-group-next-unread-group 1))
6675 (setq group-point (point))
6678 ;; If we have several article buffers, we kill them at exit.
6679 (unless gnus-single-article-buffer
6680 (gnus-kill-buffer gnus-article-buffer)
6681 (gnus-kill-buffer gnus-original-article-buffer)
6682 (setq gnus-article-current nil))
6684 (if (not gnus-kill-summary-on-exit)
6686 (gnus-deaden-summary)
6688 ;; We set all buffer-local variables to nil. It is unclear why
6689 ;; this is needed, but if we don't, buffer-local variables are
6690 ;; not garbage-collected, it seems. This would the lead to en
6691 ;; ever-growing Emacs.
6692 (gnus-summary-clear-local-variables)
6693 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6694 (gnus-summary-clear-local-variables))
6695 (when (get-buffer gnus-article-buffer)
6696 (bury-buffer gnus-article-buffer))
6697 ;; We clear the global counterparts of the buffer-local
6698 ;; variables as well, just to be on the safe side.
6699 (set-buffer gnus-group-buffer)
6700 (gnus-summary-clear-local-variables)
6701 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6702 (gnus-summary-clear-local-variables))
6703 ;; Return to group mode buffer.
6704 (when (eq mode 'gnus-summary-mode)
6705 (gnus-kill-buffer buf)))
6706 (setq gnus-current-select-method gnus-select-method)
6708 (set-buffer gnus-group-buffer)
6709 (pop-to-buffer gnus-group-buffer))
6710 (if (not quit-config)
6712 (goto-char group-point)
6713 (unless leave-hidden
6714 (gnus-configure-windows 'group 'force))
6715 (unless (pos-visible-in-window-p)
6716 (forward-line (/ (static-if (featurep 'xemacs)
6717 (window-displayed-height)
6718 (1- (window-height)))
6720 (set-window-start (selected-window) (point))
6721 (goto-char group-point)))
6722 (gnus-handle-ephemeral-exit quit-config))
6723 ;; Clear the current group name.
6725 (setq gnus-newsgroup-name nil)))))
6727 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6728 (defun gnus-summary-exit-no-update (&optional no-questions)
6729 "Quit reading current newsgroup without updating read article info."
6731 (let* ((group gnus-newsgroup-name)
6732 (gnus-group-is-exiting-p t)
6733 (gnus-group-is-exiting-without-update-p t)
6734 (quit-config (gnus-group-quit-config group)))
6735 (when (or no-questions
6737 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6738 (gnus-async-halt-prefetch)
6739 (run-hooks 'gnus-summary-prepare-exit-hook)
6740 ;; If we have several article buffers, we kill them at exit.
6741 (unless gnus-single-article-buffer
6742 (gnus-kill-buffer gnus-article-buffer)
6743 (gnus-kill-buffer gnus-original-article-buffer)
6744 (setq gnus-article-current nil))
6745 (if (not gnus-kill-summary-on-exit)
6746 (gnus-deaden-summary)
6747 (gnus-close-group group)
6748 (gnus-summary-clear-local-variables)
6749 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6750 (gnus-summary-clear-local-variables))
6751 (set-buffer gnus-group-buffer)
6752 (gnus-summary-clear-local-variables)
6753 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6754 (gnus-summary-clear-local-variables))
6755 (gnus-kill-buffer gnus-summary-buffer))
6756 (unless gnus-single-article-buffer
6757 (setq gnus-article-current nil))
6758 (when gnus-use-trees
6759 (gnus-tree-close group))
6760 (gnus-async-prefetch-remove-group group)
6761 (when (get-buffer gnus-article-buffer)
6762 (bury-buffer gnus-article-buffer))
6763 ;; Return to the group buffer.
6764 (gnus-configure-windows 'group 'force)
6765 ;; Clear the current group name.
6766 (setq gnus-newsgroup-name nil)
6767 (unless (gnus-ephemeral-group-p group)
6768 (gnus-group-update-group group))
6769 (when (equal (gnus-group-group-name) group)
6770 (gnus-group-next-unread-group 1))
6772 (gnus-handle-ephemeral-exit quit-config)))))
6774 (defun gnus-handle-ephemeral-exit (quit-config)
6775 "Handle movement when leaving an ephemeral group.
6776 The state which existed when entering the ephemeral is reset."
6777 (if (not (buffer-name (car quit-config)))
6778 (gnus-configure-windows 'group 'force)
6779 (set-buffer (car quit-config))
6780 (cond ((eq major-mode 'gnus-summary-mode)
6781 (gnus-set-global-variables))
6782 ((eq major-mode 'gnus-article-mode)
6784 ;; The `gnus-summary-buffer' variable may point
6785 ;; to the old summary buffer when using a single
6787 (unless (gnus-buffer-live-p gnus-summary-buffer)
6788 (set-buffer gnus-group-buffer))
6789 (set-buffer gnus-summary-buffer)
6790 (gnus-set-global-variables))))
6791 (if (or (eq (cdr quit-config) 'article)
6792 (eq (cdr quit-config) 'pick))
6794 ;; The current article may be from the ephemeral group
6795 ;; thus it is best that we reload this article
6797 ;; If we're exiting from a large digest, this can be
6798 ;; extremely slow. So, it's better not to reload it. -- jh.
6799 ;;(gnus-summary-show-article)
6800 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6801 (gnus-configure-windows 'pick 'force)
6802 (gnus-configure-windows (cdr quit-config) 'force)))
6803 (gnus-configure-windows (cdr quit-config) 'force))
6804 (when (eq major-mode 'gnus-summary-mode)
6805 (gnus-summary-next-subject 1 nil t)
6806 (gnus-summary-recenter)
6807 (gnus-summary-position-point))))
6809 (defun gnus-summary-preview-mime-message ()
6810 "MIME decode and play this message."
6812 (let ((gnus-break-pages nil)
6814 (gnus-summary-select-article gnus-show-all-headers t))
6815 (let ((w (get-buffer-window gnus-article-buffer)))
6817 (select-window (get-buffer-window gnus-article-buffer)))))
6821 (defvar gnus-dead-summary-mode-map nil)
6823 (unless gnus-dead-summary-mode-map
6824 (setq gnus-dead-summary-mode-map (make-keymap))
6825 (suppress-keymap gnus-dead-summary-mode-map)
6826 (substitute-key-definition
6827 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6828 (dolist (key '("\C-d" "\r" "\177" [delete]))
6829 (define-key gnus-dead-summary-mode-map
6830 key 'gnus-summary-wake-up-the-dead))
6831 (dolist (key '("q" "Q"))
6832 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6834 (defvar gnus-dead-summary-mode nil
6835 "Minor mode for Gnus summary buffers.")
6837 (defun gnus-dead-summary-mode (&optional arg)
6838 "Minor mode for Gnus summary buffers."
6840 (when (eq major-mode 'gnus-summary-mode)
6841 (make-local-variable 'gnus-dead-summary-mode)
6842 (setq gnus-dead-summary-mode
6843 (if (null arg) (not gnus-dead-summary-mode)
6844 (> (prefix-numeric-value arg) 0)))
6845 (when gnus-dead-summary-mode
6847 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6849 (defun gnus-deaden-summary ()
6850 "Make the current summary buffer into a dead summary buffer."
6851 ;; Kill any previous dead summary buffer.
6852 (when (and gnus-dead-summary
6853 (buffer-name gnus-dead-summary))
6854 (with-current-buffer gnus-dead-summary
6855 (when gnus-dead-summary-mode
6856 (kill-buffer (current-buffer)))))
6857 ;; Make this the current dead summary.
6858 (setq gnus-dead-summary (current-buffer))
6859 (gnus-dead-summary-mode 1)
6860 (let ((name (buffer-name)))
6861 (when (string-match "Summary" name)
6863 (concat (substring name 0 (match-beginning 0)) "Dead "
6864 (substring name (match-beginning 0)))
6868 (defun gnus-kill-or-deaden-summary (buffer)
6869 "Kill or deaden the summary BUFFER."
6871 (when (and (buffer-name buffer)
6872 (not gnus-single-article-buffer))
6873 (with-current-buffer buffer
6874 (gnus-kill-buffer gnus-article-buffer)
6875 (gnus-kill-buffer gnus-original-article-buffer)))
6878 (gnus-kill-summary-on-exit
6879 (when (and gnus-use-trees
6880 (gnus-buffer-exists-p buffer))
6883 (gnus-tree-close gnus-newsgroup-name)))
6884 (gnus-kill-buffer buffer))
6885 ;; Deaden the buffer.
6886 ((gnus-buffer-exists-p buffer)
6889 (gnus-deaden-summary))))))
6891 (defun gnus-summary-wake-up-the-dead (&rest args)
6892 "Wake up the dead summary buffer."
6894 (gnus-dead-summary-mode -1)
6895 (let ((name (buffer-name)))
6896 (when (string-match "Dead " name)
6898 (concat (substring name 0 (match-beginning 0))
6899 (substring name (match-end 0)))
6901 (gnus-message 3 "This dead summary is now alive again"))
6903 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6904 (defun gnus-summary-fetch-faq (&optional faq-dir)
6905 "Fetch the FAQ for the current group.
6906 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6910 (when current-prefix-arg
6912 "FAQ dir: " (and (listp gnus-group-faq-directory)
6914 gnus-group-faq-directory))))))
6915 (let (gnus-faq-buffer)
6916 (when (setq gnus-faq-buffer
6917 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6918 (gnus-configure-windows 'summary-faq))))
6920 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6921 (defun gnus-summary-describe-group (&optional force)
6922 "Describe the current newsgroup."
6924 (gnus-group-describe-group force gnus-newsgroup-name))
6926 (defun gnus-summary-describe-briefly ()
6927 "Describe summary mode commands briefly."
6929 (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")))
6931 ;; Walking around group mode buffer from summary mode.
6933 (defun gnus-summary-next-group (&optional no-article target-group backward)
6934 "Exit current newsgroup and then select next unread newsgroup.
6935 If prefix argument NO-ARTICLE is non-nil, no article is selected
6936 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6937 previous group instead."
6939 ;; Stop pre-fetching.
6940 (gnus-async-halt-prefetch)
6941 (let ((current-group gnus-newsgroup-name)
6942 (current-buffer (current-buffer))
6944 ;; First we semi-exit this group to update Xrefs and all variables.
6945 ;; We can't do a real exit, because the window conf must remain
6946 ;; the same in case the user is prompted for info, and we don't
6947 ;; want the window conf to change before that...
6948 (gnus-summary-exit t)
6949 (while (not entered)
6950 ;; Then we find what group we are supposed to enter.
6951 (set-buffer gnus-group-buffer)
6952 (gnus-group-jump-to-group current-group)
6955 (if (eq gnus-keep-same-level 'best)
6956 (gnus-summary-best-group gnus-newsgroup-name)
6957 (gnus-summary-search-group backward gnus-keep-same-level))))
6958 (if (not target-group)
6959 ;; There are no further groups, so we return to the group
6962 (gnus-message 5 "Returning to the group buffer")
6964 (when (gnus-buffer-live-p current-buffer)
6965 (set-buffer current-buffer)
6966 (gnus-summary-exit))
6967 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6968 ;; We try to enter the target group.
6969 (gnus-group-jump-to-group target-group)
6970 (let ((unreads (gnus-group-group-unread)))
6971 (if (and (or (eq t unreads)
6972 (and unreads (not (zerop unreads))))
6973 (gnus-summary-read-group
6974 target-group nil no-article
6975 (and (buffer-name current-buffer) current-buffer)
6978 (setq current-group target-group
6979 target-group nil)))))))
6981 (defun gnus-summary-prev-group (&optional no-article)
6982 "Exit current newsgroup and then select previous unread newsgroup.
6983 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6985 (gnus-summary-next-group no-article nil t))
6987 ;; Walking around summary lines.
6989 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6990 "Go to the first subject satisfying any non-nil constraint.
6991 If UNREAD is non-nil, the article should be unread.
6992 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6993 If UNSEEN is non-nil, the article should be unseen.
6994 Returns the article selected or nil if there are no matching articles."
6998 ((null gnus-newsgroup-data)
6999 (gnus-message 3 "No articles in the group")
7001 ;; Pick the first article.
7002 ((not (or unread undownloaded unseen))
7003 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7004 (gnus-data-number (car gnus-newsgroup-data)))
7005 ;; Find the first unread article.
7007 (let ((data gnus-newsgroup-data))
7009 (let ((num (gnus-data-number (car data))))
7010 (or (memq num gnus-newsgroup-unfetched)
7011 (not (or (and unread
7012 (memq num gnus-newsgroup-unreads))
7014 (memq num gnus-newsgroup-undownloaded))
7016 (memq num gnus-newsgroup-unseen)))))))
7017 (setq data (cdr data)))
7021 (goto-char (gnus-data-pos (car data)))
7022 (gnus-data-number (car data)))
7023 (gnus-message 3 "No more%s articles"
7024 (let* ((r (when unread " unread"))
7025 (d (when undownloaded " undownloaded"))
7026 (s (when unseen " unseen"))
7027 (l (delq nil (list r d s))))
7028 (cond ((= 3 (length l))
7029 (concat r "," d ", or" s))
7031 (concat (car l) ", or" (cadr l)))
7038 (gnus-summary-position-point))))))
7040 (defun gnus-summary-next-subject (n &optional unread dont-display)
7041 "Go to next N'th summary line.
7042 If N is negative, go to the previous N'th subject line.
7043 If UNREAD is non-nil, only unread articles are selected.
7044 The difference between N and the actual number of steps taken is
7047 (let ((backward (< n 0))
7051 (gnus-summary-find-prev unread)
7052 (gnus-summary-find-next unread)))
7053 (unless (zerop (setq n (1- n)))
7054 (gnus-summary-show-thread)))
7056 (gnus-message 7 "No more%s articles"
7057 (if unread " unread" "")))
7058 (unless dont-display
7059 (gnus-summary-recenter)
7060 (gnus-summary-position-point))
7063 (defun gnus-summary-next-unread-subject (n)
7064 "Go to next N'th unread summary line."
7066 (gnus-summary-next-subject n t))
7068 (defun gnus-summary-prev-subject (n &optional unread)
7069 "Go to previous N'th summary line.
7070 If optional argument UNREAD is non-nil, only unread article is selected."
7072 (gnus-summary-next-subject (- n) unread))
7074 (defun gnus-summary-prev-unread-subject (n)
7075 "Go to previous N'th unread summary line."
7077 (gnus-summary-next-subject (- n) t))
7079 (defun gnus-summary-goto-subjects (articles)
7080 "Insert the subject header for ARTICLES in the current buffer."
7082 (dolist (article articles)
7083 (gnus-summary-goto-subject article t)))
7084 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7085 (gnus-summary-position-point))
7087 (defun gnus-summary-goto-subject (article &optional force silent)
7088 "Go the subject line of ARTICLE.
7089 If FORCE, also allow jumping to articles not currently shown."
7090 (interactive "nArticle number: ")
7091 (unless (numberp article)
7092 (error "Article %s is not a number" article))
7094 (data (gnus-data-find article)))
7095 ;; We read in the article if we have to.
7098 (gnus-summary-insert-subject
7100 (if (or (numberp force) (vectorp force)) force)
7102 (setq data (gnus-data-find article)))
7107 (gnus-message 3 "Can't find article %d" article))
7109 (let ((pt (gnus-data-pos data)))
7111 (gnus-summary-set-article-display-arrow pt))
7112 (gnus-summary-position-point)
7115 ;; Walking around summary lines with displaying articles.
7117 (defun gnus-summary-expand-window (&optional arg)
7118 "Make the summary buffer take up the entire Emacs frame.
7119 Given a prefix, will force an `article' buffer configuration."
7122 (gnus-configure-windows 'article 'force)
7123 (gnus-configure-windows 'summary 'force)))
7125 (defun gnus-summary-display-article (article &optional all-header)
7126 "Display ARTICLE in article buffer."
7127 (when (gnus-buffer-live-p gnus-article-buffer)
7128 (with-current-buffer gnus-article-buffer
7129 (set-buffer-multibyte t)))
7130 (gnus-set-global-variables)
7131 (when (gnus-buffer-live-p gnus-article-buffer)
7132 (with-current-buffer gnus-article-buffer
7133 (setq gnus-article-charset gnus-newsgroup-charset)
7134 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7135 (set-buffer-multibyte t)))
7139 (if gnus-summary-display-article-function
7140 (funcall gnus-summary-display-article-function article all-header)
7141 (gnus-article-prepare article all-header))
7142 (with-current-buffer gnus-article-buffer
7143 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7145 (gnus-run-hooks 'gnus-select-article-hook)
7146 (when (and gnus-current-article
7147 (not (zerop gnus-current-article)))
7148 (gnus-summary-goto-subject gnus-current-article))
7149 (gnus-summary-recenter)
7150 (when (and gnus-use-trees gnus-show-threads)
7151 (gnus-possibly-generate-tree article)
7152 (gnus-highlight-selected-tree article))
7153 ;; Successfully display article.
7154 (gnus-article-set-window-start
7155 (cdr (assq article gnus-newsgroup-bookmarks))))))
7157 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7158 "Select the current article.
7159 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7160 non-nil, the article will be re-fetched even if it already present in
7161 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7163 ;; Make sure we are in the summary buffer to work around bbdb bug.
7164 (unless (eq major-mode 'gnus-summary-mode)
7165 (set-buffer gnus-summary-buffer))
7166 (let ((article (or article (gnus-summary-article-number)))
7167 (all-headers (not (not all-headers))) ;Must be T or NIL.
7168 gnus-summary-display-article-function)
7170 (gnus-summary-article-pseudo-p article)
7171 (error "This is a pseudo-article"))
7173 (set-buffer gnus-summary-buffer)
7174 (if (or (and gnus-single-article-buffer
7175 (or (null gnus-current-article)
7176 (null gnus-article-current)
7177 (null (get-buffer gnus-article-buffer))
7178 (not (eq article (cdr gnus-article-current)))
7179 (not (equal (car gnus-article-current)
7180 gnus-newsgroup-name))))
7181 (and (not gnus-single-article-buffer)
7182 (or (null gnus-current-article)
7183 (not (eq gnus-current-article article))))
7185 ;; The requested article is different from the current article.
7187 (gnus-summary-display-article article all-headers)
7188 (gnus-article-set-window-start
7189 (cdr (assq article gnus-newsgroup-bookmarks)))
7193 (defun gnus-summary-force-verify-and-decrypt ()
7194 "Display buttons for signed/encrypted parts and verify/decrypt them."
7196 (let ((mm-verify-option 'known)
7197 (mm-decrypt-option 'known)
7198 (gnus-article-emulate-mime t)
7199 (gnus-buttonized-mime-types (append (list "multipart/signed"
7200 "multipart/encrypted")
7201 gnus-buttonized-mime-types)))
7202 (gnus-summary-select-article nil 'force)))
7204 (defun gnus-summary-set-current-mark (&optional current-mark)
7205 "Obsolete function."
7208 (defun gnus-summary-next-article (&optional unread subject backward push)
7209 "Select the next article.
7210 If UNREAD, only unread articles are selected.
7211 If SUBJECT, only articles with SUBJECT are selected.
7212 If BACKWARD, the previous article is selected instead of the next."
7215 ;; Is there such an article?
7216 ((and (gnus-summary-search-forward unread subject backward)
7217 (or (gnus-summary-display-article (gnus-summary-article-number))
7218 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7219 (gnus-summary-position-point))
7220 ;; If not, we try the first unread, if that is wanted.
7222 gnus-auto-select-same
7223 (gnus-summary-first-unread-article))
7224 (gnus-summary-position-point)
7225 (gnus-message 6 "Wrapped"))
7226 ;; Try to get next/previous article not displayed in this group.
7227 ((and gnus-auto-extend-newsgroup
7228 (not unread) (not subject))
7229 (gnus-summary-goto-article
7230 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7231 nil (count-lines (point-min) (point))))
7232 ;; Go to next/previous group.
7234 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7235 (gnus-summary-jump-to-group gnus-newsgroup-name))
7236 (let ((cmd last-command-char)
7238 (with-current-buffer gnus-group-buffer
7241 (if (eq gnus-keep-same-level 'best)
7242 (gnus-summary-best-group gnus-newsgroup-name)
7243 (gnus-summary-search-group backward gnus-keep-same-level))))
7244 ;; For some reason, the group window gets selected. We change
7246 (select-window (get-buffer-window (current-buffer)))
7247 ;; Select next unread newsgroup automagically.
7249 ((or (not gnus-auto-select-next)
7251 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7252 ((or (eq gnus-auto-select-next 'quietly)
7253 (and (eq gnus-auto-select-next 'slightly-quietly)
7255 (and (eq gnus-auto-select-next 'almost-quietly)
7256 (gnus-summary-last-article-p)))
7258 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7260 (gnus-message 7 "No more%s articles (%s)..."
7261 (if unread " unread" "")
7262 (if group (concat "selecting " group)
7264 (gnus-summary-next-group nil group backward)))
7266 (when (gnus-key-press-event-p last-input-event)
7267 (gnus-summary-walk-group-buffer
7268 gnus-newsgroup-name cmd unread backward point))))))))
7270 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7271 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7272 (?\C-p (gnus-group-prev-unread-group 1))))
7273 (cursor-in-echo-area t)
7274 keve key group ended prompt)
7276 (set-buffer gnus-group-buffer)
7279 (if (eq gnus-keep-same-level 'best)
7280 (gnus-summary-best-group gnus-newsgroup-name)
7281 (gnus-summary-search-group backward gnus-keep-same-level))))
7285 "No more%s articles%s " (if unread " unread" "")
7287 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7288 (format " (Type %s for %s [%s])"
7289 (single-key-description cmd) group
7290 (gnus-group-unread group))
7291 (format " (Type %s to exit %s)"
7292 (single-key-description cmd)
7293 gnus-newsgroup-name))))
7294 ;; Confirm auto selection.
7295 (setq key (car (setq keve (gnus-read-event-char prompt)))
7298 ((assq key keystrokes)
7299 (let ((obuf (current-buffer)))
7300 (switch-to-buffer gnus-group-buffer)
7302 (gnus-group-jump-to-group group))
7303 (eval (cadr (assq key keystrokes)))
7304 (setq group (gnus-group-group-name))
7305 (switch-to-buffer obuf))
7309 (gnus-ephemeral-group-p gnus-newsgroup-name))
7311 (gnus-summary-next-group nil group backward)))
7313 (push (cdr keve) unread-command-events))))))
7315 (defun gnus-summary-next-unread-article ()
7316 "Select unread article after current one."
7318 (gnus-summary-next-article
7319 (or (not (eq gnus-summary-goto-unread 'never))
7320 (gnus-summary-last-article-p (gnus-summary-article-number)))
7321 (and gnus-auto-select-same
7322 (gnus-summary-article-subject))))
7324 (defun gnus-summary-prev-article (&optional unread subject)
7325 "Select the article after the current one.
7326 If UNREAD is non-nil, only unread articles are selected."
7328 (gnus-summary-next-article unread subject t))
7330 (defun gnus-summary-prev-unread-article ()
7331 "Select unread article before current one."
7333 (gnus-summary-prev-article
7334 (or (not (eq gnus-summary-goto-unread 'never))
7335 (gnus-summary-first-article-p (gnus-summary-article-number)))
7336 (and gnus-auto-select-same
7337 (gnus-summary-article-subject))))
7339 (defun gnus-summary-next-page (&optional lines circular stop)
7340 "Show next page of the selected article.
7341 If at the end of the current article, select the next article.
7342 LINES says how many lines should be scrolled up.
7344 If CIRCULAR is non-nil, go to the start of the article instead of
7345 selecting the next article when reaching the end of the current
7348 If STOP is non-nil, just stop when reaching the end of the message.
7350 Also see the variable `gnus-article-skip-boring'."
7352 (setq gnus-summary-buffer (current-buffer))
7353 (gnus-set-global-variables)
7354 (let ((article (gnus-summary-article-number))
7355 (article-window (get-buffer-window gnus-article-buffer t))
7357 ;; If the buffer is empty, we have no article.
7359 (error "No article to select"))
7360 (gnus-configure-windows 'article)
7361 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7362 (if (and (eq gnus-summary-goto-unread 'never)
7363 (not (gnus-summary-last-article-p article)))
7364 (gnus-summary-next-article)
7365 (gnus-summary-next-unread-article))
7366 (if (or (null gnus-current-article)
7367 (null gnus-article-current)
7368 (/= article (cdr gnus-article-current))
7369 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7370 ;; Selected subject is different from current article's.
7371 (gnus-summary-display-article article)
7372 (when article-window
7373 (gnus-eval-in-buffer-window gnus-article-buffer
7374 (setq endp (or (gnus-article-next-page lines)
7375 (gnus-article-only-boring-p))))
7378 (gnus-message 3 "End of message"))
7380 (gnus-summary-beginning-of-article))
7382 (gnus-message 3 "End of message"))
7384 (if (and (eq gnus-summary-goto-unread 'never)
7385 (not (gnus-summary-last-article-p article)))
7386 (gnus-summary-next-article)
7387 (gnus-summary-next-unread-article))))))))
7388 (gnus-summary-recenter)
7389 (gnus-summary-position-point)))
7391 (defun gnus-summary-prev-page (&optional lines move)
7392 "Show previous page of selected article.
7393 Argument LINES specifies lines to be scrolled down.
7394 If MOVE, move to the previous unread article if point is at
7395 the beginning of the buffer."
7397 (let ((article (gnus-summary-article-number))
7398 (article-window (get-buffer-window gnus-article-buffer t))
7400 (gnus-configure-windows 'article)
7401 (if (or (null gnus-current-article)
7402 (null gnus-article-current)
7403 (/= article (cdr gnus-article-current))
7404 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7405 ;; Selected subject is different from current article's.
7406 (gnus-summary-display-article article)
7407 (gnus-summary-recenter)
7408 (when article-window
7409 (gnus-eval-in-buffer-window gnus-article-buffer
7410 (setq endp (gnus-article-prev-page lines)))
7411 (when (and move endp)
7413 (gnus-message 3 "Beginning of message"))
7415 (if (and (eq gnus-summary-goto-unread 'never)
7416 (not (gnus-summary-first-article-p article)))
7417 (gnus-summary-prev-article)
7418 (gnus-summary-prev-unread-article))))))))
7419 (gnus-summary-position-point))
7421 (defun gnus-summary-prev-page-or-article (&optional lines)
7422 "Show previous page of selected article.
7423 Argument LINES specifies lines to be scrolled down.
7424 If at the beginning of the article, go to the next article."
7426 (gnus-summary-prev-page lines t))
7428 (defun gnus-summary-scroll-up (lines)
7429 "Scroll up (or down) one line current article.
7430 Argument LINES specifies lines to be scrolled up (or down if negative)."
7432 (gnus-configure-windows 'article)
7433 (gnus-summary-show-thread)
7434 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7435 (gnus-eval-in-buffer-window gnus-article-buffer
7437 (when (gnus-article-next-page lines)
7438 (gnus-message 3 "End of message")))
7440 (gnus-article-prev-page (- lines))))))
7441 (gnus-summary-recenter)
7442 (gnus-summary-position-point))
7444 (defun gnus-summary-scroll-down (lines)
7445 "Scroll down (or up) one line current article.
7446 Argument LINES specifies lines to be scrolled down (or up if negative)."
7448 (gnus-summary-scroll-up (- lines)))
7450 (defun gnus-summary-next-same-subject ()
7451 "Select next article which has the same subject as current one."
7453 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7455 (defun gnus-summary-prev-same-subject ()
7456 "Select previous article which has the same subject as current one."
7458 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7460 (defun gnus-summary-next-unread-same-subject ()
7461 "Select next unread article which has the same subject as current one."
7463 (gnus-summary-next-article t (gnus-summary-article-subject)))
7465 (defun gnus-summary-prev-unread-same-subject ()
7466 "Select previous unread article which has the same subject as current one."
7468 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7470 (defun gnus-summary-first-unread-article ()
7471 "Select the first unread article.
7472 Return nil if there are no unread articles."
7475 (when (gnus-summary-first-subject t)
7476 (gnus-summary-show-thread)
7477 (gnus-summary-first-subject t)
7478 (gnus-summary-display-article (gnus-summary-article-number)))
7479 (gnus-summary-position-point)))
7481 (defun gnus-summary-first-unread-subject ()
7482 "Place the point on the subject line of the first unread article.
7483 Return nil if there are no unread articles."
7486 (when (gnus-summary-first-subject t)
7487 (gnus-summary-show-thread)
7488 (gnus-summary-first-subject t))
7489 (gnus-summary-position-point)))
7491 (defun gnus-summary-first-unseen-subject ()
7492 "Place the point on the subject line of the first unseen article.
7493 Return nil if there are no unseen articles."
7496 (when (gnus-summary-first-subject nil nil t)
7497 (gnus-summary-show-thread)
7498 (gnus-summary-first-subject nil nil t))
7499 (gnus-summary-position-point)))
7501 (defun gnus-summary-first-unseen-or-unread-subject ()
7502 "Place the point on the subject line of the first unseen article or,
7503 if all article have been seen, on the subject line of the first unread
7507 (unless (when (gnus-summary-first-subject nil nil t)
7508 (gnus-summary-show-thread)
7509 (gnus-summary-first-subject nil nil t))
7510 (when (gnus-summary-first-subject t)
7511 (gnus-summary-show-thread)
7512 (gnus-summary-first-subject t)))
7513 (gnus-summary-position-point)))
7515 (defun gnus-summary-first-article ()
7516 "Select the first article.
7517 Return nil if there are no articles."
7520 (when (gnus-summary-first-subject)
7521 (gnus-summary-show-thread)
7522 (gnus-summary-first-subject)
7523 (gnus-summary-display-article (gnus-summary-article-number)))
7524 (gnus-summary-position-point)))
7526 (defun gnus-summary-best-unread-article (&optional arg)
7527 "Select the unread article with the highest score.
7528 If given a prefix argument, select the next unread article that has a
7529 score higher than the default score."
7531 (let ((article (if arg
7532 (gnus-summary-better-unread-subject)
7533 (gnus-summary-best-unread-subject))))
7535 (gnus-summary-goto-article article)
7536 (error "No unread articles"))))
7538 (defun gnus-summary-best-unread-subject ()
7539 "Select the unread subject with the highest score."
7541 (let ((best -1000000)
7542 (data gnus-newsgroup-data)
7545 (and (gnus-data-unread-p (car data))
7547 (gnus-summary-article-score (gnus-data-number (car data))))
7550 article (gnus-data-number (car data))))
7551 (setq data (cdr data)))
7553 (gnus-summary-goto-subject article))
7554 (gnus-summary-position-point)
7557 (defun gnus-summary-better-unread-subject ()
7558 "Select the first unread subject that has a score over the default score."
7560 (let ((data gnus-newsgroup-data)
7562 (while (and (setq article (gnus-data-number (car data)))
7563 (or (gnus-data-read-p (car data))
7564 (not (> (gnus-summary-article-score article)
7565 gnus-summary-default-score))))
7566 (setq data (cdr data)))
7568 (gnus-summary-goto-subject article))
7569 (gnus-summary-position-point)
7572 (defun gnus-summary-last-subject ()
7573 "Go to the last displayed subject line in the group."
7574 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7576 (gnus-summary-goto-subject article))))
7578 (defun gnus-summary-goto-article (article &optional all-headers force)
7579 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7580 If ALL-HEADERS is non-nil, no header lines are hidden.
7581 If FORCE, go to the article even if it isn't displayed. If FORCE
7582 is a number, it is the line the article is to be displayed on."
7586 "Article number or Message-ID: "
7587 (mapcar (lambda (number) (list (int-to-string number)))
7588 gnus-newsgroup-limit))
7592 (if (and (stringp article)
7593 (string-match "@\\|%40" article))
7594 (gnus-summary-refer-article article)
7595 (when (stringp article)
7596 (setq article (string-to-number article)))
7597 (if (gnus-summary-goto-subject article force)
7598 (gnus-summary-display-article article all-headers)
7599 (gnus-message 4 "Couldn't go to article %s" article) nil))
7600 (gnus-summary-position-point)))
7602 (defun gnus-summary-goto-last-article ()
7603 "Go to the previously read article."
7606 (when gnus-last-article
7607 (gnus-summary-goto-article gnus-last-article nil t))
7608 (gnus-summary-position-point)))
7610 (defun gnus-summary-pop-article (number)
7611 "Pop one article off the history and go to the previous.
7612 NUMBER articles will be popped off."
7615 (setq gnus-newsgroup-history
7616 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7618 (gnus-summary-goto-article (car to) nil t)
7619 (error "Article history empty")))
7620 (gnus-summary-position-point))
7622 ;; Summary commands and functions for limiting the summary buffer.
7624 (defun gnus-summary-limit-to-articles (n)
7625 "Limit the summary buffer to the next N articles.
7626 If not given a prefix, use the process marked articles instead."
7629 (let ((articles (gnus-summary-work-articles n)))
7630 (setq gnus-newsgroup-processable nil)
7631 (gnus-summary-limit articles))
7632 (gnus-summary-position-point)))
7634 (defun gnus-summary-pop-limit (&optional total)
7635 "Restore the previous limit.
7636 If given a prefix, remove all limits."
7639 (setq gnus-newsgroup-limits
7640 (list (mapcar (lambda (h) (mail-header-number h))
7641 gnus-newsgroup-headers))))
7642 (unless gnus-newsgroup-limits
7643 (error "No limit to pop"))
7645 (gnus-summary-limit nil 'pop)
7646 (gnus-summary-position-point)))
7648 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7649 "Limit the summary buffer to articles that have subjects that match a regexp.
7650 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7652 (list (read-string (if current-prefix-arg
7653 "Exclude subject (regexp): "
7654 "Limit to subject (regexp): "))
7655 nil current-prefix-arg))
7657 (setq header "subject"))
7658 (when (not (equal "" subject))
7660 (let ((articles (gnus-summary-find-matching
7661 (or header "subject") subject 'all nil nil
7664 (error "Found no matches for \"%s\"" subject))
7665 (gnus-summary-limit articles))
7666 (gnus-summary-position-point))))
7668 (defun gnus-summary-limit-to-author (from &optional not-matching)
7669 "Limit the summary buffer to articles that have authors that match a regexp.
7670 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7672 (list (read-string (if current-prefix-arg
7673 "Exclude author (regexp): "
7674 "Limit to author (regexp): "))
7675 current-prefix-arg))
7676 (gnus-summary-limit-to-subject from "from" not-matching))
7678 (defun gnus-summary-limit-to-age (age &optional younger-p)
7679 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7680 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7681 articles that are younger than AGE days."
7683 (let ((younger current-prefix-arg)
7686 (while (not days-got)
7687 (setq days (if younger
7688 (read-string "Limit to articles younger than (in days, older when negative): ")
7690 "Limit to articles older than (in days, younger when negative): ")))
7691 (when (> (length days) 0)
7692 (setq days (read days)))
7697 (setq younger (not younger))
7698 (setq days (* days -1))))
7699 (message "Please enter a number.")
7701 (list days younger)))
7703 (let ((data gnus-newsgroup-data)
7704 (cutoff (days-to-time age))
7705 articles d date is-younger)
7706 (while (setq d (pop data))
7707 (when (and (vectorp (gnus-data-header d))
7708 (setq date (mail-header-date (gnus-data-header d))))
7709 (setq is-younger (time-less-p
7710 (time-since (condition-case ()
7717 (push (gnus-data-number d) articles))))
7718 (gnus-summary-limit (nreverse articles)))
7719 (gnus-summary-position-point)))
7721 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7722 "Limit the summary buffer to articles that match an 'extra' header."
7726 (gnus-completing-read-with-default
7727 (symbol-name (car gnus-extra-headers))
7728 (if current-prefix-arg
7729 "Exclude extra header:"
7730 "Limit extra header:")
7732 (cons (symbol-name x) x))
7737 (read-string (format "%s header %s (regexp): "
7738 (if current-prefix-arg "Exclude" "Limit to")
7740 current-prefix-arg)))
7741 (when (not (equal "" regexp))
7743 (let ((articles (gnus-summary-find-matching
7744 (cons 'extra header) regexp 'all nil nil
7747 (error "Found no matches for \"%s\"" regexp))
7748 (gnus-summary-limit articles))
7749 (gnus-summary-position-point))))
7751 (defun gnus-summary-limit-to-display-predicate ()
7752 "Limit the summary buffer to the predicated in the `display' group parameter."
7754 (unless gnus-newsgroup-display
7755 (error "There is no `display' group parameter"))
7757 (dolist (number gnus-newsgroup-articles)
7758 (when (funcall gnus-newsgroup-display)
7759 (push number articles)))
7760 (gnus-summary-limit articles))
7761 (gnus-summary-position-point))
7763 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7765 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7767 (defun gnus-summary-limit-to-unread (&optional all)
7768 "Limit the summary buffer to articles that are not marked as read.
7769 If ALL is non-nil, limit strictly to unread articles."
7772 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7773 (gnus-summary-limit-to-marks
7774 ;; Concat all the marks that say that an article is read and have
7776 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7777 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7778 gnus-low-score-mark gnus-expirable-mark
7779 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7780 gnus-duplicate-mark gnus-souped-mark)
7783 (defun gnus-summary-limit-to-replied (&optional unreplied)
7784 "Limit the summary buffer to replied articles.
7785 If UNREPLIED (the prefix), limit to unreplied articles."
7789 (gnus-set-difference gnus-newsgroup-articles
7790 gnus-newsgroup-replied))
7791 (gnus-summary-limit gnus-newsgroup-replied))
7792 (gnus-summary-position-point))
7794 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7795 (make-obsolete 'gnus-summary-delete-marked-with
7796 'gnus-summary-limit-exclude-marks)
7798 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7799 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7800 If REVERSE, limit the summary buffer to articles that are marked
7801 with MARKS. MARKS can either be a string of marks or a list of marks.
7802 Returns how many articles were removed."
7803 (interactive "sMarks: ")
7804 (gnus-summary-limit-to-marks marks t))
7806 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7807 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7808 If REVERSE (the prefix), limit the summary buffer to articles that are
7809 not marked with MARKS. MARKS can either be a string of marks or a
7811 Returns how many articles were removed."
7812 (interactive "sMarks: \nP")
7814 (let ((data gnus-newsgroup-data)
7815 (marks (if (listp marks) marks
7816 (append marks nil))) ; Transform to list.
7819 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7820 (memq (gnus-data-mark (car data)) marks))
7821 (push (gnus-data-number (car data)) articles))
7822 (setq data (cdr data)))
7823 (gnus-summary-limit articles))
7824 (gnus-summary-position-point)))
7826 (defun gnus-summary-limit-to-score (score)
7827 "Limit to articles with score at or above SCORE."
7828 (interactive "NLimit to articles with score of at least: ")
7829 (let ((data gnus-newsgroup-data)
7832 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7834 (push (gnus-data-number (car data)) articles))
7835 (setq data (cdr data)))
7837 (gnus-summary-limit articles)
7838 (gnus-summary-position-point))))
7840 (defun gnus-summary-limit-to-unseen ()
7841 "Limit to unseen articles."
7844 (gnus-summary-limit gnus-newsgroup-unseen)
7845 (gnus-summary-position-point)))
7847 (defun gnus-summary-limit-include-thread (id)
7848 "Display all the hidden articles that is in the thread with ID in it.
7849 When called interactively, ID is the Message-ID of the current
7851 (interactive (list (mail-header-id (gnus-summary-article-header))))
7852 (let ((articles (gnus-articles-in-thread
7853 (gnus-id-to-thread (gnus-root-id id)))))
7855 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7856 (gnus-summary-limit-include-matching-articles
7858 (regexp-quote (gnus-simplify-subject-re
7859 (mail-header-subject (gnus-id-to-header id)))))
7860 (gnus-summary-position-point))))
7862 (defun gnus-summary-limit-include-matching-articles (header regexp)
7863 "Display all the hidden articles that have HEADERs that match REGEXP."
7864 (interactive (list (read-string "Match on header: ")
7865 (read-string "Regexp: ")))
7866 (let ((articles (gnus-find-matching-articles header regexp)))
7868 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7869 (gnus-summary-position-point))))
7871 (defun gnus-summary-insert-dormant-articles ()
7872 "Insert all the dormant articles for this group into the current buffer."
7874 (let ((gnus-verbose (max 6 gnus-verbose)))
7875 (if (not gnus-newsgroup-dormant)
7876 (gnus-message 3 "No cached articles for this group")
7877 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7879 (defun gnus-summary-limit-include-dormant ()
7880 "Display all the hidden articles that are marked as dormant.
7881 Note that this command only works on a subset of the articles currently
7882 fetched for this group."
7884 (unless gnus-newsgroup-dormant
7885 (error "There are no dormant articles in this group"))
7887 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7888 (gnus-summary-position-point)))
7890 (defun gnus-summary-limit-exclude-dormant ()
7891 "Hide all dormant articles."
7894 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7895 (gnus-summary-position-point)))
7897 (defun gnus-summary-limit-exclude-childless-dormant ()
7898 "Hide all dormant articles that have no children."
7900 (let ((data (gnus-data-list t))
7901 articles d children)
7902 ;; Find all articles that are either not dormant or have
7904 (while (setq d (pop data))
7905 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7907 (gnus-article-children (gnus-data-number d)))
7910 (when (memq (car children) articles)
7915 (push (gnus-data-number d) articles)))
7918 (gnus-summary-limit articles)
7919 (gnus-summary-position-point))))
7921 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7922 "Mark all unread excluded articles as read.
7923 If ALL, mark even excluded ticked and dormants as read."
7925 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7926 (let ((articles (gnus-sorted-ndifference
7928 (mapcar (lambda (h) (mail-header-number h))
7929 gnus-newsgroup-headers)
7931 gnus-newsgroup-limit))
7933 (setq gnus-newsgroup-unreads
7934 (gnus-sorted-intersection gnus-newsgroup-unreads
7935 gnus-newsgroup-limit))
7937 (setq gnus-newsgroup-dormant nil
7938 gnus-newsgroup-marked nil
7939 gnus-newsgroup-reads
7941 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7942 gnus-newsgroup-reads))
7943 (while (setq article (pop articles))
7944 (unless (or (memq article gnus-newsgroup-dormant)
7945 (memq article gnus-newsgroup-marked))
7946 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7948 (defun gnus-summary-limit (articles &optional pop)
7950 ;; We pop the previous limit off the stack and use that.
7951 (setq articles (car gnus-newsgroup-limits)
7952 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7953 ;; We use the new limit, so we push the old limit on the stack.
7954 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7956 (setq gnus-newsgroup-limit articles)
7957 (let ((total (length gnus-newsgroup-data))
7958 (data (gnus-data-find-list (gnus-summary-article-number)))
7959 (gnus-summary-mark-below nil) ; Inhibit this.
7961 ;; This will do all the work of generating the new summary buffer
7962 ;; according to the new limit.
7963 (gnus-summary-prepare)
7964 ;; Hide any threads, possibly.
7965 (gnus-summary-maybe-hide-threads)
7966 ;; Try to return to the article you were at, or one in the
7969 ;; We try to find some article after the current one.
7971 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7974 (setq data (cdr data))))
7976 ;; If there is no data, that means that we were after the last
7977 ;; article. The same goes when we can't find any articles
7978 ;; after the current one.
7979 (goto-char (point-max))
7980 (gnus-summary-find-prev))
7981 (gnus-set-mode-line 'summary)
7982 ;; We return how many articles were removed from the summary
7983 ;; buffer as a result of the new limit.
7984 (- total (length gnus-newsgroup-data))))
7986 (defsubst gnus-invisible-cut-children (threads)
7989 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7994 (defsubst gnus-cut-thread (thread)
7995 "Go forwards in the thread until we find an article that we want to display."
7996 (when (or (eq gnus-fetch-old-headers 'some)
7997 (eq gnus-fetch-old-headers 'invisible)
7998 (numberp gnus-fetch-old-headers)
7999 (eq gnus-build-sparse-threads 'some)
8000 (eq gnus-build-sparse-threads 'more))
8001 ;; Deal with old-fetched headers and sparse threads.
8005 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8006 (gnus-summary-article-ancient-p
8007 (mail-header-number (car thread))))
8008 (if (or (<= (length (cdr thread)) 1)
8009 (eq gnus-fetch-old-headers 'invisible))
8010 (setq gnus-newsgroup-limit
8011 (delq (mail-header-number (car thread))
8012 gnus-newsgroup-limit)
8013 thread (cadr thread))
8014 (when (gnus-invisible-cut-children (cdr thread))
8015 (let ((th (cdr thread)))
8017 (if (memq (mail-header-number (caar th))
8018 gnus-newsgroup-limit)
8019 (setq thread (car th)
8021 (setq th (cdr th))))))))))
8024 (defun gnus-cut-threads (threads)
8025 "Cut off all uninteresting articles from the beginning of THREADS."
8026 (when (or (eq gnus-fetch-old-headers 'some)
8027 (eq gnus-fetch-old-headers 'invisible)
8028 (numberp gnus-fetch-old-headers)
8029 (eq gnus-build-sparse-threads 'some)
8030 (eq gnus-build-sparse-threads 'more))
8033 (setcar th (gnus-cut-thread (car th)))
8034 (setq th (cdr th)))))
8035 ;; Remove nixed out threads.
8038 (defun gnus-summary-initial-limit (&optional show-if-empty)
8039 "Figure out what the initial limit is supposed to be on group entry.
8040 This entails weeding out unwanted dormants, low-scored articles,
8041 fetch-old-headers verbiage, and so on."
8042 ;; Most groups have nothing to remove.
8043 (if (or gnus-inhibit-limiting
8044 (and (null gnus-newsgroup-dormant)
8045 (eq gnus-newsgroup-display 'gnus-not-ignore)
8046 (not (eq gnus-fetch-old-headers 'some))
8047 (not (numberp gnus-fetch-old-headers))
8048 (not (eq gnus-fetch-old-headers 'invisible))
8049 (null gnus-summary-expunge-below)
8050 (not (eq gnus-build-sparse-threads 'some))
8051 (not (eq gnus-build-sparse-threads 'more))
8052 (null gnus-thread-expunge-below)
8053 (not gnus-use-nocem)))
8055 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8056 (setq gnus-newsgroup-limit nil)
8059 (unless (car (symbol-value node))
8060 ;; These threads have no parents -- they are roots.
8061 (let ((nodes (cdr (symbol-value node)))
8064 (if (and gnus-thread-expunge-below
8065 (< (gnus-thread-total-score (car nodes))
8066 gnus-thread-expunge-below))
8067 (gnus-expunge-thread (pop nodes))
8068 (setq thread (pop nodes))
8069 (gnus-summary-limit-children thread))))))
8070 gnus-newsgroup-dependencies)
8071 ;; If this limitation resulted in an empty group, we might
8072 ;; pop the previous limit and use it instead.
8073 (when (and (not gnus-newsgroup-limit)
8075 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8076 gnus-newsgroup-limit))
8078 (defun gnus-summary-limit-children (thread)
8079 "Return 1 if this subthread is visible and 0 if it is not."
8080 ;; First we get the number of visible children to this thread. This
8081 ;; is done by recursing down the thread using this function, so this
8082 ;; will really go down to a leaf article first, before slowly
8083 ;; working its way up towards the root.
8085 (let* ((max-lisp-eval-depth 5000)
8088 (apply '+ (mapcar 'gnus-summary-limit-children
8091 (number (mail-header-number (car thread)))
8094 (not (memq number gnus-newsgroup-marked))
8096 ;; If this article is dormant and has absolutely no visible
8097 ;; children, then this article isn't visible.
8098 (and (memq number gnus-newsgroup-dormant)
8100 ;; If this is "fetch-old-headered" and there is no
8101 ;; visible children, then we don't want this article.
8102 (and (or (eq gnus-fetch-old-headers 'some)
8103 (numberp gnus-fetch-old-headers))
8104 (gnus-summary-article-ancient-p number)
8106 ;; If this is "fetch-old-headered" and `invisible', then
8107 ;; we don't want this article.
8108 (and (eq gnus-fetch-old-headers 'invisible)
8109 (gnus-summary-article-ancient-p number))
8110 ;; If this is a sparsely inserted article with no children,
8111 ;; we don't want it.
8112 (and (eq gnus-build-sparse-threads 'some)
8113 (gnus-summary-article-sparse-p number)
8115 ;; If we use expunging, and this article is really
8116 ;; low-scored, then we don't want this article.
8117 (when (and gnus-summary-expunge-below
8119 (or (cdr (assq number gnus-newsgroup-scored))
8120 gnus-summary-default-score))
8121 gnus-summary-expunge-below))
8122 ;; We increase the expunge-tally here, but that has
8123 ;; nothing to do with the limits, really.
8124 (incf gnus-newsgroup-expunged-tally)
8125 ;; We also mark as read here, if that's wanted.
8126 (when (and gnus-summary-mark-below
8127 (< score gnus-summary-mark-below))
8128 (setq gnus-newsgroup-unreads
8129 (delq number gnus-newsgroup-unreads))
8130 (if gnus-newsgroup-auto-expire
8131 (push number gnus-newsgroup-expirable)
8132 (push (cons number gnus-low-score-mark)
8133 gnus-newsgroup-reads)))
8135 ;; Do the `display' group parameter.
8136 (and gnus-newsgroup-display
8137 (not (funcall gnus-newsgroup-display)))
8138 ;; Check NoCeM things.
8139 (when (and gnus-use-nocem
8140 (gnus-nocem-unwanted-article-p
8141 (mail-header-id (car thread))))
8142 (setq gnus-newsgroup-unreads
8143 (delq number gnus-newsgroup-unreads))
8145 ;; Nope, invisible article.
8147 ;; Ok, this article is to be visible, so we add it to the limit
8149 (push number gnus-newsgroup-limit)
8152 (defun gnus-expunge-thread (thread)
8153 "Mark all articles in THREAD as read."
8154 (let* ((number (mail-header-number (car thread))))
8155 (incf gnus-newsgroup-expunged-tally)
8156 ;; We also mark as read here, if that's wanted.
8157 (setq gnus-newsgroup-unreads
8158 (delq number gnus-newsgroup-unreads))
8159 (if gnus-newsgroup-auto-expire
8160 (push number gnus-newsgroup-expirable)
8161 (push (cons number gnus-low-score-mark)
8162 gnus-newsgroup-reads)))
8163 ;; Go recursively through all subthreads.
8164 (mapcar 'gnus-expunge-thread (cdr thread)))
8166 ;; Summary article oriented commands
8168 (defun gnus-summary-refer-parent-article (n)
8169 "Refer parent article N times.
8170 If N is negative, go to ancestor -N instead.
8171 The difference between N and the number of articles fetched is returned."
8175 (when (not (natnump n))
8180 (setq header (gnus-summary-article-header))
8181 (if (and (eq (mail-header-number header)
8182 (cdr gnus-article-current))
8183 (equal gnus-newsgroup-name
8184 (car gnus-article-current)))
8185 ;; If we try to find the parent of the currently
8186 ;; displayed article, then we take a look at the actual
8187 ;; References header, since this is slightly more
8188 ;; reliable than the References field we got from the
8191 (set-buffer gnus-original-article-buffer)
8192 (nnheader-narrow-to-headers)
8193 (unless (setq ref (message-fetch-field "references"))
8194 (when (setq ref (message-fetch-field "in-reply-to"))
8195 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8198 ;; It's not the current article, so we take a bet on
8199 ;; the value we got from the server.
8200 (mail-header-references header)))
8202 (not (equal ref "")))
8203 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8204 (gnus-message 1 "Couldn't find parent"))
8205 (gnus-message 1 "No references in article %d"
8206 (gnus-summary-article-number))
8209 (gnus-summary-position-point)
8212 (defun gnus-summary-refer-references ()
8213 "Fetch all articles mentioned in the References header.
8214 Return the number of articles fetched."
8216 (let ((ref (mail-header-references (gnus-summary-article-header)))
8217 (current (gnus-summary-article-number))
8221 (error "No References in the current article")
8222 ;; For each Message-ID in the References header...
8223 (while (string-match "<[^>]*>" ref)
8225 ;; ... fetch that article.
8226 (gnus-summary-refer-article
8227 (prog1 (match-string 0 ref)
8228 (setq ref (substring ref (match-end 0))))))
8229 (gnus-summary-goto-subject current)
8230 (gnus-summary-position-point)
8233 (defun gnus-summary-refer-thread (&optional limit)
8234 "Fetch all articles in the current thread.
8235 If LIMIT (the numerical prefix), fetch that many old headers instead
8236 of what's specified by the `gnus-refer-thread-limit' variable."
8238 (let ((id (mail-header-id (gnus-summary-article-header)))
8239 (limit (if limit (prefix-numeric-value limit)
8240 gnus-refer-thread-limit)))
8241 (unless (eq gnus-fetch-old-headers 'invisible)
8242 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8243 ;; Retrieve the headers and read them in.
8244 (if (eq (if (numberp limit)
8245 (gnus-retrieve-headers
8247 (+ (mail-header-number
8248 (gnus-summary-article-header))
8250 gnus-newsgroup-end))
8251 gnus-newsgroup-name (* limit 2))
8252 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8254 (gnus-retrieve-headers (list gnus-newsgroup-end)
8255 gnus-newsgroup-name limit))
8257 (gnus-build-all-threads)
8258 (error "Can't fetch thread from back ends that don't support NOV"))
8259 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8260 (gnus-summary-limit-include-thread id)))
8262 (defun gnus-summary-refer-article (message-id)
8263 "Fetch an article specified by MESSAGE-ID."
8264 (interactive "sMessage-ID: ")
8265 (when (and (stringp message-id)
8266 (not (zerop (length message-id))))
8267 (setq message-id (gnus-replace-in-string message-id " " ""))
8268 ;; Construct the correct Message-ID if necessary.
8269 ;; Suggested by tale@pawl.rpi.edu.
8270 (unless (string-match "^<" message-id)
8271 (setq message-id (concat "<" message-id)))
8272 (unless (string-match ">$" message-id)
8273 (setq message-id (concat message-id ">")))
8274 ;; People often post MIDs from URLs, so unhex it:
8275 (unless (string-match "@" message-id)
8276 (setq message-id (gnus-url-unhex-string message-id)))
8277 (let* ((header (gnus-id-to-header message-id))
8279 (gnus-summary-article-sparse-p
8280 (mail-header-number header))
8281 (memq (mail-header-number header)
8282 gnus-newsgroup-limit)))
8285 ;; If the article is present in the buffer we just go to it.
8287 (or (not (gnus-summary-article-sparse-p
8288 (mail-header-number header)))
8291 (gnus-summary-goto-article
8292 (mail-header-number header) nil t)
8294 (gnus-summary-update-article (mail-header-number header)))))
8296 ;; We fetch the article.
8298 (dolist (gnus-override-method (gnus-refer-article-methods))
8299 (when (and (gnus-check-server gnus-override-method)
8300 ;; Fetch the header,
8301 (setq number (gnus-summary-insert-subject message-id)))
8302 ;; and display the article.
8303 (gnus-summary-select-article nil nil nil number)
8305 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8307 (defun gnus-refer-article-methods ()
8308 "Return a list of referable methods."
8310 ;; No method, so we default to current and native.
8311 ((null gnus-refer-article-method)
8312 (list gnus-current-select-method gnus-select-method))
8314 ((eq 'current gnus-refer-article-method)
8315 (list gnus-current-select-method))
8316 ;; List of select methods.
8317 ((not (and (symbolp (car gnus-refer-article-method))
8318 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8320 (dolist (method gnus-refer-article-method)
8321 (push (if (eq 'current method)
8322 gnus-current-select-method
8326 ;; One single select method.
8328 (list gnus-refer-article-method))))
8330 (defun gnus-summary-edit-parameters ()
8331 "Edit the group parameters of the current group."
8333 (gnus-group-edit-group gnus-newsgroup-name 'params))
8335 (defun gnus-summary-customize-parameters ()
8336 "Customize the group parameters of the current group."
8338 (gnus-group-customize gnus-newsgroup-name))
8340 (defun gnus-summary-enter-digest-group (&optional force)
8341 "Enter an nndoc group based on the current article.
8342 If FORCE, force a digest interpretation. If not, try
8343 to guess what the document format is."
8345 (let ((conf gnus-current-window-configuration))
8346 (save-window-excursion
8348 (let (gnus-article-prepare-hook
8349 gnus-display-mime-function
8351 (gnus-summary-select-article))))
8352 (setq gnus-current-window-configuration conf)
8353 (let* ((name (format "%s-%d"
8354 (gnus-group-prefixed-name
8355 gnus-newsgroup-name (list 'nndoc ""))
8356 (with-current-buffer gnus-summary-buffer
8357 gnus-current-article)))
8358 (ogroup gnus-newsgroup-name)
8359 (params (append (gnus-info-params (gnus-get-info ogroup))
8360 (list (cons 'to-group ogroup))
8361 (list (cons 'parent-group ogroup))
8362 (list (cons 'save-article-group ogroup))))
8363 (case-fold-search t)
8364 (buf (current-buffer))
8367 (set-buffer gnus-original-article-buffer)
8368 ;; Have the digest group inherit the main mail address of
8369 ;; the parent article.
8370 (when (setq to-address (or (gnus-fetch-field "reply-to")
8371 (gnus-fetch-field "from")))
8372 (setq params (append
8373 (list (cons 'to-address
8374 (funcall gnus-decode-encoded-word-function
8376 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8377 (insert-buffer-substring gnus-original-article-buffer)
8378 ;; Remove lines that may lead nndoc to misinterpret the
8381 (goto-char (point-min))
8382 (or (search-forward "\n\n" nil t) (point)))
8383 (goto-char (point-min))
8384 (delete-matching-lines "^Path:\\|^From ")
8387 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8388 (gnus-newsgroup-ephemeral-ignored-charsets
8389 gnus-newsgroup-ignored-charsets))
8390 (gnus-group-read-ephemeral-group
8391 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8393 ,(if force 'mbox 'guess)))
8395 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8397 ;; Make all postings to this group go to the parent group.
8398 (nconc (gnus-info-params (gnus-get-info name))
8400 ;; Couldn't select this doc group.
8401 (switch-to-buffer buf)
8402 (gnus-set-global-variables)
8403 (gnus-configure-windows 'summary)
8404 (gnus-message 3 "Article couldn't be entered?"))
8405 (kill-buffer dig)))))
8407 (defun gnus-summary-read-document (n)
8408 "Open a new group based on the current article(s).
8409 This will allow you to read digests and other similar
8410 documents as newsgroups.
8411 Obeys the standard process/prefix convention."
8413 (let* ((ogroup gnus-newsgroup-name)
8414 (params (append (gnus-info-params (gnus-get-info ogroup))
8415 (list (cons 'to-group ogroup))))
8416 group egroup groups vgroup)
8417 (dolist (article (gnus-summary-work-articles n))
8418 (setq group (format "%s-%d" gnus-newsgroup-name article))
8419 (gnus-summary-remove-process-mark article)
8420 (when (gnus-summary-display-article article)
8423 (insert-buffer-substring gnus-original-article-buffer)
8424 ;; Remove some headers that may lead nndoc to make
8426 (message-narrow-to-head)
8427 (goto-char (point-min))
8428 (delete-matching-lines "^Path:\\|^From ")
8431 (gnus-group-read-ephemeral-group
8432 group `(nndoc ,group (nndoc-address ,(current-buffer))
8433 (nndoc-article-type guess))
8436 ;; Make all postings to this group go to the parent group.
8437 (nconc (gnus-info-params (gnus-get-info egroup))
8439 (push egroup groups))
8440 ;; Couldn't select this doc group.
8441 (gnus-error 3 "Article couldn't be entered"))))))
8442 ;; Now we have selected all the documents.
8445 (error "None of the articles could be interpreted as documents"))
8446 ((gnus-group-read-ephemeral-group
8447 (setq vgroup (format
8448 "nnvirtual:%s-%s" gnus-newsgroup-name
8449 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8450 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8452 (cons (current-buffer) 'summary)))
8454 (error "Couldn't select virtual nndoc group")))))
8456 (defun gnus-summary-isearch-article (&optional regexp-p)
8457 "Do incremental search forward on the current article.
8458 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8460 (let* ((gnus-inhibit-treatment t)
8461 (old (gnus-summary-select-article)))
8462 (gnus-configure-windows 'article)
8463 (gnus-eval-in-buffer-window gnus-article-buffer
8467 (gnus-article-show-all-headers))
8468 (goto-char (point-min))
8469 (isearch-forward regexp-p)))))
8471 (defun gnus-summary-search-article-forward (regexp &optional backward)
8472 "Search for an article containing REGEXP forward.
8473 If BACKWARD, search backward instead."
8476 (format "Search article %s (regexp%s): "
8477 (if current-prefix-arg "backward" "forward")
8478 (if gnus-last-search-regexp
8479 (concat ", default " gnus-last-search-regexp)
8481 current-prefix-arg))
8482 (if (string-equal regexp "")
8483 (setq regexp (or gnus-last-search-regexp ""))
8484 (setq gnus-last-search-regexp regexp)
8485 (setq gnus-article-before-search gnus-current-article))
8486 ;; Intentionally set gnus-last-article.
8487 (setq gnus-last-article gnus-article-before-search)
8488 (let ((gnus-last-article gnus-last-article))
8489 (if (gnus-summary-search-article regexp backward)
8490 (gnus-summary-show-thread)
8491 (signal 'search-failed (list regexp)))))
8493 (defun gnus-summary-search-article-backward (regexp)
8494 "Search for an article containing REGEXP backward."
8497 (format "Search article backward (regexp%s): "
8498 (if gnus-last-search-regexp
8499 (concat ", default " gnus-last-search-regexp)
8501 (gnus-summary-search-article-forward regexp 'backward))
8504 (defmacro gnus-summary-search-article-position-point (regexp backward)
8505 "Dehighlight the last matched text and goto the beginning position."
8506 (` (if (and gnus-summary-search-article-matched-data
8507 (let ((text (caddr gnus-summary-search-article-matched-data))
8508 (inhibit-read-only t)
8511 (goto-char (car gnus-summary-search-article-matched-data))
8512 (cadr gnus-summary-search-article-matched-data))
8514 (string-match (, regexp) text)))
8515 (if (, backward) (beginning-of-line) (end-of-line))
8516 (goto-char (if (, backward) (point-max) (point-min))))))
8518 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8519 "Place point where X-Face image is displayed."
8520 (if (featurep 'xemacs)
8521 (` (let ((end (if (search-forward "\n\n" nil t)
8522 (goto-char (1- (point)))
8525 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8526 (unless (and (re-search-forward "^From:" end t)
8527 (setq extent (extent-at (point)))
8528 (extent-begin-glyph extent))
8529 (goto-char (, opoint)))))
8530 (` (let ((end (if (search-forward "\n\n" nil t)
8531 (goto-char (1- (point)))
8533 (start (or (search-backward "\n\n" nil t) (point-min))))
8535 (or (text-property-any start end 'x-face-image t);; x-face-e21
8536 (text-property-any start end 'x-face-mule-bitmap-image t)
8539 (defmacro gnus-summary-search-article-highlight-matched-text
8540 (backward treated x-face)
8541 "Highlight matched text in the function `gnus-summary-search-article'."
8542 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8543 (end (set-marker (make-marker) (match-end 0)))
8544 (inhibit-read-only t)
8548 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8550 (lambda (item) (setq items (delq item items)))
8551 '(gnus-treat-buttonize
8552 gnus-treat-fill-article
8553 gnus-treat-fill-long-lines
8554 gnus-treat-emphasize
8555 gnus-treat-highlight-headers
8556 gnus-treat-highlight-citation
8557 gnus-treat-highlight-signature
8558 gnus-treat-overstrike
8559 gnus-treat-display-x-face
8560 gnus-treat-buttonize-head
8561 gnus-treat-decode-article-as-default-mime-charset))
8562 (static-if (featurep 'xemacs)
8564 (cons '(x-face-mule-delete-x-face-field
8567 (gnus-treat-display-x-face
8568 (when (, x-face) gnus-treat-display-x-face)))
8569 (gnus-article-prepare-mime-display)))
8570 (goto-char (if (, backward) start end))
8572 (gnus-summary-search-article-highlight-goto-x-face (point)))
8573 (setq gnus-summary-search-article-matched-data
8574 (list start end (buffer-substring start end)))
8575 (unless (eq start end);; matched text has been deleted. :-<
8576 (put-text-property start end 'face
8577 (or (find-face 'isearch)
8578 'secondary-selection))))))
8581 (defun gnus-summary-search-article (regexp &optional backward)
8582 "Search for an article containing REGEXP.
8583 Optional argument BACKWARD means do search for backward.
8584 `gnus-select-article-hook' is not called during the search."
8585 ;; We have to require this here to make sure that the following
8586 ;; dynamic binding isn't shadowed by autoloading.
8587 (require 'gnus-async)
8589 (let ((gnus-select-article-hook nil) ;Disable hook.
8590 (gnus-article-prepare-hook nil)
8591 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8592 (gnus-use-article-prefetch nil)
8593 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8594 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8596 (gnus-keep-backlog nil)
8597 (gnus-break-pages nil)
8598 (gnus-summary-display-arrow nil)
8599 (gnus-updated-mode-lines nil)
8600 (gnus-auto-center-summary nil)
8601 (sum (current-buffer))
8604 (gnus-save-hidden-threads
8605 (static-if (featurep 'xemacs)
8606 (let ((gnus-inhibit-treatment t))
8607 (setq treated (eq 'old (gnus-summary-select-article)))
8609 (not (and (gnus-buffer-live-p gnus-article-buffer)
8610 (window-live-p (get-buffer-window
8611 gnus-article-buffer t)))))
8612 (gnus-summary-select-article nil t)
8613 (setq treated nil)))
8614 (let ((gnus-inhibit-treatment t)
8615 (x-face-mule-delete-x-face-field 'never))
8616 (setq treated (eq 'old (gnus-summary-select-article)))
8619 (and (gnus-buffer-live-p gnus-article-buffer)
8620 (window-live-p (get-buffer-window
8621 gnus-article-buffer t))
8622 (or (not (string-match "^\\^X-Face:" regexp))
8623 (with-current-buffer gnus-article-buffer
8624 gnus-summary-search-article-matched-data)))))
8625 (gnus-summary-select-article nil t)
8626 (setq treated nil))))
8627 (set-buffer gnus-article-buffer)
8631 (gnus-article-show-all-headers)
8632 (gnus-summary-search-article-position-point regexp backward))
8633 (goto-char (if backward (point-max) (point-min))))
8635 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8637 (re-search-backward regexp nil t)
8638 (re-search-forward regexp nil t))
8639 ;; We found the regexp.
8641 (gnus-summary-search-article-highlight-matched-text
8642 backward treated (string-match "^\\^X-Face:" regexp))
8645 (/ (- 2 (window-height
8646 (get-buffer-window gnus-article-buffer t)))
8649 (get-buffer-window (current-buffer))
8652 (setq point (point)))
8653 ;; We didn't find it, so we go to the next article.
8656 (while (eq found 'not)
8657 (if (not (if backward (gnus-summary-find-prev)
8658 (gnus-summary-find-next)))
8659 ;; No more articles.
8661 ;; Select the next article and adjust point.
8662 (unless (gnus-summary-article-sparse-p
8663 (gnus-summary-article-number))
8665 (let ((gnus-inhibit-treatment t))
8666 (gnus-summary-select-article))
8668 (set-buffer gnus-article-buffer)
8670 (goto-char (if backward (point-max) (point-min))))))))
8671 (gnus-message 7 ""))
8672 ;; Return whether we found the regexp.
8673 (when (eq found 'found)
8675 (gnus-summary-show-thread)
8676 (gnus-summary-goto-subject gnus-current-article)
8677 (gnus-summary-position-point)
8680 (defun gnus-find-matching-articles (header regexp)
8681 "Return a list of all articles that match REGEXP on HEADER.
8682 This search includes all articles in the current group that Gnus has
8683 fetched headers for, whether they are displayed or not."
8684 (let ((articles nil)
8685 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8686 (case-fold-search t))
8687 (dolist (header gnus-newsgroup-headers)
8688 (when (string-match regexp (funcall func header))
8689 (push (mail-header-number header) articles)))
8690 (nreverse articles)))
8692 (defun gnus-summary-find-matching (header regexp &optional backward unread
8693 not-case-fold not-matching)
8694 "Return a list of all articles that match REGEXP on HEADER.
8695 The search stars on the current article and goes forwards unless
8696 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8697 If UNREAD is non-nil, only unread articles will
8698 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8699 in the comparisons. If NOT-MATCHING, return a list of all articles that
8700 not match REGEXP on HEADER."
8701 (let ((case-fold-search (not not-case-fold))
8704 (if (eq (car header) 'extra)
8707 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8709 (error "%s is an invalid header" header))
8710 (unless (fboundp (intern (concat "mail-header-" header)))
8711 (error "%s is not a valid header" header))
8712 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8713 (dolist (d (if (eq backward 'all)
8715 (gnus-data-find-list
8716 (gnus-summary-article-number)
8717 (gnus-data-list backward))))
8718 (when (and (or (not unread) ; We want all articles...
8719 (gnus-data-unread-p d)) ; Or just unreads.
8720 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8724 (funcall func (gnus-data-header d))))
8725 (string-match regexp
8726 (funcall func (gnus-data-header d)))))
8727 (push (gnus-data-number d) articles))) ; Success!
8728 (nreverse articles)))
8730 (defun gnus-summary-execute-command (header regexp command &optional backward)
8731 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8732 If HEADER is an empty string (or nil), the match is done on the entire
8733 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8735 (list (let ((completion-ignore-case t))
8738 (mapcar (lambda (header) (list (format "%s" header)))
8740 '("Number" "Subject" "From" "Lines" "Date"
8741 "Message-ID" "Xref" "References" "Body")
8742 gnus-extra-headers))
8743 nil 'require-match))
8744 (read-string "Regexp: ")
8745 (read-key-sequence "Command: ")
8746 current-prefix-arg))
8747 (when (equal header "Body")
8749 ;; Hidden thread subtrees must be searched as well.
8750 (gnus-summary-show-all-threads)
8751 ;; We don't want to change current point nor window configuration.
8753 (save-window-excursion
8755 gnus-treat-strip-trailing-blank-lines
8756 gnus-treat-strip-leading-blank-lines
8757 gnus-treat-strip-multiple-blank-lines
8758 gnus-treat-hide-boring-headers
8759 gnus-treat-fold-newsgroups
8760 gnus-article-prepare-hook)
8761 (gnus-message 6 "Executing %s..." (key-description command))
8762 ;; We'd like to execute COMMAND interactively so as to give arguments.
8763 (gnus-execute header regexp
8764 `(call-interactively ',(key-binding command))
8766 (gnus-message 6 "Executing %s...done" (key-description command))))))
8768 (defun gnus-summary-beginning-of-article ()
8769 "Scroll the article back to the beginning."
8771 (gnus-summary-select-article)
8772 (gnus-configure-windows 'article)
8773 (gnus-eval-in-buffer-window gnus-article-buffer
8775 (goto-char (point-min))
8776 (when gnus-break-pages
8777 (gnus-narrow-to-page))))
8779 (defun gnus-summary-end-of-article ()
8780 "Scroll to the end of the article."
8782 (gnus-summary-select-article)
8783 (gnus-configure-windows 'article)
8784 (gnus-eval-in-buffer-window gnus-article-buffer
8786 (goto-char (point-max))
8788 (when gnus-break-pages
8789 (when (re-search-backward page-delimiter nil t)
8790 (narrow-to-region (match-end 0) (point-max)))
8791 (gnus-narrow-to-page))))
8793 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8794 "Truncate to LEN and quote all \"(\"'s in STRING."
8795 (gnus-replace-in-string (if (and len (> (length string) len))
8796 (substring string 0 len)
8800 (defun gnus-summary-print-article (&optional filename n)
8801 "Generate and print a PostScript image of the process-marked (mail) articles.
8803 If used interactively, print the current article if none are
8804 process-marked. With prefix arg, prompt the user for the name of the
8807 When used from Lisp, accept two optional args FILENAME and N. N means
8808 to print the next N articles. If N is negative, print the N previous
8809 articles. If N is nil and articles have been marked with the process
8810 mark, print these instead.
8812 If the optional first argument FILENAME is nil, send the image to the
8813 printer. If FILENAME is a string, save the PostScript image in a file with
8814 that name. If FILENAME is a number, prompt the user for the name of the file
8816 (interactive (list (ps-print-preprint current-prefix-arg)))
8817 (dolist (article (gnus-summary-work-articles n))
8818 (gnus-summary-select-article nil nil 'pseudo article)
8819 (gnus-eval-in-buffer-window gnus-article-buffer
8820 (gnus-print-buffer))
8821 (gnus-summary-remove-process-mark article))
8822 (ps-despool filename))
8824 (defun gnus-print-buffer ()
8825 (let ((buffer (generate-new-buffer " *print*")))
8828 (copy-to-buffer buffer (point-min) (point-max))
8830 (gnus-remove-text-with-property 'gnus-decoration)
8831 (when (gnus-visual-p 'article-highlight 'highlight)
8832 ;; Copy-to-buffer doesn't copy overlay. So redo
8834 (let ((gnus-article-buffer buffer))
8835 (gnus-article-highlight-citation t)
8836 (gnus-article-highlight-signature)
8837 (gnus-article-emphasize)
8838 (gnus-article-delete-invisible-text)))
8839 (let ((ps-left-header
8842 (gnus-summary-print-truncate-and-quote
8843 (mail-header-subject gnus-current-headers)
8846 (gnus-summary-print-truncate-and-quote
8847 (mail-header-from gnus-current-headers)
8851 "/pagenumberstring load"
8853 (mail-header-date gnus-current-headers) ")"))))
8854 (gnus-run-hooks 'gnus-ps-print-hook)
8857 (ps-spool-buffer-with-faces)
8858 (ps-spool-buffer)))))
8859 (kill-buffer buffer))))
8861 (defun gnus-summary-show-article (&optional arg)
8862 "Force redisplaying of the current article.
8863 If ARG (the prefix) is a number, show the article with the charset
8864 defined in `gnus-summary-show-article-charset-alist', or the charset
8866 If ARG (the prefix) is non-nil and not a number, show the raw article
8867 without any article massaging functions being run. Normally, the key
8868 strokes are `C-u g'."
8872 (gnus-summary-show-article t)
8873 (let* ((gnus-newsgroup-charset
8874 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8875 (mm-read-coding-system
8876 "View as charset: " ;; actually it is coding system.
8877 (with-current-buffer gnus-article-buffer
8878 (mm-detect-coding-region (point) (point-max))))))
8879 (default-mime-charset gnus-newsgroup-charset)
8880 (gnus-newsgroup-ignored-charsets 'gnus-all))
8881 (gnus-summary-select-article nil 'force)
8882 (let ((deps gnus-newsgroup-dependencies)
8885 (set-buffer gnus-original-article-buffer)
8887 (message-narrow-to-head)
8888 (setq head (buffer-string))
8889 (goto-char (point-min))
8890 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8891 (goto-char (point-max))
8893 (setq lines (1- (count-lines (point) (point-max))))))
8895 (insert (format "211 %d Article retrieved.\n"
8896 (cdr gnus-article-current)))
8898 (if lines (insert (format "Lines: %d\n" lines)))
8900 (let ((nntp-server-buffer (current-buffer)))
8901 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8902 (gnus-data-set-header
8903 (gnus-data-find (cdr gnus-article-current))
8905 (gnus-summary-update-article-line
8906 (cdr gnus-article-current) header)
8907 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8908 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8910 ;; Select the article the normal way.
8911 (gnus-summary-select-article nil 'force))
8913 ;; We have to require this here to make sure that the following
8914 ;; dynamic binding isn't shadowed by autoloading.
8915 (require 'gnus-async)
8917 ;; Bind the article treatment functions to nil.
8918 (let ((gnus-have-all-headers t)
8919 gnus-article-prepare-hook
8920 gnus-article-decode-hook
8923 (gnus-inhibit-treatment t))
8924 (gnus-summary-select-article nil 'force))))
8925 (gnus-summary-goto-subject gnus-current-article)
8926 (gnus-summary-position-point))
8928 (defun gnus-summary-show-raw-article ()
8929 "Show the raw article without any article massaging functions being run."
8931 (gnus-summary-show-article t))
8933 (defun gnus-summary-verbose-headers (&optional arg)
8934 "Toggle permanent full header display.
8935 If ARG is a positive number, turn header display on.
8936 If ARG is a negative number, turn header display off."
8938 (setq gnus-show-all-headers
8939 (cond ((or (not (numberp arg))
8941 (not gnus-show-all-headers))
8944 (gnus-summary-show-article))
8946 (defun gnus-summary-toggle-header (&optional arg)
8947 "Show the headers if they are hidden, or hide them if they are shown.
8948 If ARG is a positive number, show the entire header.
8949 If ARG is a negative number, hide the unwanted header lines."
8951 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8952 (get-buffer-window gnus-article-buffer t))))
8953 (with-current-buffer gnus-article-buffer
8955 (article-narrow-to-head)
8956 (let* ((buffer-read-only nil)
8957 (inhibit-point-motion-hooks t)
8958 (hidden (if (numberp arg)
8960 (or (not (looking-at "[^ \t\n]+:"))
8961 (gnus-article-hidden-text-p 'headers))))
8963 (delete-region (point-min) (point-max))
8964 (with-current-buffer gnus-original-article-buffer
8965 (goto-char (setq s (point-min)))
8966 (setq e (if (search-forward "\n\n" nil t)
8969 (insert-buffer-substring gnus-original-article-buffer s e)
8970 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8971 ;; article-decode-encoded-words by default.
8972 (article-decode-encoded-words)
8973 (run-hooks 'gnus-article-decode-hook)
8975 (let ((gnus-treat-hide-headers nil)
8976 (gnus-treat-hide-boring-headers nil))
8977 (gnus-delete-wash-type 'headers)
8978 (gnus-treat-article 'head))
8979 (gnus-treat-article 'head))
8982 (set-window-start window (goto-char (point-min))))
8983 (if gnus-break-pages
8984 (gnus-narrow-to-page)
8985 (when (gnus-visual-p 'page-marker)
8986 (let ((buffer-read-only nil))
8987 (gnus-remove-text-with-property 'gnus-prev)
8988 (gnus-remove-text-with-property 'gnus-next))))
8989 (gnus-set-mode-line 'article)))))
8991 (defun gnus-summary-show-all-headers ()
8992 "Make all header lines visible."
8994 (gnus-summary-toggle-header 1))
8996 (defun gnus-summary-toggle-mime (&optional arg)
8997 "Toggle MIME processing.
8998 If ARG is a positive number, turn MIME processing on."
9000 (setq gnus-show-mime
9002 (not gnus-show-mime)
9003 (> (prefix-numeric-value arg) 0)))
9004 (gnus-summary-select-article t 'force))
9006 (defun gnus-summary-caesar-message (&optional arg)
9007 "Caesar rotate the current article by 13.
9008 The numerical prefix specifies how many places to rotate each letter
9011 (gnus-summary-select-article)
9012 (let ((mail-header-separator ""))
9013 (gnus-eval-in-buffer-window gnus-article-buffer
9016 (let ((start (window-start))
9018 (message-caesar-buffer-body arg)
9019 (set-window-start (get-buffer-window (current-buffer)) start))))))
9021 (autoload 'unmorse-region "morse"
9022 "Convert morse coded text in region to ordinary ASCII text."
9025 (defun gnus-summary-morse-message (&optional arg)
9026 "Morse decode the current article."
9028 (gnus-summary-select-article)
9029 (let ((mail-header-separator ""))
9030 (gnus-eval-in-buffer-window gnus-article-buffer
9034 (let ((pos (window-start))
9036 (goto-char (point-min))
9037 (when (message-goto-body)
9038 (gnus-narrow-to-body))
9039 (goto-char (point-min))
9040 (while (search-forward "·" (point-max) t)
9041 (replace-match "."))
9042 (unmorse-region (point-min) (point-max))
9044 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9046 (defun gnus-summary-stop-page-breaking ()
9047 "Stop page breaking in the current article."
9049 (gnus-summary-select-article)
9050 (gnus-eval-in-buffer-window gnus-article-buffer
9052 (when (gnus-visual-p 'page-marker)
9053 (let ((buffer-read-only nil))
9054 (gnus-remove-text-with-property 'gnus-prev)
9055 (gnus-remove-text-with-property 'gnus-next))
9056 (setq gnus-page-broken nil))))
9058 (defun gnus-summary-move-article (&optional n to-newsgroup
9059 select-method action)
9060 "Move the current article to a different newsgroup.
9061 If N is a positive number, move the N next articles.
9062 If N is a negative number, move the N previous articles.
9063 If N is nil and any articles have been marked with the process mark,
9064 move those articles instead.
9065 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9066 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9067 re-spool using this method.
9069 When called interactively with TO-NEWSGROUP being nil, the value of
9070 the variable `gnus-move-split-methods' is used for finding a default
9071 for the target newsgroup.
9073 For this function to work, both the current newsgroup and the
9074 newsgroup that you want to move to have to support the `request-move'
9075 and `request-accept' functions.
9077 ACTION can be either `move' (the default), `crosspost' or `copy'."
9080 (setq action 'move))
9081 ;; Check whether the source group supports the required functions.
9082 (cond ((and (eq action 'move)
9083 (not (gnus-check-backend-function
9084 'request-move-article gnus-newsgroup-name)))
9085 (error "The current group does not support article moving"))
9086 ((and (eq action 'crosspost)
9087 (not (gnus-check-backend-function
9088 'request-replace-article gnus-newsgroup-name)))
9089 (error "The current group does not support article editing")))
9090 (let ((articles (gnus-summary-work-articles n))
9091 (prefix (if (gnus-check-backend-function
9092 'request-move-article gnus-newsgroup-name)
9093 (funcall gnus-move-group-prefix-function
9094 gnus-newsgroup-name)
9096 (names '((move "Move" "Moving")
9097 (copy "Copy" "Copying")
9098 (crosspost "Crosspost" "Crossposting")))
9099 (copy-buf (save-excursion
9100 (nnheader-set-temp-buffer " *copy article*")))
9101 art-group to-method new-xref article to-groups)
9102 (unless (assq action names)
9103 (error "Unknown action %s" action))
9104 ;; Read the newsgroup name.
9105 (when (and (not to-newsgroup)
9106 (not select-method))
9107 (if (and gnus-move-split-methods
9109 (and (memq gnus-current-article articles)
9110 (gnus-buffer-live-p gnus-original-article-buffer))))
9111 ;; When `gnus-move-split-methods' is non-nil, we have to
9112 ;; select an article to give `gnus-read-move-group-name' an
9113 ;; opportunity to suggest an appropriate default. However,
9114 ;; we needn't render or mark the article.
9115 (let ((gnus-display-mime-function nil)
9116 (gnus-article-prepare-hook nil)
9117 (gnus-mark-article-hook nil))
9118 (gnus-summary-select-article nil nil nil (car articles))))
9120 (gnus-read-move-group-name
9121 (cadr (assq action names))
9122 (symbol-value (intern (format "gnus-current-%s-group" action)))
9124 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9125 (setq to-method (or select-method
9126 (gnus-server-to-method
9127 (gnus-group-method to-newsgroup))))
9128 ;; Check the method we are to move this article to...
9129 (unless (gnus-check-backend-function
9130 'request-accept-article (car to-method))
9131 (error "%s does not support article copying" (car to-method)))
9132 (unless (gnus-check-server to-method)
9133 (error "Can't open server %s" (car to-method)))
9134 (gnus-message 6 "%s to %s: %s..."
9135 (caddr (assq action names))
9136 (or (car select-method) to-newsgroup) articles)
9138 (setq article (pop articles))
9142 ;; Move the article.
9144 ;; Remove this article from future suppression.
9145 (gnus-dup-unsuppress-article article)
9146 (gnus-request-move-article
9147 article ; Article to move
9148 gnus-newsgroup-name ; From newsgroup
9149 (nth 1 (gnus-find-method-for-group
9150 gnus-newsgroup-name)) ; Server
9151 (list 'gnus-request-accept-article
9152 to-newsgroup (list 'quote select-method)
9153 (not articles) t) ; Accept form
9154 (not articles))) ; Only save nov last time
9155 ;; Copy the article.
9158 (set-buffer copy-buf)
9159 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9161 (nnheader-narrow-to-headers)
9162 (dolist (hdr gnus-copy-article-ignored-headers)
9163 (message-remove-header hdr t)))
9164 (gnus-request-accept-article
9165 to-newsgroup select-method (not articles) t))))
9166 ;; Crosspost the article.
9167 ((eq action 'crosspost)
9168 (let ((xref (message-tokenize-header
9169 (mail-header-xref (gnus-summary-article-header article))
9171 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9172 ":" (number-to-string article)))
9174 (setq xref (list (system-name))))
9177 (mapconcat 'identity
9178 (delete "Xref:" (delete new-xref xref))
9182 (set-buffer copy-buf)
9183 ;; First put the article in the destination group.
9184 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9185 (when (consp (setq art-group
9186 (gnus-request-accept-article
9187 to-newsgroup select-method (not articles))))
9188 (setq new-xref (concat new-xref " " (car art-group)
9190 (number-to-string (cdr art-group))))
9191 ;; Now we have the new Xrefs header, so we insert
9192 ;; it and replace the new article.
9193 (nnheader-replace-header "Xref" new-xref)
9194 (gnus-request-replace-article
9195 (cdr art-group) to-newsgroup (current-buffer))
9199 (gnus-message 1 "Couldn't %s article %s: %s"
9200 (cadr (assq action names)) article
9201 (nnheader-get-report (car to-method))))
9202 ((eq art-group 'junk)
9203 (when (eq action 'move)
9204 (gnus-summary-mark-article article gnus-canceled-mark)
9205 (gnus-message 4 "Deleted article %s" article)
9206 ;; run the delete hook
9207 (run-hook-with-args 'gnus-summary-article-delete-hook
9210 (assoc article (gnus-data-list nil)))
9211 gnus-newsgroup-name nil
9214 (let* ((pto-group (gnus-group-prefixed-name
9215 (car art-group) to-method))
9216 (info (gnus-get-info pto-group))
9217 (to-group (gnus-info-group info))
9219 ;; Update the group that has been moved to.
9221 (memq action '(move copy)))
9222 (unless (member to-group to-groups)
9223 (push to-group to-groups))
9225 (unless (memq article gnus-newsgroup-unreads)
9226 (push 'read to-marks)
9228 info (gnus-add-to-range (gnus-info-read info)
9229 (list (cdr art-group)))))
9231 ;; See whether the article is to be put in the cache.
9232 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9233 gnus-article-mark-lists
9234 (delete '(expirable . expire)
9235 (copy-sequence gnus-article-mark-lists))))
9236 (to-article (cdr art-group)))
9238 ;; Enter the article into the cache in the new group,
9239 ;; if that is required.
9240 (when gnus-use-cache
9241 (gnus-cache-possibly-enter-article
9243 (let ((header (copy-sequence
9244 (gnus-summary-article-header article))))
9245 (mail-header-set-number header to-article)
9247 (memq article gnus-newsgroup-marked)
9248 (memq article gnus-newsgroup-dormant)
9249 (memq article gnus-newsgroup-unreads)))
9251 (when gnus-preserve-marks
9252 ;; Copy any marks over to the new group.
9253 (when (and (equal to-group gnus-newsgroup-name)
9254 (not (memq article gnus-newsgroup-unreads)))
9255 ;; Mark this article as read in this group.
9256 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9257 (setcdr (gnus-active to-group) to-article)
9258 (setcdr gnus-newsgroup-active to-article))
9261 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9262 (when (memq article (symbol-value
9263 (intern (format "gnus-newsgroup-%s"
9265 (push (cdar marks) to-marks)
9266 ;; If the other group is the same as this group,
9267 ;; then we have to add the mark to the list.
9268 (when (equal to-group gnus-newsgroup-name)
9269 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9272 (intern (format "gnus-newsgroup-%s"
9274 ;; Copy the marks to other group.
9275 (gnus-add-marked-articles
9276 to-group (cdar marks) (list to-article) info)))
9277 (setq marks (cdr marks)))
9279 (gnus-request-set-mark
9280 to-group (list (list (list to-article) 'add to-marks))))
9283 (concat "(gnus-group-set-info '"
9284 (gnus-prin1-to-string (gnus-get-info to-group))
9287 ;; Update the Xref header in this article to point to
9288 ;; the new crossposted article we have just created.
9289 (when (eq action 'crosspost)
9291 (set-buffer copy-buf)
9292 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9293 (nnheader-replace-header "Xref" new-xref)
9294 (gnus-request-replace-article
9295 article gnus-newsgroup-name (current-buffer))))
9297 ;; run the move/copy/crosspost/respool hook
9298 (run-hook-with-args 'gnus-summary-article-move-hook
9301 (assoc article (gnus-data-list nil)))
9306 ;;;!!!Why is this necessary?
9307 (set-buffer gnus-summary-buffer)
9309 (gnus-summary-goto-subject article)
9310 (when (eq action 'move)
9311 (gnus-summary-mark-article article gnus-canceled-mark))))
9312 (gnus-summary-remove-process-mark article))
9313 ;; Re-activate all groups that have been moved to.
9315 (set-buffer gnus-group-buffer)
9316 (let ((gnus-group-marked to-groups))
9317 (gnus-group-get-new-news-this-group nil t)))
9319 (gnus-kill-buffer copy-buf)
9320 (gnus-summary-position-point)
9321 (gnus-set-mode-line 'summary)))
9323 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9324 "Copy the current article to some other group.
9325 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9326 When called interactively, if TO-NEWSGROUP is nil, use the value of
9327 the variable `gnus-move-split-methods' for finding a default target
9329 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9330 re-spool using this method."
9332 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9334 (defun gnus-summary-crosspost-article (&optional n)
9335 "Crosspost the current article to some other group."
9337 (gnus-summary-move-article n nil nil 'crosspost))
9339 (defcustom gnus-summary-respool-default-method nil
9340 "Default method type for respooling an article.
9341 If nil, use to the current newsgroup method."
9343 :group 'gnus-summary-mail)
9345 (defcustom gnus-summary-display-while-building nil
9346 "If non-nil, show and update the summary buffer as it's being built.
9347 If the value is t, update the buffer after every line is inserted. If
9348 the value is an integer (N), update the display every N lines."
9350 :type '(choice (const :tag "off" nil)
9352 (const :tag "frequently" t)))
9354 (defun gnus-summary-respool-article (&optional n method)
9355 "Respool the current article.
9356 The article will be squeezed through the mail spooling process again,
9357 which means that it will be put in some mail newsgroup or other
9358 depending on `nnmail-split-methods'.
9359 If N is a positive number, respool the N next articles.
9360 If N is a negative number, respool the N previous articles.
9361 If N is nil and any articles have been marked with the process mark,
9362 respool those articles instead.
9364 Respooling can be done both from mail groups and \"real\" newsgroups.
9365 In the former case, the articles in question will be moved from the
9366 current group into whatever groups they are destined to. In the
9367 latter case, they will be copied into the relevant groups."
9369 (list current-prefix-arg
9370 (let* ((methods (gnus-methods-using 'respool))
9372 (symbol-name (or gnus-summary-respool-default-method
9373 (car (gnus-find-method-for-group
9374 gnus-newsgroup-name)))))
9376 (gnus-completing-read-with-default
9377 methname "What backend do you want to use when respooling?"
9378 methods nil t nil 'gnus-mail-method-history))
9381 ((zerop (length (setq ms (gnus-servers-using-backend
9383 (list (intern method) ""))
9387 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9388 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9391 (error "No method given for respooling"))
9392 (if (assoc (symbol-name
9393 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9394 (gnus-methods-using 'respool))
9395 (gnus-summary-move-article n nil method)
9396 (gnus-summary-copy-article n nil method)))
9398 (defun gnus-summary-import-article (file &optional edit)
9399 "Import an arbitrary file into a mail newsgroup."
9400 (interactive "fImport file: \nP")
9401 (let ((group gnus-newsgroup-name)
9402 (now (current-time))
9403 atts lines group-art)
9404 (unless (gnus-check-backend-function 'request-accept-article group)
9405 (error "%s does not support article importing" group))
9406 (or (file-readable-p file)
9407 (not (file-regular-p file))
9408 (error "Can't read %s" file))
9410 (set-buffer (gnus-get-buffer-create " *import file*"))
9412 (nnheader-insert-file-contents file)
9413 (goto-char (point-min))
9414 (if (nnheader-article-p)
9416 (goto-char (point-min))
9417 (search-forward "\n\n" nil t)
9418 (narrow-to-region (point-min) (1- (point)))
9419 (goto-char (point-min))
9420 (unless (re-search-forward "^date:" nil t)
9421 (goto-char (point-max))
9422 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9423 ;; This doesn't look like an article, so we fudge some headers.
9424 (setq atts (file-attributes file)
9425 lines (count-lines (point-min) (point-max)))
9426 (insert "From: " (read-string "From: ") "\n"
9427 "Subject: " (read-string "Subject: ") "\n"
9428 "Date: " (message-make-date (nth 5 atts)) "\n"
9429 "Message-ID: " (message-make-message-id) "\n"
9430 "Lines: " (int-to-string lines) "\n"
9431 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9432 (setq group-art (gnus-request-accept-article group nil t))
9433 (kill-buffer (current-buffer)))
9434 (setq gnus-newsgroup-active (gnus-activate-group group))
9436 (gnus-summary-goto-article (cdr group-art) nil t)
9438 (gnus-summary-edit-article))))
9440 (defun gnus-summary-create-article ()
9441 "Create an article in a mail newsgroup."
9443 (let ((group gnus-newsgroup-name)
9444 (now (current-time))
9446 (unless (gnus-check-backend-function 'request-accept-article group)
9447 (error "%s does not support article importing" group))
9449 (set-buffer (gnus-get-buffer-create " *import file*"))
9451 (goto-char (point-min))
9452 ;; This doesn't look like an article, so we fudge some headers.
9453 (insert "From: " (read-string "From: ") "\n"
9454 "Subject: " (read-string "Subject: ") "\n"
9455 "Date: " (message-make-date now) "\n"
9456 "Message-ID: " (message-make-message-id) "\n")
9457 (setq group-art (gnus-request-accept-article group nil t))
9458 (kill-buffer (current-buffer)))
9459 (setq gnus-newsgroup-active (gnus-activate-group group))
9461 (gnus-summary-goto-article (cdr group-art) nil t)
9462 (gnus-summary-edit-article)))
9464 (defun gnus-summary-article-posted-p ()
9465 "Say whether the current (mail) article is available from news as well.
9466 This will be the case if the article has both been mailed and posted."
9468 (let ((id (mail-header-references (gnus-summary-article-header)))
9469 (gnus-override-method (car (gnus-refer-article-methods))))
9470 (if (gnus-request-head id "")
9471 (gnus-message 2 "The current message was found on %s"
9472 gnus-override-method)
9473 (gnus-message 2 "The current message couldn't be found on %s"
9474 gnus-override-method)
9477 (defun gnus-summary-expire-articles (&optional now)
9478 "Expire all articles that are marked as expirable in the current group."
9480 (when (and (not gnus-group-is-exiting-without-update-p)
9481 (gnus-check-backend-function
9482 'request-expire-articles gnus-newsgroup-name))
9483 ;; This backend supports expiry.
9484 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9485 (expirable (if total
9487 ;; We need to update the info for
9488 ;; this group for `gnus-list-of-read-articles'
9489 ;; to give us the right answer.
9490 (gnus-run-hooks 'gnus-exit-group-hook)
9491 (gnus-summary-update-info)
9492 (gnus-list-of-read-articles gnus-newsgroup-name))
9493 (setq gnus-newsgroup-expirable
9494 (sort gnus-newsgroup-expirable '<))))
9495 (expiry-wait (if now 'immediate
9496 (gnus-group-find-parameter
9497 gnus-newsgroup-name 'expiry-wait)))
9498 (nnmail-expiry-target
9499 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9500 nnmail-expiry-target))
9503 ;; There are expirable articles in this group, so we run them
9504 ;; through the expiry process.
9505 (gnus-message 6 "Expiring articles...")
9506 (unless (gnus-check-group gnus-newsgroup-name)
9507 (error "Can't open server for %s" gnus-newsgroup-name))
9508 ;; The list of articles that weren't expired is returned.
9511 (let ((nnmail-expiry-wait-function nil)
9512 (nnmail-expiry-wait expiry-wait))
9513 (setq es (gnus-request-expire-articles
9514 expirable gnus-newsgroup-name)))
9515 (setq es (gnus-request-expire-articles
9516 expirable gnus-newsgroup-name)))
9518 (setq gnus-newsgroup-expirable es))
9519 ;; We go through the old list of expirable, and mark all
9520 ;; really expired articles as nonexistent.
9521 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9522 (let ((gnus-use-cache nil))
9523 (dolist (article expirable)
9524 (when (and (not (memq article es))
9525 (gnus-data-find article))
9526 (gnus-summary-mark-article article gnus-canceled-mark)
9527 (run-hook-with-args 'gnus-summary-article-expire-hook
9530 (assoc article (gnus-data-list nil)))
9534 (gnus-message 6 "Expiring articles...done")))))
9536 (defun gnus-summary-expire-articles-now ()
9537 "Expunge all expirable articles in the current group.
9538 This means that *all* articles that are marked as expirable will be
9539 deleted forever, right now."
9541 (or gnus-expert-user
9543 "Are you really, really, really sure you want to delete all these messages? ")
9545 (gnus-summary-expire-articles t))
9547 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9548 (defun gnus-summary-delete-article (&optional n)
9549 "Delete the N next (mail) articles.
9550 This command actually deletes articles. This is not a marking
9551 command. The article will disappear forever from your life, never to
9554 If N is negative, delete backwards.
9555 If N is nil and articles have been marked with the process mark,
9556 delete these instead.
9558 If `gnus-novice-user' is non-nil you will be asked for
9559 confirmation before the articles are deleted."
9561 (unless (gnus-check-backend-function 'request-expire-articles
9562 gnus-newsgroup-name)
9563 (error "The current newsgroup does not support article deletion"))
9564 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9565 (error "Couldn't open server"))
9566 ;; Compute the list of articles to delete.
9567 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9568 (nnmail-expiry-target 'delete)
9570 (if (and gnus-novice-user
9571 (not (gnus-yes-or-no-p
9572 (format "Do you really want to delete %s forever? "
9573 (if (> (length articles) 1)
9574 (format "these %s articles" (length articles))
9577 ;; Delete the articles.
9578 (setq not-deleted (gnus-request-expire-articles
9579 articles gnus-newsgroup-name 'force))
9581 (gnus-summary-remove-process-mark (car articles))
9582 ;; The backend might not have been able to delete the article
9584 (unless (memq (car articles) not-deleted)
9585 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9586 (let* ((article (car articles))
9587 (ghead (gnus-data-header
9588 (assoc article (gnus-data-list nil)))))
9589 (run-hook-with-args 'gnus-summary-article-delete-hook
9590 'delete ghead gnus-newsgroup-name nil
9592 (setq articles (cdr articles)))
9594 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9595 (gnus-summary-position-point)
9596 (gnus-set-mode-line 'summary)
9599 (defun gnus-summary-edit-article (&optional force)
9600 "Edit the current article.
9601 This will have permanent effect only in mail groups.
9602 If FORCE is non-nil, allow editing of articles even in read-only
9606 (set-buffer gnus-summary-buffer)
9607 (let ((mail-parse-charset gnus-newsgroup-charset)
9608 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9609 (gnus-set-global-variables)
9610 (when (and (not force)
9611 (gnus-group-read-only-p))
9612 (error "The current newsgroup does not support article editing"))
9613 (gnus-summary-show-article t)
9614 (gnus-article-edit-article
9616 `(lambda (no-highlight)
9617 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9618 (message-options message-options)
9619 (message-options-set-recipient)
9620 (mail-parse-ignored-charsets
9621 ',gnus-newsgroup-ignored-charsets))
9622 (gnus-summary-edit-article-done
9623 ,(or (mail-header-references gnus-current-headers) "")
9624 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9626 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9628 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9630 "Make edits to the current article permanent."
9633 ;; The buffer restriction contains the entire article if it exists.
9634 (when (article-goto-body)
9635 (let ((lines (count-lines (point) (point-max)))
9636 (length (- (point-max) (point)))
9637 (case-fold-search t)
9638 (body (copy-marker (point))))
9639 (goto-char (point-min))
9640 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9641 (delete-region (match-beginning 1) (match-end 1))
9642 (insert (number-to-string length)))
9643 (goto-char (point-min))
9644 (when (re-search-forward
9645 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9646 (delete-region (match-beginning 1) (match-end 1))
9647 (insert (number-to-string length)))
9648 (goto-char (point-min))
9649 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9650 (delete-region (match-beginning 1) (match-end 1))
9651 (insert (number-to-string lines))))))
9652 ;; Replace the article.
9653 (let ((buf (current-buffer)))
9655 (insert-buffer-substring buf)
9657 (if (and (not read-only)
9658 (not (gnus-request-replace-article
9659 (cdr gnus-article-current) (car gnus-article-current)
9660 (current-buffer) t)))
9661 (error "Couldn't replace article")
9662 ;; Update the summary buffer.
9664 (equal (message-tokenize-header references " ")
9665 (message-tokenize-header
9666 (or (message-fetch-field "references") "") " ")))
9667 ;; We only have to update this line.
9670 (message-narrow-to-head)
9671 (let ((head (buffer-string))
9674 (insert (format "211 %d Article retrieved.\n"
9675 (cdr gnus-article-current)))
9678 (let ((nntp-server-buffer (current-buffer)))
9679 (setq header (car (gnus-get-newsgroup-headers
9682 (set-buffer gnus-summary-buffer)
9683 (gnus-data-set-header
9684 (gnus-data-find (cdr gnus-article-current))
9686 (gnus-summary-update-article-line
9687 (cdr gnus-article-current) header)
9688 (if (gnus-summary-goto-subject
9689 (cdr gnus-article-current) nil t)
9690 (gnus-summary-update-secondary-mark
9691 (cdr gnus-article-current))))))))
9693 (set-buffer (or buffer gnus-summary-buffer))
9694 (gnus-summary-update-article (cdr gnus-article-current))
9695 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9696 (gnus-summary-update-secondary-mark
9697 (cdr gnus-article-current))))
9698 ;; Prettify the article buffer again.
9699 (unless no-highlight
9701 (set-buffer gnus-article-buffer)
9702 ;;;!!! Fix this -- article should be rehighlighted.
9703 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9704 (set-buffer gnus-original-article-buffer)
9705 (gnus-request-article
9706 (cdr gnus-article-current)
9707 (car gnus-article-current) (current-buffer))))
9708 ;; Prettify the summary buffer line.
9709 (when (gnus-visual-p 'summary-highlight 'highlight)
9710 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9712 (defun gnus-summary-edit-wash (key)
9713 "Perform editing command KEY in the article buffer."
9717 (message "%s" (concat (this-command-keys) "- "))
9720 (gnus-summary-edit-article)
9721 (execute-kbd-macro (concat (this-command-keys) key))
9722 (gnus-article-edit-done))
9726 (defun gnus-summary-respool-query (&optional silent trace)
9727 "Query where the respool algorithm would put this article."
9729 (let (gnus-mark-article-hook)
9730 (gnus-summary-select-article)
9732 (set-buffer gnus-original-article-buffer)
9733 (let ((groups (nnmail-article-group 'identity trace)))
9736 (message "This message would go to %s"
9737 (mapconcat 'car groups ", "))
9738 (message "This message would go to no groups"))
9741 (defun gnus-summary-respool-trace ()
9742 "Trace where the respool algorithm would put this article.
9743 Display a buffer showing all fancy splitting patterns which matched."
9745 (gnus-summary-respool-query nil t))
9747 ;; Summary marking commands.
9749 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9750 "Mark articles which has the same subject as read, and then select the next.
9751 If UNMARK is positive, remove any kind of mark.
9752 If UNMARK is negative, tick articles."
9755 (setq unmark (prefix-numeric-value unmark)))
9757 (gnus-summary-mark-same-subject
9758 (gnus-summary-article-subject) unmark)))
9759 ;; Select next unread article. If auto-select-same mode, should
9760 ;; select the first unread article.
9761 (gnus-summary-next-article t (and gnus-auto-select-same
9762 (gnus-summary-article-subject)))
9763 (gnus-message 7 "%d article%s marked as %s"
9764 count (if (= count 1) " is" "s are")
9765 (if unmark "unread" "read"))))
9767 (defun gnus-summary-kill-same-subject (&optional unmark)
9768 "Mark articles which has the same subject as read.
9769 If UNMARK is positive, remove any kind of mark.
9770 If UNMARK is negative, tick articles."
9773 (setq unmark (prefix-numeric-value unmark)))
9775 (gnus-summary-mark-same-subject
9776 (gnus-summary-article-subject) unmark)))
9777 ;; If marked as read, go to next unread subject.
9779 ;; Go to next unread subject.
9780 (gnus-summary-next-subject 1 t))
9781 (gnus-message 7 "%d articles are marked as %s"
9782 count (if unmark "unread" "read"))))
9784 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9785 "Mark articles with same SUBJECT as read, and return marked number.
9786 If optional argument UNMARK is positive, remove any kinds of marks.
9787 If optional argument UNMARK is negative, mark articles as unread instead."
9791 ((null unmark) ; Mark as read.
9794 (gnus-summary-mark-article-as-read gnus-killed-mark)
9795 (gnus-summary-show-thread) t)
9796 (gnus-summary-find-subject subject))
9797 (setq count (1+ count))))
9798 ((> unmark 0) ; Tick.
9801 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9802 (gnus-summary-show-thread) t)
9803 (gnus-summary-find-subject subject))
9804 (setq count (1+ count))))
9805 (t ; Mark as unread.
9808 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9809 (gnus-summary-show-thread) t)
9810 (gnus-summary-find-subject subject))
9811 (setq count (1+ count)))))
9812 (gnus-set-mode-line 'summary)
9813 ;; Return the number of marked articles.
9816 (defun gnus-summary-mark-as-processable (n &optional unmark)
9817 "Set the process mark on the next N articles.
9818 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9819 the process mark instead. The difference between N and the actual
9820 number of articles marked is returned."
9822 (if (and (null n) (gnus-region-active-p))
9823 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9824 (setq n (prefix-numeric-value n))
9825 (let ((backward (< n 0))
9830 (gnus-summary-remove-process-mark
9831 (gnus-summary-article-number))
9832 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9833 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9836 (gnus-message 7 "No more articles"))
9837 (gnus-summary-recenter)
9838 (gnus-summary-position-point)
9841 (defun gnus-summary-unmark-as-processable (n)
9842 "Remove the process mark from the next N articles.
9843 If N is negative, unmark backward instead. The difference between N and
9844 the actual number of articles unmarked is returned."
9846 (gnus-summary-mark-as-processable n t))
9848 (defun gnus-summary-unmark-all-processable ()
9849 "Remove the process mark from all articles."
9852 (while gnus-newsgroup-processable
9853 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9854 (gnus-summary-position-point))
9856 (defun gnus-summary-add-mark (article type)
9857 "Mark ARTICLE with a mark of TYPE."
9858 (let ((vtype (car (assq type gnus-article-mark-lists)))
9861 (error "No such mark type: %s" type)
9862 (setq var (intern (format "gnus-newsgroup-%s" type)))
9863 (set var (cons article (symbol-value var)))
9864 (if (memq type '(processable cached replied forwarded recent saved))
9865 (gnus-summary-update-secondary-mark article)
9866 ;;; !!! This is bogus. We should find out what primary
9867 ;;; !!! mark we want to set.
9868 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9870 (defun gnus-summary-mark-as-expirable (n)
9871 "Mark N articles forward as expirable.
9872 If N is negative, mark backward instead. The difference between N and
9873 the actual number of articles marked is returned."
9875 (gnus-summary-mark-forward n gnus-expirable-mark))
9877 (defun gnus-summary-mark-as-spam (n)
9878 "Mark N articles forward as spam.
9879 If N is negative, mark backward instead. The difference between N and
9880 the actual number of articles marked is returned."
9882 (gnus-summary-mark-forward n gnus-spam-mark))
9884 (defun gnus-summary-mark-article-as-replied (article)
9885 "Mark ARTICLE as replied to and update the summary line.
9886 ARTICLE can also be a list of articles."
9887 (interactive (list (gnus-summary-article-number)))
9888 (let ((articles (if (listp article) article (list article))))
9889 (dolist (article articles)
9890 (unless (numberp article)
9891 (error "%s is not a number" article))
9892 (push article gnus-newsgroup-replied)
9893 (let ((buffer-read-only nil))
9894 (when (gnus-summary-goto-subject article nil t)
9895 (gnus-summary-update-secondary-mark article))))))
9897 (defun gnus-summary-mark-article-as-forwarded (article)
9898 "Mark ARTICLE as forwarded and update the summary line.
9899 ARTICLE can also be a list of articles."
9900 (let ((articles (if (listp article) article (list article))))
9901 (dolist (article articles)
9902 (push article gnus-newsgroup-forwarded)
9903 (let ((buffer-read-only nil))
9904 (when (gnus-summary-goto-subject article nil t)
9905 (gnus-summary-update-secondary-mark article))))))
9907 (defun gnus-summary-set-bookmark (article)
9908 "Set a bookmark in current article."
9909 (interactive (list (gnus-summary-article-number)))
9910 (when (or (not (get-buffer gnus-article-buffer))
9911 (not gnus-current-article)
9912 (not gnus-article-current)
9913 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9914 (error "No current article selected"))
9915 ;; Remove old bookmark, if one exists.
9916 (gnus-pull article gnus-newsgroup-bookmarks)
9917 ;; Set the new bookmark, which is on the form
9918 ;; (article-number . line-number-in-body).
9921 (with-current-buffer gnus-article-buffer
9928 gnus-newsgroup-bookmarks)
9929 (gnus-message 6 "A bookmark has been added to the current article."))
9931 (defun gnus-summary-remove-bookmark (article)
9932 "Remove the bookmark from the current article."
9933 (interactive (list (gnus-summary-article-number)))
9934 ;; Remove old bookmark, if one exists.
9935 (if (not (assq article gnus-newsgroup-bookmarks))
9936 (gnus-message 6 "No bookmark in current article.")
9937 (gnus-pull article gnus-newsgroup-bookmarks)
9938 (gnus-message 6 "Removed bookmark.")))
9940 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9941 (defun gnus-summary-mark-as-dormant (n)
9942 "Mark N articles forward as dormant.
9943 If N is negative, mark backward instead. The difference between N and
9944 the actual number of articles marked is returned."
9946 (gnus-summary-mark-forward n gnus-dormant-mark))
9948 (defun gnus-summary-set-process-mark (article)
9949 "Set the process mark on ARTICLE and update the summary line."
9950 (setq gnus-newsgroup-processable
9952 (delq article gnus-newsgroup-processable)))
9953 (when (gnus-summary-goto-subject article)
9954 (gnus-summary-show-thread)
9955 (gnus-summary-goto-subject article)
9956 (gnus-summary-update-secondary-mark article)))
9958 (defun gnus-summary-remove-process-mark (article)
9959 "Remove the process mark from ARTICLE and update the summary line."
9960 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9961 (when (gnus-summary-goto-subject article)
9962 (gnus-summary-show-thread)
9963 (gnus-summary-goto-subject article)
9964 (gnus-summary-update-secondary-mark article)))
9966 (defun gnus-summary-set-saved-mark (article)
9967 "Set the process mark on ARTICLE and update the summary line."
9968 (push article gnus-newsgroup-saved)
9969 (when (gnus-summary-goto-subject article)
9970 (gnus-summary-update-secondary-mark article)))
9972 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9973 "Mark N articles as read forwards.
9974 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9975 The difference between N and the actual number of articles marked is
9977 If NO-EXPIRE, auto-expiry will be inhibited."
9979 (gnus-summary-show-thread)
9980 (let ((backward (< n 0))
9981 (gnus-summary-goto-unread
9982 (and gnus-summary-goto-unread
9983 (not (eq gnus-summary-goto-unread 'never))
9984 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9985 gnus-ticked-mark gnus-dormant-mark)))))
9987 (mark (or mark gnus-del-mark)))
9989 (gnus-summary-mark-article nil mark no-expire)
9990 (zerop (gnus-summary-next-subject
9992 (and gnus-summary-goto-unread
9993 (not (eq gnus-summary-goto-unread 'never)))
9997 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9998 (gnus-summary-recenter)
9999 (gnus-summary-position-point)
10000 (gnus-set-mode-line 'summary)
10003 (defun gnus-summary-mark-article-as-read (mark)
10004 "Mark the current article quickly as read with MARK."
10005 (let ((article (gnus-summary-article-number)))
10006 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10007 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10008 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10009 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10010 (push (cons article mark) gnus-newsgroup-reads)
10011 ;; Possibly remove from cache, if that is used.
10012 (when gnus-use-cache
10013 (gnus-cache-enter-remove-article article))
10014 ;; Allow the backend to change the mark.
10015 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10016 ;; Check for auto-expiry.
10017 (when (and gnus-newsgroup-auto-expire
10018 (memq mark gnus-auto-expirable-marks))
10019 (setq mark gnus-expirable-mark)
10020 ;; Let the backend know about the mark change.
10021 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10022 (push article gnus-newsgroup-expirable))
10023 ;; Set the mark in the buffer.
10024 (gnus-summary-update-mark mark 'unread)
10027 (defun gnus-summary-mark-article-as-unread (mark)
10028 "Mark the current article quickly as unread with MARK."
10029 (let* ((article (gnus-summary-article-number))
10030 (old-mark (gnus-summary-article-mark article)))
10031 ;; Allow the backend to change the mark.
10032 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10033 (if (eq mark old-mark)
10037 (gnus-error 1 "Can't mark negative article numbers")
10039 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10040 (setq gnus-newsgroup-spam-marked
10041 (delq article gnus-newsgroup-spam-marked))
10042 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10043 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10044 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10045 (cond ((= mark gnus-ticked-mark)
10046 (setq gnus-newsgroup-marked
10047 (gnus-add-to-sorted-list gnus-newsgroup-marked
10049 ((= mark gnus-spam-mark)
10050 (setq gnus-newsgroup-spam-marked
10051 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10053 ((= mark gnus-dormant-mark)
10054 (setq gnus-newsgroup-dormant
10055 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10058 (setq gnus-newsgroup-unreads
10059 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10061 (gnus-pull article gnus-newsgroup-reads)
10063 ;; See whether the article is to be put in the cache.
10064 (and gnus-use-cache
10065 (vectorp (gnus-summary-article-header article))
10067 (gnus-cache-possibly-enter-article
10068 gnus-newsgroup-name article
10069 (gnus-summary-article-header article)
10070 (= mark gnus-ticked-mark)
10071 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10074 (gnus-summary-update-mark mark 'unread)
10077 (defun gnus-summary-mark-article (&optional article mark no-expire)
10078 "Mark ARTICLE with MARK. MARK can be any character.
10079 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10080 `??' (dormant) and `?E' (expirable).
10081 If MARK is nil, then the default character `?r' is used.
10082 If ARTICLE is nil, then the article on the current line will be
10084 If NO-EXPIRE, auto-expiry will be inhibited."
10085 ;; The mark might be a string.
10086 (when (stringp mark)
10087 (setq mark (aref mark 0)))
10088 ;; If no mark is given, then we check auto-expiring.
10090 (setq mark gnus-del-mark))
10091 (when (and (not no-expire)
10092 gnus-newsgroup-auto-expire
10093 (memq mark gnus-auto-expirable-marks))
10094 (setq mark gnus-expirable-mark))
10095 (let ((article (or article (gnus-summary-article-number)))
10096 (old-mark (gnus-summary-article-mark article)))
10097 ;; Allow the backend to change the mark.
10098 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10099 (if (eq mark old-mark)
10102 (error "No article on current line"))
10103 (if (not (if (or (= mark gnus-unread-mark)
10104 (= mark gnus-ticked-mark)
10105 (= mark gnus-spam-mark)
10106 (= mark gnus-dormant-mark))
10107 (gnus-mark-article-as-unread article mark)
10108 (gnus-mark-article-as-read article mark)))
10110 ;; See whether the article is to be put in the cache.
10111 (and gnus-use-cache
10112 (not (= mark gnus-canceled-mark))
10113 (vectorp (gnus-summary-article-header article))
10115 (gnus-cache-possibly-enter-article
10116 gnus-newsgroup-name article
10117 (gnus-summary-article-header article)
10118 (= mark gnus-ticked-mark)
10119 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10121 (when (gnus-summary-goto-subject article nil t)
10122 (let ((buffer-read-only nil))
10123 (gnus-summary-show-thread)
10125 (gnus-summary-update-mark mark 'unread)
10128 (defun gnus-summary-update-secondary-mark (article)
10129 "Update the secondary (read, process, cache) mark."
10130 (gnus-summary-update-mark
10131 (cond ((memq article gnus-newsgroup-processable)
10133 ((memq article gnus-newsgroup-cached)
10135 ((memq article gnus-newsgroup-replied)
10137 ((memq article gnus-newsgroup-forwarded)
10138 gnus-forwarded-mark)
10139 ((memq article gnus-newsgroup-saved)
10141 ((memq article gnus-newsgroup-recent)
10143 ((memq article gnus-newsgroup-unseen)
10147 (when (gnus-visual-p 'summary-highlight 'highlight)
10148 (gnus-run-hooks 'gnus-summary-update-hook))
10151 (defun gnus-summary-update-download-mark (article)
10152 "Update the download mark."
10153 (gnus-summary-update-mark
10154 (cond ((memq article gnus-newsgroup-undownloaded)
10155 gnus-undownloaded-mark)
10156 (gnus-newsgroup-agentized
10157 gnus-downloaded-mark)
10161 (gnus-summary-update-line t)
10164 (defun gnus-summary-update-mark (mark type)
10165 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10166 (buffer-read-only nil))
10167 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10169 (when (looking-at "\r")
10171 (when (<= (+ forward (point)) (point-max))
10172 ;; Go to the right position on the line.
10173 (goto-char (+ forward (point)))
10174 ;; Replace the old mark with the new mark.
10175 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10176 ;; Optionally update the marks by some user rule.
10177 (when (eq type 'unread)
10178 (gnus-data-set-mark
10179 (gnus-data-find (gnus-summary-article-number)) mark)
10180 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10182 (defun gnus-mark-article-as-read (article &optional mark)
10183 "Enter ARTICLE in the pertinent lists and remove it from others."
10184 ;; Make the article expirable.
10185 (let ((mark (or mark gnus-del-mark)))
10186 (setq gnus-newsgroup-expirable
10187 (if (= mark gnus-expirable-mark)
10188 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10189 (delq article gnus-newsgroup-expirable)))
10190 ;; Remove from unread and marked lists.
10191 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10192 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10193 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10194 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10195 (push (cons article mark) gnus-newsgroup-reads)
10196 ;; Possibly remove from cache, if that is used.
10197 (when gnus-use-cache
10198 (gnus-cache-enter-remove-article article))
10201 (defun gnus-mark-article-as-unread (article &optional mark)
10202 "Enter ARTICLE in the pertinent lists and remove it from others."
10203 (let ((mark (or mark gnus-ticked-mark)))
10206 (gnus-error 1 "Can't mark negative article numbers")
10208 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10209 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10210 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10211 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10212 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10214 ;; Unsuppress duplicates?
10215 (when gnus-suppress-duplicates
10216 (gnus-dup-unsuppress-article article))
10218 (cond ((= mark gnus-ticked-mark)
10219 (setq gnus-newsgroup-marked
10220 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10221 ((= mark gnus-spam-mark)
10222 (setq gnus-newsgroup-spam-marked
10223 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10225 ((= mark gnus-dormant-mark)
10226 (setq gnus-newsgroup-dormant
10227 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10229 (setq gnus-newsgroup-unreads
10230 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10231 (gnus-pull article gnus-newsgroup-reads)
10234 (defalias 'gnus-summary-mark-as-unread-forward
10235 'gnus-summary-tick-article-forward)
10236 (make-obsolete 'gnus-summary-mark-as-unread-forward
10237 'gnus-summary-tick-article-forward)
10238 (defun gnus-summary-tick-article-forward (n)
10239 "Tick N articles forwards.
10240 If N is negative, tick backwards instead.
10241 The difference between N and the number of articles ticked is returned."
10243 (gnus-summary-mark-forward n gnus-ticked-mark))
10245 (defalias 'gnus-summary-mark-as-unread-backward
10246 'gnus-summary-tick-article-backward)
10247 (make-obsolete 'gnus-summary-mark-as-unread-backward
10248 'gnus-summary-tick-article-backward)
10249 (defun gnus-summary-tick-article-backward (n)
10250 "Tick N articles backwards.
10251 The difference between N and the number of articles ticked is returned."
10253 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10255 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10256 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10257 (defun gnus-summary-tick-article (&optional article clear-mark)
10258 "Mark current article as unread.
10259 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10260 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10262 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10263 gnus-ticked-mark)))
10265 (defun gnus-summary-mark-as-read-forward (n)
10266 "Mark N articles as read forwards.
10267 If N is negative, mark backwards instead.
10268 The difference between N and the actual number of articles marked is
10271 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10273 (defun gnus-summary-mark-as-read-backward (n)
10274 "Mark the N articles as read backwards.
10275 The difference between N and the actual number of articles marked is
10278 (gnus-summary-mark-forward
10279 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10281 (defun gnus-summary-mark-as-read (&optional article mark)
10282 "Mark current article as read.
10283 ARTICLE specifies the article to be marked as read.
10284 MARK specifies a string to be inserted at the beginning of the line."
10285 (gnus-summary-mark-article article mark))
10287 (defun gnus-summary-clear-mark-forward (n)
10288 "Clear marks from N articles forward.
10289 If N is negative, clear backward instead.
10290 The difference between N and the number of marks cleared is returned."
10292 (gnus-summary-mark-forward n gnus-unread-mark))
10294 (defun gnus-summary-clear-mark-backward (n)
10295 "Clear marks from N articles backward.
10296 The difference between N and the number of marks cleared is returned."
10298 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10300 (defun gnus-summary-mark-unread-as-read ()
10301 "Intended to be used by `gnus-summary-mark-article-hook'."
10302 (when (memq gnus-current-article gnus-newsgroup-unreads)
10303 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10305 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10306 "Intended to be used by `gnus-summary-mark-article-hook'."
10307 (let ((mark (gnus-summary-article-mark)))
10308 (when (or (gnus-unread-mark-p mark)
10309 (gnus-read-mark-p mark))
10310 (gnus-summary-mark-article gnus-current-article
10311 (or new-mark gnus-read-mark)))))
10313 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10314 "Intended to be used by `gnus-summary-mark-article-hook'."
10315 (let ((mark (gnus-summary-article-mark)))
10316 (when (or (gnus-unread-mark-p mark)
10317 (gnus-read-mark-p mark))
10318 (gnus-summary-mark-article (gnus-summary-article-number)
10319 (or new-mark gnus-read-mark)))))
10321 (defun gnus-summary-mark-unread-as-ticked ()
10322 "Intended to be used by `gnus-summary-mark-article-hook'."
10323 (when (memq gnus-current-article gnus-newsgroup-unreads)
10324 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10326 (defun gnus-summary-mark-region-as-read (point mark all)
10327 "Mark all unread articles between point and mark as read.
10328 If given a prefix, mark all articles between point and mark as read,
10329 even ticked and dormant ones."
10330 (interactive "r\nP")
10334 (beginning-of-line)
10339 (memq (setq article (gnus-summary-article-number))
10340 gnus-newsgroup-unreads))
10341 (gnus-summary-mark-article article gnus-del-mark))
10343 (gnus-summary-find-next))))))
10345 (defun gnus-summary-mark-below (score mark)
10346 "Mark articles with score less than SCORE with MARK."
10347 (interactive "P\ncMark: ")
10348 (setq score (if score
10349 (prefix-numeric-value score)
10350 (or gnus-summary-default-score 0)))
10352 (set-buffer gnus-summary-buffer)
10353 (goto-char (point-min))
10356 (and (< (gnus-summary-article-score) score)
10357 (gnus-summary-mark-article nil mark))
10358 (gnus-summary-find-next)))))
10360 (defun gnus-summary-kill-below (&optional score)
10361 "Mark articles with score below SCORE as read."
10363 (gnus-summary-mark-below score gnus-killed-mark))
10365 (defun gnus-summary-clear-above (&optional score)
10366 "Clear all marks from articles with score above SCORE."
10368 (gnus-summary-mark-above score gnus-unread-mark))
10370 (defun gnus-summary-tick-above (&optional score)
10371 "Tick all articles with score above SCORE."
10373 (gnus-summary-mark-above score gnus-ticked-mark))
10375 (defun gnus-summary-mark-above (score mark)
10376 "Mark articles with score over SCORE with MARK."
10377 (interactive "P\ncMark: ")
10378 (setq score (if score
10379 (prefix-numeric-value score)
10380 (or gnus-summary-default-score 0)))
10382 (set-buffer gnus-summary-buffer)
10383 (goto-char (point-min))
10385 (when (> (gnus-summary-article-score) score)
10386 (gnus-summary-mark-article nil mark))
10388 (gnus-summary-find-next)))))
10390 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10391 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10392 (defun gnus-summary-limit-include-expunged (&optional no-error)
10393 "Display all the hidden articles that were expunged for low scores."
10395 (let ((buffer-read-only nil))
10396 (let ((scored gnus-newsgroup-scored)
10399 (unless (gnus-summary-article-header (caar scored))
10400 (and (setq h (gnus-number-to-header (caar scored)))
10401 (< (cdar scored) gnus-summary-expunge-below)
10403 (setq scored (cdr scored)))
10405 (when (not no-error)
10406 (error "No expunged articles hidden"))
10407 (goto-char (point-min))
10408 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10409 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10410 (mapcar (lambda (x) (push (mail-header-number x)
10411 gnus-newsgroup-limit))
10413 (gnus-summary-prepare-unthreaded (nreverse headers))
10414 (goto-char (point-min))
10415 (gnus-summary-position-point)
10418 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10419 "Mark all unread articles in this newsgroup as read.
10420 If prefix argument ALL is non-nil, ticked and dormant articles will
10421 also be marked as read.
10422 If QUIETLY is non-nil, no questions will be asked.
10424 If TO-HERE is non-nil, it should be a point in the buffer. All
10425 articles before (after, if REVERSE is set) this point will be marked
10428 Note that this function will only catch up the unread article
10429 in the current summary buffer limitation.
10431 The number of articles marked as read is returned."
10436 (not gnus-interactive-catchup) ;Without confirmation?
10440 "Mark absolutely all articles as read? "
10441 "Mark all unread articles as read? ")))
10443 (not gnus-newsgroup-adaptive)
10444 (not gnus-newsgroup-auto-expire)
10445 (not gnus-suppress-duplicates)
10446 (or (not gnus-use-cache)
10447 (eq gnus-use-cache 'passive)))
10450 (setq gnus-newsgroup-marked nil
10451 gnus-newsgroup-spam-marked nil
10452 gnus-newsgroup-dormant nil))
10453 (setq gnus-newsgroup-unreads
10454 (gnus-sorted-nunion
10455 (gnus-intersection gnus-newsgroup-unreads
10456 gnus-newsgroup-downloadable)
10457 gnus-newsgroup-unfetched)))
10458 ;; We actually mark all articles as canceled, which we
10459 ;; have to do when using auto-expiry or adaptive scoring.
10460 (gnus-summary-show-all-threads)
10461 (if (and to-here reverse)
10463 (goto-char to-here)
10464 (gnus-summary-mark-current-read-and-unread-as-read
10466 (while (gnus-summary-find-next (not all))
10467 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10468 (when (gnus-summary-first-subject (not all))
10470 (if to-here (< (point) to-here) t)
10471 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10472 (gnus-summary-find-next (not all))))))
10473 (gnus-set-mode-line 'summary))
10475 (gnus-summary-position-point)))
10477 (defun gnus-summary-catchup-to-here (&optional all)
10478 "Mark all unticked articles before the current one as read.
10479 If ALL is non-nil, also mark ticked and dormant articles as read."
10482 (gnus-save-hidden-threads
10483 (let ((beg (point)))
10484 ;; We check that there are unread articles.
10485 (when (or all (gnus-summary-find-prev))
10486 (gnus-summary-catchup all t beg)))))
10487 (gnus-summary-position-point))
10489 (defun gnus-summary-catchup-from-here (&optional all)
10490 "Mark all unticked articles after (and including) the current one as read.
10491 If ALL is non-nil, also mark ticked and dormant articles as read."
10494 (gnus-save-hidden-threads
10495 (let ((beg (point)))
10496 ;; We check that there are unread articles.
10497 (when (or all (gnus-summary-find-next))
10498 (gnus-summary-catchup all t beg nil t)))))
10499 (gnus-summary-position-point))
10501 (defun gnus-summary-catchup-all (&optional quietly)
10502 "Mark all articles in this newsgroup as read.
10503 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10504 instead, which marks only unread articles as read."
10506 (gnus-summary-catchup t quietly))
10508 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10509 "Mark all unread articles in this group as read, then exit.
10510 If prefix argument ALL is non-nil, all articles are marked as read.
10511 If QUIETLY is non-nil, no questions will be asked."
10513 (when (gnus-summary-catchup all quietly nil 'fast)
10514 ;; Select next newsgroup or exit.
10515 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10516 (eq gnus-auto-select-next 'quietly))
10517 (gnus-summary-next-group nil)
10518 (gnus-summary-exit))))
10520 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10521 "Mark all articles in this newsgroup as read, and then exit.
10522 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10523 instead, which marks only unread articles as read."
10525 (gnus-summary-catchup-and-exit t quietly))
10527 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10528 "Mark all articles in this group as read and select the next group.
10529 If given a prefix, mark all articles, unread as well as ticked, as
10533 (gnus-summary-catchup all))
10534 (gnus-summary-next-group))
10540 (defmacro gnus-with-article (article &rest forms)
10541 "Select ARTICLE and perform FORMS in the original article buffer.
10542 Then replace the article with the result."
10544 ;; We don't want the article to be marked as read.
10545 (let (gnus-mark-article-hook)
10546 (gnus-summary-select-article t t nil ,article))
10547 (set-buffer gnus-original-article-buffer)
10549 (if (not (gnus-check-backend-function
10550 'request-replace-article (car gnus-article-current)))
10551 (gnus-message 5 "Read-only group; not replacing")
10552 (unless (gnus-request-replace-article
10553 ,article (car gnus-article-current)
10554 (current-buffer) t)
10555 (error "Couldn't replace article")))
10556 ;; The cache and backlog have to be flushed somewhat.
10557 (when gnus-keep-backlog
10558 (gnus-backlog-remove-article
10559 (car gnus-article-current) (cdr gnus-article-current)))
10560 (when gnus-use-cache
10561 (gnus-cache-update-article
10562 (car gnus-article-current) (cdr gnus-article-current)))))
10564 (put 'gnus-with-article 'lisp-indent-function 1)
10565 (put 'gnus-with-article 'edebug-form-spec '(form body))
10567 ;; Thread-based commands.
10569 (defun gnus-summary-articles-in-thread (&optional article)
10570 "Return a list of all articles in the current thread.
10571 If ARTICLE is non-nil, return all articles in the thread that starts
10572 with that article."
10573 (let* ((article (or article (gnus-summary-article-number)))
10574 (data (gnus-data-find-list article))
10575 (top-level (gnus-data-level (car data)))
10577 (cond ((null gnus-thread-operation-ignore-subject)
10578 (gnus-simplify-subject-re
10579 (mail-header-subject (gnus-data-header (car data)))))
10580 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10581 (gnus-simplify-subject-fuzzy
10582 (mail-header-subject (gnus-data-header (car data)))))
10584 (end-point (save-excursion
10585 (if (gnus-summary-go-to-next-thread)
10586 (point) (point-max))))
10589 (< (gnus-data-pos (car data)) end-point))
10590 (when (or (not top-subject)
10591 (string= top-subject
10592 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10593 (gnus-simplify-subject-fuzzy
10594 (mail-header-subject
10595 (gnus-data-header (car data))))
10596 (gnus-simplify-subject-re
10597 (mail-header-subject
10598 (gnus-data-header (car data)))))))
10599 (push (gnus-data-number (car data)) articles))
10600 (unless (and (setq data (cdr data))
10601 (> (gnus-data-level (car data)) top-level))
10603 ;; Return the list of articles.
10604 (nreverse articles)))
10606 (defun gnus-summary-rethread-current ()
10607 "Rethread the thread the current article is part of."
10609 (let* ((gnus-show-threads t)
10610 (article (gnus-summary-article-number))
10611 (id (mail-header-id (gnus-summary-article-header)))
10612 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10614 (error "No article on the current line"))
10615 (gnus-rebuild-thread id)
10616 (gnus-summary-goto-subject article)))
10618 (defun gnus-summary-reparent-thread ()
10619 "Make the current article child of the marked (or previous) article.
10621 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10622 is non-nil or the Subject: of both articles are the same."
10624 (unless (not (gnus-group-read-only-p))
10625 (error "The current newsgroup does not support article editing"))
10626 (unless (<= (length gnus-newsgroup-processable) 1)
10627 (error "No more than one article may be marked"))
10628 (save-window-excursion
10629 (let ((gnus-article-buffer " *reparent*")
10630 (current-article (gnus-summary-article-number))
10631 ;; First grab the marked article, otherwise one line up.
10632 (parent-article (if (not (null gnus-newsgroup-processable))
10633 (car gnus-newsgroup-processable)
10635 (if (eq (forward-line -1) 0)
10636 (gnus-summary-article-number)
10637 (error "Beginning of summary buffer"))))))
10638 (unless (not (eq current-article parent-article))
10639 (error "An article may not be self-referential"))
10640 (let ((message-id (mail-header-id
10641 (gnus-summary-article-header parent-article))))
10642 (unless (and message-id (not (equal message-id "")))
10643 (error "No message-id in desired parent"))
10644 (gnus-with-article current-article
10646 (goto-char (point-min))
10647 (message-narrow-to-head)
10648 (if (re-search-forward "^References: " nil t)
10650 (re-search-forward "^[^ \t]" nil t)
10653 (insert " " message-id))
10654 (insert "References: " message-id "\n"))))
10655 (set-buffer gnus-summary-buffer)
10656 (gnus-summary-unmark-all-processable)
10657 (gnus-summary-update-article current-article)
10658 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10659 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10660 (gnus-summary-rethread-current)
10661 (gnus-message 3 "Article %d is now the child of article %d"
10662 current-article parent-article)))))
10664 (defun gnus-summary-toggle-threads (&optional arg)
10665 "Toggle showing conversation threads.
10666 If ARG is positive number, turn showing conversation threads on."
10668 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10669 (setq gnus-show-threads
10670 (if (null arg) (not gnus-show-threads)
10671 (> (prefix-numeric-value arg) 0)))
10672 (gnus-summary-prepare)
10673 (gnus-summary-goto-subject current)
10674 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10675 (gnus-summary-position-point)))
10677 (defun gnus-summary-show-all-threads ()
10678 "Show all threads."
10681 (let ((buffer-read-only nil))
10682 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10683 (gnus-summary-position-point))
10685 (defun gnus-summary-show-thread ()
10686 "Show thread subtrees.
10687 Returns nil if no thread was there to be shown."
10689 (let ((buffer-read-only nil)
10691 (end (point-at-eol))
10692 ;; Leave point at bol
10693 (beg (progn (beginning-of-line) (point))))
10695 ;; Any hidden lines here?
10696 (search-forward "\r" end t)
10697 (subst-char-in-region beg end ?\^M ?\n t)
10699 (gnus-summary-position-point))))
10701 (defun gnus-summary-maybe-hide-threads ()
10702 "If requested, hide the threads that should be hidden."
10703 (when (and gnus-show-threads
10704 gnus-thread-hide-subtree)
10705 (gnus-summary-hide-all-threads
10706 (if (or (consp gnus-thread-hide-subtree)
10707 (functionp gnus-thread-hide-subtree))
10708 (gnus-make-predicate gnus-thread-hide-subtree)
10711 ;;; Hiding predicates.
10713 (defun gnus-article-unread-p (header)
10714 (memq (mail-header-number header) gnus-newsgroup-unreads))
10716 (defun gnus-article-unseen-p (header)
10717 (memq (mail-header-number header) gnus-newsgroup-unseen))
10719 (defun gnus-map-articles (predicate articles)
10720 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10721 (apply 'gnus-or (mapcar predicate
10722 (mapcar 'gnus-summary-article-header articles))))
10724 (defun gnus-summary-hide-all-threads (&optional predicate)
10725 "Hide all thread subtrees.
10726 If PREDICATE is supplied, threads that satisfy this predicate
10727 will not be hidden."
10730 (goto-char (point-min))
10733 (when (or (not predicate)
10735 predicate (gnus-summary-article-children)))
10736 (gnus-summary-hide-thread))
10737 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10738 (gnus-summary-position-point))
10740 (defun gnus-summary-hide-thread ()
10741 "Hide thread subtrees.
10742 If PREDICATE is supplied, threads that satisfy this predicate
10743 will not be hidden.
10744 Returns nil if no threads were there to be hidden."
10746 (let ((buffer-read-only nil)
10748 (article (gnus-summary-article-number)))
10750 ;; Go forward until either the buffer ends or the subthread
10752 (when (and (not (eobp))
10753 (or (zerop (gnus-summary-next-thread 1 t))
10754 (goto-char (point-max))))
10756 (if (and (> (point) start)
10757 (search-backward "\n" start t))
10759 (subst-char-in-region start (point) ?\n ?\^M)
10760 (gnus-summary-goto-subject article))
10764 (defun gnus-summary-go-to-next-thread (&optional previous)
10765 "Go to the same level (or less) next thread.
10766 If PREVIOUS is non-nil, go to previous thread instead.
10767 Return the article number moved to, or nil if moving was impossible."
10768 (let ((level (gnus-summary-thread-level))
10769 (way (if previous -1 1))
10772 (while (and (not (eobp))
10773 (< level (gnus-summary-thread-level)))
10774 (forward-line way))
10781 (gnus-summary-article-number)
10782 (goto-char beg)))))
10784 (defun gnus-summary-next-thread (n &optional silent)
10785 "Go to the same level next N'th thread.
10786 If N is negative, search backward instead.
10787 Returns the difference between N and the number of skips actually
10790 If SILENT, don't output messages."
10792 (let ((backward (< n 0))
10794 (while (and (> n 0)
10795 (gnus-summary-go-to-next-thread backward))
10798 (gnus-summary-position-point))
10799 (when (and (not silent) (/= 0 n))
10800 (gnus-message 7 "No more threads"))
10803 (defun gnus-summary-prev-thread (n)
10804 "Go to the same level previous N'th thread.
10805 Returns the difference between N and the number of skips actually
10808 (gnus-summary-next-thread (- n)))
10810 (defun gnus-summary-go-down-thread ()
10811 "Go down one level in the current thread."
10812 (let ((children (gnus-summary-article-children)))
10814 (gnus-summary-goto-subject (car children)))))
10816 (defun gnus-summary-go-up-thread ()
10817 "Go up one level in the current thread."
10818 (let ((parent (gnus-summary-article-parent)))
10820 (gnus-summary-goto-subject parent))))
10822 (defun gnus-summary-down-thread (n)
10823 "Go down thread N steps.
10824 If N is negative, go up instead.
10825 Returns the difference between N and how many steps down that were
10830 (while (and (> n 0)
10831 (if up (gnus-summary-go-up-thread)
10832 (gnus-summary-go-down-thread)))
10834 (gnus-summary-position-point)
10836 (gnus-message 7 "Can't go further"))
10839 (defun gnus-summary-up-thread (n)
10840 "Go up thread N steps.
10841 If N is negative, go down instead.
10842 Returns the difference between N and how many steps down that were
10845 (gnus-summary-down-thread (- n)))
10847 (defun gnus-summary-top-thread ()
10848 "Go to the top of the thread."
10850 (while (gnus-summary-go-up-thread))
10851 (gnus-summary-article-number))
10853 (defun gnus-summary-kill-thread (&optional unmark)
10854 "Mark articles under current thread as read.
10855 If the prefix argument is positive, remove any kinds of marks.
10856 If the prefix argument is negative, tick articles instead."
10859 (setq unmark (prefix-numeric-value unmark)))
10860 (let ((articles (gnus-summary-articles-in-thread)))
10862 ;; Expand the thread.
10863 (gnus-summary-show-thread)
10864 ;; Mark all the articles.
10866 (gnus-summary-goto-subject (car articles))
10867 (cond ((null unmark)
10868 (gnus-summary-mark-article-as-read gnus-killed-mark))
10870 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10872 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10873 (setq articles (cdr articles))))
10874 ;; Hide killed subtrees.
10876 gnus-thread-hide-killed
10877 (gnus-summary-hide-thread))
10878 ;; If marked as read, go to next unread subject.
10879 (when (null unmark)
10880 ;; Go to next unread subject.
10881 (gnus-summary-next-subject 1 t)))
10882 (gnus-set-mode-line 'summary))
10884 ;; Summary sorting commands
10886 (defun gnus-summary-sort-by-number (&optional reverse)
10887 "Sort the summary buffer by article number.
10888 Argument REVERSE means reverse order."
10890 (gnus-summary-sort 'number reverse))
10892 (defun gnus-summary-sort-by-random (&optional reverse)
10893 "Randomize the order in the summary buffer.
10894 Argument REVERSE means to randomize in reverse order."
10896 (gnus-summary-sort 'random reverse))
10898 (defun gnus-summary-sort-by-author (&optional reverse)
10899 "Sort the summary buffer by author name alphabetically.
10900 If `case-fold-search' is non-nil, case of letters is ignored.
10901 Argument REVERSE means reverse order."
10903 (gnus-summary-sort 'author reverse))
10905 (defun gnus-summary-sort-by-subject (&optional reverse)
10906 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10907 If `case-fold-search' is non-nil, case of letters is ignored.
10908 Argument REVERSE means reverse order."
10910 (gnus-summary-sort 'subject reverse))
10912 (defun gnus-summary-sort-by-date (&optional reverse)
10913 "Sort the summary buffer by date.
10914 Argument REVERSE means reverse order."
10916 (gnus-summary-sort 'date reverse))
10918 (defun gnus-summary-sort-by-score (&optional reverse)
10919 "Sort the summary buffer by score.
10920 Argument REVERSE means reverse order."
10922 (gnus-summary-sort 'score reverse))
10924 (defun gnus-summary-sort-by-lines (&optional reverse)
10925 "Sort the summary buffer by the number of lines.
10926 Argument REVERSE means reverse order."
10928 (gnus-summary-sort 'lines reverse))
10930 (defun gnus-summary-sort-by-chars (&optional reverse)
10931 "Sort the summary buffer by article length.
10932 Argument REVERSE means reverse order."
10934 (gnus-summary-sort 'chars reverse))
10936 (defun gnus-summary-sort-by-original (&optional reverse)
10937 "Sort the summary buffer using the default sorting method.
10938 Argument REVERSE means reverse order."
10940 (let* ((buffer-read-only)
10941 (gnus-summary-prepare-hook nil))
10942 ;; We do the sorting by regenerating the threads.
10943 (gnus-summary-prepare)
10944 ;; Hide subthreads if needed.
10945 (gnus-summary-maybe-hide-threads)))
10947 (defun gnus-summary-sort (predicate reverse)
10948 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10949 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10950 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10951 (gnus-thread-sort-functions
10956 (gnus-sort-gathered-threads-function
10957 gnus-thread-sort-functions)
10958 (gnus-article-sort-functions
10962 (,article t2 t1))))
10964 (gnus-summary-prepare-hook nil))
10965 ;; We do the sorting by regenerating the threads.
10966 (gnus-summary-prepare)
10967 ;; Hide subthreads if needed.
10968 (gnus-summary-maybe-hide-threads)))
10970 ;; Summary saving commands.
10972 (defun gnus-summary-save-article (&optional n not-saved)
10973 "Save the current article using the default saver function.
10974 If N is a positive number, save the N next articles.
10975 If N is a negative number, save the N previous articles.
10976 If N is nil and any articles have been marked with the process mark,
10977 save those articles instead.
10978 The variable `gnus-default-article-saver' specifies the saver function."
10980 (let* ((articles (gnus-summary-work-articles n))
10981 (save-buffer (save-excursion
10982 (nnheader-set-temp-buffer " *Gnus Save*")))
10983 (num (length articles))
10985 (dolist (article articles)
10986 (setq header (gnus-summary-article-header article))
10987 (if (not (vectorp header))
10988 ;; This is a pseudo-article.
10989 (if (assq 'name header)
10990 (gnus-copy-file (cdr (assq 'name header)))
10991 (gnus-message 1 "Article %d is unsaveable" article))
10992 ;; This is a real article.
10993 (save-window-excursion
10994 (let ((gnus-display-mime-function nil)
10995 (gnus-article-prepare-hook nil))
10996 (gnus-summary-select-article t nil nil article)))
10998 (set-buffer save-buffer)
11000 (insert-buffer-substring gnus-original-article-buffer))
11001 (setq file (gnus-article-save save-buffer file num))
11002 (gnus-summary-remove-process-mark article)
11004 (gnus-summary-set-saved-mark article))))
11005 (gnus-kill-buffer save-buffer)
11006 (gnus-summary-position-point)
11007 (gnus-set-mode-line 'summary)
11010 (defun gnus-summary-pipe-output (&optional arg headers)
11011 "Pipe the current article to a subprocess.
11012 If N is a positive number, pipe the N next articles.
11013 If N is a negative number, pipe the N previous articles.
11014 If N is nil and any articles have been marked with the process mark,
11015 pipe those articles instead.
11016 If HEADERS (the symbolic prefix), include the headers, too."
11017 (interactive (gnus-interactive "P\ny"))
11018 (require 'gnus-art)
11019 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11020 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11021 (gnus-summary-save-article arg t))
11022 (let ((buffer (get-buffer "*Shell Command Output*")))
11024 (not (zerop (buffer-size buffer))))
11025 (gnus-configure-windows 'pipe))))
11027 (defun gnus-summary-save-article-mail (&optional arg)
11028 "Append the current article to an mail file.
11029 If N is a positive number, save the N next articles.
11030 If N is a negative number, save the N previous articles.
11031 If N is nil and any articles have been marked with the process mark,
11032 save those articles instead."
11034 (require 'gnus-art)
11035 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11036 (gnus-summary-save-article arg)))
11038 (defun gnus-summary-save-article-rmail (&optional arg)
11039 "Append the current article to an rmail file.
11040 If N is a positive number, save the N next articles.
11041 If N is a negative number, save the N previous articles.
11042 If N is nil and any articles have been marked with the process mark,
11043 save those articles instead."
11045 (require 'gnus-art)
11046 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11047 (gnus-summary-save-article arg)))
11049 (defun gnus-summary-save-article-file (&optional arg)
11050 "Append the current article to a file.
11051 If N is a positive number, save the N next articles.
11052 If N is a negative number, save the N previous articles.
11053 If N is nil and any articles have been marked with the process mark,
11054 save those articles instead."
11056 (require 'gnus-art)
11057 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11058 (gnus-summary-save-article arg)))
11060 (defun gnus-summary-write-article-file (&optional arg)
11061 "Write the current article to a file, deleting the previous file.
11062 If N is a positive number, save the N next articles.
11063 If N is a negative number, save the N previous articles.
11064 If N is nil and any articles have been marked with the process mark,
11065 save those articles instead."
11067 (require 'gnus-art)
11068 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11069 (gnus-summary-save-article arg)))
11071 (defun gnus-summary-save-article-body-file (&optional arg)
11072 "Append the current article body to a file.
11073 If N is a positive number, save the N next articles.
11074 If N is a negative number, save the N previous articles.
11075 If N is nil and any articles have been marked with the process mark,
11076 save those articles instead."
11078 (require 'gnus-art)
11079 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11080 (gnus-summary-save-article arg)))
11082 (defun gnus-summary-muttprint (&optional arg)
11083 "Print the current article using Muttprint.
11084 If N is a positive number, save the N next articles.
11085 If N is a negative number, save the N previous articles.
11086 If N is nil and any articles have been marked with the process mark,
11087 save those articles instead."
11089 (require 'gnus-art)
11090 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11091 (gnus-summary-save-article arg t)))
11093 (defun gnus-summary-pipe-message (program)
11094 "Pipe the current article through PROGRAM."
11095 (interactive "sProgram: ")
11096 (gnus-summary-select-article)
11097 (let ((mail-header-separator ""))
11098 (gnus-eval-in-buffer-window gnus-article-buffer
11101 (let ((start (window-start))
11103 (message-pipe-buffer-body program)
11104 (set-window-start (get-buffer-window (current-buffer)) start))))))
11106 (defun gnus-get-split-value (methods)
11107 "Return a value based on the split METHODS."
11108 (let (split-name method result match)
11111 (set-buffer gnus-original-article-buffer)
11113 (nnheader-narrow-to-headers)
11114 (while (and methods (not split-name))
11115 (goto-char (point-min))
11116 (setq method (pop methods))
11117 (setq match (car method))
11120 ;; Regular expression.
11122 (re-search-forward match nil t)))
11127 (setq result (funcall match gnus-newsgroup-name))))
11132 (setq result (eval match)))))
11133 (setq split-name (cdr method))
11134 (cond ((stringp result)
11135 (push (expand-file-name
11136 result gnus-article-save-directory)
11139 (setq split-name (append result split-name)))))))))
11140 (nreverse split-name)))
11142 (defun gnus-valid-move-group-p (group)
11143 (and (boundp group)
11144 (symbol-name group)
11145 (symbol-value group)
11146 (gnus-get-function (gnus-find-method-for-group
11147 (symbol-name group)) 'request-accept-article t)))
11149 (defun gnus-read-move-group-name (prompt default articles prefix)
11150 "Read a group name."
11151 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11152 (minibuffer-confirm-incomplete nil) ; XEmacs
11154 (format "%s %s to:"
11156 (if (> (length articles) 1)
11157 (format "these %d articles" (length articles))
11162 (gnus-completing-read-with-default
11165 'gnus-valid-move-group-p
11167 'gnus-group-history))
11168 ((= 1 (length split-name))
11169 (gnus-completing-read-with-default
11170 (car split-name) prom
11172 'gnus-valid-move-group-p
11174 'gnus-group-history))
11176 (gnus-completing-read-with-default
11178 (mapcar 'list (nreverse split-name))
11180 'gnus-group-history))))
11181 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11183 (if (or (string= to-newsgroup "")
11184 (string= to-newsgroup prefix))
11185 (setq to-newsgroup default))
11186 (unless to-newsgroup
11187 (error "No group name entered"))
11188 (or (gnus-active to-newsgroup)
11189 (gnus-activate-group to-newsgroup nil nil to-method)
11190 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11192 (or (and (gnus-request-create-group to-newsgroup to-method)
11193 (gnus-activate-group
11194 to-newsgroup nil nil to-method)
11195 (gnus-subscribe-group to-newsgroup))
11196 (error "Couldn't create group %s" to-newsgroup)))
11197 (error "No such group: %s" to-newsgroup)))
11200 (defun gnus-summary-save-parts (type dir n &optional reverse)
11201 "Save parts matching TYPE to DIR.
11202 If REVERSE, save parts that do not match TYPE."
11204 (list (read-string "Save parts of type: "
11205 (or (car gnus-summary-save-parts-type-history)
11206 gnus-summary-save-parts-default-mime)
11207 'gnus-summary-save-parts-type-history)
11208 (setq gnus-summary-save-parts-last-directory
11209 (read-file-name "Save to directory: "
11210 gnus-summary-save-parts-last-directory
11212 current-prefix-arg))
11213 (gnus-summary-iterate n
11214 (let ((gnus-display-mime-function nil)
11215 (gnus-inhibit-treatment t))
11216 (gnus-summary-select-article))
11218 (set-buffer gnus-article-buffer)
11219 (let ((handles (or gnus-article-mime-handles
11220 (mm-dissect-buffer nil gnus-article-loose-mime)
11221 (and gnus-article-emulate-mime
11222 (mm-uu-dissect)))))
11224 (gnus-summary-save-parts-1 type dir handles reverse)
11225 (unless gnus-article-mime-handles ;; Don't destroy this case.
11226 (mm-destroy-parts handles)))))))
11228 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11229 (if (stringp (car handle))
11230 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11233 (not (string-match type (mm-handle-media-type handle)))
11234 (string-match type (mm-handle-media-type handle)))
11235 (let ((file (expand-file-name
11237 mm-file-name-rewrite-functions
11238 (file-name-nondirectory
11240 (mail-content-type-get
11241 (mm-handle-disposition handle) 'filename)
11242 (mail-content-type-get
11243 (mm-handle-type handle) 'name)
11244 (concat gnus-newsgroup-name
11245 "." (number-to-string
11246 (cdr gnus-article-current))))))
11248 (unless (file-exists-p file)
11249 (mm-save-part-to-file handle file))))))
11251 ;; Summary extract commands
11253 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11254 (let ((buffer-read-only nil)
11255 (article (gnus-summary-article-number))
11257 (unless (gnus-summary-goto-subject article)
11258 (error "No such article: %d" article))
11259 (gnus-summary-position-point)
11260 ;; If all commands are to be bunched up on one line, we collect
11262 (unless gnus-view-pseudos-separately
11263 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11266 (setq action (cdr (assq 'action (car ps))))
11267 (setq files (list (cdr (assq 'name (car ps)))))
11268 (while (and ps (cdr ps)
11269 (string= (or action "1")
11270 (or (cdr (assq 'action (cadr ps))) "2")))
11271 (push (cdr (assq 'name (cadr ps))) files)
11272 (setcdr ps (cddr ps)))
11274 (when (not (string-match "%s" action))
11277 (when (assq 'execute (car ps))
11278 (setcdr (assq 'execute (car ps))
11279 (funcall (if (string-match "%s" action)
11286 (shell-quote-argument f)))
11288 (setq ps (cdr ps)))))
11289 (if (and gnus-view-pseudos (not not-view))
11291 (when (assq 'execute (car pslist))
11292 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11293 (eq gnus-view-pseudos 'not-confirm)))
11294 (setq pslist (cdr pslist)))
11297 (setq after-article (or (cdr (assq 'article (car pslist)))
11298 (gnus-summary-article-number)))
11299 (gnus-summary-goto-subject after-article)
11302 (insert " " (file-name-nondirectory
11303 (cdr (assq 'name (car pslist))))
11304 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11306 (forward-line -1) ; back to `b'
11307 (gnus-add-text-properties
11308 b (1- e) (list 'gnus-number gnus-reffed-article-number
11309 gnus-mouse-face-prop gnus-mouse-face))
11311 after-article gnus-reffed-article-number
11312 gnus-unread-mark b (car pslist) 0 (- e b))
11313 (setq gnus-newsgroup-unreads
11314 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11315 gnus-reffed-article-number))
11316 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11317 (setq pslist (cdr pslist)))))))
11319 (defun gnus-pseudos< (p1 p2)
11320 (let ((c1 (cdr (assq 'action p1)))
11321 (c2 (cdr (assq 'action p2))))
11322 (and c1 c2 (string< c1 c2))))
11324 (defun gnus-request-pseudo-article (props)
11325 (cond ((assq 'execute props)
11326 (gnus-execute-command (cdr (assq 'execute props)))))
11327 (let ((gnus-current-article (gnus-summary-article-number)))
11328 (gnus-run-hooks 'gnus-mark-article-hook)))
11330 (defun gnus-execute-command (command &optional automatic)
11332 (gnus-article-setup-buffer)
11333 (set-buffer gnus-article-buffer)
11334 (setq buffer-read-only nil)
11335 (let ((command (if automatic command
11336 (read-string "Command: " (cons command 0)))))
11338 (insert "$ " command "\n\n")
11339 (if gnus-view-pseudo-asynchronously
11340 (start-process "gnus-execute" (current-buffer) shell-file-name
11341 shell-command-switch command)
11342 (call-process shell-file-name nil t nil
11343 shell-command-switch command)))))
11345 ;; Summary kill commands.
11347 (defun gnus-summary-edit-global-kill (article)
11348 "Edit the \"global\" kill file."
11349 (interactive (list (gnus-summary-article-number)))
11350 (gnus-group-edit-global-kill article))
11352 (defun gnus-summary-edit-local-kill ()
11353 "Edit a local kill file applied to the current newsgroup."
11355 (setq gnus-current-headers (gnus-summary-article-header))
11356 (gnus-group-edit-local-kill
11357 (gnus-summary-article-number) gnus-newsgroup-name))
11359 ;;; Header reading.
11361 (defun gnus-read-header (id &optional header)
11362 "Read the headers of article ID and enter them into the Gnus system."
11363 (let ((group gnus-newsgroup-name)
11364 (gnus-override-method
11366 gnus-override-method
11367 (and (gnus-news-group-p gnus-newsgroup-name)
11368 (car (gnus-refer-article-methods)))))
11370 ;; First we check to see whether the header in question is already
11373 ;; This is a Message-ID.
11374 (setq header (or header (gnus-id-to-header id)))
11375 ;; This is an article number.
11376 (setq header (or header (gnus-summary-article-header id))))
11378 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11379 ;; We have found the header.
11381 ;; We have to really fetch the header to this article.
11383 (set-buffer nntp-server-buffer)
11384 (when (setq where (gnus-request-head id group))
11385 (nnheader-fold-continuation-lines)
11386 (goto-char (point-max))
11388 (goto-char (point-min))
11392 ((cdr where) (cdr where))
11393 (header (mail-header-number header))
11394 (t gnus-reffed-article-number))
11396 (insert " Article retrieved.\n"))
11397 (if (or (not where)
11398 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11399 () ; Malformed head.
11400 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11401 (when (and (stringp id)
11402 (not (string= (gnus-group-real-name group)
11404 ;; If we fetched by Message-ID and the article came
11405 ;; from a different group, we fudge some bogus article
11406 ;; numbers for this article.
11407 (mail-header-set-number header gnus-reffed-article-number))
11409 (set-buffer gnus-summary-buffer)
11410 (decf gnus-reffed-article-number)
11411 (gnus-remove-header (mail-header-number header))
11412 (push header gnus-newsgroup-headers)
11413 (setq gnus-current-headers header)
11414 (push (mail-header-number header) gnus-newsgroup-limit)))
11417 (defun gnus-remove-header (number)
11418 "Remove header NUMBER from `gnus-newsgroup-headers'."
11419 (if (and gnus-newsgroup-headers
11420 (= number (mail-header-number (car gnus-newsgroup-headers))))
11421 (pop gnus-newsgroup-headers)
11422 (let ((headers gnus-newsgroup-headers))
11423 (while (and (cdr headers)
11424 (not (= number (mail-header-number (cadr headers)))))
11426 (when (cdr headers)
11427 (setcdr headers (cddr headers))))))
11430 ;;; summary highlights
11433 (defun gnus-highlight-selected-summary ()
11434 "Highlight selected article in summary buffer."
11435 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11436 (when gnus-summary-selected-face
11438 (let* ((beg (point-at-bol))
11439 (end (point-at-eol))
11440 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11441 (from (if (get-text-property beg gnus-mouse-face-prop)
11443 (or (next-single-property-change
11444 beg gnus-mouse-face-prop nil end)
11449 (or (next-single-property-change
11450 from gnus-mouse-face-prop nil end)
11452 ;; If no mouse-face prop on line we will have to = from = end,
11453 ;; so we highlight the entire line instead.
11454 (when (= (+ to 2) from)
11457 (if gnus-newsgroup-selected-overlay
11458 ;; Move old overlay.
11460 gnus-newsgroup-selected-overlay from to (current-buffer))
11461 ;; Create new overlay.
11463 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11464 'face gnus-summary-selected-face))))))
11466 (defvar gnus-summary-highlight-line-cached nil)
11467 (defvar gnus-summary-highlight-line-trigger nil)
11469 (defun gnus-summary-highlight-line-0 ()
11470 (if (and (eq gnus-summary-highlight-line-trigger
11471 gnus-summary-highlight)
11472 gnus-summary-highlight-line-cached)
11473 gnus-summary-highlight-line-cached
11474 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11475 gnus-summary-highlight-line-cached
11476 (let* ((cond (list 'cond))
11478 (list gnus-summary-highlight))
11480 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11484 (gnus-byte-compile (list 'lambda nil cond))))))
11486 (defun gnus-summary-highlight-line ()
11487 "Highlight current line according to `gnus-summary-highlight'."
11488 (let* ((beg (point-at-bol))
11489 (article (or (gnus-summary-article-number) gnus-current-article))
11490 (score (or (cdr (assq article
11491 gnus-newsgroup-scored))
11492 gnus-summary-default-score 0))
11493 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11494 (inhibit-read-only t)
11495 (default gnus-summary-default-score)
11496 (default-high gnus-summary-default-high-score)
11497 (default-low gnus-summary-default-low-score)
11498 (uncached (and gnus-summary-use-undownloaded-faces
11499 (memq article gnus-newsgroup-undownloaded)
11500 (not (memq article gnus-newsgroup-cached)))))
11501 (let ((face (funcall (gnus-summary-highlight-line-0))))
11502 (unless (eq face (get-text-property beg 'face))
11503 (gnus-put-text-property-excluding-characters-with-faces
11504 beg (point-at-eol) 'face
11505 (setq face (if (boundp face) (symbol-value face) face)))
11506 (when gnus-summary-highlight-line-function
11507 (funcall gnus-summary-highlight-line-function article face))))))
11509 (defun gnus-update-read-articles (group unread &optional compute)
11510 "Update the list of read articles in GROUP.
11511 UNREAD is a sorted list."
11512 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11513 (info (gnus-get-info group))
11516 (if (or (not info) (not active))
11517 ;; There is no info on this group if it was, in fact,
11518 ;; killed. Gnus stores no information on killed groups, so
11519 ;; there's nothing to be done.
11520 ;; One could store the information somewhere temporarily,
11521 ;; perhaps... Hmmm...
11523 ;; Remove any negative articles numbers.
11524 (while (and unread (< (car unread) 0))
11525 (setq unread (cdr unread)))
11526 ;; Remove any expired article numbers
11527 (while (and unread (< (car unread) (car active)))
11528 (setq unread (cdr unread)))
11529 ;; Compute the ranges of read articles by looking at the list of
11530 ;; unread articles.
11532 (when (/= (car unread) prev)
11533 (push (if (= prev (1- (car unread))) prev
11534 (cons prev (1- (car unread))))
11536 (setq prev (1+ (car unread)))
11537 (setq unread (cdr unread)))
11538 (when (<= prev (cdr active))
11539 (push (cons prev (cdr active)) read))
11540 (setq read (if (> (length read) 1) (nreverse read) read))
11545 ;; Propagate the read marks to the backend.
11546 (when (gnus-check-backend-function 'request-set-mark group)
11547 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11548 (add (gnus-remove-from-range read (gnus-info-read info))))
11550 (unless (gnus-check-group group)
11551 (error "Can't open server for %s" group))
11552 (gnus-request-set-mark
11553 group (delq nil (list (if add (list add 'add '(read)))
11554 (if del (list del 'del '(read))))))
11556 `(gnus-request-set-mark
11559 (if del (list del 'add '(read)))
11560 (if add (list add 'del '(read))))))))))
11561 (set-buffer gnus-group-buffer)
11562 (gnus-undo-register
11564 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11565 (gnus-info-set-read ',info ',(gnus-info-read info))
11566 (gnus-get-unread-articles-in-group ',info
11567 (gnus-active ,group))
11568 (gnus-group-update-group ,group t)
11570 ;; Enter this list into the group info.
11571 (gnus-info-set-read info read)
11572 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11573 (gnus-get-unread-articles-in-group info (gnus-active group))
11576 (defun gnus-offer-save-summaries ()
11577 "Offer to save all active summary buffers."
11579 ;; Go through all buffers and find all summaries.
11580 (dolist (buffer (buffer-list))
11581 (when (and (setq buffer (buffer-name buffer))
11582 (string-match "Summary" buffer)
11583 (with-current-buffer buffer
11584 ;; We check that this is, indeed, a summary buffer.
11585 (and (eq major-mode 'gnus-summary-mode)
11586 ;; Also make sure this isn't bogus.
11587 gnus-newsgroup-prepared
11588 ;; Also make sure that this isn't a
11589 ;; dead summary buffer.
11590 (not gnus-dead-summary-mode))))
11591 (push buffer buffers)))
11592 ;; Go through all these summary buffers and offer to save them.
11596 "Update summary buffer %s? "
11598 (switch-to-buffer buf)
11599 (gnus-summary-exit))
11603 ;;; @ for mime-partial
11606 (defun gnus-request-partial-message ()
11608 (let ((number (gnus-summary-article-number))
11609 (group gnus-newsgroup-name)
11610 (mother gnus-article-buffer))
11611 (set-buffer (get-buffer-create " *Partial Article*"))
11613 (setq mime-preview-buffer mother)
11614 (gnus-request-article-this-buffer number group)
11615 (mime-parse-buffer)
11618 (autoload 'mime-combine-message/partial-pieces-automatically
11620 "Internal method to combine message/partial messages automatically.")
11622 (mime-add-condition
11623 'action '((type . message)(subtype . partial)
11624 (major-mode . gnus-original-article-mode)
11625 (method . mime-combine-message/partial-pieces-automatically)
11626 (summary-buffer-exp . gnus-summary-buffer)
11627 (request-partial-message-method . gnus-request-partial-message)
11631 ;;; @ for message/rfc822
11634 (defun gnus-mime-extract-message/rfc822 (entity situation)
11635 "Burst a forwarded article."
11637 (set-buffer gnus-summary-buffer)
11638 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11639 gnus-newsgroup-name 'gnus-group-history))
11640 (gnus-group-marked (list group))
11643 (mime-insert-entity-content entity)
11644 (setq article (gnus-request-accept-article group)))
11645 (when (and (consp article)
11646 (numberp (setq article (cdr article))))
11647 (setq info (gnus-get-info group))
11648 (gnus-info-set-read info
11649 (gnus-remove-from-range (gnus-info-read info)
11651 (when (string-equal group gnus-newsgroup-name)
11653 (let (gnus-show-threads)
11654 (gnus-summary-goto-subject article t))
11655 (gnus-summary-clear-mark-forward 1))
11656 (set-buffer gnus-group-buffer)
11657 (gnus-group-get-new-news-this-group nil t)))))
11659 (mime-add-condition
11660 'action '((type . message)(subtype . rfc822)
11661 (major-mode . gnus-original-article-mode)
11662 (method . gnus-mime-extract-message/rfc822)
11666 (mime-add-condition
11667 'action '((type . message)(subtype . news)
11668 (major-mode . gnus-original-article-mode)
11669 (method . gnus-mime-extract-message/rfc822)
11673 (defun gnus-mime-extract-multipart (entity situation)
11674 (let ((children (mime-entity-children entity))
11675 mime-acting-situation-to-override
11678 (mime-play-entity (car children)
11679 (cons (assq 'mode situation)
11680 mime-acting-situation-to-override))
11681 (setq children (cdr children)))
11682 (if (setq f (cdr (assq 'after-method
11683 mime-acting-situation-to-override)))
11687 (mime-add-condition
11688 'action '((type . multipart)
11689 (method . gnus-mime-extract-multipart)
11698 (defun gnus-summary-inherit-default-charset ()
11699 "Import `default-mime-charset' from summary buffer.
11700 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11702 (if (buffer-live-p gnus-summary-buffer)
11703 (let (d-m-c d-m-c-u)
11704 (with-current-buffer gnus-summary-buffer
11705 (setq d-m-c (if (local-variable-p 'default-mime-charset
11706 gnus-summary-buffer)
11707 default-mime-charset
11710 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11711 gnus-summary-buffer)
11712 (symbol-value 'default-mime-charset-unlimited)
11715 (kill-local-variable 'default-mime-charset)
11716 (set (make-local-variable 'default-mime-charset) d-m-c))
11718 (kill-local-variable 'default-mime-charset-unlimited)
11719 (set (make-local-variable 'default-mime-charset-unlimited)
11722 (defun gnus-summary-setup-default-charset ()
11723 "Setup newsgroup default charset."
11724 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11726 (setq gnus-newsgroup-charset nil)
11727 (set (make-local-variable 'default-mime-charset) nil)
11728 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11729 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11730 (let ((ignored-charsets
11731 (or gnus-newsgroup-ephemeral-ignored-charsets
11733 (and gnus-newsgroup-name
11734 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11735 gnus-newsgroup-ignored-charsets)))
11737 (setq gnus-newsgroup-charset
11738 (or gnus-newsgroup-ephemeral-charset
11739 (when (and gnus-newsgroup-name
11740 (setq charset (gnus-parameter-charset
11741 gnus-newsgroup-name)))
11742 (make-local-variable 'default-mime-charset)
11743 (setq default-mime-charset charset))
11744 gnus-default-charset))
11745 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11746 ignored-charsets))))
11752 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11753 "Display the current article buffer fully MIME-buttonized.
11754 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11755 treated as multipart/mixed."
11757 (require 'gnus-art)
11758 (let ((gnus-unbuttonized-mime-types nil)
11759 (gnus-mime-display-multipart-as-mixed show-all-parts))
11760 (gnus-summary-show-article)))
11762 (defun gnus-summary-repair-multipart (article)
11763 "Add a Content-Type header to a multipart article without one."
11764 (interactive (list (gnus-summary-article-number)))
11765 (gnus-with-article article
11766 (message-narrow-to-head)
11767 (message-remove-header "Mime-Version")
11768 (goto-char (point-max))
11769 (insert "Mime-Version: 1.0\n")
11771 (when (search-forward "\n--" nil t)
11772 (let ((separator (buffer-substring (point) (point-at-eol))))
11773 (message-narrow-to-head)
11774 (message-remove-header "Content-Type")
11775 (goto-char (point-max))
11776 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11779 (let (gnus-mark-article-hook)
11780 (gnus-summary-select-article t t nil article)))
11782 (defun gnus-summary-toggle-display-buttonized ()
11783 "Toggle the buttonizing of the article buffer."
11785 (require 'gnus-art)
11786 (if (setq gnus-inhibit-mime-unbuttonizing
11787 (not gnus-inhibit-mime-unbuttonizing))
11788 (let ((gnus-unbuttonized-mime-types nil))
11789 (gnus-summary-show-article))
11790 (gnus-summary-show-article)))
11793 ;;; Intelli-mouse commmands
11796 (defun gnus-wheel-summary-scroll (event)
11798 (let ((amount (if (memq 'shift (event-modifiers event))
11799 (car gnus-wheel-scroll-amount)
11800 (cdr gnus-wheel-scroll-amount)))
11801 (direction (- (* (static-if (featurep 'xemacs)
11802 (event-button event)
11803 (cond ((eq 'mouse-4 (event-basic-type event))
11805 ((eq 'mouse-5 (event-basic-type event))
11809 (gnus-summary-scroll-up (* amount direction))
11810 (when (gnus-eval-in-buffer-window gnus-article-buffer
11813 (and (if (< 0 direction)
11814 (gnus-article-next-page 0)
11815 (gnus-article-prev-page 0)
11817 (if (setq edge (get-text-property
11818 (point-min) 'gnus-wheel-edge))
11819 (setq edge (* edge direction))
11822 (let ((buffer-read-only nil)
11823 (inhibit-read-only t))
11824 (put-text-property (point-min) (point-max)
11825 'gnus-wheel-edge direction)
11827 (or (> edge gnus-wheel-edge-resistance)
11828 (let ((buffer-read-only nil)
11829 (inhibit-read-only t))
11830 (put-text-property (point-min) (point-max)
11832 (* (1+ edge) direction))
11834 (eq last-command 'gnus-wheel-summary-scroll))))
11835 (gnus-summary-next-article nil nil (minusp direction)))))
11837 (defun gnus-wheel-install ()
11838 "Enable mouse wheel support on summary window."
11839 (when gnus-use-wheel
11841 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11843 (define-key gnus-summary-mode-map key
11844 'gnus-wheel-summary-scroll)))))
11846 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11849 ;;; Traditional PGP commmands
11852 (defun gnus-summary-decrypt-article (&optional force)
11853 "Decrypt the current article in traditional PGP way.
11854 This will have permanent effect only in mail groups.
11855 If FORCE is non-nil, allow editing of articles even in read-only
11858 (gnus-summary-select-article t)
11859 (gnus-eval-in-buffer-window gnus-article-buffer
11863 (goto-char (point-min))
11864 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11865 (error "Not a traditional PGP message!"))
11866 (let ((armor-start (match-beginning 0)))
11867 (if (and (pgg-decrypt-region armor-start (point-max))
11868 (or force (not (gnus-group-read-only-p))))
11869 (let ((inhibit-read-only t)
11871 (delete-region armor-start
11873 (re-search-forward "^-+END PGP" nil t)
11874 (beginning-of-line 2)
11876 (insert-buffer-substring pgg-output-buffer))))))))
11878 (defun gnus-summary-verify-article ()
11879 "Verify the current article in traditional PGP way."
11882 (set-buffer gnus-original-article-buffer)
11883 (goto-char (point-min))
11884 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11885 (error "Not a traditional PGP message!"))
11886 (re-search-forward "^-+END PGP" nil t)
11887 (beginning-of-line 2)
11888 (call-interactively (function pgg-verify-region))))
11891 ;;; Generic summary marking commands
11894 (defvar gnus-summary-marking-alist
11895 '((read gnus-del-mark "d")
11896 (unread gnus-unread-mark "u")
11897 (ticked gnus-ticked-mark "!")
11898 (dormant gnus-dormant-mark "?")
11899 (expirable gnus-expirable-mark "e"))
11900 "An alist of names/marks/keystrokes.")
11902 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11903 (defvar gnus-summary-mark-map)
11905 (defun gnus-summary-make-all-marking-commands ()
11906 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11907 (dolist (elem gnus-summary-marking-alist)
11908 (apply 'gnus-summary-make-marking-command elem)))
11910 (defun gnus-summary-make-marking-command (name mark keystroke)
11911 (let ((map (make-sparse-keymap)))
11912 (define-key gnus-summary-generic-mark-map keystroke map)
11913 (dolist (lway `((next "next" next nil "n")
11914 (next-unread "next unread" next t "N")
11915 (prev "previous" prev nil "p")
11916 (prev-unread "previous unread" prev t "P")
11917 (nomove "" nil nil ,keystroke)))
11918 (let ((func (gnus-summary-make-marking-command-1
11919 mark (car lway) lway name)))
11920 (setq func (eval func))
11921 (define-key map (nth 4 lway) func)))))
11923 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11925 (format "gnus-summary-put-mark-as-%s%s"
11926 name (if (eq way 'nomove)
11928 (concat "-" (symbol-name way)))))
11931 "Mark the current article as %s%s.
11932 If N, the prefix, then repeat N times.
11933 If N is negative, move in reverse order.
11934 The difference between N and the actual number of articles marked is
11936 name (car (cdr lway)))
11938 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11940 (defun gnus-summary-generic-mark (n mark move unread)
11941 "Mark N articles with MARK."
11942 (unless (eq major-mode 'gnus-summary-mode)
11943 (error "This command can only be used in the summary buffer"))
11944 (gnus-summary-show-thread)
11947 ((eq move 'next) 1)
11948 ((eq move 'prev) -1)
11950 (if (zerop nummove)
11954 nummove (* -1 nummove))))
11955 (while (and (> n 0)
11956 (gnus-summary-mark-article nil mark)
11957 (zerop (gnus-summary-next-subject nummove unread t)))
11960 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11961 (gnus-summary-recenter)
11962 (gnus-summary-position-point)
11963 (gnus-set-mode-line 'summary)
11966 (defun gnus-summary-insert-articles (articles)
11967 (when (setq articles
11968 (gnus-sorted-difference articles
11969 (mapcar (lambda (h)
11970 (mail-header-number h))
11971 gnus-newsgroup-headers)))
11972 (setq gnus-newsgroup-headers
11974 gnus-newsgroup-headers
11975 (gnus-fetch-headers articles)
11976 'gnus-article-sort-by-number))
11977 ;; Suppress duplicates?
11978 (when gnus-suppress-duplicates
11979 (gnus-dup-suppress-articles))
11981 ;; We might want to build some more threads first.
11982 (when (and gnus-fetch-old-headers
11983 (eq gnus-headers-retrieved-by 'nov))
11984 (if (eq gnus-fetch-old-headers 'invisible)
11985 (gnus-build-all-threads)
11986 (gnus-build-old-threads)))
11987 ;; Let the Gnus agent mark articles as read.
11989 (gnus-agent-get-undownloaded-list))
11990 ;; Remove list identifiers from subject
11991 (when gnus-list-identifiers
11992 (gnus-summary-remove-list-identifiers))
11993 ;; First and last article in this newsgroup.
11994 (when gnus-newsgroup-headers
11995 (setq gnus-newsgroup-begin
11996 (mail-header-number (car gnus-newsgroup-headers))
11998 (mail-header-number
11999 (gnus-last-element gnus-newsgroup-headers))))
12000 (when gnus-use-scoring
12001 (gnus-possibly-score-headers))))
12003 (defun gnus-summary-insert-old-articles (&optional all)
12004 "Insert all old articles in this group.
12005 If ALL is non-nil, already read articles become readable.
12006 If ALL is a number, fetch this number of articles."
12009 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12012 ;; Some nntp servers lie about their active range. When
12013 ;; this happens, the active range can be in the millions.
12014 ;; Use a compressed range to avoid creating a huge list.
12015 (gnus-range-difference (list gnus-newsgroup-active) old))
12016 (setq len (gnus-range-length older))
12021 (let ((older-range (nreverse older)))
12025 (let* ((r (pop older-range))
12026 (min (if (numberp r) r (car r)))
12027 (max (if (numberp r) r (cdr r))))
12028 (while (and (<= min max)
12033 (setq older (gnus-uncompress-range older))))
12035 (setq older (gnus-uncompress-range older)))
12037 (when (and (numberp gnus-large-newsgroup)
12038 (> len gnus-large-newsgroup))
12039 (let* ((cursor-in-echo-area nil)
12040 (initial (gnus-parameter-large-newsgroup-initial
12041 gnus-newsgroup-name))
12045 "How many articles from %s (%s %d): "
12047 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12048 (if initial "max" "default")
12051 (cons (number-to-string initial)
12053 (unless (string-match "^[ \t]*$" input)
12054 (setq all (string-to-number input))
12056 (let ((older-range (nreverse older)))
12060 (let* ((r (pop older-range))
12061 (min (if (numberp r) r (car r)))
12062 (max (if (numberp r) r (cdr r))))
12063 (while (and (<= min max)
12067 max (1- max))))))))))
12068 (setq older (gnus-uncompress-range older))))
12070 (message "No old news.")
12071 (gnus-summary-insert-articles older)
12072 (gnus-summary-limit (gnus-sorted-nunion old older))))
12073 (gnus-summary-position-point)))
12075 (defun gnus-summary-insert-new-articles ()
12076 "Insert all new articles in this group."
12079 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12080 (old-active gnus-newsgroup-active)
12081 (nnmail-fetched-sources (list t))
12083 (setq gnus-newsgroup-active
12084 (gnus-activate-group gnus-newsgroup-name 'scan))
12085 (setq i (cdr gnus-newsgroup-active))
12086 (while (> i (cdr old-active))
12090 (message "No gnus is bad news")
12091 (gnus-summary-insert-articles new)
12092 (setq gnus-newsgroup-unreads
12093 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12094 (gnus-summary-limit (gnus-sorted-nunion old new))))
12095 (gnus-summary-position-point)))
12097 (gnus-summary-make-all-marking-commands)
12099 (gnus-ems-redefine)
12101 (provide 'gnus-sum)
12103 (run-hooks 'gnus-sum-load-hook)
12105 ;; Local Variables:
12106 ;; coding: iso-8859-1
12109 ;;; gnus-sum.el ends here