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 non-nil, 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)
89 (sexp :menu-tag "other" t)))
91 (defcustom gnus-refer-thread-limit 200
92 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
93 If t, fetch all the available old headers."
96 (sexp :menu-tag "other" t)))
98 (defcustom gnus-summary-make-false-root 'adopt
99 "*nil means that Gnus won't gather loose threads.
100 If the root of a thread has expired or been read in a previous
101 session, the information necessary to build a complete thread has been
102 lost. Instead of having many small sub-threads from this original thread
103 scattered all over the summary buffer, Gnus can gather them.
105 If non-nil, Gnus will try to gather all loose sub-threads from an
106 original thread into one large thread.
108 If this variable is non-nil, it should be one of `none', `adopt',
111 If this variable is `none', Gnus will not make a false root, but just
112 present the sub-threads after another.
113 If this variable is `dummy', Gnus will create a dummy root that will
114 have all the sub-threads as children.
115 If this variable is `adopt', Gnus will make one of the \"children\"
116 the parent and mark all the step-children as such.
117 If this variable is `empty', the \"children\" are printed with empty
118 subject fields. (Or rather, they will be printed with a string
119 given by the `gnus-summary-same-subject' variable.)"
121 :type '(choice (const :tag "off" nil)
127 (defcustom gnus-summary-make-false-root-always nil
128 "Always make a false dummy root."
132 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
133 "*A regexp to match subjects to be excluded from loose thread gathering.
134 As loose thread gathering is done on subjects only, that means that
135 there can be many false gatherings performed. By rooting out certain
136 common subjects, gathering might become saner."
140 (defcustom gnus-summary-gather-subject-limit nil
141 "*Maximum length of subject comparisons when gathering loose threads.
142 Use nil to compare full subjects. Setting this variable to a low
143 number will help gather threads that have been corrupted by
144 newsreaders chopping off subject lines, but it might also mean that
145 unrelated articles that have subject that happen to begin with the
146 same few characters will be incorrectly gathered.
148 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
151 :type '(choice (const :tag "off" nil)
153 (sexp :menu-tag "on" t)))
155 (defcustom gnus-simplify-subject-functions nil
156 "List of functions taking a string argument that simplify subjects.
157 The functions are applied recursively.
159 Useful functions to put in this list include:
160 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
161 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
163 :type '(repeat function))
165 (defcustom gnus-simplify-ignored-prefixes nil
166 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
168 :type '(choice (const :tag "off" nil)
171 (defcustom gnus-build-sparse-threads nil
172 "*If non-nil, fill in the gaps in threads.
173 If `some', only fill in the gaps that are needed to tie loose threads
174 together. If `more', fill in all leaf nodes that Gnus can find. If
175 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
177 :type '(choice (const :tag "off" nil)
180 (sexp :menu-tag "all" t)))
182 (defcustom gnus-summary-thread-gathering-function
183 'gnus-gather-threads-by-subject
184 "*Function used for gathering loose threads.
185 There are two pre-defined functions: `gnus-gather-threads-by-subject',
186 which only takes Subjects into consideration; and
187 `gnus-gather-threads-by-references', which compared the References
188 headers of the articles to find matches."
190 :type '(radio (function-item gnus-gather-threads-by-subject)
191 (function-item gnus-gather-threads-by-references)
192 (function :tag "other")))
194 (defcustom gnus-summary-same-subject ""
195 "*String indicating that the current article has the same subject as the previous.
196 This variable will only be used if the value of
197 `gnus-summary-make-false-root' is `empty'."
198 :group 'gnus-summary-format
201 (defcustom gnus-summary-goto-unread t
202 "*If t, many commands will go to the next unread article.
203 This applies to marking commands as well as other commands that
204 \"naturally\" select the next article, like, for instance, `SPC' at
205 the end of an article.
207 If nil, the marking commands do NOT go to the next unread article
208 \(they go to the next article instead). If `never', commands that
209 usually go to the next unread article, will go to the next article,
210 whether it is read or not."
211 :group 'gnus-summary-marks
212 :link '(custom-manual "(gnus)Setting Marks")
213 :type '(choice (const :tag "off" nil)
215 (sexp :menu-tag "on" t)))
217 (defcustom gnus-summary-default-score 0
218 "*Default article score level.
219 All scores generated by the score files will be added to this score.
220 If this variable is nil, scoring will be disabled."
221 :group 'gnus-score-default
222 :type '(choice (const :tag "disable")
225 (defcustom gnus-summary-default-high-score 0
226 "*Default threshold for a high scored article.
227 An article will be highlighted as high scored if its score is greater
229 :group 'gnus-score-default
232 (defcustom gnus-summary-default-low-score 0
233 "*Default threshold for a low scored article.
234 An article will be highlighted as low scored if its score is smaller
236 :group 'gnus-score-default
239 (defcustom gnus-summary-zcore-fuzz 0
240 "*Fuzziness factor for the zcore in the summary buffer.
241 Articles with scores closer than this to `gnus-summary-default-score'
243 :group 'gnus-summary-format
246 (defcustom gnus-simplify-subject-fuzzy-regexp nil
247 "*Strings to be removed when doing fuzzy matches.
248 This can either be a regular expression or list of regular expressions
249 that will be removed from subject strings if fuzzy subject
250 simplification is selected."
252 :type '(repeat regexp))
254 (defcustom gnus-show-threads t
255 "*If non-nil, display threads in summary mode."
259 (defcustom gnus-thread-hide-subtree nil
260 "*If non-nil, hide all threads initially.
261 This can be a predicate specifier which says which threads to hide.
262 If threads are hidden, you have to run the command
263 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
264 to expose hidden threads."
266 :type '(radio (sexp :format "Non-nil\n"
267 :match (lambda (widget value)
268 (not (or (consp value) (functionp value))))
271 (sexp :tag "Predicate specifier" :size 0)))
273 (defcustom gnus-thread-hide-killed t
274 "*If non-nil, hide killed threads automatically."
278 (defcustom gnus-thread-ignore-subject t
279 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
280 If nil, articles that have different subjects from their parents will
281 start separate threads."
285 (defcustom gnus-thread-operation-ignore-subject t
286 "*If non-nil, subjects will be ignored when doing thread commands.
287 This affects commands like `gnus-summary-kill-thread' and
288 `gnus-summary-lower-thread'.
290 If this variable is nil, articles in the same thread with different
291 subjects will not be included in the operation in question. If this
292 variable is `fuzzy', only articles that have subjects that are fuzzily
293 equal will be included."
295 :type '(choice (const :tag "off" nil)
299 (defcustom gnus-thread-indent-level 4
300 "*Number that says how much each sub-thread should be indented."
304 (defcustom gnus-auto-extend-newsgroup t
305 "*If non-nil, extend newsgroup forward and backward when requested."
306 :group 'gnus-summary-choose
309 (defcustom gnus-auto-select-first t
310 "*If non-nil, select the article under point.
311 Which article this is is controlled by the `gnus-auto-select-subject'
314 If you want to prevent automatic selection of articles in some
315 newsgroups, set the variable to nil in `gnus-select-group-hook'."
316 :group 'gnus-group-select
317 :type '(choice (const :tag "none" nil)
318 (sexp :menu-tag "first" t)))
320 (defcustom gnus-auto-select-subject 'unread
321 "*Says what subject to place under point when entering a group.
323 This variable can either be the symbols `first' (place point on the
324 first subject), `unread' (place point on the subject line of the first
325 unread article), `best' (place point on the subject line of the
326 higest-scored article), `unseen' (place point on the subject line of
327 the first unseen article), 'unseen-or-unread' (place point on the subject
328 line of the first unseen article or, if all article have been seen, on the
329 subject line of the first unread article), or a function to be called to
330 place point on some subject line."
331 :group 'gnus-group-select
332 :type '(choice (const best)
336 (const unseen-or-unread)))
338 (defcustom gnus-dont-select-after-jump-to-other-group nil
339 "If non-nil, don't select the first unread article after entering the
340 other group by the command `gnus-summary-jump-to-other-group'. If nil,
341 it is depend on the value of `gnus-auto-select-first' whether to select
343 :group 'gnus-group-select
346 (defcustom gnus-auto-select-next t
347 "*If non-nil, offer to go to the next group from the end of the previous.
348 If the value is t and the next newsgroup is empty, Gnus will exit
349 summary mode and go back to group mode. If the value is neither nil
350 nor t, Gnus will select the following unread newsgroup. In
351 particular, if the value is the symbol `quietly', the next unread
352 newsgroup will be selected without any confirmation, and if it is
353 `almost-quietly', the next group will be selected without any
354 confirmation if you are located on the last article in the group.
355 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
356 will go to the next group without confirmation."
357 :group 'gnus-summary-maneuvering
358 :type '(choice (const :tag "off" nil)
360 (const almost-quietly)
361 (const slightly-quietly)
362 (sexp :menu-tag "on" t)))
364 (defcustom gnus-auto-select-same nil
365 "*If non-nil, select the next article with the same subject.
366 If there are no more articles with the same subject, go to
367 the first unread article."
368 :group 'gnus-summary-maneuvering
371 (defcustom gnus-auto-goto-ignores 'unfetched
372 "*Says how to handle unfetched articles when maneuvering.
374 This variable can either be the symbols nil (maneuver to any
375 article), `undownloaded' (maneuvering while unplugged ignores articles
376 that have not been fetched), `always-undownloaded' (maneuvering always
377 ignores articles that have not been fetched), `unfetched' (maneuvering
378 ignores articles whose headers have not been fetched).
380 NOTE: The list of unfetched articles will always be nil when plugged
381 and, when unplugged, a subset of the undownloaded article list."
382 :group 'gnus-summary-maneuvering
383 :type '(choice (const :tag "None" nil)
384 (const :tag "Undownloaded when unplugged" undownloaded)
385 (const :tag "Undownloaded" always-undownloaded)
386 (const :tag "Unfetched" unfetched)))
388 (defcustom gnus-summary-check-current nil
389 "*If non-nil, consider the current article when moving.
390 The \"unread\" movement commands will stay on the same line if the
391 current article is unread."
392 :group 'gnus-summary-maneuvering
395 (defcustom gnus-auto-center-summary t
396 "*If non-nil, always center the current summary buffer.
397 In particular, if `vertical' do only vertical recentering. If non-nil
398 and non-`vertical', do both horizontal and vertical recentering."
399 :group 'gnus-summary-maneuvering
400 :type '(choice (const :tag "none" nil)
402 (integer :tag "height")
403 (sexp :menu-tag "both" t)))
405 (defvar gnus-auto-center-group t
406 "*If non-nil, always center the group buffer.")
408 (defcustom gnus-show-all-headers nil
409 "*If non-nil, don't hide any headers."
410 :group 'gnus-article-hiding
411 :group 'gnus-article-headers
414 (defcustom gnus-summary-ignore-duplicates nil
415 "*If non-nil, ignore articles with identical Message-ID headers."
419 (defcustom gnus-single-article-buffer t
420 "*If non-nil, display all articles in the same buffer.
421 If nil, each group will get its own article buffer."
422 :group 'gnus-article-various
425 (defcustom gnus-break-pages t
426 "*If non-nil, do page breaking on articles.
427 The page delimiter is specified by the `gnus-page-delimiter'
429 :group 'gnus-article-various
432 (defcustom gnus-show-mime t
433 "*If non-nil, do mime processing of articles.
434 The articles will simply be fed to the function given by
435 `gnus-article-display-method-for-mime'."
436 :group 'gnus-article-mime
439 (defcustom gnus-move-split-methods nil
440 "*Variable used to suggest where articles are to be moved to.
441 It uses the same syntax as the `gnus-split-methods' variable.
442 However, whereas `gnus-split-methods' specifies file names as targets,
443 this variable specifies group names."
444 :group 'gnus-summary-mail
445 :type '(repeat (choice (list :value (fun) function)
446 (cons :value ("" "") regexp (repeat string))
449 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
450 "Function used to compute default prefix for article move/copy/etc prompts.
451 The function should take one argument, a group name, and return a
452 string with the suggested prefix."
453 :group 'gnus-summary-mail
456 (defcustom gnus-unread-mark ?\ ;;;Whitespace
457 "*Mark used for unread articles."
458 :group 'gnus-summary-marks
461 (defcustom gnus-ticked-mark ?!
462 "*Mark used for ticked articles."
463 :group 'gnus-summary-marks
466 (defcustom gnus-dormant-mark ??
467 "*Mark used for dormant articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-del-mark ?r
472 "*Mark used for del'd articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-read-mark ?R
477 "*Mark used for read articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-expirable-mark ?E
482 "*Mark used for expirable articles."
483 :group 'gnus-summary-marks
486 (defcustom gnus-killed-mark ?K
487 "*Mark used for killed articles."
488 :group 'gnus-summary-marks
491 (defcustom gnus-spam-mark ?$
492 "*Mark used for spam articles."
493 :group 'gnus-summary-marks
496 (defcustom gnus-souped-mark ?F
497 "*Mark used for souped articles."
498 :group 'gnus-summary-marks
501 (defcustom gnus-kill-file-mark ?X
502 "*Mark used for articles killed by kill files."
503 :group 'gnus-summary-marks
506 (defcustom gnus-low-score-mark ?Y
507 "*Mark used for articles with a low score."
508 :group 'gnus-summary-marks
511 (defcustom gnus-catchup-mark ?C
512 "*Mark used for articles that are caught up."
513 :group 'gnus-summary-marks
516 (defcustom gnus-replied-mark ?A
517 "*Mark used for articles that have been replied to."
518 :group 'gnus-summary-marks
521 (defcustom gnus-forwarded-mark ?F
522 "*Mark used for articles that have been forwarded."
523 :group 'gnus-summary-marks
526 (defcustom gnus-recent-mark ?N
527 "*Mark used for articles that are recent."
528 :group 'gnus-summary-marks
531 (defcustom gnus-cached-mark ?*
532 "*Mark used for articles that are in the cache."
533 :group 'gnus-summary-marks
536 (defcustom gnus-saved-mark ?S
537 "*Mark used for articles that have been saved."
538 :group 'gnus-summary-marks
541 (defcustom gnus-unseen-mark ?.
542 "*Mark used for articles that haven't been seen."
543 :group 'gnus-summary-marks
546 (defcustom gnus-no-mark ?\ ;;;Whitespace
547 "*Mark used for articles that have no other secondary mark."
548 :group 'gnus-summary-marks
551 (defcustom gnus-ancient-mark ?O
552 "*Mark used for ancient articles."
553 :group 'gnus-summary-marks
556 (defcustom gnus-sparse-mark ?Q
557 "*Mark used for sparsely reffed articles."
558 :group 'gnus-summary-marks
561 (defcustom gnus-canceled-mark ?G
562 "*Mark used for canceled articles."
563 :group 'gnus-summary-marks
566 (defcustom gnus-duplicate-mark ?M
567 "*Mark used for duplicate articles."
568 :group 'gnus-summary-marks
571 (defcustom gnus-undownloaded-mark ?-
572 "*Mark used for articles that weren't downloaded."
573 :group 'gnus-summary-marks
576 (defcustom gnus-downloaded-mark ?+
577 "*Mark used for articles that were downloaded."
578 :group 'gnus-summary-marks
581 (defcustom gnus-downloadable-mark ?%
582 "*Mark used for articles that are to be downloaded."
583 :group 'gnus-summary-marks
586 (defcustom gnus-unsendable-mark ?=
587 "*Mark used for articles that won't be sent."
588 :group 'gnus-summary-marks
591 (defcustom gnus-score-over-mark ?+
592 "*Score mark used for articles with high scores."
593 :group 'gnus-summary-marks
596 (defcustom gnus-score-below-mark ?-
597 "*Score mark used for articles with low scores."
598 :group 'gnus-summary-marks
601 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
602 "*There is no thread under the article."
603 :group 'gnus-summary-marks
606 (defcustom gnus-not-empty-thread-mark ?=
607 "*There is a thread under the article."
608 :group 'gnus-summary-marks
611 (defcustom gnus-view-pseudo-asynchronously nil
612 "*If non-nil, Gnus will view pseudo-articles asynchronously."
613 :group 'gnus-extract-view
616 (defcustom gnus-auto-expirable-marks
617 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
618 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
619 gnus-souped-mark gnus-duplicate-mark)
620 "*The list of marks converted into expiration if a group is auto-expirable."
623 :type '(repeat character))
625 (defcustom gnus-inhibit-user-auto-expire t
626 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
631 (defcustom gnus-view-pseudos nil
632 "*If `automatic', pseudo-articles will be viewed automatically.
633 If `not-confirm', pseudos will be viewed automatically, and the user
634 will not be asked to confirm the command."
635 :group 'gnus-extract-view
636 :type '(choice (const :tag "off" nil)
638 (const not-confirm)))
640 (defcustom gnus-view-pseudos-separately t
641 "*If non-nil, one pseudo-article will be created for each file to be viewed.
642 If nil, all files that use the same viewing command will be given as a
643 list of parameters to that command."
644 :group 'gnus-extract-view
647 (defcustom gnus-insert-pseudo-articles t
648 "*If non-nil, insert pseudo-articles when decoding articles."
649 :group 'gnus-extract-view
652 (defcustom gnus-summary-dummy-line-format
654 "*The format specification for the dummy roots in the summary buffer.
655 It works along the same lines as a normal formatting string,
656 with some simple extensions.
660 General format specifiers can also be used.
661 See `(gnus)Formatting Variables'."
662 :link '(custom-manual "(gnus)Formatting Variables")
663 :group 'gnus-threading
666 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
667 "*The format specification for the summary mode line.
668 It works along the same lines as a normal formatting string,
669 with some simple extensions:
672 %p Unprefixed group name
673 %A Current article number
674 %z Current article score
676 %U Number of unread articles in the group
677 %e Number of unselected articles in the group
678 %Z A string with unread/unselected article counts
679 %g Shortish group name
680 %S Subject of the current article
682 %s Current score file name
683 %d Number of dormant articles
684 %r Number of articles that have been marked as read in this session
685 %E Number of articles expunged by the score files"
686 :group 'gnus-summary-format
689 (defcustom gnus-list-identifiers nil
690 "Regexp that matches list identifiers to be removed from subject.
691 This can also be a list of regexps."
693 :group 'gnus-summary-format
694 :group 'gnus-article-hiding
695 :type '(choice (const :tag "none" nil)
697 (repeat :value (".*") regexp)))
699 (defcustom gnus-summary-mark-below 0
700 "*Mark all articles with a score below this variable as read.
701 This variable is local to each summary buffer and usually set by the
703 :group 'gnus-score-default
706 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
707 "*List of functions used for sorting articles in the summary buffer.
709 Each function takes two articles and returns non-nil if the first
710 article should be sorted before the other. If you use more than one
711 function, the primary sort function should be the last. You should
712 probably always include `gnus-article-sort-by-number' in the list of
713 sorting functions -- preferably first. Also note that sorting by date
714 is often much slower than sorting by number, and the sorting order is
715 very similar. (Sorting by date means sorting by the time the message
716 was sent, sorting by number means sorting by arrival time.)
718 Ready-made functions include `gnus-article-sort-by-number',
719 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
720 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
721 and `gnus-article-sort-by-score'.
723 When threading is turned on, the variable `gnus-thread-sort-functions'
724 controls how articles are sorted."
725 :group 'gnus-summary-sort
726 :type '(repeat (choice (function-item gnus-article-sort-by-number)
727 (function-item gnus-article-sort-by-author)
728 (function-item gnus-article-sort-by-subject)
729 (function-item gnus-article-sort-by-date)
730 (function-item gnus-article-sort-by-score)
731 (function-item gnus-article-sort-by-random)
732 (function :tag "other"))))
734 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
735 "*List of functions used for sorting threads in the summary buffer.
736 By default, threads are sorted by article number.
738 Each function takes two threads and returns non-nil if the first
739 thread should be sorted before the other. If you use more than one
740 function, the primary sort function should be the last. You should
741 probably always include `gnus-thread-sort-by-number' in the list of
742 sorting functions -- preferably first. Also note that sorting by date
743 is often much slower than sorting by number, and the sorting order is
744 very similar. (Sorting by date means sorting by the time the message
745 was sent, sorting by number means sorting by arrival time.)
747 Ready-made functions include `gnus-thread-sort-by-number',
748 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
749 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
750 `gnus-thread-sort-by-most-recent-number',
751 `gnus-thread-sort-by-most-recent-date',
752 `gnus-thread-sort-by-random', and
753 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
755 When threading is turned off, the variable
756 `gnus-article-sort-functions' controls how articles are sorted."
757 :group 'gnus-summary-sort
758 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
759 (function-item gnus-thread-sort-by-author)
760 (function-item gnus-thread-sort-by-subject)
761 (function-item gnus-thread-sort-by-date)
762 (function-item gnus-thread-sort-by-score)
763 (function-item gnus-thread-sort-by-total-score)
764 (function-item gnus-thread-sort-by-random)
765 (function :tag "other"))))
767 (defcustom gnus-thread-score-function '+
768 "*Function used for calculating the total score of a thread.
770 The function is called with the scores of the article and each
771 subthread and should then return the score of the thread.
773 Some functions you can use are `+', `max', or `min'."
774 :group 'gnus-summary-sort
777 (defcustom gnus-summary-expunge-below nil
778 "All articles that have a score less than this variable will be expunged.
779 This variable is local to the summary buffers."
780 :group 'gnus-score-default
781 :type '(choice (const :tag "off" nil)
784 (defcustom gnus-thread-expunge-below nil
785 "All threads that have a total score less than this variable will be expunged.
786 See `gnus-thread-score-function' for en explanation of what a
789 This variable is local to the summary buffers."
790 :group 'gnus-threading
791 :group 'gnus-score-default
792 :type '(choice (const :tag "off" nil)
795 (defcustom gnus-summary-mode-hook nil
796 "*A hook for Gnus summary mode.
797 This hook is run before any variables are set in the summary buffer."
798 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
799 :group 'gnus-summary-various
802 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
803 (when (featurep 'xemacs)
804 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
805 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
806 (add-hook 'gnus-summary-mode-hook
807 'gnus-xmas-switch-horizontal-scrollbar-off))
809 (defcustom gnus-summary-menu-hook nil
810 "*Hook run after the creation of the summary mode menu."
811 :group 'gnus-summary-visual
814 (defcustom gnus-summary-exit-hook nil
815 "*A hook called on exit from the summary buffer.
816 It will be called with point in the group buffer."
817 :group 'gnus-summary-exit
820 (defcustom gnus-summary-prepare-hook nil
821 "*A hook called after the summary buffer has been generated.
822 If you want to modify the summary buffer, you can use this hook."
823 :group 'gnus-summary-various
826 (defcustom gnus-summary-prepared-hook nil
827 "*A hook called as the last thing after the summary buffer has been generated."
828 :group 'gnus-summary-various
831 (defcustom gnus-summary-generate-hook nil
832 "*A hook run just before generating the summary buffer.
833 This hook is commonly used to customize threading variables and the
835 :group 'gnus-summary-various
838 (defcustom gnus-select-group-hook nil
839 "*A hook called when a newsgroup is selected.
841 If you'd like to simplify subjects like the
842 `gnus-summary-next-same-subject' command does, you can use the
845 (add-hook gnus-select-group-hook
847 (mapcar (lambda (header)
848 (mail-header-set-subject
850 (gnus-simplify-subject
851 (mail-header-subject header) 're-only)))
852 gnus-newsgroup-headers)))"
853 :group 'gnus-group-select
856 (defcustom gnus-select-article-hook nil
857 "*A hook called when an article is selected."
858 :group 'gnus-summary-choose
859 :options '(gnus-agent-fetch-selected-article)
862 (defcustom gnus-visual-mark-article-hook
863 (list 'gnus-highlight-selected-summary)
864 "*Hook run after selecting an article in the summary buffer.
865 It is meant to be used for highlighting the article in some way. It
866 is not run if `gnus-visual' is nil."
867 :group 'gnus-summary-visual
870 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
871 "*A hook called before parsing the headers."
875 (defcustom gnus-exit-group-hook nil
876 "*A hook called when exiting summary mode.
877 This hook is not called from the non-updating exit commands like `Q'."
881 (defcustom gnus-summary-update-hook
882 (list 'gnus-summary-highlight-line)
883 "*A hook called when a summary line is changed.
884 The hook will not be called if `gnus-visual' is nil.
886 The default function `gnus-summary-highlight-line' will
887 highlight the line according to the `gnus-summary-highlight'
889 :group 'gnus-summary-visual
892 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
893 "*A hook called when an article is selected for the first time.
894 The hook is intended to mark an article as read (or unread)
895 automatically when it is selected."
896 :group 'gnus-summary-choose
899 (defcustom gnus-group-no-more-groups-hook nil
900 "*A hook run when returning to group mode having no more (unread) groups."
901 :group 'gnus-group-select
904 (defcustom gnus-ps-print-hook nil
905 "*A hook run before ps-printing something from Gnus."
909 (defcustom gnus-summary-article-move-hook nil
910 "*A hook called after an article is moved, copied, respooled, or crossposted."
914 (defcustom gnus-summary-article-delete-hook nil
915 "*A hook called after an article is deleted."
919 (defcustom gnus-summary-article-expire-hook nil
920 "*A hook called after an article is expired."
924 (defcustom gnus-summary-display-arrow
925 (and (fboundp 'display-graphic-p)
927 "*If non-nil, display an arrow highlighting the current article."
932 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
933 "Face used for highlighting the current article in the summary buffer."
934 :group 'gnus-summary-visual
937 (defvar gnus-tmp-downloaded nil)
939 (defcustom gnus-summary-highlight
940 '(((eq mark gnus-canceled-mark)
941 . gnus-summary-cancelled-face)
942 ((and uncached (> score default-high))
943 . gnus-summary-high-undownloaded-face)
944 ((and uncached (< score default-low))
945 . gnus-summary-low-undownloaded-face)
947 . gnus-summary-normal-undownloaded-face)
948 ((and (> score default-high)
949 (or (eq mark gnus-dormant-mark)
950 (eq mark gnus-ticked-mark)))
951 . gnus-summary-high-ticked-face)
952 ((and (< score default-low)
953 (or (eq mark gnus-dormant-mark)
954 (eq mark gnus-ticked-mark)))
955 . gnus-summary-low-ticked-face)
956 ((or (eq mark gnus-dormant-mark)
957 (eq mark gnus-ticked-mark))
958 . gnus-summary-normal-ticked-face)
959 ((and (> score default-high) (eq mark gnus-ancient-mark))
960 . gnus-summary-high-ancient-face)
961 ((and (< score default-low) (eq mark gnus-ancient-mark))
962 . gnus-summary-low-ancient-face)
963 ((eq mark gnus-ancient-mark)
964 . gnus-summary-normal-ancient-face)
965 ((and (> score default-high) (eq mark gnus-unread-mark))
966 . gnus-summary-high-unread-face)
967 ((and (< score default-low) (eq mark gnus-unread-mark))
968 . gnus-summary-low-unread-face)
969 ((eq mark gnus-unread-mark)
970 . gnus-summary-normal-unread-face)
971 ((> score default-high)
972 . gnus-summary-high-read-face)
973 ((< score default-low)
974 . gnus-summary-low-read-face)
976 . gnus-summary-normal-read-face))
977 "*Controls the highlighting of summary buffer lines.
979 A list of (FORM . FACE) pairs. When deciding how a a particular
980 summary line should be displayed, each form is evaluated. The content
981 of the face field after the first true form is used. You can change
982 how those summary lines are displayed, by editing the face field.
984 You can use the following variables in the FORM field.
986 score: The article's score
987 default: The default article score.
988 default-high: The default score for high scored articles.
989 default-low: The default score for low scored articles.
990 below: The score below which articles are automatically marked as read.
991 mark: The article's mark.
992 uncached: Non-nil if the article is uncached."
993 :group 'gnus-summary-visual
994 :type '(repeat (cons (sexp :tag "Form" nil)
997 (defcustom gnus-alter-header-function nil
998 "Function called to allow alteration of article header structures.
999 The function is called with one parameter, the article header vector,
1000 which it may alter in any way."
1001 :type '(choice (const :tag "None" nil)
1003 :group 'gnus-summary)
1005 (defvar gnus-decode-encoded-word-function
1006 (mime-find-field-decoder 'From 'nov)
1007 "Variable that says which function should be used to decode a string with encoded words.")
1009 (defcustom gnus-extra-headers '(To Newsgroups)
1010 "*Extra headers to parse."
1012 :group 'gnus-summary
1013 :type '(repeat symbol))
1015 (defcustom gnus-ignored-from-addresses
1016 (and user-mail-address (regexp-quote user-mail-address))
1017 "*Regexp of From headers that may be suppressed in favor of To headers."
1019 :group 'gnus-summary
1022 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1023 "List of charsets that should be ignored.
1024 When these charsets are used in the \"charset\" parameter, the
1025 default charset will be used instead."
1027 :type '(repeat symbol)
1028 :group 'gnus-charset)
1030 (gnus-define-group-parameter
1034 "Return the ignored charsets of GROUP."
1035 :variable gnus-group-ignored-charsets-alist
1037 '(("alt\\.chinese\\.text" iso-8859-1))
1039 "Alist of regexps (to match group names) and charsets that should be ignored.
1040 When these charsets are used in the \"charset\" parameter, the
1041 default charset will be used instead."
1042 :variable-group gnus-charset
1043 :variable-type '(repeat (cons (regexp :tag "Group")
1045 :parameter-type '(choice :tag "Ignored charsets"
1048 :parameter-document "\
1049 List of charsets that should be ignored.
1051 When these charsets are used in the \"charset\" parameter, the
1052 default charset will be used instead.")
1054 (defcustom gnus-group-highlight-words-alist nil
1055 "Alist of group regexps and highlight regexps.
1056 This variable uses the same syntax as `gnus-emphasis-alist'."
1058 :type '(repeat (cons (regexp :tag "Group")
1059 (repeat (list (regexp :tag "Highlight regexp")
1060 (number :tag "Group for entire word" 0)
1061 (number :tag "Group for displayed part" 0)
1063 gnus-emphasis-highlight-words)))))
1064 :group 'gnus-summary-visual)
1066 (defcustom gnus-use-wheel nil
1067 "Use Intelli-mouse on summary movement"
1069 :group 'gnus-summary-maneuvering)
1071 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1072 "Amount to scroll messages by spinning the mouse wheel.
1073 This is actually a cons cell, where the first item is the amount to scroll
1074 on a normal wheel event, and the second is the amount to scroll when the
1075 wheel is moved with the shift key depressed."
1076 :type '(cons (integer :tag "Shift") integer)
1077 :group 'gnus-summary-maneuvering)
1079 (defcustom gnus-wheel-edge-resistance 2
1080 "How hard it should be to change the current article
1081 by moving the mouse over the edge of the article window."
1083 :group 'gnus-summary-maneuvering)
1085 (defcustom gnus-summary-show-article-charset-alist
1087 "Alist of number and charset.
1088 The article will be shown with the charset corresponding to the
1090 For example: ((1 . cn-gb-2312) (2 . big5))."
1092 :type '(repeat (cons (number :tag "Argument" 1)
1093 (symbol :tag "Charset")))
1094 :group 'gnus-charset)
1096 (defcustom gnus-preserve-marks t
1097 "Whether marks are preserved when moving, copying and respooling messages."
1100 :group 'gnus-summary-marks)
1102 (defcustom gnus-alter-articles-to-read-function nil
1103 "Function to be called to alter the list of articles to be selected."
1104 :type '(choice (const nil) function)
1105 :group 'gnus-summary)
1107 (defcustom gnus-orphan-score nil
1108 "*All orphans get this score added. Set in the score file."
1109 :group 'gnus-score-default
1110 :type '(choice (const nil)
1113 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1114 "*A regexp to match MIME parts when saving multiple parts of a
1115 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1116 This regexp will be used by default when prompting the user for which
1117 type of files to save."
1118 :group 'gnus-summary
1121 (defcustom gnus-read-all-available-headers nil
1122 "Whether Gnus should parse all headers made available to it.
1123 This is mostly relevant for slow back ends where the user may
1124 wish to widen the summary buffer to include all headers
1125 that were fetched. Say, for nnultimate groups."
1126 :group 'gnus-summary
1127 :type '(choice boolean regexp))
1129 (defcustom gnus-summary-muttprint-program "muttprint"
1130 "Command (and optional arguments) used to run Muttprint."
1132 :group 'gnus-summary
1135 (defcustom gnus-article-loose-mime nil
1136 "If non-nil, don't require MIME-Version header.
1137 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1138 supply the MIME-Version header or deliberately strip it From the mail.
1139 Set it to non-nil, Gnus will treat some articles as MIME even if
1140 the MIME-Version header is missed."
1143 :group 'gnus-article-mime)
1145 (defcustom gnus-article-emulate-mime t
1146 "If non-nil, use MIME emulation for uuencode and the like.
1147 This means that Gnus will search message bodies for text that look
1148 like uuencoded bits, yEncoded bits, and so on, and present that using
1149 the normal Gnus MIME machinery."
1151 :group 'gnus-article-mime)
1153 ;;; Internal variables
1155 (defvar gnus-summary-display-cache nil)
1156 (defvar gnus-article-mime-handles nil)
1157 (defvar gnus-article-decoded-p nil)
1158 (defvar gnus-article-charset nil)
1159 (defvar gnus-article-ignored-charsets nil)
1160 (defvar gnus-scores-exclude-files nil)
1161 (defvar gnus-page-broken nil)
1163 (defvar gnus-original-article nil)
1164 (defvar gnus-article-internal-prepare-hook nil)
1165 (defvar gnus-newsgroup-process-stack nil)
1167 (defvar gnus-thread-indent-array nil)
1168 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1169 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1170 "Function called to sort the articles within a thread after it has been gathered together.")
1172 (defvar gnus-summary-save-parts-type-history nil)
1173 (defvar gnus-summary-save-parts-last-directory nil)
1175 ;; Avoid highlighting in kill files.
1176 (defvar gnus-summary-inhibit-highlight nil)
1177 (defvar gnus-newsgroup-selected-overlay nil)
1178 (defvar gnus-inhibit-limiting nil)
1179 (defvar gnus-newsgroup-adaptive-score-file nil)
1180 (defvar gnus-current-score-file nil)
1181 (defvar gnus-current-move-group nil)
1182 (defvar gnus-current-copy-group nil)
1183 (defvar gnus-current-crosspost-group nil)
1184 (defvar gnus-newsgroup-display nil)
1186 (defvar gnus-newsgroup-dependencies nil)
1187 (defvar gnus-newsgroup-adaptive nil)
1188 (defvar gnus-summary-display-article-function nil)
1189 (defvar gnus-summary-highlight-line-function nil
1190 "Function called after highlighting a summary line.")
1192 (defvar gnus-summary-line-format-alist
1193 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1194 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1195 (?s gnus-tmp-subject-or-nil ?s)
1196 (?n gnus-tmp-name ?s)
1197 (?A (std11-address-string
1198 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1199 (?a (or (std11-full-name-string
1200 (car (mime-entity-read-field gnus-tmp-header 'From)))
1202 (?F gnus-tmp-from ?s)
1203 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1204 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1205 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1206 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1207 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1208 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1209 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1210 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1211 (?L gnus-tmp-lines ?s)
1212 (?O gnus-tmp-downloaded ?c)
1213 (?I gnus-tmp-indentation ?s)
1214 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1215 (?R gnus-tmp-replied ?c)
1216 (?\[ gnus-tmp-opening-bracket ?c)
1217 (?\] gnus-tmp-closing-bracket ?c)
1218 (?\> (make-string gnus-tmp-level ? ) ?s)
1219 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1220 (?i gnus-tmp-score ?d)
1221 (?z gnus-tmp-score-char ?c)
1222 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1223 (?U gnus-tmp-unread ?c)
1224 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1226 (?t (gnus-summary-number-of-articles-in-thread
1227 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1229 (?e (gnus-summary-number-of-articles-in-thread
1230 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1232 (?u gnus-tmp-user-defined ?s)
1233 (?P (gnus-pick-line-number) ?d)
1234 (?B gnus-tmp-thread-tree-header-string ?s)
1235 (user-date (gnus-user-date
1236 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1237 "An alist of format specifications that can appear in summary lines.
1238 These are paired with what variables they correspond with, along with
1239 the type of the variable (string, integer, character, etc).")
1241 (defvar gnus-summary-dummy-line-format-alist
1242 `((?S gnus-tmp-subject ?s)
1243 (?N gnus-tmp-number ?d)
1244 (?u gnus-tmp-user-defined ?s)))
1246 (defvar gnus-summary-mode-line-format-alist
1247 `((?G gnus-tmp-group-name ?s)
1248 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1249 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1250 (?A gnus-tmp-article-number ?d)
1251 (?Z gnus-tmp-unread-and-unselected ?s)
1252 (?V gnus-version ?s)
1253 (?U gnus-tmp-unread-and-unticked ?d)
1254 (?S gnus-tmp-subject ?s)
1255 (?e gnus-tmp-unselected ?d)
1256 (?u gnus-tmp-user-defined ?s)
1257 (?d (length gnus-newsgroup-dormant) ?d)
1258 (?t (length gnus-newsgroup-marked) ?d)
1259 (?h (length gnus-newsgroup-spam-marked) ?d)
1260 (?r (length gnus-newsgroup-reads) ?d)
1261 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1262 (?E gnus-newsgroup-expunged-tally ?d)
1263 (?s (gnus-current-score-file-nondirectory) ?s)))
1265 (defvar gnus-last-search-regexp nil
1266 "Default regexp for article search command.")
1268 (defvar gnus-summary-search-article-matched-data nil
1269 "Last matched data of article search command. It is the local variable
1270 in `gnus-article-buffer' which consists of the list of start position,
1271 end position and text.")
1273 (defvar gnus-last-shell-command nil
1274 "Default shell command on article.")
1276 (defvar gnus-newsgroup-agentized nil
1277 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1278 (defvar gnus-newsgroup-begin nil)
1279 (defvar gnus-newsgroup-end nil)
1280 (defvar gnus-newsgroup-last-rmail nil)
1281 (defvar gnus-newsgroup-last-mail nil)
1282 (defvar gnus-newsgroup-last-folder nil)
1283 (defvar gnus-newsgroup-last-file nil)
1284 (defvar gnus-newsgroup-auto-expire nil)
1285 (defvar gnus-newsgroup-active nil)
1287 (defvar gnus-newsgroup-data nil)
1288 (defvar gnus-newsgroup-data-reverse nil)
1289 (defvar gnus-newsgroup-limit nil)
1290 (defvar gnus-newsgroup-limits nil)
1291 (defvar gnus-summary-use-undownloaded-faces nil)
1293 (defvar gnus-newsgroup-unreads nil
1294 "Sorted list of unread articles in the current newsgroup.")
1296 (defvar gnus-newsgroup-unselected nil
1297 "Sorted list of unselected unread articles in the current newsgroup.")
1299 (defvar gnus-newsgroup-reads nil
1300 "Alist of read articles and article marks in the current newsgroup.")
1302 (defvar gnus-newsgroup-expunged-tally nil)
1304 (defvar gnus-newsgroup-marked nil
1305 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1307 (defvar gnus-newsgroup-spam-marked nil
1308 "List of ranges of articles that have been marked as spam.")
1310 (defvar gnus-newsgroup-killed nil
1311 "List of ranges of articles that have been through the scoring process.")
1313 (defvar gnus-newsgroup-cached nil
1314 "Sorted list of articles that come from the article cache.")
1316 (defvar gnus-newsgroup-saved nil
1317 "List of articles that have been saved.")
1319 (defvar gnus-newsgroup-kill-headers nil)
1321 (defvar gnus-newsgroup-replied nil
1322 "List of articles that have been replied to in the current newsgroup.")
1324 (defvar gnus-newsgroup-forwarded nil
1325 "List of articles that have been forwarded in the current newsgroup.")
1327 (defvar gnus-newsgroup-recent nil
1328 "List of articles that have are recent in the current newsgroup.")
1330 (defvar gnus-newsgroup-expirable nil
1331 "Sorted list of articles in the current newsgroup that can be expired.")
1333 (defvar gnus-newsgroup-processable nil
1334 "List of articles in the current newsgroup that can be processed.")
1336 (defvar gnus-newsgroup-downloadable nil
1337 "Sorted list of articles in the current newsgroup that can be processed.")
1339 (defvar gnus-newsgroup-unfetched nil
1340 "Sorted list of articles in the current newsgroup whose headers have
1341 not been fetched into the agent.
1343 This list will always be a subset of gnus-newsgroup-undownloaded.")
1345 (defvar gnus-newsgroup-undownloaded nil
1346 "List of articles in the current newsgroup that haven't been downloaded.")
1348 (defvar gnus-newsgroup-unsendable nil
1349 "List of articles in the current newsgroup that won't be sent.")
1351 (defvar gnus-newsgroup-bookmarks nil
1352 "List of articles in the current newsgroup that have bookmarks.")
1354 (defvar gnus-newsgroup-dormant nil
1355 "Sorted list of dormant articles in the current newsgroup.")
1357 (defvar gnus-newsgroup-unseen nil
1358 "List of unseen articles in the current newsgroup.")
1360 (defvar gnus-newsgroup-seen nil
1361 "Range of seen articles in the current newsgroup.")
1363 (defvar gnus-newsgroup-articles nil
1364 "List of articles in the current newsgroup.")
1366 (defvar gnus-newsgroup-scored nil
1367 "List of scored articles in the current newsgroup.")
1369 (defvar gnus-newsgroup-incorporated nil
1370 "List of incorporated articles in the current newsgroup.")
1372 (defvar gnus-newsgroup-headers nil
1373 "List of article headers in the current newsgroup.")
1375 (defvar gnus-newsgroup-threads nil)
1377 (defvar gnus-newsgroup-prepared nil
1378 "Whether the current group has been prepared properly.")
1380 (defvar gnus-newsgroup-ancient nil
1381 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1383 (defvar gnus-newsgroup-sparse nil)
1385 (defvar gnus-current-article nil)
1386 (defvar gnus-article-current nil)
1387 (defvar gnus-current-headers nil)
1388 (defvar gnus-have-all-headers nil)
1389 (defvar gnus-last-article nil)
1390 (defvar gnus-newsgroup-history nil)
1391 (defvar gnus-newsgroup-charset nil)
1392 (defvar gnus-newsgroup-ephemeral-charset nil)
1393 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1395 (defvar gnus-article-before-search nil)
1397 (defvar gnus-summary-local-variables
1398 '(gnus-newsgroup-name
1399 gnus-newsgroup-begin gnus-newsgroup-end
1400 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1401 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1402 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1403 gnus-newsgroup-unselected gnus-newsgroup-marked
1404 gnus-newsgroup-spam-marked
1405 gnus-newsgroup-reads gnus-newsgroup-saved
1406 gnus-newsgroup-replied gnus-newsgroup-forwarded
1407 gnus-newsgroup-recent
1408 gnus-newsgroup-expirable
1409 gnus-newsgroup-processable gnus-newsgroup-killed
1410 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1411 gnus-newsgroup-unfetched
1412 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1413 gnus-newsgroup-seen gnus-newsgroup-articles
1414 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1415 gnus-newsgroup-headers gnus-newsgroup-threads
1416 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1417 gnus-current-article gnus-current-headers gnus-have-all-headers
1418 gnus-last-article gnus-article-internal-prepare-hook
1419 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1420 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1421 gnus-thread-expunge-below
1422 gnus-score-alist gnus-current-score-file
1423 (gnus-summary-expunge-below . global)
1424 (gnus-summary-mark-below . global)
1425 (gnus-orphan-score . global)
1426 gnus-newsgroup-active gnus-scores-exclude-files
1427 gnus-newsgroup-history gnus-newsgroup-ancient
1428 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1429 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1430 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1431 (gnus-newsgroup-expunged-tally . 0)
1432 gnus-cache-removable-articles gnus-newsgroup-cached
1433 gnus-newsgroup-data gnus-newsgroup-data-reverse
1434 gnus-newsgroup-limit gnus-newsgroup-limits
1435 gnus-newsgroup-charset gnus-newsgroup-display
1436 gnus-summary-use-undownloaded-faces
1437 gnus-newsgroup-incorporated)
1438 "Variables that are buffer-local to the summary buffers.")
1440 (defvar gnus-newsgroup-variables nil
1441 "A list of variables that have separate values in different newsgroups.
1442 A list of newsgroup (summary buffer) local variables, or cons of
1443 variables and their default values (when the default values are not
1444 nil), that should be made global while the summary buffer is active.
1445 These variables can be used to set variables in the group parameters
1446 while still allowing them to affect operations done in other
1447 buffers. For example:
1449 \(setq gnus-newsgroup-variables
1450 '(message-use-followup-to
1451 (gnus-visible-headers .
1452 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1455 ;; Byte-compiler warning.
1457 ;; Bind features so that require will believe that gnus-sum has
1458 ;; already been loaded (avoids infinite recursion)
1459 (let ((features (cons 'gnus-sum features)))
1460 ;; Several of the declarations in gnus-sum are needed to load the
1461 ;; following files. Right now, these definitions have been
1462 ;; compiled but not defined (evaluated). We could either do a
1463 ;; eval-and-compile about all of the declarations or evaluate the
1465 (if (boundp 'gnus-newsgroup-variables)
1467 (load "gnus-sum.el" t t t))
1469 (require 'gnus-agent)
1470 (require 'gnus-art)))
1472 ;; Subject simplification.
1474 (defun gnus-simplify-whitespace (str)
1475 "Remove excessive whitespace from STR."
1477 (while (string-match "[ \t][ \t]+" str)
1478 (setq str (concat (substring str 0 (match-beginning 0))
1480 (substring str (match-end 0)))))
1482 (when (string-match "^[ \t]+" str)
1483 (setq str (substring str (match-end 0))))
1485 (when (string-match "[ \t]+$" str)
1486 (setq str (substring str 0 (match-beginning 0))))
1489 (defun gnus-simplify-all-whitespace (str)
1490 "Remove all whitespace from STR."
1491 (while (string-match "[ \t\n]+" str)
1492 (setq str (replace-match "" nil nil str)))
1495 (defsubst gnus-simplify-subject-re (subject)
1496 "Remove \"Re:\" from subject lines."
1497 (if (string-match message-subject-re-regexp subject)
1498 (substring subject (match-end 0))
1501 (defun gnus-simplify-subject (subject &optional re-only)
1502 "Remove `Re:' and words in parentheses.
1503 If RE-ONLY is non-nil, strip leading `Re:'s only."
1504 (let ((case-fold-search t)) ;Ignore case.
1505 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1506 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1507 (setq subject (substring subject (match-end 0))))
1508 ;; Remove uninteresting prefixes.
1509 (when (and (not re-only)
1510 gnus-simplify-ignored-prefixes
1511 (string-match gnus-simplify-ignored-prefixes subject))
1512 (setq subject (substring subject (match-end 0))))
1513 ;; Remove words in parentheses from end.
1515 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1516 (setq subject (substring subject 0 (match-beginning 0)))))
1517 ;; Return subject string.
1520 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1522 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1523 (goto-char (point-min))
1524 (while (re-search-forward regexp nil t)
1525 (replace-match (or newtext ""))))
1527 (defun gnus-simplify-buffer-fuzzy ()
1528 "Simplify string in the buffer fuzzily.
1529 The string in the accessible portion of the current buffer is simplified.
1530 It is assumed to be a single-line subject.
1531 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1532 matter is removed. Additional things can be deleted by setting
1533 `gnus-simplify-subject-fuzzy-regexp'."
1534 (let ((case-fold-search t)
1536 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1538 (while (not (eq modified-tick (buffer-modified-tick)))
1539 (setq modified-tick (buffer-modified-tick))
1541 ((listp gnus-simplify-subject-fuzzy-regexp)
1542 (mapcar 'gnus-simplify-buffer-fuzzy-step
1543 gnus-simplify-subject-fuzzy-regexp))
1544 (gnus-simplify-subject-fuzzy-regexp
1545 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1546 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1547 (gnus-simplify-buffer-fuzzy-step
1548 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1549 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1551 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1552 (gnus-simplify-buffer-fuzzy-step " +" " ")
1553 (gnus-simplify-buffer-fuzzy-step " $")
1554 (gnus-simplify-buffer-fuzzy-step "^ +")))
1556 (defun gnus-simplify-subject-fuzzy (subject)
1557 "Simplify a subject string fuzzily.
1558 See `gnus-simplify-buffer-fuzzy' for details."
1560 (gnus-set-work-buffer)
1561 (let ((case-fold-search t))
1562 ;; Remove uninteresting prefixes.
1563 (when (and gnus-simplify-ignored-prefixes
1564 (string-match gnus-simplify-ignored-prefixes subject))
1565 (setq subject (substring subject (match-end 0))))
1567 (inline (gnus-simplify-buffer-fuzzy))
1570 (defsubst gnus-simplify-subject-fully (subject)
1571 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1573 (gnus-simplify-subject-functions
1574 (gnus-map-function gnus-simplify-subject-functions subject))
1575 ((null gnus-summary-gather-subject-limit)
1576 (gnus-simplify-subject-re subject))
1577 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1578 (gnus-simplify-subject-fuzzy subject))
1579 ((numberp gnus-summary-gather-subject-limit)
1580 (gnus-limit-string (gnus-simplify-subject-re subject)
1581 gnus-summary-gather-subject-limit))
1585 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1586 "Check whether two subjects are equal.
1587 If optional argument SIMPLE-FIRST is t, first argument is already
1590 ((null simple-first)
1591 (equal (gnus-simplify-subject-fully s1)
1592 (gnus-simplify-subject-fully s2)))
1595 (gnus-simplify-subject-fully s2)))))
1597 (defun gnus-summary-bubble-group ()
1598 "Increase the score of the current group.
1599 This is a handy function to add to `gnus-summary-exit-hook' to
1600 increase the score of each group you read."
1601 (gnus-group-add-score gnus-newsgroup-name))
1605 ;;; Gnus summary mode
1608 (put 'gnus-summary-mode 'mode-class 'special)
1610 (defvar gnus-article-commands-menu)
1612 ;; Non-orthogonal keys
1614 (gnus-define-keys gnus-summary-mode-map
1615 " " gnus-summary-next-page
1616 "\177" gnus-summary-prev-page
1617 [delete] gnus-summary-prev-page
1618 [backspace] gnus-summary-prev-page
1619 "\r" gnus-summary-scroll-up
1620 "\M-\r" gnus-summary-scroll-down
1621 "n" gnus-summary-next-unread-article
1622 "p" gnus-summary-prev-unread-article
1623 "N" gnus-summary-next-article
1624 "P" gnus-summary-prev-article
1625 "\M-\C-n" gnus-summary-next-same-subject
1626 "\M-\C-p" gnus-summary-prev-same-subject
1627 "\M-n" gnus-summary-next-unread-subject
1628 "\M-p" gnus-summary-prev-unread-subject
1629 "." gnus-summary-first-unread-article
1630 "," gnus-summary-best-unread-article
1631 "\M-s" gnus-summary-search-article-forward
1632 "\M-r" gnus-summary-search-article-backward
1633 "<" gnus-summary-beginning-of-article
1634 ">" gnus-summary-end-of-article
1635 "j" gnus-summary-goto-article
1636 "^" gnus-summary-refer-parent-article
1637 "\M-^" gnus-summary-refer-article
1638 "u" gnus-summary-tick-article-forward
1639 "!" gnus-summary-tick-article-forward
1640 "U" gnus-summary-tick-article-backward
1641 "d" gnus-summary-mark-as-read-forward
1642 "D" gnus-summary-mark-as-read-backward
1643 "E" gnus-summary-mark-as-expirable
1644 "\M-u" gnus-summary-clear-mark-forward
1645 "\M-U" gnus-summary-clear-mark-backward
1646 "k" gnus-summary-kill-same-subject-and-select
1647 "\C-k" gnus-summary-kill-same-subject
1648 "\M-\C-k" gnus-summary-kill-thread
1649 "\M-\C-l" gnus-summary-lower-thread
1650 "e" gnus-summary-edit-article
1651 "#" gnus-summary-mark-as-processable
1652 "\M-#" gnus-summary-unmark-as-processable
1653 "\M-\C-t" gnus-summary-toggle-threads
1654 "\M-\C-s" gnus-summary-show-thread
1655 "\M-\C-h" gnus-summary-hide-thread
1656 "\M-\C-f" gnus-summary-next-thread
1657 "\M-\C-b" gnus-summary-prev-thread
1658 [(meta down)] gnus-summary-next-thread
1659 [(meta up)] gnus-summary-prev-thread
1660 "\M-\C-u" gnus-summary-up-thread
1661 "\M-\C-d" gnus-summary-down-thread
1662 "&" gnus-summary-execute-command
1663 "c" gnus-summary-catchup-and-exit
1664 "\C-w" gnus-summary-mark-region-as-read
1665 "\C-t" gnus-summary-toggle-truncation
1666 "?" gnus-summary-mark-as-dormant
1667 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1668 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1669 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1670 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1671 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1672 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1673 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1674 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1675 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1676 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1677 "=" gnus-summary-expand-window
1678 "\C-x\C-s" gnus-summary-reselect-current-group
1679 "\M-g" gnus-summary-rescan-group
1680 "w" gnus-summary-stop-page-breaking
1681 "\C-c\C-r" gnus-summary-caesar-message
1682 "\M-t" gnus-summary-toggle-mime
1683 "f" gnus-summary-followup
1684 "F" gnus-summary-followup-with-original
1685 "C" gnus-summary-cancel-article
1686 "r" gnus-summary-reply
1687 "R" gnus-summary-reply-with-original
1688 "\C-c\C-f" gnus-summary-mail-forward
1689 "o" gnus-summary-save-article
1690 "\C-o" gnus-summary-save-article-mail
1691 "|" gnus-summary-pipe-output
1692 "\M-k" gnus-summary-edit-local-kill
1693 "\M-K" gnus-summary-edit-global-kill
1695 "\C-c\C-d" gnus-summary-describe-group
1696 "q" gnus-summary-exit
1697 "Q" gnus-summary-exit-no-update
1698 "\C-c\C-i" gnus-info-find-node
1699 gnus-mouse-2 gnus-mouse-pick-article
1700 "m" gnus-summary-mail-other-window
1701 "a" gnus-summary-post-news
1702 "i" gnus-summary-news-other-window
1703 "x" gnus-summary-limit-to-unread
1704 "s" gnus-summary-isearch-article
1705 "t" gnus-summary-toggle-header
1706 "g" gnus-summary-show-article
1707 "l" gnus-summary-goto-last-article
1708 "v" gnus-summary-preview-mime-message
1709 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1710 "\C-d" gnus-summary-enter-digest-group
1711 "\M-\C-d" gnus-summary-read-document
1712 "\M-\C-e" gnus-summary-edit-parameters
1713 "\M-\C-a" gnus-summary-customize-parameters
1715 "\C-c\C-n" gnus-namazu-search
1716 "*" gnus-cache-enter-article
1717 "\M-*" gnus-cache-remove-article
1718 "\M-&" gnus-summary-universal-argument
1719 "\C-l" gnus-recenter
1720 "I" gnus-summary-increase-score
1721 "L" gnus-summary-lower-score
1722 "\M-i" gnus-symbolic-argument
1723 "h" gnus-summary-select-article-buffer
1725 "V" gnus-summary-score-map
1726 "X" gnus-uu-extract-map
1727 "S" gnus-summary-send-map)
1729 ;; Sort of orthogonal keymap
1730 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1731 "t" gnus-summary-tick-article-forward
1732 "!" gnus-summary-tick-article-forward
1733 "d" gnus-summary-mark-as-read-forward
1734 "r" gnus-summary-mark-as-read-forward
1735 "c" gnus-summary-clear-mark-forward
1736 " " gnus-summary-clear-mark-forward
1737 "e" gnus-summary-mark-as-expirable
1738 "x" gnus-summary-mark-as-expirable
1739 "?" gnus-summary-mark-as-dormant
1740 "b" gnus-summary-set-bookmark
1741 "B" gnus-summary-remove-bookmark
1742 "#" gnus-summary-mark-as-processable
1743 "\M-#" gnus-summary-unmark-as-processable
1744 "S" gnus-summary-limit-include-expunged
1745 "C" gnus-summary-catchup
1746 "H" gnus-summary-catchup-to-here
1747 "h" gnus-summary-catchup-from-here
1748 "\C-c" gnus-summary-catchup-all
1749 "k" gnus-summary-kill-same-subject-and-select
1750 "K" gnus-summary-kill-same-subject
1751 "P" gnus-uu-mark-map)
1753 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1754 "c" gnus-summary-clear-above
1755 "u" gnus-summary-tick-above
1756 "m" gnus-summary-mark-above
1757 "k" gnus-summary-kill-below)
1759 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1760 "/" gnus-summary-limit-to-subject
1761 "n" gnus-summary-limit-to-articles
1762 "w" gnus-summary-pop-limit
1763 "s" gnus-summary-limit-to-subject
1764 "a" gnus-summary-limit-to-author
1765 "u" gnus-summary-limit-to-unread
1766 "m" gnus-summary-limit-to-marks
1767 "M" gnus-summary-limit-exclude-marks
1768 "v" gnus-summary-limit-to-score
1769 "*" gnus-summary-limit-include-cached
1770 "D" gnus-summary-limit-include-dormant
1771 "T" gnus-summary-limit-include-thread
1772 "d" gnus-summary-limit-exclude-dormant
1773 "t" gnus-summary-limit-to-age
1774 "." gnus-summary-limit-to-unseen
1775 "x" gnus-summary-limit-to-extra
1776 "p" gnus-summary-limit-to-display-predicate
1777 "E" gnus-summary-limit-include-expunged
1778 "c" gnus-summary-limit-exclude-childless-dormant
1779 "C" gnus-summary-limit-mark-excluded-as-read
1780 "o" gnus-summary-insert-old-articles
1781 "N" gnus-summary-insert-new-articles
1782 "r" gnus-summary-limit-to-replied)
1784 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1785 "n" gnus-summary-next-unread-article
1786 "p" gnus-summary-prev-unread-article
1787 "N" gnus-summary-next-article
1788 "P" gnus-summary-prev-article
1789 "\C-n" gnus-summary-next-same-subject
1790 "\C-p" gnus-summary-prev-same-subject
1791 "\M-n" gnus-summary-next-unread-subject
1792 "\M-p" gnus-summary-prev-unread-subject
1793 "f" gnus-summary-first-unread-article
1794 "b" gnus-summary-best-unread-article
1795 "j" gnus-summary-goto-article
1796 "g" gnus-summary-goto-subject
1797 "l" gnus-summary-goto-last-article
1798 "o" gnus-summary-pop-article)
1800 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1801 "k" gnus-summary-kill-thread
1802 "l" gnus-summary-lower-thread
1803 "i" gnus-summary-raise-thread
1804 "T" gnus-summary-toggle-threads
1805 "t" gnus-summary-rethread-current
1806 "^" gnus-summary-reparent-thread
1807 "s" gnus-summary-show-thread
1808 "S" gnus-summary-show-all-threads
1809 "h" gnus-summary-hide-thread
1810 "H" gnus-summary-hide-all-threads
1811 "n" gnus-summary-next-thread
1812 "p" gnus-summary-prev-thread
1813 "u" gnus-summary-up-thread
1814 "o" gnus-summary-top-thread
1815 "d" gnus-summary-down-thread
1816 "#" gnus-uu-mark-thread
1817 "\M-#" gnus-uu-unmark-thread)
1819 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1820 "g" gnus-summary-prepare
1821 "c" gnus-summary-insert-cached-articles
1822 "d" gnus-summary-insert-dormant-articles)
1824 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1825 "c" gnus-summary-catchup-and-exit
1826 "C" gnus-summary-catchup-all-and-exit
1827 "E" gnus-summary-exit-no-update
1828 "J" gnus-summary-jump-to-other-group
1829 "Q" gnus-summary-exit
1830 "Z" gnus-summary-exit
1831 "n" gnus-summary-catchup-and-goto-next-group
1832 "R" gnus-summary-reselect-current-group
1833 "G" gnus-summary-rescan-group
1834 "N" gnus-summary-next-group
1835 "s" gnus-summary-save-newsrc
1836 "P" gnus-summary-prev-group)
1838 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1839 " " gnus-summary-next-page
1840 "n" gnus-summary-next-page
1841 "\177" gnus-summary-prev-page
1842 [delete] gnus-summary-prev-page
1843 "p" gnus-summary-prev-page
1844 "\r" gnus-summary-scroll-up
1845 "\M-\r" gnus-summary-scroll-down
1846 "<" gnus-summary-beginning-of-article
1847 ">" gnus-summary-end-of-article
1848 "b" gnus-summary-beginning-of-article
1849 "e" gnus-summary-end-of-article
1850 "^" gnus-summary-refer-parent-article
1851 "r" gnus-summary-refer-parent-article
1852 "D" gnus-summary-enter-digest-group
1853 "R" gnus-summary-refer-references
1854 "T" gnus-summary-refer-thread
1855 "g" gnus-summary-show-article
1856 "s" gnus-summary-isearch-article
1857 "P" gnus-summary-print-article
1858 "M" gnus-mailing-list-insinuate
1859 "t" gnus-article-babel)
1861 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1862 "b" gnus-article-add-buttons
1863 "B" gnus-article-add-buttons-to-head
1864 "o" gnus-article-treat-overstrike
1865 "e" gnus-article-emphasize
1866 "w" gnus-article-fill-cited-article
1867 "Q" gnus-article-fill-long-lines
1868 "C" gnus-article-capitalize-sentences
1869 "c" gnus-article-remove-cr
1870 "Z" gnus-article-decode-HZ
1871 "A" gnus-article-treat-ansi-sequences
1872 "h" gnus-article-wash-html
1873 "u" gnus-article-unsplit-urls
1874 "f" gnus-article-display-x-face
1875 "l" gnus-summary-stop-page-breaking
1876 "r" gnus-summary-caesar-message
1877 "m" gnus-summary-morse-message
1878 "t" gnus-summary-toggle-header
1879 "g" gnus-treat-smiley
1880 "v" gnus-summary-verbose-headers
1881 "m" gnus-summary-toggle-mime
1882 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1883 "p" gnus-article-verify-x-pgp-sig
1884 "d" gnus-article-treat-dumbquotes)
1886 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1887 ;; mnemonic: deuglif*Y*
1888 "u" gnus-article-outlook-unwrap-lines
1889 "a" gnus-article-outlook-repair-attribution
1890 "c" gnus-article-outlook-rearrange-citation
1891 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1893 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1894 "a" gnus-article-hide
1895 "h" gnus-article-hide-headers
1896 "b" gnus-article-hide-boring-headers
1897 "s" gnus-article-hide-signature
1898 "c" gnus-article-hide-citation
1899 "C" gnus-article-hide-citation-in-followups
1900 "l" gnus-article-hide-list-identifiers
1901 "B" gnus-article-strip-banner
1902 "P" gnus-article-hide-pem
1903 "\C-c" gnus-article-hide-citation-maybe)
1905 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1906 "a" gnus-article-highlight
1907 "h" gnus-article-highlight-headers
1908 "c" gnus-article-highlight-citation
1909 "s" gnus-article-highlight-signature)
1911 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1912 "f" gnus-article-treat-fold-headers
1913 "u" gnus-article-treat-unfold-headers
1914 "n" gnus-article-treat-fold-newsgroups)
1916 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1917 "x" gnus-article-display-x-face
1918 "d" gnus-article-display-face
1919 "s" gnus-treat-smiley
1920 "D" gnus-article-remove-images
1921 "f" gnus-treat-from-picon
1922 "m" gnus-treat-mail-picon
1923 "n" gnus-treat-newsgroups-picon)
1925 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1926 "z" gnus-article-date-ut
1927 "u" gnus-article-date-ut
1928 "l" gnus-article-date-local
1929 "p" gnus-article-date-english
1930 "e" gnus-article-date-lapsed
1931 "o" gnus-article-date-original
1932 "i" gnus-article-date-iso8601
1933 "s" gnus-article-date-user)
1935 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1936 "t" gnus-article-remove-trailing-blank-lines
1937 "l" gnus-article-strip-leading-blank-lines
1938 "m" gnus-article-strip-multiple-blank-lines
1939 "a" gnus-article-strip-blank-lines
1940 "A" gnus-article-strip-all-blank-lines
1941 "s" gnus-article-strip-leading-space
1942 "e" gnus-article-strip-trailing-space
1943 "w" gnus-article-remove-leading-whitespace)
1945 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1947 "f" gnus-summary-fetch-faq
1948 "d" gnus-summary-describe-group
1949 "h" gnus-summary-describe-briefly
1950 "i" gnus-info-find-node
1951 "c" gnus-group-fetch-charter
1952 "C" gnus-group-fetch-control)
1954 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1955 "e" gnus-summary-expire-articles
1956 "\M-\C-e" gnus-summary-expire-articles-now
1957 "\177" gnus-summary-delete-article
1958 [delete] gnus-summary-delete-article
1959 [backspace] gnus-summary-delete-article
1960 "m" gnus-summary-move-article
1961 "r" gnus-summary-respool-article
1962 "w" gnus-summary-edit-article
1963 "c" gnus-summary-copy-article
1964 "B" gnus-summary-crosspost-article
1965 "q" gnus-summary-respool-query
1966 "t" gnus-summary-respool-trace
1967 "i" gnus-summary-import-article
1968 "I" gnus-summary-create-article
1969 "p" gnus-summary-article-posted-p)
1971 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1972 "o" gnus-summary-save-article
1973 "m" gnus-summary-save-article-mail
1974 "F" gnus-summary-write-article-file
1975 "r" gnus-summary-save-article-rmail
1976 "f" gnus-summary-save-article-file
1977 "b" gnus-summary-save-article-body-file
1978 "h" gnus-summary-save-article-folder
1979 "v" gnus-summary-save-article-vm
1980 "p" gnus-summary-pipe-output
1981 "P" gnus-summary-muttprint
1982 "s" gnus-soup-add-article)
1984 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1985 "b" gnus-summary-display-buttonized
1986 "m" gnus-summary-repair-multipart
1987 "v" gnus-article-view-part
1988 "o" gnus-article-save-part
1989 "c" gnus-article-copy-part
1990 "C" gnus-article-view-part-as-charset
1991 "e" gnus-article-view-part-externally
1992 "E" gnus-article-encrypt-body
1993 "i" gnus-article-inline-part
1994 "|" gnus-article-pipe-part)
1996 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1997 "p" gnus-summary-mark-as-processable
1998 "u" gnus-summary-unmark-as-processable
1999 "U" gnus-summary-unmark-all-processable
2000 "v" gnus-uu-mark-over
2001 "s" gnus-uu-mark-series
2002 "r" gnus-uu-mark-region
2003 "g" gnus-uu-unmark-region
2004 "R" gnus-uu-mark-by-regexp
2005 "G" gnus-uu-unmark-by-regexp
2006 "t" gnus-uu-mark-thread
2007 "T" gnus-uu-unmark-thread
2008 "a" gnus-uu-mark-all
2009 "b" gnus-uu-mark-buffer
2010 "S" gnus-uu-mark-sparse
2011 "k" gnus-summary-kill-process-mark
2012 "y" gnus-summary-yank-process-mark
2013 "w" gnus-summary-save-process-mark
2014 "i" gnus-uu-invert-processable)
2016 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2017 ;;"x" gnus-uu-extract-any
2018 "m" gnus-summary-save-parts
2019 "u" gnus-uu-decode-uu
2020 "U" gnus-uu-decode-uu-and-save
2021 "s" gnus-uu-decode-unshar
2022 "S" gnus-uu-decode-unshar-and-save
2023 "o" gnus-uu-decode-save
2024 "O" gnus-uu-decode-save
2025 "b" gnus-uu-decode-binhex
2026 "B" gnus-uu-decode-binhex
2027 "p" gnus-uu-decode-postscript
2028 "P" gnus-uu-decode-postscript-and-save)
2031 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2032 "u" gnus-uu-decode-uu-view
2033 "U" gnus-uu-decode-uu-and-save-view
2034 "s" gnus-uu-decode-unshar-view
2035 "S" gnus-uu-decode-unshar-and-save-view
2036 "o" gnus-uu-decode-save-view
2037 "O" gnus-uu-decode-save-view
2038 "b" gnus-uu-decode-binhex-view
2039 "B" gnus-uu-decode-binhex-view
2040 "p" gnus-uu-decode-postscript-view
2041 "P" gnus-uu-decode-postscript-and-save-view)
2043 (defvar gnus-article-post-menu nil)
2045 (defconst gnus-summary-menu-maxlen 20)
2047 (defun gnus-summary-menu-split (menu)
2048 ;; If we have lots of elements, divide them into groups of 20
2049 ;; and make a pane (or submenu) for each one.
2050 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2051 (let ((menu menu) sublists next
2054 ;; Pull off the next gnus-summary-menu-maxlen elements
2055 ;; and make them the next element of sublist.
2056 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2058 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2060 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2061 (aref (car (last menu)) 0)) menu)
2065 (nreverse sublists))
2066 ;; Few elements--put them all in one pane.
2069 (defun gnus-summary-make-menu-bar ()
2070 (gnus-turn-off-edit-menu 'summary)
2072 (unless (boundp 'gnus-summary-misc-menu)
2075 gnus-summary-kill-menu gnus-summary-mode-map ""
2080 ["Customize" gnus-score-customize t])
2081 (gnus-make-score-map 'increase)
2082 (gnus-make-score-map 'lower)
2084 ["Kill below" gnus-summary-kill-below t]
2085 ["Mark above" gnus-summary-mark-above t]
2086 ["Tick above" gnus-summary-tick-above t]
2087 ["Clear above" gnus-summary-clear-above t])
2088 ["Current score" gnus-summary-current-score t]
2089 ["Set score" gnus-summary-set-score t]
2090 ["Switch current score file..." gnus-score-change-score-file t]
2091 ["Set mark below..." gnus-score-set-mark-below t]
2092 ["Set expunge below..." gnus-score-set-expunge-below t]
2093 ["Edit current score file" gnus-score-edit-current-scores t]
2094 ["Edit score file" gnus-score-edit-file t]
2095 ["Trace score" gnus-score-find-trace t]
2096 ["Find words" gnus-score-find-favourite-words t]
2097 ["Rescore buffer" gnus-summary-rescore t]
2098 ["Increase score..." gnus-summary-increase-score t]
2099 ["Lower score..." gnus-summary-lower-score t]))))
2101 ;; Define both the Article menu in the summary buffer and the
2102 ;; equivalent Commands menu in the article buffer here for
2106 ["All" gnus-article-hide t]
2107 ["Headers" gnus-article-hide-headers t]
2108 ["Signature" gnus-article-hide-signature t]
2109 ["Citation" gnus-article-hide-citation t]
2110 ["List identifiers" gnus-article-hide-list-identifiers t]
2111 ["Banner" gnus-article-strip-banner t]
2112 ["Boring headers" gnus-article-hide-boring-headers t])
2114 ["All" gnus-article-highlight t]
2115 ["Headers" gnus-article-highlight-headers t]
2116 ["Signature" gnus-article-highlight-signature t]
2117 ["Citation" gnus-article-highlight-citation t])
2119 ["Local" gnus-article-date-local t]
2120 ["ISO8601" gnus-article-date-iso8601 t]
2121 ["UT" gnus-article-date-ut t]
2122 ["Original" gnus-article-date-original t]
2123 ["Lapsed" gnus-article-date-lapsed t]
2124 ["User-defined" gnus-article-date-user t])
2126 ["Remove images" gnus-article-remove-images t]
2127 ["Toggle smiley" gnus-treat-smiley t]
2128 ["Show X-Face" gnus-article-display-x-face t]
2129 ["Show picons in From" gnus-treat-from-picon t]
2130 ["Show picons in mail headers" gnus-treat-mail-picon t]
2131 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2132 ("View as different encoding"
2133 ,@(gnus-summary-menu-split
2136 ;; Since easymenu under Emacs doesn't allow
2137 ;; lambda forms for menu commands, we should
2138 ;; provide intern'ed function symbols.
2139 (let ((command (intern (format "\
2140 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2144 (let ((gnus-summary-show-article-charset-alist
2146 (gnus-summary-show-article 1))))
2147 `[,(symbol-name cs) ,command t]))
2148 (sort (if (fboundp 'coding-system-list)
2149 (coding-system-list)
2150 ;;(mapcar 'car mm-mime-mule-charset-alist)
2155 ["Leading" gnus-article-strip-leading-blank-lines t]
2156 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2157 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2158 ["All of the above" gnus-article-strip-blank-lines t]
2159 ["All" gnus-article-strip-all-blank-lines t]
2160 ["Leading space" gnus-article-strip-leading-space t]
2161 ["Trailing space" gnus-article-strip-trailing-space t]
2162 ["Leading space in headers"
2163 gnus-article-remove-leading-whitespace t])
2164 ["Overstrike" gnus-article-treat-overstrike t]
2165 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2166 ["Emphasis" gnus-article-emphasize t]
2167 ["Word wrap" gnus-article-fill-cited-article t]
2168 ["Fill long lines" gnus-article-fill-long-lines t]
2169 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2170 ["Remove CR" gnus-article-remove-cr t]
2171 ["Rot 13" gnus-summary-caesar-message
2172 ,@(if (featurep 'xemacs) '(t)
2173 '(:help "\"Caesar rotate\" article by 13"))]
2174 ["Morse decode" gnus-summary-morse-message t]
2175 ["Unix pipe..." gnus-summary-pipe-message t]
2176 ["Add buttons" gnus-article-add-buttons t]
2177 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2178 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2179 ["Toggle MIME" gnus-summary-toggle-mime t]
2180 ["Verbose header" gnus-summary-verbose-headers t]
2181 ["Toggle header" gnus-summary-toggle-header t]
2182 ["Unfold headers" gnus-article-treat-unfold-headers t]
2183 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2184 ["Html" gnus-article-wash-html t]
2185 ["Unsplit URLs" gnus-article-unsplit-urls t]
2186 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2187 ["Decode HZ" gnus-article-decode-HZ t]
2188 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2189 ("(Outlook) Deuglify"
2190 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2191 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2192 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2193 ["Full (Outlook) deuglify"
2194 gnus-article-outlook-deuglify-article t])
2197 ["Save in default format..." gnus-summary-save-article
2198 ,@(if (featurep 'xemacs) '(t)
2199 '(:help "Save article using default method"))]
2200 ["Save in file..." gnus-summary-save-article-file
2201 ,@(if (featurep 'xemacs) '(t)
2202 '(:help "Save article in file"))]
2203 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2204 ["Save in MH folder..." gnus-summary-save-article-folder t]
2205 ["Save in VM folder..." gnus-summary-save-article-vm t]
2206 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2207 ["Save body in file..." gnus-summary-save-article-body-file t]
2208 ["Pipe through a filter..." gnus-summary-pipe-output t]
2209 ["Add to SOUP packet" gnus-soup-add-article t]
2210 ["Print with Muttprint..." gnus-summary-muttprint t]
2211 ["Print" gnus-summary-print-article t])
2213 ["Respool article..." gnus-summary-respool-article t]
2214 ["Move article..." gnus-summary-move-article
2215 (gnus-check-backend-function
2216 'request-move-article gnus-newsgroup-name)]
2217 ["Copy article..." gnus-summary-copy-article t]
2218 ["Crosspost article..." gnus-summary-crosspost-article
2219 (gnus-check-backend-function
2220 'request-replace-article gnus-newsgroup-name)]
2221 ["Import file..." gnus-summary-import-article
2222 (gnus-check-backend-function
2223 'request-accept-article gnus-newsgroup-name)]
2224 ["Create article..." gnus-summary-create-article
2225 (gnus-check-backend-function
2226 'request-accept-article gnus-newsgroup-name)]
2227 ["Check if posted" gnus-summary-article-posted-p t]
2228 ["Edit article" gnus-summary-edit-article
2229 (not (gnus-group-read-only-p))]
2230 ["Delete article" gnus-summary-delete-article
2231 (gnus-check-backend-function
2232 'request-expire-articles gnus-newsgroup-name)]
2233 ["Query respool" gnus-summary-respool-query t]
2234 ["Trace respool" gnus-summary-respool-trace t]
2235 ["Delete expirable articles" gnus-summary-expire-articles-now
2236 (gnus-check-backend-function
2237 'request-expire-articles gnus-newsgroup-name)])
2239 ["Uudecode" gnus-uu-decode-uu
2240 ,@(if (featurep 'xemacs) '(t)
2241 '(:help "Decode uuencoded article(s)"))]
2242 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2243 ["Unshar" gnus-uu-decode-unshar t]
2244 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2245 ["Save" gnus-uu-decode-save t]
2246 ["Binhex" gnus-uu-decode-binhex t]
2247 ["Postscript" gnus-uu-decode-postscript t])
2249 ["Enter article" gnus-cache-enter-article t]
2250 ["Remove article" gnus-cache-remove-article t])
2251 ["Translate" gnus-article-babel t]
2252 ["Select article buffer" gnus-summary-select-article-buffer t]
2253 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2254 ["Isearch article..." gnus-summary-isearch-article t]
2255 ["Beginning of the article" gnus-summary-beginning-of-article t]
2256 ["End of the article" gnus-summary-end-of-article t]
2257 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2258 ["Fetch referenced articles" gnus-summary-refer-references t]
2259 ["Fetch current thread" gnus-summary-refer-thread t]
2260 ["Fetch article with id..." gnus-summary-refer-article t]
2261 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2262 ["Redisplay" gnus-summary-show-article t]
2263 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2265 gnus-summary-article-menu gnus-summary-mode-map ""
2266 (cons "Article" innards))
2268 (if (not (keymapp gnus-summary-article-menu))
2270 gnus-article-commands-menu gnus-article-mode-map ""
2271 (cons "Commands" innards))
2272 ;; in Emacs, don't share menu.
2273 (setq gnus-article-commands-menu
2274 (copy-keymap gnus-summary-article-menu))
2275 (define-key gnus-article-mode-map [menu-bar commands]
2276 (cons "Commands" gnus-article-commands-menu))))
2279 gnus-summary-thread-menu gnus-summary-mode-map ""
2281 ["Find all messages in thread" gnus-summary-refer-thread t]
2282 ["Toggle threading" gnus-summary-toggle-threads t]
2283 ["Hide threads" gnus-summary-hide-all-threads t]
2284 ["Show threads" gnus-summary-show-all-threads t]
2285 ["Hide thread" gnus-summary-hide-thread t]
2286 ["Show thread" gnus-summary-show-thread t]
2287 ["Go to next thread" gnus-summary-next-thread t]
2288 ["Go to previous thread" gnus-summary-prev-thread t]
2289 ["Go down thread" gnus-summary-down-thread t]
2290 ["Go up thread" gnus-summary-up-thread t]
2291 ["Top of thread" gnus-summary-top-thread t]
2292 ["Mark thread as read" gnus-summary-kill-thread t]
2293 ["Lower thread score" gnus-summary-lower-thread t]
2294 ["Raise thread score" gnus-summary-raise-thread t]
2295 ["Rethread current" gnus-summary-rethread-current t]))
2298 gnus-summary-post-menu gnus-summary-mode-map ""
2300 ["Send a message (mail or news)" gnus-summary-post-news
2301 ,@(if (featurep 'xemacs) '(t)
2302 '(:help "Post an article"))]
2303 ["Followup" gnus-summary-followup
2304 ,@(if (featurep 'xemacs) '(t)
2305 '(:help "Post followup to this article"))]
2306 ["Followup and yank" gnus-summary-followup-with-original
2307 ,@(if (featurep 'xemacs) '(t)
2308 '(:help "Post followup to this article, quoting its contents"))]
2309 ["Supersede article" gnus-summary-supersede-article t]
2310 ["Cancel article" gnus-summary-cancel-article
2311 ,@(if (featurep 'xemacs) '(t)
2312 '(:help "Cancel an article you posted"))]
2313 ["Reply" gnus-summary-reply t]
2314 ["Reply and yank" gnus-summary-reply-with-original t]
2315 ["Wide reply" gnus-summary-wide-reply t]
2316 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2317 ,@(if (featurep 'xemacs) '(t)
2318 '(:help "Mail a reply, quoting this article"))]
2319 ["Very wide reply" gnus-summary-very-wide-reply t]
2320 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2321 ,@(if (featurep 'xemacs) '(t)
2322 '(:help "Mail a very wide reply, quoting this article"))]
2323 ["Mail forward" gnus-summary-mail-forward t]
2324 ["Post forward" gnus-summary-post-forward t]
2325 ["Digest and mail" gnus-summary-digest-mail-forward t]
2326 ["Digest and post" gnus-summary-digest-post-forward t]
2327 ["Resend message" gnus-summary-resend-message t]
2328 ["Resend message edit" gnus-summary-resend-message-edit t]
2329 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2330 ["Send a mail" gnus-summary-mail-other-window t]
2331 ["Create a local message" gnus-summary-news-other-window t]
2332 ["Uuencode and post" gnus-uu-post-news
2333 ,@(if (featurep 'xemacs) '(t)
2334 '(:help "Post a uuencoded article"))]
2335 ["Followup via news" gnus-summary-followup-to-mail t]
2336 ["Followup via news and yank"
2337 gnus-summary-followup-to-mail-with-original t]
2339 ;;["Send" gnus-summary-send-draft t]
2340 ;;["Send bounced" gnus-resend-bounced-mail t])
2344 ((not (keymapp gnus-summary-post-menu))
2345 (setq gnus-article-post-menu gnus-summary-post-menu))
2346 ((not gnus-article-post-menu)
2347 ;; Don't share post menu.
2348 (setq gnus-article-post-menu
2349 (copy-keymap gnus-summary-post-menu))))
2350 (define-key gnus-article-mode-map [menu-bar post]
2351 (cons "Post" gnus-article-post-menu))
2354 gnus-summary-misc-menu gnus-summary-mode-map ""
2357 ["Mark as read" gnus-summary-mark-as-read-forward t]
2358 ["Mark same subject and select"
2359 gnus-summary-kill-same-subject-and-select t]
2360 ["Mark same subject" gnus-summary-kill-same-subject t]
2361 ["Catchup" gnus-summary-catchup
2362 ,@(if (featurep 'xemacs) '(t)
2363 '(:help "Mark unread articles in this group as read"))]
2364 ["Catchup all" gnus-summary-catchup-all t]
2365 ["Catchup to here" gnus-summary-catchup-to-here t]
2366 ["Catchup from here" gnus-summary-catchup-from-here t]
2367 ["Catchup region" gnus-summary-mark-region-as-read
2368 (gnus-mark-active-p)]
2369 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2371 ["Tick" gnus-summary-tick-article-forward t]
2372 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2373 ["Remove marks" gnus-summary-clear-mark-forward t]
2374 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2375 ["Set bookmark" gnus-summary-set-bookmark t]
2376 ["Remove bookmark" gnus-summary-remove-bookmark t])
2378 ["Marks..." gnus-summary-limit-to-marks t]
2379 ["Subject..." gnus-summary-limit-to-subject t]
2380 ["Author..." gnus-summary-limit-to-author t]
2381 ["Age..." gnus-summary-limit-to-age t]
2382 ["Extra..." gnus-summary-limit-to-extra t]
2383 ["Score..." gnus-summary-limit-to-score t]
2384 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2385 ["Unread" gnus-summary-limit-to-unread t]
2386 ["Unseen" gnus-summary-limit-to-unseen t]
2387 ["Replied" gnus-summary-limit-to-replied t]
2388 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2389 ["Next articles" gnus-summary-limit-to-articles t]
2390 ["Pop limit" gnus-summary-pop-limit t]
2391 ["Show dormant" gnus-summary-limit-include-dormant t]
2392 ["Hide childless dormant"
2393 gnus-summary-limit-exclude-childless-dormant t]
2394 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2395 ["Hide marked" gnus-summary-limit-exclude-marks t]
2396 ["Show expunged" gnus-summary-limit-include-expunged t])
2398 ["Set mark" gnus-summary-mark-as-processable t]
2399 ["Remove mark" gnus-summary-unmark-as-processable t]
2400 ["Remove all marks" gnus-summary-unmark-all-processable t]
2401 ["Mark above" gnus-uu-mark-over t]
2402 ["Mark series" gnus-uu-mark-series t]
2403 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2404 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2405 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2406 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2407 ["Mark all" gnus-uu-mark-all t]
2408 ["Mark buffer" gnus-uu-mark-buffer t]
2409 ["Mark sparse" gnus-uu-mark-sparse t]
2410 ["Mark thread" gnus-uu-mark-thread t]
2411 ["Unmark thread" gnus-uu-unmark-thread t]
2412 ("Process Mark Sets"
2413 ["Kill" gnus-summary-kill-process-mark t]
2414 ["Yank" gnus-summary-yank-process-mark
2415 gnus-newsgroup-process-stack]
2416 ["Save" gnus-summary-save-process-mark t]
2417 ["Run command on marked..." gnus-summary-universal-argument t]))
2419 ["Page forward" gnus-summary-next-page
2420 ,@(if (featurep 'xemacs) '(t)
2421 '(:help "Show next page of article"))]
2422 ["Page backward" gnus-summary-prev-page
2423 ,@(if (featurep 'xemacs) '(t)
2424 '(:help "Show previous page of article"))]
2425 ["Line forward" gnus-summary-scroll-up t])
2427 ["Next unread article" gnus-summary-next-unread-article t]
2428 ["Previous unread article" gnus-summary-prev-unread-article t]
2429 ["Next article" gnus-summary-next-article t]
2430 ["Previous article" gnus-summary-prev-article t]
2431 ["Next unread subject" gnus-summary-next-unread-subject t]
2432 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2433 ["Next article same subject" gnus-summary-next-same-subject t]
2434 ["Previous article same subject" gnus-summary-prev-same-subject t]
2435 ["First unread article" gnus-summary-first-unread-article t]
2436 ["Best unread article" gnus-summary-best-unread-article t]
2437 ["Go to subject number..." gnus-summary-goto-subject t]
2438 ["Go to article number..." gnus-summary-goto-article t]
2439 ["Go to the last article" gnus-summary-goto-last-article t]
2440 ["Pop article off history" gnus-summary-pop-article t])
2442 ["Sort by number" gnus-summary-sort-by-number t]
2443 ["Sort by author" gnus-summary-sort-by-author t]
2444 ["Sort by subject" gnus-summary-sort-by-subject t]
2445 ["Sort by date" gnus-summary-sort-by-date t]
2446 ["Sort by score" gnus-summary-sort-by-score t]
2447 ["Sort by lines" gnus-summary-sort-by-lines t]
2448 ["Sort by characters" gnus-summary-sort-by-chars t]
2449 ["Randomize" gnus-summary-sort-by-random t]
2450 ["Original sort" gnus-summary-sort-by-original t])
2452 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2453 ["Describe group" gnus-summary-describe-group t]
2454 ["Fetch charter" gnus-group-fetch-charter
2455 ,@(if (featurep 'xemacs) nil
2456 '(:help "Display the charter of the current group"))]
2457 ["Fetch control message" gnus-group-fetch-control
2458 ,@(if (featurep 'xemacs) nil
2459 '(:help "Display the archived control message for the current group"))]
2460 ["Read manual" gnus-info-find-node t])
2462 ["Pick and read" gnus-pick-mode t]
2463 ["Binary" gnus-binary-mode t])
2465 ["Regenerate" gnus-summary-prepare t]
2466 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2467 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2468 ["Toggle threading" gnus-summary-toggle-threads t])
2469 ["See old articles" gnus-summary-insert-old-articles t]
2470 ["See new articles" gnus-summary-insert-new-articles t]
2471 ["Filter articles..." gnus-summary-execute-command t]
2472 ["Run command on articles..." gnus-summary-universal-argument t]
2473 ["Search articles forward..." gnus-summary-search-article-forward t]
2474 ["Search articles backward..." gnus-summary-search-article-backward t]
2475 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2476 ["Expand window" gnus-summary-expand-window t]
2477 ["Expire expirable articles" gnus-summary-expire-articles
2478 (gnus-check-backend-function
2479 'request-expire-articles gnus-newsgroup-name)]
2480 ["Edit local kill file" gnus-summary-edit-local-kill t]
2481 ["Edit main kill file" gnus-summary-edit-global-kill t]
2482 ["Edit group parameters" gnus-summary-edit-parameters t]
2483 ["Customize group parameters" gnus-summary-customize-parameters t]
2484 ["Send a bug report" gnus-bug t]
2486 ["Catchup and exit" gnus-summary-catchup-and-exit
2487 ,@(if (featurep 'xemacs) '(t)
2488 '(:help "Mark unread articles in this group as read, then exit"))]
2489 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2490 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2491 ["Exit group" gnus-summary-exit
2492 ,@(if (featurep 'xemacs) '(t)
2493 '(:help "Exit current group, return to group selection mode"))]
2494 ["Exit group without updating" gnus-summary-exit-no-update t]
2495 ["Exit and goto next group" gnus-summary-next-group t]
2496 ["Exit and goto prev group" gnus-summary-prev-group t]
2497 ["Reselect group" gnus-summary-reselect-current-group t]
2498 ["Rescan group" gnus-summary-rescan-group t]
2499 ["Update dribble" gnus-summary-save-newsrc t])))
2501 (gnus-run-hooks 'gnus-summary-menu-hook)))
2503 (defvar gnus-summary-tool-bar-map nil)
2505 ;; Emacs 21 tool bar. Should be no-op otherwise.
2506 (defun gnus-summary-make-tool-bar ()
2507 (if (and (fboundp 'tool-bar-add-item-from-menu)
2508 (default-value 'tool-bar-mode)
2509 (not gnus-summary-tool-bar-map))
2510 (setq gnus-summary-tool-bar-map
2511 (let ((tool-bar-map (make-sparse-keymap))
2512 (load-path (mm-image-load-path)))
2513 (tool-bar-add-item-from-menu
2514 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2515 (tool-bar-add-item-from-menu
2516 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2517 (tool-bar-add-item-from-menu
2518 'gnus-summary-post-news "post" gnus-summary-mode-map)
2519 (tool-bar-add-item-from-menu
2520 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2521 (tool-bar-add-item-from-menu
2522 'gnus-summary-followup "followup" gnus-summary-mode-map)
2523 (tool-bar-add-item-from-menu
2524 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2525 (tool-bar-add-item-from-menu
2526 'gnus-summary-reply "reply" gnus-summary-mode-map)
2527 (tool-bar-add-item-from-menu
2528 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2529 (tool-bar-add-item-from-menu
2530 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2531 (tool-bar-add-item-from-menu
2532 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2533 (tool-bar-add-item-from-menu
2534 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2535 (tool-bar-add-item-from-menu
2536 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2537 (tool-bar-add-item-from-menu
2538 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2539 (tool-bar-add-item-from-menu
2540 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2541 (tool-bar-add-item-from-menu
2542 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2544 (if gnus-summary-tool-bar-map
2545 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2547 (defun gnus-score-set-default (var value)
2548 "A version of set that updates the GNU Emacs menu-bar."
2550 ;; It is the message that forces the active status to be updated.
2553 (defun gnus-make-score-map (type)
2554 "Make a summary score map of type TYPE."
2557 (let ((headers '(("author" "from" string)
2558 ("subject" "subject" string)
2559 ("article body" "body" string)
2560 ("article head" "head" string)
2561 ("xref" "xref" string)
2562 ("extra header" "extra" string)
2563 ("lines" "lines" number)
2564 ("followups to author" "followup" string)))
2565 (types '((number ("less than" <)
2568 (string ("substring" s)
2572 (perms '(("temporary" (current-time-string))
2580 (if (eq type 'lower)
2585 (setq header (car headers))
2591 (let ((ts (cdr (assoc (nth 2 header) types)))
2607 'gnus-summary-score-entry
2609 (if (or (string= (nth 1 header)
2611 (string= (nth 1 header)
2614 (list 'gnus-summary-header
2616 (list 'quote (nth 1 (car ts)))
2617 (list 'gnus-score-delta-default
2624 (list (nreverse outp))))
2627 (list (nreverse outt))))
2629 (setq headers (cdr headers)))
2630 (list (nreverse outh))))))))
2634 (defun gnus-summary-mode (&optional group)
2635 "Major mode for reading articles.
2637 All normal editing commands are switched off.
2638 \\<gnus-summary-mode-map>
2639 Each line in this buffer represents one article. To read an
2640 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2641 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2644 You can also post articles and send mail from this buffer. To
2645 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2646 of an article, type `\\[gnus-summary-reply]'.
2648 There are approx. one gazillion commands you can execute in this
2649 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2651 The following commands are available:
2653 \\{gnus-summary-mode-map}"
2655 (kill-all-local-variables)
2656 (when (gnus-visual-p 'summary-menu 'menu)
2657 (gnus-summary-make-menu-bar)
2658 (gnus-summary-make-tool-bar))
2659 (gnus-summary-make-local-variables)
2660 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2661 (gnus-summary-make-local-variables))
2662 (gnus-make-thread-indent-array)
2663 (gnus-simplify-mode-line)
2664 (setq major-mode 'gnus-summary-mode)
2665 (setq mode-name "Summary")
2666 (make-local-variable 'minor-mode-alist)
2667 (use-local-map gnus-summary-mode-map)
2668 (buffer-disable-undo)
2669 (setq buffer-read-only t) ;Disable modification
2670 (setq truncate-lines t)
2671 (setq selective-display t)
2672 (setq selective-display-ellipses t) ;Display `...'
2673 (gnus-summary-set-display-table)
2674 (gnus-set-default-directory)
2675 (setq gnus-newsgroup-name group)
2676 (unless (gnus-news-group-p group)
2677 (setq gnus-newsgroup-incorporated
2678 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2679 (make-local-variable 'gnus-summary-line-format)
2680 (make-local-variable 'gnus-summary-line-format-spec)
2681 (make-local-variable 'gnus-summary-dummy-line-format)
2682 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2683 (make-local-variable 'gnus-summary-mark-positions)
2684 (gnus-make-local-hook 'pre-command-hook)
2685 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2686 (gnus-run-hooks 'gnus-summary-mode-hook)
2687 (turn-on-gnus-mailing-list-mode)
2688 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2689 (gnus-update-summary-mark-positions))
2691 (defun gnus-summary-make-local-variables ()
2692 "Make all the local summary buffer variables."
2694 (dolist (local gnus-summary-local-variables)
2697 (if (eq (cdr local) 'global)
2698 ;; Copy the global value of the variable.
2699 (setq global (symbol-value (car local)))
2700 ;; Use the value from the list.
2701 (setq global (eval (cdr local))))
2702 (set (make-local-variable (car local)) global))
2703 ;; Simple nil-valued local variable.
2704 (set (make-local-variable local) nil)))))
2706 (defun gnus-summary-clear-local-variables ()
2707 (let ((locals gnus-summary-local-variables))
2709 (if (consp (car locals))
2710 (and (vectorp (caar locals))
2711 (set (caar locals) nil))
2712 (and (vectorp (car locals))
2713 (set (car locals) nil)))
2714 (setq locals (cdr locals)))))
2716 ;; Summary data functions.
2718 (defmacro gnus-data-number (data)
2721 (defmacro gnus-data-set-number (data number)
2722 `(setcar ,data ,number))
2724 (defmacro gnus-data-mark (data)
2727 (defmacro gnus-data-set-mark (data mark)
2728 `(setcar (nthcdr 1 ,data) ,mark))
2730 (defmacro gnus-data-pos (data)
2733 (defmacro gnus-data-set-pos (data pos)
2734 `(setcar (nthcdr 2 ,data) ,pos))
2736 (defmacro gnus-data-header (data)
2739 (defmacro gnus-data-set-header (data header)
2740 `(setcar (nthcdr 3 ,data) ,header))
2742 (defmacro gnus-data-level (data)
2745 (defmacro gnus-data-unread-p (data)
2746 `(= (nth 1 ,data) gnus-unread-mark))
2748 (defmacro gnus-data-read-p (data)
2749 `(/= (nth 1 ,data) gnus-unread-mark))
2751 (defmacro gnus-data-pseudo-p (data)
2752 `(consp (nth 3 ,data)))
2754 (defmacro gnus-data-find (number)
2755 `(assq ,number gnus-newsgroup-data))
2757 (defmacro gnus-data-find-list (number &optional data)
2758 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2759 (memq (assq ,number bdata)
2762 (defmacro gnus-data-make (number mark pos header level)
2763 `(list ,number ,mark ,pos ,header ,level))
2765 (defun gnus-data-enter (after-article number mark pos header level offset)
2766 (let ((data (gnus-data-find-list after-article)))
2768 (error "No such article: %d" after-article))
2769 (setcdr data (cons (gnus-data-make number mark pos header level)
2771 (setq gnus-newsgroup-data-reverse nil)
2772 (gnus-data-update-list (cddr data) offset)))
2774 (defun gnus-data-enter-list (after-article list &optional offset)
2776 (let ((data (and after-article (gnus-data-find-list after-article)))
2780 (let ((odata gnus-newsgroup-data))
2781 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2783 (gnus-data-update-list odata offset)))
2784 ;; Find the last element in the list to be spliced into the main
2787 (setq list (cdr list)))
2790 (setcdr list gnus-newsgroup-data)
2791 (setq gnus-newsgroup-data ilist)
2793 (gnus-data-update-list (cdr list) offset)))
2794 (setcdr list (cdr data))
2797 (gnus-data-update-list (cdr list) offset))))
2798 (setq gnus-newsgroup-data-reverse nil))))
2800 (defun gnus-data-remove (article &optional offset)
2801 (let ((data gnus-newsgroup-data))
2802 (if (= (gnus-data-number (car data)) article)
2804 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2805 gnus-newsgroup-data-reverse nil)
2807 (gnus-data-update-list gnus-newsgroup-data offset)))
2809 (when (= (gnus-data-number (cadr data)) article)
2810 (setcdr data (cddr data))
2812 (gnus-data-update-list (cdr data) offset))
2814 gnus-newsgroup-data-reverse nil))
2815 (setq data (cdr data))))))
2817 (defmacro gnus-data-list (backward)
2819 (or gnus-newsgroup-data-reverse
2820 (setq gnus-newsgroup-data-reverse
2821 (reverse gnus-newsgroup-data)))
2822 gnus-newsgroup-data))
2824 (defun gnus-data-update-list (data offset)
2825 "Add OFFSET to the POS of all data entries in DATA."
2826 (setq gnus-newsgroup-data-reverse nil)
2828 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2829 (setq data (cdr data))))
2831 (defun gnus-summary-article-pseudo-p (article)
2832 "Say whether this article is a pseudo article or not."
2833 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2835 (defmacro gnus-summary-article-sparse-p (article)
2836 "Say whether this article is a sparse article or not."
2837 `(memq ,article gnus-newsgroup-sparse))
2839 (defmacro gnus-summary-article-ancient-p (article)
2840 "Say whether this article is a sparse article or not."
2841 `(memq ,article gnus-newsgroup-ancient))
2843 (defun gnus-article-parent-p (number)
2844 "Say whether this article is a parent or not."
2845 (let ((data (gnus-data-find-list number)))
2846 (and (cdr data) ; There has to be an article after...
2847 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2848 (gnus-data-level (nth 1 data))))))
2850 (defun gnus-article-children (number)
2851 "Return a list of all children to NUMBER."
2852 (let* ((data (gnus-data-find-list number))
2853 (level (gnus-data-level (car data)))
2855 (setq data (cdr data))
2857 (= (gnus-data-level (car data)) (1+ level)))
2858 (push (gnus-data-number (car data)) children)
2859 (setq data (cdr data)))
2862 (defmacro gnus-summary-skip-intangible ()
2863 "If the current article is intangible, then jump to a different article."
2864 '(let ((to (get-text-property (point) 'gnus-intangible)))
2865 (and to (gnus-summary-goto-subject to))))
2867 (defmacro gnus-summary-article-intangible-p ()
2868 "Say whether this article is intangible or not."
2869 '(get-text-property (point) 'gnus-intangible))
2871 (defun gnus-article-read-p (article)
2872 "Say whether ARTICLE is read or not."
2873 (not (or (memq article gnus-newsgroup-marked)
2874 (memq article gnus-newsgroup-spam-marked)
2875 (memq article gnus-newsgroup-unreads)
2876 (memq article gnus-newsgroup-unselected)
2877 (memq article gnus-newsgroup-dormant))))
2879 ;; Some summary mode macros.
2881 (defmacro gnus-summary-article-number ()
2882 "The article number of the article on the current line.
2883 If there isn't an article number here, then we return the current
2886 (gnus-summary-skip-intangible)
2887 (or (get-text-property (point) 'gnus-number)
2888 (gnus-summary-last-subject))))
2890 (defmacro gnus-summary-article-header (&optional number)
2891 "Return the header of article NUMBER."
2892 `(gnus-data-header (gnus-data-find
2893 ,(or number '(gnus-summary-article-number)))))
2895 (defmacro gnus-summary-thread-level (&optional number)
2896 "Return the level of thread that starts with article NUMBER."
2897 `(if (and (eq gnus-summary-make-false-root 'dummy)
2898 (get-text-property (point) 'gnus-intangible))
2900 (gnus-data-level (gnus-data-find
2901 ,(or number '(gnus-summary-article-number))))))
2903 (defmacro gnus-summary-article-mark (&optional number)
2904 "Return the mark of article NUMBER."
2905 `(gnus-data-mark (gnus-data-find
2906 ,(or number '(gnus-summary-article-number)))))
2908 (defmacro gnus-summary-article-pos (&optional number)
2909 "Return the position of the line of article NUMBER."
2910 `(gnus-data-pos (gnus-data-find
2911 ,(or number '(gnus-summary-article-number)))))
2913 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2914 (defmacro gnus-summary-article-subject (&optional number)
2915 "Return current subject string or nil if nothing."
2918 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2919 '(gnus-data-header (assq (gnus-summary-article-number)
2920 gnus-newsgroup-data)))))
2923 (mail-header-subject headers))))
2925 (defmacro gnus-summary-article-score (&optional number)
2926 "Return current article score."
2927 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2928 gnus-newsgroup-scored))
2929 gnus-summary-default-score 0))
2931 (defun gnus-summary-article-children (&optional number)
2932 "Return a list of article numbers that are children of article NUMBER."
2933 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2934 (level (gnus-data-level (car data)))
2936 (while (and (setq data (cdr data))
2937 (> (setq l (gnus-data-level (car data))) level))
2938 (and (= (1+ level) l)
2939 (push (gnus-data-number (car data))
2941 (nreverse children)))
2943 (defun gnus-summary-article-parent (&optional number)
2944 "Return the article number of the parent of article NUMBER."
2945 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2946 (gnus-data-list t)))
2947 (level (gnus-data-level (car data))))
2949 () ; This is a root.
2950 ;; We search until we find an article with a level less than
2951 ;; this one. That function has to be the parent.
2952 (while (and (setq data (cdr data))
2953 (not (< (gnus-data-level (car data)) level))))
2954 (and data (gnus-data-number (car data))))))
2956 (defun gnus-unread-mark-p (mark)
2957 "Say whether MARK is the unread mark."
2958 (= mark gnus-unread-mark))
2960 (defun gnus-read-mark-p (mark)
2961 "Say whether MARK is one of the marks that mark as read.
2962 This is all marks except unread, ticked, dormant, and expirable."
2963 (not (or (= mark gnus-unread-mark)
2964 (= mark gnus-ticked-mark)
2965 (= mark gnus-spam-mark)
2966 (= mark gnus-dormant-mark)
2967 (= mark gnus-expirable-mark))))
2969 (defmacro gnus-article-mark (number)
2970 "Return the MARK of article NUMBER.
2971 This macro should only be used when computing the mark the \"first\"
2972 time; i.e., when generating the summary lines. After that,
2973 `gnus-summary-article-mark' should be used to examine the
2976 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2977 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2978 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2979 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2980 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2981 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2982 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2983 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2984 gnus-ancient-mark))))
2986 ;; Saving hidden threads.
2988 (defmacro gnus-save-hidden-threads (&rest forms)
2989 "Save hidden threads, eval FORMS, and restore the hidden threads."
2990 (let ((config (make-symbol "config")))
2991 `(let ((,config (gnus-hidden-threads-configuration)))
2995 (gnus-restore-hidden-threads-configuration ,config)))))
2996 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2997 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2999 (defun gnus-data-compute-positions ()
3000 "Compute the positions of all articles."
3001 (setq gnus-newsgroup-data-reverse nil)
3002 (let ((data gnus-newsgroup-data))
3004 (gnus-save-hidden-threads
3005 (gnus-summary-show-all-threads)
3006 (goto-char (point-min))
3008 (while (get-text-property (point) 'gnus-intangible)
3010 (gnus-data-set-pos (car data) (+ (point) 3))
3011 (setq data (cdr data))
3012 (forward-line 1))))))
3014 (defun gnus-hidden-threads-configuration ()
3015 "Return the current hidden threads configuration."
3018 (goto-char (point-min))
3019 (while (search-forward "\r" nil t)
3020 (push (1- (point)) config))
3023 (defun gnus-restore-hidden-threads-configuration (config)
3024 "Restore hidden threads configuration from CONFIG."
3026 (let (point buffer-read-only)
3027 (while (setq point (pop config))
3028 (when (and (< point (point-max))
3030 (eq (char-after) ?\n))
3031 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3033 ;; Various summary mode internalish functions.
3035 (defun gnus-mouse-pick-article (e)
3038 (gnus-summary-next-page nil t))
3040 (defun gnus-summary-set-display-table ()
3041 "Change the display table.
3042 Odd characters have a tendency to mess
3043 up nicely formatted displays - we make all possible glyphs
3044 display only a single character."
3046 ;; We start from the standard display table, if any.
3047 (let ((table (or (copy-sequence standard-display-table)
3048 (make-display-table)))
3050 ;; Nix out all the control chars...
3051 (while (>= (setq i (1- i)) 0)
3052 (aset table i [??]))
3053 ;; ... but not newline and cr, of course. (cr is necessary for the
3054 ;; selective display).
3055 (aset table ?\n nil)
3056 (aset table ?\r nil)
3057 ;; We keep TAB as well.
3058 (aset table ?\t nil)
3059 ;; We nix out any glyphs over 126 that are not set already.
3061 (while (>= (setq i (1- i)) 127)
3062 ;; Only modify if the entry is nil.
3063 (unless (aref table i)
3064 (aset table i [??]))))
3065 (setq buffer-display-table table)))
3067 (defun gnus-summary-set-article-display-arrow (pos)
3068 "Update the overlay arrow to point to line at position POS."
3069 (when (and gnus-summary-display-arrow
3070 (boundp 'overlay-arrow-position)
3071 (boundp 'overlay-arrow-string))
3075 (unless overlay-arrow-position
3076 (setq overlay-arrow-position (make-marker)))
3077 (setq overlay-arrow-string "=>"
3078 overlay-arrow-position (set-marker overlay-arrow-position
3080 (current-buffer))))))
3082 (defun gnus-summary-setup-buffer (group)
3083 "Initialize summary buffer."
3084 (let ((buffer (gnus-summary-buffer-name group))
3085 (dead-name (concat "*Dead Summary "
3086 (gnus-group-decoded-name group) "*")))
3087 ;; If a dead summary buffer exists, we kill it.
3088 (when (gnus-buffer-live-p dead-name)
3089 (gnus-kill-buffer dead-name))
3090 (if (get-buffer buffer)
3093 (setq gnus-summary-buffer (current-buffer))
3094 (not gnus-newsgroup-prepared))
3095 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3096 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3097 (gnus-summary-mode group)
3099 (gnus-carpal-setup-buffer 'summary))
3100 (unless gnus-single-article-buffer
3101 (make-local-variable 'gnus-article-buffer)
3102 (make-local-variable 'gnus-article-current)
3103 (make-local-variable 'gnus-original-article-buffer))
3104 (setq gnus-newsgroup-name group)
3105 ;; Set any local variables in the group parameters.
3106 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3109 (defun gnus-set-global-variables ()
3110 "Set the global equivalents of the buffer-local variables.
3111 They are set to the latest values they had. These reflect the summary
3112 buffer that was in action when the last article was fetched."
3113 (when (eq major-mode 'gnus-summary-mode)
3114 (setq gnus-summary-buffer (current-buffer))
3115 (let ((name gnus-newsgroup-name)
3116 (marked gnus-newsgroup-marked)
3117 (spam gnus-newsgroup-spam-marked)
3118 (unread gnus-newsgroup-unreads)
3119 (headers gnus-current-headers)
3120 (data gnus-newsgroup-data)
3121 (summary gnus-summary-buffer)
3122 (article-buffer gnus-article-buffer)
3123 (original gnus-original-article-buffer)
3124 (gac gnus-article-current)
3125 (reffed gnus-reffed-article-number)
3126 (score-file gnus-current-score-file)
3127 (default-charset gnus-newsgroup-charset)
3129 (let ((locals gnus-newsgroup-variables))
3131 (if (consp (car locals))
3132 (push (eval (caar locals)) vlist)
3133 (push (eval (car locals)) vlist))
3134 (setq locals (cdr locals)))
3135 (setq vlist (nreverse vlist)))
3137 (set-buffer gnus-group-buffer)
3138 (setq gnus-newsgroup-name name
3139 gnus-newsgroup-marked marked
3140 gnus-newsgroup-spam-marked spam
3141 gnus-newsgroup-unreads unread
3142 gnus-current-headers headers
3143 gnus-newsgroup-data data
3144 gnus-article-current gac
3145 gnus-summary-buffer summary
3146 gnus-article-buffer article-buffer
3147 gnus-original-article-buffer original
3148 gnus-reffed-article-number reffed
3149 gnus-current-score-file score-file
3150 gnus-newsgroup-charset default-charset)
3151 (let ((locals gnus-newsgroup-variables))
3153 (if (consp (car locals))
3154 (set (caar locals) (pop vlist))
3155 (set (car locals) (pop vlist)))
3156 (setq locals (cdr locals))))
3157 ;; The article buffer also has local variables.
3158 (when (gnus-buffer-live-p gnus-article-buffer)
3159 (set-buffer gnus-article-buffer)
3160 (setq gnus-summary-buffer summary))))))
3162 (defun gnus-summary-article-unread-p (article)
3163 "Say whether ARTICLE is unread or not."
3164 (memq article gnus-newsgroup-unreads))
3166 (defun gnus-summary-first-article-p (&optional article)
3167 "Return whether ARTICLE is the first article in the buffer."
3168 (if (not (setq article (or article (gnus-summary-article-number))))
3170 (eq article (caar gnus-newsgroup-data))))
3172 (defun gnus-summary-last-article-p (&optional article)
3173 "Return whether ARTICLE is the last article in the buffer."
3174 (if (not (setq article (or article (gnus-summary-article-number))))
3175 ;; All non-existent numbers are the last article. :-)
3177 (not (cdr (gnus-data-find-list article)))))
3179 (defun gnus-make-thread-indent-array ()
3181 (unless (and gnus-thread-indent-array
3182 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3183 (setq gnus-thread-indent-array (make-vector 201 "")
3184 gnus-thread-indent-array-level gnus-thread-indent-level)
3186 (aset gnus-thread-indent-array n
3187 (make-string (* n gnus-thread-indent-level) ? ))
3190 (defun gnus-update-summary-mark-positions ()
3191 "Compute where the summary marks are to go."
3193 (when (gnus-buffer-exists-p gnus-summary-buffer)
3194 (set-buffer gnus-summary-buffer))
3195 (let ((gnus-replied-mark 129)
3196 (gnus-score-below-mark 130)
3197 (gnus-score-over-mark 130)
3198 (gnus-undownloaded-mark 131)
3199 (spec gnus-summary-line-format-spec)
3202 (gnus-set-work-buffer)
3203 (let ((gnus-summary-line-format-spec spec)
3204 (gnus-newsgroup-downloadable '(0)))
3205 (gnus-summary-insert-line
3206 (make-full-mail-header 0 "" "nobody"
3207 "05 Apr 2001 23:33:09 +0400"
3209 0 nil t 128 t nil "" nil 1)
3210 (goto-char (point-min))
3211 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3212 (- (point) (point-min) 1)))))
3213 (goto-char (point-min))
3214 (push (cons 'replied (and (search-forward "\201" nil t)
3215 (- (point) (point-min) 1)))
3217 (goto-char (point-min))
3218 (push (cons 'score (and (search-forward "\202" nil t)
3219 (- (point) (point-min) 1)))
3221 (goto-char (point-min))
3222 (push (cons 'download
3223 (and (search-forward "\203" nil t)
3224 (- (point) (point-min) 1)))
3226 (setq gnus-summary-mark-positions pos))))
3228 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3229 "Insert a dummy root in the summary buffer."
3231 (gnus-add-text-properties
3232 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3233 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3235 (defun gnus-summary-extract-address-component (from)
3236 (or (car (funcall gnus-extract-address-components from))
3239 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3240 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3241 default-mime-charset)))
3242 ;; Is it really necessary to do this next part for each summary line?
3243 ;; Luckily, doesn't seem to slow things down much.
3245 (and gnus-ignored-from-addresses
3246 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3247 (let ((extra-headers (mail-header-extra header))
3251 ((setq to (cdr (assq 'To extra-headers)))
3254 (gnus-summary-extract-address-component
3255 (funcall gnus-decode-encoded-word-function to)))))
3256 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3257 (concat "=> " newsgroups)))))
3258 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3260 (defun gnus-summary-insert-line (gnus-tmp-header
3261 gnus-tmp-level gnus-tmp-current
3262 undownloaded gnus-tmp-unread gnus-tmp-replied
3263 gnus-tmp-expirable gnus-tmp-subject-or-nil
3264 &optional gnus-tmp-dummy gnus-tmp-score
3266 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3267 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3268 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3269 (gnus-tmp-score-char
3270 (if (or (null gnus-summary-default-score)
3271 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3272 gnus-summary-zcore-fuzz))
3274 (if (< gnus-tmp-score gnus-summary-default-score)
3275 gnus-score-below-mark gnus-score-over-mark)))
3276 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3278 (cond (gnus-tmp-process gnus-process-mark)
3279 ((memq gnus-tmp-current gnus-newsgroup-cached)
3281 (gnus-tmp-replied gnus-replied-mark)
3282 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3283 gnus-forwarded-mark)
3284 ((memq gnus-tmp-current gnus-newsgroup-saved)
3286 ((memq gnus-tmp-number gnus-newsgroup-recent)
3288 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3291 (gnus-tmp-downloaded
3293 gnus-undownloaded-mark)
3294 (gnus-newsgroup-agentized
3295 gnus-downloaded-mark)
3298 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3301 ((string-match "<[^>]+> *$" gnus-tmp-from)
3302 (let ((beg (match-beginning 0)))
3303 (or (and (string-match "^\".+\"" gnus-tmp-from)
3304 (substring gnus-tmp-from 1 (1- (match-end 0))))
3305 (substring gnus-tmp-from 0 beg))))
3306 ((string-match "(.+)" gnus-tmp-from)
3307 (substring gnus-tmp-from
3308 (1+ (match-beginning 0)) (1- (match-end 0))))
3310 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3311 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3312 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3313 (buffer-read-only nil))
3314 (when (string= gnus-tmp-name "")
3315 (setq gnus-tmp-name gnus-tmp-from))
3316 (unless (numberp gnus-tmp-lines)
3317 (setq gnus-tmp-lines -1))
3318 (if (= gnus-tmp-lines -1)
3319 (setq gnus-tmp-lines "?")
3320 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3321 (gnus-put-text-property-excluding-characters-with-faces
3323 (progn (eval gnus-summary-line-format-spec) (point))
3324 'gnus-number gnus-tmp-number)
3325 (when (gnus-visual-p 'summary-highlight 'highlight)
3327 (gnus-run-hooks 'gnus-summary-update-hook)
3330 (defun gnus-summary-update-line (&optional dont-update)
3331 "Update summary line after change."
3332 (when (and gnus-summary-default-score
3333 (not gnus-summary-inhibit-highlight))
3334 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3335 (article (gnus-summary-article-number))
3336 (score (gnus-summary-article-score article)))
3338 (if (and gnus-summary-mark-below
3339 (< (gnus-summary-article-score)
3340 gnus-summary-mark-below))
3341 ;; This article has a low score, so we mark it as read.
3342 (when (memq article gnus-newsgroup-unreads)
3343 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3344 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3345 ;; This article was previously marked as read on account
3346 ;; of a low score, but now it has risen, so we mark it as
3348 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3349 (gnus-summary-update-mark
3350 (if (or (null gnus-summary-default-score)
3351 (<= (abs (- score gnus-summary-default-score))
3352 gnus-summary-zcore-fuzz))
3354 (if (< score gnus-summary-default-score)
3355 gnus-score-below-mark gnus-score-over-mark))
3357 ;; Do visual highlighting.
3358 (when (gnus-visual-p 'summary-highlight 'highlight)
3359 (gnus-run-hooks 'gnus-summary-update-hook)))))
3361 (defvar gnus-tmp-new-adopts nil)
3363 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3364 "Return the number of articles in THREAD.
3365 This may be 0 in some cases -- if none of the articles in
3366 the thread are to be displayed."
3368 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3370 ((not (listp thread))
3372 ((and (consp thread) (cdr thread))
3375 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3378 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3381 (when (and level (zerop level) gnus-tmp-new-adopts)
3384 'gnus-summary-number-of-articles-in-thread
3385 gnus-tmp-new-adopts))))
3387 (if (> number 1) gnus-not-empty-thread-mark
3388 gnus-empty-thread-mark)
3391 (defsubst gnus-summary-line-message-size (head)
3392 "Return pretty-printed version of message size.
3393 This function is intended to be used in
3394 `gnus-summary-line-format-alist'."
3395 (let ((c (or (mail-header-chars head) -1)))
3396 (cond ((< c 0) "n/a") ; chars not available
3397 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3398 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3399 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3400 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3403 (defun gnus-summary-set-local-parameters (group)
3404 "Go through the local params of GROUP and set all variable specs in that list."
3405 (let ((params (gnus-group-find-parameter group))
3406 (vars '(quit-config)) ; Ignore quit-config.
3409 (setq elem (car params)
3410 params (cdr params))
3411 (and (consp elem) ; Has to be a cons.
3412 (consp (cdr elem)) ; The cdr has to be a list.
3413 (symbolp (car elem)) ; Has to be a symbol in there.
3414 (not (memq (car elem) vars))
3415 (ignore-errors ; So we set it.
3416 (push (car elem) vars)
3417 (make-local-variable (car elem))
3418 (set (car elem) (eval (nth 1 elem))))))))
3420 (defun gnus-summary-read-group (group &optional show-all no-article
3421 kill-buffer no-display backward
3423 "Start reading news in newsgroup GROUP.
3424 If SHOW-ALL is non-nil, already read articles are also listed.
3425 If NO-ARTICLE is non-nil, no article is selected initially.
3426 If NO-DISPLAY, don't generate a summary buffer."
3430 (let ((gnus-auto-select-next nil))
3431 (or (gnus-summary-read-group-1
3432 group show-all no-article
3433 kill-buffer no-display
3436 select-articles nil)))))
3437 (eq gnus-auto-select-next 'quietly))
3438 (set-buffer gnus-group-buffer)
3439 ;; The entry function called above goes to the next
3440 ;; group automatically, so we go two groups back
3441 ;; if we are searching for the previous group.
3443 (gnus-group-prev-unread-group 2))
3444 (if (not (equal group (gnus-group-group-name)))
3445 (setq group (gnus-group-group-name))
3449 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3450 "Directly jump to the other GROUP from summary buffer.
3451 If SHOW-ALL is non-nil, already read articles are also listed."
3453 (if (eq gnus-summary-buffer (current-buffer))
3454 (list (completing-read
3455 "Group: " gnus-active-hashtb nil t
3456 (when (and gnus-newsgroup-name
3457 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3458 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3459 'gnus-group-history)
3461 (error "%s must be invoked from a gnus summary buffer." this-command)))
3462 (unless (or (zerop (length group))
3463 (and gnus-newsgroup-name
3464 (string-equal gnus-newsgroup-name group)))
3466 (gnus-summary-read-group group show-all
3467 gnus-dont-select-after-jump-to-other-group)))
3469 (defun gnus-summary-read-group-1 (group show-all no-article
3470 kill-buffer no-display
3471 &optional select-articles)
3472 ;; Killed foreign groups can't be entered.
3473 ;; (when (and (not (gnus-group-native-p group))
3474 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3475 ;; (error "Dead non-native groups can't be entered"))
3476 (gnus-message 5 "Retrieving newsgroup: %s..."
3477 (gnus-group-decoded-name group))
3478 (let* ((new-group (gnus-summary-setup-buffer group))
3479 (quit-config (gnus-group-quit-config group))
3480 (did-select (and new-group (gnus-select-newsgroup
3481 group show-all select-articles))))
3483 ;; This summary buffer exists already, so we just select it.
3485 (gnus-set-global-variables)
3487 (gnus-kill-or-deaden-summary kill-buffer))
3488 (gnus-configure-windows 'summary 'force)
3489 (gnus-set-mode-line 'summary)
3490 (gnus-summary-position-point)
3493 ;; We couldn't select this group.
3495 (when (and (eq major-mode 'gnus-summary-mode)
3496 (not (equal (current-buffer) kill-buffer)))
3497 (kill-buffer (current-buffer))
3498 (if (not quit-config)
3500 ;; Update the info -- marks might need to be removed,
3502 (gnus-summary-update-info)
3503 (set-buffer gnus-group-buffer)
3504 (gnus-group-jump-to-group group)
3505 (gnus-group-next-unread-group 1))
3506 (gnus-handle-ephemeral-exit quit-config)))
3507 (let ((grpinfo (gnus-get-info group)))
3508 (if (null (gnus-info-read grpinfo))
3509 (gnus-message 3 "Group %s contains no messages"
3510 (gnus-group-decoded-name group))
3511 (gnus-message 3 "Can't select group")))
3513 ;; The user did a `C-g' while prompting for number of articles,
3514 ;; so we exit this group.
3515 ((eq did-select 'quit)
3516 (and (eq major-mode 'gnus-summary-mode)
3517 (not (equal (current-buffer) kill-buffer))
3518 (kill-buffer (current-buffer)))
3520 (gnus-kill-or-deaden-summary kill-buffer))
3521 (if (not quit-config)
3523 (set-buffer gnus-group-buffer)
3524 (gnus-group-jump-to-group group)
3525 (gnus-group-next-unread-group 1)
3526 (gnus-configure-windows 'group 'force))
3527 (gnus-handle-ephemeral-exit quit-config))
3528 ;; Finally signal the quit.
3530 ;; The group was successfully selected.
3532 (gnus-set-global-variables)
3533 ;; Save the active value in effect when the group was entered.
3534 (setq gnus-newsgroup-active
3536 (gnus-active gnus-newsgroup-name)))
3537 ;; You can change the summary buffer in some way with this hook.
3538 (gnus-run-hooks 'gnus-select-group-hook)
3539 (gnus-update-format-specifications
3540 nil 'summary 'summary-mode 'summary-dummy)
3541 (gnus-update-summary-mark-positions)
3542 ;; Do score processing.
3543 (when gnus-use-scoring
3544 (gnus-possibly-score-headers))
3545 ;; Check whether to fill in the gaps in the threads.
3546 (when gnus-build-sparse-threads
3547 (gnus-build-sparse-threads))
3548 ;; Find the initial limit.
3549 (if gnus-show-threads
3551 (let ((gnus-newsgroup-dormant nil))
3552 (gnus-summary-initial-limit show-all))
3553 (gnus-summary-initial-limit show-all))
3554 ;; When unthreaded, all articles are always shown.
3555 (setq gnus-newsgroup-limit
3557 (lambda (header) (mail-header-number header))
3558 gnus-newsgroup-headers)))
3559 ;; Generate the summary buffer.
3561 (gnus-summary-prepare))
3562 (when gnus-use-trees
3563 (gnus-tree-open group)
3564 (setq gnus-summary-highlight-line-function
3565 'gnus-tree-highlight-article))
3566 ;; If the summary buffer is empty, but there are some low-scored
3567 ;; articles or some excluded dormants, we include these in the
3569 (when (and (zerop (buffer-size))
3571 (cond (gnus-newsgroup-dormant
3572 (gnus-summary-limit-include-dormant))
3573 ((and gnus-newsgroup-scored show-all)
3574 (gnus-summary-limit-include-expunged t))))
3575 ;; Function `gnus-apply-kill-file' must be called in this hook.
3576 (gnus-run-hooks 'gnus-apply-kill-hook)
3577 (if (and (zerop (buffer-size))
3580 ;; This newsgroup is empty.
3581 (gnus-summary-catchup-and-exit nil t)
3582 (gnus-message 6 "No unread news")
3584 (gnus-kill-or-deaden-summary kill-buffer))
3585 ;; Return nil from this function.
3587 ;; Hide conversation thread subtrees. We cannot do this in
3588 ;; gnus-summary-prepare-hook since kill processing may not
3589 ;; work with hidden articles.
3590 (gnus-summary-maybe-hide-threads)
3592 (gnus-kill-or-deaden-summary kill-buffer))
3593 (gnus-summary-auto-select-subject)
3594 ;; Show first unread article if requested.
3595 (if (and (not no-article)
3597 gnus-newsgroup-unreads
3598 gnus-auto-select-first)
3600 (gnus-configure-windows 'summary)
3601 (let ((art (gnus-summary-article-number)))
3602 (unless (and (not gnus-plugged)
3603 (or (memq art gnus-newsgroup-undownloaded)
3604 (memq art gnus-newsgroup-downloadable)))
3605 (gnus-summary-goto-article art))))
3606 ;; Don't select any articles.
3607 (gnus-summary-position-point)
3608 (gnus-configure-windows 'summary 'force)
3609 (gnus-set-mode-line 'summary))
3610 (when (and gnus-auto-center-group
3611 (get-buffer-window gnus-group-buffer t))
3612 ;; Gotta use windows, because recenter does weird stuff if
3613 ;; the current buffer ain't the displayed window.
3614 (let ((owin (selected-window)))
3615 (select-window (get-buffer-window gnus-group-buffer t))
3616 (when (gnus-group-goto-group group)
3618 (select-window owin)))
3619 ;; Mark this buffer as "prepared".
3620 (setq gnus-newsgroup-prepared t)
3621 (gnus-run-hooks 'gnus-summary-prepared-hook)
3622 (unless (gnus-ephemeral-group-p group)
3623 (gnus-group-update-group group))
3626 (defun gnus-summary-auto-select-subject ()
3627 "Select the subject line on initial group entry."
3628 (goto-char (point-min))
3630 ((eq gnus-auto-select-subject 'best)
3631 (gnus-summary-best-unread-subject))
3632 ((eq gnus-auto-select-subject 'unread)
3633 (gnus-summary-first-unread-subject))
3634 ((eq gnus-auto-select-subject 'unseen)
3635 (gnus-summary-first-unseen-subject))
3636 ((eq gnus-auto-select-subject 'unseen-or-unread)
3637 (gnus-summary-first-unseen-or-unread-subject))
3638 ((eq gnus-auto-select-subject 'first)
3641 ((functionp gnus-auto-select-subject)
3642 (funcall gnus-auto-select-subject))))
3644 (defun gnus-summary-prepare ()
3645 "Generate the summary buffer."
3647 (let ((buffer-read-only nil))
3649 (setq gnus-newsgroup-data nil
3650 gnus-newsgroup-data-reverse nil)
3651 (gnus-run-hooks 'gnus-summary-generate-hook)
3652 ;; Generate the buffer, either with threads or without.
3653 (when gnus-newsgroup-headers
3654 (gnus-summary-prepare-threads
3655 (if gnus-show-threads
3656 (gnus-sort-gathered-threads
3657 (funcall gnus-summary-thread-gathering-function
3659 (gnus-cut-threads (gnus-make-threads)))))
3660 ;; Unthreaded display.
3661 (gnus-sort-articles gnus-newsgroup-headers))))
3662 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3663 ;; Call hooks for modifying summary buffer.
3664 (goto-char (point-min))
3665 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3667 (defsubst gnus-general-simplify-subject (subject)
3668 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3671 ;; Truncate the subject.
3672 (gnus-simplify-subject-functions
3673 (gnus-map-function gnus-simplify-subject-functions subject))
3674 ((numberp gnus-summary-gather-subject-limit)
3675 (setq subject (gnus-simplify-subject-re subject))
3676 (if (> (length subject) gnus-summary-gather-subject-limit)
3677 (substring subject 0 gnus-summary-gather-subject-limit)
3679 ;; Fuzzily simplify it.
3680 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3681 (gnus-simplify-subject-fuzzy subject))
3682 ;; Just remove the leading "Re:".
3684 (gnus-simplify-subject-re subject))))
3686 (if (and gnus-summary-gather-exclude-subject
3687 (string-match gnus-summary-gather-exclude-subject subject))
3688 nil ; This article shouldn't be gathered
3691 (defun gnus-summary-simplify-subject-query ()
3692 "Query where the respool algorithm would put this article."
3694 (gnus-summary-select-article)
3696 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3698 (defun gnus-gather-threads-by-subject (threads)
3699 "Gather threads by looking at Subject headers."
3700 (if (not gnus-summary-make-false-root)
3702 (let ((hashtb (gnus-make-hashtable 1024))
3705 subject hthread whole-subject)
3707 (setq subject (gnus-general-simplify-subject
3708 (setq whole-subject (mail-header-subject
3711 (if (setq hthread (gnus-gethash subject hashtb))
3713 ;; We enter a dummy root into the thread, if we
3714 ;; haven't done that already.
3715 (unless (stringp (caar hthread))
3716 (setcar hthread (list whole-subject (car hthread))))
3717 ;; We add this new gathered thread to this gathered
3719 (setcdr (car hthread)
3720 (nconc (cdar hthread) (list (car threads))))
3721 ;; Remove it from the list of threads.
3722 (setcdr prev (cdr threads))
3723 (setq threads prev))
3724 ;; Enter this thread into the hash table.
3725 (gnus-sethash subject
3726 (if gnus-summary-make-false-root-always
3728 ;; If you want a dummy root above all
3730 (setcar threads (list whole-subject
3736 (setq threads (cdr threads)))
3739 (defun gnus-gather-threads-by-references (threads)
3740 "Gather threads by looking at References headers."
3741 (let ((idhashtb (gnus-make-hashtable 1024))
3742 (thhashtb (gnus-make-hashtable 1024))
3745 ids references id gthread gid entered ref)
3747 (when (setq references (mail-header-references (caar threads)))
3748 (setq id (mail-header-id (caar threads))
3749 ids (inline (gnus-split-references references))
3751 (while (setq ref (pop ids))
3752 (setq ids (delete ref ids))
3753 (if (not (setq gid (gnus-gethash ref idhashtb)))
3755 (gnus-sethash ref id idhashtb)
3756 (gnus-sethash id threads thhashtb))
3757 (setq gthread (gnus-gethash gid thhashtb))
3759 ;; We enter a dummy root into the thread, if we
3760 ;; haven't done that already.
3761 (unless (stringp (caar gthread))
3762 (setcar gthread (list (mail-header-subject (caar gthread))
3764 ;; We add this new gathered thread to this gathered
3766 (setcdr (car gthread)
3767 (nconc (cdar gthread) (list (car threads)))))
3768 ;; Add it into the thread hash table.
3769 (gnus-sethash id gthread thhashtb)
3771 ;; Remove it from the list of threads.
3772 (setcdr prev (cdr threads))
3773 (setq threads prev))))
3775 (setq threads (cdr threads)))
3778 (defun gnus-sort-gathered-threads (threads)
3779 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3780 (let ((result threads))
3782 (when (stringp (caar threads))
3783 (setcdr (car threads)
3784 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3785 (setq threads (cdr threads)))
3788 (defun gnus-thread-loop-p (root thread)
3789 "Say whether ROOT is in THREAD."
3790 (let ((stack (list thread))
3793 (while (setq thread (pop stack))
3794 (setq th (cdr thread))
3796 (not (eq (caar th) root)))
3799 ;; We have found a loop.
3801 (setcdr thread (delq (car th) (cdr thread)))
3802 (if (boundp (setq ref-dep (intern "none"
3803 gnus-newsgroup-dependencies)))
3804 (setcdr (symbol-value ref-dep)
3805 (nconc (cdr (symbol-value ref-dep))
3807 (set ref-dep (list nil (car th))))
3810 ;; Push all the subthreads onto the stack.
3811 (push (cdr thread) stack)))
3814 (defun gnus-make-threads ()
3815 "Go through the dependency hashtb and find the roots. Return all threads."
3817 (while (catch 'infloop
3820 ;; Deal with self-referencing References loops.
3821 (when (and (car (symbol-value refs))
3828 (car (symbol-value refs)) thread))
3829 (cdr (symbol-value refs)))))))
3832 (unless (car (symbol-value refs))
3833 ;; These threads do not refer back to any other articles,
3834 ;; so they're roots.
3835 (setq threads (append (cdr (symbol-value refs)) threads))))
3836 gnus-newsgroup-dependencies)))
3839 ;; Build the thread tree.
3840 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3841 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3843 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3844 if it was already present.
3846 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3847 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3848 Message-IDs will be renamed to a unique Message-ID before being
3851 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3852 (let* ((id (mail-header-id header))
3853 (id-dep (and id (intern id dependencies)))
3854 parent-id ref ref-dep ref-header replaced)
3855 ;; Enter this `header' in the `dependencies' table.
3859 ;; The first two cases do the normal part: enter a new `header'
3860 ;; in the `dependencies' table.
3861 ((not (boundp id-dep))
3862 (set id-dep (list header)))
3863 ((null (car (symbol-value id-dep)))
3864 (setcar (symbol-value id-dep) header))
3866 ;; From here the `header' was already present in the
3867 ;; `dependencies' table.
3869 ;; Overrides an existing entry;
3870 ;; just set the header part of the entry.
3871 (setcar (symbol-value id-dep) header)
3874 ;; Renames the existing `header' to a unique Message-ID.
3875 ((not gnus-summary-ignore-duplicates)
3876 ;; An article with this Message-ID has already been seen.
3877 ;; We rename the Message-ID.
3878 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3880 (mail-header-set-id header id))
3882 ;; The last case ignores an existing entry, except it adds any
3883 ;; additional Xrefs (in case the two articles came from different
3885 ;; Also sets `header' to `nil' meaning that the `dependencies'
3886 ;; table was *not* modified.
3888 (mail-header-set-xref
3889 (car (symbol-value id-dep))
3890 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3892 (or (mail-header-xref header) "")))
3895 (when (and header (not replaced))
3896 ;; First check that we are not creating a References loop.
3897 (setq parent-id (gnus-parent-id (mail-header-references header)))
3898 (setq ref parent-id)
3900 (setq ref-dep (intern-soft ref dependencies))
3902 (setq ref-header (car (symbol-value ref-dep))))
3903 (if (string= id ref)
3904 ;; Yuk! This is a reference loop. Make the article be a
3907 (mail-header-set-references (car (symbol-value id-dep)) "none")
3909 (setq parent-id nil))
3910 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3911 (setq ref-dep (intern (or parent-id "none") dependencies))
3912 (if (boundp ref-dep)
3913 (setcdr (symbol-value ref-dep)
3914 (nconc (cdr (symbol-value ref-dep))
3915 (list (symbol-value id-dep))))
3916 (set ref-dep (list nil (symbol-value id-dep)))))
3919 (defun gnus-extract-message-id-from-in-reply-to (string)
3920 (if (string-match "<[^>]+>" string)
3921 (substring string (match-beginning 0) (match-end 0))
3924 (defun gnus-build-sparse-threads ()
3925 (let ((headers gnus-newsgroup-headers)
3926 (mail-parse-charset gnus-newsgroup-charset)
3927 (gnus-summary-ignore-duplicates t)
3928 header references generation relations
3929 subject child end new-child date)
3930 ;; First we create an alist of generations/relations, where
3931 ;; generations is how much we trust the relation, and the relation
3933 (gnus-message 7 "Making sparse threads...")
3935 (nnheader-set-temp-buffer " *gnus sparse threads*")
3936 (while (setq header (pop headers))
3937 (when (and (setq references (mail-header-references header))
3938 (not (string= references "")))
3940 (setq child (mail-header-id header)
3941 subject (mail-header-subject header)
3942 date (mail-header-date header)
3944 (while (search-backward ">" nil t)
3945 (setq end (1+ (point)))
3946 (when (search-backward "<" nil t)
3947 (setq new-child (buffer-substring (point) end))
3948 (push (list (incf generation)
3949 child (setq child new-child)
3953 (push (list (1+ generation) child nil subject) relations))
3955 (kill-buffer (current-buffer)))
3956 ;; Sort over trustworthiness.
3959 (when (gnus-dependencies-add-header
3960 (make-full-mail-header-from-decoded-header
3961 gnus-reffed-article-number
3962 (nth 3 relation) "" (or (nth 4 relation) "")
3964 (or (nth 2 relation) "") 0 0 "")
3965 gnus-newsgroup-dependencies nil)
3966 (push gnus-reffed-article-number gnus-newsgroup-limit)
3967 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3968 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3969 gnus-newsgroup-reads)
3970 (decf gnus-reffed-article-number)))
3971 (sort relations 'car-less-than-car))
3972 (gnus-message 7 "Making sparse threads...done")))
3974 (defun gnus-build-old-threads ()
3975 ;; Look at all the articles that refer back to old articles, and
3976 ;; fetch the headers for the articles that aren't there. This will
3977 ;; build complete threads - if the roots haven't been expired by the
3979 (let ((mail-parse-charset gnus-newsgroup-charset)
3983 (when (not (car (symbol-value refs)))
3984 (setq heads (cdr (symbol-value refs)))
3986 (if (memq (mail-header-number (caar heads))
3987 gnus-newsgroup-dormant)
3988 (setq heads (cdr heads))
3989 (setq id (symbol-name refs))
3990 (while (and (setq id (gnus-build-get-header id))
3991 (not (car (gnus-id-to-thread id)))))
3992 (setq heads nil)))))
3993 gnus-newsgroup-dependencies)))
3995 (defsubst gnus-remove-odd-characters (string)
3996 "Translate STRING into something that doesn't contain weird characters."
3997 (mm-subst-char-in-string
3999 (mm-subst-char-in-string ?\n ?\- string t) t))
4001 ;; This function has to be called with point after the article number
4002 ;; on the beginning of the line.
4003 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4004 (let ((eol (point-at-eol))
4005 (buffer (current-buffer))
4006 header references in-reply-to)
4008 ;; overview: [num subject from date id refs chars lines misc]
4011 (narrow-to-region (point) eol)
4016 (make-full-mail-header
4018 (nnheader-nov-field) ; subject
4019 (nnheader-nov-field) ; from
4020 (nnheader-nov-field) ; date
4021 (nnheader-nov-read-message-id) ; id
4022 (nnheader-nov-field) ; refs
4023 (nnheader-nov-read-integer) ; chars
4024 (nnheader-nov-read-integer) ; lines
4026 (if (looking-at "Xref: ")
4027 (goto-char (match-end 0)))
4028 (nnheader-nov-field)) ; Xref
4029 (nnheader-nov-parse-extra)))) ; extra
4033 (when (and (string= references "")
4034 (setq in-reply-to (mail-header-extra header))
4035 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4036 (mail-header-set-references
4037 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4039 (when gnus-alter-header-function
4040 (funcall gnus-alter-header-function header))
4041 (gnus-dependencies-add-header header dependencies force-new)))
4043 (defun gnus-build-get-header (id)
4044 "Look through the buffer of NOV lines and find the header to ID.
4045 Enter this line into the dependencies hash table, and return
4046 the id of the parent article (if any)."
4047 (let ((deps gnus-newsgroup-dependencies)
4051 (set-buffer nntp-server-buffer)
4052 (let ((case-fold-search nil))
4053 (goto-char (point-min))
4054 (while (and (not found)
4055 (search-forward id nil t))
4057 (setq found (looking-at
4058 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4059 (regexp-quote id))))
4060 (or found (beginning-of-line 2)))
4064 (setq header (gnus-nov-parse-line
4065 (read (current-buffer)) deps))
4066 (gnus-parent-id (mail-header-references header))))))
4068 (let ((number (mail-header-number header)))
4069 (push number gnus-newsgroup-limit)
4070 (push header gnus-newsgroup-headers)
4071 (if (memq number gnus-newsgroup-unselected)
4073 (setq gnus-newsgroup-unreads
4074 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4076 (setq gnus-newsgroup-unselected
4077 (delq number gnus-newsgroup-unselected)))
4078 (push number gnus-newsgroup-ancient)))))))
4080 (defun gnus-build-all-threads ()
4081 "Read all the headers."
4082 (let ((gnus-summary-ignore-duplicates t)
4083 (mail-parse-charset gnus-newsgroup-charset)
4084 (dependencies gnus-newsgroup-dependencies)
4087 (set-buffer nntp-server-buffer)
4088 (let ((case-fold-search nil))
4089 (goto-char (point-min))
4092 (setq article (read (current-buffer))
4093 header (gnus-nov-parse-line article dependencies)))
4096 (set-buffer gnus-summary-buffer)
4097 (push header gnus-newsgroup-headers)
4098 (if (memq (setq article (mail-header-number header))
4099 gnus-newsgroup-unselected)
4101 (setq gnus-newsgroup-unreads
4102 (gnus-add-to-sorted-list
4103 gnus-newsgroup-unreads article))
4104 (setq gnus-newsgroup-unselected
4105 (delq article gnus-newsgroup-unselected)))
4106 (push article gnus-newsgroup-ancient)))
4107 (forward-line 1)))))))
4109 (defun gnus-summary-update-article-line (article header)
4110 "Update the line for ARTICLE using HEADER."
4111 (let* ((id (mail-header-id header))
4112 (thread (gnus-id-to-thread id)))
4114 (error "Article in no thread"))
4115 ;; Update the thread.
4116 (setcar thread header)
4117 (gnus-summary-goto-subject article)
4118 (let* ((datal (gnus-data-find-list article))
4120 (buffer-read-only nil)
4121 (level (gnus-summary-thread-level)))
4123 (let ((inserted (- (point)
4125 (gnus-summary-insert-line
4127 (memq article gnus-newsgroup-undownloaded)
4128 (gnus-article-mark article)
4129 (memq article gnus-newsgroup-replied)
4130 (memq article gnus-newsgroup-expirable)
4131 ;; Only insert the Subject string when it's different
4132 ;; from the previous Subject string.
4137 (mail-header-subject
4140 (gnus-data-find-list
4142 (gnus-data-list t)))))
4143 ;; Error on the side of excessive subjects.
4145 (mail-header-subject header)))
4147 (mail-header-subject header))
4148 nil (cdr (assq article gnus-newsgroup-scored))
4149 (memq article gnus-newsgroup-processable))
4152 (gnus-data-update-list
4154 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4156 (defun gnus-summary-update-article (article &optional iheader)
4157 "Update ARTICLE in the summary buffer."
4158 (set-buffer gnus-summary-buffer)
4159 (let* ((header (gnus-summary-article-header article))
4160 (id (mail-header-id header))
4161 (data (gnus-data-find article))
4162 (thread (gnus-id-to-thread id))
4163 (references (mail-header-references header))
4167 (when (and references
4168 (not (equal "" references)))
4171 (buffer-read-only nil)
4177 (delq thread parent)))
4178 (if (gnus-summary-insert-subject id header)
4179 ;; Set the (possibly) new article number in the data structure.
4180 (gnus-data-set-number data (gnus-id-to-article id))
4184 (defun gnus-rebuild-thread (id &optional line)
4185 "Rebuild the thread containing ID.
4186 If LINE, insert the rebuilt thread starting on line LINE."
4187 (let ((buffer-read-only nil)
4188 old-pos current thread data)
4189 (if (not gnus-show-threads)
4190 (setq thread (list (car (gnus-id-to-thread id))))
4191 ;; Get the thread this article is part of.
4192 (setq thread (gnus-remove-thread id)))
4193 (setq old-pos (point-at-bol))
4194 (setq current (save-excursion
4195 (and (re-search-backward "[\r\n]" nil t)
4196 (gnus-summary-article-number))))
4197 ;; If this is a gathered thread, we have to go some re-gathering.
4198 (when (stringp (car thread))
4199 (let ((subject (car thread))
4201 (setq thread (cdr thread))
4203 (unless (memq (setq thr (gnus-id-to-thread
4205 (mail-header-id (caar thread)))))
4208 (setq thread (cdr thread)))
4209 ;; We now have all (unique) roots.
4210 (if (= (length roots) 1)
4211 ;; All the loose roots are now one solid root.
4212 (setq thread (car roots))
4213 (setq thread (cons subject (gnus-sort-threads roots))))))
4215 ;; We then insert this thread into the summary buffer.
4217 (goto-char (point-min))
4218 (forward-line (1- line)))
4219 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4220 (if gnus-show-threads
4221 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4222 (gnus-summary-prepare-unthreaded thread))
4223 (setq data (nreverse gnus-newsgroup-data))
4224 (setq threads gnus-newsgroup-threads))
4225 ;; We splice the new data into the data structure.
4226 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4227 ;;!!! then we want to insert at the beginning of the buffer.
4228 ;;!!! That happens to be true with Gnus now, but that may
4229 ;;!!! change in the future. Perhaps.
4230 (gnus-data-enter-list
4231 (if line nil current) data (- (point) old-pos))
4232 (setq gnus-newsgroup-threads
4233 (nconc threads gnus-newsgroup-threads))
4234 (gnus-data-compute-positions))))
4236 (defun gnus-number-to-header (number)
4237 "Return the header for article NUMBER."
4238 (let ((headers gnus-newsgroup-headers))
4240 (not (= number (mail-header-number (car headers)))))
4245 (defun gnus-parent-headers (in-headers &optional generation)
4246 "Return the headers of the GENERATIONeth parent of HEADERS."
4248 (setq generation 1))
4250 (headers in-headers)
4253 (not (zerop generation))
4254 (setq references (mail-header-references headers)))
4255 (setq headers (if (and references
4256 (setq parent (gnus-parent-id references)))
4257 (car (gnus-id-to-thread parent))
4260 (and (not (eq headers in-headers))
4263 (defun gnus-id-to-thread (id)
4264 "Return the (sub-)thread where ID appears."
4265 (gnus-gethash id gnus-newsgroup-dependencies))
4267 (defun gnus-id-to-article (id)
4268 "Return the article number of ID."
4269 (let ((thread (gnus-id-to-thread id)))
4272 (mail-header-number (car thread)))))
4274 (defun gnus-id-to-header (id)
4275 "Return the article headers of ID."
4276 (car (gnus-id-to-thread id)))
4278 (defun gnus-article-displayed-root-p (article)
4279 "Say whether ARTICLE is a root(ish) article."
4280 (let ((level (gnus-summary-thread-level article))
4281 (refs (mail-header-references (gnus-summary-article-header article)))
4287 ((null (gnus-parent-id refs)) t)
4289 (null (setq particle (gnus-id-to-article
4290 (gnus-parent-id refs))))
4291 (null (gnus-summary-thread-level particle)))))))
4293 (defun gnus-root-id (id)
4294 "Return the id of the root of the thread where ID appears."
4296 (while (and id (setq prev (car (gnus-id-to-thread id))))
4298 id (gnus-parent-id (mail-header-references prev))))
4301 (defun gnus-articles-in-thread (thread)
4302 "Return the list of articles in THREAD."
4303 (cons (mail-header-number (car thread))
4304 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4306 (defun gnus-remove-thread (id &optional dont-remove)
4307 "Remove the thread that has ID in it."
4308 (let (headers thread last-id)
4309 ;; First go up in this thread until we find the root.
4310 (setq last-id (gnus-root-id id)
4311 headers (message-flatten-list (gnus-id-to-thread last-id)))
4312 ;; We have now found the real root of this thread. It might have
4313 ;; been gathered into some loose thread, so we have to search
4314 ;; through the threads to find the thread we wanted.
4315 (let ((threads gnus-newsgroup-threads)
4318 (setq sub (car threads))
4319 (if (stringp (car sub))
4320 ;; This is a gathered thread, so we look at the roots
4321 ;; below it to find whether this article is in this
4324 (setq sub (cdr sub))
4326 (when (member (caar sub) headers)
4327 (setq thread (car threads)
4330 (setq sub (cdr sub))))
4331 ;; It's an ordinary thread, so we check it.
4332 (when (eq (car sub) (car headers))
4335 (setq threads (cdr threads)))
4336 ;; If this article is in no thread, then it's a root.
4339 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4340 (setq thread (gnus-id-to-thread last-id)))
4343 thread ; We return this thread.
4345 (if (stringp (car thread))
4347 ;; If we use dummy roots, then we have to remove the
4348 ;; dummy root as well.
4349 (when (eq gnus-summary-make-false-root 'dummy)
4350 ;; We go to the dummy root by going to
4351 ;; the first sub-"thread", and then one line up.
4352 (gnus-summary-goto-article
4353 (mail-header-number (caadr thread)))
4356 (gnus-data-compute-positions))
4357 (setq thread (cdr thread))
4359 (gnus-remove-thread-1 (car thread))
4360 (setq thread (cdr thread))))
4361 (gnus-remove-thread-1 thread))))))))
4363 (defun gnus-remove-thread-1 (thread)
4364 "Remove the thread THREAD recursively."
4365 (let ((number (mail-header-number (pop thread)))
4367 (setq thread (reverse thread))
4369 (gnus-remove-thread-1 (pop thread)))
4370 (when (setq d (gnus-data-find number))
4371 (goto-char (gnus-data-pos d))
4372 (gnus-summary-show-thread)
4378 (gnus-delete-line)))))))
4380 (defun gnus-sort-threads-1 (threads func)
4381 (sort (mapcar (lambda (thread)
4384 (gnus-sort-threads-1 (cdr thread) func))))
4387 (defun gnus-sort-threads (threads)
4389 (if (not gnus-thread-sort-functions)
4391 (gnus-message 8 "Sorting threads...")
4392 (let ((max-lisp-eval-depth 5000))
4393 (prog1 (gnus-sort-threads-1
4395 (gnus-make-sort-function gnus-thread-sort-functions))
4396 (gnus-message 8 "Sorting threads...done")))))
4398 (defun gnus-sort-articles (articles)
4400 (when gnus-article-sort-functions
4401 (gnus-message 7 "Sorting articles...")
4403 (setq gnus-newsgroup-headers
4404 (sort articles (gnus-make-sort-function
4405 gnus-article-sort-functions)))
4406 (gnus-message 7 "Sorting articles...done"))))
4408 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4409 (defmacro gnus-thread-header (thread)
4410 "Return header of first article in THREAD.
4411 Note that THREAD must never, ever be anything else than a variable -
4412 using some other form will lead to serious barfage."
4413 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4414 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4415 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4418 (defsubst gnus-article-sort-by-number (h1 h2)
4419 "Sort articles by article number."
4420 (< (mail-header-number h1)
4421 (mail-header-number h2)))
4423 (defun gnus-thread-sort-by-number (h1 h2)
4424 "Sort threads by root article number."
4425 (gnus-article-sort-by-number
4426 (gnus-thread-header h1) (gnus-thread-header h2)))
4428 (defsubst gnus-article-sort-by-random (h1 h2)
4429 "Sort articles by article number."
4432 (defun gnus-thread-sort-by-random (h1 h2)
4433 "Sort threads by root article number."
4434 (gnus-article-sort-by-random
4435 (gnus-thread-header h1) (gnus-thread-header h2)))
4437 (defsubst gnus-article-sort-by-lines (h1 h2)
4438 "Sort articles by article Lines header."
4439 (< (mail-header-lines h1)
4440 (mail-header-lines h2)))
4442 (defun gnus-thread-sort-by-lines (h1 h2)
4443 "Sort threads by root article Lines header."
4444 (gnus-article-sort-by-lines
4445 (gnus-thread-header h1) (gnus-thread-header h2)))
4447 (defsubst gnus-article-sort-by-chars (h1 h2)
4448 "Sort articles by octet length."
4449 (< (mail-header-chars h1)
4450 (mail-header-chars h2)))
4452 (defun gnus-thread-sort-by-chars (h1 h2)
4453 "Sort threads by root article octet length."
4454 (gnus-article-sort-by-chars
4455 (gnus-thread-header h1) (gnus-thread-header h2)))
4457 (defsubst gnus-article-sort-by-author (h1 h2)
4458 "Sort articles by root author."
4460 (let ((addr (car (mime-entity-read-field h1 'From))))
4461 (or (std11-full-name-string addr)
4462 (std11-address-string addr)
4464 (let ((addr (car (mime-entity-read-field h2 'From))))
4465 (or (std11-full-name-string addr)
4466 (std11-address-string addr)
4470 (defun gnus-thread-sort-by-author (h1 h2)
4471 "Sort threads by root author."
4472 (gnus-article-sort-by-author
4473 (gnus-thread-header h1) (gnus-thread-header h2)))
4475 (defsubst gnus-article-sort-by-subject (h1 h2)
4476 "Sort articles by root subject."
4478 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4479 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4481 (defun gnus-thread-sort-by-subject (h1 h2)
4482 "Sort threads by root subject."
4483 (gnus-article-sort-by-subject
4484 (gnus-thread-header h1) (gnus-thread-header h2)))
4486 (defsubst gnus-article-sort-by-date (h1 h2)
4487 "Sort articles by root article date."
4489 (gnus-date-get-time (mail-header-date h1))
4490 (gnus-date-get-time (mail-header-date h2))))
4492 (defun gnus-thread-sort-by-date (h1 h2)
4493 "Sort threads by root article date."
4494 (gnus-article-sort-by-date
4495 (gnus-thread-header h1) (gnus-thread-header h2)))
4497 (defsubst gnus-article-sort-by-score (h1 h2)
4498 "Sort articles by root article score.
4499 Unscored articles will be counted as having a score of zero."
4500 (> (or (cdr (assq (mail-header-number h1)
4501 gnus-newsgroup-scored))
4502 gnus-summary-default-score 0)
4503 (or (cdr (assq (mail-header-number h2)
4504 gnus-newsgroup-scored))
4505 gnus-summary-default-score 0)))
4507 (defun gnus-thread-sort-by-score (h1 h2)
4508 "Sort threads by root article score."
4509 (gnus-article-sort-by-score
4510 (gnus-thread-header h1) (gnus-thread-header h2)))
4512 (defun gnus-thread-sort-by-total-score (h1 h2)
4513 "Sort threads by the sum of all scores in the thread.
4514 Unscored articles will be counted as having a score of zero."
4515 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4517 (defun gnus-thread-total-score (thread)
4518 ;; This function find the total score of THREAD.
4523 (if (stringp (car thread))
4524 (apply gnus-thread-score-function 0
4525 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4526 (gnus-thread-total-score-1 thread)))
4528 (gnus-thread-total-score-1 (list thread)))))
4530 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4531 "Sort threads such that the thread with the most recently arrived article comes first."
4532 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4534 (defun gnus-thread-highest-number (thread)
4535 "Return the highest article number in THREAD."
4536 (apply 'max (mapcar (lambda (header)
4537 (mail-header-number header))
4538 (message-flatten-list thread))))
4540 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4541 "Sort threads such that the thread with the most recently dated article comes first."
4542 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4544 (defun gnus-thread-latest-date (thread)
4545 "Return the highest article date in THREAD."
4546 (let ((previous-time 0))
4552 (time-to-seconds (mail-header-parse-date
4553 (mail-header-date header)))
4554 (error previous-time))))
4556 (message-flatten-list thread)
4558 (< (mail-header-number h1)
4559 (mail-header-number h2))))))))
4561 (defun gnus-thread-total-score-1 (root)
4562 ;; This function find the total score of the thread below ROOT.
4563 (setq root (car root))
4564 (apply gnus-thread-score-function
4566 (mapcar 'gnus-thread-total-score
4567 (cdr (gnus-id-to-thread (mail-header-id root))))
4568 (when (> (mail-header-number root) 0)
4569 (list (or (cdr (assq (mail-header-number root)
4570 gnus-newsgroup-scored))
4571 gnus-summary-default-score 0))))
4572 (list gnus-summary-default-score)
4575 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4576 (defvar gnus-tmp-prev-subject nil)
4577 (defvar gnus-tmp-false-parent nil)
4578 (defvar gnus-tmp-root-expunged nil)
4579 (defvar gnus-tmp-dummy-line nil)
4581 (eval-when-compile (defvar gnus-tmp-header))
4582 (defun gnus-extra-header (type &optional header)
4583 "Return the extra header of TYPE."
4584 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4587 (defvar gnus-tmp-thread-tree-header-string "")
4589 (defcustom gnus-sum-thread-tree-root "> "
4590 "With %B spec, used for the root of a thread.
4591 If nil, use subject instead."
4592 :type '(radio (const :format "%v " nil) (string :size 0))
4593 :group 'gnus-thread)
4594 (defcustom gnus-sum-thread-tree-false-root "> "
4595 "With %B spec, used for a false root of a thread.
4596 If nil, use subject instead."
4597 :type '(radio (const :format "%v " nil) (string :size 0))
4598 :group 'gnus-thread)
4599 (defcustom gnus-sum-thread-tree-single-indent ""
4600 "With %B spec, used for a thread with just one message.
4601 If nil, use subject instead."
4602 :type '(radio (const :format "%v " nil) (string :size 0))
4603 :group 'gnus-thread)
4604 (defcustom gnus-sum-thread-tree-vertical "| "
4605 "With %B spec, used for drawing a vertical line."
4607 :group 'gnus-thread)
4608 (defcustom gnus-sum-thread-tree-indent " "
4609 "With %B spec, used for indenting."
4611 :group 'gnus-thread)
4612 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4613 "With %B spec, used for a leaf with brothers."
4615 :group 'gnus-thread)
4616 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4617 "With %B spec, used for a leaf without brothers."
4619 :group 'gnus-thread)
4621 (defun gnus-summary-prepare-threads (threads)
4622 "Prepare summary buffer from THREADS and indentation LEVEL.
4623 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4624 or a straight list of headers."
4625 (gnus-message 7 "Generating summary...")
4627 (setq gnus-newsgroup-threads threads)
4630 (let ((gnus-tmp-level 0)
4631 (default-score (or gnus-summary-default-score 0))
4632 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4633 (building-line-count gnus-summary-display-while-building)
4634 (building-count (integerp gnus-summary-display-while-building))
4635 thread number subject stack state gnus-tmp-gathered beg-match
4636 new-roots gnus-tmp-new-adopts thread-end simp-subject
4637 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4638 gnus-tmp-replied gnus-tmp-subject-or-nil
4639 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4640 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4641 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4644 (setq gnus-tmp-prev-subject nil
4645 gnus-tmp-thread-tree-header-string "")
4647 (if (vectorp (car threads))
4648 ;; If this is a straight (sic) list of headers, then a
4649 ;; threaded summary display isn't required, so we just create
4650 ;; an unthreaded one.
4651 (gnus-summary-prepare-unthreaded threads)
4653 ;; Do the threaded display.
4655 (if gnus-summary-display-while-building
4656 (switch-to-buffer (buffer-name)))
4657 (while (or threads stack gnus-tmp-new-adopts new-roots)
4659 (if (and (= gnus-tmp-level 0)
4662 (not gnus-tmp-false-parent)
4663 (or gnus-tmp-new-adopts new-roots))
4664 (if gnus-tmp-new-adopts
4665 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4666 thread (list (car gnus-tmp-new-adopts))
4667 gnus-tmp-header (caar thread)
4668 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4670 (setq thread (list (car new-roots))
4671 gnus-tmp-header (caar thread)
4672 new-roots (cdr new-roots))))
4675 ;; If there are some threads, we do them before the
4676 ;; threads on the stack.
4677 (setq thread threads
4678 gnus-tmp-header (caar thread))
4679 ;; There were no current threads, so we pop something off
4681 (setq state (car stack)
4682 gnus-tmp-level (car state)
4683 tree-stack (cadr state)
4684 thread (caddr state)
4686 gnus-tmp-header (caar thread))))
4688 (setq gnus-tmp-false-parent nil)
4689 (setq gnus-tmp-root-expunged nil)
4690 (setq thread-end nil)
4692 (if (stringp gnus-tmp-header)
4693 ;; The header is a dummy root.
4695 ((eq gnus-summary-make-false-root 'adopt)
4696 ;; We let the first article adopt the rest.
4697 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4699 (setq gnus-tmp-gathered
4701 (lambda (h) (mail-header-number (car h)))
4704 (setq thread (cons (list (caar thread)
4707 (setq gnus-tmp-level -1
4708 gnus-tmp-false-parent t))
4709 ((eq gnus-summary-make-false-root 'empty)
4710 ;; We print adopted articles with empty subject fields.
4711 (setq gnus-tmp-gathered
4713 (lambda (h) (mail-header-number (car h)))
4716 (setq gnus-tmp-level -1))
4717 ((eq gnus-summary-make-false-root 'dummy)
4718 ;; We remember that we probably want to output a dummy
4720 (setq gnus-tmp-dummy-line gnus-tmp-header)
4721 (setq gnus-tmp-prev-subject gnus-tmp-header))
4723 ;; We do not make a root for the gathered
4724 ;; sub-threads at all.
4725 (setq gnus-tmp-level -1)))
4727 (setq number (mail-header-number gnus-tmp-header)
4728 subject (mail-header-subject gnus-tmp-header)
4729 simp-subject (gnus-simplify-subject-fully subject))
4732 ;; If the thread has changed subject, we might want to make
4733 ;; this subthread into a root.
4734 ((and (null gnus-thread-ignore-subject)
4735 (not (zerop gnus-tmp-level))
4736 gnus-tmp-prev-subject
4737 (not (string= gnus-tmp-prev-subject simp-subject)))
4738 (setq new-roots (nconc new-roots (list (car thread)))
4740 gnus-tmp-header nil))
4741 ;; If the article lies outside the current limit,
4742 ;; then we do not display it.
4743 ((not (memq number gnus-newsgroup-limit))
4744 (setq gnus-tmp-gathered
4746 (lambda (h) (mail-header-number (car h)))
4749 (setq gnus-tmp-new-adopts (if (cdar thread)
4750 (append gnus-tmp-new-adopts
4752 gnus-tmp-new-adopts)
4754 gnus-tmp-header nil)
4755 (when (zerop gnus-tmp-level)
4756 (setq gnus-tmp-root-expunged t)))
4757 ;; Perhaps this article is to be marked as read?
4758 ((and gnus-summary-mark-below
4759 (< (or (cdr (assq number gnus-newsgroup-scored))
4761 gnus-summary-mark-below)
4762 ;; Don't touch sparse articles.
4763 (not (gnus-summary-article-sparse-p number))
4764 (not (gnus-summary-article-ancient-p number)))
4765 (setq gnus-newsgroup-unreads
4766 (delq number gnus-newsgroup-unreads))
4767 (if gnus-newsgroup-auto-expire
4768 (setq gnus-newsgroup-expirable
4769 (gnus-add-to-sorted-list
4770 gnus-newsgroup-expirable number))
4771 (push (cons number gnus-low-score-mark)
4772 gnus-newsgroup-reads))))
4774 (when gnus-tmp-header
4775 ;; We may have an old dummy line to output before this
4777 (when (and gnus-tmp-dummy-line
4780 (mail-header-subject gnus-tmp-header)))
4781 (gnus-summary-insert-dummy-line
4782 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4783 (setq gnus-tmp-dummy-line nil))
4785 ;; Compute the mark.
4786 (setq gnus-tmp-unread (gnus-article-mark number))
4788 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4789 gnus-tmp-header gnus-tmp-level)
4790 gnus-newsgroup-data)
4792 ;; Actually insert the line.
4794 gnus-tmp-subject-or-nil
4796 ((and gnus-thread-ignore-subject
4797 gnus-tmp-prev-subject
4798 (not (string= gnus-tmp-prev-subject simp-subject)))
4800 ((zerop gnus-tmp-level)
4801 (if (and (eq gnus-summary-make-false-root 'empty)
4802 (memq number gnus-tmp-gathered)
4803 gnus-tmp-prev-subject
4804 (string= gnus-tmp-prev-subject simp-subject))
4805 gnus-summary-same-subject
4807 (t gnus-summary-same-subject)))
4808 (if (and (eq gnus-summary-make-false-root 'adopt)
4809 (= gnus-tmp-level 1)
4810 (memq number gnus-tmp-gathered))
4811 (setq gnus-tmp-opening-bracket ?\<
4812 gnus-tmp-closing-bracket ?\>)
4813 (setq gnus-tmp-opening-bracket ?\[
4814 gnus-tmp-closing-bracket ?\]))
4816 gnus-tmp-indentation
4817 (aref gnus-thread-indent-array gnus-tmp-level)
4818 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4819 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4820 gnus-summary-default-score 0)
4822 (if (or (null gnus-summary-default-score)
4823 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4824 gnus-summary-zcore-fuzz))
4826 (if (< gnus-tmp-score gnus-summary-default-score)
4827 gnus-score-below-mark gnus-score-over-mark))
4829 (cond ((memq number gnus-newsgroup-processable)
4831 ((memq number gnus-newsgroup-cached)
4833 ((memq number gnus-newsgroup-replied)
4835 ((memq number gnus-newsgroup-forwarded)
4836 gnus-forwarded-mark)
4837 ((memq number gnus-newsgroup-saved)
4839 ((memq number gnus-newsgroup-recent)
4841 ((memq number gnus-newsgroup-unseen)
4845 (cond ((memq number gnus-newsgroup-undownloaded)
4846 gnus-undownloaded-mark)
4847 (gnus-newsgroup-agentized
4848 gnus-downloaded-mark)
4851 gnus-tmp-from (mail-header-from gnus-tmp-header)
4854 ((string-match "<[^>]+> *$" gnus-tmp-from)
4855 (setq beg-match (match-beginning 0))
4856 (or (and (string-match "^\".+\"" gnus-tmp-from)
4857 (substring gnus-tmp-from 1 (1- (match-end 0))))
4858 (substring gnus-tmp-from 0 beg-match)))
4859 ((string-match "(.+)" gnus-tmp-from)
4860 (substring gnus-tmp-from
4861 (1+ (match-beginning 0)) (1- (match-end 0))))
4865 gnus-tmp-thread-tree-header-string
4867 ((not gnus-show-threads) "")
4868 ((zerop gnus-tmp-level)
4869 (cond ((cdar thread)
4870 (or gnus-sum-thread-tree-root subject))
4871 (gnus-tmp-new-adopts
4872 (or gnus-sum-thread-tree-false-root subject))
4874 (or gnus-sum-thread-tree-single-indent subject))))
4876 (concat (apply 'concat
4877 (mapcar (lambda (item)
4879 gnus-sum-thread-tree-vertical
4880 gnus-sum-thread-tree-indent))
4881 (cdr (reverse tree-stack))))
4883 gnus-sum-thread-tree-leaf-with-other
4884 gnus-sum-thread-tree-single-leaf)))))
4885 (when (string= gnus-tmp-name "")
4886 (setq gnus-tmp-name gnus-tmp-from))
4887 (unless (numberp gnus-tmp-lines)
4888 (setq gnus-tmp-lines -1))
4889 (if (= gnus-tmp-lines -1)
4890 (setq gnus-tmp-lines "?")
4891 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4892 (gnus-put-text-property
4894 (progn (eval gnus-summary-line-format-spec) (point))
4895 'gnus-number number)
4898 (gnus-run-hooks 'gnus-summary-update-hook)
4901 (setq gnus-tmp-prev-subject simp-subject)))
4903 (when (nth 1 thread)
4904 (push (list (max 0 gnus-tmp-level)
4905 (copy-sequence tree-stack)
4908 (push (if (nth 1 thread) 1 0) tree-stack)
4909 (incf gnus-tmp-level)
4910 (setq threads (if thread-end nil (cdar thread)))
4911 (if gnus-summary-display-while-building
4914 ;; use a set frequency
4915 (setq building-line-count (1- building-line-count))
4916 (when (= building-line-count 0)
4918 (setq building-line-count
4919 gnus-summary-display-while-building)))
4923 (setq gnus-tmp-level 0)))))
4924 (gnus-message 7 "Generating summary...done"))
4926 (defun gnus-summary-prepare-unthreaded (headers)
4927 "Generate an unthreaded summary buffer based on HEADERS."
4928 (let (header number mark)
4933 ;; We may have to root out some bad articles...
4934 (when (memq (setq number (mail-header-number
4935 (setq header (pop headers))))
4936 gnus-newsgroup-limit)
4937 ;; Mark article as read when it has a low score.
4938 (when (and gnus-summary-mark-below
4939 (< (or (cdr (assq number gnus-newsgroup-scored))
4940 gnus-summary-default-score 0)
4941 gnus-summary-mark-below)
4942 (not (gnus-summary-article-ancient-p number)))
4943 (setq gnus-newsgroup-unreads
4944 (delq number gnus-newsgroup-unreads))
4945 (if gnus-newsgroup-auto-expire
4946 (push number gnus-newsgroup-expirable)
4947 (push (cons number gnus-low-score-mark)
4948 gnus-newsgroup-reads)))
4950 (setq mark (gnus-article-mark number))
4951 (push (gnus-data-make number mark (1+ (point)) header 0)
4952 gnus-newsgroup-data)
4953 (gnus-summary-insert-line
4955 (memq number gnus-newsgroup-undownloaded)
4956 mark (memq number gnus-newsgroup-replied)
4957 (memq number gnus-newsgroup-expirable)
4958 (mail-header-subject header) nil
4959 (cdr (assq number gnus-newsgroup-scored))
4960 (memq number gnus-newsgroup-processable))))))
4962 (defun gnus-summary-remove-list-identifiers ()
4963 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4964 (let ((regexp (if (consp gnus-list-identifiers)
4965 (mapconcat 'identity gnus-list-identifiers " *\\|")
4966 gnus-list-identifiers))
4969 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
4970 (dolist (header gnus-newsgroup-headers)
4971 (setq subject (mail-header-subject header)
4973 (while (string-match regexp subject)
4975 (concat (substring subject 0 (match-beginning 1))
4976 (substring subject (match-end 0)))
4979 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
4981 (concat (substring subject 0 (match-beginning 1))
4982 (substring subject (match-end 1)))))
4983 (mail-header-set-subject header subject))))))
4985 (defun gnus-fetch-headers (articles)
4986 "Fetch headers of ARTICLES."
4987 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4988 (gnus-message 5 "Fetching headers for %s..." name)
4991 (setq gnus-headers-retrieved-by
4992 (gnus-retrieve-headers
4993 articles gnus-newsgroup-name
4994 ;; We might want to fetch old headers, but
4995 ;; not if there is only 1 article.
4997 (not (eq gnus-fetch-old-headers 'some))
4998 (not (numberp gnus-fetch-old-headers)))
4999 (> (length articles) 1))
5000 gnus-fetch-old-headers))))
5001 (gnus-get-newsgroup-headers-xover
5002 articles nil nil gnus-newsgroup-name t)
5003 (gnus-get-newsgroup-headers))
5004 (gnus-message 5 "Fetching headers for %s...done" name))))
5006 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5007 "Select newsgroup GROUP.
5008 If READ-ALL is non-nil, all articles in the group are selected.
5009 If SELECT-ARTICLES, only select those articles from GROUP."
5010 (let* ((entry (gnus-group-entry group))
5011 ;;!!! Dirty hack; should be removed.
5012 (gnus-summary-ignore-duplicates
5013 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5015 gnus-summary-ignore-duplicates))
5016 (info (nth 2 entry))
5017 articles fetched-articles cached)
5019 (unless (gnus-check-server
5020 (set (make-local-variable 'gnus-current-select-method)
5021 (gnus-find-method-for-group group)))
5022 (error "Couldn't open server"))
5024 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5025 (gnus-activate-group group) ; Or we can activate it...
5026 (progn ; Or we bug out.
5027 (when (equal major-mode 'gnus-summary-mode)
5028 (gnus-kill-buffer (current-buffer)))
5029 (error "Couldn't activate group %s: %s"
5030 group (gnus-status-message group))))
5032 (unless (gnus-request-group group t)
5033 (when (equal major-mode 'gnus-summary-mode)
5034 (gnus-kill-buffer (current-buffer)))
5035 (error "Couldn't request group %s: %s"
5036 group (gnus-status-message group)))
5039 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5041 (setq gnus-summary-use-undownloaded-faces
5042 (gnus-agent-find-parameter
5044 'agent-enable-undownloaded-faces)))
5046 (setq gnus-newsgroup-name group
5047 gnus-newsgroup-unselected nil
5048 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5050 (let ((display (gnus-group-find-parameter group 'display)))
5051 (setq gnus-newsgroup-display
5053 ((not (zerop (or (car-safe read-all) 0)))
5054 ;; The user entered the group with C-u SPC/RET, let's show
5060 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5062 ;; The following is probably the "correct" solution, but
5063 ;; it makes Gnus fetch all headers and then limit the
5064 ;; articles (which is slow), so instead we hack the
5065 ;; select-articles parameter instead. -- Simon Josefsson
5068 ;; (gnus-byte-compile
5069 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5071 (setq select-articles
5072 (gnus-uncompress-range
5073 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5077 (cdr (gnus-active group)))))
5082 (gnus-summary-setup-default-charset)
5084 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5085 (when (gnus-virtual-group-p group)
5086 (setq cached gnus-newsgroup-cached))
5088 (setq gnus-newsgroup-unreads
5089 (gnus-sorted-ndifference
5090 (gnus-sorted-ndifference gnus-newsgroup-unreads
5091 gnus-newsgroup-marked)
5092 gnus-newsgroup-dormant))
5094 (setq gnus-newsgroup-processable nil)
5096 (gnus-update-read-articles group gnus-newsgroup-unreads)
5098 ;; Adjust and set lists of article marks.
5100 (gnus-adjust-marked-articles info))
5101 (if (setq articles select-articles)
5102 (setq gnus-newsgroup-unselected
5103 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5104 (setq articles (gnus-articles-to-read group read-all)))
5108 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5110 ((eq articles 0) nil)
5112 ;; Init the dependencies hash table.
5113 (setq gnus-newsgroup-dependencies
5114 (gnus-make-hashtable (length articles)))
5115 (gnus-set-global-variables)
5116 ;; Retrieve the headers and read them in.
5118 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5120 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5122 (setq gnus-newsgroup-cached cached))
5124 ;; Suppress duplicates?
5125 (when gnus-suppress-duplicates
5126 (gnus-dup-suppress-articles))
5128 ;; Set the initial limit.
5129 (setq gnus-newsgroup-limit (copy-sequence articles))
5130 ;; Remove canceled articles from the list of unread articles.
5131 (setq fetched-articles
5132 (mapcar (lambda (headers) (mail-header-number headers))
5133 gnus-newsgroup-headers))
5134 (setq gnus-newsgroup-articles fetched-articles)
5135 (setq gnus-newsgroup-unreads
5136 (gnus-sorted-nintersection
5137 gnus-newsgroup-unreads fetched-articles))
5138 (gnus-compute-unseen-list)
5140 ;; Removed marked articles that do not exist.
5141 (gnus-update-missing-marks
5142 (gnus-sorted-difference articles fetched-articles))
5143 ;; We might want to build some more threads first.
5144 (when (and gnus-fetch-old-headers
5145 (eq gnus-headers-retrieved-by 'nov))
5146 (if (eq gnus-fetch-old-headers 'invisible)
5147 (gnus-build-all-threads)
5148 (gnus-build-old-threads)))
5149 ;; Let the Gnus agent mark articles as read.
5151 (gnus-agent-get-undownloaded-list))
5152 ;; Remove list identifiers from subject
5153 (when gnus-list-identifiers
5154 (gnus-summary-remove-list-identifiers))
5155 ;; Check whether auto-expire is to be done in this group.
5156 (setq gnus-newsgroup-auto-expire
5157 (gnus-group-auto-expirable-p group))
5158 ;; Set up the article buffer now, if necessary.
5159 (unless gnus-single-article-buffer
5160 (gnus-article-setup-buffer))
5161 ;; First and last article in this newsgroup.
5162 (when gnus-newsgroup-headers
5163 (setq gnus-newsgroup-begin
5164 (mail-header-number (car gnus-newsgroup-headers))
5167 (gnus-last-element gnus-newsgroup-headers))))
5168 ;; GROUP is successfully selected.
5169 (or gnus-newsgroup-headers t)))))
5171 (defun gnus-compute-unseen-list ()
5172 ;; The `seen' marks are treated specially.
5173 (if (not gnus-newsgroup-seen)
5174 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5175 (setq gnus-newsgroup-unseen
5176 (gnus-inverse-list-range-intersection
5177 gnus-newsgroup-articles gnus-newsgroup-seen))))
5179 (defun gnus-summary-display-make-predicate (display)
5180 (require 'gnus-agent)
5181 (when (= (length display) 1)
5182 (setq display (car display)))
5183 (unless gnus-summary-display-cache
5184 (dolist (elem (append '((unread . unread)
5187 gnus-article-mark-lists))
5188 (push (cons (cdr elem)
5190 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5191 gnus-summary-display-cache)))
5192 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5193 (gnus-category-predicate-cache gnus-summary-display-cache))
5194 (gnus-get-predicate display)))
5196 ;; Uses the dynamically bound `number' variable.
5199 (defun gnus-article-marked-p (type &optional article)
5200 (let ((article (or article number)))
5203 (memq article gnus-newsgroup-marked))
5205 (memq article gnus-newsgroup-spam-marked))
5207 (memq article gnus-newsgroup-unsendable))
5208 ((eq type 'undownload)
5209 (memq article gnus-newsgroup-undownloaded))
5210 ((eq type 'download)
5211 (memq article gnus-newsgroup-downloadable))
5213 (memq article gnus-newsgroup-unreads))
5215 (memq article gnus-newsgroup-reads))
5217 (memq article gnus-newsgroup-dormant) )
5219 (memq article gnus-newsgroup-expirable))
5221 (memq article gnus-newsgroup-replied))
5223 (memq article gnus-newsgroup-killed))
5224 ((eq type 'bookmark)
5225 (assq article gnus-newsgroup-bookmarks))
5227 (assq article gnus-newsgroup-scored))
5229 (memq article gnus-newsgroup-saved))
5231 (memq article gnus-newsgroup-cached))
5233 (memq article gnus-newsgroup-forwarded))
5235 (not (memq article gnus-newsgroup-unseen)))
5237 (memq article gnus-newsgroup-recent))
5240 (defun gnus-articles-to-read (group &optional read-all)
5241 "Find out what articles the user wants to read."
5242 (let* ((display (gnus-group-find-parameter group 'display))
5244 ;; Select all articles if `read-all' is non-nil, or if there
5245 ;; are no unread articles.
5247 (and (zerop (length gnus-newsgroup-marked))
5248 (zerop (length gnus-newsgroup-unreads)))
5249 ;; Fetch all if the predicate is non-nil.
5250 gnus-newsgroup-display)
5251 ;; We want to select the headers for all the articles in
5252 ;; the group, so we select either all the active
5253 ;; articles in the group, or (if that's nil), the
5254 ;; articles in the cache.
5256 (gnus-uncompress-range (gnus-active group))
5257 (gnus-cache-articles-in-group group))
5258 ;; Select only the "normal" subset of articles.
5260 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5261 gnus-newsgroup-unreads)))
5262 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5263 (scored (length scored-list))
5264 (number (length articles))
5265 (marked (+ (length gnus-newsgroup-marked)
5266 (length gnus-newsgroup-dormant)))
5271 ((numberp gnus-newsgroup-display)
5272 gnus-newsgroup-display)
5276 ((and (or (<= scored marked) (= scored number))
5277 (numberp gnus-large-newsgroup)
5278 (> number gnus-large-newsgroup))
5279 (let* ((cursor-in-echo-area nil)
5280 (initial (gnus-parameter-large-newsgroup-initial
5281 gnus-newsgroup-name))
5285 "How many articles from %s (%s %d): "
5287 (gnus-group-decoded-name gnus-newsgroup-name)
5289 (if initial "max" "default")
5292 (cons (number-to-string initial)
5294 (if (string-match "^[ \t]*$" input) number input)))
5295 ((and (> scored marked) (< scored number)
5296 (> (- scored number) 20))
5299 (format "%s %s (%d scored, %d total): "
5300 "How many articles from"
5301 (gnus-group-decoded-name group)
5303 (if (string-match "^[ \t]*$" input)
5307 (message "Quit getting the articles to read")
5309 (setq select (if (stringp select) (string-to-number select) select))
5310 (if (or (null select) (zerop select))
5312 (if (and (not (zerop scored)) (<= (abs select) scored))
5314 (setq articles (sort scored-list '<))
5315 (setq number (length articles)))
5316 (setq articles (copy-sequence articles)))
5318 (when (< (abs select) number)
5320 ;; Select the N oldest articles.
5321 (setcdr (nthcdr (1- (abs select)) articles) nil)
5322 ;; Select the N most recent articles.
5323 (setq articles (nthcdr (- number select) articles))))
5324 (setq gnus-newsgroup-unselected
5325 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5326 (when gnus-alter-articles-to-read-function
5329 (funcall gnus-alter-articles-to-read-function
5330 gnus-newsgroup-name articles)
5334 (defun gnus-killed-articles (killed articles)
5337 (when (inline (gnus-member-of-range (car articles) killed))
5338 (push (car articles) out))
5339 (setq articles (cdr articles)))
5342 (defun gnus-uncompress-marks (marks)
5343 "Uncompress the mark ranges in MARKS."
5344 (let ((uncompressed '(score bookmark))
5347 (if (memq (caar marks) uncompressed)
5348 (push (car marks) out)
5349 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5350 (setq marks (cdr marks)))
5353 (defun gnus-article-mark-to-type (mark)
5354 "Return the type of MARK."
5355 (or (cadr (assq mark gnus-article-special-mark-lists))
5358 (defun gnus-article-unpropagatable-p (mark)
5359 "Return whether MARK should be propagated to back end."
5360 (memq mark gnus-article-unpropagated-mark-lists))
5362 (defun gnus-adjust-marked-articles (info)
5363 "Set all article lists and remove all marks that are no longer valid."
5364 (let* ((marked-lists (gnus-info-marks info))
5365 (active (gnus-active (gnus-info-group info)))
5368 (types gnus-article-mark-lists)
5369 marks var articles article mark mark-type
5372 (dolist (marks marked-lists)
5373 (setq mark (car marks)
5374 mark-type (gnus-article-mark-to-type mark)
5375 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5377 ;; We set the variable according to the type of the marks list,
5378 ;; and then adjust the marks to a subset of the active articles.
5380 ;; Adjust "simple" lists - compressed yet unsorted
5381 ((eq mark-type 'list)
5382 ;; Simultaneously uncompress and clip to active range
5383 ;; See gnus-uncompress-range for a description of possible marks
5385 (if (not (cadr marks))
5387 (setq articles (if (numberp (cddr marks))
5393 (while (setq article (pop articles))
5394 (cond ((consp article)
5395 (setq bgn (max (car article) min)
5396 end (min (cdr article) max))
5398 (setq l (setcdr l (cons bgn nil))
5400 ((and (<= min article)
5402 (setq l (setcdr l (cons article nil))))))
5403 (set var (cdr lh)))))
5405 ((eq mark-type 'tuple)
5406 (set var (setq articles (cdr marks)))
5407 (when (not (listp (cdr (symbol-value var))))
5408 (set var (list (symbol-value var))))
5409 (when (not (listp (cdr articles)))
5410 (setq articles (list articles)))
5412 (when (or (not (consp (setq article (pop articles))))
5413 (< (car article) min)
5414 (> (car article) max))
5415 (set var (delq article (symbol-value var))))))
5416 ;; Adjust ranges (sloppily).
5417 ((eq mark-type 'range)
5420 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5421 ;; It should be (seen (NUM1 . NUM2)).
5422 (when (numberp (cddr marks))
5423 (setcdr marks (list (cdr marks))))
5424 (setq articles (cdr marks))
5425 (while (and articles
5426 (or (and (consp (car articles))
5427 (> min (cdar articles)))
5428 (and (numberp (car articles))
5429 (> min (car articles)))))
5431 (set var articles))))))))
5433 (defun gnus-update-missing-marks (missing)
5434 "Go through the list of MISSING articles and remove them from the mark lists."
5437 ;; Go through all types.
5438 (dolist (elem gnus-article-mark-lists)
5439 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5440 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5441 (when (symbol-value var)
5442 ;; This list has articles. So we delete all missing
5443 ;; articles from it.
5446 (set var (delq (pop m) (symbol-value var))))))))))
5448 (defun gnus-update-marks ()
5449 "Enter the various lists of marked articles into the newsgroup info list."
5450 (let ((types gnus-article-mark-lists)
5451 (info (gnus-get-info gnus-newsgroup-name))
5452 type list newmarked symbol delta-marks)
5454 ;; Add all marks lists to the list of marks lists.
5455 (while (setq type (pop types))
5456 (setq list (symbol-value
5458 (intern (format "gnus-newsgroup-%s" (car type))))))
5461 ;; Get rid of the entries of the articles that have the
5463 (when (and (eq (cdr type) 'score)
5467 (prev (cons nil list))
5470 (if (or (not (consp (car arts)))
5471 (= (cdar arts) gnus-summary-default-score))
5472 (setcdr prev (cdr arts))
5474 (setq arts (cdr arts)))
5475 (setq list (cdr all)))))
5477 (when (eq (cdr type) 'seen)
5478 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5480 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5481 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5483 (when (and (gnus-check-backend-function
5484 'request-set-mark gnus-newsgroup-name)
5485 (not (gnus-article-unpropagatable-p (cdr type))))
5486 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5487 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5488 (add (gnus-remove-from-range
5489 (gnus-copy-sequence list) old)))
5491 (push (list add 'add (list (cdr type))) delta-marks))
5493 (push (list del 'del (list (cdr type))) delta-marks))))
5496 (push (cons (cdr type) list) newmarked)))
5499 (unless (gnus-check-group gnus-newsgroup-name)
5500 (error "Can't open server for %s" gnus-newsgroup-name))
5501 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5503 ;; Enter these new marks into the info of the group.
5505 (setcar (nthcdr 3 info) newmarked)
5506 ;; Add the marks lists to the end of the info.
5508 (setcdr (nthcdr 2 info) (list newmarked))))
5510 ;; Cut off the end of the info if there's nothing else there.
5514 (when (nthcdr (decf i) info)
5515 (setcdr (nthcdr i info) nil)))))))
5517 (defun gnus-set-mode-line (where)
5518 "Set the mode line of the article or summary buffers.
5519 If WHERE is `summary', the summary mode line format will be used."
5520 ;; Is this mode line one we keep updated?
5521 (when (and (memq where gnus-updated-mode-lines)
5523 (intern (format "gnus-%s-mode-line-format-spec" where))))
5526 ;; We evaluate this in the summary buffer since these
5527 ;; variables are buffer-local to that buffer.
5528 (set-buffer gnus-summary-buffer)
5529 ;; We bind all these variables that are used in the `eval' form
5531 (let* ((mformat (symbol-value
5533 (format "gnus-%s-mode-line-format-spec" where))))
5534 (gnus-tmp-group-name (gnus-group-decoded-name
5535 gnus-newsgroup-name))
5536 (gnus-tmp-article-number (or gnus-current-article 0))
5537 (gnus-tmp-unread gnus-newsgroup-unreads)
5538 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5539 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5540 (gnus-tmp-unread-and-unselected
5541 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5542 (zerop gnus-tmp-unselected))
5544 ((zerop gnus-tmp-unselected)
5545 (format "{%d more}" gnus-tmp-unread-and-unticked))
5546 (t (format "{%d(+%d) more}"
5547 gnus-tmp-unread-and-unticked
5548 gnus-tmp-unselected))))
5550 (if (and gnus-current-headers
5551 (vectorp gnus-current-headers))
5552 (gnus-mode-string-quote
5553 (mail-header-subject gnus-current-headers))
5555 bufname-length max-len
5556 gnus-tmp-header);; passed as argument to any user-format-funcs
5557 (setq mode-string (eval mformat))
5558 (setq bufname-length (if (string-match "%b" mode-string)
5561 (if (eq where 'summary)
5563 (get-buffer gnus-article-buffer))))
5566 (setq max-len (max 4 (if gnus-mode-non-string-length
5568 gnus-mode-non-string-length
5570 (length mode-string))))
5571 ;; We might have to chop a bit of the string off...
5572 (when (> (length mode-string) max-len)
5574 (concat (gnus-truncate-string mode-string (- max-len 3))
5576 ;; Pad the mode string a bit.
5577 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5578 ;; Update the mode line.
5579 (setq mode-line-buffer-identification
5580 (gnus-mode-line-buffer-identification (list mode-string)))
5581 (set-buffer-modified-p t))))
5583 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5584 "Go through the HEADERS list and add all Xrefs to a hash table.
5585 The resulting hash table is returned, or nil if no Xrefs were found."
5586 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5587 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5588 (xref-hashtb (gnus-make-hashtable))
5589 start group entry number xrefs header)
5591 (setq header (pop headers))
5592 (when (and (setq xrefs (mail-header-xref header))
5593 (not (memq (setq number (mail-header-number header))
5596 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5597 (setq start (match-end 0))
5598 (setq group (if prefix
5599 (concat prefix (substring xrefs (match-beginning 1)
5601 (substring xrefs (match-beginning 1) (match-end 1))))
5603 (string-to-int (substring xrefs (match-beginning 2)
5605 (if (setq entry (gnus-gethash group xref-hashtb))
5606 (setcdr entry (cons number (cdr entry)))
5607 (gnus-sethash group (cons number nil) xref-hashtb)))))
5608 (and start xref-hashtb)))
5610 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5611 "Look through all the headers and mark the Xrefs as read."
5612 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5613 name info xref-hashtb idlist method nth4)
5615 (set-buffer gnus-group-buffer)
5616 (when (setq xref-hashtb
5617 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5620 (unless (string= from-newsgroup (setq name (symbol-name group)))
5621 (setq idlist (symbol-value group))
5622 ;; Dead groups are not updated.
5624 (setq info (gnus-get-info name))
5625 (when (stringp (setq nth4 (gnus-info-method info)))
5626 (setq nth4 (gnus-server-to-method nth4))))
5627 ;; Only do the xrefs if the group has the same
5628 ;; select method as the group we have just read.
5629 (or (gnus-methods-equal-p
5630 nth4 (gnus-find-method-for-group from-newsgroup))
5632 (equal nth4 (setq method (gnus-find-method-for-group
5634 (and (equal (car nth4) (car method))
5635 (equal (nth 1 nth4) (nth 1 method))))
5636 gnus-use-cross-reference
5637 (or (not (eq gnus-use-cross-reference t))
5639 ;; Only do cross-references on subscribed
5640 ;; groups, if that is what is wanted.
5641 (<= (gnus-info-level info) gnus-level-subscribed))
5642 (gnus-group-make-articles-read name idlist))))
5645 (defun gnus-compute-read-articles (group articles)
5646 (let* ((entry (gnus-group-entry group))
5647 (info (nth 2 entry))
5648 (active (gnus-active group))
5651 ;; First peel off all invalid article numbers.
5653 (let ((ids articles)
5655 (while (setq id (pop ids))
5656 (when (and first (> id (cdr active)))
5657 ;; We'll end up in this situation in one particular
5658 ;; obscure situation. If you re-scan a group and get
5659 ;; a new article that is cross-posted to a different
5660 ;; group that has not been re-scanned, you might get
5661 ;; crossposted article that has a higher number than
5662 ;; Gnus believes possible. So we re-activate this
5663 ;; group as well. This might mean doing the
5664 ;; crossposting thingy will *increase* the number
5665 ;; of articles in some groups. Tsk, tsk.
5666 (setq active (or (gnus-activate-group group) active)))
5667 (when (or (> id (cdr active))
5668 (< id (car active)))
5669 (setq articles (delq id articles))))))
5670 ;; If the read list is nil, we init it.
5672 (null (gnus-info-read info))
5674 (setq ninfo (cons 1 (1- (car active))))
5675 (setq ninfo (gnus-info-read info)))
5676 ;; Then we add the read articles to the range.
5678 ninfo (setq articles (sort articles '<))))))
5680 (defun gnus-group-make-articles-read (group articles)
5681 "Update the info of GROUP to say that ARTICLES are read."
5683 (entry (gnus-group-entry group))
5684 (info (nth 2 entry))
5685 (active (gnus-active group))
5688 (setq range (gnus-compute-read-articles group articles))
5689 (with-current-buffer gnus-group-buffer
5692 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5693 (gnus-info-set-read ',info ',(gnus-info-read info))
5694 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5695 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5696 (gnus-group-update-group ,group t))))
5697 ;; Add the read articles to the range.
5698 (gnus-info-set-read info range)
5699 (gnus-request-set-mark group (list (list range 'add '(read))))
5700 ;; Then we have to re-compute how many unread
5701 ;; articles there are in this group.
5705 (setq num (- (1+ (cdr active)) (car active))))
5706 ((not (listp (cdr range)))
5707 (setq num (- (cdr active) (- (1+ (cdr range))
5711 (if (numberp (car range))
5713 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5714 (setq range (cdr range)))
5715 (setq num (- (cdr active) num))))
5716 ;; Update the number of unread articles.
5718 ;; Update the group buffer.
5719 (unless (gnus-ephemeral-group-p group)
5720 (gnus-group-update-group group t))))))
5722 (defvar gnus-newsgroup-none-id 0)
5724 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5725 (let ((cur nntp-server-buffer)
5728 (save-excursion (set-buffer gnus-summary-buffer)
5729 gnus-newsgroup-dependencies)))
5731 (mail-parse-charset gnus-newsgroup-charset)
5732 (mail-parse-ignored-charsets
5733 (save-excursion (condition-case nil
5734 (set-buffer gnus-summary-buffer)
5736 gnus-newsgroup-ignored-charsets)))
5738 (set-buffer nntp-server-buffer)
5739 ;; Translate all TAB characters into SPACE characters.
5740 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5741 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5742 (ietf-drums-unfold-fws)
5743 (gnus-run-hooks 'gnus-parse-headers-hook)
5744 (let ((case-fold-search t)
5745 in-reply-to header p lines chars ctype)
5746 (goto-char (point-min))
5747 ;; Search to the beginning of the next header. Error messages
5748 ;; do not begin with 2 or 3.
5749 (while (re-search-forward "^[23][0-9]+ " nil t)
5752 ;; This implementation of this function, with nine
5753 ;; search-forwards instead of the one re-search-forward and
5754 ;; a case (which basically was the old function) is actually
5755 ;; about twice as fast, even though it looks messier. You
5756 ;; can't have everything, I guess. Speed and elegance
5757 ;; doesn't always go hand in hand.
5760 (make-full-mail-header
5766 (narrow-to-region (point)
5767 (or (and (search-forward "\n.\n" nil t)
5773 (if (search-forward "\nsubject:" nil t)
5774 (nnheader-header-value)
5779 (if (search-forward "\nfrom:" nil t)
5780 (nnheader-header-value)
5785 (if (search-forward "\ndate:" nil t)
5786 (nnheader-header-value) ""))
5790 (setq id (if (re-search-forward
5791 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5792 ;; We do it this way to make sure the Message-ID
5793 ;; is (somewhat) syntactically valid.
5794 (buffer-substring (match-beginning 1)
5796 ;; If there was no message-id, we just fake one
5797 ;; to make subsequent routines simpler.
5798 (nnheader-generate-fake-message-id))))
5802 (if (search-forward "\nreferences:" nil t)
5806 (nnheader-header-value)
5811 (search-backward ">" end t)
5814 (search-backward "<" end t)
5816 ;; Get the references from the in-reply-to header if there
5817 ;; were no references and the in-reply-to header looks
5819 (if (and (search-forward "\nin-reply-to:" nil t)
5820 (setq in-reply-to (nnheader-header-value))
5821 (string-match "<[^>]+>" in-reply-to))
5823 (setq ref (substring in-reply-to (match-beginning 0)
5825 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5826 (setq ref2 (substring in-reply-to (match-beginning 0)
5828 (when (> (length ref2) (length ref))
5835 (if (search-forward "\nchars: " nil t)
5836 (if (numberp (setq chars (ignore-errors (read cur))))
5842 (if (search-forward "\nlines: " nil t)
5843 (if (numberp (setq lines (ignore-errors (read cur))))
5849 (and (search-forward "\nxref:" nil t)
5850 (nnheader-header-value)))
5852 (when gnus-extra-headers
5853 (let ((extra gnus-extra-headers)
5857 (when (search-forward
5858 (concat "\n" (symbol-name (car extra)) ":") nil t)
5859 (push (cons (car extra) (nnheader-header-value)) out))
5863 (if (and (search-forward "\ncontent-type: " nil t)
5864 (setq ctype (nnheader-header-value)))
5865 (mime-entity-set-content-type-internal
5866 header (mime-parse-Content-Type ctype)))
5867 (when (equal id ref)
5870 (when gnus-alter-header-function
5871 (funcall gnus-alter-header-function header)
5872 (setq id (mail-header-id header)
5873 ref (gnus-parent-id (mail-header-references header))))
5876 (gnus-dependencies-add-header
5877 header dependencies force-new))
5878 (push header headers))
5879 (goto-char (point-max))
5881 (nreverse headers)))))
5883 ;; Goes through the xover lines and returns a list of vectors
5884 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5885 force-new dependencies
5886 group also-fetch-heads)
5887 "Parse the news overview data in the server buffer.
5888 Return a list of headers that match SEQUENCE (see
5889 `nntp-retrieve-headers')."
5890 ;; Get the Xref when the users reads the articles since most/some
5891 ;; NNTP servers do not include Xrefs when using XOVER.
5892 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5893 (let ((mail-parse-charset gnus-newsgroup-charset)
5894 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5895 (cur nntp-server-buffer)
5896 (dependencies (or dependencies gnus-newsgroup-dependencies))
5898 ((eq gnus-read-all-available-headers t)
5900 ((stringp gnus-read-all-available-headers)
5901 (string-match gnus-read-all-available-headers group))
5904 number headers header)
5906 (set-buffer nntp-server-buffer)
5907 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5908 ;; Allow the user to mangle the headers before parsing them.
5909 (gnus-run-hooks 'gnus-parse-headers-hook)
5910 (goto-char (point-min))
5911 (gnus-parse-without-error
5912 (while (and (or sequence allp)
5914 (setq number (read cur))
5916 (while (and sequence
5917 (< (car sequence) number))
5918 (setq sequence (cdr sequence))))
5921 (eq number (car sequence))))
5923 (setq sequence (cdr sequence))
5924 (setq header (inline
5925 (gnus-nov-parse-line
5926 number dependencies force-new)))))
5927 (push header headers))
5929 ;; A common bug in inn is that if you have posted an article and
5930 ;; then retrieves the active file, it will answer correctly --
5931 ;; the new article is included. However, a NOV entry for the
5932 ;; article may not have been generated yet, so this may fail.
5933 ;; We work around this problem by retrieving the last few
5934 ;; headers using HEAD.
5935 (if (or (not also-fetch-heads)
5937 ;; We (probably) got all the headers.
5939 (let ((gnus-nov-is-evil t))
5942 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5943 (gnus-get-newsgroup-headers))))))))
5945 (defun gnus-article-get-xrefs ()
5946 "Fill in the Xref value in `gnus-current-headers', if necessary.
5947 This is meant to be called in `gnus-article-internal-prepare-hook'."
5948 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5949 gnus-current-headers)))
5950 (or (not gnus-use-cross-reference)
5952 (and (mail-header-xref headers)
5953 (not (string= (mail-header-xref headers) "")))
5954 (let ((case-fold-search t)
5957 (nnheader-narrow-to-headers)
5958 (goto-char (point-min))
5959 (when (or (and (not (eobp))
5960 (eq (downcase (char-after)) ?x)
5961 (looking-at "Xref:"))
5962 (search-forward "\nXref:" nil t))
5963 (goto-char (1+ (match-end 0)))
5964 (setq xref (buffer-substring (point) (point-at-eol)))
5965 (mail-header-set-xref headers xref)))))))
5967 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5968 "Find article ID and insert the summary line for that article.
5969 OLD-HEADER can either be a header or a line number to insert
5970 the subject line on."
5971 (let* ((line (and (numberp old-header) old-header))
5972 (old-header (and (vectorp old-header) old-header))
5973 (header (cond ((and old-header use-old-header)
5976 (gnus-number-to-header id))
5977 (gnus-number-to-header id))
5979 (gnus-read-header id))))
5980 (number (and (numberp id) id))
5983 ;; Rebuild the thread that this article is part of and go to the
5984 ;; article we have fetched.
5985 (when (and (not gnus-show-threads)
5988 (setq d (gnus-data-find (mail-header-number old-header))))
5989 (goto-char (gnus-data-pos d))
5995 (gnus-delete-line))))))
5997 (mail-header-set-number header (mail-header-number old-header)))
5998 (setq gnus-newsgroup-sparse
5999 (delq (setq number (mail-header-number header))
6000 gnus-newsgroup-sparse))
6001 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6002 (push number gnus-newsgroup-limit)
6003 (gnus-rebuild-thread (mail-header-id header) line)
6004 (gnus-summary-goto-subject number nil t))
6005 (when (and (numberp number)
6007 ;; We have to update the boundaries even if we can't fetch the
6008 ;; article if ID is a number -- so that the next `P' or `N'
6009 ;; command will fetch the previous (or next) article even
6010 ;; if the one we tried to fetch this time has been canceled.
6011 (when (> number gnus-newsgroup-end)
6012 (setq gnus-newsgroup-end number))
6013 (when (< number gnus-newsgroup-begin)
6014 (setq gnus-newsgroup-begin number))
6015 (setq gnus-newsgroup-unselected
6016 (delq number gnus-newsgroup-unselected)))
6017 ;; Report back a success?
6018 (and header (mail-header-number header))))
6020 ;;; Process/prefix in the summary buffer
6022 (defun gnus-summary-work-articles (n)
6023 "Return a list of articles to be worked upon.
6024 The prefix argument, the list of process marked articles, and the
6025 current article will be taken into consideration."
6027 (set-buffer gnus-summary-buffer)
6030 ;; A numerical prefix has been given.
6031 (setq n (prefix-numeric-value n))
6032 (let ((backward (< n 0))
6033 (n (abs (prefix-numeric-value n)))
6038 (push (setq article (gnus-summary-article-number))
6041 (gnus-summary-find-prev nil article)
6042 (gnus-summary-find-next nil article)))
6044 (nreverse articles)))
6045 ((and (gnus-region-active-p) (mark))
6046 (message "region active")
6047 ;; Work on the region between point and mark.
6048 (let ((max (max (point) (mark)))
6051 (goto-char (min (point) (mark)))
6054 (push (setq article (gnus-summary-article-number)) articles)
6055 (gnus-summary-find-next nil article)
6057 (nreverse articles))))
6058 (gnus-newsgroup-processable
6059 ;; There are process-marked articles present.
6060 ;; Save current state.
6061 (gnus-summary-save-process-mark)
6063 (reverse gnus-newsgroup-processable))
6065 ;; Just return the current article.
6066 (list (gnus-summary-article-number))))))
6068 (defmacro gnus-summary-iterate (arg &rest forms)
6069 "Iterate over the process/prefixed articles and do FORMS.
6070 ARG is the interactive prefix given to the command. FORMS will be
6071 executed with point over the summary line of the articles."
6072 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6073 `(let ((,articles (gnus-summary-work-articles ,arg)))
6075 (gnus-summary-goto-subject (car ,articles))
6079 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6080 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6082 (defun gnus-summary-save-process-mark ()
6083 "Push the current set of process marked articles on the stack."
6085 (push (copy-sequence gnus-newsgroup-processable)
6086 gnus-newsgroup-process-stack))
6088 (defun gnus-summary-kill-process-mark ()
6089 "Push the current set of process marked articles on the stack and unmark."
6091 (gnus-summary-save-process-mark)
6092 (gnus-summary-unmark-all-processable))
6094 (defun gnus-summary-yank-process-mark ()
6095 "Pop the last process mark state off the stack and restore it."
6097 (unless gnus-newsgroup-process-stack
6098 (error "Empty mark stack"))
6099 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6101 (defun gnus-summary-process-mark-set (set)
6102 "Make SET into the current process marked articles."
6103 (gnus-summary-unmark-all-processable)
6105 (gnus-summary-set-process-mark (pop set))))
6107 ;;; Searching and stuff
6109 (defun gnus-summary-search-group (&optional backward use-level)
6110 "Search for next unread newsgroup.
6111 If optional argument BACKWARD is non-nil, search backward instead."
6113 (set-buffer gnus-group-buffer)
6114 (when (gnus-group-search-forward
6115 backward nil (if use-level (gnus-group-group-level) nil))
6116 (gnus-group-group-name))))
6118 (defun gnus-summary-best-group (&optional exclude-group)
6119 "Find the name of the best unread group.
6120 If EXCLUDE-GROUP, do not go to this group."
6122 (set-buffer gnus-group-buffer)
6124 (gnus-group-best-unread-group exclude-group))))
6126 (defun gnus-summary-find-next (&optional unread article backward)
6128 (gnus-summary-find-prev unread article)
6129 (let* ((dummy (gnus-summary-article-intangible-p))
6130 (article (or article (gnus-summary-article-number)))
6131 (data (gnus-data-find-list article))
6133 (when (and (not dummy)
6134 (or (not gnus-summary-check-current)
6136 (not (gnus-data-unread-p (car data)))))
6137 (setq data (cdr data)))
6142 (unless (memq (gnus-data-number (car data))
6144 ((eq gnus-auto-goto-ignores
6145 'always-undownloaded)
6146 gnus-newsgroup-undownloaded)
6149 ((eq gnus-auto-goto-ignores
6151 gnus-newsgroup-unfetched)
6152 ((eq gnus-auto-goto-ignores
6154 gnus-newsgroup-undownloaded)))
6155 (when (gnus-data-unread-p (car data))
6156 (setq result (car data)
6158 (setq data (cdr data)))
6161 (goto-char (gnus-data-pos result))
6162 (gnus-data-number result)))))
6164 (defun gnus-summary-find-prev (&optional unread article)
6165 (let* ((eobp (eobp))
6166 (article (or article (gnus-summary-article-number)))
6167 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6169 (when (and (not eobp)
6170 (or (not gnus-summary-check-current)
6172 (not (gnus-data-unread-p (car data)))))
6173 (setq data (cdr data)))
6178 (unless (memq (gnus-data-number (car data))
6180 ((eq gnus-auto-goto-ignores
6181 'always-undownloaded)
6182 gnus-newsgroup-undownloaded)
6185 ((eq gnus-auto-goto-ignores
6187 gnus-newsgroup-unfetched)
6188 ((eq gnus-auto-goto-ignores
6190 gnus-newsgroup-undownloaded)))
6191 (when (gnus-data-unread-p (car data))
6192 (setq result (car data)
6194 (setq data (cdr data)))
6197 (goto-char (gnus-data-pos result))
6198 (gnus-data-number result))))
6200 (defun gnus-summary-find-subject (subject &optional unread backward article)
6201 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6202 (article (or article (gnus-summary-article-number)))
6203 (articles (gnus-data-list backward))
6204 (arts (gnus-data-find-list article articles))
6206 (when (or (not gnus-summary-check-current)
6208 (not (gnus-data-unread-p (car arts))))
6209 (setq arts (cdr arts)))
6211 (and (or (not unread)
6212 (gnus-data-unread-p (car arts)))
6213 (vectorp (gnus-data-header (car arts)))
6215 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6216 (setq result (car arts)
6218 (setq arts (cdr arts)))
6220 (goto-char (gnus-data-pos result))
6221 (gnus-data-number result))))
6223 (defun gnus-summary-search-forward (&optional unread subject backward)
6224 "Search forward for an article.
6225 If UNREAD, look for unread articles. If SUBJECT, look for
6226 articles with that subject. If BACKWARD, search backward instead."
6227 (cond (subject (gnus-summary-find-subject subject unread backward))
6228 (backward (gnus-summary-find-prev unread))
6229 (t (gnus-summary-find-next unread))))
6231 (defun gnus-recenter (&optional n)
6232 "Center point in window and redisplay frame.
6233 Also do horizontal recentering."
6235 (when (and gnus-auto-center-summary
6236 (not (eq gnus-auto-center-summary 'vertical)))
6237 (gnus-horizontal-recenter))
6240 (defun gnus-summary-recenter ()
6241 "Center point in the summary window.
6242 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6243 displayed, no centering will be performed."
6244 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6245 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6247 ;; The user has to want it.
6248 (when gnus-auto-center-summary
6249 (let* ((top (cond ((< (window-height) 4) 0)
6250 ((< (window-height) 7) 1)
6251 (t (if (numberp gnus-auto-center-summary)
6252 gnus-auto-center-summary
6254 (height (1- (window-height)))
6255 (bottom (save-excursion (goto-char (point-max))
6256 (forward-line (- height))
6258 (window (get-buffer-window (current-buffer))))
6259 (when (get-buffer-window gnus-article-buffer)
6260 ;; Only do recentering when the article buffer is displayed,
6261 ;; Set the window start to either `bottom', which is the biggest
6262 ;; possible valid number, or the second line from the top,
6263 ;; whichever is the least.
6264 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6265 (if (> bottom top-pos)
6266 ;; Keep the second line from the top visible
6267 (set-window-start window top-pos t)
6268 ;; Try to keep the bottom line visible; if it's partially
6269 ;; obscured, either scroll one more line to make it fully
6270 ;; visible, or revert to using TOP-POS.
6272 (goto-char (point-max))
6274 (let ((last-line-start (point)))
6276 (set-window-start window (point) t)
6277 (when (not (pos-visible-in-window-p last-line-start window))
6279 (set-window-start window (min (point) top-pos) t)))))))
6280 ;; Do horizontal recentering while we're at it.
6281 (when (and (get-buffer-window (current-buffer) t)
6282 (not (eq gnus-auto-center-summary 'vertical)))
6283 (let ((selected (selected-window)))
6284 (select-window (get-buffer-window (current-buffer) t))
6285 (gnus-summary-position-point)
6286 (gnus-horizontal-recenter)
6287 (select-window selected))))))
6289 (defun gnus-summary-jump-to-group (newsgroup)
6290 "Move point to NEWSGROUP in group mode buffer."
6291 ;; Keep update point of group mode buffer if visible.
6292 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6293 (save-window-excursion
6294 ;; Take care of tree window mode.
6295 (when (get-buffer-window gnus-group-buffer)
6296 (pop-to-buffer gnus-group-buffer))
6297 (gnus-group-jump-to-group newsgroup))
6299 ;; Take care of tree window mode.
6300 (if (get-buffer-window gnus-group-buffer)
6301 (pop-to-buffer gnus-group-buffer)
6302 (set-buffer gnus-group-buffer))
6303 (gnus-group-jump-to-group newsgroup))))
6305 ;; This function returns a list of article numbers based on the
6306 ;; difference between the ranges of read articles in this group and
6307 ;; the range of active articles.
6308 (defun gnus-list-of-unread-articles (group)
6309 (let* ((read (gnus-info-read (gnus-get-info group)))
6310 (active (or (gnus-active group) (gnus-activate-group group)))
6313 ;; If none are read, then all are unread.
6315 (setq first (car active))
6316 ;; If the range of read articles is a single range, then the
6317 ;; first unread article is the article after the last read
6318 ;; article. Sounds logical, doesn't it?
6319 (if (and (not (listp (cdr read)))
6320 (or (< (car read) (car active))
6321 (progn (setq read (list read))
6323 (setq first (max (car active) (1+ (cdr read))))
6324 ;; `read' is a list of ranges.
6325 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6328 (setq first (car active)))
6331 (while (< first nlast)
6332 (setq unread (cons first unread)
6334 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6335 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6336 (setq read (cdr read)))))
6337 ;; And add the last unread articles.
6338 (while (<= first last)
6339 (setq unread (cons first unread)
6341 ;; Return the list of unread articles.
6342 (delq 0 (nreverse unread))))
6344 (defun gnus-list-of-read-articles (group)
6345 "Return a list of unread, unticked and non-dormant articles."
6346 (let* ((info (gnus-get-info group))
6347 (marked (gnus-info-marks info))
6348 (active (gnus-active group)))
6350 (gnus-list-range-difference
6351 (gnus-list-range-difference
6352 (gnus-sorted-complement
6353 (gnus-uncompress-range active)
6354 (gnus-list-of-unread-articles group))
6355 (cdr (assq 'dormant marked)))
6356 (cdr (assq 'tick marked))))))
6358 ;; This function returns a sequence of article numbers based on the
6359 ;; difference between the ranges of read articles in this group and
6360 ;; the range of active articles.
6361 (defun gnus-sequence-of-unread-articles (group)
6362 (let* ((read (gnus-info-read (gnus-get-info group)))
6363 (active (or (gnus-active group) (gnus-activate-group group)))
6366 ;; If none are read, then all are unread.
6368 (setq first (car active))
6369 ;; If the range of read articles is a single range, then the
6370 ;; first unread article is the article after the last read
6371 ;; article. Sounds logical, doesn't it?
6372 (if (and (not (listp (cdr read)))
6373 (or (< (car read) (car active))
6374 (progn (setq read (list read))
6376 (setq first (max (car active) (1+ (cdr read))))
6377 ;; `read' is a list of ranges.
6378 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6381 (setq first (car active)))
6384 (push (cons first nlast) unread))
6385 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6386 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6387 (setq read (cdr read)))))
6388 ;; And add the last unread articles.
6389 (cond ((< first last)
6390 (push (cons first last) unread))
6392 (push first unread)))
6393 ;; Return the sequence of unread articles.
6394 (delq 0 (nreverse unread))))
6396 ;; Various summary commands
6398 (defun gnus-summary-select-article-buffer ()
6399 "Reconfigure windows to show article buffer."
6401 (if (not (gnus-buffer-live-p gnus-article-buffer))
6402 (error "There is no article buffer for this summary buffer")
6403 (gnus-configure-windows 'article)
6404 (select-window (get-buffer-window gnus-article-buffer))))
6406 (defun gnus-summary-universal-argument (arg)
6407 "Perform any operation on all articles that are process/prefixed."
6409 (let ((articles (gnus-summary-work-articles arg))
6416 (substitute-command-keys
6417 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6419 (gnus-error 1 "Undefined key")
6422 (gnus-summary-goto-subject (setq article (pop articles)))
6423 (let (gnus-newsgroup-processable)
6424 (command-execute func))
6425 (gnus-summary-remove-process-mark article)))))
6426 (gnus-summary-position-point))
6428 (defun gnus-summary-toggle-truncation (&optional arg)
6429 "Toggle truncation of summary lines.
6430 With ARG, turn line truncation on if ARG is positive."
6432 (setq truncate-lines
6433 (if (null arg) (not truncate-lines)
6434 (> (prefix-numeric-value arg) 0)))
6437 (defun gnus-summary-find-for-reselect ()
6438 "Return the number of an article to stay on across a reselect.
6439 The current article is considered, then following articles, then previous
6440 articles. An article is sought which is not cancelled and isn't a temporary
6441 insertion from another group. If there's no such then return a dummy 0."
6443 (dolist (rev '(nil t))
6444 (unless found ; don't demand the reverse list if we don't need it
6445 (let ((data (gnus-data-find-list
6446 (gnus-summary-article-number) (gnus-data-list rev))))
6447 (while (and data (not found))
6448 (if (and (< 0 (gnus-data-number (car data)))
6449 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6450 (setq found (gnus-data-number (car data))))
6451 (setq data (cdr data))))))
6454 (defun gnus-summary-reselect-current-group (&optional all rescan)
6455 "Exit and then reselect the current newsgroup.
6456 The prefix argument ALL means to select all articles."
6458 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6459 (error "Ephemeral groups can't be reselected"))
6460 (let ((current-subject (gnus-summary-find-for-reselect))
6461 (group gnus-newsgroup-name))
6462 (setq gnus-newsgroup-begin nil)
6463 (gnus-summary-exit nil 'leave-hidden)
6464 ;; We have to adjust the point of group mode buffer because
6465 ;; point was moved to the next unread newsgroup by exiting.
6466 (gnus-summary-jump-to-group group)
6469 (save-window-excursion
6470 ;; Don't show group contents.
6471 (set-window-start (selected-window) (point-max))
6472 (gnus-group-get-new-news-this-group 1))))
6473 (gnus-group-read-group all t)
6474 (gnus-summary-goto-subject current-subject nil t)))
6476 (defun gnus-summary-rescan-group (&optional all)
6477 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6479 (gnus-summary-reselect-current-group all t))
6481 (defun gnus-summary-update-info (&optional non-destructive)
6483 (let ((group gnus-newsgroup-name))
6485 (when gnus-newsgroup-kill-headers
6486 (setq gnus-newsgroup-killed
6487 (gnus-compress-sequence
6489 (gnus-list-range-intersection
6490 gnus-newsgroup-unselected gnus-newsgroup-killed)
6491 gnus-newsgroup-unreads)
6493 (unless (listp (cdr gnus-newsgroup-killed))
6494 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6495 (let ((headers gnus-newsgroup-headers))
6496 ;; Set the new ranges of read articles.
6498 (set-buffer gnus-group-buffer)
6499 (gnus-undo-force-boundary))
6500 (gnus-update-read-articles
6501 group (gnus-sorted-union
6502 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6503 ;; Set the current article marks.
6504 (let ((gnus-newsgroup-scored
6505 (if (and (not gnus-save-score)
6506 (not non-destructive))
6508 gnus-newsgroup-scored)))
6510 (gnus-update-marks)))
6511 ;; Do the cross-ref thing.
6512 (when gnus-use-cross-reference
6513 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6514 ;; Do not switch windows but change the buffer to work.
6515 (set-buffer gnus-group-buffer)
6516 (unless (gnus-ephemeral-group-p group)
6517 (gnus-group-update-group group)))))))
6519 (defun gnus-summary-save-newsrc (&optional force)
6520 "Save the current number of read/marked articles in the dribble buffer.
6521 The dribble buffer will then be saved.
6522 If FORCE (the prefix), also save the .newsrc file(s)."
6524 (gnus-summary-update-info t)
6526 (gnus-save-newsrc-file)
6527 (gnus-dribble-save)))
6529 (defun gnus-summary-exit (&optional temporary leave-hidden)
6530 "Exit reading current newsgroup, and then return to group selection mode.
6531 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6533 (gnus-set-global-variables)
6534 (gnus-kill-save-kill-buffer)
6535 (gnus-async-halt-prefetch)
6536 (let* ((group gnus-newsgroup-name)
6537 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6538 (gnus-group-is-exiting-p t)
6541 (buf (current-buffer)))
6543 ;; Do adaptive scoring, and possibly save score files.
6544 (when gnus-newsgroup-adaptive
6545 (gnus-score-adaptive))
6546 (when gnus-use-scoring
6548 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6549 ;; If we have several article buffers, we kill them at exit.
6550 (unless gnus-single-article-buffer
6551 (gnus-kill-buffer gnus-original-article-buffer)
6552 (setq gnus-article-current nil))
6553 (when gnus-use-cache
6554 (gnus-cache-possibly-remove-articles)
6555 (gnus-cache-save-buffers))
6556 (gnus-async-prefetch-remove-group group)
6557 (when gnus-suppress-duplicates
6558 (gnus-dup-enter-articles))
6559 (when gnus-use-trees
6560 (gnus-tree-close group))
6561 (when gnus-use-cache
6562 (gnus-cache-write-active))
6563 ;; Remove entries for this group.
6564 (nnmail-purge-split-history (gnus-group-real-name group))
6565 ;; Make all changes in this group permanent.
6567 (gnus-run-hooks 'gnus-exit-group-hook)
6568 (gnus-summary-update-info))
6569 (gnus-close-group group)
6570 ;; Make sure where we were, and go to next newsgroup.
6571 (set-buffer gnus-group-buffer)
6573 (gnus-group-jump-to-group group))
6574 (gnus-run-hooks 'gnus-summary-exit-hook)
6575 (unless (or quit-config
6576 ;; If this group has disappeared from the summary
6577 ;; buffer, don't skip forwards.
6578 (not (string= group (gnus-group-group-name))))
6579 (gnus-group-next-unread-group 1))
6580 (setq group-point (point))
6583 ;; If we have several article buffers, we kill them at exit.
6584 (unless gnus-single-article-buffer
6585 (gnus-kill-buffer gnus-article-buffer)
6586 (gnus-kill-buffer gnus-original-article-buffer)
6587 (setq gnus-article-current nil))
6589 (if (not gnus-kill-summary-on-exit)
6591 (gnus-deaden-summary)
6593 ;; We set all buffer-local variables to nil. It is unclear why
6594 ;; this is needed, but if we don't, buffer-local variables are
6595 ;; not garbage-collected, it seems. This would the lead to en
6596 ;; ever-growing Emacs.
6597 (gnus-summary-clear-local-variables)
6598 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6599 (gnus-summary-clear-local-variables))
6600 (when (get-buffer gnus-article-buffer)
6601 (bury-buffer gnus-article-buffer))
6602 ;; We clear the global counterparts of the buffer-local
6603 ;; variables as well, just to be on the safe side.
6604 (set-buffer gnus-group-buffer)
6605 (gnus-summary-clear-local-variables)
6606 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6607 (gnus-summary-clear-local-variables))
6608 ;; Return to group mode buffer.
6609 (when (eq mode 'gnus-summary-mode)
6610 (gnus-kill-buffer buf)))
6611 (setq gnus-current-select-method gnus-select-method)
6613 (set-buffer gnus-group-buffer)
6614 (pop-to-buffer gnus-group-buffer))
6615 (if (not quit-config)
6617 (goto-char group-point)
6618 (unless leave-hidden
6619 (gnus-configure-windows 'group 'force))
6620 (unless (pos-visible-in-window-p)
6621 (forward-line (/ (static-if (featurep 'xemacs)
6622 (window-displayed-height)
6623 (1- (window-height)))
6625 (set-window-start (selected-window) (point))
6626 (goto-char group-point)))
6627 (gnus-handle-ephemeral-exit quit-config))
6628 ;; Clear the current group name.
6630 (setq gnus-newsgroup-name nil)))))
6632 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6633 (defun gnus-summary-exit-no-update (&optional no-questions)
6634 "Quit reading current newsgroup without updating read article info."
6636 (let* ((group gnus-newsgroup-name)
6637 (gnus-group-is-exiting-p t)
6638 (gnus-group-is-exiting-without-update-p t)
6639 (quit-config (gnus-group-quit-config group)))
6640 (when (or no-questions
6642 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6643 (gnus-async-halt-prefetch)
6644 (run-hooks 'gnus-summary-prepare-exit-hook)
6645 ;; If we have several article buffers, we kill them at exit.
6646 (unless gnus-single-article-buffer
6647 (gnus-kill-buffer gnus-article-buffer)
6648 (gnus-kill-buffer gnus-original-article-buffer)
6649 (setq gnus-article-current nil))
6650 (if (not gnus-kill-summary-on-exit)
6651 (gnus-deaden-summary)
6652 (gnus-close-group group)
6653 (gnus-summary-clear-local-variables)
6654 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6655 (gnus-summary-clear-local-variables))
6656 (set-buffer gnus-group-buffer)
6657 (gnus-summary-clear-local-variables)
6658 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6659 (gnus-summary-clear-local-variables))
6660 (gnus-kill-buffer gnus-summary-buffer))
6661 (unless gnus-single-article-buffer
6662 (setq gnus-article-current nil))
6663 (when gnus-use-trees
6664 (gnus-tree-close group))
6665 (gnus-async-prefetch-remove-group group)
6666 (when (get-buffer gnus-article-buffer)
6667 (bury-buffer gnus-article-buffer))
6668 ;; Return to the group buffer.
6669 (gnus-configure-windows 'group 'force)
6670 ;; Clear the current group name.
6671 (setq gnus-newsgroup-name nil)
6672 (unless (gnus-ephemeral-group-p group)
6673 (gnus-group-update-group group))
6674 (when (equal (gnus-group-group-name) group)
6675 (gnus-group-next-unread-group 1))
6677 (gnus-handle-ephemeral-exit quit-config)))))
6679 (defun gnus-handle-ephemeral-exit (quit-config)
6680 "Handle movement when leaving an ephemeral group.
6681 The state which existed when entering the ephemeral is reset."
6682 (if (not (buffer-name (car quit-config)))
6683 (gnus-configure-windows 'group 'force)
6684 (set-buffer (car quit-config))
6685 (cond ((eq major-mode 'gnus-summary-mode)
6686 (gnus-set-global-variables))
6687 ((eq major-mode 'gnus-article-mode)
6689 ;; The `gnus-summary-buffer' variable may point
6690 ;; to the old summary buffer when using a single
6692 (unless (gnus-buffer-live-p gnus-summary-buffer)
6693 (set-buffer gnus-group-buffer))
6694 (set-buffer gnus-summary-buffer)
6695 (gnus-set-global-variables))))
6696 (if (or (eq (cdr quit-config) 'article)
6697 (eq (cdr quit-config) 'pick))
6699 ;; The current article may be from the ephemeral group
6700 ;; thus it is best that we reload this article
6702 ;; If we're exiting from a large digest, this can be
6703 ;; extremely slow. So, it's better not to reload it. -- jh.
6704 ;;(gnus-summary-show-article)
6705 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6706 (gnus-configure-windows 'pick 'force)
6707 (gnus-configure-windows (cdr quit-config) 'force)))
6708 (gnus-configure-windows (cdr quit-config) 'force))
6709 (when (eq major-mode 'gnus-summary-mode)
6710 (gnus-summary-next-subject 1 nil t)
6711 (gnus-summary-recenter)
6712 (gnus-summary-position-point))))
6714 (defun gnus-summary-preview-mime-message ()
6715 "MIME decode and play this message."
6717 (let ((gnus-break-pages nil)
6719 (gnus-summary-select-article gnus-show-all-headers t))
6720 (let ((w (get-buffer-window gnus-article-buffer)))
6722 (select-window (get-buffer-window gnus-article-buffer)))))
6726 (defvar gnus-dead-summary-mode-map nil)
6728 (unless gnus-dead-summary-mode-map
6729 (setq gnus-dead-summary-mode-map (make-keymap))
6730 (suppress-keymap gnus-dead-summary-mode-map)
6731 (substitute-key-definition
6732 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6733 (dolist (key '("\C-d" "\r" "\177" [delete]))
6734 (define-key gnus-dead-summary-mode-map
6735 key 'gnus-summary-wake-up-the-dead))
6736 (dolist (key '("q" "Q"))
6737 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6739 (defvar gnus-dead-summary-mode nil
6740 "Minor mode for Gnus summary buffers.")
6742 (defun gnus-dead-summary-mode (&optional arg)
6743 "Minor mode for Gnus summary buffers."
6745 (when (eq major-mode 'gnus-summary-mode)
6746 (make-local-variable 'gnus-dead-summary-mode)
6747 (setq gnus-dead-summary-mode
6748 (if (null arg) (not gnus-dead-summary-mode)
6749 (> (prefix-numeric-value arg) 0)))
6750 (when gnus-dead-summary-mode
6752 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6754 (defun gnus-deaden-summary ()
6755 "Make the current summary buffer into a dead summary buffer."
6756 ;; Kill any previous dead summary buffer.
6757 (when (and gnus-dead-summary
6758 (buffer-name gnus-dead-summary))
6760 (set-buffer gnus-dead-summary)
6761 (when gnus-dead-summary-mode
6762 (kill-buffer (current-buffer)))))
6763 ;; Make this the current dead summary.
6764 (setq gnus-dead-summary (current-buffer))
6765 (gnus-dead-summary-mode 1)
6766 (let ((name (buffer-name)))
6767 (when (string-match "Summary" name)
6769 (concat (substring name 0 (match-beginning 0)) "Dead "
6770 (substring name (match-beginning 0)))
6774 (defun gnus-kill-or-deaden-summary (buffer)
6775 "Kill or deaden the summary BUFFER."
6777 (when (and (buffer-name buffer)
6778 (not gnus-single-article-buffer))
6781 (gnus-kill-buffer gnus-article-buffer)
6782 (gnus-kill-buffer gnus-original-article-buffer)))
6785 (gnus-kill-summary-on-exit
6786 (when (and gnus-use-trees
6787 (gnus-buffer-exists-p buffer))
6790 (gnus-tree-close gnus-newsgroup-name)))
6791 (gnus-kill-buffer buffer))
6792 ;; Deaden the buffer.
6793 ((gnus-buffer-exists-p buffer)
6796 (gnus-deaden-summary))))))
6798 (defun gnus-summary-wake-up-the-dead (&rest args)
6799 "Wake up the dead summary buffer."
6801 (gnus-dead-summary-mode -1)
6802 (let ((name (buffer-name)))
6803 (when (string-match "Dead " name)
6805 (concat (substring name 0 (match-beginning 0))
6806 (substring name (match-end 0)))
6808 (gnus-message 3 "This dead summary is now alive again"))
6810 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6811 (defun gnus-summary-fetch-faq (&optional faq-dir)
6812 "Fetch the FAQ for the current group.
6813 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6817 (when current-prefix-arg
6819 "FAQ dir: " (and (listp gnus-group-faq-directory)
6820 (mapcar (lambda (file) (list file))
6821 gnus-group-faq-directory))))))
6822 (let (gnus-faq-buffer)
6823 (when (setq gnus-faq-buffer
6824 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6825 (gnus-configure-windows 'summary-faq))))
6827 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6828 (defun gnus-summary-describe-group (&optional force)
6829 "Describe the current newsgroup."
6831 (gnus-group-describe-group force gnus-newsgroup-name))
6833 (defun gnus-summary-describe-briefly ()
6834 "Describe summary mode commands briefly."
6836 (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")))
6838 ;; Walking around group mode buffer from summary mode.
6840 (defun gnus-summary-next-group (&optional no-article target-group backward)
6841 "Exit current newsgroup and then select next unread newsgroup.
6842 If prefix argument NO-ARTICLE is non-nil, no article is selected
6843 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6844 previous group instead."
6846 ;; Stop pre-fetching.
6847 (gnus-async-halt-prefetch)
6848 (let ((current-group gnus-newsgroup-name)
6849 (current-buffer (current-buffer))
6851 ;; First we semi-exit this group to update Xrefs and all variables.
6852 ;; We can't do a real exit, because the window conf must remain
6853 ;; the same in case the user is prompted for info, and we don't
6854 ;; want the window conf to change before that...
6855 (gnus-summary-exit t)
6856 (while (not entered)
6857 ;; Then we find what group we are supposed to enter.
6858 (set-buffer gnus-group-buffer)
6859 (gnus-group-jump-to-group current-group)
6862 (if (eq gnus-keep-same-level 'best)
6863 (gnus-summary-best-group gnus-newsgroup-name)
6864 (gnus-summary-search-group backward gnus-keep-same-level))))
6865 (if (not target-group)
6866 ;; There are no further groups, so we return to the group
6869 (gnus-message 5 "Returning to the group buffer")
6871 (when (gnus-buffer-live-p current-buffer)
6872 (set-buffer current-buffer)
6873 (gnus-summary-exit))
6874 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6875 ;; We try to enter the target group.
6876 (gnus-group-jump-to-group target-group)
6877 (let ((unreads (gnus-group-group-unread)))
6878 (if (and (or (eq t unreads)
6879 (and unreads (not (zerop unreads))))
6880 (gnus-summary-read-group
6881 target-group nil no-article
6882 (and (buffer-name current-buffer) current-buffer)
6885 (setq current-group target-group
6886 target-group nil)))))))
6888 (defun gnus-summary-prev-group (&optional no-article)
6889 "Exit current newsgroup and then select previous unread newsgroup.
6890 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6892 (gnus-summary-next-group no-article nil t))
6894 ;; Walking around summary lines.
6896 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6897 "Go to the first subject satisfying any non-nil constraint.
6898 If UNREAD is non-nil, the article should be unread.
6899 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6900 If UNSEEN is non-nil, the article should be unseen.
6901 Returns the article selected or nil if there are no matching articles."
6905 ((null gnus-newsgroup-data)
6906 (gnus-message 3 "No articles in the group")
6908 ;; Pick the first article.
6909 ((not (or unread undownloaded unseen))
6910 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6911 (gnus-data-number (car gnus-newsgroup-data)))
6912 ;; Find the first unread article.
6914 (let ((data gnus-newsgroup-data))
6916 (let ((num (gnus-data-number (car data))))
6917 (or (memq num gnus-newsgroup-unfetched)
6918 (not (or (and unread
6919 (memq num gnus-newsgroup-unreads))
6921 (memq num gnus-newsgroup-undownloaded))
6923 (memq num gnus-newsgroup-unseen)))))))
6924 (setq data (cdr data)))
6928 (goto-char (gnus-data-pos (car data)))
6929 (gnus-data-number (car data)))
6930 (gnus-message 3 "No more%s articles"
6931 (let* ((r (when unread " unread"))
6932 (d (when undownloaded " undownloaded"))
6933 (s (when unseen " unseen"))
6934 (l (delq nil (list r d s))))
6935 (cond ((= 3 (length l))
6936 (concat r "," d ", or" s))
6938 (concat (car l) ", or" (cadr l)))
6945 (gnus-summary-position-point))))))
6947 (defun gnus-summary-next-subject (n &optional unread dont-display)
6948 "Go to next N'th summary line.
6949 If N is negative, go to the previous N'th subject line.
6950 If UNREAD is non-nil, only unread articles are selected.
6951 The difference between N and the actual number of steps taken is
6954 (let ((backward (< n 0))
6958 (gnus-summary-find-prev unread)
6959 (gnus-summary-find-next unread)))
6960 (unless (zerop (setq n (1- n)))
6961 (gnus-summary-show-thread)))
6963 (gnus-message 7 "No more%s articles"
6964 (if unread " unread" "")))
6965 (unless dont-display
6966 (gnus-summary-recenter)
6967 (gnus-summary-position-point))
6970 (defun gnus-summary-next-unread-subject (n)
6971 "Go to next N'th unread summary line."
6973 (gnus-summary-next-subject n t))
6975 (defun gnus-summary-prev-subject (n &optional unread)
6976 "Go to previous N'th summary line.
6977 If optional argument UNREAD is non-nil, only unread article is selected."
6979 (gnus-summary-next-subject (- n) unread))
6981 (defun gnus-summary-prev-unread-subject (n)
6982 "Go to previous N'th unread summary line."
6984 (gnus-summary-next-subject (- n) t))
6986 (defun gnus-summary-goto-subjects (articles)
6987 "Insert the subject header for ARTICLES in the current buffer."
6989 (dolist (article articles)
6990 (gnus-summary-goto-subject article t)))
6991 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6992 (gnus-summary-position-point))
6994 (defun gnus-summary-goto-subject (article &optional force silent)
6995 "Go the subject line of ARTICLE.
6996 If FORCE, also allow jumping to articles not currently shown."
6997 (interactive "nArticle number: ")
6998 (unless (numberp article)
6999 (error "Article %s is not a number" article))
7001 (data (gnus-data-find article)))
7002 ;; We read in the article if we have to.
7005 (gnus-summary-insert-subject
7007 (if (or (numberp force) (vectorp force)) force)
7009 (setq data (gnus-data-find article)))
7014 (gnus-message 3 "Can't find article %d" article))
7016 (let ((pt (gnus-data-pos data)))
7018 (gnus-summary-set-article-display-arrow pt))
7019 (gnus-summary-position-point)
7022 ;; Walking around summary lines with displaying articles.
7024 (defun gnus-summary-expand-window (&optional arg)
7025 "Make the summary buffer take up the entire Emacs frame.
7026 Given a prefix, will force an `article' buffer configuration."
7029 (gnus-configure-windows 'article 'force)
7030 (gnus-configure-windows 'summary 'force)))
7032 (defun gnus-summary-display-article (article &optional all-header)
7033 "Display ARTICLE in article buffer."
7034 (when (gnus-buffer-live-p gnus-article-buffer)
7035 (with-current-buffer gnus-article-buffer
7036 (set-buffer-multibyte t)))
7037 (gnus-set-global-variables)
7038 (when (gnus-buffer-live-p gnus-article-buffer)
7039 (with-current-buffer gnus-article-buffer
7040 (setq gnus-article-charset gnus-newsgroup-charset)
7041 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7042 (set-buffer-multibyte t)))
7046 (if gnus-summary-display-article-function
7047 (funcall gnus-summary-display-article-function article all-header)
7048 (gnus-article-prepare article all-header))
7049 (with-current-buffer gnus-article-buffer
7050 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7052 (gnus-run-hooks 'gnus-select-article-hook)
7053 (when (and gnus-current-article
7054 (not (zerop gnus-current-article)))
7055 (gnus-summary-goto-subject gnus-current-article))
7056 (gnus-summary-recenter)
7057 (when (and gnus-use-trees gnus-show-threads)
7058 (gnus-possibly-generate-tree article)
7059 (gnus-highlight-selected-tree article))
7060 ;; Successfully display article.
7061 (gnus-article-set-window-start
7062 (cdr (assq article gnus-newsgroup-bookmarks))))))
7064 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7065 "Select the current article.
7066 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7067 non-nil, the article will be re-fetched even if it already present in
7068 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7070 ;; Make sure we are in the summary buffer to work around bbdb bug.
7071 (unless (eq major-mode 'gnus-summary-mode)
7072 (set-buffer gnus-summary-buffer))
7073 (let ((article (or article (gnus-summary-article-number)))
7074 (all-headers (not (not all-headers))) ;Must be T or NIL.
7075 gnus-summary-display-article-function)
7077 (gnus-summary-article-pseudo-p article)
7078 (error "This is a pseudo-article"))
7080 (set-buffer gnus-summary-buffer)
7081 (if (or (and gnus-single-article-buffer
7082 (or (null gnus-current-article)
7083 (null gnus-article-current)
7084 (null (get-buffer gnus-article-buffer))
7085 (not (eq article (cdr gnus-article-current)))
7086 (not (equal (car gnus-article-current)
7087 gnus-newsgroup-name))))
7088 (and (not gnus-single-article-buffer)
7089 (or (null gnus-current-article)
7090 (not (eq gnus-current-article article))))
7092 ;; The requested article is different from the current article.
7094 (gnus-summary-display-article article all-headers)
7095 (gnus-article-set-window-start
7096 (cdr (assq article gnus-newsgroup-bookmarks)))
7100 (defun gnus-summary-force-verify-and-decrypt ()
7101 "Display buttons for signed/encrypted parts and verify/decrypt them."
7103 (let ((mm-verify-option 'known)
7104 (mm-decrypt-option 'known)
7105 (gnus-article-emulate-mime t)
7106 (gnus-buttonized-mime-types (append (list "multipart/signed"
7107 "multipart/encrypted")
7108 gnus-buttonized-mime-types)))
7109 (gnus-summary-select-article nil 'force)))
7111 (defun gnus-summary-set-current-mark (&optional current-mark)
7112 "Obsolete function."
7115 (defun gnus-summary-next-article (&optional unread subject backward push)
7116 "Select the next article.
7117 If UNREAD, only unread articles are selected.
7118 If SUBJECT, only articles with SUBJECT are selected.
7119 If BACKWARD, the previous article is selected instead of the next."
7122 ;; Is there such an article?
7123 ((and (gnus-summary-search-forward unread subject backward)
7124 (or (gnus-summary-display-article (gnus-summary-article-number))
7125 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7126 (gnus-summary-position-point))
7127 ;; If not, we try the first unread, if that is wanted.
7129 gnus-auto-select-same
7130 (gnus-summary-first-unread-article))
7131 (gnus-summary-position-point)
7132 (gnus-message 6 "Wrapped"))
7133 ;; Try to get next/previous article not displayed in this group.
7134 ((and gnus-auto-extend-newsgroup
7135 (not unread) (not subject))
7136 (gnus-summary-goto-article
7137 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7138 nil (count-lines (point-min) (point))))
7139 ;; Go to next/previous group.
7141 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7142 (gnus-summary-jump-to-group gnus-newsgroup-name))
7143 (let ((cmd last-command-char)
7146 (set-buffer gnus-group-buffer)
7149 (if (eq gnus-keep-same-level 'best)
7150 (gnus-summary-best-group gnus-newsgroup-name)
7151 (gnus-summary-search-group backward gnus-keep-same-level))))
7152 ;; For some reason, the group window gets selected. We change
7154 (select-window (get-buffer-window (current-buffer)))
7155 ;; Select next unread newsgroup automagically.
7157 ((or (not gnus-auto-select-next)
7159 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7160 ((or (eq gnus-auto-select-next 'quietly)
7161 (and (eq gnus-auto-select-next 'slightly-quietly)
7163 (and (eq gnus-auto-select-next 'almost-quietly)
7164 (gnus-summary-last-article-p)))
7166 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7168 (gnus-message 7 "No more%s articles (%s)..."
7169 (if unread " unread" "")
7170 (if group (concat "selecting " group)
7172 (gnus-summary-next-group nil group backward)))
7174 (when (gnus-key-press-event-p last-input-event)
7175 (gnus-summary-walk-group-buffer
7176 gnus-newsgroup-name cmd unread backward point))))))))
7178 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7179 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7180 (?\C-p (gnus-group-prev-unread-group 1))))
7181 (cursor-in-echo-area t)
7182 keve key group ended prompt)
7184 (set-buffer gnus-group-buffer)
7187 (if (eq gnus-keep-same-level 'best)
7188 (gnus-summary-best-group gnus-newsgroup-name)
7189 (gnus-summary-search-group backward gnus-keep-same-level))))
7193 "No more%s articles%s " (if unread " unread" "")
7195 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7196 (format " (Type %s for %s [%s])"
7197 (single-key-description cmd) group
7198 (gnus-group-unread group))
7199 (format " (Type %s to exit %s)"
7200 (single-key-description cmd)
7201 gnus-newsgroup-name))))
7202 ;; Confirm auto selection.
7203 (setq key (car (setq keve (gnus-read-event-char prompt)))
7206 ((assq key keystrokes)
7207 (let ((obuf (current-buffer)))
7208 (switch-to-buffer gnus-group-buffer)
7210 (gnus-group-jump-to-group group))
7211 (eval (cadr (assq key keystrokes)))
7212 (setq group (gnus-group-group-name))
7213 (switch-to-buffer obuf))
7217 (gnus-ephemeral-group-p gnus-newsgroup-name))
7219 (gnus-summary-next-group nil group backward)))
7221 (push (cdr keve) unread-command-events))))))
7223 (defun gnus-summary-next-unread-article ()
7224 "Select unread article after current one."
7226 (gnus-summary-next-article
7227 (or (not (eq gnus-summary-goto-unread 'never))
7228 (gnus-summary-last-article-p (gnus-summary-article-number)))
7229 (and gnus-auto-select-same
7230 (gnus-summary-article-subject))))
7232 (defun gnus-summary-prev-article (&optional unread subject)
7233 "Select the article after the current one.
7234 If UNREAD is non-nil, only unread articles are selected."
7236 (gnus-summary-next-article unread subject t))
7238 (defun gnus-summary-prev-unread-article ()
7239 "Select unread article before current one."
7241 (gnus-summary-prev-article
7242 (or (not (eq gnus-summary-goto-unread 'never))
7243 (gnus-summary-first-article-p (gnus-summary-article-number)))
7244 (and gnus-auto-select-same
7245 (gnus-summary-article-subject))))
7247 (defun gnus-summary-next-page (&optional lines circular stop)
7248 "Show next page of the selected article.
7249 If at the end of the current article, select the next article.
7250 LINES says how many lines should be scrolled up.
7252 If CIRCULAR is non-nil, go to the start of the article instead of
7253 selecting the next article when reaching the end of the current
7256 If STOP is non-nil, just stop when reaching the end of the message.
7258 Also see the variable `gnus-article-skip-boring'."
7260 (setq gnus-summary-buffer (current-buffer))
7261 (gnus-set-global-variables)
7262 (let ((article (gnus-summary-article-number))
7263 (article-window (get-buffer-window gnus-article-buffer t))
7265 ;; If the buffer is empty, we have no article.
7267 (error "No article to select"))
7268 (gnus-configure-windows 'article)
7269 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7270 (if (and (eq gnus-summary-goto-unread 'never)
7271 (not (gnus-summary-last-article-p article)))
7272 (gnus-summary-next-article)
7273 (gnus-summary-next-unread-article))
7274 (if (or (null gnus-current-article)
7275 (null gnus-article-current)
7276 (/= article (cdr gnus-article-current))
7277 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7278 ;; Selected subject is different from current article's.
7279 (gnus-summary-display-article article)
7280 (when article-window
7281 (gnus-eval-in-buffer-window gnus-article-buffer
7282 (setq endp (or (gnus-article-next-page lines)
7283 (gnus-article-only-boring-p))))
7286 (gnus-message 3 "End of message"))
7288 (gnus-summary-beginning-of-article))
7290 (gnus-message 3 "End of message"))
7292 (if (and (eq gnus-summary-goto-unread 'never)
7293 (not (gnus-summary-last-article-p article)))
7294 (gnus-summary-next-article)
7295 (gnus-summary-next-unread-article))))))))
7296 (gnus-summary-recenter)
7297 (gnus-summary-position-point)))
7299 (defun gnus-summary-prev-page (&optional lines move)
7300 "Show previous page of selected article.
7301 Argument LINES specifies lines to be scrolled down.
7302 If MOVE, move to the previous unread article if point is at
7303 the beginning of the buffer."
7305 (let ((article (gnus-summary-article-number))
7306 (article-window (get-buffer-window gnus-article-buffer t))
7308 (gnus-configure-windows 'article)
7309 (if (or (null gnus-current-article)
7310 (null gnus-article-current)
7311 (/= article (cdr gnus-article-current))
7312 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7313 ;; Selected subject is different from current article's.
7314 (gnus-summary-display-article article)
7315 (gnus-summary-recenter)
7316 (when article-window
7317 (gnus-eval-in-buffer-window gnus-article-buffer
7318 (setq endp (gnus-article-prev-page lines)))
7319 (when (and move endp)
7321 (gnus-message 3 "Beginning of message"))
7323 (if (and (eq gnus-summary-goto-unread 'never)
7324 (not (gnus-summary-first-article-p article)))
7325 (gnus-summary-prev-article)
7326 (gnus-summary-prev-unread-article))))))))
7327 (gnus-summary-position-point))
7329 (defun gnus-summary-prev-page-or-article (&optional lines)
7330 "Show previous page of selected article.
7331 Argument LINES specifies lines to be scrolled down.
7332 If at the beginning of the article, go to the next article."
7334 (gnus-summary-prev-page lines t))
7336 (defun gnus-summary-scroll-up (lines)
7337 "Scroll up (or down) one line current article.
7338 Argument LINES specifies lines to be scrolled up (or down if negative)."
7340 (gnus-configure-windows 'article)
7341 (gnus-summary-show-thread)
7342 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7343 (gnus-eval-in-buffer-window gnus-article-buffer
7345 (when (gnus-article-next-page lines)
7346 (gnus-message 3 "End of message")))
7348 (gnus-article-prev-page (- lines))))))
7349 (gnus-summary-recenter)
7350 (gnus-summary-position-point))
7352 (defun gnus-summary-scroll-down (lines)
7353 "Scroll down (or up) one line current article.
7354 Argument LINES specifies lines to be scrolled down (or up if negative)."
7356 (gnus-summary-scroll-up (- lines)))
7358 (defun gnus-summary-next-same-subject ()
7359 "Select next article which has the same subject as current one."
7361 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7363 (defun gnus-summary-prev-same-subject ()
7364 "Select previous article which has the same subject as current one."
7366 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7368 (defun gnus-summary-next-unread-same-subject ()
7369 "Select next unread article which has the same subject as current one."
7371 (gnus-summary-next-article t (gnus-summary-article-subject)))
7373 (defun gnus-summary-prev-unread-same-subject ()
7374 "Select previous unread article which has the same subject as current one."
7376 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7378 (defun gnus-summary-first-unread-article ()
7379 "Select the first unread article.
7380 Return nil if there are no unread articles."
7383 (when (gnus-summary-first-subject t)
7384 (gnus-summary-show-thread)
7385 (gnus-summary-first-subject t)
7386 (gnus-summary-display-article (gnus-summary-article-number)))
7387 (gnus-summary-position-point)))
7389 (defun gnus-summary-first-unread-subject ()
7390 "Place the point on the subject line of the first unread article.
7391 Return nil if there are no unread articles."
7394 (when (gnus-summary-first-subject t)
7395 (gnus-summary-show-thread)
7396 (gnus-summary-first-subject t))
7397 (gnus-summary-position-point)))
7399 (defun gnus-summary-first-unseen-subject ()
7400 "Place the point on the subject line of the first unseen article.
7401 Return nil if there are no unseen articles."
7404 (when (gnus-summary-first-subject nil nil t)
7405 (gnus-summary-show-thread)
7406 (gnus-summary-first-subject nil nil t))
7407 (gnus-summary-position-point)))
7409 (defun gnus-summary-first-unseen-or-unread-subject ()
7410 "Place the point on the subject line of the first unseen article or,
7411 if all article have been seen, on the subject line of the first unread
7415 (unless (when (gnus-summary-first-subject nil nil t)
7416 (gnus-summary-show-thread)
7417 (gnus-summary-first-subject nil nil t))
7418 (when (gnus-summary-first-subject t)
7419 (gnus-summary-show-thread)
7420 (gnus-summary-first-subject t)))
7421 (gnus-summary-position-point)))
7423 (defun gnus-summary-first-article ()
7424 "Select the first article.
7425 Return nil if there are no articles."
7428 (when (gnus-summary-first-subject)
7429 (gnus-summary-show-thread)
7430 (gnus-summary-first-subject)
7431 (gnus-summary-display-article (gnus-summary-article-number)))
7432 (gnus-summary-position-point)))
7434 (defun gnus-summary-best-unread-article (&optional arg)
7435 "Select the unread article with the highest score.
7436 If given a prefix argument, select the next unread article that has a
7437 score higher than the default score."
7439 (let ((article (if arg
7440 (gnus-summary-better-unread-subject)
7441 (gnus-summary-best-unread-subject))))
7443 (gnus-summary-goto-article article)
7444 (error "No unread articles"))))
7446 (defun gnus-summary-best-unread-subject ()
7447 "Select the unread subject with the highest score."
7449 (let ((best -1000000)
7450 (data gnus-newsgroup-data)
7453 (and (gnus-data-unread-p (car data))
7455 (gnus-summary-article-score (gnus-data-number (car data))))
7458 article (gnus-data-number (car data))))
7459 (setq data (cdr data)))
7461 (gnus-summary-goto-subject article))
7462 (gnus-summary-position-point)
7465 (defun gnus-summary-better-unread-subject ()
7466 "Select the first unread subject that has a score over the default score."
7468 (let ((data gnus-newsgroup-data)
7470 (while (and (setq article (gnus-data-number (car data)))
7471 (or (gnus-data-read-p (car data))
7472 (not (> (gnus-summary-article-score article)
7473 gnus-summary-default-score))))
7474 (setq data (cdr data)))
7476 (gnus-summary-goto-subject article))
7477 (gnus-summary-position-point)
7480 (defun gnus-summary-last-subject ()
7481 "Go to the last displayed subject line in the group."
7482 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7484 (gnus-summary-goto-subject article))))
7486 (defun gnus-summary-goto-article (article &optional all-headers force)
7487 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7488 If ALL-HEADERS is non-nil, no header lines are hidden.
7489 If FORCE, go to the article even if it isn't displayed. If FORCE
7490 is a number, it is the line the article is to be displayed on."
7494 "Article number or Message-ID: "
7495 (mapcar (lambda (number) (list (int-to-string number)))
7496 gnus-newsgroup-limit))
7500 (if (and (stringp article)
7501 (string-match "@\\|%40" article))
7502 (gnus-summary-refer-article article)
7503 (when (stringp article)
7504 (setq article (string-to-number article)))
7505 (if (gnus-summary-goto-subject article force)
7506 (gnus-summary-display-article article all-headers)
7507 (gnus-message 4 "Couldn't go to article %s" article) nil))
7508 (gnus-summary-position-point)))
7510 (defun gnus-summary-goto-last-article ()
7511 "Go to the previously read article."
7514 (when gnus-last-article
7515 (gnus-summary-goto-article gnus-last-article nil t))
7516 (gnus-summary-position-point)))
7518 (defun gnus-summary-pop-article (number)
7519 "Pop one article off the history and go to the previous.
7520 NUMBER articles will be popped off."
7523 (setq gnus-newsgroup-history
7524 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7526 (gnus-summary-goto-article (car to) nil t)
7527 (error "Article history empty")))
7528 (gnus-summary-position-point))
7530 ;; Summary commands and functions for limiting the summary buffer.
7532 (defun gnus-summary-limit-to-articles (n)
7533 "Limit the summary buffer to the next N articles.
7534 If not given a prefix, use the process marked articles instead."
7537 (let ((articles (gnus-summary-work-articles n)))
7538 (setq gnus-newsgroup-processable nil)
7539 (gnus-summary-limit articles))
7540 (gnus-summary-position-point)))
7542 (defun gnus-summary-pop-limit (&optional total)
7543 "Restore the previous limit.
7544 If given a prefix, remove all limits."
7547 (setq gnus-newsgroup-limits
7548 (list (mapcar (lambda (h) (mail-header-number h))
7549 gnus-newsgroup-headers))))
7550 (unless gnus-newsgroup-limits
7551 (error "No limit to pop"))
7553 (gnus-summary-limit nil 'pop)
7554 (gnus-summary-position-point)))
7556 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7557 "Limit the summary buffer to articles that have subjects that match a regexp.
7558 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7560 (list (read-string (if current-prefix-arg
7561 "Exclude subject (regexp): "
7562 "Limit to subject (regexp): "))
7563 nil current-prefix-arg))
7565 (setq header "subject"))
7566 (when (not (equal "" subject))
7568 (let ((articles (gnus-summary-find-matching
7569 (or header "subject") subject 'all nil nil
7572 (error "Found no matches for \"%s\"" subject))
7573 (gnus-summary-limit articles))
7574 (gnus-summary-position-point))))
7576 (defun gnus-summary-limit-to-author (from &optional not-matching)
7577 "Limit the summary buffer to articles that have authors that match a regexp.
7578 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7580 (list (read-string (if current-prefix-arg
7581 "Exclude author (regexp): "
7582 "Limit to author (regexp): "))
7583 current-prefix-arg))
7584 (gnus-summary-limit-to-subject from "from" not-matching))
7586 (defun gnus-summary-limit-to-age (age &optional younger-p)
7587 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7588 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7589 articles that are younger than AGE days."
7591 (let ((younger current-prefix-arg)
7594 (while (not days-got)
7595 (setq days (if younger
7596 (read-string "Limit to articles younger than (in days, older when negative): ")
7598 "Limit to articles older than (in days, younger when negative): ")))
7599 (when (> (length days) 0)
7600 (setq days (read days)))
7605 (setq younger (not younger))
7606 (setq days (* days -1))))
7607 (message "Please enter a number.")
7609 (list days younger)))
7611 (let ((data gnus-newsgroup-data)
7612 (cutoff (days-to-time age))
7613 articles d date is-younger)
7614 (while (setq d (pop data))
7615 (when (and (vectorp (gnus-data-header d))
7616 (setq date (mail-header-date (gnus-data-header d))))
7617 (setq is-younger (time-less-p
7618 (time-since (condition-case ()
7625 (push (gnus-data-number d) articles))))
7626 (gnus-summary-limit (nreverse articles)))
7627 (gnus-summary-position-point)))
7629 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7630 "Limit the summary buffer to articles that match an 'extra' header."
7634 (gnus-completing-read-with-default
7635 (symbol-name (car gnus-extra-headers))
7636 (if current-prefix-arg
7637 "Exclude extra header:"
7638 "Limit extra header:")
7640 (cons (symbol-name x) x))
7645 (read-string (format "%s header %s (regexp): "
7646 (if current-prefix-arg "Exclude" "Limit to")
7648 current-prefix-arg)))
7649 (when (not (equal "" regexp))
7651 (let ((articles (gnus-summary-find-matching
7652 (cons 'extra header) regexp 'all nil nil
7655 (error "Found no matches for \"%s\"" regexp))
7656 (gnus-summary-limit articles))
7657 (gnus-summary-position-point))))
7659 (defun gnus-summary-limit-to-display-predicate ()
7660 "Limit the summary buffer to the predicated in the `display' group parameter."
7662 (unless gnus-newsgroup-display
7663 (error "There is no `display' group parameter"))
7665 (dolist (number gnus-newsgroup-articles)
7666 (when (funcall gnus-newsgroup-display)
7667 (push number articles)))
7668 (gnus-summary-limit articles))
7669 (gnus-summary-position-point))
7671 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7673 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7675 (defun gnus-summary-limit-to-unread (&optional all)
7676 "Limit the summary buffer to articles that are not marked as read.
7677 If ALL is non-nil, limit strictly to unread articles."
7680 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7681 (gnus-summary-limit-to-marks
7682 ;; Concat all the marks that say that an article is read and have
7684 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7685 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7686 gnus-low-score-mark gnus-expirable-mark
7687 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7688 gnus-duplicate-mark gnus-souped-mark)
7691 (defun gnus-summary-limit-to-replied (&optional unreplied)
7692 "Limit the summary buffer to replied articles.
7693 If UNREPLIED (the prefix), limit to unreplied articles."
7697 (gnus-set-difference gnus-newsgroup-articles
7698 gnus-newsgroup-replied))
7699 (gnus-summary-limit gnus-newsgroup-replied))
7700 (gnus-summary-position-point))
7702 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7703 (make-obsolete 'gnus-summary-delete-marked-with
7704 'gnus-summary-limit-exclude-marks)
7706 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7707 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7708 If REVERSE, limit the summary buffer to articles that are marked
7709 with MARKS. MARKS can either be a string of marks or a list of marks.
7710 Returns how many articles were removed."
7711 (interactive "sMarks: ")
7712 (gnus-summary-limit-to-marks marks t))
7714 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7715 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7716 If REVERSE (the prefix), limit the summary buffer to articles that are
7717 not marked with MARKS. MARKS can either be a string of marks or a
7719 Returns how many articles were removed."
7720 (interactive "sMarks: \nP")
7722 (let ((data gnus-newsgroup-data)
7723 (marks (if (listp marks) marks
7724 (append marks nil))) ; Transform to list.
7727 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7728 (memq (gnus-data-mark (car data)) marks))
7729 (push (gnus-data-number (car data)) articles))
7730 (setq data (cdr data)))
7731 (gnus-summary-limit articles))
7732 (gnus-summary-position-point)))
7734 (defun gnus-summary-limit-to-score (score)
7735 "Limit to articles with score at or above SCORE."
7736 (interactive "NLimit to articles with score of at least: ")
7737 (let ((data gnus-newsgroup-data)
7740 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7742 (push (gnus-data-number (car data)) articles))
7743 (setq data (cdr data)))
7745 (gnus-summary-limit articles)
7746 (gnus-summary-position-point))))
7748 (defun gnus-summary-limit-to-unseen ()
7749 "Limit to unseen articles."
7752 (gnus-summary-limit gnus-newsgroup-unseen)
7753 (gnus-summary-position-point)))
7755 (defun gnus-summary-limit-include-thread (id)
7756 "Display all the hidden articles that is in the thread with ID in it.
7757 When called interactively, ID is the Message-ID of the current
7759 (interactive (list (mail-header-id (gnus-summary-article-header))))
7760 (let ((articles (gnus-articles-in-thread
7761 (gnus-id-to-thread (gnus-root-id id)))))
7763 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7764 (gnus-summary-limit-include-matching-articles
7766 (regexp-quote (gnus-simplify-subject-re
7767 (mail-header-subject (gnus-id-to-header id)))))
7768 (gnus-summary-position-point))))
7770 (defun gnus-summary-limit-include-matching-articles (header regexp)
7771 "Display all the hidden articles that have HEADERs that match REGEXP."
7772 (interactive (list (read-string "Match on header: ")
7773 (read-string "Regexp: ")))
7774 (let ((articles (gnus-find-matching-articles header regexp)))
7776 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7777 (gnus-summary-position-point))))
7779 (defun gnus-summary-insert-dormant-articles ()
7780 "Insert all the dormant articles for this group into the current buffer."
7782 (let ((gnus-verbose (max 6 gnus-verbose)))
7783 (if (not gnus-newsgroup-dormant)
7784 (gnus-message 3 "No cached articles for this group")
7785 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7787 (defun gnus-summary-limit-include-dormant ()
7788 "Display all the hidden articles that are marked as dormant.
7789 Note that this command only works on a subset of the articles currently
7790 fetched for this group."
7792 (unless gnus-newsgroup-dormant
7793 (error "There are no dormant articles in this group"))
7795 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7796 (gnus-summary-position-point)))
7798 (defun gnus-summary-limit-exclude-dormant ()
7799 "Hide all dormant articles."
7802 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7803 (gnus-summary-position-point)))
7805 (defun gnus-summary-limit-exclude-childless-dormant ()
7806 "Hide all dormant articles that have no children."
7808 (let ((data (gnus-data-list t))
7809 articles d children)
7810 ;; Find all articles that are either not dormant or have
7812 (while (setq d (pop data))
7813 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7815 (gnus-article-children (gnus-data-number d)))
7818 (when (memq (car children) articles)
7823 (push (gnus-data-number d) articles)))
7826 (gnus-summary-limit articles)
7827 (gnus-summary-position-point))))
7829 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7830 "Mark all unread excluded articles as read.
7831 If ALL, mark even excluded ticked and dormants as read."
7833 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7834 (let ((articles (gnus-sorted-ndifference
7836 (mapcar (lambda (h) (mail-header-number h))
7837 gnus-newsgroup-headers)
7839 gnus-newsgroup-limit))
7841 (setq gnus-newsgroup-unreads
7842 (gnus-sorted-intersection gnus-newsgroup-unreads
7843 gnus-newsgroup-limit))
7845 (setq gnus-newsgroup-dormant nil
7846 gnus-newsgroup-marked nil
7847 gnus-newsgroup-reads
7849 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7850 gnus-newsgroup-reads))
7851 (while (setq article (pop articles))
7852 (unless (or (memq article gnus-newsgroup-dormant)
7853 (memq article gnus-newsgroup-marked))
7854 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7856 (defun gnus-summary-limit (articles &optional pop)
7858 ;; We pop the previous limit off the stack and use that.
7859 (setq articles (car gnus-newsgroup-limits)
7860 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7861 ;; We use the new limit, so we push the old limit on the stack.
7862 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7864 (setq gnus-newsgroup-limit articles)
7865 (let ((total (length gnus-newsgroup-data))
7866 (data (gnus-data-find-list (gnus-summary-article-number)))
7867 (gnus-summary-mark-below nil) ; Inhibit this.
7869 ;; This will do all the work of generating the new summary buffer
7870 ;; according to the new limit.
7871 (gnus-summary-prepare)
7872 ;; Hide any threads, possibly.
7873 (gnus-summary-maybe-hide-threads)
7874 ;; Try to return to the article you were at, or one in the
7877 ;; We try to find some article after the current one.
7879 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7882 (setq data (cdr data))))
7884 ;; If there is no data, that means that we were after the last
7885 ;; article. The same goes when we can't find any articles
7886 ;; after the current one.
7887 (goto-char (point-max))
7888 (gnus-summary-find-prev))
7889 (gnus-set-mode-line 'summary)
7890 ;; We return how many articles were removed from the summary
7891 ;; buffer as a result of the new limit.
7892 (- total (length gnus-newsgroup-data))))
7894 (defsubst gnus-invisible-cut-children (threads)
7897 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7902 (defsubst gnus-cut-thread (thread)
7903 "Go forwards in the thread until we find an article that we want to display."
7904 (when (or (eq gnus-fetch-old-headers 'some)
7905 (eq gnus-fetch-old-headers 'invisible)
7906 (numberp gnus-fetch-old-headers)
7907 (eq gnus-build-sparse-threads 'some)
7908 (eq gnus-build-sparse-threads 'more))
7909 ;; Deal with old-fetched headers and sparse threads.
7913 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7914 (gnus-summary-article-ancient-p
7915 (mail-header-number (car thread))))
7916 (if (or (<= (length (cdr thread)) 1)
7917 (eq gnus-fetch-old-headers 'invisible))
7918 (setq gnus-newsgroup-limit
7919 (delq (mail-header-number (car thread))
7920 gnus-newsgroup-limit)
7921 thread (cadr thread))
7922 (when (gnus-invisible-cut-children (cdr thread))
7923 (let ((th (cdr thread)))
7925 (if (memq (mail-header-number (caar th))
7926 gnus-newsgroup-limit)
7927 (setq thread (car th)
7929 (setq th (cdr th))))))))))
7932 (defun gnus-cut-threads (threads)
7933 "Cut off all uninteresting articles from the beginning of THREADS."
7934 (when (or (eq gnus-fetch-old-headers 'some)
7935 (eq gnus-fetch-old-headers 'invisible)
7936 (numberp gnus-fetch-old-headers)
7937 (eq gnus-build-sparse-threads 'some)
7938 (eq gnus-build-sparse-threads 'more))
7941 (setcar th (gnus-cut-thread (car th)))
7942 (setq th (cdr th)))))
7943 ;; Remove nixed out threads.
7946 (defun gnus-summary-initial-limit (&optional show-if-empty)
7947 "Figure out what the initial limit is supposed to be on group entry.
7948 This entails weeding out unwanted dormants, low-scored articles,
7949 fetch-old-headers verbiage, and so on."
7950 ;; Most groups have nothing to remove.
7951 (if (or gnus-inhibit-limiting
7952 (and (null gnus-newsgroup-dormant)
7953 (eq gnus-newsgroup-display 'gnus-not-ignore)
7954 (not (eq gnus-fetch-old-headers 'some))
7955 (not (numberp gnus-fetch-old-headers))
7956 (not (eq gnus-fetch-old-headers 'invisible))
7957 (null gnus-summary-expunge-below)
7958 (not (eq gnus-build-sparse-threads 'some))
7959 (not (eq gnus-build-sparse-threads 'more))
7960 (null gnus-thread-expunge-below)
7961 (not gnus-use-nocem)))
7963 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7964 (setq gnus-newsgroup-limit nil)
7967 (unless (car (symbol-value node))
7968 ;; These threads have no parents -- they are roots.
7969 (let ((nodes (cdr (symbol-value node)))
7972 (if (and gnus-thread-expunge-below
7973 (< (gnus-thread-total-score (car nodes))
7974 gnus-thread-expunge-below))
7975 (gnus-expunge-thread (pop nodes))
7976 (setq thread (pop nodes))
7977 (gnus-summary-limit-children thread))))))
7978 gnus-newsgroup-dependencies)
7979 ;; If this limitation resulted in an empty group, we might
7980 ;; pop the previous limit and use it instead.
7981 (when (and (not gnus-newsgroup-limit)
7983 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7984 gnus-newsgroup-limit))
7986 (defun gnus-summary-limit-children (thread)
7987 "Return 1 if this subthread is visible and 0 if it is not."
7988 ;; First we get the number of visible children to this thread. This
7989 ;; is done by recursing down the thread using this function, so this
7990 ;; will really go down to a leaf article first, before slowly
7991 ;; working its way up towards the root.
7993 (let* ((max-lisp-eval-depth 5000)
7996 (apply '+ (mapcar 'gnus-summary-limit-children
7999 (number (mail-header-number (car thread)))
8002 (not (memq number gnus-newsgroup-marked))
8004 ;; If this article is dormant and has absolutely no visible
8005 ;; children, then this article isn't visible.
8006 (and (memq number gnus-newsgroup-dormant)
8008 ;; If this is "fetch-old-headered" and there is no
8009 ;; visible children, then we don't want this article.
8010 (and (or (eq gnus-fetch-old-headers 'some)
8011 (numberp gnus-fetch-old-headers))
8012 (gnus-summary-article-ancient-p number)
8014 ;; If this is "fetch-old-headered" and `invisible', then
8015 ;; we don't want this article.
8016 (and (eq gnus-fetch-old-headers 'invisible)
8017 (gnus-summary-article-ancient-p number))
8018 ;; If this is a sparsely inserted article with no children,
8019 ;; we don't want it.
8020 (and (eq gnus-build-sparse-threads 'some)
8021 (gnus-summary-article-sparse-p number)
8023 ;; If we use expunging, and this article is really
8024 ;; low-scored, then we don't want this article.
8025 (when (and gnus-summary-expunge-below
8027 (or (cdr (assq number gnus-newsgroup-scored))
8028 gnus-summary-default-score))
8029 gnus-summary-expunge-below))
8030 ;; We increase the expunge-tally here, but that has
8031 ;; nothing to do with the limits, really.
8032 (incf gnus-newsgroup-expunged-tally)
8033 ;; We also mark as read here, if that's wanted.
8034 (when (and gnus-summary-mark-below
8035 (< score gnus-summary-mark-below))
8036 (setq gnus-newsgroup-unreads
8037 (delq number gnus-newsgroup-unreads))
8038 (if gnus-newsgroup-auto-expire
8039 (push number gnus-newsgroup-expirable)
8040 (push (cons number gnus-low-score-mark)
8041 gnus-newsgroup-reads)))
8043 ;; Do the `display' group parameter.
8044 (and gnus-newsgroup-display
8045 (not (funcall gnus-newsgroup-display)))
8046 ;; Check NoCeM things.
8047 (when (and gnus-use-nocem
8048 (gnus-nocem-unwanted-article-p
8049 (mail-header-id (car thread))))
8050 (setq gnus-newsgroup-unreads
8051 (delq number gnus-newsgroup-unreads))
8053 ;; Nope, invisible article.
8055 ;; Ok, this article is to be visible, so we add it to the limit
8057 (push number gnus-newsgroup-limit)
8060 (defun gnus-expunge-thread (thread)
8061 "Mark all articles in THREAD as read."
8062 (let* ((number (mail-header-number (car thread))))
8063 (incf gnus-newsgroup-expunged-tally)
8064 ;; We also mark as read here, if that's wanted.
8065 (setq gnus-newsgroup-unreads
8066 (delq number gnus-newsgroup-unreads))
8067 (if gnus-newsgroup-auto-expire
8068 (push number gnus-newsgroup-expirable)
8069 (push (cons number gnus-low-score-mark)
8070 gnus-newsgroup-reads)))
8071 ;; Go recursively through all subthreads.
8072 (mapcar 'gnus-expunge-thread (cdr thread)))
8074 ;; Summary article oriented commands
8076 (defun gnus-summary-refer-parent-article (n)
8077 "Refer parent article N times.
8078 If N is negative, go to ancestor -N instead.
8079 The difference between N and the number of articles fetched is returned."
8083 (when (not (natnump n))
8088 (setq header (gnus-summary-article-header))
8089 (if (and (eq (mail-header-number header)
8090 (cdr gnus-article-current))
8091 (equal gnus-newsgroup-name
8092 (car gnus-article-current)))
8093 ;; If we try to find the parent of the currently
8094 ;; displayed article, then we take a look at the actual
8095 ;; References header, since this is slightly more
8096 ;; reliable than the References field we got from the
8099 (set-buffer gnus-original-article-buffer)
8100 (nnheader-narrow-to-headers)
8101 (unless (setq ref (message-fetch-field "references"))
8102 (when (setq ref (message-fetch-field "in-reply-to"))
8103 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8106 ;; It's not the current article, so we take a bet on
8107 ;; the value we got from the server.
8108 (mail-header-references header)))
8110 (not (equal ref "")))
8111 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8112 (gnus-message 1 "Couldn't find parent"))
8113 (gnus-message 1 "No references in article %d"
8114 (gnus-summary-article-number))
8117 (gnus-summary-position-point)
8120 (defun gnus-summary-refer-references ()
8121 "Fetch all articles mentioned in the References header.
8122 Return the number of articles fetched."
8124 (let ((ref (mail-header-references (gnus-summary-article-header)))
8125 (current (gnus-summary-article-number))
8129 (error "No References in the current article")
8130 ;; For each Message-ID in the References header...
8131 (while (string-match "<[^>]*>" ref)
8133 ;; ... fetch that article.
8134 (gnus-summary-refer-article
8135 (prog1 (match-string 0 ref)
8136 (setq ref (substring ref (match-end 0))))))
8137 (gnus-summary-goto-subject current)
8138 (gnus-summary-position-point)
8141 (defun gnus-summary-refer-thread (&optional limit)
8142 "Fetch all articles in the current thread.
8143 If LIMIT (the numerical prefix), fetch that many old headers instead
8144 of what's specified by the `gnus-refer-thread-limit' variable."
8146 (let ((id (mail-header-id (gnus-summary-article-header)))
8147 (limit (if limit (prefix-numeric-value limit)
8148 gnus-refer-thread-limit)))
8149 (unless (eq gnus-fetch-old-headers 'invisible)
8150 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8151 ;; Retrieve the headers and read them in.
8152 (if (eq (if (numberp limit)
8153 (gnus-retrieve-headers
8155 (+ (mail-header-number
8156 (gnus-summary-article-header))
8158 gnus-newsgroup-end))
8159 gnus-newsgroup-name (* limit 2))
8160 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8162 (gnus-retrieve-headers (list gnus-newsgroup-end)
8163 gnus-newsgroup-name limit))
8165 (gnus-build-all-threads)
8166 (error "Can't fetch thread from back ends that don't support NOV"))
8167 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8168 (gnus-summary-limit-include-thread id)))
8170 (defun gnus-summary-refer-article (message-id)
8171 "Fetch an article specified by MESSAGE-ID."
8172 (interactive "sMessage-ID: ")
8173 (when (and (stringp message-id)
8174 (not (zerop (length message-id))))
8175 (setq message-id (gnus-replace-in-string message-id " " ""))
8176 ;; Construct the correct Message-ID if necessary.
8177 ;; Suggested by tale@pawl.rpi.edu.
8178 (unless (string-match "^<" message-id)
8179 (setq message-id (concat "<" message-id)))
8180 (unless (string-match ">$" message-id)
8181 (setq message-id (concat message-id ">")))
8182 ;; People often post MIDs from URLs, so unhex it:
8183 (unless (string-match "@" message-id)
8184 (setq message-id (gnus-url-unhex-string message-id)))
8185 (let* ((header (gnus-id-to-header message-id))
8187 (gnus-summary-article-sparse-p
8188 (mail-header-number header))
8189 (memq (mail-header-number header)
8190 gnus-newsgroup-limit)))
8193 ;; If the article is present in the buffer we just go to it.
8195 (or (not (gnus-summary-article-sparse-p
8196 (mail-header-number header)))
8199 (gnus-summary-goto-article
8200 (mail-header-number header) nil t)
8202 (gnus-summary-update-article (mail-header-number header)))))
8204 ;; We fetch the article.
8206 (dolist (gnus-override-method (gnus-refer-article-methods))
8207 (when (and (gnus-check-server gnus-override-method)
8208 ;; Fetch the header,
8209 (setq number (gnus-summary-insert-subject message-id)))
8210 ;; and display the article.
8211 (gnus-summary-select-article nil nil nil number)
8213 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8215 (defun gnus-refer-article-methods ()
8216 "Return a list of referable methods."
8218 ;; No method, so we default to current and native.
8219 ((null gnus-refer-article-method)
8220 (list gnus-current-select-method gnus-select-method))
8222 ((eq 'current gnus-refer-article-method)
8223 (list gnus-current-select-method))
8224 ;; List of select methods.
8225 ((not (and (symbolp (car gnus-refer-article-method))
8226 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8228 (dolist (method gnus-refer-article-method)
8229 (push (if (eq 'current method)
8230 gnus-current-select-method
8234 ;; One single select method.
8236 (list gnus-refer-article-method))))
8238 (defun gnus-summary-edit-parameters ()
8239 "Edit the group parameters of the current group."
8241 (gnus-group-edit-group gnus-newsgroup-name 'params))
8243 (defun gnus-summary-customize-parameters ()
8244 "Customize the group parameters of the current group."
8246 (gnus-group-customize gnus-newsgroup-name))
8248 (defun gnus-summary-enter-digest-group (&optional force)
8249 "Enter an nndoc group based on the current article.
8250 If FORCE, force a digest interpretation. If not, try
8251 to guess what the document format is."
8253 (let ((conf gnus-current-window-configuration))
8254 (save-window-excursion
8256 (let (gnus-article-prepare-hook
8257 gnus-display-mime-function
8259 (gnus-summary-select-article))))
8260 (setq gnus-current-window-configuration conf)
8261 (let* ((name (format "%s-%d"
8262 (gnus-group-prefixed-name
8263 gnus-newsgroup-name (list 'nndoc ""))
8265 (set-buffer gnus-summary-buffer)
8266 gnus-current-article)))
8267 (ogroup gnus-newsgroup-name)
8268 (params (append (gnus-info-params (gnus-get-info ogroup))
8269 (list (cons 'to-group ogroup))
8270 (list (cons 'parent-group ogroup))
8271 (list (cons 'save-article-group ogroup))))
8272 (case-fold-search t)
8273 (buf (current-buffer))
8276 (set-buffer gnus-original-article-buffer)
8277 ;; Have the digest group inherit the main mail address of
8278 ;; the parent article.
8279 (when (setq to-address (or (gnus-fetch-field "reply-to")
8280 (gnus-fetch-field "from")))
8281 (setq params (append
8282 (list (cons 'to-address
8283 (funcall gnus-decode-encoded-word-function
8285 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8286 (insert-buffer-substring gnus-original-article-buffer)
8287 ;; Remove lines that may lead nndoc to misinterpret the
8290 (goto-char (point-min))
8291 (or (search-forward "\n\n" nil t) (point)))
8292 (goto-char (point-min))
8293 (delete-matching-lines "^Path:\\|^From ")
8296 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8297 (gnus-newsgroup-ephemeral-ignored-charsets
8298 gnus-newsgroup-ignored-charsets))
8299 (gnus-group-read-ephemeral-group
8300 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8302 ,(if force 'mbox 'guess)))
8304 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8306 ;; Make all postings to this group go to the parent group.
8307 (nconc (gnus-info-params (gnus-get-info name))
8309 ;; Couldn't select this doc group.
8310 (switch-to-buffer buf)
8311 (gnus-set-global-variables)
8312 (gnus-configure-windows 'summary)
8313 (gnus-message 3 "Article couldn't be entered?"))
8314 (kill-buffer dig)))))
8316 (defun gnus-summary-read-document (n)
8317 "Open a new group based on the current article(s).
8318 This will allow you to read digests and other similar
8319 documents as newsgroups.
8320 Obeys the standard process/prefix convention."
8322 (let* ((articles (gnus-summary-work-articles n))
8323 (ogroup gnus-newsgroup-name)
8324 (params (append (gnus-info-params (gnus-get-info ogroup))
8325 (list (cons 'to-group ogroup))))
8326 article group egroup groups vgroup)
8327 (while (setq article (pop articles))
8328 (setq group (format "%s-%d" gnus-newsgroup-name article))
8329 (gnus-summary-remove-process-mark article)
8330 (when (gnus-summary-display-article article)
8333 (insert-buffer-substring gnus-original-article-buffer)
8334 ;; Remove some headers that may lead nndoc to make
8336 (message-narrow-to-head)
8337 (goto-char (point-min))
8338 (delete-matching-lines "^Path:\\|^From ")
8341 (gnus-group-read-ephemeral-group
8342 group `(nndoc ,group (nndoc-address ,(current-buffer))
8343 (nndoc-article-type guess))
8346 ;; Make all postings to this group go to the parent group.
8347 (nconc (gnus-info-params (gnus-get-info egroup))
8349 (push egroup groups))
8350 ;; Couldn't select this doc group.
8351 (gnus-error 3 "Article couldn't be entered"))))))
8352 ;; Now we have selected all the documents.
8355 (error "None of the articles could be interpreted as documents"))
8356 ((gnus-group-read-ephemeral-group
8357 (setq vgroup (format
8358 "nnvirtual:%s-%s" gnus-newsgroup-name
8359 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8360 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8362 (cons (current-buffer) 'summary)))
8364 (error "Couldn't select virtual nndoc group")))))
8366 (defun gnus-summary-isearch-article (&optional regexp-p)
8367 "Do incremental search forward on the current article.
8368 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8370 (let* ((gnus-inhibit-treatment t)
8371 (old (gnus-summary-select-article)))
8372 (gnus-configure-windows 'article)
8373 (gnus-eval-in-buffer-window gnus-article-buffer
8377 (gnus-article-show-all-headers))
8378 (goto-char (point-min))
8379 (isearch-forward regexp-p)))))
8381 (defun gnus-summary-search-article-forward (regexp &optional backward)
8382 "Search for an article containing REGEXP forward.
8383 If BACKWARD, search backward instead."
8386 (format "Search article %s (regexp%s): "
8387 (if current-prefix-arg "backward" "forward")
8388 (if gnus-last-search-regexp
8389 (concat ", default " gnus-last-search-regexp)
8391 current-prefix-arg))
8392 (if (string-equal regexp "")
8393 (setq regexp (or gnus-last-search-regexp ""))
8394 (setq gnus-last-search-regexp regexp)
8395 (setq gnus-article-before-search gnus-current-article))
8396 ;; Intentionally set gnus-last-article.
8397 (setq gnus-last-article gnus-article-before-search)
8398 (let ((gnus-last-article gnus-last-article))
8399 (if (gnus-summary-search-article regexp backward)
8400 (gnus-summary-show-thread)
8401 (error "Search failed: \"%s\"" regexp))))
8403 (defun gnus-summary-search-article-backward (regexp)
8404 "Search for an article containing REGEXP backward."
8407 (format "Search article backward (regexp%s): "
8408 (if gnus-last-search-regexp
8409 (concat ", default " gnus-last-search-regexp)
8411 (gnus-summary-search-article-forward regexp 'backward))
8414 (defmacro gnus-summary-search-article-position-point (regexp backward)
8415 "Dehighlight the last matched text and goto the beginning position."
8416 (` (if (and gnus-summary-search-article-matched-data
8417 (let ((text (caddr gnus-summary-search-article-matched-data))
8418 (inhibit-read-only t)
8421 (goto-char (car gnus-summary-search-article-matched-data))
8422 (cadr gnus-summary-search-article-matched-data))
8424 (string-match (, regexp) text)))
8425 (if (, backward) (beginning-of-line) (end-of-line))
8426 (goto-char (if (, backward) (point-max) (point-min))))))
8428 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8429 "Place point where X-Face image is displayed."
8430 (if (featurep 'xemacs)
8431 (` (let ((end (if (search-forward "\n\n" nil t)
8432 (goto-char (1- (point)))
8435 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8436 (unless (and (re-search-forward "^From:" end t)
8437 (setq extent (extent-at (point)))
8438 (extent-begin-glyph extent))
8439 (goto-char (, opoint)))))
8440 (` (let ((end (if (search-forward "\n\n" nil t)
8441 (goto-char (1- (point)))
8443 (start (or (search-backward "\n\n" nil t) (point-min))))
8445 (or (text-property-any start end 'x-face-image t);; x-face-e21
8446 (text-property-any start end 'x-face-mule-bitmap-image t)
8449 (defmacro gnus-summary-search-article-highlight-matched-text
8450 (backward treated x-face)
8451 "Highlight matched text in the function `gnus-summary-search-article'."
8452 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8453 (end (set-marker (make-marker) (match-end 0)))
8454 (inhibit-read-only t)
8458 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8460 (lambda (item) (setq items (delq item items)))
8461 '(gnus-treat-buttonize
8462 gnus-treat-fill-article
8463 gnus-treat-fill-long-lines
8464 gnus-treat-emphasize
8465 gnus-treat-highlight-headers
8466 gnus-treat-highlight-citation
8467 gnus-treat-highlight-signature
8468 gnus-treat-overstrike
8469 gnus-treat-display-x-face
8470 gnus-treat-buttonize-head
8471 gnus-treat-decode-article-as-default-mime-charset))
8472 (static-if (featurep 'xemacs)
8474 (cons '(x-face-mule-delete-x-face-field
8477 (gnus-treat-display-x-face
8478 (when (, x-face) gnus-treat-display-x-face)))
8479 (gnus-article-prepare-mime-display)))
8480 (goto-char (if (, backward) start end))
8482 (gnus-summary-search-article-highlight-goto-x-face (point)))
8483 (setq gnus-summary-search-article-matched-data
8484 (list start end (buffer-substring start end)))
8485 (unless (eq start end);; matched text has been deleted. :-<
8486 (put-text-property start end 'face
8487 (or (find-face 'isearch)
8488 'secondary-selection))))))
8491 (defun gnus-summary-search-article (regexp &optional backward)
8492 "Search for an article containing REGEXP.
8493 Optional argument BACKWARD means do search for backward.
8494 `gnus-select-article-hook' is not called during the search."
8495 ;; We have to require this here to make sure that the following
8496 ;; dynamic binding isn't shadowed by autoloading.
8497 (require 'gnus-async)
8499 (let ((gnus-select-article-hook nil) ;Disable hook.
8500 (gnus-article-prepare-hook nil)
8501 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8502 (gnus-use-article-prefetch nil)
8503 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8504 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8506 (gnus-keep-backlog nil)
8507 (gnus-break-pages nil)
8508 (gnus-summary-display-arrow nil)
8509 (gnus-updated-mode-lines nil)
8510 (gnus-auto-center-summary nil)
8511 (sum (current-buffer))
8514 (gnus-save-hidden-threads
8515 (static-if (featurep 'xemacs)
8516 (let ((gnus-inhibit-treatment t))
8517 (setq treated (eq 'old (gnus-summary-select-article)))
8519 (not (and (gnus-buffer-live-p gnus-article-buffer)
8520 (window-live-p (get-buffer-window
8521 gnus-article-buffer t)))))
8522 (gnus-summary-select-article nil t)
8523 (setq treated nil)))
8524 (let ((gnus-inhibit-treatment t)
8525 (x-face-mule-delete-x-face-field 'never))
8526 (setq treated (eq 'old (gnus-summary-select-article)))
8529 (and (gnus-buffer-live-p gnus-article-buffer)
8530 (window-live-p (get-buffer-window
8531 gnus-article-buffer t))
8532 (or (not (string-match "^\\^X-Face:" regexp))
8533 (with-current-buffer gnus-article-buffer
8534 gnus-summary-search-article-matched-data)))))
8535 (gnus-summary-select-article nil t)
8536 (setq treated nil))))
8537 (set-buffer gnus-article-buffer)
8541 (gnus-article-show-all-headers)
8542 (gnus-summary-search-article-position-point regexp backward))
8543 (goto-char (if backward (point-max) (point-min))))
8545 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8547 (re-search-backward regexp nil t)
8548 (re-search-forward regexp nil t))
8549 ;; We found the regexp.
8551 (gnus-summary-search-article-highlight-matched-text
8552 backward treated (string-match "^\\^X-Face:" regexp))
8555 (/ (- 2 (window-height
8556 (get-buffer-window gnus-article-buffer t)))
8559 (get-buffer-window (current-buffer))
8562 (setq point (point)))
8563 ;; We didn't find it, so we go to the next article.
8566 (while (eq found 'not)
8567 (if (not (if backward (gnus-summary-find-prev)
8568 (gnus-summary-find-next)))
8569 ;; No more articles.
8571 ;; Select the next article and adjust point.
8572 (unless (gnus-summary-article-sparse-p
8573 (gnus-summary-article-number))
8575 (let ((gnus-inhibit-treatment t))
8576 (gnus-summary-select-article))
8578 (set-buffer gnus-article-buffer)
8580 (goto-char (if backward (point-max) (point-min))))))))
8581 (gnus-message 7 ""))
8582 ;; Return whether we found the regexp.
8583 (when (eq found 'found)
8585 (gnus-summary-show-thread)
8586 (gnus-summary-goto-subject gnus-current-article)
8587 (gnus-summary-position-point)
8590 (defun gnus-find-matching-articles (header regexp)
8591 "Return a list of all articles that match REGEXP on HEADER.
8592 This search includes all articles in the current group that Gnus has
8593 fetched headers for, whether they are displayed or not."
8594 (let ((articles nil)
8595 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8596 (case-fold-search t))
8597 (dolist (header gnus-newsgroup-headers)
8598 (when (string-match regexp (funcall func header))
8599 (push (mail-header-number header) articles)))
8600 (nreverse articles)))
8602 (defun gnus-summary-find-matching (header regexp &optional backward unread
8603 not-case-fold not-matching)
8604 "Return a list of all articles that match REGEXP on HEADER.
8605 The search stars on the current article and goes forwards unless
8606 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8607 If UNREAD is non-nil, only unread articles will
8608 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8609 in the comparisons. If NOT-MATCHING, return a list of all articles that
8610 not match REGEXP on HEADER."
8611 (let ((case-fold-search (not not-case-fold))
8614 (if (eq (car header) 'extra)
8617 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8619 (error "%s is an invalid header" header))
8620 (unless (fboundp (intern (concat "mail-header-" header)))
8621 (error "%s is not a valid header" header))
8622 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8623 (dolist (d (if (eq backward 'all)
8625 (gnus-data-find-list
8626 (gnus-summary-article-number)
8627 (gnus-data-list backward))))
8628 (when (and (or (not unread) ; We want all articles...
8629 (gnus-data-unread-p d)) ; Or just unreads.
8630 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8634 (funcall func (gnus-data-header d))))
8635 (string-match regexp
8636 (funcall func (gnus-data-header d)))))
8637 (push (gnus-data-number d) articles))) ; Success!
8638 (nreverse articles)))
8640 (defun gnus-summary-execute-command (header regexp command &optional backward)
8641 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8642 If HEADER is an empty string (or nil), the match is done on the entire
8643 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8645 (list (let ((completion-ignore-case t))
8648 (mapcar (lambda (header) (list (format "%s" header)))
8650 '("Number" "Subject" "From" "Lines" "Date"
8651 "Message-ID" "Xref" "References" "Body")
8652 gnus-extra-headers))
8653 nil 'require-match))
8654 (read-string "Regexp: ")
8655 (read-key-sequence "Command: ")
8656 current-prefix-arg))
8657 (when (equal header "Body")
8659 ;; Hidden thread subtrees must be searched as well.
8660 (gnus-summary-show-all-threads)
8661 ;; We don't want to change current point nor window configuration.
8663 (save-window-excursion
8665 gnus-treat-strip-trailing-blank-lines
8666 gnus-treat-strip-leading-blank-lines
8667 gnus-treat-strip-multiple-blank-lines
8668 gnus-treat-hide-boring-headers
8669 gnus-treat-fold-newsgroups
8670 gnus-article-prepare-hook)
8671 (gnus-message 6 "Executing %s..." (key-description command))
8672 ;; We'd like to execute COMMAND interactively so as to give arguments.
8673 (gnus-execute header regexp
8674 `(call-interactively ',(key-binding command))
8676 (gnus-message 6 "Executing %s...done" (key-description command))))))
8678 (defun gnus-summary-beginning-of-article ()
8679 "Scroll the article back to the beginning."
8681 (gnus-summary-select-article)
8682 (gnus-configure-windows 'article)
8683 (gnus-eval-in-buffer-window gnus-article-buffer
8685 (goto-char (point-min))
8686 (when gnus-break-pages
8687 (gnus-narrow-to-page))))
8689 (defun gnus-summary-end-of-article ()
8690 "Scroll to the end of the article."
8692 (gnus-summary-select-article)
8693 (gnus-configure-windows 'article)
8694 (gnus-eval-in-buffer-window gnus-article-buffer
8696 (goto-char (point-max))
8698 (when gnus-break-pages
8699 (when (re-search-backward page-delimiter nil t)
8700 (narrow-to-region (match-end 0) (point-max)))
8701 (gnus-narrow-to-page))))
8703 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8704 "Truncate to LEN and quote all \"(\"'s in STRING."
8705 (gnus-replace-in-string (if (and len (> (length string) len))
8706 (substring string 0 len)
8710 (defun gnus-summary-print-article (&optional filename n)
8711 "Generate and print a PostScript image of the process-marked (mail) articles.
8713 If used interactively, print the current article if none are
8714 process-marked. With prefix arg, prompt the user for the name of the
8717 When used from Lisp, accept two optional args FILENAME and N. N means
8718 to print the next N articles. If N is negative, print the N previous
8719 articles. If N is nil and articles have been marked with the process
8720 mark, print these instead.
8722 If the optional first argument FILENAME is nil, send the image to the
8723 printer. If FILENAME is a string, save the PostScript image in a file with
8724 that name. If FILENAME is a number, prompt the user for the name of the file
8726 (interactive (list (ps-print-preprint current-prefix-arg)))
8727 (dolist (article (gnus-summary-work-articles n))
8728 (gnus-summary-select-article nil nil 'pseudo article)
8729 (gnus-eval-in-buffer-window gnus-article-buffer
8730 (gnus-print-buffer))
8731 (gnus-summary-remove-process-mark article))
8732 (ps-despool filename))
8734 (defun gnus-print-buffer ()
8735 (let ((buffer (generate-new-buffer " *print*")))
8738 (copy-to-buffer buffer (point-min) (point-max))
8740 (gnus-remove-text-with-property 'gnus-decoration)
8741 (when (gnus-visual-p 'article-highlight 'highlight)
8742 ;; Copy-to-buffer doesn't copy overlay. So redo
8744 (let ((gnus-article-buffer buffer))
8745 (gnus-article-highlight-citation t)
8746 (gnus-article-highlight-signature)
8747 (gnus-article-emphasize)
8748 (gnus-article-delete-invisible-text)))
8749 (let ((ps-left-header
8752 (gnus-summary-print-truncate-and-quote
8753 (mail-header-subject gnus-current-headers)
8756 (gnus-summary-print-truncate-and-quote
8757 (mail-header-from gnus-current-headers)
8761 "/pagenumberstring load"
8763 (mail-header-date gnus-current-headers) ")"))))
8764 (gnus-run-hooks 'gnus-ps-print-hook)
8767 (ps-spool-buffer-with-faces)
8768 (ps-spool-buffer)))))
8769 (kill-buffer buffer))))
8771 (defun gnus-summary-show-article (&optional arg)
8772 "Force redisplaying of the current article.
8773 If ARG (the prefix) is a number, show the article with the charset
8774 defined in `gnus-summary-show-article-charset-alist', or the charset
8776 If ARG (the prefix) is non-nil and not a number, show the raw article
8777 without any article massaging functions being run. Normally, the key
8778 strokes are `C-u g'."
8782 (gnus-summary-show-article t)
8783 (let* ((gnus-newsgroup-charset
8784 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8785 (mm-read-coding-system
8786 "View as charset: " ;; actually it is coding system.
8788 (set-buffer gnus-article-buffer)
8789 (mm-detect-coding-region (point) (point-max))))))
8790 (default-mime-charset gnus-newsgroup-charset)
8791 (gnus-newsgroup-ignored-charsets 'gnus-all))
8792 (gnus-summary-select-article nil 'force)
8793 (let ((deps gnus-newsgroup-dependencies)
8796 (set-buffer gnus-original-article-buffer)
8798 (message-narrow-to-head)
8799 (setq head (buffer-string))
8800 (goto-char (point-min))
8801 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8802 (goto-char (point-max))
8804 (setq lines (1- (count-lines (point) (point-max))))))
8806 (insert (format "211 %d Article retrieved.\n"
8807 (cdr gnus-article-current)))
8809 (if lines (insert (format "Lines: %d\n" lines)))
8811 (let ((nntp-server-buffer (current-buffer)))
8812 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8813 (gnus-data-set-header
8814 (gnus-data-find (cdr gnus-article-current))
8816 (gnus-summary-update-article-line
8817 (cdr gnus-article-current) header)
8818 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8819 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8821 ;; Select the article the normal way.
8822 (gnus-summary-select-article nil 'force))
8824 ;; We have to require this here to make sure that the following
8825 ;; dynamic binding isn't shadowed by autoloading.
8826 (require 'gnus-async)
8828 ;; Bind the article treatment functions to nil.
8829 (let ((gnus-have-all-headers t)
8830 gnus-article-prepare-hook
8831 gnus-article-decode-hook
8834 (gnus-inhibit-treatment t))
8835 (gnus-summary-select-article nil 'force))))
8836 (gnus-summary-goto-subject gnus-current-article)
8837 (gnus-summary-position-point))
8839 (defun gnus-summary-show-raw-article ()
8840 "Show the raw article without any article massaging functions being run."
8842 (gnus-summary-show-article t))
8844 (defun gnus-summary-verbose-headers (&optional arg)
8845 "Toggle permanent full header display.
8846 If ARG is a positive number, turn header display on.
8847 If ARG is a negative number, turn header display off."
8849 (setq gnus-show-all-headers
8850 (cond ((or (not (numberp arg))
8852 (not gnus-show-all-headers))
8855 (gnus-summary-show-article))
8857 (defun gnus-summary-toggle-header (&optional arg)
8858 "Show the headers if they are hidden, or hide them if they are shown.
8859 If ARG is a positive number, show the entire header.
8860 If ARG is a negative number, hide the unwanted header lines."
8862 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8863 (get-buffer-window gnus-article-buffer t))))
8864 (with-current-buffer gnus-article-buffer
8866 (article-narrow-to-head)
8867 (let* ((buffer-read-only nil)
8868 (inhibit-point-motion-hooks t)
8869 (hidden (if (numberp arg)
8871 (gnus-article-hidden-text-p 'headers)))
8873 (delete-region (point-min) (point-max))
8874 (with-current-buffer gnus-original-article-buffer
8875 (goto-char (setq s (point-min)))
8876 (setq e (if (search-forward "\n\n" nil t)
8879 (insert-buffer-substring gnus-original-article-buffer s e)
8880 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8881 ;; article-decode-encoded-words by default.
8882 (article-decode-encoded-words)
8883 (run-hooks 'gnus-article-decode-hook)
8885 (let ((gnus-treat-hide-headers nil)
8886 (gnus-treat-hide-boring-headers nil))
8887 (gnus-delete-wash-type 'headers)
8888 (gnus-treat-article 'head))
8889 (gnus-treat-article 'head))
8892 (set-window-start window (goto-char (point-min))))
8893 (if gnus-break-pages
8894 (gnus-narrow-to-page)
8895 (when (gnus-visual-p 'page-marker)
8896 (let ((buffer-read-only nil))
8897 (gnus-remove-text-with-property 'gnus-prev)
8898 (gnus-remove-text-with-property 'gnus-next))))
8899 (gnus-set-mode-line 'article)))))
8901 (defun gnus-summary-show-all-headers ()
8902 "Make all header lines visible."
8904 (gnus-summary-toggle-header 1))
8906 (defun gnus-summary-toggle-mime (&optional arg)
8907 "Toggle MIME processing.
8908 If ARG is a positive number, turn MIME processing on."
8910 (setq gnus-show-mime
8912 (not gnus-show-mime)
8913 (> (prefix-numeric-value arg) 0)))
8914 (gnus-summary-select-article t 'force))
8916 (defun gnus-summary-caesar-message (&optional arg)
8917 "Caesar rotate the current article by 13.
8918 The numerical prefix specifies how many places to rotate each letter
8921 (gnus-summary-select-article)
8922 (let ((mail-header-separator ""))
8923 (gnus-eval-in-buffer-window gnus-article-buffer
8926 (let ((start (window-start))
8928 (message-caesar-buffer-body arg)
8929 (set-window-start (get-buffer-window (current-buffer)) start))))))
8931 (autoload 'unmorse-region "morse"
8932 "Convert morse coded text in region to ordinary ASCII text."
8935 (defun gnus-summary-morse-message (&optional arg)
8936 "Morse decode the current article."
8938 (gnus-summary-select-article)
8939 (let ((mail-header-separator ""))
8940 (gnus-eval-in-buffer-window gnus-article-buffer
8944 (let ((pos (window-start))
8946 (goto-char (point-min))
8947 (when (message-goto-body)
8948 (gnus-narrow-to-body))
8949 (goto-char (point-min))
8950 (while (re-search-forward "·" (point-max) t)
8951 (replace-match "."))
8952 (unmorse-region (point-min) (point-max))
8954 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8956 (defun gnus-summary-stop-page-breaking ()
8957 "Stop page breaking in the current article."
8959 (gnus-summary-select-article)
8960 (gnus-eval-in-buffer-window gnus-article-buffer
8962 (when (gnus-visual-p 'page-marker)
8963 (let ((buffer-read-only nil))
8964 (gnus-remove-text-with-property 'gnus-prev)
8965 (gnus-remove-text-with-property 'gnus-next))
8966 (setq gnus-page-broken nil))))
8968 (defun gnus-summary-move-article (&optional n to-newsgroup
8969 select-method action)
8970 "Move the current article to a different newsgroup.
8971 If N is a positive number, move the N next articles.
8972 If N is a negative number, move the N previous articles.
8973 If N is nil and any articles have been marked with the process mark,
8974 move those articles instead.
8975 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8976 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8977 re-spool using this method.
8979 When called interactively with TO-NEWSGROUP being nil, the value of
8980 the variable `gnus-move-split-methods' is used for finding a default
8981 for the target newsgroup.
8983 For this function to work, both the current newsgroup and the
8984 newsgroup that you want to move to have to support the `request-move'
8985 and `request-accept' functions.
8987 ACTION can be either `move' (the default), `crosspost' or `copy'."
8990 (setq action 'move))
8991 ;; Check whether the source group supports the required functions.
8992 (cond ((and (eq action 'move)
8993 (not (gnus-check-backend-function
8994 'request-move-article gnus-newsgroup-name)))
8995 (error "The current group does not support article moving"))
8996 ((and (eq action 'crosspost)
8997 (not (gnus-check-backend-function
8998 'request-replace-article gnus-newsgroup-name)))
8999 (error "The current group does not support article editing")))
9000 (let ((articles (gnus-summary-work-articles n))
9001 (prefix (if (gnus-check-backend-function
9002 'request-move-article gnus-newsgroup-name)
9003 (funcall gnus-move-group-prefix-function
9004 gnus-newsgroup-name)
9006 (names '((move "Move" "Moving")
9007 (copy "Copy" "Copying")
9008 (crosspost "Crosspost" "Crossposting")))
9009 (copy-buf (save-excursion
9010 (nnheader-set-temp-buffer " *copy article*")))
9011 art-group to-method new-xref article to-groups)
9012 (unless (assq action names)
9013 (error "Unknown action %s" action))
9014 ;; Read the newsgroup name.
9015 (when (and (not to-newsgroup)
9016 (not select-method))
9017 (if (and gnus-move-split-methods
9019 (and (memq gnus-current-article articles)
9020 (gnus-buffer-live-p gnus-original-article-buffer))))
9021 ;; When `gnus-move-split-methods' is non-nil, we have to
9022 ;; select an article to give `gnus-read-move-group-name' an
9023 ;; opportunity to suggest an appropriate default. However,
9024 ;; we needn't render or mark the article.
9025 (let ((gnus-display-mime-function nil)
9026 (gnus-article-prepare-hook nil)
9027 (gnus-mark-article-hook nil))
9028 (gnus-summary-select-article nil nil nil (car articles))))
9030 (gnus-read-move-group-name
9031 (cadr (assq action names))
9032 (symbol-value (intern (format "gnus-current-%s-group" action)))
9034 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9035 (setq to-method (or select-method
9036 (gnus-server-to-method
9037 (gnus-group-method to-newsgroup))))
9038 ;; Check the method we are to move this article to...
9039 (unless (gnus-check-backend-function
9040 'request-accept-article (car to-method))
9041 (error "%s does not support article copying" (car to-method)))
9042 (unless (gnus-check-server to-method)
9043 (error "Can't open server %s" (car to-method)))
9044 (gnus-message 6 "%s to %s: %s..."
9045 (caddr (assq action names))
9046 (or (car select-method) to-newsgroup) articles)
9048 (setq article (pop articles))
9052 ;; Move the article.
9054 ;; Remove this article from future suppression.
9055 (gnus-dup-unsuppress-article article)
9056 (gnus-request-move-article
9057 article ; Article to move
9058 gnus-newsgroup-name ; From newsgroup
9059 (nth 1 (gnus-find-method-for-group
9060 gnus-newsgroup-name)) ; Server
9061 (list 'gnus-request-accept-article
9062 to-newsgroup (list 'quote select-method)
9063 (not articles) t) ; Accept form
9064 (not articles))) ; Only save nov last time
9065 ;; Copy the article.
9068 (set-buffer copy-buf)
9069 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9070 (gnus-request-accept-article
9071 to-newsgroup select-method (not articles) t))))
9072 ;; Crosspost the article.
9073 ((eq action 'crosspost)
9074 (let ((xref (message-tokenize-header
9075 (mail-header-xref (gnus-summary-article-header article))
9077 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9078 ":" (number-to-string article)))
9080 (setq xref (list (system-name))))
9083 (mapconcat 'identity
9084 (delete "Xref:" (delete new-xref xref))
9088 (set-buffer copy-buf)
9089 ;; First put the article in the destination group.
9090 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9091 (when (consp (setq art-group
9092 (gnus-request-accept-article
9093 to-newsgroup select-method (not articles))))
9094 (setq new-xref (concat new-xref " " (car art-group)
9096 (number-to-string (cdr art-group))))
9097 ;; Now we have the new Xrefs header, so we insert
9098 ;; it and replace the new article.
9099 (nnheader-replace-header "Xref" new-xref)
9100 (gnus-request-replace-article
9101 (cdr art-group) to-newsgroup (current-buffer))
9105 (gnus-message 1 "Couldn't %s article %s: %s"
9106 (cadr (assq action names)) article
9107 (nnheader-get-report (car to-method))))
9108 ((eq art-group 'junk)
9109 (when (eq action 'move)
9110 (gnus-summary-mark-article article gnus-canceled-mark)
9111 (gnus-message 4 "Deleted article %s" article)
9112 ;; run the delete hook
9113 (run-hook-with-args 'gnus-summary-article-delete-hook
9116 (assoc article (gnus-data-list nil)))
9117 gnus-newsgroup-name nil
9120 (let* ((pto-group (gnus-group-prefixed-name
9121 (car art-group) to-method))
9122 (info (gnus-get-info pto-group))
9123 (to-group (gnus-info-group info))
9125 ;; Update the group that has been moved to.
9127 (memq action '(move copy)))
9128 (unless (member to-group to-groups)
9129 (push to-group to-groups))
9131 (unless (memq article gnus-newsgroup-unreads)
9132 (push 'read to-marks)
9134 info (gnus-add-to-range (gnus-info-read info)
9135 (list (cdr art-group)))))
9137 ;; See whether the article is to be put in the cache.
9138 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9139 gnus-article-mark-lists
9140 (delete '(expirable . expire)
9141 (copy-sequence gnus-article-mark-lists))))
9142 (to-article (cdr art-group)))
9144 ;; Enter the article into the cache in the new group,
9145 ;; if that is required.
9146 (when gnus-use-cache
9147 (gnus-cache-possibly-enter-article
9149 (let ((header (copy-sequence
9150 (gnus-summary-article-header article))))
9151 (mail-header-set-number header to-article)
9153 (memq article gnus-newsgroup-marked)
9154 (memq article gnus-newsgroup-dormant)
9155 (memq article gnus-newsgroup-unreads)))
9157 (when gnus-preserve-marks
9158 ;; Copy any marks over to the new group.
9159 (when (and (equal to-group gnus-newsgroup-name)
9160 (not (memq article gnus-newsgroup-unreads)))
9161 ;; Mark this article as read in this group.
9162 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9163 (setcdr (gnus-active to-group) to-article)
9164 (setcdr gnus-newsgroup-active to-article))
9167 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9168 (when (memq article (symbol-value
9169 (intern (format "gnus-newsgroup-%s"
9171 (push (cdar marks) to-marks)
9172 ;; If the other group is the same as this group,
9173 ;; then we have to add the mark to the list.
9174 (when (equal to-group gnus-newsgroup-name)
9175 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9178 (intern (format "gnus-newsgroup-%s"
9180 ;; Copy the marks to other group.
9181 (gnus-add-marked-articles
9182 to-group (cdar marks) (list to-article) info)))
9183 (setq marks (cdr marks)))
9185 (gnus-request-set-mark
9186 to-group (list (list (list to-article) 'add to-marks))))
9189 (concat "(gnus-group-set-info '"
9190 (gnus-prin1-to-string (gnus-get-info to-group))
9193 ;; Update the Xref header in this article to point to
9194 ;; the new crossposted article we have just created.
9195 (when (eq action 'crosspost)
9197 (set-buffer copy-buf)
9198 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9199 (nnheader-replace-header "Xref" new-xref)
9200 (gnus-request-replace-article
9201 article gnus-newsgroup-name (current-buffer))))
9203 ;; run the move/copy/crosspost/respool hook
9204 (run-hook-with-args 'gnus-summary-article-move-hook
9207 (assoc article (gnus-data-list nil)))
9212 ;;;!!!Why is this necessary?
9213 (set-buffer gnus-summary-buffer)
9215 (gnus-summary-goto-subject article)
9216 (when (eq action 'move)
9217 (gnus-summary-mark-article article gnus-canceled-mark))))
9218 (gnus-summary-remove-process-mark article))
9219 ;; Re-activate all groups that have been moved to.
9221 (set-buffer gnus-group-buffer)
9222 (let ((gnus-group-marked to-groups))
9223 (gnus-group-get-new-news-this-group nil t)))
9225 (gnus-kill-buffer copy-buf)
9226 (gnus-summary-position-point)
9227 (gnus-set-mode-line 'summary)))
9229 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9230 "Move the current article to a different newsgroup.
9231 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9232 When called interactively, if TO-NEWSGROUP is nil, use the value of
9233 the variable `gnus-move-split-methods' for finding a default target
9235 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9236 re-spool using this method."
9238 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9240 (defun gnus-summary-crosspost-article (&optional n)
9241 "Crosspost the current article to some other group."
9243 (gnus-summary-move-article n nil nil 'crosspost))
9245 (defcustom gnus-summary-respool-default-method nil
9246 "Default method type for respooling an article.
9247 If nil, use to the current newsgroup method."
9249 :group 'gnus-summary-mail)
9251 (defcustom gnus-summary-display-while-building nil
9252 "If non-nil, show and update the summary buffer as it's being built.
9253 If the value is t, update the buffer after every line is inserted. If
9254 the value is an integer (N), update the display every N lines."
9256 :type '(choice (const :tag "off" nil)
9258 (const :tag "frequently" t)))
9260 (defun gnus-summary-respool-article (&optional n method)
9261 "Respool the current article.
9262 The article will be squeezed through the mail spooling process again,
9263 which means that it will be put in some mail newsgroup or other
9264 depending on `nnmail-split-methods'.
9265 If N is a positive number, respool the N next articles.
9266 If N is a negative number, respool the N previous articles.
9267 If N is nil and any articles have been marked with the process mark,
9268 respool those articles instead.
9270 Respooling can be done both from mail groups and \"real\" newsgroups.
9271 In the former case, the articles in question will be moved from the
9272 current group into whatever groups they are destined to. In the
9273 latter case, they will be copied into the relevant groups."
9275 (list current-prefix-arg
9276 (let* ((methods (gnus-methods-using 'respool))
9278 (symbol-name (or gnus-summary-respool-default-method
9279 (car (gnus-find-method-for-group
9280 gnus-newsgroup-name)))))
9282 (gnus-completing-read-with-default
9283 methname "What backend do you want to use when respooling?"
9284 methods nil t nil 'gnus-mail-method-history))
9287 ((zerop (length (setq ms (gnus-servers-using-backend
9289 (list (intern method) ""))
9293 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9294 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9297 (error "No method given for respooling"))
9298 (if (assoc (symbol-name
9299 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9300 (gnus-methods-using 'respool))
9301 (gnus-summary-move-article n nil method)
9302 (gnus-summary-copy-article n nil method)))
9304 (defun gnus-summary-import-article (file &optional edit)
9305 "Import an arbitrary file into a mail newsgroup."
9306 (interactive "fImport file: \nP")
9307 (let ((group gnus-newsgroup-name)
9308 (now (current-time))
9309 atts lines group-art)
9310 (unless (gnus-check-backend-function 'request-accept-article group)
9311 (error "%s does not support article importing" group))
9312 (or (file-readable-p file)
9313 (not (file-regular-p file))
9314 (error "Can't read %s" file))
9316 (set-buffer (gnus-get-buffer-create " *import file*"))
9318 (nnheader-insert-file-contents file)
9319 (goto-char (point-min))
9320 (if (nnheader-article-p)
9322 (goto-char (point-min))
9323 (search-forward "\n\n" nil t)
9324 (narrow-to-region (point-min) (1- (point)))
9325 (goto-char (point-min))
9326 (unless (re-search-forward "^date:" nil t)
9327 (goto-char (point-max))
9328 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9329 ;; This doesn't look like an article, so we fudge some headers.
9330 (setq atts (file-attributes file)
9331 lines (count-lines (point-min) (point-max)))
9332 (insert "From: " (read-string "From: ") "\n"
9333 "Subject: " (read-string "Subject: ") "\n"
9334 "Date: " (message-make-date (nth 5 atts)) "\n"
9335 "Message-ID: " (message-make-message-id) "\n"
9336 "Lines: " (int-to-string lines) "\n"
9337 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9338 (setq group-art (gnus-request-accept-article group nil t))
9339 (kill-buffer (current-buffer)))
9340 (setq gnus-newsgroup-active (gnus-activate-group group))
9342 (gnus-summary-goto-article (cdr group-art) nil t)
9344 (gnus-summary-edit-article))))
9346 (defun gnus-summary-create-article ()
9347 "Create an article in a mail newsgroup."
9349 (let ((group gnus-newsgroup-name)
9350 (now (current-time))
9352 (unless (gnus-check-backend-function 'request-accept-article group)
9353 (error "%s does not support article importing" group))
9355 (set-buffer (gnus-get-buffer-create " *import file*"))
9357 (goto-char (point-min))
9358 ;; This doesn't look like an article, so we fudge some headers.
9359 (insert "From: " (read-string "From: ") "\n"
9360 "Subject: " (read-string "Subject: ") "\n"
9361 "Date: " (message-make-date now) "\n"
9362 "Message-ID: " (message-make-message-id) "\n")
9363 (setq group-art (gnus-request-accept-article group nil t))
9364 (kill-buffer (current-buffer)))
9365 (setq gnus-newsgroup-active (gnus-activate-group group))
9367 (gnus-summary-goto-article (cdr group-art) nil t)
9368 (gnus-summary-edit-article)))
9370 (defun gnus-summary-article-posted-p ()
9371 "Say whether the current (mail) article is available from news as well.
9372 This will be the case if the article has both been mailed and posted."
9374 (let ((id (mail-header-references (gnus-summary-article-header)))
9375 (gnus-override-method (car (gnus-refer-article-methods))))
9376 (if (gnus-request-head id "")
9377 (gnus-message 2 "The current message was found on %s"
9378 gnus-override-method)
9379 (gnus-message 2 "The current message couldn't be found on %s"
9380 gnus-override-method)
9383 (defun gnus-summary-expire-articles (&optional now)
9384 "Expire all articles that are marked as expirable in the current group."
9386 (when (and (not gnus-group-is-exiting-without-update-p)
9387 (gnus-check-backend-function
9388 'request-expire-articles gnus-newsgroup-name))
9389 ;; This backend supports expiry.
9390 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9391 (expirable (if total
9393 ;; We need to update the info for
9394 ;; this group for `gnus-list-of-read-articles'
9395 ;; to give us the right answer.
9396 (gnus-run-hooks 'gnus-exit-group-hook)
9397 (gnus-summary-update-info)
9398 (gnus-list-of-read-articles gnus-newsgroup-name))
9399 (setq gnus-newsgroup-expirable
9400 (sort gnus-newsgroup-expirable '<))))
9401 (expiry-wait (if now 'immediate
9402 (gnus-group-find-parameter
9403 gnus-newsgroup-name 'expiry-wait)))
9404 (nnmail-expiry-target
9405 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9406 nnmail-expiry-target))
9409 ;; There are expirable articles in this group, so we run them
9410 ;; through the expiry process.
9411 (gnus-message 6 "Expiring articles...")
9412 (unless (gnus-check-group gnus-newsgroup-name)
9413 (error "Can't open server for %s" gnus-newsgroup-name))
9414 ;; The list of articles that weren't expired is returned.
9417 (let ((nnmail-expiry-wait-function nil)
9418 (nnmail-expiry-wait expiry-wait))
9419 (setq es (gnus-request-expire-articles
9420 expirable gnus-newsgroup-name)))
9421 (setq es (gnus-request-expire-articles
9422 expirable gnus-newsgroup-name)))
9424 (setq gnus-newsgroup-expirable es))
9425 ;; We go through the old list of expirable, and mark all
9426 ;; really expired articles as nonexistent.
9427 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9428 (let ((gnus-use-cache nil))
9429 (dolist (article expirable)
9430 (when (and (not (memq article es))
9431 (gnus-data-find article))
9432 (gnus-summary-mark-article article gnus-canceled-mark)
9433 (run-hook-with-args 'gnus-summary-article-expire-hook
9436 (assoc article (gnus-data-list nil)))
9440 (gnus-message 6 "Expiring articles...done")))))
9442 (defun gnus-summary-expire-articles-now ()
9443 "Expunge all expirable articles in the current group.
9444 This means that *all* articles that are marked as expirable will be
9445 deleted forever, right now."
9447 (or gnus-expert-user
9449 "Are you really, really, really sure you want to delete all these messages? ")
9451 (gnus-summary-expire-articles t))
9453 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9454 (defun gnus-summary-delete-article (&optional n)
9455 "Delete the N next (mail) articles.
9456 This command actually deletes articles. This is not a marking
9457 command. The article will disappear forever from your life, never to
9460 If N is negative, delete backwards.
9461 If N is nil and articles have been marked with the process mark,
9462 delete these instead.
9464 If `gnus-novice-user' is non-nil you will be asked for
9465 confirmation before the articles are deleted."
9467 (unless (gnus-check-backend-function 'request-expire-articles
9468 gnus-newsgroup-name)
9469 (error "The current newsgroup does not support article deletion"))
9470 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9471 (error "Couldn't open server"))
9472 ;; Compute the list of articles to delete.
9473 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9474 (nnmail-expiry-target 'delete)
9476 (if (and gnus-novice-user
9477 (not (gnus-yes-or-no-p
9478 (format "Do you really want to delete %s forever? "
9479 (if (> (length articles) 1)
9480 (format "these %s articles" (length articles))
9483 ;; Delete the articles.
9484 (setq not-deleted (gnus-request-expire-articles
9485 articles gnus-newsgroup-name 'force))
9487 (gnus-summary-remove-process-mark (car articles))
9488 ;; The backend might not have been able to delete the article
9490 (unless (memq (car articles) not-deleted)
9491 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9492 (let* ((article (car articles))
9493 (id (mail-header-id (gnus-data-header
9494 (assoc article (gnus-data-list nil))))))
9495 (run-hook-with-args 'gnus-summary-article-delete-hook
9496 'delete id gnus-newsgroup-name nil
9498 (setq articles (cdr articles)))
9500 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9501 (gnus-summary-position-point)
9502 (gnus-set-mode-line 'summary)
9505 (defun gnus-summary-edit-article (&optional force)
9506 "Edit the current article.
9507 This will have permanent effect only in mail groups.
9508 If FORCE is non-nil, allow editing of articles even in read-only
9512 (set-buffer gnus-summary-buffer)
9513 (let ((mail-parse-charset gnus-newsgroup-charset)
9514 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9515 (gnus-set-global-variables)
9516 (when (and (not force)
9517 (gnus-group-read-only-p))
9518 (error "The current newsgroup does not support article editing"))
9519 (gnus-summary-show-article t)
9520 (gnus-article-edit-article
9522 `(lambda (no-highlight)
9523 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9524 (message-options message-options)
9525 (message-options-set-recipient)
9526 (mail-parse-ignored-charsets
9527 ',gnus-newsgroup-ignored-charsets))
9528 (gnus-summary-edit-article-done
9529 ,(or (mail-header-references gnus-current-headers) "")
9530 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9532 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9534 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9536 "Make edits to the current article permanent."
9539 ;; The buffer restriction contains the entire article if it exists.
9540 (when (article-goto-body)
9541 (let ((lines (count-lines (point) (point-max)))
9542 (length (- (point-max) (point)))
9543 (case-fold-search t)
9544 (body (copy-marker (point))))
9545 (goto-char (point-min))
9546 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9547 (delete-region (match-beginning 1) (match-end 1))
9548 (insert (number-to-string length)))
9549 (goto-char (point-min))
9550 (when (re-search-forward
9551 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9552 (delete-region (match-beginning 1) (match-end 1))
9553 (insert (number-to-string length)))
9554 (goto-char (point-min))
9555 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9556 (delete-region (match-beginning 1) (match-end 1))
9557 (insert (number-to-string lines))))))
9558 ;; Replace the article.
9559 (let ((buf (current-buffer)))
9561 (insert-buffer-substring buf)
9563 (if (and (not read-only)
9564 (not (gnus-request-replace-article
9565 (cdr gnus-article-current) (car gnus-article-current)
9566 (current-buffer) t)))
9567 (error "Couldn't replace article")
9568 ;; Update the summary buffer.
9570 (equal (message-tokenize-header references " ")
9571 (message-tokenize-header
9572 (or (message-fetch-field "references") "") " ")))
9573 ;; We only have to update this line.
9576 (message-narrow-to-head)
9577 (let ((head (buffer-string))
9580 (insert (format "211 %d Article retrieved.\n"
9581 (cdr gnus-article-current)))
9584 (let ((nntp-server-buffer (current-buffer)))
9585 (setq header (car (gnus-get-newsgroup-headers
9588 (set-buffer gnus-summary-buffer)
9589 (gnus-data-set-header
9590 (gnus-data-find (cdr gnus-article-current))
9592 (gnus-summary-update-article-line
9593 (cdr gnus-article-current) header)
9594 (if (gnus-summary-goto-subject
9595 (cdr gnus-article-current) nil t)
9596 (gnus-summary-update-secondary-mark
9597 (cdr gnus-article-current))))))))
9599 (set-buffer (or buffer gnus-summary-buffer))
9600 (gnus-summary-update-article (cdr gnus-article-current))
9601 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9602 (gnus-summary-update-secondary-mark
9603 (cdr gnus-article-current))))
9604 ;; Prettify the article buffer again.
9605 (unless no-highlight
9607 (set-buffer gnus-article-buffer)
9608 ;;;!!! Fix this -- article should be rehighlighted.
9609 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9610 (set-buffer gnus-original-article-buffer)
9611 (gnus-request-article
9612 (cdr gnus-article-current)
9613 (car gnus-article-current) (current-buffer))))
9614 ;; Prettify the summary buffer line.
9615 (when (gnus-visual-p 'summary-highlight 'highlight)
9616 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9618 (defun gnus-summary-edit-wash (key)
9619 "Perform editing command KEY in the article buffer."
9623 (message "%s" (concat (this-command-keys) "- "))
9626 (gnus-summary-edit-article)
9627 (execute-kbd-macro (concat (this-command-keys) key))
9628 (gnus-article-edit-done))
9632 (defun gnus-summary-respool-query (&optional silent trace)
9633 "Query where the respool algorithm would put this article."
9635 (let (gnus-mark-article-hook)
9636 (gnus-summary-select-article)
9638 (set-buffer gnus-original-article-buffer)
9639 (let ((groups (nnmail-article-group 'identity trace)))
9642 (message "This message would go to %s"
9643 (mapconcat 'car groups ", "))
9644 (message "This message would go to no groups"))
9647 (defun gnus-summary-respool-trace ()
9648 "Trace where the respool algorithm would put this article.
9649 Display a buffer showing all fancy splitting patterns which matched."
9651 (gnus-summary-respool-query nil t))
9653 ;; Summary marking commands.
9655 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9656 "Mark articles which has the same subject as read, and then select the next.
9657 If UNMARK is positive, remove any kind of mark.
9658 If UNMARK is negative, tick articles."
9661 (setq unmark (prefix-numeric-value unmark)))
9663 (gnus-summary-mark-same-subject
9664 (gnus-summary-article-subject) unmark)))
9665 ;; Select next unread article. If auto-select-same mode, should
9666 ;; select the first unread article.
9667 (gnus-summary-next-article t (and gnus-auto-select-same
9668 (gnus-summary-article-subject)))
9669 (gnus-message 7 "%d article%s marked as %s"
9670 count (if (= count 1) " is" "s are")
9671 (if unmark "unread" "read"))))
9673 (defun gnus-summary-kill-same-subject (&optional unmark)
9674 "Mark articles which has the same subject as read.
9675 If UNMARK is positive, remove any kind of mark.
9676 If UNMARK is negative, tick articles."
9679 (setq unmark (prefix-numeric-value unmark)))
9681 (gnus-summary-mark-same-subject
9682 (gnus-summary-article-subject) unmark)))
9683 ;; If marked as read, go to next unread subject.
9685 ;; Go to next unread subject.
9686 (gnus-summary-next-subject 1 t))
9687 (gnus-message 7 "%d articles are marked as %s"
9688 count (if unmark "unread" "read"))))
9690 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9691 "Mark articles with same SUBJECT as read, and return marked number.
9692 If optional argument UNMARK is positive, remove any kinds of marks.
9693 If optional argument UNMARK is negative, mark articles as unread instead."
9697 ((null unmark) ; Mark as read.
9700 (gnus-summary-mark-article-as-read gnus-killed-mark)
9701 (gnus-summary-show-thread) t)
9702 (gnus-summary-find-subject subject))
9703 (setq count (1+ count))))
9704 ((> unmark 0) ; Tick.
9707 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9708 (gnus-summary-show-thread) t)
9709 (gnus-summary-find-subject subject))
9710 (setq count (1+ count))))
9711 (t ; Mark as unread.
9714 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9715 (gnus-summary-show-thread) t)
9716 (gnus-summary-find-subject subject))
9717 (setq count (1+ count)))))
9718 (gnus-set-mode-line 'summary)
9719 ;; Return the number of marked articles.
9722 (defun gnus-summary-mark-as-processable (n &optional unmark)
9723 "Set the process mark on the next N articles.
9724 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9725 the process mark instead. The difference between N and the actual
9726 number of articles marked is returned."
9728 (if (and (null n) (gnus-region-active-p))
9729 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9730 (setq n (prefix-numeric-value n))
9731 (let ((backward (< n 0))
9736 (gnus-summary-remove-process-mark
9737 (gnus-summary-article-number))
9738 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9739 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9742 (gnus-message 7 "No more articles"))
9743 (gnus-summary-recenter)
9744 (gnus-summary-position-point)
9747 (defun gnus-summary-unmark-as-processable (n)
9748 "Remove the process mark from the next N articles.
9749 If N is negative, unmark backward instead. The difference between N and
9750 the actual number of articles unmarked is returned."
9752 (gnus-summary-mark-as-processable n t))
9754 (defun gnus-summary-unmark-all-processable ()
9755 "Remove the process mark from all articles."
9758 (while gnus-newsgroup-processable
9759 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9760 (gnus-summary-position-point))
9762 (defun gnus-summary-add-mark (article type)
9763 "Mark ARTICLE with a mark of TYPE."
9764 (let ((vtype (car (assq type gnus-article-mark-lists)))
9767 (error "No such mark type: %s" type)
9768 (setq var (intern (format "gnus-newsgroup-%s" type)))
9769 (set var (cons article (symbol-value var)))
9770 (if (memq type '(processable cached replied forwarded recent saved))
9771 (gnus-summary-update-secondary-mark article)
9772 ;;; !!! This is bogus. We should find out what primary
9773 ;;; !!! mark we want to set.
9774 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9776 (defun gnus-summary-mark-as-expirable (n)
9777 "Mark N articles forward as expirable.
9778 If N is negative, mark backward instead. The difference between N and
9779 the actual number of articles marked is returned."
9781 (gnus-summary-mark-forward n gnus-expirable-mark))
9783 (defun gnus-summary-mark-as-spam (n)
9784 "Mark N articles forward as spam.
9785 If N is negative, mark backward instead. The difference between N and
9786 the actual number of articles marked is returned."
9788 (gnus-summary-mark-forward n gnus-spam-mark))
9790 (defun gnus-summary-mark-article-as-replied (article)
9791 "Mark ARTICLE as replied to and update the summary line.
9792 ARTICLE can also be a list of articles."
9793 (interactive (list (gnus-summary-article-number)))
9794 (let ((articles (if (listp article) article (list article))))
9795 (dolist (article articles)
9796 (unless (numberp article)
9797 (error "%s is not a number" article))
9798 (push article gnus-newsgroup-replied)
9799 (let ((buffer-read-only nil))
9800 (when (gnus-summary-goto-subject article nil t)
9801 (gnus-summary-update-secondary-mark article))))))
9803 (defun gnus-summary-mark-article-as-forwarded (article)
9804 "Mark ARTICLE as forwarded and update the summary line.
9805 ARTICLE can also be a list of articles."
9806 (let ((articles (if (listp article) article (list article))))
9807 (dolist (article articles)
9808 (push article gnus-newsgroup-forwarded)
9809 (let ((buffer-read-only nil))
9810 (when (gnus-summary-goto-subject article nil t)
9811 (gnus-summary-update-secondary-mark article))))))
9813 (defun gnus-summary-set-bookmark (article)
9814 "Set a bookmark in current article."
9815 (interactive (list (gnus-summary-article-number)))
9816 (when (or (not (get-buffer gnus-article-buffer))
9817 (not gnus-current-article)
9818 (not gnus-article-current)
9819 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9820 (error "No current article selected"))
9821 ;; Remove old bookmark, if one exists.
9822 (gnus-pull article gnus-newsgroup-bookmarks)
9823 ;; Set the new bookmark, which is on the form
9824 ;; (article-number . line-number-in-body).
9828 (set-buffer gnus-article-buffer)
9835 gnus-newsgroup-bookmarks)
9836 (gnus-message 6 "A bookmark has been added to the current article."))
9838 (defun gnus-summary-remove-bookmark (article)
9839 "Remove the bookmark from the current article."
9840 (interactive (list (gnus-summary-article-number)))
9841 ;; Remove old bookmark, if one exists.
9842 (if (not (assq article gnus-newsgroup-bookmarks))
9843 (gnus-message 6 "No bookmark in current article.")
9844 (gnus-pull article gnus-newsgroup-bookmarks)
9845 (gnus-message 6 "Removed bookmark.")))
9847 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9848 (defun gnus-summary-mark-as-dormant (n)
9849 "Mark N articles forward as dormant.
9850 If N is negative, mark backward instead. The difference between N and
9851 the actual number of articles marked is returned."
9853 (gnus-summary-mark-forward n gnus-dormant-mark))
9855 (defun gnus-summary-set-process-mark (article)
9856 "Set the process mark on ARTICLE and update the summary line."
9857 (setq gnus-newsgroup-processable
9859 (delq article gnus-newsgroup-processable)))
9860 (when (gnus-summary-goto-subject article)
9861 (gnus-summary-show-thread)
9862 (gnus-summary-goto-subject article)
9863 (gnus-summary-update-secondary-mark article)))
9865 (defun gnus-summary-remove-process-mark (article)
9866 "Remove the process mark from ARTICLE and update the summary line."
9867 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9868 (when (gnus-summary-goto-subject article)
9869 (gnus-summary-show-thread)
9870 (gnus-summary-goto-subject article)
9871 (gnus-summary-update-secondary-mark article)))
9873 (defun gnus-summary-set-saved-mark (article)
9874 "Set the process mark on ARTICLE and update the summary line."
9875 (push article gnus-newsgroup-saved)
9876 (when (gnus-summary-goto-subject article)
9877 (gnus-summary-update-secondary-mark article)))
9879 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9880 "Mark N articles as read forwards.
9881 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9882 The difference between N and the actual number of articles marked is
9884 If NO-EXPIRE, auto-expiry will be inhibited."
9886 (gnus-summary-show-thread)
9887 (let ((backward (< n 0))
9888 (gnus-summary-goto-unread
9889 (and gnus-summary-goto-unread
9890 (not (eq gnus-summary-goto-unread 'never))
9891 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9892 gnus-ticked-mark gnus-dormant-mark)))))
9894 (mark (or mark gnus-del-mark)))
9896 (gnus-summary-mark-article nil mark no-expire)
9897 (zerop (gnus-summary-next-subject
9899 (and gnus-summary-goto-unread
9900 (not (eq gnus-summary-goto-unread 'never)))
9904 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9905 (gnus-summary-recenter)
9906 (gnus-summary-position-point)
9907 (gnus-set-mode-line 'summary)
9910 (defun gnus-summary-mark-article-as-read (mark)
9911 "Mark the current article quickly as read with MARK."
9912 (let ((article (gnus-summary-article-number)))
9913 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9914 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9915 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9916 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9917 (push (cons article mark) gnus-newsgroup-reads)
9918 ;; Possibly remove from cache, if that is used.
9919 (when gnus-use-cache
9920 (gnus-cache-enter-remove-article article))
9921 ;; Allow the backend to change the mark.
9922 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9923 ;; Check for auto-expiry.
9924 (when (and gnus-newsgroup-auto-expire
9925 (memq mark gnus-auto-expirable-marks))
9926 (setq mark gnus-expirable-mark)
9927 ;; Let the backend know about the mark change.
9928 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9929 (push article gnus-newsgroup-expirable))
9930 ;; Set the mark in the buffer.
9931 (gnus-summary-update-mark mark 'unread)
9934 (defun gnus-summary-mark-article-as-unread (mark)
9935 "Mark the current article quickly as unread with MARK."
9936 (let* ((article (gnus-summary-article-number))
9937 (old-mark (gnus-summary-article-mark article)))
9938 ;; Allow the backend to change the mark.
9939 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9940 (if (eq mark old-mark)
9944 (gnus-error 1 "Can't mark negative article numbers")
9946 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9947 (setq gnus-newsgroup-spam-marked
9948 (delq article gnus-newsgroup-spam-marked))
9949 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9950 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9951 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9952 (cond ((= mark gnus-ticked-mark)
9953 (setq gnus-newsgroup-marked
9954 (gnus-add-to-sorted-list gnus-newsgroup-marked
9956 ((= mark gnus-spam-mark)
9957 (setq gnus-newsgroup-spam-marked
9958 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9960 ((= mark gnus-dormant-mark)
9961 (setq gnus-newsgroup-dormant
9962 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9965 (setq gnus-newsgroup-unreads
9966 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9968 (gnus-pull article gnus-newsgroup-reads)
9970 ;; See whether the article is to be put in the cache.
9972 (vectorp (gnus-summary-article-header article))
9974 (gnus-cache-possibly-enter-article
9975 gnus-newsgroup-name article
9976 (gnus-summary-article-header article)
9977 (= mark gnus-ticked-mark)
9978 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9981 (gnus-summary-update-mark mark 'unread)
9984 (defun gnus-summary-mark-article (&optional article mark no-expire)
9985 "Mark ARTICLE with MARK. MARK can be any character.
9986 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9987 `??' (dormant) and `?E' (expirable).
9988 If MARK is nil, then the default character `?r' is used.
9989 If ARTICLE is nil, then the article on the current line will be
9991 If NO-EXPIRE, auto-expiry will be inhibited."
9992 ;; The mark might be a string.
9993 (when (stringp mark)
9994 (setq mark (aref mark 0)))
9995 ;; If no mark is given, then we check auto-expiring.
9997 (setq mark gnus-del-mark))
9998 (when (and (not no-expire)
9999 gnus-newsgroup-auto-expire
10000 (memq mark gnus-auto-expirable-marks))
10001 (setq mark gnus-expirable-mark))
10002 (let ((article (or article (gnus-summary-article-number)))
10003 (old-mark (gnus-summary-article-mark article)))
10004 ;; Allow the backend to change the mark.
10005 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10006 (if (eq mark old-mark)
10009 (error "No article on current line"))
10010 (if (not (if (or (= mark gnus-unread-mark)
10011 (= mark gnus-ticked-mark)
10012 (= mark gnus-spam-mark)
10013 (= mark gnus-dormant-mark))
10014 (gnus-mark-article-as-unread article mark)
10015 (gnus-mark-article-as-read article mark)))
10017 ;; See whether the article is to be put in the cache.
10018 (and gnus-use-cache
10019 (not (= mark gnus-canceled-mark))
10020 (vectorp (gnus-summary-article-header article))
10022 (gnus-cache-possibly-enter-article
10023 gnus-newsgroup-name article
10024 (gnus-summary-article-header article)
10025 (= mark gnus-ticked-mark)
10026 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10028 (when (gnus-summary-goto-subject article nil t)
10029 (let ((buffer-read-only nil))
10030 (gnus-summary-show-thread)
10032 (gnus-summary-update-mark mark 'unread)
10035 (defun gnus-summary-update-secondary-mark (article)
10036 "Update the secondary (read, process, cache) mark."
10037 (gnus-summary-update-mark
10038 (cond ((memq article gnus-newsgroup-processable)
10040 ((memq article gnus-newsgroup-cached)
10042 ((memq article gnus-newsgroup-replied)
10044 ((memq article gnus-newsgroup-forwarded)
10045 gnus-forwarded-mark)
10046 ((memq article gnus-newsgroup-saved)
10048 ((memq article gnus-newsgroup-recent)
10050 ((memq article gnus-newsgroup-unseen)
10054 (when (gnus-visual-p 'summary-highlight 'highlight)
10055 (gnus-run-hooks 'gnus-summary-update-hook))
10058 (defun gnus-summary-update-download-mark (article)
10059 "Update the download mark."
10060 (gnus-summary-update-mark
10061 (cond ((memq article gnus-newsgroup-undownloaded)
10062 gnus-undownloaded-mark)
10063 (gnus-newsgroup-agentized
10064 gnus-downloaded-mark)
10068 (gnus-summary-update-line t)
10071 (defun gnus-summary-update-mark (mark type)
10072 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10073 (buffer-read-only nil))
10074 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10076 (when (looking-at "\r")
10078 (when (<= (+ forward (point)) (point-max))
10079 ;; Go to the right position on the line.
10080 (goto-char (+ forward (point)))
10081 ;; Replace the old mark with the new mark.
10082 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10083 ;; Optionally update the marks by some user rule.
10084 (when (eq type 'unread)
10085 (gnus-data-set-mark
10086 (gnus-data-find (gnus-summary-article-number)) mark)
10087 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10089 (defun gnus-mark-article-as-read (article &optional mark)
10090 "Enter ARTICLE in the pertinent lists and remove it from others."
10091 ;; Make the article expirable.
10092 (let ((mark (or mark gnus-del-mark)))
10093 (setq gnus-newsgroup-expirable
10094 (if (= mark gnus-expirable-mark)
10095 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10096 (delq article gnus-newsgroup-expirable)))
10097 ;; Remove from unread and marked lists.
10098 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10099 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10100 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10101 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10102 (push (cons article mark) gnus-newsgroup-reads)
10103 ;; Possibly remove from cache, if that is used.
10104 (when gnus-use-cache
10105 (gnus-cache-enter-remove-article article))
10108 (defun gnus-mark-article-as-unread (article &optional mark)
10109 "Enter ARTICLE in the pertinent lists and remove it from others."
10110 (let ((mark (or mark gnus-ticked-mark)))
10113 (gnus-error 1 "Can't mark negative article numbers")
10115 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10116 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10117 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10118 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10119 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10121 ;; Unsuppress duplicates?
10122 (when gnus-suppress-duplicates
10123 (gnus-dup-unsuppress-article article))
10125 (cond ((= mark gnus-ticked-mark)
10126 (setq gnus-newsgroup-marked
10127 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10128 ((= mark gnus-spam-mark)
10129 (setq gnus-newsgroup-spam-marked
10130 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10132 ((= mark gnus-dormant-mark)
10133 (setq gnus-newsgroup-dormant
10134 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10136 (setq gnus-newsgroup-unreads
10137 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10138 (gnus-pull article gnus-newsgroup-reads)
10141 (defalias 'gnus-summary-mark-as-unread-forward
10142 'gnus-summary-tick-article-forward)
10143 (make-obsolete 'gnus-summary-mark-as-unread-forward
10144 'gnus-summary-tick-article-forward)
10145 (defun gnus-summary-tick-article-forward (n)
10146 "Tick N articles forwards.
10147 If N is negative, tick backwards instead.
10148 The difference between N and the number of articles ticked is returned."
10150 (gnus-summary-mark-forward n gnus-ticked-mark))
10152 (defalias 'gnus-summary-mark-as-unread-backward
10153 'gnus-summary-tick-article-backward)
10154 (make-obsolete 'gnus-summary-mark-as-unread-backward
10155 'gnus-summary-tick-article-backward)
10156 (defun gnus-summary-tick-article-backward (n)
10157 "Tick N articles backwards.
10158 The difference between N and the number of articles ticked is returned."
10160 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10162 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10163 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10164 (defun gnus-summary-tick-article (&optional article clear-mark)
10165 "Mark current article as unread.
10166 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10167 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10169 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10170 gnus-ticked-mark)))
10172 (defun gnus-summary-mark-as-read-forward (n)
10173 "Mark N articles as read forwards.
10174 If N is negative, mark backwards instead.
10175 The difference between N and the actual number of articles marked is
10178 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10180 (defun gnus-summary-mark-as-read-backward (n)
10181 "Mark the N articles as read backwards.
10182 The difference between N and the actual number of articles marked is
10185 (gnus-summary-mark-forward
10186 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10188 (defun gnus-summary-mark-as-read (&optional article mark)
10189 "Mark current article as read.
10190 ARTICLE specifies the article to be marked as read.
10191 MARK specifies a string to be inserted at the beginning of the line."
10192 (gnus-summary-mark-article article mark))
10194 (defun gnus-summary-clear-mark-forward (n)
10195 "Clear marks from N articles forward.
10196 If N is negative, clear backward instead.
10197 The difference between N and the number of marks cleared is returned."
10199 (gnus-summary-mark-forward n gnus-unread-mark))
10201 (defun gnus-summary-clear-mark-backward (n)
10202 "Clear marks from N articles backward.
10203 The difference between N and the number of marks cleared is returned."
10205 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10207 (defun gnus-summary-mark-unread-as-read ()
10208 "Intended to be used by `gnus-summary-mark-article-hook'."
10209 (when (memq gnus-current-article gnus-newsgroup-unreads)
10210 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10212 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10213 "Intended to be used by `gnus-summary-mark-article-hook'."
10214 (let ((mark (gnus-summary-article-mark)))
10215 (when (or (gnus-unread-mark-p mark)
10216 (gnus-read-mark-p mark))
10217 (gnus-summary-mark-article gnus-current-article
10218 (or new-mark gnus-read-mark)))))
10220 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10221 "Intended to be used by `gnus-summary-mark-article-hook'."
10222 (let ((mark (gnus-summary-article-mark)))
10223 (when (or (gnus-unread-mark-p mark)
10224 (gnus-read-mark-p mark))
10225 (gnus-summary-mark-article (gnus-summary-article-number)
10226 (or new-mark gnus-read-mark)))))
10228 (defun gnus-summary-mark-unread-as-ticked ()
10229 "Intended to be used by `gnus-summary-mark-article-hook'."
10230 (when (memq gnus-current-article gnus-newsgroup-unreads)
10231 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10233 (defun gnus-summary-mark-region-as-read (point mark all)
10234 "Mark all unread articles between point and mark as read.
10235 If given a prefix, mark all articles between point and mark as read,
10236 even ticked and dormant ones."
10237 (interactive "r\nP")
10241 (beginning-of-line)
10246 (memq (setq article (gnus-summary-article-number))
10247 gnus-newsgroup-unreads))
10248 (gnus-summary-mark-article article gnus-del-mark))
10250 (gnus-summary-find-next))))))
10252 (defun gnus-summary-mark-below (score mark)
10253 "Mark articles with score less than SCORE with MARK."
10254 (interactive "P\ncMark: ")
10255 (setq score (if score
10256 (prefix-numeric-value score)
10257 (or gnus-summary-default-score 0)))
10259 (set-buffer gnus-summary-buffer)
10260 (goto-char (point-min))
10263 (and (< (gnus-summary-article-score) score)
10264 (gnus-summary-mark-article nil mark))
10265 (gnus-summary-find-next)))))
10267 (defun gnus-summary-kill-below (&optional score)
10268 "Mark articles with score below SCORE as read."
10270 (gnus-summary-mark-below score gnus-killed-mark))
10272 (defun gnus-summary-clear-above (&optional score)
10273 "Clear all marks from articles with score above SCORE."
10275 (gnus-summary-mark-above score gnus-unread-mark))
10277 (defun gnus-summary-tick-above (&optional score)
10278 "Tick all articles with score above SCORE."
10280 (gnus-summary-mark-above score gnus-ticked-mark))
10282 (defun gnus-summary-mark-above (score mark)
10283 "Mark articles with score over SCORE with MARK."
10284 (interactive "P\ncMark: ")
10285 (setq score (if score
10286 (prefix-numeric-value score)
10287 (or gnus-summary-default-score 0)))
10289 (set-buffer gnus-summary-buffer)
10290 (goto-char (point-min))
10292 (when (> (gnus-summary-article-score) score)
10293 (gnus-summary-mark-article nil mark))
10295 (gnus-summary-find-next)))))
10297 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10298 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10299 (defun gnus-summary-limit-include-expunged (&optional no-error)
10300 "Display all the hidden articles that were expunged for low scores."
10302 (let ((buffer-read-only nil))
10303 (let ((scored gnus-newsgroup-scored)
10306 (unless (gnus-summary-article-header (caar scored))
10307 (and (setq h (gnus-number-to-header (caar scored)))
10308 (< (cdar scored) gnus-summary-expunge-below)
10310 (setq scored (cdr scored)))
10312 (when (not no-error)
10313 (error "No expunged articles hidden"))
10314 (goto-char (point-min))
10315 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10316 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10317 (mapcar (lambda (x) (push (mail-header-number x)
10318 gnus-newsgroup-limit))
10320 (gnus-summary-prepare-unthreaded (nreverse headers))
10321 (goto-char (point-min))
10322 (gnus-summary-position-point)
10325 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10326 "Mark all unread articles in this newsgroup as read.
10327 If prefix argument ALL is non-nil, ticked and dormant articles will
10328 also be marked as read.
10329 If QUIETLY is non-nil, no questions will be asked.
10331 If TO-HERE is non-nil, it should be a point in the buffer. All
10332 articles before (after, if REVERSE is set) this point will be marked
10335 Note that this function will only catch up the unread article
10336 in the current summary buffer limitation.
10338 The number of articles marked as read is returned."
10343 (not gnus-interactive-catchup) ;Without confirmation?
10347 "Mark absolutely all articles as read? "
10348 "Mark all unread articles as read? ")))
10350 (not gnus-newsgroup-adaptive)
10351 (not gnus-newsgroup-auto-expire)
10352 (not gnus-suppress-duplicates)
10353 (or (not gnus-use-cache)
10354 (eq gnus-use-cache 'passive)))
10357 (setq gnus-newsgroup-marked nil
10358 gnus-newsgroup-spam-marked nil
10359 gnus-newsgroup-dormant nil))
10360 (setq gnus-newsgroup-unreads
10361 (gnus-sorted-nunion
10362 (gnus-intersection gnus-newsgroup-unreads
10363 gnus-newsgroup-downloadable)
10364 gnus-newsgroup-unfetched)))
10365 ;; We actually mark all articles as canceled, which we
10366 ;; have to do when using auto-expiry or adaptive scoring.
10367 (gnus-summary-show-all-threads)
10368 (if (and to-here reverse)
10370 (goto-char to-here)
10371 (gnus-summary-mark-current-read-and-unread-as-read
10373 (while (gnus-summary-find-next (not all))
10374 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10375 (when (gnus-summary-first-subject (not all))
10377 (if to-here (< (point) to-here) t)
10378 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10379 (gnus-summary-find-next (not all))))))
10380 (gnus-set-mode-line 'summary))
10382 (gnus-summary-position-point)))
10384 (defun gnus-summary-catchup-to-here (&optional all)
10385 "Mark all unticked articles before the current one as read.
10386 If ALL is non-nil, also mark ticked and dormant articles as read."
10389 (gnus-save-hidden-threads
10390 (let ((beg (point)))
10391 ;; We check that there are unread articles.
10392 (when (or all (gnus-summary-find-prev))
10393 (gnus-summary-catchup all t beg)))))
10394 (gnus-summary-position-point))
10396 (defun gnus-summary-catchup-from-here (&optional all)
10397 "Mark all unticked articles after (and including) the current one as read.
10398 If ALL is non-nil, also mark ticked and dormant articles as read."
10401 (gnus-save-hidden-threads
10402 (let ((beg (point)))
10403 ;; We check that there are unread articles.
10404 (when (or all (gnus-summary-find-next))
10405 (gnus-summary-catchup all t beg nil t)))))
10406 (gnus-summary-position-point))
10408 (defun gnus-summary-catchup-all (&optional quietly)
10409 "Mark all articles in this newsgroup as read.
10410 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10411 instead, which marks only unread articles as read."
10413 (gnus-summary-catchup t quietly))
10415 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10416 "Mark all unread articles in this group as read, then exit.
10417 If prefix argument ALL is non-nil, all articles are marked as read.
10418 If QUIETLY is non-nil, no questions will be asked."
10420 (when (gnus-summary-catchup all quietly nil 'fast)
10421 ;; Select next newsgroup or exit.
10422 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10423 (eq gnus-auto-select-next 'quietly))
10424 (gnus-summary-next-group nil)
10425 (gnus-summary-exit))))
10427 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10428 "Mark all articles in this newsgroup as read, and then exit.
10429 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10430 instead, which marks only unread articles as read."
10432 (gnus-summary-catchup-and-exit t quietly))
10434 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10435 "Mark all articles in this group as read and select the next group.
10436 If given a prefix, mark all articles, unread as well as ticked, as
10440 (gnus-summary-catchup all))
10441 (gnus-summary-next-group))
10447 (defmacro gnus-with-article (article &rest forms)
10448 "Select ARTICLE and perform FORMS in the original article buffer.
10449 Then replace the article with the result."
10451 ;; We don't want the article to be marked as read.
10452 (let (gnus-mark-article-hook)
10453 (gnus-summary-select-article t t nil ,article))
10454 (set-buffer gnus-original-article-buffer)
10456 (if (not (gnus-check-backend-function
10457 'request-replace-article (car gnus-article-current)))
10458 (gnus-message 5 "Read-only group; not replacing")
10459 (unless (gnus-request-replace-article
10460 ,article (car gnus-article-current)
10461 (current-buffer) t)
10462 (error "Couldn't replace article")))
10463 ;; The cache and backlog have to be flushed somewhat.
10464 (when gnus-keep-backlog
10465 (gnus-backlog-remove-article
10466 (car gnus-article-current) (cdr gnus-article-current)))
10467 (when gnus-use-cache
10468 (gnus-cache-update-article
10469 (car gnus-article-current) (cdr gnus-article-current)))))
10471 (put 'gnus-with-article 'lisp-indent-function 1)
10472 (put 'gnus-with-article 'edebug-form-spec '(form body))
10474 ;; Thread-based commands.
10476 (defun gnus-summary-articles-in-thread (&optional article)
10477 "Return a list of all articles in the current thread.
10478 If ARTICLE is non-nil, return all articles in the thread that starts
10479 with that article."
10480 (let* ((article (or article (gnus-summary-article-number)))
10481 (data (gnus-data-find-list article))
10482 (top-level (gnus-data-level (car data)))
10484 (cond ((null gnus-thread-operation-ignore-subject)
10485 (gnus-simplify-subject-re
10486 (mail-header-subject (gnus-data-header (car data)))))
10487 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10488 (gnus-simplify-subject-fuzzy
10489 (mail-header-subject (gnus-data-header (car data)))))
10491 (end-point (save-excursion
10492 (if (gnus-summary-go-to-next-thread)
10493 (point) (point-max))))
10496 (< (gnus-data-pos (car data)) end-point))
10497 (when (or (not top-subject)
10498 (string= top-subject
10499 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10500 (gnus-simplify-subject-fuzzy
10501 (mail-header-subject
10502 (gnus-data-header (car data))))
10503 (gnus-simplify-subject-re
10504 (mail-header-subject
10505 (gnus-data-header (car data)))))))
10506 (push (gnus-data-number (car data)) articles))
10507 (unless (and (setq data (cdr data))
10508 (> (gnus-data-level (car data)) top-level))
10510 ;; Return the list of articles.
10511 (nreverse articles)))
10513 (defun gnus-summary-rethread-current ()
10514 "Rethread the thread the current article is part of."
10516 (let* ((gnus-show-threads t)
10517 (article (gnus-summary-article-number))
10518 (id (mail-header-id (gnus-summary-article-header)))
10519 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10521 (error "No article on the current line"))
10522 (gnus-rebuild-thread id)
10523 (gnus-summary-goto-subject article)))
10525 (defun gnus-summary-reparent-thread ()
10526 "Make the current article child of the marked (or previous) article.
10528 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10529 is non-nil or the Subject: of both articles are the same."
10531 (unless (not (gnus-group-read-only-p))
10532 (error "The current newsgroup does not support article editing"))
10533 (unless (<= (length gnus-newsgroup-processable) 1)
10534 (error "No more than one article may be marked"))
10535 (save-window-excursion
10536 (let ((gnus-article-buffer " *reparent*")
10537 (current-article (gnus-summary-article-number))
10538 ;; First grab the marked article, otherwise one line up.
10539 (parent-article (if (not (null gnus-newsgroup-processable))
10540 (car gnus-newsgroup-processable)
10542 (if (eq (forward-line -1) 0)
10543 (gnus-summary-article-number)
10544 (error "Beginning of summary buffer"))))))
10545 (unless (not (eq current-article parent-article))
10546 (error "An article may not be self-referential"))
10547 (let ((message-id (mail-header-id
10548 (gnus-summary-article-header parent-article))))
10549 (unless (and message-id (not (equal message-id "")))
10550 (error "No message-id in desired parent"))
10551 (gnus-with-article current-article
10553 (goto-char (point-min))
10554 (message-narrow-to-head)
10555 (if (re-search-forward "^References: " nil t)
10557 (re-search-forward "^[^ \t]" nil t)
10560 (insert " " message-id))
10561 (insert "References: " message-id "\n"))))
10562 (set-buffer gnus-summary-buffer)
10563 (gnus-summary-unmark-all-processable)
10564 (gnus-summary-update-article current-article)
10565 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10566 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10567 (gnus-summary-rethread-current)
10568 (gnus-message 3 "Article %d is now the child of article %d"
10569 current-article parent-article)))))
10571 (defun gnus-summary-toggle-threads (&optional arg)
10572 "Toggle showing conversation threads.
10573 If ARG is positive number, turn showing conversation threads on."
10575 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10576 (setq gnus-show-threads
10577 (if (null arg) (not gnus-show-threads)
10578 (> (prefix-numeric-value arg) 0)))
10579 (gnus-summary-prepare)
10580 (gnus-summary-goto-subject current)
10581 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10582 (gnus-summary-position-point)))
10584 (defun gnus-summary-show-all-threads ()
10585 "Show all threads."
10588 (let ((buffer-read-only nil))
10589 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10590 (gnus-summary-position-point))
10592 (defun gnus-summary-show-thread ()
10593 "Show thread subtrees.
10594 Returns nil if no thread was there to be shown."
10596 (let ((buffer-read-only nil)
10598 (end (point-at-eol))
10599 ;; Leave point at bol
10600 (beg (progn (beginning-of-line) (point))))
10602 ;; Any hidden lines here?
10603 (search-forward "\r" end t)
10604 (subst-char-in-region beg end ?\^M ?\n t)
10606 (gnus-summary-position-point))))
10608 (defun gnus-summary-maybe-hide-threads ()
10609 "If requested, hide the threads that should be hidden."
10610 (when (and gnus-show-threads
10611 gnus-thread-hide-subtree)
10612 (gnus-summary-hide-all-threads
10613 (if (or (consp gnus-thread-hide-subtree)
10614 (functionp gnus-thread-hide-subtree))
10615 (gnus-make-predicate gnus-thread-hide-subtree)
10618 ;;; Hiding predicates.
10620 (defun gnus-article-unread-p (header)
10621 (memq (mail-header-number header) gnus-newsgroup-unreads))
10623 (defun gnus-article-unseen-p (header)
10624 (memq (mail-header-number header) gnus-newsgroup-unseen))
10626 (defun gnus-map-articles (predicate articles)
10627 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10628 (apply 'gnus-or (mapcar predicate
10629 (mapcar 'gnus-summary-article-header articles))))
10631 (defun gnus-summary-hide-all-threads (&optional predicate)
10632 "Hide all thread subtrees.
10633 If PREDICATE is supplied, threads that satisfy this predicate
10634 will not be hidden."
10637 (goto-char (point-min))
10640 (when (or (not predicate)
10642 predicate (gnus-summary-article-children)))
10643 (gnus-summary-hide-thread))
10644 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10645 (gnus-summary-position-point))
10647 (defun gnus-summary-hide-thread ()
10648 "Hide thread subtrees.
10649 If PREDICATE is supplied, threads that satisfy this predicate
10650 will not be hidden.
10651 Returns nil if no threads were there to be hidden."
10653 (let ((buffer-read-only nil)
10655 (article (gnus-summary-article-number)))
10657 ;; Go forward until either the buffer ends or the subthread
10659 (when (and (not (eobp))
10660 (or (zerop (gnus-summary-next-thread 1 t))
10661 (goto-char (point-max))))
10663 (if (and (> (point) start)
10664 (search-backward "\n" start t))
10666 (subst-char-in-region start (point) ?\n ?\^M)
10667 (gnus-summary-goto-subject article))
10671 (defun gnus-summary-go-to-next-thread (&optional previous)
10672 "Go to the same level (or less) next thread.
10673 If PREVIOUS is non-nil, go to previous thread instead.
10674 Return the article number moved to, or nil if moving was impossible."
10675 (let ((level (gnus-summary-thread-level))
10676 (way (if previous -1 1))
10679 (while (and (not (eobp))
10680 (< level (gnus-summary-thread-level)))
10681 (forward-line way))
10688 (gnus-summary-article-number)
10689 (goto-char beg)))))
10691 (defun gnus-summary-next-thread (n &optional silent)
10692 "Go to the same level next N'th thread.
10693 If N is negative, search backward instead.
10694 Returns the difference between N and the number of skips actually
10697 If SILENT, don't output messages."
10699 (let ((backward (< n 0))
10701 (while (and (> n 0)
10702 (gnus-summary-go-to-next-thread backward))
10705 (gnus-summary-position-point))
10706 (when (and (not silent) (/= 0 n))
10707 (gnus-message 7 "No more threads"))
10710 (defun gnus-summary-prev-thread (n)
10711 "Go to the same level previous N'th thread.
10712 Returns the difference between N and the number of skips actually
10715 (gnus-summary-next-thread (- n)))
10717 (defun gnus-summary-go-down-thread ()
10718 "Go down one level in the current thread."
10719 (let ((children (gnus-summary-article-children)))
10721 (gnus-summary-goto-subject (car children)))))
10723 (defun gnus-summary-go-up-thread ()
10724 "Go up one level in the current thread."
10725 (let ((parent (gnus-summary-article-parent)))
10727 (gnus-summary-goto-subject parent))))
10729 (defun gnus-summary-down-thread (n)
10730 "Go down thread N steps.
10731 If N is negative, go up instead.
10732 Returns the difference between N and how many steps down that were
10737 (while (and (> n 0)
10738 (if up (gnus-summary-go-up-thread)
10739 (gnus-summary-go-down-thread)))
10741 (gnus-summary-position-point)
10743 (gnus-message 7 "Can't go further"))
10746 (defun gnus-summary-up-thread (n)
10747 "Go up thread N steps.
10748 If N is negative, go down instead.
10749 Returns the difference between N and how many steps down that were
10752 (gnus-summary-down-thread (- n)))
10754 (defun gnus-summary-top-thread ()
10755 "Go to the top of the thread."
10757 (while (gnus-summary-go-up-thread))
10758 (gnus-summary-article-number))
10760 (defun gnus-summary-kill-thread (&optional unmark)
10761 "Mark articles under current thread as read.
10762 If the prefix argument is positive, remove any kinds of marks.
10763 If the prefix argument is negative, tick articles instead."
10766 (setq unmark (prefix-numeric-value unmark)))
10767 (let ((articles (gnus-summary-articles-in-thread)))
10769 ;; Expand the thread.
10770 (gnus-summary-show-thread)
10771 ;; Mark all the articles.
10773 (gnus-summary-goto-subject (car articles))
10774 (cond ((null unmark)
10775 (gnus-summary-mark-article-as-read gnus-killed-mark))
10777 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10779 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10780 (setq articles (cdr articles))))
10781 ;; Hide killed subtrees.
10783 gnus-thread-hide-killed
10784 (gnus-summary-hide-thread))
10785 ;; If marked as read, go to next unread subject.
10786 (when (null unmark)
10787 ;; Go to next unread subject.
10788 (gnus-summary-next-subject 1 t)))
10789 (gnus-set-mode-line 'summary))
10791 ;; Summary sorting commands
10793 (defun gnus-summary-sort-by-number (&optional reverse)
10794 "Sort the summary buffer by article number.
10795 Argument REVERSE means reverse order."
10797 (gnus-summary-sort 'number reverse))
10799 (defun gnus-summary-sort-by-random (&optional reverse)
10800 "Randomize the order in the summary buffer.
10801 Argument REVERSE means to randomize in reverse order."
10803 (gnus-summary-sort 'random reverse))
10805 (defun gnus-summary-sort-by-author (&optional reverse)
10806 "Sort the summary buffer by author name alphabetically.
10807 If `case-fold-search' is non-nil, case of letters is ignored.
10808 Argument REVERSE means reverse order."
10810 (gnus-summary-sort 'author reverse))
10812 (defun gnus-summary-sort-by-subject (&optional reverse)
10813 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10814 If `case-fold-search' is non-nil, case of letters is ignored.
10815 Argument REVERSE means reverse order."
10817 (gnus-summary-sort 'subject reverse))
10819 (defun gnus-summary-sort-by-date (&optional reverse)
10820 "Sort the summary buffer by date.
10821 Argument REVERSE means reverse order."
10823 (gnus-summary-sort 'date reverse))
10825 (defun gnus-summary-sort-by-score (&optional reverse)
10826 "Sort the summary buffer by score.
10827 Argument REVERSE means reverse order."
10829 (gnus-summary-sort 'score reverse))
10831 (defun gnus-summary-sort-by-lines (&optional reverse)
10832 "Sort the summary buffer by the number of lines.
10833 Argument REVERSE means reverse order."
10835 (gnus-summary-sort 'lines reverse))
10837 (defun gnus-summary-sort-by-chars (&optional reverse)
10838 "Sort the summary buffer by article length.
10839 Argument REVERSE means reverse order."
10841 (gnus-summary-sort 'chars reverse))
10843 (defun gnus-summary-sort-by-original (&optional reverse)
10844 "Sort the summary buffer using the default sorting method.
10845 Argument REVERSE means reverse order."
10847 (let* ((buffer-read-only)
10848 (gnus-summary-prepare-hook nil))
10849 ;; We do the sorting by regenerating the threads.
10850 (gnus-summary-prepare)
10851 ;; Hide subthreads if needed.
10852 (gnus-summary-maybe-hide-threads)))
10854 (defun gnus-summary-sort (predicate reverse)
10855 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10856 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10857 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10858 (gnus-thread-sort-functions
10863 (gnus-sort-gathered-threads-function
10864 gnus-thread-sort-functions)
10865 (gnus-article-sort-functions
10869 (,article t2 t1))))
10871 (gnus-summary-prepare-hook nil))
10872 ;; We do the sorting by regenerating the threads.
10873 (gnus-summary-prepare)
10874 ;; Hide subthreads if needed.
10875 (gnus-summary-maybe-hide-threads)))
10877 ;; Summary saving commands.
10879 (defun gnus-summary-save-article (&optional n not-saved)
10880 "Save the current article using the default saver function.
10881 If N is a positive number, save the N next articles.
10882 If N is a negative number, save the N previous articles.
10883 If N is nil and any articles have been marked with the process mark,
10884 save those articles instead.
10885 The variable `gnus-default-article-saver' specifies the saver function."
10887 (let* ((articles (gnus-summary-work-articles n))
10888 (save-buffer (save-excursion
10889 (nnheader-set-temp-buffer " *Gnus Save*")))
10890 (num (length articles))
10892 (dolist (article articles)
10893 (setq header (gnus-summary-article-header article))
10894 (if (not (vectorp header))
10895 ;; This is a pseudo-article.
10896 (if (assq 'name header)
10897 (gnus-copy-file (cdr (assq 'name header)))
10898 (gnus-message 1 "Article %d is unsaveable" article))
10899 ;; This is a real article.
10900 (save-window-excursion
10901 (let ((gnus-display-mime-function nil)
10902 (gnus-article-prepare-hook nil))
10903 (gnus-summary-select-article t nil nil article)))
10905 (set-buffer save-buffer)
10907 (insert-buffer-substring gnus-original-article-buffer))
10908 (setq file (gnus-article-save save-buffer file num))
10909 (gnus-summary-remove-process-mark article)
10911 (gnus-summary-set-saved-mark article))))
10912 (gnus-kill-buffer save-buffer)
10913 (gnus-summary-position-point)
10914 (gnus-set-mode-line 'summary)
10917 (defun gnus-summary-pipe-output (&optional arg headers)
10918 "Pipe the current article to a subprocess.
10919 If N is a positive number, pipe the N next articles.
10920 If N is a negative number, pipe the N previous articles.
10921 If N is nil and any articles have been marked with the process mark,
10922 pipe those articles instead.
10923 If HEADERS (the symbolic prefix), include the headers, too."
10924 (interactive (gnus-interactive "P\ny"))
10925 (require 'gnus-art)
10926 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10927 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10928 (gnus-summary-save-article arg t))
10929 (let ((buffer (get-buffer "*Shell Command Output*")))
10931 (not (zerop (buffer-size buffer))))
10932 (gnus-configure-windows 'pipe))))
10934 (defun gnus-summary-save-article-mail (&optional arg)
10935 "Append the current article to an mail file.
10936 If N is a positive number, save the N next articles.
10937 If N is a negative number, save the N previous articles.
10938 If N is nil and any articles have been marked with the process mark,
10939 save those articles instead."
10941 (require 'gnus-art)
10942 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10943 (gnus-summary-save-article arg)))
10945 (defun gnus-summary-save-article-rmail (&optional arg)
10946 "Append the current article to an rmail file.
10947 If N is a positive number, save the N next articles.
10948 If N is a negative number, save the N previous articles.
10949 If N is nil and any articles have been marked with the process mark,
10950 save those articles instead."
10952 (require 'gnus-art)
10953 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10954 (gnus-summary-save-article arg)))
10956 (defun gnus-summary-save-article-file (&optional arg)
10957 "Append the current article to a file.
10958 If N is a positive number, save the N next articles.
10959 If N is a negative number, save the N previous articles.
10960 If N is nil and any articles have been marked with the process mark,
10961 save those articles instead."
10963 (require 'gnus-art)
10964 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10965 (gnus-summary-save-article arg)))
10967 (defun gnus-summary-write-article-file (&optional arg)
10968 "Write the current article to a file, deleting the previous file.
10969 If N is a positive number, save the N next articles.
10970 If N is a negative number, save the N previous articles.
10971 If N is nil and any articles have been marked with the process mark,
10972 save those articles instead."
10974 (require 'gnus-art)
10975 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10976 (gnus-summary-save-article arg)))
10978 (defun gnus-summary-save-article-body-file (&optional arg)
10979 "Append the current article body to a file.
10980 If N is a positive number, save the N next articles.
10981 If N is a negative number, save the N previous articles.
10982 If N is nil and any articles have been marked with the process mark,
10983 save those articles instead."
10985 (require 'gnus-art)
10986 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10987 (gnus-summary-save-article arg)))
10989 (defun gnus-summary-muttprint (&optional arg)
10990 "Print the current article using Muttprint.
10991 If N is a positive number, save the N next articles.
10992 If N is a negative number, save the N previous articles.
10993 If N is nil and any articles have been marked with the process mark,
10994 save those articles instead."
10996 (require 'gnus-art)
10997 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10998 (gnus-summary-save-article arg t)))
11000 (defun gnus-summary-pipe-message (program)
11001 "Pipe the current article through PROGRAM."
11002 (interactive "sProgram: ")
11003 (gnus-summary-select-article)
11004 (let ((mail-header-separator ""))
11005 (gnus-eval-in-buffer-window gnus-article-buffer
11008 (let ((start (window-start))
11010 (message-pipe-buffer-body program)
11011 (set-window-start (get-buffer-window (current-buffer)) start))))))
11013 (defun gnus-get-split-value (methods)
11014 "Return a value based on the split METHODS."
11015 (let (split-name method result match)
11018 (set-buffer gnus-original-article-buffer)
11020 (nnheader-narrow-to-headers)
11021 (while (and methods (not split-name))
11022 (goto-char (point-min))
11023 (setq method (pop methods))
11024 (setq match (car method))
11027 ;; Regular expression.
11029 (re-search-forward match nil t)))
11034 (setq result (funcall match gnus-newsgroup-name))))
11039 (setq result (eval match)))))
11040 (setq split-name (cdr method))
11041 (cond ((stringp result)
11042 (push (expand-file-name
11043 result gnus-article-save-directory)
11046 (setq split-name (append result split-name)))))))))
11047 (nreverse split-name)))
11049 (defun gnus-valid-move-group-p (group)
11050 (and (boundp group)
11051 (symbol-name group)
11052 (symbol-value group)
11053 (gnus-get-function (gnus-find-method-for-group
11054 (symbol-name group)) 'request-accept-article t)))
11056 (defun gnus-read-move-group-name (prompt default articles prefix)
11057 "Read a group name."
11058 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11059 (minibuffer-confirm-incomplete nil) ; XEmacs
11061 (format "%s %s to:"
11063 (if (> (length articles) 1)
11064 (format "these %d articles" (length articles))
11069 (gnus-completing-read-with-default
11072 'gnus-valid-move-group-p
11074 'gnus-group-history))
11075 ((= 1 (length split-name))
11076 (gnus-completing-read-with-default
11077 (car split-name) prom
11079 'gnus-valid-move-group-p
11081 'gnus-group-history))
11083 (gnus-completing-read-with-default
11085 (mapcar (lambda (el) (list el))
11086 (nreverse split-name))
11088 'gnus-group-history))))
11089 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11091 (if (or (string= to-newsgroup "")
11092 (string= to-newsgroup prefix))
11093 (setq to-newsgroup default))
11094 (unless to-newsgroup
11095 (error "No group name entered"))
11096 (or (gnus-active to-newsgroup)
11097 (gnus-activate-group to-newsgroup nil nil to-method)
11098 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11100 (or (and (gnus-request-create-group to-newsgroup to-method)
11101 (gnus-activate-group
11102 to-newsgroup nil nil to-method)
11103 (gnus-subscribe-group to-newsgroup))
11104 (error "Couldn't create group %s" to-newsgroup)))
11105 (error "No such group: %s" to-newsgroup)))
11108 (defun gnus-summary-save-parts (type dir n &optional reverse)
11109 "Save parts matching TYPE to DIR.
11110 If REVERSE, save parts that do not match TYPE."
11112 (list (read-string "Save parts of type: "
11113 (or (car gnus-summary-save-parts-type-history)
11114 gnus-summary-save-parts-default-mime)
11115 'gnus-summary-save-parts-type-history)
11116 (setq gnus-summary-save-parts-last-directory
11117 (read-file-name "Save to directory: "
11118 gnus-summary-save-parts-last-directory
11120 current-prefix-arg))
11121 (gnus-summary-iterate n
11122 (let ((gnus-display-mime-function nil)
11123 (gnus-inhibit-treatment t))
11124 (gnus-summary-select-article))
11126 (set-buffer gnus-article-buffer)
11127 (let ((handles (or gnus-article-mime-handles
11128 (mm-dissect-buffer nil gnus-article-loose-mime)
11129 (and gnus-article-emulate-mime
11130 (mm-uu-dissect)))))
11132 (gnus-summary-save-parts-1 type dir handles reverse)
11133 (unless gnus-article-mime-handles ;; Don't destroy this case.
11134 (mm-destroy-parts handles)))))))
11136 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11137 (if (stringp (car handle))
11138 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11141 (not (string-match type (mm-handle-media-type handle)))
11142 (string-match type (mm-handle-media-type handle)))
11143 (let ((file (expand-file-name
11145 mm-file-name-rewrite-functions
11146 (file-name-nondirectory
11148 (mail-content-type-get
11149 (mm-handle-disposition handle) 'filename)
11150 (mail-content-type-get
11151 (mm-handle-type handle) 'name)
11152 (concat gnus-newsgroup-name
11153 "." (number-to-string
11154 (cdr gnus-article-current))))))
11156 (unless (file-exists-p file)
11157 (mm-save-part-to-file handle file))))))
11159 ;; Summary extract commands
11161 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11162 (let ((buffer-read-only nil)
11163 (article (gnus-summary-article-number))
11165 (unless (gnus-summary-goto-subject article)
11166 (error "No such article: %d" article))
11167 (gnus-summary-position-point)
11168 ;; If all commands are to be bunched up on one line, we collect
11170 (unless gnus-view-pseudos-separately
11171 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11174 (setq action (cdr (assq 'action (car ps))))
11175 (setq files (list (cdr (assq 'name (car ps)))))
11176 (while (and ps (cdr ps)
11177 (string= (or action "1")
11178 (or (cdr (assq 'action (cadr ps))) "2")))
11179 (push (cdr (assq 'name (cadr ps))) files)
11180 (setcdr ps (cddr ps)))
11182 (when (not (string-match "%s" action))
11185 (when (assq 'execute (car ps))
11186 (setcdr (assq 'execute (car ps))
11187 (funcall (if (string-match "%s" action)
11194 (shell-quote-argument f)))
11196 (setq ps (cdr ps)))))
11197 (if (and gnus-view-pseudos (not not-view))
11199 (when (assq 'execute (car pslist))
11200 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11201 (eq gnus-view-pseudos 'not-confirm)))
11202 (setq pslist (cdr pslist)))
11205 (setq after-article (or (cdr (assq 'article (car pslist)))
11206 (gnus-summary-article-number)))
11207 (gnus-summary-goto-subject after-article)
11210 (insert " " (file-name-nondirectory
11211 (cdr (assq 'name (car pslist))))
11212 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11214 (forward-line -1) ; back to `b'
11215 (gnus-add-text-properties
11216 b (1- e) (list 'gnus-number gnus-reffed-article-number
11217 gnus-mouse-face-prop gnus-mouse-face))
11219 after-article gnus-reffed-article-number
11220 gnus-unread-mark b (car pslist) 0 (- e b))
11221 (setq gnus-newsgroup-unreads
11222 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11223 gnus-reffed-article-number))
11224 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11225 (setq pslist (cdr pslist)))))))
11227 (defun gnus-pseudos< (p1 p2)
11228 (let ((c1 (cdr (assq 'action p1)))
11229 (c2 (cdr (assq 'action p2))))
11230 (and c1 c2 (string< c1 c2))))
11232 (defun gnus-request-pseudo-article (props)
11233 (cond ((assq 'execute props)
11234 (gnus-execute-command (cdr (assq 'execute props)))))
11235 (let ((gnus-current-article (gnus-summary-article-number)))
11236 (gnus-run-hooks 'gnus-mark-article-hook)))
11238 (defun gnus-execute-command (command &optional automatic)
11240 (gnus-article-setup-buffer)
11241 (set-buffer gnus-article-buffer)
11242 (setq buffer-read-only nil)
11243 (let ((command (if automatic command
11244 (read-string "Command: " (cons command 0)))))
11246 (insert "$ " command "\n\n")
11247 (if gnus-view-pseudo-asynchronously
11248 (start-process "gnus-execute" (current-buffer) shell-file-name
11249 shell-command-switch command)
11250 (call-process shell-file-name nil t nil
11251 shell-command-switch command)))))
11253 ;; Summary kill commands.
11255 (defun gnus-summary-edit-global-kill (article)
11256 "Edit the \"global\" kill file."
11257 (interactive (list (gnus-summary-article-number)))
11258 (gnus-group-edit-global-kill article))
11260 (defun gnus-summary-edit-local-kill ()
11261 "Edit a local kill file applied to the current newsgroup."
11263 (setq gnus-current-headers (gnus-summary-article-header))
11264 (gnus-group-edit-local-kill
11265 (gnus-summary-article-number) gnus-newsgroup-name))
11267 ;;; Header reading.
11269 (defun gnus-read-header (id &optional header)
11270 "Read the headers of article ID and enter them into the Gnus system."
11271 (let ((group gnus-newsgroup-name)
11272 (gnus-override-method
11274 gnus-override-method
11275 (and (gnus-news-group-p gnus-newsgroup-name)
11276 (car (gnus-refer-article-methods)))))
11278 ;; First we check to see whether the header in question is already
11281 ;; This is a Message-ID.
11282 (setq header (or header (gnus-id-to-header id)))
11283 ;; This is an article number.
11284 (setq header (or header (gnus-summary-article-header id))))
11286 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11287 ;; We have found the header.
11289 ;; If this is a sparse article, we have to nix out its
11290 ;; previous entry in the thread hashtb.
11292 (gnus-summary-article-sparse-p (mail-header-number header)))
11293 (let* ((parent (gnus-parent-id (mail-header-references header)))
11294 (thread (and parent (gnus-id-to-thread parent))))
11296 (delq (assq header thread) thread))))
11297 ;; We have to really fetch the header to this article.
11299 (set-buffer nntp-server-buffer)
11300 (when (setq where (gnus-request-head id group))
11301 (nnheader-fold-continuation-lines)
11302 (goto-char (point-max))
11304 (goto-char (point-min))
11308 ((cdr where) (cdr where))
11309 (header (mail-header-number header))
11310 (t gnus-reffed-article-number))
11312 (insert " Article retrieved.\n"))
11313 (if (or (not where)
11314 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11315 () ; Malformed head.
11316 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11317 (when (and (stringp id)
11318 (not (string= (gnus-group-real-name group)
11320 ;; If we fetched by Message-ID and the article came
11321 ;; from a different group, we fudge some bogus article
11322 ;; numbers for this article.
11323 (mail-header-set-number header gnus-reffed-article-number))
11325 (set-buffer gnus-summary-buffer)
11326 (decf gnus-reffed-article-number)
11327 (gnus-remove-header (mail-header-number header))
11328 (push header gnus-newsgroup-headers)
11329 (setq gnus-current-headers header)
11330 (push (mail-header-number header) gnus-newsgroup-limit)))
11333 (defun gnus-remove-header (number)
11334 "Remove header NUMBER from `gnus-newsgroup-headers'."
11335 (if (and gnus-newsgroup-headers
11336 (= number (mail-header-number (car gnus-newsgroup-headers))))
11337 (pop gnus-newsgroup-headers)
11338 (let ((headers gnus-newsgroup-headers))
11339 (while (and (cdr headers)
11340 (not (= number (mail-header-number (cadr headers)))))
11342 (when (cdr headers)
11343 (setcdr headers (cddr headers))))))
11346 ;;; summary highlights
11349 (defun gnus-highlight-selected-summary ()
11350 "Highlight selected article in summary buffer."
11351 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11352 (when gnus-summary-selected-face
11354 (let* ((beg (point-at-bol))
11355 (end (point-at-eol))
11356 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11357 (from (if (get-text-property beg gnus-mouse-face-prop)
11359 (or (next-single-property-change
11360 beg gnus-mouse-face-prop nil end)
11365 (or (next-single-property-change
11366 from gnus-mouse-face-prop nil end)
11368 ;; If no mouse-face prop on line we will have to = from = end,
11369 ;; so we highlight the entire line instead.
11370 (when (= (+ to 2) from)
11373 (if gnus-newsgroup-selected-overlay
11374 ;; Move old overlay.
11376 gnus-newsgroup-selected-overlay from to (current-buffer))
11377 ;; Create new overlay.
11379 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11380 'face gnus-summary-selected-face))))))
11382 (defvar gnus-summary-highlight-line-cached nil)
11383 (defvar gnus-summary-highlight-line-trigger nil)
11385 (defun gnus-summary-highlight-line-0 ()
11386 (if (and (eq gnus-summary-highlight-line-trigger
11387 gnus-summary-highlight)
11388 gnus-summary-highlight-line-cached)
11389 gnus-summary-highlight-line-cached
11390 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11391 gnus-summary-highlight-line-cached
11392 (let* ((cond (list 'cond))
11394 (list gnus-summary-highlight))
11396 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11400 (gnus-byte-compile (list 'lambda nil cond))))))
11402 (defun gnus-summary-highlight-line ()
11403 "Highlight current line according to `gnus-summary-highlight'."
11404 (let* ((beg (point-at-bol))
11405 (article (or (gnus-summary-article-number) gnus-current-article))
11406 (score (or (cdr (assq article
11407 gnus-newsgroup-scored))
11408 gnus-summary-default-score 0))
11409 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11410 (inhibit-read-only t)
11411 (default gnus-summary-default-score)
11412 (default-high gnus-summary-default-high-score)
11413 (default-low gnus-summary-default-low-score)
11414 (uncached (and gnus-summary-use-undownloaded-faces
11415 (memq article gnus-newsgroup-undownloaded)
11416 (not (memq article gnus-newsgroup-cached)))))
11417 (let ((face (funcall (gnus-summary-highlight-line-0))))
11418 (unless (eq face (get-text-property beg 'face))
11419 (gnus-put-text-property-excluding-characters-with-faces
11420 beg (point-at-eol) 'face
11421 (setq face (if (boundp face) (symbol-value face) face)))
11422 (when gnus-summary-highlight-line-function
11423 (funcall gnus-summary-highlight-line-function article face))))))
11425 (defun gnus-update-read-articles (group unread &optional compute)
11426 "Update the list of read articles in GROUP.
11427 UNREAD is a sorted list."
11428 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11429 (info (gnus-get-info group))
11432 (if (or (not info) (not active))
11433 ;; There is no info on this group if it was, in fact,
11434 ;; killed. Gnus stores no information on killed groups, so
11435 ;; there's nothing to be done.
11436 ;; One could store the information somewhere temporarily,
11437 ;; perhaps... Hmmm...
11439 ;; Remove any negative articles numbers.
11440 (while (and unread (< (car unread) 0))
11441 (setq unread (cdr unread)))
11442 ;; Remove any expired article numbers
11443 (while (and unread (< (car unread) (car active)))
11444 (setq unread (cdr unread)))
11445 ;; Compute the ranges of read articles by looking at the list of
11446 ;; unread articles.
11448 (when (/= (car unread) prev)
11449 (push (if (= prev (1- (car unread))) prev
11450 (cons prev (1- (car unread))))
11452 (setq prev (1+ (car unread)))
11453 (setq unread (cdr unread)))
11454 (when (<= prev (cdr active))
11455 (push (cons prev (cdr active)) read))
11456 (setq read (if (> (length read) 1) (nreverse read) read))
11461 ;; Propagate the read marks to the backend.
11462 (when (gnus-check-backend-function 'request-set-mark group)
11463 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11464 (add (gnus-remove-from-range read (gnus-info-read info))))
11466 (unless (gnus-check-group group)
11467 (error "Can't open server for %s" group))
11468 (gnus-request-set-mark
11469 group (delq nil (list (if add (list add 'add '(read)))
11470 (if del (list del 'del '(read))))))
11472 `(gnus-request-set-mark
11475 (if del (list del 'add '(read)))
11476 (if add (list add 'del '(read))))))))))
11477 (set-buffer gnus-group-buffer)
11478 (gnus-undo-register
11480 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11481 (gnus-info-set-read ',info ',(gnus-info-read info))
11482 (gnus-get-unread-articles-in-group ',info
11483 (gnus-active ,group))
11484 (gnus-group-update-group ,group t)
11486 ;; Enter this list into the group info.
11487 (gnus-info-set-read info read)
11488 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11489 (gnus-get-unread-articles-in-group info (gnus-active group))
11492 (defun gnus-offer-save-summaries ()
11493 "Offer to save all active summary buffers."
11495 ;; Go through all buffers and find all summaries.
11496 (dolist (buffer (buffer-list))
11497 (when (and (setq buffer (buffer-name buffer))
11498 (string-match "Summary" buffer)
11500 (set-buffer buffer)
11501 ;; We check that this is, indeed, a summary buffer.
11502 (and (eq major-mode 'gnus-summary-mode)
11503 ;; Also make sure this isn't bogus.
11504 gnus-newsgroup-prepared
11505 ;; Also make sure that this isn't a
11506 ;; dead summary buffer.
11507 (not gnus-dead-summary-mode))))
11508 (push buffer buffers)))
11509 ;; Go through all these summary buffers and offer to save them.
11513 "Update summary buffer %s? "
11515 (switch-to-buffer buf)
11516 (gnus-summary-exit))
11520 ;;; @ for mime-partial
11523 (defun gnus-request-partial-message ()
11525 (let ((number (gnus-summary-article-number))
11526 (group gnus-newsgroup-name)
11527 (mother gnus-article-buffer))
11528 (set-buffer (get-buffer-create " *Partial Article*"))
11530 (setq mime-preview-buffer mother)
11531 (gnus-request-article-this-buffer number group)
11532 (mime-parse-buffer)
11535 (autoload 'mime-combine-message/partial-pieces-automatically
11537 "Internal method to combine message/partial messages automatically.")
11539 (mime-add-condition
11540 'action '((type . message)(subtype . partial)
11541 (major-mode . gnus-original-article-mode)
11542 (method . mime-combine-message/partial-pieces-automatically)
11543 (summary-buffer-exp . gnus-summary-buffer)
11544 (request-partial-message-method . gnus-request-partial-message)
11548 ;;; @ for message/rfc822
11551 (defun gnus-mime-extract-message/rfc822 (entity situation)
11552 "Burst a forwarded article."
11554 (set-buffer gnus-summary-buffer)
11555 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11556 gnus-newsgroup-name 'gnus-group-history))
11557 (gnus-group-marked (list group))
11560 (mime-insert-entity-content entity)
11561 (setq article (gnus-request-accept-article group)))
11562 (when (and (consp article)
11563 (numberp (setq article (cdr article))))
11564 (setq info (gnus-get-info group))
11565 (gnus-info-set-read info
11566 (gnus-remove-from-range (gnus-info-read info)
11568 (when (string-equal group gnus-newsgroup-name)
11570 (let (gnus-show-threads)
11571 (gnus-summary-goto-subject article t))
11572 (gnus-summary-clear-mark-forward 1))
11573 (set-buffer gnus-group-buffer)
11574 (gnus-group-get-new-news-this-group nil t)))))
11576 (mime-add-condition
11577 'action '((type . message)(subtype . rfc822)
11578 (major-mode . gnus-original-article-mode)
11579 (method . gnus-mime-extract-message/rfc822)
11583 (mime-add-condition
11584 'action '((type . message)(subtype . news)
11585 (major-mode . gnus-original-article-mode)
11586 (method . gnus-mime-extract-message/rfc822)
11590 (defun gnus-mime-extract-multipart (entity situation)
11591 (let ((children (mime-entity-children entity))
11592 mime-acting-situation-to-override
11595 (mime-play-entity (car children)
11596 (cons (assq 'mode situation)
11597 mime-acting-situation-to-override))
11598 (setq children (cdr children)))
11599 (if (setq f (cdr (assq 'after-method
11600 mime-acting-situation-to-override)))
11604 (mime-add-condition
11605 'action '((type . multipart)
11606 (method . gnus-mime-extract-multipart)
11615 (defun gnus-summary-inherit-default-charset ()
11616 "Import `default-mime-charset' from summary buffer.
11617 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11619 (if (buffer-live-p gnus-summary-buffer)
11620 (let (d-m-c d-m-c-u)
11621 (with-current-buffer gnus-summary-buffer
11622 (setq d-m-c (if (local-variable-p 'default-mime-charset
11623 gnus-summary-buffer)
11624 default-mime-charset
11627 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11628 gnus-summary-buffer)
11629 (symbol-value 'default-mime-charset-unlimited)
11632 (kill-local-variable 'default-mime-charset)
11633 (set (make-local-variable 'default-mime-charset) d-m-c))
11635 (kill-local-variable 'default-mime-charset-unlimited)
11636 (set (make-local-variable 'default-mime-charset-unlimited)
11639 (defun gnus-summary-setup-default-charset ()
11640 "Setup newsgroup default charset."
11641 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11643 (setq gnus-newsgroup-charset nil)
11644 (set (make-local-variable 'default-mime-charset) nil)
11645 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11646 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11647 (let ((ignored-charsets
11648 (or gnus-newsgroup-ephemeral-ignored-charsets
11650 (and gnus-newsgroup-name
11651 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11652 gnus-newsgroup-ignored-charsets)))
11654 (setq gnus-newsgroup-charset
11655 (or gnus-newsgroup-ephemeral-charset
11656 (when (and gnus-newsgroup-name
11657 (setq charset (gnus-parameter-charset
11658 gnus-newsgroup-name)))
11659 (make-local-variable 'default-mime-charset)
11660 (setq default-mime-charset charset))
11661 gnus-default-charset))
11662 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11663 ignored-charsets))))
11669 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11670 "Display the current article buffer fully MIME-buttonized.
11671 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11672 treated as multipart/mixed."
11674 (require 'gnus-art)
11675 (let ((gnus-unbuttonized-mime-types nil)
11676 (gnus-mime-display-multipart-as-mixed show-all-parts))
11677 (gnus-summary-show-article)))
11679 (defun gnus-summary-repair-multipart (article)
11680 "Add a Content-Type header to a multipart article without one."
11681 (interactive (list (gnus-summary-article-number)))
11682 (gnus-with-article article
11683 (message-narrow-to-head)
11684 (message-remove-header "Mime-Version")
11685 (goto-char (point-max))
11686 (insert "Mime-Version: 1.0\n")
11688 (when (search-forward "\n--" nil t)
11689 (let ((separator (buffer-substring (point) (point-at-eol))))
11690 (message-narrow-to-head)
11691 (message-remove-header "Content-Type")
11692 (goto-char (point-max))
11693 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11696 (let (gnus-mark-article-hook)
11697 (gnus-summary-select-article t t nil article)))
11699 (defun gnus-summary-toggle-display-buttonized ()
11700 "Toggle the buttonizing of the article buffer."
11702 (require 'gnus-art)
11703 (if (setq gnus-inhibit-mime-unbuttonizing
11704 (not gnus-inhibit-mime-unbuttonizing))
11705 (let ((gnus-unbuttonized-mime-types nil))
11706 (gnus-summary-show-article))
11707 (gnus-summary-show-article)))
11710 ;;; Intelli-mouse commmands
11713 (defun gnus-wheel-summary-scroll (event)
11715 (let ((amount (if (memq 'shift (event-modifiers event))
11716 (car gnus-wheel-scroll-amount)
11717 (cdr gnus-wheel-scroll-amount)))
11718 (direction (- (* (static-if (featurep 'xemacs)
11719 (event-button event)
11720 (cond ((eq 'mouse-4 (event-basic-type event))
11722 ((eq 'mouse-5 (event-basic-type event))
11726 (gnus-summary-scroll-up (* amount direction))
11727 (when (gnus-eval-in-buffer-window gnus-article-buffer
11730 (and (if (< 0 direction)
11731 (gnus-article-next-page 0)
11732 (gnus-article-prev-page 0)
11734 (if (setq edge (get-text-property
11735 (point-min) 'gnus-wheel-edge))
11736 (setq edge (* edge direction))
11739 (let ((buffer-read-only nil)
11740 (inhibit-read-only t))
11741 (put-text-property (point-min) (point-max)
11742 'gnus-wheel-edge direction)
11744 (or (> edge gnus-wheel-edge-resistance)
11745 (let ((buffer-read-only nil)
11746 (inhibit-read-only t))
11747 (put-text-property (point-min) (point-max)
11749 (* (1+ edge) direction))
11751 (eq last-command 'gnus-wheel-summary-scroll))))
11752 (gnus-summary-next-article nil nil (minusp direction)))))
11754 (defun gnus-wheel-install ()
11755 "Enable mouse wheel support on summary window."
11756 (when gnus-use-wheel
11758 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11760 (define-key gnus-summary-mode-map key
11761 'gnus-wheel-summary-scroll)))))
11763 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11766 ;;; Traditional PGP commmands
11769 (defun gnus-summary-decrypt-article (&optional force)
11770 "Decrypt the current article in traditional PGP way.
11771 This will have permanent effect only in mail groups.
11772 If FORCE is non-nil, allow editing of articles even in read-only
11775 (gnus-summary-select-article t)
11776 (gnus-eval-in-buffer-window gnus-article-buffer
11780 (goto-char (point-min))
11781 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11782 (error "Not a traditional PGP message!"))
11783 (let ((armor-start (match-beginning 0)))
11784 (if (and (pgg-decrypt-region armor-start (point-max))
11785 (or force (not (gnus-group-read-only-p))))
11786 (let ((inhibit-read-only t)
11788 (delete-region armor-start
11790 (re-search-forward "^-+END PGP" nil t)
11791 (beginning-of-line 2)
11793 (insert-buffer-substring pgg-output-buffer))))))))
11795 (defun gnus-summary-verify-article ()
11796 "Verify the current article in traditional PGP way."
11799 (set-buffer gnus-original-article-buffer)
11800 (goto-char (point-min))
11801 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11802 (error "Not a traditional PGP message!"))
11803 (re-search-forward "^-+END PGP" nil t)
11804 (beginning-of-line 2)
11805 (call-interactively (function pgg-verify-region))))
11808 ;;; Generic summary marking commands
11811 (defvar gnus-summary-marking-alist
11812 '((read gnus-del-mark "d")
11813 (unread gnus-unread-mark "u")
11814 (ticked gnus-ticked-mark "!")
11815 (dormant gnus-dormant-mark "?")
11816 (expirable gnus-expirable-mark "e"))
11817 "An alist of names/marks/keystrokes.")
11819 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11820 (defvar gnus-summary-mark-map)
11822 (defun gnus-summary-make-all-marking-commands ()
11823 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11824 (dolist (elem gnus-summary-marking-alist)
11825 (apply 'gnus-summary-make-marking-command elem)))
11827 (defun gnus-summary-make-marking-command (name mark keystroke)
11828 (let ((map (make-sparse-keymap)))
11829 (define-key gnus-summary-generic-mark-map keystroke map)
11830 (dolist (lway `((next "next" next nil "n")
11831 (next-unread "next unread" next t "N")
11832 (prev "previous" prev nil "p")
11833 (prev-unread "previous unread" prev t "P")
11834 (nomove "" nil nil ,keystroke)))
11835 (let ((func (gnus-summary-make-marking-command-1
11836 mark (car lway) lway name)))
11837 (setq func (eval func))
11838 (define-key map (nth 4 lway) func)))))
11840 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11842 (format "gnus-summary-put-mark-as-%s%s"
11843 name (if (eq way 'nomove)
11845 (concat "-" (symbol-name way)))))
11848 "Mark the current article as %s%s.
11849 If N, the prefix, then repeat N times.
11850 If N is negative, move in reverse order.
11851 The difference between N and the actual number of articles marked is
11853 name (car (cdr lway)))
11855 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11857 (defun gnus-summary-generic-mark (n mark move unread)
11858 "Mark N articles with MARK."
11859 (unless (eq major-mode 'gnus-summary-mode)
11860 (error "This command can only be used in the summary buffer"))
11861 (gnus-summary-show-thread)
11864 ((eq move 'next) 1)
11865 ((eq move 'prev) -1)
11867 (if (zerop nummove)
11871 nummove (* -1 nummove))))
11872 (while (and (> n 0)
11873 (gnus-summary-mark-article nil mark)
11874 (zerop (gnus-summary-next-subject nummove unread t)))
11877 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11878 (gnus-summary-recenter)
11879 (gnus-summary-position-point)
11880 (gnus-set-mode-line 'summary)
11883 (defun gnus-summary-insert-articles (articles)
11884 (when (setq articles
11885 (gnus-sorted-difference articles
11886 (mapcar (lambda (h)
11887 (mail-header-number h))
11888 gnus-newsgroup-headers)))
11889 (setq gnus-newsgroup-headers
11891 gnus-newsgroup-headers
11892 (gnus-fetch-headers articles)
11893 'gnus-article-sort-by-number))
11894 ;; Suppress duplicates?
11895 (when gnus-suppress-duplicates
11896 (gnus-dup-suppress-articles))
11898 ;; We might want to build some more threads first.
11899 (when (and gnus-fetch-old-headers
11900 (eq gnus-headers-retrieved-by 'nov))
11901 (if (eq gnus-fetch-old-headers 'invisible)
11902 (gnus-build-all-threads)
11903 (gnus-build-old-threads)))
11904 ;; Let the Gnus agent mark articles as read.
11906 (gnus-agent-get-undownloaded-list))
11907 ;; Remove list identifiers from subject
11908 (when gnus-list-identifiers
11909 (gnus-summary-remove-list-identifiers))
11910 ;; First and last article in this newsgroup.
11911 (when gnus-newsgroup-headers
11912 (setq gnus-newsgroup-begin
11913 (mail-header-number (car gnus-newsgroup-headers))
11915 (mail-header-number
11916 (gnus-last-element gnus-newsgroup-headers))))
11917 (when gnus-use-scoring
11918 (gnus-possibly-score-headers))))
11920 (defun gnus-summary-insert-old-articles (&optional all)
11921 "Insert all old articles in this group.
11922 If ALL is non-nil, already read articles become readable.
11923 If ALL is a number, fetch this number of articles."
11926 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11929 ;; Some nntp servers lie about their active range. When
11930 ;; this happens, the active range can be in the millions.
11931 ;; Use a compressed range to avoid creating a huge list.
11932 (gnus-range-difference (list gnus-newsgroup-active) old))
11933 (setq len (gnus-range-length older))
11938 (let ((older-range (nreverse older)))
11942 (let* ((r (pop older-range))
11943 (min (if (numberp r) r (car r)))
11944 (max (if (numberp r) r (cdr r))))
11945 (while (and (<= min max)
11950 (setq older (gnus-uncompress-range older))))
11952 (setq older (gnus-uncompress-range older)))
11954 (when (and (numberp gnus-large-newsgroup)
11955 (> len gnus-large-newsgroup))
11956 (let* ((cursor-in-echo-area nil)
11957 (initial (gnus-parameter-large-newsgroup-initial
11958 gnus-newsgroup-name))
11962 "How many articles from %s (%s %d): "
11964 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11965 (if initial "max" "default")
11968 (cons (number-to-string initial)
11970 (unless (string-match "^[ \t]*$" input)
11971 (setq all (string-to-number input))
11973 (let ((older-range (nreverse older)))
11977 (let* ((r (pop older-range))
11978 (min (if (numberp r) r (car r)))
11979 (max (if (numberp r) r (cdr r))))
11980 (while (and (<= min max)
11984 max (1- max))))))))))
11985 (setq older (gnus-uncompress-range older))))
11987 (message "No old news.")
11988 (gnus-summary-insert-articles older)
11989 (gnus-summary-limit (gnus-sorted-nunion old older))))
11990 (gnus-summary-position-point)))
11992 (defun gnus-summary-insert-new-articles ()
11993 "Insert all new articles in this group."
11996 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11997 (old-active gnus-newsgroup-active)
11998 (nnmail-fetched-sources (list t))
12000 (setq gnus-newsgroup-active
12001 (gnus-activate-group gnus-newsgroup-name 'scan))
12002 (setq i (cdr gnus-newsgroup-active))
12003 (while (> i (cdr old-active))
12007 (message "No gnus is bad news")
12008 (gnus-summary-insert-articles new)
12009 (setq gnus-newsgroup-unreads
12010 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12011 (gnus-summary-limit (gnus-sorted-nunion old new))))
12012 (gnus-summary-position-point)))
12014 (gnus-summary-make-all-marking-commands)
12016 (gnus-ems-redefine)
12018 (provide 'gnus-sum)
12020 (run-hooks 'gnus-sum-load-hook)
12022 ;; Local Variables:
12023 ;; coding: iso-8859-1
12026 ;;; gnus-sum.el ends here