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)
1281 (defvar gnus-newsgroup-unreads nil
1282 "Sorted list of unread articles in the current newsgroup.")
1284 (defvar gnus-newsgroup-unselected nil
1285 "Sorted list of unselected unread articles in the current newsgroup.")
1287 (defvar gnus-newsgroup-reads nil
1288 "Alist of read articles and article marks in the current newsgroup.")
1290 (defvar gnus-newsgroup-expunged-tally nil)
1292 (defvar gnus-newsgroup-marked nil
1293 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1295 (defvar gnus-newsgroup-spam-marked nil
1296 "List of ranges of articles that have been marked as spam.")
1298 (defvar gnus-newsgroup-killed nil
1299 "List of ranges of articles that have been through the scoring process.")
1301 (defvar gnus-newsgroup-cached nil
1302 "Sorted list of articles that come from the article cache.")
1304 (defvar gnus-newsgroup-saved nil
1305 "List of articles that have been saved.")
1307 (defvar gnus-newsgroup-kill-headers nil)
1309 (defvar gnus-newsgroup-replied nil
1310 "List of articles that have been replied to in the current newsgroup.")
1312 (defvar gnus-newsgroup-forwarded nil
1313 "List of articles that have been forwarded in the current newsgroup.")
1315 (defvar gnus-newsgroup-recent nil
1316 "List of articles that have are recent in the current newsgroup.")
1318 (defvar gnus-newsgroup-expirable nil
1319 "Sorted list of articles in the current newsgroup that can be expired.")
1321 (defvar gnus-newsgroup-processable nil
1322 "List of articles in the current newsgroup that can be processed.")
1324 (defvar gnus-newsgroup-downloadable nil
1325 "Sorted list of articles in the current newsgroup that can be processed.")
1327 (defvar gnus-newsgroup-unfetched nil
1328 "Sorted list of articles in the current newsgroup whose headers have
1329 not been fetched into the agent.
1331 This list will always be a subset of gnus-newsgroup-undownloaded.")
1333 (defvar gnus-newsgroup-undownloaded nil
1334 "List of articles in the current newsgroup that haven't been downloaded.")
1336 (defvar gnus-newsgroup-unsendable nil
1337 "List of articles in the current newsgroup that won't be sent.")
1339 (defvar gnus-newsgroup-bookmarks nil
1340 "List of articles in the current newsgroup that have bookmarks.")
1342 (defvar gnus-newsgroup-dormant nil
1343 "Sorted list of dormant articles in the current newsgroup.")
1345 (defvar gnus-newsgroup-unseen nil
1346 "List of unseen articles in the current newsgroup.")
1348 (defvar gnus-newsgroup-seen nil
1349 "Range of seen articles in the current newsgroup.")
1351 (defvar gnus-newsgroup-articles nil
1352 "List of articles in the current newsgroup.")
1354 (defvar gnus-newsgroup-scored nil
1355 "List of scored articles in the current newsgroup.")
1357 (defvar gnus-newsgroup-incorporated nil
1358 "List of incorporated articles in the current newsgroup.")
1360 (defvar gnus-newsgroup-headers nil
1361 "List of article headers in the current newsgroup.")
1363 (defvar gnus-newsgroup-threads nil)
1365 (defvar gnus-newsgroup-prepared nil
1366 "Whether the current group has been prepared properly.")
1368 (defvar gnus-newsgroup-ancient nil
1369 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1371 (defvar gnus-newsgroup-sparse nil)
1373 (defvar gnus-current-article nil)
1374 (defvar gnus-article-current nil)
1375 (defvar gnus-current-headers nil)
1376 (defvar gnus-have-all-headers nil)
1377 (defvar gnus-last-article nil)
1378 (defvar gnus-newsgroup-history nil)
1379 (defvar gnus-newsgroup-charset nil)
1380 (defvar gnus-newsgroup-ephemeral-charset nil)
1381 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1383 (defvar gnus-article-before-search nil)
1385 (defvar gnus-summary-local-variables
1386 '(gnus-newsgroup-name
1387 gnus-newsgroup-begin gnus-newsgroup-end
1388 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1389 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1390 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1391 gnus-newsgroup-unselected gnus-newsgroup-marked
1392 gnus-newsgroup-spam-marked
1393 gnus-newsgroup-reads gnus-newsgroup-saved
1394 gnus-newsgroup-replied gnus-newsgroup-forwarded
1395 gnus-newsgroup-recent
1396 gnus-newsgroup-expirable
1397 gnus-newsgroup-processable gnus-newsgroup-killed
1398 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1399 gnus-newsgroup-unfetched
1400 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1401 gnus-newsgroup-seen gnus-newsgroup-articles
1402 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1403 gnus-newsgroup-headers gnus-newsgroup-threads
1404 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1405 gnus-current-article gnus-current-headers gnus-have-all-headers
1406 gnus-last-article gnus-article-internal-prepare-hook
1407 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1408 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1409 gnus-thread-expunge-below
1410 gnus-score-alist gnus-current-score-file
1411 (gnus-summary-expunge-below . global)
1412 (gnus-summary-mark-below . global)
1413 (gnus-orphan-score . global)
1414 gnus-newsgroup-active gnus-scores-exclude-files
1415 gnus-newsgroup-history gnus-newsgroup-ancient
1416 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1417 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1418 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1419 (gnus-newsgroup-expunged-tally . 0)
1420 gnus-cache-removable-articles gnus-newsgroup-cached
1421 gnus-newsgroup-data gnus-newsgroup-data-reverse
1422 gnus-newsgroup-limit gnus-newsgroup-limits
1423 gnus-newsgroup-charset gnus-newsgroup-display
1424 gnus-newsgroup-incorporated)
1425 "Variables that are buffer-local to the summary buffers.")
1427 (defvar gnus-newsgroup-variables nil
1428 "A list of variables that have separate values in different newsgroups.
1429 A list of newsgroup (summary buffer) local variables, or cons of
1430 variables and their default values (when the default values are not
1431 nil), that should be made global while the summary buffer is active.
1432 These variables can be used to set variables in the group parameters
1433 while still allowing them to affect operations done in other
1434 buffers. For example:
1436 \(setq gnus-newsgroup-variables
1437 '(message-use-followup-to
1438 (gnus-visible-headers .
1439 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1442 ;; Byte-compiler warning.
1444 ;; Bind features so that require will believe that gnus-sum has
1445 ;; already been loaded (avoids infinite recursion)
1446 (let ((features (cons 'gnus-sum features)))
1447 ;; Several of the declarations in gnus-sum are needed to load the
1448 ;; following files. Right now, these definitions have been
1449 ;; compiled but not defined (evaluated). We could either do a
1450 ;; eval-and-compile about all of the declarations or evaluate the
1452 (if (boundp 'gnus-newsgroup-variables)
1454 (load "gnus-sum.el" t t t))
1456 (require 'gnus-agent)
1457 (require 'gnus-art)))
1459 ;; Subject simplification.
1461 (defun gnus-simplify-whitespace (str)
1462 "Remove excessive whitespace from STR."
1464 (while (string-match "[ \t][ \t]+" str)
1465 (setq str (concat (substring str 0 (match-beginning 0))
1467 (substring str (match-end 0)))))
1469 (when (string-match "^[ \t]+" str)
1470 (setq str (substring str (match-end 0))))
1472 (when (string-match "[ \t]+$" str)
1473 (setq str (substring str 0 (match-beginning 0))))
1476 (defun gnus-simplify-all-whitespace (str)
1477 "Remove all whitespace from STR."
1478 (while (string-match "[ \t\n]+" str)
1479 (setq str (replace-match "" nil nil str)))
1482 (defsubst gnus-simplify-subject-re (subject)
1483 "Remove \"Re:\" from subject lines."
1484 (if (string-match message-subject-re-regexp subject)
1485 (substring subject (match-end 0))
1488 (defun gnus-simplify-subject (subject &optional re-only)
1489 "Remove `Re:' and words in parentheses.
1490 If RE-ONLY is non-nil, strip leading `Re:'s only."
1491 (let ((case-fold-search t)) ;Ignore case.
1492 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1493 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1494 (setq subject (substring subject (match-end 0))))
1495 ;; Remove uninteresting prefixes.
1496 (when (and (not re-only)
1497 gnus-simplify-ignored-prefixes
1498 (string-match gnus-simplify-ignored-prefixes subject))
1499 (setq subject (substring subject (match-end 0))))
1500 ;; Remove words in parentheses from end.
1502 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1503 (setq subject (substring subject 0 (match-beginning 0)))))
1504 ;; Return subject string.
1507 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1509 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1510 (goto-char (point-min))
1511 (while (re-search-forward regexp nil t)
1512 (replace-match (or newtext ""))))
1514 (defun gnus-simplify-buffer-fuzzy ()
1515 "Simplify string in the buffer fuzzily.
1516 The string in the accessible portion of the current buffer is simplified.
1517 It is assumed to be a single-line subject.
1518 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1519 matter is removed. Additional things can be deleted by setting
1520 `gnus-simplify-subject-fuzzy-regexp'."
1521 (let ((case-fold-search t)
1523 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1525 (while (not (eq modified-tick (buffer-modified-tick)))
1526 (setq modified-tick (buffer-modified-tick))
1528 ((listp gnus-simplify-subject-fuzzy-regexp)
1529 (mapcar 'gnus-simplify-buffer-fuzzy-step
1530 gnus-simplify-subject-fuzzy-regexp))
1531 (gnus-simplify-subject-fuzzy-regexp
1532 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1533 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1534 (gnus-simplify-buffer-fuzzy-step
1535 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1536 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1538 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1539 (gnus-simplify-buffer-fuzzy-step " +" " ")
1540 (gnus-simplify-buffer-fuzzy-step " $")
1541 (gnus-simplify-buffer-fuzzy-step "^ +")))
1543 (defun gnus-simplify-subject-fuzzy (subject)
1544 "Simplify a subject string fuzzily.
1545 See `gnus-simplify-buffer-fuzzy' for details."
1547 (gnus-set-work-buffer)
1548 (let ((case-fold-search t))
1549 ;; Remove uninteresting prefixes.
1550 (when (and gnus-simplify-ignored-prefixes
1551 (string-match gnus-simplify-ignored-prefixes subject))
1552 (setq subject (substring subject (match-end 0))))
1554 (inline (gnus-simplify-buffer-fuzzy))
1557 (defsubst gnus-simplify-subject-fully (subject)
1558 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1560 (gnus-simplify-subject-functions
1561 (gnus-map-function gnus-simplify-subject-functions subject))
1562 ((null gnus-summary-gather-subject-limit)
1563 (gnus-simplify-subject-re subject))
1564 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1565 (gnus-simplify-subject-fuzzy subject))
1566 ((numberp gnus-summary-gather-subject-limit)
1567 (gnus-limit-string (gnus-simplify-subject-re subject)
1568 gnus-summary-gather-subject-limit))
1572 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1573 "Check whether two subjects are equal.
1574 If optional argument SIMPLE-FIRST is t, first argument is already
1577 ((null simple-first)
1578 (equal (gnus-simplify-subject-fully s1)
1579 (gnus-simplify-subject-fully s2)))
1582 (gnus-simplify-subject-fully s2)))))
1584 (defun gnus-summary-bubble-group ()
1585 "Increase the score of the current group.
1586 This is a handy function to add to `gnus-summary-exit-hook' to
1587 increase the score of each group you read."
1588 (gnus-group-add-score gnus-newsgroup-name))
1592 ;;; Gnus summary mode
1595 (put 'gnus-summary-mode 'mode-class 'special)
1597 (defvar gnus-article-commands-menu)
1599 ;; Non-orthogonal keys
1601 (gnus-define-keys gnus-summary-mode-map
1602 " " gnus-summary-next-page
1603 "\177" gnus-summary-prev-page
1604 [delete] gnus-summary-prev-page
1605 [backspace] gnus-summary-prev-page
1606 "\r" gnus-summary-scroll-up
1607 "\M-\r" gnus-summary-scroll-down
1608 "n" gnus-summary-next-unread-article
1609 "p" gnus-summary-prev-unread-article
1610 "N" gnus-summary-next-article
1611 "P" gnus-summary-prev-article
1612 "\M-\C-n" gnus-summary-next-same-subject
1613 "\M-\C-p" gnus-summary-prev-same-subject
1614 "\M-n" gnus-summary-next-unread-subject
1615 "\M-p" gnus-summary-prev-unread-subject
1616 "." gnus-summary-first-unread-article
1617 "," gnus-summary-best-unread-article
1618 "\M-s" gnus-summary-search-article-forward
1619 "\M-r" gnus-summary-search-article-backward
1620 "<" gnus-summary-beginning-of-article
1621 ">" gnus-summary-end-of-article
1622 "j" gnus-summary-goto-article
1623 "^" gnus-summary-refer-parent-article
1624 "\M-^" gnus-summary-refer-article
1625 "u" gnus-summary-tick-article-forward
1626 "!" gnus-summary-tick-article-forward
1627 "U" gnus-summary-tick-article-backward
1628 "d" gnus-summary-mark-as-read-forward
1629 "D" gnus-summary-mark-as-read-backward
1630 "E" gnus-summary-mark-as-expirable
1631 "\M-u" gnus-summary-clear-mark-forward
1632 "\M-U" gnus-summary-clear-mark-backward
1633 "k" gnus-summary-kill-same-subject-and-select
1634 "\C-k" gnus-summary-kill-same-subject
1635 "\M-\C-k" gnus-summary-kill-thread
1636 "\M-\C-l" gnus-summary-lower-thread
1637 "e" gnus-summary-edit-article
1638 "#" gnus-summary-mark-as-processable
1639 "\M-#" gnus-summary-unmark-as-processable
1640 "\M-\C-t" gnus-summary-toggle-threads
1641 "\M-\C-s" gnus-summary-show-thread
1642 "\M-\C-h" gnus-summary-hide-thread
1643 "\M-\C-f" gnus-summary-next-thread
1644 "\M-\C-b" gnus-summary-prev-thread
1645 [(meta down)] gnus-summary-next-thread
1646 [(meta up)] gnus-summary-prev-thread
1647 "\M-\C-u" gnus-summary-up-thread
1648 "\M-\C-d" gnus-summary-down-thread
1649 "&" gnus-summary-execute-command
1650 "c" gnus-summary-catchup-and-exit
1651 "\C-w" gnus-summary-mark-region-as-read
1652 "\C-t" gnus-summary-toggle-truncation
1653 "?" gnus-summary-mark-as-dormant
1654 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1655 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1656 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1657 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1658 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1659 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1660 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1661 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1662 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1663 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1664 "=" gnus-summary-expand-window
1665 "\C-x\C-s" gnus-summary-reselect-current-group
1666 "\M-g" gnus-summary-rescan-group
1667 "w" gnus-summary-stop-page-breaking
1668 "\C-c\C-r" gnus-summary-caesar-message
1669 "\M-t" gnus-summary-toggle-mime
1670 "f" gnus-summary-followup
1671 "F" gnus-summary-followup-with-original
1672 "C" gnus-summary-cancel-article
1673 "r" gnus-summary-reply
1674 "R" gnus-summary-reply-with-original
1675 "\C-c\C-f" gnus-summary-mail-forward
1676 "o" gnus-summary-save-article
1677 "\C-o" gnus-summary-save-article-mail
1678 "|" gnus-summary-pipe-output
1679 "\M-k" gnus-summary-edit-local-kill
1680 "\M-K" gnus-summary-edit-global-kill
1682 "\C-c\C-d" gnus-summary-describe-group
1683 "q" gnus-summary-exit
1684 "Q" gnus-summary-exit-no-update
1685 "\C-c\C-i" gnus-info-find-node
1686 gnus-mouse-2 gnus-mouse-pick-article
1687 "m" gnus-summary-mail-other-window
1688 "a" gnus-summary-post-news
1689 "i" gnus-summary-news-other-window
1690 "x" gnus-summary-limit-to-unread
1691 "s" gnus-summary-isearch-article
1692 "t" gnus-summary-toggle-header
1693 "g" gnus-summary-show-article
1694 "l" gnus-summary-goto-last-article
1695 "v" gnus-summary-preview-mime-message
1696 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1697 "\C-d" gnus-summary-enter-digest-group
1698 "\M-\C-d" gnus-summary-read-document
1699 "\M-\C-e" gnus-summary-edit-parameters
1700 "\M-\C-a" gnus-summary-customize-parameters
1702 "\C-c\C-n" gnus-namazu-search
1703 "*" gnus-cache-enter-article
1704 "\M-*" gnus-cache-remove-article
1705 "\M-&" gnus-summary-universal-argument
1706 "\C-l" gnus-recenter
1707 "I" gnus-summary-increase-score
1708 "L" gnus-summary-lower-score
1709 "\M-i" gnus-symbolic-argument
1710 "h" gnus-summary-select-article-buffer
1712 "V" gnus-summary-score-map
1713 "X" gnus-uu-extract-map
1714 "S" gnus-summary-send-map)
1716 ;; Sort of orthogonal keymap
1717 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1718 "t" gnus-summary-tick-article-forward
1719 "!" gnus-summary-tick-article-forward
1720 "d" gnus-summary-mark-as-read-forward
1721 "r" gnus-summary-mark-as-read-forward
1722 "c" gnus-summary-clear-mark-forward
1723 " " gnus-summary-clear-mark-forward
1724 "e" gnus-summary-mark-as-expirable
1725 "x" gnus-summary-mark-as-expirable
1726 "?" gnus-summary-mark-as-dormant
1727 "b" gnus-summary-set-bookmark
1728 "B" gnus-summary-remove-bookmark
1729 "#" gnus-summary-mark-as-processable
1730 "\M-#" gnus-summary-unmark-as-processable
1731 "S" gnus-summary-limit-include-expunged
1732 "C" gnus-summary-catchup
1733 "H" gnus-summary-catchup-to-here
1734 "h" gnus-summary-catchup-from-here
1735 "\C-c" gnus-summary-catchup-all
1736 "k" gnus-summary-kill-same-subject-and-select
1737 "K" gnus-summary-kill-same-subject
1738 "P" gnus-uu-mark-map)
1740 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1741 "c" gnus-summary-clear-above
1742 "u" gnus-summary-tick-above
1743 "m" gnus-summary-mark-above
1744 "k" gnus-summary-kill-below)
1746 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1747 "/" gnus-summary-limit-to-subject
1748 "n" gnus-summary-limit-to-articles
1749 "w" gnus-summary-pop-limit
1750 "s" gnus-summary-limit-to-subject
1751 "a" gnus-summary-limit-to-author
1752 "u" gnus-summary-limit-to-unread
1753 "m" gnus-summary-limit-to-marks
1754 "M" gnus-summary-limit-exclude-marks
1755 "v" gnus-summary-limit-to-score
1756 "*" gnus-summary-limit-include-cached
1757 "D" gnus-summary-limit-include-dormant
1758 "T" gnus-summary-limit-include-thread
1759 "d" gnus-summary-limit-exclude-dormant
1760 "t" gnus-summary-limit-to-age
1761 "." gnus-summary-limit-to-unseen
1762 "x" gnus-summary-limit-to-extra
1763 "p" gnus-summary-limit-to-display-predicate
1764 "E" gnus-summary-limit-include-expunged
1765 "c" gnus-summary-limit-exclude-childless-dormant
1766 "C" gnus-summary-limit-mark-excluded-as-read
1767 "o" gnus-summary-insert-old-articles
1768 "N" gnus-summary-insert-new-articles)
1770 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1771 "n" gnus-summary-next-unread-article
1772 "p" gnus-summary-prev-unread-article
1773 "N" gnus-summary-next-article
1774 "P" gnus-summary-prev-article
1775 "\C-n" gnus-summary-next-same-subject
1776 "\C-p" gnus-summary-prev-same-subject
1777 "\M-n" gnus-summary-next-unread-subject
1778 "\M-p" gnus-summary-prev-unread-subject
1779 "f" gnus-summary-first-unread-article
1780 "b" gnus-summary-best-unread-article
1781 "j" gnus-summary-goto-article
1782 "g" gnus-summary-goto-subject
1783 "l" gnus-summary-goto-last-article
1784 "o" gnus-summary-pop-article)
1786 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1787 "k" gnus-summary-kill-thread
1788 "l" gnus-summary-lower-thread
1789 "i" gnus-summary-raise-thread
1790 "T" gnus-summary-toggle-threads
1791 "t" gnus-summary-rethread-current
1792 "^" gnus-summary-reparent-thread
1793 "s" gnus-summary-show-thread
1794 "S" gnus-summary-show-all-threads
1795 "h" gnus-summary-hide-thread
1796 "H" gnus-summary-hide-all-threads
1797 "n" gnus-summary-next-thread
1798 "p" gnus-summary-prev-thread
1799 "u" gnus-summary-up-thread
1800 "o" gnus-summary-top-thread
1801 "d" gnus-summary-down-thread
1802 "#" gnus-uu-mark-thread
1803 "\M-#" gnus-uu-unmark-thread)
1805 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1806 "g" gnus-summary-prepare
1807 "c" gnus-summary-insert-cached-articles
1808 "d" gnus-summary-insert-dormant-articles)
1810 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1811 "c" gnus-summary-catchup-and-exit
1812 "C" gnus-summary-catchup-all-and-exit
1813 "E" gnus-summary-exit-no-update
1814 "J" gnus-summary-jump-to-other-group
1815 "Q" gnus-summary-exit
1816 "Z" gnus-summary-exit
1817 "n" gnus-summary-catchup-and-goto-next-group
1818 "R" gnus-summary-reselect-current-group
1819 "G" gnus-summary-rescan-group
1820 "N" gnus-summary-next-group
1821 "s" gnus-summary-save-newsrc
1822 "P" gnus-summary-prev-group)
1824 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1825 " " gnus-summary-next-page
1826 "n" gnus-summary-next-page
1827 "\177" gnus-summary-prev-page
1828 [delete] gnus-summary-prev-page
1829 "p" gnus-summary-prev-page
1830 "\r" gnus-summary-scroll-up
1831 "\M-\r" gnus-summary-scroll-down
1832 "<" gnus-summary-beginning-of-article
1833 ">" gnus-summary-end-of-article
1834 "b" gnus-summary-beginning-of-article
1835 "e" gnus-summary-end-of-article
1836 "^" gnus-summary-refer-parent-article
1837 "r" gnus-summary-refer-parent-article
1838 "D" gnus-summary-enter-digest-group
1839 "R" gnus-summary-refer-references
1840 "T" gnus-summary-refer-thread
1841 "g" gnus-summary-show-article
1842 "s" gnus-summary-isearch-article
1843 "P" gnus-summary-print-article
1844 "M" gnus-mailing-list-insinuate
1845 "t" gnus-article-babel)
1847 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1848 "b" gnus-article-add-buttons
1849 "B" gnus-article-add-buttons-to-head
1850 "o" gnus-article-treat-overstrike
1851 "e" gnus-article-emphasize
1852 "w" gnus-article-fill-cited-article
1853 "Q" gnus-article-fill-long-lines
1854 "C" gnus-article-capitalize-sentences
1855 "c" gnus-article-remove-cr
1856 "Z" gnus-article-decode-HZ
1857 "h" gnus-article-wash-html
1858 "u" gnus-article-unsplit-urls
1859 "f" gnus-article-display-x-face
1860 "l" gnus-summary-stop-page-breaking
1861 "r" gnus-summary-caesar-message
1862 "m" gnus-summary-morse-message
1863 "t" gnus-summary-toggle-header
1864 "g" gnus-treat-smiley
1865 "v" gnus-summary-verbose-headers
1866 "m" gnus-summary-toggle-mime
1867 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1868 "p" gnus-article-verify-x-pgp-sig
1869 "d" gnus-article-treat-dumbquotes)
1871 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1872 ;; mnemonic: deuglif*Y*
1873 "u" gnus-article-outlook-unwrap-lines
1874 "a" gnus-article-outlook-repair-attribution
1875 "c" gnus-article-outlook-rearrange-citation
1876 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1878 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1879 "a" gnus-article-hide
1880 "h" gnus-article-hide-headers
1881 "b" gnus-article-hide-boring-headers
1882 "s" gnus-article-hide-signature
1883 "c" gnus-article-hide-citation
1884 "C" gnus-article-hide-citation-in-followups
1885 "l" gnus-article-hide-list-identifiers
1886 "B" gnus-article-strip-banner
1887 "P" gnus-article-hide-pem
1888 "\C-c" gnus-article-hide-citation-maybe)
1890 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1891 "a" gnus-article-highlight
1892 "h" gnus-article-highlight-headers
1893 "c" gnus-article-highlight-citation
1894 "s" gnus-article-highlight-signature)
1896 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1897 "f" gnus-article-treat-fold-headers
1898 "u" gnus-article-treat-unfold-headers
1899 "n" gnus-article-treat-fold-newsgroups)
1901 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1902 "x" gnus-article-display-x-face
1903 "d" gnus-article-display-face
1904 "s" gnus-treat-smiley
1905 "D" gnus-article-remove-images
1906 "f" gnus-treat-from-picon
1907 "m" gnus-treat-mail-picon
1908 "n" gnus-treat-newsgroups-picon)
1910 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1911 "z" gnus-article-date-ut
1912 "u" gnus-article-date-ut
1913 "l" gnus-article-date-local
1914 "p" gnus-article-date-english
1915 "e" gnus-article-date-lapsed
1916 "o" gnus-article-date-original
1917 "i" gnus-article-date-iso8601
1918 "s" gnus-article-date-user)
1920 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1921 "t" gnus-article-remove-trailing-blank-lines
1922 "l" gnus-article-strip-leading-blank-lines
1923 "m" gnus-article-strip-multiple-blank-lines
1924 "a" gnus-article-strip-blank-lines
1925 "A" gnus-article-strip-all-blank-lines
1926 "s" gnus-article-strip-leading-space
1927 "e" gnus-article-strip-trailing-space
1928 "w" gnus-article-remove-leading-whitespace)
1930 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1932 "f" gnus-summary-fetch-faq
1933 "d" gnus-summary-describe-group
1934 "h" gnus-summary-describe-briefly
1935 "i" gnus-info-find-node
1936 "c" gnus-group-fetch-charter
1937 "C" gnus-group-fetch-control)
1939 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1940 "e" gnus-summary-expire-articles
1941 "\M-\C-e" gnus-summary-expire-articles-now
1942 "\177" gnus-summary-delete-article
1943 [delete] gnus-summary-delete-article
1944 [backspace] gnus-summary-delete-article
1945 "m" gnus-summary-move-article
1946 "r" gnus-summary-respool-article
1947 "w" gnus-summary-edit-article
1948 "c" gnus-summary-copy-article
1949 "B" gnus-summary-crosspost-article
1950 "q" gnus-summary-respool-query
1951 "t" gnus-summary-respool-trace
1952 "i" gnus-summary-import-article
1953 "I" gnus-summary-create-article
1954 "p" gnus-summary-article-posted-p)
1956 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1957 "o" gnus-summary-save-article
1958 "m" gnus-summary-save-article-mail
1959 "F" gnus-summary-write-article-file
1960 "r" gnus-summary-save-article-rmail
1961 "f" gnus-summary-save-article-file
1962 "b" gnus-summary-save-article-body-file
1963 "h" gnus-summary-save-article-folder
1964 "v" gnus-summary-save-article-vm
1965 "p" gnus-summary-pipe-output
1966 "P" gnus-summary-muttprint
1967 "s" gnus-soup-add-article)
1969 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1970 "b" gnus-summary-display-buttonized
1971 "m" gnus-summary-repair-multipart
1972 "v" gnus-article-view-part
1973 "o" gnus-article-save-part
1974 "c" gnus-article-copy-part
1975 "C" gnus-article-view-part-as-charset
1976 "e" gnus-article-view-part-externally
1977 "E" gnus-article-encrypt-body
1978 "i" gnus-article-inline-part
1979 "|" gnus-article-pipe-part)
1981 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1982 "p" gnus-summary-mark-as-processable
1983 "u" gnus-summary-unmark-as-processable
1984 "U" gnus-summary-unmark-all-processable
1985 "v" gnus-uu-mark-over
1986 "s" gnus-uu-mark-series
1987 "r" gnus-uu-mark-region
1988 "g" gnus-uu-unmark-region
1989 "R" gnus-uu-mark-by-regexp
1990 "G" gnus-uu-unmark-by-regexp
1991 "t" gnus-uu-mark-thread
1992 "T" gnus-uu-unmark-thread
1993 "a" gnus-uu-mark-all
1994 "b" gnus-uu-mark-buffer
1995 "S" gnus-uu-mark-sparse
1996 "k" gnus-summary-kill-process-mark
1997 "y" gnus-summary-yank-process-mark
1998 "w" gnus-summary-save-process-mark
1999 "i" gnus-uu-invert-processable)
2001 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2002 ;;"x" gnus-uu-extract-any
2003 "m" gnus-summary-save-parts
2004 "u" gnus-uu-decode-uu
2005 "U" gnus-uu-decode-uu-and-save
2006 "s" gnus-uu-decode-unshar
2007 "S" gnus-uu-decode-unshar-and-save
2008 "o" gnus-uu-decode-save
2009 "O" gnus-uu-decode-save
2010 "b" gnus-uu-decode-binhex
2011 "B" gnus-uu-decode-binhex
2012 "p" gnus-uu-decode-postscript
2013 "P" gnus-uu-decode-postscript-and-save)
2016 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2017 "u" gnus-uu-decode-uu-view
2018 "U" gnus-uu-decode-uu-and-save-view
2019 "s" gnus-uu-decode-unshar-view
2020 "S" gnus-uu-decode-unshar-and-save-view
2021 "o" gnus-uu-decode-save-view
2022 "O" gnus-uu-decode-save-view
2023 "b" gnus-uu-decode-binhex-view
2024 "B" gnus-uu-decode-binhex-view
2025 "p" gnus-uu-decode-postscript-view
2026 "P" gnus-uu-decode-postscript-and-save-view)
2028 (defvar gnus-article-post-menu nil)
2030 (defconst gnus-summary-menu-maxlen 20)
2032 (defun gnus-summary-menu-split (menu)
2033 ;; If we have lots of elements, divide them into groups of 20
2034 ;; and make a pane (or submenu) for each one.
2035 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2036 (let ((menu menu) sublists next
2039 ;; Pull off the next gnus-summary-menu-maxlen elements
2040 ;; and make them the next element of sublist.
2041 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2043 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2045 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2046 (aref (car (last menu)) 0)) menu)
2050 (nreverse sublists))
2051 ;; Few elements--put them all in one pane.
2054 (defun gnus-summary-make-menu-bar ()
2055 (gnus-turn-off-edit-menu 'summary)
2057 (unless (boundp 'gnus-summary-misc-menu)
2060 gnus-summary-kill-menu gnus-summary-mode-map ""
2065 ["Customize" gnus-score-customize t])
2066 (gnus-make-score-map 'increase)
2067 (gnus-make-score-map 'lower)
2069 ["Kill below" gnus-summary-kill-below t]
2070 ["Mark above" gnus-summary-mark-above t]
2071 ["Tick above" gnus-summary-tick-above t]
2072 ["Clear above" gnus-summary-clear-above t])
2073 ["Current score" gnus-summary-current-score t]
2074 ["Set score" gnus-summary-set-score t]
2075 ["Switch current score file..." gnus-score-change-score-file t]
2076 ["Set mark below..." gnus-score-set-mark-below t]
2077 ["Set expunge below..." gnus-score-set-expunge-below t]
2078 ["Edit current score file" gnus-score-edit-current-scores t]
2079 ["Edit score file" gnus-score-edit-file t]
2080 ["Trace score" gnus-score-find-trace t]
2081 ["Find words" gnus-score-find-favourite-words t]
2082 ["Rescore buffer" gnus-summary-rescore t]
2083 ["Increase score..." gnus-summary-increase-score t]
2084 ["Lower score..." gnus-summary-lower-score t]))))
2086 ;; Define both the Article menu in the summary buffer and the
2087 ;; equivalent Commands menu in the article buffer here for
2091 ["All" gnus-article-hide t]
2092 ["Headers" gnus-article-hide-headers t]
2093 ["Signature" gnus-article-hide-signature t]
2094 ["Citation" gnus-article-hide-citation t]
2095 ["List identifiers" gnus-article-hide-list-identifiers t]
2096 ["Banner" gnus-article-strip-banner t]
2097 ["Boring headers" gnus-article-hide-boring-headers t])
2099 ["All" gnus-article-highlight t]
2100 ["Headers" gnus-article-highlight-headers t]
2101 ["Signature" gnus-article-highlight-signature t]
2102 ["Citation" gnus-article-highlight-citation t])
2104 ["Local" gnus-article-date-local t]
2105 ["ISO8601" gnus-article-date-iso8601 t]
2106 ["UT" gnus-article-date-ut t]
2107 ["Original" gnus-article-date-original t]
2108 ["Lapsed" gnus-article-date-lapsed t]
2109 ["User-defined" gnus-article-date-user t])
2111 ["Remove images" gnus-article-remove-images t]
2112 ["Toggle smiley" gnus-treat-smiley t]
2113 ["Show X-Face" gnus-article-display-x-face t]
2114 ["Show picons in From" gnus-treat-from-picon t]
2115 ["Show picons in mail headers" gnus-treat-mail-picon t]
2116 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2117 ("View as different encoding"
2118 ,@(gnus-summary-menu-split
2121 ;; Since easymenu under Emacs doesn't allow
2122 ;; lambda forms for menu commands, we should
2123 ;; provide intern'ed function symbols.
2124 (let ((command (intern (format "\
2125 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2129 (let ((gnus-summary-show-article-charset-alist
2131 (gnus-summary-show-article 1))))
2132 `[,(symbol-name cs) ,command t]))
2133 (sort (if (fboundp 'coding-system-list)
2134 (coding-system-list)
2135 ;;(mapcar 'car mm-mime-mule-charset-alist)
2140 ["Leading" gnus-article-strip-leading-blank-lines t]
2141 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2142 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2143 ["All of the above" gnus-article-strip-blank-lines t]
2144 ["All" gnus-article-strip-all-blank-lines t]
2145 ["Leading space" gnus-article-strip-leading-space t]
2146 ["Trailing space" gnus-article-strip-trailing-space t]
2147 ["Leading space in headers"
2148 gnus-article-remove-leading-whitespace t])
2149 ["Overstrike" gnus-article-treat-overstrike t]
2150 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2151 ["Emphasis" gnus-article-emphasize t]
2152 ["Word wrap" gnus-article-fill-cited-article t]
2153 ["Fill long lines" gnus-article-fill-long-lines t]
2154 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2155 ["CR" gnus-article-remove-cr t]
2156 ["Rot 13" gnus-summary-caesar-message
2157 ,@(if (featurep 'xemacs) '(t)
2158 '(:help "\"Caesar rotate\" article by 13"))]
2159 ["Morse decode" gnus-summary-morse-message t]
2160 ["Unix pipe..." gnus-summary-pipe-message t]
2161 ["Add buttons" gnus-article-add-buttons t]
2162 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2163 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2164 ["Toggle MIME" gnus-summary-toggle-mime t]
2165 ["Verbose header" gnus-summary-verbose-headers t]
2166 ["Toggle header" gnus-summary-toggle-header t]
2167 ["Unfold headers" gnus-article-treat-unfold-headers t]
2168 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2169 ["Html" gnus-article-wash-html t]
2170 ["URLs" gnus-article-unsplit-urls t]
2171 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2172 ["HZ" gnus-article-decode-HZ t]
2173 ("(Outlook) Deuglify"
2174 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2175 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2176 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2177 ["Full (Outlook) deuglify"
2178 gnus-article-outlook-deuglify-article t])
2181 ["Save in default format" gnus-summary-save-article
2182 ,@(if (featurep 'xemacs) '(t)
2183 '(:help "Save article using default method"))]
2184 ["Save in file" gnus-summary-save-article-file
2185 ,@(if (featurep 'xemacs) '(t)
2186 '(:help "Save article in file"))]
2187 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2188 ["Save in MH folder" gnus-summary-save-article-folder t]
2189 ["Save in VM folder" gnus-summary-save-article-vm t]
2190 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2191 ["Save body in file" gnus-summary-save-article-body-file t]
2192 ["Pipe through a filter" gnus-summary-pipe-output t]
2193 ["Add to SOUP packet" gnus-soup-add-article t]
2194 ["Print with Muttprint" gnus-summary-muttprint t]
2195 ["Print" gnus-summary-print-article t])
2197 ["Respool article..." gnus-summary-respool-article t]
2198 ["Move article..." gnus-summary-move-article
2199 (gnus-check-backend-function
2200 'request-move-article gnus-newsgroup-name)]
2201 ["Copy article..." gnus-summary-copy-article t]
2202 ["Crosspost article..." gnus-summary-crosspost-article
2203 (gnus-check-backend-function
2204 'request-replace-article gnus-newsgroup-name)]
2205 ["Import file..." gnus-summary-import-article
2206 (gnus-check-backend-function
2207 'request-accept-article gnus-newsgroup-name)]
2208 ["Create article..." gnus-summary-create-article
2209 (gnus-check-backend-function
2210 'request-accept-article gnus-newsgroup-name)]
2211 ["Check if posted" gnus-summary-article-posted-p t]
2212 ["Edit article" gnus-summary-edit-article
2213 (not (gnus-group-read-only-p))]
2214 ["Delete article" gnus-summary-delete-article
2215 (gnus-check-backend-function
2216 'request-expire-articles gnus-newsgroup-name)]
2217 ["Query respool" gnus-summary-respool-query t]
2218 ["Trace respool" gnus-summary-respool-trace t]
2219 ["Delete expirable articles" gnus-summary-expire-articles-now
2220 (gnus-check-backend-function
2221 'request-expire-articles gnus-newsgroup-name)])
2223 ["Uudecode" gnus-uu-decode-uu
2224 ,@(if (featurep 'xemacs) '(t)
2225 '(:help "Decode uuencoded article(s)"))]
2226 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2227 ["Unshar" gnus-uu-decode-unshar t]
2228 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2229 ["Save" gnus-uu-decode-save t]
2230 ["Binhex" gnus-uu-decode-binhex t]
2231 ["Postscript" gnus-uu-decode-postscript t])
2233 ["Enter article" gnus-cache-enter-article t]
2234 ["Remove article" gnus-cache-remove-article t])
2235 ["Translate" gnus-article-babel t]
2236 ["Select article buffer" gnus-summary-select-article-buffer t]
2237 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2238 ["Isearch article..." gnus-summary-isearch-article t]
2239 ["Beginning of the article" gnus-summary-beginning-of-article t]
2240 ["End of the article" gnus-summary-end-of-article t]
2241 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2242 ["Fetch referenced articles" gnus-summary-refer-references t]
2243 ["Fetch current thread" gnus-summary-refer-thread t]
2244 ["Fetch article with id..." gnus-summary-refer-article t]
2245 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2246 ["Redisplay" gnus-summary-show-article t]
2247 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2249 gnus-summary-article-menu gnus-summary-mode-map ""
2250 (cons "Article" innards))
2252 (if (not (keymapp gnus-summary-article-menu))
2254 gnus-article-commands-menu gnus-article-mode-map ""
2255 (cons "Commands" innards))
2256 ;; in Emacs, don't share menu.
2257 (setq gnus-article-commands-menu
2258 (copy-keymap gnus-summary-article-menu))
2259 (define-key gnus-article-mode-map [menu-bar commands]
2260 (cons "Commands" gnus-article-commands-menu))))
2263 gnus-summary-thread-menu gnus-summary-mode-map ""
2265 ["Find all messages in thread" gnus-summary-refer-thread t]
2266 ["Toggle threading" gnus-summary-toggle-threads t]
2267 ["Hide threads" gnus-summary-hide-all-threads t]
2268 ["Show threads" gnus-summary-show-all-threads t]
2269 ["Hide thread" gnus-summary-hide-thread t]
2270 ["Show thread" gnus-summary-show-thread t]
2271 ["Go to next thread" gnus-summary-next-thread t]
2272 ["Go to previous thread" gnus-summary-prev-thread t]
2273 ["Go down thread" gnus-summary-down-thread t]
2274 ["Go up thread" gnus-summary-up-thread t]
2275 ["Top of thread" gnus-summary-top-thread t]
2276 ["Mark thread as read" gnus-summary-kill-thread t]
2277 ["Lower thread score" gnus-summary-lower-thread t]
2278 ["Raise thread score" gnus-summary-raise-thread t]
2279 ["Rethread current" gnus-summary-rethread-current t]))
2282 gnus-summary-post-menu gnus-summary-mode-map ""
2284 ["Send a message (mail or news)" gnus-summary-post-news
2285 ,@(if (featurep 'xemacs) '(t)
2286 '(:help "Post an article"))]
2287 ["Followup" gnus-summary-followup
2288 ,@(if (featurep 'xemacs) '(t)
2289 '(:help "Post followup to this article"))]
2290 ["Followup and yank" gnus-summary-followup-with-original
2291 ,@(if (featurep 'xemacs) '(t)
2292 '(:help "Post followup to this article, quoting its contents"))]
2293 ["Supersede article" gnus-summary-supersede-article t]
2294 ["Cancel article" gnus-summary-cancel-article
2295 ,@(if (featurep 'xemacs) '(t)
2296 '(:help "Cancel an article you posted"))]
2297 ["Reply" gnus-summary-reply t]
2298 ["Reply and yank" gnus-summary-reply-with-original t]
2299 ["Wide reply" gnus-summary-wide-reply t]
2300 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2301 ,@(if (featurep 'xemacs) '(t)
2302 '(:help "Mail a reply, quoting this article"))]
2303 ["Very wide reply" gnus-summary-very-wide-reply t]
2304 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2305 ,@(if (featurep 'xemacs) '(t)
2306 '(:help "Mail a very wide reply, quoting this article"))]
2307 ["Mail forward" gnus-summary-mail-forward t]
2308 ["Post forward" gnus-summary-post-forward t]
2309 ["Digest and mail" gnus-summary-digest-mail-forward t]
2310 ["Digest and post" gnus-summary-digest-post-forward t]
2311 ["Resend message" gnus-summary-resend-message t]
2312 ["Resend message edit" gnus-summary-resend-message-edit t]
2313 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2314 ["Send a mail" gnus-summary-mail-other-window t]
2315 ["Create a local message" gnus-summary-news-other-window t]
2316 ["Uuencode and post" gnus-uu-post-news
2317 ,@(if (featurep 'xemacs) '(t)
2318 '(:help "Post a uuencoded article"))]
2319 ["Followup via news" gnus-summary-followup-to-mail t]
2320 ["Followup via news and yank"
2321 gnus-summary-followup-to-mail-with-original t]
2323 ;;["Send" gnus-summary-send-draft t]
2324 ;;["Send bounced" gnus-resend-bounced-mail t])
2328 ((not (keymapp gnus-summary-post-menu))
2329 (setq gnus-article-post-menu gnus-summary-post-menu))
2330 ((not gnus-article-post-menu)
2331 ;; Don't share post menu.
2332 (setq gnus-article-post-menu
2333 (copy-keymap gnus-summary-post-menu))))
2334 (define-key gnus-article-mode-map [menu-bar post]
2335 (cons "Post" gnus-article-post-menu))
2338 gnus-summary-misc-menu gnus-summary-mode-map ""
2341 ["Mark as read" gnus-summary-mark-as-read-forward t]
2342 ["Mark same subject and select"
2343 gnus-summary-kill-same-subject-and-select t]
2344 ["Mark same subject" gnus-summary-kill-same-subject t]
2345 ["Catchup" gnus-summary-catchup
2346 ,@(if (featurep 'xemacs) '(t)
2347 '(:help "Mark unread articles in this group as read"))]
2348 ["Catchup all" gnus-summary-catchup-all t]
2349 ["Catchup to here" gnus-summary-catchup-to-here t]
2350 ["Catchup from here" gnus-summary-catchup-from-here t]
2351 ["Catchup region" gnus-summary-mark-region-as-read
2352 (gnus-mark-active-p)]
2353 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2355 ["Tick" gnus-summary-tick-article-forward t]
2356 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2357 ["Remove marks" gnus-summary-clear-mark-forward t]
2358 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2359 ["Set bookmark" gnus-summary-set-bookmark t]
2360 ["Remove bookmark" gnus-summary-remove-bookmark t])
2362 ["Marks..." gnus-summary-limit-to-marks t]
2363 ["Subject..." gnus-summary-limit-to-subject t]
2364 ["Author..." gnus-summary-limit-to-author t]
2365 ["Age..." gnus-summary-limit-to-age t]
2366 ["Extra..." gnus-summary-limit-to-extra t]
2367 ["Score..." gnus-summary-limit-to-score t]
2368 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2369 ["Unread" gnus-summary-limit-to-unread t]
2370 ["Unseen" gnus-summary-limit-to-unseen t]
2371 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2372 ["Next articles" gnus-summary-limit-to-articles t]
2373 ["Pop limit" gnus-summary-pop-limit t]
2374 ["Show dormant" gnus-summary-limit-include-dormant t]
2375 ["Hide childless dormant"
2376 gnus-summary-limit-exclude-childless-dormant t]
2377 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2378 ["Hide marked" gnus-summary-limit-exclude-marks t]
2379 ["Show expunged" gnus-summary-limit-include-expunged t])
2381 ["Set mark" gnus-summary-mark-as-processable t]
2382 ["Remove mark" gnus-summary-unmark-as-processable t]
2383 ["Remove all marks" gnus-summary-unmark-all-processable t]
2384 ["Mark above" gnus-uu-mark-over t]
2385 ["Mark series" gnus-uu-mark-series t]
2386 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2387 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2388 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2389 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2390 ["Mark all" gnus-uu-mark-all t]
2391 ["Mark buffer" gnus-uu-mark-buffer t]
2392 ["Mark sparse" gnus-uu-mark-sparse t]
2393 ["Mark thread" gnus-uu-mark-thread t]
2394 ["Unmark thread" gnus-uu-unmark-thread t]
2395 ("Process Mark Sets"
2396 ["Kill" gnus-summary-kill-process-mark t]
2397 ["Yank" gnus-summary-yank-process-mark
2398 gnus-newsgroup-process-stack]
2399 ["Save" gnus-summary-save-process-mark t]
2400 ["Run command on marked..." gnus-summary-universal-argument t]))
2402 ["Page forward" gnus-summary-next-page
2403 ,@(if (featurep 'xemacs) '(t)
2404 '(:help "Show next page of article"))]
2405 ["Page backward" gnus-summary-prev-page
2406 ,@(if (featurep 'xemacs) '(t)
2407 '(:help "Show previous page of article"))]
2408 ["Line forward" gnus-summary-scroll-up t])
2410 ["Next unread article" gnus-summary-next-unread-article t]
2411 ["Previous unread article" gnus-summary-prev-unread-article t]
2412 ["Next article" gnus-summary-next-article t]
2413 ["Previous article" gnus-summary-prev-article t]
2414 ["Next unread subject" gnus-summary-next-unread-subject t]
2415 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2416 ["Next article same subject" gnus-summary-next-same-subject t]
2417 ["Previous article same subject" gnus-summary-prev-same-subject t]
2418 ["First unread article" gnus-summary-first-unread-article t]
2419 ["Best unread article" gnus-summary-best-unread-article t]
2420 ["Go to subject number..." gnus-summary-goto-subject t]
2421 ["Go to article number..." gnus-summary-goto-article t]
2422 ["Go to the last article" gnus-summary-goto-last-article t]
2423 ["Pop article off history" gnus-summary-pop-article t])
2425 ["Sort by number" gnus-summary-sort-by-number t]
2426 ["Sort by author" gnus-summary-sort-by-author t]
2427 ["Sort by subject" gnus-summary-sort-by-subject t]
2428 ["Sort by date" gnus-summary-sort-by-date t]
2429 ["Sort by score" gnus-summary-sort-by-score t]
2430 ["Sort by lines" gnus-summary-sort-by-lines t]
2431 ["Sort by characters" gnus-summary-sort-by-chars t]
2432 ["Randomize" gnus-summary-sort-by-random t]
2433 ["Original sort" gnus-summary-sort-by-original t])
2435 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2436 ["Describe group" gnus-summary-describe-group t]
2437 ["Fetch charter" gnus-group-fetch-charter
2438 ,@(if (featurep 'xemacs) nil
2439 '(:help "Display the charter of the current group"))]
2440 ["Fetch control message" gnus-group-fetch-control
2441 ,@(if (featurep 'xemacs) nil
2442 '(:help "Display the archived control message for the current group"))]
2443 ["Read manual" gnus-info-find-node t])
2445 ["Pick and read" gnus-pick-mode t]
2446 ["Binary" gnus-binary-mode t])
2448 ["Regenerate" gnus-summary-prepare t]
2449 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2450 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2451 ["Toggle threading" gnus-summary-toggle-threads t])
2452 ["See old articles" gnus-summary-insert-old-articles t]
2453 ["See new articles" gnus-summary-insert-new-articles t]
2454 ["Filter articles..." gnus-summary-execute-command t]
2455 ["Run command on articles..." gnus-summary-universal-argument t]
2456 ["Search articles forward..." gnus-summary-search-article-forward t]
2457 ["Search articles backward..." gnus-summary-search-article-backward t]
2458 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2459 ["Expand window" gnus-summary-expand-window t]
2460 ["Expire expirable articles" gnus-summary-expire-articles
2461 (gnus-check-backend-function
2462 'request-expire-articles gnus-newsgroup-name)]
2463 ["Edit local kill file" gnus-summary-edit-local-kill t]
2464 ["Edit main kill file" gnus-summary-edit-global-kill t]
2465 ["Edit group parameters" gnus-summary-edit-parameters t]
2466 ["Customize group parameters" gnus-summary-customize-parameters t]
2467 ["Send a bug report" gnus-bug t]
2469 ["Catchup and exit" gnus-summary-catchup-and-exit
2470 ,@(if (featurep 'xemacs) '(t)
2471 '(:help "Mark unread articles in this group as read, then exit"))]
2472 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2473 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2474 ["Exit group" gnus-summary-exit
2475 ,@(if (featurep 'xemacs) '(t)
2476 '(:help "Exit current group, return to group selection mode"))]
2477 ["Exit group without updating" gnus-summary-exit-no-update t]
2478 ["Exit and goto next group" gnus-summary-next-group t]
2479 ["Exit and goto prev group" gnus-summary-prev-group t]
2480 ["Reselect group" gnus-summary-reselect-current-group t]
2481 ["Rescan group" gnus-summary-rescan-group t]
2482 ["Update dribble" gnus-summary-save-newsrc t])))
2484 (gnus-run-hooks 'gnus-summary-menu-hook)))
2486 (defvar gnus-summary-tool-bar-map nil)
2488 ;; Emacs 21 tool bar. Should be no-op otherwise.
2489 (defun gnus-summary-make-tool-bar ()
2490 (if (and (fboundp 'tool-bar-add-item-from-menu)
2491 (default-value 'tool-bar-mode)
2492 (not gnus-summary-tool-bar-map))
2493 (setq gnus-summary-tool-bar-map
2494 (let ((tool-bar-map (make-sparse-keymap))
2495 (load-path (mm-image-load-path)))
2496 (tool-bar-add-item-from-menu
2497 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2498 (tool-bar-add-item-from-menu
2499 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2500 (tool-bar-add-item-from-menu
2501 'gnus-summary-post-news "post" gnus-summary-mode-map)
2502 (tool-bar-add-item-from-menu
2503 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2504 (tool-bar-add-item-from-menu
2505 'gnus-summary-followup "followup" gnus-summary-mode-map)
2506 (tool-bar-add-item-from-menu
2507 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2508 (tool-bar-add-item-from-menu
2509 'gnus-summary-reply "reply" gnus-summary-mode-map)
2510 (tool-bar-add-item-from-menu
2511 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2512 (tool-bar-add-item-from-menu
2513 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2514 (tool-bar-add-item-from-menu
2515 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2516 (tool-bar-add-item-from-menu
2517 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2518 (tool-bar-add-item-from-menu
2519 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2520 (tool-bar-add-item-from-menu
2521 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2522 (tool-bar-add-item-from-menu
2523 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2524 (tool-bar-add-item-from-menu
2525 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2527 (if gnus-summary-tool-bar-map
2528 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2530 (defun gnus-score-set-default (var value)
2531 "A version of set that updates the GNU Emacs menu-bar."
2533 ;; It is the message that forces the active status to be updated.
2536 (defun gnus-make-score-map (type)
2537 "Make a summary score map of type TYPE."
2540 (let ((headers '(("author" "from" string)
2541 ("subject" "subject" string)
2542 ("article body" "body" string)
2543 ("article head" "head" string)
2544 ("xref" "xref" string)
2545 ("extra header" "extra" string)
2546 ("lines" "lines" number)
2547 ("followups to author" "followup" string)))
2548 (types '((number ("less than" <)
2551 (string ("substring" s)
2555 (perms '(("temporary" (current-time-string))
2563 (if (eq type 'lower)
2568 (setq header (car headers))
2574 (let ((ts (cdr (assoc (nth 2 header) types)))
2590 'gnus-summary-score-entry
2592 (if (or (string= (nth 1 header)
2594 (string= (nth 1 header)
2597 (list 'gnus-summary-header
2599 (list 'quote (nth 1 (car ts)))
2600 (list 'gnus-score-delta-default
2607 (list (nreverse outp))))
2610 (list (nreverse outt))))
2612 (setq headers (cdr headers)))
2613 (list (nreverse outh))))))))
2617 (defun gnus-summary-mode (&optional group)
2618 "Major mode for reading articles.
2620 All normal editing commands are switched off.
2621 \\<gnus-summary-mode-map>
2622 Each line in this buffer represents one article. To read an
2623 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2624 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2627 You can also post articles and send mail from this buffer. To
2628 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2629 of an article, type `\\[gnus-summary-reply]'.
2631 There are approx. one gazillion commands you can execute in this
2632 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2634 The following commands are available:
2636 \\{gnus-summary-mode-map}"
2638 (kill-all-local-variables)
2639 (when (gnus-visual-p 'summary-menu 'menu)
2640 (gnus-summary-make-menu-bar)
2641 (gnus-summary-make-tool-bar))
2642 (gnus-summary-make-local-variables)
2643 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2644 (gnus-summary-make-local-variables))
2645 (gnus-make-thread-indent-array)
2646 (gnus-simplify-mode-line)
2647 (setq major-mode 'gnus-summary-mode)
2648 (setq mode-name "Summary")
2649 (make-local-variable 'minor-mode-alist)
2650 (use-local-map gnus-summary-mode-map)
2651 (buffer-disable-undo)
2652 (setq buffer-read-only t) ;Disable modification
2653 (setq truncate-lines t)
2654 (setq selective-display t)
2655 (setq selective-display-ellipses t) ;Display `...'
2656 (gnus-summary-set-display-table)
2657 (gnus-set-default-directory)
2658 (setq gnus-newsgroup-name group)
2659 (unless (gnus-news-group-p group)
2660 (setq gnus-newsgroup-incorporated
2661 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2662 (make-local-variable 'gnus-summary-line-format)
2663 (make-local-variable 'gnus-summary-line-format-spec)
2664 (make-local-variable 'gnus-summary-dummy-line-format)
2665 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2666 (make-local-variable 'gnus-summary-mark-positions)
2667 (gnus-make-local-hook 'pre-command-hook)
2668 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2669 (gnus-run-hooks 'gnus-summary-mode-hook)
2670 (turn-on-gnus-mailing-list-mode)
2671 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2672 (gnus-update-summary-mark-positions))
2674 (defun gnus-summary-make-local-variables ()
2675 "Make all the local summary buffer variables."
2677 (dolist (local gnus-summary-local-variables)
2680 (if (eq (cdr local) 'global)
2681 ;; Copy the global value of the variable.
2682 (setq global (symbol-value (car local)))
2683 ;; Use the value from the list.
2684 (setq global (eval (cdr local))))
2685 (set (make-local-variable (car local)) global))
2686 ;; Simple nil-valued local variable.
2687 (set (make-local-variable local) nil)))))
2689 (defun gnus-summary-clear-local-variables ()
2690 (let ((locals gnus-summary-local-variables))
2692 (if (consp (car locals))
2693 (and (vectorp (caar locals))
2694 (set (caar locals) nil))
2695 (and (vectorp (car locals))
2696 (set (car locals) nil)))
2697 (setq locals (cdr locals)))))
2699 ;; Summary data functions.
2701 (defmacro gnus-data-number (data)
2704 (defmacro gnus-data-set-number (data number)
2705 `(setcar ,data ,number))
2707 (defmacro gnus-data-mark (data)
2710 (defmacro gnus-data-set-mark (data mark)
2711 `(setcar (nthcdr 1 ,data) ,mark))
2713 (defmacro gnus-data-pos (data)
2716 (defmacro gnus-data-set-pos (data pos)
2717 `(setcar (nthcdr 2 ,data) ,pos))
2719 (defmacro gnus-data-header (data)
2722 (defmacro gnus-data-set-header (data header)
2723 `(setcar (nthcdr 3 ,data) ,header))
2725 (defmacro gnus-data-level (data)
2728 (defmacro gnus-data-unread-p (data)
2729 `(= (nth 1 ,data) gnus-unread-mark))
2731 (defmacro gnus-data-read-p (data)
2732 `(/= (nth 1 ,data) gnus-unread-mark))
2734 (defmacro gnus-data-pseudo-p (data)
2735 `(consp (nth 3 ,data)))
2737 (defmacro gnus-data-find (number)
2738 `(assq ,number gnus-newsgroup-data))
2740 (defmacro gnus-data-find-list (number &optional data)
2741 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2742 (memq (assq ,number bdata)
2745 (defmacro gnus-data-make (number mark pos header level)
2746 `(list ,number ,mark ,pos ,header ,level))
2748 (defun gnus-data-enter (after-article number mark pos header level offset)
2749 (let ((data (gnus-data-find-list after-article)))
2751 (error "No such article: %d" after-article))
2752 (setcdr data (cons (gnus-data-make number mark pos header level)
2754 (setq gnus-newsgroup-data-reverse nil)
2755 (gnus-data-update-list (cddr data) offset)))
2757 (defun gnus-data-enter-list (after-article list &optional offset)
2759 (let ((data (and after-article (gnus-data-find-list after-article)))
2763 (let ((odata gnus-newsgroup-data))
2764 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2766 (gnus-data-update-list odata offset)))
2767 ;; Find the last element in the list to be spliced into the main
2770 (setq list (cdr list)))
2773 (setcdr list gnus-newsgroup-data)
2774 (setq gnus-newsgroup-data ilist)
2776 (gnus-data-update-list (cdr list) offset)))
2777 (setcdr list (cdr data))
2780 (gnus-data-update-list (cdr list) offset))))
2781 (setq gnus-newsgroup-data-reverse nil))))
2783 (defun gnus-data-remove (article &optional offset)
2784 (let ((data gnus-newsgroup-data))
2785 (if (= (gnus-data-number (car data)) article)
2787 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2788 gnus-newsgroup-data-reverse nil)
2790 (gnus-data-update-list gnus-newsgroup-data offset)))
2792 (when (= (gnus-data-number (cadr data)) article)
2793 (setcdr data (cddr data))
2795 (gnus-data-update-list (cdr data) offset))
2797 gnus-newsgroup-data-reverse nil))
2798 (setq data (cdr data))))))
2800 (defmacro gnus-data-list (backward)
2802 (or gnus-newsgroup-data-reverse
2803 (setq gnus-newsgroup-data-reverse
2804 (reverse gnus-newsgroup-data)))
2805 gnus-newsgroup-data))
2807 (defun gnus-data-update-list (data offset)
2808 "Add OFFSET to the POS of all data entries in DATA."
2809 (setq gnus-newsgroup-data-reverse nil)
2811 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2812 (setq data (cdr data))))
2814 (defun gnus-summary-article-pseudo-p (article)
2815 "Say whether this article is a pseudo article or not."
2816 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2818 (defmacro gnus-summary-article-sparse-p (article)
2819 "Say whether this article is a sparse article or not."
2820 `(memq ,article gnus-newsgroup-sparse))
2822 (defmacro gnus-summary-article-ancient-p (article)
2823 "Say whether this article is a sparse article or not."
2824 `(memq ,article gnus-newsgroup-ancient))
2826 (defun gnus-article-parent-p (number)
2827 "Say whether this article is a parent or not."
2828 (let ((data (gnus-data-find-list number)))
2829 (and (cdr data) ; There has to be an article after...
2830 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2831 (gnus-data-level (nth 1 data))))))
2833 (defun gnus-article-children (number)
2834 "Return a list of all children to NUMBER."
2835 (let* ((data (gnus-data-find-list number))
2836 (level (gnus-data-level (car data)))
2838 (setq data (cdr data))
2840 (= (gnus-data-level (car data)) (1+ level)))
2841 (push (gnus-data-number (car data)) children)
2842 (setq data (cdr data)))
2845 (defmacro gnus-summary-skip-intangible ()
2846 "If the current article is intangible, then jump to a different article."
2847 '(let ((to (get-text-property (point) 'gnus-intangible)))
2848 (and to (gnus-summary-goto-subject to))))
2850 (defmacro gnus-summary-article-intangible-p ()
2851 "Say whether this article is intangible or not."
2852 '(get-text-property (point) 'gnus-intangible))
2854 (defun gnus-article-read-p (article)
2855 "Say whether ARTICLE is read or not."
2856 (not (or (memq article gnus-newsgroup-marked)
2857 (memq article gnus-newsgroup-spam-marked)
2858 (memq article gnus-newsgroup-unreads)
2859 (memq article gnus-newsgroup-unselected)
2860 (memq article gnus-newsgroup-dormant))))
2862 ;; Some summary mode macros.
2864 (defmacro gnus-summary-article-number ()
2865 "The article number of the article on the current line.
2866 If there isn't an article number here, then we return the current
2869 (gnus-summary-skip-intangible)
2870 (or (get-text-property (point) 'gnus-number)
2871 (gnus-summary-last-subject))))
2873 (defmacro gnus-summary-article-header (&optional number)
2874 "Return the header of article NUMBER."
2875 `(gnus-data-header (gnus-data-find
2876 ,(or number '(gnus-summary-article-number)))))
2878 (defmacro gnus-summary-thread-level (&optional number)
2879 "Return the level of thread that starts with article NUMBER."
2880 `(if (and (eq gnus-summary-make-false-root 'dummy)
2881 (get-text-property (point) 'gnus-intangible))
2883 (gnus-data-level (gnus-data-find
2884 ,(or number '(gnus-summary-article-number))))))
2886 (defmacro gnus-summary-article-mark (&optional number)
2887 "Return the mark of article NUMBER."
2888 `(gnus-data-mark (gnus-data-find
2889 ,(or number '(gnus-summary-article-number)))))
2891 (defmacro gnus-summary-article-pos (&optional number)
2892 "Return the position of the line of article NUMBER."
2893 `(gnus-data-pos (gnus-data-find
2894 ,(or number '(gnus-summary-article-number)))))
2896 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2897 (defmacro gnus-summary-article-subject (&optional number)
2898 "Return current subject string or nil if nothing."
2901 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2902 '(gnus-data-header (assq (gnus-summary-article-number)
2903 gnus-newsgroup-data)))))
2906 (mail-header-subject headers))))
2908 (defmacro gnus-summary-article-score (&optional number)
2909 "Return current article score."
2910 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2911 gnus-newsgroup-scored))
2912 gnus-summary-default-score 0))
2914 (defun gnus-summary-article-children (&optional number)
2915 "Return a list of article numbers that are children of article NUMBER."
2916 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2917 (level (gnus-data-level (car data)))
2919 (while (and (setq data (cdr data))
2920 (> (setq l (gnus-data-level (car data))) level))
2921 (and (= (1+ level) l)
2922 (push (gnus-data-number (car data))
2924 (nreverse children)))
2926 (defun gnus-summary-article-parent (&optional number)
2927 "Return the article number of the parent of article NUMBER."
2928 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2929 (gnus-data-list t)))
2930 (level (gnus-data-level (car data))))
2932 () ; This is a root.
2933 ;; We search until we find an article with a level less than
2934 ;; this one. That function has to be the parent.
2935 (while (and (setq data (cdr data))
2936 (not (< (gnus-data-level (car data)) level))))
2937 (and data (gnus-data-number (car data))))))
2939 (defun gnus-unread-mark-p (mark)
2940 "Say whether MARK is the unread mark."
2941 (= mark gnus-unread-mark))
2943 (defun gnus-read-mark-p (mark)
2944 "Say whether MARK is one of the marks that mark as read.
2945 This is all marks except unread, ticked, dormant, and expirable."
2946 (not (or (= mark gnus-unread-mark)
2947 (= mark gnus-ticked-mark)
2948 (= mark gnus-spam-mark)
2949 (= mark gnus-dormant-mark)
2950 (= mark gnus-expirable-mark))))
2952 (defmacro gnus-article-mark (number)
2953 "Return the MARK of article NUMBER.
2954 This macro should only be used when computing the mark the \"first\"
2955 time; i.e., when generating the summary lines. After that,
2956 `gnus-summary-article-mark' should be used to examine the
2959 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2960 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2961 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2962 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2963 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2964 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2965 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2966 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2967 gnus-ancient-mark))))
2969 ;; Saving hidden threads.
2971 (defmacro gnus-save-hidden-threads (&rest forms)
2972 "Save hidden threads, eval FORMS, and restore the hidden threads."
2973 (let ((config (make-symbol "config")))
2974 `(let ((,config (gnus-hidden-threads-configuration)))
2978 (gnus-restore-hidden-threads-configuration ,config)))))
2979 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2980 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2982 (defun gnus-data-compute-positions ()
2983 "Compute the positions of all articles."
2984 (setq gnus-newsgroup-data-reverse nil)
2985 (let ((data gnus-newsgroup-data))
2987 (gnus-save-hidden-threads
2988 (gnus-summary-show-all-threads)
2989 (goto-char (point-min))
2991 (while (get-text-property (point) 'gnus-intangible)
2993 (gnus-data-set-pos (car data) (+ (point) 3))
2994 (setq data (cdr data))
2995 (forward-line 1))))))
2997 (defun gnus-hidden-threads-configuration ()
2998 "Return the current hidden threads configuration."
3001 (goto-char (point-min))
3002 (while (search-forward "\r" nil t)
3003 (push (1- (point)) config))
3006 (defun gnus-restore-hidden-threads-configuration (config)
3007 "Restore hidden threads configuration from CONFIG."
3009 (let (point buffer-read-only)
3010 (while (setq point (pop config))
3011 (when (and (< point (point-max))
3013 (eq (char-after) ?\n))
3014 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3016 ;; Various summary mode internalish functions.
3018 (defun gnus-mouse-pick-article (e)
3021 (gnus-summary-next-page nil t))
3023 (defun gnus-summary-set-display-table ()
3024 "Change the display table.
3025 Odd characters have a tendency to mess
3026 up nicely formatted displays - we make all possible glyphs
3027 display only a single character."
3029 ;; We start from the standard display table, if any.
3030 (let ((table (or (copy-sequence standard-display-table)
3031 (make-display-table)))
3033 ;; Nix out all the control chars...
3034 (while (>= (setq i (1- i)) 0)
3035 (aset table i [??]))
3036 ;; ... but not newline and cr, of course. (cr is necessary for the
3037 ;; selective display).
3038 (aset table ?\n nil)
3039 (aset table ?\r nil)
3040 ;; We keep TAB as well.
3041 (aset table ?\t nil)
3042 ;; We nix out any glyphs over 126 that are not set already.
3044 (while (>= (setq i (1- i)) 127)
3045 ;; Only modify if the entry is nil.
3046 (unless (aref table i)
3047 (aset table i [??]))))
3048 (setq buffer-display-table table)))
3050 (defun gnus-summary-set-article-display-arrow (pos)
3051 "Update the overlay arrow to point to line at position POS."
3052 (when (and gnus-summary-display-arrow
3053 (boundp 'overlay-arrow-position)
3054 (boundp 'overlay-arrow-string))
3058 (unless overlay-arrow-position
3059 (setq overlay-arrow-position (make-marker)))
3060 (setq overlay-arrow-string "=>"
3061 overlay-arrow-position (set-marker overlay-arrow-position
3063 (current-buffer))))))
3065 (defun gnus-summary-setup-buffer (group)
3066 "Initialize summary buffer."
3067 (let ((buffer (gnus-summary-buffer-name group))
3068 (dead-name (concat "*Dead Summary "
3069 (gnus-group-decoded-name group) "*")))
3070 ;; If a dead summary buffer exists, we kill it.
3071 (when (gnus-buffer-live-p dead-name)
3072 (gnus-kill-buffer dead-name))
3073 (if (get-buffer buffer)
3076 (setq gnus-summary-buffer (current-buffer))
3077 (not gnus-newsgroup-prepared))
3078 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3079 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3080 (gnus-summary-mode group)
3082 (gnus-carpal-setup-buffer 'summary))
3083 (unless gnus-single-article-buffer
3084 (make-local-variable 'gnus-article-buffer)
3085 (make-local-variable 'gnus-article-current)
3086 (make-local-variable 'gnus-original-article-buffer))
3087 (setq gnus-newsgroup-name group)
3088 ;; Set any local variables in the group parameters.
3089 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3092 (defun gnus-set-global-variables ()
3093 "Set the global equivalents of the buffer-local variables.
3094 They are set to the latest values they had. These reflect the summary
3095 buffer that was in action when the last article was fetched."
3096 (when (eq major-mode 'gnus-summary-mode)
3097 (setq gnus-summary-buffer (current-buffer))
3098 (let ((name gnus-newsgroup-name)
3099 (marked gnus-newsgroup-marked)
3100 (spam gnus-newsgroup-spam-marked)
3101 (unread gnus-newsgroup-unreads)
3102 (headers gnus-current-headers)
3103 (data gnus-newsgroup-data)
3104 (summary gnus-summary-buffer)
3105 (article-buffer gnus-article-buffer)
3106 (original gnus-original-article-buffer)
3107 (gac gnus-article-current)
3108 (reffed gnus-reffed-article-number)
3109 (score-file gnus-current-score-file)
3110 (default-charset gnus-newsgroup-charset)
3112 (let ((locals gnus-newsgroup-variables))
3114 (if (consp (car locals))
3115 (push (eval (caar locals)) vlist)
3116 (push (eval (car locals)) vlist))
3117 (setq locals (cdr locals)))
3118 (setq vlist (nreverse vlist)))
3120 (set-buffer gnus-group-buffer)
3121 (setq gnus-newsgroup-name name
3122 gnus-newsgroup-marked marked
3123 gnus-newsgroup-spam-marked spam
3124 gnus-newsgroup-unreads unread
3125 gnus-current-headers headers
3126 gnus-newsgroup-data data
3127 gnus-article-current gac
3128 gnus-summary-buffer summary
3129 gnus-article-buffer article-buffer
3130 gnus-original-article-buffer original
3131 gnus-reffed-article-number reffed
3132 gnus-current-score-file score-file
3133 gnus-newsgroup-charset default-charset)
3134 (let ((locals gnus-newsgroup-variables))
3136 (if (consp (car locals))
3137 (set (caar locals) (pop vlist))
3138 (set (car locals) (pop vlist)))
3139 (setq locals (cdr locals))))
3140 ;; The article buffer also has local variables.
3141 (when (gnus-buffer-live-p gnus-article-buffer)
3142 (set-buffer gnus-article-buffer)
3143 (setq gnus-summary-buffer summary))))))
3145 (defun gnus-summary-article-unread-p (article)
3146 "Say whether ARTICLE is unread or not."
3147 (memq article gnus-newsgroup-unreads))
3149 (defun gnus-summary-first-article-p (&optional article)
3150 "Return whether ARTICLE is the first article in the buffer."
3151 (if (not (setq article (or article (gnus-summary-article-number))))
3153 (eq article (caar gnus-newsgroup-data))))
3155 (defun gnus-summary-last-article-p (&optional article)
3156 "Return whether ARTICLE is the last article in the buffer."
3157 (if (not (setq article (or article (gnus-summary-article-number))))
3158 ;; All non-existent numbers are the last article. :-)
3160 (not (cdr (gnus-data-find-list article)))))
3162 (defun gnus-make-thread-indent-array ()
3164 (unless (and gnus-thread-indent-array
3165 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3166 (setq gnus-thread-indent-array (make-vector 201 "")
3167 gnus-thread-indent-array-level gnus-thread-indent-level)
3169 (aset gnus-thread-indent-array n
3170 (make-string (* n gnus-thread-indent-level) ? ))
3173 (defun gnus-update-summary-mark-positions ()
3174 "Compute where the summary marks are to go."
3176 (when (gnus-buffer-exists-p gnus-summary-buffer)
3177 (set-buffer gnus-summary-buffer))
3178 (let ((gnus-replied-mark 129)
3179 (gnus-score-below-mark 130)
3180 (gnus-score-over-mark 130)
3181 (gnus-undownloaded-mark 131)
3182 (spec gnus-summary-line-format-spec)
3185 (gnus-set-work-buffer)
3186 (let ((gnus-summary-line-format-spec spec)
3187 (gnus-newsgroup-downloadable '(0)))
3188 (gnus-summary-insert-line
3189 (make-full-mail-header 0 "" "nobody"
3190 "05 Apr 2001 23:33:09 +0400"
3192 0 nil t 128 t nil "" nil 1)
3193 (goto-char (point-min))
3194 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3195 (- (point) (point-min) 1)))))
3196 (goto-char (point-min))
3197 (push (cons 'replied (and (search-forward "\201" nil t)
3198 (- (point) (point-min) 1)))
3200 (goto-char (point-min))
3201 (push (cons 'score (and (search-forward "\202" nil t)
3202 (- (point) (point-min) 1)))
3204 (goto-char (point-min))
3205 (push (cons 'download
3206 (and (search-forward "\203" nil t)
3207 (- (point) (point-min) 1)))
3209 (setq gnus-summary-mark-positions pos))))
3211 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3212 "Insert a dummy root in the summary buffer."
3214 (gnus-add-text-properties
3215 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3216 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3218 (defun gnus-summary-extract-address-component (from)
3219 (or (car (funcall gnus-extract-address-components from))
3222 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3223 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3224 default-mime-charset)))
3225 ;; Is it really necessary to do this next part for each summary line?
3226 ;; Luckily, doesn't seem to slow things down much.
3228 (and gnus-ignored-from-addresses
3229 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3230 (let ((extra-headers (mail-header-extra header))
3234 ((setq to (cdr (assq 'To extra-headers)))
3237 (gnus-summary-extract-address-component
3238 (funcall gnus-decode-encoded-word-function to)))))
3239 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3240 (concat "=> " newsgroups)))))
3241 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3243 (defun gnus-summary-insert-line (gnus-tmp-header
3244 gnus-tmp-level gnus-tmp-current
3245 undownloaded gnus-tmp-unread gnus-tmp-replied
3246 gnus-tmp-expirable gnus-tmp-subject-or-nil
3247 &optional gnus-tmp-dummy gnus-tmp-score
3249 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3250 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3251 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3252 (gnus-tmp-score-char
3253 (if (or (null gnus-summary-default-score)
3254 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3255 gnus-summary-zcore-fuzz))
3257 (if (< gnus-tmp-score gnus-summary-default-score)
3258 gnus-score-below-mark gnus-score-over-mark)))
3259 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3261 (cond (gnus-tmp-process gnus-process-mark)
3262 ((memq gnus-tmp-current gnus-newsgroup-cached)
3264 (gnus-tmp-replied gnus-replied-mark)
3265 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3266 gnus-forwarded-mark)
3267 ((memq gnus-tmp-current gnus-newsgroup-saved)
3269 ((memq gnus-tmp-number gnus-newsgroup-recent)
3271 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3274 (gnus-tmp-downloaded
3276 gnus-undownloaded-mark)
3277 (gnus-newsgroup-agentized
3278 gnus-downloaded-mark)
3281 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3284 ((string-match "<[^>]+> *$" gnus-tmp-from)
3285 (let ((beg (match-beginning 0)))
3286 (or (and (string-match "^\".+\"" gnus-tmp-from)
3287 (substring gnus-tmp-from 1 (1- (match-end 0))))
3288 (substring gnus-tmp-from 0 beg))))
3289 ((string-match "(.+)" gnus-tmp-from)
3290 (substring gnus-tmp-from
3291 (1+ (match-beginning 0)) (1- (match-end 0))))
3293 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3294 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3295 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3296 (buffer-read-only nil))
3297 (when (string= gnus-tmp-name "")
3298 (setq gnus-tmp-name gnus-tmp-from))
3299 (unless (numberp gnus-tmp-lines)
3300 (setq gnus-tmp-lines -1))
3301 (if (= gnus-tmp-lines -1)
3302 (setq gnus-tmp-lines "?")
3303 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3304 (gnus-put-text-property-excluding-characters-with-faces
3306 (progn (eval gnus-summary-line-format-spec) (point))
3307 'gnus-number gnus-tmp-number)
3308 (when (gnus-visual-p 'summary-highlight 'highlight)
3310 (gnus-run-hooks 'gnus-summary-update-hook)
3313 (defun gnus-summary-update-line (&optional dont-update)
3314 "Update summary line after change."
3315 (when (and gnus-summary-default-score
3316 (not gnus-summary-inhibit-highlight))
3317 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3318 (article (gnus-summary-article-number))
3319 (score (gnus-summary-article-score article)))
3321 (if (and gnus-summary-mark-below
3322 (< (gnus-summary-article-score)
3323 gnus-summary-mark-below))
3324 ;; This article has a low score, so we mark it as read.
3325 (when (memq article gnus-newsgroup-unreads)
3326 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3327 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3328 ;; This article was previously marked as read on account
3329 ;; of a low score, but now it has risen, so we mark it as
3331 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3332 (gnus-summary-update-mark
3333 (if (or (null gnus-summary-default-score)
3334 (<= (abs (- score gnus-summary-default-score))
3335 gnus-summary-zcore-fuzz))
3337 (if (< score gnus-summary-default-score)
3338 gnus-score-below-mark gnus-score-over-mark))
3340 ;; Do visual highlighting.
3341 (when (gnus-visual-p 'summary-highlight 'highlight)
3342 (gnus-run-hooks 'gnus-summary-update-hook)))))
3344 (defvar gnus-tmp-new-adopts nil)
3346 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3347 "Return the number of articles in THREAD.
3348 This may be 0 in some cases -- if none of the articles in
3349 the thread are to be displayed."
3351 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3353 ((not (listp thread))
3355 ((and (consp thread) (cdr thread))
3358 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3361 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3364 (when (and level (zerop level) gnus-tmp-new-adopts)
3367 'gnus-summary-number-of-articles-in-thread
3368 gnus-tmp-new-adopts))))
3370 (if (> number 1) gnus-not-empty-thread-mark
3371 gnus-empty-thread-mark)
3374 (defsubst gnus-summary-line-message-size (head)
3375 "Return pretty-printed version of message size.
3376 This function is intended to be used in
3377 `gnus-summary-line-format-alist'."
3378 (let ((c (or (mail-header-chars head) -1)))
3379 (cond ((< c 0) "n/a") ; chars not available
3380 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3381 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3382 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3383 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3386 (defun gnus-summary-set-local-parameters (group)
3387 "Go through the local params of GROUP and set all variable specs in that list."
3388 (let ((params (gnus-group-find-parameter group))
3389 (vars '(quit-config)) ; Ignore quit-config.
3392 (setq elem (car params)
3393 params (cdr params))
3394 (and (consp elem) ; Has to be a cons.
3395 (consp (cdr elem)) ; The cdr has to be a list.
3396 (symbolp (car elem)) ; Has to be a symbol in there.
3397 (not (memq (car elem) vars))
3398 (ignore-errors ; So we set it.
3399 (push (car elem) vars)
3400 (make-local-variable (car elem))
3401 (set (car elem) (eval (nth 1 elem))))))))
3403 (defun gnus-summary-read-group (group &optional show-all no-article
3404 kill-buffer no-display backward
3406 "Start reading news in newsgroup GROUP.
3407 If SHOW-ALL is non-nil, already read articles are also listed.
3408 If NO-ARTICLE is non-nil, no article is selected initially.
3409 If NO-DISPLAY, don't generate a summary buffer."
3413 (let ((gnus-auto-select-next nil))
3414 (or (gnus-summary-read-group-1
3415 group show-all no-article
3416 kill-buffer no-display
3419 select-articles nil)))))
3420 (eq gnus-auto-select-next 'quietly))
3421 (set-buffer gnus-group-buffer)
3422 ;; The entry function called above goes to the next
3423 ;; group automatically, so we go two groups back
3424 ;; if we are searching for the previous group.
3426 (gnus-group-prev-unread-group 2))
3427 (if (not (equal group (gnus-group-group-name)))
3428 (setq group (gnus-group-group-name))
3432 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3433 "Directly jump to the other GROUP from summary buffer.
3434 If SHOW-ALL is non-nil, already read articles are also listed."
3436 (if (eq gnus-summary-buffer (current-buffer))
3437 (list (completing-read
3438 "Group: " gnus-active-hashtb nil t
3439 (when (and gnus-newsgroup-name
3440 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3441 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3442 'gnus-group-history)
3444 (error "%s must be invoked from a gnus summary buffer." this-command)))
3445 (unless (or (zerop (length group))
3446 (and gnus-newsgroup-name
3447 (string-equal gnus-newsgroup-name group)))
3449 (gnus-summary-read-group group show-all
3450 gnus-dont-select-after-jump-to-other-group)))
3452 (defun gnus-summary-read-group-1 (group show-all no-article
3453 kill-buffer no-display
3454 &optional select-articles)
3455 ;; Killed foreign groups can't be entered.
3456 ;; (when (and (not (gnus-group-native-p group))
3457 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3458 ;; (error "Dead non-native groups can't be entered"))
3459 (gnus-message 5 "Retrieving newsgroup: %s..."
3460 (gnus-group-decoded-name group))
3461 (let* ((new-group (gnus-summary-setup-buffer group))
3462 (quit-config (gnus-group-quit-config group))
3463 (did-select (and new-group (gnus-select-newsgroup
3464 group show-all select-articles))))
3466 ;; This summary buffer exists already, so we just select it.
3468 (gnus-set-global-variables)
3470 (gnus-kill-or-deaden-summary kill-buffer))
3471 (gnus-configure-windows 'summary 'force)
3472 (gnus-set-mode-line 'summary)
3473 (gnus-summary-position-point)
3476 ;; We couldn't select this group.
3478 (when (and (eq major-mode 'gnus-summary-mode)
3479 (not (equal (current-buffer) kill-buffer)))
3480 (kill-buffer (current-buffer))
3481 (if (not quit-config)
3483 ;; Update the info -- marks might need to be removed,
3485 (gnus-summary-update-info)
3486 (set-buffer gnus-group-buffer)
3487 (gnus-group-jump-to-group group)
3488 (gnus-group-next-unread-group 1))
3489 (gnus-handle-ephemeral-exit quit-config)))
3490 (let ((grpinfo (gnus-get-info group)))
3491 (if (null (gnus-info-read grpinfo))
3492 (gnus-message 3 "Group %s contains no messages"
3493 (gnus-group-decoded-name group))
3494 (gnus-message 3 "Can't select group")))
3496 ;; The user did a `C-g' while prompting for number of articles,
3497 ;; so we exit this group.
3498 ((eq did-select 'quit)
3499 (and (eq major-mode 'gnus-summary-mode)
3500 (not (equal (current-buffer) kill-buffer))
3501 (kill-buffer (current-buffer)))
3503 (gnus-kill-or-deaden-summary kill-buffer))
3504 (if (not quit-config)
3506 (set-buffer gnus-group-buffer)
3507 (gnus-group-jump-to-group group)
3508 (gnus-group-next-unread-group 1)
3509 (gnus-configure-windows 'group 'force))
3510 (gnus-handle-ephemeral-exit quit-config))
3511 ;; Finally signal the quit.
3513 ;; The group was successfully selected.
3515 (gnus-set-global-variables)
3516 ;; Save the active value in effect when the group was entered.
3517 (setq gnus-newsgroup-active
3519 (gnus-active gnus-newsgroup-name)))
3520 ;; You can change the summary buffer in some way with this hook.
3521 (gnus-run-hooks 'gnus-select-group-hook)
3522 (gnus-update-format-specifications
3523 nil 'summary 'summary-mode 'summary-dummy)
3524 (gnus-update-summary-mark-positions)
3525 ;; Do score processing.
3526 (when gnus-use-scoring
3527 (gnus-possibly-score-headers))
3528 ;; Check whether to fill in the gaps in the threads.
3529 (when gnus-build-sparse-threads
3530 (gnus-build-sparse-threads))
3531 ;; Find the initial limit.
3532 (if gnus-show-threads
3534 (let ((gnus-newsgroup-dormant nil))
3535 (gnus-summary-initial-limit show-all))
3536 (gnus-summary-initial-limit show-all))
3537 ;; When unthreaded, all articles are always shown.
3538 (setq gnus-newsgroup-limit
3540 (lambda (header) (mail-header-number header))
3541 gnus-newsgroup-headers)))
3542 ;; Generate the summary buffer.
3544 (gnus-summary-prepare))
3545 (when gnus-use-trees
3546 (gnus-tree-open group)
3547 (setq gnus-summary-highlight-line-function
3548 'gnus-tree-highlight-article))
3549 ;; If the summary buffer is empty, but there are some low-scored
3550 ;; articles or some excluded dormants, we include these in the
3552 (when (and (zerop (buffer-size))
3554 (cond (gnus-newsgroup-dormant
3555 (gnus-summary-limit-include-dormant))
3556 ((and gnus-newsgroup-scored show-all)
3557 (gnus-summary-limit-include-expunged t))))
3558 ;; Function `gnus-apply-kill-file' must be called in this hook.
3559 (gnus-run-hooks 'gnus-apply-kill-hook)
3560 (if (and (zerop (buffer-size))
3563 ;; This newsgroup is empty.
3564 (gnus-summary-catchup-and-exit nil t)
3565 (gnus-message 6 "No unread news")
3567 (gnus-kill-or-deaden-summary kill-buffer))
3568 ;; Return nil from this function.
3570 ;; Hide conversation thread subtrees. We cannot do this in
3571 ;; gnus-summary-prepare-hook since kill processing may not
3572 ;; work with hidden articles.
3573 (gnus-summary-maybe-hide-threads)
3575 (gnus-kill-or-deaden-summary kill-buffer))
3576 (gnus-summary-auto-select-subject)
3577 ;; Show first unread article if requested.
3578 (if (and (not no-article)
3580 gnus-newsgroup-unreads
3581 gnus-auto-select-first)
3583 (gnus-configure-windows 'summary)
3584 (let ((art (gnus-summary-article-number)))
3585 (unless (and (not gnus-plugged)
3586 (or (memq art gnus-newsgroup-undownloaded)
3587 (memq art gnus-newsgroup-downloadable)))
3588 (gnus-summary-goto-article art))))
3589 ;; Don't select any articles.
3590 (gnus-summary-position-point)
3591 (gnus-configure-windows 'summary 'force)
3592 (gnus-set-mode-line 'summary))
3593 (when (and gnus-auto-center-group
3594 (get-buffer-window gnus-group-buffer t))
3595 ;; Gotta use windows, because recenter does weird stuff if
3596 ;; the current buffer ain't the displayed window.
3597 (let ((owin (selected-window)))
3598 (select-window (get-buffer-window gnus-group-buffer t))
3599 (when (gnus-group-goto-group group)
3601 (select-window owin)))
3602 ;; Mark this buffer as "prepared".
3603 (setq gnus-newsgroup-prepared t)
3604 (gnus-run-hooks 'gnus-summary-prepared-hook)
3605 (unless (gnus-ephemeral-group-p group)
3606 (gnus-group-update-group group))
3609 (defun gnus-summary-auto-select-subject ()
3610 "Select the subject line on initial group entry."
3611 (goto-char (point-min))
3613 ((eq gnus-auto-select-subject 'best)
3614 (gnus-summary-best-unread-subject))
3615 ((eq gnus-auto-select-subject 'unread)
3616 (gnus-summary-first-unread-subject))
3617 ((eq gnus-auto-select-subject 'unseen)
3618 (gnus-summary-first-unseen-subject))
3619 ((eq gnus-auto-select-subject 'unseen-or-unread)
3620 (gnus-summary-first-unseen-or-unread-subject))
3621 ((eq gnus-auto-select-subject 'first)
3624 ((functionp gnus-auto-select-subject)
3625 (funcall gnus-auto-select-subject))))
3627 (defun gnus-summary-prepare ()
3628 "Generate the summary buffer."
3630 (let ((buffer-read-only nil))
3632 (setq gnus-newsgroup-data nil
3633 gnus-newsgroup-data-reverse nil)
3634 (gnus-run-hooks 'gnus-summary-generate-hook)
3635 ;; Generate the buffer, either with threads or without.
3636 (when gnus-newsgroup-headers
3637 (gnus-summary-prepare-threads
3638 (if gnus-show-threads
3639 (gnus-sort-gathered-threads
3640 (funcall gnus-summary-thread-gathering-function
3642 (gnus-cut-threads (gnus-make-threads)))))
3643 ;; Unthreaded display.
3644 (gnus-sort-articles gnus-newsgroup-headers))))
3645 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3646 ;; Call hooks for modifying summary buffer.
3647 (goto-char (point-min))
3648 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3650 (defsubst gnus-general-simplify-subject (subject)
3651 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3654 ;; Truncate the subject.
3655 (gnus-simplify-subject-functions
3656 (gnus-map-function gnus-simplify-subject-functions subject))
3657 ((numberp gnus-summary-gather-subject-limit)
3658 (setq subject (gnus-simplify-subject-re subject))
3659 (if (> (length subject) gnus-summary-gather-subject-limit)
3660 (substring subject 0 gnus-summary-gather-subject-limit)
3662 ;; Fuzzily simplify it.
3663 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3664 (gnus-simplify-subject-fuzzy subject))
3665 ;; Just remove the leading "Re:".
3667 (gnus-simplify-subject-re subject))))
3669 (if (and gnus-summary-gather-exclude-subject
3670 (string-match gnus-summary-gather-exclude-subject subject))
3671 nil ; This article shouldn't be gathered
3674 (defun gnus-summary-simplify-subject-query ()
3675 "Query where the respool algorithm would put this article."
3677 (gnus-summary-select-article)
3679 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3681 (defun gnus-gather-threads-by-subject (threads)
3682 "Gather threads by looking at Subject headers."
3683 (if (not gnus-summary-make-false-root)
3685 (let ((hashtb (gnus-make-hashtable 1024))
3688 subject hthread whole-subject)
3690 (setq subject (gnus-general-simplify-subject
3691 (setq whole-subject (mail-header-subject
3694 (if (setq hthread (gnus-gethash subject hashtb))
3696 ;; We enter a dummy root into the thread, if we
3697 ;; haven't done that already.
3698 (unless (stringp (caar hthread))
3699 (setcar hthread (list whole-subject (car hthread))))
3700 ;; We add this new gathered thread to this gathered
3702 (setcdr (car hthread)
3703 (nconc (cdar hthread) (list (car threads))))
3704 ;; Remove it from the list of threads.
3705 (setcdr prev (cdr threads))
3706 (setq threads prev))
3707 ;; Enter this thread into the hash table.
3708 (gnus-sethash subject
3709 (if gnus-summary-make-false-root-always
3711 ;; If you want a dummy root above all
3713 (setcar threads (list whole-subject
3719 (setq threads (cdr threads)))
3722 (defun gnus-gather-threads-by-references (threads)
3723 "Gather threads by looking at References headers."
3724 (let ((idhashtb (gnus-make-hashtable 1024))
3725 (thhashtb (gnus-make-hashtable 1024))
3728 ids references id gthread gid entered ref)
3730 (when (setq references (mail-header-references (caar threads)))
3731 (setq id (mail-header-id (caar threads))
3732 ids (inline (gnus-split-references references))
3734 (while (setq ref (pop ids))
3735 (setq ids (delete ref ids))
3736 (if (not (setq gid (gnus-gethash ref idhashtb)))
3738 (gnus-sethash ref id idhashtb)
3739 (gnus-sethash id threads thhashtb))
3740 (setq gthread (gnus-gethash gid thhashtb))
3742 ;; We enter a dummy root into the thread, if we
3743 ;; haven't done that already.
3744 (unless (stringp (caar gthread))
3745 (setcar gthread (list (mail-header-subject (caar gthread))
3747 ;; We add this new gathered thread to this gathered
3749 (setcdr (car gthread)
3750 (nconc (cdar gthread) (list (car threads)))))
3751 ;; Add it into the thread hash table.
3752 (gnus-sethash id gthread thhashtb)
3754 ;; Remove it from the list of threads.
3755 (setcdr prev (cdr threads))
3756 (setq threads prev))))
3758 (setq threads (cdr threads)))
3761 (defun gnus-sort-gathered-threads (threads)
3762 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3763 (let ((result threads))
3765 (when (stringp (caar threads))
3766 (setcdr (car threads)
3767 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3768 (setq threads (cdr threads)))
3771 (defun gnus-thread-loop-p (root thread)
3772 "Say whether ROOT is in THREAD."
3773 (let ((stack (list thread))
3776 (while (setq thread (pop stack))
3777 (setq th (cdr thread))
3779 (not (eq (caar th) root)))
3782 ;; We have found a loop.
3784 (setcdr thread (delq (car th) (cdr thread)))
3785 (if (boundp (setq ref-dep (intern "none"
3786 gnus-newsgroup-dependencies)))
3787 (setcdr (symbol-value ref-dep)
3788 (nconc (cdr (symbol-value ref-dep))
3790 (set ref-dep (list nil (car th))))
3793 ;; Push all the subthreads onto the stack.
3794 (push (cdr thread) stack)))
3797 (defun gnus-make-threads ()
3798 "Go through the dependency hashtb and find the roots. Return all threads."
3800 (while (catch 'infloop
3803 ;; Deal with self-referencing References loops.
3804 (when (and (car (symbol-value refs))
3811 (car (symbol-value refs)) thread))
3812 (cdr (symbol-value refs)))))))
3815 (unless (car (symbol-value refs))
3816 ;; These threads do not refer back to any other articles,
3817 ;; so they're roots.
3818 (setq threads (append (cdr (symbol-value refs)) threads))))
3819 gnus-newsgroup-dependencies)))
3822 ;; Build the thread tree.
3823 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3824 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3826 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3827 if it was already present.
3829 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3830 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3831 Message-IDs will be renamed to a unique Message-ID before being
3834 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3835 (let* ((id (mail-header-id header))
3836 (id-dep (and id (intern id dependencies)))
3837 parent-id ref ref-dep ref-header replaced)
3838 ;; Enter this `header' in the `dependencies' table.
3842 ;; The first two cases do the normal part: enter a new `header'
3843 ;; in the `dependencies' table.
3844 ((not (boundp id-dep))
3845 (set id-dep (list header)))
3846 ((null (car (symbol-value id-dep)))
3847 (setcar (symbol-value id-dep) header))
3849 ;; From here the `header' was already present in the
3850 ;; `dependencies' table.
3852 ;; Overrides an existing entry;
3853 ;; just set the header part of the entry.
3854 (setcar (symbol-value id-dep) header)
3857 ;; Renames the existing `header' to a unique Message-ID.
3858 ((not gnus-summary-ignore-duplicates)
3859 ;; An article with this Message-ID has already been seen.
3860 ;; We rename the Message-ID.
3861 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3863 (mail-header-set-id header id))
3865 ;; The last case ignores an existing entry, except it adds any
3866 ;; additional Xrefs (in case the two articles came from different
3868 ;; Also sets `header' to `nil' meaning that the `dependencies'
3869 ;; table was *not* modified.
3871 (mail-header-set-xref
3872 (car (symbol-value id-dep))
3873 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3875 (or (mail-header-xref header) "")))
3878 (when (and header (not replaced))
3879 ;; First check that we are not creating a References loop.
3880 (setq parent-id (gnus-parent-id (mail-header-references header)))
3881 (setq ref parent-id)
3883 (setq ref-dep (intern-soft ref dependencies))
3885 (setq ref-header (car (symbol-value ref-dep))))
3886 (if (string= id ref)
3887 ;; Yuk! This is a reference loop. Make the article be a
3890 (mail-header-set-references (car (symbol-value id-dep)) "none")
3892 (setq parent-id nil))
3893 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3894 (setq ref-dep (intern (or parent-id "none") dependencies))
3895 (if (boundp ref-dep)
3896 (setcdr (symbol-value ref-dep)
3897 (nconc (cdr (symbol-value ref-dep))
3898 (list (symbol-value id-dep))))
3899 (set ref-dep (list nil (symbol-value id-dep)))))
3902 (defun gnus-extract-message-id-from-in-reply-to (string)
3903 (if (string-match "<[^>]+>" string)
3904 (substring string (match-beginning 0) (match-end 0))
3907 (defun gnus-build-sparse-threads ()
3908 (let ((headers gnus-newsgroup-headers)
3909 (mail-parse-charset gnus-newsgroup-charset)
3910 (gnus-summary-ignore-duplicates t)
3911 header references generation relations
3912 subject child end new-child date)
3913 ;; First we create an alist of generations/relations, where
3914 ;; generations is how much we trust the relation, and the relation
3916 (gnus-message 7 "Making sparse threads...")
3918 (nnheader-set-temp-buffer " *gnus sparse threads*")
3919 (while (setq header (pop headers))
3920 (when (and (setq references (mail-header-references header))
3921 (not (string= references "")))
3923 (setq child (mail-header-id header)
3924 subject (mail-header-subject header)
3925 date (mail-header-date header)
3927 (while (search-backward ">" nil t)
3928 (setq end (1+ (point)))
3929 (when (search-backward "<" nil t)
3930 (setq new-child (buffer-substring (point) end))
3931 (push (list (incf generation)
3932 child (setq child new-child)
3936 (push (list (1+ generation) child nil subject) relations))
3938 (kill-buffer (current-buffer)))
3939 ;; Sort over trustworthiness.
3942 (when (gnus-dependencies-add-header
3943 (make-full-mail-header-from-decoded-header
3944 gnus-reffed-article-number
3945 (nth 3 relation) "" (or (nth 4 relation) "")
3947 (or (nth 2 relation) "") 0 0 "")
3948 gnus-newsgroup-dependencies nil)
3949 (push gnus-reffed-article-number gnus-newsgroup-limit)
3950 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3951 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3952 gnus-newsgroup-reads)
3953 (decf gnus-reffed-article-number)))
3954 (sort relations 'car-less-than-car))
3955 (gnus-message 7 "Making sparse threads...done")))
3957 (defun gnus-build-old-threads ()
3958 ;; Look at all the articles that refer back to old articles, and
3959 ;; fetch the headers for the articles that aren't there. This will
3960 ;; build complete threads - if the roots haven't been expired by the
3962 (let ((mail-parse-charset gnus-newsgroup-charset)
3966 (when (not (car (symbol-value refs)))
3967 (setq heads (cdr (symbol-value refs)))
3969 (if (memq (mail-header-number (caar heads))
3970 gnus-newsgroup-dormant)
3971 (setq heads (cdr heads))
3972 (setq id (symbol-name refs))
3973 (while (and (setq id (gnus-build-get-header id))
3974 (not (car (gnus-id-to-thread id)))))
3975 (setq heads nil)))))
3976 gnus-newsgroup-dependencies)))
3978 ;; This function has to be called with point after the article number
3979 ;; on the beginning of the line.
3980 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3981 (let ((eol (gnus-point-at-eol))
3982 (buffer (current-buffer))
3983 header references in-reply-to)
3985 ;; overview: [num subject from date id refs chars lines misc]
3988 (narrow-to-region (point) eol)
3993 (make-full-mail-header
3995 (nnheader-nov-field) ; subject
3996 (nnheader-nov-field) ; from
3997 (nnheader-nov-field) ; date
3998 (nnheader-nov-read-message-id) ; id
3999 (nnheader-nov-field) ; refs
4000 (nnheader-nov-read-integer) ; chars
4001 (nnheader-nov-read-integer) ; lines
4003 (if (looking-at "Xref: ")
4004 (goto-char (match-end 0)))
4005 (nnheader-nov-field)) ; Xref
4006 (nnheader-nov-parse-extra)))) ; extra
4010 (when (and (string= references "")
4011 (setq in-reply-to (mail-header-extra header))
4012 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4013 (mail-header-set-references
4014 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4016 (when gnus-alter-header-function
4017 (funcall gnus-alter-header-function header))
4018 (gnus-dependencies-add-header header dependencies force-new)))
4020 (defun gnus-build-get-header (id)
4021 "Look through the buffer of NOV lines and find the header to ID.
4022 Enter this line into the dependencies hash table, and return
4023 the id of the parent article (if any)."
4024 (let ((deps gnus-newsgroup-dependencies)
4028 (set-buffer nntp-server-buffer)
4029 (let ((case-fold-search nil))
4030 (goto-char (point-min))
4031 (while (and (not found)
4032 (search-forward id nil t))
4034 (setq found (looking-at
4035 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4036 (regexp-quote id))))
4037 (or found (beginning-of-line 2)))
4041 (setq header (gnus-nov-parse-line
4042 (read (current-buffer)) deps))
4043 (gnus-parent-id (mail-header-references header))))))
4045 (let ((number (mail-header-number header)))
4046 (push number gnus-newsgroup-limit)
4047 (push header gnus-newsgroup-headers)
4048 (if (memq number gnus-newsgroup-unselected)
4050 (setq gnus-newsgroup-unreads
4051 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4053 (setq gnus-newsgroup-unselected
4054 (delq number gnus-newsgroup-unselected)))
4055 (push number gnus-newsgroup-ancient)))))))
4057 (defun gnus-build-all-threads ()
4058 "Read all the headers."
4059 (let ((gnus-summary-ignore-duplicates t)
4060 (mail-parse-charset gnus-newsgroup-charset)
4061 (dependencies gnus-newsgroup-dependencies)
4064 (set-buffer nntp-server-buffer)
4065 (let ((case-fold-search nil))
4066 (goto-char (point-min))
4069 (setq article (read (current-buffer))
4070 header (gnus-nov-parse-line article dependencies)))
4073 (set-buffer gnus-summary-buffer)
4074 (push header gnus-newsgroup-headers)
4075 (if (memq (setq article (mail-header-number header))
4076 gnus-newsgroup-unselected)
4078 (setq gnus-newsgroup-unreads
4079 (gnus-add-to-sorted-list
4080 gnus-newsgroup-unreads article))
4081 (setq gnus-newsgroup-unselected
4082 (delq article gnus-newsgroup-unselected)))
4083 (push article gnus-newsgroup-ancient)))
4084 (forward-line 1)))))))
4086 (defun gnus-summary-update-article-line (article header)
4087 "Update the line for ARTICLE using HEADERS."
4088 (let* ((id (mail-header-id header))
4089 (thread (gnus-id-to-thread id)))
4091 (error "Article in no thread"))
4092 ;; Update the thread.
4093 (setcar thread header)
4094 (gnus-summary-goto-subject article)
4095 (let* ((datal (gnus-data-find-list article))
4097 (buffer-read-only nil)
4098 (level (gnus-summary-thread-level)))
4100 (let ((inserted (- (point)
4102 (gnus-summary-insert-line
4104 (memq article gnus-newsgroup-undownloaded)
4105 (gnus-article-mark article)
4106 (memq article gnus-newsgroup-replied)
4107 (memq article gnus-newsgroup-expirable)
4108 ;; Only insert the Subject string when it's different
4109 ;; from the previous Subject string.
4114 (mail-header-subject
4117 (gnus-data-find-list
4119 (gnus-data-list t)))))
4120 ;; Error on the side of excessive subjects.
4122 (mail-header-subject header)))
4124 (mail-header-subject header))
4125 nil (cdr (assq article gnus-newsgroup-scored))
4126 (memq article gnus-newsgroup-processable))
4129 (gnus-data-update-list
4131 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4133 (defun gnus-summary-update-article (article &optional iheader)
4134 "Update ARTICLE in the summary buffer."
4135 (set-buffer gnus-summary-buffer)
4136 (let* ((header (gnus-summary-article-header article))
4137 (id (mail-header-id header))
4138 (data (gnus-data-find article))
4139 (thread (gnus-id-to-thread id))
4140 (references (mail-header-references header))
4144 (when (and references
4145 (not (equal "" references)))
4148 (buffer-read-only nil)
4154 (delq thread parent)))
4155 (if (gnus-summary-insert-subject id header)
4156 ;; Set the (possibly) new article number in the data structure.
4157 (gnus-data-set-number data (gnus-id-to-article id))
4161 (defun gnus-rebuild-thread (id &optional line)
4162 "Rebuild the thread containing ID.
4163 If LINE, insert the rebuilt thread starting on line LINE."
4164 (let ((buffer-read-only nil)
4165 old-pos current thread data)
4166 (if (not gnus-show-threads)
4167 (setq thread (list (car (gnus-id-to-thread id))))
4168 ;; Get the thread this article is part of.
4169 (setq thread (gnus-remove-thread id)))
4170 (setq old-pos (gnus-point-at-bol))
4171 (setq current (save-excursion
4172 (and (re-search-backward "[\r\n]" nil t)
4173 (gnus-summary-article-number))))
4174 ;; If this is a gathered thread, we have to go some re-gathering.
4175 (when (stringp (car thread))
4176 (let ((subject (car thread))
4178 (setq thread (cdr thread))
4180 (unless (memq (setq thr (gnus-id-to-thread
4182 (mail-header-id (caar thread)))))
4185 (setq thread (cdr thread)))
4186 ;; We now have all (unique) roots.
4187 (if (= (length roots) 1)
4188 ;; All the loose roots are now one solid root.
4189 (setq thread (car roots))
4190 (setq thread (cons subject (gnus-sort-threads roots))))))
4192 ;; We then insert this thread into the summary buffer.
4194 (goto-char (point-min))
4195 (forward-line (1- line)))
4196 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4197 (if gnus-show-threads
4198 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4199 (gnus-summary-prepare-unthreaded thread))
4200 (setq data (nreverse gnus-newsgroup-data))
4201 (setq threads gnus-newsgroup-threads))
4202 ;; We splice the new data into the data structure.
4203 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4204 ;;!!! then we want to insert at the beginning of the buffer.
4205 ;;!!! That happens to be true with Gnus now, but that may
4206 ;;!!! change in the future. Perhaps.
4207 (gnus-data-enter-list
4208 (if line nil current) data (- (point) old-pos))
4209 (setq gnus-newsgroup-threads
4210 (nconc threads gnus-newsgroup-threads))
4211 (gnus-data-compute-positions))))
4213 (defun gnus-number-to-header (number)
4214 "Return the header for article NUMBER."
4215 (let ((headers gnus-newsgroup-headers))
4217 (not (= number (mail-header-number (car headers)))))
4222 (defun gnus-parent-headers (in-headers &optional generation)
4223 "Return the headers of the GENERATIONeth parent of HEADERS."
4225 (setq generation 1))
4227 (headers in-headers)
4230 (not (zerop generation))
4231 (setq references (mail-header-references headers)))
4232 (setq headers (if (and references
4233 (setq parent (gnus-parent-id references)))
4234 (car (gnus-id-to-thread parent))
4237 (and (not (eq headers in-headers))
4240 (defun gnus-id-to-thread (id)
4241 "Return the (sub-)thread where ID appears."
4242 (gnus-gethash id gnus-newsgroup-dependencies))
4244 (defun gnus-id-to-article (id)
4245 "Return the article number of ID."
4246 (let ((thread (gnus-id-to-thread id)))
4249 (mail-header-number (car thread)))))
4251 (defun gnus-id-to-header (id)
4252 "Return the article headers of ID."
4253 (car (gnus-id-to-thread id)))
4255 (defun gnus-article-displayed-root-p (article)
4256 "Say whether ARTICLE is a root(ish) article."
4257 (let ((level (gnus-summary-thread-level article))
4258 (refs (mail-header-references (gnus-summary-article-header article)))
4264 ((null (gnus-parent-id refs)) t)
4266 (null (setq particle (gnus-id-to-article
4267 (gnus-parent-id refs))))
4268 (null (gnus-summary-thread-level particle)))))))
4270 (defun gnus-root-id (id)
4271 "Return the id of the root of the thread where ID appears."
4273 (while (and id (setq prev (car (gnus-id-to-thread id))))
4275 id (gnus-parent-id (mail-header-references prev))))
4278 (defun gnus-articles-in-thread (thread)
4279 "Return the list of articles in THREAD."
4280 (cons (mail-header-number (car thread))
4281 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4283 (defun gnus-remove-thread (id &optional dont-remove)
4284 "Remove the thread that has ID in it."
4285 (let (headers thread last-id)
4286 ;; First go up in this thread until we find the root.
4287 (setq last-id (gnus-root-id id)
4288 headers (message-flatten-list (gnus-id-to-thread last-id)))
4289 ;; We have now found the real root of this thread. It might have
4290 ;; been gathered into some loose thread, so we have to search
4291 ;; through the threads to find the thread we wanted.
4292 (let ((threads gnus-newsgroup-threads)
4295 (setq sub (car threads))
4296 (if (stringp (car sub))
4297 ;; This is a gathered thread, so we look at the roots
4298 ;; below it to find whether this article is in this
4301 (setq sub (cdr sub))
4303 (when (member (caar sub) headers)
4304 (setq thread (car threads)
4307 (setq sub (cdr sub))))
4308 ;; It's an ordinary thread, so we check it.
4309 (when (eq (car sub) (car headers))
4312 (setq threads (cdr threads)))
4313 ;; If this article is in no thread, then it's a root.
4316 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4317 (setq thread (gnus-id-to-thread last-id)))
4320 thread ; We return this thread.
4322 (if (stringp (car thread))
4324 ;; If we use dummy roots, then we have to remove the
4325 ;; dummy root as well.
4326 (when (eq gnus-summary-make-false-root 'dummy)
4327 ;; We go to the dummy root by going to
4328 ;; the first sub-"thread", and then one line up.
4329 (gnus-summary-goto-article
4330 (mail-header-number (caadr thread)))
4333 (gnus-data-compute-positions))
4334 (setq thread (cdr thread))
4336 (gnus-remove-thread-1 (car thread))
4337 (setq thread (cdr thread))))
4338 (gnus-remove-thread-1 thread))))))))
4340 (defun gnus-remove-thread-1 (thread)
4341 "Remove the thread THREAD recursively."
4342 (let ((number (mail-header-number (pop thread)))
4344 (setq thread (reverse thread))
4346 (gnus-remove-thread-1 (pop thread)))
4347 (when (setq d (gnus-data-find number))
4348 (goto-char (gnus-data-pos d))
4349 (gnus-summary-show-thread)
4352 (- (gnus-point-at-bol)
4354 (1+ (gnus-point-at-eol))
4355 (gnus-delete-line)))))))
4357 (defun gnus-sort-threads-1 (threads func)
4358 (sort (mapcar (lambda (thread)
4361 (gnus-sort-threads-1 (cdr thread) func))))
4364 (defun gnus-sort-threads (threads)
4366 (if (not gnus-thread-sort-functions)
4368 (gnus-message 8 "Sorting threads...")
4369 (let ((max-lisp-eval-depth 5000))
4370 (prog1 (gnus-sort-threads-1
4372 (gnus-make-sort-function gnus-thread-sort-functions))
4373 (gnus-message 8 "Sorting threads...done")))))
4375 (defun gnus-sort-articles (articles)
4377 (when gnus-article-sort-functions
4378 (gnus-message 7 "Sorting articles...")
4380 (setq gnus-newsgroup-headers
4381 (sort articles (gnus-make-sort-function
4382 gnus-article-sort-functions)))
4383 (gnus-message 7 "Sorting articles...done"))))
4385 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4386 (defmacro gnus-thread-header (thread)
4387 "Return header of first article in THREAD.
4388 Note that THREAD must never, ever be anything else than a variable -
4389 using some other form will lead to serious barfage."
4390 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4391 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4392 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4395 (defsubst gnus-article-sort-by-number (h1 h2)
4396 "Sort articles by article number."
4397 (< (mail-header-number h1)
4398 (mail-header-number h2)))
4400 (defun gnus-thread-sort-by-number (h1 h2)
4401 "Sort threads by root article number."
4402 (gnus-article-sort-by-number
4403 (gnus-thread-header h1) (gnus-thread-header h2)))
4405 (defsubst gnus-article-sort-by-random (h1 h2)
4406 "Sort articles by article number."
4409 (defun gnus-thread-sort-by-random (h1 h2)
4410 "Sort threads by root article number."
4411 (gnus-article-sort-by-random
4412 (gnus-thread-header h1) (gnus-thread-header h2)))
4414 (defsubst gnus-article-sort-by-lines (h1 h2)
4415 "Sort articles by article Lines header."
4416 (< (mail-header-lines h1)
4417 (mail-header-lines h2)))
4419 (defun gnus-thread-sort-by-lines (h1 h2)
4420 "Sort threads by root article Lines header."
4421 (gnus-article-sort-by-lines
4422 (gnus-thread-header h1) (gnus-thread-header h2)))
4424 (defsubst gnus-article-sort-by-chars (h1 h2)
4425 "Sort articles by octet length."
4426 (< (mail-header-chars h1)
4427 (mail-header-chars h2)))
4429 (defun gnus-thread-sort-by-chars (h1 h2)
4430 "Sort threads by root article octet length."
4431 (gnus-article-sort-by-chars
4432 (gnus-thread-header h1) (gnus-thread-header h2)))
4434 (defsubst gnus-article-sort-by-author (h1 h2)
4435 "Sort articles by root author."
4437 (let ((addr (car (mime-entity-read-field h1 'From))))
4438 (or (std11-full-name-string addr)
4439 (std11-address-string addr)
4441 (let ((addr (car (mime-entity-read-field h2 'From))))
4442 (or (std11-full-name-string addr)
4443 (std11-address-string addr)
4447 (defun gnus-thread-sort-by-author (h1 h2)
4448 "Sort threads by root author."
4449 (gnus-article-sort-by-author
4450 (gnus-thread-header h1) (gnus-thread-header h2)))
4452 (defsubst gnus-article-sort-by-subject (h1 h2)
4453 "Sort articles by root subject."
4455 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4456 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4458 (defun gnus-thread-sort-by-subject (h1 h2)
4459 "Sort threads by root subject."
4460 (gnus-article-sort-by-subject
4461 (gnus-thread-header h1) (gnus-thread-header h2)))
4463 (defsubst gnus-article-sort-by-date (h1 h2)
4464 "Sort articles by root article date."
4466 (gnus-date-get-time (mail-header-date h1))
4467 (gnus-date-get-time (mail-header-date h2))))
4469 (defun gnus-thread-sort-by-date (h1 h2)
4470 "Sort threads by root article date."
4471 (gnus-article-sort-by-date
4472 (gnus-thread-header h1) (gnus-thread-header h2)))
4474 (defsubst gnus-article-sort-by-score (h1 h2)
4475 "Sort articles by root article score.
4476 Unscored articles will be counted as having a score of zero."
4477 (> (or (cdr (assq (mail-header-number h1)
4478 gnus-newsgroup-scored))
4479 gnus-summary-default-score 0)
4480 (or (cdr (assq (mail-header-number h2)
4481 gnus-newsgroup-scored))
4482 gnus-summary-default-score 0)))
4484 (defun gnus-thread-sort-by-score (h1 h2)
4485 "Sort threads by root article score."
4486 (gnus-article-sort-by-score
4487 (gnus-thread-header h1) (gnus-thread-header h2)))
4489 (defun gnus-thread-sort-by-total-score (h1 h2)
4490 "Sort threads by the sum of all scores in the thread.
4491 Unscored articles will be counted as having a score of zero."
4492 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4494 (defun gnus-thread-total-score (thread)
4495 ;; This function find the total score of THREAD.
4500 (if (stringp (car thread))
4501 (apply gnus-thread-score-function 0
4502 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4503 (gnus-thread-total-score-1 thread)))
4505 (gnus-thread-total-score-1 (list thread)))))
4507 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4508 "Sort threads such that the thread with the most recently arrived article comes first."
4509 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4511 (defun gnus-thread-highest-number (thread)
4512 "Return the highest article number in THREAD."
4513 (apply 'max (mapcar (lambda (header)
4514 (mail-header-number header))
4515 (message-flatten-list thread))))
4517 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4518 "Sort threads such that the thread with the most recently dated article comes first."
4519 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4521 (defun gnus-thread-latest-date (thread)
4522 "Return the highest article date in THREAD."
4523 (let ((previous-time 0))
4530 (mail-header-parse-date (mail-header-date header))
4531 (error previous-time)))))
4533 (message-flatten-list thread)
4535 (< (mail-header-number h1)
4536 (mail-header-number h2))))))))
4538 (defun gnus-thread-total-score-1 (root)
4539 ;; This function find the total score of the thread below ROOT.
4540 (setq root (car root))
4541 (apply gnus-thread-score-function
4543 (mapcar 'gnus-thread-total-score
4544 (cdr (gnus-id-to-thread (mail-header-id root))))
4545 (when (> (mail-header-number root) 0)
4546 (list (or (cdr (assq (mail-header-number root)
4547 gnus-newsgroup-scored))
4548 gnus-summary-default-score 0))))
4549 (list gnus-summary-default-score)
4552 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4553 (defvar gnus-tmp-prev-subject nil)
4554 (defvar gnus-tmp-false-parent nil)
4555 (defvar gnus-tmp-root-expunged nil)
4556 (defvar gnus-tmp-dummy-line nil)
4558 (eval-when-compile (defvar gnus-tmp-header))
4559 (defun gnus-extra-header (type &optional header)
4560 "Return the extra header of TYPE."
4561 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4564 (defvar gnus-tmp-thread-tree-header-string "")
4566 (defcustom gnus-sum-thread-tree-root "> "
4567 "With %B spec, used for the root of a thread.
4568 If nil, use subject instead."
4570 :group 'gnus-thread)
4571 (defcustom gnus-sum-thread-tree-false-root "> "
4572 "With %B spec, used for a false root of a thread.
4573 If nil, use subject instead."
4575 :group 'gnus-thread)
4576 (defcustom gnus-sum-thread-tree-single-indent ""
4577 "With %B spec, used for a thread with just one message.
4578 If nil, use subject instead."
4580 :group 'gnus-thread)
4581 (defcustom gnus-sum-thread-tree-vertical "| "
4582 "With %B spec, used for drawing a vertical line."
4584 :group 'gnus-thread)
4585 (defcustom gnus-sum-thread-tree-indent " "
4586 "With %B spec, used for indenting."
4588 :group 'gnus-thread)
4589 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4590 "With %B spec, used for a leaf with brothers."
4592 :group 'gnus-thread)
4593 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4594 "With %B spec, used for a leaf without brothers."
4596 :group 'gnus-thread)
4598 (defun gnus-summary-prepare-threads (threads)
4599 "Prepare summary buffer from THREADS and indentation LEVEL.
4600 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4601 or a straight list of headers."
4602 (gnus-message 7 "Generating summary...")
4604 (setq gnus-newsgroup-threads threads)
4607 (let ((gnus-tmp-level 0)
4608 (default-score (or gnus-summary-default-score 0))
4609 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4610 (building-line-count gnus-summary-display-while-building)
4611 (building-count (integerp gnus-summary-display-while-building))
4612 thread number subject stack state gnus-tmp-gathered beg-match
4613 new-roots gnus-tmp-new-adopts thread-end simp-subject
4614 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4615 gnus-tmp-replied gnus-tmp-subject-or-nil
4616 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4617 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4618 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4621 (setq gnus-tmp-prev-subject nil
4622 gnus-tmp-thread-tree-header-string "")
4624 (if (vectorp (car threads))
4625 ;; If this is a straight (sic) list of headers, then a
4626 ;; threaded summary display isn't required, so we just create
4627 ;; an unthreaded one.
4628 (gnus-summary-prepare-unthreaded threads)
4630 ;; Do the threaded display.
4632 (if gnus-summary-display-while-building
4633 (switch-to-buffer (buffer-name)))
4634 (while (or threads stack gnus-tmp-new-adopts new-roots)
4636 (if (and (= gnus-tmp-level 0)
4639 (not gnus-tmp-false-parent)
4640 (or gnus-tmp-new-adopts new-roots))
4641 (if gnus-tmp-new-adopts
4642 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4643 thread (list (car gnus-tmp-new-adopts))
4644 gnus-tmp-header (caar thread)
4645 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4647 (setq thread (list (car new-roots))
4648 gnus-tmp-header (caar thread)
4649 new-roots (cdr new-roots))))
4652 ;; If there are some threads, we do them before the
4653 ;; threads on the stack.
4654 (setq thread threads
4655 gnus-tmp-header (caar thread))
4656 ;; There were no current threads, so we pop something off
4658 (setq state (car stack)
4659 gnus-tmp-level (car state)
4660 tree-stack (cadr state)
4661 thread (caddr state)
4663 gnus-tmp-header (caar thread))))
4665 (setq gnus-tmp-false-parent nil)
4666 (setq gnus-tmp-root-expunged nil)
4667 (setq thread-end nil)
4669 (if (stringp gnus-tmp-header)
4670 ;; The header is a dummy root.
4672 ((eq gnus-summary-make-false-root 'adopt)
4673 ;; We let the first article adopt the rest.
4674 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4676 (setq gnus-tmp-gathered
4678 (lambda (h) (mail-header-number (car h)))
4681 (setq thread (cons (list (caar thread)
4684 (setq gnus-tmp-level -1
4685 gnus-tmp-false-parent t))
4686 ((eq gnus-summary-make-false-root 'empty)
4687 ;; We print adopted articles with empty subject fields.
4688 (setq gnus-tmp-gathered
4690 (lambda (h) (mail-header-number (car h)))
4693 (setq gnus-tmp-level -1))
4694 ((eq gnus-summary-make-false-root 'dummy)
4695 ;; We remember that we probably want to output a dummy
4697 (setq gnus-tmp-dummy-line gnus-tmp-header)
4698 (setq gnus-tmp-prev-subject gnus-tmp-header))
4700 ;; We do not make a root for the gathered
4701 ;; sub-threads at all.
4702 (setq gnus-tmp-level -1)))
4704 (setq number (mail-header-number gnus-tmp-header)
4705 subject (mail-header-subject gnus-tmp-header)
4706 simp-subject (gnus-simplify-subject-fully subject))
4709 ;; If the thread has changed subject, we might want to make
4710 ;; this subthread into a root.
4711 ((and (null gnus-thread-ignore-subject)
4712 (not (zerop gnus-tmp-level))
4713 gnus-tmp-prev-subject
4714 (not (string= gnus-tmp-prev-subject simp-subject)))
4715 (setq new-roots (nconc new-roots (list (car thread)))
4717 gnus-tmp-header nil))
4718 ;; If the article lies outside the current limit,
4719 ;; then we do not display it.
4720 ((not (memq number gnus-newsgroup-limit))
4721 (setq gnus-tmp-gathered
4723 (lambda (h) (mail-header-number (car h)))
4726 (setq gnus-tmp-new-adopts (if (cdar thread)
4727 (append gnus-tmp-new-adopts
4729 gnus-tmp-new-adopts)
4731 gnus-tmp-header nil)
4732 (when (zerop gnus-tmp-level)
4733 (setq gnus-tmp-root-expunged t)))
4734 ;; Perhaps this article is to be marked as read?
4735 ((and gnus-summary-mark-below
4736 (< (or (cdr (assq number gnus-newsgroup-scored))
4738 gnus-summary-mark-below)
4739 ;; Don't touch sparse articles.
4740 (not (gnus-summary-article-sparse-p number))
4741 (not (gnus-summary-article-ancient-p number)))
4742 (setq gnus-newsgroup-unreads
4743 (delq number gnus-newsgroup-unreads))
4744 (if gnus-newsgroup-auto-expire
4745 (setq gnus-newsgroup-expirable
4746 (gnus-add-to-sorted-list
4747 gnus-newsgroup-expirable number))
4748 (push (cons number gnus-low-score-mark)
4749 gnus-newsgroup-reads))))
4751 (when gnus-tmp-header
4752 ;; We may have an old dummy line to output before this
4754 (when (and gnus-tmp-dummy-line
4757 (mail-header-subject gnus-tmp-header)))
4758 (gnus-summary-insert-dummy-line
4759 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4760 (setq gnus-tmp-dummy-line nil))
4762 ;; Compute the mark.
4763 (setq gnus-tmp-unread (gnus-article-mark number))
4765 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4766 gnus-tmp-header gnus-tmp-level)
4767 gnus-newsgroup-data)
4769 ;; Actually insert the line.
4771 gnus-tmp-subject-or-nil
4773 ((and gnus-thread-ignore-subject
4774 gnus-tmp-prev-subject
4775 (not (string= gnus-tmp-prev-subject simp-subject)))
4777 ((zerop gnus-tmp-level)
4778 (if (and (eq gnus-summary-make-false-root 'empty)
4779 (memq number gnus-tmp-gathered)
4780 gnus-tmp-prev-subject
4781 (string= gnus-tmp-prev-subject simp-subject))
4782 gnus-summary-same-subject
4784 (t gnus-summary-same-subject)))
4785 (if (and (eq gnus-summary-make-false-root 'adopt)
4786 (= gnus-tmp-level 1)
4787 (memq number gnus-tmp-gathered))
4788 (setq gnus-tmp-opening-bracket ?\<
4789 gnus-tmp-closing-bracket ?\>)
4790 (setq gnus-tmp-opening-bracket ?\[
4791 gnus-tmp-closing-bracket ?\]))
4793 gnus-tmp-indentation
4794 (aref gnus-thread-indent-array gnus-tmp-level)
4795 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4796 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4797 gnus-summary-default-score 0)
4799 (if (or (null gnus-summary-default-score)
4800 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4801 gnus-summary-zcore-fuzz))
4803 (if (< gnus-tmp-score gnus-summary-default-score)
4804 gnus-score-below-mark gnus-score-over-mark))
4806 (cond ((memq number gnus-newsgroup-processable)
4808 ((memq number gnus-newsgroup-cached)
4810 ((memq number gnus-newsgroup-replied)
4812 ((memq number gnus-newsgroup-forwarded)
4813 gnus-forwarded-mark)
4814 ((memq number gnus-newsgroup-saved)
4816 ((memq number gnus-newsgroup-recent)
4818 ((memq number gnus-newsgroup-unseen)
4822 (cond ((memq number gnus-newsgroup-undownloaded)
4823 gnus-undownloaded-mark)
4824 (gnus-newsgroup-agentized
4825 gnus-downloaded-mark)
4828 gnus-tmp-from (mail-header-from gnus-tmp-header)
4831 ((string-match "<[^>]+> *$" gnus-tmp-from)
4832 (setq beg-match (match-beginning 0))
4833 (or (and (string-match "^\".+\"" gnus-tmp-from)
4834 (substring gnus-tmp-from 1 (1- (match-end 0))))
4835 (substring gnus-tmp-from 0 beg-match)))
4836 ((string-match "(.+)" gnus-tmp-from)
4837 (substring gnus-tmp-from
4838 (1+ (match-beginning 0)) (1- (match-end 0))))
4842 gnus-tmp-thread-tree-header-string
4844 ((not gnus-show-threads) "")
4845 ((zerop gnus-tmp-level)
4846 (cond ((cdar thread)
4847 (or gnus-sum-thread-tree-root subject))
4848 (gnus-tmp-new-adopts
4849 (or gnus-sum-thread-tree-false-root subject))
4851 (or gnus-sum-thread-tree-single-indent subject))))
4853 (concat (apply 'concat
4854 (mapcar (lambda (item)
4856 gnus-sum-thread-tree-vertical
4857 gnus-sum-thread-tree-indent))
4858 (cdr (reverse tree-stack))))
4860 gnus-sum-thread-tree-leaf-with-other
4861 gnus-sum-thread-tree-single-leaf)))))
4862 (when (string= gnus-tmp-name "")
4863 (setq gnus-tmp-name gnus-tmp-from))
4864 (unless (numberp gnus-tmp-lines)
4865 (setq gnus-tmp-lines -1))
4866 (if (= gnus-tmp-lines -1)
4867 (setq gnus-tmp-lines "?")
4868 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4869 (gnus-put-text-property
4871 (progn (eval gnus-summary-line-format-spec) (point))
4872 'gnus-number number)
4875 (gnus-run-hooks 'gnus-summary-update-hook)
4878 (setq gnus-tmp-prev-subject simp-subject)))
4880 (when (nth 1 thread)
4881 (push (list (max 0 gnus-tmp-level)
4882 (copy-sequence tree-stack)
4885 (push (if (nth 1 thread) 1 0) tree-stack)
4886 (incf gnus-tmp-level)
4887 (setq threads (if thread-end nil (cdar thread)))
4888 (if gnus-summary-display-while-building
4891 ;; use a set frequency
4892 (setq building-line-count (1- building-line-count))
4893 (when (= building-line-count 0)
4895 (setq building-line-count
4896 gnus-summary-display-while-building)))
4900 (setq gnus-tmp-level 0)))))
4901 (gnus-message 7 "Generating summary...done"))
4903 (defun gnus-summary-prepare-unthreaded (headers)
4904 "Generate an unthreaded summary buffer based on HEADERS."
4905 (let (header number mark)
4910 ;; We may have to root out some bad articles...
4911 (when (memq (setq number (mail-header-number
4912 (setq header (pop headers))))
4913 gnus-newsgroup-limit)
4914 ;; Mark article as read when it has a low score.
4915 (when (and gnus-summary-mark-below
4916 (< (or (cdr (assq number gnus-newsgroup-scored))
4917 gnus-summary-default-score 0)
4918 gnus-summary-mark-below)
4919 (not (gnus-summary-article-ancient-p number)))
4920 (setq gnus-newsgroup-unreads
4921 (delq number gnus-newsgroup-unreads))
4922 (if gnus-newsgroup-auto-expire
4923 (push number gnus-newsgroup-expirable)
4924 (push (cons number gnus-low-score-mark)
4925 gnus-newsgroup-reads)))
4927 (setq mark (gnus-article-mark number))
4928 (push (gnus-data-make number mark (1+ (point)) header 0)
4929 gnus-newsgroup-data)
4930 (gnus-summary-insert-line
4932 (memq number gnus-newsgroup-undownloaded)
4933 mark (memq number gnus-newsgroup-replied)
4934 (memq number gnus-newsgroup-expirable)
4935 (mail-header-subject header) nil
4936 (cdr (assq number gnus-newsgroup-scored))
4937 (memq number gnus-newsgroup-processable))))))
4939 (defun gnus-summary-remove-list-identifiers ()
4940 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4941 (let ((regexp (if (consp gnus-list-identifiers)
4942 (mapconcat 'identity gnus-list-identifiers " *\\|")
4943 gnus-list-identifiers))
4946 (dolist (header gnus-newsgroup-headers)
4947 (setq subject (mail-header-subject header)
4949 (while (string-match
4950 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4953 (concat (substring subject 0 (match-beginning 2))
4954 (substring subject (match-end 0)))
4958 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4960 (concat (substring subject 0 (match-beginning 1))
4961 (substring subject (match-end 1)))))
4963 (mail-header-set-subject header subject))))))
4965 (defun gnus-fetch-headers (articles)
4966 "Fetch headers of ARTICLES."
4967 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4968 (gnus-message 5 "Fetching headers for %s..." name)
4971 (setq gnus-headers-retrieved-by
4972 (gnus-retrieve-headers
4973 articles gnus-newsgroup-name
4974 ;; We might want to fetch old headers, but
4975 ;; not if there is only 1 article.
4977 (not (eq gnus-fetch-old-headers 'some))
4978 (not (numberp gnus-fetch-old-headers)))
4979 (> (length articles) 1))
4980 gnus-fetch-old-headers))))
4981 (gnus-get-newsgroup-headers-xover
4982 articles nil nil gnus-newsgroup-name t)
4983 (gnus-get-newsgroup-headers))
4984 (gnus-message 5 "Fetching headers for %s...done" name))))
4986 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4987 "Select newsgroup GROUP.
4988 If READ-ALL is non-nil, all articles in the group are selected.
4989 If SELECT-ARTICLES, only select those articles from GROUP."
4990 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4991 ;;!!! Dirty hack; should be removed.
4992 (gnus-summary-ignore-duplicates
4993 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4995 gnus-summary-ignore-duplicates))
4996 (info (nth 2 entry))
4997 articles fetched-articles cached)
4999 (unless (gnus-check-server
5000 (set (make-local-variable 'gnus-current-select-method)
5001 (gnus-find-method-for-group group)))
5002 (error "Couldn't open server"))
5004 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5005 (gnus-activate-group group) ; Or we can activate it...
5006 (progn ; Or we bug out.
5007 (when (equal major-mode 'gnus-summary-mode)
5008 (gnus-kill-buffer (current-buffer)))
5009 (error "Couldn't activate group %s: %s"
5010 group (gnus-status-message group))))
5012 (unless (gnus-request-group group t)
5013 (when (equal major-mode 'gnus-summary-mode)
5014 (gnus-kill-buffer (current-buffer)))
5015 (error "Couldn't request group %s: %s"
5016 group (gnus-status-message group)))
5019 ;; The agent may be storing articles that are no longer in the
5020 ;; server's active range. If that is the case, the active range
5021 ;; needs to be expanded such that the agent's articles can be
5022 ;; included in the summary.
5023 (let* ((gnus-command-method (gnus-find-method-for-group group))
5024 (alist (gnus-agent-load-alist group))
5025 (active (gnus-active group)))
5026 (if (and (car alist)
5027 (< (caar alist) (car active)))
5028 (gnus-set-active group (cons (caar alist) (cdr active))))))
5030 (setq gnus-newsgroup-name group
5031 gnus-newsgroup-unselected nil
5032 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5034 (let ((display (gnus-group-find-parameter group 'display)))
5035 (setq gnus-newsgroup-display
5037 ((not (zerop (or (car-safe read-all) 0)))
5038 ;; The user entered the group with C-u SPC/RET, let's show
5044 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5046 ;; The following is probably the "correct" solution, but
5047 ;; it makes Gnus fetch all headers and then limit the
5048 ;; articles (which is slow), so instead we hack the
5049 ;; select-articles parameter instead. -- Simon Josefsson
5052 ;; (gnus-byte-compile
5053 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5055 (setq select-articles
5056 (gnus-uncompress-range
5057 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5061 (cdr (gnus-active group)))))
5066 (gnus-summary-setup-default-charset)
5068 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5069 (when (gnus-virtual-group-p group)
5070 (setq cached gnus-newsgroup-cached))
5072 (setq gnus-newsgroup-unreads
5073 (gnus-sorted-ndifference
5074 (gnus-sorted-ndifference gnus-newsgroup-unreads
5075 gnus-newsgroup-marked)
5076 gnus-newsgroup-dormant))
5078 (setq gnus-newsgroup-processable nil)
5080 (gnus-update-read-articles group gnus-newsgroup-unreads)
5082 ;; Adjust and set lists of article marks.
5084 (gnus-adjust-marked-articles info))
5085 (if (setq articles select-articles)
5086 (setq gnus-newsgroup-unselected
5087 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5088 (setq articles (gnus-articles-to-read group read-all)))
5092 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5094 ((eq articles 0) nil)
5096 ;; Init the dependencies hash table.
5097 (setq gnus-newsgroup-dependencies
5098 (gnus-make-hashtable (length articles)))
5099 (gnus-set-global-variables)
5100 ;; Retrieve the headers and read them in.
5102 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5104 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5106 (setq gnus-newsgroup-cached cached))
5108 ;; Suppress duplicates?
5109 (when gnus-suppress-duplicates
5110 (gnus-dup-suppress-articles))
5112 ;; Set the initial limit.
5113 (setq gnus-newsgroup-limit (copy-sequence articles))
5114 ;; Remove canceled articles from the list of unread articles.
5115 (setq fetched-articles
5116 (mapcar (lambda (headers) (mail-header-number headers))
5117 gnus-newsgroup-headers))
5118 (setq gnus-newsgroup-articles fetched-articles)
5119 (setq gnus-newsgroup-unreads
5120 (gnus-sorted-nintersection
5121 gnus-newsgroup-unreads fetched-articles))
5122 (gnus-compute-unseen-list)
5124 ;; Removed marked articles that do not exist.
5125 (gnus-update-missing-marks
5126 (gnus-sorted-difference articles fetched-articles))
5127 ;; We might want to build some more threads first.
5128 (when (and gnus-fetch-old-headers
5129 (eq gnus-headers-retrieved-by 'nov))
5130 (if (eq gnus-fetch-old-headers 'invisible)
5131 (gnus-build-all-threads)
5132 (gnus-build-old-threads)))
5133 ;; Let the Gnus agent mark articles as read.
5135 (gnus-agent-get-undownloaded-list))
5136 ;; Remove list identifiers from subject
5137 (when gnus-list-identifiers
5138 (gnus-summary-remove-list-identifiers))
5139 ;; Check whether auto-expire is to be done in this group.
5140 (setq gnus-newsgroup-auto-expire
5141 (gnus-group-auto-expirable-p group))
5142 ;; Set up the article buffer now, if necessary.
5143 (unless gnus-single-article-buffer
5144 (gnus-article-setup-buffer))
5145 ;; First and last article in this newsgroup.
5146 (when gnus-newsgroup-headers
5147 (setq gnus-newsgroup-begin
5148 (mail-header-number (car gnus-newsgroup-headers))
5151 (gnus-last-element gnus-newsgroup-headers))))
5152 ;; GROUP is successfully selected.
5153 (or gnus-newsgroup-headers t)))))
5155 (defun gnus-compute-unseen-list ()
5156 ;; The `seen' marks are treated specially.
5157 (if (not gnus-newsgroup-seen)
5158 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5159 (setq gnus-newsgroup-unseen
5160 (gnus-inverse-list-range-intersection
5161 gnus-newsgroup-articles gnus-newsgroup-seen))))
5163 (defun gnus-summary-display-make-predicate (display)
5164 (require 'gnus-agent)
5165 (when (= (length display) 1)
5166 (setq display (car display)))
5167 (unless gnus-summary-display-cache
5168 (dolist (elem (append '((unread . unread)
5171 gnus-article-mark-lists))
5172 (push (cons (cdr elem)
5174 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5175 gnus-summary-display-cache)))
5176 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5177 (gnus-category-predicate-cache gnus-summary-display-cache))
5178 (gnus-get-predicate display)))
5180 ;; Uses the dynamically bound `number' variable.
5183 (defun gnus-article-marked-p (type &optional article)
5184 (let ((article (or article number)))
5187 (memq article gnus-newsgroup-marked))
5189 (memq article gnus-newsgroup-spam-marked))
5191 (memq article gnus-newsgroup-unsendable))
5192 ((eq type 'undownload)
5193 (memq article gnus-newsgroup-undownloaded))
5194 ((eq type 'download)
5195 (memq article gnus-newsgroup-downloadable))
5197 (memq article gnus-newsgroup-unreads))
5199 (memq article gnus-newsgroup-reads))
5201 (memq article gnus-newsgroup-dormant) )
5203 (memq article gnus-newsgroup-expirable))
5205 (memq article gnus-newsgroup-replied))
5207 (memq article gnus-newsgroup-killed))
5208 ((eq type 'bookmark)
5209 (assq article gnus-newsgroup-bookmarks))
5211 (assq article gnus-newsgroup-scored))
5213 (memq article gnus-newsgroup-saved))
5215 (memq article gnus-newsgroup-cached))
5217 (memq article gnus-newsgroup-forwarded))
5219 (not (memq article gnus-newsgroup-unseen)))
5221 (memq article gnus-newsgroup-recent))
5224 (defun gnus-articles-to-read (group &optional read-all)
5225 "Find out what articles the user wants to read."
5226 (let* ((display (gnus-group-find-parameter group 'display))
5228 ;; Select all articles if `read-all' is non-nil, or if there
5229 ;; are no unread articles.
5231 (and (zerop (length gnus-newsgroup-marked))
5232 (zerop (length gnus-newsgroup-unreads)))
5233 ;; Fetch all if the predicate is non-nil.
5234 gnus-newsgroup-display)
5235 ;; We want to select the headers for all the articles in
5236 ;; the group, so we select either all the active
5237 ;; articles in the group, or (if that's nil), the
5238 ;; articles in the cache.
5240 (gnus-uncompress-range (gnus-active group))
5241 (gnus-cache-articles-in-group group))
5242 ;; Select only the "normal" subset of articles.
5244 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5245 gnus-newsgroup-unreads)))
5246 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5247 (scored (length scored-list))
5248 (number (length articles))
5249 (marked (+ (length gnus-newsgroup-marked)
5250 (length gnus-newsgroup-dormant)))
5255 ((numberp gnus-newsgroup-display)
5256 gnus-newsgroup-display)
5260 ((and (or (<= scored marked) (= scored number))
5261 (numberp gnus-large-newsgroup)
5262 (> number gnus-large-newsgroup))
5263 (let* ((cursor-in-echo-area nil)
5264 (initial (gnus-parameter-large-newsgroup-initial
5265 gnus-newsgroup-name))
5269 "How many articles from %s (%s %d): "
5271 (gnus-group-decoded-name gnus-newsgroup-name)
5273 (if initial "max" "default")
5276 (cons (number-to-string initial)
5278 (if (string-match "^[ \t]*$" input) number input)))
5279 ((and (> scored marked) (< scored number)
5280 (> (- scored number) 20))
5283 (format "%s %s (%d scored, %d total): "
5284 "How many articles from"
5285 (gnus-group-decoded-name group)
5287 (if (string-match "^[ \t]*$" input)
5291 (message "Quit getting the articles to read")
5293 (setq select (if (stringp select) (string-to-number select) select))
5294 (if (or (null select) (zerop select))
5296 (if (and (not (zerop scored)) (<= (abs select) scored))
5298 (setq articles (sort scored-list '<))
5299 (setq number (length articles)))
5300 (setq articles (copy-sequence articles)))
5302 (when (< (abs select) number)
5304 ;; Select the N oldest articles.
5305 (setcdr (nthcdr (1- (abs select)) articles) nil)
5306 ;; Select the N most recent articles.
5307 (setq articles (nthcdr (- number select) articles))))
5308 (setq gnus-newsgroup-unselected
5309 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5310 (when gnus-alter-articles-to-read-function
5313 (funcall gnus-alter-articles-to-read-function
5314 gnus-newsgroup-name articles)
5318 (defun gnus-killed-articles (killed articles)
5321 (when (inline (gnus-member-of-range (car articles) killed))
5322 (push (car articles) out))
5323 (setq articles (cdr articles)))
5326 (defun gnus-uncompress-marks (marks)
5327 "Uncompress the mark ranges in MARKS."
5328 (let ((uncompressed '(score bookmark))
5331 (if (memq (caar marks) uncompressed)
5332 (push (car marks) out)
5333 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5334 (setq marks (cdr marks)))
5337 (defun gnus-article-mark-to-type (mark)
5338 "Return the type of MARK."
5339 (or (cadr (assq mark gnus-article-special-mark-lists))
5342 (defun gnus-article-unpropagatable-p (mark)
5343 "Return whether MARK should be propagated to backend."
5344 (memq mark gnus-article-unpropagated-mark-lists))
5346 (defun gnus-adjust-marked-articles (info)
5347 "Set all article lists and remove all marks that are no longer valid."
5348 (let* ((marked-lists (gnus-info-marks info))
5349 (active (gnus-active (gnus-info-group info)))
5352 (types gnus-article-mark-lists)
5353 marks var articles article mark mark-type)
5355 (dolist (marks marked-lists)
5356 (setq mark (car marks)
5357 mark-type (gnus-article-mark-to-type mark)
5358 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5360 ;; We set the variable according to the type of the marks list,
5361 ;; and then adjust the marks to a subset of the active articles.
5363 ;; Adjust "simple" lists.
5364 ((eq mark-type 'list)
5365 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5366 (when (memq mark '(tick dormant expire reply save))
5368 (when (or (< (setq article (pop articles)) min) (> article max))
5369 (set var (delq article (symbol-value var)))))))
5371 ((eq mark-type 'tuple)
5372 (set var (setq articles (cdr marks)))
5373 (when (not (listp (cdr (symbol-value var))))
5374 (set var (list (symbol-value var))))
5375 (when (not (listp (cdr articles)))
5376 (setq articles (list articles)))
5378 (when (or (not (consp (setq article (pop articles))))
5379 (< (car article) min)
5380 (> (car article) max))
5381 (set var (delq article (symbol-value var))))))
5382 ;; Adjust ranges (sloppily).
5383 ((eq mark-type 'range)
5386 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5387 ;; It should be (seen (NUM1 . NUM2)).
5388 (when (numberp (cddr marks))
5389 (setcdr marks (list (cdr marks))))
5390 (setq articles (cdr marks))
5391 (while (and articles
5392 (or (and (consp (car articles))
5393 (> min (cdar articles)))
5394 (and (numberp (car articles))
5395 (> min (car articles)))))
5397 (set var articles))))))))
5399 (defun gnus-update-missing-marks (missing)
5400 "Go through the list of MISSING articles and remove them from the mark lists."
5403 ;; Go through all types.
5404 (dolist (elem gnus-article-mark-lists)
5405 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5406 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5407 (when (symbol-value var)
5408 ;; This list has articles. So we delete all missing
5409 ;; articles from it.
5412 (set var (delq (pop m) (symbol-value var))))))))))
5414 (defun gnus-update-marks ()
5415 "Enter the various lists of marked articles into the newsgroup info list."
5416 (let ((types gnus-article-mark-lists)
5417 (info (gnus-get-info gnus-newsgroup-name))
5418 type list newmarked symbol delta-marks)
5420 ;; Add all marks lists to the list of marks lists.
5421 (while (setq type (pop types))
5422 (setq list (symbol-value
5424 (intern (format "gnus-newsgroup-%s" (car type))))))
5427 ;; Get rid of the entries of the articles that have the
5429 (when (and (eq (cdr type) 'score)
5433 (prev (cons nil list))
5436 (if (or (not (consp (car arts)))
5437 (= (cdar arts) gnus-summary-default-score))
5438 (setcdr prev (cdr arts))
5440 (setq arts (cdr arts)))
5441 (setq list (cdr all)))))
5443 (when (eq (cdr type) 'seen)
5444 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5446 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5447 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5449 (when (and (gnus-check-backend-function
5450 'request-set-mark gnus-newsgroup-name)
5451 (not (gnus-article-unpropagatable-p (cdr type))))
5452 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5453 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5454 (add (gnus-remove-from-range
5455 (gnus-copy-sequence list) old)))
5457 (push (list add 'add (list (cdr type))) delta-marks))
5459 (push (list del 'del (list (cdr type))) delta-marks))))
5462 (push (cons (cdr type) list) newmarked)))
5465 (unless (gnus-check-group gnus-newsgroup-name)
5466 (error "Can't open server for %s" gnus-newsgroup-name))
5467 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5469 ;; Enter these new marks into the info of the group.
5471 (setcar (nthcdr 3 info) newmarked)
5472 ;; Add the marks lists to the end of the info.
5474 (setcdr (nthcdr 2 info) (list newmarked))))
5476 ;; Cut off the end of the info if there's nothing else there.
5480 (when (nthcdr (decf i) info)
5481 (setcdr (nthcdr i info) nil)))))))
5483 (defun gnus-set-mode-line (where)
5484 "Set the mode line of the article or summary buffers.
5485 If WHERE is `summary', the summary mode line format will be used."
5486 ;; Is this mode line one we keep updated?
5487 (when (and (memq where gnus-updated-mode-lines)
5489 (intern (format "gnus-%s-mode-line-format-spec" where))))
5492 ;; We evaluate this in the summary buffer since these
5493 ;; variables are buffer-local to that buffer.
5494 (set-buffer gnus-summary-buffer)
5495 ;; We bind all these variables that are used in the `eval' form
5497 (let* ((mformat (symbol-value
5499 (format "gnus-%s-mode-line-format-spec" where))))
5500 (gnus-tmp-group-name (gnus-group-decoded-name
5501 gnus-newsgroup-name))
5502 (gnus-tmp-article-number (or gnus-current-article 0))
5503 (gnus-tmp-unread gnus-newsgroup-unreads)
5504 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5505 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5506 (gnus-tmp-unread-and-unselected
5507 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5508 (zerop gnus-tmp-unselected))
5510 ((zerop gnus-tmp-unselected)
5511 (format "{%d more}" gnus-tmp-unread-and-unticked))
5512 (t (format "{%d(+%d) more}"
5513 gnus-tmp-unread-and-unticked
5514 gnus-tmp-unselected))))
5516 (if (and gnus-current-headers
5517 (vectorp gnus-current-headers))
5518 (gnus-mode-string-quote
5519 (mail-header-subject gnus-current-headers))
5521 bufname-length max-len
5522 gnus-tmp-header);; passed as argument to any user-format-funcs
5523 (setq mode-string (eval mformat))
5524 (setq bufname-length (if (string-match "%b" mode-string)
5527 (if (eq where 'summary)
5529 (get-buffer gnus-article-buffer))))
5532 (setq max-len (max 4 (if gnus-mode-non-string-length
5534 gnus-mode-non-string-length
5536 (length mode-string))))
5537 ;; We might have to chop a bit of the string off...
5538 (when (> (length mode-string) max-len)
5540 (concat (gnus-truncate-string mode-string (- max-len 3))
5542 ;; Pad the mode string a bit.
5543 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5544 ;; Update the mode line.
5545 (setq mode-line-buffer-identification
5546 (gnus-mode-line-buffer-identification (list mode-string)))
5547 (set-buffer-modified-p t))))
5549 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5550 "Go through the HEADERS list and add all Xrefs to a hash table.
5551 The resulting hash table is returned, or nil if no Xrefs were found."
5552 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5553 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5554 (xref-hashtb (gnus-make-hashtable))
5555 start group entry number xrefs header)
5557 (setq header (pop headers))
5558 (when (and (setq xrefs (mail-header-xref header))
5559 (not (memq (setq number (mail-header-number header))
5562 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5563 (setq start (match-end 0))
5564 (setq group (if prefix
5565 (concat prefix (substring xrefs (match-beginning 1)
5567 (substring xrefs (match-beginning 1) (match-end 1))))
5569 (string-to-int (substring xrefs (match-beginning 2)
5571 (if (setq entry (gnus-gethash group xref-hashtb))
5572 (setcdr entry (cons number (cdr entry)))
5573 (gnus-sethash group (cons number nil) xref-hashtb)))))
5574 (and start xref-hashtb)))
5576 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5577 "Look through all the headers and mark the Xrefs as read."
5578 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5579 name entry info xref-hashtb idlist method nth4)
5581 (set-buffer gnus-group-buffer)
5582 (when (setq xref-hashtb
5583 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5586 (unless (string= from-newsgroup (setq name (symbol-name group)))
5587 (setq idlist (symbol-value group))
5588 ;; Dead groups are not updated.
5590 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5592 (when (stringp (setq nth4 (gnus-info-method info)))
5593 (setq nth4 (gnus-server-to-method nth4))))
5594 ;; Only do the xrefs if the group has the same
5595 ;; select method as the group we have just read.
5596 (or (gnus-methods-equal-p
5597 nth4 (gnus-find-method-for-group from-newsgroup))
5599 (equal nth4 (setq method (gnus-find-method-for-group
5601 (and (equal (car nth4) (car method))
5602 (equal (nth 1 nth4) (nth 1 method))))
5603 gnus-use-cross-reference
5604 (or (not (eq gnus-use-cross-reference t))
5606 ;; Only do cross-references on subscribed
5607 ;; groups, if that is what is wanted.
5608 (<= (gnus-info-level info) gnus-level-subscribed))
5609 (gnus-group-make-articles-read name idlist))))
5612 (defun gnus-compute-read-articles (group articles)
5613 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5614 (info (nth 2 entry))
5615 (active (gnus-active group))
5618 ;; First peel off all invalid article numbers.
5620 (let ((ids articles)
5622 (while (setq id (pop ids))
5623 (when (and first (> id (cdr active)))
5624 ;; We'll end up in this situation in one particular
5625 ;; obscure situation. If you re-scan a group and get
5626 ;; a new article that is cross-posted to a different
5627 ;; group that has not been re-scanned, you might get
5628 ;; crossposted article that has a higher number than
5629 ;; Gnus believes possible. So we re-activate this
5630 ;; group as well. This might mean doing the
5631 ;; crossposting thingy will *increase* the number
5632 ;; of articles in some groups. Tsk, tsk.
5633 (setq active (or (gnus-activate-group group) active)))
5634 (when (or (> id (cdr active))
5635 (< id (car active)))
5636 (setq articles (delq id articles))))))
5637 ;; If the read list is nil, we init it.
5639 (null (gnus-info-read info))
5641 (setq ninfo (cons 1 (1- (car active))))
5642 (setq ninfo (gnus-info-read info)))
5643 ;; Then we add the read articles to the range.
5645 ninfo (setq articles (sort articles '<))))))
5647 (defun gnus-group-make-articles-read (group articles)
5648 "Update the info of GROUP to say that ARTICLES are read."
5650 (entry (gnus-gethash group gnus-newsrc-hashtb))
5651 (info (nth 2 entry))
5652 (active (gnus-active group))
5655 (setq range (gnus-compute-read-articles group articles))
5657 (set-buffer gnus-group-buffer)
5660 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5661 (gnus-info-set-read ',info ',(gnus-info-read info))
5662 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5663 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5664 (gnus-group-update-group ,group t))))
5665 ;; Add the read articles to the range.
5666 (gnus-info-set-read info range)
5667 (gnus-request-set-mark group (list (list range 'add '(read))))
5668 ;; Then we have to re-compute how many unread
5669 ;; articles there are in this group.
5673 (setq num (- (1+ (cdr active)) (car active))))
5674 ((not (listp (cdr range)))
5675 (setq num (- (cdr active) (- (1+ (cdr range))
5679 (if (numberp (car range))
5681 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5682 (setq range (cdr range)))
5683 (setq num (- (cdr active) num))))
5684 ;; Update the number of unread articles.
5686 ;; Update the group buffer.
5687 (unless (gnus-ephemeral-group-p group)
5688 (gnus-group-update-group group t))))))
5690 (defvar gnus-newsgroup-none-id 0)
5692 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5693 (let ((cur nntp-server-buffer)
5696 (save-excursion (set-buffer gnus-summary-buffer)
5697 gnus-newsgroup-dependencies)))
5699 (mail-parse-charset gnus-newsgroup-charset)
5700 (mail-parse-ignored-charsets
5701 (save-excursion (condition-case nil
5702 (set-buffer gnus-summary-buffer)
5704 gnus-newsgroup-ignored-charsets)))
5706 (set-buffer nntp-server-buffer)
5707 ;; Translate all TAB characters into SPACE characters.
5708 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5709 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5710 (gnus-run-hooks 'gnus-parse-headers-hook)
5711 (let ((case-fold-search t)
5712 in-reply-to header p lines chars ctype)
5713 (goto-char (point-min))
5714 ;; Search to the beginning of the next header. Error messages
5715 ;; do not begin with 2 or 3.
5716 (while (re-search-forward "^[23][0-9]+ " nil t)
5719 ;; This implementation of this function, with nine
5720 ;; search-forwards instead of the one re-search-forward and
5721 ;; a case (which basically was the old function) is actually
5722 ;; about twice as fast, even though it looks messier. You
5723 ;; can't have everything, I guess. Speed and elegance
5724 ;; doesn't always go hand in hand.
5727 (make-full-mail-header
5733 (narrow-to-region (point)
5734 (or (and (search-forward "\n.\n" nil t)
5740 (if (search-forward "\nsubject:" nil t)
5741 (nnheader-header-value)
5746 (if (search-forward "\nfrom:" nil t)
5747 (nnheader-header-value)
5752 (if (search-forward "\ndate:" nil t)
5753 (nnheader-header-value) ""))
5757 (setq id (if (re-search-forward
5758 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5759 ;; We do it this way to make sure the Message-ID
5760 ;; is (somewhat) syntactically valid.
5761 (buffer-substring (match-beginning 1)
5763 ;; If there was no message-id, we just fake one
5764 ;; to make subsequent routines simpler.
5765 (nnheader-generate-fake-message-id))))
5769 (if (search-forward "\nreferences:" nil t)
5773 (nnheader-header-value)
5778 (search-backward ">" end t)
5781 (search-backward "<" end t)
5783 ;; Get the references from the in-reply-to header if there
5784 ;; were no references and the in-reply-to header looks
5786 (if (and (search-forward "\nin-reply-to:" nil t)
5787 (setq in-reply-to (nnheader-header-value))
5788 (string-match "<[^>]+>" in-reply-to))
5790 (setq ref (substring in-reply-to (match-beginning 0)
5792 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5793 (setq ref2 (substring in-reply-to (match-beginning 0)
5795 (when (> (length ref2) (length ref))
5802 (if (search-forward "\nchars: " nil t)
5803 (if (numberp (setq chars (ignore-errors (read cur))))
5809 (if (search-forward "\nlines: " nil t)
5810 (if (numberp (setq lines (ignore-errors (read cur))))
5816 (and (search-forward "\nxref:" nil t)
5817 (nnheader-header-value)))
5819 (when gnus-extra-headers
5820 (let ((extra gnus-extra-headers)
5824 (when (search-forward
5825 (concat "\n" (symbol-name (car extra)) ":") nil t)
5826 (push (cons (car extra) (nnheader-header-value)) out))
5830 (if (and (search-forward "\ncontent-type: " nil t)
5831 (setq ctype (nnheader-header-value)))
5832 (mime-entity-set-content-type-internal
5833 header (mime-parse-Content-Type ctype)))
5834 (when (equal id ref)
5837 (when gnus-alter-header-function
5838 (funcall gnus-alter-header-function header)
5839 (setq id (mail-header-id header)
5840 ref (gnus-parent-id (mail-header-references header))))
5843 (gnus-dependencies-add-header
5844 header dependencies force-new))
5845 (push header headers))
5846 (goto-char (point-max))
5848 (nreverse headers)))))
5850 ;; Goes through the xover lines and returns a list of vectors
5851 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5852 force-new dependencies
5853 group also-fetch-heads)
5854 "Parse the news overview data in the server buffer.
5855 Return a list of headers that match SEQUENCE (see
5856 `nntp-retrieve-headers')."
5857 ;; Get the Xref when the users reads the articles since most/some
5858 ;; NNTP servers do not include Xrefs when using XOVER.
5859 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5860 (let ((mail-parse-charset gnus-newsgroup-charset)
5861 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5862 (cur nntp-server-buffer)
5863 (dependencies (or dependencies gnus-newsgroup-dependencies))
5865 ((eq gnus-read-all-available-headers t)
5867 ((stringp gnus-read-all-available-headers)
5868 (string-match gnus-read-all-available-headers group))
5871 number headers header)
5873 (set-buffer nntp-server-buffer)
5874 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5875 ;; Allow the user to mangle the headers before parsing them.
5876 (gnus-run-hooks 'gnus-parse-headers-hook)
5877 (goto-char (point-min))
5878 (gnus-parse-without-error
5879 (while (and (or sequence allp)
5881 (setq number (read cur))
5883 (while (and sequence
5884 (< (car sequence) number))
5885 (setq sequence (cdr sequence))))
5888 (eq number (car sequence))))
5890 (setq sequence (cdr sequence))
5891 (setq header (inline
5892 (gnus-nov-parse-line
5893 number dependencies force-new)))))
5894 (push header headers))
5896 ;; A common bug in inn is that if you have posted an article and
5897 ;; then retrieves the active file, it will answer correctly --
5898 ;; the new article is included. However, a NOV entry for the
5899 ;; article may not have been generated yet, so this may fail.
5900 ;; We work around this problem by retrieving the last few
5901 ;; headers using HEAD.
5902 (if (or (not also-fetch-heads)
5904 ;; We (probably) got all the headers.
5906 (let ((gnus-nov-is-evil t))
5909 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5910 (gnus-get-newsgroup-headers))))))))
5912 (defun gnus-article-get-xrefs ()
5913 "Fill in the Xref value in `gnus-current-headers', if necessary.
5914 This is meant to be called in `gnus-article-internal-prepare-hook'."
5915 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5916 gnus-current-headers)))
5917 (or (not gnus-use-cross-reference)
5919 (and (mail-header-xref headers)
5920 (not (string= (mail-header-xref headers) "")))
5921 (let ((case-fold-search t)
5924 (nnheader-narrow-to-headers)
5925 (goto-char (point-min))
5926 (when (or (and (not (eobp))
5927 (eq (downcase (char-after)) ?x)
5928 (looking-at "Xref:"))
5929 (search-forward "\nXref:" nil t))
5930 (goto-char (1+ (match-end 0)))
5931 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
5932 (mail-header-set-xref headers xref)))))))
5934 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5935 "Find article ID and insert the summary line for that article.
5936 OLD-HEADER can either be a header or a line number to insert
5937 the subject line on."
5938 (let* ((line (and (numberp old-header) old-header))
5939 (old-header (and (vectorp old-header) old-header))
5940 (header (cond ((and old-header use-old-header)
5943 (gnus-number-to-header id))
5944 (gnus-number-to-header id))
5946 (gnus-read-header id))))
5947 (number (and (numberp id) id))
5950 ;; Rebuild the thread that this article is part of and go to the
5951 ;; article we have fetched.
5952 (when (and (not gnus-show-threads)
5955 (setq d (gnus-data-find (mail-header-number old-header))))
5956 (goto-char (gnus-data-pos d))
5959 (- (gnus-point-at-bol)
5961 (1+ (gnus-point-at-eol))
5962 (gnus-delete-line))))))
5964 (mail-header-set-number header (mail-header-number old-header)))
5965 (setq gnus-newsgroup-sparse
5966 (delq (setq number (mail-header-number header))
5967 gnus-newsgroup-sparse))
5968 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5969 (push number gnus-newsgroup-limit)
5970 (gnus-rebuild-thread (mail-header-id header) line)
5971 (gnus-summary-goto-subject number nil t))
5972 (when (and (numberp number)
5974 ;; We have to update the boundaries even if we can't fetch the
5975 ;; article if ID is a number -- so that the next `P' or `N'
5976 ;; command will fetch the previous (or next) article even
5977 ;; if the one we tried to fetch this time has been canceled.
5978 (when (> number gnus-newsgroup-end)
5979 (setq gnus-newsgroup-end number))
5980 (when (< number gnus-newsgroup-begin)
5981 (setq gnus-newsgroup-begin number))
5982 (setq gnus-newsgroup-unselected
5983 (delq number gnus-newsgroup-unselected)))
5984 ;; Report back a success?
5985 (and header (mail-header-number header))))
5987 ;;; Process/prefix in the summary buffer
5989 (defun gnus-summary-work-articles (n)
5990 "Return a list of articles to be worked upon.
5991 The prefix argument, the list of process marked articles, and the
5992 current article will be taken into consideration."
5994 (set-buffer gnus-summary-buffer)
5997 ;; A numerical prefix has been given.
5998 (setq n (prefix-numeric-value n))
5999 (let ((backward (< n 0))
6000 (n (abs (prefix-numeric-value n)))
6005 (push (setq article (gnus-summary-article-number))
6008 (gnus-summary-find-prev nil article)
6009 (gnus-summary-find-next nil article)))
6011 (nreverse articles)))
6012 ((and (gnus-region-active-p) (mark))
6013 (message "region active")
6014 ;; Work on the region between point and mark.
6015 (let ((max (max (point) (mark)))
6018 (goto-char (min (point) (mark)))
6021 (push (setq article (gnus-summary-article-number)) articles)
6022 (gnus-summary-find-next nil article)
6024 (nreverse articles))))
6025 (gnus-newsgroup-processable
6026 ;; There are process-marked articles present.
6027 ;; Save current state.
6028 (gnus-summary-save-process-mark)
6030 (reverse gnus-newsgroup-processable))
6032 ;; Just return the current article.
6033 (list (gnus-summary-article-number))))))
6035 (defmacro gnus-summary-iterate (arg &rest forms)
6036 "Iterate over the process/prefixed articles and do FORMS.
6037 ARG is the interactive prefix given to the command. FORMS will be
6038 executed with point over the summary line of the articles."
6039 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6040 `(let ((,articles (gnus-summary-work-articles ,arg)))
6042 (gnus-summary-goto-subject (car ,articles))
6046 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6047 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6049 (defun gnus-summary-save-process-mark ()
6050 "Push the current set of process marked articles on the stack."
6052 (push (copy-sequence gnus-newsgroup-processable)
6053 gnus-newsgroup-process-stack))
6055 (defun gnus-summary-kill-process-mark ()
6056 "Push the current set of process marked articles on the stack and unmark."
6058 (gnus-summary-save-process-mark)
6059 (gnus-summary-unmark-all-processable))
6061 (defun gnus-summary-yank-process-mark ()
6062 "Pop the last process mark state off the stack and restore it."
6064 (unless gnus-newsgroup-process-stack
6065 (error "Empty mark stack"))
6066 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6068 (defun gnus-summary-process-mark-set (set)
6069 "Make SET into the current process marked articles."
6070 (gnus-summary-unmark-all-processable)
6072 (gnus-summary-set-process-mark (pop set))))
6074 ;;; Searching and stuff
6076 (defun gnus-summary-search-group (&optional backward use-level)
6077 "Search for next unread newsgroup.
6078 If optional argument BACKWARD is non-nil, search backward instead."
6080 (set-buffer gnus-group-buffer)
6081 (when (gnus-group-search-forward
6082 backward nil (if use-level (gnus-group-group-level) nil))
6083 (gnus-group-group-name))))
6085 (defun gnus-summary-best-group (&optional exclude-group)
6086 "Find the name of the best unread group.
6087 If EXCLUDE-GROUP, do not go to this group."
6089 (set-buffer gnus-group-buffer)
6091 (gnus-group-best-unread-group exclude-group))))
6093 (defun gnus-summary-find-next (&optional unread article backward)
6094 (if backward (gnus-summary-find-prev unread article)
6095 (let* ((dummy (gnus-summary-article-intangible-p))
6096 (article (or article (gnus-summary-article-number)))
6097 (data (gnus-data-find-list article))
6099 (when (and (not dummy)
6100 (or (not gnus-summary-check-current)
6102 (not (gnus-data-unread-p (car data)))))
6103 (setq data (cdr data)))
6108 (unless (memq (gnus-data-number (car data))
6109 (cond ((eq gnus-auto-goto-ignores 'always-undownloaded)
6110 gnus-newsgroup-undownloaded)
6113 ((eq gnus-auto-goto-ignores 'unfetched)
6114 gnus-newsgroup-unfetched)
6115 ((eq gnus-auto-goto-ignores 'undownloaded)
6116 gnus-newsgroup-undownloaded)))
6117 (when (gnus-data-unread-p (car data))
6118 (setq result (car data)
6120 (setq data (cdr data)))
6123 (goto-char (gnus-data-pos result))
6124 (gnus-data-number result)))))
6126 (defun gnus-summary-find-prev (&optional unread article)
6127 (let* ((eobp (eobp))
6128 (article (or article (gnus-summary-article-number)))
6129 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6131 (when (and (not eobp)
6132 (or (not gnus-summary-check-current)
6134 (not (gnus-data-unread-p (car data)))))
6135 (setq data (cdr data)))
6140 (unless (memq (gnus-data-number (car data))
6141 (cond ((eq gnus-auto-goto-ignores 'always-undownloaded)
6142 gnus-newsgroup-undownloaded)
6145 ((eq gnus-auto-goto-ignores 'unfetched)
6146 gnus-newsgroup-unfetched)
6147 ((eq gnus-auto-goto-ignores 'undownloaded)
6148 gnus-newsgroup-undownloaded)))
6149 (when (gnus-data-unread-p (car data))
6150 (setq result (car data)
6152 (setq data (cdr data)))
6155 (goto-char (gnus-data-pos result))
6156 (gnus-data-number result))))
6158 (defun gnus-summary-find-subject (subject &optional unread backward article)
6159 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6160 (article (or article (gnus-summary-article-number)))
6161 (articles (gnus-data-list backward))
6162 (arts (gnus-data-find-list article articles))
6164 (when (or (not gnus-summary-check-current)
6166 (not (gnus-data-unread-p (car arts))))
6167 (setq arts (cdr arts)))
6169 (and (or (not unread)
6170 (gnus-data-unread-p (car arts)))
6171 (vectorp (gnus-data-header (car arts)))
6173 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6174 (setq result (car arts)
6176 (setq arts (cdr arts)))
6178 (goto-char (gnus-data-pos result))
6179 (gnus-data-number result))))
6181 (defun gnus-summary-search-forward (&optional unread subject backward)
6182 "Search forward for an article.
6183 If UNREAD, look for unread articles. If SUBJECT, look for
6184 articles with that subject. If BACKWARD, search backward instead."
6185 (cond (subject (gnus-summary-find-subject subject unread backward))
6186 (backward (gnus-summary-find-prev unread))
6187 (t (gnus-summary-find-next unread))))
6189 (defun gnus-recenter (&optional n)
6190 "Center point in window and redisplay frame.
6191 Also do horizontal recentering."
6193 (when (and gnus-auto-center-summary
6194 (not (eq gnus-auto-center-summary 'vertical)))
6195 (gnus-horizontal-recenter))
6198 (defun gnus-summary-recenter ()
6199 "Center point in the summary window.
6200 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6201 displayed, no centering will be performed."
6202 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6203 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6205 ;; The user has to want it.
6206 (when gnus-auto-center-summary
6207 (let* ((top (cond ((< (window-height) 4) 0)
6208 ((< (window-height) 7) 1)
6209 (t (if (numberp gnus-auto-center-summary)
6210 gnus-auto-center-summary
6212 (height (1- (window-height)))
6213 (bottom (save-excursion (goto-char (point-max))
6214 (forward-line (- height))
6216 (window (get-buffer-window (current-buffer))))
6217 (when (get-buffer-window gnus-article-buffer)
6218 ;; Only do recentering when the article buffer is displayed,
6219 ;; Set the window start to either `bottom', which is the biggest
6220 ;; possible valid number, or the second line from the top,
6221 ;; whichever is the least.
6222 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6223 (if (> bottom top-pos)
6224 ;; Keep the second line from the top visible
6225 (set-window-start window top-pos t)
6226 ;; Try to keep the bottom line visible; if it's partially
6227 ;; obscured, either scroll one more line to make it fully
6228 ;; visible, or revert to using TOP-POS.
6230 (goto-char (point-max))
6232 (let ((last-line-start (point)))
6234 (set-window-start window (point) t)
6235 (when (not (pos-visible-in-window-p last-line-start window))
6237 (set-window-start window (min (point) top-pos) t)))))))
6238 ;; Do horizontal recentering while we're at it.
6239 (when (and (get-buffer-window (current-buffer) t)
6240 (not (eq gnus-auto-center-summary 'vertical)))
6241 (let ((selected (selected-window)))
6242 (select-window (get-buffer-window (current-buffer) t))
6243 (gnus-summary-position-point)
6244 (gnus-horizontal-recenter)
6245 (select-window selected))))))
6247 (defun gnus-summary-jump-to-group (newsgroup)
6248 "Move point to NEWSGROUP in group mode buffer."
6249 ;; Keep update point of group mode buffer if visible.
6250 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6251 (save-window-excursion
6252 ;; Take care of tree window mode.
6253 (when (get-buffer-window gnus-group-buffer)
6254 (pop-to-buffer gnus-group-buffer))
6255 (gnus-group-jump-to-group newsgroup))
6257 ;; Take care of tree window mode.
6258 (if (get-buffer-window gnus-group-buffer)
6259 (pop-to-buffer gnus-group-buffer)
6260 (set-buffer gnus-group-buffer))
6261 (gnus-group-jump-to-group newsgroup))))
6263 ;; This function returns a list of article numbers based on the
6264 ;; difference between the ranges of read articles in this group and
6265 ;; the range of active articles.
6266 (defun gnus-list-of-unread-articles (group)
6267 (let* ((read (gnus-info-read (gnus-get-info group)))
6268 (active (or (gnus-active group) (gnus-activate-group group)))
6271 ;; If none are read, then all are unread.
6273 (setq first (car active))
6274 ;; If the range of read articles is a single range, then the
6275 ;; first unread article is the article after the last read
6276 ;; article. Sounds logical, doesn't it?
6277 (if (and (not (listp (cdr read)))
6278 (or (< (car read) (car active))
6279 (progn (setq read (list read))
6281 (setq first (max (car active) (1+ (cdr read))))
6282 ;; `read' is a list of ranges.
6283 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6286 (setq first (car active)))
6289 (while (< first nlast)
6291 (setq first (1+ first))))
6292 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6293 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6294 (setq read (cdr read)))))
6295 ;; And add the last unread articles.
6296 (while (<= first last)
6298 (setq first (1+ first)))
6299 ;; Return the list of unread articles.
6300 (delq 0 (nreverse unread))))
6302 (defun gnus-list-of-read-articles (group)
6303 "Return a list of unread, unticked and non-dormant articles."
6304 (let* ((info (gnus-get-info group))
6305 (marked (gnus-info-marks info))
6306 (active (gnus-active group)))
6308 (gnus-list-range-difference
6309 (gnus-list-range-difference
6310 (gnus-sorted-complement
6311 (gnus-uncompress-range active)
6312 (gnus-list-of-unread-articles group))
6313 (cdr (assq 'dormant marked)))
6314 (cdr (assq 'tick marked))))))
6316 ;; Various summary commands
6318 (defun gnus-summary-select-article-buffer ()
6319 "Reconfigure windows to show article buffer."
6321 (if (not (gnus-buffer-live-p gnus-article-buffer))
6322 (error "There is no article buffer for this summary buffer")
6323 (gnus-configure-windows 'article)
6324 (select-window (get-buffer-window gnus-article-buffer))))
6326 (defun gnus-summary-universal-argument (arg)
6327 "Perform any operation on all articles that are process/prefixed."
6329 (let ((articles (gnus-summary-work-articles arg))
6336 (substitute-command-keys
6337 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6339 (gnus-error 1 "Undefined key")
6342 (gnus-summary-goto-subject (setq article (pop articles)))
6343 (let (gnus-newsgroup-processable)
6344 (command-execute func))
6345 (gnus-summary-remove-process-mark article)))))
6346 (gnus-summary-position-point))
6348 (defun gnus-summary-toggle-truncation (&optional arg)
6349 "Toggle truncation of summary lines.
6350 With arg, turn line truncation on if arg is positive."
6352 (setq truncate-lines
6353 (if (null arg) (not truncate-lines)
6354 (> (prefix-numeric-value arg) 0)))
6357 (defun gnus-summary-find-for-reselect ()
6358 "Return the number of an article to stay on across a reselect.
6359 The current article is considered, then following articles, then previous
6360 articles. An article is sought which is not cancelled and isn't a temporary
6361 insertion from another group. If there's no such then return a dummy 0."
6363 (dolist (rev '(nil t))
6364 (unless found ; don't demand the reverse list if we don't need it
6365 (let ((data (gnus-data-find-list
6366 (gnus-summary-article-number) (gnus-data-list rev))))
6367 (while (and data (not found))
6368 (if (and (< 0 (gnus-data-number (car data)))
6369 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6370 (setq found (gnus-data-number (car data))))
6371 (setq data (cdr data))))))
6374 (defun gnus-summary-reselect-current-group (&optional all rescan)
6375 "Exit and then reselect the current newsgroup.
6376 The prefix argument ALL means to select all articles."
6378 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6379 (error "Ephemeral groups can't be reselected"))
6380 (let ((current-subject (gnus-summary-find-for-reselect))
6381 (group gnus-newsgroup-name))
6382 (setq gnus-newsgroup-begin nil)
6384 ;; We have to adjust the point of group mode buffer because
6385 ;; point was moved to the next unread newsgroup by exiting.
6386 (gnus-summary-jump-to-group group)
6389 (save-window-excursion
6390 ;; Don't show group contents.
6391 (set-window-start (selected-window) (point-max))
6392 (gnus-group-get-new-news-this-group 1))))
6393 (gnus-group-read-group all t)
6394 (gnus-summary-goto-subject current-subject nil t)))
6396 (defun gnus-summary-rescan-group (&optional all)
6397 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6399 (gnus-summary-reselect-current-group all t))
6401 (defun gnus-summary-update-info (&optional non-destructive)
6403 (let ((group gnus-newsgroup-name))
6405 (when gnus-newsgroup-kill-headers
6406 (setq gnus-newsgroup-killed
6407 (gnus-compress-sequence
6409 (gnus-list-range-intersection
6410 gnus-newsgroup-unselected gnus-newsgroup-killed)
6411 gnus-newsgroup-unreads)
6413 (unless (listp (cdr gnus-newsgroup-killed))
6414 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6415 (let ((headers gnus-newsgroup-headers))
6416 ;; Set the new ranges of read articles.
6418 (set-buffer gnus-group-buffer)
6419 (gnus-undo-force-boundary))
6420 (gnus-update-read-articles
6421 group (gnus-sorted-union
6422 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6423 ;; Set the current article marks.
6424 (let ((gnus-newsgroup-scored
6425 (if (and (not gnus-save-score)
6426 (not non-destructive))
6428 gnus-newsgroup-scored)))
6430 (gnus-update-marks)))
6431 ;; Do the cross-ref thing.
6432 (when gnus-use-cross-reference
6433 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6434 ;; Do not switch windows but change the buffer to work.
6435 (set-buffer gnus-group-buffer)
6436 (unless (gnus-ephemeral-group-p group)
6437 (gnus-group-update-group group)))))))
6439 (defun gnus-summary-save-newsrc (&optional force)
6440 "Save the current number of read/marked articles in the dribble buffer.
6441 The dribble buffer will then be saved.
6442 If FORCE (the prefix), also save the .newsrc file(s)."
6444 (gnus-summary-update-info t)
6446 (gnus-save-newsrc-file)
6447 (gnus-dribble-save)))
6449 (defun gnus-summary-exit (&optional temporary)
6450 "Exit reading current newsgroup, and then return to group selection mode.
6451 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6453 (gnus-set-global-variables)
6454 (gnus-kill-save-kill-buffer)
6455 (gnus-async-halt-prefetch)
6456 (let* ((group gnus-newsgroup-name)
6457 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6458 (gnus-group-is-exiting-p t)
6461 (buf (current-buffer)))
6463 ;; Do adaptive scoring, and possibly save score files.
6464 (when gnus-newsgroup-adaptive
6465 (gnus-score-adaptive))
6466 (when gnus-use-scoring
6468 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6469 ;; If we have several article buffers, we kill them at exit.
6470 (unless gnus-single-article-buffer
6471 (gnus-kill-buffer gnus-original-article-buffer)
6472 (setq gnus-article-current nil))
6473 (when gnus-use-cache
6474 (gnus-cache-possibly-remove-articles)
6475 (gnus-cache-save-buffers))
6476 (gnus-async-prefetch-remove-group group)
6477 (when gnus-suppress-duplicates
6478 (gnus-dup-enter-articles))
6479 (when gnus-use-trees
6480 (gnus-tree-close group))
6481 (when gnus-use-cache
6482 (gnus-cache-write-active))
6483 ;; Remove entries for this group.
6484 (nnmail-purge-split-history (gnus-group-real-name group))
6485 ;; Make all changes in this group permanent.
6487 (gnus-run-hooks 'gnus-exit-group-hook)
6488 (gnus-summary-update-info))
6489 (gnus-close-group group)
6490 ;; Make sure where we were, and go to next newsgroup.
6491 (set-buffer gnus-group-buffer)
6493 (gnus-group-jump-to-group group))
6494 (gnus-run-hooks 'gnus-summary-exit-hook)
6495 (unless (or quit-config
6496 ;; If this group has disappeared from the summary
6497 ;; buffer, don't skip forwards.
6498 (not (string= group (gnus-group-group-name))))
6499 (gnus-group-next-unread-group 1))
6500 (setq group-point (point))
6503 ;; If we have several article buffers, we kill them at exit.
6504 (unless gnus-single-article-buffer
6505 (gnus-kill-buffer gnus-article-buffer)
6506 (gnus-kill-buffer gnus-original-article-buffer)
6507 (setq gnus-article-current nil))
6509 (if (not gnus-kill-summary-on-exit)
6511 (gnus-deaden-summary)
6513 ;; We set all buffer-local variables to nil. It is unclear why
6514 ;; this is needed, but if we don't, buffer-local variables are
6515 ;; not garbage-collected, it seems. This would the lead to en
6516 ;; ever-growing Emacs.
6517 (gnus-summary-clear-local-variables)
6518 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6519 (gnus-summary-clear-local-variables))
6520 (when (get-buffer gnus-article-buffer)
6521 (bury-buffer gnus-article-buffer))
6522 ;; We clear the global counterparts of the buffer-local
6523 ;; variables as well, just to be on the safe side.
6524 (set-buffer gnus-group-buffer)
6525 (gnus-summary-clear-local-variables)
6526 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6527 (gnus-summary-clear-local-variables))
6528 ;; Return to group mode buffer.
6529 (when (eq mode 'gnus-summary-mode)
6530 (gnus-kill-buffer buf)))
6531 (setq gnus-current-select-method gnus-select-method)
6532 (pop-to-buffer gnus-group-buffer)
6533 (if (not quit-config)
6535 (goto-char group-point)
6536 (gnus-configure-windows 'group 'force)
6537 (unless (pos-visible-in-window-p)
6538 (forward-line (/ (static-if (featurep 'xemacs)
6539 (window-displayed-height)
6540 (1- (window-height)))
6542 (set-window-start (selected-window) (point))
6543 (goto-char group-point)))
6544 (gnus-handle-ephemeral-exit quit-config))
6545 ;; Clear the current group name.
6547 (setq gnus-newsgroup-name nil)))))
6549 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6550 (defun gnus-summary-exit-no-update (&optional no-questions)
6551 "Quit reading current newsgroup without updating read article info."
6553 (let* ((group gnus-newsgroup-name)
6554 (gnus-group-is-exiting-p t)
6555 (gnus-group-is-exiting-without-update-p t)
6556 (quit-config (gnus-group-quit-config group)))
6557 (when (or no-questions
6559 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6560 (gnus-async-halt-prefetch)
6561 (run-hooks 'gnus-summary-prepare-exit-hook)
6562 ;; If we have several article buffers, we kill them at exit.
6563 (unless gnus-single-article-buffer
6564 (gnus-kill-buffer gnus-article-buffer)
6565 (gnus-kill-buffer gnus-original-article-buffer)
6566 (setq gnus-article-current nil))
6567 (if (not gnus-kill-summary-on-exit)
6568 (gnus-deaden-summary)
6569 (gnus-close-group group)
6570 (gnus-summary-clear-local-variables)
6571 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6572 (gnus-summary-clear-local-variables))
6573 (set-buffer gnus-group-buffer)
6574 (gnus-summary-clear-local-variables)
6575 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6576 (gnus-summary-clear-local-variables))
6577 (gnus-kill-buffer gnus-summary-buffer))
6578 (unless gnus-single-article-buffer
6579 (setq gnus-article-current nil))
6580 (when gnus-use-trees
6581 (gnus-tree-close group))
6582 (gnus-async-prefetch-remove-group group)
6583 (when (get-buffer gnus-article-buffer)
6584 (bury-buffer gnus-article-buffer))
6585 ;; Return to the group buffer.
6586 (gnus-configure-windows 'group 'force)
6587 ;; Clear the current group name.
6588 (setq gnus-newsgroup-name nil)
6589 (unless (gnus-ephemeral-group-p group)
6590 (gnus-group-update-group group))
6591 (when (equal (gnus-group-group-name) group)
6592 (gnus-group-next-unread-group 1))
6594 (gnus-handle-ephemeral-exit quit-config)))))
6596 (defun gnus-handle-ephemeral-exit (quit-config)
6597 "Handle movement when leaving an ephemeral group.
6598 The state which existed when entering the ephemeral is reset."
6599 (if (not (buffer-name (car quit-config)))
6600 (gnus-configure-windows 'group 'force)
6601 (set-buffer (car quit-config))
6602 (cond ((eq major-mode 'gnus-summary-mode)
6603 (gnus-set-global-variables))
6604 ((eq major-mode 'gnus-article-mode)
6606 ;; The `gnus-summary-buffer' variable may point
6607 ;; to the old summary buffer when using a single
6609 (unless (gnus-buffer-live-p gnus-summary-buffer)
6610 (set-buffer gnus-group-buffer))
6611 (set-buffer gnus-summary-buffer)
6612 (gnus-set-global-variables))))
6613 (if (or (eq (cdr quit-config) 'article)
6614 (eq (cdr quit-config) 'pick))
6616 ;; The current article may be from the ephemeral group
6617 ;; thus it is best that we reload this article
6618 (gnus-summary-show-article)
6619 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6620 (gnus-configure-windows 'pick 'force)
6621 (gnus-configure-windows (cdr quit-config) 'force)))
6622 (gnus-configure-windows (cdr quit-config) 'force))
6623 (when (eq major-mode 'gnus-summary-mode)
6624 (gnus-summary-next-subject 1 nil t)
6625 (gnus-summary-recenter)
6626 (gnus-summary-position-point))))
6628 (defun gnus-summary-preview-mime-message ()
6629 "MIME decode and play this message."
6631 (let ((gnus-break-pages nil)
6633 (gnus-summary-select-article gnus-show-all-headers t))
6634 (let ((w (get-buffer-window gnus-article-buffer)))
6636 (select-window (get-buffer-window gnus-article-buffer)))))
6640 (defvar gnus-dead-summary-mode-map nil)
6642 (unless gnus-dead-summary-mode-map
6643 (setq gnus-dead-summary-mode-map (make-keymap))
6644 (suppress-keymap gnus-dead-summary-mode-map)
6645 (substitute-key-definition
6646 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6647 (dolist (key '("\C-d" "\r" "\177" [delete]))
6648 (define-key gnus-dead-summary-mode-map
6649 key 'gnus-summary-wake-up-the-dead))
6650 (dolist (key '("q" "Q"))
6651 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6653 (defvar gnus-dead-summary-mode nil
6654 "Minor mode for Gnus summary buffers.")
6656 (defun gnus-dead-summary-mode (&optional arg)
6657 "Minor mode for Gnus summary buffers."
6659 (when (eq major-mode 'gnus-summary-mode)
6660 (make-local-variable 'gnus-dead-summary-mode)
6661 (setq gnus-dead-summary-mode
6662 (if (null arg) (not gnus-dead-summary-mode)
6663 (> (prefix-numeric-value arg) 0)))
6664 (when gnus-dead-summary-mode
6665 (gnus-add-minor-mode
6666 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6668 (defun gnus-deaden-summary ()
6669 "Make the current summary buffer into a dead summary buffer."
6670 ;; Kill any previous dead summary buffer.
6671 (when (and gnus-dead-summary
6672 (buffer-name gnus-dead-summary))
6674 (set-buffer gnus-dead-summary)
6675 (when gnus-dead-summary-mode
6676 (kill-buffer (current-buffer)))))
6677 ;; Make this the current dead summary.
6678 (setq gnus-dead-summary (current-buffer))
6679 (gnus-dead-summary-mode 1)
6680 (let ((name (buffer-name)))
6681 (when (string-match "Summary" name)
6683 (concat (substring name 0 (match-beginning 0)) "Dead "
6684 (substring name (match-beginning 0)))
6688 (defun gnus-kill-or-deaden-summary (buffer)
6689 "Kill or deaden the summary BUFFER."
6691 (when (and (buffer-name buffer)
6692 (not gnus-single-article-buffer))
6695 (gnus-kill-buffer gnus-article-buffer)
6696 (gnus-kill-buffer gnus-original-article-buffer)))
6699 (gnus-kill-summary-on-exit
6700 (when (and gnus-use-trees
6701 (gnus-buffer-exists-p buffer))
6704 (gnus-tree-close gnus-newsgroup-name)))
6705 (gnus-kill-buffer buffer))
6706 ;; Deaden the buffer.
6707 ((gnus-buffer-exists-p buffer)
6710 (gnus-deaden-summary))))))
6712 (defun gnus-summary-wake-up-the-dead (&rest args)
6713 "Wake up the dead summary buffer."
6715 (gnus-dead-summary-mode -1)
6716 (let ((name (buffer-name)))
6717 (when (string-match "Dead " name)
6719 (concat (substring name 0 (match-beginning 0))
6720 (substring name (match-end 0)))
6722 (gnus-message 3 "This dead summary is now alive again"))
6724 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6725 (defun gnus-summary-fetch-faq (&optional faq-dir)
6726 "Fetch the FAQ for the current group.
6727 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6731 (when current-prefix-arg
6733 "FAQ dir: " (and (listp gnus-group-faq-directory)
6734 (mapcar (lambda (file) (list file))
6735 gnus-group-faq-directory))))))
6736 (let (gnus-faq-buffer)
6737 (when (setq gnus-faq-buffer
6738 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6739 (gnus-configure-windows 'summary-faq))))
6741 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6742 (defun gnus-summary-describe-group (&optional force)
6743 "Describe the current newsgroup."
6745 (gnus-group-describe-group force gnus-newsgroup-name))
6747 (defun gnus-summary-describe-briefly ()
6748 "Describe summary mode commands briefly."
6750 (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")))
6752 ;; Walking around group mode buffer from summary mode.
6754 (defun gnus-summary-next-group (&optional no-article target-group backward)
6755 "Exit current newsgroup and then select next unread newsgroup.
6756 If prefix argument NO-ARTICLE is non-nil, no article is selected
6757 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6758 previous group instead."
6760 ;; Stop pre-fetching.
6761 (gnus-async-halt-prefetch)
6762 (let ((current-group gnus-newsgroup-name)
6763 (current-buffer (current-buffer))
6765 ;; First we semi-exit this group to update Xrefs and all variables.
6766 ;; We can't do a real exit, because the window conf must remain
6767 ;; the same in case the user is prompted for info, and we don't
6768 ;; want the window conf to change before that...
6769 (gnus-summary-exit t)
6770 (while (not entered)
6771 ;; Then we find what group we are supposed to enter.
6772 (set-buffer gnus-group-buffer)
6773 (gnus-group-jump-to-group current-group)
6776 (if (eq gnus-keep-same-level 'best)
6777 (gnus-summary-best-group gnus-newsgroup-name)
6778 (gnus-summary-search-group backward gnus-keep-same-level))))
6779 (if (not target-group)
6780 ;; There are no further groups, so we return to the group
6783 (gnus-message 5 "Returning to the group buffer")
6785 (when (gnus-buffer-live-p current-buffer)
6786 (set-buffer current-buffer)
6787 (gnus-summary-exit))
6788 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6789 ;; We try to enter the target group.
6790 (gnus-group-jump-to-group target-group)
6791 (let ((unreads (gnus-group-group-unread)))
6792 (if (and (or (eq t unreads)
6793 (and unreads (not (zerop unreads))))
6794 (gnus-summary-read-group
6795 target-group nil no-article
6796 (and (buffer-name current-buffer) current-buffer)
6799 (setq current-group target-group
6800 target-group nil)))))))
6802 (defun gnus-summary-prev-group (&optional no-article)
6803 "Exit current newsgroup and then select previous unread newsgroup.
6804 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6806 (gnus-summary-next-group no-article nil t))
6808 ;; Walking around summary lines.
6810 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6811 "Go to the first subject satisfying any non-nil constraint.
6812 If UNREAD is non-nil, the article should be unread.
6813 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6814 If UNSEED is non-nil, the article should be unseen.
6815 Returns the article selected or nil if there are no matching articles."
6819 ((null gnus-newsgroup-data)
6820 (gnus-message 3 "No articles in the group")
6822 ;; Pick the first article.
6823 ((not (or unread undownloaded unseen))
6824 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6825 (gnus-data-number (car gnus-newsgroup-data)))
6826 ;; Find the first unread article.
6828 (let ((data gnus-newsgroup-data))
6830 (let ((num (gnus-data-number (car data))))
6831 (or (memq num gnus-newsgroup-unfetched)
6832 (not (or (and unread
6833 (memq num gnus-newsgroup-unreads))
6835 (memq num gnus-newsgroup-undownloaded))
6837 (memq num gnus-newsgroup-unseen)))))))
6838 (setq data (cdr data)))
6842 (goto-char (gnus-data-pos (car data)))
6843 (gnus-data-number (car data)))
6844 (gnus-message 3 "No more%s articles"
6845 (let* ((r (when unread " unread"))
6846 (d (when undownloaded " undownloaded"))
6847 (s (when unseen " unseen"))
6848 (l (delq nil (list r d s))))
6849 (cond ((= 3 (length l))
6850 (concat r "," d ", or" s))
6852 (concat (car l) ", or" (cadr l)))
6859 (gnus-summary-position-point))))))
6861 (defun gnus-summary-next-subject (n &optional unread dont-display)
6862 "Go to next N'th summary line.
6863 If N is negative, go to the previous N'th subject line.
6864 If UNREAD is non-nil, only unread articles are selected.
6865 The difference between N and the actual number of steps taken is
6868 (let ((backward (< n 0))
6872 (gnus-summary-find-prev unread)
6873 (gnus-summary-find-next unread)))
6874 (unless (zerop (setq n (1- n)))
6875 (gnus-summary-show-thread)))
6877 (gnus-message 7 "No more%s articles"
6878 (if unread " unread" "")))
6879 (unless dont-display
6880 (gnus-summary-recenter)
6881 (gnus-summary-position-point))
6884 (defun gnus-summary-next-unread-subject (n)
6885 "Go to next N'th unread summary line."
6887 (gnus-summary-next-subject n t))
6889 (defun gnus-summary-prev-subject (n &optional unread)
6890 "Go to previous N'th summary line.
6891 If optional argument UNREAD is non-nil, only unread article is selected."
6893 (gnus-summary-next-subject (- n) unread))
6895 (defun gnus-summary-prev-unread-subject (n)
6896 "Go to previous N'th unread summary line."
6898 (gnus-summary-next-subject (- n) t))
6900 (defun gnus-summary-goto-subjects (articles)
6901 "Insert the subject header for ARTICLES in the current buffer."
6903 (dolist (article articles)
6904 (gnus-summary-goto-subject article t)))
6905 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6906 (gnus-summary-position-point))
6908 (defun gnus-summary-goto-subject (article &optional force silent)
6909 "Go the subject line of ARTICLE.
6910 If FORCE, also allow jumping to articles not currently shown."
6911 (interactive "nArticle number: ")
6912 (unless (numberp article)
6913 (error "Article %s is not a number" article))
6915 (data (gnus-data-find article)))
6916 ;; We read in the article if we have to.
6919 (gnus-summary-insert-subject
6921 (if (or (numberp force) (vectorp force)) force)
6923 (setq data (gnus-data-find article)))
6928 (gnus-message 3 "Can't find article %d" article))
6930 (let ((pt (gnus-data-pos data)))
6932 (gnus-summary-set-article-display-arrow pt))
6933 (gnus-summary-position-point)
6936 ;; Walking around summary lines with displaying articles.
6938 (defun gnus-summary-expand-window (&optional arg)
6939 "Make the summary buffer take up the entire Emacs frame.
6940 Given a prefix, will force an `article' buffer configuration."
6943 (gnus-configure-windows 'article 'force)
6944 (gnus-configure-windows 'summary 'force)))
6946 (defun gnus-summary-display-article (article &optional all-header)
6947 "Display ARTICLE in article buffer."
6948 (when (gnus-buffer-live-p gnus-article-buffer)
6949 (with-current-buffer gnus-article-buffer
6950 (set-buffer-multibyte t)))
6951 (gnus-set-global-variables)
6952 (when (gnus-buffer-live-p gnus-article-buffer)
6953 (with-current-buffer gnus-article-buffer
6954 (setq gnus-article-charset gnus-newsgroup-charset)
6955 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6956 (set-buffer-multibyte t)))
6960 (if gnus-summary-display-article-function
6961 (funcall gnus-summary-display-article-function article all-header)
6962 (gnus-article-prepare article all-header))
6963 (with-current-buffer gnus-article-buffer
6964 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6966 (gnus-run-hooks 'gnus-select-article-hook)
6967 (when (and gnus-current-article
6968 (not (zerop gnus-current-article)))
6969 (gnus-summary-goto-subject gnus-current-article))
6970 (gnus-summary-recenter)
6971 (when (and gnus-use-trees gnus-show-threads)
6972 (gnus-possibly-generate-tree article)
6973 (gnus-highlight-selected-tree article))
6974 ;; Successfully display article.
6975 (gnus-article-set-window-start
6976 (cdr (assq article gnus-newsgroup-bookmarks))))))
6978 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6979 "Select the current article.
6980 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6981 non-nil, the article will be re-fetched even if it already present in
6982 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6984 ;; Make sure we are in the summary buffer to work around bbdb bug.
6985 (unless (eq major-mode 'gnus-summary-mode)
6986 (set-buffer gnus-summary-buffer))
6987 (let ((article (or article (gnus-summary-article-number)))
6988 (all-headers (not (not all-headers))) ;Must be T or NIL.
6989 gnus-summary-display-article-function)
6991 (gnus-summary-article-pseudo-p article)
6992 (error "This is a pseudo-article"))
6994 (set-buffer gnus-summary-buffer)
6995 (if (or (and gnus-single-article-buffer
6996 (or (null gnus-current-article)
6997 (null gnus-article-current)
6998 (null (get-buffer gnus-article-buffer))
6999 (not (eq article (cdr gnus-article-current)))
7000 (not (equal (car gnus-article-current)
7001 gnus-newsgroup-name))))
7002 (and (not gnus-single-article-buffer)
7003 (or (null gnus-current-article)
7004 (not (eq gnus-current-article article))))
7006 ;; The requested article is different from the current article.
7008 (gnus-summary-display-article article all-headers)
7009 (gnus-article-set-window-start
7010 (cdr (assq article gnus-newsgroup-bookmarks)))
7014 (defun gnus-summary-force-verify-and-decrypt ()
7015 "Display buttons for signed/encrypted parts and verify/decrypt them."
7017 (let ((mm-verify-option 'known)
7018 (mm-decrypt-option 'known)
7019 (gnus-buttonized-mime-types (append (list "multipart/signed"
7020 "multipart/encrypted")
7021 gnus-buttonized-mime-types)))
7022 (gnus-summary-select-article nil 'force)))
7024 (defun gnus-summary-set-current-mark (&optional current-mark)
7025 "Obsolete function."
7028 (defun gnus-summary-next-article (&optional unread subject backward push)
7029 "Select the next article.
7030 If UNREAD, only unread articles are selected.
7031 If SUBJECT, only articles with SUBJECT are selected.
7032 If BACKWARD, the previous article is selected instead of the next."
7035 ;; Is there such an article?
7036 ((and (gnus-summary-search-forward unread subject backward)
7037 (or (gnus-summary-display-article (gnus-summary-article-number))
7038 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7039 (gnus-summary-position-point))
7040 ;; If not, we try the first unread, if that is wanted.
7042 gnus-auto-select-same
7043 (gnus-summary-first-unread-article))
7044 (gnus-summary-position-point)
7045 (gnus-message 6 "Wrapped"))
7046 ;; Try to get next/previous article not displayed in this group.
7047 ((and gnus-auto-extend-newsgroup
7048 (not unread) (not subject))
7049 (gnus-summary-goto-article
7050 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7051 nil (count-lines (point-min) (point))))
7052 ;; Go to next/previous group.
7054 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7055 (gnus-summary-jump-to-group gnus-newsgroup-name))
7056 (let ((cmd last-command-char)
7059 (set-buffer gnus-group-buffer)
7062 (if (eq gnus-keep-same-level 'best)
7063 (gnus-summary-best-group gnus-newsgroup-name)
7064 (gnus-summary-search-group backward gnus-keep-same-level))))
7065 ;; For some reason, the group window gets selected. We change
7067 (select-window (get-buffer-window (current-buffer)))
7068 ;; Select next unread newsgroup automagically.
7070 ((or (not gnus-auto-select-next)
7072 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7073 ((or (eq gnus-auto-select-next 'quietly)
7074 (and (eq gnus-auto-select-next 'slightly-quietly)
7076 (and (eq gnus-auto-select-next 'almost-quietly)
7077 (gnus-summary-last-article-p)))
7079 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7081 (gnus-message 7 "No more%s articles (%s)..."
7082 (if unread " unread" "")
7083 (if group (concat "selecting " group)
7085 (gnus-summary-next-group nil group backward)))
7087 (when (gnus-key-press-event-p last-input-event)
7088 (gnus-summary-walk-group-buffer
7089 gnus-newsgroup-name cmd unread backward point))))))))
7091 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7092 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7093 (?\C-p (gnus-group-prev-unread-group 1))))
7094 (cursor-in-echo-area t)
7095 keve key group ended prompt)
7097 (set-buffer gnus-group-buffer)
7100 (if (eq gnus-keep-same-level 'best)
7101 (gnus-summary-best-group gnus-newsgroup-name)
7102 (gnus-summary-search-group backward gnus-keep-same-level))))
7106 "No more%s articles%s " (if unread " unread" "")
7108 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7109 (format " (Type %s for %s [%s])"
7110 (single-key-description cmd) group
7111 (car (gnus-gethash group gnus-newsrc-hashtb)))
7112 (format " (Type %s to exit %s)"
7113 (single-key-description cmd)
7114 gnus-newsgroup-name))))
7115 ;; Confirm auto selection.
7116 (setq key (car (setq keve (gnus-read-event-char prompt)))
7119 ((assq key keystrokes)
7120 (let ((obuf (current-buffer)))
7121 (switch-to-buffer gnus-group-buffer)
7123 (gnus-group-jump-to-group group))
7124 (eval (cadr (assq key keystrokes)))
7125 (setq group (gnus-group-group-name))
7126 (switch-to-buffer obuf))
7130 (gnus-ephemeral-group-p gnus-newsgroup-name))
7132 (gnus-summary-next-group nil group backward)))
7134 (push (cdr keve) unread-command-events))))))
7136 (defun gnus-summary-next-unread-article ()
7137 "Select unread article after current one."
7139 (gnus-summary-next-article
7140 (or (not (eq gnus-summary-goto-unread 'never))
7141 (gnus-summary-last-article-p (gnus-summary-article-number)))
7142 (and gnus-auto-select-same
7143 (gnus-summary-article-subject))))
7145 (defun gnus-summary-prev-article (&optional unread subject)
7146 "Select the article after the current one.
7147 If UNREAD is non-nil, only unread articles are selected."
7149 (gnus-summary-next-article unread subject t))
7151 (defun gnus-summary-prev-unread-article ()
7152 "Select unread article before current one."
7154 (gnus-summary-prev-article
7155 (or (not (eq gnus-summary-goto-unread 'never))
7156 (gnus-summary-first-article-p (gnus-summary-article-number)))
7157 (and gnus-auto-select-same
7158 (gnus-summary-article-subject))))
7160 (defun gnus-summary-next-page (&optional lines circular stop)
7161 "Show next page of the selected article.
7162 If at the end of the current article, select the next article.
7163 LINES says how many lines should be scrolled up.
7165 If CIRCULAR is non-nil, go to the start of the article instead of
7166 selecting the next article when reaching the end of the current
7169 If STOP is non-nil, just stop when reaching the end of the message."
7171 (setq gnus-summary-buffer (current-buffer))
7172 (gnus-set-global-variables)
7173 (let ((article (gnus-summary-article-number))
7174 (article-window (get-buffer-window gnus-article-buffer t))
7176 ;; If the buffer is empty, we have no article.
7178 (error "No article to select"))
7179 (gnus-configure-windows 'article)
7180 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7181 (if (and (eq gnus-summary-goto-unread 'never)
7182 (not (gnus-summary-last-article-p article)))
7183 (gnus-summary-next-article)
7184 (gnus-summary-next-unread-article))
7185 (if (or (null gnus-current-article)
7186 (null gnus-article-current)
7187 (/= article (cdr gnus-article-current))
7188 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7189 ;; Selected subject is different from current article's.
7190 (gnus-summary-display-article article)
7191 (when article-window
7192 (gnus-eval-in-buffer-window gnus-article-buffer
7193 (setq endp (or (gnus-article-next-page lines)
7194 (gnus-article-only-boring-p))))
7197 (gnus-message 3 "End of message"))
7199 (gnus-summary-beginning-of-article))
7201 (gnus-message 3 "End of message"))
7203 (if (and (eq gnus-summary-goto-unread 'never)
7204 (not (gnus-summary-last-article-p article)))
7205 (gnus-summary-next-article)
7206 (gnus-summary-next-unread-article))))))))
7207 (gnus-summary-recenter)
7208 (gnus-summary-position-point)))
7210 (defun gnus-summary-prev-page (&optional lines move)
7211 "Show previous page of selected article.
7212 Argument LINES specifies lines to be scrolled down.
7213 If MOVE, move to the previous unread article if point is at
7214 the beginning of the buffer."
7216 (let ((article (gnus-summary-article-number))
7217 (article-window (get-buffer-window gnus-article-buffer t))
7219 (gnus-configure-windows 'article)
7220 (if (or (null gnus-current-article)
7221 (null gnus-article-current)
7222 (/= article (cdr gnus-article-current))
7223 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7224 ;; Selected subject is different from current article's.
7225 (gnus-summary-display-article article)
7226 (gnus-summary-recenter)
7227 (when article-window
7228 (gnus-eval-in-buffer-window gnus-article-buffer
7229 (setq endp (gnus-article-prev-page lines)))
7230 (when (and move endp)
7232 (gnus-message 3 "Beginning of message"))
7234 (if (and (eq gnus-summary-goto-unread 'never)
7235 (not (gnus-summary-first-article-p article)))
7236 (gnus-summary-prev-article)
7237 (gnus-summary-prev-unread-article))))))))
7238 (gnus-summary-position-point))
7240 (defun gnus-summary-prev-page-or-article (&optional lines)
7241 "Show previous page of selected article.
7242 Argument LINES specifies lines to be scrolled down.
7243 If at the beginning of the article, go to the next article."
7245 (gnus-summary-prev-page lines t))
7247 (defun gnus-summary-scroll-up (lines)
7248 "Scroll up (or down) one line current article.
7249 Argument LINES specifies lines to be scrolled up (or down if negative)."
7251 (gnus-configure-windows 'article)
7252 (gnus-summary-show-thread)
7253 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7254 (gnus-eval-in-buffer-window gnus-article-buffer
7256 (when (gnus-article-next-page lines)
7257 (gnus-message 3 "End of message")))
7259 (gnus-article-prev-page (- lines))))))
7260 (gnus-summary-recenter)
7261 (gnus-summary-position-point))
7263 (defun gnus-summary-scroll-down (lines)
7264 "Scroll down (or up) one line current article.
7265 Argument LINES specifies lines to be scrolled down (or up if negative)."
7267 (gnus-summary-scroll-up (- lines)))
7269 (defun gnus-summary-next-same-subject ()
7270 "Select next article which has the same subject as current one."
7272 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7274 (defun gnus-summary-prev-same-subject ()
7275 "Select previous article which has the same subject as current one."
7277 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7279 (defun gnus-summary-next-unread-same-subject ()
7280 "Select next unread article which has the same subject as current one."
7282 (gnus-summary-next-article t (gnus-summary-article-subject)))
7284 (defun gnus-summary-prev-unread-same-subject ()
7285 "Select previous unread article which has the same subject as current one."
7287 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7289 (defun gnus-summary-first-unread-article ()
7290 "Select the first unread article.
7291 Return nil if there are no unread articles."
7294 (when (gnus-summary-first-subject t)
7295 (gnus-summary-show-thread)
7296 (gnus-summary-first-subject t)
7297 (gnus-summary-display-article (gnus-summary-article-number)))
7298 (gnus-summary-position-point)))
7300 (defun gnus-summary-first-unread-subject ()
7301 "Place the point on the subject line of the first unread article.
7302 Return nil if there are no unread articles."
7305 (when (gnus-summary-first-subject t)
7306 (gnus-summary-show-thread)
7307 (gnus-summary-first-subject t))
7308 (gnus-summary-position-point)))
7310 (defun gnus-summary-first-unseen-subject ()
7311 "Place the point on the subject line of the first unseen article.
7312 Return nil if there are no unseen articles."
7315 (when (gnus-summary-first-subject nil nil t)
7316 (gnus-summary-show-thread)
7317 (gnus-summary-first-subject nil nil t))
7318 (gnus-summary-position-point)))
7320 (defun gnus-summary-first-unseen-or-unread-subject ()
7321 "Place the point on the subject line of the first unseen article or,
7322 if all article have been seen, on the subject line of the first unread
7326 (unless (when (gnus-summary-first-subject nil nil t)
7327 (gnus-summary-show-thread)
7328 (gnus-summary-first-subject nil nil t))
7329 (when (gnus-summary-first-subject t)
7330 (gnus-summary-show-thread)
7331 (gnus-summary-first-subject t)))
7332 (gnus-summary-position-point)))
7334 (defun gnus-summary-first-article ()
7335 "Select the first article.
7336 Return nil if there are no articles."
7339 (when (gnus-summary-first-subject)
7340 (gnus-summary-show-thread)
7341 (gnus-summary-first-subject)
7342 (gnus-summary-display-article (gnus-summary-article-number)))
7343 (gnus-summary-position-point)))
7345 (defun gnus-summary-best-unread-article (&optional arg)
7346 "Select the unread article with the highest score.
7347 If given a prefix argument, select the next unread article that has a
7348 score higher than the default score."
7350 (let ((article (if arg
7351 (gnus-summary-better-unread-subject)
7352 (gnus-summary-best-unread-subject))))
7354 (gnus-summary-goto-article article)
7355 (error "No unread articles"))))
7357 (defun gnus-summary-best-unread-subject ()
7358 "Select the unread subject with the highest score."
7360 (let ((best -1000000)
7361 (data gnus-newsgroup-data)
7364 (and (gnus-data-unread-p (car data))
7366 (gnus-summary-article-score (gnus-data-number (car data))))
7369 article (gnus-data-number (car data))))
7370 (setq data (cdr data)))
7372 (gnus-summary-goto-subject article))
7373 (gnus-summary-position-point)
7376 (defun gnus-summary-better-unread-subject ()
7377 "Select the first unread subject that has a score over the default score."
7379 (let ((data gnus-newsgroup-data)
7381 (while (and (setq article (gnus-data-number (car data)))
7382 (or (gnus-data-read-p (car data))
7383 (not (> (gnus-summary-article-score article)
7384 gnus-summary-default-score))))
7385 (setq data (cdr data)))
7387 (gnus-summary-goto-subject article))
7388 (gnus-summary-position-point)
7391 (defun gnus-summary-last-subject ()
7392 "Go to the last displayed subject line in the group."
7393 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7395 (gnus-summary-goto-subject article))))
7397 (defun gnus-summary-goto-article (article &optional all-headers force)
7398 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7399 If ALL-HEADERS is non-nil, no header lines are hidden.
7400 If FORCE, go to the article even if it isn't displayed. If FORCE
7401 is a number, it is the line the article is to be displayed on."
7405 "Article number or Message-ID: "
7406 (mapcar (lambda (number) (list (int-to-string number)))
7407 gnus-newsgroup-limit))
7411 (if (and (stringp article)
7412 (string-match "@" article))
7413 (gnus-summary-refer-article article)
7414 (when (stringp article)
7415 (setq article (string-to-number article)))
7416 (if (gnus-summary-goto-subject article force)
7417 (gnus-summary-display-article article all-headers)
7418 (gnus-message 4 "Couldn't go to article %s" article) nil))
7419 (gnus-summary-position-point)))
7421 (defun gnus-summary-goto-last-article ()
7422 "Go to the previously read article."
7425 (when gnus-last-article
7426 (gnus-summary-goto-article gnus-last-article nil t))
7427 (gnus-summary-position-point)))
7429 (defun gnus-summary-pop-article (number)
7430 "Pop one article off the history and go to the previous.
7431 NUMBER articles will be popped off."
7434 (setq gnus-newsgroup-history
7435 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7437 (gnus-summary-goto-article (car to) nil t)
7438 (error "Article history empty")))
7439 (gnus-summary-position-point))
7441 ;; Summary commands and functions for limiting the summary buffer.
7443 (defun gnus-summary-limit-to-articles (n)
7444 "Limit the summary buffer to the next N articles.
7445 If not given a prefix, use the process marked articles instead."
7448 (let ((articles (gnus-summary-work-articles n)))
7449 (setq gnus-newsgroup-processable nil)
7450 (gnus-summary-limit articles))
7451 (gnus-summary-position-point)))
7453 (defun gnus-summary-pop-limit (&optional total)
7454 "Restore the previous limit.
7455 If given a prefix, remove all limits."
7458 (setq gnus-newsgroup-limits
7459 (list (mapcar (lambda (h) (mail-header-number h))
7460 gnus-newsgroup-headers))))
7461 (unless gnus-newsgroup-limits
7462 (error "No limit to pop"))
7464 (gnus-summary-limit nil 'pop)
7465 (gnus-summary-position-point)))
7467 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7468 "Limit the summary buffer to articles that have subjects that match a regexp.
7469 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7471 (list (read-string (if current-prefix-arg
7472 "Exclude subject (regexp): "
7473 "Limit to subject (regexp): "))
7474 nil current-prefix-arg))
7476 (setq header "subject"))
7477 (when (not (equal "" subject))
7479 (let ((articles (gnus-summary-find-matching
7480 (or header "subject") subject 'all nil nil
7483 (error "Found no matches for \"%s\"" subject))
7484 (gnus-summary-limit articles))
7485 (gnus-summary-position-point))))
7487 (defun gnus-summary-limit-to-author (from &optional not-matching)
7488 "Limit the summary buffer to articles that have authors that match a regexp.
7489 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7491 (list (read-string (if current-prefix-arg
7492 "Exclude author (regexp): "
7493 "Limit to author (regexp): "))
7494 current-prefix-arg))
7495 (gnus-summary-limit-to-subject from "from" not-matching))
7497 (defun gnus-summary-limit-to-age (age &optional younger-p)
7498 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7499 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7500 articles that are younger than AGE days."
7502 (let ((younger current-prefix-arg)
7505 (while (not days-got)
7506 (setq days (if younger
7507 (read-string "Limit to articles younger than (in days, older when negative): ")
7509 "Limit to articles older than (in days, younger when negative): ")))
7510 (when (> (length days) 0)
7511 (setq days (read days)))
7517 (setq younger (not younger))
7518 (setq days (* days -1)))))
7519 (message "Please enter a number.")
7521 (list days younger)))
7523 (let ((data gnus-newsgroup-data)
7524 (cutoff (days-to-time age))
7525 articles d date is-younger)
7526 (while (setq d (pop data))
7527 (when (and (vectorp (gnus-data-header d))
7528 (setq date (mail-header-date (gnus-data-header d))))
7529 (setq is-younger (time-less-p
7530 (time-since (condition-case ()
7537 (push (gnus-data-number d) articles))))
7538 (gnus-summary-limit (nreverse articles)))
7539 (gnus-summary-position-point)))
7541 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7542 "Limit the summary buffer to articles that match an 'extra' header."
7546 (gnus-completing-read-with-default
7547 (symbol-name (car gnus-extra-headers))
7548 (if current-prefix-arg
7549 "Exclude extra header:"
7550 "Limit extra header:")
7552 (cons (symbol-name x) x))
7557 (read-string (format "%s header %s (regexp): "
7558 (if current-prefix-arg "Exclude" "Limit to")
7560 current-prefix-arg)))
7561 (when (not (equal "" regexp))
7563 (let ((articles (gnus-summary-find-matching
7564 (cons 'extra header) regexp 'all nil nil
7567 (error "Found no matches for \"%s\"" regexp))
7568 (gnus-summary-limit articles))
7569 (gnus-summary-position-point))))
7571 (defun gnus-summary-limit-to-display-predicate ()
7572 "Limit the summary buffer to the predicated in the `display' group parameter."
7574 (unless gnus-newsgroup-display
7575 (error "There is no `display' group parameter"))
7577 (dolist (number gnus-newsgroup-articles)
7578 (when (funcall gnus-newsgroup-display)
7579 (push number articles)))
7580 (gnus-summary-limit articles))
7581 (gnus-summary-position-point))
7583 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7585 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7587 (defun gnus-summary-limit-to-unread (&optional all)
7588 "Limit the summary buffer to articles that are not marked as read.
7589 If ALL is non-nil, limit strictly to unread articles."
7592 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7593 (gnus-summary-limit-to-marks
7594 ;; Concat all the marks that say that an article is read and have
7596 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7597 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7598 gnus-low-score-mark gnus-expirable-mark
7599 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7600 gnus-duplicate-mark gnus-souped-mark)
7603 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7604 (make-obsolete 'gnus-summary-delete-marked-with
7605 'gnus-summary-limit-exclude-marks)
7607 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7608 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7609 If REVERSE, limit the summary buffer to articles that are marked
7610 with MARKS. MARKS can either be a string of marks or a list of marks.
7611 Returns how many articles were removed."
7612 (interactive "sMarks: ")
7613 (gnus-summary-limit-to-marks marks t))
7615 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7616 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7617 If REVERSE (the prefix), limit the summary buffer to articles that are
7618 not marked with MARKS. MARKS can either be a string of marks or a
7620 Returns how many articles were removed."
7621 (interactive "sMarks: \nP")
7623 (let ((data gnus-newsgroup-data)
7624 (marks (if (listp marks) marks
7625 (append marks nil))) ; Transform to list.
7628 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7629 (memq (gnus-data-mark (car data)) marks))
7630 (push (gnus-data-number (car data)) articles))
7631 (setq data (cdr data)))
7632 (gnus-summary-limit articles))
7633 (gnus-summary-position-point)))
7635 (defun gnus-summary-limit-to-score (score)
7636 "Limit to articles with score at or above SCORE."
7637 (interactive "NLimit to articles with score of at least: ")
7638 (let ((data gnus-newsgroup-data)
7641 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7643 (push (gnus-data-number (car data)) articles))
7644 (setq data (cdr data)))
7646 (gnus-summary-limit articles)
7647 (gnus-summary-position-point))))
7649 (defun gnus-summary-limit-to-unseen ()
7650 "Limit to unseen articles."
7653 (gnus-summary-limit gnus-newsgroup-unseen)
7654 (gnus-summary-position-point)))
7656 (defun gnus-summary-limit-include-thread (id)
7657 "Display all the hidden articles that is in the thread with ID in it.
7658 When called interactively, ID is the Message-ID of the current
7660 (interactive (list (mail-header-id (gnus-summary-article-header))))
7661 (let ((articles (gnus-articles-in-thread
7662 (gnus-id-to-thread (gnus-root-id id)))))
7664 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7665 (gnus-summary-limit-include-matching-articles
7667 (regexp-quote (gnus-simplify-subject-re
7668 (mail-header-subject (gnus-id-to-header id)))))
7669 (gnus-summary-position-point))))
7671 (defun gnus-summary-limit-include-matching-articles (header regexp)
7672 "Display all the hidden articles that have HEADERs that match REGEXP."
7673 (interactive (list (read-string "Match on header: ")
7674 (read-string "Regexp: ")))
7675 (let ((articles (gnus-find-matching-articles header regexp)))
7677 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7678 (gnus-summary-position-point))))
7680 (defun gnus-summary-insert-dormant-articles ()
7681 "Insert all the dormat articles for this group into the current buffer."
7683 (let ((gnus-verbose (max 6 gnus-verbose)))
7684 (if (not gnus-newsgroup-dormant)
7685 (gnus-message 3 "No cached articles for this group")
7686 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7688 (defun gnus-summary-limit-include-dormant ()
7689 "Display all the hidden articles that are marked as dormant.
7690 Note that this command only works on a subset of the articles currently
7691 fetched for this group."
7693 (unless gnus-newsgroup-dormant
7694 (error "There are no dormant articles in this group"))
7696 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7697 (gnus-summary-position-point)))
7699 (defun gnus-summary-limit-exclude-dormant ()
7700 "Hide all dormant articles."
7703 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7704 (gnus-summary-position-point)))
7706 (defun gnus-summary-limit-exclude-childless-dormant ()
7707 "Hide all dormant articles that have no children."
7709 (let ((data (gnus-data-list t))
7710 articles d children)
7711 ;; Find all articles that are either not dormant or have
7713 (while (setq d (pop data))
7714 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7716 (gnus-article-children (gnus-data-number d)))
7719 (when (memq (car children) articles)
7724 (push (gnus-data-number d) articles)))
7727 (gnus-summary-limit articles)
7728 (gnus-summary-position-point))))
7730 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7731 "Mark all unread excluded articles as read.
7732 If ALL, mark even excluded ticked and dormants as read."
7734 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7735 (let ((articles (gnus-sorted-ndifference
7737 (mapcar (lambda (h) (mail-header-number h))
7738 gnus-newsgroup-headers)
7740 gnus-newsgroup-limit))
7742 (setq gnus-newsgroup-unreads
7743 (gnus-sorted-intersection gnus-newsgroup-unreads
7744 gnus-newsgroup-limit))
7746 (setq gnus-newsgroup-dormant nil
7747 gnus-newsgroup-marked nil
7748 gnus-newsgroup-reads
7750 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7751 gnus-newsgroup-reads))
7752 (while (setq article (pop articles))
7753 (unless (or (memq article gnus-newsgroup-dormant)
7754 (memq article gnus-newsgroup-marked))
7755 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7757 (defun gnus-summary-limit (articles &optional pop)
7759 ;; We pop the previous limit off the stack and use that.
7760 (setq articles (car gnus-newsgroup-limits)
7761 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7762 ;; We use the new limit, so we push the old limit on the stack.
7763 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7765 (setq gnus-newsgroup-limit articles)
7766 (let ((total (length gnus-newsgroup-data))
7767 (data (gnus-data-find-list (gnus-summary-article-number)))
7768 (gnus-summary-mark-below nil) ; Inhibit this.
7770 ;; This will do all the work of generating the new summary buffer
7771 ;; according to the new limit.
7772 (gnus-summary-prepare)
7773 ;; Hide any threads, possibly.
7774 (gnus-summary-maybe-hide-threads)
7775 ;; Try to return to the article you were at, or one in the
7778 ;; We try to find some article after the current one.
7780 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7783 (setq data (cdr data))))
7785 ;; If there is no data, that means that we were after the last
7786 ;; article. The same goes when we can't find any articles
7787 ;; after the current one.
7788 (goto-char (point-max))
7789 (gnus-summary-find-prev))
7790 (gnus-set-mode-line 'summary)
7791 ;; We return how many articles were removed from the summary
7792 ;; buffer as a result of the new limit.
7793 (- total (length gnus-newsgroup-data))))
7795 (defsubst gnus-invisible-cut-children (threads)
7798 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7803 (defsubst gnus-cut-thread (thread)
7804 "Go forwards in the thread until we find an article that we want to display."
7805 (when (or (eq gnus-fetch-old-headers 'some)
7806 (eq gnus-fetch-old-headers 'invisible)
7807 (numberp gnus-fetch-old-headers)
7808 (eq gnus-build-sparse-threads 'some)
7809 (eq gnus-build-sparse-threads 'more))
7810 ;; Deal with old-fetched headers and sparse threads.
7814 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7815 (gnus-summary-article-ancient-p
7816 (mail-header-number (car thread))))
7817 (if (or (<= (length (cdr thread)) 1)
7818 (eq gnus-fetch-old-headers 'invisible))
7819 (setq gnus-newsgroup-limit
7820 (delq (mail-header-number (car thread))
7821 gnus-newsgroup-limit)
7822 thread (cadr thread))
7823 (when (gnus-invisible-cut-children (cdr thread))
7824 (let ((th (cdr thread)))
7826 (if (memq (mail-header-number (caar th))
7827 gnus-newsgroup-limit)
7828 (setq thread (car th)
7830 (setq th (cdr th))))))))))
7833 (defun gnus-cut-threads (threads)
7834 "Cut off all uninteresting articles from the beginning of threads."
7835 (when (or (eq gnus-fetch-old-headers 'some)
7836 (eq gnus-fetch-old-headers 'invisible)
7837 (numberp gnus-fetch-old-headers)
7838 (eq gnus-build-sparse-threads 'some)
7839 (eq gnus-build-sparse-threads 'more))
7842 (setcar th (gnus-cut-thread (car th)))
7843 (setq th (cdr th)))))
7844 ;; Remove nixed out threads.
7847 (defun gnus-summary-initial-limit (&optional show-if-empty)
7848 "Figure out what the initial limit is supposed to be on group entry.
7849 This entails weeding out unwanted dormants, low-scored articles,
7850 fetch-old-headers verbiage, and so on."
7851 ;; Most groups have nothing to remove.
7852 (if (or gnus-inhibit-limiting
7853 (and (null gnus-newsgroup-dormant)
7854 (eq gnus-newsgroup-display 'gnus-not-ignore)
7855 (not (eq gnus-fetch-old-headers 'some))
7856 (not (numberp gnus-fetch-old-headers))
7857 (not (eq gnus-fetch-old-headers 'invisible))
7858 (null gnus-summary-expunge-below)
7859 (not (eq gnus-build-sparse-threads 'some))
7860 (not (eq gnus-build-sparse-threads 'more))
7861 (null gnus-thread-expunge-below)
7862 (not gnus-use-nocem)))
7864 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7865 (setq gnus-newsgroup-limit nil)
7868 (unless (car (symbol-value node))
7869 ;; These threads have no parents -- they are roots.
7870 (let ((nodes (cdr (symbol-value node)))
7873 (if (and gnus-thread-expunge-below
7874 (< (gnus-thread-total-score (car nodes))
7875 gnus-thread-expunge-below))
7876 (gnus-expunge-thread (pop nodes))
7877 (setq thread (pop nodes))
7878 (gnus-summary-limit-children thread))))))
7879 gnus-newsgroup-dependencies)
7880 ;; If this limitation resulted in an empty group, we might
7881 ;; pop the previous limit and use it instead.
7882 (when (and (not gnus-newsgroup-limit)
7884 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7885 gnus-newsgroup-limit))
7887 (defun gnus-summary-limit-children (thread)
7888 "Return 1 if this subthread is visible and 0 if it is not."
7889 ;; First we get the number of visible children to this thread. This
7890 ;; is done by recursing down the thread using this function, so this
7891 ;; will really go down to a leaf article first, before slowly
7892 ;; working its way up towards the root.
7894 (let* ((max-lisp-eval-depth 5000)
7897 (apply '+ (mapcar 'gnus-summary-limit-children
7900 (number (mail-header-number (car thread)))
7903 (not (memq number gnus-newsgroup-marked))
7905 ;; If this article is dormant and has absolutely no visible
7906 ;; children, then this article isn't visible.
7907 (and (memq number gnus-newsgroup-dormant)
7909 ;; If this is "fetch-old-headered" and there is no
7910 ;; visible children, then we don't want this article.
7911 (and (or (eq gnus-fetch-old-headers 'some)
7912 (numberp gnus-fetch-old-headers))
7913 (gnus-summary-article-ancient-p number)
7915 ;; If this is "fetch-old-headered" and `invisible', then
7916 ;; we don't want this article.
7917 (and (eq gnus-fetch-old-headers 'invisible)
7918 (gnus-summary-article-ancient-p number))
7919 ;; If this is a sparsely inserted article with no children,
7920 ;; we don't want it.
7921 (and (eq gnus-build-sparse-threads 'some)
7922 (gnus-summary-article-sparse-p number)
7924 ;; If we use expunging, and this article is really
7925 ;; low-scored, then we don't want this article.
7926 (when (and gnus-summary-expunge-below
7928 (or (cdr (assq number gnus-newsgroup-scored))
7929 gnus-summary-default-score))
7930 gnus-summary-expunge-below))
7931 ;; We increase the expunge-tally here, but that has
7932 ;; nothing to do with the limits, really.
7933 (incf gnus-newsgroup-expunged-tally)
7934 ;; We also mark as read here, if that's wanted.
7935 (when (and gnus-summary-mark-below
7936 (< score gnus-summary-mark-below))
7937 (setq gnus-newsgroup-unreads
7938 (delq number gnus-newsgroup-unreads))
7939 (if gnus-newsgroup-auto-expire
7940 (push number gnus-newsgroup-expirable)
7941 (push (cons number gnus-low-score-mark)
7942 gnus-newsgroup-reads)))
7944 ;; Do the `display' group parameter.
7945 (and gnus-newsgroup-display
7946 (not (funcall gnus-newsgroup-display)))
7947 ;; Check NoCeM things.
7948 (if (and gnus-use-nocem
7949 (gnus-nocem-unwanted-article-p
7950 (mail-header-id (car thread))))
7952 (setq gnus-newsgroup-unreads
7953 (delq number gnus-newsgroup-unreads))
7955 ;; Nope, invisible article.
7957 ;; Ok, this article is to be visible, so we add it to the limit
7959 (push number gnus-newsgroup-limit)
7962 (defun gnus-expunge-thread (thread)
7963 "Mark all articles in THREAD as read."
7964 (let* ((number (mail-header-number (car thread))))
7965 (incf gnus-newsgroup-expunged-tally)
7966 ;; We also mark as read here, if that's wanted.
7967 (setq gnus-newsgroup-unreads
7968 (delq number gnus-newsgroup-unreads))
7969 (if gnus-newsgroup-auto-expire
7970 (push number gnus-newsgroup-expirable)
7971 (push (cons number gnus-low-score-mark)
7972 gnus-newsgroup-reads)))
7973 ;; Go recursively through all subthreads.
7974 (mapcar 'gnus-expunge-thread (cdr thread)))
7976 ;; Summary article oriented commands
7978 (defun gnus-summary-refer-parent-article (n)
7979 "Refer parent article N times.
7980 If N is negative, go to ancestor -N instead.
7981 The difference between N and the number of articles fetched is returned."
7985 (when (not (natnump n))
7990 (setq header (gnus-summary-article-header))
7991 (if (and (eq (mail-header-number header)
7992 (cdr gnus-article-current))
7993 (equal gnus-newsgroup-name
7994 (car gnus-article-current)))
7995 ;; If we try to find the parent of the currently
7996 ;; displayed article, then we take a look at the actual
7997 ;; References header, since this is slightly more
7998 ;; reliable than the References field we got from the
8001 (set-buffer gnus-original-article-buffer)
8002 (nnheader-narrow-to-headers)
8003 (unless (setq ref (message-fetch-field "references"))
8004 (setq ref (message-fetch-field "in-reply-to")))
8007 ;; It's not the current article, so we take a bet on
8008 ;; the value we got from the server.
8009 (mail-header-references header)))
8011 (not (equal ref "")))
8012 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8013 (gnus-message 1 "Couldn't find parent"))
8014 (gnus-message 1 "No references in article %d"
8015 (gnus-summary-article-number))
8018 (gnus-summary-position-point)
8021 (defun gnus-summary-refer-references ()
8022 "Fetch all articles mentioned in the References header.
8023 Return the number of articles fetched."
8025 (let ((ref (mail-header-references (gnus-summary-article-header)))
8026 (current (gnus-summary-article-number))
8030 (error "No References in the current article")
8031 ;; For each Message-ID in the References header...
8032 (while (string-match "<[^>]*>" ref)
8034 ;; ... fetch that article.
8035 (gnus-summary-refer-article
8036 (prog1 (match-string 0 ref)
8037 (setq ref (substring ref (match-end 0))))))
8038 (gnus-summary-goto-subject current)
8039 (gnus-summary-position-point)
8042 (defun gnus-summary-refer-thread (&optional limit)
8043 "Fetch all articles in the current thread.
8044 If LIMIT (the numerical prefix), fetch that many old headers instead
8045 of what's specified by the `gnus-refer-thread-limit' variable."
8047 (let ((id (mail-header-id (gnus-summary-article-header)))
8048 (limit (if limit (prefix-numeric-value limit)
8049 gnus-refer-thread-limit)))
8050 (unless (eq gnus-fetch-old-headers 'invisible)
8051 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8052 ;; Retrieve the headers and read them in.
8053 (if (eq (if (numberp limit)
8054 (gnus-retrieve-headers
8056 (+ (mail-header-number
8057 (gnus-summary-article-header))
8059 gnus-newsgroup-end))
8060 gnus-newsgroup-name (* limit 2))
8061 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8063 (gnus-retrieve-headers (list gnus-newsgroup-end)
8064 gnus-newsgroup-name limit))
8066 (gnus-build-all-threads)
8067 (error "Can't fetch thread from backends that don't support NOV"))
8068 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8069 (gnus-summary-limit-include-thread id)))
8071 (defun gnus-summary-refer-article (message-id)
8072 "Fetch an article specified by MESSAGE-ID."
8073 (interactive "sMessage-ID: ")
8074 (when (and (stringp message-id)
8075 (not (zerop (length message-id))))
8076 ;; Construct the correct Message-ID if necessary.
8077 ;; Suggested by tale@pawl.rpi.edu.
8078 (unless (string-match "^<" message-id)
8079 (setq message-id (concat "<" message-id)))
8080 (unless (string-match ">$" message-id)
8081 (setq message-id (concat message-id ">")))
8082 (let* ((header (gnus-id-to-header message-id))
8084 (gnus-summary-article-sparse-p
8085 (mail-header-number header))
8086 (memq (mail-header-number header)
8087 gnus-newsgroup-limit)))
8090 ;; If the article is present in the buffer we just go to it.
8092 (or (not (gnus-summary-article-sparse-p
8093 (mail-header-number header)))
8096 (gnus-summary-goto-article
8097 (mail-header-number header) nil t)
8099 (gnus-summary-update-article (mail-header-number header)))))
8101 ;; We fetch the article.
8103 (dolist (gnus-override-method (gnus-refer-article-methods))
8104 (when (and (gnus-check-server gnus-override-method)
8105 ;; Fetch the header,
8106 (setq number (gnus-summary-insert-subject message-id)))
8107 ;; and display the article.
8108 (gnus-summary-select-article nil nil nil number)
8110 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8112 (defun gnus-refer-article-methods ()
8113 "Return a list of referable methods."
8115 ;; No method, so we default to current and native.
8116 ((null gnus-refer-article-method)
8117 (list gnus-current-select-method gnus-select-method))
8119 ((eq 'current gnus-refer-article-method)
8120 (list gnus-current-select-method))
8121 ;; List of select methods.
8122 ((not (and (symbolp (car gnus-refer-article-method))
8123 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8125 (dolist (method gnus-refer-article-method)
8126 (push (if (eq 'current method)
8127 gnus-current-select-method
8131 ;; One single select method.
8133 (list gnus-refer-article-method))))
8135 (defun gnus-summary-edit-parameters ()
8136 "Edit the group parameters of the current group."
8138 (gnus-group-edit-group gnus-newsgroup-name 'params))
8140 (defun gnus-summary-customize-parameters ()
8141 "Customize the group parameters of the current group."
8143 (gnus-group-customize gnus-newsgroup-name))
8145 (defun gnus-summary-enter-digest-group (&optional force)
8146 "Enter an nndoc group based on the current article.
8147 If FORCE, force a digest interpretation. If not, try
8148 to guess what the document format is."
8150 (let ((conf gnus-current-window-configuration))
8152 (gnus-summary-select-article))
8153 (setq gnus-current-window-configuration conf)
8154 (let* ((name (format "%s-%d"
8155 (gnus-group-prefixed-name
8156 gnus-newsgroup-name (list 'nndoc ""))
8158 (set-buffer gnus-summary-buffer)
8159 gnus-current-article)))
8160 (ogroup gnus-newsgroup-name)
8161 (params (append (gnus-info-params (gnus-get-info ogroup))
8162 (list (cons 'to-group ogroup))
8163 (list (cons 'save-article-group ogroup))))
8164 (case-fold-search t)
8165 (buf (current-buffer))
8168 (set-buffer gnus-original-article-buffer)
8169 ;; Have the digest group inherit the main mail address of
8170 ;; the parent article.
8171 (when (setq to-address (or (gnus-fetch-field "reply-to")
8172 (gnus-fetch-field "from")))
8173 (setq params (append
8174 (list (cons 'to-address
8175 (funcall gnus-decode-encoded-word-function
8177 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8178 (insert-buffer-substring gnus-original-article-buffer)
8179 ;; Remove lines that may lead nndoc to misinterpret the
8182 (goto-char (point-min))
8183 (or (search-forward "\n\n" nil t) (point)))
8184 (goto-char (point-min))
8185 (delete-matching-lines "^Path:\\|^From ")
8188 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8189 (gnus-newsgroup-ephemeral-ignored-charsets
8190 gnus-newsgroup-ignored-charsets))
8191 (gnus-group-read-ephemeral-group
8192 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8194 ,(if force 'mbox 'guess)))
8196 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8198 ;; Make all postings to this group go to the parent group.
8199 (nconc (gnus-info-params (gnus-get-info name))
8201 ;; Couldn't select this doc group.
8202 (switch-to-buffer buf)
8203 (gnus-set-global-variables)
8204 (gnus-configure-windows 'summary)
8205 (gnus-message 3 "Article couldn't be entered?"))
8206 (kill-buffer dig)))))
8208 (defun gnus-summary-read-document (n)
8209 "Open a new group based on the current article(s).
8210 This will allow you to read digests and other similar
8211 documents as newsgroups.
8212 Obeys the standard process/prefix convention."
8214 (let* ((articles (gnus-summary-work-articles n))
8215 (ogroup gnus-newsgroup-name)
8216 (params (append (gnus-info-params (gnus-get-info ogroup))
8217 (list (cons 'to-group ogroup))))
8218 article group egroup groups vgroup)
8219 (while (setq article (pop articles))
8220 (setq group (format "%s-%d" gnus-newsgroup-name article))
8221 (gnus-summary-remove-process-mark article)
8222 (when (gnus-summary-display-article article)
8225 (insert-buffer-substring gnus-original-article-buffer)
8226 ;; Remove some headers that may lead nndoc to make
8228 (message-narrow-to-head)
8229 (goto-char (point-min))
8230 (delete-matching-lines "^\\(Path\\):\\|^From ")
8233 (gnus-group-read-ephemeral-group
8234 group `(nndoc ,group (nndoc-address ,(current-buffer))
8235 (nndoc-article-type guess))
8238 ;; Make all postings to this group go to the parent group.
8239 (nconc (gnus-info-params (gnus-get-info egroup))
8241 (push egroup groups))
8242 ;; Couldn't select this doc group.
8243 (gnus-error 3 "Article couldn't be entered"))))))
8244 ;; Now we have selected all the documents.
8247 (error "None of the articles could be interpreted as documents"))
8248 ((gnus-group-read-ephemeral-group
8249 (setq vgroup (format
8250 "nnvirtual:%s-%s" gnus-newsgroup-name
8251 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8252 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8254 (cons (current-buffer) 'summary)))
8256 (error "Couldn't select virtual nndoc group")))))
8258 (defun gnus-summary-isearch-article (&optional regexp-p)
8259 "Do incremental search forward on the current article.
8260 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8262 (let* ((gnus-inhibit-treatment t)
8263 (old (gnus-summary-select-article)))
8264 (gnus-configure-windows 'article)
8265 (gnus-eval-in-buffer-window gnus-article-buffer
8269 (gnus-article-show-all-headers))
8270 (goto-char (point-min))
8271 (isearch-forward regexp-p)))))
8273 (defun gnus-summary-search-article-forward (regexp &optional backward)
8274 "Search for an article containing REGEXP forward.
8275 If BACKWARD, search backward instead."
8278 (format "Search article %s (regexp%s): "
8279 (if current-prefix-arg "backward" "forward")
8280 (if gnus-last-search-regexp
8281 (concat ", default " gnus-last-search-regexp)
8283 current-prefix-arg))
8284 (if (string-equal regexp "")
8285 (setq regexp (or gnus-last-search-regexp ""))
8286 (setq gnus-last-search-regexp regexp)
8287 (setq gnus-article-before-search gnus-current-article))
8288 ;; Intentionally set gnus-last-article.
8289 (setq gnus-last-article gnus-article-before-search)
8290 (let ((gnus-last-article gnus-last-article))
8291 (if (gnus-summary-search-article regexp backward)
8292 (gnus-summary-show-thread)
8293 (error "Search failed: \"%s\"" regexp))))
8295 (defun gnus-summary-search-article-backward (regexp)
8296 "Search for an article containing REGEXP backward."
8299 (format "Search article backward (regexp%s): "
8300 (if gnus-last-search-regexp
8301 (concat ", default " gnus-last-search-regexp)
8303 (gnus-summary-search-article-forward regexp 'backward))
8306 (defmacro gnus-summary-search-article-position-point (regexp backward)
8307 "Dehighlight the last matched text and goto the beginning position."
8308 (` (if (and gnus-summary-search-article-matched-data
8309 (let ((text (caddr gnus-summary-search-article-matched-data))
8310 (inhibit-read-only t)
8313 (goto-char (car gnus-summary-search-article-matched-data))
8314 (cadr gnus-summary-search-article-matched-data))
8316 (string-match (, regexp) text)))
8317 (if (, backward) (beginning-of-line) (end-of-line))
8318 (goto-char (if (, backward) (point-max) (point-min))))))
8320 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8321 "Place point where X-Face image is displayed."
8322 (if (featurep 'xemacs)
8323 (` (let ((end (if (search-forward "\n\n" nil t)
8324 (goto-char (1- (point)))
8327 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8328 (unless (and (re-search-forward "^From:" end t)
8329 (setq extent (extent-at (point)))
8330 (extent-begin-glyph extent))
8331 (goto-char (, opoint)))))
8332 (` (let ((end (if (search-forward "\n\n" nil t)
8333 (goto-char (1- (point)))
8335 (start (or (search-backward "\n\n" nil t) (point-min))))
8337 (or (text-property-any start end 'x-face-image t);; x-face-e21
8338 (text-property-any start end 'x-face-mule-bitmap-image t)
8341 (defmacro gnus-summary-search-article-highlight-matched-text
8342 (backward treated x-face)
8343 "Highlight matched text in the function `gnus-summary-search-article'."
8344 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8345 (end (set-marker (make-marker) (match-end 0)))
8346 (inhibit-read-only t)
8350 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8352 (lambda (item) (setq items (delq item items)))
8353 '(gnus-treat-buttonize
8354 gnus-treat-fill-article
8355 gnus-treat-fill-long-lines
8356 gnus-treat-emphasize
8357 gnus-treat-highlight-headers
8358 gnus-treat-highlight-citation
8359 gnus-treat-highlight-signature
8360 gnus-treat-overstrike
8361 gnus-treat-display-xface
8362 gnus-treat-buttonize-head
8363 gnus-treat-decode-article-as-default-mime-charset))
8364 (static-if (featurep 'xemacs)
8366 (cons '(x-face-mule-delete-x-face-field
8369 (gnus-treat-display-xface
8370 (when (, x-face) gnus-treat-display-xface)))
8371 (gnus-article-prepare-mime-display)))
8372 (goto-char (if (, backward) start end))
8374 (gnus-summary-search-article-highlight-goto-x-face (point)))
8375 (setq gnus-summary-search-article-matched-data
8376 (list start end (buffer-substring start end)))
8377 (unless (eq start end);; matched text has been deleted. :-<
8378 (put-text-property start end 'face
8379 (or (find-face 'isearch)
8380 'secondary-selection))))))
8383 (defun gnus-summary-search-article (regexp &optional backward)
8384 "Search for an article containing REGEXP.
8385 Optional argument BACKWARD means do search for backward.
8386 `gnus-select-article-hook' is not called during the search."
8387 ;; We have to require this here to make sure that the following
8388 ;; dynamic binding isn't shadowed by autoloading.
8389 (require 'gnus-async)
8391 (let ((gnus-select-article-hook nil) ;Disable hook.
8392 (gnus-article-prepare-hook nil)
8393 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8394 (gnus-use-article-prefetch nil)
8395 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8396 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8398 (gnus-keep-backlog nil)
8399 (gnus-break-pages nil)
8400 (gnus-summary-display-arrow nil)
8401 (gnus-updated-mode-lines nil)
8402 (gnus-auto-center-summary nil)
8403 (sum (current-buffer))
8406 (gnus-save-hidden-threads
8407 (static-if (featurep 'xemacs)
8408 (let ((gnus-inhibit-treatment t))
8409 (setq treated (eq 'old (gnus-summary-select-article)))
8411 (not (and (gnus-buffer-live-p gnus-article-buffer)
8412 (window-live-p (get-buffer-window
8413 gnus-article-buffer t)))))
8414 (gnus-summary-select-article nil t)
8415 (setq treated nil)))
8416 (let ((gnus-inhibit-treatment t)
8417 (x-face-mule-delete-x-face-field 'never))
8418 (setq treated (eq 'old (gnus-summary-select-article)))
8421 (and (gnus-buffer-live-p gnus-article-buffer)
8422 (window-live-p (get-buffer-window
8423 gnus-article-buffer t))
8424 (or (not (string-match "^\\^X-Face:" regexp))
8425 (with-current-buffer gnus-article-buffer
8426 gnus-summary-search-article-matched-data)))))
8427 (gnus-summary-select-article nil t)
8428 (setq treated nil))))
8429 (set-buffer gnus-article-buffer)
8433 (gnus-article-show-all-headers)
8434 (gnus-summary-search-article-position-point regexp backward))
8435 (goto-char (if backward (point-max) (point-min))))
8437 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8439 (re-search-backward regexp nil t)
8440 (re-search-forward regexp nil t))
8441 ;; We found the regexp.
8443 (gnus-summary-search-article-highlight-matched-text
8444 backward treated (string-match "^\\^X-Face:" regexp))
8447 (/ (- 2 (window-height
8448 (get-buffer-window gnus-article-buffer t)))
8451 (get-buffer-window (current-buffer))
8454 (setq point (point)))
8455 ;; We didn't find it, so we go to the next article.
8458 (while (eq found 'not)
8459 (if (not (if backward (gnus-summary-find-prev)
8460 (gnus-summary-find-next)))
8461 ;; No more articles.
8463 ;; Select the next article and adjust point.
8464 (unless (gnus-summary-article-sparse-p
8465 (gnus-summary-article-number))
8467 (let ((gnus-inhibit-treatment t))
8468 (gnus-summary-select-article))
8470 (set-buffer gnus-article-buffer)
8472 (goto-char (if backward (point-max) (point-min))))))))
8473 (gnus-message 7 ""))
8474 ;; Return whether we found the regexp.
8475 (when (eq found 'found)
8477 (gnus-summary-show-thread)
8478 (gnus-summary-goto-subject gnus-current-article)
8479 (gnus-summary-position-point)
8482 (defun gnus-find-matching-articles (header regexp)
8483 "Return a list of all articles that match REGEXP on HEADER.
8484 This search includes all articles in the current group that Gnus has
8485 fetched headers for, whether they are displayed or not."
8486 (let ((articles nil)
8487 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8488 (case-fold-search t))
8489 (dolist (header gnus-newsgroup-headers)
8490 (when (string-match regexp (funcall func header))
8491 (push (mail-header-number header) articles)))
8492 (nreverse articles)))
8494 (defun gnus-summary-find-matching (header regexp &optional backward unread
8495 not-case-fold not-matching)
8496 "Return a list of all articles that match REGEXP on HEADER.
8497 The search stars on the current article and goes forwards unless
8498 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8499 If UNREAD is non-nil, only unread articles will
8500 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8501 in the comparisons. If NOT-MATCHING, return a list of all articles that
8502 not match REGEXP on HEADER."
8503 (let ((case-fold-search (not not-case-fold))
8506 (if (eq (car header) 'extra)
8509 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8511 (error "%s is an invalid header" header))
8512 (unless (fboundp (intern (concat "mail-header-" header)))
8513 (error "%s is not a valid header" header))
8514 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8515 (dolist (d (if (eq backward 'all)
8517 (gnus-data-find-list
8518 (gnus-summary-article-number)
8519 (gnus-data-list backward))))
8520 (when (and (or (not unread) ; We want all articles...
8521 (gnus-data-unread-p d)) ; Or just unreads.
8522 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8526 (funcall func (gnus-data-header d))))
8527 (string-match regexp
8528 (funcall func (gnus-data-header d)))))
8529 (push (gnus-data-number d) articles))) ; Success!
8530 (nreverse articles)))
8532 (defun gnus-summary-execute-command (header regexp command &optional backward)
8533 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8534 If HEADER is an empty string (or nil), the match is done on the entire
8535 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8537 (list (let ((completion-ignore-case t))
8540 (mapcar (lambda (header) (list (format "%s" header)))
8542 '("Number" "Subject" "From" "Lines" "Date"
8543 "Message-ID" "Xref" "References" "Body")
8544 gnus-extra-headers))
8545 nil 'require-match))
8546 (read-string "Regexp: ")
8547 (read-key-sequence "Command: ")
8548 current-prefix-arg))
8549 (when (equal header "Body")
8551 ;; Hidden thread subtrees must be searched as well.
8552 (gnus-summary-show-all-threads)
8553 ;; We don't want to change current point nor window configuration.
8555 (save-window-excursion
8557 gnus-treat-strip-trailing-blank-lines
8558 gnus-treat-strip-leading-blank-lines
8559 gnus-treat-strip-multiple-blank-lines
8560 gnus-treat-hide-boring-headers
8561 gnus-treat-fold-newsgroups
8562 gnus-article-prepare-hook)
8563 (gnus-message 6 "Executing %s..." (key-description command))
8564 ;; We'd like to execute COMMAND interactively so as to give arguments.
8565 (gnus-execute header regexp
8566 `(call-interactively ',(key-binding command))
8568 (gnus-message 6 "Executing %s...done" (key-description command))))))
8570 (defun gnus-summary-beginning-of-article ()
8571 "Scroll the article back to the beginning."
8573 (gnus-summary-select-article)
8574 (gnus-configure-windows 'article)
8575 (gnus-eval-in-buffer-window gnus-article-buffer
8577 (goto-char (point-min))
8578 (when gnus-page-broken
8579 (gnus-narrow-to-page))))
8581 (defun gnus-summary-end-of-article ()
8582 "Scroll to the end of the article."
8584 (gnus-summary-select-article)
8585 (gnus-configure-windows 'article)
8586 (gnus-eval-in-buffer-window gnus-article-buffer
8588 (goto-char (point-max))
8590 (when gnus-page-broken
8591 (gnus-narrow-to-page))))
8593 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8594 "Truncate to LEN and quote all \"(\"'s in STRING."
8595 (gnus-replace-in-string (if (and len (> (length string) len))
8596 (substring string 0 len)
8600 (defun gnus-summary-print-article (&optional filename n)
8601 "Generate and print a PostScript image of the N next (mail) articles.
8603 If N is negative, print the N previous articles. If N is nil and articles
8604 have been marked with the process mark, print these instead.
8606 If the optional first argument FILENAME is nil, send the image to the
8607 printer. If FILENAME is a string, save the PostScript image in a file with
8608 that name. If FILENAME is a number, prompt the user for the name of the file
8610 (interactive (list (ps-print-preprint current-prefix-arg)))
8611 (dolist (article (gnus-summary-work-articles n))
8612 (gnus-summary-select-article nil nil 'pseudo article)
8613 (gnus-eval-in-buffer-window gnus-article-buffer
8614 (gnus-print-buffer))
8615 (gnus-summary-remove-process-mark article))
8616 (ps-despool filename))
8618 (defun gnus-print-buffer ()
8619 (let ((buffer (generate-new-buffer " *print*")))
8622 (copy-to-buffer buffer (point-min) (point-max))
8624 (gnus-article-delete-invisible-text)
8625 (gnus-remove-text-with-property 'gnus-decoration)
8626 (when (gnus-visual-p 'article-highlight 'highlight)
8627 ;; Copy-to-buffer doesn't copy overlay. So redo
8629 (let ((gnus-article-buffer buffer))
8630 (gnus-article-highlight-citation t)
8631 (gnus-article-highlight-signature)))
8632 (let ((ps-left-header
8635 (gnus-summary-print-truncate-and-quote
8636 (mail-header-subject gnus-current-headers)
8639 (gnus-summary-print-truncate-and-quote
8640 (mail-header-from gnus-current-headers)
8644 "/pagenumberstring load"
8646 (mail-header-date gnus-current-headers) ")"))))
8647 (gnus-run-hooks 'gnus-ps-print-hook)
8650 (ps-spool-buffer-with-faces)
8651 (ps-spool-buffer)))))
8652 (kill-buffer buffer))))
8654 (defun gnus-summary-show-article (&optional arg)
8655 "Force redisplaying of the current article.
8656 If ARG (the prefix) is a number, show the article with the charset
8657 defined in `gnus-summary-show-article-charset-alist', or the charset
8659 If ARG (the prefix) is non-nil and not a number, show the raw article
8660 without any article massaging functions being run. Normally, the key
8661 strokes are `C-u g'."
8665 (gnus-summary-show-article t)
8666 (let* ((gnus-newsgroup-charset
8667 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8668 (mm-read-coding-system
8669 "View as charset: " ;; actually it is coding system.
8671 (set-buffer gnus-article-buffer)
8672 (mm-detect-coding-region (point) (point-max))))))
8673 (default-mime-charset gnus-newsgroup-charset)
8674 (gnus-newsgroup-ignored-charsets 'gnus-all))
8675 (gnus-summary-select-article nil 'force)
8676 (let ((deps gnus-newsgroup-dependencies)
8679 (set-buffer gnus-original-article-buffer)
8681 (message-narrow-to-head)
8682 (setq head (buffer-string))
8683 (goto-char (point-min))
8684 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8685 (goto-char (point-max))
8687 (setq lines (1- (count-lines (point) (point-max))))))
8689 (insert (format "211 %d Article retrieved.\n"
8690 (cdr gnus-article-current)))
8692 (if lines (insert (format "Lines: %d\n" lines)))
8694 (let ((nntp-server-buffer (current-buffer)))
8695 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8696 (gnus-data-set-header
8697 (gnus-data-find (cdr gnus-article-current))
8699 (gnus-summary-update-article-line
8700 (cdr gnus-article-current) header)
8701 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8702 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8704 ;; Select the article the normal way.
8705 (gnus-summary-select-article nil 'force))
8707 ;; We have to require this here to make sure that the following
8708 ;; dynamic binding isn't shadowed by autoloading.
8709 (require 'gnus-async)
8711 ;; Bind the article treatment functions to nil.
8712 (let ((gnus-have-all-headers t)
8713 gnus-article-prepare-hook
8714 gnus-article-decode-hook
8717 (gnus-inhibit-treatment t))
8718 (gnus-summary-select-article nil 'force))))
8719 (gnus-summary-goto-subject gnus-current-article)
8720 (gnus-summary-position-point))
8722 (defun gnus-summary-show-raw-article ()
8723 "Show the raw article without any article massaging functions being run."
8725 (gnus-summary-show-article t))
8727 (defun gnus-summary-verbose-headers (&optional arg)
8728 "Toggle permanent full header display.
8729 If ARG is a positive number, turn header display on.
8730 If ARG is a negative number, turn header display off."
8732 (setq gnus-show-all-headers
8733 (cond ((or (not (numberp arg))
8735 (not gnus-show-all-headers))
8738 (gnus-summary-show-article))
8740 (defun gnus-summary-toggle-header (&optional arg)
8741 "Show the headers if they are hidden, or hide them if they are shown.
8742 If ARG is a positive number, show the entire header.
8743 If ARG is a negative number, hide the unwanted header lines."
8745 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8746 (get-buffer-window gnus-article-buffer t))))
8747 (with-current-buffer gnus-article-buffer
8749 (article-narrow-to-head)
8750 (let* ((buffer-read-only nil)
8751 (inhibit-point-motion-hooks t)
8752 (hidden (if (numberp arg)
8754 (gnus-article-hidden-text-p 'headers)))
8756 (delete-region (point-min) (point-max))
8757 (with-current-buffer gnus-original-article-buffer
8758 (goto-char (setq s (point-min)))
8759 (setq e (if (search-forward "\n\n" nil t)
8762 (insert-buffer-substring gnus-original-article-buffer s e)
8763 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8764 ;; article-decode-encoded-words by default.
8765 (article-decode-encoded-words)
8766 (run-hooks 'gnus-article-decode-hook)
8768 (let ((gnus-treat-hide-headers nil)
8769 (gnus-treat-hide-boring-headers nil))
8770 (gnus-delete-wash-type 'headers)
8771 (gnus-treat-article 'head))
8772 (gnus-treat-article 'head))
8775 (set-window-start window (goto-char (point-min))))
8776 (setq gnus-page-broken
8777 (when gnus-break-pages
8778 (gnus-narrow-to-page)
8780 (gnus-set-mode-line 'article)))))
8782 (defun gnus-summary-show-all-headers ()
8783 "Make all header lines visible."
8785 (gnus-summary-toggle-header 1))
8787 (defun gnus-summary-toggle-mime (&optional arg)
8788 "Toggle MIME processing.
8789 If ARG is a positive number, turn MIME processing on."
8791 (setq gnus-show-mime
8793 (not gnus-show-mime)
8794 (> (prefix-numeric-value arg) 0)))
8795 (gnus-summary-select-article t 'force))
8797 (defun gnus-summary-caesar-message (&optional arg)
8798 "Caesar rotate the current article by 13.
8799 The numerical prefix specifies how many places to rotate each letter
8802 (gnus-summary-select-article)
8803 (let ((mail-header-separator ""))
8804 (gnus-eval-in-buffer-window gnus-article-buffer
8807 (let ((start (window-start))
8809 (message-caesar-buffer-body arg)
8810 (set-window-start (get-buffer-window (current-buffer)) start))))))
8812 (autoload 'unmorse-region "morse"
8813 "Convert morse coded text in region to ordinary ASCII text."
8816 (defun gnus-summary-morse-message (&optional arg)
8817 "Morse decode the current article."
8819 (gnus-summary-select-article)
8820 (let ((mail-header-separator ""))
8821 (gnus-eval-in-buffer-window gnus-article-buffer
8825 (let ((pos (window-start))
8827 (goto-char (point-min))
8828 (when (message-goto-body)
8829 (gnus-narrow-to-body))
8830 (goto-char (point-min))
8831 (while (re-search-forward "·" (point-max) t)
8832 (replace-match "."))
8833 (unmorse-region (point-min) (point-max))
8835 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8837 (defun gnus-summary-stop-page-breaking ()
8838 "Stop page breaking in the current article."
8840 (gnus-summary-select-article)
8841 (gnus-eval-in-buffer-window gnus-article-buffer
8843 (when (gnus-visual-p 'page-marker)
8844 (let ((buffer-read-only nil))
8845 (gnus-remove-text-with-property 'gnus-prev)
8846 (gnus-remove-text-with-property 'gnus-next))
8847 (setq gnus-page-broken nil))))
8849 (defun gnus-summary-move-article (&optional n to-newsgroup
8850 select-method action)
8851 "Move the current article to a different newsgroup.
8852 If N is a positive number, move the N next articles.
8853 If N is a negative number, move the N previous articles.
8854 If N is nil and any articles have been marked with the process mark,
8855 move those articles instead.
8856 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8857 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8858 re-spool using this method.
8860 When called interactively with TO-NEWSGROUP being nil, the value of
8861 the variable `gnus-move-split-methods' is used for finding a default
8862 for the target newsgroup.
8864 For this function to work, both the current newsgroup and the
8865 newsgroup that you want to move to have to support the `request-move'
8866 and `request-accept' functions.
8868 ACTION can be either `move' (the default), `crosspost' or `copy'."
8871 (setq action 'move))
8872 ;; Check whether the source group supports the required functions.
8873 (cond ((and (eq action 'move)
8874 (not (gnus-check-backend-function
8875 'request-move-article gnus-newsgroup-name)))
8876 (error "The current group does not support article moving"))
8877 ((and (eq action 'crosspost)
8878 (not (gnus-check-backend-function
8879 'request-replace-article gnus-newsgroup-name)))
8880 (error "The current group does not support article editing")))
8881 (let ((articles (gnus-summary-work-articles n))
8882 (prefix (if (gnus-check-backend-function
8883 'request-move-article gnus-newsgroup-name)
8884 (gnus-group-real-prefix gnus-newsgroup-name)
8886 (names '((move "Move" "Moving")
8887 (copy "Copy" "Copying")
8888 (crosspost "Crosspost" "Crossposting")))
8889 (copy-buf (save-excursion
8890 (nnheader-set-temp-buffer " *copy article*")))
8891 (default-marks gnus-article-mark-lists)
8892 (no-expire-marks (delete '(expirable . expire)
8893 (copy-sequence gnus-article-mark-lists)))
8894 art-group to-method new-xref article to-groups)
8895 (unless (assq action names)
8896 (error "Unknown action %s" action))
8897 ;; Read the newsgroup name.
8898 (when (and (not to-newsgroup)
8899 (not select-method))
8900 (if (and gnus-move-split-methods
8902 (and (memq gnus-current-article articles)
8903 (gnus-buffer-live-p gnus-original-article-buffer))))
8904 ;; When `gnus-move-split-methods' is non-nil, we have to
8905 ;; select an article to give `gnus-read-move-group-name' an
8906 ;; opportunity to suggest an appropriate default. However,
8907 ;; we needn't render or mark the article.
8908 (let ((gnus-display-mime-function nil)
8909 (gnus-article-prepare-hook nil)
8910 (gnus-mark-article-hook nil))
8911 (gnus-summary-select-article nil nil nil (car articles))))
8913 (gnus-read-move-group-name
8914 (cadr (assq action names))
8915 (symbol-value (intern (format "gnus-current-%s-group" action)))
8917 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8918 (setq to-method (or select-method
8919 (gnus-server-to-method
8920 (gnus-group-method to-newsgroup))))
8921 ;; Check the method we are to move this article to...
8922 (unless (gnus-check-backend-function
8923 'request-accept-article (car to-method))
8924 (error "%s does not support article copying" (car to-method)))
8925 (unless (gnus-check-server to-method)
8926 (error "Can't open server %s" (car to-method)))
8927 (gnus-message 6 "%s to %s: %s..."
8928 (caddr (assq action names))
8929 (or (car select-method) to-newsgroup) articles)
8931 (setq article (pop articles))
8935 ;; Move the article.
8937 ;; Remove this article from future suppression.
8938 (gnus-dup-unsuppress-article article)
8939 (gnus-request-move-article
8940 article ; Article to move
8941 gnus-newsgroup-name ; From newsgroup
8942 (nth 1 (gnus-find-method-for-group
8943 gnus-newsgroup-name)) ; Server
8944 (list 'gnus-request-accept-article
8945 to-newsgroup (list 'quote select-method)
8946 (not articles) t) ; Accept form
8947 (not articles))) ; Only save nov last time
8948 ;; Copy the article.
8951 (set-buffer copy-buf)
8952 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8953 (gnus-request-accept-article
8954 to-newsgroup select-method (not articles) t))))
8955 ;; Crosspost the article.
8956 ((eq action 'crosspost)
8957 (let ((xref (message-tokenize-header
8958 (mail-header-xref (gnus-summary-article-header article))
8960 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8961 ":" (number-to-string article)))
8963 (setq xref (list (system-name))))
8966 (mapconcat 'identity
8967 (delete "Xref:" (delete new-xref xref))
8971 (set-buffer copy-buf)
8972 ;; First put the article in the destination group.
8973 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8974 (when (consp (setq art-group
8975 (gnus-request-accept-article
8976 to-newsgroup select-method (not articles))))
8977 (setq new-xref (concat new-xref " " (car art-group)
8979 (number-to-string (cdr art-group))))
8980 ;; Now we have the new Xrefs header, so we insert
8981 ;; it and replace the new article.
8982 (nnheader-replace-header "Xref" new-xref)
8983 (gnus-request-replace-article
8984 (cdr art-group) to-newsgroup (current-buffer))
8988 (gnus-message 1 "Couldn't %s article %s: %s"
8989 (cadr (assq action names)) article
8990 (nnheader-get-report (car to-method))))
8991 ((eq art-group 'junk)
8992 (when (eq action 'move)
8993 (gnus-summary-mark-article article gnus-canceled-mark)
8994 (gnus-message 4 "Deleted article %s" article)
8995 ;; run the delete hook
8996 (run-hook-with-args 'gnus-summary-article-delete-hook
8999 (assoc article (gnus-data-list nil)))
9000 gnus-newsgroup-name nil
9003 (let* ((pto-group (gnus-group-prefixed-name
9004 (car art-group) to-method))
9006 (gnus-gethash pto-group gnus-newsrc-hashtb))
9007 (info (nth 2 entry))
9008 (to-group (gnus-info-group info))
9010 ;; Update the group that has been moved to.
9012 (memq action '(move copy)))
9013 (unless (member to-group to-groups)
9014 (push to-group to-groups))
9016 (unless (memq article gnus-newsgroup-unreads)
9017 (push 'read to-marks)
9019 info (gnus-add-to-range (gnus-info-read info)
9020 (list (cdr art-group)))))
9022 ;; See whether the article is to be put in the cache.
9023 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9026 (to-article (cdr art-group)))
9028 ;; Enter the article into the cache in the new group,
9029 ;; if that is required.
9030 (when gnus-use-cache
9031 (gnus-cache-possibly-enter-article
9033 (let ((header (copy-sequence
9034 (gnus-summary-article-header article))))
9035 (mail-header-set-number header to-article)
9037 (memq article gnus-newsgroup-marked)
9038 (memq article gnus-newsgroup-dormant)
9039 (memq article gnus-newsgroup-unreads)))
9041 (when gnus-preserve-marks
9042 ;; Copy any marks over to the new group.
9043 (when (and (equal to-group gnus-newsgroup-name)
9044 (not (memq article gnus-newsgroup-unreads)))
9045 ;; Mark this article as read in this group.
9046 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9047 (setcdr (gnus-active to-group) to-article)
9048 (setcdr gnus-newsgroup-active to-article))
9051 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9052 (when (memq article (symbol-value
9053 (intern (format "gnus-newsgroup-%s"
9055 (push (cdar marks) to-marks)
9056 ;; If the other group is the same as this group,
9057 ;; then we have to add the mark to the list.
9058 (when (equal to-group gnus-newsgroup-name)
9059 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9062 (intern (format "gnus-newsgroup-%s"
9064 ;; Copy the marks to other group.
9065 (gnus-add-marked-articles
9066 to-group (cdar marks) (list to-article) info)))
9067 (setq marks (cdr marks)))
9069 (gnus-request-set-mark
9070 to-group (list (list (list to-article) 'add to-marks))))
9073 (concat "(gnus-group-set-info '"
9074 (gnus-prin1-to-string (gnus-get-info to-group))
9077 ;; Update the Xref header in this article to point to
9078 ;; the new crossposted article we have just created.
9079 (when (eq action 'crosspost)
9081 (set-buffer copy-buf)
9082 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9083 (nnheader-replace-header "Xref" new-xref)
9084 (gnus-request-replace-article
9085 article gnus-newsgroup-name (current-buffer))))
9087 ;; run the move/copy/crosspost/respool hook
9088 (run-hook-with-args 'gnus-summary-article-move-hook
9091 (assoc article (gnus-data-list nil)))
9096 ;;;!!!Why is this necessary?
9097 (set-buffer gnus-summary-buffer)
9099 (gnus-summary-goto-subject article)
9100 (when (eq action 'move)
9101 (gnus-summary-mark-article article gnus-canceled-mark))))
9102 (gnus-summary-remove-process-mark article))
9103 ;; Re-activate all groups that have been moved to.
9105 (set-buffer gnus-group-buffer)
9106 (let ((gnus-group-marked to-groups))
9107 (gnus-group-get-new-news-this-group nil t)))
9109 (gnus-kill-buffer copy-buf)
9110 (gnus-summary-position-point)
9111 (gnus-set-mode-line 'summary)))
9113 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9114 "Move the current article to a different newsgroup.
9115 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9116 When called interactively, if TO-NEWSGROUP is nil, use the value of
9117 the variable `gnus-move-split-methods' for finding a default target
9119 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9120 re-spool using this method."
9122 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9124 (defun gnus-summary-crosspost-article (&optional n)
9125 "Crosspost the current article to some other group."
9127 (gnus-summary-move-article n nil nil 'crosspost))
9129 (defcustom gnus-summary-respool-default-method nil
9130 "Default method type for respooling an article.
9131 If nil, use to the current newsgroup method."
9133 :group 'gnus-summary-mail)
9135 (defcustom gnus-summary-display-while-building nil
9136 "If non-nil, show and update the summary buffer as it's being built.
9137 If the value is t, update the buffer after every line is inserted. If
9138 the value is an integer (N), update the display every N lines."
9140 :type '(choice (const :tag "off" nil)
9142 (const :tag "frequently" t)))
9144 (defun gnus-summary-respool-article (&optional n method)
9145 "Respool the current article.
9146 The article will be squeezed through the mail spooling process again,
9147 which means that it will be put in some mail newsgroup or other
9148 depending on `nnmail-split-methods'.
9149 If N is a positive number, respool the N next articles.
9150 If N is a negative number, respool the N previous articles.
9151 If N is nil and any articles have been marked with the process mark,
9152 respool those articles instead.
9154 Respooling can be done both from mail groups and \"real\" newsgroups.
9155 In the former case, the articles in question will be moved from the
9156 current group into whatever groups they are destined to. In the
9157 latter case, they will be copied into the relevant groups."
9159 (list current-prefix-arg
9160 (let* ((methods (gnus-methods-using 'respool))
9162 (symbol-name (or gnus-summary-respool-default-method
9163 (car (gnus-find-method-for-group
9164 gnus-newsgroup-name)))))
9166 (gnus-completing-read-with-default
9167 methname "What backend do you want to use when respooling?"
9168 methods nil t nil 'gnus-mail-method-history))
9171 ((zerop (length (setq ms (gnus-servers-using-backend
9173 (list (intern method) ""))
9177 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9178 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9181 (error "No method given for respooling"))
9182 (if (assoc (symbol-name
9183 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9184 (gnus-methods-using 'respool))
9185 (gnus-summary-move-article n nil method)
9186 (gnus-summary-copy-article n nil method)))
9188 (defun gnus-summary-import-article (file &optional edit)
9189 "Import an arbitrary file into a mail newsgroup."
9190 (interactive "fImport file: \nP")
9191 (let ((group gnus-newsgroup-name)
9192 (now (current-time))
9193 atts lines group-art)
9194 (unless (gnus-check-backend-function 'request-accept-article group)
9195 (error "%s does not support article importing" group))
9196 (or (file-readable-p file)
9197 (not (file-regular-p file))
9198 (error "Can't read %s" file))
9200 (set-buffer (gnus-get-buffer-create " *import file*"))
9202 (nnheader-insert-file-contents file)
9203 (goto-char (point-min))
9204 (if (nnheader-article-p)
9206 (goto-char (point-min))
9207 (search-forward "\n\n" nil t)
9208 (narrow-to-region (point-min) (1- (point)))
9209 (goto-char (point-min))
9210 (unless (re-search-forward "^date:" nil t)
9211 (goto-char (point-max))
9212 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9213 ;; This doesn't look like an article, so we fudge some headers.
9214 (setq atts (file-attributes file)
9215 lines (count-lines (point-min) (point-max)))
9216 (insert "From: " (read-string "From: ") "\n"
9217 "Subject: " (read-string "Subject: ") "\n"
9218 "Date: " (message-make-date (nth 5 atts)) "\n"
9219 "Message-ID: " (message-make-message-id) "\n"
9220 "Lines: " (int-to-string lines) "\n"
9221 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9222 (setq group-art (gnus-request-accept-article group nil t))
9223 (kill-buffer (current-buffer)))
9224 (setq gnus-newsgroup-active (gnus-activate-group group))
9226 (gnus-summary-goto-article (cdr group-art) nil t)
9228 (gnus-summary-edit-article))))
9230 (defun gnus-summary-create-article ()
9231 "Create an article in a mail newsgroup."
9233 (let ((group gnus-newsgroup-name)
9234 (now (current-time))
9236 (unless (gnus-check-backend-function 'request-accept-article group)
9237 (error "%s does not support article importing" group))
9239 (set-buffer (gnus-get-buffer-create " *import file*"))
9241 (goto-char (point-min))
9242 ;; This doesn't look like an article, so we fudge some headers.
9243 (insert "From: " (read-string "From: ") "\n"
9244 "Subject: " (read-string "Subject: ") "\n"
9245 "Date: " (message-make-date now) "\n"
9246 "Message-ID: " (message-make-message-id) "\n")
9247 (setq group-art (gnus-request-accept-article group nil t))
9248 (kill-buffer (current-buffer)))
9249 (setq gnus-newsgroup-active (gnus-activate-group group))
9251 (gnus-summary-goto-article (cdr group-art) nil t)
9252 (gnus-summary-edit-article)))
9254 (defun gnus-summary-article-posted-p ()
9255 "Say whether the current (mail) article is available from news as well.
9256 This will be the case if the article has both been mailed and posted."
9258 (let ((id (mail-header-references (gnus-summary-article-header)))
9259 (gnus-override-method (car (gnus-refer-article-methods))))
9260 (if (gnus-request-head id "")
9261 (gnus-message 2 "The current message was found on %s"
9262 gnus-override-method)
9263 (gnus-message 2 "The current message couldn't be found on %s"
9264 gnus-override-method)
9267 (defun gnus-summary-expire-articles (&optional now)
9268 "Expire all articles that are marked as expirable in the current group."
9270 (when (and (not gnus-group-is-exiting-without-update-p)
9271 (gnus-check-backend-function
9272 'request-expire-articles gnus-newsgroup-name))
9273 ;; This backend supports expiry.
9274 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9275 (expirable (if total
9277 ;; We need to update the info for
9278 ;; this group for `gnus-list-of-read-articles'
9279 ;; to give us the right answer.
9280 (gnus-run-hooks 'gnus-exit-group-hook)
9281 (gnus-summary-update-info)
9282 (gnus-list-of-read-articles gnus-newsgroup-name))
9283 (setq gnus-newsgroup-expirable
9284 (sort gnus-newsgroup-expirable '<))))
9285 (expiry-wait (if now 'immediate
9286 (gnus-group-find-parameter
9287 gnus-newsgroup-name 'expiry-wait)))
9288 (nnmail-expiry-target
9289 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9290 nnmail-expiry-target))
9293 ;; There are expirable articles in this group, so we run them
9294 ;; through the expiry process.
9295 (gnus-message 6 "Expiring articles...")
9296 (unless (gnus-check-group gnus-newsgroup-name)
9297 (error "Can't open server for %s" gnus-newsgroup-name))
9298 ;; The list of articles that weren't expired is returned.
9301 (let ((nnmail-expiry-wait-function nil)
9302 (nnmail-expiry-wait expiry-wait))
9303 (setq es (gnus-request-expire-articles
9304 expirable gnus-newsgroup-name)))
9305 (setq es (gnus-request-expire-articles
9306 expirable gnus-newsgroup-name)))
9308 (setq gnus-newsgroup-expirable es))
9309 ;; We go through the old list of expirable, and mark all
9310 ;; really expired articles as nonexistent.
9311 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9312 (let ((gnus-use-cache nil))
9313 (dolist (article expirable)
9314 (when (and (not (memq article es))
9315 (gnus-data-find article))
9316 (gnus-summary-mark-article article gnus-canceled-mark)
9317 (run-hook-with-args 'gnus-summary-article-expire-hook
9320 (assoc article (gnus-data-list nil)))
9324 (gnus-message 6 "Expiring articles...done")))))
9326 (defun gnus-summary-expire-articles-now ()
9327 "Expunge all expirable articles in the current group.
9328 This means that *all* articles that are marked as expirable will be
9329 deleted forever, right now."
9331 (or gnus-expert-user
9333 "Are you really, really, really sure you want to delete all these messages? ")
9335 (gnus-summary-expire-articles t))
9337 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9338 (defun gnus-summary-delete-article (&optional n)
9339 "Delete the N next (mail) articles.
9340 This command actually deletes articles. This is not a marking
9341 command. The article will disappear forever from your life, never to
9344 If N is negative, delete backwards.
9345 If N is nil and articles have been marked with the process mark,
9346 delete these instead.
9348 If `gnus-novice-user' is non-nil you will be asked for
9349 confirmation before the articles are deleted."
9351 (unless (gnus-check-backend-function 'request-expire-articles
9352 gnus-newsgroup-name)
9353 (error "The current newsgroup does not support article deletion"))
9354 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9355 (error "Couldn't open server"))
9356 ;; Compute the list of articles to delete.
9357 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9358 (nnmail-expiry-target 'delete)
9360 (if (and gnus-novice-user
9361 (not (gnus-yes-or-no-p
9362 (format "Do you really want to delete %s forever? "
9363 (if (> (length articles) 1)
9364 (format "these %s articles" (length articles))
9367 ;; Delete the articles.
9368 (setq not-deleted (gnus-request-expire-articles
9369 articles gnus-newsgroup-name 'force))
9371 (gnus-summary-remove-process-mark (car articles))
9372 ;; The backend might not have been able to delete the article
9374 (unless (memq (car articles) not-deleted)
9375 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9376 (let* ((article (car articles))
9377 (id (mail-header-id (gnus-data-header
9378 (assoc article (gnus-data-list nil))))))
9379 (run-hook-with-args 'gnus-summary-article-delete-hook
9380 'delete id gnus-newsgroup-name nil
9382 (setq articles (cdr articles)))
9384 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9385 (gnus-summary-position-point)
9386 (gnus-set-mode-line 'summary)
9389 (defun gnus-summary-edit-article (&optional force)
9390 "Edit the current article.
9391 This will have permanent effect only in mail groups.
9392 If FORCE is non-nil, allow editing of articles even in read-only
9396 (set-buffer gnus-summary-buffer)
9397 (let ((mail-parse-charset gnus-newsgroup-charset)
9398 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9399 (gnus-set-global-variables)
9400 (when (and (not force)
9401 (gnus-group-read-only-p))
9402 (error "The current newsgroup does not support article editing"))
9403 (gnus-summary-show-article t)
9404 (gnus-article-edit-article
9406 `(lambda (no-highlight)
9407 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9408 (message-options message-options)
9409 (message-options-set-recipient)
9410 (mail-parse-ignored-charsets
9411 ',gnus-newsgroup-ignored-charsets))
9412 (gnus-summary-edit-article-done
9413 ,(or (mail-header-references gnus-current-headers) "")
9414 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9416 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9418 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9420 "Make edits to the current article permanent."
9423 ;; The buffer restriction contains the entire article if it exists.
9424 (when (article-goto-body)
9425 (let ((lines (count-lines (point) (point-max)))
9426 (length (- (point-max) (point)))
9427 (case-fold-search t)
9428 (body (copy-marker (point))))
9429 (goto-char (point-min))
9430 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9431 (delete-region (match-beginning 1) (match-end 1))
9432 (insert (number-to-string length)))
9433 (goto-char (point-min))
9434 (when (re-search-forward
9435 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9436 (delete-region (match-beginning 1) (match-end 1))
9437 (insert (number-to-string length)))
9438 (goto-char (point-min))
9439 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9440 (delete-region (match-beginning 1) (match-end 1))
9441 (insert (number-to-string lines))))))
9442 ;; Replace the article.
9443 (let ((buf (current-buffer)))
9445 (insert-buffer-substring buf)
9447 (if (and (not read-only)
9448 (not (gnus-request-replace-article
9449 (cdr gnus-article-current) (car gnus-article-current)
9450 (current-buffer) t)))
9451 (error "Couldn't replace article")
9452 ;; Update the summary buffer.
9454 (equal (message-tokenize-header references " ")
9455 (message-tokenize-header
9456 (or (message-fetch-field "references") "") " ")))
9457 ;; We only have to update this line.
9460 (message-narrow-to-head)
9461 (let ((head (buffer-string))
9464 (insert (format "211 %d Article retrieved.\n"
9465 (cdr gnus-article-current)))
9468 (let ((nntp-server-buffer (current-buffer)))
9469 (setq header (car (gnus-get-newsgroup-headers
9472 (set-buffer gnus-summary-buffer)
9473 (gnus-data-set-header
9474 (gnus-data-find (cdr gnus-article-current))
9476 (gnus-summary-update-article-line
9477 (cdr gnus-article-current) header)
9478 (if (gnus-summary-goto-subject
9479 (cdr gnus-article-current) nil t)
9480 (gnus-summary-update-secondary-mark
9481 (cdr gnus-article-current))))))))
9483 (set-buffer (or buffer gnus-summary-buffer))
9484 (gnus-summary-update-article (cdr gnus-article-current))
9485 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9486 (gnus-summary-update-secondary-mark
9487 (cdr gnus-article-current))))
9488 ;; Prettify the article buffer again.
9489 (unless no-highlight
9491 (set-buffer gnus-article-buffer)
9492 ;;;!!! Fix this -- article should be rehighlighted.
9493 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9494 (set-buffer gnus-original-article-buffer)
9495 (gnus-request-article
9496 (cdr gnus-article-current)
9497 (car gnus-article-current) (current-buffer))))
9498 ;; Prettify the summary buffer line.
9499 (when (gnus-visual-p 'summary-highlight 'highlight)
9500 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9502 (defun gnus-summary-edit-wash (key)
9503 "Perform editing command KEY in the article buffer."
9507 (message "%s" (concat (this-command-keys) "- "))
9510 (gnus-summary-edit-article)
9511 (execute-kbd-macro (concat (this-command-keys) key))
9512 (gnus-article-edit-done))
9516 (defun gnus-summary-respool-query (&optional silent trace)
9517 "Query where the respool algorithm would put this article."
9519 (let (gnus-mark-article-hook)
9520 (gnus-summary-select-article)
9522 (set-buffer gnus-original-article-buffer)
9524 (message-narrow-to-head)
9525 (let ((groups (nnmail-article-group 'identity trace)))
9528 (message "This message would go to %s"
9529 (mapconcat 'car groups ", "))
9530 (message "This message would go to no groups"))
9533 (defun gnus-summary-respool-trace ()
9534 "Trace where the respool algorithm would put this article.
9535 Display a buffer showing all fancy splitting patterns which matched."
9537 (gnus-summary-respool-query nil t))
9539 ;; Summary marking commands.
9541 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9542 "Mark articles which has the same subject as read, and then select the next.
9543 If UNMARK is positive, remove any kind of mark.
9544 If UNMARK is negative, tick articles."
9547 (setq unmark (prefix-numeric-value unmark)))
9549 (gnus-summary-mark-same-subject
9550 (gnus-summary-article-subject) unmark)))
9551 ;; Select next unread article. If auto-select-same mode, should
9552 ;; select the first unread article.
9553 (gnus-summary-next-article t (and gnus-auto-select-same
9554 (gnus-summary-article-subject)))
9555 (gnus-message 7 "%d article%s marked as %s"
9556 count (if (= count 1) " is" "s are")
9557 (if unmark "unread" "read"))))
9559 (defun gnus-summary-kill-same-subject (&optional unmark)
9560 "Mark articles which has the same subject as read.
9561 If UNMARK is positive, remove any kind of mark.
9562 If UNMARK is negative, tick articles."
9565 (setq unmark (prefix-numeric-value unmark)))
9567 (gnus-summary-mark-same-subject
9568 (gnus-summary-article-subject) unmark)))
9569 ;; If marked as read, go to next unread subject.
9571 ;; Go to next unread subject.
9572 (gnus-summary-next-subject 1 t))
9573 (gnus-message 7 "%d articles are marked as %s"
9574 count (if unmark "unread" "read"))))
9576 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9577 "Mark articles with same SUBJECT as read, and return marked number.
9578 If optional argument UNMARK is positive, remove any kinds of marks.
9579 If optional argument UNMARK is negative, mark articles as unread instead."
9583 ((null unmark) ; Mark as read.
9586 (gnus-summary-mark-article-as-read gnus-killed-mark)
9587 (gnus-summary-show-thread) t)
9588 (gnus-summary-find-subject subject))
9589 (setq count (1+ count))))
9590 ((> unmark 0) ; Tick.
9593 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9594 (gnus-summary-show-thread) t)
9595 (gnus-summary-find-subject subject))
9596 (setq count (1+ count))))
9597 (t ; Mark as unread.
9600 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9601 (gnus-summary-show-thread) t)
9602 (gnus-summary-find-subject subject))
9603 (setq count (1+ count)))))
9604 (gnus-set-mode-line 'summary)
9605 ;; Return the number of marked articles.
9608 (defun gnus-summary-mark-as-processable (n &optional unmark)
9609 "Set the process mark on the next N articles.
9610 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9611 the process mark instead. The difference between N and the actual
9612 number of articles marked is returned."
9614 (if (and (null n) (gnus-region-active-p))
9615 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9616 (setq n (prefix-numeric-value n))
9617 (let ((backward (< n 0))
9622 (gnus-summary-remove-process-mark
9623 (gnus-summary-article-number))
9624 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9625 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9628 (gnus-message 7 "No more articles"))
9629 (gnus-summary-recenter)
9630 (gnus-summary-position-point)
9633 (defun gnus-summary-unmark-as-processable (n)
9634 "Remove the process mark from the next N articles.
9635 If N is negative, unmark backward instead. The difference between N and
9636 the actual number of articles unmarked is returned."
9638 (gnus-summary-mark-as-processable n t))
9640 (defun gnus-summary-unmark-all-processable ()
9641 "Remove the process mark from all articles."
9644 (while gnus-newsgroup-processable
9645 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9646 (gnus-summary-position-point))
9648 (defun gnus-summary-add-mark (article type)
9649 "Mark ARTICLE with a mark of TYPE."
9650 (let ((vtype (car (assq type gnus-article-mark-lists)))
9653 (error "No such mark type: %s" type)
9654 (setq var (intern (format "gnus-newsgroup-%s" type)))
9655 (set var (cons article (symbol-value var)))
9656 (if (memq type '(processable cached replied forwarded recent saved))
9657 (gnus-summary-update-secondary-mark article)
9658 ;;; !!! This is bogus. We should find out what primary
9659 ;;; !!! mark we want to set.
9660 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9662 (defun gnus-summary-mark-as-expirable (n)
9663 "Mark N articles forward as expirable.
9664 If N is negative, mark backward instead. The difference between N and
9665 the actual number of articles marked is returned."
9667 (gnus-summary-mark-forward n gnus-expirable-mark))
9669 (defun gnus-summary-mark-as-spam (n)
9670 "Mark N articles forward as spam.
9671 If N is negative, mark backward instead. The difference between N and
9672 the actual number of articles marked is returned."
9674 (gnus-summary-mark-forward n gnus-spam-mark))
9676 (defun gnus-summary-mark-article-as-replied (article)
9677 "Mark ARTICLE as replied to and update the summary line.
9678 ARTICLE can also be a list of articles."
9679 (interactive (list (gnus-summary-article-number)))
9680 (let ((articles (if (listp article) article (list article))))
9681 (dolist (article articles)
9682 (unless (numberp article)
9683 (error "%s is not a number" article))
9684 (push article gnus-newsgroup-replied)
9685 (let ((buffer-read-only nil))
9686 (when (gnus-summary-goto-subject article nil t)
9687 (gnus-summary-update-secondary-mark article))))))
9689 (defun gnus-summary-mark-article-as-forwarded (article)
9690 "Mark ARTICLE as forwarded and update the summary line.
9691 ARTICLE can also be a list of articles."
9692 (let ((articles (if (listp article) article (list article))))
9693 (dolist (article articles)
9694 (push article gnus-newsgroup-forwarded)
9695 (let ((buffer-read-only nil))
9696 (when (gnus-summary-goto-subject article nil t)
9697 (gnus-summary-update-secondary-mark article))))))
9699 (defun gnus-summary-set-bookmark (article)
9700 "Set a bookmark in current article."
9701 (interactive (list (gnus-summary-article-number)))
9702 (when (or (not (get-buffer gnus-article-buffer))
9703 (not gnus-current-article)
9704 (not gnus-article-current)
9705 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9706 (error "No current article selected"))
9707 ;; Remove old bookmark, if one exists.
9708 (gnus-pull article gnus-newsgroup-bookmarks)
9709 ;; Set the new bookmark, which is on the form
9710 ;; (article-number . line-number-in-body).
9714 (set-buffer gnus-article-buffer)
9721 gnus-newsgroup-bookmarks)
9722 (gnus-message 6 "A bookmark has been added to the current article."))
9724 (defun gnus-summary-remove-bookmark (article)
9725 "Remove the bookmark from the current article."
9726 (interactive (list (gnus-summary-article-number)))
9727 ;; Remove old bookmark, if one exists.
9728 (if (not (assq article gnus-newsgroup-bookmarks))
9729 (gnus-message 6 "No bookmark in current article.")
9730 (gnus-pull article gnus-newsgroup-bookmarks)
9731 (gnus-message 6 "Removed bookmark.")))
9733 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9734 (defun gnus-summary-mark-as-dormant (n)
9735 "Mark N articles forward as dormant.
9736 If N is negative, mark backward instead. The difference between N and
9737 the actual number of articles marked is returned."
9739 (gnus-summary-mark-forward n gnus-dormant-mark))
9741 (defun gnus-summary-set-process-mark (article)
9742 "Set the process mark on ARTICLE and update the summary line."
9743 (setq gnus-newsgroup-processable
9745 (delq article gnus-newsgroup-processable)))
9746 (when (gnus-summary-goto-subject article)
9747 (gnus-summary-show-thread)
9748 (gnus-summary-goto-subject article)
9749 (gnus-summary-update-secondary-mark article)))
9751 (defun gnus-summary-remove-process-mark (article)
9752 "Remove the process mark from ARTICLE and update the summary line."
9753 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9754 (when (gnus-summary-goto-subject article)
9755 (gnus-summary-show-thread)
9756 (gnus-summary-goto-subject article)
9757 (gnus-summary-update-secondary-mark article)))
9759 (defun gnus-summary-set-saved-mark (article)
9760 "Set the process mark on ARTICLE and update the summary line."
9761 (push article gnus-newsgroup-saved)
9762 (when (gnus-summary-goto-subject article)
9763 (gnus-summary-update-secondary-mark article)))
9765 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9766 "Mark N articles as read forwards.
9767 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9768 The difference between N and the actual number of articles marked is
9770 If NO-EXPIRE, auto-expiry will be inhibited."
9772 (gnus-summary-show-thread)
9773 (let ((backward (< n 0))
9774 (gnus-summary-goto-unread
9775 (and gnus-summary-goto-unread
9776 (not (eq gnus-summary-goto-unread 'never))
9777 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9778 gnus-ticked-mark gnus-dormant-mark)))))
9780 (mark (or mark gnus-del-mark)))
9782 (gnus-summary-mark-article nil mark no-expire)
9783 (zerop (gnus-summary-next-subject
9785 (and gnus-summary-goto-unread
9786 (not (eq gnus-summary-goto-unread 'never)))
9790 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9791 (gnus-summary-recenter)
9792 (gnus-summary-position-point)
9793 (gnus-set-mode-line 'summary)
9796 (defun gnus-summary-mark-article-as-read (mark)
9797 "Mark the current article quickly as read with MARK."
9798 (let ((article (gnus-summary-article-number)))
9799 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9800 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9801 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9802 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9803 (push (cons article mark) gnus-newsgroup-reads)
9804 ;; Possibly remove from cache, if that is used.
9805 (when gnus-use-cache
9806 (gnus-cache-enter-remove-article article))
9807 ;; Allow the backend to change the mark.
9808 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9809 ;; Check for auto-expiry.
9810 (when (and gnus-newsgroup-auto-expire
9811 (memq mark gnus-auto-expirable-marks))
9812 (setq mark gnus-expirable-mark)
9813 ;; Let the backend know about the mark change.
9814 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9815 (push article gnus-newsgroup-expirable))
9816 ;; Set the mark in the buffer.
9817 (gnus-summary-update-mark mark 'unread)
9820 (defun gnus-summary-mark-article-as-unread (mark)
9821 "Mark the current article quickly as unread with MARK."
9822 (let* ((article (gnus-summary-article-number))
9823 (old-mark (gnus-summary-article-mark article)))
9824 ;; Allow the backend to change the mark.
9825 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9826 (if (eq mark old-mark)
9830 (gnus-error 1 "Can't mark negative article numbers")
9832 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9833 (setq gnus-newsgroup-spam-marked
9834 (delq article gnus-newsgroup-spam-marked))
9835 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9836 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9837 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9838 (cond ((= mark gnus-ticked-mark)
9839 (setq gnus-newsgroup-marked
9840 (gnus-add-to-sorted-list gnus-newsgroup-marked
9842 ((= mark gnus-spam-mark)
9843 (setq gnus-newsgroup-spam-marked
9844 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9846 ((= mark gnus-dormant-mark)
9847 (setq gnus-newsgroup-dormant
9848 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9851 (setq gnus-newsgroup-unreads
9852 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9854 (gnus-pull article gnus-newsgroup-reads)
9856 ;; See whether the article is to be put in the cache.
9858 (vectorp (gnus-summary-article-header article))
9860 (gnus-cache-possibly-enter-article
9861 gnus-newsgroup-name article
9862 (gnus-summary-article-header article)
9863 (= mark gnus-ticked-mark)
9864 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9867 (gnus-summary-update-mark mark 'unread)
9870 (defun gnus-summary-mark-article (&optional article mark no-expire)
9871 "Mark ARTICLE with MARK. MARK can be any character.
9872 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9873 `??' (dormant) and `?E' (expirable).
9874 If MARK is nil, then the default character `?r' is used.
9875 If ARTICLE is nil, then the article on the current line will be
9877 If NO-EXPIRE, auto-expiry will be inhibited."
9878 ;; The mark might be a string.
9879 (when (stringp mark)
9880 (setq mark (aref mark 0)))
9881 ;; If no mark is given, then we check auto-expiring.
9883 (setq mark gnus-del-mark))
9884 (when (and (not no-expire)
9885 gnus-newsgroup-auto-expire
9886 (memq mark gnus-auto-expirable-marks))
9887 (setq mark gnus-expirable-mark))
9888 (let ((article (or article (gnus-summary-article-number)))
9889 (old-mark (gnus-summary-article-mark article)))
9890 ;; Allow the backend to change the mark.
9891 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9892 (if (eq mark old-mark)
9895 (error "No article on current line"))
9896 (if (not (if (or (= mark gnus-unread-mark)
9897 (= mark gnus-ticked-mark)
9898 (= mark gnus-spam-mark)
9899 (= mark gnus-dormant-mark))
9900 (gnus-mark-article-as-unread article mark)
9901 (gnus-mark-article-as-read article mark)))
9903 ;; See whether the article is to be put in the cache.
9905 (not (= mark gnus-canceled-mark))
9906 (vectorp (gnus-summary-article-header article))
9908 (gnus-cache-possibly-enter-article
9909 gnus-newsgroup-name article
9910 (gnus-summary-article-header article)
9911 (= mark gnus-ticked-mark)
9912 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9914 (when (gnus-summary-goto-subject article nil t)
9915 (let ((buffer-read-only nil))
9916 (gnus-summary-show-thread)
9918 (gnus-summary-update-mark mark 'unread)
9921 (defun gnus-summary-update-secondary-mark (article)
9922 "Update the secondary (read, process, cache) mark."
9923 (gnus-summary-update-mark
9924 (cond ((memq article gnus-newsgroup-processable)
9926 ((memq article gnus-newsgroup-cached)
9928 ((memq article gnus-newsgroup-replied)
9930 ((memq article gnus-newsgroup-forwarded)
9931 gnus-forwarded-mark)
9932 ((memq article gnus-newsgroup-saved)
9934 ((memq article gnus-newsgroup-recent)
9936 ((memq article gnus-newsgroup-unseen)
9940 (when (gnus-visual-p 'summary-highlight 'highlight)
9941 (gnus-run-hooks 'gnus-summary-update-hook))
9944 (defun gnus-summary-update-download-mark (article)
9945 "Update the download mark."
9946 (gnus-summary-update-mark
9947 (cond ((memq article gnus-newsgroup-undownloaded)
9948 gnus-undownloaded-mark)
9949 (gnus-newsgroup-agentized
9950 gnus-downloaded-mark)
9954 (gnus-summary-update-line t)
9957 (defun gnus-summary-update-mark (mark type)
9958 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9959 (buffer-read-only nil))
9960 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9962 (when (looking-at "\r")
9964 (when (<= (+ forward (point)) (point-max))
9965 ;; Go to the right position on the line.
9966 (goto-char (+ forward (point)))
9967 ;; Replace the old mark with the new mark.
9968 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9969 ;; Optionally update the marks by some user rule.
9970 (when (eq type 'unread)
9972 (gnus-data-find (gnus-summary-article-number)) mark)
9973 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9975 (defun gnus-mark-article-as-read (article &optional mark)
9976 "Enter ARTICLE in the pertinent lists and remove it from others."
9977 ;; Make the article expirable.
9978 (let ((mark (or mark gnus-del-mark)))
9979 (setq gnus-newsgroup-expirable
9980 (if (= mark gnus-expirable-mark)
9981 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9982 (delq article gnus-newsgroup-expirable)))
9983 ;; Remove from unread and marked lists.
9984 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9985 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9986 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9987 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9988 (push (cons article mark) gnus-newsgroup-reads)
9989 ;; Possibly remove from cache, if that is used.
9990 (when gnus-use-cache
9991 (gnus-cache-enter-remove-article article))
9994 (defun gnus-mark-article-as-unread (article &optional mark)
9995 "Enter ARTICLE in the pertinent lists and remove it from others."
9996 (let ((mark (or mark gnus-ticked-mark)))
9999 (gnus-error 1 "Can't mark negative article numbers")
10001 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10002 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10003 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10004 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10005 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10007 ;; Unsuppress duplicates?
10008 (when gnus-suppress-duplicates
10009 (gnus-dup-unsuppress-article article))
10011 (cond ((= mark gnus-ticked-mark)
10012 (setq gnus-newsgroup-marked
10013 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10014 ((= mark gnus-spam-mark)
10015 (setq gnus-newsgroup-spam-marked
10016 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10018 ((= mark gnus-dormant-mark)
10019 (setq gnus-newsgroup-dormant
10020 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10022 (setq gnus-newsgroup-unreads
10023 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10024 (gnus-pull article gnus-newsgroup-reads)
10027 (defalias 'gnus-summary-mark-as-unread-forward
10028 'gnus-summary-tick-article-forward)
10029 (make-obsolete 'gnus-summary-mark-as-unread-forward
10030 'gnus-summary-tick-article-forward)
10031 (defun gnus-summary-tick-article-forward (n)
10032 "Tick N articles forwards.
10033 If N is negative, tick backwards instead.
10034 The difference between N and the number of articles ticked is returned."
10036 (gnus-summary-mark-forward n gnus-ticked-mark))
10038 (defalias 'gnus-summary-mark-as-unread-backward
10039 'gnus-summary-tick-article-backward)
10040 (make-obsolete 'gnus-summary-mark-as-unread-backward
10041 'gnus-summary-tick-article-backward)
10042 (defun gnus-summary-tick-article-backward (n)
10043 "Tick N articles backwards.
10044 The difference between N and the number of articles ticked is returned."
10046 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10048 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10049 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10050 (defun gnus-summary-tick-article (&optional article clear-mark)
10051 "Mark current article as unread.
10052 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10053 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10055 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10056 gnus-ticked-mark)))
10058 (defun gnus-summary-mark-as-read-forward (n)
10059 "Mark N articles as read forwards.
10060 If N is negative, mark backwards instead.
10061 The difference between N and the actual number of articles marked is
10064 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10066 (defun gnus-summary-mark-as-read-backward (n)
10067 "Mark the N articles as read backwards.
10068 The difference between N and the actual number of articles marked is
10071 (gnus-summary-mark-forward
10072 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10074 (defun gnus-summary-mark-as-read (&optional article mark)
10075 "Mark current article as read.
10076 ARTICLE specifies the article to be marked as read.
10077 MARK specifies a string to be inserted at the beginning of the line."
10078 (gnus-summary-mark-article article mark))
10080 (defun gnus-summary-clear-mark-forward (n)
10081 "Clear marks from N articles forward.
10082 If N is negative, clear backward instead.
10083 The difference between N and the number of marks cleared is returned."
10085 (gnus-summary-mark-forward n gnus-unread-mark))
10087 (defun gnus-summary-clear-mark-backward (n)
10088 "Clear marks from N articles backward.
10089 The difference between N and the number of marks cleared is returned."
10091 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10093 (defun gnus-summary-mark-unread-as-read ()
10094 "Intended to be used by `gnus-summary-mark-article-hook'."
10095 (when (memq gnus-current-article gnus-newsgroup-unreads)
10096 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10098 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10099 "Intended to be used by `gnus-summary-mark-article-hook'."
10100 (let ((mark (gnus-summary-article-mark)))
10101 (when (or (gnus-unread-mark-p mark)
10102 (gnus-read-mark-p mark))
10103 (gnus-summary-mark-article gnus-current-article
10104 (or new-mark gnus-read-mark)))))
10106 (defun gnus-summary-mark-unread-as-ticked ()
10107 "Intended to be used by `gnus-summary-mark-article-hook'."
10108 (when (memq gnus-current-article gnus-newsgroup-unreads)
10109 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10111 (defun gnus-summary-mark-region-as-read (point mark all)
10112 "Mark all unread articles between point and mark as read.
10113 If given a prefix, mark all articles between point and mark as read,
10114 even ticked and dormant ones."
10115 (interactive "r\nP")
10119 (beginning-of-line)
10124 (memq (setq article (gnus-summary-article-number))
10125 gnus-newsgroup-unreads))
10126 (gnus-summary-mark-article article gnus-del-mark))
10128 (gnus-summary-find-next))))))
10130 (defun gnus-summary-mark-below (score mark)
10131 "Mark articles with score less than SCORE with MARK."
10132 (interactive "P\ncMark: ")
10133 (setq score (if score
10134 (prefix-numeric-value score)
10135 (or gnus-summary-default-score 0)))
10137 (set-buffer gnus-summary-buffer)
10138 (goto-char (point-min))
10141 (and (< (gnus-summary-article-score) score)
10142 (gnus-summary-mark-article nil mark))
10143 (gnus-summary-find-next)))))
10145 (defun gnus-summary-kill-below (&optional score)
10146 "Mark articles with score below SCORE as read."
10148 (gnus-summary-mark-below score gnus-killed-mark))
10150 (defun gnus-summary-clear-above (&optional score)
10151 "Clear all marks from articles with score above SCORE."
10153 (gnus-summary-mark-above score gnus-unread-mark))
10155 (defun gnus-summary-tick-above (&optional score)
10156 "Tick all articles with score above SCORE."
10158 (gnus-summary-mark-above score gnus-ticked-mark))
10160 (defun gnus-summary-mark-above (score mark)
10161 "Mark articles with score over SCORE with MARK."
10162 (interactive "P\ncMark: ")
10163 (setq score (if score
10164 (prefix-numeric-value score)
10165 (or gnus-summary-default-score 0)))
10167 (set-buffer gnus-summary-buffer)
10168 (goto-char (point-min))
10170 (when (> (gnus-summary-article-score) score)
10171 (gnus-summary-mark-article nil mark))
10173 (gnus-summary-find-next)))))
10175 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10176 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10177 (defun gnus-summary-limit-include-expunged (&optional no-error)
10178 "Display all the hidden articles that were expunged for low scores."
10180 (let ((buffer-read-only nil))
10181 (let ((scored gnus-newsgroup-scored)
10184 (unless (gnus-summary-article-header (caar scored))
10185 (and (setq h (gnus-number-to-header (caar scored)))
10186 (< (cdar scored) gnus-summary-expunge-below)
10188 (setq scored (cdr scored)))
10190 (when (not no-error)
10191 (error "No expunged articles hidden"))
10192 (goto-char (point-min))
10193 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10194 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10195 (mapcar (lambda (x) (push (mail-header-number x)
10196 gnus-newsgroup-limit))
10198 (gnus-summary-prepare-unthreaded (nreverse headers))
10199 (goto-char (point-min))
10200 (gnus-summary-position-point)
10203 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10204 "Mark all unread articles in this newsgroup as read.
10205 If prefix argument ALL is non-nil, ticked and dormant articles will
10206 also be marked as read.
10207 If QUIETLY is non-nil, no questions will be asked.
10208 If TO-HERE is non-nil, it should be a point in the buffer. All
10209 articles before (after, if REVERSE is set) this point will be marked as read.
10210 Note that this function will only catch up the unread article
10211 in the current summary buffer limitation.
10212 The number of articles marked as read is returned."
10217 (not gnus-interactive-catchup) ;Without confirmation?
10221 "Mark absolutely all articles as read? "
10222 "Mark all unread articles as read? ")))
10224 (not gnus-newsgroup-adaptive)
10225 (not gnus-newsgroup-auto-expire)
10226 (not gnus-suppress-duplicates)
10227 (or (not gnus-use-cache)
10228 (eq gnus-use-cache 'passive)))
10231 (setq gnus-newsgroup-marked nil
10232 gnus-newsgroup-spam-marked nil
10233 gnus-newsgroup-dormant nil))
10234 (setq gnus-newsgroup-unreads
10235 (gnus-sorted-nunion
10236 (gnus-intersection gnus-newsgroup-unreads
10237 gnus-newsgroup-downloadable)
10238 gnus-newsgroup-unfetched)))
10239 ;; We actually mark all articles as canceled, which we
10240 ;; have to do when using auto-expiry or adaptive scoring.
10241 (gnus-summary-show-all-threads)
10242 (if (and to-here reverse)
10244 (goto-char to-here)
10245 (gnus-summary-mark-read-and-unread-as-read gnus-catchup-mark)
10246 (while (gnus-summary-find-next (not all))
10247 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10248 (when (gnus-summary-first-subject (not all))
10250 (if to-here (< (point) to-here) t)
10251 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10252 (gnus-summary-find-next (not all))))))
10253 (gnus-set-mode-line 'summary))
10255 (gnus-summary-position-point)))
10257 (defun gnus-summary-catchup-to-here (&optional all)
10258 "Mark all unticked articles before the current one as read.
10259 If ALL is non-nil, also mark ticked and dormant articles as read."
10262 (gnus-save-hidden-threads
10263 (let ((beg (point)))
10264 ;; We check that there are unread articles.
10265 (when (or all (gnus-summary-find-prev))
10266 (gnus-summary-catchup all t beg)))))
10267 (gnus-summary-position-point))
10269 (defun gnus-summary-catchup-from-here (&optional all)
10270 "Mark all unticked articles after (and including) the current one as read.
10271 If ALL is non-nil, also mark ticked and dormant articles as read."
10274 (gnus-save-hidden-threads
10275 (let ((beg (point)))
10276 ;; We check that there are unread articles.
10277 (when (or all (gnus-summary-find-next))
10278 (gnus-summary-catchup all t beg nil t)))))
10279 (gnus-summary-position-point))
10281 (defun gnus-summary-catchup-all (&optional quietly)
10282 "Mark all articles in this newsgroup as read.
10283 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10284 instead, which marks only unread articles as read."
10286 (gnus-summary-catchup t quietly))
10288 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10289 "Mark all unread articles in this group as read, then exit.
10290 If prefix argument ALL is non-nil, all articles are marked as read.
10291 If QUIETLY is non-nil, no questions will be asked."
10293 (when (gnus-summary-catchup all quietly nil 'fast)
10294 ;; Select next newsgroup or exit.
10295 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10296 (eq gnus-auto-select-next 'quietly))
10297 (gnus-summary-next-group nil)
10298 (gnus-summary-exit))))
10300 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10301 "Mark all articles in this newsgroup as read, and then exit.
10302 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10303 instead, which marks only unread articles as read."
10305 (gnus-summary-catchup-and-exit t quietly))
10307 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10308 "Mark all articles in this group as read and select the next group.
10309 If given a prefix, mark all articles, unread as well as ticked, as
10313 (gnus-summary-catchup all))
10314 (gnus-summary-next-group))
10320 (defmacro gnus-with-article (article &rest forms)
10321 "Select ARTICLE and perform FORMS in the original article buffer.
10322 Then replace the article with the result."
10324 ;; We don't want the article to be marked as read.
10325 (let (gnus-mark-article-hook)
10326 (gnus-summary-select-article t t nil ,article))
10327 (set-buffer gnus-original-article-buffer)
10329 (if (not (gnus-check-backend-function
10330 'request-replace-article (car gnus-article-current)))
10331 (gnus-message 5 "Read-only group; not replacing")
10332 (unless (gnus-request-replace-article
10333 ,article (car gnus-article-current)
10334 (current-buffer) t)
10335 (error "Couldn't replace article")))
10336 ;; The cache and backlog have to be flushed somewhat.
10337 (when gnus-keep-backlog
10338 (gnus-backlog-remove-article
10339 (car gnus-article-current) (cdr gnus-article-current)))
10340 (when gnus-use-cache
10341 (gnus-cache-update-article
10342 (car gnus-article-current) (cdr gnus-article-current)))))
10344 (put 'gnus-with-article 'lisp-indent-function 1)
10345 (put 'gnus-with-article 'edebug-form-spec '(form body))
10347 ;; Thread-based commands.
10349 (defun gnus-summary-articles-in-thread (&optional article)
10350 "Return a list of all articles in the current thread.
10351 If ARTICLE is non-nil, return all articles in the thread that starts
10352 with that article."
10353 (let* ((article (or article (gnus-summary-article-number)))
10354 (data (gnus-data-find-list article))
10355 (top-level (gnus-data-level (car data)))
10357 (cond ((null gnus-thread-operation-ignore-subject)
10358 (gnus-simplify-subject-re
10359 (mail-header-subject (gnus-data-header (car data)))))
10360 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10361 (gnus-simplify-subject-fuzzy
10362 (mail-header-subject (gnus-data-header (car data)))))
10364 (end-point (save-excursion
10365 (if (gnus-summary-go-to-next-thread)
10366 (point) (point-max))))
10369 (< (gnus-data-pos (car data)) end-point))
10370 (when (or (not top-subject)
10371 (string= top-subject
10372 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10373 (gnus-simplify-subject-fuzzy
10374 (mail-header-subject
10375 (gnus-data-header (car data))))
10376 (gnus-simplify-subject-re
10377 (mail-header-subject
10378 (gnus-data-header (car data)))))))
10379 (push (gnus-data-number (car data)) articles))
10380 (unless (and (setq data (cdr data))
10381 (> (gnus-data-level (car data)) top-level))
10383 ;; Return the list of articles.
10384 (nreverse articles)))
10386 (defun gnus-summary-rethread-current ()
10387 "Rethread the thread the current article is part of."
10389 (let* ((gnus-show-threads t)
10390 (article (gnus-summary-article-number))
10391 (id (mail-header-id (gnus-summary-article-header)))
10392 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10394 (error "No article on the current line"))
10395 (gnus-rebuild-thread id)
10396 (gnus-summary-goto-subject article)))
10398 (defun gnus-summary-reparent-thread ()
10399 "Make the current article child of the marked (or previous) article.
10401 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10402 is non-nil or the Subject: of both articles are the same."
10404 (unless (not (gnus-group-read-only-p))
10405 (error "The current newsgroup does not support article editing"))
10406 (unless (<= (length gnus-newsgroup-processable) 1)
10407 (error "No more than one article may be marked"))
10408 (save-window-excursion
10409 (let ((gnus-article-buffer " *reparent*")
10410 (current-article (gnus-summary-article-number))
10411 ;; First grab the marked article, otherwise one line up.
10412 (parent-article (if (not (null gnus-newsgroup-processable))
10413 (car gnus-newsgroup-processable)
10415 (if (eq (forward-line -1) 0)
10416 (gnus-summary-article-number)
10417 (error "Beginning of summary buffer"))))))
10418 (unless (not (eq current-article parent-article))
10419 (error "An article may not be self-referential"))
10420 (let ((message-id (mail-header-id
10421 (gnus-summary-article-header parent-article))))
10422 (unless (and message-id (not (equal message-id "")))
10423 (error "No message-id in desired parent"))
10424 (gnus-with-article current-article
10426 (goto-char (point-min))
10427 (message-narrow-to-head)
10428 (if (re-search-forward "^References: " nil t)
10430 (re-search-forward "^[^ \t]" nil t)
10433 (insert " " message-id))
10434 (insert "References: " message-id "\n"))))
10435 (set-buffer gnus-summary-buffer)
10436 (gnus-summary-unmark-all-processable)
10437 (gnus-summary-update-article current-article)
10438 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10439 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10440 (gnus-summary-rethread-current)
10441 (gnus-message 3 "Article %d is now the child of article %d"
10442 current-article parent-article)))))
10444 (defun gnus-summary-toggle-threads (&optional arg)
10445 "Toggle showing conversation threads.
10446 If ARG is positive number, turn showing conversation threads on."
10448 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10449 (setq gnus-show-threads
10450 (if (null arg) (not gnus-show-threads)
10451 (> (prefix-numeric-value arg) 0)))
10452 (gnus-summary-prepare)
10453 (gnus-summary-goto-subject current)
10454 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10455 (gnus-summary-position-point)))
10457 (defun gnus-summary-show-all-threads ()
10458 "Show all threads."
10461 (let ((buffer-read-only nil))
10462 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10463 (gnus-summary-position-point))
10465 (defun gnus-summary-show-thread ()
10466 "Show thread subtrees.
10467 Returns nil if no thread was there to be shown."
10469 (let ((buffer-read-only nil)
10471 (end (gnus-point-at-eol))
10472 ;; Leave point at bol
10473 (beg (progn (beginning-of-line) (point))))
10475 ;; Any hidden lines here?
10476 (search-forward "\r" end t)
10477 (subst-char-in-region beg end ?\^M ?\n t)
10479 (gnus-summary-position-point))))
10481 (defun gnus-summary-maybe-hide-threads ()
10482 "If requested, hide the threads that should be hidden."
10483 (when (and gnus-show-threads
10484 gnus-thread-hide-subtree)
10485 (gnus-summary-hide-all-threads
10486 (if (or (consp gnus-thread-hide-subtree)
10487 (functionp gnus-thread-hide-subtree))
10488 (gnus-make-predicate gnus-thread-hide-subtree)
10491 ;;; Hiding predicates.
10493 (defun gnus-article-unread-p (header)
10494 (memq (mail-header-number header) gnus-newsgroup-unreads))
10496 (defun gnus-article-unseen-p (header)
10497 (memq (mail-header-number header) gnus-newsgroup-unseen))
10499 (defun gnus-map-articles (predicate articles)
10500 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10501 (apply 'gnus-or (mapcar predicate
10502 (mapcar 'gnus-summary-article-header articles))))
10504 (defun gnus-summary-hide-all-threads (&optional predicate)
10505 "Hide all thread subtrees.
10506 If PREDICATE is supplied, threads that satisfy this predicate
10507 will not be hidden."
10510 (goto-char (point-min))
10513 (when (or (not predicate)
10515 predicate (gnus-summary-article-children)))
10516 (gnus-summary-hide-thread))
10517 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10518 (gnus-summary-position-point))
10520 (defun gnus-summary-hide-thread ()
10521 "Hide thread subtrees.
10522 If PREDICATE is supplied, threads that satisfy this predicate
10523 will not be hidden.
10524 Returns nil if no threads were there to be hidden."
10526 (let ((buffer-read-only nil)
10528 (article (gnus-summary-article-number)))
10530 ;; Go forward until either the buffer ends or the subthread
10532 (when (and (not (eobp))
10533 (or (zerop (gnus-summary-next-thread 1 t))
10534 (goto-char (point-max))))
10536 (if (and (> (point) start)
10537 (search-backward "\n" start t))
10539 (subst-char-in-region start (point) ?\n ?\^M)
10540 (gnus-summary-goto-subject article))
10544 (defun gnus-summary-go-to-next-thread (&optional previous)
10545 "Go to the same level (or less) next thread.
10546 If PREVIOUS is non-nil, go to previous thread instead.
10547 Return the article number moved to, or nil if moving was impossible."
10548 (let ((level (gnus-summary-thread-level))
10549 (way (if previous -1 1))
10552 (while (and (not (eobp))
10553 (< level (gnus-summary-thread-level)))
10554 (forward-line way))
10561 (gnus-summary-article-number)
10562 (goto-char beg)))))
10564 (defun gnus-summary-next-thread (n &optional silent)
10565 "Go to the same level next N'th thread.
10566 If N is negative, search backward instead.
10567 Returns the difference between N and the number of skips actually
10570 If SILENT, don't output messages."
10572 (let ((backward (< n 0))
10574 (while (and (> n 0)
10575 (gnus-summary-go-to-next-thread backward))
10578 (gnus-summary-position-point))
10579 (when (and (not silent) (/= 0 n))
10580 (gnus-message 7 "No more threads"))
10583 (defun gnus-summary-prev-thread (n)
10584 "Go to the same level previous N'th thread.
10585 Returns the difference between N and the number of skips actually
10588 (gnus-summary-next-thread (- n)))
10590 (defun gnus-summary-go-down-thread ()
10591 "Go down one level in the current thread."
10592 (let ((children (gnus-summary-article-children)))
10594 (gnus-summary-goto-subject (car children)))))
10596 (defun gnus-summary-go-up-thread ()
10597 "Go up one level in the current thread."
10598 (let ((parent (gnus-summary-article-parent)))
10600 (gnus-summary-goto-subject parent))))
10602 (defun gnus-summary-down-thread (n)
10603 "Go down thread N steps.
10604 If N is negative, go up instead.
10605 Returns the difference between N and how many steps down that were
10610 (while (and (> n 0)
10611 (if up (gnus-summary-go-up-thread)
10612 (gnus-summary-go-down-thread)))
10614 (gnus-summary-position-point)
10616 (gnus-message 7 "Can't go further"))
10619 (defun gnus-summary-up-thread (n)
10620 "Go up thread N steps.
10621 If N is negative, go down instead.
10622 Returns the difference between N and how many steps down that were
10625 (gnus-summary-down-thread (- n)))
10627 (defun gnus-summary-top-thread ()
10628 "Go to the top of the thread."
10630 (while (gnus-summary-go-up-thread))
10631 (gnus-summary-article-number))
10633 (defun gnus-summary-kill-thread (&optional unmark)
10634 "Mark articles under current thread as read.
10635 If the prefix argument is positive, remove any kinds of marks.
10636 If the prefix argument is negative, tick articles instead."
10639 (setq unmark (prefix-numeric-value unmark)))
10640 (let ((articles (gnus-summary-articles-in-thread)))
10642 ;; Expand the thread.
10643 (gnus-summary-show-thread)
10644 ;; Mark all the articles.
10646 (gnus-summary-goto-subject (car articles))
10647 (cond ((null unmark)
10648 (gnus-summary-mark-article-as-read gnus-killed-mark))
10650 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10652 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10653 (setq articles (cdr articles))))
10654 ;; Hide killed subtrees.
10656 gnus-thread-hide-killed
10657 (gnus-summary-hide-thread))
10658 ;; If marked as read, go to next unread subject.
10659 (when (null unmark)
10660 ;; Go to next unread subject.
10661 (gnus-summary-next-subject 1 t)))
10662 (gnus-set-mode-line 'summary))
10664 ;; Summary sorting commands
10666 (defun gnus-summary-sort-by-number (&optional reverse)
10667 "Sort the summary buffer by article number.
10668 Argument REVERSE means reverse order."
10670 (gnus-summary-sort 'number reverse))
10672 (defun gnus-summary-sort-by-random (&optional reverse)
10673 "Randomize the order in the summary buffer.
10674 Argument REVERSE means to randomize in reverse order."
10676 (gnus-summary-sort 'random reverse))
10678 (defun gnus-summary-sort-by-author (&optional reverse)
10679 "Sort the summary buffer by author name alphabetically.
10680 If `case-fold-search' is non-nil, case of letters is ignored.
10681 Argument REVERSE means reverse order."
10683 (gnus-summary-sort 'author reverse))
10685 (defun gnus-summary-sort-by-subject (&optional reverse)
10686 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10687 If `case-fold-search' is non-nil, case of letters is ignored.
10688 Argument REVERSE means reverse order."
10690 (gnus-summary-sort 'subject reverse))
10692 (defun gnus-summary-sort-by-date (&optional reverse)
10693 "Sort the summary buffer by date.
10694 Argument REVERSE means reverse order."
10696 (gnus-summary-sort 'date reverse))
10698 (defun gnus-summary-sort-by-score (&optional reverse)
10699 "Sort the summary buffer by score.
10700 Argument REVERSE means reverse order."
10702 (gnus-summary-sort 'score reverse))
10704 (defun gnus-summary-sort-by-lines (&optional reverse)
10705 "Sort the summary buffer by the number of lines.
10706 Argument REVERSE means reverse order."
10708 (gnus-summary-sort 'lines reverse))
10710 (defun gnus-summary-sort-by-chars (&optional reverse)
10711 "Sort the summary buffer by article length.
10712 Argument REVERSE means reverse order."
10714 (gnus-summary-sort 'chars reverse))
10716 (defun gnus-summary-sort-by-original (&optional reverse)
10717 "Sort the summary buffer using the default sorting method.
10718 Argument REVERSE means reverse order."
10720 (let* ((buffer-read-only)
10721 (gnus-summary-prepare-hook nil))
10722 ;; We do the sorting by regenerating the threads.
10723 (gnus-summary-prepare)
10724 ;; Hide subthreads if needed.
10725 (gnus-summary-maybe-hide-threads)))
10727 (defun gnus-summary-sort (predicate reverse)
10728 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10729 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10730 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10731 (gnus-thread-sort-functions
10736 (gnus-sort-gathered-threads-function
10737 gnus-thread-sort-functions)
10738 (gnus-article-sort-functions
10742 (,article t2 t1))))
10744 (gnus-summary-prepare-hook nil))
10745 ;; We do the sorting by regenerating the threads.
10746 (gnus-summary-prepare)
10747 ;; Hide subthreads if needed.
10748 (gnus-summary-maybe-hide-threads)))
10750 ;; Summary saving commands.
10752 (defun gnus-summary-save-article (&optional n not-saved)
10753 "Save the current article using the default saver function.
10754 If N is a positive number, save the N next articles.
10755 If N is a negative number, save the N previous articles.
10756 If N is nil and any articles have been marked with the process mark,
10757 save those articles instead.
10758 The variable `gnus-default-article-saver' specifies the saver function."
10760 (let* ((articles (gnus-summary-work-articles n))
10761 (save-buffer (save-excursion
10762 (nnheader-set-temp-buffer " *Gnus Save*")))
10763 (num (length articles))
10765 (dolist (article articles)
10766 (setq header (gnus-summary-article-header article))
10767 (if (not (vectorp header))
10768 ;; This is a pseudo-article.
10769 (if (assq 'name header)
10770 (gnus-copy-file (cdr (assq 'name header)))
10771 (gnus-message 1 "Article %d is unsaveable" article))
10772 ;; This is a real article.
10773 (save-window-excursion
10774 (let ((gnus-display-mime-function nil)
10775 (gnus-article-prepare-hook nil))
10776 (gnus-summary-select-article t nil nil article)))
10778 (set-buffer save-buffer)
10780 (insert-buffer-substring gnus-original-article-buffer))
10781 (setq file (gnus-article-save save-buffer file num))
10782 (gnus-summary-remove-process-mark article)
10784 (gnus-summary-set-saved-mark article))))
10785 (gnus-kill-buffer save-buffer)
10786 (gnus-summary-position-point)
10787 (gnus-set-mode-line 'summary)
10790 (defun gnus-summary-pipe-output (&optional arg headers)
10791 "Pipe the current article to a subprocess.
10792 If N is a positive number, pipe the N next articles.
10793 If N is a negative number, pipe the N previous articles.
10794 If N is nil and any articles have been marked with the process mark,
10795 pipe those articles instead.
10796 If HEADERS (the symbolic prefix), include the headers, too."
10797 (interactive (gnus-interactive "P\ny"))
10798 (require 'gnus-art)
10799 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10800 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10801 (gnus-summary-save-article arg t))
10802 (let ((buffer (get-buffer "*Shell Command Output*")))
10804 (not (zerop (buffer-size buffer))))
10805 (gnus-configure-windows 'pipe))))
10807 (defun gnus-summary-save-article-mail (&optional arg)
10808 "Append the current article to an mail file.
10809 If N is a positive number, save the N next articles.
10810 If N is a negative number, save the N previous articles.
10811 If N is nil and any articles have been marked with the process mark,
10812 save those articles instead."
10814 (require 'gnus-art)
10815 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10816 (gnus-summary-save-article arg)))
10818 (defun gnus-summary-save-article-rmail (&optional arg)
10819 "Append the current article to an rmail file.
10820 If N is a positive number, save the N next articles.
10821 If N is a negative number, save the N previous articles.
10822 If N is nil and any articles have been marked with the process mark,
10823 save those articles instead."
10825 (require 'gnus-art)
10826 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10827 (gnus-summary-save-article arg)))
10829 (defun gnus-summary-save-article-file (&optional arg)
10830 "Append the current article to a file.
10831 If N is a positive number, save the N next articles.
10832 If N is a negative number, save the N previous articles.
10833 If N is nil and any articles have been marked with the process mark,
10834 save those articles instead."
10836 (require 'gnus-art)
10837 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10838 (gnus-summary-save-article arg)))
10840 (defun gnus-summary-write-article-file (&optional arg)
10841 "Write the current article to a file, deleting the previous file.
10842 If N is a positive number, save the N next articles.
10843 If N is a negative number, save the N previous articles.
10844 If N is nil and any articles have been marked with the process mark,
10845 save those articles instead."
10847 (require 'gnus-art)
10848 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10849 (gnus-summary-save-article arg)))
10851 (defun gnus-summary-save-article-body-file (&optional arg)
10852 "Append the current article body to a file.
10853 If N is a positive number, save the N next articles.
10854 If N is a negative number, save the N previous articles.
10855 If N is nil and any articles have been marked with the process mark,
10856 save those articles instead."
10858 (require 'gnus-art)
10859 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10860 (gnus-summary-save-article arg)))
10862 (defun gnus-summary-muttprint (&optional arg)
10863 "Print the current article using Muttprint.
10864 If N is a positive number, save the N next articles.
10865 If N is a negative number, save the N previous articles.
10866 If N is nil and any articles have been marked with the process mark,
10867 save those articles instead."
10869 (require 'gnus-art)
10870 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10871 (gnus-summary-save-article arg t)))
10873 (defun gnus-summary-pipe-message (program)
10874 "Pipe the current article through PROGRAM."
10875 (interactive "sProgram: ")
10876 (gnus-summary-select-article)
10877 (let ((mail-header-separator ""))
10878 (gnus-eval-in-buffer-window gnus-article-buffer
10881 (let ((start (window-start))
10883 (message-pipe-buffer-body program)
10884 (set-window-start (get-buffer-window (current-buffer)) start))))))
10886 (defun gnus-get-split-value (methods)
10887 "Return a value based on the split METHODS."
10888 (let (split-name method result match)
10891 (set-buffer gnus-original-article-buffer)
10893 (nnheader-narrow-to-headers)
10894 (while (and methods (not split-name))
10895 (goto-char (point-min))
10896 (setq method (pop methods))
10897 (setq match (car method))
10900 ;; Regular expression.
10902 (re-search-forward match nil t)))
10907 (setq result (funcall match gnus-newsgroup-name))))
10912 (setq result (eval match)))))
10913 (setq split-name (cdr method))
10914 (cond ((stringp result)
10915 (push (expand-file-name
10916 result gnus-article-save-directory)
10919 (setq split-name (append result split-name)))))))))
10920 (nreverse split-name)))
10922 (defun gnus-valid-move-group-p (group)
10923 (and (boundp group)
10924 (symbol-name group)
10925 (symbol-value group)
10926 (gnus-get-function (gnus-find-method-for-group
10927 (symbol-name group)) 'request-accept-article t)))
10929 (defun gnus-read-move-group-name (prompt default articles prefix)
10930 "Read a group name."
10931 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10932 (minibuffer-confirm-incomplete nil) ; XEmacs
10934 (format "%s %s to:"
10936 (if (> (length articles) 1)
10937 (format "these %d articles" (length articles))
10942 (gnus-completing-read-with-default
10945 'gnus-valid-move-group-p
10947 'gnus-group-history))
10948 ((= 1 (length split-name))
10949 (gnus-completing-read-with-default
10950 (car split-name) prom
10952 'gnus-valid-move-group-p
10954 'gnus-group-history))
10956 (gnus-completing-read-with-default
10958 (mapcar (lambda (el) (list el))
10959 (nreverse split-name))
10961 'gnus-group-history))))
10962 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10964 (if (or (string= to-newsgroup "")
10965 (string= to-newsgroup prefix))
10966 (setq to-newsgroup default))
10967 (unless to-newsgroup
10968 (error "No group name entered"))
10969 (or (gnus-active to-newsgroup)
10970 (gnus-activate-group to-newsgroup nil nil to-method)
10971 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10973 (or (and (gnus-request-create-group to-newsgroup to-method)
10974 (gnus-activate-group
10975 to-newsgroup nil nil to-method)
10976 (gnus-subscribe-group to-newsgroup))
10977 (error "Couldn't create group %s" to-newsgroup)))
10978 (error "No such group: %s" to-newsgroup)))
10981 (defun gnus-summary-save-parts (type dir n &optional reverse)
10982 "Save parts matching TYPE to DIR.
10983 If REVERSE, save parts that do not match TYPE."
10985 (list (read-string "Save parts of type: "
10986 (or (car gnus-summary-save-parts-type-history)
10987 gnus-summary-save-parts-default-mime)
10988 'gnus-summary-save-parts-type-history)
10989 (setq gnus-summary-save-parts-last-directory
10990 (read-file-name "Save to directory: "
10991 gnus-summary-save-parts-last-directory
10993 current-prefix-arg))
10994 (gnus-summary-iterate n
10995 (let ((gnus-display-mime-function nil)
10996 (gnus-inhibit-treatment t))
10997 (gnus-summary-select-article))
10999 (set-buffer gnus-article-buffer)
11000 (let ((handles (or gnus-article-mime-handles
11001 (mm-dissect-buffer nil gnus-article-loose-mime)
11002 (and gnus-article-emulate-mime
11003 (mm-uu-dissect)))))
11005 (gnus-summary-save-parts-1 type dir handles reverse)
11006 (unless gnus-article-mime-handles ;; Don't destroy this case.
11007 (mm-destroy-parts handles)))))))
11009 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11010 (if (stringp (car handle))
11011 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11014 (not (string-match type (mm-handle-media-type handle)))
11015 (string-match type (mm-handle-media-type handle)))
11016 (let ((file (expand-file-name
11017 (file-name-nondirectory
11019 (mail-content-type-get
11020 (mm-handle-disposition handle) 'filename)
11021 (concat gnus-newsgroup-name
11022 "." (number-to-string
11023 (cdr gnus-article-current)))))
11025 (unless (file-exists-p file)
11026 (mm-save-part-to-file handle file))))))
11028 ;; Summary extract commands
11030 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11031 (let ((buffer-read-only nil)
11032 (article (gnus-summary-article-number))
11034 (unless (gnus-summary-goto-subject article)
11035 (error "No such article: %d" article))
11036 (gnus-summary-position-point)
11037 ;; If all commands are to be bunched up on one line, we collect
11039 (unless gnus-view-pseudos-separately
11040 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11043 (setq action (cdr (assq 'action (car ps))))
11044 (setq files (list (cdr (assq 'name (car ps)))))
11045 (while (and ps (cdr ps)
11046 (string= (or action "1")
11047 (or (cdr (assq 'action (cadr ps))) "2")))
11048 (push (cdr (assq 'name (cadr ps))) files)
11049 (setcdr ps (cddr ps)))
11051 (when (not (string-match "%s" action))
11054 (when (assq 'execute (car ps))
11055 (setcdr (assq 'execute (car ps))
11056 (funcall (if (string-match "%s" action)
11063 (gnus-quote-arg-for-sh-or-csh f)))
11065 (setq ps (cdr ps)))))
11066 (if (and gnus-view-pseudos (not not-view))
11068 (when (assq 'execute (car pslist))
11069 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11070 (eq gnus-view-pseudos 'not-confirm)))
11071 (setq pslist (cdr pslist)))
11074 (setq after-article (or (cdr (assq 'article (car pslist)))
11075 (gnus-summary-article-number)))
11076 (gnus-summary-goto-subject after-article)
11079 (insert " " (file-name-nondirectory
11080 (cdr (assq 'name (car pslist))))
11081 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11083 (forward-line -1) ; back to `b'
11084 (gnus-add-text-properties
11085 b (1- e) (list 'gnus-number gnus-reffed-article-number
11086 gnus-mouse-face-prop gnus-mouse-face))
11088 after-article gnus-reffed-article-number
11089 gnus-unread-mark b (car pslist) 0 (- e b))
11090 (setq gnus-newsgroup-unreads
11091 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11092 gnus-reffed-article-number))
11093 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11094 (setq pslist (cdr pslist)))))))
11096 (defun gnus-pseudos< (p1 p2)
11097 (let ((c1 (cdr (assq 'action p1)))
11098 (c2 (cdr (assq 'action p2))))
11099 (and c1 c2 (string< c1 c2))))
11101 (defun gnus-request-pseudo-article (props)
11102 (cond ((assq 'execute props)
11103 (gnus-execute-command (cdr (assq 'execute props)))))
11104 (let ((gnus-current-article (gnus-summary-article-number)))
11105 (gnus-run-hooks 'gnus-mark-article-hook)))
11107 (defun gnus-execute-command (command &optional automatic)
11109 (gnus-article-setup-buffer)
11110 (set-buffer gnus-article-buffer)
11111 (setq buffer-read-only nil)
11112 (let ((command (if automatic command
11113 (read-string "Command: " (cons command 0)))))
11115 (insert "$ " command "\n\n")
11116 (if gnus-view-pseudo-asynchronously
11117 (start-process "gnus-execute" (current-buffer) shell-file-name
11118 shell-command-switch command)
11119 (call-process shell-file-name nil t nil
11120 shell-command-switch command)))))
11122 ;; Summary kill commands.
11124 (defun gnus-summary-edit-global-kill (article)
11125 "Edit the \"global\" kill file."
11126 (interactive (list (gnus-summary-article-number)))
11127 (gnus-group-edit-global-kill article))
11129 (defun gnus-summary-edit-local-kill ()
11130 "Edit a local kill file applied to the current newsgroup."
11132 (setq gnus-current-headers (gnus-summary-article-header))
11133 (gnus-group-edit-local-kill
11134 (gnus-summary-article-number) gnus-newsgroup-name))
11136 ;;; Header reading.
11138 (defun gnus-read-header (id &optional header)
11139 "Read the headers of article ID and enter them into the Gnus system."
11140 (let ((group gnus-newsgroup-name)
11141 (gnus-override-method
11143 gnus-override-method
11144 (and (gnus-news-group-p gnus-newsgroup-name)
11145 (car (gnus-refer-article-methods)))))
11147 ;; First we check to see whether the header in question is already
11150 ;; This is a Message-ID.
11151 (setq header (or header (gnus-id-to-header id)))
11152 ;; This is an article number.
11153 (setq header (or header (gnus-summary-article-header id))))
11155 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11156 ;; We have found the header.
11158 ;; If this is a sparse article, we have to nix out its
11159 ;; previous entry in the thread hashtb.
11161 (gnus-summary-article-sparse-p (mail-header-number header)))
11162 (let* ((parent (gnus-parent-id (mail-header-references header)))
11163 (thread (and parent (gnus-id-to-thread parent))))
11165 (delq (assq header thread) thread))))
11166 ;; We have to really fetch the header to this article.
11168 (set-buffer nntp-server-buffer)
11169 (when (setq where (gnus-request-head id group))
11170 (nnheader-fold-continuation-lines)
11171 (goto-char (point-max))
11173 (goto-char (point-min))
11177 ((cdr where) (cdr where))
11178 (header (mail-header-number header))
11179 (t gnus-reffed-article-number))
11181 (insert " Article retrieved.\n"))
11182 (if (or (not where)
11183 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11184 () ; Malformed head.
11185 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11186 (when (and (stringp id)
11187 (not (string= (gnus-group-real-name group)
11189 ;; If we fetched by Message-ID and the article came
11190 ;; from a different group, we fudge some bogus article
11191 ;; numbers for this article.
11192 (mail-header-set-number header gnus-reffed-article-number))
11194 (set-buffer gnus-summary-buffer)
11195 (decf gnus-reffed-article-number)
11196 (gnus-remove-header (mail-header-number header))
11197 (push header gnus-newsgroup-headers)
11198 (setq gnus-current-headers header)
11199 (push (mail-header-number header) gnus-newsgroup-limit)))
11202 (defun gnus-remove-header (number)
11203 "Remove header NUMBER from `gnus-newsgroup-headers'."
11204 (if (and gnus-newsgroup-headers
11205 (= number (mail-header-number (car gnus-newsgroup-headers))))
11206 (pop gnus-newsgroup-headers)
11207 (let ((headers gnus-newsgroup-headers))
11208 (while (and (cdr headers)
11209 (not (= number (mail-header-number (cadr headers)))))
11211 (when (cdr headers)
11212 (setcdr headers (cddr headers))))))
11215 ;;; summary highlights
11218 (defun gnus-highlight-selected-summary ()
11219 "Highlight selected article in summary buffer."
11220 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11221 (when gnus-summary-selected-face
11223 (let* ((beg (gnus-point-at-bol))
11224 (end (gnus-point-at-eol))
11225 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11226 (from (if (get-text-property beg gnus-mouse-face-prop)
11228 (or (next-single-property-change
11229 beg gnus-mouse-face-prop nil end)
11234 (or (next-single-property-change
11235 from gnus-mouse-face-prop nil end)
11237 ;; If no mouse-face prop on line we will have to = from = end,
11238 ;; so we highlight the entire line instead.
11239 (when (= (+ to 2) from)
11242 (if gnus-newsgroup-selected-overlay
11243 ;; Move old overlay.
11245 gnus-newsgroup-selected-overlay from to (current-buffer))
11246 ;; Create new overlay.
11248 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11249 'face gnus-summary-selected-face))))))
11251 (defvar gnus-summary-highlight-line-cached nil)
11252 (defvar gnus-summary-highlight-line-trigger nil)
11254 (defun gnus-summary-highlight-line-0 ()
11255 (if (and (eq gnus-summary-highlight-line-trigger
11256 gnus-summary-highlight)
11257 gnus-summary-highlight-line-cached)
11258 gnus-summary-highlight-line-cached
11259 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11260 gnus-summary-highlight-line-cached
11261 (let* ((cond (list 'cond))
11263 (list gnus-summary-highlight))
11265 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11269 (gnus-byte-compile (list 'lambda nil cond))))))
11271 (defun gnus-summary-highlight-line ()
11272 "Highlight current line according to `gnus-summary-highlight'."
11273 (let* ((beg (gnus-point-at-bol))
11274 (article (or (gnus-summary-article-number) gnus-current-article))
11275 (score (or (cdr (assq article
11276 gnus-newsgroup-scored))
11277 gnus-summary-default-score 0))
11278 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11279 (inhibit-read-only t)
11280 (default gnus-summary-default-score)
11281 (default-high gnus-summary-default-high-score)
11282 (default-low gnus-summary-default-low-score)
11283 (uncached (memq article gnus-newsgroup-undownloaded))
11284 (downloaded (not uncached)))
11285 (let ((face (funcall (gnus-summary-highlight-line-0))))
11286 (unless (eq face (get-text-property beg 'face))
11287 (gnus-put-text-property-excluding-characters-with-faces
11288 beg (gnus-point-at-eol) 'face
11289 (setq face (if (boundp face) (symbol-value face) face)))
11290 (when gnus-summary-highlight-line-function
11291 (funcall gnus-summary-highlight-line-function article face))))))
11293 (defun gnus-update-read-articles (group unread &optional compute)
11294 "Update the list of read articles in GROUP.
11295 UNREAD is a sorted list."
11296 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11297 (entry (gnus-gethash group gnus-newsrc-hashtb))
11298 (info (nth 2 entry))
11301 (if (or (not info) (not active))
11302 ;; There is no info on this group if it was, in fact,
11303 ;; killed. Gnus stores no information on killed groups, so
11304 ;; there's nothing to be done.
11305 ;; One could store the information somewhere temporarily,
11306 ;; perhaps... Hmmm...
11308 ;; Remove any negative articles numbers.
11309 (while (and unread (< (car unread) 0))
11310 (setq unread (cdr unread)))
11311 ;; Remove any expired article numbers
11312 (while (and unread (< (car unread) (car active)))
11313 (setq unread (cdr unread)))
11314 ;; Compute the ranges of read articles by looking at the list of
11315 ;; unread articles.
11317 (when (/= (car unread) prev)
11318 (push (if (= prev (1- (car unread))) prev
11319 (cons prev (1- (car unread))))
11321 (setq prev (1+ (car unread)))
11322 (setq unread (cdr unread)))
11323 (when (<= prev (cdr active))
11324 (push (cons prev (cdr active)) read))
11325 (setq read (if (> (length read) 1) (nreverse read) read))
11330 ;; Propagate the read marks to the backend.
11331 (when (gnus-check-backend-function 'request-set-mark group)
11332 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11333 (add (gnus-remove-from-range read (gnus-info-read info))))
11335 (unless (gnus-check-group group)
11336 (error "Can't open server for %s" group))
11337 (gnus-request-set-mark
11338 group (delq nil (list (if add (list add 'add '(read)))
11339 (if del (list del 'del '(read))))))
11341 `(gnus-request-set-mark
11344 (if del (list del 'add '(read)))
11345 (if add (list add 'del '(read))))))))))
11346 (set-buffer gnus-group-buffer)
11347 (gnus-undo-register
11349 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11350 (gnus-info-set-read ',info ',(gnus-info-read info))
11351 (gnus-get-unread-articles-in-group ',info
11352 (gnus-active ,group))
11353 (gnus-group-update-group ,group t)
11355 ;; Enter this list into the group info.
11356 (gnus-info-set-read info read)
11357 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11358 (gnus-get-unread-articles-in-group info (gnus-active group))
11361 (defun gnus-offer-save-summaries ()
11362 "Offer to save all active summary buffers."
11364 ;; Go through all buffers and find all summaries.
11365 (dolist (buffer (buffer-list))
11366 (when (and (setq buffer (buffer-name buffer))
11367 (string-match "Summary" buffer)
11369 (set-buffer buffer)
11370 ;; We check that this is, indeed, a summary buffer.
11371 (and (eq major-mode 'gnus-summary-mode)
11372 ;; Also make sure this isn't bogus.
11373 gnus-newsgroup-prepared
11374 ;; Also make sure that this isn't a
11375 ;; dead summary buffer.
11376 (not gnus-dead-summary-mode))))
11377 (push buffer buffers)))
11378 ;; Go through all these summary buffers and offer to save them.
11382 "Update summary buffer %s? "
11384 (switch-to-buffer buf)
11385 (gnus-summary-exit))
11389 ;;; @ for mime-partial
11392 (defun gnus-request-partial-message ()
11394 (let ((number (gnus-summary-article-number))
11395 (group gnus-newsgroup-name)
11396 (mother gnus-article-buffer))
11397 (set-buffer (get-buffer-create " *Partial Article*"))
11399 (setq mime-preview-buffer mother)
11400 (gnus-request-article-this-buffer number group)
11401 (mime-parse-buffer)
11404 (autoload 'mime-combine-message/partial-pieces-automatically
11406 "Internal method to combine message/partial messages automatically.")
11408 (mime-add-condition
11409 'action '((type . message)(subtype . partial)
11410 (major-mode . gnus-original-article-mode)
11411 (method . mime-combine-message/partial-pieces-automatically)
11412 (summary-buffer-exp . gnus-summary-buffer)
11413 (request-partial-message-method . gnus-request-partial-message)
11417 ;;; @ for message/rfc822
11420 (defun gnus-mime-extract-message/rfc822 (entity situation)
11421 "Burst a forwarded article."
11423 (set-buffer gnus-summary-buffer)
11424 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11425 gnus-newsgroup-name 'gnus-group-history))
11426 (gnus-group-marked (list group))
11429 (mime-insert-entity-content entity)
11430 (setq article (gnus-request-accept-article group)))
11431 (when (and (consp article)
11432 (numberp (setq article (cdr article))))
11433 (setq info (gnus-get-info group))
11434 (gnus-info-set-read info
11435 (gnus-remove-from-range (gnus-info-read info)
11437 (when (string-equal group gnus-newsgroup-name)
11439 (let (gnus-show-threads)
11440 (gnus-summary-goto-subject article t))
11441 (gnus-summary-clear-mark-forward 1))
11442 (set-buffer gnus-group-buffer)
11443 (gnus-group-get-new-news-this-group nil t)))))
11445 (mime-add-condition
11446 'action '((type . message)(subtype . rfc822)
11447 (major-mode . gnus-original-article-mode)
11448 (method . gnus-mime-extract-message/rfc822)
11452 (mime-add-condition
11453 'action '((type . message)(subtype . news)
11454 (major-mode . gnus-original-article-mode)
11455 (method . gnus-mime-extract-message/rfc822)
11459 (defun gnus-mime-extract-multipart (entity situation)
11460 (let ((children (mime-entity-children entity))
11461 mime-acting-situation-to-override
11464 (mime-play-entity (car children)
11465 (cons (assq 'mode situation)
11466 mime-acting-situation-to-override))
11467 (setq children (cdr children)))
11468 (if (setq f (cdr (assq 'after-method
11469 mime-acting-situation-to-override)))
11473 (mime-add-condition
11474 'action '((type . multipart)
11475 (method . gnus-mime-extract-multipart)
11484 (defun gnus-summary-inherit-default-charset ()
11485 "Import `default-mime-charset' from summary buffer.
11486 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11488 (if (buffer-live-p gnus-summary-buffer)
11489 (let (d-m-c d-m-c-u)
11490 (with-current-buffer gnus-summary-buffer
11491 (setq d-m-c (if (local-variable-p 'default-mime-charset
11492 gnus-summary-buffer)
11493 default-mime-charset
11496 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11497 gnus-summary-buffer)
11498 (symbol-value 'default-mime-charset-unlimited)
11501 (kill-local-variable 'default-mime-charset)
11502 (set (make-local-variable 'default-mime-charset) d-m-c))
11504 (kill-local-variable 'default-mime-charset-unlimited)
11505 (set (make-local-variable 'default-mime-charset-unlimited)
11508 (defun gnus-summary-setup-default-charset ()
11509 "Setup newsgroup default charset."
11510 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11512 (setq gnus-newsgroup-charset nil)
11513 (set (make-local-variable 'default-mime-charset) nil)
11514 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11515 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11516 (let ((ignored-charsets
11517 (or gnus-newsgroup-ephemeral-ignored-charsets
11519 (and gnus-newsgroup-name
11520 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11521 gnus-newsgroup-ignored-charsets)))
11523 (setq gnus-newsgroup-charset
11524 (or gnus-newsgroup-ephemeral-charset
11525 (when (and gnus-newsgroup-name
11526 (setq charset (gnus-parameter-charset
11527 gnus-newsgroup-name)))
11528 (make-local-variable 'default-mime-charset)
11529 (setq default-mime-charset charset))
11530 gnus-default-charset))
11531 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11532 ignored-charsets))))
11538 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11539 "Display the current article buffer fully MIME-buttonized.
11540 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11541 treated as multipart/mixed."
11543 (require 'gnus-art)
11544 (let ((gnus-unbuttonized-mime-types nil)
11545 (gnus-mime-display-multipart-as-mixed show-all-parts))
11546 (gnus-summary-show-article)))
11548 (defun gnus-summary-repair-multipart (article)
11549 "Add a Content-Type header to a multipart article without one."
11550 (interactive (list (gnus-summary-article-number)))
11551 (gnus-with-article article
11552 (message-narrow-to-head)
11553 (message-remove-header "Mime-Version")
11554 (goto-char (point-max))
11555 (insert "Mime-Version: 1.0\n")
11557 (when (search-forward "\n--" nil t)
11558 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11559 (message-narrow-to-head)
11560 (message-remove-header "Content-Type")
11561 (goto-char (point-max))
11562 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11565 (let (gnus-mark-article-hook)
11566 (gnus-summary-select-article t t nil article)))
11568 (defun gnus-summary-toggle-display-buttonized ()
11569 "Toggle the buttonizing of the article buffer."
11571 (require 'gnus-art)
11572 (if (setq gnus-inhibit-mime-unbuttonizing
11573 (not gnus-inhibit-mime-unbuttonizing))
11574 (let ((gnus-unbuttonized-mime-types nil))
11575 (gnus-summary-show-article))
11576 (gnus-summary-show-article)))
11579 ;;; Intelli-mouse commmands
11582 (defun gnus-wheel-summary-scroll (event)
11584 (let ((amount (if (memq 'shift (event-modifiers event))
11585 (car gnus-wheel-scroll-amount)
11586 (cdr gnus-wheel-scroll-amount)))
11587 (direction (- (* (static-if (featurep 'xemacs)
11588 (event-button event)
11589 (cond ((eq 'mouse-4 (event-basic-type event))
11591 ((eq 'mouse-5 (event-basic-type event))
11595 (gnus-summary-scroll-up (* amount direction))
11596 (when (gnus-eval-in-buffer-window gnus-article-buffer
11599 (and (if (< 0 direction)
11600 (gnus-article-next-page 0)
11601 (gnus-article-prev-page 0)
11603 (if (setq edge (get-text-property
11604 (point-min) 'gnus-wheel-edge))
11605 (setq edge (* edge direction))
11608 (let ((buffer-read-only nil)
11609 (inhibit-read-only t))
11610 (put-text-property (point-min) (point-max)
11611 'gnus-wheel-edge direction)
11613 (or (> edge gnus-wheel-edge-resistance)
11614 (let ((buffer-read-only nil)
11615 (inhibit-read-only t))
11616 (put-text-property (point-min) (point-max)
11618 (* (1+ edge) direction))
11620 (eq last-command 'gnus-wheel-summary-scroll))))
11621 (gnus-summary-next-article nil nil (minusp direction)))))
11623 (defun gnus-wheel-install ()
11624 "Enable mouse wheel support on summary window."
11625 (when gnus-use-wheel
11627 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11629 (define-key gnus-summary-mode-map key
11630 'gnus-wheel-summary-scroll)))))
11632 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11635 ;;; Traditional PGP commmands
11638 (defun gnus-summary-decrypt-article (&optional force)
11639 "Decrypt the current article in traditional PGP way.
11640 This will have permanent effect only in mail groups.
11641 If FORCE is non-nil, allow editing of articles even in read-only
11644 (gnus-summary-select-article t)
11645 (gnus-eval-in-buffer-window gnus-article-buffer
11649 (goto-char (point-min))
11650 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11651 (error "Not a traditional PGP message!"))
11652 (let ((armor-start (match-beginning 0)))
11653 (if (and (pgg-decrypt-region armor-start (point-max))
11654 (or force (not (gnus-group-read-only-p))))
11655 (let ((inhibit-read-only t)
11657 (delete-region armor-start
11659 (re-search-forward "^-+END PGP" nil t)
11660 (beginning-of-line 2)
11662 (insert-buffer-substring pgg-output-buffer))))))))
11664 (defun gnus-summary-verify-article ()
11665 "Verify the current article in traditional PGP way."
11668 (set-buffer gnus-original-article-buffer)
11669 (goto-char (point-min))
11670 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11671 (error "Not a traditional PGP message!"))
11672 (re-search-forward "^-+END PGP" nil t)
11673 (beginning-of-line 2)
11674 (call-interactively (function pgg-verify-region))))
11677 ;;; Generic summary marking commands
11680 (defvar gnus-summary-marking-alist
11681 '((read gnus-del-mark "d")
11682 (unread gnus-unread-mark "u")
11683 (ticked gnus-ticked-mark "!")
11684 (dormant gnus-dormant-mark "?")
11685 (expirable gnus-expirable-mark "e"))
11686 "An alist of names/marks/keystrokes.")
11688 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11689 (defvar gnus-summary-mark-map)
11691 (defun gnus-summary-make-all-marking-commands ()
11692 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11693 (dolist (elem gnus-summary-marking-alist)
11694 (apply 'gnus-summary-make-marking-command elem)))
11696 (defun gnus-summary-make-marking-command (name mark keystroke)
11697 (let ((map (make-sparse-keymap)))
11698 (define-key gnus-summary-generic-mark-map keystroke map)
11699 (dolist (lway `((next "next" next nil "n")
11700 (next-unread "next unread" next t "N")
11701 (prev "previous" prev nil "p")
11702 (prev-unread "previous unread" prev t "P")
11703 (nomove "" nil nil ,keystroke)))
11704 (let ((func (gnus-summary-make-marking-command-1
11705 mark (car lway) lway name)))
11706 (setq func (eval func))
11707 (define-key map (nth 4 lway) func)))))
11709 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11711 (format "gnus-summary-put-mark-as-%s%s"
11712 name (if (eq way 'nomove)
11714 (concat "-" (symbol-name way)))))
11717 "Mark the current article as %s%s.
11718 If N, the prefix, then repeat N times.
11719 If N is negative, move in reverse order.
11720 The difference between N and the actual number of articles marked is
11722 name (car (cdr lway)))
11724 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11726 (defun gnus-summary-generic-mark (n mark move unread)
11727 "Mark N articles with MARK."
11728 (unless (eq major-mode 'gnus-summary-mode)
11729 (error "This command can only be used in the summary buffer"))
11730 (gnus-summary-show-thread)
11733 ((eq move 'next) 1)
11734 ((eq move 'prev) -1)
11736 (if (zerop nummove)
11740 nummove (* -1 nummove))))
11741 (while (and (> n 0)
11742 (gnus-summary-mark-article nil mark)
11743 (zerop (gnus-summary-next-subject nummove unread t)))
11746 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11747 (gnus-summary-recenter)
11748 (gnus-summary-position-point)
11749 (gnus-set-mode-line 'summary)
11752 (defun gnus-summary-insert-articles (articles)
11753 (when (setq articles
11754 (gnus-sorted-difference articles
11755 (mapcar (lambda (h)
11756 (mail-header-number h))
11757 gnus-newsgroup-headers)))
11758 (setq gnus-newsgroup-headers
11760 gnus-newsgroup-headers
11761 (gnus-fetch-headers articles)
11762 'gnus-article-sort-by-number))
11763 ;; Suppress duplicates?
11764 (when gnus-suppress-duplicates
11765 (gnus-dup-suppress-articles))
11767 ;; We might want to build some more threads first.
11768 (when (and gnus-fetch-old-headers
11769 (eq gnus-headers-retrieved-by 'nov))
11770 (if (eq gnus-fetch-old-headers 'invisible)
11771 (gnus-build-all-threads)
11772 (gnus-build-old-threads)))
11773 ;; Let the Gnus agent mark articles as read.
11775 (gnus-agent-get-undownloaded-list))
11776 ;; Remove list identifiers from subject
11777 (when gnus-list-identifiers
11778 (gnus-summary-remove-list-identifiers))
11779 ;; First and last article in this newsgroup.
11780 (when gnus-newsgroup-headers
11781 (setq gnus-newsgroup-begin
11782 (mail-header-number (car gnus-newsgroup-headers))
11784 (mail-header-number
11785 (gnus-last-element gnus-newsgroup-headers))))
11786 (when gnus-use-scoring
11787 (gnus-possibly-score-headers))))
11789 (defun gnus-summary-insert-old-articles (&optional all)
11790 "Insert all old articles in this group.
11791 If ALL is non-nil, already read articles become readable.
11792 If ALL is a number, fetch this number of articles."
11795 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11798 ;; Some nntp servers lie about their active range. When
11799 ;; this happens, the active range can be in the millions.
11800 ;; Use a compressed range to avoid creating a huge list.
11801 (gnus-range-difference (list gnus-newsgroup-active) old))
11802 (setq len (gnus-range-length older))
11807 (let ((older-range (nreverse older)))
11811 (let* ((r (pop older-range))
11812 (min (if (numberp r) r (car r)))
11813 (max (if (numberp r) r (cdr r))))
11814 (while (and (<= min max)
11819 (setq older (gnus-uncompress-range older))))
11821 (setq older (gnus-uncompress-range older)))
11823 (when (and (numberp gnus-large-newsgroup)
11824 (> len gnus-large-newsgroup))
11825 (let* ((cursor-in-echo-area nil)
11826 (initial (gnus-parameter-large-newsgroup-initial
11827 gnus-newsgroup-name))
11831 "How many articles from %s (%s %d): "
11833 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11834 (if initial "max" "default")
11837 (cons (number-to-string initial)
11839 (unless (string-match "^[ \t]*$" input)
11840 (setq all (string-to-number input))
11842 (let ((older-range (nreverse older)))
11846 (let* ((r (pop older-range))
11847 (min (if (numberp r) r (car r)))
11848 (max (if (numberp r) r (cdr r))))
11849 (while (and (<= min max)
11853 max (1- max))))))))))
11854 (setq older (gnus-uncompress-range older))))
11856 (message "No old news.")
11857 (gnus-summary-insert-articles older)
11858 (gnus-summary-limit (gnus-sorted-nunion old older))))
11859 (gnus-summary-position-point)))
11861 (defun gnus-summary-insert-new-articles ()
11862 "Insert all new articles in this group."
11865 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11866 (old-active gnus-newsgroup-active)
11867 (nnmail-fetched-sources (list t))
11869 (setq gnus-newsgroup-active
11870 (gnus-activate-group gnus-newsgroup-name 'scan))
11871 (setq i (cdr gnus-newsgroup-active))
11872 (while (> i (cdr old-active))
11876 (message "No gnus is bad news.")
11877 (gnus-summary-insert-articles new)
11878 (setq gnus-newsgroup-unreads
11879 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11880 (gnus-summary-limit (gnus-sorted-nunion old new))))
11881 (gnus-summary-position-point)))
11883 (gnus-summary-make-all-marking-commands)
11885 (gnus-ems-redefine)
11887 (provide 'gnus-sum)
11889 (run-hooks 'gnus-sum-load-hook)
11891 ;; Local Variables:
11892 ;; coding: iso-8859-1
11895 ;;; gnus-sum.el ends here