1 ;;; gnus-sum.el --- summary mode commands for 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>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-cache-write-active "gnus-cache")
45 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
46 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
47 (autoload 'mm-uu-dissect "mm-uu")
48 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
49 "Deuglify broken Outlook (Express) articles and redisplay."
51 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
52 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
53 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
55 (defcustom gnus-kill-summary-on-exit t
56 "*If non-nil, kill the summary buffer when you exit from it.
57 If nil, the summary will become a \"*Dead Summary*\" buffer, and
58 it will be killed sometime later."
59 :group 'gnus-summary-exit
62 (defcustom gnus-fetch-old-headers nil
63 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
64 If an unread article in the group refers to an older, already read (or
65 just marked as read) article, the old article will not normally be
66 displayed in the Summary buffer. If this variable is non-nil, Gnus
67 will attempt to grab the headers to the old articles, and thereby
68 build complete threads. If it has the value `some', only enough
69 headers to connect otherwise loose threads will be displayed. This
70 variable can also be a number. In that case, no more than that number
71 of old headers will be fetched. If it has the value `invisible', all
72 old headers will be fetched, but none will be displayed.
74 The server has to support NOV for any of this to work."
76 :type '(choice (const :tag "off" nil)
79 (sexp :menu-tag "other" t)))
81 (defcustom gnus-refer-thread-limit 200
82 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
83 If t, fetch all the available old headers."
86 (sexp :menu-tag "other" t)))
88 (defcustom gnus-summary-make-false-root 'adopt
89 "*nil means that Gnus won't gather loose threads.
90 If the root of a thread has expired or been read in a previous
91 session, the information necessary to build a complete thread has been
92 lost. Instead of having many small sub-threads from this original thread
93 scattered all over the summary buffer, Gnus can gather them.
95 If non-nil, Gnus will try to gather all loose sub-threads from an
96 original thread into one large thread.
98 If this variable is non-nil, it should be one of `none', `adopt',
101 If this variable is `none', Gnus will not make a false root, but just
102 present the sub-threads after another.
103 If this variable is `dummy', Gnus will create a dummy root that will
104 have all the sub-threads as children.
105 If this variable is `adopt', Gnus will make one of the \"children\"
106 the parent and mark all the step-children as such.
107 If this variable is `empty', the \"children\" are printed with empty
108 subject fields. (Or rather, they will be printed with a string
109 given by the `gnus-summary-same-subject' variable.)"
111 :type '(choice (const :tag "off" nil)
117 (defcustom gnus-summary-make-false-root-always nil
118 "Always make a false dummy root."
122 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
123 "*A regexp to match subjects to be excluded from loose thread gathering.
124 As loose thread gathering is done on subjects only, that means that
125 there can be many false gatherings performed. By rooting out certain
126 common subjects, gathering might become saner."
130 (defcustom gnus-summary-gather-subject-limit nil
131 "*Maximum length of subject comparisons when gathering loose threads.
132 Use nil to compare full subjects. Setting this variable to a low
133 number will help gather threads that have been corrupted by
134 newsreaders chopping off subject lines, but it might also mean that
135 unrelated articles that have subject that happen to begin with the
136 same few characters will be incorrectly gathered.
138 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
141 :type '(choice (const :tag "off" nil)
143 (sexp :menu-tag "on" t)))
145 (defcustom gnus-simplify-subject-functions nil
146 "List of functions taking a string argument that simplify subjects.
147 The functions are applied recursively.
149 Useful functions to put in this list include:
150 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
151 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
153 :type '(repeat function))
155 (defcustom gnus-simplify-ignored-prefixes nil
156 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
158 :type '(choice (const :tag "off" nil)
161 (defcustom gnus-build-sparse-threads nil
162 "*If non-nil, fill in the gaps in threads.
163 If `some', only fill in the gaps that are needed to tie loose threads
164 together. If `more', fill in all leaf nodes that Gnus can find. If
165 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
167 :type '(choice (const :tag "off" nil)
170 (sexp :menu-tag "all" t)))
172 (defcustom gnus-summary-thread-gathering-function
173 'gnus-gather-threads-by-subject
174 "*Function used for gathering loose threads.
175 There are two pre-defined functions: `gnus-gather-threads-by-subject',
176 which only takes Subjects into consideration; and
177 `gnus-gather-threads-by-references', which compared the References
178 headers of the articles to find matches."
180 :type '(radio (function-item gnus-gather-threads-by-subject)
181 (function-item gnus-gather-threads-by-references)
182 (function :tag "other")))
184 (defcustom gnus-summary-same-subject ""
185 "*String indicating that the current article has the same subject as the previous.
186 This variable will only be used if the value of
187 `gnus-summary-make-false-root' is `empty'."
188 :group 'gnus-summary-format
191 (defcustom gnus-summary-goto-unread t
192 "*If t, many commands will go to the next unread article.
193 This applies to marking commands as well as other commands that
194 \"naturally\" select the next article, like, for instance, `SPC' at
195 the end of an article.
197 If nil, the marking commands do NOT go to the next unread article
198 \(they go to the next article instead). If `never', commands that
199 usually go to the next unread article, will go to the next article,
200 whether it is read or not."
201 :group 'gnus-summary-marks
202 :link '(custom-manual "(gnus)Setting Marks")
203 :type '(choice (const :tag "off" nil)
205 (sexp :menu-tag "on" t)))
207 (defcustom gnus-summary-default-score 0
208 "*Default article score level.
209 All scores generated by the score files will be added to this score.
210 If this variable is nil, scoring will be disabled."
211 :group 'gnus-score-default
212 :type '(choice (const :tag "disable")
215 (defcustom gnus-summary-default-high-score 0
216 "*Default threshold for a high scored article.
217 An article will be highlighted as high scored if its score is greater
219 :group 'gnus-score-default
222 (defcustom gnus-summary-default-low-score 0
223 "*Default threshold for a low scored article.
224 An article will be highlighted as low scored if its score is smaller
226 :group 'gnus-score-default
229 (defcustom gnus-summary-zcore-fuzz 0
230 "*Fuzziness factor for the zcore in the summary buffer.
231 Articles with scores closer than this to `gnus-summary-default-score'
233 :group 'gnus-summary-format
236 (defcustom gnus-simplify-subject-fuzzy-regexp nil
237 "*Strings to be removed when doing fuzzy matches.
238 This can either be a regular expression or list of regular expressions
239 that will be removed from subject strings if fuzzy subject
240 simplification is selected."
242 :type '(repeat regexp))
244 (defcustom gnus-show-threads t
245 "*If non-nil, display threads in summary mode."
249 (defcustom gnus-thread-hide-subtree nil
250 "*If non-nil, hide all threads initially.
251 This can be a predicate specifier which says which threads to hide.
252 If threads are hidden, you have to run the command
253 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
254 to expose hidden threads."
258 (defcustom gnus-thread-hide-killed t
259 "*If non-nil, hide killed threads automatically."
263 (defcustom gnus-thread-ignore-subject t
264 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
265 If nil, articles that have different subjects from their parents will
266 start separate threads."
270 (defcustom gnus-thread-operation-ignore-subject t
271 "*If non-nil, subjects will be ignored when doing thread commands.
272 This affects commands like `gnus-summary-kill-thread' and
273 `gnus-summary-lower-thread'.
275 If this variable is nil, articles in the same thread with different
276 subjects will not be included in the operation in question. If this
277 variable is `fuzzy', only articles that have subjects that are fuzzily
278 equal will be included."
280 :type '(choice (const :tag "off" nil)
284 (defcustom gnus-thread-indent-level 4
285 "*Number that says how much each sub-thread should be indented."
289 (defcustom gnus-auto-extend-newsgroup t
290 "*If non-nil, extend newsgroup forward and backward when requested."
291 :group 'gnus-summary-choose
294 (defcustom gnus-auto-select-first t
295 "*If non-nil, select the article under point.
296 Which article this is is controlled by the `gnus-auto-select-subject'
299 If you want to prevent automatic selection of articles in some
300 newsgroups, set the variable to nil in `gnus-select-group-hook'."
301 :group 'gnus-group-select
302 :type '(choice (const :tag "none" nil)
303 (sexp :menu-tag "first" t)))
305 (defcustom gnus-auto-select-subject 'unread
306 "*Says what subject to place under point when entering a group.
308 This variable can either be the symbols `first' (place point on the
309 first subject), `unread' (place point on the subject line of the first
310 unread article), `best' (place point on the subject line of the
311 higest-scored article), `unseen' (place point on the subject line of
312 the first unseen article), 'unseen-or-unread' (place point on the subject
313 line of the first unseen article or, if all article have been seen, on the
314 subject line of the first unread article), or a function to be called to
315 place point on some subject line."
316 :group 'gnus-group-select
317 :type '(choice (const best)
321 (const unseen-or-unread)))
323 (defcustom gnus-auto-select-next t
324 "*If non-nil, offer to go to the next group from the end of the previous.
325 If the value is t and the next newsgroup is empty, Gnus will exit
326 summary mode and go back to group mode. If the value is neither nil
327 nor t, Gnus will select the following unread newsgroup. In
328 particular, if the value is the symbol `quietly', the next unread
329 newsgroup will be selected without any confirmation, and if it is
330 `almost-quietly', the next group will be selected without any
331 confirmation if you are located on the last article in the group.
332 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
333 will go to the next group without confirmation."
334 :group 'gnus-summary-maneuvering
335 :type '(choice (const :tag "off" nil)
337 (const almost-quietly)
338 (const slightly-quietly)
339 (sexp :menu-tag "on" t)))
341 (defcustom gnus-auto-select-same nil
342 "*If non-nil, select the next article with the same subject.
343 If there are no more articles with the same subject, go to
344 the first unread article."
345 :group 'gnus-summary-maneuvering
348 (defcustom gnus-auto-goto-ignores 'unfetched
349 "*Says how to handle unfetched articles when maneuvering.
351 This variable can either be the symbols `nil' (maneuver to any
352 article), `undownloaded' (maneuvering while unplugged ignores articles
353 that have not been fetched), `always-undownloaded' (maneuvering always
354 ignores articles that have not been fetched), `unfetched' (maneuvering
355 ignores articles whose headers have not been fetched).
357 NOTE: The list of unfetched articles will always be nil when plugged
358 and, when unplugged, a subset of the undownloaded article list."
359 :group 'gnus-summary-maneuvering
360 :type '(choice (const :tag "None" nil)
361 (const :tag "Undownloaded when unplugged" undownloaded)
362 (const :tag "Undownloaded" always-undownloaded)
363 (const :tag "Unfetched" unfetched)))
365 (defcustom gnus-summary-check-current nil
366 "*If non-nil, consider the current article when moving.
367 The \"unread\" movement commands will stay on the same line if the
368 current article is unread."
369 :group 'gnus-summary-maneuvering
372 (defcustom gnus-auto-center-summary t
373 "*If non-nil, always center the current summary buffer.
374 In particular, if `vertical' do only vertical recentering. If non-nil
375 and non-`vertical', do both horizontal and vertical recentering."
376 :group 'gnus-summary-maneuvering
377 :type '(choice (const :tag "none" nil)
379 (integer :tag "height")
380 (sexp :menu-tag "both" t)))
382 (defvar gnus-auto-center-group t
383 "*If non-nil, always center the group buffer.")
385 (defcustom gnus-show-all-headers nil
386 "*If non-nil, don't hide any headers."
387 :group 'gnus-article-hiding
388 :group 'gnus-article-headers
391 (defcustom gnus-summary-ignore-duplicates nil
392 "*If non-nil, ignore articles with identical Message-ID headers."
396 (defcustom gnus-single-article-buffer t
397 "*If non-nil, display all articles in the same buffer.
398 If nil, each group will get its own article buffer."
399 :group 'gnus-article-various
402 (defcustom gnus-break-pages t
403 "*If non-nil, do page breaking on articles.
404 The page delimiter is specified by the `gnus-page-delimiter'
406 :group 'gnus-article-various
409 (defcustom gnus-move-split-methods nil
410 "*Variable used to suggest where articles are to be moved to.
411 It uses the same syntax as the `gnus-split-methods' variable.
412 However, whereas `gnus-split-methods' specifies file names as targets,
413 this variable specifies group names."
414 :group 'gnus-summary-mail
415 :type '(repeat (choice (list :value (fun) function)
416 (cons :value ("" "") regexp (repeat string))
419 (defcustom gnus-unread-mark ? ;Whitespace
420 "*Mark used for unread articles."
421 :group 'gnus-summary-marks
424 (defcustom gnus-ticked-mark ?!
425 "*Mark used for ticked articles."
426 :group 'gnus-summary-marks
429 (defcustom gnus-dormant-mark ??
430 "*Mark used for dormant articles."
431 :group 'gnus-summary-marks
434 (defcustom gnus-del-mark ?r
435 "*Mark used for del'd articles."
436 :group 'gnus-summary-marks
439 (defcustom gnus-read-mark ?R
440 "*Mark used for read articles."
441 :group 'gnus-summary-marks
444 (defcustom gnus-expirable-mark ?E
445 "*Mark used for expirable articles."
446 :group 'gnus-summary-marks
449 (defcustom gnus-killed-mark ?K
450 "*Mark used for killed articles."
451 :group 'gnus-summary-marks
454 (defcustom gnus-spam-mark ?$
455 "*Mark used for spam articles."
456 :group 'gnus-summary-marks
459 (defcustom gnus-souped-mark ?F
460 "*Mark used for souped articles."
461 :group 'gnus-summary-marks
464 (defcustom gnus-kill-file-mark ?X
465 "*Mark used for articles killed by kill files."
466 :group 'gnus-summary-marks
469 (defcustom gnus-low-score-mark ?Y
470 "*Mark used for articles with a low score."
471 :group 'gnus-summary-marks
474 (defcustom gnus-catchup-mark ?C
475 "*Mark used for articles that are caught up."
476 :group 'gnus-summary-marks
479 (defcustom gnus-replied-mark ?A
480 "*Mark used for articles that have been replied to."
481 :group 'gnus-summary-marks
484 (defcustom gnus-forwarded-mark ?F
485 "*Mark used for articles that have been forwarded."
486 :group 'gnus-summary-marks
489 (defcustom gnus-recent-mark ?N
490 "*Mark used for articles that are recent."
491 :group 'gnus-summary-marks
494 (defcustom gnus-cached-mark ?*
495 "*Mark used for articles that are in the cache."
496 :group 'gnus-summary-marks
499 (defcustom gnus-saved-mark ?S
500 "*Mark used for articles that have been saved."
501 :group 'gnus-summary-marks
504 (defcustom gnus-unseen-mark ?.
505 "*Mark used for articles that haven't been seen."
506 :group 'gnus-summary-marks
509 (defcustom gnus-no-mark ? ;Whitespace
510 "*Mark used for articles that have no other secondary mark."
511 :group 'gnus-summary-marks
514 (defcustom gnus-ancient-mark ?O
515 "*Mark used for ancient articles."
516 :group 'gnus-summary-marks
519 (defcustom gnus-sparse-mark ?Q
520 "*Mark used for sparsely reffed articles."
521 :group 'gnus-summary-marks
524 (defcustom gnus-canceled-mark ?G
525 "*Mark used for canceled articles."
526 :group 'gnus-summary-marks
529 (defcustom gnus-duplicate-mark ?M
530 "*Mark used for duplicate articles."
531 :group 'gnus-summary-marks
534 (defcustom gnus-undownloaded-mark ?-
535 "*Mark used for articles that weren't downloaded."
536 :group 'gnus-summary-marks
539 (defcustom gnus-downloaded-mark ?+
540 "*Mark used for articles that were downloaded."
541 :group 'gnus-summary-marks
544 (defcustom gnus-downloadable-mark ?%
545 "*Mark used for articles that are to be downloaded."
546 :group 'gnus-summary-marks
549 (defcustom gnus-unsendable-mark ?=
550 "*Mark used for articles that won't be sent."
551 :group 'gnus-summary-marks
554 (defcustom gnus-score-over-mark ?+
555 "*Score mark used for articles with high scores."
556 :group 'gnus-summary-marks
559 (defcustom gnus-score-below-mark ?-
560 "*Score mark used for articles with low scores."
561 :group 'gnus-summary-marks
564 (defcustom gnus-empty-thread-mark ? ;Whitespace
565 "*There is no thread under the article."
566 :group 'gnus-summary-marks
569 (defcustom gnus-not-empty-thread-mark ?=
570 "*There is a thread under the article."
571 :group 'gnus-summary-marks
574 (defcustom gnus-view-pseudo-asynchronously nil
575 "*If non-nil, Gnus will view pseudo-articles asynchronously."
576 :group 'gnus-extract-view
579 (defcustom gnus-auto-expirable-marks
580 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
581 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
582 gnus-souped-mark gnus-duplicate-mark)
583 "*The list of marks converted into expiration if a group is auto-expirable."
586 :type '(repeat character))
588 (defcustom gnus-inhibit-user-auto-expire t
589 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
594 (defcustom gnus-view-pseudos nil
595 "*If `automatic', pseudo-articles will be viewed automatically.
596 If `not-confirm', pseudos will be viewed automatically, and the user
597 will not be asked to confirm the command."
598 :group 'gnus-extract-view
599 :type '(choice (const :tag "off" nil)
601 (const not-confirm)))
603 (defcustom gnus-view-pseudos-separately t
604 "*If non-nil, one pseudo-article will be created for each file to be viewed.
605 If nil, all files that use the same viewing command will be given as a
606 list of parameters to that command."
607 :group 'gnus-extract-view
610 (defcustom gnus-insert-pseudo-articles t
611 "*If non-nil, insert pseudo-articles when decoding articles."
612 :group 'gnus-extract-view
615 (defcustom gnus-summary-dummy-line-format
617 "*The format specification for the dummy roots in the summary buffer.
618 It works along the same lines as a normal formatting string,
619 with some simple extensions.
623 General format specifiers can also be used.
624 See `(gnus)Formatting Variables'."
625 :link '(custom-manual "(gnus)Formatting Variables")
626 :group 'gnus-threading
629 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
630 "*The format specification for the summary mode line.
631 It works along the same lines as a normal formatting string,
632 with some simple extensions:
635 %p Unprefixed group name
636 %A Current article number
637 %z Current article score
639 %U Number of unread articles in the group
640 %e Number of unselected articles in the group
641 %Z A string with unread/unselected article counts
642 %g Shortish group name
643 %S Subject of the current article
645 %s Current score file name
646 %d Number of dormant articles
647 %r Number of articles that have been marked as read in this session
648 %E Number of articles expunged by the score files"
649 :group 'gnus-summary-format
652 (defcustom gnus-list-identifiers nil
653 "Regexp that matches list identifiers to be removed from subject.
654 This can also be a list of regexps."
656 :group 'gnus-summary-format
657 :group 'gnus-article-hiding
658 :type '(choice (const :tag "none" nil)
660 (repeat :value (".*") regexp)))
662 (defcustom gnus-summary-mark-below 0
663 "*Mark all articles with a score below this variable as read.
664 This variable is local to each summary buffer and usually set by the
666 :group 'gnus-score-default
669 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
670 "*List of functions used for sorting articles in the summary buffer.
672 Each function takes two articles and returns non-nil if the first
673 article should be sorted before the other. If you use more than one
674 function, the primary sort function should be the last. You should
675 probably always include `gnus-article-sort-by-number' in the list of
676 sorting functions -- preferably first. Also note that sorting by date
677 is often much slower than sorting by number, and the sorting order is
678 very similar. (Sorting by date means sorting by the time the message
679 was sent, sorting by number means sorting by arrival time.)
681 Ready-made functions include `gnus-article-sort-by-number',
682 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
683 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
684 and `gnus-article-sort-by-score'.
686 When threading is turned on, the variable `gnus-thread-sort-functions'
687 controls how articles are sorted."
688 :group 'gnus-summary-sort
689 :type '(repeat (choice (function-item gnus-article-sort-by-number)
690 (function-item gnus-article-sort-by-author)
691 (function-item gnus-article-sort-by-subject)
692 (function-item gnus-article-sort-by-date)
693 (function-item gnus-article-sort-by-score)
694 (function-item gnus-article-sort-by-random)
695 (function :tag "other"))))
697 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
698 "*List of functions used for sorting threads in the summary buffer.
699 By default, threads are sorted by article number.
701 Each function takes two threads and returns non-nil if the first
702 thread should be sorted before the other. If you use more than one
703 function, the primary sort function should be the last. You should
704 probably always include `gnus-thread-sort-by-number' in the list of
705 sorting functions -- preferably first. Also note that sorting by date
706 is often much slower than sorting by number, and the sorting order is
707 very similar. (Sorting by date means sorting by the time the message
708 was sent, sorting by number means sorting by arrival time.)
710 Ready-made functions include `gnus-thread-sort-by-number',
711 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
712 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
713 `gnus-thread-sort-by-most-recent-number',
714 `gnus-thread-sort-by-most-recent-date',
715 `gnus-thread-sort-by-random', and
716 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
718 When threading is turned off, the variable
719 `gnus-article-sort-functions' controls how articles are sorted."
720 :group 'gnus-summary-sort
721 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
722 (function-item gnus-thread-sort-by-author)
723 (function-item gnus-thread-sort-by-subject)
724 (function-item gnus-thread-sort-by-date)
725 (function-item gnus-thread-sort-by-score)
726 (function-item gnus-thread-sort-by-total-score)
727 (function-item gnus-thread-sort-by-random)
728 (function :tag "other"))))
730 (defcustom gnus-thread-score-function '+
731 "*Function used for calculating the total score of a thread.
733 The function is called with the scores of the article and each
734 subthread and should then return the score of the thread.
736 Some functions you can use are `+', `max', or `min'."
737 :group 'gnus-summary-sort
740 (defcustom gnus-summary-expunge-below nil
741 "All articles that have a score less than this variable will be expunged.
742 This variable is local to the summary buffers."
743 :group 'gnus-score-default
744 :type '(choice (const :tag "off" nil)
747 (defcustom gnus-thread-expunge-below nil
748 "All threads that have a total score less than this variable will be expunged.
749 See `gnus-thread-score-function' for en explanation of what a
752 This variable is local to the summary buffers."
753 :group 'gnus-threading
754 :group 'gnus-score-default
755 :type '(choice (const :tag "off" nil)
758 (defcustom gnus-summary-mode-hook nil
759 "*A hook for Gnus summary mode.
760 This hook is run before any variables are set in the summary buffer."
761 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
762 :group 'gnus-summary-various
765 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
766 (when (featurep 'xemacs)
767 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
768 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
769 (add-hook 'gnus-summary-mode-hook
770 'gnus-xmas-switch-horizontal-scrollbar-off))
772 (defcustom gnus-summary-menu-hook nil
773 "*Hook run after the creation of the summary mode menu."
774 :group 'gnus-summary-visual
777 (defcustom gnus-summary-exit-hook nil
778 "*A hook called on exit from the summary buffer.
779 It will be called with point in the group buffer."
780 :group 'gnus-summary-exit
783 (defcustom gnus-summary-prepare-hook nil
784 "*A hook called after the summary buffer has been generated.
785 If you want to modify the summary buffer, you can use this hook."
786 :group 'gnus-summary-various
789 (defcustom gnus-summary-prepared-hook nil
790 "*A hook called as the last thing after the summary buffer has been generated."
791 :group 'gnus-summary-various
794 (defcustom gnus-summary-generate-hook nil
795 "*A hook run just before generating the summary buffer.
796 This hook is commonly used to customize threading variables and the
798 :group 'gnus-summary-various
801 (defcustom gnus-select-group-hook nil
802 "*A hook called when a newsgroup is selected.
804 If you'd like to simplify subjects like the
805 `gnus-summary-next-same-subject' command does, you can use the
808 (add-hook gnus-select-group-hook
810 (mapcar (lambda (header)
811 (mail-header-set-subject
813 (gnus-simplify-subject
814 (mail-header-subject header) 're-only)))
815 gnus-newsgroup-headers)))"
816 :group 'gnus-group-select
819 (defcustom gnus-select-article-hook nil
820 "*A hook called when an article is selected."
821 :group 'gnus-summary-choose
822 :options '(gnus-agent-fetch-selected-article)
825 (defcustom gnus-visual-mark-article-hook
826 (list 'gnus-highlight-selected-summary)
827 "*Hook run after selecting an article in the summary buffer.
828 It is meant to be used for highlighting the article in some way. It
829 is not run if `gnus-visual' is nil."
830 :group 'gnus-summary-visual
833 (defcustom gnus-parse-headers-hook nil
834 "*A hook called before parsing the headers."
838 (defcustom gnus-exit-group-hook nil
839 "*A hook called when exiting summary mode.
840 This hook is not called from the non-updating exit commands like `Q'."
844 (defcustom gnus-summary-update-hook
845 (list 'gnus-summary-highlight-line)
846 "*A hook called when a summary line is changed.
847 The hook will not be called if `gnus-visual' is nil.
849 The default function `gnus-summary-highlight-line' will
850 highlight the line according to the `gnus-summary-highlight'
852 :group 'gnus-summary-visual
855 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
856 "*A hook called when an article is selected for the first time.
857 The hook is intended to mark an article as read (or unread)
858 automatically when it is selected."
859 :group 'gnus-summary-choose
862 (defcustom gnus-group-no-more-groups-hook nil
863 "*A hook run when returning to group mode having no more (unread) groups."
864 :group 'gnus-group-select
867 (defcustom gnus-ps-print-hook nil
868 "*A hook run before ps-printing something from Gnus."
872 (defcustom gnus-summary-article-move-hook nil
873 "*A hook called after an article is moved, copied, respooled, or crossposted."
877 (defcustom gnus-summary-article-delete-hook nil
878 "*A hook called after an article is deleted."
882 (defcustom gnus-summary-article-expire-hook nil
883 "*A hook called after an article is expired."
887 (defcustom gnus-summary-display-arrow
888 (and (fboundp 'display-graphic-p)
890 "*If non-nil, display an arrow highlighting the current article."
895 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
896 "Face used for highlighting the current article in the summary buffer."
897 :group 'gnus-summary-visual
900 (defvar gnus-tmp-downloaded nil)
902 (defcustom gnus-summary-highlight
903 '(((eq mark gnus-canceled-mark)
904 . gnus-summary-cancelled-face)
905 ((and uncached (> score default-high))
906 . gnus-summary-high-undownloaded-face)
907 ((and uncached (< score default-low))
908 . gnus-summary-low-undownloaded-face)
910 . gnus-summary-normal-undownloaded-face)
911 ((and (> score default-high)
912 (or (eq mark gnus-dormant-mark)
913 (eq mark gnus-ticked-mark)))
914 . gnus-summary-high-ticked-face)
915 ((and (< score default-low)
916 (or (eq mark gnus-dormant-mark)
917 (eq mark gnus-ticked-mark)))
918 . gnus-summary-low-ticked-face)
919 ((or (eq mark gnus-dormant-mark)
920 (eq mark gnus-ticked-mark))
921 . gnus-summary-normal-ticked-face)
922 ((and (> score default-high) (eq mark gnus-ancient-mark))
923 . gnus-summary-high-ancient-face)
924 ((and (< score default-low) (eq mark gnus-ancient-mark))
925 . gnus-summary-low-ancient-face)
926 ((eq mark gnus-ancient-mark)
927 . gnus-summary-normal-ancient-face)
928 ((and (> score default-high) (eq mark gnus-unread-mark))
929 . gnus-summary-high-unread-face)
930 ((and (< score default-low) (eq mark gnus-unread-mark))
931 . gnus-summary-low-unread-face)
932 ((eq mark gnus-unread-mark)
933 . gnus-summary-normal-unread-face)
934 ((> score default-high)
935 . gnus-summary-high-read-face)
936 ((< score default-low)
937 . gnus-summary-low-read-face)
939 . gnus-summary-normal-read-face))
940 "*Controls the highlighting of summary buffer lines.
942 A list of (FORM . FACE) pairs. When deciding how a a particular
943 summary line should be displayed, each form is evaluated. The content
944 of the face field after the first true form is used. You can change
945 how those summary lines are displayed, by editing the face field.
947 You can use the following variables in the FORM field.
949 score: The article's score
950 default: The default article score.
951 default-high: The default score for high scored articles.
952 default-low: The default score for low scored articles.
953 below: The score below which articles are automatically marked as read.
954 mark: The articles mark."
955 :group 'gnus-summary-visual
956 :type '(repeat (cons (sexp :tag "Form" nil)
959 (defcustom gnus-alter-header-function nil
960 "Function called to allow alteration of article header structures.
961 The function is called with one parameter, the article header vector,
962 which it may alter in any way."
963 :type '(choice (const :tag "None" nil)
965 :group 'gnus-summary)
967 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
968 "Variable that says which function should be used to decode a string with encoded words.")
970 (defcustom gnus-extra-headers '(To Newsgroups)
971 "*Extra headers to parse."
974 :type '(repeat symbol))
976 (defcustom gnus-ignored-from-addresses
977 (and user-mail-address (regexp-quote user-mail-address))
978 "*Regexp of From headers that may be suppressed in favor of To headers."
983 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
984 "List of charsets that should be ignored.
985 When these charsets are used in the \"charset\" parameter, the
986 default charset will be used instead."
988 :type '(repeat symbol)
989 :group 'gnus-charset)
991 (gnus-define-group-parameter
995 "Return the ignored charsets of GROUP."
996 :variable gnus-group-ignored-charsets-alist
998 '(("alt\\.chinese\\.text" iso-8859-1))
1000 "Alist of regexps (to match group names) and charsets that should be ignored.
1001 When these charsets are used in the \"charset\" parameter, the
1002 default charset will be used instead."
1003 :variable-group gnus-charset
1004 :variable-type '(repeat (cons (regexp :tag "Group")
1006 :parameter-type '(choice :tag "Ignored charsets"
1009 :parameter-document "\
1010 List of charsets that should be ignored.
1012 When these charsets are used in the \"charset\" parameter, the
1013 default charset will be used instead.")
1015 (defcustom gnus-group-highlight-words-alist nil
1016 "Alist of group regexps and highlight regexps.
1017 This variable uses the same syntax as `gnus-emphasis-alist'."
1019 :type '(repeat (cons (regexp :tag "Group")
1020 (repeat (list (regexp :tag "Highlight regexp")
1021 (number :tag "Group for entire word" 0)
1022 (number :tag "Group for displayed part" 0)
1024 gnus-emphasis-highlight-words)))))
1025 :group 'gnus-summary-visual)
1027 (defcustom gnus-summary-show-article-charset-alist
1029 "Alist of number and charset.
1030 The article will be shown with the charset corresponding to the
1032 For example: ((1 . cn-gb-2312) (2 . big5))."
1034 :type '(repeat (cons (number :tag "Argument" 1)
1035 (symbol :tag "Charset")))
1036 :group 'gnus-charset)
1038 (defcustom gnus-preserve-marks t
1039 "Whether marks are preserved when moving, copying and respooling messages."
1042 :group 'gnus-summary-marks)
1044 (defcustom gnus-alter-articles-to-read-function nil
1045 "Function to be called to alter the list of articles to be selected."
1046 :type '(choice (const nil) function)
1047 :group 'gnus-summary)
1049 (defcustom gnus-orphan-score nil
1050 "*All orphans get this score added. Set in the score file."
1051 :group 'gnus-score-default
1052 :type '(choice (const nil)
1055 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1056 "*A regexp to match MIME parts when saving multiple parts of a
1057 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1058 This regexp will be used by default when prompting the user for which
1059 type of files to save."
1060 :group 'gnus-summary
1063 (defcustom gnus-read-all-available-headers nil
1064 "Whether Gnus should parse all headers made available to it.
1065 This is mostly relevant for slow backends where the user may
1066 wish to widen the summary buffer to include all headers
1067 that were fetched. Say, for nnultimate groups."
1068 :group 'gnus-summary
1069 :type '(choice boolean regexp))
1071 (defcustom gnus-summary-muttprint-program "muttprint"
1072 "Command (and optional arguments) used to run Muttprint."
1074 :group 'gnus-summary
1077 (defcustom gnus-article-loose-mime nil
1078 "If non-nil, don't require MIME-Version header.
1079 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1080 supply the MIME-Version header or deliberately strip it From the mail.
1081 Set it to non-nil, Gnus will treat some articles as MIME even if
1082 the MIME-Version header is missed."
1085 :group 'gnus-article-mime)
1087 (defcustom gnus-article-emulate-mime t
1088 "If non-nil, use MIME emulation for uuencode and the like.
1089 This means that Gnus will search message bodies for text that look
1090 like uuencoded bits, yEncoded bits, and so on, and present that using
1091 the normal Gnus MIME machinery."
1093 :group 'gnus-article-mime)
1095 ;;; Internal variables
1097 (defvar gnus-summary-display-cache nil)
1098 (defvar gnus-article-mime-handles nil)
1099 (defvar gnus-article-decoded-p nil)
1100 (defvar gnus-article-charset nil)
1101 (defvar gnus-article-ignored-charsets nil)
1102 (defvar gnus-scores-exclude-files nil)
1103 (defvar gnus-page-broken nil)
1105 (defvar gnus-original-article nil)
1106 (defvar gnus-article-internal-prepare-hook nil)
1107 (defvar gnus-newsgroup-process-stack nil)
1109 (defvar gnus-thread-indent-array nil)
1110 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1111 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1112 "Function called to sort the articles within a thread after it has been gathered together.")
1114 (defvar gnus-summary-save-parts-type-history nil)
1115 (defvar gnus-summary-save-parts-last-directory nil)
1117 ;; Avoid highlighting in kill files.
1118 (defvar gnus-summary-inhibit-highlight nil)
1119 (defvar gnus-newsgroup-selected-overlay nil)
1120 (defvar gnus-inhibit-limiting nil)
1121 (defvar gnus-newsgroup-adaptive-score-file nil)
1122 (defvar gnus-current-score-file nil)
1123 (defvar gnus-current-move-group nil)
1124 (defvar gnus-current-copy-group nil)
1125 (defvar gnus-current-crosspost-group nil)
1126 (defvar gnus-newsgroup-display nil)
1128 (defvar gnus-newsgroup-dependencies nil)
1129 (defvar gnus-newsgroup-adaptive nil)
1130 (defvar gnus-summary-display-article-function nil)
1131 (defvar gnus-summary-highlight-line-function nil
1132 "Function called after highlighting a summary line.")
1134 (defvar gnus-summary-line-format-alist
1135 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1136 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1137 (?s gnus-tmp-subject-or-nil ?s)
1138 (?n gnus-tmp-name ?s)
1139 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1141 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1143 (?F gnus-tmp-from ?s)
1144 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1145 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1146 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1147 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1148 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1149 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1150 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1151 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1152 (?L gnus-tmp-lines ?s)
1153 (?O gnus-tmp-downloaded ?c)
1154 (?I gnus-tmp-indentation ?s)
1155 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1156 (?R gnus-tmp-replied ?c)
1157 (?\[ gnus-tmp-opening-bracket ?c)
1158 (?\] gnus-tmp-closing-bracket ?c)
1159 (?\> (make-string gnus-tmp-level ? ) ?s)
1160 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1161 (?i gnus-tmp-score ?d)
1162 (?z gnus-tmp-score-char ?c)
1163 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1164 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1165 (?U gnus-tmp-unread ?c)
1166 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1168 (?t (gnus-summary-number-of-articles-in-thread
1169 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1171 (?e (gnus-summary-number-of-articles-in-thread
1172 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1174 (?u gnus-tmp-user-defined ?s)
1175 (?P (gnus-pick-line-number) ?d)
1176 (?B gnus-tmp-thread-tree-header-string ?s)
1177 (user-date (gnus-user-date
1178 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1179 "An alist of format specifications that can appear in summary lines.
1180 These are paired with what variables they correspond with, along with
1181 the type of the variable (string, integer, character, etc).")
1183 (defvar gnus-summary-dummy-line-format-alist
1184 `((?S gnus-tmp-subject ?s)
1185 (?N gnus-tmp-number ?d)
1186 (?u gnus-tmp-user-defined ?s)))
1188 (defvar gnus-summary-mode-line-format-alist
1189 `((?G gnus-tmp-group-name ?s)
1190 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1191 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1192 (?A gnus-tmp-article-number ?d)
1193 (?Z gnus-tmp-unread-and-unselected ?s)
1194 (?V gnus-version ?s)
1195 (?U gnus-tmp-unread-and-unticked ?d)
1196 (?S gnus-tmp-subject ?s)
1197 (?e gnus-tmp-unselected ?d)
1198 (?u gnus-tmp-user-defined ?s)
1199 (?d (length gnus-newsgroup-dormant) ?d)
1200 (?t (length gnus-newsgroup-marked) ?d)
1201 (?h (length gnus-newsgroup-spam-marked) ?d)
1202 (?r (length gnus-newsgroup-reads) ?d)
1203 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1204 (?E gnus-newsgroup-expunged-tally ?d)
1205 (?s (gnus-current-score-file-nondirectory) ?s)))
1207 (defvar gnus-last-search-regexp nil
1208 "Default regexp for article search command.")
1210 (defvar gnus-last-shell-command nil
1211 "Default shell command on article.")
1213 (defvar gnus-newsgroup-agentized nil
1214 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1215 (defvar gnus-newsgroup-begin nil)
1216 (defvar gnus-newsgroup-end nil)
1217 (defvar gnus-newsgroup-last-rmail nil)
1218 (defvar gnus-newsgroup-last-mail nil)
1219 (defvar gnus-newsgroup-last-folder nil)
1220 (defvar gnus-newsgroup-last-file nil)
1221 (defvar gnus-newsgroup-auto-expire nil)
1222 (defvar gnus-newsgroup-active nil)
1224 (defvar gnus-newsgroup-data nil)
1225 (defvar gnus-newsgroup-data-reverse nil)
1226 (defvar gnus-newsgroup-limit nil)
1227 (defvar gnus-newsgroup-limits nil)
1229 (defvar gnus-newsgroup-unreads nil
1230 "Sorted list of unread articles in the current newsgroup.")
1232 (defvar gnus-newsgroup-unselected nil
1233 "Sorted list of unselected unread articles in the current newsgroup.")
1235 (defvar gnus-newsgroup-reads nil
1236 "Alist of read articles and article marks in the current newsgroup.")
1238 (defvar gnus-newsgroup-expunged-tally nil)
1240 (defvar gnus-newsgroup-marked nil
1241 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1243 (defvar gnus-newsgroup-spam-marked nil
1244 "List of ranges of articles that have been marked as spam.")
1246 (defvar gnus-newsgroup-killed nil
1247 "List of ranges of articles that have been through the scoring process.")
1249 (defvar gnus-newsgroup-cached nil
1250 "Sorted list of articles that come from the article cache.")
1252 (defvar gnus-newsgroup-saved nil
1253 "List of articles that have been saved.")
1255 (defvar gnus-newsgroup-kill-headers nil)
1257 (defvar gnus-newsgroup-replied nil
1258 "List of articles that have been replied to in the current newsgroup.")
1260 (defvar gnus-newsgroup-forwarded nil
1261 "List of articles that have been forwarded in the current newsgroup.")
1263 (defvar gnus-newsgroup-recent nil
1264 "List of articles that have are recent in the current newsgroup.")
1266 (defvar gnus-newsgroup-expirable nil
1267 "Sorted list of articles in the current newsgroup that can be expired.")
1269 (defvar gnus-newsgroup-processable nil
1270 "List of articles in the current newsgroup that can be processed.")
1272 (defvar gnus-newsgroup-downloadable nil
1273 "Sorted list of articles in the current newsgroup that can be processed.")
1275 (defvar gnus-newsgroup-unfetched nil
1276 "Sorted list of articles in the current newsgroup whose headers have
1277 not been fetched into the agent.
1279 This list will always be a subset of gnus-newsgroup-undownloaded.")
1281 (defvar gnus-newsgroup-undownloaded nil
1282 "List of articles in the current newsgroup that haven't been downloaded.")
1284 (defvar gnus-newsgroup-unsendable nil
1285 "List of articles in the current newsgroup that won't be sent.")
1287 (defvar gnus-newsgroup-bookmarks nil
1288 "List of articles in the current newsgroup that have bookmarks.")
1290 (defvar gnus-newsgroup-dormant nil
1291 "Sorted list of dormant articles in the current newsgroup.")
1293 (defvar gnus-newsgroup-unseen nil
1294 "List of unseen articles in the current newsgroup.")
1296 (defvar gnus-newsgroup-seen nil
1297 "Range of seen articles in the current newsgroup.")
1299 (defvar gnus-newsgroup-articles nil
1300 "List of articles in the current newsgroup.")
1302 (defvar gnus-newsgroup-scored nil
1303 "List of scored articles in the current newsgroup.")
1305 (defvar gnus-newsgroup-headers nil
1306 "List of article headers in the current newsgroup.")
1308 (defvar gnus-newsgroup-threads nil)
1310 (defvar gnus-newsgroup-prepared nil
1311 "Whether the current group has been prepared properly.")
1313 (defvar gnus-newsgroup-ancient nil
1314 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1316 (defvar gnus-newsgroup-sparse nil)
1318 (defvar gnus-current-article nil)
1319 (defvar gnus-article-current nil)
1320 (defvar gnus-current-headers nil)
1321 (defvar gnus-have-all-headers nil)
1322 (defvar gnus-last-article nil)
1323 (defvar gnus-newsgroup-history nil)
1324 (defvar gnus-newsgroup-charset nil)
1325 (defvar gnus-newsgroup-ephemeral-charset nil)
1326 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1328 (defvar gnus-article-before-search nil)
1330 (defvar gnus-summary-local-variables
1331 '(gnus-newsgroup-name
1332 gnus-newsgroup-begin gnus-newsgroup-end
1333 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1334 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1335 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1336 gnus-newsgroup-unselected gnus-newsgroup-marked
1337 gnus-newsgroup-spam-marked
1338 gnus-newsgroup-reads gnus-newsgroup-saved
1339 gnus-newsgroup-replied gnus-newsgroup-forwarded
1340 gnus-newsgroup-recent
1341 gnus-newsgroup-expirable
1342 gnus-newsgroup-processable gnus-newsgroup-killed
1343 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1344 gnus-newsgroup-unfetched
1345 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1346 gnus-newsgroup-seen gnus-newsgroup-articles
1347 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1348 gnus-newsgroup-headers gnus-newsgroup-threads
1349 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1350 gnus-current-article gnus-current-headers gnus-have-all-headers
1351 gnus-last-article gnus-article-internal-prepare-hook
1352 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1353 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1354 gnus-thread-expunge-below
1355 gnus-score-alist gnus-current-score-file
1356 (gnus-summary-expunge-below . global)
1357 (gnus-summary-mark-below . global)
1358 (gnus-orphan-score . global)
1359 gnus-newsgroup-active gnus-scores-exclude-files
1360 gnus-newsgroup-history gnus-newsgroup-ancient
1361 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1362 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1363 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1364 (gnus-newsgroup-expunged-tally . 0)
1365 gnus-cache-removable-articles gnus-newsgroup-cached
1366 gnus-newsgroup-data gnus-newsgroup-data-reverse
1367 gnus-newsgroup-limit gnus-newsgroup-limits
1368 gnus-newsgroup-charset gnus-newsgroup-display)
1369 "Variables that are buffer-local to the summary buffers.")
1371 (defvar gnus-newsgroup-variables nil
1372 "A list of variables that have separate values in different newsgroups.
1373 A list of newsgroup (summary buffer) local variables, or cons of
1374 variables and their default values (when the default values are not
1375 nil), that should be made global while the summary buffer is active.
1376 These variables can be used to set variables in the group parameters
1377 while still allowing them to affect operations done in other
1378 buffers. For example:
1380 \(setq gnus-newsgroup-variables
1381 '(message-use-followup-to
1382 (gnus-visible-headers .
1383 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1386 ;; Byte-compiler warning.
1388 ;; Bind features so that require will believe that gnus-sum has
1389 ;; already been loaded (avoids infinite recursion)
1390 (let ((features (cons 'gnus-sum features)))
1391 ;; Several of the declarations in gnus-sum are needed to load the
1392 ;; following files. Right now, these definitions have been
1393 ;; compiled but not defined (evaluated). We could either do a
1394 ;; eval-and-compile about all of the declarations or evaluate the
1396 (if (boundp 'gnus-newsgroup-variables)
1398 (load "gnus-sum.el" t t t))
1400 (require 'gnus-agent)
1401 (require 'gnus-art)))
1405 (defvar gnus-decode-encoded-word-methods
1406 '(mail-decode-encoded-word-string)
1407 "List of methods used to decode encoded words.
1409 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1410 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1411 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1412 whose names match REGEXP.
1415 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1416 mail-decode-encoded-word-string
1417 (\"chinese\" . rfc1843-decode-string))")
1419 (defvar gnus-decode-encoded-word-methods-cache nil)
1421 (defun gnus-multi-decode-encoded-word-string (string)
1422 "Apply the functions from `gnus-encoded-word-methods' that match."
1423 (unless (and gnus-decode-encoded-word-methods-cache
1424 (eq gnus-newsgroup-name
1425 (car gnus-decode-encoded-word-methods-cache)))
1426 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1429 (nconc gnus-decode-encoded-word-methods-cache (list x))
1430 (if (and gnus-newsgroup-name
1431 (string-match (car x) gnus-newsgroup-name))
1432 (nconc gnus-decode-encoded-word-methods-cache
1434 gnus-decode-encoded-word-methods))
1435 (let ((xlist gnus-decode-encoded-word-methods-cache))
1438 (setq string (funcall (pop xlist) string))))
1441 ;; Subject simplification.
1443 (defun gnus-simplify-whitespace (str)
1444 "Remove excessive whitespace from STR."
1446 (while (string-match "[ \t][ \t]+" str)
1447 (setq str (concat (substring str 0 (match-beginning 0))
1449 (substring str (match-end 0)))))
1451 (when (string-match "^[ \t]+" str)
1452 (setq str (substring str (match-end 0))))
1454 (when (string-match "[ \t]+$" str)
1455 (setq str (substring str 0 (match-beginning 0))))
1458 (defun gnus-simplify-all-whitespace (str)
1459 "Remove all whitespace from STR."
1460 (while (string-match "[ \t\n]+" str)
1461 (setq str (replace-match "" nil nil str)))
1464 (defsubst gnus-simplify-subject-re (subject)
1465 "Remove \"Re:\" from subject lines."
1466 (if (string-match message-subject-re-regexp subject)
1467 (substring subject (match-end 0))
1470 (defun gnus-simplify-subject (subject &optional re-only)
1471 "Remove `Re:' and words in parentheses.
1472 If RE-ONLY is non-nil, strip leading `Re:'s only."
1473 (let ((case-fold-search t)) ;Ignore case.
1474 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1475 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1476 (setq subject (substring subject (match-end 0))))
1477 ;; Remove uninteresting prefixes.
1478 (when (and (not re-only)
1479 gnus-simplify-ignored-prefixes
1480 (string-match gnus-simplify-ignored-prefixes subject))
1481 (setq subject (substring subject (match-end 0))))
1482 ;; Remove words in parentheses from end.
1484 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1485 (setq subject (substring subject 0 (match-beginning 0)))))
1486 ;; Return subject string.
1489 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1491 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1492 (goto-char (point-min))
1493 (while (re-search-forward regexp nil t)
1494 (replace-match (or newtext ""))))
1496 (defun gnus-simplify-buffer-fuzzy ()
1497 "Simplify string in the buffer fuzzily.
1498 The string in the accessible portion of the current buffer is simplified.
1499 It is assumed to be a single-line subject.
1500 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1501 matter is removed. Additional things can be deleted by setting
1502 `gnus-simplify-subject-fuzzy-regexp'."
1503 (let ((case-fold-search t)
1505 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1507 (while (not (eq modified-tick (buffer-modified-tick)))
1508 (setq modified-tick (buffer-modified-tick))
1510 ((listp gnus-simplify-subject-fuzzy-regexp)
1511 (mapcar 'gnus-simplify-buffer-fuzzy-step
1512 gnus-simplify-subject-fuzzy-regexp))
1513 (gnus-simplify-subject-fuzzy-regexp
1514 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1515 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1516 (gnus-simplify-buffer-fuzzy-step
1517 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1518 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1520 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1521 (gnus-simplify-buffer-fuzzy-step " +" " ")
1522 (gnus-simplify-buffer-fuzzy-step " $")
1523 (gnus-simplify-buffer-fuzzy-step "^ +")))
1525 (defun gnus-simplify-subject-fuzzy (subject)
1526 "Simplify a subject string fuzzily.
1527 See `gnus-simplify-buffer-fuzzy' for details."
1529 (gnus-set-work-buffer)
1530 (let ((case-fold-search t))
1531 ;; Remove uninteresting prefixes.
1532 (when (and gnus-simplify-ignored-prefixes
1533 (string-match gnus-simplify-ignored-prefixes subject))
1534 (setq subject (substring subject (match-end 0))))
1536 (inline (gnus-simplify-buffer-fuzzy))
1539 (defsubst gnus-simplify-subject-fully (subject)
1540 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1542 (gnus-simplify-subject-functions
1543 (gnus-map-function gnus-simplify-subject-functions subject))
1544 ((null gnus-summary-gather-subject-limit)
1545 (gnus-simplify-subject-re subject))
1546 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1547 (gnus-simplify-subject-fuzzy subject))
1548 ((numberp gnus-summary-gather-subject-limit)
1549 (gnus-limit-string (gnus-simplify-subject-re subject)
1550 gnus-summary-gather-subject-limit))
1554 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1555 "Check whether two subjects are equal.
1556 If optional argument SIMPLE-FIRST is t, first argument is already
1559 ((null simple-first)
1560 (equal (gnus-simplify-subject-fully s1)
1561 (gnus-simplify-subject-fully s2)))
1564 (gnus-simplify-subject-fully s2)))))
1566 (defun gnus-summary-bubble-group ()
1567 "Increase the score of the current group.
1568 This is a handy function to add to `gnus-summary-exit-hook' to
1569 increase the score of each group you read."
1570 (gnus-group-add-score gnus-newsgroup-name))
1574 ;;; Gnus summary mode
1577 (put 'gnus-summary-mode 'mode-class 'special)
1579 (defvar gnus-article-commands-menu)
1581 ;; Non-orthogonal keys
1583 (gnus-define-keys gnus-summary-mode-map
1584 " " gnus-summary-next-page
1585 "\177" gnus-summary-prev-page
1586 [delete] gnus-summary-prev-page
1587 [backspace] gnus-summary-prev-page
1588 "\r" gnus-summary-scroll-up
1589 "\M-\r" gnus-summary-scroll-down
1590 "n" gnus-summary-next-unread-article
1591 "p" gnus-summary-prev-unread-article
1592 "N" gnus-summary-next-article
1593 "P" gnus-summary-prev-article
1594 "\M-\C-n" gnus-summary-next-same-subject
1595 "\M-\C-p" gnus-summary-prev-same-subject
1596 "\M-n" gnus-summary-next-unread-subject
1597 "\M-p" gnus-summary-prev-unread-subject
1598 "." gnus-summary-first-unread-article
1599 "," gnus-summary-best-unread-article
1600 "\M-s" gnus-summary-search-article-forward
1601 "\M-r" gnus-summary-search-article-backward
1602 "<" gnus-summary-beginning-of-article
1603 ">" gnus-summary-end-of-article
1604 "j" gnus-summary-goto-article
1605 "^" gnus-summary-refer-parent-article
1606 "\M-^" gnus-summary-refer-article
1607 "u" gnus-summary-tick-article-forward
1608 "!" gnus-summary-tick-article-forward
1609 "U" gnus-summary-tick-article-backward
1610 "d" gnus-summary-mark-as-read-forward
1611 "D" gnus-summary-mark-as-read-backward
1612 "E" gnus-summary-mark-as-expirable
1613 "\M-u" gnus-summary-clear-mark-forward
1614 "\M-U" gnus-summary-clear-mark-backward
1615 "k" gnus-summary-kill-same-subject-and-select
1616 "\C-k" gnus-summary-kill-same-subject
1617 "\M-\C-k" gnus-summary-kill-thread
1618 "\M-\C-l" gnus-summary-lower-thread
1619 "e" gnus-summary-edit-article
1620 "#" gnus-summary-mark-as-processable
1621 "\M-#" gnus-summary-unmark-as-processable
1622 "\M-\C-t" gnus-summary-toggle-threads
1623 "\M-\C-s" gnus-summary-show-thread
1624 "\M-\C-h" gnus-summary-hide-thread
1625 "\M-\C-f" gnus-summary-next-thread
1626 "\M-\C-b" gnus-summary-prev-thread
1627 [(meta down)] gnus-summary-next-thread
1628 [(meta up)] gnus-summary-prev-thread
1629 "\M-\C-u" gnus-summary-up-thread
1630 "\M-\C-d" gnus-summary-down-thread
1631 "&" gnus-summary-execute-command
1632 "c" gnus-summary-catchup-and-exit
1633 "\C-w" gnus-summary-mark-region-as-read
1634 "\C-t" gnus-summary-toggle-truncation
1635 "?" gnus-summary-mark-as-dormant
1636 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1637 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1638 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1639 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1640 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1641 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1642 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1643 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1644 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1645 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1646 "=" gnus-summary-expand-window
1647 "\C-x\C-s" gnus-summary-reselect-current-group
1648 "\M-g" gnus-summary-rescan-group
1649 "w" gnus-summary-stop-page-breaking
1650 "\C-c\C-r" gnus-summary-caesar-message
1651 "f" gnus-summary-followup
1652 "F" gnus-summary-followup-with-original
1653 "C" gnus-summary-cancel-article
1654 "r" gnus-summary-reply
1655 "R" gnus-summary-reply-with-original
1656 "\C-c\C-f" gnus-summary-mail-forward
1657 "o" gnus-summary-save-article
1658 "\C-o" gnus-summary-save-article-mail
1659 "|" gnus-summary-pipe-output
1660 "\M-k" gnus-summary-edit-local-kill
1661 "\M-K" gnus-summary-edit-global-kill
1663 "\C-c\C-d" gnus-summary-describe-group
1664 "q" gnus-summary-exit
1665 "Q" gnus-summary-exit-no-update
1666 "\C-c\C-i" gnus-info-find-node
1667 gnus-mouse-2 gnus-mouse-pick-article
1668 "m" gnus-summary-mail-other-window
1669 "a" gnus-summary-post-news
1670 "i" gnus-summary-news-other-window
1671 "x" gnus-summary-limit-to-unread
1672 "s" gnus-summary-isearch-article
1673 "t" gnus-summary-toggle-header
1674 "g" gnus-summary-show-article
1675 "l" gnus-summary-goto-last-article
1676 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1677 "\C-d" gnus-summary-enter-digest-group
1678 "\M-\C-d" gnus-summary-read-document
1679 "\M-\C-e" gnus-summary-edit-parameters
1680 "\M-\C-a" gnus-summary-customize-parameters
1682 "*" gnus-cache-enter-article
1683 "\M-*" gnus-cache-remove-article
1684 "\M-&" gnus-summary-universal-argument
1685 "\C-l" gnus-recenter
1686 "I" gnus-summary-increase-score
1687 "L" gnus-summary-lower-score
1688 "\M-i" gnus-symbolic-argument
1689 "h" gnus-summary-select-article-buffer
1691 "b" gnus-article-view-part
1692 "\M-t" gnus-summary-toggle-display-buttonized
1694 "V" gnus-summary-score-map
1695 "X" gnus-uu-extract-map
1696 "S" gnus-summary-send-map)
1698 ;; Sort of orthogonal keymap
1699 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1700 "t" gnus-summary-tick-article-forward
1701 "!" gnus-summary-tick-article-forward
1702 "d" gnus-summary-mark-as-read-forward
1703 "r" gnus-summary-mark-as-read-forward
1704 "c" gnus-summary-clear-mark-forward
1705 " " gnus-summary-clear-mark-forward
1706 "e" gnus-summary-mark-as-expirable
1707 "x" gnus-summary-mark-as-expirable
1708 "?" gnus-summary-mark-as-dormant
1709 "b" gnus-summary-set-bookmark
1710 "B" gnus-summary-remove-bookmark
1711 "#" gnus-summary-mark-as-processable
1712 "\M-#" gnus-summary-unmark-as-processable
1713 "S" gnus-summary-limit-include-expunged
1714 "C" gnus-summary-catchup
1715 "H" gnus-summary-catchup-to-here
1716 "h" gnus-summary-catchup-from-here
1717 "\C-c" gnus-summary-catchup-all
1718 "k" gnus-summary-kill-same-subject-and-select
1719 "K" gnus-summary-kill-same-subject
1720 "P" gnus-uu-mark-map)
1722 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1723 "c" gnus-summary-clear-above
1724 "u" gnus-summary-tick-above
1725 "m" gnus-summary-mark-above
1726 "k" gnus-summary-kill-below)
1728 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1729 "/" gnus-summary-limit-to-subject
1730 "n" gnus-summary-limit-to-articles
1731 "w" gnus-summary-pop-limit
1732 "s" gnus-summary-limit-to-subject
1733 "a" gnus-summary-limit-to-author
1734 "u" gnus-summary-limit-to-unread
1735 "m" gnus-summary-limit-to-marks
1736 "M" gnus-summary-limit-exclude-marks
1737 "v" gnus-summary-limit-to-score
1738 "*" gnus-summary-limit-include-cached
1739 "D" gnus-summary-limit-include-dormant
1740 "T" gnus-summary-limit-include-thread
1741 "d" gnus-summary-limit-exclude-dormant
1742 "t" gnus-summary-limit-to-age
1743 "." gnus-summary-limit-to-unseen
1744 "x" gnus-summary-limit-to-extra
1745 "p" gnus-summary-limit-to-display-predicate
1746 "E" gnus-summary-limit-include-expunged
1747 "c" gnus-summary-limit-exclude-childless-dormant
1748 "C" gnus-summary-limit-mark-excluded-as-read
1749 "o" gnus-summary-insert-old-articles
1750 "N" gnus-summary-insert-new-articles)
1752 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1753 "n" gnus-summary-next-unread-article
1754 "p" gnus-summary-prev-unread-article
1755 "N" gnus-summary-next-article
1756 "P" gnus-summary-prev-article
1757 "\C-n" gnus-summary-next-same-subject
1758 "\C-p" gnus-summary-prev-same-subject
1759 "\M-n" gnus-summary-next-unread-subject
1760 "\M-p" gnus-summary-prev-unread-subject
1761 "f" gnus-summary-first-unread-article
1762 "b" gnus-summary-best-unread-article
1763 "j" gnus-summary-goto-article
1764 "g" gnus-summary-goto-subject
1765 "l" gnus-summary-goto-last-article
1766 "o" gnus-summary-pop-article)
1768 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1769 "k" gnus-summary-kill-thread
1770 "l" gnus-summary-lower-thread
1771 "i" gnus-summary-raise-thread
1772 "T" gnus-summary-toggle-threads
1773 "t" gnus-summary-rethread-current
1774 "^" gnus-summary-reparent-thread
1775 "s" gnus-summary-show-thread
1776 "S" gnus-summary-show-all-threads
1777 "h" gnus-summary-hide-thread
1778 "H" gnus-summary-hide-all-threads
1779 "n" gnus-summary-next-thread
1780 "p" gnus-summary-prev-thread
1781 "u" gnus-summary-up-thread
1782 "o" gnus-summary-top-thread
1783 "d" gnus-summary-down-thread
1784 "#" gnus-uu-mark-thread
1785 "\M-#" gnus-uu-unmark-thread)
1787 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1788 "g" gnus-summary-prepare
1789 "c" gnus-summary-insert-cached-articles
1790 "d" gnus-summary-insert-dormant-articles)
1792 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1793 "c" gnus-summary-catchup-and-exit
1794 "C" gnus-summary-catchup-all-and-exit
1795 "E" gnus-summary-exit-no-update
1796 "Q" gnus-summary-exit
1797 "Z" gnus-summary-exit
1798 "n" gnus-summary-catchup-and-goto-next-group
1799 "R" gnus-summary-reselect-current-group
1800 "G" gnus-summary-rescan-group
1801 "N" gnus-summary-next-group
1802 "s" gnus-summary-save-newsrc
1803 "P" gnus-summary-prev-group)
1805 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1806 " " gnus-summary-next-page
1807 "n" gnus-summary-next-page
1808 "\177" gnus-summary-prev-page
1809 [delete] gnus-summary-prev-page
1810 "p" gnus-summary-prev-page
1811 "\r" gnus-summary-scroll-up
1812 "\M-\r" gnus-summary-scroll-down
1813 "<" gnus-summary-beginning-of-article
1814 ">" gnus-summary-end-of-article
1815 "b" gnus-summary-beginning-of-article
1816 "e" gnus-summary-end-of-article
1817 "^" gnus-summary-refer-parent-article
1818 "r" gnus-summary-refer-parent-article
1819 "D" gnus-summary-enter-digest-group
1820 "R" gnus-summary-refer-references
1821 "T" gnus-summary-refer-thread
1822 "g" gnus-summary-show-article
1823 "s" gnus-summary-isearch-article
1824 "P" gnus-summary-print-article
1825 "M" gnus-mailing-list-insinuate
1826 "t" gnus-article-babel)
1828 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1829 "b" gnus-article-add-buttons
1830 "B" gnus-article-add-buttons-to-head
1831 "o" gnus-article-treat-overstrike
1832 "e" gnus-article-emphasize
1833 "w" gnus-article-fill-cited-article
1834 "Q" gnus-article-fill-long-lines
1835 "C" gnus-article-capitalize-sentences
1836 "c" gnus-article-remove-cr
1837 "q" gnus-article-de-quoted-unreadable
1838 "6" gnus-article-de-base64-unreadable
1839 "Z" gnus-article-decode-HZ
1840 "h" gnus-article-wash-html
1841 "u" gnus-article-unsplit-urls
1842 "s" gnus-summary-force-verify-and-decrypt
1843 "f" gnus-article-display-x-face
1844 "l" gnus-summary-stop-page-breaking
1845 "r" gnus-summary-caesar-message
1846 "m" gnus-summary-morse-message
1847 "t" gnus-summary-toggle-header
1848 "g" gnus-treat-smiley
1849 "v" gnus-summary-verbose-headers
1850 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1851 "p" gnus-article-verify-x-pgp-sig
1852 "d" gnus-article-treat-dumbquotes)
1854 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1855 ;; mnemonic: deuglif*Y*
1856 "u" gnus-article-outlook-unwrap-lines
1857 "a" gnus-article-outlook-repair-attribution
1858 "c" gnus-article-outlook-rearrange-citation
1859 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1861 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1862 "a" gnus-article-hide
1863 "h" gnus-article-hide-headers
1864 "b" gnus-article-hide-boring-headers
1865 "s" gnus-article-hide-signature
1866 "c" gnus-article-hide-citation
1867 "C" gnus-article-hide-citation-in-followups
1868 "l" gnus-article-hide-list-identifiers
1869 "B" gnus-article-strip-banner
1870 "P" gnus-article-hide-pem
1871 "\C-c" gnus-article-hide-citation-maybe)
1873 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1874 "a" gnus-article-highlight
1875 "h" gnus-article-highlight-headers
1876 "c" gnus-article-highlight-citation
1877 "s" gnus-article-highlight-signature)
1879 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1880 "f" gnus-article-treat-fold-headers
1881 "u" gnus-article-treat-unfold-headers
1882 "n" gnus-article-treat-fold-newsgroups)
1884 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1885 "x" gnus-article-display-x-face
1886 "d" gnus-article-display-face
1887 "s" gnus-treat-smiley
1888 "D" gnus-article-remove-images
1889 "f" gnus-treat-from-picon
1890 "m" gnus-treat-mail-picon
1891 "n" gnus-treat-newsgroups-picon)
1893 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1894 "w" gnus-article-decode-mime-words
1895 "c" gnus-article-decode-charset
1896 "v" gnus-mime-view-all-parts
1897 "b" gnus-article-view-part)
1899 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1900 "z" gnus-article-date-ut
1901 "u" gnus-article-date-ut
1902 "l" gnus-article-date-local
1903 "p" gnus-article-date-english
1904 "e" gnus-article-date-lapsed
1905 "o" gnus-article-date-original
1906 "i" gnus-article-date-iso8601
1907 "s" gnus-article-date-user)
1909 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1910 "t" gnus-article-remove-trailing-blank-lines
1911 "l" gnus-article-strip-leading-blank-lines
1912 "m" gnus-article-strip-multiple-blank-lines
1913 "a" gnus-article-strip-blank-lines
1914 "A" gnus-article-strip-all-blank-lines
1915 "s" gnus-article-strip-leading-space
1916 "e" gnus-article-strip-trailing-space
1917 "w" gnus-article-remove-leading-whitespace)
1919 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1921 "f" gnus-summary-fetch-faq
1922 "d" gnus-summary-describe-group
1923 "h" gnus-summary-describe-briefly
1924 "i" gnus-info-find-node
1925 "c" gnus-group-fetch-charter
1926 "C" gnus-group-fetch-control)
1928 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1929 "e" gnus-summary-expire-articles
1930 "\M-\C-e" gnus-summary-expire-articles-now
1931 "\177" gnus-summary-delete-article
1932 [delete] gnus-summary-delete-article
1933 [backspace] gnus-summary-delete-article
1934 "m" gnus-summary-move-article
1935 "r" gnus-summary-respool-article
1936 "w" gnus-summary-edit-article
1937 "c" gnus-summary-copy-article
1938 "B" gnus-summary-crosspost-article
1939 "q" gnus-summary-respool-query
1940 "t" gnus-summary-respool-trace
1941 "i" gnus-summary-import-article
1942 "I" gnus-summary-create-article
1943 "p" gnus-summary-article-posted-p)
1945 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1946 "o" gnus-summary-save-article
1947 "m" gnus-summary-save-article-mail
1948 "F" gnus-summary-write-article-file
1949 "r" gnus-summary-save-article-rmail
1950 "f" gnus-summary-save-article-file
1951 "b" gnus-summary-save-article-body-file
1952 "h" gnus-summary-save-article-folder
1953 "v" gnus-summary-save-article-vm
1954 "p" gnus-summary-pipe-output
1955 "P" gnus-summary-muttprint
1956 "s" gnus-soup-add-article)
1958 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1959 "b" gnus-summary-display-buttonized
1960 "m" gnus-summary-repair-multipart
1961 "v" gnus-article-view-part
1962 "o" gnus-article-save-part
1963 "c" gnus-article-copy-part
1964 "C" gnus-article-view-part-as-charset
1965 "e" gnus-article-view-part-externally
1966 "E" gnus-article-encrypt-body
1967 "i" gnus-article-inline-part
1968 "|" gnus-article-pipe-part)
1970 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1971 "p" gnus-summary-mark-as-processable
1972 "u" gnus-summary-unmark-as-processable
1973 "U" gnus-summary-unmark-all-processable
1974 "v" gnus-uu-mark-over
1975 "s" gnus-uu-mark-series
1976 "r" gnus-uu-mark-region
1977 "g" gnus-uu-unmark-region
1978 "R" gnus-uu-mark-by-regexp
1979 "G" gnus-uu-unmark-by-regexp
1980 "t" gnus-uu-mark-thread
1981 "T" gnus-uu-unmark-thread
1982 "a" gnus-uu-mark-all
1983 "b" gnus-uu-mark-buffer
1984 "S" gnus-uu-mark-sparse
1985 "k" gnus-summary-kill-process-mark
1986 "y" gnus-summary-yank-process-mark
1987 "w" gnus-summary-save-process-mark
1988 "i" gnus-uu-invert-processable)
1990 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1991 ;;"x" gnus-uu-extract-any
1992 "m" gnus-summary-save-parts
1993 "u" gnus-uu-decode-uu
1994 "U" gnus-uu-decode-uu-and-save
1995 "s" gnus-uu-decode-unshar
1996 "S" gnus-uu-decode-unshar-and-save
1997 "o" gnus-uu-decode-save
1998 "O" gnus-uu-decode-save
1999 "b" gnus-uu-decode-binhex
2000 "B" gnus-uu-decode-binhex
2001 "p" gnus-uu-decode-postscript
2002 "P" gnus-uu-decode-postscript-and-save)
2005 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2006 "u" gnus-uu-decode-uu-view
2007 "U" gnus-uu-decode-uu-and-save-view
2008 "s" gnus-uu-decode-unshar-view
2009 "S" gnus-uu-decode-unshar-and-save-view
2010 "o" gnus-uu-decode-save-view
2011 "O" gnus-uu-decode-save-view
2012 "b" gnus-uu-decode-binhex-view
2013 "B" gnus-uu-decode-binhex-view
2014 "p" gnus-uu-decode-postscript-view
2015 "P" gnus-uu-decode-postscript-and-save-view)
2017 (defvar gnus-article-post-menu nil)
2019 (defconst gnus-summary-menu-maxlen 20)
2021 (defun gnus-summary-menu-split (menu)
2022 ;; If we have lots of elements, divide them into groups of 20
2023 ;; and make a pane (or submenu) for each one.
2024 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2025 (let ((menu menu) sublists next
2028 ;; Pull off the next gnus-summary-menu-maxlen elements
2029 ;; and make them the next element of sublist.
2030 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2032 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2034 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2035 (aref (car (last menu)) 0)) menu)
2039 (nreverse sublists))
2040 ;; Few elements--put them all in one pane.
2043 (defun gnus-summary-make-menu-bar ()
2044 (gnus-turn-off-edit-menu 'summary)
2046 (unless (boundp 'gnus-summary-misc-menu)
2049 gnus-summary-kill-menu gnus-summary-mode-map ""
2054 ["Customize" gnus-score-customize t])
2055 (gnus-make-score-map 'increase)
2056 (gnus-make-score-map 'lower)
2058 ["Kill below" gnus-summary-kill-below t]
2059 ["Mark above" gnus-summary-mark-above t]
2060 ["Tick above" gnus-summary-tick-above t]
2061 ["Clear above" gnus-summary-clear-above t])
2062 ["Current score" gnus-summary-current-score t]
2063 ["Set score" gnus-summary-set-score t]
2064 ["Switch current score file..." gnus-score-change-score-file t]
2065 ["Set mark below..." gnus-score-set-mark-below t]
2066 ["Set expunge below..." gnus-score-set-expunge-below t]
2067 ["Edit current score file" gnus-score-edit-current-scores t]
2068 ["Edit score file" gnus-score-edit-file t]
2069 ["Trace score" gnus-score-find-trace t]
2070 ["Find words" gnus-score-find-favourite-words t]
2071 ["Rescore buffer" gnus-summary-rescore t]
2072 ["Increase score..." gnus-summary-increase-score t]
2073 ["Lower score..." gnus-summary-lower-score t]))))
2075 ;; Define both the Article menu in the summary buffer and the
2076 ;; equivalent Commands menu in the article buffer here for
2080 ["All" gnus-article-hide t]
2081 ["Headers" gnus-article-hide-headers t]
2082 ["Signature" gnus-article-hide-signature t]
2083 ["Citation" gnus-article-hide-citation t]
2084 ["List identifiers" gnus-article-hide-list-identifiers t]
2085 ["Banner" gnus-article-strip-banner t]
2086 ["Boring headers" gnus-article-hide-boring-headers t])
2088 ["All" gnus-article-highlight t]
2089 ["Headers" gnus-article-highlight-headers t]
2090 ["Signature" gnus-article-highlight-signature t]
2091 ["Citation" gnus-article-highlight-citation t])
2093 ["Words" gnus-article-decode-mime-words t]
2094 ["Charset" gnus-article-decode-charset t]
2095 ["QP" gnus-article-de-quoted-unreadable t]
2096 ["Base64" gnus-article-de-base64-unreadable t]
2097 ["View MIME buttons" gnus-summary-display-buttonized t]
2098 ["View all" gnus-mime-view-all-parts t]
2099 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2100 ["Encrypt body" gnus-article-encrypt-body
2101 :active (not (gnus-group-read-only-p))
2102 ,@(if (featurep 'xemacs) nil
2103 '(:help "Encrypt the message body on disk"))]
2104 ["Extract all parts" gnus-summary-save-parts t]
2106 ["Repair multipart" gnus-summary-repair-multipart t]
2107 ["Add buttons" gnus-summary-display-buttonized t]
2108 ["Pipe part" gnus-article-pipe-part t]
2109 ["Inline part" gnus-article-inline-part t]
2110 ["Encrypt body" gnus-article-encrypt-body
2111 :active (not (gnus-group-read-only-p))
2112 ,@(if (featurep 'xemacs) nil
2113 '(:help "Encrypt the message body on disk"))]
2114 ["View part externally" gnus-article-view-part-externally t]
2115 ["View part with charset" gnus-article-view-part-as-charset t]
2116 ["Copy part" gnus-article-copy-part t]
2117 ["Save part" gnus-article-save-part t]
2118 ["View part" gnus-article-view-part t]))
2120 ["Local" gnus-article-date-local t]
2121 ["ISO8601" gnus-article-date-iso8601 t]
2122 ["UT" gnus-article-date-ut t]
2123 ["Original" gnus-article-date-original t]
2124 ["Lapsed" gnus-article-date-lapsed t]
2125 ["User-defined" gnus-article-date-user t])
2127 ["Remove images" gnus-article-remove-images t]
2128 ["Toggle smiley" gnus-treat-smiley t]
2129 ["Show X-Face" gnus-article-display-x-face t]
2130 ["Show picons in From" gnus-treat-from-picon t]
2131 ["Show picons in mail headers" gnus-treat-mail-picon t]
2132 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2133 ("View as different encoding"
2134 ,@(gnus-summary-menu-split
2137 ;; Since easymenu under FSF Emacs doesn't allow lambda
2138 ;; forms for menu commands, we should provide intern'ed
2139 ;; function symbols.
2140 (let ((command (intern (format "\
2141 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2145 (let ((gnus-summary-show-article-charset-alist
2147 (gnus-summary-show-article 1))))
2148 `[,(symbol-name cs) ,command t]))
2149 (sort (if (fboundp 'coding-system-list)
2150 (coding-system-list)
2151 (mapcar 'car mm-mime-mule-charset-alist))
2155 ["Leading" gnus-article-strip-leading-blank-lines t]
2156 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2157 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2158 ["All of the above" gnus-article-strip-blank-lines t]
2159 ["All" gnus-article-strip-all-blank-lines t]
2160 ["Leading space" gnus-article-strip-leading-space t]
2161 ["Trailing space" gnus-article-strip-trailing-space t]
2162 ["Leading space in headers"
2163 gnus-article-remove-leading-whitespace t])
2164 ["Overstrike" gnus-article-treat-overstrike t]
2165 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2166 ["Emphasis" gnus-article-emphasize t]
2167 ["Word wrap" gnus-article-fill-cited-article t]
2168 ["Fill long lines" gnus-article-fill-long-lines t]
2169 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2170 ["CR" gnus-article-remove-cr t]
2171 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2172 ["Base64" gnus-article-de-base64-unreadable t]
2173 ["Rot 13" gnus-summary-caesar-message
2174 ,@(if (featurep 'xemacs) '(t)
2175 '(:help "\"Caesar rotate\" article by 13"))]
2176 ["Morse decode" gnus-summary-morse-message t]
2177 ["Unix pipe..." gnus-summary-pipe-message t]
2178 ["Add buttons" gnus-article-add-buttons t]
2179 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2180 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2181 ["Verbose header" gnus-summary-verbose-headers t]
2182 ["Toggle header" gnus-summary-toggle-header t]
2183 ["Unfold headers" gnus-article-treat-unfold-headers t]
2184 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2185 ["Html" gnus-article-wash-html t]
2186 ["URLs" gnus-article-unsplit-urls t]
2187 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2188 ["HZ" gnus-article-decode-HZ t]
2189 ("(Outlook) Deuglify"
2190 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2191 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2192 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2193 ["Full (Outlook) deuglify"
2194 gnus-article-outlook-deuglify-article t])
2197 ["Save in default format" gnus-summary-save-article
2198 ,@(if (featurep 'xemacs) '(t)
2199 '(:help "Save article using default method"))]
2200 ["Save in file" gnus-summary-save-article-file
2201 ,@(if (featurep 'xemacs) '(t)
2202 '(:help "Save article in file"))]
2203 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2204 ["Save in MH folder" gnus-summary-save-article-folder t]
2205 ["Save in VM folder" gnus-summary-save-article-vm t]
2206 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2207 ["Save body in file" gnus-summary-save-article-body-file t]
2208 ["Pipe through a filter" gnus-summary-pipe-output t]
2209 ["Add to SOUP packet" gnus-soup-add-article t]
2210 ["Print with Muttprint" gnus-summary-muttprint t]
2211 ["Print" gnus-summary-print-article t])
2213 ["Respool article..." gnus-summary-respool-article t]
2214 ["Move article..." gnus-summary-move-article
2215 (gnus-check-backend-function
2216 'request-move-article gnus-newsgroup-name)]
2217 ["Copy article..." gnus-summary-copy-article t]
2218 ["Crosspost article..." gnus-summary-crosspost-article
2219 (gnus-check-backend-function
2220 'request-replace-article gnus-newsgroup-name)]
2221 ["Import file..." gnus-summary-import-article
2222 (gnus-check-backend-function
2223 'request-accept-article gnus-newsgroup-name)]
2224 ["Create article..." gnus-summary-create-article
2225 (gnus-check-backend-function
2226 'request-accept-article gnus-newsgroup-name)]
2227 ["Check if posted" gnus-summary-article-posted-p t]
2228 ["Edit article" gnus-summary-edit-article
2229 (not (gnus-group-read-only-p))]
2230 ["Delete article" gnus-summary-delete-article
2231 (gnus-check-backend-function
2232 'request-expire-articles gnus-newsgroup-name)]
2233 ["Query respool" gnus-summary-respool-query t]
2234 ["Trace respool" gnus-summary-respool-trace t]
2235 ["Delete expirable articles" gnus-summary-expire-articles-now
2236 (gnus-check-backend-function
2237 'request-expire-articles gnus-newsgroup-name)])
2239 ["Uudecode" gnus-uu-decode-uu
2240 ,@(if (featurep 'xemacs) '(t)
2241 '(:help "Decode uuencoded article(s)"))]
2242 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2243 ["Unshar" gnus-uu-decode-unshar t]
2244 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2245 ["Save" gnus-uu-decode-save t]
2246 ["Binhex" gnus-uu-decode-binhex t]
2247 ["Postscript" gnus-uu-decode-postscript t]
2248 ["All MIME parts" gnus-summary-save-parts t])
2250 ["Enter article" gnus-cache-enter-article t]
2251 ["Remove article" gnus-cache-remove-article t])
2252 ["Translate" gnus-article-babel t]
2253 ["Select article buffer" gnus-summary-select-article-buffer t]
2254 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2255 ["Isearch article..." gnus-summary-isearch-article t]
2256 ["Beginning of the article" gnus-summary-beginning-of-article t]
2257 ["End of the article" gnus-summary-end-of-article t]
2258 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2259 ["Fetch referenced articles" gnus-summary-refer-references t]
2260 ["Fetch current thread" gnus-summary-refer-thread t]
2261 ["Fetch article with id..." gnus-summary-refer-article t]
2262 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2263 ["Redisplay" gnus-summary-show-article t]
2264 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2266 gnus-summary-article-menu gnus-summary-mode-map ""
2267 (cons "Article" innards))
2269 (if (not (keymapp gnus-summary-article-menu))
2271 gnus-article-commands-menu gnus-article-mode-map ""
2272 (cons "Commands" innards))
2273 ;; in Emacs, don't share menu.
2274 (setq gnus-article-commands-menu
2275 (copy-keymap gnus-summary-article-menu))
2276 (define-key gnus-article-mode-map [menu-bar commands]
2277 (cons "Commands" gnus-article-commands-menu))))
2280 gnus-summary-thread-menu gnus-summary-mode-map ""
2282 ["Find all messages in thread" gnus-summary-refer-thread t]
2283 ["Toggle threading" gnus-summary-toggle-threads t]
2284 ["Hide threads" gnus-summary-hide-all-threads t]
2285 ["Show threads" gnus-summary-show-all-threads t]
2286 ["Hide thread" gnus-summary-hide-thread t]
2287 ["Show thread" gnus-summary-show-thread t]
2288 ["Go to next thread" gnus-summary-next-thread t]
2289 ["Go to previous thread" gnus-summary-prev-thread t]
2290 ["Go down thread" gnus-summary-down-thread t]
2291 ["Go up thread" gnus-summary-up-thread t]
2292 ["Top of thread" gnus-summary-top-thread t]
2293 ["Mark thread as read" gnus-summary-kill-thread t]
2294 ["Lower thread score" gnus-summary-lower-thread t]
2295 ["Raise thread score" gnus-summary-raise-thread t]
2296 ["Rethread current" gnus-summary-rethread-current t]))
2299 gnus-summary-post-menu gnus-summary-mode-map ""
2301 ["Send a message (mail or news)" gnus-summary-post-news
2302 ,@(if (featurep 'xemacs) '(t)
2303 '(:help "Post an article"))]
2304 ["Followup" gnus-summary-followup
2305 ,@(if (featurep 'xemacs) '(t)
2306 '(:help "Post followup to this article"))]
2307 ["Followup and yank" gnus-summary-followup-with-original
2308 ,@(if (featurep 'xemacs) '(t)
2309 '(:help "Post followup to this article, quoting its contents"))]
2310 ["Supersede article" gnus-summary-supersede-article t]
2311 ["Cancel article" gnus-summary-cancel-article
2312 ,@(if (featurep 'xemacs) '(t)
2313 '(:help "Cancel an article you posted"))]
2314 ["Reply" gnus-summary-reply t]
2315 ["Reply and yank" gnus-summary-reply-with-original t]
2316 ["Wide reply" gnus-summary-wide-reply t]
2317 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2318 ,@(if (featurep 'xemacs) '(t)
2319 '(:help "Mail a reply, quoting this article"))]
2320 ["Very wide reply" gnus-summary-very-wide-reply t]
2321 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2322 ,@(if (featurep 'xemacs) '(t)
2323 '(:help "Mail a very wide reply, quoting this article"))]
2324 ["Mail forward" gnus-summary-mail-forward t]
2325 ["Post forward" gnus-summary-post-forward t]
2326 ["Digest and mail" gnus-uu-digest-mail-forward t]
2327 ["Digest and post" gnus-uu-digest-post-forward t]
2328 ["Resend message" gnus-summary-resend-message t]
2329 ["Resend message edit" gnus-summary-resend-message-edit t]
2330 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2331 ["Send a mail" gnus-summary-mail-other-window t]
2332 ["Create a local message" gnus-summary-news-other-window t]
2333 ["Uuencode and post" gnus-uu-post-news
2334 ,@(if (featurep 'xemacs) '(t)
2335 '(:help "Post a uuencoded article"))]
2336 ["Followup via news" gnus-summary-followup-to-mail t]
2337 ["Followup via news and yank"
2338 gnus-summary-followup-to-mail-with-original t]
2340 ;;["Send" gnus-summary-send-draft t]
2341 ;;["Send bounced" gnus-resend-bounced-mail t])
2345 ((not (keymapp gnus-summary-post-menu))
2346 (setq gnus-article-post-menu gnus-summary-post-menu))
2347 ((not gnus-article-post-menu)
2348 ;; Don't share post menu.
2349 (setq gnus-article-post-menu
2350 (copy-keymap gnus-summary-post-menu))))
2351 (define-key gnus-article-mode-map [menu-bar post]
2352 (cons "Post" gnus-article-post-menu))
2355 gnus-summary-misc-menu gnus-summary-mode-map ""
2358 ["Mark as read" gnus-summary-mark-as-read-forward t]
2359 ["Mark same subject and select"
2360 gnus-summary-kill-same-subject-and-select t]
2361 ["Mark same subject" gnus-summary-kill-same-subject t]
2362 ["Catchup" gnus-summary-catchup
2363 ,@(if (featurep 'xemacs) '(t)
2364 '(:help "Mark unread articles in this group as read"))]
2365 ["Catchup all" gnus-summary-catchup-all t]
2366 ["Catchup to here" gnus-summary-catchup-to-here t]
2367 ["Catchup from here" gnus-summary-catchup-from-here t]
2368 ["Catchup region" gnus-summary-mark-region-as-read
2369 (gnus-mark-active-p)]
2370 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2372 ["Tick" gnus-summary-tick-article-forward t]
2373 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2374 ["Remove marks" gnus-summary-clear-mark-forward t]
2375 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2376 ["Set bookmark" gnus-summary-set-bookmark t]
2377 ["Remove bookmark" gnus-summary-remove-bookmark t])
2379 ["Marks..." gnus-summary-limit-to-marks t]
2380 ["Subject..." gnus-summary-limit-to-subject t]
2381 ["Author..." gnus-summary-limit-to-author t]
2382 ["Age..." gnus-summary-limit-to-age t]
2383 ["Extra..." gnus-summary-limit-to-extra t]
2384 ["Score..." gnus-summary-limit-to-score t]
2385 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2386 ["Unread" gnus-summary-limit-to-unread t]
2387 ["Unseen" gnus-summary-limit-to-unseen t]
2388 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2389 ["Next articles" gnus-summary-limit-to-articles t]
2390 ["Pop limit" gnus-summary-pop-limit t]
2391 ["Show dormant" gnus-summary-limit-include-dormant t]
2392 ["Hide childless dormant"
2393 gnus-summary-limit-exclude-childless-dormant t]
2394 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2395 ["Hide marked" gnus-summary-limit-exclude-marks t]
2396 ["Show expunged" gnus-summary-limit-include-expunged t])
2398 ["Set mark" gnus-summary-mark-as-processable t]
2399 ["Remove mark" gnus-summary-unmark-as-processable t]
2400 ["Remove all marks" gnus-summary-unmark-all-processable t]
2401 ["Mark above" gnus-uu-mark-over t]
2402 ["Mark series" gnus-uu-mark-series t]
2403 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2404 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2405 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2406 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2407 ["Mark all" gnus-uu-mark-all t]
2408 ["Mark buffer" gnus-uu-mark-buffer t]
2409 ["Mark sparse" gnus-uu-mark-sparse t]
2410 ["Mark thread" gnus-uu-mark-thread t]
2411 ["Unmark thread" gnus-uu-unmark-thread t]
2412 ("Process Mark Sets"
2413 ["Kill" gnus-summary-kill-process-mark t]
2414 ["Yank" gnus-summary-yank-process-mark
2415 gnus-newsgroup-process-stack]
2416 ["Save" gnus-summary-save-process-mark t]
2417 ["Run command on marked..." gnus-summary-universal-argument t]))
2419 ["Page forward" gnus-summary-next-page
2420 ,@(if (featurep 'xemacs) '(t)
2421 '(:help "Show next page of article"))]
2422 ["Page backward" gnus-summary-prev-page
2423 ,@(if (featurep 'xemacs) '(t)
2424 '(:help "Show previous page of article"))]
2425 ["Line forward" gnus-summary-scroll-up t])
2427 ["Next unread article" gnus-summary-next-unread-article t]
2428 ["Previous unread article" gnus-summary-prev-unread-article t]
2429 ["Next article" gnus-summary-next-article t]
2430 ["Previous article" gnus-summary-prev-article t]
2431 ["Next unread subject" gnus-summary-next-unread-subject t]
2432 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2433 ["Next article same subject" gnus-summary-next-same-subject t]
2434 ["Previous article same subject" gnus-summary-prev-same-subject t]
2435 ["First unread article" gnus-summary-first-unread-article t]
2436 ["Best unread article" gnus-summary-best-unread-article t]
2437 ["Go to subject number..." gnus-summary-goto-subject t]
2438 ["Go to article number..." gnus-summary-goto-article t]
2439 ["Go to the last article" gnus-summary-goto-last-article t]
2440 ["Pop article off history" gnus-summary-pop-article t])
2442 ["Sort by number" gnus-summary-sort-by-number t]
2443 ["Sort by author" gnus-summary-sort-by-author t]
2444 ["Sort by subject" gnus-summary-sort-by-subject t]
2445 ["Sort by date" gnus-summary-sort-by-date t]
2446 ["Sort by score" gnus-summary-sort-by-score t]
2447 ["Sort by lines" gnus-summary-sort-by-lines t]
2448 ["Sort by characters" gnus-summary-sort-by-chars t]
2449 ["Randomize" gnus-summary-sort-by-random t]
2450 ["Original sort" gnus-summary-sort-by-original t])
2452 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2453 ["Describe group" gnus-summary-describe-group t]
2454 ["Fetch charter" gnus-group-fetch-charter
2455 ,@(if (featurep 'xemacs) nil
2456 '(:help "Display the charter of the current group"))]
2457 ["Fetch control message" gnus-group-fetch-control
2458 ,@(if (featurep 'xemacs) nil
2459 '(:help "Display the archived control message for the current group"))]
2460 ["Read manual" gnus-info-find-node t])
2462 ["Pick and read" gnus-pick-mode t]
2463 ["Binary" gnus-binary-mode t])
2465 ["Regenerate" gnus-summary-prepare t]
2466 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2467 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2468 ["Toggle threading" gnus-summary-toggle-threads t])
2469 ["See old articles" gnus-summary-insert-old-articles t]
2470 ["See new articles" gnus-summary-insert-new-articles t]
2471 ["Filter articles..." gnus-summary-execute-command t]
2472 ["Run command on articles..." gnus-summary-universal-argument t]
2473 ["Search articles forward..." gnus-summary-search-article-forward t]
2474 ["Search articles backward..." gnus-summary-search-article-backward t]
2475 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2476 ["Expand window" gnus-summary-expand-window t]
2477 ["Expire expirable articles" gnus-summary-expire-articles
2478 (gnus-check-backend-function
2479 'request-expire-articles gnus-newsgroup-name)]
2480 ["Edit local kill file" gnus-summary-edit-local-kill t]
2481 ["Edit main kill file" gnus-summary-edit-global-kill t]
2482 ["Edit group parameters" gnus-summary-edit-parameters t]
2483 ["Customize group parameters" gnus-summary-customize-parameters t]
2484 ["Send a bug report" gnus-bug t]
2486 ["Catchup and exit" gnus-summary-catchup-and-exit
2487 ,@(if (featurep 'xemacs) '(t)
2488 '(:help "Mark unread articles in this group as read, then exit"))]
2489 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2490 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2491 ["Exit group" gnus-summary-exit
2492 ,@(if (featurep 'xemacs) '(t)
2493 '(:help "Exit current group, return to group selection mode"))]
2494 ["Exit group without updating" gnus-summary-exit-no-update t]
2495 ["Exit and goto next group" gnus-summary-next-group t]
2496 ["Exit and goto prev group" gnus-summary-prev-group t]
2497 ["Reselect group" gnus-summary-reselect-current-group t]
2498 ["Rescan group" gnus-summary-rescan-group t]
2499 ["Update dribble" gnus-summary-save-newsrc t])))
2501 (gnus-run-hooks 'gnus-summary-menu-hook)))
2503 (defvar gnus-summary-tool-bar-map nil)
2505 ;; Emacs 21 tool bar. Should be no-op otherwise.
2506 (defun gnus-summary-make-tool-bar ()
2507 (if (and (fboundp 'tool-bar-add-item-from-menu)
2508 (default-value 'tool-bar-mode)
2509 (not gnus-summary-tool-bar-map))
2510 (setq gnus-summary-tool-bar-map
2511 (let ((tool-bar-map (make-sparse-keymap))
2512 (load-path (mm-image-load-path)))
2513 (tool-bar-add-item-from-menu
2514 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2515 (tool-bar-add-item-from-menu
2516 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2517 (tool-bar-add-item-from-menu
2518 'gnus-summary-post-news "post" gnus-summary-mode-map)
2519 (tool-bar-add-item-from-menu
2520 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2521 (tool-bar-add-item-from-menu
2522 'gnus-summary-followup "followup" gnus-summary-mode-map)
2523 (tool-bar-add-item-from-menu
2524 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2525 (tool-bar-add-item-from-menu
2526 'gnus-summary-reply "reply" gnus-summary-mode-map)
2527 (tool-bar-add-item-from-menu
2528 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2529 (tool-bar-add-item-from-menu
2530 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2531 (tool-bar-add-item-from-menu
2532 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2533 (tool-bar-add-item-from-menu
2534 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2535 (tool-bar-add-item-from-menu
2536 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2537 (tool-bar-add-item-from-menu
2538 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2539 (tool-bar-add-item-from-menu
2540 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2541 (tool-bar-add-item-from-menu
2542 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2544 (if gnus-summary-tool-bar-map
2545 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2547 (defun gnus-score-set-default (var value)
2548 "A version of set that updates the GNU Emacs menu-bar."
2550 ;; It is the message that forces the active status to be updated.
2553 (defun gnus-make-score-map (type)
2554 "Make a summary score map of type TYPE."
2557 (let ((headers '(("author" "from" string)
2558 ("subject" "subject" string)
2559 ("article body" "body" string)
2560 ("article head" "head" string)
2561 ("xref" "xref" string)
2562 ("extra header" "extra" string)
2563 ("lines" "lines" number)
2564 ("followups to author" "followup" string)))
2565 (types '((number ("less than" <)
2568 (string ("substring" s)
2572 (perms '(("temporary" (current-time-string))
2580 (if (eq type 'lower)
2585 (setq header (car headers))
2591 (let ((ts (cdr (assoc (nth 2 header) types)))
2607 'gnus-summary-score-entry
2609 (if (or (string= (nth 1 header)
2611 (string= (nth 1 header)
2614 (list 'gnus-summary-header
2616 (list 'quote (nth 1 (car ts)))
2617 (list 'gnus-score-delta-default
2624 (list (nreverse outp))))
2627 (list (nreverse outt))))
2629 (setq headers (cdr headers)))
2630 (list (nreverse outh))))))))
2634 (defun gnus-summary-mode (&optional group)
2635 "Major mode for reading articles.
2637 All normal editing commands are switched off.
2638 \\<gnus-summary-mode-map>
2639 Each line in this buffer represents one article. To read an
2640 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2641 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2644 You can also post articles and send mail from this buffer. To
2645 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2646 of an article, type `\\[gnus-summary-reply]'.
2648 There are approx. one gazillion commands you can execute in this
2649 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2651 The following commands are available:
2653 \\{gnus-summary-mode-map}"
2655 (kill-all-local-variables)
2656 (when (gnus-visual-p 'summary-menu 'menu)
2657 (gnus-summary-make-menu-bar)
2658 (gnus-summary-make-tool-bar))
2659 (gnus-summary-make-local-variables)
2660 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2661 (gnus-summary-make-local-variables))
2662 (gnus-make-thread-indent-array)
2663 (gnus-simplify-mode-line)
2664 (setq major-mode 'gnus-summary-mode)
2665 (setq mode-name "Summary")
2666 (make-local-variable 'minor-mode-alist)
2667 (use-local-map gnus-summary-mode-map)
2668 (buffer-disable-undo)
2669 (setq buffer-read-only t) ;Disable modification
2670 (setq truncate-lines t)
2671 (setq selective-display t)
2672 (setq selective-display-ellipses t) ;Display `...'
2673 (gnus-summary-set-display-table)
2674 (gnus-set-default-directory)
2675 (setq gnus-newsgroup-name group)
2676 (make-local-variable 'gnus-summary-line-format)
2677 (make-local-variable 'gnus-summary-line-format-spec)
2678 (make-local-variable 'gnus-summary-dummy-line-format)
2679 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2680 (make-local-variable 'gnus-summary-mark-positions)
2681 (make-local-hook 'pre-command-hook)
2682 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2683 (gnus-run-hooks 'gnus-summary-mode-hook)
2684 (turn-on-gnus-mailing-list-mode)
2685 (mm-enable-multibyte)
2686 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2687 (gnus-update-summary-mark-positions))
2689 (defun gnus-summary-make-local-variables ()
2690 "Make all the local summary buffer variables."
2692 (dolist (local gnus-summary-local-variables)
2695 (if (eq (cdr local) 'global)
2696 ;; Copy the global value of the variable.
2697 (setq global (symbol-value (car local)))
2698 ;; Use the value from the list.
2699 (setq global (eval (cdr local))))
2700 (set (make-local-variable (car local)) global))
2701 ;; Simple nil-valued local variable.
2702 (set (make-local-variable local) nil)))))
2704 (defun gnus-summary-clear-local-variables ()
2705 (let ((locals gnus-summary-local-variables))
2707 (if (consp (car locals))
2708 (and (vectorp (caar locals))
2709 (set (caar locals) nil))
2710 (and (vectorp (car locals))
2711 (set (car locals) nil)))
2712 (setq locals (cdr locals)))))
2714 ;; Summary data functions.
2716 (defmacro gnus-data-number (data)
2719 (defmacro gnus-data-set-number (data number)
2720 `(setcar ,data ,number))
2722 (defmacro gnus-data-mark (data)
2725 (defmacro gnus-data-set-mark (data mark)
2726 `(setcar (nthcdr 1 ,data) ,mark))
2728 (defmacro gnus-data-pos (data)
2731 (defmacro gnus-data-set-pos (data pos)
2732 `(setcar (nthcdr 2 ,data) ,pos))
2734 (defmacro gnus-data-header (data)
2737 (defmacro gnus-data-set-header (data header)
2738 `(setf (nth 3 ,data) ,header))
2740 (defmacro gnus-data-level (data)
2743 (defmacro gnus-data-unread-p (data)
2744 `(= (nth 1 ,data) gnus-unread-mark))
2746 (defmacro gnus-data-read-p (data)
2747 `(/= (nth 1 ,data) gnus-unread-mark))
2749 (defmacro gnus-data-pseudo-p (data)
2750 `(consp (nth 3 ,data)))
2752 (defmacro gnus-data-find (number)
2753 `(assq ,number gnus-newsgroup-data))
2755 (defmacro gnus-data-find-list (number &optional data)
2756 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2757 (memq (assq ,number bdata)
2760 (defmacro gnus-data-make (number mark pos header level)
2761 `(list ,number ,mark ,pos ,header ,level))
2763 (defun gnus-data-enter (after-article number mark pos header level offset)
2764 (let ((data (gnus-data-find-list after-article)))
2766 (error "No such article: %d" after-article))
2767 (setcdr data (cons (gnus-data-make number mark pos header level)
2769 (setq gnus-newsgroup-data-reverse nil)
2770 (gnus-data-update-list (cddr data) offset)))
2772 (defun gnus-data-enter-list (after-article list &optional offset)
2774 (let ((data (and after-article (gnus-data-find-list after-article)))
2778 (let ((odata gnus-newsgroup-data))
2779 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2781 (gnus-data-update-list odata offset)))
2782 ;; Find the last element in the list to be spliced into the main
2785 (setq list (cdr list)))
2788 (setcdr list gnus-newsgroup-data)
2789 (setq gnus-newsgroup-data ilist)
2791 (gnus-data-update-list (cdr list) offset)))
2792 (setcdr list (cdr data))
2795 (gnus-data-update-list (cdr list) offset))))
2796 (setq gnus-newsgroup-data-reverse nil))))
2798 (defun gnus-data-remove (article &optional offset)
2799 (let ((data gnus-newsgroup-data))
2800 (if (= (gnus-data-number (car data)) article)
2802 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2803 gnus-newsgroup-data-reverse nil)
2805 (gnus-data-update-list gnus-newsgroup-data offset)))
2807 (when (= (gnus-data-number (cadr data)) article)
2808 (setcdr data (cddr data))
2810 (gnus-data-update-list (cdr data) offset))
2812 gnus-newsgroup-data-reverse nil))
2813 (setq data (cdr data))))))
2815 (defmacro gnus-data-list (backward)
2817 (or gnus-newsgroup-data-reverse
2818 (setq gnus-newsgroup-data-reverse
2819 (reverse gnus-newsgroup-data)))
2820 gnus-newsgroup-data))
2822 (defun gnus-data-update-list (data offset)
2823 "Add OFFSET to the POS of all data entries in DATA."
2824 (setq gnus-newsgroup-data-reverse nil)
2826 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2827 (setq data (cdr data))))
2829 (defun gnus-summary-article-pseudo-p (article)
2830 "Say whether this article is a pseudo article or not."
2831 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2833 (defmacro gnus-summary-article-sparse-p (article)
2834 "Say whether this article is a sparse article or not."
2835 `(memq ,article gnus-newsgroup-sparse))
2837 (defmacro gnus-summary-article-ancient-p (article)
2838 "Say whether this article is a sparse article or not."
2839 `(memq ,article gnus-newsgroup-ancient))
2841 (defun gnus-article-parent-p (number)
2842 "Say whether this article is a parent or not."
2843 (let ((data (gnus-data-find-list number)))
2844 (and (cdr data) ; There has to be an article after...
2845 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2846 (gnus-data-level (nth 1 data))))))
2848 (defun gnus-article-children (number)
2849 "Return a list of all children to NUMBER."
2850 (let* ((data (gnus-data-find-list number))
2851 (level (gnus-data-level (car data)))
2853 (setq data (cdr data))
2855 (= (gnus-data-level (car data)) (1+ level)))
2856 (push (gnus-data-number (car data)) children)
2857 (setq data (cdr data)))
2860 (defmacro gnus-summary-skip-intangible ()
2861 "If the current article is intangible, then jump to a different article."
2862 '(let ((to (get-text-property (point) 'gnus-intangible)))
2863 (and to (gnus-summary-goto-subject to))))
2865 (defmacro gnus-summary-article-intangible-p ()
2866 "Say whether this article is intangible or not."
2867 '(get-text-property (point) 'gnus-intangible))
2869 (defun gnus-article-read-p (article)
2870 "Say whether ARTICLE is read or not."
2871 (not (or (memq article gnus-newsgroup-marked)
2872 (memq article gnus-newsgroup-spam-marked)
2873 (memq article gnus-newsgroup-unreads)
2874 (memq article gnus-newsgroup-unselected)
2875 (memq article gnus-newsgroup-dormant))))
2877 ;; Some summary mode macros.
2879 (defmacro gnus-summary-article-number ()
2880 "The article number of the article on the current line.
2881 If there isn't an article number here, then we return the current
2884 (gnus-summary-skip-intangible)
2885 (or (get-text-property (point) 'gnus-number)
2886 (gnus-summary-last-subject))))
2888 (defmacro gnus-summary-article-header (&optional number)
2889 "Return the header of article NUMBER."
2890 `(gnus-data-header (gnus-data-find
2891 ,(or number '(gnus-summary-article-number)))))
2893 (defmacro gnus-summary-thread-level (&optional number)
2894 "Return the level of thread that starts with article NUMBER."
2895 `(if (and (eq gnus-summary-make-false-root 'dummy)
2896 (get-text-property (point) 'gnus-intangible))
2898 (gnus-data-level (gnus-data-find
2899 ,(or number '(gnus-summary-article-number))))))
2901 (defmacro gnus-summary-article-mark (&optional number)
2902 "Return the mark of article NUMBER."
2903 `(gnus-data-mark (gnus-data-find
2904 ,(or number '(gnus-summary-article-number)))))
2906 (defmacro gnus-summary-article-pos (&optional number)
2907 "Return the position of the line of article NUMBER."
2908 `(gnus-data-pos (gnus-data-find
2909 ,(or number '(gnus-summary-article-number)))))
2911 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2912 (defmacro gnus-summary-article-subject (&optional number)
2913 "Return current subject string or nil if nothing."
2916 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2917 '(gnus-data-header (assq (gnus-summary-article-number)
2918 gnus-newsgroup-data)))))
2921 (mail-header-subject headers))))
2923 (defmacro gnus-summary-article-score (&optional number)
2924 "Return current article score."
2925 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2926 gnus-newsgroup-scored))
2927 gnus-summary-default-score 0))
2929 (defun gnus-summary-article-children (&optional number)
2930 "Return a list of article numbers that are children of article NUMBER."
2931 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2932 (level (gnus-data-level (car data)))
2934 (while (and (setq data (cdr data))
2935 (> (setq l (gnus-data-level (car data))) level))
2936 (and (= (1+ level) l)
2937 (push (gnus-data-number (car data))
2939 (nreverse children)))
2941 (defun gnus-summary-article-parent (&optional number)
2942 "Return the article number of the parent of article NUMBER."
2943 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2944 (gnus-data-list t)))
2945 (level (gnus-data-level (car data))))
2947 () ; This is a root.
2948 ;; We search until we find an article with a level less than
2949 ;; this one. That function has to be the parent.
2950 (while (and (setq data (cdr data))
2951 (not (< (gnus-data-level (car data)) level))))
2952 (and data (gnus-data-number (car data))))))
2954 (defun gnus-unread-mark-p (mark)
2955 "Say whether MARK is the unread mark."
2956 (= mark gnus-unread-mark))
2958 (defun gnus-read-mark-p (mark)
2959 "Say whether MARK is one of the marks that mark as read.
2960 This is all marks except unread, ticked, dormant, and expirable."
2961 (not (or (= mark gnus-unread-mark)
2962 (= mark gnus-ticked-mark)
2963 (= mark gnus-spam-mark)
2964 (= mark gnus-dormant-mark)
2965 (= mark gnus-expirable-mark))))
2967 (defmacro gnus-article-mark (number)
2968 "Return the MARK of article NUMBER.
2969 This macro should only be used when computing the mark the \"first\"
2970 time; i.e., when generating the summary lines. After that,
2971 `gnus-summary-article-mark' should be used to examine the
2974 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2975 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2976 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2977 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2978 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2979 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2980 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2981 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2982 gnus-ancient-mark))))
2984 ;; Saving hidden threads.
2986 (defmacro gnus-save-hidden-threads (&rest forms)
2987 "Save hidden threads, eval FORMS, and restore the hidden threads."
2988 (let ((config (make-symbol "config")))
2989 `(let ((,config (gnus-hidden-threads-configuration)))
2993 (gnus-restore-hidden-threads-configuration ,config)))))
2994 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2995 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2997 (defun gnus-data-compute-positions ()
2998 "Compute the positions of all articles."
2999 (setq gnus-newsgroup-data-reverse nil)
3000 (let ((data gnus-newsgroup-data))
3002 (gnus-save-hidden-threads
3003 (gnus-summary-show-all-threads)
3004 (goto-char (point-min))
3006 (while (get-text-property (point) 'gnus-intangible)
3008 (gnus-data-set-pos (car data) (+ (point) 3))
3009 (setq data (cdr data))
3010 (forward-line 1))))))
3012 (defun gnus-hidden-threads-configuration ()
3013 "Return the current hidden threads configuration."
3016 (goto-char (point-min))
3017 (while (search-forward "\r" nil t)
3018 (push (1- (point)) config))
3021 (defun gnus-restore-hidden-threads-configuration (config)
3022 "Restore hidden threads configuration from CONFIG."
3024 (let (point buffer-read-only)
3025 (while (setq point (pop config))
3026 (when (and (< point (point-max))
3028 (eq (char-after) ?\n))
3029 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3031 ;; Various summary mode internalish functions.
3033 (defun gnus-mouse-pick-article (e)
3036 (gnus-summary-next-page nil t))
3038 (defun gnus-summary-set-display-table ()
3039 "Change the display table.
3040 Odd characters have a tendency to mess
3041 up nicely formatted displays - we make all possible glyphs
3042 display only a single character."
3044 ;; We start from the standard display table, if any.
3045 (let ((table (or (copy-sequence standard-display-table)
3046 (make-display-table)))
3048 ;; Nix out all the control chars...
3049 (while (>= (setq i (1- i)) 0)
3050 (aset table i [??]))
3051 ;; ... but not newline and cr, of course. (cr is necessary for the
3052 ;; selective display).
3053 (aset table ?\n nil)
3054 (aset table ?\r nil)
3055 ;; We keep TAB as well.
3056 (aset table ?\t nil)
3057 ;; We nix out any glyphs over 126 that are not set already.
3059 (while (>= (setq i (1- i)) 127)
3060 ;; Only modify if the entry is nil.
3061 (unless (aref table i)
3062 (aset table i [??]))))
3063 (setq buffer-display-table table)))
3065 (defun gnus-summary-set-article-display-arrow (pos)
3066 "Update the overlay arrow to point to line at position POS."
3067 (when (and gnus-summary-display-arrow
3068 (boundp 'overlay-arrow-position)
3069 (boundp 'overlay-arrow-string))
3073 (unless overlay-arrow-position
3074 (setq overlay-arrow-position (make-marker)))
3075 (setq overlay-arrow-string "=>"
3076 overlay-arrow-position (set-marker overlay-arrow-position
3078 (current-buffer))))))
3080 (defun gnus-summary-setup-buffer (group)
3081 "Initialize summary buffer."
3082 (let ((buffer (gnus-summary-buffer-name group))
3083 (dead-name (concat "*Dead Summary "
3084 (gnus-group-decoded-name group) "*")))
3085 ;; If a dead summary buffer exists, we kill it.
3086 (when (gnus-buffer-live-p dead-name)
3087 (gnus-kill-buffer dead-name))
3088 (if (get-buffer buffer)
3091 (setq gnus-summary-buffer (current-buffer))
3092 (not gnus-newsgroup-prepared))
3093 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3094 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3095 (gnus-summary-mode group)
3097 (gnus-carpal-setup-buffer 'summary))
3098 (unless gnus-single-article-buffer
3099 (make-local-variable 'gnus-article-buffer)
3100 (make-local-variable 'gnus-article-current)
3101 (make-local-variable 'gnus-original-article-buffer))
3102 (setq gnus-newsgroup-name group)
3103 ;; Set any local variables in the group parameters.
3104 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3107 (defun gnus-set-global-variables ()
3108 "Set the global equivalents of the buffer-local variables.
3109 They are set to the latest values they had. These reflect the summary
3110 buffer that was in action when the last article was fetched."
3111 (when (eq major-mode 'gnus-summary-mode)
3112 (setq gnus-summary-buffer (current-buffer))
3113 (let ((name gnus-newsgroup-name)
3114 (marked gnus-newsgroup-marked)
3115 (spam gnus-newsgroup-spam-marked)
3116 (unread gnus-newsgroup-unreads)
3117 (headers gnus-current-headers)
3118 (data gnus-newsgroup-data)
3119 (summary gnus-summary-buffer)
3120 (article-buffer gnus-article-buffer)
3121 (original gnus-original-article-buffer)
3122 (gac gnus-article-current)
3123 (reffed gnus-reffed-article-number)
3124 (score-file gnus-current-score-file)
3125 (default-charset gnus-newsgroup-charset)
3127 (let ((locals gnus-newsgroup-variables))
3129 (if (consp (car locals))
3130 (push (eval (caar locals)) vlist)
3131 (push (eval (car locals)) vlist))
3132 (setq locals (cdr locals)))
3133 (setq vlist (nreverse vlist)))
3135 (set-buffer gnus-group-buffer)
3136 (setq gnus-newsgroup-name name
3137 gnus-newsgroup-marked marked
3138 gnus-newsgroup-spam-marked spam
3139 gnus-newsgroup-unreads unread
3140 gnus-current-headers headers
3141 gnus-newsgroup-data data
3142 gnus-article-current gac
3143 gnus-summary-buffer summary
3144 gnus-article-buffer article-buffer
3145 gnus-original-article-buffer original
3146 gnus-reffed-article-number reffed
3147 gnus-current-score-file score-file
3148 gnus-newsgroup-charset default-charset)
3149 (let ((locals gnus-newsgroup-variables))
3151 (if (consp (car locals))
3152 (set (caar locals) (pop vlist))
3153 (set (car locals) (pop vlist)))
3154 (setq locals (cdr locals))))
3155 ;; The article buffer also has local variables.
3156 (when (gnus-buffer-live-p gnus-article-buffer)
3157 (set-buffer gnus-article-buffer)
3158 (setq gnus-summary-buffer summary))))))
3160 (defun gnus-summary-article-unread-p (article)
3161 "Say whether ARTICLE is unread or not."
3162 (memq article gnus-newsgroup-unreads))
3164 (defun gnus-summary-first-article-p (&optional article)
3165 "Return whether ARTICLE is the first article in the buffer."
3166 (if (not (setq article (or article (gnus-summary-article-number))))
3168 (eq article (caar gnus-newsgroup-data))))
3170 (defun gnus-summary-last-article-p (&optional article)
3171 "Return whether ARTICLE is the last article in the buffer."
3172 (if (not (setq article (or article (gnus-summary-article-number))))
3173 ;; All non-existent numbers are the last article. :-)
3175 (not (cdr (gnus-data-find-list article)))))
3177 (defun gnus-make-thread-indent-array ()
3179 (unless (and gnus-thread-indent-array
3180 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3181 (setq gnus-thread-indent-array (make-vector 201 "")
3182 gnus-thread-indent-array-level gnus-thread-indent-level)
3184 (aset gnus-thread-indent-array n
3185 (make-string (* n gnus-thread-indent-level) ? ))
3188 (defun gnus-update-summary-mark-positions ()
3189 "Compute where the summary marks are to go."
3191 (when (gnus-buffer-exists-p gnus-summary-buffer)
3192 (set-buffer gnus-summary-buffer))
3193 (let ((gnus-replied-mark 129)
3194 (gnus-score-below-mark 130)
3195 (gnus-score-over-mark 130)
3196 (gnus-undownloaded-mark 131)
3197 (spec gnus-summary-line-format-spec)
3200 (gnus-set-work-buffer)
3201 (let ((gnus-summary-line-format-spec spec)
3202 (gnus-newsgroup-downloadable '(0)))
3203 (gnus-summary-insert-line
3204 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3205 0 nil t 128 t nil "" nil 1)
3206 (goto-char (point-min))
3207 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3208 (- (point) (point-min) 1)))))
3209 (goto-char (point-min))
3210 (push (cons 'replied (and (search-forward "\201" nil t)
3211 (- (point) (point-min) 1)))
3213 (goto-char (point-min))
3214 (push (cons 'score (and (search-forward "\202" nil t)
3215 (- (point) (point-min) 1)))
3217 (goto-char (point-min))
3218 (push (cons 'download
3219 (and (search-forward "\203" nil t)
3220 (- (point) (point-min) 1)))
3222 (setq gnus-summary-mark-positions pos))))
3224 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3225 "Insert a dummy root in the summary buffer."
3227 (gnus-add-text-properties
3228 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3229 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3231 (defun gnus-summary-extract-address-component (from)
3232 (or (car (funcall gnus-extract-address-components from))
3235 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3236 (let ((mail-parse-charset gnus-newsgroup-charset)
3237 ; Is it really necessary to do this next part for each summary line?
3238 ; Luckily, doesn't seem to slow things down much.
3239 (mail-parse-ignored-charsets
3240 (save-excursion (set-buffer gnus-summary-buffer)
3241 gnus-newsgroup-ignored-charsets)))
3243 (and gnus-ignored-from-addresses
3244 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3245 (let ((extra-headers (mail-header-extra header))
3249 ((setq to (cdr (assq 'To extra-headers)))
3252 (gnus-summary-extract-address-component
3253 (funcall gnus-decode-encoded-word-function to)))))
3254 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3255 (concat "=> " newsgroups)))))
3256 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3258 (defun gnus-summary-insert-line (gnus-tmp-header
3259 gnus-tmp-level gnus-tmp-current
3260 undownloaded gnus-tmp-unread gnus-tmp-replied
3261 gnus-tmp-expirable gnus-tmp-subject-or-nil
3262 &optional gnus-tmp-dummy gnus-tmp-score
3264 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3265 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3266 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3267 (gnus-tmp-score-char
3268 (if (or (null gnus-summary-default-score)
3269 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3270 gnus-summary-zcore-fuzz))
3272 (if (< gnus-tmp-score gnus-summary-default-score)
3273 gnus-score-below-mark gnus-score-over-mark)))
3274 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3276 (cond (gnus-tmp-process gnus-process-mark)
3277 ((memq gnus-tmp-current gnus-newsgroup-cached)
3279 (gnus-tmp-replied gnus-replied-mark)
3280 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3281 gnus-forwarded-mark)
3282 ((memq gnus-tmp-current gnus-newsgroup-saved)
3284 ((memq gnus-tmp-number gnus-newsgroup-recent)
3286 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3289 (gnus-tmp-downloaded
3291 gnus-undownloaded-mark)
3292 (gnus-newsgroup-agentized
3293 gnus-downloaded-mark)
3296 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3299 ((string-match "<[^>]+> *$" gnus-tmp-from)
3300 (let ((beg (match-beginning 0)))
3301 (or (and (string-match "^\".+\"" gnus-tmp-from)
3302 (substring gnus-tmp-from 1 (1- (match-end 0))))
3303 (substring gnus-tmp-from 0 beg))))
3304 ((string-match "(.+)" gnus-tmp-from)
3305 (substring gnus-tmp-from
3306 (1+ (match-beginning 0)) (1- (match-end 0))))
3308 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3309 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3310 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3311 (buffer-read-only nil))
3312 (when (string= gnus-tmp-name "")
3313 (setq gnus-tmp-name gnus-tmp-from))
3314 (unless (numberp gnus-tmp-lines)
3315 (setq gnus-tmp-lines -1))
3316 (if (= gnus-tmp-lines -1)
3317 (setq gnus-tmp-lines "?")
3318 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3319 (gnus-put-text-property
3321 (progn (eval gnus-summary-line-format-spec) (point))
3322 'gnus-number gnus-tmp-number)
3323 (when (gnus-visual-p 'summary-highlight 'highlight)
3325 (gnus-run-hooks 'gnus-summary-update-hook)
3328 (defun gnus-summary-update-line (&optional dont-update)
3329 "Update summary line after change."
3330 (when (and gnus-summary-default-score
3331 (not gnus-summary-inhibit-highlight))
3332 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3333 (article (gnus-summary-article-number))
3334 (score (gnus-summary-article-score article)))
3336 (if (and gnus-summary-mark-below
3337 (< (gnus-summary-article-score)
3338 gnus-summary-mark-below))
3339 ;; This article has a low score, so we mark it as read.
3340 (when (memq article gnus-newsgroup-unreads)
3341 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3342 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3343 ;; This article was previously marked as read on account
3344 ;; of a low score, but now it has risen, so we mark it as
3346 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3347 (gnus-summary-update-mark
3348 (if (or (null gnus-summary-default-score)
3349 (<= (abs (- score gnus-summary-default-score))
3350 gnus-summary-zcore-fuzz))
3352 (if (< score gnus-summary-default-score)
3353 gnus-score-below-mark gnus-score-over-mark))
3355 ;; Do visual highlighting.
3356 (when (gnus-visual-p 'summary-highlight 'highlight)
3357 (gnus-run-hooks 'gnus-summary-update-hook)))))
3359 (defvar gnus-tmp-new-adopts nil)
3361 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3362 "Return the number of articles in THREAD.
3363 This may be 0 in some cases -- if none of the articles in
3364 the thread are to be displayed."
3366 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3368 ((not (listp thread))
3370 ((and (consp thread) (cdr thread))
3373 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3376 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3379 (when (and level (zerop level) gnus-tmp-new-adopts)
3382 'gnus-summary-number-of-articles-in-thread
3383 gnus-tmp-new-adopts))))
3385 (if (> number 1) gnus-not-empty-thread-mark
3386 gnus-empty-thread-mark)
3389 (defsubst gnus-summary-line-message-size (head)
3390 "Return pretty-printed version of message size.
3391 This function is intended to be used in
3392 `gnus-summary-line-format-alist'."
3393 (let ((c (or (mail-header-chars head) -1)))
3394 (cond ((< c 0) "n/a") ; chars not available
3395 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3396 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3397 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3398 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3401 (defun gnus-summary-set-local-parameters (group)
3402 "Go through the local params of GROUP and set all variable specs in that list."
3403 (let ((params (gnus-group-find-parameter group))
3404 (vars '(quit-config)) ; Ignore quit-config.
3407 (setq elem (car params)
3408 params (cdr params))
3409 (and (consp elem) ; Has to be a cons.
3410 (consp (cdr elem)) ; The cdr has to be a list.
3411 (symbolp (car elem)) ; Has to be a symbol in there.
3412 (not (memq (car elem) vars))
3413 (ignore-errors ; So we set it.
3414 (push (car elem) vars)
3415 (make-local-variable (car elem))
3416 (set (car elem) (eval (nth 1 elem))))))))
3418 (defun gnus-summary-read-group (group &optional show-all no-article
3419 kill-buffer no-display backward
3421 "Start reading news in newsgroup GROUP.
3422 If SHOW-ALL is non-nil, already read articles are also listed.
3423 If NO-ARTICLE is non-nil, no article is selected initially.
3424 If NO-DISPLAY, don't generate a summary buffer."
3428 (let ((gnus-auto-select-next nil))
3429 (or (gnus-summary-read-group-1
3430 group show-all no-article
3431 kill-buffer no-display
3434 select-articles nil)))))
3435 (eq gnus-auto-select-next 'quietly))
3436 (set-buffer gnus-group-buffer)
3437 ;; The entry function called above goes to the next
3438 ;; group automatically, so we go two groups back
3439 ;; if we are searching for the previous group.
3441 (gnus-group-prev-unread-group 2))
3442 (if (not (equal group (gnus-group-group-name)))
3443 (setq group (gnus-group-group-name))
3447 (defun gnus-summary-read-group-1 (group show-all no-article
3448 kill-buffer no-display
3449 &optional select-articles)
3450 ;; Killed foreign groups can't be entered.
3451 ;; (when (and (not (gnus-group-native-p group))
3452 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3453 ;; (error "Dead non-native groups can't be entered"))
3454 (gnus-message 5 "Retrieving newsgroup: %s..."
3455 (gnus-group-decoded-name group))
3456 (let* ((new-group (gnus-summary-setup-buffer group))
3457 (quit-config (gnus-group-quit-config group))
3458 (did-select (and new-group (gnus-select-newsgroup
3459 group show-all select-articles))))
3461 ;; This summary buffer exists already, so we just select it.
3463 (gnus-set-global-variables)
3465 (gnus-kill-or-deaden-summary kill-buffer))
3466 (gnus-configure-windows 'summary 'force)
3467 (gnus-set-mode-line 'summary)
3468 (gnus-summary-position-point)
3471 ;; We couldn't select this group.
3473 (when (and (eq major-mode 'gnus-summary-mode)
3474 (not (equal (current-buffer) kill-buffer)))
3475 (kill-buffer (current-buffer))
3476 (if (not quit-config)
3478 ;; Update the info -- marks might need to be removed,
3480 (gnus-summary-update-info)
3481 (set-buffer gnus-group-buffer)
3482 (gnus-group-jump-to-group group)
3483 (gnus-group-next-unread-group 1))
3484 (gnus-handle-ephemeral-exit quit-config)))
3485 (let ((grpinfo (gnus-get-info group)))
3486 (if (null (gnus-info-read grpinfo))
3487 (gnus-message 3 "Group %s contains no messages"
3488 (gnus-group-decoded-name group))
3489 (gnus-message 3 "Can't select group")))
3491 ;; The user did a `C-g' while prompting for number of articles,
3492 ;; so we exit this group.
3493 ((eq did-select 'quit)
3494 (and (eq major-mode 'gnus-summary-mode)
3495 (not (equal (current-buffer) kill-buffer))
3496 (kill-buffer (current-buffer)))
3498 (gnus-kill-or-deaden-summary kill-buffer))
3499 (if (not quit-config)
3501 (set-buffer gnus-group-buffer)
3502 (gnus-group-jump-to-group group)
3503 (gnus-group-next-unread-group 1)
3504 (gnus-configure-windows 'group 'force))
3505 (gnus-handle-ephemeral-exit quit-config))
3506 ;; Finally signal the quit.
3508 ;; The group was successfully selected.
3510 (gnus-set-global-variables)
3511 ;; Save the active value in effect when the group was entered.
3512 (setq gnus-newsgroup-active
3514 (gnus-active gnus-newsgroup-name)))
3515 ;; You can change the summary buffer in some way with this hook.
3516 (gnus-run-hooks 'gnus-select-group-hook)
3517 (gnus-update-format-specifications
3518 nil 'summary 'summary-mode 'summary-dummy)
3519 (gnus-update-summary-mark-positions)
3520 ;; Do score processing.
3521 (when gnus-use-scoring
3522 (gnus-possibly-score-headers))
3523 ;; Check whether to fill in the gaps in the threads.
3524 (when gnus-build-sparse-threads
3525 (gnus-build-sparse-threads))
3526 ;; Find the initial limit.
3527 (if gnus-show-threads
3529 (let ((gnus-newsgroup-dormant nil))
3530 (gnus-summary-initial-limit show-all))
3531 (gnus-summary-initial-limit show-all))
3532 ;; When unthreaded, all articles are always shown.
3533 (setq gnus-newsgroup-limit
3535 (lambda (header) (mail-header-number header))
3536 gnus-newsgroup-headers)))
3537 ;; Generate the summary buffer.
3539 (gnus-summary-prepare))
3540 (when gnus-use-trees
3541 (gnus-tree-open group)
3542 (setq gnus-summary-highlight-line-function
3543 'gnus-tree-highlight-article))
3544 ;; If the summary buffer is empty, but there are some low-scored
3545 ;; articles or some excluded dormants, we include these in the
3547 (when (and (zerop (buffer-size))
3549 (cond (gnus-newsgroup-dormant
3550 (gnus-summary-limit-include-dormant))
3551 ((and gnus-newsgroup-scored show-all)
3552 (gnus-summary-limit-include-expunged t))))
3553 ;; Function `gnus-apply-kill-file' must be called in this hook.
3554 (gnus-run-hooks 'gnus-apply-kill-hook)
3555 (if (and (zerop (buffer-size))
3558 ;; This newsgroup is empty.
3559 (gnus-summary-catchup-and-exit nil t)
3560 (gnus-message 6 "No unread news")
3562 (gnus-kill-or-deaden-summary kill-buffer))
3563 ;; Return nil from this function.
3565 ;; Hide conversation thread subtrees. We cannot do this in
3566 ;; gnus-summary-prepare-hook since kill processing may not
3567 ;; work with hidden articles.
3568 (gnus-summary-maybe-hide-threads)
3570 (gnus-kill-or-deaden-summary kill-buffer))
3571 (gnus-summary-auto-select-subject)
3572 ;; Show first unread article if requested.
3573 (if (and (not no-article)
3575 gnus-newsgroup-unreads
3576 gnus-auto-select-first)
3578 (gnus-configure-windows 'summary)
3579 (let ((art (gnus-summary-article-number)))
3580 (unless (and (not gnus-plugged)
3581 (or (memq art gnus-newsgroup-undownloaded)
3582 (memq art gnus-newsgroup-downloadable)))
3583 (gnus-summary-goto-article art))))
3584 ;; Don't select any articles.
3585 (gnus-summary-position-point)
3586 (gnus-configure-windows 'summary 'force)
3587 (gnus-set-mode-line 'summary))
3588 (when (and gnus-auto-center-group
3589 (get-buffer-window gnus-group-buffer t))
3590 ;; Gotta use windows, because recenter does weird stuff if
3591 ;; the current buffer ain't the displayed window.
3592 (let ((owin (selected-window)))
3593 (select-window (get-buffer-window gnus-group-buffer t))
3594 (when (gnus-group-goto-group group)
3596 (select-window owin)))
3597 ;; Mark this buffer as "prepared".
3598 (setq gnus-newsgroup-prepared t)
3599 (gnus-run-hooks 'gnus-summary-prepared-hook)
3600 (unless (gnus-ephemeral-group-p group)
3601 (gnus-group-update-group group))
3604 (defun gnus-summary-auto-select-subject ()
3605 "Select the subject line on initial group entry."
3606 (goto-char (point-min))
3608 ((eq gnus-auto-select-subject 'best)
3609 (gnus-summary-best-unread-subject))
3610 ((eq gnus-auto-select-subject 'unread)
3611 (gnus-summary-first-unread-subject))
3612 ((eq gnus-auto-select-subject 'unseen)
3613 (gnus-summary-first-unseen-subject))
3614 ((eq gnus-auto-select-subject 'unseen-or-unread)
3615 (gnus-summary-first-unseen-or-unread-subject))
3616 ((eq gnus-auto-select-subject 'first)
3619 ((gnus-functionp gnus-auto-select-subject)
3620 (funcall gnus-auto-select-subject))))
3622 (defun gnus-summary-prepare ()
3623 "Generate the summary buffer."
3625 (let ((buffer-read-only nil))
3627 (setq gnus-newsgroup-data nil
3628 gnus-newsgroup-data-reverse nil)
3629 (gnus-run-hooks 'gnus-summary-generate-hook)
3630 ;; Generate the buffer, either with threads or without.
3631 (when gnus-newsgroup-headers
3632 (gnus-summary-prepare-threads
3633 (if gnus-show-threads
3634 (gnus-sort-gathered-threads
3635 (funcall gnus-summary-thread-gathering-function
3637 (gnus-cut-threads (gnus-make-threads)))))
3638 ;; Unthreaded display.
3639 (gnus-sort-articles gnus-newsgroup-headers))))
3640 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3641 ;; Call hooks for modifying summary buffer.
3642 (goto-char (point-min))
3643 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3645 (defsubst gnus-general-simplify-subject (subject)
3646 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3649 ;; Truncate the subject.
3650 (gnus-simplify-subject-functions
3651 (gnus-map-function gnus-simplify-subject-functions subject))
3652 ((numberp gnus-summary-gather-subject-limit)
3653 (setq subject (gnus-simplify-subject-re subject))
3654 (if (> (length subject) gnus-summary-gather-subject-limit)
3655 (substring subject 0 gnus-summary-gather-subject-limit)
3657 ;; Fuzzily simplify it.
3658 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3659 (gnus-simplify-subject-fuzzy subject))
3660 ;; Just remove the leading "Re:".
3662 (gnus-simplify-subject-re subject))))
3664 (if (and gnus-summary-gather-exclude-subject
3665 (string-match gnus-summary-gather-exclude-subject subject))
3666 nil ; This article shouldn't be gathered
3669 (defun gnus-summary-simplify-subject-query ()
3670 "Query where the respool algorithm would put this article."
3672 (gnus-summary-select-article)
3673 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3675 (defun gnus-gather-threads-by-subject (threads)
3676 "Gather threads by looking at Subject headers."
3677 (if (not gnus-summary-make-false-root)
3679 (let ((hashtb (gnus-make-hashtable 1024))
3682 subject hthread whole-subject)
3684 (setq subject (gnus-general-simplify-subject
3685 (setq whole-subject (mail-header-subject
3688 (if (setq hthread (gnus-gethash subject hashtb))
3690 ;; We enter a dummy root into the thread, if we
3691 ;; haven't done that already.
3692 (unless (stringp (caar hthread))
3693 (setcar hthread (list whole-subject (car hthread))))
3694 ;; We add this new gathered thread to this gathered
3696 (setcdr (car hthread)
3697 (nconc (cdar hthread) (list (car threads))))
3698 ;; Remove it from the list of threads.
3699 (setcdr prev (cdr threads))
3700 (setq threads prev))
3701 ;; Enter this thread into the hash table.
3702 (gnus-sethash subject
3703 (if gnus-summary-make-false-root-always
3705 ;; If you want a dummy root above all
3707 (setcar threads (list whole-subject
3713 (setq threads (cdr threads)))
3716 (defun gnus-gather-threads-by-references (threads)
3717 "Gather threads by looking at References headers."
3718 (let ((idhashtb (gnus-make-hashtable 1024))
3719 (thhashtb (gnus-make-hashtable 1024))
3722 ids references id gthread gid entered ref)
3724 (when (setq references (mail-header-references (caar threads)))
3725 (setq id (mail-header-id (caar threads))
3726 ids (inline (gnus-split-references references))
3728 (while (setq ref (pop ids))
3729 (setq ids (delete ref ids))
3730 (if (not (setq gid (gnus-gethash ref idhashtb)))
3732 (gnus-sethash ref id idhashtb)
3733 (gnus-sethash id threads thhashtb))
3734 (setq gthread (gnus-gethash gid thhashtb))
3736 ;; We enter a dummy root into the thread, if we
3737 ;; haven't done that already.
3738 (unless (stringp (caar gthread))
3739 (setcar gthread (list (mail-header-subject (caar gthread))
3741 ;; We add this new gathered thread to this gathered
3743 (setcdr (car gthread)
3744 (nconc (cdar gthread) (list (car threads)))))
3745 ;; Add it into the thread hash table.
3746 (gnus-sethash id gthread thhashtb)
3748 ;; Remove it from the list of threads.
3749 (setcdr prev (cdr threads))
3750 (setq threads prev))))
3752 (setq threads (cdr threads)))
3755 (defun gnus-sort-gathered-threads (threads)
3756 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3757 (let ((result threads))
3759 (when (stringp (caar threads))
3760 (setcdr (car threads)
3761 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3762 (setq threads (cdr threads)))
3765 (defun gnus-thread-loop-p (root thread)
3766 "Say whether ROOT is in THREAD."
3767 (let ((stack (list thread))
3770 (while (setq thread (pop stack))
3771 (setq th (cdr thread))
3773 (not (eq (caar th) root)))
3776 ;; We have found a loop.
3778 (setcdr thread (delq (car th) (cdr thread)))
3779 (if (boundp (setq ref-dep (intern "none"
3780 gnus-newsgroup-dependencies)))
3781 (setcdr (symbol-value ref-dep)
3782 (nconc (cdr (symbol-value ref-dep))
3784 (set ref-dep (list nil (car th))))
3787 ;; Push all the subthreads onto the stack.
3788 (push (cdr thread) stack)))
3791 (defun gnus-make-threads ()
3792 "Go through the dependency hashtb and find the roots. Return all threads."
3794 (while (catch 'infloop
3797 ;; Deal with self-referencing References loops.
3798 (when (and (car (symbol-value refs))
3805 (car (symbol-value refs)) thread))
3806 (cdr (symbol-value refs)))))))
3809 (unless (car (symbol-value refs))
3810 ;; These threads do not refer back to any other
3811 ;; articles, so they're roots.
3812 (setq threads (append (cdr (symbol-value refs)) threads))))
3813 gnus-newsgroup-dependencies)))
3816 ;; Build the thread tree.
3817 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3818 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3820 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3821 if it was already present.
3823 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3824 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3825 Message-IDs will be renamed to a unique Message-ID before being
3828 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3829 (let* ((id (mail-header-id header))
3830 (id-dep (and id (intern id dependencies)))
3831 parent-id ref ref-dep ref-header replaced)
3832 ;; Enter this `header' in the `dependencies' table.
3836 ;; The first two cases do the normal part: enter a new `header'
3837 ;; in the `dependencies' table.
3838 ((not (boundp id-dep))
3839 (set id-dep (list header)))
3840 ((null (car (symbol-value id-dep)))
3841 (setcar (symbol-value id-dep) header))
3843 ;; From here the `header' was already present in the
3844 ;; `dependencies' table.
3846 ;; Overrides an existing entry;
3847 ;; just set the header part of the entry.
3848 (setcar (symbol-value id-dep) header)
3851 ;; Renames the existing `header' to a unique Message-ID.
3852 ((not gnus-summary-ignore-duplicates)
3853 ;; An article with this Message-ID has already been seen.
3854 ;; We rename the Message-ID.
3855 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3857 (mail-header-set-id header id))
3859 ;; The last case ignores an existing entry, except it adds any
3860 ;; additional Xrefs (in case the two articles came from different
3862 ;; Also sets `header' to `nil' meaning that the `dependencies'
3863 ;; table was *not* modified.
3865 (mail-header-set-xref
3866 (car (symbol-value id-dep))
3867 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3869 (or (mail-header-xref header) "")))
3872 (when (and header (not replaced))
3873 ;; First check that we are not creating a References loop.
3874 (setq parent-id (gnus-parent-id (mail-header-references header)))
3875 (setq ref parent-id)
3877 (setq ref-dep (intern-soft ref dependencies))
3879 (setq ref-header (car (symbol-value ref-dep))))
3880 (if (string= id ref)
3881 ;; Yuk! This is a reference loop. Make the article be a
3884 (mail-header-set-references (car (symbol-value id-dep)) "none")
3886 (setq parent-id nil))
3887 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3888 (setq ref-dep (intern (or parent-id "none") dependencies))
3889 (if (boundp ref-dep)
3890 (setcdr (symbol-value ref-dep)
3891 (nconc (cdr (symbol-value ref-dep))
3892 (list (symbol-value id-dep))))
3893 (set ref-dep (list nil (symbol-value id-dep)))))
3896 (defun gnus-extract-message-id-from-in-reply-to (string)
3897 (if (string-match "<[^>]+>" string)
3898 (substring string (match-beginning 0) (match-end 0))
3901 (defun gnus-build-sparse-threads ()
3902 (let ((headers gnus-newsgroup-headers)
3903 (mail-parse-charset gnus-newsgroup-charset)
3904 (gnus-summary-ignore-duplicates t)
3905 header references generation relations
3906 subject child end new-child date)
3907 ;; First we create an alist of generations/relations, where
3908 ;; generations is how much we trust the relation, and the relation
3910 (gnus-message 7 "Making sparse threads...")
3912 (nnheader-set-temp-buffer " *gnus sparse threads*")
3913 (while (setq header (pop headers))
3914 (when (and (setq references (mail-header-references header))
3915 (not (string= references "")))
3917 (setq child (mail-header-id header)
3918 subject (mail-header-subject header)
3919 date (mail-header-date header)
3921 (while (search-backward ">" nil t)
3922 (setq end (1+ (point)))
3923 (when (search-backward "<" nil t)
3924 (setq new-child (buffer-substring (point) end))
3925 (push (list (incf generation)
3926 child (setq child new-child)
3930 (push (list (1+ generation) child nil subject) relations))
3932 (kill-buffer (current-buffer)))
3933 ;; Sort over trustworthiness.
3936 (when (gnus-dependencies-add-header
3937 (make-full-mail-header
3938 gnus-reffed-article-number
3939 (nth 3 relation) "" (or (nth 4 relation) "")
3941 (or (nth 2 relation) "") 0 0 "")
3942 gnus-newsgroup-dependencies nil)
3943 (push gnus-reffed-article-number gnus-newsgroup-limit)
3944 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3945 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3946 gnus-newsgroup-reads)
3947 (decf gnus-reffed-article-number)))
3948 (sort relations 'car-less-than-car))
3949 (gnus-message 7 "Making sparse threads...done")))
3951 (defun gnus-build-old-threads ()
3952 ;; Look at all the articles that refer back to old articles, and
3953 ;; fetch the headers for the articles that aren't there. This will
3954 ;; build complete threads - if the roots haven't been expired by the
3956 (let ((mail-parse-charset gnus-newsgroup-charset)
3960 (when (not (car (symbol-value refs)))
3961 (setq heads (cdr (symbol-value refs)))
3963 (if (memq (mail-header-number (caar heads))
3964 gnus-newsgroup-dormant)
3965 (setq heads (cdr heads))
3966 (setq id (symbol-name refs))
3967 (while (and (setq id (gnus-build-get-header id))
3968 (not (car (gnus-id-to-thread id)))))
3969 (setq heads nil)))))
3970 gnus-newsgroup-dependencies)))
3972 ;; This function has to be called with point after the article number
3973 ;; on the beginning of the line.
3974 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3975 (let ((eol (gnus-point-at-eol))
3976 (buffer (current-buffer))
3977 header references in-reply-to)
3979 ;; overview: [num subject from date id refs chars lines misc]
3982 (narrow-to-region (point) eol)
3987 (make-full-mail-header
3989 (condition-case () ; subject
3990 (funcall gnus-decode-encoded-word-function
3991 (setq x (nnheader-nov-field)))
3993 (condition-case () ; from
3994 (funcall gnus-decode-encoded-word-function
3995 (setq x (nnheader-nov-field)))
3997 (nnheader-nov-field) ; date
3998 (nnheader-nov-read-message-id) ; id
3999 (setq references (nnheader-nov-field)) ; refs
4000 (nnheader-nov-read-integer) ; chars
4001 (nnheader-nov-read-integer) ; lines
4003 (if (looking-at "Xref: ")
4004 (goto-char (match-end 0)))
4005 (nnheader-nov-field)) ; Xref
4006 (nnheader-nov-parse-extra)))) ; extra
4010 (when (and (string= references "")
4011 (setq in-reply-to (mail-header-extra header))
4012 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4013 (mail-header-set-references
4014 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4016 (when gnus-alter-header-function
4017 (funcall gnus-alter-header-function header))
4018 (gnus-dependencies-add-header header dependencies force-new)))
4020 (defun gnus-build-get-header (id)
4021 "Look through the buffer of NOV lines and find the header to ID.
4022 Enter this line into the dependencies hash table, and return
4023 the id of the parent article (if any)."
4024 (let ((deps gnus-newsgroup-dependencies)
4028 (set-buffer nntp-server-buffer)
4029 (let ((case-fold-search nil))
4030 (goto-char (point-min))
4031 (while (and (not found)
4032 (search-forward id nil t))
4034 (setq found (looking-at
4035 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4036 (regexp-quote id))))
4037 (or found (beginning-of-line 2)))
4041 (setq header (gnus-nov-parse-line
4042 (read (current-buffer)) deps))
4043 (gnus-parent-id (mail-header-references header))))))
4045 (let ((number (mail-header-number header)))
4046 (push number gnus-newsgroup-limit)
4047 (push header gnus-newsgroup-headers)
4048 (if (memq number gnus-newsgroup-unselected)
4050 (setq gnus-newsgroup-unreads
4051 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4053 (setq gnus-newsgroup-unselected
4054 (delq number gnus-newsgroup-unselected)))
4055 (push number gnus-newsgroup-ancient)))))))
4057 (defun gnus-build-all-threads ()
4058 "Read all the headers."
4059 (let ((gnus-summary-ignore-duplicates t)
4060 (mail-parse-charset gnus-newsgroup-charset)
4061 (dependencies gnus-newsgroup-dependencies)
4064 (set-buffer nntp-server-buffer)
4065 (let ((case-fold-search nil))
4066 (goto-char (point-min))
4069 (setq article (read (current-buffer))
4070 header (gnus-nov-parse-line article dependencies)))
4073 (set-buffer gnus-summary-buffer)
4074 (push header gnus-newsgroup-headers)
4075 (if (memq (setq article (mail-header-number header))
4076 gnus-newsgroup-unselected)
4078 (setq gnus-newsgroup-unreads
4079 (gnus-add-to-sorted-list
4080 gnus-newsgroup-unreads article))
4081 (setq gnus-newsgroup-unselected
4082 (delq article gnus-newsgroup-unselected)))
4083 (push article gnus-newsgroup-ancient)))
4084 (forward-line 1)))))))
4086 (defun gnus-summary-update-article-line (article header)
4087 "Update the line for ARTICLE using HEADERS."
4088 (let* ((id (mail-header-id header))
4089 (thread (gnus-id-to-thread id)))
4091 (error "Article in no thread"))
4092 ;; Update the thread.
4093 (setcar thread header)
4094 (gnus-summary-goto-subject article)
4095 (let* ((datal (gnus-data-find-list article))
4097 (buffer-read-only nil)
4098 (level (gnus-summary-thread-level)))
4100 (let ((inserted (- (point)
4102 (gnus-summary-insert-line
4104 (memq article gnus-newsgroup-undownloaded)
4105 (gnus-article-mark article)
4106 (memq article gnus-newsgroup-replied)
4107 (memq article gnus-newsgroup-expirable)
4108 ;; Only insert the Subject string when it's different
4109 ;; from the previous Subject string.
4114 (mail-header-subject
4117 (gnus-data-find-list
4119 (gnus-data-list t)))))
4120 ;; Error on the side of excessive subjects.
4122 (mail-header-subject header)))
4124 (mail-header-subject header))
4125 nil (cdr (assq article gnus-newsgroup-scored))
4126 (memq article gnus-newsgroup-processable))
4129 (gnus-data-update-list
4131 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4133 (defun gnus-summary-update-article (article &optional iheader)
4134 "Update ARTICLE in the summary buffer."
4135 (set-buffer gnus-summary-buffer)
4136 (let* ((header (gnus-summary-article-header article))
4137 (id (mail-header-id header))
4138 (data (gnus-data-find article))
4139 (thread (gnus-id-to-thread id))
4140 (references (mail-header-references header))
4144 (when (and references
4145 (not (equal "" references)))
4148 (buffer-read-only nil)
4154 (delq thread parent)))
4155 (if (gnus-summary-insert-subject id header)
4156 ;; Set the (possibly) new article number in the data structure.
4157 (gnus-data-set-number data (gnus-id-to-article id))
4161 (defun gnus-rebuild-thread (id &optional line)
4162 "Rebuild the thread containing ID.
4163 If LINE, insert the rebuilt thread starting on line LINE."
4164 (let ((buffer-read-only nil)
4165 old-pos current thread data)
4166 (if (not gnus-show-threads)
4167 (setq thread (list (car (gnus-id-to-thread id))))
4168 ;; Get the thread this article is part of.
4169 (setq thread (gnus-remove-thread id)))
4170 (setq old-pos (gnus-point-at-bol))
4171 (setq current (save-excursion
4172 (and (re-search-backward "[\r\n]" nil t)
4173 (gnus-summary-article-number))))
4174 ;; If this is a gathered thread, we have to go some re-gathering.
4175 (when (stringp (car thread))
4176 (let ((subject (car thread))
4178 (setq thread (cdr thread))
4180 (unless (memq (setq thr (gnus-id-to-thread
4182 (mail-header-id (caar thread)))))
4185 (setq thread (cdr thread)))
4186 ;; We now have all (unique) roots.
4187 (if (= (length roots) 1)
4188 ;; All the loose roots are now one solid root.
4189 (setq thread (car roots))
4190 (setq thread (cons subject (gnus-sort-threads roots))))))
4192 ;; We then insert this thread into the summary buffer.
4194 (goto-char (point-min))
4195 (forward-line (1- line)))
4196 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4197 (if gnus-show-threads
4198 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4199 (gnus-summary-prepare-unthreaded thread))
4200 (setq data (nreverse gnus-newsgroup-data))
4201 (setq threads gnus-newsgroup-threads))
4202 ;; We splice the new data into the data structure.
4203 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4204 ;;!!! then we want to insert at the beginning of the buffer.
4205 ;;!!! That happens to be true with Gnus now, but that may
4206 ;;!!! change in the future. Perhaps.
4207 (gnus-data-enter-list
4208 (if line nil current) data (- (point) old-pos))
4209 (setq gnus-newsgroup-threads
4210 (nconc threads gnus-newsgroup-threads))
4211 (gnus-data-compute-positions))))
4213 (defun gnus-number-to-header (number)
4214 "Return the header for article NUMBER."
4215 (let ((headers gnus-newsgroup-headers))
4217 (not (= number (mail-header-number (car headers)))))
4222 (defun gnus-parent-headers (in-headers &optional generation)
4223 "Return the headers of the GENERATIONeth parent of HEADERS."
4225 (setq generation 1))
4227 (headers in-headers)
4230 (not (zerop generation))
4231 (setq references (mail-header-references headers)))
4232 (setq headers (if (and references
4233 (setq parent (gnus-parent-id references)))
4234 (car (gnus-id-to-thread parent))
4237 (and (not (eq headers in-headers))
4240 (defun gnus-id-to-thread (id)
4241 "Return the (sub-)thread where ID appears."
4242 (gnus-gethash id gnus-newsgroup-dependencies))
4244 (defun gnus-id-to-article (id)
4245 "Return the article number of ID."
4246 (let ((thread (gnus-id-to-thread id)))
4249 (mail-header-number (car thread)))))
4251 (defun gnus-id-to-header (id)
4252 "Return the article headers of ID."
4253 (car (gnus-id-to-thread id)))
4255 (defun gnus-article-displayed-root-p (article)
4256 "Say whether ARTICLE is a root(ish) article."
4257 (let ((level (gnus-summary-thread-level article))
4258 (refs (mail-header-references (gnus-summary-article-header article)))
4264 ((null (gnus-parent-id refs)) t)
4266 (null (setq particle (gnus-id-to-article
4267 (gnus-parent-id refs))))
4268 (null (gnus-summary-thread-level particle)))))))
4270 (defun gnus-root-id (id)
4271 "Return the id of the root of the thread where ID appears."
4273 (while (and id (setq prev (car (gnus-id-to-thread id))))
4275 id (gnus-parent-id (mail-header-references prev))))
4278 (defun gnus-articles-in-thread (thread)
4279 "Return the list of articles in THREAD."
4280 (cons (mail-header-number (car thread))
4281 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4283 (defun gnus-remove-thread (id &optional dont-remove)
4284 "Remove the thread that has ID in it."
4285 (let (headers thread last-id)
4286 ;; First go up in this thread until we find the root.
4287 (setq last-id (gnus-root-id id)
4288 headers (message-flatten-list (gnus-id-to-thread last-id)))
4289 ;; We have now found the real root of this thread. It might have
4290 ;; been gathered into some loose thread, so we have to search
4291 ;; through the threads to find the thread we wanted.
4292 (let ((threads gnus-newsgroup-threads)
4295 (setq sub (car threads))
4296 (if (stringp (car sub))
4297 ;; This is a gathered thread, so we look at the roots
4298 ;; below it to find whether this article is in this
4301 (setq sub (cdr sub))
4303 (when (member (caar sub) headers)
4304 (setq thread (car threads)
4307 (setq sub (cdr sub))))
4308 ;; It's an ordinary thread, so we check it.
4309 (when (eq (car sub) (car headers))
4312 (setq threads (cdr threads)))
4313 ;; If this article is in no thread, then it's a root.
4316 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4317 (setq thread (gnus-id-to-thread last-id)))
4320 thread ; We return this thread.
4322 (if (stringp (car thread))
4324 ;; If we use dummy roots, then we have to remove the
4325 ;; dummy root as well.
4326 (when (eq gnus-summary-make-false-root 'dummy)
4327 ;; We go to the dummy root by going to
4328 ;; the first sub-"thread", and then one line up.
4329 (gnus-summary-goto-article
4330 (mail-header-number (caadr thread)))
4333 (gnus-data-compute-positions))
4334 (setq thread (cdr thread))
4336 (gnus-remove-thread-1 (car thread))
4337 (setq thread (cdr thread))))
4338 (gnus-remove-thread-1 thread))))))))
4340 (defun gnus-remove-thread-1 (thread)
4341 "Remove the thread THREAD recursively."
4342 (let ((number (mail-header-number (pop thread)))
4344 (setq thread (reverse thread))
4346 (gnus-remove-thread-1 (pop thread)))
4347 (when (setq d (gnus-data-find number))
4348 (goto-char (gnus-data-pos d))
4349 (gnus-summary-show-thread)
4352 (- (gnus-point-at-bol)
4354 (1+ (gnus-point-at-eol))
4355 (gnus-delete-line)))))))
4357 (defun gnus-sort-threads-1 (threads func)
4358 (sort (mapcar (lambda (thread)
4361 (gnus-sort-threads-1 (cdr thread) func))))
4364 (defun gnus-sort-threads (threads)
4366 (if (not gnus-thread-sort-functions)
4368 (gnus-message 8 "Sorting threads...")
4369 (let ((max-lisp-eval-depth 5000))
4370 (prog1 (gnus-sort-threads-1
4372 (gnus-make-sort-function gnus-thread-sort-functions))
4373 (gnus-message 8 "Sorting threads...done")))))
4375 (defun gnus-sort-articles (articles)
4377 (when gnus-article-sort-functions
4378 (gnus-message 7 "Sorting articles...")
4380 (setq gnus-newsgroup-headers
4381 (sort articles (gnus-make-sort-function
4382 gnus-article-sort-functions)))
4383 (gnus-message 7 "Sorting articles...done"))))
4385 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4386 (defmacro gnus-thread-header (thread)
4387 "Return header of first article in THREAD.
4388 Note that THREAD must never, ever be anything else than a variable -
4389 using some other form will lead to serious barfage."
4390 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4391 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4392 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4395 (defsubst gnus-article-sort-by-number (h1 h2)
4396 "Sort articles by article number."
4397 (< (mail-header-number h1)
4398 (mail-header-number h2)))
4400 (defun gnus-thread-sort-by-number (h1 h2)
4401 "Sort threads by root article number."
4402 (gnus-article-sort-by-number
4403 (gnus-thread-header h1) (gnus-thread-header h2)))
4405 (defsubst gnus-article-sort-by-random (h1 h2)
4406 "Sort articles by article number."
4409 (defun gnus-thread-sort-by-random (h1 h2)
4410 "Sort threads by root article number."
4411 (gnus-article-sort-by-random
4412 (gnus-thread-header h1) (gnus-thread-header h2)))
4414 (defsubst gnus-article-sort-by-lines (h1 h2)
4415 "Sort articles by article Lines header."
4416 (< (mail-header-lines h1)
4417 (mail-header-lines h2)))
4419 (defun gnus-thread-sort-by-lines (h1 h2)
4420 "Sort threads by root article Lines header."
4421 (gnus-article-sort-by-lines
4422 (gnus-thread-header h1) (gnus-thread-header h2)))
4424 (defsubst gnus-article-sort-by-chars (h1 h2)
4425 "Sort articles by octet length."
4426 (< (mail-header-chars h1)
4427 (mail-header-chars h2)))
4429 (defun gnus-thread-sort-by-chars (h1 h2)
4430 "Sort threads by root article octet length."
4431 (gnus-article-sort-by-chars
4432 (gnus-thread-header h1) (gnus-thread-header h2)))
4434 (defsubst gnus-article-sort-by-author (h1 h2)
4435 "Sort articles by root author."
4437 (let ((extract (funcall
4438 gnus-extract-address-components
4439 (mail-header-from h1))))
4440 (or (car extract) (cadr extract) ""))
4441 (let ((extract (funcall
4442 gnus-extract-address-components
4443 (mail-header-from h2))))
4444 (or (car extract) (cadr extract) ""))))
4446 (defun gnus-thread-sort-by-author (h1 h2)
4447 "Sort threads by root author."
4448 (gnus-article-sort-by-author
4449 (gnus-thread-header h1) (gnus-thread-header h2)))
4451 (defsubst gnus-article-sort-by-subject (h1 h2)
4452 "Sort articles by root subject."
4454 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4455 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4457 (defun gnus-thread-sort-by-subject (h1 h2)
4458 "Sort threads by root subject."
4459 (gnus-article-sort-by-subject
4460 (gnus-thread-header h1) (gnus-thread-header h2)))
4462 (defsubst gnus-article-sort-by-date (h1 h2)
4463 "Sort articles by root article date."
4465 (gnus-date-get-time (mail-header-date h1))
4466 (gnus-date-get-time (mail-header-date h2))))
4468 (defun gnus-thread-sort-by-date (h1 h2)
4469 "Sort threads by root article date."
4470 (gnus-article-sort-by-date
4471 (gnus-thread-header h1) (gnus-thread-header h2)))
4473 (defsubst gnus-article-sort-by-score (h1 h2)
4474 "Sort articles by root article score.
4475 Unscored articles will be counted as having a score of zero."
4476 (> (or (cdr (assq (mail-header-number h1)
4477 gnus-newsgroup-scored))
4478 gnus-summary-default-score 0)
4479 (or (cdr (assq (mail-header-number h2)
4480 gnus-newsgroup-scored))
4481 gnus-summary-default-score 0)))
4483 (defun gnus-thread-sort-by-score (h1 h2)
4484 "Sort threads by root article score."
4485 (gnus-article-sort-by-score
4486 (gnus-thread-header h1) (gnus-thread-header h2)))
4488 (defun gnus-thread-sort-by-total-score (h1 h2)
4489 "Sort threads by the sum of all scores in the thread.
4490 Unscored articles will be counted as having a score of zero."
4491 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4493 (defun gnus-thread-total-score (thread)
4494 ;; This function find the total score of THREAD.
4499 (if (stringp (car thread))
4500 (apply gnus-thread-score-function 0
4501 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4502 (gnus-thread-total-score-1 thread)))
4504 (gnus-thread-total-score-1 (list thread)))))
4506 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4507 "Sort threads such that the thread with the most recently arrived article comes first."
4508 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4510 (defun gnus-thread-highest-number (thread)
4511 "Return the highest article number in THREAD."
4512 (apply 'max (mapcar (lambda (header)
4513 (mail-header-number header))
4514 (message-flatten-list thread))))
4516 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4517 "Sort threads such that the thread with the most recently dated article comes first."
4518 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4520 (defun gnus-thread-latest-date (thread)
4521 "Return the highest article date in THREAD."
4522 (let ((previous-time 0))
4529 (mail-header-parse-date (mail-header-date header))
4530 (error previous-time)))))
4532 (message-flatten-list thread)
4534 (< (mail-header-number h1)
4535 (mail-header-number h2))))))))
4537 (defun gnus-thread-total-score-1 (root)
4538 ;; This function find the total score of the thread below ROOT.
4539 (setq root (car root))
4540 (apply gnus-thread-score-function
4542 (mapcar 'gnus-thread-total-score
4543 (cdr (gnus-id-to-thread (mail-header-id root))))
4544 (when (> (mail-header-number root) 0)
4545 (list (or (cdr (assq (mail-header-number root)
4546 gnus-newsgroup-scored))
4547 gnus-summary-default-score 0))))
4548 (list gnus-summary-default-score)
4551 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4552 (defvar gnus-tmp-prev-subject nil)
4553 (defvar gnus-tmp-false-parent nil)
4554 (defvar gnus-tmp-root-expunged nil)
4555 (defvar gnus-tmp-dummy-line nil)
4557 (eval-when-compile (defvar gnus-tmp-header))
4558 (defun gnus-extra-header (type &optional header)
4559 "Return the extra header of TYPE."
4560 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4563 (defvar gnus-tmp-thread-tree-header-string "")
4565 (defcustom gnus-sum-thread-tree-root "> "
4566 "With %B spec, used for the root of a thread.
4567 If nil, use subject instead."
4569 :group 'gnus-thread)
4570 (defcustom gnus-sum-thread-tree-single-indent ""
4571 "With %B spec, used for a thread with just one message.
4572 If nil, use subject instead."
4574 :group 'gnus-thread)
4575 (defcustom gnus-sum-thread-tree-vertical "| "
4576 "With %B spec, used for drawing a vertical line."
4578 :group 'gnus-thread)
4579 (defcustom gnus-sum-thread-tree-indent " "
4580 "With %B spec, used for indenting."
4582 :group 'gnus-thread)
4583 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4584 "With %B spec, used for a leaf with brothers."
4586 :group 'gnus-thread)
4587 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4588 "With %B spec, used for a leaf without brothers."
4590 :group 'gnus-thread)
4592 (defun gnus-summary-prepare-threads (threads)
4593 "Prepare summary buffer from THREADS and indentation LEVEL.
4594 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4595 or a straight list of headers."
4596 (gnus-message 7 "Generating summary...")
4598 (setq gnus-newsgroup-threads threads)
4601 (let ((gnus-tmp-level 0)
4602 (default-score (or gnus-summary-default-score 0))
4603 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4604 (building-line-count gnus-summary-display-while-building)
4605 (building-count (integerp gnus-summary-display-while-building))
4606 thread number subject stack state gnus-tmp-gathered beg-match
4607 new-roots gnus-tmp-new-adopts thread-end simp-subject
4608 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4609 gnus-tmp-replied gnus-tmp-subject-or-nil
4610 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4611 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4612 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4615 (setq gnus-tmp-prev-subject nil
4616 gnus-tmp-thread-tree-header-string "")
4618 (if (vectorp (car threads))
4619 ;; If this is a straight (sic) list of headers, then a
4620 ;; threaded summary display isn't required, so we just create
4621 ;; an unthreaded one.
4622 (gnus-summary-prepare-unthreaded threads)
4624 ;; Do the threaded display.
4626 (if gnus-summary-display-while-building
4627 (switch-to-buffer (buffer-name)))
4628 (while (or threads stack gnus-tmp-new-adopts new-roots)
4630 (if (and (= gnus-tmp-level 0)
4633 (not gnus-tmp-false-parent)
4634 (or gnus-tmp-new-adopts new-roots))
4635 (if gnus-tmp-new-adopts
4636 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4637 thread (list (car gnus-tmp-new-adopts))
4638 gnus-tmp-header (caar thread)
4639 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4641 (setq thread (list (car new-roots))
4642 gnus-tmp-header (caar thread)
4643 new-roots (cdr new-roots))))
4646 ;; If there are some threads, we do them before the
4647 ;; threads on the stack.
4648 (setq thread threads
4649 gnus-tmp-header (caar thread))
4650 ;; There were no current threads, so we pop something off
4652 (setq state (car stack)
4653 gnus-tmp-level (car state)
4654 tree-stack (cadr state)
4655 thread (caddr state)
4657 gnus-tmp-header (caar thread))))
4659 (setq gnus-tmp-false-parent nil)
4660 (setq gnus-tmp-root-expunged nil)
4661 (setq thread-end nil)
4663 (if (stringp gnus-tmp-header)
4664 ;; The header is a dummy root.
4666 ((eq gnus-summary-make-false-root 'adopt)
4667 ;; We let the first article adopt the rest.
4668 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4670 (setq gnus-tmp-gathered
4672 (lambda (h) (mail-header-number (car h)))
4675 (setq thread (cons (list (caar thread)
4678 (setq gnus-tmp-level -1
4679 gnus-tmp-false-parent t))
4680 ((eq gnus-summary-make-false-root 'empty)
4681 ;; We print adopted articles with empty subject fields.
4682 (setq gnus-tmp-gathered
4684 (lambda (h) (mail-header-number (car h)))
4687 (setq gnus-tmp-level -1))
4688 ((eq gnus-summary-make-false-root 'dummy)
4689 ;; We remember that we probably want to output a dummy
4691 (setq gnus-tmp-dummy-line gnus-tmp-header)
4692 (setq gnus-tmp-prev-subject gnus-tmp-header))
4694 ;; We do not make a root for the gathered
4695 ;; sub-threads at all.
4696 (setq gnus-tmp-level -1)))
4698 (setq number (mail-header-number gnus-tmp-header)
4699 subject (mail-header-subject gnus-tmp-header)
4700 simp-subject (gnus-simplify-subject-fully subject))
4703 ;; If the thread has changed subject, we might want to make
4704 ;; this subthread into a root.
4705 ((and (null gnus-thread-ignore-subject)
4706 (not (zerop gnus-tmp-level))
4707 gnus-tmp-prev-subject
4708 (not (string= gnus-tmp-prev-subject simp-subject)))
4709 (setq new-roots (nconc new-roots (list (car thread)))
4711 gnus-tmp-header nil))
4712 ;; If the article lies outside the current limit,
4713 ;; then we do not display it.
4714 ((not (memq number gnus-newsgroup-limit))
4715 (setq gnus-tmp-gathered
4717 (lambda (h) (mail-header-number (car h)))
4720 (setq gnus-tmp-new-adopts (if (cdar thread)
4721 (append gnus-tmp-new-adopts
4723 gnus-tmp-new-adopts)
4725 gnus-tmp-header nil)
4726 (when (zerop gnus-tmp-level)
4727 (setq gnus-tmp-root-expunged t)))
4728 ;; Perhaps this article is to be marked as read?
4729 ((and gnus-summary-mark-below
4730 (< (or (cdr (assq number gnus-newsgroup-scored))
4732 gnus-summary-mark-below)
4733 ;; Don't touch sparse articles.
4734 (not (gnus-summary-article-sparse-p number))
4735 (not (gnus-summary-article-ancient-p number)))
4736 (setq gnus-newsgroup-unreads
4737 (delq number gnus-newsgroup-unreads))
4738 (if gnus-newsgroup-auto-expire
4739 (setq gnus-newsgroup-expirable
4740 (gnus-add-to-sorted-list
4741 gnus-newsgroup-expirable number))
4742 (push (cons number gnus-low-score-mark)
4743 gnus-newsgroup-reads))))
4745 (when gnus-tmp-header
4746 ;; We may have an old dummy line to output before this
4748 (when (and gnus-tmp-dummy-line
4751 (mail-header-subject gnus-tmp-header)))
4752 (gnus-summary-insert-dummy-line
4753 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4754 (setq gnus-tmp-dummy-line nil))
4756 ;; Compute the mark.
4757 (setq gnus-tmp-unread (gnus-article-mark number))
4759 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4760 gnus-tmp-header gnus-tmp-level)
4761 gnus-newsgroup-data)
4763 ;; Actually insert the line.
4765 gnus-tmp-subject-or-nil
4767 ((and gnus-thread-ignore-subject
4768 gnus-tmp-prev-subject
4769 (not (string= gnus-tmp-prev-subject simp-subject)))
4771 ((zerop gnus-tmp-level)
4772 (if (and (eq gnus-summary-make-false-root 'empty)
4773 (memq number gnus-tmp-gathered)
4774 gnus-tmp-prev-subject
4775 (string= gnus-tmp-prev-subject simp-subject))
4776 gnus-summary-same-subject
4778 (t gnus-summary-same-subject)))
4779 (if (and (eq gnus-summary-make-false-root 'adopt)
4780 (= gnus-tmp-level 1)
4781 (memq number gnus-tmp-gathered))
4782 (setq gnus-tmp-opening-bracket ?\<
4783 gnus-tmp-closing-bracket ?\>)
4784 (setq gnus-tmp-opening-bracket ?\[
4785 gnus-tmp-closing-bracket ?\]))
4787 gnus-tmp-indentation
4788 (aref gnus-thread-indent-array gnus-tmp-level)
4789 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4790 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4791 gnus-summary-default-score 0)
4793 (if (or (null gnus-summary-default-score)
4794 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4795 gnus-summary-zcore-fuzz))
4797 (if (< gnus-tmp-score gnus-summary-default-score)
4798 gnus-score-below-mark gnus-score-over-mark))
4800 (cond ((memq number gnus-newsgroup-processable)
4802 ((memq number gnus-newsgroup-cached)
4804 ((memq number gnus-newsgroup-replied)
4806 ((memq number gnus-newsgroup-forwarded)
4807 gnus-forwarded-mark)
4808 ((memq number gnus-newsgroup-saved)
4810 ((memq number gnus-newsgroup-recent)
4812 ((memq number gnus-newsgroup-unseen)
4816 (cond ((memq number gnus-newsgroup-undownloaded)
4817 gnus-undownloaded-mark)
4818 (gnus-newsgroup-agentized
4819 gnus-downloaded-mark)
4822 gnus-tmp-from (mail-header-from gnus-tmp-header)
4825 ((string-match "<[^>]+> *$" gnus-tmp-from)
4826 (setq beg-match (match-beginning 0))
4827 (or (and (string-match "^\".+\"" gnus-tmp-from)
4828 (substring gnus-tmp-from 1 (1- (match-end 0))))
4829 (substring gnus-tmp-from 0 beg-match)))
4830 ((string-match "(.+)" gnus-tmp-from)
4831 (substring gnus-tmp-from
4832 (1+ (match-beginning 0)) (1- (match-end 0))))
4836 gnus-tmp-thread-tree-header-string
4838 ((not gnus-show-threads) "")
4839 ((zerop gnus-tmp-level)
4841 (or gnus-sum-thread-tree-root subject)
4842 (or gnus-sum-thread-tree-single-indent subject)))
4844 (concat (apply 'concat
4845 (mapcar (lambda (item)
4847 gnus-sum-thread-tree-vertical
4848 gnus-sum-thread-tree-indent))
4849 (cdr (reverse tree-stack))))
4851 gnus-sum-thread-tree-leaf-with-other
4852 gnus-sum-thread-tree-single-leaf)))))
4853 (when (string= gnus-tmp-name "")
4854 (setq gnus-tmp-name gnus-tmp-from))
4855 (unless (numberp gnus-tmp-lines)
4856 (setq gnus-tmp-lines -1))
4857 (if (= gnus-tmp-lines -1)
4858 (setq gnus-tmp-lines "?")
4859 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4860 (gnus-put-text-property
4862 (progn (eval gnus-summary-line-format-spec) (point))
4863 'gnus-number number)
4866 (gnus-run-hooks 'gnus-summary-update-hook)
4869 (setq gnus-tmp-prev-subject simp-subject)))
4871 (when (nth 1 thread)
4872 (push (list (max 0 gnus-tmp-level)
4873 (copy-list tree-stack)
4876 (push (if (nth 1 thread) 1 0) tree-stack)
4877 (incf gnus-tmp-level)
4878 (setq threads (if thread-end nil (cdar thread)))
4879 (if gnus-summary-display-while-building
4882 ;; use a set frequency
4883 (setq building-line-count (1- building-line-count))
4884 (when (= building-line-count 0)
4886 (setq building-line-count
4887 gnus-summary-display-while-building)))
4891 (setq gnus-tmp-level 0)))))
4892 (gnus-message 7 "Generating summary...done"))
4894 (defun gnus-summary-prepare-unthreaded (headers)
4895 "Generate an unthreaded summary buffer based on HEADERS."
4896 (let (header number mark)
4901 ;; We may have to root out some bad articles...
4902 (when (memq (setq number (mail-header-number
4903 (setq header (pop headers))))
4904 gnus-newsgroup-limit)
4905 ;; Mark article as read when it has a low score.
4906 (when (and gnus-summary-mark-below
4907 (< (or (cdr (assq number gnus-newsgroup-scored))
4908 gnus-summary-default-score 0)
4909 gnus-summary-mark-below)
4910 (not (gnus-summary-article-ancient-p number)))
4911 (setq gnus-newsgroup-unreads
4912 (delq number gnus-newsgroup-unreads))
4913 (if gnus-newsgroup-auto-expire
4914 (push number gnus-newsgroup-expirable)
4915 (push (cons number gnus-low-score-mark)
4916 gnus-newsgroup-reads)))
4918 (setq mark (gnus-article-mark number))
4919 (push (gnus-data-make number mark (1+ (point)) header 0)
4920 gnus-newsgroup-data)
4921 (gnus-summary-insert-line
4923 (memq number gnus-newsgroup-undownloaded)
4924 mark (memq number gnus-newsgroup-replied)
4925 (memq number gnus-newsgroup-expirable)
4926 (mail-header-subject header) nil
4927 (cdr (assq number gnus-newsgroup-scored))
4928 (memq number gnus-newsgroup-processable))))))
4930 (defun gnus-summary-remove-list-identifiers ()
4931 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4932 (let ((regexp (if (consp gnus-list-identifiers)
4933 (mapconcat 'identity gnus-list-identifiers " *\\|")
4934 gnus-list-identifiers))
4937 (dolist (header gnus-newsgroup-headers)
4938 (setq subject (mail-header-subject header)
4940 (while (string-match
4941 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4944 (concat (substring subject 0 (match-beginning 2))
4945 (substring subject (match-end 0)))
4949 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4951 (concat (substring subject 0 (match-beginning 1))
4952 (substring subject (match-end 1)))))
4954 (mail-header-set-subject header subject))))))
4956 (defun gnus-fetch-headers (articles)
4957 "Fetch headers of ARTICLES."
4958 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4959 (gnus-message 5 "Fetching headers for %s..." name)
4962 (setq gnus-headers-retrieved-by
4963 (gnus-retrieve-headers
4964 articles gnus-newsgroup-name
4965 ;; We might want to fetch old headers, but
4966 ;; not if there is only 1 article.
4968 (not (eq gnus-fetch-old-headers 'some))
4969 (not (numberp gnus-fetch-old-headers)))
4970 (> (length articles) 1))
4971 gnus-fetch-old-headers))))
4972 (gnus-get-newsgroup-headers-xover
4973 articles nil nil gnus-newsgroup-name t)
4974 (gnus-get-newsgroup-headers))
4975 (gnus-message 5 "Fetching headers for %s...done" name))))
4977 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4978 "Select newsgroup GROUP.
4979 If READ-ALL is non-nil, all articles in the group are selected.
4980 If SELECT-ARTICLES, only select those articles from GROUP."
4981 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4982 ;;!!! Dirty hack; should be removed.
4983 (gnus-summary-ignore-duplicates
4984 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4986 gnus-summary-ignore-duplicates))
4987 (info (nth 2 entry))
4988 articles fetched-articles cached)
4990 (unless (gnus-check-server
4991 (set (make-local-variable 'gnus-current-select-method)
4992 (gnus-find-method-for-group group)))
4993 (error "Couldn't open server"))
4995 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4996 (gnus-activate-group group) ; Or we can activate it...
4997 (progn ; Or we bug out.
4998 (when (equal major-mode 'gnus-summary-mode)
4999 (gnus-kill-buffer (current-buffer)))
5000 (error "Couldn't activate group %s: %s"
5001 group (gnus-status-message group))))
5003 (unless (gnus-request-group group t)
5004 (when (equal major-mode 'gnus-summary-mode)
5005 (gnus-kill-buffer (current-buffer)))
5006 (error "Couldn't request group %s: %s"
5007 group (gnus-status-message group)))
5010 ;; The agent may be storing articles that are no longer in the
5011 ;; server's active range. If that is the case, the active range
5012 ;; needs to be expanded such that the agent's articles can be
5013 ;; included in the summary.
5014 (let* ((gnus-command-method (gnus-find-method-for-group group))
5015 (alist (gnus-agent-load-alist group))
5016 (active (gnus-active group)))
5017 (if (and (car alist)
5018 (< (caar alist) (car active)))
5019 (gnus-set-active group (cons (caar alist) (cdr active))))))
5021 (setq gnus-newsgroup-name group
5022 gnus-newsgroup-unselected nil
5023 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5025 (let ((display (gnus-group-find-parameter group 'display)))
5026 (setq gnus-newsgroup-display
5028 ((not (zerop (or (car-safe read-all) 0)))
5029 ;; The user entered the group with C-u SPC/RET, let's show
5035 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5037 ;; The following is probably the "correct" solution, but
5038 ;; it makes Gnus fetch all headers and then limit the
5039 ;; articles (which is slow), so instead we hack the
5040 ;; select-articles parameter instead. -- Simon Josefsson
5043 ;; (gnus-byte-compile
5044 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5046 (setq select-articles
5047 (gnus-uncompress-range
5048 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5052 (cdr (gnus-active group)))))
5057 (gnus-summary-setup-default-charset)
5059 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5060 (when (gnus-virtual-group-p group)
5061 (setq cached gnus-newsgroup-cached))
5063 (setq gnus-newsgroup-unreads
5064 (gnus-sorted-ndifference
5065 (gnus-sorted-ndifference gnus-newsgroup-unreads
5066 gnus-newsgroup-marked)
5067 gnus-newsgroup-dormant))
5069 (setq gnus-newsgroup-processable nil)
5071 (gnus-update-read-articles group gnus-newsgroup-unreads)
5073 ;; Adjust and set lists of article marks.
5075 (gnus-adjust-marked-articles info))
5076 (if (setq articles select-articles)
5077 (setq gnus-newsgroup-unselected
5078 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5079 (setq articles (gnus-articles-to-read group read-all)))
5083 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5085 ((eq articles 0) nil)
5087 ;; Init the dependencies hash table.
5088 (setq gnus-newsgroup-dependencies
5089 (gnus-make-hashtable (length articles)))
5090 (gnus-set-global-variables)
5091 ;; Retrieve the headers and read them in.
5093 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5095 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5097 (setq gnus-newsgroup-cached cached))
5099 ;; Suppress duplicates?
5100 (when gnus-suppress-duplicates
5101 (gnus-dup-suppress-articles))
5103 ;; Set the initial limit.
5104 (setq gnus-newsgroup-limit (copy-sequence articles))
5105 ;; Remove canceled articles from the list of unread articles.
5106 (setq fetched-articles
5107 (mapcar (lambda (headers) (mail-header-number headers))
5108 gnus-newsgroup-headers))
5109 (setq gnus-newsgroup-articles fetched-articles)
5110 (setq gnus-newsgroup-unreads
5111 (gnus-sorted-nintersection
5112 gnus-newsgroup-unreads fetched-articles))
5113 (gnus-compute-unseen-list)
5115 ;; Removed marked articles that do not exist.
5116 (gnus-update-missing-marks
5117 (gnus-sorted-difference articles fetched-articles))
5118 ;; We might want to build some more threads first.
5119 (when (and gnus-fetch-old-headers
5120 (eq gnus-headers-retrieved-by 'nov))
5121 (if (eq gnus-fetch-old-headers 'invisible)
5122 (gnus-build-all-threads)
5123 (gnus-build-old-threads)))
5124 ;; Let the Gnus agent mark articles as read.
5126 (gnus-agent-get-undownloaded-list))
5127 ;; Remove list identifiers from subject
5128 (when gnus-list-identifiers
5129 (gnus-summary-remove-list-identifiers))
5130 ;; Check whether auto-expire is to be done in this group.
5131 (setq gnus-newsgroup-auto-expire
5132 (gnus-group-auto-expirable-p group))
5133 ;; Set up the article buffer now, if necessary.
5134 (unless gnus-single-article-buffer
5135 (gnus-article-setup-buffer))
5136 ;; First and last article in this newsgroup.
5137 (when gnus-newsgroup-headers
5138 (setq gnus-newsgroup-begin
5139 (mail-header-number (car gnus-newsgroup-headers))
5142 (gnus-last-element gnus-newsgroup-headers))))
5143 ;; GROUP is successfully selected.
5144 (or gnus-newsgroup-headers t)))))
5146 (defun gnus-compute-unseen-list ()
5147 ;; The `seen' marks are treated specially.
5148 (if (not gnus-newsgroup-seen)
5149 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5150 (setq gnus-newsgroup-unseen
5151 (gnus-inverse-list-range-intersection
5152 gnus-newsgroup-articles gnus-newsgroup-seen))))
5154 (defun gnus-summary-display-make-predicate (display)
5155 (require 'gnus-agent)
5156 (when (= (length display) 1)
5157 (setq display (car display)))
5158 (unless gnus-summary-display-cache
5159 (dolist (elem (append '((unread . unread)
5162 gnus-article-mark-lists))
5163 (push (cons (cdr elem)
5165 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5166 gnus-summary-display-cache)))
5167 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5168 (gnus-category-predicate-cache gnus-summary-display-cache))
5169 (gnus-get-predicate display)))
5171 ;; Uses the dynamically bound `number' variable.
5174 (defun gnus-article-marked-p (type &optional article)
5175 (let ((article (or article number)))
5178 (memq article gnus-newsgroup-marked))
5180 (memq article gnus-newsgroup-spam-marked))
5182 (memq article gnus-newsgroup-unsendable))
5183 ((eq type 'undownload)
5184 (memq article gnus-newsgroup-undownloaded))
5185 ((eq type 'download)
5186 (memq article gnus-newsgroup-downloadable))
5188 (memq article gnus-newsgroup-unreads))
5190 (memq article gnus-newsgroup-reads))
5192 (memq article gnus-newsgroup-dormant) )
5194 (memq article gnus-newsgroup-expirable))
5196 (memq article gnus-newsgroup-replied))
5198 (memq article gnus-newsgroup-killed))
5199 ((eq type 'bookmark)
5200 (assq article gnus-newsgroup-bookmarks))
5202 (assq article gnus-newsgroup-scored))
5204 (memq article gnus-newsgroup-saved))
5206 (memq article gnus-newsgroup-cached))
5208 (memq article gnus-newsgroup-forwarded))
5210 (not (memq article gnus-newsgroup-unseen)))
5212 (memq article gnus-newsgroup-recent))
5215 (defun gnus-articles-to-read (group &optional read-all)
5216 "Find out what articles the user wants to read."
5217 (let* ((display (gnus-group-find-parameter group 'display))
5219 ;; Select all articles if `read-all' is non-nil, or if there
5220 ;; are no unread articles.
5222 (and (zerop (length gnus-newsgroup-marked))
5223 (zerop (length gnus-newsgroup-unreads)))
5224 ;; Fetch all if the predicate is non-nil.
5225 gnus-newsgroup-display)
5226 ;; We want to select the headers for all the articles in
5227 ;; the group, so we select either all the active
5228 ;; articles in the group, or (if that's nil), the
5229 ;; articles in the cache.
5231 (gnus-uncompress-range (gnus-active group))
5232 (gnus-cache-articles-in-group group))
5233 ;; Select only the "normal" subset of articles.
5235 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5236 gnus-newsgroup-unreads)))
5237 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5238 (scored (length scored-list))
5239 (number (length articles))
5240 (marked (+ (length gnus-newsgroup-marked)
5241 (length gnus-newsgroup-dormant)))
5246 ((numberp gnus-newsgroup-display)
5247 gnus-newsgroup-display)
5251 ((and (or (<= scored marked) (= scored number))
5252 (numberp gnus-large-newsgroup)
5253 (> number gnus-large-newsgroup))
5254 (let* ((cursor-in-echo-area nil)
5255 (initial (gnus-parameter-large-newsgroup-initial
5256 gnus-newsgroup-name))
5260 "How many articles from %s (%s %d): "
5262 (gnus-group-decoded-name gnus-newsgroup-name)
5264 (if initial "max" "default")
5267 (cons (number-to-string initial)
5269 (if (string-match "^[ \t]*$" input) number input)))
5270 ((and (> scored marked) (< scored number)
5271 (> (- scored number) 20))
5274 (format "%s %s (%d scored, %d total): "
5275 "How many articles from"
5276 (gnus-group-decoded-name group)
5278 (if (string-match "^[ \t]*$" input)
5282 (message "Quit getting the articles to read")
5284 (setq select (if (stringp select) (string-to-number select) select))
5285 (if (or (null select) (zerop select))
5287 (if (and (not (zerop scored)) (<= (abs select) scored))
5289 (setq articles (sort scored-list '<))
5290 (setq number (length articles)))
5291 (setq articles (copy-sequence articles)))
5293 (when (< (abs select) number)
5295 ;; Select the N oldest articles.
5296 (setcdr (nthcdr (1- (abs select)) articles) nil)
5297 ;; Select the N most recent articles.
5298 (setq articles (nthcdr (- number select) articles))))
5299 (setq gnus-newsgroup-unselected
5300 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5301 (when gnus-alter-articles-to-read-function
5304 (funcall gnus-alter-articles-to-read-function
5305 gnus-newsgroup-name articles)
5309 (defun gnus-killed-articles (killed articles)
5312 (when (inline (gnus-member-of-range (car articles) killed))
5313 (push (car articles) out))
5314 (setq articles (cdr articles)))
5317 (defun gnus-uncompress-marks (marks)
5318 "Uncompress the mark ranges in MARKS."
5319 (let ((uncompressed '(score bookmark))
5322 (if (memq (caar marks) uncompressed)
5323 (push (car marks) out)
5324 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5325 (setq marks (cdr marks)))
5328 (defun gnus-article-mark-to-type (mark)
5329 "Return the type of MARK."
5330 (or (cadr (assq mark gnus-article-special-mark-lists))
5333 (defun gnus-article-unpropagatable-p (mark)
5334 "Return whether MARK should be propagated to backend."
5335 (memq mark gnus-article-unpropagated-mark-lists))
5337 (defun gnus-adjust-marked-articles (info)
5338 "Set all article lists and remove all marks that are no longer valid."
5339 (let* ((marked-lists (gnus-info-marks info))
5340 (active (gnus-active (gnus-info-group info)))
5343 (types gnus-article-mark-lists)
5344 marks var articles article mark mark-type)
5346 (dolist (marks marked-lists)
5347 (setq mark (car marks)
5348 mark-type (gnus-article-mark-to-type mark)
5349 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5351 ;; We set the variable according to the type of the marks list,
5352 ;; and then adjust the marks to a subset of the active articles.
5354 ;; Adjust "simple" lists.
5355 ((eq mark-type 'list)
5356 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5357 (when (memq mark '(tick dormant expire reply save))
5359 (when (or (< (setq article (pop articles)) min) (> article max))
5360 (set var (delq article (symbol-value var)))))))
5362 ((eq mark-type 'tuple)
5363 (set var (setq articles (cdr marks)))
5364 (when (not (listp (cdr (symbol-value var))))
5365 (set var (list (symbol-value var))))
5366 (when (not (listp (cdr articles)))
5367 (setq articles (list articles)))
5369 (when (or (not (consp (setq article (pop articles))))
5370 (< (car article) min)
5371 (> (car article) max))
5372 (set var (delq article (symbol-value var))))))
5373 ;; Adjust ranges (sloppily).
5374 ((eq mark-type 'range)
5377 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5378 ;; It should be (seen (NUM1 . NUM2)).
5379 (when (numberp (cddr marks))
5380 (setcdr marks (list (cdr marks))))
5381 (setq articles (cdr marks))
5382 (while (and articles
5383 (or (and (consp (car articles))
5384 (> min (cdar articles)))
5385 (and (numberp (car articles))
5386 (> min (car articles)))))
5388 (set var articles))))))))
5390 (defun gnus-update-missing-marks (missing)
5391 "Go through the list of MISSING articles and remove them from the mark lists."
5394 ;; Go through all types.
5395 (dolist (elem gnus-article-mark-lists)
5396 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5397 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5398 (when (symbol-value var)
5399 ;; This list has articles. So we delete all missing
5400 ;; articles from it.
5403 (set var (delq (pop m) (symbol-value var))))))))))
5405 (defun gnus-update-marks ()
5406 "Enter the various lists of marked articles into the newsgroup info list."
5407 (let ((types gnus-article-mark-lists)
5408 (info (gnus-get-info gnus-newsgroup-name))
5409 type list newmarked symbol delta-marks)
5411 ;; Add all marks lists to the list of marks lists.
5412 (while (setq type (pop types))
5413 (setq list (symbol-value
5415 (intern (format "gnus-newsgroup-%s" (car type))))))
5418 ;; Get rid of the entries of the articles that have the
5420 (when (and (eq (cdr type) 'score)
5424 (prev (cons nil list))
5427 (if (or (not (consp (car arts)))
5428 (= (cdar arts) gnus-summary-default-score))
5429 (setcdr prev (cdr arts))
5431 (setq arts (cdr arts)))
5432 (setq list (cdr all)))))
5434 (when (eq (cdr type) 'seen)
5435 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5437 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5438 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5440 (when (and (gnus-check-backend-function
5441 'request-set-mark gnus-newsgroup-name)
5442 (not (gnus-article-unpropagatable-p (cdr type))))
5443 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5444 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5445 (add (gnus-remove-from-range
5446 (gnus-copy-sequence list) old)))
5448 (push (list add 'add (list (cdr type))) delta-marks))
5450 (push (list del 'del (list (cdr type))) delta-marks))))
5453 (push (cons (cdr type) list) newmarked)))
5456 (unless (gnus-check-group gnus-newsgroup-name)
5457 (error "Can't open server for %s" gnus-newsgroup-name))
5458 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5460 ;; Enter these new marks into the info of the group.
5462 (setcar (nthcdr 3 info) newmarked)
5463 ;; Add the marks lists to the end of the info.
5465 (setcdr (nthcdr 2 info) (list newmarked))))
5467 ;; Cut off the end of the info if there's nothing else there.
5471 (when (nthcdr (decf i) info)
5472 (setcdr (nthcdr i info) nil)))))))
5474 (defun gnus-set-mode-line (where)
5475 "Set the mode line of the article or summary buffers.
5476 If WHERE is `summary', the summary mode line format will be used."
5477 ;; Is this mode line one we keep updated?
5478 (when (and (memq where gnus-updated-mode-lines)
5480 (intern (format "gnus-%s-mode-line-format-spec" where))))
5483 ;; We evaluate this in the summary buffer since these
5484 ;; variables are buffer-local to that buffer.
5485 (set-buffer gnus-summary-buffer)
5486 ;; We bind all these variables that are used in the `eval' form
5488 (let* ((mformat (symbol-value
5490 (format "gnus-%s-mode-line-format-spec" where))))
5491 (gnus-tmp-group-name (gnus-group-decoded-name
5492 gnus-newsgroup-name))
5493 (gnus-tmp-article-number (or gnus-current-article 0))
5494 (gnus-tmp-unread gnus-newsgroup-unreads)
5495 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5496 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5497 (gnus-tmp-unread-and-unselected
5498 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5499 (zerop gnus-tmp-unselected))
5501 ((zerop gnus-tmp-unselected)
5502 (format "{%d more}" gnus-tmp-unread-and-unticked))
5503 (t (format "{%d(+%d) more}"
5504 gnus-tmp-unread-and-unticked
5505 gnus-tmp-unselected))))
5507 (if (and gnus-current-headers
5508 (vectorp gnus-current-headers))
5509 (gnus-mode-string-quote
5510 (mail-header-subject gnus-current-headers))
5512 bufname-length max-len
5513 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5514 (setq mode-string (eval mformat))
5515 (setq bufname-length (if (string-match "%b" mode-string)
5518 (if (eq where 'summary)
5520 (get-buffer gnus-article-buffer))))
5523 (setq max-len (max 4 (if gnus-mode-non-string-length
5525 gnus-mode-non-string-length
5527 (length mode-string))))
5528 ;; We might have to chop a bit of the string off...
5529 (when (> (length mode-string) max-len)
5531 (concat (truncate-string-to-width mode-string (- max-len 3))
5533 ;; Pad the mode string a bit.
5534 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5535 ;; Update the mode line.
5536 (setq mode-line-buffer-identification
5537 (gnus-mode-line-buffer-identification (list mode-string)))
5538 (set-buffer-modified-p t))))
5540 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5541 "Go through the HEADERS list and add all Xrefs to a hash table.
5542 The resulting hash table is returned, or nil if no Xrefs were found."
5543 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5544 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5545 (xref-hashtb (gnus-make-hashtable))
5546 start group entry number xrefs header)
5548 (setq header (pop headers))
5549 (when (and (setq xrefs (mail-header-xref header))
5550 (not (memq (setq number (mail-header-number header))
5553 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5554 (setq start (match-end 0))
5555 (setq group (if prefix
5556 (concat prefix (substring xrefs (match-beginning 1)
5558 (substring xrefs (match-beginning 1) (match-end 1))))
5560 (string-to-int (substring xrefs (match-beginning 2)
5562 (if (setq entry (gnus-gethash group xref-hashtb))
5563 (setcdr entry (cons number (cdr entry)))
5564 (gnus-sethash group (cons number nil) xref-hashtb)))))
5565 (and start xref-hashtb)))
5567 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5568 "Look through all the headers and mark the Xrefs as read."
5569 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5570 name entry info xref-hashtb idlist method nth4)
5572 (set-buffer gnus-group-buffer)
5573 (when (setq xref-hashtb
5574 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5577 (unless (string= from-newsgroup (setq name (symbol-name group)))
5578 (setq idlist (symbol-value group))
5579 ;; Dead groups are not updated.
5581 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5583 (when (stringp (setq nth4 (gnus-info-method info)))
5584 (setq nth4 (gnus-server-to-method nth4))))
5585 ;; Only do the xrefs if the group has the same
5586 ;; select method as the group we have just read.
5587 (or (gnus-methods-equal-p
5588 nth4 (gnus-find-method-for-group from-newsgroup))
5590 (equal nth4 (setq method (gnus-find-method-for-group
5592 (and (equal (car nth4) (car method))
5593 (equal (nth 1 nth4) (nth 1 method))))
5594 gnus-use-cross-reference
5595 (or (not (eq gnus-use-cross-reference t))
5597 ;; Only do cross-references on subscribed
5598 ;; groups, if that is what is wanted.
5599 (<= (gnus-info-level info) gnus-level-subscribed))
5600 (gnus-group-make-articles-read name idlist))))
5603 (defun gnus-compute-read-articles (group articles)
5604 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5605 (info (nth 2 entry))
5606 (active (gnus-active group))
5609 ;; First peel off all invalid article numbers.
5611 (let ((ids articles)
5613 (while (setq id (pop ids))
5614 (when (and first (> id (cdr active)))
5615 ;; We'll end up in this situation in one particular
5616 ;; obscure situation. If you re-scan a group and get
5617 ;; a new article that is cross-posted to a different
5618 ;; group that has not been re-scanned, you might get
5619 ;; crossposted article that has a higher number than
5620 ;; Gnus believes possible. So we re-activate this
5621 ;; group as well. This might mean doing the
5622 ;; crossposting thingy will *increase* the number
5623 ;; of articles in some groups. Tsk, tsk.
5624 (setq active (or (gnus-activate-group group) active)))
5625 (when (or (> id (cdr active))
5626 (< id (car active)))
5627 (setq articles (delq id articles))))))
5628 ;; If the read list is nil, we init it.
5630 (null (gnus-info-read info))
5632 (setq ninfo (cons 1 (1- (car active))))
5633 (setq ninfo (gnus-info-read info)))
5634 ;; Then we add the read articles to the range.
5636 ninfo (setq articles (sort articles '<))))))
5638 (defun gnus-group-make-articles-read (group articles)
5639 "Update the info of GROUP to say that ARTICLES are read."
5641 (entry (gnus-gethash group gnus-newsrc-hashtb))
5642 (info (nth 2 entry))
5643 (active (gnus-active group))
5646 (setq range (gnus-compute-read-articles group articles))
5648 (set-buffer gnus-group-buffer)
5651 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5652 (gnus-info-set-read ',info ',(gnus-info-read info))
5653 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5654 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5655 (gnus-group-update-group ,group t))))
5656 ;; Add the read articles to the range.
5657 (gnus-info-set-read info range)
5658 (gnus-request-set-mark group (list (list range 'add '(read))))
5659 ;; Then we have to re-compute how many unread
5660 ;; articles there are in this group.
5664 (setq num (- (1+ (cdr active)) (car active))))
5665 ((not (listp (cdr range)))
5666 (setq num (- (cdr active) (- (1+ (cdr range))
5670 (if (numberp (car range))
5672 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5673 (setq range (cdr range)))
5674 (setq num (- (cdr active) num))))
5675 ;; Update the number of unread articles.
5677 ;; Update the group buffer.
5678 (unless (gnus-ephemeral-group-p group)
5679 (gnus-group-update-group group t))))))
5681 (defvar gnus-newsgroup-none-id 0)
5683 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5684 (let ((cur nntp-server-buffer)
5687 (save-excursion (set-buffer gnus-summary-buffer)
5688 gnus-newsgroup-dependencies)))
5690 (mail-parse-charset gnus-newsgroup-charset)
5691 (mail-parse-ignored-charsets
5692 (save-excursion (condition-case nil
5693 (set-buffer gnus-summary-buffer)
5695 gnus-newsgroup-ignored-charsets)))
5697 (set-buffer nntp-server-buffer)
5698 ;; Translate all TAB characters into SPACE characters.
5699 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5700 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5701 (gnus-run-hooks 'gnus-parse-headers-hook)
5702 (let ((case-fold-search t)
5703 in-reply-to header p lines chars)
5704 (goto-char (point-min))
5705 ;; Search to the beginning of the next header. Error messages
5706 ;; do not begin with 2 or 3.
5707 (while (re-search-forward "^[23][0-9]+ " nil t)
5710 ;; This implementation of this function, with nine
5711 ;; search-forwards instead of the one re-search-forward and
5712 ;; a case (which basically was the old function) is actually
5713 ;; about twice as fast, even though it looks messier. You
5714 ;; can't have everything, I guess. Speed and elegance
5715 ;; doesn't always go hand in hand.
5724 (narrow-to-region (point)
5725 (or (and (search-forward "\n.\n" nil t)
5731 (if (search-forward "\nsubject:" nil t)
5732 (funcall gnus-decode-encoded-word-function
5733 (nnheader-header-value))
5738 (if (search-forward "\nfrom:" nil t)
5739 (funcall gnus-decode-encoded-word-function
5740 (nnheader-header-value))
5745 (if (search-forward "\ndate:" nil t)
5746 (nnheader-header-value) ""))
5750 (setq id (if (re-search-forward
5751 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5752 ;; We do it this way to make sure the Message-ID
5753 ;; is (somewhat) syntactically valid.
5754 (buffer-substring (match-beginning 1)
5756 ;; If there was no message-id, we just fake one
5757 ;; to make subsequent routines simpler.
5758 (nnheader-generate-fake-message-id))))
5762 (if (search-forward "\nreferences:" nil t)
5766 (nnheader-header-value)
5771 (search-backward ">" end t)
5774 (search-backward "<" end t)
5776 ;; Get the references from the in-reply-to header if there
5777 ;; were no references and the in-reply-to header looks
5779 (if (and (search-forward "\nin-reply-to:" nil t)
5780 (setq in-reply-to (nnheader-header-value))
5781 (string-match "<[^>]+>" in-reply-to))
5783 (setq ref (substring in-reply-to (match-beginning 0)
5785 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5786 (setq ref2 (substring in-reply-to (match-beginning 0)
5788 (when (> (length ref2) (length ref))
5795 (if (search-forward "\nchars: " nil t)
5796 (if (numberp (setq chars (ignore-errors (read cur))))
5802 (if (search-forward "\nlines: " nil t)
5803 (if (numberp (setq lines (ignore-errors (read cur))))
5809 (and (search-forward "\nxref:" nil t)
5810 (nnheader-header-value)))
5812 (when gnus-extra-headers
5813 (let ((extra gnus-extra-headers)
5817 (when (search-forward
5818 (concat "\n" (symbol-name (car extra)) ":") nil t)
5819 (push (cons (car extra) (nnheader-header-value))
5823 (when (equal id ref)
5826 (when gnus-alter-header-function
5827 (funcall gnus-alter-header-function header)
5828 (setq id (mail-header-id header)
5829 ref (gnus-parent-id (mail-header-references header))))
5832 (gnus-dependencies-add-header
5833 header dependencies force-new))
5834 (push header headers))
5835 (goto-char (point-max))
5837 (nreverse headers)))))
5839 ;; Goes through the xover lines and returns a list of vectors
5840 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5841 force-new dependencies
5842 group also-fetch-heads)
5843 "Parse the news overview data in the server buffer.
5844 Return a list of headers that match SEQUENCE (see
5845 `nntp-retrieve-headers')."
5846 ;; Get the Xref when the users reads the articles since most/some
5847 ;; NNTP servers do not include Xrefs when using XOVER.
5848 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5849 (let ((mail-parse-charset gnus-newsgroup-charset)
5850 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5851 (cur nntp-server-buffer)
5852 (dependencies (or dependencies gnus-newsgroup-dependencies))
5854 ((eq gnus-read-all-available-headers t)
5856 ((stringp gnus-read-all-available-headers)
5857 (string-match gnus-read-all-available-headers group))
5860 number headers header)
5862 (set-buffer nntp-server-buffer)
5863 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5864 ;; Allow the user to mangle the headers before parsing them.
5865 (gnus-run-hooks 'gnus-parse-headers-hook)
5866 (goto-char (point-min))
5867 (gnus-parse-without-error
5868 (while (and (or sequence allp)
5870 (setq number (read cur))
5872 (while (and sequence
5873 (< (car sequence) number))
5874 (setq sequence (cdr sequence))))
5877 (eq number (car sequence))))
5879 (setq sequence (cdr sequence))
5880 (setq header (inline
5881 (gnus-nov-parse-line
5882 number dependencies force-new)))))
5883 (push header headers))
5885 ;; A common bug in inn is that if you have posted an article and
5886 ;; then retrieves the active file, it will answer correctly --
5887 ;; the new article is included. However, a NOV entry for the
5888 ;; article may not have been generated yet, so this may fail.
5889 ;; We work around this problem by retrieving the last few
5890 ;; headers using HEAD.
5891 (if (or (not also-fetch-heads)
5893 ;; We (probably) got all the headers.
5895 (let ((gnus-nov-is-evil t))
5898 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5899 (gnus-get-newsgroup-headers))))))))
5901 (defun gnus-article-get-xrefs ()
5902 "Fill in the Xref value in `gnus-current-headers', if necessary.
5903 This is meant to be called in `gnus-article-internal-prepare-hook'."
5904 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5905 gnus-current-headers)))
5906 (or (not gnus-use-cross-reference)
5908 (and (mail-header-xref headers)
5909 (not (string= (mail-header-xref headers) "")))
5910 (let ((case-fold-search t)
5913 (nnheader-narrow-to-headers)
5914 (goto-char (point-min))
5915 (when (or (and (not (eobp))
5916 (eq (downcase (char-after)) ?x)
5917 (looking-at "Xref:"))
5918 (search-forward "\nXref:" nil t))
5919 (goto-char (1+ (match-end 0)))
5920 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
5921 (mail-header-set-xref headers xref)))))))
5923 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5924 "Find article ID and insert the summary line for that article.
5925 OLD-HEADER can either be a header or a line number to insert
5926 the subject line on."
5927 (let* ((line (and (numberp old-header) old-header))
5928 (old-header (and (vectorp old-header) old-header))
5929 (header (cond ((and old-header use-old-header)
5932 (gnus-number-to-header id))
5933 (gnus-number-to-header id))
5935 (gnus-read-header id))))
5936 (number (and (numberp id) id))
5939 ;; Rebuild the thread that this article is part of and go to the
5940 ;; article we have fetched.
5941 (when (and (not gnus-show-threads)
5944 (setq d (gnus-data-find (mail-header-number old-header))))
5945 (goto-char (gnus-data-pos d))
5948 (- (gnus-point-at-bol)
5950 (1+ (gnus-point-at-eol))
5951 (gnus-delete-line))))))
5953 (mail-header-set-number header (mail-header-number old-header)))
5954 (setq gnus-newsgroup-sparse
5955 (delq (setq number (mail-header-number header))
5956 gnus-newsgroup-sparse))
5957 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5958 (push number gnus-newsgroup-limit)
5959 (gnus-rebuild-thread (mail-header-id header) line)
5960 (gnus-summary-goto-subject number nil t))
5961 (when (and (numberp number)
5963 ;; We have to update the boundaries even if we can't fetch the
5964 ;; article if ID is a number -- so that the next `P' or `N'
5965 ;; command will fetch the previous (or next) article even
5966 ;; if the one we tried to fetch this time has been canceled.
5967 (when (> number gnus-newsgroup-end)
5968 (setq gnus-newsgroup-end number))
5969 (when (< number gnus-newsgroup-begin)
5970 (setq gnus-newsgroup-begin number))
5971 (setq gnus-newsgroup-unselected
5972 (delq number gnus-newsgroup-unselected)))
5973 ;; Report back a success?
5974 (and header (mail-header-number header))))
5976 ;;; Process/prefix in the summary buffer
5978 (defun gnus-summary-work-articles (n)
5979 "Return a list of articles to be worked upon.
5980 The prefix argument, the list of process marked articles, and the
5981 current article will be taken into consideration."
5983 (set-buffer gnus-summary-buffer)
5986 ;; A numerical prefix has been given.
5987 (setq n (prefix-numeric-value n))
5988 (let ((backward (< n 0))
5989 (n (abs (prefix-numeric-value n)))
5994 (push (setq article (gnus-summary-article-number))
5997 (gnus-summary-find-prev nil article)
5998 (gnus-summary-find-next nil article)))
6000 (nreverse articles)))
6001 ((and (gnus-region-active-p) (mark))
6002 (message "region active")
6003 ;; Work on the region between point and mark.
6004 (let ((max (max (point) (mark)))
6007 (goto-char (min (min (point) (mark))))
6010 (push (setq article (gnus-summary-article-number)) articles)
6011 (gnus-summary-find-next nil article)
6013 (nreverse articles))))
6014 (gnus-newsgroup-processable
6015 ;; There are process-marked articles present.
6016 ;; Save current state.
6017 (gnus-summary-save-process-mark)
6019 (reverse gnus-newsgroup-processable))
6021 ;; Just return the current article.
6022 (list (gnus-summary-article-number))))))
6024 (defmacro gnus-summary-iterate (arg &rest forms)
6025 "Iterate over the process/prefixed articles and do FORMS.
6026 ARG is the interactive prefix given to the command. FORMS will be
6027 executed with point over the summary line of the articles."
6028 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6029 `(let ((,articles (gnus-summary-work-articles ,arg)))
6031 (gnus-summary-goto-subject (car ,articles))
6035 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6036 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6038 (defun gnus-summary-save-process-mark ()
6039 "Push the current set of process marked articles on the stack."
6041 (push (copy-sequence gnus-newsgroup-processable)
6042 gnus-newsgroup-process-stack))
6044 (defun gnus-summary-kill-process-mark ()
6045 "Push the current set of process marked articles on the stack and unmark."
6047 (gnus-summary-save-process-mark)
6048 (gnus-summary-unmark-all-processable))
6050 (defun gnus-summary-yank-process-mark ()
6051 "Pop the last process mark state off the stack and restore it."
6053 (unless gnus-newsgroup-process-stack
6054 (error "Empty mark stack"))
6055 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6057 (defun gnus-summary-process-mark-set (set)
6058 "Make SET into the current process marked articles."
6059 (gnus-summary-unmark-all-processable)
6061 (gnus-summary-set-process-mark (pop set))))
6063 ;;; Searching and stuff
6065 (defun gnus-summary-search-group (&optional backward use-level)
6066 "Search for next unread newsgroup.
6067 If optional argument BACKWARD is non-nil, search backward instead."
6069 (set-buffer gnus-group-buffer)
6070 (when (gnus-group-search-forward
6071 backward nil (if use-level (gnus-group-group-level) nil))
6072 (gnus-group-group-name))))
6074 (defun gnus-summary-best-group (&optional exclude-group)
6075 "Find the name of the best unread group.
6076 If EXCLUDE-GROUP, do not go to this group."
6078 (set-buffer gnus-group-buffer)
6080 (gnus-group-best-unread-group exclude-group))))
6082 (defun gnus-summary-find-next (&optional unread article backward)
6083 (if backward (gnus-summary-find-prev unread article)
6084 (let* ((dummy (gnus-summary-article-intangible-p))
6085 (article (or article (gnus-summary-article-number)))
6086 (data (gnus-data-find-list article))
6088 (when (and (not dummy)
6089 (or (not gnus-summary-check-current)
6091 (not (gnus-data-unread-p (car data)))))
6092 (setq data (cdr data)))
6097 (unless (memq (gnus-data-number (car data))
6098 (cond ((eq gnus-auto-goto-ignores 'always-undownloaded)
6099 gnus-newsgroup-undownloaded)
6102 ((eq gnus-auto-goto-ignores 'unfetched)
6103 gnus-newsgroup-unfetched)
6104 ((eq gnus-auto-goto-ignores 'undownloaded)
6105 gnus-newsgroup-undownloaded)))
6106 (when (gnus-data-unread-p (car data))
6107 (setq result (car data)
6109 (setq data (cdr data)))
6112 (goto-char (gnus-data-pos result))
6113 (gnus-data-number result)))))
6115 (defun gnus-summary-find-prev (&optional unread article)
6116 (let* ((eobp (eobp))
6117 (article (or article (gnus-summary-article-number)))
6118 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6120 (when (and (not eobp)
6121 (or (not gnus-summary-check-current)
6123 (not (gnus-data-unread-p (car data)))))
6124 (setq data (cdr data)))
6129 (unless (memq (gnus-data-number (car data))
6130 (cond ((eq gnus-auto-goto-ignores 'always-undownloaded)
6131 gnus-newsgroup-undownloaded)
6134 ((eq gnus-auto-goto-ignores 'unfetched)
6135 gnus-newsgroup-unfetched)
6136 ((eq gnus-auto-goto-ignores 'undownloaded)
6137 gnus-newsgroup-undownloaded)))
6138 (when (gnus-data-unread-p (car data))
6139 (setq result (car data)
6141 (setq data (cdr data)))
6144 (goto-char (gnus-data-pos result))
6145 (gnus-data-number result))))
6147 (defun gnus-summary-find-subject (subject &optional unread backward article)
6148 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6149 (article (or article (gnus-summary-article-number)))
6150 (articles (gnus-data-list backward))
6151 (arts (gnus-data-find-list article articles))
6153 (when (or (not gnus-summary-check-current)
6155 (not (gnus-data-unread-p (car arts))))
6156 (setq arts (cdr arts)))
6158 (and (or (not unread)
6159 (gnus-data-unread-p (car arts)))
6160 (vectorp (gnus-data-header (car arts)))
6162 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6163 (setq result (car arts)
6165 (setq arts (cdr arts)))
6167 (goto-char (gnus-data-pos result))
6168 (gnus-data-number result))))
6170 (defun gnus-summary-search-forward (&optional unread subject backward)
6171 "Search forward for an article.
6172 If UNREAD, look for unread articles. If SUBJECT, look for
6173 articles with that subject. If BACKWARD, search backward instead."
6174 (cond (subject (gnus-summary-find-subject subject unread backward))
6175 (backward (gnus-summary-find-prev unread))
6176 (t (gnus-summary-find-next unread))))
6178 (defun gnus-recenter (&optional n)
6179 "Center point in window and redisplay frame.
6180 Also do horizontal recentering."
6182 (when (and gnus-auto-center-summary
6183 (not (eq gnus-auto-center-summary 'vertical)))
6184 (gnus-horizontal-recenter))
6187 (defun gnus-summary-recenter ()
6188 "Center point in the summary window.
6189 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6190 displayed, no centering will be performed."
6191 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6192 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6194 ;; The user has to want it.
6195 (when gnus-auto-center-summary
6196 (let* ((top (cond ((< (window-height) 4) 0)
6197 ((< (window-height) 7) 1)
6198 (t (if (numberp gnus-auto-center-summary)
6199 gnus-auto-center-summary
6201 (height (1- (window-height)))
6202 (bottom (save-excursion (goto-char (point-max))
6203 (forward-line (- height))
6205 (window (get-buffer-window (current-buffer))))
6206 (when (get-buffer-window gnus-article-buffer)
6207 ;; Only do recentering when the article buffer is displayed,
6208 ;; Set the window start to either `bottom', which is the biggest
6209 ;; possible valid number, or the second line from the top,
6210 ;; whichever is the least.
6211 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6212 (if (> bottom top-pos)
6213 ;; Keep the second line from the top visible
6214 (set-window-start window top-pos t)
6215 ;; Try to keep the bottom line visible; if it's partially
6216 ;; obscured, either scroll one more line to make it fully
6217 ;; visible, or revert to using TOP-POS.
6219 (goto-char (point-max))
6221 (let ((last-line-start (point)))
6223 (set-window-start window (point) t)
6224 (when (not (pos-visible-in-window-p last-line-start window))
6226 (set-window-start window (min (point) top-pos) t)))))))
6227 ;; Do horizontal recentering while we're at it.
6228 (when (and (get-buffer-window (current-buffer) t)
6229 (not (eq gnus-auto-center-summary 'vertical)))
6230 (let ((selected (selected-window)))
6231 (select-window (get-buffer-window (current-buffer) t))
6232 (gnus-summary-position-point)
6233 (gnus-horizontal-recenter)
6234 (select-window selected))))))
6236 (defun gnus-summary-jump-to-group (newsgroup)
6237 "Move point to NEWSGROUP in group mode buffer."
6238 ;; Keep update point of group mode buffer if visible.
6239 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6240 (save-window-excursion
6241 ;; Take care of tree window mode.
6242 (when (get-buffer-window gnus-group-buffer)
6243 (pop-to-buffer gnus-group-buffer))
6244 (gnus-group-jump-to-group newsgroup))
6246 ;; Take care of tree window mode.
6247 (if (get-buffer-window gnus-group-buffer)
6248 (pop-to-buffer gnus-group-buffer)
6249 (set-buffer gnus-group-buffer))
6250 (gnus-group-jump-to-group newsgroup))))
6252 ;; This function returns a list of article numbers based on the
6253 ;; difference between the ranges of read articles in this group and
6254 ;; the range of active articles.
6255 (defun gnus-list-of-unread-articles (group)
6256 (let* ((read (gnus-info-read (gnus-get-info group)))
6257 (active (or (gnus-active group) (gnus-activate-group group)))
6260 ;; If none are read, then all are unread.
6262 (setq first (car active))
6263 ;; If the range of read articles is a single range, then the
6264 ;; first unread article is the article after the last read
6265 ;; article. Sounds logical, doesn't it?
6266 (if (and (not (listp (cdr read)))
6267 (or (< (car read) (car active))
6268 (progn (setq read (list read))
6270 (setq first (max (car active) (1+ (cdr read))))
6271 ;; `read' is a list of ranges.
6272 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6275 (setq first (car active)))
6278 (while (< first nlast)
6280 (setq first (1+ first))))
6281 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6282 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6283 (setq read (cdr read)))))
6284 ;; And add the last unread articles.
6285 (while (<= first last)
6287 (setq first (1+ first)))
6288 ;; Return the list of unread articles.
6289 (delq 0 (nreverse unread))))
6291 (defun gnus-list-of-read-articles (group)
6292 "Return a list of unread, unticked and non-dormant articles."
6293 (let* ((info (gnus-get-info group))
6294 (marked (gnus-info-marks info))
6295 (active (gnus-active group)))
6297 (gnus-list-range-difference
6298 (gnus-list-range-difference
6299 (gnus-sorted-complement
6300 (gnus-uncompress-range active)
6301 (gnus-list-of-unread-articles group))
6302 (cdr (assq 'dormant marked)))
6303 (cdr (assq 'tick marked))))))
6305 ;; Various summary commands
6307 (defun gnus-summary-select-article-buffer ()
6308 "Reconfigure windows to show article buffer."
6310 (if (not (gnus-buffer-live-p gnus-article-buffer))
6311 (error "There is no article buffer for this summary buffer")
6312 (gnus-configure-windows 'article)
6313 (select-window (get-buffer-window gnus-article-buffer))))
6315 (defun gnus-summary-universal-argument (arg)
6316 "Perform any operation on all articles that are process/prefixed."
6318 (let ((articles (gnus-summary-work-articles arg))
6325 (substitute-command-keys
6326 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6328 (gnus-error 1 "Undefined key")
6331 (gnus-summary-goto-subject (setq article (pop articles)))
6332 (let (gnus-newsgroup-processable)
6333 (command-execute func))
6334 (gnus-summary-remove-process-mark article)))))
6335 (gnus-summary-position-point))
6337 (defun gnus-summary-toggle-truncation (&optional arg)
6338 "Toggle truncation of summary lines.
6339 With arg, turn line truncation on if arg is positive."
6341 (setq truncate-lines
6342 (if (null arg) (not truncate-lines)
6343 (> (prefix-numeric-value arg) 0)))
6346 (defun gnus-summary-find-for-reselect ()
6347 "Return the number of an article to stay on across a reselect.
6348 The current article is considered, then following articles, then previous
6349 articles. An article is sought which is not cancelled and isn't a temporary
6350 insertion from another group. If there's no such then return a dummy 0."
6352 (dolist (rev '(nil t))
6353 (unless found ; don't demand the reverse list if we don't need it
6354 (let ((data (gnus-data-find-list
6355 (gnus-summary-article-number) (gnus-data-list rev))))
6356 (while (and data (not found))
6357 (if (and (< 0 (gnus-data-number (car data)))
6358 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6359 (setq found (gnus-data-number (car data))))
6360 (setq data (cdr data))))))
6363 (defun gnus-summary-reselect-current-group (&optional all rescan)
6364 "Exit and then reselect the current newsgroup.
6365 The prefix argument ALL means to select all articles."
6367 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6368 (error "Ephemeral groups can't be reselected"))
6369 (let ((current-subject (gnus-summary-find-for-reselect))
6370 (group gnus-newsgroup-name))
6371 (setq gnus-newsgroup-begin nil)
6373 ;; We have to adjust the point of group mode buffer because
6374 ;; point was moved to the next unread newsgroup by exiting.
6375 (gnus-summary-jump-to-group group)
6378 (gnus-group-get-new-news-this-group 1)))
6379 (gnus-group-read-group all t)
6380 (gnus-summary-goto-subject current-subject nil t)))
6382 (defun gnus-summary-rescan-group (&optional all)
6383 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6385 (gnus-summary-reselect-current-group all t))
6387 (defun gnus-summary-update-info (&optional non-destructive)
6389 (let ((group gnus-newsgroup-name))
6391 (when gnus-newsgroup-kill-headers
6392 (setq gnus-newsgroup-killed
6393 (gnus-compress-sequence
6395 (gnus-list-range-intersection
6396 gnus-newsgroup-unselected gnus-newsgroup-killed)
6397 gnus-newsgroup-unreads)
6399 (unless (listp (cdr gnus-newsgroup-killed))
6400 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6401 (let ((headers gnus-newsgroup-headers))
6402 ;; Set the new ranges of read articles.
6404 (set-buffer gnus-group-buffer)
6405 (gnus-undo-force-boundary))
6406 (gnus-update-read-articles
6407 group (gnus-sorted-union
6408 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6409 ;; Set the current article marks.
6410 (let ((gnus-newsgroup-scored
6411 (if (and (not gnus-save-score)
6412 (not non-destructive))
6414 gnus-newsgroup-scored)))
6416 (gnus-update-marks)))
6417 ;; Do the cross-ref thing.
6418 (when gnus-use-cross-reference
6419 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6420 ;; Do not switch windows but change the buffer to work.
6421 (set-buffer gnus-group-buffer)
6422 (unless (gnus-ephemeral-group-p group)
6423 (gnus-group-update-group group)))))))
6425 (defun gnus-summary-save-newsrc (&optional force)
6426 "Save the current number of read/marked articles in the dribble buffer.
6427 The dribble buffer will then be saved.
6428 If FORCE (the prefix), also save the .newsrc file(s)."
6430 (gnus-summary-update-info t)
6432 (gnus-save-newsrc-file)
6433 (gnus-dribble-save)))
6435 (defun gnus-summary-exit (&optional temporary)
6436 "Exit reading current newsgroup, and then return to group selection mode.
6437 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6439 (gnus-set-global-variables)
6440 (when (gnus-buffer-live-p gnus-article-buffer)
6442 (set-buffer gnus-article-buffer)
6443 (mm-destroy-parts gnus-article-mime-handles)
6444 ;; Set it to nil for safety reason.
6445 (setq gnus-article-mime-handle-alist nil)
6446 (setq gnus-article-mime-handles nil)))
6447 (gnus-kill-save-kill-buffer)
6448 (gnus-async-halt-prefetch)
6449 (let* ((group gnus-newsgroup-name)
6450 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6451 (gnus-group-is-exiting-p t)
6454 (buf (current-buffer)))
6456 ;; Do adaptive scoring, and possibly save score files.
6457 (when gnus-newsgroup-adaptive
6458 (gnus-score-adaptive))
6459 (when gnus-use-scoring
6461 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6462 ;; If we have several article buffers, we kill them at exit.
6463 (unless gnus-single-article-buffer
6464 (gnus-kill-buffer gnus-original-article-buffer)
6465 (setq gnus-article-current nil))
6466 (when gnus-use-cache
6467 (gnus-cache-possibly-remove-articles)
6468 (gnus-cache-save-buffers))
6469 (gnus-async-prefetch-remove-group group)
6470 (when gnus-suppress-duplicates
6471 (gnus-dup-enter-articles))
6472 (when gnus-use-trees
6473 (gnus-tree-close group))
6474 (when gnus-use-cache
6475 (gnus-cache-write-active))
6476 ;; Remove entries for this group.
6477 (nnmail-purge-split-history (gnus-group-real-name group))
6478 ;; Make all changes in this group permanent.
6480 (gnus-run-hooks 'gnus-exit-group-hook)
6481 (gnus-summary-update-info))
6482 (gnus-close-group group)
6483 ;; Make sure where we were, and go to next newsgroup.
6484 (set-buffer gnus-group-buffer)
6486 (gnus-group-jump-to-group group))
6487 (gnus-run-hooks 'gnus-summary-exit-hook)
6488 (unless (or quit-config
6489 ;; If this group has disappeared from the summary
6490 ;; buffer, don't skip forwards.
6491 (not (string= group (gnus-group-group-name))))
6492 (gnus-group-next-unread-group 1))
6493 (setq group-point (point))
6496 ;; If we have several article buffers, we kill them at exit.
6497 (unless gnus-single-article-buffer
6498 (gnus-kill-buffer gnus-article-buffer)
6499 (gnus-kill-buffer gnus-original-article-buffer)
6500 (setq gnus-article-current nil))
6502 (if (not gnus-kill-summary-on-exit)
6504 (gnus-deaden-summary)
6506 ;; We set all buffer-local variables to nil. It is unclear why
6507 ;; this is needed, but if we don't, buffer-local variables are
6508 ;; not garbage-collected, it seems. This would the lead to en
6509 ;; ever-growing Emacs.
6510 (gnus-summary-clear-local-variables)
6511 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6512 (gnus-summary-clear-local-variables))
6513 (when (get-buffer gnus-article-buffer)
6514 (bury-buffer gnus-article-buffer))
6515 ;; We clear the global counterparts of the buffer-local
6516 ;; variables as well, just to be on the safe side.
6517 (set-buffer gnus-group-buffer)
6518 (gnus-summary-clear-local-variables)
6519 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6520 (gnus-summary-clear-local-variables))
6521 ;; Return to group mode buffer.
6522 (when (eq mode 'gnus-summary-mode)
6523 (gnus-kill-buffer buf)))
6524 (setq gnus-current-select-method gnus-select-method)
6525 (pop-to-buffer gnus-group-buffer)
6526 (if (not quit-config)
6528 (goto-char group-point)
6529 (gnus-configure-windows 'group 'force))
6530 (gnus-handle-ephemeral-exit quit-config))
6531 ;; Clear the current group name.
6533 (setq gnus-newsgroup-name nil)))))
6535 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6536 (defun gnus-summary-exit-no-update (&optional no-questions)
6537 "Quit reading current newsgroup without updating read article info."
6539 (let* ((group gnus-newsgroup-name)
6540 (gnus-group-is-exiting-p t)
6541 (gnus-group-is-exiting-without-update-p t)
6542 (quit-config (gnus-group-quit-config group)))
6543 (when (or no-questions
6545 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6546 (gnus-async-halt-prefetch)
6547 (run-hooks 'gnus-summary-prepare-exit-hook)
6548 (when (gnus-buffer-live-p gnus-article-buffer)
6550 (set-buffer gnus-article-buffer)
6551 (mm-destroy-parts gnus-article-mime-handles)
6552 ;; Set it to nil for safety reason.
6553 (setq gnus-article-mime-handle-alist nil)
6554 (setq gnus-article-mime-handles nil)))
6555 ;; If we have several article buffers, we kill them at exit.
6556 (unless gnus-single-article-buffer
6557 (gnus-kill-buffer gnus-article-buffer)
6558 (gnus-kill-buffer gnus-original-article-buffer)
6559 (setq gnus-article-current nil))
6560 (if (not gnus-kill-summary-on-exit)
6561 (gnus-deaden-summary)
6562 (gnus-close-group group)
6563 (gnus-summary-clear-local-variables)
6564 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6565 (gnus-summary-clear-local-variables))
6566 (set-buffer gnus-group-buffer)
6567 (gnus-summary-clear-local-variables)
6568 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6569 (gnus-summary-clear-local-variables))
6570 (gnus-kill-buffer gnus-summary-buffer))
6571 (unless gnus-single-article-buffer
6572 (setq gnus-article-current nil))
6573 (when gnus-use-trees
6574 (gnus-tree-close group))
6575 (gnus-async-prefetch-remove-group group)
6576 (when (get-buffer gnus-article-buffer)
6577 (bury-buffer gnus-article-buffer))
6578 ;; Return to the group buffer.
6579 (gnus-configure-windows 'group 'force)
6580 ;; Clear the current group name.
6581 (setq gnus-newsgroup-name nil)
6582 (unless (gnus-ephemeral-group-p group)
6583 (gnus-group-update-group group))
6584 (when (equal (gnus-group-group-name) group)
6585 (gnus-group-next-unread-group 1))
6587 (gnus-handle-ephemeral-exit quit-config)))))
6589 (defun gnus-handle-ephemeral-exit (quit-config)
6590 "Handle movement when leaving an ephemeral group.
6591 The state which existed when entering the ephemeral is reset."
6592 (if (not (buffer-name (car quit-config)))
6593 (gnus-configure-windows 'group 'force)
6594 (set-buffer (car quit-config))
6595 (cond ((eq major-mode 'gnus-summary-mode)
6596 (gnus-set-global-variables))
6597 ((eq major-mode 'gnus-article-mode)
6599 ;; The `gnus-summary-buffer' variable may point
6600 ;; to the old summary buffer when using a single
6602 (unless (gnus-buffer-live-p gnus-summary-buffer)
6603 (set-buffer gnus-group-buffer))
6604 (set-buffer gnus-summary-buffer)
6605 (gnus-set-global-variables))))
6606 (if (or (eq (cdr quit-config) 'article)
6607 (eq (cdr quit-config) 'pick))
6609 ;; The current article may be from the ephemeral group
6610 ;; thus it is best that we reload this article
6611 (gnus-summary-show-article)
6612 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6613 (gnus-configure-windows 'pick 'force)
6614 (gnus-configure-windows (cdr quit-config) 'force)))
6615 (gnus-configure-windows (cdr quit-config) 'force))
6616 (when (eq major-mode 'gnus-summary-mode)
6617 (gnus-summary-next-subject 1 nil t)
6618 (gnus-summary-recenter)
6619 (gnus-summary-position-point))))
6623 (defvar gnus-dead-summary-mode-map nil)
6625 (unless gnus-dead-summary-mode-map
6626 (setq gnus-dead-summary-mode-map (make-keymap))
6627 (suppress-keymap gnus-dead-summary-mode-map)
6628 (substitute-key-definition
6629 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6630 (dolist (key '("\C-d" "\r" "\177" [delete]))
6631 (define-key gnus-dead-summary-mode-map
6632 key 'gnus-summary-wake-up-the-dead))
6633 (dolist (key '("q" "Q"))
6634 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6636 (defvar gnus-dead-summary-mode nil
6637 "Minor mode for Gnus summary buffers.")
6639 (defun gnus-dead-summary-mode (&optional arg)
6640 "Minor mode for Gnus summary buffers."
6642 (when (eq major-mode 'gnus-summary-mode)
6643 (make-local-variable 'gnus-dead-summary-mode)
6644 (setq gnus-dead-summary-mode
6645 (if (null arg) (not gnus-dead-summary-mode)
6646 (> (prefix-numeric-value arg) 0)))
6647 (when gnus-dead-summary-mode
6648 (gnus-add-minor-mode
6649 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6651 (defun gnus-deaden-summary ()
6652 "Make the current summary buffer into a dead summary buffer."
6653 ;; Kill any previous dead summary buffer.
6654 (when (and gnus-dead-summary
6655 (buffer-name gnus-dead-summary))
6657 (set-buffer gnus-dead-summary)
6658 (when gnus-dead-summary-mode
6659 (kill-buffer (current-buffer)))))
6660 ;; Make this the current dead summary.
6661 (setq gnus-dead-summary (current-buffer))
6662 (gnus-dead-summary-mode 1)
6663 (let ((name (buffer-name)))
6664 (when (string-match "Summary" name)
6666 (concat (substring name 0 (match-beginning 0)) "Dead "
6667 (substring name (match-beginning 0)))
6671 (defun gnus-kill-or-deaden-summary (buffer)
6672 "Kill or deaden the summary BUFFER."
6674 (when (and (buffer-name buffer)
6675 (not gnus-single-article-buffer))
6678 (gnus-kill-buffer gnus-article-buffer)
6679 (gnus-kill-buffer gnus-original-article-buffer)))
6682 (gnus-kill-summary-on-exit
6683 (when (and gnus-use-trees
6684 (gnus-buffer-exists-p buffer))
6687 (gnus-tree-close gnus-newsgroup-name)))
6688 (gnus-kill-buffer buffer))
6689 ;; Deaden the buffer.
6690 ((gnus-buffer-exists-p buffer)
6693 (gnus-deaden-summary))))))
6695 (defun gnus-summary-wake-up-the-dead (&rest args)
6696 "Wake up the dead summary buffer."
6698 (gnus-dead-summary-mode -1)
6699 (let ((name (buffer-name)))
6700 (when (string-match "Dead " name)
6702 (concat (substring name 0 (match-beginning 0))
6703 (substring name (match-end 0)))
6705 (gnus-message 3 "This dead summary is now alive again"))
6707 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6708 (defun gnus-summary-fetch-faq (&optional faq-dir)
6709 "Fetch the FAQ for the current group.
6710 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6714 (when current-prefix-arg
6716 "FAQ dir: " (and (listp gnus-group-faq-directory)
6717 (mapcar (lambda (file) (list file))
6718 gnus-group-faq-directory))))))
6719 (let (gnus-faq-buffer)
6720 (when (setq gnus-faq-buffer
6721 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6722 (gnus-configure-windows 'summary-faq))))
6724 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6725 (defun gnus-summary-describe-group (&optional force)
6726 "Describe the current newsgroup."
6728 (gnus-group-describe-group force gnus-newsgroup-name))
6730 (defun gnus-summary-describe-briefly ()
6731 "Describe summary mode commands briefly."
6733 (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")))
6735 ;; Walking around group mode buffer from summary mode.
6737 (defun gnus-summary-next-group (&optional no-article target-group backward)
6738 "Exit current newsgroup and then select next unread newsgroup.
6739 If prefix argument NO-ARTICLE is non-nil, no article is selected
6740 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6741 previous group instead."
6743 ;; Stop pre-fetching.
6744 (gnus-async-halt-prefetch)
6745 (let ((current-group gnus-newsgroup-name)
6746 (current-buffer (current-buffer))
6748 ;; First we semi-exit this group to update Xrefs and all variables.
6749 ;; We can't do a real exit, because the window conf must remain
6750 ;; the same in case the user is prompted for info, and we don't
6751 ;; want the window conf to change before that...
6752 (gnus-summary-exit t)
6753 (while (not entered)
6754 ;; Then we find what group we are supposed to enter.
6755 (set-buffer gnus-group-buffer)
6756 (gnus-group-jump-to-group current-group)
6759 (if (eq gnus-keep-same-level 'best)
6760 (gnus-summary-best-group gnus-newsgroup-name)
6761 (gnus-summary-search-group backward gnus-keep-same-level))))
6762 (if (not target-group)
6763 ;; There are no further groups, so we return to the group
6766 (gnus-message 5 "Returning to the group buffer")
6768 (when (gnus-buffer-live-p current-buffer)
6769 (set-buffer current-buffer)
6770 (gnus-summary-exit))
6771 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6772 ;; We try to enter the target group.
6773 (gnus-group-jump-to-group target-group)
6774 (let ((unreads (gnus-group-group-unread)))
6775 (if (and (or (eq t unreads)
6776 (and unreads (not (zerop unreads))))
6777 (gnus-summary-read-group
6778 target-group nil no-article
6779 (and (buffer-name current-buffer) current-buffer)
6782 (setq current-group target-group
6783 target-group nil)))))))
6785 (defun gnus-summary-prev-group (&optional no-article)
6786 "Exit current newsgroup and then select previous unread newsgroup.
6787 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6789 (gnus-summary-next-group no-article nil t))
6791 ;; Walking around summary lines.
6793 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6794 "Go to the first subject satisfying any non-nil constraint.
6795 If UNREAD is non-nil, the article should be unread.
6796 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6797 If UNSEED is non-nil, the article should be unseen.
6798 Returns the article selected or nil if there are no matching articles."
6802 ((null gnus-newsgroup-data)
6803 (gnus-message 3 "No articles in the group")
6805 ;; Pick the first article.
6806 ((not (or unread undownloaded unseen))
6807 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6808 (gnus-data-number (car gnus-newsgroup-data)))
6809 ;; Find the first unread article.
6811 (let ((data gnus-newsgroup-data))
6813 (let ((num (gnus-data-number (car data))))
6814 (or (memq num gnus-newsgroup-unfetched)
6815 (not (or (and unread
6816 (memq num gnus-newsgroup-unreads))
6818 (memq num gnus-newsgroup-undownloaded))
6820 (memq num gnus-newsgroup-unseen)))))))
6821 (setq data (cdr data)))
6825 (goto-char (gnus-data-pos (car data)))
6826 (gnus-data-number (car data)))
6827 (gnus-message 3 "No more%s articles"
6828 (let* ((r (when unread " unread"))
6829 (d (when undownloaded " undownloaded"))
6830 (s (when unseen " unseen"))
6831 (l (delq nil (list r d s))))
6832 (cond ((= 3 (length l))
6833 (concat r "," d ", or" s))
6835 (concat (car l) ", or" (cadr l)))
6842 (gnus-summary-position-point))))))
6844 (defun gnus-summary-next-subject (n &optional unread dont-display)
6845 "Go to next N'th summary line.
6846 If N is negative, go to the previous N'th subject line.
6847 If UNREAD is non-nil, only unread articles are selected.
6848 The difference between N and the actual number of steps taken is
6851 (let ((backward (< n 0))
6855 (gnus-summary-find-prev unread)
6856 (gnus-summary-find-next unread)))
6857 (unless (zerop (setq n (1- n)))
6858 (gnus-summary-show-thread)))
6860 (gnus-message 7 "No more%s articles"
6861 (if unread " unread" "")))
6862 (unless dont-display
6863 (gnus-summary-recenter)
6864 (gnus-summary-position-point))
6867 (defun gnus-summary-next-unread-subject (n)
6868 "Go to next N'th unread summary line."
6870 (gnus-summary-next-subject n t))
6872 (defun gnus-summary-prev-subject (n &optional unread)
6873 "Go to previous N'th summary line.
6874 If optional argument UNREAD is non-nil, only unread article is selected."
6876 (gnus-summary-next-subject (- n) unread))
6878 (defun gnus-summary-prev-unread-subject (n)
6879 "Go to previous N'th unread summary line."
6881 (gnus-summary-next-subject (- n) t))
6883 (defun gnus-summary-goto-subjects (articles)
6884 "Insert the subject header for ARTICLES in the current buffer."
6886 (dolist (article articles)
6887 (gnus-summary-goto-subject article t)))
6888 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6889 (gnus-summary-position-point))
6891 (defun gnus-summary-goto-subject (article &optional force silent)
6892 "Go the subject line of ARTICLE.
6893 If FORCE, also allow jumping to articles not currently shown."
6894 (interactive "nArticle number: ")
6895 (unless (numberp article)
6896 (error "Article %s is not a number" article))
6898 (data (gnus-data-find article)))
6899 ;; We read in the article if we have to.
6902 (gnus-summary-insert-subject
6904 (if (or (numberp force) (vectorp force)) force)
6906 (setq data (gnus-data-find article)))
6911 (gnus-message 3 "Can't find article %d" article))
6913 (let ((pt (gnus-data-pos data)))
6915 (gnus-summary-set-article-display-arrow pt))
6916 (gnus-summary-position-point)
6919 ;; Walking around summary lines with displaying articles.
6921 (defun gnus-summary-expand-window (&optional arg)
6922 "Make the summary buffer take up the entire Emacs frame.
6923 Given a prefix, will force an `article' buffer configuration."
6926 (gnus-configure-windows 'article 'force)
6927 (gnus-configure-windows 'summary 'force)))
6929 (defun gnus-summary-display-article (article &optional all-header)
6930 "Display ARTICLE in article buffer."
6931 (when (gnus-buffer-live-p gnus-article-buffer)
6932 (with-current-buffer gnus-article-buffer
6933 (mm-enable-multibyte)))
6934 (gnus-set-global-variables)
6935 (when (gnus-buffer-live-p gnus-article-buffer)
6936 (with-current-buffer gnus-article-buffer
6937 (setq gnus-article-charset gnus-newsgroup-charset)
6938 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6939 (mm-enable-multibyte)))
6943 (if gnus-summary-display-article-function
6944 (funcall gnus-summary-display-article-function article all-header)
6945 (gnus-article-prepare article all-header))
6946 (gnus-run-hooks 'gnus-select-article-hook)
6947 (when (and gnus-current-article
6948 (not (zerop gnus-current-article)))
6949 (gnus-summary-goto-subject gnus-current-article))
6950 (gnus-summary-recenter)
6951 (when (and gnus-use-trees gnus-show-threads)
6952 (gnus-possibly-generate-tree article)
6953 (gnus-highlight-selected-tree article))
6954 ;; Successfully display article.
6955 (gnus-article-set-window-start
6956 (cdr (assq article gnus-newsgroup-bookmarks))))))
6958 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6959 "Select the current article.
6960 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6961 non-nil, the article will be re-fetched even if it already present in
6962 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6964 ;; Make sure we are in the summary buffer to work around bbdb bug.
6965 (unless (eq major-mode 'gnus-summary-mode)
6966 (set-buffer gnus-summary-buffer))
6967 (let ((article (or article (gnus-summary-article-number)))
6968 (all-headers (not (not all-headers))) ;Must be t or nil.
6969 gnus-summary-display-article-function)
6971 (gnus-summary-article-pseudo-p article)
6972 (error "This is a pseudo-article"))
6974 (set-buffer gnus-summary-buffer)
6975 (if (or (and gnus-single-article-buffer
6976 (or (null gnus-current-article)
6977 (null gnus-article-current)
6978 (null (get-buffer gnus-article-buffer))
6979 (not (eq article (cdr gnus-article-current)))
6980 (not (equal (car gnus-article-current)
6981 gnus-newsgroup-name))))
6982 (and (not gnus-single-article-buffer)
6983 (or (null gnus-current-article)
6984 (not (eq gnus-current-article article))))
6986 ;; The requested article is different from the current article.
6988 (gnus-summary-display-article article all-headers)
6989 (when (gnus-buffer-live-p gnus-article-buffer)
6990 (with-current-buffer gnus-article-buffer
6991 (if (not gnus-article-decoded-p) ;; a local variable
6992 (mm-disable-multibyte))))
6993 (gnus-article-set-window-start
6994 (cdr (assq article gnus-newsgroup-bookmarks)))
6998 (defun gnus-summary-force-verify-and-decrypt ()
6999 "Display buttons for signed/encrypted parts and verify/decrypt them."
7001 (let ((mm-verify-option 'known)
7002 (mm-decrypt-option 'known)
7003 (gnus-buttonized-mime-types (append (list "multipart/signed"
7004 "multipart/encrypted")
7005 gnus-buttonized-mime-types)))
7006 (gnus-summary-select-article nil 'force)))
7008 (defun gnus-summary-set-current-mark (&optional current-mark)
7009 "Obsolete function."
7012 (defun gnus-summary-next-article (&optional unread subject backward push)
7013 "Select the next article.
7014 If UNREAD, only unread articles are selected.
7015 If SUBJECT, only articles with SUBJECT are selected.
7016 If BACKWARD, the previous article is selected instead of the next."
7019 ;; Is there such an article?
7020 ((and (gnus-summary-search-forward unread subject backward)
7021 (or (gnus-summary-display-article (gnus-summary-article-number))
7022 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7023 (gnus-summary-position-point))
7024 ;; If not, we try the first unread, if that is wanted.
7026 gnus-auto-select-same
7027 (gnus-summary-first-unread-article))
7028 (gnus-summary-position-point)
7029 (gnus-message 6 "Wrapped"))
7030 ;; Try to get next/previous article not displayed in this group.
7031 ((and gnus-auto-extend-newsgroup
7032 (not unread) (not subject))
7033 (gnus-summary-goto-article
7034 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7035 nil (count-lines (point-min) (point))))
7036 ;; Go to next/previous group.
7038 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7039 (gnus-summary-jump-to-group gnus-newsgroup-name))
7040 (let ((cmd last-command-char)
7043 (set-buffer gnus-group-buffer)
7046 (if (eq gnus-keep-same-level 'best)
7047 (gnus-summary-best-group gnus-newsgroup-name)
7048 (gnus-summary-search-group backward gnus-keep-same-level))))
7049 ;; For some reason, the group window gets selected. We change
7051 (select-window (get-buffer-window (current-buffer)))
7052 ;; Select next unread newsgroup automagically.
7054 ((or (not gnus-auto-select-next)
7056 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7057 ((or (eq gnus-auto-select-next 'quietly)
7058 (and (eq gnus-auto-select-next 'slightly-quietly)
7060 (and (eq gnus-auto-select-next 'almost-quietly)
7061 (gnus-summary-last-article-p)))
7063 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7065 (gnus-message 7 "No more%s articles (%s)..."
7066 (if unread " unread" "")
7067 (if group (concat "selecting " group)
7069 (gnus-summary-next-group nil group backward)))
7071 (when (gnus-key-press-event-p last-input-event)
7072 (gnus-summary-walk-group-buffer
7073 gnus-newsgroup-name cmd unread backward point))))))))
7075 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7076 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7077 (?\C-p (gnus-group-prev-unread-group 1))))
7078 (cursor-in-echo-area t)
7079 keve key group ended prompt)
7081 (set-buffer gnus-group-buffer)
7084 (if (eq gnus-keep-same-level 'best)
7085 (gnus-summary-best-group gnus-newsgroup-name)
7086 (gnus-summary-search-group backward gnus-keep-same-level))))
7090 "No more%s articles%s " (if unread " unread" "")
7092 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7093 (format " (Type %s for %s [%s])"
7094 (single-key-description cmd) group
7095 (car (gnus-gethash group gnus-newsrc-hashtb)))
7096 (format " (Type %s to exit %s)"
7097 (single-key-description cmd)
7098 gnus-newsgroup-name))))
7099 ;; Confirm auto selection.
7100 (setq key (car (setq keve (gnus-read-event-char prompt)))
7103 ((assq key keystrokes)
7104 (let ((obuf (current-buffer)))
7105 (switch-to-buffer gnus-group-buffer)
7107 (gnus-group-jump-to-group group))
7108 (eval (cadr (assq key keystrokes)))
7109 (setq group (gnus-group-group-name))
7110 (switch-to-buffer obuf))
7114 (gnus-ephemeral-group-p gnus-newsgroup-name))
7116 (gnus-summary-next-group nil group backward)))
7118 (push (cdr keve) unread-command-events))))))
7120 (defun gnus-summary-next-unread-article ()
7121 "Select unread article after current one."
7123 (gnus-summary-next-article
7124 (or (not (eq gnus-summary-goto-unread 'never))
7125 (gnus-summary-last-article-p (gnus-summary-article-number)))
7126 (and gnus-auto-select-same
7127 (gnus-summary-article-subject))))
7129 (defun gnus-summary-prev-article (&optional unread subject)
7130 "Select the article after the current one.
7131 If UNREAD is non-nil, only unread articles are selected."
7133 (gnus-summary-next-article unread subject t))
7135 (defun gnus-summary-prev-unread-article ()
7136 "Select unread article before current one."
7138 (gnus-summary-prev-article
7139 (or (not (eq gnus-summary-goto-unread 'never))
7140 (gnus-summary-first-article-p (gnus-summary-article-number)))
7141 (and gnus-auto-select-same
7142 (gnus-summary-article-subject))))
7144 (defun gnus-summary-next-page (&optional lines circular stop)
7145 "Show next page of the selected article.
7146 If at the end of the current article, select the next article.
7147 LINES says how many lines should be scrolled up.
7149 If CIRCULAR is non-nil, go to the start of the article instead of
7150 selecting the next article when reaching the end of the current
7153 If STOP is non-nil, just stop when reaching the end of the message."
7155 (setq gnus-summary-buffer (current-buffer))
7156 (gnus-set-global-variables)
7157 (let ((article (gnus-summary-article-number))
7158 (article-window (get-buffer-window gnus-article-buffer t))
7160 ;; If the buffer is empty, we have no article.
7162 (error "No article to select"))
7163 (gnus-configure-windows 'article)
7164 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7165 (if (and (eq gnus-summary-goto-unread 'never)
7166 (not (gnus-summary-last-article-p article)))
7167 (gnus-summary-next-article)
7168 (gnus-summary-next-unread-article))
7169 (if (or (null gnus-current-article)
7170 (null gnus-article-current)
7171 (/= article (cdr gnus-article-current))
7172 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7173 ;; Selected subject is different from current article's.
7174 (gnus-summary-display-article article)
7175 (when article-window
7176 (gnus-eval-in-buffer-window gnus-article-buffer
7177 (setq endp (or (gnus-article-next-page lines)
7178 (gnus-article-only-boring-p))))
7181 (gnus-message 3 "End of message"))
7183 (gnus-summary-beginning-of-article))
7185 (gnus-message 3 "End of message"))
7187 (if (and (eq gnus-summary-goto-unread 'never)
7188 (not (gnus-summary-last-article-p article)))
7189 (gnus-summary-next-article)
7190 (gnus-summary-next-unread-article))))))))
7191 (gnus-summary-recenter)
7192 (gnus-summary-position-point)))
7194 (defun gnus-summary-prev-page (&optional lines move)
7195 "Show previous page of selected article.
7196 Argument LINES specifies lines to be scrolled down.
7197 If MOVE, move to the previous unread article if point is at
7198 the beginning of the buffer."
7200 (let ((article (gnus-summary-article-number))
7201 (article-window (get-buffer-window gnus-article-buffer t))
7203 (gnus-configure-windows 'article)
7204 (if (or (null gnus-current-article)
7205 (null gnus-article-current)
7206 (/= article (cdr gnus-article-current))
7207 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7208 ;; Selected subject is different from current article's.
7209 (gnus-summary-display-article article)
7210 (gnus-summary-recenter)
7211 (when article-window
7212 (gnus-eval-in-buffer-window gnus-article-buffer
7213 (setq endp (gnus-article-prev-page lines)))
7214 (when (and move endp)
7216 (gnus-message 3 "Beginning of message"))
7218 (if (and (eq gnus-summary-goto-unread 'never)
7219 (not (gnus-summary-first-article-p article)))
7220 (gnus-summary-prev-article)
7221 (gnus-summary-prev-unread-article))))))))
7222 (gnus-summary-position-point))
7224 (defun gnus-summary-prev-page-or-article (&optional lines)
7225 "Show previous page of selected article.
7226 Argument LINES specifies lines to be scrolled down.
7227 If at the beginning of the article, go to the next article."
7229 (gnus-summary-prev-page lines t))
7231 (defun gnus-summary-scroll-up (lines)
7232 "Scroll up (or down) one line current article.
7233 Argument LINES specifies lines to be scrolled up (or down if negative)."
7235 (gnus-configure-windows 'article)
7236 (gnus-summary-show-thread)
7237 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7238 (gnus-eval-in-buffer-window gnus-article-buffer
7240 (when (gnus-article-next-page lines)
7241 (gnus-message 3 "End of message")))
7243 (gnus-article-prev-page (- lines))))))
7244 (gnus-summary-recenter)
7245 (gnus-summary-position-point))
7247 (defun gnus-summary-scroll-down (lines)
7248 "Scroll down (or up) one line current article.
7249 Argument LINES specifies lines to be scrolled down (or up if negative)."
7251 (gnus-summary-scroll-up (- lines)))
7253 (defun gnus-summary-next-same-subject ()
7254 "Select next article which has the same subject as current one."
7256 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7258 (defun gnus-summary-prev-same-subject ()
7259 "Select previous article which has the same subject as current one."
7261 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7263 (defun gnus-summary-next-unread-same-subject ()
7264 "Select next unread article which has the same subject as current one."
7266 (gnus-summary-next-article t (gnus-summary-article-subject)))
7268 (defun gnus-summary-prev-unread-same-subject ()
7269 "Select previous unread article which has the same subject as current one."
7271 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7273 (defun gnus-summary-first-unread-article ()
7274 "Select the first unread article.
7275 Return nil if there are no unread articles."
7278 (when (gnus-summary-first-subject t)
7279 (gnus-summary-show-thread)
7280 (gnus-summary-first-subject t)
7281 (gnus-summary-display-article (gnus-summary-article-number)))
7282 (gnus-summary-position-point)))
7284 (defun gnus-summary-first-unread-subject ()
7285 "Place the point on the subject line of the first unread article.
7286 Return nil if there are no unread articles."
7289 (when (gnus-summary-first-subject t)
7290 (gnus-summary-show-thread)
7291 (gnus-summary-first-subject t))
7292 (gnus-summary-position-point)))
7294 (defun gnus-summary-first-unseen-subject ()
7295 "Place the point on the subject line of the first unseen article.
7296 Return nil if there are no unseen articles."
7299 (when (gnus-summary-first-subject nil nil t)
7300 (gnus-summary-show-thread)
7301 (gnus-summary-first-subject nil nil t))
7302 (gnus-summary-position-point)))
7304 (defun gnus-summary-first-unseen-or-unread-subject ()
7305 "Place the point on the subject line of the first unseen article or,
7306 if all article have been seen, on the subject line of the first unread
7310 (unless (when (gnus-summary-first-subject nil nil t)
7311 (gnus-summary-show-thread)
7312 (gnus-summary-first-subject nil nil t))
7313 (when (gnus-summary-first-subject t)
7314 (gnus-summary-show-thread)
7315 (gnus-summary-first-subject t)))
7316 (gnus-summary-position-point)))
7318 (defun gnus-summary-first-article ()
7319 "Select the first article.
7320 Return nil if there are no articles."
7323 (when (gnus-summary-first-subject)
7324 (gnus-summary-show-thread)
7325 (gnus-summary-first-subject)
7326 (gnus-summary-display-article (gnus-summary-article-number)))
7327 (gnus-summary-position-point)))
7329 (defun gnus-summary-best-unread-article (&optional arg)
7330 "Select the unread article with the highest score.
7331 If given a prefix argument, select the next unread article that has a
7332 score higher than the default score."
7334 (let ((article (if arg
7335 (gnus-summary-better-unread-subject)
7336 (gnus-summary-best-unread-subject))))
7338 (gnus-summary-goto-article article)
7339 (error "No unread articles"))))
7341 (defun gnus-summary-best-unread-subject ()
7342 "Select the unread subject with the highest score."
7344 (let ((best -1000000)
7345 (data gnus-newsgroup-data)
7348 (and (gnus-data-unread-p (car data))
7350 (gnus-summary-article-score (gnus-data-number (car data))))
7353 article (gnus-data-number (car data))))
7354 (setq data (cdr data)))
7356 (gnus-summary-goto-subject article))
7357 (gnus-summary-position-point)
7360 (defun gnus-summary-better-unread-subject ()
7361 "Select the first unread subject that has a score over the default score."
7363 (let ((data gnus-newsgroup-data)
7365 (while (and (setq article (gnus-data-number (car data)))
7366 (or (gnus-data-read-p (car data))
7367 (not (> (gnus-summary-article-score article)
7368 gnus-summary-default-score))))
7369 (setq data (cdr data)))
7371 (gnus-summary-goto-subject article))
7372 (gnus-summary-position-point)
7375 (defun gnus-summary-last-subject ()
7376 "Go to the last displayed subject line in the group."
7377 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7379 (gnus-summary-goto-subject article))))
7381 (defun gnus-summary-goto-article (article &optional all-headers force)
7382 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7383 If ALL-HEADERS is non-nil, no header lines are hidden.
7384 If FORCE, go to the article even if it isn't displayed. If FORCE
7385 is a number, it is the line the article is to be displayed on."
7389 "Article number or Message-ID: "
7390 (mapcar (lambda (number) (list (int-to-string number)))
7391 gnus-newsgroup-limit))
7395 (if (and (stringp article)
7396 (string-match "@" article))
7397 (gnus-summary-refer-article article)
7398 (when (stringp article)
7399 (setq article (string-to-number article)))
7400 (if (gnus-summary-goto-subject article force)
7401 (gnus-summary-display-article article all-headers)
7402 (gnus-message 4 "Couldn't go to article %s" article) nil))
7403 (gnus-summary-position-point)))
7405 (defun gnus-summary-goto-last-article ()
7406 "Go to the previously read article."
7409 (when gnus-last-article
7410 (gnus-summary-goto-article gnus-last-article nil t))
7411 (gnus-summary-position-point)))
7413 (defun gnus-summary-pop-article (number)
7414 "Pop one article off the history and go to the previous.
7415 NUMBER articles will be popped off."
7418 (setq gnus-newsgroup-history
7419 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7421 (gnus-summary-goto-article (car to) nil t)
7422 (error "Article history empty")))
7423 (gnus-summary-position-point))
7425 ;; Summary commands and functions for limiting the summary buffer.
7427 (defun gnus-summary-limit-to-articles (n)
7428 "Limit the summary buffer to the next N articles.
7429 If not given a prefix, use the process marked articles instead."
7432 (let ((articles (gnus-summary-work-articles n)))
7433 (setq gnus-newsgroup-processable nil)
7434 (gnus-summary-limit articles))
7435 (gnus-summary-position-point)))
7437 (defun gnus-summary-pop-limit (&optional total)
7438 "Restore the previous limit.
7439 If given a prefix, remove all limits."
7442 (setq gnus-newsgroup-limits
7443 (list (mapcar (lambda (h) (mail-header-number h))
7444 gnus-newsgroup-headers))))
7445 (unless gnus-newsgroup-limits
7446 (error "No limit to pop"))
7448 (gnus-summary-limit nil 'pop)
7449 (gnus-summary-position-point)))
7451 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7452 "Limit the summary buffer to articles that have subjects that match a regexp.
7453 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7455 (list (read-string (if current-prefix-arg
7456 "Exclude subject (regexp): "
7457 "Limit to subject (regexp): "))
7458 nil current-prefix-arg))
7460 (setq header "subject"))
7461 (when (not (equal "" subject))
7463 (let ((articles (gnus-summary-find-matching
7464 (or header "subject") subject 'all nil nil
7467 (error "Found no matches for \"%s\"" subject))
7468 (gnus-summary-limit articles))
7469 (gnus-summary-position-point))))
7471 (defun gnus-summary-limit-to-author (from &optional not-matching)
7472 "Limit the summary buffer to articles that have authors that match a regexp.
7473 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7475 (list (read-string (if current-prefix-arg
7476 "Exclude author (regexp): "
7477 "Limit to author (regexp): "))
7478 current-prefix-arg))
7479 (gnus-summary-limit-to-subject from "from" not-matching))
7481 (defun gnus-summary-limit-to-age (age &optional younger-p)
7482 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7483 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7484 articles that are younger than AGE days."
7486 (let ((younger current-prefix-arg)
7489 (while (not days-got)
7490 (setq days (if younger
7491 (read-string "Limit to articles younger than (in days, older when negative): ")
7493 "Limit to articles older than (in days, younger when negative): ")))
7494 (when (> (length days) 0)
7495 (setq days (read days)))
7501 (setq younger (not younger))
7502 (setq days (* days -1)))))
7503 (message "Please enter a number.")
7505 (list days younger)))
7507 (let ((data gnus-newsgroup-data)
7508 (cutoff (days-to-time age))
7509 articles d date is-younger)
7510 (while (setq d (pop data))
7511 (when (and (vectorp (gnus-data-header d))
7512 (setq date (mail-header-date (gnus-data-header d))))
7513 (setq is-younger (time-less-p
7514 (time-since (condition-case ()
7521 (push (gnus-data-number d) articles))))
7522 (gnus-summary-limit (nreverse articles)))
7523 (gnus-summary-position-point)))
7525 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7526 "Limit the summary buffer to articles that match an 'extra' header."
7530 (gnus-completing-read-with-default
7531 (symbol-name (car gnus-extra-headers))
7532 (if current-prefix-arg
7533 "Exclude extra header:"
7534 "Limit extra header:")
7536 (cons (symbol-name x) x))
7541 (read-string (format "%s header %s (regexp): "
7542 (if current-prefix-arg "Exclude" "Limit to")
7544 current-prefix-arg)))
7545 (when (not (equal "" regexp))
7547 (let ((articles (gnus-summary-find-matching
7548 (cons 'extra header) regexp 'all nil nil
7551 (error "Found no matches for \"%s\"" regexp))
7552 (gnus-summary-limit articles))
7553 (gnus-summary-position-point))))
7555 (defun gnus-summary-limit-to-display-predicate ()
7556 "Limit the summary buffer to the predicated in the `display' group parameter."
7558 (unless gnus-newsgroup-display
7559 (error "There is no `display' group parameter"))
7561 (dolist (number gnus-newsgroup-articles)
7562 (when (funcall gnus-newsgroup-display)
7563 (push number articles)))
7564 (gnus-summary-limit articles))
7565 (gnus-summary-position-point))
7567 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7569 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7571 (defun gnus-summary-limit-to-unread (&optional all)
7572 "Limit the summary buffer to articles that are not marked as read.
7573 If ALL is non-nil, limit strictly to unread articles."
7576 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7577 (gnus-summary-limit-to-marks
7578 ;; Concat all the marks that say that an article is read and have
7580 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7581 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7582 gnus-low-score-mark gnus-expirable-mark
7583 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7584 gnus-duplicate-mark gnus-souped-mark)
7587 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7588 (make-obsolete 'gnus-summary-delete-marked-with
7589 'gnus-summary-limit-exclude-marks)
7591 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7592 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7593 If REVERSE, limit the summary buffer to articles that are marked
7594 with MARKS. MARKS can either be a string of marks or a list of marks.
7595 Returns how many articles were removed."
7596 (interactive "sMarks: ")
7597 (gnus-summary-limit-to-marks marks t))
7599 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7600 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7601 If REVERSE (the prefix), limit the summary buffer to articles that are
7602 not marked with MARKS. MARKS can either be a string of marks or a
7604 Returns how many articles were removed."
7605 (interactive "sMarks: \nP")
7607 (let ((data gnus-newsgroup-data)
7608 (marks (if (listp marks) marks
7609 (append marks nil))) ; Transform to list.
7612 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7613 (memq (gnus-data-mark (car data)) marks))
7614 (push (gnus-data-number (car data)) articles))
7615 (setq data (cdr data)))
7616 (gnus-summary-limit articles))
7617 (gnus-summary-position-point)))
7619 (defun gnus-summary-limit-to-score (score)
7620 "Limit to articles with score at or above SCORE."
7621 (interactive "NLimit to articles with score of at least: ")
7622 (let ((data gnus-newsgroup-data)
7625 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7627 (push (gnus-data-number (car data)) articles))
7628 (setq data (cdr data)))
7630 (gnus-summary-limit articles)
7631 (gnus-summary-position-point))))
7633 (defun gnus-summary-limit-to-unseen ()
7634 "Limit to unseen articles."
7637 (gnus-summary-limit gnus-newsgroup-unseen)
7638 (gnus-summary-position-point)))
7640 (defun gnus-summary-limit-include-thread (id)
7641 "Display all the hidden articles that is in the thread with ID in it.
7642 When called interactively, ID is the Message-ID of the current
7644 (interactive (list (mail-header-id (gnus-summary-article-header))))
7645 (let ((articles (gnus-articles-in-thread
7646 (gnus-id-to-thread (gnus-root-id id)))))
7648 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7649 (gnus-summary-limit-include-matching-articles
7651 (regexp-quote (gnus-simplify-subject-re
7652 (mail-header-subject (gnus-id-to-header id)))))
7653 (gnus-summary-position-point))))
7655 (defun gnus-summary-limit-include-matching-articles (header regexp)
7656 "Display all the hidden articles that have HEADERs that match REGEXP."
7657 (interactive (list (read-string "Match on header: ")
7658 (read-string "Regexp: ")))
7659 (let ((articles (gnus-find-matching-articles header regexp)))
7661 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7662 (gnus-summary-position-point))))
7664 (defun gnus-summary-insert-dormant-articles ()
7665 "Insert all the dormat articles for this group into the current buffer."
7667 (let ((gnus-verbose (max 6 gnus-verbose)))
7668 (if (not gnus-newsgroup-dormant)
7669 (gnus-message 3 "No cached articles for this group")
7670 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7672 (defun gnus-summary-limit-include-dormant ()
7673 "Display all the hidden articles that are marked as dormant.
7674 Note that this command only works on a subset of the articles currently
7675 fetched for this group."
7677 (unless gnus-newsgroup-dormant
7678 (error "There are no dormant articles in this group"))
7680 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7681 (gnus-summary-position-point)))
7683 (defun gnus-summary-limit-exclude-dormant ()
7684 "Hide all dormant articles."
7687 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7688 (gnus-summary-position-point)))
7690 (defun gnus-summary-limit-exclude-childless-dormant ()
7691 "Hide all dormant articles that have no children."
7693 (let ((data (gnus-data-list t))
7694 articles d children)
7695 ;; Find all articles that are either not dormant or have
7697 (while (setq d (pop data))
7698 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7700 (gnus-article-children (gnus-data-number d)))
7703 (when (memq (car children) articles)
7708 (push (gnus-data-number d) articles)))
7711 (gnus-summary-limit articles)
7712 (gnus-summary-position-point))))
7714 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7715 "Mark all unread excluded articles as read.
7716 If ALL, mark even excluded ticked and dormants as read."
7718 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7719 (let ((articles (gnus-sorted-ndifference
7721 (mapcar (lambda (h) (mail-header-number h))
7722 gnus-newsgroup-headers)
7724 gnus-newsgroup-limit))
7726 (setq gnus-newsgroup-unreads
7727 (gnus-sorted-intersection gnus-newsgroup-unreads
7728 gnus-newsgroup-limit))
7730 (setq gnus-newsgroup-dormant nil
7731 gnus-newsgroup-marked nil
7732 gnus-newsgroup-reads
7734 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7735 gnus-newsgroup-reads))
7736 (while (setq article (pop articles))
7737 (unless (or (memq article gnus-newsgroup-dormant)
7738 (memq article gnus-newsgroup-marked))
7739 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7741 (defun gnus-summary-limit (articles &optional pop)
7743 ;; We pop the previous limit off the stack and use that.
7744 (setq articles (car gnus-newsgroup-limits)
7745 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7746 ;; We use the new limit, so we push the old limit on the stack.
7747 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7749 (setq gnus-newsgroup-limit articles)
7750 (let ((total (length gnus-newsgroup-data))
7751 (data (gnus-data-find-list (gnus-summary-article-number)))
7752 (gnus-summary-mark-below nil) ; Inhibit this.
7754 ;; This will do all the work of generating the new summary buffer
7755 ;; according to the new limit.
7756 (gnus-summary-prepare)
7757 ;; Hide any threads, possibly.
7758 (gnus-summary-maybe-hide-threads)
7759 ;; Try to return to the article you were at, or one in the
7762 ;; We try to find some article after the current one.
7764 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7767 (setq data (cdr data))))
7769 ;; If there is no data, that means that we were after the last
7770 ;; article. The same goes when we can't find any articles
7771 ;; after the current one.
7772 (goto-char (point-max))
7773 (gnus-summary-find-prev))
7774 (gnus-set-mode-line 'summary)
7775 ;; We return how many articles were removed from the summary
7776 ;; buffer as a result of the new limit.
7777 (- total (length gnus-newsgroup-data))))
7779 (defsubst gnus-invisible-cut-children (threads)
7782 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7787 (defsubst gnus-cut-thread (thread)
7788 "Go forwards in the thread until we find an article that we want to display."
7789 (when (or (eq gnus-fetch-old-headers 'some)
7790 (eq gnus-fetch-old-headers 'invisible)
7791 (numberp gnus-fetch-old-headers)
7792 (eq gnus-build-sparse-threads 'some)
7793 (eq gnus-build-sparse-threads 'more))
7794 ;; Deal with old-fetched headers and sparse threads.
7798 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7799 (gnus-summary-article-ancient-p
7800 (mail-header-number (car thread))))
7801 (if (or (<= (length (cdr thread)) 1)
7802 (eq gnus-fetch-old-headers 'invisible))
7803 (setq gnus-newsgroup-limit
7804 (delq (mail-header-number (car thread))
7805 gnus-newsgroup-limit)
7806 thread (cadr thread))
7807 (when (gnus-invisible-cut-children (cdr thread))
7808 (let ((th (cdr thread)))
7810 (if (memq (mail-header-number (caar th))
7811 gnus-newsgroup-limit)
7812 (setq thread (car th)
7814 (setq th (cdr th))))))))))
7817 (defun gnus-cut-threads (threads)
7818 "Cut off all uninteresting articles from the beginning of threads."
7819 (when (or (eq gnus-fetch-old-headers 'some)
7820 (eq gnus-fetch-old-headers 'invisible)
7821 (numberp gnus-fetch-old-headers)
7822 (eq gnus-build-sparse-threads 'some)
7823 (eq gnus-build-sparse-threads 'more))
7826 (setcar th (gnus-cut-thread (car th)))
7827 (setq th (cdr th)))))
7828 ;; Remove nixed out threads.
7831 (defun gnus-summary-initial-limit (&optional show-if-empty)
7832 "Figure out what the initial limit is supposed to be on group entry.
7833 This entails weeding out unwanted dormants, low-scored articles,
7834 fetch-old-headers verbiage, and so on."
7835 ;; Most groups have nothing to remove.
7836 (if (or gnus-inhibit-limiting
7837 (and (null gnus-newsgroup-dormant)
7838 (eq gnus-newsgroup-display 'gnus-not-ignore)
7839 (not (eq gnus-fetch-old-headers 'some))
7840 (not (numberp gnus-fetch-old-headers))
7841 (not (eq gnus-fetch-old-headers 'invisible))
7842 (null gnus-summary-expunge-below)
7843 (not (eq gnus-build-sparse-threads 'some))
7844 (not (eq gnus-build-sparse-threads 'more))
7845 (null gnus-thread-expunge-below)
7846 (not gnus-use-nocem)))
7848 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7849 (setq gnus-newsgroup-limit nil)
7852 (unless (car (symbol-value node))
7853 ;; These threads have no parents -- they are roots.
7854 (let ((nodes (cdr (symbol-value node)))
7857 (if (and gnus-thread-expunge-below
7858 (< (gnus-thread-total-score (car nodes))
7859 gnus-thread-expunge-below))
7860 (gnus-expunge-thread (pop nodes))
7861 (setq thread (pop nodes))
7862 (gnus-summary-limit-children thread))))))
7863 gnus-newsgroup-dependencies)
7864 ;; If this limitation resulted in an empty group, we might
7865 ;; pop the previous limit and use it instead.
7866 (when (and (not gnus-newsgroup-limit)
7868 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7869 gnus-newsgroup-limit))
7871 (defun gnus-summary-limit-children (thread)
7872 "Return 1 if this subthread is visible and 0 if it is not."
7873 ;; First we get the number of visible children to this thread. This
7874 ;; is done by recursing down the thread using this function, so this
7875 ;; will really go down to a leaf article first, before slowly
7876 ;; working its way up towards the root.
7878 (let* ((max-lisp-eval-depth 5000)
7881 (apply '+ (mapcar 'gnus-summary-limit-children
7884 (number (mail-header-number (car thread)))
7887 (not (memq number gnus-newsgroup-marked))
7889 ;; If this article is dormant and has absolutely no visible
7890 ;; children, then this article isn't visible.
7891 (and (memq number gnus-newsgroup-dormant)
7893 ;; If this is "fetch-old-headered" and there is no
7894 ;; visible children, then we don't want this article.
7895 (and (or (eq gnus-fetch-old-headers 'some)
7896 (numberp gnus-fetch-old-headers))
7897 (gnus-summary-article-ancient-p number)
7899 ;; If this is "fetch-old-headered" and `invisible', then
7900 ;; we don't want this article.
7901 (and (eq gnus-fetch-old-headers 'invisible)
7902 (gnus-summary-article-ancient-p number))
7903 ;; If this is a sparsely inserted article with no children,
7904 ;; we don't want it.
7905 (and (eq gnus-build-sparse-threads 'some)
7906 (gnus-summary-article-sparse-p number)
7908 ;; If we use expunging, and this article is really
7909 ;; low-scored, then we don't want this article.
7910 (when (and gnus-summary-expunge-below
7912 (or (cdr (assq number gnus-newsgroup-scored))
7913 gnus-summary-default-score))
7914 gnus-summary-expunge-below))
7915 ;; We increase the expunge-tally here, but that has
7916 ;; nothing to do with the limits, really.
7917 (incf gnus-newsgroup-expunged-tally)
7918 ;; We also mark as read here, if that's wanted.
7919 (when (and gnus-summary-mark-below
7920 (< score gnus-summary-mark-below))
7921 (setq gnus-newsgroup-unreads
7922 (delq number gnus-newsgroup-unreads))
7923 (if gnus-newsgroup-auto-expire
7924 (push number gnus-newsgroup-expirable)
7925 (push (cons number gnus-low-score-mark)
7926 gnus-newsgroup-reads)))
7928 ;; Do the `display' group parameter.
7929 (and gnus-newsgroup-display
7930 (not (funcall gnus-newsgroup-display)))
7931 ;; Check NoCeM things.
7932 (if (and gnus-use-nocem
7933 (gnus-nocem-unwanted-article-p
7934 (mail-header-id (car thread))))
7936 (setq gnus-newsgroup-unreads
7937 (delq number gnus-newsgroup-unreads))
7939 ;; Nope, invisible article.
7941 ;; Ok, this article is to be visible, so we add it to the limit
7943 (push number gnus-newsgroup-limit)
7946 (defun gnus-expunge-thread (thread)
7947 "Mark all articles in THREAD as read."
7948 (let* ((number (mail-header-number (car thread))))
7949 (incf gnus-newsgroup-expunged-tally)
7950 ;; We also mark as read here, if that's wanted.
7951 (setq gnus-newsgroup-unreads
7952 (delq number gnus-newsgroup-unreads))
7953 (if gnus-newsgroup-auto-expire
7954 (push number gnus-newsgroup-expirable)
7955 (push (cons number gnus-low-score-mark)
7956 gnus-newsgroup-reads)))
7957 ;; Go recursively through all subthreads.
7958 (mapcar 'gnus-expunge-thread (cdr thread)))
7960 ;; Summary article oriented commands
7962 (defun gnus-summary-refer-parent-article (n)
7963 "Refer parent article N times.
7964 If N is negative, go to ancestor -N instead.
7965 The difference between N and the number of articles fetched is returned."
7969 (when (not (natnump n))
7974 (setq header (gnus-summary-article-header))
7975 (if (and (eq (mail-header-number header)
7976 (cdr gnus-article-current))
7977 (equal gnus-newsgroup-name
7978 (car gnus-article-current)))
7979 ;; If we try to find the parent of the currently
7980 ;; displayed article, then we take a look at the actual
7981 ;; References header, since this is slightly more
7982 ;; reliable than the References field we got from the
7985 (set-buffer gnus-original-article-buffer)
7986 (nnheader-narrow-to-headers)
7987 (unless (setq ref (message-fetch-field "references"))
7988 (setq ref (message-fetch-field "in-reply-to")))
7991 ;; It's not the current article, so we take a bet on
7992 ;; the value we got from the server.
7993 (mail-header-references header)))
7995 (not (equal ref "")))
7996 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7997 (gnus-message 1 "Couldn't find parent"))
7998 (gnus-message 1 "No references in article %d"
7999 (gnus-summary-article-number))
8002 (gnus-summary-position-point)
8005 (defun gnus-summary-refer-references ()
8006 "Fetch all articles mentioned in the References header.
8007 Return the number of articles fetched."
8009 (let ((ref (mail-header-references (gnus-summary-article-header)))
8010 (current (gnus-summary-article-number))
8014 (error "No References in the current article")
8015 ;; For each Message-ID in the References header...
8016 (while (string-match "<[^>]*>" ref)
8018 ;; ... fetch that article.
8019 (gnus-summary-refer-article
8020 (prog1 (match-string 0 ref)
8021 (setq ref (substring ref (match-end 0))))))
8022 (gnus-summary-goto-subject current)
8023 (gnus-summary-position-point)
8026 (defun gnus-summary-refer-thread (&optional limit)
8027 "Fetch all articles in the current thread.
8028 If LIMIT (the numerical prefix), fetch that many old headers instead
8029 of what's specified by the `gnus-refer-thread-limit' variable."
8031 (let ((id (mail-header-id (gnus-summary-article-header)))
8032 (limit (if limit (prefix-numeric-value limit)
8033 gnus-refer-thread-limit)))
8034 (unless (eq gnus-fetch-old-headers 'invisible)
8035 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8036 ;; Retrieve the headers and read them in.
8037 (if (eq (if (numberp limit)
8038 (gnus-retrieve-headers
8040 (+ (mail-header-number
8041 (gnus-summary-article-header))
8043 gnus-newsgroup-end))
8044 gnus-newsgroup-name (* limit 2))
8045 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8047 (gnus-retrieve-headers (list gnus-newsgroup-end)
8048 gnus-newsgroup-name limit))
8050 (gnus-build-all-threads)
8051 (error "Can't fetch thread from backends that don't support NOV"))
8052 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8053 (gnus-summary-limit-include-thread id)))
8055 (defun gnus-summary-refer-article (message-id)
8056 "Fetch an article specified by MESSAGE-ID."
8057 (interactive "sMessage-ID: ")
8058 (when (and (stringp message-id)
8059 (not (zerop (length message-id))))
8060 ;; Construct the correct Message-ID if necessary.
8061 ;; Suggested by tale@pawl.rpi.edu.
8062 (unless (string-match "^<" message-id)
8063 (setq message-id (concat "<" message-id)))
8064 (unless (string-match ">$" message-id)
8065 (setq message-id (concat message-id ">")))
8066 (let* ((header (gnus-id-to-header message-id))
8068 (gnus-summary-article-sparse-p
8069 (mail-header-number header))
8070 (memq (mail-header-number header)
8071 gnus-newsgroup-limit)))
8074 ;; If the article is present in the buffer we just go to it.
8076 (or (not (gnus-summary-article-sparse-p
8077 (mail-header-number header)))
8080 (gnus-summary-goto-article
8081 (mail-header-number header) nil t)
8083 (gnus-summary-update-article (mail-header-number header)))))
8085 ;; We fetch the article.
8087 (dolist (gnus-override-method (gnus-refer-article-methods))
8088 (when (and (gnus-check-server gnus-override-method)
8089 ;; Fetch the header,
8090 (setq number (gnus-summary-insert-subject message-id)))
8091 ;; and display the article.
8092 (gnus-summary-select-article nil nil nil number)
8094 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8096 (defun gnus-refer-article-methods ()
8097 "Return a list of referable methods."
8099 ;; No method, so we default to current and native.
8100 ((null gnus-refer-article-method)
8101 (list gnus-current-select-method gnus-select-method))
8103 ((eq 'current gnus-refer-article-method)
8104 (list gnus-current-select-method))
8105 ;; List of select methods.
8106 ((not (and (symbolp (car gnus-refer-article-method))
8107 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8109 (dolist (method gnus-refer-article-method)
8110 (push (if (eq 'current method)
8111 gnus-current-select-method
8115 ;; One single select method.
8117 (list gnus-refer-article-method))))
8119 (defun gnus-summary-edit-parameters ()
8120 "Edit the group parameters of the current group."
8122 (gnus-group-edit-group gnus-newsgroup-name 'params))
8124 (defun gnus-summary-customize-parameters ()
8125 "Customize the group parameters of the current group."
8127 (gnus-group-customize gnus-newsgroup-name))
8129 (defun gnus-summary-enter-digest-group (&optional force)
8130 "Enter an nndoc group based on the current article.
8131 If FORCE, force a digest interpretation. If not, try
8132 to guess what the document format is."
8134 (let ((conf gnus-current-window-configuration))
8136 (gnus-summary-select-article))
8137 (setq gnus-current-window-configuration conf)
8138 (let* ((name (format "%s-%d"
8139 (gnus-group-prefixed-name
8140 gnus-newsgroup-name (list 'nndoc ""))
8142 (set-buffer gnus-summary-buffer)
8143 gnus-current-article)))
8144 (ogroup gnus-newsgroup-name)
8145 (params (append (gnus-info-params (gnus-get-info ogroup))
8146 (list (cons 'to-group ogroup))
8147 (list (cons 'save-article-group ogroup))))
8148 (case-fold-search t)
8149 (buf (current-buffer))
8152 (set-buffer gnus-original-article-buffer)
8153 ;; Have the digest group inherit the main mail address of
8154 ;; the parent article.
8155 (when (setq to-address (or (gnus-fetch-field "reply-to")
8156 (gnus-fetch-field "from")))
8157 (setq params (append
8158 (list (cons 'to-address
8159 (funcall gnus-decode-encoded-word-function
8161 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8162 (insert-buffer-substring gnus-original-article-buffer)
8163 ;; Remove lines that may lead nndoc to misinterpret the
8166 (goto-char (point-min))
8167 (or (search-forward "\n\n" nil t) (point)))
8168 (goto-char (point-min))
8169 (delete-matching-lines "^Path:\\|^From ")
8172 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8173 (gnus-newsgroup-ephemeral-ignored-charsets
8174 gnus-newsgroup-ignored-charsets))
8175 (gnus-group-read-ephemeral-group
8176 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8178 ,(if force 'mbox 'guess)))
8180 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8182 ;; Make all postings to this group go to the parent group.
8183 (nconc (gnus-info-params (gnus-get-info name))
8185 ;; Couldn't select this doc group.
8186 (switch-to-buffer buf)
8187 (gnus-set-global-variables)
8188 (gnus-configure-windows 'summary)
8189 (gnus-message 3 "Article couldn't be entered?"))
8190 (kill-buffer dig)))))
8192 (defun gnus-summary-read-document (n)
8193 "Open a new group based on the current article(s).
8194 This will allow you to read digests and other similar
8195 documents as newsgroups.
8196 Obeys the standard process/prefix convention."
8198 (let* ((articles (gnus-summary-work-articles n))
8199 (ogroup gnus-newsgroup-name)
8200 (params (append (gnus-info-params (gnus-get-info ogroup))
8201 (list (cons 'to-group ogroup))))
8202 article group egroup groups vgroup)
8203 (while (setq article (pop articles))
8204 (setq group (format "%s-%d" gnus-newsgroup-name article))
8205 (gnus-summary-remove-process-mark article)
8206 (when (gnus-summary-display-article article)
8209 (insert-buffer-substring gnus-original-article-buffer)
8210 ;; Remove some headers that may lead nndoc to make
8212 (message-narrow-to-head)
8213 (goto-char (point-min))
8214 (delete-matching-lines "^\\(Path\\):\\|^From ")
8217 (gnus-group-read-ephemeral-group
8218 group `(nndoc ,group (nndoc-address ,(current-buffer))
8219 (nndoc-article-type guess))
8222 ;; Make all postings to this group go to the parent group.
8223 (nconc (gnus-info-params (gnus-get-info egroup))
8225 (push egroup groups))
8226 ;; Couldn't select this doc group.
8227 (gnus-error 3 "Article couldn't be entered"))))))
8228 ;; Now we have selected all the documents.
8231 (error "None of the articles could be interpreted as documents"))
8232 ((gnus-group-read-ephemeral-group
8233 (setq vgroup (format
8234 "nnvirtual:%s-%s" gnus-newsgroup-name
8235 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8236 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8238 (cons (current-buffer) 'summary)))
8240 (error "Couldn't select virtual nndoc group")))))
8242 (defun gnus-summary-isearch-article (&optional regexp-p)
8243 "Do incremental search forward on the current article.
8244 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8246 (gnus-summary-select-article)
8247 (gnus-configure-windows 'article)
8248 (gnus-eval-in-buffer-window gnus-article-buffer
8251 (isearch-forward regexp-p))))
8253 (defun gnus-summary-search-article-forward (regexp &optional backward)
8254 "Search for an article containing REGEXP forward.
8255 If BACKWARD, search backward instead."
8258 (format "Search article %s (regexp%s): "
8259 (if current-prefix-arg "backward" "forward")
8260 (if gnus-last-search-regexp
8261 (concat ", default " gnus-last-search-regexp)
8263 current-prefix-arg))
8264 (if (string-equal regexp "")
8265 (setq regexp (or gnus-last-search-regexp ""))
8266 (setq gnus-last-search-regexp regexp)
8267 (setq gnus-article-before-search gnus-current-article))
8268 ;; Intentionally set gnus-last-article.
8269 (setq gnus-last-article gnus-article-before-search)
8270 (let ((gnus-last-article gnus-last-article))
8271 (if (gnus-summary-search-article regexp backward)
8272 (gnus-summary-show-thread)
8273 (error "Search failed: \"%s\"" regexp))))
8275 (defun gnus-summary-search-article-backward (regexp)
8276 "Search for an article containing REGEXP backward."
8279 (format "Search article backward (regexp%s): "
8280 (if gnus-last-search-regexp
8281 (concat ", default " gnus-last-search-regexp)
8283 (gnus-summary-search-article-forward regexp 'backward))
8285 (defun gnus-summary-search-article (regexp &optional backward)
8286 "Search for an article containing REGEXP.
8287 Optional argument BACKWARD means do search for backward.
8288 `gnus-select-article-hook' is not called during the search."
8289 ;; We have to require this here to make sure that the following
8290 ;; dynamic binding isn't shadowed by autoloading.
8291 (require 'gnus-async)
8293 (let ((gnus-select-article-hook nil) ;Disable hook.
8294 (gnus-article-prepare-hook nil)
8295 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8296 (gnus-use-article-prefetch nil)
8297 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8298 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8300 (gnus-keep-backlog nil)
8301 (gnus-break-pages nil)
8302 (gnus-summary-display-arrow nil)
8303 (gnus-updated-mode-lines nil)
8304 (gnus-auto-center-summary nil)
8305 (sum (current-buffer))
8306 (gnus-display-mime-function nil)
8309 (gnus-save-hidden-threads
8310 (gnus-summary-select-article)
8311 (set-buffer gnus-article-buffer)
8312 (goto-char (window-point (get-buffer-window (current-buffer))))
8316 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8318 (re-search-backward regexp nil t)
8319 (re-search-forward regexp nil t))
8320 ;; We found the regexp.
8325 (get-buffer-window (current-buffer))
8329 (get-buffer-window (current-buffer))
8332 (setq point (point)))
8333 ;; We didn't find it, so we go to the next article.
8336 (while (eq found 'not)
8337 (if (not (if backward (gnus-summary-find-prev)
8338 (gnus-summary-find-next)))
8339 ;; No more articles.
8341 ;; Select the next article and adjust point.
8342 (unless (gnus-summary-article-sparse-p
8343 (gnus-summary-article-number))
8345 (gnus-summary-select-article)
8346 (set-buffer gnus-article-buffer)
8348 (goto-char (if backward (point-max) (point-min))))))))
8349 (gnus-message 7 ""))
8350 ;; Return whether we found the regexp.
8351 (when (eq found 'found)
8353 (gnus-summary-show-thread)
8354 (gnus-summary-goto-subject gnus-current-article)
8355 (gnus-summary-position-point)
8358 (defun gnus-find-matching-articles (header regexp)
8359 "Return a list of all articles that match REGEXP on HEADER.
8360 This search includes all articles in the current group that Gnus has
8361 fetched headers for, whether they are displayed or not."
8362 (let ((articles nil)
8363 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8364 (case-fold-search t))
8365 (dolist (header gnus-newsgroup-headers)
8366 (when (string-match regexp (funcall func header))
8367 (push (mail-header-number header) articles)))
8368 (nreverse articles)))
8370 (defun gnus-summary-find-matching (header regexp &optional backward unread
8371 not-case-fold not-matching)
8372 "Return a list of all articles that match REGEXP on HEADER.
8373 The search stars on the current article and goes forwards unless
8374 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8375 If UNREAD is non-nil, only unread articles will
8376 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8377 in the comparisons. If NOT-MATCHING, return a list of all articles that
8378 not match REGEXP on HEADER."
8379 (let ((case-fold-search (not not-case-fold))
8382 (if (eq (car header) 'extra)
8385 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8387 (error "%s is an invalid header" header))
8388 (unless (fboundp (intern (concat "mail-header-" header)))
8389 (error "%s is not a valid header" header))
8390 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8391 (dolist (d (if (eq backward 'all)
8393 (gnus-data-find-list
8394 (gnus-summary-article-number)
8395 (gnus-data-list backward))))
8396 (when (and (or (not unread) ; We want all articles...
8397 (gnus-data-unread-p d)) ; Or just unreads.
8398 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8402 (funcall func (gnus-data-header d))))
8403 (string-match regexp
8404 (funcall func (gnus-data-header d)))))
8405 (push (gnus-data-number d) articles))) ; Success!
8406 (nreverse articles)))
8408 (defun gnus-summary-execute-command (header regexp command &optional backward)
8409 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8410 If HEADER is an empty string (or nil), the match is done on the entire
8411 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8413 (list (let ((completion-ignore-case t))
8416 (mapcar (lambda (header) (list (format "%s" header)))
8418 '("Number" "Subject" "From" "Lines" "Date"
8419 "Message-ID" "Xref" "References" "Body")
8420 gnus-extra-headers))
8421 nil 'require-match))
8422 (read-string "Regexp: ")
8423 (read-key-sequence "Command: ")
8424 current-prefix-arg))
8425 (when (equal header "Body")
8427 ;; Hidden thread subtrees must be searched as well.
8428 (gnus-summary-show-all-threads)
8429 ;; We don't want to change current point nor window configuration.
8431 (save-window-excursion
8433 gnus-treat-strip-trailing-blank-lines
8434 gnus-treat-strip-leading-blank-lines
8435 gnus-treat-strip-multiple-blank-lines
8436 gnus-treat-hide-boring-headers
8437 gnus-treat-fold-newsgroups
8438 gnus-article-prepare-hook)
8439 (gnus-message 6 "Executing %s..." (key-description command))
8440 ;; We'd like to execute COMMAND interactively so as to give arguments.
8441 (gnus-execute header regexp
8442 `(call-interactively ',(key-binding command))
8444 (gnus-message 6 "Executing %s...done" (key-description command))))))
8446 (defun gnus-summary-beginning-of-article ()
8447 "Scroll the article back to the beginning."
8449 (gnus-summary-select-article)
8450 (gnus-configure-windows 'article)
8451 (gnus-eval-in-buffer-window gnus-article-buffer
8453 (goto-char (point-min))
8454 (when gnus-page-broken
8455 (gnus-narrow-to-page))))
8457 (defun gnus-summary-end-of-article ()
8458 "Scroll to the end of the article."
8460 (gnus-summary-select-article)
8461 (gnus-configure-windows 'article)
8462 (gnus-eval-in-buffer-window gnus-article-buffer
8464 (goto-char (point-max))
8466 (when gnus-page-broken
8467 (gnus-narrow-to-page))))
8469 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8470 "Truncate to LEN and quote all \"(\"'s in STRING."
8471 (gnus-replace-in-string (if (and len (> (length string) len))
8472 (substring string 0 len)
8476 (defun gnus-summary-print-article (&optional filename n)
8477 "Generate and print a PostScript image of the N next (mail) articles.
8479 If N is negative, print the N previous articles. If N is nil and articles
8480 have been marked with the process mark, print these instead.
8482 If the optional first argument FILENAME is nil, send the image to the
8483 printer. If FILENAME is a string, save the PostScript image in a file with
8484 that name. If FILENAME is a number, prompt the user for the name of the file
8486 (interactive (list (ps-print-preprint current-prefix-arg)))
8487 (dolist (article (gnus-summary-work-articles n))
8488 (gnus-summary-select-article nil nil 'pseudo article)
8489 (gnus-eval-in-buffer-window gnus-article-buffer
8490 (gnus-print-buffer))
8491 (gnus-summary-remove-process-mark article))
8492 (ps-despool filename))
8494 (defun gnus-print-buffer ()
8495 (let ((buffer (generate-new-buffer " *print*")))
8498 (copy-to-buffer buffer (point-min) (point-max))
8500 (gnus-article-delete-invisible-text)
8501 (gnus-remove-text-with-property 'gnus-decoration)
8502 (when (gnus-visual-p 'article-highlight 'highlight)
8503 ;; Copy-to-buffer doesn't copy overlay. So redo
8505 (let ((gnus-article-buffer buffer))
8506 (gnus-article-highlight-citation t)
8507 (gnus-article-highlight-signature)))
8508 (let ((ps-left-header
8511 (gnus-summary-print-truncate-and-quote
8512 (mail-header-subject gnus-current-headers)
8515 (gnus-summary-print-truncate-and-quote
8516 (mail-header-from gnus-current-headers)
8520 "/pagenumberstring load"
8522 (mail-header-date gnus-current-headers) ")"))))
8523 (gnus-run-hooks 'gnus-ps-print-hook)
8526 (ps-spool-buffer-with-faces)
8527 (ps-spool-buffer)))))
8528 (kill-buffer buffer))))
8530 (defun gnus-summary-show-article (&optional arg)
8531 "Force redisplaying of the current article.
8532 If ARG (the prefix) is a number, show the article with the charset
8533 defined in `gnus-summary-show-article-charset-alist', or the charset
8535 If ARG (the prefix) is non-nil and not a number, show the raw article
8536 without any article massaging functions being run. Normally, the key strokes
8541 (gnus-summary-show-article t)
8542 (let ((gnus-newsgroup-charset
8543 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8544 (mm-read-coding-system
8545 "View as charset: " ;; actually it is coding system.
8547 (set-buffer gnus-article-buffer)
8548 (mm-detect-coding-region (point) (point-max))))))
8549 (gnus-newsgroup-ignored-charsets 'gnus-all))
8550 (gnus-summary-select-article nil 'force)
8551 (let ((deps gnus-newsgroup-dependencies)
8554 (set-buffer gnus-original-article-buffer)
8556 (message-narrow-to-head)
8557 (setq head (buffer-string))
8558 (goto-char (point-min))
8559 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8560 (goto-char (point-max))
8562 (setq lines (1- (count-lines (point) (point-max))))))
8564 (insert (format "211 %d Article retrieved.\n"
8565 (cdr gnus-article-current)))
8567 (if lines (insert (format "Lines: %d\n" lines)))
8569 (let ((nntp-server-buffer (current-buffer)))
8570 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8571 (gnus-data-set-header
8572 (gnus-data-find (cdr gnus-article-current))
8574 (gnus-summary-update-article-line
8575 (cdr gnus-article-current) header)
8576 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8577 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8579 ;; Select the article the normal way.
8580 (gnus-summary-select-article nil 'force))
8582 ;; We have to require this here to make sure that the following
8583 ;; dynamic binding isn't shadowed by autoloading.
8584 (require 'gnus-async)
8586 ;; Bind the article treatment functions to nil.
8587 (let ((gnus-have-all-headers t)
8588 gnus-article-prepare-hook
8589 gnus-article-decode-hook
8590 gnus-display-mime-function
8592 ;; Destroy any MIME parts.
8593 (when (gnus-buffer-live-p gnus-article-buffer)
8595 (set-buffer gnus-article-buffer)
8596 (mm-destroy-parts gnus-article-mime-handles)
8597 ;; Set it to nil for safety reason.
8598 (setq gnus-article-mime-handle-alist nil)
8599 (setq gnus-article-mime-handles nil)))
8600 (gnus-summary-select-article nil 'force))))
8601 (gnus-summary-goto-subject gnus-current-article)
8602 (gnus-summary-position-point))
8604 (defun gnus-summary-show-raw-article ()
8605 "Show the raw article without any article massaging functions being run."
8607 (gnus-summary-show-article t))
8609 (defun gnus-summary-verbose-headers (&optional arg)
8610 "Toggle permanent full header display.
8611 If ARG is a positive number, turn header display on.
8612 If ARG is a negative number, turn header display off."
8614 (setq gnus-show-all-headers
8615 (cond ((or (not (numberp arg))
8617 (not gnus-show-all-headers))
8620 (gnus-summary-show-article))
8622 (defun gnus-summary-toggle-header (&optional arg)
8623 "Show the headers if they are hidden, or hide them if they are shown.
8624 If ARG is a positive number, show the entire header.
8625 If ARG is a negative number, hide the unwanted header lines."
8627 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8628 (get-buffer-window gnus-article-buffer t))))
8629 (with-current-buffer gnus-article-buffer
8631 (article-narrow-to-head)
8632 (let* ((buffer-read-only nil)
8633 (inhibit-point-motion-hooks t)
8634 (hidden (if (numberp arg)
8636 (gnus-article-hidden-text-p 'headers)))
8638 (delete-region (point-min) (point-max))
8639 (with-current-buffer gnus-original-article-buffer
8640 (goto-char (setq s (point-min)))
8641 (setq e (if (search-forward "\n\n" nil t)
8644 (insert-buffer-substring gnus-original-article-buffer s e)
8645 (run-hooks 'gnus-article-decode-hook)
8647 (let ((gnus-treat-hide-headers nil)
8648 (gnus-treat-hide-boring-headers nil))
8649 (gnus-delete-wash-type 'headers)
8650 (gnus-treat-article 'head))
8651 (gnus-treat-article 'head))
8654 (set-window-start window (goto-char (point-min))))
8655 (setq gnus-page-broken
8656 (when gnus-break-pages
8657 (gnus-narrow-to-page)
8659 (gnus-set-mode-line 'article)))))
8661 (defun gnus-summary-show-all-headers ()
8662 "Make all header lines visible."
8664 (gnus-summary-toggle-header 1))
8666 (defun gnus-summary-caesar-message (&optional arg)
8667 "Caesar rotate the current article by 13.
8668 The numerical prefix specifies how many places to rotate each letter
8671 (gnus-summary-select-article)
8672 (let ((mail-header-separator ""))
8673 (gnus-eval-in-buffer-window gnus-article-buffer
8676 (let ((start (window-start))
8678 (message-caesar-buffer-body arg)
8679 (set-window-start (get-buffer-window (current-buffer)) start))))))
8681 (autoload 'unmorse-region "morse"
8682 "Convert morse coded text in region to ordinary ASCII text."
8685 (defun gnus-summary-morse-message (&optional arg)
8686 "Morse decode the current article."
8688 (gnus-summary-select-article)
8689 (let ((mail-header-separator ""))
8690 (gnus-eval-in-buffer-window gnus-article-buffer
8694 (let ((pos (window-start))
8696 (goto-char (point-min))
8697 (when (message-goto-body)
8698 (gnus-narrow-to-body))
8699 (goto-char (point-min))
8700 (while (re-search-forward "·" (point-max) t)
8701 (replace-match "."))
8702 (unmorse-region (point-min) (point-max))
8704 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8706 (defun gnus-summary-stop-page-breaking ()
8707 "Stop page breaking in the current article."
8709 (gnus-summary-select-article)
8710 (gnus-eval-in-buffer-window gnus-article-buffer
8712 (when (gnus-visual-p 'page-marker)
8713 (let ((buffer-read-only nil))
8714 (gnus-remove-text-with-property 'gnus-prev)
8715 (gnus-remove-text-with-property 'gnus-next))
8716 (setq gnus-page-broken nil))))
8718 (defun gnus-summary-move-article (&optional n to-newsgroup
8719 select-method action)
8720 "Move the current article to a different newsgroup.
8721 If N is a positive number, move the N next articles.
8722 If N is a negative number, move the N previous articles.
8723 If N is nil and any articles have been marked with the process mark,
8724 move those articles instead.
8725 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8726 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8727 re-spool using this method.
8729 When called interactively with TO-NEWSGROUP being nil, the value of
8730 the variable `gnus-move-split-methods' is used for finding a default
8731 for the target newsgroup.
8733 For this function to work, both the current newsgroup and the
8734 newsgroup that you want to move to have to support the `request-move'
8735 and `request-accept' functions.
8737 ACTION can be either `move' (the default), `crosspost' or `copy'."
8740 (setq action 'move))
8741 ;; Check whether the source group supports the required functions.
8742 (cond ((and (eq action 'move)
8743 (not (gnus-check-backend-function
8744 'request-move-article gnus-newsgroup-name)))
8745 (error "The current group does not support article moving"))
8746 ((and (eq action 'crosspost)
8747 (not (gnus-check-backend-function
8748 'request-replace-article gnus-newsgroup-name)))
8749 (error "The current group does not support article editing")))
8750 (let ((articles (gnus-summary-work-articles n))
8751 (prefix (if (gnus-check-backend-function
8752 'request-move-article gnus-newsgroup-name)
8753 (gnus-group-real-prefix gnus-newsgroup-name)
8755 (names '((move "Move" "Moving")
8756 (copy "Copy" "Copying")
8757 (crosspost "Crosspost" "Crossposting")))
8758 (copy-buf (save-excursion
8759 (nnheader-set-temp-buffer " *copy article*")))
8760 art-group to-method new-xref article to-groups)
8761 (unless (assq action names)
8762 (error "Unknown action %s" action))
8763 ;; Read the newsgroup name.
8764 (when (and (not to-newsgroup)
8765 (not select-method))
8766 (if (and gnus-move-split-methods
8768 (and (memq gnus-current-article articles)
8769 (gnus-buffer-live-p gnus-original-article-buffer))))
8770 ;; When `gnus-move-split-methods' is non-nil, we have to
8771 ;; select an article to give `gnus-read-move-group-name' an
8772 ;; opportunity to suggest an appropriate default. However,
8773 ;; we needn't render or mark the article.
8774 (let ((gnus-display-mime-function nil)
8775 (gnus-article-prepare-hook nil)
8776 (gnus-mark-article-hook nil))
8777 (gnus-summary-select-article nil nil nil (car articles))))
8779 (gnus-read-move-group-name
8780 (cadr (assq action names))
8781 (symbol-value (intern (format "gnus-current-%s-group" action)))
8783 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8784 (setq to-method (or select-method
8785 (gnus-server-to-method
8786 (gnus-group-method to-newsgroup))))
8787 ;; Check the method we are to move this article to...
8788 (unless (gnus-check-backend-function
8789 'request-accept-article (car to-method))
8790 (error "%s does not support article copying" (car to-method)))
8791 (unless (gnus-check-server to-method)
8792 (error "Can't open server %s" (car to-method)))
8793 (gnus-message 6 "%s to %s: %s..."
8794 (caddr (assq action names))
8795 (or (car select-method) to-newsgroup) articles)
8797 (setq article (pop articles))
8801 ;; Move the article.
8803 ;; Remove this article from future suppression.
8804 (gnus-dup-unsuppress-article article)
8805 (gnus-request-move-article
8806 article ; Article to move
8807 gnus-newsgroup-name ; From newsgroup
8808 (nth 1 (gnus-find-method-for-group
8809 gnus-newsgroup-name)) ; Server
8810 (list 'gnus-request-accept-article
8811 to-newsgroup (list 'quote select-method)
8812 (not articles) t) ; Accept form
8813 (not articles))) ; Only save nov last time
8814 ;; Copy the article.
8817 (set-buffer copy-buf)
8818 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8819 (gnus-request-accept-article
8820 to-newsgroup select-method (not articles) t))))
8821 ;; Crosspost the article.
8822 ((eq action 'crosspost)
8823 (let ((xref (message-tokenize-header
8824 (mail-header-xref (gnus-summary-article-header article))
8826 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8827 ":" (number-to-string article)))
8829 (setq xref (list (system-name))))
8832 (mapconcat 'identity
8833 (delete "Xref:" (delete new-xref xref))
8837 (set-buffer copy-buf)
8838 ;; First put the article in the destination group.
8839 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8840 (when (consp (setq art-group
8841 (gnus-request-accept-article
8842 to-newsgroup select-method (not articles))))
8843 (setq new-xref (concat new-xref " " (car art-group)
8845 (number-to-string (cdr art-group))))
8846 ;; Now we have the new Xrefs header, so we insert
8847 ;; it and replace the new article.
8848 (nnheader-replace-header "Xref" new-xref)
8849 (gnus-request-replace-article
8850 (cdr art-group) to-newsgroup (current-buffer))
8854 (gnus-message 1 "Couldn't %s article %s: %s"
8855 (cadr (assq action names)) article
8856 (nnheader-get-report (car to-method))))
8857 ((eq art-group 'junk)
8858 (when (eq action 'move)
8859 (gnus-summary-mark-article article gnus-canceled-mark)
8860 (gnus-message 4 "Deleted article %s" article)
8861 ;; run the delete hook
8862 (run-hook-with-args 'gnus-summary-article-delete-hook
8865 (assoc article (gnus-data-list nil)))
8866 gnus-newsgroup-name nil
8869 (let* ((pto-group (gnus-group-prefixed-name
8870 (car art-group) to-method))
8872 (gnus-gethash pto-group gnus-newsrc-hashtb))
8873 (info (nth 2 entry))
8874 (to-group (gnus-info-group info))
8876 ;; Update the group that has been moved to.
8878 (memq action '(move copy)))
8879 (unless (member to-group to-groups)
8880 (push to-group to-groups))
8882 (unless (memq article gnus-newsgroup-unreads)
8883 (push 'read to-marks)
8885 info (gnus-add-to-range (gnus-info-read info)
8886 (list (cdr art-group)))))
8888 ;; See whether the article is to be put in the cache.
8889 (let ((marks gnus-article-mark-lists)
8890 (to-article (cdr art-group)))
8892 ;; Enter the article into the cache in the new group,
8893 ;; if that is required.
8894 (when gnus-use-cache
8895 (gnus-cache-possibly-enter-article
8897 (memq article gnus-newsgroup-marked)
8898 (memq article gnus-newsgroup-dormant)
8899 (memq article gnus-newsgroup-unreads)))
8901 (when gnus-preserve-marks
8902 ;; Copy any marks over to the new group.
8903 (when (and (equal to-group gnus-newsgroup-name)
8904 (not (memq article gnus-newsgroup-unreads)))
8905 ;; Mark this article as read in this group.
8906 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8907 (setcdr (gnus-active to-group) to-article)
8908 (setcdr gnus-newsgroup-active to-article))
8911 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8912 (when (memq article (symbol-value
8913 (intern (format "gnus-newsgroup-%s"
8915 (push (cdar marks) to-marks)
8916 ;; If the other group is the same as this group,
8917 ;; then we have to add the mark to the list.
8918 (when (equal to-group gnus-newsgroup-name)
8919 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8922 (intern (format "gnus-newsgroup-%s"
8924 ;; Copy the marks to other group.
8925 (gnus-add-marked-articles
8926 to-group (cdar marks) (list to-article) info)))
8927 (setq marks (cdr marks)))
8929 (gnus-request-set-mark
8930 to-group (list (list (list to-article) 'add to-marks))))
8933 (concat "(gnus-group-set-info '"
8934 (gnus-prin1-to-string (gnus-get-info to-group))
8937 ;; Update the Xref header in this article to point to
8938 ;; the new crossposted article we have just created.
8939 (when (eq action 'crosspost)
8941 (set-buffer copy-buf)
8942 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8943 (nnheader-replace-header "Xref" new-xref)
8944 (gnus-request-replace-article
8945 article gnus-newsgroup-name (current-buffer))))
8947 ;; run the move/copy/crosspost/respool hook
8948 (run-hook-with-args 'gnus-summary-article-move-hook
8951 (assoc article (gnus-data-list nil)))
8956 ;;;!!!Why is this necessary?
8957 (set-buffer gnus-summary-buffer)
8959 (gnus-summary-goto-subject article)
8960 (when (eq action 'move)
8961 (gnus-summary-mark-article article gnus-canceled-mark))))
8962 (gnus-summary-remove-process-mark article))
8963 ;; Re-activate all groups that have been moved to.
8965 (set-buffer gnus-group-buffer)
8966 (let ((gnus-group-marked to-groups))
8967 (gnus-group-get-new-news-this-group nil t)))
8969 (gnus-kill-buffer copy-buf)
8970 (gnus-summary-position-point)
8971 (gnus-set-mode-line 'summary)))
8973 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8974 "Move the current article to a different newsgroup.
8975 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8976 When called interactively, if TO-NEWSGROUP is nil, use the value of
8977 the variable `gnus-move-split-methods' for finding a default target
8979 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8980 re-spool using this method."
8982 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8984 (defun gnus-summary-crosspost-article (&optional n)
8985 "Crosspost the current article to some other group."
8987 (gnus-summary-move-article n nil nil 'crosspost))
8989 (defcustom gnus-summary-respool-default-method nil
8990 "Default method type for respooling an article.
8991 If nil, use to the current newsgroup method."
8993 :group 'gnus-summary-mail)
8995 (defcustom gnus-summary-display-while-building nil
8996 "If not-nil, show and update the summary buffer as it's being built.
8997 If the value is t, update the buffer after every line is inserted. If
8998 the value is an integer (N), update the display every N lines."
9000 :type '(choice (const :tag "off" nil)
9002 (const :tag "frequently" t)))
9004 (defun gnus-summary-respool-article (&optional n method)
9005 "Respool the current article.
9006 The article will be squeezed through the mail spooling process again,
9007 which means that it will be put in some mail newsgroup or other
9008 depending on `nnmail-split-methods'.
9009 If N is a positive number, respool the N next articles.
9010 If N is a negative number, respool the N previous articles.
9011 If N is nil and any articles have been marked with the process mark,
9012 respool those articles instead.
9014 Respooling can be done both from mail groups and \"real\" newsgroups.
9015 In the former case, the articles in question will be moved from the
9016 current group into whatever groups they are destined to. In the
9017 latter case, they will be copied into the relevant groups."
9019 (list current-prefix-arg
9020 (let* ((methods (gnus-methods-using 'respool))
9022 (symbol-name (or gnus-summary-respool-default-method
9023 (car (gnus-find-method-for-group
9024 gnus-newsgroup-name)))))
9026 (gnus-completing-read-with-default
9027 methname "What backend do you want to use when respooling?"
9028 methods nil t nil 'gnus-mail-method-history))
9031 ((zerop (length (setq ms (gnus-servers-using-backend
9033 (list (intern method) ""))
9037 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9038 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9041 (error "No method given for respooling"))
9042 (if (assoc (symbol-name
9043 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9044 (gnus-methods-using 'respool))
9045 (gnus-summary-move-article n nil method)
9046 (gnus-summary-copy-article n nil method)))
9048 (defun gnus-summary-import-article (file &optional edit)
9049 "Import an arbitrary file into a mail newsgroup."
9050 (interactive "fImport file: \nP")
9051 (let ((group gnus-newsgroup-name)
9052 (now (current-time))
9053 atts lines group-art)
9054 (unless (gnus-check-backend-function 'request-accept-article group)
9055 (error "%s does not support article importing" group))
9056 (or (file-readable-p file)
9057 (not (file-regular-p file))
9058 (error "Can't read %s" file))
9060 (set-buffer (gnus-get-buffer-create " *import file*"))
9062 (nnheader-insert-file-contents file)
9063 (goto-char (point-min))
9064 (if (nnheader-article-p)
9066 (goto-char (point-min))
9067 (search-forward "\n\n" nil t)
9068 (narrow-to-region (point-min) (1- (point)))
9069 (goto-char (point-min))
9070 (unless (re-search-forward "^date:" nil t)
9071 (goto-char (point-max))
9072 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9073 ;; This doesn't look like an article, so we fudge some headers.
9074 (setq atts (file-attributes file)
9075 lines (count-lines (point-min) (point-max)))
9076 (insert "From: " (read-string "From: ") "\n"
9077 "Subject: " (read-string "Subject: ") "\n"
9078 "Date: " (message-make-date (nth 5 atts)) "\n"
9079 "Message-ID: " (message-make-message-id) "\n"
9080 "Lines: " (int-to-string lines) "\n"
9081 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9082 (setq group-art (gnus-request-accept-article group nil t))
9083 (kill-buffer (current-buffer)))
9084 (setq gnus-newsgroup-active (gnus-activate-group group))
9086 (gnus-summary-goto-article (cdr group-art) nil t)
9088 (gnus-summary-edit-article))))
9090 (defun gnus-summary-create-article ()
9091 "Create an article in a mail newsgroup."
9093 (let ((group gnus-newsgroup-name)
9094 (now (current-time))
9096 (unless (gnus-check-backend-function 'request-accept-article group)
9097 (error "%s does not support article importing" group))
9099 (set-buffer (gnus-get-buffer-create " *import file*"))
9101 (goto-char (point-min))
9102 ;; This doesn't look like an article, so we fudge some headers.
9103 (insert "From: " (read-string "From: ") "\n"
9104 "Subject: " (read-string "Subject: ") "\n"
9105 "Date: " (message-make-date now) "\n"
9106 "Message-ID: " (message-make-message-id) "\n")
9107 (setq group-art (gnus-request-accept-article group nil t))
9108 (kill-buffer (current-buffer)))
9109 (setq gnus-newsgroup-active (gnus-activate-group group))
9111 (gnus-summary-goto-article (cdr group-art) nil t)
9112 (gnus-summary-edit-article)))
9114 (defun gnus-summary-article-posted-p ()
9115 "Say whether the current (mail) article is available from news as well.
9116 This will be the case if the article has both been mailed and posted."
9118 (let ((id (mail-header-references (gnus-summary-article-header)))
9119 (gnus-override-method (car (gnus-refer-article-methods))))
9120 (if (gnus-request-head id "")
9121 (gnus-message 2 "The current message was found on %s"
9122 gnus-override-method)
9123 (gnus-message 2 "The current message couldn't be found on %s"
9124 gnus-override-method)
9127 (defun gnus-summary-expire-articles (&optional now)
9128 "Expire all articles that are marked as expirable in the current group."
9130 (when (and (not gnus-group-is-exiting-without-update-p)
9131 (gnus-check-backend-function
9132 'request-expire-articles gnus-newsgroup-name))
9133 ;; This backend supports expiry.
9134 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9135 (expirable (if total
9137 ;; We need to update the info for
9138 ;; this group for `gnus-list-of-read-articles'
9139 ;; to give us the right answer.
9140 (gnus-run-hooks 'gnus-exit-group-hook)
9141 (gnus-summary-update-info)
9142 (gnus-list-of-read-articles gnus-newsgroup-name))
9143 (setq gnus-newsgroup-expirable
9144 (sort gnus-newsgroup-expirable '<))))
9145 (expiry-wait (if now 'immediate
9146 (gnus-group-find-parameter
9147 gnus-newsgroup-name 'expiry-wait)))
9148 (nnmail-expiry-target
9149 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9150 nnmail-expiry-target))
9153 ;; There are expirable articles in this group, so we run them
9154 ;; through the expiry process.
9155 (gnus-message 6 "Expiring articles...")
9156 (unless (gnus-check-group gnus-newsgroup-name)
9157 (error "Can't open server for %s" gnus-newsgroup-name))
9158 ;; The list of articles that weren't expired is returned.
9161 (let ((nnmail-expiry-wait-function nil)
9162 (nnmail-expiry-wait expiry-wait))
9163 (setq es (gnus-request-expire-articles
9164 expirable gnus-newsgroup-name)))
9165 (setq es (gnus-request-expire-articles
9166 expirable gnus-newsgroup-name)))
9168 (setq gnus-newsgroup-expirable es))
9169 ;; We go through the old list of expirable, and mark all
9170 ;; really expired articles as nonexistent.
9171 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9172 (let ((gnus-use-cache nil))
9173 (dolist (article expirable)
9174 (when (and (not (memq article es))
9175 (gnus-data-find article))
9176 (gnus-summary-mark-article article gnus-canceled-mark)
9177 (run-hook-with-args 'gnus-summary-article-expire-hook
9180 (assoc article (gnus-data-list nil)))
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 (let* ((article (car articles))
9233 (id (mail-header-id (gnus-data-header
9234 (assoc article (gnus-data-list nil))))))
9235 (run-hook-with-args 'gnus-summary-article-delete-hook
9236 'delete id gnus-newsgroup-name nil
9238 (setq articles (cdr articles)))
9240 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9241 (gnus-summary-position-point)
9242 (gnus-set-mode-line 'summary)
9245 (defun gnus-summary-edit-article (&optional arg)
9246 "Edit the current article.
9247 This will have permanent effect only in mail groups.
9248 If ARG is nil, edit the decoded articles.
9249 If ARG is 1, edit the raw articles.
9250 If ARG is 2, edit the raw articles even in read-only groups.
9251 If ARG is 3, edit the articles with the current handles.
9252 Otherwise, allow editing of articles even in read-only
9255 (let (force raw current-handles)
9264 (setq current-handles
9265 (and (gnus-buffer-live-p gnus-article-buffer)
9266 (with-current-buffer gnus-article-buffer
9268 gnus-article-mime-handles
9269 (setq gnus-article-mime-handles nil))))))
9272 (when (and raw (not force)
9273 (member gnus-newsgroup-name '("nndraft:delayed"
9276 (error "Can't edit the raw article in group %s"
9277 gnus-newsgroup-name))
9279 (set-buffer gnus-summary-buffer)
9280 (let ((mail-parse-charset gnus-newsgroup-charset)
9281 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9282 (gnus-set-global-variables)
9283 (when (and (not force)
9284 (gnus-group-read-only-p))
9285 (error "The current newsgroup does not support article editing"))
9286 (gnus-summary-show-article t)
9287 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9288 (with-current-buffer gnus-article-buffer
9289 (mm-enable-multibyte)))
9290 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9292 (gnus-article-edit-article
9295 (let ((mbl mml-buffer-list))
9296 (setq mml-buffer-list nil)
9297 (mime-to-mml ,'current-handles)
9298 (let ((mbl1 mml-buffer-list))
9299 (setq mml-buffer-list mbl)
9300 (set (make-local-variable 'mml-buffer-list) mbl1))
9301 (make-local-hook 'kill-buffer-hook)
9302 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9303 `(lambda (no-highlight)
9304 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9305 (message-options message-options)
9306 (message-options-set-recipient)
9307 (mail-parse-ignored-charsets
9308 ',gnus-newsgroup-ignored-charsets))
9309 ,(if (not raw) '(progn
9311 (mml-destroy-buffers)
9312 (remove-hook 'kill-buffer-hook
9313 'mml-destroy-buffers t)
9314 (kill-local-variable 'mml-buffer-list)))
9315 (gnus-summary-edit-article-done
9316 ,(or (mail-header-references gnus-current-headers) "")
9317 ,(gnus-group-read-only-p)
9318 ,gnus-summary-buffer no-highlight))))))))
9320 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9322 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9324 "Make edits to the current article permanent."
9327 ;; The buffer restriction contains the entire article if it exists.
9328 (when (article-goto-body)
9329 (let ((lines (count-lines (point) (point-max)))
9330 (length (- (point-max) (point)))
9331 (case-fold-search t)
9332 (body (copy-marker (point))))
9333 (goto-char (point-min))
9334 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9335 (delete-region (match-beginning 1) (match-end 1))
9336 (insert (number-to-string length)))
9337 (goto-char (point-min))
9338 (when (re-search-forward
9339 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9340 (delete-region (match-beginning 1) (match-end 1))
9341 (insert (number-to-string length)))
9342 (goto-char (point-min))
9343 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9344 (delete-region (match-beginning 1) (match-end 1))
9345 (insert (number-to-string lines))))))
9346 ;; Replace the article.
9347 (let ((buf (current-buffer)))
9349 (insert-buffer-substring buf)
9351 (if (and (not read-only)
9352 (not (gnus-request-replace-article
9353 (cdr gnus-article-current) (car gnus-article-current)
9354 (current-buffer) t)))
9355 (error "Couldn't replace article")
9356 ;; Update the summary buffer.
9358 (equal (message-tokenize-header references " ")
9359 (message-tokenize-header
9360 (or (message-fetch-field "references") "") " ")))
9361 ;; We only have to update this line.
9364 (message-narrow-to-head)
9365 (let ((head (buffer-string))
9368 (insert (format "211 %d Article retrieved.\n"
9369 (cdr gnus-article-current)))
9372 (let ((nntp-server-buffer (current-buffer)))
9373 (setq header (car (gnus-get-newsgroup-headers
9376 (set-buffer gnus-summary-buffer)
9377 (gnus-data-set-header
9378 (gnus-data-find (cdr gnus-article-current))
9380 (gnus-summary-update-article-line
9381 (cdr gnus-article-current) header)
9382 (if (gnus-summary-goto-subject
9383 (cdr gnus-article-current) nil t)
9384 (gnus-summary-update-secondary-mark
9385 (cdr gnus-article-current))))))))
9387 (set-buffer (or buffer gnus-summary-buffer))
9388 (gnus-summary-update-article (cdr gnus-article-current))
9389 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9390 (gnus-summary-update-secondary-mark
9391 (cdr gnus-article-current))))
9392 ;; Prettify the article buffer again.
9393 (unless no-highlight
9395 (set-buffer gnus-article-buffer)
9396 ;;;!!! Fix this -- article should be rehighlighted.
9397 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9398 (set-buffer gnus-original-article-buffer)
9399 (gnus-request-article
9400 (cdr gnus-article-current)
9401 (car gnus-article-current) (current-buffer))))
9402 ;; Prettify the summary buffer line.
9403 (when (gnus-visual-p 'summary-highlight 'highlight)
9404 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9406 (defun gnus-summary-edit-wash (key)
9407 "Perform editing command KEY in the article buffer."
9411 (message "%s" (concat (this-command-keys) "- "))
9414 (gnus-summary-edit-article)
9415 (execute-kbd-macro (concat (this-command-keys) key))
9416 (gnus-article-edit-done))
9420 (defun gnus-summary-respool-query (&optional silent trace)
9421 "Query where the respool algorithm would put this article."
9423 (let (gnus-mark-article-hook)
9424 (gnus-summary-select-article)
9426 (set-buffer gnus-original-article-buffer)
9428 (message-narrow-to-head)
9429 (let ((groups (nnmail-article-group 'identity trace)))
9432 (message "This message would go to %s"
9433 (mapconcat 'car groups ", "))
9434 (message "This message would go to no groups"))
9437 (defun gnus-summary-respool-trace ()
9438 "Trace where the respool algorithm would put this article.
9439 Display a buffer showing all fancy splitting patterns which matched."
9441 (gnus-summary-respool-query nil t))
9443 ;; Summary marking commands.
9445 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9446 "Mark articles which has the same subject as read, and then select the next.
9447 If UNMARK is positive, remove any kind of mark.
9448 If UNMARK is negative, tick articles."
9451 (setq unmark (prefix-numeric-value unmark)))
9453 (gnus-summary-mark-same-subject
9454 (gnus-summary-article-subject) unmark)))
9455 ;; Select next unread article. If auto-select-same mode, should
9456 ;; select the first unread article.
9457 (gnus-summary-next-article t (and gnus-auto-select-same
9458 (gnus-summary-article-subject)))
9459 (gnus-message 7 "%d article%s marked as %s"
9460 count (if (= count 1) " is" "s are")
9461 (if unmark "unread" "read"))))
9463 (defun gnus-summary-kill-same-subject (&optional unmark)
9464 "Mark articles which has the same subject as read.
9465 If UNMARK is positive, remove any kind of mark.
9466 If UNMARK is negative, tick articles."
9469 (setq unmark (prefix-numeric-value unmark)))
9471 (gnus-summary-mark-same-subject
9472 (gnus-summary-article-subject) unmark)))
9473 ;; If marked as read, go to next unread subject.
9475 ;; Go to next unread subject.
9476 (gnus-summary-next-subject 1 t))
9477 (gnus-message 7 "%d articles are marked as %s"
9478 count (if unmark "unread" "read"))))
9480 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9481 "Mark articles with same SUBJECT as read, and return marked number.
9482 If optional argument UNMARK is positive, remove any kinds of marks.
9483 If optional argument UNMARK is negative, mark articles as unread instead."
9487 ((null unmark) ; Mark as read.
9490 (gnus-summary-mark-article-as-read gnus-killed-mark)
9491 (gnus-summary-show-thread) t)
9492 (gnus-summary-find-subject subject))
9493 (setq count (1+ count))))
9494 ((> unmark 0) ; Tick.
9497 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9498 (gnus-summary-show-thread) t)
9499 (gnus-summary-find-subject subject))
9500 (setq count (1+ count))))
9501 (t ; Mark as unread.
9504 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9505 (gnus-summary-show-thread) t)
9506 (gnus-summary-find-subject subject))
9507 (setq count (1+ count)))))
9508 (gnus-set-mode-line 'summary)
9509 ;; Return the number of marked articles.
9512 (defun gnus-summary-mark-as-processable (n &optional unmark)
9513 "Set the process mark on the next N articles.
9514 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9515 the process mark instead. The difference between N and the actual
9516 number of articles marked is returned."
9518 (if (and (null n) (gnus-region-active-p))
9519 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9520 (setq n (prefix-numeric-value n))
9521 (let ((backward (< n 0))
9526 (gnus-summary-remove-process-mark
9527 (gnus-summary-article-number))
9528 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9529 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9532 (gnus-message 7 "No more articles"))
9533 (gnus-summary-recenter)
9534 (gnus-summary-position-point)
9537 (defun gnus-summary-unmark-as-processable (n)
9538 "Remove the process mark from the next N articles.
9539 If N is negative, unmark backward instead. The difference between N and
9540 the actual number of articles unmarked is returned."
9542 (gnus-summary-mark-as-processable n t))
9544 (defun gnus-summary-unmark-all-processable ()
9545 "Remove the process mark from all articles."
9548 (while gnus-newsgroup-processable
9549 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9550 (gnus-summary-position-point))
9552 (defun gnus-summary-add-mark (article type)
9553 "Mark ARTICLE with a mark of TYPE."
9554 (let ((vtype (car (assq type gnus-article-mark-lists)))
9557 (error "No such mark type: %s" type)
9558 (setq var (intern (format "gnus-newsgroup-%s" type)))
9559 (set var (cons article (symbol-value var)))
9560 (if (memq type '(processable cached replied forwarded recent saved))
9561 (gnus-summary-update-secondary-mark article)
9562 ;;; !!! This is bogus. We should find out what primary
9563 ;;; !!! mark we want to set.
9564 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9566 (defun gnus-summary-mark-as-expirable (n)
9567 "Mark N articles forward as expirable.
9568 If N is negative, mark backward instead. The difference between N and
9569 the actual number of articles marked is returned."
9571 (gnus-summary-mark-forward n gnus-expirable-mark))
9573 (defun gnus-summary-mark-as-spam (n)
9574 "Mark N articles forward as spam.
9575 If N is negative, mark backward instead. The difference between N and
9576 the actual number of articles marked is returned."
9578 (gnus-summary-mark-forward n gnus-spam-mark))
9580 (defun gnus-summary-mark-article-as-replied (article)
9581 "Mark ARTICLE as replied to and update the summary line.
9582 ARTICLE can also be a list of articles."
9583 (interactive (list (gnus-summary-article-number)))
9584 (let ((articles (if (listp article) article (list article))))
9585 (dolist (article articles)
9586 (unless (numberp article)
9587 (error "%s is not a number" article))
9588 (push article gnus-newsgroup-replied)
9589 (let ((buffer-read-only nil))
9590 (when (gnus-summary-goto-subject article nil t)
9591 (gnus-summary-update-secondary-mark article))))))
9593 (defun gnus-summary-mark-article-as-forwarded (article)
9594 "Mark ARTICLE as forwarded and update the summary line.
9595 ARTICLE can also be a list of articles."
9596 (let ((articles (if (listp article) article (list article))))
9597 (dolist (article articles)
9598 (push article gnus-newsgroup-forwarded)
9599 (let ((buffer-read-only nil))
9600 (when (gnus-summary-goto-subject article nil t)
9601 (gnus-summary-update-secondary-mark article))))))
9603 (defun gnus-summary-set-bookmark (article)
9604 "Set a bookmark in current article."
9605 (interactive (list (gnus-summary-article-number)))
9606 (when (or (not (get-buffer gnus-article-buffer))
9607 (not gnus-current-article)
9608 (not gnus-article-current)
9609 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9610 (error "No current article selected"))
9611 ;; Remove old bookmark, if one exists.
9612 (gnus-pull article gnus-newsgroup-bookmarks)
9613 ;; Set the new bookmark, which is on the form
9614 ;; (article-number . line-number-in-body).
9618 (set-buffer gnus-article-buffer)
9625 gnus-newsgroup-bookmarks)
9626 (gnus-message 6 "A bookmark has been added to the current article."))
9628 (defun gnus-summary-remove-bookmark (article)
9629 "Remove the bookmark from the current article."
9630 (interactive (list (gnus-summary-article-number)))
9631 ;; Remove old bookmark, if one exists.
9632 (if (not (assq article gnus-newsgroup-bookmarks))
9633 (gnus-message 6 "No bookmark in current article.")
9634 (gnus-pull article gnus-newsgroup-bookmarks)
9635 (gnus-message 6 "Removed bookmark.")))
9637 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9638 (defun gnus-summary-mark-as-dormant (n)
9639 "Mark N articles forward as dormant.
9640 If N is negative, mark backward instead. The difference between N and
9641 the actual number of articles marked is returned."
9643 (gnus-summary-mark-forward n gnus-dormant-mark))
9645 (defun gnus-summary-set-process-mark (article)
9646 "Set the process mark on ARTICLE and update the summary line."
9647 (setq gnus-newsgroup-processable
9649 (delq article gnus-newsgroup-processable)))
9650 (when (gnus-summary-goto-subject article)
9651 (gnus-summary-show-thread)
9652 (gnus-summary-goto-subject article)
9653 (gnus-summary-update-secondary-mark article)))
9655 (defun gnus-summary-remove-process-mark (article)
9656 "Remove the process mark from ARTICLE and update the summary line."
9657 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9658 (when (gnus-summary-goto-subject article)
9659 (gnus-summary-show-thread)
9660 (gnus-summary-goto-subject article)
9661 (gnus-summary-update-secondary-mark article)))
9663 (defun gnus-summary-set-saved-mark (article)
9664 "Set the process mark on ARTICLE and update the summary line."
9665 (push article gnus-newsgroup-saved)
9666 (when (gnus-summary-goto-subject article)
9667 (gnus-summary-update-secondary-mark article)))
9669 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9670 "Mark N articles as read forwards.
9671 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9672 The difference between N and the actual number of articles marked is
9674 If NO-EXPIRE, auto-expiry will be inhibited."
9676 (gnus-summary-show-thread)
9677 (let ((backward (< n 0))
9678 (gnus-summary-goto-unread
9679 (and gnus-summary-goto-unread
9680 (not (eq gnus-summary-goto-unread 'never))
9681 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9682 gnus-ticked-mark gnus-dormant-mark)))))
9684 (mark (or mark gnus-del-mark)))
9686 (gnus-summary-mark-article nil mark no-expire)
9687 (zerop (gnus-summary-next-subject
9689 (and gnus-summary-goto-unread
9690 (not (eq gnus-summary-goto-unread 'never)))
9694 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9695 (gnus-summary-recenter)
9696 (gnus-summary-position-point)
9697 (gnus-set-mode-line 'summary)
9700 (defun gnus-summary-mark-article-as-read (mark)
9701 "Mark the current article quickly as read with MARK."
9702 (let ((article (gnus-summary-article-number)))
9703 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9704 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9705 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9706 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9707 (push (cons article mark) gnus-newsgroup-reads)
9708 ;; Possibly remove from cache, if that is used.
9709 (when gnus-use-cache
9710 (gnus-cache-enter-remove-article article))
9711 ;; Allow the backend to change the mark.
9712 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9713 ;; Check for auto-expiry.
9714 (when (and gnus-newsgroup-auto-expire
9715 (memq mark gnus-auto-expirable-marks))
9716 (setq mark gnus-expirable-mark)
9717 ;; Let the backend know about the mark change.
9718 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9719 (push article gnus-newsgroup-expirable))
9720 ;; Set the mark in the buffer.
9721 (gnus-summary-update-mark mark 'unread)
9724 (defun gnus-summary-mark-article-as-unread (mark)
9725 "Mark the current article quickly as unread with MARK."
9726 (let* ((article (gnus-summary-article-number))
9727 (old-mark (gnus-summary-article-mark article)))
9728 ;; Allow the backend to change the mark.
9729 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9730 (if (eq mark old-mark)
9734 (gnus-error 1 "Can't mark negative article numbers")
9736 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9737 (setq gnus-newsgroup-spam-marked
9738 (delq article gnus-newsgroup-spam-marked))
9739 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9740 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9741 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9742 (cond ((= mark gnus-ticked-mark)
9743 (setq gnus-newsgroup-marked
9744 (gnus-add-to-sorted-list gnus-newsgroup-marked
9746 ((= mark gnus-spam-mark)
9747 (setq gnus-newsgroup-spam-marked
9748 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9750 ((= mark gnus-dormant-mark)
9751 (setq gnus-newsgroup-dormant
9752 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9755 (setq gnus-newsgroup-unreads
9756 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9758 (gnus-pull article gnus-newsgroup-reads)
9760 ;; See whether the article is to be put in the cache.
9762 (vectorp (gnus-summary-article-header article))
9764 (gnus-cache-possibly-enter-article
9765 gnus-newsgroup-name article
9766 (= mark gnus-ticked-mark)
9767 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9770 (gnus-summary-update-mark mark 'unread)
9773 (defun gnus-summary-mark-article (&optional article mark no-expire)
9774 "Mark ARTICLE with MARK. MARK can be any character.
9775 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9776 `??' (dormant) and `?E' (expirable).
9777 If MARK is nil, then the default character `?r' is used.
9778 If ARTICLE is nil, then the article on the current line will be
9780 If NO-EXPIRE, auto-expiry will be inhibited."
9781 ;; The mark might be a string.
9782 (when (stringp mark)
9783 (setq mark (aref mark 0)))
9784 ;; If no mark is given, then we check auto-expiring.
9786 (setq mark gnus-del-mark))
9787 (when (and (not no-expire)
9788 gnus-newsgroup-auto-expire
9789 (memq mark gnus-auto-expirable-marks))
9790 (setq mark gnus-expirable-mark))
9791 (let ((article (or article (gnus-summary-article-number)))
9792 (old-mark (gnus-summary-article-mark article)))
9793 ;; Allow the backend to change the mark.
9794 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9795 (if (eq mark old-mark)
9798 (error "No article on current line"))
9799 (if (not (if (or (= mark gnus-unread-mark)
9800 (= mark gnus-ticked-mark)
9801 (= mark gnus-spam-mark)
9802 (= mark gnus-dormant-mark))
9803 (gnus-mark-article-as-unread article mark)
9804 (gnus-mark-article-as-read article mark)))
9806 ;; See whether the article is to be put in the cache.
9808 (not (= mark gnus-canceled-mark))
9809 (vectorp (gnus-summary-article-header article))
9811 (gnus-cache-possibly-enter-article
9812 gnus-newsgroup-name article
9813 (= mark gnus-ticked-mark)
9814 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9816 (when (gnus-summary-goto-subject article nil t)
9817 (let ((buffer-read-only nil))
9818 (gnus-summary-show-thread)
9820 (gnus-summary-update-mark mark 'unread)
9823 (defun gnus-summary-update-secondary-mark (article)
9824 "Update the secondary (read, process, cache) mark."
9825 (gnus-summary-update-mark
9826 (cond ((memq article gnus-newsgroup-processable)
9828 ((memq article gnus-newsgroup-cached)
9830 ((memq article gnus-newsgroup-replied)
9832 ((memq article gnus-newsgroup-forwarded)
9833 gnus-forwarded-mark)
9834 ((memq article gnus-newsgroup-saved)
9836 ((memq article gnus-newsgroup-recent)
9838 ((memq article gnus-newsgroup-unseen)
9842 (when (gnus-visual-p 'summary-highlight 'highlight)
9843 (gnus-run-hooks 'gnus-summary-update-hook))
9846 (defun gnus-summary-update-download-mark (article)
9847 "Update the download mark."
9848 (gnus-summary-update-mark
9849 (cond ((memq article gnus-newsgroup-undownloaded)
9850 gnus-undownloaded-mark)
9851 (gnus-newsgroup-agentized
9852 gnus-downloaded-mark)
9856 (gnus-summary-update-line t)
9859 (defun gnus-summary-update-mark (mark type)
9860 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9861 (buffer-read-only nil))
9862 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9864 (when (looking-at "\r")
9866 (when (<= (+ forward (point)) (point-max))
9867 ;; Go to the right position on the line.
9868 (goto-char (+ forward (point)))
9869 ;; Replace the old mark with the new mark.
9870 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9871 ;; Optionally update the marks by some user rule.
9872 (when (eq type 'unread)
9874 (gnus-data-find (gnus-summary-article-number)) mark)
9875 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9877 (defun gnus-mark-article-as-read (article &optional mark)
9878 "Enter ARTICLE in the pertinent lists and remove it from others."
9879 ;; Make the article expirable.
9880 (let ((mark (or mark gnus-del-mark)))
9881 (setq gnus-newsgroup-expirable
9882 (if (= mark gnus-expirable-mark)
9883 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9884 (delq article gnus-newsgroup-expirable)))
9885 ;; Remove from unread and marked lists.
9886 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9887 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9888 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9889 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9890 (push (cons article mark) gnus-newsgroup-reads)
9891 ;; Possibly remove from cache, if that is used.
9892 (when gnus-use-cache
9893 (gnus-cache-enter-remove-article article))
9896 (defun gnus-mark-article-as-unread (article &optional mark)
9897 "Enter ARTICLE in the pertinent lists and remove it from others."
9898 (let ((mark (or mark gnus-ticked-mark)))
9901 (gnus-error 1 "Can't mark negative article numbers")
9903 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9904 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9905 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9906 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9907 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9909 ;; Unsuppress duplicates?
9910 (when gnus-suppress-duplicates
9911 (gnus-dup-unsuppress-article article))
9913 (cond ((= mark gnus-ticked-mark)
9914 (setq gnus-newsgroup-marked
9915 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9916 ((= mark gnus-spam-mark)
9917 (setq gnus-newsgroup-spam-marked
9918 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9920 ((= mark gnus-dormant-mark)
9921 (setq gnus-newsgroup-dormant
9922 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9924 (setq gnus-newsgroup-unreads
9925 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9926 (gnus-pull article gnus-newsgroup-reads)
9929 (defalias 'gnus-summary-mark-as-unread-forward
9930 'gnus-summary-tick-article-forward)
9931 (make-obsolete 'gnus-summary-mark-as-unread-forward
9932 'gnus-summary-tick-article-forward)
9933 (defun gnus-summary-tick-article-forward (n)
9934 "Tick N articles forwards.
9935 If N is negative, tick backwards instead.
9936 The difference between N and the number of articles ticked is returned."
9938 (gnus-summary-mark-forward n gnus-ticked-mark))
9940 (defalias 'gnus-summary-mark-as-unread-backward
9941 'gnus-summary-tick-article-backward)
9942 (make-obsolete 'gnus-summary-mark-as-unread-backward
9943 'gnus-summary-tick-article-backward)
9944 (defun gnus-summary-tick-article-backward (n)
9945 "Tick N articles backwards.
9946 The difference between N and the number of articles ticked is returned."
9948 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9950 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9951 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9952 (defun gnus-summary-tick-article (&optional article clear-mark)
9953 "Mark current article as unread.
9954 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9955 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9957 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9960 (defun gnus-summary-mark-as-read-forward (n)
9961 "Mark N articles as read forwards.
9962 If N is negative, mark backwards instead.
9963 The difference between N and the actual number of articles marked is
9966 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9968 (defun gnus-summary-mark-as-read-backward (n)
9969 "Mark the N articles as read backwards.
9970 The difference between N and the actual number of articles marked is
9973 (gnus-summary-mark-forward
9974 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9976 (defun gnus-summary-mark-as-read (&optional article mark)
9977 "Mark current article as read.
9978 ARTICLE specifies the article to be marked as read.
9979 MARK specifies a string to be inserted at the beginning of the line."
9980 (gnus-summary-mark-article article mark))
9982 (defun gnus-summary-clear-mark-forward (n)
9983 "Clear marks from N articles forward.
9984 If N is negative, clear backward instead.
9985 The difference between N and the number of marks cleared is returned."
9987 (gnus-summary-mark-forward n gnus-unread-mark))
9989 (defun gnus-summary-clear-mark-backward (n)
9990 "Clear marks from N articles backward.
9991 The difference between N and the number of marks cleared is returned."
9993 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9995 (defun gnus-summary-mark-unread-as-read ()
9996 "Intended to be used by `gnus-summary-mark-article-hook'."
9997 (when (memq gnus-current-article gnus-newsgroup-unreads)
9998 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10000 (defun gnus-summary-mark-read-and-unread-as-read ()
10001 "Intended to be used by `gnus-summary-mark-article-hook'."
10002 (let ((mark (gnus-summary-article-mark)))
10003 (when (or (gnus-unread-mark-p mark)
10004 (gnus-read-mark-p mark))
10005 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
10007 (defun gnus-summary-mark-unread-as-ticked ()
10008 "Intended to be used by `gnus-summary-mark-article-hook'."
10009 (when (memq gnus-current-article gnus-newsgroup-unreads)
10010 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10012 (defun gnus-summary-mark-region-as-read (point mark all)
10013 "Mark all unread articles between point and mark as read.
10014 If given a prefix, mark all articles between point and mark as read,
10015 even ticked and dormant ones."
10016 (interactive "r\nP")
10020 (beginning-of-line)
10025 (memq (setq article (gnus-summary-article-number))
10026 gnus-newsgroup-unreads))
10027 (gnus-summary-mark-article article gnus-del-mark))
10029 (gnus-summary-find-next))))))
10031 (defun gnus-summary-mark-below (score mark)
10032 "Mark articles with score less than SCORE with MARK."
10033 (interactive "P\ncMark: ")
10034 (setq score (if score
10035 (prefix-numeric-value score)
10036 (or gnus-summary-default-score 0)))
10038 (set-buffer gnus-summary-buffer)
10039 (goto-char (point-min))
10042 (and (< (gnus-summary-article-score) score)
10043 (gnus-summary-mark-article nil mark))
10044 (gnus-summary-find-next)))))
10046 (defun gnus-summary-kill-below (&optional score)
10047 "Mark articles with score below SCORE as read."
10049 (gnus-summary-mark-below score gnus-killed-mark))
10051 (defun gnus-summary-clear-above (&optional score)
10052 "Clear all marks from articles with score above SCORE."
10054 (gnus-summary-mark-above score gnus-unread-mark))
10056 (defun gnus-summary-tick-above (&optional score)
10057 "Tick all articles with score above SCORE."
10059 (gnus-summary-mark-above score gnus-ticked-mark))
10061 (defun gnus-summary-mark-above (score mark)
10062 "Mark articles with score over SCORE with MARK."
10063 (interactive "P\ncMark: ")
10064 (setq score (if score
10065 (prefix-numeric-value score)
10066 (or gnus-summary-default-score 0)))
10068 (set-buffer gnus-summary-buffer)
10069 (goto-char (point-min))
10071 (when (> (gnus-summary-article-score) score)
10072 (gnus-summary-mark-article nil mark))
10074 (gnus-summary-find-next)))))
10076 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10077 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10078 (defun gnus-summary-limit-include-expunged (&optional no-error)
10079 "Display all the hidden articles that were expunged for low scores."
10081 (let ((buffer-read-only nil))
10082 (let ((scored gnus-newsgroup-scored)
10085 (unless (gnus-summary-article-header (caar scored))
10086 (and (setq h (gnus-number-to-header (caar scored)))
10087 (< (cdar scored) gnus-summary-expunge-below)
10089 (setq scored (cdr scored)))
10091 (when (not no-error)
10092 (error "No expunged articles hidden"))
10093 (goto-char (point-min))
10094 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10095 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10096 (mapcar (lambda (x) (push (mail-header-number x)
10097 gnus-newsgroup-limit))
10099 (gnus-summary-prepare-unthreaded (nreverse headers))
10100 (goto-char (point-min))
10101 (gnus-summary-position-point)
10104 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10105 "Mark all unread articles in this newsgroup as read.
10106 If prefix argument ALL is non-nil, ticked and dormant articles will
10107 also be marked as read.
10108 If QUIETLY is non-nil, no questions will be asked.
10109 If TO-HERE is non-nil, it should be a point in the buffer. All
10110 articles before (after, if REVERSE is set) this point will be marked as read.
10111 Note that this function will only catch up the unread article
10112 in the current summary buffer limitation.
10113 The number of articles marked as read is returned."
10118 (not gnus-interactive-catchup) ;Without confirmation?
10122 "Mark absolutely all articles as read? "
10123 "Mark all unread articles as read? ")))
10125 (not gnus-newsgroup-adaptive)
10126 (not gnus-newsgroup-auto-expire)
10127 (not gnus-suppress-duplicates)
10128 (or (not gnus-use-cache)
10129 (eq gnus-use-cache 'passive)))
10132 (setq gnus-newsgroup-marked nil
10133 gnus-newsgroup-spam-marked nil
10134 gnus-newsgroup-dormant nil))
10135 (setq gnus-newsgroup-unreads
10136 (gnus-sorted-nunion
10137 (gnus-intersection gnus-newsgroup-unreads
10138 gnus-newsgroup-downloadable)
10139 gnus-newsgroup-unfetched)))
10140 ;; We actually mark all articles as canceled, which we
10141 ;; have to do when using auto-expiry or adaptive scoring.
10142 (gnus-summary-show-all-threads)
10143 (if (and to-here reverse)
10145 (goto-char to-here)
10147 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10148 (gnus-summary-find-next (not all)))))
10149 (when (gnus-summary-first-subject (not all))
10151 (if to-here (< (point) to-here) t)
10152 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10153 (gnus-summary-find-next (not all))))))
10154 (gnus-set-mode-line 'summary))
10156 (gnus-summary-position-point)))
10158 (defun gnus-summary-catchup-to-here (&optional all)
10159 "Mark all unticked articles before the current one as read.
10160 If ALL is non-nil, also mark ticked and dormant articles as read."
10163 (gnus-save-hidden-threads
10164 (let ((beg (point)))
10165 ;; We check that there are unread articles.
10166 (when (or all (gnus-summary-find-prev))
10167 (gnus-summary-catchup all t beg)))))
10168 (gnus-summary-position-point))
10170 (defun gnus-summary-catchup-from-here (&optional all)
10171 "Mark all unticked articles after the current one as read.
10172 If ALL is non-nil, also mark ticked and dormant articles as read."
10175 (gnus-save-hidden-threads
10176 (let ((beg (point)))
10177 ;; We check that there are unread articles.
10178 (when (or all (gnus-summary-find-next))
10179 (gnus-summary-catchup all t beg nil t)))))
10181 (gnus-summary-position-point))
10182 (defun gnus-summary-catchup-all (&optional quietly)
10183 "Mark all articles in this newsgroup as read.
10184 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10185 instead, which marks only unread articles as read."
10187 (gnus-summary-catchup t quietly))
10189 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10190 "Mark all unread articles in this group as read, then exit.
10191 If prefix argument ALL is non-nil, all articles are marked as read.
10192 If QUIETLY is non-nil, no questions will be asked."
10194 (when (gnus-summary-catchup all quietly nil 'fast)
10195 ;; Select next newsgroup or exit.
10196 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10197 (eq gnus-auto-select-next 'quietly))
10198 (gnus-summary-next-group nil)
10199 (gnus-summary-exit))))
10201 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10202 "Mark all articles in this newsgroup as read, and then exit.
10203 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10204 instead, which marks only unread articles as read."
10206 (gnus-summary-catchup-and-exit t quietly))
10208 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10209 "Mark all articles in this group as read and select the next group.
10210 If given a prefix, mark all articles, unread as well as ticked, as
10214 (gnus-summary-catchup all))
10215 (gnus-summary-next-group))
10221 (defmacro gnus-with-article (article &rest forms)
10222 "Select ARTICLE and perform FORMS in the original article buffer.
10223 Then replace the article with the result."
10225 ;; We don't want the article to be marked as read.
10226 (let (gnus-mark-article-hook)
10227 (gnus-summary-select-article t t nil ,article))
10228 (set-buffer gnus-original-article-buffer)
10230 (if (not (gnus-check-backend-function
10231 'request-replace-article (car gnus-article-current)))
10232 (gnus-message 5 "Read-only group; not replacing")
10233 (unless (gnus-request-replace-article
10234 ,article (car gnus-article-current)
10235 (current-buffer) t)
10236 (error "Couldn't replace article")))
10237 ;; The cache and backlog have to be flushed somewhat.
10238 (when gnus-keep-backlog
10239 (gnus-backlog-remove-article
10240 (car gnus-article-current) (cdr gnus-article-current)))
10241 (when gnus-use-cache
10242 (gnus-cache-update-article
10243 (car gnus-article-current) (cdr gnus-article-current)))))
10245 (put 'gnus-with-article 'lisp-indent-function 1)
10246 (put 'gnus-with-article 'edebug-form-spec '(form body))
10248 ;; Thread-based commands.
10250 (defun gnus-summary-articles-in-thread (&optional article)
10251 "Return a list of all articles in the current thread.
10252 If ARTICLE is non-nil, return all articles in the thread that starts
10253 with that article."
10254 (let* ((article (or article (gnus-summary-article-number)))
10255 (data (gnus-data-find-list article))
10256 (top-level (gnus-data-level (car data)))
10258 (cond ((null gnus-thread-operation-ignore-subject)
10259 (gnus-simplify-subject-re
10260 (mail-header-subject (gnus-data-header (car data)))))
10261 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10262 (gnus-simplify-subject-fuzzy
10263 (mail-header-subject (gnus-data-header (car data)))))
10265 (end-point (save-excursion
10266 (if (gnus-summary-go-to-next-thread)
10267 (point) (point-max))))
10270 (< (gnus-data-pos (car data)) end-point))
10271 (when (or (not top-subject)
10272 (string= top-subject
10273 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10274 (gnus-simplify-subject-fuzzy
10275 (mail-header-subject
10276 (gnus-data-header (car data))))
10277 (gnus-simplify-subject-re
10278 (mail-header-subject
10279 (gnus-data-header (car data)))))))
10280 (push (gnus-data-number (car data)) articles))
10281 (unless (and (setq data (cdr data))
10282 (> (gnus-data-level (car data)) top-level))
10284 ;; Return the list of articles.
10285 (nreverse articles)))
10287 (defun gnus-summary-rethread-current ()
10288 "Rethread the thread the current article is part of."
10290 (let* ((gnus-show-threads t)
10291 (article (gnus-summary-article-number))
10292 (id (mail-header-id (gnus-summary-article-header)))
10293 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10295 (error "No article on the current line"))
10296 (gnus-rebuild-thread id)
10297 (gnus-summary-goto-subject article)))
10299 (defun gnus-summary-reparent-thread ()
10300 "Make the current article child of the marked (or previous) article.
10302 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10303 is non-nil or the Subject: of both articles are the same."
10305 (unless (not (gnus-group-read-only-p))
10306 (error "The current newsgroup does not support article editing"))
10307 (unless (<= (length gnus-newsgroup-processable) 1)
10308 (error "No more than one article may be marked"))
10309 (save-window-excursion
10310 (let ((gnus-article-buffer " *reparent*")
10311 (current-article (gnus-summary-article-number))
10312 ;; First grab the marked article, otherwise one line up.
10313 (parent-article (if (not (null gnus-newsgroup-processable))
10314 (car gnus-newsgroup-processable)
10316 (if (eq (forward-line -1) 0)
10317 (gnus-summary-article-number)
10318 (error "Beginning of summary buffer"))))))
10319 (unless (not (eq current-article parent-article))
10320 (error "An article may not be self-referential"))
10321 (let ((message-id (mail-header-id
10322 (gnus-summary-article-header parent-article))))
10323 (unless (and message-id (not (equal message-id "")))
10324 (error "No message-id in desired parent"))
10325 (gnus-with-article current-article
10327 (goto-char (point-min))
10328 (message-narrow-to-head)
10329 (if (re-search-forward "^References: " nil t)
10331 (re-search-forward "^[^ \t]" nil t)
10334 (insert " " message-id))
10335 (insert "References: " message-id "\n"))))
10336 (set-buffer gnus-summary-buffer)
10337 (gnus-summary-unmark-all-processable)
10338 (gnus-summary-update-article current-article)
10339 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10340 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10341 (gnus-summary-rethread-current)
10342 (gnus-message 3 "Article %d is now the child of article %d"
10343 current-article parent-article)))))
10345 (defun gnus-summary-toggle-threads (&optional arg)
10346 "Toggle showing conversation threads.
10347 If ARG is positive number, turn showing conversation threads on."
10349 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10350 (setq gnus-show-threads
10351 (if (null arg) (not gnus-show-threads)
10352 (> (prefix-numeric-value arg) 0)))
10353 (gnus-summary-prepare)
10354 (gnus-summary-goto-subject current)
10355 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10356 (gnus-summary-position-point)))
10358 (defun gnus-summary-show-all-threads ()
10359 "Show all threads."
10362 (let ((buffer-read-only nil))
10363 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10364 (gnus-summary-position-point))
10366 (defun gnus-summary-show-thread ()
10367 "Show thread subtrees.
10368 Returns nil if no thread was there to be shown."
10370 (let ((buffer-read-only nil)
10372 (end (gnus-point-at-eol))
10373 ;; Leave point at bol
10374 (beg (progn (beginning-of-line) (point))))
10376 ;; Any hidden lines here?
10377 (search-forward "\r" end t)
10378 (subst-char-in-region beg end ?\^M ?\n t)
10380 (gnus-summary-position-point))))
10382 (defun gnus-summary-maybe-hide-threads ()
10383 "If requested, hide the threads that should be hidden."
10384 (when (and gnus-show-threads
10385 gnus-thread-hide-subtree)
10386 (gnus-summary-hide-all-threads
10387 (if (or (consp gnus-thread-hide-subtree)
10388 (gnus-functionp gnus-thread-hide-subtree))
10389 (gnus-make-predicate gnus-thread-hide-subtree)
10392 ;;; Hiding predicates.
10394 (defun gnus-article-unread-p (header)
10395 (memq (mail-header-number header) gnus-newsgroup-unreads))
10397 (defun gnus-article-unseen-p (header)
10398 (memq (mail-header-number header) gnus-newsgroup-unseen))
10400 (defun gnus-map-articles (predicate articles)
10401 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10402 (apply 'gnus-or (mapcar predicate
10403 (mapcar 'gnus-summary-article-header articles))))
10405 (defun gnus-summary-hide-all-threads (&optional predicate)
10406 "Hide all thread subtrees.
10407 If PREDICATE is supplied, threads that satisfy this predicate
10408 will not be hidden."
10411 (goto-char (point-min))
10414 (when (or (not predicate)
10416 predicate (gnus-summary-article-children)))
10417 (gnus-summary-hide-thread))
10418 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10419 (gnus-summary-position-point))
10421 (defun gnus-summary-hide-thread ()
10422 "Hide thread subtrees.
10423 If PREDICATE is supplied, threads that satisfy this predicate
10424 will not be hidden.
10425 Returns nil if no threads were there to be hidden."
10427 (let ((buffer-read-only nil)
10429 (article (gnus-summary-article-number)))
10431 ;; Go forward until either the buffer ends or the subthread
10433 (when (and (not (eobp))
10434 (or (zerop (gnus-summary-next-thread 1 t))
10435 (goto-char (point-max))))
10437 (if (and (> (point) start)
10438 (search-backward "\n" start t))
10440 (subst-char-in-region start (point) ?\n ?\^M)
10441 (gnus-summary-goto-subject article))
10445 (defun gnus-summary-go-to-next-thread (&optional previous)
10446 "Go to the same level (or less) next thread.
10447 If PREVIOUS is non-nil, go to previous thread instead.
10448 Return the article number moved to, or nil if moving was impossible."
10449 (let ((level (gnus-summary-thread-level))
10450 (way (if previous -1 1))
10453 (while (and (not (eobp))
10454 (< level (gnus-summary-thread-level)))
10455 (forward-line way))
10462 (gnus-summary-article-number)
10463 (goto-char beg)))))
10465 (defun gnus-summary-next-thread (n &optional silent)
10466 "Go to the same level next N'th thread.
10467 If N is negative, search backward instead.
10468 Returns the difference between N and the number of skips actually
10471 If SILENT, don't output messages."
10473 (let ((backward (< n 0))
10475 (while (and (> n 0)
10476 (gnus-summary-go-to-next-thread backward))
10479 (gnus-summary-position-point))
10480 (when (and (not silent) (/= 0 n))
10481 (gnus-message 7 "No more threads"))
10484 (defun gnus-summary-prev-thread (n)
10485 "Go to the same level previous N'th thread.
10486 Returns the difference between N and the number of skips actually
10489 (gnus-summary-next-thread (- n)))
10491 (defun gnus-summary-go-down-thread ()
10492 "Go down one level in the current thread."
10493 (let ((children (gnus-summary-article-children)))
10495 (gnus-summary-goto-subject (car children)))))
10497 (defun gnus-summary-go-up-thread ()
10498 "Go up one level in the current thread."
10499 (let ((parent (gnus-summary-article-parent)))
10501 (gnus-summary-goto-subject parent))))
10503 (defun gnus-summary-down-thread (n)
10504 "Go down thread N steps.
10505 If N is negative, go up instead.
10506 Returns the difference between N and how many steps down that were
10511 (while (and (> n 0)
10512 (if up (gnus-summary-go-up-thread)
10513 (gnus-summary-go-down-thread)))
10515 (gnus-summary-position-point)
10517 (gnus-message 7 "Can't go further"))
10520 (defun gnus-summary-up-thread (n)
10521 "Go up thread N steps.
10522 If N is negative, go down instead.
10523 Returns the difference between N and how many steps down that were
10526 (gnus-summary-down-thread (- n)))
10528 (defun gnus-summary-top-thread ()
10529 "Go to the top of the thread."
10531 (while (gnus-summary-go-up-thread))
10532 (gnus-summary-article-number))
10534 (defun gnus-summary-kill-thread (&optional unmark)
10535 "Mark articles under current thread as read.
10536 If the prefix argument is positive, remove any kinds of marks.
10537 If the prefix argument is negative, tick articles instead."
10540 (setq unmark (prefix-numeric-value unmark)))
10541 (let ((articles (gnus-summary-articles-in-thread)))
10543 ;; Expand the thread.
10544 (gnus-summary-show-thread)
10545 ;; Mark all the articles.
10547 (gnus-summary-goto-subject (car articles))
10548 (cond ((null unmark)
10549 (gnus-summary-mark-article-as-read gnus-killed-mark))
10551 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10553 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10554 (setq articles (cdr articles))))
10555 ;; Hide killed subtrees.
10557 gnus-thread-hide-killed
10558 (gnus-summary-hide-thread))
10559 ;; If marked as read, go to next unread subject.
10560 (when (null unmark)
10561 ;; Go to next unread subject.
10562 (gnus-summary-next-subject 1 t)))
10563 (gnus-set-mode-line 'summary))
10565 ;; Summary sorting commands
10567 (defun gnus-summary-sort-by-number (&optional reverse)
10568 "Sort the summary buffer by article number.
10569 Argument REVERSE means reverse order."
10571 (gnus-summary-sort 'number reverse))
10573 (defun gnus-summary-sort-by-random (&optional reverse)
10574 "Randomize the order in the summary buffer.
10575 Argument REVERSE means to randomize in reverse order."
10577 (gnus-summary-sort 'random reverse))
10579 (defun gnus-summary-sort-by-author (&optional reverse)
10580 "Sort the summary buffer by author name alphabetically.
10581 If `case-fold-search' is non-nil, case of letters is ignored.
10582 Argument REVERSE means reverse order."
10584 (gnus-summary-sort 'author reverse))
10586 (defun gnus-summary-sort-by-subject (&optional reverse)
10587 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10588 If `case-fold-search' is non-nil, case of letters is ignored.
10589 Argument REVERSE means reverse order."
10591 (gnus-summary-sort 'subject reverse))
10593 (defun gnus-summary-sort-by-date (&optional reverse)
10594 "Sort the summary buffer by date.
10595 Argument REVERSE means reverse order."
10597 (gnus-summary-sort 'date reverse))
10599 (defun gnus-summary-sort-by-score (&optional reverse)
10600 "Sort the summary buffer by score.
10601 Argument REVERSE means reverse order."
10603 (gnus-summary-sort 'score reverse))
10605 (defun gnus-summary-sort-by-lines (&optional reverse)
10606 "Sort the summary buffer by the number of lines.
10607 Argument REVERSE means reverse order."
10609 (gnus-summary-sort 'lines reverse))
10611 (defun gnus-summary-sort-by-chars (&optional reverse)
10612 "Sort the summary buffer by article length.
10613 Argument REVERSE means reverse order."
10615 (gnus-summary-sort 'chars reverse))
10617 (defun gnus-summary-sort-by-original (&optional reverse)
10618 "Sort the summary buffer using the default sorting method.
10619 Argument REVERSE means reverse order."
10621 (let* ((buffer-read-only)
10622 (gnus-summary-prepare-hook nil))
10623 ;; We do the sorting by regenerating the threads.
10624 (gnus-summary-prepare)
10625 ;; Hide subthreads if needed.
10626 (gnus-summary-maybe-hide-threads)))
10628 (defun gnus-summary-sort (predicate reverse)
10629 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10630 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10631 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10632 (gnus-thread-sort-functions
10637 (gnus-sort-gathered-threads-function
10638 gnus-thread-sort-functions)
10639 (gnus-article-sort-functions
10643 (,article t2 t1))))
10645 (gnus-summary-prepare-hook nil))
10646 ;; We do the sorting by regenerating the threads.
10647 (gnus-summary-prepare)
10648 ;; Hide subthreads if needed.
10649 (gnus-summary-maybe-hide-threads)))
10651 ;; Summary saving commands.
10653 (defun gnus-summary-save-article (&optional n not-saved)
10654 "Save the current article using the default saver function.
10655 If N is a positive number, save the N next articles.
10656 If N is a negative number, save the N previous articles.
10657 If N is nil and any articles have been marked with the process mark,
10658 save those articles instead.
10659 The variable `gnus-default-article-saver' specifies the saver function."
10661 (let* ((articles (gnus-summary-work-articles n))
10662 (save-buffer (save-excursion
10663 (nnheader-set-temp-buffer " *Gnus Save*")))
10664 (num (length articles))
10666 (dolist (article articles)
10667 (setq header (gnus-summary-article-header article))
10668 (if (not (vectorp header))
10669 ;; This is a pseudo-article.
10670 (if (assq 'name header)
10671 (gnus-copy-file (cdr (assq 'name header)))
10672 (gnus-message 1 "Article %d is unsaveable" article))
10673 ;; This is a real article.
10674 (save-window-excursion
10675 (let ((gnus-display-mime-function nil)
10676 (gnus-article-prepare-hook nil))
10677 (gnus-summary-select-article t nil nil article)))
10679 (set-buffer save-buffer)
10681 (insert-buffer-substring gnus-original-article-buffer))
10682 (setq file (gnus-article-save save-buffer file num))
10683 (gnus-summary-remove-process-mark article)
10685 (gnus-summary-set-saved-mark article))))
10686 (gnus-kill-buffer save-buffer)
10687 (gnus-summary-position-point)
10688 (gnus-set-mode-line 'summary)
10691 (defun gnus-summary-pipe-output (&optional arg headers)
10692 "Pipe the current article to a subprocess.
10693 If N is a positive number, pipe the N next articles.
10694 If N is a negative number, pipe the N previous articles.
10695 If N is nil and any articles have been marked with the process mark,
10696 pipe those articles instead.
10697 If HEADERS (the symbolic prefix), include the headers, too."
10698 (interactive (gnus-interactive "P\ny"))
10699 (require 'gnus-art)
10700 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10701 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10702 (gnus-summary-save-article arg t))
10703 (let ((buffer (get-buffer "*Shell Command Output*")))
10705 (not (zerop (buffer-size buffer))))
10706 (gnus-configure-windows 'pipe))))
10708 (defun gnus-summary-save-article-mail (&optional arg)
10709 "Append the current article to an mail file.
10710 If N is a positive number, save the N next articles.
10711 If N is a negative number, save the N previous articles.
10712 If N is nil and any articles have been marked with the process mark,
10713 save those articles instead."
10715 (require 'gnus-art)
10716 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10717 (gnus-summary-save-article arg)))
10719 (defun gnus-summary-save-article-rmail (&optional arg)
10720 "Append the current article to an rmail file.
10721 If N is a positive number, save the N next articles.
10722 If N is a negative number, save the N previous articles.
10723 If N is nil and any articles have been marked with the process mark,
10724 save those articles instead."
10726 (require 'gnus-art)
10727 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10728 (gnus-summary-save-article arg)))
10730 (defun gnus-summary-save-article-file (&optional arg)
10731 "Append the current article to a file.
10732 If N is a positive number, save the N next articles.
10733 If N is a negative number, save the N previous articles.
10734 If N is nil and any articles have been marked with the process mark,
10735 save those articles instead."
10737 (require 'gnus-art)
10738 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10739 (gnus-summary-save-article arg)))
10741 (defun gnus-summary-write-article-file (&optional arg)
10742 "Write the current article to a file, deleting the previous file.
10743 If N is a positive number, save the N next articles.
10744 If N is a negative number, save the N previous articles.
10745 If N is nil and any articles have been marked with the process mark,
10746 save those articles instead."
10748 (require 'gnus-art)
10749 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10750 (gnus-summary-save-article arg)))
10752 (defun gnus-summary-save-article-body-file (&optional arg)
10753 "Append the current article body to a file.
10754 If N is a positive number, save the N next articles.
10755 If N is a negative number, save the N previous articles.
10756 If N is nil and any articles have been marked with the process mark,
10757 save those articles instead."
10759 (require 'gnus-art)
10760 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10761 (gnus-summary-save-article arg)))
10763 (defun gnus-summary-muttprint (&optional arg)
10764 "Print the current article using Muttprint.
10765 If N is a positive number, save the N next articles.
10766 If N is a negative number, save the N previous articles.
10767 If N is nil and any articles have been marked with the process mark,
10768 save those articles instead."
10770 (require 'gnus-art)
10771 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10772 (gnus-summary-save-article arg t)))
10774 (defun gnus-summary-pipe-message (program)
10775 "Pipe the current article through PROGRAM."
10776 (interactive "sProgram: ")
10777 (gnus-summary-select-article)
10778 (let ((mail-header-separator ""))
10779 (gnus-eval-in-buffer-window gnus-article-buffer
10782 (let ((start (window-start))
10784 (message-pipe-buffer-body program)
10785 (set-window-start (get-buffer-window (current-buffer)) start))))))
10787 (defun gnus-get-split-value (methods)
10788 "Return a value based on the split METHODS."
10789 (let (split-name method result match)
10792 (set-buffer gnus-original-article-buffer)
10794 (nnheader-narrow-to-headers)
10795 (while (and methods (not split-name))
10796 (goto-char (point-min))
10797 (setq method (pop methods))
10798 (setq match (car method))
10801 ;; Regular expression.
10803 (re-search-forward match nil t)))
10804 ((gnus-functionp match)
10808 (setq result (funcall match gnus-newsgroup-name))))
10813 (setq result (eval match)))))
10814 (setq split-name (cdr method))
10815 (cond ((stringp result)
10816 (push (expand-file-name
10817 result gnus-article-save-directory)
10820 (setq split-name (append result split-name)))))))))
10821 (nreverse split-name)))
10823 (defun gnus-valid-move-group-p (group)
10824 (and (boundp group)
10825 (symbol-name group)
10826 (symbol-value group)
10827 (gnus-get-function (gnus-find-method-for-group
10828 (symbol-name group)) 'request-accept-article t)))
10830 (defun gnus-read-move-group-name (prompt default articles prefix)
10831 "Read a group name."
10832 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10833 (minibuffer-confirm-incomplete nil) ; XEmacs
10835 (format "%s %s to:"
10837 (if (> (length articles) 1)
10838 (format "these %d articles" (length articles))
10843 (gnus-completing-read-with-default
10846 'gnus-valid-move-group-p
10848 'gnus-group-history))
10849 ((= 1 (length split-name))
10850 (gnus-completing-read-with-default
10851 (car split-name) prom
10853 'gnus-valid-move-group-p
10855 'gnus-group-history))
10857 (gnus-completing-read-with-default
10859 (mapcar (lambda (el) (list el))
10860 (nreverse split-name))
10862 'gnus-group-history))))
10863 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10865 (if (or (string= to-newsgroup "")
10866 (string= to-newsgroup prefix))
10867 (setq to-newsgroup default))
10868 (unless to-newsgroup
10869 (error "No group name entered"))
10870 (or (gnus-active to-newsgroup)
10871 (gnus-activate-group to-newsgroup nil nil to-method)
10872 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10874 (or (and (gnus-request-create-group to-newsgroup to-method)
10875 (gnus-activate-group
10876 to-newsgroup nil nil to-method)
10877 (gnus-subscribe-group to-newsgroup))
10878 (error "Couldn't create group %s" to-newsgroup)))
10879 (error "No such group: %s" to-newsgroup)))
10882 (defun gnus-summary-save-parts (type dir n &optional reverse)
10883 "Save parts matching TYPE to DIR.
10884 If REVERSE, save parts that do not match TYPE."
10886 (list (read-string "Save parts of type: "
10887 (or (car gnus-summary-save-parts-type-history)
10888 gnus-summary-save-parts-default-mime)
10889 'gnus-summary-save-parts-type-history)
10890 (setq gnus-summary-save-parts-last-directory
10891 (read-file-name "Save to directory: "
10892 gnus-summary-save-parts-last-directory
10894 current-prefix-arg))
10895 (gnus-summary-iterate n
10896 (let ((gnus-display-mime-function nil)
10897 (gnus-inhibit-treatment t))
10898 (gnus-summary-select-article))
10900 (set-buffer gnus-article-buffer)
10901 (let ((handles (or gnus-article-mime-handles
10902 (mm-dissect-buffer nil gnus-article-loose-mime)
10903 (and gnus-article-emulate-mime
10904 (mm-uu-dissect)))))
10906 (gnus-summary-save-parts-1 type dir handles reverse)
10907 (unless gnus-article-mime-handles ;; Don't destroy this case.
10908 (mm-destroy-parts handles)))))))
10910 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10911 (if (stringp (car handle))
10912 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10915 (not (string-match type (mm-handle-media-type handle)))
10916 (string-match type (mm-handle-media-type handle)))
10917 (let ((file (expand-file-name
10918 (file-name-nondirectory
10920 (mail-content-type-get
10921 (mm-handle-disposition handle) 'filename)
10922 (concat gnus-newsgroup-name
10923 "." (number-to-string
10924 (cdr gnus-article-current)))))
10926 (unless (file-exists-p file)
10927 (mm-save-part-to-file handle file))))))
10929 ;; Summary extract commands
10931 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10932 (let ((buffer-read-only nil)
10933 (article (gnus-summary-article-number))
10935 (unless (gnus-summary-goto-subject article)
10936 (error "No such article: %d" article))
10937 (gnus-summary-position-point)
10938 ;; If all commands are to be bunched up on one line, we collect
10940 (unless gnus-view-pseudos-separately
10941 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10944 (setq action (cdr (assq 'action (car ps))))
10945 (setq files (list (cdr (assq 'name (car ps)))))
10946 (while (and ps (cdr ps)
10947 (string= (or action "1")
10948 (or (cdr (assq 'action (cadr ps))) "2")))
10949 (push (cdr (assq 'name (cadr ps))) files)
10950 (setcdr ps (cddr ps)))
10952 (when (not (string-match "%s" action))
10955 (when (assq 'execute (car ps))
10956 (setcdr (assq 'execute (car ps))
10957 (funcall (if (string-match "%s" action)
10966 (setq ps (cdr ps)))))
10967 (if (and gnus-view-pseudos (not not-view))
10969 (when (assq 'execute (car pslist))
10970 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10971 (eq gnus-view-pseudos 'not-confirm)))
10972 (setq pslist (cdr pslist)))
10975 (setq after-article (or (cdr (assq 'article (car pslist)))
10976 (gnus-summary-article-number)))
10977 (gnus-summary-goto-subject after-article)
10980 (insert " " (file-name-nondirectory
10981 (cdr (assq 'name (car pslist))))
10982 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10984 (forward-line -1) ; back to `b'
10985 (gnus-add-text-properties
10986 b (1- e) (list 'gnus-number gnus-reffed-article-number
10987 gnus-mouse-face-prop gnus-mouse-face))
10989 after-article gnus-reffed-article-number
10990 gnus-unread-mark b (car pslist) 0 (- e b))
10991 (setq gnus-newsgroup-unreads
10992 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10993 gnus-reffed-article-number))
10994 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10995 (setq pslist (cdr pslist)))))))
10997 (defun gnus-pseudos< (p1 p2)
10998 (let ((c1 (cdr (assq 'action p1)))
10999 (c2 (cdr (assq 'action p2))))
11000 (and c1 c2 (string< c1 c2))))
11002 (defun gnus-request-pseudo-article (props)
11003 (cond ((assq 'execute props)
11004 (gnus-execute-command (cdr (assq 'execute props)))))
11005 (let ((gnus-current-article (gnus-summary-article-number)))
11006 (gnus-run-hooks 'gnus-mark-article-hook)))
11008 (defun gnus-execute-command (command &optional automatic)
11010 (gnus-article-setup-buffer)
11011 (set-buffer gnus-article-buffer)
11012 (setq buffer-read-only nil)
11013 (let ((command (if automatic command
11014 (read-string "Command: " (cons command 0)))))
11016 (insert "$ " command "\n\n")
11017 (if gnus-view-pseudo-asynchronously
11018 (start-process "gnus-execute" (current-buffer) shell-file-name
11019 shell-command-switch command)
11020 (call-process shell-file-name nil t nil
11021 shell-command-switch command)))))
11023 ;; Summary kill commands.
11025 (defun gnus-summary-edit-global-kill (article)
11026 "Edit the \"global\" kill file."
11027 (interactive (list (gnus-summary-article-number)))
11028 (gnus-group-edit-global-kill article))
11030 (defun gnus-summary-edit-local-kill ()
11031 "Edit a local kill file applied to the current newsgroup."
11033 (setq gnus-current-headers (gnus-summary-article-header))
11034 (gnus-group-edit-local-kill
11035 (gnus-summary-article-number) gnus-newsgroup-name))
11037 ;;; Header reading.
11039 (defun gnus-read-header (id &optional header)
11040 "Read the headers of article ID and enter them into the Gnus system."
11041 (let ((group gnus-newsgroup-name)
11042 (gnus-override-method
11044 gnus-override-method
11045 (and (gnus-news-group-p gnus-newsgroup-name)
11046 (car (gnus-refer-article-methods)))))
11048 ;; First we check to see whether the header in question is already
11051 ;; This is a Message-ID.
11052 (setq header (or header (gnus-id-to-header id)))
11053 ;; This is an article number.
11054 (setq header (or header (gnus-summary-article-header id))))
11056 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11057 ;; We have found the header.
11059 ;; If this is a sparse article, we have to nix out its
11060 ;; previous entry in the thread hashtb.
11062 (gnus-summary-article-sparse-p (mail-header-number header)))
11063 (let* ((parent (gnus-parent-id (mail-header-references header)))
11064 (thread (and parent (gnus-id-to-thread parent))))
11066 (delq (assq header thread) thread))))
11067 ;; We have to really fetch the header to this article.
11069 (set-buffer nntp-server-buffer)
11070 (when (setq where (gnus-request-head id group))
11071 (nnheader-fold-continuation-lines)
11072 (goto-char (point-max))
11074 (goto-char (point-min))
11078 ((cdr where) (cdr where))
11079 (header (mail-header-number header))
11080 (t gnus-reffed-article-number))
11082 (insert " Article retrieved.\n"))
11083 (if (or (not where)
11084 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11085 () ; Malformed head.
11086 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11087 (when (and (stringp id)
11088 (not (string= (gnus-group-real-name group)
11090 ;; If we fetched by Message-ID and the article came
11091 ;; from a different group, we fudge some bogus article
11092 ;; numbers for this article.
11093 (mail-header-set-number header gnus-reffed-article-number))
11095 (set-buffer gnus-summary-buffer)
11096 (decf gnus-reffed-article-number)
11097 (gnus-remove-header (mail-header-number header))
11098 (push header gnus-newsgroup-headers)
11099 (setq gnus-current-headers header)
11100 (push (mail-header-number header) gnus-newsgroup-limit)))
11103 (defun gnus-remove-header (number)
11104 "Remove header NUMBER from `gnus-newsgroup-headers'."
11105 (if (and gnus-newsgroup-headers
11106 (= number (mail-header-number (car gnus-newsgroup-headers))))
11107 (pop gnus-newsgroup-headers)
11108 (let ((headers gnus-newsgroup-headers))
11109 (while (and (cdr headers)
11110 (not (= number (mail-header-number (cadr headers)))))
11112 (when (cdr headers)
11113 (setcdr headers (cddr headers))))))
11116 ;;; summary highlights
11119 (defun gnus-highlight-selected-summary ()
11120 "Highlight selected article in summary buffer."
11121 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11122 (when gnus-summary-selected-face
11124 (let* ((beg (gnus-point-at-bol))
11125 (end (gnus-point-at-eol))
11126 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11127 (from (if (get-text-property beg gnus-mouse-face-prop)
11129 (or (next-single-property-change
11130 beg gnus-mouse-face-prop nil end)
11135 (or (next-single-property-change
11136 from gnus-mouse-face-prop nil end)
11138 ;; If no mouse-face prop on line we will have to = from = end,
11139 ;; so we highlight the entire line instead.
11140 (when (= (+ to 2) from)
11143 (if gnus-newsgroup-selected-overlay
11144 ;; Move old overlay.
11146 gnus-newsgroup-selected-overlay from to (current-buffer))
11147 ;; Create new overlay.
11149 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11150 'face gnus-summary-selected-face))))))
11152 (defvar gnus-summary-highlight-line-cached nil)
11153 (defvar gnus-summary-highlight-line-trigger nil)
11155 (defun gnus-summary-highlight-line-0 ()
11156 (if (and (eq gnus-summary-highlight-line-trigger
11157 gnus-summary-highlight)
11158 gnus-summary-highlight-line-cached)
11159 gnus-summary-highlight-line-cached
11160 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11161 gnus-summary-highlight-line-cached
11162 (let* ((cond (list 'cond))
11164 (list gnus-summary-highlight))
11166 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11170 (gnus-byte-compile (list 'lambda nil cond))))))
11172 (defun gnus-summary-highlight-line ()
11173 "Highlight current line according to `gnus-summary-highlight'."
11174 (let* ((beg (gnus-point-at-bol))
11175 (article (or (gnus-summary-article-number) gnus-current-article))
11176 (score (or (cdr (assq article
11177 gnus-newsgroup-scored))
11178 gnus-summary-default-score 0))
11179 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11180 (inhibit-read-only t)
11181 (default gnus-summary-default-score)
11182 (default-high gnus-summary-default-high-score)
11183 (default-low gnus-summary-default-low-score)
11184 (uncached (memq article gnus-newsgroup-undownloaded))
11185 (downloaded (not uncached)))
11186 (let ((face (funcall (gnus-summary-highlight-line-0))))
11187 (unless (eq face (get-text-property beg 'face))
11188 (gnus-put-text-property-excluding-characters-with-faces
11189 beg (gnus-point-at-eol) 'face
11190 (setq face (if (boundp face) (symbol-value face) face)))
11191 (when gnus-summary-highlight-line-function
11192 (funcall gnus-summary-highlight-line-function article face))))))
11194 (defun gnus-update-read-articles (group unread &optional compute)
11195 "Update the list of read articles in GROUP.
11196 UNREAD is a sorted list."
11197 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11198 (entry (gnus-gethash group gnus-newsrc-hashtb))
11199 (info (nth 2 entry))
11202 (if (or (not info) (not active))
11203 ;; There is no info on this group if it was, in fact,
11204 ;; killed. Gnus stores no information on killed groups, so
11205 ;; there's nothing to be done.
11206 ;; One could store the information somewhere temporarily,
11207 ;; perhaps... Hmmm...
11209 ;; Remove any negative articles numbers.
11210 (while (and unread (< (car unread) 0))
11211 (setq unread (cdr unread)))
11212 ;; Remove any expired article numbers
11213 (while (and unread (< (car unread) (car active)))
11214 (setq unread (cdr unread)))
11215 ;; Compute the ranges of read articles by looking at the list of
11216 ;; unread articles.
11218 (when (/= (car unread) prev)
11219 (push (if (= prev (1- (car unread))) prev
11220 (cons prev (1- (car unread))))
11222 (setq prev (1+ (car unread)))
11223 (setq unread (cdr unread)))
11224 (when (<= prev (cdr active))
11225 (push (cons prev (cdr active)) read))
11226 (setq read (if (> (length read) 1) (nreverse read) read))
11231 ;; Propagate the read marks to the backend.
11232 (when (gnus-check-backend-function 'request-set-mark group)
11233 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11234 (add (gnus-remove-from-range read (gnus-info-read info))))
11236 (unless (gnus-check-group group)
11237 (error "Can't open server for %s" group))
11238 (gnus-request-set-mark
11239 group (delq nil (list (if add (list add 'add '(read)))
11240 (if del (list del 'del '(read))))))
11242 `(gnus-request-set-mark
11245 (if del (list del 'add '(read)))
11246 (if add (list add 'del '(read))))))))))
11247 (set-buffer gnus-group-buffer)
11248 (gnus-undo-register
11250 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11251 (gnus-info-set-read ',info ',(gnus-info-read info))
11252 (gnus-get-unread-articles-in-group ',info
11253 (gnus-active ,group))
11254 (gnus-group-update-group ,group t)
11256 ;; Enter this list into the group info.
11257 (gnus-info-set-read info read)
11258 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11259 (gnus-get-unread-articles-in-group info (gnus-active group))
11262 (defun gnus-offer-save-summaries ()
11263 "Offer to save all active summary buffers."
11265 ;; Go through all buffers and find all summaries.
11266 (dolist (buffer (buffer-list))
11267 (when (and (setq buffer (buffer-name buffer))
11268 (string-match "Summary" buffer)
11270 (set-buffer buffer)
11271 ;; We check that this is, indeed, a summary buffer.
11272 (and (eq major-mode 'gnus-summary-mode)
11273 ;; Also make sure this isn't bogus.
11274 gnus-newsgroup-prepared
11275 ;; Also make sure that this isn't a
11276 ;; dead summary buffer.
11277 (not gnus-dead-summary-mode))))
11278 (push buffer buffers)))
11279 ;; Go through all these summary buffers and offer to save them.
11283 "Update summary buffer %s? "
11285 (switch-to-buffer buf)
11286 (gnus-summary-exit))
11289 (defun gnus-summary-setup-default-charset ()
11290 "Setup newsgroup default charset."
11291 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11292 (setq gnus-newsgroup-charset nil)
11293 (let* ((ignored-charsets
11294 (or gnus-newsgroup-ephemeral-ignored-charsets
11296 (and gnus-newsgroup-name
11297 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11298 gnus-newsgroup-ignored-charsets))))
11299 (setq gnus-newsgroup-charset
11300 (or gnus-newsgroup-ephemeral-charset
11301 (and gnus-newsgroup-name
11302 (gnus-parameter-charset gnus-newsgroup-name))
11303 gnus-default-charset))
11304 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11305 ignored-charsets))))
11311 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11312 "Display the current article buffer fully MIME-buttonized.
11313 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11314 treated as multipart/mixed."
11316 (require 'gnus-art)
11317 (let ((gnus-unbuttonized-mime-types nil)
11318 (gnus-mime-display-multipart-as-mixed show-all-parts))
11319 (gnus-summary-show-article)))
11321 (defun gnus-summary-repair-multipart (article)
11322 "Add a Content-Type header to a multipart article without one."
11323 (interactive (list (gnus-summary-article-number)))
11324 (gnus-with-article article
11325 (message-narrow-to-head)
11326 (message-remove-header "Mime-Version")
11327 (goto-char (point-max))
11328 (insert "Mime-Version: 1.0\n")
11330 (when (search-forward "\n--" nil t)
11331 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11332 (message-narrow-to-head)
11333 (message-remove-header "Content-Type")
11334 (goto-char (point-max))
11335 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11338 (let (gnus-mark-article-hook)
11339 (gnus-summary-select-article t t nil article)))
11341 (defun gnus-summary-toggle-display-buttonized ()
11342 "Toggle the buttonizing of the article buffer."
11344 (require 'gnus-art)
11345 (if (setq gnus-inhibit-mime-unbuttonizing
11346 (not gnus-inhibit-mime-unbuttonizing))
11347 (let ((gnus-unbuttonized-mime-types nil))
11348 (gnus-summary-show-article))
11349 (gnus-summary-show-article)))
11352 ;;; Generic summary marking commands
11355 (defvar gnus-summary-marking-alist
11356 '((read gnus-del-mark "d")
11357 (unread gnus-unread-mark "u")
11358 (ticked gnus-ticked-mark "!")
11359 (dormant gnus-dormant-mark "?")
11360 (expirable gnus-expirable-mark "e"))
11361 "An alist of names/marks/keystrokes.")
11363 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11364 (defvar gnus-summary-mark-map)
11366 (defun gnus-summary-make-all-marking-commands ()
11367 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11368 (dolist (elem gnus-summary-marking-alist)
11369 (apply 'gnus-summary-make-marking-command elem)))
11371 (defun gnus-summary-make-marking-command (name mark keystroke)
11372 (let ((map (make-sparse-keymap)))
11373 (define-key gnus-summary-generic-mark-map keystroke map)
11374 (dolist (lway `((next "next" next nil "n")
11375 (next-unread "next unread" next t "N")
11376 (prev "previous" prev nil "p")
11377 (prev-unread "previous unread" prev t "P")
11378 (nomove "" nil nil ,keystroke)))
11379 (let ((func (gnus-summary-make-marking-command-1
11380 mark (car lway) lway name)))
11381 (setq func (eval func))
11382 (define-key map (nth 4 lway) func)))))
11384 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11386 (format "gnus-summary-put-mark-as-%s%s"
11387 name (if (eq way 'nomove)
11389 (concat "-" (symbol-name way)))))
11392 "Mark the current article as %s%s.
11393 If N, the prefix, then repeat N times.
11394 If N is negative, move in reverse order.
11395 The difference between N and the actual number of articles marked is
11399 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11401 (defun gnus-summary-generic-mark (n mark move unread)
11402 "Mark N articles with MARK."
11403 (unless (eq major-mode 'gnus-summary-mode)
11404 (error "This command can only be used in the summary buffer"))
11405 (gnus-summary-show-thread)
11408 ((eq move 'next) 1)
11409 ((eq move 'prev) -1)
11411 (if (zerop nummove)
11415 nummove (* -1 nummove))))
11416 (while (and (> n 0)
11417 (gnus-summary-mark-article nil mark)
11418 (zerop (gnus-summary-next-subject nummove unread t)))
11421 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11422 (gnus-summary-recenter)
11423 (gnus-summary-position-point)
11424 (gnus-set-mode-line 'summary)
11427 (defun gnus-summary-insert-articles (articles)
11428 (when (setq articles
11429 (gnus-sorted-difference articles
11430 (mapcar (lambda (h)
11431 (mail-header-number h))
11432 gnus-newsgroup-headers)))
11433 (setq gnus-newsgroup-headers
11435 gnus-newsgroup-headers
11436 (gnus-fetch-headers articles)
11437 'gnus-article-sort-by-number))
11438 ;; Suppress duplicates?
11439 (when gnus-suppress-duplicates
11440 (gnus-dup-suppress-articles))
11442 ;; We might want to build some more threads first.
11443 (when (and gnus-fetch-old-headers
11444 (eq gnus-headers-retrieved-by 'nov))
11445 (if (eq gnus-fetch-old-headers 'invisible)
11446 (gnus-build-all-threads)
11447 (gnus-build-old-threads)))
11448 ;; Let the Gnus agent mark articles as read.
11450 (gnus-agent-get-undownloaded-list))
11451 ;; Remove list identifiers from subject
11452 (when gnus-list-identifiers
11453 (gnus-summary-remove-list-identifiers))
11454 ;; First and last article in this newsgroup.
11455 (when gnus-newsgroup-headers
11456 (setq gnus-newsgroup-begin
11457 (mail-header-number (car gnus-newsgroup-headers))
11459 (mail-header-number
11460 (gnus-last-element gnus-newsgroup-headers))))
11461 (when gnus-use-scoring
11462 (gnus-possibly-score-headers))))
11464 (defun gnus-summary-insert-old-articles (&optional all)
11465 "Insert all old articles in this group.
11466 If ALL is non-nil, already read articles become readable.
11467 If ALL is a number, fetch this number of articles."
11470 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11473 ;; Some nntp servers lie about their active range. When
11474 ;; this happens, the active range can be in the millions.
11475 ;; Use a compressed range to avoid creating a huge list.
11476 (gnus-range-difference (list gnus-newsgroup-active) old))
11477 (setq len (gnus-range-length older))
11482 (let ((older-range (nreverse older)))
11486 (let* ((r (pop older-range))
11487 (min (if (numberp r) r (car r)))
11488 (max (if (numberp r) r (cdr r))))
11489 (while (and (<= min max)
11494 (setq older (gnus-uncompress-range older))))
11496 (setq older (gnus-uncompress-range older)))
11498 (when (and (numberp gnus-large-newsgroup)
11499 (> len gnus-large-newsgroup))
11500 (let* ((cursor-in-echo-area nil)
11501 (initial (gnus-parameter-large-newsgroup-initial
11502 gnus-newsgroup-name))
11506 "How many articles from %s (%s %d): "
11508 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11509 (if initial "max" "default")
11512 (cons (number-to-string initial)
11514 (unless (string-match "^[ \t]*$" input)
11515 (setq all (string-to-number input))
11517 (let ((older-range (nreverse older)))
11521 (let* ((r (pop older-range))
11522 (min (if (numberp r) r (car r)))
11523 (max (if (numberp r) r (cdr r))))
11524 (while (and (<= min max)
11528 max (1- max))))))))))
11529 (setq older (gnus-uncompress-range older))))
11531 (message "No old news.")
11532 (gnus-summary-insert-articles older)
11533 (gnus-summary-limit (gnus-sorted-nunion old older))))
11534 (gnus-summary-position-point)))
11536 (defun gnus-summary-insert-new-articles ()
11537 "Insert all new articles in this group."
11540 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11541 (old-active gnus-newsgroup-active)
11542 (nnmail-fetched-sources (list t))
11544 (setq gnus-newsgroup-active
11545 (gnus-activate-group gnus-newsgroup-name 'scan))
11546 (setq i (cdr gnus-newsgroup-active))
11547 (while (> i (cdr old-active))
11551 (message "No gnus is bad news.")
11552 (gnus-summary-insert-articles new)
11553 (setq gnus-newsgroup-unreads
11554 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11555 (gnus-summary-limit (gnus-sorted-nunion old new))))
11556 (gnus-summary-position-point)))
11558 (gnus-summary-make-all-marking-commands)
11560 (gnus-ems-redefine)
11562 (provide 'gnus-sum)
11564 (run-hooks 'gnus-sum-load-hook)
11566 ;; Local Variables:
11567 ;; coding: iso-8859-1
11570 ;;; gnus-sum.el ends here