1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
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.
34 (defvar tool-bar-map))
51 (autoload 'pgg-decrypt-region "pgg" nil t)
52 (autoload 'pgg-verify-region "pgg" nil t))
54 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
55 (autoload 'gnus-cache-write-active "gnus-cache")
56 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
57 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
58 (autoload 'mm-uu-dissect "mm-uu")
59 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
60 "Deuglify broken Outlook (Express) articles and redisplay."
62 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
63 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
64 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
66 (defcustom gnus-kill-summary-on-exit t
67 "*If non-nil, kill the summary buffer when you exit from it.
68 If nil, the summary will become a \"*Dead Summary*\" buffer, and
69 it will be killed sometime later."
70 :group 'gnus-summary-exit
73 (defcustom gnus-fetch-old-headers nil
74 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
75 If an unread article in the group refers to an older, already read (or
76 just marked as read) article, the old article will not normally be
77 displayed in the Summary buffer. If this variable is non-nil, Gnus
78 will attempt to grab the headers to the old articles, and thereby
79 build complete threads. If it has the value `some', only enough
80 headers to connect otherwise loose threads will be displayed. This
81 variable can also be a number. In that case, no more than that number
82 of old headers will be fetched. If it has the value `invisible', all
83 old headers will be fetched, but none will be displayed.
85 The server has to support NOV for any of this to work."
87 :type '(choice (const :tag "off" nil)
90 (sexp :menu-tag "other" t)))
92 (defcustom gnus-refer-thread-limit 200
93 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
94 If t, fetch all the available old headers."
97 (sexp :menu-tag "other" t)))
99 (defcustom gnus-summary-make-false-root 'adopt
100 "*nil means that Gnus won't gather loose threads.
101 If the root of a thread has expired or been read in a previous
102 session, the information necessary to build a complete thread has been
103 lost. Instead of having many small sub-threads from this original thread
104 scattered all over the summary buffer, Gnus can gather them.
106 If non-nil, Gnus will try to gather all loose sub-threads from an
107 original thread into one large thread.
109 If this variable is non-nil, it should be one of `none', `adopt',
112 If this variable is `none', Gnus will not make a false root, but just
113 present the sub-threads after another.
114 If this variable is `dummy', Gnus will create a dummy root that will
115 have all the sub-threads as children.
116 If this variable is `adopt', Gnus will make one of the \"children\"
117 the parent and mark all the step-children as such.
118 If this variable is `empty', the \"children\" are printed with empty
119 subject fields. (Or rather, they will be printed with a string
120 given by the `gnus-summary-same-subject' variable.)"
122 :type '(choice (const :tag "off" nil)
128 (defcustom gnus-summary-make-false-root-always nil
129 "Always make a false dummy root."
133 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
134 "*A regexp to match subjects to be excluded from loose thread gathering.
135 As loose thread gathering is done on subjects only, that means that
136 there can be many false gatherings performed. By rooting out certain
137 common subjects, gathering might become saner."
141 (defcustom gnus-summary-gather-subject-limit nil
142 "*Maximum length of subject comparisons when gathering loose threads.
143 Use nil to compare full subjects. Setting this variable to a low
144 number will help gather threads that have been corrupted by
145 newsreaders chopping off subject lines, but it might also mean that
146 unrelated articles that have subject that happen to begin with the
147 same few characters will be incorrectly gathered.
149 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
152 :type '(choice (const :tag "off" nil)
154 (sexp :menu-tag "on" t)))
156 (defcustom gnus-simplify-subject-functions nil
157 "List of functions taking a string argument that simplify subjects.
158 The functions are applied recursively.
160 Useful functions to put in this list include:
161 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
162 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
164 :type '(repeat function))
166 (defcustom gnus-simplify-ignored-prefixes nil
167 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
169 :type '(choice (const :tag "off" nil)
172 (defcustom gnus-build-sparse-threads nil
173 "*If non-nil, fill in the gaps in threads.
174 If `some', only fill in the gaps that are needed to tie loose threads
175 together. If `more', fill in all leaf nodes that Gnus can find. If
176 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
178 :type '(choice (const :tag "off" nil)
181 (sexp :menu-tag "all" t)))
183 (defcustom gnus-summary-thread-gathering-function
184 'gnus-gather-threads-by-subject
185 "*Function used for gathering loose threads.
186 There are two pre-defined functions: `gnus-gather-threads-by-subject',
187 which only takes Subjects into consideration; and
188 `gnus-gather-threads-by-references', which compared the References
189 headers of the articles to find matches."
191 :type '(radio (function-item gnus-gather-threads-by-subject)
192 (function-item gnus-gather-threads-by-references)
193 (function :tag "other")))
195 (defcustom gnus-summary-same-subject ""
196 "*String indicating that the current article has the same subject as the previous.
197 This variable will only be used if the value of
198 `gnus-summary-make-false-root' is `empty'."
199 :group 'gnus-summary-format
202 (defcustom gnus-summary-goto-unread t
203 "*If t, many commands will go to the next unread article.
204 This applies to marking commands as well as other commands that
205 \"naturally\" select the next article, like, for instance, `SPC' at
206 the end of an article.
208 If nil, the marking commands do NOT go to the next unread article
209 \(they go to the next article instead). If `never', commands that
210 usually go to the next unread article, will go to the next article,
211 whether it is read or not."
212 :group 'gnus-summary-marks
213 :link '(custom-manual "(gnus)Setting Marks")
214 :type '(choice (const :tag "off" nil)
216 (sexp :menu-tag "on" t)))
218 (defcustom gnus-summary-default-score 0
219 "*Default article score level.
220 All scores generated by the score files will be added to this score.
221 If this variable is nil, scoring will be disabled."
222 :group 'gnus-score-default
223 :type '(choice (const :tag "disable")
226 (defcustom gnus-summary-default-high-score 0
227 "*Default threshold for a high scored article.
228 An article will be highlighted as high scored if its score is greater
230 :group 'gnus-score-default
233 (defcustom gnus-summary-default-low-score 0
234 "*Default threshold for a low scored article.
235 An article will be highlighted as low scored if its score is smaller
237 :group 'gnus-score-default
240 (defcustom gnus-summary-zcore-fuzz 0
241 "*Fuzziness factor for the zcore in the summary buffer.
242 Articles with scores closer than this to `gnus-summary-default-score'
244 :group 'gnus-summary-format
247 (defcustom gnus-simplify-subject-fuzzy-regexp nil
248 "*Strings to be removed when doing fuzzy matches.
249 This can either be a regular expression or list of regular expressions
250 that will be removed from subject strings if fuzzy subject
251 simplification is selected."
253 :type '(repeat regexp))
255 (defcustom gnus-show-threads t
256 "*If non-nil, display threads in summary mode."
260 (defcustom gnus-thread-hide-subtree nil
261 "*If non-nil, hide all threads initially.
262 This can be a predicate specifier which says which threads to hide.
263 If threads are hidden, you have to run the command
264 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
265 to expose hidden threads."
269 (defcustom gnus-thread-hide-killed t
270 "*If non-nil, hide killed threads automatically."
274 (defcustom gnus-thread-ignore-subject t
275 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
276 If nil, articles that have different subjects from their parents will
277 start separate threads."
281 (defcustom gnus-thread-operation-ignore-subject t
282 "*If non-nil, subjects will be ignored when doing thread commands.
283 This affects commands like `gnus-summary-kill-thread' and
284 `gnus-summary-lower-thread'.
286 If this variable is nil, articles in the same thread with different
287 subjects will not be included in the operation in question. If this
288 variable is `fuzzy', only articles that have subjects that are fuzzily
289 equal will be included."
291 :type '(choice (const :tag "off" nil)
295 (defcustom gnus-thread-indent-level 4
296 "*Number that says how much each sub-thread should be indented."
300 (defcustom gnus-auto-extend-newsgroup t
301 "*If non-nil, extend newsgroup forward and backward when requested."
302 :group 'gnus-summary-choose
305 (defcustom gnus-auto-select-first t
306 "*If non-nil, select the article under point.
307 Which article this is is controlled by the `gnus-auto-select-subject'
310 If you want to prevent automatic selection of articles in some
311 newsgroups, set the variable to nil in `gnus-select-group-hook'."
312 :group 'gnus-group-select
313 :type '(choice (const :tag "none" nil)
314 (sexp :menu-tag "first" t)))
316 (defcustom gnus-auto-select-subject 'unread
317 "*Says what subject to place under point when entering a group.
319 This variable can either be the symbols `first' (place point on the
320 first subject), `unread' (place point on the subject line of the first
321 unread article), `best' (place point on the subject line of the
322 higest-scored article), `unseen' (place point on the subject line of
323 the first unseen article), 'unseen-or-unread' (place point on the subject
324 line of the first unseen article or, if all article have been seen, on the
325 subject line of the first unread article), or a function to be called to
326 place point on some subject line."
327 :group 'gnus-group-select
328 :type '(choice (const best)
332 (const unseen-or-unread)))
334 (defcustom gnus-dont-select-after-jump-to-other-group nil
335 "If non-nil, don't select the first unread article after entering the
336 other group by the command `gnus-summary-jump-to-other-group'. If nil,
337 it is depend on the value of `gnus-auto-select-first' whether to select
339 :group 'gnus-group-select
342 (defcustom gnus-auto-select-next t
343 "*If non-nil, offer to go to the next group from the end of the previous.
344 If the value is t and the next newsgroup is empty, Gnus will exit
345 summary mode and go back to group mode. If the value is neither nil
346 nor t, Gnus will select the following unread newsgroup. In
347 particular, if the value is the symbol `quietly', the next unread
348 newsgroup will be selected without any confirmation, and if it is
349 `almost-quietly', the next group will be selected without any
350 confirmation if you are located on the last article in the group.
351 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
352 will go to the next group without confirmation."
353 :group 'gnus-summary-maneuvering
354 :type '(choice (const :tag "off" nil)
356 (const almost-quietly)
357 (const slightly-quietly)
358 (sexp :menu-tag "on" t)))
360 (defcustom gnus-auto-select-same nil
361 "*If non-nil, select the next article with the same subject.
362 If there are no more articles with the same subject, go to
363 the first unread article."
364 :group 'gnus-summary-maneuvering
367 (defcustom gnus-auto-goto-ignores 'unfetched
368 "*Says how to handle unfetched articles when maneuvering.
370 This variable can either be the symbols nil (maneuver to any
371 article), `undownloaded' (maneuvering while unplugged ignores articles
372 that have not been fetched), `always-undownloaded' (maneuvering always
373 ignores articles that have not been fetched), `unfetched' (maneuvering
374 ignores articles whose headers have not been fetched).
376 NOTE: The list of unfetched articles will always be nil when plugged
377 and, when unplugged, a subset of the undownloaded article list."
378 :group 'gnus-summary-maneuvering
379 :type '(choice (const :tag "None" nil)
380 (const :tag "Undownloaded when unplugged" undownloaded)
381 (const :tag "Undownloaded" always-undownloaded)
382 (const :tag "Unfetched" unfetched)))
384 (defcustom gnus-summary-check-current nil
385 "*If non-nil, consider the current article when moving.
386 The \"unread\" movement commands will stay on the same line if the
387 current article is unread."
388 :group 'gnus-summary-maneuvering
391 (defcustom gnus-auto-center-summary t
392 "*If non-nil, always center the current summary buffer.
393 In particular, if `vertical' do only vertical recentering. If non-nil
394 and non-`vertical', do both horizontal and vertical recentering."
395 :group 'gnus-summary-maneuvering
396 :type '(choice (const :tag "none" nil)
398 (integer :tag "height")
399 (sexp :menu-tag "both" t)))
401 (defvar gnus-auto-center-group t
402 "*If non-nil, always center the group buffer.")
404 (defcustom gnus-show-all-headers nil
405 "*If non-nil, don't hide any headers."
406 :group 'gnus-article-hiding
407 :group 'gnus-article-headers
410 (defcustom gnus-summary-ignore-duplicates nil
411 "*If non-nil, ignore articles with identical Message-ID headers."
415 (defcustom gnus-single-article-buffer t
416 "*If non-nil, display all articles in the same buffer.
417 If nil, each group will get its own article buffer."
418 :group 'gnus-article-various
421 (defcustom gnus-break-pages t
422 "*If non-nil, do page breaking on articles.
423 The page delimiter is specified by the `gnus-page-delimiter'
425 :group 'gnus-article-various
428 (defcustom gnus-show-mime t
429 "*If non-nil, do mime processing of articles.
430 The articles will simply be fed to the function given by
431 `gnus-article-display-method-for-mime'."
432 :group 'gnus-article-mime
435 (defcustom gnus-move-split-methods nil
436 "*Variable used to suggest where articles are to be moved to.
437 It uses the same syntax as the `gnus-split-methods' variable.
438 However, whereas `gnus-split-methods' specifies file names as targets,
439 this variable specifies group names."
440 :group 'gnus-summary-mail
441 :type '(repeat (choice (list :value (fun) function)
442 (cons :value ("" "") regexp (repeat string))
445 (defcustom gnus-unread-mark ?\ ;;;Whitespace
446 "*Mark used for unread articles."
447 :group 'gnus-summary-marks
450 (defcustom gnus-ticked-mark ?!
451 "*Mark used for ticked articles."
452 :group 'gnus-summary-marks
455 (defcustom gnus-dormant-mark ??
456 "*Mark used for dormant articles."
457 :group 'gnus-summary-marks
460 (defcustom gnus-del-mark ?r
461 "*Mark used for del'd articles."
462 :group 'gnus-summary-marks
465 (defcustom gnus-read-mark ?R
466 "*Mark used for read articles."
467 :group 'gnus-summary-marks
470 (defcustom gnus-expirable-mark ?E
471 "*Mark used for expirable articles."
472 :group 'gnus-summary-marks
475 (defcustom gnus-killed-mark ?K
476 "*Mark used for killed articles."
477 :group 'gnus-summary-marks
480 (defcustom gnus-spam-mark ?$
481 "*Mark used for spam articles."
482 :group 'gnus-summary-marks
485 (defcustom gnus-souped-mark ?F
486 "*Mark used for souped articles."
487 :group 'gnus-summary-marks
490 (defcustom gnus-kill-file-mark ?X
491 "*Mark used for articles killed by kill files."
492 :group 'gnus-summary-marks
495 (defcustom gnus-low-score-mark ?Y
496 "*Mark used for articles with a low score."
497 :group 'gnus-summary-marks
500 (defcustom gnus-catchup-mark ?C
501 "*Mark used for articles that are caught up."
502 :group 'gnus-summary-marks
505 (defcustom gnus-replied-mark ?A
506 "*Mark used for articles that have been replied to."
507 :group 'gnus-summary-marks
510 (defcustom gnus-forwarded-mark ?F
511 "*Mark used for articles that have been forwarded."
512 :group 'gnus-summary-marks
515 (defcustom gnus-recent-mark ?N
516 "*Mark used for articles that are recent."
517 :group 'gnus-summary-marks
520 (defcustom gnus-cached-mark ?*
521 "*Mark used for articles that are in the cache."
522 :group 'gnus-summary-marks
525 (defcustom gnus-saved-mark ?S
526 "*Mark used for articles that have been saved."
527 :group 'gnus-summary-marks
530 (defcustom gnus-unseen-mark ?.
531 "*Mark used for articles that haven't been seen."
532 :group 'gnus-summary-marks
535 (defcustom gnus-no-mark ?\ ;;;Whitespace
536 "*Mark used for articles that have no other secondary mark."
537 :group 'gnus-summary-marks
540 (defcustom gnus-ancient-mark ?O
541 "*Mark used for ancient articles."
542 :group 'gnus-summary-marks
545 (defcustom gnus-sparse-mark ?Q
546 "*Mark used for sparsely reffed articles."
547 :group 'gnus-summary-marks
550 (defcustom gnus-canceled-mark ?G
551 "*Mark used for canceled articles."
552 :group 'gnus-summary-marks
555 (defcustom gnus-duplicate-mark ?M
556 "*Mark used for duplicate articles."
557 :group 'gnus-summary-marks
560 (defcustom gnus-undownloaded-mark ?-
561 "*Mark used for articles that weren't downloaded."
562 :group 'gnus-summary-marks
565 (defcustom gnus-downloaded-mark ?+
566 "*Mark used for articles that were downloaded."
567 :group 'gnus-summary-marks
570 (defcustom gnus-downloadable-mark ?%
571 "*Mark used for articles that are to be downloaded."
572 :group 'gnus-summary-marks
575 (defcustom gnus-unsendable-mark ?=
576 "*Mark used for articles that won't be sent."
577 :group 'gnus-summary-marks
580 (defcustom gnus-score-over-mark ?+
581 "*Score mark used for articles with high scores."
582 :group 'gnus-summary-marks
585 (defcustom gnus-score-below-mark ?-
586 "*Score mark used for articles with low scores."
587 :group 'gnus-summary-marks
590 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
591 "*There is no thread under the article."
592 :group 'gnus-summary-marks
595 (defcustom gnus-not-empty-thread-mark ?=
596 "*There is a thread under the article."
597 :group 'gnus-summary-marks
600 (defcustom gnus-view-pseudo-asynchronously nil
601 "*If non-nil, Gnus will view pseudo-articles asynchronously."
602 :group 'gnus-extract-view
605 (defcustom gnus-auto-expirable-marks
606 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
607 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
608 gnus-souped-mark gnus-duplicate-mark)
609 "*The list of marks converted into expiration if a group is auto-expirable."
612 :type '(repeat character))
614 (defcustom gnus-inhibit-user-auto-expire t
615 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
620 (defcustom gnus-view-pseudos nil
621 "*If `automatic', pseudo-articles will be viewed automatically.
622 If `not-confirm', pseudos will be viewed automatically, and the user
623 will not be asked to confirm the command."
624 :group 'gnus-extract-view
625 :type '(choice (const :tag "off" nil)
627 (const not-confirm)))
629 (defcustom gnus-view-pseudos-separately t
630 "*If non-nil, one pseudo-article will be created for each file to be viewed.
631 If nil, all files that use the same viewing command will be given as a
632 list of parameters to that command."
633 :group 'gnus-extract-view
636 (defcustom gnus-insert-pseudo-articles t
637 "*If non-nil, insert pseudo-articles when decoding articles."
638 :group 'gnus-extract-view
641 (defcustom gnus-summary-dummy-line-format
643 "*The format specification for the dummy roots in the summary buffer.
644 It works along the same lines as a normal formatting string,
645 with some simple extensions.
649 General format specifiers can also be used.
650 See `(gnus)Formatting Variables'."
651 :link '(custom-manual "(gnus)Formatting Variables")
652 :group 'gnus-threading
655 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
656 "*The format specification for the summary mode line.
657 It works along the same lines as a normal formatting string,
658 with some simple extensions:
661 %p Unprefixed group name
662 %A Current article number
663 %z Current article score
665 %U Number of unread articles in the group
666 %e Number of unselected articles in the group
667 %Z A string with unread/unselected article counts
668 %g Shortish group name
669 %S Subject of the current article
671 %s Current score file name
672 %d Number of dormant articles
673 %r Number of articles that have been marked as read in this session
674 %E Number of articles expunged by the score files"
675 :group 'gnus-summary-format
678 (defcustom gnus-list-identifiers nil
679 "Regexp that matches list identifiers to be removed from subject.
680 This can also be a list of regexps."
682 :group 'gnus-summary-format
683 :group 'gnus-article-hiding
684 :type '(choice (const :tag "none" nil)
686 (repeat :value (".*") regexp)))
688 (defcustom gnus-summary-mark-below 0
689 "*Mark all articles with a score below this variable as read.
690 This variable is local to each summary buffer and usually set by the
692 :group 'gnus-score-default
695 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
696 "*List of functions used for sorting articles in the summary buffer.
698 Each function takes two articles and returns non-nil if the first
699 article should be sorted before the other. If you use more than one
700 function, the primary sort function should be the last. You should
701 probably always include `gnus-article-sort-by-number' in the list of
702 sorting functions -- preferably first. Also note that sorting by date
703 is often much slower than sorting by number, and the sorting order is
704 very similar. (Sorting by date means sorting by the time the message
705 was sent, sorting by number means sorting by arrival time.)
707 Ready-made functions include `gnus-article-sort-by-number',
708 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
709 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
710 and `gnus-article-sort-by-score'.
712 When threading is turned on, the variable `gnus-thread-sort-functions'
713 controls how articles are sorted."
714 :group 'gnus-summary-sort
715 :type '(repeat (choice (function-item gnus-article-sort-by-number)
716 (function-item gnus-article-sort-by-author)
717 (function-item gnus-article-sort-by-subject)
718 (function-item gnus-article-sort-by-date)
719 (function-item gnus-article-sort-by-score)
720 (function-item gnus-article-sort-by-random)
721 (function :tag "other"))))
723 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
724 "*List of functions used for sorting threads in the summary buffer.
725 By default, threads are sorted by article number.
727 Each function takes two threads and returns non-nil if the first
728 thread should be sorted before the other. If you use more than one
729 function, the primary sort function should be the last. You should
730 probably always include `gnus-thread-sort-by-number' in the list of
731 sorting functions -- preferably first. Also note that sorting by date
732 is often much slower than sorting by number, and the sorting order is
733 very similar. (Sorting by date means sorting by the time the message
734 was sent, sorting by number means sorting by arrival time.)
736 Ready-made functions include `gnus-thread-sort-by-number',
737 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
738 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
739 `gnus-thread-sort-by-most-recent-number',
740 `gnus-thread-sort-by-most-recent-date',
741 `gnus-thread-sort-by-random', and
742 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
744 When threading is turned off, the variable
745 `gnus-article-sort-functions' controls how articles are sorted."
746 :group 'gnus-summary-sort
747 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
748 (function-item gnus-thread-sort-by-author)
749 (function-item gnus-thread-sort-by-subject)
750 (function-item gnus-thread-sort-by-date)
751 (function-item gnus-thread-sort-by-score)
752 (function-item gnus-thread-sort-by-total-score)
753 (function-item gnus-thread-sort-by-random)
754 (function :tag "other"))))
756 (defcustom gnus-thread-score-function '+
757 "*Function used for calculating the total score of a thread.
759 The function is called with the scores of the article and each
760 subthread and should then return the score of the thread.
762 Some functions you can use are `+', `max', or `min'."
763 :group 'gnus-summary-sort
766 (defcustom gnus-summary-expunge-below nil
767 "All articles that have a score less than this variable will be expunged.
768 This variable is local to the summary buffers."
769 :group 'gnus-score-default
770 :type '(choice (const :tag "off" nil)
773 (defcustom gnus-thread-expunge-below nil
774 "All threads that have a total score less than this variable will be expunged.
775 See `gnus-thread-score-function' for en explanation of what a
778 This variable is local to the summary buffers."
779 :group 'gnus-threading
780 :group 'gnus-score-default
781 :type '(choice (const :tag "off" nil)
784 (defcustom gnus-summary-mode-hook nil
785 "*A hook for Gnus summary mode.
786 This hook is run before any variables are set in the summary buffer."
787 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
788 :group 'gnus-summary-various
791 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
792 (when (featurep 'xemacs)
793 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
794 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
795 (add-hook 'gnus-summary-mode-hook
796 'gnus-xmas-switch-horizontal-scrollbar-off))
798 (defcustom gnus-summary-menu-hook nil
799 "*Hook run after the creation of the summary mode menu."
800 :group 'gnus-summary-visual
803 (defcustom gnus-summary-exit-hook nil
804 "*A hook called on exit from the summary buffer.
805 It will be called with point in the group buffer."
806 :group 'gnus-summary-exit
809 (defcustom gnus-summary-prepare-hook nil
810 "*A hook called after the summary buffer has been generated.
811 If you want to modify the summary buffer, you can use this hook."
812 :group 'gnus-summary-various
815 (defcustom gnus-summary-prepared-hook nil
816 "*A hook called as the last thing after the summary buffer has been generated."
817 :group 'gnus-summary-various
820 (defcustom gnus-summary-generate-hook nil
821 "*A hook run just before generating the summary buffer.
822 This hook is commonly used to customize threading variables and the
824 :group 'gnus-summary-various
827 (defcustom gnus-select-group-hook nil
828 "*A hook called when a newsgroup is selected.
830 If you'd like to simplify subjects like the
831 `gnus-summary-next-same-subject' command does, you can use the
834 (add-hook gnus-select-group-hook
836 (mapcar (lambda (header)
837 (mail-header-set-subject
839 (gnus-simplify-subject
840 (mail-header-subject header) 're-only)))
841 gnus-newsgroup-headers)))"
842 :group 'gnus-group-select
845 (defcustom gnus-select-article-hook nil
846 "*A hook called when an article is selected."
847 :group 'gnus-summary-choose
848 :options '(gnus-agent-fetch-selected-article)
851 (defcustom gnus-visual-mark-article-hook
852 (list 'gnus-highlight-selected-summary)
853 "*Hook run after selecting an article in the summary buffer.
854 It is meant to be used for highlighting the article in some way. It
855 is not run if `gnus-visual' is nil."
856 :group 'gnus-summary-visual
859 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
860 "*A hook called before parsing the headers."
864 (defcustom gnus-exit-group-hook nil
865 "*A hook called when exiting summary mode.
866 This hook is not called from the non-updating exit commands like `Q'."
870 (defcustom gnus-summary-update-hook
871 (list 'gnus-summary-highlight-line)
872 "*A hook called when a summary line is changed.
873 The hook will not be called if `gnus-visual' is nil.
875 The default function `gnus-summary-highlight-line' will
876 highlight the line according to the `gnus-summary-highlight'
878 :group 'gnus-summary-visual
881 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
882 "*A hook called when an article is selected for the first time.
883 The hook is intended to mark an article as read (or unread)
884 automatically when it is selected."
885 :group 'gnus-summary-choose
888 (defcustom gnus-group-no-more-groups-hook nil
889 "*A hook run when returning to group mode having no more (unread) groups."
890 :group 'gnus-group-select
893 (defcustom gnus-ps-print-hook nil
894 "*A hook run before ps-printing something from Gnus."
898 (defcustom gnus-summary-article-move-hook nil
899 "*A hook called after an article is moved, copied, respooled, or crossposted."
903 (defcustom gnus-summary-article-delete-hook nil
904 "*A hook called after an article is deleted."
908 (defcustom gnus-summary-article-expire-hook nil
909 "*A hook called after an article is expired."
913 (defcustom gnus-summary-display-arrow
914 (and (fboundp 'display-graphic-p)
916 "*If non-nil, display an arrow highlighting the current article."
921 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
922 "Face used for highlighting the current article in the summary buffer."
923 :group 'gnus-summary-visual
926 (defvar gnus-tmp-downloaded nil)
928 (defcustom gnus-summary-highlight
929 '(((eq mark gnus-canceled-mark)
930 . gnus-summary-cancelled-face)
931 ((and uncached (> score default-high))
932 . gnus-summary-high-undownloaded-face)
933 ((and uncached (< score default-low))
934 . gnus-summary-low-undownloaded-face)
936 . gnus-summary-normal-undownloaded-face)
937 ((and (> score default-high)
938 (or (eq mark gnus-dormant-mark)
939 (eq mark gnus-ticked-mark)))
940 . gnus-summary-high-ticked-face)
941 ((and (< score default-low)
942 (or (eq mark gnus-dormant-mark)
943 (eq mark gnus-ticked-mark)))
944 . gnus-summary-low-ticked-face)
945 ((or (eq mark gnus-dormant-mark)
946 (eq mark gnus-ticked-mark))
947 . gnus-summary-normal-ticked-face)
948 ((and (> score default-high) (eq mark gnus-ancient-mark))
949 . gnus-summary-high-ancient-face)
950 ((and (< score default-low) (eq mark gnus-ancient-mark))
951 . gnus-summary-low-ancient-face)
952 ((eq mark gnus-ancient-mark)
953 . gnus-summary-normal-ancient-face)
954 ((and (> score default-high) (eq mark gnus-unread-mark))
955 . gnus-summary-high-unread-face)
956 ((and (< score default-low) (eq mark gnus-unread-mark))
957 . gnus-summary-low-unread-face)
958 ((eq mark gnus-unread-mark)
959 . gnus-summary-normal-unread-face)
960 ((> score default-high)
961 . gnus-summary-high-read-face)
962 ((< score default-low)
963 . gnus-summary-low-read-face)
965 . gnus-summary-normal-read-face))
966 "*Controls the highlighting of summary buffer lines.
968 A list of (FORM . FACE) pairs. When deciding how a a particular
969 summary line should be displayed, each form is evaluated. The content
970 of the face field after the first true form is used. You can change
971 how those summary lines are displayed, by editing the face field.
973 You can use the following variables in the FORM field.
975 score: The article's score
976 default: The default article score.
977 default-high: The default score for high scored articles.
978 default-low: The default score for low scored articles.
979 below: The score below which articles are automatically marked as read.
980 mark: The articles mark."
981 :group 'gnus-summary-visual
982 :type '(repeat (cons (sexp :tag "Form" nil)
985 (defcustom gnus-alter-header-function nil
986 "Function called to allow alteration of article header structures.
987 The function is called with one parameter, the article header vector,
988 which it may alter in any way."
989 :type '(choice (const :tag "None" nil)
991 :group 'gnus-summary)
993 (defvar gnus-decode-encoded-word-function
994 (mime-find-field-decoder 'From 'nov)
995 "Variable that says which function should be used to decode a string with encoded words.")
997 (defcustom gnus-extra-headers '(To Newsgroups)
998 "*Extra headers to parse."
1000 :group 'gnus-summary
1001 :type '(repeat symbol))
1003 (defcustom gnus-ignored-from-addresses
1004 (and user-mail-address (regexp-quote user-mail-address))
1005 "*Regexp of From headers that may be suppressed in favor of To headers."
1007 :group 'gnus-summary
1010 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1011 "List of charsets that should be ignored.
1012 When these charsets are used in the \"charset\" parameter, the
1013 default charset will be used instead."
1015 :type '(repeat symbol)
1016 :group 'gnus-charset)
1018 (gnus-define-group-parameter
1022 "Return the ignored charsets of GROUP."
1023 :variable gnus-group-ignored-charsets-alist
1025 '(("alt\\.chinese\\.text" iso-8859-1))
1027 "Alist of regexps (to match group names) and charsets that should be ignored.
1028 When these charsets are used in the \"charset\" parameter, the
1029 default charset will be used instead."
1030 :variable-group gnus-charset
1031 :variable-type '(repeat (cons (regexp :tag "Group")
1033 :parameter-type '(choice :tag "Ignored charsets"
1036 :parameter-document "\
1037 List of charsets that should be ignored.
1039 When these charsets are used in the \"charset\" parameter, the
1040 default charset will be used instead.")
1042 (defcustom gnus-group-highlight-words-alist nil
1043 "Alist of group regexps and highlight regexps.
1044 This variable uses the same syntax as `gnus-emphasis-alist'."
1046 :type '(repeat (cons (regexp :tag "Group")
1047 (repeat (list (regexp :tag "Highlight regexp")
1048 (number :tag "Group for entire word" 0)
1049 (number :tag "Group for displayed part" 0)
1051 gnus-emphasis-highlight-words)))))
1052 :group 'gnus-summary-visual)
1054 (defcustom gnus-use-wheel nil
1055 "Use Intelli-mouse on summary movement"
1057 :group 'gnus-summary-maneuvering)
1059 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1060 "Amount to scroll messages by spinning the mouse wheel.
1061 This is actually a cons cell, where the first item is the amount to scroll
1062 on a normal wheel event, and the second is the amount to scroll when the
1063 wheel is moved with the shift key depressed."
1064 :type '(cons (integer :tag "Shift") integer)
1065 :group 'gnus-summary-maneuvering)
1067 (defcustom gnus-wheel-edge-resistance 2
1068 "How hard it should be to change the current article
1069 by moving the mouse over the edge of the article window."
1071 :group 'gnus-summary-maneuvering)
1073 (defcustom gnus-summary-show-article-charset-alist
1075 "Alist of number and charset.
1076 The article will be shown with the charset corresponding to the
1078 For example: ((1 . cn-gb-2312) (2 . big5))."
1080 :type '(repeat (cons (number :tag "Argument" 1)
1081 (symbol :tag "Charset")))
1082 :group 'gnus-charset)
1084 (defcustom gnus-preserve-marks t
1085 "Whether marks are preserved when moving, copying and respooling messages."
1088 :group 'gnus-summary-marks)
1090 (defcustom gnus-alter-articles-to-read-function nil
1091 "Function to be called to alter the list of articles to be selected."
1092 :type '(choice (const nil) function)
1093 :group 'gnus-summary)
1095 (defcustom gnus-orphan-score nil
1096 "*All orphans get this score added. Set in the score file."
1097 :group 'gnus-score-default
1098 :type '(choice (const nil)
1101 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1102 "*A regexp to match MIME parts when saving multiple parts of a
1103 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1104 This regexp will be used by default when prompting the user for which
1105 type of files to save."
1106 :group 'gnus-summary
1109 (defcustom gnus-read-all-available-headers nil
1110 "Whether Gnus should parse all headers made available to it.
1111 This is mostly relevant for slow backends where the user may
1112 wish to widen the summary buffer to include all headers
1113 that were fetched. Say, for nnultimate groups."
1114 :group 'gnus-summary
1115 :type '(choice boolean regexp))
1117 (defcustom gnus-summary-muttprint-program "muttprint"
1118 "Command (and optional arguments) used to run Muttprint."
1120 :group 'gnus-summary
1123 (defcustom gnus-article-loose-mime nil
1124 "If non-nil, don't require MIME-Version header.
1125 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1126 supply the MIME-Version header or deliberately strip it From the mail.
1127 Set it to non-nil, Gnus will treat some articles as MIME even if
1128 the MIME-Version header is missed."
1131 :group 'gnus-article-mime)
1133 (defcustom gnus-article-emulate-mime t
1134 "If non-nil, use MIME emulation for uuencode and the like.
1135 This means that Gnus will search message bodies for text that look
1136 like uuencoded bits, yEncoded bits, and so on, and present that using
1137 the normal Gnus MIME machinery."
1139 :group 'gnus-article-mime)
1141 ;;; Internal variables
1143 (defvar gnus-summary-display-cache nil)
1144 (defvar gnus-article-mime-handles nil)
1145 (defvar gnus-article-decoded-p nil)
1146 (defvar gnus-article-charset nil)
1147 (defvar gnus-article-ignored-charsets nil)
1148 (defvar gnus-scores-exclude-files nil)
1149 (defvar gnus-page-broken nil)
1151 (defvar gnus-original-article nil)
1152 (defvar gnus-article-internal-prepare-hook nil)
1153 (defvar gnus-newsgroup-process-stack nil)
1155 (defvar gnus-thread-indent-array nil)
1156 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1157 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1158 "Function called to sort the articles within a thread after it has been gathered together.")
1160 (defvar gnus-summary-save-parts-type-history nil)
1161 (defvar gnus-summary-save-parts-last-directory nil)
1163 ;; Avoid highlighting in kill files.
1164 (defvar gnus-summary-inhibit-highlight nil)
1165 (defvar gnus-newsgroup-selected-overlay nil)
1166 (defvar gnus-inhibit-limiting nil)
1167 (defvar gnus-newsgroup-adaptive-score-file nil)
1168 (defvar gnus-current-score-file nil)
1169 (defvar gnus-current-move-group nil)
1170 (defvar gnus-current-copy-group nil)
1171 (defvar gnus-current-crosspost-group nil)
1172 (defvar gnus-newsgroup-display nil)
1174 (defvar gnus-newsgroup-dependencies nil)
1175 (defvar gnus-newsgroup-adaptive nil)
1176 (defvar gnus-summary-display-article-function nil)
1177 (defvar gnus-summary-highlight-line-function nil
1178 "Function called after highlighting a summary line.")
1180 (defvar gnus-summary-line-format-alist
1181 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1182 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1183 (?s gnus-tmp-subject-or-nil ?s)
1184 (?n gnus-tmp-name ?s)
1185 (?A (std11-address-string
1186 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1187 (?a (or (std11-full-name-string
1188 (car (mime-entity-read-field gnus-tmp-header 'From)))
1190 (?F gnus-tmp-from ?s)
1191 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1192 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1193 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1194 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1195 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1196 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1197 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1198 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1199 (?L gnus-tmp-lines ?s)
1200 (?O gnus-tmp-downloaded ?c)
1201 (?I gnus-tmp-indentation ?s)
1202 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1203 (?R gnus-tmp-replied ?c)
1204 (?\[ gnus-tmp-opening-bracket ?c)
1205 (?\] gnus-tmp-closing-bracket ?c)
1206 (?\> (make-string gnus-tmp-level ? ) ?s)
1207 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1208 (?i gnus-tmp-score ?d)
1209 (?z gnus-tmp-score-char ?c)
1210 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1211 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1212 (?U gnus-tmp-unread ?c)
1213 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1215 (?t (gnus-summary-number-of-articles-in-thread
1216 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1218 (?e (gnus-summary-number-of-articles-in-thread
1219 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1221 (?u gnus-tmp-user-defined ?s)
1222 (?P (gnus-pick-line-number) ?d)
1223 (?B gnus-tmp-thread-tree-header-string ?s)
1224 (user-date (gnus-user-date
1225 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1226 "An alist of format specifications that can appear in summary lines.
1227 These are paired with what variables they correspond with, along with
1228 the type of the variable (string, integer, character, etc).")
1230 (defvar gnus-summary-dummy-line-format-alist
1231 `((?S gnus-tmp-subject ?s)
1232 (?N gnus-tmp-number ?d)
1233 (?u gnus-tmp-user-defined ?s)))
1235 (defvar gnus-summary-mode-line-format-alist
1236 `((?G gnus-tmp-group-name ?s)
1237 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1238 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1239 (?A gnus-tmp-article-number ?d)
1240 (?Z gnus-tmp-unread-and-unselected ?s)
1241 (?V gnus-version ?s)
1242 (?U gnus-tmp-unread-and-unticked ?d)
1243 (?S gnus-tmp-subject ?s)
1244 (?e gnus-tmp-unselected ?d)
1245 (?u gnus-tmp-user-defined ?s)
1246 (?d (length gnus-newsgroup-dormant) ?d)
1247 (?t (length gnus-newsgroup-marked) ?d)
1248 (?h (length gnus-newsgroup-spam-marked) ?d)
1249 (?r (length gnus-newsgroup-reads) ?d)
1250 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1251 (?E gnus-newsgroup-expunged-tally ?d)
1252 (?s (gnus-current-score-file-nondirectory) ?s)))
1254 (defvar gnus-last-search-regexp nil
1255 "Default regexp for article search command.")
1257 (defvar gnus-summary-search-article-matched-data nil
1258 "Last matched data of article search command. It is the local variable
1259 in `gnus-article-buffer' which consists of the list of start position,
1260 end position and text.")
1262 (defvar gnus-last-shell-command nil
1263 "Default shell command on article.")
1265 (defvar gnus-newsgroup-agentized nil
1266 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1267 (defvar gnus-newsgroup-begin nil)
1268 (defvar gnus-newsgroup-end nil)
1269 (defvar gnus-newsgroup-last-rmail nil)
1270 (defvar gnus-newsgroup-last-mail nil)
1271 (defvar gnus-newsgroup-last-folder nil)
1272 (defvar gnus-newsgroup-last-file nil)
1273 (defvar gnus-newsgroup-auto-expire nil)
1274 (defvar gnus-newsgroup-active nil)
1276 (defvar gnus-newsgroup-data nil)
1277 (defvar gnus-newsgroup-data-reverse nil)
1278 (defvar gnus-newsgroup-limit nil)
1279 (defvar gnus-newsgroup-limits nil)
1280 (defvar gnus-summary-use-undownloaded-faces nil)
1282 (defvar gnus-newsgroup-unreads nil
1283 "Sorted list of unread articles in the current newsgroup.")
1285 (defvar gnus-newsgroup-unselected nil
1286 "Sorted list of unselected unread articles in the current newsgroup.")
1288 (defvar gnus-newsgroup-reads nil
1289 "Alist of read articles and article marks in the current newsgroup.")
1291 (defvar gnus-newsgroup-expunged-tally nil)
1293 (defvar gnus-newsgroup-marked nil
1294 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1296 (defvar gnus-newsgroup-spam-marked nil
1297 "List of ranges of articles that have been marked as spam.")
1299 (defvar gnus-newsgroup-killed nil
1300 "List of ranges of articles that have been through the scoring process.")
1302 (defvar gnus-newsgroup-cached nil
1303 "Sorted list of articles that come from the article cache.")
1305 (defvar gnus-newsgroup-saved nil
1306 "List of articles that have been saved.")
1308 (defvar gnus-newsgroup-kill-headers nil)
1310 (defvar gnus-newsgroup-replied nil
1311 "List of articles that have been replied to in the current newsgroup.")
1313 (defvar gnus-newsgroup-forwarded nil
1314 "List of articles that have been forwarded in the current newsgroup.")
1316 (defvar gnus-newsgroup-recent nil
1317 "List of articles that have are recent in the current newsgroup.")
1319 (defvar gnus-newsgroup-expirable nil
1320 "Sorted list of articles in the current newsgroup that can be expired.")
1322 (defvar gnus-newsgroup-processable nil
1323 "List of articles in the current newsgroup that can be processed.")
1325 (defvar gnus-newsgroup-downloadable nil
1326 "Sorted list of articles in the current newsgroup that can be processed.")
1328 (defvar gnus-newsgroup-unfetched nil
1329 "Sorted list of articles in the current newsgroup whose headers have
1330 not been fetched into the agent.
1332 This list will always be a subset of gnus-newsgroup-undownloaded.")
1334 (defvar gnus-newsgroup-undownloaded nil
1335 "List of articles in the current newsgroup that haven't been downloaded.")
1337 (defvar gnus-newsgroup-unsendable nil
1338 "List of articles in the current newsgroup that won't be sent.")
1340 (defvar gnus-newsgroup-bookmarks nil
1341 "List of articles in the current newsgroup that have bookmarks.")
1343 (defvar gnus-newsgroup-dormant nil
1344 "Sorted list of dormant articles in the current newsgroup.")
1346 (defvar gnus-newsgroup-unseen nil
1347 "List of unseen articles in the current newsgroup.")
1349 (defvar gnus-newsgroup-seen nil
1350 "Range of seen articles in the current newsgroup.")
1352 (defvar gnus-newsgroup-articles nil
1353 "List of articles in the current newsgroup.")
1355 (defvar gnus-newsgroup-scored nil
1356 "List of scored articles in the current newsgroup.")
1358 (defvar gnus-newsgroup-incorporated nil
1359 "List of incorporated articles in the current newsgroup.")
1361 (defvar gnus-newsgroup-headers nil
1362 "List of article headers in the current newsgroup.")
1364 (defvar gnus-newsgroup-threads nil)
1366 (defvar gnus-newsgroup-prepared nil
1367 "Whether the current group has been prepared properly.")
1369 (defvar gnus-newsgroup-ancient nil
1370 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1372 (defvar gnus-newsgroup-sparse nil)
1374 (defvar gnus-current-article nil)
1375 (defvar gnus-article-current nil)
1376 (defvar gnus-current-headers nil)
1377 (defvar gnus-have-all-headers nil)
1378 (defvar gnus-last-article nil)
1379 (defvar gnus-newsgroup-history nil)
1380 (defvar gnus-newsgroup-charset nil)
1381 (defvar gnus-newsgroup-ephemeral-charset nil)
1382 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1384 (defvar gnus-article-before-search nil)
1386 (defvar gnus-summary-local-variables
1387 '(gnus-newsgroup-name
1388 gnus-newsgroup-begin gnus-newsgroup-end
1389 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1390 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1391 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1392 gnus-newsgroup-unselected gnus-newsgroup-marked
1393 gnus-newsgroup-spam-marked
1394 gnus-newsgroup-reads gnus-newsgroup-saved
1395 gnus-newsgroup-replied gnus-newsgroup-forwarded
1396 gnus-newsgroup-recent
1397 gnus-newsgroup-expirable
1398 gnus-newsgroup-processable gnus-newsgroup-killed
1399 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1400 gnus-newsgroup-unfetched
1401 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1402 gnus-newsgroup-seen gnus-newsgroup-articles
1403 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1404 gnus-newsgroup-headers gnus-newsgroup-threads
1405 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1406 gnus-current-article gnus-current-headers gnus-have-all-headers
1407 gnus-last-article gnus-article-internal-prepare-hook
1408 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1409 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1410 gnus-thread-expunge-below
1411 gnus-score-alist gnus-current-score-file
1412 (gnus-summary-expunge-below . global)
1413 (gnus-summary-mark-below . global)
1414 (gnus-orphan-score . global)
1415 gnus-newsgroup-active gnus-scores-exclude-files
1416 gnus-newsgroup-history gnus-newsgroup-ancient
1417 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1418 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1419 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1420 (gnus-newsgroup-expunged-tally . 0)
1421 gnus-cache-removable-articles gnus-newsgroup-cached
1422 gnus-newsgroup-data gnus-newsgroup-data-reverse
1423 gnus-newsgroup-limit gnus-newsgroup-limits
1424 gnus-newsgroup-charset gnus-newsgroup-display
1425 gnus-summary-use-undownloaded-faces
1426 gnus-newsgroup-incorporated)
1427 "Variables that are buffer-local to the summary buffers.")
1429 (defvar gnus-newsgroup-variables nil
1430 "A list of variables that have separate values in different newsgroups.
1431 A list of newsgroup (summary buffer) local variables, or cons of
1432 variables and their default values (when the default values are not
1433 nil), that should be made global while the summary buffer is active.
1434 These variables can be used to set variables in the group parameters
1435 while still allowing them to affect operations done in other
1436 buffers. For example:
1438 \(setq gnus-newsgroup-variables
1439 '(message-use-followup-to
1440 (gnus-visible-headers .
1441 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1444 ;; Byte-compiler warning.
1446 ;; Bind features so that require will believe that gnus-sum has
1447 ;; already been loaded (avoids infinite recursion)
1448 (let ((features (cons 'gnus-sum features)))
1449 ;; Several of the declarations in gnus-sum are needed to load the
1450 ;; following files. Right now, these definitions have been
1451 ;; compiled but not defined (evaluated). We could either do a
1452 ;; eval-and-compile about all of the declarations or evaluate the
1454 (if (boundp 'gnus-newsgroup-variables)
1456 (load "gnus-sum.el" t t t))
1458 (require 'gnus-agent)
1459 (require 'gnus-art)))
1461 ;; Subject simplification.
1463 (defun gnus-simplify-whitespace (str)
1464 "Remove excessive whitespace from STR."
1466 (while (string-match "[ \t][ \t]+" str)
1467 (setq str (concat (substring str 0 (match-beginning 0))
1469 (substring str (match-end 0)))))
1471 (when (string-match "^[ \t]+" str)
1472 (setq str (substring str (match-end 0))))
1474 (when (string-match "[ \t]+$" str)
1475 (setq str (substring str 0 (match-beginning 0))))
1478 (defun gnus-simplify-all-whitespace (str)
1479 "Remove all whitespace from STR."
1480 (while (string-match "[ \t\n]+" str)
1481 (setq str (replace-match "" nil nil str)))
1484 (defsubst gnus-simplify-subject-re (subject)
1485 "Remove \"Re:\" from subject lines."
1486 (if (string-match message-subject-re-regexp subject)
1487 (substring subject (match-end 0))
1490 (defun gnus-simplify-subject (subject &optional re-only)
1491 "Remove `Re:' and words in parentheses.
1492 If RE-ONLY is non-nil, strip leading `Re:'s only."
1493 (let ((case-fold-search t)) ;Ignore case.
1494 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1495 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1496 (setq subject (substring subject (match-end 0))))
1497 ;; Remove uninteresting prefixes.
1498 (when (and (not re-only)
1499 gnus-simplify-ignored-prefixes
1500 (string-match gnus-simplify-ignored-prefixes subject))
1501 (setq subject (substring subject (match-end 0))))
1502 ;; Remove words in parentheses from end.
1504 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1505 (setq subject (substring subject 0 (match-beginning 0)))))
1506 ;; Return subject string.
1509 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1511 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1512 (goto-char (point-min))
1513 (while (re-search-forward regexp nil t)
1514 (replace-match (or newtext ""))))
1516 (defun gnus-simplify-buffer-fuzzy ()
1517 "Simplify string in the buffer fuzzily.
1518 The string in the accessible portion of the current buffer is simplified.
1519 It is assumed to be a single-line subject.
1520 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1521 matter is removed. Additional things can be deleted by setting
1522 `gnus-simplify-subject-fuzzy-regexp'."
1523 (let ((case-fold-search t)
1525 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1527 (while (not (eq modified-tick (buffer-modified-tick)))
1528 (setq modified-tick (buffer-modified-tick))
1530 ((listp gnus-simplify-subject-fuzzy-regexp)
1531 (mapcar 'gnus-simplify-buffer-fuzzy-step
1532 gnus-simplify-subject-fuzzy-regexp))
1533 (gnus-simplify-subject-fuzzy-regexp
1534 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1535 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1536 (gnus-simplify-buffer-fuzzy-step
1537 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1538 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1540 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1541 (gnus-simplify-buffer-fuzzy-step " +" " ")
1542 (gnus-simplify-buffer-fuzzy-step " $")
1543 (gnus-simplify-buffer-fuzzy-step "^ +")))
1545 (defun gnus-simplify-subject-fuzzy (subject)
1546 "Simplify a subject string fuzzily.
1547 See `gnus-simplify-buffer-fuzzy' for details."
1549 (gnus-set-work-buffer)
1550 (let ((case-fold-search t))
1551 ;; Remove uninteresting prefixes.
1552 (when (and gnus-simplify-ignored-prefixes
1553 (string-match gnus-simplify-ignored-prefixes subject))
1554 (setq subject (substring subject (match-end 0))))
1556 (inline (gnus-simplify-buffer-fuzzy))
1559 (defsubst gnus-simplify-subject-fully (subject)
1560 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1562 (gnus-simplify-subject-functions
1563 (gnus-map-function gnus-simplify-subject-functions subject))
1564 ((null gnus-summary-gather-subject-limit)
1565 (gnus-simplify-subject-re subject))
1566 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1567 (gnus-simplify-subject-fuzzy subject))
1568 ((numberp gnus-summary-gather-subject-limit)
1569 (gnus-limit-string (gnus-simplify-subject-re subject)
1570 gnus-summary-gather-subject-limit))
1574 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1575 "Check whether two subjects are equal.
1576 If optional argument SIMPLE-FIRST is t, first argument is already
1579 ((null simple-first)
1580 (equal (gnus-simplify-subject-fully s1)
1581 (gnus-simplify-subject-fully s2)))
1584 (gnus-simplify-subject-fully s2)))))
1586 (defun gnus-summary-bubble-group ()
1587 "Increase the score of the current group.
1588 This is a handy function to add to `gnus-summary-exit-hook' to
1589 increase the score of each group you read."
1590 (gnus-group-add-score gnus-newsgroup-name))
1594 ;;; Gnus summary mode
1597 (put 'gnus-summary-mode 'mode-class 'special)
1599 (defvar gnus-article-commands-menu)
1601 ;; Non-orthogonal keys
1603 (gnus-define-keys gnus-summary-mode-map
1604 " " gnus-summary-next-page
1605 "\177" gnus-summary-prev-page
1606 [delete] gnus-summary-prev-page
1607 [backspace] gnus-summary-prev-page
1608 "\r" gnus-summary-scroll-up
1609 "\M-\r" gnus-summary-scroll-down
1610 "n" gnus-summary-next-unread-article
1611 "p" gnus-summary-prev-unread-article
1612 "N" gnus-summary-next-article
1613 "P" gnus-summary-prev-article
1614 "\M-\C-n" gnus-summary-next-same-subject
1615 "\M-\C-p" gnus-summary-prev-same-subject
1616 "\M-n" gnus-summary-next-unread-subject
1617 "\M-p" gnus-summary-prev-unread-subject
1618 "." gnus-summary-first-unread-article
1619 "," gnus-summary-best-unread-article
1620 "\M-s" gnus-summary-search-article-forward
1621 "\M-r" gnus-summary-search-article-backward
1622 "<" gnus-summary-beginning-of-article
1623 ">" gnus-summary-end-of-article
1624 "j" gnus-summary-goto-article
1625 "^" gnus-summary-refer-parent-article
1626 "\M-^" gnus-summary-refer-article
1627 "u" gnus-summary-tick-article-forward
1628 "!" gnus-summary-tick-article-forward
1629 "U" gnus-summary-tick-article-backward
1630 "d" gnus-summary-mark-as-read-forward
1631 "D" gnus-summary-mark-as-read-backward
1632 "E" gnus-summary-mark-as-expirable
1633 "\M-u" gnus-summary-clear-mark-forward
1634 "\M-U" gnus-summary-clear-mark-backward
1635 "k" gnus-summary-kill-same-subject-and-select
1636 "\C-k" gnus-summary-kill-same-subject
1637 "\M-\C-k" gnus-summary-kill-thread
1638 "\M-\C-l" gnus-summary-lower-thread
1639 "e" gnus-summary-edit-article
1640 "#" gnus-summary-mark-as-processable
1641 "\M-#" gnus-summary-unmark-as-processable
1642 "\M-\C-t" gnus-summary-toggle-threads
1643 "\M-\C-s" gnus-summary-show-thread
1644 "\M-\C-h" gnus-summary-hide-thread
1645 "\M-\C-f" gnus-summary-next-thread
1646 "\M-\C-b" gnus-summary-prev-thread
1647 [(meta down)] gnus-summary-next-thread
1648 [(meta up)] gnus-summary-prev-thread
1649 "\M-\C-u" gnus-summary-up-thread
1650 "\M-\C-d" gnus-summary-down-thread
1651 "&" gnus-summary-execute-command
1652 "c" gnus-summary-catchup-and-exit
1653 "\C-w" gnus-summary-mark-region-as-read
1654 "\C-t" gnus-summary-toggle-truncation
1655 "?" gnus-summary-mark-as-dormant
1656 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1657 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1658 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1659 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1660 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1661 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1662 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1663 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1664 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1665 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1666 "=" gnus-summary-expand-window
1667 "\C-x\C-s" gnus-summary-reselect-current-group
1668 "\M-g" gnus-summary-rescan-group
1669 "w" gnus-summary-stop-page-breaking
1670 "\C-c\C-r" gnus-summary-caesar-message
1671 "\M-t" gnus-summary-toggle-mime
1672 "f" gnus-summary-followup
1673 "F" gnus-summary-followup-with-original
1674 "C" gnus-summary-cancel-article
1675 "r" gnus-summary-reply
1676 "R" gnus-summary-reply-with-original
1677 "\C-c\C-f" gnus-summary-mail-forward
1678 "o" gnus-summary-save-article
1679 "\C-o" gnus-summary-save-article-mail
1680 "|" gnus-summary-pipe-output
1681 "\M-k" gnus-summary-edit-local-kill
1682 "\M-K" gnus-summary-edit-global-kill
1684 "\C-c\C-d" gnus-summary-describe-group
1685 "q" gnus-summary-exit
1686 "Q" gnus-summary-exit-no-update
1687 "\C-c\C-i" gnus-info-find-node
1688 gnus-mouse-2 gnus-mouse-pick-article
1689 "m" gnus-summary-mail-other-window
1690 "a" gnus-summary-post-news
1691 "i" gnus-summary-news-other-window
1692 "x" gnus-summary-limit-to-unread
1693 "s" gnus-summary-isearch-article
1694 "t" gnus-summary-toggle-header
1695 "g" gnus-summary-show-article
1696 "l" gnus-summary-goto-last-article
1697 "v" gnus-summary-preview-mime-message
1698 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1699 "\C-d" gnus-summary-enter-digest-group
1700 "\M-\C-d" gnus-summary-read-document
1701 "\M-\C-e" gnus-summary-edit-parameters
1702 "\M-\C-a" gnus-summary-customize-parameters
1704 "\C-c\C-n" gnus-namazu-search
1705 "*" gnus-cache-enter-article
1706 "\M-*" gnus-cache-remove-article
1707 "\M-&" gnus-summary-universal-argument
1708 "\C-l" gnus-recenter
1709 "I" gnus-summary-increase-score
1710 "L" gnus-summary-lower-score
1711 "\M-i" gnus-symbolic-argument
1712 "h" gnus-summary-select-article-buffer
1714 "V" gnus-summary-score-map
1715 "X" gnus-uu-extract-map
1716 "S" gnus-summary-send-map)
1718 ;; Sort of orthogonal keymap
1719 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1720 "t" gnus-summary-tick-article-forward
1721 "!" gnus-summary-tick-article-forward
1722 "d" gnus-summary-mark-as-read-forward
1723 "r" gnus-summary-mark-as-read-forward
1724 "c" gnus-summary-clear-mark-forward
1725 " " gnus-summary-clear-mark-forward
1726 "e" gnus-summary-mark-as-expirable
1727 "x" gnus-summary-mark-as-expirable
1728 "?" gnus-summary-mark-as-dormant
1729 "b" gnus-summary-set-bookmark
1730 "B" gnus-summary-remove-bookmark
1731 "#" gnus-summary-mark-as-processable
1732 "\M-#" gnus-summary-unmark-as-processable
1733 "S" gnus-summary-limit-include-expunged
1734 "C" gnus-summary-catchup
1735 "H" gnus-summary-catchup-to-here
1736 "h" gnus-summary-catchup-from-here
1737 "\C-c" gnus-summary-catchup-all
1738 "k" gnus-summary-kill-same-subject-and-select
1739 "K" gnus-summary-kill-same-subject
1740 "P" gnus-uu-mark-map)
1742 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1743 "c" gnus-summary-clear-above
1744 "u" gnus-summary-tick-above
1745 "m" gnus-summary-mark-above
1746 "k" gnus-summary-kill-below)
1748 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1749 "/" gnus-summary-limit-to-subject
1750 "n" gnus-summary-limit-to-articles
1751 "w" gnus-summary-pop-limit
1752 "s" gnus-summary-limit-to-subject
1753 "a" gnus-summary-limit-to-author
1754 "u" gnus-summary-limit-to-unread
1755 "m" gnus-summary-limit-to-marks
1756 "M" gnus-summary-limit-exclude-marks
1757 "v" gnus-summary-limit-to-score
1758 "*" gnus-summary-limit-include-cached
1759 "D" gnus-summary-limit-include-dormant
1760 "T" gnus-summary-limit-include-thread
1761 "d" gnus-summary-limit-exclude-dormant
1762 "t" gnus-summary-limit-to-age
1763 "." gnus-summary-limit-to-unseen
1764 "x" gnus-summary-limit-to-extra
1765 "p" gnus-summary-limit-to-display-predicate
1766 "E" gnus-summary-limit-include-expunged
1767 "c" gnus-summary-limit-exclude-childless-dormant
1768 "C" gnus-summary-limit-mark-excluded-as-read
1769 "o" gnus-summary-insert-old-articles
1770 "N" gnus-summary-insert-new-articles)
1772 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1773 "n" gnus-summary-next-unread-article
1774 "p" gnus-summary-prev-unread-article
1775 "N" gnus-summary-next-article
1776 "P" gnus-summary-prev-article
1777 "\C-n" gnus-summary-next-same-subject
1778 "\C-p" gnus-summary-prev-same-subject
1779 "\M-n" gnus-summary-next-unread-subject
1780 "\M-p" gnus-summary-prev-unread-subject
1781 "f" gnus-summary-first-unread-article
1782 "b" gnus-summary-best-unread-article
1783 "j" gnus-summary-goto-article
1784 "g" gnus-summary-goto-subject
1785 "l" gnus-summary-goto-last-article
1786 "o" gnus-summary-pop-article)
1788 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1789 "k" gnus-summary-kill-thread
1790 "l" gnus-summary-lower-thread
1791 "i" gnus-summary-raise-thread
1792 "T" gnus-summary-toggle-threads
1793 "t" gnus-summary-rethread-current
1794 "^" gnus-summary-reparent-thread
1795 "s" gnus-summary-show-thread
1796 "S" gnus-summary-show-all-threads
1797 "h" gnus-summary-hide-thread
1798 "H" gnus-summary-hide-all-threads
1799 "n" gnus-summary-next-thread
1800 "p" gnus-summary-prev-thread
1801 "u" gnus-summary-up-thread
1802 "o" gnus-summary-top-thread
1803 "d" gnus-summary-down-thread
1804 "#" gnus-uu-mark-thread
1805 "\M-#" gnus-uu-unmark-thread)
1807 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1808 "g" gnus-summary-prepare
1809 "c" gnus-summary-insert-cached-articles
1810 "d" gnus-summary-insert-dormant-articles)
1812 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1813 "c" gnus-summary-catchup-and-exit
1814 "C" gnus-summary-catchup-all-and-exit
1815 "E" gnus-summary-exit-no-update
1816 "J" gnus-summary-jump-to-other-group
1817 "Q" gnus-summary-exit
1818 "Z" gnus-summary-exit
1819 "n" gnus-summary-catchup-and-goto-next-group
1820 "R" gnus-summary-reselect-current-group
1821 "G" gnus-summary-rescan-group
1822 "N" gnus-summary-next-group
1823 "s" gnus-summary-save-newsrc
1824 "P" gnus-summary-prev-group)
1826 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1827 " " gnus-summary-next-page
1828 "n" gnus-summary-next-page
1829 "\177" gnus-summary-prev-page
1830 [delete] gnus-summary-prev-page
1831 "p" gnus-summary-prev-page
1832 "\r" gnus-summary-scroll-up
1833 "\M-\r" gnus-summary-scroll-down
1834 "<" gnus-summary-beginning-of-article
1835 ">" gnus-summary-end-of-article
1836 "b" gnus-summary-beginning-of-article
1837 "e" gnus-summary-end-of-article
1838 "^" gnus-summary-refer-parent-article
1839 "r" gnus-summary-refer-parent-article
1840 "D" gnus-summary-enter-digest-group
1841 "R" gnus-summary-refer-references
1842 "T" gnus-summary-refer-thread
1843 "g" gnus-summary-show-article
1844 "s" gnus-summary-isearch-article
1845 "P" gnus-summary-print-article
1846 "M" gnus-mailing-list-insinuate
1847 "t" gnus-article-babel)
1849 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1850 "b" gnus-article-add-buttons
1851 "B" gnus-article-add-buttons-to-head
1852 "o" gnus-article-treat-overstrike
1853 "e" gnus-article-emphasize
1854 "w" gnus-article-fill-cited-article
1855 "Q" gnus-article-fill-long-lines
1856 "C" gnus-article-capitalize-sentences
1857 "c" gnus-article-remove-cr
1858 "Z" gnus-article-decode-HZ
1859 "h" gnus-article-wash-html
1860 "u" gnus-article-unsplit-urls
1861 "f" gnus-article-display-x-face
1862 "l" gnus-summary-stop-page-breaking
1863 "r" gnus-summary-caesar-message
1864 "m" gnus-summary-morse-message
1865 "t" gnus-summary-toggle-header
1866 "g" gnus-treat-smiley
1867 "v" gnus-summary-verbose-headers
1868 "m" gnus-summary-toggle-mime
1869 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1870 "p" gnus-article-verify-x-pgp-sig
1871 "d" gnus-article-treat-dumbquotes)
1873 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1874 ;; mnemonic: deuglif*Y*
1875 "u" gnus-article-outlook-unwrap-lines
1876 "a" gnus-article-outlook-repair-attribution
1877 "c" gnus-article-outlook-rearrange-citation
1878 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1880 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1881 "a" gnus-article-hide
1882 "h" gnus-article-hide-headers
1883 "b" gnus-article-hide-boring-headers
1884 "s" gnus-article-hide-signature
1885 "c" gnus-article-hide-citation
1886 "C" gnus-article-hide-citation-in-followups
1887 "l" gnus-article-hide-list-identifiers
1888 "B" gnus-article-strip-banner
1889 "P" gnus-article-hide-pem
1890 "\C-c" gnus-article-hide-citation-maybe)
1892 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1893 "a" gnus-article-highlight
1894 "h" gnus-article-highlight-headers
1895 "c" gnus-article-highlight-citation
1896 "s" gnus-article-highlight-signature)
1898 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1899 "f" gnus-article-treat-fold-headers
1900 "u" gnus-article-treat-unfold-headers
1901 "n" gnus-article-treat-fold-newsgroups)
1903 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1904 "x" gnus-article-display-x-face
1905 "d" gnus-article-display-face
1906 "s" gnus-treat-smiley
1907 "D" gnus-article-remove-images
1908 "f" gnus-treat-from-picon
1909 "m" gnus-treat-mail-picon
1910 "n" gnus-treat-newsgroups-picon)
1912 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1913 "z" gnus-article-date-ut
1914 "u" gnus-article-date-ut
1915 "l" gnus-article-date-local
1916 "p" gnus-article-date-english
1917 "e" gnus-article-date-lapsed
1918 "o" gnus-article-date-original
1919 "i" gnus-article-date-iso8601
1920 "s" gnus-article-date-user)
1922 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1923 "t" gnus-article-remove-trailing-blank-lines
1924 "l" gnus-article-strip-leading-blank-lines
1925 "m" gnus-article-strip-multiple-blank-lines
1926 "a" gnus-article-strip-blank-lines
1927 "A" gnus-article-strip-all-blank-lines
1928 "s" gnus-article-strip-leading-space
1929 "e" gnus-article-strip-trailing-space
1930 "w" gnus-article-remove-leading-whitespace)
1932 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1934 "f" gnus-summary-fetch-faq
1935 "d" gnus-summary-describe-group
1936 "h" gnus-summary-describe-briefly
1937 "i" gnus-info-find-node
1938 "c" gnus-group-fetch-charter
1939 "C" gnus-group-fetch-control)
1941 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1942 "e" gnus-summary-expire-articles
1943 "\M-\C-e" gnus-summary-expire-articles-now
1944 "\177" gnus-summary-delete-article
1945 [delete] gnus-summary-delete-article
1946 [backspace] gnus-summary-delete-article
1947 "m" gnus-summary-move-article
1948 "r" gnus-summary-respool-article
1949 "w" gnus-summary-edit-article
1950 "c" gnus-summary-copy-article
1951 "B" gnus-summary-crosspost-article
1952 "q" gnus-summary-respool-query
1953 "t" gnus-summary-respool-trace
1954 "i" gnus-summary-import-article
1955 "I" gnus-summary-create-article
1956 "p" gnus-summary-article-posted-p)
1958 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1959 "o" gnus-summary-save-article
1960 "m" gnus-summary-save-article-mail
1961 "F" gnus-summary-write-article-file
1962 "r" gnus-summary-save-article-rmail
1963 "f" gnus-summary-save-article-file
1964 "b" gnus-summary-save-article-body-file
1965 "h" gnus-summary-save-article-folder
1966 "v" gnus-summary-save-article-vm
1967 "p" gnus-summary-pipe-output
1968 "P" gnus-summary-muttprint
1969 "s" gnus-soup-add-article)
1971 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1972 "b" gnus-summary-display-buttonized
1973 "m" gnus-summary-repair-multipart
1974 "v" gnus-article-view-part
1975 "o" gnus-article-save-part
1976 "c" gnus-article-copy-part
1977 "C" gnus-article-view-part-as-charset
1978 "e" gnus-article-view-part-externally
1979 "E" gnus-article-encrypt-body
1980 "i" gnus-article-inline-part
1981 "|" gnus-article-pipe-part)
1983 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1984 "p" gnus-summary-mark-as-processable
1985 "u" gnus-summary-unmark-as-processable
1986 "U" gnus-summary-unmark-all-processable
1987 "v" gnus-uu-mark-over
1988 "s" gnus-uu-mark-series
1989 "r" gnus-uu-mark-region
1990 "g" gnus-uu-unmark-region
1991 "R" gnus-uu-mark-by-regexp
1992 "G" gnus-uu-unmark-by-regexp
1993 "t" gnus-uu-mark-thread
1994 "T" gnus-uu-unmark-thread
1995 "a" gnus-uu-mark-all
1996 "b" gnus-uu-mark-buffer
1997 "S" gnus-uu-mark-sparse
1998 "k" gnus-summary-kill-process-mark
1999 "y" gnus-summary-yank-process-mark
2000 "w" gnus-summary-save-process-mark
2001 "i" gnus-uu-invert-processable)
2003 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2004 ;;"x" gnus-uu-extract-any
2005 "m" gnus-summary-save-parts
2006 "u" gnus-uu-decode-uu
2007 "U" gnus-uu-decode-uu-and-save
2008 "s" gnus-uu-decode-unshar
2009 "S" gnus-uu-decode-unshar-and-save
2010 "o" gnus-uu-decode-save
2011 "O" gnus-uu-decode-save
2012 "b" gnus-uu-decode-binhex
2013 "B" gnus-uu-decode-binhex
2014 "p" gnus-uu-decode-postscript
2015 "P" gnus-uu-decode-postscript-and-save)
2018 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2019 "u" gnus-uu-decode-uu-view
2020 "U" gnus-uu-decode-uu-and-save-view
2021 "s" gnus-uu-decode-unshar-view
2022 "S" gnus-uu-decode-unshar-and-save-view
2023 "o" gnus-uu-decode-save-view
2024 "O" gnus-uu-decode-save-view
2025 "b" gnus-uu-decode-binhex-view
2026 "B" gnus-uu-decode-binhex-view
2027 "p" gnus-uu-decode-postscript-view
2028 "P" gnus-uu-decode-postscript-and-save-view)
2030 (defvar gnus-article-post-menu nil)
2032 (defconst gnus-summary-menu-maxlen 20)
2034 (defun gnus-summary-menu-split (menu)
2035 ;; If we have lots of elements, divide them into groups of 20
2036 ;; and make a pane (or submenu) for each one.
2037 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2038 (let ((menu menu) sublists next
2041 ;; Pull off the next gnus-summary-menu-maxlen elements
2042 ;; and make them the next element of sublist.
2043 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2045 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2047 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2048 (aref (car (last menu)) 0)) menu)
2052 (nreverse sublists))
2053 ;; Few elements--put them all in one pane.
2056 (defun gnus-summary-make-menu-bar ()
2057 (gnus-turn-off-edit-menu 'summary)
2059 (unless (boundp 'gnus-summary-misc-menu)
2062 gnus-summary-kill-menu gnus-summary-mode-map ""
2067 ["Customize" gnus-score-customize t])
2068 (gnus-make-score-map 'increase)
2069 (gnus-make-score-map 'lower)
2071 ["Kill below" gnus-summary-kill-below t]
2072 ["Mark above" gnus-summary-mark-above t]
2073 ["Tick above" gnus-summary-tick-above t]
2074 ["Clear above" gnus-summary-clear-above t])
2075 ["Current score" gnus-summary-current-score t]
2076 ["Set score" gnus-summary-set-score t]
2077 ["Switch current score file..." gnus-score-change-score-file t]
2078 ["Set mark below..." gnus-score-set-mark-below t]
2079 ["Set expunge below..." gnus-score-set-expunge-below t]
2080 ["Edit current score file" gnus-score-edit-current-scores t]
2081 ["Edit score file" gnus-score-edit-file t]
2082 ["Trace score" gnus-score-find-trace t]
2083 ["Find words" gnus-score-find-favourite-words t]
2084 ["Rescore buffer" gnus-summary-rescore t]
2085 ["Increase score..." gnus-summary-increase-score t]
2086 ["Lower score..." gnus-summary-lower-score t]))))
2088 ;; Define both the Article menu in the summary buffer and the
2089 ;; equivalent Commands menu in the article buffer here for
2093 ["All" gnus-article-hide t]
2094 ["Headers" gnus-article-hide-headers t]
2095 ["Signature" gnus-article-hide-signature t]
2096 ["Citation" gnus-article-hide-citation t]
2097 ["List identifiers" gnus-article-hide-list-identifiers t]
2098 ["Banner" gnus-article-strip-banner t]
2099 ["Boring headers" gnus-article-hide-boring-headers t])
2101 ["All" gnus-article-highlight t]
2102 ["Headers" gnus-article-highlight-headers t]
2103 ["Signature" gnus-article-highlight-signature t]
2104 ["Citation" gnus-article-highlight-citation t])
2106 ["Local" gnus-article-date-local t]
2107 ["ISO8601" gnus-article-date-iso8601 t]
2108 ["UT" gnus-article-date-ut t]
2109 ["Original" gnus-article-date-original t]
2110 ["Lapsed" gnus-article-date-lapsed t]
2111 ["User-defined" gnus-article-date-user t])
2113 ["Remove images" gnus-article-remove-images t]
2114 ["Toggle smiley" gnus-treat-smiley t]
2115 ["Show X-Face" gnus-article-display-x-face t]
2116 ["Show picons in From" gnus-treat-from-picon t]
2117 ["Show picons in mail headers" gnus-treat-mail-picon t]
2118 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2119 ("View as different encoding"
2120 ,@(gnus-summary-menu-split
2123 ;; Since easymenu under Emacs doesn't allow
2124 ;; lambda forms for menu commands, we should
2125 ;; provide intern'ed function symbols.
2126 (let ((command (intern (format "\
2127 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2131 (let ((gnus-summary-show-article-charset-alist
2133 (gnus-summary-show-article 1))))
2134 `[,(symbol-name cs) ,command t]))
2135 (sort (if (fboundp 'coding-system-list)
2136 (coding-system-list)
2137 ;;(mapcar 'car mm-mime-mule-charset-alist)
2142 ["Leading" gnus-article-strip-leading-blank-lines t]
2143 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2144 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2145 ["All of the above" gnus-article-strip-blank-lines t]
2146 ["All" gnus-article-strip-all-blank-lines t]
2147 ["Leading space" gnus-article-strip-leading-space t]
2148 ["Trailing space" gnus-article-strip-trailing-space t]
2149 ["Leading space in headers"
2150 gnus-article-remove-leading-whitespace t])
2151 ["Overstrike" gnus-article-treat-overstrike t]
2152 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2153 ["Emphasis" gnus-article-emphasize t]
2154 ["Word wrap" gnus-article-fill-cited-article t]
2155 ["Fill long lines" gnus-article-fill-long-lines t]
2156 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2157 ["CR" gnus-article-remove-cr t]
2158 ["Rot 13" gnus-summary-caesar-message
2159 ,@(if (featurep 'xemacs) '(t)
2160 '(:help "\"Caesar rotate\" article by 13"))]
2161 ["Morse decode" gnus-summary-morse-message t]
2162 ["Unix pipe..." gnus-summary-pipe-message t]
2163 ["Add buttons" gnus-article-add-buttons t]
2164 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2165 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2166 ["Toggle MIME" gnus-summary-toggle-mime t]
2167 ["Verbose header" gnus-summary-verbose-headers t]
2168 ["Toggle header" gnus-summary-toggle-header t]
2169 ["Unfold headers" gnus-article-treat-unfold-headers t]
2170 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2171 ["Html" gnus-article-wash-html t]
2172 ["URLs" gnus-article-unsplit-urls t]
2173 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2174 ["HZ" gnus-article-decode-HZ t]
2175 ("(Outlook) Deuglify"
2176 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2177 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2178 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2179 ["Full (Outlook) deuglify"
2180 gnus-article-outlook-deuglify-article t])
2183 ["Save in default format" gnus-summary-save-article
2184 ,@(if (featurep 'xemacs) '(t)
2185 '(:help "Save article using default method"))]
2186 ["Save in file" gnus-summary-save-article-file
2187 ,@(if (featurep 'xemacs) '(t)
2188 '(:help "Save article in file"))]
2189 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2190 ["Save in MH folder" gnus-summary-save-article-folder t]
2191 ["Save in VM folder" gnus-summary-save-article-vm t]
2192 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2193 ["Save body in file" gnus-summary-save-article-body-file t]
2194 ["Pipe through a filter" gnus-summary-pipe-output t]
2195 ["Add to SOUP packet" gnus-soup-add-article t]
2196 ["Print with Muttprint" gnus-summary-muttprint t]
2197 ["Print" gnus-summary-print-article t])
2199 ["Respool article..." gnus-summary-respool-article t]
2200 ["Move article..." gnus-summary-move-article
2201 (gnus-check-backend-function
2202 'request-move-article gnus-newsgroup-name)]
2203 ["Copy article..." gnus-summary-copy-article t]
2204 ["Crosspost article..." gnus-summary-crosspost-article
2205 (gnus-check-backend-function
2206 'request-replace-article gnus-newsgroup-name)]
2207 ["Import file..." gnus-summary-import-article
2208 (gnus-check-backend-function
2209 'request-accept-article gnus-newsgroup-name)]
2210 ["Create article..." gnus-summary-create-article
2211 (gnus-check-backend-function
2212 'request-accept-article gnus-newsgroup-name)]
2213 ["Check if posted" gnus-summary-article-posted-p t]
2214 ["Edit article" gnus-summary-edit-article
2215 (not (gnus-group-read-only-p))]
2216 ["Delete article" gnus-summary-delete-article
2217 (gnus-check-backend-function
2218 'request-expire-articles gnus-newsgroup-name)]
2219 ["Query respool" gnus-summary-respool-query t]
2220 ["Trace respool" gnus-summary-respool-trace t]
2221 ["Delete expirable articles" gnus-summary-expire-articles-now
2222 (gnus-check-backend-function
2223 'request-expire-articles gnus-newsgroup-name)])
2225 ["Uudecode" gnus-uu-decode-uu
2226 ,@(if (featurep 'xemacs) '(t)
2227 '(:help "Decode uuencoded article(s)"))]
2228 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2229 ["Unshar" gnus-uu-decode-unshar t]
2230 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2231 ["Save" gnus-uu-decode-save t]
2232 ["Binhex" gnus-uu-decode-binhex t]
2233 ["Postscript" gnus-uu-decode-postscript t])
2235 ["Enter article" gnus-cache-enter-article t]
2236 ["Remove article" gnus-cache-remove-article t])
2237 ["Translate" gnus-article-babel t]
2238 ["Select article buffer" gnus-summary-select-article-buffer t]
2239 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2240 ["Isearch article..." gnus-summary-isearch-article t]
2241 ["Beginning of the article" gnus-summary-beginning-of-article t]
2242 ["End of the article" gnus-summary-end-of-article t]
2243 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2244 ["Fetch referenced articles" gnus-summary-refer-references t]
2245 ["Fetch current thread" gnus-summary-refer-thread t]
2246 ["Fetch article with id..." gnus-summary-refer-article t]
2247 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2248 ["Redisplay" gnus-summary-show-article t]
2249 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2251 gnus-summary-article-menu gnus-summary-mode-map ""
2252 (cons "Article" innards))
2254 (if (not (keymapp gnus-summary-article-menu))
2256 gnus-article-commands-menu gnus-article-mode-map ""
2257 (cons "Commands" innards))
2258 ;; in Emacs, don't share menu.
2259 (setq gnus-article-commands-menu
2260 (copy-keymap gnus-summary-article-menu))
2261 (define-key gnus-article-mode-map [menu-bar commands]
2262 (cons "Commands" gnus-article-commands-menu))))
2265 gnus-summary-thread-menu gnus-summary-mode-map ""
2267 ["Find all messages in thread" gnus-summary-refer-thread t]
2268 ["Toggle threading" gnus-summary-toggle-threads t]
2269 ["Hide threads" gnus-summary-hide-all-threads t]
2270 ["Show threads" gnus-summary-show-all-threads t]
2271 ["Hide thread" gnus-summary-hide-thread t]
2272 ["Show thread" gnus-summary-show-thread t]
2273 ["Go to next thread" gnus-summary-next-thread t]
2274 ["Go to previous thread" gnus-summary-prev-thread t]
2275 ["Go down thread" gnus-summary-down-thread t]
2276 ["Go up thread" gnus-summary-up-thread t]
2277 ["Top of thread" gnus-summary-top-thread t]
2278 ["Mark thread as read" gnus-summary-kill-thread t]
2279 ["Lower thread score" gnus-summary-lower-thread t]
2280 ["Raise thread score" gnus-summary-raise-thread t]
2281 ["Rethread current" gnus-summary-rethread-current t]))
2284 gnus-summary-post-menu gnus-summary-mode-map ""
2286 ["Send a message (mail or news)" gnus-summary-post-news
2287 ,@(if (featurep 'xemacs) '(t)
2288 '(:help "Post an article"))]
2289 ["Followup" gnus-summary-followup
2290 ,@(if (featurep 'xemacs) '(t)
2291 '(:help "Post followup to this article"))]
2292 ["Followup and yank" gnus-summary-followup-with-original
2293 ,@(if (featurep 'xemacs) '(t)
2294 '(:help "Post followup to this article, quoting its contents"))]
2295 ["Supersede article" gnus-summary-supersede-article t]
2296 ["Cancel article" gnus-summary-cancel-article
2297 ,@(if (featurep 'xemacs) '(t)
2298 '(:help "Cancel an article you posted"))]
2299 ["Reply" gnus-summary-reply t]
2300 ["Reply and yank" gnus-summary-reply-with-original t]
2301 ["Wide reply" gnus-summary-wide-reply t]
2302 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2303 ,@(if (featurep 'xemacs) '(t)
2304 '(:help "Mail a reply, quoting this article"))]
2305 ["Very wide reply" gnus-summary-very-wide-reply t]
2306 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2307 ,@(if (featurep 'xemacs) '(t)
2308 '(:help "Mail a very wide reply, quoting this article"))]
2309 ["Mail forward" gnus-summary-mail-forward t]
2310 ["Post forward" gnus-summary-post-forward t]
2311 ["Digest and mail" gnus-summary-digest-mail-forward t]
2312 ["Digest and post" gnus-summary-digest-post-forward t]
2313 ["Resend message" gnus-summary-resend-message t]
2314 ["Resend message edit" gnus-summary-resend-message-edit t]
2315 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2316 ["Send a mail" gnus-summary-mail-other-window t]
2317 ["Create a local message" gnus-summary-news-other-window t]
2318 ["Uuencode and post" gnus-uu-post-news
2319 ,@(if (featurep 'xemacs) '(t)
2320 '(:help "Post a uuencoded article"))]
2321 ["Followup via news" gnus-summary-followup-to-mail t]
2322 ["Followup via news and yank"
2323 gnus-summary-followup-to-mail-with-original t]
2325 ;;["Send" gnus-summary-send-draft t]
2326 ;;["Send bounced" gnus-resend-bounced-mail t])
2330 ((not (keymapp gnus-summary-post-menu))
2331 (setq gnus-article-post-menu gnus-summary-post-menu))
2332 ((not gnus-article-post-menu)
2333 ;; Don't share post menu.
2334 (setq gnus-article-post-menu
2335 (copy-keymap gnus-summary-post-menu))))
2336 (define-key gnus-article-mode-map [menu-bar post]
2337 (cons "Post" gnus-article-post-menu))
2340 gnus-summary-misc-menu gnus-summary-mode-map ""
2343 ["Mark as read" gnus-summary-mark-as-read-forward t]
2344 ["Mark same subject and select"
2345 gnus-summary-kill-same-subject-and-select t]
2346 ["Mark same subject" gnus-summary-kill-same-subject t]
2347 ["Catchup" gnus-summary-catchup
2348 ,@(if (featurep 'xemacs) '(t)
2349 '(:help "Mark unread articles in this group as read"))]
2350 ["Catchup all" gnus-summary-catchup-all t]
2351 ["Catchup to here" gnus-summary-catchup-to-here t]
2352 ["Catchup from here" gnus-summary-catchup-from-here t]
2353 ["Catchup region" gnus-summary-mark-region-as-read
2354 (gnus-mark-active-p)]
2355 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2357 ["Tick" gnus-summary-tick-article-forward t]
2358 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2359 ["Remove marks" gnus-summary-clear-mark-forward t]
2360 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2361 ["Set bookmark" gnus-summary-set-bookmark t]
2362 ["Remove bookmark" gnus-summary-remove-bookmark t])
2364 ["Marks..." gnus-summary-limit-to-marks t]
2365 ["Subject..." gnus-summary-limit-to-subject t]
2366 ["Author..." gnus-summary-limit-to-author t]
2367 ["Age..." gnus-summary-limit-to-age t]
2368 ["Extra..." gnus-summary-limit-to-extra t]
2369 ["Score..." gnus-summary-limit-to-score t]
2370 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2371 ["Unread" gnus-summary-limit-to-unread t]
2372 ["Unseen" gnus-summary-limit-to-unseen t]
2373 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2374 ["Next articles" gnus-summary-limit-to-articles t]
2375 ["Pop limit" gnus-summary-pop-limit t]
2376 ["Show dormant" gnus-summary-limit-include-dormant t]
2377 ["Hide childless dormant"
2378 gnus-summary-limit-exclude-childless-dormant t]
2379 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2380 ["Hide marked" gnus-summary-limit-exclude-marks t]
2381 ["Show expunged" gnus-summary-limit-include-expunged t])
2383 ["Set mark" gnus-summary-mark-as-processable t]
2384 ["Remove mark" gnus-summary-unmark-as-processable t]
2385 ["Remove all marks" gnus-summary-unmark-all-processable t]
2386 ["Mark above" gnus-uu-mark-over t]
2387 ["Mark series" gnus-uu-mark-series t]
2388 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2389 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2390 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2391 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2392 ["Mark all" gnus-uu-mark-all t]
2393 ["Mark buffer" gnus-uu-mark-buffer t]
2394 ["Mark sparse" gnus-uu-mark-sparse t]
2395 ["Mark thread" gnus-uu-mark-thread t]
2396 ["Unmark thread" gnus-uu-unmark-thread t]
2397 ("Process Mark Sets"
2398 ["Kill" gnus-summary-kill-process-mark t]
2399 ["Yank" gnus-summary-yank-process-mark
2400 gnus-newsgroup-process-stack]
2401 ["Save" gnus-summary-save-process-mark t]
2402 ["Run command on marked..." gnus-summary-universal-argument t]))
2404 ["Page forward" gnus-summary-next-page
2405 ,@(if (featurep 'xemacs) '(t)
2406 '(:help "Show next page of article"))]
2407 ["Page backward" gnus-summary-prev-page
2408 ,@(if (featurep 'xemacs) '(t)
2409 '(:help "Show previous page of article"))]
2410 ["Line forward" gnus-summary-scroll-up t])
2412 ["Next unread article" gnus-summary-next-unread-article t]
2413 ["Previous unread article" gnus-summary-prev-unread-article t]
2414 ["Next article" gnus-summary-next-article t]
2415 ["Previous article" gnus-summary-prev-article t]
2416 ["Next unread subject" gnus-summary-next-unread-subject t]
2417 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2418 ["Next article same subject" gnus-summary-next-same-subject t]
2419 ["Previous article same subject" gnus-summary-prev-same-subject t]
2420 ["First unread article" gnus-summary-first-unread-article t]
2421 ["Best unread article" gnus-summary-best-unread-article t]
2422 ["Go to subject number..." gnus-summary-goto-subject t]
2423 ["Go to article number..." gnus-summary-goto-article t]
2424 ["Go to the last article" gnus-summary-goto-last-article t]
2425 ["Pop article off history" gnus-summary-pop-article t])
2427 ["Sort by number" gnus-summary-sort-by-number t]
2428 ["Sort by author" gnus-summary-sort-by-author t]
2429 ["Sort by subject" gnus-summary-sort-by-subject t]
2430 ["Sort by date" gnus-summary-sort-by-date t]
2431 ["Sort by score" gnus-summary-sort-by-score t]
2432 ["Sort by lines" gnus-summary-sort-by-lines t]
2433 ["Sort by characters" gnus-summary-sort-by-chars t]
2434 ["Randomize" gnus-summary-sort-by-random t]
2435 ["Original sort" gnus-summary-sort-by-original t])
2437 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2438 ["Describe group" gnus-summary-describe-group t]
2439 ["Fetch charter" gnus-group-fetch-charter
2440 ,@(if (featurep 'xemacs) nil
2441 '(:help "Display the charter of the current group"))]
2442 ["Fetch control message" gnus-group-fetch-control
2443 ,@(if (featurep 'xemacs) nil
2444 '(:help "Display the archived control message for the current group"))]
2445 ["Read manual" gnus-info-find-node t])
2447 ["Pick and read" gnus-pick-mode t]
2448 ["Binary" gnus-binary-mode t])
2450 ["Regenerate" gnus-summary-prepare t]
2451 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2452 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2453 ["Toggle threading" gnus-summary-toggle-threads t])
2454 ["See old articles" gnus-summary-insert-old-articles t]
2455 ["See new articles" gnus-summary-insert-new-articles t]
2456 ["Filter articles..." gnus-summary-execute-command t]
2457 ["Run command on articles..." gnus-summary-universal-argument t]
2458 ["Search articles forward..." gnus-summary-search-article-forward t]
2459 ["Search articles backward..." gnus-summary-search-article-backward t]
2460 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2461 ["Expand window" gnus-summary-expand-window t]
2462 ["Expire expirable articles" gnus-summary-expire-articles
2463 (gnus-check-backend-function
2464 'request-expire-articles gnus-newsgroup-name)]
2465 ["Edit local kill file" gnus-summary-edit-local-kill t]
2466 ["Edit main kill file" gnus-summary-edit-global-kill t]
2467 ["Edit group parameters" gnus-summary-edit-parameters t]
2468 ["Customize group parameters" gnus-summary-customize-parameters t]
2469 ["Send a bug report" gnus-bug t]
2471 ["Catchup and exit" gnus-summary-catchup-and-exit
2472 ,@(if (featurep 'xemacs) '(t)
2473 '(:help "Mark unread articles in this group as read, then exit"))]
2474 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2475 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2476 ["Exit group" gnus-summary-exit
2477 ,@(if (featurep 'xemacs) '(t)
2478 '(:help "Exit current group, return to group selection mode"))]
2479 ["Exit group without updating" gnus-summary-exit-no-update t]
2480 ["Exit and goto next group" gnus-summary-next-group t]
2481 ["Exit and goto prev group" gnus-summary-prev-group t]
2482 ["Reselect group" gnus-summary-reselect-current-group t]
2483 ["Rescan group" gnus-summary-rescan-group t]
2484 ["Update dribble" gnus-summary-save-newsrc t])))
2486 (gnus-run-hooks 'gnus-summary-menu-hook)))
2488 (defvar gnus-summary-tool-bar-map nil)
2490 ;; Emacs 21 tool bar. Should be no-op otherwise.
2491 (defun gnus-summary-make-tool-bar ()
2492 (if (and (fboundp 'tool-bar-add-item-from-menu)
2493 (default-value 'tool-bar-mode)
2494 (not gnus-summary-tool-bar-map))
2495 (setq gnus-summary-tool-bar-map
2496 (let ((tool-bar-map (make-sparse-keymap))
2497 (load-path (mm-image-load-path)))
2498 (tool-bar-add-item-from-menu
2499 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2500 (tool-bar-add-item-from-menu
2501 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2502 (tool-bar-add-item-from-menu
2503 'gnus-summary-post-news "post" gnus-summary-mode-map)
2504 (tool-bar-add-item-from-menu
2505 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2506 (tool-bar-add-item-from-menu
2507 'gnus-summary-followup "followup" gnus-summary-mode-map)
2508 (tool-bar-add-item-from-menu
2509 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2510 (tool-bar-add-item-from-menu
2511 'gnus-summary-reply "reply" gnus-summary-mode-map)
2512 (tool-bar-add-item-from-menu
2513 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2514 (tool-bar-add-item-from-menu
2515 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2516 (tool-bar-add-item-from-menu
2517 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2518 (tool-bar-add-item-from-menu
2519 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2520 (tool-bar-add-item-from-menu
2521 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2522 (tool-bar-add-item-from-menu
2523 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2524 (tool-bar-add-item-from-menu
2525 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2526 (tool-bar-add-item-from-menu
2527 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2529 (if gnus-summary-tool-bar-map
2530 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2532 (defun gnus-score-set-default (var value)
2533 "A version of set that updates the GNU Emacs menu-bar."
2535 ;; It is the message that forces the active status to be updated.
2538 (defun gnus-make-score-map (type)
2539 "Make a summary score map of type TYPE."
2542 (let ((headers '(("author" "from" string)
2543 ("subject" "subject" string)
2544 ("article body" "body" string)
2545 ("article head" "head" string)
2546 ("xref" "xref" string)
2547 ("extra header" "extra" string)
2548 ("lines" "lines" number)
2549 ("followups to author" "followup" string)))
2550 (types '((number ("less than" <)
2553 (string ("substring" s)
2557 (perms '(("temporary" (current-time-string))
2565 (if (eq type 'lower)
2570 (setq header (car headers))
2576 (let ((ts (cdr (assoc (nth 2 header) types)))
2592 'gnus-summary-score-entry
2594 (if (or (string= (nth 1 header)
2596 (string= (nth 1 header)
2599 (list 'gnus-summary-header
2601 (list 'quote (nth 1 (car ts)))
2602 (list 'gnus-score-delta-default
2609 (list (nreverse outp))))
2612 (list (nreverse outt))))
2614 (setq headers (cdr headers)))
2615 (list (nreverse outh))))))))
2619 (defun gnus-summary-mode (&optional group)
2620 "Major mode for reading articles.
2622 All normal editing commands are switched off.
2623 \\<gnus-summary-mode-map>
2624 Each line in this buffer represents one article. To read an
2625 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2626 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2629 You can also post articles and send mail from this buffer. To
2630 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2631 of an article, type `\\[gnus-summary-reply]'.
2633 There are approx. one gazillion commands you can execute in this
2634 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2636 The following commands are available:
2638 \\{gnus-summary-mode-map}"
2640 (kill-all-local-variables)
2641 (when (gnus-visual-p 'summary-menu 'menu)
2642 (gnus-summary-make-menu-bar)
2643 (gnus-summary-make-tool-bar))
2644 (gnus-summary-make-local-variables)
2645 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2646 (gnus-summary-make-local-variables))
2647 (gnus-make-thread-indent-array)
2648 (gnus-simplify-mode-line)
2649 (setq major-mode 'gnus-summary-mode)
2650 (setq mode-name "Summary")
2651 (make-local-variable 'minor-mode-alist)
2652 (use-local-map gnus-summary-mode-map)
2653 (buffer-disable-undo)
2654 (setq buffer-read-only t) ;Disable modification
2655 (setq truncate-lines t)
2656 (setq selective-display t)
2657 (setq selective-display-ellipses t) ;Display `...'
2658 (gnus-summary-set-display-table)
2659 (gnus-set-default-directory)
2660 (setq gnus-newsgroup-name group)
2661 (unless (gnus-news-group-p group)
2662 (setq gnus-newsgroup-incorporated
2663 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2664 (make-local-variable 'gnus-summary-line-format)
2665 (make-local-variable 'gnus-summary-line-format-spec)
2666 (make-local-variable 'gnus-summary-dummy-line-format)
2667 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2668 (make-local-variable 'gnus-summary-mark-positions)
2669 (gnus-make-local-hook 'pre-command-hook)
2670 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2671 (gnus-run-hooks 'gnus-summary-mode-hook)
2672 (turn-on-gnus-mailing-list-mode)
2673 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2674 (gnus-update-summary-mark-positions))
2676 (defun gnus-summary-make-local-variables ()
2677 "Make all the local summary buffer variables."
2679 (dolist (local gnus-summary-local-variables)
2682 (if (eq (cdr local) 'global)
2683 ;; Copy the global value of the variable.
2684 (setq global (symbol-value (car local)))
2685 ;; Use the value from the list.
2686 (setq global (eval (cdr local))))
2687 (set (make-local-variable (car local)) global))
2688 ;; Simple nil-valued local variable.
2689 (set (make-local-variable local) nil)))))
2691 (defun gnus-summary-clear-local-variables ()
2692 (let ((locals gnus-summary-local-variables))
2694 (if (consp (car locals))
2695 (and (vectorp (caar locals))
2696 (set (caar locals) nil))
2697 (and (vectorp (car locals))
2698 (set (car locals) nil)))
2699 (setq locals (cdr locals)))))
2701 ;; Summary data functions.
2703 (defmacro gnus-data-number (data)
2706 (defmacro gnus-data-set-number (data number)
2707 `(setcar ,data ,number))
2709 (defmacro gnus-data-mark (data)
2712 (defmacro gnus-data-set-mark (data mark)
2713 `(setcar (nthcdr 1 ,data) ,mark))
2715 (defmacro gnus-data-pos (data)
2718 (defmacro gnus-data-set-pos (data pos)
2719 `(setcar (nthcdr 2 ,data) ,pos))
2721 (defmacro gnus-data-header (data)
2724 (defmacro gnus-data-set-header (data header)
2725 `(setcar (nthcdr 3 ,data) ,header))
2727 (defmacro gnus-data-level (data)
2730 (defmacro gnus-data-unread-p (data)
2731 `(= (nth 1 ,data) gnus-unread-mark))
2733 (defmacro gnus-data-read-p (data)
2734 `(/= (nth 1 ,data) gnus-unread-mark))
2736 (defmacro gnus-data-pseudo-p (data)
2737 `(consp (nth 3 ,data)))
2739 (defmacro gnus-data-find (number)
2740 `(assq ,number gnus-newsgroup-data))
2742 (defmacro gnus-data-find-list (number &optional data)
2743 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2744 (memq (assq ,number bdata)
2747 (defmacro gnus-data-make (number mark pos header level)
2748 `(list ,number ,mark ,pos ,header ,level))
2750 (defun gnus-data-enter (after-article number mark pos header level offset)
2751 (let ((data (gnus-data-find-list after-article)))
2753 (error "No such article: %d" after-article))
2754 (setcdr data (cons (gnus-data-make number mark pos header level)
2756 (setq gnus-newsgroup-data-reverse nil)
2757 (gnus-data-update-list (cddr data) offset)))
2759 (defun gnus-data-enter-list (after-article list &optional offset)
2761 (let ((data (and after-article (gnus-data-find-list after-article)))
2765 (let ((odata gnus-newsgroup-data))
2766 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2768 (gnus-data-update-list odata offset)))
2769 ;; Find the last element in the list to be spliced into the main
2772 (setq list (cdr list)))
2775 (setcdr list gnus-newsgroup-data)
2776 (setq gnus-newsgroup-data ilist)
2778 (gnus-data-update-list (cdr list) offset)))
2779 (setcdr list (cdr data))
2782 (gnus-data-update-list (cdr list) offset))))
2783 (setq gnus-newsgroup-data-reverse nil))))
2785 (defun gnus-data-remove (article &optional offset)
2786 (let ((data gnus-newsgroup-data))
2787 (if (= (gnus-data-number (car data)) article)
2789 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2790 gnus-newsgroup-data-reverse nil)
2792 (gnus-data-update-list gnus-newsgroup-data offset)))
2794 (when (= (gnus-data-number (cadr data)) article)
2795 (setcdr data (cddr data))
2797 (gnus-data-update-list (cdr data) offset))
2799 gnus-newsgroup-data-reverse nil))
2800 (setq data (cdr data))))))
2802 (defmacro gnus-data-list (backward)
2804 (or gnus-newsgroup-data-reverse
2805 (setq gnus-newsgroup-data-reverse
2806 (reverse gnus-newsgroup-data)))
2807 gnus-newsgroup-data))
2809 (defun gnus-data-update-list (data offset)
2810 "Add OFFSET to the POS of all data entries in DATA."
2811 (setq gnus-newsgroup-data-reverse nil)
2813 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2814 (setq data (cdr data))))
2816 (defun gnus-summary-article-pseudo-p (article)
2817 "Say whether this article is a pseudo article or not."
2818 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2820 (defmacro gnus-summary-article-sparse-p (article)
2821 "Say whether this article is a sparse article or not."
2822 `(memq ,article gnus-newsgroup-sparse))
2824 (defmacro gnus-summary-article-ancient-p (article)
2825 "Say whether this article is a sparse article or not."
2826 `(memq ,article gnus-newsgroup-ancient))
2828 (defun gnus-article-parent-p (number)
2829 "Say whether this article is a parent or not."
2830 (let ((data (gnus-data-find-list number)))
2831 (and (cdr data) ; There has to be an article after...
2832 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2833 (gnus-data-level (nth 1 data))))))
2835 (defun gnus-article-children (number)
2836 "Return a list of all children to NUMBER."
2837 (let* ((data (gnus-data-find-list number))
2838 (level (gnus-data-level (car data)))
2840 (setq data (cdr data))
2842 (= (gnus-data-level (car data)) (1+ level)))
2843 (push (gnus-data-number (car data)) children)
2844 (setq data (cdr data)))
2847 (defmacro gnus-summary-skip-intangible ()
2848 "If the current article is intangible, then jump to a different article."
2849 '(let ((to (get-text-property (point) 'gnus-intangible)))
2850 (and to (gnus-summary-goto-subject to))))
2852 (defmacro gnus-summary-article-intangible-p ()
2853 "Say whether this article is intangible or not."
2854 '(get-text-property (point) 'gnus-intangible))
2856 (defun gnus-article-read-p (article)
2857 "Say whether ARTICLE is read or not."
2858 (not (or (memq article gnus-newsgroup-marked)
2859 (memq article gnus-newsgroup-spam-marked)
2860 (memq article gnus-newsgroup-unreads)
2861 (memq article gnus-newsgroup-unselected)
2862 (memq article gnus-newsgroup-dormant))))
2864 ;; Some summary mode macros.
2866 (defmacro gnus-summary-article-number ()
2867 "The article number of the article on the current line.
2868 If there isn't an article number here, then we return the current
2871 (gnus-summary-skip-intangible)
2872 (or (get-text-property (point) 'gnus-number)
2873 (gnus-summary-last-subject))))
2875 (defmacro gnus-summary-article-header (&optional number)
2876 "Return the header of article NUMBER."
2877 `(gnus-data-header (gnus-data-find
2878 ,(or number '(gnus-summary-article-number)))))
2880 (defmacro gnus-summary-thread-level (&optional number)
2881 "Return the level of thread that starts with article NUMBER."
2882 `(if (and (eq gnus-summary-make-false-root 'dummy)
2883 (get-text-property (point) 'gnus-intangible))
2885 (gnus-data-level (gnus-data-find
2886 ,(or number '(gnus-summary-article-number))))))
2888 (defmacro gnus-summary-article-mark (&optional number)
2889 "Return the mark of article NUMBER."
2890 `(gnus-data-mark (gnus-data-find
2891 ,(or number '(gnus-summary-article-number)))))
2893 (defmacro gnus-summary-article-pos (&optional number)
2894 "Return the position of the line of article NUMBER."
2895 `(gnus-data-pos (gnus-data-find
2896 ,(or number '(gnus-summary-article-number)))))
2898 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2899 (defmacro gnus-summary-article-subject (&optional number)
2900 "Return current subject string or nil if nothing."
2903 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2904 '(gnus-data-header (assq (gnus-summary-article-number)
2905 gnus-newsgroup-data)))))
2908 (mail-header-subject headers))))
2910 (defmacro gnus-summary-article-score (&optional number)
2911 "Return current article score."
2912 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2913 gnus-newsgroup-scored))
2914 gnus-summary-default-score 0))
2916 (defun gnus-summary-article-children (&optional number)
2917 "Return a list of article numbers that are children of article NUMBER."
2918 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2919 (level (gnus-data-level (car data)))
2921 (while (and (setq data (cdr data))
2922 (> (setq l (gnus-data-level (car data))) level))
2923 (and (= (1+ level) l)
2924 (push (gnus-data-number (car data))
2926 (nreverse children)))
2928 (defun gnus-summary-article-parent (&optional number)
2929 "Return the article number of the parent of article NUMBER."
2930 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2931 (gnus-data-list t)))
2932 (level (gnus-data-level (car data))))
2934 () ; This is a root.
2935 ;; We search until we find an article with a level less than
2936 ;; this one. That function has to be the parent.
2937 (while (and (setq data (cdr data))
2938 (not (< (gnus-data-level (car data)) level))))
2939 (and data (gnus-data-number (car data))))))
2941 (defun gnus-unread-mark-p (mark)
2942 "Say whether MARK is the unread mark."
2943 (= mark gnus-unread-mark))
2945 (defun gnus-read-mark-p (mark)
2946 "Say whether MARK is one of the marks that mark as read.
2947 This is all marks except unread, ticked, dormant, and expirable."
2948 (not (or (= mark gnus-unread-mark)
2949 (= mark gnus-ticked-mark)
2950 (= mark gnus-spam-mark)
2951 (= mark gnus-dormant-mark)
2952 (= mark gnus-expirable-mark))))
2954 (defmacro gnus-article-mark (number)
2955 "Return the MARK of article NUMBER.
2956 This macro should only be used when computing the mark the \"first\"
2957 time; i.e., when generating the summary lines. After that,
2958 `gnus-summary-article-mark' should be used to examine the
2961 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2962 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2963 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2964 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2965 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2966 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2967 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2968 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2969 gnus-ancient-mark))))
2971 ;; Saving hidden threads.
2973 (defmacro gnus-save-hidden-threads (&rest forms)
2974 "Save hidden threads, eval FORMS, and restore the hidden threads."
2975 (let ((config (make-symbol "config")))
2976 `(let ((,config (gnus-hidden-threads-configuration)))
2980 (gnus-restore-hidden-threads-configuration ,config)))))
2981 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2982 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2984 (defun gnus-data-compute-positions ()
2985 "Compute the positions of all articles."
2986 (setq gnus-newsgroup-data-reverse nil)
2987 (let ((data gnus-newsgroup-data))
2989 (gnus-save-hidden-threads
2990 (gnus-summary-show-all-threads)
2991 (goto-char (point-min))
2993 (while (get-text-property (point) 'gnus-intangible)
2995 (gnus-data-set-pos (car data) (+ (point) 3))
2996 (setq data (cdr data))
2997 (forward-line 1))))))
2999 (defun gnus-hidden-threads-configuration ()
3000 "Return the current hidden threads configuration."
3003 (goto-char (point-min))
3004 (while (search-forward "\r" nil t)
3005 (push (1- (point)) config))
3008 (defun gnus-restore-hidden-threads-configuration (config)
3009 "Restore hidden threads configuration from CONFIG."
3011 (let (point buffer-read-only)
3012 (while (setq point (pop config))
3013 (when (and (< point (point-max))
3015 (eq (char-after) ?\n))
3016 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3018 ;; Various summary mode internalish functions.
3020 (defun gnus-mouse-pick-article (e)
3023 (gnus-summary-next-page nil t))
3025 (defun gnus-summary-set-display-table ()
3026 "Change the display table.
3027 Odd characters have a tendency to mess
3028 up nicely formatted displays - we make all possible glyphs
3029 display only a single character."
3031 ;; We start from the standard display table, if any.
3032 (let ((table (or (copy-sequence standard-display-table)
3033 (make-display-table)))
3035 ;; Nix out all the control chars...
3036 (while (>= (setq i (1- i)) 0)
3037 (aset table i [??]))
3038 ;; ... but not newline and cr, of course. (cr is necessary for the
3039 ;; selective display).
3040 (aset table ?\n nil)
3041 (aset table ?\r nil)
3042 ;; We keep TAB as well.
3043 (aset table ?\t nil)
3044 ;; We nix out any glyphs over 126 that are not set already.
3046 (while (>= (setq i (1- i)) 127)
3047 ;; Only modify if the entry is nil.
3048 (unless (aref table i)
3049 (aset table i [??]))))
3050 (setq buffer-display-table table)))
3052 (defun gnus-summary-set-article-display-arrow (pos)
3053 "Update the overlay arrow to point to line at position POS."
3054 (when (and gnus-summary-display-arrow
3055 (boundp 'overlay-arrow-position)
3056 (boundp 'overlay-arrow-string))
3060 (unless overlay-arrow-position
3061 (setq overlay-arrow-position (make-marker)))
3062 (setq overlay-arrow-string "=>"
3063 overlay-arrow-position (set-marker overlay-arrow-position
3065 (current-buffer))))))
3067 (defun gnus-summary-setup-buffer (group)
3068 "Initialize summary buffer."
3069 (let ((buffer (gnus-summary-buffer-name group))
3070 (dead-name (concat "*Dead Summary "
3071 (gnus-group-decoded-name group) "*")))
3072 ;; If a dead summary buffer exists, we kill it.
3073 (when (gnus-buffer-live-p dead-name)
3074 (gnus-kill-buffer dead-name))
3075 (if (get-buffer buffer)
3078 (setq gnus-summary-buffer (current-buffer))
3079 (not gnus-newsgroup-prepared))
3080 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3081 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3082 (gnus-summary-mode group)
3084 (gnus-carpal-setup-buffer 'summary))
3085 (unless gnus-single-article-buffer
3086 (make-local-variable 'gnus-article-buffer)
3087 (make-local-variable 'gnus-article-current)
3088 (make-local-variable 'gnus-original-article-buffer))
3089 (setq gnus-newsgroup-name group)
3090 ;; Set any local variables in the group parameters.
3091 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3094 (defun gnus-set-global-variables ()
3095 "Set the global equivalents of the buffer-local variables.
3096 They are set to the latest values they had. These reflect the summary
3097 buffer that was in action when the last article was fetched."
3098 (when (eq major-mode 'gnus-summary-mode)
3099 (setq gnus-summary-buffer (current-buffer))
3100 (let ((name gnus-newsgroup-name)
3101 (marked gnus-newsgroup-marked)
3102 (spam gnus-newsgroup-spam-marked)
3103 (unread gnus-newsgroup-unreads)
3104 (headers gnus-current-headers)
3105 (data gnus-newsgroup-data)
3106 (summary gnus-summary-buffer)
3107 (article-buffer gnus-article-buffer)
3108 (original gnus-original-article-buffer)
3109 (gac gnus-article-current)
3110 (reffed gnus-reffed-article-number)
3111 (score-file gnus-current-score-file)
3112 (default-charset gnus-newsgroup-charset)
3114 (let ((locals gnus-newsgroup-variables))
3116 (if (consp (car locals))
3117 (push (eval (caar locals)) vlist)
3118 (push (eval (car locals)) vlist))
3119 (setq locals (cdr locals)))
3120 (setq vlist (nreverse vlist)))
3122 (set-buffer gnus-group-buffer)
3123 (setq gnus-newsgroup-name name
3124 gnus-newsgroup-marked marked
3125 gnus-newsgroup-spam-marked spam
3126 gnus-newsgroup-unreads unread
3127 gnus-current-headers headers
3128 gnus-newsgroup-data data
3129 gnus-article-current gac
3130 gnus-summary-buffer summary
3131 gnus-article-buffer article-buffer
3132 gnus-original-article-buffer original
3133 gnus-reffed-article-number reffed
3134 gnus-current-score-file score-file
3135 gnus-newsgroup-charset default-charset)
3136 (let ((locals gnus-newsgroup-variables))
3138 (if (consp (car locals))
3139 (set (caar locals) (pop vlist))
3140 (set (car locals) (pop vlist)))
3141 (setq locals (cdr locals))))
3142 ;; The article buffer also has local variables.
3143 (when (gnus-buffer-live-p gnus-article-buffer)
3144 (set-buffer gnus-article-buffer)
3145 (setq gnus-summary-buffer summary))))))
3147 (defun gnus-summary-article-unread-p (article)
3148 "Say whether ARTICLE is unread or not."
3149 (memq article gnus-newsgroup-unreads))
3151 (defun gnus-summary-first-article-p (&optional article)
3152 "Return whether ARTICLE is the first article in the buffer."
3153 (if (not (setq article (or article (gnus-summary-article-number))))
3155 (eq article (caar gnus-newsgroup-data))))
3157 (defun gnus-summary-last-article-p (&optional article)
3158 "Return whether ARTICLE is the last article in the buffer."
3159 (if (not (setq article (or article (gnus-summary-article-number))))
3160 ;; All non-existent numbers are the last article. :-)
3162 (not (cdr (gnus-data-find-list article)))))
3164 (defun gnus-make-thread-indent-array ()
3166 (unless (and gnus-thread-indent-array
3167 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3168 (setq gnus-thread-indent-array (make-vector 201 "")
3169 gnus-thread-indent-array-level gnus-thread-indent-level)
3171 (aset gnus-thread-indent-array n
3172 (make-string (* n gnus-thread-indent-level) ? ))
3175 (defun gnus-update-summary-mark-positions ()
3176 "Compute where the summary marks are to go."
3178 (when (gnus-buffer-exists-p gnus-summary-buffer)
3179 (set-buffer gnus-summary-buffer))
3180 (let ((gnus-replied-mark 129)
3181 (gnus-score-below-mark 130)
3182 (gnus-score-over-mark 130)
3183 (gnus-undownloaded-mark 131)
3184 (spec gnus-summary-line-format-spec)
3187 (gnus-set-work-buffer)
3188 (let ((gnus-summary-line-format-spec spec)
3189 (gnus-newsgroup-downloadable '(0)))
3190 (gnus-summary-insert-line
3191 (make-full-mail-header 0 "" "nobody"
3192 "05 Apr 2001 23:33:09 +0400"
3194 0 nil t 128 t nil "" nil 1)
3195 (goto-char (point-min))
3196 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3197 (- (point) (point-min) 1)))))
3198 (goto-char (point-min))
3199 (push (cons 'replied (and (search-forward "\201" nil t)
3200 (- (point) (point-min) 1)))
3202 (goto-char (point-min))
3203 (push (cons 'score (and (search-forward "\202" nil t)
3204 (- (point) (point-min) 1)))
3206 (goto-char (point-min))
3207 (push (cons 'download
3208 (and (search-forward "\203" nil t)
3209 (- (point) (point-min) 1)))
3211 (setq gnus-summary-mark-positions pos))))
3213 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3214 "Insert a dummy root in the summary buffer."
3216 (gnus-add-text-properties
3217 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3218 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3220 (defun gnus-summary-extract-address-component (from)
3221 (or (car (funcall gnus-extract-address-components from))
3224 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3225 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3226 default-mime-charset)))
3227 ;; Is it really necessary to do this next part for each summary line?
3228 ;; Luckily, doesn't seem to slow things down much.
3230 (and gnus-ignored-from-addresses
3231 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3232 (let ((extra-headers (mail-header-extra header))
3236 ((setq to (cdr (assq 'To extra-headers)))
3239 (gnus-summary-extract-address-component
3240 (funcall gnus-decode-encoded-word-function to)))))
3241 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3242 (concat "=> " newsgroups)))))
3243 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3245 (defun gnus-summary-insert-line (gnus-tmp-header
3246 gnus-tmp-level gnus-tmp-current
3247 undownloaded gnus-tmp-unread gnus-tmp-replied
3248 gnus-tmp-expirable gnus-tmp-subject-or-nil
3249 &optional gnus-tmp-dummy gnus-tmp-score
3251 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3252 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3253 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3254 (gnus-tmp-score-char
3255 (if (or (null gnus-summary-default-score)
3256 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3257 gnus-summary-zcore-fuzz))
3259 (if (< gnus-tmp-score gnus-summary-default-score)
3260 gnus-score-below-mark gnus-score-over-mark)))
3261 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3263 (cond (gnus-tmp-process gnus-process-mark)
3264 ((memq gnus-tmp-current gnus-newsgroup-cached)
3266 (gnus-tmp-replied gnus-replied-mark)
3267 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3268 gnus-forwarded-mark)
3269 ((memq gnus-tmp-current gnus-newsgroup-saved)
3271 ((memq gnus-tmp-number gnus-newsgroup-recent)
3273 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3276 (gnus-tmp-downloaded
3278 gnus-undownloaded-mark)
3279 (gnus-newsgroup-agentized
3280 gnus-downloaded-mark)
3283 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3286 ((string-match "<[^>]+> *$" gnus-tmp-from)
3287 (let ((beg (match-beginning 0)))
3288 (or (and (string-match "^\".+\"" gnus-tmp-from)
3289 (substring gnus-tmp-from 1 (1- (match-end 0))))
3290 (substring gnus-tmp-from 0 beg))))
3291 ((string-match "(.+)" gnus-tmp-from)
3292 (substring gnus-tmp-from
3293 (1+ (match-beginning 0)) (1- (match-end 0))))
3295 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3296 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3297 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3298 (buffer-read-only nil))
3299 (when (string= gnus-tmp-name "")
3300 (setq gnus-tmp-name gnus-tmp-from))
3301 (unless (numberp gnus-tmp-lines)
3302 (setq gnus-tmp-lines -1))
3303 (if (= gnus-tmp-lines -1)
3304 (setq gnus-tmp-lines "?")
3305 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3306 (gnus-put-text-property-excluding-characters-with-faces
3308 (progn (eval gnus-summary-line-format-spec) (point))
3309 'gnus-number gnus-tmp-number)
3310 (when (gnus-visual-p 'summary-highlight 'highlight)
3312 (gnus-run-hooks 'gnus-summary-update-hook)
3315 (defun gnus-summary-update-line (&optional dont-update)
3316 "Update summary line after change."
3317 (when (and gnus-summary-default-score
3318 (not gnus-summary-inhibit-highlight))
3319 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3320 (article (gnus-summary-article-number))
3321 (score (gnus-summary-article-score article)))
3323 (if (and gnus-summary-mark-below
3324 (< (gnus-summary-article-score)
3325 gnus-summary-mark-below))
3326 ;; This article has a low score, so we mark it as read.
3327 (when (memq article gnus-newsgroup-unreads)
3328 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3329 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3330 ;; This article was previously marked as read on account
3331 ;; of a low score, but now it has risen, so we mark it as
3333 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3334 (gnus-summary-update-mark
3335 (if (or (null gnus-summary-default-score)
3336 (<= (abs (- score gnus-summary-default-score))
3337 gnus-summary-zcore-fuzz))
3339 (if (< score gnus-summary-default-score)
3340 gnus-score-below-mark gnus-score-over-mark))
3342 ;; Do visual highlighting.
3343 (when (gnus-visual-p 'summary-highlight 'highlight)
3344 (gnus-run-hooks 'gnus-summary-update-hook)))))
3346 (defvar gnus-tmp-new-adopts nil)
3348 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3349 "Return the number of articles in THREAD.
3350 This may be 0 in some cases -- if none of the articles in
3351 the thread are to be displayed."
3353 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3355 ((not (listp thread))
3357 ((and (consp thread) (cdr thread))
3360 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3363 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3366 (when (and level (zerop level) gnus-tmp-new-adopts)
3369 'gnus-summary-number-of-articles-in-thread
3370 gnus-tmp-new-adopts))))
3372 (if (> number 1) gnus-not-empty-thread-mark
3373 gnus-empty-thread-mark)
3376 (defsubst gnus-summary-line-message-size (head)
3377 "Return pretty-printed version of message size.
3378 This function is intended to be used in
3379 `gnus-summary-line-format-alist'."
3380 (let ((c (or (mail-header-chars head) -1)))
3381 (cond ((< c 0) "n/a") ; chars not available
3382 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3383 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3384 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3385 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3388 (defun gnus-summary-set-local-parameters (group)
3389 "Go through the local params of GROUP and set all variable specs in that list."
3390 (let ((params (gnus-group-find-parameter group))
3391 (vars '(quit-config)) ; Ignore quit-config.
3394 (setq elem (car params)
3395 params (cdr params))
3396 (and (consp elem) ; Has to be a cons.
3397 (consp (cdr elem)) ; The cdr has to be a list.
3398 (symbolp (car elem)) ; Has to be a symbol in there.
3399 (not (memq (car elem) vars))
3400 (ignore-errors ; So we set it.
3401 (push (car elem) vars)
3402 (make-local-variable (car elem))
3403 (set (car elem) (eval (nth 1 elem))))))))
3405 (defun gnus-summary-read-group (group &optional show-all no-article
3406 kill-buffer no-display backward
3408 "Start reading news in newsgroup GROUP.
3409 If SHOW-ALL is non-nil, already read articles are also listed.
3410 If NO-ARTICLE is non-nil, no article is selected initially.
3411 If NO-DISPLAY, don't generate a summary buffer."
3415 (let ((gnus-auto-select-next nil))
3416 (or (gnus-summary-read-group-1
3417 group show-all no-article
3418 kill-buffer no-display
3421 select-articles nil)))))
3422 (eq gnus-auto-select-next 'quietly))
3423 (set-buffer gnus-group-buffer)
3424 ;; The entry function called above goes to the next
3425 ;; group automatically, so we go two groups back
3426 ;; if we are searching for the previous group.
3428 (gnus-group-prev-unread-group 2))
3429 (if (not (equal group (gnus-group-group-name)))
3430 (setq group (gnus-group-group-name))
3434 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3435 "Directly jump to the other GROUP from summary buffer.
3436 If SHOW-ALL is non-nil, already read articles are also listed."
3438 (if (eq gnus-summary-buffer (current-buffer))
3439 (list (completing-read
3440 "Group: " gnus-active-hashtb nil t
3441 (when (and gnus-newsgroup-name
3442 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3443 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3444 'gnus-group-history)
3446 (error "%s must be invoked from a gnus summary buffer." this-command)))
3447 (unless (or (zerop (length group))
3448 (and gnus-newsgroup-name
3449 (string-equal gnus-newsgroup-name group)))
3451 (gnus-summary-read-group group show-all
3452 gnus-dont-select-after-jump-to-other-group)))
3454 (defun gnus-summary-read-group-1 (group show-all no-article
3455 kill-buffer no-display
3456 &optional select-articles)
3457 ;; Killed foreign groups can't be entered.
3458 ;; (when (and (not (gnus-group-native-p group))
3459 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3460 ;; (error "Dead non-native groups can't be entered"))
3461 (gnus-message 5 "Retrieving newsgroup: %s..."
3462 (gnus-group-decoded-name group))
3463 (let* ((new-group (gnus-summary-setup-buffer group))
3464 (quit-config (gnus-group-quit-config group))
3465 (did-select (and new-group (gnus-select-newsgroup
3466 group show-all select-articles))))
3468 ;; This summary buffer exists already, so we just select it.
3470 (gnus-set-global-variables)
3472 (gnus-kill-or-deaden-summary kill-buffer))
3473 (gnus-configure-windows 'summary 'force)
3474 (gnus-set-mode-line 'summary)
3475 (gnus-summary-position-point)
3478 ;; We couldn't select this group.
3480 (when (and (eq major-mode 'gnus-summary-mode)
3481 (not (equal (current-buffer) kill-buffer)))
3482 (kill-buffer (current-buffer))
3483 (if (not quit-config)
3485 ;; Update the info -- marks might need to be removed,
3487 (gnus-summary-update-info)
3488 (set-buffer gnus-group-buffer)
3489 (gnus-group-jump-to-group group)
3490 (gnus-group-next-unread-group 1))
3491 (gnus-handle-ephemeral-exit quit-config)))
3492 (let ((grpinfo (gnus-get-info group)))
3493 (if (null (gnus-info-read grpinfo))
3494 (gnus-message 3 "Group %s contains no messages"
3495 (gnus-group-decoded-name group))
3496 (gnus-message 3 "Can't select group")))
3498 ;; The user did a `C-g' while prompting for number of articles,
3499 ;; so we exit this group.
3500 ((eq did-select 'quit)
3501 (and (eq major-mode 'gnus-summary-mode)
3502 (not (equal (current-buffer) kill-buffer))
3503 (kill-buffer (current-buffer)))
3505 (gnus-kill-or-deaden-summary kill-buffer))
3506 (if (not quit-config)
3508 (set-buffer gnus-group-buffer)
3509 (gnus-group-jump-to-group group)
3510 (gnus-group-next-unread-group 1)
3511 (gnus-configure-windows 'group 'force))
3512 (gnus-handle-ephemeral-exit quit-config))
3513 ;; Finally signal the quit.
3515 ;; The group was successfully selected.
3517 (gnus-set-global-variables)
3518 ;; Save the active value in effect when the group was entered.
3519 (setq gnus-newsgroup-active
3521 (gnus-active gnus-newsgroup-name)))
3522 ;; You can change the summary buffer in some way with this hook.
3523 (gnus-run-hooks 'gnus-select-group-hook)
3524 (gnus-update-format-specifications
3525 nil 'summary 'summary-mode 'summary-dummy)
3526 (gnus-update-summary-mark-positions)
3527 ;; Do score processing.
3528 (when gnus-use-scoring
3529 (gnus-possibly-score-headers))
3530 ;; Check whether to fill in the gaps in the threads.
3531 (when gnus-build-sparse-threads
3532 (gnus-build-sparse-threads))
3533 ;; Find the initial limit.
3534 (if gnus-show-threads
3536 (let ((gnus-newsgroup-dormant nil))
3537 (gnus-summary-initial-limit show-all))
3538 (gnus-summary-initial-limit show-all))
3539 ;; When unthreaded, all articles are always shown.
3540 (setq gnus-newsgroup-limit
3542 (lambda (header) (mail-header-number header))
3543 gnus-newsgroup-headers)))
3544 ;; Generate the summary buffer.
3546 (gnus-summary-prepare))
3547 (when gnus-use-trees
3548 (gnus-tree-open group)
3549 (setq gnus-summary-highlight-line-function
3550 'gnus-tree-highlight-article))
3551 ;; If the summary buffer is empty, but there are some low-scored
3552 ;; articles or some excluded dormants, we include these in the
3554 (when (and (zerop (buffer-size))
3556 (cond (gnus-newsgroup-dormant
3557 (gnus-summary-limit-include-dormant))
3558 ((and gnus-newsgroup-scored show-all)
3559 (gnus-summary-limit-include-expunged t))))
3560 ;; Function `gnus-apply-kill-file' must be called in this hook.
3561 (gnus-run-hooks 'gnus-apply-kill-hook)
3562 (if (and (zerop (buffer-size))
3565 ;; This newsgroup is empty.
3566 (gnus-summary-catchup-and-exit nil t)
3567 (gnus-message 6 "No unread news")
3569 (gnus-kill-or-deaden-summary kill-buffer))
3570 ;; Return nil from this function.
3572 ;; Hide conversation thread subtrees. We cannot do this in
3573 ;; gnus-summary-prepare-hook since kill processing may not
3574 ;; work with hidden articles.
3575 (gnus-summary-maybe-hide-threads)
3577 (gnus-kill-or-deaden-summary kill-buffer))
3578 (gnus-summary-auto-select-subject)
3579 ;; Show first unread article if requested.
3580 (if (and (not no-article)
3582 gnus-newsgroup-unreads
3583 gnus-auto-select-first)
3585 (gnus-configure-windows 'summary)
3586 (let ((art (gnus-summary-article-number)))
3587 (unless (and (not gnus-plugged)
3588 (or (memq art gnus-newsgroup-undownloaded)
3589 (memq art gnus-newsgroup-downloadable)))
3590 (gnus-summary-goto-article art))))
3591 ;; Don't select any articles.
3592 (gnus-summary-position-point)
3593 (gnus-configure-windows 'summary 'force)
3594 (gnus-set-mode-line 'summary))
3595 (when (and gnus-auto-center-group
3596 (get-buffer-window gnus-group-buffer t))
3597 ;; Gotta use windows, because recenter does weird stuff if
3598 ;; the current buffer ain't the displayed window.
3599 (let ((owin (selected-window)))
3600 (select-window (get-buffer-window gnus-group-buffer t))
3601 (when (gnus-group-goto-group group)
3603 (select-window owin)))
3604 ;; Mark this buffer as "prepared".
3605 (setq gnus-newsgroup-prepared t)
3606 (gnus-run-hooks 'gnus-summary-prepared-hook)
3607 (unless (gnus-ephemeral-group-p group)
3608 (gnus-group-update-group group))
3611 (defun gnus-summary-auto-select-subject ()
3612 "Select the subject line on initial group entry."
3613 (goto-char (point-min))
3615 ((eq gnus-auto-select-subject 'best)
3616 (gnus-summary-best-unread-subject))
3617 ((eq gnus-auto-select-subject 'unread)
3618 (gnus-summary-first-unread-subject))
3619 ((eq gnus-auto-select-subject 'unseen)
3620 (gnus-summary-first-unseen-subject))
3621 ((eq gnus-auto-select-subject 'unseen-or-unread)
3622 (gnus-summary-first-unseen-or-unread-subject))
3623 ((eq gnus-auto-select-subject 'first)
3626 ((functionp gnus-auto-select-subject)
3627 (funcall gnus-auto-select-subject))))
3629 (defun gnus-summary-prepare ()
3630 "Generate the summary buffer."
3632 (let ((buffer-read-only nil))
3634 (setq gnus-newsgroup-data nil
3635 gnus-newsgroup-data-reverse nil)
3636 (gnus-run-hooks 'gnus-summary-generate-hook)
3637 ;; Generate the buffer, either with threads or without.
3638 (when gnus-newsgroup-headers
3639 (gnus-summary-prepare-threads
3640 (if gnus-show-threads
3641 (gnus-sort-gathered-threads
3642 (funcall gnus-summary-thread-gathering-function
3644 (gnus-cut-threads (gnus-make-threads)))))
3645 ;; Unthreaded display.
3646 (gnus-sort-articles gnus-newsgroup-headers))))
3647 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3648 ;; Call hooks for modifying summary buffer.
3649 (goto-char (point-min))
3650 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3652 (defsubst gnus-general-simplify-subject (subject)
3653 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3656 ;; Truncate the subject.
3657 (gnus-simplify-subject-functions
3658 (gnus-map-function gnus-simplify-subject-functions subject))
3659 ((numberp gnus-summary-gather-subject-limit)
3660 (setq subject (gnus-simplify-subject-re subject))
3661 (if (> (length subject) gnus-summary-gather-subject-limit)
3662 (substring subject 0 gnus-summary-gather-subject-limit)
3664 ;; Fuzzily simplify it.
3665 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3666 (gnus-simplify-subject-fuzzy subject))
3667 ;; Just remove the leading "Re:".
3669 (gnus-simplify-subject-re subject))))
3671 (if (and gnus-summary-gather-exclude-subject
3672 (string-match gnus-summary-gather-exclude-subject subject))
3673 nil ; This article shouldn't be gathered
3676 (defun gnus-summary-simplify-subject-query ()
3677 "Query where the respool algorithm would put this article."
3679 (gnus-summary-select-article)
3681 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3683 (defun gnus-gather-threads-by-subject (threads)
3684 "Gather threads by looking at Subject headers."
3685 (if (not gnus-summary-make-false-root)
3687 (let ((hashtb (gnus-make-hashtable 1024))
3690 subject hthread whole-subject)
3692 (setq subject (gnus-general-simplify-subject
3693 (setq whole-subject (mail-header-subject
3696 (if (setq hthread (gnus-gethash subject hashtb))
3698 ;; We enter a dummy root into the thread, if we
3699 ;; haven't done that already.
3700 (unless (stringp (caar hthread))
3701 (setcar hthread (list whole-subject (car hthread))))
3702 ;; We add this new gathered thread to this gathered
3704 (setcdr (car hthread)
3705 (nconc (cdar hthread) (list (car threads))))
3706 ;; Remove it from the list of threads.
3707 (setcdr prev (cdr threads))
3708 (setq threads prev))
3709 ;; Enter this thread into the hash table.
3710 (gnus-sethash subject
3711 (if gnus-summary-make-false-root-always
3713 ;; If you want a dummy root above all
3715 (setcar threads (list whole-subject
3721 (setq threads (cdr threads)))
3724 (defun gnus-gather-threads-by-references (threads)
3725 "Gather threads by looking at References headers."
3726 (let ((idhashtb (gnus-make-hashtable 1024))
3727 (thhashtb (gnus-make-hashtable 1024))
3730 ids references id gthread gid entered ref)
3732 (when (setq references (mail-header-references (caar threads)))
3733 (setq id (mail-header-id (caar threads))
3734 ids (inline (gnus-split-references references))
3736 (while (setq ref (pop ids))
3737 (setq ids (delete ref ids))
3738 (if (not (setq gid (gnus-gethash ref idhashtb)))
3740 (gnus-sethash ref id idhashtb)
3741 (gnus-sethash id threads thhashtb))
3742 (setq gthread (gnus-gethash gid thhashtb))
3744 ;; We enter a dummy root into the thread, if we
3745 ;; haven't done that already.
3746 (unless (stringp (caar gthread))
3747 (setcar gthread (list (mail-header-subject (caar gthread))
3749 ;; We add this new gathered thread to this gathered
3751 (setcdr (car gthread)
3752 (nconc (cdar gthread) (list (car threads)))))
3753 ;; Add it into the thread hash table.
3754 (gnus-sethash id gthread thhashtb)
3756 ;; Remove it from the list of threads.
3757 (setcdr prev (cdr threads))
3758 (setq threads prev))))
3760 (setq threads (cdr threads)))
3763 (defun gnus-sort-gathered-threads (threads)
3764 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3765 (let ((result threads))
3767 (when (stringp (caar threads))
3768 (setcdr (car threads)
3769 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3770 (setq threads (cdr threads)))
3773 (defun gnus-thread-loop-p (root thread)
3774 "Say whether ROOT is in THREAD."
3775 (let ((stack (list thread))
3778 (while (setq thread (pop stack))
3779 (setq th (cdr thread))
3781 (not (eq (caar th) root)))
3784 ;; We have found a loop.
3786 (setcdr thread (delq (car th) (cdr thread)))
3787 (if (boundp (setq ref-dep (intern "none"
3788 gnus-newsgroup-dependencies)))
3789 (setcdr (symbol-value ref-dep)
3790 (nconc (cdr (symbol-value ref-dep))
3792 (set ref-dep (list nil (car th))))
3795 ;; Push all the subthreads onto the stack.
3796 (push (cdr thread) stack)))
3799 (defun gnus-make-threads ()
3800 "Go through the dependency hashtb and find the roots. Return all threads."
3802 (while (catch 'infloop
3805 ;; Deal with self-referencing References loops.
3806 (when (and (car (symbol-value refs))
3813 (car (symbol-value refs)) thread))
3814 (cdr (symbol-value refs)))))))
3817 (unless (car (symbol-value refs))
3818 ;; These threads do not refer back to any other articles,
3819 ;; so they're roots.
3820 (setq threads (append (cdr (symbol-value refs)) threads))))
3821 gnus-newsgroup-dependencies)))
3824 ;; Build the thread tree.
3825 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3826 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3828 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3829 if it was already present.
3831 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3832 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3833 Message-IDs will be renamed to a unique Message-ID before being
3836 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3837 (let* ((id (mail-header-id header))
3838 (id-dep (and id (intern id dependencies)))
3839 parent-id ref ref-dep ref-header replaced)
3840 ;; Enter this `header' in the `dependencies' table.
3844 ;; The first two cases do the normal part: enter a new `header'
3845 ;; in the `dependencies' table.
3846 ((not (boundp id-dep))
3847 (set id-dep (list header)))
3848 ((null (car (symbol-value id-dep)))
3849 (setcar (symbol-value id-dep) header))
3851 ;; From here the `header' was already present in the
3852 ;; `dependencies' table.
3854 ;; Overrides an existing entry;
3855 ;; just set the header part of the entry.
3856 (setcar (symbol-value id-dep) header)
3859 ;; Renames the existing `header' to a unique Message-ID.
3860 ((not gnus-summary-ignore-duplicates)
3861 ;; An article with this Message-ID has already been seen.
3862 ;; We rename the Message-ID.
3863 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3865 (mail-header-set-id header id))
3867 ;; The last case ignores an existing entry, except it adds any
3868 ;; additional Xrefs (in case the two articles came from different
3870 ;; Also sets `header' to `nil' meaning that the `dependencies'
3871 ;; table was *not* modified.
3873 (mail-header-set-xref
3874 (car (symbol-value id-dep))
3875 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3877 (or (mail-header-xref header) "")))
3880 (when (and header (not replaced))
3881 ;; First check that we are not creating a References loop.
3882 (setq parent-id (gnus-parent-id (mail-header-references header)))
3883 (setq ref parent-id)
3885 (setq ref-dep (intern-soft ref dependencies))
3887 (setq ref-header (car (symbol-value ref-dep))))
3888 (if (string= id ref)
3889 ;; Yuk! This is a reference loop. Make the article be a
3892 (mail-header-set-references (car (symbol-value id-dep)) "none")
3894 (setq parent-id nil))
3895 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3896 (setq ref-dep (intern (or parent-id "none") dependencies))
3897 (if (boundp ref-dep)
3898 (setcdr (symbol-value ref-dep)
3899 (nconc (cdr (symbol-value ref-dep))
3900 (list (symbol-value id-dep))))
3901 (set ref-dep (list nil (symbol-value id-dep)))))
3904 (defun gnus-extract-message-id-from-in-reply-to (string)
3905 (if (string-match "<[^>]+>" string)
3906 (substring string (match-beginning 0) (match-end 0))
3909 (defun gnus-build-sparse-threads ()
3910 (let ((headers gnus-newsgroup-headers)
3911 (mail-parse-charset gnus-newsgroup-charset)
3912 (gnus-summary-ignore-duplicates t)
3913 header references generation relations
3914 subject child end new-child date)
3915 ;; First we create an alist of generations/relations, where
3916 ;; generations is how much we trust the relation, and the relation
3918 (gnus-message 7 "Making sparse threads...")
3920 (nnheader-set-temp-buffer " *gnus sparse threads*")
3921 (while (setq header (pop headers))
3922 (when (and (setq references (mail-header-references header))
3923 (not (string= references "")))
3925 (setq child (mail-header-id header)
3926 subject (mail-header-subject header)
3927 date (mail-header-date header)
3929 (while (search-backward ">" nil t)
3930 (setq end (1+ (point)))
3931 (when (search-backward "<" nil t)
3932 (setq new-child (buffer-substring (point) end))
3933 (push (list (incf generation)
3934 child (setq child new-child)
3938 (push (list (1+ generation) child nil subject) relations))
3940 (kill-buffer (current-buffer)))
3941 ;; Sort over trustworthiness.
3944 (when (gnus-dependencies-add-header
3945 (make-full-mail-header-from-decoded-header
3946 gnus-reffed-article-number
3947 (nth 3 relation) "" (or (nth 4 relation) "")
3949 (or (nth 2 relation) "") 0 0 "")
3950 gnus-newsgroup-dependencies nil)
3951 (push gnus-reffed-article-number gnus-newsgroup-limit)
3952 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3953 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3954 gnus-newsgroup-reads)
3955 (decf gnus-reffed-article-number)))
3956 (sort relations 'car-less-than-car))
3957 (gnus-message 7 "Making sparse threads...done")))
3959 (defun gnus-build-old-threads ()
3960 ;; Look at all the articles that refer back to old articles, and
3961 ;; fetch the headers for the articles that aren't there. This will
3962 ;; build complete threads - if the roots haven't been expired by the
3964 (let ((mail-parse-charset gnus-newsgroup-charset)
3968 (when (not (car (symbol-value refs)))
3969 (setq heads (cdr (symbol-value refs)))
3971 (if (memq (mail-header-number (caar heads))
3972 gnus-newsgroup-dormant)
3973 (setq heads (cdr heads))
3974 (setq id (symbol-name refs))
3975 (while (and (setq id (gnus-build-get-header id))
3976 (not (car (gnus-id-to-thread id)))))
3977 (setq heads nil)))))
3978 gnus-newsgroup-dependencies)))
3980 ;; This function has to be called with point after the article number
3981 ;; on the beginning of the line.
3982 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3983 (let ((eol (gnus-point-at-eol))
3984 (buffer (current-buffer))
3985 header references in-reply-to)
3987 ;; overview: [num subject from date id refs chars lines misc]
3990 (narrow-to-region (point) eol)
3995 (make-full-mail-header
3997 (nnheader-nov-field) ; subject
3998 (nnheader-nov-field) ; from
3999 (nnheader-nov-field) ; date
4000 (nnheader-nov-read-message-id) ; id
4001 (nnheader-nov-field) ; refs
4002 (nnheader-nov-read-integer) ; chars
4003 (nnheader-nov-read-integer) ; lines
4005 (if (looking-at "Xref: ")
4006 (goto-char (match-end 0)))
4007 (nnheader-nov-field)) ; Xref
4008 (nnheader-nov-parse-extra)))) ; extra
4012 (when (and (string= references "")
4013 (setq in-reply-to (mail-header-extra header))
4014 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4015 (mail-header-set-references
4016 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4018 (when gnus-alter-header-function
4019 (funcall gnus-alter-header-function header))
4020 (gnus-dependencies-add-header header dependencies force-new)))
4022 (defun gnus-build-get-header (id)
4023 "Look through the buffer of NOV lines and find the header to ID.
4024 Enter this line into the dependencies hash table, and return
4025 the id of the parent article (if any)."
4026 (let ((deps gnus-newsgroup-dependencies)
4030 (set-buffer nntp-server-buffer)
4031 (let ((case-fold-search nil))
4032 (goto-char (point-min))
4033 (while (and (not found)
4034 (search-forward id nil t))
4036 (setq found (looking-at
4037 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4038 (regexp-quote id))))
4039 (or found (beginning-of-line 2)))
4043 (setq header (gnus-nov-parse-line
4044 (read (current-buffer)) deps))
4045 (gnus-parent-id (mail-header-references header))))))
4047 (let ((number (mail-header-number header)))
4048 (push number gnus-newsgroup-limit)
4049 (push header gnus-newsgroup-headers)
4050 (if (memq number gnus-newsgroup-unselected)
4052 (setq gnus-newsgroup-unreads
4053 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4055 (setq gnus-newsgroup-unselected
4056 (delq number gnus-newsgroup-unselected)))
4057 (push number gnus-newsgroup-ancient)))))))
4059 (defun gnus-build-all-threads ()
4060 "Read all the headers."
4061 (let ((gnus-summary-ignore-duplicates t)
4062 (mail-parse-charset gnus-newsgroup-charset)
4063 (dependencies gnus-newsgroup-dependencies)
4066 (set-buffer nntp-server-buffer)
4067 (let ((case-fold-search nil))
4068 (goto-char (point-min))
4071 (setq article (read (current-buffer))
4072 header (gnus-nov-parse-line article dependencies)))
4075 (set-buffer gnus-summary-buffer)
4076 (push header gnus-newsgroup-headers)
4077 (if (memq (setq article (mail-header-number header))
4078 gnus-newsgroup-unselected)
4080 (setq gnus-newsgroup-unreads
4081 (gnus-add-to-sorted-list
4082 gnus-newsgroup-unreads article))
4083 (setq gnus-newsgroup-unselected
4084 (delq article gnus-newsgroup-unselected)))
4085 (push article gnus-newsgroup-ancient)))
4086 (forward-line 1)))))))
4088 (defun gnus-summary-update-article-line (article header)
4089 "Update the line for ARTICLE using HEADERS."
4090 (let* ((id (mail-header-id header))
4091 (thread (gnus-id-to-thread id)))
4093 (error "Article in no thread"))
4094 ;; Update the thread.
4095 (setcar thread header)
4096 (gnus-summary-goto-subject article)
4097 (let* ((datal (gnus-data-find-list article))
4099 (buffer-read-only nil)
4100 (level (gnus-summary-thread-level)))
4102 (let ((inserted (- (point)
4104 (gnus-summary-insert-line
4106 (memq article gnus-newsgroup-undownloaded)
4107 (gnus-article-mark article)
4108 (memq article gnus-newsgroup-replied)
4109 (memq article gnus-newsgroup-expirable)
4110 ;; Only insert the Subject string when it's different
4111 ;; from the previous Subject string.
4116 (mail-header-subject
4119 (gnus-data-find-list
4121 (gnus-data-list t)))))
4122 ;; Error on the side of excessive subjects.
4124 (mail-header-subject header)))
4126 (mail-header-subject header))
4127 nil (cdr (assq article gnus-newsgroup-scored))
4128 (memq article gnus-newsgroup-processable))
4131 (gnus-data-update-list
4133 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4135 (defun gnus-summary-update-article (article &optional iheader)
4136 "Update ARTICLE in the summary buffer."
4137 (set-buffer gnus-summary-buffer)
4138 (let* ((header (gnus-summary-article-header article))
4139 (id (mail-header-id header))
4140 (data (gnus-data-find article))
4141 (thread (gnus-id-to-thread id))
4142 (references (mail-header-references header))
4146 (when (and references
4147 (not (equal "" references)))
4150 (buffer-read-only nil)
4156 (delq thread parent)))
4157 (if (gnus-summary-insert-subject id header)
4158 ;; Set the (possibly) new article number in the data structure.
4159 (gnus-data-set-number data (gnus-id-to-article id))
4163 (defun gnus-rebuild-thread (id &optional line)
4164 "Rebuild the thread containing ID.
4165 If LINE, insert the rebuilt thread starting on line LINE."
4166 (let ((buffer-read-only nil)
4167 old-pos current thread data)
4168 (if (not gnus-show-threads)
4169 (setq thread (list (car (gnus-id-to-thread id))))
4170 ;; Get the thread this article is part of.
4171 (setq thread (gnus-remove-thread id)))
4172 (setq old-pos (gnus-point-at-bol))
4173 (setq current (save-excursion
4174 (and (re-search-backward "[\r\n]" nil t)
4175 (gnus-summary-article-number))))
4176 ;; If this is a gathered thread, we have to go some re-gathering.
4177 (when (stringp (car thread))
4178 (let ((subject (car thread))
4180 (setq thread (cdr thread))
4182 (unless (memq (setq thr (gnus-id-to-thread
4184 (mail-header-id (caar thread)))))
4187 (setq thread (cdr thread)))
4188 ;; We now have all (unique) roots.
4189 (if (= (length roots) 1)
4190 ;; All the loose roots are now one solid root.
4191 (setq thread (car roots))
4192 (setq thread (cons subject (gnus-sort-threads roots))))))
4194 ;; We then insert this thread into the summary buffer.
4196 (goto-char (point-min))
4197 (forward-line (1- line)))
4198 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4199 (if gnus-show-threads
4200 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4201 (gnus-summary-prepare-unthreaded thread))
4202 (setq data (nreverse gnus-newsgroup-data))
4203 (setq threads gnus-newsgroup-threads))
4204 ;; We splice the new data into the data structure.
4205 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4206 ;;!!! then we want to insert at the beginning of the buffer.
4207 ;;!!! That happens to be true with Gnus now, but that may
4208 ;;!!! change in the future. Perhaps.
4209 (gnus-data-enter-list
4210 (if line nil current) data (- (point) old-pos))
4211 (setq gnus-newsgroup-threads
4212 (nconc threads gnus-newsgroup-threads))
4213 (gnus-data-compute-positions))))
4215 (defun gnus-number-to-header (number)
4216 "Return the header for article NUMBER."
4217 (let ((headers gnus-newsgroup-headers))
4219 (not (= number (mail-header-number (car headers)))))
4224 (defun gnus-parent-headers (in-headers &optional generation)
4225 "Return the headers of the GENERATIONeth parent of HEADERS."
4227 (setq generation 1))
4229 (headers in-headers)
4232 (not (zerop generation))
4233 (setq references (mail-header-references headers)))
4234 (setq headers (if (and references
4235 (setq parent (gnus-parent-id references)))
4236 (car (gnus-id-to-thread parent))
4239 (and (not (eq headers in-headers))
4242 (defun gnus-id-to-thread (id)
4243 "Return the (sub-)thread where ID appears."
4244 (gnus-gethash id gnus-newsgroup-dependencies))
4246 (defun gnus-id-to-article (id)
4247 "Return the article number of ID."
4248 (let ((thread (gnus-id-to-thread id)))
4251 (mail-header-number (car thread)))))
4253 (defun gnus-id-to-header (id)
4254 "Return the article headers of ID."
4255 (car (gnus-id-to-thread id)))
4257 (defun gnus-article-displayed-root-p (article)
4258 "Say whether ARTICLE is a root(ish) article."
4259 (let ((level (gnus-summary-thread-level article))
4260 (refs (mail-header-references (gnus-summary-article-header article)))
4266 ((null (gnus-parent-id refs)) t)
4268 (null (setq particle (gnus-id-to-article
4269 (gnus-parent-id refs))))
4270 (null (gnus-summary-thread-level particle)))))))
4272 (defun gnus-root-id (id)
4273 "Return the id of the root of the thread where ID appears."
4275 (while (and id (setq prev (car (gnus-id-to-thread id))))
4277 id (gnus-parent-id (mail-header-references prev))))
4280 (defun gnus-articles-in-thread (thread)
4281 "Return the list of articles in THREAD."
4282 (cons (mail-header-number (car thread))
4283 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4285 (defun gnus-remove-thread (id &optional dont-remove)
4286 "Remove the thread that has ID in it."
4287 (let (headers thread last-id)
4288 ;; First go up in this thread until we find the root.
4289 (setq last-id (gnus-root-id id)
4290 headers (message-flatten-list (gnus-id-to-thread last-id)))
4291 ;; We have now found the real root of this thread. It might have
4292 ;; been gathered into some loose thread, so we have to search
4293 ;; through the threads to find the thread we wanted.
4294 (let ((threads gnus-newsgroup-threads)
4297 (setq sub (car threads))
4298 (if (stringp (car sub))
4299 ;; This is a gathered thread, so we look at the roots
4300 ;; below it to find whether this article is in this
4303 (setq sub (cdr sub))
4305 (when (member (caar sub) headers)
4306 (setq thread (car threads)
4309 (setq sub (cdr sub))))
4310 ;; It's an ordinary thread, so we check it.
4311 (when (eq (car sub) (car headers))
4314 (setq threads (cdr threads)))
4315 ;; If this article is in no thread, then it's a root.
4318 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4319 (setq thread (gnus-id-to-thread last-id)))
4322 thread ; We return this thread.
4324 (if (stringp (car thread))
4326 ;; If we use dummy roots, then we have to remove the
4327 ;; dummy root as well.
4328 (when (eq gnus-summary-make-false-root 'dummy)
4329 ;; We go to the dummy root by going to
4330 ;; the first sub-"thread", and then one line up.
4331 (gnus-summary-goto-article
4332 (mail-header-number (caadr thread)))
4335 (gnus-data-compute-positions))
4336 (setq thread (cdr thread))
4338 (gnus-remove-thread-1 (car thread))
4339 (setq thread (cdr thread))))
4340 (gnus-remove-thread-1 thread))))))))
4342 (defun gnus-remove-thread-1 (thread)
4343 "Remove the thread THREAD recursively."
4344 (let ((number (mail-header-number (pop thread)))
4346 (setq thread (reverse thread))
4348 (gnus-remove-thread-1 (pop thread)))
4349 (when (setq d (gnus-data-find number))
4350 (goto-char (gnus-data-pos d))
4351 (gnus-summary-show-thread)
4354 (- (gnus-point-at-bol)
4356 (1+ (gnus-point-at-eol))
4357 (gnus-delete-line)))))))
4359 (defun gnus-sort-threads-1 (threads func)
4360 (sort (mapcar (lambda (thread)
4363 (gnus-sort-threads-1 (cdr thread) func))))
4366 (defun gnus-sort-threads (threads)
4368 (if (not gnus-thread-sort-functions)
4370 (gnus-message 8 "Sorting threads...")
4371 (let ((max-lisp-eval-depth 5000))
4372 (prog1 (gnus-sort-threads-1
4374 (gnus-make-sort-function gnus-thread-sort-functions))
4375 (gnus-message 8 "Sorting threads...done")))))
4377 (defun gnus-sort-articles (articles)
4379 (when gnus-article-sort-functions
4380 (gnus-message 7 "Sorting articles...")
4382 (setq gnus-newsgroup-headers
4383 (sort articles (gnus-make-sort-function
4384 gnus-article-sort-functions)))
4385 (gnus-message 7 "Sorting articles...done"))))
4387 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4388 (defmacro gnus-thread-header (thread)
4389 "Return header of first article in THREAD.
4390 Note that THREAD must never, ever be anything else than a variable -
4391 using some other form will lead to serious barfage."
4392 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4393 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4394 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4397 (defsubst gnus-article-sort-by-number (h1 h2)
4398 "Sort articles by article number."
4399 (< (mail-header-number h1)
4400 (mail-header-number h2)))
4402 (defun gnus-thread-sort-by-number (h1 h2)
4403 "Sort threads by root article number."
4404 (gnus-article-sort-by-number
4405 (gnus-thread-header h1) (gnus-thread-header h2)))
4407 (defsubst gnus-article-sort-by-random (h1 h2)
4408 "Sort articles by article number."
4411 (defun gnus-thread-sort-by-random (h1 h2)
4412 "Sort threads by root article number."
4413 (gnus-article-sort-by-random
4414 (gnus-thread-header h1) (gnus-thread-header h2)))
4416 (defsubst gnus-article-sort-by-lines (h1 h2)
4417 "Sort articles by article Lines header."
4418 (< (mail-header-lines h1)
4419 (mail-header-lines h2)))
4421 (defun gnus-thread-sort-by-lines (h1 h2)
4422 "Sort threads by root article Lines header."
4423 (gnus-article-sort-by-lines
4424 (gnus-thread-header h1) (gnus-thread-header h2)))
4426 (defsubst gnus-article-sort-by-chars (h1 h2)
4427 "Sort articles by octet length."
4428 (< (mail-header-chars h1)
4429 (mail-header-chars h2)))
4431 (defun gnus-thread-sort-by-chars (h1 h2)
4432 "Sort threads by root article octet length."
4433 (gnus-article-sort-by-chars
4434 (gnus-thread-header h1) (gnus-thread-header h2)))
4436 (defsubst gnus-article-sort-by-author (h1 h2)
4437 "Sort articles by root author."
4439 (let ((addr (car (mime-entity-read-field h1 'From))))
4440 (or (std11-full-name-string addr)
4441 (std11-address-string addr)
4443 (let ((addr (car (mime-entity-read-field h2 'From))))
4444 (or (std11-full-name-string addr)
4445 (std11-address-string addr)
4449 (defun gnus-thread-sort-by-author (h1 h2)
4450 "Sort threads by root author."
4451 (gnus-article-sort-by-author
4452 (gnus-thread-header h1) (gnus-thread-header h2)))
4454 (defsubst gnus-article-sort-by-subject (h1 h2)
4455 "Sort articles by root subject."
4457 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4458 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4460 (defun gnus-thread-sort-by-subject (h1 h2)
4461 "Sort threads by root subject."
4462 (gnus-article-sort-by-subject
4463 (gnus-thread-header h1) (gnus-thread-header h2)))
4465 (defsubst gnus-article-sort-by-date (h1 h2)
4466 "Sort articles by root article date."
4468 (gnus-date-get-time (mail-header-date h1))
4469 (gnus-date-get-time (mail-header-date h2))))
4471 (defun gnus-thread-sort-by-date (h1 h2)
4472 "Sort threads by root article date."
4473 (gnus-article-sort-by-date
4474 (gnus-thread-header h1) (gnus-thread-header h2)))
4476 (defsubst gnus-article-sort-by-score (h1 h2)
4477 "Sort articles by root article score.
4478 Unscored articles will be counted as having a score of zero."
4479 (> (or (cdr (assq (mail-header-number h1)
4480 gnus-newsgroup-scored))
4481 gnus-summary-default-score 0)
4482 (or (cdr (assq (mail-header-number h2)
4483 gnus-newsgroup-scored))
4484 gnus-summary-default-score 0)))
4486 (defun gnus-thread-sort-by-score (h1 h2)
4487 "Sort threads by root article score."
4488 (gnus-article-sort-by-score
4489 (gnus-thread-header h1) (gnus-thread-header h2)))
4491 (defun gnus-thread-sort-by-total-score (h1 h2)
4492 "Sort threads by the sum of all scores in the thread.
4493 Unscored articles will be counted as having a score of zero."
4494 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4496 (defun gnus-thread-total-score (thread)
4497 ;; This function find the total score of THREAD.
4502 (if (stringp (car thread))
4503 (apply gnus-thread-score-function 0
4504 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4505 (gnus-thread-total-score-1 thread)))
4507 (gnus-thread-total-score-1 (list thread)))))
4509 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4510 "Sort threads such that the thread with the most recently arrived article comes first."
4511 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4513 (defun gnus-thread-highest-number (thread)
4514 "Return the highest article number in THREAD."
4515 (apply 'max (mapcar (lambda (header)
4516 (mail-header-number header))
4517 (message-flatten-list thread))))
4519 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4520 "Sort threads such that the thread with the most recently dated article comes first."
4521 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4523 (defun gnus-thread-latest-date (thread)
4524 "Return the highest article date in THREAD."
4525 (let ((previous-time 0))
4532 (mail-header-parse-date (mail-header-date header))
4533 (error previous-time)))))
4535 (message-flatten-list thread)
4537 (< (mail-header-number h1)
4538 (mail-header-number h2))))))))
4540 (defun gnus-thread-total-score-1 (root)
4541 ;; This function find the total score of the thread below ROOT.
4542 (setq root (car root))
4543 (apply gnus-thread-score-function
4545 (mapcar 'gnus-thread-total-score
4546 (cdr (gnus-id-to-thread (mail-header-id root))))
4547 (when (> (mail-header-number root) 0)
4548 (list (or (cdr (assq (mail-header-number root)
4549 gnus-newsgroup-scored))
4550 gnus-summary-default-score 0))))
4551 (list gnus-summary-default-score)
4554 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4555 (defvar gnus-tmp-prev-subject nil)
4556 (defvar gnus-tmp-false-parent nil)
4557 (defvar gnus-tmp-root-expunged nil)
4558 (defvar gnus-tmp-dummy-line nil)
4560 (eval-when-compile (defvar gnus-tmp-header))
4561 (defun gnus-extra-header (type &optional header)
4562 "Return the extra header of TYPE."
4563 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4566 (defvar gnus-tmp-thread-tree-header-string "")
4568 (defcustom gnus-sum-thread-tree-root "> "
4569 "With %B spec, used for the root of a thread.
4570 If nil, use subject instead."
4572 :group 'gnus-thread)
4573 (defcustom gnus-sum-thread-tree-false-root "> "
4574 "With %B spec, used for a false root of a thread.
4575 If nil, use subject instead."
4577 :group 'gnus-thread)
4578 (defcustom gnus-sum-thread-tree-single-indent ""
4579 "With %B spec, used for a thread with just one message.
4580 If nil, use subject instead."
4582 :group 'gnus-thread)
4583 (defcustom gnus-sum-thread-tree-vertical "| "
4584 "With %B spec, used for drawing a vertical line."
4586 :group 'gnus-thread)
4587 (defcustom gnus-sum-thread-tree-indent " "
4588 "With %B spec, used for indenting."
4590 :group 'gnus-thread)
4591 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4592 "With %B spec, used for a leaf with brothers."
4594 :group 'gnus-thread)
4595 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4596 "With %B spec, used for a leaf without brothers."
4598 :group 'gnus-thread)
4600 (defun gnus-summary-prepare-threads (threads)
4601 "Prepare summary buffer from THREADS and indentation LEVEL.
4602 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4603 or a straight list of headers."
4604 (gnus-message 7 "Generating summary...")
4606 (setq gnus-newsgroup-threads threads)
4609 (let ((gnus-tmp-level 0)
4610 (default-score (or gnus-summary-default-score 0))
4611 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4612 (building-line-count gnus-summary-display-while-building)
4613 (building-count (integerp gnus-summary-display-while-building))
4614 thread number subject stack state gnus-tmp-gathered beg-match
4615 new-roots gnus-tmp-new-adopts thread-end simp-subject
4616 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4617 gnus-tmp-replied gnus-tmp-subject-or-nil
4618 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4619 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4620 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4623 (setq gnus-tmp-prev-subject nil
4624 gnus-tmp-thread-tree-header-string "")
4626 (if (vectorp (car threads))
4627 ;; If this is a straight (sic) list of headers, then a
4628 ;; threaded summary display isn't required, so we just create
4629 ;; an unthreaded one.
4630 (gnus-summary-prepare-unthreaded threads)
4632 ;; Do the threaded display.
4634 (if gnus-summary-display-while-building
4635 (switch-to-buffer (buffer-name)))
4636 (while (or threads stack gnus-tmp-new-adopts new-roots)
4638 (if (and (= gnus-tmp-level 0)
4641 (not gnus-tmp-false-parent)
4642 (or gnus-tmp-new-adopts new-roots))
4643 (if gnus-tmp-new-adopts
4644 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4645 thread (list (car gnus-tmp-new-adopts))
4646 gnus-tmp-header (caar thread)
4647 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4649 (setq thread (list (car new-roots))
4650 gnus-tmp-header (caar thread)
4651 new-roots (cdr new-roots))))
4654 ;; If there are some threads, we do them before the
4655 ;; threads on the stack.
4656 (setq thread threads
4657 gnus-tmp-header (caar thread))
4658 ;; There were no current threads, so we pop something off
4660 (setq state (car stack)
4661 gnus-tmp-level (car state)
4662 tree-stack (cadr state)
4663 thread (caddr state)
4665 gnus-tmp-header (caar thread))))
4667 (setq gnus-tmp-false-parent nil)
4668 (setq gnus-tmp-root-expunged nil)
4669 (setq thread-end nil)
4671 (if (stringp gnus-tmp-header)
4672 ;; The header is a dummy root.
4674 ((eq gnus-summary-make-false-root 'adopt)
4675 ;; We let the first article adopt the rest.
4676 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4678 (setq gnus-tmp-gathered
4680 (lambda (h) (mail-header-number (car h)))
4683 (setq thread (cons (list (caar thread)
4686 (setq gnus-tmp-level -1
4687 gnus-tmp-false-parent t))
4688 ((eq gnus-summary-make-false-root 'empty)
4689 ;; We print adopted articles with empty subject fields.
4690 (setq gnus-tmp-gathered
4692 (lambda (h) (mail-header-number (car h)))
4695 (setq gnus-tmp-level -1))
4696 ((eq gnus-summary-make-false-root 'dummy)
4697 ;; We remember that we probably want to output a dummy
4699 (setq gnus-tmp-dummy-line gnus-tmp-header)
4700 (setq gnus-tmp-prev-subject gnus-tmp-header))
4702 ;; We do not make a root for the gathered
4703 ;; sub-threads at all.
4704 (setq gnus-tmp-level -1)))
4706 (setq number (mail-header-number gnus-tmp-header)
4707 subject (mail-header-subject gnus-tmp-header)
4708 simp-subject (gnus-simplify-subject-fully subject))
4711 ;; If the thread has changed subject, we might want to make
4712 ;; this subthread into a root.
4713 ((and (null gnus-thread-ignore-subject)
4714 (not (zerop gnus-tmp-level))
4715 gnus-tmp-prev-subject
4716 (not (string= gnus-tmp-prev-subject simp-subject)))
4717 (setq new-roots (nconc new-roots (list (car thread)))
4719 gnus-tmp-header nil))
4720 ;; If the article lies outside the current limit,
4721 ;; then we do not display it.
4722 ((not (memq number gnus-newsgroup-limit))
4723 (setq gnus-tmp-gathered
4725 (lambda (h) (mail-header-number (car h)))
4728 (setq gnus-tmp-new-adopts (if (cdar thread)
4729 (append gnus-tmp-new-adopts
4731 gnus-tmp-new-adopts)
4733 gnus-tmp-header nil)
4734 (when (zerop gnus-tmp-level)
4735 (setq gnus-tmp-root-expunged t)))
4736 ;; Perhaps this article is to be marked as read?
4737 ((and gnus-summary-mark-below
4738 (< (or (cdr (assq number gnus-newsgroup-scored))
4740 gnus-summary-mark-below)
4741 ;; Don't touch sparse articles.
4742 (not (gnus-summary-article-sparse-p number))
4743 (not (gnus-summary-article-ancient-p number)))
4744 (setq gnus-newsgroup-unreads
4745 (delq number gnus-newsgroup-unreads))
4746 (if gnus-newsgroup-auto-expire
4747 (setq gnus-newsgroup-expirable
4748 (gnus-add-to-sorted-list
4749 gnus-newsgroup-expirable number))
4750 (push (cons number gnus-low-score-mark)
4751 gnus-newsgroup-reads))))
4753 (when gnus-tmp-header
4754 ;; We may have an old dummy line to output before this
4756 (when (and gnus-tmp-dummy-line
4759 (mail-header-subject gnus-tmp-header)))
4760 (gnus-summary-insert-dummy-line
4761 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4762 (setq gnus-tmp-dummy-line nil))
4764 ;; Compute the mark.
4765 (setq gnus-tmp-unread (gnus-article-mark number))
4767 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4768 gnus-tmp-header gnus-tmp-level)
4769 gnus-newsgroup-data)
4771 ;; Actually insert the line.
4773 gnus-tmp-subject-or-nil
4775 ((and gnus-thread-ignore-subject
4776 gnus-tmp-prev-subject
4777 (not (string= gnus-tmp-prev-subject simp-subject)))
4779 ((zerop gnus-tmp-level)
4780 (if (and (eq gnus-summary-make-false-root 'empty)
4781 (memq number gnus-tmp-gathered)
4782 gnus-tmp-prev-subject
4783 (string= gnus-tmp-prev-subject simp-subject))
4784 gnus-summary-same-subject
4786 (t gnus-summary-same-subject)))
4787 (if (and (eq gnus-summary-make-false-root 'adopt)
4788 (= gnus-tmp-level 1)
4789 (memq number gnus-tmp-gathered))
4790 (setq gnus-tmp-opening-bracket ?\<
4791 gnus-tmp-closing-bracket ?\>)
4792 (setq gnus-tmp-opening-bracket ?\[
4793 gnus-tmp-closing-bracket ?\]))
4795 gnus-tmp-indentation
4796 (aref gnus-thread-indent-array gnus-tmp-level)
4797 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4798 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4799 gnus-summary-default-score 0)
4801 (if (or (null gnus-summary-default-score)
4802 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4803 gnus-summary-zcore-fuzz))
4805 (if (< gnus-tmp-score gnus-summary-default-score)
4806 gnus-score-below-mark gnus-score-over-mark))
4808 (cond ((memq number gnus-newsgroup-processable)
4810 ((memq number gnus-newsgroup-cached)
4812 ((memq number gnus-newsgroup-replied)
4814 ((memq number gnus-newsgroup-forwarded)
4815 gnus-forwarded-mark)
4816 ((memq number gnus-newsgroup-saved)
4818 ((memq number gnus-newsgroup-recent)
4820 ((memq number gnus-newsgroup-unseen)
4824 (cond ((memq number gnus-newsgroup-undownloaded)
4825 gnus-undownloaded-mark)
4826 (gnus-newsgroup-agentized
4827 gnus-downloaded-mark)
4830 gnus-tmp-from (mail-header-from gnus-tmp-header)
4833 ((string-match "<[^>]+> *$" gnus-tmp-from)
4834 (setq beg-match (match-beginning 0))
4835 (or (and (string-match "^\".+\"" gnus-tmp-from)
4836 (substring gnus-tmp-from 1 (1- (match-end 0))))
4837 (substring gnus-tmp-from 0 beg-match)))
4838 ((string-match "(.+)" gnus-tmp-from)
4839 (substring gnus-tmp-from
4840 (1+ (match-beginning 0)) (1- (match-end 0))))
4844 gnus-tmp-thread-tree-header-string
4846 ((not gnus-show-threads) "")
4847 ((zerop gnus-tmp-level)
4848 (cond ((cdar thread)
4849 (or gnus-sum-thread-tree-root subject))
4850 (gnus-tmp-new-adopts
4851 (or gnus-sum-thread-tree-false-root subject))
4853 (or gnus-sum-thread-tree-single-indent subject))))
4855 (concat (apply 'concat
4856 (mapcar (lambda (item)
4858 gnus-sum-thread-tree-vertical
4859 gnus-sum-thread-tree-indent))
4860 (cdr (reverse tree-stack))))
4862 gnus-sum-thread-tree-leaf-with-other
4863 gnus-sum-thread-tree-single-leaf)))))
4864 (when (string= gnus-tmp-name "")
4865 (setq gnus-tmp-name gnus-tmp-from))
4866 (unless (numberp gnus-tmp-lines)
4867 (setq gnus-tmp-lines -1))
4868 (if (= gnus-tmp-lines -1)
4869 (setq gnus-tmp-lines "?")
4870 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4871 (gnus-put-text-property
4873 (progn (eval gnus-summary-line-format-spec) (point))
4874 'gnus-number number)
4877 (gnus-run-hooks 'gnus-summary-update-hook)
4880 (setq gnus-tmp-prev-subject simp-subject)))
4882 (when (nth 1 thread)
4883 (push (list (max 0 gnus-tmp-level)
4884 (copy-sequence tree-stack)
4887 (push (if (nth 1 thread) 1 0) tree-stack)
4888 (incf gnus-tmp-level)
4889 (setq threads (if thread-end nil (cdar thread)))
4890 (if gnus-summary-display-while-building
4893 ;; use a set frequency
4894 (setq building-line-count (1- building-line-count))
4895 (when (= building-line-count 0)
4897 (setq building-line-count
4898 gnus-summary-display-while-building)))
4902 (setq gnus-tmp-level 0)))))
4903 (gnus-message 7 "Generating summary...done"))
4905 (defun gnus-summary-prepare-unthreaded (headers)
4906 "Generate an unthreaded summary buffer based on HEADERS."
4907 (let (header number mark)
4912 ;; We may have to root out some bad articles...
4913 (when (memq (setq number (mail-header-number
4914 (setq header (pop headers))))
4915 gnus-newsgroup-limit)
4916 ;; Mark article as read when it has a low score.
4917 (when (and gnus-summary-mark-below
4918 (< (or (cdr (assq number gnus-newsgroup-scored))
4919 gnus-summary-default-score 0)
4920 gnus-summary-mark-below)
4921 (not (gnus-summary-article-ancient-p number)))
4922 (setq gnus-newsgroup-unreads
4923 (delq number gnus-newsgroup-unreads))
4924 (if gnus-newsgroup-auto-expire
4925 (push number gnus-newsgroup-expirable)
4926 (push (cons number gnus-low-score-mark)
4927 gnus-newsgroup-reads)))
4929 (setq mark (gnus-article-mark number))
4930 (push (gnus-data-make number mark (1+ (point)) header 0)
4931 gnus-newsgroup-data)
4932 (gnus-summary-insert-line
4934 (memq number gnus-newsgroup-undownloaded)
4935 mark (memq number gnus-newsgroup-replied)
4936 (memq number gnus-newsgroup-expirable)
4937 (mail-header-subject header) nil
4938 (cdr (assq number gnus-newsgroup-scored))
4939 (memq number gnus-newsgroup-processable))))))
4941 (defun gnus-summary-remove-list-identifiers ()
4942 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4943 (let ((regexp (if (consp gnus-list-identifiers)
4944 (mapconcat 'identity gnus-list-identifiers " *\\|")
4945 gnus-list-identifiers))
4948 (dolist (header gnus-newsgroup-headers)
4949 (setq subject (mail-header-subject header)
4951 (while (string-match
4952 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4955 (concat (substring subject 0 (match-beginning 2))
4956 (substring subject (match-end 0)))
4960 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4962 (concat (substring subject 0 (match-beginning 1))
4963 (substring subject (match-end 1)))))
4965 (mail-header-set-subject header subject))))))
4967 (defun gnus-fetch-headers (articles)
4968 "Fetch headers of ARTICLES."
4969 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4970 (gnus-message 5 "Fetching headers for %s..." name)
4973 (setq gnus-headers-retrieved-by
4974 (gnus-retrieve-headers
4975 articles gnus-newsgroup-name
4976 ;; We might want to fetch old headers, but
4977 ;; not if there is only 1 article.
4979 (not (eq gnus-fetch-old-headers 'some))
4980 (not (numberp gnus-fetch-old-headers)))
4981 (> (length articles) 1))
4982 gnus-fetch-old-headers))))
4983 (gnus-get-newsgroup-headers-xover
4984 articles nil nil gnus-newsgroup-name t)
4985 (gnus-get-newsgroup-headers))
4986 (gnus-message 5 "Fetching headers for %s...done" name))))
4988 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4989 "Select newsgroup GROUP.
4990 If READ-ALL is non-nil, all articles in the group are selected.
4991 If SELECT-ARTICLES, only select those articles from GROUP."
4992 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4993 ;;!!! Dirty hack; should be removed.
4994 (gnus-summary-ignore-duplicates
4995 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4997 gnus-summary-ignore-duplicates))
4998 (info (nth 2 entry))
4999 articles fetched-articles cached)
5001 (unless (gnus-check-server
5002 (set (make-local-variable 'gnus-current-select-method)
5003 (gnus-find-method-for-group group)))
5004 (error "Couldn't open server"))
5006 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5007 (gnus-activate-group group) ; Or we can activate it...
5008 (progn ; Or we bug out.
5009 (when (equal major-mode 'gnus-summary-mode)
5010 (gnus-kill-buffer (current-buffer)))
5011 (error "Couldn't activate group %s: %s"
5012 group (gnus-status-message group))))
5014 (unless (gnus-request-group group t)
5015 (when (equal major-mode 'gnus-summary-mode)
5016 (gnus-kill-buffer (current-buffer)))
5017 (error "Couldn't request group %s: %s"
5018 group (gnus-status-message group)))
5021 ;; The agent may be storing articles that are no longer in the
5022 ;; server's active range. If that is the case, the active range
5023 ;; needs to be expanded such that the agent's articles can be
5024 ;; included in the summary.
5025 (let* ((gnus-command-method (gnus-find-method-for-group group))
5026 (alist (gnus-agent-load-alist group))
5027 (active (gnus-active group)))
5028 (if (and (car alist)
5029 (< (caar alist) (car active)))
5030 (gnus-set-active group (cons (caar alist) (cdr active)))))
5032 (setq gnus-summary-use-undownloaded-faces
5033 (not (gnus-agent-find-parameter
5035 'agent-disable-undownloaded-faces))))
5037 (setq gnus-newsgroup-name group
5038 gnus-newsgroup-unselected nil
5039 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5041 (let ((display (gnus-group-find-parameter group 'display)))
5042 (setq gnus-newsgroup-display
5044 ((not (zerop (or (car-safe read-all) 0)))
5045 ;; The user entered the group with C-u SPC/RET, let's show
5051 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5053 ;; The following is probably the "correct" solution, but
5054 ;; it makes Gnus fetch all headers and then limit the
5055 ;; articles (which is slow), so instead we hack the
5056 ;; select-articles parameter instead. -- Simon Josefsson
5059 ;; (gnus-byte-compile
5060 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5062 (setq select-articles
5063 (gnus-uncompress-range
5064 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5068 (cdr (gnus-active group)))))
5073 (gnus-summary-setup-default-charset)
5075 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5076 (when (gnus-virtual-group-p group)
5077 (setq cached gnus-newsgroup-cached))
5079 (setq gnus-newsgroup-unreads
5080 (gnus-sorted-ndifference
5081 (gnus-sorted-ndifference gnus-newsgroup-unreads
5082 gnus-newsgroup-marked)
5083 gnus-newsgroup-dormant))
5085 (setq gnus-newsgroup-processable nil)
5087 (gnus-update-read-articles group gnus-newsgroup-unreads)
5089 ;; Adjust and set lists of article marks.
5091 (gnus-adjust-marked-articles info))
5092 (if (setq articles select-articles)
5093 (setq gnus-newsgroup-unselected
5094 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5095 (setq articles (gnus-articles-to-read group read-all)))
5099 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5101 ((eq articles 0) nil)
5103 ;; Init the dependencies hash table.
5104 (setq gnus-newsgroup-dependencies
5105 (gnus-make-hashtable (length articles)))
5106 (gnus-set-global-variables)
5107 ;; Retrieve the headers and read them in.
5109 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5111 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5113 (setq gnus-newsgroup-cached cached))
5115 ;; Suppress duplicates?
5116 (when gnus-suppress-duplicates
5117 (gnus-dup-suppress-articles))
5119 ;; Set the initial limit.
5120 (setq gnus-newsgroup-limit (copy-sequence articles))
5121 ;; Remove canceled articles from the list of unread articles.
5122 (setq fetched-articles
5123 (mapcar (lambda (headers) (mail-header-number headers))
5124 gnus-newsgroup-headers))
5125 (setq gnus-newsgroup-articles fetched-articles)
5126 (setq gnus-newsgroup-unreads
5127 (gnus-sorted-nintersection
5128 gnus-newsgroup-unreads fetched-articles))
5129 (gnus-compute-unseen-list)
5131 ;; Removed marked articles that do not exist.
5132 (gnus-update-missing-marks
5133 (gnus-sorted-difference articles fetched-articles))
5134 ;; We might want to build some more threads first.
5135 (when (and gnus-fetch-old-headers
5136 (eq gnus-headers-retrieved-by 'nov))
5137 (if (eq gnus-fetch-old-headers 'invisible)
5138 (gnus-build-all-threads)
5139 (gnus-build-old-threads)))
5140 ;; Let the Gnus agent mark articles as read.
5142 (gnus-agent-get-undownloaded-list))
5143 ;; Remove list identifiers from subject
5144 (when gnus-list-identifiers
5145 (gnus-summary-remove-list-identifiers))
5146 ;; Check whether auto-expire is to be done in this group.
5147 (setq gnus-newsgroup-auto-expire
5148 (gnus-group-auto-expirable-p group))
5149 ;; Set up the article buffer now, if necessary.
5150 (unless gnus-single-article-buffer
5151 (gnus-article-setup-buffer))
5152 ;; First and last article in this newsgroup.
5153 (when gnus-newsgroup-headers
5154 (setq gnus-newsgroup-begin
5155 (mail-header-number (car gnus-newsgroup-headers))
5158 (gnus-last-element gnus-newsgroup-headers))))
5159 ;; GROUP is successfully selected.
5160 (or gnus-newsgroup-headers t)))))
5162 (defun gnus-compute-unseen-list ()
5163 ;; The `seen' marks are treated specially.
5164 (if (not gnus-newsgroup-seen)
5165 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5166 (setq gnus-newsgroup-unseen
5167 (gnus-inverse-list-range-intersection
5168 gnus-newsgroup-articles gnus-newsgroup-seen))))
5170 (defun gnus-summary-display-make-predicate (display)
5171 (require 'gnus-agent)
5172 (when (= (length display) 1)
5173 (setq display (car display)))
5174 (unless gnus-summary-display-cache
5175 (dolist (elem (append '((unread . unread)
5178 gnus-article-mark-lists))
5179 (push (cons (cdr elem)
5181 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5182 gnus-summary-display-cache)))
5183 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5184 (gnus-category-predicate-cache gnus-summary-display-cache))
5185 (gnus-get-predicate display)))
5187 ;; Uses the dynamically bound `number' variable.
5190 (defun gnus-article-marked-p (type &optional article)
5191 (let ((article (or article number)))
5194 (memq article gnus-newsgroup-marked))
5196 (memq article gnus-newsgroup-spam-marked))
5198 (memq article gnus-newsgroup-unsendable))
5199 ((eq type 'undownload)
5200 (memq article gnus-newsgroup-undownloaded))
5201 ((eq type 'download)
5202 (memq article gnus-newsgroup-downloadable))
5204 (memq article gnus-newsgroup-unreads))
5206 (memq article gnus-newsgroup-reads))
5208 (memq article gnus-newsgroup-dormant) )
5210 (memq article gnus-newsgroup-expirable))
5212 (memq article gnus-newsgroup-replied))
5214 (memq article gnus-newsgroup-killed))
5215 ((eq type 'bookmark)
5216 (assq article gnus-newsgroup-bookmarks))
5218 (assq article gnus-newsgroup-scored))
5220 (memq article gnus-newsgroup-saved))
5222 (memq article gnus-newsgroup-cached))
5224 (memq article gnus-newsgroup-forwarded))
5226 (not (memq article gnus-newsgroup-unseen)))
5228 (memq article gnus-newsgroup-recent))
5231 (defun gnus-articles-to-read (group &optional read-all)
5232 "Find out what articles the user wants to read."
5233 (let* ((display (gnus-group-find-parameter group 'display))
5235 ;; Select all articles if `read-all' is non-nil, or if there
5236 ;; are no unread articles.
5238 (and (zerop (length gnus-newsgroup-marked))
5239 (zerop (length gnus-newsgroup-unreads)))
5240 ;; Fetch all if the predicate is non-nil.
5241 gnus-newsgroup-display)
5242 ;; We want to select the headers for all the articles in
5243 ;; the group, so we select either all the active
5244 ;; articles in the group, or (if that's nil), the
5245 ;; articles in the cache.
5247 (gnus-uncompress-range (gnus-active group))
5248 (gnus-cache-articles-in-group group))
5249 ;; Select only the "normal" subset of articles.
5251 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5252 gnus-newsgroup-unreads)))
5253 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5254 (scored (length scored-list))
5255 (number (length articles))
5256 (marked (+ (length gnus-newsgroup-marked)
5257 (length gnus-newsgroup-dormant)))
5262 ((numberp gnus-newsgroup-display)
5263 gnus-newsgroup-display)
5267 ((and (or (<= scored marked) (= scored number))
5268 (numberp gnus-large-newsgroup)
5269 (> number gnus-large-newsgroup))
5270 (let* ((cursor-in-echo-area nil)
5271 (initial (gnus-parameter-large-newsgroup-initial
5272 gnus-newsgroup-name))
5276 "How many articles from %s (%s %d): "
5278 (gnus-group-decoded-name gnus-newsgroup-name)
5280 (if initial "max" "default")
5283 (cons (number-to-string initial)
5285 (if (string-match "^[ \t]*$" input) number input)))
5286 ((and (> scored marked) (< scored number)
5287 (> (- scored number) 20))
5290 (format "%s %s (%d scored, %d total): "
5291 "How many articles from"
5292 (gnus-group-decoded-name group)
5294 (if (string-match "^[ \t]*$" input)
5298 (message "Quit getting the articles to read")
5300 (setq select (if (stringp select) (string-to-number select) select))
5301 (if (or (null select) (zerop select))
5303 (if (and (not (zerop scored)) (<= (abs select) scored))
5305 (setq articles (sort scored-list '<))
5306 (setq number (length articles)))
5307 (setq articles (copy-sequence articles)))
5309 (when (< (abs select) number)
5311 ;; Select the N oldest articles.
5312 (setcdr (nthcdr (1- (abs select)) articles) nil)
5313 ;; Select the N most recent articles.
5314 (setq articles (nthcdr (- number select) articles))))
5315 (setq gnus-newsgroup-unselected
5316 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5317 (when gnus-alter-articles-to-read-function
5320 (funcall gnus-alter-articles-to-read-function
5321 gnus-newsgroup-name articles)
5325 (defun gnus-killed-articles (killed articles)
5328 (when (inline (gnus-member-of-range (car articles) killed))
5329 (push (car articles) out))
5330 (setq articles (cdr articles)))
5333 (defun gnus-uncompress-marks (marks)
5334 "Uncompress the mark ranges in MARKS."
5335 (let ((uncompressed '(score bookmark))
5338 (if (memq (caar marks) uncompressed)
5339 (push (car marks) out)
5340 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5341 (setq marks (cdr marks)))
5344 (defun gnus-article-mark-to-type (mark)
5345 "Return the type of MARK."
5346 (or (cadr (assq mark gnus-article-special-mark-lists))
5349 (defun gnus-article-unpropagatable-p (mark)
5350 "Return whether MARK should be propagated to backend."
5351 (memq mark gnus-article-unpropagated-mark-lists))
5353 (defun gnus-adjust-marked-articles (info)
5354 "Set all article lists and remove all marks that are no longer valid."
5355 (let* ((marked-lists (gnus-info-marks info))
5356 (active (gnus-active (gnus-info-group info)))
5359 (types gnus-article-mark-lists)
5360 marks var articles article mark mark-type)
5362 (dolist (marks marked-lists)
5363 (setq mark (car marks)
5364 mark-type (gnus-article-mark-to-type mark)
5365 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5367 ;; We set the variable according to the type of the marks list,
5368 ;; and then adjust the marks to a subset of the active articles.
5370 ;; Adjust "simple" lists.
5371 ((eq mark-type 'list)
5372 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5373 (when (memq mark '(tick dormant expire reply save))
5375 (when (or (< (setq article (pop articles)) min) (> article max))
5376 (set var (delq article (symbol-value var)))))))
5378 ((eq mark-type 'tuple)
5379 (set var (setq articles (cdr marks)))
5380 (when (not (listp (cdr (symbol-value var))))
5381 (set var (list (symbol-value var))))
5382 (when (not (listp (cdr articles)))
5383 (setq articles (list articles)))
5385 (when (or (not (consp (setq article (pop articles))))
5386 (< (car article) min)
5387 (> (car article) max))
5388 (set var (delq article (symbol-value var))))))
5389 ;; Adjust ranges (sloppily).
5390 ((eq mark-type 'range)
5393 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5394 ;; It should be (seen (NUM1 . NUM2)).
5395 (when (numberp (cddr marks))
5396 (setcdr marks (list (cdr marks))))
5397 (setq articles (cdr marks))
5398 (while (and articles
5399 (or (and (consp (car articles))
5400 (> min (cdar articles)))
5401 (and (numberp (car articles))
5402 (> min (car articles)))))
5404 (set var articles))))))))
5406 (defun gnus-update-missing-marks (missing)
5407 "Go through the list of MISSING articles and remove them from the mark lists."
5410 ;; Go through all types.
5411 (dolist (elem gnus-article-mark-lists)
5412 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5413 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5414 (when (symbol-value var)
5415 ;; This list has articles. So we delete all missing
5416 ;; articles from it.
5419 (set var (delq (pop m) (symbol-value var))))))))))
5421 (defun gnus-update-marks ()
5422 "Enter the various lists of marked articles into the newsgroup info list."
5423 (let ((types gnus-article-mark-lists)
5424 (info (gnus-get-info gnus-newsgroup-name))
5425 type list newmarked symbol delta-marks)
5427 ;; Add all marks lists to the list of marks lists.
5428 (while (setq type (pop types))
5429 (setq list (symbol-value
5431 (intern (format "gnus-newsgroup-%s" (car type))))))
5434 ;; Get rid of the entries of the articles that have the
5436 (when (and (eq (cdr type) 'score)
5440 (prev (cons nil list))
5443 (if (or (not (consp (car arts)))
5444 (= (cdar arts) gnus-summary-default-score))
5445 (setcdr prev (cdr arts))
5447 (setq arts (cdr arts)))
5448 (setq list (cdr all)))))
5450 (when (eq (cdr type) 'seen)
5451 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5453 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5454 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5456 (when (and (gnus-check-backend-function
5457 'request-set-mark gnus-newsgroup-name)
5458 (not (gnus-article-unpropagatable-p (cdr type))))
5459 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5460 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5461 (add (gnus-remove-from-range
5462 (gnus-copy-sequence list) old)))
5464 (push (list add 'add (list (cdr type))) delta-marks))
5466 (push (list del 'del (list (cdr type))) delta-marks))))
5469 (push (cons (cdr type) list) newmarked)))
5472 (unless (gnus-check-group gnus-newsgroup-name)
5473 (error "Can't open server for %s" gnus-newsgroup-name))
5474 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5476 ;; Enter these new marks into the info of the group.
5478 (setcar (nthcdr 3 info) newmarked)
5479 ;; Add the marks lists to the end of the info.
5481 (setcdr (nthcdr 2 info) (list newmarked))))
5483 ;; Cut off the end of the info if there's nothing else there.
5487 (when (nthcdr (decf i) info)
5488 (setcdr (nthcdr i info) nil)))))))
5490 (defun gnus-set-mode-line (where)
5491 "Set the mode line of the article or summary buffers.
5492 If WHERE is `summary', the summary mode line format will be used."
5493 ;; Is this mode line one we keep updated?
5494 (when (and (memq where gnus-updated-mode-lines)
5496 (intern (format "gnus-%s-mode-line-format-spec" where))))
5499 ;; We evaluate this in the summary buffer since these
5500 ;; variables are buffer-local to that buffer.
5501 (set-buffer gnus-summary-buffer)
5502 ;; We bind all these variables that are used in the `eval' form
5504 (let* ((mformat (symbol-value
5506 (format "gnus-%s-mode-line-format-spec" where))))
5507 (gnus-tmp-group-name (gnus-group-decoded-name
5508 gnus-newsgroup-name))
5509 (gnus-tmp-article-number (or gnus-current-article 0))
5510 (gnus-tmp-unread gnus-newsgroup-unreads)
5511 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5512 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5513 (gnus-tmp-unread-and-unselected
5514 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5515 (zerop gnus-tmp-unselected))
5517 ((zerop gnus-tmp-unselected)
5518 (format "{%d more}" gnus-tmp-unread-and-unticked))
5519 (t (format "{%d(+%d) more}"
5520 gnus-tmp-unread-and-unticked
5521 gnus-tmp-unselected))))
5523 (if (and gnus-current-headers
5524 (vectorp gnus-current-headers))
5525 (gnus-mode-string-quote
5526 (mail-header-subject gnus-current-headers))
5528 bufname-length max-len
5529 gnus-tmp-header);; passed as argument to any user-format-funcs
5530 (setq mode-string (eval mformat))
5531 (setq bufname-length (if (string-match "%b" mode-string)
5534 (if (eq where 'summary)
5536 (get-buffer gnus-article-buffer))))
5539 (setq max-len (max 4 (if gnus-mode-non-string-length
5541 gnus-mode-non-string-length
5543 (length mode-string))))
5544 ;; We might have to chop a bit of the string off...
5545 (when (> (length mode-string) max-len)
5547 (concat (gnus-truncate-string mode-string (- max-len 3))
5549 ;; Pad the mode string a bit.
5550 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5551 ;; Update the mode line.
5552 (setq mode-line-buffer-identification
5553 (gnus-mode-line-buffer-identification (list mode-string)))
5554 (set-buffer-modified-p t))))
5556 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5557 "Go through the HEADERS list and add all Xrefs to a hash table.
5558 The resulting hash table is returned, or nil if no Xrefs were found."
5559 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5560 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5561 (xref-hashtb (gnus-make-hashtable))
5562 start group entry number xrefs header)
5564 (setq header (pop headers))
5565 (when (and (setq xrefs (mail-header-xref header))
5566 (not (memq (setq number (mail-header-number header))
5569 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5570 (setq start (match-end 0))
5571 (setq group (if prefix
5572 (concat prefix (substring xrefs (match-beginning 1)
5574 (substring xrefs (match-beginning 1) (match-end 1))))
5576 (string-to-int (substring xrefs (match-beginning 2)
5578 (if (setq entry (gnus-gethash group xref-hashtb))
5579 (setcdr entry (cons number (cdr entry)))
5580 (gnus-sethash group (cons number nil) xref-hashtb)))))
5581 (and start xref-hashtb)))
5583 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5584 "Look through all the headers and mark the Xrefs as read."
5585 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5586 name entry info xref-hashtb idlist method nth4)
5588 (set-buffer gnus-group-buffer)
5589 (when (setq xref-hashtb
5590 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5593 (unless (string= from-newsgroup (setq name (symbol-name group)))
5594 (setq idlist (symbol-value group))
5595 ;; Dead groups are not updated.
5597 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5599 (when (stringp (setq nth4 (gnus-info-method info)))
5600 (setq nth4 (gnus-server-to-method nth4))))
5601 ;; Only do the xrefs if the group has the same
5602 ;; select method as the group we have just read.
5603 (or (gnus-methods-equal-p
5604 nth4 (gnus-find-method-for-group from-newsgroup))
5606 (equal nth4 (setq method (gnus-find-method-for-group
5608 (and (equal (car nth4) (car method))
5609 (equal (nth 1 nth4) (nth 1 method))))
5610 gnus-use-cross-reference
5611 (or (not (eq gnus-use-cross-reference t))
5613 ;; Only do cross-references on subscribed
5614 ;; groups, if that is what is wanted.
5615 (<= (gnus-info-level info) gnus-level-subscribed))
5616 (gnus-group-make-articles-read name idlist))))
5619 (defun gnus-compute-read-articles (group articles)
5620 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5621 (info (nth 2 entry))
5622 (active (gnus-active group))
5625 ;; First peel off all invalid article numbers.
5627 (let ((ids articles)
5629 (while (setq id (pop ids))
5630 (when (and first (> id (cdr active)))
5631 ;; We'll end up in this situation in one particular
5632 ;; obscure situation. If you re-scan a group and get
5633 ;; a new article that is cross-posted to a different
5634 ;; group that has not been re-scanned, you might get
5635 ;; crossposted article that has a higher number than
5636 ;; Gnus believes possible. So we re-activate this
5637 ;; group as well. This might mean doing the
5638 ;; crossposting thingy will *increase* the number
5639 ;; of articles in some groups. Tsk, tsk.
5640 (setq active (or (gnus-activate-group group) active)))
5641 (when (or (> id (cdr active))
5642 (< id (car active)))
5643 (setq articles (delq id articles))))))
5644 ;; If the read list is nil, we init it.
5646 (null (gnus-info-read info))
5648 (setq ninfo (cons 1 (1- (car active))))
5649 (setq ninfo (gnus-info-read info)))
5650 ;; Then we add the read articles to the range.
5652 ninfo (setq articles (sort articles '<))))))
5654 (defun gnus-group-make-articles-read (group articles)
5655 "Update the info of GROUP to say that ARTICLES are read."
5657 (entry (gnus-gethash group gnus-newsrc-hashtb))
5658 (info (nth 2 entry))
5659 (active (gnus-active group))
5662 (setq range (gnus-compute-read-articles group articles))
5664 (set-buffer gnus-group-buffer)
5667 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5668 (gnus-info-set-read ',info ',(gnus-info-read info))
5669 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5670 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5671 (gnus-group-update-group ,group t))))
5672 ;; Add the read articles to the range.
5673 (gnus-info-set-read info range)
5674 (gnus-request-set-mark group (list (list range 'add '(read))))
5675 ;; Then we have to re-compute how many unread
5676 ;; articles there are in this group.
5680 (setq num (- (1+ (cdr active)) (car active))))
5681 ((not (listp (cdr range)))
5682 (setq num (- (cdr active) (- (1+ (cdr range))
5686 (if (numberp (car range))
5688 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5689 (setq range (cdr range)))
5690 (setq num (- (cdr active) num))))
5691 ;; Update the number of unread articles.
5693 ;; Update the group buffer.
5694 (unless (gnus-ephemeral-group-p group)
5695 (gnus-group-update-group group t))))))
5697 (defvar gnus-newsgroup-none-id 0)
5699 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5700 (let ((cur nntp-server-buffer)
5703 (save-excursion (set-buffer gnus-summary-buffer)
5704 gnus-newsgroup-dependencies)))
5706 (mail-parse-charset gnus-newsgroup-charset)
5707 (mail-parse-ignored-charsets
5708 (save-excursion (condition-case nil
5709 (set-buffer gnus-summary-buffer)
5711 gnus-newsgroup-ignored-charsets)))
5713 (set-buffer nntp-server-buffer)
5714 ;; Translate all TAB characters into SPACE characters.
5715 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5716 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5717 (ietf-drums-unfold-fws)
5718 (gnus-run-hooks 'gnus-parse-headers-hook)
5719 (let ((case-fold-search t)
5720 in-reply-to header p lines chars ctype)
5721 (goto-char (point-min))
5722 ;; Search to the beginning of the next header. Error messages
5723 ;; do not begin with 2 or 3.
5724 (while (re-search-forward "^[23][0-9]+ " nil t)
5727 ;; This implementation of this function, with nine
5728 ;; search-forwards instead of the one re-search-forward and
5729 ;; a case (which basically was the old function) is actually
5730 ;; about twice as fast, even though it looks messier. You
5731 ;; can't have everything, I guess. Speed and elegance
5732 ;; doesn't always go hand in hand.
5735 (make-full-mail-header
5741 (narrow-to-region (point)
5742 (or (and (search-forward "\n.\n" nil t)
5748 (if (search-forward "\nsubject:" nil t)
5749 (nnheader-header-value)
5754 (if (search-forward "\nfrom:" nil t)
5755 (nnheader-header-value)
5760 (if (search-forward "\ndate:" nil t)
5761 (nnheader-header-value) ""))
5765 (setq id (if (re-search-forward
5766 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5767 ;; We do it this way to make sure the Message-ID
5768 ;; is (somewhat) syntactically valid.
5769 (buffer-substring (match-beginning 1)
5771 ;; If there was no message-id, we just fake one
5772 ;; to make subsequent routines simpler.
5773 (nnheader-generate-fake-message-id))))
5777 (if (search-forward "\nreferences:" nil t)
5781 (nnheader-header-value)
5786 (search-backward ">" end t)
5789 (search-backward "<" end t)
5791 ;; Get the references from the in-reply-to header if there
5792 ;; were no references and the in-reply-to header looks
5794 (if (and (search-forward "\nin-reply-to:" nil t)
5795 (setq in-reply-to (nnheader-header-value))
5796 (string-match "<[^>]+>" in-reply-to))
5798 (setq ref (substring in-reply-to (match-beginning 0)
5800 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5801 (setq ref2 (substring in-reply-to (match-beginning 0)
5803 (when (> (length ref2) (length ref))
5810 (if (search-forward "\nchars: " nil t)
5811 (if (numberp (setq chars (ignore-errors (read cur))))
5817 (if (search-forward "\nlines: " nil t)
5818 (if (numberp (setq lines (ignore-errors (read cur))))
5824 (and (search-forward "\nxref:" nil t)
5825 (nnheader-header-value)))
5827 (when gnus-extra-headers
5828 (let ((extra gnus-extra-headers)
5832 (when (search-forward
5833 (concat "\n" (symbol-name (car extra)) ":") nil t)
5834 (push (cons (car extra) (nnheader-header-value)) out))
5838 (if (and (search-forward "\ncontent-type: " nil t)
5839 (setq ctype (nnheader-header-value)))
5840 (mime-entity-set-content-type-internal
5841 header (mime-parse-Content-Type ctype)))
5842 (when (equal id ref)
5845 (when gnus-alter-header-function
5846 (funcall gnus-alter-header-function header)
5847 (setq id (mail-header-id header)
5848 ref (gnus-parent-id (mail-header-references header))))
5851 (gnus-dependencies-add-header
5852 header dependencies force-new))
5853 (push header headers))
5854 (goto-char (point-max))
5856 (nreverse headers)))))
5858 ;; Goes through the xover lines and returns a list of vectors
5859 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5860 force-new dependencies
5861 group also-fetch-heads)
5862 "Parse the news overview data in the server buffer.
5863 Return a list of headers that match SEQUENCE (see
5864 `nntp-retrieve-headers')."
5865 ;; Get the Xref when the users reads the articles since most/some
5866 ;; NNTP servers do not include Xrefs when using XOVER.
5867 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5868 (let ((mail-parse-charset gnus-newsgroup-charset)
5869 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5870 (cur nntp-server-buffer)
5871 (dependencies (or dependencies gnus-newsgroup-dependencies))
5873 ((eq gnus-read-all-available-headers t)
5875 ((stringp gnus-read-all-available-headers)
5876 (string-match gnus-read-all-available-headers group))
5879 number headers header)
5881 (set-buffer nntp-server-buffer)
5882 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5883 ;; Allow the user to mangle the headers before parsing them.
5884 (gnus-run-hooks 'gnus-parse-headers-hook)
5885 (goto-char (point-min))
5886 (gnus-parse-without-error
5887 (while (and (or sequence allp)
5889 (setq number (read cur))
5891 (while (and sequence
5892 (< (car sequence) number))
5893 (setq sequence (cdr sequence))))
5896 (eq number (car sequence))))
5898 (setq sequence (cdr sequence))
5899 (setq header (inline
5900 (gnus-nov-parse-line
5901 number dependencies force-new)))))
5902 (push header headers))
5904 ;; A common bug in inn is that if you have posted an article and
5905 ;; then retrieves the active file, it will answer correctly --
5906 ;; the new article is included. However, a NOV entry for the
5907 ;; article may not have been generated yet, so this may fail.
5908 ;; We work around this problem by retrieving the last few
5909 ;; headers using HEAD.
5910 (if (or (not also-fetch-heads)
5912 ;; We (probably) got all the headers.
5914 (let ((gnus-nov-is-evil t))
5917 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5918 (gnus-get-newsgroup-headers))))))))
5920 (defun gnus-article-get-xrefs ()
5921 "Fill in the Xref value in `gnus-current-headers', if necessary.
5922 This is meant to be called in `gnus-article-internal-prepare-hook'."
5923 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5924 gnus-current-headers)))
5925 (or (not gnus-use-cross-reference)
5927 (and (mail-header-xref headers)
5928 (not (string= (mail-header-xref headers) "")))
5929 (let ((case-fold-search t)
5932 (nnheader-narrow-to-headers)
5933 (goto-char (point-min))
5934 (when (or (and (not (eobp))
5935 (eq (downcase (char-after)) ?x)
5936 (looking-at "Xref:"))
5937 (search-forward "\nXref:" nil t))
5938 (goto-char (1+ (match-end 0)))
5939 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
5940 (mail-header-set-xref headers xref)))))))
5942 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5943 "Find article ID and insert the summary line for that article.
5944 OLD-HEADER can either be a header or a line number to insert
5945 the subject line on."
5946 (let* ((line (and (numberp old-header) old-header))
5947 (old-header (and (vectorp old-header) old-header))
5948 (header (cond ((and old-header use-old-header)
5951 (gnus-number-to-header id))
5952 (gnus-number-to-header id))
5954 (gnus-read-header id))))
5955 (number (and (numberp id) id))
5958 ;; Rebuild the thread that this article is part of and go to the
5959 ;; article we have fetched.
5960 (when (and (not gnus-show-threads)
5963 (setq d (gnus-data-find (mail-header-number old-header))))
5964 (goto-char (gnus-data-pos d))
5967 (- (gnus-point-at-bol)
5969 (1+ (gnus-point-at-eol))
5970 (gnus-delete-line))))))
5972 (mail-header-set-number header (mail-header-number old-header)))
5973 (setq gnus-newsgroup-sparse
5974 (delq (setq number (mail-header-number header))
5975 gnus-newsgroup-sparse))
5976 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5977 (push number gnus-newsgroup-limit)
5978 (gnus-rebuild-thread (mail-header-id header) line)
5979 (gnus-summary-goto-subject number nil t))
5980 (when (and (numberp number)
5982 ;; We have to update the boundaries even if we can't fetch the
5983 ;; article if ID is a number -- so that the next `P' or `N'
5984 ;; command will fetch the previous (or next) article even
5985 ;; if the one we tried to fetch this time has been canceled.
5986 (when (> number gnus-newsgroup-end)
5987 (setq gnus-newsgroup-end number))
5988 (when (< number gnus-newsgroup-begin)
5989 (setq gnus-newsgroup-begin number))
5990 (setq gnus-newsgroup-unselected
5991 (delq number gnus-newsgroup-unselected)))
5992 ;; Report back a success?
5993 (and header (mail-header-number header))))
5995 ;;; Process/prefix in the summary buffer
5997 (defun gnus-summary-work-articles (n)
5998 "Return a list of articles to be worked upon.
5999 The prefix argument, the list of process marked articles, and the
6000 current article will be taken into consideration."
6002 (set-buffer gnus-summary-buffer)
6005 ;; A numerical prefix has been given.
6006 (setq n (prefix-numeric-value n))
6007 (let ((backward (< n 0))
6008 (n (abs (prefix-numeric-value n)))
6013 (push (setq article (gnus-summary-article-number))
6016 (gnus-summary-find-prev nil article)
6017 (gnus-summary-find-next nil article)))
6019 (nreverse articles)))
6020 ((and (gnus-region-active-p) (mark))
6021 (message "region active")
6022 ;; Work on the region between point and mark.
6023 (let ((max (max (point) (mark)))
6026 (goto-char (min (point) (mark)))
6029 (push (setq article (gnus-summary-article-number)) articles)
6030 (gnus-summary-find-next nil article)
6032 (nreverse articles))))
6033 (gnus-newsgroup-processable
6034 ;; There are process-marked articles present.
6035 ;; Save current state.
6036 (gnus-summary-save-process-mark)
6038 (reverse gnus-newsgroup-processable))
6040 ;; Just return the current article.
6041 (list (gnus-summary-article-number))))))
6043 (defmacro gnus-summary-iterate (arg &rest forms)
6044 "Iterate over the process/prefixed articles and do FORMS.
6045 ARG is the interactive prefix given to the command. FORMS will be
6046 executed with point over the summary line of the articles."
6047 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6048 `(let ((,articles (gnus-summary-work-articles ,arg)))
6050 (gnus-summary-goto-subject (car ,articles))
6054 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6055 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6057 (defun gnus-summary-save-process-mark ()
6058 "Push the current set of process marked articles on the stack."
6060 (push (copy-sequence gnus-newsgroup-processable)
6061 gnus-newsgroup-process-stack))
6063 (defun gnus-summary-kill-process-mark ()
6064 "Push the current set of process marked articles on the stack and unmark."
6066 (gnus-summary-save-process-mark)
6067 (gnus-summary-unmark-all-processable))
6069 (defun gnus-summary-yank-process-mark ()
6070 "Pop the last process mark state off the stack and restore it."
6072 (unless gnus-newsgroup-process-stack
6073 (error "Empty mark stack"))
6074 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6076 (defun gnus-summary-process-mark-set (set)
6077 "Make SET into the current process marked articles."
6078 (gnus-summary-unmark-all-processable)
6080 (gnus-summary-set-process-mark (pop set))))
6082 ;;; Searching and stuff
6084 (defun gnus-summary-search-group (&optional backward use-level)
6085 "Search for next unread newsgroup.
6086 If optional argument BACKWARD is non-nil, search backward instead."
6088 (set-buffer gnus-group-buffer)
6089 (when (gnus-group-search-forward
6090 backward nil (if use-level (gnus-group-group-level) nil))
6091 (gnus-group-group-name))))
6093 (defun gnus-summary-best-group (&optional exclude-group)
6094 "Find the name of the best unread group.
6095 If EXCLUDE-GROUP, do not go to this group."
6097 (set-buffer gnus-group-buffer)
6099 (gnus-group-best-unread-group exclude-group))))
6101 (defun gnus-summary-find-next (&optional unread article backward)
6103 (gnus-summary-find-prev unread article)
6104 (let* ((dummy (gnus-summary-article-intangible-p))
6105 (article (or article (gnus-summary-article-number)))
6106 (data (gnus-data-find-list article))
6108 (when (and (not dummy)
6109 (or (not gnus-summary-check-current)
6111 (not (gnus-data-unread-p (car data)))))
6112 (setq data (cdr data)))
6117 (unless (memq (gnus-data-number (car data))
6119 ((eq gnus-auto-goto-ignores
6120 'always-undownloaded)
6121 gnus-newsgroup-undownloaded)
6124 ((eq gnus-auto-goto-ignores
6126 gnus-newsgroup-unfetched)
6127 ((eq gnus-auto-goto-ignores
6129 gnus-newsgroup-undownloaded)))
6130 (when (gnus-data-unread-p (car data))
6131 (setq result (car data)
6133 (setq data (cdr data)))
6136 (goto-char (gnus-data-pos result))
6137 (gnus-data-number result)))))
6139 (defun gnus-summary-find-prev (&optional unread article)
6140 (let* ((eobp (eobp))
6141 (article (or article (gnus-summary-article-number)))
6142 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6144 (when (and (not eobp)
6145 (or (not gnus-summary-check-current)
6147 (not (gnus-data-unread-p (car data)))))
6148 (setq data (cdr data)))
6153 (unless (memq (gnus-data-number (car data))
6155 ((eq gnus-auto-goto-ignores
6156 'always-undownloaded)
6157 gnus-newsgroup-undownloaded)
6160 ((eq gnus-auto-goto-ignores
6162 gnus-newsgroup-unfetched)
6163 ((eq gnus-auto-goto-ignores
6165 gnus-newsgroup-undownloaded)))
6166 (when (gnus-data-unread-p (car data))
6167 (setq result (car data)
6169 (setq data (cdr data)))
6172 (goto-char (gnus-data-pos result))
6173 (gnus-data-number result))))
6175 (defun gnus-summary-find-subject (subject &optional unread backward article)
6176 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6177 (article (or article (gnus-summary-article-number)))
6178 (articles (gnus-data-list backward))
6179 (arts (gnus-data-find-list article articles))
6181 (when (or (not gnus-summary-check-current)
6183 (not (gnus-data-unread-p (car arts))))
6184 (setq arts (cdr arts)))
6186 (and (or (not unread)
6187 (gnus-data-unread-p (car arts)))
6188 (vectorp (gnus-data-header (car arts)))
6190 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6191 (setq result (car arts)
6193 (setq arts (cdr arts)))
6195 (goto-char (gnus-data-pos result))
6196 (gnus-data-number result))))
6198 (defun gnus-summary-search-forward (&optional unread subject backward)
6199 "Search forward for an article.
6200 If UNREAD, look for unread articles. If SUBJECT, look for
6201 articles with that subject. If BACKWARD, search backward instead."
6202 (cond (subject (gnus-summary-find-subject subject unread backward))
6203 (backward (gnus-summary-find-prev unread))
6204 (t (gnus-summary-find-next unread))))
6206 (defun gnus-recenter (&optional n)
6207 "Center point in window and redisplay frame.
6208 Also do horizontal recentering."
6210 (when (and gnus-auto-center-summary
6211 (not (eq gnus-auto-center-summary 'vertical)))
6212 (gnus-horizontal-recenter))
6215 (defun gnus-summary-recenter ()
6216 "Center point in the summary window.
6217 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6218 displayed, no centering will be performed."
6219 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6220 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6222 ;; The user has to want it.
6223 (when gnus-auto-center-summary
6224 (let* ((top (cond ((< (window-height) 4) 0)
6225 ((< (window-height) 7) 1)
6226 (t (if (numberp gnus-auto-center-summary)
6227 gnus-auto-center-summary
6229 (height (1- (window-height)))
6230 (bottom (save-excursion (goto-char (point-max))
6231 (forward-line (- height))
6233 (window (get-buffer-window (current-buffer))))
6234 (when (get-buffer-window gnus-article-buffer)
6235 ;; Only do recentering when the article buffer is displayed,
6236 ;; Set the window start to either `bottom', which is the biggest
6237 ;; possible valid number, or the second line from the top,
6238 ;; whichever is the least.
6239 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6240 (if (> bottom top-pos)
6241 ;; Keep the second line from the top visible
6242 (set-window-start window top-pos t)
6243 ;; Try to keep the bottom line visible; if it's partially
6244 ;; obscured, either scroll one more line to make it fully
6245 ;; visible, or revert to using TOP-POS.
6247 (goto-char (point-max))
6249 (let ((last-line-start (point)))
6251 (set-window-start window (point) t)
6252 (when (not (pos-visible-in-window-p last-line-start window))
6254 (set-window-start window (min (point) top-pos) t)))))))
6255 ;; Do horizontal recentering while we're at it.
6256 (when (and (get-buffer-window (current-buffer) t)
6257 (not (eq gnus-auto-center-summary 'vertical)))
6258 (let ((selected (selected-window)))
6259 (select-window (get-buffer-window (current-buffer) t))
6260 (gnus-summary-position-point)
6261 (gnus-horizontal-recenter)
6262 (select-window selected))))))
6264 (defun gnus-summary-jump-to-group (newsgroup)
6265 "Move point to NEWSGROUP in group mode buffer."
6266 ;; Keep update point of group mode buffer if visible.
6267 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6268 (save-window-excursion
6269 ;; Take care of tree window mode.
6270 (when (get-buffer-window gnus-group-buffer)
6271 (pop-to-buffer gnus-group-buffer))
6272 (gnus-group-jump-to-group newsgroup))
6274 ;; Take care of tree window mode.
6275 (if (get-buffer-window gnus-group-buffer)
6276 (pop-to-buffer gnus-group-buffer)
6277 (set-buffer gnus-group-buffer))
6278 (gnus-group-jump-to-group newsgroup))))
6280 ;; This function returns a list of article numbers based on the
6281 ;; difference between the ranges of read articles in this group and
6282 ;; the range of active articles.
6283 (defun gnus-list-of-unread-articles (group)
6284 (let* ((read (gnus-info-read (gnus-get-info group)))
6285 (active (or (gnus-active group) (gnus-activate-group group)))
6288 ;; If none are read, then all are unread.
6290 (setq first (car active))
6291 ;; If the range of read articles is a single range, then the
6292 ;; first unread article is the article after the last read
6293 ;; article. Sounds logical, doesn't it?
6294 (if (and (not (listp (cdr read)))
6295 (or (< (car read) (car active))
6296 (progn (setq read (list read))
6298 (setq first (max (car active) (1+ (cdr read))))
6299 ;; `read' is a list of ranges.
6300 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6303 (setq first (car active)))
6306 (while (< first nlast)
6308 (setq first (1+ first))))
6309 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6310 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6311 (setq read (cdr read)))))
6312 ;; And add the last unread articles.
6313 (while (<= first last)
6315 (setq first (1+ first)))
6316 ;; Return the list of unread articles.
6317 (delq 0 (nreverse unread))))
6319 (defun gnus-list-of-read-articles (group)
6320 "Return a list of unread, unticked and non-dormant articles."
6321 (let* ((info (gnus-get-info group))
6322 (marked (gnus-info-marks info))
6323 (active (gnus-active group)))
6325 (gnus-list-range-difference
6326 (gnus-list-range-difference
6327 (gnus-sorted-complement
6328 (gnus-uncompress-range active)
6329 (gnus-list-of-unread-articles group))
6330 (cdr (assq 'dormant marked)))
6331 (cdr (assq 'tick marked))))))
6333 ;; Various summary commands
6335 (defun gnus-summary-select-article-buffer ()
6336 "Reconfigure windows to show article buffer."
6338 (if (not (gnus-buffer-live-p gnus-article-buffer))
6339 (error "There is no article buffer for this summary buffer")
6340 (gnus-configure-windows 'article)
6341 (select-window (get-buffer-window gnus-article-buffer))))
6343 (defun gnus-summary-universal-argument (arg)
6344 "Perform any operation on all articles that are process/prefixed."
6346 (let ((articles (gnus-summary-work-articles arg))
6353 (substitute-command-keys
6354 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6356 (gnus-error 1 "Undefined key")
6359 (gnus-summary-goto-subject (setq article (pop articles)))
6360 (let (gnus-newsgroup-processable)
6361 (command-execute func))
6362 (gnus-summary-remove-process-mark article)))))
6363 (gnus-summary-position-point))
6365 (defun gnus-summary-toggle-truncation (&optional arg)
6366 "Toggle truncation of summary lines.
6367 With arg, turn line truncation on if arg is positive."
6369 (setq truncate-lines
6370 (if (null arg) (not truncate-lines)
6371 (> (prefix-numeric-value arg) 0)))
6374 (defun gnus-summary-find-for-reselect ()
6375 "Return the number of an article to stay on across a reselect.
6376 The current article is considered, then following articles, then previous
6377 articles. An article is sought which is not cancelled and isn't a temporary
6378 insertion from another group. If there's no such then return a dummy 0."
6380 (dolist (rev '(nil t))
6381 (unless found ; don't demand the reverse list if we don't need it
6382 (let ((data (gnus-data-find-list
6383 (gnus-summary-article-number) (gnus-data-list rev))))
6384 (while (and data (not found))
6385 (if (and (< 0 (gnus-data-number (car data)))
6386 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6387 (setq found (gnus-data-number (car data))))
6388 (setq data (cdr data))))))
6391 (defun gnus-summary-reselect-current-group (&optional all rescan)
6392 "Exit and then reselect the current newsgroup.
6393 The prefix argument ALL means to select all articles."
6395 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6396 (error "Ephemeral groups can't be reselected"))
6397 (let ((current-subject (gnus-summary-find-for-reselect))
6398 (group gnus-newsgroup-name))
6399 (setq gnus-newsgroup-begin nil)
6400 (gnus-summary-exit nil 'leave-hidden)
6401 ;; We have to adjust the point of group mode buffer because
6402 ;; point was moved to the next unread newsgroup by exiting.
6403 (gnus-summary-jump-to-group group)
6406 (save-window-excursion
6407 ;; Don't show group contents.
6408 (set-window-start (selected-window) (point-max))
6409 (gnus-group-get-new-news-this-group 1))))
6410 (gnus-group-read-group all t)
6411 (gnus-summary-goto-subject current-subject nil t)))
6413 (defun gnus-summary-rescan-group (&optional all)
6414 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6416 (gnus-summary-reselect-current-group all t))
6418 (defun gnus-summary-update-info (&optional non-destructive)
6420 (let ((group gnus-newsgroup-name))
6422 (when gnus-newsgroup-kill-headers
6423 (setq gnus-newsgroup-killed
6424 (gnus-compress-sequence
6426 (gnus-list-range-intersection
6427 gnus-newsgroup-unselected gnus-newsgroup-killed)
6428 gnus-newsgroup-unreads)
6430 (unless (listp (cdr gnus-newsgroup-killed))
6431 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6432 (let ((headers gnus-newsgroup-headers))
6433 ;; Set the new ranges of read articles.
6435 (set-buffer gnus-group-buffer)
6436 (gnus-undo-force-boundary))
6437 (gnus-update-read-articles
6438 group (gnus-sorted-union
6439 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6440 ;; Set the current article marks.
6441 (let ((gnus-newsgroup-scored
6442 (if (and (not gnus-save-score)
6443 (not non-destructive))
6445 gnus-newsgroup-scored)))
6447 (gnus-update-marks)))
6448 ;; Do the cross-ref thing.
6449 (when gnus-use-cross-reference
6450 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6451 ;; Do not switch windows but change the buffer to work.
6452 (set-buffer gnus-group-buffer)
6453 (unless (gnus-ephemeral-group-p group)
6454 (gnus-group-update-group group)))))))
6456 (defun gnus-summary-save-newsrc (&optional force)
6457 "Save the current number of read/marked articles in the dribble buffer.
6458 The dribble buffer will then be saved.
6459 If FORCE (the prefix), also save the .newsrc file(s)."
6461 (gnus-summary-update-info t)
6463 (gnus-save-newsrc-file)
6464 (gnus-dribble-save)))
6466 (defun gnus-summary-exit (&optional temporary leave-hidden)
6467 "Exit reading current newsgroup, and then return to group selection mode.
6468 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6470 (gnus-set-global-variables)
6471 (gnus-kill-save-kill-buffer)
6472 (gnus-async-halt-prefetch)
6473 (let* ((group gnus-newsgroup-name)
6474 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6475 (gnus-group-is-exiting-p t)
6478 (buf (current-buffer)))
6480 ;; Do adaptive scoring, and possibly save score files.
6481 (when gnus-newsgroup-adaptive
6482 (gnus-score-adaptive))
6483 (when gnus-use-scoring
6485 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6486 ;; If we have several article buffers, we kill them at exit.
6487 (unless gnus-single-article-buffer
6488 (gnus-kill-buffer gnus-original-article-buffer)
6489 (setq gnus-article-current nil))
6490 (when gnus-use-cache
6491 (gnus-cache-possibly-remove-articles)
6492 (gnus-cache-save-buffers))
6493 (gnus-async-prefetch-remove-group group)
6494 (when gnus-suppress-duplicates
6495 (gnus-dup-enter-articles))
6496 (when gnus-use-trees
6497 (gnus-tree-close group))
6498 (when gnus-use-cache
6499 (gnus-cache-write-active))
6500 ;; Remove entries for this group.
6501 (nnmail-purge-split-history (gnus-group-real-name group))
6502 ;; Make all changes in this group permanent.
6504 (gnus-run-hooks 'gnus-exit-group-hook)
6505 (gnus-summary-update-info))
6506 (gnus-close-group group)
6507 ;; Make sure where we were, and go to next newsgroup.
6508 (set-buffer gnus-group-buffer)
6510 (gnus-group-jump-to-group group))
6511 (gnus-run-hooks 'gnus-summary-exit-hook)
6512 (unless (or quit-config
6513 ;; If this group has disappeared from the summary
6514 ;; buffer, don't skip forwards.
6515 (not (string= group (gnus-group-group-name))))
6516 (gnus-group-next-unread-group 1))
6517 (setq group-point (point))
6520 ;; If we have several article buffers, we kill them at exit.
6521 (unless gnus-single-article-buffer
6522 (gnus-kill-buffer gnus-article-buffer)
6523 (gnus-kill-buffer gnus-original-article-buffer)
6524 (setq gnus-article-current nil))
6526 (if (not gnus-kill-summary-on-exit)
6528 (gnus-deaden-summary)
6530 ;; We set all buffer-local variables to nil. It is unclear why
6531 ;; this is needed, but if we don't, buffer-local variables are
6532 ;; not garbage-collected, it seems. This would the lead to en
6533 ;; ever-growing Emacs.
6534 (gnus-summary-clear-local-variables)
6535 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6536 (gnus-summary-clear-local-variables))
6537 (when (get-buffer gnus-article-buffer)
6538 (bury-buffer gnus-article-buffer))
6539 ;; We clear the global counterparts of the buffer-local
6540 ;; variables as well, just to be on the safe side.
6541 (set-buffer gnus-group-buffer)
6542 (gnus-summary-clear-local-variables)
6543 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6544 (gnus-summary-clear-local-variables))
6545 ;; Return to group mode buffer.
6546 (when (eq mode 'gnus-summary-mode)
6547 (gnus-kill-buffer buf)))
6548 (setq gnus-current-select-method gnus-select-method)
6550 (set-buffer gnus-group-buffer)
6551 (pop-to-buffer gnus-group-buffer))
6552 (if (not quit-config)
6554 (goto-char group-point)
6555 (unless leave-hidden
6556 (gnus-configure-windows 'group 'force))
6557 (unless (pos-visible-in-window-p)
6558 (forward-line (/ (static-if (featurep 'xemacs)
6559 (window-displayed-height)
6560 (1- (window-height)))
6562 (set-window-start (selected-window) (point))
6563 (goto-char group-point)))
6564 (gnus-handle-ephemeral-exit quit-config))
6565 ;; Clear the current group name.
6567 (setq gnus-newsgroup-name nil)))))
6569 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6570 (defun gnus-summary-exit-no-update (&optional no-questions)
6571 "Quit reading current newsgroup without updating read article info."
6573 (let* ((group gnus-newsgroup-name)
6574 (gnus-group-is-exiting-p t)
6575 (gnus-group-is-exiting-without-update-p t)
6576 (quit-config (gnus-group-quit-config group)))
6577 (when (or no-questions
6579 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6580 (gnus-async-halt-prefetch)
6581 (run-hooks 'gnus-summary-prepare-exit-hook)
6582 ;; If we have several article buffers, we kill them at exit.
6583 (unless gnus-single-article-buffer
6584 (gnus-kill-buffer gnus-article-buffer)
6585 (gnus-kill-buffer gnus-original-article-buffer)
6586 (setq gnus-article-current nil))
6587 (if (not gnus-kill-summary-on-exit)
6588 (gnus-deaden-summary)
6589 (gnus-close-group group)
6590 (gnus-summary-clear-local-variables)
6591 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6592 (gnus-summary-clear-local-variables))
6593 (set-buffer gnus-group-buffer)
6594 (gnus-summary-clear-local-variables)
6595 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6596 (gnus-summary-clear-local-variables))
6597 (gnus-kill-buffer gnus-summary-buffer))
6598 (unless gnus-single-article-buffer
6599 (setq gnus-article-current nil))
6600 (when gnus-use-trees
6601 (gnus-tree-close group))
6602 (gnus-async-prefetch-remove-group group)
6603 (when (get-buffer gnus-article-buffer)
6604 (bury-buffer gnus-article-buffer))
6605 ;; Return to the group buffer.
6606 (gnus-configure-windows 'group 'force)
6607 ;; Clear the current group name.
6608 (setq gnus-newsgroup-name nil)
6609 (unless (gnus-ephemeral-group-p group)
6610 (gnus-group-update-group group))
6611 (when (equal (gnus-group-group-name) group)
6612 (gnus-group-next-unread-group 1))
6614 (gnus-handle-ephemeral-exit quit-config)))))
6616 (defun gnus-handle-ephemeral-exit (quit-config)
6617 "Handle movement when leaving an ephemeral group.
6618 The state which existed when entering the ephemeral is reset."
6619 (if (not (buffer-name (car quit-config)))
6620 (gnus-configure-windows 'group 'force)
6621 (set-buffer (car quit-config))
6622 (cond ((eq major-mode 'gnus-summary-mode)
6623 (gnus-set-global-variables))
6624 ((eq major-mode 'gnus-article-mode)
6626 ;; The `gnus-summary-buffer' variable may point
6627 ;; to the old summary buffer when using a single
6629 (unless (gnus-buffer-live-p gnus-summary-buffer)
6630 (set-buffer gnus-group-buffer))
6631 (set-buffer gnus-summary-buffer)
6632 (gnus-set-global-variables))))
6633 (if (or (eq (cdr quit-config) 'article)
6634 (eq (cdr quit-config) 'pick))
6636 ;; The current article may be from the ephemeral group
6637 ;; thus it is best that we reload this article
6639 ;; If we're exiting from a large digest, this can be
6640 ;; extremely slow. So, it's better not to reload it. -- jh.
6641 ;;(gnus-summary-show-article)
6642 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6643 (gnus-configure-windows 'pick 'force)
6644 (gnus-configure-windows (cdr quit-config) 'force)))
6645 (gnus-configure-windows (cdr quit-config) 'force))
6646 (when (eq major-mode 'gnus-summary-mode)
6647 (gnus-summary-next-subject 1 nil t)
6648 (gnus-summary-recenter)
6649 (gnus-summary-position-point))))
6651 (defun gnus-summary-preview-mime-message ()
6652 "MIME decode and play this message."
6654 (let ((gnus-break-pages nil)
6656 (gnus-summary-select-article gnus-show-all-headers t))
6657 (let ((w (get-buffer-window gnus-article-buffer)))
6659 (select-window (get-buffer-window gnus-article-buffer)))))
6663 (defvar gnus-dead-summary-mode-map nil)
6665 (unless gnus-dead-summary-mode-map
6666 (setq gnus-dead-summary-mode-map (make-keymap))
6667 (suppress-keymap gnus-dead-summary-mode-map)
6668 (substitute-key-definition
6669 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6670 (dolist (key '("\C-d" "\r" "\177" [delete]))
6671 (define-key gnus-dead-summary-mode-map
6672 key 'gnus-summary-wake-up-the-dead))
6673 (dolist (key '("q" "Q"))
6674 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6676 (defvar gnus-dead-summary-mode nil
6677 "Minor mode for Gnus summary buffers.")
6679 (defun gnus-dead-summary-mode (&optional arg)
6680 "Minor mode for Gnus summary buffers."
6682 (when (eq major-mode 'gnus-summary-mode)
6683 (make-local-variable 'gnus-dead-summary-mode)
6684 (setq gnus-dead-summary-mode
6685 (if (null arg) (not gnus-dead-summary-mode)
6686 (> (prefix-numeric-value arg) 0)))
6687 (when gnus-dead-summary-mode
6688 (gnus-add-minor-mode
6689 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6691 (defun gnus-deaden-summary ()
6692 "Make the current summary buffer into a dead summary buffer."
6693 ;; Kill any previous dead summary buffer.
6694 (when (and gnus-dead-summary
6695 (buffer-name gnus-dead-summary))
6697 (set-buffer gnus-dead-summary)
6698 (when gnus-dead-summary-mode
6699 (kill-buffer (current-buffer)))))
6700 ;; Make this the current dead summary.
6701 (setq gnus-dead-summary (current-buffer))
6702 (gnus-dead-summary-mode 1)
6703 (let ((name (buffer-name)))
6704 (when (string-match "Summary" name)
6706 (concat (substring name 0 (match-beginning 0)) "Dead "
6707 (substring name (match-beginning 0)))
6711 (defun gnus-kill-or-deaden-summary (buffer)
6712 "Kill or deaden the summary BUFFER."
6714 (when (and (buffer-name buffer)
6715 (not gnus-single-article-buffer))
6718 (gnus-kill-buffer gnus-article-buffer)
6719 (gnus-kill-buffer gnus-original-article-buffer)))
6722 (gnus-kill-summary-on-exit
6723 (when (and gnus-use-trees
6724 (gnus-buffer-exists-p buffer))
6727 (gnus-tree-close gnus-newsgroup-name)))
6728 (gnus-kill-buffer buffer))
6729 ;; Deaden the buffer.
6730 ((gnus-buffer-exists-p buffer)
6733 (gnus-deaden-summary))))))
6735 (defun gnus-summary-wake-up-the-dead (&rest args)
6736 "Wake up the dead summary buffer."
6738 (gnus-dead-summary-mode -1)
6739 (let ((name (buffer-name)))
6740 (when (string-match "Dead " name)
6742 (concat (substring name 0 (match-beginning 0))
6743 (substring name (match-end 0)))
6745 (gnus-message 3 "This dead summary is now alive again"))
6747 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6748 (defun gnus-summary-fetch-faq (&optional faq-dir)
6749 "Fetch the FAQ for the current group.
6750 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6754 (when current-prefix-arg
6756 "FAQ dir: " (and (listp gnus-group-faq-directory)
6757 (mapcar (lambda (file) (list file))
6758 gnus-group-faq-directory))))))
6759 (let (gnus-faq-buffer)
6760 (when (setq gnus-faq-buffer
6761 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6762 (gnus-configure-windows 'summary-faq))))
6764 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6765 (defun gnus-summary-describe-group (&optional force)
6766 "Describe the current newsgroup."
6768 (gnus-group-describe-group force gnus-newsgroup-name))
6770 (defun gnus-summary-describe-briefly ()
6771 "Describe summary mode commands briefly."
6773 (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")))
6775 ;; Walking around group mode buffer from summary mode.
6777 (defun gnus-summary-next-group (&optional no-article target-group backward)
6778 "Exit current newsgroup and then select next unread newsgroup.
6779 If prefix argument NO-ARTICLE is non-nil, no article is selected
6780 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6781 previous group instead."
6783 ;; Stop pre-fetching.
6784 (gnus-async-halt-prefetch)
6785 (let ((current-group gnus-newsgroup-name)
6786 (current-buffer (current-buffer))
6788 ;; First we semi-exit this group to update Xrefs and all variables.
6789 ;; We can't do a real exit, because the window conf must remain
6790 ;; the same in case the user is prompted for info, and we don't
6791 ;; want the window conf to change before that...
6792 (gnus-summary-exit t)
6793 (while (not entered)
6794 ;; Then we find what group we are supposed to enter.
6795 (set-buffer gnus-group-buffer)
6796 (gnus-group-jump-to-group current-group)
6799 (if (eq gnus-keep-same-level 'best)
6800 (gnus-summary-best-group gnus-newsgroup-name)
6801 (gnus-summary-search-group backward gnus-keep-same-level))))
6802 (if (not target-group)
6803 ;; There are no further groups, so we return to the group
6806 (gnus-message 5 "Returning to the group buffer")
6808 (when (gnus-buffer-live-p current-buffer)
6809 (set-buffer current-buffer)
6810 (gnus-summary-exit))
6811 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6812 ;; We try to enter the target group.
6813 (gnus-group-jump-to-group target-group)
6814 (let ((unreads (gnus-group-group-unread)))
6815 (if (and (or (eq t unreads)
6816 (and unreads (not (zerop unreads))))
6817 (gnus-summary-read-group
6818 target-group nil no-article
6819 (and (buffer-name current-buffer) current-buffer)
6822 (setq current-group target-group
6823 target-group nil)))))))
6825 (defun gnus-summary-prev-group (&optional no-article)
6826 "Exit current newsgroup and then select previous unread newsgroup.
6827 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6829 (gnus-summary-next-group no-article nil t))
6831 ;; Walking around summary lines.
6833 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6834 "Go to the first subject satisfying any non-nil constraint.
6835 If UNREAD is non-nil, the article should be unread.
6836 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6837 If UNSEED is non-nil, the article should be unseen.
6838 Returns the article selected or nil if there are no matching articles."
6842 ((null gnus-newsgroup-data)
6843 (gnus-message 3 "No articles in the group")
6845 ;; Pick the first article.
6846 ((not (or unread undownloaded unseen))
6847 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6848 (gnus-data-number (car gnus-newsgroup-data)))
6849 ;; Find the first unread article.
6851 (let ((data gnus-newsgroup-data))
6853 (let ((num (gnus-data-number (car data))))
6854 (or (memq num gnus-newsgroup-unfetched)
6855 (not (or (and unread
6856 (memq num gnus-newsgroup-unreads))
6858 (memq num gnus-newsgroup-undownloaded))
6860 (memq num gnus-newsgroup-unseen)))))))
6861 (setq data (cdr data)))
6865 (goto-char (gnus-data-pos (car data)))
6866 (gnus-data-number (car data)))
6867 (gnus-message 3 "No more%s articles"
6868 (let* ((r (when unread " unread"))
6869 (d (when undownloaded " undownloaded"))
6870 (s (when unseen " unseen"))
6871 (l (delq nil (list r d s))))
6872 (cond ((= 3 (length l))
6873 (concat r "," d ", or" s))
6875 (concat (car l) ", or" (cadr l)))
6882 (gnus-summary-position-point))))))
6884 (defun gnus-summary-next-subject (n &optional unread dont-display)
6885 "Go to next N'th summary line.
6886 If N is negative, go to the previous N'th subject line.
6887 If UNREAD is non-nil, only unread articles are selected.
6888 The difference between N and the actual number of steps taken is
6891 (let ((backward (< n 0))
6895 (gnus-summary-find-prev unread)
6896 (gnus-summary-find-next unread)))
6897 (unless (zerop (setq n (1- n)))
6898 (gnus-summary-show-thread)))
6900 (gnus-message 7 "No more%s articles"
6901 (if unread " unread" "")))
6902 (unless dont-display
6903 (gnus-summary-recenter)
6904 (gnus-summary-position-point))
6907 (defun gnus-summary-next-unread-subject (n)
6908 "Go to next N'th unread summary line."
6910 (gnus-summary-next-subject n t))
6912 (defun gnus-summary-prev-subject (n &optional unread)
6913 "Go to previous N'th summary line.
6914 If optional argument UNREAD is non-nil, only unread article is selected."
6916 (gnus-summary-next-subject (- n) unread))
6918 (defun gnus-summary-prev-unread-subject (n)
6919 "Go to previous N'th unread summary line."
6921 (gnus-summary-next-subject (- n) t))
6923 (defun gnus-summary-goto-subjects (articles)
6924 "Insert the subject header for ARTICLES in the current buffer."
6926 (dolist (article articles)
6927 (gnus-summary-goto-subject article t)))
6928 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6929 (gnus-summary-position-point))
6931 (defun gnus-summary-goto-subject (article &optional force silent)
6932 "Go the subject line of ARTICLE.
6933 If FORCE, also allow jumping to articles not currently shown."
6934 (interactive "nArticle number: ")
6935 (unless (numberp article)
6936 (error "Article %s is not a number" article))
6938 (data (gnus-data-find article)))
6939 ;; We read in the article if we have to.
6942 (gnus-summary-insert-subject
6944 (if (or (numberp force) (vectorp force)) force)
6946 (setq data (gnus-data-find article)))
6951 (gnus-message 3 "Can't find article %d" article))
6953 (let ((pt (gnus-data-pos data)))
6955 (gnus-summary-set-article-display-arrow pt))
6956 (gnus-summary-position-point)
6959 ;; Walking around summary lines with displaying articles.
6961 (defun gnus-summary-expand-window (&optional arg)
6962 "Make the summary buffer take up the entire Emacs frame.
6963 Given a prefix, will force an `article' buffer configuration."
6966 (gnus-configure-windows 'article 'force)
6967 (gnus-configure-windows 'summary 'force)))
6969 (defun gnus-summary-display-article (article &optional all-header)
6970 "Display ARTICLE in article buffer."
6971 (when (gnus-buffer-live-p gnus-article-buffer)
6972 (with-current-buffer gnus-article-buffer
6973 (set-buffer-multibyte t)))
6974 (gnus-set-global-variables)
6975 (when (gnus-buffer-live-p gnus-article-buffer)
6976 (with-current-buffer gnus-article-buffer
6977 (setq gnus-article-charset gnus-newsgroup-charset)
6978 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6979 (set-buffer-multibyte t)))
6983 (if gnus-summary-display-article-function
6984 (funcall gnus-summary-display-article-function article all-header)
6985 (gnus-article-prepare article all-header))
6986 (with-current-buffer gnus-article-buffer
6987 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6989 (gnus-run-hooks 'gnus-select-article-hook)
6990 (when (and gnus-current-article
6991 (not (zerop gnus-current-article)))
6992 (gnus-summary-goto-subject gnus-current-article))
6993 (gnus-summary-recenter)
6994 (when (and gnus-use-trees gnus-show-threads)
6995 (gnus-possibly-generate-tree article)
6996 (gnus-highlight-selected-tree article))
6997 ;; Successfully display article.
6998 (gnus-article-set-window-start
6999 (cdr (assq article gnus-newsgroup-bookmarks))))))
7001 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7002 "Select the current article.
7003 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7004 non-nil, the article will be re-fetched even if it already present in
7005 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7007 ;; Make sure we are in the summary buffer to work around bbdb bug.
7008 (unless (eq major-mode 'gnus-summary-mode)
7009 (set-buffer gnus-summary-buffer))
7010 (let ((article (or article (gnus-summary-article-number)))
7011 (all-headers (not (not all-headers))) ;Must be T or NIL.
7012 gnus-summary-display-article-function)
7014 (gnus-summary-article-pseudo-p article)
7015 (error "This is a pseudo-article"))
7017 (set-buffer gnus-summary-buffer)
7018 (if (or (and gnus-single-article-buffer
7019 (or (null gnus-current-article)
7020 (null gnus-article-current)
7021 (null (get-buffer gnus-article-buffer))
7022 (not (eq article (cdr gnus-article-current)))
7023 (not (equal (car gnus-article-current)
7024 gnus-newsgroup-name))))
7025 (and (not gnus-single-article-buffer)
7026 (or (null gnus-current-article)
7027 (not (eq gnus-current-article article))))
7029 ;; The requested article is different from the current article.
7031 (gnus-summary-display-article article all-headers)
7032 (gnus-article-set-window-start
7033 (cdr (assq article gnus-newsgroup-bookmarks)))
7037 (defun gnus-summary-force-verify-and-decrypt ()
7038 "Display buttons for signed/encrypted parts and verify/decrypt them."
7040 (let ((mm-verify-option 'known)
7041 (mm-decrypt-option 'known)
7042 (gnus-buttonized-mime-types (append (list "multipart/signed"
7043 "multipart/encrypted")
7044 gnus-buttonized-mime-types)))
7045 (gnus-summary-select-article nil 'force)))
7047 (defun gnus-summary-set-current-mark (&optional current-mark)
7048 "Obsolete function."
7051 (defun gnus-summary-next-article (&optional unread subject backward push)
7052 "Select the next article.
7053 If UNREAD, only unread articles are selected.
7054 If SUBJECT, only articles with SUBJECT are selected.
7055 If BACKWARD, the previous article is selected instead of the next."
7058 ;; Is there such an article?
7059 ((and (gnus-summary-search-forward unread subject backward)
7060 (or (gnus-summary-display-article (gnus-summary-article-number))
7061 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7062 (gnus-summary-position-point))
7063 ;; If not, we try the first unread, if that is wanted.
7065 gnus-auto-select-same
7066 (gnus-summary-first-unread-article))
7067 (gnus-summary-position-point)
7068 (gnus-message 6 "Wrapped"))
7069 ;; Try to get next/previous article not displayed in this group.
7070 ((and gnus-auto-extend-newsgroup
7071 (not unread) (not subject))
7072 (gnus-summary-goto-article
7073 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7074 nil (count-lines (point-min) (point))))
7075 ;; Go to next/previous group.
7077 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7078 (gnus-summary-jump-to-group gnus-newsgroup-name))
7079 (let ((cmd last-command-char)
7082 (set-buffer gnus-group-buffer)
7085 (if (eq gnus-keep-same-level 'best)
7086 (gnus-summary-best-group gnus-newsgroup-name)
7087 (gnus-summary-search-group backward gnus-keep-same-level))))
7088 ;; For some reason, the group window gets selected. We change
7090 (select-window (get-buffer-window (current-buffer)))
7091 ;; Select next unread newsgroup automagically.
7093 ((or (not gnus-auto-select-next)
7095 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7096 ((or (eq gnus-auto-select-next 'quietly)
7097 (and (eq gnus-auto-select-next 'slightly-quietly)
7099 (and (eq gnus-auto-select-next 'almost-quietly)
7100 (gnus-summary-last-article-p)))
7102 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7104 (gnus-message 7 "No more%s articles (%s)..."
7105 (if unread " unread" "")
7106 (if group (concat "selecting " group)
7108 (gnus-summary-next-group nil group backward)))
7110 (when (gnus-key-press-event-p last-input-event)
7111 (gnus-summary-walk-group-buffer
7112 gnus-newsgroup-name cmd unread backward point))))))))
7114 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7115 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7116 (?\C-p (gnus-group-prev-unread-group 1))))
7117 (cursor-in-echo-area t)
7118 keve key group ended prompt)
7120 (set-buffer gnus-group-buffer)
7123 (if (eq gnus-keep-same-level 'best)
7124 (gnus-summary-best-group gnus-newsgroup-name)
7125 (gnus-summary-search-group backward gnus-keep-same-level))))
7129 "No more%s articles%s " (if unread " unread" "")
7131 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7132 (format " (Type %s for %s [%s])"
7133 (single-key-description cmd) group
7134 (car (gnus-gethash group gnus-newsrc-hashtb)))
7135 (format " (Type %s to exit %s)"
7136 (single-key-description cmd)
7137 gnus-newsgroup-name))))
7138 ;; Confirm auto selection.
7139 (setq key (car (setq keve (gnus-read-event-char prompt)))
7142 ((assq key keystrokes)
7143 (let ((obuf (current-buffer)))
7144 (switch-to-buffer gnus-group-buffer)
7146 (gnus-group-jump-to-group group))
7147 (eval (cadr (assq key keystrokes)))
7148 (setq group (gnus-group-group-name))
7149 (switch-to-buffer obuf))
7153 (gnus-ephemeral-group-p gnus-newsgroup-name))
7155 (gnus-summary-next-group nil group backward)))
7157 (push (cdr keve) unread-command-events))))))
7159 (defun gnus-summary-next-unread-article ()
7160 "Select unread article after current one."
7162 (gnus-summary-next-article
7163 (or (not (eq gnus-summary-goto-unread 'never))
7164 (gnus-summary-last-article-p (gnus-summary-article-number)))
7165 (and gnus-auto-select-same
7166 (gnus-summary-article-subject))))
7168 (defun gnus-summary-prev-article (&optional unread subject)
7169 "Select the article after the current one.
7170 If UNREAD is non-nil, only unread articles are selected."
7172 (gnus-summary-next-article unread subject t))
7174 (defun gnus-summary-prev-unread-article ()
7175 "Select unread article before current one."
7177 (gnus-summary-prev-article
7178 (or (not (eq gnus-summary-goto-unread 'never))
7179 (gnus-summary-first-article-p (gnus-summary-article-number)))
7180 (and gnus-auto-select-same
7181 (gnus-summary-article-subject))))
7183 (defun gnus-summary-next-page (&optional lines circular stop)
7184 "Show next page of the selected article.
7185 If at the end of the current article, select the next article.
7186 LINES says how many lines should be scrolled up.
7188 If CIRCULAR is non-nil, go to the start of the article instead of
7189 selecting the next article when reaching the end of the current
7192 If STOP is non-nil, just stop when reaching the end of the message.
7194 Also see the variable `gnus-article-skip-boring'."
7196 (setq gnus-summary-buffer (current-buffer))
7197 (gnus-set-global-variables)
7198 (let ((article (gnus-summary-article-number))
7199 (article-window (get-buffer-window gnus-article-buffer t))
7201 ;; If the buffer is empty, we have no article.
7203 (error "No article to select"))
7204 (gnus-configure-windows 'article)
7205 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7206 (if (and (eq gnus-summary-goto-unread 'never)
7207 (not (gnus-summary-last-article-p article)))
7208 (gnus-summary-next-article)
7209 (gnus-summary-next-unread-article))
7210 (if (or (null gnus-current-article)
7211 (null gnus-article-current)
7212 (/= article (cdr gnus-article-current))
7213 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7214 ;; Selected subject is different from current article's.
7215 (gnus-summary-display-article article)
7216 (when article-window
7217 (gnus-eval-in-buffer-window gnus-article-buffer
7218 (setq endp (or (gnus-article-next-page lines)
7219 (gnus-article-only-boring-p))))
7222 (gnus-message 3 "End of message"))
7224 (gnus-summary-beginning-of-article))
7226 (gnus-message 3 "End of message"))
7228 (if (and (eq gnus-summary-goto-unread 'never)
7229 (not (gnus-summary-last-article-p article)))
7230 (gnus-summary-next-article)
7231 (gnus-summary-next-unread-article))))))))
7232 (gnus-summary-recenter)
7233 (gnus-summary-position-point)))
7235 (defun gnus-summary-prev-page (&optional lines move)
7236 "Show previous page of selected article.
7237 Argument LINES specifies lines to be scrolled down.
7238 If MOVE, move to the previous unread article if point is at
7239 the beginning of the buffer."
7241 (let ((article (gnus-summary-article-number))
7242 (article-window (get-buffer-window gnus-article-buffer t))
7244 (gnus-configure-windows 'article)
7245 (if (or (null gnus-current-article)
7246 (null gnus-article-current)
7247 (/= article (cdr gnus-article-current))
7248 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7249 ;; Selected subject is different from current article's.
7250 (gnus-summary-display-article article)
7251 (gnus-summary-recenter)
7252 (when article-window
7253 (gnus-eval-in-buffer-window gnus-article-buffer
7254 (setq endp (gnus-article-prev-page lines)))
7255 (when (and move endp)
7257 (gnus-message 3 "Beginning of message"))
7259 (if (and (eq gnus-summary-goto-unread 'never)
7260 (not (gnus-summary-first-article-p article)))
7261 (gnus-summary-prev-article)
7262 (gnus-summary-prev-unread-article))))))))
7263 (gnus-summary-position-point))
7265 (defun gnus-summary-prev-page-or-article (&optional lines)
7266 "Show previous page of selected article.
7267 Argument LINES specifies lines to be scrolled down.
7268 If at the beginning of the article, go to the next article."
7270 (gnus-summary-prev-page lines t))
7272 (defun gnus-summary-scroll-up (lines)
7273 "Scroll up (or down) one line current article.
7274 Argument LINES specifies lines to be scrolled up (or down if negative)."
7276 (gnus-configure-windows 'article)
7277 (gnus-summary-show-thread)
7278 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7279 (gnus-eval-in-buffer-window gnus-article-buffer
7281 (when (gnus-article-next-page lines)
7282 (gnus-message 3 "End of message")))
7284 (gnus-article-prev-page (- lines))))))
7285 (gnus-summary-recenter)
7286 (gnus-summary-position-point))
7288 (defun gnus-summary-scroll-down (lines)
7289 "Scroll down (or up) one line current article.
7290 Argument LINES specifies lines to be scrolled down (or up if negative)."
7292 (gnus-summary-scroll-up (- lines)))
7294 (defun gnus-summary-next-same-subject ()
7295 "Select next article which has the same subject as current one."
7297 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7299 (defun gnus-summary-prev-same-subject ()
7300 "Select previous article which has the same subject as current one."
7302 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7304 (defun gnus-summary-next-unread-same-subject ()
7305 "Select next unread article which has the same subject as current one."
7307 (gnus-summary-next-article t (gnus-summary-article-subject)))
7309 (defun gnus-summary-prev-unread-same-subject ()
7310 "Select previous unread article which has the same subject as current one."
7312 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7314 (defun gnus-summary-first-unread-article ()
7315 "Select the first unread article.
7316 Return nil if there are no unread articles."
7319 (when (gnus-summary-first-subject t)
7320 (gnus-summary-show-thread)
7321 (gnus-summary-first-subject t)
7322 (gnus-summary-display-article (gnus-summary-article-number)))
7323 (gnus-summary-position-point)))
7325 (defun gnus-summary-first-unread-subject ()
7326 "Place the point on the subject line of the first unread article.
7327 Return nil if there are no unread articles."
7330 (when (gnus-summary-first-subject t)
7331 (gnus-summary-show-thread)
7332 (gnus-summary-first-subject t))
7333 (gnus-summary-position-point)))
7335 (defun gnus-summary-first-unseen-subject ()
7336 "Place the point on the subject line of the first unseen article.
7337 Return nil if there are no unseen articles."
7340 (when (gnus-summary-first-subject nil nil t)
7341 (gnus-summary-show-thread)
7342 (gnus-summary-first-subject nil nil t))
7343 (gnus-summary-position-point)))
7345 (defun gnus-summary-first-unseen-or-unread-subject ()
7346 "Place the point on the subject line of the first unseen article or,
7347 if all article have been seen, on the subject line of the first unread
7351 (unless (when (gnus-summary-first-subject nil nil t)
7352 (gnus-summary-show-thread)
7353 (gnus-summary-first-subject nil nil t))
7354 (when (gnus-summary-first-subject t)
7355 (gnus-summary-show-thread)
7356 (gnus-summary-first-subject t)))
7357 (gnus-summary-position-point)))
7359 (defun gnus-summary-first-article ()
7360 "Select the first article.
7361 Return nil if there are no articles."
7364 (when (gnus-summary-first-subject)
7365 (gnus-summary-show-thread)
7366 (gnus-summary-first-subject)
7367 (gnus-summary-display-article (gnus-summary-article-number)))
7368 (gnus-summary-position-point)))
7370 (defun gnus-summary-best-unread-article (&optional arg)
7371 "Select the unread article with the highest score.
7372 If given a prefix argument, select the next unread article that has a
7373 score higher than the default score."
7375 (let ((article (if arg
7376 (gnus-summary-better-unread-subject)
7377 (gnus-summary-best-unread-subject))))
7379 (gnus-summary-goto-article article)
7380 (error "No unread articles"))))
7382 (defun gnus-summary-best-unread-subject ()
7383 "Select the unread subject with the highest score."
7385 (let ((best -1000000)
7386 (data gnus-newsgroup-data)
7389 (and (gnus-data-unread-p (car data))
7391 (gnus-summary-article-score (gnus-data-number (car data))))
7394 article (gnus-data-number (car data))))
7395 (setq data (cdr data)))
7397 (gnus-summary-goto-subject article))
7398 (gnus-summary-position-point)
7401 (defun gnus-summary-better-unread-subject ()
7402 "Select the first unread subject that has a score over the default score."
7404 (let ((data gnus-newsgroup-data)
7406 (while (and (setq article (gnus-data-number (car data)))
7407 (or (gnus-data-read-p (car data))
7408 (not (> (gnus-summary-article-score article)
7409 gnus-summary-default-score))))
7410 (setq data (cdr data)))
7412 (gnus-summary-goto-subject article))
7413 (gnus-summary-position-point)
7416 (defun gnus-summary-last-subject ()
7417 "Go to the last displayed subject line in the group."
7418 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7420 (gnus-summary-goto-subject article))))
7422 (defun gnus-summary-goto-article (article &optional all-headers force)
7423 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7424 If ALL-HEADERS is non-nil, no header lines are hidden.
7425 If FORCE, go to the article even if it isn't displayed. If FORCE
7426 is a number, it is the line the article is to be displayed on."
7430 "Article number or Message-ID: "
7431 (mapcar (lambda (number) (list (int-to-string number)))
7432 gnus-newsgroup-limit))
7436 (if (and (stringp article)
7437 (string-match "@" article))
7438 (gnus-summary-refer-article article)
7439 (when (stringp article)
7440 (setq article (string-to-number article)))
7441 (if (gnus-summary-goto-subject article force)
7442 (gnus-summary-display-article article all-headers)
7443 (gnus-message 4 "Couldn't go to article %s" article) nil))
7444 (gnus-summary-position-point)))
7446 (defun gnus-summary-goto-last-article ()
7447 "Go to the previously read article."
7450 (when gnus-last-article
7451 (gnus-summary-goto-article gnus-last-article nil t))
7452 (gnus-summary-position-point)))
7454 (defun gnus-summary-pop-article (number)
7455 "Pop one article off the history and go to the previous.
7456 NUMBER articles will be popped off."
7459 (setq gnus-newsgroup-history
7460 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7462 (gnus-summary-goto-article (car to) nil t)
7463 (error "Article history empty")))
7464 (gnus-summary-position-point))
7466 ;; Summary commands and functions for limiting the summary buffer.
7468 (defun gnus-summary-limit-to-articles (n)
7469 "Limit the summary buffer to the next N articles.
7470 If not given a prefix, use the process marked articles instead."
7473 (let ((articles (gnus-summary-work-articles n)))
7474 (setq gnus-newsgroup-processable nil)
7475 (gnus-summary-limit articles))
7476 (gnus-summary-position-point)))
7478 (defun gnus-summary-pop-limit (&optional total)
7479 "Restore the previous limit.
7480 If given a prefix, remove all limits."
7483 (setq gnus-newsgroup-limits
7484 (list (mapcar (lambda (h) (mail-header-number h))
7485 gnus-newsgroup-headers))))
7486 (unless gnus-newsgroup-limits
7487 (error "No limit to pop"))
7489 (gnus-summary-limit nil 'pop)
7490 (gnus-summary-position-point)))
7492 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7493 "Limit the summary buffer to articles that have subjects that match a regexp.
7494 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7496 (list (read-string (if current-prefix-arg
7497 "Exclude subject (regexp): "
7498 "Limit to subject (regexp): "))
7499 nil current-prefix-arg))
7501 (setq header "subject"))
7502 (when (not (equal "" subject))
7504 (let ((articles (gnus-summary-find-matching
7505 (or header "subject") subject 'all nil nil
7508 (error "Found no matches for \"%s\"" subject))
7509 (gnus-summary-limit articles))
7510 (gnus-summary-position-point))))
7512 (defun gnus-summary-limit-to-author (from &optional not-matching)
7513 "Limit the summary buffer to articles that have authors that match a regexp.
7514 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7516 (list (read-string (if current-prefix-arg
7517 "Exclude author (regexp): "
7518 "Limit to author (regexp): "))
7519 current-prefix-arg))
7520 (gnus-summary-limit-to-subject from "from" not-matching))
7522 (defun gnus-summary-limit-to-age (age &optional younger-p)
7523 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7524 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7525 articles that are younger than AGE days."
7527 (let ((younger current-prefix-arg)
7530 (while (not days-got)
7531 (setq days (if younger
7532 (read-string "Limit to articles younger than (in days, older when negative): ")
7534 "Limit to articles older than (in days, younger when negative): ")))
7535 (when (> (length days) 0)
7536 (setq days (read days)))
7542 (setq younger (not younger))
7543 (setq days (* days -1)))))
7544 (message "Please enter a number.")
7546 (list days younger)))
7548 (let ((data gnus-newsgroup-data)
7549 (cutoff (days-to-time age))
7550 articles d date is-younger)
7551 (while (setq d (pop data))
7552 (when (and (vectorp (gnus-data-header d))
7553 (setq date (mail-header-date (gnus-data-header d))))
7554 (setq is-younger (time-less-p
7555 (time-since (condition-case ()
7562 (push (gnus-data-number d) articles))))
7563 (gnus-summary-limit (nreverse articles)))
7564 (gnus-summary-position-point)))
7566 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7567 "Limit the summary buffer to articles that match an 'extra' header."
7571 (gnus-completing-read-with-default
7572 (symbol-name (car gnus-extra-headers))
7573 (if current-prefix-arg
7574 "Exclude extra header:"
7575 "Limit extra header:")
7577 (cons (symbol-name x) x))
7582 (read-string (format "%s header %s (regexp): "
7583 (if current-prefix-arg "Exclude" "Limit to")
7585 current-prefix-arg)))
7586 (when (not (equal "" regexp))
7588 (let ((articles (gnus-summary-find-matching
7589 (cons 'extra header) regexp 'all nil nil
7592 (error "Found no matches for \"%s\"" regexp))
7593 (gnus-summary-limit articles))
7594 (gnus-summary-position-point))))
7596 (defun gnus-summary-limit-to-display-predicate ()
7597 "Limit the summary buffer to the predicated in the `display' group parameter."
7599 (unless gnus-newsgroup-display
7600 (error "There is no `display' group parameter"))
7602 (dolist (number gnus-newsgroup-articles)
7603 (when (funcall gnus-newsgroup-display)
7604 (push number articles)))
7605 (gnus-summary-limit articles))
7606 (gnus-summary-position-point))
7608 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7610 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7612 (defun gnus-summary-limit-to-unread (&optional all)
7613 "Limit the summary buffer to articles that are not marked as read.
7614 If ALL is non-nil, limit strictly to unread articles."
7617 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7618 (gnus-summary-limit-to-marks
7619 ;; Concat all the marks that say that an article is read and have
7621 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7622 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7623 gnus-low-score-mark gnus-expirable-mark
7624 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7625 gnus-duplicate-mark gnus-souped-mark)
7628 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7629 (make-obsolete 'gnus-summary-delete-marked-with
7630 'gnus-summary-limit-exclude-marks)
7632 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7633 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7634 If REVERSE, limit the summary buffer to articles that are marked
7635 with MARKS. MARKS can either be a string of marks or a list of marks.
7636 Returns how many articles were removed."
7637 (interactive "sMarks: ")
7638 (gnus-summary-limit-to-marks marks t))
7640 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7641 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7642 If REVERSE (the prefix), limit the summary buffer to articles that are
7643 not marked with MARKS. MARKS can either be a string of marks or a
7645 Returns how many articles were removed."
7646 (interactive "sMarks: \nP")
7648 (let ((data gnus-newsgroup-data)
7649 (marks (if (listp marks) marks
7650 (append marks nil))) ; Transform to list.
7653 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7654 (memq (gnus-data-mark (car data)) marks))
7655 (push (gnus-data-number (car data)) articles))
7656 (setq data (cdr data)))
7657 (gnus-summary-limit articles))
7658 (gnus-summary-position-point)))
7660 (defun gnus-summary-limit-to-score (score)
7661 "Limit to articles with score at or above SCORE."
7662 (interactive "NLimit to articles with score of at least: ")
7663 (let ((data gnus-newsgroup-data)
7666 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7668 (push (gnus-data-number (car data)) articles))
7669 (setq data (cdr data)))
7671 (gnus-summary-limit articles)
7672 (gnus-summary-position-point))))
7674 (defun gnus-summary-limit-to-unseen ()
7675 "Limit to unseen articles."
7678 (gnus-summary-limit gnus-newsgroup-unseen)
7679 (gnus-summary-position-point)))
7681 (defun gnus-summary-limit-include-thread (id)
7682 "Display all the hidden articles that is in the thread with ID in it.
7683 When called interactively, ID is the Message-ID of the current
7685 (interactive (list (mail-header-id (gnus-summary-article-header))))
7686 (let ((articles (gnus-articles-in-thread
7687 (gnus-id-to-thread (gnus-root-id id)))))
7689 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7690 (gnus-summary-limit-include-matching-articles
7692 (regexp-quote (gnus-simplify-subject-re
7693 (mail-header-subject (gnus-id-to-header id)))))
7694 (gnus-summary-position-point))))
7696 (defun gnus-summary-limit-include-matching-articles (header regexp)
7697 "Display all the hidden articles that have HEADERs that match REGEXP."
7698 (interactive (list (read-string "Match on header: ")
7699 (read-string "Regexp: ")))
7700 (let ((articles (gnus-find-matching-articles header regexp)))
7702 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7703 (gnus-summary-position-point))))
7705 (defun gnus-summary-insert-dormant-articles ()
7706 "Insert all the dormat articles for this group into the current buffer."
7708 (let ((gnus-verbose (max 6 gnus-verbose)))
7709 (if (not gnus-newsgroup-dormant)
7710 (gnus-message 3 "No cached articles for this group")
7711 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7713 (defun gnus-summary-limit-include-dormant ()
7714 "Display all the hidden articles that are marked as dormant.
7715 Note that this command only works on a subset of the articles currently
7716 fetched for this group."
7718 (unless gnus-newsgroup-dormant
7719 (error "There are no dormant articles in this group"))
7721 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7722 (gnus-summary-position-point)))
7724 (defun gnus-summary-limit-exclude-dormant ()
7725 "Hide all dormant articles."
7728 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7729 (gnus-summary-position-point)))
7731 (defun gnus-summary-limit-exclude-childless-dormant ()
7732 "Hide all dormant articles that have no children."
7734 (let ((data (gnus-data-list t))
7735 articles d children)
7736 ;; Find all articles that are either not dormant or have
7738 (while (setq d (pop data))
7739 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7741 (gnus-article-children (gnus-data-number d)))
7744 (when (memq (car children) articles)
7749 (push (gnus-data-number d) articles)))
7752 (gnus-summary-limit articles)
7753 (gnus-summary-position-point))))
7755 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7756 "Mark all unread excluded articles as read.
7757 If ALL, mark even excluded ticked and dormants as read."
7759 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7760 (let ((articles (gnus-sorted-ndifference
7762 (mapcar (lambda (h) (mail-header-number h))
7763 gnus-newsgroup-headers)
7765 gnus-newsgroup-limit))
7767 (setq gnus-newsgroup-unreads
7768 (gnus-sorted-intersection gnus-newsgroup-unreads
7769 gnus-newsgroup-limit))
7771 (setq gnus-newsgroup-dormant nil
7772 gnus-newsgroup-marked nil
7773 gnus-newsgroup-reads
7775 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7776 gnus-newsgroup-reads))
7777 (while (setq article (pop articles))
7778 (unless (or (memq article gnus-newsgroup-dormant)
7779 (memq article gnus-newsgroup-marked))
7780 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7782 (defun gnus-summary-limit (articles &optional pop)
7784 ;; We pop the previous limit off the stack and use that.
7785 (setq articles (car gnus-newsgroup-limits)
7786 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7787 ;; We use the new limit, so we push the old limit on the stack.
7788 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7790 (setq gnus-newsgroup-limit articles)
7791 (let ((total (length gnus-newsgroup-data))
7792 (data (gnus-data-find-list (gnus-summary-article-number)))
7793 (gnus-summary-mark-below nil) ; Inhibit this.
7795 ;; This will do all the work of generating the new summary buffer
7796 ;; according to the new limit.
7797 (gnus-summary-prepare)
7798 ;; Hide any threads, possibly.
7799 (gnus-summary-maybe-hide-threads)
7800 ;; Try to return to the article you were at, or one in the
7803 ;; We try to find some article after the current one.
7805 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7808 (setq data (cdr data))))
7810 ;; If there is no data, that means that we were after the last
7811 ;; article. The same goes when we can't find any articles
7812 ;; after the current one.
7813 (goto-char (point-max))
7814 (gnus-summary-find-prev))
7815 (gnus-set-mode-line 'summary)
7816 ;; We return how many articles were removed from the summary
7817 ;; buffer as a result of the new limit.
7818 (- total (length gnus-newsgroup-data))))
7820 (defsubst gnus-invisible-cut-children (threads)
7823 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7828 (defsubst gnus-cut-thread (thread)
7829 "Go forwards in the thread until we find an article that we want to display."
7830 (when (or (eq gnus-fetch-old-headers 'some)
7831 (eq gnus-fetch-old-headers 'invisible)
7832 (numberp gnus-fetch-old-headers)
7833 (eq gnus-build-sparse-threads 'some)
7834 (eq gnus-build-sparse-threads 'more))
7835 ;; Deal with old-fetched headers and sparse threads.
7839 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7840 (gnus-summary-article-ancient-p
7841 (mail-header-number (car thread))))
7842 (if (or (<= (length (cdr thread)) 1)
7843 (eq gnus-fetch-old-headers 'invisible))
7844 (setq gnus-newsgroup-limit
7845 (delq (mail-header-number (car thread))
7846 gnus-newsgroup-limit)
7847 thread (cadr thread))
7848 (when (gnus-invisible-cut-children (cdr thread))
7849 (let ((th (cdr thread)))
7851 (if (memq (mail-header-number (caar th))
7852 gnus-newsgroup-limit)
7853 (setq thread (car th)
7855 (setq th (cdr th))))))))))
7858 (defun gnus-cut-threads (threads)
7859 "Cut off all uninteresting articles from the beginning of threads."
7860 (when (or (eq gnus-fetch-old-headers 'some)
7861 (eq gnus-fetch-old-headers 'invisible)
7862 (numberp gnus-fetch-old-headers)
7863 (eq gnus-build-sparse-threads 'some)
7864 (eq gnus-build-sparse-threads 'more))
7867 (setcar th (gnus-cut-thread (car th)))
7868 (setq th (cdr th)))))
7869 ;; Remove nixed out threads.
7872 (defun gnus-summary-initial-limit (&optional show-if-empty)
7873 "Figure out what the initial limit is supposed to be on group entry.
7874 This entails weeding out unwanted dormants, low-scored articles,
7875 fetch-old-headers verbiage, and so on."
7876 ;; Most groups have nothing to remove.
7877 (if (or gnus-inhibit-limiting
7878 (and (null gnus-newsgroup-dormant)
7879 (eq gnus-newsgroup-display 'gnus-not-ignore)
7880 (not (eq gnus-fetch-old-headers 'some))
7881 (not (numberp gnus-fetch-old-headers))
7882 (not (eq gnus-fetch-old-headers 'invisible))
7883 (null gnus-summary-expunge-below)
7884 (not (eq gnus-build-sparse-threads 'some))
7885 (not (eq gnus-build-sparse-threads 'more))
7886 (null gnus-thread-expunge-below)
7887 (not gnus-use-nocem)))
7889 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7890 (setq gnus-newsgroup-limit nil)
7893 (unless (car (symbol-value node))
7894 ;; These threads have no parents -- they are roots.
7895 (let ((nodes (cdr (symbol-value node)))
7898 (if (and gnus-thread-expunge-below
7899 (< (gnus-thread-total-score (car nodes))
7900 gnus-thread-expunge-below))
7901 (gnus-expunge-thread (pop nodes))
7902 (setq thread (pop nodes))
7903 (gnus-summary-limit-children thread))))))
7904 gnus-newsgroup-dependencies)
7905 ;; If this limitation resulted in an empty group, we might
7906 ;; pop the previous limit and use it instead.
7907 (when (and (not gnus-newsgroup-limit)
7909 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7910 gnus-newsgroup-limit))
7912 (defun gnus-summary-limit-children (thread)
7913 "Return 1 if this subthread is visible and 0 if it is not."
7914 ;; First we get the number of visible children to this thread. This
7915 ;; is done by recursing down the thread using this function, so this
7916 ;; will really go down to a leaf article first, before slowly
7917 ;; working its way up towards the root.
7919 (let* ((max-lisp-eval-depth 5000)
7922 (apply '+ (mapcar 'gnus-summary-limit-children
7925 (number (mail-header-number (car thread)))
7928 (not (memq number gnus-newsgroup-marked))
7930 ;; If this article is dormant and has absolutely no visible
7931 ;; children, then this article isn't visible.
7932 (and (memq number gnus-newsgroup-dormant)
7934 ;; If this is "fetch-old-headered" and there is no
7935 ;; visible children, then we don't want this article.
7936 (and (or (eq gnus-fetch-old-headers 'some)
7937 (numberp gnus-fetch-old-headers))
7938 (gnus-summary-article-ancient-p number)
7940 ;; If this is "fetch-old-headered" and `invisible', then
7941 ;; we don't want this article.
7942 (and (eq gnus-fetch-old-headers 'invisible)
7943 (gnus-summary-article-ancient-p number))
7944 ;; If this is a sparsely inserted article with no children,
7945 ;; we don't want it.
7946 (and (eq gnus-build-sparse-threads 'some)
7947 (gnus-summary-article-sparse-p number)
7949 ;; If we use expunging, and this article is really
7950 ;; low-scored, then we don't want this article.
7951 (when (and gnus-summary-expunge-below
7953 (or (cdr (assq number gnus-newsgroup-scored))
7954 gnus-summary-default-score))
7955 gnus-summary-expunge-below))
7956 ;; We increase the expunge-tally here, but that has
7957 ;; nothing to do with the limits, really.
7958 (incf gnus-newsgroup-expunged-tally)
7959 ;; We also mark as read here, if that's wanted.
7960 (when (and gnus-summary-mark-below
7961 (< score gnus-summary-mark-below))
7962 (setq gnus-newsgroup-unreads
7963 (delq number gnus-newsgroup-unreads))
7964 (if gnus-newsgroup-auto-expire
7965 (push number gnus-newsgroup-expirable)
7966 (push (cons number gnus-low-score-mark)
7967 gnus-newsgroup-reads)))
7969 ;; Do the `display' group parameter.
7970 (and gnus-newsgroup-display
7971 (not (funcall gnus-newsgroup-display)))
7972 ;; Check NoCeM things.
7973 (if (and gnus-use-nocem
7974 (gnus-nocem-unwanted-article-p
7975 (mail-header-id (car thread))))
7977 (setq gnus-newsgroup-unreads
7978 (delq number gnus-newsgroup-unreads))
7980 ;; Nope, invisible article.
7982 ;; Ok, this article is to be visible, so we add it to the limit
7984 (push number gnus-newsgroup-limit)
7987 (defun gnus-expunge-thread (thread)
7988 "Mark all articles in THREAD as read."
7989 (let* ((number (mail-header-number (car thread))))
7990 (incf gnus-newsgroup-expunged-tally)
7991 ;; We also mark as read here, if that's wanted.
7992 (setq gnus-newsgroup-unreads
7993 (delq number gnus-newsgroup-unreads))
7994 (if gnus-newsgroup-auto-expire
7995 (push number gnus-newsgroup-expirable)
7996 (push (cons number gnus-low-score-mark)
7997 gnus-newsgroup-reads)))
7998 ;; Go recursively through all subthreads.
7999 (mapcar 'gnus-expunge-thread (cdr thread)))
8001 ;; Summary article oriented commands
8003 (defun gnus-summary-refer-parent-article (n)
8004 "Refer parent article N times.
8005 If N is negative, go to ancestor -N instead.
8006 The difference between N and the number of articles fetched is returned."
8010 (when (not (natnump n))
8015 (setq header (gnus-summary-article-header))
8016 (if (and (eq (mail-header-number header)
8017 (cdr gnus-article-current))
8018 (equal gnus-newsgroup-name
8019 (car gnus-article-current)))
8020 ;; If we try to find the parent of the currently
8021 ;; displayed article, then we take a look at the actual
8022 ;; References header, since this is slightly more
8023 ;; reliable than the References field we got from the
8026 (set-buffer gnus-original-article-buffer)
8027 (nnheader-narrow-to-headers)
8028 (unless (setq ref (message-fetch-field "references"))
8029 (setq ref (message-fetch-field "in-reply-to")))
8032 ;; It's not the current article, so we take a bet on
8033 ;; the value we got from the server.
8034 (mail-header-references header)))
8036 (not (equal ref "")))
8037 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8038 (gnus-message 1 "Couldn't find parent"))
8039 (gnus-message 1 "No references in article %d"
8040 (gnus-summary-article-number))
8043 (gnus-summary-position-point)
8046 (defun gnus-summary-refer-references ()
8047 "Fetch all articles mentioned in the References header.
8048 Return the number of articles fetched."
8050 (let ((ref (mail-header-references (gnus-summary-article-header)))
8051 (current (gnus-summary-article-number))
8055 (error "No References in the current article")
8056 ;; For each Message-ID in the References header...
8057 (while (string-match "<[^>]*>" ref)
8059 ;; ... fetch that article.
8060 (gnus-summary-refer-article
8061 (prog1 (match-string 0 ref)
8062 (setq ref (substring ref (match-end 0))))))
8063 (gnus-summary-goto-subject current)
8064 (gnus-summary-position-point)
8067 (defun gnus-summary-refer-thread (&optional limit)
8068 "Fetch all articles in the current thread.
8069 If LIMIT (the numerical prefix), fetch that many old headers instead
8070 of what's specified by the `gnus-refer-thread-limit' variable."
8072 (let ((id (mail-header-id (gnus-summary-article-header)))
8073 (limit (if limit (prefix-numeric-value limit)
8074 gnus-refer-thread-limit)))
8075 (unless (eq gnus-fetch-old-headers 'invisible)
8076 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8077 ;; Retrieve the headers and read them in.
8078 (if (eq (if (numberp limit)
8079 (gnus-retrieve-headers
8081 (+ (mail-header-number
8082 (gnus-summary-article-header))
8084 gnus-newsgroup-end))
8085 gnus-newsgroup-name (* limit 2))
8086 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8088 (gnus-retrieve-headers (list gnus-newsgroup-end)
8089 gnus-newsgroup-name limit))
8091 (gnus-build-all-threads)
8092 (error "Can't fetch thread from backends that don't support NOV"))
8093 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8094 (gnus-summary-limit-include-thread id)))
8096 (defun gnus-summary-refer-article (message-id)
8097 "Fetch an article specified by MESSAGE-ID."
8098 (interactive "sMessage-ID: ")
8099 (when (and (stringp message-id)
8100 (not (zerop (length message-id))))
8101 ;; Construct the correct Message-ID if necessary.
8102 ;; Suggested by tale@pawl.rpi.edu.
8103 (unless (string-match "^<" message-id)
8104 (setq message-id (concat "<" message-id)))
8105 (unless (string-match ">$" message-id)
8106 (setq message-id (concat message-id ">")))
8107 (let* ((header (gnus-id-to-header message-id))
8109 (gnus-summary-article-sparse-p
8110 (mail-header-number header))
8111 (memq (mail-header-number header)
8112 gnus-newsgroup-limit)))
8115 ;; If the article is present in the buffer we just go to it.
8117 (or (not (gnus-summary-article-sparse-p
8118 (mail-header-number header)))
8121 (gnus-summary-goto-article
8122 (mail-header-number header) nil t)
8124 (gnus-summary-update-article (mail-header-number header)))))
8126 ;; We fetch the article.
8128 (dolist (gnus-override-method (gnus-refer-article-methods))
8129 (when (and (gnus-check-server gnus-override-method)
8130 ;; Fetch the header,
8131 (setq number (gnus-summary-insert-subject message-id)))
8132 ;; and display the article.
8133 (gnus-summary-select-article nil nil nil number)
8135 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8137 (defun gnus-refer-article-methods ()
8138 "Return a list of referable methods."
8140 ;; No method, so we default to current and native.
8141 ((null gnus-refer-article-method)
8142 (list gnus-current-select-method gnus-select-method))
8144 ((eq 'current gnus-refer-article-method)
8145 (list gnus-current-select-method))
8146 ;; List of select methods.
8147 ((not (and (symbolp (car gnus-refer-article-method))
8148 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8150 (dolist (method gnus-refer-article-method)
8151 (push (if (eq 'current method)
8152 gnus-current-select-method
8156 ;; One single select method.
8158 (list gnus-refer-article-method))))
8160 (defun gnus-summary-edit-parameters ()
8161 "Edit the group parameters of the current group."
8163 (gnus-group-edit-group gnus-newsgroup-name 'params))
8165 (defun gnus-summary-customize-parameters ()
8166 "Customize the group parameters of the current group."
8168 (gnus-group-customize gnus-newsgroup-name))
8170 (defun gnus-summary-enter-digest-group (&optional force)
8171 "Enter an nndoc group based on the current article.
8172 If FORCE, force a digest interpretation. If not, try
8173 to guess what the document format is."
8175 (let ((conf gnus-current-window-configuration))
8176 (save-window-excursion
8178 (let (gnus-article-prepare-hook
8179 gnus-display-mime-function
8181 (gnus-summary-select-article))))
8182 (setq gnus-current-window-configuration conf)
8183 (let* ((name (format "%s-%d"
8184 (gnus-group-prefixed-name
8185 gnus-newsgroup-name (list 'nndoc ""))
8187 (set-buffer gnus-summary-buffer)
8188 gnus-current-article)))
8189 (ogroup gnus-newsgroup-name)
8190 (params (append (gnus-info-params (gnus-get-info ogroup))
8191 (list (cons 'to-group ogroup))
8192 (list (cons 'save-article-group ogroup))))
8193 (case-fold-search t)
8194 (buf (current-buffer))
8197 (set-buffer gnus-original-article-buffer)
8198 ;; Have the digest group inherit the main mail address of
8199 ;; the parent article.
8200 (when (setq to-address (or (gnus-fetch-field "reply-to")
8201 (gnus-fetch-field "from")))
8202 (setq params (append
8203 (list (cons 'to-address
8204 (funcall gnus-decode-encoded-word-function
8206 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8207 (insert-buffer-substring gnus-original-article-buffer)
8208 ;; Remove lines that may lead nndoc to misinterpret the
8211 (goto-char (point-min))
8212 (or (search-forward "\n\n" nil t) (point)))
8213 (goto-char (point-min))
8214 (delete-matching-lines "^Path:\\|^From ")
8217 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8218 (gnus-newsgroup-ephemeral-ignored-charsets
8219 gnus-newsgroup-ignored-charsets))
8220 (gnus-group-read-ephemeral-group
8221 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8223 ,(if force 'mbox 'guess)))
8225 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8227 ;; Make all postings to this group go to the parent group.
8228 (nconc (gnus-info-params (gnus-get-info name))
8230 ;; Couldn't select this doc group.
8231 (switch-to-buffer buf)
8232 (gnus-set-global-variables)
8233 (gnus-configure-windows 'summary)
8234 (gnus-message 3 "Article couldn't be entered?"))
8235 (kill-buffer dig)))))
8237 (defun gnus-summary-read-document (n)
8238 "Open a new group based on the current article(s).
8239 This will allow you to read digests and other similar
8240 documents as newsgroups.
8241 Obeys the standard process/prefix convention."
8243 (let* ((articles (gnus-summary-work-articles n))
8244 (ogroup gnus-newsgroup-name)
8245 (params (append (gnus-info-params (gnus-get-info ogroup))
8246 (list (cons 'to-group ogroup))))
8247 article group egroup groups vgroup)
8248 (while (setq article (pop articles))
8249 (setq group (format "%s-%d" gnus-newsgroup-name article))
8250 (gnus-summary-remove-process-mark article)
8251 (when (gnus-summary-display-article article)
8254 (insert-buffer-substring gnus-original-article-buffer)
8255 ;; Remove some headers that may lead nndoc to make
8257 (message-narrow-to-head)
8258 (goto-char (point-min))
8259 (delete-matching-lines "^\\(Path\\):\\|^From ")
8262 (gnus-group-read-ephemeral-group
8263 group `(nndoc ,group (nndoc-address ,(current-buffer))
8264 (nndoc-article-type guess))
8267 ;; Make all postings to this group go to the parent group.
8268 (nconc (gnus-info-params (gnus-get-info egroup))
8270 (push egroup groups))
8271 ;; Couldn't select this doc group.
8272 (gnus-error 3 "Article couldn't be entered"))))))
8273 ;; Now we have selected all the documents.
8276 (error "None of the articles could be interpreted as documents"))
8277 ((gnus-group-read-ephemeral-group
8278 (setq vgroup (format
8279 "nnvirtual:%s-%s" gnus-newsgroup-name
8280 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8281 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8283 (cons (current-buffer) 'summary)))
8285 (error "Couldn't select virtual nndoc group")))))
8287 (defun gnus-summary-isearch-article (&optional regexp-p)
8288 "Do incremental search forward on the current article.
8289 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8291 (let* ((gnus-inhibit-treatment t)
8292 (old (gnus-summary-select-article)))
8293 (gnus-configure-windows 'article)
8294 (gnus-eval-in-buffer-window gnus-article-buffer
8298 (gnus-article-show-all-headers))
8299 (goto-char (point-min))
8300 (isearch-forward regexp-p)))))
8302 (defun gnus-summary-search-article-forward (regexp &optional backward)
8303 "Search for an article containing REGEXP forward.
8304 If BACKWARD, search backward instead."
8307 (format "Search article %s (regexp%s): "
8308 (if current-prefix-arg "backward" "forward")
8309 (if gnus-last-search-regexp
8310 (concat ", default " gnus-last-search-regexp)
8312 current-prefix-arg))
8313 (if (string-equal regexp "")
8314 (setq regexp (or gnus-last-search-regexp ""))
8315 (setq gnus-last-search-regexp regexp)
8316 (setq gnus-article-before-search gnus-current-article))
8317 ;; Intentionally set gnus-last-article.
8318 (setq gnus-last-article gnus-article-before-search)
8319 (let ((gnus-last-article gnus-last-article))
8320 (if (gnus-summary-search-article regexp backward)
8321 (gnus-summary-show-thread)
8322 (error "Search failed: \"%s\"" regexp))))
8324 (defun gnus-summary-search-article-backward (regexp)
8325 "Search for an article containing REGEXP backward."
8328 (format "Search article backward (regexp%s): "
8329 (if gnus-last-search-regexp
8330 (concat ", default " gnus-last-search-regexp)
8332 (gnus-summary-search-article-forward regexp 'backward))
8335 (defmacro gnus-summary-search-article-position-point (regexp backward)
8336 "Dehighlight the last matched text and goto the beginning position."
8337 (` (if (and gnus-summary-search-article-matched-data
8338 (let ((text (caddr gnus-summary-search-article-matched-data))
8339 (inhibit-read-only t)
8342 (goto-char (car gnus-summary-search-article-matched-data))
8343 (cadr gnus-summary-search-article-matched-data))
8345 (string-match (, regexp) text)))
8346 (if (, backward) (beginning-of-line) (end-of-line))
8347 (goto-char (if (, backward) (point-max) (point-min))))))
8349 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8350 "Place point where X-Face image is displayed."
8351 (if (featurep 'xemacs)
8352 (` (let ((end (if (search-forward "\n\n" nil t)
8353 (goto-char (1- (point)))
8356 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8357 (unless (and (re-search-forward "^From:" end t)
8358 (setq extent (extent-at (point)))
8359 (extent-begin-glyph extent))
8360 (goto-char (, opoint)))))
8361 (` (let ((end (if (search-forward "\n\n" nil t)
8362 (goto-char (1- (point)))
8364 (start (or (search-backward "\n\n" nil t) (point-min))))
8366 (or (text-property-any start end 'x-face-image t);; x-face-e21
8367 (text-property-any start end 'x-face-mule-bitmap-image t)
8370 (defmacro gnus-summary-search-article-highlight-matched-text
8371 (backward treated x-face)
8372 "Highlight matched text in the function `gnus-summary-search-article'."
8373 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8374 (end (set-marker (make-marker) (match-end 0)))
8375 (inhibit-read-only t)
8379 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8381 (lambda (item) (setq items (delq item items)))
8382 '(gnus-treat-buttonize
8383 gnus-treat-fill-article
8384 gnus-treat-fill-long-lines
8385 gnus-treat-emphasize
8386 gnus-treat-highlight-headers
8387 gnus-treat-highlight-citation
8388 gnus-treat-highlight-signature
8389 gnus-treat-overstrike
8390 gnus-treat-display-xface
8391 gnus-treat-buttonize-head
8392 gnus-treat-decode-article-as-default-mime-charset))
8393 (static-if (featurep 'xemacs)
8395 (cons '(x-face-mule-delete-x-face-field
8398 (gnus-treat-display-xface
8399 (when (, x-face) gnus-treat-display-xface)))
8400 (gnus-article-prepare-mime-display)))
8401 (goto-char (if (, backward) start end))
8403 (gnus-summary-search-article-highlight-goto-x-face (point)))
8404 (setq gnus-summary-search-article-matched-data
8405 (list start end (buffer-substring start end)))
8406 (unless (eq start end);; matched text has been deleted. :-<
8407 (put-text-property start end 'face
8408 (or (find-face 'isearch)
8409 'secondary-selection))))))
8412 (defun gnus-summary-search-article (regexp &optional backward)
8413 "Search for an article containing REGEXP.
8414 Optional argument BACKWARD means do search for backward.
8415 `gnus-select-article-hook' is not called during the search."
8416 ;; We have to require this here to make sure that the following
8417 ;; dynamic binding isn't shadowed by autoloading.
8418 (require 'gnus-async)
8420 (let ((gnus-select-article-hook nil) ;Disable hook.
8421 (gnus-article-prepare-hook nil)
8422 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8423 (gnus-use-article-prefetch nil)
8424 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8425 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8427 (gnus-keep-backlog nil)
8428 (gnus-break-pages nil)
8429 (gnus-summary-display-arrow nil)
8430 (gnus-updated-mode-lines nil)
8431 (gnus-auto-center-summary nil)
8432 (sum (current-buffer))
8435 (gnus-save-hidden-threads
8436 (static-if (featurep 'xemacs)
8437 (let ((gnus-inhibit-treatment t))
8438 (setq treated (eq 'old (gnus-summary-select-article)))
8440 (not (and (gnus-buffer-live-p gnus-article-buffer)
8441 (window-live-p (get-buffer-window
8442 gnus-article-buffer t)))))
8443 (gnus-summary-select-article nil t)
8444 (setq treated nil)))
8445 (let ((gnus-inhibit-treatment t)
8446 (x-face-mule-delete-x-face-field 'never))
8447 (setq treated (eq 'old (gnus-summary-select-article)))
8450 (and (gnus-buffer-live-p gnus-article-buffer)
8451 (window-live-p (get-buffer-window
8452 gnus-article-buffer t))
8453 (or (not (string-match "^\\^X-Face:" regexp))
8454 (with-current-buffer gnus-article-buffer
8455 gnus-summary-search-article-matched-data)))))
8456 (gnus-summary-select-article nil t)
8457 (setq treated nil))))
8458 (set-buffer gnus-article-buffer)
8462 (gnus-article-show-all-headers)
8463 (gnus-summary-search-article-position-point regexp backward))
8464 (goto-char (if backward (point-max) (point-min))))
8466 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8468 (re-search-backward regexp nil t)
8469 (re-search-forward regexp nil t))
8470 ;; We found the regexp.
8472 (gnus-summary-search-article-highlight-matched-text
8473 backward treated (string-match "^\\^X-Face:" regexp))
8476 (/ (- 2 (window-height
8477 (get-buffer-window gnus-article-buffer t)))
8480 (get-buffer-window (current-buffer))
8483 (setq point (point)))
8484 ;; We didn't find it, so we go to the next article.
8487 (while (eq found 'not)
8488 (if (not (if backward (gnus-summary-find-prev)
8489 (gnus-summary-find-next)))
8490 ;; No more articles.
8492 ;; Select the next article and adjust point.
8493 (unless (gnus-summary-article-sparse-p
8494 (gnus-summary-article-number))
8496 (let ((gnus-inhibit-treatment t))
8497 (gnus-summary-select-article))
8499 (set-buffer gnus-article-buffer)
8501 (goto-char (if backward (point-max) (point-min))))))))
8502 (gnus-message 7 ""))
8503 ;; Return whether we found the regexp.
8504 (when (eq found 'found)
8506 (gnus-summary-show-thread)
8507 (gnus-summary-goto-subject gnus-current-article)
8508 (gnus-summary-position-point)
8511 (defun gnus-find-matching-articles (header regexp)
8512 "Return a list of all articles that match REGEXP on HEADER.
8513 This search includes all articles in the current group that Gnus has
8514 fetched headers for, whether they are displayed or not."
8515 (let ((articles nil)
8516 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8517 (case-fold-search t))
8518 (dolist (header gnus-newsgroup-headers)
8519 (when (string-match regexp (funcall func header))
8520 (push (mail-header-number header) articles)))
8521 (nreverse articles)))
8523 (defun gnus-summary-find-matching (header regexp &optional backward unread
8524 not-case-fold not-matching)
8525 "Return a list of all articles that match REGEXP on HEADER.
8526 The search stars on the current article and goes forwards unless
8527 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8528 If UNREAD is non-nil, only unread articles will
8529 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8530 in the comparisons. If NOT-MATCHING, return a list of all articles that
8531 not match REGEXP on HEADER."
8532 (let ((case-fold-search (not not-case-fold))
8535 (if (eq (car header) 'extra)
8538 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8540 (error "%s is an invalid header" header))
8541 (unless (fboundp (intern (concat "mail-header-" header)))
8542 (error "%s is not a valid header" header))
8543 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8544 (dolist (d (if (eq backward 'all)
8546 (gnus-data-find-list
8547 (gnus-summary-article-number)
8548 (gnus-data-list backward))))
8549 (when (and (or (not unread) ; We want all articles...
8550 (gnus-data-unread-p d)) ; Or just unreads.
8551 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8555 (funcall func (gnus-data-header d))))
8556 (string-match regexp
8557 (funcall func (gnus-data-header d)))))
8558 (push (gnus-data-number d) articles))) ; Success!
8559 (nreverse articles)))
8561 (defun gnus-summary-execute-command (header regexp command &optional backward)
8562 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8563 If HEADER is an empty string (or nil), the match is done on the entire
8564 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8566 (list (let ((completion-ignore-case t))
8569 (mapcar (lambda (header) (list (format "%s" header)))
8571 '("Number" "Subject" "From" "Lines" "Date"
8572 "Message-ID" "Xref" "References" "Body")
8573 gnus-extra-headers))
8574 nil 'require-match))
8575 (read-string "Regexp: ")
8576 (read-key-sequence "Command: ")
8577 current-prefix-arg))
8578 (when (equal header "Body")
8580 ;; Hidden thread subtrees must be searched as well.
8581 (gnus-summary-show-all-threads)
8582 ;; We don't want to change current point nor window configuration.
8584 (save-window-excursion
8586 gnus-treat-strip-trailing-blank-lines
8587 gnus-treat-strip-leading-blank-lines
8588 gnus-treat-strip-multiple-blank-lines
8589 gnus-treat-hide-boring-headers
8590 gnus-treat-fold-newsgroups
8591 gnus-article-prepare-hook)
8592 (gnus-message 6 "Executing %s..." (key-description command))
8593 ;; We'd like to execute COMMAND interactively so as to give arguments.
8594 (gnus-execute header regexp
8595 `(call-interactively ',(key-binding command))
8597 (gnus-message 6 "Executing %s...done" (key-description command))))))
8599 (defun gnus-summary-beginning-of-article ()
8600 "Scroll the article back to the beginning."
8602 (gnus-summary-select-article)
8603 (gnus-configure-windows 'article)
8604 (gnus-eval-in-buffer-window gnus-article-buffer
8606 (goto-char (point-min))
8607 (when gnus-page-broken
8608 (gnus-narrow-to-page))))
8610 (defun gnus-summary-end-of-article ()
8611 "Scroll to the end of the article."
8613 (gnus-summary-select-article)
8614 (gnus-configure-windows 'article)
8615 (gnus-eval-in-buffer-window gnus-article-buffer
8617 (goto-char (point-max))
8619 (when gnus-page-broken
8620 (gnus-narrow-to-page))))
8622 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8623 "Truncate to LEN and quote all \"(\"'s in STRING."
8624 (gnus-replace-in-string (if (and len (> (length string) len))
8625 (substring string 0 len)
8629 (defun gnus-summary-print-article (&optional filename n)
8630 "Generate and print a PostScript image of the N next (mail) articles.
8632 If N is negative, print the N previous articles. If N is nil and articles
8633 have been marked with the process mark, print these instead.
8635 If the optional first argument FILENAME is nil, send the image to the
8636 printer. If FILENAME is a string, save the PostScript image in a file with
8637 that name. If FILENAME is a number, prompt the user for the name of the file
8639 (interactive (list (ps-print-preprint current-prefix-arg)))
8640 (dolist (article (gnus-summary-work-articles n))
8641 (gnus-summary-select-article nil nil 'pseudo article)
8642 (gnus-eval-in-buffer-window gnus-article-buffer
8643 (gnus-print-buffer))
8644 (gnus-summary-remove-process-mark article))
8645 (ps-despool filename))
8647 (defun gnus-print-buffer ()
8648 (let ((buffer (generate-new-buffer " *print*")))
8651 (copy-to-buffer buffer (point-min) (point-max))
8653 (gnus-article-delete-invisible-text)
8654 (gnus-remove-text-with-property 'gnus-decoration)
8655 (when (gnus-visual-p 'article-highlight 'highlight)
8656 ;; Copy-to-buffer doesn't copy overlay. So redo
8658 (let ((gnus-article-buffer buffer))
8659 (gnus-article-highlight-citation t)
8660 (gnus-article-highlight-signature)))
8661 (let ((ps-left-header
8664 (gnus-summary-print-truncate-and-quote
8665 (mail-header-subject gnus-current-headers)
8668 (gnus-summary-print-truncate-and-quote
8669 (mail-header-from gnus-current-headers)
8673 "/pagenumberstring load"
8675 (mail-header-date gnus-current-headers) ")"))))
8676 (gnus-run-hooks 'gnus-ps-print-hook)
8679 (ps-spool-buffer-with-faces)
8680 (ps-spool-buffer)))))
8681 (kill-buffer buffer))))
8683 (defun gnus-summary-show-article (&optional arg)
8684 "Force redisplaying of the current article.
8685 If ARG (the prefix) is a number, show the article with the charset
8686 defined in `gnus-summary-show-article-charset-alist', or the charset
8688 If ARG (the prefix) is non-nil and not a number, show the raw article
8689 without any article massaging functions being run. Normally, the key
8690 strokes are `C-u g'."
8694 (gnus-summary-show-article t)
8695 (let* ((gnus-newsgroup-charset
8696 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8697 (mm-read-coding-system
8698 "View as charset: " ;; actually it is coding system.
8700 (set-buffer gnus-article-buffer)
8701 (mm-detect-coding-region (point) (point-max))))))
8702 (default-mime-charset gnus-newsgroup-charset)
8703 (gnus-newsgroup-ignored-charsets 'gnus-all))
8704 (gnus-summary-select-article nil 'force)
8705 (let ((deps gnus-newsgroup-dependencies)
8708 (set-buffer gnus-original-article-buffer)
8710 (message-narrow-to-head)
8711 (setq head (buffer-string))
8712 (goto-char (point-min))
8713 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8714 (goto-char (point-max))
8716 (setq lines (1- (count-lines (point) (point-max))))))
8718 (insert (format "211 %d Article retrieved.\n"
8719 (cdr gnus-article-current)))
8721 (if lines (insert (format "Lines: %d\n" lines)))
8723 (let ((nntp-server-buffer (current-buffer)))
8724 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8725 (gnus-data-set-header
8726 (gnus-data-find (cdr gnus-article-current))
8728 (gnus-summary-update-article-line
8729 (cdr gnus-article-current) header)
8730 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8731 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8733 ;; Select the article the normal way.
8734 (gnus-summary-select-article nil 'force))
8736 ;; We have to require this here to make sure that the following
8737 ;; dynamic binding isn't shadowed by autoloading.
8738 (require 'gnus-async)
8740 ;; Bind the article treatment functions to nil.
8741 (let ((gnus-have-all-headers t)
8742 gnus-article-prepare-hook
8743 gnus-article-decode-hook
8746 (gnus-inhibit-treatment t))
8747 (gnus-summary-select-article nil 'force))))
8748 (gnus-summary-goto-subject gnus-current-article)
8749 (gnus-summary-position-point))
8751 (defun gnus-summary-show-raw-article ()
8752 "Show the raw article without any article massaging functions being run."
8754 (gnus-summary-show-article t))
8756 (defun gnus-summary-verbose-headers (&optional arg)
8757 "Toggle permanent full header display.
8758 If ARG is a positive number, turn header display on.
8759 If ARG is a negative number, turn header display off."
8761 (setq gnus-show-all-headers
8762 (cond ((or (not (numberp arg))
8764 (not gnus-show-all-headers))
8767 (gnus-summary-show-article))
8769 (defun gnus-summary-toggle-header (&optional arg)
8770 "Show the headers if they are hidden, or hide them if they are shown.
8771 If ARG is a positive number, show the entire header.
8772 If ARG is a negative number, hide the unwanted header lines."
8774 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8775 (get-buffer-window gnus-article-buffer t))))
8776 (with-current-buffer gnus-article-buffer
8778 (article-narrow-to-head)
8779 (let* ((buffer-read-only nil)
8780 (inhibit-point-motion-hooks t)
8781 (hidden (if (numberp arg)
8783 (gnus-article-hidden-text-p 'headers)))
8785 (delete-region (point-min) (point-max))
8786 (with-current-buffer gnus-original-article-buffer
8787 (goto-char (setq s (point-min)))
8788 (setq e (if (search-forward "\n\n" nil t)
8791 (insert-buffer-substring gnus-original-article-buffer s e)
8792 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8793 ;; article-decode-encoded-words by default.
8794 (article-decode-encoded-words)
8795 (run-hooks 'gnus-article-decode-hook)
8797 (let ((gnus-treat-hide-headers nil)
8798 (gnus-treat-hide-boring-headers nil))
8799 (gnus-delete-wash-type 'headers)
8800 (gnus-treat-article 'head))
8801 (gnus-treat-article 'head))
8804 (set-window-start window (goto-char (point-min))))
8805 (setq gnus-page-broken
8806 (when gnus-break-pages
8807 (gnus-narrow-to-page)
8809 (gnus-set-mode-line 'article)))))
8811 (defun gnus-summary-show-all-headers ()
8812 "Make all header lines visible."
8814 (gnus-summary-toggle-header 1))
8816 (defun gnus-summary-toggle-mime (&optional arg)
8817 "Toggle MIME processing.
8818 If ARG is a positive number, turn MIME processing on."
8820 (setq gnus-show-mime
8822 (not gnus-show-mime)
8823 (> (prefix-numeric-value arg) 0)))
8824 (gnus-summary-select-article t 'force))
8826 (defun gnus-summary-caesar-message (&optional arg)
8827 "Caesar rotate the current article by 13.
8828 The numerical prefix specifies how many places to rotate each letter
8831 (gnus-summary-select-article)
8832 (let ((mail-header-separator ""))
8833 (gnus-eval-in-buffer-window gnus-article-buffer
8836 (let ((start (window-start))
8838 (message-caesar-buffer-body arg)
8839 (set-window-start (get-buffer-window (current-buffer)) start))))))
8841 (autoload 'unmorse-region "morse"
8842 "Convert morse coded text in region to ordinary ASCII text."
8845 (defun gnus-summary-morse-message (&optional arg)
8846 "Morse decode the current article."
8848 (gnus-summary-select-article)
8849 (let ((mail-header-separator ""))
8850 (gnus-eval-in-buffer-window gnus-article-buffer
8854 (let ((pos (window-start))
8856 (goto-char (point-min))
8857 (when (message-goto-body)
8858 (gnus-narrow-to-body))
8859 (goto-char (point-min))
8860 (while (re-search-forward "·" (point-max) t)
8861 (replace-match "."))
8862 (unmorse-region (point-min) (point-max))
8864 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8866 (defun gnus-summary-stop-page-breaking ()
8867 "Stop page breaking in the current article."
8869 (gnus-summary-select-article)
8870 (gnus-eval-in-buffer-window gnus-article-buffer
8872 (when (gnus-visual-p 'page-marker)
8873 (let ((buffer-read-only nil))
8874 (gnus-remove-text-with-property 'gnus-prev)
8875 (gnus-remove-text-with-property 'gnus-next))
8876 (setq gnus-page-broken nil))))
8878 (defun gnus-summary-move-article (&optional n to-newsgroup
8879 select-method action)
8880 "Move the current article to a different newsgroup.
8881 If N is a positive number, move the N next articles.
8882 If N is a negative number, move the N previous articles.
8883 If N is nil and any articles have been marked with the process mark,
8884 move those articles instead.
8885 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8886 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8887 re-spool using this method.
8889 When called interactively with TO-NEWSGROUP being nil, the value of
8890 the variable `gnus-move-split-methods' is used for finding a default
8891 for the target newsgroup.
8893 For this function to work, both the current newsgroup and the
8894 newsgroup that you want to move to have to support the `request-move'
8895 and `request-accept' functions.
8897 ACTION can be either `move' (the default), `crosspost' or `copy'."
8900 (setq action 'move))
8901 ;; Check whether the source group supports the required functions.
8902 (cond ((and (eq action 'move)
8903 (not (gnus-check-backend-function
8904 'request-move-article gnus-newsgroup-name)))
8905 (error "The current group does not support article moving"))
8906 ((and (eq action 'crosspost)
8907 (not (gnus-check-backend-function
8908 'request-replace-article gnus-newsgroup-name)))
8909 (error "The current group does not support article editing")))
8910 (let ((articles (gnus-summary-work-articles n))
8911 (prefix (if (gnus-check-backend-function
8912 'request-move-article gnus-newsgroup-name)
8913 (gnus-group-real-prefix gnus-newsgroup-name)
8915 (names '((move "Move" "Moving")
8916 (copy "Copy" "Copying")
8917 (crosspost "Crosspost" "Crossposting")))
8918 (copy-buf (save-excursion
8919 (nnheader-set-temp-buffer " *copy article*")))
8920 art-group to-method new-xref article to-groups)
8921 (unless (assq action names)
8922 (error "Unknown action %s" action))
8923 ;; Read the newsgroup name.
8924 (when (and (not to-newsgroup)
8925 (not select-method))
8926 (if (and gnus-move-split-methods
8928 (and (memq gnus-current-article articles)
8929 (gnus-buffer-live-p gnus-original-article-buffer))))
8930 ;; When `gnus-move-split-methods' is non-nil, we have to
8931 ;; select an article to give `gnus-read-move-group-name' an
8932 ;; opportunity to suggest an appropriate default. However,
8933 ;; we needn't render or mark the article.
8934 (let ((gnus-display-mime-function nil)
8935 (gnus-article-prepare-hook nil)
8936 (gnus-mark-article-hook nil))
8937 (gnus-summary-select-article nil nil nil (car articles))))
8939 (gnus-read-move-group-name
8940 (cadr (assq action names))
8941 (symbol-value (intern (format "gnus-current-%s-group" action)))
8943 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8944 (setq to-method (or select-method
8945 (gnus-server-to-method
8946 (gnus-group-method to-newsgroup))))
8947 ;; Check the method we are to move this article to...
8948 (unless (gnus-check-backend-function
8949 'request-accept-article (car to-method))
8950 (error "%s does not support article copying" (car to-method)))
8951 (unless (gnus-check-server to-method)
8952 (error "Can't open server %s" (car to-method)))
8953 (gnus-message 6 "%s to %s: %s..."
8954 (caddr (assq action names))
8955 (or (car select-method) to-newsgroup) articles)
8957 (setq article (pop articles))
8961 ;; Move the article.
8963 ;; Remove this article from future suppression.
8964 (gnus-dup-unsuppress-article article)
8965 (gnus-request-move-article
8966 article ; Article to move
8967 gnus-newsgroup-name ; From newsgroup
8968 (nth 1 (gnus-find-method-for-group
8969 gnus-newsgroup-name)) ; Server
8970 (list 'gnus-request-accept-article
8971 to-newsgroup (list 'quote select-method)
8972 (not articles) t) ; Accept form
8973 (not articles))) ; Only save nov last time
8974 ;; Copy the article.
8977 (set-buffer copy-buf)
8978 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8979 (gnus-request-accept-article
8980 to-newsgroup select-method (not articles) t))))
8981 ;; Crosspost the article.
8982 ((eq action 'crosspost)
8983 (let ((xref (message-tokenize-header
8984 (mail-header-xref (gnus-summary-article-header article))
8986 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8987 ":" (number-to-string article)))
8989 (setq xref (list (system-name))))
8992 (mapconcat 'identity
8993 (delete "Xref:" (delete new-xref xref))
8997 (set-buffer copy-buf)
8998 ;; First put the article in the destination group.
8999 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9000 (when (consp (setq art-group
9001 (gnus-request-accept-article
9002 to-newsgroup select-method (not articles))))
9003 (setq new-xref (concat new-xref " " (car art-group)
9005 (number-to-string (cdr art-group))))
9006 ;; Now we have the new Xrefs header, so we insert
9007 ;; it and replace the new article.
9008 (nnheader-replace-header "Xref" new-xref)
9009 (gnus-request-replace-article
9010 (cdr art-group) to-newsgroup (current-buffer))
9014 (gnus-message 1 "Couldn't %s article %s: %s"
9015 (cadr (assq action names)) article
9016 (nnheader-get-report (car to-method))))
9017 ((eq art-group 'junk)
9018 (when (eq action 'move)
9019 (gnus-summary-mark-article article gnus-canceled-mark)
9020 (gnus-message 4 "Deleted article %s" article)
9021 ;; run the delete hook
9022 (run-hook-with-args 'gnus-summary-article-delete-hook
9025 (assoc article (gnus-data-list nil)))
9026 gnus-newsgroup-name nil
9029 (let* ((pto-group (gnus-group-prefixed-name
9030 (car art-group) to-method))
9032 (gnus-gethash pto-group gnus-newsrc-hashtb))
9033 (info (nth 2 entry))
9034 (to-group (gnus-info-group info))
9036 ;; Update the group that has been moved to.
9038 (memq action '(move copy)))
9039 (unless (member to-group to-groups)
9040 (push to-group to-groups))
9042 (unless (memq article gnus-newsgroup-unreads)
9043 (push 'read to-marks)
9045 info (gnus-add-to-range (gnus-info-read info)
9046 (list (cdr art-group)))))
9048 ;; See whether the article is to be put in the cache.
9049 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9050 gnus-article-mark-lists
9051 (delete '(expirable . expire)
9052 (copy-sequence gnus-article-mark-lists))))
9053 (to-article (cdr art-group)))
9055 ;; Enter the article into the cache in the new group,
9056 ;; if that is required.
9057 (when gnus-use-cache
9058 (gnus-cache-possibly-enter-article
9060 (let ((header (copy-sequence
9061 (gnus-summary-article-header article))))
9062 (mail-header-set-number header to-article)
9064 (memq article gnus-newsgroup-marked)
9065 (memq article gnus-newsgroup-dormant)
9066 (memq article gnus-newsgroup-unreads)))
9068 (when gnus-preserve-marks
9069 ;; Copy any marks over to the new group.
9070 (when (and (equal to-group gnus-newsgroup-name)
9071 (not (memq article gnus-newsgroup-unreads)))
9072 ;; Mark this article as read in this group.
9073 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9074 (setcdr (gnus-active to-group) to-article)
9075 (setcdr gnus-newsgroup-active to-article))
9078 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9079 (when (memq article (symbol-value
9080 (intern (format "gnus-newsgroup-%s"
9082 (push (cdar marks) to-marks)
9083 ;; If the other group is the same as this group,
9084 ;; then we have to add the mark to the list.
9085 (when (equal to-group gnus-newsgroup-name)
9086 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9089 (intern (format "gnus-newsgroup-%s"
9091 ;; Copy the marks to other group.
9092 (gnus-add-marked-articles
9093 to-group (cdar marks) (list to-article) info)))
9094 (setq marks (cdr marks)))
9096 (gnus-request-set-mark
9097 to-group (list (list (list to-article) 'add to-marks))))
9100 (concat "(gnus-group-set-info '"
9101 (gnus-prin1-to-string (gnus-get-info to-group))
9104 ;; Update the Xref header in this article to point to
9105 ;; the new crossposted article we have just created.
9106 (when (eq action 'crosspost)
9108 (set-buffer copy-buf)
9109 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9110 (nnheader-replace-header "Xref" new-xref)
9111 (gnus-request-replace-article
9112 article gnus-newsgroup-name (current-buffer))))
9114 ;; run the move/copy/crosspost/respool hook
9115 (run-hook-with-args 'gnus-summary-article-move-hook
9118 (assoc article (gnus-data-list nil)))
9123 ;;;!!!Why is this necessary?
9124 (set-buffer gnus-summary-buffer)
9126 (gnus-summary-goto-subject article)
9127 (when (eq action 'move)
9128 (gnus-summary-mark-article article gnus-canceled-mark))))
9129 (gnus-summary-remove-process-mark article))
9130 ;; Re-activate all groups that have been moved to.
9132 (set-buffer gnus-group-buffer)
9133 (let ((gnus-group-marked to-groups))
9134 (gnus-group-get-new-news-this-group nil t)))
9136 (gnus-kill-buffer copy-buf)
9137 (gnus-summary-position-point)
9138 (gnus-set-mode-line 'summary)))
9140 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9141 "Move the current article to a different newsgroup.
9142 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9143 When called interactively, if TO-NEWSGROUP is nil, use the value of
9144 the variable `gnus-move-split-methods' for finding a default target
9146 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9147 re-spool using this method."
9149 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9151 (defun gnus-summary-crosspost-article (&optional n)
9152 "Crosspost the current article to some other group."
9154 (gnus-summary-move-article n nil nil 'crosspost))
9156 (defcustom gnus-summary-respool-default-method nil
9157 "Default method type for respooling an article.
9158 If nil, use to the current newsgroup method."
9160 :group 'gnus-summary-mail)
9162 (defcustom gnus-summary-display-while-building nil
9163 "If non-nil, show and update the summary buffer as it's being built.
9164 If the value is t, update the buffer after every line is inserted. If
9165 the value is an integer (N), update the display every N lines."
9167 :type '(choice (const :tag "off" nil)
9169 (const :tag "frequently" t)))
9171 (defun gnus-summary-respool-article (&optional n method)
9172 "Respool the current article.
9173 The article will be squeezed through the mail spooling process again,
9174 which means that it will be put in some mail newsgroup or other
9175 depending on `nnmail-split-methods'.
9176 If N is a positive number, respool the N next articles.
9177 If N is a negative number, respool the N previous articles.
9178 If N is nil and any articles have been marked with the process mark,
9179 respool those articles instead.
9181 Respooling can be done both from mail groups and \"real\" newsgroups.
9182 In the former case, the articles in question will be moved from the
9183 current group into whatever groups they are destined to. In the
9184 latter case, they will be copied into the relevant groups."
9186 (list current-prefix-arg
9187 (let* ((methods (gnus-methods-using 'respool))
9189 (symbol-name (or gnus-summary-respool-default-method
9190 (car (gnus-find-method-for-group
9191 gnus-newsgroup-name)))))
9193 (gnus-completing-read-with-default
9194 methname "What backend do you want to use when respooling?"
9195 methods nil t nil 'gnus-mail-method-history))
9198 ((zerop (length (setq ms (gnus-servers-using-backend
9200 (list (intern method) ""))
9204 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9205 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9208 (error "No method given for respooling"))
9209 (if (assoc (symbol-name
9210 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9211 (gnus-methods-using 'respool))
9212 (gnus-summary-move-article n nil method)
9213 (gnus-summary-copy-article n nil method)))
9215 (defun gnus-summary-import-article (file &optional edit)
9216 "Import an arbitrary file into a mail newsgroup."
9217 (interactive "fImport file: \nP")
9218 (let ((group gnus-newsgroup-name)
9219 (now (current-time))
9220 atts lines group-art)
9221 (unless (gnus-check-backend-function 'request-accept-article group)
9222 (error "%s does not support article importing" group))
9223 (or (file-readable-p file)
9224 (not (file-regular-p file))
9225 (error "Can't read %s" file))
9227 (set-buffer (gnus-get-buffer-create " *import file*"))
9229 (nnheader-insert-file-contents file)
9230 (goto-char (point-min))
9231 (if (nnheader-article-p)
9233 (goto-char (point-min))
9234 (search-forward "\n\n" nil t)
9235 (narrow-to-region (point-min) (1- (point)))
9236 (goto-char (point-min))
9237 (unless (re-search-forward "^date:" nil t)
9238 (goto-char (point-max))
9239 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9240 ;; This doesn't look like an article, so we fudge some headers.
9241 (setq atts (file-attributes file)
9242 lines (count-lines (point-min) (point-max)))
9243 (insert "From: " (read-string "From: ") "\n"
9244 "Subject: " (read-string "Subject: ") "\n"
9245 "Date: " (message-make-date (nth 5 atts)) "\n"
9246 "Message-ID: " (message-make-message-id) "\n"
9247 "Lines: " (int-to-string lines) "\n"
9248 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9249 (setq group-art (gnus-request-accept-article group nil t))
9250 (kill-buffer (current-buffer)))
9251 (setq gnus-newsgroup-active (gnus-activate-group group))
9253 (gnus-summary-goto-article (cdr group-art) nil t)
9255 (gnus-summary-edit-article))))
9257 (defun gnus-summary-create-article ()
9258 "Create an article in a mail newsgroup."
9260 (let ((group gnus-newsgroup-name)
9261 (now (current-time))
9263 (unless (gnus-check-backend-function 'request-accept-article group)
9264 (error "%s does not support article importing" group))
9266 (set-buffer (gnus-get-buffer-create " *import file*"))
9268 (goto-char (point-min))
9269 ;; This doesn't look like an article, so we fudge some headers.
9270 (insert "From: " (read-string "From: ") "\n"
9271 "Subject: " (read-string "Subject: ") "\n"
9272 "Date: " (message-make-date now) "\n"
9273 "Message-ID: " (message-make-message-id) "\n")
9274 (setq group-art (gnus-request-accept-article group nil t))
9275 (kill-buffer (current-buffer)))
9276 (setq gnus-newsgroup-active (gnus-activate-group group))
9278 (gnus-summary-goto-article (cdr group-art) nil t)
9279 (gnus-summary-edit-article)))
9281 (defun gnus-summary-article-posted-p ()
9282 "Say whether the current (mail) article is available from news as well.
9283 This will be the case if the article has both been mailed and posted."
9285 (let ((id (mail-header-references (gnus-summary-article-header)))
9286 (gnus-override-method (car (gnus-refer-article-methods))))
9287 (if (gnus-request-head id "")
9288 (gnus-message 2 "The current message was found on %s"
9289 gnus-override-method)
9290 (gnus-message 2 "The current message couldn't be found on %s"
9291 gnus-override-method)
9294 (defun gnus-summary-expire-articles (&optional now)
9295 "Expire all articles that are marked as expirable in the current group."
9297 (when (and (not gnus-group-is-exiting-without-update-p)
9298 (gnus-check-backend-function
9299 'request-expire-articles gnus-newsgroup-name))
9300 ;; This backend supports expiry.
9301 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9302 (expirable (if total
9304 ;; We need to update the info for
9305 ;; this group for `gnus-list-of-read-articles'
9306 ;; to give us the right answer.
9307 (gnus-run-hooks 'gnus-exit-group-hook)
9308 (gnus-summary-update-info)
9309 (gnus-list-of-read-articles gnus-newsgroup-name))
9310 (setq gnus-newsgroup-expirable
9311 (sort gnus-newsgroup-expirable '<))))
9312 (expiry-wait (if now 'immediate
9313 (gnus-group-find-parameter
9314 gnus-newsgroup-name 'expiry-wait)))
9315 (nnmail-expiry-target
9316 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9317 nnmail-expiry-target))
9320 ;; There are expirable articles in this group, so we run them
9321 ;; through the expiry process.
9322 (gnus-message 6 "Expiring articles...")
9323 (unless (gnus-check-group gnus-newsgroup-name)
9324 (error "Can't open server for %s" gnus-newsgroup-name))
9325 ;; The list of articles that weren't expired is returned.
9328 (let ((nnmail-expiry-wait-function nil)
9329 (nnmail-expiry-wait expiry-wait))
9330 (setq es (gnus-request-expire-articles
9331 expirable gnus-newsgroup-name)))
9332 (setq es (gnus-request-expire-articles
9333 expirable gnus-newsgroup-name)))
9335 (setq gnus-newsgroup-expirable es))
9336 ;; We go through the old list of expirable, and mark all
9337 ;; really expired articles as nonexistent.
9338 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9339 (let ((gnus-use-cache nil))
9340 (dolist (article expirable)
9341 (when (and (not (memq article es))
9342 (gnus-data-find article))
9343 (gnus-summary-mark-article article gnus-canceled-mark)
9344 (run-hook-with-args 'gnus-summary-article-expire-hook
9347 (assoc article (gnus-data-list nil)))
9351 (gnus-message 6 "Expiring articles...done")))))
9353 (defun gnus-summary-expire-articles-now ()
9354 "Expunge all expirable articles in the current group.
9355 This means that *all* articles that are marked as expirable will be
9356 deleted forever, right now."
9358 (or gnus-expert-user
9360 "Are you really, really, really sure you want to delete all these messages? ")
9362 (gnus-summary-expire-articles t))
9364 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9365 (defun gnus-summary-delete-article (&optional n)
9366 "Delete the N next (mail) articles.
9367 This command actually deletes articles. This is not a marking
9368 command. The article will disappear forever from your life, never to
9371 If N is negative, delete backwards.
9372 If N is nil and articles have been marked with the process mark,
9373 delete these instead.
9375 If `gnus-novice-user' is non-nil you will be asked for
9376 confirmation before the articles are deleted."
9378 (unless (gnus-check-backend-function 'request-expire-articles
9379 gnus-newsgroup-name)
9380 (error "The current newsgroup does not support article deletion"))
9381 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9382 (error "Couldn't open server"))
9383 ;; Compute the list of articles to delete.
9384 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9385 (nnmail-expiry-target 'delete)
9387 (if (and gnus-novice-user
9388 (not (gnus-yes-or-no-p
9389 (format "Do you really want to delete %s forever? "
9390 (if (> (length articles) 1)
9391 (format "these %s articles" (length articles))
9394 ;; Delete the articles.
9395 (setq not-deleted (gnus-request-expire-articles
9396 articles gnus-newsgroup-name 'force))
9398 (gnus-summary-remove-process-mark (car articles))
9399 ;; The backend might not have been able to delete the article
9401 (unless (memq (car articles) not-deleted)
9402 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9403 (let* ((article (car articles))
9404 (id (mail-header-id (gnus-data-header
9405 (assoc article (gnus-data-list nil))))))
9406 (run-hook-with-args 'gnus-summary-article-delete-hook
9407 'delete id gnus-newsgroup-name nil
9409 (setq articles (cdr articles)))
9411 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9412 (gnus-summary-position-point)
9413 (gnus-set-mode-line 'summary)
9416 (defun gnus-summary-edit-article (&optional force)
9417 "Edit the current article.
9418 This will have permanent effect only in mail groups.
9419 If FORCE is non-nil, allow editing of articles even in read-only
9423 (set-buffer gnus-summary-buffer)
9424 (let ((mail-parse-charset gnus-newsgroup-charset)
9425 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9426 (gnus-set-global-variables)
9427 (when (and (not force)
9428 (gnus-group-read-only-p))
9429 (error "The current newsgroup does not support article editing"))
9430 (gnus-summary-show-article t)
9431 (gnus-article-edit-article
9433 `(lambda (no-highlight)
9434 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9435 (message-options message-options)
9436 (message-options-set-recipient)
9437 (mail-parse-ignored-charsets
9438 ',gnus-newsgroup-ignored-charsets))
9439 (gnus-summary-edit-article-done
9440 ,(or (mail-header-references gnus-current-headers) "")
9441 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9443 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9445 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9447 "Make edits to the current article permanent."
9450 ;; The buffer restriction contains the entire article if it exists.
9451 (when (article-goto-body)
9452 (let ((lines (count-lines (point) (point-max)))
9453 (length (- (point-max) (point)))
9454 (case-fold-search t)
9455 (body (copy-marker (point))))
9456 (goto-char (point-min))
9457 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9458 (delete-region (match-beginning 1) (match-end 1))
9459 (insert (number-to-string length)))
9460 (goto-char (point-min))
9461 (when (re-search-forward
9462 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9463 (delete-region (match-beginning 1) (match-end 1))
9464 (insert (number-to-string length)))
9465 (goto-char (point-min))
9466 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9467 (delete-region (match-beginning 1) (match-end 1))
9468 (insert (number-to-string lines))))))
9469 ;; Replace the article.
9470 (let ((buf (current-buffer)))
9472 (insert-buffer-substring buf)
9474 (if (and (not read-only)
9475 (not (gnus-request-replace-article
9476 (cdr gnus-article-current) (car gnus-article-current)
9477 (current-buffer) t)))
9478 (error "Couldn't replace article")
9479 ;; Update the summary buffer.
9481 (equal (message-tokenize-header references " ")
9482 (message-tokenize-header
9483 (or (message-fetch-field "references") "") " ")))
9484 ;; We only have to update this line.
9487 (message-narrow-to-head)
9488 (let ((head (buffer-string))
9491 (insert (format "211 %d Article retrieved.\n"
9492 (cdr gnus-article-current)))
9495 (let ((nntp-server-buffer (current-buffer)))
9496 (setq header (car (gnus-get-newsgroup-headers
9499 (set-buffer gnus-summary-buffer)
9500 (gnus-data-set-header
9501 (gnus-data-find (cdr gnus-article-current))
9503 (gnus-summary-update-article-line
9504 (cdr gnus-article-current) header)
9505 (if (gnus-summary-goto-subject
9506 (cdr gnus-article-current) nil t)
9507 (gnus-summary-update-secondary-mark
9508 (cdr gnus-article-current))))))))
9510 (set-buffer (or buffer gnus-summary-buffer))
9511 (gnus-summary-update-article (cdr gnus-article-current))
9512 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9513 (gnus-summary-update-secondary-mark
9514 (cdr gnus-article-current))))
9515 ;; Prettify the article buffer again.
9516 (unless no-highlight
9518 (set-buffer gnus-article-buffer)
9519 ;;;!!! Fix this -- article should be rehighlighted.
9520 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9521 (set-buffer gnus-original-article-buffer)
9522 (gnus-request-article
9523 (cdr gnus-article-current)
9524 (car gnus-article-current) (current-buffer))))
9525 ;; Prettify the summary buffer line.
9526 (when (gnus-visual-p 'summary-highlight 'highlight)
9527 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9529 (defun gnus-summary-edit-wash (key)
9530 "Perform editing command KEY in the article buffer."
9534 (message "%s" (concat (this-command-keys) "- "))
9537 (gnus-summary-edit-article)
9538 (execute-kbd-macro (concat (this-command-keys) key))
9539 (gnus-article-edit-done))
9543 (defun gnus-summary-respool-query (&optional silent trace)
9544 "Query where the respool algorithm would put this article."
9546 (let (gnus-mark-article-hook)
9547 (gnus-summary-select-article)
9549 (set-buffer gnus-original-article-buffer)
9551 (message-narrow-to-head)
9552 (let ((groups (nnmail-article-group 'identity trace)))
9555 (message "This message would go to %s"
9556 (mapconcat 'car groups ", "))
9557 (message "This message would go to no groups"))
9560 (defun gnus-summary-respool-trace ()
9561 "Trace where the respool algorithm would put this article.
9562 Display a buffer showing all fancy splitting patterns which matched."
9564 (gnus-summary-respool-query nil t))
9566 ;; Summary marking commands.
9568 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9569 "Mark articles which has the same subject as read, and then select the next.
9570 If UNMARK is positive, remove any kind of mark.
9571 If UNMARK is negative, tick articles."
9574 (setq unmark (prefix-numeric-value unmark)))
9576 (gnus-summary-mark-same-subject
9577 (gnus-summary-article-subject) unmark)))
9578 ;; Select next unread article. If auto-select-same mode, should
9579 ;; select the first unread article.
9580 (gnus-summary-next-article t (and gnus-auto-select-same
9581 (gnus-summary-article-subject)))
9582 (gnus-message 7 "%d article%s marked as %s"
9583 count (if (= count 1) " is" "s are")
9584 (if unmark "unread" "read"))))
9586 (defun gnus-summary-kill-same-subject (&optional unmark)
9587 "Mark articles which has the same subject as read.
9588 If UNMARK is positive, remove any kind of mark.
9589 If UNMARK is negative, tick articles."
9592 (setq unmark (prefix-numeric-value unmark)))
9594 (gnus-summary-mark-same-subject
9595 (gnus-summary-article-subject) unmark)))
9596 ;; If marked as read, go to next unread subject.
9598 ;; Go to next unread subject.
9599 (gnus-summary-next-subject 1 t))
9600 (gnus-message 7 "%d articles are marked as %s"
9601 count (if unmark "unread" "read"))))
9603 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9604 "Mark articles with same SUBJECT as read, and return marked number.
9605 If optional argument UNMARK is positive, remove any kinds of marks.
9606 If optional argument UNMARK is negative, mark articles as unread instead."
9610 ((null unmark) ; Mark as read.
9613 (gnus-summary-mark-article-as-read gnus-killed-mark)
9614 (gnus-summary-show-thread) t)
9615 (gnus-summary-find-subject subject))
9616 (setq count (1+ count))))
9617 ((> unmark 0) ; Tick.
9620 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9621 (gnus-summary-show-thread) t)
9622 (gnus-summary-find-subject subject))
9623 (setq count (1+ count))))
9624 (t ; Mark as unread.
9627 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9628 (gnus-summary-show-thread) t)
9629 (gnus-summary-find-subject subject))
9630 (setq count (1+ count)))))
9631 (gnus-set-mode-line 'summary)
9632 ;; Return the number of marked articles.
9635 (defun gnus-summary-mark-as-processable (n &optional unmark)
9636 "Set the process mark on the next N articles.
9637 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9638 the process mark instead. The difference between N and the actual
9639 number of articles marked is returned."
9641 (if (and (null n) (gnus-region-active-p))
9642 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9643 (setq n (prefix-numeric-value n))
9644 (let ((backward (< n 0))
9649 (gnus-summary-remove-process-mark
9650 (gnus-summary-article-number))
9651 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9652 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9655 (gnus-message 7 "No more articles"))
9656 (gnus-summary-recenter)
9657 (gnus-summary-position-point)
9660 (defun gnus-summary-unmark-as-processable (n)
9661 "Remove the process mark from the next N articles.
9662 If N is negative, unmark backward instead. The difference between N and
9663 the actual number of articles unmarked is returned."
9665 (gnus-summary-mark-as-processable n t))
9667 (defun gnus-summary-unmark-all-processable ()
9668 "Remove the process mark from all articles."
9671 (while gnus-newsgroup-processable
9672 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9673 (gnus-summary-position-point))
9675 (defun gnus-summary-add-mark (article type)
9676 "Mark ARTICLE with a mark of TYPE."
9677 (let ((vtype (car (assq type gnus-article-mark-lists)))
9680 (error "No such mark type: %s" type)
9681 (setq var (intern (format "gnus-newsgroup-%s" type)))
9682 (set var (cons article (symbol-value var)))
9683 (if (memq type '(processable cached replied forwarded recent saved))
9684 (gnus-summary-update-secondary-mark article)
9685 ;;; !!! This is bogus. We should find out what primary
9686 ;;; !!! mark we want to set.
9687 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9689 (defun gnus-summary-mark-as-expirable (n)
9690 "Mark N articles forward as expirable.
9691 If N is negative, mark backward instead. The difference between N and
9692 the actual number of articles marked is returned."
9694 (gnus-summary-mark-forward n gnus-expirable-mark))
9696 (defun gnus-summary-mark-as-spam (n)
9697 "Mark N articles forward as spam.
9698 If N is negative, mark backward instead. The difference between N and
9699 the actual number of articles marked is returned."
9701 (gnus-summary-mark-forward n gnus-spam-mark))
9703 (defun gnus-summary-mark-article-as-replied (article)
9704 "Mark ARTICLE as replied to and update the summary line.
9705 ARTICLE can also be a list of articles."
9706 (interactive (list (gnus-summary-article-number)))
9707 (let ((articles (if (listp article) article (list article))))
9708 (dolist (article articles)
9709 (unless (numberp article)
9710 (error "%s is not a number" article))
9711 (push article gnus-newsgroup-replied)
9712 (let ((buffer-read-only nil))
9713 (when (gnus-summary-goto-subject article nil t)
9714 (gnus-summary-update-secondary-mark article))))))
9716 (defun gnus-summary-mark-article-as-forwarded (article)
9717 "Mark ARTICLE as forwarded and update the summary line.
9718 ARTICLE can also be a list of articles."
9719 (let ((articles (if (listp article) article (list article))))
9720 (dolist (article articles)
9721 (push article gnus-newsgroup-forwarded)
9722 (let ((buffer-read-only nil))
9723 (when (gnus-summary-goto-subject article nil t)
9724 (gnus-summary-update-secondary-mark article))))))
9726 (defun gnus-summary-set-bookmark (article)
9727 "Set a bookmark in current article."
9728 (interactive (list (gnus-summary-article-number)))
9729 (when (or (not (get-buffer gnus-article-buffer))
9730 (not gnus-current-article)
9731 (not gnus-article-current)
9732 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9733 (error "No current article selected"))
9734 ;; Remove old bookmark, if one exists.
9735 (gnus-pull article gnus-newsgroup-bookmarks)
9736 ;; Set the new bookmark, which is on the form
9737 ;; (article-number . line-number-in-body).
9741 (set-buffer gnus-article-buffer)
9748 gnus-newsgroup-bookmarks)
9749 (gnus-message 6 "A bookmark has been added to the current article."))
9751 (defun gnus-summary-remove-bookmark (article)
9752 "Remove the bookmark from the current article."
9753 (interactive (list (gnus-summary-article-number)))
9754 ;; Remove old bookmark, if one exists.
9755 (if (not (assq article gnus-newsgroup-bookmarks))
9756 (gnus-message 6 "No bookmark in current article.")
9757 (gnus-pull article gnus-newsgroup-bookmarks)
9758 (gnus-message 6 "Removed bookmark.")))
9760 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9761 (defun gnus-summary-mark-as-dormant (n)
9762 "Mark N articles forward as dormant.
9763 If N is negative, mark backward instead. The difference between N and
9764 the actual number of articles marked is returned."
9766 (gnus-summary-mark-forward n gnus-dormant-mark))
9768 (defun gnus-summary-set-process-mark (article)
9769 "Set the process mark on ARTICLE and update the summary line."
9770 (setq gnus-newsgroup-processable
9772 (delq article gnus-newsgroup-processable)))
9773 (when (gnus-summary-goto-subject article)
9774 (gnus-summary-show-thread)
9775 (gnus-summary-goto-subject article)
9776 (gnus-summary-update-secondary-mark article)))
9778 (defun gnus-summary-remove-process-mark (article)
9779 "Remove the process mark from ARTICLE and update the summary line."
9780 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9781 (when (gnus-summary-goto-subject article)
9782 (gnus-summary-show-thread)
9783 (gnus-summary-goto-subject article)
9784 (gnus-summary-update-secondary-mark article)))
9786 (defun gnus-summary-set-saved-mark (article)
9787 "Set the process mark on ARTICLE and update the summary line."
9788 (push article gnus-newsgroup-saved)
9789 (when (gnus-summary-goto-subject article)
9790 (gnus-summary-update-secondary-mark article)))
9792 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9793 "Mark N articles as read forwards.
9794 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9795 The difference between N and the actual number of articles marked is
9797 If NO-EXPIRE, auto-expiry will be inhibited."
9799 (gnus-summary-show-thread)
9800 (let ((backward (< n 0))
9801 (gnus-summary-goto-unread
9802 (and gnus-summary-goto-unread
9803 (not (eq gnus-summary-goto-unread 'never))
9804 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9805 gnus-ticked-mark gnus-dormant-mark)))))
9807 (mark (or mark gnus-del-mark)))
9809 (gnus-summary-mark-article nil mark no-expire)
9810 (zerop (gnus-summary-next-subject
9812 (and gnus-summary-goto-unread
9813 (not (eq gnus-summary-goto-unread 'never)))
9817 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9818 (gnus-summary-recenter)
9819 (gnus-summary-position-point)
9820 (gnus-set-mode-line 'summary)
9823 (defun gnus-summary-mark-article-as-read (mark)
9824 "Mark the current article quickly as read with MARK."
9825 (let ((article (gnus-summary-article-number)))
9826 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9827 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9828 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9829 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9830 (push (cons article mark) gnus-newsgroup-reads)
9831 ;; Possibly remove from cache, if that is used.
9832 (when gnus-use-cache
9833 (gnus-cache-enter-remove-article article))
9834 ;; Allow the backend to change the mark.
9835 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9836 ;; Check for auto-expiry.
9837 (when (and gnus-newsgroup-auto-expire
9838 (memq mark gnus-auto-expirable-marks))
9839 (setq mark gnus-expirable-mark)
9840 ;; Let the backend know about the mark change.
9841 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9842 (push article gnus-newsgroup-expirable))
9843 ;; Set the mark in the buffer.
9844 (gnus-summary-update-mark mark 'unread)
9847 (defun gnus-summary-mark-article-as-unread (mark)
9848 "Mark the current article quickly as unread with MARK."
9849 (let* ((article (gnus-summary-article-number))
9850 (old-mark (gnus-summary-article-mark article)))
9851 ;; Allow the backend to change the mark.
9852 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9853 (if (eq mark old-mark)
9857 (gnus-error 1 "Can't mark negative article numbers")
9859 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9860 (setq gnus-newsgroup-spam-marked
9861 (delq article gnus-newsgroup-spam-marked))
9862 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9863 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9864 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9865 (cond ((= mark gnus-ticked-mark)
9866 (setq gnus-newsgroup-marked
9867 (gnus-add-to-sorted-list gnus-newsgroup-marked
9869 ((= mark gnus-spam-mark)
9870 (setq gnus-newsgroup-spam-marked
9871 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9873 ((= mark gnus-dormant-mark)
9874 (setq gnus-newsgroup-dormant
9875 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9878 (setq gnus-newsgroup-unreads
9879 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9881 (gnus-pull article gnus-newsgroup-reads)
9883 ;; See whether the article is to be put in the cache.
9885 (vectorp (gnus-summary-article-header article))
9887 (gnus-cache-possibly-enter-article
9888 gnus-newsgroup-name article
9889 (gnus-summary-article-header article)
9890 (= mark gnus-ticked-mark)
9891 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9894 (gnus-summary-update-mark mark 'unread)
9897 (defun gnus-summary-mark-article (&optional article mark no-expire)
9898 "Mark ARTICLE with MARK. MARK can be any character.
9899 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9900 `??' (dormant) and `?E' (expirable).
9901 If MARK is nil, then the default character `?r' is used.
9902 If ARTICLE is nil, then the article on the current line will be
9904 If NO-EXPIRE, auto-expiry will be inhibited."
9905 ;; The mark might be a string.
9906 (when (stringp mark)
9907 (setq mark (aref mark 0)))
9908 ;; If no mark is given, then we check auto-expiring.
9910 (setq mark gnus-del-mark))
9911 (when (and (not no-expire)
9912 gnus-newsgroup-auto-expire
9913 (memq mark gnus-auto-expirable-marks))
9914 (setq mark gnus-expirable-mark))
9915 (let ((article (or article (gnus-summary-article-number)))
9916 (old-mark (gnus-summary-article-mark article)))
9917 ;; Allow the backend to change the mark.
9918 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9919 (if (eq mark old-mark)
9922 (error "No article on current line"))
9923 (if (not (if (or (= mark gnus-unread-mark)
9924 (= mark gnus-ticked-mark)
9925 (= mark gnus-spam-mark)
9926 (= mark gnus-dormant-mark))
9927 (gnus-mark-article-as-unread article mark)
9928 (gnus-mark-article-as-read article mark)))
9930 ;; See whether the article is to be put in the cache.
9932 (not (= mark gnus-canceled-mark))
9933 (vectorp (gnus-summary-article-header article))
9935 (gnus-cache-possibly-enter-article
9936 gnus-newsgroup-name article
9937 (gnus-summary-article-header article)
9938 (= mark gnus-ticked-mark)
9939 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9941 (when (gnus-summary-goto-subject article nil t)
9942 (let ((buffer-read-only nil))
9943 (gnus-summary-show-thread)
9945 (gnus-summary-update-mark mark 'unread)
9948 (defun gnus-summary-update-secondary-mark (article)
9949 "Update the secondary (read, process, cache) mark."
9950 (gnus-summary-update-mark
9951 (cond ((memq article gnus-newsgroup-processable)
9953 ((memq article gnus-newsgroup-cached)
9955 ((memq article gnus-newsgroup-replied)
9957 ((memq article gnus-newsgroup-forwarded)
9958 gnus-forwarded-mark)
9959 ((memq article gnus-newsgroup-saved)
9961 ((memq article gnus-newsgroup-recent)
9963 ((memq article gnus-newsgroup-unseen)
9967 (when (gnus-visual-p 'summary-highlight 'highlight)
9968 (gnus-run-hooks 'gnus-summary-update-hook))
9971 (defun gnus-summary-update-download-mark (article)
9972 "Update the download mark."
9973 (gnus-summary-update-mark
9974 (cond ((memq article gnus-newsgroup-undownloaded)
9975 gnus-undownloaded-mark)
9976 (gnus-newsgroup-agentized
9977 gnus-downloaded-mark)
9981 (gnus-summary-update-line t)
9984 (defun gnus-summary-update-mark (mark type)
9985 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9986 (buffer-read-only nil))
9987 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9989 (when (looking-at "\r")
9991 (when (<= (+ forward (point)) (point-max))
9992 ;; Go to the right position on the line.
9993 (goto-char (+ forward (point)))
9994 ;; Replace the old mark with the new mark.
9995 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9996 ;; Optionally update the marks by some user rule.
9997 (when (eq type 'unread)
9999 (gnus-data-find (gnus-summary-article-number)) mark)
10000 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10002 (defun gnus-mark-article-as-read (article &optional mark)
10003 "Enter ARTICLE in the pertinent lists and remove it from others."
10004 ;; Make the article expirable.
10005 (let ((mark (or mark gnus-del-mark)))
10006 (setq gnus-newsgroup-expirable
10007 (if (= mark gnus-expirable-mark)
10008 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10009 (delq article gnus-newsgroup-expirable)))
10010 ;; Remove from unread and marked lists.
10011 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10012 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10013 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10014 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10015 (push (cons article mark) gnus-newsgroup-reads)
10016 ;; Possibly remove from cache, if that is used.
10017 (when gnus-use-cache
10018 (gnus-cache-enter-remove-article article))
10021 (defun gnus-mark-article-as-unread (article &optional mark)
10022 "Enter ARTICLE in the pertinent lists and remove it from others."
10023 (let ((mark (or mark gnus-ticked-mark)))
10026 (gnus-error 1 "Can't mark negative article numbers")
10028 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10029 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10030 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10031 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10032 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10034 ;; Unsuppress duplicates?
10035 (when gnus-suppress-duplicates
10036 (gnus-dup-unsuppress-article article))
10038 (cond ((= mark gnus-ticked-mark)
10039 (setq gnus-newsgroup-marked
10040 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10041 ((= mark gnus-spam-mark)
10042 (setq gnus-newsgroup-spam-marked
10043 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10045 ((= mark gnus-dormant-mark)
10046 (setq gnus-newsgroup-dormant
10047 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10049 (setq gnus-newsgroup-unreads
10050 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10051 (gnus-pull article gnus-newsgroup-reads)
10054 (defalias 'gnus-summary-mark-as-unread-forward
10055 'gnus-summary-tick-article-forward)
10056 (make-obsolete 'gnus-summary-mark-as-unread-forward
10057 'gnus-summary-tick-article-forward)
10058 (defun gnus-summary-tick-article-forward (n)
10059 "Tick N articles forwards.
10060 If N is negative, tick backwards instead.
10061 The difference between N and the number of articles ticked is returned."
10063 (gnus-summary-mark-forward n gnus-ticked-mark))
10065 (defalias 'gnus-summary-mark-as-unread-backward
10066 'gnus-summary-tick-article-backward)
10067 (make-obsolete 'gnus-summary-mark-as-unread-backward
10068 'gnus-summary-tick-article-backward)
10069 (defun gnus-summary-tick-article-backward (n)
10070 "Tick N articles backwards.
10071 The difference between N and the number of articles ticked is returned."
10073 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10075 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10076 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10077 (defun gnus-summary-tick-article (&optional article clear-mark)
10078 "Mark current article as unread.
10079 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10080 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10082 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10083 gnus-ticked-mark)))
10085 (defun gnus-summary-mark-as-read-forward (n)
10086 "Mark N articles as read forwards.
10087 If N is negative, mark backwards instead.
10088 The difference between N and the actual number of articles marked is
10091 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10093 (defun gnus-summary-mark-as-read-backward (n)
10094 "Mark the N articles as read backwards.
10095 The difference between N and the actual number of articles marked is
10098 (gnus-summary-mark-forward
10099 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10101 (defun gnus-summary-mark-as-read (&optional article mark)
10102 "Mark current article as read.
10103 ARTICLE specifies the article to be marked as read.
10104 MARK specifies a string to be inserted at the beginning of the line."
10105 (gnus-summary-mark-article article mark))
10107 (defun gnus-summary-clear-mark-forward (n)
10108 "Clear marks from N articles forward.
10109 If N is negative, clear backward instead.
10110 The difference between N and the number of marks cleared is returned."
10112 (gnus-summary-mark-forward n gnus-unread-mark))
10114 (defun gnus-summary-clear-mark-backward (n)
10115 "Clear marks from N articles backward.
10116 The difference between N and the number of marks cleared is returned."
10118 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10120 (defun gnus-summary-mark-unread-as-read ()
10121 "Intended to be used by `gnus-summary-mark-article-hook'."
10122 (when (memq gnus-current-article gnus-newsgroup-unreads)
10123 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10125 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10126 "Intended to be used by `gnus-summary-mark-article-hook'."
10127 (let ((mark (gnus-summary-article-mark)))
10128 (when (or (gnus-unread-mark-p mark)
10129 (gnus-read-mark-p mark))
10130 (gnus-summary-mark-article gnus-current-article
10131 (or new-mark gnus-read-mark)))))
10133 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10134 "Intended to be used by `gnus-summary-mark-article-hook'."
10135 (let ((mark (gnus-summary-article-mark)))
10136 (when (or (gnus-unread-mark-p mark)
10137 (gnus-read-mark-p mark))
10138 (gnus-summary-mark-article (gnus-summary-article-number)
10139 (or new-mark gnus-read-mark)))))
10141 (defun gnus-summary-mark-unread-as-ticked ()
10142 "Intended to be used by `gnus-summary-mark-article-hook'."
10143 (when (memq gnus-current-article gnus-newsgroup-unreads)
10144 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10146 (defun gnus-summary-mark-region-as-read (point mark all)
10147 "Mark all unread articles between point and mark as read.
10148 If given a prefix, mark all articles between point and mark as read,
10149 even ticked and dormant ones."
10150 (interactive "r\nP")
10154 (beginning-of-line)
10159 (memq (setq article (gnus-summary-article-number))
10160 gnus-newsgroup-unreads))
10161 (gnus-summary-mark-article article gnus-del-mark))
10163 (gnus-summary-find-next))))))
10165 (defun gnus-summary-mark-below (score mark)
10166 "Mark articles with score less than SCORE with MARK."
10167 (interactive "P\ncMark: ")
10168 (setq score (if score
10169 (prefix-numeric-value score)
10170 (or gnus-summary-default-score 0)))
10172 (set-buffer gnus-summary-buffer)
10173 (goto-char (point-min))
10176 (and (< (gnus-summary-article-score) score)
10177 (gnus-summary-mark-article nil mark))
10178 (gnus-summary-find-next)))))
10180 (defun gnus-summary-kill-below (&optional score)
10181 "Mark articles with score below SCORE as read."
10183 (gnus-summary-mark-below score gnus-killed-mark))
10185 (defun gnus-summary-clear-above (&optional score)
10186 "Clear all marks from articles with score above SCORE."
10188 (gnus-summary-mark-above score gnus-unread-mark))
10190 (defun gnus-summary-tick-above (&optional score)
10191 "Tick all articles with score above SCORE."
10193 (gnus-summary-mark-above score gnus-ticked-mark))
10195 (defun gnus-summary-mark-above (score mark)
10196 "Mark articles with score over SCORE with MARK."
10197 (interactive "P\ncMark: ")
10198 (setq score (if score
10199 (prefix-numeric-value score)
10200 (or gnus-summary-default-score 0)))
10202 (set-buffer gnus-summary-buffer)
10203 (goto-char (point-min))
10205 (when (> (gnus-summary-article-score) score)
10206 (gnus-summary-mark-article nil mark))
10208 (gnus-summary-find-next)))))
10210 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10211 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10212 (defun gnus-summary-limit-include-expunged (&optional no-error)
10213 "Display all the hidden articles that were expunged for low scores."
10215 (let ((buffer-read-only nil))
10216 (let ((scored gnus-newsgroup-scored)
10219 (unless (gnus-summary-article-header (caar scored))
10220 (and (setq h (gnus-number-to-header (caar scored)))
10221 (< (cdar scored) gnus-summary-expunge-below)
10223 (setq scored (cdr scored)))
10225 (when (not no-error)
10226 (error "No expunged articles hidden"))
10227 (goto-char (point-min))
10228 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10229 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10230 (mapcar (lambda (x) (push (mail-header-number x)
10231 gnus-newsgroup-limit))
10233 (gnus-summary-prepare-unthreaded (nreverse headers))
10234 (goto-char (point-min))
10235 (gnus-summary-position-point)
10238 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10239 "Mark all unread articles in this newsgroup as read.
10240 If prefix argument ALL is non-nil, ticked and dormant articles will
10241 also be marked as read.
10242 If QUIETLY is non-nil, no questions will be asked.
10244 If TO-HERE is non-nil, it should be a point in the buffer. All
10245 articles before (after, if REVERSE is set) this point will be marked
10248 Note that this function will only catch up the unread article
10249 in the current summary buffer limitation.
10251 The number of articles marked as read is returned."
10256 (not gnus-interactive-catchup) ;Without confirmation?
10260 "Mark absolutely all articles as read? "
10261 "Mark all unread articles as read? ")))
10263 (not gnus-newsgroup-adaptive)
10264 (not gnus-newsgroup-auto-expire)
10265 (not gnus-suppress-duplicates)
10266 (or (not gnus-use-cache)
10267 (eq gnus-use-cache 'passive)))
10270 (setq gnus-newsgroup-marked nil
10271 gnus-newsgroup-spam-marked nil
10272 gnus-newsgroup-dormant nil))
10273 (setq gnus-newsgroup-unreads
10274 (gnus-sorted-nunion
10275 (gnus-intersection gnus-newsgroup-unreads
10276 gnus-newsgroup-downloadable)
10277 gnus-newsgroup-unfetched)))
10278 ;; We actually mark all articles as canceled, which we
10279 ;; have to do when using auto-expiry or adaptive scoring.
10280 (gnus-summary-show-all-threads)
10281 (if (and to-here reverse)
10283 (goto-char to-here)
10284 (gnus-summary-mark-current-read-and-unread-as-read
10286 (while (gnus-summary-find-next (not all))
10287 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10288 (when (gnus-summary-first-subject (not all))
10290 (if to-here (< (point) to-here) t)
10291 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10292 (gnus-summary-find-next (not all))))))
10293 (gnus-set-mode-line 'summary))
10295 (gnus-summary-position-point)))
10297 (defun gnus-summary-catchup-to-here (&optional all)
10298 "Mark all unticked articles before the current one as read.
10299 If ALL is non-nil, also mark ticked and dormant articles as read."
10302 (gnus-save-hidden-threads
10303 (let ((beg (point)))
10304 ;; We check that there are unread articles.
10305 (when (or all (gnus-summary-find-prev))
10306 (gnus-summary-catchup all t beg)))))
10307 (gnus-summary-position-point))
10309 (defun gnus-summary-catchup-from-here (&optional all)
10310 "Mark all unticked articles after (and including) the current one as read.
10311 If ALL is non-nil, also mark ticked and dormant articles as read."
10314 (gnus-save-hidden-threads
10315 (let ((beg (point)))
10316 ;; We check that there are unread articles.
10317 (when (or all (gnus-summary-find-next))
10318 (gnus-summary-catchup all t beg nil t)))))
10319 (gnus-summary-position-point))
10321 (defun gnus-summary-catchup-all (&optional quietly)
10322 "Mark all articles in this newsgroup as read.
10323 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10324 instead, which marks only unread articles as read."
10326 (gnus-summary-catchup t quietly))
10328 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10329 "Mark all unread articles in this group as read, then exit.
10330 If prefix argument ALL is non-nil, all articles are marked as read.
10331 If QUIETLY is non-nil, no questions will be asked."
10333 (when (gnus-summary-catchup all quietly nil 'fast)
10334 ;; Select next newsgroup or exit.
10335 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10336 (eq gnus-auto-select-next 'quietly))
10337 (gnus-summary-next-group nil)
10338 (gnus-summary-exit))))
10340 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10341 "Mark all articles in this newsgroup as read, and then exit.
10342 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10343 instead, which marks only unread articles as read."
10345 (gnus-summary-catchup-and-exit t quietly))
10347 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10348 "Mark all articles in this group as read and select the next group.
10349 If given a prefix, mark all articles, unread as well as ticked, as
10353 (gnus-summary-catchup all))
10354 (gnus-summary-next-group))
10360 (defmacro gnus-with-article (article &rest forms)
10361 "Select ARTICLE and perform FORMS in the original article buffer.
10362 Then replace the article with the result."
10364 ;; We don't want the article to be marked as read.
10365 (let (gnus-mark-article-hook)
10366 (gnus-summary-select-article t t nil ,article))
10367 (set-buffer gnus-original-article-buffer)
10369 (if (not (gnus-check-backend-function
10370 'request-replace-article (car gnus-article-current)))
10371 (gnus-message 5 "Read-only group; not replacing")
10372 (unless (gnus-request-replace-article
10373 ,article (car gnus-article-current)
10374 (current-buffer) t)
10375 (error "Couldn't replace article")))
10376 ;; The cache and backlog have to be flushed somewhat.
10377 (when gnus-keep-backlog
10378 (gnus-backlog-remove-article
10379 (car gnus-article-current) (cdr gnus-article-current)))
10380 (when gnus-use-cache
10381 (gnus-cache-update-article
10382 (car gnus-article-current) (cdr gnus-article-current)))))
10384 (put 'gnus-with-article 'lisp-indent-function 1)
10385 (put 'gnus-with-article 'edebug-form-spec '(form body))
10387 ;; Thread-based commands.
10389 (defun gnus-summary-articles-in-thread (&optional article)
10390 "Return a list of all articles in the current thread.
10391 If ARTICLE is non-nil, return all articles in the thread that starts
10392 with that article."
10393 (let* ((article (or article (gnus-summary-article-number)))
10394 (data (gnus-data-find-list article))
10395 (top-level (gnus-data-level (car data)))
10397 (cond ((null gnus-thread-operation-ignore-subject)
10398 (gnus-simplify-subject-re
10399 (mail-header-subject (gnus-data-header (car data)))))
10400 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10401 (gnus-simplify-subject-fuzzy
10402 (mail-header-subject (gnus-data-header (car data)))))
10404 (end-point (save-excursion
10405 (if (gnus-summary-go-to-next-thread)
10406 (point) (point-max))))
10409 (< (gnus-data-pos (car data)) end-point))
10410 (when (or (not top-subject)
10411 (string= top-subject
10412 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10413 (gnus-simplify-subject-fuzzy
10414 (mail-header-subject
10415 (gnus-data-header (car data))))
10416 (gnus-simplify-subject-re
10417 (mail-header-subject
10418 (gnus-data-header (car data)))))))
10419 (push (gnus-data-number (car data)) articles))
10420 (unless (and (setq data (cdr data))
10421 (> (gnus-data-level (car data)) top-level))
10423 ;; Return the list of articles.
10424 (nreverse articles)))
10426 (defun gnus-summary-rethread-current ()
10427 "Rethread the thread the current article is part of."
10429 (let* ((gnus-show-threads t)
10430 (article (gnus-summary-article-number))
10431 (id (mail-header-id (gnus-summary-article-header)))
10432 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10434 (error "No article on the current line"))
10435 (gnus-rebuild-thread id)
10436 (gnus-summary-goto-subject article)))
10438 (defun gnus-summary-reparent-thread ()
10439 "Make the current article child of the marked (or previous) article.
10441 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10442 is non-nil or the Subject: of both articles are the same."
10444 (unless (not (gnus-group-read-only-p))
10445 (error "The current newsgroup does not support article editing"))
10446 (unless (<= (length gnus-newsgroup-processable) 1)
10447 (error "No more than one article may be marked"))
10448 (save-window-excursion
10449 (let ((gnus-article-buffer " *reparent*")
10450 (current-article (gnus-summary-article-number))
10451 ;; First grab the marked article, otherwise one line up.
10452 (parent-article (if (not (null gnus-newsgroup-processable))
10453 (car gnus-newsgroup-processable)
10455 (if (eq (forward-line -1) 0)
10456 (gnus-summary-article-number)
10457 (error "Beginning of summary buffer"))))))
10458 (unless (not (eq current-article parent-article))
10459 (error "An article may not be self-referential"))
10460 (let ((message-id (mail-header-id
10461 (gnus-summary-article-header parent-article))))
10462 (unless (and message-id (not (equal message-id "")))
10463 (error "No message-id in desired parent"))
10464 (gnus-with-article current-article
10466 (goto-char (point-min))
10467 (message-narrow-to-head)
10468 (if (re-search-forward "^References: " nil t)
10470 (re-search-forward "^[^ \t]" nil t)
10473 (insert " " message-id))
10474 (insert "References: " message-id "\n"))))
10475 (set-buffer gnus-summary-buffer)
10476 (gnus-summary-unmark-all-processable)
10477 (gnus-summary-update-article current-article)
10478 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10479 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10480 (gnus-summary-rethread-current)
10481 (gnus-message 3 "Article %d is now the child of article %d"
10482 current-article parent-article)))))
10484 (defun gnus-summary-toggle-threads (&optional arg)
10485 "Toggle showing conversation threads.
10486 If ARG is positive number, turn showing conversation threads on."
10488 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10489 (setq gnus-show-threads
10490 (if (null arg) (not gnus-show-threads)
10491 (> (prefix-numeric-value arg) 0)))
10492 (gnus-summary-prepare)
10493 (gnus-summary-goto-subject current)
10494 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10495 (gnus-summary-position-point)))
10497 (defun gnus-summary-show-all-threads ()
10498 "Show all threads."
10501 (let ((buffer-read-only nil))
10502 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10503 (gnus-summary-position-point))
10505 (defun gnus-summary-show-thread ()
10506 "Show thread subtrees.
10507 Returns nil if no thread was there to be shown."
10509 (let ((buffer-read-only nil)
10511 (end (gnus-point-at-eol))
10512 ;; Leave point at bol
10513 (beg (progn (beginning-of-line) (point))))
10515 ;; Any hidden lines here?
10516 (search-forward "\r" end t)
10517 (subst-char-in-region beg end ?\^M ?\n t)
10519 (gnus-summary-position-point))))
10521 (defun gnus-summary-maybe-hide-threads ()
10522 "If requested, hide the threads that should be hidden."
10523 (when (and gnus-show-threads
10524 gnus-thread-hide-subtree)
10525 (gnus-summary-hide-all-threads
10526 (if (or (consp gnus-thread-hide-subtree)
10527 (functionp gnus-thread-hide-subtree))
10528 (gnus-make-predicate gnus-thread-hide-subtree)
10531 ;;; Hiding predicates.
10533 (defun gnus-article-unread-p (header)
10534 (memq (mail-header-number header) gnus-newsgroup-unreads))
10536 (defun gnus-article-unseen-p (header)
10537 (memq (mail-header-number header) gnus-newsgroup-unseen))
10539 (defun gnus-map-articles (predicate articles)
10540 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10541 (apply 'gnus-or (mapcar predicate
10542 (mapcar 'gnus-summary-article-header articles))))
10544 (defun gnus-summary-hide-all-threads (&optional predicate)
10545 "Hide all thread subtrees.
10546 If PREDICATE is supplied, threads that satisfy this predicate
10547 will not be hidden."
10550 (goto-char (point-min))
10553 (when (or (not predicate)
10555 predicate (gnus-summary-article-children)))
10556 (gnus-summary-hide-thread))
10557 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10558 (gnus-summary-position-point))
10560 (defun gnus-summary-hide-thread ()
10561 "Hide thread subtrees.
10562 If PREDICATE is supplied, threads that satisfy this predicate
10563 will not be hidden.
10564 Returns nil if no threads were there to be hidden."
10566 (let ((buffer-read-only nil)
10568 (article (gnus-summary-article-number)))
10570 ;; Go forward until either the buffer ends or the subthread
10572 (when (and (not (eobp))
10573 (or (zerop (gnus-summary-next-thread 1 t))
10574 (goto-char (point-max))))
10576 (if (and (> (point) start)
10577 (search-backward "\n" start t))
10579 (subst-char-in-region start (point) ?\n ?\^M)
10580 (gnus-summary-goto-subject article))
10584 (defun gnus-summary-go-to-next-thread (&optional previous)
10585 "Go to the same level (or less) next thread.
10586 If PREVIOUS is non-nil, go to previous thread instead.
10587 Return the article number moved to, or nil if moving was impossible."
10588 (let ((level (gnus-summary-thread-level))
10589 (way (if previous -1 1))
10592 (while (and (not (eobp))
10593 (< level (gnus-summary-thread-level)))
10594 (forward-line way))
10601 (gnus-summary-article-number)
10602 (goto-char beg)))))
10604 (defun gnus-summary-next-thread (n &optional silent)
10605 "Go to the same level next N'th thread.
10606 If N is negative, search backward instead.
10607 Returns the difference between N and the number of skips actually
10610 If SILENT, don't output messages."
10612 (let ((backward (< n 0))
10614 (while (and (> n 0)
10615 (gnus-summary-go-to-next-thread backward))
10618 (gnus-summary-position-point))
10619 (when (and (not silent) (/= 0 n))
10620 (gnus-message 7 "No more threads"))
10623 (defun gnus-summary-prev-thread (n)
10624 "Go to the same level previous N'th thread.
10625 Returns the difference between N and the number of skips actually
10628 (gnus-summary-next-thread (- n)))
10630 (defun gnus-summary-go-down-thread ()
10631 "Go down one level in the current thread."
10632 (let ((children (gnus-summary-article-children)))
10634 (gnus-summary-goto-subject (car children)))))
10636 (defun gnus-summary-go-up-thread ()
10637 "Go up one level in the current thread."
10638 (let ((parent (gnus-summary-article-parent)))
10640 (gnus-summary-goto-subject parent))))
10642 (defun gnus-summary-down-thread (n)
10643 "Go down thread N steps.
10644 If N is negative, go up instead.
10645 Returns the difference between N and how many steps down that were
10650 (while (and (> n 0)
10651 (if up (gnus-summary-go-up-thread)
10652 (gnus-summary-go-down-thread)))
10654 (gnus-summary-position-point)
10656 (gnus-message 7 "Can't go further"))
10659 (defun gnus-summary-up-thread (n)
10660 "Go up thread N steps.
10661 If N is negative, go down instead.
10662 Returns the difference between N and how many steps down that were
10665 (gnus-summary-down-thread (- n)))
10667 (defun gnus-summary-top-thread ()
10668 "Go to the top of the thread."
10670 (while (gnus-summary-go-up-thread))
10671 (gnus-summary-article-number))
10673 (defun gnus-summary-kill-thread (&optional unmark)
10674 "Mark articles under current thread as read.
10675 If the prefix argument is positive, remove any kinds of marks.
10676 If the prefix argument is negative, tick articles instead."
10679 (setq unmark (prefix-numeric-value unmark)))
10680 (let ((articles (gnus-summary-articles-in-thread)))
10682 ;; Expand the thread.
10683 (gnus-summary-show-thread)
10684 ;; Mark all the articles.
10686 (gnus-summary-goto-subject (car articles))
10687 (cond ((null unmark)
10688 (gnus-summary-mark-article-as-read gnus-killed-mark))
10690 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10692 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10693 (setq articles (cdr articles))))
10694 ;; Hide killed subtrees.
10696 gnus-thread-hide-killed
10697 (gnus-summary-hide-thread))
10698 ;; If marked as read, go to next unread subject.
10699 (when (null unmark)
10700 ;; Go to next unread subject.
10701 (gnus-summary-next-subject 1 t)))
10702 (gnus-set-mode-line 'summary))
10704 ;; Summary sorting commands
10706 (defun gnus-summary-sort-by-number (&optional reverse)
10707 "Sort the summary buffer by article number.
10708 Argument REVERSE means reverse order."
10710 (gnus-summary-sort 'number reverse))
10712 (defun gnus-summary-sort-by-random (&optional reverse)
10713 "Randomize the order in the summary buffer.
10714 Argument REVERSE means to randomize in reverse order."
10716 (gnus-summary-sort 'random reverse))
10718 (defun gnus-summary-sort-by-author (&optional reverse)
10719 "Sort the summary buffer by author name alphabetically.
10720 If `case-fold-search' is non-nil, case of letters is ignored.
10721 Argument REVERSE means reverse order."
10723 (gnus-summary-sort 'author reverse))
10725 (defun gnus-summary-sort-by-subject (&optional reverse)
10726 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10727 If `case-fold-search' is non-nil, case of letters is ignored.
10728 Argument REVERSE means reverse order."
10730 (gnus-summary-sort 'subject reverse))
10732 (defun gnus-summary-sort-by-date (&optional reverse)
10733 "Sort the summary buffer by date.
10734 Argument REVERSE means reverse order."
10736 (gnus-summary-sort 'date reverse))
10738 (defun gnus-summary-sort-by-score (&optional reverse)
10739 "Sort the summary buffer by score.
10740 Argument REVERSE means reverse order."
10742 (gnus-summary-sort 'score reverse))
10744 (defun gnus-summary-sort-by-lines (&optional reverse)
10745 "Sort the summary buffer by the number of lines.
10746 Argument REVERSE means reverse order."
10748 (gnus-summary-sort 'lines reverse))
10750 (defun gnus-summary-sort-by-chars (&optional reverse)
10751 "Sort the summary buffer by article length.
10752 Argument REVERSE means reverse order."
10754 (gnus-summary-sort 'chars reverse))
10756 (defun gnus-summary-sort-by-original (&optional reverse)
10757 "Sort the summary buffer using the default sorting method.
10758 Argument REVERSE means reverse order."
10760 (let* ((buffer-read-only)
10761 (gnus-summary-prepare-hook nil))
10762 ;; We do the sorting by regenerating the threads.
10763 (gnus-summary-prepare)
10764 ;; Hide subthreads if needed.
10765 (gnus-summary-maybe-hide-threads)))
10767 (defun gnus-summary-sort (predicate reverse)
10768 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10769 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10770 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10771 (gnus-thread-sort-functions
10776 (gnus-sort-gathered-threads-function
10777 gnus-thread-sort-functions)
10778 (gnus-article-sort-functions
10782 (,article t2 t1))))
10784 (gnus-summary-prepare-hook nil))
10785 ;; We do the sorting by regenerating the threads.
10786 (gnus-summary-prepare)
10787 ;; Hide subthreads if needed.
10788 (gnus-summary-maybe-hide-threads)))
10790 ;; Summary saving commands.
10792 (defun gnus-summary-save-article (&optional n not-saved)
10793 "Save the current article using the default saver function.
10794 If N is a positive number, save the N next articles.
10795 If N is a negative number, save the N previous articles.
10796 If N is nil and any articles have been marked with the process mark,
10797 save those articles instead.
10798 The variable `gnus-default-article-saver' specifies the saver function."
10800 (let* ((articles (gnus-summary-work-articles n))
10801 (save-buffer (save-excursion
10802 (nnheader-set-temp-buffer " *Gnus Save*")))
10803 (num (length articles))
10805 (dolist (article articles)
10806 (setq header (gnus-summary-article-header article))
10807 (if (not (vectorp header))
10808 ;; This is a pseudo-article.
10809 (if (assq 'name header)
10810 (gnus-copy-file (cdr (assq 'name header)))
10811 (gnus-message 1 "Article %d is unsaveable" article))
10812 ;; This is a real article.
10813 (save-window-excursion
10814 (let ((gnus-display-mime-function nil)
10815 (gnus-article-prepare-hook nil))
10816 (gnus-summary-select-article t nil nil article)))
10818 (set-buffer save-buffer)
10820 (insert-buffer-substring gnus-original-article-buffer))
10821 (setq file (gnus-article-save save-buffer file num))
10822 (gnus-summary-remove-process-mark article)
10824 (gnus-summary-set-saved-mark article))))
10825 (gnus-kill-buffer save-buffer)
10826 (gnus-summary-position-point)
10827 (gnus-set-mode-line 'summary)
10830 (defun gnus-summary-pipe-output (&optional arg headers)
10831 "Pipe the current article to a subprocess.
10832 If N is a positive number, pipe the N next articles.
10833 If N is a negative number, pipe the N previous articles.
10834 If N is nil and any articles have been marked with the process mark,
10835 pipe those articles instead.
10836 If HEADERS (the symbolic prefix), include the headers, too."
10837 (interactive (gnus-interactive "P\ny"))
10838 (require 'gnus-art)
10839 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10840 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10841 (gnus-summary-save-article arg t))
10842 (let ((buffer (get-buffer "*Shell Command Output*")))
10844 (not (zerop (buffer-size buffer))))
10845 (gnus-configure-windows 'pipe))))
10847 (defun gnus-summary-save-article-mail (&optional arg)
10848 "Append the current article to an mail file.
10849 If N is a positive number, save the N next articles.
10850 If N is a negative number, save the N previous articles.
10851 If N is nil and any articles have been marked with the process mark,
10852 save those articles instead."
10854 (require 'gnus-art)
10855 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10856 (gnus-summary-save-article arg)))
10858 (defun gnus-summary-save-article-rmail (&optional arg)
10859 "Append the current article to an rmail file.
10860 If N is a positive number, save the N next articles.
10861 If N is a negative number, save the N previous articles.
10862 If N is nil and any articles have been marked with the process mark,
10863 save those articles instead."
10865 (require 'gnus-art)
10866 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10867 (gnus-summary-save-article arg)))
10869 (defun gnus-summary-save-article-file (&optional arg)
10870 "Append the current article to a file.
10871 If N is a positive number, save the N next articles.
10872 If N is a negative number, save the N previous articles.
10873 If N is nil and any articles have been marked with the process mark,
10874 save those articles instead."
10876 (require 'gnus-art)
10877 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10878 (gnus-summary-save-article arg)))
10880 (defun gnus-summary-write-article-file (&optional arg)
10881 "Write the current article to a file, deleting the previous file.
10882 If N is a positive number, save the N next articles.
10883 If N is a negative number, save the N previous articles.
10884 If N is nil and any articles have been marked with the process mark,
10885 save those articles instead."
10887 (require 'gnus-art)
10888 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10889 (gnus-summary-save-article arg)))
10891 (defun gnus-summary-save-article-body-file (&optional arg)
10892 "Append the current article body to a file.
10893 If N is a positive number, save the N next articles.
10894 If N is a negative number, save the N previous articles.
10895 If N is nil and any articles have been marked with the process mark,
10896 save those articles instead."
10898 (require 'gnus-art)
10899 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10900 (gnus-summary-save-article arg)))
10902 (defun gnus-summary-muttprint (&optional arg)
10903 "Print the current article using Muttprint.
10904 If N is a positive number, save the N next articles.
10905 If N is a negative number, save the N previous articles.
10906 If N is nil and any articles have been marked with the process mark,
10907 save those articles instead."
10909 (require 'gnus-art)
10910 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10911 (gnus-summary-save-article arg t)))
10913 (defun gnus-summary-pipe-message (program)
10914 "Pipe the current article through PROGRAM."
10915 (interactive "sProgram: ")
10916 (gnus-summary-select-article)
10917 (let ((mail-header-separator ""))
10918 (gnus-eval-in-buffer-window gnus-article-buffer
10921 (let ((start (window-start))
10923 (message-pipe-buffer-body program)
10924 (set-window-start (get-buffer-window (current-buffer)) start))))))
10926 (defun gnus-get-split-value (methods)
10927 "Return a value based on the split METHODS."
10928 (let (split-name method result match)
10931 (set-buffer gnus-original-article-buffer)
10933 (nnheader-narrow-to-headers)
10934 (while (and methods (not split-name))
10935 (goto-char (point-min))
10936 (setq method (pop methods))
10937 (setq match (car method))
10940 ;; Regular expression.
10942 (re-search-forward match nil t)))
10947 (setq result (funcall match gnus-newsgroup-name))))
10952 (setq result (eval match)))))
10953 (setq split-name (cdr method))
10954 (cond ((stringp result)
10955 (push (expand-file-name
10956 result gnus-article-save-directory)
10959 (setq split-name (append result split-name)))))))))
10960 (nreverse split-name)))
10962 (defun gnus-valid-move-group-p (group)
10963 (and (boundp group)
10964 (symbol-name group)
10965 (symbol-value group)
10966 (gnus-get-function (gnus-find-method-for-group
10967 (symbol-name group)) 'request-accept-article t)))
10969 (defun gnus-read-move-group-name (prompt default articles prefix)
10970 "Read a group name."
10971 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10972 (minibuffer-confirm-incomplete nil) ; XEmacs
10974 (format "%s %s to:"
10976 (if (> (length articles) 1)
10977 (format "these %d articles" (length articles))
10982 (gnus-completing-read-with-default
10985 'gnus-valid-move-group-p
10987 'gnus-group-history))
10988 ((= 1 (length split-name))
10989 (gnus-completing-read-with-default
10990 (car split-name) prom
10992 'gnus-valid-move-group-p
10994 'gnus-group-history))
10996 (gnus-completing-read-with-default
10998 (mapcar (lambda (el) (list el))
10999 (nreverse split-name))
11001 'gnus-group-history))))
11002 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11004 (if (or (string= to-newsgroup "")
11005 (string= to-newsgroup prefix))
11006 (setq to-newsgroup default))
11007 (unless to-newsgroup
11008 (error "No group name entered"))
11009 (or (gnus-active to-newsgroup)
11010 (gnus-activate-group to-newsgroup nil nil to-method)
11011 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11013 (or (and (gnus-request-create-group to-newsgroup to-method)
11014 (gnus-activate-group
11015 to-newsgroup nil nil to-method)
11016 (gnus-subscribe-group to-newsgroup))
11017 (error "Couldn't create group %s" to-newsgroup)))
11018 (error "No such group: %s" to-newsgroup)))
11021 (defun gnus-summary-save-parts (type dir n &optional reverse)
11022 "Save parts matching TYPE to DIR.
11023 If REVERSE, save parts that do not match TYPE."
11025 (list (read-string "Save parts of type: "
11026 (or (car gnus-summary-save-parts-type-history)
11027 gnus-summary-save-parts-default-mime)
11028 'gnus-summary-save-parts-type-history)
11029 (setq gnus-summary-save-parts-last-directory
11030 (read-file-name "Save to directory: "
11031 gnus-summary-save-parts-last-directory
11033 current-prefix-arg))
11034 (gnus-summary-iterate n
11035 (let ((gnus-display-mime-function nil)
11036 (gnus-inhibit-treatment t))
11037 (gnus-summary-select-article))
11039 (set-buffer gnus-article-buffer)
11040 (let ((handles (or gnus-article-mime-handles
11041 (mm-dissect-buffer nil gnus-article-loose-mime)
11042 (and gnus-article-emulate-mime
11043 (mm-uu-dissect)))))
11045 (gnus-summary-save-parts-1 type dir handles reverse)
11046 (unless gnus-article-mime-handles ;; Don't destroy this case.
11047 (mm-destroy-parts handles)))))))
11049 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11050 (if (stringp (car handle))
11051 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11054 (not (string-match type (mm-handle-media-type handle)))
11055 (string-match type (mm-handle-media-type handle)))
11056 (let ((file (expand-file-name
11057 (file-name-nondirectory
11059 (mail-content-type-get
11060 (mm-handle-disposition handle) 'filename)
11061 (concat gnus-newsgroup-name
11062 "." (number-to-string
11063 (cdr gnus-article-current)))))
11065 (unless (file-exists-p file)
11066 (mm-save-part-to-file handle file))))))
11068 ;; Summary extract commands
11070 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11071 (let ((buffer-read-only nil)
11072 (article (gnus-summary-article-number))
11074 (unless (gnus-summary-goto-subject article)
11075 (error "No such article: %d" article))
11076 (gnus-summary-position-point)
11077 ;; If all commands are to be bunched up on one line, we collect
11079 (unless gnus-view-pseudos-separately
11080 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11083 (setq action (cdr (assq 'action (car ps))))
11084 (setq files (list (cdr (assq 'name (car ps)))))
11085 (while (and ps (cdr ps)
11086 (string= (or action "1")
11087 (or (cdr (assq 'action (cadr ps))) "2")))
11088 (push (cdr (assq 'name (cadr ps))) files)
11089 (setcdr ps (cddr ps)))
11091 (when (not (string-match "%s" action))
11094 (when (assq 'execute (car ps))
11095 (setcdr (assq 'execute (car ps))
11096 (funcall (if (string-match "%s" action)
11103 (gnus-quote-arg-for-sh-or-csh f)))
11105 (setq ps (cdr ps)))))
11106 (if (and gnus-view-pseudos (not not-view))
11108 (when (assq 'execute (car pslist))
11109 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11110 (eq gnus-view-pseudos 'not-confirm)))
11111 (setq pslist (cdr pslist)))
11114 (setq after-article (or (cdr (assq 'article (car pslist)))
11115 (gnus-summary-article-number)))
11116 (gnus-summary-goto-subject after-article)
11119 (insert " " (file-name-nondirectory
11120 (cdr (assq 'name (car pslist))))
11121 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11123 (forward-line -1) ; back to `b'
11124 (gnus-add-text-properties
11125 b (1- e) (list 'gnus-number gnus-reffed-article-number
11126 gnus-mouse-face-prop gnus-mouse-face))
11128 after-article gnus-reffed-article-number
11129 gnus-unread-mark b (car pslist) 0 (- e b))
11130 (setq gnus-newsgroup-unreads
11131 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11132 gnus-reffed-article-number))
11133 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11134 (setq pslist (cdr pslist)))))))
11136 (defun gnus-pseudos< (p1 p2)
11137 (let ((c1 (cdr (assq 'action p1)))
11138 (c2 (cdr (assq 'action p2))))
11139 (and c1 c2 (string< c1 c2))))
11141 (defun gnus-request-pseudo-article (props)
11142 (cond ((assq 'execute props)
11143 (gnus-execute-command (cdr (assq 'execute props)))))
11144 (let ((gnus-current-article (gnus-summary-article-number)))
11145 (gnus-run-hooks 'gnus-mark-article-hook)))
11147 (defun gnus-execute-command (command &optional automatic)
11149 (gnus-article-setup-buffer)
11150 (set-buffer gnus-article-buffer)
11151 (setq buffer-read-only nil)
11152 (let ((command (if automatic command
11153 (read-string "Command: " (cons command 0)))))
11155 (insert "$ " command "\n\n")
11156 (if gnus-view-pseudo-asynchronously
11157 (start-process "gnus-execute" (current-buffer) shell-file-name
11158 shell-command-switch command)
11159 (call-process shell-file-name nil t nil
11160 shell-command-switch command)))))
11162 ;; Summary kill commands.
11164 (defun gnus-summary-edit-global-kill (article)
11165 "Edit the \"global\" kill file."
11166 (interactive (list (gnus-summary-article-number)))
11167 (gnus-group-edit-global-kill article))
11169 (defun gnus-summary-edit-local-kill ()
11170 "Edit a local kill file applied to the current newsgroup."
11172 (setq gnus-current-headers (gnus-summary-article-header))
11173 (gnus-group-edit-local-kill
11174 (gnus-summary-article-number) gnus-newsgroup-name))
11176 ;;; Header reading.
11178 (defun gnus-read-header (id &optional header)
11179 "Read the headers of article ID and enter them into the Gnus system."
11180 (let ((group gnus-newsgroup-name)
11181 (gnus-override-method
11183 gnus-override-method
11184 (and (gnus-news-group-p gnus-newsgroup-name)
11185 (car (gnus-refer-article-methods)))))
11187 ;; First we check to see whether the header in question is already
11190 ;; This is a Message-ID.
11191 (setq header (or header (gnus-id-to-header id)))
11192 ;; This is an article number.
11193 (setq header (or header (gnus-summary-article-header id))))
11195 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11196 ;; We have found the header.
11198 ;; If this is a sparse article, we have to nix out its
11199 ;; previous entry in the thread hashtb.
11201 (gnus-summary-article-sparse-p (mail-header-number header)))
11202 (let* ((parent (gnus-parent-id (mail-header-references header)))
11203 (thread (and parent (gnus-id-to-thread parent))))
11205 (delq (assq header thread) thread))))
11206 ;; We have to really fetch the header to this article.
11208 (set-buffer nntp-server-buffer)
11209 (when (setq where (gnus-request-head id group))
11210 (nnheader-fold-continuation-lines)
11211 (goto-char (point-max))
11213 (goto-char (point-min))
11217 ((cdr where) (cdr where))
11218 (header (mail-header-number header))
11219 (t gnus-reffed-article-number))
11221 (insert " Article retrieved.\n"))
11222 (if (or (not where)
11223 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11224 () ; Malformed head.
11225 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11226 (when (and (stringp id)
11227 (not (string= (gnus-group-real-name group)
11229 ;; If we fetched by Message-ID and the article came
11230 ;; from a different group, we fudge some bogus article
11231 ;; numbers for this article.
11232 (mail-header-set-number header gnus-reffed-article-number))
11234 (set-buffer gnus-summary-buffer)
11235 (decf gnus-reffed-article-number)
11236 (gnus-remove-header (mail-header-number header))
11237 (push header gnus-newsgroup-headers)
11238 (setq gnus-current-headers header)
11239 (push (mail-header-number header) gnus-newsgroup-limit)))
11242 (defun gnus-remove-header (number)
11243 "Remove header NUMBER from `gnus-newsgroup-headers'."
11244 (if (and gnus-newsgroup-headers
11245 (= number (mail-header-number (car gnus-newsgroup-headers))))
11246 (pop gnus-newsgroup-headers)
11247 (let ((headers gnus-newsgroup-headers))
11248 (while (and (cdr headers)
11249 (not (= number (mail-header-number (cadr headers)))))
11251 (when (cdr headers)
11252 (setcdr headers (cddr headers))))))
11255 ;;; summary highlights
11258 (defun gnus-highlight-selected-summary ()
11259 "Highlight selected article in summary buffer."
11260 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11261 (when gnus-summary-selected-face
11263 (let* ((beg (gnus-point-at-bol))
11264 (end (gnus-point-at-eol))
11265 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11266 (from (if (get-text-property beg gnus-mouse-face-prop)
11268 (or (next-single-property-change
11269 beg gnus-mouse-face-prop nil end)
11274 (or (next-single-property-change
11275 from gnus-mouse-face-prop nil end)
11277 ;; If no mouse-face prop on line we will have to = from = end,
11278 ;; so we highlight the entire line instead.
11279 (when (= (+ to 2) from)
11282 (if gnus-newsgroup-selected-overlay
11283 ;; Move old overlay.
11285 gnus-newsgroup-selected-overlay from to (current-buffer))
11286 ;; Create new overlay.
11288 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11289 'face gnus-summary-selected-face))))))
11291 (defvar gnus-summary-highlight-line-cached nil)
11292 (defvar gnus-summary-highlight-line-trigger nil)
11294 (defun gnus-summary-highlight-line-0 ()
11295 (if (and (eq gnus-summary-highlight-line-trigger
11296 gnus-summary-highlight)
11297 gnus-summary-highlight-line-cached)
11298 gnus-summary-highlight-line-cached
11299 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11300 gnus-summary-highlight-line-cached
11301 (let* ((cond (list 'cond))
11303 (list gnus-summary-highlight))
11305 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11309 (gnus-byte-compile (list 'lambda nil cond))))))
11311 (defun gnus-summary-highlight-line ()
11312 "Highlight current line according to `gnus-summary-highlight'."
11313 (let* ((beg (gnus-point-at-bol))
11314 (article (or (gnus-summary-article-number) gnus-current-article))
11315 (score (or (cdr (assq article
11316 gnus-newsgroup-scored))
11317 gnus-summary-default-score 0))
11318 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11319 (inhibit-read-only t)
11320 (default gnus-summary-default-score)
11321 (default-high gnus-summary-default-high-score)
11322 (default-low gnus-summary-default-low-score)
11323 (uncached (and gnus-summary-use-undownloaded-faces
11324 (memq article gnus-newsgroup-undownloaded))))
11325 (let ((face (funcall (gnus-summary-highlight-line-0))))
11326 (unless (eq face (get-text-property beg 'face))
11327 (gnus-put-text-property-excluding-characters-with-faces
11328 beg (gnus-point-at-eol) 'face
11329 (setq face (if (boundp face) (symbol-value face) face)))
11330 (when gnus-summary-highlight-line-function
11331 (funcall gnus-summary-highlight-line-function article face))))))
11333 (defun gnus-update-read-articles (group unread &optional compute)
11334 "Update the list of read articles in GROUP.
11335 UNREAD is a sorted list."
11336 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11337 (entry (gnus-gethash group gnus-newsrc-hashtb))
11338 (info (nth 2 entry))
11341 (if (or (not info) (not active))
11342 ;; There is no info on this group if it was, in fact,
11343 ;; killed. Gnus stores no information on killed groups, so
11344 ;; there's nothing to be done.
11345 ;; One could store the information somewhere temporarily,
11346 ;; perhaps... Hmmm...
11348 ;; Remove any negative articles numbers.
11349 (while (and unread (< (car unread) 0))
11350 (setq unread (cdr unread)))
11351 ;; Remove any expired article numbers
11352 (while (and unread (< (car unread) (car active)))
11353 (setq unread (cdr unread)))
11354 ;; Compute the ranges of read articles by looking at the list of
11355 ;; unread articles.
11357 (when (/= (car unread) prev)
11358 (push (if (= prev (1- (car unread))) prev
11359 (cons prev (1- (car unread))))
11361 (setq prev (1+ (car unread)))
11362 (setq unread (cdr unread)))
11363 (when (<= prev (cdr active))
11364 (push (cons prev (cdr active)) read))
11365 (setq read (if (> (length read) 1) (nreverse read) read))
11370 ;; Propagate the read marks to the backend.
11371 (when (gnus-check-backend-function 'request-set-mark group)
11372 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11373 (add (gnus-remove-from-range read (gnus-info-read info))))
11375 (unless (gnus-check-group group)
11376 (error "Can't open server for %s" group))
11377 (gnus-request-set-mark
11378 group (delq nil (list (if add (list add 'add '(read)))
11379 (if del (list del 'del '(read))))))
11381 `(gnus-request-set-mark
11384 (if del (list del 'add '(read)))
11385 (if add (list add 'del '(read))))))))))
11386 (set-buffer gnus-group-buffer)
11387 (gnus-undo-register
11389 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11390 (gnus-info-set-read ',info ',(gnus-info-read info))
11391 (gnus-get-unread-articles-in-group ',info
11392 (gnus-active ,group))
11393 (gnus-group-update-group ,group t)
11395 ;; Enter this list into the group info.
11396 (gnus-info-set-read info read)
11397 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11398 (gnus-get-unread-articles-in-group info (gnus-active group))
11401 (defun gnus-offer-save-summaries ()
11402 "Offer to save all active summary buffers."
11404 ;; Go through all buffers and find all summaries.
11405 (dolist (buffer (buffer-list))
11406 (when (and (setq buffer (buffer-name buffer))
11407 (string-match "Summary" buffer)
11409 (set-buffer buffer)
11410 ;; We check that this is, indeed, a summary buffer.
11411 (and (eq major-mode 'gnus-summary-mode)
11412 ;; Also make sure this isn't bogus.
11413 gnus-newsgroup-prepared
11414 ;; Also make sure that this isn't a
11415 ;; dead summary buffer.
11416 (not gnus-dead-summary-mode))))
11417 (push buffer buffers)))
11418 ;; Go through all these summary buffers and offer to save them.
11422 "Update summary buffer %s? "
11424 (switch-to-buffer buf)
11425 (gnus-summary-exit))
11429 ;;; @ for mime-partial
11432 (defun gnus-request-partial-message ()
11434 (let ((number (gnus-summary-article-number))
11435 (group gnus-newsgroup-name)
11436 (mother gnus-article-buffer))
11437 (set-buffer (get-buffer-create " *Partial Article*"))
11439 (setq mime-preview-buffer mother)
11440 (gnus-request-article-this-buffer number group)
11441 (mime-parse-buffer)
11444 (autoload 'mime-combine-message/partial-pieces-automatically
11446 "Internal method to combine message/partial messages automatically.")
11448 (mime-add-condition
11449 'action '((type . message)(subtype . partial)
11450 (major-mode . gnus-original-article-mode)
11451 (method . mime-combine-message/partial-pieces-automatically)
11452 (summary-buffer-exp . gnus-summary-buffer)
11453 (request-partial-message-method . gnus-request-partial-message)
11457 ;;; @ for message/rfc822
11460 (defun gnus-mime-extract-message/rfc822 (entity situation)
11461 "Burst a forwarded article."
11463 (set-buffer gnus-summary-buffer)
11464 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11465 gnus-newsgroup-name 'gnus-group-history))
11466 (gnus-group-marked (list group))
11469 (mime-insert-entity-content entity)
11470 (setq article (gnus-request-accept-article group)))
11471 (when (and (consp article)
11472 (numberp (setq article (cdr article))))
11473 (setq info (gnus-get-info group))
11474 (gnus-info-set-read info
11475 (gnus-remove-from-range (gnus-info-read info)
11477 (when (string-equal group gnus-newsgroup-name)
11479 (let (gnus-show-threads)
11480 (gnus-summary-goto-subject article t))
11481 (gnus-summary-clear-mark-forward 1))
11482 (set-buffer gnus-group-buffer)
11483 (gnus-group-get-new-news-this-group nil t)))))
11485 (mime-add-condition
11486 'action '((type . message)(subtype . rfc822)
11487 (major-mode . gnus-original-article-mode)
11488 (method . gnus-mime-extract-message/rfc822)
11492 (mime-add-condition
11493 'action '((type . message)(subtype . news)
11494 (major-mode . gnus-original-article-mode)
11495 (method . gnus-mime-extract-message/rfc822)
11499 (defun gnus-mime-extract-multipart (entity situation)
11500 (let ((children (mime-entity-children entity))
11501 mime-acting-situation-to-override
11504 (mime-play-entity (car children)
11505 (cons (assq 'mode situation)
11506 mime-acting-situation-to-override))
11507 (setq children (cdr children)))
11508 (if (setq f (cdr (assq 'after-method
11509 mime-acting-situation-to-override)))
11513 (mime-add-condition
11514 'action '((type . multipart)
11515 (method . gnus-mime-extract-multipart)
11524 (defun gnus-summary-inherit-default-charset ()
11525 "Import `default-mime-charset' from summary buffer.
11526 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11528 (if (buffer-live-p gnus-summary-buffer)
11529 (let (d-m-c d-m-c-u)
11530 (with-current-buffer gnus-summary-buffer
11531 (setq d-m-c (if (local-variable-p 'default-mime-charset
11532 gnus-summary-buffer)
11533 default-mime-charset
11536 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11537 gnus-summary-buffer)
11538 (symbol-value 'default-mime-charset-unlimited)
11541 (kill-local-variable 'default-mime-charset)
11542 (set (make-local-variable 'default-mime-charset) d-m-c))
11544 (kill-local-variable 'default-mime-charset-unlimited)
11545 (set (make-local-variable 'default-mime-charset-unlimited)
11548 (defun gnus-summary-setup-default-charset ()
11549 "Setup newsgroup default charset."
11550 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11552 (setq gnus-newsgroup-charset nil)
11553 (set (make-local-variable 'default-mime-charset) nil)
11554 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11555 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11556 (let ((ignored-charsets
11557 (or gnus-newsgroup-ephemeral-ignored-charsets
11559 (and gnus-newsgroup-name
11560 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11561 gnus-newsgroup-ignored-charsets)))
11563 (setq gnus-newsgroup-charset
11564 (or gnus-newsgroup-ephemeral-charset
11565 (when (and gnus-newsgroup-name
11566 (setq charset (gnus-parameter-charset
11567 gnus-newsgroup-name)))
11568 (make-local-variable 'default-mime-charset)
11569 (setq default-mime-charset charset))
11570 gnus-default-charset))
11571 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11572 ignored-charsets))))
11578 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11579 "Display the current article buffer fully MIME-buttonized.
11580 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11581 treated as multipart/mixed."
11583 (require 'gnus-art)
11584 (let ((gnus-unbuttonized-mime-types nil)
11585 (gnus-mime-display-multipart-as-mixed show-all-parts))
11586 (gnus-summary-show-article)))
11588 (defun gnus-summary-repair-multipart (article)
11589 "Add a Content-Type header to a multipart article without one."
11590 (interactive (list (gnus-summary-article-number)))
11591 (gnus-with-article article
11592 (message-narrow-to-head)
11593 (message-remove-header "Mime-Version")
11594 (goto-char (point-max))
11595 (insert "Mime-Version: 1.0\n")
11597 (when (search-forward "\n--" nil t)
11598 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11599 (message-narrow-to-head)
11600 (message-remove-header "Content-Type")
11601 (goto-char (point-max))
11602 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11605 (let (gnus-mark-article-hook)
11606 (gnus-summary-select-article t t nil article)))
11608 (defun gnus-summary-toggle-display-buttonized ()
11609 "Toggle the buttonizing of the article buffer."
11611 (require 'gnus-art)
11612 (if (setq gnus-inhibit-mime-unbuttonizing
11613 (not gnus-inhibit-mime-unbuttonizing))
11614 (let ((gnus-unbuttonized-mime-types nil))
11615 (gnus-summary-show-article))
11616 (gnus-summary-show-article)))
11619 ;;; Intelli-mouse commmands
11622 (defun gnus-wheel-summary-scroll (event)
11624 (let ((amount (if (memq 'shift (event-modifiers event))
11625 (car gnus-wheel-scroll-amount)
11626 (cdr gnus-wheel-scroll-amount)))
11627 (direction (- (* (static-if (featurep 'xemacs)
11628 (event-button event)
11629 (cond ((eq 'mouse-4 (event-basic-type event))
11631 ((eq 'mouse-5 (event-basic-type event))
11635 (gnus-summary-scroll-up (* amount direction))
11636 (when (gnus-eval-in-buffer-window gnus-article-buffer
11639 (and (if (< 0 direction)
11640 (gnus-article-next-page 0)
11641 (gnus-article-prev-page 0)
11643 (if (setq edge (get-text-property
11644 (point-min) 'gnus-wheel-edge))
11645 (setq edge (* edge direction))
11648 (let ((buffer-read-only nil)
11649 (inhibit-read-only t))
11650 (put-text-property (point-min) (point-max)
11651 'gnus-wheel-edge direction)
11653 (or (> edge gnus-wheel-edge-resistance)
11654 (let ((buffer-read-only nil)
11655 (inhibit-read-only t))
11656 (put-text-property (point-min) (point-max)
11658 (* (1+ edge) direction))
11660 (eq last-command 'gnus-wheel-summary-scroll))))
11661 (gnus-summary-next-article nil nil (minusp direction)))))
11663 (defun gnus-wheel-install ()
11664 "Enable mouse wheel support on summary window."
11665 (when gnus-use-wheel
11667 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11669 (define-key gnus-summary-mode-map key
11670 'gnus-wheel-summary-scroll)))))
11672 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11675 ;;; Traditional PGP commmands
11678 (defun gnus-summary-decrypt-article (&optional force)
11679 "Decrypt the current article in traditional PGP way.
11680 This will have permanent effect only in mail groups.
11681 If FORCE is non-nil, allow editing of articles even in read-only
11684 (gnus-summary-select-article t)
11685 (gnus-eval-in-buffer-window gnus-article-buffer
11689 (goto-char (point-min))
11690 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11691 (error "Not a traditional PGP message!"))
11692 (let ((armor-start (match-beginning 0)))
11693 (if (and (pgg-decrypt-region armor-start (point-max))
11694 (or force (not (gnus-group-read-only-p))))
11695 (let ((inhibit-read-only t)
11697 (delete-region armor-start
11699 (re-search-forward "^-+END PGP" nil t)
11700 (beginning-of-line 2)
11702 (insert-buffer-substring pgg-output-buffer))))))))
11704 (defun gnus-summary-verify-article ()
11705 "Verify the current article in traditional PGP way."
11708 (set-buffer gnus-original-article-buffer)
11709 (goto-char (point-min))
11710 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11711 (error "Not a traditional PGP message!"))
11712 (re-search-forward "^-+END PGP" nil t)
11713 (beginning-of-line 2)
11714 (call-interactively (function pgg-verify-region))))
11717 ;;; Generic summary marking commands
11720 (defvar gnus-summary-marking-alist
11721 '((read gnus-del-mark "d")
11722 (unread gnus-unread-mark "u")
11723 (ticked gnus-ticked-mark "!")
11724 (dormant gnus-dormant-mark "?")
11725 (expirable gnus-expirable-mark "e"))
11726 "An alist of names/marks/keystrokes.")
11728 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11729 (defvar gnus-summary-mark-map)
11731 (defun gnus-summary-make-all-marking-commands ()
11732 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11733 (dolist (elem gnus-summary-marking-alist)
11734 (apply 'gnus-summary-make-marking-command elem)))
11736 (defun gnus-summary-make-marking-command (name mark keystroke)
11737 (let ((map (make-sparse-keymap)))
11738 (define-key gnus-summary-generic-mark-map keystroke map)
11739 (dolist (lway `((next "next" next nil "n")
11740 (next-unread "next unread" next t "N")
11741 (prev "previous" prev nil "p")
11742 (prev-unread "previous unread" prev t "P")
11743 (nomove "" nil nil ,keystroke)))
11744 (let ((func (gnus-summary-make-marking-command-1
11745 mark (car lway) lway name)))
11746 (setq func (eval func))
11747 (define-key map (nth 4 lway) func)))))
11749 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11751 (format "gnus-summary-put-mark-as-%s%s"
11752 name (if (eq way 'nomove)
11754 (concat "-" (symbol-name way)))))
11757 "Mark the current article as %s%s.
11758 If N, the prefix, then repeat N times.
11759 If N is negative, move in reverse order.
11760 The difference between N and the actual number of articles marked is
11762 name (car (cdr lway)))
11764 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11766 (defun gnus-summary-generic-mark (n mark move unread)
11767 "Mark N articles with MARK."
11768 (unless (eq major-mode 'gnus-summary-mode)
11769 (error "This command can only be used in the summary buffer"))
11770 (gnus-summary-show-thread)
11773 ((eq move 'next) 1)
11774 ((eq move 'prev) -1)
11776 (if (zerop nummove)
11780 nummove (* -1 nummove))))
11781 (while (and (> n 0)
11782 (gnus-summary-mark-article nil mark)
11783 (zerop (gnus-summary-next-subject nummove unread t)))
11786 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11787 (gnus-summary-recenter)
11788 (gnus-summary-position-point)
11789 (gnus-set-mode-line 'summary)
11792 (defun gnus-summary-insert-articles (articles)
11793 (when (setq articles
11794 (gnus-sorted-difference articles
11795 (mapcar (lambda (h)
11796 (mail-header-number h))
11797 gnus-newsgroup-headers)))
11798 (setq gnus-newsgroup-headers
11800 gnus-newsgroup-headers
11801 (gnus-fetch-headers articles)
11802 'gnus-article-sort-by-number))
11803 ;; Suppress duplicates?
11804 (when gnus-suppress-duplicates
11805 (gnus-dup-suppress-articles))
11807 ;; We might want to build some more threads first.
11808 (when (and gnus-fetch-old-headers
11809 (eq gnus-headers-retrieved-by 'nov))
11810 (if (eq gnus-fetch-old-headers 'invisible)
11811 (gnus-build-all-threads)
11812 (gnus-build-old-threads)))
11813 ;; Let the Gnus agent mark articles as read.
11815 (gnus-agent-get-undownloaded-list))
11816 ;; Remove list identifiers from subject
11817 (when gnus-list-identifiers
11818 (gnus-summary-remove-list-identifiers))
11819 ;; First and last article in this newsgroup.
11820 (when gnus-newsgroup-headers
11821 (setq gnus-newsgroup-begin
11822 (mail-header-number (car gnus-newsgroup-headers))
11824 (mail-header-number
11825 (gnus-last-element gnus-newsgroup-headers))))
11826 (when gnus-use-scoring
11827 (gnus-possibly-score-headers))))
11829 (defun gnus-summary-insert-old-articles (&optional all)
11830 "Insert all old articles in this group.
11831 If ALL is non-nil, already read articles become readable.
11832 If ALL is a number, fetch this number of articles."
11835 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11838 ;; Some nntp servers lie about their active range. When
11839 ;; this happens, the active range can be in the millions.
11840 ;; Use a compressed range to avoid creating a huge list.
11841 (gnus-range-difference (list gnus-newsgroup-active) old))
11842 (setq len (gnus-range-length older))
11847 (let ((older-range (nreverse older)))
11851 (let* ((r (pop older-range))
11852 (min (if (numberp r) r (car r)))
11853 (max (if (numberp r) r (cdr r))))
11854 (while (and (<= min max)
11859 (setq older (gnus-uncompress-range older))))
11861 (setq older (gnus-uncompress-range older)))
11863 (when (and (numberp gnus-large-newsgroup)
11864 (> len gnus-large-newsgroup))
11865 (let* ((cursor-in-echo-area nil)
11866 (initial (gnus-parameter-large-newsgroup-initial
11867 gnus-newsgroup-name))
11871 "How many articles from %s (%s %d): "
11873 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11874 (if initial "max" "default")
11877 (cons (number-to-string initial)
11879 (unless (string-match "^[ \t]*$" input)
11880 (setq all (string-to-number input))
11882 (let ((older-range (nreverse older)))
11886 (let* ((r (pop older-range))
11887 (min (if (numberp r) r (car r)))
11888 (max (if (numberp r) r (cdr r))))
11889 (while (and (<= min max)
11893 max (1- max))))))))))
11894 (setq older (gnus-uncompress-range older))))
11896 (message "No old news.")
11897 (gnus-summary-insert-articles older)
11898 (gnus-summary-limit (gnus-sorted-nunion old older))))
11899 (gnus-summary-position-point)))
11901 (defun gnus-summary-insert-new-articles ()
11902 "Insert all new articles in this group."
11905 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11906 (old-active gnus-newsgroup-active)
11907 (nnmail-fetched-sources (list t))
11909 (setq gnus-newsgroup-active
11910 (gnus-activate-group gnus-newsgroup-name 'scan))
11911 (setq i (cdr gnus-newsgroup-active))
11912 (while (> i (cdr old-active))
11916 (message "No gnus is bad news.")
11917 (gnus-summary-insert-articles new)
11918 (setq gnus-newsgroup-unreads
11919 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11920 (gnus-summary-limit (gnus-sorted-nunion old new))))
11921 (gnus-summary-position-point)))
11923 (gnus-summary-make-all-marking-commands)
11925 (gnus-ems-redefine)
11927 (provide 'gnus-sum)
11929 (run-hooks 'gnus-sum-load-hook)
11931 ;; Local Variables:
11932 ;; coding: iso-8859-1
11935 ;;; gnus-sum.el ends here