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.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'mm-uu-dissect "mm-uu")
57 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
60 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
61 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
62 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
64 (defcustom gnus-kill-summary-on-exit t
65 "*If non-nil, kill the summary buffer when you exit from it.
66 If nil, the summary will become a \"*Dead Summary*\" buffer, and
67 it will be killed sometime later."
68 :group 'gnus-summary-exit
71 (defcustom gnus-fetch-old-headers nil
72 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
73 If an unread article in the group refers to an older, already read (or
74 just marked as read) article, the old article will not normally be
75 displayed in the Summary buffer. If this variable is non-nil, Gnus
76 will attempt to grab the headers to the old articles, and thereby
77 build complete threads. If it has the value `some', only enough
78 headers to connect otherwise loose threads will be displayed. This
79 variable can also be a number. In that case, no more than that number
80 of old headers will be fetched. If it has the value `invisible', all
81 old headers will be fetched, but none will be displayed.
83 The server has to support NOV for any of this to work."
85 :type '(choice (const :tag "off" nil)
88 (sexp :menu-tag "other" t)))
90 (defcustom gnus-refer-thread-limit 200
91 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
92 If t, fetch all the available old headers."
95 (sexp :menu-tag "other" t)))
97 (defcustom gnus-summary-make-false-root 'adopt
98 "*nil means that Gnus won't gather loose threads.
99 If the root of a thread has expired or been read in a previous
100 session, the information necessary to build a complete thread has been
101 lost. Instead of having many small sub-threads from this original thread
102 scattered all over the summary buffer, Gnus can gather them.
104 If non-nil, Gnus will try to gather all loose sub-threads from an
105 original thread into one large thread.
107 If this variable is non-nil, it should be one of `none', `adopt',
110 If this variable is `none', Gnus will not make a false root, but just
111 present the sub-threads after another.
112 If this variable is `dummy', Gnus will create a dummy root that will
113 have all the sub-threads as children.
114 If this variable is `adopt', Gnus will make one of the \"children\"
115 the parent and mark all the step-children as such.
116 If this variable is `empty', the \"children\" are printed with empty
117 subject fields. (Or rather, they will be printed with a string
118 given by the `gnus-summary-same-subject' variable.)"
120 :type '(choice (const :tag "off" nil)
126 (defcustom gnus-summary-make-false-root-always nil
127 "Always make a false dummy root."
131 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
132 "*A regexp to match subjects to be excluded from loose thread gathering.
133 As loose thread gathering is done on subjects only, that means that
134 there can be many false gatherings performed. By rooting out certain
135 common subjects, gathering might become saner."
139 (defcustom gnus-summary-gather-subject-limit nil
140 "*Maximum length of subject comparisons when gathering loose threads.
141 Use nil to compare full subjects. Setting this variable to a low
142 number will help gather threads that have been corrupted by
143 newsreaders chopping off subject lines, but it might also mean that
144 unrelated articles that have subject that happen to begin with the
145 same few characters will be incorrectly gathered.
147 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
150 :type '(choice (const :tag "off" nil)
152 (sexp :menu-tag "on" t)))
154 (defcustom gnus-simplify-subject-functions nil
155 "List of functions taking a string argument that simplify subjects.
156 The functions are applied recursively.
158 Useful functions to put in this list include:
159 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
160 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
162 :type '(repeat function))
164 (defcustom gnus-simplify-ignored-prefixes nil
165 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
167 :type '(choice (const :tag "off" nil)
170 (defcustom gnus-build-sparse-threads nil
171 "*If non-nil, fill in the gaps in threads.
172 If `some', only fill in the gaps that are needed to tie loose threads
173 together. If `more', fill in all leaf nodes that Gnus can find. If
174 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
176 :type '(choice (const :tag "off" nil)
179 (sexp :menu-tag "all" t)))
181 (defcustom gnus-summary-thread-gathering-function
182 'gnus-gather-threads-by-subject
183 "*Function used for gathering loose threads.
184 There are two pre-defined functions: `gnus-gather-threads-by-subject',
185 which only takes Subjects into consideration; and
186 `gnus-gather-threads-by-references', which compared the References
187 headers of the articles to find matches."
189 :type '(radio (function-item gnus-gather-threads-by-subject)
190 (function-item gnus-gather-threads-by-references)
191 (function :tag "other")))
193 (defcustom gnus-summary-same-subject ""
194 "*String indicating that the current article has the same subject as the previous.
195 This variable will only be used if the value of
196 `gnus-summary-make-false-root' is `empty'."
197 :group 'gnus-summary-format
200 (defcustom gnus-summary-goto-unread t
201 "*If t, many commands will go to the next unread article.
202 This applies to marking commands as well as other commands that
203 \"naturally\" select the next article, like, for instance, `SPC' at
204 the end of an article.
206 If nil, the marking commands do NOT go to the next unread article
207 \(they go to the next article instead). If `never', commands that
208 usually go to the next unread article, will go to the next article,
209 whether it is read or not."
210 :group 'gnus-summary-marks
211 :link '(custom-manual "(gnus)Setting Marks")
212 :type '(choice (const :tag "off" nil)
214 (sexp :menu-tag "on" t)))
216 (defcustom gnus-summary-default-score 0
217 "*Default article score level.
218 All scores generated by the score files will be added to this score.
219 If this variable is nil, scoring will be disabled."
220 :group 'gnus-score-default
221 :type '(choice (const :tag "disable")
224 (defcustom gnus-summary-default-high-score 0
225 "*Default threshold for a high scored article.
226 An article will be highlighted as high scored if its score is greater
228 :group 'gnus-score-default
231 (defcustom gnus-summary-default-low-score 0
232 "*Default threshold for a low scored article.
233 An article will be highlighted as low scored if its score is smaller
235 :group 'gnus-score-default
238 (defcustom gnus-summary-zcore-fuzz 0
239 "*Fuzziness factor for the zcore in the summary buffer.
240 Articles with scores closer than this to `gnus-summary-default-score'
242 :group 'gnus-summary-format
245 (defcustom gnus-simplify-subject-fuzzy-regexp nil
246 "*Strings to be removed when doing fuzzy matches.
247 This can either be a regular expression or list of regular expressions
248 that will be removed from subject strings if fuzzy subject
249 simplification is selected."
251 :type '(repeat regexp))
253 (defcustom gnus-show-threads t
254 "*If non-nil, display threads in summary mode."
258 (defcustom gnus-thread-hide-subtree nil
259 "*If non-nil, hide all threads initially.
260 This can be a predicate specifier which says which threads to hide.
261 If threads are hidden, you have to run the command
262 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
263 to expose hidden threads."
267 (defcustom gnus-thread-hide-killed t
268 "*If non-nil, hide killed threads automatically."
272 (defcustom gnus-thread-ignore-subject t
273 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
274 If nil, articles that have different subjects from their parents will
275 start separate threads."
279 (defcustom gnus-thread-operation-ignore-subject t
280 "*If non-nil, subjects will be ignored when doing thread commands.
281 This affects commands like `gnus-summary-kill-thread' and
282 `gnus-summary-lower-thread'.
284 If this variable is nil, articles in the same thread with different
285 subjects will not be included in the operation in question. If this
286 variable is `fuzzy', only articles that have subjects that are fuzzily
287 equal will be included."
289 :type '(choice (const :tag "off" nil)
293 (defcustom gnus-thread-indent-level 4
294 "*Number that says how much each sub-thread should be indented."
298 (defcustom gnus-auto-extend-newsgroup t
299 "*If non-nil, extend newsgroup forward and backward when requested."
300 :group 'gnus-summary-choose
303 (defcustom gnus-auto-select-first t
304 "*If non-nil, select the article under point.
305 Which article this is is controlled by the `gnus-auto-select-subject'
308 If you want to prevent automatic selection of articles in some
309 newsgroups, set the variable to nil in `gnus-select-group-hook'."
310 :group 'gnus-group-select
311 :type '(choice (const :tag "none" nil)
312 (sexp :menu-tag "first" t)))
314 (defcustom gnus-auto-select-subject 'unread
315 "*Says what subject to place under point when entering a group.
317 This variable can either be the symbols `first' (place point on the
318 first subject), `unread' (place point on the subject line of the first
319 unread article), `best' (place point on the subject line of the
320 higest-scored article), `unseen' (place point on the subject line of
321 the first unseen article), 'unseen-or-unread' (place point on the subject
322 line of the first unseen article or, if all article have been seen, on the
323 subject line of the first unread article), or a function to be called to
324 place point on some subject line."
325 :group 'gnus-group-select
326 :type '(choice (const best)
330 (const unseen-or-unread)))
332 (defcustom gnus-dont-select-after-jump-to-other-group nil
333 "If non-nil, don't select the first unread article after entering the
334 other group by the command `gnus-summary-jump-to-other-group'. If nil,
335 it is depend on the value of `gnus-auto-select-first' whether to select
337 :group 'gnus-group-select
340 (defcustom gnus-auto-select-next t
341 "*If non-nil, offer to go to the next group from the end of the previous.
342 If the value is t and the next newsgroup is empty, Gnus will exit
343 summary mode and go back to group mode. If the value is neither nil
344 nor t, Gnus will select the following unread newsgroup. In
345 particular, if the value is the symbol `quietly', the next unread
346 newsgroup will be selected without any confirmation, and if it is
347 `almost-quietly', the next group will be selected without any
348 confirmation if you are located on the last article in the group.
349 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
350 will go to the next group without confirmation."
351 :group 'gnus-summary-maneuvering
352 :type '(choice (const :tag "off" nil)
354 (const almost-quietly)
355 (const slightly-quietly)
356 (sexp :menu-tag "on" t)))
358 (defcustom gnus-auto-select-same nil
359 "*If non-nil, select the next article with the same subject.
360 If there are no more articles with the same subject, go to
361 the first unread article."
362 :group 'gnus-summary-maneuvering
365 (defcustom gnus-summary-check-current nil
366 "*If non-nil, consider the current article when moving.
367 The \"unread\" movement commands will stay on the same line if the
368 current article is unread."
369 :group 'gnus-summary-maneuvering
372 (defcustom gnus-auto-center-summary t
373 "*If non-nil, always center the current summary buffer.
374 In particular, if `vertical' do only vertical recentering. If non-nil
375 and non-`vertical', do both horizontal and vertical recentering."
376 :group 'gnus-summary-maneuvering
377 :type '(choice (const :tag "none" nil)
379 (integer :tag "height")
380 (sexp :menu-tag "both" t)))
382 (defvar gnus-auto-center-group t
383 "*If non-nil, always center the group buffer.")
385 (defcustom gnus-show-all-headers nil
386 "*If non-nil, don't hide any headers."
387 :group 'gnus-article-hiding
388 :group 'gnus-article-headers
391 (defcustom gnus-summary-ignore-duplicates nil
392 "*If non-nil, ignore articles with identical Message-ID headers."
396 (defcustom gnus-single-article-buffer t
397 "*If non-nil, display all articles in the same buffer.
398 If nil, each group will get its own article buffer."
399 :group 'gnus-article-various
402 (defcustom gnus-break-pages t
403 "*If non-nil, do page breaking on articles.
404 The page delimiter is specified by the `gnus-page-delimiter'
406 :group 'gnus-article-various
409 (defcustom gnus-show-mime t
410 "*If non-nil, do mime processing of articles.
411 The articles will simply be fed to the function given by
412 `gnus-article-display-method-for-mime'."
413 :group 'gnus-article-mime
416 (defcustom gnus-move-split-methods nil
417 "*Variable used to suggest where articles are to be moved to.
418 It uses the same syntax as the `gnus-split-methods' variable.
419 However, whereas `gnus-split-methods' specifies file names as targets,
420 this variable specifies group names."
421 :group 'gnus-summary-mail
422 :type '(repeat (choice (list :value (fun) function)
423 (cons :value ("" "") regexp (repeat string))
426 (defcustom gnus-unread-mark ?\ ;;;Whitespace
427 "*Mark used for unread articles."
428 :group 'gnus-summary-marks
431 (defcustom gnus-ticked-mark ?!
432 "*Mark used for ticked articles."
433 :group 'gnus-summary-marks
436 (defcustom gnus-dormant-mark ??
437 "*Mark used for dormant articles."
438 :group 'gnus-summary-marks
441 (defcustom gnus-del-mark ?r
442 "*Mark used for del'd articles."
443 :group 'gnus-summary-marks
446 (defcustom gnus-read-mark ?R
447 "*Mark used for read articles."
448 :group 'gnus-summary-marks
451 (defcustom gnus-expirable-mark ?E
452 "*Mark used for expirable articles."
453 :group 'gnus-summary-marks
456 (defcustom gnus-killed-mark ?K
457 "*Mark used for killed articles."
458 :group 'gnus-summary-marks
461 (defcustom gnus-spam-mark ?$
462 "*Mark used for spam articles."
463 :group 'gnus-summary-marks
466 (defcustom gnus-souped-mark ?F
467 "*Mark used for souped articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-kill-file-mark ?X
472 "*Mark used for articles killed by kill files."
473 :group 'gnus-summary-marks
476 (defcustom gnus-low-score-mark ?Y
477 "*Mark used for articles with a low score."
478 :group 'gnus-summary-marks
481 (defcustom gnus-catchup-mark ?C
482 "*Mark used for articles that are caught up."
483 :group 'gnus-summary-marks
486 (defcustom gnus-replied-mark ?A
487 "*Mark used for articles that have been replied to."
488 :group 'gnus-summary-marks
491 (defcustom gnus-forwarded-mark ?F
492 "*Mark used for articles that have been forwarded."
493 :group 'gnus-summary-marks
496 (defcustom gnus-recent-mark ?N
497 "*Mark used for articles that are recent."
498 :group 'gnus-summary-marks
501 (defcustom gnus-cached-mark ?*
502 "*Mark used for articles that are in the cache."
503 :group 'gnus-summary-marks
506 (defcustom gnus-saved-mark ?S
507 "*Mark used for articles that have been saved."
508 :group 'gnus-summary-marks
511 (defcustom gnus-unseen-mark ?.
512 "*Mark used for articles that haven't been seen."
513 :group 'gnus-summary-marks
516 (defcustom gnus-no-mark ?\ ;;;Whitespace
517 "*Mark used for articles that have no other secondary mark."
518 :group 'gnus-summary-marks
521 (defcustom gnus-ancient-mark ?O
522 "*Mark used for ancient articles."
523 :group 'gnus-summary-marks
526 (defcustom gnus-sparse-mark ?Q
527 "*Mark used for sparsely reffed articles."
528 :group 'gnus-summary-marks
531 (defcustom gnus-canceled-mark ?G
532 "*Mark used for canceled articles."
533 :group 'gnus-summary-marks
536 (defcustom gnus-duplicate-mark ?M
537 "*Mark used for duplicate articles."
538 :group 'gnus-summary-marks
541 (defcustom gnus-undownloaded-mark ?-
542 "*Mark used for articles that weren't downloaded."
543 :group 'gnus-summary-marks
546 (defcustom gnus-downloaded-mark ?+
547 "*Mark used for articles that were downloaded."
548 :group 'gnus-summary-marks
551 (defcustom gnus-downloadable-mark ?%
552 "*Mark used for articles that are to be downloaded."
553 :group 'gnus-summary-marks
556 (defcustom gnus-unsendable-mark ?=
557 "*Mark used for articles that won't be sent."
558 :group 'gnus-summary-marks
561 (defcustom gnus-score-over-mark ?+
562 "*Score mark used for articles with high scores."
563 :group 'gnus-summary-marks
566 (defcustom gnus-score-below-mark ?-
567 "*Score mark used for articles with low scores."
568 :group 'gnus-summary-marks
571 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
572 "*There is no thread under the article."
573 :group 'gnus-summary-marks
576 (defcustom gnus-not-empty-thread-mark ?=
577 "*There is a thread under the article."
578 :group 'gnus-summary-marks
581 (defcustom gnus-view-pseudo-asynchronously nil
582 "*If non-nil, Gnus will view pseudo-articles asynchronously."
583 :group 'gnus-extract-view
586 (defcustom gnus-auto-expirable-marks
587 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
588 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
589 gnus-souped-mark gnus-duplicate-mark)
590 "*The list of marks converted into expiration if a group is auto-expirable."
593 :type '(repeat character))
595 (defcustom gnus-inhibit-user-auto-expire t
596 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
601 (defcustom gnus-view-pseudos nil
602 "*If `automatic', pseudo-articles will be viewed automatically.
603 If `not-confirm', pseudos will be viewed automatically, and the user
604 will not be asked to confirm the command."
605 :group 'gnus-extract-view
606 :type '(choice (const :tag "off" nil)
608 (const not-confirm)))
610 (defcustom gnus-view-pseudos-separately t
611 "*If non-nil, one pseudo-article will be created for each file to be viewed.
612 If nil, all files that use the same viewing command will be given as a
613 list of parameters to that command."
614 :group 'gnus-extract-view
617 (defcustom gnus-insert-pseudo-articles t
618 "*If non-nil, insert pseudo-articles when decoding articles."
619 :group 'gnus-extract-view
622 (defcustom gnus-summary-dummy-line-format
624 "*The format specification for the dummy roots in the summary buffer.
625 It works along the same lines as a normal formatting string,
626 with some simple extensions.
630 General format specifiers can also be used.
631 See `(gnus)Formatting Variables'."
632 :link '(custom-manual "(gnus)Formatting Variables")
633 :group 'gnus-threading
636 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
637 "*The format specification for the summary mode line.
638 It works along the same lines as a normal formatting string,
639 with some simple extensions:
642 %p Unprefixed group name
643 %A Current article number
644 %z Current article score
646 %U Number of unread articles in the group
647 %e Number of unselected articles in the group
648 %Z A string with unread/unselected article counts
649 %g Shortish group name
650 %S Subject of the current article
652 %s Current score file name
653 %d Number of dormant articles
654 %r Number of articles that have been marked as read in this session
655 %E Number of articles expunged by the score files"
656 :group 'gnus-summary-format
659 (defcustom gnus-list-identifiers nil
660 "Regexp that matches list identifiers to be removed from subject.
661 This can also be a list of regexps."
663 :group 'gnus-summary-format
664 :group 'gnus-article-hiding
665 :type '(choice (const :tag "none" nil)
667 (repeat :value (".*") regexp)))
669 (defcustom gnus-summary-mark-below 0
670 "*Mark all articles with a score below this variable as read.
671 This variable is local to each summary buffer and usually set by the
673 :group 'gnus-score-default
676 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
677 "*List of functions used for sorting articles in the summary buffer.
679 Each function takes two articles and returns non-nil if the first
680 article should be sorted before the other. If you use more than one
681 function, the primary sort function should be the last. You should
682 probably always include `gnus-article-sort-by-number' in the list of
683 sorting functions -- preferably first. Also note that sorting by date
684 is often much slower than sorting by number, and the sorting order is
685 very similar. (Sorting by date means sorting by the time the message
686 was sent, sorting by number means sorting by arrival time.)
688 Ready-made functions include `gnus-article-sort-by-number',
689 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
690 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
691 and `gnus-article-sort-by-score'.
693 When threading is turned on, the variable `gnus-thread-sort-functions'
694 controls how articles are sorted."
695 :group 'gnus-summary-sort
696 :type '(repeat (choice (function-item gnus-article-sort-by-number)
697 (function-item gnus-article-sort-by-author)
698 (function-item gnus-article-sort-by-subject)
699 (function-item gnus-article-sort-by-date)
700 (function-item gnus-article-sort-by-score)
701 (function-item gnus-article-sort-by-random)
702 (function :tag "other"))))
704 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
705 "*List of functions used for sorting threads in the summary buffer.
706 By default, threads are sorted by article number.
708 Each function takes two threads and returns non-nil if the first
709 thread should be sorted before the other. If you use more than one
710 function, the primary sort function should be the last. You should
711 probably always include `gnus-thread-sort-by-number' in the list of
712 sorting functions -- preferably first. Also note that sorting by date
713 is often much slower than sorting by number, and the sorting order is
714 very similar. (Sorting by date means sorting by the time the message
715 was sent, sorting by number means sorting by arrival time.)
717 Ready-made functions include `gnus-thread-sort-by-number',
718 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
719 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
720 `gnus-thread-sort-by-most-recent-number',
721 `gnus-thread-sort-by-most-recent-date',
722 `gnus-thread-sort-by-random', and
723 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
725 When threading is turned off, the variable
726 `gnus-article-sort-functions' controls how articles are sorted."
727 :group 'gnus-summary-sort
728 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
729 (function-item gnus-thread-sort-by-author)
730 (function-item gnus-thread-sort-by-subject)
731 (function-item gnus-thread-sort-by-date)
732 (function-item gnus-thread-sort-by-score)
733 (function-item gnus-thread-sort-by-total-score)
734 (function-item gnus-thread-sort-by-random)
735 (function :tag "other"))))
737 (defcustom gnus-thread-score-function '+
738 "*Function used for calculating the total score of a thread.
740 The function is called with the scores of the article and each
741 subthread and should then return the score of the thread.
743 Some functions you can use are `+', `max', or `min'."
744 :group 'gnus-summary-sort
747 (defcustom gnus-summary-expunge-below nil
748 "All articles that have a score less than this variable will be expunged.
749 This variable is local to the summary buffers."
750 :group 'gnus-score-default
751 :type '(choice (const :tag "off" nil)
754 (defcustom gnus-thread-expunge-below nil
755 "All threads that have a total score less than this variable will be expunged.
756 See `gnus-thread-score-function' for en explanation of what a
759 This variable is local to the summary buffers."
760 :group 'gnus-threading
761 :group 'gnus-score-default
762 :type '(choice (const :tag "off" nil)
765 (defcustom gnus-summary-mode-hook nil
766 "*A hook for Gnus summary mode.
767 This hook is run before any variables are set in the summary buffer."
768 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
769 :group 'gnus-summary-various
772 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
773 (when (featurep 'xemacs)
774 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
775 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
776 (add-hook 'gnus-summary-mode-hook
777 'gnus-xmas-switch-horizontal-scrollbar-off))
779 (defcustom gnus-summary-menu-hook nil
780 "*Hook run after the creation of the summary mode menu."
781 :group 'gnus-summary-visual
784 (defcustom gnus-summary-exit-hook nil
785 "*A hook called on exit from the summary buffer.
786 It will be called with point in the group buffer."
787 :group 'gnus-summary-exit
790 (defcustom gnus-summary-prepare-hook nil
791 "*A hook called after the summary buffer has been generated.
792 If you want to modify the summary buffer, you can use this hook."
793 :group 'gnus-summary-various
796 (defcustom gnus-summary-prepared-hook nil
797 "*A hook called as the last thing after the summary buffer has been generated."
798 :group 'gnus-summary-various
801 (defcustom gnus-summary-generate-hook nil
802 "*A hook run just before generating the summary buffer.
803 This hook is commonly used to customize threading variables and the
805 :group 'gnus-summary-various
808 (defcustom gnus-select-group-hook nil
809 "*A hook called when a newsgroup is selected.
811 If you'd like to simplify subjects like the
812 `gnus-summary-next-same-subject' command does, you can use the
815 (add-hook gnus-select-group-hook
817 (mapcar (lambda (header)
818 (mail-header-set-subject
820 (gnus-simplify-subject
821 (mail-header-subject header) 're-only)))
822 gnus-newsgroup-headers)))"
823 :group 'gnus-group-select
826 (defcustom gnus-select-article-hook nil
827 "*A hook called when an article is selected."
828 :group 'gnus-summary-choose
829 :options '(gnus-agent-fetch-selected-article)
832 (defcustom gnus-visual-mark-article-hook
833 (list 'gnus-highlight-selected-summary)
834 "*Hook run after selecting an article in the summary buffer.
835 It is meant to be used for highlighting the article in some way. It
836 is not run if `gnus-visual' is nil."
837 :group 'gnus-summary-visual
840 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
841 "*A hook called before parsing the headers."
845 (defcustom gnus-exit-group-hook nil
846 "*A hook called when exiting summary mode.
847 This hook is not called from the non-updating exit commands like `Q'."
851 (defcustom gnus-summary-update-hook
852 (list 'gnus-summary-highlight-line)
853 "*A hook called when a summary line is changed.
854 The hook will not be called if `gnus-visual' is nil.
856 The default function `gnus-summary-highlight-line' will
857 highlight the line according to the `gnus-summary-highlight'
859 :group 'gnus-summary-visual
862 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
863 "*A hook called when an article is selected for the first time.
864 The hook is intended to mark an article as read (or unread)
865 automatically when it is selected."
866 :group 'gnus-summary-choose
869 (defcustom gnus-group-no-more-groups-hook nil
870 "*A hook run when returning to group mode having no more (unread) groups."
871 :group 'gnus-group-select
874 (defcustom gnus-ps-print-hook nil
875 "*A hook run before ps-printing something from Gnus."
879 (defcustom gnus-summary-article-move-hook nil
880 "*A hook called after an article is moved, copied, respooled, or crossposted."
884 (defcustom gnus-summary-article-delete-hook nil
885 "*A hook called after an article is deleted."
889 (defcustom gnus-summary-article-expire-hook nil
890 "*A hook called after an article is expired."
894 (defcustom gnus-summary-display-arrow
895 (and (fboundp 'display-graphic-p)
897 "*If non-nil, display an arrow highlighting the current article."
902 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
903 "Face used for highlighting the current article in the summary buffer."
904 :group 'gnus-summary-visual
907 (defvar gnus-tmp-downloaded nil)
909 (defcustom gnus-summary-highlight
910 '(((eq mark gnus-canceled-mark)
911 . gnus-summary-cancelled-face)
912 ((and uncached (> score default-high))
913 . gnus-summary-high-undownloaded-face)
914 ((and uncached (< score default-low))
915 . gnus-summary-low-undownloaded-face)
917 . gnus-summary-normal-undownloaded-face)
918 ((and (> score default-high)
919 (or (eq mark gnus-dormant-mark)
920 (eq mark gnus-ticked-mark)))
921 . gnus-summary-high-ticked-face)
922 ((and (< score default-low)
923 (or (eq mark gnus-dormant-mark)
924 (eq mark gnus-ticked-mark)))
925 . gnus-summary-low-ticked-face)
926 ((or (eq mark gnus-dormant-mark)
927 (eq mark gnus-ticked-mark))
928 . gnus-summary-normal-ticked-face)
929 ((and (> score default-high) (eq mark gnus-ancient-mark))
930 . gnus-summary-high-ancient-face)
931 ((and (< score default-low) (eq mark gnus-ancient-mark))
932 . gnus-summary-low-ancient-face)
933 ((eq mark gnus-ancient-mark)
934 . gnus-summary-normal-ancient-face)
935 ((and (> score default-high) (eq mark gnus-unread-mark))
936 . gnus-summary-high-unread-face)
937 ((and (< score default-low) (eq mark gnus-unread-mark))
938 . gnus-summary-low-unread-face)
939 ((eq mark gnus-unread-mark)
940 . gnus-summary-normal-unread-face)
941 ((> score default-high)
942 . gnus-summary-high-read-face)
943 ((< score default-low)
944 . gnus-summary-low-read-face)
946 . gnus-summary-normal-read-face))
947 "*Controls the highlighting of summary buffer lines.
949 A list of (FORM . FACE) pairs. When deciding how a a particular
950 summary line should be displayed, each form is evaluated. The content
951 of the face field after the first true form is used. You can change
952 how those summary lines are displayed, by editing the face field.
954 You can use the following variables in the FORM field.
956 score: The article's score
957 default: The default article score.
958 default-high: The default score for high scored articles.
959 default-low: The default score for low scored articles.
960 below: The score below which articles are automatically marked as read.
961 mark: The articles mark."
962 :group 'gnus-summary-visual
963 :type '(repeat (cons (sexp :tag "Form" nil)
966 (defcustom gnus-alter-header-function nil
967 "Function called to allow alteration of article header structures.
968 The function is called with one parameter, the article header vector,
969 which it may alter in any way."
970 :type '(choice (const :tag "None" nil)
972 :group 'gnus-summary)
974 (defvar gnus-decode-encoded-word-function
975 (mime-find-field-decoder 'From 'nov)
976 "Variable that says which function should be used to decode a string with encoded words.")
978 (defcustom gnus-extra-headers '(To Newsgroups)
979 "*Extra headers to parse."
982 :type '(repeat symbol))
984 (defcustom gnus-ignored-from-addresses
985 (and user-mail-address (regexp-quote user-mail-address))
986 "*Regexp of From headers that may be suppressed in favor of To headers."
991 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
992 "List of charsets that should be ignored.
993 When these charsets are used in the \"charset\" parameter, the
994 default charset will be used instead."
996 :type '(repeat symbol)
997 :group 'gnus-charset)
999 (gnus-define-group-parameter
1003 "Return the ignored charsets of GROUP."
1004 :variable gnus-group-ignored-charsets-alist
1006 '(("alt\\.chinese\\.text" iso-8859-1))
1008 "Alist of regexps (to match group names) and charsets that should be ignored.
1009 When these charsets are used in the \"charset\" parameter, the
1010 default charset will be used instead."
1011 :variable-group gnus-charset
1012 :variable-type '(repeat (cons (regexp :tag "Group")
1014 :parameter-type '(choice :tag "Ignored charsets"
1017 :parameter-document "\
1018 List of charsets that should be ignored.
1020 When these charsets are used in the \"charset\" parameter, the
1021 default charset will be used instead.")
1023 (defcustom gnus-group-highlight-words-alist nil
1024 "Alist of group regexps and highlight regexps.
1025 This variable uses the same syntax as `gnus-emphasis-alist'."
1027 :type '(repeat (cons (regexp :tag "Group")
1028 (repeat (list (regexp :tag "Highlight regexp")
1029 (number :tag "Group for entire word" 0)
1030 (number :tag "Group for displayed part" 0)
1032 gnus-emphasis-highlight-words)))))
1033 :group 'gnus-summary-visual)
1035 (defcustom gnus-use-wheel nil
1036 "Use Intelli-mouse on summary movement"
1038 :group 'gnus-summary-maneuvering)
1040 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1041 "Amount to scroll messages by spinning the mouse wheel.
1042 This is actually a cons cell, where the first item is the amount to scroll
1043 on a normal wheel event, and the second is the amount to scroll when the
1044 wheel is moved with the shift key depressed."
1045 :type '(cons (integer :tag "Shift") integer)
1046 :group 'gnus-summary-maneuvering)
1048 (defcustom gnus-wheel-edge-resistance 2
1049 "How hard it should be to change the current article
1050 by moving the mouse over the edge of the article window."
1052 :group 'gnus-summary-maneuvering)
1054 (defcustom gnus-summary-show-article-charset-alist
1056 "Alist of number and charset.
1057 The article will be shown with the charset corresponding to the
1059 For example: ((1 . cn-gb-2312) (2 . big5))."
1061 :type '(repeat (cons (number :tag "Argument" 1)
1062 (symbol :tag "Charset")))
1063 :group 'gnus-charset)
1065 (defcustom gnus-preserve-marks t
1066 "Whether marks are preserved when moving, copying and respooling messages."
1069 :group 'gnus-summary-marks)
1071 (defcustom gnus-alter-articles-to-read-function nil
1072 "Function to be called to alter the list of articles to be selected."
1073 :type '(choice (const nil) function)
1074 :group 'gnus-summary)
1076 (defcustom gnus-orphan-score nil
1077 "*All orphans get this score added. Set in the score file."
1078 :group 'gnus-score-default
1079 :type '(choice (const nil)
1082 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1083 "*A regexp to match MIME parts when saving multiple parts of a
1084 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1085 This regexp will be used by default when prompting the user for which
1086 type of files to save."
1087 :group 'gnus-summary
1090 (defcustom gnus-read-all-available-headers nil
1091 "Whether Gnus should parse all headers made available to it.
1092 This is mostly relevant for slow backends where the user may
1093 wish to widen the summary buffer to include all headers
1094 that were fetched. Say, for nnultimate groups."
1095 :group 'gnus-summary
1096 :type '(choice boolean regexp))
1098 (defcustom gnus-summary-muttprint-program "muttprint"
1099 "Command (and optional arguments) used to run Muttprint."
1101 :group 'gnus-summary
1104 (defcustom gnus-article-loose-mime nil
1105 "If non-nil, don't require MIME-Version header.
1106 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1107 supply the MIME-Version header or deliberately strip it From the mail.
1108 Set it to non-nil, Gnus will treat some articles as MIME even if
1109 the MIME-Version header is missed."
1112 :group 'gnus-article)
1114 (defcustom gnus-article-emulate-mime t
1115 "If non-nil, use MIME emulation for uuencode and the like.
1116 This means that Gnus will search message bodies for text that look
1117 like uuencoded bits, yEncoded bits, and so on, and present that using
1118 the normal Gnus MIME machinery."
1120 :group 'gnus-article)
1122 ;;; Internal variables
1124 (defvar gnus-summary-display-cache nil)
1125 (defvar gnus-article-mime-handles nil)
1126 (defvar gnus-article-decoded-p nil)
1127 (defvar gnus-article-charset nil)
1128 (defvar gnus-article-ignored-charsets nil)
1129 (defvar gnus-scores-exclude-files nil)
1130 (defvar gnus-page-broken nil)
1132 (defvar gnus-original-article nil)
1133 (defvar gnus-article-internal-prepare-hook nil)
1134 (defvar gnus-newsgroup-process-stack nil)
1136 (defvar gnus-thread-indent-array nil)
1137 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1138 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1139 "Function called to sort the articles within a thread after it has been gathered together.")
1141 (defvar gnus-summary-save-parts-type-history nil)
1142 (defvar gnus-summary-save-parts-last-directory nil)
1144 ;; Avoid highlighting in kill files.
1145 (defvar gnus-summary-inhibit-highlight nil)
1146 (defvar gnus-newsgroup-selected-overlay nil)
1147 (defvar gnus-inhibit-limiting nil)
1148 (defvar gnus-newsgroup-adaptive-score-file nil)
1149 (defvar gnus-current-score-file nil)
1150 (defvar gnus-current-move-group nil)
1151 (defvar gnus-current-copy-group nil)
1152 (defvar gnus-current-crosspost-group nil)
1153 (defvar gnus-newsgroup-display nil)
1155 (defvar gnus-newsgroup-dependencies nil)
1156 (defvar gnus-newsgroup-adaptive nil)
1157 (defvar gnus-summary-display-article-function nil)
1158 (defvar gnus-summary-highlight-line-function nil
1159 "Function called after highlighting a summary line.")
1161 (defvar gnus-summary-line-format-alist
1162 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1163 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1164 (?s gnus-tmp-subject-or-nil ?s)
1165 (?n gnus-tmp-name ?s)
1166 (?A (std11-address-string
1167 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1168 (?a (or (std11-full-name-string
1169 (car (mime-entity-read-field gnus-tmp-header 'From)))
1171 (?F gnus-tmp-from ?s)
1172 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1173 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1174 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1175 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1176 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1177 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1178 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1179 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1180 (?L gnus-tmp-lines ?s)
1181 (?O gnus-tmp-downloaded ?c)
1182 (?I gnus-tmp-indentation ?s)
1183 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1184 (?R gnus-tmp-replied ?c)
1185 (?\[ gnus-tmp-opening-bracket ?c)
1186 (?\] gnus-tmp-closing-bracket ?c)
1187 (?\> (make-string gnus-tmp-level ? ) ?s)
1188 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1189 (?i gnus-tmp-score ?d)
1190 (?z gnus-tmp-score-char ?c)
1191 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1192 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1193 (?U gnus-tmp-unread ?c)
1194 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1196 (?t (gnus-summary-number-of-articles-in-thread
1197 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1199 (?e (gnus-summary-number-of-articles-in-thread
1200 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1202 (?u gnus-tmp-user-defined ?s)
1203 (?P (gnus-pick-line-number) ?d)
1204 (?B gnus-tmp-thread-tree-header-string ?s)
1205 (user-date (gnus-user-date
1206 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1207 "An alist of format specifications that can appear in summary lines.
1208 These are paired with what variables they correspond with, along with
1209 the type of the variable (string, integer, character, etc).")
1211 (defvar gnus-summary-dummy-line-format-alist
1212 `((?S gnus-tmp-subject ?s)
1213 (?N gnus-tmp-number ?d)
1214 (?u gnus-tmp-user-defined ?s)))
1216 (defvar gnus-summary-mode-line-format-alist
1217 `((?G gnus-tmp-group-name ?s)
1218 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1219 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1220 (?A gnus-tmp-article-number ?d)
1221 (?Z gnus-tmp-unread-and-unselected ?s)
1222 (?V gnus-version ?s)
1223 (?U gnus-tmp-unread-and-unticked ?d)
1224 (?S gnus-tmp-subject ?s)
1225 (?e gnus-tmp-unselected ?d)
1226 (?u gnus-tmp-user-defined ?s)
1227 (?d (length gnus-newsgroup-dormant) ?d)
1228 (?t (length gnus-newsgroup-marked) ?d)
1229 (?h (length gnus-newsgroup-spam-marked) ?d)
1230 (?r (length gnus-newsgroup-reads) ?d)
1231 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1232 (?E gnus-newsgroup-expunged-tally ?d)
1233 (?s (gnus-current-score-file-nondirectory) ?s)))
1235 (defvar gnus-last-search-regexp nil
1236 "Default regexp for article search command.")
1238 (defvar gnus-summary-search-article-matched-data nil
1239 "Last matched data of article search command. It is the local variable
1240 in `gnus-article-buffer' which consists of the list of start position,
1241 end position and text.")
1243 (defvar gnus-last-shell-command nil
1244 "Default shell command on article.")
1246 (defvar gnus-newsgroup-agentized nil
1247 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1248 (defvar gnus-newsgroup-begin nil)
1249 (defvar gnus-newsgroup-end nil)
1250 (defvar gnus-newsgroup-last-rmail nil)
1251 (defvar gnus-newsgroup-last-mail nil)
1252 (defvar gnus-newsgroup-last-folder nil)
1253 (defvar gnus-newsgroup-last-file nil)
1254 (defvar gnus-newsgroup-auto-expire nil)
1255 (defvar gnus-newsgroup-active nil)
1257 (defvar gnus-newsgroup-data nil)
1258 (defvar gnus-newsgroup-data-reverse nil)
1259 (defvar gnus-newsgroup-limit nil)
1260 (defvar gnus-newsgroup-limits nil)
1262 (defvar gnus-newsgroup-unreads nil
1263 "Sorted list of unread articles in the current newsgroup.")
1265 (defvar gnus-newsgroup-unselected nil
1266 "Sorted list of unselected unread articles in the current newsgroup.")
1268 (defvar gnus-newsgroup-reads nil
1269 "Alist of read articles and article marks in the current newsgroup.")
1271 (defvar gnus-newsgroup-expunged-tally nil)
1273 (defvar gnus-newsgroup-marked nil
1274 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1276 (defvar gnus-newsgroup-spam-marked nil
1277 "List of ranges of articles that have been marked as spam.")
1279 (defvar gnus-newsgroup-killed nil
1280 "List of ranges of articles that have been through the scoring process.")
1282 (defvar gnus-newsgroup-cached nil
1283 "Sorted list of articles that come from the article cache.")
1285 (defvar gnus-newsgroup-saved nil
1286 "List of articles that have been saved.")
1288 (defvar gnus-newsgroup-kill-headers nil)
1290 (defvar gnus-newsgroup-replied nil
1291 "List of articles that have been replied to in the current newsgroup.")
1293 (defvar gnus-newsgroup-forwarded nil
1294 "List of articles that have been forwarded in the current newsgroup.")
1296 (defvar gnus-newsgroup-recent nil
1297 "List of articles that have are recent in the current newsgroup.")
1299 (defvar gnus-newsgroup-expirable nil
1300 "Sorted list of articles in the current newsgroup that can be expired.")
1302 (defvar gnus-newsgroup-processable nil
1303 "List of articles in the current newsgroup that can be processed.")
1305 (defvar gnus-newsgroup-downloadable nil
1306 "Sorted list of articles in the current newsgroup that can be processed.")
1308 (defvar gnus-newsgroup-unfetched nil
1309 "Sorted list of articles in the current newsgroup whose headers have not been fetched into the agent.")
1311 (defvar gnus-newsgroup-undownloaded nil
1312 "List of articles in the current newsgroup that haven't been downloaded.")
1314 (defvar gnus-newsgroup-unsendable nil
1315 "List of articles in the current newsgroup that won't be sent.")
1317 (defvar gnus-newsgroup-bookmarks nil
1318 "List of articles in the current newsgroup that have bookmarks.")
1320 (defvar gnus-newsgroup-dormant nil
1321 "Sorted list of dormant articles in the current newsgroup.")
1323 (defvar gnus-newsgroup-unseen nil
1324 "List of unseen articles in the current newsgroup.")
1326 (defvar gnus-newsgroup-seen nil
1327 "Range of seen articles in the current newsgroup.")
1329 (defvar gnus-newsgroup-articles nil
1330 "List of articles in the current newsgroup.")
1332 (defvar gnus-newsgroup-scored nil
1333 "List of scored articles in the current newsgroup.")
1335 (defvar gnus-newsgroup-incorporated nil
1336 "List of incorporated articles in the current newsgroup.")
1338 (defvar gnus-newsgroup-headers nil
1339 "List of article headers in the current newsgroup.")
1341 (defvar gnus-newsgroup-threads nil)
1343 (defvar gnus-newsgroup-prepared nil
1344 "Whether the current group has been prepared properly.")
1346 (defvar gnus-newsgroup-ancient nil
1347 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1349 (defvar gnus-newsgroup-sparse nil)
1351 (defvar gnus-current-article nil)
1352 (defvar gnus-article-current nil)
1353 (defvar gnus-current-headers nil)
1354 (defvar gnus-have-all-headers nil)
1355 (defvar gnus-last-article nil)
1356 (defvar gnus-newsgroup-history nil)
1357 (defvar gnus-newsgroup-charset nil)
1358 (defvar gnus-newsgroup-ephemeral-charset nil)
1359 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1361 (defvar gnus-article-before-search nil)
1363 (defconst gnus-summary-local-variables
1364 '(gnus-newsgroup-name
1365 gnus-newsgroup-begin gnus-newsgroup-end
1366 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1367 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1368 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1369 gnus-newsgroup-unselected gnus-newsgroup-marked
1370 gnus-newsgroup-spam-marked
1371 gnus-newsgroup-reads gnus-newsgroup-saved
1372 gnus-newsgroup-replied gnus-newsgroup-forwarded
1373 gnus-newsgroup-recent
1374 gnus-newsgroup-expirable
1375 gnus-newsgroup-processable gnus-newsgroup-killed
1376 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1377 gnus-newsgroup-unfetched
1378 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1379 gnus-newsgroup-seen gnus-newsgroup-articles
1380 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1381 gnus-newsgroup-headers gnus-newsgroup-threads
1382 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1383 gnus-current-article gnus-current-headers gnus-have-all-headers
1384 gnus-last-article gnus-article-internal-prepare-hook
1385 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1386 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1387 gnus-thread-expunge-below
1388 gnus-score-alist gnus-current-score-file
1389 (gnus-summary-expunge-below . global)
1390 (gnus-summary-mark-below . global)
1391 (gnus-orphan-score . global)
1392 gnus-newsgroup-active gnus-scores-exclude-files
1393 gnus-newsgroup-history gnus-newsgroup-ancient
1394 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1395 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1396 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1397 (gnus-newsgroup-expunged-tally . 0)
1398 gnus-cache-removable-articles gnus-newsgroup-cached
1399 gnus-newsgroup-data gnus-newsgroup-data-reverse
1400 gnus-newsgroup-limit gnus-newsgroup-limits
1401 gnus-newsgroup-charset gnus-newsgroup-display
1402 gnus-newsgroup-incorporated)
1403 "Variables that are buffer-local to the summary buffers.")
1405 (defvar gnus-newsgroup-variables nil
1406 "A list of variables that have separate values in different newsgroups.
1407 A list of newsgroup (summary buffer) local variables, or cons of
1408 variables and their default values (when the default values are not
1409 nil), that should be made global while the summary buffer is active.
1410 These variables can be used to set variables in the group parameters
1411 while still allowing them to affect operations done in other
1412 buffers. For example:
1414 \(setq gnus-newsgroup-variables
1415 '(message-use-followup-to
1416 (gnus-visible-headers .
1417 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1420 ;; Byte-compiler warning.
1421 ;(eval-when-compile (defvar gnus-article-mode-map))
1423 (let ((features (cons 'gnus-sum features)))
1425 (require 'gnus-agent)
1426 (require 'gnus-art)))
1428 ;; Subject simplification.
1430 (defun gnus-simplify-whitespace (str)
1431 "Remove excessive whitespace from STR."
1433 (while (string-match "[ \t][ \t]+" str)
1434 (setq str (concat (substring str 0 (match-beginning 0))
1436 (substring str (match-end 0)))))
1438 (when (string-match "^[ \t]+" str)
1439 (setq str (substring str (match-end 0))))
1441 (when (string-match "[ \t]+$" str)
1442 (setq str (substring str 0 (match-beginning 0))))
1445 (defun gnus-simplify-all-whitespace (str)
1446 "Remove all whitespace from STR."
1447 (while (string-match "[ \t\n]+" str)
1448 (setq str (replace-match "" nil nil str)))
1451 (defsubst gnus-simplify-subject-re (subject)
1452 "Remove \"Re:\" from subject lines."
1453 (if (string-match message-subject-re-regexp subject)
1454 (substring subject (match-end 0))
1457 (defun gnus-simplify-subject (subject &optional re-only)
1458 "Remove `Re:' and words in parentheses.
1459 If RE-ONLY is non-nil, strip leading `Re:'s only."
1460 (let ((case-fold-search t)) ;Ignore case.
1461 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1462 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1463 (setq subject (substring subject (match-end 0))))
1464 ;; Remove uninteresting prefixes.
1465 (when (and (not re-only)
1466 gnus-simplify-ignored-prefixes
1467 (string-match gnus-simplify-ignored-prefixes subject))
1468 (setq subject (substring subject (match-end 0))))
1469 ;; Remove words in parentheses from end.
1471 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1472 (setq subject (substring subject 0 (match-beginning 0)))))
1473 ;; Return subject string.
1476 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1478 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1479 (goto-char (point-min))
1480 (while (re-search-forward regexp nil t)
1481 (replace-match (or newtext ""))))
1483 (defun gnus-simplify-buffer-fuzzy ()
1484 "Simplify string in the buffer fuzzily.
1485 The string in the accessible portion of the current buffer is simplified.
1486 It is assumed to be a single-line subject.
1487 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1488 matter is removed. Additional things can be deleted by setting
1489 `gnus-simplify-subject-fuzzy-regexp'."
1490 (let ((case-fold-search t)
1492 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1494 (while (not (eq modified-tick (buffer-modified-tick)))
1495 (setq modified-tick (buffer-modified-tick))
1497 ((listp gnus-simplify-subject-fuzzy-regexp)
1498 (mapcar 'gnus-simplify-buffer-fuzzy-step
1499 gnus-simplify-subject-fuzzy-regexp))
1500 (gnus-simplify-subject-fuzzy-regexp
1501 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1502 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1503 (gnus-simplify-buffer-fuzzy-step
1504 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1505 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1507 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1508 (gnus-simplify-buffer-fuzzy-step " +" " ")
1509 (gnus-simplify-buffer-fuzzy-step " $")
1510 (gnus-simplify-buffer-fuzzy-step "^ +")))
1512 (defun gnus-simplify-subject-fuzzy (subject)
1513 "Simplify a subject string fuzzily.
1514 See `gnus-simplify-buffer-fuzzy' for details."
1516 (gnus-set-work-buffer)
1517 (let ((case-fold-search t))
1518 ;; Remove uninteresting prefixes.
1519 (when (and gnus-simplify-ignored-prefixes
1520 (string-match gnus-simplify-ignored-prefixes subject))
1521 (setq subject (substring subject (match-end 0))))
1523 (inline (gnus-simplify-buffer-fuzzy))
1526 (defsubst gnus-simplify-subject-fully (subject)
1527 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1529 (gnus-simplify-subject-functions
1530 (gnus-map-function gnus-simplify-subject-functions subject))
1531 ((null gnus-summary-gather-subject-limit)
1532 (gnus-simplify-subject-re subject))
1533 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1534 (gnus-simplify-subject-fuzzy subject))
1535 ((numberp gnus-summary-gather-subject-limit)
1536 (gnus-limit-string (gnus-simplify-subject-re subject)
1537 gnus-summary-gather-subject-limit))
1541 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1542 "Check whether two subjects are equal.
1543 If optional argument SIMPLE-FIRST is t, first argument is already
1546 ((null simple-first)
1547 (equal (gnus-simplify-subject-fully s1)
1548 (gnus-simplify-subject-fully s2)))
1551 (gnus-simplify-subject-fully s2)))))
1553 (defun gnus-summary-bubble-group ()
1554 "Increase the score of the current group.
1555 This is a handy function to add to `gnus-summary-exit-hook' to
1556 increase the score of each group you read."
1557 (gnus-group-add-score gnus-newsgroup-name))
1561 ;;; Gnus summary mode
1564 (put 'gnus-summary-mode 'mode-class 'special)
1566 (defvar gnus-article-commands-menu)
1568 ;; Non-orthogonal keys
1570 (gnus-define-keys gnus-summary-mode-map
1571 " " gnus-summary-next-page
1572 "\177" gnus-summary-prev-page
1573 [delete] gnus-summary-prev-page
1574 [backspace] gnus-summary-prev-page
1575 "\r" gnus-summary-scroll-up
1576 "\M-\r" gnus-summary-scroll-down
1577 "n" gnus-summary-next-unread-article
1578 "p" gnus-summary-prev-unread-article
1579 "N" gnus-summary-next-article
1580 "P" gnus-summary-prev-article
1581 "\M-\C-n" gnus-summary-next-same-subject
1582 "\M-\C-p" gnus-summary-prev-same-subject
1583 "\M-n" gnus-summary-next-unread-subject
1584 "\M-p" gnus-summary-prev-unread-subject
1585 "." gnus-summary-first-unread-article
1586 "," gnus-summary-best-unread-article
1587 "\M-s" gnus-summary-search-article-forward
1588 "\M-r" gnus-summary-search-article-backward
1589 "<" gnus-summary-beginning-of-article
1590 ">" gnus-summary-end-of-article
1591 "j" gnus-summary-goto-article
1592 "^" gnus-summary-refer-parent-article
1593 "\M-^" gnus-summary-refer-article
1594 "u" gnus-summary-tick-article-forward
1595 "!" gnus-summary-tick-article-forward
1596 "U" gnus-summary-tick-article-backward
1597 "d" gnus-summary-mark-as-read-forward
1598 "D" gnus-summary-mark-as-read-backward
1599 "E" gnus-summary-mark-as-expirable
1600 "\M-u" gnus-summary-clear-mark-forward
1601 "\M-U" gnus-summary-clear-mark-backward
1602 "k" gnus-summary-kill-same-subject-and-select
1603 "\C-k" gnus-summary-kill-same-subject
1604 "\M-\C-k" gnus-summary-kill-thread
1605 "\M-\C-l" gnus-summary-lower-thread
1606 "e" gnus-summary-edit-article
1607 "#" gnus-summary-mark-as-processable
1608 "\M-#" gnus-summary-unmark-as-processable
1609 "\M-\C-t" gnus-summary-toggle-threads
1610 "\M-\C-s" gnus-summary-show-thread
1611 "\M-\C-h" gnus-summary-hide-thread
1612 "\M-\C-f" gnus-summary-next-thread
1613 "\M-\C-b" gnus-summary-prev-thread
1614 [(meta down)] gnus-summary-next-thread
1615 [(meta up)] gnus-summary-prev-thread
1616 "\M-\C-u" gnus-summary-up-thread
1617 "\M-\C-d" gnus-summary-down-thread
1618 "&" gnus-summary-execute-command
1619 "c" gnus-summary-catchup-and-exit
1620 "\C-w" gnus-summary-mark-region-as-read
1621 "\C-t" gnus-summary-toggle-truncation
1622 "?" gnus-summary-mark-as-dormant
1623 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1624 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1625 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1626 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1627 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1628 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1629 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1630 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1631 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1632 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1633 "=" gnus-summary-expand-window
1634 "\C-x\C-s" gnus-summary-reselect-current-group
1635 "\M-g" gnus-summary-rescan-group
1636 "w" gnus-summary-stop-page-breaking
1637 "\C-c\C-r" gnus-summary-caesar-message
1638 "\M-t" gnus-summary-toggle-mime
1639 "f" gnus-summary-followup
1640 "F" gnus-summary-followup-with-original
1641 "C" gnus-summary-cancel-article
1642 "r" gnus-summary-reply
1643 "R" gnus-summary-reply-with-original
1644 "\C-c\C-f" gnus-summary-mail-forward
1645 "o" gnus-summary-save-article
1646 "\C-o" gnus-summary-save-article-mail
1647 "|" gnus-summary-pipe-output
1648 "\M-k" gnus-summary-edit-local-kill
1649 "\M-K" gnus-summary-edit-global-kill
1651 "\C-c\C-d" gnus-summary-describe-group
1652 "q" gnus-summary-exit
1653 "Q" gnus-summary-exit-no-update
1654 "\C-c\C-i" gnus-info-find-node
1655 gnus-mouse-2 gnus-mouse-pick-article
1656 "m" gnus-summary-mail-other-window
1657 "a" gnus-summary-post-news
1658 "i" gnus-summary-news-other-window
1659 "x" gnus-summary-limit-to-unread
1660 "s" gnus-summary-isearch-article
1661 "t" gnus-summary-toggle-header
1662 "g" gnus-summary-show-article
1663 "l" gnus-summary-goto-last-article
1664 "v" gnus-summary-preview-mime-message
1665 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1666 "\C-d" gnus-summary-enter-digest-group
1667 "\M-\C-d" gnus-summary-read-document
1668 "\M-\C-e" gnus-summary-edit-parameters
1669 "\M-\C-a" gnus-summary-customize-parameters
1671 "\C-c\C-n" gnus-namazu-search
1672 "*" gnus-cache-enter-article
1673 "\M-*" gnus-cache-remove-article
1674 "\M-&" gnus-summary-universal-argument
1675 "\C-l" gnus-recenter
1676 "I" gnus-summary-increase-score
1677 "L" gnus-summary-lower-score
1678 "\M-i" gnus-symbolic-argument
1679 "h" gnus-summary-select-article-buffer
1681 "V" gnus-summary-score-map
1682 "X" gnus-uu-extract-map
1683 "S" gnus-summary-send-map)
1685 ;; Sort of orthogonal keymap
1686 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1687 "t" gnus-summary-tick-article-forward
1688 "!" gnus-summary-tick-article-forward
1689 "d" gnus-summary-mark-as-read-forward
1690 "r" gnus-summary-mark-as-read-forward
1691 "c" gnus-summary-clear-mark-forward
1692 " " gnus-summary-clear-mark-forward
1693 "e" gnus-summary-mark-as-expirable
1694 "x" gnus-summary-mark-as-expirable
1695 "?" gnus-summary-mark-as-dormant
1696 "b" gnus-summary-set-bookmark
1697 "B" gnus-summary-remove-bookmark
1698 "#" gnus-summary-mark-as-processable
1699 "\M-#" gnus-summary-unmark-as-processable
1700 "S" gnus-summary-limit-include-expunged
1701 "C" gnus-summary-catchup
1702 "H" gnus-summary-catchup-to-here
1703 "h" gnus-summary-catchup-from-here
1704 "\C-c" gnus-summary-catchup-all
1705 "k" gnus-summary-kill-same-subject-and-select
1706 "K" gnus-summary-kill-same-subject
1707 "P" gnus-uu-mark-map)
1709 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1710 "c" gnus-summary-clear-above
1711 "u" gnus-summary-tick-above
1712 "m" gnus-summary-mark-above
1713 "k" gnus-summary-kill-below)
1715 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1716 "/" gnus-summary-limit-to-subject
1717 "n" gnus-summary-limit-to-articles
1718 "w" gnus-summary-pop-limit
1719 "s" gnus-summary-limit-to-subject
1720 "a" gnus-summary-limit-to-author
1721 "u" gnus-summary-limit-to-unread
1722 "m" gnus-summary-limit-to-marks
1723 "M" gnus-summary-limit-exclude-marks
1724 "v" gnus-summary-limit-to-score
1725 "*" gnus-summary-limit-include-cached
1726 "D" gnus-summary-limit-include-dormant
1727 "T" gnus-summary-limit-include-thread
1728 "d" gnus-summary-limit-exclude-dormant
1729 "t" gnus-summary-limit-to-age
1730 "." gnus-summary-limit-to-unseen
1731 "x" gnus-summary-limit-to-extra
1732 "p" gnus-summary-limit-to-display-predicate
1733 "E" gnus-summary-limit-include-expunged
1734 "c" gnus-summary-limit-exclude-childless-dormant
1735 "C" gnus-summary-limit-mark-excluded-as-read
1736 "o" gnus-summary-insert-old-articles
1737 "N" gnus-summary-insert-new-articles)
1739 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1740 "n" gnus-summary-next-unread-article
1741 "p" gnus-summary-prev-unread-article
1742 "N" gnus-summary-next-article
1743 "P" gnus-summary-prev-article
1744 "\C-n" gnus-summary-next-same-subject
1745 "\C-p" gnus-summary-prev-same-subject
1746 "\M-n" gnus-summary-next-unread-subject
1747 "\M-p" gnus-summary-prev-unread-subject
1748 "f" gnus-summary-first-unread-article
1749 "b" gnus-summary-best-unread-article
1750 "j" gnus-summary-goto-article
1751 "g" gnus-summary-goto-subject
1752 "l" gnus-summary-goto-last-article
1753 "o" gnus-summary-pop-article)
1755 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1756 "k" gnus-summary-kill-thread
1757 "l" gnus-summary-lower-thread
1758 "i" gnus-summary-raise-thread
1759 "T" gnus-summary-toggle-threads
1760 "t" gnus-summary-rethread-current
1761 "^" gnus-summary-reparent-thread
1762 "s" gnus-summary-show-thread
1763 "S" gnus-summary-show-all-threads
1764 "h" gnus-summary-hide-thread
1765 "H" gnus-summary-hide-all-threads
1766 "n" gnus-summary-next-thread
1767 "p" gnus-summary-prev-thread
1768 "u" gnus-summary-up-thread
1769 "o" gnus-summary-top-thread
1770 "d" gnus-summary-down-thread
1771 "#" gnus-uu-mark-thread
1772 "\M-#" gnus-uu-unmark-thread)
1774 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1775 "g" gnus-summary-prepare
1776 "c" gnus-summary-insert-cached-articles
1777 "d" gnus-summary-insert-dormant-articles)
1779 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1780 "c" gnus-summary-catchup-and-exit
1781 "C" gnus-summary-catchup-all-and-exit
1782 "E" gnus-summary-exit-no-update
1783 "J" gnus-summary-jump-to-other-group
1784 "Q" gnus-summary-exit
1785 "Z" gnus-summary-exit
1786 "n" gnus-summary-catchup-and-goto-next-group
1787 "R" gnus-summary-reselect-current-group
1788 "G" gnus-summary-rescan-group
1789 "N" gnus-summary-next-group
1790 "s" gnus-summary-save-newsrc
1791 "P" gnus-summary-prev-group)
1793 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1794 " " gnus-summary-next-page
1795 "n" gnus-summary-next-page
1796 "\177" gnus-summary-prev-page
1797 [delete] gnus-summary-prev-page
1798 "p" gnus-summary-prev-page
1799 "\r" gnus-summary-scroll-up
1800 "\M-\r" gnus-summary-scroll-down
1801 "<" gnus-summary-beginning-of-article
1802 ">" gnus-summary-end-of-article
1803 "b" gnus-summary-beginning-of-article
1804 "e" gnus-summary-end-of-article
1805 "^" gnus-summary-refer-parent-article
1806 "r" gnus-summary-refer-parent-article
1807 "D" gnus-summary-enter-digest-group
1808 "R" gnus-summary-refer-references
1809 "T" gnus-summary-refer-thread
1810 "g" gnus-summary-show-article
1811 "s" gnus-summary-isearch-article
1812 "P" gnus-summary-print-article
1813 "M" gnus-mailing-list-insinuate
1814 "t" gnus-article-babel)
1816 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1817 "b" gnus-article-add-buttons
1818 "B" gnus-article-add-buttons-to-head
1819 "o" gnus-article-treat-overstrike
1820 "e" gnus-article-emphasize
1821 "w" gnus-article-fill-cited-article
1822 "Q" gnus-article-fill-long-lines
1823 "C" gnus-article-capitalize-sentences
1824 "c" gnus-article-remove-cr
1825 "Z" gnus-article-decode-HZ
1826 "h" gnus-article-wash-html
1827 "u" gnus-article-unsplit-urls
1828 "f" gnus-article-display-x-face
1829 "l" gnus-summary-stop-page-breaking
1830 "r" gnus-summary-caesar-message
1831 "m" gnus-summary-morse-message
1832 "t" gnus-summary-toggle-header
1833 "g" gnus-treat-smiley
1834 "v" gnus-summary-verbose-headers
1835 "m" gnus-summary-toggle-mime
1836 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1837 "p" gnus-article-verify-x-pgp-sig
1838 "d" gnus-article-treat-dumbquotes)
1840 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1841 ;; mnemonic: deuglif*Y*
1842 "u" gnus-article-outlook-unwrap-lines
1843 "a" gnus-article-outlook-repair-attribution
1844 "c" gnus-article-outlook-rearrange-citation
1845 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1847 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1848 "a" gnus-article-hide
1849 "h" gnus-article-hide-headers
1850 "b" gnus-article-hide-boring-headers
1851 "s" gnus-article-hide-signature
1852 "c" gnus-article-hide-citation
1853 "C" gnus-article-hide-citation-in-followups
1854 "l" gnus-article-hide-list-identifiers
1855 "B" gnus-article-strip-banner
1856 "P" gnus-article-hide-pem
1857 "\C-c" gnus-article-hide-citation-maybe)
1859 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1860 "a" gnus-article-highlight
1861 "h" gnus-article-highlight-headers
1862 "c" gnus-article-highlight-citation
1863 "s" gnus-article-highlight-signature)
1865 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1866 "f" gnus-article-treat-fold-headers
1867 "u" gnus-article-treat-unfold-headers
1868 "n" gnus-article-treat-fold-newsgroups)
1870 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1871 "x" gnus-article-display-x-face
1872 "d" gnus-article-display-face
1873 "s" gnus-treat-smiley
1874 "D" gnus-article-remove-images
1875 "f" gnus-treat-from-picon
1876 "m" gnus-treat-mail-picon
1877 "n" gnus-treat-newsgroups-picon)
1879 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1880 "z" gnus-article-date-ut
1881 "u" gnus-article-date-ut
1882 "l" gnus-article-date-local
1883 "p" gnus-article-date-english
1884 "e" gnus-article-date-lapsed
1885 "o" gnus-article-date-original
1886 "i" gnus-article-date-iso8601
1887 "s" gnus-article-date-user)
1889 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1890 "t" gnus-article-remove-trailing-blank-lines
1891 "l" gnus-article-strip-leading-blank-lines
1892 "m" gnus-article-strip-multiple-blank-lines
1893 "a" gnus-article-strip-blank-lines
1894 "A" gnus-article-strip-all-blank-lines
1895 "s" gnus-article-strip-leading-space
1896 "e" gnus-article-strip-trailing-space
1897 "w" gnus-article-remove-leading-whitespace)
1899 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1901 "f" gnus-summary-fetch-faq
1902 "d" gnus-summary-describe-group
1903 "h" gnus-summary-describe-briefly
1904 "i" gnus-info-find-node
1905 "c" gnus-group-fetch-charter
1906 "C" gnus-group-fetch-control)
1908 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1909 "e" gnus-summary-expire-articles
1910 "\M-\C-e" gnus-summary-expire-articles-now
1911 "\177" gnus-summary-delete-article
1912 [delete] gnus-summary-delete-article
1913 [backspace] gnus-summary-delete-article
1914 "m" gnus-summary-move-article
1915 "r" gnus-summary-respool-article
1916 "w" gnus-summary-edit-article
1917 "c" gnus-summary-copy-article
1918 "B" gnus-summary-crosspost-article
1919 "q" gnus-summary-respool-query
1920 "t" gnus-summary-respool-trace
1921 "i" gnus-summary-import-article
1922 "I" gnus-summary-create-article
1923 "p" gnus-summary-article-posted-p)
1925 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1926 "o" gnus-summary-save-article
1927 "m" gnus-summary-save-article-mail
1928 "F" gnus-summary-write-article-file
1929 "r" gnus-summary-save-article-rmail
1930 "f" gnus-summary-save-article-file
1931 "b" gnus-summary-save-article-body-file
1932 "h" gnus-summary-save-article-folder
1933 "v" gnus-summary-save-article-vm
1934 "p" gnus-summary-pipe-output
1935 "P" gnus-summary-muttprint
1936 "s" gnus-soup-add-article)
1938 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1939 "b" gnus-summary-display-buttonized
1940 "m" gnus-summary-repair-multipart
1941 "v" gnus-article-view-part
1942 "o" gnus-article-save-part
1943 "c" gnus-article-copy-part
1944 "C" gnus-article-view-part-as-charset
1945 "e" gnus-article-view-part-externally
1946 "E" gnus-article-encrypt-body
1947 "i" gnus-article-inline-part
1948 "|" gnus-article-pipe-part)
1950 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1951 "p" gnus-summary-mark-as-processable
1952 "u" gnus-summary-unmark-as-processable
1953 "U" gnus-summary-unmark-all-processable
1954 "v" gnus-uu-mark-over
1955 "s" gnus-uu-mark-series
1956 "r" gnus-uu-mark-region
1957 "g" gnus-uu-unmark-region
1958 "R" gnus-uu-mark-by-regexp
1959 "G" gnus-uu-unmark-by-regexp
1960 "t" gnus-uu-mark-thread
1961 "T" gnus-uu-unmark-thread
1962 "a" gnus-uu-mark-all
1963 "b" gnus-uu-mark-buffer
1964 "S" gnus-uu-mark-sparse
1965 "k" gnus-summary-kill-process-mark
1966 "y" gnus-summary-yank-process-mark
1967 "w" gnus-summary-save-process-mark
1968 "i" gnus-uu-invert-processable)
1970 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1971 ;;"x" gnus-uu-extract-any
1972 "m" gnus-summary-save-parts
1973 "u" gnus-uu-decode-uu
1974 "U" gnus-uu-decode-uu-and-save
1975 "s" gnus-uu-decode-unshar
1976 "S" gnus-uu-decode-unshar-and-save
1977 "o" gnus-uu-decode-save
1978 "O" gnus-uu-decode-save
1979 "b" gnus-uu-decode-binhex
1980 "B" gnus-uu-decode-binhex
1981 "p" gnus-uu-decode-postscript
1982 "P" gnus-uu-decode-postscript-and-save)
1985 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1986 "u" gnus-uu-decode-uu-view
1987 "U" gnus-uu-decode-uu-and-save-view
1988 "s" gnus-uu-decode-unshar-view
1989 "S" gnus-uu-decode-unshar-and-save-view
1990 "o" gnus-uu-decode-save-view
1991 "O" gnus-uu-decode-save-view
1992 "b" gnus-uu-decode-binhex-view
1993 "B" gnus-uu-decode-binhex-view
1994 "p" gnus-uu-decode-postscript-view
1995 "P" gnus-uu-decode-postscript-and-save-view)
1997 (defvar gnus-article-post-menu nil)
1999 (defconst gnus-summary-menu-maxlen 20)
2001 (defun gnus-summary-menu-split (menu)
2002 ;; If we have lots of elements, divide them into groups of 20
2003 ;; and make a pane (or submenu) for each one.
2004 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2005 (let ((menu menu) sublists next
2008 ;; Pull off the next gnus-summary-menu-maxlen elements
2009 ;; and make them the next element of sublist.
2010 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2012 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2014 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2015 (aref (car (last menu)) 0)) menu)
2019 (nreverse sublists))
2020 ;; Few elements--put them all in one pane.
2023 (defun gnus-summary-make-menu-bar ()
2024 (gnus-turn-off-edit-menu 'summary)
2026 (unless (boundp 'gnus-summary-misc-menu)
2029 gnus-summary-kill-menu gnus-summary-mode-map ""
2034 ["Customize" gnus-score-customize t])
2035 (gnus-make-score-map 'increase)
2036 (gnus-make-score-map 'lower)
2038 ["Kill below" gnus-summary-kill-below t]
2039 ["Mark above" gnus-summary-mark-above t]
2040 ["Tick above" gnus-summary-tick-above t]
2041 ["Clear above" gnus-summary-clear-above t])
2042 ["Current score" gnus-summary-current-score t]
2043 ["Set score" gnus-summary-set-score t]
2044 ["Switch current score file..." gnus-score-change-score-file t]
2045 ["Set mark below..." gnus-score-set-mark-below t]
2046 ["Set expunge below..." gnus-score-set-expunge-below t]
2047 ["Edit current score file" gnus-score-edit-current-scores t]
2048 ["Edit score file" gnus-score-edit-file t]
2049 ["Trace score" gnus-score-find-trace t]
2050 ["Find words" gnus-score-find-favourite-words t]
2051 ["Rescore buffer" gnus-summary-rescore t]
2052 ["Increase score..." gnus-summary-increase-score t]
2053 ["Lower score..." gnus-summary-lower-score t]))))
2055 ;; Define both the Article menu in the summary buffer and the
2056 ;; equivalent Commands menu in the article buffer here for
2060 ["All" gnus-article-hide t]
2061 ["Headers" gnus-article-hide-headers t]
2062 ["Signature" gnus-article-hide-signature t]
2063 ["Citation" gnus-article-hide-citation t]
2064 ["List identifiers" gnus-article-hide-list-identifiers t]
2065 ["Banner" gnus-article-strip-banner t]
2066 ["Boring headers" gnus-article-hide-boring-headers t])
2068 ["All" gnus-article-highlight t]
2069 ["Headers" gnus-article-highlight-headers t]
2070 ["Signature" gnus-article-highlight-signature t]
2071 ["Citation" gnus-article-highlight-citation t])
2073 ["Local" gnus-article-date-local t]
2074 ["ISO8601" gnus-article-date-iso8601 t]
2075 ["UT" gnus-article-date-ut t]
2076 ["Original" gnus-article-date-original t]
2077 ["Lapsed" gnus-article-date-lapsed t]
2078 ["User-defined" gnus-article-date-user t])
2080 ["Remove images" gnus-article-remove-images t]
2081 ["Toggle smiley" gnus-treat-smiley t]
2082 ["Show X-Face" gnus-article-display-x-face t]
2083 ["Show picons in From" gnus-treat-from-picon t]
2084 ["Show picons in mail headers" gnus-treat-mail-picon t]
2085 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2086 ("View as different encoding"
2087 ,@(gnus-summary-menu-split
2090 ;; Since easymenu under FSF Emacs doesn't allow lambda
2091 ;; forms for menu commands, we should provide intern'ed
2092 ;; function symbols.
2093 (let ((command (intern (format "\
2094 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2098 (let ((gnus-summary-show-article-charset-alist
2100 (gnus-summary-show-article 1))))
2101 `[,(symbol-name cs) ,command t]))
2102 (sort (if (fboundp 'coding-system-list)
2103 (coding-system-list)
2104 ;;(mapcar 'car mm-mime-mule-charset-alist)
2109 ["Leading" gnus-article-strip-leading-blank-lines t]
2110 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2111 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2112 ["All of the above" gnus-article-strip-blank-lines t]
2113 ["All" gnus-article-strip-all-blank-lines t]
2114 ["Leading space" gnus-article-strip-leading-space t]
2115 ["Trailing space" gnus-article-strip-trailing-space t]
2116 ["Leading space in headers"
2117 gnus-article-remove-leading-whitespace t])
2118 ["Overstrike" gnus-article-treat-overstrike t]
2119 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2120 ["Emphasis" gnus-article-emphasize t]
2121 ["Word wrap" gnus-article-fill-cited-article t]
2122 ["Fill long lines" gnus-article-fill-long-lines t]
2123 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2124 ["CR" gnus-article-remove-cr t]
2125 ["Rot 13" gnus-summary-caesar-message
2126 ,@(if (featurep 'xemacs) '(t)
2127 '(:help "\"Caesar rotate\" article by 13"))]
2128 ["Morse decode" gnus-summary-morse-message t]
2129 ["Unix pipe..." gnus-summary-pipe-message t]
2130 ["Add buttons" gnus-article-add-buttons t]
2131 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2132 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2133 ["Toggle MIME" gnus-summary-toggle-mime t]
2134 ["Verbose header" gnus-summary-verbose-headers t]
2135 ["Toggle header" gnus-summary-toggle-header t]
2136 ["Unfold headers" gnus-article-treat-unfold-headers t]
2137 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2138 ["Html" gnus-article-wash-html t]
2139 ["URLs" gnus-article-unsplit-urls t]
2140 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2141 ["HZ" gnus-article-decode-HZ t]
2142 ("(Outlook) Deuglify"
2143 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2144 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2145 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2146 ["Full (Outlook) deuglify"
2147 gnus-article-outlook-deuglify-article t])
2150 ["Save in default format" gnus-summary-save-article
2151 ,@(if (featurep 'xemacs) '(t)
2152 '(:help "Save article using default method"))]
2153 ["Save in file" gnus-summary-save-article-file
2154 ,@(if (featurep 'xemacs) '(t)
2155 '(:help "Save article in file"))]
2156 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2157 ["Save in MH folder" gnus-summary-save-article-folder t]
2158 ["Save in VM folder" gnus-summary-save-article-vm t]
2159 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2160 ["Save body in file" gnus-summary-save-article-body-file t]
2161 ["Pipe through a filter" gnus-summary-pipe-output t]
2162 ["Add to SOUP packet" gnus-soup-add-article t]
2163 ["Print with Muttprint" gnus-summary-muttprint t]
2164 ["Print" gnus-summary-print-article t])
2166 ["Respool article..." gnus-summary-respool-article t]
2167 ["Move article..." gnus-summary-move-article
2168 (gnus-check-backend-function
2169 'request-move-article gnus-newsgroup-name)]
2170 ["Copy article..." gnus-summary-copy-article t]
2171 ["Crosspost article..." gnus-summary-crosspost-article
2172 (gnus-check-backend-function
2173 'request-replace-article gnus-newsgroup-name)]
2174 ["Import file..." gnus-summary-import-article t]
2175 ["Create article..." gnus-summary-create-article t]
2176 ["Check if posted" gnus-summary-article-posted-p t]
2177 ["Edit article" gnus-summary-edit-article
2178 (not (gnus-group-read-only-p))]
2179 ["Delete article" gnus-summary-delete-article
2180 (gnus-check-backend-function
2181 'request-expire-articles gnus-newsgroup-name)]
2182 ["Query respool" gnus-summary-respool-query t]
2183 ["Trace respool" gnus-summary-respool-trace t]
2184 ["Delete expirable articles" gnus-summary-expire-articles-now
2185 (gnus-check-backend-function
2186 'request-expire-articles gnus-newsgroup-name)])
2188 ["Uudecode" gnus-uu-decode-uu
2189 ,@(if (featurep 'xemacs) '(t)
2190 '(:help "Decode uuencoded article(s)"))]
2191 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2192 ["Unshar" gnus-uu-decode-unshar t]
2193 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2194 ["Save" gnus-uu-decode-save t]
2195 ["Binhex" gnus-uu-decode-binhex t]
2196 ["Postscript" gnus-uu-decode-postscript t])
2198 ["Enter article" gnus-cache-enter-article t]
2199 ["Remove article" gnus-cache-remove-article t])
2200 ["Translate" gnus-article-babel t]
2201 ["Select article buffer" gnus-summary-select-article-buffer t]
2202 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2203 ["Isearch article..." gnus-summary-isearch-article t]
2204 ["Beginning of the article" gnus-summary-beginning-of-article t]
2205 ["End of the article" gnus-summary-end-of-article t]
2206 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2207 ["Fetch referenced articles" gnus-summary-refer-references t]
2208 ["Fetch current thread" gnus-summary-refer-thread t]
2209 ["Fetch article with id..." gnus-summary-refer-article t]
2210 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2211 ["Redisplay" gnus-summary-show-article t]
2212 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2214 gnus-summary-article-menu gnus-summary-mode-map ""
2215 (cons "Article" innards))
2217 (if (not (keymapp gnus-summary-article-menu))
2219 gnus-article-commands-menu gnus-article-mode-map ""
2220 (cons "Commands" innards))
2221 ;; in Emacs, don't share menu.
2222 (setq gnus-article-commands-menu
2223 (copy-keymap gnus-summary-article-menu))
2224 (define-key gnus-article-mode-map [menu-bar commands]
2225 (cons "Commands" gnus-article-commands-menu))))
2228 gnus-summary-thread-menu gnus-summary-mode-map ""
2230 ["Find all messages in thread" gnus-summary-refer-thread t]
2231 ["Toggle threading" gnus-summary-toggle-threads t]
2232 ["Hide threads" gnus-summary-hide-all-threads t]
2233 ["Show threads" gnus-summary-show-all-threads t]
2234 ["Hide thread" gnus-summary-hide-thread t]
2235 ["Show thread" gnus-summary-show-thread t]
2236 ["Go to next thread" gnus-summary-next-thread t]
2237 ["Go to previous thread" gnus-summary-prev-thread t]
2238 ["Go down thread" gnus-summary-down-thread t]
2239 ["Go up thread" gnus-summary-up-thread t]
2240 ["Top of thread" gnus-summary-top-thread t]
2241 ["Mark thread as read" gnus-summary-kill-thread t]
2242 ["Lower thread score" gnus-summary-lower-thread t]
2243 ["Raise thread score" gnus-summary-raise-thread t]
2244 ["Rethread current" gnus-summary-rethread-current t]))
2247 gnus-summary-post-menu gnus-summary-mode-map ""
2249 ["Send a message (mail or news)" gnus-summary-post-news
2250 ,@(if (featurep 'xemacs) '(t)
2251 '(:help "Post an article"))]
2252 ["Followup" gnus-summary-followup
2253 ,@(if (featurep 'xemacs) '(t)
2254 '(:help "Post followup to this article"))]
2255 ["Followup and yank" gnus-summary-followup-with-original
2256 ,@(if (featurep 'xemacs) '(t)
2257 '(:help "Post followup to this article, quoting its contents"))]
2258 ["Supersede article" gnus-summary-supersede-article t]
2259 ["Cancel article" gnus-summary-cancel-article
2260 ,@(if (featurep 'xemacs) '(t)
2261 '(:help "Cancel an article you posted"))]
2262 ["Reply" gnus-summary-reply t]
2263 ["Reply and yank" gnus-summary-reply-with-original t]
2264 ["Wide reply" gnus-summary-wide-reply t]
2265 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2266 ,@(if (featurep 'xemacs) '(t)
2267 '(:help "Mail a reply, quoting this article"))]
2268 ["Very wide reply" gnus-summary-very-wide-reply t]
2269 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2270 ,@(if (featurep 'xemacs) '(t)
2271 '(:help "Mail a very wide reply, quoting this article"))]
2272 ["Mail forward" gnus-summary-mail-forward t]
2273 ["Post forward" gnus-summary-post-forward t]
2274 ["Digest and mail" gnus-summary-digest-mail-forward t]
2275 ["Digest and post" gnus-summary-digest-post-forward t]
2276 ["Resend message" gnus-summary-resend-message t]
2277 ["Resend message edit" gnus-summary-resend-message-edit t]
2278 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2279 ["Send a mail" gnus-summary-mail-other-window t]
2280 ["Create a local message" gnus-summary-news-other-window t]
2281 ["Uuencode and post" gnus-uu-post-news
2282 ,@(if (featurep 'xemacs) '(t)
2283 '(:help "Post a uuencoded article"))]
2284 ["Followup via news" gnus-summary-followup-to-mail t]
2285 ["Followup via news and yank"
2286 gnus-summary-followup-to-mail-with-original t]
2288 ;;["Send" gnus-summary-send-draft t]
2289 ;;["Send bounced" gnus-resend-bounced-mail t])
2293 ((not (keymapp gnus-summary-post-menu))
2294 (setq gnus-article-post-menu gnus-summary-post-menu))
2295 ((not gnus-article-post-menu)
2296 ;; Don't share post menu.
2297 (setq gnus-article-post-menu
2298 (copy-keymap gnus-summary-post-menu))))
2299 (define-key gnus-article-mode-map [menu-bar post]
2300 (cons "Post" gnus-article-post-menu))
2303 gnus-summary-misc-menu gnus-summary-mode-map ""
2306 ["Mark as read" gnus-summary-mark-as-read-forward t]
2307 ["Mark same subject and select"
2308 gnus-summary-kill-same-subject-and-select t]
2309 ["Mark same subject" gnus-summary-kill-same-subject t]
2310 ["Catchup" gnus-summary-catchup
2311 ,@(if (featurep 'xemacs) '(t)
2312 '(:help "Mark unread articles in this group as read"))]
2313 ["Catchup all" gnus-summary-catchup-all t]
2314 ["Catchup to here" gnus-summary-catchup-to-here t]
2315 ["Catchup from here" gnus-summary-catchup-from-here t]
2316 ["Catchup region" gnus-summary-mark-region-as-read
2317 (gnus-mark-active-p)]
2318 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2320 ["Tick" gnus-summary-tick-article-forward t]
2321 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2322 ["Remove marks" gnus-summary-clear-mark-forward t]
2323 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2324 ["Set bookmark" gnus-summary-set-bookmark t]
2325 ["Remove bookmark" gnus-summary-remove-bookmark t])
2327 ["Marks..." gnus-summary-limit-to-marks t]
2328 ["Subject..." gnus-summary-limit-to-subject t]
2329 ["Author..." gnus-summary-limit-to-author t]
2330 ["Age..." gnus-summary-limit-to-age t]
2331 ["Extra..." gnus-summary-limit-to-extra t]
2332 ["Score..." gnus-summary-limit-to-score t]
2333 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2334 ["Unread" gnus-summary-limit-to-unread t]
2335 ["Unseen" gnus-summary-limit-to-unseen t]
2336 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2337 ["Next articles" gnus-summary-limit-to-articles t]
2338 ["Pop limit" gnus-summary-pop-limit t]
2339 ["Show dormant" gnus-summary-limit-include-dormant t]
2340 ["Hide childless dormant"
2341 gnus-summary-limit-exclude-childless-dormant t]
2342 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2343 ["Hide marked" gnus-summary-limit-exclude-marks t]
2344 ["Show expunged" gnus-summary-limit-include-expunged t])
2346 ["Set mark" gnus-summary-mark-as-processable t]
2347 ["Remove mark" gnus-summary-unmark-as-processable t]
2348 ["Remove all marks" gnus-summary-unmark-all-processable t]
2349 ["Mark above" gnus-uu-mark-over t]
2350 ["Mark series" gnus-uu-mark-series t]
2351 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2352 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2353 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2354 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2355 ["Mark all" gnus-uu-mark-all t]
2356 ["Mark buffer" gnus-uu-mark-buffer t]
2357 ["Mark sparse" gnus-uu-mark-sparse t]
2358 ["Mark thread" gnus-uu-mark-thread t]
2359 ["Unmark thread" gnus-uu-unmark-thread t]
2360 ("Process Mark Sets"
2361 ["Kill" gnus-summary-kill-process-mark t]
2362 ["Yank" gnus-summary-yank-process-mark
2363 gnus-newsgroup-process-stack]
2364 ["Save" gnus-summary-save-process-mark t]
2365 ["Run command on marked..." gnus-summary-universal-argument t]))
2367 ["Page forward" gnus-summary-next-page
2368 ,@(if (featurep 'xemacs) '(t)
2369 '(:help "Show next page of article"))]
2370 ["Page backward" gnus-summary-prev-page
2371 ,@(if (featurep 'xemacs) '(t)
2372 '(:help "Show previous page of article"))]
2373 ["Line forward" gnus-summary-scroll-up t])
2375 ["Next unread article" gnus-summary-next-unread-article t]
2376 ["Previous unread article" gnus-summary-prev-unread-article t]
2377 ["Next article" gnus-summary-next-article t]
2378 ["Previous article" gnus-summary-prev-article t]
2379 ["Next unread subject" gnus-summary-next-unread-subject t]
2380 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2381 ["Next article same subject" gnus-summary-next-same-subject t]
2382 ["Previous article same subject" gnus-summary-prev-same-subject t]
2383 ["First unread article" gnus-summary-first-unread-article t]
2384 ["Best unread article" gnus-summary-best-unread-article t]
2385 ["Go to subject number..." gnus-summary-goto-subject t]
2386 ["Go to article number..." gnus-summary-goto-article t]
2387 ["Go to the last article" gnus-summary-goto-last-article t]
2388 ["Pop article off history" gnus-summary-pop-article t])
2390 ["Sort by number" gnus-summary-sort-by-number t]
2391 ["Sort by author" gnus-summary-sort-by-author t]
2392 ["Sort by subject" gnus-summary-sort-by-subject t]
2393 ["Sort by date" gnus-summary-sort-by-date t]
2394 ["Sort by score" gnus-summary-sort-by-score t]
2395 ["Sort by lines" gnus-summary-sort-by-lines t]
2396 ["Sort by characters" gnus-summary-sort-by-chars t]
2397 ["Randomize" gnus-summary-sort-by-random t]
2398 ["Original sort" gnus-summary-sort-by-original t])
2400 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2401 ["Describe group" gnus-summary-describe-group t]
2402 ["Fetch charter" gnus-group-fetch-charter
2403 ,@(if (featurep 'xemacs) nil
2404 '(:help "Display the charter of the current group"))]
2405 ["Fetch control message" gnus-group-fetch-control
2406 ,@(if (featurep 'xemacs) nil
2407 '(:help "Display the archived control message for the current group"))]
2408 ["Read manual" gnus-info-find-node t])
2410 ["Pick and read" gnus-pick-mode t]
2411 ["Binary" gnus-binary-mode t])
2413 ["Regenerate" gnus-summary-prepare t]
2414 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2415 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2416 ["Toggle threading" gnus-summary-toggle-threads t])
2417 ["See old articles" gnus-summary-insert-old-articles t]
2418 ["See new articles" gnus-summary-insert-new-articles t]
2419 ["Filter articles..." gnus-summary-execute-command t]
2420 ["Run command on articles..." gnus-summary-universal-argument t]
2421 ["Search articles forward..." gnus-summary-search-article-forward t]
2422 ["Search articles backward..." gnus-summary-search-article-backward t]
2423 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2424 ["Expand window" gnus-summary-expand-window t]
2425 ["Expire expirable articles" gnus-summary-expire-articles
2426 (gnus-check-backend-function
2427 'request-expire-articles gnus-newsgroup-name)]
2428 ["Edit local kill file" gnus-summary-edit-local-kill t]
2429 ["Edit main kill file" gnus-summary-edit-global-kill t]
2430 ["Edit group parameters" gnus-summary-edit-parameters t]
2431 ["Customize group parameters" gnus-summary-customize-parameters t]
2432 ["Send a bug report" gnus-bug t]
2434 ["Catchup and exit" gnus-summary-catchup-and-exit
2435 ,@(if (featurep 'xemacs) '(t)
2436 '(:help "Mark unread articles in this group as read, then exit"))]
2437 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2438 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2439 ["Exit group" gnus-summary-exit
2440 ,@(if (featurep 'xemacs) '(t)
2441 '(:help "Exit current group, return to group selection mode"))]
2442 ["Exit group without updating" gnus-summary-exit-no-update t]
2443 ["Exit and goto next group" gnus-summary-next-group t]
2444 ["Exit and goto prev group" gnus-summary-prev-group t]
2445 ["Reselect group" gnus-summary-reselect-current-group t]
2446 ["Rescan group" gnus-summary-rescan-group t]
2447 ["Update dribble" gnus-summary-save-newsrc t])))
2449 (gnus-run-hooks 'gnus-summary-menu-hook)))
2451 (defvar gnus-summary-tool-bar-map nil)
2453 ;; Emacs 21 tool bar. Should be no-op otherwise.
2454 (defun gnus-summary-make-tool-bar ()
2455 (if (and (fboundp 'tool-bar-add-item-from-menu)
2456 (default-value 'tool-bar-mode)
2457 (not gnus-summary-tool-bar-map))
2458 (setq gnus-summary-tool-bar-map
2459 (let ((tool-bar-map (make-sparse-keymap))
2460 (load-path (mm-image-load-path)))
2461 (tool-bar-add-item-from-menu
2462 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2463 (tool-bar-add-item-from-menu
2464 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2465 (tool-bar-add-item-from-menu
2466 'gnus-summary-post-news "post" gnus-summary-mode-map)
2467 (tool-bar-add-item-from-menu
2468 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2469 (tool-bar-add-item-from-menu
2470 'gnus-summary-followup "followup" gnus-summary-mode-map)
2471 (tool-bar-add-item-from-menu
2472 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2473 (tool-bar-add-item-from-menu
2474 'gnus-summary-reply "reply" gnus-summary-mode-map)
2475 (tool-bar-add-item-from-menu
2476 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2477 (tool-bar-add-item-from-menu
2478 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2479 (tool-bar-add-item-from-menu
2480 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2481 (tool-bar-add-item-from-menu
2482 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2483 (tool-bar-add-item-from-menu
2484 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2485 (tool-bar-add-item-from-menu
2486 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2487 (tool-bar-add-item-from-menu
2488 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2489 (tool-bar-add-item-from-menu
2490 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2492 (if gnus-summary-tool-bar-map
2493 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2495 (defun gnus-score-set-default (var value)
2496 "A version of set that updates the GNU Emacs menu-bar."
2498 ;; It is the message that forces the active status to be updated.
2501 (defun gnus-make-score-map (type)
2502 "Make a summary score map of type TYPE."
2505 (let ((headers '(("author" "from" string)
2506 ("subject" "subject" string)
2507 ("article body" "body" string)
2508 ("article head" "head" string)
2509 ("xref" "xref" string)
2510 ("extra header" "extra" string)
2511 ("lines" "lines" number)
2512 ("followups to author" "followup" string)))
2513 (types '((number ("less than" <)
2516 (string ("substring" s)
2520 (perms '(("temporary" (current-time-string))
2528 (if (eq type 'lower)
2533 (setq header (car headers))
2539 (let ((ts (cdr (assoc (nth 2 header) types)))
2555 'gnus-summary-score-entry
2557 (if (or (string= (nth 1 header)
2559 (string= (nth 1 header)
2562 (list 'gnus-summary-header
2564 (list 'quote (nth 1 (car ts)))
2565 (list 'gnus-score-delta-default
2572 (list (nreverse outp))))
2575 (list (nreverse outt))))
2577 (setq headers (cdr headers)))
2578 (list (nreverse outh))))))))
2582 (defun gnus-summary-mode (&optional group)
2583 "Major mode for reading articles.
2585 All normal editing commands are switched off.
2586 \\<gnus-summary-mode-map>
2587 Each line in this buffer represents one article. To read an
2588 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2589 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2592 You can also post articles and send mail from this buffer. To
2593 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2594 of an article, type `\\[gnus-summary-reply]'.
2596 There are approx. one gazillion commands you can execute in this
2597 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2599 The following commands are available:
2601 \\{gnus-summary-mode-map}"
2603 (kill-all-local-variables)
2604 (when (gnus-visual-p 'summary-menu 'menu)
2605 (gnus-summary-make-menu-bar)
2606 (gnus-summary-make-tool-bar))
2607 (gnus-summary-make-local-variables)
2608 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2609 (gnus-summary-make-local-variables))
2610 (gnus-make-thread-indent-array)
2611 (gnus-simplify-mode-line)
2612 (setq major-mode 'gnus-summary-mode)
2613 (setq mode-name "Summary")
2614 (make-local-variable 'minor-mode-alist)
2615 (use-local-map gnus-summary-mode-map)
2616 (buffer-disable-undo)
2617 (setq buffer-read-only t) ;Disable modification
2618 (setq truncate-lines t)
2619 (setq selective-display t)
2620 (setq selective-display-ellipses t) ;Display `...'
2621 (gnus-summary-set-display-table)
2622 (gnus-set-default-directory)
2623 (setq gnus-newsgroup-name group)
2624 (unless (gnus-news-group-p group)
2625 (setq gnus-newsgroup-incorporated
2626 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2627 (make-local-variable 'gnus-summary-line-format)
2628 (make-local-variable 'gnus-summary-line-format-spec)
2629 (make-local-variable 'gnus-summary-dummy-line-format)
2630 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2631 (make-local-variable 'gnus-summary-mark-positions)
2632 (make-local-hook 'pre-command-hook)
2633 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2634 (gnus-run-hooks 'gnus-summary-mode-hook)
2635 (turn-on-gnus-mailing-list-mode)
2636 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2637 (gnus-update-summary-mark-positions))
2639 (defun gnus-summary-make-local-variables ()
2640 "Make all the local summary buffer variables."
2642 (dolist (local gnus-summary-local-variables)
2645 (if (eq (cdr local) 'global)
2646 ;; Copy the global value of the variable.
2647 (setq global (symbol-value (car local)))
2648 ;; Use the value from the list.
2649 (setq global (eval (cdr local))))
2650 (set (make-local-variable (car local)) global))
2651 ;; Simple nil-valued local variable.
2652 (set (make-local-variable local) nil)))))
2654 (defun gnus-summary-clear-local-variables ()
2655 (let ((locals gnus-summary-local-variables))
2657 (if (consp (car locals))
2658 (and (vectorp (caar locals))
2659 (set (caar locals) nil))
2660 (and (vectorp (car locals))
2661 (set (car locals) nil)))
2662 (setq locals (cdr locals)))))
2664 ;; Summary data functions.
2666 (defmacro gnus-data-number (data)
2669 (defmacro gnus-data-set-number (data number)
2670 `(setcar ,data ,number))
2672 (defmacro gnus-data-mark (data)
2675 (defmacro gnus-data-set-mark (data mark)
2676 `(setcar (nthcdr 1 ,data) ,mark))
2678 (defmacro gnus-data-pos (data)
2681 (defmacro gnus-data-set-pos (data pos)
2682 `(setcar (nthcdr 2 ,data) ,pos))
2684 (defmacro gnus-data-header (data)
2687 (defmacro gnus-data-set-header (data header)
2688 `(setcar (nthcdr 3 ,data) ,header))
2690 (defmacro gnus-data-level (data)
2693 (defmacro gnus-data-unread-p (data)
2694 `(= (nth 1 ,data) gnus-unread-mark))
2696 (defmacro gnus-data-read-p (data)
2697 `(/= (nth 1 ,data) gnus-unread-mark))
2699 (defmacro gnus-data-pseudo-p (data)
2700 `(consp (nth 3 ,data)))
2702 (defmacro gnus-data-find (number)
2703 `(assq ,number gnus-newsgroup-data))
2705 (defmacro gnus-data-find-list (number &optional data)
2706 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2707 (memq (assq ,number bdata)
2710 (defmacro gnus-data-make (number mark pos header level)
2711 `(list ,number ,mark ,pos ,header ,level))
2713 (defun gnus-data-enter (after-article number mark pos header level offset)
2714 (let ((data (gnus-data-find-list after-article)))
2716 (error "No such article: %d" after-article))
2717 (setcdr data (cons (gnus-data-make number mark pos header level)
2719 (setq gnus-newsgroup-data-reverse nil)
2720 (gnus-data-update-list (cddr data) offset)))
2722 (defun gnus-data-enter-list (after-article list &optional offset)
2724 (let ((data (and after-article (gnus-data-find-list after-article)))
2728 (let ((odata gnus-newsgroup-data))
2729 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2731 (gnus-data-update-list odata offset)))
2732 ;; Find the last element in the list to be spliced into the main
2735 (setq list (cdr list)))
2738 (setcdr list gnus-newsgroup-data)
2739 (setq gnus-newsgroup-data ilist)
2741 (gnus-data-update-list (cdr list) offset)))
2742 (setcdr list (cdr data))
2745 (gnus-data-update-list (cdr list) offset))))
2746 (setq gnus-newsgroup-data-reverse nil))))
2748 (defun gnus-data-remove (article &optional offset)
2749 (let ((data gnus-newsgroup-data))
2750 (if (= (gnus-data-number (car data)) article)
2752 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2753 gnus-newsgroup-data-reverse nil)
2755 (gnus-data-update-list gnus-newsgroup-data offset)))
2757 (when (= (gnus-data-number (cadr data)) article)
2758 (setcdr data (cddr data))
2760 (gnus-data-update-list (cdr data) offset))
2762 gnus-newsgroup-data-reverse nil))
2763 (setq data (cdr data))))))
2765 (defmacro gnus-data-list (backward)
2767 (or gnus-newsgroup-data-reverse
2768 (setq gnus-newsgroup-data-reverse
2769 (reverse gnus-newsgroup-data)))
2770 gnus-newsgroup-data))
2772 (defun gnus-data-update-list (data offset)
2773 "Add OFFSET to the POS of all data entries in DATA."
2774 (setq gnus-newsgroup-data-reverse nil)
2776 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2777 (setq data (cdr data))))
2779 (defun gnus-summary-article-pseudo-p (article)
2780 "Say whether this article is a pseudo article or not."
2781 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2783 (defmacro gnus-summary-article-sparse-p (article)
2784 "Say whether this article is a sparse article or not."
2785 `(memq ,article gnus-newsgroup-sparse))
2787 (defmacro gnus-summary-article-ancient-p (article)
2788 "Say whether this article is a sparse article or not."
2789 `(memq ,article gnus-newsgroup-ancient))
2791 (defun gnus-article-parent-p (number)
2792 "Say whether this article is a parent or not."
2793 (let ((data (gnus-data-find-list number)))
2794 (and (cdr data) ; There has to be an article after...
2795 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2796 (gnus-data-level (nth 1 data))))))
2798 (defun gnus-article-children (number)
2799 "Return a list of all children to NUMBER."
2800 (let* ((data (gnus-data-find-list number))
2801 (level (gnus-data-level (car data)))
2803 (setq data (cdr data))
2805 (= (gnus-data-level (car data)) (1+ level)))
2806 (push (gnus-data-number (car data)) children)
2807 (setq data (cdr data)))
2810 (defmacro gnus-summary-skip-intangible ()
2811 "If the current article is intangible, then jump to a different article."
2812 '(let ((to (get-text-property (point) 'gnus-intangible)))
2813 (and to (gnus-summary-goto-subject to))))
2815 (defmacro gnus-summary-article-intangible-p ()
2816 "Say whether this article is intangible or not."
2817 '(get-text-property (point) 'gnus-intangible))
2819 (defun gnus-article-read-p (article)
2820 "Say whether ARTICLE is read or not."
2821 (not (or (memq article gnus-newsgroup-marked)
2822 (memq article gnus-newsgroup-spam-marked)
2823 (memq article gnus-newsgroup-unreads)
2824 (memq article gnus-newsgroup-unselected)
2825 (memq article gnus-newsgroup-dormant))))
2827 ;; Some summary mode macros.
2829 (defmacro gnus-summary-article-number ()
2830 "The article number of the article on the current line.
2831 If there isn't an article number here, then we return the current
2834 (gnus-summary-skip-intangible)
2835 (or (get-text-property (point) 'gnus-number)
2836 (gnus-summary-last-subject))))
2838 (defmacro gnus-summary-article-header (&optional number)
2839 "Return the header of article NUMBER."
2840 `(gnus-data-header (gnus-data-find
2841 ,(or number '(gnus-summary-article-number)))))
2843 (defmacro gnus-summary-thread-level (&optional number)
2844 "Return the level of thread that starts with article NUMBER."
2845 `(if (and (eq gnus-summary-make-false-root 'dummy)
2846 (get-text-property (point) 'gnus-intangible))
2848 (gnus-data-level (gnus-data-find
2849 ,(or number '(gnus-summary-article-number))))))
2851 (defmacro gnus-summary-article-mark (&optional number)
2852 "Return the mark of article NUMBER."
2853 `(gnus-data-mark (gnus-data-find
2854 ,(or number '(gnus-summary-article-number)))))
2856 (defmacro gnus-summary-article-pos (&optional number)
2857 "Return the position of the line of article NUMBER."
2858 `(gnus-data-pos (gnus-data-find
2859 ,(or number '(gnus-summary-article-number)))))
2861 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2862 (defmacro gnus-summary-article-subject (&optional number)
2863 "Return current subject string or nil if nothing."
2866 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2867 '(gnus-data-header (assq (gnus-summary-article-number)
2868 gnus-newsgroup-data)))))
2871 (mail-header-subject headers))))
2873 (defmacro gnus-summary-article-score (&optional number)
2874 "Return current article score."
2875 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2876 gnus-newsgroup-scored))
2877 gnus-summary-default-score 0))
2879 (defun gnus-summary-article-children (&optional number)
2880 "Return a list of article numbers that are children of article NUMBER."
2881 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2882 (level (gnus-data-level (car data)))
2884 (while (and (setq data (cdr data))
2885 (> (setq l (gnus-data-level (car data))) level))
2886 (and (= (1+ level) l)
2887 (push (gnus-data-number (car data))
2889 (nreverse children)))
2891 (defun gnus-summary-article-parent (&optional number)
2892 "Return the article number of the parent of article NUMBER."
2893 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2894 (gnus-data-list t)))
2895 (level (gnus-data-level (car data))))
2897 () ; This is a root.
2898 ;; We search until we find an article with a level less than
2899 ;; this one. That function has to be the parent.
2900 (while (and (setq data (cdr data))
2901 (not (< (gnus-data-level (car data)) level))))
2902 (and data (gnus-data-number (car data))))))
2904 (defun gnus-unread-mark-p (mark)
2905 "Say whether MARK is the unread mark."
2906 (= mark gnus-unread-mark))
2908 (defun gnus-read-mark-p (mark)
2909 "Say whether MARK is one of the marks that mark as read.
2910 This is all marks except unread, ticked, dormant, and expirable."
2911 (not (or (= mark gnus-unread-mark)
2912 (= mark gnus-ticked-mark)
2913 (= mark gnus-spam-mark)
2914 (= mark gnus-dormant-mark)
2915 (= mark gnus-expirable-mark))))
2917 (defmacro gnus-article-mark (number)
2918 "Return the MARK of article NUMBER.
2919 This macro should only be used when computing the mark the \"first\"
2920 time; i.e., when generating the summary lines. After that,
2921 `gnus-summary-article-mark' should be used to examine the
2924 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2925 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2926 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2927 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2928 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2929 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2930 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2931 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2932 gnus-ancient-mark))))
2934 ;; Saving hidden threads.
2936 (defmacro gnus-save-hidden-threads (&rest forms)
2937 "Save hidden threads, eval FORMS, and restore the hidden threads."
2938 (let ((config (make-symbol "config")))
2939 `(let ((,config (gnus-hidden-threads-configuration)))
2943 (gnus-restore-hidden-threads-configuration ,config)))))
2944 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2945 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2947 (defun gnus-data-compute-positions ()
2948 "Compute the positions of all articles."
2949 (setq gnus-newsgroup-data-reverse nil)
2950 (let ((data gnus-newsgroup-data))
2952 (gnus-save-hidden-threads
2953 (gnus-summary-show-all-threads)
2954 (goto-char (point-min))
2956 (while (get-text-property (point) 'gnus-intangible)
2958 (gnus-data-set-pos (car data) (+ (point) 3))
2959 (setq data (cdr data))
2960 (forward-line 1))))))
2962 (defun gnus-hidden-threads-configuration ()
2963 "Return the current hidden threads configuration."
2966 (goto-char (point-min))
2967 (while (search-forward "\r" nil t)
2968 (push (1- (point)) config))
2971 (defun gnus-restore-hidden-threads-configuration (config)
2972 "Restore hidden threads configuration from CONFIG."
2974 (let (point buffer-read-only)
2975 (while (setq point (pop config))
2976 (when (and (< point (point-max))
2978 (eq (char-after) ?\n))
2979 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2981 ;; Various summary mode internalish functions.
2983 (defun gnus-mouse-pick-article (e)
2986 (gnus-summary-next-page nil t))
2988 (defun gnus-summary-set-display-table ()
2989 "Change the display table.
2990 Odd characters have a tendency to mess
2991 up nicely formatted displays - we make all possible glyphs
2992 display only a single character."
2994 ;; We start from the standard display table, if any.
2995 (let ((table (or (copy-sequence standard-display-table)
2996 (make-display-table)))
2998 ;; Nix out all the control chars...
2999 (while (>= (setq i (1- i)) 0)
3000 (aset table i [??]))
3001 ;; ... but not newline and cr, of course. (cr is necessary for the
3002 ;; selective display).
3003 (aset table ?\n nil)
3004 (aset table ?\r nil)
3005 ;; We keep TAB as well.
3006 (aset table ?\t nil)
3007 ;; We nix out any glyphs over 126 that are not set already.
3009 (while (>= (setq i (1- i)) 127)
3010 ;; Only modify if the entry is nil.
3011 (unless (aref table i)
3012 (aset table i [??]))))
3013 (setq buffer-display-table table)))
3015 (defun gnus-summary-set-article-display-arrow (pos)
3016 "Update the overlay arrow to point to line at position POS."
3017 (when (and gnus-summary-display-arrow
3018 (boundp 'overlay-arrow-position)
3019 (boundp 'overlay-arrow-string))
3023 (unless overlay-arrow-position
3024 (setq overlay-arrow-position (make-marker)))
3025 (setq overlay-arrow-string "=>"
3026 overlay-arrow-position (set-marker overlay-arrow-position
3028 (current-buffer))))))
3030 (defun gnus-summary-buffer-name (group)
3031 "Return the summary buffer name of GROUP."
3032 (concat "*Summary " (gnus-group-decoded-name group) "*"))
3034 (defun gnus-summary-setup-buffer (group)
3035 "Initialize summary buffer."
3036 (let ((buffer (gnus-summary-buffer-name group))
3037 (dead-name (concat "*Dead Summary "
3038 (gnus-group-decoded-name group) "*")))
3039 ;; If a dead summary buffer exists, we kill it.
3040 (when (gnus-buffer-live-p dead-name)
3041 (gnus-kill-buffer dead-name))
3042 (if (get-buffer buffer)
3045 (setq gnus-summary-buffer (current-buffer))
3046 (not gnus-newsgroup-prepared))
3047 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3048 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3049 (gnus-summary-mode group)
3051 (gnus-carpal-setup-buffer 'summary))
3052 (unless gnus-single-article-buffer
3053 (make-local-variable 'gnus-article-buffer)
3054 (make-local-variable 'gnus-article-current)
3055 (make-local-variable 'gnus-original-article-buffer))
3056 (setq gnus-newsgroup-name group)
3057 ;; Set any local variables in the group parameters.
3058 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3061 (defun gnus-set-global-variables ()
3062 "Set the global equivalents of the buffer-local variables.
3063 They are set to the latest values they had. These reflect the summary
3064 buffer that was in action when the last article was fetched."
3065 (when (eq major-mode 'gnus-summary-mode)
3066 (setq gnus-summary-buffer (current-buffer))
3067 (let ((name gnus-newsgroup-name)
3068 (marked gnus-newsgroup-marked)
3069 (spam gnus-newsgroup-spam-marked)
3070 (unread gnus-newsgroup-unreads)
3071 (headers gnus-current-headers)
3072 (data gnus-newsgroup-data)
3073 (summary gnus-summary-buffer)
3074 (article-buffer gnus-article-buffer)
3075 (original gnus-original-article-buffer)
3076 (gac gnus-article-current)
3077 (reffed gnus-reffed-article-number)
3078 (score-file gnus-current-score-file)
3079 (default-charset gnus-newsgroup-charset)
3081 (let ((locals gnus-newsgroup-variables))
3083 (if (consp (car locals))
3084 (push (eval (caar locals)) vlist)
3085 (push (eval (car locals)) vlist))
3086 (setq locals (cdr locals)))
3087 (setq vlist (nreverse vlist)))
3089 (set-buffer gnus-group-buffer)
3090 (setq gnus-newsgroup-name name
3091 gnus-newsgroup-marked marked
3092 gnus-newsgroup-spam-marked spam
3093 gnus-newsgroup-unreads unread
3094 gnus-current-headers headers
3095 gnus-newsgroup-data data
3096 gnus-article-current gac
3097 gnus-summary-buffer summary
3098 gnus-article-buffer article-buffer
3099 gnus-original-article-buffer original
3100 gnus-reffed-article-number reffed
3101 gnus-current-score-file score-file
3102 gnus-newsgroup-charset default-charset)
3103 (let ((locals gnus-newsgroup-variables))
3105 (if (consp (car locals))
3106 (set (caar locals) (pop vlist))
3107 (set (car locals) (pop vlist)))
3108 (setq locals (cdr locals))))
3109 ;; The article buffer also has local variables.
3110 (when (gnus-buffer-live-p gnus-article-buffer)
3111 (set-buffer gnus-article-buffer)
3112 (setq gnus-summary-buffer summary))))))
3114 (defun gnus-summary-article-unread-p (article)
3115 "Say whether ARTICLE is unread or not."
3116 (memq article gnus-newsgroup-unreads))
3118 (defun gnus-summary-first-article-p (&optional article)
3119 "Return whether ARTICLE is the first article in the buffer."
3120 (if (not (setq article (or article (gnus-summary-article-number))))
3122 (eq article (caar gnus-newsgroup-data))))
3124 (defun gnus-summary-last-article-p (&optional article)
3125 "Return whether ARTICLE is the last article in the buffer."
3126 (if (not (setq article (or article (gnus-summary-article-number))))
3127 ;; All non-existent numbers are the last article. :-)
3129 (not (cdr (gnus-data-find-list article)))))
3131 (defun gnus-make-thread-indent-array ()
3133 (unless (and gnus-thread-indent-array
3134 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3135 (setq gnus-thread-indent-array (make-vector 201 "")
3136 gnus-thread-indent-array-level gnus-thread-indent-level)
3138 (aset gnus-thread-indent-array n
3139 (make-string (* n gnus-thread-indent-level) ? ))
3142 (defun gnus-update-summary-mark-positions ()
3143 "Compute where the summary marks are to go."
3145 (when (gnus-buffer-exists-p gnus-summary-buffer)
3146 (set-buffer gnus-summary-buffer))
3147 (let ((gnus-replied-mark 129)
3148 (gnus-score-below-mark 130)
3149 (gnus-score-over-mark 130)
3150 (gnus-undownloaded-mark 131)
3151 (spec gnus-summary-line-format-spec)
3154 (gnus-set-work-buffer)
3155 (let ((gnus-summary-line-format-spec spec)
3156 (gnus-newsgroup-downloadable '(0)))
3157 (gnus-summary-insert-line
3158 (make-full-mail-header 0 "" "nobody"
3159 "05 Apr 2001 23:33:09 +0400"
3161 0 nil t 128 t nil "" nil 1)
3162 (goto-char (point-min))
3163 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3164 (- (point) (point-min) 1)))))
3165 (goto-char (point-min))
3166 (push (cons 'replied (and (search-forward "\201" nil t)
3167 (- (point) (point-min) 1)))
3169 (goto-char (point-min))
3170 (push (cons 'score (and (search-forward "\202" nil t)
3171 (- (point) (point-min) 1)))
3173 (goto-char (point-min))
3174 (push (cons 'download
3175 (and (search-forward "\203" nil t)
3176 (- (point) (point-min) 1)))
3178 (setq gnus-summary-mark-positions pos))))
3180 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3181 "Insert a dummy root in the summary buffer."
3183 (gnus-add-text-properties
3184 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3185 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3187 (defun gnus-summary-extract-address-component (from)
3188 (or (car (funcall gnus-extract-address-components from))
3191 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3192 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3193 default-mime-charset)))
3194 ;; Is it really necessary to do this next part for each summary line?
3195 ;; Luckily, doesn't seem to slow things down much.
3197 (and gnus-ignored-from-addresses
3198 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3199 (let ((extra-headers (mail-header-extra header))
3203 ((setq to (cdr (assq 'To extra-headers)))
3206 (gnus-summary-extract-address-component
3207 (funcall gnus-decode-encoded-word-function to)))))
3208 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3209 (concat "=> " newsgroups)))))
3210 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3212 (defun gnus-summary-insert-line (gnus-tmp-header
3213 gnus-tmp-level gnus-tmp-current
3214 undownloaded gnus-tmp-unread gnus-tmp-replied
3215 gnus-tmp-expirable gnus-tmp-subject-or-nil
3216 &optional gnus-tmp-dummy gnus-tmp-score
3218 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3219 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3220 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3221 (gnus-tmp-score-char
3222 (if (or (null gnus-summary-default-score)
3223 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3224 gnus-summary-zcore-fuzz))
3226 (if (< gnus-tmp-score gnus-summary-default-score)
3227 gnus-score-below-mark gnus-score-over-mark)))
3228 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3230 (cond (gnus-tmp-process gnus-process-mark)
3231 ((memq gnus-tmp-current gnus-newsgroup-cached)
3233 (gnus-tmp-replied gnus-replied-mark)
3234 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3235 gnus-forwarded-mark)
3236 ((memq gnus-tmp-current gnus-newsgroup-saved)
3238 ((memq gnus-tmp-number gnus-newsgroup-recent)
3240 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3243 (gnus-tmp-downloaded
3245 gnus-undownloaded-mark)
3246 (gnus-newsgroup-agentized
3247 gnus-downloaded-mark)
3250 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3253 ((string-match "<[^>]+> *$" gnus-tmp-from)
3254 (let ((beg (match-beginning 0)))
3255 (or (and (string-match "^\".+\"" gnus-tmp-from)
3256 (substring gnus-tmp-from 1 (1- (match-end 0))))
3257 (substring gnus-tmp-from 0 beg))))
3258 ((string-match "(.+)" gnus-tmp-from)
3259 (substring gnus-tmp-from
3260 (1+ (match-beginning 0)) (1- (match-end 0))))
3262 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3263 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3264 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3265 (buffer-read-only nil))
3266 (when (string= gnus-tmp-name "")
3267 (setq gnus-tmp-name gnus-tmp-from))
3268 (unless (numberp gnus-tmp-lines)
3269 (setq gnus-tmp-lines -1))
3270 (if (= gnus-tmp-lines -1)
3271 (setq gnus-tmp-lines "?")
3272 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3273 (gnus-put-text-property-excluding-characters-with-faces
3275 (progn (eval gnus-summary-line-format-spec) (point))
3276 'gnus-number gnus-tmp-number)
3277 (when (gnus-visual-p 'summary-highlight 'highlight)
3279 (gnus-run-hooks 'gnus-summary-update-hook)
3282 (defun gnus-summary-update-line (&optional dont-update)
3283 "Update summary line after change."
3284 (when (and gnus-summary-default-score
3285 (not gnus-summary-inhibit-highlight))
3286 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3287 (article (gnus-summary-article-number))
3288 (score (gnus-summary-article-score article)))
3290 (if (and gnus-summary-mark-below
3291 (< (gnus-summary-article-score)
3292 gnus-summary-mark-below))
3293 ;; This article has a low score, so we mark it as read.
3294 (when (memq article gnus-newsgroup-unreads)
3295 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3296 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3297 ;; This article was previously marked as read on account
3298 ;; of a low score, but now it has risen, so we mark it as
3300 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3301 (gnus-summary-update-mark
3302 (if (or (null gnus-summary-default-score)
3303 (<= (abs (- score gnus-summary-default-score))
3304 gnus-summary-zcore-fuzz))
3306 (if (< score gnus-summary-default-score)
3307 gnus-score-below-mark gnus-score-over-mark))
3309 ;; Do visual highlighting.
3310 (when (gnus-visual-p 'summary-highlight 'highlight)
3311 (gnus-run-hooks 'gnus-summary-update-hook)))))
3313 (defvar gnus-tmp-new-adopts nil)
3315 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3316 "Return the number of articles in THREAD.
3317 This may be 0 in some cases -- if none of the articles in
3318 the thread are to be displayed."
3320 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3322 ((not (listp thread))
3324 ((and (consp thread) (cdr thread))
3327 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3330 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3333 (when (and level (zerop level) gnus-tmp-new-adopts)
3336 'gnus-summary-number-of-articles-in-thread
3337 gnus-tmp-new-adopts))))
3339 (if (> number 1) gnus-not-empty-thread-mark
3340 gnus-empty-thread-mark)
3343 (defsubst gnus-summary-line-message-size (head)
3344 "Return pretty-printed version of message size.
3345 This function is intended to be used in
3346 `gnus-summary-line-format-alist', which see."
3347 (let ((c (or (mail-header-chars head) -1)))
3348 (cond ((< c 0) "n/a") ; chars not available
3349 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3350 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3351 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3352 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3355 (defun gnus-summary-set-local-parameters (group)
3356 "Go through the local params of GROUP and set all variable specs in that list."
3357 (let ((params (gnus-group-find-parameter group))
3358 (vars '(quit-config)) ; Ignore quit-config.
3361 (setq elem (car params)
3362 params (cdr params))
3363 (and (consp elem) ; Has to be a cons.
3364 (consp (cdr elem)) ; The cdr has to be a list.
3365 (symbolp (car elem)) ; Has to be a symbol in there.
3366 (not (memq (car elem) vars))
3367 (ignore-errors ; So we set it.
3368 (push (car elem) vars)
3369 (make-local-variable (car elem))
3370 (set (car elem) (eval (nth 1 elem))))))))
3372 (defun gnus-summary-read-group (group &optional show-all no-article
3373 kill-buffer no-display backward
3375 "Start reading news in newsgroup GROUP.
3376 If SHOW-ALL is non-nil, already read articles are also listed.
3377 If NO-ARTICLE is non-nil, no article is selected initially.
3378 If NO-DISPLAY, don't generate a summary buffer."
3382 (let ((gnus-auto-select-next nil))
3383 (or (gnus-summary-read-group-1
3384 group show-all no-article
3385 kill-buffer no-display
3388 select-articles nil)))))
3389 (eq gnus-auto-select-next 'quietly))
3390 (set-buffer gnus-group-buffer)
3391 ;; The entry function called above goes to the next
3392 ;; group automatically, so we go two groups back
3393 ;; if we are searching for the previous group.
3395 (gnus-group-prev-unread-group 2))
3396 (if (not (equal group (gnus-group-group-name)))
3397 (setq group (gnus-group-group-name))
3401 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3402 "Directly jump to the other GROUP from summary buffer.
3403 If SHOW-ALL is non-nil, already read articles are also listed."
3405 (if (eq gnus-summary-buffer (current-buffer))
3406 (list (completing-read
3407 "Group: " gnus-active-hashtb nil t
3408 (when (and gnus-newsgroup-name
3409 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3410 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3411 'gnus-group-history)
3413 (error "%s must be invoked from a gnus summary buffer." this-command)))
3414 (unless (or (zerop (length group))
3415 (and gnus-newsgroup-name
3416 (string-equal gnus-newsgroup-name group)))
3418 (gnus-summary-read-group group show-all
3419 gnus-dont-select-after-jump-to-other-group)))
3421 (defun gnus-summary-read-group-1 (group show-all no-article
3422 kill-buffer no-display
3423 &optional select-articles)
3424 ;; Killed foreign groups can't be entered.
3425 ;; (when (and (not (gnus-group-native-p group))
3426 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3427 ;; (error "Dead non-native groups can't be entered"))
3428 (gnus-message 5 "Retrieving newsgroup: %s..."
3429 (gnus-group-decoded-name group))
3430 (let* ((new-group (gnus-summary-setup-buffer group))
3431 (quit-config (gnus-group-quit-config group))
3432 (did-select (and new-group (gnus-select-newsgroup
3433 group show-all select-articles))))
3435 ;; This summary buffer exists already, so we just select it.
3437 (gnus-set-global-variables)
3439 (gnus-kill-or-deaden-summary kill-buffer))
3440 (gnus-configure-windows 'summary 'force)
3441 (gnus-set-mode-line 'summary)
3442 (gnus-summary-position-point)
3445 ;; We couldn't select this group.
3447 (when (and (eq major-mode 'gnus-summary-mode)
3448 (not (equal (current-buffer) kill-buffer)))
3449 (kill-buffer (current-buffer))
3450 (if (not quit-config)
3452 ;; Update the info -- marks might need to be removed,
3454 (gnus-summary-update-info)
3455 (set-buffer gnus-group-buffer)
3456 (gnus-group-jump-to-group group)
3457 (gnus-group-next-unread-group 1))
3458 (gnus-handle-ephemeral-exit quit-config)))
3459 (let ((grpinfo (gnus-get-info group)))
3460 (if (null (gnus-info-read grpinfo))
3461 (gnus-message 3 "Group %s contains no messages"
3462 (gnus-group-decoded-name group))
3463 (gnus-message 3 "Can't select group")))
3465 ;; The user did a `C-g' while prompting for number of articles,
3466 ;; so we exit this group.
3467 ((eq did-select 'quit)
3468 (and (eq major-mode 'gnus-summary-mode)
3469 (not (equal (current-buffer) kill-buffer))
3470 (kill-buffer (current-buffer)))
3472 (gnus-kill-or-deaden-summary kill-buffer))
3473 (if (not quit-config)
3475 (set-buffer gnus-group-buffer)
3476 (gnus-group-jump-to-group group)
3477 (gnus-group-next-unread-group 1)
3478 (gnus-configure-windows 'group 'force))
3479 (gnus-handle-ephemeral-exit quit-config))
3480 ;; Finally signal the quit.
3482 ;; The group was successfully selected.
3484 (gnus-set-global-variables)
3485 ;; Save the active value in effect when the group was entered.
3486 (setq gnus-newsgroup-active
3488 (gnus-active gnus-newsgroup-name)))
3489 ;; You can change the summary buffer in some way with this hook.
3490 (gnus-run-hooks 'gnus-select-group-hook)
3491 (gnus-update-format-specifications
3492 nil 'summary 'summary-mode 'summary-dummy)
3493 (gnus-update-summary-mark-positions)
3494 ;; Do score processing.
3495 (when gnus-use-scoring
3496 (gnus-possibly-score-headers))
3497 ;; Check whether to fill in the gaps in the threads.
3498 (when gnus-build-sparse-threads
3499 (gnus-build-sparse-threads))
3500 ;; Find the initial limit.
3501 (if gnus-show-threads
3503 (let ((gnus-newsgroup-dormant nil))
3504 (gnus-summary-initial-limit show-all))
3505 (gnus-summary-initial-limit show-all))
3506 ;; When unthreaded, all articles are always shown.
3507 (setq gnus-newsgroup-limit
3509 (lambda (header) (mail-header-number header))
3510 gnus-newsgroup-headers)))
3511 ;; Generate the summary buffer.
3513 (gnus-summary-prepare))
3514 (when gnus-use-trees
3515 (gnus-tree-open group)
3516 (setq gnus-summary-highlight-line-function
3517 'gnus-tree-highlight-article))
3518 ;; If the summary buffer is empty, but there are some low-scored
3519 ;; articles or some excluded dormants, we include these in the
3521 (when (and (zerop (buffer-size))
3523 (cond (gnus-newsgroup-dormant
3524 (gnus-summary-limit-include-dormant))
3525 ((and gnus-newsgroup-scored show-all)
3526 (gnus-summary-limit-include-expunged t))))
3527 ;; Function `gnus-apply-kill-file' must be called in this hook.
3528 (gnus-run-hooks 'gnus-apply-kill-hook)
3529 (if (and (zerop (buffer-size))
3532 ;; This newsgroup is empty.
3533 (gnus-summary-catchup-and-exit nil t)
3534 (gnus-message 6 "No unread news")
3536 (gnus-kill-or-deaden-summary kill-buffer))
3537 ;; Return nil from this function.
3539 ;; Hide conversation thread subtrees. We cannot do this in
3540 ;; gnus-summary-prepare-hook since kill processing may not
3541 ;; work with hidden articles.
3542 (gnus-summary-maybe-hide-threads)
3544 (gnus-kill-or-deaden-summary kill-buffer))
3545 (gnus-summary-auto-select-subject)
3546 ;; Show first unread article if requested.
3547 (if (and (not no-article)
3549 gnus-newsgroup-unreads
3550 gnus-auto-select-first)
3552 (gnus-configure-windows 'summary)
3553 (let ((art (gnus-summary-article-number)))
3554 (unless (and (not gnus-plugged)
3555 (or (memq art gnus-newsgroup-undownloaded)
3556 (memq art gnus-newsgroup-downloadable)))
3557 (gnus-summary-goto-article art))))
3558 ;; Don't select any articles.
3559 (gnus-summary-position-point)
3560 (gnus-configure-windows 'summary 'force)
3561 (gnus-set-mode-line 'summary))
3562 (when (and gnus-auto-center-group
3563 (get-buffer-window gnus-group-buffer t))
3564 ;; Gotta use windows, because recenter does weird stuff if
3565 ;; the current buffer ain't the displayed window.
3566 (let ((owin (selected-window)))
3567 (select-window (get-buffer-window gnus-group-buffer t))
3568 (when (gnus-group-goto-group group)
3570 (select-window owin)))
3571 ;; Mark this buffer as "prepared".
3572 (setq gnus-newsgroup-prepared t)
3573 (gnus-run-hooks 'gnus-summary-prepared-hook)
3574 (unless (gnus-ephemeral-group-p group)
3575 (gnus-group-update-group group))
3578 (defun gnus-summary-auto-select-subject ()
3579 "Select the subject line on initial group entry."
3580 (goto-char (point-min))
3582 ((eq gnus-auto-select-subject 'best)
3583 (gnus-summary-best-unread-subject))
3584 ((eq gnus-auto-select-subject 'unread)
3585 (gnus-summary-first-unread-subject))
3586 ((eq gnus-auto-select-subject 'unseen)
3587 (gnus-summary-first-unseen-subject))
3588 ((eq gnus-auto-select-subject 'unseen-or-unread)
3589 (gnus-summary-first-unseen-or-unread-subject))
3590 ((eq gnus-auto-select-subject 'first)
3593 ((gnus-functionp gnus-auto-select-subject)
3594 (funcall gnus-auto-select-subject))))
3596 (defun gnus-summary-prepare ()
3597 "Generate the summary buffer."
3599 (let ((buffer-read-only nil))
3601 (setq gnus-newsgroup-data nil
3602 gnus-newsgroup-data-reverse nil)
3603 (gnus-run-hooks 'gnus-summary-generate-hook)
3604 ;; Generate the buffer, either with threads or without.
3605 (when gnus-newsgroup-headers
3606 (gnus-summary-prepare-threads
3607 (if gnus-show-threads
3608 (gnus-sort-gathered-threads
3609 (funcall gnus-summary-thread-gathering-function
3611 (gnus-cut-threads (gnus-make-threads)))))
3612 ;; Unthreaded display.
3613 (gnus-sort-articles gnus-newsgroup-headers))))
3614 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3615 ;; Call hooks for modifying summary buffer.
3616 (goto-char (point-min))
3617 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3619 (defsubst gnus-general-simplify-subject (subject)
3620 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3623 ;; Truncate the subject.
3624 (gnus-simplify-subject-functions
3625 (gnus-map-function gnus-simplify-subject-functions subject))
3626 ((numberp gnus-summary-gather-subject-limit)
3627 (setq subject (gnus-simplify-subject-re subject))
3628 (if (> (length subject) gnus-summary-gather-subject-limit)
3629 (substring subject 0 gnus-summary-gather-subject-limit)
3631 ;; Fuzzily simplify it.
3632 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3633 (gnus-simplify-subject-fuzzy subject))
3634 ;; Just remove the leading "Re:".
3636 (gnus-simplify-subject-re subject))))
3638 (if (and gnus-summary-gather-exclude-subject
3639 (string-match gnus-summary-gather-exclude-subject subject))
3640 nil ; This article shouldn't be gathered
3643 (defun gnus-summary-simplify-subject-query ()
3644 "Query where the respool algorithm would put this article."
3646 (gnus-summary-select-article)
3648 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3650 (defun gnus-gather-threads-by-subject (threads)
3651 "Gather threads by looking at Subject headers."
3652 (if (not gnus-summary-make-false-root)
3654 (let ((hashtb (gnus-make-hashtable 1024))
3657 subject hthread whole-subject)
3659 (setq subject (gnus-general-simplify-subject
3660 (setq whole-subject (mail-header-subject
3663 (if (setq hthread (gnus-gethash subject hashtb))
3665 ;; We enter a dummy root into the thread, if we
3666 ;; haven't done that already.
3667 (unless (stringp (caar hthread))
3668 (setcar hthread (list whole-subject (car hthread))))
3669 ;; We add this new gathered thread to this gathered
3671 (setcdr (car hthread)
3672 (nconc (cdar hthread) (list (car threads))))
3673 ;; Remove it from the list of threads.
3674 (setcdr prev (cdr threads))
3675 (setq threads prev))
3676 ;; Enter this thread into the hash table.
3677 (gnus-sethash subject
3678 (if gnus-summary-make-false-root-always
3680 ;; If you want a dummy root above all
3682 (setcar threads (list whole-subject
3688 (setq threads (cdr threads)))
3691 (defun gnus-gather-threads-by-references (threads)
3692 "Gather threads by looking at References headers."
3693 (let ((idhashtb (gnus-make-hashtable 1024))
3694 (thhashtb (gnus-make-hashtable 1024))
3697 ids references id gthread gid entered ref)
3699 (when (setq references (mail-header-references (caar threads)))
3700 (setq id (mail-header-id (caar threads))
3701 ids (inline (gnus-split-references references))
3703 (while (setq ref (pop ids))
3704 (setq ids (delete ref ids))
3705 (if (not (setq gid (gnus-gethash ref idhashtb)))
3707 (gnus-sethash ref id idhashtb)
3708 (gnus-sethash id threads thhashtb))
3709 (setq gthread (gnus-gethash gid thhashtb))
3711 ;; We enter a dummy root into the thread, if we
3712 ;; haven't done that already.
3713 (unless (stringp (caar gthread))
3714 (setcar gthread (list (mail-header-subject (caar gthread))
3716 ;; We add this new gathered thread to this gathered
3718 (setcdr (car gthread)
3719 (nconc (cdar gthread) (list (car threads)))))
3720 ;; Add it into the thread hash table.
3721 (gnus-sethash id gthread thhashtb)
3723 ;; Remove it from the list of threads.
3724 (setcdr prev (cdr threads))
3725 (setq threads prev))))
3727 (setq threads (cdr threads)))
3730 (defun gnus-sort-gathered-threads (threads)
3731 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3732 (let ((result threads))
3734 (when (stringp (caar threads))
3735 (setcdr (car threads)
3736 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3737 (setq threads (cdr threads)))
3740 (defun gnus-thread-loop-p (root thread)
3741 "Say whether ROOT is in THREAD."
3742 (let ((stack (list thread))
3745 (while (setq thread (pop stack))
3746 (setq th (cdr thread))
3748 (not (eq (caar th) root)))
3751 ;; We have found a loop.
3753 (setcdr thread (delq (car th) (cdr thread)))
3754 (if (boundp (setq ref-dep (intern "none"
3755 gnus-newsgroup-dependencies)))
3756 (setcdr (symbol-value ref-dep)
3757 (nconc (cdr (symbol-value ref-dep))
3759 (set ref-dep (list nil (car th))))
3762 ;; Push all the subthreads onto the stack.
3763 (push (cdr thread) stack)))
3766 (defun gnus-make-threads ()
3767 "Go through the dependency hashtb and find the roots. Return all threads."
3769 (while (catch 'infloop
3772 ;; Deal with self-referencing References loops.
3773 (when (and (car (symbol-value refs))
3780 (car (symbol-value refs)) thread))
3781 (cdr (symbol-value refs)))))))
3784 (unless (car (symbol-value refs))
3785 ;; These threads do not refer back to any other articles,
3786 ;; so they're roots.
3787 (setq threads (append (cdr (symbol-value refs)) threads))))
3788 gnus-newsgroup-dependencies)))
3791 ;; Build the thread tree.
3792 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3793 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3795 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3796 if it was already present.
3798 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3799 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3800 Message-IDs will be renamed to a unique Message-ID before being
3803 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3804 (let* ((id (mail-header-id header))
3805 (id-dep (and id (intern id dependencies)))
3806 parent-id ref ref-dep ref-header replaced)
3807 ;; Enter this `header' in the `dependencies' table.
3811 ;; The first two cases do the normal part: enter a new `header'
3812 ;; in the `dependencies' table.
3813 ((not (boundp id-dep))
3814 (set id-dep (list header)))
3815 ((null (car (symbol-value id-dep)))
3816 (setcar (symbol-value id-dep) header))
3818 ;; From here the `header' was already present in the
3819 ;; `dependencies' table.
3821 ;; Overrides an existing entry;
3822 ;; just set the header part of the entry.
3823 (setcar (symbol-value id-dep) header)
3826 ;; Renames the existing `header' to a unique Message-ID.
3827 ((not gnus-summary-ignore-duplicates)
3828 ;; An article with this Message-ID has already been seen.
3829 ;; We rename the Message-ID.
3830 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3832 (mail-header-set-id header id))
3834 ;; The last case ignores an existing entry, except it adds any
3835 ;; additional Xrefs (in case the two articles came from different
3837 ;; Also sets `header' to `nil' meaning that the `dependencies'
3838 ;; table was *not* modified.
3840 (mail-header-set-xref
3841 (car (symbol-value id-dep))
3842 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3844 (or (mail-header-xref header) "")))
3847 (when (and header (not replaced))
3848 ;; First check that we are not creating a References loop.
3849 (setq parent-id (gnus-parent-id (mail-header-references header)))
3850 (setq ref parent-id)
3852 (setq ref-dep (intern-soft ref dependencies))
3854 (setq ref-header (car (symbol-value ref-dep))))
3855 (if (string= id ref)
3856 ;; Yuk! This is a reference loop. Make the article be a
3859 (mail-header-set-references (car (symbol-value id-dep)) "none")
3861 (setq parent-id nil))
3862 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3863 (setq ref-dep (intern (or parent-id "none") dependencies))
3864 (if (boundp ref-dep)
3865 (setcdr (symbol-value ref-dep)
3866 (nconc (cdr (symbol-value ref-dep))
3867 (list (symbol-value id-dep))))
3868 (set ref-dep (list nil (symbol-value id-dep)))))
3871 (defun gnus-extract-message-id-from-in-reply-to (string)
3872 (if (string-match "<[^>]+>" string)
3873 (substring string (match-beginning 0) (match-end 0))
3876 (defun gnus-build-sparse-threads ()
3877 (let ((headers gnus-newsgroup-headers)
3878 (mail-parse-charset gnus-newsgroup-charset)
3879 (gnus-summary-ignore-duplicates t)
3880 header references generation relations
3881 subject child end new-child date)
3882 ;; First we create an alist of generations/relations, where
3883 ;; generations is how much we trust the relation, and the relation
3885 (gnus-message 7 "Making sparse threads...")
3887 (nnheader-set-temp-buffer " *gnus sparse threads*")
3888 (while (setq header (pop headers))
3889 (when (and (setq references (mail-header-references header))
3890 (not (string= references "")))
3892 (setq child (mail-header-id header)
3893 subject (mail-header-subject header)
3894 date (mail-header-date header)
3896 (while (search-backward ">" nil t)
3897 (setq end (1+ (point)))
3898 (when (search-backward "<" nil t)
3899 (setq new-child (buffer-substring (point) end))
3900 (push (list (incf generation)
3901 child (setq child new-child)
3905 (push (list (1+ generation) child nil subject) relations))
3907 (kill-buffer (current-buffer)))
3908 ;; Sort over trustworthiness.
3911 (when (gnus-dependencies-add-header
3912 (make-full-mail-header-from-decoded-header
3913 gnus-reffed-article-number
3914 (nth 3 relation) "" (or (nth 4 relation) "")
3916 (or (nth 2 relation) "") 0 0 "")
3917 gnus-newsgroup-dependencies nil)
3918 (push gnus-reffed-article-number gnus-newsgroup-limit)
3919 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3920 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3921 gnus-newsgroup-reads)
3922 (decf gnus-reffed-article-number)))
3923 (sort relations 'car-less-than-car))
3924 (gnus-message 7 "Making sparse threads...done")))
3926 (defun gnus-build-old-threads ()
3927 ;; Look at all the articles that refer back to old articles, and
3928 ;; fetch the headers for the articles that aren't there. This will
3929 ;; build complete threads - if the roots haven't been expired by the
3931 (let ((mail-parse-charset gnus-newsgroup-charset)
3935 (when (not (car (symbol-value refs)))
3936 (setq heads (cdr (symbol-value refs)))
3938 (if (memq (mail-header-number (caar heads))
3939 gnus-newsgroup-dormant)
3940 (setq heads (cdr heads))
3941 (setq id (symbol-name refs))
3942 (while (and (setq id (gnus-build-get-header id))
3943 (not (car (gnus-id-to-thread id)))))
3944 (setq heads nil)))))
3945 gnus-newsgroup-dependencies)))
3947 ;; This function has to be called with point after the article number
3948 ;; on the beginning of the line.
3949 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3950 (let ((eol (gnus-point-at-eol))
3951 (buffer (current-buffer))
3952 header references in-reply-to)
3954 ;; overview: [num subject from date id refs chars lines misc]
3957 (narrow-to-region (point) eol)
3962 (make-full-mail-header
3964 (nnheader-nov-field) ; subject
3965 (nnheader-nov-field) ; from
3966 (nnheader-nov-field) ; date
3967 (nnheader-nov-read-message-id) ; id
3968 (nnheader-nov-field) ; refs
3969 (nnheader-nov-read-integer) ; chars
3970 (nnheader-nov-read-integer) ; lines
3972 (if (looking-at "Xref: ")
3973 (goto-char (match-end 0)))
3974 (nnheader-nov-field)) ; Xref
3975 (nnheader-nov-parse-extra)))) ; extra
3979 (when (and (string= references "")
3980 (setq in-reply-to (mail-header-extra header))
3981 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3982 (mail-header-set-references
3983 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3985 (when gnus-alter-header-function
3986 (funcall gnus-alter-header-function header))
3987 (gnus-dependencies-add-header header dependencies force-new)))
3989 (defun gnus-build-get-header (id)
3990 "Look through the buffer of NOV lines and find the header to ID.
3991 Enter this line into the dependencies hash table, and return
3992 the id of the parent article (if any)."
3993 (let ((deps gnus-newsgroup-dependencies)
3997 (set-buffer nntp-server-buffer)
3998 (let ((case-fold-search nil))
3999 (goto-char (point-min))
4000 (while (and (not found)
4001 (search-forward id nil t))
4003 (setq found (looking-at
4004 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4005 (regexp-quote id))))
4006 (or found (beginning-of-line 2)))
4010 (setq header (gnus-nov-parse-line
4011 (read (current-buffer)) deps))
4012 (gnus-parent-id (mail-header-references header))))))
4014 (let ((number (mail-header-number header)))
4015 (push number gnus-newsgroup-limit)
4016 (push header gnus-newsgroup-headers)
4017 (if (memq number gnus-newsgroup-unselected)
4019 (setq gnus-newsgroup-unreads
4020 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4022 (setq gnus-newsgroup-unselected
4023 (delq number gnus-newsgroup-unselected)))
4024 (push number gnus-newsgroup-ancient)))))))
4026 (defun gnus-build-all-threads ()
4027 "Read all the headers."
4028 (let ((gnus-summary-ignore-duplicates t)
4029 (mail-parse-charset gnus-newsgroup-charset)
4030 (dependencies gnus-newsgroup-dependencies)
4033 (set-buffer nntp-server-buffer)
4034 (let ((case-fold-search nil))
4035 (goto-char (point-min))
4038 (setq article (read (current-buffer))
4039 header (gnus-nov-parse-line article dependencies)))
4042 (set-buffer gnus-summary-buffer)
4043 (push header gnus-newsgroup-headers)
4044 (if (memq (setq article (mail-header-number header))
4045 gnus-newsgroup-unselected)
4047 (setq gnus-newsgroup-unreads
4048 (gnus-add-to-sorted-list
4049 gnus-newsgroup-unreads article))
4050 (setq gnus-newsgroup-unselected
4051 (delq article gnus-newsgroup-unselected)))
4052 (push article gnus-newsgroup-ancient)))
4053 (forward-line 1)))))))
4055 (defun gnus-summary-update-article-line (article header)
4056 "Update the line for ARTICLE using HEADERS."
4057 (let* ((id (mail-header-id header))
4058 (thread (gnus-id-to-thread id)))
4060 (error "Article in no thread"))
4061 ;; Update the thread.
4062 (setcar thread header)
4063 (gnus-summary-goto-subject article)
4064 (let* ((datal (gnus-data-find-list article))
4066 (buffer-read-only nil)
4067 (level (gnus-summary-thread-level)))
4069 (let ((inserted (- (point)
4071 (gnus-summary-insert-line
4073 (memq article gnus-newsgroup-undownloaded)
4074 (gnus-article-mark article)
4075 (memq article gnus-newsgroup-replied)
4076 (memq article gnus-newsgroup-expirable)
4077 ;; Only insert the Subject string when it's different
4078 ;; from the previous Subject string.
4083 (mail-header-subject
4086 (gnus-data-find-list
4088 (gnus-data-list t)))))
4089 ;; Error on the side of excessive subjects.
4091 (mail-header-subject header)))
4093 (mail-header-subject header))
4094 nil (cdr (assq article gnus-newsgroup-scored))
4095 (memq article gnus-newsgroup-processable))
4098 (gnus-data-update-list
4100 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4102 (defun gnus-summary-update-article (article &optional iheader)
4103 "Update ARTICLE in the summary buffer."
4104 (set-buffer gnus-summary-buffer)
4105 (let* ((header (gnus-summary-article-header article))
4106 (id (mail-header-id header))
4107 (data (gnus-data-find article))
4108 (thread (gnus-id-to-thread id))
4109 (references (mail-header-references header))
4113 (when (and references
4114 (not (equal "" references)))
4117 (buffer-read-only nil)
4123 (delq thread parent)))
4124 (if (gnus-summary-insert-subject id header)
4125 ;; Set the (possibly) new article number in the data structure.
4126 (gnus-data-set-number data (gnus-id-to-article id))
4130 (defun gnus-rebuild-thread (id &optional line)
4131 "Rebuild the thread containing ID.
4132 If LINE, insert the rebuilt thread starting on line LINE."
4133 (let ((buffer-read-only nil)
4134 old-pos current thread data)
4135 (if (not gnus-show-threads)
4136 (setq thread (list (car (gnus-id-to-thread id))))
4137 ;; Get the thread this article is part of.
4138 (setq thread (gnus-remove-thread id)))
4139 (setq old-pos (gnus-point-at-bol))
4140 (setq current (save-excursion
4141 (and (re-search-backward "[\r\n]" nil t)
4142 (gnus-summary-article-number))))
4143 ;; If this is a gathered thread, we have to go some re-gathering.
4144 (when (stringp (car thread))
4145 (let ((subject (car thread))
4147 (setq thread (cdr thread))
4149 (unless (memq (setq thr (gnus-id-to-thread
4151 (mail-header-id (caar thread)))))
4154 (setq thread (cdr thread)))
4155 ;; We now have all (unique) roots.
4156 (if (= (length roots) 1)
4157 ;; All the loose roots are now one solid root.
4158 (setq thread (car roots))
4159 (setq thread (cons subject (gnus-sort-threads roots))))))
4161 ;; We then insert this thread into the summary buffer.
4163 (goto-char (point-min))
4164 (forward-line (1- line)))
4165 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4166 (if gnus-show-threads
4167 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4168 (gnus-summary-prepare-unthreaded thread))
4169 (setq data (nreverse gnus-newsgroup-data))
4170 (setq threads gnus-newsgroup-threads))
4171 ;; We splice the new data into the data structure.
4172 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4173 ;;!!! then we want to insert at the beginning of the buffer.
4174 ;;!!! That happens to be true with Gnus now, but that may
4175 ;;!!! change in the future. Perhaps.
4176 (gnus-data-enter-list
4177 (if line nil current) data (- (point) old-pos))
4178 (setq gnus-newsgroup-threads
4179 (nconc threads gnus-newsgroup-threads))
4180 (gnus-data-compute-positions))))
4182 (defun gnus-number-to-header (number)
4183 "Return the header for article NUMBER."
4184 (let ((headers gnus-newsgroup-headers))
4186 (not (= number (mail-header-number (car headers)))))
4191 (defun gnus-parent-headers (in-headers &optional generation)
4192 "Return the headers of the GENERATIONeth parent of HEADERS."
4194 (setq generation 1))
4196 (headers in-headers)
4199 (not (zerop generation))
4200 (setq references (mail-header-references headers)))
4201 (setq headers (if (and references
4202 (setq parent (gnus-parent-id references)))
4203 (car (gnus-id-to-thread parent))
4206 (and (not (eq headers in-headers))
4209 (defun gnus-id-to-thread (id)
4210 "Return the (sub-)thread where ID appears."
4211 (gnus-gethash id gnus-newsgroup-dependencies))
4213 (defun gnus-id-to-article (id)
4214 "Return the article number of ID."
4215 (let ((thread (gnus-id-to-thread id)))
4218 (mail-header-number (car thread)))))
4220 (defun gnus-id-to-header (id)
4221 "Return the article headers of ID."
4222 (car (gnus-id-to-thread id)))
4224 (defun gnus-article-displayed-root-p (article)
4225 "Say whether ARTICLE is a root(ish) article."
4226 (let ((level (gnus-summary-thread-level article))
4227 (refs (mail-header-references (gnus-summary-article-header article)))
4233 ((null (gnus-parent-id refs)) t)
4235 (null (setq particle (gnus-id-to-article
4236 (gnus-parent-id refs))))
4237 (null (gnus-summary-thread-level particle)))))))
4239 (defun gnus-root-id (id)
4240 "Return the id of the root of the thread where ID appears."
4242 (while (and id (setq prev (car (gnus-id-to-thread id))))
4244 id (gnus-parent-id (mail-header-references prev))))
4247 (defun gnus-articles-in-thread (thread)
4248 "Return the list of articles in THREAD."
4249 (cons (mail-header-number (car thread))
4250 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4252 (defun gnus-remove-thread (id &optional dont-remove)
4253 "Remove the thread that has ID in it."
4254 (let (headers thread last-id)
4255 ;; First go up in this thread until we find the root.
4256 (setq last-id (gnus-root-id id)
4257 headers (message-flatten-list (gnus-id-to-thread last-id)))
4258 ;; We have now found the real root of this thread. It might have
4259 ;; been gathered into some loose thread, so we have to search
4260 ;; through the threads to find the thread we wanted.
4261 (let ((threads gnus-newsgroup-threads)
4264 (setq sub (car threads))
4265 (if (stringp (car sub))
4266 ;; This is a gathered thread, so we look at the roots
4267 ;; below it to find whether this article is in this
4270 (setq sub (cdr sub))
4272 (when (member (caar sub) headers)
4273 (setq thread (car threads)
4276 (setq sub (cdr sub))))
4277 ;; It's an ordinary thread, so we check it.
4278 (when (eq (car sub) (car headers))
4281 (setq threads (cdr threads)))
4282 ;; If this article is in no thread, then it's a root.
4285 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4286 (setq thread (gnus-id-to-thread last-id)))
4289 thread ; We return this thread.
4291 (if (stringp (car thread))
4293 ;; If we use dummy roots, then we have to remove the
4294 ;; dummy root as well.
4295 (when (eq gnus-summary-make-false-root 'dummy)
4296 ;; We go to the dummy root by going to
4297 ;; the first sub-"thread", and then one line up.
4298 (gnus-summary-goto-article
4299 (mail-header-number (caadr thread)))
4302 (gnus-data-compute-positions))
4303 (setq thread (cdr thread))
4305 (gnus-remove-thread-1 (car thread))
4306 (setq thread (cdr thread))))
4307 (gnus-remove-thread-1 thread))))))))
4309 (defun gnus-remove-thread-1 (thread)
4310 "Remove the thread THREAD recursively."
4311 (let ((number (mail-header-number (pop thread)))
4313 (setq thread (reverse thread))
4315 (gnus-remove-thread-1 (pop thread)))
4316 (when (setq d (gnus-data-find number))
4317 (goto-char (gnus-data-pos d))
4318 (gnus-summary-show-thread)
4321 (- (gnus-point-at-bol)
4323 (1+ (gnus-point-at-eol))
4324 (gnus-delete-line)))))))
4326 (defun gnus-sort-threads-1 (threads func)
4327 (sort (mapcar (lambda (thread)
4330 (gnus-sort-threads-1 (cdr thread) func))))
4333 (defun gnus-sort-threads (threads)
4335 (if (not gnus-thread-sort-functions)
4337 (gnus-message 8 "Sorting threads...")
4338 (let ((max-lisp-eval-depth 5000))
4339 (prog1 (gnus-sort-threads-1
4341 (gnus-make-sort-function gnus-thread-sort-functions))
4342 (gnus-message 8 "Sorting threads...done")))))
4344 (defun gnus-sort-articles (articles)
4346 (when gnus-article-sort-functions
4347 (gnus-message 7 "Sorting articles...")
4349 (setq gnus-newsgroup-headers
4350 (sort articles (gnus-make-sort-function
4351 gnus-article-sort-functions)))
4352 (gnus-message 7 "Sorting articles...done"))))
4354 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4355 (defmacro gnus-thread-header (thread)
4356 "Return header of first article in THREAD.
4357 Note that THREAD must never, ever be anything else than a variable -
4358 using some other form will lead to serious barfage."
4359 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4360 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4361 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4364 (defsubst gnus-article-sort-by-number (h1 h2)
4365 "Sort articles by article number."
4366 (< (mail-header-number h1)
4367 (mail-header-number h2)))
4369 (defun gnus-thread-sort-by-number (h1 h2)
4370 "Sort threads by root article number."
4371 (gnus-article-sort-by-number
4372 (gnus-thread-header h1) (gnus-thread-header h2)))
4374 (defsubst gnus-article-sort-by-random (h1 h2)
4375 "Sort articles by article number."
4378 (defun gnus-thread-sort-by-random (h1 h2)
4379 "Sort threads by root article number."
4380 (gnus-article-sort-by-random
4381 (gnus-thread-header h1) (gnus-thread-header h2)))
4383 (defsubst gnus-article-sort-by-lines (h1 h2)
4384 "Sort articles by article Lines header."
4385 (< (mail-header-lines h1)
4386 (mail-header-lines h2)))
4388 (defun gnus-thread-sort-by-lines (h1 h2)
4389 "Sort threads by root article Lines header."
4390 (gnus-article-sort-by-lines
4391 (gnus-thread-header h1) (gnus-thread-header h2)))
4393 (defsubst gnus-article-sort-by-chars (h1 h2)
4394 "Sort articles by octet length."
4395 (< (mail-header-chars h1)
4396 (mail-header-chars h2)))
4398 (defun gnus-thread-sort-by-chars (h1 h2)
4399 "Sort threads by root article octet length."
4400 (gnus-article-sort-by-chars
4401 (gnus-thread-header h1) (gnus-thread-header h2)))
4403 (defsubst gnus-article-sort-by-author (h1 h2)
4404 "Sort articles by root author."
4406 (let ((addr (car (mime-entity-read-field h1 'From))))
4407 (or (std11-full-name-string addr)
4408 (std11-address-string addr)
4410 (let ((addr (car (mime-entity-read-field h2 'From))))
4411 (or (std11-full-name-string addr)
4412 (std11-address-string addr)
4416 (defun gnus-thread-sort-by-author (h1 h2)
4417 "Sort threads by root author."
4418 (gnus-article-sort-by-author
4419 (gnus-thread-header h1) (gnus-thread-header h2)))
4421 (defsubst gnus-article-sort-by-subject (h1 h2)
4422 "Sort articles by root subject."
4424 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4425 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4427 (defun gnus-thread-sort-by-subject (h1 h2)
4428 "Sort threads by root subject."
4429 (gnus-article-sort-by-subject
4430 (gnus-thread-header h1) (gnus-thread-header h2)))
4432 (defsubst gnus-article-sort-by-date (h1 h2)
4433 "Sort articles by root article date."
4435 (gnus-date-get-time (mail-header-date h1))
4436 (gnus-date-get-time (mail-header-date h2))))
4438 (defun gnus-thread-sort-by-date (h1 h2)
4439 "Sort threads by root article date."
4440 (gnus-article-sort-by-date
4441 (gnus-thread-header h1) (gnus-thread-header h2)))
4443 (defsubst gnus-article-sort-by-score (h1 h2)
4444 "Sort articles by root article score.
4445 Unscored articles will be counted as having a score of zero."
4446 (> (or (cdr (assq (mail-header-number h1)
4447 gnus-newsgroup-scored))
4448 gnus-summary-default-score 0)
4449 (or (cdr (assq (mail-header-number h2)
4450 gnus-newsgroup-scored))
4451 gnus-summary-default-score 0)))
4453 (defun gnus-thread-sort-by-score (h1 h2)
4454 "Sort threads by root article score."
4455 (gnus-article-sort-by-score
4456 (gnus-thread-header h1) (gnus-thread-header h2)))
4458 (defun gnus-thread-sort-by-total-score (h1 h2)
4459 "Sort threads by the sum of all scores in the thread.
4460 Unscored articles will be counted as having a score of zero."
4461 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4463 (defun gnus-thread-total-score (thread)
4464 ;; This function find the total score of THREAD.
4469 (if (stringp (car thread))
4470 (apply gnus-thread-score-function 0
4471 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4472 (gnus-thread-total-score-1 thread)))
4474 (gnus-thread-total-score-1 (list thread)))))
4476 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4477 "Sort threads such that the thread with the most recently arrived article comes first."
4478 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4480 (defun gnus-thread-highest-number (thread)
4481 "Return the highest article number in THREAD."
4482 (apply 'max (mapcar (lambda (header)
4483 (mail-header-number header))
4484 (message-flatten-list thread))))
4486 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4487 "Sort threads such that the thread with the most recently dated article comes first."
4488 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4490 (defun gnus-thread-latest-date (thread)
4491 "Return the highest article date in THREAD."
4492 (let ((previous-time 0))
4499 (mail-header-parse-date (mail-header-date header))
4500 (error previous-time)))))
4502 (message-flatten-list thread)
4504 (< (mail-header-number h1)
4505 (mail-header-number h2))))))))
4507 (defun gnus-thread-total-score-1 (root)
4508 ;; This function find the total score of the thread below ROOT.
4509 (setq root (car root))
4510 (apply gnus-thread-score-function
4512 (mapcar 'gnus-thread-total-score
4513 (cdr (gnus-id-to-thread (mail-header-id root))))
4514 (when (> (mail-header-number root) 0)
4515 (list (or (cdr (assq (mail-header-number root)
4516 gnus-newsgroup-scored))
4517 gnus-summary-default-score 0))))
4518 (list gnus-summary-default-score)
4521 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4522 (defvar gnus-tmp-prev-subject nil)
4523 (defvar gnus-tmp-false-parent nil)
4524 (defvar gnus-tmp-root-expunged nil)
4525 (defvar gnus-tmp-dummy-line nil)
4527 (eval-when-compile (defvar gnus-tmp-header))
4528 (defun gnus-extra-header (type &optional header)
4529 "Return the extra header of TYPE."
4530 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4533 (defvar gnus-tmp-thread-tree-header-string "")
4535 (defcustom gnus-sum-thread-tree-root "> "
4536 "With %B spec, used for the root of a thread.
4537 If nil, use subject instead."
4539 :group 'gnus-thread)
4540 (defcustom gnus-sum-thread-tree-single-indent ""
4541 "With %B spec, used for a thread with just one message.
4542 If nil, use subject instead."
4544 :group 'gnus-thread)
4545 (defcustom gnus-sum-thread-tree-vertical "| "
4546 "With %B spec, used for drawing a vertical line."
4548 :group 'gnus-thread)
4549 (defcustom gnus-sum-thread-tree-indent " "
4550 "With %B spec, used for indenting."
4552 :group 'gnus-thread)
4553 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4554 "With %B spec, used for a leaf with brothers."
4556 :group 'gnus-thread)
4557 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4558 "With %B spec, used for a leaf without brothers."
4560 :group 'gnus-thread)
4562 (defun gnus-summary-prepare-threads (threads)
4563 "Prepare summary buffer from THREADS and indentation LEVEL.
4564 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4565 or a straight list of headers."
4566 (gnus-message 7 "Generating summary...")
4568 (setq gnus-newsgroup-threads threads)
4571 (let ((gnus-tmp-level 0)
4572 (default-score (or gnus-summary-default-score 0))
4573 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4574 (building-line-count gnus-summary-display-while-building)
4575 (building-count (integerp gnus-summary-display-while-building))
4576 thread number subject stack state gnus-tmp-gathered beg-match
4577 new-roots gnus-tmp-new-adopts thread-end simp-subject
4578 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4579 gnus-tmp-replied gnus-tmp-subject-or-nil
4580 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4581 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4582 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4585 (setq gnus-tmp-prev-subject nil
4586 gnus-tmp-thread-tree-header-string "")
4588 (if (vectorp (car threads))
4589 ;; If this is a straight (sic) list of headers, then a
4590 ;; threaded summary display isn't required, so we just create
4591 ;; an unthreaded one.
4592 (gnus-summary-prepare-unthreaded threads)
4594 ;; Do the threaded display.
4596 (if gnus-summary-display-while-building
4597 (switch-to-buffer (buffer-name)))
4598 (while (or threads stack gnus-tmp-new-adopts new-roots)
4600 (if (and (= gnus-tmp-level 0)
4603 (not gnus-tmp-false-parent)
4604 (or gnus-tmp-new-adopts new-roots))
4605 (if gnus-tmp-new-adopts
4606 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4607 thread (list (car gnus-tmp-new-adopts))
4608 gnus-tmp-header (caar thread)
4609 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4611 (setq thread (list (car new-roots))
4612 gnus-tmp-header (caar thread)
4613 new-roots (cdr new-roots))))
4616 ;; If there are some threads, we do them before the
4617 ;; threads on the stack.
4618 (setq thread threads
4619 gnus-tmp-header (caar thread))
4620 ;; There were no current threads, so we pop something off
4622 (setq state (car stack)
4623 gnus-tmp-level (car state)
4624 tree-stack (cadr state)
4625 thread (caddr state)
4627 gnus-tmp-header (caar thread))))
4629 (setq gnus-tmp-false-parent nil)
4630 (setq gnus-tmp-root-expunged nil)
4631 (setq thread-end nil)
4633 (if (stringp gnus-tmp-header)
4634 ;; The header is a dummy root.
4636 ((eq gnus-summary-make-false-root 'adopt)
4637 ;; We let the first article adopt the rest.
4638 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4640 (setq gnus-tmp-gathered
4642 (lambda (h) (mail-header-number (car h)))
4645 (setq thread (cons (list (caar thread)
4648 (setq gnus-tmp-level -1
4649 gnus-tmp-false-parent t))
4650 ((eq gnus-summary-make-false-root 'empty)
4651 ;; We print adopted articles with empty subject fields.
4652 (setq gnus-tmp-gathered
4654 (lambda (h) (mail-header-number (car h)))
4657 (setq gnus-tmp-level -1))
4658 ((eq gnus-summary-make-false-root 'dummy)
4659 ;; We remember that we probably want to output a dummy
4661 (setq gnus-tmp-dummy-line gnus-tmp-header)
4662 (setq gnus-tmp-prev-subject gnus-tmp-header))
4664 ;; We do not make a root for the gathered
4665 ;; sub-threads at all.
4666 (setq gnus-tmp-level -1)))
4668 (setq number (mail-header-number gnus-tmp-header)
4669 subject (mail-header-subject gnus-tmp-header)
4670 simp-subject (gnus-simplify-subject-fully subject))
4673 ;; If the thread has changed subject, we might want to make
4674 ;; this subthread into a root.
4675 ((and (null gnus-thread-ignore-subject)
4676 (not (zerop gnus-tmp-level))
4677 gnus-tmp-prev-subject
4678 (not (string= gnus-tmp-prev-subject simp-subject)))
4679 (setq new-roots (nconc new-roots (list (car thread)))
4681 gnus-tmp-header nil))
4682 ;; If the article lies outside the current limit,
4683 ;; then we do not display it.
4684 ((not (memq number gnus-newsgroup-limit))
4685 (setq gnus-tmp-gathered
4687 (lambda (h) (mail-header-number (car h)))
4690 (setq gnus-tmp-new-adopts (if (cdar thread)
4691 (append gnus-tmp-new-adopts
4693 gnus-tmp-new-adopts)
4695 gnus-tmp-header nil)
4696 (when (zerop gnus-tmp-level)
4697 (setq gnus-tmp-root-expunged t)))
4698 ;; Perhaps this article is to be marked as read?
4699 ((and gnus-summary-mark-below
4700 (< (or (cdr (assq number gnus-newsgroup-scored))
4702 gnus-summary-mark-below)
4703 ;; Don't touch sparse articles.
4704 (not (gnus-summary-article-sparse-p number))
4705 (not (gnus-summary-article-ancient-p number)))
4706 (setq gnus-newsgroup-unreads
4707 (delq number gnus-newsgroup-unreads))
4708 (if gnus-newsgroup-auto-expire
4709 (setq gnus-newsgroup-expirable
4710 (gnus-add-to-sorted-list
4711 gnus-newsgroup-expirable number))
4712 (push (cons number gnus-low-score-mark)
4713 gnus-newsgroup-reads))))
4715 (when gnus-tmp-header
4716 ;; We may have an old dummy line to output before this
4718 (when (and gnus-tmp-dummy-line
4721 (mail-header-subject gnus-tmp-header)))
4722 (gnus-summary-insert-dummy-line
4723 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4724 (setq gnus-tmp-dummy-line nil))
4726 ;; Compute the mark.
4727 (setq gnus-tmp-unread (gnus-article-mark number))
4729 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4730 gnus-tmp-header gnus-tmp-level)
4731 gnus-newsgroup-data)
4733 ;; Actually insert the line.
4735 gnus-tmp-subject-or-nil
4737 ((and gnus-thread-ignore-subject
4738 gnus-tmp-prev-subject
4739 (not (string= gnus-tmp-prev-subject simp-subject)))
4741 ((zerop gnus-tmp-level)
4742 (if (and (eq gnus-summary-make-false-root 'empty)
4743 (memq number gnus-tmp-gathered)
4744 gnus-tmp-prev-subject
4745 (string= gnus-tmp-prev-subject simp-subject))
4746 gnus-summary-same-subject
4748 (t gnus-summary-same-subject)))
4749 (if (and (eq gnus-summary-make-false-root 'adopt)
4750 (= gnus-tmp-level 1)
4751 (memq number gnus-tmp-gathered))
4752 (setq gnus-tmp-opening-bracket ?\<
4753 gnus-tmp-closing-bracket ?\>)
4754 (setq gnus-tmp-opening-bracket ?\[
4755 gnus-tmp-closing-bracket ?\]))
4757 gnus-tmp-indentation
4758 (aref gnus-thread-indent-array gnus-tmp-level)
4759 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4760 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4761 gnus-summary-default-score 0)
4763 (if (or (null gnus-summary-default-score)
4764 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4765 gnus-summary-zcore-fuzz))
4767 (if (< gnus-tmp-score gnus-summary-default-score)
4768 gnus-score-below-mark gnus-score-over-mark))
4770 (cond ((memq number gnus-newsgroup-processable)
4772 ((memq number gnus-newsgroup-cached)
4774 ((memq number gnus-newsgroup-replied)
4776 ((memq number gnus-newsgroup-forwarded)
4777 gnus-forwarded-mark)
4778 ((memq number gnus-newsgroup-saved)
4780 ((memq number gnus-newsgroup-recent)
4782 ((memq number gnus-newsgroup-unseen)
4786 (cond ((memq number gnus-newsgroup-undownloaded)
4787 gnus-undownloaded-mark)
4788 (gnus-newsgroup-agentized
4789 gnus-downloaded-mark)
4792 gnus-tmp-from (mail-header-from gnus-tmp-header)
4795 ((string-match "<[^>]+> *$" gnus-tmp-from)
4796 (setq beg-match (match-beginning 0))
4797 (or (and (string-match "^\".+\"" gnus-tmp-from)
4798 (substring gnus-tmp-from 1 (1- (match-end 0))))
4799 (substring gnus-tmp-from 0 beg-match)))
4800 ((string-match "(.+)" gnus-tmp-from)
4801 (substring gnus-tmp-from
4802 (1+ (match-beginning 0)) (1- (match-end 0))))
4804 gnus-tmp-thread-tree-header-string
4806 ((not gnus-show-threads) "")
4807 ((zerop gnus-tmp-level)
4809 (or gnus-sum-thread-tree-root subject)
4810 (or gnus-sum-thread-tree-single-indent subject)))
4812 (concat (apply 'concat
4813 (mapcar (lambda (item)
4815 gnus-sum-thread-tree-vertical
4816 gnus-sum-thread-tree-indent))
4817 (cdr (reverse tree-stack))))
4819 gnus-sum-thread-tree-leaf-with-other
4820 gnus-sum-thread-tree-single-leaf)))))
4821 (when (string= gnus-tmp-name "")
4822 (setq gnus-tmp-name gnus-tmp-from))
4823 (unless (numberp gnus-tmp-lines)
4824 (setq gnus-tmp-lines -1))
4825 (if (= gnus-tmp-lines -1)
4826 (setq gnus-tmp-lines "?")
4827 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4828 (gnus-put-text-property
4830 (progn (eval gnus-summary-line-format-spec) (point))
4831 'gnus-number number)
4834 (gnus-run-hooks 'gnus-summary-update-hook)
4837 (setq gnus-tmp-prev-subject simp-subject)))
4839 (when (nth 1 thread)
4840 (push (list (max 0 gnus-tmp-level)
4841 (copy-list tree-stack)
4844 (push (if (nth 1 thread) 1 0) tree-stack)
4845 (incf gnus-tmp-level)
4846 (setq threads (if thread-end nil (cdar thread)))
4847 (if gnus-summary-display-while-building
4850 ;; use a set frequency
4851 (setq building-line-count (1- building-line-count))
4852 (when (= building-line-count 0)
4854 (setq building-line-count
4855 gnus-summary-display-while-building)))
4859 (setq gnus-tmp-level 0)))))
4860 (gnus-message 7 "Generating summary...done"))
4862 (defun gnus-summary-prepare-unthreaded (headers)
4863 "Generate an unthreaded summary buffer based on HEADERS."
4864 (let (header number mark)
4869 ;; We may have to root out some bad articles...
4870 (when (memq (setq number (mail-header-number
4871 (setq header (pop headers))))
4872 gnus-newsgroup-limit)
4873 ;; Mark article as read when it has a low score.
4874 (when (and gnus-summary-mark-below
4875 (< (or (cdr (assq number gnus-newsgroup-scored))
4876 gnus-summary-default-score 0)
4877 gnus-summary-mark-below)
4878 (not (gnus-summary-article-ancient-p number)))
4879 (setq gnus-newsgroup-unreads
4880 (delq number gnus-newsgroup-unreads))
4881 (if gnus-newsgroup-auto-expire
4882 (push number gnus-newsgroup-expirable)
4883 (push (cons number gnus-low-score-mark)
4884 gnus-newsgroup-reads)))
4886 (setq mark (gnus-article-mark number))
4887 (push (gnus-data-make number mark (1+ (point)) header 0)
4888 gnus-newsgroup-data)
4889 (gnus-summary-insert-line
4891 (memq number gnus-newsgroup-undownloaded)
4892 mark (memq number gnus-newsgroup-replied)
4893 (memq number gnus-newsgroup-expirable)
4894 (mail-header-subject header) nil
4895 (cdr (assq number gnus-newsgroup-scored))
4896 (memq number gnus-newsgroup-processable))))))
4898 (defun gnus-summary-remove-list-identifiers ()
4899 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4900 (let ((regexp (if (consp gnus-list-identifiers)
4901 (mapconcat 'identity gnus-list-identifiers " *\\|")
4902 gnus-list-identifiers))
4905 (dolist (header gnus-newsgroup-headers)
4906 (setq subject (mail-header-subject header)
4908 (while (string-match
4909 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4912 (concat (substring subject 0 (match-beginning 2))
4913 (substring subject (match-end 0)))
4917 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4919 (concat (substring subject 0 (match-beginning 1))
4920 (substring subject (match-end 1)))))
4922 (mail-header-set-subject header subject))))))
4924 (defun gnus-fetch-headers (articles)
4925 "Fetch headers of ARTICLES."
4926 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4927 (gnus-message 5 "Fetching headers for %s..." name)
4930 (setq gnus-headers-retrieved-by
4931 (gnus-retrieve-headers
4932 articles gnus-newsgroup-name
4933 ;; We might want to fetch old headers, but
4934 ;; not if there is only 1 article.
4936 (not (eq gnus-fetch-old-headers 'some))
4937 (not (numberp gnus-fetch-old-headers)))
4938 (> (length articles) 1))
4939 gnus-fetch-old-headers))))
4940 (gnus-get-newsgroup-headers-xover
4941 articles nil nil gnus-newsgroup-name t)
4942 (gnus-get-newsgroup-headers))
4943 (gnus-message 5 "Fetching headers for %s...done" name))))
4945 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4946 "Select newsgroup GROUP.
4947 If READ-ALL is non-nil, all articles in the group are selected.
4948 If SELECT-ARTICLES, only select those articles from GROUP."
4949 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4950 ;;!!! Dirty hack; should be removed.
4951 (gnus-summary-ignore-duplicates
4952 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4954 gnus-summary-ignore-duplicates))
4955 (info (nth 2 entry))
4956 articles fetched-articles cached)
4958 (unless (gnus-check-server
4959 (set (make-local-variable 'gnus-current-select-method)
4960 (gnus-find-method-for-group group)))
4961 (error "Couldn't open server"))
4963 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4964 (gnus-activate-group group) ; Or we can activate it...
4965 (progn ; Or we bug out.
4966 (when (equal major-mode 'gnus-summary-mode)
4967 (gnus-kill-buffer (current-buffer)))
4968 (error "Couldn't activate group %s: %s"
4969 group (gnus-status-message group))))
4971 (unless (gnus-request-group group t)
4972 (when (equal major-mode 'gnus-summary-mode)
4973 (gnus-kill-buffer (current-buffer)))
4974 (error "Couldn't request group %s: %s"
4975 group (gnus-status-message group)))
4977 (setq gnus-newsgroup-name group
4978 gnus-newsgroup-unselected nil
4979 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4981 (let ((display (gnus-group-find-parameter group 'display)))
4982 (setq gnus-newsgroup-display
4984 ((not (zerop (or (car-safe read-all) 0)))
4985 ;; The user entered the group with C-u SPC/RET, let's show
4991 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4993 ;; The following is probably the "correct" solution, but
4994 ;; it makes Gnus fetch all headers and then limit the
4995 ;; articles (which is slow), so instead we hack the
4996 ;; select-articles parameter instead. -- Simon Josefsson
4999 ;; (gnus-byte-compile
5000 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5002 (setq select-articles
5003 (gnus-uncompress-range
5004 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5008 (cdr (gnus-active group)))))
5013 (gnus-summary-setup-default-charset)
5015 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5016 (when (gnus-virtual-group-p group)
5017 (setq cached gnus-newsgroup-cached))
5019 (setq gnus-newsgroup-unreads
5020 (gnus-sorted-ndifference
5021 (gnus-sorted-ndifference gnus-newsgroup-unreads
5022 gnus-newsgroup-marked)
5023 gnus-newsgroup-dormant))
5025 (setq gnus-newsgroup-processable nil)
5027 (gnus-update-read-articles group gnus-newsgroup-unreads)
5029 ;; Adjust and set lists of article marks.
5031 (gnus-adjust-marked-articles info))
5032 (if (setq articles select-articles)
5033 (setq gnus-newsgroup-unselected
5034 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5035 (setq articles (gnus-articles-to-read group read-all)))
5039 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5041 ((eq articles 0) nil)
5043 ;; Init the dependencies hash table.
5044 (setq gnus-newsgroup-dependencies
5045 (gnus-make-hashtable (length articles)))
5046 (gnus-set-global-variables)
5047 ;; Retrieve the headers and read them in.
5049 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5051 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5053 (setq gnus-newsgroup-cached cached))
5055 ;; Suppress duplicates?
5056 (when gnus-suppress-duplicates
5057 (gnus-dup-suppress-articles))
5059 ;; Set the initial limit.
5060 (setq gnus-newsgroup-limit (copy-sequence articles))
5061 ;; Remove canceled articles from the list of unread articles.
5062 (setq fetched-articles
5063 (mapcar (lambda (headers) (mail-header-number headers))
5064 gnus-newsgroup-headers))
5065 (setq gnus-newsgroup-articles fetched-articles)
5066 (setq gnus-newsgroup-unreads
5067 (gnus-sorted-nintersection
5068 gnus-newsgroup-unreads fetched-articles))
5069 (gnus-compute-unseen-list)
5071 ;; Removed marked articles that do not exist.
5072 (gnus-update-missing-marks
5073 (gnus-sorted-difference articles fetched-articles))
5074 ;; We might want to build some more threads first.
5075 (when (and gnus-fetch-old-headers
5076 (eq gnus-headers-retrieved-by 'nov))
5077 (if (eq gnus-fetch-old-headers 'invisible)
5078 (gnus-build-all-threads)
5079 (gnus-build-old-threads)))
5080 ;; Let the Gnus agent mark articles as read.
5082 (gnus-agent-get-undownloaded-list))
5083 ;; Remove list identifiers from subject
5084 (when gnus-list-identifiers
5085 (gnus-summary-remove-list-identifiers))
5086 ;; Check whether auto-expire is to be done in this group.
5087 (setq gnus-newsgroup-auto-expire
5088 (gnus-group-auto-expirable-p group))
5089 ;; Set up the article buffer now, if necessary.
5090 (unless gnus-single-article-buffer
5091 (gnus-article-setup-buffer))
5092 ;; First and last article in this newsgroup.
5093 (when gnus-newsgroup-headers
5094 (setq gnus-newsgroup-begin
5095 (mail-header-number (car gnus-newsgroup-headers))
5098 (gnus-last-element gnus-newsgroup-headers))))
5099 ;; GROUP is successfully selected.
5100 (or gnus-newsgroup-headers t)))))
5102 (defun gnus-compute-unseen-list ()
5103 ;; The `seen' marks are treated specially.
5104 (if (not gnus-newsgroup-seen)
5105 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5106 (setq gnus-newsgroup-unseen
5107 (gnus-inverse-list-range-intersection
5108 gnus-newsgroup-articles gnus-newsgroup-seen))))
5110 (defun gnus-summary-display-make-predicate (display)
5111 (require 'gnus-agent)
5112 (when (= (length display) 1)
5113 (setq display (car display)))
5114 (unless gnus-summary-display-cache
5115 (dolist (elem (append '((unread . unread)
5118 gnus-article-mark-lists))
5119 (push (cons (cdr elem)
5121 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5122 gnus-summary-display-cache)))
5123 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5124 (gnus-category-predicate-cache gnus-summary-display-cache))
5125 (gnus-get-predicate display)))
5127 ;; Uses the dynamically bound `number' variable.
5130 (defun gnus-article-marked-p (type &optional article)
5131 (let ((article (or article number)))
5134 (memq article gnus-newsgroup-marked))
5136 (memq article gnus-newsgroup-spam-marked))
5138 (memq article gnus-newsgroup-unsendable))
5139 ((eq type 'undownload)
5140 (memq article gnus-newsgroup-undownloaded))
5141 ((eq type 'download)
5142 (memq article gnus-newsgroup-downloadable))
5144 (memq article gnus-newsgroup-unreads))
5146 (memq article gnus-newsgroup-reads))
5148 (memq article gnus-newsgroup-dormant) )
5150 (memq article gnus-newsgroup-expirable))
5152 (memq article gnus-newsgroup-replied))
5154 (memq article gnus-newsgroup-killed))
5155 ((eq type 'bookmark)
5156 (assq article gnus-newsgroup-bookmarks))
5158 (assq article gnus-newsgroup-scored))
5160 (memq article gnus-newsgroup-saved))
5162 (memq article gnus-newsgroup-cached))
5164 (memq article gnus-newsgroup-forwarded))
5166 (not (memq article gnus-newsgroup-unseen)))
5168 (memq article gnus-newsgroup-recent))
5171 (defun gnus-articles-to-read (group &optional read-all)
5172 "Find out what articles the user wants to read."
5173 (let* ((display (gnus-group-find-parameter group 'display))
5175 ;; Select all articles if `read-all' is non-nil, or if there
5176 ;; are no unread articles.
5178 (and (zerop (length gnus-newsgroup-marked))
5179 (zerop (length gnus-newsgroup-unreads)))
5180 ;; Fetch all if the predicate is non-nil.
5181 gnus-newsgroup-display)
5182 ;; We want to select the headers for all the articles in
5183 ;; the group, so we select either all the active
5184 ;; articles in the group, or (if that's nil), the
5185 ;; articles in the cache.
5187 (gnus-uncompress-range (gnus-active group))
5188 (gnus-cache-articles-in-group group))
5189 ;; Select only the "normal" subset of articles.
5191 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5192 gnus-newsgroup-unreads)))
5193 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5194 (scored (length scored-list))
5195 (number (length articles))
5196 (marked (+ (length gnus-newsgroup-marked)
5197 (length gnus-newsgroup-dormant)))
5202 ((numberp gnus-newsgroup-display)
5203 gnus-newsgroup-display)
5207 ((and (or (<= scored marked) (= scored number))
5208 (numberp gnus-large-newsgroup)
5209 (> number gnus-large-newsgroup))
5210 (let* ((cursor-in-echo-area nil)
5211 (initial (gnus-parameter-large-newsgroup-initial
5212 gnus-newsgroup-name))
5216 "How many articles from %s (%s %d): "
5218 (gnus-group-decoded-name gnus-newsgroup-name)
5220 (if initial "max" "default")
5223 (cons (number-to-string initial)
5225 (if (string-match "^[ \t]*$" input) number input)))
5226 ((and (> scored marked) (< scored number)
5227 (> (- scored number) 20))
5230 (format "%s %s (%d scored, %d total): "
5231 "How many articles from"
5232 (gnus-group-decoded-name group)
5234 (if (string-match "^[ \t]*$" input)
5238 (message "Quit getting the articles to read")
5240 (setq select (if (stringp select) (string-to-number select) select))
5241 (if (or (null select) (zerop select))
5243 (if (and (not (zerop scored)) (<= (abs select) scored))
5245 (setq articles (sort scored-list '<))
5246 (setq number (length articles)))
5247 (setq articles (copy-sequence articles)))
5249 (when (< (abs select) number)
5251 ;; Select the N oldest articles.
5252 (setcdr (nthcdr (1- (abs select)) articles) nil)
5253 ;; Select the N most recent articles.
5254 (setq articles (nthcdr (- number select) articles))))
5255 (setq gnus-newsgroup-unselected
5256 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5257 (when gnus-alter-articles-to-read-function
5260 (funcall gnus-alter-articles-to-read-function
5261 gnus-newsgroup-name articles)
5265 (defun gnus-killed-articles (killed articles)
5268 (when (inline (gnus-member-of-range (car articles) killed))
5269 (push (car articles) out))
5270 (setq articles (cdr articles)))
5273 (defun gnus-uncompress-marks (marks)
5274 "Uncompress the mark ranges in MARKS."
5275 (let ((uncompressed '(score bookmark))
5278 (if (memq (caar marks) uncompressed)
5279 (push (car marks) out)
5280 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5281 (setq marks (cdr marks)))
5284 (defun gnus-article-mark-to-type (mark)
5285 "Return the type of MARK."
5286 (or (cadr (assq mark gnus-article-special-mark-lists))
5289 (defun gnus-article-unpropagatable-p (mark)
5290 "Return whether MARK should be propagated to backend."
5291 (memq mark gnus-article-unpropagated-mark-lists))
5293 (defun gnus-adjust-marked-articles (info)
5294 "Set all article lists and remove all marks that are no longer valid."
5295 (let* ((marked-lists (gnus-info-marks info))
5296 (active (gnus-active (gnus-info-group info)))
5299 (types gnus-article-mark-lists)
5300 marks var articles article mark mark-type)
5302 (dolist (marks marked-lists)
5303 (setq mark (car marks)
5304 mark-type (gnus-article-mark-to-type mark)
5305 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5307 ;; We set the variable according to the type of the marks list,
5308 ;; and then adjust the marks to a subset of the active articles.
5310 ;; Adjust "simple" lists.
5311 ((eq mark-type 'list)
5312 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5313 (when (memq mark '(tick dormant expire reply save))
5315 (when (or (< (setq article (pop articles)) min) (> article max))
5316 (set var (delq article (symbol-value var)))))))
5318 ((eq mark-type 'tuple)
5319 (set var (setq articles (cdr marks)))
5320 (when (not (listp (cdr (symbol-value var))))
5321 (set var (list (symbol-value var))))
5322 (when (not (listp (cdr articles)))
5323 (setq articles (list articles)))
5325 (when (or (not (consp (setq article (pop articles))))
5326 (< (car article) min)
5327 (> (car article) max))
5328 (set var (delq article (symbol-value var))))))
5329 ;; Adjust ranges (sloppily).
5330 ((eq mark-type 'range)
5333 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5334 ;; It should be (seen (NUM1 . NUM2)).
5335 (when (numberp (cddr marks))
5336 (setcdr marks (list (cdr marks))))
5337 (setq articles (cdr marks))
5338 (while (and articles
5339 (or (and (consp (car articles))
5340 (> min (cdar articles)))
5341 (and (numberp (car articles))
5342 (> min (car articles)))))
5344 (set var articles))))))))
5346 (defun gnus-update-missing-marks (missing)
5347 "Go through the list of MISSING articles and remove them from the mark lists."
5350 ;; Go through all types.
5351 (dolist (elem gnus-article-mark-lists)
5352 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5353 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5354 (when (symbol-value var)
5355 ;; This list has articles. So we delete all missing
5356 ;; articles from it.
5359 (set var (delq (pop m) (symbol-value var))))))))))
5361 (defun gnus-update-marks ()
5362 "Enter the various lists of marked articles into the newsgroup info list."
5363 (let ((types gnus-article-mark-lists)
5364 (info (gnus-get-info gnus-newsgroup-name))
5365 type list newmarked symbol delta-marks)
5367 ;; Add all marks lists to the list of marks lists.
5368 (while (setq type (pop types))
5369 (setq list (symbol-value
5371 (intern (format "gnus-newsgroup-%s" (car type))))))
5374 ;; Get rid of the entries of the articles that have the
5376 (when (and (eq (cdr type) 'score)
5380 (prev (cons nil list))
5383 (if (or (not (consp (car arts)))
5384 (= (cdar arts) gnus-summary-default-score))
5385 (setcdr prev (cdr arts))
5387 (setq arts (cdr arts)))
5388 (setq list (cdr all)))))
5390 (when (eq (cdr type) 'seen)
5391 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5393 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5394 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5396 (when (and (gnus-check-backend-function
5397 'request-set-mark gnus-newsgroup-name)
5398 (not (gnus-article-unpropagatable-p (cdr type))))
5399 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5400 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5401 (add (gnus-remove-from-range
5402 (gnus-copy-sequence list) old)))
5404 (push (list add 'add (list (cdr type))) delta-marks))
5406 (push (list del 'del (list (cdr type))) delta-marks))))
5409 (push (cons (cdr type) list) newmarked)))
5412 (unless (gnus-check-group gnus-newsgroup-name)
5413 (error "Can't open server for %s" gnus-newsgroup-name))
5414 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5416 ;; Enter these new marks into the info of the group.
5418 (setcar (nthcdr 3 info) newmarked)
5419 ;; Add the marks lists to the end of the info.
5421 (setcdr (nthcdr 2 info) (list newmarked))))
5423 ;; Cut off the end of the info if there's nothing else there.
5427 (when (nthcdr (decf i) info)
5428 (setcdr (nthcdr i info) nil)))))))
5430 (defun gnus-set-mode-line (where)
5431 "Set the mode line of the article or summary buffers.
5432 If WHERE is `summary', the summary mode line format will be used."
5433 ;; Is this mode line one we keep updated?
5434 (when (and (memq where gnus-updated-mode-lines)
5436 (intern (format "gnus-%s-mode-line-format-spec" where))))
5439 ;; We evaluate this in the summary buffer since these
5440 ;; variables are buffer-local to that buffer.
5441 (set-buffer gnus-summary-buffer)
5442 ;; We bind all these variables that are used in the `eval' form
5444 (let* ((mformat (symbol-value
5446 (format "gnus-%s-mode-line-format-spec" where))))
5447 (gnus-tmp-group-name (gnus-group-decoded-name
5448 gnus-newsgroup-name))
5449 (gnus-tmp-article-number (or gnus-current-article 0))
5450 (gnus-tmp-unread gnus-newsgroup-unreads)
5451 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5452 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5453 (gnus-tmp-unread-and-unselected
5454 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5455 (zerop gnus-tmp-unselected))
5457 ((zerop gnus-tmp-unselected)
5458 (format "{%d more}" gnus-tmp-unread-and-unticked))
5459 (t (format "{%d(+%d) more}"
5460 gnus-tmp-unread-and-unticked
5461 gnus-tmp-unselected))))
5463 (if (and gnus-current-headers
5464 (vectorp gnus-current-headers))
5465 (gnus-mode-string-quote
5466 (mail-header-subject gnus-current-headers))
5468 bufname-length max-len
5469 gnus-tmp-header);; passed as argument to any user-format-funcs
5470 (setq mode-string (eval mformat))
5471 (setq bufname-length (if (string-match "%b" mode-string)
5474 (if (eq where 'summary)
5476 (get-buffer gnus-article-buffer))))
5479 (setq max-len (max 4 (if gnus-mode-non-string-length
5481 gnus-mode-non-string-length
5483 (length mode-string))))
5484 ;; We might have to chop a bit of the string off...
5485 (when (> (length mode-string) max-len)
5487 (concat (gnus-truncate-string mode-string (- max-len 3))
5489 ;; Pad the mode string a bit.
5490 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5491 ;; Update the mode line.
5492 (setq mode-line-buffer-identification
5493 (gnus-mode-line-buffer-identification (list mode-string)))
5494 (set-buffer-modified-p t))))
5496 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5497 "Go through the HEADERS list and add all Xrefs to a hash table.
5498 The resulting hash table is returned, or nil if no Xrefs were found."
5499 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5500 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5501 (xref-hashtb (gnus-make-hashtable))
5502 start group entry number xrefs header)
5504 (setq header (pop headers))
5505 (when (and (setq xrefs (mail-header-xref header))
5506 (not (memq (setq number (mail-header-number header))
5509 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5510 (setq start (match-end 0))
5511 (setq group (if prefix
5512 (concat prefix (substring xrefs (match-beginning 1)
5514 (substring xrefs (match-beginning 1) (match-end 1))))
5516 (string-to-int (substring xrefs (match-beginning 2)
5518 (if (setq entry (gnus-gethash group xref-hashtb))
5519 (setcdr entry (cons number (cdr entry)))
5520 (gnus-sethash group (cons number nil) xref-hashtb)))))
5521 (and start xref-hashtb)))
5523 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5524 "Look through all the headers and mark the Xrefs as read."
5525 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5526 name entry info xref-hashtb idlist method nth4)
5528 (set-buffer gnus-group-buffer)
5529 (when (setq xref-hashtb
5530 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5533 (unless (string= from-newsgroup (setq name (symbol-name group)))
5534 (setq idlist (symbol-value group))
5535 ;; Dead groups are not updated.
5537 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5539 (when (stringp (setq nth4 (gnus-info-method info)))
5540 (setq nth4 (gnus-server-to-method nth4))))
5541 ;; Only do the xrefs if the group has the same
5542 ;; select method as the group we have just read.
5543 (or (gnus-methods-equal-p
5544 nth4 (gnus-find-method-for-group from-newsgroup))
5546 (equal nth4 (setq method (gnus-find-method-for-group
5548 (and (equal (car nth4) (car method))
5549 (equal (nth 1 nth4) (nth 1 method))))
5550 gnus-use-cross-reference
5551 (or (not (eq gnus-use-cross-reference t))
5553 ;; Only do cross-references on subscribed
5554 ;; groups, if that is what is wanted.
5555 (<= (gnus-info-level info) gnus-level-subscribed))
5556 (gnus-group-make-articles-read name idlist))))
5559 (defun gnus-compute-read-articles (group articles)
5560 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5561 (info (nth 2 entry))
5562 (active (gnus-active group))
5565 ;; First peel off all invalid article numbers.
5567 (let ((ids articles)
5569 (while (setq id (pop ids))
5570 (when (and first (> id (cdr active)))
5571 ;; We'll end up in this situation in one particular
5572 ;; obscure situation. If you re-scan a group and get
5573 ;; a new article that is cross-posted to a different
5574 ;; group that has not been re-scanned, you might get
5575 ;; crossposted article that has a higher number than
5576 ;; Gnus believes possible. So we re-activate this
5577 ;; group as well. This might mean doing the
5578 ;; crossposting thingy will *increase* the number
5579 ;; of articles in some groups. Tsk, tsk.
5580 (setq active (or (gnus-activate-group group) active)))
5581 (when (or (> id (cdr active))
5582 (< id (car active)))
5583 (setq articles (delq id articles))))))
5584 ;; If the read list is nil, we init it.
5586 (null (gnus-info-read info))
5588 (setq ninfo (cons 1 (1- (car active))))
5589 (setq ninfo (gnus-info-read info)))
5590 ;; Then we add the read articles to the range.
5592 ninfo (setq articles (sort articles '<))))))
5594 (defun gnus-group-make-articles-read (group articles)
5595 "Update the info of GROUP to say that ARTICLES are read."
5597 (entry (gnus-gethash group gnus-newsrc-hashtb))
5598 (info (nth 2 entry))
5599 (active (gnus-active group))
5602 (setq range (gnus-compute-read-articles group articles))
5604 (set-buffer gnus-group-buffer)
5607 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5608 (gnus-info-set-read ',info ',(gnus-info-read info))
5609 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5610 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5611 (gnus-group-update-group ,group t))))
5612 ;; Add the read articles to the range.
5613 (gnus-info-set-read info range)
5614 (gnus-request-set-mark group (list (list range 'add '(read))))
5615 ;; Then we have to re-compute how many unread
5616 ;; articles there are in this group.
5620 (setq num (- (1+ (cdr active)) (car active))))
5621 ((not (listp (cdr range)))
5622 (setq num (- (cdr active) (- (1+ (cdr range))
5626 (if (numberp (car range))
5628 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5629 (setq range (cdr range)))
5630 (setq num (- (cdr active) num))))
5631 ;; Update the number of unread articles.
5633 ;; Update the group buffer.
5634 (unless (gnus-ephemeral-group-p group)
5635 (gnus-group-update-group group t))))))
5637 (defvar gnus-newsgroup-none-id 0)
5639 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5640 (let ((cur nntp-server-buffer)
5643 (save-excursion (set-buffer gnus-summary-buffer)
5644 gnus-newsgroup-dependencies)))
5646 (mail-parse-charset gnus-newsgroup-charset)
5647 (mail-parse-ignored-charsets
5648 (save-excursion (condition-case nil
5649 (set-buffer gnus-summary-buffer)
5651 gnus-newsgroup-ignored-charsets)))
5653 (set-buffer nntp-server-buffer)
5654 ;; Translate all TAB characters into SPACE characters.
5655 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5656 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5657 (gnus-run-hooks 'gnus-parse-headers-hook)
5658 (let ((case-fold-search t)
5659 in-reply-to header p lines chars ctype)
5660 (goto-char (point-min))
5661 ;; Search to the beginning of the next header. Error messages
5662 ;; do not begin with 2 or 3.
5663 (while (re-search-forward "^[23][0-9]+ " nil t)
5666 ;; This implementation of this function, with nine
5667 ;; search-forwards instead of the one re-search-forward and
5668 ;; a case (which basically was the old function) is actually
5669 ;; about twice as fast, even though it looks messier. You
5670 ;; can't have everything, I guess. Speed and elegance
5671 ;; doesn't always go hand in hand.
5674 (make-full-mail-header
5680 (narrow-to-region (point)
5681 (or (and (search-forward "\n.\n" nil t)
5687 (if (search-forward "\nsubject:" nil t)
5688 (nnheader-header-value)
5693 (if (search-forward "\nfrom:" nil t)
5694 (nnheader-header-value)
5699 (if (search-forward "\ndate:" nil t)
5700 (nnheader-header-value) ""))
5704 (setq id (if (re-search-forward
5705 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5706 ;; We do it this way to make sure the Message-ID
5707 ;; is (somewhat) syntactically valid.
5708 (buffer-substring (match-beginning 1)
5710 ;; If there was no message-id, we just fake one
5711 ;; to make subsequent routines simpler.
5712 (nnheader-generate-fake-message-id))))
5716 (if (search-forward "\nreferences:" nil t)
5720 (nnheader-header-value)
5725 (search-backward ">" end t)
5728 (search-backward "<" end t)
5730 ;; Get the references from the in-reply-to header if there
5731 ;; were no references and the in-reply-to header looks
5733 (if (and (search-forward "\nin-reply-to:" nil t)
5734 (setq in-reply-to (nnheader-header-value))
5735 (string-match "<[^>]+>" in-reply-to))
5737 (setq ref (substring in-reply-to (match-beginning 0)
5739 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5740 (setq ref2 (substring in-reply-to (match-beginning 0)
5742 (when (> (length ref2) (length ref))
5749 (if (search-forward "\nchars: " nil t)
5750 (if (numberp (setq chars (ignore-errors (read cur))))
5756 (if (search-forward "\nlines: " nil t)
5757 (if (numberp (setq lines (ignore-errors (read cur))))
5763 (and (search-forward "\nxref:" nil t)
5764 (nnheader-header-value)))
5766 (when gnus-extra-headers
5767 (let ((extra gnus-extra-headers)
5771 (when (search-forward
5772 (concat "\n" (symbol-name (car extra)) ":") nil t)
5773 (push (cons (car extra) (nnheader-header-value)) out))
5777 (if (and (search-forward "\ncontent-type: " nil t)
5778 (setq ctype (nnheader-header-value)))
5779 (mime-entity-set-content-type-internal
5780 header (mime-parse-Content-Type ctype)))
5781 (when (equal id ref)
5784 (when gnus-alter-header-function
5785 (funcall gnus-alter-header-function header)
5786 (setq id (mail-header-id header)
5787 ref (gnus-parent-id (mail-header-references header))))
5790 (gnus-dependencies-add-header
5791 header dependencies force-new))
5792 (push header headers))
5793 (goto-char (point-max))
5795 (nreverse headers)))))
5797 ;; Goes through the xover lines and returns a list of vectors
5798 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5799 force-new dependencies
5800 group also-fetch-heads)
5801 "Parse the news overview data in the server buffer.
5802 Return a list of headers that match SEQUENCE (see
5803 `nntp-retrieve-headers')."
5804 ;; Get the Xref when the users reads the articles since most/some
5805 ;; NNTP servers do not include Xrefs when using XOVER.
5806 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5807 (let ((mail-parse-charset gnus-newsgroup-charset)
5808 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5809 (cur nntp-server-buffer)
5810 (dependencies (or dependencies gnus-newsgroup-dependencies))
5812 ((eq gnus-read-all-available-headers t)
5814 ((stringp gnus-read-all-available-headers)
5815 (string-match gnus-read-all-available-headers group))
5818 number headers header)
5820 (set-buffer nntp-server-buffer)
5821 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5822 ;; Allow the user to mangle the headers before parsing them.
5823 (gnus-run-hooks 'gnus-parse-headers-hook)
5824 (goto-char (point-min))
5825 (gnus-parse-without-error
5826 (while (and (or sequence allp)
5828 (setq number (read cur))
5830 (while (and sequence
5831 (< (car sequence) number))
5832 (setq sequence (cdr sequence))))
5835 (eq number (car sequence))))
5837 (setq sequence (cdr sequence))
5838 (setq header (inline
5839 (gnus-nov-parse-line
5840 number dependencies force-new)))))
5841 (push header headers))
5843 ;; A common bug in inn is that if you have posted an article and
5844 ;; then retrieves the active file, it will answer correctly --
5845 ;; the new article is included. However, a NOV entry for the
5846 ;; article may not have been generated yet, so this may fail.
5847 ;; We work around this problem by retrieving the last few
5848 ;; headers using HEAD.
5849 (if (or (not also-fetch-heads)
5851 ;; We (probably) got all the headers.
5853 (let ((gnus-nov-is-evil t))
5856 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5857 (gnus-get-newsgroup-headers))))))))
5859 (defun gnus-article-get-xrefs ()
5860 "Fill in the Xref value in `gnus-current-headers', if necessary.
5861 This is meant to be called in `gnus-article-internal-prepare-hook'."
5862 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5863 gnus-current-headers)))
5864 (or (not gnus-use-cross-reference)
5866 (and (mail-header-xref headers)
5867 (not (string= (mail-header-xref headers) "")))
5868 (let ((case-fold-search t)
5871 (nnheader-narrow-to-headers)
5872 (goto-char (point-min))
5873 (when (or (and (not (eobp))
5874 (eq (downcase (char-after)) ?x)
5875 (looking-at "Xref:"))
5876 (search-forward "\nXref:" nil t))
5877 (goto-char (1+ (match-end 0)))
5878 (setq xref (buffer-substring (point)
5879 (progn (end-of-line) (point))))
5880 (mail-header-set-xref headers xref)))))))
5882 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5883 "Find article ID and insert the summary line for that article.
5884 OLD-HEADER can either be a header or a line number to insert
5885 the subject line on."
5886 (let* ((line (and (numberp old-header) old-header))
5887 (old-header (and (vectorp old-header) old-header))
5888 (header (cond ((and old-header use-old-header)
5891 (gnus-number-to-header id))
5892 (gnus-number-to-header id))
5894 (gnus-read-header id))))
5895 (number (and (numberp id) id))
5898 ;; Rebuild the thread that this article is part of and go to the
5899 ;; article we have fetched.
5900 (when (and (not gnus-show-threads)
5903 (setq d (gnus-data-find (mail-header-number old-header))))
5904 (goto-char (gnus-data-pos d))
5907 (- (gnus-point-at-bol)
5909 (1+ (gnus-point-at-eol))
5910 (gnus-delete-line))))))
5912 (mail-header-set-number header (mail-header-number old-header)))
5913 (setq gnus-newsgroup-sparse
5914 (delq (setq number (mail-header-number header))
5915 gnus-newsgroup-sparse))
5916 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5917 (push number gnus-newsgroup-limit)
5918 (gnus-rebuild-thread (mail-header-id header) line)
5919 (gnus-summary-goto-subject number nil t))
5920 (when (and (numberp number)
5922 ;; We have to update the boundaries even if we can't fetch the
5923 ;; article if ID is a number -- so that the next `P' or `N'
5924 ;; command will fetch the previous (or next) article even
5925 ;; if the one we tried to fetch this time has been canceled.
5926 (when (> number gnus-newsgroup-end)
5927 (setq gnus-newsgroup-end number))
5928 (when (< number gnus-newsgroup-begin)
5929 (setq gnus-newsgroup-begin number))
5930 (setq gnus-newsgroup-unselected
5931 (delq number gnus-newsgroup-unselected)))
5932 ;; Report back a success?
5933 (and header (mail-header-number header))))
5935 ;;; Process/prefix in the summary buffer
5937 (defun gnus-summary-work-articles (n)
5938 "Return a list of articles to be worked upon.
5939 The prefix argument, the list of process marked articles, and the
5940 current article will be taken into consideration."
5942 (set-buffer gnus-summary-buffer)
5945 ;; A numerical prefix has been given.
5946 (setq n (prefix-numeric-value n))
5947 (let ((backward (< n 0))
5948 (n (abs (prefix-numeric-value n)))
5953 (push (setq article (gnus-summary-article-number))
5956 (gnus-summary-find-prev nil article)
5957 (gnus-summary-find-next nil article)))
5959 (nreverse articles)))
5960 ((and (gnus-region-active-p) (mark))
5961 (message "region active")
5962 ;; Work on the region between point and mark.
5963 (let ((max (max (point) (mark)))
5966 (goto-char (min (point) (mark)))
5969 (push (setq article (gnus-summary-article-number)) articles)
5970 (gnus-summary-find-next nil article)
5972 (nreverse articles))))
5973 (gnus-newsgroup-processable
5974 ;; There are process-marked articles present.
5975 ;; Save current state.
5976 (gnus-summary-save-process-mark)
5978 (reverse gnus-newsgroup-processable))
5980 ;; Just return the current article.
5981 (list (gnus-summary-article-number))))))
5983 (defmacro gnus-summary-iterate (arg &rest forms)
5984 "Iterate over the process/prefixed articles and do FORMS.
5985 ARG is the interactive prefix given to the command. FORMS will be
5986 executed with point over the summary line of the articles."
5987 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5988 `(let ((,articles (gnus-summary-work-articles ,arg)))
5990 (gnus-summary-goto-subject (car ,articles))
5994 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5995 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5997 (defun gnus-summary-save-process-mark ()
5998 "Push the current set of process marked articles on the stack."
6000 (push (copy-sequence gnus-newsgroup-processable)
6001 gnus-newsgroup-process-stack))
6003 (defun gnus-summary-kill-process-mark ()
6004 "Push the current set of process marked articles on the stack and unmark."
6006 (gnus-summary-save-process-mark)
6007 (gnus-summary-unmark-all-processable))
6009 (defun gnus-summary-yank-process-mark ()
6010 "Pop the last process mark state off the stack and restore it."
6012 (unless gnus-newsgroup-process-stack
6013 (error "Empty mark stack"))
6014 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6016 (defun gnus-summary-process-mark-set (set)
6017 "Make SET into the current process marked articles."
6018 (gnus-summary-unmark-all-processable)
6020 (gnus-summary-set-process-mark (pop set))))
6022 ;;; Searching and stuff
6024 (defun gnus-summary-search-group (&optional backward use-level)
6025 "Search for next unread newsgroup.
6026 If optional argument BACKWARD is non-nil, search backward instead."
6028 (set-buffer gnus-group-buffer)
6029 (when (gnus-group-search-forward
6030 backward nil (if use-level (gnus-group-group-level) nil))
6031 (gnus-group-group-name))))
6033 (defun gnus-summary-best-group (&optional exclude-group)
6034 "Find the name of the best unread group.
6035 If EXCLUDE-GROUP, do not go to this group."
6037 (set-buffer gnus-group-buffer)
6039 (gnus-group-best-unread-group exclude-group))))
6041 (defun gnus-summary-find-next (&optional unread article backward)
6042 (if backward (gnus-summary-find-prev)
6043 (let* ((dummy (gnus-summary-article-intangible-p))
6044 (article (or article (gnus-summary-article-number)))
6045 (data (gnus-data-find-list article))
6047 (when (and (not dummy)
6048 (or (not gnus-summary-check-current)
6050 (not (gnus-data-unread-p (car data)))))
6051 (setq data (cdr data)))
6056 (unless (memq (gnus-data-number (car data))
6057 gnus-newsgroup-unfetched)
6058 (when (gnus-data-unread-p (car data))
6059 (setq result (car data)
6061 (setq data (cdr data)))
6064 (goto-char (gnus-data-pos result))
6065 (gnus-data-number result)))))
6067 (defun gnus-summary-find-prev (&optional unread article)
6068 (let* ((eobp (eobp))
6069 (article (or article (gnus-summary-article-number)))
6070 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6072 (when (and (not eobp)
6073 (or (not gnus-summary-check-current)
6075 (not (gnus-data-unread-p (car data)))))
6076 (setq data (cdr data)))
6081 (unless (memq (gnus-data-number (car data)) gnus-newsgroup-unfetched)
6082 (when (gnus-data-unread-p (car data))
6083 (setq result (car data)
6085 (setq data (cdr data)))
6088 (goto-char (gnus-data-pos result))
6089 (gnus-data-number result))))
6091 (defun gnus-summary-find-subject (subject &optional unread backward article)
6092 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6093 (article (or article (gnus-summary-article-number)))
6094 (articles (gnus-data-list backward))
6095 (arts (gnus-data-find-list article articles))
6097 (when (or (not gnus-summary-check-current)
6099 (not (gnus-data-unread-p (car arts))))
6100 (setq arts (cdr arts)))
6102 (and (or (not unread)
6103 (gnus-data-unread-p (car arts)))
6104 (vectorp (gnus-data-header (car arts)))
6106 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6107 (setq result (car arts)
6109 (setq arts (cdr arts)))
6111 (goto-char (gnus-data-pos result))
6112 (gnus-data-number result))))
6114 (defun gnus-summary-search-forward (&optional unread subject backward)
6115 "Search forward for an article.
6116 If UNREAD, look for unread articles. If SUBJECT, look for
6117 articles with that subject. If BACKWARD, search backward instead."
6118 (cond (subject (gnus-summary-find-subject subject unread backward))
6119 (backward (gnus-summary-find-prev unread))
6120 (t (gnus-summary-find-next unread))))
6122 (defun gnus-recenter (&optional n)
6123 "Center point in window and redisplay frame.
6124 Also do horizontal recentering."
6126 (when (and gnus-auto-center-summary
6127 (not (eq gnus-auto-center-summary 'vertical)))
6128 (gnus-horizontal-recenter))
6131 (defun gnus-summary-recenter ()
6132 "Center point in the summary window.
6133 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6134 displayed, no centering will be performed."
6135 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6136 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6138 ;; The user has to want it.
6139 (when gnus-auto-center-summary
6140 (let* ((top (cond ((< (window-height) 4) 0)
6141 ((< (window-height) 7) 1)
6142 (t (if (numberp gnus-auto-center-summary)
6143 gnus-auto-center-summary
6145 (height (1- (window-height)))
6146 (bottom (save-excursion (goto-char (point-max))
6147 (forward-line (- height))
6149 (window (get-buffer-window (current-buffer))))
6150 (when (get-buffer-window gnus-article-buffer)
6151 ;; Only do recentering when the article buffer is displayed,
6152 ;; Set the window start to either `bottom', which is the biggest
6153 ;; possible valid number, or the second line from the top,
6154 ;; whichever is the least.
6155 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6156 (if (> bottom top-pos)
6157 ;; Keep the second line from the top visible
6158 (set-window-start window top-pos t)
6159 ;; Try to keep the bottom line visible; if it's partially
6160 ;; obscured, either scroll one more line to make it fully
6161 ;; visible, or revert to using TOP-POS.
6163 (goto-char (point-max))
6165 (let ((last-line-start (point)))
6167 (set-window-start window (point) t)
6168 (when (not (pos-visible-in-window-p last-line-start window))
6170 (set-window-start window (min (point) top-pos) t)))))))
6171 ;; Do horizontal recentering while we're at it.
6172 (when (and (get-buffer-window (current-buffer) t)
6173 (not (eq gnus-auto-center-summary 'vertical)))
6174 (let ((selected (selected-window)))
6175 (select-window (get-buffer-window (current-buffer) t))
6176 (gnus-summary-position-point)
6177 (gnus-horizontal-recenter)
6178 (select-window selected))))))
6180 (defun gnus-summary-jump-to-group (newsgroup)
6181 "Move point to NEWSGROUP in group mode buffer."
6182 ;; Keep update point of group mode buffer if visible.
6183 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6184 (save-window-excursion
6185 ;; Take care of tree window mode.
6186 (when (get-buffer-window gnus-group-buffer)
6187 (pop-to-buffer gnus-group-buffer))
6188 (gnus-group-jump-to-group newsgroup))
6190 ;; Take care of tree window mode.
6191 (if (get-buffer-window gnus-group-buffer)
6192 (pop-to-buffer gnus-group-buffer)
6193 (set-buffer gnus-group-buffer))
6194 (gnus-group-jump-to-group newsgroup))))
6196 ;; This function returns a list of article numbers based on the
6197 ;; difference between the ranges of read articles in this group and
6198 ;; the range of active articles.
6199 (defun gnus-list-of-unread-articles (group)
6200 (let* ((read (gnus-info-read (gnus-get-info group)))
6201 (active (or (gnus-active group) (gnus-activate-group group)))
6204 ;; If none are read, then all are unread.
6206 (setq first (car active))
6207 ;; If the range of read articles is a single range, then the
6208 ;; first unread article is the article after the last read
6209 ;; article. Sounds logical, doesn't it?
6210 (if (and (not (listp (cdr read)))
6211 (or (< (car read) (car active))
6212 (progn (setq read (list read))
6214 (setq first (max (car active) (1+ (cdr read))))
6215 ;; `read' is a list of ranges.
6216 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6219 (setq first (car active)))
6222 (while (< first nlast)
6224 (setq first (1+ first))))
6225 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6226 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6227 (setq read (cdr read)))))
6228 ;; And add the last unread articles.
6229 (while (<= first last)
6231 (setq first (1+ first)))
6232 ;; Return the list of unread articles.
6233 (delq 0 (nreverse unread))))
6235 (defun gnus-list-of-read-articles (group)
6236 "Return a list of unread, unticked and non-dormant articles."
6237 (let* ((info (gnus-get-info group))
6238 (marked (gnus-info-marks info))
6239 (active (gnus-active group)))
6241 (gnus-list-range-difference
6242 (gnus-list-range-difference
6243 (gnus-sorted-complement
6244 (gnus-uncompress-range active)
6245 (gnus-list-of-unread-articles group))
6246 (cdr (assq 'dormant marked)))
6247 (cdr (assq 'tick marked))))))
6249 ;; Various summary commands
6251 (defun gnus-summary-select-article-buffer ()
6252 "Reconfigure windows to show article buffer."
6254 (if (not (gnus-buffer-live-p gnus-article-buffer))
6255 (error "There is no article buffer for this summary buffer")
6256 (gnus-configure-windows 'article)
6257 (select-window (get-buffer-window gnus-article-buffer))))
6259 (defun gnus-summary-universal-argument (arg)
6260 "Perform any operation on all articles that are process/prefixed."
6262 (let ((articles (gnus-summary-work-articles arg))
6269 (substitute-command-keys
6270 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6272 (gnus-error 1 "Undefined key")
6275 (gnus-summary-goto-subject (setq article (pop articles)))
6276 (let (gnus-newsgroup-processable)
6277 (command-execute func))
6278 (gnus-summary-remove-process-mark article)))))
6279 (gnus-summary-position-point))
6281 (defun gnus-summary-toggle-truncation (&optional arg)
6282 "Toggle truncation of summary lines.
6283 With arg, turn line truncation on if arg is positive."
6285 (setq truncate-lines
6286 (if (null arg) (not truncate-lines)
6287 (> (prefix-numeric-value arg) 0)))
6290 (defun gnus-summary-find-uncancelled ()
6291 "Return the number of an uncancelled article.
6292 The current article is considered, then following articles, then previous
6293 articles. If all articles are cancelled then return a dummy 0."
6295 (dolist (rev '(nil t))
6296 (unless found ; don't demand the reverse list if we don't need it
6297 (let ((data (gnus-data-find-list
6298 (gnus-summary-article-number) (gnus-data-list rev))))
6299 (while (and data (not found))
6300 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6301 (setq found (gnus-data-number (car data))))
6302 (setq data (cdr data))))))
6305 (defun gnus-summary-reselect-current-group (&optional all rescan)
6306 "Exit and then reselect the current newsgroup.
6307 The prefix argument ALL means to select all articles."
6309 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6310 (error "Ephemeral groups can't be reselected"))
6311 (let ((current-subject (gnus-summary-find-uncancelled))
6312 (group gnus-newsgroup-name))
6313 (setq gnus-newsgroup-begin nil)
6315 ;; We have to adjust the point of group mode buffer because
6316 ;; point was moved to the next unread newsgroup by exiting.
6317 (gnus-summary-jump-to-group group)
6320 (save-window-excursion
6321 ;; Don't show group contents.
6322 (set-window-start (selected-window) (point-max))
6323 (gnus-group-get-new-news-this-group 1))))
6324 (gnus-group-read-group all t)
6325 (gnus-summary-goto-subject current-subject nil t)))
6327 (defun gnus-summary-rescan-group (&optional all)
6328 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6330 (gnus-summary-reselect-current-group all t))
6332 (defun gnus-summary-update-info (&optional non-destructive)
6334 (let ((group gnus-newsgroup-name))
6336 (when gnus-newsgroup-kill-headers
6337 (setq gnus-newsgroup-killed
6338 (gnus-compress-sequence
6340 (gnus-list-range-intersection
6341 gnus-newsgroup-unselected gnus-newsgroup-killed)
6342 gnus-newsgroup-unreads)
6344 (unless (listp (cdr gnus-newsgroup-killed))
6345 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6346 (let ((headers gnus-newsgroup-headers))
6347 ;; Set the new ranges of read articles.
6349 (set-buffer gnus-group-buffer)
6350 (gnus-undo-force-boundary))
6351 (gnus-update-read-articles
6352 group (gnus-sorted-union
6353 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6354 ;; Set the current article marks.
6355 (let ((gnus-newsgroup-scored
6356 (if (and (not gnus-save-score)
6357 (not non-destructive))
6359 gnus-newsgroup-scored)))
6361 (gnus-update-marks)))
6362 ;; Do the cross-ref thing.
6363 (when gnus-use-cross-reference
6364 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6365 ;; Do not switch windows but change the buffer to work.
6366 (set-buffer gnus-group-buffer)
6367 (unless (gnus-ephemeral-group-p group)
6368 (gnus-group-update-group group)))))))
6370 (defun gnus-summary-save-newsrc (&optional force)
6371 "Save the current number of read/marked articles in the dribble buffer.
6372 The dribble buffer will then be saved.
6373 If FORCE (the prefix), also save the .newsrc file(s)."
6375 (gnus-summary-update-info t)
6377 (gnus-save-newsrc-file)
6378 (gnus-dribble-save)))
6380 (defun gnus-summary-exit (&optional temporary)
6381 "Exit reading current newsgroup, and then return to group selection mode.
6382 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6384 (gnus-set-global-variables)
6385 (gnus-kill-save-kill-buffer)
6386 (gnus-async-halt-prefetch)
6387 (let* ((group gnus-newsgroup-name)
6388 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6389 (gnus-group-is-exiting-p t)
6392 (buf (current-buffer)))
6394 ;; Do adaptive scoring, and possibly save score files.
6395 (when gnus-newsgroup-adaptive
6396 (gnus-score-adaptive))
6397 (when gnus-use-scoring
6399 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6400 ;; If we have several article buffers, we kill them at exit.
6401 (unless gnus-single-article-buffer
6402 (gnus-kill-buffer gnus-original-article-buffer)
6403 (setq gnus-article-current nil))
6404 (when gnus-use-cache
6405 (gnus-cache-possibly-remove-articles)
6406 (gnus-cache-save-buffers))
6407 (gnus-async-prefetch-remove-group group)
6408 (when gnus-suppress-duplicates
6409 (gnus-dup-enter-articles))
6410 (when gnus-use-trees
6411 (gnus-tree-close group))
6412 (when gnus-use-cache
6413 (gnus-cache-write-active))
6414 ;; Remove entries for this group.
6415 (nnmail-purge-split-history (gnus-group-real-name group))
6416 ;; Make all changes in this group permanent.
6418 (gnus-run-hooks 'gnus-exit-group-hook)
6419 (gnus-summary-update-info))
6420 (gnus-close-group group)
6421 ;; Make sure where we were, and go to next newsgroup.
6422 (set-buffer gnus-group-buffer)
6424 (gnus-group-jump-to-group group))
6425 (gnus-run-hooks 'gnus-summary-exit-hook)
6426 (unless (or quit-config
6427 ;; If this group has disappeared from the summary
6428 ;; buffer, don't skip forwards.
6429 (not (string= group (gnus-group-group-name))))
6430 (gnus-group-next-unread-group 1))
6431 (setq group-point (point))
6434 ;; If we have several article buffers, we kill them at exit.
6435 (unless gnus-single-article-buffer
6436 (gnus-kill-buffer gnus-article-buffer)
6437 (gnus-kill-buffer gnus-original-article-buffer)
6438 (setq gnus-article-current nil))
6440 (if (not gnus-kill-summary-on-exit)
6442 (gnus-deaden-summary)
6444 ;; We set all buffer-local variables to nil. It is unclear why
6445 ;; this is needed, but if we don't, buffer-local variables are
6446 ;; not garbage-collected, it seems. This would the lead to en
6447 ;; ever-growing Emacs.
6448 (gnus-summary-clear-local-variables)
6449 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6450 (gnus-summary-clear-local-variables))
6451 (when (get-buffer gnus-article-buffer)
6452 (bury-buffer gnus-article-buffer))
6453 ;; We clear the global counterparts of the buffer-local
6454 ;; variables as well, just to be on the safe side.
6455 (set-buffer gnus-group-buffer)
6456 (gnus-summary-clear-local-variables)
6457 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6458 (gnus-summary-clear-local-variables))
6459 ;; Return to group mode buffer.
6460 (when (eq mode 'gnus-summary-mode)
6461 (gnus-kill-buffer buf)))
6462 (setq gnus-current-select-method gnus-select-method)
6463 (pop-to-buffer gnus-group-buffer)
6464 (if (not quit-config)
6466 (goto-char group-point)
6467 (gnus-configure-windows 'group 'force)
6468 (unless (pos-visible-in-window-p)
6469 (forward-line (/ (static-if (featurep 'xemacs)
6470 (window-displayed-height)
6471 (1- (window-height)))
6473 (set-window-start (selected-window) (point))
6474 (goto-char group-point)))
6475 (gnus-handle-ephemeral-exit quit-config))
6476 ;; Clear the current group name.
6478 (setq gnus-newsgroup-name nil)))))
6480 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6481 (defun gnus-summary-exit-no-update (&optional no-questions)
6482 "Quit reading current newsgroup without updating read article info."
6484 (let* ((group gnus-newsgroup-name)
6485 (gnus-group-is-exiting-p t)
6486 (quit-config (gnus-group-quit-config group)))
6487 (when (or no-questions
6489 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6490 (gnus-async-halt-prefetch)
6492 (delq 'gnus-summary-expire-articles
6493 (copy-sequence gnus-summary-prepare-exit-hook)))
6494 ;; If we have several article buffers, we kill them at exit.
6495 (unless gnus-single-article-buffer
6496 (gnus-kill-buffer gnus-article-buffer)
6497 (gnus-kill-buffer gnus-original-article-buffer)
6498 (setq gnus-article-current nil))
6499 (if (not gnus-kill-summary-on-exit)
6500 (gnus-deaden-summary)
6501 (gnus-close-group group)
6502 (gnus-summary-clear-local-variables)
6503 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6504 (gnus-summary-clear-local-variables))
6505 (set-buffer gnus-group-buffer)
6506 (gnus-summary-clear-local-variables)
6507 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6508 (gnus-summary-clear-local-variables))
6509 (gnus-kill-buffer gnus-summary-buffer))
6510 (unless gnus-single-article-buffer
6511 (setq gnus-article-current nil))
6512 (when gnus-use-trees
6513 (gnus-tree-close group))
6514 (gnus-async-prefetch-remove-group group)
6515 (when (get-buffer gnus-article-buffer)
6516 (bury-buffer gnus-article-buffer))
6517 ;; Return to the group buffer.
6518 (gnus-configure-windows 'group 'force)
6519 ;; Clear the current group name.
6520 (setq gnus-newsgroup-name nil)
6521 (unless (gnus-ephemeral-group-p group)
6522 (gnus-group-update-group group))
6523 (when (equal (gnus-group-group-name) group)
6524 (gnus-group-next-unread-group 1))
6526 (gnus-handle-ephemeral-exit quit-config)))))
6528 (defun gnus-handle-ephemeral-exit (quit-config)
6529 "Handle movement when leaving an ephemeral group.
6530 The state which existed when entering the ephemeral is reset."
6531 (if (not (buffer-name (car quit-config)))
6532 (gnus-configure-windows 'group 'force)
6533 (set-buffer (car quit-config))
6534 (cond ((eq major-mode 'gnus-summary-mode)
6535 (gnus-set-global-variables))
6536 ((eq major-mode 'gnus-article-mode)
6538 ;; The `gnus-summary-buffer' variable may point
6539 ;; to the old summary buffer when using a single
6541 (unless (gnus-buffer-live-p gnus-summary-buffer)
6542 (set-buffer gnus-group-buffer))
6543 (set-buffer gnus-summary-buffer)
6544 (gnus-set-global-variables))))
6545 (if (or (eq (cdr quit-config) 'article)
6546 (eq (cdr quit-config) 'pick))
6548 ;; The current article may be from the ephemeral group
6549 ;; thus it is best that we reload this article
6550 (gnus-summary-show-article)
6551 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6552 (gnus-configure-windows 'pick 'force)
6553 (gnus-configure-windows (cdr quit-config) 'force)))
6554 (gnus-configure-windows (cdr quit-config) 'force))
6555 (when (eq major-mode 'gnus-summary-mode)
6556 (gnus-summary-next-subject 1 nil t)
6557 (gnus-summary-recenter)
6558 (gnus-summary-position-point))))
6560 (defun gnus-summary-preview-mime-message ()
6561 "MIME decode and play this message."
6563 (let ((gnus-break-pages nil)
6565 (gnus-summary-select-article gnus-show-all-headers t))
6566 (let ((w (get-buffer-window gnus-article-buffer)))
6568 (select-window (get-buffer-window gnus-article-buffer)))))
6572 (defvar gnus-dead-summary-mode-map nil)
6574 (unless gnus-dead-summary-mode-map
6575 (setq gnus-dead-summary-mode-map (make-keymap))
6576 (suppress-keymap gnus-dead-summary-mode-map)
6577 (substitute-key-definition
6578 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6579 (dolist (key '("\C-d" "\r" "\177" [delete]))
6580 (define-key gnus-dead-summary-mode-map
6581 key 'gnus-summary-wake-up-the-dead))
6582 (dolist (key '("q" "Q"))
6583 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6585 (defvar gnus-dead-summary-mode nil
6586 "Minor mode for Gnus summary buffers.")
6588 (defun gnus-dead-summary-mode (&optional arg)
6589 "Minor mode for Gnus summary buffers."
6591 (when (eq major-mode 'gnus-summary-mode)
6592 (make-local-variable 'gnus-dead-summary-mode)
6593 (setq gnus-dead-summary-mode
6594 (if (null arg) (not gnus-dead-summary-mode)
6595 (> (prefix-numeric-value arg) 0)))
6596 (when gnus-dead-summary-mode
6597 (gnus-add-minor-mode
6598 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6600 (defun gnus-deaden-summary ()
6601 "Make the current summary buffer into a dead summary buffer."
6602 ;; Kill any previous dead summary buffer.
6603 (when (and gnus-dead-summary
6604 (buffer-name gnus-dead-summary))
6606 (set-buffer gnus-dead-summary)
6607 (when gnus-dead-summary-mode
6608 (kill-buffer (current-buffer)))))
6609 ;; Make this the current dead summary.
6610 (setq gnus-dead-summary (current-buffer))
6611 (gnus-dead-summary-mode 1)
6612 (let ((name (buffer-name)))
6613 (when (string-match "Summary" name)
6615 (concat (substring name 0 (match-beginning 0)) "Dead "
6616 (substring name (match-beginning 0)))
6620 (defun gnus-kill-or-deaden-summary (buffer)
6621 "Kill or deaden the summary BUFFER."
6623 (when (and (buffer-name buffer)
6624 (not gnus-single-article-buffer))
6627 (gnus-kill-buffer gnus-article-buffer)
6628 (gnus-kill-buffer gnus-original-article-buffer)))
6631 (gnus-kill-summary-on-exit
6632 (when (and gnus-use-trees
6633 (gnus-buffer-exists-p buffer))
6636 (gnus-tree-close gnus-newsgroup-name)))
6637 (gnus-kill-buffer buffer))
6638 ;; Deaden the buffer.
6639 ((gnus-buffer-exists-p buffer)
6642 (gnus-deaden-summary))))))
6644 (defun gnus-summary-wake-up-the-dead (&rest args)
6645 "Wake up the dead summary buffer."
6647 (gnus-dead-summary-mode -1)
6648 (let ((name (buffer-name)))
6649 (when (string-match "Dead " name)
6651 (concat (substring name 0 (match-beginning 0))
6652 (substring name (match-end 0)))
6654 (gnus-message 3 "This dead summary is now alive again"))
6656 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6657 (defun gnus-summary-fetch-faq (&optional faq-dir)
6658 "Fetch the FAQ for the current group.
6659 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6663 (when current-prefix-arg
6665 "FAQ dir: " (and (listp gnus-group-faq-directory)
6666 (mapcar (lambda (file) (list file))
6667 gnus-group-faq-directory))))))
6668 (let (gnus-faq-buffer)
6669 (when (setq gnus-faq-buffer
6670 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6671 (gnus-configure-windows 'summary-faq))))
6673 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6674 (defun gnus-summary-describe-group (&optional force)
6675 "Describe the current newsgroup."
6677 (gnus-group-describe-group force gnus-newsgroup-name))
6679 (defun gnus-summary-describe-briefly ()
6680 "Describe summary mode commands briefly."
6682 (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")))
6684 ;; Walking around group mode buffer from summary mode.
6686 (defun gnus-summary-next-group (&optional no-article target-group backward)
6687 "Exit current newsgroup and then select next unread newsgroup.
6688 If prefix argument NO-ARTICLE is non-nil, no article is selected
6689 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6690 previous group instead."
6692 ;; Stop pre-fetching.
6693 (gnus-async-halt-prefetch)
6694 (let ((current-group gnus-newsgroup-name)
6695 (current-buffer (current-buffer))
6697 (gnus-summary-exit t)
6698 (while (not entered)
6699 ;; Then we find what group we are supposed to enter.
6700 (set-buffer gnus-group-buffer)
6701 (gnus-group-jump-to-group current-group)
6704 (if (eq gnus-keep-same-level 'best)
6705 (gnus-summary-best-group gnus-newsgroup-name)
6706 (gnus-summary-search-group backward gnus-keep-same-level))))
6707 (if (not target-group)
6708 ;; There are no further groups, so we return to the group
6711 (gnus-message 5 "Returning to the group buffer")
6713 (when (gnus-buffer-live-p current-buffer)
6714 (set-buffer current-buffer)
6715 (gnus-summary-exit))
6716 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6717 ;; We try to enter the target group.
6718 (gnus-group-jump-to-group target-group)
6719 (let ((unreads (gnus-group-group-unread)))
6720 (if (and (or (eq t unreads)
6721 (and unreads (not (zerop unreads))))
6723 ;; Now we semi-exit this group to update Xrefs
6724 ;; and all variables. We can't do a real exit,
6725 ;; because the window conf must remain the same
6726 ;; in case the user is prompted for info, and we
6727 ;; don't want the window conf to change before
6729 (when (gnus-buffer-live-p current-buffer)
6730 (set-buffer current-buffer)
6731 (gnus-summary-exit t))
6732 (gnus-summary-read-group
6733 target-group nil no-article
6734 (and (buffer-name current-buffer) current-buffer)
6737 (setq current-group target-group
6738 target-group nil)))))))
6740 (defun gnus-summary-prev-group (&optional no-article)
6741 "Exit current newsgroup and then select previous unread newsgroup.
6742 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6744 (gnus-summary-next-group no-article nil t))
6746 ;; Walking around summary lines.
6748 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6749 "Go to the first subject satisfying any non-nil constraint.
6750 If UNREAD is non-nil, the article should be unread.
6751 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6752 If UNSEED is non-nil, the article should be unseen.
6753 Returns the article selected or nil if there are no matching articles."
6757 ((null gnus-newsgroup-data)
6758 (gnus-message 3 "No articles in the group")
6760 ;; Pick the first article.
6761 ((not (or unread undownloaded unseen))
6762 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6763 (gnus-data-number (car gnus-newsgroup-data)))
6764 ;; Find the first unread article.
6766 (let ((data gnus-newsgroup-data))
6768 (let ((num (gnus-data-number (car data))))
6769 (or (memq num gnus-newsgroup-unfetched)
6770 (not (or (and unread
6771 (memq num gnus-newsgroup-unreads))
6773 (memq num gnus-newsgroup-undownloaded))
6775 (memq num gnus-newsgroup-unseen)))))))
6776 (setq data (cdr data)))
6780 (goto-char (gnus-data-pos (car data)))
6781 (gnus-data-number (car data)))
6782 (gnus-message 3 "No more%s articles"
6783 (let* ((r (when unread " unread"))
6784 (d (when undownloaded " undownloaded"))
6785 (s (when unseen " unseen"))
6786 (l (delq nil (list r d s))))
6787 (cond ((= 3 (length l))
6788 (concat r "," d ", or" s))
6790 (concat (car l) ", or" (cadr l)))
6797 (gnus-summary-position-point))))))
6799 (defun gnus-summary-next-subject (n &optional unread dont-display)
6800 "Go to next N'th summary line.
6801 If N is negative, go to the previous N'th subject line.
6802 If UNREAD is non-nil, only unread articles are selected.
6803 The difference between N and the actual number of steps taken is
6806 (let ((backward (< n 0))
6810 (gnus-summary-find-prev unread)
6811 (gnus-summary-find-next unread)))
6812 (unless (zerop (setq n (1- n)))
6813 (gnus-summary-show-thread)))
6815 (gnus-message 7 "No more%s articles"
6816 (if unread " unread" "")))
6817 (unless dont-display
6818 (gnus-summary-recenter)
6819 (gnus-summary-position-point))
6822 (defun gnus-summary-next-unread-subject (n)
6823 "Go to next N'th unread summary line."
6825 (gnus-summary-next-subject n t))
6827 (defun gnus-summary-prev-subject (n &optional unread)
6828 "Go to previous N'th summary line.
6829 If optional argument UNREAD is non-nil, only unread article is selected."
6831 (gnus-summary-next-subject (- n) unread))
6833 (defun gnus-summary-prev-unread-subject (n)
6834 "Go to previous N'th unread summary line."
6836 (gnus-summary-next-subject (- n) t))
6838 (defun gnus-summary-goto-subjects (articles)
6839 "Insert the subject header for ARTICLES in the current buffer."
6841 (dolist (article articles)
6842 (gnus-summary-goto-subject article t)))
6843 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6844 (gnus-summary-position-point))
6846 (defun gnus-summary-goto-subject (article &optional force silent)
6847 "Go the subject line of ARTICLE.
6848 If FORCE, also allow jumping to articles not currently shown."
6849 (interactive "nArticle number: ")
6850 (unless (numberp article)
6851 (error "Article %s is not a number" article))
6853 (data (gnus-data-find article)))
6854 ;; We read in the article if we have to.
6857 (gnus-summary-insert-subject
6859 (if (or (numberp force) (vectorp force)) force)
6861 (setq data (gnus-data-find article)))
6866 (gnus-message 3 "Can't find article %d" article))
6868 (let ((pt (gnus-data-pos data)))
6870 (gnus-summary-set-article-display-arrow pt))
6871 (gnus-summary-position-point)
6874 ;; Walking around summary lines with displaying articles.
6876 (defun gnus-summary-expand-window (&optional arg)
6877 "Make the summary buffer take up the entire Emacs frame.
6878 Given a prefix, will force an `article' buffer configuration."
6881 (gnus-configure-windows 'article 'force)
6882 (gnus-configure-windows 'summary 'force)))
6884 (defun gnus-summary-display-article (article &optional all-header)
6885 "Display ARTICLE in article buffer."
6886 (when (gnus-buffer-live-p gnus-article-buffer)
6887 (with-current-buffer gnus-article-buffer
6888 (set-buffer-multibyte t)))
6889 (gnus-set-global-variables)
6890 (when (gnus-buffer-live-p gnus-article-buffer)
6891 (with-current-buffer gnus-article-buffer
6892 (setq gnus-article-charset gnus-newsgroup-charset)
6893 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6894 (set-buffer-multibyte t)))
6898 (if gnus-summary-display-article-function
6899 (funcall gnus-summary-display-article-function article all-header)
6900 (gnus-article-prepare article all-header))
6901 (with-current-buffer gnus-article-buffer
6902 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6904 (gnus-run-hooks 'gnus-select-article-hook)
6905 (when (and gnus-current-article
6906 (not (zerop gnus-current-article)))
6907 (gnus-summary-goto-subject gnus-current-article))
6908 (gnus-summary-recenter)
6909 (when (and gnus-use-trees gnus-show-threads)
6910 (gnus-possibly-generate-tree article)
6911 (gnus-highlight-selected-tree article))
6912 ;; Successfully display article.
6913 (gnus-article-set-window-start
6914 (cdr (assq article gnus-newsgroup-bookmarks))))))
6916 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6917 "Select the current article.
6918 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6919 non-nil, the article will be re-fetched even if it already present in
6920 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6922 ;; Make sure we are in the summary buffer to work around bbdb bug.
6923 (unless (eq major-mode 'gnus-summary-mode)
6924 (set-buffer gnus-summary-buffer))
6925 (let ((article (or article (gnus-summary-article-number)))
6926 (all-headers (not (not all-headers))) ;Must be T or NIL.
6927 gnus-summary-display-article-function)
6929 (gnus-summary-article-pseudo-p article)
6930 (error "This is a pseudo-article"))
6932 (set-buffer gnus-summary-buffer)
6933 (if (or (and gnus-single-article-buffer
6934 (or (null gnus-current-article)
6935 (null gnus-article-current)
6936 (null (get-buffer gnus-article-buffer))
6937 (not (eq article (cdr gnus-article-current)))
6938 (not (equal (car gnus-article-current)
6939 gnus-newsgroup-name))))
6940 (and (not gnus-single-article-buffer)
6941 (or (null gnus-current-article)
6942 (not (eq gnus-current-article article))))
6944 ;; The requested article is different from the current article.
6946 (gnus-summary-display-article article all-headers)
6947 (gnus-article-set-window-start
6948 (cdr (assq article gnus-newsgroup-bookmarks)))
6952 (defun gnus-summary-force-verify-and-decrypt ()
6953 "Display buttons for signed/encrypted parts and verify/decrypt them."
6955 (let ((mm-verify-option 'known)
6956 (mm-decrypt-option 'known)
6957 (gnus-buttonized-mime-types (append (list "multipart/signed"
6958 "multipart/encrypted")
6959 gnus-buttonized-mime-types)))
6960 (gnus-summary-select-article nil 'force)))
6962 (defun gnus-summary-set-current-mark (&optional current-mark)
6963 "Obsolete function."
6966 (defun gnus-summary-next-article (&optional unread subject backward push)
6967 "Select the next article.
6968 If UNREAD, only unread articles are selected.
6969 If SUBJECT, only articles with SUBJECT are selected.
6970 If BACKWARD, the previous article is selected instead of the next."
6973 ;; Is there such an article?
6974 ((and (gnus-summary-search-forward unread subject backward)
6975 (or (gnus-summary-display-article (gnus-summary-article-number))
6976 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6977 (gnus-summary-position-point))
6978 ;; If not, we try the first unread, if that is wanted.
6980 gnus-auto-select-same
6981 (gnus-summary-first-unread-article))
6982 (gnus-summary-position-point)
6983 (gnus-message 6 "Wrapped"))
6984 ;; Try to get next/previous article not displayed in this group.
6985 ((and gnus-auto-extend-newsgroup
6986 (not unread) (not subject))
6987 (gnus-summary-goto-article
6988 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6989 nil (count-lines (point-min) (point))))
6990 ;; Go to next/previous group.
6992 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6993 (gnus-summary-jump-to-group gnus-newsgroup-name))
6994 (let ((cmd last-command-char)
6997 (set-buffer gnus-group-buffer)
7000 (if (eq gnus-keep-same-level 'best)
7001 (gnus-summary-best-group gnus-newsgroup-name)
7002 (gnus-summary-search-group backward gnus-keep-same-level))))
7003 ;; For some reason, the group window gets selected. We change
7005 (select-window (get-buffer-window (current-buffer)))
7006 ;; Select next unread newsgroup automagically.
7008 ((or (not gnus-auto-select-next)
7010 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7011 ((or (eq gnus-auto-select-next 'quietly)
7012 (and (eq gnus-auto-select-next 'slightly-quietly)
7014 (and (eq gnus-auto-select-next 'almost-quietly)
7015 (gnus-summary-last-article-p)))
7017 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7019 (gnus-message 7 "No more%s articles (%s)..."
7020 (if unread " unread" "")
7021 (if group (concat "selecting " group)
7023 (gnus-summary-next-group nil group backward)))
7025 (when (gnus-key-press-event-p last-input-event)
7026 (gnus-summary-walk-group-buffer
7027 gnus-newsgroup-name cmd unread backward point))))))))
7029 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7030 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7031 (?\C-p (gnus-group-prev-unread-group 1))))
7032 (cursor-in-echo-area t)
7033 keve key group ended prompt)
7035 (set-buffer gnus-group-buffer)
7038 (if (eq gnus-keep-same-level 'best)
7039 (gnus-summary-best-group gnus-newsgroup-name)
7040 (gnus-summary-search-group backward gnus-keep-same-level))))
7044 "No more%s articles%s " (if unread " unread" "")
7046 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7047 (format " (Type %s for %s [%s])"
7048 (single-key-description cmd) group
7049 (car (gnus-gethash group gnus-newsrc-hashtb)))
7050 (format " (Type %s to exit %s)"
7051 (single-key-description cmd)
7052 gnus-newsgroup-name))))
7053 ;; Confirm auto selection.
7054 (setq key (car (setq keve (gnus-read-event-char prompt)))
7057 ((assq key keystrokes)
7058 (let ((obuf (current-buffer)))
7059 (switch-to-buffer gnus-group-buffer)
7061 (gnus-group-jump-to-group group))
7062 (eval (cadr (assq key keystrokes)))
7063 (setq group (gnus-group-group-name))
7064 (switch-to-buffer obuf))
7068 (gnus-ephemeral-group-p gnus-newsgroup-name))
7070 (gnus-summary-next-group nil group backward)))
7072 (push (cdr keve) unread-command-events))))))
7074 (defun gnus-summary-next-unread-article ()
7075 "Select unread article after current one."
7077 (gnus-summary-next-article
7078 (or (not (eq gnus-summary-goto-unread 'never))
7079 (gnus-summary-last-article-p (gnus-summary-article-number)))
7080 (and gnus-auto-select-same
7081 (gnus-summary-article-subject))))
7083 (defun gnus-summary-prev-article (&optional unread subject)
7084 "Select the article after the current one.
7085 If UNREAD is non-nil, only unread articles are selected."
7087 (gnus-summary-next-article unread subject t))
7089 (defun gnus-summary-prev-unread-article ()
7090 "Select unread article before current one."
7092 (gnus-summary-prev-article
7093 (or (not (eq gnus-summary-goto-unread 'never))
7094 (gnus-summary-first-article-p (gnus-summary-article-number)))
7095 (and gnus-auto-select-same
7096 (gnus-summary-article-subject))))
7098 (defun gnus-summary-next-page (&optional lines circular stop)
7099 "Show next page of the selected article.
7100 If at the end of the current article, select the next article.
7101 LINES says how many lines should be scrolled up.
7103 If CIRCULAR is non-nil, go to the start of the article instead of
7104 selecting the next article when reaching the end of the current
7107 If STOP is non-nil, just stop when reaching the end of the message."
7109 (setq gnus-summary-buffer (current-buffer))
7110 (gnus-set-global-variables)
7111 (let ((article (gnus-summary-article-number))
7112 (article-window (get-buffer-window gnus-article-buffer t))
7114 ;; If the buffer is empty, we have no article.
7116 (error "No article to select"))
7117 (gnus-configure-windows 'article)
7118 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7119 (if (and (eq gnus-summary-goto-unread 'never)
7120 (not (gnus-summary-last-article-p article)))
7121 (gnus-summary-next-article)
7122 (gnus-summary-next-unread-article))
7123 (if (or (null gnus-current-article)
7124 (null gnus-article-current)
7125 (/= article (cdr gnus-article-current))
7126 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7127 ;; Selected subject is different from current article's.
7128 (gnus-summary-display-article article)
7129 (when article-window
7130 (gnus-eval-in-buffer-window gnus-article-buffer
7131 (setq endp (or (gnus-article-next-page lines)
7132 (gnus-article-only-boring-p))))
7135 (gnus-message 3 "End of message"))
7137 (gnus-summary-beginning-of-article))
7139 (gnus-message 3 "End of message"))
7141 (if (and (eq gnus-summary-goto-unread 'never)
7142 (not (gnus-summary-last-article-p article)))
7143 (gnus-summary-next-article)
7144 (gnus-summary-next-unread-article))))))))
7145 (gnus-summary-recenter)
7146 (gnus-summary-position-point)))
7148 (defun gnus-summary-prev-page (&optional lines move)
7149 "Show previous page of selected article.
7150 Argument LINES specifies lines to be scrolled down.
7151 If MOVE, move to the previous unread article if point is at
7152 the beginning of the buffer."
7154 (let ((article (gnus-summary-article-number))
7155 (article-window (get-buffer-window gnus-article-buffer t))
7157 (gnus-configure-windows 'article)
7158 (if (or (null gnus-current-article)
7159 (null gnus-article-current)
7160 (/= article (cdr gnus-article-current))
7161 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7162 ;; Selected subject is different from current article's.
7163 (gnus-summary-display-article article)
7164 (gnus-summary-recenter)
7165 (when article-window
7166 (gnus-eval-in-buffer-window gnus-article-buffer
7167 (setq endp (gnus-article-prev-page lines)))
7168 (when (and move endp)
7170 (gnus-message 3 "Beginning of message"))
7172 (if (and (eq gnus-summary-goto-unread 'never)
7173 (not (gnus-summary-first-article-p article)))
7174 (gnus-summary-prev-article)
7175 (gnus-summary-prev-unread-article))))))))
7176 (gnus-summary-position-point))
7178 (defun gnus-summary-prev-page-or-article (&optional lines)
7179 "Show previous page of selected article.
7180 Argument LINES specifies lines to be scrolled down.
7181 If at the beginning of the article, go to the next article."
7183 (gnus-summary-prev-page lines t))
7185 (defun gnus-summary-scroll-up (lines)
7186 "Scroll up (or down) one line current article.
7187 Argument LINES specifies lines to be scrolled up (or down if negative)."
7189 (gnus-configure-windows 'article)
7190 (gnus-summary-show-thread)
7191 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7192 (gnus-eval-in-buffer-window gnus-article-buffer
7194 (when (gnus-article-next-page lines)
7195 (gnus-message 3 "End of message")))
7197 (gnus-article-prev-page (- lines))))))
7198 (gnus-summary-recenter)
7199 (gnus-summary-position-point))
7201 (defun gnus-summary-scroll-down (lines)
7202 "Scroll down (or up) one line current article.
7203 Argument LINES specifies lines to be scrolled down (or up if negative)."
7205 (gnus-summary-scroll-up (- lines)))
7207 (defun gnus-summary-next-same-subject ()
7208 "Select next article which has the same subject as current one."
7210 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7212 (defun gnus-summary-prev-same-subject ()
7213 "Select previous article which has the same subject as current one."
7215 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7217 (defun gnus-summary-next-unread-same-subject ()
7218 "Select next unread article which has the same subject as current one."
7220 (gnus-summary-next-article t (gnus-summary-article-subject)))
7222 (defun gnus-summary-prev-unread-same-subject ()
7223 "Select previous unread article which has the same subject as current one."
7225 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7227 (defun gnus-summary-first-unread-article ()
7228 "Select the first unread article.
7229 Return nil if there are no unread articles."
7232 (when (gnus-summary-first-subject t)
7233 (gnus-summary-show-thread)
7234 (gnus-summary-first-subject t)
7235 (gnus-summary-display-article (gnus-summary-article-number)))
7236 (gnus-summary-position-point)))
7238 (defun gnus-summary-first-unread-subject ()
7239 "Place the point on the subject line of the first unread article.
7240 Return nil if there are no unread articles."
7243 (when (gnus-summary-first-subject t)
7244 (gnus-summary-show-thread)
7245 (gnus-summary-first-subject t))
7246 (gnus-summary-position-point)))
7248 (defun gnus-summary-first-unseen-subject ()
7249 "Place the point on the subject line of the first unseen article.
7250 Return nil if there are no unseen articles."
7253 (when (gnus-summary-first-subject nil nil t)
7254 (gnus-summary-show-thread)
7255 (gnus-summary-first-subject nil nil t))
7256 (gnus-summary-position-point)))
7258 (defun gnus-summary-first-unseen-or-unread-subject ()
7259 "Place the point on the subject line of the first unseen article or,
7260 if all article have been seen, on the subject line of the first unread
7264 (unless (when (gnus-summary-first-subject nil nil t)
7265 (gnus-summary-show-thread)
7266 (gnus-summary-first-subject nil nil t))
7267 (when (gnus-summary-first-subject t)
7268 (gnus-summary-show-thread)
7269 (gnus-summary-first-subject t)))
7270 (gnus-summary-position-point)))
7272 (defun gnus-summary-first-article ()
7273 "Select the first article.
7274 Return nil if there are no articles."
7277 (when (gnus-summary-first-subject)
7278 (gnus-summary-show-thread)
7279 (gnus-summary-first-subject)
7280 (gnus-summary-display-article (gnus-summary-article-number)))
7281 (gnus-summary-position-point)))
7283 (defun gnus-summary-best-unread-article (&optional arg)
7284 "Select the unread article with the highest score.
7285 If given a prefix argument, select the next unread article that has a
7286 score higher than the default score."
7288 (let ((article (if arg
7289 (gnus-summary-better-unread-subject)
7290 (gnus-summary-best-unread-subject))))
7292 (gnus-summary-goto-article article)
7293 (error "No unread articles"))))
7295 (defun gnus-summary-best-unread-subject ()
7296 "Select the unread subject with the highest score."
7298 (let ((best -1000000)
7299 (data gnus-newsgroup-data)
7302 (and (gnus-data-unread-p (car data))
7304 (gnus-summary-article-score (gnus-data-number (car data))))
7307 article (gnus-data-number (car data))))
7308 (setq data (cdr data)))
7310 (gnus-summary-goto-subject article))
7311 (gnus-summary-position-point)
7314 (defun gnus-summary-better-unread-subject ()
7315 "Select the first unread subject that has a score over the default score."
7317 (let ((data gnus-newsgroup-data)
7319 (while (and (setq article (gnus-data-number (car data)))
7320 (or (gnus-data-read-p (car data))
7321 (not (> (gnus-summary-article-score article)
7322 gnus-summary-default-score))))
7323 (setq data (cdr data)))
7325 (gnus-summary-goto-subject article))
7326 (gnus-summary-position-point)
7329 (defun gnus-summary-last-subject ()
7330 "Go to the last displayed subject line in the group."
7331 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7333 (gnus-summary-goto-subject article))))
7335 (defun gnus-summary-goto-article (article &optional all-headers force)
7336 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7337 If ALL-HEADERS is non-nil, no header lines are hidden.
7338 If FORCE, go to the article even if it isn't displayed. If FORCE
7339 is a number, it is the line the article is to be displayed on."
7343 "Article number or Message-ID: "
7344 (mapcar (lambda (number) (list (int-to-string number)))
7345 gnus-newsgroup-limit))
7349 (if (and (stringp article)
7350 (string-match "@" article))
7351 (gnus-summary-refer-article article)
7352 (when (stringp article)
7353 (setq article (string-to-number article)))
7354 (if (gnus-summary-goto-subject article force)
7355 (gnus-summary-display-article article all-headers)
7356 (gnus-message 4 "Couldn't go to article %s" article) nil))
7357 (gnus-summary-position-point)))
7359 (defun gnus-summary-goto-last-article ()
7360 "Go to the previously read article."
7363 (when gnus-last-article
7364 (gnus-summary-goto-article gnus-last-article nil t))
7365 (gnus-summary-position-point)))
7367 (defun gnus-summary-pop-article (number)
7368 "Pop one article off the history and go to the previous.
7369 NUMBER articles will be popped off."
7372 (setq gnus-newsgroup-history
7373 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7375 (gnus-summary-goto-article (car to) nil t)
7376 (error "Article history empty")))
7377 (gnus-summary-position-point))
7379 ;; Summary commands and functions for limiting the summary buffer.
7381 (defun gnus-summary-limit-to-articles (n)
7382 "Limit the summary buffer to the next N articles.
7383 If not given a prefix, use the process marked articles instead."
7386 (let ((articles (gnus-summary-work-articles n)))
7387 (setq gnus-newsgroup-processable nil)
7388 (gnus-summary-limit articles))
7389 (gnus-summary-position-point)))
7391 (defun gnus-summary-pop-limit (&optional total)
7392 "Restore the previous limit.
7393 If given a prefix, remove all limits."
7396 (setq gnus-newsgroup-limits
7397 (list (mapcar (lambda (h) (mail-header-number h))
7398 gnus-newsgroup-headers))))
7399 (unless gnus-newsgroup-limits
7400 (error "No limit to pop"))
7402 (gnus-summary-limit nil 'pop)
7403 (gnus-summary-position-point)))
7405 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7406 "Limit the summary buffer to articles that have subjects that match a regexp.
7407 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7409 (list (read-string (if current-prefix-arg
7410 "Exclude subject (regexp): "
7411 "Limit to subject (regexp): "))
7412 nil current-prefix-arg))
7414 (setq header "subject"))
7415 (when (not (equal "" subject))
7417 (let ((articles (gnus-summary-find-matching
7418 (or header "subject") subject 'all nil nil
7421 (error "Found no matches for \"%s\"" subject))
7422 (gnus-summary-limit articles))
7423 (gnus-summary-position-point))))
7425 (defun gnus-summary-limit-to-author (from &optional not-matching)
7426 "Limit the summary buffer to articles that have authors that match a regexp.
7427 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7429 (list (read-string (if current-prefix-arg
7430 "Exclude author (regexp): "
7431 "Limit to author (regexp): "))
7432 current-prefix-arg))
7433 (gnus-summary-limit-to-subject from "from" not-matching))
7435 (defun gnus-summary-limit-to-age (age &optional younger-p)
7436 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7437 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7438 articles that are younger than AGE days."
7440 (let ((younger current-prefix-arg)
7443 (while (not days-got)
7444 (setq days (if younger
7445 (read-string "Limit to articles younger than (in days, older when negative): ")
7447 "Limit to articles older than (in days, younger when negative): ")))
7448 (when (> (length days) 0)
7449 (setq days (read days)))
7455 (setq younger (not younger))
7456 (setq days (* days -1)))))
7457 (message "Please enter a number.")
7459 (list days younger)))
7461 (let ((data gnus-newsgroup-data)
7462 (cutoff (days-to-time age))
7463 articles d date is-younger)
7464 (while (setq d (pop data))
7465 (when (and (vectorp (gnus-data-header d))
7466 (setq date (mail-header-date (gnus-data-header d))))
7467 (setq is-younger (time-less-p
7468 (time-since (condition-case ()
7475 (push (gnus-data-number d) articles))))
7476 (gnus-summary-limit (nreverse articles)))
7477 (gnus-summary-position-point)))
7479 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7480 "Limit the summary buffer to articles that match an 'extra' header."
7484 (gnus-completing-read-with-default
7485 (symbol-name (car gnus-extra-headers))
7486 (if current-prefix-arg
7487 "Exclude extra header:"
7488 "Limit extra header:")
7490 (cons (symbol-name x) x))
7495 (read-string (format "%s header %s (regexp): "
7496 (if current-prefix-arg "Exclude" "Limit to")
7498 current-prefix-arg)))
7499 (when (not (equal "" regexp))
7501 (let ((articles (gnus-summary-find-matching
7502 (cons 'extra header) regexp 'all nil nil
7505 (error "Found no matches for \"%s\"" regexp))
7506 (gnus-summary-limit articles))
7507 (gnus-summary-position-point))))
7509 (defun gnus-summary-limit-to-display-predicate ()
7510 "Limit the summary buffer to the predicated in the `display' group parameter."
7512 (unless gnus-newsgroup-display
7513 (error "There is no `display' group parameter"))
7515 (dolist (number gnus-newsgroup-articles)
7516 (when (funcall gnus-newsgroup-display)
7517 (push number articles)))
7518 (gnus-summary-limit articles))
7519 (gnus-summary-position-point))
7521 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7523 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7525 (defun gnus-summary-limit-to-unread (&optional all)
7526 "Limit the summary buffer to articles that are not marked as read.
7527 If ALL is non-nil, limit strictly to unread articles."
7530 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7531 (gnus-summary-limit-to-marks
7532 ;; Concat all the marks that say that an article is read and have
7534 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7535 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7536 gnus-low-score-mark gnus-expirable-mark
7537 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7538 gnus-duplicate-mark gnus-souped-mark)
7541 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7542 (make-obsolete 'gnus-summary-delete-marked-with
7543 'gnus-summary-limit-exclude-marks)
7545 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7546 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7547 If REVERSE, limit the summary buffer to articles that are marked
7548 with MARKS. MARKS can either be a string of marks or a list of marks.
7549 Returns how many articles were removed."
7550 (interactive "sMarks: ")
7551 (gnus-summary-limit-to-marks marks t))
7553 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7554 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7555 If REVERSE (the prefix), limit the summary buffer to articles that are
7556 not marked with MARKS. MARKS can either be a string of marks or a
7558 Returns how many articles were removed."
7559 (interactive "sMarks: \nP")
7561 (let ((data gnus-newsgroup-data)
7562 (marks (if (listp marks) marks
7563 (append marks nil))) ; Transform to list.
7566 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7567 (memq (gnus-data-mark (car data)) marks))
7568 (push (gnus-data-number (car data)) articles))
7569 (setq data (cdr data)))
7570 (gnus-summary-limit articles))
7571 (gnus-summary-position-point)))
7573 (defun gnus-summary-limit-to-score (score)
7574 "Limit to articles with score at or above SCORE."
7575 (interactive "NLimit to articles with score of at least: ")
7576 (let ((data gnus-newsgroup-data)
7579 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7581 (push (gnus-data-number (car data)) articles))
7582 (setq data (cdr data)))
7584 (gnus-summary-limit articles)
7585 (gnus-summary-position-point))))
7587 (defun gnus-summary-limit-to-unseen ()
7588 "Limit to unseen articles."
7591 (gnus-summary-limit gnus-newsgroup-unseen)
7592 (gnus-summary-position-point)))
7594 (defun gnus-summary-limit-include-thread (id)
7595 "Display all the hidden articles that is in the thread with ID in it.
7596 When called interactively, ID is the Message-ID of the current
7598 (interactive (list (mail-header-id (gnus-summary-article-header))))
7599 (let ((articles (gnus-articles-in-thread
7600 (gnus-id-to-thread (gnus-root-id id)))))
7602 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7603 (gnus-summary-limit-include-matching-articles
7605 (regexp-quote (gnus-simplify-subject-re
7606 (mail-header-subject (gnus-id-to-header id)))))
7607 (gnus-summary-position-point))))
7609 (defun gnus-summary-limit-include-matching-articles (header regexp)
7610 "Display all the hidden articles that have HEADERs that match REGEXP."
7611 (interactive (list (read-string "Match on header: ")
7612 (read-string "Regexp: ")))
7613 (let ((articles (gnus-find-matching-articles header regexp)))
7615 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7616 (gnus-summary-position-point))))
7618 (defun gnus-summary-insert-dormant-articles ()
7619 "Insert all the dormat articles for this group into the current buffer."
7621 (let ((gnus-verbose (max 6 gnus-verbose)))
7622 (if (not gnus-newsgroup-dormant)
7623 (gnus-message 3 "No cached articles for this group")
7624 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7626 (defun gnus-summary-limit-include-dormant ()
7627 "Display all the hidden articles that are marked as dormant.
7628 Note that this command only works on a subset of the articles currently
7629 fetched for this group."
7631 (unless gnus-newsgroup-dormant
7632 (error "There are no dormant articles in this group"))
7634 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7635 (gnus-summary-position-point)))
7637 (defun gnus-summary-limit-exclude-dormant ()
7638 "Hide all dormant articles."
7641 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7642 (gnus-summary-position-point)))
7644 (defun gnus-summary-limit-exclude-childless-dormant ()
7645 "Hide all dormant articles that have no children."
7647 (let ((data (gnus-data-list t))
7648 articles d children)
7649 ;; Find all articles that are either not dormant or have
7651 (while (setq d (pop data))
7652 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7654 (gnus-article-children (gnus-data-number d)))
7657 (when (memq (car children) articles)
7662 (push (gnus-data-number d) articles)))
7665 (gnus-summary-limit articles)
7666 (gnus-summary-position-point))))
7668 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7669 "Mark all unread excluded articles as read.
7670 If ALL, mark even excluded ticked and dormants as read."
7672 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7673 (let ((articles (gnus-sorted-ndifference
7675 (mapcar (lambda (h) (mail-header-number h))
7676 gnus-newsgroup-headers)
7678 gnus-newsgroup-limit))
7680 (setq gnus-newsgroup-unreads
7681 (gnus-sorted-intersection gnus-newsgroup-unreads
7682 gnus-newsgroup-limit))
7684 (setq gnus-newsgroup-dormant nil
7685 gnus-newsgroup-marked nil
7686 gnus-newsgroup-reads
7688 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7689 gnus-newsgroup-reads))
7690 (while (setq article (pop articles))
7691 (unless (or (memq article gnus-newsgroup-dormant)
7692 (memq article gnus-newsgroup-marked))
7693 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7695 (defun gnus-summary-limit (articles &optional pop)
7697 ;; We pop the previous limit off the stack and use that.
7698 (setq articles (car gnus-newsgroup-limits)
7699 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7700 ;; We use the new limit, so we push the old limit on the stack.
7701 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7703 (setq gnus-newsgroup-limit articles)
7704 (let ((total (length gnus-newsgroup-data))
7705 (data (gnus-data-find-list (gnus-summary-article-number)))
7706 (gnus-summary-mark-below nil) ; Inhibit this.
7708 ;; This will do all the work of generating the new summary buffer
7709 ;; according to the new limit.
7710 (gnus-summary-prepare)
7711 ;; Hide any threads, possibly.
7712 (gnus-summary-maybe-hide-threads)
7713 ;; Try to return to the article you were at, or one in the
7716 ;; We try to find some article after the current one.
7718 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7721 (setq data (cdr data))))
7723 ;; If there is no data, that means that we were after the last
7724 ;; article. The same goes when we can't find any articles
7725 ;; after the current one.
7726 (goto-char (point-max))
7727 (gnus-summary-find-prev))
7728 (gnus-set-mode-line 'summary)
7729 ;; We return how many articles were removed from the summary
7730 ;; buffer as a result of the new limit.
7731 (- total (length gnus-newsgroup-data))))
7733 (defsubst gnus-invisible-cut-children (threads)
7736 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7741 (defsubst gnus-cut-thread (thread)
7742 "Go forwards in the thread until we find an article that we want to display."
7743 (when (or (eq gnus-fetch-old-headers 'some)
7744 (eq gnus-fetch-old-headers 'invisible)
7745 (numberp gnus-fetch-old-headers)
7746 (eq gnus-build-sparse-threads 'some)
7747 (eq gnus-build-sparse-threads 'more))
7748 ;; Deal with old-fetched headers and sparse threads.
7752 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7753 (gnus-summary-article-ancient-p
7754 (mail-header-number (car thread))))
7755 (if (or (<= (length (cdr thread)) 1)
7756 (eq gnus-fetch-old-headers 'invisible))
7757 (setq gnus-newsgroup-limit
7758 (delq (mail-header-number (car thread))
7759 gnus-newsgroup-limit)
7760 thread (cadr thread))
7761 (when (gnus-invisible-cut-children (cdr thread))
7762 (let ((th (cdr thread)))
7764 (if (memq (mail-header-number (caar th))
7765 gnus-newsgroup-limit)
7766 (setq thread (car th)
7768 (setq th (cdr th))))))))))
7771 (defun gnus-cut-threads (threads)
7772 "Cut off all uninteresting articles from the beginning of threads."
7773 (when (or (eq gnus-fetch-old-headers 'some)
7774 (eq gnus-fetch-old-headers 'invisible)
7775 (numberp gnus-fetch-old-headers)
7776 (eq gnus-build-sparse-threads 'some)
7777 (eq gnus-build-sparse-threads 'more))
7780 (setcar th (gnus-cut-thread (car th)))
7781 (setq th (cdr th)))))
7782 ;; Remove nixed out threads.
7785 (defun gnus-summary-initial-limit (&optional show-if-empty)
7786 "Figure out what the initial limit is supposed to be on group entry.
7787 This entails weeding out unwanted dormants, low-scored articles,
7788 fetch-old-headers verbiage, and so on."
7789 ;; Most groups have nothing to remove.
7790 (if (or gnus-inhibit-limiting
7791 (and (null gnus-newsgroup-dormant)
7792 (eq gnus-newsgroup-display 'gnus-not-ignore)
7793 (not (eq gnus-fetch-old-headers 'some))
7794 (not (numberp gnus-fetch-old-headers))
7795 (not (eq gnus-fetch-old-headers 'invisible))
7796 (null gnus-summary-expunge-below)
7797 (not (eq gnus-build-sparse-threads 'some))
7798 (not (eq gnus-build-sparse-threads 'more))
7799 (null gnus-thread-expunge-below)
7800 (not gnus-use-nocem)))
7802 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7803 (setq gnus-newsgroup-limit nil)
7806 (unless (car (symbol-value node))
7807 ;; These threads have no parents -- they are roots.
7808 (let ((nodes (cdr (symbol-value node)))
7811 (if (and gnus-thread-expunge-below
7812 (< (gnus-thread-total-score (car nodes))
7813 gnus-thread-expunge-below))
7814 (gnus-expunge-thread (pop nodes))
7815 (setq thread (pop nodes))
7816 (gnus-summary-limit-children thread))))))
7817 gnus-newsgroup-dependencies)
7818 ;; If this limitation resulted in an empty group, we might
7819 ;; pop the previous limit and use it instead.
7820 (when (and (not gnus-newsgroup-limit)
7822 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7823 gnus-newsgroup-limit))
7825 (defun gnus-summary-limit-children (thread)
7826 "Return 1 if this subthread is visible and 0 if it is not."
7827 ;; First we get the number of visible children to this thread. This
7828 ;; is done by recursing down the thread using this function, so this
7829 ;; will really go down to a leaf article first, before slowly
7830 ;; working its way up towards the root.
7832 (let* ((max-lisp-eval-depth 5000)
7835 (apply '+ (mapcar 'gnus-summary-limit-children
7838 (number (mail-header-number (car thread)))
7841 (not (memq number gnus-newsgroup-marked))
7843 ;; If this article is dormant and has absolutely no visible
7844 ;; children, then this article isn't visible.
7845 (and (memq number gnus-newsgroup-dormant)
7847 ;; If this is "fetch-old-headered" and there is no
7848 ;; visible children, then we don't want this article.
7849 (and (or (eq gnus-fetch-old-headers 'some)
7850 (numberp gnus-fetch-old-headers))
7851 (gnus-summary-article-ancient-p number)
7853 ;; If this is "fetch-old-headered" and `invisible', then
7854 ;; we don't want this article.
7855 (and (eq gnus-fetch-old-headers 'invisible)
7856 (gnus-summary-article-ancient-p number))
7857 ;; If this is a sparsely inserted article with no children,
7858 ;; we don't want it.
7859 (and (eq gnus-build-sparse-threads 'some)
7860 (gnus-summary-article-sparse-p number)
7862 ;; If we use expunging, and this article is really
7863 ;; low-scored, then we don't want this article.
7864 (when (and gnus-summary-expunge-below
7866 (or (cdr (assq number gnus-newsgroup-scored))
7867 gnus-summary-default-score))
7868 gnus-summary-expunge-below))
7869 ;; We increase the expunge-tally here, but that has
7870 ;; nothing to do with the limits, really.
7871 (incf gnus-newsgroup-expunged-tally)
7872 ;; We also mark as read here, if that's wanted.
7873 (when (and gnus-summary-mark-below
7874 (< score gnus-summary-mark-below))
7875 (setq gnus-newsgroup-unreads
7876 (delq number gnus-newsgroup-unreads))
7877 (if gnus-newsgroup-auto-expire
7878 (push number gnus-newsgroup-expirable)
7879 (push (cons number gnus-low-score-mark)
7880 gnus-newsgroup-reads)))
7882 ;; Do the `display' group parameter.
7883 (and gnus-newsgroup-display
7884 (not (funcall gnus-newsgroup-display)))
7885 ;; Check NoCeM things.
7886 (if (and gnus-use-nocem
7887 (gnus-nocem-unwanted-article-p
7888 (mail-header-id (car thread))))
7890 (setq gnus-newsgroup-unreads
7891 (delq number gnus-newsgroup-unreads))
7893 ;; Nope, invisible article.
7895 ;; Ok, this article is to be visible, so we add it to the limit
7897 (push number gnus-newsgroup-limit)
7900 (defun gnus-expunge-thread (thread)
7901 "Mark all articles in THREAD as read."
7902 (let* ((number (mail-header-number (car thread))))
7903 (incf gnus-newsgroup-expunged-tally)
7904 ;; We also mark as read here, if that's wanted.
7905 (setq gnus-newsgroup-unreads
7906 (delq number gnus-newsgroup-unreads))
7907 (if gnus-newsgroup-auto-expire
7908 (push number gnus-newsgroup-expirable)
7909 (push (cons number gnus-low-score-mark)
7910 gnus-newsgroup-reads)))
7911 ;; Go recursively through all subthreads.
7912 (mapcar 'gnus-expunge-thread (cdr thread)))
7914 ;; Summary article oriented commands
7916 (defun gnus-summary-refer-parent-article (n)
7917 "Refer parent article N times.
7918 If N is negative, go to ancestor -N instead.
7919 The difference between N and the number of articles fetched is returned."
7923 (when (not (natnump n))
7928 (setq header (gnus-summary-article-header))
7929 (if (and (eq (mail-header-number header)
7930 (cdr gnus-article-current))
7931 (equal gnus-newsgroup-name
7932 (car gnus-article-current)))
7933 ;; If we try to find the parent of the currently
7934 ;; displayed article, then we take a look at the actual
7935 ;; References header, since this is slightly more
7936 ;; reliable than the References field we got from the
7939 (set-buffer gnus-original-article-buffer)
7940 (nnheader-narrow-to-headers)
7941 (unless (setq ref (message-fetch-field "references"))
7942 (setq ref (message-fetch-field "in-reply-to")))
7945 ;; It's not the current article, so we take a bet on
7946 ;; the value we got from the server.
7947 (mail-header-references header)))
7949 (not (equal ref "")))
7950 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7951 (gnus-message 1 "Couldn't find parent"))
7952 (gnus-message 1 "No references in article %d"
7953 (gnus-summary-article-number))
7956 (gnus-summary-position-point)
7959 (defun gnus-summary-refer-references ()
7960 "Fetch all articles mentioned in the References header.
7961 Return the number of articles fetched."
7963 (let ((ref (mail-header-references (gnus-summary-article-header)))
7964 (current (gnus-summary-article-number))
7968 (error "No References in the current article")
7969 ;; For each Message-ID in the References header...
7970 (while (string-match "<[^>]*>" ref)
7972 ;; ... fetch that article.
7973 (gnus-summary-refer-article
7974 (prog1 (match-string 0 ref)
7975 (setq ref (substring ref (match-end 0))))))
7976 (gnus-summary-goto-subject current)
7977 (gnus-summary-position-point)
7980 (defun gnus-summary-refer-thread (&optional limit)
7981 "Fetch all articles in the current thread.
7982 If LIMIT (the numerical prefix), fetch that many old headers instead
7983 of what's specified by the `gnus-refer-thread-limit' variable."
7985 (let ((id (mail-header-id (gnus-summary-article-header)))
7986 (limit (if limit (prefix-numeric-value limit)
7987 gnus-refer-thread-limit)))
7988 (unless (eq gnus-fetch-old-headers 'invisible)
7989 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7990 ;; Retrieve the headers and read them in.
7991 (if (eq (if (numberp limit)
7992 (gnus-retrieve-headers
7994 (+ (mail-header-number
7995 (gnus-summary-article-header))
7997 gnus-newsgroup-end))
7998 gnus-newsgroup-name (* limit 2))
7999 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8001 (gnus-retrieve-headers (list gnus-newsgroup-end)
8002 gnus-newsgroup-name limit))
8004 (gnus-build-all-threads)
8005 (error "Can't fetch thread from backends that don't support NOV"))
8006 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8007 (gnus-summary-limit-include-thread id)))
8009 (defun gnus-summary-refer-article (message-id)
8010 "Fetch an article specified by MESSAGE-ID."
8011 (interactive "sMessage-ID: ")
8012 (when (and (stringp message-id)
8013 (not (zerop (length message-id))))
8014 ;; Construct the correct Message-ID if necessary.
8015 ;; Suggested by tale@pawl.rpi.edu.
8016 (unless (string-match "^<" message-id)
8017 (setq message-id (concat "<" message-id)))
8018 (unless (string-match ">$" message-id)
8019 (setq message-id (concat message-id ">")))
8020 (let* ((header (gnus-id-to-header message-id))
8022 (gnus-summary-article-sparse-p
8023 (mail-header-number header))
8024 (memq (mail-header-number header)
8025 gnus-newsgroup-limit)))
8028 ;; If the article is present in the buffer we just go to it.
8030 (or (not (gnus-summary-article-sparse-p
8031 (mail-header-number header)))
8034 (gnus-summary-goto-article
8035 (mail-header-number header) nil t)
8037 (gnus-summary-update-article (mail-header-number header)))))
8039 ;; We fetch the article.
8041 (dolist (gnus-override-method (gnus-refer-article-methods))
8042 (gnus-check-server gnus-override-method)
8043 ;; Fetch the header, and display the article.
8044 (when (setq number (gnus-summary-insert-subject message-id))
8045 (gnus-summary-select-article nil nil nil number)
8047 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8049 (defun gnus-refer-article-methods ()
8050 "Return a list of referable methods."
8052 ;; No method, so we default to current and native.
8053 ((null gnus-refer-article-method)
8054 (list gnus-current-select-method gnus-select-method))
8056 ((eq 'current gnus-refer-article-method)
8057 (list gnus-current-select-method))
8058 ;; List of select methods.
8059 ((not (and (symbolp (car gnus-refer-article-method))
8060 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8062 (dolist (method gnus-refer-article-method)
8063 (push (if (eq 'current method)
8064 gnus-current-select-method
8068 ;; One single select method.
8070 (list gnus-refer-article-method))))
8072 (defun gnus-summary-edit-parameters ()
8073 "Edit the group parameters of the current group."
8075 (gnus-group-edit-group gnus-newsgroup-name 'params))
8077 (defun gnus-summary-customize-parameters ()
8078 "Customize the group parameters of the current group."
8080 (gnus-group-customize gnus-newsgroup-name))
8082 (defun gnus-summary-enter-digest-group (&optional force)
8083 "Enter an nndoc group based on the current article.
8084 If FORCE, force a digest interpretation. If not, try
8085 to guess what the document format is."
8087 (let ((conf gnus-current-window-configuration))
8089 (gnus-summary-select-article))
8090 (setq gnus-current-window-configuration conf)
8091 (let* ((name (format "%s-%d"
8092 (gnus-group-prefixed-name
8093 gnus-newsgroup-name (list 'nndoc ""))
8095 (set-buffer gnus-summary-buffer)
8096 gnus-current-article)))
8097 (ogroup gnus-newsgroup-name)
8098 (params (append (gnus-info-params (gnus-get-info ogroup))
8099 (list (cons 'to-group ogroup))
8100 (list (cons 'save-article-group ogroup))))
8101 (case-fold-search t)
8102 (buf (current-buffer))
8105 (set-buffer gnus-original-article-buffer)
8106 ;; Have the digest group inherit the main mail address of
8107 ;; the parent article.
8108 (when (setq to-address (or (gnus-fetch-field "reply-to")
8109 (gnus-fetch-field "from")))
8110 (setq params (append
8111 (list (cons 'to-address
8112 (funcall gnus-decode-encoded-word-function
8114 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8115 (insert-buffer-substring gnus-original-article-buffer)
8116 ;; Remove lines that may lead nndoc to misinterpret the
8119 (goto-char (point-min))
8120 (or (search-forward "\n\n" nil t) (point)))
8121 (goto-char (point-min))
8122 (delete-matching-lines "^Path:\\|^From ")
8125 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8126 (gnus-newsgroup-ephemeral-ignored-charsets
8127 gnus-newsgroup-ignored-charsets))
8128 (gnus-group-read-ephemeral-group
8129 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8131 ,(if force 'mbox 'guess)))
8133 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8135 ;; Make all postings to this group go to the parent group.
8136 (nconc (gnus-info-params (gnus-get-info name))
8138 ;; Couldn't select this doc group.
8139 (switch-to-buffer buf)
8140 (gnus-set-global-variables)
8141 (gnus-configure-windows 'summary)
8142 (gnus-message 3 "Article couldn't be entered?"))
8143 (kill-buffer dig)))))
8145 (defun gnus-summary-read-document (n)
8146 "Open a new group based on the current article(s).
8147 This will allow you to read digests and other similar
8148 documents as newsgroups.
8149 Obeys the standard process/prefix convention."
8151 (let* ((articles (gnus-summary-work-articles n))
8152 (ogroup gnus-newsgroup-name)
8153 (params (append (gnus-info-params (gnus-get-info ogroup))
8154 (list (cons 'to-group ogroup))))
8155 article group egroup groups vgroup)
8156 (while (setq article (pop articles))
8157 (setq group (format "%s-%d" gnus-newsgroup-name article))
8158 (gnus-summary-remove-process-mark article)
8159 (when (gnus-summary-display-article article)
8162 (insert-buffer-substring gnus-original-article-buffer)
8163 ;; Remove some headers that may lead nndoc to make
8165 (message-narrow-to-head)
8166 (goto-char (point-min))
8167 (delete-matching-lines "^\\(Path\\):\\|^From ")
8170 (gnus-group-read-ephemeral-group
8171 group `(nndoc ,group (nndoc-address ,(current-buffer))
8172 (nndoc-article-type guess))
8175 ;; Make all postings to this group go to the parent group.
8176 (nconc (gnus-info-params (gnus-get-info egroup))
8178 (push egroup groups))
8179 ;; Couldn't select this doc group.
8180 (gnus-error 3 "Article couldn't be entered"))))))
8181 ;; Now we have selected all the documents.
8184 (error "None of the articles could be interpreted as documents"))
8185 ((gnus-group-read-ephemeral-group
8186 (setq vgroup (format
8187 "nnvirtual:%s-%s" gnus-newsgroup-name
8188 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8189 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8191 (cons (current-buffer) 'summary)))
8193 (error "Couldn't select virtual nndoc group")))))
8195 (defun gnus-summary-isearch-article (&optional regexp-p)
8196 "Do incremental search forward on the current article.
8197 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8199 (let* ((gnus-inhibit-treatment t)
8200 (old (gnus-summary-select-article)))
8201 (gnus-configure-windows 'article)
8202 (gnus-eval-in-buffer-window gnus-article-buffer
8206 (gnus-article-show-all-headers))
8207 (goto-char (point-min))
8208 (isearch-forward regexp-p)))))
8210 (defun gnus-summary-search-article-forward (regexp &optional backward)
8211 "Search for an article containing REGEXP forward.
8212 If BACKWARD, search backward instead."
8215 (format "Search article %s (regexp%s): "
8216 (if current-prefix-arg "backward" "forward")
8217 (if gnus-last-search-regexp
8218 (concat ", default " gnus-last-search-regexp)
8220 current-prefix-arg))
8221 (if (string-equal regexp "")
8222 (setq regexp (or gnus-last-search-regexp ""))
8223 (setq gnus-last-search-regexp regexp)
8224 (setq gnus-article-before-search gnus-current-article))
8225 ;; Intentionally set gnus-last-article.
8226 (setq gnus-last-article gnus-article-before-search)
8227 (let ((gnus-last-article gnus-last-article))
8228 (if (gnus-summary-search-article regexp backward)
8229 (gnus-summary-show-thread)
8230 (error "Search failed: \"%s\"" regexp))))
8232 (defun gnus-summary-search-article-backward (regexp)
8233 "Search for an article containing REGEXP backward."
8236 (format "Search article backward (regexp%s): "
8237 (if gnus-last-search-regexp
8238 (concat ", default " gnus-last-search-regexp)
8240 (gnus-summary-search-article-forward regexp 'backward))
8243 (defmacro gnus-summary-search-article-position-point (regexp backward)
8244 "Dehighlight the last matched text and goto the beginning position."
8245 (` (if (and gnus-summary-search-article-matched-data
8246 (let ((text (caddr gnus-summary-search-article-matched-data))
8247 (inhibit-read-only t)
8250 (goto-char (car gnus-summary-search-article-matched-data))
8251 (cadr gnus-summary-search-article-matched-data))
8253 (string-match (, regexp) text)))
8254 (if (, backward) (beginning-of-line) (end-of-line))
8255 (goto-char (if (, backward) (point-max) (point-min))))))
8257 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8258 "Place point where X-Face image is displayed."
8259 (if (featurep 'xemacs)
8260 (` (let ((end (if (search-forward "\n\n" nil t)
8261 (goto-char (1- (point)))
8264 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8265 (unless (and (re-search-forward "^From:" end t)
8266 (setq extent (extent-at (point)))
8267 (extent-begin-glyph extent))
8268 (goto-char (, opoint)))))
8269 (` (let ((end (if (search-forward "\n\n" nil t)
8270 (goto-char (1- (point)))
8272 (start (or (search-backward "\n\n" nil t) (point-min))))
8274 (or (text-property-any start end 'x-face-image t);; x-face-e21
8275 (text-property-any start end 'x-face-mule-bitmap-image t)
8278 (defmacro gnus-summary-search-article-highlight-matched-text
8279 (backward treated x-face)
8280 "Highlight matched text in the function `gnus-summary-search-article'."
8281 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8282 (end (set-marker (make-marker) (match-end 0)))
8283 (inhibit-read-only t)
8287 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8289 (lambda (item) (setq items (delq item items)))
8290 '(gnus-treat-buttonize
8291 gnus-treat-fill-article
8292 gnus-treat-fill-long-lines
8293 gnus-treat-emphasize
8294 gnus-treat-highlight-headers
8295 gnus-treat-highlight-citation
8296 gnus-treat-highlight-signature
8297 gnus-treat-overstrike
8298 gnus-treat-display-xface
8299 gnus-treat-buttonize-head
8300 gnus-treat-decode-article-as-default-mime-charset))
8301 (static-if (featurep 'xemacs)
8303 (cons '(x-face-mule-delete-x-face-field
8306 (gnus-treat-display-xface
8307 (when (, x-face) gnus-treat-display-xface)))
8308 (gnus-article-prepare-mime-display)))
8309 (goto-char (if (, backward) start end))
8311 (gnus-summary-search-article-highlight-goto-x-face (point)))
8312 (setq gnus-summary-search-article-matched-data
8313 (list start end (buffer-substring start end)))
8314 (unless (eq start end);; matched text has been deleted. :-<
8315 (put-text-property start end 'face
8316 (or (find-face 'isearch)
8317 'secondary-selection))))))
8320 (defun gnus-summary-search-article (regexp &optional backward)
8321 "Search for an article containing REGEXP.
8322 Optional argument BACKWARD means do search for backward.
8323 `gnus-select-article-hook' is not called during the search."
8324 ;; We have to require this here to make sure that the following
8325 ;; dynamic binding isn't shadowed by autoloading.
8326 (require 'gnus-async)
8328 (let ((gnus-select-article-hook nil) ;Disable hook.
8329 (gnus-article-prepare-hook nil)
8330 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8331 (gnus-use-article-prefetch nil)
8332 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8333 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8335 (gnus-keep-backlog nil)
8336 (gnus-break-pages nil)
8337 (gnus-summary-display-arrow nil)
8338 (gnus-updated-mode-lines nil)
8339 (gnus-auto-center-summary nil)
8340 (sum (current-buffer))
8343 (gnus-save-hidden-threads
8344 (static-if (featurep 'xemacs)
8345 (let ((gnus-inhibit-treatment t))
8346 (setq treated (eq 'old (gnus-summary-select-article)))
8348 (not (and (gnus-buffer-live-p gnus-article-buffer)
8349 (window-live-p (get-buffer-window
8350 gnus-article-buffer t)))))
8351 (gnus-summary-select-article nil t)
8352 (setq treated nil)))
8353 (let ((gnus-inhibit-treatment t)
8354 (x-face-mule-delete-x-face-field 'never))
8355 (setq treated (eq 'old (gnus-summary-select-article)))
8358 (and (gnus-buffer-live-p gnus-article-buffer)
8359 (window-live-p (get-buffer-window
8360 gnus-article-buffer t))
8361 (or (not (string-match "^\\^X-Face:" regexp))
8362 (with-current-buffer gnus-article-buffer
8363 gnus-summary-search-article-matched-data)))))
8364 (gnus-summary-select-article nil t)
8365 (setq treated nil))))
8366 (set-buffer gnus-article-buffer)
8370 (gnus-article-show-all-headers)
8371 (gnus-summary-search-article-position-point regexp backward))
8372 (goto-char (if backward (point-max) (point-min))))
8374 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8376 (re-search-backward regexp nil t)
8377 (re-search-forward regexp nil t))
8378 ;; We found the regexp.
8380 (gnus-summary-search-article-highlight-matched-text
8381 backward treated (string-match "^\\^X-Face:" regexp))
8384 (/ (- 2 (window-height
8385 (get-buffer-window gnus-article-buffer t)))
8388 (get-buffer-window (current-buffer))
8391 (setq point (point)))
8392 ;; We didn't find it, so we go to the next article.
8395 (while (eq found 'not)
8396 (if (not (if backward (gnus-summary-find-prev)
8397 (gnus-summary-find-next)))
8398 ;; No more articles.
8400 ;; Select the next article and adjust point.
8401 (unless (gnus-summary-article-sparse-p
8402 (gnus-summary-article-number))
8404 (let ((gnus-inhibit-treatment t))
8405 (gnus-summary-select-article))
8407 (set-buffer gnus-article-buffer)
8409 (goto-char (if backward (point-max) (point-min))))))))
8410 (gnus-message 7 ""))
8411 ;; Return whether we found the regexp.
8412 (when (eq found 'found)
8414 (gnus-summary-show-thread)
8415 (gnus-summary-goto-subject gnus-current-article)
8416 (gnus-summary-position-point)
8419 (defun gnus-find-matching-articles (header regexp)
8420 "Return a list of all articles that match REGEXP on HEADER.
8421 This search includes all articles in the current group that Gnus has
8422 fetched headers for, whether they are displayed or not."
8423 (let ((articles nil)
8424 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8425 (case-fold-search t))
8426 (dolist (header gnus-newsgroup-headers)
8427 (when (string-match regexp (funcall func header))
8428 (push (mail-header-number header) articles)))
8429 (nreverse articles)))
8431 (defun gnus-summary-find-matching (header regexp &optional backward unread
8432 not-case-fold not-matching)
8433 "Return a list of all articles that match REGEXP on HEADER.
8434 The search stars on the current article and goes forwards unless
8435 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8436 If UNREAD is non-nil, only unread articles will
8437 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8438 in the comparisons. If NOT-MATCHING, return a list of all articles that
8439 not match REGEXP on HEADER."
8440 (let ((case-fold-search (not not-case-fold))
8443 (if (eq (car header) 'extra)
8446 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8448 (error "%s is an invalid header" header))
8449 (unless (fboundp (intern (concat "mail-header-" header)))
8450 (error "%s is not a valid header" header))
8451 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8452 (dolist (d (if (eq backward 'all)
8454 (gnus-data-find-list
8455 (gnus-summary-article-number)
8456 (gnus-data-list backward))))
8457 (when (and (or (not unread) ; We want all articles...
8458 (gnus-data-unread-p d)) ; Or just unreads.
8459 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8463 (funcall func (gnus-data-header d))))
8464 (string-match regexp
8465 (funcall func (gnus-data-header d)))))
8466 (push (gnus-data-number d) articles))) ; Success!
8467 (nreverse articles)))
8469 (defun gnus-summary-execute-command (header regexp command &optional backward)
8470 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8471 If HEADER is an empty string (or nil), the match is done on the entire
8472 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8474 (list (let ((completion-ignore-case t))
8477 (mapcar (lambda (header) (list (format "%s" header)))
8479 '("Number" "Subject" "From" "Lines" "Date"
8480 "Message-ID" "Xref" "References" "Body")
8481 gnus-extra-headers))
8482 nil 'require-match))
8483 (read-string "Regexp: ")
8484 (read-key-sequence "Command: ")
8485 current-prefix-arg))
8486 (when (equal header "Body")
8488 ;; Hidden thread subtrees must be searched as well.
8489 (gnus-summary-show-all-threads)
8490 ;; We don't want to change current point nor window configuration.
8492 (save-window-excursion
8494 gnus-treat-strip-trailing-blank-lines
8495 gnus-treat-strip-leading-blank-lines
8496 gnus-treat-strip-multiple-blank-lines
8497 gnus-treat-hide-boring-headers
8498 gnus-treat-fold-newsgroups
8499 gnus-article-prepare-hook)
8500 (gnus-message 6 "Executing %s..." (key-description command))
8501 ;; We'd like to execute COMMAND interactively so as to give arguments.
8502 (gnus-execute header regexp
8503 `(call-interactively ',(key-binding command))
8505 (gnus-message 6 "Executing %s...done" (key-description command))))))
8507 (defun gnus-summary-beginning-of-article ()
8508 "Scroll the article back to the beginning."
8510 (gnus-summary-select-article)
8511 (gnus-configure-windows 'article)
8512 (gnus-eval-in-buffer-window gnus-article-buffer
8514 (goto-char (point-min))
8515 (when gnus-page-broken
8516 (gnus-narrow-to-page))))
8518 (defun gnus-summary-end-of-article ()
8519 "Scroll to the end of the article."
8521 (gnus-summary-select-article)
8522 (gnus-configure-windows 'article)
8523 (gnus-eval-in-buffer-window gnus-article-buffer
8525 (goto-char (point-max))
8527 (when gnus-page-broken
8528 (gnus-narrow-to-page))))
8530 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8531 "Truncate to LEN and quote all \"(\"'s in STRING."
8532 (gnus-replace-in-string (if (and len (> (length string) len))
8533 (substring string 0 len)
8537 (defun gnus-summary-print-article (&optional filename n)
8538 "Generate and print a PostScript image of the N next (mail) articles.
8540 If N is negative, print the N previous articles. If N is nil and articles
8541 have been marked with the process mark, print these instead.
8543 If the optional first argument FILENAME is nil, send the image to the
8544 printer. If FILENAME is a string, save the PostScript image in a file with
8545 that name. If FILENAME is a number, prompt the user for the name of the file
8547 (interactive (list (ps-print-preprint current-prefix-arg)))
8548 (dolist (article (gnus-summary-work-articles n))
8549 (gnus-summary-select-article nil nil 'pseudo article)
8550 (gnus-eval-in-buffer-window gnus-article-buffer
8551 (gnus-print-buffer))
8552 (gnus-summary-remove-process-mark article))
8553 (ps-despool filename))
8555 (defun gnus-print-buffer ()
8556 (let ((buffer (generate-new-buffer " *print*")))
8559 (copy-to-buffer buffer (point-min) (point-max))
8561 (gnus-article-delete-invisible-text)
8562 (gnus-remove-text-with-property 'gnus-decoration)
8563 (when (gnus-visual-p 'article-highlight 'highlight)
8564 ;; Copy-to-buffer doesn't copy overlay. So redo
8566 (let ((gnus-article-buffer buffer))
8567 (gnus-article-highlight-citation t)
8568 (gnus-article-highlight-signature)))
8569 (let ((ps-left-header
8572 (gnus-summary-print-truncate-and-quote
8573 (mail-header-subject gnus-current-headers)
8576 (gnus-summary-print-truncate-and-quote
8577 (mail-header-from gnus-current-headers)
8581 "/pagenumberstring load"
8583 (mail-header-date gnus-current-headers) ")"))))
8584 (gnus-run-hooks 'gnus-ps-print-hook)
8587 (ps-spool-buffer-with-faces)
8588 (ps-spool-buffer)))))
8589 (kill-buffer buffer))))
8591 (defun gnus-summary-show-article (&optional arg)
8592 "Force redisplaying of the current article.
8593 If ARG (the prefix) is a number, show the article with the charset
8594 defined in `gnus-summary-show-article-charset-alist', or the charset
8596 If ARG (the prefix) is non-nil and not a number, show the raw article
8597 without any article massaging functions being run. Normally, the key strokes
8602 (gnus-summary-show-article t)
8603 (let* ((gnus-newsgroup-charset
8604 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8605 (mm-read-coding-system
8606 "View as charset: " ;; actually it is coding system.
8608 (set-buffer gnus-article-buffer)
8609 (mm-detect-coding-region (point) (point-max))))))
8610 (default-mime-charset gnus-newsgroup-charset)
8611 (gnus-newsgroup-ignored-charsets 'gnus-all))
8612 (gnus-summary-select-article nil 'force)
8613 (let ((deps gnus-newsgroup-dependencies)
8616 (set-buffer gnus-original-article-buffer)
8618 (message-narrow-to-head)
8619 (setq head (buffer-string))
8620 (goto-char (point-min))
8621 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8622 (goto-char (point-max))
8624 (setq lines (1- (count-lines (point) (point-max))))))
8626 (insert (format "211 %d Article retrieved.\n"
8627 (cdr gnus-article-current)))
8629 (if lines (insert (format "Lines: %d\n" lines)))
8631 (let ((nntp-server-buffer (current-buffer)))
8632 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8633 (gnus-data-set-header
8634 (gnus-data-find (cdr gnus-article-current))
8636 (gnus-summary-update-article-line
8637 (cdr gnus-article-current) header)
8638 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8639 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8641 ;; Select the article the normal way.
8642 (gnus-summary-select-article nil 'force))
8644 ;; We have to require this here to make sure that the following
8645 ;; dynamic binding isn't shadowed by autoloading.
8646 (require 'gnus-async)
8648 ;; Bind the article treatment functions to nil.
8649 (let ((gnus-have-all-headers t)
8650 gnus-article-prepare-hook
8651 gnus-article-decode-hook
8654 (gnus-inhibit-treatment t))
8655 (gnus-summary-select-article nil 'force))))
8656 (gnus-summary-goto-subject gnus-current-article)
8657 (gnus-summary-position-point))
8659 (defun gnus-summary-show-raw-article ()
8660 "Show the raw article without any article massaging functions being run."
8662 (gnus-summary-show-article t))
8664 (defun gnus-summary-verbose-headers (&optional arg)
8665 "Toggle permanent full header display.
8666 If ARG is a positive number, turn header display on.
8667 If ARG is a negative number, turn header display off."
8669 (setq gnus-show-all-headers
8670 (cond ((or (not (numberp arg))
8672 (not gnus-show-all-headers))
8675 (gnus-summary-show-article))
8677 (defun gnus-summary-toggle-header (&optional arg)
8678 "Show the headers if they are hidden, or hide them if they are shown.
8679 If ARG is a positive number, show the entire header.
8680 If ARG is a negative number, hide the unwanted header lines."
8682 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8683 (get-buffer-window gnus-article-buffer t))))
8684 (with-current-buffer gnus-article-buffer
8686 (article-narrow-to-head)
8687 (let* ((buffer-read-only nil)
8688 (inhibit-point-motion-hooks t)
8689 (hidden (if (numberp arg)
8691 (gnus-article-hidden-text-p 'headers)))
8693 (delete-region (point-min) (point-max))
8694 (with-current-buffer gnus-original-article-buffer
8695 (goto-char (setq s (point-min)))
8696 (setq e (if (search-forward "\n\n" nil t)
8699 (insert-buffer-substring gnus-original-article-buffer s e)
8700 (article-decode-encoded-words)
8702 (let ((gnus-treat-hide-headers nil)
8703 (gnus-treat-hide-boring-headers nil))
8704 (gnus-delete-wash-type 'headers)
8705 (gnus-treat-article 'head))
8706 (gnus-treat-article 'head))
8709 (set-window-start window (goto-char (point-min))))
8710 (setq gnus-page-broken
8711 (when gnus-break-pages
8712 (gnus-narrow-to-page)
8714 (gnus-set-mode-line 'article)))))
8716 (defun gnus-summary-show-all-headers ()
8717 "Make all header lines visible."
8719 (gnus-summary-toggle-header 1))
8721 (defun gnus-summary-toggle-mime (&optional arg)
8722 "Toggle MIME processing.
8723 If ARG is a positive number, turn MIME processing on."
8725 (setq gnus-show-mime
8727 (not gnus-show-mime)
8728 (> (prefix-numeric-value arg) 0)))
8729 (gnus-summary-select-article t 'force))
8731 (defun gnus-summary-caesar-message (&optional arg)
8732 "Caesar rotate the current article by 13.
8733 The numerical prefix specifies how many places to rotate each letter
8736 (gnus-summary-select-article)
8737 (let ((mail-header-separator ""))
8738 (gnus-eval-in-buffer-window gnus-article-buffer
8741 (let ((start (window-start))
8743 (message-caesar-buffer-body arg)
8744 (set-window-start (get-buffer-window (current-buffer)) start))))))
8746 (autoload 'unmorse-region "morse"
8747 "Convert morse coded text in region to ordinary ASCII text."
8750 (defun gnus-summary-morse-message (&optional arg)
8751 "Morse decode the current article."
8753 (gnus-summary-select-article)
8754 (let ((mail-header-separator ""))
8755 (gnus-eval-in-buffer-window gnus-article-buffer
8759 (let ((pos (window-start))
8761 (goto-char (point-min))
8762 (when (message-goto-body)
8763 (gnus-narrow-to-body))
8764 (goto-char (point-min))
8765 (while (re-search-forward "·" (point-max) t)
8766 (replace-match "."))
8767 (unmorse-region (point-min) (point-max))
8769 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8771 (defun gnus-summary-stop-page-breaking ()
8772 "Stop page breaking in the current article."
8774 (gnus-summary-select-article)
8775 (gnus-eval-in-buffer-window gnus-article-buffer
8777 (when (gnus-visual-p 'page-marker)
8778 (let ((buffer-read-only nil))
8779 (gnus-remove-text-with-property 'gnus-prev)
8780 (gnus-remove-text-with-property 'gnus-next))
8781 (setq gnus-page-broken nil))))
8783 (defun gnus-summary-move-article (&optional n to-newsgroup
8784 select-method action)
8785 "Move the current article to a different newsgroup.
8786 If N is a positive number, move the N next articles.
8787 If N is a negative number, move the N previous articles.
8788 If N is nil and any articles have been marked with the process mark,
8789 move those articles instead.
8790 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8791 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8792 re-spool using this method.
8794 When called interactively with TO-NEWSGROUP being nil, the value of
8795 the variable `gnus-move-split-methods' is used for finding a default
8796 for the target newsgroup.
8798 For this function to work, both the current newsgroup and the
8799 newsgroup that you want to move to have to support the `request-move'
8800 and `request-accept' functions.
8802 ACTION can be either `move' (the default), `crosspost' or `copy'."
8805 (setq action 'move))
8806 ;; Check whether the source group supports the required functions.
8807 (cond ((and (eq action 'move)
8808 (not (gnus-check-backend-function
8809 'request-move-article gnus-newsgroup-name)))
8810 (error "The current group does not support article moving"))
8811 ((and (eq action 'crosspost)
8812 (not (gnus-check-backend-function
8813 'request-replace-article gnus-newsgroup-name)))
8814 (error "The current group does not support article editing")))
8815 (let ((articles (gnus-summary-work-articles n))
8816 (prefix (if (gnus-check-backend-function
8817 'request-move-article gnus-newsgroup-name)
8818 (gnus-group-real-prefix gnus-newsgroup-name)
8820 (names '((move "Move" "Moving")
8821 (copy "Copy" "Copying")
8822 (crosspost "Crosspost" "Crossposting")))
8823 (copy-buf (save-excursion
8824 (nnheader-set-temp-buffer " *copy article*")))
8825 (default-marks gnus-article-mark-lists)
8826 (no-expire-marks (delete '(expirable . expire)
8827 (copy-sequence gnus-article-mark-lists)))
8828 art-group to-method new-xref article to-groups)
8829 (unless (assq action names)
8830 (error "Unknown action %s" action))
8831 ;; Read the newsgroup name.
8832 (when (and (not to-newsgroup)
8833 (not select-method))
8834 (if (and gnus-move-split-methods
8836 (and (memq gnus-current-article articles)
8837 (gnus-buffer-live-p gnus-original-article-buffer))))
8838 ;; When `gnus-move-split-methods' is non-nil, we have to
8839 ;; select an article to give `gnus-read-move-group-name' an
8840 ;; opportunity to suggest an appropriate default. However,
8841 ;; we needn't render or mark the article.
8842 (let ((gnus-display-mime-function nil)
8843 (gnus-article-prepare-hook nil)
8844 (gnus-mark-article-hook nil))
8845 (gnus-summary-select-article nil nil nil (car articles))))
8847 (gnus-read-move-group-name
8848 (cadr (assq action names))
8849 (symbol-value (intern (format "gnus-current-%s-group" action)))
8851 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8852 (setq to-method (or select-method
8853 (gnus-server-to-method
8854 (gnus-group-method to-newsgroup))))
8855 ;; Check the method we are to move this article to...
8856 (unless (gnus-check-backend-function
8857 'request-accept-article (car to-method))
8858 (error "%s does not support article copying" (car to-method)))
8859 (unless (gnus-check-server to-method)
8860 (error "Can't open server %s" (car to-method)))
8861 (gnus-message 6 "%s to %s: %s..."
8862 (caddr (assq action names))
8863 (or (car select-method) to-newsgroup) articles)
8865 (setq article (pop articles))
8869 ;; Move the article.
8871 ;; Remove this article from future suppression.
8872 (gnus-dup-unsuppress-article article)
8873 (gnus-request-move-article
8874 article ; Article to move
8875 gnus-newsgroup-name ; From newsgroup
8876 (nth 1 (gnus-find-method-for-group
8877 gnus-newsgroup-name)) ; Server
8878 (list 'gnus-request-accept-article
8879 to-newsgroup (list 'quote select-method)
8880 (not articles) t) ; Accept form
8881 (not articles))) ; Only save nov last time
8882 ;; Copy the article.
8885 (set-buffer copy-buf)
8886 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8887 (gnus-request-accept-article
8888 to-newsgroup select-method (not articles) t))))
8889 ;; Crosspost the article.
8890 ((eq action 'crosspost)
8891 (let ((xref (message-tokenize-header
8892 (mail-header-xref (gnus-summary-article-header article))
8894 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8895 ":" (number-to-string article)))
8897 (setq xref (list (system-name))))
8900 (mapconcat 'identity
8901 (delete "Xref:" (delete new-xref xref))
8905 (set-buffer copy-buf)
8906 ;; First put the article in the destination group.
8907 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8908 (when (consp (setq art-group
8909 (gnus-request-accept-article
8910 to-newsgroup select-method (not articles))))
8911 (setq new-xref (concat new-xref " " (car art-group)
8913 (number-to-string (cdr art-group))))
8914 ;; Now we have the new Xrefs header, so we insert
8915 ;; it and replace the new article.
8916 (nnheader-replace-header "Xref" new-xref)
8917 (gnus-request-replace-article
8918 (cdr art-group) to-newsgroup (current-buffer))
8922 (gnus-message 1 "Couldn't %s article %s: %s"
8923 (cadr (assq action names)) article
8924 (nnheader-get-report (car to-method))))
8925 ((eq art-group 'junk)
8926 (when (eq action 'move)
8927 (let ((id (mail-header-id (gnus-data-header
8928 (assoc article (gnus-data-list nil))))))
8929 (gnus-summary-mark-article article gnus-canceled-mark)
8930 (gnus-message 4 "Deleted article %s" article)
8931 ;; run the move/copy/crosspost/respool hook
8932 (run-hook-with-args 'gnus-summary-article-delete-hook
8933 action id gnus-newsgroup-name nil
8936 (let* ((pto-group (gnus-group-prefixed-name
8937 (car art-group) to-method))
8939 (gnus-gethash pto-group gnus-newsrc-hashtb))
8940 (info (nth 2 entry))
8941 (to-group (gnus-info-group info))
8943 ;; Update the group that has been moved to.
8945 (memq action '(move copy)))
8946 (unless (member to-group to-groups)
8947 (push to-group to-groups))
8949 (unless (memq article gnus-newsgroup-unreads)
8950 (push 'read to-marks)
8952 info (gnus-add-to-range (gnus-info-read info)
8953 (list (cdr art-group)))))
8955 ;; See whether the article is to be put in the cache.
8956 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8959 (to-article (cdr art-group)))
8961 ;; Enter the article into the cache in the new group,
8962 ;; if that is required.
8963 (when gnus-use-cache
8964 (gnus-cache-possibly-enter-article
8966 (let ((header (copy-sequence
8967 (gnus-summary-article-header article))))
8968 (mail-header-set-number header to-article)
8970 (memq article gnus-newsgroup-marked)
8971 (memq article gnus-newsgroup-dormant)
8972 (memq article gnus-newsgroup-unreads)))
8974 (when gnus-preserve-marks
8975 ;; Copy any marks over to the new group.
8976 (when (and (equal to-group gnus-newsgroup-name)
8977 (not (memq article gnus-newsgroup-unreads)))
8978 ;; Mark this article as read in this group.
8979 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8980 (setcdr (gnus-active to-group) to-article)
8981 (setcdr gnus-newsgroup-active to-article))
8984 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8985 (when (memq article (symbol-value
8986 (intern (format "gnus-newsgroup-%s"
8988 (push (cdar marks) to-marks)
8989 ;; If the other group is the same as this group,
8990 ;; then we have to add the mark to the list.
8991 (when (equal to-group gnus-newsgroup-name)
8992 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8995 (intern (format "gnus-newsgroup-%s"
8997 ;; Copy the marks to other group.
8998 (gnus-add-marked-articles
8999 to-group (cdar marks) (list to-article) info)))
9000 (setq marks (cdr marks)))
9002 (gnus-request-set-mark
9003 to-group (list (list (list to-article) 'add to-marks))))
9006 (concat "(gnus-group-set-info '"
9007 (gnus-prin1-to-string (gnus-get-info to-group))
9010 ;; Update the Xref header in this article to point to
9011 ;; the new crossposted article we have just created.
9012 (when (eq action 'crosspost)
9014 (set-buffer copy-buf)
9015 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9016 (nnheader-replace-header "Xref" new-xref)
9017 (gnus-request-replace-article
9018 article gnus-newsgroup-name (current-buffer))))
9020 ;; run the move/copy/crosspost/respool hook
9021 (let ((id (mail-header-id (gnus-data-header
9022 (assoc article (gnus-data-list nil))))))
9023 (run-hook-with-args 'gnus-summary-article-move-hook
9024 action id gnus-newsgroup-name to-newsgroup
9027 ;;;!!!Why is this necessary?
9028 (set-buffer gnus-summary-buffer)
9030 (gnus-summary-goto-subject article)
9031 (when (eq action 'move)
9032 (gnus-summary-mark-article article gnus-canceled-mark))))
9033 (gnus-summary-remove-process-mark article))
9034 ;; Re-activate all groups that have been moved to.
9036 (set-buffer gnus-group-buffer)
9037 (let ((gnus-group-marked to-groups))
9038 (gnus-group-get-new-news-this-group nil t)))
9040 (gnus-kill-buffer copy-buf)
9041 (gnus-summary-position-point)
9042 (gnus-set-mode-line 'summary)))
9044 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9045 "Move the current article to a different newsgroup.
9046 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9047 When called interactively, if TO-NEWSGROUP is nil, use the value of
9048 the variable `gnus-move-split-methods' for finding a default target
9050 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9051 re-spool using this method."
9053 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9055 (defun gnus-summary-crosspost-article (&optional n)
9056 "Crosspost the current article to some other group."
9058 (gnus-summary-move-article n nil nil 'crosspost))
9060 (defcustom gnus-summary-respool-default-method nil
9061 "Default method type for respooling an article.
9062 If nil, use to the current newsgroup method."
9064 :group 'gnus-summary-mail)
9066 (defcustom gnus-summary-display-while-building nil
9067 "If not-nil, show and update the summary buffer as it's being built.
9068 If the value is t, update the buffer after every line is inserted. If
9069 the value is an integer (N), update the display every N lines."
9071 :type '(choice (const :tag "off" nil)
9073 (const :tag "frequently" t)))
9075 (defun gnus-summary-respool-article (&optional n method)
9076 "Respool the current article.
9077 The article will be squeezed through the mail spooling process again,
9078 which means that it will be put in some mail newsgroup or other
9079 depending on `nnmail-split-methods'.
9080 If N is a positive number, respool the N next articles.
9081 If N is a negative number, respool the N previous articles.
9082 If N is nil and any articles have been marked with the process mark,
9083 respool those articles instead.
9085 Respooling can be done both from mail groups and \"real\" newsgroups.
9086 In the former case, the articles in question will be moved from the
9087 current group into whatever groups they are destined to. In the
9088 latter case, they will be copied into the relevant groups."
9090 (list current-prefix-arg
9091 (let* ((methods (gnus-methods-using 'respool))
9093 (symbol-name (or gnus-summary-respool-default-method
9094 (car (gnus-find-method-for-group
9095 gnus-newsgroup-name)))))
9097 (gnus-completing-read-with-default
9098 methname "What backend do you want to use when respooling?"
9099 methods nil t nil 'gnus-mail-method-history))
9102 ((zerop (length (setq ms (gnus-servers-using-backend
9104 (list (intern method) ""))
9108 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9109 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9112 (error "No method given for respooling"))
9113 (if (assoc (symbol-name
9114 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9115 (gnus-methods-using 'respool))
9116 (gnus-summary-move-article n nil method)
9117 (gnus-summary-copy-article n nil method)))
9119 (defun gnus-summary-import-article (file &optional edit)
9120 "Import an arbitrary file into a mail newsgroup."
9121 (interactive "fImport file: \nP")
9122 (let ((group gnus-newsgroup-name)
9123 (now (current-time))
9124 atts lines group-art)
9125 (unless (gnus-check-backend-function 'request-accept-article group)
9126 (error "%s does not support article importing" group))
9127 (or (file-readable-p file)
9128 (not (file-regular-p file))
9129 (error "Can't read %s" file))
9131 (set-buffer (gnus-get-buffer-create " *import file*"))
9133 (nnheader-insert-file-contents file)
9134 (goto-char (point-min))
9135 (if (nnheader-article-p)
9137 (goto-char (point-min))
9138 (search-forward "\n\n" nil t)
9139 (narrow-to-region (point-min) (1- (point)))
9140 (goto-char (point-min))
9141 (unless (re-search-forward "^date:" nil t)
9142 (goto-char (point-max))
9143 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9144 ;; This doesn't look like an article, so we fudge some headers.
9145 (setq atts (file-attributes file)
9146 lines (count-lines (point-min) (point-max)))
9147 (insert "From: " (read-string "From: ") "\n"
9148 "Subject: " (read-string "Subject: ") "\n"
9149 "Date: " (message-make-date (nth 5 atts)) "\n"
9150 "Message-ID: " (message-make-message-id) "\n"
9151 "Lines: " (int-to-string lines) "\n"
9152 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9153 (setq group-art (gnus-request-accept-article group nil t))
9154 (kill-buffer (current-buffer)))
9155 (setq gnus-newsgroup-active (gnus-activate-group group))
9157 (gnus-summary-goto-article (cdr group-art) nil t)
9159 (gnus-summary-edit-article))))
9161 (defun gnus-summary-create-article ()
9162 "Create an article in a mail newsgroup."
9164 (let ((group gnus-newsgroup-name)
9165 (now (current-time))
9167 (unless (gnus-check-backend-function 'request-accept-article group)
9168 (error "%s does not support article importing" group))
9170 (set-buffer (gnus-get-buffer-create " *import file*"))
9172 (goto-char (point-min))
9173 ;; This doesn't look like an article, so we fudge some headers.
9174 (insert "From: " (read-string "From: ") "\n"
9175 "Subject: " (read-string "Subject: ") "\n"
9176 "Date: " (message-make-date now) "\n"
9177 "Message-ID: " (message-make-message-id) "\n")
9178 (setq group-art (gnus-request-accept-article group nil t))
9179 (kill-buffer (current-buffer)))
9180 (setq gnus-newsgroup-active (gnus-activate-group group))
9182 (gnus-summary-goto-article (cdr group-art) nil t)
9183 (gnus-summary-edit-article)))
9185 (defun gnus-summary-article-posted-p ()
9186 "Say whether the current (mail) article is available from news as well.
9187 This will be the case if the article has both been mailed and posted."
9189 (let ((id (mail-header-references (gnus-summary-article-header)))
9190 (gnus-override-method (car (gnus-refer-article-methods))))
9191 (if (gnus-request-head id "")
9192 (gnus-message 2 "The current message was found on %s"
9193 gnus-override-method)
9194 (gnus-message 2 "The current message couldn't be found on %s"
9195 gnus-override-method)
9198 (defun gnus-summary-expire-articles (&optional now)
9199 "Expire all articles that are marked as expirable in the current group."
9201 (when (gnus-check-backend-function
9202 'request-expire-articles gnus-newsgroup-name)
9203 ;; This backend supports expiry.
9204 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9205 (expirable (if total
9207 ;; We need to update the info for
9208 ;; this group for `gnus-list-of-read-articles'
9209 ;; to give us the right answer.
9210 (gnus-run-hooks 'gnus-exit-group-hook)
9211 (gnus-summary-update-info)
9212 (gnus-list-of-read-articles gnus-newsgroup-name))
9213 (setq gnus-newsgroup-expirable
9214 (sort gnus-newsgroup-expirable '<))))
9215 (expiry-wait (if now 'immediate
9216 (gnus-group-find-parameter
9217 gnus-newsgroup-name 'expiry-wait)))
9218 (nnmail-expiry-target
9219 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9220 nnmail-expiry-target))
9223 ;; There are expirable articles in this group, so we run them
9224 ;; through the expiry process.
9225 (gnus-message 6 "Expiring articles...")
9226 (unless (gnus-check-group gnus-newsgroup-name)
9227 (error "Can't open server for %s" gnus-newsgroup-name))
9228 ;; The list of articles that weren't expired is returned.
9231 (let ((nnmail-expiry-wait-function nil)
9232 (nnmail-expiry-wait expiry-wait))
9233 (setq es (gnus-request-expire-articles
9234 expirable gnus-newsgroup-name)))
9235 (setq es (gnus-request-expire-articles
9236 expirable gnus-newsgroup-name)))
9238 (setq gnus-newsgroup-expirable es))
9239 ;; We go through the old list of expirable, and mark all
9240 ;; really expired articles as nonexistent.
9241 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9242 (let ((gnus-use-cache nil))
9243 (dolist (article expirable)
9244 (when (and (not (memq article es))
9245 (gnus-data-find article))
9246 (gnus-summary-mark-article article gnus-canceled-mark)
9247 (let ((id (mail-header-id (gnus-data-header
9249 (gnus-data-list nil))))))
9250 (run-hook-with-args 'gnus-summary-article-expire-hook
9251 'delete id gnus-newsgroup-name nil
9253 (gnus-message 6 "Expiring articles...done")))))
9255 (defun gnus-summary-expire-articles-now ()
9256 "Expunge all expirable articles in the current group.
9257 This means that *all* articles that are marked as expirable will be
9258 deleted forever, right now."
9260 (or gnus-expert-user
9262 "Are you really, really, really sure you want to delete all these messages? ")
9264 (gnus-summary-expire-articles t))
9266 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9267 (defun gnus-summary-delete-article (&optional n)
9268 "Delete the N next (mail) articles.
9269 This command actually deletes articles. This is not a marking
9270 command. The article will disappear forever from your life, never to
9272 If N is negative, delete backwards.
9273 If N is nil and articles have been marked with the process mark,
9274 delete these instead."
9276 (unless (gnus-check-backend-function 'request-expire-articles
9277 gnus-newsgroup-name)
9278 (error "The current newsgroup does not support article deletion"))
9279 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9280 (error "Couldn't open server"))
9281 ;; Compute the list of articles to delete.
9282 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9283 (nnmail-expiry-target 'delete)
9285 (if (and gnus-novice-user
9286 (not (gnus-yes-or-no-p
9287 (format "Do you really want to delete %s forever? "
9288 (if (> (length articles) 1)
9289 (format "these %s articles" (length articles))
9292 ;; Delete the articles.
9293 (setq not-deleted (gnus-request-expire-articles
9294 articles gnus-newsgroup-name 'force))
9296 (gnus-summary-remove-process-mark (car articles))
9297 ;; The backend might not have been able to delete the article
9299 (unless (memq (car articles) not-deleted)
9300 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9301 (let* ((article (car articles))
9302 (id (mail-header-id (gnus-data-header
9303 (assoc article (gnus-data-list nil))))))
9304 (run-hook-with-args 'gnus-summary-article-delete-hook
9305 'delete id gnus-newsgroup-name nil
9307 (setq articles (cdr articles)))
9309 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9310 (gnus-summary-position-point)
9311 (gnus-set-mode-line 'summary)
9314 (defun gnus-summary-edit-article (&optional force)
9315 "Edit the current article.
9316 This will have permanent effect only in mail groups.
9317 If FORCE is non-nil, allow editing of articles even in read-only
9321 (set-buffer gnus-summary-buffer)
9322 (let ((mail-parse-charset gnus-newsgroup-charset)
9323 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9324 (gnus-set-global-variables)
9325 (when (and (not force)
9326 (gnus-group-read-only-p))
9327 (error "The current newsgroup does not support article editing"))
9328 (gnus-summary-show-article t)
9329 (gnus-article-edit-article
9331 `(lambda (no-highlight)
9332 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9333 (message-options message-options)
9334 (message-options-set-recipient)
9335 (mail-parse-ignored-charsets
9336 ',gnus-newsgroup-ignored-charsets))
9337 (gnus-summary-edit-article-done
9338 ,(or (mail-header-references gnus-current-headers) "")
9339 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9341 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9343 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9345 "Make edits to the current article permanent."
9348 ;; The buffer restriction contains the entire article if it exists.
9349 (when (article-goto-body)
9350 (let ((lines (count-lines (point) (point-max)))
9351 (length (- (point-max) (point)))
9352 (case-fold-search t)
9353 (body (copy-marker (point))))
9354 (goto-char (point-min))
9355 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9356 (delete-region (match-beginning 1) (match-end 1))
9357 (insert (number-to-string length)))
9358 (goto-char (point-min))
9359 (when (re-search-forward
9360 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9361 (delete-region (match-beginning 1) (match-end 1))
9362 (insert (number-to-string length)))
9363 (goto-char (point-min))
9364 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9365 (delete-region (match-beginning 1) (match-end 1))
9366 (insert (number-to-string lines))))))
9367 ;; Replace the article.
9368 (let ((buf (current-buffer)))
9370 (insert-buffer-substring buf)
9372 (if (and (not read-only)
9373 (not (gnus-request-replace-article
9374 (cdr gnus-article-current) (car gnus-article-current)
9375 (current-buffer) t)))
9376 (error "Couldn't replace article")
9377 ;; Update the summary buffer.
9379 (equal (message-tokenize-header references " ")
9380 (message-tokenize-header
9381 (or (message-fetch-field "references") "") " ")))
9382 ;; We only have to update this line.
9385 (message-narrow-to-head)
9386 (let ((head (buffer-string))
9389 (insert (format "211 %d Article retrieved.\n"
9390 (cdr gnus-article-current)))
9393 (let ((nntp-server-buffer (current-buffer)))
9394 (setq header (car (gnus-get-newsgroup-headers
9397 (set-buffer gnus-summary-buffer)
9398 (gnus-data-set-header
9399 (gnus-data-find (cdr gnus-article-current))
9401 (gnus-summary-update-article-line
9402 (cdr gnus-article-current) header)
9403 (if (gnus-summary-goto-subject
9404 (cdr gnus-article-current) nil t)
9405 (gnus-summary-update-secondary-mark
9406 (cdr gnus-article-current))))))))
9408 (set-buffer (or buffer gnus-summary-buffer))
9409 (gnus-summary-update-article (cdr gnus-article-current))
9410 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9411 (gnus-summary-update-secondary-mark
9412 (cdr gnus-article-current))))
9413 ;; Prettify the article buffer again.
9414 (unless no-highlight
9416 (set-buffer gnus-article-buffer)
9417 ;;;!!! Fix this -- article should be rehighlighted.
9418 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9419 (set-buffer gnus-original-article-buffer)
9420 (gnus-request-article
9421 (cdr gnus-article-current)
9422 (car gnus-article-current) (current-buffer))))
9423 ;; Prettify the summary buffer line.
9424 (when (gnus-visual-p 'summary-highlight 'highlight)
9425 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9427 (defun gnus-summary-edit-wash (key)
9428 "Perform editing command KEY in the article buffer."
9432 (message "%s" (concat (this-command-keys) "- "))
9435 (gnus-summary-edit-article)
9436 (execute-kbd-macro (concat (this-command-keys) key))
9437 (gnus-article-edit-done))
9441 (defun gnus-summary-respool-query (&optional silent trace)
9442 "Query where the respool algorithm would put this article."
9444 (let (gnus-mark-article-hook)
9445 (gnus-summary-select-article)
9447 (set-buffer gnus-original-article-buffer)
9449 (message-narrow-to-head)
9450 (let ((groups (nnmail-article-group 'identity trace)))
9453 (message "This message would go to %s"
9454 (mapconcat 'car groups ", "))
9455 (message "This message would go to no groups"))
9458 (defun gnus-summary-respool-trace ()
9459 "Trace where the respool algorithm would put this article.
9460 Display a buffer showing all fancy splitting patterns which matched."
9462 (gnus-summary-respool-query nil t))
9464 ;; Summary marking commands.
9466 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9467 "Mark articles which has the same subject as read, and then select the next.
9468 If UNMARK is positive, remove any kind of mark.
9469 If UNMARK is negative, tick articles."
9472 (setq unmark (prefix-numeric-value unmark)))
9474 (gnus-summary-mark-same-subject
9475 (gnus-summary-article-subject) unmark)))
9476 ;; Select next unread article. If auto-select-same mode, should
9477 ;; select the first unread article.
9478 (gnus-summary-next-article t (and gnus-auto-select-same
9479 (gnus-summary-article-subject)))
9480 (gnus-message 7 "%d article%s marked as %s"
9481 count (if (= count 1) " is" "s are")
9482 (if unmark "unread" "read"))))
9484 (defun gnus-summary-kill-same-subject (&optional unmark)
9485 "Mark articles which has the same subject as read.
9486 If UNMARK is positive, remove any kind of mark.
9487 If UNMARK is negative, tick articles."
9490 (setq unmark (prefix-numeric-value unmark)))
9492 (gnus-summary-mark-same-subject
9493 (gnus-summary-article-subject) unmark)))
9494 ;; If marked as read, go to next unread subject.
9496 ;; Go to next unread subject.
9497 (gnus-summary-next-subject 1 t))
9498 (gnus-message 7 "%d articles are marked as %s"
9499 count (if unmark "unread" "read"))))
9501 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9502 "Mark articles with same SUBJECT as read, and return marked number.
9503 If optional argument UNMARK is positive, remove any kinds of marks.
9504 If optional argument UNMARK is negative, mark articles as unread instead."
9508 ((null unmark) ; Mark as read.
9511 (gnus-summary-mark-article-as-read gnus-killed-mark)
9512 (gnus-summary-show-thread) t)
9513 (gnus-summary-find-subject subject))
9514 (setq count (1+ count))))
9515 ((> unmark 0) ; Tick.
9518 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9519 (gnus-summary-show-thread) t)
9520 (gnus-summary-find-subject subject))
9521 (setq count (1+ count))))
9522 (t ; Mark as unread.
9525 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9526 (gnus-summary-show-thread) t)
9527 (gnus-summary-find-subject subject))
9528 (setq count (1+ count)))))
9529 (gnus-set-mode-line 'summary)
9530 ;; Return the number of marked articles.
9533 (defun gnus-summary-mark-as-processable (n &optional unmark)
9534 "Set the process mark on the next N articles.
9535 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9536 the process mark instead. The difference between N and the actual
9537 number of articles marked is returned."
9539 (if (and (null n) (gnus-region-active-p))
9540 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9541 (setq n (prefix-numeric-value n))
9542 (let ((backward (< n 0))
9547 (gnus-summary-remove-process-mark
9548 (gnus-summary-article-number))
9549 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9550 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9553 (gnus-message 7 "No more articles"))
9554 (gnus-summary-recenter)
9555 (gnus-summary-position-point)
9558 (defun gnus-summary-unmark-as-processable (n)
9559 "Remove the process mark from the next N articles.
9560 If N is negative, unmark backward instead. The difference between N and
9561 the actual number of articles unmarked is returned."
9563 (gnus-summary-mark-as-processable n t))
9565 (defun gnus-summary-unmark-all-processable ()
9566 "Remove the process mark from all articles."
9569 (while gnus-newsgroup-processable
9570 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9571 (gnus-summary-position-point))
9573 (defun gnus-summary-add-mark (article type)
9574 "Mark ARTICLE with a mark of TYPE."
9575 (let ((vtype (car (assq type gnus-article-mark-lists)))
9578 (error "No such mark type: %s" type)
9579 (setq var (intern (format "gnus-newsgroup-%s" type)))
9580 (set var (cons article (symbol-value var)))
9581 (if (memq type '(processable cached replied forwarded recent saved))
9582 (gnus-summary-update-secondary-mark article)
9583 ;;; !!! This is bogus. We should find out what primary
9584 ;;; !!! mark we want to set.
9585 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9587 (defun gnus-summary-mark-as-expirable (n)
9588 "Mark N articles forward as expirable.
9589 If N is negative, mark backward instead. The difference between N and
9590 the actual number of articles marked is returned."
9592 (gnus-summary-mark-forward n gnus-expirable-mark))
9594 (defun gnus-summary-mark-as-spam (n)
9595 "Mark N articles forward as spam.
9596 If N is negative, mark backward instead. The difference between N and
9597 the actual number of articles marked is returned."
9599 (gnus-summary-mark-forward n gnus-spam-mark))
9601 (defun gnus-summary-mark-article-as-replied (article)
9602 "Mark ARTICLE as replied to and update the summary line.
9603 ARTICLE can also be a list of articles."
9604 (interactive (list (gnus-summary-article-number)))
9605 (let ((articles (if (listp article) article (list article))))
9606 (dolist (article articles)
9607 (unless (numberp article)
9608 (error "%s is not a number" article))
9609 (push article gnus-newsgroup-replied)
9610 (let ((buffer-read-only nil))
9611 (when (gnus-summary-goto-subject article nil t)
9612 (gnus-summary-update-secondary-mark article))))))
9614 (defun gnus-summary-mark-article-as-forwarded (article)
9615 "Mark ARTICLE as forwarded and update the summary line.
9616 ARTICLE can also be a list of articles."
9617 (let ((articles (if (listp article) article (list article))))
9618 (dolist (article articles)
9619 (push article gnus-newsgroup-forwarded)
9620 (let ((buffer-read-only nil))
9621 (when (gnus-summary-goto-subject article nil t)
9622 (gnus-summary-update-secondary-mark article))))))
9624 (defun gnus-summary-set-bookmark (article)
9625 "Set a bookmark in current article."
9626 (interactive (list (gnus-summary-article-number)))
9627 (when (or (not (get-buffer gnus-article-buffer))
9628 (not gnus-current-article)
9629 (not gnus-article-current)
9630 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9631 (error "No current article selected"))
9632 ;; Remove old bookmark, if one exists.
9633 (gnus-pull article gnus-newsgroup-bookmarks)
9634 ;; Set the new bookmark, which is on the form
9635 ;; (article-number . line-number-in-body).
9639 (set-buffer gnus-article-buffer)
9646 gnus-newsgroup-bookmarks)
9647 (gnus-message 6 "A bookmark has been added to the current article."))
9649 (defun gnus-summary-remove-bookmark (article)
9650 "Remove the bookmark from the current article."
9651 (interactive (list (gnus-summary-article-number)))
9652 ;; Remove old bookmark, if one exists.
9653 (if (not (assq article gnus-newsgroup-bookmarks))
9654 (gnus-message 6 "No bookmark in current article.")
9655 (gnus-pull article gnus-newsgroup-bookmarks)
9656 (gnus-message 6 "Removed bookmark.")))
9658 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9659 (defun gnus-summary-mark-as-dormant (n)
9660 "Mark N articles forward as dormant.
9661 If N is negative, mark backward instead. The difference between N and
9662 the actual number of articles marked is returned."
9664 (gnus-summary-mark-forward n gnus-dormant-mark))
9666 (defun gnus-summary-set-process-mark (article)
9667 "Set the process mark on ARTICLE and update the summary line."
9668 (setq gnus-newsgroup-processable
9670 (delq article gnus-newsgroup-processable)))
9671 (when (gnus-summary-goto-subject article)
9672 (gnus-summary-show-thread)
9673 (gnus-summary-goto-subject article)
9674 (gnus-summary-update-secondary-mark article)))
9676 (defun gnus-summary-remove-process-mark (article)
9677 "Remove the process mark from ARTICLE and update the summary line."
9678 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9679 (when (gnus-summary-goto-subject article)
9680 (gnus-summary-show-thread)
9681 (gnus-summary-goto-subject article)
9682 (gnus-summary-update-secondary-mark article)))
9684 (defun gnus-summary-set-saved-mark (article)
9685 "Set the process mark on ARTICLE and update the summary line."
9686 (push article gnus-newsgroup-saved)
9687 (when (gnus-summary-goto-subject article)
9688 (gnus-summary-update-secondary-mark article)))
9690 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9691 "Mark N articles as read forwards.
9692 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9693 The difference between N and the actual number of articles marked is
9695 If NO-EXPIRE, auto-expiry will be inhibited."
9697 (gnus-summary-show-thread)
9698 (let ((backward (< n 0))
9699 (gnus-summary-goto-unread
9700 (and gnus-summary-goto-unread
9701 (not (eq gnus-summary-goto-unread 'never))
9702 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9703 gnus-ticked-mark gnus-dormant-mark)))))
9705 (mark (or mark gnus-del-mark)))
9707 (gnus-summary-mark-article nil mark no-expire)
9708 (zerop (gnus-summary-next-subject
9710 (and gnus-summary-goto-unread
9711 (not (eq gnus-summary-goto-unread 'never)))
9715 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9716 (gnus-summary-recenter)
9717 (gnus-summary-position-point)
9718 (gnus-set-mode-line 'summary)
9721 (defun gnus-summary-mark-article-as-read (mark)
9722 "Mark the current article quickly as read with MARK."
9723 (let ((article (gnus-summary-article-number)))
9724 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9725 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9726 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9727 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9728 (push (cons article mark) gnus-newsgroup-reads)
9729 ;; Possibly remove from cache, if that is used.
9730 (when gnus-use-cache
9731 (gnus-cache-enter-remove-article article))
9732 ;; Allow the backend to change the mark.
9733 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9734 ;; Check for auto-expiry.
9735 (when (and gnus-newsgroup-auto-expire
9736 (memq mark gnus-auto-expirable-marks))
9737 (setq mark gnus-expirable-mark)
9738 ;; Let the backend know about the mark change.
9739 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9740 (push article gnus-newsgroup-expirable))
9741 ;; Set the mark in the buffer.
9742 (gnus-summary-update-mark mark 'unread)
9745 (defun gnus-summary-mark-article-as-unread (mark)
9746 "Mark the current article quickly as unread with MARK."
9747 (let* ((article (gnus-summary-article-number))
9748 (old-mark (gnus-summary-article-mark article)))
9749 ;; Allow the backend to change the mark.
9750 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9751 (if (eq mark old-mark)
9755 (gnus-error 1 "Can't mark negative article numbers")
9757 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9758 (setq gnus-newsgroup-spam-marked
9759 (delq article gnus-newsgroup-spam-marked))
9760 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9761 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9762 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9763 (cond ((= mark gnus-ticked-mark)
9764 (setq gnus-newsgroup-marked
9765 (gnus-add-to-sorted-list gnus-newsgroup-marked
9767 ((= mark gnus-spam-mark)
9768 (setq gnus-newsgroup-spam-marked
9769 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9771 ((= mark gnus-dormant-mark)
9772 (setq gnus-newsgroup-dormant
9773 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9776 (setq gnus-newsgroup-unreads
9777 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9779 (gnus-pull article gnus-newsgroup-reads)
9781 ;; See whether the article is to be put in the cache.
9783 (vectorp (gnus-summary-article-header article))
9785 (gnus-cache-possibly-enter-article
9786 gnus-newsgroup-name article
9787 (gnus-summary-article-header article)
9788 (= mark gnus-ticked-mark)
9789 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9792 (gnus-summary-update-mark mark 'unread)
9795 (defun gnus-summary-mark-article (&optional article mark no-expire)
9796 "Mark ARTICLE with MARK. MARK can be any character.
9797 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9798 `??' (dormant) and `?E' (expirable).
9799 If MARK is nil, then the default character `?r' is used.
9800 If ARTICLE is nil, then the article on the current line will be
9802 If NO-EXPIRE, auto-expiry will be inhibited."
9803 ;; The mark might be a string.
9804 (when (stringp mark)
9805 (setq mark (aref mark 0)))
9806 ;; If no mark is given, then we check auto-expiring.
9808 (setq mark gnus-del-mark))
9809 (when (and (not no-expire)
9810 gnus-newsgroup-auto-expire
9811 (memq mark gnus-auto-expirable-marks))
9812 (setq mark gnus-expirable-mark))
9813 (let ((article (or article (gnus-summary-article-number)))
9814 (old-mark (gnus-summary-article-mark article)))
9815 ;; Allow the backend to change the mark.
9816 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9817 (if (eq mark old-mark)
9820 (error "No article on current line"))
9821 (if (not (if (or (= mark gnus-unread-mark)
9822 (= mark gnus-ticked-mark)
9823 (= mark gnus-spam-mark)
9824 (= mark gnus-dormant-mark))
9825 (gnus-mark-article-as-unread article mark)
9826 (gnus-mark-article-as-read article mark)))
9828 ;; See whether the article is to be put in the cache.
9830 (not (= mark gnus-canceled-mark))
9831 (vectorp (gnus-summary-article-header article))
9833 (gnus-cache-possibly-enter-article
9834 gnus-newsgroup-name article
9835 (gnus-summary-article-header article)
9836 (= mark gnus-ticked-mark)
9837 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9839 (when (gnus-summary-goto-subject article nil t)
9840 (let ((buffer-read-only nil))
9841 (gnus-summary-show-thread)
9843 (gnus-summary-update-mark mark 'unread)
9846 (defun gnus-summary-update-secondary-mark (article)
9847 "Update the secondary (read, process, cache) mark."
9848 (gnus-summary-update-mark
9849 (cond ((memq article gnus-newsgroup-processable)
9851 ((memq article gnus-newsgroup-cached)
9853 ((memq article gnus-newsgroup-replied)
9855 ((memq article gnus-newsgroup-forwarded)
9856 gnus-forwarded-mark)
9857 ((memq article gnus-newsgroup-saved)
9859 ((memq article gnus-newsgroup-recent)
9861 ((memq article gnus-newsgroup-unseen)
9865 (when (gnus-visual-p 'summary-highlight 'highlight)
9866 (gnus-run-hooks 'gnus-summary-update-hook))
9869 (defun gnus-summary-update-download-mark (article)
9870 "Update the secondary (read, process, cache) mark."
9871 (gnus-summary-update-mark
9872 (cond ((memq article gnus-newsgroup-undownloaded)
9873 gnus-undownloaded-mark)
9874 (gnus-newsgroup-agentized
9875 gnus-downloaded-mark)
9879 (gnus-summary-update-line t)
9882 (defun gnus-summary-update-mark (mark type)
9883 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9884 (buffer-read-only nil))
9885 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9887 (when (looking-at "\r")
9889 (when (<= (+ forward (point)) (point-max))
9890 ;; Go to the right position on the line.
9891 (goto-char (+ forward (point)))
9892 ;; Replace the old mark with the new mark.
9893 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9894 ;; Optionally update the marks by some user rule.
9895 (when (eq type 'unread)
9897 (gnus-data-find (gnus-summary-article-number)) mark)
9898 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9900 (defun gnus-mark-article-as-read (article &optional mark)
9901 "Enter ARTICLE in the pertinent lists and remove it from others."
9902 ;; Make the article expirable.
9903 (let ((mark (or mark gnus-del-mark)))
9904 (setq gnus-newsgroup-expirable
9905 (if (= mark gnus-expirable-mark)
9906 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9907 (delq article gnus-newsgroup-expirable)))
9908 ;; Remove from unread and marked lists.
9909 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9910 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9911 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9912 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9913 (push (cons article mark) gnus-newsgroup-reads)
9914 ;; Possibly remove from cache, if that is used.
9915 (when gnus-use-cache
9916 (gnus-cache-enter-remove-article article))
9919 (defun gnus-mark-article-as-unread (article &optional mark)
9920 "Enter ARTICLE in the pertinent lists and remove it from others."
9921 (let ((mark (or mark gnus-ticked-mark)))
9924 (gnus-error 1 "Can't mark negative article numbers")
9926 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9927 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9928 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9929 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9930 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9932 ;; Unsuppress duplicates?
9933 (when gnus-suppress-duplicates
9934 (gnus-dup-unsuppress-article article))
9936 (cond ((= mark gnus-ticked-mark)
9937 (setq gnus-newsgroup-marked
9938 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9939 ((= mark gnus-spam-mark)
9940 (setq gnus-newsgroup-spam-marked
9941 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9943 ((= mark gnus-dormant-mark)
9944 (setq gnus-newsgroup-dormant
9945 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9947 (setq gnus-newsgroup-unreads
9948 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9949 (gnus-pull article gnus-newsgroup-reads)
9952 (defalias 'gnus-summary-mark-as-unread-forward
9953 'gnus-summary-tick-article-forward)
9954 (make-obsolete 'gnus-summary-mark-as-unread-forward
9955 'gnus-summary-tick-article-forward)
9956 (defun gnus-summary-tick-article-forward (n)
9957 "Tick N articles forwards.
9958 If N is negative, tick backwards instead.
9959 The difference between N and the number of articles ticked is returned."
9961 (gnus-summary-mark-forward n gnus-ticked-mark))
9963 (defalias 'gnus-summary-mark-as-unread-backward
9964 'gnus-summary-tick-article-backward)
9965 (make-obsolete 'gnus-summary-mark-as-unread-backward
9966 'gnus-summary-tick-article-backward)
9967 (defun gnus-summary-tick-article-backward (n)
9968 "Tick N articles backwards.
9969 The difference between N and the number of articles ticked is returned."
9971 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9973 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9974 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9975 (defun gnus-summary-tick-article (&optional article clear-mark)
9976 "Mark current article as unread.
9977 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9978 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9980 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9983 (defun gnus-summary-mark-as-read-forward (n)
9984 "Mark N articles as read forwards.
9985 If N is negative, mark backwards instead.
9986 The difference between N and the actual number of articles marked is
9989 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9991 (defun gnus-summary-mark-as-read-backward (n)
9992 "Mark the N articles as read backwards.
9993 The difference between N and the actual number of articles marked is
9996 (gnus-summary-mark-forward
9997 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9999 (defun gnus-summary-mark-as-read (&optional article mark)
10000 "Mark current article as read.
10001 ARTICLE specifies the article to be marked as read.
10002 MARK specifies a string to be inserted at the beginning of the line."
10003 (gnus-summary-mark-article article mark))
10005 (defun gnus-summary-clear-mark-forward (n)
10006 "Clear marks from N articles forward.
10007 If N is negative, clear backward instead.
10008 The difference between N and the number of marks cleared is returned."
10010 (gnus-summary-mark-forward n gnus-unread-mark))
10012 (defun gnus-summary-clear-mark-backward (n)
10013 "Clear marks from N articles backward.
10014 The difference between N and the number of marks cleared is returned."
10016 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10018 (defun gnus-summary-mark-unread-as-read ()
10019 "Intended to be used by `gnus-summary-mark-article-hook'."
10020 (when (memq gnus-current-article gnus-newsgroup-unreads)
10021 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10023 (defun gnus-summary-mark-read-and-unread-as-read ()
10024 "Intended to be used by `gnus-summary-mark-article-hook'."
10025 (let ((mark (gnus-summary-article-mark)))
10026 (when (or (gnus-unread-mark-p mark)
10027 (gnus-read-mark-p mark))
10028 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
10030 (defun gnus-summary-mark-unread-as-ticked ()
10031 "Intended to be used by `gnus-summary-mark-article-hook'."
10032 (when (memq gnus-current-article gnus-newsgroup-unreads)
10033 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10035 (defun gnus-summary-mark-region-as-read (point mark all)
10036 "Mark all unread articles between point and mark as read.
10037 If given a prefix, mark all articles between point and mark as read,
10038 even ticked and dormant ones."
10039 (interactive "r\nP")
10043 (beginning-of-line)
10048 (memq (setq article (gnus-summary-article-number))
10049 gnus-newsgroup-unreads))
10050 (gnus-summary-mark-article article gnus-del-mark))
10052 (gnus-summary-find-next))))))
10054 (defun gnus-summary-mark-below (score mark)
10055 "Mark articles with score less than SCORE with MARK."
10056 (interactive "P\ncMark: ")
10057 (setq score (if score
10058 (prefix-numeric-value score)
10059 (or gnus-summary-default-score 0)))
10061 (set-buffer gnus-summary-buffer)
10062 (goto-char (point-min))
10065 (and (< (gnus-summary-article-score) score)
10066 (gnus-summary-mark-article nil mark))
10067 (gnus-summary-find-next)))))
10069 (defun gnus-summary-kill-below (&optional score)
10070 "Mark articles with score below SCORE as read."
10072 (gnus-summary-mark-below score gnus-killed-mark))
10074 (defun gnus-summary-clear-above (&optional score)
10075 "Clear all marks from articles with score above SCORE."
10077 (gnus-summary-mark-above score gnus-unread-mark))
10079 (defun gnus-summary-tick-above (&optional score)
10080 "Tick all articles with score above SCORE."
10082 (gnus-summary-mark-above score gnus-ticked-mark))
10084 (defun gnus-summary-mark-above (score mark)
10085 "Mark articles with score over SCORE with MARK."
10086 (interactive "P\ncMark: ")
10087 (setq score (if score
10088 (prefix-numeric-value score)
10089 (or gnus-summary-default-score 0)))
10091 (set-buffer gnus-summary-buffer)
10092 (goto-char (point-min))
10094 (when (> (gnus-summary-article-score) score)
10095 (gnus-summary-mark-article nil mark))
10097 (gnus-summary-find-next)))))
10099 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10100 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10101 (defun gnus-summary-limit-include-expunged (&optional no-error)
10102 "Display all the hidden articles that were expunged for low scores."
10104 (let ((buffer-read-only nil))
10105 (let ((scored gnus-newsgroup-scored)
10108 (unless (gnus-summary-article-header (caar scored))
10109 (and (setq h (gnus-number-to-header (caar scored)))
10110 (< (cdar scored) gnus-summary-expunge-below)
10112 (setq scored (cdr scored)))
10114 (when (not no-error)
10115 (error "No expunged articles hidden"))
10116 (goto-char (point-min))
10117 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10118 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10119 (mapcar (lambda (x) (push (mail-header-number x)
10120 gnus-newsgroup-limit))
10122 (gnus-summary-prepare-unthreaded (nreverse headers))
10123 (goto-char (point-min))
10124 (gnus-summary-position-point)
10127 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10128 "Mark all unread articles in this newsgroup as read.
10129 If prefix argument ALL is non-nil, ticked and dormant articles will
10130 also be marked as read.
10131 If QUIETLY is non-nil, no questions will be asked.
10132 If TO-HERE is non-nil, it should be a point in the buffer. All
10133 articles before (after, if REVERSE is set) this point will be marked as read.
10134 Note that this function will only catch up the unread article
10135 in the current summary buffer limitation.
10136 The number of articles marked as read is returned."
10141 (not gnus-interactive-catchup) ;Without confirmation?
10145 "Mark absolutely all articles as read? "
10146 "Mark all unread articles as read? ")))
10148 (not gnus-newsgroup-adaptive)
10149 (not gnus-newsgroup-auto-expire)
10150 (not gnus-suppress-duplicates)
10151 (or (not gnus-use-cache)
10152 (eq gnus-use-cache 'passive)))
10155 (setq gnus-newsgroup-marked nil
10156 gnus-newsgroup-spam-marked nil
10157 gnus-newsgroup-dormant nil))
10158 (setq gnus-newsgroup-unreads
10159 (gnus-sorted-nunion
10160 (gnus-intersection gnus-newsgroup-unreads
10161 gnus-newsgroup-downloadable)
10162 gnus-newsgroup-unfetched)))
10163 ;; We actually mark all articles as canceled, which we
10164 ;; have to do when using auto-expiry or adaptive scoring.
10165 (gnus-summary-show-all-threads)
10166 (if (and to-here reverse)
10168 (goto-char to-here)
10170 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10171 (gnus-summary-find-next (not all)))))
10172 (when (gnus-summary-first-subject (not all))
10174 (if to-here (< (point) to-here) t)
10175 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10176 (gnus-summary-find-next (not all))))))
10177 (gnus-set-mode-line 'summary))
10179 (gnus-summary-position-point)))
10181 (defun gnus-summary-catchup-to-here (&optional all)
10182 "Mark all unticked articles before the current one as read.
10183 If ALL is non-nil, also mark ticked and dormant articles as read."
10186 (gnus-save-hidden-threads
10187 (let ((beg (point)))
10188 ;; We check that there are unread articles.
10189 (when (or all (gnus-summary-find-prev))
10190 (gnus-summary-catchup all t beg)))))
10191 (gnus-summary-position-point))
10193 (defun gnus-summary-catchup-from-here (&optional all)
10194 "Mark all unticked articles after the current one as read.
10195 If ALL is non-nil, also mark ticked and dormant articles as read."
10198 (gnus-save-hidden-threads
10199 (let ((beg (point)))
10200 ;; We check that there are unread articles.
10201 (when (or all (gnus-summary-find-next))
10202 (gnus-summary-catchup all t beg nil t)))))
10203 (gnus-summary-position-point))
10205 (defun gnus-summary-catchup-all (&optional quietly)
10206 "Mark all articles in this newsgroup as read.
10207 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10208 instead, which marks only unread articles as read."
10210 (gnus-summary-catchup t quietly))
10212 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10213 "Mark all unread articles in this group as read, then exit.
10214 If prefix argument ALL is non-nil, all articles are marked as read.
10215 If QUIETLY is non-nil, no questions will be asked."
10217 (when (gnus-summary-catchup all quietly nil 'fast)
10218 ;; Select next newsgroup or exit.
10219 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10220 (eq gnus-auto-select-next 'quietly))
10221 (gnus-summary-next-group nil)
10222 (gnus-summary-exit))))
10224 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10225 "Mark all articles in this newsgroup as read, and then exit.
10226 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10227 instead, which marks only unread articles as read."
10229 (gnus-summary-catchup-and-exit t quietly))
10231 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10232 "Mark all articles in this group as read and select the next group.
10233 If given a prefix, mark all articles, unread as well as ticked, as
10237 (gnus-summary-catchup all))
10238 (gnus-summary-next-group))
10244 (defmacro gnus-with-article (article &rest forms)
10245 "Select ARTICLE and perform FORMS in the original article buffer.
10246 Then replace the article with the result."
10248 ;; We don't want the article to be marked as read.
10249 (let (gnus-mark-article-hook)
10250 (gnus-summary-select-article t t nil ,article))
10251 (set-buffer gnus-original-article-buffer)
10253 (if (not (gnus-check-backend-function
10254 'request-replace-article (car gnus-article-current)))
10255 (gnus-message 5 "Read-only group; not replacing")
10256 (unless (gnus-request-replace-article
10257 ,article (car gnus-article-current)
10258 (current-buffer) t)
10259 (error "Couldn't replace article")))
10260 ;; The cache and backlog have to be flushed somewhat.
10261 (when gnus-keep-backlog
10262 (gnus-backlog-remove-article
10263 (car gnus-article-current) (cdr gnus-article-current)))
10264 (when gnus-use-cache
10265 (gnus-cache-update-article
10266 (car gnus-article-current) (cdr gnus-article-current)))))
10268 (put 'gnus-with-article 'lisp-indent-function 1)
10269 (put 'gnus-with-article 'edebug-form-spec '(form body))
10271 ;; Thread-based commands.
10273 (defun gnus-summary-articles-in-thread (&optional article)
10274 "Return a list of all articles in the current thread.
10275 If ARTICLE is non-nil, return all articles in the thread that starts
10276 with that article."
10277 (let* ((article (or article (gnus-summary-article-number)))
10278 (data (gnus-data-find-list article))
10279 (top-level (gnus-data-level (car data)))
10281 (cond ((null gnus-thread-operation-ignore-subject)
10282 (gnus-simplify-subject-re
10283 (mail-header-subject (gnus-data-header (car data)))))
10284 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10285 (gnus-simplify-subject-fuzzy
10286 (mail-header-subject (gnus-data-header (car data)))))
10288 (end-point (save-excursion
10289 (if (gnus-summary-go-to-next-thread)
10290 (point) (point-max))))
10293 (< (gnus-data-pos (car data)) end-point))
10294 (when (or (not top-subject)
10295 (string= top-subject
10296 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10297 (gnus-simplify-subject-fuzzy
10298 (mail-header-subject
10299 (gnus-data-header (car data))))
10300 (gnus-simplify-subject-re
10301 (mail-header-subject
10302 (gnus-data-header (car data)))))))
10303 (push (gnus-data-number (car data)) articles))
10304 (unless (and (setq data (cdr data))
10305 (> (gnus-data-level (car data)) top-level))
10307 ;; Return the list of articles.
10308 (nreverse articles)))
10310 (defun gnus-summary-rethread-current ()
10311 "Rethread the thread the current article is part of."
10313 (let* ((gnus-show-threads t)
10314 (article (gnus-summary-article-number))
10315 (id (mail-header-id (gnus-summary-article-header)))
10316 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10318 (error "No article on the current line"))
10319 (gnus-rebuild-thread id)
10320 (gnus-summary-goto-subject article)))
10322 (defun gnus-summary-reparent-thread ()
10323 "Make the current article child of the marked (or previous) article.
10325 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10326 is non-nil or the Subject: of both articles are the same."
10328 (unless (not (gnus-group-read-only-p))
10329 (error "The current newsgroup does not support article editing"))
10330 (unless (<= (length gnus-newsgroup-processable) 1)
10331 (error "No more than one article may be marked"))
10332 (save-window-excursion
10333 (let ((gnus-article-buffer " *reparent*")
10334 (current-article (gnus-summary-article-number))
10335 ;; First grab the marked article, otherwise one line up.
10336 (parent-article (if (not (null gnus-newsgroup-processable))
10337 (car gnus-newsgroup-processable)
10339 (if (eq (forward-line -1) 0)
10340 (gnus-summary-article-number)
10341 (error "Beginning of summary buffer"))))))
10342 (unless (not (eq current-article parent-article))
10343 (error "An article may not be self-referential"))
10344 (let ((message-id (mail-header-id
10345 (gnus-summary-article-header parent-article))))
10346 (unless (and message-id (not (equal message-id "")))
10347 (error "No message-id in desired parent"))
10348 (gnus-with-article current-article
10350 (goto-char (point-min))
10351 (message-narrow-to-head)
10352 (if (re-search-forward "^References: " nil t)
10354 (re-search-forward "^[^ \t]" nil t)
10357 (insert " " message-id))
10358 (insert "References: " message-id "\n"))))
10359 (set-buffer gnus-summary-buffer)
10360 (gnus-summary-unmark-all-processable)
10361 (gnus-summary-update-article current-article)
10362 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10363 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10364 (gnus-summary-rethread-current)
10365 (gnus-message 3 "Article %d is now the child of article %d"
10366 current-article parent-article)))))
10368 (defun gnus-summary-toggle-threads (&optional arg)
10369 "Toggle showing conversation threads.
10370 If ARG is positive number, turn showing conversation threads on."
10372 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10373 (setq gnus-show-threads
10374 (if (null arg) (not gnus-show-threads)
10375 (> (prefix-numeric-value arg) 0)))
10376 (gnus-summary-prepare)
10377 (gnus-summary-goto-subject current)
10378 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10379 (gnus-summary-position-point)))
10381 (defun gnus-summary-show-all-threads ()
10382 "Show all threads."
10385 (let ((buffer-read-only nil))
10386 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10387 (gnus-summary-position-point))
10389 (defun gnus-summary-show-thread ()
10390 "Show thread subtrees.
10391 Returns nil if no thread was there to be shown."
10393 (let ((buffer-read-only nil)
10395 ;; first goto end then to beg, to have point at beg after let
10396 (end (progn (end-of-line) (point)))
10397 (beg (progn (beginning-of-line) (point))))
10399 ;; Any hidden lines here?
10400 (search-forward "\r" end t)
10401 (subst-char-in-region beg end ?\^M ?\n t)
10403 (gnus-summary-position-point))))
10405 (defun gnus-summary-maybe-hide-threads ()
10406 "If requested, hide the threads that should be hidden."
10407 (when (and gnus-show-threads
10408 gnus-thread-hide-subtree)
10409 (gnus-summary-hide-all-threads
10410 (if (or (consp gnus-thread-hide-subtree)
10411 (gnus-functionp gnus-thread-hide-subtree))
10412 (gnus-make-predicate gnus-thread-hide-subtree)
10415 ;;; Hiding predicates.
10417 (defun gnus-article-unread-p (header)
10418 (memq (mail-header-number header) gnus-newsgroup-unreads))
10420 (defun gnus-article-unseen-p (header)
10421 (memq (mail-header-number header) gnus-newsgroup-unseen))
10423 (defun gnus-map-articles (predicate articles)
10424 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10425 (apply 'gnus-or (mapcar predicate
10426 (mapcar 'gnus-summary-article-header articles))))
10428 (defun gnus-summary-hide-all-threads (&optional predicate)
10429 "Hide all thread subtrees.
10430 If PREDICATE is supplied, threads that satisfy this predicate
10431 will not be hidden."
10434 (goto-char (point-min))
10437 (when (or (not predicate)
10439 predicate (gnus-summary-article-children)))
10440 (gnus-summary-hide-thread))
10441 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10442 (gnus-summary-position-point))
10444 (defun gnus-summary-hide-thread ()
10445 "Hide thread subtrees.
10446 If PREDICATE is supplied, threads that satisfy this predicate
10447 will not be hidden.
10448 Returns nil if no threads were there to be hidden."
10450 (let ((buffer-read-only nil)
10452 (article (gnus-summary-article-number)))
10454 ;; Go forward until either the buffer ends or the subthread
10456 (when (and (not (eobp))
10457 (or (zerop (gnus-summary-next-thread 1 t))
10458 (goto-char (point-max))))
10460 (if (and (> (point) start)
10461 (search-backward "\n" start t))
10463 (subst-char-in-region start (point) ?\n ?\^M)
10464 (gnus-summary-goto-subject article))
10468 (defun gnus-summary-go-to-next-thread (&optional previous)
10469 "Go to the same level (or less) next thread.
10470 If PREVIOUS is non-nil, go to previous thread instead.
10471 Return the article number moved to, or nil if moving was impossible."
10472 (let ((level (gnus-summary-thread-level))
10473 (way (if previous -1 1))
10476 (while (and (not (eobp))
10477 (< level (gnus-summary-thread-level)))
10478 (forward-line way))
10485 (gnus-summary-article-number)
10486 (goto-char beg)))))
10488 (defun gnus-summary-next-thread (n &optional silent)
10489 "Go to the same level next N'th thread.
10490 If N is negative, search backward instead.
10491 Returns the difference between N and the number of skips actually
10494 If SILENT, don't output messages."
10496 (let ((backward (< n 0))
10498 (while (and (> n 0)
10499 (gnus-summary-go-to-next-thread backward))
10502 (gnus-summary-position-point))
10503 (when (and (not silent) (/= 0 n))
10504 (gnus-message 7 "No more threads"))
10507 (defun gnus-summary-prev-thread (n)
10508 "Go to the same level previous N'th thread.
10509 Returns the difference between N and the number of skips actually
10512 (gnus-summary-next-thread (- n)))
10514 (defun gnus-summary-go-down-thread ()
10515 "Go down one level in the current thread."
10516 (let ((children (gnus-summary-article-children)))
10518 (gnus-summary-goto-subject (car children)))))
10520 (defun gnus-summary-go-up-thread ()
10521 "Go up one level in the current thread."
10522 (let ((parent (gnus-summary-article-parent)))
10524 (gnus-summary-goto-subject parent))))
10526 (defun gnus-summary-down-thread (n)
10527 "Go down thread N steps.
10528 If N is negative, go up instead.
10529 Returns the difference between N and how many steps down that were
10534 (while (and (> n 0)
10535 (if up (gnus-summary-go-up-thread)
10536 (gnus-summary-go-down-thread)))
10538 (gnus-summary-position-point)
10540 (gnus-message 7 "Can't go further"))
10543 (defun gnus-summary-up-thread (n)
10544 "Go up thread N steps.
10545 If N is negative, go down instead.
10546 Returns the difference between N and how many steps down that were
10549 (gnus-summary-down-thread (- n)))
10551 (defun gnus-summary-top-thread ()
10552 "Go to the top of the thread."
10554 (while (gnus-summary-go-up-thread))
10555 (gnus-summary-article-number))
10557 (defun gnus-summary-kill-thread (&optional unmark)
10558 "Mark articles under current thread as read.
10559 If the prefix argument is positive, remove any kinds of marks.
10560 If the prefix argument is negative, tick articles instead."
10563 (setq unmark (prefix-numeric-value unmark)))
10564 (let ((articles (gnus-summary-articles-in-thread)))
10566 ;; Expand the thread.
10567 (gnus-summary-show-thread)
10568 ;; Mark all the articles.
10570 (gnus-summary-goto-subject (car articles))
10571 (cond ((null unmark)
10572 (gnus-summary-mark-article-as-read gnus-killed-mark))
10574 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10576 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10577 (setq articles (cdr articles))))
10578 ;; Hide killed subtrees.
10580 gnus-thread-hide-killed
10581 (gnus-summary-hide-thread))
10582 ;; If marked as read, go to next unread subject.
10583 (when (null unmark)
10584 ;; Go to next unread subject.
10585 (gnus-summary-next-subject 1 t)))
10586 (gnus-set-mode-line 'summary))
10588 ;; Summary sorting commands
10590 (defun gnus-summary-sort-by-number (&optional reverse)
10591 "Sort the summary buffer by article number.
10592 Argument REVERSE means reverse order."
10594 (gnus-summary-sort 'number reverse))
10596 (defun gnus-summary-sort-by-random (&optional reverse)
10597 "Randomize the order in the summary buffer.
10598 Argument REVERSE means to randomize in reverse order."
10600 (gnus-summary-sort 'random reverse))
10602 (defun gnus-summary-sort-by-author (&optional reverse)
10603 "Sort the summary buffer by author name alphabetically.
10604 If `case-fold-search' is non-nil, case of letters is ignored.
10605 Argument REVERSE means reverse order."
10607 (gnus-summary-sort 'author reverse))
10609 (defun gnus-summary-sort-by-subject (&optional reverse)
10610 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10611 If `case-fold-search' is non-nil, case of letters is ignored.
10612 Argument REVERSE means reverse order."
10614 (gnus-summary-sort 'subject reverse))
10616 (defun gnus-summary-sort-by-date (&optional reverse)
10617 "Sort the summary buffer by date.
10618 Argument REVERSE means reverse order."
10620 (gnus-summary-sort 'date reverse))
10622 (defun gnus-summary-sort-by-score (&optional reverse)
10623 "Sort the summary buffer by score.
10624 Argument REVERSE means reverse order."
10626 (gnus-summary-sort 'score reverse))
10628 (defun gnus-summary-sort-by-lines (&optional reverse)
10629 "Sort the summary buffer by the number of lines.
10630 Argument REVERSE means reverse order."
10632 (gnus-summary-sort 'lines reverse))
10634 (defun gnus-summary-sort-by-chars (&optional reverse)
10635 "Sort the summary buffer by article length.
10636 Argument REVERSE means reverse order."
10638 (gnus-summary-sort 'chars reverse))
10640 (defun gnus-summary-sort-by-original (&optional reverse)
10641 "Sort the summary buffer using the default sorting method.
10642 Argument REVERSE means reverse order."
10644 (let* ((buffer-read-only)
10645 (gnus-summary-prepare-hook nil))
10646 ;; We do the sorting by regenerating the threads.
10647 (gnus-summary-prepare)
10648 ;; Hide subthreads if needed.
10649 (gnus-summary-maybe-hide-threads)))
10651 (defun gnus-summary-sort (predicate reverse)
10652 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10653 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10654 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10655 (gnus-thread-sort-functions
10660 (gnus-sort-gathered-threads-function
10661 gnus-thread-sort-functions)
10662 (gnus-article-sort-functions
10666 (,article t2 t1))))
10668 (gnus-summary-prepare-hook nil))
10669 ;; We do the sorting by regenerating the threads.
10670 (gnus-summary-prepare)
10671 ;; Hide subthreads if needed.
10672 (gnus-summary-maybe-hide-threads)))
10674 ;; Summary saving commands.
10676 (defun gnus-summary-save-article (&optional n not-saved)
10677 "Save the current article using the default saver function.
10678 If N is a positive number, save the N next articles.
10679 If N is a negative number, save the N previous articles.
10680 If N is nil and any articles have been marked with the process mark,
10681 save those articles instead.
10682 The variable `gnus-default-article-saver' specifies the saver function."
10684 (let* ((articles (gnus-summary-work-articles n))
10685 (save-buffer (save-excursion
10686 (nnheader-set-temp-buffer " *Gnus Save*")))
10687 (num (length articles))
10689 (dolist (article articles)
10690 (setq header (gnus-summary-article-header article))
10691 (if (not (vectorp header))
10692 ;; This is a pseudo-article.
10693 (if (assq 'name header)
10694 (gnus-copy-file (cdr (assq 'name header)))
10695 (gnus-message 1 "Article %d is unsaveable" article))
10696 ;; This is a real article.
10697 (save-window-excursion
10698 (let ((gnus-display-mime-function nil)
10699 (gnus-article-prepare-hook nil))
10700 (gnus-summary-select-article t nil nil article)))
10702 (set-buffer save-buffer)
10704 (insert-buffer-substring gnus-original-article-buffer))
10705 (setq file (gnus-article-save save-buffer file num))
10706 (gnus-summary-remove-process-mark article)
10708 (gnus-summary-set-saved-mark article))))
10709 (gnus-kill-buffer save-buffer)
10710 (gnus-summary-position-point)
10711 (gnus-set-mode-line 'summary)
10714 (defun gnus-summary-pipe-output (&optional arg headers)
10715 "Pipe the current article to a subprocess.
10716 If N is a positive number, pipe the N next articles.
10717 If N is a negative number, pipe the N previous articles.
10718 If N is nil and any articles have been marked with the process mark,
10719 pipe those articles instead.
10720 If HEADERS (the symbolic prefix), include the headers, too."
10721 (interactive (gnus-interactive "P\ny"))
10722 (require 'gnus-art)
10723 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10724 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10725 (gnus-summary-save-article arg t))
10726 (let ((buffer (get-buffer "*Shell Command Output*")))
10728 (not (zerop (buffer-size buffer))))
10729 (gnus-configure-windows 'pipe))))
10731 (defun gnus-summary-save-article-mail (&optional arg)
10732 "Append the current article to an mail file.
10733 If N is a positive number, save the N next articles.
10734 If N is a negative number, save the N previous articles.
10735 If N is nil and any articles have been marked with the process mark,
10736 save those articles instead."
10738 (require 'gnus-art)
10739 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10740 (gnus-summary-save-article arg)))
10742 (defun gnus-summary-save-article-rmail (&optional arg)
10743 "Append the current article to an rmail file.
10744 If N is a positive number, save the N next articles.
10745 If N is a negative number, save the N previous articles.
10746 If N is nil and any articles have been marked with the process mark,
10747 save those articles instead."
10749 (require 'gnus-art)
10750 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10751 (gnus-summary-save-article arg)))
10753 (defun gnus-summary-save-article-file (&optional arg)
10754 "Append the current article to a file.
10755 If N is a positive number, save the N next articles.
10756 If N is a negative number, save the N previous articles.
10757 If N is nil and any articles have been marked with the process mark,
10758 save those articles instead."
10760 (require 'gnus-art)
10761 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10762 (gnus-summary-save-article arg)))
10764 (defun gnus-summary-write-article-file (&optional arg)
10765 "Write the current article to a file, deleting the previous file.
10766 If N is a positive number, save the N next articles.
10767 If N is a negative number, save the N previous articles.
10768 If N is nil and any articles have been marked with the process mark,
10769 save those articles instead."
10771 (require 'gnus-art)
10772 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10773 (gnus-summary-save-article arg)))
10775 (defun gnus-summary-save-article-body-file (&optional arg)
10776 "Append the current article body to a file.
10777 If N is a positive number, save the N next articles.
10778 If N is a negative number, save the N previous articles.
10779 If N is nil and any articles have been marked with the process mark,
10780 save those articles instead."
10782 (require 'gnus-art)
10783 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10784 (gnus-summary-save-article arg)))
10786 (defun gnus-summary-muttprint (&optional arg)
10787 "Print the current article using Muttprint.
10788 If N is a positive number, save the N next articles.
10789 If N is a negative number, save the N previous articles.
10790 If N is nil and any articles have been marked with the process mark,
10791 save those articles instead."
10793 (require 'gnus-art)
10794 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10795 (gnus-summary-save-article arg t)))
10797 (defun gnus-summary-pipe-message (program)
10798 "Pipe the current article through PROGRAM."
10799 (interactive "sProgram: ")
10800 (gnus-summary-select-article)
10801 (let ((mail-header-separator ""))
10802 (gnus-eval-in-buffer-window gnus-article-buffer
10805 (let ((start (window-start))
10807 (message-pipe-buffer-body program)
10808 (set-window-start (get-buffer-window (current-buffer)) start))))))
10810 (defun gnus-get-split-value (methods)
10811 "Return a value based on the split METHODS."
10812 (let (split-name method result match)
10815 (set-buffer gnus-original-article-buffer)
10817 (nnheader-narrow-to-headers)
10818 (while (and methods (not split-name))
10819 (goto-char (point-min))
10820 (setq method (pop methods))
10821 (setq match (car method))
10824 ;; Regular expression.
10826 (re-search-forward match nil t)))
10827 ((gnus-functionp match)
10831 (setq result (funcall match gnus-newsgroup-name))))
10836 (setq result (eval match)))))
10837 (setq split-name (cdr method))
10838 (cond ((stringp result)
10839 (push (expand-file-name
10840 result gnus-article-save-directory)
10843 (setq split-name (append result split-name)))))))))
10844 (nreverse split-name)))
10846 (defun gnus-valid-move-group-p (group)
10847 (and (boundp group)
10848 (symbol-name group)
10849 (symbol-value group)
10850 (gnus-get-function (gnus-find-method-for-group
10851 (symbol-name group)) 'request-accept-article t)))
10853 (defun gnus-read-move-group-name (prompt default articles prefix)
10854 "Read a group name."
10855 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10856 (minibuffer-confirm-incomplete nil) ; XEmacs
10858 (format "%s %s to:"
10860 (if (> (length articles) 1)
10861 (format "these %d articles" (length articles))
10866 (gnus-completing-read-with-default
10869 'gnus-valid-move-group-p
10871 'gnus-group-history))
10872 ((= 1 (length split-name))
10873 (gnus-completing-read-with-default
10874 (car split-name) prom
10876 'gnus-valid-move-group-p
10878 'gnus-group-history))
10880 (gnus-completing-read-with-default
10882 (mapcar (lambda (el) (list el))
10883 (nreverse split-name))
10885 'gnus-group-history))))
10886 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10888 (if (or (string= to-newsgroup "")
10889 (string= to-newsgroup prefix))
10890 (setq to-newsgroup default))
10891 (unless to-newsgroup
10892 (error "No group name entered"))
10893 (or (gnus-active to-newsgroup)
10894 (gnus-activate-group to-newsgroup nil nil to-method)
10895 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10897 (or (and (gnus-request-create-group to-newsgroup to-method)
10898 (gnus-activate-group
10899 to-newsgroup nil nil to-method)
10900 (gnus-subscribe-group to-newsgroup))
10901 (error "Couldn't create group %s" to-newsgroup)))
10902 (error "No such group: %s" to-newsgroup)))
10905 (defun gnus-summary-save-parts (type dir n &optional reverse)
10906 "Save parts matching TYPE to DIR.
10907 If REVERSE, save parts that do not match TYPE."
10909 (list (read-string "Save parts of type: "
10910 (or (car gnus-summary-save-parts-type-history)
10911 gnus-summary-save-parts-default-mime)
10912 'gnus-summary-save-parts-type-history)
10913 (setq gnus-summary-save-parts-last-directory
10914 (read-file-name "Save to directory: "
10915 gnus-summary-save-parts-last-directory
10917 current-prefix-arg))
10918 (gnus-summary-iterate n
10919 (let ((gnus-display-mime-function nil)
10920 (gnus-inhibit-treatment t))
10921 (gnus-summary-select-article))
10923 (set-buffer gnus-article-buffer)
10924 (let ((handles (or gnus-article-mime-handles
10925 (mm-dissect-buffer nil gnus-article-loose-mime)
10926 (and gnus-article-emulate-mime
10927 (mm-uu-dissect)))))
10929 (gnus-summary-save-parts-1 type dir handles reverse)
10930 (unless gnus-article-mime-handles ;; Don't destroy this case.
10931 (mm-destroy-parts handles)))))))
10933 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10934 (if (stringp (car handle))
10935 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10938 (not (string-match type (mm-handle-media-type handle)))
10939 (string-match type (mm-handle-media-type handle)))
10940 (let ((file (expand-file-name
10941 (file-name-nondirectory
10943 (mail-content-type-get
10944 (mm-handle-disposition handle) 'filename)
10945 (concat gnus-newsgroup-name
10946 "." (number-to-string
10947 (cdr gnus-article-current)))))
10949 (unless (file-exists-p file)
10950 (mm-save-part-to-file handle file))))))
10952 ;; Summary extract commands
10954 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10955 (let ((buffer-read-only nil)
10956 (article (gnus-summary-article-number))
10958 (unless (gnus-summary-goto-subject article)
10959 (error "No such article: %d" article))
10960 (gnus-summary-position-point)
10961 ;; If all commands are to be bunched up on one line, we collect
10963 (unless gnus-view-pseudos-separately
10964 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10967 (setq action (cdr (assq 'action (car ps))))
10968 (setq files (list (cdr (assq 'name (car ps)))))
10969 (while (and ps (cdr ps)
10970 (string= (or action "1")
10971 (or (cdr (assq 'action (cadr ps))) "2")))
10972 (push (cdr (assq 'name (cadr ps))) files)
10973 (setcdr ps (cddr ps)))
10975 (when (not (string-match "%s" action))
10978 (when (assq 'execute (car ps))
10979 (setcdr (assq 'execute (car ps))
10980 (funcall (if (string-match "%s" action)
10987 (gnus-quote-arg-for-sh-or-csh f)))
10989 (setq ps (cdr ps)))))
10990 (if (and gnus-view-pseudos (not not-view))
10992 (when (assq 'execute (car pslist))
10993 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10994 (eq gnus-view-pseudos 'not-confirm)))
10995 (setq pslist (cdr pslist)))
10998 (setq after-article (or (cdr (assq 'article (car pslist)))
10999 (gnus-summary-article-number)))
11000 (gnus-summary-goto-subject after-article)
11003 (insert " " (file-name-nondirectory
11004 (cdr (assq 'name (car pslist))))
11005 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11007 (forward-line -1) ; back to `b'
11008 (gnus-add-text-properties
11009 b (1- e) (list 'gnus-number gnus-reffed-article-number
11010 gnus-mouse-face-prop gnus-mouse-face))
11012 after-article gnus-reffed-article-number
11013 gnus-unread-mark b (car pslist) 0 (- e b))
11014 (setq gnus-newsgroup-unreads
11015 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11016 gnus-reffed-article-number))
11017 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11018 (setq pslist (cdr pslist)))))))
11020 (defun gnus-pseudos< (p1 p2)
11021 (let ((c1 (cdr (assq 'action p1)))
11022 (c2 (cdr (assq 'action p2))))
11023 (and c1 c2 (string< c1 c2))))
11025 (defun gnus-request-pseudo-article (props)
11026 (cond ((assq 'execute props)
11027 (gnus-execute-command (cdr (assq 'execute props)))))
11028 (let ((gnus-current-article (gnus-summary-article-number)))
11029 (gnus-run-hooks 'gnus-mark-article-hook)))
11031 (defun gnus-execute-command (command &optional automatic)
11033 (gnus-article-setup-buffer)
11034 (set-buffer gnus-article-buffer)
11035 (setq buffer-read-only nil)
11036 (let ((command (if automatic command
11037 (read-string "Command: " (cons command 0)))))
11039 (insert "$ " command "\n\n")
11040 (if gnus-view-pseudo-asynchronously
11041 (start-process "gnus-execute" (current-buffer) shell-file-name
11042 shell-command-switch command)
11043 (call-process shell-file-name nil t nil
11044 shell-command-switch command)))))
11046 ;; Summary kill commands.
11048 (defun gnus-summary-edit-global-kill (article)
11049 "Edit the \"global\" kill file."
11050 (interactive (list (gnus-summary-article-number)))
11051 (gnus-group-edit-global-kill article))
11053 (defun gnus-summary-edit-local-kill ()
11054 "Edit a local kill file applied to the current newsgroup."
11056 (setq gnus-current-headers (gnus-summary-article-header))
11057 (gnus-group-edit-local-kill
11058 (gnus-summary-article-number) gnus-newsgroup-name))
11060 ;;; Header reading.
11062 (defun gnus-read-header (id &optional header)
11063 "Read the headers of article ID and enter them into the Gnus system."
11064 (let ((group gnus-newsgroup-name)
11065 (gnus-override-method
11067 gnus-override-method
11068 (and (gnus-news-group-p gnus-newsgroup-name)
11069 (car (gnus-refer-article-methods)))))
11071 ;; First we check to see whether the header in question is already
11074 ;; This is a Message-ID.
11075 (setq header (or header (gnus-id-to-header id)))
11076 ;; This is an article number.
11077 (setq header (or header (gnus-summary-article-header id))))
11079 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11080 ;; We have found the header.
11082 ;; If this is a sparse article, we have to nix out its
11083 ;; previous entry in the thread hashtb.
11085 (gnus-summary-article-sparse-p (mail-header-number header)))
11086 (let* ((parent (gnus-parent-id (mail-header-references header)))
11087 (thread (and parent (gnus-id-to-thread parent))))
11089 (delq (assq header thread) thread))))
11090 ;; We have to really fetch the header to this article.
11092 (set-buffer nntp-server-buffer)
11093 (when (setq where (gnus-request-head id group))
11094 (nnheader-fold-continuation-lines)
11095 (goto-char (point-max))
11097 (goto-char (point-min))
11101 ((cdr where) (cdr where))
11102 (header (mail-header-number header))
11103 (t gnus-reffed-article-number))
11105 (insert " Article retrieved.\n"))
11106 (if (or (not where)
11107 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11108 () ; Malformed head.
11109 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11110 (when (and (stringp id)
11111 (not (string= (gnus-group-real-name group)
11113 ;; If we fetched by Message-ID and the article came
11114 ;; from a different group, we fudge some bogus article
11115 ;; numbers for this article.
11116 (mail-header-set-number header gnus-reffed-article-number))
11118 (set-buffer gnus-summary-buffer)
11119 (decf gnus-reffed-article-number)
11120 (gnus-remove-header (mail-header-number header))
11121 (push header gnus-newsgroup-headers)
11122 (setq gnus-current-headers header)
11123 (push (mail-header-number header) gnus-newsgroup-limit)))
11126 (defun gnus-remove-header (number)
11127 "Remove header NUMBER from `gnus-newsgroup-headers'."
11128 (if (and gnus-newsgroup-headers
11129 (= number (mail-header-number (car gnus-newsgroup-headers))))
11130 (pop gnus-newsgroup-headers)
11131 (let ((headers gnus-newsgroup-headers))
11132 (while (and (cdr headers)
11133 (not (= number (mail-header-number (cadr headers)))))
11135 (when (cdr headers)
11136 (setcdr headers (cddr headers))))))
11139 ;;; summary highlights
11142 (defun gnus-highlight-selected-summary ()
11143 "Highlight selected article in summary buffer."
11144 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11145 (when gnus-summary-selected-face
11147 (let* ((beg (progn (beginning-of-line) (point)))
11148 (end (progn (end-of-line) (point)))
11149 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11150 (from (if (get-text-property beg gnus-mouse-face-prop)
11152 (or (next-single-property-change
11153 beg gnus-mouse-face-prop nil end)
11158 (or (next-single-property-change
11159 from gnus-mouse-face-prop nil end)
11161 ;; If no mouse-face prop on line we will have to = from = end,
11162 ;; so we highlight the entire line instead.
11163 (when (= (+ to 2) from)
11166 (if gnus-newsgroup-selected-overlay
11167 ;; Move old overlay.
11169 gnus-newsgroup-selected-overlay from to (current-buffer))
11170 ;; Create new overlay.
11172 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11173 'face gnus-summary-selected-face))))))
11175 (defvar gnus-summary-highlight-line-cached nil)
11176 (defvar gnus-summary-highlight-line-trigger nil)
11178 (defun gnus-summary-highlight-line-0 ()
11179 (if (and (eq gnus-summary-highlight-line-trigger
11180 gnus-summary-highlight)
11181 gnus-summary-highlight-line-cached)
11182 gnus-summary-highlight-line-cached
11183 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11184 gnus-summary-highlight-line-cached
11185 (let* ((cond (list 'cond))
11187 (list gnus-summary-highlight))
11189 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11192 (gnus-byte-compile (list 'lambda nil cond))))))
11194 (defun gnus-summary-highlight-line ()
11195 "Highlight current line according to `gnus-summary-highlight'."
11196 (let* ((beg (gnus-point-at-bol))
11197 (article (or (gnus-summary-article-number) gnus-current-article))
11198 (score (or (cdr (assq article
11199 gnus-newsgroup-scored))
11200 gnus-summary-default-score 0))
11201 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11202 (inhibit-read-only t)
11203 (default gnus-summary-default-score)
11204 (default-high gnus-summary-default-high-score)
11205 (default-low gnus-summary-default-low-score)
11206 (uncached (memq article gnus-newsgroup-undownloaded))
11207 (downloaded (not uncached)))
11208 (let ((face (funcall (gnus-summary-highlight-line-0))))
11209 (unless (eq face (get-text-property beg 'face))
11210 (gnus-put-text-property-excluding-characters-with-faces
11211 beg (gnus-point-at-eol) 'face
11212 (setq face (if (boundp face) (symbol-value face) face)))
11213 (when gnus-summary-highlight-line-function
11214 (funcall gnus-summary-highlight-line-function article face))))))
11216 (defun gnus-update-read-articles (group unread &optional compute)
11217 "Update the list of read articles in GROUP.
11218 UNREAD is a sorted list."
11219 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11220 (entry (gnus-gethash group gnus-newsrc-hashtb))
11221 (info (nth 2 entry))
11224 (if (or (not info) (not active))
11225 ;; There is no info on this group if it was, in fact,
11226 ;; killed. Gnus stores no information on killed groups, so
11227 ;; there's nothing to be done.
11228 ;; One could store the information somewhere temporarily,
11229 ;; perhaps... Hmmm...
11231 ;; Remove any negative articles numbers.
11232 (while (and unread (< (car unread) 0))
11233 (setq unread (cdr unread)))
11234 ;; Remove any expired article numbers
11235 (while (and unread (< (car unread) (car active)))
11236 (setq unread (cdr unread)))
11237 ;; Compute the ranges of read articles by looking at the list of
11238 ;; unread articles.
11240 (when (/= (car unread) prev)
11241 (push (if (= prev (1- (car unread))) prev
11242 (cons prev (1- (car unread))))
11244 (setq prev (1+ (car unread)))
11245 (setq unread (cdr unread)))
11246 (when (<= prev (cdr active))
11247 (push (cons prev (cdr active)) read))
11248 (setq read (if (> (length read) 1) (nreverse read) read))
11253 ;; Propagate the read marks to the backend.
11254 (when (gnus-check-backend-function 'request-set-mark group)
11255 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11256 (add (gnus-remove-from-range read (gnus-info-read info))))
11258 (unless (gnus-check-group group)
11259 (error "Can't open server for %s" group))
11260 (gnus-request-set-mark
11261 group (delq nil (list (if add (list add 'add '(read)))
11262 (if del (list del 'del '(read))))))
11264 `(gnus-request-set-mark
11267 (if del (list del 'add '(read)))
11268 (if add (list add 'del '(read))))))))))
11269 (set-buffer gnus-group-buffer)
11270 (gnus-undo-register
11272 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11273 (gnus-info-set-read ',info ',(gnus-info-read info))
11274 (gnus-get-unread-articles-in-group ',info
11275 (gnus-active ,group))
11276 (gnus-group-update-group ,group t)
11278 ;; Enter this list into the group info.
11279 (gnus-info-set-read info read)
11280 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11281 (gnus-get-unread-articles-in-group info (gnus-active group))
11284 (defun gnus-offer-save-summaries ()
11285 "Offer to save all active summary buffers."
11287 ;; Go through all buffers and find all summaries.
11288 (dolist (buffer (buffer-list))
11289 (when (and (setq buffer (buffer-name buffer))
11290 (string-match "Summary" buffer)
11292 (set-buffer buffer)
11293 ;; We check that this is, indeed, a summary buffer.
11294 (and (eq major-mode 'gnus-summary-mode)
11295 ;; Also make sure this isn't bogus.
11296 gnus-newsgroup-prepared
11297 ;; Also make sure that this isn't a
11298 ;; dead summary buffer.
11299 (not gnus-dead-summary-mode))))
11300 (push buffer buffers)))
11301 ;; Go through all these summary buffers and offer to save them.
11305 "Update summary buffer %s? "
11307 (switch-to-buffer buf)
11308 (gnus-summary-exit))
11312 ;;; @ for mime-partial
11315 (defun gnus-request-partial-message ()
11317 (let ((number (gnus-summary-article-number))
11318 (group gnus-newsgroup-name)
11319 (mother gnus-article-buffer))
11320 (set-buffer (get-buffer-create " *Partial Article*"))
11322 (setq mime-preview-buffer mother)
11323 (gnus-request-article-this-buffer number group)
11324 (mime-parse-buffer)
11327 (autoload 'mime-combine-message/partial-pieces-automatically
11329 "Internal method to combine message/partial messages automatically.")
11331 (mime-add-condition
11332 'action '((type . message)(subtype . partial)
11333 (major-mode . gnus-original-article-mode)
11334 (method . mime-combine-message/partial-pieces-automatically)
11335 (summary-buffer-exp . gnus-summary-buffer)
11336 (request-partial-message-method . gnus-request-partial-message)
11340 ;;; @ for message/rfc822
11343 (defun gnus-mime-extract-message/rfc822 (entity situation)
11344 "Burst a forwarded article."
11346 (set-buffer gnus-summary-buffer)
11347 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11348 gnus-newsgroup-name 'gnus-group-history))
11349 (gnus-group-marked (list group))
11352 (mime-insert-entity-content entity)
11353 (setq article (gnus-request-accept-article group)))
11354 (when (and (consp article)
11355 (numberp (setq article (cdr article))))
11356 (setq info (gnus-get-info group))
11357 (gnus-info-set-read info
11358 (gnus-remove-from-range (gnus-info-read info)
11360 (when (string-equal group gnus-newsgroup-name)
11362 (let (gnus-show-threads)
11363 (gnus-summary-goto-subject article t))
11364 (gnus-summary-clear-mark-forward 1))
11365 (set-buffer gnus-group-buffer)
11366 (gnus-group-get-new-news-this-group nil t)))))
11368 (mime-add-condition
11369 'action '((type . message)(subtype . rfc822)
11370 (major-mode . gnus-original-article-mode)
11371 (method . gnus-mime-extract-message/rfc822)
11375 (mime-add-condition
11376 'action '((type . message)(subtype . news)
11377 (major-mode . gnus-original-article-mode)
11378 (method . gnus-mime-extract-message/rfc822)
11382 (defun gnus-mime-extract-multipart (entity situation)
11383 (let ((children (mime-entity-children entity))
11384 mime-acting-situation-to-override
11387 (mime-play-entity (car children)
11388 (cons (assq 'mode situation)
11389 mime-acting-situation-to-override))
11390 (setq children (cdr children)))
11391 (if (setq f (cdr (assq 'after-method
11392 mime-acting-situation-to-override)))
11396 (mime-add-condition
11397 'action '((type . multipart)
11398 (method . gnus-mime-extract-multipart)
11407 (defun gnus-summary-inherit-default-charset ()
11408 "Import `default-mime-charset' from summary buffer.
11409 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11411 (if (buffer-live-p gnus-summary-buffer)
11412 (let (d-m-c d-m-c-u)
11413 (with-current-buffer gnus-summary-buffer
11414 (setq d-m-c (if (local-variable-p 'default-mime-charset
11415 gnus-summary-buffer)
11416 default-mime-charset
11419 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11420 gnus-summary-buffer)
11421 (symbol-value 'default-mime-charset-unlimited)
11424 (kill-local-variable 'default-mime-charset)
11425 (set (make-local-variable 'default-mime-charset) d-m-c))
11427 (kill-local-variable 'default-mime-charset-unlimited)
11428 (set (make-local-variable 'default-mime-charset-unlimited)
11431 (defun gnus-summary-setup-default-charset ()
11432 "Setup newsgroup default charset."
11433 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11435 (setq gnus-newsgroup-charset nil)
11436 (set (make-local-variable 'default-mime-charset) nil)
11437 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11438 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11439 (let ((ignored-charsets
11440 (or gnus-newsgroup-ephemeral-ignored-charsets
11442 (and gnus-newsgroup-name
11443 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11444 gnus-newsgroup-ignored-charsets)))
11446 (setq gnus-newsgroup-charset
11447 (or gnus-newsgroup-ephemeral-charset
11448 (when (and gnus-newsgroup-name
11449 (setq charset (gnus-parameter-charset
11450 gnus-newsgroup-name)))
11451 (make-local-variable 'default-mime-charset)
11452 (setq default-mime-charset charset))
11453 gnus-default-charset))
11454 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11455 ignored-charsets))))
11461 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11462 "Display the current article buffer fully MIME-buttonized.
11463 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11464 treated as multipart/mixed."
11466 (require 'gnus-art)
11467 (let ((gnus-unbuttonized-mime-types nil)
11468 (gnus-mime-display-multipart-as-mixed show-all-parts))
11469 (gnus-summary-show-article)))
11471 (defun gnus-summary-repair-multipart (article)
11472 "Add a Content-Type header to a multipart article without one."
11473 (interactive (list (gnus-summary-article-number)))
11474 (gnus-with-article article
11475 (message-narrow-to-head)
11476 (message-remove-header "Mime-Version")
11477 (goto-char (point-max))
11478 (insert "Mime-Version: 1.0\n")
11480 (when (search-forward "\n--" nil t)
11481 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11482 (message-narrow-to-head)
11483 (message-remove-header "Content-Type")
11484 (goto-char (point-max))
11485 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11488 (let (gnus-mark-article-hook)
11489 (gnus-summary-select-article t t nil article)))
11491 (defun gnus-summary-toggle-display-buttonized ()
11492 "Toggle the buttonizing of the article buffer."
11494 (require 'gnus-art)
11495 (if (setq gnus-inhibit-mime-unbuttonizing
11496 (not gnus-inhibit-mime-unbuttonizing))
11497 (let ((gnus-unbuttonized-mime-types nil))
11498 (gnus-summary-show-article))
11499 (gnus-summary-show-article)))
11502 ;;; Intelli-mouse commmands
11505 (defun gnus-wheel-summary-scroll (event)
11507 (let ((amount (if (memq 'shift (event-modifiers event))
11508 (car gnus-wheel-scroll-amount)
11509 (cdr gnus-wheel-scroll-amount)))
11510 (direction (- (* (static-if (featurep 'xemacs)
11511 (event-button event)
11512 (cond ((eq 'mouse-4 (event-basic-type event))
11514 ((eq 'mouse-5 (event-basic-type event))
11518 (gnus-summary-scroll-up (* amount direction))
11519 (when (gnus-eval-in-buffer-window gnus-article-buffer
11522 (and (if (< 0 direction)
11523 (gnus-article-next-page 0)
11524 (gnus-article-prev-page 0)
11526 (if (setq edge (get-text-property
11527 (point-min) 'gnus-wheel-edge))
11528 (setq edge (* edge direction))
11531 (let ((buffer-read-only nil)
11532 (inhibit-read-only t))
11533 (put-text-property (point-min) (point-max)
11534 'gnus-wheel-edge direction)
11536 (or (> edge gnus-wheel-edge-resistance)
11537 (let ((buffer-read-only nil)
11538 (inhibit-read-only t))
11539 (put-text-property (point-min) (point-max)
11541 (* (1+ edge) direction))
11543 (eq last-command 'gnus-wheel-summary-scroll))))
11544 (gnus-summary-next-article nil nil (minusp direction)))))
11546 (defun gnus-wheel-install ()
11547 "Enable mouse wheel support on summary window."
11548 (when gnus-use-wheel
11550 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11552 (define-key gnus-summary-mode-map key
11553 'gnus-wheel-summary-scroll)))))
11555 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11558 ;;; Traditional PGP commmands
11561 (defun gnus-summary-decrypt-article (&optional force)
11562 "Decrypt the current article in traditional PGP way.
11563 This will have permanent effect only in mail groups.
11564 If FORCE is non-nil, allow editing of articles even in read-only
11567 (gnus-summary-select-article t)
11568 (gnus-eval-in-buffer-window gnus-article-buffer
11572 (goto-char (point-min))
11573 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11574 (error "Not a traditional PGP message!"))
11575 (let ((armor-start (match-beginning 0)))
11576 (if (and (pgg-decrypt-region armor-start (point-max))
11577 (or force (not (gnus-group-read-only-p))))
11578 (let ((inhibit-read-only t)
11580 (delete-region armor-start
11582 (re-search-forward "^-+END PGP" nil t)
11583 (beginning-of-line 2)
11585 (insert-buffer-substring pgg-output-buffer))))))))
11587 (defun gnus-summary-verify-article ()
11588 "Verify the current article in traditional PGP way."
11591 (set-buffer gnus-original-article-buffer)
11592 (goto-char (point-min))
11593 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11594 (error "Not a traditional PGP message!"))
11595 (re-search-forward "^-+END PGP" nil t)
11596 (beginning-of-line 2)
11597 (call-interactively (function pgg-verify-region))))
11600 ;;; Generic summary marking commands
11603 (defvar gnus-summary-marking-alist
11604 '((read gnus-del-mark "d")
11605 (unread gnus-unread-mark "u")
11606 (ticked gnus-ticked-mark "!")
11607 (dormant gnus-dormant-mark "?")
11608 (expirable gnus-expirable-mark "e"))
11609 "An alist of names/marks/keystrokes.")
11611 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11612 (defvar gnus-summary-mark-map)
11614 (defun gnus-summary-make-all-marking-commands ()
11615 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11616 (dolist (elem gnus-summary-marking-alist)
11617 (apply 'gnus-summary-make-marking-command elem)))
11619 (defun gnus-summary-make-marking-command (name mark keystroke)
11620 (let ((map (make-sparse-keymap)))
11621 (define-key gnus-summary-generic-mark-map keystroke map)
11622 (dolist (lway `((next "next" next nil "n")
11623 (next-unread "next unread" next t "N")
11624 (prev "previous" prev nil "p")
11625 (prev-unread "previous unread" prev t "P")
11626 (nomove "" nil nil ,keystroke)))
11627 (let ((func (gnus-summary-make-marking-command-1
11628 mark (car lway) lway name)))
11629 (setq func (eval func))
11630 (define-key map (nth 4 lway) func)))))
11632 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11634 (format "gnus-summary-put-mark-as-%s%s"
11635 name (if (eq way 'nomove)
11637 (concat "-" (symbol-name way)))))
11640 "Mark the current article as %s%s.
11641 If N, the prefix, then repeat N times.
11642 If N is negative, move in reverse order.
11643 The difference between N and the actual number of articles marked is
11645 name (car (cdr lway)))
11647 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11649 (defun gnus-summary-generic-mark (n mark move unread)
11650 "Mark N articles with MARK."
11651 (unless (eq major-mode 'gnus-summary-mode)
11652 (error "This command can only be used in the summary buffer"))
11653 (gnus-summary-show-thread)
11656 ((eq move 'next) 1)
11657 ((eq move 'prev) -1)
11659 (if (zerop nummove)
11663 nummove (* -1 nummove))))
11664 (while (and (> n 0)
11665 (gnus-summary-mark-article nil mark)
11666 (zerop (gnus-summary-next-subject nummove unread t)))
11669 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11670 (gnus-summary-recenter)
11671 (gnus-summary-position-point)
11672 (gnus-set-mode-line 'summary)
11675 (defun gnus-summary-insert-articles (articles)
11676 (when (setq articles
11677 (gnus-sorted-difference articles
11678 (mapcar (lambda (h)
11679 (mail-header-number h))
11680 gnus-newsgroup-headers)))
11681 (setq gnus-newsgroup-headers
11683 gnus-newsgroup-headers
11684 (gnus-fetch-headers articles)
11685 'gnus-article-sort-by-number))
11686 ;; Suppress duplicates?
11687 (when gnus-suppress-duplicates
11688 (gnus-dup-suppress-articles))
11690 ;; We might want to build some more threads first.
11691 (when (and gnus-fetch-old-headers
11692 (eq gnus-headers-retrieved-by 'nov))
11693 (if (eq gnus-fetch-old-headers 'invisible)
11694 (gnus-build-all-threads)
11695 (gnus-build-old-threads)))
11696 ;; Let the Gnus agent mark articles as read.
11698 (gnus-agent-get-undownloaded-list))
11699 ;; Remove list identifiers from subject
11700 (when gnus-list-identifiers
11701 (gnus-summary-remove-list-identifiers))
11702 ;; First and last article in this newsgroup.
11703 (when gnus-newsgroup-headers
11704 (setq gnus-newsgroup-begin
11705 (mail-header-number (car gnus-newsgroup-headers))
11707 (mail-header-number
11708 (gnus-last-element gnus-newsgroup-headers))))
11709 (when gnus-use-scoring
11710 (gnus-possibly-score-headers))))
11712 (defun gnus-summary-insert-old-articles (&optional all)
11713 "Insert all old articles in this group.
11714 If ALL is non-nil, already read articles become readable.
11715 If ALL is a number, fetch this number of articles."
11718 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11721 ;; Some nntp servers lie about their active range. When
11722 ;; this happens, the active range can be in the millions.
11723 ;; Use a compressed range to avoid creating a huge list.
11724 (gnus-range-difference (list gnus-newsgroup-active) old))
11725 (setq len (gnus-range-length older))
11730 (let ((older-range (nreverse older)))
11734 (let* ((r (pop older-range))
11735 (min (if (numberp r) r (car r)))
11736 (max (if (numberp r) r (cdr r))))
11737 (while (and (<= min max)
11742 (setq older (gnus-uncompress-range older))))
11744 (setq older (gnus-uncompress-range older)))
11746 (when (and (numberp gnus-large-newsgroup)
11747 (> len gnus-large-newsgroup))
11748 (let* ((cursor-in-echo-area nil)
11749 (initial (gnus-parameter-large-newsgroup-initial
11750 gnus-newsgroup-name))
11754 "How many articles from %s (%s %d): "
11756 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11757 (if initial "max" "default")
11760 (cons (number-to-string initial)
11762 (unless (string-match "^[ \t]*$" input)
11763 (setq all (string-to-number input))
11765 (let ((older-range (nreverse older)))
11769 (let* ((r (pop older-range))
11770 (min (if (numberp r) r (car r)))
11771 (max (if (numberp r) r (cdr r))))
11772 (while (and (<= min max)
11776 max (1- max))))))))))
11777 (setq older (gnus-uncompress-range older))))
11779 (message "No old news.")
11780 (gnus-summary-insert-articles older)
11781 (gnus-summary-limit (gnus-sorted-nunion old older))))
11782 (gnus-summary-position-point)))
11784 (defun gnus-summary-insert-new-articles ()
11785 "Insert all new articles in this group."
11788 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11789 (old-active gnus-newsgroup-active)
11790 (nnmail-fetched-sources (list t))
11792 (setq gnus-newsgroup-active
11793 (gnus-activate-group gnus-newsgroup-name 'scan))
11794 (setq i (cdr gnus-newsgroup-active))
11795 (while (> i (cdr old-active))
11799 (message "No gnus is bad news.")
11800 (gnus-summary-insert-articles new)
11801 (setq gnus-newsgroup-unreads
11802 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11803 (gnus-summary-limit (gnus-sorted-nunion old new))))
11804 (gnus-summary-position-point)))
11806 (gnus-summary-make-all-marking-commands)
11808 (gnus-ems-redefine)
11810 (provide 'gnus-sum)
11812 (run-hooks 'gnus-sum-load-hook)
11814 ;;; gnus-sum.el ends here