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 `Z n' 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 (defcustom gnus-show-all-headers nil
383 "*If non-nil, don't hide any headers."
384 :group 'gnus-article-hiding
385 :group 'gnus-article-headers
388 (defcustom gnus-summary-ignore-duplicates nil
389 "*If non-nil, ignore articles with identical Message-ID headers."
393 (defcustom gnus-single-article-buffer t
394 "*If non-nil, display all articles in the same buffer.
395 If nil, each group will get its own article buffer."
396 :group 'gnus-article-various
399 (defcustom gnus-break-pages t
400 "*If non-nil, do page breaking on articles.
401 The page delimiter is specified by the `gnus-page-delimiter'
403 :group 'gnus-article-various
406 (defcustom gnus-show-mime t
407 "*If non-nil, do mime processing of articles.
408 The articles will simply be fed to the function given by
409 `gnus-article-display-method-for-mime'."
410 :group 'gnus-article-mime
413 (defcustom gnus-move-split-methods nil
414 "*Variable used to suggest where articles are to be moved to.
415 It uses the same syntax as the `gnus-split-methods' variable.
416 However, whereas `gnus-split-methods' specifies file names as targets,
417 this variable specifies group names."
418 :group 'gnus-summary-mail
419 :type '(repeat (choice (list :value (fun) function)
420 (cons :value ("" "") regexp (repeat string))
423 (defcustom gnus-unread-mark ?\ ;;;Whitespace
424 "*Mark used for unread articles."
425 :group 'gnus-summary-marks
428 (defcustom gnus-ticked-mark ?!
429 "*Mark used for ticked articles."
430 :group 'gnus-summary-marks
433 (defcustom gnus-dormant-mark ??
434 "*Mark used for dormant articles."
435 :group 'gnus-summary-marks
438 (defcustom gnus-del-mark ?r
439 "*Mark used for del'd articles."
440 :group 'gnus-summary-marks
443 (defcustom gnus-read-mark ?R
444 "*Mark used for read articles."
445 :group 'gnus-summary-marks
448 (defcustom gnus-expirable-mark ?E
449 "*Mark used for expirable articles."
450 :group 'gnus-summary-marks
453 (defcustom gnus-killed-mark ?K
454 "*Mark used for killed articles."
455 :group 'gnus-summary-marks
458 (defcustom gnus-spam-mark ?H
459 "*Mark used for spam articles."
460 :group 'gnus-summary-marks
463 (defcustom gnus-souped-mark ?F
464 "*Mark used for souped articles."
465 :group 'gnus-summary-marks
468 (defcustom gnus-kill-file-mark ?X
469 "*Mark used for articles killed by kill files."
470 :group 'gnus-summary-marks
473 (defcustom gnus-low-score-mark ?Y
474 "*Mark used for articles with a low score."
475 :group 'gnus-summary-marks
478 (defcustom gnus-catchup-mark ?C
479 "*Mark used for articles that are caught up."
480 :group 'gnus-summary-marks
483 (defcustom gnus-replied-mark ?A
484 "*Mark used for articles that have been replied to."
485 :group 'gnus-summary-marks
488 (defcustom gnus-forwarded-mark ?F
489 "*Mark used for articles that have been forwarded."
490 :group 'gnus-summary-marks
493 (defcustom gnus-recent-mark ?N
494 "*Mark used for articles that are recent."
495 :group 'gnus-summary-marks
498 (defcustom gnus-cached-mark ?*
499 "*Mark used for articles that are in the cache."
500 :group 'gnus-summary-marks
503 (defcustom gnus-saved-mark ?S
504 "*Mark used for articles that have been saved."
505 :group 'gnus-summary-marks
508 (defcustom gnus-unseen-mark ?.
509 "*Mark used for articles that haven't been seen."
510 :group 'gnus-summary-marks
513 (defcustom gnus-no-mark ?\ ;;;Whitespace
514 "*Mark used for articles that have no other secondary mark."
515 :group 'gnus-summary-marks
518 (defcustom gnus-ancient-mark ?O
519 "*Mark used for ancient articles."
520 :group 'gnus-summary-marks
523 (defcustom gnus-sparse-mark ?Q
524 "*Mark used for sparsely reffed articles."
525 :group 'gnus-summary-marks
528 (defcustom gnus-canceled-mark ?G
529 "*Mark used for canceled articles."
530 :group 'gnus-summary-marks
533 (defcustom gnus-duplicate-mark ?M
534 "*Mark used for duplicate articles."
535 :group 'gnus-summary-marks
538 (defcustom gnus-undownloaded-mark ?-
539 "*Mark used for articles that weren't downloaded."
540 :group 'gnus-summary-marks
543 (defcustom gnus-downloaded-mark ?+
544 "*Mark used for articles that were downloaded."
545 :group 'gnus-summary-marks
548 (defcustom gnus-downloadable-mark ?%
549 "*Mark used for articles that are to be downloaded."
550 :group 'gnus-summary-marks
553 (defcustom gnus-unsendable-mark ?=
554 "*Mark used for articles that won't be sent."
555 :group 'gnus-summary-marks
558 (defcustom gnus-score-over-mark ?+
559 "*Score mark used for articles with high scores."
560 :group 'gnus-summary-marks
563 (defcustom gnus-score-below-mark ?-
564 "*Score mark used for articles with low scores."
565 :group 'gnus-summary-marks
568 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
569 "*There is no thread under the article."
570 :group 'gnus-summary-marks
573 (defcustom gnus-not-empty-thread-mark ?=
574 "*There is a thread under the article."
575 :group 'gnus-summary-marks
578 (defcustom gnus-view-pseudo-asynchronously nil
579 "*If non-nil, Gnus will view pseudo-articles asynchronously."
580 :group 'gnus-extract-view
583 (defcustom gnus-auto-expirable-marks
584 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
585 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
586 gnus-souped-mark gnus-duplicate-mark)
587 "*The list of marks converted into expiration if a group is auto-expirable."
590 :type '(repeat character))
592 (defcustom gnus-inhibit-user-auto-expire t
593 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
598 (defcustom gnus-view-pseudos nil
599 "*If `automatic', pseudo-articles will be viewed automatically.
600 If `not-confirm', pseudos will be viewed automatically, and the user
601 will not be asked to confirm the command."
602 :group 'gnus-extract-view
603 :type '(choice (const :tag "off" nil)
605 (const not-confirm)))
607 (defcustom gnus-view-pseudos-separately t
608 "*If non-nil, one pseudo-article will be created for each file to be viewed.
609 If nil, all files that use the same viewing command will be given as a
610 list of parameters to that command."
611 :group 'gnus-extract-view
614 (defcustom gnus-insert-pseudo-articles t
615 "*If non-nil, insert pseudo-articles when decoding articles."
616 :group 'gnus-extract-view
619 (defcustom gnus-summary-dummy-line-format
621 "*The format specification for the dummy roots in the summary buffer.
622 It works along the same lines as a normal formatting string,
623 with some simple extensions.
627 General format specifiers can also be used.
628 See `(gnus)Formatting Variables'."
629 :link '(custom-manual "(gnus)Formatting Variables")
630 :group 'gnus-threading
633 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
634 "*The format specification for the summary mode line.
635 It works along the same lines as a normal formatting string,
636 with some simple extensions:
639 %p Unprefixed group name
640 %A Current article number
641 %z Current article score
643 %U Number of unread articles in the group
644 %e Number of unselected articles in the group
645 %Z A string with unread/unselected article counts
646 %g Shortish group name
647 %S Subject of the current article
649 %s Current score file name
650 %d Number of dormant articles
651 %r Number of articles that have been marked as read in this session
652 %E Number of articles expunged by the score files"
653 :group 'gnus-summary-format
656 (defcustom gnus-list-identifiers nil
657 "Regexp that matches list identifiers to be removed from subject.
658 This can also be a list of regexps."
660 :group 'gnus-summary-format
661 :group 'gnus-article-hiding
662 :type '(choice (const :tag "none" nil)
664 (repeat :value (".*") regexp)))
666 (defcustom gnus-summary-mark-below 0
667 "*Mark all articles with a score below this variable as read.
668 This variable is local to each summary buffer and usually set by the
670 :group 'gnus-score-default
673 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
674 "*List of functions used for sorting articles in the summary buffer.
676 Each function takes two articles and returns non-nil if the first
677 article should be sorted before the other. If you use more than one
678 function, the primary sort function should be the last. You should
679 probably always include `gnus-article-sort-by-number' in the list of
680 sorting functions -- preferably first. Also note that sorting by date
681 is often much slower than sorting by number, and the sorting order is
682 very similar. (Sorting by date means sorting by the time the message
683 was sent, sorting by number means sorting by arrival time.)
685 Ready-made functions include `gnus-article-sort-by-number',
686 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
687 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
688 and `gnus-article-sort-by-score'.
690 When threading is turned on, the variable `gnus-thread-sort-functions'
691 controls how articles are sorted."
692 :group 'gnus-summary-sort
693 :type '(repeat (choice (function-item gnus-article-sort-by-number)
694 (function-item gnus-article-sort-by-author)
695 (function-item gnus-article-sort-by-subject)
696 (function-item gnus-article-sort-by-date)
697 (function-item gnus-article-sort-by-score)
698 (function-item gnus-article-sort-by-random)
699 (function :tag "other"))))
701 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
702 "*List of functions used for sorting threads in the summary buffer.
703 By default, threads are sorted by article number.
705 Each function takes two threads and returns non-nil if the first
706 thread should be sorted before the other. If you use more than one
707 function, the primary sort function should be the last. You should
708 probably always include `gnus-thread-sort-by-number' in the list of
709 sorting functions -- preferably first. Also note that sorting by date
710 is often much slower than sorting by number, and the sorting order is
711 very similar. (Sorting by date means sorting by the time the message
712 was sent, sorting by number means sorting by arrival time.)
714 Ready-made functions include `gnus-thread-sort-by-number',
715 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
716 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
717 `gnus-thread-sort-by-most-recent-number',
718 `gnus-thread-sort-by-most-recent-date',
719 `gnus-thread-sort-by-random', and
720 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
722 When threading is turned off, the variable
723 `gnus-article-sort-functions' controls how articles are sorted."
724 :group 'gnus-summary-sort
725 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
726 (function-item gnus-thread-sort-by-author)
727 (function-item gnus-thread-sort-by-subject)
728 (function-item gnus-thread-sort-by-date)
729 (function-item gnus-thread-sort-by-score)
730 (function-item gnus-thread-sort-by-total-score)
731 (function-item gnus-thread-sort-by-random)
732 (function :tag "other"))))
734 (defcustom gnus-thread-score-function '+
735 "*Function used for calculating the total score of a thread.
737 The function is called with the scores of the article and each
738 subthread and should then return the score of the thread.
740 Some functions you can use are `+', `max', or `min'."
741 :group 'gnus-summary-sort
744 (defcustom gnus-summary-expunge-below nil
745 "All articles that have a score less than this variable will be expunged.
746 This variable is local to the summary buffers."
747 :group 'gnus-score-default
748 :type '(choice (const :tag "off" nil)
751 (defcustom gnus-thread-expunge-below nil
752 "All threads that have a total score less than this variable will be expunged.
753 See `gnus-thread-score-function' for en explanation of what a
756 This variable is local to the summary buffers."
757 :group 'gnus-threading
758 :group 'gnus-score-default
759 :type '(choice (const :tag "off" nil)
762 (defcustom gnus-summary-mode-hook nil
763 "*A hook for Gnus summary mode.
764 This hook is run before any variables are set in the summary buffer."
765 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
766 :group 'gnus-summary-various
769 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
770 (when (featurep 'xemacs)
771 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
772 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
773 (add-hook 'gnus-summary-mode-hook
774 'gnus-xmas-switch-horizontal-scrollbar-off))
776 (defcustom gnus-summary-menu-hook nil
777 "*Hook run after the creation of the summary mode menu."
778 :group 'gnus-summary-visual
781 (defcustom gnus-summary-exit-hook nil
782 "*A hook called on exit from the summary buffer.
783 It will be called with point in the group buffer."
784 :group 'gnus-summary-exit
787 (defcustom gnus-summary-prepare-hook nil
788 "*A hook called after the summary buffer has been generated.
789 If you want to modify the summary buffer, you can use this hook."
790 :group 'gnus-summary-various
793 (defcustom gnus-summary-prepared-hook nil
794 "*A hook called as the last thing after the summary buffer has been generated."
795 :group 'gnus-summary-various
798 (defcustom gnus-summary-generate-hook nil
799 "*A hook run just before generating the summary buffer.
800 This hook is commonly used to customize threading variables and the
802 :group 'gnus-summary-various
805 (defcustom gnus-select-group-hook nil
806 "*A hook called when a newsgroup is selected.
808 If you'd like to simplify subjects like the
809 `gnus-summary-next-same-subject' command does, you can use the
812 (add-hook gnus-select-group-hook
814 (mapcar (lambda (header)
815 (mail-header-set-subject
817 (gnus-simplify-subject
818 (mail-header-subject header) 're-only)))
819 gnus-newsgroup-headers)))"
820 :group 'gnus-group-select
823 (defcustom gnus-select-article-hook nil
824 "*A hook called when an article is selected."
825 :group 'gnus-summary-choose
826 :options '(gnus-agent-fetch-selected-article)
829 (defcustom gnus-visual-mark-article-hook
830 (list 'gnus-highlight-selected-summary)
831 "*Hook run after selecting an article in the summary buffer.
832 It is meant to be used for highlighting the article in some way. It
833 is not run if `gnus-visual' is nil."
834 :group 'gnus-summary-visual
837 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
838 "*A hook called before parsing the headers."
842 (defcustom gnus-exit-group-hook nil
843 "*A hook called when exiting summary mode.
844 This hook is not called from the non-updating exit commands like `Q'."
848 (defcustom gnus-summary-update-hook
849 (list 'gnus-summary-highlight-line)
850 "*A hook called when a summary line is changed.
851 The hook will not be called if `gnus-visual' is nil.
853 The default function `gnus-summary-highlight-line' will
854 highlight the line according to the `gnus-summary-highlight'
856 :group 'gnus-summary-visual
859 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
860 "*A hook called when an article is selected for the first time.
861 The hook is intended to mark an article as read (or unread)
862 automatically when it is selected."
863 :group 'gnus-summary-choose
866 (defcustom gnus-group-no-more-groups-hook nil
867 "*A hook run when returning to group mode having no more (unread) groups."
868 :group 'gnus-group-select
871 (defcustom gnus-ps-print-hook nil
872 "*A hook run before ps-printing something from Gnus."
876 (defcustom gnus-summary-display-arrow
877 (and (fboundp 'display-graphic-p)
879 "*If non-nil, display an arrow highlighting the current article."
884 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
885 "Face used for highlighting the current article in the summary buffer."
886 :group 'gnus-summary-visual
889 (defvar gnus-tmp-downloaded nil)
891 (defcustom gnus-summary-highlight
892 '(((eq mark gnus-canceled-mark)
893 . gnus-summary-cancelled-face)
894 ((and uncached (> score default-high))
895 . gnus-summary-high-undownloaded-face)
896 ((and uncached (< score default-low))
897 . gnus-summary-low-undownloaded-face)
899 . gnus-summary-normal-undownloaded-face)
900 ((and (> score default-high)
901 (or (eq mark gnus-dormant-mark)
902 (eq mark gnus-ticked-mark)))
903 . gnus-summary-high-ticked-face)
904 ((and (< score default-low)
905 (or (eq mark gnus-dormant-mark)
906 (eq mark gnus-ticked-mark)))
907 . gnus-summary-low-ticked-face)
908 ((or (eq mark gnus-dormant-mark)
909 (eq mark gnus-ticked-mark))
910 . gnus-summary-normal-ticked-face)
911 ((and (> score default-high) (eq mark gnus-ancient-mark))
912 . gnus-summary-high-ancient-face)
913 ((and (< score default-low) (eq mark gnus-ancient-mark))
914 . gnus-summary-low-ancient-face)
915 ((eq mark gnus-ancient-mark)
916 . gnus-summary-normal-ancient-face)
917 ((and (> score default-high) (eq mark gnus-unread-mark))
918 . gnus-summary-high-unread-face)
919 ((and (< score default-low) (eq mark gnus-unread-mark))
920 . gnus-summary-low-unread-face)
921 ((eq mark gnus-unread-mark)
922 . gnus-summary-normal-unread-face)
923 ((> score default-high)
924 . gnus-summary-high-read-face)
925 ((< score default-low)
926 . gnus-summary-low-read-face)
928 . gnus-summary-normal-read-face))
929 "*Controls the highlighting of summary buffer lines.
931 A list of (FORM . FACE) pairs. When deciding how a a particular
932 summary line should be displayed, each form is evaluated. The content
933 of the face field after the first true form is used. You can change
934 how those summary lines are displayed, by editing the face field.
936 You can use the following variables in the FORM field.
938 score: The article's score
939 default: The default article score.
940 default-high: The default score for high scored articles.
941 default-low: The default score for low scored articles.
942 below: The score below which articles are automatically marked as read.
943 mark: The articles mark."
944 :group 'gnus-summary-visual
945 :type '(repeat (cons (sexp :tag "Form" nil)
948 (defcustom gnus-alter-header-function nil
949 "Function called to allow alteration of article header structures.
950 The function is called with one parameter, the article header vector,
951 which it may alter in any way."
952 :type '(choice (const :tag "None" nil)
954 :group 'gnus-summary)
956 (defvar gnus-decode-encoded-word-function
957 (mime-find-field-decoder 'From 'nov)
958 "Variable that says which function should be used to decode a string with encoded words.")
960 (defcustom gnus-extra-headers '(To Newsgroups)
961 "*Extra headers to parse."
964 :type '(repeat symbol))
966 (defcustom gnus-ignored-from-addresses
967 (and user-mail-address (regexp-quote user-mail-address))
968 "*Regexp of From headers that may be suppressed in favor of To headers."
973 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
974 "List of charsets that should be ignored.
975 When these charsets are used in the \"charset\" parameter, the
976 default charset will be used instead."
978 :type '(repeat symbol)
979 :group 'gnus-charset)
981 (gnus-define-group-parameter
985 "Return the ignored charsets of GROUP."
986 :variable gnus-group-ignored-charsets-alist
988 '(("alt\\.chinese\\.text" iso-8859-1))
990 "Alist of regexps (to match group names) and charsets that should be ignored.
991 When these charsets are used in the \"charset\" parameter, the
992 default charset will be used instead."
993 :variable-group gnus-charset
994 :variable-type '(repeat (cons (regexp :tag "Group")
996 :parameter-type '(choice :tag "Ignored charsets"
999 :parameter-document "\
1000 List of charsets that should be ignored.
1002 When these charsets are used in the \"charset\" parameter, the
1003 default charset will be used instead.")
1005 (defcustom gnus-group-highlight-words-alist nil
1006 "Alist of group regexps and highlight regexps.
1007 This variable uses the same syntax as `gnus-emphasis-alist'."
1009 :type '(repeat (cons (regexp :tag "Group")
1010 (repeat (list (regexp :tag "Highlight regexp")
1011 (number :tag "Group for entire word" 0)
1012 (number :tag "Group for displayed part" 0)
1014 gnus-emphasis-highlight-words)))))
1015 :group 'gnus-summary-visual)
1017 (defcustom gnus-use-wheel nil
1018 "Use Intelli-mouse on summary movement"
1020 :group 'gnus-summary-maneuvering)
1022 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1023 "Amount to scroll messages by spinning the mouse wheel.
1024 This is actually a cons cell, where the first item is the amount to scroll
1025 on a normal wheel event, and the second is the amount to scroll when the
1026 wheel is moved with the shift key depressed."
1027 :type '(cons (integer :tag "Shift") integer)
1028 :group 'gnus-summary-maneuvering)
1030 (defcustom gnus-wheel-edge-resistance 2
1031 "How hard it should be to change the current article
1032 by moving the mouse over the edge of the article window."
1034 :group 'gnus-summary-maneuvering)
1036 (defcustom gnus-summary-show-article-charset-alist
1038 "Alist of number and charset.
1039 The article will be shown with the charset corresponding to the
1041 For example: ((1 . cn-gb-2312) (2 . big5))."
1043 :type '(repeat (cons (number :tag "Argument" 1)
1044 (symbol :tag "Charset")))
1045 :group 'gnus-charset)
1047 (defcustom gnus-preserve-marks t
1048 "Whether marks are preserved when moving, copying and respooling messages."
1051 :group 'gnus-summary-marks)
1053 (defcustom gnus-alter-articles-to-read-function nil
1054 "Function to be called to alter the list of articles to be selected."
1055 :type '(choice (const nil) function)
1056 :group 'gnus-summary)
1058 (defcustom gnus-orphan-score nil
1059 "*All orphans get this score added. Set in the score file."
1060 :group 'gnus-score-default
1061 :type '(choice (const nil)
1064 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1065 "*A regexp to match MIME parts when saving multiple parts of a message
1066 with gnus-summary-save-parts (X m). This regexp will be used by default
1067 when prompting the user for which type of files to save."
1068 :group 'gnus-summary
1071 (defcustom gnus-read-all-available-headers nil
1072 "Whether Gnus should parse all headers made available to it.
1073 This is mostly relevant for slow backends where the user may
1074 wish to widen the summary buffer to include all headers
1075 that were fetched. Say, for nnultimate groups."
1076 :group 'gnus-summary
1077 :type '(choice boolean regexp))
1079 (defcustom gnus-summary-muttprint-program "muttprint"
1080 "Command (and optional arguments) used to run Muttprint."
1082 :group 'gnus-summary
1085 (defcustom gnus-article-loose-mime nil
1086 "If non-nil, don't require MIME-Version header.
1087 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1088 supply the MIME-Version header or deliberately strip it From the mail.
1089 Set it to non-nil, Gnus will treat some articles as MIME even if
1090 the MIME-Version header is missed."
1093 :group 'gnus-article)
1095 (defcustom gnus-article-emulate-mime t
1096 "If non-nil, use MIME emulation for uuencode and the like.
1097 This means that Gnus will search message bodies for text that look
1098 like uuencoded bits, yEncoded bits, and so on, and present that using
1099 the normal Gnus MIME machinery."
1101 :group 'gnus-article)
1103 ;;; Internal variables
1105 (defvar gnus-summary-display-cache nil)
1106 (defvar gnus-article-mime-handles nil)
1107 (defvar gnus-article-decoded-p nil)
1108 (defvar gnus-article-charset nil)
1109 (defvar gnus-article-ignored-charsets nil)
1110 (defvar gnus-scores-exclude-files nil)
1111 (defvar gnus-page-broken nil)
1113 (defvar gnus-original-article nil)
1114 (defvar gnus-article-internal-prepare-hook nil)
1115 (defvar gnus-newsgroup-process-stack nil)
1117 (defvar gnus-thread-indent-array nil)
1118 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1119 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1120 "Function called to sort the articles within a thread after it has been gathered together.")
1122 (defvar gnus-summary-save-parts-type-history nil)
1123 (defvar gnus-summary-save-parts-last-directory nil)
1125 ;; Avoid highlighting in kill files.
1126 (defvar gnus-summary-inhibit-highlight nil)
1127 (defvar gnus-newsgroup-selected-overlay nil)
1128 (defvar gnus-inhibit-limiting nil)
1129 (defvar gnus-newsgroup-adaptive-score-file nil)
1130 (defvar gnus-current-score-file nil)
1131 (defvar gnus-current-move-group nil)
1132 (defvar gnus-current-copy-group nil)
1133 (defvar gnus-current-crosspost-group nil)
1134 (defvar gnus-newsgroup-display nil)
1136 (defvar gnus-newsgroup-dependencies nil)
1137 (defvar gnus-newsgroup-adaptive nil)
1138 (defvar gnus-summary-display-article-function nil)
1139 (defvar gnus-summary-highlight-line-function nil
1140 "Function called after highlighting a summary line.")
1142 (defvar gnus-summary-line-format-alist
1143 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1144 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1145 (?s gnus-tmp-subject-or-nil ?s)
1146 (?n gnus-tmp-name ?s)
1147 (?A (std11-address-string
1148 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1149 (?a (or (std11-full-name-string
1150 (car (mime-entity-read-field gnus-tmp-header 'From)))
1152 (?F gnus-tmp-from ?s)
1153 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1154 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1155 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1156 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1157 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1158 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1159 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1160 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1161 (?L gnus-tmp-lines ?s)
1162 (?O gnus-tmp-downloaded ?c)
1163 (?I gnus-tmp-indentation ?s)
1164 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1165 (?R gnus-tmp-replied ?c)
1166 (?\[ gnus-tmp-opening-bracket ?c)
1167 (?\] gnus-tmp-closing-bracket ?c)
1168 (?\> (make-string gnus-tmp-level ? ) ?s)
1169 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1170 (?i gnus-tmp-score ?d)
1171 (?z gnus-tmp-score-char ?c)
1172 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1173 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1174 (?U gnus-tmp-unread ?c)
1175 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1177 (?t (gnus-summary-number-of-articles-in-thread
1178 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1180 (?e (gnus-summary-number-of-articles-in-thread
1181 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1183 (?u gnus-tmp-user-defined ?s)
1184 (?P (gnus-pick-line-number) ?d)
1185 (?B gnus-tmp-thread-tree-header-string ?s)
1186 (user-date (gnus-user-date
1187 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1188 "An alist of format specifications that can appear in summary lines.
1189 These are paired with what variables they correspond with, along with
1190 the type of the variable (string, integer, character, etc).")
1192 (defvar gnus-summary-dummy-line-format-alist
1193 `((?S gnus-tmp-subject ?s)
1194 (?N gnus-tmp-number ?d)
1195 (?u gnus-tmp-user-defined ?s)))
1197 (defvar gnus-summary-mode-line-format-alist
1198 `((?G gnus-tmp-group-name ?s)
1199 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1200 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1201 (?A gnus-tmp-article-number ?d)
1202 (?Z gnus-tmp-unread-and-unselected ?s)
1203 (?V gnus-version ?s)
1204 (?U gnus-tmp-unread-and-unticked ?d)
1205 (?S gnus-tmp-subject ?s)
1206 (?e gnus-tmp-unselected ?d)
1207 (?u gnus-tmp-user-defined ?s)
1208 (?d (length gnus-newsgroup-dormant) ?d)
1209 (?t (length gnus-newsgroup-marked) ?d)
1210 (?h (length gnus-newsgroup-spam-marked) ?d)
1211 (?r (length gnus-newsgroup-reads) ?d)
1212 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1213 (?E gnus-newsgroup-expunged-tally ?d)
1214 (?s (gnus-current-score-file-nondirectory) ?s)))
1216 (defvar gnus-last-search-regexp nil
1217 "Default regexp for article search command.")
1219 (defvar gnus-summary-search-article-matched-data nil
1220 "Last matched data of article search command. It is the local variable
1221 in `gnus-article-buffer' which consists of the list of start position,
1222 end position and text.")
1224 (defvar gnus-last-shell-command nil
1225 "Default shell command on article.")
1227 (defvar gnus-newsgroup-agentized nil
1228 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1229 (defvar gnus-newsgroup-begin nil)
1230 (defvar gnus-newsgroup-end nil)
1231 (defvar gnus-newsgroup-last-rmail nil)
1232 (defvar gnus-newsgroup-last-mail nil)
1233 (defvar gnus-newsgroup-last-folder nil)
1234 (defvar gnus-newsgroup-last-file nil)
1235 (defvar gnus-newsgroup-auto-expire nil)
1236 (defvar gnus-newsgroup-active nil)
1238 (defvar gnus-newsgroup-data nil)
1239 (defvar gnus-newsgroup-data-reverse nil)
1240 (defvar gnus-newsgroup-limit nil)
1241 (defvar gnus-newsgroup-limits nil)
1243 (defvar gnus-newsgroup-unreads nil
1244 "Sorted list of unread articles in the current newsgroup.")
1246 (defvar gnus-newsgroup-unselected nil
1247 "Sorted list of unselected unread articles in the current newsgroup.")
1249 (defvar gnus-newsgroup-reads nil
1250 "Alist of read articles and article marks in the current newsgroup.")
1252 (defvar gnus-newsgroup-expunged-tally nil)
1254 (defvar gnus-newsgroup-marked nil
1255 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1257 (defvar gnus-newsgroup-spam-marked nil
1258 "List of ranges of articles that have been marked as spam.")
1260 (defvar gnus-newsgroup-killed nil
1261 "List of ranges of articles that have been through the scoring process.")
1263 (defvar gnus-newsgroup-cached nil
1264 "Sorted list of articles that come from the article cache.")
1266 (defvar gnus-newsgroup-saved nil
1267 "List of articles that have been saved.")
1269 (defvar gnus-newsgroup-kill-headers nil)
1271 (defvar gnus-newsgroup-replied nil
1272 "List of articles that have been replied to in the current newsgroup.")
1274 (defvar gnus-newsgroup-forwarded nil
1275 "List of articles that have been forwarded in the current newsgroup.")
1277 (defvar gnus-newsgroup-recent nil
1278 "List of articles that have are recent in the current newsgroup.")
1280 (defvar gnus-newsgroup-expirable nil
1281 "Sorted list of articles in the current newsgroup that can be expired.")
1283 (defvar gnus-newsgroup-processable nil
1284 "List of articles in the current newsgroup that can be processed.")
1286 (defvar gnus-newsgroup-downloadable nil
1287 "Sorted list of articles in the current newsgroup that can be processed.")
1289 (defvar gnus-newsgroup-undownloaded nil
1290 "List of articles in the current newsgroup that haven't been downloaded..")
1292 (defvar gnus-newsgroup-unsendable nil
1293 "List of articles in the current newsgroup that won't be sent.")
1295 (defvar gnus-newsgroup-bookmarks nil
1296 "List of articles in the current newsgroup that have bookmarks.")
1298 (defvar gnus-newsgroup-dormant nil
1299 "Sorted list of dormant articles in the current newsgroup.")
1301 (defvar gnus-newsgroup-unseen nil
1302 "List of unseen articles in the current newsgroup.")
1304 (defvar gnus-newsgroup-seen nil
1305 "Range of seen articles in the current newsgroup.")
1307 (defvar gnus-newsgroup-articles nil
1308 "List of articles in the current newsgroup.")
1310 (defvar gnus-newsgroup-scored nil
1311 "List of scored articles in the current newsgroup.")
1313 (defvar gnus-newsgroup-incorporated nil
1314 "List of incorporated articles in the current newsgroup.")
1316 (defvar gnus-newsgroup-headers nil
1317 "List of article headers in the current newsgroup.")
1319 (defvar gnus-newsgroup-threads nil)
1321 (defvar gnus-newsgroup-prepared nil
1322 "Whether the current group has been prepared properly.")
1324 (defvar gnus-newsgroup-ancient nil
1325 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1327 (defvar gnus-newsgroup-sparse nil)
1329 (defvar gnus-current-article nil)
1330 (defvar gnus-article-current nil)
1331 (defvar gnus-current-headers nil)
1332 (defvar gnus-have-all-headers nil)
1333 (defvar gnus-last-article nil)
1334 (defvar gnus-newsgroup-history nil)
1335 (defvar gnus-newsgroup-charset nil)
1336 (defvar gnus-newsgroup-ephemeral-charset nil)
1337 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1339 (defvar gnus-article-before-search nil)
1341 (defconst gnus-summary-local-variables
1342 '(gnus-newsgroup-name
1343 gnus-newsgroup-begin gnus-newsgroup-end
1344 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1345 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1346 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1347 gnus-newsgroup-unselected gnus-newsgroup-marked
1348 gnus-newsgroup-spam-marked
1349 gnus-newsgroup-reads gnus-newsgroup-saved
1350 gnus-newsgroup-replied gnus-newsgroup-forwarded
1351 gnus-newsgroup-recent
1352 gnus-newsgroup-expirable
1353 gnus-newsgroup-processable gnus-newsgroup-killed
1354 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1355 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1356 gnus-newsgroup-seen gnus-newsgroup-articles
1357 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1358 gnus-newsgroup-headers gnus-newsgroup-threads
1359 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1360 gnus-current-article gnus-current-headers gnus-have-all-headers
1361 gnus-last-article gnus-article-internal-prepare-hook
1362 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1363 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1364 gnus-thread-expunge-below
1365 gnus-score-alist gnus-current-score-file
1366 (gnus-summary-expunge-below . global)
1367 (gnus-summary-mark-below . global)
1368 (gnus-orphan-score . global)
1369 gnus-newsgroup-active gnus-scores-exclude-files
1370 gnus-newsgroup-history gnus-newsgroup-ancient
1371 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1372 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1373 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1374 (gnus-newsgroup-expunged-tally . 0)
1375 gnus-cache-removable-articles gnus-newsgroup-cached
1376 gnus-newsgroup-data gnus-newsgroup-data-reverse
1377 gnus-newsgroup-limit gnus-newsgroup-limits
1378 gnus-newsgroup-charset gnus-newsgroup-display
1379 gnus-newsgroup-incorporated)
1380 "Variables that are buffer-local to the summary buffers.")
1382 (defvar gnus-newsgroup-variables nil
1383 "A list of variables that have separate values in different newsgroups.
1384 A list of newsgroup (summary buffer) local variables, or cons of
1385 variables and their default values (when the default values are not
1386 nil), that should be made global while the summary buffer is active.
1387 These variables can be used to set variables in the group parameters
1388 while still allowing them to affect operations done in other
1389 buffers. For example:
1391 \(setq gnus-newsgroup-variables
1392 '(message-use-followup-to
1393 (gnus-visible-headers .
1394 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1397 ;; Byte-compiler warning.
1398 ;(eval-when-compile (defvar gnus-article-mode-map))
1400 (let ((features (cons 'gnus-sum features)))
1402 (require 'gnus-agent)
1403 (require 'gnus-art)))
1405 ;; Subject simplification.
1407 (defun gnus-simplify-whitespace (str)
1408 "Remove excessive whitespace from STR."
1411 (while (string-match "[ \t][ \t]+" mystr)
1412 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1414 (substring mystr (match-end 0)))))
1416 (when (string-match "^[ \t]+" mystr)
1417 (setq mystr (substring mystr (match-end 0))))
1419 (when (string-match "[ \t]+$" mystr)
1420 (setq mystr (substring mystr 0 (match-beginning 0))))
1423 (defun gnus-simplify-all-whitespace (str)
1424 "Remove all whitespace from STR."
1426 (while (string-match "[ \t\n]+" mystr)
1427 (setq mystr (replace-match "" nil nil mystr)))
1430 (defsubst gnus-simplify-subject-re (subject)
1431 "Remove \"Re:\" from subject lines."
1432 (if (string-match message-subject-re-regexp subject)
1433 (substring subject (match-end 0))
1436 (defun gnus-simplify-subject (subject &optional re-only)
1437 "Remove `Re:' and words in parentheses.
1438 If RE-ONLY is non-nil, strip leading `Re:'s only."
1439 (let ((case-fold-search t)) ;Ignore case.
1440 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1441 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1442 (setq subject (substring subject (match-end 0))))
1443 ;; Remove uninteresting prefixes.
1444 (when (and (not re-only)
1445 gnus-simplify-ignored-prefixes
1446 (string-match gnus-simplify-ignored-prefixes subject))
1447 (setq subject (substring subject (match-end 0))))
1448 ;; Remove words in parentheses from end.
1450 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1451 (setq subject (substring subject 0 (match-beginning 0)))))
1452 ;; Return subject string.
1455 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1457 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1458 (goto-char (point-min))
1459 (while (re-search-forward regexp nil t)
1460 (replace-match (or newtext ""))))
1462 (defun gnus-simplify-buffer-fuzzy ()
1463 "Simplify string in the buffer fuzzily.
1464 The string in the accessible portion of the current buffer is simplified.
1465 It is assumed to be a single-line subject.
1466 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1467 matter is removed. Additional things can be deleted by setting
1468 `gnus-simplify-subject-fuzzy-regexp'."
1469 (let ((case-fold-search t)
1471 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1473 (while (not (eq modified-tick (buffer-modified-tick)))
1474 (setq modified-tick (buffer-modified-tick))
1476 ((listp gnus-simplify-subject-fuzzy-regexp)
1477 (mapcar 'gnus-simplify-buffer-fuzzy-step
1478 gnus-simplify-subject-fuzzy-regexp))
1479 (gnus-simplify-subject-fuzzy-regexp
1480 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1481 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1482 (gnus-simplify-buffer-fuzzy-step
1483 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1484 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1486 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1487 (gnus-simplify-buffer-fuzzy-step " +" " ")
1488 (gnus-simplify-buffer-fuzzy-step " $")
1489 (gnus-simplify-buffer-fuzzy-step "^ +")))
1491 (defun gnus-simplify-subject-fuzzy (subject)
1492 "Simplify a subject string fuzzily.
1493 See `gnus-simplify-buffer-fuzzy' for details."
1495 (gnus-set-work-buffer)
1496 (let ((case-fold-search t))
1497 ;; Remove uninteresting prefixes.
1498 (when (and gnus-simplify-ignored-prefixes
1499 (string-match gnus-simplify-ignored-prefixes subject))
1500 (setq subject (substring subject (match-end 0))))
1502 (inline (gnus-simplify-buffer-fuzzy))
1505 (defsubst gnus-simplify-subject-fully (subject)
1506 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1508 (gnus-simplify-subject-functions
1509 (gnus-map-function gnus-simplify-subject-functions subject))
1510 ((null gnus-summary-gather-subject-limit)
1511 (gnus-simplify-subject-re subject))
1512 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1513 (gnus-simplify-subject-fuzzy subject))
1514 ((numberp gnus-summary-gather-subject-limit)
1515 (gnus-limit-string (gnus-simplify-subject-re subject)
1516 gnus-summary-gather-subject-limit))
1520 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1521 "Check whether two subjects are equal.
1522 If optional argument simple-first is t, first argument is already
1525 ((null simple-first)
1526 (equal (gnus-simplify-subject-fully s1)
1527 (gnus-simplify-subject-fully s2)))
1530 (gnus-simplify-subject-fully s2)))))
1532 (defun gnus-summary-bubble-group ()
1533 "Increase the score of the current group.
1534 This is a handy function to add to `gnus-summary-exit-hook' to
1535 increase the score of each group you read."
1536 (gnus-group-add-score gnus-newsgroup-name))
1540 ;;; Gnus summary mode
1543 (put 'gnus-summary-mode 'mode-class 'special)
1545 (defvar gnus-article-commands-menu)
1547 ;; Non-orthogonal keys
1549 (gnus-define-keys gnus-summary-mode-map
1550 " " gnus-summary-next-page
1551 "\177" gnus-summary-prev-page
1552 [delete] gnus-summary-prev-page
1553 [backspace] gnus-summary-prev-page
1554 "\r" gnus-summary-scroll-up
1555 "\M-\r" gnus-summary-scroll-down
1556 "n" gnus-summary-next-unread-article
1557 "p" gnus-summary-prev-unread-article
1558 "N" gnus-summary-next-article
1559 "P" gnus-summary-prev-article
1560 "\M-\C-n" gnus-summary-next-same-subject
1561 "\M-\C-p" gnus-summary-prev-same-subject
1562 "\M-n" gnus-summary-next-unread-subject
1563 "\M-p" gnus-summary-prev-unread-subject
1564 "." gnus-summary-first-unread-article
1565 "," gnus-summary-best-unread-article
1566 "\M-s" gnus-summary-search-article-forward
1567 "\M-r" gnus-summary-search-article-backward
1568 "<" gnus-summary-beginning-of-article
1569 ">" gnus-summary-end-of-article
1570 "j" gnus-summary-goto-article
1571 "^" gnus-summary-refer-parent-article
1572 "\M-^" gnus-summary-refer-article
1573 "u" gnus-summary-tick-article-forward
1574 "!" gnus-summary-tick-article-forward
1575 "U" gnus-summary-tick-article-backward
1576 "d" gnus-summary-mark-as-read-forward
1577 "D" gnus-summary-mark-as-read-backward
1578 "E" gnus-summary-mark-as-expirable
1579 "\M-u" gnus-summary-clear-mark-forward
1580 "\M-U" gnus-summary-clear-mark-backward
1581 "k" gnus-summary-kill-same-subject-and-select
1582 "\C-k" gnus-summary-kill-same-subject
1583 "\M-\C-k" gnus-summary-kill-thread
1584 "\M-\C-l" gnus-summary-lower-thread
1585 "e" gnus-summary-edit-article
1586 "#" gnus-summary-mark-as-processable
1587 "\M-#" gnus-summary-unmark-as-processable
1588 "\M-\C-t" gnus-summary-toggle-threads
1589 "\M-\C-s" gnus-summary-show-thread
1590 "\M-\C-h" gnus-summary-hide-thread
1591 "\M-\C-f" gnus-summary-next-thread
1592 "\M-\C-b" gnus-summary-prev-thread
1593 [(meta down)] gnus-summary-next-thread
1594 [(meta up)] gnus-summary-prev-thread
1595 "\M-\C-u" gnus-summary-up-thread
1596 "\M-\C-d" gnus-summary-down-thread
1597 "&" gnus-summary-execute-command
1598 "c" gnus-summary-catchup-and-exit
1599 "\C-w" gnus-summary-mark-region-as-read
1600 "\C-t" gnus-summary-toggle-truncation
1601 "?" gnus-summary-mark-as-dormant
1602 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1603 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1604 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1605 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1606 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1607 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1608 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1609 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1610 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1611 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1612 "=" gnus-summary-expand-window
1613 "\C-x\C-s" gnus-summary-reselect-current-group
1614 "\M-g" gnus-summary-rescan-group
1615 "w" gnus-summary-stop-page-breaking
1616 "\C-c\C-r" gnus-summary-caesar-message
1617 "\M-t" gnus-summary-toggle-mime
1618 "f" gnus-summary-followup
1619 "F" gnus-summary-followup-with-original
1620 "C" gnus-summary-cancel-article
1621 "r" gnus-summary-reply
1622 "R" gnus-summary-reply-with-original
1623 "\C-c\C-f" gnus-summary-mail-forward
1624 "o" gnus-summary-save-article
1625 "\C-o" gnus-summary-save-article-mail
1626 "|" gnus-summary-pipe-output
1627 "\M-k" gnus-summary-edit-local-kill
1628 "\M-K" gnus-summary-edit-global-kill
1630 "\C-c\C-d" gnus-summary-describe-group
1631 "q" gnus-summary-exit
1632 "Q" gnus-summary-exit-no-update
1633 "\C-c\C-i" gnus-info-find-node
1634 gnus-mouse-2 gnus-mouse-pick-article
1635 "m" gnus-summary-mail-other-window
1636 "a" gnus-summary-post-news
1637 "i" gnus-summary-news-other-window
1638 "x" gnus-summary-limit-to-unread
1639 "s" gnus-summary-isearch-article
1640 "t" gnus-summary-toggle-header
1641 "g" gnus-summary-show-article
1642 "l" gnus-summary-goto-last-article
1643 "v" gnus-summary-preview-mime-message
1644 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1645 "\C-d" gnus-summary-enter-digest-group
1646 "\M-\C-d" gnus-summary-read-document
1647 "\M-\C-e" gnus-summary-edit-parameters
1648 "\M-\C-a" gnus-summary-customize-parameters
1650 "\C-c\C-n" gnus-namazu-search
1651 "*" gnus-cache-enter-article
1652 "\M-*" gnus-cache-remove-article
1653 "\M-&" gnus-summary-universal-argument
1654 "\C-l" gnus-recenter
1655 "I" gnus-summary-increase-score
1656 "L" gnus-summary-lower-score
1657 "\M-i" gnus-symbolic-argument
1658 "h" gnus-summary-select-article-buffer
1660 "V" gnus-summary-score-map
1661 "X" gnus-uu-extract-map
1662 "S" gnus-summary-send-map)
1664 ;; Sort of orthogonal keymap
1665 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1666 "t" gnus-summary-tick-article-forward
1667 "!" gnus-summary-tick-article-forward
1668 "d" gnus-summary-mark-as-read-forward
1669 "r" gnus-summary-mark-as-read-forward
1670 "c" gnus-summary-clear-mark-forward
1671 " " gnus-summary-clear-mark-forward
1672 "e" gnus-summary-mark-as-expirable
1673 "x" gnus-summary-mark-as-expirable
1674 "?" gnus-summary-mark-as-dormant
1675 "b" gnus-summary-set-bookmark
1676 "B" gnus-summary-remove-bookmark
1677 "#" gnus-summary-mark-as-processable
1678 "\M-#" gnus-summary-unmark-as-processable
1679 "S" gnus-summary-limit-include-expunged
1680 "C" gnus-summary-catchup
1681 "H" gnus-summary-catchup-to-here
1682 "h" gnus-summary-catchup-from-here
1683 "\C-c" gnus-summary-catchup-all
1684 "k" gnus-summary-kill-same-subject-and-select
1685 "K" gnus-summary-kill-same-subject
1686 "P" gnus-uu-mark-map)
1688 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1689 "c" gnus-summary-clear-above
1690 "u" gnus-summary-tick-above
1691 "m" gnus-summary-mark-above
1692 "k" gnus-summary-kill-below)
1694 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1695 "/" gnus-summary-limit-to-subject
1696 "n" gnus-summary-limit-to-articles
1697 "w" gnus-summary-pop-limit
1698 "s" gnus-summary-limit-to-subject
1699 "a" gnus-summary-limit-to-author
1700 "u" gnus-summary-limit-to-unread
1701 "m" gnus-summary-limit-to-marks
1702 "M" gnus-summary-limit-exclude-marks
1703 "v" gnus-summary-limit-to-score
1704 "*" gnus-summary-limit-include-cached
1705 "D" gnus-summary-limit-include-dormant
1706 "T" gnus-summary-limit-include-thread
1707 "d" gnus-summary-limit-exclude-dormant
1708 "t" gnus-summary-limit-to-age
1709 "." gnus-summary-limit-to-unseen
1710 "x" gnus-summary-limit-to-extra
1711 "p" gnus-summary-limit-to-display-predicate
1712 "E" gnus-summary-limit-include-expunged
1713 "c" gnus-summary-limit-exclude-childless-dormant
1714 "C" gnus-summary-limit-mark-excluded-as-read
1715 "o" gnus-summary-insert-old-articles
1716 "N" gnus-summary-insert-new-articles)
1718 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1719 "n" gnus-summary-next-unread-article
1720 "p" gnus-summary-prev-unread-article
1721 "N" gnus-summary-next-article
1722 "P" gnus-summary-prev-article
1723 "\C-n" gnus-summary-next-same-subject
1724 "\C-p" gnus-summary-prev-same-subject
1725 "\M-n" gnus-summary-next-unread-subject
1726 "\M-p" gnus-summary-prev-unread-subject
1727 "f" gnus-summary-first-unread-article
1728 "b" gnus-summary-best-unread-article
1729 "j" gnus-summary-goto-article
1730 "g" gnus-summary-goto-subject
1731 "l" gnus-summary-goto-last-article
1732 "o" gnus-summary-pop-article)
1734 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1735 "k" gnus-summary-kill-thread
1736 "l" gnus-summary-lower-thread
1737 "i" gnus-summary-raise-thread
1738 "T" gnus-summary-toggle-threads
1739 "t" gnus-summary-rethread-current
1740 "^" gnus-summary-reparent-thread
1741 "s" gnus-summary-show-thread
1742 "S" gnus-summary-show-all-threads
1743 "h" gnus-summary-hide-thread
1744 "H" gnus-summary-hide-all-threads
1745 "n" gnus-summary-next-thread
1746 "p" gnus-summary-prev-thread
1747 "u" gnus-summary-up-thread
1748 "o" gnus-summary-top-thread
1749 "d" gnus-summary-down-thread
1750 "#" gnus-uu-mark-thread
1751 "\M-#" gnus-uu-unmark-thread)
1753 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1754 "g" gnus-summary-prepare
1755 "c" gnus-summary-insert-cached-articles
1756 "d" gnus-summary-insert-dormant-articles)
1758 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1759 "c" gnus-summary-catchup-and-exit
1760 "C" gnus-summary-catchup-all-and-exit
1761 "E" gnus-summary-exit-no-update
1762 "J" gnus-summary-jump-to-other-group
1763 "Q" gnus-summary-exit
1764 "Z" gnus-summary-exit
1765 "n" gnus-summary-catchup-and-goto-next-group
1766 "R" gnus-summary-reselect-current-group
1767 "G" gnus-summary-rescan-group
1768 "N" gnus-summary-next-group
1769 "s" gnus-summary-save-newsrc
1770 "P" gnus-summary-prev-group)
1772 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1773 " " gnus-summary-next-page
1774 "n" gnus-summary-next-page
1775 "\177" gnus-summary-prev-page
1776 [delete] gnus-summary-prev-page
1777 "p" gnus-summary-prev-page
1778 "\r" gnus-summary-scroll-up
1779 "\M-\r" gnus-summary-scroll-down
1780 "<" gnus-summary-beginning-of-article
1781 ">" gnus-summary-end-of-article
1782 "b" gnus-summary-beginning-of-article
1783 "e" gnus-summary-end-of-article
1784 "^" gnus-summary-refer-parent-article
1785 "r" gnus-summary-refer-parent-article
1786 "D" gnus-summary-enter-digest-group
1787 "R" gnus-summary-refer-references
1788 "T" gnus-summary-refer-thread
1789 "g" gnus-summary-show-article
1790 "s" gnus-summary-isearch-article
1791 "P" gnus-summary-print-article
1792 "M" gnus-mailing-list-insinuate
1793 "t" gnus-article-babel)
1795 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1796 "b" gnus-article-add-buttons
1797 "B" gnus-article-add-buttons-to-head
1798 "o" gnus-article-treat-overstrike
1799 "e" gnus-article-emphasize
1800 "w" gnus-article-fill-cited-article
1801 "Q" gnus-article-fill-long-lines
1802 "C" gnus-article-capitalize-sentences
1803 "c" gnus-article-remove-cr
1804 "Z" gnus-article-decode-HZ
1805 "h" gnus-article-wash-html
1806 "u" gnus-article-unsplit-urls
1807 "f" gnus-article-display-x-face
1808 "l" gnus-summary-stop-page-breaking
1809 "r" gnus-summary-caesar-message
1810 "m" gnus-summary-morse-message
1811 "t" gnus-summary-toggle-header
1812 "g" gnus-treat-smiley
1813 "v" gnus-summary-verbose-headers
1814 "m" gnus-summary-toggle-mime
1815 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1816 "p" gnus-article-verify-x-pgp-sig
1817 "d" gnus-article-treat-dumbquotes)
1819 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1820 ;; mnemonic: deuglif*Y*
1821 "u" gnus-article-outlook-unwrap-lines
1822 "a" gnus-article-outlook-repair-attribution
1823 "c" gnus-article-outlook-rearrange-citation
1824 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1826 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1827 "a" gnus-article-hide
1828 "h" gnus-article-hide-headers
1829 "b" gnus-article-hide-boring-headers
1830 "s" gnus-article-hide-signature
1831 "c" gnus-article-hide-citation
1832 "C" gnus-article-hide-citation-in-followups
1833 "l" gnus-article-hide-list-identifiers
1834 "p" gnus-article-hide-pgp
1835 "B" gnus-article-strip-banner
1836 "P" gnus-article-hide-pem
1837 "\C-c" gnus-article-hide-citation-maybe)
1839 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1840 "a" gnus-article-highlight
1841 "h" gnus-article-highlight-headers
1842 "c" gnus-article-highlight-citation
1843 "s" gnus-article-highlight-signature)
1845 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1846 "f" gnus-article-treat-fold-headers
1847 "u" gnus-article-treat-unfold-headers
1848 "n" gnus-article-treat-fold-newsgroups)
1850 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1851 "x" gnus-article-display-x-face
1852 "d" gnus-article-display-face
1853 "s" gnus-treat-smiley
1854 "D" gnus-article-remove-images
1855 "f" gnus-treat-from-picon
1856 "m" gnus-treat-mail-picon
1857 "n" gnus-treat-newsgroups-picon)
1859 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1860 "z" gnus-article-date-ut
1861 "u" gnus-article-date-ut
1862 "l" gnus-article-date-local
1863 "p" gnus-article-date-english
1864 "e" gnus-article-date-lapsed
1865 "o" gnus-article-date-original
1866 "i" gnus-article-date-iso8601
1867 "s" gnus-article-date-user)
1869 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1870 "t" gnus-article-remove-trailing-blank-lines
1871 "l" gnus-article-strip-leading-blank-lines
1872 "m" gnus-article-strip-multiple-blank-lines
1873 "a" gnus-article-strip-blank-lines
1874 "A" gnus-article-strip-all-blank-lines
1875 "s" gnus-article-strip-leading-space
1876 "e" gnus-article-strip-trailing-space
1877 "w" gnus-article-remove-leading-whitespace)
1879 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1881 "f" gnus-summary-fetch-faq
1882 "d" gnus-summary-describe-group
1883 "h" gnus-summary-describe-briefly
1884 "i" gnus-info-find-node
1885 "c" gnus-group-fetch-charter
1886 "C" gnus-group-fetch-control)
1888 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1889 "e" gnus-summary-expire-articles
1890 "\M-\C-e" gnus-summary-expire-articles-now
1891 "\177" gnus-summary-delete-article
1892 [delete] gnus-summary-delete-article
1893 [backspace] gnus-summary-delete-article
1894 "m" gnus-summary-move-article
1895 "r" gnus-summary-respool-article
1896 "w" gnus-summary-edit-article
1897 "c" gnus-summary-copy-article
1898 "B" gnus-summary-crosspost-article
1899 "q" gnus-summary-respool-query
1900 "t" gnus-summary-respool-trace
1901 "i" gnus-summary-import-article
1902 "I" gnus-summary-create-article
1903 "p" gnus-summary-article-posted-p)
1905 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1906 "o" gnus-summary-save-article
1907 "m" gnus-summary-save-article-mail
1908 "F" gnus-summary-write-article-file
1909 "r" gnus-summary-save-article-rmail
1910 "f" gnus-summary-save-article-file
1911 "b" gnus-summary-save-article-body-file
1912 "h" gnus-summary-save-article-folder
1913 "v" gnus-summary-save-article-vm
1914 "p" gnus-summary-pipe-output
1915 "P" gnus-summary-muttprint
1916 "s" gnus-soup-add-article)
1918 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1919 "b" gnus-summary-display-buttonized
1920 "m" gnus-summary-repair-multipart
1921 "v" gnus-article-view-part
1922 "o" gnus-article-save-part
1923 "c" gnus-article-copy-part
1924 "C" gnus-article-view-part-as-charset
1925 "e" gnus-article-view-part-externally
1926 "E" gnus-article-encrypt-body
1927 "i" gnus-article-inline-part
1928 "|" gnus-article-pipe-part)
1930 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1931 "p" gnus-summary-mark-as-processable
1932 "u" gnus-summary-unmark-as-processable
1933 "U" gnus-summary-unmark-all-processable
1934 "v" gnus-uu-mark-over
1935 "s" gnus-uu-mark-series
1936 "r" gnus-uu-mark-region
1937 "g" gnus-uu-unmark-region
1938 "R" gnus-uu-mark-by-regexp
1939 "G" gnus-uu-unmark-by-regexp
1940 "t" gnus-uu-mark-thread
1941 "T" gnus-uu-unmark-thread
1942 "a" gnus-uu-mark-all
1943 "b" gnus-uu-mark-buffer
1944 "S" gnus-uu-mark-sparse
1945 "k" gnus-summary-kill-process-mark
1946 "y" gnus-summary-yank-process-mark
1947 "w" gnus-summary-save-process-mark
1948 "i" gnus-uu-invert-processable)
1950 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1951 ;;"x" gnus-uu-extract-any
1952 "m" gnus-summary-save-parts
1953 "u" gnus-uu-decode-uu
1954 "U" gnus-uu-decode-uu-and-save
1955 "s" gnus-uu-decode-unshar
1956 "S" gnus-uu-decode-unshar-and-save
1957 "o" gnus-uu-decode-save
1958 "O" gnus-uu-decode-save
1959 "b" gnus-uu-decode-binhex
1960 "B" gnus-uu-decode-binhex
1961 "p" gnus-uu-decode-postscript
1962 "P" gnus-uu-decode-postscript-and-save)
1965 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1966 "u" gnus-uu-decode-uu-view
1967 "U" gnus-uu-decode-uu-and-save-view
1968 "s" gnus-uu-decode-unshar-view
1969 "S" gnus-uu-decode-unshar-and-save-view
1970 "o" gnus-uu-decode-save-view
1971 "O" gnus-uu-decode-save-view
1972 "b" gnus-uu-decode-binhex-view
1973 "B" gnus-uu-decode-binhex-view
1974 "p" gnus-uu-decode-postscript-view
1975 "P" gnus-uu-decode-postscript-and-save-view)
1977 (defvar gnus-article-post-menu nil)
1979 (defconst gnus-summary-menu-maxlen 20)
1981 (defun gnus-summary-menu-split (menu)
1982 ;; If we have lots of elements, divide them into groups of 20
1983 ;; and make a pane (or submenu) for each one.
1984 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1985 (let ((menu menu) sublists next
1988 ;; Pull off the next gnus-summary-menu-maxlen elements
1989 ;; and make them the next element of sublist.
1990 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1992 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1994 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1995 (aref (car (last menu)) 0)) menu)
1999 (nreverse sublists))
2000 ;; Few elements--put them all in one pane.
2003 (defun gnus-summary-make-menu-bar ()
2004 (gnus-turn-off-edit-menu 'summary)
2006 (unless (boundp 'gnus-summary-misc-menu)
2009 gnus-summary-kill-menu gnus-summary-mode-map ""
2014 ["Customize" gnus-score-customize t])
2015 (gnus-make-score-map 'increase)
2016 (gnus-make-score-map 'lower)
2018 ["Kill below" gnus-summary-kill-below t]
2019 ["Mark above" gnus-summary-mark-above t]
2020 ["Tick above" gnus-summary-tick-above t]
2021 ["Clear above" gnus-summary-clear-above t])
2022 ["Current score" gnus-summary-current-score t]
2023 ["Set score" gnus-summary-set-score t]
2024 ["Switch current score file..." gnus-score-change-score-file t]
2025 ["Set mark below..." gnus-score-set-mark-below t]
2026 ["Set expunge below..." gnus-score-set-expunge-below t]
2027 ["Edit current score file" gnus-score-edit-current-scores t]
2028 ["Edit score file" gnus-score-edit-file t]
2029 ["Trace score" gnus-score-find-trace t]
2030 ["Find words" gnus-score-find-favourite-words t]
2031 ["Rescore buffer" gnus-summary-rescore t]
2032 ["Increase score..." gnus-summary-increase-score t]
2033 ["Lower score..." gnus-summary-lower-score t]))))
2035 ;; Define both the Article menu in the summary buffer and the
2036 ;; equivalent Commands menu in the article buffer here for
2040 ["All" gnus-article-hide t]
2041 ["Headers" gnus-article-hide-headers t]
2042 ["Signature" gnus-article-hide-signature t]
2043 ["Citation" gnus-article-hide-citation t]
2044 ["List identifiers" gnus-article-hide-list-identifiers t]
2045 ["PGP" gnus-article-hide-pgp t]
2046 ["Banner" gnus-article-strip-banner t]
2047 ["Boring headers" gnus-article-hide-boring-headers t])
2049 ["All" gnus-article-highlight t]
2050 ["Headers" gnus-article-highlight-headers t]
2051 ["Signature" gnus-article-highlight-signature t]
2052 ["Citation" gnus-article-highlight-citation t])
2054 ["Local" gnus-article-date-local t]
2055 ["ISO8601" gnus-article-date-iso8601 t]
2056 ["UT" gnus-article-date-ut t]
2057 ["Original" gnus-article-date-original t]
2058 ["Lapsed" gnus-article-date-lapsed t]
2059 ["User-defined" gnus-article-date-user t])
2061 ["Remove images" gnus-article-remove-images t]
2062 ["Toggle smiley" gnus-treat-smiley t]
2063 ["Show X-Face" gnus-article-display-x-face t]
2064 ["Show picons in From" gnus-treat-from-picon t]
2065 ["Show picons in mail headers" gnus-treat-mail-picon t]
2066 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2067 ("View as different encoding"
2068 ,@(gnus-summary-menu-split
2071 ;; Since easymenu under FSF Emacs doesn't allow lambda
2072 ;; forms for menu commands, we should provide intern'ed
2073 ;; function symbols.
2074 (let ((command (intern (format "\
2075 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2079 (let ((gnus-summary-show-article-charset-alist
2081 (gnus-summary-show-article 1))))
2082 `[,(symbol-name cs) ,command t]))
2083 (sort (if (fboundp 'coding-system-list)
2084 (coding-system-list)
2085 ;;(mapcar 'car mm-mime-mule-charset-alist)
2090 ["Leading" gnus-article-strip-leading-blank-lines t]
2091 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2092 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2093 ["All of the above" gnus-article-strip-blank-lines t]
2094 ["All" gnus-article-strip-all-blank-lines t]
2095 ["Leading space" gnus-article-strip-leading-space t]
2096 ["Trailing space" gnus-article-strip-trailing-space t]
2097 ["Leading space in headers"
2098 gnus-article-remove-leading-whitespace t])
2099 ["Overstrike" gnus-article-treat-overstrike t]
2100 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2101 ["Emphasis" gnus-article-emphasize t]
2102 ["Word wrap" gnus-article-fill-cited-article t]
2103 ["Fill long lines" gnus-article-fill-long-lines t]
2104 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2105 ["CR" gnus-article-remove-cr t]
2106 ["Rot 13" gnus-summary-caesar-message
2107 ,@(if (featurep 'xemacs) '(t)
2108 '(:help "\"Caesar rotate\" article by 13"))]
2109 ["Morse decode" gnus-summary-morse-message t]
2110 ["Unix pipe..." gnus-summary-pipe-message t]
2111 ["Add buttons" gnus-article-add-buttons t]
2112 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2113 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2114 ["Toggle MIME" gnus-summary-toggle-mime t]
2115 ["Verbose header" gnus-summary-verbose-headers t]
2116 ["Toggle header" gnus-summary-toggle-header t]
2117 ["Unfold headers" gnus-article-treat-unfold-headers t]
2118 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2119 ["Html" gnus-article-wash-html t]
2120 ["URLs" gnus-article-unsplit-urls t]
2121 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2122 ["HZ" gnus-article-decode-HZ t]
2123 ("(Outlook) Deuglify"
2124 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2125 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2126 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2127 ["Full (Outlook) deuglify"
2128 gnus-article-outlook-deuglify-article t])
2131 ["Save in default format" gnus-summary-save-article
2132 ,@(if (featurep 'xemacs) '(t)
2133 '(:help "Save article using default method"))]
2134 ["Save in file" gnus-summary-save-article-file
2135 ,@(if (featurep 'xemacs) '(t)
2136 '(:help "Save article in file"))]
2137 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2138 ["Save in MH folder" gnus-summary-save-article-folder t]
2139 ["Save in VM folder" gnus-summary-save-article-vm t]
2140 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2141 ["Save body in file" gnus-summary-save-article-body-file t]
2142 ["Pipe through a filter" gnus-summary-pipe-output t]
2143 ["Add to SOUP packet" gnus-soup-add-article t]
2144 ["Print with Muttprint" gnus-summary-muttprint t]
2145 ["Print" gnus-summary-print-article t])
2147 ["Respool article..." gnus-summary-respool-article t]
2148 ["Move article..." gnus-summary-move-article
2149 (gnus-check-backend-function
2150 'request-move-article gnus-newsgroup-name)]
2151 ["Copy article..." gnus-summary-copy-article t]
2152 ["Crosspost article..." gnus-summary-crosspost-article
2153 (gnus-check-backend-function
2154 'request-replace-article gnus-newsgroup-name)]
2155 ["Import file..." gnus-summary-import-article t]
2156 ["Create article..." gnus-summary-create-article t]
2157 ["Check if posted" gnus-summary-article-posted-p t]
2158 ["Edit article" gnus-summary-edit-article
2159 (not (gnus-group-read-only-p))]
2160 ["Delete article" gnus-summary-delete-article
2161 (gnus-check-backend-function
2162 'request-expire-articles gnus-newsgroup-name)]
2163 ["Query respool" gnus-summary-respool-query t]
2164 ["Trace respool" gnus-summary-respool-trace t]
2165 ["Delete expirable articles" gnus-summary-expire-articles-now
2166 (gnus-check-backend-function
2167 'request-expire-articles gnus-newsgroup-name)])
2169 ["Uudecode" gnus-uu-decode-uu
2170 ,@(if (featurep 'xemacs) '(t)
2171 '(:help "Decode uuencoded article(s)"))]
2172 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2173 ["Unshar" gnus-uu-decode-unshar t]
2174 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2175 ["Save" gnus-uu-decode-save t]
2176 ["Binhex" gnus-uu-decode-binhex t]
2177 ["Postscript" gnus-uu-decode-postscript t])
2179 ["Enter article" gnus-cache-enter-article t]
2180 ["Remove article" gnus-cache-remove-article t])
2181 ["Translate" gnus-article-babel t]
2182 ["Select article buffer" gnus-summary-select-article-buffer t]
2183 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2184 ["Isearch article..." gnus-summary-isearch-article t]
2185 ["Beginning of the article" gnus-summary-beginning-of-article t]
2186 ["End of the article" gnus-summary-end-of-article t]
2187 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2188 ["Fetch referenced articles" gnus-summary-refer-references t]
2189 ["Fetch current thread" gnus-summary-refer-thread t]
2190 ["Fetch article with id..." gnus-summary-refer-article t]
2191 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2192 ["Redisplay" gnus-summary-show-article t]
2193 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2195 gnus-summary-article-menu gnus-summary-mode-map ""
2196 (cons "Article" innards))
2198 (if (not (keymapp gnus-summary-article-menu))
2200 gnus-article-commands-menu gnus-article-mode-map ""
2201 (cons "Commands" innards))
2202 ;; in Emacs, don't share menu.
2203 (setq gnus-article-commands-menu
2204 (copy-keymap gnus-summary-article-menu))
2205 (define-key gnus-article-mode-map [menu-bar commands]
2206 (cons "Commands" gnus-article-commands-menu))))
2209 gnus-summary-thread-menu gnus-summary-mode-map ""
2211 ["Find all messages in thread" gnus-summary-refer-thread t]
2212 ["Toggle threading" gnus-summary-toggle-threads t]
2213 ["Hide threads" gnus-summary-hide-all-threads t]
2214 ["Show threads" gnus-summary-show-all-threads t]
2215 ["Hide thread" gnus-summary-hide-thread t]
2216 ["Show thread" gnus-summary-show-thread t]
2217 ["Go to next thread" gnus-summary-next-thread t]
2218 ["Go to previous thread" gnus-summary-prev-thread t]
2219 ["Go down thread" gnus-summary-down-thread t]
2220 ["Go up thread" gnus-summary-up-thread t]
2221 ["Top of thread" gnus-summary-top-thread t]
2222 ["Mark thread as read" gnus-summary-kill-thread t]
2223 ["Lower thread score" gnus-summary-lower-thread t]
2224 ["Raise thread score" gnus-summary-raise-thread t]
2225 ["Rethread current" gnus-summary-rethread-current t]))
2228 gnus-summary-post-menu gnus-summary-mode-map ""
2230 ["Send a message (mail or news)" gnus-summary-post-news
2231 ,@(if (featurep 'xemacs) '(t)
2232 '(:help "Post an article"))]
2233 ["Followup" gnus-summary-followup
2234 ,@(if (featurep 'xemacs) '(t)
2235 '(:help "Post followup to this article"))]
2236 ["Followup and yank" gnus-summary-followup-with-original
2237 ,@(if (featurep 'xemacs) '(t)
2238 '(:help "Post followup to this article, quoting its contents"))]
2239 ["Supersede article" gnus-summary-supersede-article t]
2240 ["Cancel article" gnus-summary-cancel-article
2241 ,@(if (featurep 'xemacs) '(t)
2242 '(:help "Cancel an article you posted"))]
2243 ["Reply" gnus-summary-reply t]
2244 ["Reply and yank" gnus-summary-reply-with-original t]
2245 ["Wide reply" gnus-summary-wide-reply t]
2246 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2247 ,@(if (featurep 'xemacs) '(t)
2248 '(:help "Mail a reply, quoting this article"))]
2249 ["Very wide reply" gnus-summary-very-wide-reply t]
2250 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2251 ,@(if (featurep 'xemacs) '(t)
2252 '(:help "Mail a very wide reply, quoting this article"))]
2253 ["Mail forward" gnus-summary-mail-forward t]
2254 ["Post forward" gnus-summary-post-forward t]
2255 ["Digest and mail" gnus-summary-digest-mail-forward t]
2256 ["Digest and post" gnus-summary-digest-post-forward t]
2257 ["Resend message" gnus-summary-resend-message t]
2258 ["Resend message edit" gnus-summary-resend-message-edit t]
2259 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2260 ["Send a mail" gnus-summary-mail-other-window t]
2261 ["Create a local message" gnus-summary-news-other-window t]
2262 ["Uuencode and post" gnus-uu-post-news
2263 ,@(if (featurep 'xemacs) '(t)
2264 '(:help "Post a uuencoded article"))]
2265 ["Followup via news" gnus-summary-followup-to-mail t]
2266 ["Followup via news and yank"
2267 gnus-summary-followup-to-mail-with-original t]
2269 ;;["Send" gnus-summary-send-draft t]
2270 ;;["Send bounced" gnus-resend-bounced-mail t])
2274 ((not (keymapp gnus-summary-post-menu))
2275 (setq gnus-article-post-menu gnus-summary-post-menu))
2276 ((not gnus-article-post-menu)
2277 ;; Don't share post menu.
2278 (setq gnus-article-post-menu
2279 (copy-keymap gnus-summary-post-menu))))
2280 (define-key gnus-article-mode-map [menu-bar post]
2281 (cons "Post" gnus-article-post-menu))
2284 gnus-summary-misc-menu gnus-summary-mode-map ""
2287 ["Mark as read" gnus-summary-mark-as-read-forward t]
2288 ["Mark same subject and select"
2289 gnus-summary-kill-same-subject-and-select t]
2290 ["Mark same subject" gnus-summary-kill-same-subject t]
2291 ["Catchup" gnus-summary-catchup
2292 ,@(if (featurep 'xemacs) '(t)
2293 '(:help "Mark unread articles in this group as read"))]
2294 ["Catchup all" gnus-summary-catchup-all t]
2295 ["Catchup to here" gnus-summary-catchup-to-here t]
2296 ["Catchup from here" gnus-summary-catchup-from-here t]
2297 ["Catchup region" gnus-summary-mark-region-as-read
2298 (gnus-mark-active-p)]
2299 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2301 ["Tick" gnus-summary-tick-article-forward t]
2302 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2303 ["Remove marks" gnus-summary-clear-mark-forward t]
2304 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2305 ["Set bookmark" gnus-summary-set-bookmark t]
2306 ["Remove bookmark" gnus-summary-remove-bookmark t])
2308 ["Marks..." gnus-summary-limit-to-marks t]
2309 ["Subject..." gnus-summary-limit-to-subject t]
2310 ["Author..." gnus-summary-limit-to-author t]
2311 ["Age..." gnus-summary-limit-to-age t]
2312 ["Extra..." gnus-summary-limit-to-extra t]
2313 ["Score..." gnus-summary-limit-to-score t]
2314 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2315 ["Unread" gnus-summary-limit-to-unread t]
2316 ["Unseen" gnus-summary-limit-to-unseen t]
2317 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2318 ["Next articles" gnus-summary-limit-to-articles t]
2319 ["Pop limit" gnus-summary-pop-limit t]
2320 ["Show dormant" gnus-summary-limit-include-dormant t]
2321 ["Hide childless dormant"
2322 gnus-summary-limit-exclude-childless-dormant t]
2323 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2324 ["Hide marked" gnus-summary-limit-exclude-marks t]
2325 ["Show expunged" gnus-summary-limit-include-expunged t])
2327 ["Set mark" gnus-summary-mark-as-processable t]
2328 ["Remove mark" gnus-summary-unmark-as-processable t]
2329 ["Remove all marks" gnus-summary-unmark-all-processable t]
2330 ["Mark above" gnus-uu-mark-over t]
2331 ["Mark series" gnus-uu-mark-series t]
2332 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2333 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2334 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2335 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2336 ["Mark all" gnus-uu-mark-all t]
2337 ["Mark buffer" gnus-uu-mark-buffer t]
2338 ["Mark sparse" gnus-uu-mark-sparse t]
2339 ["Mark thread" gnus-uu-mark-thread t]
2340 ["Unmark thread" gnus-uu-unmark-thread t]
2341 ("Process Mark Sets"
2342 ["Kill" gnus-summary-kill-process-mark t]
2343 ["Yank" gnus-summary-yank-process-mark
2344 gnus-newsgroup-process-stack]
2345 ["Save" gnus-summary-save-process-mark t]))
2347 ["Page forward" gnus-summary-next-page
2348 ,@(if (featurep 'xemacs) '(t)
2349 '(:help "Show next page of article"))]
2350 ["Page backward" gnus-summary-prev-page
2351 ,@(if (featurep 'xemacs) '(t)
2352 '(:help "Show previous page of article"))]
2353 ["Line forward" gnus-summary-scroll-up t])
2355 ["Next unread article" gnus-summary-next-unread-article t]
2356 ["Previous unread article" gnus-summary-prev-unread-article t]
2357 ["Next article" gnus-summary-next-article t]
2358 ["Previous article" gnus-summary-prev-article t]
2359 ["Next unread subject" gnus-summary-next-unread-subject t]
2360 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2361 ["Next article same subject" gnus-summary-next-same-subject t]
2362 ["Previous article same subject" gnus-summary-prev-same-subject t]
2363 ["First unread article" gnus-summary-first-unread-article t]
2364 ["Best unread article" gnus-summary-best-unread-article t]
2365 ["Go to subject number..." gnus-summary-goto-subject t]
2366 ["Go to article number..." gnus-summary-goto-article t]
2367 ["Go to the last article" gnus-summary-goto-last-article t]
2368 ["Pop article off history" gnus-summary-pop-article t])
2370 ["Sort by number" gnus-summary-sort-by-number t]
2371 ["Sort by author" gnus-summary-sort-by-author t]
2372 ["Sort by subject" gnus-summary-sort-by-subject t]
2373 ["Sort by date" gnus-summary-sort-by-date t]
2374 ["Sort by score" gnus-summary-sort-by-score t]
2375 ["Sort by lines" gnus-summary-sort-by-lines t]
2376 ["Sort by characters" gnus-summary-sort-by-chars t]
2377 ["Randomize" gnus-summary-sort-by-random t]
2378 ["Original sort" gnus-summary-sort-by-original t])
2380 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2381 ["Describe group" gnus-summary-describe-group t]
2382 ["Fetch charter" gnus-group-fetch-charter
2383 ,@(if (featurep 'xemacs) nil
2384 '(:help "Display the charter of the current group"))]
2385 ["Fetch control message" gnus-group-fetch-control
2386 ,@(if (featurep 'xemacs) nil
2387 '(:help "Display the archived control message for the current group"))]
2388 ["Read manual" gnus-info-find-node t])
2390 ["Pick and read" gnus-pick-mode t]
2391 ["Binary" gnus-binary-mode t])
2393 ["Regenerate" gnus-summary-prepare t]
2394 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2395 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2396 ["Toggle threading" gnus-summary-toggle-threads t])
2397 ["See old articles" gnus-summary-insert-old-articles t]
2398 ["See new articles" gnus-summary-insert-new-articles t]
2399 ["Filter articles..." gnus-summary-execute-command t]
2400 ["Run command on subjects..." gnus-summary-universal-argument t]
2401 ["Search articles forward..." gnus-summary-search-article-forward t]
2402 ["Search articles backward..." gnus-summary-search-article-backward t]
2403 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2404 ["Expand window" gnus-summary-expand-window t]
2405 ["Expire expirable articles" gnus-summary-expire-articles
2406 (gnus-check-backend-function
2407 'request-expire-articles gnus-newsgroup-name)]
2408 ["Edit local kill file" gnus-summary-edit-local-kill t]
2409 ["Edit main kill file" gnus-summary-edit-global-kill t]
2410 ["Edit group parameters" gnus-summary-edit-parameters t]
2411 ["Customize group parameters" gnus-summary-customize-parameters t]
2412 ["Send a bug report" gnus-bug t]
2414 ["Catchup and exit" gnus-summary-catchup-and-exit
2415 ,@(if (featurep 'xemacs) '(t)
2416 '(:help "Mark unread articles in this group as read, then exit"))]
2417 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2418 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2419 ["Exit group" gnus-summary-exit
2420 ,@(if (featurep 'xemacs) '(t)
2421 '(:help "Exit current group, return to group selection mode"))]
2422 ["Exit group without updating" gnus-summary-exit-no-update t]
2423 ["Exit and goto next group" gnus-summary-next-group t]
2424 ["Exit and goto prev group" gnus-summary-prev-group t]
2425 ["Reselect group" gnus-summary-reselect-current-group t]
2426 ["Rescan group" gnus-summary-rescan-group t]
2427 ["Update dribble" gnus-summary-save-newsrc t])))
2429 (gnus-run-hooks 'gnus-summary-menu-hook)))
2431 (defvar gnus-summary-tool-bar-map nil)
2433 ;; Emacs 21 tool bar. Should be no-op otherwise.
2434 (defun gnus-summary-make-tool-bar ()
2435 (if (and (fboundp 'tool-bar-add-item-from-menu)
2436 (default-value 'tool-bar-mode)
2437 (not gnus-summary-tool-bar-map))
2438 (setq gnus-summary-tool-bar-map
2439 (let ((tool-bar-map (make-sparse-keymap))
2440 (load-path (mm-image-load-path)))
2441 (tool-bar-add-item-from-menu
2442 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2443 (tool-bar-add-item-from-menu
2444 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2445 (tool-bar-add-item-from-menu
2446 'gnus-summary-post-news "post" gnus-summary-mode-map)
2447 (tool-bar-add-item-from-menu
2448 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2449 (tool-bar-add-item-from-menu
2450 'gnus-summary-followup "followup" gnus-summary-mode-map)
2451 (tool-bar-add-item-from-menu
2452 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2453 (tool-bar-add-item-from-menu
2454 'gnus-summary-reply "reply" gnus-summary-mode-map)
2455 (tool-bar-add-item-from-menu
2456 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2457 (tool-bar-add-item-from-menu
2458 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2459 (tool-bar-add-item-from-menu
2460 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2461 (tool-bar-add-item-from-menu
2462 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2463 (tool-bar-add-item-from-menu
2464 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2465 (tool-bar-add-item-from-menu
2466 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2467 (tool-bar-add-item-from-menu
2468 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2469 (tool-bar-add-item-from-menu
2470 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2472 (if gnus-summary-tool-bar-map
2473 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2475 (defun gnus-score-set-default (var value)
2476 "A version of set that updates the GNU Emacs menu-bar."
2478 ;; It is the message that forces the active status to be updated.
2481 (defun gnus-make-score-map (type)
2482 "Make a summary score map of type TYPE."
2485 (let ((headers '(("author" "from" string)
2486 ("subject" "subject" string)
2487 ("article body" "body" string)
2488 ("article head" "head" string)
2489 ("xref" "xref" string)
2490 ("extra header" "extra" string)
2491 ("lines" "lines" number)
2492 ("followups to author" "followup" string)))
2493 (types '((number ("less than" <)
2496 (string ("substring" s)
2500 (perms '(("temporary" (current-time-string))
2508 (if (eq type 'lower)
2513 (setq header (car headers))
2519 (let ((ts (cdr (assoc (nth 2 header) types)))
2535 'gnus-summary-score-entry
2537 (if (or (string= (nth 1 header)
2539 (string= (nth 1 header)
2542 (list 'gnus-summary-header
2544 (list 'quote (nth 1 (car ts)))
2545 (list 'gnus-score-delta-default
2552 (list (nreverse outp))))
2555 (list (nreverse outt))))
2557 (setq headers (cdr headers)))
2558 (list (nreverse outh))))))))
2562 (defun gnus-summary-mode (&optional group)
2563 "Major mode for reading articles.
2565 All normal editing commands are switched off.
2566 \\<gnus-summary-mode-map>
2567 Each line in this buffer represents one article. To read an
2568 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2569 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2572 You can also post articles and send mail from this buffer. To
2573 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2574 of an article, type `\\[gnus-summary-reply]'.
2576 There are approx. one gazillion commands you can execute in this
2577 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2579 The following commands are available:
2581 \\{gnus-summary-mode-map}"
2583 (kill-all-local-variables)
2584 (when (gnus-visual-p 'summary-menu 'menu)
2585 (gnus-summary-make-menu-bar)
2586 (gnus-summary-make-tool-bar))
2587 (gnus-summary-make-local-variables)
2588 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2589 (gnus-summary-make-local-variables))
2590 (gnus-make-thread-indent-array)
2591 (gnus-simplify-mode-line)
2592 (setq major-mode 'gnus-summary-mode)
2593 (setq mode-name "Summary")
2594 (make-local-variable 'minor-mode-alist)
2595 (use-local-map gnus-summary-mode-map)
2596 (buffer-disable-undo)
2597 (setq buffer-read-only t) ;Disable modification
2598 (setq truncate-lines t)
2599 (setq selective-display t)
2600 (setq selective-display-ellipses t) ;Display `...'
2601 (gnus-summary-set-display-table)
2602 (gnus-set-default-directory)
2603 (setq gnus-newsgroup-name group)
2604 (unless (gnus-news-group-p group)
2605 (setq gnus-newsgroup-incorporated
2606 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2607 (make-local-variable 'gnus-summary-line-format)
2608 (make-local-variable 'gnus-summary-line-format-spec)
2609 (make-local-variable 'gnus-summary-dummy-line-format)
2610 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2611 (make-local-variable 'gnus-summary-mark-positions)
2612 (make-local-hook 'pre-command-hook)
2613 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2614 (gnus-run-hooks 'gnus-summary-mode-hook)
2615 (turn-on-gnus-mailing-list-mode)
2616 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2617 (gnus-update-summary-mark-positions))
2619 (defun gnus-summary-make-local-variables ()
2620 "Make all the local summary buffer variables."
2622 (dolist (local gnus-summary-local-variables)
2625 (if (eq (cdr local) 'global)
2626 ;; Copy the global value of the variable.
2627 (setq global (symbol-value (car local)))
2628 ;; Use the value from the list.
2629 (setq global (eval (cdr local))))
2630 (set (make-local-variable (car local)) global))
2631 ;; Simple nil-valued local variable.
2632 (set (make-local-variable local) nil)))))
2634 (defun gnus-summary-clear-local-variables ()
2635 (let ((locals gnus-summary-local-variables))
2637 (if (consp (car locals))
2638 (and (vectorp (caar locals))
2639 (set (caar locals) nil))
2640 (and (vectorp (car locals))
2641 (set (car locals) nil)))
2642 (setq locals (cdr locals)))))
2644 ;; Summary data functions.
2646 (defmacro gnus-data-number (data)
2649 (defmacro gnus-data-set-number (data number)
2650 `(setcar ,data ,number))
2652 (defmacro gnus-data-mark (data)
2655 (defmacro gnus-data-set-mark (data mark)
2656 `(setcar (nthcdr 1 ,data) ,mark))
2658 (defmacro gnus-data-pos (data)
2661 (defmacro gnus-data-set-pos (data pos)
2662 `(setcar (nthcdr 2 ,data) ,pos))
2664 (defmacro gnus-data-header (data)
2667 (defmacro gnus-data-set-header (data header)
2668 `(setcar (nthcdr 3 ,data) ,header))
2670 (defmacro gnus-data-level (data)
2673 (defmacro gnus-data-unread-p (data)
2674 `(= (nth 1 ,data) gnus-unread-mark))
2676 (defmacro gnus-data-read-p (data)
2677 `(/= (nth 1 ,data) gnus-unread-mark))
2679 (defmacro gnus-data-pseudo-p (data)
2680 `(consp (nth 3 ,data)))
2682 (defmacro gnus-data-find (number)
2683 `(assq ,number gnus-newsgroup-data))
2685 (defmacro gnus-data-find-list (number &optional data)
2686 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2687 (memq (assq ,number bdata)
2690 (defmacro gnus-data-make (number mark pos header level)
2691 `(list ,number ,mark ,pos ,header ,level))
2693 (defun gnus-data-enter (after-article number mark pos header level offset)
2694 (let ((data (gnus-data-find-list after-article)))
2696 (error "No such article: %d" after-article))
2697 (setcdr data (cons (gnus-data-make number mark pos header level)
2699 (setq gnus-newsgroup-data-reverse nil)
2700 (gnus-data-update-list (cddr data) offset)))
2702 (defun gnus-data-enter-list (after-article list &optional offset)
2704 (let ((data (and after-article (gnus-data-find-list after-article)))
2708 (let ((odata gnus-newsgroup-data))
2709 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2711 (gnus-data-update-list odata offset)))
2712 ;; Find the last element in the list to be spliced into the main
2715 (setq list (cdr list)))
2718 (setcdr list gnus-newsgroup-data)
2719 (setq gnus-newsgroup-data ilist)
2721 (gnus-data-update-list (cdr list) offset)))
2722 (setcdr list (cdr data))
2725 (gnus-data-update-list (cdr list) offset))))
2726 (setq gnus-newsgroup-data-reverse nil))))
2728 (defun gnus-data-remove (article &optional offset)
2729 (let ((data gnus-newsgroup-data))
2730 (if (= (gnus-data-number (car data)) article)
2732 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2733 gnus-newsgroup-data-reverse nil)
2735 (gnus-data-update-list gnus-newsgroup-data offset)))
2737 (when (= (gnus-data-number (cadr data)) article)
2738 (setcdr data (cddr data))
2740 (gnus-data-update-list (cdr data) offset))
2742 gnus-newsgroup-data-reverse nil))
2743 (setq data (cdr data))))))
2745 (defmacro gnus-data-list (backward)
2747 (or gnus-newsgroup-data-reverse
2748 (setq gnus-newsgroup-data-reverse
2749 (reverse gnus-newsgroup-data)))
2750 gnus-newsgroup-data))
2752 (defun gnus-data-update-list (data offset)
2753 "Add OFFSET to the POS of all data entries in DATA."
2754 (setq gnus-newsgroup-data-reverse nil)
2756 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2757 (setq data (cdr data))))
2759 (defun gnus-summary-article-pseudo-p (article)
2760 "Say whether this article is a pseudo article or not."
2761 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2763 (defmacro gnus-summary-article-sparse-p (article)
2764 "Say whether this article is a sparse article or not."
2765 `(memq ,article gnus-newsgroup-sparse))
2767 (defmacro gnus-summary-article-ancient-p (article)
2768 "Say whether this article is a sparse article or not."
2769 `(memq ,article gnus-newsgroup-ancient))
2771 (defun gnus-article-parent-p (number)
2772 "Say whether this article is a parent or not."
2773 (let ((data (gnus-data-find-list number)))
2774 (and (cdr data) ; There has to be an article after...
2775 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2776 (gnus-data-level (nth 1 data))))))
2778 (defun gnus-article-children (number)
2779 "Return a list of all children to NUMBER."
2780 (let* ((data (gnus-data-find-list number))
2781 (level (gnus-data-level (car data)))
2783 (setq data (cdr data))
2785 (= (gnus-data-level (car data)) (1+ level)))
2786 (push (gnus-data-number (car data)) children)
2787 (setq data (cdr data)))
2790 (defmacro gnus-summary-skip-intangible ()
2791 "If the current article is intangible, then jump to a different article."
2792 '(let ((to (get-text-property (point) 'gnus-intangible)))
2793 (and to (gnus-summary-goto-subject to))))
2795 (defmacro gnus-summary-article-intangible-p ()
2796 "Say whether this article is intangible or not."
2797 '(get-text-property (point) 'gnus-intangible))
2799 (defun gnus-article-read-p (article)
2800 "Say whether ARTICLE is read or not."
2801 (not (or (memq article gnus-newsgroup-marked)
2802 (memq article gnus-newsgroup-spam-marked)
2803 (memq article gnus-newsgroup-unreads)
2804 (memq article gnus-newsgroup-unselected)
2805 (memq article gnus-newsgroup-dormant))))
2807 ;; Some summary mode macros.
2809 (defmacro gnus-summary-article-number ()
2810 "The article number of the article on the current line.
2811 If there isn't an article number here, then we return the current
2814 (gnus-summary-skip-intangible)
2815 (or (get-text-property (point) 'gnus-number)
2816 (gnus-summary-last-subject))))
2818 (defmacro gnus-summary-article-header (&optional number)
2819 "Return the header of article NUMBER."
2820 `(gnus-data-header (gnus-data-find
2821 ,(or number '(gnus-summary-article-number)))))
2823 (defmacro gnus-summary-thread-level (&optional number)
2824 "Return the level of thread that starts with article NUMBER."
2825 `(if (and (eq gnus-summary-make-false-root 'dummy)
2826 (get-text-property (point) 'gnus-intangible))
2828 (gnus-data-level (gnus-data-find
2829 ,(or number '(gnus-summary-article-number))))))
2831 (defmacro gnus-summary-article-mark (&optional number)
2832 "Return the mark of article NUMBER."
2833 `(gnus-data-mark (gnus-data-find
2834 ,(or number '(gnus-summary-article-number)))))
2836 (defmacro gnus-summary-article-pos (&optional number)
2837 "Return the position of the line of article NUMBER."
2838 `(gnus-data-pos (gnus-data-find
2839 ,(or number '(gnus-summary-article-number)))))
2841 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2842 (defmacro gnus-summary-article-subject (&optional number)
2843 "Return current subject string or nil if nothing."
2846 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2847 '(gnus-data-header (assq (gnus-summary-article-number)
2848 gnus-newsgroup-data)))))
2851 (mail-header-subject headers))))
2853 (defmacro gnus-summary-article-score (&optional number)
2854 "Return current article score."
2855 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2856 gnus-newsgroup-scored))
2857 gnus-summary-default-score 0))
2859 (defun gnus-summary-article-children (&optional number)
2860 "Return a list of article numbers that are children of article NUMBER."
2861 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2862 (level (gnus-data-level (car data)))
2864 (while (and (setq data (cdr data))
2865 (> (setq l (gnus-data-level (car data))) level))
2866 (and (= (1+ level) l)
2867 (push (gnus-data-number (car data))
2869 (nreverse children)))
2871 (defun gnus-summary-article-parent (&optional number)
2872 "Return the article number of the parent of article NUMBER."
2873 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2874 (gnus-data-list t)))
2875 (level (gnus-data-level (car data))))
2877 () ; This is a root.
2878 ;; We search until we find an article with a level less than
2879 ;; this one. That function has to be the parent.
2880 (while (and (setq data (cdr data))
2881 (not (< (gnus-data-level (car data)) level))))
2882 (and data (gnus-data-number (car data))))))
2884 (defun gnus-unread-mark-p (mark)
2885 "Say whether MARK is the unread mark."
2886 (= mark gnus-unread-mark))
2888 (defun gnus-read-mark-p (mark)
2889 "Say whether MARK is one of the marks that mark as read.
2890 This is all marks except unread, ticked, dormant, and expirable."
2891 (not (or (= mark gnus-unread-mark)
2892 (= mark gnus-ticked-mark)
2893 (= mark gnus-spam-mark)
2894 (= mark gnus-dormant-mark)
2895 (= mark gnus-expirable-mark))))
2897 (defmacro gnus-article-mark (number)
2898 "Return the MARK of article NUMBER.
2899 This macro should only be used when computing the mark the \"first\"
2900 time; i.e., when generating the summary lines. After that,
2901 `gnus-summary-article-mark' should be used to examine the
2904 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2905 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2906 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2907 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2908 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2909 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2910 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2911 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2912 gnus-ancient-mark))))
2914 ;; Saving hidden threads.
2916 (defmacro gnus-save-hidden-threads (&rest forms)
2917 "Save hidden threads, eval FORMS, and restore the hidden threads."
2918 (let ((config (make-symbol "config")))
2919 `(let ((,config (gnus-hidden-threads-configuration)))
2923 (gnus-restore-hidden-threads-configuration ,config)))))
2924 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2925 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2927 (defun gnus-data-compute-positions ()
2928 "Compute the positions of all articles."
2929 (setq gnus-newsgroup-data-reverse nil)
2930 (let ((data gnus-newsgroup-data))
2932 (gnus-save-hidden-threads
2933 (gnus-summary-show-all-threads)
2934 (goto-char (point-min))
2936 (while (get-text-property (point) 'gnus-intangible)
2938 (gnus-data-set-pos (car data) (+ (point) 3))
2939 (setq data (cdr data))
2940 (forward-line 1))))))
2942 (defun gnus-hidden-threads-configuration ()
2943 "Return the current hidden threads configuration."
2946 (goto-char (point-min))
2947 (while (search-forward "\r" nil t)
2948 (push (1- (point)) config))
2951 (defun gnus-restore-hidden-threads-configuration (config)
2952 "Restore hidden threads configuration from CONFIG."
2954 (let (point buffer-read-only)
2955 (while (setq point (pop config))
2956 (when (and (< point (point-max))
2958 (eq (char-after) ?\n))
2959 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2961 ;; Various summary mode internalish functions.
2963 (defun gnus-mouse-pick-article (e)
2966 (gnus-summary-next-page nil t))
2968 (defun gnus-summary-set-display-table ()
2969 "Change the display table.
2970 Odd characters have a tendency to mess
2971 up nicely formatted displays - we make all possible glyphs
2972 display only a single character."
2974 ;; We start from the standard display table, if any.
2975 (let ((table (or (copy-sequence standard-display-table)
2976 (make-display-table)))
2978 ;; Nix out all the control chars...
2979 (while (>= (setq i (1- i)) 0)
2980 (aset table i [??]))
2981 ;; ... but not newline and cr, of course. (cr is necessary for the
2982 ;; selective display).
2983 (aset table ?\n nil)
2984 (aset table ?\r nil)
2985 ;; We keep TAB as well.
2986 (aset table ?\t nil)
2987 ;; We nix out any glyphs over 126 that are not set already.
2989 (while (>= (setq i (1- i)) 127)
2990 ;; Only modify if the entry is nil.
2991 (unless (aref table i)
2992 (aset table i [??]))))
2993 (setq buffer-display-table table)))
2995 (defun gnus-summary-set-article-display-arrow (pos)
2996 "Update the overlay arrow to point to line at position POS."
2997 (when (and gnus-summary-display-arrow
2998 (boundp 'overlay-arrow-position)
2999 (boundp 'overlay-arrow-string))
3003 (unless overlay-arrow-position
3004 (setq overlay-arrow-position (make-marker)))
3005 (setq overlay-arrow-string "=>"
3006 overlay-arrow-position (set-marker overlay-arrow-position
3008 (current-buffer))))))
3010 (defun gnus-summary-buffer-name (group)
3011 "Return the summary buffer name of GROUP."
3012 (concat "*Summary " (gnus-group-decoded-name group) "*"))
3014 (defun gnus-summary-setup-buffer (group)
3015 "Initialize summary buffer."
3016 (let ((buffer (gnus-summary-buffer-name group))
3017 (dead-name (concat "*Dead Summary "
3018 (gnus-group-decoded-name group) "*")))
3019 ;; If a dead summary buffer exists, we kill it.
3020 (when (gnus-buffer-live-p dead-name)
3021 (gnus-kill-buffer dead-name))
3022 (if (get-buffer buffer)
3025 (setq gnus-summary-buffer (current-buffer))
3026 (not gnus-newsgroup-prepared))
3027 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3028 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3029 (gnus-summary-mode group)
3031 (gnus-carpal-setup-buffer 'summary))
3032 (unless gnus-single-article-buffer
3033 (make-local-variable 'gnus-article-buffer)
3034 (make-local-variable 'gnus-article-current)
3035 (make-local-variable 'gnus-original-article-buffer))
3036 (setq gnus-newsgroup-name group)
3037 ;; Set any local variables in the group parameters.
3038 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3041 (defun gnus-set-global-variables ()
3042 "Set the global equivalents of the buffer-local variables.
3043 They are set to the latest values they had. These reflect the summary
3044 buffer that was in action when the last article was fetched."
3045 (when (eq major-mode 'gnus-summary-mode)
3046 (setq gnus-summary-buffer (current-buffer))
3047 (let ((name gnus-newsgroup-name)
3048 (marked gnus-newsgroup-marked)
3049 (spam gnus-newsgroup-spam-marked)
3050 (unread gnus-newsgroup-unreads)
3051 (headers gnus-current-headers)
3052 (data gnus-newsgroup-data)
3053 (summary gnus-summary-buffer)
3054 (article-buffer gnus-article-buffer)
3055 (original gnus-original-article-buffer)
3056 (gac gnus-article-current)
3057 (reffed gnus-reffed-article-number)
3058 (score-file gnus-current-score-file)
3059 (default-charset gnus-newsgroup-charset)
3061 (let ((locals gnus-newsgroup-variables))
3063 (if (consp (car locals))
3064 (push (eval (caar locals)) vlist)
3065 (push (eval (car locals)) vlist))
3066 (setq locals (cdr locals)))
3067 (setq vlist (nreverse vlist)))
3069 (set-buffer gnus-group-buffer)
3070 (setq gnus-newsgroup-name name
3071 gnus-newsgroup-marked marked
3072 gnus-newsgroup-spam-marked spam
3073 gnus-newsgroup-unreads unread
3074 gnus-current-headers headers
3075 gnus-newsgroup-data data
3076 gnus-article-current gac
3077 gnus-summary-buffer summary
3078 gnus-article-buffer article-buffer
3079 gnus-original-article-buffer original
3080 gnus-reffed-article-number reffed
3081 gnus-current-score-file score-file
3082 gnus-newsgroup-charset default-charset)
3083 (let ((locals gnus-newsgroup-variables))
3085 (if (consp (car locals))
3086 (set (caar locals) (pop vlist))
3087 (set (car locals) (pop vlist)))
3088 (setq locals (cdr locals))))
3089 ;; The article buffer also has local variables.
3090 (when (gnus-buffer-live-p gnus-article-buffer)
3091 (set-buffer gnus-article-buffer)
3092 (setq gnus-summary-buffer summary))))))
3094 (defun gnus-summary-article-unread-p (article)
3095 "Say whether ARTICLE is unread or not."
3096 (memq article gnus-newsgroup-unreads))
3098 (defun gnus-summary-first-article-p (&optional article)
3099 "Return whether ARTICLE is the first article in the buffer."
3100 (if (not (setq article (or article (gnus-summary-article-number))))
3102 (eq article (caar gnus-newsgroup-data))))
3104 (defun gnus-summary-last-article-p (&optional article)
3105 "Return whether ARTICLE is the last article in the buffer."
3106 (if (not (setq article (or article (gnus-summary-article-number))))
3107 ;; All non-existent numbers are the last article. :-)
3109 (not (cdr (gnus-data-find-list article)))))
3111 (defun gnus-make-thread-indent-array ()
3113 (unless (and gnus-thread-indent-array
3114 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3115 (setq gnus-thread-indent-array (make-vector 201 "")
3116 gnus-thread-indent-array-level gnus-thread-indent-level)
3118 (aset gnus-thread-indent-array n
3119 (make-string (* n gnus-thread-indent-level) ? ))
3122 (defun gnus-update-summary-mark-positions ()
3123 "Compute where the summary marks are to go."
3125 (when (gnus-buffer-exists-p gnus-summary-buffer)
3126 (set-buffer gnus-summary-buffer))
3127 (let ((gnus-replied-mark 129)
3128 (gnus-score-below-mark 130)
3129 (gnus-score-over-mark 130)
3130 (gnus-undownloaded-mark 131)
3131 (spec gnus-summary-line-format-spec)
3134 (gnus-set-work-buffer)
3135 (let ((gnus-summary-line-format-spec spec)
3136 (gnus-newsgroup-downloadable '(0)))
3137 (gnus-summary-insert-line
3138 (make-full-mail-header 0 "" "nobody"
3139 "05 Apr 2001 23:33:09 +0400"
3141 0 nil t 128 t nil "" nil 1)
3142 (goto-char (point-min))
3143 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3144 (- (point) (point-min) 1)))))
3145 (goto-char (point-min))
3146 (push (cons 'replied (and (search-forward "\201" nil t)
3147 (- (point) (point-min) 1)))
3149 (goto-char (point-min))
3150 (push (cons 'score (and (search-forward "\202" nil t)
3151 (- (point) (point-min) 1)))
3153 (goto-char (point-min))
3154 (push (cons 'download
3155 (and (search-forward "\203" nil t)
3156 (- (point) (point-min) 1)))
3158 (setq gnus-summary-mark-positions pos))))
3160 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3161 "Insert a dummy root in the summary buffer."
3163 (gnus-add-text-properties
3164 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3165 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3167 (defun gnus-summary-extract-address-component (from)
3168 (or (car (funcall gnus-extract-address-components from))
3171 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3172 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3173 default-mime-charset)))
3174 ;; Is it really necessary to do this next part for each summary line?
3175 ;; Luckily, doesn't seem to slow things down much.
3177 (and gnus-ignored-from-addresses
3178 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3179 (let ((extra-headers (mail-header-extra header))
3183 ((setq to (cdr (assq 'To extra-headers)))
3186 (gnus-summary-extract-address-component
3187 (funcall gnus-decode-encoded-word-function to)))))
3188 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3189 (concat "=> " newsgroups)))))
3190 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3192 (defun gnus-summary-insert-line (gnus-tmp-header
3193 gnus-tmp-level gnus-tmp-current
3194 undownloaded gnus-tmp-unread gnus-tmp-replied
3195 gnus-tmp-expirable gnus-tmp-subject-or-nil
3196 &optional gnus-tmp-dummy gnus-tmp-score
3198 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3199 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3200 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3201 (gnus-tmp-score-char
3202 (if (or (null gnus-summary-default-score)
3203 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3204 gnus-summary-zcore-fuzz))
3206 (if (< gnus-tmp-score gnus-summary-default-score)
3207 gnus-score-below-mark gnus-score-over-mark)))
3208 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3210 (cond (gnus-tmp-process gnus-process-mark)
3211 ((memq gnus-tmp-current gnus-newsgroup-cached)
3213 (gnus-tmp-replied gnus-replied-mark)
3214 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3215 gnus-forwarded-mark)
3216 ((memq gnus-tmp-current gnus-newsgroup-saved)
3218 ((memq gnus-tmp-number gnus-newsgroup-recent)
3220 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3223 (gnus-tmp-downloaded
3225 gnus-undownloaded-mark)
3226 (gnus-newsgroup-agentized
3227 gnus-downloaded-mark)
3230 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3233 ((string-match "<[^>]+> *$" gnus-tmp-from)
3234 (let ((beg (match-beginning 0)))
3235 (or (and (string-match "^\".+\"" gnus-tmp-from)
3236 (substring gnus-tmp-from 1 (1- (match-end 0))))
3237 (substring gnus-tmp-from 0 beg))))
3238 ((string-match "(.+)" gnus-tmp-from)
3239 (substring gnus-tmp-from
3240 (1+ (match-beginning 0)) (1- (match-end 0))))
3242 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3243 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3244 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3245 (buffer-read-only nil))
3246 (when (string= gnus-tmp-name "")
3247 (setq gnus-tmp-name gnus-tmp-from))
3248 (unless (numberp gnus-tmp-lines)
3249 (setq gnus-tmp-lines -1))
3250 (if (= gnus-tmp-lines -1)
3251 (setq gnus-tmp-lines "?")
3252 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3253 (gnus-put-text-property-excluding-characters-with-faces
3255 (progn (eval gnus-summary-line-format-spec) (point))
3256 'gnus-number gnus-tmp-number)
3257 (when (gnus-visual-p 'summary-highlight 'highlight)
3259 (gnus-run-hooks 'gnus-summary-update-hook)
3262 (defun gnus-summary-update-line (&optional dont-update)
3263 "Update summary line after change."
3264 (when (and gnus-summary-default-score
3265 (not gnus-summary-inhibit-highlight))
3266 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3267 (article (gnus-summary-article-number))
3268 (score (gnus-summary-article-score article)))
3270 (if (and gnus-summary-mark-below
3271 (< (gnus-summary-article-score)
3272 gnus-summary-mark-below))
3273 ;; This article has a low score, so we mark it as read.
3274 (when (memq article gnus-newsgroup-unreads)
3275 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3276 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3277 ;; This article was previously marked as read on account
3278 ;; of a low score, but now it has risen, so we mark it as
3280 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3281 (gnus-summary-update-mark
3282 (if (or (null gnus-summary-default-score)
3283 (<= (abs (- score gnus-summary-default-score))
3284 gnus-summary-zcore-fuzz))
3286 (if (< score gnus-summary-default-score)
3287 gnus-score-below-mark gnus-score-over-mark))
3289 ;; Do visual highlighting.
3290 (when (gnus-visual-p 'summary-highlight 'highlight)
3291 (gnus-run-hooks 'gnus-summary-update-hook)))))
3293 (defvar gnus-tmp-new-adopts nil)
3295 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3296 "Return the number of articles in THREAD.
3297 This may be 0 in some cases -- if none of the articles in
3298 the thread are to be displayed."
3300 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3302 ((not (listp thread))
3304 ((and (consp thread) (cdr thread))
3307 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3310 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3313 (when (and level (zerop level) gnus-tmp-new-adopts)
3316 'gnus-summary-number-of-articles-in-thread
3317 gnus-tmp-new-adopts))))
3319 (if (> number 1) gnus-not-empty-thread-mark
3320 gnus-empty-thread-mark)
3323 (defsubst gnus-summary-line-message-size (head)
3324 "Return pretty-printed version of message size.
3325 This function is intended to be used in
3326 `gnus-summary-line-format-alist', which see."
3327 (let ((c (or (mail-header-chars head) -1)))
3328 (cond ((< c 0) "n/a") ; chars not available
3329 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3330 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3331 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3332 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3335 (defun gnus-summary-set-local-parameters (group)
3336 "Go through the local params of GROUP and set all variable specs in that list."
3337 (let ((params (gnus-group-find-parameter group))
3338 (vars '(quit-config)) ; Ignore quit-config.
3341 (setq elem (car params)
3342 params (cdr params))
3343 (and (consp elem) ; Has to be a cons.
3344 (consp (cdr elem)) ; The cdr has to be a list.
3345 (symbolp (car elem)) ; Has to be a symbol in there.
3346 (not (memq (car elem) vars))
3347 (ignore-errors ; So we set it.
3348 (push (car elem) vars)
3349 (make-local-variable (car elem))
3350 (set (car elem) (eval (nth 1 elem))))))))
3352 (defun gnus-summary-read-group (group &optional show-all no-article
3353 kill-buffer no-display backward
3355 "Start reading news in newsgroup GROUP.
3356 If SHOW-ALL is non-nil, already read articles are also listed.
3357 If NO-ARTICLE is non-nil, no article is selected initially.
3358 If NO-DISPLAY, don't generate a summary buffer."
3362 (let ((gnus-auto-select-next nil))
3363 (or (gnus-summary-read-group-1
3364 group show-all no-article
3365 kill-buffer no-display
3368 select-articles nil)))))
3369 (eq gnus-auto-select-next 'quietly))
3370 (set-buffer gnus-group-buffer)
3371 ;; The entry function called above goes to the next
3372 ;; group automatically, so we go two groups back
3373 ;; if we are searching for the previous group.
3375 (gnus-group-prev-unread-group 2))
3376 (if (not (equal group (gnus-group-group-name)))
3377 (setq group (gnus-group-group-name))
3381 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3382 "Directly jump to the other GROUP from summary buffer.
3383 If SHOW-ALL is non-nil, already read articles are also listed."
3385 (if (eq gnus-summary-buffer (current-buffer))
3386 (list (completing-read
3387 "Group: " gnus-active-hashtb nil t
3388 (when (and gnus-newsgroup-name
3389 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3390 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3391 'gnus-group-history)
3393 (error "%s must be invoked from a gnus summary buffer." this-command)))
3394 (unless (or (zerop (length group))
3395 (and gnus-newsgroup-name
3396 (string-equal gnus-newsgroup-name group)))
3398 (gnus-summary-read-group group show-all
3399 gnus-dont-select-after-jump-to-other-group)))
3401 (defun gnus-summary-read-group-1 (group show-all no-article
3402 kill-buffer no-display
3403 &optional select-articles)
3404 ;; Killed foreign groups can't be entered.
3405 ;; (when (and (not (gnus-group-native-p group))
3406 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3407 ;; (error "Dead non-native groups can't be entered"))
3408 (gnus-message 5 "Retrieving newsgroup: %s..."
3409 (gnus-group-decoded-name group))
3410 (let* ((new-group (gnus-summary-setup-buffer group))
3411 (quit-config (gnus-group-quit-config group))
3412 (did-select (and new-group (gnus-select-newsgroup
3413 group show-all select-articles))))
3415 ;; This summary buffer exists already, so we just select it.
3417 (gnus-set-global-variables)
3419 (gnus-kill-or-deaden-summary kill-buffer))
3420 (gnus-configure-windows 'summary 'force)
3421 (gnus-set-mode-line 'summary)
3422 (gnus-summary-position-point)
3425 ;; We couldn't select this group.
3427 (when (and (eq major-mode 'gnus-summary-mode)
3428 (not (equal (current-buffer) kill-buffer)))
3429 (kill-buffer (current-buffer))
3430 (if (not quit-config)
3432 ;; Update the info -- marks might need to be removed,
3434 (gnus-summary-update-info)
3435 (set-buffer gnus-group-buffer)
3436 (gnus-group-jump-to-group group)
3437 (gnus-group-next-unread-group 1))
3438 (gnus-handle-ephemeral-exit quit-config)))
3439 (let ((grpinfo (gnus-get-info group)))
3440 (if (null (gnus-info-read grpinfo))
3441 (gnus-message 3 "Group %s contains no messages"
3442 (gnus-group-decoded-name group))
3443 (gnus-message 3 "Can't select group")))
3445 ;; The user did a `C-g' while prompting for number of articles,
3446 ;; so we exit this group.
3447 ((eq did-select 'quit)
3448 (and (eq major-mode 'gnus-summary-mode)
3449 (not (equal (current-buffer) kill-buffer))
3450 (kill-buffer (current-buffer)))
3452 (gnus-kill-or-deaden-summary kill-buffer))
3453 (if (not quit-config)
3455 (set-buffer gnus-group-buffer)
3456 (gnus-group-jump-to-group group)
3457 (gnus-group-next-unread-group 1)
3458 (gnus-configure-windows 'group 'force))
3459 (gnus-handle-ephemeral-exit quit-config))
3460 ;; Finally signal the quit.
3462 ;; The group was successfully selected.
3464 (gnus-set-global-variables)
3465 ;; Save the active value in effect when the group was entered.
3466 (setq gnus-newsgroup-active
3468 (gnus-active gnus-newsgroup-name)))
3469 ;; You can change the summary buffer in some way with this hook.
3470 (gnus-run-hooks 'gnus-select-group-hook)
3471 (gnus-update-format-specifications
3472 nil 'summary 'summary-mode 'summary-dummy)
3473 (gnus-update-summary-mark-positions)
3474 ;; Do score processing.
3475 (when gnus-use-scoring
3476 (gnus-possibly-score-headers))
3477 ;; Check whether to fill in the gaps in the threads.
3478 (when gnus-build-sparse-threads
3479 (gnus-build-sparse-threads))
3480 ;; Find the initial limit.
3481 (if gnus-show-threads
3483 (let ((gnus-newsgroup-dormant nil))
3484 (gnus-summary-initial-limit show-all))
3485 (gnus-summary-initial-limit show-all))
3486 ;; When unthreaded, all articles are always shown.
3487 (setq gnus-newsgroup-limit
3489 (lambda (header) (mail-header-number header))
3490 gnus-newsgroup-headers)))
3491 ;; Generate the summary buffer.
3493 (gnus-summary-prepare))
3494 (when gnus-use-trees
3495 (gnus-tree-open group)
3496 (setq gnus-summary-highlight-line-function
3497 'gnus-tree-highlight-article))
3498 ;; If the summary buffer is empty, but there are some low-scored
3499 ;; articles or some excluded dormants, we include these in the
3501 (when (and (zerop (buffer-size))
3503 (cond (gnus-newsgroup-dormant
3504 (gnus-summary-limit-include-dormant))
3505 ((and gnus-newsgroup-scored show-all)
3506 (gnus-summary-limit-include-expunged t))))
3507 ;; Function `gnus-apply-kill-file' must be called in this hook.
3508 (gnus-run-hooks 'gnus-apply-kill-hook)
3509 (if (and (zerop (buffer-size))
3512 ;; This newsgroup is empty.
3513 (gnus-summary-catchup-and-exit nil t)
3514 (gnus-message 6 "No unread news")
3516 (gnus-kill-or-deaden-summary kill-buffer))
3517 ;; Return nil from this function.
3519 ;; Hide conversation thread subtrees. We cannot do this in
3520 ;; gnus-summary-prepare-hook since kill processing may not
3521 ;; work with hidden articles.
3522 (gnus-summary-maybe-hide-threads)
3524 (gnus-kill-or-deaden-summary kill-buffer))
3525 (gnus-summary-auto-select-subject)
3526 ;; Show first unread article if requested.
3527 (if (and (not no-article)
3529 gnus-newsgroup-unreads
3530 gnus-auto-select-first)
3532 (gnus-configure-windows 'summary)
3533 (let ((art (gnus-summary-article-number)))
3534 (unless (and (not gnus-plugged)
3535 (or (memq art gnus-newsgroup-undownloaded)
3536 (memq art gnus-newsgroup-downloadable)))
3537 (gnus-summary-goto-article art))))
3538 ;; Don't select any articles.
3539 (gnus-summary-position-point)
3540 (gnus-configure-windows 'summary 'force)
3541 (gnus-set-mode-line 'summary))
3542 (when (get-buffer-window gnus-group-buffer t)
3543 ;; Gotta use windows, because recenter does weird stuff if
3544 ;; the current buffer ain't the displayed window.
3545 (let ((owin (selected-window)))
3546 (select-window (get-buffer-window gnus-group-buffer t))
3547 (when (gnus-group-goto-group group)
3549 (select-window owin)))
3550 ;; Mark this buffer as "prepared".
3551 (setq gnus-newsgroup-prepared t)
3552 (gnus-run-hooks 'gnus-summary-prepared-hook)
3553 (unless (gnus-ephemeral-group-p group)
3554 (gnus-group-update-group group))
3557 (defun gnus-summary-auto-select-subject ()
3558 "Select the subject line on initial group entry."
3559 (goto-char (point-min))
3561 ((eq gnus-auto-select-subject 'best)
3562 (gnus-summary-best-unread-subject))
3563 ((eq gnus-auto-select-subject 'unread)
3564 (gnus-summary-first-unread-subject))
3565 ((eq gnus-auto-select-subject 'unseen)
3566 (gnus-summary-first-unseen-subject))
3567 ((eq gnus-auto-select-subject 'unseen-or-unread)
3568 (gnus-summary-first-unseen-or-unread-subject))
3569 ((eq gnus-auto-select-subject 'first)
3572 ((gnus-functionp gnus-auto-select-subject)
3573 (funcall gnus-auto-select-subject))))
3575 (defun gnus-summary-prepare ()
3576 "Generate the summary buffer."
3578 (let ((buffer-read-only nil))
3580 (setq gnus-newsgroup-data nil
3581 gnus-newsgroup-data-reverse nil)
3582 (gnus-run-hooks 'gnus-summary-generate-hook)
3583 ;; Generate the buffer, either with threads or without.
3584 (when gnus-newsgroup-headers
3585 (gnus-summary-prepare-threads
3586 (if gnus-show-threads
3587 (gnus-sort-gathered-threads
3588 (funcall gnus-summary-thread-gathering-function
3590 (gnus-cut-threads (gnus-make-threads)))))
3591 ;; Unthreaded display.
3592 (gnus-sort-articles gnus-newsgroup-headers))))
3593 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3594 ;; Call hooks for modifying summary buffer.
3595 (goto-char (point-min))
3596 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3598 (defsubst gnus-general-simplify-subject (subject)
3599 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3602 ;; Truncate the subject.
3603 (gnus-simplify-subject-functions
3604 (gnus-map-function gnus-simplify-subject-functions subject))
3605 ((numberp gnus-summary-gather-subject-limit)
3606 (setq subject (gnus-simplify-subject-re subject))
3607 (if (> (length subject) gnus-summary-gather-subject-limit)
3608 (substring subject 0 gnus-summary-gather-subject-limit)
3610 ;; Fuzzily simplify it.
3611 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3612 (gnus-simplify-subject-fuzzy subject))
3613 ;; Just remove the leading "Re:".
3615 (gnus-simplify-subject-re subject))))
3617 (if (and gnus-summary-gather-exclude-subject
3618 (string-match gnus-summary-gather-exclude-subject subject))
3619 nil ; This article shouldn't be gathered
3622 (defun gnus-summary-simplify-subject-query ()
3623 "Query where the respool algorithm would put this article."
3625 (gnus-summary-select-article)
3627 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3629 (defun gnus-gather-threads-by-subject (threads)
3630 "Gather threads by looking at Subject headers."
3631 (if (not gnus-summary-make-false-root)
3633 (let ((hashtb (gnus-make-hashtable 1024))
3636 subject hthread whole-subject)
3638 (setq subject (gnus-general-simplify-subject
3639 (setq whole-subject (mail-header-subject
3642 (if (setq hthread (gnus-gethash subject hashtb))
3644 ;; We enter a dummy root into the thread, if we
3645 ;; haven't done that already.
3646 (unless (stringp (caar hthread))
3647 (setcar hthread (list whole-subject (car hthread))))
3648 ;; We add this new gathered thread to this gathered
3650 (setcdr (car hthread)
3651 (nconc (cdar hthread) (list (car threads))))
3652 ;; Remove it from the list of threads.
3653 (setcdr prev (cdr threads))
3654 (setq threads prev))
3655 ;; Enter this thread into the hash table.
3656 (gnus-sethash subject
3657 (if gnus-summary-make-false-root-always
3659 ;; If you want a dummy root above all
3661 (setcar threads (list whole-subject
3667 (setq threads (cdr threads)))
3670 (defun gnus-gather-threads-by-references (threads)
3671 "Gather threads by looking at References headers."
3672 (let ((idhashtb (gnus-make-hashtable 1024))
3673 (thhashtb (gnus-make-hashtable 1024))
3676 ids references id gthread gid entered ref)
3678 (when (setq references (mail-header-references (caar threads)))
3679 (setq id (mail-header-id (caar threads))
3680 ids (inline (gnus-split-references references))
3682 (while (setq ref (pop ids))
3683 (setq ids (delete ref ids))
3684 (if (not (setq gid (gnus-gethash ref idhashtb)))
3686 (gnus-sethash ref id idhashtb)
3687 (gnus-sethash id threads thhashtb))
3688 (setq gthread (gnus-gethash gid thhashtb))
3690 ;; We enter a dummy root into the thread, if we
3691 ;; haven't done that already.
3692 (unless (stringp (caar gthread))
3693 (setcar gthread (list (mail-header-subject (caar gthread))
3695 ;; We add this new gathered thread to this gathered
3697 (setcdr (car gthread)
3698 (nconc (cdar gthread) (list (car threads)))))
3699 ;; Add it into the thread hash table.
3700 (gnus-sethash id gthread thhashtb)
3702 ;; Remove it from the list of threads.
3703 (setcdr prev (cdr threads))
3704 (setq threads prev))))
3706 (setq threads (cdr threads)))
3709 (defun gnus-sort-gathered-threads (threads)
3710 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3711 (let ((result threads))
3713 (when (stringp (caar threads))
3714 (setcdr (car threads)
3715 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3716 (setq threads (cdr threads)))
3719 (defun gnus-thread-loop-p (root thread)
3720 "Say whether ROOT is in THREAD."
3721 (let ((stack (list thread))
3724 (while (setq thread (pop stack))
3725 (setq th (cdr thread))
3727 (not (eq (caar th) root)))
3730 ;; We have found a loop.
3732 (setcdr thread (delq (car th) (cdr thread)))
3733 (if (boundp (setq ref-dep (intern "none"
3734 gnus-newsgroup-dependencies)))
3735 (setcdr (symbol-value ref-dep)
3736 (nconc (cdr (symbol-value ref-dep))
3738 (set ref-dep (list nil (car th))))
3741 ;; Push all the subthreads onto the stack.
3742 (push (cdr thread) stack)))
3745 (defun gnus-make-threads ()
3746 "Go through the dependency hashtb and find the roots. Return all threads."
3748 (while (catch 'infloop
3751 ;; Deal with self-referencing References loops.
3752 (when (and (car (symbol-value refs))
3759 (car (symbol-value refs)) thread))
3760 (cdr (symbol-value refs)))))))
3763 (unless (car (symbol-value refs))
3764 ;; These threads do not refer back to any other articles,
3765 ;; so they're roots.
3766 (setq threads (append (cdr (symbol-value refs)) threads))))
3767 gnus-newsgroup-dependencies)))
3770 ;; Build the thread tree.
3771 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3772 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3774 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3775 if it was already present.
3777 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3778 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3779 Message-IDs will be renamed to a unique Message-ID before being
3782 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3783 (let* ((id (mail-header-id header))
3784 (id-dep (and id (intern id dependencies)))
3785 parent-id ref ref-dep ref-header replaced)
3786 ;; Enter this `header' in the `dependencies' table.
3790 ;; The first two cases do the normal part: enter a new `header'
3791 ;; in the `dependencies' table.
3792 ((not (boundp id-dep))
3793 (set id-dep (list header)))
3794 ((null (car (symbol-value id-dep)))
3795 (setcar (symbol-value id-dep) header))
3797 ;; From here the `header' was already present in the
3798 ;; `dependencies' table.
3800 ;; Overrides an existing entry;
3801 ;; just set the header part of the entry.
3802 (setcar (symbol-value id-dep) header)
3805 ;; Renames the existing `header' to a unique Message-ID.
3806 ((not gnus-summary-ignore-duplicates)
3807 ;; An article with this Message-ID has already been seen.
3808 ;; We rename the Message-ID.
3809 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3811 (mail-header-set-id header id))
3813 ;; The last case ignores an existing entry, except it adds any
3814 ;; additional Xrefs (in case the two articles came from different
3816 ;; Also sets `header' to `nil' meaning that the `dependencies'
3817 ;; table was *not* modified.
3819 (mail-header-set-xref
3820 (car (symbol-value id-dep))
3821 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3823 (or (mail-header-xref header) "")))
3826 (when (and header (not replaced))
3827 ;; First check that we are not creating a References loop.
3828 (setq parent-id (gnus-parent-id (mail-header-references header)))
3829 (setq ref parent-id)
3831 (setq ref-dep (intern-soft ref dependencies))
3833 (setq ref-header (car (symbol-value ref-dep))))
3834 (if (string= id ref)
3835 ;; Yuk! This is a reference loop. Make the article be a
3838 (mail-header-set-references (car (symbol-value id-dep)) "none")
3840 (setq parent-id nil))
3841 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3842 (setq ref-dep (intern (or parent-id "none") dependencies))
3843 (if (boundp ref-dep)
3844 (setcdr (symbol-value ref-dep)
3845 (nconc (cdr (symbol-value ref-dep))
3846 (list (symbol-value id-dep))))
3847 (set ref-dep (list nil (symbol-value id-dep)))))
3850 (defun gnus-extract-message-id-from-in-reply-to (string)
3851 (if (string-match "<[^>]+>" string)
3852 (substring string (match-beginning 0) (match-end 0))
3855 (defun gnus-build-sparse-threads ()
3856 (let ((headers gnus-newsgroup-headers)
3857 (mail-parse-charset gnus-newsgroup-charset)
3858 (gnus-summary-ignore-duplicates t)
3859 header references generation relations
3860 subject child end new-child date)
3861 ;; First we create an alist of generations/relations, where
3862 ;; generations is how much we trust the relation, and the relation
3864 (gnus-message 7 "Making sparse threads...")
3866 (nnheader-set-temp-buffer " *gnus sparse threads*")
3867 (while (setq header (pop headers))
3868 (when (and (setq references (mail-header-references header))
3869 (not (string= references "")))
3871 (setq child (mail-header-id header)
3872 subject (mail-header-subject header)
3873 date (mail-header-date header)
3875 (while (search-backward ">" nil t)
3876 (setq end (1+ (point)))
3877 (when (search-backward "<" nil t)
3878 (setq new-child (buffer-substring (point) end))
3879 (push (list (incf generation)
3880 child (setq child new-child)
3884 (push (list (1+ generation) child nil subject) relations))
3886 (kill-buffer (current-buffer)))
3887 ;; Sort over trustworthiness.
3890 (when (gnus-dependencies-add-header
3891 (make-full-mail-header-from-decoded-header
3892 gnus-reffed-article-number
3893 (nth 3 relation) "" (or (nth 4 relation) "")
3895 (or (nth 2 relation) "") 0 0 "")
3896 gnus-newsgroup-dependencies nil)
3897 (push gnus-reffed-article-number gnus-newsgroup-limit)
3898 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3899 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3900 gnus-newsgroup-reads)
3901 (decf gnus-reffed-article-number)))
3902 (sort relations 'car-less-than-car))
3903 (gnus-message 7 "Making sparse threads...done")))
3905 (defun gnus-build-old-threads ()
3906 ;; Look at all the articles that refer back to old articles, and
3907 ;; fetch the headers for the articles that aren't there. This will
3908 ;; build complete threads - if the roots haven't been expired by the
3910 (let ((mail-parse-charset gnus-newsgroup-charset)
3914 (when (not (car (symbol-value refs)))
3915 (setq heads (cdr (symbol-value refs)))
3917 (if (memq (mail-header-number (caar heads))
3918 gnus-newsgroup-dormant)
3919 (setq heads (cdr heads))
3920 (setq id (symbol-name refs))
3921 (while (and (setq id (gnus-build-get-header id))
3922 (not (car (gnus-id-to-thread id)))))
3923 (setq heads nil)))))
3924 gnus-newsgroup-dependencies)))
3926 ;; This function has to be called with point after the article number
3927 ;; on the beginning of the line.
3928 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3929 (let ((eol (gnus-point-at-eol))
3930 (buffer (current-buffer))
3931 header references in-reply-to)
3933 ;; overview: [num subject from date id refs chars lines misc]
3936 (narrow-to-region (point) eol)
3941 (make-full-mail-header
3943 (nnheader-nov-field) ; subject
3944 (nnheader-nov-field) ; from
3945 (nnheader-nov-field) ; date
3946 (nnheader-nov-read-message-id) ; id
3947 (nnheader-nov-field) ; refs
3948 (nnheader-nov-read-integer) ; chars
3949 (nnheader-nov-read-integer) ; lines
3951 (if (looking-at "Xref: ")
3952 (goto-char (match-end 0)))
3953 (nnheader-nov-field)) ; Xref
3954 (nnheader-nov-parse-extra)))) ; extra
3958 (when (and (string= references "")
3959 (setq in-reply-to (mail-header-extra header))
3960 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3961 (mail-header-set-references
3962 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3964 (when gnus-alter-header-function
3965 (funcall gnus-alter-header-function header))
3966 (gnus-dependencies-add-header header dependencies force-new)))
3968 (defun gnus-build-get-header (id)
3969 "Look through the buffer of NOV lines and find the header to ID.
3970 Enter this line into the dependencies hash table, and return
3971 the id of the parent article (if any)."
3972 (let ((deps gnus-newsgroup-dependencies)
3976 (set-buffer nntp-server-buffer)
3977 (let ((case-fold-search nil))
3978 (goto-char (point-min))
3979 (while (and (not found)
3980 (search-forward id nil t))
3982 (setq found (looking-at
3983 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3984 (regexp-quote id))))
3985 (or found (beginning-of-line 2)))
3989 (setq header (gnus-nov-parse-line
3990 (read (current-buffer)) deps))
3991 (gnus-parent-id (mail-header-references header))))))
3993 (let ((number (mail-header-number header)))
3994 (push number gnus-newsgroup-limit)
3995 (push header gnus-newsgroup-headers)
3996 (if (memq number gnus-newsgroup-unselected)
3998 (setq gnus-newsgroup-unreads
3999 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4001 (setq gnus-newsgroup-unselected
4002 (delq number gnus-newsgroup-unselected)))
4003 (push number gnus-newsgroup-ancient)))))))
4005 (defun gnus-build-all-threads ()
4006 "Read all the headers."
4007 (let ((gnus-summary-ignore-duplicates t)
4008 (mail-parse-charset gnus-newsgroup-charset)
4009 (dependencies gnus-newsgroup-dependencies)
4012 (set-buffer nntp-server-buffer)
4013 (let ((case-fold-search nil))
4014 (goto-char (point-min))
4017 (setq article (read (current-buffer))
4018 header (gnus-nov-parse-line article dependencies)))
4021 (set-buffer gnus-summary-buffer)
4022 (push header gnus-newsgroup-headers)
4023 (if (memq (setq article (mail-header-number header))
4024 gnus-newsgroup-unselected)
4026 (setq gnus-newsgroup-unreads
4027 (gnus-add-to-sorted-list
4028 gnus-newsgroup-unreads article))
4029 (setq gnus-newsgroup-unselected
4030 (delq article gnus-newsgroup-unselected)))
4031 (push article gnus-newsgroup-ancient)))
4032 (forward-line 1)))))))
4034 (defun gnus-summary-update-article-line (article header)
4035 "Update the line for ARTICLE using HEADERS."
4036 (let* ((id (mail-header-id header))
4037 (thread (gnus-id-to-thread id)))
4039 (error "Article in no thread"))
4040 ;; Update the thread.
4041 (setcar thread header)
4042 (gnus-summary-goto-subject article)
4043 (let* ((datal (gnus-data-find-list article))
4045 (length (when (cdr datal)
4046 (- (gnus-data-pos data)
4047 (gnus-data-pos (cadr datal)))))
4048 (buffer-read-only nil)
4049 (level (gnus-summary-thread-level)))
4051 (gnus-summary-insert-line
4053 (memq article gnus-newsgroup-undownloaded)
4054 (gnus-article-mark article)
4055 (memq article gnus-newsgroup-replied)
4056 (memq article gnus-newsgroup-expirable)
4057 ;; Only insert the Subject string when it's different
4058 ;; from the previous Subject string.
4063 (mail-header-subject
4066 (gnus-data-find-list
4068 (gnus-data-list t)))))
4069 ;; Error on the side of excessive subjects.
4071 (mail-header-subject header)))
4073 (mail-header-subject header))
4074 nil (cdr (assq article gnus-newsgroup-scored))
4075 (memq article gnus-newsgroup-processable))
4077 (gnus-data-update-list
4078 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
4080 (defun gnus-summary-update-article (article &optional iheader)
4081 "Update ARTICLE in the summary buffer."
4082 (set-buffer gnus-summary-buffer)
4083 (let* ((header (gnus-summary-article-header article))
4084 (id (mail-header-id header))
4085 (data (gnus-data-find article))
4086 (thread (gnus-id-to-thread id))
4087 (references (mail-header-references header))
4091 (when (and references
4092 (not (equal "" references)))
4095 (buffer-read-only nil)
4101 (delq thread parent)))
4102 (if (gnus-summary-insert-subject id header)
4103 ;; Set the (possibly) new article number in the data structure.
4104 (gnus-data-set-number data (gnus-id-to-article id))
4108 (defun gnus-rebuild-thread (id &optional line)
4109 "Rebuild the thread containing ID.
4110 If LINE, insert the rebuilt thread starting on line LINE."
4111 (let ((buffer-read-only nil)
4112 old-pos current thread data)
4113 (if (not gnus-show-threads)
4114 (setq thread (list (car (gnus-id-to-thread id))))
4115 ;; Get the thread this article is part of.
4116 (setq thread (gnus-remove-thread id)))
4117 (setq old-pos (gnus-point-at-bol))
4118 (setq current (save-excursion
4119 (and (re-search-backward "[\r\n]" nil t)
4120 (gnus-summary-article-number))))
4121 ;; If this is a gathered thread, we have to go some re-gathering.
4122 (when (stringp (car thread))
4123 (let ((subject (car thread))
4125 (setq thread (cdr thread))
4127 (unless (memq (setq thr (gnus-id-to-thread
4129 (mail-header-id (caar thread)))))
4132 (setq thread (cdr thread)))
4133 ;; We now have all (unique) roots.
4134 (if (= (length roots) 1)
4135 ;; All the loose roots are now one solid root.
4136 (setq thread (car roots))
4137 (setq thread (cons subject (gnus-sort-threads roots))))))
4139 ;; We then insert this thread into the summary buffer.
4141 (goto-char (point-min))
4142 (forward-line (1- line)))
4143 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4144 (if gnus-show-threads
4145 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4146 (gnus-summary-prepare-unthreaded thread))
4147 (setq data (nreverse gnus-newsgroup-data))
4148 (setq threads gnus-newsgroup-threads))
4149 ;; We splice the new data into the data structure.
4150 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4151 ;;!!! then we want to insert at the beginning of the buffer.
4152 ;;!!! That happens to be true with Gnus now, but that may
4153 ;;!!! change in the future. Perhaps.
4154 (gnus-data-enter-list
4155 (if line nil current) data (- (point) old-pos))
4156 (setq gnus-newsgroup-threads
4157 (nconc threads gnus-newsgroup-threads))
4158 (gnus-data-compute-positions))))
4160 (defun gnus-number-to-header (number)
4161 "Return the header for article NUMBER."
4162 (let ((headers gnus-newsgroup-headers))
4164 (not (= number (mail-header-number (car headers)))))
4169 (defun gnus-parent-headers (in-headers &optional generation)
4170 "Return the headers of the GENERATIONeth parent of HEADERS."
4172 (setq generation 1))
4174 (headers in-headers)
4177 (not (zerop generation))
4178 (setq references (mail-header-references headers)))
4179 (setq headers (if (and references
4180 (setq parent (gnus-parent-id references)))
4181 (car (gnus-id-to-thread parent))
4184 (and (not (eq headers in-headers))
4187 (defun gnus-id-to-thread (id)
4188 "Return the (sub-)thread where ID appears."
4189 (gnus-gethash id gnus-newsgroup-dependencies))
4191 (defun gnus-id-to-article (id)
4192 "Return the article number of ID."
4193 (let ((thread (gnus-id-to-thread id)))
4196 (mail-header-number (car thread)))))
4198 (defun gnus-id-to-header (id)
4199 "Return the article headers of ID."
4200 (car (gnus-id-to-thread id)))
4202 (defun gnus-article-displayed-root-p (article)
4203 "Say whether ARTICLE is a root(ish) article."
4204 (let ((level (gnus-summary-thread-level article))
4205 (refs (mail-header-references (gnus-summary-article-header article)))
4211 ((null (gnus-parent-id refs)) t)
4213 (null (setq particle (gnus-id-to-article
4214 (gnus-parent-id refs))))
4215 (null (gnus-summary-thread-level particle)))))))
4217 (defun gnus-root-id (id)
4218 "Return the id of the root of the thread where ID appears."
4220 (while (and id (setq prev (car (gnus-id-to-thread id))))
4222 id (gnus-parent-id (mail-header-references prev))))
4225 (defun gnus-articles-in-thread (thread)
4226 "Return the list of articles in THREAD."
4227 (cons (mail-header-number (car thread))
4228 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4230 (defun gnus-remove-thread (id &optional dont-remove)
4231 "Remove the thread that has ID in it."
4232 (let (headers thread last-id)
4233 ;; First go up in this thread until we find the root.
4234 (setq last-id (gnus-root-id id)
4235 headers (message-flatten-list (gnus-id-to-thread last-id)))
4236 ;; We have now found the real root of this thread. It might have
4237 ;; been gathered into some loose thread, so we have to search
4238 ;; through the threads to find the thread we wanted.
4239 (let ((threads gnus-newsgroup-threads)
4242 (setq sub (car threads))
4243 (if (stringp (car sub))
4244 ;; This is a gathered thread, so we look at the roots
4245 ;; below it to find whether this article is in this
4248 (setq sub (cdr sub))
4250 (when (member (caar sub) headers)
4251 (setq thread (car threads)
4254 (setq sub (cdr sub))))
4255 ;; It's an ordinary thread, so we check it.
4256 (when (eq (car sub) (car headers))
4259 (setq threads (cdr threads)))
4260 ;; If this article is in no thread, then it's a root.
4263 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4264 (setq thread (gnus-id-to-thread last-id)))
4267 thread ; We return this thread.
4269 (if (stringp (car thread))
4271 ;; If we use dummy roots, then we have to remove the
4272 ;; dummy root as well.
4273 (when (eq gnus-summary-make-false-root 'dummy)
4274 ;; We go to the dummy root by going to
4275 ;; the first sub-"thread", and then one line up.
4276 (gnus-summary-goto-article
4277 (mail-header-number (caadr thread)))
4280 (gnus-data-compute-positions))
4281 (setq thread (cdr thread))
4283 (gnus-remove-thread-1 (car thread))
4284 (setq thread (cdr thread))))
4285 (gnus-remove-thread-1 thread))))))))
4287 (defun gnus-remove-thread-1 (thread)
4288 "Remove the thread THREAD recursively."
4289 (let ((number (mail-header-number (pop thread)))
4291 (setq thread (reverse thread))
4293 (gnus-remove-thread-1 (pop thread)))
4294 (when (setq d (gnus-data-find number))
4295 (goto-char (gnus-data-pos d))
4296 (gnus-summary-show-thread)
4299 (- (gnus-point-at-bol)
4301 (1+ (gnus-point-at-eol))
4302 (gnus-delete-line)))))))
4304 (defun gnus-sort-threads-1 (threads func)
4305 (sort (mapcar (lambda (thread)
4308 (gnus-sort-threads-1 (cdr thread) func))))
4311 (defun gnus-sort-threads (threads)
4313 (if (not gnus-thread-sort-functions)
4315 (gnus-message 8 "Sorting threads...")
4316 (let ((max-lisp-eval-depth 5000))
4317 (prog1 (gnus-sort-threads-1
4319 (gnus-make-sort-function gnus-thread-sort-functions))
4320 (gnus-message 8 "Sorting threads...done")))))
4322 (defun gnus-sort-articles (articles)
4324 (when gnus-article-sort-functions
4325 (gnus-message 7 "Sorting articles...")
4327 (setq gnus-newsgroup-headers
4328 (sort articles (gnus-make-sort-function
4329 gnus-article-sort-functions)))
4330 (gnus-message 7 "Sorting articles...done"))))
4332 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4333 (defmacro gnus-thread-header (thread)
4334 "Return header of first article in THREAD.
4335 Note that THREAD must never, ever be anything else than a variable -
4336 using some other form will lead to serious barfage."
4337 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4338 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4339 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4342 (defsubst gnus-article-sort-by-number (h1 h2)
4343 "Sort articles by article number."
4344 (< (mail-header-number h1)
4345 (mail-header-number h2)))
4347 (defun gnus-thread-sort-by-number (h1 h2)
4348 "Sort threads by root article number."
4349 (gnus-article-sort-by-number
4350 (gnus-thread-header h1) (gnus-thread-header h2)))
4352 (defsubst gnus-article-sort-by-random (h1 h2)
4353 "Sort articles by article number."
4356 (defun gnus-thread-sort-by-random (h1 h2)
4357 "Sort threads by root article number."
4358 (gnus-article-sort-by-random
4359 (gnus-thread-header h1) (gnus-thread-header h2)))
4361 (defsubst gnus-article-sort-by-lines (h1 h2)
4362 "Sort articles by article Lines header."
4363 (< (mail-header-lines h1)
4364 (mail-header-lines h2)))
4366 (defun gnus-thread-sort-by-lines (h1 h2)
4367 "Sort threads by root article Lines header."
4368 (gnus-article-sort-by-lines
4369 (gnus-thread-header h1) (gnus-thread-header h2)))
4371 (defsubst gnus-article-sort-by-chars (h1 h2)
4372 "Sort articles by octet length."
4373 (< (mail-header-chars h1)
4374 (mail-header-chars h2)))
4376 (defun gnus-thread-sort-by-chars (h1 h2)
4377 "Sort threads by root article octet length."
4378 (gnus-article-sort-by-chars
4379 (gnus-thread-header h1) (gnus-thread-header h2)))
4381 (defsubst gnus-article-sort-by-author (h1 h2)
4382 "Sort articles by root author."
4384 (let ((addr (car (mime-entity-read-field h1 'From))))
4385 (or (std11-full-name-string addr)
4386 (std11-address-string addr)
4388 (let ((addr (car (mime-entity-read-field h2 'From))))
4389 (or (std11-full-name-string addr)
4390 (std11-address-string addr)
4394 (defun gnus-thread-sort-by-author (h1 h2)
4395 "Sort threads by root author."
4396 (gnus-article-sort-by-author
4397 (gnus-thread-header h1) (gnus-thread-header h2)))
4399 (defsubst gnus-article-sort-by-subject (h1 h2)
4400 "Sort articles by root subject."
4402 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4403 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4405 (defun gnus-thread-sort-by-subject (h1 h2)
4406 "Sort threads by root subject."
4407 (gnus-article-sort-by-subject
4408 (gnus-thread-header h1) (gnus-thread-header h2)))
4410 (defsubst gnus-article-sort-by-date (h1 h2)
4411 "Sort articles by root article date."
4413 (gnus-date-get-time (mail-header-date h1))
4414 (gnus-date-get-time (mail-header-date h2))))
4416 (defun gnus-thread-sort-by-date (h1 h2)
4417 "Sort threads by root article date."
4418 (gnus-article-sort-by-date
4419 (gnus-thread-header h1) (gnus-thread-header h2)))
4421 (defsubst gnus-article-sort-by-score (h1 h2)
4422 "Sort articles by root article score.
4423 Unscored articles will be counted as having a score of zero."
4424 (> (or (cdr (assq (mail-header-number h1)
4425 gnus-newsgroup-scored))
4426 gnus-summary-default-score 0)
4427 (or (cdr (assq (mail-header-number h2)
4428 gnus-newsgroup-scored))
4429 gnus-summary-default-score 0)))
4431 (defun gnus-thread-sort-by-score (h1 h2)
4432 "Sort threads by root article score."
4433 (gnus-article-sort-by-score
4434 (gnus-thread-header h1) (gnus-thread-header h2)))
4436 (defun gnus-thread-sort-by-total-score (h1 h2)
4437 "Sort threads by the sum of all scores in the thread.
4438 Unscored articles will be counted as having a score of zero."
4439 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4441 (defun gnus-thread-total-score (thread)
4442 ;; This function find the total score of THREAD.
4447 (if (stringp (car thread))
4448 (apply gnus-thread-score-function 0
4449 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4450 (gnus-thread-total-score-1 thread)))
4452 (gnus-thread-total-score-1 (list thread)))))
4454 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4455 "Sort threads such that the thread with the most recently arrived article comes first."
4456 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4458 (defun gnus-thread-highest-number (thread)
4459 "Return the highest article number in THREAD."
4460 (apply 'max (mapcar (lambda (header)
4461 (mail-header-number header))
4462 (message-flatten-list thread))))
4464 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4465 "Sort threads such that the thread with the most recently dated article comes first."
4466 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4468 (defun gnus-thread-latest-date (thread)
4469 "Return the highest article date in THREAD."
4470 (let ((previous-time 0))
4477 (mail-header-parse-date (mail-header-date header))
4478 (error previous-time)))))
4480 (message-flatten-list thread)
4482 (< (mail-header-number h1)
4483 (mail-header-number h2))))))))
4485 (defun gnus-thread-total-score-1 (root)
4486 ;; This function find the total score of the thread below ROOT.
4487 (setq root (car root))
4488 (apply gnus-thread-score-function
4490 (mapcar 'gnus-thread-total-score
4491 (cdr (gnus-id-to-thread (mail-header-id root))))
4492 (when (> (mail-header-number root) 0)
4493 (list (or (cdr (assq (mail-header-number root)
4494 gnus-newsgroup-scored))
4495 gnus-summary-default-score 0))))
4496 (list gnus-summary-default-score)
4499 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4500 (defvar gnus-tmp-prev-subject nil)
4501 (defvar gnus-tmp-false-parent nil)
4502 (defvar gnus-tmp-root-expunged nil)
4503 (defvar gnus-tmp-dummy-line nil)
4505 (eval-when-compile (defvar gnus-tmp-header))
4506 (defun gnus-extra-header (type &optional header)
4507 "Return the extra header of TYPE."
4508 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4511 (defvar gnus-tmp-thread-tree-header-string "")
4513 (defcustom gnus-sum-thread-tree-root "> "
4514 "With %B spec, used for the root of a thread.
4515 If nil, use subject instead."
4517 :group 'gnus-thread)
4518 (defcustom gnus-sum-thread-tree-single-indent ""
4519 "With %B spec, used for a thread with just one message.
4520 If nil, use subject instead."
4522 :group 'gnus-thread)
4523 (defcustom gnus-sum-thread-tree-vertical "| "
4524 "With %B spec, used for drawing a vertical line."
4526 :group 'gnus-thread)
4527 (defcustom gnus-sum-thread-tree-indent " "
4528 "With %B spec, used for indenting."
4530 :group 'gnus-thread)
4531 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4532 "With %B spec, used for a leaf with brothers."
4534 :group 'gnus-thread)
4535 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4536 "With %B spec, used for a leaf without brothers."
4538 :group 'gnus-thread)
4540 (defun gnus-summary-prepare-threads (threads)
4541 "Prepare summary buffer from THREADS and indentation LEVEL.
4542 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4543 or a straight list of headers."
4544 (gnus-message 7 "Generating summary...")
4546 (setq gnus-newsgroup-threads threads)
4549 (let ((gnus-tmp-level 0)
4550 (default-score (or gnus-summary-default-score 0))
4551 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4552 (building-line-count gnus-summary-display-while-building)
4553 (building-count (integerp gnus-summary-display-while-building))
4554 thread number subject stack state gnus-tmp-gathered beg-match
4555 new-roots gnus-tmp-new-adopts thread-end simp-subject
4556 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4557 gnus-tmp-replied gnus-tmp-subject-or-nil
4558 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4559 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4560 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4563 (setq gnus-tmp-prev-subject nil)
4565 (if (vectorp (car threads))
4566 ;; If this is a straight (sic) list of headers, then a
4567 ;; threaded summary display isn't required, so we just create
4568 ;; an unthreaded one.
4569 (gnus-summary-prepare-unthreaded threads)
4571 ;; Do the threaded display.
4573 (if gnus-summary-display-while-building
4574 (switch-to-buffer (buffer-name)))
4575 (while (or threads stack gnus-tmp-new-adopts new-roots)
4577 (if (and (= gnus-tmp-level 0)
4580 (not gnus-tmp-false-parent)
4581 (or gnus-tmp-new-adopts new-roots))
4582 (if gnus-tmp-new-adopts
4583 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4584 thread (list (car gnus-tmp-new-adopts))
4585 gnus-tmp-header (caar thread)
4586 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4588 (setq thread (list (car new-roots))
4589 gnus-tmp-header (caar thread)
4590 new-roots (cdr new-roots))))
4593 ;; If there are some threads, we do them before the
4594 ;; threads on the stack.
4595 (setq thread threads
4596 gnus-tmp-header (caar thread))
4597 ;; There were no current threads, so we pop something off
4599 (setq state (car stack)
4600 gnus-tmp-level (car state)
4601 tree-stack (cadr state)
4602 thread (caddr state)
4604 gnus-tmp-header (caar thread))))
4606 (setq gnus-tmp-false-parent nil)
4607 (setq gnus-tmp-root-expunged nil)
4608 (setq thread-end nil)
4610 (if (stringp gnus-tmp-header)
4611 ;; The header is a dummy root.
4613 ((eq gnus-summary-make-false-root 'adopt)
4614 ;; We let the first article adopt the rest.
4615 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4617 (setq gnus-tmp-gathered
4619 (lambda (h) (mail-header-number (car h)))
4622 (setq thread (cons (list (caar thread)
4625 (setq gnus-tmp-level -1
4626 gnus-tmp-false-parent t))
4627 ((eq gnus-summary-make-false-root 'empty)
4628 ;; We print adopted articles with empty subject fields.
4629 (setq gnus-tmp-gathered
4631 (lambda (h) (mail-header-number (car h)))
4634 (setq gnus-tmp-level -1))
4635 ((eq gnus-summary-make-false-root 'dummy)
4636 ;; We remember that we probably want to output a dummy
4638 (setq gnus-tmp-dummy-line gnus-tmp-header)
4639 (setq gnus-tmp-prev-subject gnus-tmp-header))
4641 ;; We do not make a root for the gathered
4642 ;; sub-threads at all.
4643 (setq gnus-tmp-level -1)))
4645 (setq number (mail-header-number gnus-tmp-header)
4646 subject (mail-header-subject gnus-tmp-header)
4647 simp-subject (gnus-simplify-subject-fully subject))
4650 ;; If the thread has changed subject, we might want to make
4651 ;; this subthread into a root.
4652 ((and (null gnus-thread-ignore-subject)
4653 (not (zerop gnus-tmp-level))
4654 gnus-tmp-prev-subject
4655 (not (string= gnus-tmp-prev-subject simp-subject)))
4656 (setq new-roots (nconc new-roots (list (car thread)))
4658 gnus-tmp-header nil))
4659 ;; If the article lies outside the current limit,
4660 ;; then we do not display it.
4661 ((not (memq number gnus-newsgroup-limit))
4662 (setq gnus-tmp-gathered
4664 (lambda (h) (mail-header-number (car h)))
4667 (setq gnus-tmp-new-adopts (if (cdar thread)
4668 (append gnus-tmp-new-adopts
4670 gnus-tmp-new-adopts)
4672 gnus-tmp-header nil)
4673 (when (zerop gnus-tmp-level)
4674 (setq gnus-tmp-root-expunged t)))
4675 ;; Perhaps this article is to be marked as read?
4676 ((and gnus-summary-mark-below
4677 (< (or (cdr (assq number gnus-newsgroup-scored))
4679 gnus-summary-mark-below)
4680 ;; Don't touch sparse articles.
4681 (not (gnus-summary-article-sparse-p number))
4682 (not (gnus-summary-article-ancient-p number)))
4683 (setq gnus-newsgroup-unreads
4684 (delq number gnus-newsgroup-unreads))
4685 (if gnus-newsgroup-auto-expire
4686 (setq gnus-newsgroup-expirable
4687 (gnus-add-to-sorted-list
4688 gnus-newsgroup-expirable number))
4689 (push (cons number gnus-low-score-mark)
4690 gnus-newsgroup-reads))))
4692 (when gnus-tmp-header
4693 ;; We may have an old dummy line to output before this
4695 (when (and gnus-tmp-dummy-line
4698 (mail-header-subject gnus-tmp-header)))
4699 (gnus-summary-insert-dummy-line
4700 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4701 (setq gnus-tmp-dummy-line nil))
4703 ;; Compute the mark.
4704 (setq gnus-tmp-unread (gnus-article-mark number))
4706 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4707 gnus-tmp-header gnus-tmp-level)
4708 gnus-newsgroup-data)
4710 ;; Actually insert the line.
4712 gnus-tmp-subject-or-nil
4714 ((and gnus-thread-ignore-subject
4715 gnus-tmp-prev-subject
4716 (not (string= gnus-tmp-prev-subject simp-subject)))
4718 ((zerop gnus-tmp-level)
4719 (if (and (eq gnus-summary-make-false-root 'empty)
4720 (memq number gnus-tmp-gathered)
4721 gnus-tmp-prev-subject
4722 (string= gnus-tmp-prev-subject simp-subject))
4723 gnus-summary-same-subject
4725 (t gnus-summary-same-subject)))
4726 (if (and (eq gnus-summary-make-false-root 'adopt)
4727 (= gnus-tmp-level 1)
4728 (memq number gnus-tmp-gathered))
4729 (setq gnus-tmp-opening-bracket ?\<
4730 gnus-tmp-closing-bracket ?\>)
4731 (setq gnus-tmp-opening-bracket ?\[
4732 gnus-tmp-closing-bracket ?\]))
4734 gnus-tmp-indentation
4735 (aref gnus-thread-indent-array gnus-tmp-level)
4736 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4737 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4738 gnus-summary-default-score 0)
4740 (if (or (null gnus-summary-default-score)
4741 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4742 gnus-summary-zcore-fuzz))
4744 (if (< gnus-tmp-score gnus-summary-default-score)
4745 gnus-score-below-mark gnus-score-over-mark))
4747 (cond ((memq number gnus-newsgroup-processable)
4749 ((memq number gnus-newsgroup-cached)
4751 ((memq number gnus-newsgroup-replied)
4753 ((memq number gnus-newsgroup-forwarded)
4754 gnus-forwarded-mark)
4755 ((memq number gnus-newsgroup-saved)
4757 ((memq number gnus-newsgroup-recent)
4759 ((memq number gnus-newsgroup-unseen)
4763 (cond ((memq number gnus-newsgroup-undownloaded)
4764 gnus-undownloaded-mark)
4765 (gnus-newsgroup-agentized
4766 gnus-downloaded-mark)
4769 gnus-tmp-from (mail-header-from gnus-tmp-header)
4772 ((string-match "<[^>]+> *$" gnus-tmp-from)
4773 (setq beg-match (match-beginning 0))
4774 (or (and (string-match "^\".+\"" gnus-tmp-from)
4775 (substring gnus-tmp-from 1 (1- (match-end 0))))
4776 (substring gnus-tmp-from 0 beg-match)))
4777 ((string-match "(.+)" gnus-tmp-from)
4778 (substring gnus-tmp-from
4779 (1+ (match-beginning 0)) (1- (match-end 0))))
4781 gnus-tmp-thread-tree-header-string
4783 ((not gnus-show-threads) "")
4784 ((zerop gnus-tmp-level)
4786 (or gnus-sum-thread-tree-root subject)
4787 (or gnus-sum-thread-tree-single-indent subject)))
4789 (concat (apply 'concat
4790 (mapcar (lambda (item)
4792 gnus-sum-thread-tree-vertical
4793 gnus-sum-thread-tree-indent))
4794 (cdr (reverse tree-stack))))
4796 gnus-sum-thread-tree-leaf-with-other
4797 gnus-sum-thread-tree-single-leaf)))))
4798 (when (string= gnus-tmp-name "")
4799 (setq gnus-tmp-name gnus-tmp-from))
4800 (unless (numberp gnus-tmp-lines)
4801 (setq gnus-tmp-lines -1))
4802 (if (= gnus-tmp-lines -1)
4803 (setq gnus-tmp-lines "?")
4804 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4805 (gnus-put-text-property
4807 (progn (eval gnus-summary-line-format-spec) (point))
4808 'gnus-number number)
4811 (gnus-run-hooks 'gnus-summary-update-hook)
4814 (setq gnus-tmp-prev-subject simp-subject)))
4816 (when (nth 1 thread)
4817 (push (list (max 0 gnus-tmp-level)
4818 (copy-list tree-stack)
4821 (push (if (nth 1 thread) 1 0) tree-stack)
4822 (incf gnus-tmp-level)
4823 (setq threads (if thread-end nil (cdar thread)))
4824 (if gnus-summary-display-while-building
4827 ;; use a set frequency
4828 (setq building-line-count (1- building-line-count))
4829 (when (= building-line-count 0)
4831 (setq building-line-count
4832 gnus-summary-display-while-building)))
4836 (setq gnus-tmp-level 0)))))
4837 (gnus-message 7 "Generating summary...done"))
4839 (defun gnus-summary-prepare-unthreaded (headers)
4840 "Generate an unthreaded summary buffer based on HEADERS."
4841 (let (header number mark)
4846 ;; We may have to root out some bad articles...
4847 (when (memq (setq number (mail-header-number
4848 (setq header (pop headers))))
4849 gnus-newsgroup-limit)
4850 ;; Mark article as read when it has a low score.
4851 (when (and gnus-summary-mark-below
4852 (< (or (cdr (assq number gnus-newsgroup-scored))
4853 gnus-summary-default-score 0)
4854 gnus-summary-mark-below)
4855 (not (gnus-summary-article-ancient-p number)))
4856 (setq gnus-newsgroup-unreads
4857 (delq number gnus-newsgroup-unreads))
4858 (if gnus-newsgroup-auto-expire
4859 (push number gnus-newsgroup-expirable)
4860 (push (cons number gnus-low-score-mark)
4861 gnus-newsgroup-reads)))
4863 (setq mark (gnus-article-mark number))
4864 (push (gnus-data-make number mark (1+ (point)) header 0)
4865 gnus-newsgroup-data)
4866 (gnus-summary-insert-line
4868 (memq number gnus-newsgroup-undownloaded)
4869 mark (memq number gnus-newsgroup-replied)
4870 (memq number gnus-newsgroup-expirable)
4871 (mail-header-subject header) nil
4872 (cdr (assq number gnus-newsgroup-scored))
4873 (memq number gnus-newsgroup-processable))))))
4875 (defun gnus-summary-remove-list-identifiers ()
4876 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4877 (let ((regexp (if (consp gnus-list-identifiers)
4878 (mapconcat 'identity gnus-list-identifiers " *\\|")
4879 gnus-list-identifiers))
4882 (dolist (header gnus-newsgroup-headers)
4883 (setq subject (mail-header-subject header)
4885 (while (string-match
4886 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4889 (concat (substring subject 0 (match-beginning 2))
4890 (substring subject (match-end 0)))
4894 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4896 (concat (substring subject 0 (match-beginning 1))
4897 (substring subject (match-end 1)))))
4899 (mail-header-set-subject header subject))))))
4901 (defun gnus-fetch-headers (articles)
4902 "Fetch headers of ARTICLES."
4903 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4904 (gnus-message 5 "Fetching headers for %s..." name)
4907 (setq gnus-headers-retrieved-by
4908 (gnus-retrieve-headers
4909 articles gnus-newsgroup-name
4910 ;; We might want to fetch old headers, but
4911 ;; not if there is only 1 article.
4913 (not (eq gnus-fetch-old-headers 'some))
4914 (not (numberp gnus-fetch-old-headers)))
4915 (> (length articles) 1))
4916 gnus-fetch-old-headers))))
4917 (gnus-get-newsgroup-headers-xover
4918 articles nil nil gnus-newsgroup-name t)
4919 (gnus-get-newsgroup-headers))
4920 (gnus-message 5 "Fetching headers for %s...done" name))))
4922 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4923 "Select newsgroup GROUP.
4924 If READ-ALL is non-nil, all articles in the group are selected.
4925 If SELECT-ARTICLES, only select those articles from GROUP."
4926 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4927 ;;!!! Dirty hack; should be removed.
4928 (gnus-summary-ignore-duplicates
4929 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4931 gnus-summary-ignore-duplicates))
4932 (info (nth 2 entry))
4933 articles fetched-articles cached)
4935 (unless (gnus-check-server
4936 (set (make-local-variable 'gnus-current-select-method)
4937 (gnus-find-method-for-group group)))
4938 (error "Couldn't open server"))
4940 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4941 (gnus-activate-group group) ; Or we can activate it...
4942 (progn ; Or we bug out.
4943 (when (equal major-mode 'gnus-summary-mode)
4944 (kill-buffer (current-buffer)))
4945 (error "Couldn't activate group %s: %s"
4946 group (gnus-status-message group))))
4948 (unless (gnus-request-group group t)
4949 (when (equal major-mode 'gnus-summary-mode)
4950 (kill-buffer (current-buffer)))
4951 (error "Couldn't request group %s: %s"
4952 group (gnus-status-message group)))
4954 (setq gnus-newsgroup-name group
4955 gnus-newsgroup-unselected nil
4956 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4958 (let ((display (gnus-group-find-parameter group 'display)))
4959 (setq gnus-newsgroup-display
4961 ((not (zerop (or (car-safe read-all) 0)))
4962 ;; The user entered the group with C-u SPC/RET, let's show
4968 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4970 ;; The following is probably the "correct" solution, but
4971 ;; it makes Gnus fetch all headers and then limit the
4972 ;; articles (which is slow), so instead we hack the
4973 ;; select-articles parameter instead. -- Simon Josefsson
4976 ;; (gnus-byte-compile
4977 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4979 (setq select-articles
4980 (gnus-uncompress-range
4981 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4985 (cdr (gnus-active group)))))
4990 (gnus-summary-setup-default-charset)
4992 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4993 (when (gnus-virtual-group-p group)
4994 (setq cached gnus-newsgroup-cached))
4996 (setq gnus-newsgroup-unreads
4997 (gnus-sorted-ndifference
4998 (gnus-sorted-ndifference gnus-newsgroup-unreads
4999 gnus-newsgroup-marked)
5000 gnus-newsgroup-dormant))
5002 (setq gnus-newsgroup-processable nil)
5004 (gnus-update-read-articles group gnus-newsgroup-unreads)
5006 ;; Adjust and set lists of article marks.
5008 (gnus-adjust-marked-articles info))
5009 (if (setq articles select-articles)
5010 (setq gnus-newsgroup-unselected
5011 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5012 (setq articles (gnus-articles-to-read group read-all)))
5016 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5018 ((eq articles 0) nil)
5020 ;; Init the dependencies hash table.
5021 (setq gnus-newsgroup-dependencies
5022 (gnus-make-hashtable (length articles)))
5023 (gnus-set-global-variables)
5024 ;; Retrieve the headers and read them in.
5026 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5028 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5030 (setq gnus-newsgroup-cached cached))
5032 ;; Suppress duplicates?
5033 (when gnus-suppress-duplicates
5034 (gnus-dup-suppress-articles))
5036 ;; Set the initial limit.
5037 (setq gnus-newsgroup-limit (copy-sequence articles))
5038 ;; Remove canceled articles from the list of unread articles.
5039 (setq fetched-articles
5040 (mapcar (lambda (headers) (mail-header-number headers))
5041 gnus-newsgroup-headers))
5042 (setq gnus-newsgroup-articles fetched-articles)
5043 (setq gnus-newsgroup-unreads
5044 (gnus-sorted-nintersection
5045 gnus-newsgroup-unreads fetched-articles))
5046 (gnus-compute-unseen-list)
5048 ;; Removed marked articles that do not exist.
5049 (gnus-update-missing-marks
5050 (gnus-sorted-difference articles fetched-articles))
5051 ;; We might want to build some more threads first.
5052 (when (and gnus-fetch-old-headers
5053 (eq gnus-headers-retrieved-by 'nov))
5054 (if (eq gnus-fetch-old-headers 'invisible)
5055 (gnus-build-all-threads)
5056 (gnus-build-old-threads)))
5057 ;; Let the Gnus agent mark articles as read.
5059 (gnus-agent-get-undownloaded-list))
5060 ;; Remove list identifiers from subject
5061 (when gnus-list-identifiers
5062 (gnus-summary-remove-list-identifiers))
5063 ;; Check whether auto-expire is to be done in this group.
5064 (setq gnus-newsgroup-auto-expire
5065 (gnus-group-auto-expirable-p group))
5066 ;; Set up the article buffer now, if necessary.
5067 (unless gnus-single-article-buffer
5068 (gnus-article-setup-buffer))
5069 ;; First and last article in this newsgroup.
5070 (when gnus-newsgroup-headers
5071 (setq gnus-newsgroup-begin
5072 (mail-header-number (car gnus-newsgroup-headers))
5075 (gnus-last-element gnus-newsgroup-headers))))
5076 ;; GROUP is successfully selected.
5077 (or gnus-newsgroup-headers t)))))
5079 (defun gnus-compute-unseen-list ()
5080 ;; The `seen' marks are treated specially.
5081 (if (not gnus-newsgroup-seen)
5082 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5083 (setq gnus-newsgroup-unseen
5084 (gnus-inverse-list-range-intersection
5085 gnus-newsgroup-articles gnus-newsgroup-seen))))
5087 (defun gnus-summary-display-make-predicate (display)
5088 (require 'gnus-agent)
5089 (when (= (length display) 1)
5090 (setq display (car display)))
5091 (unless gnus-summary-display-cache
5092 (dolist (elem (append '((unread . unread)
5095 gnus-article-mark-lists))
5096 (push (cons (cdr elem)
5098 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5099 gnus-summary-display-cache)))
5100 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5101 (gnus-category-predicate-cache gnus-summary-display-cache))
5102 (gnus-get-predicate display)))
5104 ;; Uses the dynamically bound `number' variable.
5107 (defun gnus-article-marked-p (type &optional article)
5108 (let ((article (or article number)))
5111 (memq article gnus-newsgroup-marked))
5113 (memq article gnus-newsgroup-spam-marked))
5115 (memq article gnus-newsgroup-unsendable))
5116 ((eq type 'undownload)
5117 (memq article gnus-newsgroup-undownloaded))
5118 ((eq type 'download)
5119 (memq article gnus-newsgroup-downloadable))
5121 (memq article gnus-newsgroup-unreads))
5123 (memq article gnus-newsgroup-reads))
5125 (memq article gnus-newsgroup-dormant) )
5127 (memq article gnus-newsgroup-expirable))
5129 (memq article gnus-newsgroup-replied))
5131 (memq article gnus-newsgroup-killed))
5132 ((eq type 'bookmark)
5133 (assq article gnus-newsgroup-bookmarks))
5135 (assq article gnus-newsgroup-scored))
5137 (memq article gnus-newsgroup-saved))
5139 (memq article gnus-newsgroup-cached))
5141 (memq article gnus-newsgroup-forwarded))
5143 (not (memq article gnus-newsgroup-unseen)))
5145 (memq article gnus-newsgroup-recent))
5148 (defun gnus-articles-to-read (group &optional read-all)
5149 "Find out what articles the user wants to read."
5150 (let* ((display (gnus-group-find-parameter group 'display))
5152 ;; Select all articles if `read-all' is non-nil, or if there
5153 ;; are no unread articles.
5155 (and (zerop (length gnus-newsgroup-marked))
5156 (zerop (length gnus-newsgroup-unreads)))
5157 ;; Fetch all if the predicate is non-nil.
5158 gnus-newsgroup-display)
5159 ;; We want to select the headers for all the articles in
5160 ;; the group, so we select either all the active
5161 ;; articles in the group, or (if that's nil), the
5162 ;; articles in the cache.
5164 (gnus-uncompress-range (gnus-active group))
5165 (gnus-cache-articles-in-group group))
5166 ;; Select only the "normal" subset of articles.
5168 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5169 gnus-newsgroup-unreads)))
5170 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5171 (scored (length scored-list))
5172 (number (length articles))
5173 (marked (+ (length gnus-newsgroup-marked)
5174 (length gnus-newsgroup-dormant)))
5179 ((numberp gnus-newsgroup-display)
5180 gnus-newsgroup-display)
5184 ((and (or (<= scored marked) (= scored number))
5185 (numberp gnus-large-newsgroup)
5186 (> number gnus-large-newsgroup))
5187 (let* ((cursor-in-echo-area nil)
5188 (initial (gnus-parameter-large-newsgroup-initial
5189 gnus-newsgroup-name))
5193 "How many articles from %s (%s %d): "
5195 (gnus-group-decoded-name gnus-newsgroup-name)
5197 (if initial "max" "default")
5200 (cons (number-to-string initial)
5202 (if (string-match "^[ \t]*$" input) number input)))
5203 ((and (> scored marked) (< scored number)
5204 (> (- scored number) 20))
5207 (format "%s %s (%d scored, %d total): "
5208 "How many articles from"
5209 (gnus-group-decoded-name group)
5211 (if (string-match "^[ \t]*$" input)
5215 (message "Quit getting the articles to read")
5217 (setq select (if (stringp select) (string-to-number select) select))
5218 (if (or (null select) (zerop select))
5220 (if (and (not (zerop scored)) (<= (abs select) scored))
5222 (setq articles (sort scored-list '<))
5223 (setq number (length articles)))
5224 (setq articles (copy-sequence articles)))
5226 (when (< (abs select) number)
5228 ;; Select the N oldest articles.
5229 (setcdr (nthcdr (1- (abs select)) articles) nil)
5230 ;; Select the N most recent articles.
5231 (setq articles (nthcdr (- number select) articles))))
5232 (setq gnus-newsgroup-unselected
5233 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5234 (when gnus-alter-articles-to-read-function
5237 (funcall gnus-alter-articles-to-read-function
5238 gnus-newsgroup-name articles)
5242 (defun gnus-killed-articles (killed articles)
5245 (when (inline (gnus-member-of-range (car articles) killed))
5246 (push (car articles) out))
5247 (setq articles (cdr articles)))
5250 (defun gnus-uncompress-marks (marks)
5251 "Uncompress the mark ranges in MARKS."
5252 (let ((uncompressed '(score bookmark))
5255 (if (memq (caar marks) uncompressed)
5256 (push (car marks) out)
5257 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5258 (setq marks (cdr marks)))
5261 (defun gnus-article-mark-to-type (mark)
5262 "Return the type of MARK."
5263 (or (cadr (assq mark gnus-article-special-mark-lists))
5266 (defun gnus-article-unpropagatable-p (mark)
5267 "Return whether MARK should be propagated to backend."
5268 (memq mark gnus-article-unpropagated-mark-lists))
5270 (defun gnus-adjust-marked-articles (info)
5271 "Set all article lists and remove all marks that are no longer valid."
5272 (let* ((marked-lists (gnus-info-marks info))
5273 (active (gnus-active (gnus-info-group info)))
5276 (types gnus-article-mark-lists)
5277 marks var articles article mark mark-type)
5279 (dolist (marks marked-lists)
5280 (setq mark (car marks)
5281 mark-type (gnus-article-mark-to-type mark)
5282 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5284 ;; We set the variable according to the type of the marks list,
5285 ;; and then adjust the marks to a subset of the active articles.
5287 ;; Adjust "simple" lists.
5288 ((eq mark-type 'list)
5289 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5290 (when (memq mark '(tick dormant expire reply save))
5292 (when (or (< (setq article (pop articles)) min) (> article max))
5293 (set var (delq article (symbol-value var)))))))
5295 ((eq mark-type 'tuple)
5296 (set var (setq articles (cdr marks)))
5297 (when (not (listp (cdr (symbol-value var))))
5298 (set var (list (symbol-value var))))
5299 (when (not (listp (cdr articles)))
5300 (setq articles (list articles)))
5302 (when (or (not (consp (setq article (pop articles))))
5303 (< (car article) min)
5304 (> (car article) max))
5305 (set var (delq article (symbol-value var))))))
5306 ;; Adjust ranges (sloppily).
5307 ((eq mark-type 'range)
5310 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5311 ;; It should be (seen (NUM1 . NUM2)).
5312 (when (numberp (cddr marks))
5313 (setcdr marks (list (cdr marks))))
5314 (setq articles (cdr marks))
5315 (while (and articles
5316 (or (and (consp (car articles))
5317 (> min (cdar articles)))
5318 (and (numberp (car articles))
5319 (> min (car articles)))))
5321 (set var articles))))))))
5323 (defun gnus-update-missing-marks (missing)
5324 "Go through the list of MISSING articles and remove them from the mark lists."
5327 ;; Go through all types.
5328 (dolist (elem gnus-article-mark-lists)
5329 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5330 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5331 (when (symbol-value var)
5332 ;; This list has articles. So we delete all missing
5333 ;; articles from it.
5336 (set var (delq (pop m) (symbol-value var))))))))))
5338 (defun gnus-update-marks ()
5339 "Enter the various lists of marked articles into the newsgroup info list."
5340 (let ((types gnus-article-mark-lists)
5341 (info (gnus-get-info gnus-newsgroup-name))
5342 type list newmarked symbol delta-marks)
5344 ;; Add all marks lists to the list of marks lists.
5345 (while (setq type (pop types))
5346 (setq list (symbol-value
5348 (intern (format "gnus-newsgroup-%s" (car type))))))
5351 ;; Get rid of the entries of the articles that have the
5353 (when (and (eq (cdr type) 'score)
5357 (prev (cons nil list))
5360 (if (or (not (consp (car arts)))
5361 (= (cdar arts) gnus-summary-default-score))
5362 (setcdr prev (cdr arts))
5364 (setq arts (cdr arts)))
5365 (setq list (cdr all)))))
5367 (when (eq (cdr type) 'seen)
5368 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5370 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5371 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5373 (when (and (gnus-check-backend-function
5374 'request-set-mark gnus-newsgroup-name)
5375 (not (gnus-article-unpropagatable-p (cdr type))))
5376 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5377 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5378 (add (gnus-remove-from-range
5379 (gnus-copy-sequence list) old)))
5381 (push (list add 'add (list (cdr type))) delta-marks))
5383 (push (list del 'del (list (cdr type))) delta-marks))))
5386 (push (cons (cdr type) list) newmarked)))
5389 (unless (gnus-check-group gnus-newsgroup-name)
5390 (error "Can't open server for %s" gnus-newsgroup-name))
5391 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5393 ;; Enter these new marks into the info of the group.
5395 (setcar (nthcdr 3 info) newmarked)
5396 ;; Add the marks lists to the end of the info.
5398 (setcdr (nthcdr 2 info) (list newmarked))))
5400 ;; Cut off the end of the info if there's nothing else there.
5404 (when (nthcdr (decf i) info)
5405 (setcdr (nthcdr i info) nil)))))))
5407 (defun gnus-set-mode-line (where)
5408 "Set the mode line of the article or summary buffers.
5409 If WHERE is `summary', the summary mode line format will be used."
5410 ;; Is this mode line one we keep updated?
5411 (when (and (memq where gnus-updated-mode-lines)
5413 (intern (format "gnus-%s-mode-line-format-spec" where))))
5416 ;; We evaluate this in the summary buffer since these
5417 ;; variables are buffer-local to that buffer.
5418 (set-buffer gnus-summary-buffer)
5419 ;; We bind all these variables that are used in the `eval' form
5421 (let* ((mformat (symbol-value
5423 (format "gnus-%s-mode-line-format-spec" where))))
5424 (gnus-tmp-group-name (gnus-group-decoded-name
5425 gnus-newsgroup-name))
5426 (gnus-tmp-article-number (or gnus-current-article 0))
5427 (gnus-tmp-unread gnus-newsgroup-unreads)
5428 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5429 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5430 (gnus-tmp-unread-and-unselected
5431 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5432 (zerop gnus-tmp-unselected))
5434 ((zerop gnus-tmp-unselected)
5435 (format "{%d more}" gnus-tmp-unread-and-unticked))
5436 (t (format "{%d(+%d) more}"
5437 gnus-tmp-unread-and-unticked
5438 gnus-tmp-unselected))))
5440 (if (and gnus-current-headers
5441 (vectorp gnus-current-headers))
5442 (gnus-mode-string-quote
5443 (mail-header-subject gnus-current-headers))
5445 bufname-length max-len
5446 gnus-tmp-header);; passed as argument to any user-format-funcs
5447 (setq mode-string (eval mformat))
5448 (setq bufname-length (if (string-match "%b" mode-string)
5451 (if (eq where 'summary)
5453 (get-buffer gnus-article-buffer))))
5456 (setq max-len (max 4 (if gnus-mode-non-string-length
5458 gnus-mode-non-string-length
5460 (length mode-string))))
5461 ;; We might have to chop a bit of the string off...
5462 (when (> (length mode-string) max-len)
5464 (concat (gnus-truncate-string mode-string (- max-len 3))
5466 ;; Pad the mode string a bit.
5467 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5468 ;; Update the mode line.
5469 (setq mode-line-buffer-identification
5470 (gnus-mode-line-buffer-identification (list mode-string)))
5471 (set-buffer-modified-p t))))
5473 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5474 "Go through the HEADERS list and add all Xrefs to a hash table.
5475 The resulting hash table is returned, or nil if no Xrefs were found."
5476 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5477 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5478 (xref-hashtb (gnus-make-hashtable))
5479 start group entry number xrefs header)
5481 (setq header (pop headers))
5482 (when (and (setq xrefs (mail-header-xref header))
5483 (not (memq (setq number (mail-header-number header))
5486 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5487 (setq start (match-end 0))
5488 (setq group (if prefix
5489 (concat prefix (substring xrefs (match-beginning 1)
5491 (substring xrefs (match-beginning 1) (match-end 1))))
5493 (string-to-int (substring xrefs (match-beginning 2)
5495 (if (setq entry (gnus-gethash group xref-hashtb))
5496 (setcdr entry (cons number (cdr entry)))
5497 (gnus-sethash group (cons number nil) xref-hashtb)))))
5498 (and start xref-hashtb)))
5500 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5501 "Look through all the headers and mark the Xrefs as read."
5502 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5503 name entry info xref-hashtb idlist method nth4)
5505 (set-buffer gnus-group-buffer)
5506 (when (setq xref-hashtb
5507 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5510 (unless (string= from-newsgroup (setq name (symbol-name group)))
5511 (setq idlist (symbol-value group))
5512 ;; Dead groups are not updated.
5514 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5516 (when (stringp (setq nth4 (gnus-info-method info)))
5517 (setq nth4 (gnus-server-to-method nth4))))
5518 ;; Only do the xrefs if the group has the same
5519 ;; select method as the group we have just read.
5520 (or (gnus-methods-equal-p
5521 nth4 (gnus-find-method-for-group from-newsgroup))
5523 (equal nth4 (setq method (gnus-find-method-for-group
5525 (and (equal (car nth4) (car method))
5526 (equal (nth 1 nth4) (nth 1 method))))
5527 gnus-use-cross-reference
5528 (or (not (eq gnus-use-cross-reference t))
5530 ;; Only do cross-references on subscribed
5531 ;; groups, if that is what is wanted.
5532 (<= (gnus-info-level info) gnus-level-subscribed))
5533 (gnus-group-make-articles-read name idlist))))
5536 (defun gnus-compute-read-articles (group articles)
5537 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5538 (info (nth 2 entry))
5539 (active (gnus-active group))
5542 ;; First peel off all invalid article numbers.
5544 (let ((ids articles)
5546 (while (setq id (pop ids))
5547 (when (and first (> id (cdr active)))
5548 ;; We'll end up in this situation in one particular
5549 ;; obscure situation. If you re-scan a group and get
5550 ;; a new article that is cross-posted to a different
5551 ;; group that has not been re-scanned, you might get
5552 ;; crossposted article that has a higher number than
5553 ;; Gnus believes possible. So we re-activate this
5554 ;; group as well. This might mean doing the
5555 ;; crossposting thingy will *increase* the number
5556 ;; of articles in some groups. Tsk, tsk.
5557 (setq active (or (gnus-activate-group group) active)))
5558 (when (or (> id (cdr active))
5559 (< id (car active)))
5560 (setq articles (delq id articles))))))
5561 ;; If the read list is nil, we init it.
5563 (null (gnus-info-read info))
5565 (setq ninfo (cons 1 (1- (car active))))
5566 (setq ninfo (gnus-info-read info)))
5567 ;; Then we add the read articles to the range.
5569 ninfo (setq articles (sort articles '<))))))
5571 (defun gnus-group-make-articles-read (group articles)
5572 "Update the info of GROUP to say that ARTICLES are read."
5574 (entry (gnus-gethash group gnus-newsrc-hashtb))
5575 (info (nth 2 entry))
5576 (active (gnus-active group))
5579 (setq range (gnus-compute-read-articles group articles))
5581 (set-buffer gnus-group-buffer)
5584 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5585 (gnus-info-set-read ',info ',(gnus-info-read info))
5586 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5587 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5588 (gnus-group-update-group ,group t))))
5589 ;; Add the read articles to the range.
5590 (gnus-info-set-read info range)
5591 (gnus-request-set-mark group (list (list range 'add '(read))))
5592 ;; Then we have to re-compute how many unread
5593 ;; articles there are in this group.
5597 (setq num (- (1+ (cdr active)) (car active))))
5598 ((not (listp (cdr range)))
5599 (setq num (- (cdr active) (- (1+ (cdr range))
5603 (if (numberp (car range))
5605 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5606 (setq range (cdr range)))
5607 (setq num (- (cdr active) num))))
5608 ;; Update the number of unread articles.
5610 ;; Update the group buffer.
5611 (unless (gnus-ephemeral-group-p group)
5612 (gnus-group-update-group group t))))))
5614 (defvar gnus-newsgroup-none-id 0)
5616 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5617 (let ((cur nntp-server-buffer)
5620 (save-excursion (set-buffer gnus-summary-buffer)
5621 gnus-newsgroup-dependencies)))
5623 (mail-parse-charset gnus-newsgroup-charset)
5624 (mail-parse-ignored-charsets
5625 (save-excursion (condition-case nil
5626 (set-buffer gnus-summary-buffer)
5628 gnus-newsgroup-ignored-charsets)))
5630 (set-buffer nntp-server-buffer)
5631 ;; Translate all TAB characters into SPACE characters.
5632 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5633 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5634 (gnus-run-hooks 'gnus-parse-headers-hook)
5635 (let ((case-fold-search t)
5636 in-reply-to header p lines chars ctype)
5637 (goto-char (point-min))
5638 ;; Search to the beginning of the next header. Error messages
5639 ;; do not begin with 2 or 3.
5640 (while (re-search-forward "^[23][0-9]+ " nil t)
5643 ;; This implementation of this function, with nine
5644 ;; search-forwards instead of the one re-search-forward and
5645 ;; a case (which basically was the old function) is actually
5646 ;; about twice as fast, even though it looks messier. You
5647 ;; can't have everything, I guess. Speed and elegance
5648 ;; doesn't always go hand in hand.
5651 (make-full-mail-header
5657 (narrow-to-region (point)
5658 (or (and (search-forward "\n.\n" nil t)
5664 (if (search-forward "\nsubject:" nil t)
5665 (nnheader-header-value)
5670 (if (search-forward "\nfrom:" nil t)
5671 (nnheader-header-value)
5676 (if (search-forward "\ndate:" nil t)
5677 (nnheader-header-value) ""))
5681 (setq id (if (re-search-forward
5682 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5683 ;; We do it this way to make sure the Message-ID
5684 ;; is (somewhat) syntactically valid.
5685 (buffer-substring (match-beginning 1)
5687 ;; If there was no message-id, we just fake one
5688 ;; to make subsequent routines simpler.
5689 (nnheader-generate-fake-message-id))))
5693 (if (search-forward "\nreferences:" nil t)
5697 (nnheader-header-value)
5702 (search-backward ">" end t)
5705 (search-backward "<" end t)
5707 ;; Get the references from the in-reply-to header if there
5708 ;; were no references and the in-reply-to header looks
5710 (if (and (search-forward "\nin-reply-to:" nil t)
5711 (setq in-reply-to (nnheader-header-value))
5712 (string-match "<[^>]+>" in-reply-to))
5714 (setq ref (substring in-reply-to (match-beginning 0)
5716 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5717 (setq ref2 (substring in-reply-to (match-beginning 0)
5719 (when (> (length ref2) (length ref))
5726 (if (search-forward "\nchars: " nil t)
5727 (if (numberp (setq chars (ignore-errors (read cur))))
5733 (if (search-forward "\nlines: " nil t)
5734 (if (numberp (setq lines (ignore-errors (read cur))))
5740 (and (search-forward "\nxref:" nil t)
5741 (nnheader-header-value)))
5743 (when gnus-extra-headers
5744 (let ((extra gnus-extra-headers)
5748 (when (search-forward
5749 (concat "\n" (symbol-name (car extra)) ":") nil t)
5750 (push (cons (car extra) (nnheader-header-value)) out))
5754 (if (and (search-forward "\ncontent-type: " nil t)
5755 (setq ctype (nnheader-header-value)))
5756 (mime-entity-set-content-type-internal
5757 header (mime-parse-Content-Type ctype)))
5758 (when (equal id ref)
5761 (when gnus-alter-header-function
5762 (funcall gnus-alter-header-function header)
5763 (setq id (mail-header-id header)
5764 ref (gnus-parent-id (mail-header-references header))))
5767 (gnus-dependencies-add-header
5768 header dependencies force-new))
5769 (push header headers))
5770 (goto-char (point-max))
5772 (nreverse headers)))))
5774 ;; Goes through the xover lines and returns a list of vectors
5775 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5776 force-new dependencies
5777 group also-fetch-heads)
5778 "Parse the news overview data in the server buffer.
5779 Return a list of headers that match SEQUENCE (see
5780 `nntp-retrieve-headers')."
5781 ;; Get the Xref when the users reads the articles since most/some
5782 ;; NNTP servers do not include Xrefs when using XOVER.
5783 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5784 (let ((mail-parse-charset gnus-newsgroup-charset)
5785 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5786 (cur nntp-server-buffer)
5787 (dependencies (or dependencies gnus-newsgroup-dependencies))
5789 ((eq gnus-read-all-available-headers t)
5791 ((stringp gnus-read-all-available-headers)
5792 (string-match gnus-read-all-available-headers group))
5795 number headers header)
5797 (set-buffer nntp-server-buffer)
5798 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5799 ;; Allow the user to mangle the headers before parsing them.
5800 (gnus-run-hooks 'gnus-parse-headers-hook)
5801 (goto-char (point-min))
5802 (gnus-parse-without-error
5803 (while (and (or sequence allp)
5805 (setq number (read cur))
5807 (while (and sequence
5808 (< (car sequence) number))
5809 (setq sequence (cdr sequence))))
5812 (eq number (car sequence))))
5814 (setq sequence (cdr sequence))
5815 (setq header (inline
5816 (gnus-nov-parse-line
5817 number dependencies force-new)))))
5818 (push header headers))
5820 ;; A common bug in inn is that if you have posted an article and
5821 ;; then retrieves the active file, it will answer correctly --
5822 ;; the new article is included. However, a NOV entry for the
5823 ;; article may not have been generated yet, so this may fail.
5824 ;; We work around this problem by retrieving the last few
5825 ;; headers using HEAD.
5826 (if (or (not also-fetch-heads)
5828 ;; We (probably) got all the headers.
5830 (let ((gnus-nov-is-evil t))
5833 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5834 (gnus-get-newsgroup-headers))))))))
5836 (defun gnus-article-get-xrefs ()
5837 "Fill in the Xref value in `gnus-current-headers', if necessary.
5838 This is meant to be called in `gnus-article-internal-prepare-hook'."
5839 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5840 gnus-current-headers)))
5841 (or (not gnus-use-cross-reference)
5843 (and (mail-header-xref headers)
5844 (not (string= (mail-header-xref headers) "")))
5845 (let ((case-fold-search t)
5848 (nnheader-narrow-to-headers)
5849 (goto-char (point-min))
5850 (when (or (and (not (eobp))
5851 (eq (downcase (char-after)) ?x)
5852 (looking-at "Xref:"))
5853 (search-forward "\nXref:" nil t))
5854 (goto-char (1+ (match-end 0)))
5855 (setq xref (buffer-substring (point)
5856 (progn (end-of-line) (point))))
5857 (mail-header-set-xref headers xref)))))))
5859 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5860 "Find article ID and insert the summary line for that article.
5861 OLD-HEADER can either be a header or a line number to insert
5862 the subject line on."
5863 (let* ((line (and (numberp old-header) old-header))
5864 (old-header (and (vectorp old-header) old-header))
5865 (header (cond ((and old-header use-old-header)
5868 (gnus-number-to-header id))
5869 (gnus-number-to-header id))
5871 (gnus-read-header id))))
5872 (number (and (numberp id) id))
5875 ;; Rebuild the thread that this article is part of and go to the
5876 ;; article we have fetched.
5877 (when (and (not gnus-show-threads)
5880 (setq d (gnus-data-find (mail-header-number old-header))))
5881 (goto-char (gnus-data-pos d))
5884 (- (gnus-point-at-bol)
5886 (1+ (gnus-point-at-eol))
5887 (gnus-delete-line))))))
5889 (mail-header-set-number header (mail-header-number old-header)))
5890 (setq gnus-newsgroup-sparse
5891 (delq (setq number (mail-header-number header))
5892 gnus-newsgroup-sparse))
5893 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5894 (push number gnus-newsgroup-limit)
5895 (gnus-rebuild-thread (mail-header-id header) line)
5896 (gnus-summary-goto-subject number nil t))
5897 (when (and (numberp number)
5899 ;; We have to update the boundaries even if we can't fetch the
5900 ;; article if ID is a number -- so that the next `P' or `N'
5901 ;; command will fetch the previous (or next) article even
5902 ;; if the one we tried to fetch this time has been canceled.
5903 (when (> number gnus-newsgroup-end)
5904 (setq gnus-newsgroup-end number))
5905 (when (< number gnus-newsgroup-begin)
5906 (setq gnus-newsgroup-begin number))
5907 (setq gnus-newsgroup-unselected
5908 (delq number gnus-newsgroup-unselected)))
5909 ;; Report back a success?
5910 (and header (mail-header-number header))))
5912 ;;; Process/prefix in the summary buffer
5914 (defun gnus-summary-work-articles (n)
5915 "Return a list of articles to be worked upon.
5916 The prefix argument, the list of process marked articles, and the
5917 current article will be taken into consideration."
5919 (set-buffer gnus-summary-buffer)
5922 ;; A numerical prefix has been given.
5923 (setq n (prefix-numeric-value n))
5924 (let ((backward (< n 0))
5925 (n (abs (prefix-numeric-value n)))
5930 (push (setq article (gnus-summary-article-number))
5933 (gnus-summary-find-prev nil article)
5934 (gnus-summary-find-next nil article)))
5936 (nreverse articles)))
5937 ((and (gnus-region-active-p) (mark))
5938 (message "region active")
5939 ;; Work on the region between point and mark.
5940 (let ((max (max (point) (mark)))
5943 (goto-char (min (point) (mark)))
5946 (push (setq article (gnus-summary-article-number)) articles)
5947 (gnus-summary-find-next nil article)
5949 (nreverse articles))))
5950 (gnus-newsgroup-processable
5951 ;; There are process-marked articles present.
5952 ;; Save current state.
5953 (gnus-summary-save-process-mark)
5955 (reverse gnus-newsgroup-processable))
5957 ;; Just return the current article.
5958 (list (gnus-summary-article-number))))))
5960 (defmacro gnus-summary-iterate (arg &rest forms)
5961 "Iterate over the process/prefixed articles and do FORMS.
5962 ARG is the interactive prefix given to the command. FORMS will be
5963 executed with point over the summary line of the articles."
5964 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5965 `(let ((,articles (gnus-summary-work-articles ,arg)))
5967 (gnus-summary-goto-subject (car ,articles))
5971 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5972 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5974 (defun gnus-summary-save-process-mark ()
5975 "Push the current set of process marked articles on the stack."
5977 (push (copy-sequence gnus-newsgroup-processable)
5978 gnus-newsgroup-process-stack))
5980 (defun gnus-summary-kill-process-mark ()
5981 "Push the current set of process marked articles on the stack and unmark."
5983 (gnus-summary-save-process-mark)
5984 (gnus-summary-unmark-all-processable))
5986 (defun gnus-summary-yank-process-mark ()
5987 "Pop the last process mark state off the stack and restore it."
5989 (unless gnus-newsgroup-process-stack
5990 (error "Empty mark stack"))
5991 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5993 (defun gnus-summary-process-mark-set (set)
5994 "Make SET into the current process marked articles."
5995 (gnus-summary-unmark-all-processable)
5997 (gnus-summary-set-process-mark (pop set))))
5999 ;;; Searching and stuff
6001 (defun gnus-summary-search-group (&optional backward use-level)
6002 "Search for next unread newsgroup.
6003 If optional argument BACKWARD is non-nil, search backward instead."
6005 (set-buffer gnus-group-buffer)
6006 (when (gnus-group-search-forward
6007 backward nil (if use-level (gnus-group-group-level) nil))
6008 (gnus-group-group-name))))
6010 (defun gnus-summary-best-group (&optional exclude-group)
6011 "Find the name of the best unread group.
6012 If EXCLUDE-GROUP, do not go to this group."
6014 (set-buffer gnus-group-buffer)
6016 (gnus-group-best-unread-group exclude-group))))
6018 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
6019 (if backward (gnus-summary-find-prev)
6020 (let* ((dummy (gnus-summary-article-intangible-p))
6021 (article (or article (gnus-summary-article-number)))
6022 (arts (gnus-data-find-list article))
6024 (when (and (not dummy)
6025 (or (not gnus-summary-check-current)
6027 (not (gnus-data-unread-p (car arts)))))
6028 (setq arts (cdr arts)))
6033 (when (or (and undownloaded
6034 (memq (car arts) gnus-newsgroup-undownloaded))
6035 (gnus-data-unread-p (car arts)))
6036 (setq result (car arts)
6038 (setq arts (cdr arts)))
6041 (goto-char (gnus-data-pos result))
6042 (gnus-data-number result)))))
6044 (defun gnus-summary-find-prev (&optional unread article)
6045 (let* ((eobp (eobp))
6046 (article (or article (gnus-summary-article-number)))
6047 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
6049 (when (and (not eobp)
6050 (or (not gnus-summary-check-current)
6052 (not (gnus-data-unread-p (car arts)))))
6053 (setq arts (cdr arts)))
6058 (when (gnus-data-unread-p (car arts))
6059 (setq result (car arts)
6061 (setq arts (cdr arts)))
6064 (goto-char (gnus-data-pos result))
6065 (gnus-data-number result))))
6067 (defun gnus-summary-find-subject (subject &optional unread backward article)
6068 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6069 (article (or article (gnus-summary-article-number)))
6070 (articles (gnus-data-list backward))
6071 (arts (gnus-data-find-list article articles))
6073 (when (or (not gnus-summary-check-current)
6075 (not (gnus-data-unread-p (car arts))))
6076 (setq arts (cdr arts)))
6078 (and (or (not unread)
6079 (gnus-data-unread-p (car arts)))
6080 (vectorp (gnus-data-header (car arts)))
6082 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6083 (setq result (car arts)
6085 (setq arts (cdr arts)))
6087 (goto-char (gnus-data-pos result))
6088 (gnus-data-number result))))
6090 (defun gnus-summary-search-forward (&optional unread subject backward)
6091 "Search forward for an article.
6092 If UNREAD, look for unread articles. If SUBJECT, look for
6093 articles with that subject. If BACKWARD, search backward instead."
6094 (cond (subject (gnus-summary-find-subject subject unread backward))
6095 (backward (gnus-summary-find-prev unread))
6096 (t (gnus-summary-find-next unread))))
6098 (defun gnus-recenter (&optional n)
6099 "Center point in window and redisplay frame.
6100 Also do horizontal recentering."
6102 (when (and gnus-auto-center-summary
6103 (not (eq gnus-auto-center-summary 'vertical)))
6104 (gnus-horizontal-recenter))
6107 (defun gnus-summary-recenter ()
6108 "Center point in the summary window.
6109 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6110 displayed, no centering will be performed."
6111 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6112 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6114 (let* ((top (cond ((< (window-height) 4) 0)
6115 ((< (window-height) 7) 1)
6116 (t (if (numberp gnus-auto-center-summary)
6117 gnus-auto-center-summary
6119 (height (1- (window-height)))
6120 (bottom (save-excursion (goto-char (point-max))
6121 (forward-line (- height))
6123 (window (get-buffer-window (current-buffer))))
6124 ;; The user has to want it.
6125 (when gnus-auto-center-summary
6126 (when (get-buffer-window gnus-article-buffer)
6127 ;; Only do recentering when the article buffer is displayed,
6128 ;; Set the window start to either `bottom', which is the biggest
6129 ;; possible valid number, or the second line from the top,
6130 ;; whichever is the least.
6131 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6132 (if (> bottom top-pos)
6133 ;; Keep the second line from the top visible
6134 (set-window-start window top-pos t)
6135 ;; Try to keep the bottom line visible; if it's partially
6136 ;; obscured, either scroll one more line to make it fully
6137 ;; visible, or revert to using TOP-POS.
6139 (goto-char (point-max))
6141 (let ((last-line-start (point)))
6143 (set-window-start window (point) t)
6144 (when (not (pos-visible-in-window-p last-line-start window))
6146 (set-window-start window (min (point) top-pos) t)))))))
6147 ;; Do horizontal recentering while we're at it.
6148 (when (and (get-buffer-window (current-buffer) t)
6149 (not (eq gnus-auto-center-summary 'vertical)))
6150 (let ((selected (selected-window)))
6151 (select-window (get-buffer-window (current-buffer) t))
6152 (gnus-summary-position-point)
6153 (gnus-horizontal-recenter)
6154 (select-window selected))))))
6156 (defun gnus-summary-jump-to-group (newsgroup)
6157 "Move point to NEWSGROUP in group mode buffer."
6158 ;; Keep update point of group mode buffer if visible.
6159 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6160 (save-window-excursion
6161 ;; Take care of tree window mode.
6162 (when (get-buffer-window gnus-group-buffer)
6163 (pop-to-buffer gnus-group-buffer))
6164 (gnus-group-jump-to-group newsgroup))
6166 ;; Take care of tree window mode.
6167 (if (get-buffer-window gnus-group-buffer)
6168 (pop-to-buffer gnus-group-buffer)
6169 (set-buffer gnus-group-buffer))
6170 (gnus-group-jump-to-group newsgroup))))
6172 ;; This function returns a list of article numbers based on the
6173 ;; difference between the ranges of read articles in this group and
6174 ;; the range of active articles.
6175 (defun gnus-list-of-unread-articles (group)
6176 (let* ((read (gnus-info-read (gnus-get-info group)))
6177 (active (or (gnus-active group) (gnus-activate-group group)))
6180 ;; If none are read, then all are unread.
6182 (setq first (car active))
6183 ;; If the range of read articles is a single range, then the
6184 ;; first unread article is the article after the last read
6185 ;; article. Sounds logical, doesn't it?
6186 (if (and (not (listp (cdr read)))
6187 (or (< (car read) (car active))
6188 (progn (setq read (list read))
6190 (setq first (max (car active) (1+ (cdr read))))
6191 ;; `read' is a list of ranges.
6192 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6195 (setq first (car active)))
6198 (while (< first nlast)
6200 (setq first (1+ first))))
6201 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6202 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6203 (setq read (cdr read)))))
6204 ;; And add the last unread articles.
6205 (while (<= first last)
6207 (setq first (1+ first)))
6208 ;; Return the list of unread articles.
6209 (delq 0 (nreverse unread))))
6211 (defun gnus-list-of-read-articles (group)
6212 "Return a list of unread, unticked and non-dormant articles."
6213 (let* ((info (gnus-get-info group))
6214 (marked (gnus-info-marks info))
6215 (active (gnus-active group)))
6217 (gnus-list-range-difference
6218 (gnus-list-range-difference
6219 (gnus-sorted-complement
6220 (gnus-uncompress-range active)
6221 (gnus-list-of-unread-articles group))
6222 (cdr (assq 'dormant marked)))
6223 (cdr (assq 'tick marked))))))
6225 ;; Various summary commands
6227 (defun gnus-summary-select-article-buffer ()
6228 "Reconfigure windows to show article buffer."
6230 (if (not (gnus-buffer-live-p gnus-article-buffer))
6231 (error "There is no article buffer for this summary buffer")
6232 (gnus-configure-windows 'article)
6233 (select-window (get-buffer-window gnus-article-buffer))))
6235 (defun gnus-summary-universal-argument (arg)
6236 "Perform any operation on all articles that are process/prefixed."
6238 (let ((articles (gnus-summary-work-articles arg))
6245 (substitute-command-keys
6246 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6248 (gnus-error 1 "Undefined key")
6251 (gnus-summary-goto-subject (setq article (pop articles)))
6252 (let (gnus-newsgroup-processable)
6253 (command-execute func))
6254 (gnus-summary-remove-process-mark article)))))
6255 (gnus-summary-position-point))
6257 (defun gnus-summary-toggle-truncation (&optional arg)
6258 "Toggle truncation of summary lines.
6259 With arg, turn line truncation on if arg is positive."
6261 (setq truncate-lines
6262 (if (null arg) (not truncate-lines)
6263 (> (prefix-numeric-value arg) 0)))
6266 (defun gnus-summary-find-uncancelled ()
6267 "Return the number of an uncancelled article.
6268 The current article is considered, then following articles, then previous
6269 articles. If all articles are cancelled then return a dummy 0."
6271 (dolist (rev '(nil t))
6272 (unless found ; don't demand the reverse list if we don't need it
6273 (let ((data (gnus-data-find-list
6274 (gnus-summary-article-number) (gnus-data-list rev))))
6275 (while (and data (not found))
6276 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6277 (setq found (gnus-data-number (car data))))
6278 (setq data (cdr data))))))
6281 (defun gnus-summary-reselect-current-group (&optional all rescan)
6282 "Exit and then reselect the current newsgroup.
6283 The prefix argument ALL means to select all articles."
6285 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6286 (error "Ephemeral groups can't be reselected"))
6287 (let ((current-subject (gnus-summary-find-uncancelled))
6288 (group gnus-newsgroup-name))
6289 (setq gnus-newsgroup-begin nil)
6291 ;; We have to adjust the point of group mode buffer because
6292 ;; point was moved to the next unread newsgroup by exiting.
6293 (gnus-summary-jump-to-group group)
6296 (save-window-excursion
6297 ;; Don't show group contents.
6298 (set-window-start (selected-window) (point-max))
6299 (gnus-group-get-new-news-this-group 1))))
6300 (gnus-group-read-group all t)
6301 (gnus-summary-goto-subject current-subject nil t)))
6303 (defun gnus-summary-rescan-group (&optional all)
6304 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6306 (gnus-summary-reselect-current-group all t))
6308 (defun gnus-summary-update-info (&optional non-destructive)
6310 (let ((group gnus-newsgroup-name))
6312 (when gnus-newsgroup-kill-headers
6313 (setq gnus-newsgroup-killed
6314 (gnus-compress-sequence
6316 (gnus-list-range-intersection
6317 gnus-newsgroup-unselected gnus-newsgroup-killed)
6318 gnus-newsgroup-unreads)
6320 (unless (listp (cdr gnus-newsgroup-killed))
6321 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6322 (let ((headers gnus-newsgroup-headers))
6323 ;; Set the new ranges of read articles.
6325 (set-buffer gnus-group-buffer)
6326 (gnus-undo-force-boundary))
6327 (gnus-update-read-articles
6328 group (gnus-sorted-union
6329 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6330 ;; Set the current article marks.
6331 (let ((gnus-newsgroup-scored
6332 (if (and (not gnus-save-score)
6333 (not non-destructive))
6335 gnus-newsgroup-scored)))
6337 (gnus-update-marks)))
6338 ;; Do the cross-ref thing.
6339 (when gnus-use-cross-reference
6340 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6341 ;; Do not switch windows but change the buffer to work.
6342 (set-buffer gnus-group-buffer)
6343 (unless (gnus-ephemeral-group-p group)
6344 (gnus-group-update-group group)))))))
6346 (defun gnus-summary-save-newsrc (&optional force)
6347 "Save the current number of read/marked articles in the dribble buffer.
6348 The dribble buffer will then be saved.
6349 If FORCE (the prefix), also save the .newsrc file(s)."
6351 (gnus-summary-update-info t)
6353 (gnus-save-newsrc-file)
6354 (gnus-dribble-save)))
6356 (defun gnus-summary-exit (&optional temporary)
6357 "Exit reading current newsgroup, and then return to group selection mode.
6358 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6360 (gnus-set-global-variables)
6361 (gnus-kill-save-kill-buffer)
6362 (gnus-async-halt-prefetch)
6363 (let* ((group gnus-newsgroup-name)
6364 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6365 (gnus-group-is-exiting-p t)
6368 (buf (current-buffer)))
6370 ;; Do adaptive scoring, and possibly save score files.
6371 (when gnus-newsgroup-adaptive
6372 (gnus-score-adaptive))
6373 (when gnus-use-scoring
6375 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6376 ;; If we have several article buffers, we kill them at exit.
6377 (unless gnus-single-article-buffer
6378 (gnus-kill-buffer gnus-original-article-buffer)
6379 (setq gnus-article-current nil))
6380 (when gnus-use-cache
6381 (gnus-cache-possibly-remove-articles)
6382 (gnus-cache-save-buffers))
6383 (gnus-async-prefetch-remove-group group)
6384 (when gnus-suppress-duplicates
6385 (gnus-dup-enter-articles))
6386 (when gnus-use-trees
6387 (gnus-tree-close group))
6388 (when gnus-use-cache
6389 (gnus-cache-write-active))
6390 ;; Remove entries for this group.
6391 (nnmail-purge-split-history (gnus-group-real-name group))
6392 ;; Make all changes in this group permanent.
6394 (gnus-run-hooks 'gnus-exit-group-hook)
6395 (gnus-summary-update-info))
6396 (gnus-close-group group)
6397 ;; Make sure where we were, and go to next newsgroup.
6398 (set-buffer gnus-group-buffer)
6400 (gnus-group-jump-to-group group))
6401 (gnus-run-hooks 'gnus-summary-exit-hook)
6402 (unless (or quit-config
6403 ;; If this group has disappeared from the summary
6404 ;; buffer, don't skip forwards.
6405 (not (string= group (gnus-group-group-name))))
6406 (gnus-group-next-unread-group 1))
6407 (setq group-point (point))
6410 ;; If we have several article buffers, we kill them at exit.
6411 (unless gnus-single-article-buffer
6412 (gnus-kill-buffer gnus-article-buffer)
6413 (gnus-kill-buffer gnus-original-article-buffer)
6414 (setq gnus-article-current nil))
6416 (if (not gnus-kill-summary-on-exit)
6418 (gnus-deaden-summary)
6420 ;; We set all buffer-local variables to nil. It is unclear why
6421 ;; this is needed, but if we don't, buffer-local variables are
6422 ;; not garbage-collected, it seems. This would the lead to en
6423 ;; ever-growing Emacs.
6424 (gnus-summary-clear-local-variables)
6425 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6426 (gnus-summary-clear-local-variables))
6427 (when (get-buffer gnus-article-buffer)
6428 (bury-buffer gnus-article-buffer))
6429 ;; We clear the global counterparts of the buffer-local
6430 ;; variables as well, just to be on the safe side.
6431 (set-buffer gnus-group-buffer)
6432 (gnus-summary-clear-local-variables)
6433 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6434 (gnus-summary-clear-local-variables))
6435 ;; Return to group mode buffer.
6436 (when (eq mode 'gnus-summary-mode)
6437 (gnus-kill-buffer buf)))
6438 (setq gnus-current-select-method gnus-select-method)
6439 (pop-to-buffer gnus-group-buffer)
6440 (if (not quit-config)
6442 (goto-char group-point)
6443 (gnus-configure-windows 'group 'force)
6444 (unless (pos-visible-in-window-p)
6445 (forward-line (/ (static-if (featurep 'xemacs)
6446 (window-displayed-height)
6447 (1- (window-height)))
6449 (set-window-start (selected-window) (point))
6450 (goto-char group-point)))
6451 (gnus-handle-ephemeral-exit quit-config))
6452 ;; Clear the current group name.
6454 (setq gnus-newsgroup-name nil)))))
6456 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6457 (defun gnus-summary-exit-no-update (&optional no-questions)
6458 "Quit reading current newsgroup without updating read article info."
6460 (let* ((group gnus-newsgroup-name)
6461 (gnus-group-is-exiting-p t)
6462 (quit-config (gnus-group-quit-config group)))
6463 (when (or no-questions
6465 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6466 (gnus-async-halt-prefetch)
6468 (delq 'gnus-summary-expire-articles
6469 (copy-sequence gnus-summary-prepare-exit-hook)))
6470 ;; If we have several article buffers, we kill them at exit.
6471 (unless gnus-single-article-buffer
6472 (gnus-kill-buffer gnus-article-buffer)
6473 (gnus-kill-buffer gnus-original-article-buffer)
6474 (setq gnus-article-current nil))
6475 (if (not gnus-kill-summary-on-exit)
6476 (gnus-deaden-summary)
6477 (gnus-close-group group)
6478 (gnus-summary-clear-local-variables)
6479 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6480 (gnus-summary-clear-local-variables))
6481 (set-buffer gnus-group-buffer)
6482 (gnus-summary-clear-local-variables)
6483 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6484 (gnus-summary-clear-local-variables))
6485 (when (get-buffer gnus-summary-buffer)
6486 (kill-buffer gnus-summary-buffer)))
6487 (unless gnus-single-article-buffer
6488 (setq gnus-article-current nil))
6489 (when gnus-use-trees
6490 (gnus-tree-close group))
6491 (gnus-async-prefetch-remove-group group)
6492 (when (get-buffer gnus-article-buffer)
6493 (bury-buffer gnus-article-buffer))
6494 ;; Return to the group buffer.
6495 (gnus-configure-windows 'group 'force)
6496 ;; Clear the current group name.
6497 (setq gnus-newsgroup-name nil)
6498 (unless (gnus-ephemeral-group-p group)
6499 (gnus-group-update-group group))
6500 (when (equal (gnus-group-group-name) group)
6501 (gnus-group-next-unread-group 1))
6503 (gnus-handle-ephemeral-exit quit-config)))))
6505 (defun gnus-handle-ephemeral-exit (quit-config)
6506 "Handle movement when leaving an ephemeral group.
6507 The state which existed when entering the ephemeral is reset."
6508 (if (not (buffer-name (car quit-config)))
6509 (gnus-configure-windows 'group 'force)
6510 (set-buffer (car quit-config))
6511 (cond ((eq major-mode 'gnus-summary-mode)
6512 (gnus-set-global-variables))
6513 ((eq major-mode 'gnus-article-mode)
6515 ;; The `gnus-summary-buffer' variable may point
6516 ;; to the old summary buffer when using a single
6518 (unless (gnus-buffer-live-p gnus-summary-buffer)
6519 (set-buffer gnus-group-buffer))
6520 (set-buffer gnus-summary-buffer)
6521 (gnus-set-global-variables))))
6522 (if (or (eq (cdr quit-config) 'article)
6523 (eq (cdr quit-config) 'pick))
6525 ;; The current article may be from the ephemeral group
6526 ;; thus it is best that we reload this article
6527 (gnus-summary-show-article)
6528 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6529 (gnus-configure-windows 'pick 'force)
6530 (gnus-configure-windows (cdr quit-config) 'force)))
6531 (gnus-configure-windows (cdr quit-config) 'force))
6532 (when (eq major-mode 'gnus-summary-mode)
6533 (gnus-summary-next-subject 1 nil t)
6534 (gnus-summary-recenter)
6535 (gnus-summary-position-point))))
6537 (defun gnus-summary-preview-mime-message ()
6538 "MIME decode and play this message."
6540 (let ((gnus-break-pages nil)
6542 (gnus-summary-select-article gnus-show-all-headers t))
6543 (let ((w (get-buffer-window gnus-article-buffer)))
6545 (select-window (get-buffer-window gnus-article-buffer)))))
6549 (defvar gnus-dead-summary-mode-map nil)
6551 (unless gnus-dead-summary-mode-map
6552 (setq gnus-dead-summary-mode-map (make-keymap))
6553 (suppress-keymap gnus-dead-summary-mode-map)
6554 (substitute-key-definition
6555 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6556 (dolist (key '("\C-d" "\r" "\177" [delete]))
6557 (define-key gnus-dead-summary-mode-map
6558 key 'gnus-summary-wake-up-the-dead))
6559 (dolist (key '("q" "Q"))
6560 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6562 (defvar gnus-dead-summary-mode nil
6563 "Minor mode for Gnus summary buffers.")
6565 (defun gnus-dead-summary-mode (&optional arg)
6566 "Minor mode for Gnus summary buffers."
6568 (when (eq major-mode 'gnus-summary-mode)
6569 (make-local-variable 'gnus-dead-summary-mode)
6570 (setq gnus-dead-summary-mode
6571 (if (null arg) (not gnus-dead-summary-mode)
6572 (> (prefix-numeric-value arg) 0)))
6573 (when gnus-dead-summary-mode
6574 (gnus-add-minor-mode
6575 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6577 (defun gnus-deaden-summary ()
6578 "Make the current summary buffer into a dead summary buffer."
6579 ;; Kill any previous dead summary buffer.
6580 (when (and gnus-dead-summary
6581 (buffer-name gnus-dead-summary))
6583 (set-buffer gnus-dead-summary)
6584 (when gnus-dead-summary-mode
6585 (kill-buffer (current-buffer)))))
6586 ;; Make this the current dead summary.
6587 (setq gnus-dead-summary (current-buffer))
6588 (gnus-dead-summary-mode 1)
6589 (let ((name (buffer-name)))
6590 (when (string-match "Summary" name)
6592 (concat (substring name 0 (match-beginning 0)) "Dead "
6593 (substring name (match-beginning 0)))
6597 (defun gnus-kill-or-deaden-summary (buffer)
6598 "Kill or deaden the summary BUFFER."
6600 (when (and (buffer-name buffer)
6601 (not gnus-single-article-buffer))
6604 (gnus-kill-buffer gnus-article-buffer)
6605 (gnus-kill-buffer gnus-original-article-buffer)))
6608 (gnus-kill-summary-on-exit
6609 (when (and gnus-use-trees
6610 (gnus-buffer-exists-p buffer))
6613 (gnus-tree-close gnus-newsgroup-name)))
6614 (gnus-kill-buffer buffer))
6615 ;; Deaden the buffer.
6616 ((gnus-buffer-exists-p buffer)
6619 (gnus-deaden-summary))))))
6621 (defun gnus-summary-wake-up-the-dead (&rest args)
6622 "Wake up the dead summary buffer."
6624 (gnus-dead-summary-mode -1)
6625 (let ((name (buffer-name)))
6626 (when (string-match "Dead " name)
6628 (concat (substring name 0 (match-beginning 0))
6629 (substring name (match-end 0)))
6631 (gnus-message 3 "This dead summary is now alive again"))
6633 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6634 (defun gnus-summary-fetch-faq (&optional faq-dir)
6635 "Fetch the FAQ for the current group.
6636 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6640 (when current-prefix-arg
6642 "FAQ dir: " (and (listp gnus-group-faq-directory)
6643 (mapcar (lambda (file) (list file))
6644 gnus-group-faq-directory))))))
6645 (let (gnus-faq-buffer)
6646 (when (setq gnus-faq-buffer
6647 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6648 (gnus-configure-windows 'summary-faq))))
6650 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6651 (defun gnus-summary-describe-group (&optional force)
6652 "Describe the current newsgroup."
6654 (gnus-group-describe-group force gnus-newsgroup-name))
6656 (defun gnus-summary-describe-briefly ()
6657 "Describe summary mode commands briefly."
6659 (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")))
6661 ;; Walking around group mode buffer from summary mode.
6663 (defun gnus-summary-next-group (&optional no-article target-group backward)
6664 "Exit current newsgroup and then select next unread newsgroup.
6665 If prefix argument NO-ARTICLE is non-nil, no article is selected
6666 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6667 previous group instead."
6669 ;; Stop pre-fetching.
6670 (gnus-async-halt-prefetch)
6671 (let ((current-group gnus-newsgroup-name)
6672 (current-buffer (current-buffer))
6674 (gnus-summary-exit t)
6675 (while (not entered)
6676 ;; Then we find what group we are supposed to enter.
6677 (set-buffer gnus-group-buffer)
6678 (gnus-group-jump-to-group current-group)
6681 (if (eq gnus-keep-same-level 'best)
6682 (gnus-summary-best-group gnus-newsgroup-name)
6683 (gnus-summary-search-group backward gnus-keep-same-level))))
6684 (if (not target-group)
6685 ;; There are no further groups, so we return to the group
6688 (gnus-message 5 "Returning to the group buffer")
6690 (when (gnus-buffer-live-p current-buffer)
6691 (set-buffer current-buffer)
6692 (gnus-summary-exit))
6693 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6694 ;; We try to enter the target group.
6695 (gnus-group-jump-to-group target-group)
6696 (let ((unreads (gnus-group-group-unread)))
6697 (if (and (or (eq t unreads)
6698 (and unreads (not (zerop unreads))))
6700 ;; Now we semi-exit this group to update Xrefs
6701 ;; and all variables. We can't do a real exit,
6702 ;; because the window conf must remain the same
6703 ;; in case the user is prompted for info, and we
6704 ;; don't want the window conf to change before
6706 (when (gnus-buffer-live-p current-buffer)
6707 (set-buffer current-buffer)
6708 (gnus-summary-exit t))
6709 (gnus-summary-read-group
6710 target-group nil no-article
6711 (and (buffer-name current-buffer) current-buffer)
6714 (setq current-group target-group
6715 target-group nil)))))))
6717 (defun gnus-summary-prev-group (&optional no-article)
6718 "Exit current newsgroup and then select previous unread newsgroup.
6719 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6721 (gnus-summary-next-group no-article nil t))
6723 ;; Walking around summary lines.
6725 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6726 "Go to the first unread subject.
6727 If UNREAD is non-nil, go to the first unread article.
6728 Returns the article selected or nil if there are no unread articles."
6733 ((null gnus-newsgroup-data)
6734 (gnus-message 3 "No articles in the group")
6736 ;; Pick the first article.
6738 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6739 (gnus-data-number (car gnus-newsgroup-data)))
6740 ;; No unread articles.
6741 ((null gnus-newsgroup-unreads)
6742 (gnus-message 3 "No more unread articles")
6744 ;; Find the first unread article.
6746 (let ((data gnus-newsgroup-data))
6748 (and (not (and undownloaded
6750 gnus-newsgroup-undownloaded)))
6753 (gnus-data-number (car data))
6754 gnus-newsgroup-unseen))
6755 (not (gnus-data-unread-p (car data))))
6756 (not (gnus-data-unread-p (car data))))))
6757 (setq data (cdr data)))
6759 (goto-char (gnus-data-pos (car data)))
6760 (gnus-data-number (car data))))))
6761 (gnus-summary-position-point)))
6763 (defun gnus-summary-next-subject (n &optional unread dont-display)
6764 "Go to next N'th summary line.
6765 If N is negative, go to the previous N'th subject line.
6766 If UNREAD is non-nil, only unread articles are selected.
6767 The difference between N and the actual number of steps taken is
6770 (let ((backward (< n 0))
6774 (gnus-summary-find-prev unread)
6775 (gnus-summary-find-next unread)))
6776 (unless (zerop (setq n (1- n)))
6777 (gnus-summary-show-thread)))
6779 (gnus-message 7 "No more%s articles"
6780 (if unread " unread" "")))
6781 (unless dont-display
6782 (gnus-summary-recenter)
6783 (gnus-summary-position-point))
6786 (defun gnus-summary-next-unread-subject (n)
6787 "Go to next N'th unread summary line."
6789 (gnus-summary-next-subject n t))
6791 (defun gnus-summary-prev-subject (n &optional unread)
6792 "Go to previous N'th summary line.
6793 If optional argument UNREAD is non-nil, only unread article is selected."
6795 (gnus-summary-next-subject (- n) unread))
6797 (defun gnus-summary-prev-unread-subject (n)
6798 "Go to previous N'th unread summary line."
6800 (gnus-summary-next-subject (- n) t))
6802 (defun gnus-summary-goto-subjects (articles)
6803 "Insert the subject header for ARTICLES in the current buffer."
6805 (dolist (article articles)
6806 (gnus-summary-goto-subject article t)))
6807 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6808 (gnus-summary-position-point))
6810 (defun gnus-summary-goto-subject (article &optional force silent)
6811 "Go the subject line of ARTICLE.
6812 If FORCE, also allow jumping to articles not currently shown."
6813 (interactive "nArticle number: ")
6814 (unless (numberp article)
6815 (error "Article %s is not a number" article))
6817 (data (gnus-data-find article)))
6818 ;; We read in the article if we have to.
6821 (gnus-summary-insert-subject
6823 (if (or (numberp force) (vectorp force)) force)
6825 (setq data (gnus-data-find article)))
6830 (gnus-message 3 "Can't find article %d" article))
6832 (let ((pt (gnus-data-pos data)))
6834 (gnus-summary-set-article-display-arrow pt))
6835 (gnus-summary-position-point)
6838 ;; Walking around summary lines with displaying articles.
6840 (defun gnus-summary-expand-window (&optional arg)
6841 "Make the summary buffer take up the entire Emacs frame.
6842 Given a prefix, will force an `article' buffer configuration."
6845 (gnus-configure-windows 'article 'force)
6846 (gnus-configure-windows 'summary 'force)))
6848 (defun gnus-summary-display-article (article &optional all-header)
6849 "Display ARTICLE in article buffer."
6850 (when (gnus-buffer-live-p gnus-article-buffer)
6851 (with-current-buffer gnus-article-buffer
6852 (set-buffer-multibyte t)))
6853 (gnus-set-global-variables)
6854 (when (gnus-buffer-live-p gnus-article-buffer)
6855 (with-current-buffer gnus-article-buffer
6856 (setq gnus-article-charset gnus-newsgroup-charset)
6857 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6858 (set-buffer-multibyte t)))
6862 (if gnus-summary-display-article-function
6863 (funcall gnus-summary-display-article-function article all-header)
6864 (gnus-article-prepare article all-header))
6865 (with-current-buffer gnus-article-buffer
6866 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6868 (gnus-run-hooks 'gnus-select-article-hook)
6869 (when (and gnus-current-article
6870 (not (zerop gnus-current-article)))
6871 (gnus-summary-goto-subject gnus-current-article))
6872 (gnus-summary-recenter)
6873 (when (and gnus-use-trees gnus-show-threads)
6874 (gnus-possibly-generate-tree article)
6875 (gnus-highlight-selected-tree article))
6876 ;; Successfully display article.
6877 (gnus-article-set-window-start
6878 (cdr (assq article gnus-newsgroup-bookmarks))))))
6880 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6881 "Select the current article.
6882 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6883 non-nil, the article will be re-fetched even if it already present in
6884 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6886 ;; Make sure we are in the summary buffer to work around bbdb bug.
6887 (unless (eq major-mode 'gnus-summary-mode)
6888 (set-buffer gnus-summary-buffer))
6889 (let ((article (or article (gnus-summary-article-number)))
6890 (all-headers (not (not all-headers))) ;Must be T or NIL.
6891 gnus-summary-display-article-function)
6893 (gnus-summary-article-pseudo-p article)
6894 (error "This is a pseudo-article"))
6896 (set-buffer gnus-summary-buffer)
6897 (if (or (and gnus-single-article-buffer
6898 (or (null gnus-current-article)
6899 (null gnus-article-current)
6900 (null (get-buffer gnus-article-buffer))
6901 (not (eq article (cdr gnus-article-current)))
6902 (not (equal (car gnus-article-current)
6903 gnus-newsgroup-name))))
6904 (and (not gnus-single-article-buffer)
6905 (or (null gnus-current-article)
6906 (not (eq gnus-current-article article))))
6908 ;; The requested article is different from the current article.
6910 (gnus-summary-display-article article all-headers)
6911 (gnus-article-set-window-start
6912 (cdr (assq article gnus-newsgroup-bookmarks)))
6916 (defun gnus-summary-force-verify-and-decrypt ()
6918 (let ((mm-verify-option 'known)
6919 (mm-decrypt-option 'known)
6920 (gnus-buttonized-mime-types (append (list "multipart/signed"
6921 "multipart/encrypted")
6922 gnus-buttonized-mime-types)))
6923 (gnus-summary-select-article nil 'force)))
6925 (defun gnus-summary-set-current-mark (&optional current-mark)
6926 "Obsolete function."
6929 (defun gnus-summary-next-article (&optional unread subject backward push)
6930 "Select the next article.
6931 If UNREAD, only unread articles are selected.
6932 If SUBJECT, only articles with SUBJECT are selected.
6933 If BACKWARD, the previous article is selected instead of the next."
6936 ;; Is there such an article?
6937 ((and (gnus-summary-search-forward unread subject backward)
6938 (or (gnus-summary-display-article (gnus-summary-article-number))
6939 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6940 (gnus-summary-position-point))
6941 ;; If not, we try the first unread, if that is wanted.
6943 gnus-auto-select-same
6944 (gnus-summary-first-unread-article))
6945 (gnus-summary-position-point)
6946 (gnus-message 6 "Wrapped"))
6947 ;; Try to get next/previous article not displayed in this group.
6948 ((and gnus-auto-extend-newsgroup
6949 (not unread) (not subject))
6950 (gnus-summary-goto-article
6951 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6952 nil (count-lines (point-min) (point))))
6953 ;; Go to next/previous group.
6955 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6956 (gnus-summary-jump-to-group gnus-newsgroup-name))
6957 (let ((cmd last-command-char)
6960 (set-buffer gnus-group-buffer)
6963 (if (eq gnus-keep-same-level 'best)
6964 (gnus-summary-best-group gnus-newsgroup-name)
6965 (gnus-summary-search-group backward gnus-keep-same-level))))
6966 ;; For some reason, the group window gets selected. We change
6968 (select-window (get-buffer-window (current-buffer)))
6969 ;; Select next unread newsgroup automagically.
6971 ((or (not gnus-auto-select-next)
6973 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6974 ((or (eq gnus-auto-select-next 'quietly)
6975 (and (eq gnus-auto-select-next 'slightly-quietly)
6977 (and (eq gnus-auto-select-next 'almost-quietly)
6978 (gnus-summary-last-article-p)))
6980 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6982 (gnus-message 7 "No more%s articles (%s)..."
6983 (if unread " unread" "")
6984 (if group (concat "selecting " group)
6986 (gnus-summary-next-group nil group backward)))
6988 (when (gnus-key-press-event-p last-input-event)
6989 (gnus-summary-walk-group-buffer
6990 gnus-newsgroup-name cmd unread backward point))))))))
6992 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6993 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6994 (?\C-p (gnus-group-prev-unread-group 1))))
6995 (cursor-in-echo-area t)
6996 keve key group ended prompt)
6998 (set-buffer gnus-group-buffer)
7001 (if (eq gnus-keep-same-level 'best)
7002 (gnus-summary-best-group gnus-newsgroup-name)
7003 (gnus-summary-search-group backward gnus-keep-same-level))))
7007 "No more%s articles%s " (if unread " unread" "")
7009 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7010 (format " (Type %s for %s [%s])"
7011 (single-key-description cmd) group
7012 (car (gnus-gethash group gnus-newsrc-hashtb)))
7013 (format " (Type %s to exit %s)"
7014 (single-key-description cmd)
7015 gnus-newsgroup-name))))
7016 ;; Confirm auto selection.
7017 (setq key (car (setq keve (gnus-read-event-char prompt)))
7020 ((assq key keystrokes)
7021 (let ((obuf (current-buffer)))
7022 (switch-to-buffer gnus-group-buffer)
7024 (gnus-group-jump-to-group group))
7025 (eval (cadr (assq key keystrokes)))
7026 (setq group (gnus-group-group-name))
7027 (switch-to-buffer obuf))
7031 (gnus-ephemeral-group-p gnus-newsgroup-name))
7033 (gnus-summary-next-group nil group backward)))
7035 (push (cdr keve) unread-command-events))))))
7037 (defun gnus-summary-next-unread-article ()
7038 "Select unread article after current one."
7040 (gnus-summary-next-article
7041 (or (not (eq gnus-summary-goto-unread 'never))
7042 (gnus-summary-last-article-p (gnus-summary-article-number)))
7043 (and gnus-auto-select-same
7044 (gnus-summary-article-subject))))
7046 (defun gnus-summary-prev-article (&optional unread subject)
7047 "Select the article after the current one.
7048 If UNREAD is non-nil, only unread articles are selected."
7050 (gnus-summary-next-article unread subject t))
7052 (defun gnus-summary-prev-unread-article ()
7053 "Select unread article before current one."
7055 (gnus-summary-prev-article
7056 (or (not (eq gnus-summary-goto-unread 'never))
7057 (gnus-summary-first-article-p (gnus-summary-article-number)))
7058 (and gnus-auto-select-same
7059 (gnus-summary-article-subject))))
7061 (defun gnus-summary-next-page (&optional lines circular stop)
7062 "Show next page of the selected article.
7063 If at the end of the current article, select the next article.
7064 LINES says how many lines should be scrolled up.
7066 If CIRCULAR is non-nil, go to the start of the article instead of
7067 selecting the next article when reaching the end of the current
7070 If STOP is non-nil, just stop when reaching the end of the message."
7072 (setq gnus-summary-buffer (current-buffer))
7073 (gnus-set-global-variables)
7074 (let ((article (gnus-summary-article-number))
7075 (article-window (get-buffer-window gnus-article-buffer t))
7077 ;; If the buffer is empty, we have no article.
7079 (error "No article to select"))
7080 (gnus-configure-windows 'article)
7081 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7082 (if (and (eq gnus-summary-goto-unread 'never)
7083 (not (gnus-summary-last-article-p article)))
7084 (gnus-summary-next-article)
7085 (gnus-summary-next-unread-article))
7086 (if (or (null gnus-current-article)
7087 (null gnus-article-current)
7088 (/= article (cdr gnus-article-current))
7089 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7090 ;; Selected subject is different from current article's.
7091 (gnus-summary-display-article article)
7092 (when article-window
7093 (gnus-eval-in-buffer-window gnus-article-buffer
7094 (setq endp (gnus-article-next-page lines)))
7097 (gnus-message 3 "End of message"))
7099 (gnus-summary-beginning-of-article))
7101 (gnus-message 3 "End of message"))
7103 (if (and (eq gnus-summary-goto-unread 'never)
7104 (not (gnus-summary-last-article-p article)))
7105 (gnus-summary-next-article)
7106 (gnus-summary-next-unread-article))))))))
7107 (gnus-summary-recenter)
7108 (gnus-summary-position-point)))
7110 (defun gnus-summary-prev-page (&optional lines move)
7111 "Show previous page of selected article.
7112 Argument LINES specifies lines to be scrolled down.
7113 If MOVE, move to the previous unread article if point is at
7114 the beginning of the buffer."
7116 (let ((article (gnus-summary-article-number))
7117 (article-window (get-buffer-window gnus-article-buffer t))
7119 (gnus-configure-windows 'article)
7120 (if (or (null gnus-current-article)
7121 (null gnus-article-current)
7122 (/= article (cdr gnus-article-current))
7123 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7124 ;; Selected subject is different from current article's.
7125 (gnus-summary-display-article article)
7126 (gnus-summary-recenter)
7127 (when article-window
7128 (gnus-eval-in-buffer-window gnus-article-buffer
7129 (setq endp (gnus-article-prev-page lines)))
7130 (when (and move endp)
7132 (gnus-message 3 "Beginning of message"))
7134 (if (and (eq gnus-summary-goto-unread 'never)
7135 (not (gnus-summary-first-article-p article)))
7136 (gnus-summary-prev-article)
7137 (gnus-summary-prev-unread-article))))))))
7138 (gnus-summary-position-point))
7140 (defun gnus-summary-prev-page-or-article (&optional lines)
7141 "Show previous page of selected article.
7142 Argument LINES specifies lines to be scrolled down.
7143 If at the beginning of the article, go to the next article."
7145 (gnus-summary-prev-page lines t))
7147 (defun gnus-summary-scroll-up (lines)
7148 "Scroll up (or down) one line current article.
7149 Argument LINES specifies lines to be scrolled up (or down if negative)."
7151 (gnus-configure-windows 'article)
7152 (gnus-summary-show-thread)
7153 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7154 (gnus-eval-in-buffer-window gnus-article-buffer
7156 (when (gnus-article-next-page lines)
7157 (gnus-message 3 "End of message")))
7159 (gnus-article-prev-page (- lines))))))
7160 (gnus-summary-recenter)
7161 (gnus-summary-position-point))
7163 (defun gnus-summary-scroll-down (lines)
7164 "Scroll down (or up) one line current article.
7165 Argument LINES specifies lines to be scrolled down (or up if negative)."
7167 (gnus-summary-scroll-up (- lines)))
7169 (defun gnus-summary-next-same-subject ()
7170 "Select next article which has the same subject as current one."
7172 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7174 (defun gnus-summary-prev-same-subject ()
7175 "Select previous article which has the same subject as current one."
7177 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7179 (defun gnus-summary-next-unread-same-subject ()
7180 "Select next unread article which has the same subject as current one."
7182 (gnus-summary-next-article t (gnus-summary-article-subject)))
7184 (defun gnus-summary-prev-unread-same-subject ()
7185 "Select previous unread article which has the same subject as current one."
7187 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7189 (defun gnus-summary-first-unread-article ()
7190 "Select the first unread article.
7191 Return nil if there are no unread articles."
7194 (when (gnus-summary-first-subject t)
7195 (gnus-summary-show-thread)
7196 (gnus-summary-first-subject t)
7197 (gnus-summary-display-article (gnus-summary-article-number)))
7198 (gnus-summary-position-point)))
7200 (defun gnus-summary-first-unread-subject ()
7201 "Place the point on the subject line of the first unread article.
7202 Return nil if there are no unread articles."
7205 (when (gnus-summary-first-subject t)
7206 (gnus-summary-show-thread)
7207 (gnus-summary-first-subject t))
7208 (gnus-summary-position-point)))
7210 (defun gnus-summary-first-unseen-subject ()
7211 "Place the point on the subject line of the first unseen article.
7212 Return nil if there are no unseen articles."
7215 (when (gnus-summary-first-subject t t t)
7216 (gnus-summary-show-thread)
7217 (gnus-summary-first-subject t t t))
7218 (gnus-summary-position-point)))
7220 (defun gnus-summary-first-unseen-or-unread-subject ()
7221 "Place the point on the subject line of the first unseen article.
7222 Return nil if there are no unseen articles."
7225 (unless (when (gnus-summary-first-subject t t t)
7226 (gnus-summary-show-thread)
7227 (gnus-summary-first-subject t t t))
7228 (when (gnus-summary-first-subject t)
7229 (gnus-summary-show-thread)
7230 (gnus-summary-first-subject t)))
7231 (gnus-summary-position-point)))
7233 (defun gnus-summary-first-article ()
7234 "Select the first article.
7235 Return nil if there are no articles."
7238 (when (gnus-summary-first-subject)
7239 (gnus-summary-show-thread)
7240 (gnus-summary-first-subject)
7241 (gnus-summary-display-article (gnus-summary-article-number)))
7242 (gnus-summary-position-point)))
7244 (defun gnus-summary-best-unread-article (&optional arg)
7245 "Select the unread article with the highest score.
7246 If given a prefix argument, select the next unread article that has a
7247 score higher than the default score."
7249 (let ((article (if arg
7250 (gnus-summary-better-unread-subject)
7251 (gnus-summary-best-unread-subject))))
7253 (gnus-summary-goto-article article)
7254 (error "No unread articles"))))
7256 (defun gnus-summary-best-unread-subject ()
7257 "Select the unread subject with the highest score."
7259 (let ((best -1000000)
7260 (data gnus-newsgroup-data)
7263 (and (gnus-data-unread-p (car data))
7265 (gnus-summary-article-score (gnus-data-number (car data))))
7268 article (gnus-data-number (car data))))
7269 (setq data (cdr data)))
7271 (gnus-summary-goto-subject article))
7272 (gnus-summary-position-point)
7275 (defun gnus-summary-better-unread-subject ()
7276 "Select the first unread subject that has a score over the default score."
7278 (let ((data gnus-newsgroup-data)
7280 (while (and (setq article (gnus-data-number (car data)))
7281 (or (gnus-data-read-p (car data))
7282 (not (> (gnus-summary-article-score article)
7283 gnus-summary-default-score))))
7284 (setq data (cdr data)))
7286 (gnus-summary-goto-subject article))
7287 (gnus-summary-position-point)
7290 (defun gnus-summary-last-subject ()
7291 "Go to the last displayed subject line in the group."
7292 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7294 (gnus-summary-goto-subject article))))
7296 (defun gnus-summary-goto-article (article &optional all-headers force)
7297 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7298 If ALL-HEADERS is non-nil, no header lines are hidden.
7299 If FORCE, go to the article even if it isn't displayed. If FORCE
7300 is a number, it is the line the article is to be displayed on."
7304 "Article number or Message-ID: "
7305 (mapcar (lambda (number) (list (int-to-string number)))
7306 gnus-newsgroup-limit))
7310 (if (and (stringp article)
7311 (string-match "@" article))
7312 (gnus-summary-refer-article article)
7313 (when (stringp article)
7314 (setq article (string-to-number article)))
7315 (if (gnus-summary-goto-subject article force)
7316 (gnus-summary-display-article article all-headers)
7317 (gnus-message 4 "Couldn't go to article %s" article) nil))
7318 (gnus-summary-position-point)))
7320 (defun gnus-summary-goto-last-article ()
7321 "Go to the previously read article."
7324 (when gnus-last-article
7325 (gnus-summary-goto-article gnus-last-article nil t))
7326 (gnus-summary-position-point)))
7328 (defun gnus-summary-pop-article (number)
7329 "Pop one article off the history and go to the previous.
7330 NUMBER articles will be popped off."
7333 (setq gnus-newsgroup-history
7334 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7336 (gnus-summary-goto-article (car to) nil t)
7337 (error "Article history empty")))
7338 (gnus-summary-position-point))
7340 ;; Summary commands and functions for limiting the summary buffer.
7342 (defun gnus-summary-limit-to-articles (n)
7343 "Limit the summary buffer to the next N articles.
7344 If not given a prefix, use the process marked articles instead."
7347 (let ((articles (gnus-summary-work-articles n)))
7348 (setq gnus-newsgroup-processable nil)
7349 (gnus-summary-limit articles))
7350 (gnus-summary-position-point)))
7352 (defun gnus-summary-pop-limit (&optional total)
7353 "Restore the previous limit.
7354 If given a prefix, remove all limits."
7357 (setq gnus-newsgroup-limits
7358 (list (mapcar (lambda (h) (mail-header-number h))
7359 gnus-newsgroup-headers))))
7360 (unless gnus-newsgroup-limits
7361 (error "No limit to pop"))
7363 (gnus-summary-limit nil 'pop)
7364 (gnus-summary-position-point)))
7366 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7367 "Limit the summary buffer to articles that have subjects that match a regexp.
7368 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7370 (list (read-string (if current-prefix-arg
7371 "Exclude subject (regexp): "
7372 "Limit to subject (regexp): "))
7373 nil current-prefix-arg))
7375 (setq header "subject"))
7376 (when (not (equal "" subject))
7378 (let ((articles (gnus-summary-find-matching
7379 (or header "subject") subject 'all nil nil
7382 (error "Found no matches for \"%s\"" subject))
7383 (gnus-summary-limit articles))
7384 (gnus-summary-position-point))))
7386 (defun gnus-summary-limit-to-author (from &optional not-matching)
7387 "Limit the summary buffer to articles that have authors that match a regexp.
7388 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7390 (list (read-string (if current-prefix-arg
7391 "Exclude author (regexp): "
7392 "Limit to author (regexp): "))
7393 current-prefix-arg))
7394 (gnus-summary-limit-to-subject from "from" not-matching))
7396 (defun gnus-summary-limit-to-age (age &optional younger-p)
7397 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7398 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7399 articles that are younger than AGE days."
7401 (let ((younger current-prefix-arg)
7404 (while (not days-got)
7405 (setq days (if younger
7406 (read-string "Limit to articles younger than (in days, older when negative): ")
7408 "Limit to articles older than (in days, younger when negative): ")))
7409 (when (> (length days) 0)
7410 (setq days (read days)))
7416 (setq younger (not younger))
7417 (setq days (* days -1)))))
7418 (message "Please enter a number.")
7420 (list days younger)))
7422 (let ((data gnus-newsgroup-data)
7423 (cutoff (days-to-time age))
7424 articles d date is-younger)
7425 (while (setq d (pop data))
7426 (when (and (vectorp (gnus-data-header d))
7427 (setq date (mail-header-date (gnus-data-header d))))
7428 (setq is-younger (time-less-p
7429 (time-since (condition-case ()
7436 (push (gnus-data-number d) articles))))
7437 (gnus-summary-limit (nreverse articles)))
7438 (gnus-summary-position-point)))
7440 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7441 "Limit the summary buffer to articles that match an 'extra' header."
7445 (gnus-completing-read-with-default
7446 (symbol-name (car gnus-extra-headers))
7447 (if current-prefix-arg
7448 "Exclude extra header:"
7449 "Limit extra header:")
7451 (cons (symbol-name x) x))
7456 (read-string (format "%s header %s (regexp): "
7457 (if current-prefix-arg "Exclude" "Limit to")
7459 current-prefix-arg)))
7460 (when (not (equal "" regexp))
7462 (let ((articles (gnus-summary-find-matching
7463 (cons 'extra header) regexp 'all nil nil
7466 (error "Found no matches for \"%s\"" regexp))
7467 (gnus-summary-limit articles))
7468 (gnus-summary-position-point))))
7470 (defun gnus-summary-limit-to-display-predicate ()
7471 "Limit the summary buffer to the predicated in the `display' group parameter."
7473 (unless gnus-newsgroup-display
7474 (error "There is no `display' group parameter"))
7476 (dolist (number gnus-newsgroup-articles)
7477 (when (funcall gnus-newsgroup-display)
7478 (push number articles)))
7479 (gnus-summary-limit articles))
7480 (gnus-summary-position-point))
7482 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7484 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7486 (defun gnus-summary-limit-to-unread (&optional all)
7487 "Limit the summary buffer to articles that are not marked as read.
7488 If ALL is non-nil, limit strictly to unread articles."
7491 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7492 (gnus-summary-limit-to-marks
7493 ;; Concat all the marks that say that an article is read and have
7495 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7496 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7497 gnus-low-score-mark gnus-expirable-mark
7498 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7499 gnus-duplicate-mark gnus-souped-mark)
7502 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7503 (make-obsolete 'gnus-summary-delete-marked-with
7504 'gnus-summary-limit-exclude-marks)
7506 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7507 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7508 If REVERSE, limit the summary buffer to articles that are marked
7509 with MARKS. MARKS can either be a string of marks or a list of marks.
7510 Returns how many articles were removed."
7511 (interactive "sMarks: ")
7512 (gnus-summary-limit-to-marks marks t))
7514 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7515 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7516 If REVERSE (the prefix), limit the summary buffer to articles that are
7517 not marked with MARKS. MARKS can either be a string of marks or a
7519 Returns how many articles were removed."
7520 (interactive "sMarks: \nP")
7522 (let ((data gnus-newsgroup-data)
7523 (marks (if (listp marks) marks
7524 (append marks nil))) ; Transform to list.
7527 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7528 (memq (gnus-data-mark (car data)) marks))
7529 (push (gnus-data-number (car data)) articles))
7530 (setq data (cdr data)))
7531 (gnus-summary-limit articles))
7532 (gnus-summary-position-point)))
7534 (defun gnus-summary-limit-to-score (score)
7535 "Limit to articles with score at or above SCORE."
7536 (interactive "NLimit to articles with score of at least: ")
7537 (let ((data gnus-newsgroup-data)
7540 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7542 (push (gnus-data-number (car data)) articles))
7543 (setq data (cdr data)))
7545 (gnus-summary-limit articles)
7546 (gnus-summary-position-point))))
7548 (defun gnus-summary-limit-to-unseen ()
7549 "Limit to unseen articles."
7552 (gnus-summary-limit gnus-newsgroup-unseen)
7553 (gnus-summary-position-point)))
7555 (defun gnus-summary-limit-include-thread (id)
7556 "Display all the hidden articles that is in the thread with ID in it.
7557 When called interactively, ID is the Message-ID of the current
7559 (interactive (list (mail-header-id (gnus-summary-article-header))))
7560 (let ((articles (gnus-articles-in-thread
7561 (gnus-id-to-thread (gnus-root-id id)))))
7563 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7564 (gnus-summary-limit-include-matching-articles
7566 (regexp-quote (gnus-simplify-subject-re
7567 (mail-header-subject (gnus-id-to-header id)))))
7568 (gnus-summary-position-point))))
7570 (defun gnus-summary-limit-include-matching-articles (header regexp)
7571 "Display all the hidden articles that have HEADERs that match REGEXP."
7572 (interactive (list (read-string "Match on header: ")
7573 (read-string "Regexp: ")))
7574 (let ((articles (gnus-find-matching-articles header regexp)))
7576 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7577 (gnus-summary-position-point))))
7579 (defun gnus-summary-insert-dormant-articles ()
7580 "Insert all the dormat articles for this group into the current buffer."
7582 (let ((gnus-verbose (max 6 gnus-verbose)))
7583 (if (not gnus-newsgroup-dormant)
7584 (gnus-message 3 "No cached articles for this group")
7585 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7587 (defun gnus-summary-limit-include-dormant ()
7588 "Display all the hidden articles that are marked as dormant.
7589 Note that this command only works on a subset of the articles currently
7590 fetched for this group."
7592 (unless gnus-newsgroup-dormant
7593 (error "There are no dormant articles in this group"))
7595 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7596 (gnus-summary-position-point)))
7598 (defun gnus-summary-limit-exclude-dormant ()
7599 "Hide all dormant articles."
7602 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7603 (gnus-summary-position-point)))
7605 (defun gnus-summary-limit-exclude-childless-dormant ()
7606 "Hide all dormant articles that have no children."
7608 (let ((data (gnus-data-list t))
7609 articles d children)
7610 ;; Find all articles that are either not dormant or have
7612 (while (setq d (pop data))
7613 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7615 (gnus-article-children (gnus-data-number d)))
7618 (when (memq (car children) articles)
7623 (push (gnus-data-number d) articles)))
7626 (gnus-summary-limit articles)
7627 (gnus-summary-position-point))))
7629 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7630 "Mark all unread excluded articles as read.
7631 If ALL, mark even excluded ticked and dormants as read."
7633 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7634 (let ((articles (gnus-sorted-ndifference
7636 (mapcar (lambda (h) (mail-header-number h))
7637 gnus-newsgroup-headers)
7639 gnus-newsgroup-limit))
7641 (setq gnus-newsgroup-unreads
7642 (gnus-sorted-intersection gnus-newsgroup-unreads
7643 gnus-newsgroup-limit))
7645 (setq gnus-newsgroup-dormant nil
7646 gnus-newsgroup-marked nil
7647 gnus-newsgroup-reads
7649 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7650 gnus-newsgroup-reads))
7651 (while (setq article (pop articles))
7652 (unless (or (memq article gnus-newsgroup-dormant)
7653 (memq article gnus-newsgroup-marked))
7654 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7656 (defun gnus-summary-limit (articles &optional pop)
7658 ;; We pop the previous limit off the stack and use that.
7659 (setq articles (car gnus-newsgroup-limits)
7660 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7661 ;; We use the new limit, so we push the old limit on the stack.
7662 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7664 (setq gnus-newsgroup-limit articles)
7665 (let ((total (length gnus-newsgroup-data))
7666 (data (gnus-data-find-list (gnus-summary-article-number)))
7667 (gnus-summary-mark-below nil) ; Inhibit this.
7669 ;; This will do all the work of generating the new summary buffer
7670 ;; according to the new limit.
7671 (gnus-summary-prepare)
7672 ;; Hide any threads, possibly.
7673 (gnus-summary-maybe-hide-threads)
7674 ;; Try to return to the article you were at, or one in the
7677 ;; We try to find some article after the current one.
7679 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7682 (setq data (cdr data))))
7684 ;; If there is no data, that means that we were after the last
7685 ;; article. The same goes when we can't find any articles
7686 ;; after the current one.
7687 (goto-char (point-max))
7688 (gnus-summary-find-prev))
7689 (gnus-set-mode-line 'summary)
7690 ;; We return how many articles were removed from the summary
7691 ;; buffer as a result of the new limit.
7692 (- total (length gnus-newsgroup-data))))
7694 (defsubst gnus-invisible-cut-children (threads)
7697 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7702 (defsubst gnus-cut-thread (thread)
7703 "Go forwards in the thread until we find an article that we want to display."
7704 (when (or (eq gnus-fetch-old-headers 'some)
7705 (eq gnus-fetch-old-headers 'invisible)
7706 (numberp gnus-fetch-old-headers)
7707 (eq gnus-build-sparse-threads 'some)
7708 (eq gnus-build-sparse-threads 'more))
7709 ;; Deal with old-fetched headers and sparse threads.
7713 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7714 (gnus-summary-article-ancient-p
7715 (mail-header-number (car thread))))
7716 (if (or (<= (length (cdr thread)) 1)
7717 (eq gnus-fetch-old-headers 'invisible))
7718 (setq gnus-newsgroup-limit
7719 (delq (mail-header-number (car thread))
7720 gnus-newsgroup-limit)
7721 thread (cadr thread))
7722 (when (gnus-invisible-cut-children (cdr thread))
7723 (let ((th (cdr thread)))
7725 (if (memq (mail-header-number (caar th))
7726 gnus-newsgroup-limit)
7727 (setq thread (car th)
7729 (setq th (cdr th))))))))))
7732 (defun gnus-cut-threads (threads)
7733 "Cut off all uninteresting articles from the beginning of threads."
7734 (when (or (eq gnus-fetch-old-headers 'some)
7735 (eq gnus-fetch-old-headers 'invisible)
7736 (numberp gnus-fetch-old-headers)
7737 (eq gnus-build-sparse-threads 'some)
7738 (eq gnus-build-sparse-threads 'more))
7741 (setcar th (gnus-cut-thread (car th)))
7742 (setq th (cdr th)))))
7743 ;; Remove nixed out threads.
7746 (defun gnus-summary-initial-limit (&optional show-if-empty)
7747 "Figure out what the initial limit is supposed to be on group entry.
7748 This entails weeding out unwanted dormants, low-scored articles,
7749 fetch-old-headers verbiage, and so on."
7750 ;; Most groups have nothing to remove.
7751 (if (or gnus-inhibit-limiting
7752 (and (null gnus-newsgroup-dormant)
7753 (eq gnus-newsgroup-display 'gnus-not-ignore)
7754 (not (eq gnus-fetch-old-headers 'some))
7755 (not (numberp gnus-fetch-old-headers))
7756 (not (eq gnus-fetch-old-headers 'invisible))
7757 (null gnus-summary-expunge-below)
7758 (not (eq gnus-build-sparse-threads 'some))
7759 (not (eq gnus-build-sparse-threads 'more))
7760 (null gnus-thread-expunge-below)
7761 (not gnus-use-nocem)))
7763 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7764 (setq gnus-newsgroup-limit nil)
7767 (unless (car (symbol-value node))
7768 ;; These threads have no parents -- they are roots.
7769 (let ((nodes (cdr (symbol-value node)))
7772 (if (and gnus-thread-expunge-below
7773 (< (gnus-thread-total-score (car nodes))
7774 gnus-thread-expunge-below))
7775 (gnus-expunge-thread (pop nodes))
7776 (setq thread (pop nodes))
7777 (gnus-summary-limit-children thread))))))
7778 gnus-newsgroup-dependencies)
7779 ;; If this limitation resulted in an empty group, we might
7780 ;; pop the previous limit and use it instead.
7781 (when (and (not gnus-newsgroup-limit)
7783 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7784 gnus-newsgroup-limit))
7786 (defun gnus-summary-limit-children (thread)
7787 "Return 1 if this subthread is visible and 0 if it is not."
7788 ;; First we get the number of visible children to this thread. This
7789 ;; is done by recursing down the thread using this function, so this
7790 ;; will really go down to a leaf article first, before slowly
7791 ;; working its way up towards the root.
7793 (let* ((max-lisp-eval-depth 5000)
7796 (apply '+ (mapcar 'gnus-summary-limit-children
7799 (number (mail-header-number (car thread)))
7802 (not (memq number gnus-newsgroup-marked))
7804 ;; If this article is dormant and has absolutely no visible
7805 ;; children, then this article isn't visible.
7806 (and (memq number gnus-newsgroup-dormant)
7808 ;; If this is "fetch-old-headered" and there is no
7809 ;; visible children, then we don't want this article.
7810 (and (or (eq gnus-fetch-old-headers 'some)
7811 (numberp gnus-fetch-old-headers))
7812 (gnus-summary-article-ancient-p number)
7814 ;; If this is "fetch-old-headered" and `invisible', then
7815 ;; we don't want this article.
7816 (and (eq gnus-fetch-old-headers 'invisible)
7817 (gnus-summary-article-ancient-p number))
7818 ;; If this is a sparsely inserted article with no children,
7819 ;; we don't want it.
7820 (and (eq gnus-build-sparse-threads 'some)
7821 (gnus-summary-article-sparse-p number)
7823 ;; If we use expunging, and this article is really
7824 ;; low-scored, then we don't want this article.
7825 (when (and gnus-summary-expunge-below
7827 (or (cdr (assq number gnus-newsgroup-scored))
7828 gnus-summary-default-score))
7829 gnus-summary-expunge-below))
7830 ;; We increase the expunge-tally here, but that has
7831 ;; nothing to do with the limits, really.
7832 (incf gnus-newsgroup-expunged-tally)
7833 ;; We also mark as read here, if that's wanted.
7834 (when (and gnus-summary-mark-below
7835 (< score gnus-summary-mark-below))
7836 (setq gnus-newsgroup-unreads
7837 (delq number gnus-newsgroup-unreads))
7838 (if gnus-newsgroup-auto-expire
7839 (push number gnus-newsgroup-expirable)
7840 (push (cons number gnus-low-score-mark)
7841 gnus-newsgroup-reads)))
7843 ;; Do the `display' group parameter.
7844 (and gnus-newsgroup-display
7845 (not (funcall gnus-newsgroup-display)))
7846 ;; Check NoCeM things.
7847 (if (and gnus-use-nocem
7848 (gnus-nocem-unwanted-article-p
7849 (mail-header-id (car thread))))
7851 (setq gnus-newsgroup-unreads
7852 (delq number gnus-newsgroup-unreads))
7854 ;; Nope, invisible article.
7856 ;; Ok, this article is to be visible, so we add it to the limit
7858 (push number gnus-newsgroup-limit)
7861 (defun gnus-expunge-thread (thread)
7862 "Mark all articles in THREAD as read."
7863 (let* ((number (mail-header-number (car thread))))
7864 (incf gnus-newsgroup-expunged-tally)
7865 ;; We also mark as read here, if that's wanted.
7866 (setq gnus-newsgroup-unreads
7867 (delq number gnus-newsgroup-unreads))
7868 (if gnus-newsgroup-auto-expire
7869 (push number gnus-newsgroup-expirable)
7870 (push (cons number gnus-low-score-mark)
7871 gnus-newsgroup-reads)))
7872 ;; Go recursively through all subthreads.
7873 (mapcar 'gnus-expunge-thread (cdr thread)))
7875 ;; Summary article oriented commands
7877 (defun gnus-summary-refer-parent-article (n)
7878 "Refer parent article N times.
7879 If N is negative, go to ancestor -N instead.
7880 The difference between N and the number of articles fetched is returned."
7884 (when (not (natnump n))
7889 (setq header (gnus-summary-article-header))
7890 (if (and (eq (mail-header-number header)
7891 (cdr gnus-article-current))
7892 (equal gnus-newsgroup-name
7893 (car gnus-article-current)))
7894 ;; If we try to find the parent of the currently
7895 ;; displayed article, then we take a look at the actual
7896 ;; References header, since this is slightly more
7897 ;; reliable than the References field we got from the
7900 (set-buffer gnus-original-article-buffer)
7901 (nnheader-narrow-to-headers)
7902 (unless (setq ref (message-fetch-field "references"))
7903 (setq ref (message-fetch-field "in-reply-to")))
7906 ;; It's not the current article, so we take a bet on
7907 ;; the value we got from the server.
7908 (mail-header-references header)))
7910 (not (equal ref "")))
7911 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7912 (gnus-message 1 "Couldn't find parent"))
7913 (gnus-message 1 "No references in article %d"
7914 (gnus-summary-article-number))
7917 (gnus-summary-position-point)
7920 (defun gnus-summary-refer-references ()
7921 "Fetch all articles mentioned in the References header.
7922 Return the number of articles fetched."
7924 (let ((ref (mail-header-references (gnus-summary-article-header)))
7925 (current (gnus-summary-article-number))
7929 (error "No References in the current article")
7930 ;; For each Message-ID in the References header...
7931 (while (string-match "<[^>]*>" ref)
7933 ;; ... fetch that article.
7934 (gnus-summary-refer-article
7935 (prog1 (match-string 0 ref)
7936 (setq ref (substring ref (match-end 0))))))
7937 (gnus-summary-goto-subject current)
7938 (gnus-summary-position-point)
7941 (defun gnus-summary-refer-thread (&optional limit)
7942 "Fetch all articles in the current thread.
7943 If LIMIT (the numerical prefix), fetch that many old headers instead
7944 of what's specified by the `gnus-refer-thread-limit' variable."
7946 (let ((id (mail-header-id (gnus-summary-article-header)))
7947 (limit (if limit (prefix-numeric-value limit)
7948 gnus-refer-thread-limit)))
7949 ;; We want to fetch LIMIT *old* headers, but we also have to
7950 ;; re-fetch all the headers in the current buffer, because many of
7951 ;; them may be undisplayed. So we adjust LIMIT.
7952 (when (numberp limit)
7953 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7954 (unless (eq gnus-fetch-old-headers 'invisible)
7955 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7956 ;; Retrieve the headers and read them in.
7957 (if (eq (gnus-retrieve-headers
7958 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7960 (gnus-build-all-threads)
7961 (error "Can't fetch thread from backends that don't support NOV"))
7962 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7963 (gnus-summary-limit-include-thread id)))
7965 (defun gnus-summary-refer-article (message-id)
7966 "Fetch an article specified by MESSAGE-ID."
7967 (interactive "sMessage-ID: ")
7968 (when (and (stringp message-id)
7969 (not (zerop (length message-id))))
7970 ;; Construct the correct Message-ID if necessary.
7971 ;; Suggested by tale@pawl.rpi.edu.
7972 (unless (string-match "^<" message-id)
7973 (setq message-id (concat "<" message-id)))
7974 (unless (string-match ">$" message-id)
7975 (setq message-id (concat message-id ">")))
7976 (let* ((header (gnus-id-to-header message-id))
7978 (gnus-summary-article-sparse-p
7979 (mail-header-number header))
7980 (memq (mail-header-number header)
7981 gnus-newsgroup-limit)))
7984 ;; If the article is present in the buffer we just go to it.
7986 (or (not (gnus-summary-article-sparse-p
7987 (mail-header-number header)))
7990 (gnus-summary-goto-article
7991 (mail-header-number header) nil t)
7993 (gnus-summary-update-article (mail-header-number header)))))
7995 ;; We fetch the article.
7997 (dolist (gnus-override-method (gnus-refer-article-methods))
7998 (gnus-check-server gnus-override-method)
7999 ;; Fetch the header, and display the article.
8000 (when (setq number (gnus-summary-insert-subject message-id))
8001 (gnus-summary-select-article nil nil nil number)
8003 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8005 (defun gnus-refer-article-methods ()
8006 "Return a list of referable methods."
8008 ;; No method, so we default to current and native.
8009 ((null gnus-refer-article-method)
8010 (list gnus-current-select-method gnus-select-method))
8012 ((eq 'current gnus-refer-article-method)
8013 (list gnus-current-select-method))
8014 ;; List of select methods.
8015 ((not (and (symbolp (car gnus-refer-article-method))
8016 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8018 (dolist (method gnus-refer-article-method)
8019 (push (if (eq 'current method)
8020 gnus-current-select-method
8024 ;; One single select method.
8026 (list gnus-refer-article-method))))
8028 (defun gnus-summary-edit-parameters ()
8029 "Edit the group parameters of the current group."
8031 (gnus-group-edit-group gnus-newsgroup-name 'params))
8033 (defun gnus-summary-customize-parameters ()
8034 "Customize the group parameters of the current group."
8036 (gnus-group-customize gnus-newsgroup-name))
8038 (defun gnus-summary-enter-digest-group (&optional force)
8039 "Enter an nndoc group based on the current article.
8040 If FORCE, force a digest interpretation. If not, try
8041 to guess what the document format is."
8043 (let ((conf gnus-current-window-configuration))
8045 (gnus-summary-select-article))
8046 (setq gnus-current-window-configuration conf)
8047 (let* ((name (format "%s-%d"
8048 (gnus-group-prefixed-name
8049 gnus-newsgroup-name (list 'nndoc ""))
8051 (set-buffer gnus-summary-buffer)
8052 gnus-current-article)))
8053 (ogroup gnus-newsgroup-name)
8054 (params (append (gnus-info-params (gnus-get-info ogroup))
8055 (list (cons 'to-group ogroup))
8056 (list (cons 'save-article-group ogroup))))
8057 (case-fold-search t)
8058 (buf (current-buffer))
8061 (set-buffer gnus-original-article-buffer)
8062 ;; Have the digest group inherit the main mail address of
8063 ;; the parent article.
8064 (when (setq to-address (or (gnus-fetch-field "reply-to")
8065 (gnus-fetch-field "from")))
8066 (setq params (append
8067 (list (cons 'to-address
8068 (funcall gnus-decode-encoded-word-function
8070 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8071 (insert-buffer-substring gnus-original-article-buffer)
8072 ;; Remove lines that may lead nndoc to misinterpret the
8075 (goto-char (point-min))
8076 (or (search-forward "\n\n" nil t) (point)))
8077 (goto-char (point-min))
8078 (delete-matching-lines "^Path:\\|^From ")
8081 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8082 (gnus-newsgroup-ephemeral-ignored-charsets
8083 gnus-newsgroup-ignored-charsets))
8084 (gnus-group-read-ephemeral-group
8085 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8087 ,(if force 'mbox 'guess)))
8089 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8091 ;; Make all postings to this group go to the parent group.
8092 (nconc (gnus-info-params (gnus-get-info name))
8094 ;; Couldn't select this doc group.
8095 (switch-to-buffer buf)
8096 (gnus-set-global-variables)
8097 (gnus-configure-windows 'summary)
8098 (gnus-message 3 "Article couldn't be entered?"))
8099 (kill-buffer dig)))))
8101 (defun gnus-summary-read-document (n)
8102 "Open a new group based on the current article(s).
8103 This will allow you to read digests and other similar
8104 documents as newsgroups.
8105 Obeys the standard process/prefix convention."
8107 (let* ((articles (gnus-summary-work-articles n))
8108 (ogroup gnus-newsgroup-name)
8109 (params (append (gnus-info-params (gnus-get-info ogroup))
8110 (list (cons 'to-group ogroup))))
8111 article group egroup groups vgroup)
8112 (while (setq article (pop articles))
8113 (setq group (format "%s-%d" gnus-newsgroup-name article))
8114 (gnus-summary-remove-process-mark article)
8115 (when (gnus-summary-display-article article)
8118 (insert-buffer-substring gnus-original-article-buffer)
8119 ;; Remove some headers that may lead nndoc to make
8121 (message-narrow-to-head)
8122 (goto-char (point-min))
8123 (delete-matching-lines "^\\(Path\\):\\|^From ")
8126 (gnus-group-read-ephemeral-group
8127 group `(nndoc ,group (nndoc-address ,(current-buffer))
8128 (nndoc-article-type guess))
8131 ;; Make all postings to this group go to the parent group.
8132 (nconc (gnus-info-params (gnus-get-info egroup))
8134 (push egroup groups))
8135 ;; Couldn't select this doc group.
8136 (gnus-error 3 "Article couldn't be entered"))))))
8137 ;; Now we have selected all the documents.
8140 (error "None of the articles could be interpreted as documents"))
8141 ((gnus-group-read-ephemeral-group
8142 (setq vgroup (format
8143 "nnvirtual:%s-%s" gnus-newsgroup-name
8144 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8145 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8147 (cons (current-buffer) 'summary)))
8149 (error "Couldn't select virtual nndoc group")))))
8151 (defun gnus-summary-isearch-article (&optional regexp-p)
8152 "Do incremental search forward on the current article.
8153 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8155 (let* ((gnus-inhibit-treatment t)
8156 (old (gnus-summary-select-article)))
8157 (gnus-configure-windows 'article)
8158 (gnus-eval-in-buffer-window gnus-article-buffer
8162 (gnus-article-show-all-headers))
8163 (goto-char (point-min))
8164 (isearch-forward regexp-p)))))
8166 (defun gnus-summary-search-article-forward (regexp &optional backward)
8167 "Search for an article containing REGEXP forward.
8168 If BACKWARD, search backward instead."
8171 (format "Search article %s (regexp%s): "
8172 (if current-prefix-arg "backward" "forward")
8173 (if gnus-last-search-regexp
8174 (concat ", default " gnus-last-search-regexp)
8176 current-prefix-arg))
8177 (if (string-equal regexp "")
8178 (setq regexp (or gnus-last-search-regexp ""))
8179 (setq gnus-last-search-regexp regexp)
8180 (setq gnus-article-before-search gnus-current-article))
8181 ;; Intentionally set gnus-last-article.
8182 (setq gnus-last-article gnus-article-before-search)
8183 (let ((gnus-last-article gnus-last-article))
8184 (if (gnus-summary-search-article regexp backward)
8185 (gnus-summary-show-thread)
8186 (error "Search failed: \"%s\"" regexp))))
8188 (defun gnus-summary-search-article-backward (regexp)
8189 "Search for an article containing REGEXP backward."
8192 (format "Search article backward (regexp%s): "
8193 (if gnus-last-search-regexp
8194 (concat ", default " gnus-last-search-regexp)
8196 (gnus-summary-search-article-forward regexp 'backward))
8199 (defmacro gnus-summary-search-article-position-point (regexp backward)
8200 "Dehighlight the last matched text and goto the beginning position."
8201 (` (if (and gnus-summary-search-article-matched-data
8202 (let ((text (caddr gnus-summary-search-article-matched-data))
8203 (inhibit-read-only t)
8206 (goto-char (car gnus-summary-search-article-matched-data))
8207 (cadr gnus-summary-search-article-matched-data))
8209 (string-match (, regexp) text)))
8210 (if (, backward) (beginning-of-line) (end-of-line))
8211 (goto-char (if (, backward) (point-max) (point-min))))))
8213 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8214 "Place point where X-Face image is displayed."
8215 (if (featurep 'xemacs)
8216 (` (let ((end (if (search-forward "\n\n" nil t)
8217 (goto-char (1- (point)))
8220 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8221 (unless (and (re-search-forward "^From:" end t)
8222 (setq extent (extent-at (point)))
8223 (extent-begin-glyph extent))
8224 (goto-char (, opoint)))))
8225 (` (let ((end (if (search-forward "\n\n" nil t)
8226 (goto-char (1- (point)))
8228 (start (or (search-backward "\n\n" nil t) (point-min))))
8230 (or (text-property-any start end 'x-face-image t);; x-face-e21
8231 (text-property-any start end 'x-face-mule-bitmap-image t)
8234 (defmacro gnus-summary-search-article-highlight-matched-text
8235 (backward treated x-face)
8236 "Highlight matched text in the function `gnus-summary-search-article'."
8237 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8238 (end (set-marker (make-marker) (match-end 0)))
8239 (inhibit-read-only t)
8243 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8245 (lambda (item) (setq items (delq item items)))
8246 '(gnus-treat-buttonize
8247 gnus-treat-fill-article
8248 gnus-treat-fill-long-lines
8249 gnus-treat-emphasize
8250 gnus-treat-highlight-headers
8251 gnus-treat-highlight-citation
8252 gnus-treat-highlight-signature
8253 gnus-treat-overstrike
8254 gnus-treat-display-xface
8255 gnus-treat-buttonize-head
8256 gnus-treat-decode-article-as-default-mime-charset))
8257 (static-if (featurep 'xemacs)
8259 (cons '(x-face-mule-delete-x-face-field
8262 (gnus-treat-display-xface
8263 (when (, x-face) gnus-treat-display-xface)))
8264 (gnus-article-prepare-mime-display)))
8265 (goto-char (if (, backward) start end))
8267 (gnus-summary-search-article-highlight-goto-x-face (point)))
8268 (setq gnus-summary-search-article-matched-data
8269 (list start end (buffer-substring start end)))
8270 (unless (eq start end);; matched text has been deleted. :-<
8271 (put-text-property start end 'face
8272 (or (find-face 'isearch)
8273 'secondary-selection))))))
8276 (defun gnus-summary-search-article (regexp &optional backward)
8277 "Search for an article containing REGEXP.
8278 Optional argument BACKWARD means do search for backward.
8279 `gnus-select-article-hook' is not called during the search."
8280 ;; We have to require this here to make sure that the following
8281 ;; dynamic binding isn't shadowed by autoloading.
8282 (require 'gnus-async)
8284 (let ((gnus-select-article-hook nil) ;Disable hook.
8285 (gnus-article-prepare-hook nil)
8286 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8287 (gnus-use-article-prefetch nil)
8288 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8289 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8290 (sum (current-buffer))
8293 (gnus-save-hidden-threads
8294 (static-if (featurep 'xemacs)
8295 (let ((gnus-inhibit-treatment t))
8296 (setq treated (eq 'old (gnus-summary-select-article)))
8298 (not (and (gnus-buffer-live-p gnus-article-buffer)
8299 (window-live-p (get-buffer-window
8300 gnus-article-buffer t)))))
8301 (gnus-summary-select-article nil t)
8302 (setq treated nil)))
8303 (let ((gnus-inhibit-treatment t)
8304 (x-face-mule-delete-x-face-field 'never))
8305 (setq treated (eq 'old (gnus-summary-select-article)))
8308 (and (gnus-buffer-live-p gnus-article-buffer)
8309 (window-live-p (get-buffer-window
8310 gnus-article-buffer t))
8311 (or (not (string-match "^\\^X-Face:" regexp))
8312 (with-current-buffer gnus-article-buffer
8313 gnus-summary-search-article-matched-data)))))
8314 (gnus-summary-select-article nil t)
8315 (setq treated nil))))
8316 (set-buffer gnus-article-buffer)
8320 (gnus-article-show-all-headers)
8321 (gnus-summary-search-article-position-point regexp backward))
8322 (goto-char (if backward (point-max) (point-min))))
8324 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8326 (re-search-backward regexp nil t)
8327 (re-search-forward regexp nil t))
8328 ;; We found the regexp.
8330 (gnus-summary-search-article-highlight-matched-text
8331 backward treated (string-match "^\\^X-Face:" regexp))
8334 (/ (- 2 (window-height
8335 (get-buffer-window gnus-article-buffer t)))
8338 (get-buffer-window (current-buffer))
8341 (setq point (point)))
8342 ;; We didn't find it, so we go to the next article.
8345 (while (eq found 'not)
8346 (if (not (if backward (gnus-summary-find-prev)
8347 (gnus-summary-find-next)))
8348 ;; No more articles.
8350 ;; Select the next article and adjust point.
8351 (unless (gnus-summary-article-sparse-p
8352 (gnus-summary-article-number))
8354 (let ((gnus-inhibit-treatment t))
8355 (gnus-summary-select-article))
8357 (set-buffer gnus-article-buffer)
8359 (goto-char (if backward (point-max) (point-min))))))))
8360 (gnus-message 7 ""))
8361 ;; Return whether we found the regexp.
8362 (when (eq found 'found)
8364 (gnus-summary-show-thread)
8365 (gnus-summary-goto-subject gnus-current-article)
8366 (gnus-summary-position-point)
8369 (defun gnus-find-matching-articles (header regexp)
8370 "Return a list of all articles that match REGEXP on HEADER.
8371 This search includes all articles in the current group that Gnus has
8372 fetched headers for, whether they are displayed or not."
8373 (let ((articles nil)
8374 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8375 (case-fold-search t))
8376 (dolist (header gnus-newsgroup-headers)
8377 (when (string-match regexp (funcall func header))
8378 (push (mail-header-number header) articles)))
8379 (nreverse articles)))
8381 (defun gnus-summary-find-matching (header regexp &optional backward unread
8382 not-case-fold not-matching)
8383 "Return a list of all articles that match REGEXP on HEADER.
8384 The search stars on the current article and goes forwards unless
8385 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8386 If UNREAD is non-nil, only unread articles will
8387 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8388 in the comparisons. If NOT-MATCHING, return a list of all articles that
8389 not match REGEXP on HEADER."
8390 (let ((case-fold-search (not not-case-fold))
8393 (if (eq (car header) 'extra)
8396 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8398 (error "%s is an invalid header" header))
8399 (unless (fboundp (intern (concat "mail-header-" header)))
8400 (error "%s is not a valid header" header))
8401 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8402 (dolist (d (if (eq backward 'all)
8404 (gnus-data-find-list
8405 (gnus-summary-article-number)
8406 (gnus-data-list backward))))
8407 (when (and (or (not unread) ; We want all articles...
8408 (gnus-data-unread-p d)) ; Or just unreads.
8409 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8413 (funcall func (gnus-data-header d))))
8414 (string-match regexp
8415 (funcall func (gnus-data-header d)))))
8416 (push (gnus-data-number d) articles))) ; Success!
8417 (nreverse articles)))
8419 (defun gnus-summary-execute-command (header regexp command &optional backward)
8420 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8421 If HEADER is an empty string (or nil), the match is done on the entire
8422 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8424 (list (let ((completion-ignore-case t))
8427 (mapcar (lambda (header) (list (format "%s" header)))
8429 '("Number" "Subject" "From" "Lines" "Date"
8430 "Message-ID" "Xref" "References" "Body")
8431 gnus-extra-headers))
8432 nil 'require-match))
8433 (read-string "Regexp: ")
8434 (read-key-sequence "Command: ")
8435 current-prefix-arg))
8436 (when (equal header "Body")
8438 ;; Hidden thread subtrees must be searched as well.
8439 (gnus-summary-show-all-threads)
8440 ;; We don't want to change current point nor window configuration.
8442 (save-window-excursion
8444 gnus-treat-strip-trailing-blank-lines
8445 gnus-treat-strip-leading-blank-lines
8446 gnus-treat-strip-multiple-blank-lines
8447 gnus-treat-hide-boring-headers
8448 gnus-treat-fold-newsgroups
8449 gnus-article-prepare-hook)
8450 (gnus-message 6 "Executing %s..." (key-description command))
8451 ;; We'd like to execute COMMAND interactively so as to give arguments.
8452 (gnus-execute header regexp
8453 `(call-interactively ',(key-binding command))
8455 (gnus-message 6 "Executing %s...done" (key-description command))))))
8457 (defun gnus-summary-beginning-of-article ()
8458 "Scroll the article back to the beginning."
8460 (gnus-summary-select-article)
8461 (gnus-configure-windows 'article)
8462 (gnus-eval-in-buffer-window gnus-article-buffer
8464 (goto-char (point-min))
8465 (when gnus-page-broken
8466 (gnus-narrow-to-page))))
8468 (defun gnus-summary-end-of-article ()
8469 "Scroll to the end of the article."
8471 (gnus-summary-select-article)
8472 (gnus-configure-windows 'article)
8473 (gnus-eval-in-buffer-window gnus-article-buffer
8475 (goto-char (point-max))
8477 (when gnus-page-broken
8478 (gnus-narrow-to-page))))
8480 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8481 "Truncate to LEN and quote all \"(\"'s in STRING."
8482 (gnus-replace-in-string (if (and len (> (length string) len))
8483 (substring string 0 len)
8487 (defun gnus-summary-print-article (&optional filename n)
8488 "Generate and print a PostScript image of the N next (mail) articles.
8490 If N is negative, print the N previous articles. If N is nil and articles
8491 have been marked with the process mark, print these instead.
8493 If the optional first argument FILENAME is nil, send the image to the
8494 printer. If FILENAME is a string, save the PostScript image in a file with
8495 that name. If FILENAME is a number, prompt the user for the name of the file
8497 (interactive (list (ps-print-preprint current-prefix-arg)))
8498 (dolist (article (gnus-summary-work-articles n))
8499 (gnus-summary-select-article nil nil 'pseudo article)
8500 (gnus-eval-in-buffer-window gnus-article-buffer
8501 (gnus-print-buffer))
8502 (gnus-summary-remove-process-mark article))
8503 (ps-despool filename))
8505 (defun gnus-print-buffer ()
8506 (let ((buffer (generate-new-buffer " *print*")))
8509 (copy-to-buffer buffer (point-min) (point-max))
8511 (gnus-article-delete-invisible-text)
8512 (gnus-remove-text-with-property 'gnus-decoration)
8513 (when (gnus-visual-p 'article-highlight 'highlight)
8514 ;; Copy-to-buffer doesn't copy overlay. So redo
8516 (let ((gnus-article-buffer buffer))
8517 (gnus-article-highlight-citation t)
8518 (gnus-article-highlight-signature)))
8519 (let ((ps-left-header
8522 (gnus-summary-print-truncate-and-quote
8523 (mail-header-subject gnus-current-headers)
8526 (gnus-summary-print-truncate-and-quote
8527 (mail-header-from gnus-current-headers)
8531 "/pagenumberstring load"
8533 (mail-header-date gnus-current-headers) ")"))))
8534 (gnus-run-hooks 'gnus-ps-print-hook)
8537 (ps-spool-buffer-with-faces)
8538 (ps-spool-buffer)))))
8539 (kill-buffer buffer))))
8541 (defun gnus-summary-show-article (&optional arg)
8542 "Force redisplaying of the current article.
8543 If ARG (the prefix) is a number, show the article with the charset
8544 defined in `gnus-summary-show-article-charset-alist', or the charset
8546 If ARG (the prefix) is non-nil and not a number, show the raw article
8547 without any article massaging functions being run. Normally, the key strokes
8552 (gnus-summary-show-article t)
8553 (let* ((gnus-newsgroup-charset
8554 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8555 (mm-read-coding-system
8556 "View as charset: " ;; actually it is coding system.
8558 (set-buffer gnus-article-buffer)
8559 (mm-detect-coding-region (point) (point-max))))))
8560 (default-mime-charset gnus-newsgroup-charset)
8561 (gnus-newsgroup-ignored-charsets 'gnus-all))
8562 (gnus-summary-select-article nil 'force)
8563 (let ((deps gnus-newsgroup-dependencies)
8566 (set-buffer gnus-original-article-buffer)
8568 (message-narrow-to-head)
8569 (setq head (buffer-string))
8570 (goto-char (point-min))
8571 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8572 (goto-char (point-max))
8574 (setq lines (1- (count-lines (point) (point-max))))))
8576 (insert (format "211 %d Article retrieved.\n"
8577 (cdr gnus-article-current)))
8579 (if lines (insert (format "Lines: %d\n" lines)))
8581 (let ((nntp-server-buffer (current-buffer)))
8582 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8583 (gnus-data-set-header
8584 (gnus-data-find (cdr gnus-article-current))
8586 (gnus-summary-update-article-line
8587 (cdr gnus-article-current) header)
8588 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8589 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8591 ;; Select the article the normal way.
8592 (gnus-summary-select-article nil 'force))
8594 ;; We have to require this here to make sure that the following
8595 ;; dynamic binding isn't shadowed by autoloading.
8596 (require 'gnus-async)
8598 ;; Bind the article treatment functions to nil.
8599 (let ((gnus-have-all-headers t)
8600 gnus-article-prepare-hook
8601 gnus-article-decode-hook
8604 (gnus-inhibit-treatment t))
8605 (gnus-summary-select-article nil 'force))))
8606 (gnus-summary-goto-subject gnus-current-article)
8607 (gnus-summary-position-point))
8609 (defun gnus-summary-show-raw-article ()
8610 "Show the raw article without any article massaging functions being run."
8612 (gnus-summary-show-article t))
8614 (defun gnus-summary-verbose-headers (&optional arg)
8615 "Toggle permanent full header display.
8616 If ARG is a positive number, turn header display on.
8617 If ARG is a negative number, turn header display off."
8619 (setq gnus-show-all-headers
8620 (cond ((or (not (numberp arg))
8622 (not gnus-show-all-headers))
8625 (gnus-summary-show-article))
8627 (defun gnus-summary-toggle-header (&optional arg)
8628 "Show the headers if they are hidden, or hide them if they are shown.
8629 If ARG is a positive number, show the entire header.
8630 If ARG is a negative number, hide the unwanted header lines."
8632 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8633 (get-buffer-window gnus-article-buffer t))))
8634 (with-current-buffer gnus-article-buffer
8636 (article-narrow-to-head)
8637 (let* ((buffer-read-only nil)
8638 (inhibit-point-motion-hooks t)
8639 (hidden (if (numberp arg)
8641 (gnus-article-hidden-text-p 'headers)))
8643 (delete-region (point-min) (point-max))
8644 (with-current-buffer gnus-original-article-buffer
8645 (goto-char (setq s (point-min)))
8646 (setq e (if (search-forward "\n\n" nil t)
8649 (insert-buffer-substring gnus-original-article-buffer s e)
8650 (article-decode-encoded-words)
8652 (let ((gnus-treat-hide-headers nil)
8653 (gnus-treat-hide-boring-headers nil))
8654 (gnus-delete-wash-type 'headers)
8655 (gnus-treat-article 'head))
8656 (gnus-treat-article 'head))
8659 (set-window-start window (goto-char (point-min))))
8660 (setq gnus-page-broken
8661 (when gnus-break-pages
8662 (gnus-narrow-to-page)
8664 (gnus-set-mode-line 'article)))))
8666 (defun gnus-summary-show-all-headers ()
8667 "Make all header lines visible."
8669 (gnus-summary-toggle-header 1))
8671 (defun gnus-summary-toggle-mime (&optional arg)
8672 "Toggle MIME processing.
8673 If ARG is a positive number, turn MIME processing on."
8675 (setq gnus-show-mime
8677 (not gnus-show-mime)
8678 (> (prefix-numeric-value arg) 0)))
8679 (gnus-summary-select-article t 'force))
8681 (defun gnus-summary-caesar-message (&optional arg)
8682 "Caesar rotate the current article by 13.
8683 The numerical prefix specifies how many places to rotate each letter
8686 (gnus-summary-select-article)
8687 (let ((mail-header-separator ""))
8688 (gnus-eval-in-buffer-window gnus-article-buffer
8691 (let ((start (window-start))
8693 (message-caesar-buffer-body arg)
8694 (set-window-start (get-buffer-window (current-buffer)) start))))))
8696 (autoload 'unmorse-region "morse"
8697 "Convert morse coded text in region to ordinary ASCII text."
8700 (defun gnus-summary-morse-message (&optional arg)
8701 "Morse decode the current article."
8703 (gnus-summary-select-article)
8704 (let ((mail-header-separator ""))
8705 (gnus-eval-in-buffer-window gnus-article-buffer
8709 (let ((pos (window-start))
8711 (goto-char (point-min))
8712 (when (message-goto-body)
8713 (gnus-narrow-to-body))
8714 (goto-char (point-min))
8715 (while (re-search-forward "·" (point-max) t)
8716 (replace-match "."))
8717 (unmorse-region (point-min) (point-max))
8719 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8721 (defun gnus-summary-stop-page-breaking ()
8722 "Stop page breaking in the current article."
8724 (gnus-summary-select-article)
8725 (gnus-eval-in-buffer-window gnus-article-buffer
8727 (when (gnus-visual-p 'page-marker)
8728 (let ((buffer-read-only nil))
8729 (gnus-remove-text-with-property 'gnus-prev)
8730 (gnus-remove-text-with-property 'gnus-next))
8731 (setq gnus-page-broken nil))))
8733 (defun gnus-summary-move-article (&optional n to-newsgroup
8734 select-method action)
8735 "Move the current article to a different newsgroup.
8736 If N is a positive number, move the N next articles.
8737 If N is a negative number, move the N previous articles.
8738 If N is nil and any articles have been marked with the process mark,
8739 move those articles instead.
8740 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8741 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8742 re-spool using this method.
8744 When called interactively with TO-NEWSGROUP being nil, the value of
8745 the variable `gnus-move-split-methods' is used for finding a default
8746 for the target newsgroup.
8748 For this function to work, both the current newsgroup and the
8749 newsgroup that you want to move to have to support the `request-move'
8750 and `request-accept' functions.
8752 ACTION can be either `move' (the default), `crosspost' or `copy'."
8755 (setq action 'move))
8756 ;; Check whether the source group supports the required functions.
8757 (cond ((and (eq action 'move)
8758 (not (gnus-check-backend-function
8759 'request-move-article gnus-newsgroup-name)))
8760 (error "The current group does not support article moving"))
8761 ((and (eq action 'crosspost)
8762 (not (gnus-check-backend-function
8763 'request-replace-article gnus-newsgroup-name)))
8764 (error "The current group does not support article editing")))
8765 (let ((articles (gnus-summary-work-articles n))
8766 (prefix (if (gnus-check-backend-function
8767 'request-move-article gnus-newsgroup-name)
8768 (gnus-group-real-prefix gnus-newsgroup-name)
8770 (names '((move "Move" "Moving")
8771 (copy "Copy" "Copying")
8772 (crosspost "Crosspost" "Crossposting")))
8773 (copy-buf (save-excursion
8774 (nnheader-set-temp-buffer " *copy article*")))
8775 (default-marks gnus-article-mark-lists)
8776 (no-expire-marks (delete '(expirable . expire)
8777 (copy-sequence gnus-article-mark-lists)))
8778 art-group to-method new-xref article to-groups)
8779 (unless (assq action names)
8780 (error "Unknown action %s" action))
8781 ;; Read the newsgroup name.
8782 (when (and (not to-newsgroup)
8783 (not select-method))
8784 (if (and gnus-move-split-methods
8786 (and (memq gnus-current-article articles)
8787 (gnus-buffer-live-p gnus-original-article-buffer))))
8788 ;; When `gnus-move-split-methods' is non-nil, we have to
8789 ;; select an article to give `gnus-read-move-group-name' an
8790 ;; opportunity to suggest an appropriate default. However,
8791 ;; we needn't render or mark the article.
8792 (let ((gnus-display-mime-function nil)
8793 (gnus-article-prepare-hook nil)
8794 (gnus-mark-article-hook nil))
8795 (gnus-summary-select-article nil nil nil (car articles))))
8797 (gnus-read-move-group-name
8798 (cadr (assq action names))
8799 (symbol-value (intern (format "gnus-current-%s-group" action)))
8801 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8802 (setq to-method (or select-method
8803 (gnus-server-to-method
8804 (gnus-group-method to-newsgroup))))
8805 ;; Check the method we are to move this article to...
8806 (unless (gnus-check-backend-function
8807 'request-accept-article (car to-method))
8808 (error "%s does not support article copying" (car to-method)))
8809 (unless (gnus-check-server to-method)
8810 (error "Can't open server %s" (car to-method)))
8811 (gnus-message 6 "%s to %s: %s..."
8812 (caddr (assq action names))
8813 (or (car select-method) to-newsgroup) articles)
8815 (setq article (pop articles))
8819 ;; Move the article.
8821 ;; Remove this article from future suppression.
8822 (gnus-dup-unsuppress-article article)
8823 (gnus-request-move-article
8824 article ; Article to move
8825 gnus-newsgroup-name ; From newsgroup
8826 (nth 1 (gnus-find-method-for-group
8827 gnus-newsgroup-name)) ; Server
8828 (list 'gnus-request-accept-article
8829 to-newsgroup (list 'quote select-method)
8830 (not articles) t) ; Accept form
8831 (not articles))) ; Only save nov last time
8832 ;; Copy the article.
8835 (set-buffer copy-buf)
8836 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8837 (gnus-request-accept-article
8838 to-newsgroup select-method (not articles) t))))
8839 ;; Crosspost the article.
8840 ((eq action 'crosspost)
8841 (let ((xref (message-tokenize-header
8842 (mail-header-xref (gnus-summary-article-header article))
8844 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8845 ":" (number-to-string article)))
8847 (setq xref (list (system-name))))
8850 (mapconcat 'identity
8851 (delete "Xref:" (delete new-xref xref))
8855 (set-buffer copy-buf)
8856 ;; First put the article in the destination group.
8857 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8858 (when (consp (setq art-group
8859 (gnus-request-accept-article
8860 to-newsgroup select-method (not articles))))
8861 (setq new-xref (concat new-xref " " (car art-group)
8863 (number-to-string (cdr art-group))))
8864 ;; Now we have the new Xrefs header, so we insert
8865 ;; it and replace the new article.
8866 (nnheader-replace-header "Xref" new-xref)
8867 (gnus-request-replace-article
8868 (cdr art-group) to-newsgroup (current-buffer))
8872 (gnus-message 1 "Couldn't %s article %s: %s"
8873 (cadr (assq action names)) article
8874 (nnheader-get-report (car to-method))))
8875 ((eq art-group 'junk)
8876 (when (eq action 'move)
8877 (gnus-summary-mark-article article gnus-canceled-mark)
8878 (gnus-message 4 "Deleted article %s" article)))
8880 (let* ((pto-group (gnus-group-prefixed-name
8881 (car art-group) to-method))
8883 (gnus-gethash pto-group gnus-newsrc-hashtb))
8884 (info (nth 2 entry))
8885 (to-group (gnus-info-group info))
8887 ;; Update the group that has been moved to.
8889 (memq action '(move copy)))
8890 (unless (member to-group to-groups)
8891 (push to-group to-groups))
8893 (unless (memq article gnus-newsgroup-unreads)
8894 (push 'read to-marks)
8896 info (gnus-add-to-range (gnus-info-read info)
8897 (list (cdr art-group)))))
8899 ;; See whether the article is to be put in the cache.
8900 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8903 (to-article (cdr art-group)))
8905 ;; Enter the article into the cache in the new group,
8906 ;; if that is required.
8907 (when gnus-use-cache
8908 (gnus-cache-possibly-enter-article
8910 (let ((header (copy-sequence
8911 (gnus-summary-article-header article))))
8912 (mail-header-set-number header to-article)
8914 (memq article gnus-newsgroup-marked)
8915 (memq article gnus-newsgroup-dormant)
8916 (memq article gnus-newsgroup-unreads)))
8918 (when gnus-preserve-marks
8919 ;; Copy any marks over to the new group.
8920 (when (and (equal to-group gnus-newsgroup-name)
8921 (not (memq article gnus-newsgroup-unreads)))
8922 ;; Mark this article as read in this group.
8923 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8924 (setcdr (gnus-active to-group) to-article)
8925 (setcdr gnus-newsgroup-active to-article))
8928 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8929 (when (memq article (symbol-value
8930 (intern (format "gnus-newsgroup-%s"
8932 (push (cdar marks) to-marks)
8933 ;; If the other group is the same as this group,
8934 ;; then we have to add the mark to the list.
8935 (when (equal to-group gnus-newsgroup-name)
8936 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8939 (intern (format "gnus-newsgroup-%s"
8941 ;; Copy the marks to other group.
8942 (gnus-add-marked-articles
8943 to-group (cdar marks) (list to-article) info)))
8944 (setq marks (cdr marks)))
8946 (gnus-request-set-mark
8947 to-group (list (list (list to-article) 'add to-marks))))
8950 (concat "(gnus-group-set-info '"
8951 (gnus-prin1-to-string (gnus-get-info to-group))
8954 ;; Update the Xref header in this article to point to
8955 ;; the new crossposted article we have just created.
8956 (when (eq action 'crosspost)
8958 (set-buffer copy-buf)
8959 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8960 (nnheader-replace-header "Xref" new-xref)
8961 (gnus-request-replace-article
8962 article gnus-newsgroup-name (current-buffer)))))
8964 ;;;!!!Why is this necessary?
8965 (set-buffer gnus-summary-buffer)
8967 (gnus-summary-goto-subject article)
8968 (when (eq action 'move)
8969 (gnus-summary-mark-article article gnus-canceled-mark))))
8970 (gnus-summary-remove-process-mark article))
8971 ;; Re-activate all groups that have been moved to.
8973 (set-buffer gnus-group-buffer)
8974 (let ((gnus-group-marked to-groups))
8975 (gnus-group-get-new-news-this-group nil t)))
8977 (gnus-kill-buffer copy-buf)
8978 (gnus-summary-position-point)
8979 (gnus-set-mode-line 'summary)))
8981 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8982 "Move the current article to a different newsgroup.
8983 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8984 When called interactively, if TO-NEWSGROUP is nil, use the value of
8985 the variable `gnus-move-split-methods' for finding a default target
8987 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8988 re-spool using this method."
8990 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8992 (defun gnus-summary-crosspost-article (&optional n)
8993 "Crosspost the current article to some other group."
8995 (gnus-summary-move-article n nil nil 'crosspost))
8997 (defcustom gnus-summary-respool-default-method nil
8998 "Default method type for respooling an article.
8999 If nil, use to the current newsgroup method."
9001 :group 'gnus-summary-mail)
9003 (defcustom gnus-summary-display-while-building nil
9004 "If not-nil, show and update the summary buffer as it's being built.
9005 If the value is t, update the buffer after every line is inserted. If
9006 the value is an integer (N), update the display every N lines."
9008 :type '(choice (const :tag "off" nil)
9010 (const :tag "frequently" t)))
9012 (defun gnus-summary-respool-article (&optional n method)
9013 "Respool the current article.
9014 The article will be squeezed through the mail spooling process again,
9015 which means that it will be put in some mail newsgroup or other
9016 depending on `nnmail-split-methods'.
9017 If N is a positive number, respool the N next articles.
9018 If N is a negative number, respool the N previous articles.
9019 If N is nil and any articles have been marked with the process mark,
9020 respool those articles instead.
9022 Respooling can be done both from mail groups and \"real\" newsgroups.
9023 In the former case, the articles in question will be moved from the
9024 current group into whatever groups they are destined to. In the
9025 latter case, they will be copied into the relevant groups."
9027 (list current-prefix-arg
9028 (let* ((methods (gnus-methods-using 'respool))
9030 (symbol-name (or gnus-summary-respool-default-method
9031 (car (gnus-find-method-for-group
9032 gnus-newsgroup-name)))))
9034 (gnus-completing-read-with-default
9035 methname "What backend do you want to use when respooling?"
9036 methods nil t nil 'gnus-mail-method-history))
9039 ((zerop (length (setq ms (gnus-servers-using-backend
9041 (list (intern method) ""))
9045 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9046 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9049 (error "No method given for respooling"))
9050 (if (assoc (symbol-name
9051 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9052 (gnus-methods-using 'respool))
9053 (gnus-summary-move-article n nil method)
9054 (gnus-summary-copy-article n nil method)))
9056 (defun gnus-summary-import-article (file &optional edit)
9057 "Import an arbitrary file into a mail newsgroup."
9058 (interactive "fImport file: \nP")
9059 (let ((group gnus-newsgroup-name)
9060 (now (current-time))
9061 atts lines group-art)
9062 (unless (gnus-check-backend-function 'request-accept-article group)
9063 (error "%s does not support article importing" group))
9064 (or (file-readable-p file)
9065 (not (file-regular-p file))
9066 (error "Can't read %s" file))
9068 (set-buffer (gnus-get-buffer-create " *import file*"))
9070 (nnheader-insert-file-contents file)
9071 (goto-char (point-min))
9072 (if (nnheader-article-p)
9074 (goto-char (point-min))
9075 (search-forward "\n\n" nil t)
9076 (narrow-to-region (point-min) (1- (point)))
9077 (goto-char (point-min))
9078 (unless (re-search-forward "^date:" nil t)
9079 (goto-char (point-max))
9080 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9081 ;; This doesn't look like an article, so we fudge some headers.
9082 (setq atts (file-attributes file)
9083 lines (count-lines (point-min) (point-max)))
9084 (insert "From: " (read-string "From: ") "\n"
9085 "Subject: " (read-string "Subject: ") "\n"
9086 "Date: " (message-make-date (nth 5 atts)) "\n"
9087 "Message-ID: " (message-make-message-id) "\n"
9088 "Lines: " (int-to-string lines) "\n"
9089 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9090 (setq group-art (gnus-request-accept-article group nil t))
9091 (kill-buffer (current-buffer)))
9092 (setq gnus-newsgroup-active (gnus-activate-group group))
9094 (gnus-summary-goto-article (cdr group-art) nil t)
9096 (gnus-summary-edit-article))))
9098 (defun gnus-summary-create-article ()
9099 "Create an article in a mail newsgroup."
9101 (let ((group gnus-newsgroup-name)
9102 (now (current-time))
9104 (unless (gnus-check-backend-function 'request-accept-article group)
9105 (error "%s does not support article importing" group))
9107 (set-buffer (gnus-get-buffer-create " *import file*"))
9109 (goto-char (point-min))
9110 ;; This doesn't look like an article, so we fudge some headers.
9111 (insert "From: " (read-string "From: ") "\n"
9112 "Subject: " (read-string "Subject: ") "\n"
9113 "Date: " (message-make-date now) "\n"
9114 "Message-ID: " (message-make-message-id) "\n")
9115 (setq group-art (gnus-request-accept-article group nil t))
9116 (kill-buffer (current-buffer)))
9117 (setq gnus-newsgroup-active (gnus-activate-group group))
9119 (gnus-summary-goto-article (cdr group-art) nil t)
9120 (gnus-summary-edit-article)))
9122 (defun gnus-summary-article-posted-p ()
9123 "Say whether the current (mail) article is available from news as well.
9124 This will be the case if the article has both been mailed and posted."
9126 (let ((id (mail-header-references (gnus-summary-article-header)))
9127 (gnus-override-method (car (gnus-refer-article-methods))))
9128 (if (gnus-request-head id "")
9129 (gnus-message 2 "The current message was found on %s"
9130 gnus-override-method)
9131 (gnus-message 2 "The current message couldn't be found on %s"
9132 gnus-override-method)
9135 (defun gnus-summary-expire-articles (&optional now)
9136 "Expire all articles that are marked as expirable in the current group."
9138 (when (gnus-check-backend-function
9139 'request-expire-articles gnus-newsgroup-name)
9140 ;; This backend supports expiry.
9141 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9142 (expirable (if total
9144 ;; We need to update the info for
9145 ;; this group for `gnus-list-of-read-articles'
9146 ;; to give us the right answer.
9147 (gnus-run-hooks 'gnus-exit-group-hook)
9148 (gnus-summary-update-info)
9149 (gnus-list-of-read-articles gnus-newsgroup-name))
9150 (setq gnus-newsgroup-expirable
9151 (sort gnus-newsgroup-expirable '<))))
9152 (expiry-wait (if now 'immediate
9153 (gnus-group-find-parameter
9154 gnus-newsgroup-name 'expiry-wait)))
9155 (nnmail-expiry-target
9156 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9157 nnmail-expiry-target))
9160 ;; There are expirable articles in this group, so we run them
9161 ;; through the expiry process.
9162 (gnus-message 6 "Expiring articles...")
9163 (unless (gnus-check-group gnus-newsgroup-name)
9164 (error "Can't open server for %s" gnus-newsgroup-name))
9165 ;; The list of articles that weren't expired is returned.
9168 (let ((nnmail-expiry-wait-function nil)
9169 (nnmail-expiry-wait expiry-wait))
9170 (setq es (gnus-request-expire-articles
9171 expirable gnus-newsgroup-name)))
9172 (setq es (gnus-request-expire-articles
9173 expirable gnus-newsgroup-name)))
9175 (setq gnus-newsgroup-expirable es))
9176 ;; We go through the old list of expirable, and mark all
9177 ;; really expired articles as nonexistent.
9178 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9179 (let ((gnus-use-cache nil))
9180 (dolist (article expirable)
9181 (when (and (not (memq article es))
9182 (gnus-data-find article))
9183 (gnus-summary-mark-article article gnus-canceled-mark))))))
9184 (gnus-message 6 "Expiring articles...done")))))
9186 (defun gnus-summary-expire-articles-now ()
9187 "Expunge all expirable articles in the current group.
9188 This means that *all* articles that are marked as expirable will be
9189 deleted forever, right now."
9191 (or gnus-expert-user
9193 "Are you really, really, really sure you want to delete all these messages? ")
9195 (gnus-summary-expire-articles t))
9197 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9198 (defun gnus-summary-delete-article (&optional n)
9199 "Delete the N next (mail) articles.
9200 This command actually deletes articles. This is not a marking
9201 command. The article will disappear forever from your life, never to
9203 If N is negative, delete backwards.
9204 If N is nil and articles have been marked with the process mark,
9205 delete these instead."
9207 (unless (gnus-check-backend-function 'request-expire-articles
9208 gnus-newsgroup-name)
9209 (error "The current newsgroup does not support article deletion"))
9210 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9211 (error "Couldn't open server"))
9212 ;; Compute the list of articles to delete.
9213 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9214 (nnmail-expiry-target 'delete)
9216 (if (and gnus-novice-user
9217 (not (gnus-yes-or-no-p
9218 (format "Do you really want to delete %s forever? "
9219 (if (> (length articles) 1)
9220 (format "these %s articles" (length articles))
9223 ;; Delete the articles.
9224 (setq not-deleted (gnus-request-expire-articles
9225 articles gnus-newsgroup-name 'force))
9227 (gnus-summary-remove-process-mark (car articles))
9228 ;; The backend might not have been able to delete the article
9230 (unless (memq (car articles) not-deleted)
9231 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9232 (setq articles (cdr articles)))
9234 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9235 (gnus-summary-position-point)
9236 (gnus-set-mode-line 'summary)
9239 (defun gnus-summary-edit-article (&optional force)
9240 "Edit the current article.
9241 This will have permanent effect only in mail groups.
9242 If FORCE is non-nil, allow editing of articles even in read-only
9246 (set-buffer gnus-summary-buffer)
9247 (let ((mail-parse-charset gnus-newsgroup-charset)
9248 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9249 (gnus-set-global-variables)
9250 (when (and (not force)
9251 (gnus-group-read-only-p))
9252 (error "The current newsgroup does not support article editing"))
9253 (gnus-summary-show-article t)
9254 (gnus-article-edit-article
9256 `(lambda (no-highlight)
9257 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9258 (message-options message-options)
9259 (message-options-set-recipient)
9260 (mail-parse-ignored-charsets
9261 ',gnus-newsgroup-ignored-charsets))
9262 (gnus-summary-edit-article-done
9263 ,(or (mail-header-references gnus-current-headers) "")
9264 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9266 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9268 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9270 "Make edits to the current article permanent."
9273 ;; The buffer restriction contains the entire article if it exists.
9274 (when (article-goto-body)
9275 (let ((lines (count-lines (point) (point-max)))
9276 (length (- (point-max) (point)))
9277 (case-fold-search t)
9278 (body (copy-marker (point))))
9279 (goto-char (point-min))
9280 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9281 (delete-region (match-beginning 1) (match-end 1))
9282 (insert (number-to-string length)))
9283 (goto-char (point-min))
9284 (when (re-search-forward
9285 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9286 (delete-region (match-beginning 1) (match-end 1))
9287 (insert (number-to-string length)))
9288 (goto-char (point-min))
9289 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9290 (delete-region (match-beginning 1) (match-end 1))
9291 (insert (number-to-string lines))))))
9292 ;; Replace the article.
9293 (let ((buf (current-buffer)))
9295 (insert-buffer-substring buf)
9297 (if (and (not read-only)
9298 (not (gnus-request-replace-article
9299 (cdr gnus-article-current) (car gnus-article-current)
9300 (current-buffer) t)))
9301 (error "Couldn't replace article")
9302 ;; Update the summary buffer.
9304 (equal (message-tokenize-header references " ")
9305 (message-tokenize-header
9306 (or (message-fetch-field "references") "") " ")))
9307 ;; We only have to update this line.
9310 (message-narrow-to-head)
9311 (let ((head (buffer-string))
9314 (insert (format "211 %d Article retrieved.\n"
9315 (cdr gnus-article-current)))
9318 (let ((nntp-server-buffer (current-buffer)))
9319 (setq header (car (gnus-get-newsgroup-headers
9322 (set-buffer gnus-summary-buffer)
9323 (gnus-data-set-header
9324 (gnus-data-find (cdr gnus-article-current))
9326 (gnus-summary-update-article-line
9327 (cdr gnus-article-current) header)
9328 (if (gnus-summary-goto-subject
9329 (cdr gnus-article-current) nil t)
9330 (gnus-summary-update-secondary-mark
9331 (cdr gnus-article-current))))))))
9333 (set-buffer (or buffer gnus-summary-buffer))
9334 (gnus-summary-update-article (cdr gnus-article-current))
9335 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9336 (gnus-summary-update-secondary-mark
9337 (cdr gnus-article-current))))
9338 ;; Prettify the article buffer again.
9339 (unless no-highlight
9341 (set-buffer gnus-article-buffer)
9342 ;;;!!! Fix this -- article should be rehighlighted.
9343 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9344 (set-buffer gnus-original-article-buffer)
9345 (gnus-request-article
9346 (cdr gnus-article-current)
9347 (car gnus-article-current) (current-buffer))))
9348 ;; Prettify the summary buffer line.
9349 (when (gnus-visual-p 'summary-highlight 'highlight)
9350 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9352 (defun gnus-summary-edit-wash (key)
9353 "Perform editing command KEY in the article buffer."
9357 (message "%s" (concat (this-command-keys) "- "))
9360 (gnus-summary-edit-article)
9361 (execute-kbd-macro (concat (this-command-keys) key))
9362 (gnus-article-edit-done))
9366 (defun gnus-summary-respool-query (&optional silent trace)
9367 "Query where the respool algorithm would put this article."
9369 (let (gnus-mark-article-hook)
9370 (gnus-summary-select-article)
9372 (set-buffer gnus-original-article-buffer)
9374 (message-narrow-to-head)
9375 (let ((groups (nnmail-article-group 'identity trace)))
9378 (message "This message would go to %s"
9379 (mapconcat 'car groups ", "))
9380 (message "This message would go to no groups"))
9383 (defun gnus-summary-respool-trace ()
9384 "Trace where the respool algorithm would put this article.
9385 Display a buffer showing all fancy splitting patterns which matched."
9387 (gnus-summary-respool-query nil t))
9389 ;; Summary marking commands.
9391 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9392 "Mark articles which has the same subject as read, and then select the next.
9393 If UNMARK is positive, remove any kind of mark.
9394 If UNMARK is negative, tick articles."
9397 (setq unmark (prefix-numeric-value unmark)))
9399 (gnus-summary-mark-same-subject
9400 (gnus-summary-article-subject) unmark)))
9401 ;; Select next unread article. If auto-select-same mode, should
9402 ;; select the first unread article.
9403 (gnus-summary-next-article t (and gnus-auto-select-same
9404 (gnus-summary-article-subject)))
9405 (gnus-message 7 "%d article%s marked as %s"
9406 count (if (= count 1) " is" "s are")
9407 (if unmark "unread" "read"))))
9409 (defun gnus-summary-kill-same-subject (&optional unmark)
9410 "Mark articles which has the same subject as read.
9411 If UNMARK is positive, remove any kind of mark.
9412 If UNMARK is negative, tick articles."
9415 (setq unmark (prefix-numeric-value unmark)))
9417 (gnus-summary-mark-same-subject
9418 (gnus-summary-article-subject) unmark)))
9419 ;; If marked as read, go to next unread subject.
9421 ;; Go to next unread subject.
9422 (gnus-summary-next-subject 1 t))
9423 (gnus-message 7 "%d articles are marked as %s"
9424 count (if unmark "unread" "read"))))
9426 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9427 "Mark articles with same SUBJECT as read, and return marked number.
9428 If optional argument UNMARK is positive, remove any kinds of marks.
9429 If optional argument UNMARK is negative, mark articles as unread instead."
9433 ((null unmark) ; Mark as read.
9436 (gnus-summary-mark-article-as-read gnus-killed-mark)
9437 (gnus-summary-show-thread) t)
9438 (gnus-summary-find-subject subject))
9439 (setq count (1+ count))))
9440 ((> unmark 0) ; Tick.
9443 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9444 (gnus-summary-show-thread) t)
9445 (gnus-summary-find-subject subject))
9446 (setq count (1+ count))))
9447 (t ; Mark as unread.
9450 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9451 (gnus-summary-show-thread) t)
9452 (gnus-summary-find-subject subject))
9453 (setq count (1+ count)))))
9454 (gnus-set-mode-line 'summary)
9455 ;; Return the number of marked articles.
9458 (defun gnus-summary-mark-as-processable (n &optional unmark)
9459 "Set the process mark on the next N articles.
9460 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9461 the process mark instead. The difference between N and the actual
9462 number of articles marked is returned."
9464 (if (and (null n) (gnus-region-active-p))
9465 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9466 (setq n (prefix-numeric-value n))
9467 (let ((backward (< n 0))
9472 (gnus-summary-remove-process-mark
9473 (gnus-summary-article-number))
9474 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9475 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9478 (gnus-message 7 "No more articles"))
9479 (gnus-summary-recenter)
9480 (gnus-summary-position-point)
9483 (defun gnus-summary-unmark-as-processable (n)
9484 "Remove the process mark from the next N articles.
9485 If N is negative, unmark backward instead. The difference between N and
9486 the actual number of articles unmarked is returned."
9488 (gnus-summary-mark-as-processable n t))
9490 (defun gnus-summary-unmark-all-processable ()
9491 "Remove the process mark from all articles."
9494 (while gnus-newsgroup-processable
9495 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9496 (gnus-summary-position-point))
9498 (defun gnus-summary-add-mark (article type)
9499 "Mark ARTICLE with a mark of TYPE."
9500 (let ((vtype (car (assq type gnus-article-mark-lists)))
9503 (error "No such mark type: %s" type)
9504 (setq var (intern (format "gnus-newsgroup-%s" type)))
9505 (set var (cons article (symbol-value var)))
9506 (if (memq type '(processable cached replied forwarded recent saved))
9507 (gnus-summary-update-secondary-mark article)
9508 ;;; !!! This is bogus. We should find out what primary
9509 ;;; !!! mark we want to set.
9510 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9512 (defun gnus-summary-mark-as-expirable (n)
9513 "Mark N articles forward as expirable.
9514 If N is negative, mark backward instead. The difference between N and
9515 the actual number of articles marked is returned."
9517 (gnus-summary-mark-forward n gnus-expirable-mark))
9519 (defun gnus-summary-mark-as-spam (n)
9520 "Mark N articles forward as spam.
9521 If N is negative, mark backward instead. The difference between N and
9522 the actual number of articles marked is returned."
9524 (gnus-summary-mark-forward n gnus-spam-mark))
9526 (defun gnus-summary-mark-article-as-replied (article)
9527 "Mark ARTICLE as replied to and update the summary line.
9528 ARTICLE can also be a list of articles."
9529 (interactive (list (gnus-summary-article-number)))
9530 (let ((articles (if (listp article) article (list article))))
9531 (dolist (article articles)
9532 (push article gnus-newsgroup-replied)
9533 (let ((buffer-read-only nil))
9534 (when (gnus-summary-goto-subject article nil t)
9535 (gnus-summary-update-secondary-mark article))))))
9537 (defun gnus-summary-mark-article-as-forwarded (article)
9538 "Mark ARTICLE as forwarded and update the summary line.
9539 ARTICLE can also be a list of articles."
9540 (let ((articles (if (listp article) article (list article))))
9541 (dolist (article articles)
9542 (push article gnus-newsgroup-forwarded)
9543 (let ((buffer-read-only nil))
9544 (when (gnus-summary-goto-subject article nil t)
9545 (gnus-summary-update-secondary-mark article))))))
9547 (defun gnus-summary-set-bookmark (article)
9548 "Set a bookmark in current article."
9549 (interactive (list (gnus-summary-article-number)))
9550 (when (or (not (get-buffer gnus-article-buffer))
9551 (not gnus-current-article)
9552 (not gnus-article-current)
9553 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9554 (error "No current article selected"))
9555 ;; Remove old bookmark, if one exists.
9556 (gnus-pull article gnus-newsgroup-bookmarks)
9557 ;; Set the new bookmark, which is on the form
9558 ;; (article-number . line-number-in-body).
9562 (set-buffer gnus-article-buffer)
9569 gnus-newsgroup-bookmarks)
9570 (gnus-message 6 "A bookmark has been added to the current article."))
9572 (defun gnus-summary-remove-bookmark (article)
9573 "Remove the bookmark from the current article."
9574 (interactive (list (gnus-summary-article-number)))
9575 ;; Remove old bookmark, if one exists.
9576 (if (not (assq article gnus-newsgroup-bookmarks))
9577 (gnus-message 6 "No bookmark in current article.")
9578 (gnus-pull article gnus-newsgroup-bookmarks)
9579 (gnus-message 6 "Removed bookmark.")))
9581 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9582 (defun gnus-summary-mark-as-dormant (n)
9583 "Mark N articles forward as dormant.
9584 If N is negative, mark backward instead. The difference between N and
9585 the actual number of articles marked is returned."
9587 (gnus-summary-mark-forward n gnus-dormant-mark))
9589 (defun gnus-summary-set-process-mark (article)
9590 "Set the process mark on ARTICLE and update the summary line."
9591 (setq gnus-newsgroup-processable
9593 (delq article gnus-newsgroup-processable)))
9594 (when (gnus-summary-goto-subject article)
9595 (gnus-summary-show-thread)
9596 (gnus-summary-goto-subject article)
9597 (gnus-summary-update-secondary-mark article)))
9599 (defun gnus-summary-remove-process-mark (article)
9600 "Remove the process mark from ARTICLE and update the summary line."
9601 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9602 (when (gnus-summary-goto-subject article)
9603 (gnus-summary-show-thread)
9604 (gnus-summary-goto-subject article)
9605 (gnus-summary-update-secondary-mark article)))
9607 (defun gnus-summary-set-saved-mark (article)
9608 "Set the process mark on ARTICLE and update the summary line."
9609 (push article gnus-newsgroup-saved)
9610 (when (gnus-summary-goto-subject article)
9611 (gnus-summary-update-secondary-mark article)))
9613 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9614 "Mark N articles as read forwards.
9615 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9616 The difference between N and the actual number of articles marked is
9618 If NO-EXPIRE, auto-expiry will be inhibited."
9620 (gnus-summary-show-thread)
9621 (let ((backward (< n 0))
9622 (gnus-summary-goto-unread
9623 (and gnus-summary-goto-unread
9624 (not (eq gnus-summary-goto-unread 'never))
9625 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9626 gnus-ticked-mark gnus-dormant-mark)))))
9628 (mark (or mark gnus-del-mark)))
9630 (gnus-summary-mark-article nil mark no-expire)
9631 (zerop (gnus-summary-next-subject
9633 (and gnus-summary-goto-unread
9634 (not (eq gnus-summary-goto-unread 'never)))
9638 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9639 (gnus-summary-recenter)
9640 (gnus-summary-position-point)
9641 (gnus-set-mode-line 'summary)
9644 (defun gnus-summary-mark-article-as-read (mark)
9645 "Mark the current article quickly as read with MARK."
9646 (let ((article (gnus-summary-article-number)))
9647 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9648 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9649 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9650 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9651 (push (cons article mark) gnus-newsgroup-reads)
9652 ;; Possibly remove from cache, if that is used.
9653 (when gnus-use-cache
9654 (gnus-cache-enter-remove-article article))
9655 ;; Allow the backend to change the mark.
9656 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9657 ;; Check for auto-expiry.
9658 (when (and gnus-newsgroup-auto-expire
9659 (memq mark gnus-auto-expirable-marks))
9660 (setq mark gnus-expirable-mark)
9661 ;; Let the backend know about the mark change.
9662 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9663 (push article gnus-newsgroup-expirable))
9664 ;; Set the mark in the buffer.
9665 (gnus-summary-update-mark mark 'unread)
9668 (defun gnus-summary-mark-article-as-unread (mark)
9669 "Mark the current article quickly as unread with MARK."
9670 (let* ((article (gnus-summary-article-number))
9671 (old-mark (gnus-summary-article-mark article)))
9672 ;; Allow the backend to change the mark.
9673 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9674 (if (eq mark old-mark)
9678 (gnus-error 1 "Can't mark negative article numbers")
9680 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9681 (setq gnus-newsgroup-spam-marked
9682 (delq article gnus-newsgroup-spam-marked))
9683 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9684 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9685 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9686 (cond ((= mark gnus-ticked-mark)
9687 (setq gnus-newsgroup-marked
9688 (gnus-add-to-sorted-list gnus-newsgroup-marked
9690 ((= mark gnus-spam-mark)
9691 (setq gnus-newsgroup-spam-marked
9692 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9694 ((= mark gnus-dormant-mark)
9695 (setq gnus-newsgroup-dormant
9696 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9699 (setq gnus-newsgroup-unreads
9700 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9702 (gnus-pull article gnus-newsgroup-reads)
9704 ;; See whether the article is to be put in the cache.
9706 (vectorp (gnus-summary-article-header article))
9708 (gnus-cache-possibly-enter-article
9709 gnus-newsgroup-name article
9710 (gnus-summary-article-header article)
9711 (= mark gnus-ticked-mark)
9712 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9715 (gnus-summary-update-mark mark 'unread)
9718 (defun gnus-summary-mark-article (&optional article mark no-expire)
9719 "Mark ARTICLE with MARK. MARK can be any character.
9720 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9721 `??' (dormant) and `?E' (expirable).
9722 If MARK is nil, then the default character `?r' is used.
9723 If ARTICLE is nil, then the article on the current line will be
9725 If NO-EXPIRE, auto-expiry will be inhibited."
9726 ;; The mark might be a string.
9727 (when (stringp mark)
9728 (setq mark (aref mark 0)))
9729 ;; If no mark is given, then we check auto-expiring.
9731 (setq mark gnus-del-mark))
9732 (when (and (not no-expire)
9733 gnus-newsgroup-auto-expire
9734 (memq mark gnus-auto-expirable-marks))
9735 (setq mark gnus-expirable-mark))
9736 (let ((article (or article (gnus-summary-article-number)))
9737 (old-mark (gnus-summary-article-mark article)))
9738 ;; Allow the backend to change the mark.
9739 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9740 (if (eq mark old-mark)
9743 (error "No article on current line"))
9744 (if (not (if (or (= mark gnus-unread-mark)
9745 (= mark gnus-ticked-mark)
9746 (= mark gnus-spam-mark)
9747 (= mark gnus-dormant-mark))
9748 (gnus-mark-article-as-unread article mark)
9749 (gnus-mark-article-as-read article mark)))
9751 ;; See whether the article is to be put in the cache.
9753 (not (= mark gnus-canceled-mark))
9754 (vectorp (gnus-summary-article-header article))
9756 (gnus-cache-possibly-enter-article
9757 gnus-newsgroup-name article
9758 (gnus-summary-article-header article)
9759 (= mark gnus-ticked-mark)
9760 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9762 (when (gnus-summary-goto-subject article nil t)
9763 (let ((buffer-read-only nil))
9764 (gnus-summary-show-thread)
9766 (gnus-summary-update-mark mark 'unread)
9769 (defun gnus-summary-update-secondary-mark (article)
9770 "Update the secondary (read, process, cache) mark."
9771 (gnus-summary-update-mark
9772 (cond ((memq article gnus-newsgroup-processable)
9774 ((memq article gnus-newsgroup-cached)
9776 ((memq article gnus-newsgroup-replied)
9778 ((memq article gnus-newsgroup-forwarded)
9779 gnus-forwarded-mark)
9780 ((memq article gnus-newsgroup-saved)
9782 ((memq article gnus-newsgroup-recent)
9784 ((memq article gnus-newsgroup-unseen)
9788 (when (gnus-visual-p 'summary-highlight 'highlight)
9789 (gnus-run-hooks 'gnus-summary-update-hook))
9792 (defun gnus-summary-update-download-mark (article)
9793 "Update the secondary (read, process, cache) mark."
9794 (gnus-summary-update-mark
9795 (cond ((memq article gnus-newsgroup-undownloaded)
9796 gnus-undownloaded-mark)
9797 (gnus-newsgroup-agentized
9798 gnus-downloaded-mark)
9802 (gnus-summary-update-line t)
9805 (defun gnus-summary-update-mark (mark type)
9806 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9807 (buffer-read-only nil))
9808 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9810 (when (looking-at "\r")
9812 (when (<= (+ forward (point)) (point-max))
9813 ;; Go to the right position on the line.
9814 (goto-char (+ forward (point)))
9815 ;; Replace the old mark with the new mark.
9816 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9817 ;; Optionally update the marks by some user rule.
9818 (when (eq type 'unread)
9820 (gnus-data-find (gnus-summary-article-number)) mark)
9821 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9823 (defun gnus-mark-article-as-read (article &optional mark)
9824 "Enter ARTICLE in the pertinent lists and remove it from others."
9825 ;; Make the article expirable.
9826 (let ((mark (or mark gnus-del-mark)))
9827 (setq gnus-newsgroup-expirable
9828 (if (= mark gnus-expirable-mark)
9829 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9830 (delq article gnus-newsgroup-expirable)))
9831 ;; Remove from unread and marked lists.
9832 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9833 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9834 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9835 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9836 (push (cons article mark) gnus-newsgroup-reads)
9837 ;; Possibly remove from cache, if that is used.
9838 (when gnus-use-cache
9839 (gnus-cache-enter-remove-article article))
9842 (defun gnus-mark-article-as-unread (article &optional mark)
9843 "Enter ARTICLE in the pertinent lists and remove it from others."
9844 (let ((mark (or mark gnus-ticked-mark)))
9847 (gnus-error 1 "Can't mark negative article numbers")
9849 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9850 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9851 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9852 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9853 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9855 ;; Unsuppress duplicates?
9856 (when gnus-suppress-duplicates
9857 (gnus-dup-unsuppress-article article))
9859 (cond ((= mark gnus-ticked-mark)
9860 (setq gnus-newsgroup-marked
9861 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9862 ((= mark gnus-spam-mark)
9863 (setq gnus-newsgroup-spam-marked
9864 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9866 ((= mark gnus-dormant-mark)
9867 (setq gnus-newsgroup-dormant
9868 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9870 (setq gnus-newsgroup-unreads
9871 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9872 (gnus-pull article gnus-newsgroup-reads)
9875 (defalias 'gnus-summary-mark-as-unread-forward
9876 'gnus-summary-tick-article-forward)
9877 (make-obsolete 'gnus-summary-mark-as-unread-forward
9878 'gnus-summary-tick-article-forward)
9879 (defun gnus-summary-tick-article-forward (n)
9880 "Tick N articles forwards.
9881 If N is negative, tick backwards instead.
9882 The difference between N and the number of articles ticked is returned."
9884 (gnus-summary-mark-forward n gnus-ticked-mark))
9886 (defalias 'gnus-summary-mark-as-unread-backward
9887 'gnus-summary-tick-article-backward)
9888 (make-obsolete 'gnus-summary-mark-as-unread-backward
9889 'gnus-summary-tick-article-backward)
9890 (defun gnus-summary-tick-article-backward (n)
9891 "Tick N articles backwards.
9892 The difference between N and the number of articles ticked is returned."
9894 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9896 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9897 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9898 (defun gnus-summary-tick-article (&optional article clear-mark)
9899 "Mark current article as unread.
9900 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9901 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9903 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9906 (defun gnus-summary-mark-as-read-forward (n)
9907 "Mark N articles as read forwards.
9908 If N is negative, mark backwards instead.
9909 The difference between N and the actual number of articles marked is
9912 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9914 (defun gnus-summary-mark-as-read-backward (n)
9915 "Mark the N articles as read backwards.
9916 The difference between N and the actual number of articles marked is
9919 (gnus-summary-mark-forward
9920 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9922 (defun gnus-summary-mark-as-read (&optional article mark)
9923 "Mark current article as read.
9924 ARTICLE specifies the article to be marked as read.
9925 MARK specifies a string to be inserted at the beginning of the line."
9926 (gnus-summary-mark-article article mark))
9928 (defun gnus-summary-clear-mark-forward (n)
9929 "Clear marks from N articles forward.
9930 If N is negative, clear backward instead.
9931 The difference between N and the number of marks cleared is returned."
9933 (gnus-summary-mark-forward n gnus-unread-mark))
9935 (defun gnus-summary-clear-mark-backward (n)
9936 "Clear marks from N articles backward.
9937 The difference between N and the number of marks cleared is returned."
9939 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9941 (defun gnus-summary-mark-unread-as-read ()
9942 "Intended to be used by `gnus-summary-mark-article-hook'."
9943 (when (memq gnus-current-article gnus-newsgroup-unreads)
9944 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9946 (defun gnus-summary-mark-read-and-unread-as-read ()
9947 "Intended to be used by `gnus-summary-mark-article-hook'."
9948 (let ((mark (gnus-summary-article-mark)))
9949 (when (or (gnus-unread-mark-p mark)
9950 (gnus-read-mark-p mark))
9951 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9953 (defun gnus-summary-mark-unread-as-ticked ()
9954 "Intended to be used by `gnus-summary-mark-article-hook'."
9955 (when (memq gnus-current-article gnus-newsgroup-unreads)
9956 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9958 (defun gnus-summary-mark-region-as-read (point mark all)
9959 "Mark all unread articles between point and mark as read.
9960 If given a prefix, mark all articles between point and mark as read,
9961 even ticked and dormant ones."
9962 (interactive "r\nP")
9971 (memq (setq article (gnus-summary-article-number))
9972 gnus-newsgroup-unreads))
9973 (gnus-summary-mark-article article gnus-del-mark))
9975 (gnus-summary-find-next))))))
9977 (defun gnus-summary-mark-below (score mark)
9978 "Mark articles with score less than SCORE with MARK."
9979 (interactive "P\ncMark: ")
9980 (setq score (if score
9981 (prefix-numeric-value score)
9982 (or gnus-summary-default-score 0)))
9984 (set-buffer gnus-summary-buffer)
9985 (goto-char (point-min))
9988 (and (< (gnus-summary-article-score) score)
9989 (gnus-summary-mark-article nil mark))
9990 (gnus-summary-find-next)))))
9992 (defun gnus-summary-kill-below (&optional score)
9993 "Mark articles with score below SCORE as read."
9995 (gnus-summary-mark-below score gnus-killed-mark))
9997 (defun gnus-summary-clear-above (&optional score)
9998 "Clear all marks from articles with score above SCORE."
10000 (gnus-summary-mark-above score gnus-unread-mark))
10002 (defun gnus-summary-tick-above (&optional score)
10003 "Tick all articles with score above SCORE."
10005 (gnus-summary-mark-above score gnus-ticked-mark))
10007 (defun gnus-summary-mark-above (score mark)
10008 "Mark articles with score over SCORE with MARK."
10009 (interactive "P\ncMark: ")
10010 (setq score (if score
10011 (prefix-numeric-value score)
10012 (or gnus-summary-default-score 0)))
10014 (set-buffer gnus-summary-buffer)
10015 (goto-char (point-min))
10017 (when (> (gnus-summary-article-score) score)
10018 (gnus-summary-mark-article nil mark))
10020 (gnus-summary-find-next)))))
10022 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10023 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10024 (defun gnus-summary-limit-include-expunged (&optional no-error)
10025 "Display all the hidden articles that were expunged for low scores."
10027 (let ((buffer-read-only nil))
10028 (let ((scored gnus-newsgroup-scored)
10031 (unless (gnus-summary-article-header (caar scored))
10032 (and (setq h (gnus-number-to-header (caar scored)))
10033 (< (cdar scored) gnus-summary-expunge-below)
10035 (setq scored (cdr scored)))
10037 (when (not no-error)
10038 (error "No expunged articles hidden"))
10039 (goto-char (point-min))
10040 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10041 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10042 (mapcar (lambda (x) (push (mail-header-number x)
10043 gnus-newsgroup-limit))
10045 (gnus-summary-prepare-unthreaded (nreverse headers))
10046 (goto-char (point-min))
10047 (gnus-summary-position-point)
10050 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10051 "Mark all unread articles in this newsgroup as read.
10052 If prefix argument ALL is non-nil, ticked and dormant articles will
10053 also be marked as read.
10054 If QUIETLY is non-nil, no questions will be asked.
10055 If TO-HERE is non-nil, it should be a point in the buffer. All
10056 articles before (after, if REVERSE is set) this point will be marked as read.
10057 Note that this function will only catch up the unread article
10058 in the current summary buffer limitation.
10059 The number of articles marked as read is returned."
10064 (not gnus-interactive-catchup) ;Without confirmation?
10068 "Mark absolutely all articles as read? "
10069 "Mark all unread articles as read? ")))
10071 (not gnus-newsgroup-adaptive)
10072 (not gnus-newsgroup-auto-expire)
10073 (not gnus-suppress-duplicates)
10074 (or (not gnus-use-cache)
10075 (eq gnus-use-cache 'passive)))
10078 (setq gnus-newsgroup-marked nil
10079 gnus-newsgroup-spam-marked nil
10080 gnus-newsgroup-dormant nil))
10081 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
10082 ;; We actually mark all articles as canceled, which we
10083 ;; have to do when using auto-expiry or adaptive scoring.
10084 (gnus-summary-show-all-threads)
10085 (if (and to-here reverse)
10087 (goto-char to-here)
10089 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10090 (gnus-summary-find-next (not all) nil nil t))))
10091 (when (gnus-summary-first-subject (not all) t)
10093 (if to-here (< (point) to-here) t)
10094 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10095 (gnus-summary-find-next (not all) nil nil t)))))
10096 (gnus-set-mode-line 'summary))
10098 (gnus-summary-position-point)))
10100 (defun gnus-summary-catchup-to-here (&optional all)
10101 "Mark all unticked articles before the current one as read.
10102 If ALL is non-nil, also mark ticked and dormant articles as read."
10105 (gnus-save-hidden-threads
10106 (let ((beg (point)))
10107 ;; We check that there are unread articles.
10108 (when (or all (gnus-summary-find-prev))
10109 (gnus-summary-catchup all t beg)))))
10110 (gnus-summary-position-point))
10112 (defun gnus-summary-catchup-from-here (&optional all)
10113 "Mark all unticked articles after the current one as read.
10114 If ALL is non-nil, also mark ticked and dormant articles as read."
10117 (gnus-save-hidden-threads
10118 (let ((beg (point)))
10119 ;; We check that there are unread articles.
10120 (when (or all (gnus-summary-find-next))
10121 (gnus-summary-catchup all t beg nil t)))))
10122 (gnus-summary-position-point))
10124 (defun gnus-summary-catchup-all (&optional quietly)
10125 "Mark all articles in this newsgroup as read.
10126 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10127 instead, which marks only unread articles as read."
10129 (gnus-summary-catchup t quietly))
10131 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10132 "Mark all unread articles in this group as read, then exit.
10133 If prefix argument ALL is non-nil, all articles are marked as read.
10134 If QUIETLY is non-nil, no questions will be asked."
10136 (when (gnus-summary-catchup all quietly nil 'fast)
10137 ;; Select next newsgroup or exit.
10138 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10139 (eq gnus-auto-select-next 'quietly))
10140 (gnus-summary-next-group nil)
10141 (gnus-summary-exit))))
10143 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10144 "Mark all articles in this newsgroup as read, and then exit.
10145 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10146 instead, which marks only unread articles as read."
10148 (gnus-summary-catchup-and-exit t quietly))
10150 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10151 "Mark all articles in this group as read and select the next group.
10152 If given a prefix, mark all articles, unread as well as ticked, as
10156 (gnus-summary-catchup all))
10157 (gnus-summary-next-group))
10163 (defmacro gnus-with-article (article &rest forms)
10164 "Select ARTICLE and perform FORMS in the original article buffer.
10165 Then replace the article with the result."
10167 ;; We don't want the article to be marked as read.
10168 (let (gnus-mark-article-hook)
10169 (gnus-summary-select-article t t nil ,article))
10170 (set-buffer gnus-original-article-buffer)
10172 (if (not (gnus-check-backend-function
10173 'request-replace-article (car gnus-article-current)))
10174 (gnus-message 5 "Read-only group; not replacing")
10175 (unless (gnus-request-replace-article
10176 ,article (car gnus-article-current)
10177 (current-buffer) t)
10178 (error "Couldn't replace article")))
10179 ;; The cache and backlog have to be flushed somewhat.
10180 (when gnus-keep-backlog
10181 (gnus-backlog-remove-article
10182 (car gnus-article-current) (cdr gnus-article-current)))
10183 (when gnus-use-cache
10184 (gnus-cache-update-article
10185 (car gnus-article-current) (cdr gnus-article-current)))))
10187 (put 'gnus-with-article 'lisp-indent-function 1)
10188 (put 'gnus-with-article 'edebug-form-spec '(form body))
10190 ;; Thread-based commands.
10192 (defun gnus-summary-articles-in-thread (&optional article)
10193 "Return a list of all articles in the current thread.
10194 If ARTICLE is non-nil, return all articles in the thread that starts
10195 with that article."
10196 (let* ((article (or article (gnus-summary-article-number)))
10197 (data (gnus-data-find-list article))
10198 (top-level (gnus-data-level (car data)))
10200 (cond ((null gnus-thread-operation-ignore-subject)
10201 (gnus-simplify-subject-re
10202 (mail-header-subject (gnus-data-header (car data)))))
10203 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10204 (gnus-simplify-subject-fuzzy
10205 (mail-header-subject (gnus-data-header (car data)))))
10207 (end-point (save-excursion
10208 (if (gnus-summary-go-to-next-thread)
10209 (point) (point-max))))
10212 (< (gnus-data-pos (car data)) end-point))
10213 (when (or (not top-subject)
10214 (string= top-subject
10215 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10216 (gnus-simplify-subject-fuzzy
10217 (mail-header-subject
10218 (gnus-data-header (car data))))
10219 (gnus-simplify-subject-re
10220 (mail-header-subject
10221 (gnus-data-header (car data)))))))
10222 (push (gnus-data-number (car data)) articles))
10223 (unless (and (setq data (cdr data))
10224 (> (gnus-data-level (car data)) top-level))
10226 ;; Return the list of articles.
10227 (nreverse articles)))
10229 (defun gnus-summary-rethread-current ()
10230 "Rethread the thread the current article is part of."
10232 (let* ((gnus-show-threads t)
10233 (article (gnus-summary-article-number))
10234 (id (mail-header-id (gnus-summary-article-header)))
10235 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10237 (error "No article on the current line"))
10238 (gnus-rebuild-thread id)
10239 (gnus-summary-goto-subject article)))
10241 (defun gnus-summary-reparent-thread ()
10242 "Make the current article child of the marked (or previous) article.
10244 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10245 is non-nil or the Subject: of both articles are the same."
10247 (unless (not (gnus-group-read-only-p))
10248 (error "The current newsgroup does not support article editing"))
10249 (unless (<= (length gnus-newsgroup-processable) 1)
10250 (error "No more than one article may be marked"))
10251 (save-window-excursion
10252 (let ((gnus-article-buffer " *reparent*")
10253 (current-article (gnus-summary-article-number))
10254 ;; First grab the marked article, otherwise one line up.
10255 (parent-article (if (not (null gnus-newsgroup-processable))
10256 (car gnus-newsgroup-processable)
10258 (if (eq (forward-line -1) 0)
10259 (gnus-summary-article-number)
10260 (error "Beginning of summary buffer"))))))
10261 (unless (not (eq current-article parent-article))
10262 (error "An article may not be self-referential"))
10263 (let ((message-id (mail-header-id
10264 (gnus-summary-article-header parent-article))))
10265 (unless (and message-id (not (equal message-id "")))
10266 (error "No message-id in desired parent"))
10267 (gnus-with-article current-article
10269 (goto-char (point-min))
10270 (message-narrow-to-head)
10271 (if (re-search-forward "^References: " nil t)
10273 (re-search-forward "^[^ \t]" nil t)
10276 (insert " " message-id))
10277 (insert "References: " message-id "\n"))))
10278 (set-buffer gnus-summary-buffer)
10279 (gnus-summary-unmark-all-processable)
10280 (gnus-summary-update-article current-article)
10281 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10282 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10283 (gnus-summary-rethread-current)
10284 (gnus-message 3 "Article %d is now the child of article %d"
10285 current-article parent-article)))))
10287 (defun gnus-summary-toggle-threads (&optional arg)
10288 "Toggle showing conversation threads.
10289 If ARG is positive number, turn showing conversation threads on."
10291 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10292 (setq gnus-show-threads
10293 (if (null arg) (not gnus-show-threads)
10294 (> (prefix-numeric-value arg) 0)))
10295 (gnus-summary-prepare)
10296 (gnus-summary-goto-subject current)
10297 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10298 (gnus-summary-position-point)))
10300 (defun gnus-summary-show-all-threads ()
10301 "Show all threads."
10304 (let ((buffer-read-only nil))
10305 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10306 (gnus-summary-position-point))
10308 (defun gnus-summary-show-thread ()
10309 "Show thread subtrees.
10310 Returns nil if no thread was there to be shown."
10312 (let ((buffer-read-only nil)
10314 ;; first goto end then to beg, to have point at beg after let
10315 (end (progn (end-of-line) (point)))
10316 (beg (progn (beginning-of-line) (point))))
10318 ;; Any hidden lines here?
10319 (search-forward "\r" end t)
10320 (subst-char-in-region beg end ?\^M ?\n t)
10322 (gnus-summary-position-point))))
10324 (defun gnus-summary-maybe-hide-threads ()
10325 "If requested, hide the threads that should be hidden."
10326 (when (and gnus-show-threads
10327 gnus-thread-hide-subtree)
10328 (gnus-summary-hide-all-threads
10329 (if (or (consp gnus-thread-hide-subtree)
10330 (gnus-functionp gnus-thread-hide-subtree))
10331 (gnus-make-predicate gnus-thread-hide-subtree)
10334 ;;; Hiding predicates.
10336 (defun gnus-article-unread-p (header)
10337 (memq (mail-header-number header) gnus-newsgroup-unreads))
10339 (defun gnus-article-unseen-p (header)
10340 (memq (mail-header-number header) gnus-newsgroup-unseen))
10342 (defun gnus-map-articles (predicate articles)
10343 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10344 (apply 'gnus-or (mapcar predicate
10345 (mapcar 'gnus-summary-article-header articles))))
10347 (defun gnus-summary-hide-all-threads (&optional predicate)
10348 "Hide all thread subtrees.
10349 If PREDICATE is supplied, threads that satisfy this predicate
10350 will not be hidden."
10353 (goto-char (point-min))
10356 (when (or (not predicate)
10358 predicate (gnus-summary-article-children)))
10359 (gnus-summary-hide-thread))
10360 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10361 (gnus-summary-position-point))
10363 (defun gnus-summary-hide-thread ()
10364 "Hide thread subtrees.
10365 If PREDICATE is supplied, threads that satisfy this predicate
10366 will not be hidden.
10367 Returns nil if no threads were there to be hidden."
10369 (let ((buffer-read-only nil)
10371 (article (gnus-summary-article-number)))
10373 ;; Go forward until either the buffer ends or the subthread
10375 (when (and (not (eobp))
10376 (or (zerop (gnus-summary-next-thread 1 t))
10377 (goto-char (point-max))))
10379 (if (and (> (point) start)
10380 (search-backward "\n" start t))
10382 (subst-char-in-region start (point) ?\n ?\^M)
10383 (gnus-summary-goto-subject article))
10387 (defun gnus-summary-go-to-next-thread (&optional previous)
10388 "Go to the same level (or less) next thread.
10389 If PREVIOUS is non-nil, go to previous thread instead.
10390 Return the article number moved to, or nil if moving was impossible."
10391 (let ((level (gnus-summary-thread-level))
10392 (way (if previous -1 1))
10395 (while (and (not (eobp))
10396 (< level (gnus-summary-thread-level)))
10397 (forward-line way))
10404 (gnus-summary-article-number)
10405 (goto-char beg)))))
10407 (defun gnus-summary-next-thread (n &optional silent)
10408 "Go to the same level next N'th thread.
10409 If N is negative, search backward instead.
10410 Returns the difference between N and the number of skips actually
10413 If SILENT, don't output messages."
10415 (let ((backward (< n 0))
10417 (while (and (> n 0)
10418 (gnus-summary-go-to-next-thread backward))
10421 (gnus-summary-position-point))
10422 (when (and (not silent) (/= 0 n))
10423 (gnus-message 7 "No more threads"))
10426 (defun gnus-summary-prev-thread (n)
10427 "Go to the same level previous N'th thread.
10428 Returns the difference between N and the number of skips actually
10431 (gnus-summary-next-thread (- n)))
10433 (defun gnus-summary-go-down-thread ()
10434 "Go down one level in the current thread."
10435 (let ((children (gnus-summary-article-children)))
10437 (gnus-summary-goto-subject (car children)))))
10439 (defun gnus-summary-go-up-thread ()
10440 "Go up one level in the current thread."
10441 (let ((parent (gnus-summary-article-parent)))
10443 (gnus-summary-goto-subject parent))))
10445 (defun gnus-summary-down-thread (n)
10446 "Go down thread N steps.
10447 If N is negative, go up instead.
10448 Returns the difference between N and how many steps down that were
10453 (while (and (> n 0)
10454 (if up (gnus-summary-go-up-thread)
10455 (gnus-summary-go-down-thread)))
10457 (gnus-summary-position-point)
10459 (gnus-message 7 "Can't go further"))
10462 (defun gnus-summary-up-thread (n)
10463 "Go up thread N steps.
10464 If N is negative, go down instead.
10465 Returns the difference between N and how many steps down that were
10468 (gnus-summary-down-thread (- n)))
10470 (defun gnus-summary-top-thread ()
10471 "Go to the top of the thread."
10473 (while (gnus-summary-go-up-thread))
10474 (gnus-summary-article-number))
10476 (defun gnus-summary-kill-thread (&optional unmark)
10477 "Mark articles under current thread as read.
10478 If the prefix argument is positive, remove any kinds of marks.
10479 If the prefix argument is negative, tick articles instead."
10482 (setq unmark (prefix-numeric-value unmark)))
10483 (let ((articles (gnus-summary-articles-in-thread)))
10485 ;; Expand the thread.
10486 (gnus-summary-show-thread)
10487 ;; Mark all the articles.
10489 (gnus-summary-goto-subject (car articles))
10490 (cond ((null unmark)
10491 (gnus-summary-mark-article-as-read gnus-killed-mark))
10493 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10495 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10496 (setq articles (cdr articles))))
10497 ;; Hide killed subtrees.
10499 gnus-thread-hide-killed
10500 (gnus-summary-hide-thread))
10501 ;; If marked as read, go to next unread subject.
10502 (when (null unmark)
10503 ;; Go to next unread subject.
10504 (gnus-summary-next-subject 1 t)))
10505 (gnus-set-mode-line 'summary))
10507 ;; Summary sorting commands
10509 (defun gnus-summary-sort-by-number (&optional reverse)
10510 "Sort the summary buffer by article number.
10511 Argument REVERSE means reverse order."
10513 (gnus-summary-sort 'number reverse))
10515 (defun gnus-summary-sort-by-random (&optional reverse)
10516 "Randomize the order in the summary buffer.
10517 Argument REVERSE means to randomize in reverse order."
10519 (gnus-summary-sort 'random reverse))
10521 (defun gnus-summary-sort-by-author (&optional reverse)
10522 "Sort the summary buffer by author name alphabetically.
10523 If `case-fold-search' is non-nil, case of letters is ignored.
10524 Argument REVERSE means reverse order."
10526 (gnus-summary-sort 'author reverse))
10528 (defun gnus-summary-sort-by-subject (&optional reverse)
10529 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10530 If `case-fold-search' is non-nil, case of letters is ignored.
10531 Argument REVERSE means reverse order."
10533 (gnus-summary-sort 'subject reverse))
10535 (defun gnus-summary-sort-by-date (&optional reverse)
10536 "Sort the summary buffer by date.
10537 Argument REVERSE means reverse order."
10539 (gnus-summary-sort 'date reverse))
10541 (defun gnus-summary-sort-by-score (&optional reverse)
10542 "Sort the summary buffer by score.
10543 Argument REVERSE means reverse order."
10545 (gnus-summary-sort 'score reverse))
10547 (defun gnus-summary-sort-by-lines (&optional reverse)
10548 "Sort the summary buffer by the number of lines.
10549 Argument REVERSE means reverse order."
10551 (gnus-summary-sort 'lines reverse))
10553 (defun gnus-summary-sort-by-chars (&optional reverse)
10554 "Sort the summary buffer by article length.
10555 Argument REVERSE means reverse order."
10557 (gnus-summary-sort 'chars reverse))
10559 (defun gnus-summary-sort-by-original (&optional reverse)
10560 "Sort the summary buffer using the default sorting method.
10561 Argument REVERSE means reverse order."
10563 (let* ((buffer-read-only)
10564 (gnus-summary-prepare-hook nil))
10565 ;; We do the sorting by regenerating the threads.
10566 (gnus-summary-prepare)
10567 ;; Hide subthreads if needed.
10568 (gnus-summary-maybe-hide-threads)))
10570 (defun gnus-summary-sort (predicate reverse)
10571 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10572 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10573 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10574 (gnus-thread-sort-functions
10579 (gnus-sort-gathered-threads-function
10580 gnus-thread-sort-functions)
10581 (gnus-article-sort-functions
10585 (,article t2 t1))))
10587 (gnus-summary-prepare-hook nil))
10588 ;; We do the sorting by regenerating the threads.
10589 (gnus-summary-prepare)
10590 ;; Hide subthreads if needed.
10591 (gnus-summary-maybe-hide-threads)))
10593 ;; Summary saving commands.
10595 (defun gnus-summary-save-article (&optional n not-saved)
10596 "Save the current article using the default saver function.
10597 If N is a positive number, save the N next articles.
10598 If N is a negative number, save the N previous articles.
10599 If N is nil and any articles have been marked with the process mark,
10600 save those articles instead.
10601 The variable `gnus-default-article-saver' specifies the saver function."
10603 (let* ((articles (gnus-summary-work-articles n))
10604 (save-buffer (save-excursion
10605 (nnheader-set-temp-buffer " *Gnus Save*")))
10606 (num (length articles))
10608 (dolist (article articles)
10609 (setq header (gnus-summary-article-header article))
10610 (if (not (vectorp header))
10611 ;; This is a pseudo-article.
10612 (if (assq 'name header)
10613 (gnus-copy-file (cdr (assq 'name header)))
10614 (gnus-message 1 "Article %d is unsaveable" article))
10615 ;; This is a real article.
10616 (save-window-excursion
10617 (let ((gnus-display-mime-function nil)
10618 (gnus-article-prepare-hook nil))
10619 (gnus-summary-select-article t nil nil article)))
10621 (set-buffer save-buffer)
10623 (insert-buffer-substring gnus-original-article-buffer))
10624 (setq file (gnus-article-save save-buffer file num))
10625 (gnus-summary-remove-process-mark article)
10627 (gnus-summary-set-saved-mark article))))
10628 (gnus-kill-buffer save-buffer)
10629 (gnus-summary-position-point)
10630 (gnus-set-mode-line 'summary)
10633 (defun gnus-summary-pipe-output (&optional arg headers)
10634 "Pipe the current article to a subprocess.
10635 If N is a positive number, pipe the N next articles.
10636 If N is a negative number, pipe the N previous articles.
10637 If N is nil and any articles have been marked with the process mark,
10638 pipe those articles instead.
10639 If HEADERS (the symbolic prefix), include the headers, too."
10640 (interactive (gnus-interactive "P\ny"))
10641 (require 'gnus-art)
10642 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10643 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10644 (gnus-summary-save-article arg t))
10645 (let ((buffer (get-buffer "*Shell Command Output*")))
10647 (not (zerop (buffer-size buffer))))
10648 (gnus-configure-windows 'pipe))))
10650 (defun gnus-summary-save-article-mail (&optional arg)
10651 "Append the current article to an mail file.
10652 If N is a positive number, save the N next articles.
10653 If N is a negative number, save the N previous articles.
10654 If N is nil and any articles have been marked with the process mark,
10655 save those articles instead."
10657 (require 'gnus-art)
10658 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10659 (gnus-summary-save-article arg)))
10661 (defun gnus-summary-save-article-rmail (&optional arg)
10662 "Append the current article to an rmail file.
10663 If N is a positive number, save the N next articles.
10664 If N is a negative number, save the N previous articles.
10665 If N is nil and any articles have been marked with the process mark,
10666 save those articles instead."
10668 (require 'gnus-art)
10669 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10670 (gnus-summary-save-article arg)))
10672 (defun gnus-summary-save-article-file (&optional arg)
10673 "Append the current article to a file.
10674 If N is a positive number, save the N next articles.
10675 If N is a negative number, save the N previous articles.
10676 If N is nil and any articles have been marked with the process mark,
10677 save those articles instead."
10679 (require 'gnus-art)
10680 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10681 (gnus-summary-save-article arg)))
10683 (defun gnus-summary-write-article-file (&optional arg)
10684 "Write the current article to a file, deleting the previous file.
10685 If N is a positive number, save the N next articles.
10686 If N is a negative number, save the N previous articles.
10687 If N is nil and any articles have been marked with the process mark,
10688 save those articles instead."
10690 (require 'gnus-art)
10691 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10692 (gnus-summary-save-article arg)))
10694 (defun gnus-summary-save-article-body-file (&optional arg)
10695 "Append the current article body to a file.
10696 If N is a positive number, save the N next articles.
10697 If N is a negative number, save the N previous articles.
10698 If N is nil and any articles have been marked with the process mark,
10699 save those articles instead."
10701 (require 'gnus-art)
10702 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10703 (gnus-summary-save-article arg)))
10705 (defun gnus-summary-muttprint (&optional arg)
10706 "Print the current article using Muttprint.
10707 If N is a positive number, save the N next articles.
10708 If N is a negative number, save the N previous articles.
10709 If N is nil and any articles have been marked with the process mark,
10710 save those articles instead."
10712 (require 'gnus-art)
10713 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10714 (gnus-summary-save-article arg t)))
10716 (defun gnus-summary-pipe-message (program)
10717 "Pipe the current article through PROGRAM."
10718 (interactive "sProgram: ")
10719 (gnus-summary-select-article)
10720 (let ((mail-header-separator ""))
10721 (gnus-eval-in-buffer-window gnus-article-buffer
10724 (let ((start (window-start))
10726 (message-pipe-buffer-body program)
10727 (set-window-start (get-buffer-window (current-buffer)) start))))))
10729 (defun gnus-get-split-value (methods)
10730 "Return a value based on the split METHODS."
10731 (let (split-name method result match)
10734 (set-buffer gnus-original-article-buffer)
10736 (nnheader-narrow-to-headers)
10737 (while (and methods (not split-name))
10738 (goto-char (point-min))
10739 (setq method (pop methods))
10740 (setq match (car method))
10743 ;; Regular expression.
10745 (re-search-forward match nil t)))
10746 ((gnus-functionp match)
10750 (setq result (funcall match gnus-newsgroup-name))))
10755 (setq result (eval match)))))
10756 (setq split-name (cdr method))
10757 (cond ((stringp result)
10758 (push (expand-file-name
10759 result gnus-article-save-directory)
10762 (setq split-name (append result split-name)))))))))
10763 (nreverse split-name)))
10765 (defun gnus-valid-move-group-p (group)
10766 (and (boundp group)
10767 (symbol-name group)
10768 (symbol-value group)
10769 (gnus-get-function (gnus-find-method-for-group
10770 (symbol-name group)) 'request-accept-article t)))
10772 (defun gnus-read-move-group-name (prompt default articles prefix)
10773 "Read a group name."
10774 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10775 (minibuffer-confirm-incomplete nil) ; XEmacs
10777 (format "%s %s to:"
10779 (if (> (length articles) 1)
10780 (format "these %d articles" (length articles))
10785 (gnus-completing-read-with-default
10788 'gnus-valid-move-group-p
10790 'gnus-group-history))
10791 ((= 1 (length split-name))
10792 (gnus-completing-read-with-default
10793 (car split-name) prom
10795 'gnus-valid-move-group-p
10797 'gnus-group-history))
10799 (gnus-completing-read-with-default
10801 (mapcar (lambda (el) (list el))
10802 (nreverse split-name))
10804 'gnus-group-history))))
10805 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10807 (if (or (string= to-newsgroup "")
10808 (string= to-newsgroup prefix))
10809 (setq to-newsgroup default))
10810 (unless to-newsgroup
10811 (error "No group name entered"))
10812 (or (gnus-active to-newsgroup)
10813 (gnus-activate-group to-newsgroup nil nil to-method)
10814 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10816 (or (and (gnus-request-create-group to-newsgroup to-method)
10817 (gnus-activate-group
10818 to-newsgroup nil nil to-method)
10819 (gnus-subscribe-group to-newsgroup))
10820 (error "Couldn't create group %s" to-newsgroup)))
10821 (error "No such group: %s" to-newsgroup)))
10824 (defun gnus-summary-save-parts (type dir n &optional reverse)
10825 "Save parts matching TYPE to DIR.
10826 If REVERSE, save parts that do not match TYPE."
10828 (list (read-string "Save parts of type: "
10829 (or (car gnus-summary-save-parts-type-history)
10830 gnus-summary-save-parts-default-mime)
10831 'gnus-summary-save-parts-type-history)
10832 (setq gnus-summary-save-parts-last-directory
10833 (read-file-name "Save to directory: "
10834 gnus-summary-save-parts-last-directory
10836 current-prefix-arg))
10837 (gnus-summary-iterate n
10838 (let ((gnus-display-mime-function nil)
10839 (gnus-inhibit-treatment t))
10840 (gnus-summary-select-article))
10842 (set-buffer gnus-article-buffer)
10843 (let ((handles (or gnus-article-mime-handles
10844 (mm-dissect-buffer nil gnus-article-loose-mime)
10845 (and gnus-article-emulate-mime
10846 (mm-uu-dissect)))))
10848 (gnus-summary-save-parts-1 type dir handles reverse)
10849 (unless gnus-article-mime-handles ;; Don't destroy this case.
10850 (mm-destroy-parts handles)))))))
10852 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10853 (if (stringp (car handle))
10854 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10857 (not (string-match type (mm-handle-media-type handle)))
10858 (string-match type (mm-handle-media-type handle)))
10859 (let ((file (expand-file-name
10860 (file-name-nondirectory
10862 (mail-content-type-get
10863 (mm-handle-disposition handle) 'filename)
10864 (concat gnus-newsgroup-name
10865 "." (number-to-string
10866 (cdr gnus-article-current)))))
10868 (unless (file-exists-p file)
10869 (mm-save-part-to-file handle file))))))
10871 ;; Summary extract commands
10873 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10874 (let ((buffer-read-only nil)
10875 (article (gnus-summary-article-number))
10877 (unless (gnus-summary-goto-subject article)
10878 (error "No such article: %d" article))
10879 (gnus-summary-position-point)
10880 ;; If all commands are to be bunched up on one line, we collect
10882 (unless gnus-view-pseudos-separately
10883 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10886 (setq action (cdr (assq 'action (car ps))))
10887 (setq files (list (cdr (assq 'name (car ps)))))
10888 (while (and ps (cdr ps)
10889 (string= (or action "1")
10890 (or (cdr (assq 'action (cadr ps))) "2")))
10891 (push (cdr (assq 'name (cadr ps))) files)
10892 (setcdr ps (cddr ps)))
10894 (when (not (string-match "%s" action))
10897 (when (assq 'execute (car ps))
10898 (setcdr (assq 'execute (car ps))
10899 (funcall (if (string-match "%s" action)
10906 (gnus-quote-arg-for-sh-or-csh f)))
10908 (setq ps (cdr ps)))))
10909 (if (and gnus-view-pseudos (not not-view))
10911 (when (assq 'execute (car pslist))
10912 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10913 (eq gnus-view-pseudos 'not-confirm)))
10914 (setq pslist (cdr pslist)))
10917 (setq after-article (or (cdr (assq 'article (car pslist)))
10918 (gnus-summary-article-number)))
10919 (gnus-summary-goto-subject after-article)
10922 (insert " " (file-name-nondirectory
10923 (cdr (assq 'name (car pslist))))
10924 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10926 (forward-line -1) ; back to `b'
10927 (gnus-add-text-properties
10928 b (1- e) (list 'gnus-number gnus-reffed-article-number
10929 gnus-mouse-face-prop gnus-mouse-face))
10931 after-article gnus-reffed-article-number
10932 gnus-unread-mark b (car pslist) 0 (- e b))
10933 (setq gnus-newsgroup-unreads
10934 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10935 gnus-reffed-article-number))
10936 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10937 (setq pslist (cdr pslist)))))))
10939 (defun gnus-pseudos< (p1 p2)
10940 (let ((c1 (cdr (assq 'action p1)))
10941 (c2 (cdr (assq 'action p2))))
10942 (and c1 c2 (string< c1 c2))))
10944 (defun gnus-request-pseudo-article (props)
10945 (cond ((assq 'execute props)
10946 (gnus-execute-command (cdr (assq 'execute props)))))
10947 (let ((gnus-current-article (gnus-summary-article-number)))
10948 (gnus-run-hooks 'gnus-mark-article-hook)))
10950 (defun gnus-execute-command (command &optional automatic)
10952 (gnus-article-setup-buffer)
10953 (set-buffer gnus-article-buffer)
10954 (setq buffer-read-only nil)
10955 (let ((command (if automatic command
10956 (read-string "Command: " (cons command 0)))))
10958 (insert "$ " command "\n\n")
10959 (if gnus-view-pseudo-asynchronously
10960 (start-process "gnus-execute" (current-buffer) shell-file-name
10961 shell-command-switch command)
10962 (call-process shell-file-name nil t nil
10963 shell-command-switch command)))))
10965 ;; Summary kill commands.
10967 (defun gnus-summary-edit-global-kill (article)
10968 "Edit the \"global\" kill file."
10969 (interactive (list (gnus-summary-article-number)))
10970 (gnus-group-edit-global-kill article))
10972 (defun gnus-summary-edit-local-kill ()
10973 "Edit a local kill file applied to the current newsgroup."
10975 (setq gnus-current-headers (gnus-summary-article-header))
10976 (gnus-group-edit-local-kill
10977 (gnus-summary-article-number) gnus-newsgroup-name))
10979 ;;; Header reading.
10981 (defun gnus-read-header (id &optional header)
10982 "Read the headers of article ID and enter them into the Gnus system."
10983 (let ((group gnus-newsgroup-name)
10984 (gnus-override-method
10986 gnus-override-method
10987 (and (gnus-news-group-p gnus-newsgroup-name)
10988 (car (gnus-refer-article-methods)))))
10990 ;; First we check to see whether the header in question is already
10993 ;; This is a Message-ID.
10994 (setq header (or header (gnus-id-to-header id)))
10995 ;; This is an article number.
10996 (setq header (or header (gnus-summary-article-header id))))
10998 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10999 ;; We have found the header.
11001 ;; If this is a sparse article, we have to nix out its
11002 ;; previous entry in the thread hashtb.
11004 (gnus-summary-article-sparse-p (mail-header-number header)))
11005 (let* ((parent (gnus-parent-id (mail-header-references header)))
11006 (thread (and parent (gnus-id-to-thread parent))))
11008 (delq (assq header thread) thread))))
11009 ;; We have to really fetch the header to this article.
11011 (set-buffer nntp-server-buffer)
11012 (when (setq where (gnus-request-head id group))
11013 (nnheader-fold-continuation-lines)
11014 (goto-char (point-max))
11016 (goto-char (point-min))
11020 ((cdr where) (cdr where))
11021 (header (mail-header-number header))
11022 (t gnus-reffed-article-number))
11024 (insert " Article retrieved.\n"))
11025 (if (or (not where)
11026 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11027 () ; Malformed head.
11028 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11029 (when (and (stringp id)
11030 (not (string= (gnus-group-real-name group)
11032 ;; If we fetched by Message-ID and the article came
11033 ;; from a different group, we fudge some bogus article
11034 ;; numbers for this article.
11035 (mail-header-set-number header gnus-reffed-article-number))
11037 (set-buffer gnus-summary-buffer)
11038 (decf gnus-reffed-article-number)
11039 (gnus-remove-header (mail-header-number header))
11040 (push header gnus-newsgroup-headers)
11041 (setq gnus-current-headers header)
11042 (push (mail-header-number header) gnus-newsgroup-limit)))
11045 (defun gnus-remove-header (number)
11046 "Remove header NUMBER from `gnus-newsgroup-headers'."
11047 (if (and gnus-newsgroup-headers
11048 (= number (mail-header-number (car gnus-newsgroup-headers))))
11049 (pop gnus-newsgroup-headers)
11050 (let ((headers gnus-newsgroup-headers))
11051 (while (and (cdr headers)
11052 (not (= number (mail-header-number (cadr headers)))))
11054 (when (cdr headers)
11055 (setcdr headers (cddr headers))))))
11058 ;;; summary highlights
11061 (defun gnus-highlight-selected-summary ()
11062 "Highlight selected article in summary buffer."
11063 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11064 (when gnus-summary-selected-face
11066 (let* ((beg (progn (beginning-of-line) (point)))
11067 (end (progn (end-of-line) (point)))
11068 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11069 (from (if (get-text-property beg gnus-mouse-face-prop)
11071 (or (next-single-property-change
11072 beg gnus-mouse-face-prop nil end)
11077 (or (next-single-property-change
11078 from gnus-mouse-face-prop nil end)
11080 ;; If no mouse-face prop on line we will have to = from = end,
11081 ;; so we highlight the entire line instead.
11082 (when (= (+ to 2) from)
11085 (if gnus-newsgroup-selected-overlay
11086 ;; Move old overlay.
11088 gnus-newsgroup-selected-overlay from to (current-buffer))
11089 ;; Create new overlay.
11091 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11092 'face gnus-summary-selected-face))))))
11094 (defvar gnus-summary-highlight-line-cached nil)
11095 (defvar gnus-summary-highlight-line-trigger nil)
11097 (defun gnus-summary-highlight-line-0 ()
11098 (if (and (eq gnus-summary-highlight-line-trigger
11099 gnus-summary-highlight)
11100 gnus-summary-highlight-line-cached)
11101 gnus-summary-highlight-line-cached
11102 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11103 gnus-summary-highlight-line-cached
11104 (let* ((cond (list 'cond))
11106 (list gnus-summary-highlight))
11108 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11111 (gnus-byte-compile (list 'lambda nil cond))))))
11113 (defun gnus-summary-highlight-line ()
11114 "Highlight current line according to `gnus-summary-highlight'."
11115 (let* ((beg (gnus-point-at-bol))
11116 (article (or (gnus-summary-article-number) gnus-current-article))
11117 (score (or (cdr (assq article
11118 gnus-newsgroup-scored))
11119 gnus-summary-default-score 0))
11120 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11121 (inhibit-read-only t)
11122 (default gnus-summary-default-score)
11123 (default-high gnus-summary-default-high-score)
11124 (default-low gnus-summary-default-low-score)
11125 (uncached (memq article gnus-newsgroup-undownloaded))
11126 (downloaded (not uncached)))
11127 (let ((face (funcall (gnus-summary-highlight-line-0))))
11128 (unless (eq face (get-text-property beg 'face))
11129 (gnus-put-text-property-excluding-characters-with-faces
11130 beg (gnus-point-at-eol) 'face
11131 (setq face (if (boundp face) (symbol-value face) face)))
11132 (when gnus-summary-highlight-line-function
11133 (funcall gnus-summary-highlight-line-function article face))))))
11135 (defun gnus-update-read-articles (group unread &optional compute)
11136 "Update the list of read articles in GROUP.
11137 UNREAD is a sorted list."
11138 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11139 (entry (gnus-gethash group gnus-newsrc-hashtb))
11140 (info (nth 2 entry))
11143 (if (or (not info) (not active))
11144 ;; There is no info on this group if it was, in fact,
11145 ;; killed. Gnus stores no information on killed groups, so
11146 ;; there's nothing to be done.
11147 ;; One could store the information somewhere temporarily,
11148 ;; perhaps... Hmmm...
11150 ;; Remove any negative articles numbers.
11151 (while (and unread (< (car unread) 0))
11152 (setq unread (cdr unread)))
11153 ;; Remove any expired article numbers
11154 (while (and unread (< (car unread) (car active)))
11155 (setq unread (cdr unread)))
11156 ;; Compute the ranges of read articles by looking at the list of
11157 ;; unread articles.
11159 (when (/= (car unread) prev)
11160 (push (if (= prev (1- (car unread))) prev
11161 (cons prev (1- (car unread))))
11163 (setq prev (1+ (car unread)))
11164 (setq unread (cdr unread)))
11165 (when (<= prev (cdr active))
11166 (push (cons prev (cdr active)) read))
11167 (setq read (if (> (length read) 1) (nreverse read) read))
11172 ;; Propagate the read marks to the backend.
11173 (when (gnus-check-backend-function 'request-set-mark group)
11174 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11175 (add (gnus-remove-from-range read (gnus-info-read info))))
11177 (unless (gnus-check-group group)
11178 (error "Can't open server for %s" group))
11179 (gnus-request-set-mark
11180 group (delq nil (list (if add (list add 'add '(read)))
11181 (if del (list del 'del '(read))))))
11183 `(gnus-request-set-mark
11186 (if del (list del 'add '(read)))
11187 (if add (list add 'del '(read))))))))))
11188 (set-buffer gnus-group-buffer)
11189 (gnus-undo-register
11191 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11192 (gnus-info-set-read ',info ',(gnus-info-read info))
11193 (gnus-get-unread-articles-in-group ',info
11194 (gnus-active ,group))
11195 (gnus-group-update-group ,group t)
11197 ;; Enter this list into the group info.
11198 (gnus-info-set-read info read)
11199 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11200 (gnus-get-unread-articles-in-group info (gnus-active group))
11203 (defun gnus-offer-save-summaries ()
11204 "Offer to save all active summary buffers."
11206 ;; Go through all buffers and find all summaries.
11207 (dolist (buffer (buffer-list))
11208 (when (and (setq buffer (buffer-name buffer))
11209 (string-match "Summary" buffer)
11211 (set-buffer buffer)
11212 ;; We check that this is, indeed, a summary buffer.
11213 (and (eq major-mode 'gnus-summary-mode)
11214 ;; Also make sure this isn't bogus.
11215 gnus-newsgroup-prepared
11216 ;; Also make sure that this isn't a
11217 ;; dead summary buffer.
11218 (not gnus-dead-summary-mode))))
11219 (push buffer buffers)))
11220 ;; Go through all these summary buffers and offer to save them.
11224 "Update summary buffer %s? "
11226 (switch-to-buffer buf)
11227 (gnus-summary-exit))
11231 ;;; @ for mime-partial
11234 (defun gnus-request-partial-message ()
11236 (let ((number (gnus-summary-article-number))
11237 (group gnus-newsgroup-name)
11238 (mother gnus-article-buffer))
11239 (set-buffer (get-buffer-create " *Partial Article*"))
11241 (setq mime-preview-buffer mother)
11242 (gnus-request-article-this-buffer number group)
11243 (mime-parse-buffer)
11246 (autoload 'mime-combine-message/partial-pieces-automatically
11248 "Internal method to combine message/partial messages automatically.")
11250 (mime-add-condition
11251 'action '((type . message)(subtype . partial)
11252 (major-mode . gnus-original-article-mode)
11253 (method . mime-combine-message/partial-pieces-automatically)
11254 (summary-buffer-exp . gnus-summary-buffer)
11255 (request-partial-message-method . gnus-request-partial-message)
11259 ;;; @ for message/rfc822
11262 (defun gnus-mime-extract-message/rfc822 (entity situation)
11263 "Burst a forwarded article."
11265 (set-buffer gnus-summary-buffer)
11266 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11267 gnus-newsgroup-name 'gnus-group-history))
11268 (gnus-group-marked (list group))
11271 (mime-insert-entity-content entity)
11272 (setq article (gnus-request-accept-article group)))
11273 (when (and (consp article)
11274 (numberp (setq article (cdr article))))
11275 (setq info (gnus-get-info group))
11276 (gnus-info-set-read info
11277 (gnus-remove-from-range (gnus-info-read info)
11279 (when (string-equal group gnus-newsgroup-name)
11281 (let (gnus-show-threads)
11282 (gnus-summary-goto-subject article t))
11283 (gnus-summary-clear-mark-forward 1))
11284 (set-buffer gnus-group-buffer)
11285 (gnus-group-get-new-news-this-group nil t)))))
11287 (mime-add-condition
11288 'action '((type . message)(subtype . rfc822)
11289 (major-mode . gnus-original-article-mode)
11290 (method . gnus-mime-extract-message/rfc822)
11294 (mime-add-condition
11295 'action '((type . message)(subtype . news)
11296 (major-mode . gnus-original-article-mode)
11297 (method . gnus-mime-extract-message/rfc822)
11301 (defun gnus-mime-extract-multipart (entity situation)
11302 (let ((children (mime-entity-children entity))
11303 mime-acting-situation-to-override
11306 (mime-play-entity (car children)
11307 (cons (assq 'mode situation)
11308 mime-acting-situation-to-override))
11309 (setq children (cdr children)))
11310 (if (setq f (cdr (assq 'after-method
11311 mime-acting-situation-to-override)))
11315 (mime-add-condition
11316 'action '((type . multipart)
11317 (method . gnus-mime-extract-multipart)
11326 (defun gnus-summary-inherit-default-charset ()
11327 "Import `default-mime-charset' from summary buffer.
11328 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11330 (if (buffer-live-p gnus-summary-buffer)
11331 (let (d-m-c d-m-c-u)
11332 (with-current-buffer gnus-summary-buffer
11333 (setq d-m-c (if (local-variable-p 'default-mime-charset
11334 gnus-summary-buffer)
11335 default-mime-charset
11338 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11339 gnus-summary-buffer)
11340 (symbol-value 'default-mime-charset-unlimited)
11343 (kill-local-variable 'default-mime-charset)
11344 (set (make-local-variable 'default-mime-charset) d-m-c))
11346 (kill-local-variable 'default-mime-charset-unlimited)
11347 (set (make-local-variable 'default-mime-charset-unlimited)
11350 (defun gnus-summary-setup-default-charset ()
11351 "Setup newsgroup default charset."
11352 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11354 (setq gnus-newsgroup-charset nil)
11355 (set (make-local-variable 'default-mime-charset) nil)
11356 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11357 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11358 (let ((ignored-charsets
11359 (or gnus-newsgroup-ephemeral-ignored-charsets
11361 (and gnus-newsgroup-name
11362 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11363 gnus-newsgroup-ignored-charsets)))
11365 (setq gnus-newsgroup-charset
11366 (or gnus-newsgroup-ephemeral-charset
11367 (when (and gnus-newsgroup-name
11368 (setq charset (gnus-parameter-charset
11369 gnus-newsgroup-name)))
11370 (make-local-variable 'default-mime-charset)
11371 (setq default-mime-charset charset))
11372 gnus-default-charset))
11373 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11374 ignored-charsets))))
11380 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11381 "Display the current article buffer fully MIME-buttonized.
11382 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11383 treated as multipart/mixed."
11385 (require 'gnus-art)
11386 (let ((gnus-unbuttonized-mime-types nil)
11387 (gnus-mime-display-multipart-as-mixed show-all-parts))
11388 (gnus-summary-show-article)))
11390 (defun gnus-summary-repair-multipart (article)
11391 "Add a Content-Type header to a multipart article without one."
11392 (interactive (list (gnus-summary-article-number)))
11393 (gnus-with-article article
11394 (message-narrow-to-head)
11395 (message-remove-header "Mime-Version")
11396 (goto-char (point-max))
11397 (insert "Mime-Version: 1.0\n")
11399 (when (search-forward "\n--" nil t)
11400 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11401 (message-narrow-to-head)
11402 (message-remove-header "Content-Type")
11403 (goto-char (point-max))
11404 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11407 (let (gnus-mark-article-hook)
11408 (gnus-summary-select-article t t nil article)))
11410 (defun gnus-summary-toggle-display-buttonized ()
11411 "Toggle the buttonizing of the article buffer."
11413 (require 'gnus-art)
11414 (if (setq gnus-inhibit-mime-unbuttonizing
11415 (not gnus-inhibit-mime-unbuttonizing))
11416 (let ((gnus-unbuttonized-mime-types nil))
11417 (gnus-summary-show-article))
11418 (gnus-summary-show-article)))
11421 ;;; Intelli-mouse commmands
11424 (defun gnus-wheel-summary-scroll (event)
11426 (let ((amount (if (memq 'shift (event-modifiers event))
11427 (car gnus-wheel-scroll-amount)
11428 (cdr gnus-wheel-scroll-amount)))
11429 (direction (- (* (static-if (featurep 'xemacs)
11430 (event-button event)
11431 (cond ((eq 'mouse-4 (event-basic-type event))
11433 ((eq 'mouse-5 (event-basic-type event))
11437 (gnus-summary-scroll-up (* amount direction))
11438 (when (gnus-eval-in-buffer-window gnus-article-buffer
11441 (and (if (< 0 direction)
11442 (gnus-article-next-page 0)
11443 (gnus-article-prev-page 0)
11445 (if (setq edge (get-text-property
11446 (point-min) 'gnus-wheel-edge))
11447 (setq edge (* edge direction))
11450 (let ((buffer-read-only nil)
11451 (inhibit-read-only t))
11452 (put-text-property (point-min) (point-max)
11453 'gnus-wheel-edge direction)
11455 (or (> edge gnus-wheel-edge-resistance)
11456 (let ((buffer-read-only nil)
11457 (inhibit-read-only t))
11458 (put-text-property (point-min) (point-max)
11460 (* (1+ edge) direction))
11462 (eq last-command 'gnus-wheel-summary-scroll))))
11463 (gnus-summary-next-article nil nil (minusp direction)))))
11465 (defun gnus-wheel-install ()
11466 "Enable mouse wheel support on summary window."
11467 (when gnus-use-wheel
11469 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11471 (define-key gnus-summary-mode-map key
11472 'gnus-wheel-summary-scroll)))))
11474 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11477 ;;; Traditional PGP commmands
11480 (defun gnus-summary-decrypt-article (&optional force)
11481 "Decrypt the current article in traditional PGP way.
11482 This will have permanent effect only in mail groups.
11483 If FORCE is non-nil, allow editing of articles even in read-only
11486 (gnus-summary-select-article t)
11487 (gnus-eval-in-buffer-window gnus-article-buffer
11491 (goto-char (point-min))
11492 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11493 (error "Not a traditional PGP message!"))
11494 (let ((armor-start (match-beginning 0)))
11495 (if (and (pgg-decrypt-region armor-start (point-max))
11496 (or force (not (gnus-group-read-only-p))))
11497 (let ((inhibit-read-only t)
11499 (delete-region armor-start
11501 (re-search-forward "^-+END PGP" nil t)
11502 (beginning-of-line 2)
11504 (insert-buffer-substring pgg-output-buffer))))))))
11506 (defun gnus-summary-verify-article ()
11507 "Verify the current article in traditional PGP way."
11510 (set-buffer gnus-original-article-buffer)
11511 (goto-char (point-min))
11512 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11513 (error "Not a traditional PGP message!"))
11514 (re-search-forward "^-+END PGP" nil t)
11515 (beginning-of-line 2)
11516 (call-interactively (function pgg-verify-region))))
11519 ;;; Generic summary marking commands
11522 (defvar gnus-summary-marking-alist
11523 '((read gnus-del-mark "d")
11524 (unread gnus-unread-mark "u")
11525 (ticked gnus-ticked-mark "!")
11526 (dormant gnus-dormant-mark "?")
11527 (expirable gnus-expirable-mark "e"))
11528 "An alist of names/marks/keystrokes.")
11530 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11531 (defvar gnus-summary-mark-map)
11533 (defun gnus-summary-make-all-marking-commands ()
11534 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11535 (dolist (elem gnus-summary-marking-alist)
11536 (apply 'gnus-summary-make-marking-command elem)))
11538 (defun gnus-summary-make-marking-command (name mark keystroke)
11539 (let ((map (make-sparse-keymap)))
11540 (define-key gnus-summary-generic-mark-map keystroke map)
11541 (dolist (lway `((next "next" next nil "n")
11542 (next-unread "next unread" next t "N")
11543 (prev "previous" prev nil "p")
11544 (prev-unread "previous unread" prev t "P")
11545 (nomove "" nil nil ,keystroke)))
11546 (let ((func (gnus-summary-make-marking-command-1
11547 mark (car lway) lway name)))
11548 (setq func (eval func))
11549 (define-key map (nth 4 lway) func)))))
11551 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11553 (format "gnus-summary-put-mark-as-%s%s"
11554 name (if (eq way 'nomove)
11556 (concat "-" (symbol-name way)))))
11559 "Mark the current article as %s%s.
11560 If N, the prefix, then repeat N times.
11561 If N is negative, move in reverse order.
11562 The difference between N and the actual number of articles marked is
11564 name (car (cdr lway)))
11566 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11568 (defun gnus-summary-generic-mark (n mark move unread)
11569 "Mark N articles with MARK."
11570 (unless (eq major-mode 'gnus-summary-mode)
11571 (error "This command can only be used in the summary buffer"))
11572 (gnus-summary-show-thread)
11575 ((eq move 'next) 1)
11576 ((eq move 'prev) -1)
11578 (if (zerop nummove)
11582 nummove (* -1 nummove))))
11583 (while (and (> n 0)
11584 (gnus-summary-mark-article nil mark)
11585 (zerop (gnus-summary-next-subject nummove unread t)))
11588 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11589 (gnus-summary-recenter)
11590 (gnus-summary-position-point)
11591 (gnus-set-mode-line 'summary)
11594 (defun gnus-summary-insert-articles (articles)
11595 (when (setq articles
11596 (gnus-sorted-difference articles
11597 (mapcar (lambda (h)
11598 (mail-header-number h))
11599 gnus-newsgroup-headers)))
11600 (setq gnus-newsgroup-headers
11602 gnus-newsgroup-headers
11603 (gnus-fetch-headers articles)
11604 'gnus-article-sort-by-number))
11605 ;; Suppress duplicates?
11606 (when gnus-suppress-duplicates
11607 (gnus-dup-suppress-articles))
11609 ;; We might want to build some more threads first.
11610 (when (and gnus-fetch-old-headers
11611 (eq gnus-headers-retrieved-by 'nov))
11612 (if (eq gnus-fetch-old-headers 'invisible)
11613 (gnus-build-all-threads)
11614 (gnus-build-old-threads)))
11615 ;; Let the Gnus agent mark articles as read.
11617 (gnus-agent-get-undownloaded-list))
11618 ;; Remove list identifiers from subject
11619 (when gnus-list-identifiers
11620 (gnus-summary-remove-list-identifiers))
11621 ;; First and last article in this newsgroup.
11622 (when gnus-newsgroup-headers
11623 (setq gnus-newsgroup-begin
11624 (mail-header-number (car gnus-newsgroup-headers))
11626 (mail-header-number
11627 (gnus-last-element gnus-newsgroup-headers))))
11628 (when gnus-use-scoring
11629 (gnus-possibly-score-headers))))
11631 (defun gnus-summary-insert-old-articles (&optional all)
11632 "Insert all old articles in this group.
11633 If ALL is non-nil, already read articles become readable.
11634 If ALL is a number, fetch this number of articles."
11637 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11640 ;; Some nntp servers lie about their active range. When
11641 ;; this happens, the active range can be in the millions.
11642 ;; Use a compressed range to avoid creating a huge list.
11643 (gnus-range-difference (list gnus-newsgroup-active) old))
11644 (setq len (gnus-range-length older))
11649 (let ((older-range (nreverse older)))
11653 (let* ((r (pop older-range))
11654 (min (if (numberp r) r (car r)))
11655 (max (if (numberp r) r (cdr r))))
11656 (while (and (<= min max)
11661 (setq older (gnus-uncompress-range older))))
11663 (setq older (gnus-uncompress-range older)))
11665 (when (and (numberp gnus-large-newsgroup)
11666 (> len gnus-large-newsgroup))
11667 (let* ((cursor-in-echo-area nil)
11668 (initial (gnus-parameter-large-newsgroup-initial
11669 gnus-newsgroup-name))
11673 "How many articles from %s (%s %d): "
11675 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11676 (if initial "max" "default")
11679 (cons (number-to-string initial)
11681 (unless (string-match "^[ \t]*$" input)
11682 (setq all (string-to-number input))
11684 (let ((older-range (nreverse older)))
11688 (let* ((r (pop older-range))
11689 (min (if (numberp r) r (car r)))
11690 (max (if (numberp r) r (cdr r))))
11691 (while (and (<= min max)
11695 max (1- max))))))))))
11696 (setq older (gnus-uncompress-range older))))
11698 (message "No old news.")
11699 (gnus-summary-insert-articles older)
11700 (gnus-summary-limit (gnus-sorted-nunion old older))))
11701 (gnus-summary-position-point)))
11703 (defun gnus-summary-insert-new-articles ()
11704 "Insert all new articles in this group."
11707 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11708 (old-active gnus-newsgroup-active)
11709 (nnmail-fetched-sources (list t))
11711 (setq gnus-newsgroup-active
11712 (gnus-activate-group gnus-newsgroup-name 'scan))
11713 (setq i (cdr gnus-newsgroup-active))
11714 (while (> i (cdr old-active))
11718 (message "No gnus is bad news.")
11719 (gnus-summary-insert-articles new)
11720 (setq gnus-newsgroup-unreads
11721 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11722 (gnus-summary-limit (gnus-sorted-nunion old new))))
11723 (gnus-summary-position-point)))
11725 (gnus-summary-make-all-marking-commands)
11727 (gnus-ems-redefine)
11729 (provide 'gnus-sum)
11731 (run-hooks 'gnus-sum-load-hook)
11733 ;;; gnus-sum.el ends here