1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
33 (defvar tool-bar-map))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
57 (autoload 'mm-uu-dissect "mm-uu")
58 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
59 "Deuglify broken Outlook (Express) articles and redisplay."
61 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
62 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
63 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-fetch-old-headers nil
73 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
74 If an unread article in the group refers to an older, already read (or
75 just marked as read) article, the old article will not normally be
76 displayed in the Summary buffer. If this variable is non-nil, Gnus
77 will attempt to grab the headers to the old articles, and thereby
78 build complete threads. If it has the value `some', only enough
79 headers to connect otherwise loose threads will be displayed. This
80 variable can also be a number. In that case, no more than that number
81 of old headers will be fetched. If it has the value `invisible', all
82 old headers will be fetched, but none will be displayed.
84 The server has to support NOV for any of this to work."
86 :type '(choice (const :tag "off" nil)
89 (sexp :menu-tag "other" t)))
91 (defcustom gnus-refer-thread-limit 200
92 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
93 If t, fetch all the available old headers."
96 (sexp :menu-tag "other" t)))
98 (defcustom gnus-summary-make-false-root 'adopt
99 "*nil means that Gnus won't gather loose threads.
100 If the root of a thread has expired or been read in a previous
101 session, the information necessary to build a complete thread has been
102 lost. Instead of having many small sub-threads from this original thread
103 scattered all over the summary buffer, Gnus can gather them.
105 If non-nil, Gnus will try to gather all loose sub-threads from an
106 original thread into one large thread.
108 If this variable is non-nil, it should be one of `none', `adopt',
111 If this variable is `none', Gnus will not make a false root, but just
112 present the sub-threads after another.
113 If this variable is `dummy', Gnus will create a dummy root that will
114 have all the sub-threads as children.
115 If this variable is `adopt', Gnus will make one of the \"children\"
116 the parent and mark all the step-children as such.
117 If this variable is `empty', the \"children\" are printed with empty
118 subject fields. (Or rather, they will be printed with a string
119 given by the `gnus-summary-same-subject' variable.)"
121 :type '(choice (const :tag "off" nil)
127 (defcustom gnus-summary-make-false-root-always nil
128 "Always make a false dummy root."
132 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
133 "*A regexp to match subjects to be excluded from loose thread gathering.
134 As loose thread gathering is done on subjects only, that means that
135 there can be many false gatherings performed. By rooting out certain
136 common subjects, gathering might become saner."
140 (defcustom gnus-summary-gather-subject-limit nil
141 "*Maximum length of subject comparisons when gathering loose threads.
142 Use nil to compare full subjects. Setting this variable to a low
143 number will help gather threads that have been corrupted by
144 newsreaders chopping off subject lines, but it might also mean that
145 unrelated articles that have subject that happen to begin with the
146 same few characters will be incorrectly gathered.
148 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
151 :type '(choice (const :tag "off" nil)
153 (sexp :menu-tag "on" t)))
155 (defcustom gnus-simplify-subject-functions nil
156 "List of functions taking a string argument that simplify subjects.
157 The functions are applied recursively.
159 Useful functions to put in this list include:
160 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
161 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
163 :type '(repeat function))
165 (defcustom gnus-simplify-ignored-prefixes nil
166 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
168 :type '(choice (const :tag "off" nil)
171 (defcustom gnus-build-sparse-threads nil
172 "*If non-nil, fill in the gaps in threads.
173 If `some', only fill in the gaps that are needed to tie loose threads
174 together. If `more', fill in all leaf nodes that Gnus can find. If
175 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
177 :type '(choice (const :tag "off" nil)
180 (sexp :menu-tag "all" t)))
182 (defcustom gnus-summary-thread-gathering-function
183 'gnus-gather-threads-by-subject
184 "*Function used for gathering loose threads.
185 There are two pre-defined functions: `gnus-gather-threads-by-subject',
186 which only takes Subjects into consideration; and
187 `gnus-gather-threads-by-references', which compared the References
188 headers of the articles to find matches."
190 :type '(radio (function-item gnus-gather-threads-by-subject)
191 (function-item gnus-gather-threads-by-references)
192 (function :tag "other")))
194 (defcustom gnus-summary-same-subject ""
195 "*String indicating that the current article has the same subject as the previous.
196 This variable will only be used if the value of
197 `gnus-summary-make-false-root' is `empty'."
198 :group 'gnus-summary-format
201 (defcustom gnus-summary-goto-unread t
202 "*If t, many commands will go to the next unread article.
203 This applies to marking commands as well as other commands that
204 \"naturally\" select the next article, like, for instance, `SPC' at
205 the end of an article.
207 If nil, the marking commands do NOT go to the next unread article
208 \(they go to the next article instead). If `never', commands that
209 usually go to the next unread article, will go to the next article,
210 whether it is read or not."
211 :group 'gnus-summary-marks
212 :link '(custom-manual "(gnus)Setting Marks")
213 :type '(choice (const :tag "off" nil)
215 (sexp :menu-tag "on" t)))
217 (defcustom gnus-summary-default-score 0
218 "*Default article score level.
219 All scores generated by the score files will be added to this score.
220 If this variable is nil, scoring will be disabled."
221 :group 'gnus-score-default
222 :type '(choice (const :tag "disable")
225 (defcustom gnus-summary-default-high-score 0
226 "*Default threshold for a high scored article.
227 An article will be highlighted as high scored if its score is greater
229 :group 'gnus-score-default
232 (defcustom gnus-summary-default-low-score 0
233 "*Default threshold for a low scored article.
234 An article will be highlighted as low scored if its score is smaller
236 :group 'gnus-score-default
239 (defcustom gnus-summary-zcore-fuzz 0
240 "*Fuzziness factor for the zcore in the summary buffer.
241 Articles with scores closer than this to `gnus-summary-default-score'
243 :group 'gnus-summary-format
246 (defcustom gnus-simplify-subject-fuzzy-regexp nil
247 "*Strings to be removed when doing fuzzy matches.
248 This can either be a regular expression or list of regular expressions
249 that will be removed from subject strings if fuzzy subject
250 simplification is selected."
252 :type '(repeat regexp))
254 (defcustom gnus-show-threads t
255 "*If non-nil, display threads in summary mode."
259 (defcustom gnus-thread-hide-subtree nil
260 "*If non-nil, hide all threads initially.
261 This can be a predicate specifier which says which threads to hide.
262 If threads are hidden, you have to run the command
263 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
264 to expose hidden threads."
266 :type '(radio (sexp :format "Non-nil\n"
267 :match (lambda (widget value)
268 (not (or (consp value) (functionp value))))
271 (sexp :tag "Predicate specifier" :size 0)))
273 (defcustom gnus-thread-hide-killed t
274 "*If non-nil, hide killed threads automatically."
278 (defcustom gnus-thread-ignore-subject t
279 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
280 If nil, articles that have different subjects from their parents will
281 start separate threads."
285 (defcustom gnus-thread-operation-ignore-subject t
286 "*If non-nil, subjects will be ignored when doing thread commands.
287 This affects commands like `gnus-summary-kill-thread' and
288 `gnus-summary-lower-thread'.
290 If this variable is nil, articles in the same thread with different
291 subjects will not be included in the operation in question. If this
292 variable is `fuzzy', only articles that have subjects that are fuzzily
293 equal will be included."
295 :type '(choice (const :tag "off" nil)
299 (defcustom gnus-thread-indent-level 4
300 "*Number that says how much each sub-thread should be indented."
304 (defcustom gnus-auto-extend-newsgroup t
305 "*If non-nil, extend newsgroup forward and backward when requested."
306 :group 'gnus-summary-choose
309 (defcustom gnus-auto-select-first t
310 "*If non-nil, select the article under point.
311 Which article this is is controlled by the `gnus-auto-select-subject'
314 If you want to prevent automatic selection of articles in some
315 newsgroups, set the variable to nil in `gnus-select-group-hook'."
316 :group 'gnus-group-select
317 :type '(choice (const :tag "none" nil)
318 (sexp :menu-tag "first" t)))
320 (defcustom gnus-auto-select-subject 'unread
321 "*Says what subject to place under point when entering a group.
323 This variable can either be the symbols `first' (place point on the
324 first subject), `unread' (place point on the subject line of the first
325 unread article), `best' (place point on the subject line of the
326 higest-scored article), `unseen' (place point on the subject line of
327 the first unseen article), 'unseen-or-unread' (place point on the subject
328 line of the first unseen article or, if all article have been seen, on the
329 subject line of the first unread article), or a function to be called to
330 place point on some subject line."
331 :group 'gnus-group-select
332 :type '(choice (const best)
336 (const unseen-or-unread)))
338 (defcustom gnus-dont-select-after-jump-to-other-group nil
339 "If non-nil, don't select the first unread article after entering the
340 other group by the command `gnus-summary-jump-to-other-group'. If nil,
341 it is depend on the value of `gnus-auto-select-first' whether to select
343 :group 'gnus-group-select
346 (defcustom gnus-auto-select-next t
347 "*If non-nil, offer to go to the next group from the end of the previous.
348 If the value is t and the next newsgroup is empty, Gnus will exit
349 summary mode and go back to group mode. If the value is neither nil
350 nor t, Gnus will select the following unread newsgroup. In
351 particular, if the value is the symbol `quietly', the next unread
352 newsgroup will be selected without any confirmation, and if it is
353 `almost-quietly', the next group will be selected without any
354 confirmation if you are located on the last article in the group.
355 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
356 will go to the next group without confirmation."
357 :group 'gnus-summary-maneuvering
358 :type '(choice (const :tag "off" nil)
360 (const almost-quietly)
361 (const slightly-quietly)
362 (sexp :menu-tag "on" t)))
364 (defcustom gnus-auto-select-same nil
365 "*If non-nil, select the next article with the same subject.
366 If there are no more articles with the same subject, go to
367 the first unread article."
368 :group 'gnus-summary-maneuvering
371 (defcustom gnus-auto-goto-ignores 'unfetched
372 "*Says how to handle unfetched articles when maneuvering.
374 This variable can either be the symbols nil (maneuver to any
375 article), `undownloaded' (maneuvering while unplugged ignores articles
376 that have not been fetched), `always-undownloaded' (maneuvering always
377 ignores articles that have not been fetched), `unfetched' (maneuvering
378 ignores articles whose headers have not been fetched).
380 NOTE: The list of unfetched articles will always be nil when plugged
381 and, when unplugged, a subset of the undownloaded article list."
382 :group 'gnus-summary-maneuvering
383 :type '(choice (const :tag "None" nil)
384 (const :tag "Undownloaded when unplugged" undownloaded)
385 (const :tag "Undownloaded" always-undownloaded)
386 (const :tag "Unfetched" unfetched)))
388 (defcustom gnus-summary-check-current nil
389 "*If non-nil, consider the current article when moving.
390 The \"unread\" movement commands will stay on the same line if the
391 current article is unread."
392 :group 'gnus-summary-maneuvering
395 (defcustom gnus-auto-center-summary t
396 "*If non-nil, always center the current summary buffer.
397 In particular, if `vertical' do only vertical recentering. If non-nil
398 and non-`vertical', do both horizontal and vertical recentering."
399 :group 'gnus-summary-maneuvering
400 :type '(choice (const :tag "none" nil)
402 (integer :tag "height")
403 (sexp :menu-tag "both" t)))
405 (defvar gnus-auto-center-group t
406 "*If non-nil, always center the group buffer.")
408 (defcustom gnus-show-all-headers nil
409 "*If non-nil, don't hide any headers."
410 :group 'gnus-article-hiding
411 :group 'gnus-article-headers
414 (defcustom gnus-summary-ignore-duplicates nil
415 "*If non-nil, ignore articles with identical Message-ID headers."
419 (defcustom gnus-single-article-buffer t
420 "*If non-nil, display all articles in the same buffer.
421 If nil, each group will get its own article buffer."
422 :group 'gnus-article-various
425 (defcustom gnus-break-pages t
426 "*If non-nil, do page breaking on articles.
427 The page delimiter is specified by the `gnus-page-delimiter'
429 :group 'gnus-article-various
432 (defcustom gnus-show-mime t
433 "*If non-nil, do mime processing of articles.
434 The articles will simply be fed to the function given by
435 `gnus-article-display-method-for-mime'."
436 :group 'gnus-article-mime
439 (defcustom gnus-move-split-methods nil
440 "*Variable used to suggest where articles are to be moved to.
441 It uses the same syntax as the `gnus-split-methods' variable.
442 However, whereas `gnus-split-methods' specifies file names as targets,
443 this variable specifies group names."
444 :group 'gnus-summary-mail
445 :type '(repeat (choice (list :value (fun) function)
446 (cons :value ("" "") regexp (repeat string))
449 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
450 "Function used to compute default prefix for article move/copy/etc prompts.
451 The function should take one argument, a group name, and return a
452 string with the suggested prefix."
453 :group 'gnus-summary-mail
456 (defcustom gnus-unread-mark ?\ ;;;Whitespace
457 "*Mark used for unread articles."
458 :group 'gnus-summary-marks
461 (defcustom gnus-ticked-mark ?!
462 "*Mark used for ticked articles."
463 :group 'gnus-summary-marks
466 (defcustom gnus-dormant-mark ??
467 "*Mark used for dormant articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-del-mark ?r
472 "*Mark used for del'd articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-read-mark ?R
477 "*Mark used for read articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-expirable-mark ?E
482 "*Mark used for expirable articles."
483 :group 'gnus-summary-marks
486 (defcustom gnus-killed-mark ?K
487 "*Mark used for killed articles."
488 :group 'gnus-summary-marks
491 (defcustom gnus-spam-mark ?$
492 "*Mark used for spam articles."
493 :group 'gnus-summary-marks
496 (defcustom gnus-souped-mark ?F
497 "*Mark used for souped articles."
498 :group 'gnus-summary-marks
501 (defcustom gnus-kill-file-mark ?X
502 "*Mark used for articles killed by kill files."
503 :group 'gnus-summary-marks
506 (defcustom gnus-low-score-mark ?Y
507 "*Mark used for articles with a low score."
508 :group 'gnus-summary-marks
511 (defcustom gnus-catchup-mark ?C
512 "*Mark used for articles that are caught up."
513 :group 'gnus-summary-marks
516 (defcustom gnus-replied-mark ?A
517 "*Mark used for articles that have been replied to."
518 :group 'gnus-summary-marks
521 (defcustom gnus-forwarded-mark ?F
522 "*Mark used for articles that have been forwarded."
523 :group 'gnus-summary-marks
526 (defcustom gnus-recent-mark ?N
527 "*Mark used for articles that are recent."
528 :group 'gnus-summary-marks
531 (defcustom gnus-cached-mark ?*
532 "*Mark used for articles that are in the cache."
533 :group 'gnus-summary-marks
536 (defcustom gnus-saved-mark ?S
537 "*Mark used for articles that have been saved."
538 :group 'gnus-summary-marks
541 (defcustom gnus-unseen-mark ?.
542 "*Mark used for articles that haven't been seen."
543 :group 'gnus-summary-marks
546 (defcustom gnus-no-mark ?\ ;;;Whitespace
547 "*Mark used for articles that have no other secondary mark."
548 :group 'gnus-summary-marks
551 (defcustom gnus-ancient-mark ?O
552 "*Mark used for ancient articles."
553 :group 'gnus-summary-marks
556 (defcustom gnus-sparse-mark ?Q
557 "*Mark used for sparsely reffed articles."
558 :group 'gnus-summary-marks
561 (defcustom gnus-canceled-mark ?G
562 "*Mark used for canceled articles."
563 :group 'gnus-summary-marks
566 (defcustom gnus-duplicate-mark ?M
567 "*Mark used for duplicate articles."
568 :group 'gnus-summary-marks
571 (defcustom gnus-undownloaded-mark ?-
572 "*Mark used for articles that weren't downloaded."
573 :group 'gnus-summary-marks
576 (defcustom gnus-downloaded-mark ?+
577 "*Mark used for articles that were downloaded."
578 :group 'gnus-summary-marks
581 (defcustom gnus-downloadable-mark ?%
582 "*Mark used for articles that are to be downloaded."
583 :group 'gnus-summary-marks
586 (defcustom gnus-unsendable-mark ?=
587 "*Mark used for articles that won't be sent."
588 :group 'gnus-summary-marks
591 (defcustom gnus-score-over-mark ?+
592 "*Score mark used for articles with high scores."
593 :group 'gnus-summary-marks
596 (defcustom gnus-score-below-mark ?-
597 "*Score mark used for articles with low scores."
598 :group 'gnus-summary-marks
601 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
602 "*There is no thread under the article."
603 :group 'gnus-summary-marks
606 (defcustom gnus-not-empty-thread-mark ?=
607 "*There is a thread under the article."
608 :group 'gnus-summary-marks
611 (defcustom gnus-view-pseudo-asynchronously nil
612 "*If non-nil, Gnus will view pseudo-articles asynchronously."
613 :group 'gnus-extract-view
616 (defcustom gnus-auto-expirable-marks
617 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
618 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
619 gnus-souped-mark gnus-duplicate-mark)
620 "*The list of marks converted into expiration if a group is auto-expirable."
623 :type '(repeat character))
625 (defcustom gnus-inhibit-user-auto-expire t
626 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
631 (defcustom gnus-view-pseudos nil
632 "*If `automatic', pseudo-articles will be viewed automatically.
633 If `not-confirm', pseudos will be viewed automatically, and the user
634 will not be asked to confirm the command."
635 :group 'gnus-extract-view
636 :type '(choice (const :tag "off" nil)
638 (const not-confirm)))
640 (defcustom gnus-view-pseudos-separately t
641 "*If non-nil, one pseudo-article will be created for each file to be viewed.
642 If nil, all files that use the same viewing command will be given as a
643 list of parameters to that command."
644 :group 'gnus-extract-view
647 (defcustom gnus-insert-pseudo-articles t
648 "*If non-nil, insert pseudo-articles when decoding articles."
649 :group 'gnus-extract-view
652 (defcustom gnus-summary-dummy-line-format
654 "*The format specification for the dummy roots in the summary buffer.
655 It works along the same lines as a normal formatting string,
656 with some simple extensions.
660 General format specifiers can also be used.
661 See `(gnus)Formatting Variables'."
662 :link '(custom-manual "(gnus)Formatting Variables")
663 :group 'gnus-threading
666 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
667 "*The format specification for the summary mode line.
668 It works along the same lines as a normal formatting string,
669 with some simple extensions:
672 %p Unprefixed group name
673 %A Current article number
674 %z Current article score
676 %U Number of unread articles in the group
677 %e Number of unselected articles in the group
678 %Z A string with unread/unselected article counts
679 %g Shortish group name
680 %S Subject of the current article
682 %s Current score file name
683 %d Number of dormant articles
684 %r Number of articles that have been marked as read in this session
685 %E Number of articles expunged by the score files"
686 :group 'gnus-summary-format
689 (defcustom gnus-list-identifiers nil
690 "Regexp that matches list identifiers to be removed from subject.
691 This can also be a list of regexps."
693 :group 'gnus-summary-format
694 :group 'gnus-article-hiding
695 :type '(choice (const :tag "none" nil)
697 (repeat :value (".*") regexp)))
699 (defcustom gnus-summary-mark-below 0
700 "*Mark all articles with a score below this variable as read.
701 This variable is local to each summary buffer and usually set by the
703 :group 'gnus-score-default
706 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
707 "*List of functions used for sorting articles in the summary buffer.
709 Each function takes two articles and returns non-nil if the first
710 article should be sorted before the other. If you use more than one
711 function, the primary sort function should be the last. You should
712 probably always include `gnus-article-sort-by-number' in the list of
713 sorting functions -- preferably first. Also note that sorting by date
714 is often much slower than sorting by number, and the sorting order is
715 very similar. (Sorting by date means sorting by the time the message
716 was sent, sorting by number means sorting by arrival time.)
718 Ready-made functions include `gnus-article-sort-by-number',
719 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
720 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
721 and `gnus-article-sort-by-score'.
723 When threading is turned on, the variable `gnus-thread-sort-functions'
724 controls how articles are sorted."
725 :group 'gnus-summary-sort
726 :type '(repeat (choice (function-item gnus-article-sort-by-number)
727 (function-item gnus-article-sort-by-author)
728 (function-item gnus-article-sort-by-subject)
729 (function-item gnus-article-sort-by-date)
730 (function-item gnus-article-sort-by-score)
731 (function-item gnus-article-sort-by-random)
732 (function :tag "other"))))
734 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
735 "*List of functions used for sorting threads in the summary buffer.
736 By default, threads are sorted by article number.
738 Each function takes two threads and returns non-nil if the first
739 thread should be sorted before the other. If you use more than one
740 function, the primary sort function should be the last. You should
741 probably always include `gnus-thread-sort-by-number' in the list of
742 sorting functions -- preferably first. Also note that sorting by date
743 is often much slower than sorting by number, and the sorting order is
744 very similar. (Sorting by date means sorting by the time the message
745 was sent, sorting by number means sorting by arrival time.)
747 Ready-made functions include `gnus-thread-sort-by-number',
748 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
749 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
750 `gnus-thread-sort-by-most-recent-number',
751 `gnus-thread-sort-by-most-recent-date',
752 `gnus-thread-sort-by-random', and
753 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
755 When threading is turned off, the variable
756 `gnus-article-sort-functions' controls how articles are sorted."
757 :group 'gnus-summary-sort
758 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
759 (function-item gnus-thread-sort-by-author)
760 (function-item gnus-thread-sort-by-subject)
761 (function-item gnus-thread-sort-by-date)
762 (function-item gnus-thread-sort-by-score)
763 (function-item gnus-thread-sort-by-most-recent-number)
764 (function-item gnus-thread-sort-by-most-recent-date)
765 (function-item gnus-thread-sort-by-random)
766 (function-item gnus-thread-sort-by-total-score)
767 (function :tag "other"))))
769 (defcustom gnus-thread-score-function '+
770 "*Function used for calculating the total score of a thread.
772 The function is called with the scores of the article and each
773 subthread and should then return the score of the thread.
775 Some functions you can use are `+', `max', or `min'."
776 :group 'gnus-summary-sort
779 (defcustom gnus-summary-expunge-below nil
780 "All articles that have a score less than this variable will be expunged.
781 This variable is local to the summary buffers."
782 :group 'gnus-score-default
783 :type '(choice (const :tag "off" nil)
786 (defcustom gnus-thread-expunge-below nil
787 "All threads that have a total score less than this variable will be expunged.
788 See `gnus-thread-score-function' for en explanation of what a
791 This variable is local to the summary buffers."
792 :group 'gnus-threading
793 :group 'gnus-score-default
794 :type '(choice (const :tag "off" nil)
797 (defcustom gnus-summary-mode-hook nil
798 "*A hook for Gnus summary mode.
799 This hook is run before any variables are set in the summary buffer."
800 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
801 :group 'gnus-summary-various
804 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
805 (when (featurep 'xemacs)
806 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
807 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
808 (add-hook 'gnus-summary-mode-hook
809 'gnus-xmas-switch-horizontal-scrollbar-off))
811 (defcustom gnus-summary-menu-hook nil
812 "*Hook run after the creation of the summary mode menu."
813 :group 'gnus-summary-visual
816 (defcustom gnus-summary-exit-hook nil
817 "*A hook called on exit from the summary buffer.
818 It will be called with point in the group buffer."
819 :group 'gnus-summary-exit
822 (defcustom gnus-summary-prepare-hook nil
823 "*A hook called after the summary buffer has been generated.
824 If you want to modify the summary buffer, you can use this hook."
825 :group 'gnus-summary-various
828 (defcustom gnus-summary-prepared-hook nil
829 "*A hook called as the last thing after the summary buffer has been generated."
830 :group 'gnus-summary-various
833 (defcustom gnus-summary-generate-hook nil
834 "*A hook run just before generating the summary buffer.
835 This hook is commonly used to customize threading variables and the
837 :group 'gnus-summary-various
840 (defcustom gnus-select-group-hook nil
841 "*A hook called when a newsgroup is selected.
843 If you'd like to simplify subjects like the
844 `gnus-summary-next-same-subject' command does, you can use the
847 (add-hook gnus-select-group-hook
849 (mapcar (lambda (header)
850 (mail-header-set-subject
852 (gnus-simplify-subject
853 (mail-header-subject header) 're-only)))
854 gnus-newsgroup-headers)))"
855 :group 'gnus-group-select
858 (defcustom gnus-select-article-hook nil
859 "*A hook called when an article is selected."
860 :group 'gnus-summary-choose
861 :options '(gnus-agent-fetch-selected-article)
864 (defcustom gnus-visual-mark-article-hook
865 (list 'gnus-highlight-selected-summary)
866 "*Hook run after selecting an article in the summary buffer.
867 It is meant to be used for highlighting the article in some way. It
868 is not run if `gnus-visual' is nil."
869 :group 'gnus-summary-visual
872 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
873 "*A hook called before parsing the headers."
877 (defcustom gnus-exit-group-hook nil
878 "*A hook called when exiting summary mode.
879 This hook is not called from the non-updating exit commands like `Q'."
883 (defcustom gnus-summary-update-hook
884 (list 'gnus-summary-highlight-line)
885 "*A hook called when a summary line is changed.
886 The hook will not be called if `gnus-visual' is nil.
888 The default function `gnus-summary-highlight-line' will
889 highlight the line according to the `gnus-summary-highlight'
891 :group 'gnus-summary-visual
894 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
895 "*A hook called when an article is selected for the first time.
896 The hook is intended to mark an article as read (or unread)
897 automatically when it is selected."
898 :group 'gnus-summary-choose
901 (defcustom gnus-group-no-more-groups-hook nil
902 "*A hook run when returning to group mode having no more (unread) groups."
903 :group 'gnus-group-select
906 (defcustom gnus-ps-print-hook nil
907 "*A hook run before ps-printing something from Gnus."
911 (defcustom gnus-summary-article-move-hook nil
912 "*A hook called after an article is moved, copied, respooled, or crossposted."
916 (defcustom gnus-summary-article-delete-hook nil
917 "*A hook called after an article is deleted."
921 (defcustom gnus-summary-article-expire-hook nil
922 "*A hook called after an article is expired."
926 (defcustom gnus-summary-display-arrow
927 (and (fboundp 'display-graphic-p)
929 "*If non-nil, display an arrow highlighting the current article."
934 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
935 "Face used for highlighting the current article in the summary buffer."
936 :group 'gnus-summary-visual
939 (defvar gnus-tmp-downloaded nil)
941 (defcustom gnus-summary-highlight
942 '(((eq mark gnus-canceled-mark)
943 . gnus-summary-cancelled-face)
944 ((and uncached (> score default-high))
945 . gnus-summary-high-undownloaded-face)
946 ((and uncached (< score default-low))
947 . gnus-summary-low-undownloaded-face)
949 . gnus-summary-normal-undownloaded-face)
950 ((and (> score default-high)
951 (or (eq mark gnus-dormant-mark)
952 (eq mark gnus-ticked-mark)))
953 . gnus-summary-high-ticked-face)
954 ((and (< score default-low)
955 (or (eq mark gnus-dormant-mark)
956 (eq mark gnus-ticked-mark)))
957 . gnus-summary-low-ticked-face)
958 ((or (eq mark gnus-dormant-mark)
959 (eq mark gnus-ticked-mark))
960 . gnus-summary-normal-ticked-face)
961 ((and (> score default-high) (eq mark gnus-ancient-mark))
962 . gnus-summary-high-ancient-face)
963 ((and (< score default-low) (eq mark gnus-ancient-mark))
964 . gnus-summary-low-ancient-face)
965 ((eq mark gnus-ancient-mark)
966 . gnus-summary-normal-ancient-face)
967 ((and (> score default-high) (eq mark gnus-unread-mark))
968 . gnus-summary-high-unread-face)
969 ((and (< score default-low) (eq mark gnus-unread-mark))
970 . gnus-summary-low-unread-face)
971 ((eq mark gnus-unread-mark)
972 . gnus-summary-normal-unread-face)
973 ((> score default-high)
974 . gnus-summary-high-read-face)
975 ((< score default-low)
976 . gnus-summary-low-read-face)
978 . gnus-summary-normal-read-face))
979 "*Controls the highlighting of summary buffer lines.
981 A list of (FORM . FACE) pairs. When deciding how a a particular
982 summary line should be displayed, each form is evaluated. The content
983 of the face field after the first true form is used. You can change
984 how those summary lines are displayed, by editing the face field.
986 You can use the following variables in the FORM field.
988 score: The article's score
989 default: The default article score.
990 default-high: The default score for high scored articles.
991 default-low: The default score for low scored articles.
992 below: The score below which articles are automatically marked as read.
993 mark: The article's mark.
994 uncached: Non-nil if the article is uncached."
995 :group 'gnus-summary-visual
996 :type '(repeat (cons (sexp :tag "Form" nil)
999 (defcustom gnus-alter-header-function nil
1000 "Function called to allow alteration of article header structures.
1001 The function is called with one parameter, the article header vector,
1002 which it may alter in any way."
1003 :type '(choice (const :tag "None" nil)
1005 :group 'gnus-summary)
1007 (defvar gnus-decode-encoded-word-function
1008 (mime-find-field-decoder 'From 'nov)
1009 "Variable that says which function should be used to decode a string with encoded words.")
1011 (defcustom gnus-extra-headers '(To Newsgroups)
1012 "*Extra headers to parse."
1014 :group 'gnus-summary
1015 :type '(repeat symbol))
1017 (defcustom gnus-ignored-from-addresses
1018 (and user-mail-address (regexp-quote user-mail-address))
1019 "*Regexp of From headers that may be suppressed in favor of To headers."
1021 :group 'gnus-summary
1024 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1025 "List of charsets that should be ignored.
1026 When these charsets are used in the \"charset\" parameter, the
1027 default charset will be used instead."
1029 :type '(repeat symbol)
1030 :group 'gnus-charset)
1032 (gnus-define-group-parameter
1036 "Return the ignored charsets of GROUP."
1037 :variable gnus-group-ignored-charsets-alist
1039 '(("alt\\.chinese\\.text" iso-8859-1))
1041 "Alist of regexps (to match group names) and charsets that should be ignored.
1042 When these charsets are used in the \"charset\" parameter, the
1043 default charset will be used instead."
1044 :variable-group gnus-charset
1045 :variable-type '(repeat (cons (regexp :tag "Group")
1047 :parameter-type '(choice :tag "Ignored charsets"
1050 :parameter-document "\
1051 List of charsets that should be ignored.
1053 When these charsets are used in the \"charset\" parameter, the
1054 default charset will be used instead.")
1056 (defcustom gnus-group-highlight-words-alist nil
1057 "Alist of group regexps and highlight regexps.
1058 This variable uses the same syntax as `gnus-emphasis-alist'."
1060 :type '(repeat (cons (regexp :tag "Group")
1061 (repeat (list (regexp :tag "Highlight regexp")
1062 (number :tag "Group for entire word" 0)
1063 (number :tag "Group for displayed part" 0)
1065 gnus-emphasis-highlight-words)))))
1066 :group 'gnus-summary-visual)
1068 (defcustom gnus-use-wheel nil
1069 "Use Intelli-mouse on summary movement"
1071 :group 'gnus-summary-maneuvering)
1073 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1074 "Amount to scroll messages by spinning the mouse wheel.
1075 This is actually a cons cell, where the first item is the amount to scroll
1076 on a normal wheel event, and the second is the amount to scroll when the
1077 wheel is moved with the shift key depressed."
1078 :type '(cons (integer :tag "Shift") integer)
1079 :group 'gnus-summary-maneuvering)
1081 (defcustom gnus-wheel-edge-resistance 2
1082 "How hard it should be to change the current article
1083 by moving the mouse over the edge of the article window."
1085 :group 'gnus-summary-maneuvering)
1087 (defcustom gnus-summary-show-article-charset-alist
1089 "Alist of number and charset.
1090 The article will be shown with the charset corresponding to the
1092 For example: ((1 . cn-gb-2312) (2 . big5))."
1094 :type '(repeat (cons (number :tag "Argument" 1)
1095 (symbol :tag "Charset")))
1096 :group 'gnus-charset)
1098 (defcustom gnus-preserve-marks t
1099 "Whether marks are preserved when moving, copying and respooling messages."
1102 :group 'gnus-summary-marks)
1104 (defcustom gnus-alter-articles-to-read-function nil
1105 "Function to be called to alter the list of articles to be selected."
1106 :type '(choice (const nil) function)
1107 :group 'gnus-summary)
1109 (defcustom gnus-orphan-score nil
1110 "*All orphans get this score added. Set in the score file."
1111 :group 'gnus-score-default
1112 :type '(choice (const nil)
1115 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1116 "*A regexp to match MIME parts when saving multiple parts of a
1117 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1118 This regexp will be used by default when prompting the user for which
1119 type of files to save."
1120 :group 'gnus-summary
1123 (defcustom gnus-read-all-available-headers nil
1124 "Whether Gnus should parse all headers made available to it.
1125 This is mostly relevant for slow back ends where the user may
1126 wish to widen the summary buffer to include all headers
1127 that were fetched. Say, for nnultimate groups."
1128 :group 'gnus-summary
1129 :type '(choice boolean regexp))
1131 (defcustom gnus-summary-muttprint-program "muttprint"
1132 "Command (and optional arguments) used to run Muttprint."
1134 :group 'gnus-summary
1137 (defcustom gnus-article-loose-mime nil
1138 "If non-nil, don't require MIME-Version header.
1139 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1140 supply the MIME-Version header or deliberately strip it From the mail.
1141 Set it to non-nil, Gnus will treat some articles as MIME even if
1142 the MIME-Version header is missed."
1145 :group 'gnus-article-mime)
1147 (defcustom gnus-article-emulate-mime t
1148 "If non-nil, use MIME emulation for uuencode and the like.
1149 This means that Gnus will search message bodies for text that look
1150 like uuencoded bits, yEncoded bits, and so on, and present that using
1151 the normal Gnus MIME machinery."
1153 :group 'gnus-article-mime)
1155 ;;; Internal variables
1157 (defvar gnus-summary-display-cache nil)
1158 (defvar gnus-article-mime-handles nil)
1159 (defvar gnus-article-decoded-p nil)
1160 (defvar gnus-article-charset nil)
1161 (defvar gnus-article-ignored-charsets nil)
1162 (defvar gnus-scores-exclude-files nil)
1163 (defvar gnus-page-broken nil)
1165 (defvar gnus-original-article nil)
1166 (defvar gnus-article-internal-prepare-hook nil)
1167 (defvar gnus-newsgroup-process-stack nil)
1169 (defvar gnus-thread-indent-array nil)
1170 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1171 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1172 "Function called to sort the articles within a thread after it has been gathered together.")
1174 (defvar gnus-summary-save-parts-type-history nil)
1175 (defvar gnus-summary-save-parts-last-directory nil)
1177 ;; Avoid highlighting in kill files.
1178 (defvar gnus-summary-inhibit-highlight nil)
1179 (defvar gnus-newsgroup-selected-overlay nil)
1180 (defvar gnus-inhibit-limiting nil)
1181 (defvar gnus-newsgroup-adaptive-score-file nil)
1182 (defvar gnus-current-score-file nil)
1183 (defvar gnus-current-move-group nil)
1184 (defvar gnus-current-copy-group nil)
1185 (defvar gnus-current-crosspost-group nil)
1186 (defvar gnus-newsgroup-display nil)
1188 (defvar gnus-newsgroup-dependencies nil)
1189 (defvar gnus-newsgroup-adaptive nil)
1190 (defvar gnus-summary-display-article-function nil)
1191 (defvar gnus-summary-highlight-line-function nil
1192 "Function called after highlighting a summary line.")
1194 (defvar gnus-summary-line-format-alist
1195 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1196 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1197 (?s gnus-tmp-subject-or-nil ?s)
1198 (?n gnus-tmp-name ?s)
1199 (?A (std11-address-string
1200 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1201 (?a (or (std11-full-name-string
1202 (car (mime-entity-read-field gnus-tmp-header 'From)))
1204 (?F gnus-tmp-from ?s)
1205 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1206 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1207 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1208 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1209 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1210 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1211 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1212 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1213 (?L gnus-tmp-lines ?s)
1214 (?O gnus-tmp-downloaded ?c)
1215 (?I gnus-tmp-indentation ?s)
1216 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1217 (?R gnus-tmp-replied ?c)
1218 (?\[ gnus-tmp-opening-bracket ?c)
1219 (?\] gnus-tmp-closing-bracket ?c)
1220 (?\> (make-string gnus-tmp-level ? ) ?s)
1221 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1222 (?i gnus-tmp-score ?d)
1223 (?z gnus-tmp-score-char ?c)
1224 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1225 (?U gnus-tmp-unread ?c)
1226 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1228 (?t (gnus-summary-number-of-articles-in-thread
1229 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1231 (?e (gnus-summary-number-of-articles-in-thread
1232 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1234 (?u gnus-tmp-user-defined ?s)
1235 (?P (gnus-pick-line-number) ?d)
1236 (?B gnus-tmp-thread-tree-header-string ?s)
1237 (user-date (gnus-user-date
1238 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1239 "An alist of format specifications that can appear in summary lines.
1240 These are paired with what variables they correspond with, along with
1241 the type of the variable (string, integer, character, etc).")
1243 (defvar gnus-summary-dummy-line-format-alist
1244 `((?S gnus-tmp-subject ?s)
1245 (?N gnus-tmp-number ?d)
1246 (?u gnus-tmp-user-defined ?s)))
1248 (defvar gnus-summary-mode-line-format-alist
1249 `((?G gnus-tmp-group-name ?s)
1250 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1251 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1252 (?A gnus-tmp-article-number ?d)
1253 (?Z gnus-tmp-unread-and-unselected ?s)
1254 (?V gnus-version ?s)
1255 (?U gnus-tmp-unread-and-unticked ?d)
1256 (?S gnus-tmp-subject ?s)
1257 (?e gnus-tmp-unselected ?d)
1258 (?u gnus-tmp-user-defined ?s)
1259 (?d (length gnus-newsgroup-dormant) ?d)
1260 (?t (length gnus-newsgroup-marked) ?d)
1261 (?h (length gnus-newsgroup-spam-marked) ?d)
1262 (?r (length gnus-newsgroup-reads) ?d)
1263 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1264 (?E gnus-newsgroup-expunged-tally ?d)
1265 (?s (gnus-current-score-file-nondirectory) ?s)))
1267 (defvar gnus-last-search-regexp nil
1268 "Default regexp for article search command.")
1270 (defvar gnus-summary-search-article-matched-data nil
1271 "Last matched data of article search command. It is the local variable
1272 in `gnus-article-buffer' which consists of the list of start position,
1273 end position and text.")
1275 (defvar gnus-last-shell-command nil
1276 "Default shell command on article.")
1278 (defvar gnus-newsgroup-agentized nil
1279 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1280 (defvar gnus-newsgroup-begin nil)
1281 (defvar gnus-newsgroup-end nil)
1282 (defvar gnus-newsgroup-last-rmail nil)
1283 (defvar gnus-newsgroup-last-mail nil)
1284 (defvar gnus-newsgroup-last-folder nil)
1285 (defvar gnus-newsgroup-last-file nil)
1286 (defvar gnus-newsgroup-auto-expire nil)
1287 (defvar gnus-newsgroup-active nil)
1289 (defvar gnus-newsgroup-data nil)
1290 (defvar gnus-newsgroup-data-reverse nil)
1291 (defvar gnus-newsgroup-limit nil)
1292 (defvar gnus-newsgroup-limits nil)
1293 (defvar gnus-summary-use-undownloaded-faces nil)
1295 (defvar gnus-newsgroup-unreads nil
1296 "Sorted list of unread articles in the current newsgroup.")
1298 (defvar gnus-newsgroup-unselected nil
1299 "Sorted list of unselected unread articles in the current newsgroup.")
1301 (defvar gnus-newsgroup-reads nil
1302 "Alist of read articles and article marks in the current newsgroup.")
1304 (defvar gnus-newsgroup-expunged-tally nil)
1306 (defvar gnus-newsgroup-marked nil
1307 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1309 (defvar gnus-newsgroup-spam-marked nil
1310 "List of ranges of articles that have been marked as spam.")
1312 (defvar gnus-newsgroup-killed nil
1313 "List of ranges of articles that have been through the scoring process.")
1315 (defvar gnus-newsgroup-cached nil
1316 "Sorted list of articles that come from the article cache.")
1318 (defvar gnus-newsgroup-saved nil
1319 "List of articles that have been saved.")
1321 (defvar gnus-newsgroup-kill-headers nil)
1323 (defvar gnus-newsgroup-replied nil
1324 "List of articles that have been replied to in the current newsgroup.")
1326 (defvar gnus-newsgroup-forwarded nil
1327 "List of articles that have been forwarded in the current newsgroup.")
1329 (defvar gnus-newsgroup-recent nil
1330 "List of articles that have are recent in the current newsgroup.")
1332 (defvar gnus-newsgroup-expirable nil
1333 "Sorted list of articles in the current newsgroup that can be expired.")
1335 (defvar gnus-newsgroup-processable nil
1336 "List of articles in the current newsgroup that can be processed.")
1338 (defvar gnus-newsgroup-downloadable nil
1339 "Sorted list of articles in the current newsgroup that can be processed.")
1341 (defvar gnus-newsgroup-unfetched nil
1342 "Sorted list of articles in the current newsgroup whose headers have
1343 not been fetched into the agent.
1345 This list will always be a subset of gnus-newsgroup-undownloaded.")
1347 (defvar gnus-newsgroup-undownloaded nil
1348 "List of articles in the current newsgroup that haven't been downloaded.")
1350 (defvar gnus-newsgroup-unsendable nil
1351 "List of articles in the current newsgroup that won't be sent.")
1353 (defvar gnus-newsgroup-bookmarks nil
1354 "List of articles in the current newsgroup that have bookmarks.")
1356 (defvar gnus-newsgroup-dormant nil
1357 "Sorted list of dormant articles in the current newsgroup.")
1359 (defvar gnus-newsgroup-unseen nil
1360 "List of unseen articles in the current newsgroup.")
1362 (defvar gnus-newsgroup-seen nil
1363 "Range of seen articles in the current newsgroup.")
1365 (defvar gnus-newsgroup-articles nil
1366 "List of articles in the current newsgroup.")
1368 (defvar gnus-newsgroup-scored nil
1369 "List of scored articles in the current newsgroup.")
1371 (defvar gnus-newsgroup-incorporated nil
1372 "List of incorporated articles in the current newsgroup.")
1374 (defvar gnus-newsgroup-headers nil
1375 "List of article headers in the current newsgroup.")
1377 (defvar gnus-newsgroup-threads nil)
1379 (defvar gnus-newsgroup-prepared nil
1380 "Whether the current group has been prepared properly.")
1382 (defvar gnus-newsgroup-ancient nil
1383 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1385 (defvar gnus-newsgroup-sparse nil)
1387 (defvar gnus-current-article nil)
1388 (defvar gnus-article-current nil)
1389 (defvar gnus-current-headers nil)
1390 (defvar gnus-have-all-headers nil)
1391 (defvar gnus-last-article nil)
1392 (defvar gnus-newsgroup-history nil)
1393 (defvar gnus-newsgroup-charset nil)
1394 (defvar gnus-newsgroup-ephemeral-charset nil)
1395 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1397 (defvar gnus-article-before-search nil)
1399 (defvar gnus-summary-local-variables
1400 '(gnus-newsgroup-name
1401 gnus-newsgroup-begin gnus-newsgroup-end
1402 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1403 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1404 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1405 gnus-newsgroup-unselected gnus-newsgroup-marked
1406 gnus-newsgroup-spam-marked
1407 gnus-newsgroup-reads gnus-newsgroup-saved
1408 gnus-newsgroup-replied gnus-newsgroup-forwarded
1409 gnus-newsgroup-recent
1410 gnus-newsgroup-expirable
1411 gnus-newsgroup-processable gnus-newsgroup-killed
1412 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1413 gnus-newsgroup-unfetched
1414 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1415 gnus-newsgroup-seen gnus-newsgroup-articles
1416 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1417 gnus-newsgroup-headers gnus-newsgroup-threads
1418 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1419 gnus-current-article gnus-current-headers gnus-have-all-headers
1420 gnus-last-article gnus-article-internal-prepare-hook
1421 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1422 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1423 gnus-thread-expunge-below
1424 gnus-score-alist gnus-current-score-file
1425 (gnus-summary-expunge-below . global)
1426 (gnus-summary-mark-below . global)
1427 (gnus-orphan-score . global)
1428 gnus-newsgroup-active gnus-scores-exclude-files
1429 gnus-newsgroup-history gnus-newsgroup-ancient
1430 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1431 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1432 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1433 (gnus-newsgroup-expunged-tally . 0)
1434 gnus-cache-removable-articles gnus-newsgroup-cached
1435 gnus-newsgroup-data gnus-newsgroup-data-reverse
1436 gnus-newsgroup-limit gnus-newsgroup-limits
1437 gnus-newsgroup-charset gnus-newsgroup-display
1438 gnus-summary-use-undownloaded-faces
1439 gnus-newsgroup-incorporated)
1440 "Variables that are buffer-local to the summary buffers.")
1442 (defvar gnus-newsgroup-variables nil
1443 "A list of variables that have separate values in different newsgroups.
1444 A list of newsgroup (summary buffer) local variables, or cons of
1445 variables and their default values (when the default values are not
1446 nil), that should be made global while the summary buffer is active.
1447 These variables can be used to set variables in the group parameters
1448 while still allowing them to affect operations done in other
1449 buffers. For example:
1451 \(setq gnus-newsgroup-variables
1452 '(message-use-followup-to
1453 (gnus-visible-headers .
1454 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1457 ;; Byte-compiler warning.
1459 ;; Bind features so that require will believe that gnus-sum has
1460 ;; already been loaded (avoids infinite recursion)
1461 (let ((features (cons 'gnus-sum features)))
1462 ;; Several of the declarations in gnus-sum are needed to load the
1463 ;; following files. Right now, these definitions have been
1464 ;; compiled but not defined (evaluated). We could either do a
1465 ;; eval-and-compile about all of the declarations or evaluate the
1467 (if (boundp 'gnus-newsgroup-variables)
1469 (load "gnus-sum.el" t t t))
1471 (require 'gnus-agent)
1472 (require 'gnus-art)))
1474 ;; Subject simplification.
1476 (defun gnus-simplify-whitespace (str)
1477 "Remove excessive whitespace from STR."
1479 (while (string-match "[ \t][ \t]+" str)
1480 (setq str (concat (substring str 0 (match-beginning 0))
1482 (substring str (match-end 0)))))
1484 (when (string-match "^[ \t]+" str)
1485 (setq str (substring str (match-end 0))))
1487 (when (string-match "[ \t]+$" str)
1488 (setq str (substring str 0 (match-beginning 0))))
1491 (defun gnus-simplify-all-whitespace (str)
1492 "Remove all whitespace from STR."
1493 (while (string-match "[ \t\n]+" str)
1494 (setq str (replace-match "" nil nil str)))
1497 (defsubst gnus-simplify-subject-re (subject)
1498 "Remove \"Re:\" from subject lines."
1499 (if (string-match message-subject-re-regexp subject)
1500 (substring subject (match-end 0))
1503 (defun gnus-simplify-subject (subject &optional re-only)
1504 "Remove `Re:' and words in parentheses.
1505 If RE-ONLY is non-nil, strip leading `Re:'s only."
1506 (let ((case-fold-search t)) ;Ignore case.
1507 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1508 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1509 (setq subject (substring subject (match-end 0))))
1510 ;; Remove uninteresting prefixes.
1511 (when (and (not re-only)
1512 gnus-simplify-ignored-prefixes
1513 (string-match gnus-simplify-ignored-prefixes subject))
1514 (setq subject (substring subject (match-end 0))))
1515 ;; Remove words in parentheses from end.
1517 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1518 (setq subject (substring subject 0 (match-beginning 0)))))
1519 ;; Return subject string.
1522 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1524 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1525 (goto-char (point-min))
1526 (while (re-search-forward regexp nil t)
1527 (replace-match (or newtext ""))))
1529 (defun gnus-simplify-buffer-fuzzy ()
1530 "Simplify string in the buffer fuzzily.
1531 The string in the accessible portion of the current buffer is simplified.
1532 It is assumed to be a single-line subject.
1533 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1534 matter is removed. Additional things can be deleted by setting
1535 `gnus-simplify-subject-fuzzy-regexp'."
1536 (let ((case-fold-search t)
1538 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1540 (while (not (eq modified-tick (buffer-modified-tick)))
1541 (setq modified-tick (buffer-modified-tick))
1543 ((listp gnus-simplify-subject-fuzzy-regexp)
1544 (mapcar 'gnus-simplify-buffer-fuzzy-step
1545 gnus-simplify-subject-fuzzy-regexp))
1546 (gnus-simplify-subject-fuzzy-regexp
1547 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1548 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1549 (gnus-simplify-buffer-fuzzy-step
1550 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1551 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1553 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1554 (gnus-simplify-buffer-fuzzy-step " +" " ")
1555 (gnus-simplify-buffer-fuzzy-step " $")
1556 (gnus-simplify-buffer-fuzzy-step "^ +")))
1558 (defun gnus-simplify-subject-fuzzy (subject)
1559 "Simplify a subject string fuzzily.
1560 See `gnus-simplify-buffer-fuzzy' for details."
1562 (gnus-set-work-buffer)
1563 (let ((case-fold-search t))
1564 ;; Remove uninteresting prefixes.
1565 (when (and gnus-simplify-ignored-prefixes
1566 (string-match gnus-simplify-ignored-prefixes subject))
1567 (setq subject (substring subject (match-end 0))))
1569 (inline (gnus-simplify-buffer-fuzzy))
1572 (defsubst gnus-simplify-subject-fully (subject)
1573 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1575 (gnus-simplify-subject-functions
1576 (gnus-map-function gnus-simplify-subject-functions subject))
1577 ((null gnus-summary-gather-subject-limit)
1578 (gnus-simplify-subject-re subject))
1579 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1580 (gnus-simplify-subject-fuzzy subject))
1581 ((numberp gnus-summary-gather-subject-limit)
1582 (gnus-limit-string (gnus-simplify-subject-re subject)
1583 gnus-summary-gather-subject-limit))
1587 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1588 "Check whether two subjects are equal.
1589 If optional argument SIMPLE-FIRST is t, first argument is already
1592 ((null simple-first)
1593 (equal (gnus-simplify-subject-fully s1)
1594 (gnus-simplify-subject-fully s2)))
1597 (gnus-simplify-subject-fully s2)))))
1599 (defun gnus-summary-bubble-group ()
1600 "Increase the score of the current group.
1601 This is a handy function to add to `gnus-summary-exit-hook' to
1602 increase the score of each group you read."
1603 (gnus-group-add-score gnus-newsgroup-name))
1607 ;;; Gnus summary mode
1610 (put 'gnus-summary-mode 'mode-class 'special)
1612 (defvar gnus-article-commands-menu)
1614 ;; Non-orthogonal keys
1616 (gnus-define-keys gnus-summary-mode-map
1617 " " gnus-summary-next-page
1618 "\177" gnus-summary-prev-page
1619 [delete] gnus-summary-prev-page
1620 [backspace] gnus-summary-prev-page
1621 "\r" gnus-summary-scroll-up
1622 "\M-\r" gnus-summary-scroll-down
1623 "n" gnus-summary-next-unread-article
1624 "p" gnus-summary-prev-unread-article
1625 "N" gnus-summary-next-article
1626 "P" gnus-summary-prev-article
1627 "\M-\C-n" gnus-summary-next-same-subject
1628 "\M-\C-p" gnus-summary-prev-same-subject
1629 "\M-n" gnus-summary-next-unread-subject
1630 "\M-p" gnus-summary-prev-unread-subject
1631 "." gnus-summary-first-unread-article
1632 "," gnus-summary-best-unread-article
1633 "\M-s" gnus-summary-search-article-forward
1634 "\M-r" gnus-summary-search-article-backward
1635 "<" gnus-summary-beginning-of-article
1636 ">" gnus-summary-end-of-article
1637 "j" gnus-summary-goto-article
1638 "^" gnus-summary-refer-parent-article
1639 "\M-^" gnus-summary-refer-article
1640 "u" gnus-summary-tick-article-forward
1641 "!" gnus-summary-tick-article-forward
1642 "U" gnus-summary-tick-article-backward
1643 "d" gnus-summary-mark-as-read-forward
1644 "D" gnus-summary-mark-as-read-backward
1645 "E" gnus-summary-mark-as-expirable
1646 "\M-u" gnus-summary-clear-mark-forward
1647 "\M-U" gnus-summary-clear-mark-backward
1648 "k" gnus-summary-kill-same-subject-and-select
1649 "\C-k" gnus-summary-kill-same-subject
1650 "\M-\C-k" gnus-summary-kill-thread
1651 "\M-\C-l" gnus-summary-lower-thread
1652 "e" gnus-summary-edit-article
1653 "#" gnus-summary-mark-as-processable
1654 "\M-#" gnus-summary-unmark-as-processable
1655 "\M-\C-t" gnus-summary-toggle-threads
1656 "\M-\C-s" gnus-summary-show-thread
1657 "\M-\C-h" gnus-summary-hide-thread
1658 "\M-\C-f" gnus-summary-next-thread
1659 "\M-\C-b" gnus-summary-prev-thread
1660 [(meta down)] gnus-summary-next-thread
1661 [(meta up)] gnus-summary-prev-thread
1662 "\M-\C-u" gnus-summary-up-thread
1663 "\M-\C-d" gnus-summary-down-thread
1664 "&" gnus-summary-execute-command
1665 "c" gnus-summary-catchup-and-exit
1666 "\C-w" gnus-summary-mark-region-as-read
1667 "\C-t" gnus-summary-toggle-truncation
1668 "?" gnus-summary-mark-as-dormant
1669 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1670 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1671 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1672 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1673 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1674 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1675 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1676 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1677 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1678 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1679 "=" gnus-summary-expand-window
1680 "\C-x\C-s" gnus-summary-reselect-current-group
1681 "\M-g" gnus-summary-rescan-group
1682 "w" gnus-summary-stop-page-breaking
1683 "\C-c\C-r" gnus-summary-caesar-message
1684 "\M-t" gnus-summary-toggle-mime
1685 "f" gnus-summary-followup
1686 "F" gnus-summary-followup-with-original
1687 "C" gnus-summary-cancel-article
1688 "r" gnus-summary-reply
1689 "R" gnus-summary-reply-with-original
1690 "\C-c\C-f" gnus-summary-mail-forward
1691 "o" gnus-summary-save-article
1692 "\C-o" gnus-summary-save-article-mail
1693 "|" gnus-summary-pipe-output
1694 "\M-k" gnus-summary-edit-local-kill
1695 "\M-K" gnus-summary-edit-global-kill
1697 "\C-c\C-d" gnus-summary-describe-group
1698 "q" gnus-summary-exit
1699 "Q" gnus-summary-exit-no-update
1700 "\C-c\C-i" gnus-info-find-node
1701 gnus-mouse-2 gnus-mouse-pick-article
1702 "m" gnus-summary-mail-other-window
1703 "a" gnus-summary-post-news
1704 "i" gnus-summary-news-other-window
1705 "x" gnus-summary-limit-to-unread
1706 "s" gnus-summary-isearch-article
1707 "t" gnus-summary-toggle-header
1708 "g" gnus-summary-show-article
1709 "l" gnus-summary-goto-last-article
1710 "v" gnus-summary-preview-mime-message
1711 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1712 "\C-d" gnus-summary-enter-digest-group
1713 "\M-\C-d" gnus-summary-read-document
1714 "\M-\C-e" gnus-summary-edit-parameters
1715 "\M-\C-a" gnus-summary-customize-parameters
1717 "\C-c\C-n" gnus-namazu-search
1718 "*" gnus-cache-enter-article
1719 "\M-*" gnus-cache-remove-article
1720 "\M-&" gnus-summary-universal-argument
1721 "\C-l" gnus-recenter
1722 "I" gnus-summary-increase-score
1723 "L" gnus-summary-lower-score
1724 "\M-i" gnus-symbolic-argument
1725 "h" gnus-summary-select-article-buffer
1727 "V" gnus-summary-score-map
1728 "X" gnus-uu-extract-map
1729 "S" gnus-summary-send-map)
1731 ;; Sort of orthogonal keymap
1732 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1733 "t" gnus-summary-tick-article-forward
1734 "!" gnus-summary-tick-article-forward
1735 "d" gnus-summary-mark-as-read-forward
1736 "r" gnus-summary-mark-as-read-forward
1737 "c" gnus-summary-clear-mark-forward
1738 " " gnus-summary-clear-mark-forward
1739 "e" gnus-summary-mark-as-expirable
1740 "x" gnus-summary-mark-as-expirable
1741 "?" gnus-summary-mark-as-dormant
1742 "b" gnus-summary-set-bookmark
1743 "B" gnus-summary-remove-bookmark
1744 "#" gnus-summary-mark-as-processable
1745 "\M-#" gnus-summary-unmark-as-processable
1746 "S" gnus-summary-limit-include-expunged
1747 "C" gnus-summary-catchup
1748 "H" gnus-summary-catchup-to-here
1749 "h" gnus-summary-catchup-from-here
1750 "\C-c" gnus-summary-catchup-all
1751 "k" gnus-summary-kill-same-subject-and-select
1752 "K" gnus-summary-kill-same-subject
1753 "P" gnus-uu-mark-map)
1755 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1756 "c" gnus-summary-clear-above
1757 "u" gnus-summary-tick-above
1758 "m" gnus-summary-mark-above
1759 "k" gnus-summary-kill-below)
1761 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1762 "/" gnus-summary-limit-to-subject
1763 "n" gnus-summary-limit-to-articles
1764 "w" gnus-summary-pop-limit
1765 "s" gnus-summary-limit-to-subject
1766 "a" gnus-summary-limit-to-author
1767 "u" gnus-summary-limit-to-unread
1768 "m" gnus-summary-limit-to-marks
1769 "M" gnus-summary-limit-exclude-marks
1770 "v" gnus-summary-limit-to-score
1771 "*" gnus-summary-limit-include-cached
1772 "D" gnus-summary-limit-include-dormant
1773 "T" gnus-summary-limit-include-thread
1774 "d" gnus-summary-limit-exclude-dormant
1775 "t" gnus-summary-limit-to-age
1776 "." gnus-summary-limit-to-unseen
1777 "x" gnus-summary-limit-to-extra
1778 "p" gnus-summary-limit-to-display-predicate
1779 "E" gnus-summary-limit-include-expunged
1780 "c" gnus-summary-limit-exclude-childless-dormant
1781 "C" gnus-summary-limit-mark-excluded-as-read
1782 "o" gnus-summary-insert-old-articles
1783 "N" gnus-summary-insert-new-articles
1784 "r" gnus-summary-limit-to-replied)
1786 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1787 "n" gnus-summary-next-unread-article
1788 "p" gnus-summary-prev-unread-article
1789 "N" gnus-summary-next-article
1790 "P" gnus-summary-prev-article
1791 "\C-n" gnus-summary-next-same-subject
1792 "\C-p" gnus-summary-prev-same-subject
1793 "\M-n" gnus-summary-next-unread-subject
1794 "\M-p" gnus-summary-prev-unread-subject
1795 "f" gnus-summary-first-unread-article
1796 "b" gnus-summary-best-unread-article
1797 "j" gnus-summary-goto-article
1798 "g" gnus-summary-goto-subject
1799 "l" gnus-summary-goto-last-article
1800 "o" gnus-summary-pop-article)
1802 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1803 "k" gnus-summary-kill-thread
1804 "l" gnus-summary-lower-thread
1805 "i" gnus-summary-raise-thread
1806 "T" gnus-summary-toggle-threads
1807 "t" gnus-summary-rethread-current
1808 "^" gnus-summary-reparent-thread
1809 "s" gnus-summary-show-thread
1810 "S" gnus-summary-show-all-threads
1811 "h" gnus-summary-hide-thread
1812 "H" gnus-summary-hide-all-threads
1813 "n" gnus-summary-next-thread
1814 "p" gnus-summary-prev-thread
1815 "u" gnus-summary-up-thread
1816 "o" gnus-summary-top-thread
1817 "d" gnus-summary-down-thread
1818 "#" gnus-uu-mark-thread
1819 "\M-#" gnus-uu-unmark-thread)
1821 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1822 "g" gnus-summary-prepare
1823 "c" gnus-summary-insert-cached-articles
1824 "d" gnus-summary-insert-dormant-articles)
1826 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1827 "c" gnus-summary-catchup-and-exit
1828 "C" gnus-summary-catchup-all-and-exit
1829 "E" gnus-summary-exit-no-update
1830 "J" gnus-summary-jump-to-other-group
1831 "Q" gnus-summary-exit
1832 "Z" gnus-summary-exit
1833 "n" gnus-summary-catchup-and-goto-next-group
1834 "R" gnus-summary-reselect-current-group
1835 "G" gnus-summary-rescan-group
1836 "N" gnus-summary-next-group
1837 "s" gnus-summary-save-newsrc
1838 "P" gnus-summary-prev-group)
1840 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1841 " " gnus-summary-next-page
1842 "n" gnus-summary-next-page
1843 "\177" gnus-summary-prev-page
1844 [delete] gnus-summary-prev-page
1845 "p" gnus-summary-prev-page
1846 "\r" gnus-summary-scroll-up
1847 "\M-\r" gnus-summary-scroll-down
1848 "<" gnus-summary-beginning-of-article
1849 ">" gnus-summary-end-of-article
1850 "b" gnus-summary-beginning-of-article
1851 "e" gnus-summary-end-of-article
1852 "^" gnus-summary-refer-parent-article
1853 "r" gnus-summary-refer-parent-article
1854 "D" gnus-summary-enter-digest-group
1855 "R" gnus-summary-refer-references
1856 "T" gnus-summary-refer-thread
1857 "g" gnus-summary-show-article
1858 "s" gnus-summary-isearch-article
1859 "P" gnus-summary-print-article
1860 "M" gnus-mailing-list-insinuate
1861 "t" gnus-article-babel)
1863 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1864 "b" gnus-article-add-buttons
1865 "B" gnus-article-add-buttons-to-head
1866 "o" gnus-article-treat-overstrike
1867 "e" gnus-article-emphasize
1868 "w" gnus-article-fill-cited-article
1869 "Q" gnus-article-fill-long-lines
1870 "C" gnus-article-capitalize-sentences
1871 "c" gnus-article-remove-cr
1872 "Z" gnus-article-decode-HZ
1873 "A" gnus-article-treat-ansi-sequences
1874 "h" gnus-article-wash-html
1875 "u" gnus-article-unsplit-urls
1876 "f" gnus-article-display-x-face
1877 "l" gnus-summary-stop-page-breaking
1878 "r" gnus-summary-caesar-message
1879 "m" gnus-summary-morse-message
1880 "t" gnus-summary-toggle-header
1881 "g" gnus-treat-smiley
1882 "v" gnus-summary-verbose-headers
1883 "m" gnus-summary-toggle-mime
1884 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1885 "p" gnus-article-verify-x-pgp-sig
1886 "d" gnus-article-treat-dumbquotes)
1888 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1889 ;; mnemonic: deuglif*Y*
1890 "u" gnus-article-outlook-unwrap-lines
1891 "a" gnus-article-outlook-repair-attribution
1892 "c" gnus-article-outlook-rearrange-citation
1893 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1895 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1896 "a" gnus-article-hide
1897 "h" gnus-article-hide-headers
1898 "b" gnus-article-hide-boring-headers
1899 "s" gnus-article-hide-signature
1900 "c" gnus-article-hide-citation
1901 "C" gnus-article-hide-citation-in-followups
1902 "l" gnus-article-hide-list-identifiers
1903 "B" gnus-article-strip-banner
1904 "P" gnus-article-hide-pem
1905 "\C-c" gnus-article-hide-citation-maybe)
1907 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1908 "a" gnus-article-highlight
1909 "h" gnus-article-highlight-headers
1910 "c" gnus-article-highlight-citation
1911 "s" gnus-article-highlight-signature)
1913 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1914 "f" gnus-article-treat-fold-headers
1915 "u" gnus-article-treat-unfold-headers
1916 "n" gnus-article-treat-fold-newsgroups)
1918 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1919 "x" gnus-article-display-x-face
1920 "d" gnus-article-display-face
1921 "s" gnus-treat-smiley
1922 "D" gnus-article-remove-images
1923 "f" gnus-treat-from-picon
1924 "m" gnus-treat-mail-picon
1925 "n" gnus-treat-newsgroups-picon)
1927 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1928 "z" gnus-article-date-ut
1929 "u" gnus-article-date-ut
1930 "l" gnus-article-date-local
1931 "p" gnus-article-date-english
1932 "e" gnus-article-date-lapsed
1933 "o" gnus-article-date-original
1934 "i" gnus-article-date-iso8601
1935 "s" gnus-article-date-user)
1937 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1938 "t" gnus-article-remove-trailing-blank-lines
1939 "l" gnus-article-strip-leading-blank-lines
1940 "m" gnus-article-strip-multiple-blank-lines
1941 "a" gnus-article-strip-blank-lines
1942 "A" gnus-article-strip-all-blank-lines
1943 "s" gnus-article-strip-leading-space
1944 "e" gnus-article-strip-trailing-space
1945 "w" gnus-article-remove-leading-whitespace)
1947 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1949 "f" gnus-summary-fetch-faq
1950 "d" gnus-summary-describe-group
1951 "h" gnus-summary-describe-briefly
1952 "i" gnus-info-find-node
1953 "c" gnus-group-fetch-charter
1954 "C" gnus-group-fetch-control)
1956 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1957 "e" gnus-summary-expire-articles
1958 "\M-\C-e" gnus-summary-expire-articles-now
1959 "\177" gnus-summary-delete-article
1960 [delete] gnus-summary-delete-article
1961 [backspace] gnus-summary-delete-article
1962 "m" gnus-summary-move-article
1963 "r" gnus-summary-respool-article
1964 "w" gnus-summary-edit-article
1965 "c" gnus-summary-copy-article
1966 "B" gnus-summary-crosspost-article
1967 "q" gnus-summary-respool-query
1968 "t" gnus-summary-respool-trace
1969 "i" gnus-summary-import-article
1970 "I" gnus-summary-create-article
1971 "p" gnus-summary-article-posted-p)
1973 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1974 "o" gnus-summary-save-article
1975 "m" gnus-summary-save-article-mail
1976 "F" gnus-summary-write-article-file
1977 "r" gnus-summary-save-article-rmail
1978 "f" gnus-summary-save-article-file
1979 "b" gnus-summary-save-article-body-file
1980 "h" gnus-summary-save-article-folder
1981 "v" gnus-summary-save-article-vm
1982 "p" gnus-summary-pipe-output
1983 "P" gnus-summary-muttprint
1984 "s" gnus-soup-add-article)
1986 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1987 "b" gnus-summary-display-buttonized
1988 "m" gnus-summary-repair-multipart
1989 "v" gnus-article-view-part
1990 "o" gnus-article-save-part
1991 "c" gnus-article-copy-part
1992 "C" gnus-article-view-part-as-charset
1993 "e" gnus-article-view-part-externally
1994 "E" gnus-article-encrypt-body
1995 "i" gnus-article-inline-part
1996 "|" gnus-article-pipe-part)
1998 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1999 "p" gnus-summary-mark-as-processable
2000 "u" gnus-summary-unmark-as-processable
2001 "U" gnus-summary-unmark-all-processable
2002 "v" gnus-uu-mark-over
2003 "s" gnus-uu-mark-series
2004 "r" gnus-uu-mark-region
2005 "g" gnus-uu-unmark-region
2006 "R" gnus-uu-mark-by-regexp
2007 "G" gnus-uu-unmark-by-regexp
2008 "t" gnus-uu-mark-thread
2009 "T" gnus-uu-unmark-thread
2010 "a" gnus-uu-mark-all
2011 "b" gnus-uu-mark-buffer
2012 "S" gnus-uu-mark-sparse
2013 "k" gnus-summary-kill-process-mark
2014 "y" gnus-summary-yank-process-mark
2015 "w" gnus-summary-save-process-mark
2016 "i" gnus-uu-invert-processable)
2018 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2019 ;;"x" gnus-uu-extract-any
2020 "m" gnus-summary-save-parts
2021 "u" gnus-uu-decode-uu
2022 "U" gnus-uu-decode-uu-and-save
2023 "s" gnus-uu-decode-unshar
2024 "S" gnus-uu-decode-unshar-and-save
2025 "o" gnus-uu-decode-save
2026 "O" gnus-uu-decode-save
2027 "b" gnus-uu-decode-binhex
2028 "B" gnus-uu-decode-binhex
2029 "p" gnus-uu-decode-postscript
2030 "P" gnus-uu-decode-postscript-and-save)
2033 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2034 "u" gnus-uu-decode-uu-view
2035 "U" gnus-uu-decode-uu-and-save-view
2036 "s" gnus-uu-decode-unshar-view
2037 "S" gnus-uu-decode-unshar-and-save-view
2038 "o" gnus-uu-decode-save-view
2039 "O" gnus-uu-decode-save-view
2040 "b" gnus-uu-decode-binhex-view
2041 "B" gnus-uu-decode-binhex-view
2042 "p" gnus-uu-decode-postscript-view
2043 "P" gnus-uu-decode-postscript-and-save-view)
2045 (defvar gnus-article-post-menu nil)
2047 (defconst gnus-summary-menu-maxlen 20)
2049 (defun gnus-summary-menu-split (menu)
2050 ;; If we have lots of elements, divide them into groups of 20
2051 ;; and make a pane (or submenu) for each one.
2052 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2053 (let ((menu menu) sublists next
2056 ;; Pull off the next gnus-summary-menu-maxlen elements
2057 ;; and make them the next element of sublist.
2058 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2060 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2062 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2063 (aref (car (last menu)) 0)) menu)
2067 (nreverse sublists))
2068 ;; Few elements--put them all in one pane.
2071 (defun gnus-summary-make-menu-bar ()
2072 (gnus-turn-off-edit-menu 'summary)
2074 (unless (boundp 'gnus-summary-misc-menu)
2077 gnus-summary-kill-menu gnus-summary-mode-map ""
2082 ["Customize" gnus-score-customize t])
2083 (gnus-make-score-map 'increase)
2084 (gnus-make-score-map 'lower)
2086 ["Kill below" gnus-summary-kill-below t]
2087 ["Mark above" gnus-summary-mark-above t]
2088 ["Tick above" gnus-summary-tick-above t]
2089 ["Clear above" gnus-summary-clear-above t])
2090 ["Current score" gnus-summary-current-score t]
2091 ["Set score" gnus-summary-set-score t]
2092 ["Switch current score file..." gnus-score-change-score-file t]
2093 ["Set mark below..." gnus-score-set-mark-below t]
2094 ["Set expunge below..." gnus-score-set-expunge-below t]
2095 ["Edit current score file" gnus-score-edit-current-scores t]
2096 ["Edit score file" gnus-score-edit-file t]
2097 ["Trace score" gnus-score-find-trace t]
2098 ["Find words" gnus-score-find-favourite-words t]
2099 ["Rescore buffer" gnus-summary-rescore t]
2100 ["Increase score..." gnus-summary-increase-score t]
2101 ["Lower score..." gnus-summary-lower-score t]))))
2103 ;; Define both the Article menu in the summary buffer and the
2104 ;; equivalent Commands menu in the article buffer here for
2108 ["All" gnus-article-hide t]
2109 ["Headers" gnus-article-hide-headers t]
2110 ["Signature" gnus-article-hide-signature t]
2111 ["Citation" gnus-article-hide-citation t]
2112 ["List identifiers" gnus-article-hide-list-identifiers t]
2113 ["Banner" gnus-article-strip-banner t]
2114 ["Boring headers" gnus-article-hide-boring-headers t])
2116 ["All" gnus-article-highlight t]
2117 ["Headers" gnus-article-highlight-headers t]
2118 ["Signature" gnus-article-highlight-signature t]
2119 ["Citation" gnus-article-highlight-citation t])
2121 ["Local" gnus-article-date-local t]
2122 ["ISO8601" gnus-article-date-iso8601 t]
2123 ["UT" gnus-article-date-ut t]
2124 ["Original" gnus-article-date-original t]
2125 ["Lapsed" gnus-article-date-lapsed t]
2126 ["User-defined" gnus-article-date-user t])
2128 ["Remove images" gnus-article-remove-images t]
2129 ["Toggle smiley" gnus-treat-smiley t]
2130 ["Show X-Face" gnus-article-display-x-face t]
2131 ["Show picons in From" gnus-treat-from-picon t]
2132 ["Show picons in mail headers" gnus-treat-mail-picon t]
2133 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2134 ("View as different encoding"
2135 ,@(gnus-summary-menu-split
2138 ;; Since easymenu under Emacs doesn't allow
2139 ;; lambda forms for menu commands, we should
2140 ;; provide intern'ed function symbols.
2141 (let ((command (intern (format "\
2142 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2146 (let ((gnus-summary-show-article-charset-alist
2148 (gnus-summary-show-article 1))))
2149 `[,(symbol-name cs) ,command t]))
2150 (sort (if (fboundp 'coding-system-list)
2151 (coding-system-list)
2152 ;;(mapcar 'car mm-mime-mule-charset-alist)
2157 ["Leading" gnus-article-strip-leading-blank-lines t]
2158 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2159 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2160 ["All of the above" gnus-article-strip-blank-lines t]
2161 ["All" gnus-article-strip-all-blank-lines t]
2162 ["Leading space" gnus-article-strip-leading-space t]
2163 ["Trailing space" gnus-article-strip-trailing-space t]
2164 ["Leading space in headers"
2165 gnus-article-remove-leading-whitespace t])
2166 ["Overstrike" gnus-article-treat-overstrike t]
2167 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2168 ["Emphasis" gnus-article-emphasize t]
2169 ["Word wrap" gnus-article-fill-cited-article t]
2170 ["Fill long lines" gnus-article-fill-long-lines t]
2171 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2172 ["Remove CR" gnus-article-remove-cr 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 ["Toggle MIME" gnus-summary-toggle-mime t]
2182 ["Verbose header" gnus-summary-verbose-headers t]
2183 ["Toggle header" gnus-summary-toggle-header t]
2184 ["Unfold headers" gnus-article-treat-unfold-headers t]
2185 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2186 ["Html" gnus-article-wash-html t]
2187 ["Unsplit URLs" gnus-article-unsplit-urls t]
2188 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2189 ["Decode HZ" gnus-article-decode-HZ t]
2190 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2191 ("(Outlook) Deuglify"
2192 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2193 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2194 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2195 ["Full (Outlook) deuglify"
2196 gnus-article-outlook-deuglify-article t])
2199 ["Save in default format..." gnus-summary-save-article
2200 ,@(if (featurep 'xemacs) '(t)
2201 '(:help "Save article using default method"))]
2202 ["Save in file..." gnus-summary-save-article-file
2203 ,@(if (featurep 'xemacs) '(t)
2204 '(:help "Save article in file"))]
2205 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2206 ["Save in MH folder..." gnus-summary-save-article-folder t]
2207 ["Save in VM folder..." gnus-summary-save-article-vm t]
2208 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2209 ["Save body in file..." gnus-summary-save-article-body-file t]
2210 ["Pipe through a filter..." gnus-summary-pipe-output t]
2211 ["Add to SOUP packet" gnus-soup-add-article t]
2212 ["Print with Muttprint..." gnus-summary-muttprint t]
2213 ["Print" gnus-summary-print-article t])
2215 ["Respool article..." gnus-summary-respool-article t]
2216 ["Move article..." gnus-summary-move-article
2217 (gnus-check-backend-function
2218 'request-move-article gnus-newsgroup-name)]
2219 ["Copy article..." gnus-summary-copy-article t]
2220 ["Crosspost article..." gnus-summary-crosspost-article
2221 (gnus-check-backend-function
2222 'request-replace-article gnus-newsgroup-name)]
2223 ["Import file..." gnus-summary-import-article
2224 (gnus-check-backend-function
2225 'request-accept-article gnus-newsgroup-name)]
2226 ["Create article..." gnus-summary-create-article
2227 (gnus-check-backend-function
2228 'request-accept-article gnus-newsgroup-name)]
2229 ["Check if posted" gnus-summary-article-posted-p t]
2230 ["Edit article" gnus-summary-edit-article
2231 (not (gnus-group-read-only-p))]
2232 ["Delete article" gnus-summary-delete-article
2233 (gnus-check-backend-function
2234 'request-expire-articles gnus-newsgroup-name)]
2235 ["Query respool" gnus-summary-respool-query t]
2236 ["Trace respool" gnus-summary-respool-trace t]
2237 ["Delete expirable articles" gnus-summary-expire-articles-now
2238 (gnus-check-backend-function
2239 'request-expire-articles gnus-newsgroup-name)])
2241 ["Uudecode" gnus-uu-decode-uu
2242 ,@(if (featurep 'xemacs) '(t)
2243 '(:help "Decode uuencoded article(s)"))]
2244 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2245 ["Unshar" gnus-uu-decode-unshar t]
2246 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2247 ["Save" gnus-uu-decode-save t]
2248 ["Binhex" gnus-uu-decode-binhex t]
2249 ["Postscript" gnus-uu-decode-postscript t])
2251 ["Enter article" gnus-cache-enter-article t]
2252 ["Remove article" gnus-cache-remove-article t])
2253 ["Translate" gnus-article-babel t]
2254 ["Select article buffer" gnus-summary-select-article-buffer t]
2255 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2256 ["Isearch article..." gnus-summary-isearch-article t]
2257 ["Beginning of the article" gnus-summary-beginning-of-article t]
2258 ["End of the article" gnus-summary-end-of-article t]
2259 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2260 ["Fetch referenced articles" gnus-summary-refer-references t]
2261 ["Fetch current thread" gnus-summary-refer-thread t]
2262 ["Fetch article with id..." gnus-summary-refer-article t]
2263 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2264 ["Redisplay" gnus-summary-show-article t]
2265 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2267 gnus-summary-article-menu gnus-summary-mode-map ""
2268 (cons "Article" innards))
2270 (if (not (keymapp gnus-summary-article-menu))
2272 gnus-article-commands-menu gnus-article-mode-map ""
2273 (cons "Commands" innards))
2274 ;; in Emacs, don't share menu.
2275 (setq gnus-article-commands-menu
2276 (copy-keymap gnus-summary-article-menu))
2277 (define-key gnus-article-mode-map [menu-bar commands]
2278 (cons "Commands" gnus-article-commands-menu))))
2281 gnus-summary-thread-menu gnus-summary-mode-map ""
2283 ["Find all messages in thread" gnus-summary-refer-thread t]
2284 ["Toggle threading" gnus-summary-toggle-threads t]
2285 ["Hide threads" gnus-summary-hide-all-threads t]
2286 ["Show threads" gnus-summary-show-all-threads t]
2287 ["Hide thread" gnus-summary-hide-thread t]
2288 ["Show thread" gnus-summary-show-thread t]
2289 ["Go to next thread" gnus-summary-next-thread t]
2290 ["Go to previous thread" gnus-summary-prev-thread t]
2291 ["Go down thread" gnus-summary-down-thread t]
2292 ["Go up thread" gnus-summary-up-thread t]
2293 ["Top of thread" gnus-summary-top-thread t]
2294 ["Mark thread as read" gnus-summary-kill-thread t]
2295 ["Lower thread score" gnus-summary-lower-thread t]
2296 ["Raise thread score" gnus-summary-raise-thread t]
2297 ["Rethread current" gnus-summary-rethread-current t]))
2300 gnus-summary-post-menu gnus-summary-mode-map ""
2302 ["Send a message (mail or news)" gnus-summary-post-news
2303 ,@(if (featurep 'xemacs) '(t)
2304 '(:help "Post an article"))]
2305 ["Followup" gnus-summary-followup
2306 ,@(if (featurep 'xemacs) '(t)
2307 '(:help "Post followup to this article"))]
2308 ["Followup and yank" gnus-summary-followup-with-original
2309 ,@(if (featurep 'xemacs) '(t)
2310 '(:help "Post followup to this article, quoting its contents"))]
2311 ["Supersede article" gnus-summary-supersede-article t]
2312 ["Cancel article" gnus-summary-cancel-article
2313 ,@(if (featurep 'xemacs) '(t)
2314 '(:help "Cancel an article you posted"))]
2315 ["Reply" gnus-summary-reply t]
2316 ["Reply and yank" gnus-summary-reply-with-original t]
2317 ["Wide reply" gnus-summary-wide-reply t]
2318 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2319 ,@(if (featurep 'xemacs) '(t)
2320 '(:help "Mail a reply, quoting this article"))]
2321 ["Very wide reply" gnus-summary-very-wide-reply t]
2322 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2323 ,@(if (featurep 'xemacs) '(t)
2324 '(:help "Mail a very wide reply, quoting this article"))]
2325 ["Mail forward" gnus-summary-mail-forward t]
2326 ["Post forward" gnus-summary-post-forward t]
2327 ["Digest and mail" gnus-summary-digest-mail-forward t]
2328 ["Digest and post" gnus-summary-digest-post-forward t]
2329 ["Resend message" gnus-summary-resend-message t]
2330 ["Resend message edit" gnus-summary-resend-message-edit t]
2331 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2332 ["Send a mail" gnus-summary-mail-other-window t]
2333 ["Create a local message" gnus-summary-news-other-window t]
2334 ["Uuencode and post" gnus-uu-post-news
2335 ,@(if (featurep 'xemacs) '(t)
2336 '(:help "Post a uuencoded article"))]
2337 ["Followup via news" gnus-summary-followup-to-mail t]
2338 ["Followup via news and yank"
2339 gnus-summary-followup-to-mail-with-original t]
2341 ;;["Send" gnus-summary-send-draft t]
2342 ;;["Send bounced" gnus-resend-bounced-mail t])
2346 ((not (keymapp gnus-summary-post-menu))
2347 (setq gnus-article-post-menu gnus-summary-post-menu))
2348 ((not gnus-article-post-menu)
2349 ;; Don't share post menu.
2350 (setq gnus-article-post-menu
2351 (copy-keymap gnus-summary-post-menu))))
2352 (define-key gnus-article-mode-map [menu-bar post]
2353 (cons "Post" gnus-article-post-menu))
2356 gnus-summary-misc-menu gnus-summary-mode-map ""
2359 ["Mark as read" gnus-summary-mark-as-read-forward t]
2360 ["Mark same subject and select"
2361 gnus-summary-kill-same-subject-and-select t]
2362 ["Mark same subject" gnus-summary-kill-same-subject t]
2363 ["Catchup" gnus-summary-catchup
2364 ,@(if (featurep 'xemacs) '(t)
2365 '(:help "Mark unread articles in this group as read"))]
2366 ["Catchup all" gnus-summary-catchup-all t]
2367 ["Catchup to here" gnus-summary-catchup-to-here t]
2368 ["Catchup from here" gnus-summary-catchup-from-here t]
2369 ["Catchup region" gnus-summary-mark-region-as-read
2370 (gnus-mark-active-p)]
2371 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2373 ["Tick" gnus-summary-tick-article-forward t]
2374 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2375 ["Remove marks" gnus-summary-clear-mark-forward t]
2376 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2377 ["Set bookmark" gnus-summary-set-bookmark t]
2378 ["Remove bookmark" gnus-summary-remove-bookmark t])
2380 ["Marks..." gnus-summary-limit-to-marks t]
2381 ["Subject..." gnus-summary-limit-to-subject t]
2382 ["Author..." gnus-summary-limit-to-author t]
2383 ["Age..." gnus-summary-limit-to-age t]
2384 ["Extra..." gnus-summary-limit-to-extra t]
2385 ["Score..." gnus-summary-limit-to-score t]
2386 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2387 ["Unread" gnus-summary-limit-to-unread t]
2388 ["Unseen" gnus-summary-limit-to-unseen t]
2389 ["Replied" gnus-summary-limit-to-replied t]
2390 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2391 ["Next articles" gnus-summary-limit-to-articles t]
2392 ["Pop limit" gnus-summary-pop-limit t]
2393 ["Show dormant" gnus-summary-limit-include-dormant t]
2394 ["Hide childless dormant"
2395 gnus-summary-limit-exclude-childless-dormant t]
2396 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2397 ["Hide marked" gnus-summary-limit-exclude-marks t]
2398 ["Show expunged" gnus-summary-limit-include-expunged t])
2400 ["Set mark" gnus-summary-mark-as-processable t]
2401 ["Remove mark" gnus-summary-unmark-as-processable t]
2402 ["Remove all marks" gnus-summary-unmark-all-processable t]
2403 ["Mark above" gnus-uu-mark-over t]
2404 ["Mark series" gnus-uu-mark-series t]
2405 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2406 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2407 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2408 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2409 ["Mark all" gnus-uu-mark-all t]
2410 ["Mark buffer" gnus-uu-mark-buffer t]
2411 ["Mark sparse" gnus-uu-mark-sparse t]
2412 ["Mark thread" gnus-uu-mark-thread t]
2413 ["Unmark thread" gnus-uu-unmark-thread t]
2414 ("Process Mark Sets"
2415 ["Kill" gnus-summary-kill-process-mark t]
2416 ["Yank" gnus-summary-yank-process-mark
2417 gnus-newsgroup-process-stack]
2418 ["Save" gnus-summary-save-process-mark t]
2419 ["Run command on marked..." gnus-summary-universal-argument t]))
2421 ["Page forward" gnus-summary-next-page
2422 ,@(if (featurep 'xemacs) '(t)
2423 '(:help "Show next page of article"))]
2424 ["Page backward" gnus-summary-prev-page
2425 ,@(if (featurep 'xemacs) '(t)
2426 '(:help "Show previous page of article"))]
2427 ["Line forward" gnus-summary-scroll-up t])
2429 ["Next unread article" gnus-summary-next-unread-article t]
2430 ["Previous unread article" gnus-summary-prev-unread-article t]
2431 ["Next article" gnus-summary-next-article t]
2432 ["Previous article" gnus-summary-prev-article t]
2433 ["Next unread subject" gnus-summary-next-unread-subject t]
2434 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2435 ["Next article same subject" gnus-summary-next-same-subject t]
2436 ["Previous article same subject" gnus-summary-prev-same-subject t]
2437 ["First unread article" gnus-summary-first-unread-article t]
2438 ["Best unread article" gnus-summary-best-unread-article t]
2439 ["Go to subject number..." gnus-summary-goto-subject t]
2440 ["Go to article number..." gnus-summary-goto-article t]
2441 ["Go to the last article" gnus-summary-goto-last-article t]
2442 ["Pop article off history" gnus-summary-pop-article t])
2444 ["Sort by number" gnus-summary-sort-by-number t]
2445 ["Sort by author" gnus-summary-sort-by-author t]
2446 ["Sort by subject" gnus-summary-sort-by-subject t]
2447 ["Sort by date" gnus-summary-sort-by-date t]
2448 ["Sort by score" gnus-summary-sort-by-score t]
2449 ["Sort by lines" gnus-summary-sort-by-lines t]
2450 ["Sort by characters" gnus-summary-sort-by-chars t]
2451 ["Randomize" gnus-summary-sort-by-random t]
2452 ["Original sort" gnus-summary-sort-by-original t])
2454 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2455 ["Describe group" gnus-summary-describe-group t]
2456 ["Fetch charter" gnus-group-fetch-charter
2457 ,@(if (featurep 'xemacs) nil
2458 '(:help "Display the charter of the current group"))]
2459 ["Fetch control message" gnus-group-fetch-control
2460 ,@(if (featurep 'xemacs) nil
2461 '(:help "Display the archived control message for the current group"))]
2462 ["Read manual" gnus-info-find-node t])
2464 ["Pick and read" gnus-pick-mode t]
2465 ["Binary" gnus-binary-mode t])
2467 ["Regenerate" gnus-summary-prepare t]
2468 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2469 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2470 ["Toggle threading" gnus-summary-toggle-threads t])
2471 ["See old articles" gnus-summary-insert-old-articles t]
2472 ["See new articles" gnus-summary-insert-new-articles t]
2473 ["Filter articles..." gnus-summary-execute-command t]
2474 ["Run command on articles..." gnus-summary-universal-argument t]
2475 ["Search articles forward..." gnus-summary-search-article-forward t]
2476 ["Search articles backward..." gnus-summary-search-article-backward t]
2477 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2478 ["Expand window" gnus-summary-expand-window t]
2479 ["Expire expirable articles" gnus-summary-expire-articles
2480 (gnus-check-backend-function
2481 'request-expire-articles gnus-newsgroup-name)]
2482 ["Edit local kill file" gnus-summary-edit-local-kill t]
2483 ["Edit main kill file" gnus-summary-edit-global-kill t]
2484 ["Edit group parameters" gnus-summary-edit-parameters t]
2485 ["Customize group parameters" gnus-summary-customize-parameters t]
2486 ["Send a bug report" gnus-bug t]
2488 ["Catchup and exit" gnus-summary-catchup-and-exit
2489 ,@(if (featurep 'xemacs) '(t)
2490 '(:help "Mark unread articles in this group as read, then exit"))]
2491 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2492 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2493 ["Exit group" gnus-summary-exit
2494 ,@(if (featurep 'xemacs) '(t)
2495 '(:help "Exit current group, return to group selection mode"))]
2496 ["Exit group without updating" gnus-summary-exit-no-update t]
2497 ["Exit and goto next group" gnus-summary-next-group t]
2498 ["Exit and goto prev group" gnus-summary-prev-group t]
2499 ["Reselect group" gnus-summary-reselect-current-group t]
2500 ["Rescan group" gnus-summary-rescan-group t]
2501 ["Update dribble" gnus-summary-save-newsrc t])))
2503 (gnus-run-hooks 'gnus-summary-menu-hook)))
2505 (defvar gnus-summary-tool-bar-map nil)
2507 ;; Emacs 21 tool bar. Should be no-op otherwise.
2508 (defun gnus-summary-make-tool-bar ()
2509 (if (and (fboundp 'tool-bar-add-item-from-menu)
2510 (default-value 'tool-bar-mode)
2511 (not gnus-summary-tool-bar-map))
2512 (setq gnus-summary-tool-bar-map
2513 (let ((tool-bar-map (make-sparse-keymap))
2514 (load-path (mm-image-load-path)))
2515 (tool-bar-add-item-from-menu
2516 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2517 (tool-bar-add-item-from-menu
2518 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2519 (tool-bar-add-item-from-menu
2520 'gnus-summary-post-news "post" gnus-summary-mode-map)
2521 (tool-bar-add-item-from-menu
2522 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2523 (tool-bar-add-item-from-menu
2524 'gnus-summary-followup "followup" gnus-summary-mode-map)
2525 (tool-bar-add-item-from-menu
2526 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2527 (tool-bar-add-item-from-menu
2528 'gnus-summary-reply "reply" gnus-summary-mode-map)
2529 (tool-bar-add-item-from-menu
2530 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2531 (tool-bar-add-item-from-menu
2532 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2533 (tool-bar-add-item-from-menu
2534 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2535 (tool-bar-add-item-from-menu
2536 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2537 (tool-bar-add-item-from-menu
2538 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2539 (tool-bar-add-item-from-menu
2540 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2541 (tool-bar-add-item-from-menu
2542 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2543 (tool-bar-add-item-from-menu
2544 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2546 (if gnus-summary-tool-bar-map
2547 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2549 (defun gnus-score-set-default (var value)
2550 "A version of set that updates the GNU Emacs menu-bar."
2552 ;; It is the message that forces the active status to be updated.
2555 (defun gnus-make-score-map (type)
2556 "Make a summary score map of type TYPE."
2559 (let ((headers '(("author" "from" string)
2560 ("subject" "subject" string)
2561 ("article body" "body" string)
2562 ("article head" "head" string)
2563 ("xref" "xref" string)
2564 ("extra header" "extra" string)
2565 ("lines" "lines" number)
2566 ("followups to author" "followup" string)))
2567 (types '((number ("less than" <)
2570 (string ("substring" s)
2574 (perms '(("temporary" (current-time-string))
2582 (if (eq type 'lower)
2587 (setq header (car headers))
2593 (let ((ts (cdr (assoc (nth 2 header) types)))
2609 'gnus-summary-score-entry
2611 (if (or (string= (nth 1 header)
2613 (string= (nth 1 header)
2616 (list 'gnus-summary-header
2618 (list 'quote (nth 1 (car ts)))
2619 (list 'gnus-score-delta-default
2626 (list (nreverse outp))))
2629 (list (nreverse outt))))
2631 (setq headers (cdr headers)))
2632 (list (nreverse outh))))))))
2636 (defun gnus-summary-mode (&optional group)
2637 "Major mode for reading articles.
2639 All normal editing commands are switched off.
2640 \\<gnus-summary-mode-map>
2641 Each line in this buffer represents one article. To read an
2642 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2643 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2646 You can also post articles and send mail from this buffer. To
2647 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2648 of an article, type `\\[gnus-summary-reply]'.
2650 There are approx. one gazillion commands you can execute in this
2651 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2653 The following commands are available:
2655 \\{gnus-summary-mode-map}"
2657 (kill-all-local-variables)
2658 (when (gnus-visual-p 'summary-menu 'menu)
2659 (gnus-summary-make-menu-bar)
2660 (gnus-summary-make-tool-bar))
2661 (gnus-summary-make-local-variables)
2662 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2663 (gnus-summary-make-local-variables))
2664 (gnus-make-thread-indent-array)
2665 (gnus-simplify-mode-line)
2666 (setq major-mode 'gnus-summary-mode)
2667 (setq mode-name "Summary")
2668 (make-local-variable 'minor-mode-alist)
2669 (use-local-map gnus-summary-mode-map)
2670 (buffer-disable-undo)
2671 (setq buffer-read-only t) ;Disable modification
2672 (setq truncate-lines t)
2673 (setq selective-display t)
2674 (setq selective-display-ellipses t) ;Display `...'
2675 (gnus-summary-set-display-table)
2676 (gnus-set-default-directory)
2677 (setq gnus-newsgroup-name group)
2678 (unless (gnus-news-group-p group)
2679 (setq gnus-newsgroup-incorporated
2680 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2681 (make-local-variable 'gnus-summary-line-format)
2682 (make-local-variable 'gnus-summary-line-format-spec)
2683 (make-local-variable 'gnus-summary-dummy-line-format)
2684 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2685 (make-local-variable 'gnus-summary-mark-positions)
2686 (gnus-make-local-hook 'pre-command-hook)
2687 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2688 (gnus-run-hooks 'gnus-summary-mode-hook)
2689 (turn-on-gnus-mailing-list-mode)
2690 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2691 (gnus-update-summary-mark-positions))
2693 (defun gnus-summary-make-local-variables ()
2694 "Make all the local summary buffer variables."
2696 (dolist (local gnus-summary-local-variables)
2699 (if (eq (cdr local) 'global)
2700 ;; Copy the global value of the variable.
2701 (setq global (symbol-value (car local)))
2702 ;; Use the value from the list.
2703 (setq global (eval (cdr local))))
2704 (set (make-local-variable (car local)) global))
2705 ;; Simple nil-valued local variable.
2706 (set (make-local-variable local) nil)))))
2708 (defun gnus-summary-clear-local-variables ()
2709 (let ((locals gnus-summary-local-variables))
2711 (if (consp (car locals))
2712 (and (vectorp (caar locals))
2713 (set (caar locals) nil))
2714 (and (vectorp (car locals))
2715 (set (car locals) nil)))
2716 (setq locals (cdr locals)))))
2718 ;; Summary data functions.
2720 (defmacro gnus-data-number (data)
2723 (defmacro gnus-data-set-number (data number)
2724 `(setcar ,data ,number))
2726 (defmacro gnus-data-mark (data)
2729 (defmacro gnus-data-set-mark (data mark)
2730 `(setcar (nthcdr 1 ,data) ,mark))
2732 (defmacro gnus-data-pos (data)
2735 (defmacro gnus-data-set-pos (data pos)
2736 `(setcar (nthcdr 2 ,data) ,pos))
2738 (defmacro gnus-data-header (data)
2741 (defmacro gnus-data-set-header (data header)
2742 `(setcar (nthcdr 3 ,data) ,header))
2744 (defmacro gnus-data-level (data)
2747 (defmacro gnus-data-unread-p (data)
2748 `(= (nth 1 ,data) gnus-unread-mark))
2750 (defmacro gnus-data-read-p (data)
2751 `(/= (nth 1 ,data) gnus-unread-mark))
2753 (defmacro gnus-data-pseudo-p (data)
2754 `(consp (nth 3 ,data)))
2756 (defmacro gnus-data-find (number)
2757 `(assq ,number gnus-newsgroup-data))
2759 (defmacro gnus-data-find-list (number &optional data)
2760 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2761 (memq (assq ,number bdata)
2764 (defmacro gnus-data-make (number mark pos header level)
2765 `(list ,number ,mark ,pos ,header ,level))
2767 (defun gnus-data-enter (after-article number mark pos header level offset)
2768 (let ((data (gnus-data-find-list after-article)))
2770 (error "No such article: %d" after-article))
2771 (setcdr data (cons (gnus-data-make number mark pos header level)
2773 (setq gnus-newsgroup-data-reverse nil)
2774 (gnus-data-update-list (cddr data) offset)))
2776 (defun gnus-data-enter-list (after-article list &optional offset)
2778 (let ((data (and after-article (gnus-data-find-list after-article)))
2782 (let ((odata gnus-newsgroup-data))
2783 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2785 (gnus-data-update-list odata offset)))
2786 ;; Find the last element in the list to be spliced into the main
2789 (setq list (cdr list)))
2792 (setcdr list gnus-newsgroup-data)
2793 (setq gnus-newsgroup-data ilist)
2795 (gnus-data-update-list (cdr list) offset)))
2796 (setcdr list (cdr data))
2799 (gnus-data-update-list (cdr list) offset))))
2800 (setq gnus-newsgroup-data-reverse nil))))
2802 (defun gnus-data-remove (article &optional offset)
2803 (let ((data gnus-newsgroup-data))
2804 (if (= (gnus-data-number (car data)) article)
2806 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2807 gnus-newsgroup-data-reverse nil)
2809 (gnus-data-update-list gnus-newsgroup-data offset)))
2811 (when (= (gnus-data-number (cadr data)) article)
2812 (setcdr data (cddr data))
2814 (gnus-data-update-list (cdr data) offset))
2816 gnus-newsgroup-data-reverse nil))
2817 (setq data (cdr data))))))
2819 (defmacro gnus-data-list (backward)
2821 (or gnus-newsgroup-data-reverse
2822 (setq gnus-newsgroup-data-reverse
2823 (reverse gnus-newsgroup-data)))
2824 gnus-newsgroup-data))
2826 (defun gnus-data-update-list (data offset)
2827 "Add OFFSET to the POS of all data entries in DATA."
2828 (setq gnus-newsgroup-data-reverse nil)
2830 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2831 (setq data (cdr data))))
2833 (defun gnus-summary-article-pseudo-p (article)
2834 "Say whether this article is a pseudo article or not."
2835 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2837 (defmacro gnus-summary-article-sparse-p (article)
2838 "Say whether this article is a sparse article or not."
2839 `(memq ,article gnus-newsgroup-sparse))
2841 (defmacro gnus-summary-article-ancient-p (article)
2842 "Say whether this article is a sparse article or not."
2843 `(memq ,article gnus-newsgroup-ancient))
2845 (defun gnus-article-parent-p (number)
2846 "Say whether this article is a parent or not."
2847 (let ((data (gnus-data-find-list number)))
2848 (and (cdr data) ; There has to be an article after...
2849 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2850 (gnus-data-level (nth 1 data))))))
2852 (defun gnus-article-children (number)
2853 "Return a list of all children to NUMBER."
2854 (let* ((data (gnus-data-find-list number))
2855 (level (gnus-data-level (car data)))
2857 (setq data (cdr data))
2859 (= (gnus-data-level (car data)) (1+ level)))
2860 (push (gnus-data-number (car data)) children)
2861 (setq data (cdr data)))
2864 (defmacro gnus-summary-skip-intangible ()
2865 "If the current article is intangible, then jump to a different article."
2866 '(let ((to (get-text-property (point) 'gnus-intangible)))
2867 (and to (gnus-summary-goto-subject to))))
2869 (defmacro gnus-summary-article-intangible-p ()
2870 "Say whether this article is intangible or not."
2871 '(get-text-property (point) 'gnus-intangible))
2873 (defun gnus-article-read-p (article)
2874 "Say whether ARTICLE is read or not."
2875 (not (or (memq article gnus-newsgroup-marked)
2876 (memq article gnus-newsgroup-spam-marked)
2877 (memq article gnus-newsgroup-unreads)
2878 (memq article gnus-newsgroup-unselected)
2879 (memq article gnus-newsgroup-dormant))))
2881 ;; Some summary mode macros.
2883 (defmacro gnus-summary-article-number ()
2884 "The article number of the article on the current line.
2885 If there isn't an article number here, then we return the current
2888 (gnus-summary-skip-intangible)
2889 (or (get-text-property (point) 'gnus-number)
2890 (gnus-summary-last-subject))))
2892 (defmacro gnus-summary-article-header (&optional number)
2893 "Return the header of article NUMBER."
2894 `(gnus-data-header (gnus-data-find
2895 ,(or number '(gnus-summary-article-number)))))
2897 (defmacro gnus-summary-thread-level (&optional number)
2898 "Return the level of thread that starts with article NUMBER."
2899 `(if (and (eq gnus-summary-make-false-root 'dummy)
2900 (get-text-property (point) 'gnus-intangible))
2902 (gnus-data-level (gnus-data-find
2903 ,(or number '(gnus-summary-article-number))))))
2905 (defmacro gnus-summary-article-mark (&optional number)
2906 "Return the mark of article NUMBER."
2907 `(gnus-data-mark (gnus-data-find
2908 ,(or number '(gnus-summary-article-number)))))
2910 (defmacro gnus-summary-article-pos (&optional number)
2911 "Return the position of the line of article NUMBER."
2912 `(gnus-data-pos (gnus-data-find
2913 ,(or number '(gnus-summary-article-number)))))
2915 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2916 (defmacro gnus-summary-article-subject (&optional number)
2917 "Return current subject string or nil if nothing."
2920 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2921 '(gnus-data-header (assq (gnus-summary-article-number)
2922 gnus-newsgroup-data)))))
2925 (mail-header-subject headers))))
2927 (defmacro gnus-summary-article-score (&optional number)
2928 "Return current article score."
2929 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2930 gnus-newsgroup-scored))
2931 gnus-summary-default-score 0))
2933 (defun gnus-summary-article-children (&optional number)
2934 "Return a list of article numbers that are children of article NUMBER."
2935 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2936 (level (gnus-data-level (car data)))
2938 (while (and (setq data (cdr data))
2939 (> (setq l (gnus-data-level (car data))) level))
2940 (and (= (1+ level) l)
2941 (push (gnus-data-number (car data))
2943 (nreverse children)))
2945 (defun gnus-summary-article-parent (&optional number)
2946 "Return the article number of the parent of article NUMBER."
2947 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2948 (gnus-data-list t)))
2949 (level (gnus-data-level (car data))))
2951 () ; This is a root.
2952 ;; We search until we find an article with a level less than
2953 ;; this one. That function has to be the parent.
2954 (while (and (setq data (cdr data))
2955 (not (< (gnus-data-level (car data)) level))))
2956 (and data (gnus-data-number (car data))))))
2958 (defun gnus-unread-mark-p (mark)
2959 "Say whether MARK is the unread mark."
2960 (= mark gnus-unread-mark))
2962 (defun gnus-read-mark-p (mark)
2963 "Say whether MARK is one of the marks that mark as read.
2964 This is all marks except unread, ticked, dormant, and expirable."
2965 (not (or (= mark gnus-unread-mark)
2966 (= mark gnus-ticked-mark)
2967 (= mark gnus-spam-mark)
2968 (= mark gnus-dormant-mark)
2969 (= mark gnus-expirable-mark))))
2971 (defmacro gnus-article-mark (number)
2972 "Return the MARK of article NUMBER.
2973 This macro should only be used when computing the mark the \"first\"
2974 time; i.e., when generating the summary lines. After that,
2975 `gnus-summary-article-mark' should be used to examine the
2978 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2979 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2980 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2981 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2982 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2983 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2984 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2985 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2986 gnus-ancient-mark))))
2988 ;; Saving hidden threads.
2990 (defmacro gnus-save-hidden-threads (&rest forms)
2991 "Save hidden threads, eval FORMS, and restore the hidden threads."
2992 (let ((config (make-symbol "config")))
2993 `(let ((,config (gnus-hidden-threads-configuration)))
2997 (gnus-restore-hidden-threads-configuration ,config)))))
2998 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2999 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3001 (defun gnus-data-compute-positions ()
3002 "Compute the positions of all articles."
3003 (setq gnus-newsgroup-data-reverse nil)
3004 (let ((data gnus-newsgroup-data))
3006 (gnus-save-hidden-threads
3007 (gnus-summary-show-all-threads)
3008 (goto-char (point-min))
3010 (while (get-text-property (point) 'gnus-intangible)
3012 (gnus-data-set-pos (car data) (+ (point) 3))
3013 (setq data (cdr data))
3014 (forward-line 1))))))
3016 (defun gnus-hidden-threads-configuration ()
3017 "Return the current hidden threads configuration."
3020 (goto-char (point-min))
3021 (while (search-forward "\r" nil t)
3022 (push (1- (point)) config))
3025 (defun gnus-restore-hidden-threads-configuration (config)
3026 "Restore hidden threads configuration from CONFIG."
3028 (let (point buffer-read-only)
3029 (while (setq point (pop config))
3030 (when (and (< point (point-max))
3032 (eq (char-after) ?\n))
3033 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3035 ;; Various summary mode internalish functions.
3037 (defun gnus-mouse-pick-article (e)
3040 (gnus-summary-next-page nil t))
3042 (defun gnus-summary-set-display-table ()
3043 "Change the display table.
3044 Odd characters have a tendency to mess
3045 up nicely formatted displays - we make all possible glyphs
3046 display only a single character."
3048 ;; We start from the standard display table, if any.
3049 (let ((table (or (copy-sequence standard-display-table)
3050 (make-display-table)))
3052 ;; Nix out all the control chars...
3053 (while (>= (setq i (1- i)) 0)
3054 (aset table i [??]))
3055 ;; ... but not newline and cr, of course. (cr is necessary for the
3056 ;; selective display).
3057 (aset table ?\n nil)
3058 (aset table ?\r nil)
3059 ;; We keep TAB as well.
3060 (aset table ?\t nil)
3061 ;; We nix out any glyphs over 126 that are not set already.
3063 (while (>= (setq i (1- i)) 127)
3064 ;; Only modify if the entry is nil.
3065 (unless (aref table i)
3066 (aset table i [??]))))
3067 (setq buffer-display-table table)))
3069 (defun gnus-summary-set-article-display-arrow (pos)
3070 "Update the overlay arrow to point to line at position POS."
3071 (when (and gnus-summary-display-arrow
3072 (boundp 'overlay-arrow-position)
3073 (boundp 'overlay-arrow-string))
3077 (unless overlay-arrow-position
3078 (setq overlay-arrow-position (make-marker)))
3079 (setq overlay-arrow-string "=>"
3080 overlay-arrow-position (set-marker overlay-arrow-position
3082 (current-buffer))))))
3084 (defun gnus-summary-setup-buffer (group)
3085 "Initialize summary buffer."
3086 (let ((buffer (gnus-summary-buffer-name group))
3087 (dead-name (concat "*Dead Summary "
3088 (gnus-group-decoded-name group) "*")))
3089 ;; If a dead summary buffer exists, we kill it.
3090 (when (gnus-buffer-live-p dead-name)
3091 (gnus-kill-buffer dead-name))
3092 (if (get-buffer buffer)
3095 (setq gnus-summary-buffer (current-buffer))
3096 (not gnus-newsgroup-prepared))
3097 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3098 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3099 (gnus-summary-mode group)
3101 (gnus-carpal-setup-buffer 'summary))
3102 (unless gnus-single-article-buffer
3103 (make-local-variable 'gnus-article-buffer)
3104 (make-local-variable 'gnus-article-current)
3105 (make-local-variable 'gnus-original-article-buffer))
3106 (setq gnus-newsgroup-name group)
3107 ;; Set any local variables in the group parameters.
3108 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3111 (defun gnus-set-global-variables ()
3112 "Set the global equivalents of the buffer-local variables.
3113 They are set to the latest values they had. These reflect the summary
3114 buffer that was in action when the last article was fetched."
3115 (when (eq major-mode 'gnus-summary-mode)
3116 (setq gnus-summary-buffer (current-buffer))
3117 (let ((name gnus-newsgroup-name)
3118 (marked gnus-newsgroup-marked)
3119 (spam gnus-newsgroup-spam-marked)
3120 (unread gnus-newsgroup-unreads)
3121 (headers gnus-current-headers)
3122 (data gnus-newsgroup-data)
3123 (summary gnus-summary-buffer)
3124 (article-buffer gnus-article-buffer)
3125 (original gnus-original-article-buffer)
3126 (gac gnus-article-current)
3127 (reffed gnus-reffed-article-number)
3128 (score-file gnus-current-score-file)
3129 (default-charset gnus-newsgroup-charset)
3131 (let ((locals gnus-newsgroup-variables))
3133 (if (consp (car locals))
3134 (push (eval (caar locals)) vlist)
3135 (push (eval (car locals)) vlist))
3136 (setq locals (cdr locals)))
3137 (setq vlist (nreverse vlist)))
3139 (set-buffer gnus-group-buffer)
3140 (setq gnus-newsgroup-name name
3141 gnus-newsgroup-marked marked
3142 gnus-newsgroup-spam-marked spam
3143 gnus-newsgroup-unreads unread
3144 gnus-current-headers headers
3145 gnus-newsgroup-data data
3146 gnus-article-current gac
3147 gnus-summary-buffer summary
3148 gnus-article-buffer article-buffer
3149 gnus-original-article-buffer original
3150 gnus-reffed-article-number reffed
3151 gnus-current-score-file score-file
3152 gnus-newsgroup-charset default-charset)
3153 (let ((locals gnus-newsgroup-variables))
3155 (if (consp (car locals))
3156 (set (caar locals) (pop vlist))
3157 (set (car locals) (pop vlist)))
3158 (setq locals (cdr locals))))
3159 ;; The article buffer also has local variables.
3160 (when (gnus-buffer-live-p gnus-article-buffer)
3161 (set-buffer gnus-article-buffer)
3162 (setq gnus-summary-buffer summary))))))
3164 (defun gnus-summary-article-unread-p (article)
3165 "Say whether ARTICLE is unread or not."
3166 (memq article gnus-newsgroup-unreads))
3168 (defun gnus-summary-first-article-p (&optional article)
3169 "Return whether ARTICLE is the first article in the buffer."
3170 (if (not (setq article (or article (gnus-summary-article-number))))
3172 (eq article (caar gnus-newsgroup-data))))
3174 (defun gnus-summary-last-article-p (&optional article)
3175 "Return whether ARTICLE is the last article in the buffer."
3176 (if (not (setq article (or article (gnus-summary-article-number))))
3177 ;; All non-existent numbers are the last article. :-)
3179 (not (cdr (gnus-data-find-list article)))))
3181 (defun gnus-make-thread-indent-array ()
3183 (unless (and gnus-thread-indent-array
3184 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3185 (setq gnus-thread-indent-array (make-vector 201 "")
3186 gnus-thread-indent-array-level gnus-thread-indent-level)
3188 (aset gnus-thread-indent-array n
3189 (make-string (* n gnus-thread-indent-level) ? ))
3192 (defun gnus-update-summary-mark-positions ()
3193 "Compute where the summary marks are to go."
3195 (when (gnus-buffer-exists-p gnus-summary-buffer)
3196 (set-buffer gnus-summary-buffer))
3197 (let ((gnus-replied-mark 129)
3198 (gnus-score-below-mark 130)
3199 (gnus-score-over-mark 130)
3200 (gnus-undownloaded-mark 131)
3201 (spec gnus-summary-line-format-spec)
3204 (gnus-set-work-buffer)
3205 (let ((gnus-summary-line-format-spec spec)
3206 (gnus-newsgroup-downloadable '(0)))
3207 (gnus-summary-insert-line
3208 (make-full-mail-header 0 "" "nobody"
3209 "05 Apr 2001 23:33:09 +0400"
3211 0 nil t 128 t nil "" nil 1)
3212 (goto-char (point-min))
3213 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3214 (- (point) (point-min) 1)))))
3215 (goto-char (point-min))
3216 (push (cons 'replied (and (search-forward "\201" nil t)
3217 (- (point) (point-min) 1)))
3219 (goto-char (point-min))
3220 (push (cons 'score (and (search-forward "\202" nil t)
3221 (- (point) (point-min) 1)))
3223 (goto-char (point-min))
3224 (push (cons 'download
3225 (and (search-forward "\203" nil t)
3226 (- (point) (point-min) 1)))
3228 (setq gnus-summary-mark-positions pos))))
3230 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3231 "Insert a dummy root in the summary buffer."
3233 (gnus-add-text-properties
3234 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3235 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3237 (defun gnus-summary-extract-address-component (from)
3238 (or (car (funcall gnus-extract-address-components from))
3241 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3242 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3243 default-mime-charset)))
3244 ;; Is it really necessary to do this next part for each summary line?
3245 ;; Luckily, doesn't seem to slow things down much.
3247 (and gnus-ignored-from-addresses
3248 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3249 (let ((extra-headers (mail-header-extra header))
3253 ((setq to (cdr (assq 'To extra-headers)))
3256 (gnus-summary-extract-address-component
3257 (funcall gnus-decode-encoded-word-function to)))))
3258 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3259 (concat "=> " newsgroups)))))
3260 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3262 (defun gnus-summary-insert-line (gnus-tmp-header
3263 gnus-tmp-level gnus-tmp-current
3264 undownloaded gnus-tmp-unread gnus-tmp-replied
3265 gnus-tmp-expirable gnus-tmp-subject-or-nil
3266 &optional gnus-tmp-dummy gnus-tmp-score
3268 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3269 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3270 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3271 (gnus-tmp-score-char
3272 (if (or (null gnus-summary-default-score)
3273 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3274 gnus-summary-zcore-fuzz))
3276 (if (< gnus-tmp-score gnus-summary-default-score)
3277 gnus-score-below-mark gnus-score-over-mark)))
3278 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3280 (cond (gnus-tmp-process gnus-process-mark)
3281 ((memq gnus-tmp-current gnus-newsgroup-cached)
3283 (gnus-tmp-replied gnus-replied-mark)
3284 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3285 gnus-forwarded-mark)
3286 ((memq gnus-tmp-current gnus-newsgroup-saved)
3288 ((memq gnus-tmp-number gnus-newsgroup-recent)
3290 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3293 (gnus-tmp-downloaded
3295 gnus-undownloaded-mark)
3296 (gnus-newsgroup-agentized
3297 gnus-downloaded-mark)
3300 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3303 ((string-match "<[^>]+> *$" gnus-tmp-from)
3304 (let ((beg (match-beginning 0)))
3305 (or (and (string-match "^\".+\"" gnus-tmp-from)
3306 (substring gnus-tmp-from 1 (1- (match-end 0))))
3307 (substring gnus-tmp-from 0 beg))))
3308 ((string-match "(.+)" gnus-tmp-from)
3309 (substring gnus-tmp-from
3310 (1+ (match-beginning 0)) (1- (match-end 0))))
3312 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3313 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3314 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3315 (buffer-read-only nil))
3316 (when (string= gnus-tmp-name "")
3317 (setq gnus-tmp-name gnus-tmp-from))
3318 (unless (numberp gnus-tmp-lines)
3319 (setq gnus-tmp-lines -1))
3320 (if (= gnus-tmp-lines -1)
3321 (setq gnus-tmp-lines "?")
3322 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3323 (gnus-put-text-property-excluding-characters-with-faces
3325 (progn (eval gnus-summary-line-format-spec) (point))
3326 'gnus-number gnus-tmp-number)
3327 (when (gnus-visual-p 'summary-highlight 'highlight)
3329 (gnus-run-hooks 'gnus-summary-update-hook)
3332 (defun gnus-summary-update-line (&optional dont-update)
3333 "Update summary line after change."
3334 (when (and gnus-summary-default-score
3335 (not gnus-summary-inhibit-highlight))
3336 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3337 (article (gnus-summary-article-number))
3338 (score (gnus-summary-article-score article)))
3340 (if (and gnus-summary-mark-below
3341 (< (gnus-summary-article-score)
3342 gnus-summary-mark-below))
3343 ;; This article has a low score, so we mark it as read.
3344 (when (memq article gnus-newsgroup-unreads)
3345 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3346 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3347 ;; This article was previously marked as read on account
3348 ;; of a low score, but now it has risen, so we mark it as
3350 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3351 (gnus-summary-update-mark
3352 (if (or (null gnus-summary-default-score)
3353 (<= (abs (- score gnus-summary-default-score))
3354 gnus-summary-zcore-fuzz))
3356 (if (< score gnus-summary-default-score)
3357 gnus-score-below-mark gnus-score-over-mark))
3359 ;; Do visual highlighting.
3360 (when (gnus-visual-p 'summary-highlight 'highlight)
3361 (gnus-run-hooks 'gnus-summary-update-hook)))))
3363 (defvar gnus-tmp-new-adopts nil)
3365 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3366 "Return the number of articles in THREAD.
3367 This may be 0 in some cases -- if none of the articles in
3368 the thread are to be displayed."
3370 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3372 ((not (listp thread))
3374 ((and (consp thread) (cdr thread))
3377 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3380 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3383 (when (and level (zerop level) gnus-tmp-new-adopts)
3386 'gnus-summary-number-of-articles-in-thread
3387 gnus-tmp-new-adopts))))
3389 (if (> number 1) gnus-not-empty-thread-mark
3390 gnus-empty-thread-mark)
3393 (defsubst gnus-summary-line-message-size (head)
3394 "Return pretty-printed version of message size.
3395 This function is intended to be used in
3396 `gnus-summary-line-format-alist'."
3397 (let ((c (or (mail-header-chars head) -1)))
3398 (cond ((< c 0) "n/a") ; chars not available
3399 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3400 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3401 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3402 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3405 (defun gnus-summary-set-local-parameters (group)
3406 "Go through the local params of GROUP and set all variable specs in that list."
3407 (let ((params (gnus-group-find-parameter group))
3408 (vars '(quit-config)) ; Ignore quit-config.
3411 (setq elem (car params)
3412 params (cdr params))
3413 (and (consp elem) ; Has to be a cons.
3414 (consp (cdr elem)) ; The cdr has to be a list.
3415 (symbolp (car elem)) ; Has to be a symbol in there.
3416 (not (memq (car elem) vars))
3417 (ignore-errors ; So we set it.
3418 (push (car elem) vars)
3419 (make-local-variable (car elem))
3420 (set (car elem) (eval (nth 1 elem))))))))
3422 (defun gnus-summary-read-group (group &optional show-all no-article
3423 kill-buffer no-display backward
3425 "Start reading news in newsgroup GROUP.
3426 If SHOW-ALL is non-nil, already read articles are also listed.
3427 If NO-ARTICLE is non-nil, no article is selected initially.
3428 If NO-DISPLAY, don't generate a summary buffer."
3432 (let ((gnus-auto-select-next nil))
3433 (or (gnus-summary-read-group-1
3434 group show-all no-article
3435 kill-buffer no-display
3438 select-articles nil)))))
3439 (eq gnus-auto-select-next 'quietly))
3440 (set-buffer gnus-group-buffer)
3441 ;; The entry function called above goes to the next
3442 ;; group automatically, so we go two groups back
3443 ;; if we are searching for the previous group.
3445 (gnus-group-prev-unread-group 2))
3446 (if (not (equal group (gnus-group-group-name)))
3447 (setq group (gnus-group-group-name))
3451 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3452 "Directly jump to the other GROUP from summary buffer.
3453 If SHOW-ALL is non-nil, already read articles are also listed."
3455 (if (eq gnus-summary-buffer (current-buffer))
3456 (list (completing-read
3457 "Group: " gnus-active-hashtb nil t
3458 (when (and gnus-newsgroup-name
3459 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3460 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3461 'gnus-group-history)
3463 (error "%s must be invoked from a gnus summary buffer." this-command)))
3464 (unless (or (zerop (length group))
3465 (and gnus-newsgroup-name
3466 (string-equal gnus-newsgroup-name group)))
3468 (gnus-summary-read-group group show-all
3469 gnus-dont-select-after-jump-to-other-group)))
3471 (defun gnus-summary-read-group-1 (group show-all no-article
3472 kill-buffer no-display
3473 &optional select-articles)
3474 ;; Killed foreign groups can't be entered.
3475 ;; (when (and (not (gnus-group-native-p group))
3476 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3477 ;; (error "Dead non-native groups can't be entered"))
3478 (gnus-message 5 "Retrieving newsgroup: %s..."
3479 (gnus-group-decoded-name group))
3480 (let* ((new-group (gnus-summary-setup-buffer group))
3481 (quit-config (gnus-group-quit-config group))
3482 (did-select (and new-group (gnus-select-newsgroup
3483 group show-all select-articles))))
3485 ;; This summary buffer exists already, so we just select it.
3487 (gnus-set-global-variables)
3489 (gnus-kill-or-deaden-summary kill-buffer))
3490 (gnus-configure-windows 'summary 'force)
3491 (gnus-set-mode-line 'summary)
3492 (gnus-summary-position-point)
3495 ;; We couldn't select this group.
3497 (when (and (eq major-mode 'gnus-summary-mode)
3498 (not (equal (current-buffer) kill-buffer)))
3499 (kill-buffer (current-buffer))
3500 (if (not quit-config)
3502 ;; Update the info -- marks might need to be removed,
3504 (gnus-summary-update-info)
3505 (set-buffer gnus-group-buffer)
3506 (gnus-group-jump-to-group group)
3507 (gnus-group-next-unread-group 1))
3508 (gnus-handle-ephemeral-exit quit-config)))
3509 (let ((grpinfo (gnus-get-info group)))
3510 (if (null (gnus-info-read grpinfo))
3511 (gnus-message 3 "Group %s contains no messages"
3512 (gnus-group-decoded-name group))
3513 (gnus-message 3 "Can't select group")))
3515 ;; The user did a `C-g' while prompting for number of articles,
3516 ;; so we exit this group.
3517 ((eq did-select 'quit)
3518 (and (eq major-mode 'gnus-summary-mode)
3519 (not (equal (current-buffer) kill-buffer))
3520 (kill-buffer (current-buffer)))
3522 (gnus-kill-or-deaden-summary kill-buffer))
3523 (if (not quit-config)
3525 (set-buffer gnus-group-buffer)
3526 (gnus-group-jump-to-group group)
3527 (gnus-group-next-unread-group 1)
3528 (gnus-configure-windows 'group 'force))
3529 (gnus-handle-ephemeral-exit quit-config))
3530 ;; Finally signal the quit.
3532 ;; The group was successfully selected.
3534 (gnus-set-global-variables)
3535 ;; Save the active value in effect when the group was entered.
3536 (setq gnus-newsgroup-active
3538 (gnus-active gnus-newsgroup-name)))
3539 ;; You can change the summary buffer in some way with this hook.
3540 (gnus-run-hooks 'gnus-select-group-hook)
3541 (gnus-update-format-specifications
3542 nil 'summary 'summary-mode 'summary-dummy)
3543 (gnus-update-summary-mark-positions)
3544 ;; Do score processing.
3545 (when gnus-use-scoring
3546 (gnus-possibly-score-headers))
3547 ;; Check whether to fill in the gaps in the threads.
3548 (when gnus-build-sparse-threads
3549 (gnus-build-sparse-threads))
3550 ;; Find the initial limit.
3551 (if gnus-show-threads
3553 (let ((gnus-newsgroup-dormant nil))
3554 (gnus-summary-initial-limit show-all))
3555 (gnus-summary-initial-limit show-all))
3556 ;; When unthreaded, all articles are always shown.
3557 (setq gnus-newsgroup-limit
3559 (lambda (header) (mail-header-number header))
3560 gnus-newsgroup-headers)))
3561 ;; Generate the summary buffer.
3563 (gnus-summary-prepare))
3564 (when gnus-use-trees
3565 (gnus-tree-open group)
3566 (setq gnus-summary-highlight-line-function
3567 'gnus-tree-highlight-article))
3568 ;; If the summary buffer is empty, but there are some low-scored
3569 ;; articles or some excluded dormants, we include these in the
3571 (when (and (zerop (buffer-size))
3573 (cond (gnus-newsgroup-dormant
3574 (gnus-summary-limit-include-dormant))
3575 ((and gnus-newsgroup-scored show-all)
3576 (gnus-summary-limit-include-expunged t))))
3577 ;; Function `gnus-apply-kill-file' must be called in this hook.
3578 (gnus-run-hooks 'gnus-apply-kill-hook)
3579 (if (and (zerop (buffer-size))
3582 ;; This newsgroup is empty.
3583 (gnus-summary-catchup-and-exit nil t)
3584 (gnus-message 6 "No unread news")
3586 (gnus-kill-or-deaden-summary kill-buffer))
3587 ;; Return nil from this function.
3589 ;; Hide conversation thread subtrees. We cannot do this in
3590 ;; gnus-summary-prepare-hook since kill processing may not
3591 ;; work with hidden articles.
3592 (gnus-summary-maybe-hide-threads)
3594 (gnus-kill-or-deaden-summary kill-buffer))
3595 (gnus-summary-auto-select-subject)
3596 ;; Show first unread article if requested.
3597 (if (and (not no-article)
3599 gnus-newsgroup-unreads
3600 gnus-auto-select-first)
3602 (gnus-configure-windows 'summary)
3603 (let ((art (gnus-summary-article-number)))
3604 (unless (and (not gnus-plugged)
3605 (or (memq art gnus-newsgroup-undownloaded)
3606 (memq art gnus-newsgroup-downloadable)))
3607 (gnus-summary-goto-article art))))
3608 ;; Don't select any articles.
3609 (gnus-summary-position-point)
3610 (gnus-configure-windows 'summary 'force)
3611 (gnus-set-mode-line 'summary))
3612 (when (and gnus-auto-center-group
3613 (get-buffer-window gnus-group-buffer t))
3614 ;; Gotta use windows, because recenter does weird stuff if
3615 ;; the current buffer ain't the displayed window.
3616 (let ((owin (selected-window)))
3617 (select-window (get-buffer-window gnus-group-buffer t))
3618 (when (gnus-group-goto-group group)
3620 (select-window owin)))
3621 ;; Mark this buffer as "prepared".
3622 (setq gnus-newsgroup-prepared t)
3623 (gnus-run-hooks 'gnus-summary-prepared-hook)
3624 (unless (gnus-ephemeral-group-p group)
3625 (gnus-group-update-group group))
3628 (defun gnus-summary-auto-select-subject ()
3629 "Select the subject line on initial group entry."
3630 (goto-char (point-min))
3632 ((eq gnus-auto-select-subject 'best)
3633 (gnus-summary-best-unread-subject))
3634 ((eq gnus-auto-select-subject 'unread)
3635 (gnus-summary-first-unread-subject))
3636 ((eq gnus-auto-select-subject 'unseen)
3637 (gnus-summary-first-unseen-subject))
3638 ((eq gnus-auto-select-subject 'unseen-or-unread)
3639 (gnus-summary-first-unseen-or-unread-subject))
3640 ((eq gnus-auto-select-subject 'first)
3643 ((functionp gnus-auto-select-subject)
3644 (funcall gnus-auto-select-subject))))
3646 (defun gnus-summary-prepare ()
3647 "Generate the summary buffer."
3649 (let ((buffer-read-only nil))
3651 (setq gnus-newsgroup-data nil
3652 gnus-newsgroup-data-reverse nil)
3653 (gnus-run-hooks 'gnus-summary-generate-hook)
3654 ;; Generate the buffer, either with threads or without.
3655 (when gnus-newsgroup-headers
3656 (gnus-summary-prepare-threads
3657 (if gnus-show-threads
3658 (gnus-sort-gathered-threads
3659 (funcall gnus-summary-thread-gathering-function
3661 (gnus-cut-threads (gnus-make-threads)))))
3662 ;; Unthreaded display.
3663 (gnus-sort-articles gnus-newsgroup-headers))))
3664 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3665 ;; Call hooks for modifying summary buffer.
3666 (goto-char (point-min))
3667 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3669 (defsubst gnus-general-simplify-subject (subject)
3670 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3673 ;; Truncate the subject.
3674 (gnus-simplify-subject-functions
3675 (gnus-map-function gnus-simplify-subject-functions subject))
3676 ((numberp gnus-summary-gather-subject-limit)
3677 (setq subject (gnus-simplify-subject-re subject))
3678 (if (> (length subject) gnus-summary-gather-subject-limit)
3679 (substring subject 0 gnus-summary-gather-subject-limit)
3681 ;; Fuzzily simplify it.
3682 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3683 (gnus-simplify-subject-fuzzy subject))
3684 ;; Just remove the leading "Re:".
3686 (gnus-simplify-subject-re subject))))
3688 (if (and gnus-summary-gather-exclude-subject
3689 (string-match gnus-summary-gather-exclude-subject subject))
3690 nil ; This article shouldn't be gathered
3693 (defun gnus-summary-simplify-subject-query ()
3694 "Query where the respool algorithm would put this article."
3696 (gnus-summary-select-article)
3698 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3700 (defun gnus-gather-threads-by-subject (threads)
3701 "Gather threads by looking at Subject headers."
3702 (if (not gnus-summary-make-false-root)
3704 (let ((hashtb (gnus-make-hashtable 1024))
3707 subject hthread whole-subject)
3709 (setq subject (gnus-general-simplify-subject
3710 (setq whole-subject (mail-header-subject
3713 (if (setq hthread (gnus-gethash subject hashtb))
3715 ;; We enter a dummy root into the thread, if we
3716 ;; haven't done that already.
3717 (unless (stringp (caar hthread))
3718 (setcar hthread (list whole-subject (car hthread))))
3719 ;; We add this new gathered thread to this gathered
3721 (setcdr (car hthread)
3722 (nconc (cdar hthread) (list (car threads))))
3723 ;; Remove it from the list of threads.
3724 (setcdr prev (cdr threads))
3725 (setq threads prev))
3726 ;; Enter this thread into the hash table.
3727 (gnus-sethash subject
3728 (if gnus-summary-make-false-root-always
3730 ;; If you want a dummy root above all
3732 (setcar threads (list whole-subject
3738 (setq threads (cdr threads)))
3741 (defun gnus-gather-threads-by-references (threads)
3742 "Gather threads by looking at References headers."
3743 (let ((idhashtb (gnus-make-hashtable 1024))
3744 (thhashtb (gnus-make-hashtable 1024))
3747 ids references id gthread gid entered ref)
3749 (when (setq references (mail-header-references (caar threads)))
3750 (setq id (mail-header-id (caar threads))
3751 ids (inline (gnus-split-references references))
3753 (while (setq ref (pop ids))
3754 (setq ids (delete ref ids))
3755 (if (not (setq gid (gnus-gethash ref idhashtb)))
3757 (gnus-sethash ref id idhashtb)
3758 (gnus-sethash id threads thhashtb))
3759 (setq gthread (gnus-gethash gid thhashtb))
3761 ;; We enter a dummy root into the thread, if we
3762 ;; haven't done that already.
3763 (unless (stringp (caar gthread))
3764 (setcar gthread (list (mail-header-subject (caar gthread))
3766 ;; We add this new gathered thread to this gathered
3768 (setcdr (car gthread)
3769 (nconc (cdar gthread) (list (car threads)))))
3770 ;; Add it into the thread hash table.
3771 (gnus-sethash id gthread thhashtb)
3773 ;; Remove it from the list of threads.
3774 (setcdr prev (cdr threads))
3775 (setq threads prev))))
3777 (setq threads (cdr threads)))
3780 (defun gnus-sort-gathered-threads (threads)
3781 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3782 (let ((result threads))
3784 (when (stringp (caar threads))
3785 (setcdr (car threads)
3786 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3787 (setq threads (cdr threads)))
3790 (defun gnus-thread-loop-p (root thread)
3791 "Say whether ROOT is in THREAD."
3792 (let ((stack (list thread))
3795 (while (setq thread (pop stack))
3796 (setq th (cdr thread))
3798 (not (eq (caar th) root)))
3801 ;; We have found a loop.
3803 (setcdr thread (delq (car th) (cdr thread)))
3804 (if (boundp (setq ref-dep (intern "none"
3805 gnus-newsgroup-dependencies)))
3806 (setcdr (symbol-value ref-dep)
3807 (nconc (cdr (symbol-value ref-dep))
3809 (set ref-dep (list nil (car th))))
3812 ;; Push all the subthreads onto the stack.
3813 (push (cdr thread) stack)))
3816 (defun gnus-make-threads ()
3817 "Go through the dependency hashtb and find the roots. Return all threads."
3819 (while (catch 'infloop
3822 ;; Deal with self-referencing References loops.
3823 (when (and (car (symbol-value refs))
3830 (car (symbol-value refs)) thread))
3831 (cdr (symbol-value refs)))))))
3834 (unless (car (symbol-value refs))
3835 ;; These threads do not refer back to any other articles,
3836 ;; so they're roots.
3837 (setq threads (append (cdr (symbol-value refs)) threads))))
3838 gnus-newsgroup-dependencies)))
3841 ;; Build the thread tree.
3842 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3843 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3845 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3846 if it was already present.
3848 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3849 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3850 Message-IDs will be renamed to a unique Message-ID before being
3853 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3854 (let* ((id (mail-header-id header))
3855 (id-dep (and id (intern id dependencies)))
3856 parent-id ref ref-dep ref-header replaced)
3857 ;; Enter this `header' in the `dependencies' table.
3861 ;; The first two cases do the normal part: enter a new `header'
3862 ;; in the `dependencies' table.
3863 ((not (boundp id-dep))
3864 (set id-dep (list header)))
3865 ((null (car (symbol-value id-dep)))
3866 (setcar (symbol-value id-dep) header))
3868 ;; From here the `header' was already present in the
3869 ;; `dependencies' table.
3871 ;; Overrides an existing entry;
3872 ;; just set the header part of the entry.
3873 (setcar (symbol-value id-dep) header)
3876 ;; Renames the existing `header' to a unique Message-ID.
3877 ((not gnus-summary-ignore-duplicates)
3878 ;; An article with this Message-ID has already been seen.
3879 ;; We rename the Message-ID.
3880 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3882 (mail-header-set-id header id))
3884 ;; The last case ignores an existing entry, except it adds any
3885 ;; additional Xrefs (in case the two articles came from different
3887 ;; Also sets `header' to `nil' meaning that the `dependencies'
3888 ;; table was *not* modified.
3890 (mail-header-set-xref
3891 (car (symbol-value id-dep))
3892 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3894 (or (mail-header-xref header) "")))
3897 (when (and header (not replaced))
3898 ;; First check that we are not creating a References loop.
3899 (setq parent-id (gnus-parent-id (mail-header-references header)))
3900 (setq ref parent-id)
3902 (setq ref-dep (intern-soft ref dependencies))
3904 (setq ref-header (car (symbol-value ref-dep))))
3905 (if (string= id ref)
3906 ;; Yuk! This is a reference loop. Make the article be a
3909 (mail-header-set-references (car (symbol-value id-dep)) "none")
3911 (setq parent-id nil))
3912 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3913 (setq ref-dep (intern (or parent-id "none") dependencies))
3914 (if (boundp ref-dep)
3915 (setcdr (symbol-value ref-dep)
3916 (nconc (cdr (symbol-value ref-dep))
3917 (list (symbol-value id-dep))))
3918 (set ref-dep (list nil (symbol-value id-dep)))))
3921 (defun gnus-extract-message-id-from-in-reply-to (string)
3922 (if (string-match "<[^>]+>" string)
3923 (substring string (match-beginning 0) (match-end 0))
3926 (defun gnus-build-sparse-threads ()
3927 (let ((headers gnus-newsgroup-headers)
3928 (mail-parse-charset gnus-newsgroup-charset)
3929 (gnus-summary-ignore-duplicates t)
3930 header references generation relations
3931 subject child end new-child date)
3932 ;; First we create an alist of generations/relations, where
3933 ;; generations is how much we trust the relation, and the relation
3935 (gnus-message 7 "Making sparse threads...")
3937 (nnheader-set-temp-buffer " *gnus sparse threads*")
3938 (while (setq header (pop headers))
3939 (when (and (setq references (mail-header-references header))
3940 (not (string= references "")))
3942 (setq child (mail-header-id header)
3943 subject (mail-header-subject header)
3944 date (mail-header-date header)
3946 (while (search-backward ">" nil t)
3947 (setq end (1+ (point)))
3948 (when (search-backward "<" nil t)
3949 (setq new-child (buffer-substring (point) end))
3950 (push (list (incf generation)
3951 child (setq child new-child)
3955 (push (list (1+ generation) child nil subject) relations))
3957 (kill-buffer (current-buffer)))
3958 ;; Sort over trustworthiness.
3961 (when (gnus-dependencies-add-header
3962 (make-full-mail-header-from-decoded-header
3963 gnus-reffed-article-number
3964 (nth 3 relation) "" (or (nth 4 relation) "")
3966 (or (nth 2 relation) "") 0 0 "")
3967 gnus-newsgroup-dependencies nil)
3968 (push gnus-reffed-article-number gnus-newsgroup-limit)
3969 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3970 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3971 gnus-newsgroup-reads)
3972 (decf gnus-reffed-article-number)))
3973 (sort relations 'car-less-than-car))
3974 (gnus-message 7 "Making sparse threads...done")))
3976 (defun gnus-build-old-threads ()
3977 ;; Look at all the articles that refer back to old articles, and
3978 ;; fetch the headers for the articles that aren't there. This will
3979 ;; build complete threads - if the roots haven't been expired by the
3981 (let ((mail-parse-charset gnus-newsgroup-charset)
3985 (when (not (car (symbol-value refs)))
3986 (setq heads (cdr (symbol-value refs)))
3988 (if (memq (mail-header-number (caar heads))
3989 gnus-newsgroup-dormant)
3990 (setq heads (cdr heads))
3991 (setq id (symbol-name refs))
3992 (while (and (setq id (gnus-build-get-header id))
3993 (not (car (gnus-id-to-thread id)))))
3994 (setq heads nil)))))
3995 gnus-newsgroup-dependencies)))
3997 (defsubst gnus-remove-odd-characters (string)
3998 "Translate STRING into something that doesn't contain weird characters."
3999 (mm-subst-char-in-string
4001 (mm-subst-char-in-string ?\n ?\- string t) t))
4003 ;; This function has to be called with point after the article number
4004 ;; on the beginning of the line.
4005 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4006 (let ((eol (point-at-eol))
4007 (buffer (current-buffer))
4008 header references in-reply-to)
4010 ;; overview: [num subject from date id refs chars lines misc]
4013 (narrow-to-region (point) eol)
4018 (make-full-mail-header
4020 (nnheader-nov-field) ; subject
4021 (nnheader-nov-field) ; from
4022 (nnheader-nov-field) ; date
4023 (nnheader-nov-read-message-id) ; id
4024 (nnheader-nov-field) ; refs
4025 (nnheader-nov-read-integer) ; chars
4026 (nnheader-nov-read-integer) ; lines
4028 (if (looking-at "Xref: ")
4029 (goto-char (match-end 0)))
4030 (nnheader-nov-field)) ; Xref
4031 (nnheader-nov-parse-extra)))) ; extra
4035 (when (and (string= references "")
4036 (setq in-reply-to (mail-header-extra header))
4037 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4038 (mail-header-set-references
4039 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4041 (when gnus-alter-header-function
4042 (funcall gnus-alter-header-function header))
4043 (gnus-dependencies-add-header header dependencies force-new)))
4045 (defun gnus-build-get-header (id)
4046 "Look through the buffer of NOV lines and find the header to ID.
4047 Enter this line into the dependencies hash table, and return
4048 the id of the parent article (if any)."
4049 (let ((deps gnus-newsgroup-dependencies)
4053 (set-buffer nntp-server-buffer)
4054 (let ((case-fold-search nil))
4055 (goto-char (point-min))
4056 (while (and (not found)
4057 (search-forward id nil t))
4059 (setq found (looking-at
4060 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4061 (regexp-quote id))))
4062 (or found (beginning-of-line 2)))
4066 (setq header (gnus-nov-parse-line
4067 (read (current-buffer)) deps))
4068 (gnus-parent-id (mail-header-references header))))))
4070 (let ((number (mail-header-number header)))
4071 (push number gnus-newsgroup-limit)
4072 (push header gnus-newsgroup-headers)
4073 (if (memq number gnus-newsgroup-unselected)
4075 (setq gnus-newsgroup-unreads
4076 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4078 (setq gnus-newsgroup-unselected
4079 (delq number gnus-newsgroup-unselected)))
4080 (push number gnus-newsgroup-ancient)))))))
4082 (defun gnus-build-all-threads ()
4083 "Read all the headers."
4084 (let ((gnus-summary-ignore-duplicates t)
4085 (mail-parse-charset gnus-newsgroup-charset)
4086 (dependencies gnus-newsgroup-dependencies)
4089 (set-buffer nntp-server-buffer)
4090 (let ((case-fold-search nil))
4091 (goto-char (point-min))
4094 (setq article (read (current-buffer))
4095 header (gnus-nov-parse-line article dependencies)))
4098 (set-buffer gnus-summary-buffer)
4099 (push header gnus-newsgroup-headers)
4100 (if (memq (setq article (mail-header-number header))
4101 gnus-newsgroup-unselected)
4103 (setq gnus-newsgroup-unreads
4104 (gnus-add-to-sorted-list
4105 gnus-newsgroup-unreads article))
4106 (setq gnus-newsgroup-unselected
4107 (delq article gnus-newsgroup-unselected)))
4108 (push article gnus-newsgroup-ancient)))
4109 (forward-line 1)))))))
4111 (defun gnus-summary-update-article-line (article header)
4112 "Update the line for ARTICLE using HEADER."
4113 (let* ((id (mail-header-id header))
4114 (thread (gnus-id-to-thread id)))
4116 (error "Article in no thread"))
4117 ;; Update the thread.
4118 (setcar thread header)
4119 (gnus-summary-goto-subject article)
4120 (let* ((datal (gnus-data-find-list article))
4122 (buffer-read-only nil)
4123 (level (gnus-summary-thread-level)))
4125 (let ((inserted (- (point)
4127 (gnus-summary-insert-line
4129 (memq article gnus-newsgroup-undownloaded)
4130 (gnus-article-mark article)
4131 (memq article gnus-newsgroup-replied)
4132 (memq article gnus-newsgroup-expirable)
4133 ;; Only insert the Subject string when it's different
4134 ;; from the previous Subject string.
4139 (mail-header-subject
4142 (gnus-data-find-list
4144 (gnus-data-list t)))))
4145 ;; Error on the side of excessive subjects.
4147 (mail-header-subject header)))
4149 (mail-header-subject header))
4150 nil (cdr (assq article gnus-newsgroup-scored))
4151 (memq article gnus-newsgroup-processable))
4154 (gnus-data-update-list
4156 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4158 (defun gnus-summary-update-article (article &optional iheader)
4159 "Update ARTICLE in the summary buffer."
4160 (set-buffer gnus-summary-buffer)
4161 (let* ((header (gnus-summary-article-header article))
4162 (id (mail-header-id header))
4163 (data (gnus-data-find article))
4164 (thread (gnus-id-to-thread id))
4165 (references (mail-header-references header))
4169 (when (and references
4170 (not (equal "" references)))
4173 (buffer-read-only nil)
4179 (delq thread parent)))
4180 (if (gnus-summary-insert-subject id header)
4181 ;; Set the (possibly) new article number in the data structure.
4182 (gnus-data-set-number data (gnus-id-to-article id))
4186 (defun gnus-rebuild-thread (id &optional line)
4187 "Rebuild the thread containing ID.
4188 If LINE, insert the rebuilt thread starting on line LINE."
4189 (let ((buffer-read-only nil)
4190 old-pos current thread data)
4191 (if (not gnus-show-threads)
4192 (setq thread (list (car (gnus-id-to-thread id))))
4193 ;; Get the thread this article is part of.
4194 (setq thread (gnus-remove-thread id)))
4195 (setq old-pos (point-at-bol))
4196 (setq current (save-excursion
4197 (and (re-search-backward "[\r\n]" nil t)
4198 (gnus-summary-article-number))))
4199 ;; If this is a gathered thread, we have to go some re-gathering.
4200 (when (stringp (car thread))
4201 (let ((subject (car thread))
4203 (setq thread (cdr thread))
4205 (unless (memq (setq thr (gnus-id-to-thread
4207 (mail-header-id (caar thread)))))
4210 (setq thread (cdr thread)))
4211 ;; We now have all (unique) roots.
4212 (if (= (length roots) 1)
4213 ;; All the loose roots are now one solid root.
4214 (setq thread (car roots))
4215 (setq thread (cons subject (gnus-sort-threads roots))))))
4217 ;; We then insert this thread into the summary buffer.
4219 (goto-char (point-min))
4220 (forward-line (1- line)))
4221 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4222 (if gnus-show-threads
4223 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4224 (gnus-summary-prepare-unthreaded thread))
4225 (setq data (nreverse gnus-newsgroup-data))
4226 (setq threads gnus-newsgroup-threads))
4227 ;; We splice the new data into the data structure.
4228 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4229 ;;!!! then we want to insert at the beginning of the buffer.
4230 ;;!!! That happens to be true with Gnus now, but that may
4231 ;;!!! change in the future. Perhaps.
4232 (gnus-data-enter-list
4233 (if line nil current) data (- (point) old-pos))
4234 (setq gnus-newsgroup-threads
4235 (nconc threads gnus-newsgroup-threads))
4236 (gnus-data-compute-positions))))
4238 (defun gnus-number-to-header (number)
4239 "Return the header for article NUMBER."
4240 (let ((headers gnus-newsgroup-headers))
4242 (not (= number (mail-header-number (car headers)))))
4247 (defun gnus-parent-headers (in-headers &optional generation)
4248 "Return the headers of the GENERATIONeth parent of HEADERS."
4250 (setq generation 1))
4252 (headers in-headers)
4255 (not (zerop generation))
4256 (setq references (mail-header-references headers)))
4257 (setq headers (if (and references
4258 (setq parent (gnus-parent-id references)))
4259 (car (gnus-id-to-thread parent))
4262 (and (not (eq headers in-headers))
4265 (defun gnus-id-to-thread (id)
4266 "Return the (sub-)thread where ID appears."
4267 (gnus-gethash id gnus-newsgroup-dependencies))
4269 (defun gnus-id-to-article (id)
4270 "Return the article number of ID."
4271 (let ((thread (gnus-id-to-thread id)))
4274 (mail-header-number (car thread)))))
4276 (defun gnus-id-to-header (id)
4277 "Return the article headers of ID."
4278 (car (gnus-id-to-thread id)))
4280 (defun gnus-article-displayed-root-p (article)
4281 "Say whether ARTICLE is a root(ish) article."
4282 (let ((level (gnus-summary-thread-level article))
4283 (refs (mail-header-references (gnus-summary-article-header article)))
4289 ((null (gnus-parent-id refs)) t)
4291 (null (setq particle (gnus-id-to-article
4292 (gnus-parent-id refs))))
4293 (null (gnus-summary-thread-level particle)))))))
4295 (defun gnus-root-id (id)
4296 "Return the id of the root of the thread where ID appears."
4298 (while (and id (setq prev (car (gnus-id-to-thread id))))
4300 id (gnus-parent-id (mail-header-references prev))))
4303 (defun gnus-articles-in-thread (thread)
4304 "Return the list of articles in THREAD."
4305 (cons (mail-header-number (car thread))
4306 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4308 (defun gnus-remove-thread (id &optional dont-remove)
4309 "Remove the thread that has ID in it."
4310 (let (headers thread last-id)
4311 ;; First go up in this thread until we find the root.
4312 (setq last-id (gnus-root-id id)
4313 headers (message-flatten-list (gnus-id-to-thread last-id)))
4314 ;; We have now found the real root of this thread. It might have
4315 ;; been gathered into some loose thread, so we have to search
4316 ;; through the threads to find the thread we wanted.
4317 (let ((threads gnus-newsgroup-threads)
4320 (setq sub (car threads))
4321 (if (stringp (car sub))
4322 ;; This is a gathered thread, so we look at the roots
4323 ;; below it to find whether this article is in this
4326 (setq sub (cdr sub))
4328 (when (member (caar sub) headers)
4329 (setq thread (car threads)
4332 (setq sub (cdr sub))))
4333 ;; It's an ordinary thread, so we check it.
4334 (when (eq (car sub) (car headers))
4337 (setq threads (cdr threads)))
4338 ;; If this article is in no thread, then it's a root.
4341 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4342 (setq thread (gnus-id-to-thread last-id)))
4345 thread ; We return this thread.
4347 (if (stringp (car thread))
4349 ;; If we use dummy roots, then we have to remove the
4350 ;; dummy root as well.
4351 (when (eq gnus-summary-make-false-root 'dummy)
4352 ;; We go to the dummy root by going to
4353 ;; the first sub-"thread", and then one line up.
4354 (gnus-summary-goto-article
4355 (mail-header-number (caadr thread)))
4358 (gnus-data-compute-positions))
4359 (setq thread (cdr thread))
4361 (gnus-remove-thread-1 (car thread))
4362 (setq thread (cdr thread))))
4363 (gnus-remove-thread-1 thread))))))))
4365 (defun gnus-remove-thread-1 (thread)
4366 "Remove the thread THREAD recursively."
4367 (let ((number (mail-header-number (pop thread)))
4369 (setq thread (reverse thread))
4371 (gnus-remove-thread-1 (pop thread)))
4372 (when (setq d (gnus-data-find number))
4373 (goto-char (gnus-data-pos d))
4374 (gnus-summary-show-thread)
4380 (gnus-delete-line)))))))
4382 (defun gnus-sort-threads-1 (threads func)
4383 (sort (mapcar (lambda (thread)
4386 (gnus-sort-threads-1 (cdr thread) func))))
4389 (defun gnus-sort-threads (threads)
4391 (if (not gnus-thread-sort-functions)
4393 (gnus-message 8 "Sorting threads...")
4394 (let ((max-lisp-eval-depth 5000))
4395 (prog1 (gnus-sort-threads-1
4397 (gnus-make-sort-function gnus-thread-sort-functions))
4398 (gnus-message 8 "Sorting threads...done")))))
4400 (defun gnus-sort-articles (articles)
4402 (when gnus-article-sort-functions
4403 (gnus-message 7 "Sorting articles...")
4405 (setq gnus-newsgroup-headers
4406 (sort articles (gnus-make-sort-function
4407 gnus-article-sort-functions)))
4408 (gnus-message 7 "Sorting articles...done"))))
4410 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4411 (defmacro gnus-thread-header (thread)
4412 "Return header of first article in THREAD.
4413 Note that THREAD must never, ever be anything else than a variable -
4414 using some other form will lead to serious barfage."
4415 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4416 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4417 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4420 (defsubst gnus-article-sort-by-number (h1 h2)
4421 "Sort articles by article number."
4422 (< (mail-header-number h1)
4423 (mail-header-number h2)))
4425 (defun gnus-thread-sort-by-number (h1 h2)
4426 "Sort threads by root article number."
4427 (gnus-article-sort-by-number
4428 (gnus-thread-header h1) (gnus-thread-header h2)))
4430 (defsubst gnus-article-sort-by-random (h1 h2)
4431 "Sort articles by article number."
4434 (defun gnus-thread-sort-by-random (h1 h2)
4435 "Sort threads by root article number."
4436 (gnus-article-sort-by-random
4437 (gnus-thread-header h1) (gnus-thread-header h2)))
4439 (defsubst gnus-article-sort-by-lines (h1 h2)
4440 "Sort articles by article Lines header."
4441 (< (mail-header-lines h1)
4442 (mail-header-lines h2)))
4444 (defun gnus-thread-sort-by-lines (h1 h2)
4445 "Sort threads by root article Lines header."
4446 (gnus-article-sort-by-lines
4447 (gnus-thread-header h1) (gnus-thread-header h2)))
4449 (defsubst gnus-article-sort-by-chars (h1 h2)
4450 "Sort articles by octet length."
4451 (< (mail-header-chars h1)
4452 (mail-header-chars h2)))
4454 (defun gnus-thread-sort-by-chars (h1 h2)
4455 "Sort threads by root article octet length."
4456 (gnus-article-sort-by-chars
4457 (gnus-thread-header h1) (gnus-thread-header h2)))
4459 (defsubst gnus-article-sort-by-author (h1 h2)
4460 "Sort articles by root author."
4462 (let ((addr (car (mime-entity-read-field h1 'From))))
4463 (or (std11-full-name-string addr)
4464 (std11-address-string addr)
4466 (let ((addr (car (mime-entity-read-field h2 'From))))
4467 (or (std11-full-name-string addr)
4468 (std11-address-string addr)
4472 (defun gnus-thread-sort-by-author (h1 h2)
4473 "Sort threads by root author."
4474 (gnus-article-sort-by-author
4475 (gnus-thread-header h1) (gnus-thread-header h2)))
4477 (defsubst gnus-article-sort-by-subject (h1 h2)
4478 "Sort articles by root subject."
4480 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4481 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4483 (defun gnus-thread-sort-by-subject (h1 h2)
4484 "Sort threads by root subject."
4485 (gnus-article-sort-by-subject
4486 (gnus-thread-header h1) (gnus-thread-header h2)))
4488 (defsubst gnus-article-sort-by-date (h1 h2)
4489 "Sort articles by root article date."
4491 (gnus-date-get-time (mail-header-date h1))
4492 (gnus-date-get-time (mail-header-date h2))))
4494 (defun gnus-thread-sort-by-date (h1 h2)
4495 "Sort threads by root article date."
4496 (gnus-article-sort-by-date
4497 (gnus-thread-header h1) (gnus-thread-header h2)))
4499 (defsubst gnus-article-sort-by-score (h1 h2)
4500 "Sort articles by root article score.
4501 Unscored articles will be counted as having a score of zero."
4502 (> (or (cdr (assq (mail-header-number h1)
4503 gnus-newsgroup-scored))
4504 gnus-summary-default-score 0)
4505 (or (cdr (assq (mail-header-number h2)
4506 gnus-newsgroup-scored))
4507 gnus-summary-default-score 0)))
4509 (defun gnus-thread-sort-by-score (h1 h2)
4510 "Sort threads by root article score."
4511 (gnus-article-sort-by-score
4512 (gnus-thread-header h1) (gnus-thread-header h2)))
4514 (defun gnus-thread-sort-by-total-score (h1 h2)
4515 "Sort threads by the sum of all scores in the thread.
4516 Unscored articles will be counted as having a score of zero."
4517 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4519 (defun gnus-thread-total-score (thread)
4520 ;; This function find the total score of THREAD.
4525 (if (stringp (car thread))
4526 (apply gnus-thread-score-function 0
4527 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4528 (gnus-thread-total-score-1 thread)))
4530 (gnus-thread-total-score-1 (list thread)))))
4532 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4533 "Sort threads such that the thread with the most recently arrived article comes first."
4534 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4536 (defun gnus-thread-highest-number (thread)
4537 "Return the highest article number in THREAD."
4538 (apply 'max (mapcar (lambda (header)
4539 (mail-header-number header))
4540 (message-flatten-list thread))))
4542 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4543 "Sort threads such that the thread with the most recently dated article comes first."
4544 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4546 (defun gnus-thread-latest-date (thread)
4547 "Return the highest article date in THREAD."
4548 (let ((previous-time 0))
4554 (time-to-seconds (mail-header-parse-date
4555 (mail-header-date header)))
4556 (error previous-time))))
4558 (message-flatten-list thread)
4560 (< (mail-header-number h1)
4561 (mail-header-number h2))))))))
4563 (defun gnus-thread-total-score-1 (root)
4564 ;; This function find the total score of the thread below ROOT.
4565 (setq root (car root))
4566 (apply gnus-thread-score-function
4568 (mapcar 'gnus-thread-total-score
4569 (cdr (gnus-id-to-thread (mail-header-id root))))
4570 (when (> (mail-header-number root) 0)
4571 (list (or (cdr (assq (mail-header-number root)
4572 gnus-newsgroup-scored))
4573 gnus-summary-default-score 0))))
4574 (list gnus-summary-default-score)
4577 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4578 (defvar gnus-tmp-prev-subject nil)
4579 (defvar gnus-tmp-false-parent nil)
4580 (defvar gnus-tmp-root-expunged nil)
4581 (defvar gnus-tmp-dummy-line nil)
4583 (eval-when-compile (defvar gnus-tmp-header))
4584 (defun gnus-extra-header (type &optional header)
4585 "Return the extra header of TYPE."
4586 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4589 (defvar gnus-tmp-thread-tree-header-string "")
4591 (defcustom gnus-sum-thread-tree-root "> "
4592 "With %B spec, used for the root of a thread.
4593 If nil, use subject instead."
4594 :type '(radio (const :format "%v " nil) (string :size 0))
4595 :group 'gnus-thread)
4596 (defcustom gnus-sum-thread-tree-false-root "> "
4597 "With %B spec, used for a false root of a thread.
4598 If nil, use subject instead."
4599 :type '(radio (const :format "%v " nil) (string :size 0))
4600 :group 'gnus-thread)
4601 (defcustom gnus-sum-thread-tree-single-indent ""
4602 "With %B spec, used for a thread with just one message.
4603 If nil, use subject instead."
4604 :type '(radio (const :format "%v " nil) (string :size 0))
4605 :group 'gnus-thread)
4606 (defcustom gnus-sum-thread-tree-vertical "| "
4607 "With %B spec, used for drawing a vertical line."
4609 :group 'gnus-thread)
4610 (defcustom gnus-sum-thread-tree-indent " "
4611 "With %B spec, used for indenting."
4613 :group 'gnus-thread)
4614 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4615 "With %B spec, used for a leaf with brothers."
4617 :group 'gnus-thread)
4618 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4619 "With %B spec, used for a leaf without brothers."
4621 :group 'gnus-thread)
4623 (defun gnus-summary-prepare-threads (threads)
4624 "Prepare summary buffer from THREADS and indentation LEVEL.
4625 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4626 or a straight list of headers."
4627 (gnus-message 7 "Generating summary...")
4629 (setq gnus-newsgroup-threads threads)
4632 (let ((gnus-tmp-level 0)
4633 (default-score (or gnus-summary-default-score 0))
4634 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4635 (building-line-count gnus-summary-display-while-building)
4636 (building-count (integerp gnus-summary-display-while-building))
4637 thread number subject stack state gnus-tmp-gathered beg-match
4638 new-roots gnus-tmp-new-adopts thread-end simp-subject
4639 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4640 gnus-tmp-replied gnus-tmp-subject-or-nil
4641 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4642 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4643 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4646 (setq gnus-tmp-prev-subject nil
4647 gnus-tmp-thread-tree-header-string "")
4649 (if (vectorp (car threads))
4650 ;; If this is a straight (sic) list of headers, then a
4651 ;; threaded summary display isn't required, so we just create
4652 ;; an unthreaded one.
4653 (gnus-summary-prepare-unthreaded threads)
4655 ;; Do the threaded display.
4657 (if gnus-summary-display-while-building
4658 (switch-to-buffer (buffer-name)))
4659 (while (or threads stack gnus-tmp-new-adopts new-roots)
4661 (if (and (= gnus-tmp-level 0)
4664 (not gnus-tmp-false-parent)
4665 (or gnus-tmp-new-adopts new-roots))
4666 (if gnus-tmp-new-adopts
4667 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4668 thread (list (car gnus-tmp-new-adopts))
4669 gnus-tmp-header (caar thread)
4670 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4672 (setq thread (list (car new-roots))
4673 gnus-tmp-header (caar thread)
4674 new-roots (cdr new-roots))))
4677 ;; If there are some threads, we do them before the
4678 ;; threads on the stack.
4679 (setq thread threads
4680 gnus-tmp-header (caar thread))
4681 ;; There were no current threads, so we pop something off
4683 (setq state (car stack)
4684 gnus-tmp-level (car state)
4685 tree-stack (cadr state)
4686 thread (caddr state)
4688 gnus-tmp-header (caar thread))))
4690 (setq gnus-tmp-false-parent nil)
4691 (setq gnus-tmp-root-expunged nil)
4692 (setq thread-end nil)
4694 (if (stringp gnus-tmp-header)
4695 ;; The header is a dummy root.
4697 ((eq gnus-summary-make-false-root 'adopt)
4698 ;; We let the first article adopt the rest.
4699 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4701 (setq gnus-tmp-gathered
4703 (lambda (h) (mail-header-number (car h)))
4706 (setq thread (cons (list (caar thread)
4709 (setq gnus-tmp-level -1
4710 gnus-tmp-false-parent t))
4711 ((eq gnus-summary-make-false-root 'empty)
4712 ;; We print adopted articles with empty subject fields.
4713 (setq gnus-tmp-gathered
4715 (lambda (h) (mail-header-number (car h)))
4718 (setq gnus-tmp-level -1))
4719 ((eq gnus-summary-make-false-root 'dummy)
4720 ;; We remember that we probably want to output a dummy
4722 (setq gnus-tmp-dummy-line gnus-tmp-header)
4723 (setq gnus-tmp-prev-subject gnus-tmp-header))
4725 ;; We do not make a root for the gathered
4726 ;; sub-threads at all.
4727 (setq gnus-tmp-level -1)))
4729 (setq number (mail-header-number gnus-tmp-header)
4730 subject (mail-header-subject gnus-tmp-header)
4731 simp-subject (gnus-simplify-subject-fully subject))
4734 ;; If the thread has changed subject, we might want to make
4735 ;; this subthread into a root.
4736 ((and (null gnus-thread-ignore-subject)
4737 (not (zerop gnus-tmp-level))
4738 gnus-tmp-prev-subject
4739 (not (string= gnus-tmp-prev-subject simp-subject)))
4740 (setq new-roots (nconc new-roots (list (car thread)))
4742 gnus-tmp-header nil))
4743 ;; If the article lies outside the current limit,
4744 ;; then we do not display it.
4745 ((not (memq number gnus-newsgroup-limit))
4746 (setq gnus-tmp-gathered
4748 (lambda (h) (mail-header-number (car h)))
4751 (setq gnus-tmp-new-adopts (if (cdar thread)
4752 (append gnus-tmp-new-adopts
4754 gnus-tmp-new-adopts)
4756 gnus-tmp-header nil)
4757 (when (zerop gnus-tmp-level)
4758 (setq gnus-tmp-root-expunged t)))
4759 ;; Perhaps this article is to be marked as read?
4760 ((and gnus-summary-mark-below
4761 (< (or (cdr (assq number gnus-newsgroup-scored))
4763 gnus-summary-mark-below)
4764 ;; Don't touch sparse articles.
4765 (not (gnus-summary-article-sparse-p number))
4766 (not (gnus-summary-article-ancient-p number)))
4767 (setq gnus-newsgroup-unreads
4768 (delq number gnus-newsgroup-unreads))
4769 (if gnus-newsgroup-auto-expire
4770 (setq gnus-newsgroup-expirable
4771 (gnus-add-to-sorted-list
4772 gnus-newsgroup-expirable number))
4773 (push (cons number gnus-low-score-mark)
4774 gnus-newsgroup-reads))))
4776 (when gnus-tmp-header
4777 ;; We may have an old dummy line to output before this
4779 (when (and gnus-tmp-dummy-line
4782 (mail-header-subject gnus-tmp-header)))
4783 (gnus-summary-insert-dummy-line
4784 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4785 (setq gnus-tmp-dummy-line nil))
4787 ;; Compute the mark.
4788 (setq gnus-tmp-unread (gnus-article-mark number))
4790 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4791 gnus-tmp-header gnus-tmp-level)
4792 gnus-newsgroup-data)
4794 ;; Actually insert the line.
4796 gnus-tmp-subject-or-nil
4798 ((and gnus-thread-ignore-subject
4799 gnus-tmp-prev-subject
4800 (not (string= gnus-tmp-prev-subject simp-subject)))
4802 ((zerop gnus-tmp-level)
4803 (if (and (eq gnus-summary-make-false-root 'empty)
4804 (memq number gnus-tmp-gathered)
4805 gnus-tmp-prev-subject
4806 (string= gnus-tmp-prev-subject simp-subject))
4807 gnus-summary-same-subject
4809 (t gnus-summary-same-subject)))
4810 (if (and (eq gnus-summary-make-false-root 'adopt)
4811 (= gnus-tmp-level 1)
4812 (memq number gnus-tmp-gathered))
4813 (setq gnus-tmp-opening-bracket ?\<
4814 gnus-tmp-closing-bracket ?\>)
4815 (setq gnus-tmp-opening-bracket ?\[
4816 gnus-tmp-closing-bracket ?\]))
4818 gnus-tmp-indentation
4819 (aref gnus-thread-indent-array gnus-tmp-level)
4820 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4821 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4822 gnus-summary-default-score 0)
4824 (if (or (null gnus-summary-default-score)
4825 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4826 gnus-summary-zcore-fuzz))
4828 (if (< gnus-tmp-score gnus-summary-default-score)
4829 gnus-score-below-mark gnus-score-over-mark))
4831 (cond ((memq number gnus-newsgroup-processable)
4833 ((memq number gnus-newsgroup-cached)
4835 ((memq number gnus-newsgroup-replied)
4837 ((memq number gnus-newsgroup-forwarded)
4838 gnus-forwarded-mark)
4839 ((memq number gnus-newsgroup-saved)
4841 ((memq number gnus-newsgroup-recent)
4843 ((memq number gnus-newsgroup-unseen)
4847 (cond ((memq number gnus-newsgroup-undownloaded)
4848 gnus-undownloaded-mark)
4849 (gnus-newsgroup-agentized
4850 gnus-downloaded-mark)
4853 gnus-tmp-from (mail-header-from gnus-tmp-header)
4856 ((string-match "<[^>]+> *$" gnus-tmp-from)
4857 (setq beg-match (match-beginning 0))
4858 (or (and (string-match "^\".+\"" gnus-tmp-from)
4859 (substring gnus-tmp-from 1 (1- (match-end 0))))
4860 (substring gnus-tmp-from 0 beg-match)))
4861 ((string-match "(.+)" gnus-tmp-from)
4862 (substring gnus-tmp-from
4863 (1+ (match-beginning 0)) (1- (match-end 0))))
4867 gnus-tmp-thread-tree-header-string
4869 ((not gnus-show-threads) "")
4870 ((zerop gnus-tmp-level)
4871 (cond ((cdar thread)
4872 (or gnus-sum-thread-tree-root subject))
4873 (gnus-tmp-new-adopts
4874 (or gnus-sum-thread-tree-false-root subject))
4876 (or gnus-sum-thread-tree-single-indent subject))))
4878 (concat (apply 'concat
4879 (mapcar (lambda (item)
4881 gnus-sum-thread-tree-vertical
4882 gnus-sum-thread-tree-indent))
4883 (cdr (reverse tree-stack))))
4885 gnus-sum-thread-tree-leaf-with-other
4886 gnus-sum-thread-tree-single-leaf)))))
4887 (when (string= gnus-tmp-name "")
4888 (setq gnus-tmp-name gnus-tmp-from))
4889 (unless (numberp gnus-tmp-lines)
4890 (setq gnus-tmp-lines -1))
4891 (if (= gnus-tmp-lines -1)
4892 (setq gnus-tmp-lines "?")
4893 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4894 (gnus-put-text-property
4896 (progn (eval gnus-summary-line-format-spec) (point))
4897 'gnus-number number)
4900 (gnus-run-hooks 'gnus-summary-update-hook)
4903 (setq gnus-tmp-prev-subject simp-subject)))
4905 (when (nth 1 thread)
4906 (push (list (max 0 gnus-tmp-level)
4907 (copy-sequence tree-stack)
4910 (push (if (nth 1 thread) 1 0) tree-stack)
4911 (incf gnus-tmp-level)
4912 (setq threads (if thread-end nil (cdar thread)))
4913 (if gnus-summary-display-while-building
4916 ;; use a set frequency
4917 (setq building-line-count (1- building-line-count))
4918 (when (= building-line-count 0)
4920 (setq building-line-count
4921 gnus-summary-display-while-building)))
4925 (setq gnus-tmp-level 0)))))
4926 (gnus-message 7 "Generating summary...done"))
4928 (defun gnus-summary-prepare-unthreaded (headers)
4929 "Generate an unthreaded summary buffer based on HEADERS."
4930 (let (header number mark)
4935 ;; We may have to root out some bad articles...
4936 (when (memq (setq number (mail-header-number
4937 (setq header (pop headers))))
4938 gnus-newsgroup-limit)
4939 ;; Mark article as read when it has a low score.
4940 (when (and gnus-summary-mark-below
4941 (< (or (cdr (assq number gnus-newsgroup-scored))
4942 gnus-summary-default-score 0)
4943 gnus-summary-mark-below)
4944 (not (gnus-summary-article-ancient-p number)))
4945 (setq gnus-newsgroup-unreads
4946 (delq number gnus-newsgroup-unreads))
4947 (if gnus-newsgroup-auto-expire
4948 (push number gnus-newsgroup-expirable)
4949 (push (cons number gnus-low-score-mark)
4950 gnus-newsgroup-reads)))
4952 (setq mark (gnus-article-mark number))
4953 (push (gnus-data-make number mark (1+ (point)) header 0)
4954 gnus-newsgroup-data)
4955 (gnus-summary-insert-line
4957 (memq number gnus-newsgroup-undownloaded)
4958 mark (memq number gnus-newsgroup-replied)
4959 (memq number gnus-newsgroup-expirable)
4960 (mail-header-subject header) nil
4961 (cdr (assq number gnus-newsgroup-scored))
4962 (memq number gnus-newsgroup-processable))))))
4964 (defun gnus-summary-remove-list-identifiers ()
4965 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4966 (let ((regexp (if (consp gnus-list-identifiers)
4967 (mapconcat 'identity gnus-list-identifiers " *\\|")
4968 gnus-list-identifiers))
4971 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
4972 (dolist (header gnus-newsgroup-headers)
4973 (setq subject (mail-header-subject header)
4975 (while (string-match regexp subject)
4977 (concat (substring subject 0 (match-beginning 1))
4978 (substring subject (match-end 0)))
4981 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
4983 (concat (substring subject 0 (match-beginning 1))
4984 (substring subject (match-end 1)))))
4985 (mail-header-set-subject header subject))))))
4987 (defun gnus-fetch-headers (articles)
4988 "Fetch headers of ARTICLES."
4989 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4990 (gnus-message 5 "Fetching headers for %s..." name)
4993 (setq gnus-headers-retrieved-by
4994 (gnus-retrieve-headers
4995 articles gnus-newsgroup-name
4996 ;; We might want to fetch old headers, but
4997 ;; not if there is only 1 article.
4999 (not (eq gnus-fetch-old-headers 'some))
5000 (not (numberp gnus-fetch-old-headers)))
5001 (> (length articles) 1))
5002 gnus-fetch-old-headers))))
5003 (gnus-get-newsgroup-headers-xover
5004 articles nil nil gnus-newsgroup-name t)
5005 (gnus-get-newsgroup-headers))
5006 (gnus-message 5 "Fetching headers for %s...done" name))))
5008 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5009 "Select newsgroup GROUP.
5010 If READ-ALL is non-nil, all articles in the group are selected.
5011 If SELECT-ARTICLES, only select those articles from GROUP."
5012 (let* ((entry (gnus-group-entry group))
5013 ;;!!! Dirty hack; should be removed.
5014 (gnus-summary-ignore-duplicates
5015 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5017 gnus-summary-ignore-duplicates))
5018 (info (nth 2 entry))
5019 articles fetched-articles cached)
5021 (unless (gnus-check-server
5022 (set (make-local-variable 'gnus-current-select-method)
5023 (gnus-find-method-for-group group)))
5024 (error "Couldn't open server"))
5026 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5027 (gnus-activate-group group) ; Or we can activate it...
5028 (progn ; Or we bug out.
5029 (when (equal major-mode 'gnus-summary-mode)
5030 (gnus-kill-buffer (current-buffer)))
5031 (error "Couldn't activate group %s: %s"
5032 group (gnus-status-message group))))
5034 (unless (gnus-request-group group t)
5035 (when (equal major-mode 'gnus-summary-mode)
5036 (gnus-kill-buffer (current-buffer)))
5037 (error "Couldn't request group %s: %s"
5038 group (gnus-status-message group)))
5041 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5043 (setq gnus-summary-use-undownloaded-faces
5044 (gnus-agent-find-parameter
5046 'agent-enable-undownloaded-faces)))
5048 (setq gnus-newsgroup-name group
5049 gnus-newsgroup-unselected nil
5050 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5052 (let ((display (gnus-group-find-parameter group 'display)))
5053 (setq gnus-newsgroup-display
5055 ((not (zerop (or (car-safe read-all) 0)))
5056 ;; The user entered the group with C-u SPC/RET, let's show
5062 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5064 ;; The following is probably the "correct" solution, but
5065 ;; it makes Gnus fetch all headers and then limit the
5066 ;; articles (which is slow), so instead we hack the
5067 ;; select-articles parameter instead. -- Simon Josefsson
5070 ;; (gnus-byte-compile
5071 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5073 (setq select-articles
5074 (gnus-uncompress-range
5075 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5079 (cdr (gnus-active group)))))
5084 (gnus-summary-setup-default-charset)
5086 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5087 (when (gnus-virtual-group-p group)
5088 (setq cached gnus-newsgroup-cached))
5090 (setq gnus-newsgroup-unreads
5091 (gnus-sorted-ndifference
5092 (gnus-sorted-ndifference gnus-newsgroup-unreads
5093 gnus-newsgroup-marked)
5094 gnus-newsgroup-dormant))
5096 (setq gnus-newsgroup-processable nil)
5098 (gnus-update-read-articles group gnus-newsgroup-unreads)
5100 ;; Adjust and set lists of article marks.
5102 (gnus-adjust-marked-articles info))
5103 (if (setq articles select-articles)
5104 (setq gnus-newsgroup-unselected
5105 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5106 (setq articles (gnus-articles-to-read group read-all)))
5110 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5112 ((eq articles 0) nil)
5114 ;; Init the dependencies hash table.
5115 (setq gnus-newsgroup-dependencies
5116 (gnus-make-hashtable (length articles)))
5117 (gnus-set-global-variables)
5118 ;; Retrieve the headers and read them in.
5120 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5122 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5124 (setq gnus-newsgroup-cached cached))
5126 ;; Suppress duplicates?
5127 (when gnus-suppress-duplicates
5128 (gnus-dup-suppress-articles))
5130 ;; Set the initial limit.
5131 (setq gnus-newsgroup-limit (copy-sequence articles))
5132 ;; Remove canceled articles from the list of unread articles.
5133 (setq fetched-articles
5134 (mapcar (lambda (headers) (mail-header-number headers))
5135 gnus-newsgroup-headers))
5136 (setq gnus-newsgroup-articles fetched-articles)
5137 (setq gnus-newsgroup-unreads
5138 (gnus-sorted-nintersection
5139 gnus-newsgroup-unreads fetched-articles))
5140 (gnus-compute-unseen-list)
5142 ;; Removed marked articles that do not exist.
5143 (gnus-update-missing-marks
5144 (gnus-sorted-difference articles fetched-articles))
5145 ;; We might want to build some more threads first.
5146 (when (and gnus-fetch-old-headers
5147 (eq gnus-headers-retrieved-by 'nov))
5148 (if (eq gnus-fetch-old-headers 'invisible)
5149 (gnus-build-all-threads)
5150 (gnus-build-old-threads)))
5151 ;; Let the Gnus agent mark articles as read.
5153 (gnus-agent-get-undownloaded-list))
5154 ;; Remove list identifiers from subject
5155 (when gnus-list-identifiers
5156 (gnus-summary-remove-list-identifiers))
5157 ;; Check whether auto-expire is to be done in this group.
5158 (setq gnus-newsgroup-auto-expire
5159 (gnus-group-auto-expirable-p group))
5160 ;; Set up the article buffer now, if necessary.
5161 (unless gnus-single-article-buffer
5162 (gnus-article-setup-buffer))
5163 ;; First and last article in this newsgroup.
5164 (when gnus-newsgroup-headers
5165 (setq gnus-newsgroup-begin
5166 (mail-header-number (car gnus-newsgroup-headers))
5169 (gnus-last-element gnus-newsgroup-headers))))
5170 ;; GROUP is successfully selected.
5171 (or gnus-newsgroup-headers t)))))
5173 (defun gnus-compute-unseen-list ()
5174 ;; The `seen' marks are treated specially.
5175 (if (not gnus-newsgroup-seen)
5176 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5177 (setq gnus-newsgroup-unseen
5178 (gnus-inverse-list-range-intersection
5179 gnus-newsgroup-articles gnus-newsgroup-seen))))
5181 (defun gnus-summary-display-make-predicate (display)
5182 (require 'gnus-agent)
5183 (when (= (length display) 1)
5184 (setq display (car display)))
5185 (unless gnus-summary-display-cache
5186 (dolist (elem (append '((unread . unread)
5189 gnus-article-mark-lists))
5190 (push (cons (cdr elem)
5192 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5193 gnus-summary-display-cache)))
5194 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5195 (gnus-category-predicate-cache gnus-summary-display-cache))
5196 (gnus-get-predicate display)))
5198 ;; Uses the dynamically bound `number' variable.
5201 (defun gnus-article-marked-p (type &optional article)
5202 (let ((article (or article number)))
5205 (memq article gnus-newsgroup-marked))
5207 (memq article gnus-newsgroup-spam-marked))
5209 (memq article gnus-newsgroup-unsendable))
5210 ((eq type 'undownload)
5211 (memq article gnus-newsgroup-undownloaded))
5212 ((eq type 'download)
5213 (memq article gnus-newsgroup-downloadable))
5215 (memq article gnus-newsgroup-unreads))
5217 (memq article gnus-newsgroup-reads))
5219 (memq article gnus-newsgroup-dormant) )
5221 (memq article gnus-newsgroup-expirable))
5223 (memq article gnus-newsgroup-replied))
5225 (memq article gnus-newsgroup-killed))
5226 ((eq type 'bookmark)
5227 (assq article gnus-newsgroup-bookmarks))
5229 (assq article gnus-newsgroup-scored))
5231 (memq article gnus-newsgroup-saved))
5233 (memq article gnus-newsgroup-cached))
5235 (memq article gnus-newsgroup-forwarded))
5237 (not (memq article gnus-newsgroup-unseen)))
5239 (memq article gnus-newsgroup-recent))
5242 (defun gnus-articles-to-read (group &optional read-all)
5243 "Find out what articles the user wants to read."
5244 (let* ((display (gnus-group-find-parameter group 'display))
5246 ;; Select all articles if `read-all' is non-nil, or if there
5247 ;; are no unread articles.
5249 (and (zerop (length gnus-newsgroup-marked))
5250 (zerop (length gnus-newsgroup-unreads)))
5251 ;; Fetch all if the predicate is non-nil.
5252 gnus-newsgroup-display)
5253 ;; We want to select the headers for all the articles in
5254 ;; the group, so we select either all the active
5255 ;; articles in the group, or (if that's nil), the
5256 ;; articles in the cache.
5258 (gnus-uncompress-range (gnus-active group))
5259 (gnus-cache-articles-in-group group))
5260 ;; Select only the "normal" subset of articles.
5262 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5263 gnus-newsgroup-unreads)))
5264 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5265 (scored (length scored-list))
5266 (number (length articles))
5267 (marked (+ (length gnus-newsgroup-marked)
5268 (length gnus-newsgroup-dormant)))
5273 ((numberp gnus-newsgroup-display)
5274 gnus-newsgroup-display)
5278 ((and (or (<= scored marked) (= scored number))
5279 (numberp gnus-large-newsgroup)
5280 (> number gnus-large-newsgroup))
5281 (let* ((cursor-in-echo-area nil)
5282 (initial (gnus-parameter-large-newsgroup-initial
5283 gnus-newsgroup-name))
5287 "How many articles from %s (%s %d): "
5289 (gnus-group-decoded-name gnus-newsgroup-name)
5291 (if initial "max" "default")
5294 (cons (number-to-string initial)
5296 (if (string-match "^[ \t]*$" input) number input)))
5297 ((and (> scored marked) (< scored number)
5298 (> (- scored number) 20))
5301 (format "%s %s (%d scored, %d total): "
5302 "How many articles from"
5303 (gnus-group-decoded-name group)
5305 (if (string-match "^[ \t]*$" input)
5309 (message "Quit getting the articles to read")
5311 (setq select (if (stringp select) (string-to-number select) select))
5312 (if (or (null select) (zerop select))
5314 (if (and (not (zerop scored)) (<= (abs select) scored))
5316 (setq articles (sort scored-list '<))
5317 (setq number (length articles)))
5318 (setq articles (copy-sequence articles)))
5320 (when (< (abs select) number)
5322 ;; Select the N oldest articles.
5323 (setcdr (nthcdr (1- (abs select)) articles) nil)
5324 ;; Select the N most recent articles.
5325 (setq articles (nthcdr (- number select) articles))))
5326 (setq gnus-newsgroup-unselected
5327 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5328 (when gnus-alter-articles-to-read-function
5331 (funcall gnus-alter-articles-to-read-function
5332 gnus-newsgroup-name articles)
5336 (defun gnus-killed-articles (killed articles)
5339 (when (inline (gnus-member-of-range (car articles) killed))
5340 (push (car articles) out))
5341 (setq articles (cdr articles)))
5344 (defun gnus-uncompress-marks (marks)
5345 "Uncompress the mark ranges in MARKS."
5346 (let ((uncompressed '(score bookmark))
5349 (if (memq (caar marks) uncompressed)
5350 (push (car marks) out)
5351 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5352 (setq marks (cdr marks)))
5355 (defun gnus-article-mark-to-type (mark)
5356 "Return the type of MARK."
5357 (or (cadr (assq mark gnus-article-special-mark-lists))
5360 (defun gnus-article-unpropagatable-p (mark)
5361 "Return whether MARK should be propagated to back end."
5362 (memq mark gnus-article-unpropagated-mark-lists))
5364 (defun gnus-adjust-marked-articles (info)
5365 "Set all article lists and remove all marks that are no longer valid."
5366 (let* ((marked-lists (gnus-info-marks info))
5367 (active (gnus-active (gnus-info-group info)))
5370 (types gnus-article-mark-lists)
5371 marks var articles article mark mark-type
5374 (dolist (marks marked-lists)
5375 (setq mark (car marks)
5376 mark-type (gnus-article-mark-to-type mark)
5377 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5379 ;; We set the variable according to the type of the marks list,
5380 ;; and then adjust the marks to a subset of the active articles.
5382 ;; Adjust "simple" lists - compressed yet unsorted
5383 ((eq mark-type 'list)
5384 ;; Simultaneously uncompress and clip to active range
5385 ;; See gnus-uncompress-range for a description of possible marks
5387 (if (not (cadr marks))
5389 (setq articles (if (numberp (cddr marks))
5395 (while (setq article (pop articles))
5396 (cond ((consp article)
5397 (setq bgn (max (car article) min)
5398 end (min (cdr article) max))
5400 (setq l (setcdr l (cons bgn nil))
5402 ((and (<= min article)
5404 (setq l (setcdr l (cons article nil))))))
5405 (set var (cdr lh)))))
5407 ((eq mark-type 'tuple)
5408 (set var (setq articles (cdr marks)))
5409 (when (not (listp (cdr (symbol-value var))))
5410 (set var (list (symbol-value var))))
5411 (when (not (listp (cdr articles)))
5412 (setq articles (list articles)))
5414 (when (or (not (consp (setq article (pop articles))))
5415 (< (car article) min)
5416 (> (car article) max))
5417 (set var (delq article (symbol-value var))))))
5418 ;; Adjust ranges (sloppily).
5419 ((eq mark-type 'range)
5422 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5423 ;; It should be (seen (NUM1 . NUM2)).
5424 (when (numberp (cddr marks))
5425 (setcdr marks (list (cdr marks))))
5426 (setq articles (cdr marks))
5427 (while (and articles
5428 (or (and (consp (car articles))
5429 (> min (cdar articles)))
5430 (and (numberp (car articles))
5431 (> min (car articles)))))
5433 (set var articles))))))))
5435 (defun gnus-update-missing-marks (missing)
5436 "Go through the list of MISSING articles and remove them from the mark lists."
5439 ;; Go through all types.
5440 (dolist (elem gnus-article-mark-lists)
5441 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5442 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5443 (when (symbol-value var)
5444 ;; This list has articles. So we delete all missing
5445 ;; articles from it.
5448 (set var (delq (pop m) (symbol-value var))))))))))
5450 (defun gnus-update-marks ()
5451 "Enter the various lists of marked articles into the newsgroup info list."
5452 (let ((types gnus-article-mark-lists)
5453 (info (gnus-get-info gnus-newsgroup-name))
5454 type list newmarked symbol delta-marks)
5456 ;; Add all marks lists to the list of marks lists.
5457 (while (setq type (pop types))
5458 (setq list (symbol-value
5460 (intern (format "gnus-newsgroup-%s" (car type))))))
5463 ;; Get rid of the entries of the articles that have the
5465 (when (and (eq (cdr type) 'score)
5469 (prev (cons nil list))
5472 (if (or (not (consp (car arts)))
5473 (= (cdar arts) gnus-summary-default-score))
5474 (setcdr prev (cdr arts))
5476 (setq arts (cdr arts)))
5477 (setq list (cdr all)))))
5479 (when (eq (cdr type) 'seen)
5480 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5482 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5483 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5485 (when (and (gnus-check-backend-function
5486 'request-set-mark gnus-newsgroup-name)
5487 (not (gnus-article-unpropagatable-p (cdr type))))
5488 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5489 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5490 (add (gnus-remove-from-range
5491 (gnus-copy-sequence list) old)))
5493 (push (list add 'add (list (cdr type))) delta-marks))
5495 (push (list del 'del (list (cdr type))) delta-marks))))
5498 (push (cons (cdr type) list) newmarked)))
5501 (unless (gnus-check-group gnus-newsgroup-name)
5502 (error "Can't open server for %s" gnus-newsgroup-name))
5503 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5505 ;; Enter these new marks into the info of the group.
5507 (setcar (nthcdr 3 info) newmarked)
5508 ;; Add the marks lists to the end of the info.
5510 (setcdr (nthcdr 2 info) (list newmarked))))
5512 ;; Cut off the end of the info if there's nothing else there.
5516 (when (nthcdr (decf i) info)
5517 (setcdr (nthcdr i info) nil)))))))
5519 (defun gnus-set-mode-line (where)
5520 "Set the mode line of the article or summary buffers.
5521 If WHERE is `summary', the summary mode line format will be used."
5522 ;; Is this mode line one we keep updated?
5523 (when (and (memq where gnus-updated-mode-lines)
5525 (intern (format "gnus-%s-mode-line-format-spec" where))))
5528 ;; We evaluate this in the summary buffer since these
5529 ;; variables are buffer-local to that buffer.
5530 (set-buffer gnus-summary-buffer)
5531 ;; We bind all these variables that are used in the `eval' form
5533 (let* ((mformat (symbol-value
5535 (format "gnus-%s-mode-line-format-spec" where))))
5536 (gnus-tmp-group-name (gnus-group-decoded-name
5537 gnus-newsgroup-name))
5538 (gnus-tmp-article-number (or gnus-current-article 0))
5539 (gnus-tmp-unread gnus-newsgroup-unreads)
5540 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5541 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5542 (gnus-tmp-unread-and-unselected
5543 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5544 (zerop gnus-tmp-unselected))
5546 ((zerop gnus-tmp-unselected)
5547 (format "{%d more}" gnus-tmp-unread-and-unticked))
5548 (t (format "{%d(+%d) more}"
5549 gnus-tmp-unread-and-unticked
5550 gnus-tmp-unselected))))
5552 (if (and gnus-current-headers
5553 (vectorp gnus-current-headers))
5554 (gnus-mode-string-quote
5555 (mail-header-subject gnus-current-headers))
5557 bufname-length max-len
5558 gnus-tmp-header);; passed as argument to any user-format-funcs
5559 (setq mode-string (eval mformat))
5560 (setq bufname-length (if (string-match "%b" mode-string)
5563 (if (eq where 'summary)
5565 (get-buffer gnus-article-buffer))))
5568 (setq max-len (max 4 (if gnus-mode-non-string-length
5570 gnus-mode-non-string-length
5572 (length mode-string))))
5573 ;; We might have to chop a bit of the string off...
5574 (when (> (length mode-string) max-len)
5576 (concat (gnus-truncate-string mode-string (- max-len 3))
5578 ;; Pad the mode string a bit.
5579 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5580 ;; Update the mode line.
5581 (setq mode-line-buffer-identification
5582 (gnus-mode-line-buffer-identification (list mode-string)))
5583 (set-buffer-modified-p t))))
5585 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5586 "Go through the HEADERS list and add all Xrefs to a hash table.
5587 The resulting hash table is returned, or nil if no Xrefs were found."
5588 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5589 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5590 (xref-hashtb (gnus-make-hashtable))
5591 start group entry number xrefs header)
5593 (setq header (pop headers))
5594 (when (and (setq xrefs (mail-header-xref header))
5595 (not (memq (setq number (mail-header-number header))
5598 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5599 (setq start (match-end 0))
5600 (setq group (if prefix
5601 (concat prefix (substring xrefs (match-beginning 1)
5603 (substring xrefs (match-beginning 1) (match-end 1))))
5605 (string-to-int (substring xrefs (match-beginning 2)
5607 (if (setq entry (gnus-gethash group xref-hashtb))
5608 (setcdr entry (cons number (cdr entry)))
5609 (gnus-sethash group (cons number nil) xref-hashtb)))))
5610 (and start xref-hashtb)))
5612 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5613 "Look through all the headers and mark the Xrefs as read."
5614 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5615 name info xref-hashtb idlist method nth4)
5617 (set-buffer gnus-group-buffer)
5618 (when (setq xref-hashtb
5619 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5622 (unless (string= from-newsgroup (setq name (symbol-name group)))
5623 (setq idlist (symbol-value group))
5624 ;; Dead groups are not updated.
5626 (setq info (gnus-get-info name))
5627 (when (stringp (setq nth4 (gnus-info-method info)))
5628 (setq nth4 (gnus-server-to-method nth4))))
5629 ;; Only do the xrefs if the group has the same
5630 ;; select method as the group we have just read.
5631 (or (gnus-methods-equal-p
5632 nth4 (gnus-find-method-for-group from-newsgroup))
5634 (equal nth4 (setq method (gnus-find-method-for-group
5636 (and (equal (car nth4) (car method))
5637 (equal (nth 1 nth4) (nth 1 method))))
5638 gnus-use-cross-reference
5639 (or (not (eq gnus-use-cross-reference t))
5641 ;; Only do cross-references on subscribed
5642 ;; groups, if that is what is wanted.
5643 (<= (gnus-info-level info) gnus-level-subscribed))
5644 (gnus-group-make-articles-read name idlist))))
5647 (defun gnus-compute-read-articles (group articles)
5648 (let* ((entry (gnus-group-entry group))
5649 (info (nth 2 entry))
5650 (active (gnus-active group))
5653 ;; First peel off all invalid article numbers.
5655 (let ((ids articles)
5657 (while (setq id (pop ids))
5658 (when (and first (> id (cdr active)))
5659 ;; We'll end up in this situation in one particular
5660 ;; obscure situation. If you re-scan a group and get
5661 ;; a new article that is cross-posted to a different
5662 ;; group that has not been re-scanned, you might get
5663 ;; crossposted article that has a higher number than
5664 ;; Gnus believes possible. So we re-activate this
5665 ;; group as well. This might mean doing the
5666 ;; crossposting thingy will *increase* the number
5667 ;; of articles in some groups. Tsk, tsk.
5668 (setq active (or (gnus-activate-group group) active)))
5669 (when (or (> id (cdr active))
5670 (< id (car active)))
5671 (setq articles (delq id articles))))))
5672 ;; If the read list is nil, we init it.
5674 (null (gnus-info-read info))
5676 (setq ninfo (cons 1 (1- (car active))))
5677 (setq ninfo (gnus-info-read info)))
5678 ;; Then we add the read articles to the range.
5680 ninfo (setq articles (sort articles '<))))))
5682 (defun gnus-group-make-articles-read (group articles)
5683 "Update the info of GROUP to say that ARTICLES are read."
5685 (entry (gnus-group-entry group))
5686 (info (nth 2 entry))
5687 (active (gnus-active group))
5690 (setq range (gnus-compute-read-articles group articles))
5691 (with-current-buffer gnus-group-buffer
5694 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5695 (gnus-info-set-read ',info ',(gnus-info-read info))
5696 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5697 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5698 (gnus-group-update-group ,group t))))
5699 ;; Add the read articles to the range.
5700 (gnus-info-set-read info range)
5701 (gnus-request-set-mark group (list (list range 'add '(read))))
5702 ;; Then we have to re-compute how many unread
5703 ;; articles there are in this group.
5707 (setq num (- (1+ (cdr active)) (car active))))
5708 ((not (listp (cdr range)))
5709 (setq num (- (cdr active) (- (1+ (cdr range))
5713 (if (numberp (car range))
5715 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5716 (setq range (cdr range)))
5717 (setq num (- (cdr active) num))))
5718 ;; Update the number of unread articles.
5720 ;; Update the group buffer.
5721 (unless (gnus-ephemeral-group-p group)
5722 (gnus-group-update-group group t))))))
5724 (defvar gnus-newsgroup-none-id 0)
5726 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5727 (let ((cur nntp-server-buffer)
5730 (save-excursion (set-buffer gnus-summary-buffer)
5731 gnus-newsgroup-dependencies)))
5733 (mail-parse-charset gnus-newsgroup-charset)
5734 (mail-parse-ignored-charsets
5735 (save-excursion (condition-case nil
5736 (set-buffer gnus-summary-buffer)
5738 gnus-newsgroup-ignored-charsets)))
5740 (set-buffer nntp-server-buffer)
5741 ;; Translate all TAB characters into SPACE characters.
5742 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5743 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5744 (ietf-drums-unfold-fws)
5745 (gnus-run-hooks 'gnus-parse-headers-hook)
5746 (let ((case-fold-search t)
5747 in-reply-to header p lines chars ctype)
5748 (goto-char (point-min))
5749 ;; Search to the beginning of the next header. Error messages
5750 ;; do not begin with 2 or 3.
5751 (while (re-search-forward "^[23][0-9]+ " nil t)
5754 ;; This implementation of this function, with nine
5755 ;; search-forwards instead of the one re-search-forward and
5756 ;; a case (which basically was the old function) is actually
5757 ;; about twice as fast, even though it looks messier. You
5758 ;; can't have everything, I guess. Speed and elegance
5759 ;; doesn't always go hand in hand.
5762 (make-full-mail-header
5768 (narrow-to-region (point)
5769 (or (and (search-forward "\n.\n" nil t)
5775 (if (search-forward "\nsubject:" nil t)
5776 (nnheader-header-value)
5781 (if (search-forward "\nfrom:" nil t)
5782 (nnheader-header-value)
5787 (if (search-forward "\ndate:" nil t)
5788 (nnheader-header-value) ""))
5792 (setq id (if (re-search-forward
5793 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5794 ;; We do it this way to make sure the Message-ID
5795 ;; is (somewhat) syntactically valid.
5796 (buffer-substring (match-beginning 1)
5798 ;; If there was no message-id, we just fake one
5799 ;; to make subsequent routines simpler.
5800 (nnheader-generate-fake-message-id))))
5804 (if (search-forward "\nreferences:" nil t)
5808 (nnheader-header-value)
5813 (search-backward ">" end t)
5816 (search-backward "<" end t)
5818 ;; Get the references from the in-reply-to header if there
5819 ;; were no references and the in-reply-to header looks
5821 (if (and (search-forward "\nin-reply-to:" nil t)
5822 (setq in-reply-to (nnheader-header-value))
5823 (string-match "<[^>]+>" in-reply-to))
5825 (setq ref (substring in-reply-to (match-beginning 0)
5827 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5828 (setq ref2 (substring in-reply-to (match-beginning 0)
5830 (when (> (length ref2) (length ref))
5837 (if (search-forward "\nchars: " nil t)
5838 (if (numberp (setq chars (ignore-errors (read cur))))
5844 (if (search-forward "\nlines: " nil t)
5845 (if (numberp (setq lines (ignore-errors (read cur))))
5851 (and (search-forward "\nxref:" nil t)
5852 (nnheader-header-value)))
5854 (when gnus-extra-headers
5855 (let ((extra gnus-extra-headers)
5859 (when (search-forward
5860 (concat "\n" (symbol-name (car extra)) ":") nil t)
5861 (push (cons (car extra) (nnheader-header-value)) out))
5865 (if (and (search-forward "\ncontent-type: " nil t)
5866 (setq ctype (nnheader-header-value)))
5867 (mime-entity-set-content-type-internal
5868 header (mime-parse-Content-Type ctype)))
5869 (when (equal id ref)
5872 (when gnus-alter-header-function
5873 (funcall gnus-alter-header-function header)
5874 (setq id (mail-header-id header)
5875 ref (gnus-parent-id (mail-header-references header))))
5878 (gnus-dependencies-add-header
5879 header dependencies force-new))
5880 (push header headers))
5881 (goto-char (point-max))
5883 (nreverse headers)))))
5885 ;; Goes through the xover lines and returns a list of vectors
5886 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5887 force-new dependencies
5888 group also-fetch-heads)
5889 "Parse the news overview data in the server buffer.
5890 Return a list of headers that match SEQUENCE (see
5891 `nntp-retrieve-headers')."
5892 ;; Get the Xref when the users reads the articles since most/some
5893 ;; NNTP servers do not include Xrefs when using XOVER.
5894 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5895 (let ((mail-parse-charset gnus-newsgroup-charset)
5896 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5897 (cur nntp-server-buffer)
5898 (dependencies (or dependencies gnus-newsgroup-dependencies))
5900 ((eq gnus-read-all-available-headers t)
5902 ((stringp gnus-read-all-available-headers)
5903 (string-match gnus-read-all-available-headers group))
5906 number headers header)
5908 (set-buffer nntp-server-buffer)
5909 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5910 ;; Allow the user to mangle the headers before parsing them.
5911 (gnus-run-hooks 'gnus-parse-headers-hook)
5912 (goto-char (point-min))
5913 (gnus-parse-without-error
5914 (while (and (or sequence allp)
5916 (setq number (read cur))
5918 (while (and sequence
5919 (< (car sequence) number))
5920 (setq sequence (cdr sequence))))
5923 (eq number (car sequence))))
5925 (setq sequence (cdr sequence))
5926 (setq header (inline
5927 (gnus-nov-parse-line
5928 number dependencies force-new)))))
5929 (push header headers))
5931 ;; A common bug in inn is that if you have posted an article and
5932 ;; then retrieves the active file, it will answer correctly --
5933 ;; the new article is included. However, a NOV entry for the
5934 ;; article may not have been generated yet, so this may fail.
5935 ;; We work around this problem by retrieving the last few
5936 ;; headers using HEAD.
5937 (if (or (not also-fetch-heads)
5939 ;; We (probably) got all the headers.
5941 (let ((gnus-nov-is-evil t))
5944 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5945 (gnus-get-newsgroup-headers))))))))
5947 (defun gnus-article-get-xrefs ()
5948 "Fill in the Xref value in `gnus-current-headers', if necessary.
5949 This is meant to be called in `gnus-article-internal-prepare-hook'."
5950 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5951 gnus-current-headers)))
5952 (or (not gnus-use-cross-reference)
5954 (and (mail-header-xref headers)
5955 (not (string= (mail-header-xref headers) "")))
5956 (let ((case-fold-search t)
5959 (nnheader-narrow-to-headers)
5960 (goto-char (point-min))
5961 (when (or (and (not (eobp))
5962 (eq (downcase (char-after)) ?x)
5963 (looking-at "Xref:"))
5964 (search-forward "\nXref:" nil t))
5965 (goto-char (1+ (match-end 0)))
5966 (setq xref (buffer-substring (point) (point-at-eol)))
5967 (mail-header-set-xref headers xref)))))))
5969 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5970 "Find article ID and insert the summary line for that article.
5971 OLD-HEADER can either be a header or a line number to insert
5972 the subject line on."
5973 (let* ((line (and (numberp old-header) old-header))
5974 (old-header (and (vectorp old-header) old-header))
5975 (header (cond ((and old-header use-old-header)
5978 (gnus-number-to-header id))
5979 (gnus-number-to-header id))
5981 (gnus-read-header id))))
5982 (number (and (numberp id) id))
5985 ;; Rebuild the thread that this article is part of and go to the
5986 ;; article we have fetched.
5987 (when (and (not gnus-show-threads)
5990 (setq d (gnus-data-find (mail-header-number old-header))))
5991 (goto-char (gnus-data-pos d))
5997 (gnus-delete-line))))))
5999 (mail-header-set-number header (mail-header-number old-header)))
6000 (setq gnus-newsgroup-sparse
6001 (delq (setq number (mail-header-number header))
6002 gnus-newsgroup-sparse))
6003 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6004 (push number gnus-newsgroup-limit)
6005 (gnus-rebuild-thread (mail-header-id header) line)
6006 (gnus-summary-goto-subject number nil t))
6007 (when (and (numberp number)
6009 ;; We have to update the boundaries even if we can't fetch the
6010 ;; article if ID is a number -- so that the next `P' or `N'
6011 ;; command will fetch the previous (or next) article even
6012 ;; if the one we tried to fetch this time has been canceled.
6013 (when (> number gnus-newsgroup-end)
6014 (setq gnus-newsgroup-end number))
6015 (when (< number gnus-newsgroup-begin)
6016 (setq gnus-newsgroup-begin number))
6017 (setq gnus-newsgroup-unselected
6018 (delq number gnus-newsgroup-unselected)))
6019 ;; Report back a success?
6020 (and header (mail-header-number header))))
6022 ;;; Process/prefix in the summary buffer
6024 (defun gnus-summary-work-articles (n)
6025 "Return a list of articles to be worked upon.
6026 The prefix argument, the list of process marked articles, and the
6027 current article will be taken into consideration."
6029 (set-buffer gnus-summary-buffer)
6032 ;; A numerical prefix has been given.
6033 (setq n (prefix-numeric-value n))
6034 (let ((backward (< n 0))
6035 (n (abs (prefix-numeric-value n)))
6040 (push (setq article (gnus-summary-article-number))
6043 (gnus-summary-find-prev nil article)
6044 (gnus-summary-find-next nil article)))
6046 (nreverse articles)))
6047 ((and (gnus-region-active-p) (mark))
6048 (message "region active")
6049 ;; Work on the region between point and mark.
6050 (let ((max (max (point) (mark)))
6053 (goto-char (min (point) (mark)))
6056 (push (setq article (gnus-summary-article-number)) articles)
6057 (gnus-summary-find-next nil article)
6059 (nreverse articles))))
6060 (gnus-newsgroup-processable
6061 ;; There are process-marked articles present.
6062 ;; Save current state.
6063 (gnus-summary-save-process-mark)
6065 (reverse gnus-newsgroup-processable))
6067 ;; Just return the current article.
6068 (list (gnus-summary-article-number))))))
6070 (defmacro gnus-summary-iterate (arg &rest forms)
6071 "Iterate over the process/prefixed articles and do FORMS.
6072 ARG is the interactive prefix given to the command. FORMS will be
6073 executed with point over the summary line of the articles."
6074 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6075 `(let ((,articles (gnus-summary-work-articles ,arg)))
6077 (gnus-summary-goto-subject (car ,articles))
6081 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6082 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6084 (defun gnus-summary-save-process-mark ()
6085 "Push the current set of process marked articles on the stack."
6087 (push (copy-sequence gnus-newsgroup-processable)
6088 gnus-newsgroup-process-stack))
6090 (defun gnus-summary-kill-process-mark ()
6091 "Push the current set of process marked articles on the stack and unmark."
6093 (gnus-summary-save-process-mark)
6094 (gnus-summary-unmark-all-processable))
6096 (defun gnus-summary-yank-process-mark ()
6097 "Pop the last process mark state off the stack and restore it."
6099 (unless gnus-newsgroup-process-stack
6100 (error "Empty mark stack"))
6101 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6103 (defun gnus-summary-process-mark-set (set)
6104 "Make SET into the current process marked articles."
6105 (gnus-summary-unmark-all-processable)
6107 (gnus-summary-set-process-mark (pop set))))
6109 ;;; Searching and stuff
6111 (defun gnus-summary-search-group (&optional backward use-level)
6112 "Search for next unread newsgroup.
6113 If optional argument BACKWARD is non-nil, search backward instead."
6115 (set-buffer gnus-group-buffer)
6116 (when (gnus-group-search-forward
6117 backward nil (if use-level (gnus-group-group-level) nil))
6118 (gnus-group-group-name))))
6120 (defun gnus-summary-best-group (&optional exclude-group)
6121 "Find the name of the best unread group.
6122 If EXCLUDE-GROUP, do not go to this group."
6124 (set-buffer gnus-group-buffer)
6126 (gnus-group-best-unread-group exclude-group))))
6128 (defun gnus-summary-find-next (&optional unread article backward)
6130 (gnus-summary-find-prev unread article)
6131 (let* ((dummy (gnus-summary-article-intangible-p))
6132 (article (or article (gnus-summary-article-number)))
6133 (data (gnus-data-find-list article))
6135 (when (and (not dummy)
6136 (or (not gnus-summary-check-current)
6138 (not (gnus-data-unread-p (car data)))))
6139 (setq data (cdr data)))
6144 (unless (memq (gnus-data-number (car data))
6146 ((eq gnus-auto-goto-ignores
6147 'always-undownloaded)
6148 gnus-newsgroup-undownloaded)
6151 ((eq gnus-auto-goto-ignores
6153 gnus-newsgroup-unfetched)
6154 ((eq gnus-auto-goto-ignores
6156 gnus-newsgroup-undownloaded)))
6157 (when (gnus-data-unread-p (car data))
6158 (setq result (car data)
6160 (setq data (cdr data)))
6163 (goto-char (gnus-data-pos result))
6164 (gnus-data-number result)))))
6166 (defun gnus-summary-find-prev (&optional unread article)
6167 (let* ((eobp (eobp))
6168 (article (or article (gnus-summary-article-number)))
6169 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6171 (when (and (not eobp)
6172 (or (not gnus-summary-check-current)
6174 (not (gnus-data-unread-p (car data)))))
6175 (setq data (cdr data)))
6180 (unless (memq (gnus-data-number (car data))
6182 ((eq gnus-auto-goto-ignores
6183 'always-undownloaded)
6184 gnus-newsgroup-undownloaded)
6187 ((eq gnus-auto-goto-ignores
6189 gnus-newsgroup-unfetched)
6190 ((eq gnus-auto-goto-ignores
6192 gnus-newsgroup-undownloaded)))
6193 (when (gnus-data-unread-p (car data))
6194 (setq result (car data)
6196 (setq data (cdr data)))
6199 (goto-char (gnus-data-pos result))
6200 (gnus-data-number result))))
6202 (defun gnus-summary-find-subject (subject &optional unread backward article)
6203 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6204 (article (or article (gnus-summary-article-number)))
6205 (articles (gnus-data-list backward))
6206 (arts (gnus-data-find-list article articles))
6208 (when (or (not gnus-summary-check-current)
6210 (not (gnus-data-unread-p (car arts))))
6211 (setq arts (cdr arts)))
6213 (and (or (not unread)
6214 (gnus-data-unread-p (car arts)))
6215 (vectorp (gnus-data-header (car arts)))
6217 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6218 (setq result (car arts)
6220 (setq arts (cdr arts)))
6222 (goto-char (gnus-data-pos result))
6223 (gnus-data-number result))))
6225 (defun gnus-summary-search-forward (&optional unread subject backward)
6226 "Search forward for an article.
6227 If UNREAD, look for unread articles. If SUBJECT, look for
6228 articles with that subject. If BACKWARD, search backward instead."
6229 (cond (subject (gnus-summary-find-subject subject unread backward))
6230 (backward (gnus-summary-find-prev unread))
6231 (t (gnus-summary-find-next unread))))
6233 (defun gnus-recenter (&optional n)
6234 "Center point in window and redisplay frame.
6235 Also do horizontal recentering."
6237 (when (and gnus-auto-center-summary
6238 (not (eq gnus-auto-center-summary 'vertical)))
6239 (gnus-horizontal-recenter))
6242 (defun gnus-summary-recenter ()
6243 "Center point in the summary window.
6244 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6245 displayed, no centering will be performed."
6246 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6247 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6249 ;; The user has to want it.
6250 (when gnus-auto-center-summary
6251 (let* ((top (cond ((< (window-height) 4) 0)
6252 ((< (window-height) 7) 1)
6253 (t (if (numberp gnus-auto-center-summary)
6254 gnus-auto-center-summary
6256 (height (1- (window-height)))
6257 (bottom (save-excursion (goto-char (point-max))
6258 (forward-line (- height))
6260 (window (get-buffer-window (current-buffer))))
6261 (when (get-buffer-window gnus-article-buffer)
6262 ;; Only do recentering when the article buffer is displayed,
6263 ;; Set the window start to either `bottom', which is the biggest
6264 ;; possible valid number, or the second line from the top,
6265 ;; whichever is the least.
6266 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6267 (if (> bottom top-pos)
6268 ;; Keep the second line from the top visible
6269 (set-window-start window top-pos t)
6270 ;; Try to keep the bottom line visible; if it's partially
6271 ;; obscured, either scroll one more line to make it fully
6272 ;; visible, or revert to using TOP-POS.
6274 (goto-char (point-max))
6276 (let ((last-line-start (point)))
6278 (set-window-start window (point) t)
6279 (when (not (pos-visible-in-window-p last-line-start window))
6281 (set-window-start window (min (point) top-pos) t)))))))
6282 ;; Do horizontal recentering while we're at it.
6283 (when (and (get-buffer-window (current-buffer) t)
6284 (not (eq gnus-auto-center-summary 'vertical)))
6285 (let ((selected (selected-window)))
6286 (select-window (get-buffer-window (current-buffer) t))
6287 (gnus-summary-position-point)
6288 (gnus-horizontal-recenter)
6289 (select-window selected))))))
6291 (defun gnus-summary-jump-to-group (newsgroup)
6292 "Move point to NEWSGROUP in group mode buffer."
6293 ;; Keep update point of group mode buffer if visible.
6294 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6295 (save-window-excursion
6296 ;; Take care of tree window mode.
6297 (when (get-buffer-window gnus-group-buffer)
6298 (pop-to-buffer gnus-group-buffer))
6299 (gnus-group-jump-to-group newsgroup))
6301 ;; Take care of tree window mode.
6302 (if (get-buffer-window gnus-group-buffer)
6303 (pop-to-buffer gnus-group-buffer)
6304 (set-buffer gnus-group-buffer))
6305 (gnus-group-jump-to-group newsgroup))))
6307 ;; This function returns a list of article numbers based on the
6308 ;; difference between the ranges of read articles in this group and
6309 ;; the range of active articles.
6310 (defun gnus-list-of-unread-articles (group)
6311 (let* ((read (gnus-info-read (gnus-get-info group)))
6312 (active (or (gnus-active group) (gnus-activate-group group)))
6315 ;; If none are read, then all are unread.
6317 (setq first (car active))
6318 ;; If the range of read articles is a single range, then the
6319 ;; first unread article is the article after the last read
6320 ;; article. Sounds logical, doesn't it?
6321 (if (and (not (listp (cdr read)))
6322 (or (< (car read) (car active))
6323 (progn (setq read (list read))
6325 (setq first (max (car active) (1+ (cdr read))))
6326 ;; `read' is a list of ranges.
6327 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6330 (setq first (car active)))
6333 (while (< first nlast)
6334 (setq unread (cons first unread)
6336 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6337 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6338 (setq read (cdr read)))))
6339 ;; And add the last unread articles.
6340 (while (<= first last)
6341 (setq unread (cons first unread)
6343 ;; Return the list of unread articles.
6344 (delq 0 (nreverse unread))))
6346 (defun gnus-list-of-read-articles (group)
6347 "Return a list of unread, unticked and non-dormant articles."
6348 (let* ((info (gnus-get-info group))
6349 (marked (gnus-info-marks info))
6350 (active (gnus-active group)))
6352 (gnus-list-range-difference
6353 (gnus-list-range-difference
6354 (gnus-sorted-complement
6355 (gnus-uncompress-range active)
6356 (gnus-list-of-unread-articles group))
6357 (cdr (assq 'dormant marked)))
6358 (cdr (assq 'tick marked))))))
6360 ;; This function returns a sequence of article numbers based on the
6361 ;; difference between the ranges of read articles in this group and
6362 ;; the range of active articles.
6363 (defun gnus-sequence-of-unread-articles (group)
6364 (let* ((read (gnus-info-read (gnus-get-info group)))
6365 (active (or (gnus-active group) (gnus-activate-group group)))
6368 ;; If none are read, then all are unread.
6370 (setq first (car active))
6371 ;; If the range of read articles is a single range, then the
6372 ;; first unread article is the article after the last read
6373 ;; article. Sounds logical, doesn't it?
6374 (if (and (not (listp (cdr read)))
6375 (or (< (car read) (car active))
6376 (progn (setq read (list read))
6378 (setq first (max (car active) (1+ (cdr read))))
6379 ;; `read' is a list of ranges.
6380 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6383 (setq first (car active)))
6386 (push (cons first nlast) unread))
6387 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6388 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6389 (setq read (cdr read)))))
6390 ;; And add the last unread articles.
6391 (cond ((< first last)
6392 (push (cons first last) unread))
6394 (push first unread)))
6395 ;; Return the sequence of unread articles.
6396 (delq 0 (nreverse unread))))
6398 ;; Various summary commands
6400 (defun gnus-summary-select-article-buffer ()
6401 "Reconfigure windows to show article buffer."
6403 (if (not (gnus-buffer-live-p gnus-article-buffer))
6404 (error "There is no article buffer for this summary buffer")
6405 (gnus-configure-windows 'article)
6406 (select-window (get-buffer-window gnus-article-buffer))))
6408 (defun gnus-summary-universal-argument (arg)
6409 "Perform any operation on all articles that are process/prefixed."
6411 (let ((articles (gnus-summary-work-articles arg))
6418 (substitute-command-keys
6419 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6421 (gnus-error 1 "Undefined key")
6424 (gnus-summary-goto-subject (setq article (pop articles)))
6425 (let (gnus-newsgroup-processable)
6426 (command-execute func))
6427 (gnus-summary-remove-process-mark article)))))
6428 (gnus-summary-position-point))
6430 (defun gnus-summary-toggle-truncation (&optional arg)
6431 "Toggle truncation of summary lines.
6432 With ARG, turn line truncation on if ARG is positive."
6434 (setq truncate-lines
6435 (if (null arg) (not truncate-lines)
6436 (> (prefix-numeric-value arg) 0)))
6439 (defun gnus-summary-find-for-reselect ()
6440 "Return the number of an article to stay on across a reselect.
6441 The current article is considered, then following articles, then previous
6442 articles. An article is sought which is not cancelled and isn't a temporary
6443 insertion from another group. If there's no such then return a dummy 0."
6445 (dolist (rev '(nil t))
6446 (unless found ; don't demand the reverse list if we don't need it
6447 (let ((data (gnus-data-find-list
6448 (gnus-summary-article-number) (gnus-data-list rev))))
6449 (while (and data (not found))
6450 (if (and (< 0 (gnus-data-number (car data)))
6451 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6452 (setq found (gnus-data-number (car data))))
6453 (setq data (cdr data))))))
6456 (defun gnus-summary-reselect-current-group (&optional all rescan)
6457 "Exit and then reselect the current newsgroup.
6458 The prefix argument ALL means to select all articles."
6460 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6461 (error "Ephemeral groups can't be reselected"))
6462 (let ((current-subject (gnus-summary-find-for-reselect))
6463 (group gnus-newsgroup-name))
6464 (setq gnus-newsgroup-begin nil)
6465 (gnus-summary-exit nil 'leave-hidden)
6466 ;; We have to adjust the point of group mode buffer because
6467 ;; point was moved to the next unread newsgroup by exiting.
6468 (gnus-summary-jump-to-group group)
6471 (save-window-excursion
6472 ;; Don't show group contents.
6473 (set-window-start (selected-window) (point-max))
6474 (gnus-group-get-new-news-this-group 1))))
6475 (gnus-group-read-group all t)
6476 (gnus-summary-goto-subject current-subject nil t)))
6478 (defun gnus-summary-rescan-group (&optional all)
6479 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6481 (gnus-summary-reselect-current-group all t))
6483 (defun gnus-summary-update-info (&optional non-destructive)
6485 (let ((group gnus-newsgroup-name))
6487 (when gnus-newsgroup-kill-headers
6488 (setq gnus-newsgroup-killed
6489 (gnus-compress-sequence
6491 (gnus-list-range-intersection
6492 gnus-newsgroup-unselected gnus-newsgroup-killed)
6493 gnus-newsgroup-unreads)
6495 (unless (listp (cdr gnus-newsgroup-killed))
6496 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6497 (let ((headers gnus-newsgroup-headers))
6498 ;; Set the new ranges of read articles.
6500 (set-buffer gnus-group-buffer)
6501 (gnus-undo-force-boundary))
6502 (gnus-update-read-articles
6503 group (gnus-sorted-union
6504 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6505 ;; Set the current article marks.
6506 (let ((gnus-newsgroup-scored
6507 (if (and (not gnus-save-score)
6508 (not non-destructive))
6510 gnus-newsgroup-scored)))
6512 (gnus-update-marks)))
6513 ;; Do the cross-ref thing.
6514 (when gnus-use-cross-reference
6515 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6516 ;; Do not switch windows but change the buffer to work.
6517 (set-buffer gnus-group-buffer)
6518 (unless (gnus-ephemeral-group-p group)
6519 (gnus-group-update-group group)))))))
6521 (defun gnus-summary-save-newsrc (&optional force)
6522 "Save the current number of read/marked articles in the dribble buffer.
6523 The dribble buffer will then be saved.
6524 If FORCE (the prefix), also save the .newsrc file(s)."
6526 (gnus-summary-update-info t)
6528 (gnus-save-newsrc-file)
6529 (gnus-dribble-save)))
6531 (defun gnus-summary-exit (&optional temporary leave-hidden)
6532 "Exit reading current newsgroup, and then return to group selection mode.
6533 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6535 (gnus-set-global-variables)
6536 (gnus-kill-save-kill-buffer)
6537 (gnus-async-halt-prefetch)
6538 (let* ((group gnus-newsgroup-name)
6539 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6540 (gnus-group-is-exiting-p t)
6543 (buf (current-buffer)))
6545 ;; Do adaptive scoring, and possibly save score files.
6546 (when gnus-newsgroup-adaptive
6547 (gnus-score-adaptive))
6548 (when gnus-use-scoring
6550 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6551 ;; If we have several article buffers, we kill them at exit.
6552 (unless gnus-single-article-buffer
6553 (gnus-kill-buffer gnus-original-article-buffer)
6554 (setq gnus-article-current nil))
6555 (when gnus-use-cache
6556 (gnus-cache-possibly-remove-articles)
6557 (gnus-cache-save-buffers))
6558 (gnus-async-prefetch-remove-group group)
6559 (when gnus-suppress-duplicates
6560 (gnus-dup-enter-articles))
6561 (when gnus-use-trees
6562 (gnus-tree-close group))
6563 (when gnus-use-cache
6564 (gnus-cache-write-active))
6565 ;; Remove entries for this group.
6566 (nnmail-purge-split-history (gnus-group-real-name group))
6567 ;; Make all changes in this group permanent.
6569 (gnus-run-hooks 'gnus-exit-group-hook)
6570 (gnus-summary-update-info))
6571 (gnus-close-group group)
6572 ;; Make sure where we were, and go to next newsgroup.
6573 (set-buffer gnus-group-buffer)
6575 (gnus-group-jump-to-group group))
6576 (gnus-run-hooks 'gnus-summary-exit-hook)
6577 (unless (or quit-config
6578 ;; If this group has disappeared from the summary
6579 ;; buffer, don't skip forwards.
6580 (not (string= group (gnus-group-group-name))))
6581 (gnus-group-next-unread-group 1))
6582 (setq group-point (point))
6585 ;; If we have several article buffers, we kill them at exit.
6586 (unless gnus-single-article-buffer
6587 (gnus-kill-buffer gnus-article-buffer)
6588 (gnus-kill-buffer gnus-original-article-buffer)
6589 (setq gnus-article-current nil))
6591 (if (not gnus-kill-summary-on-exit)
6593 (gnus-deaden-summary)
6595 ;; We set all buffer-local variables to nil. It is unclear why
6596 ;; this is needed, but if we don't, buffer-local variables are
6597 ;; not garbage-collected, it seems. This would the lead to en
6598 ;; ever-growing Emacs.
6599 (gnus-summary-clear-local-variables)
6600 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6601 (gnus-summary-clear-local-variables))
6602 (when (get-buffer gnus-article-buffer)
6603 (bury-buffer gnus-article-buffer))
6604 ;; We clear the global counterparts of the buffer-local
6605 ;; variables as well, just to be on the safe side.
6606 (set-buffer gnus-group-buffer)
6607 (gnus-summary-clear-local-variables)
6608 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6609 (gnus-summary-clear-local-variables))
6610 ;; Return to group mode buffer.
6611 (when (eq mode 'gnus-summary-mode)
6612 (gnus-kill-buffer buf)))
6613 (setq gnus-current-select-method gnus-select-method)
6615 (set-buffer gnus-group-buffer)
6616 (pop-to-buffer gnus-group-buffer))
6617 (if (not quit-config)
6619 (goto-char group-point)
6620 (unless leave-hidden
6621 (gnus-configure-windows 'group 'force))
6622 (unless (pos-visible-in-window-p)
6623 (forward-line (/ (static-if (featurep 'xemacs)
6624 (window-displayed-height)
6625 (1- (window-height)))
6627 (set-window-start (selected-window) (point))
6628 (goto-char group-point)))
6629 (gnus-handle-ephemeral-exit quit-config))
6630 ;; Clear the current group name.
6632 (setq gnus-newsgroup-name nil)))))
6634 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6635 (defun gnus-summary-exit-no-update (&optional no-questions)
6636 "Quit reading current newsgroup without updating read article info."
6638 (let* ((group gnus-newsgroup-name)
6639 (gnus-group-is-exiting-p t)
6640 (gnus-group-is-exiting-without-update-p t)
6641 (quit-config (gnus-group-quit-config group)))
6642 (when (or no-questions
6644 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6645 (gnus-async-halt-prefetch)
6646 (run-hooks 'gnus-summary-prepare-exit-hook)
6647 ;; If we have several article buffers, we kill them at exit.
6648 (unless gnus-single-article-buffer
6649 (gnus-kill-buffer gnus-article-buffer)
6650 (gnus-kill-buffer gnus-original-article-buffer)
6651 (setq gnus-article-current nil))
6652 (if (not gnus-kill-summary-on-exit)
6653 (gnus-deaden-summary)
6654 (gnus-close-group group)
6655 (gnus-summary-clear-local-variables)
6656 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6657 (gnus-summary-clear-local-variables))
6658 (set-buffer gnus-group-buffer)
6659 (gnus-summary-clear-local-variables)
6660 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6661 (gnus-summary-clear-local-variables))
6662 (gnus-kill-buffer gnus-summary-buffer))
6663 (unless gnus-single-article-buffer
6664 (setq gnus-article-current nil))
6665 (when gnus-use-trees
6666 (gnus-tree-close group))
6667 (gnus-async-prefetch-remove-group group)
6668 (when (get-buffer gnus-article-buffer)
6669 (bury-buffer gnus-article-buffer))
6670 ;; Return to the group buffer.
6671 (gnus-configure-windows 'group 'force)
6672 ;; Clear the current group name.
6673 (setq gnus-newsgroup-name nil)
6674 (unless (gnus-ephemeral-group-p group)
6675 (gnus-group-update-group group))
6676 (when (equal (gnus-group-group-name) group)
6677 (gnus-group-next-unread-group 1))
6679 (gnus-handle-ephemeral-exit quit-config)))))
6681 (defun gnus-handle-ephemeral-exit (quit-config)
6682 "Handle movement when leaving an ephemeral group.
6683 The state which existed when entering the ephemeral is reset."
6684 (if (not (buffer-name (car quit-config)))
6685 (gnus-configure-windows 'group 'force)
6686 (set-buffer (car quit-config))
6687 (cond ((eq major-mode 'gnus-summary-mode)
6688 (gnus-set-global-variables))
6689 ((eq major-mode 'gnus-article-mode)
6691 ;; The `gnus-summary-buffer' variable may point
6692 ;; to the old summary buffer when using a single
6694 (unless (gnus-buffer-live-p gnus-summary-buffer)
6695 (set-buffer gnus-group-buffer))
6696 (set-buffer gnus-summary-buffer)
6697 (gnus-set-global-variables))))
6698 (if (or (eq (cdr quit-config) 'article)
6699 (eq (cdr quit-config) 'pick))
6701 ;; The current article may be from the ephemeral group
6702 ;; thus it is best that we reload this article
6704 ;; If we're exiting from a large digest, this can be
6705 ;; extremely slow. So, it's better not to reload it. -- jh.
6706 ;;(gnus-summary-show-article)
6707 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6708 (gnus-configure-windows 'pick 'force)
6709 (gnus-configure-windows (cdr quit-config) 'force)))
6710 (gnus-configure-windows (cdr quit-config) 'force))
6711 (when (eq major-mode 'gnus-summary-mode)
6712 (gnus-summary-next-subject 1 nil t)
6713 (gnus-summary-recenter)
6714 (gnus-summary-position-point))))
6716 (defun gnus-summary-preview-mime-message ()
6717 "MIME decode and play this message."
6719 (let ((gnus-break-pages nil)
6721 (gnus-summary-select-article gnus-show-all-headers t))
6722 (let ((w (get-buffer-window gnus-article-buffer)))
6724 (select-window (get-buffer-window gnus-article-buffer)))))
6728 (defvar gnus-dead-summary-mode-map nil)
6730 (unless gnus-dead-summary-mode-map
6731 (setq gnus-dead-summary-mode-map (make-keymap))
6732 (suppress-keymap gnus-dead-summary-mode-map)
6733 (substitute-key-definition
6734 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6735 (dolist (key '("\C-d" "\r" "\177" [delete]))
6736 (define-key gnus-dead-summary-mode-map
6737 key 'gnus-summary-wake-up-the-dead))
6738 (dolist (key '("q" "Q"))
6739 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6741 (defvar gnus-dead-summary-mode nil
6742 "Minor mode for Gnus summary buffers.")
6744 (defun gnus-dead-summary-mode (&optional arg)
6745 "Minor mode for Gnus summary buffers."
6747 (when (eq major-mode 'gnus-summary-mode)
6748 (make-local-variable 'gnus-dead-summary-mode)
6749 (setq gnus-dead-summary-mode
6750 (if (null arg) (not gnus-dead-summary-mode)
6751 (> (prefix-numeric-value arg) 0)))
6752 (when gnus-dead-summary-mode
6754 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6756 (defun gnus-deaden-summary ()
6757 "Make the current summary buffer into a dead summary buffer."
6758 ;; Kill any previous dead summary buffer.
6759 (when (and gnus-dead-summary
6760 (buffer-name gnus-dead-summary))
6762 (set-buffer gnus-dead-summary)
6763 (when gnus-dead-summary-mode
6764 (kill-buffer (current-buffer)))))
6765 ;; Make this the current dead summary.
6766 (setq gnus-dead-summary (current-buffer))
6767 (gnus-dead-summary-mode 1)
6768 (let ((name (buffer-name)))
6769 (when (string-match "Summary" name)
6771 (concat (substring name 0 (match-beginning 0)) "Dead "
6772 (substring name (match-beginning 0)))
6776 (defun gnus-kill-or-deaden-summary (buffer)
6777 "Kill or deaden the summary BUFFER."
6779 (when (and (buffer-name buffer)
6780 (not gnus-single-article-buffer))
6783 (gnus-kill-buffer gnus-article-buffer)
6784 (gnus-kill-buffer gnus-original-article-buffer)))
6787 (gnus-kill-summary-on-exit
6788 (when (and gnus-use-trees
6789 (gnus-buffer-exists-p buffer))
6792 (gnus-tree-close gnus-newsgroup-name)))
6793 (gnus-kill-buffer buffer))
6794 ;; Deaden the buffer.
6795 ((gnus-buffer-exists-p buffer)
6798 (gnus-deaden-summary))))))
6800 (defun gnus-summary-wake-up-the-dead (&rest args)
6801 "Wake up the dead summary buffer."
6803 (gnus-dead-summary-mode -1)
6804 (let ((name (buffer-name)))
6805 (when (string-match "Dead " name)
6807 (concat (substring name 0 (match-beginning 0))
6808 (substring name (match-end 0)))
6810 (gnus-message 3 "This dead summary is now alive again"))
6812 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6813 (defun gnus-summary-fetch-faq (&optional faq-dir)
6814 "Fetch the FAQ for the current group.
6815 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6819 (when current-prefix-arg
6821 "FAQ dir: " (and (listp gnus-group-faq-directory)
6822 (mapcar (lambda (file) (list file))
6823 gnus-group-faq-directory))))))
6824 (let (gnus-faq-buffer)
6825 (when (setq gnus-faq-buffer
6826 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6827 (gnus-configure-windows 'summary-faq))))
6829 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6830 (defun gnus-summary-describe-group (&optional force)
6831 "Describe the current newsgroup."
6833 (gnus-group-describe-group force gnus-newsgroup-name))
6835 (defun gnus-summary-describe-briefly ()
6836 "Describe summary mode commands briefly."
6838 (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")))
6840 ;; Walking around group mode buffer from summary mode.
6842 (defun gnus-summary-next-group (&optional no-article target-group backward)
6843 "Exit current newsgroup and then select next unread newsgroup.
6844 If prefix argument NO-ARTICLE is non-nil, no article is selected
6845 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6846 previous group instead."
6848 ;; Stop pre-fetching.
6849 (gnus-async-halt-prefetch)
6850 (let ((current-group gnus-newsgroup-name)
6851 (current-buffer (current-buffer))
6853 ;; First we semi-exit this group to update Xrefs and all variables.
6854 ;; We can't do a real exit, because the window conf must remain
6855 ;; the same in case the user is prompted for info, and we don't
6856 ;; want the window conf to change before that...
6857 (gnus-summary-exit t)
6858 (while (not entered)
6859 ;; Then we find what group we are supposed to enter.
6860 (set-buffer gnus-group-buffer)
6861 (gnus-group-jump-to-group current-group)
6864 (if (eq gnus-keep-same-level 'best)
6865 (gnus-summary-best-group gnus-newsgroup-name)
6866 (gnus-summary-search-group backward gnus-keep-same-level))))
6867 (if (not target-group)
6868 ;; There are no further groups, so we return to the group
6871 (gnus-message 5 "Returning to the group buffer")
6873 (when (gnus-buffer-live-p current-buffer)
6874 (set-buffer current-buffer)
6875 (gnus-summary-exit))
6876 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6877 ;; We try to enter the target group.
6878 (gnus-group-jump-to-group target-group)
6879 (let ((unreads (gnus-group-group-unread)))
6880 (if (and (or (eq t unreads)
6881 (and unreads (not (zerop unreads))))
6882 (gnus-summary-read-group
6883 target-group nil no-article
6884 (and (buffer-name current-buffer) current-buffer)
6887 (setq current-group target-group
6888 target-group nil)))))))
6890 (defun gnus-summary-prev-group (&optional no-article)
6891 "Exit current newsgroup and then select previous unread newsgroup.
6892 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6894 (gnus-summary-next-group no-article nil t))
6896 ;; Walking around summary lines.
6898 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6899 "Go to the first subject satisfying any non-nil constraint.
6900 If UNREAD is non-nil, the article should be unread.
6901 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6902 If UNSEEN is non-nil, the article should be unseen.
6903 Returns the article selected or nil if there are no matching articles."
6907 ((null gnus-newsgroup-data)
6908 (gnus-message 3 "No articles in the group")
6910 ;; Pick the first article.
6911 ((not (or unread undownloaded unseen))
6912 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6913 (gnus-data-number (car gnus-newsgroup-data)))
6914 ;; Find the first unread article.
6916 (let ((data gnus-newsgroup-data))
6918 (let ((num (gnus-data-number (car data))))
6919 (or (memq num gnus-newsgroup-unfetched)
6920 (not (or (and unread
6921 (memq num gnus-newsgroup-unreads))
6923 (memq num gnus-newsgroup-undownloaded))
6925 (memq num gnus-newsgroup-unseen)))))))
6926 (setq data (cdr data)))
6930 (goto-char (gnus-data-pos (car data)))
6931 (gnus-data-number (car data)))
6932 (gnus-message 3 "No more%s articles"
6933 (let* ((r (when unread " unread"))
6934 (d (when undownloaded " undownloaded"))
6935 (s (when unseen " unseen"))
6936 (l (delq nil (list r d s))))
6937 (cond ((= 3 (length l))
6938 (concat r "," d ", or" s))
6940 (concat (car l) ", or" (cadr l)))
6947 (gnus-summary-position-point))))))
6949 (defun gnus-summary-next-subject (n &optional unread dont-display)
6950 "Go to next N'th summary line.
6951 If N is negative, go to the previous N'th subject line.
6952 If UNREAD is non-nil, only unread articles are selected.
6953 The difference between N and the actual number of steps taken is
6956 (let ((backward (< n 0))
6960 (gnus-summary-find-prev unread)
6961 (gnus-summary-find-next unread)))
6962 (unless (zerop (setq n (1- n)))
6963 (gnus-summary-show-thread)))
6965 (gnus-message 7 "No more%s articles"
6966 (if unread " unread" "")))
6967 (unless dont-display
6968 (gnus-summary-recenter)
6969 (gnus-summary-position-point))
6972 (defun gnus-summary-next-unread-subject (n)
6973 "Go to next N'th unread summary line."
6975 (gnus-summary-next-subject n t))
6977 (defun gnus-summary-prev-subject (n &optional unread)
6978 "Go to previous N'th summary line.
6979 If optional argument UNREAD is non-nil, only unread article is selected."
6981 (gnus-summary-next-subject (- n) unread))
6983 (defun gnus-summary-prev-unread-subject (n)
6984 "Go to previous N'th unread summary line."
6986 (gnus-summary-next-subject (- n) t))
6988 (defun gnus-summary-goto-subjects (articles)
6989 "Insert the subject header for ARTICLES in the current buffer."
6991 (dolist (article articles)
6992 (gnus-summary-goto-subject article t)))
6993 (gnus-summary-limit (append articles gnus-newsgroup-limit))
6994 (gnus-summary-position-point))
6996 (defun gnus-summary-goto-subject (article &optional force silent)
6997 "Go the subject line of ARTICLE.
6998 If FORCE, also allow jumping to articles not currently shown."
6999 (interactive "nArticle number: ")
7000 (unless (numberp article)
7001 (error "Article %s is not a number" article))
7003 (data (gnus-data-find article)))
7004 ;; We read in the article if we have to.
7007 (gnus-summary-insert-subject
7009 (if (or (numberp force) (vectorp force)) force)
7011 (setq data (gnus-data-find article)))
7016 (gnus-message 3 "Can't find article %d" article))
7018 (let ((pt (gnus-data-pos data)))
7020 (gnus-summary-set-article-display-arrow pt))
7021 (gnus-summary-position-point)
7024 ;; Walking around summary lines with displaying articles.
7026 (defun gnus-summary-expand-window (&optional arg)
7027 "Make the summary buffer take up the entire Emacs frame.
7028 Given a prefix, will force an `article' buffer configuration."
7031 (gnus-configure-windows 'article 'force)
7032 (gnus-configure-windows 'summary 'force)))
7034 (defun gnus-summary-display-article (article &optional all-header)
7035 "Display ARTICLE in article buffer."
7036 (when (gnus-buffer-live-p gnus-article-buffer)
7037 (with-current-buffer gnus-article-buffer
7038 (set-buffer-multibyte t)))
7039 (gnus-set-global-variables)
7040 (when (gnus-buffer-live-p gnus-article-buffer)
7041 (with-current-buffer gnus-article-buffer
7042 (setq gnus-article-charset gnus-newsgroup-charset)
7043 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7044 (set-buffer-multibyte t)))
7048 (if gnus-summary-display-article-function
7049 (funcall gnus-summary-display-article-function article all-header)
7050 (gnus-article-prepare article all-header))
7051 (with-current-buffer gnus-article-buffer
7052 (set (make-local-variable 'gnus-summary-search-article-matched-data)
7054 (gnus-run-hooks 'gnus-select-article-hook)
7055 (when (and gnus-current-article
7056 (not (zerop gnus-current-article)))
7057 (gnus-summary-goto-subject gnus-current-article))
7058 (gnus-summary-recenter)
7059 (when (and gnus-use-trees gnus-show-threads)
7060 (gnus-possibly-generate-tree article)
7061 (gnus-highlight-selected-tree article))
7062 ;; Successfully display article.
7063 (gnus-article-set-window-start
7064 (cdr (assq article gnus-newsgroup-bookmarks))))))
7066 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7067 "Select the current article.
7068 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7069 non-nil, the article will be re-fetched even if it already present in
7070 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7072 ;; Make sure we are in the summary buffer to work around bbdb bug.
7073 (unless (eq major-mode 'gnus-summary-mode)
7074 (set-buffer gnus-summary-buffer))
7075 (let ((article (or article (gnus-summary-article-number)))
7076 (all-headers (not (not all-headers))) ;Must be T or NIL.
7077 gnus-summary-display-article-function)
7079 (gnus-summary-article-pseudo-p article)
7080 (error "This is a pseudo-article"))
7082 (set-buffer gnus-summary-buffer)
7083 (if (or (and gnus-single-article-buffer
7084 (or (null gnus-current-article)
7085 (null gnus-article-current)
7086 (null (get-buffer gnus-article-buffer))
7087 (not (eq article (cdr gnus-article-current)))
7088 (not (equal (car gnus-article-current)
7089 gnus-newsgroup-name))))
7090 (and (not gnus-single-article-buffer)
7091 (or (null gnus-current-article)
7092 (not (eq gnus-current-article article))))
7094 ;; The requested article is different from the current article.
7096 (gnus-summary-display-article article all-headers)
7097 (gnus-article-set-window-start
7098 (cdr (assq article gnus-newsgroup-bookmarks)))
7102 (defun gnus-summary-force-verify-and-decrypt ()
7103 "Display buttons for signed/encrypted parts and verify/decrypt them."
7105 (let ((mm-verify-option 'known)
7106 (mm-decrypt-option 'known)
7107 (gnus-article-emulate-mime t)
7108 (gnus-buttonized-mime-types (append (list "multipart/signed"
7109 "multipart/encrypted")
7110 gnus-buttonized-mime-types)))
7111 (gnus-summary-select-article nil 'force)))
7113 (defun gnus-summary-set-current-mark (&optional current-mark)
7114 "Obsolete function."
7117 (defun gnus-summary-next-article (&optional unread subject backward push)
7118 "Select the next article.
7119 If UNREAD, only unread articles are selected.
7120 If SUBJECT, only articles with SUBJECT are selected.
7121 If BACKWARD, the previous article is selected instead of the next."
7124 ;; Is there such an article?
7125 ((and (gnus-summary-search-forward unread subject backward)
7126 (or (gnus-summary-display-article (gnus-summary-article-number))
7127 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7128 (gnus-summary-position-point))
7129 ;; If not, we try the first unread, if that is wanted.
7131 gnus-auto-select-same
7132 (gnus-summary-first-unread-article))
7133 (gnus-summary-position-point)
7134 (gnus-message 6 "Wrapped"))
7135 ;; Try to get next/previous article not displayed in this group.
7136 ((and gnus-auto-extend-newsgroup
7137 (not unread) (not subject))
7138 (gnus-summary-goto-article
7139 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7140 nil (count-lines (point-min) (point))))
7141 ;; Go to next/previous group.
7143 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7144 (gnus-summary-jump-to-group gnus-newsgroup-name))
7145 (let ((cmd last-command-char)
7148 (set-buffer gnus-group-buffer)
7151 (if (eq gnus-keep-same-level 'best)
7152 (gnus-summary-best-group gnus-newsgroup-name)
7153 (gnus-summary-search-group backward gnus-keep-same-level))))
7154 ;; For some reason, the group window gets selected. We change
7156 (select-window (get-buffer-window (current-buffer)))
7157 ;; Select next unread newsgroup automagically.
7159 ((or (not gnus-auto-select-next)
7161 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7162 ((or (eq gnus-auto-select-next 'quietly)
7163 (and (eq gnus-auto-select-next 'slightly-quietly)
7165 (and (eq gnus-auto-select-next 'almost-quietly)
7166 (gnus-summary-last-article-p)))
7168 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7170 (gnus-message 7 "No more%s articles (%s)..."
7171 (if unread " unread" "")
7172 (if group (concat "selecting " group)
7174 (gnus-summary-next-group nil group backward)))
7176 (when (gnus-key-press-event-p last-input-event)
7177 (gnus-summary-walk-group-buffer
7178 gnus-newsgroup-name cmd unread backward point))))))))
7180 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7181 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7182 (?\C-p (gnus-group-prev-unread-group 1))))
7183 (cursor-in-echo-area t)
7184 keve key group ended prompt)
7186 (set-buffer gnus-group-buffer)
7189 (if (eq gnus-keep-same-level 'best)
7190 (gnus-summary-best-group gnus-newsgroup-name)
7191 (gnus-summary-search-group backward gnus-keep-same-level))))
7195 "No more%s articles%s " (if unread " unread" "")
7197 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7198 (format " (Type %s for %s [%s])"
7199 (single-key-description cmd) group
7200 (gnus-group-unread group))
7201 (format " (Type %s to exit %s)"
7202 (single-key-description cmd)
7203 gnus-newsgroup-name))))
7204 ;; Confirm auto selection.
7205 (setq key (car (setq keve (gnus-read-event-char prompt)))
7208 ((assq key keystrokes)
7209 (let ((obuf (current-buffer)))
7210 (switch-to-buffer gnus-group-buffer)
7212 (gnus-group-jump-to-group group))
7213 (eval (cadr (assq key keystrokes)))
7214 (setq group (gnus-group-group-name))
7215 (switch-to-buffer obuf))
7219 (gnus-ephemeral-group-p gnus-newsgroup-name))
7221 (gnus-summary-next-group nil group backward)))
7223 (push (cdr keve) unread-command-events))))))
7225 (defun gnus-summary-next-unread-article ()
7226 "Select unread article after current one."
7228 (gnus-summary-next-article
7229 (or (not (eq gnus-summary-goto-unread 'never))
7230 (gnus-summary-last-article-p (gnus-summary-article-number)))
7231 (and gnus-auto-select-same
7232 (gnus-summary-article-subject))))
7234 (defun gnus-summary-prev-article (&optional unread subject)
7235 "Select the article after the current one.
7236 If UNREAD is non-nil, only unread articles are selected."
7238 (gnus-summary-next-article unread subject t))
7240 (defun gnus-summary-prev-unread-article ()
7241 "Select unread article before current one."
7243 (gnus-summary-prev-article
7244 (or (not (eq gnus-summary-goto-unread 'never))
7245 (gnus-summary-first-article-p (gnus-summary-article-number)))
7246 (and gnus-auto-select-same
7247 (gnus-summary-article-subject))))
7249 (defun gnus-summary-next-page (&optional lines circular stop)
7250 "Show next page of the selected article.
7251 If at the end of the current article, select the next article.
7252 LINES says how many lines should be scrolled up.
7254 If CIRCULAR is non-nil, go to the start of the article instead of
7255 selecting the next article when reaching the end of the current
7258 If STOP is non-nil, just stop when reaching the end of the message.
7260 Also see the variable `gnus-article-skip-boring'."
7262 (setq gnus-summary-buffer (current-buffer))
7263 (gnus-set-global-variables)
7264 (let ((article (gnus-summary-article-number))
7265 (article-window (get-buffer-window gnus-article-buffer t))
7267 ;; If the buffer is empty, we have no article.
7269 (error "No article to select"))
7270 (gnus-configure-windows 'article)
7271 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7272 (if (and (eq gnus-summary-goto-unread 'never)
7273 (not (gnus-summary-last-article-p article)))
7274 (gnus-summary-next-article)
7275 (gnus-summary-next-unread-article))
7276 (if (or (null gnus-current-article)
7277 (null gnus-article-current)
7278 (/= article (cdr gnus-article-current))
7279 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7280 ;; Selected subject is different from current article's.
7281 (gnus-summary-display-article article)
7282 (when article-window
7283 (gnus-eval-in-buffer-window gnus-article-buffer
7284 (setq endp (or (gnus-article-next-page lines)
7285 (gnus-article-only-boring-p))))
7288 (gnus-message 3 "End of message"))
7290 (gnus-summary-beginning-of-article))
7292 (gnus-message 3 "End of message"))
7294 (if (and (eq gnus-summary-goto-unread 'never)
7295 (not (gnus-summary-last-article-p article)))
7296 (gnus-summary-next-article)
7297 (gnus-summary-next-unread-article))))))))
7298 (gnus-summary-recenter)
7299 (gnus-summary-position-point)))
7301 (defun gnus-summary-prev-page (&optional lines move)
7302 "Show previous page of selected article.
7303 Argument LINES specifies lines to be scrolled down.
7304 If MOVE, move to the previous unread article if point is at
7305 the beginning of the buffer."
7307 (let ((article (gnus-summary-article-number))
7308 (article-window (get-buffer-window gnus-article-buffer t))
7310 (gnus-configure-windows 'article)
7311 (if (or (null gnus-current-article)
7312 (null gnus-article-current)
7313 (/= article (cdr gnus-article-current))
7314 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7315 ;; Selected subject is different from current article's.
7316 (gnus-summary-display-article article)
7317 (gnus-summary-recenter)
7318 (when article-window
7319 (gnus-eval-in-buffer-window gnus-article-buffer
7320 (setq endp (gnus-article-prev-page lines)))
7321 (when (and move endp)
7323 (gnus-message 3 "Beginning of message"))
7325 (if (and (eq gnus-summary-goto-unread 'never)
7326 (not (gnus-summary-first-article-p article)))
7327 (gnus-summary-prev-article)
7328 (gnus-summary-prev-unread-article))))))))
7329 (gnus-summary-position-point))
7331 (defun gnus-summary-prev-page-or-article (&optional lines)
7332 "Show previous page of selected article.
7333 Argument LINES specifies lines to be scrolled down.
7334 If at the beginning of the article, go to the next article."
7336 (gnus-summary-prev-page lines t))
7338 (defun gnus-summary-scroll-up (lines)
7339 "Scroll up (or down) one line current article.
7340 Argument LINES specifies lines to be scrolled up (or down if negative)."
7342 (gnus-configure-windows 'article)
7343 (gnus-summary-show-thread)
7344 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7345 (gnus-eval-in-buffer-window gnus-article-buffer
7347 (when (gnus-article-next-page lines)
7348 (gnus-message 3 "End of message")))
7350 (gnus-article-prev-page (- lines))))))
7351 (gnus-summary-recenter)
7352 (gnus-summary-position-point))
7354 (defun gnus-summary-scroll-down (lines)
7355 "Scroll down (or up) one line current article.
7356 Argument LINES specifies lines to be scrolled down (or up if negative)."
7358 (gnus-summary-scroll-up (- lines)))
7360 (defun gnus-summary-next-same-subject ()
7361 "Select next article which has the same subject as current one."
7363 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7365 (defun gnus-summary-prev-same-subject ()
7366 "Select previous article which has the same subject as current one."
7368 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7370 (defun gnus-summary-next-unread-same-subject ()
7371 "Select next unread article which has the same subject as current one."
7373 (gnus-summary-next-article t (gnus-summary-article-subject)))
7375 (defun gnus-summary-prev-unread-same-subject ()
7376 "Select previous unread article which has the same subject as current one."
7378 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7380 (defun gnus-summary-first-unread-article ()
7381 "Select the first unread article.
7382 Return nil if there are no unread articles."
7385 (when (gnus-summary-first-subject t)
7386 (gnus-summary-show-thread)
7387 (gnus-summary-first-subject t)
7388 (gnus-summary-display-article (gnus-summary-article-number)))
7389 (gnus-summary-position-point)))
7391 (defun gnus-summary-first-unread-subject ()
7392 "Place the point on the subject line of the first unread article.
7393 Return nil if there are no unread articles."
7396 (when (gnus-summary-first-subject t)
7397 (gnus-summary-show-thread)
7398 (gnus-summary-first-subject t))
7399 (gnus-summary-position-point)))
7401 (defun gnus-summary-first-unseen-subject ()
7402 "Place the point on the subject line of the first unseen article.
7403 Return nil if there are no unseen articles."
7406 (when (gnus-summary-first-subject nil nil t)
7407 (gnus-summary-show-thread)
7408 (gnus-summary-first-subject nil nil t))
7409 (gnus-summary-position-point)))
7411 (defun gnus-summary-first-unseen-or-unread-subject ()
7412 "Place the point on the subject line of the first unseen article or,
7413 if all article have been seen, on the subject line of the first unread
7417 (unless (when (gnus-summary-first-subject nil nil t)
7418 (gnus-summary-show-thread)
7419 (gnus-summary-first-subject nil nil t))
7420 (when (gnus-summary-first-subject t)
7421 (gnus-summary-show-thread)
7422 (gnus-summary-first-subject t)))
7423 (gnus-summary-position-point)))
7425 (defun gnus-summary-first-article ()
7426 "Select the first article.
7427 Return nil if there are no articles."
7430 (when (gnus-summary-first-subject)
7431 (gnus-summary-show-thread)
7432 (gnus-summary-first-subject)
7433 (gnus-summary-display-article (gnus-summary-article-number)))
7434 (gnus-summary-position-point)))
7436 (defun gnus-summary-best-unread-article (&optional arg)
7437 "Select the unread article with the highest score.
7438 If given a prefix argument, select the next unread article that has a
7439 score higher than the default score."
7441 (let ((article (if arg
7442 (gnus-summary-better-unread-subject)
7443 (gnus-summary-best-unread-subject))))
7445 (gnus-summary-goto-article article)
7446 (error "No unread articles"))))
7448 (defun gnus-summary-best-unread-subject ()
7449 "Select the unread subject with the highest score."
7451 (let ((best -1000000)
7452 (data gnus-newsgroup-data)
7455 (and (gnus-data-unread-p (car data))
7457 (gnus-summary-article-score (gnus-data-number (car data))))
7460 article (gnus-data-number (car data))))
7461 (setq data (cdr data)))
7463 (gnus-summary-goto-subject article))
7464 (gnus-summary-position-point)
7467 (defun gnus-summary-better-unread-subject ()
7468 "Select the first unread subject that has a score over the default score."
7470 (let ((data gnus-newsgroup-data)
7472 (while (and (setq article (gnus-data-number (car data)))
7473 (or (gnus-data-read-p (car data))
7474 (not (> (gnus-summary-article-score article)
7475 gnus-summary-default-score))))
7476 (setq data (cdr data)))
7478 (gnus-summary-goto-subject article))
7479 (gnus-summary-position-point)
7482 (defun gnus-summary-last-subject ()
7483 "Go to the last displayed subject line in the group."
7484 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7486 (gnus-summary-goto-subject article))))
7488 (defun gnus-summary-goto-article (article &optional all-headers force)
7489 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7490 If ALL-HEADERS is non-nil, no header lines are hidden.
7491 If FORCE, go to the article even if it isn't displayed. If FORCE
7492 is a number, it is the line the article is to be displayed on."
7496 "Article number or Message-ID: "
7497 (mapcar (lambda (number) (list (int-to-string number)))
7498 gnus-newsgroup-limit))
7502 (if (and (stringp article)
7503 (string-match "@\\|%40" article))
7504 (gnus-summary-refer-article article)
7505 (when (stringp article)
7506 (setq article (string-to-number article)))
7507 (if (gnus-summary-goto-subject article force)
7508 (gnus-summary-display-article article all-headers)
7509 (gnus-message 4 "Couldn't go to article %s" article) nil))
7510 (gnus-summary-position-point)))
7512 (defun gnus-summary-goto-last-article ()
7513 "Go to the previously read article."
7516 (when gnus-last-article
7517 (gnus-summary-goto-article gnus-last-article nil t))
7518 (gnus-summary-position-point)))
7520 (defun gnus-summary-pop-article (number)
7521 "Pop one article off the history and go to the previous.
7522 NUMBER articles will be popped off."
7525 (setq gnus-newsgroup-history
7526 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7528 (gnus-summary-goto-article (car to) nil t)
7529 (error "Article history empty")))
7530 (gnus-summary-position-point))
7532 ;; Summary commands and functions for limiting the summary buffer.
7534 (defun gnus-summary-limit-to-articles (n)
7535 "Limit the summary buffer to the next N articles.
7536 If not given a prefix, use the process marked articles instead."
7539 (let ((articles (gnus-summary-work-articles n)))
7540 (setq gnus-newsgroup-processable nil)
7541 (gnus-summary-limit articles))
7542 (gnus-summary-position-point)))
7544 (defun gnus-summary-pop-limit (&optional total)
7545 "Restore the previous limit.
7546 If given a prefix, remove all limits."
7549 (setq gnus-newsgroup-limits
7550 (list (mapcar (lambda (h) (mail-header-number h))
7551 gnus-newsgroup-headers))))
7552 (unless gnus-newsgroup-limits
7553 (error "No limit to pop"))
7555 (gnus-summary-limit nil 'pop)
7556 (gnus-summary-position-point)))
7558 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7559 "Limit the summary buffer to articles that have subjects that match a regexp.
7560 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7562 (list (read-string (if current-prefix-arg
7563 "Exclude subject (regexp): "
7564 "Limit to subject (regexp): "))
7565 nil current-prefix-arg))
7567 (setq header "subject"))
7568 (when (not (equal "" subject))
7570 (let ((articles (gnus-summary-find-matching
7571 (or header "subject") subject 'all nil nil
7574 (error "Found no matches for \"%s\"" subject))
7575 (gnus-summary-limit articles))
7576 (gnus-summary-position-point))))
7578 (defun gnus-summary-limit-to-author (from &optional not-matching)
7579 "Limit the summary buffer to articles that have authors that match a regexp.
7580 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7582 (list (read-string (if current-prefix-arg
7583 "Exclude author (regexp): "
7584 "Limit to author (regexp): "))
7585 current-prefix-arg))
7586 (gnus-summary-limit-to-subject from "from" not-matching))
7588 (defun gnus-summary-limit-to-age (age &optional younger-p)
7589 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7590 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7591 articles that are younger than AGE days."
7593 (let ((younger current-prefix-arg)
7596 (while (not days-got)
7597 (setq days (if younger
7598 (read-string "Limit to articles younger than (in days, older when negative): ")
7600 "Limit to articles older than (in days, younger when negative): ")))
7601 (when (> (length days) 0)
7602 (setq days (read days)))
7607 (setq younger (not younger))
7608 (setq days (* days -1))))
7609 (message "Please enter a number.")
7611 (list days younger)))
7613 (let ((data gnus-newsgroup-data)
7614 (cutoff (days-to-time age))
7615 articles d date is-younger)
7616 (while (setq d (pop data))
7617 (when (and (vectorp (gnus-data-header d))
7618 (setq date (mail-header-date (gnus-data-header d))))
7619 (setq is-younger (time-less-p
7620 (time-since (condition-case ()
7627 (push (gnus-data-number d) articles))))
7628 (gnus-summary-limit (nreverse articles)))
7629 (gnus-summary-position-point)))
7631 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7632 "Limit the summary buffer to articles that match an 'extra' header."
7636 (gnus-completing-read-with-default
7637 (symbol-name (car gnus-extra-headers))
7638 (if current-prefix-arg
7639 "Exclude extra header:"
7640 "Limit extra header:")
7642 (cons (symbol-name x) x))
7647 (read-string (format "%s header %s (regexp): "
7648 (if current-prefix-arg "Exclude" "Limit to")
7650 current-prefix-arg)))
7651 (when (not (equal "" regexp))
7653 (let ((articles (gnus-summary-find-matching
7654 (cons 'extra header) regexp 'all nil nil
7657 (error "Found no matches for \"%s\"" regexp))
7658 (gnus-summary-limit articles))
7659 (gnus-summary-position-point))))
7661 (defun gnus-summary-limit-to-display-predicate ()
7662 "Limit the summary buffer to the predicated in the `display' group parameter."
7664 (unless gnus-newsgroup-display
7665 (error "There is no `display' group parameter"))
7667 (dolist (number gnus-newsgroup-articles)
7668 (when (funcall gnus-newsgroup-display)
7669 (push number articles)))
7670 (gnus-summary-limit articles))
7671 (gnus-summary-position-point))
7673 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7675 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7677 (defun gnus-summary-limit-to-unread (&optional all)
7678 "Limit the summary buffer to articles that are not marked as read.
7679 If ALL is non-nil, limit strictly to unread articles."
7682 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7683 (gnus-summary-limit-to-marks
7684 ;; Concat all the marks that say that an article is read and have
7686 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7687 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7688 gnus-low-score-mark gnus-expirable-mark
7689 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7690 gnus-duplicate-mark gnus-souped-mark)
7693 (defun gnus-summary-limit-to-replied (&optional unreplied)
7694 "Limit the summary buffer to replied articles.
7695 If UNREPLIED (the prefix), limit to unreplied articles."
7699 (gnus-set-difference gnus-newsgroup-articles
7700 gnus-newsgroup-replied))
7701 (gnus-summary-limit gnus-newsgroup-replied))
7702 (gnus-summary-position-point))
7704 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7705 (make-obsolete 'gnus-summary-delete-marked-with
7706 'gnus-summary-limit-exclude-marks)
7708 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7709 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7710 If REVERSE, limit the summary buffer to articles that are marked
7711 with MARKS. MARKS can either be a string of marks or a list of marks.
7712 Returns how many articles were removed."
7713 (interactive "sMarks: ")
7714 (gnus-summary-limit-to-marks marks t))
7716 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7717 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7718 If REVERSE (the prefix), limit the summary buffer to articles that are
7719 not marked with MARKS. MARKS can either be a string of marks or a
7721 Returns how many articles were removed."
7722 (interactive "sMarks: \nP")
7724 (let ((data gnus-newsgroup-data)
7725 (marks (if (listp marks) marks
7726 (append marks nil))) ; Transform to list.
7729 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7730 (memq (gnus-data-mark (car data)) marks))
7731 (push (gnus-data-number (car data)) articles))
7732 (setq data (cdr data)))
7733 (gnus-summary-limit articles))
7734 (gnus-summary-position-point)))
7736 (defun gnus-summary-limit-to-score (score)
7737 "Limit to articles with score at or above SCORE."
7738 (interactive "NLimit to articles with score of at least: ")
7739 (let ((data gnus-newsgroup-data)
7742 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7744 (push (gnus-data-number (car data)) articles))
7745 (setq data (cdr data)))
7747 (gnus-summary-limit articles)
7748 (gnus-summary-position-point))))
7750 (defun gnus-summary-limit-to-unseen ()
7751 "Limit to unseen articles."
7754 (gnus-summary-limit gnus-newsgroup-unseen)
7755 (gnus-summary-position-point)))
7757 (defun gnus-summary-limit-include-thread (id)
7758 "Display all the hidden articles that is in the thread with ID in it.
7759 When called interactively, ID is the Message-ID of the current
7761 (interactive (list (mail-header-id (gnus-summary-article-header))))
7762 (let ((articles (gnus-articles-in-thread
7763 (gnus-id-to-thread (gnus-root-id id)))))
7765 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7766 (gnus-summary-limit-include-matching-articles
7768 (regexp-quote (gnus-simplify-subject-re
7769 (mail-header-subject (gnus-id-to-header id)))))
7770 (gnus-summary-position-point))))
7772 (defun gnus-summary-limit-include-matching-articles (header regexp)
7773 "Display all the hidden articles that have HEADERs that match REGEXP."
7774 (interactive (list (read-string "Match on header: ")
7775 (read-string "Regexp: ")))
7776 (let ((articles (gnus-find-matching-articles header regexp)))
7778 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7779 (gnus-summary-position-point))))
7781 (defun gnus-summary-insert-dormant-articles ()
7782 "Insert all the dormant articles for this group into the current buffer."
7784 (let ((gnus-verbose (max 6 gnus-verbose)))
7785 (if (not gnus-newsgroup-dormant)
7786 (gnus-message 3 "No cached articles for this group")
7787 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7789 (defun gnus-summary-limit-include-dormant ()
7790 "Display all the hidden articles that are marked as dormant.
7791 Note that this command only works on a subset of the articles currently
7792 fetched for this group."
7794 (unless gnus-newsgroup-dormant
7795 (error "There are no dormant articles in this group"))
7797 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7798 (gnus-summary-position-point)))
7800 (defun gnus-summary-limit-exclude-dormant ()
7801 "Hide all dormant articles."
7804 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7805 (gnus-summary-position-point)))
7807 (defun gnus-summary-limit-exclude-childless-dormant ()
7808 "Hide all dormant articles that have no children."
7810 (let ((data (gnus-data-list t))
7811 articles d children)
7812 ;; Find all articles that are either not dormant or have
7814 (while (setq d (pop data))
7815 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7817 (gnus-article-children (gnus-data-number d)))
7820 (when (memq (car children) articles)
7825 (push (gnus-data-number d) articles)))
7828 (gnus-summary-limit articles)
7829 (gnus-summary-position-point))))
7831 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7832 "Mark all unread excluded articles as read.
7833 If ALL, mark even excluded ticked and dormants as read."
7835 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7836 (let ((articles (gnus-sorted-ndifference
7838 (mapcar (lambda (h) (mail-header-number h))
7839 gnus-newsgroup-headers)
7841 gnus-newsgroup-limit))
7843 (setq gnus-newsgroup-unreads
7844 (gnus-sorted-intersection gnus-newsgroup-unreads
7845 gnus-newsgroup-limit))
7847 (setq gnus-newsgroup-dormant nil
7848 gnus-newsgroup-marked nil
7849 gnus-newsgroup-reads
7851 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7852 gnus-newsgroup-reads))
7853 (while (setq article (pop articles))
7854 (unless (or (memq article gnus-newsgroup-dormant)
7855 (memq article gnus-newsgroup-marked))
7856 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7858 (defun gnus-summary-limit (articles &optional pop)
7860 ;; We pop the previous limit off the stack and use that.
7861 (setq articles (car gnus-newsgroup-limits)
7862 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7863 ;; We use the new limit, so we push the old limit on the stack.
7864 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7866 (setq gnus-newsgroup-limit articles)
7867 (let ((total (length gnus-newsgroup-data))
7868 (data (gnus-data-find-list (gnus-summary-article-number)))
7869 (gnus-summary-mark-below nil) ; Inhibit this.
7871 ;; This will do all the work of generating the new summary buffer
7872 ;; according to the new limit.
7873 (gnus-summary-prepare)
7874 ;; Hide any threads, possibly.
7875 (gnus-summary-maybe-hide-threads)
7876 ;; Try to return to the article you were at, or one in the
7879 ;; We try to find some article after the current one.
7881 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7884 (setq data (cdr data))))
7886 ;; If there is no data, that means that we were after the last
7887 ;; article. The same goes when we can't find any articles
7888 ;; after the current one.
7889 (goto-char (point-max))
7890 (gnus-summary-find-prev))
7891 (gnus-set-mode-line 'summary)
7892 ;; We return how many articles were removed from the summary
7893 ;; buffer as a result of the new limit.
7894 (- total (length gnus-newsgroup-data))))
7896 (defsubst gnus-invisible-cut-children (threads)
7899 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7904 (defsubst gnus-cut-thread (thread)
7905 "Go forwards in the thread until we find an article that we want to display."
7906 (when (or (eq gnus-fetch-old-headers 'some)
7907 (eq gnus-fetch-old-headers 'invisible)
7908 (numberp gnus-fetch-old-headers)
7909 (eq gnus-build-sparse-threads 'some)
7910 (eq gnus-build-sparse-threads 'more))
7911 ;; Deal with old-fetched headers and sparse threads.
7915 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7916 (gnus-summary-article-ancient-p
7917 (mail-header-number (car thread))))
7918 (if (or (<= (length (cdr thread)) 1)
7919 (eq gnus-fetch-old-headers 'invisible))
7920 (setq gnus-newsgroup-limit
7921 (delq (mail-header-number (car thread))
7922 gnus-newsgroup-limit)
7923 thread (cadr thread))
7924 (when (gnus-invisible-cut-children (cdr thread))
7925 (let ((th (cdr thread)))
7927 (if (memq (mail-header-number (caar th))
7928 gnus-newsgroup-limit)
7929 (setq thread (car th)
7931 (setq th (cdr th))))))))))
7934 (defun gnus-cut-threads (threads)
7935 "Cut off all uninteresting articles from the beginning of THREADS."
7936 (when (or (eq gnus-fetch-old-headers 'some)
7937 (eq gnus-fetch-old-headers 'invisible)
7938 (numberp gnus-fetch-old-headers)
7939 (eq gnus-build-sparse-threads 'some)
7940 (eq gnus-build-sparse-threads 'more))
7943 (setcar th (gnus-cut-thread (car th)))
7944 (setq th (cdr th)))))
7945 ;; Remove nixed out threads.
7948 (defun gnus-summary-initial-limit (&optional show-if-empty)
7949 "Figure out what the initial limit is supposed to be on group entry.
7950 This entails weeding out unwanted dormants, low-scored articles,
7951 fetch-old-headers verbiage, and so on."
7952 ;; Most groups have nothing to remove.
7953 (if (or gnus-inhibit-limiting
7954 (and (null gnus-newsgroup-dormant)
7955 (eq gnus-newsgroup-display 'gnus-not-ignore)
7956 (not (eq gnus-fetch-old-headers 'some))
7957 (not (numberp gnus-fetch-old-headers))
7958 (not (eq gnus-fetch-old-headers 'invisible))
7959 (null gnus-summary-expunge-below)
7960 (not (eq gnus-build-sparse-threads 'some))
7961 (not (eq gnus-build-sparse-threads 'more))
7962 (null gnus-thread-expunge-below)
7963 (not gnus-use-nocem)))
7965 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7966 (setq gnus-newsgroup-limit nil)
7969 (unless (car (symbol-value node))
7970 ;; These threads have no parents -- they are roots.
7971 (let ((nodes (cdr (symbol-value node)))
7974 (if (and gnus-thread-expunge-below
7975 (< (gnus-thread-total-score (car nodes))
7976 gnus-thread-expunge-below))
7977 (gnus-expunge-thread (pop nodes))
7978 (setq thread (pop nodes))
7979 (gnus-summary-limit-children thread))))))
7980 gnus-newsgroup-dependencies)
7981 ;; If this limitation resulted in an empty group, we might
7982 ;; pop the previous limit and use it instead.
7983 (when (and (not gnus-newsgroup-limit)
7985 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7986 gnus-newsgroup-limit))
7988 (defun gnus-summary-limit-children (thread)
7989 "Return 1 if this subthread is visible and 0 if it is not."
7990 ;; First we get the number of visible children to this thread. This
7991 ;; is done by recursing down the thread using this function, so this
7992 ;; will really go down to a leaf article first, before slowly
7993 ;; working its way up towards the root.
7995 (let* ((max-lisp-eval-depth 5000)
7998 (apply '+ (mapcar 'gnus-summary-limit-children
8001 (number (mail-header-number (car thread)))
8004 (not (memq number gnus-newsgroup-marked))
8006 ;; If this article is dormant and has absolutely no visible
8007 ;; children, then this article isn't visible.
8008 (and (memq number gnus-newsgroup-dormant)
8010 ;; If this is "fetch-old-headered" and there is no
8011 ;; visible children, then we don't want this article.
8012 (and (or (eq gnus-fetch-old-headers 'some)
8013 (numberp gnus-fetch-old-headers))
8014 (gnus-summary-article-ancient-p number)
8016 ;; If this is "fetch-old-headered" and `invisible', then
8017 ;; we don't want this article.
8018 (and (eq gnus-fetch-old-headers 'invisible)
8019 (gnus-summary-article-ancient-p number))
8020 ;; If this is a sparsely inserted article with no children,
8021 ;; we don't want it.
8022 (and (eq gnus-build-sparse-threads 'some)
8023 (gnus-summary-article-sparse-p number)
8025 ;; If we use expunging, and this article is really
8026 ;; low-scored, then we don't want this article.
8027 (when (and gnus-summary-expunge-below
8029 (or (cdr (assq number gnus-newsgroup-scored))
8030 gnus-summary-default-score))
8031 gnus-summary-expunge-below))
8032 ;; We increase the expunge-tally here, but that has
8033 ;; nothing to do with the limits, really.
8034 (incf gnus-newsgroup-expunged-tally)
8035 ;; We also mark as read here, if that's wanted.
8036 (when (and gnus-summary-mark-below
8037 (< score gnus-summary-mark-below))
8038 (setq gnus-newsgroup-unreads
8039 (delq number gnus-newsgroup-unreads))
8040 (if gnus-newsgroup-auto-expire
8041 (push number gnus-newsgroup-expirable)
8042 (push (cons number gnus-low-score-mark)
8043 gnus-newsgroup-reads)))
8045 ;; Do the `display' group parameter.
8046 (and gnus-newsgroup-display
8047 (not (funcall gnus-newsgroup-display)))
8048 ;; Check NoCeM things.
8049 (when (and gnus-use-nocem
8050 (gnus-nocem-unwanted-article-p
8051 (mail-header-id (car thread))))
8052 (setq gnus-newsgroup-unreads
8053 (delq number gnus-newsgroup-unreads))
8055 ;; Nope, invisible article.
8057 ;; Ok, this article is to be visible, so we add it to the limit
8059 (push number gnus-newsgroup-limit)
8062 (defun gnus-expunge-thread (thread)
8063 "Mark all articles in THREAD as read."
8064 (let* ((number (mail-header-number (car thread))))
8065 (incf gnus-newsgroup-expunged-tally)
8066 ;; We also mark as read here, if that's wanted.
8067 (setq gnus-newsgroup-unreads
8068 (delq number gnus-newsgroup-unreads))
8069 (if gnus-newsgroup-auto-expire
8070 (push number gnus-newsgroup-expirable)
8071 (push (cons number gnus-low-score-mark)
8072 gnus-newsgroup-reads)))
8073 ;; Go recursively through all subthreads.
8074 (mapcar 'gnus-expunge-thread (cdr thread)))
8076 ;; Summary article oriented commands
8078 (defun gnus-summary-refer-parent-article (n)
8079 "Refer parent article N times.
8080 If N is negative, go to ancestor -N instead.
8081 The difference between N and the number of articles fetched is returned."
8085 (when (not (natnump n))
8090 (setq header (gnus-summary-article-header))
8091 (if (and (eq (mail-header-number header)
8092 (cdr gnus-article-current))
8093 (equal gnus-newsgroup-name
8094 (car gnus-article-current)))
8095 ;; If we try to find the parent of the currently
8096 ;; displayed article, then we take a look at the actual
8097 ;; References header, since this is slightly more
8098 ;; reliable than the References field we got from the
8101 (set-buffer gnus-original-article-buffer)
8102 (nnheader-narrow-to-headers)
8103 (unless (setq ref (message-fetch-field "references"))
8104 (when (setq ref (message-fetch-field "in-reply-to"))
8105 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8108 ;; It's not the current article, so we take a bet on
8109 ;; the value we got from the server.
8110 (mail-header-references header)))
8112 (not (equal ref "")))
8113 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8114 (gnus-message 1 "Couldn't find parent"))
8115 (gnus-message 1 "No references in article %d"
8116 (gnus-summary-article-number))
8119 (gnus-summary-position-point)
8122 (defun gnus-summary-refer-references ()
8123 "Fetch all articles mentioned in the References header.
8124 Return the number of articles fetched."
8126 (let ((ref (mail-header-references (gnus-summary-article-header)))
8127 (current (gnus-summary-article-number))
8131 (error "No References in the current article")
8132 ;; For each Message-ID in the References header...
8133 (while (string-match "<[^>]*>" ref)
8135 ;; ... fetch that article.
8136 (gnus-summary-refer-article
8137 (prog1 (match-string 0 ref)
8138 (setq ref (substring ref (match-end 0))))))
8139 (gnus-summary-goto-subject current)
8140 (gnus-summary-position-point)
8143 (defun gnus-summary-refer-thread (&optional limit)
8144 "Fetch all articles in the current thread.
8145 If LIMIT (the numerical prefix), fetch that many old headers instead
8146 of what's specified by the `gnus-refer-thread-limit' variable."
8148 (let ((id (mail-header-id (gnus-summary-article-header)))
8149 (limit (if limit (prefix-numeric-value limit)
8150 gnus-refer-thread-limit)))
8151 (unless (eq gnus-fetch-old-headers 'invisible)
8152 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8153 ;; Retrieve the headers and read them in.
8154 (if (eq (if (numberp limit)
8155 (gnus-retrieve-headers
8157 (+ (mail-header-number
8158 (gnus-summary-article-header))
8160 gnus-newsgroup-end))
8161 gnus-newsgroup-name (* limit 2))
8162 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8164 (gnus-retrieve-headers (list gnus-newsgroup-end)
8165 gnus-newsgroup-name limit))
8167 (gnus-build-all-threads)
8168 (error "Can't fetch thread from back ends that don't support NOV"))
8169 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8170 (gnus-summary-limit-include-thread id)))
8172 (defun gnus-summary-refer-article (message-id)
8173 "Fetch an article specified by MESSAGE-ID."
8174 (interactive "sMessage-ID: ")
8175 (when (and (stringp message-id)
8176 (not (zerop (length message-id))))
8177 (setq message-id (gnus-replace-in-string message-id " " ""))
8178 ;; Construct the correct Message-ID if necessary.
8179 ;; Suggested by tale@pawl.rpi.edu.
8180 (unless (string-match "^<" message-id)
8181 (setq message-id (concat "<" message-id)))
8182 (unless (string-match ">$" message-id)
8183 (setq message-id (concat message-id ">")))
8184 ;; People often post MIDs from URLs, so unhex it:
8185 (unless (string-match "@" message-id)
8186 (setq message-id (gnus-url-unhex-string message-id)))
8187 (let* ((header (gnus-id-to-header message-id))
8189 (gnus-summary-article-sparse-p
8190 (mail-header-number header))
8191 (memq (mail-header-number header)
8192 gnus-newsgroup-limit)))
8195 ;; If the article is present in the buffer we just go to it.
8197 (or (not (gnus-summary-article-sparse-p
8198 (mail-header-number header)))
8201 (gnus-summary-goto-article
8202 (mail-header-number header) nil t)
8204 (gnus-summary-update-article (mail-header-number header)))))
8206 ;; We fetch the article.
8208 (dolist (gnus-override-method (gnus-refer-article-methods))
8209 (when (and (gnus-check-server gnus-override-method)
8210 ;; Fetch the header,
8211 (setq number (gnus-summary-insert-subject message-id)))
8212 ;; and display the article.
8213 (gnus-summary-select-article nil nil nil number)
8215 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8217 (defun gnus-refer-article-methods ()
8218 "Return a list of referable methods."
8220 ;; No method, so we default to current and native.
8221 ((null gnus-refer-article-method)
8222 (list gnus-current-select-method gnus-select-method))
8224 ((eq 'current gnus-refer-article-method)
8225 (list gnus-current-select-method))
8226 ;; List of select methods.
8227 ((not (and (symbolp (car gnus-refer-article-method))
8228 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8230 (dolist (method gnus-refer-article-method)
8231 (push (if (eq 'current method)
8232 gnus-current-select-method
8236 ;; One single select method.
8238 (list gnus-refer-article-method))))
8240 (defun gnus-summary-edit-parameters ()
8241 "Edit the group parameters of the current group."
8243 (gnus-group-edit-group gnus-newsgroup-name 'params))
8245 (defun gnus-summary-customize-parameters ()
8246 "Customize the group parameters of the current group."
8248 (gnus-group-customize gnus-newsgroup-name))
8250 (defun gnus-summary-enter-digest-group (&optional force)
8251 "Enter an nndoc group based on the current article.
8252 If FORCE, force a digest interpretation. If not, try
8253 to guess what the document format is."
8255 (let ((conf gnus-current-window-configuration))
8256 (save-window-excursion
8258 (let (gnus-article-prepare-hook
8259 gnus-display-mime-function
8261 (gnus-summary-select-article))))
8262 (setq gnus-current-window-configuration conf)
8263 (let* ((name (format "%s-%d"
8264 (gnus-group-prefixed-name
8265 gnus-newsgroup-name (list 'nndoc ""))
8267 (set-buffer gnus-summary-buffer)
8268 gnus-current-article)))
8269 (ogroup gnus-newsgroup-name)
8270 (params (append (gnus-info-params (gnus-get-info ogroup))
8271 (list (cons 'to-group ogroup))
8272 (list (cons 'parent-group ogroup))
8273 (list (cons 'save-article-group ogroup))))
8274 (case-fold-search t)
8275 (buf (current-buffer))
8278 (set-buffer gnus-original-article-buffer)
8279 ;; Have the digest group inherit the main mail address of
8280 ;; the parent article.
8281 (when (setq to-address (or (gnus-fetch-field "reply-to")
8282 (gnus-fetch-field "from")))
8283 (setq params (append
8284 (list (cons 'to-address
8285 (funcall gnus-decode-encoded-word-function
8287 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8288 (insert-buffer-substring gnus-original-article-buffer)
8289 ;; Remove lines that may lead nndoc to misinterpret the
8292 (goto-char (point-min))
8293 (or (search-forward "\n\n" nil t) (point)))
8294 (goto-char (point-min))
8295 (delete-matching-lines "^Path:\\|^From ")
8298 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8299 (gnus-newsgroup-ephemeral-ignored-charsets
8300 gnus-newsgroup-ignored-charsets))
8301 (gnus-group-read-ephemeral-group
8302 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8304 ,(if force 'mbox 'guess)))
8306 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8308 ;; Make all postings to this group go to the parent group.
8309 (nconc (gnus-info-params (gnus-get-info name))
8311 ;; Couldn't select this doc group.
8312 (switch-to-buffer buf)
8313 (gnus-set-global-variables)
8314 (gnus-configure-windows 'summary)
8315 (gnus-message 3 "Article couldn't be entered?"))
8316 (kill-buffer dig)))))
8318 (defun gnus-summary-read-document (n)
8319 "Open a new group based on the current article(s).
8320 This will allow you to read digests and other similar
8321 documents as newsgroups.
8322 Obeys the standard process/prefix convention."
8324 (let* ((articles (gnus-summary-work-articles n))
8325 (ogroup gnus-newsgroup-name)
8326 (params (append (gnus-info-params (gnus-get-info ogroup))
8327 (list (cons 'to-group ogroup))))
8328 article group egroup groups vgroup)
8329 (while (setq article (pop articles))
8330 (setq group (format "%s-%d" gnus-newsgroup-name article))
8331 (gnus-summary-remove-process-mark article)
8332 (when (gnus-summary-display-article article)
8335 (insert-buffer-substring gnus-original-article-buffer)
8336 ;; Remove some headers that may lead nndoc to make
8338 (message-narrow-to-head)
8339 (goto-char (point-min))
8340 (delete-matching-lines "^Path:\\|^From ")
8343 (gnus-group-read-ephemeral-group
8344 group `(nndoc ,group (nndoc-address ,(current-buffer))
8345 (nndoc-article-type guess))
8348 ;; Make all postings to this group go to the parent group.
8349 (nconc (gnus-info-params (gnus-get-info egroup))
8351 (push egroup groups))
8352 ;; Couldn't select this doc group.
8353 (gnus-error 3 "Article couldn't be entered"))))))
8354 ;; Now we have selected all the documents.
8357 (error "None of the articles could be interpreted as documents"))
8358 ((gnus-group-read-ephemeral-group
8359 (setq vgroup (format
8360 "nnvirtual:%s-%s" gnus-newsgroup-name
8361 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8362 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8364 (cons (current-buffer) 'summary)))
8366 (error "Couldn't select virtual nndoc group")))))
8368 (defun gnus-summary-isearch-article (&optional regexp-p)
8369 "Do incremental search forward on the current article.
8370 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8372 (let* ((gnus-inhibit-treatment t)
8373 (old (gnus-summary-select-article)))
8374 (gnus-configure-windows 'article)
8375 (gnus-eval-in-buffer-window gnus-article-buffer
8379 (gnus-article-show-all-headers))
8380 (goto-char (point-min))
8381 (isearch-forward regexp-p)))))
8383 (defun gnus-summary-search-article-forward (regexp &optional backward)
8384 "Search for an article containing REGEXP forward.
8385 If BACKWARD, search backward instead."
8388 (format "Search article %s (regexp%s): "
8389 (if current-prefix-arg "backward" "forward")
8390 (if gnus-last-search-regexp
8391 (concat ", default " gnus-last-search-regexp)
8393 current-prefix-arg))
8394 (if (string-equal regexp "")
8395 (setq regexp (or gnus-last-search-regexp ""))
8396 (setq gnus-last-search-regexp regexp)
8397 (setq gnus-article-before-search gnus-current-article))
8398 ;; Intentionally set gnus-last-article.
8399 (setq gnus-last-article gnus-article-before-search)
8400 (let ((gnus-last-article gnus-last-article))
8401 (if (gnus-summary-search-article regexp backward)
8402 (gnus-summary-show-thread)
8403 (error "Search failed: \"%s\"" regexp))))
8405 (defun gnus-summary-search-article-backward (regexp)
8406 "Search for an article containing REGEXP backward."
8409 (format "Search article backward (regexp%s): "
8410 (if gnus-last-search-regexp
8411 (concat ", default " gnus-last-search-regexp)
8413 (gnus-summary-search-article-forward regexp 'backward))
8416 (defmacro gnus-summary-search-article-position-point (regexp backward)
8417 "Dehighlight the last matched text and goto the beginning position."
8418 (` (if (and gnus-summary-search-article-matched-data
8419 (let ((text (caddr gnus-summary-search-article-matched-data))
8420 (inhibit-read-only t)
8423 (goto-char (car gnus-summary-search-article-matched-data))
8424 (cadr gnus-summary-search-article-matched-data))
8426 (string-match (, regexp) text)))
8427 (if (, backward) (beginning-of-line) (end-of-line))
8428 (goto-char (if (, backward) (point-max) (point-min))))))
8430 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8431 "Place point where X-Face image is displayed."
8432 (if (featurep 'xemacs)
8433 (` (let ((end (if (search-forward "\n\n" nil t)
8434 (goto-char (1- (point)))
8437 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8438 (unless (and (re-search-forward "^From:" end t)
8439 (setq extent (extent-at (point)))
8440 (extent-begin-glyph extent))
8441 (goto-char (, opoint)))))
8442 (` (let ((end (if (search-forward "\n\n" nil t)
8443 (goto-char (1- (point)))
8445 (start (or (search-backward "\n\n" nil t) (point-min))))
8447 (or (text-property-any start end 'x-face-image t);; x-face-e21
8448 (text-property-any start end 'x-face-mule-bitmap-image t)
8451 (defmacro gnus-summary-search-article-highlight-matched-text
8452 (backward treated x-face)
8453 "Highlight matched text in the function `gnus-summary-search-article'."
8454 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8455 (end (set-marker (make-marker) (match-end 0)))
8456 (inhibit-read-only t)
8460 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8462 (lambda (item) (setq items (delq item items)))
8463 '(gnus-treat-buttonize
8464 gnus-treat-fill-article
8465 gnus-treat-fill-long-lines
8466 gnus-treat-emphasize
8467 gnus-treat-highlight-headers
8468 gnus-treat-highlight-citation
8469 gnus-treat-highlight-signature
8470 gnus-treat-overstrike
8471 gnus-treat-display-x-face
8472 gnus-treat-buttonize-head
8473 gnus-treat-decode-article-as-default-mime-charset))
8474 (static-if (featurep 'xemacs)
8476 (cons '(x-face-mule-delete-x-face-field
8479 (gnus-treat-display-x-face
8480 (when (, x-face) gnus-treat-display-x-face)))
8481 (gnus-article-prepare-mime-display)))
8482 (goto-char (if (, backward) start end))
8484 (gnus-summary-search-article-highlight-goto-x-face (point)))
8485 (setq gnus-summary-search-article-matched-data
8486 (list start end (buffer-substring start end)))
8487 (unless (eq start end);; matched text has been deleted. :-<
8488 (put-text-property start end 'face
8489 (or (find-face 'isearch)
8490 'secondary-selection))))))
8493 (defun gnus-summary-search-article (regexp &optional backward)
8494 "Search for an article containing REGEXP.
8495 Optional argument BACKWARD means do search for backward.
8496 `gnus-select-article-hook' is not called during the search."
8497 ;; We have to require this here to make sure that the following
8498 ;; dynamic binding isn't shadowed by autoloading.
8499 (require 'gnus-async)
8501 (let ((gnus-select-article-hook nil) ;Disable hook.
8502 (gnus-article-prepare-hook nil)
8503 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8504 (gnus-use-article-prefetch nil)
8505 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8506 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8508 (gnus-keep-backlog nil)
8509 (gnus-break-pages nil)
8510 (gnus-summary-display-arrow nil)
8511 (gnus-updated-mode-lines nil)
8512 (gnus-auto-center-summary nil)
8513 (sum (current-buffer))
8516 (gnus-save-hidden-threads
8517 (static-if (featurep 'xemacs)
8518 (let ((gnus-inhibit-treatment t))
8519 (setq treated (eq 'old (gnus-summary-select-article)))
8521 (not (and (gnus-buffer-live-p gnus-article-buffer)
8522 (window-live-p (get-buffer-window
8523 gnus-article-buffer t)))))
8524 (gnus-summary-select-article nil t)
8525 (setq treated nil)))
8526 (let ((gnus-inhibit-treatment t)
8527 (x-face-mule-delete-x-face-field 'never))
8528 (setq treated (eq 'old (gnus-summary-select-article)))
8531 (and (gnus-buffer-live-p gnus-article-buffer)
8532 (window-live-p (get-buffer-window
8533 gnus-article-buffer t))
8534 (or (not (string-match "^\\^X-Face:" regexp))
8535 (with-current-buffer gnus-article-buffer
8536 gnus-summary-search-article-matched-data)))))
8537 (gnus-summary-select-article nil t)
8538 (setq treated nil))))
8539 (set-buffer gnus-article-buffer)
8543 (gnus-article-show-all-headers)
8544 (gnus-summary-search-article-position-point regexp backward))
8545 (goto-char (if backward (point-max) (point-min))))
8547 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8549 (re-search-backward regexp nil t)
8550 (re-search-forward regexp nil t))
8551 ;; We found the regexp.
8553 (gnus-summary-search-article-highlight-matched-text
8554 backward treated (string-match "^\\^X-Face:" regexp))
8557 (/ (- 2 (window-height
8558 (get-buffer-window gnus-article-buffer t)))
8561 (get-buffer-window (current-buffer))
8564 (setq point (point)))
8565 ;; We didn't find it, so we go to the next article.
8568 (while (eq found 'not)
8569 (if (not (if backward (gnus-summary-find-prev)
8570 (gnus-summary-find-next)))
8571 ;; No more articles.
8573 ;; Select the next article and adjust point.
8574 (unless (gnus-summary-article-sparse-p
8575 (gnus-summary-article-number))
8577 (let ((gnus-inhibit-treatment t))
8578 (gnus-summary-select-article))
8580 (set-buffer gnus-article-buffer)
8582 (goto-char (if backward (point-max) (point-min))))))))
8583 (gnus-message 7 ""))
8584 ;; Return whether we found the regexp.
8585 (when (eq found 'found)
8587 (gnus-summary-show-thread)
8588 (gnus-summary-goto-subject gnus-current-article)
8589 (gnus-summary-position-point)
8592 (defun gnus-find-matching-articles (header regexp)
8593 "Return a list of all articles that match REGEXP on HEADER.
8594 This search includes all articles in the current group that Gnus has
8595 fetched headers for, whether they are displayed or not."
8596 (let ((articles nil)
8597 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8598 (case-fold-search t))
8599 (dolist (header gnus-newsgroup-headers)
8600 (when (string-match regexp (funcall func header))
8601 (push (mail-header-number header) articles)))
8602 (nreverse articles)))
8604 (defun gnus-summary-find-matching (header regexp &optional backward unread
8605 not-case-fold not-matching)
8606 "Return a list of all articles that match REGEXP on HEADER.
8607 The search stars on the current article and goes forwards unless
8608 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8609 If UNREAD is non-nil, only unread articles will
8610 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8611 in the comparisons. If NOT-MATCHING, return a list of all articles that
8612 not match REGEXP on HEADER."
8613 (let ((case-fold-search (not not-case-fold))
8616 (if (eq (car header) 'extra)
8619 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8621 (error "%s is an invalid header" header))
8622 (unless (fboundp (intern (concat "mail-header-" header)))
8623 (error "%s is not a valid header" header))
8624 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8625 (dolist (d (if (eq backward 'all)
8627 (gnus-data-find-list
8628 (gnus-summary-article-number)
8629 (gnus-data-list backward))))
8630 (when (and (or (not unread) ; We want all articles...
8631 (gnus-data-unread-p d)) ; Or just unreads.
8632 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8636 (funcall func (gnus-data-header d))))
8637 (string-match regexp
8638 (funcall func (gnus-data-header d)))))
8639 (push (gnus-data-number d) articles))) ; Success!
8640 (nreverse articles)))
8642 (defun gnus-summary-execute-command (header regexp command &optional backward)
8643 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8644 If HEADER is an empty string (or nil), the match is done on the entire
8645 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8647 (list (let ((completion-ignore-case t))
8650 (mapcar (lambda (header) (list (format "%s" header)))
8652 '("Number" "Subject" "From" "Lines" "Date"
8653 "Message-ID" "Xref" "References" "Body")
8654 gnus-extra-headers))
8655 nil 'require-match))
8656 (read-string "Regexp: ")
8657 (read-key-sequence "Command: ")
8658 current-prefix-arg))
8659 (when (equal header "Body")
8661 ;; Hidden thread subtrees must be searched as well.
8662 (gnus-summary-show-all-threads)
8663 ;; We don't want to change current point nor window configuration.
8665 (save-window-excursion
8667 gnus-treat-strip-trailing-blank-lines
8668 gnus-treat-strip-leading-blank-lines
8669 gnus-treat-strip-multiple-blank-lines
8670 gnus-treat-hide-boring-headers
8671 gnus-treat-fold-newsgroups
8672 gnus-article-prepare-hook)
8673 (gnus-message 6 "Executing %s..." (key-description command))
8674 ;; We'd like to execute COMMAND interactively so as to give arguments.
8675 (gnus-execute header regexp
8676 `(call-interactively ',(key-binding command))
8678 (gnus-message 6 "Executing %s...done" (key-description command))))))
8680 (defun gnus-summary-beginning-of-article ()
8681 "Scroll the article back to the beginning."
8683 (gnus-summary-select-article)
8684 (gnus-configure-windows 'article)
8685 (gnus-eval-in-buffer-window gnus-article-buffer
8687 (goto-char (point-min))
8688 (when gnus-break-pages
8689 (gnus-narrow-to-page))))
8691 (defun gnus-summary-end-of-article ()
8692 "Scroll to the end of the article."
8694 (gnus-summary-select-article)
8695 (gnus-configure-windows 'article)
8696 (gnus-eval-in-buffer-window gnus-article-buffer
8698 (goto-char (point-max))
8700 (when gnus-break-pages
8701 (when (re-search-backward page-delimiter nil t)
8702 (narrow-to-region (match-end 0) (point-max)))
8703 (gnus-narrow-to-page))))
8705 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8706 "Truncate to LEN and quote all \"(\"'s in STRING."
8707 (gnus-replace-in-string (if (and len (> (length string) len))
8708 (substring string 0 len)
8712 (defun gnus-summary-print-article (&optional filename n)
8713 "Generate and print a PostScript image of the process-marked (mail) articles.
8715 If used interactively, print the current article if none are
8716 process-marked. With prefix arg, prompt the user for the name of the
8719 When used from Lisp, accept two optional args FILENAME and N. N means
8720 to print the next N articles. If N is negative, print the N previous
8721 articles. If N is nil and articles have been marked with the process
8722 mark, print these instead.
8724 If the optional first argument FILENAME is nil, send the image to the
8725 printer. If FILENAME is a string, save the PostScript image in a file with
8726 that name. If FILENAME is a number, prompt the user for the name of the file
8728 (interactive (list (ps-print-preprint current-prefix-arg)))
8729 (dolist (article (gnus-summary-work-articles n))
8730 (gnus-summary-select-article nil nil 'pseudo article)
8731 (gnus-eval-in-buffer-window gnus-article-buffer
8732 (gnus-print-buffer))
8733 (gnus-summary-remove-process-mark article))
8734 (ps-despool filename))
8736 (defun gnus-print-buffer ()
8737 (let ((buffer (generate-new-buffer " *print*")))
8740 (copy-to-buffer buffer (point-min) (point-max))
8742 (gnus-remove-text-with-property 'gnus-decoration)
8743 (when (gnus-visual-p 'article-highlight 'highlight)
8744 ;; Copy-to-buffer doesn't copy overlay. So redo
8746 (let ((gnus-article-buffer buffer))
8747 (gnus-article-highlight-citation t)
8748 (gnus-article-highlight-signature)
8749 (gnus-article-emphasize)
8750 (gnus-article-delete-invisible-text)))
8751 (let ((ps-left-header
8754 (gnus-summary-print-truncate-and-quote
8755 (mail-header-subject gnus-current-headers)
8758 (gnus-summary-print-truncate-and-quote
8759 (mail-header-from gnus-current-headers)
8763 "/pagenumberstring load"
8765 (mail-header-date gnus-current-headers) ")"))))
8766 (gnus-run-hooks 'gnus-ps-print-hook)
8769 (ps-spool-buffer-with-faces)
8770 (ps-spool-buffer)))))
8771 (kill-buffer buffer))))
8773 (defun gnus-summary-show-article (&optional arg)
8774 "Force redisplaying of the current article.
8775 If ARG (the prefix) is a number, show the article with the charset
8776 defined in `gnus-summary-show-article-charset-alist', or the charset
8778 If ARG (the prefix) is non-nil and not a number, show the raw article
8779 without any article massaging functions being run. Normally, the key
8780 strokes are `C-u g'."
8784 (gnus-summary-show-article t)
8785 (let* ((gnus-newsgroup-charset
8786 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8787 (mm-read-coding-system
8788 "View as charset: " ;; actually it is coding system.
8790 (set-buffer gnus-article-buffer)
8791 (mm-detect-coding-region (point) (point-max))))))
8792 (default-mime-charset gnus-newsgroup-charset)
8793 (gnus-newsgroup-ignored-charsets 'gnus-all))
8794 (gnus-summary-select-article nil 'force)
8795 (let ((deps gnus-newsgroup-dependencies)
8798 (set-buffer gnus-original-article-buffer)
8800 (message-narrow-to-head)
8801 (setq head (buffer-string))
8802 (goto-char (point-min))
8803 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8804 (goto-char (point-max))
8806 (setq lines (1- (count-lines (point) (point-max))))))
8808 (insert (format "211 %d Article retrieved.\n"
8809 (cdr gnus-article-current)))
8811 (if lines (insert (format "Lines: %d\n" lines)))
8813 (let ((nntp-server-buffer (current-buffer)))
8814 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8815 (gnus-data-set-header
8816 (gnus-data-find (cdr gnus-article-current))
8818 (gnus-summary-update-article-line
8819 (cdr gnus-article-current) header)
8820 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8821 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8823 ;; Select the article the normal way.
8824 (gnus-summary-select-article nil 'force))
8826 ;; We have to require this here to make sure that the following
8827 ;; dynamic binding isn't shadowed by autoloading.
8828 (require 'gnus-async)
8830 ;; Bind the article treatment functions to nil.
8831 (let ((gnus-have-all-headers t)
8832 gnus-article-prepare-hook
8833 gnus-article-decode-hook
8836 (gnus-inhibit-treatment t))
8837 (gnus-summary-select-article nil 'force))))
8838 (gnus-summary-goto-subject gnus-current-article)
8839 (gnus-summary-position-point))
8841 (defun gnus-summary-show-raw-article ()
8842 "Show the raw article without any article massaging functions being run."
8844 (gnus-summary-show-article t))
8846 (defun gnus-summary-verbose-headers (&optional arg)
8847 "Toggle permanent full header display.
8848 If ARG is a positive number, turn header display on.
8849 If ARG is a negative number, turn header display off."
8851 (setq gnus-show-all-headers
8852 (cond ((or (not (numberp arg))
8854 (not gnus-show-all-headers))
8857 (gnus-summary-show-article))
8859 (defun gnus-summary-toggle-header (&optional arg)
8860 "Show the headers if they are hidden, or hide them if they are shown.
8861 If ARG is a positive number, show the entire header.
8862 If ARG is a negative number, hide the unwanted header lines."
8864 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8865 (get-buffer-window gnus-article-buffer t))))
8866 (with-current-buffer gnus-article-buffer
8868 (article-narrow-to-head)
8869 (let* ((buffer-read-only nil)
8870 (inhibit-point-motion-hooks t)
8871 (hidden (if (numberp arg)
8873 (gnus-article-hidden-text-p 'headers)))
8875 (delete-region (point-min) (point-max))
8876 (with-current-buffer gnus-original-article-buffer
8877 (goto-char (setq s (point-min)))
8878 (setq e (if (search-forward "\n\n" nil t)
8881 (insert-buffer-substring gnus-original-article-buffer s e)
8882 ;; In T-gnus, gnus-article-decode-hook doesn't contain
8883 ;; article-decode-encoded-words by default.
8884 (article-decode-encoded-words)
8885 (run-hooks 'gnus-article-decode-hook)
8887 (let ((gnus-treat-hide-headers nil)
8888 (gnus-treat-hide-boring-headers nil))
8889 (gnus-delete-wash-type 'headers)
8890 (gnus-treat-article 'head))
8891 (gnus-treat-article 'head))
8894 (set-window-start window (goto-char (point-min))))
8895 (if gnus-break-pages
8896 (gnus-narrow-to-page)
8897 (when (gnus-visual-p 'page-marker)
8898 (let ((buffer-read-only nil))
8899 (gnus-remove-text-with-property 'gnus-prev)
8900 (gnus-remove-text-with-property 'gnus-next))))
8901 (gnus-set-mode-line 'article)))))
8903 (defun gnus-summary-show-all-headers ()
8904 "Make all header lines visible."
8906 (gnus-summary-toggle-header 1))
8908 (defun gnus-summary-toggle-mime (&optional arg)
8909 "Toggle MIME processing.
8910 If ARG is a positive number, turn MIME processing on."
8912 (setq gnus-show-mime
8914 (not gnus-show-mime)
8915 (> (prefix-numeric-value arg) 0)))
8916 (gnus-summary-select-article t 'force))
8918 (defun gnus-summary-caesar-message (&optional arg)
8919 "Caesar rotate the current article by 13.
8920 The numerical prefix specifies how many places to rotate each letter
8923 (gnus-summary-select-article)
8924 (let ((mail-header-separator ""))
8925 (gnus-eval-in-buffer-window gnus-article-buffer
8928 (let ((start (window-start))
8930 (message-caesar-buffer-body arg)
8931 (set-window-start (get-buffer-window (current-buffer)) start))))))
8933 (autoload 'unmorse-region "morse"
8934 "Convert morse coded text in region to ordinary ASCII text."
8937 (defun gnus-summary-morse-message (&optional arg)
8938 "Morse decode the current article."
8940 (gnus-summary-select-article)
8941 (let ((mail-header-separator ""))
8942 (gnus-eval-in-buffer-window gnus-article-buffer
8946 (let ((pos (window-start))
8948 (goto-char (point-min))
8949 (when (message-goto-body)
8950 (gnus-narrow-to-body))
8951 (goto-char (point-min))
8952 (while (re-search-forward "·" (point-max) t)
8953 (replace-match "."))
8954 (unmorse-region (point-min) (point-max))
8956 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8958 (defun gnus-summary-stop-page-breaking ()
8959 "Stop page breaking in the current article."
8961 (gnus-summary-select-article)
8962 (gnus-eval-in-buffer-window gnus-article-buffer
8964 (when (gnus-visual-p 'page-marker)
8965 (let ((buffer-read-only nil))
8966 (gnus-remove-text-with-property 'gnus-prev)
8967 (gnus-remove-text-with-property 'gnus-next))
8968 (setq gnus-page-broken nil))))
8970 (defun gnus-summary-move-article (&optional n to-newsgroup
8971 select-method action)
8972 "Move the current article to a different newsgroup.
8973 If N is a positive number, move the N next articles.
8974 If N is a negative number, move the N previous articles.
8975 If N is nil and any articles have been marked with the process mark,
8976 move those articles instead.
8977 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8978 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8979 re-spool using this method.
8981 When called interactively with TO-NEWSGROUP being nil, the value of
8982 the variable `gnus-move-split-methods' is used for finding a default
8983 for the target newsgroup.
8985 For this function to work, both the current newsgroup and the
8986 newsgroup that you want to move to have to support the `request-move'
8987 and `request-accept' functions.
8989 ACTION can be either `move' (the default), `crosspost' or `copy'."
8992 (setq action 'move))
8993 ;; Check whether the source group supports the required functions.
8994 (cond ((and (eq action 'move)
8995 (not (gnus-check-backend-function
8996 'request-move-article gnus-newsgroup-name)))
8997 (error "The current group does not support article moving"))
8998 ((and (eq action 'crosspost)
8999 (not (gnus-check-backend-function
9000 'request-replace-article gnus-newsgroup-name)))
9001 (error "The current group does not support article editing")))
9002 (let ((articles (gnus-summary-work-articles n))
9003 (prefix (if (gnus-check-backend-function
9004 'request-move-article gnus-newsgroup-name)
9005 (funcall gnus-move-group-prefix-function
9006 gnus-newsgroup-name)
9008 (names '((move "Move" "Moving")
9009 (copy "Copy" "Copying")
9010 (crosspost "Crosspost" "Crossposting")))
9011 (copy-buf (save-excursion
9012 (nnheader-set-temp-buffer " *copy article*")))
9013 art-group to-method new-xref article to-groups)
9014 (unless (assq action names)
9015 (error "Unknown action %s" action))
9016 ;; Read the newsgroup name.
9017 (when (and (not to-newsgroup)
9018 (not select-method))
9019 (if (and gnus-move-split-methods
9021 (and (memq gnus-current-article articles)
9022 (gnus-buffer-live-p gnus-original-article-buffer))))
9023 ;; When `gnus-move-split-methods' is non-nil, we have to
9024 ;; select an article to give `gnus-read-move-group-name' an
9025 ;; opportunity to suggest an appropriate default. However,
9026 ;; we needn't render or mark the article.
9027 (let ((gnus-display-mime-function nil)
9028 (gnus-article-prepare-hook nil)
9029 (gnus-mark-article-hook nil))
9030 (gnus-summary-select-article nil nil nil (car articles))))
9032 (gnus-read-move-group-name
9033 (cadr (assq action names))
9034 (symbol-value (intern (format "gnus-current-%s-group" action)))
9036 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9037 (setq to-method (or select-method
9038 (gnus-server-to-method
9039 (gnus-group-method to-newsgroup))))
9040 ;; Check the method we are to move this article to...
9041 (unless (gnus-check-backend-function
9042 'request-accept-article (car to-method))
9043 (error "%s does not support article copying" (car to-method)))
9044 (unless (gnus-check-server to-method)
9045 (error "Can't open server %s" (car to-method)))
9046 (gnus-message 6 "%s to %s: %s..."
9047 (caddr (assq action names))
9048 (or (car select-method) to-newsgroup) articles)
9050 (setq article (pop articles))
9054 ;; Move the article.
9056 ;; Remove this article from future suppression.
9057 (gnus-dup-unsuppress-article article)
9058 (gnus-request-move-article
9059 article ; Article to move
9060 gnus-newsgroup-name ; From newsgroup
9061 (nth 1 (gnus-find-method-for-group
9062 gnus-newsgroup-name)) ; Server
9063 (list 'gnus-request-accept-article
9064 to-newsgroup (list 'quote select-method)
9065 (not articles) t) ; Accept form
9066 (not articles))) ; Only save nov last time
9067 ;; Copy the article.
9070 (set-buffer copy-buf)
9071 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9072 (gnus-request-accept-article
9073 to-newsgroup select-method (not articles) t))))
9074 ;; Crosspost the article.
9075 ((eq action 'crosspost)
9076 (let ((xref (message-tokenize-header
9077 (mail-header-xref (gnus-summary-article-header article))
9079 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9080 ":" (number-to-string article)))
9082 (setq xref (list (system-name))))
9085 (mapconcat 'identity
9086 (delete "Xref:" (delete new-xref xref))
9090 (set-buffer copy-buf)
9091 ;; First put the article in the destination group.
9092 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9093 (when (consp (setq art-group
9094 (gnus-request-accept-article
9095 to-newsgroup select-method (not articles))))
9096 (setq new-xref (concat new-xref " " (car art-group)
9098 (number-to-string (cdr art-group))))
9099 ;; Now we have the new Xrefs header, so we insert
9100 ;; it and replace the new article.
9101 (nnheader-replace-header "Xref" new-xref)
9102 (gnus-request-replace-article
9103 (cdr art-group) to-newsgroup (current-buffer))
9107 (gnus-message 1 "Couldn't %s article %s: %s"
9108 (cadr (assq action names)) article
9109 (nnheader-get-report (car to-method))))
9110 ((eq art-group 'junk)
9111 (when (eq action 'move)
9112 (gnus-summary-mark-article article gnus-canceled-mark)
9113 (gnus-message 4 "Deleted article %s" article)
9114 ;; run the delete hook
9115 (run-hook-with-args 'gnus-summary-article-delete-hook
9118 (assoc article (gnus-data-list nil)))
9119 gnus-newsgroup-name nil
9122 (let* ((pto-group (gnus-group-prefixed-name
9123 (car art-group) to-method))
9124 (info (gnus-get-info pto-group))
9125 (to-group (gnus-info-group info))
9127 ;; Update the group that has been moved to.
9129 (memq action '(move copy)))
9130 (unless (member to-group to-groups)
9131 (push to-group to-groups))
9133 (unless (memq article gnus-newsgroup-unreads)
9134 (push 'read to-marks)
9136 info (gnus-add-to-range (gnus-info-read info)
9137 (list (cdr art-group)))))
9139 ;; See whether the article is to be put in the cache.
9140 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9141 gnus-article-mark-lists
9142 (delete '(expirable . expire)
9143 (copy-sequence gnus-article-mark-lists))))
9144 (to-article (cdr art-group)))
9146 ;; Enter the article into the cache in the new group,
9147 ;; if that is required.
9148 (when gnus-use-cache
9149 (gnus-cache-possibly-enter-article
9151 (let ((header (copy-sequence
9152 (gnus-summary-article-header article))))
9153 (mail-header-set-number header to-article)
9155 (memq article gnus-newsgroup-marked)
9156 (memq article gnus-newsgroup-dormant)
9157 (memq article gnus-newsgroup-unreads)))
9159 (when gnus-preserve-marks
9160 ;; Copy any marks over to the new group.
9161 (when (and (equal to-group gnus-newsgroup-name)
9162 (not (memq article gnus-newsgroup-unreads)))
9163 ;; Mark this article as read in this group.
9164 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9165 (setcdr (gnus-active to-group) to-article)
9166 (setcdr gnus-newsgroup-active to-article))
9169 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9170 (when (memq article (symbol-value
9171 (intern (format "gnus-newsgroup-%s"
9173 (push (cdar marks) to-marks)
9174 ;; If the other group is the same as this group,
9175 ;; then we have to add the mark to the list.
9176 (when (equal to-group gnus-newsgroup-name)
9177 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9180 (intern (format "gnus-newsgroup-%s"
9182 ;; Copy the marks to other group.
9183 (gnus-add-marked-articles
9184 to-group (cdar marks) (list to-article) info)))
9185 (setq marks (cdr marks)))
9187 (gnus-request-set-mark
9188 to-group (list (list (list to-article) 'add to-marks))))
9191 (concat "(gnus-group-set-info '"
9192 (gnus-prin1-to-string (gnus-get-info to-group))
9195 ;; Update the Xref header in this article to point to
9196 ;; the new crossposted article we have just created.
9197 (when (eq action 'crosspost)
9199 (set-buffer copy-buf)
9200 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9201 (nnheader-replace-header "Xref" new-xref)
9202 (gnus-request-replace-article
9203 article gnus-newsgroup-name (current-buffer))))
9205 ;; run the move/copy/crosspost/respool hook
9206 (run-hook-with-args 'gnus-summary-article-move-hook
9209 (assoc article (gnus-data-list nil)))
9214 ;;;!!!Why is this necessary?
9215 (set-buffer gnus-summary-buffer)
9217 (gnus-summary-goto-subject article)
9218 (when (eq action 'move)
9219 (gnus-summary-mark-article article gnus-canceled-mark))))
9220 (gnus-summary-remove-process-mark article))
9221 ;; Re-activate all groups that have been moved to.
9223 (set-buffer gnus-group-buffer)
9224 (let ((gnus-group-marked to-groups))
9225 (gnus-group-get-new-news-this-group nil t)))
9227 (gnus-kill-buffer copy-buf)
9228 (gnus-summary-position-point)
9229 (gnus-set-mode-line 'summary)))
9231 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9232 "Move the current article to a different newsgroup.
9233 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9234 When called interactively, if TO-NEWSGROUP is nil, use the value of
9235 the variable `gnus-move-split-methods' for finding a default target
9237 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9238 re-spool using this method."
9240 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9242 (defun gnus-summary-crosspost-article (&optional n)
9243 "Crosspost the current article to some other group."
9245 (gnus-summary-move-article n nil nil 'crosspost))
9247 (defcustom gnus-summary-respool-default-method nil
9248 "Default method type for respooling an article.
9249 If nil, use to the current newsgroup method."
9251 :group 'gnus-summary-mail)
9253 (defcustom gnus-summary-display-while-building nil
9254 "If non-nil, show and update the summary buffer as it's being built.
9255 If the value is t, update the buffer after every line is inserted. If
9256 the value is an integer (N), update the display every N lines."
9258 :type '(choice (const :tag "off" nil)
9260 (const :tag "frequently" t)))
9262 (defun gnus-summary-respool-article (&optional n method)
9263 "Respool the current article.
9264 The article will be squeezed through the mail spooling process again,
9265 which means that it will be put in some mail newsgroup or other
9266 depending on `nnmail-split-methods'.
9267 If N is a positive number, respool the N next articles.
9268 If N is a negative number, respool the N previous articles.
9269 If N is nil and any articles have been marked with the process mark,
9270 respool those articles instead.
9272 Respooling can be done both from mail groups and \"real\" newsgroups.
9273 In the former case, the articles in question will be moved from the
9274 current group into whatever groups they are destined to. In the
9275 latter case, they will be copied into the relevant groups."
9277 (list current-prefix-arg
9278 (let* ((methods (gnus-methods-using 'respool))
9280 (symbol-name (or gnus-summary-respool-default-method
9281 (car (gnus-find-method-for-group
9282 gnus-newsgroup-name)))))
9284 (gnus-completing-read-with-default
9285 methname "What backend do you want to use when respooling?"
9286 methods nil t nil 'gnus-mail-method-history))
9289 ((zerop (length (setq ms (gnus-servers-using-backend
9291 (list (intern method) ""))
9295 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9296 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9299 (error "No method given for respooling"))
9300 (if (assoc (symbol-name
9301 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9302 (gnus-methods-using 'respool))
9303 (gnus-summary-move-article n nil method)
9304 (gnus-summary-copy-article n nil method)))
9306 (defun gnus-summary-import-article (file &optional edit)
9307 "Import an arbitrary file into a mail newsgroup."
9308 (interactive "fImport file: \nP")
9309 (let ((group gnus-newsgroup-name)
9310 (now (current-time))
9311 atts lines group-art)
9312 (unless (gnus-check-backend-function 'request-accept-article group)
9313 (error "%s does not support article importing" group))
9314 (or (file-readable-p file)
9315 (not (file-regular-p file))
9316 (error "Can't read %s" file))
9318 (set-buffer (gnus-get-buffer-create " *import file*"))
9320 (nnheader-insert-file-contents file)
9321 (goto-char (point-min))
9322 (if (nnheader-article-p)
9324 (goto-char (point-min))
9325 (search-forward "\n\n" nil t)
9326 (narrow-to-region (point-min) (1- (point)))
9327 (goto-char (point-min))
9328 (unless (re-search-forward "^date:" nil t)
9329 (goto-char (point-max))
9330 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9331 ;; This doesn't look like an article, so we fudge some headers.
9332 (setq atts (file-attributes file)
9333 lines (count-lines (point-min) (point-max)))
9334 (insert "From: " (read-string "From: ") "\n"
9335 "Subject: " (read-string "Subject: ") "\n"
9336 "Date: " (message-make-date (nth 5 atts)) "\n"
9337 "Message-ID: " (message-make-message-id) "\n"
9338 "Lines: " (int-to-string lines) "\n"
9339 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9340 (setq group-art (gnus-request-accept-article group nil t))
9341 (kill-buffer (current-buffer)))
9342 (setq gnus-newsgroup-active (gnus-activate-group group))
9344 (gnus-summary-goto-article (cdr group-art) nil t)
9346 (gnus-summary-edit-article))))
9348 (defun gnus-summary-create-article ()
9349 "Create an article in a mail newsgroup."
9351 (let ((group gnus-newsgroup-name)
9352 (now (current-time))
9354 (unless (gnus-check-backend-function 'request-accept-article group)
9355 (error "%s does not support article importing" group))
9357 (set-buffer (gnus-get-buffer-create " *import file*"))
9359 (goto-char (point-min))
9360 ;; This doesn't look like an article, so we fudge some headers.
9361 (insert "From: " (read-string "From: ") "\n"
9362 "Subject: " (read-string "Subject: ") "\n"
9363 "Date: " (message-make-date now) "\n"
9364 "Message-ID: " (message-make-message-id) "\n")
9365 (setq group-art (gnus-request-accept-article group nil t))
9366 (kill-buffer (current-buffer)))
9367 (setq gnus-newsgroup-active (gnus-activate-group group))
9369 (gnus-summary-goto-article (cdr group-art) nil t)
9370 (gnus-summary-edit-article)))
9372 (defun gnus-summary-article-posted-p ()
9373 "Say whether the current (mail) article is available from news as well.
9374 This will be the case if the article has both been mailed and posted."
9376 (let ((id (mail-header-references (gnus-summary-article-header)))
9377 (gnus-override-method (car (gnus-refer-article-methods))))
9378 (if (gnus-request-head id "")
9379 (gnus-message 2 "The current message was found on %s"
9380 gnus-override-method)
9381 (gnus-message 2 "The current message couldn't be found on %s"
9382 gnus-override-method)
9385 (defun gnus-summary-expire-articles (&optional now)
9386 "Expire all articles that are marked as expirable in the current group."
9388 (when (and (not gnus-group-is-exiting-without-update-p)
9389 (gnus-check-backend-function
9390 'request-expire-articles gnus-newsgroup-name))
9391 ;; This backend supports expiry.
9392 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9393 (expirable (if total
9395 ;; We need to update the info for
9396 ;; this group for `gnus-list-of-read-articles'
9397 ;; to give us the right answer.
9398 (gnus-run-hooks 'gnus-exit-group-hook)
9399 (gnus-summary-update-info)
9400 (gnus-list-of-read-articles gnus-newsgroup-name))
9401 (setq gnus-newsgroup-expirable
9402 (sort gnus-newsgroup-expirable '<))))
9403 (expiry-wait (if now 'immediate
9404 (gnus-group-find-parameter
9405 gnus-newsgroup-name 'expiry-wait)))
9406 (nnmail-expiry-target
9407 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9408 nnmail-expiry-target))
9411 ;; There are expirable articles in this group, so we run them
9412 ;; through the expiry process.
9413 (gnus-message 6 "Expiring articles...")
9414 (unless (gnus-check-group gnus-newsgroup-name)
9415 (error "Can't open server for %s" gnus-newsgroup-name))
9416 ;; The list of articles that weren't expired is returned.
9419 (let ((nnmail-expiry-wait-function nil)
9420 (nnmail-expiry-wait expiry-wait))
9421 (setq es (gnus-request-expire-articles
9422 expirable gnus-newsgroup-name)))
9423 (setq es (gnus-request-expire-articles
9424 expirable gnus-newsgroup-name)))
9426 (setq gnus-newsgroup-expirable es))
9427 ;; We go through the old list of expirable, and mark all
9428 ;; really expired articles as nonexistent.
9429 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9430 (let ((gnus-use-cache nil))
9431 (dolist (article expirable)
9432 (when (and (not (memq article es))
9433 (gnus-data-find article))
9434 (gnus-summary-mark-article article gnus-canceled-mark)
9435 (run-hook-with-args 'gnus-summary-article-expire-hook
9438 (assoc article (gnus-data-list nil)))
9442 (gnus-message 6 "Expiring articles...done")))))
9444 (defun gnus-summary-expire-articles-now ()
9445 "Expunge all expirable articles in the current group.
9446 This means that *all* articles that are marked as expirable will be
9447 deleted forever, right now."
9449 (or gnus-expert-user
9451 "Are you really, really, really sure you want to delete all these messages? ")
9453 (gnus-summary-expire-articles t))
9455 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9456 (defun gnus-summary-delete-article (&optional n)
9457 "Delete the N next (mail) articles.
9458 This command actually deletes articles. This is not a marking
9459 command. The article will disappear forever from your life, never to
9462 If N is negative, delete backwards.
9463 If N is nil and articles have been marked with the process mark,
9464 delete these instead.
9466 If `gnus-novice-user' is non-nil you will be asked for
9467 confirmation before the articles are deleted."
9469 (unless (gnus-check-backend-function 'request-expire-articles
9470 gnus-newsgroup-name)
9471 (error "The current newsgroup does not support article deletion"))
9472 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9473 (error "Couldn't open server"))
9474 ;; Compute the list of articles to delete.
9475 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9476 (nnmail-expiry-target 'delete)
9478 (if (and gnus-novice-user
9479 (not (gnus-yes-or-no-p
9480 (format "Do you really want to delete %s forever? "
9481 (if (> (length articles) 1)
9482 (format "these %s articles" (length articles))
9485 ;; Delete the articles.
9486 (setq not-deleted (gnus-request-expire-articles
9487 articles gnus-newsgroup-name 'force))
9489 (gnus-summary-remove-process-mark (car articles))
9490 ;; The backend might not have been able to delete the article
9492 (unless (memq (car articles) not-deleted)
9493 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9494 (let* ((article (car articles))
9495 (id (mail-header-id (gnus-data-header
9496 (assoc article (gnus-data-list nil))))))
9497 (run-hook-with-args 'gnus-summary-article-delete-hook
9498 'delete id gnus-newsgroup-name nil
9500 (setq articles (cdr articles)))
9502 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9503 (gnus-summary-position-point)
9504 (gnus-set-mode-line 'summary)
9507 (defun gnus-summary-edit-article (&optional force)
9508 "Edit the current article.
9509 This will have permanent effect only in mail groups.
9510 If FORCE is non-nil, allow editing of articles even in read-only
9514 (set-buffer gnus-summary-buffer)
9515 (let ((mail-parse-charset gnus-newsgroup-charset)
9516 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9517 (gnus-set-global-variables)
9518 (when (and (not force)
9519 (gnus-group-read-only-p))
9520 (error "The current newsgroup does not support article editing"))
9521 (gnus-summary-show-article t)
9522 (gnus-article-edit-article
9524 `(lambda (no-highlight)
9525 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9526 (message-options message-options)
9527 (message-options-set-recipient)
9528 (mail-parse-ignored-charsets
9529 ',gnus-newsgroup-ignored-charsets))
9530 (gnus-summary-edit-article-done
9531 ,(or (mail-header-references gnus-current-headers) "")
9532 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9534 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9536 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9538 "Make edits to the current article permanent."
9541 ;; The buffer restriction contains the entire article if it exists.
9542 (when (article-goto-body)
9543 (let ((lines (count-lines (point) (point-max)))
9544 (length (- (point-max) (point)))
9545 (case-fold-search t)
9546 (body (copy-marker (point))))
9547 (goto-char (point-min))
9548 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9549 (delete-region (match-beginning 1) (match-end 1))
9550 (insert (number-to-string length)))
9551 (goto-char (point-min))
9552 (when (re-search-forward
9553 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9554 (delete-region (match-beginning 1) (match-end 1))
9555 (insert (number-to-string length)))
9556 (goto-char (point-min))
9557 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9558 (delete-region (match-beginning 1) (match-end 1))
9559 (insert (number-to-string lines))))))
9560 ;; Replace the article.
9561 (let ((buf (current-buffer)))
9563 (insert-buffer-substring buf)
9565 (if (and (not read-only)
9566 (not (gnus-request-replace-article
9567 (cdr gnus-article-current) (car gnus-article-current)
9568 (current-buffer) t)))
9569 (error "Couldn't replace article")
9570 ;; Update the summary buffer.
9572 (equal (message-tokenize-header references " ")
9573 (message-tokenize-header
9574 (or (message-fetch-field "references") "") " ")))
9575 ;; We only have to update this line.
9578 (message-narrow-to-head)
9579 (let ((head (buffer-string))
9582 (insert (format "211 %d Article retrieved.\n"
9583 (cdr gnus-article-current)))
9586 (let ((nntp-server-buffer (current-buffer)))
9587 (setq header (car (gnus-get-newsgroup-headers
9590 (set-buffer gnus-summary-buffer)
9591 (gnus-data-set-header
9592 (gnus-data-find (cdr gnus-article-current))
9594 (gnus-summary-update-article-line
9595 (cdr gnus-article-current) header)
9596 (if (gnus-summary-goto-subject
9597 (cdr gnus-article-current) nil t)
9598 (gnus-summary-update-secondary-mark
9599 (cdr gnus-article-current))))))))
9601 (set-buffer (or buffer gnus-summary-buffer))
9602 (gnus-summary-update-article (cdr gnus-article-current))
9603 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9604 (gnus-summary-update-secondary-mark
9605 (cdr gnus-article-current))))
9606 ;; Prettify the article buffer again.
9607 (unless no-highlight
9609 (set-buffer gnus-article-buffer)
9610 ;;;!!! Fix this -- article should be rehighlighted.
9611 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9612 (set-buffer gnus-original-article-buffer)
9613 (gnus-request-article
9614 (cdr gnus-article-current)
9615 (car gnus-article-current) (current-buffer))))
9616 ;; Prettify the summary buffer line.
9617 (when (gnus-visual-p 'summary-highlight 'highlight)
9618 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9620 (defun gnus-summary-edit-wash (key)
9621 "Perform editing command KEY in the article buffer."
9625 (message "%s" (concat (this-command-keys) "- "))
9628 (gnus-summary-edit-article)
9629 (execute-kbd-macro (concat (this-command-keys) key))
9630 (gnus-article-edit-done))
9634 (defun gnus-summary-respool-query (&optional silent trace)
9635 "Query where the respool algorithm would put this article."
9637 (let (gnus-mark-article-hook)
9638 (gnus-summary-select-article)
9640 (set-buffer gnus-original-article-buffer)
9641 (let ((groups (nnmail-article-group 'identity trace)))
9644 (message "This message would go to %s"
9645 (mapconcat 'car groups ", "))
9646 (message "This message would go to no groups"))
9649 (defun gnus-summary-respool-trace ()
9650 "Trace where the respool algorithm would put this article.
9651 Display a buffer showing all fancy splitting patterns which matched."
9653 (gnus-summary-respool-query nil t))
9655 ;; Summary marking commands.
9657 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9658 "Mark articles which has the same subject as read, and then select the next.
9659 If UNMARK is positive, remove any kind of mark.
9660 If UNMARK is negative, tick articles."
9663 (setq unmark (prefix-numeric-value unmark)))
9665 (gnus-summary-mark-same-subject
9666 (gnus-summary-article-subject) unmark)))
9667 ;; Select next unread article. If auto-select-same mode, should
9668 ;; select the first unread article.
9669 (gnus-summary-next-article t (and gnus-auto-select-same
9670 (gnus-summary-article-subject)))
9671 (gnus-message 7 "%d article%s marked as %s"
9672 count (if (= count 1) " is" "s are")
9673 (if unmark "unread" "read"))))
9675 (defun gnus-summary-kill-same-subject (&optional unmark)
9676 "Mark articles which has the same subject as read.
9677 If UNMARK is positive, remove any kind of mark.
9678 If UNMARK is negative, tick articles."
9681 (setq unmark (prefix-numeric-value unmark)))
9683 (gnus-summary-mark-same-subject
9684 (gnus-summary-article-subject) unmark)))
9685 ;; If marked as read, go to next unread subject.
9687 ;; Go to next unread subject.
9688 (gnus-summary-next-subject 1 t))
9689 (gnus-message 7 "%d articles are marked as %s"
9690 count (if unmark "unread" "read"))))
9692 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9693 "Mark articles with same SUBJECT as read, and return marked number.
9694 If optional argument UNMARK is positive, remove any kinds of marks.
9695 If optional argument UNMARK is negative, mark articles as unread instead."
9699 ((null unmark) ; Mark as read.
9702 (gnus-summary-mark-article-as-read gnus-killed-mark)
9703 (gnus-summary-show-thread) t)
9704 (gnus-summary-find-subject subject))
9705 (setq count (1+ count))))
9706 ((> unmark 0) ; Tick.
9709 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9710 (gnus-summary-show-thread) t)
9711 (gnus-summary-find-subject subject))
9712 (setq count (1+ count))))
9713 (t ; Mark as unread.
9716 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9717 (gnus-summary-show-thread) t)
9718 (gnus-summary-find-subject subject))
9719 (setq count (1+ count)))))
9720 (gnus-set-mode-line 'summary)
9721 ;; Return the number of marked articles.
9724 (defun gnus-summary-mark-as-processable (n &optional unmark)
9725 "Set the process mark on the next N articles.
9726 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9727 the process mark instead. The difference between N and the actual
9728 number of articles marked is returned."
9730 (if (and (null n) (gnus-region-active-p))
9731 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9732 (setq n (prefix-numeric-value n))
9733 (let ((backward (< n 0))
9738 (gnus-summary-remove-process-mark
9739 (gnus-summary-article-number))
9740 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9741 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9744 (gnus-message 7 "No more articles"))
9745 (gnus-summary-recenter)
9746 (gnus-summary-position-point)
9749 (defun gnus-summary-unmark-as-processable (n)
9750 "Remove the process mark from the next N articles.
9751 If N is negative, unmark backward instead. The difference between N and
9752 the actual number of articles unmarked is returned."
9754 (gnus-summary-mark-as-processable n t))
9756 (defun gnus-summary-unmark-all-processable ()
9757 "Remove the process mark from all articles."
9760 (while gnus-newsgroup-processable
9761 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9762 (gnus-summary-position-point))
9764 (defun gnus-summary-add-mark (article type)
9765 "Mark ARTICLE with a mark of TYPE."
9766 (let ((vtype (car (assq type gnus-article-mark-lists)))
9769 (error "No such mark type: %s" type)
9770 (setq var (intern (format "gnus-newsgroup-%s" type)))
9771 (set var (cons article (symbol-value var)))
9772 (if (memq type '(processable cached replied forwarded recent saved))
9773 (gnus-summary-update-secondary-mark article)
9774 ;;; !!! This is bogus. We should find out what primary
9775 ;;; !!! mark we want to set.
9776 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9778 (defun gnus-summary-mark-as-expirable (n)
9779 "Mark N articles forward as expirable.
9780 If N is negative, mark backward instead. The difference between N and
9781 the actual number of articles marked is returned."
9783 (gnus-summary-mark-forward n gnus-expirable-mark))
9785 (defun gnus-summary-mark-as-spam (n)
9786 "Mark N articles forward as spam.
9787 If N is negative, mark backward instead. The difference between N and
9788 the actual number of articles marked is returned."
9790 (gnus-summary-mark-forward n gnus-spam-mark))
9792 (defun gnus-summary-mark-article-as-replied (article)
9793 "Mark ARTICLE as replied to and update the summary line.
9794 ARTICLE can also be a list of articles."
9795 (interactive (list (gnus-summary-article-number)))
9796 (let ((articles (if (listp article) article (list article))))
9797 (dolist (article articles)
9798 (unless (numberp article)
9799 (error "%s is not a number" article))
9800 (push article gnus-newsgroup-replied)
9801 (let ((buffer-read-only nil))
9802 (when (gnus-summary-goto-subject article nil t)
9803 (gnus-summary-update-secondary-mark article))))))
9805 (defun gnus-summary-mark-article-as-forwarded (article)
9806 "Mark ARTICLE as forwarded and update the summary line.
9807 ARTICLE can also be a list of articles."
9808 (let ((articles (if (listp article) article (list article))))
9809 (dolist (article articles)
9810 (push article gnus-newsgroup-forwarded)
9811 (let ((buffer-read-only nil))
9812 (when (gnus-summary-goto-subject article nil t)
9813 (gnus-summary-update-secondary-mark article))))))
9815 (defun gnus-summary-set-bookmark (article)
9816 "Set a bookmark in current article."
9817 (interactive (list (gnus-summary-article-number)))
9818 (when (or (not (get-buffer gnus-article-buffer))
9819 (not gnus-current-article)
9820 (not gnus-article-current)
9821 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9822 (error "No current article selected"))
9823 ;; Remove old bookmark, if one exists.
9824 (gnus-pull article gnus-newsgroup-bookmarks)
9825 ;; Set the new bookmark, which is on the form
9826 ;; (article-number . line-number-in-body).
9830 (set-buffer gnus-article-buffer)
9837 gnus-newsgroup-bookmarks)
9838 (gnus-message 6 "A bookmark has been added to the current article."))
9840 (defun gnus-summary-remove-bookmark (article)
9841 "Remove the bookmark from the current article."
9842 (interactive (list (gnus-summary-article-number)))
9843 ;; Remove old bookmark, if one exists.
9844 (if (not (assq article gnus-newsgroup-bookmarks))
9845 (gnus-message 6 "No bookmark in current article.")
9846 (gnus-pull article gnus-newsgroup-bookmarks)
9847 (gnus-message 6 "Removed bookmark.")))
9849 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9850 (defun gnus-summary-mark-as-dormant (n)
9851 "Mark N articles forward as dormant.
9852 If N is negative, mark backward instead. The difference between N and
9853 the actual number of articles marked is returned."
9855 (gnus-summary-mark-forward n gnus-dormant-mark))
9857 (defun gnus-summary-set-process-mark (article)
9858 "Set the process mark on ARTICLE and update the summary line."
9859 (setq gnus-newsgroup-processable
9861 (delq article gnus-newsgroup-processable)))
9862 (when (gnus-summary-goto-subject article)
9863 (gnus-summary-show-thread)
9864 (gnus-summary-goto-subject article)
9865 (gnus-summary-update-secondary-mark article)))
9867 (defun gnus-summary-remove-process-mark (article)
9868 "Remove the process mark from ARTICLE and update the summary line."
9869 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9870 (when (gnus-summary-goto-subject article)
9871 (gnus-summary-show-thread)
9872 (gnus-summary-goto-subject article)
9873 (gnus-summary-update-secondary-mark article)))
9875 (defun gnus-summary-set-saved-mark (article)
9876 "Set the process mark on ARTICLE and update the summary line."
9877 (push article gnus-newsgroup-saved)
9878 (when (gnus-summary-goto-subject article)
9879 (gnus-summary-update-secondary-mark article)))
9881 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9882 "Mark N articles as read forwards.
9883 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9884 The difference between N and the actual number of articles marked is
9886 If NO-EXPIRE, auto-expiry will be inhibited."
9888 (gnus-summary-show-thread)
9889 (let ((backward (< n 0))
9890 (gnus-summary-goto-unread
9891 (and gnus-summary-goto-unread
9892 (not (eq gnus-summary-goto-unread 'never))
9893 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9894 gnus-ticked-mark gnus-dormant-mark)))))
9896 (mark (or mark gnus-del-mark)))
9898 (gnus-summary-mark-article nil mark no-expire)
9899 (zerop (gnus-summary-next-subject
9901 (and gnus-summary-goto-unread
9902 (not (eq gnus-summary-goto-unread 'never)))
9906 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9907 (gnus-summary-recenter)
9908 (gnus-summary-position-point)
9909 (gnus-set-mode-line 'summary)
9912 (defun gnus-summary-mark-article-as-read (mark)
9913 "Mark the current article quickly as read with MARK."
9914 (let ((article (gnus-summary-article-number)))
9915 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9916 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9917 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9918 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9919 (push (cons article mark) gnus-newsgroup-reads)
9920 ;; Possibly remove from cache, if that is used.
9921 (when gnus-use-cache
9922 (gnus-cache-enter-remove-article article))
9923 ;; Allow the backend to change the mark.
9924 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9925 ;; Check for auto-expiry.
9926 (when (and gnus-newsgroup-auto-expire
9927 (memq mark gnus-auto-expirable-marks))
9928 (setq mark gnus-expirable-mark)
9929 ;; Let the backend know about the mark change.
9930 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9931 (push article gnus-newsgroup-expirable))
9932 ;; Set the mark in the buffer.
9933 (gnus-summary-update-mark mark 'unread)
9936 (defun gnus-summary-mark-article-as-unread (mark)
9937 "Mark the current article quickly as unread with MARK."
9938 (let* ((article (gnus-summary-article-number))
9939 (old-mark (gnus-summary-article-mark article)))
9940 ;; Allow the backend to change the mark.
9941 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9942 (if (eq mark old-mark)
9946 (gnus-error 1 "Can't mark negative article numbers")
9948 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9949 (setq gnus-newsgroup-spam-marked
9950 (delq article gnus-newsgroup-spam-marked))
9951 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9952 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9953 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9954 (cond ((= mark gnus-ticked-mark)
9955 (setq gnus-newsgroup-marked
9956 (gnus-add-to-sorted-list gnus-newsgroup-marked
9958 ((= mark gnus-spam-mark)
9959 (setq gnus-newsgroup-spam-marked
9960 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9962 ((= mark gnus-dormant-mark)
9963 (setq gnus-newsgroup-dormant
9964 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9967 (setq gnus-newsgroup-unreads
9968 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9970 (gnus-pull article gnus-newsgroup-reads)
9972 ;; See whether the article is to be put in the cache.
9974 (vectorp (gnus-summary-article-header article))
9976 (gnus-cache-possibly-enter-article
9977 gnus-newsgroup-name article
9978 (gnus-summary-article-header article)
9979 (= mark gnus-ticked-mark)
9980 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9983 (gnus-summary-update-mark mark 'unread)
9986 (defun gnus-summary-mark-article (&optional article mark no-expire)
9987 "Mark ARTICLE with MARK. MARK can be any character.
9988 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9989 `??' (dormant) and `?E' (expirable).
9990 If MARK is nil, then the default character `?r' is used.
9991 If ARTICLE is nil, then the article on the current line will be
9993 If NO-EXPIRE, auto-expiry will be inhibited."
9994 ;; The mark might be a string.
9995 (when (stringp mark)
9996 (setq mark (aref mark 0)))
9997 ;; If no mark is given, then we check auto-expiring.
9999 (setq mark gnus-del-mark))
10000 (when (and (not no-expire)
10001 gnus-newsgroup-auto-expire
10002 (memq mark gnus-auto-expirable-marks))
10003 (setq mark gnus-expirable-mark))
10004 (let ((article (or article (gnus-summary-article-number)))
10005 (old-mark (gnus-summary-article-mark article)))
10006 ;; Allow the backend to change the mark.
10007 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10008 (if (eq mark old-mark)
10011 (error "No article on current line"))
10012 (if (not (if (or (= mark gnus-unread-mark)
10013 (= mark gnus-ticked-mark)
10014 (= mark gnus-spam-mark)
10015 (= mark gnus-dormant-mark))
10016 (gnus-mark-article-as-unread article mark)
10017 (gnus-mark-article-as-read article mark)))
10019 ;; See whether the article is to be put in the cache.
10020 (and gnus-use-cache
10021 (not (= mark gnus-canceled-mark))
10022 (vectorp (gnus-summary-article-header article))
10024 (gnus-cache-possibly-enter-article
10025 gnus-newsgroup-name article
10026 (gnus-summary-article-header article)
10027 (= mark gnus-ticked-mark)
10028 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10030 (when (gnus-summary-goto-subject article nil t)
10031 (let ((buffer-read-only nil))
10032 (gnus-summary-show-thread)
10034 (gnus-summary-update-mark mark 'unread)
10037 (defun gnus-summary-update-secondary-mark (article)
10038 "Update the secondary (read, process, cache) mark."
10039 (gnus-summary-update-mark
10040 (cond ((memq article gnus-newsgroup-processable)
10042 ((memq article gnus-newsgroup-cached)
10044 ((memq article gnus-newsgroup-replied)
10046 ((memq article gnus-newsgroup-forwarded)
10047 gnus-forwarded-mark)
10048 ((memq article gnus-newsgroup-saved)
10050 ((memq article gnus-newsgroup-recent)
10052 ((memq article gnus-newsgroup-unseen)
10056 (when (gnus-visual-p 'summary-highlight 'highlight)
10057 (gnus-run-hooks 'gnus-summary-update-hook))
10060 (defun gnus-summary-update-download-mark (article)
10061 "Update the download mark."
10062 (gnus-summary-update-mark
10063 (cond ((memq article gnus-newsgroup-undownloaded)
10064 gnus-undownloaded-mark)
10065 (gnus-newsgroup-agentized
10066 gnus-downloaded-mark)
10070 (gnus-summary-update-line t)
10073 (defun gnus-summary-update-mark (mark type)
10074 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10075 (buffer-read-only nil))
10076 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10078 (when (looking-at "\r")
10080 (when (<= (+ forward (point)) (point-max))
10081 ;; Go to the right position on the line.
10082 (goto-char (+ forward (point)))
10083 ;; Replace the old mark with the new mark.
10084 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10085 ;; Optionally update the marks by some user rule.
10086 (when (eq type 'unread)
10087 (gnus-data-set-mark
10088 (gnus-data-find (gnus-summary-article-number)) mark)
10089 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10091 (defun gnus-mark-article-as-read (article &optional mark)
10092 "Enter ARTICLE in the pertinent lists and remove it from others."
10093 ;; Make the article expirable.
10094 (let ((mark (or mark gnus-del-mark)))
10095 (setq gnus-newsgroup-expirable
10096 (if (= mark gnus-expirable-mark)
10097 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10098 (delq article gnus-newsgroup-expirable)))
10099 ;; Remove from unread and marked lists.
10100 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10101 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10102 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10103 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10104 (push (cons article mark) gnus-newsgroup-reads)
10105 ;; Possibly remove from cache, if that is used.
10106 (when gnus-use-cache
10107 (gnus-cache-enter-remove-article article))
10110 (defun gnus-mark-article-as-unread (article &optional mark)
10111 "Enter ARTICLE in the pertinent lists and remove it from others."
10112 (let ((mark (or mark gnus-ticked-mark)))
10115 (gnus-error 1 "Can't mark negative article numbers")
10117 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10118 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10119 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10120 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10121 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10123 ;; Unsuppress duplicates?
10124 (when gnus-suppress-duplicates
10125 (gnus-dup-unsuppress-article article))
10127 (cond ((= mark gnus-ticked-mark)
10128 (setq gnus-newsgroup-marked
10129 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10130 ((= mark gnus-spam-mark)
10131 (setq gnus-newsgroup-spam-marked
10132 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10134 ((= mark gnus-dormant-mark)
10135 (setq gnus-newsgroup-dormant
10136 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10138 (setq gnus-newsgroup-unreads
10139 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10140 (gnus-pull article gnus-newsgroup-reads)
10143 (defalias 'gnus-summary-mark-as-unread-forward
10144 'gnus-summary-tick-article-forward)
10145 (make-obsolete 'gnus-summary-mark-as-unread-forward
10146 'gnus-summary-tick-article-forward)
10147 (defun gnus-summary-tick-article-forward (n)
10148 "Tick N articles forwards.
10149 If N is negative, tick backwards instead.
10150 The difference between N and the number of articles ticked is returned."
10152 (gnus-summary-mark-forward n gnus-ticked-mark))
10154 (defalias 'gnus-summary-mark-as-unread-backward
10155 'gnus-summary-tick-article-backward)
10156 (make-obsolete 'gnus-summary-mark-as-unread-backward
10157 'gnus-summary-tick-article-backward)
10158 (defun gnus-summary-tick-article-backward (n)
10159 "Tick N articles backwards.
10160 The difference between N and the number of articles ticked is returned."
10162 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10164 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10165 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10166 (defun gnus-summary-tick-article (&optional article clear-mark)
10167 "Mark current article as unread.
10168 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10169 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10171 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10172 gnus-ticked-mark)))
10174 (defun gnus-summary-mark-as-read-forward (n)
10175 "Mark N articles as read forwards.
10176 If N is negative, mark backwards instead.
10177 The difference between N and the actual number of articles marked is
10180 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10182 (defun gnus-summary-mark-as-read-backward (n)
10183 "Mark the N articles as read backwards.
10184 The difference between N and the actual number of articles marked is
10187 (gnus-summary-mark-forward
10188 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10190 (defun gnus-summary-mark-as-read (&optional article mark)
10191 "Mark current article as read.
10192 ARTICLE specifies the article to be marked as read.
10193 MARK specifies a string to be inserted at the beginning of the line."
10194 (gnus-summary-mark-article article mark))
10196 (defun gnus-summary-clear-mark-forward (n)
10197 "Clear marks from N articles forward.
10198 If N is negative, clear backward instead.
10199 The difference between N and the number of marks cleared is returned."
10201 (gnus-summary-mark-forward n gnus-unread-mark))
10203 (defun gnus-summary-clear-mark-backward (n)
10204 "Clear marks from N articles backward.
10205 The difference between N and the number of marks cleared is returned."
10207 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10209 (defun gnus-summary-mark-unread-as-read ()
10210 "Intended to be used by `gnus-summary-mark-article-hook'."
10211 (when (memq gnus-current-article gnus-newsgroup-unreads)
10212 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10214 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10215 "Intended to be used by `gnus-summary-mark-article-hook'."
10216 (let ((mark (gnus-summary-article-mark)))
10217 (when (or (gnus-unread-mark-p mark)
10218 (gnus-read-mark-p mark))
10219 (gnus-summary-mark-article gnus-current-article
10220 (or new-mark gnus-read-mark)))))
10222 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10223 "Intended to be used by `gnus-summary-mark-article-hook'."
10224 (let ((mark (gnus-summary-article-mark)))
10225 (when (or (gnus-unread-mark-p mark)
10226 (gnus-read-mark-p mark))
10227 (gnus-summary-mark-article (gnus-summary-article-number)
10228 (or new-mark gnus-read-mark)))))
10230 (defun gnus-summary-mark-unread-as-ticked ()
10231 "Intended to be used by `gnus-summary-mark-article-hook'."
10232 (when (memq gnus-current-article gnus-newsgroup-unreads)
10233 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10235 (defun gnus-summary-mark-region-as-read (point mark all)
10236 "Mark all unread articles between point and mark as read.
10237 If given a prefix, mark all articles between point and mark as read,
10238 even ticked and dormant ones."
10239 (interactive "r\nP")
10243 (beginning-of-line)
10248 (memq (setq article (gnus-summary-article-number))
10249 gnus-newsgroup-unreads))
10250 (gnus-summary-mark-article article gnus-del-mark))
10252 (gnus-summary-find-next))))))
10254 (defun gnus-summary-mark-below (score mark)
10255 "Mark articles with score less than SCORE with MARK."
10256 (interactive "P\ncMark: ")
10257 (setq score (if score
10258 (prefix-numeric-value score)
10259 (or gnus-summary-default-score 0)))
10261 (set-buffer gnus-summary-buffer)
10262 (goto-char (point-min))
10265 (and (< (gnus-summary-article-score) score)
10266 (gnus-summary-mark-article nil mark))
10267 (gnus-summary-find-next)))))
10269 (defun gnus-summary-kill-below (&optional score)
10270 "Mark articles with score below SCORE as read."
10272 (gnus-summary-mark-below score gnus-killed-mark))
10274 (defun gnus-summary-clear-above (&optional score)
10275 "Clear all marks from articles with score above SCORE."
10277 (gnus-summary-mark-above score gnus-unread-mark))
10279 (defun gnus-summary-tick-above (&optional score)
10280 "Tick all articles with score above SCORE."
10282 (gnus-summary-mark-above score gnus-ticked-mark))
10284 (defun gnus-summary-mark-above (score mark)
10285 "Mark articles with score over SCORE with MARK."
10286 (interactive "P\ncMark: ")
10287 (setq score (if score
10288 (prefix-numeric-value score)
10289 (or gnus-summary-default-score 0)))
10291 (set-buffer gnus-summary-buffer)
10292 (goto-char (point-min))
10294 (when (> (gnus-summary-article-score) score)
10295 (gnus-summary-mark-article nil mark))
10297 (gnus-summary-find-next)))))
10299 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10300 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10301 (defun gnus-summary-limit-include-expunged (&optional no-error)
10302 "Display all the hidden articles that were expunged for low scores."
10304 (let ((buffer-read-only nil))
10305 (let ((scored gnus-newsgroup-scored)
10308 (unless (gnus-summary-article-header (caar scored))
10309 (and (setq h (gnus-number-to-header (caar scored)))
10310 (< (cdar scored) gnus-summary-expunge-below)
10312 (setq scored (cdr scored)))
10314 (when (not no-error)
10315 (error "No expunged articles hidden"))
10316 (goto-char (point-min))
10317 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10318 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10319 (mapcar (lambda (x) (push (mail-header-number x)
10320 gnus-newsgroup-limit))
10322 (gnus-summary-prepare-unthreaded (nreverse headers))
10323 (goto-char (point-min))
10324 (gnus-summary-position-point)
10327 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10328 "Mark all unread articles in this newsgroup as read.
10329 If prefix argument ALL is non-nil, ticked and dormant articles will
10330 also be marked as read.
10331 If QUIETLY is non-nil, no questions will be asked.
10333 If TO-HERE is non-nil, it should be a point in the buffer. All
10334 articles before (after, if REVERSE is set) this point will be marked
10337 Note that this function will only catch up the unread article
10338 in the current summary buffer limitation.
10340 The number of articles marked as read is returned."
10345 (not gnus-interactive-catchup) ;Without confirmation?
10349 "Mark absolutely all articles as read? "
10350 "Mark all unread articles as read? ")))
10352 (not gnus-newsgroup-adaptive)
10353 (not gnus-newsgroup-auto-expire)
10354 (not gnus-suppress-duplicates)
10355 (or (not gnus-use-cache)
10356 (eq gnus-use-cache 'passive)))
10359 (setq gnus-newsgroup-marked nil
10360 gnus-newsgroup-spam-marked nil
10361 gnus-newsgroup-dormant nil))
10362 (setq gnus-newsgroup-unreads
10363 (gnus-sorted-nunion
10364 (gnus-intersection gnus-newsgroup-unreads
10365 gnus-newsgroup-downloadable)
10366 gnus-newsgroup-unfetched)))
10367 ;; We actually mark all articles as canceled, which we
10368 ;; have to do when using auto-expiry or adaptive scoring.
10369 (gnus-summary-show-all-threads)
10370 (if (and to-here reverse)
10372 (goto-char to-here)
10373 (gnus-summary-mark-current-read-and-unread-as-read
10375 (while (gnus-summary-find-next (not all))
10376 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10377 (when (gnus-summary-first-subject (not all))
10379 (if to-here (< (point) to-here) t)
10380 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10381 (gnus-summary-find-next (not all))))))
10382 (gnus-set-mode-line 'summary))
10384 (gnus-summary-position-point)))
10386 (defun gnus-summary-catchup-to-here (&optional all)
10387 "Mark all unticked articles before the current one as read.
10388 If ALL is non-nil, also mark ticked and dormant articles as read."
10391 (gnus-save-hidden-threads
10392 (let ((beg (point)))
10393 ;; We check that there are unread articles.
10394 (when (or all (gnus-summary-find-prev))
10395 (gnus-summary-catchup all t beg)))))
10396 (gnus-summary-position-point))
10398 (defun gnus-summary-catchup-from-here (&optional all)
10399 "Mark all unticked articles after (and including) the current one as read.
10400 If ALL is non-nil, also mark ticked and dormant articles as read."
10403 (gnus-save-hidden-threads
10404 (let ((beg (point)))
10405 ;; We check that there are unread articles.
10406 (when (or all (gnus-summary-find-next))
10407 (gnus-summary-catchup all t beg nil t)))))
10408 (gnus-summary-position-point))
10410 (defun gnus-summary-catchup-all (&optional quietly)
10411 "Mark all articles in this newsgroup as read.
10412 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10413 instead, which marks only unread articles as read."
10415 (gnus-summary-catchup t quietly))
10417 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10418 "Mark all unread articles in this group as read, then exit.
10419 If prefix argument ALL is non-nil, all articles are marked as read.
10420 If QUIETLY is non-nil, no questions will be asked."
10422 (when (gnus-summary-catchup all quietly nil 'fast)
10423 ;; Select next newsgroup or exit.
10424 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10425 (eq gnus-auto-select-next 'quietly))
10426 (gnus-summary-next-group nil)
10427 (gnus-summary-exit))))
10429 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10430 "Mark all articles in this newsgroup as read, and then exit.
10431 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10432 instead, which marks only unread articles as read."
10434 (gnus-summary-catchup-and-exit t quietly))
10436 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10437 "Mark all articles in this group as read and select the next group.
10438 If given a prefix, mark all articles, unread as well as ticked, as
10442 (gnus-summary-catchup all))
10443 (gnus-summary-next-group))
10449 (defmacro gnus-with-article (article &rest forms)
10450 "Select ARTICLE and perform FORMS in the original article buffer.
10451 Then replace the article with the result."
10453 ;; We don't want the article to be marked as read.
10454 (let (gnus-mark-article-hook)
10455 (gnus-summary-select-article t t nil ,article))
10456 (set-buffer gnus-original-article-buffer)
10458 (if (not (gnus-check-backend-function
10459 'request-replace-article (car gnus-article-current)))
10460 (gnus-message 5 "Read-only group; not replacing")
10461 (unless (gnus-request-replace-article
10462 ,article (car gnus-article-current)
10463 (current-buffer) t)
10464 (error "Couldn't replace article")))
10465 ;; The cache and backlog have to be flushed somewhat.
10466 (when gnus-keep-backlog
10467 (gnus-backlog-remove-article
10468 (car gnus-article-current) (cdr gnus-article-current)))
10469 (when gnus-use-cache
10470 (gnus-cache-update-article
10471 (car gnus-article-current) (cdr gnus-article-current)))))
10473 (put 'gnus-with-article 'lisp-indent-function 1)
10474 (put 'gnus-with-article 'edebug-form-spec '(form body))
10476 ;; Thread-based commands.
10478 (defun gnus-summary-articles-in-thread (&optional article)
10479 "Return a list of all articles in the current thread.
10480 If ARTICLE is non-nil, return all articles in the thread that starts
10481 with that article."
10482 (let* ((article (or article (gnus-summary-article-number)))
10483 (data (gnus-data-find-list article))
10484 (top-level (gnus-data-level (car data)))
10486 (cond ((null gnus-thread-operation-ignore-subject)
10487 (gnus-simplify-subject-re
10488 (mail-header-subject (gnus-data-header (car data)))))
10489 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10490 (gnus-simplify-subject-fuzzy
10491 (mail-header-subject (gnus-data-header (car data)))))
10493 (end-point (save-excursion
10494 (if (gnus-summary-go-to-next-thread)
10495 (point) (point-max))))
10498 (< (gnus-data-pos (car data)) end-point))
10499 (when (or (not top-subject)
10500 (string= top-subject
10501 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10502 (gnus-simplify-subject-fuzzy
10503 (mail-header-subject
10504 (gnus-data-header (car data))))
10505 (gnus-simplify-subject-re
10506 (mail-header-subject
10507 (gnus-data-header (car data)))))))
10508 (push (gnus-data-number (car data)) articles))
10509 (unless (and (setq data (cdr data))
10510 (> (gnus-data-level (car data)) top-level))
10512 ;; Return the list of articles.
10513 (nreverse articles)))
10515 (defun gnus-summary-rethread-current ()
10516 "Rethread the thread the current article is part of."
10518 (let* ((gnus-show-threads t)
10519 (article (gnus-summary-article-number))
10520 (id (mail-header-id (gnus-summary-article-header)))
10521 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10523 (error "No article on the current line"))
10524 (gnus-rebuild-thread id)
10525 (gnus-summary-goto-subject article)))
10527 (defun gnus-summary-reparent-thread ()
10528 "Make the current article child of the marked (or previous) article.
10530 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10531 is non-nil or the Subject: of both articles are the same."
10533 (unless (not (gnus-group-read-only-p))
10534 (error "The current newsgroup does not support article editing"))
10535 (unless (<= (length gnus-newsgroup-processable) 1)
10536 (error "No more than one article may be marked"))
10537 (save-window-excursion
10538 (let ((gnus-article-buffer " *reparent*")
10539 (current-article (gnus-summary-article-number))
10540 ;; First grab the marked article, otherwise one line up.
10541 (parent-article (if (not (null gnus-newsgroup-processable))
10542 (car gnus-newsgroup-processable)
10544 (if (eq (forward-line -1) 0)
10545 (gnus-summary-article-number)
10546 (error "Beginning of summary buffer"))))))
10547 (unless (not (eq current-article parent-article))
10548 (error "An article may not be self-referential"))
10549 (let ((message-id (mail-header-id
10550 (gnus-summary-article-header parent-article))))
10551 (unless (and message-id (not (equal message-id "")))
10552 (error "No message-id in desired parent"))
10553 (gnus-with-article current-article
10555 (goto-char (point-min))
10556 (message-narrow-to-head)
10557 (if (re-search-forward "^References: " nil t)
10559 (re-search-forward "^[^ \t]" nil t)
10562 (insert " " message-id))
10563 (insert "References: " message-id "\n"))))
10564 (set-buffer gnus-summary-buffer)
10565 (gnus-summary-unmark-all-processable)
10566 (gnus-summary-update-article current-article)
10567 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10568 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10569 (gnus-summary-rethread-current)
10570 (gnus-message 3 "Article %d is now the child of article %d"
10571 current-article parent-article)))))
10573 (defun gnus-summary-toggle-threads (&optional arg)
10574 "Toggle showing conversation threads.
10575 If ARG is positive number, turn showing conversation threads on."
10577 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10578 (setq gnus-show-threads
10579 (if (null arg) (not gnus-show-threads)
10580 (> (prefix-numeric-value arg) 0)))
10581 (gnus-summary-prepare)
10582 (gnus-summary-goto-subject current)
10583 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10584 (gnus-summary-position-point)))
10586 (defun gnus-summary-show-all-threads ()
10587 "Show all threads."
10590 (let ((buffer-read-only nil))
10591 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10592 (gnus-summary-position-point))
10594 (defun gnus-summary-show-thread ()
10595 "Show thread subtrees.
10596 Returns nil if no thread was there to be shown."
10598 (let ((buffer-read-only nil)
10600 (end (point-at-eol))
10601 ;; Leave point at bol
10602 (beg (progn (beginning-of-line) (point))))
10604 ;; Any hidden lines here?
10605 (search-forward "\r" end t)
10606 (subst-char-in-region beg end ?\^M ?\n t)
10608 (gnus-summary-position-point))))
10610 (defun gnus-summary-maybe-hide-threads ()
10611 "If requested, hide the threads that should be hidden."
10612 (when (and gnus-show-threads
10613 gnus-thread-hide-subtree)
10614 (gnus-summary-hide-all-threads
10615 (if (or (consp gnus-thread-hide-subtree)
10616 (functionp gnus-thread-hide-subtree))
10617 (gnus-make-predicate gnus-thread-hide-subtree)
10620 ;;; Hiding predicates.
10622 (defun gnus-article-unread-p (header)
10623 (memq (mail-header-number header) gnus-newsgroup-unreads))
10625 (defun gnus-article-unseen-p (header)
10626 (memq (mail-header-number header) gnus-newsgroup-unseen))
10628 (defun gnus-map-articles (predicate articles)
10629 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10630 (apply 'gnus-or (mapcar predicate
10631 (mapcar 'gnus-summary-article-header articles))))
10633 (defun gnus-summary-hide-all-threads (&optional predicate)
10634 "Hide all thread subtrees.
10635 If PREDICATE is supplied, threads that satisfy this predicate
10636 will not be hidden."
10639 (goto-char (point-min))
10642 (when (or (not predicate)
10644 predicate (gnus-summary-article-children)))
10645 (gnus-summary-hide-thread))
10646 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10647 (gnus-summary-position-point))
10649 (defun gnus-summary-hide-thread ()
10650 "Hide thread subtrees.
10651 If PREDICATE is supplied, threads that satisfy this predicate
10652 will not be hidden.
10653 Returns nil if no threads were there to be hidden."
10655 (let ((buffer-read-only nil)
10657 (article (gnus-summary-article-number)))
10659 ;; Go forward until either the buffer ends or the subthread
10661 (when (and (not (eobp))
10662 (or (zerop (gnus-summary-next-thread 1 t))
10663 (goto-char (point-max))))
10665 (if (and (> (point) start)
10666 (search-backward "\n" start t))
10668 (subst-char-in-region start (point) ?\n ?\^M)
10669 (gnus-summary-goto-subject article))
10673 (defun gnus-summary-go-to-next-thread (&optional previous)
10674 "Go to the same level (or less) next thread.
10675 If PREVIOUS is non-nil, go to previous thread instead.
10676 Return the article number moved to, or nil if moving was impossible."
10677 (let ((level (gnus-summary-thread-level))
10678 (way (if previous -1 1))
10681 (while (and (not (eobp))
10682 (< level (gnus-summary-thread-level)))
10683 (forward-line way))
10690 (gnus-summary-article-number)
10691 (goto-char beg)))))
10693 (defun gnus-summary-next-thread (n &optional silent)
10694 "Go to the same level next N'th thread.
10695 If N is negative, search backward instead.
10696 Returns the difference between N and the number of skips actually
10699 If SILENT, don't output messages."
10701 (let ((backward (< n 0))
10703 (while (and (> n 0)
10704 (gnus-summary-go-to-next-thread backward))
10707 (gnus-summary-position-point))
10708 (when (and (not silent) (/= 0 n))
10709 (gnus-message 7 "No more threads"))
10712 (defun gnus-summary-prev-thread (n)
10713 "Go to the same level previous N'th thread.
10714 Returns the difference between N and the number of skips actually
10717 (gnus-summary-next-thread (- n)))
10719 (defun gnus-summary-go-down-thread ()
10720 "Go down one level in the current thread."
10721 (let ((children (gnus-summary-article-children)))
10723 (gnus-summary-goto-subject (car children)))))
10725 (defun gnus-summary-go-up-thread ()
10726 "Go up one level in the current thread."
10727 (let ((parent (gnus-summary-article-parent)))
10729 (gnus-summary-goto-subject parent))))
10731 (defun gnus-summary-down-thread (n)
10732 "Go down thread N steps.
10733 If N is negative, go up instead.
10734 Returns the difference between N and how many steps down that were
10739 (while (and (> n 0)
10740 (if up (gnus-summary-go-up-thread)
10741 (gnus-summary-go-down-thread)))
10743 (gnus-summary-position-point)
10745 (gnus-message 7 "Can't go further"))
10748 (defun gnus-summary-up-thread (n)
10749 "Go up thread N steps.
10750 If N is negative, go down instead.
10751 Returns the difference between N and how many steps down that were
10754 (gnus-summary-down-thread (- n)))
10756 (defun gnus-summary-top-thread ()
10757 "Go to the top of the thread."
10759 (while (gnus-summary-go-up-thread))
10760 (gnus-summary-article-number))
10762 (defun gnus-summary-kill-thread (&optional unmark)
10763 "Mark articles under current thread as read.
10764 If the prefix argument is positive, remove any kinds of marks.
10765 If the prefix argument is negative, tick articles instead."
10768 (setq unmark (prefix-numeric-value unmark)))
10769 (let ((articles (gnus-summary-articles-in-thread)))
10771 ;; Expand the thread.
10772 (gnus-summary-show-thread)
10773 ;; Mark all the articles.
10775 (gnus-summary-goto-subject (car articles))
10776 (cond ((null unmark)
10777 (gnus-summary-mark-article-as-read gnus-killed-mark))
10779 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10781 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10782 (setq articles (cdr articles))))
10783 ;; Hide killed subtrees.
10785 gnus-thread-hide-killed
10786 (gnus-summary-hide-thread))
10787 ;; If marked as read, go to next unread subject.
10788 (when (null unmark)
10789 ;; Go to next unread subject.
10790 (gnus-summary-next-subject 1 t)))
10791 (gnus-set-mode-line 'summary))
10793 ;; Summary sorting commands
10795 (defun gnus-summary-sort-by-number (&optional reverse)
10796 "Sort the summary buffer by article number.
10797 Argument REVERSE means reverse order."
10799 (gnus-summary-sort 'number reverse))
10801 (defun gnus-summary-sort-by-random (&optional reverse)
10802 "Randomize the order in the summary buffer.
10803 Argument REVERSE means to randomize in reverse order."
10805 (gnus-summary-sort 'random reverse))
10807 (defun gnus-summary-sort-by-author (&optional reverse)
10808 "Sort the summary buffer by author name alphabetically.
10809 If `case-fold-search' is non-nil, case of letters is ignored.
10810 Argument REVERSE means reverse order."
10812 (gnus-summary-sort 'author reverse))
10814 (defun gnus-summary-sort-by-subject (&optional reverse)
10815 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10816 If `case-fold-search' is non-nil, case of letters is ignored.
10817 Argument REVERSE means reverse order."
10819 (gnus-summary-sort 'subject reverse))
10821 (defun gnus-summary-sort-by-date (&optional reverse)
10822 "Sort the summary buffer by date.
10823 Argument REVERSE means reverse order."
10825 (gnus-summary-sort 'date reverse))
10827 (defun gnus-summary-sort-by-score (&optional reverse)
10828 "Sort the summary buffer by score.
10829 Argument REVERSE means reverse order."
10831 (gnus-summary-sort 'score reverse))
10833 (defun gnus-summary-sort-by-lines (&optional reverse)
10834 "Sort the summary buffer by the number of lines.
10835 Argument REVERSE means reverse order."
10837 (gnus-summary-sort 'lines reverse))
10839 (defun gnus-summary-sort-by-chars (&optional reverse)
10840 "Sort the summary buffer by article length.
10841 Argument REVERSE means reverse order."
10843 (gnus-summary-sort 'chars reverse))
10845 (defun gnus-summary-sort-by-original (&optional reverse)
10846 "Sort the summary buffer using the default sorting method.
10847 Argument REVERSE means reverse order."
10849 (let* ((buffer-read-only)
10850 (gnus-summary-prepare-hook nil))
10851 ;; We do the sorting by regenerating the threads.
10852 (gnus-summary-prepare)
10853 ;; Hide subthreads if needed.
10854 (gnus-summary-maybe-hide-threads)))
10856 (defun gnus-summary-sort (predicate reverse)
10857 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10858 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10859 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10860 (gnus-thread-sort-functions
10865 (gnus-sort-gathered-threads-function
10866 gnus-thread-sort-functions)
10867 (gnus-article-sort-functions
10871 (,article t2 t1))))
10873 (gnus-summary-prepare-hook nil))
10874 ;; We do the sorting by regenerating the threads.
10875 (gnus-summary-prepare)
10876 ;; Hide subthreads if needed.
10877 (gnus-summary-maybe-hide-threads)))
10879 ;; Summary saving commands.
10881 (defun gnus-summary-save-article (&optional n not-saved)
10882 "Save the current article using the default saver function.
10883 If N is a positive number, save the N next articles.
10884 If N is a negative number, save the N previous articles.
10885 If N is nil and any articles have been marked with the process mark,
10886 save those articles instead.
10887 The variable `gnus-default-article-saver' specifies the saver function."
10889 (let* ((articles (gnus-summary-work-articles n))
10890 (save-buffer (save-excursion
10891 (nnheader-set-temp-buffer " *Gnus Save*")))
10892 (num (length articles))
10894 (dolist (article articles)
10895 (setq header (gnus-summary-article-header article))
10896 (if (not (vectorp header))
10897 ;; This is a pseudo-article.
10898 (if (assq 'name header)
10899 (gnus-copy-file (cdr (assq 'name header)))
10900 (gnus-message 1 "Article %d is unsaveable" article))
10901 ;; This is a real article.
10902 (save-window-excursion
10903 (let ((gnus-display-mime-function nil)
10904 (gnus-article-prepare-hook nil))
10905 (gnus-summary-select-article t nil nil article)))
10907 (set-buffer save-buffer)
10909 (insert-buffer-substring gnus-original-article-buffer))
10910 (setq file (gnus-article-save save-buffer file num))
10911 (gnus-summary-remove-process-mark article)
10913 (gnus-summary-set-saved-mark article))))
10914 (gnus-kill-buffer save-buffer)
10915 (gnus-summary-position-point)
10916 (gnus-set-mode-line 'summary)
10919 (defun gnus-summary-pipe-output (&optional arg headers)
10920 "Pipe the current article to a subprocess.
10921 If N is a positive number, pipe the N next articles.
10922 If N is a negative number, pipe the N previous articles.
10923 If N is nil and any articles have been marked with the process mark,
10924 pipe those articles instead.
10925 If HEADERS (the symbolic prefix), include the headers, too."
10926 (interactive (gnus-interactive "P\ny"))
10927 (require 'gnus-art)
10928 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10929 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10930 (gnus-summary-save-article arg t))
10931 (let ((buffer (get-buffer "*Shell Command Output*")))
10933 (not (zerop (buffer-size buffer))))
10934 (gnus-configure-windows 'pipe))))
10936 (defun gnus-summary-save-article-mail (&optional arg)
10937 "Append the current article to an mail file.
10938 If N is a positive number, save the N next articles.
10939 If N is a negative number, save the N previous articles.
10940 If N is nil and any articles have been marked with the process mark,
10941 save those articles instead."
10943 (require 'gnus-art)
10944 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10945 (gnus-summary-save-article arg)))
10947 (defun gnus-summary-save-article-rmail (&optional arg)
10948 "Append the current article to an rmail file.
10949 If N is a positive number, save the N next articles.
10950 If N is a negative number, save the N previous articles.
10951 If N is nil and any articles have been marked with the process mark,
10952 save those articles instead."
10954 (require 'gnus-art)
10955 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10956 (gnus-summary-save-article arg)))
10958 (defun gnus-summary-save-article-file (&optional arg)
10959 "Append the current article to a file.
10960 If N is a positive number, save the N next articles.
10961 If N is a negative number, save the N previous articles.
10962 If N is nil and any articles have been marked with the process mark,
10963 save those articles instead."
10965 (require 'gnus-art)
10966 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10967 (gnus-summary-save-article arg)))
10969 (defun gnus-summary-write-article-file (&optional arg)
10970 "Write the current article to a file, deleting the previous file.
10971 If N is a positive number, save the N next articles.
10972 If N is a negative number, save the N previous articles.
10973 If N is nil and any articles have been marked with the process mark,
10974 save those articles instead."
10976 (require 'gnus-art)
10977 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10978 (gnus-summary-save-article arg)))
10980 (defun gnus-summary-save-article-body-file (&optional arg)
10981 "Append the current article body to a file.
10982 If N is a positive number, save the N next articles.
10983 If N is a negative number, save the N previous articles.
10984 If N is nil and any articles have been marked with the process mark,
10985 save those articles instead."
10987 (require 'gnus-art)
10988 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10989 (gnus-summary-save-article arg)))
10991 (defun gnus-summary-muttprint (&optional arg)
10992 "Print the current article using Muttprint.
10993 If N is a positive number, save the N next articles.
10994 If N is a negative number, save the N previous articles.
10995 If N is nil and any articles have been marked with the process mark,
10996 save those articles instead."
10998 (require 'gnus-art)
10999 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11000 (gnus-summary-save-article arg t)))
11002 (defun gnus-summary-pipe-message (program)
11003 "Pipe the current article through PROGRAM."
11004 (interactive "sProgram: ")
11005 (gnus-summary-select-article)
11006 (let ((mail-header-separator ""))
11007 (gnus-eval-in-buffer-window gnus-article-buffer
11010 (let ((start (window-start))
11012 (message-pipe-buffer-body program)
11013 (set-window-start (get-buffer-window (current-buffer)) start))))))
11015 (defun gnus-get-split-value (methods)
11016 "Return a value based on the split METHODS."
11017 (let (split-name method result match)
11020 (set-buffer gnus-original-article-buffer)
11022 (nnheader-narrow-to-headers)
11023 (while (and methods (not split-name))
11024 (goto-char (point-min))
11025 (setq method (pop methods))
11026 (setq match (car method))
11029 ;; Regular expression.
11031 (re-search-forward match nil t)))
11036 (setq result (funcall match gnus-newsgroup-name))))
11041 (setq result (eval match)))))
11042 (setq split-name (cdr method))
11043 (cond ((stringp result)
11044 (push (expand-file-name
11045 result gnus-article-save-directory)
11048 (setq split-name (append result split-name)))))))))
11049 (nreverse split-name)))
11051 (defun gnus-valid-move-group-p (group)
11052 (and (boundp group)
11053 (symbol-name group)
11054 (symbol-value group)
11055 (gnus-get-function (gnus-find-method-for-group
11056 (symbol-name group)) 'request-accept-article t)))
11058 (defun gnus-read-move-group-name (prompt default articles prefix)
11059 "Read a group name."
11060 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11061 (minibuffer-confirm-incomplete nil) ; XEmacs
11063 (format "%s %s to:"
11065 (if (> (length articles) 1)
11066 (format "these %d articles" (length articles))
11071 (gnus-completing-read-with-default
11074 'gnus-valid-move-group-p
11076 'gnus-group-history))
11077 ((= 1 (length split-name))
11078 (gnus-completing-read-with-default
11079 (car split-name) prom
11081 'gnus-valid-move-group-p
11083 'gnus-group-history))
11085 (gnus-completing-read-with-default
11087 (mapcar (lambda (el) (list el))
11088 (nreverse split-name))
11090 'gnus-group-history))))
11091 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11093 (if (or (string= to-newsgroup "")
11094 (string= to-newsgroup prefix))
11095 (setq to-newsgroup default))
11096 (unless to-newsgroup
11097 (error "No group name entered"))
11098 (or (gnus-active to-newsgroup)
11099 (gnus-activate-group to-newsgroup nil nil to-method)
11100 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11102 (or (and (gnus-request-create-group to-newsgroup to-method)
11103 (gnus-activate-group
11104 to-newsgroup nil nil to-method)
11105 (gnus-subscribe-group to-newsgroup))
11106 (error "Couldn't create group %s" to-newsgroup)))
11107 (error "No such group: %s" to-newsgroup)))
11110 (defun gnus-summary-save-parts (type dir n &optional reverse)
11111 "Save parts matching TYPE to DIR.
11112 If REVERSE, save parts that do not match TYPE."
11114 (list (read-string "Save parts of type: "
11115 (or (car gnus-summary-save-parts-type-history)
11116 gnus-summary-save-parts-default-mime)
11117 'gnus-summary-save-parts-type-history)
11118 (setq gnus-summary-save-parts-last-directory
11119 (read-file-name "Save to directory: "
11120 gnus-summary-save-parts-last-directory
11122 current-prefix-arg))
11123 (gnus-summary-iterate n
11124 (let ((gnus-display-mime-function nil)
11125 (gnus-inhibit-treatment t))
11126 (gnus-summary-select-article))
11128 (set-buffer gnus-article-buffer)
11129 (let ((handles (or gnus-article-mime-handles
11130 (mm-dissect-buffer nil gnus-article-loose-mime)
11131 (and gnus-article-emulate-mime
11132 (mm-uu-dissect)))))
11134 (gnus-summary-save-parts-1 type dir handles reverse)
11135 (unless gnus-article-mime-handles ;; Don't destroy this case.
11136 (mm-destroy-parts handles)))))))
11138 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11139 (if (stringp (car handle))
11140 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11143 (not (string-match type (mm-handle-media-type handle)))
11144 (string-match type (mm-handle-media-type handle)))
11145 (let ((file (expand-file-name
11147 mm-file-name-rewrite-functions
11148 (file-name-nondirectory
11150 (mail-content-type-get
11151 (mm-handle-disposition handle) 'filename)
11152 (mail-content-type-get
11153 (mm-handle-type handle) 'name)
11154 (concat gnus-newsgroup-name
11155 "." (number-to-string
11156 (cdr gnus-article-current))))))
11158 (unless (file-exists-p file)
11159 (mm-save-part-to-file handle file))))))
11161 ;; Summary extract commands
11163 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11164 (let ((buffer-read-only nil)
11165 (article (gnus-summary-article-number))
11167 (unless (gnus-summary-goto-subject article)
11168 (error "No such article: %d" article))
11169 (gnus-summary-position-point)
11170 ;; If all commands are to be bunched up on one line, we collect
11172 (unless gnus-view-pseudos-separately
11173 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11176 (setq action (cdr (assq 'action (car ps))))
11177 (setq files (list (cdr (assq 'name (car ps)))))
11178 (while (and ps (cdr ps)
11179 (string= (or action "1")
11180 (or (cdr (assq 'action (cadr ps))) "2")))
11181 (push (cdr (assq 'name (cadr ps))) files)
11182 (setcdr ps (cddr ps)))
11184 (when (not (string-match "%s" action))
11187 (when (assq 'execute (car ps))
11188 (setcdr (assq 'execute (car ps))
11189 (funcall (if (string-match "%s" action)
11196 (shell-quote-argument f)))
11198 (setq ps (cdr ps)))))
11199 (if (and gnus-view-pseudos (not not-view))
11201 (when (assq 'execute (car pslist))
11202 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11203 (eq gnus-view-pseudos 'not-confirm)))
11204 (setq pslist (cdr pslist)))
11207 (setq after-article (or (cdr (assq 'article (car pslist)))
11208 (gnus-summary-article-number)))
11209 (gnus-summary-goto-subject after-article)
11212 (insert " " (file-name-nondirectory
11213 (cdr (assq 'name (car pslist))))
11214 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11216 (forward-line -1) ; back to `b'
11217 (gnus-add-text-properties
11218 b (1- e) (list 'gnus-number gnus-reffed-article-number
11219 gnus-mouse-face-prop gnus-mouse-face))
11221 after-article gnus-reffed-article-number
11222 gnus-unread-mark b (car pslist) 0 (- e b))
11223 (setq gnus-newsgroup-unreads
11224 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11225 gnus-reffed-article-number))
11226 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11227 (setq pslist (cdr pslist)))))))
11229 (defun gnus-pseudos< (p1 p2)
11230 (let ((c1 (cdr (assq 'action p1)))
11231 (c2 (cdr (assq 'action p2))))
11232 (and c1 c2 (string< c1 c2))))
11234 (defun gnus-request-pseudo-article (props)
11235 (cond ((assq 'execute props)
11236 (gnus-execute-command (cdr (assq 'execute props)))))
11237 (let ((gnus-current-article (gnus-summary-article-number)))
11238 (gnus-run-hooks 'gnus-mark-article-hook)))
11240 (defun gnus-execute-command (command &optional automatic)
11242 (gnus-article-setup-buffer)
11243 (set-buffer gnus-article-buffer)
11244 (setq buffer-read-only nil)
11245 (let ((command (if automatic command
11246 (read-string "Command: " (cons command 0)))))
11248 (insert "$ " command "\n\n")
11249 (if gnus-view-pseudo-asynchronously
11250 (start-process "gnus-execute" (current-buffer) shell-file-name
11251 shell-command-switch command)
11252 (call-process shell-file-name nil t nil
11253 shell-command-switch command)))))
11255 ;; Summary kill commands.
11257 (defun gnus-summary-edit-global-kill (article)
11258 "Edit the \"global\" kill file."
11259 (interactive (list (gnus-summary-article-number)))
11260 (gnus-group-edit-global-kill article))
11262 (defun gnus-summary-edit-local-kill ()
11263 "Edit a local kill file applied to the current newsgroup."
11265 (setq gnus-current-headers (gnus-summary-article-header))
11266 (gnus-group-edit-local-kill
11267 (gnus-summary-article-number) gnus-newsgroup-name))
11269 ;;; Header reading.
11271 (defun gnus-read-header (id &optional header)
11272 "Read the headers of article ID and enter them into the Gnus system."
11273 (let ((group gnus-newsgroup-name)
11274 (gnus-override-method
11276 gnus-override-method
11277 (and (gnus-news-group-p gnus-newsgroup-name)
11278 (car (gnus-refer-article-methods)))))
11280 ;; First we check to see whether the header in question is already
11283 ;; This is a Message-ID.
11284 (setq header (or header (gnus-id-to-header id)))
11285 ;; This is an article number.
11286 (setq header (or header (gnus-summary-article-header id))))
11288 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11289 ;; We have found the header.
11291 ;; If this is a sparse article, we have to nix out its
11292 ;; previous entry in the thread hashtb.
11294 (gnus-summary-article-sparse-p (mail-header-number header)))
11295 (let* ((parent (gnus-parent-id (mail-header-references header)))
11296 (thread (and parent (gnus-id-to-thread parent))))
11298 (delq (assq header thread) thread))))
11299 ;; We have to really fetch the header to this article.
11301 (set-buffer nntp-server-buffer)
11302 (when (setq where (gnus-request-head id group))
11303 (nnheader-fold-continuation-lines)
11304 (goto-char (point-max))
11306 (goto-char (point-min))
11310 ((cdr where) (cdr where))
11311 (header (mail-header-number header))
11312 (t gnus-reffed-article-number))
11314 (insert " Article retrieved.\n"))
11315 (if (or (not where)
11316 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11317 () ; Malformed head.
11318 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11319 (when (and (stringp id)
11320 (not (string= (gnus-group-real-name group)
11322 ;; If we fetched by Message-ID and the article came
11323 ;; from a different group, we fudge some bogus article
11324 ;; numbers for this article.
11325 (mail-header-set-number header gnus-reffed-article-number))
11327 (set-buffer gnus-summary-buffer)
11328 (decf gnus-reffed-article-number)
11329 (gnus-remove-header (mail-header-number header))
11330 (push header gnus-newsgroup-headers)
11331 (setq gnus-current-headers header)
11332 (push (mail-header-number header) gnus-newsgroup-limit)))
11335 (defun gnus-remove-header (number)
11336 "Remove header NUMBER from `gnus-newsgroup-headers'."
11337 (if (and gnus-newsgroup-headers
11338 (= number (mail-header-number (car gnus-newsgroup-headers))))
11339 (pop gnus-newsgroup-headers)
11340 (let ((headers gnus-newsgroup-headers))
11341 (while (and (cdr headers)
11342 (not (= number (mail-header-number (cadr headers)))))
11344 (when (cdr headers)
11345 (setcdr headers (cddr headers))))))
11348 ;;; summary highlights
11351 (defun gnus-highlight-selected-summary ()
11352 "Highlight selected article in summary buffer."
11353 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11354 (when gnus-summary-selected-face
11356 (let* ((beg (point-at-bol))
11357 (end (point-at-eol))
11358 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11359 (from (if (get-text-property beg gnus-mouse-face-prop)
11361 (or (next-single-property-change
11362 beg gnus-mouse-face-prop nil end)
11367 (or (next-single-property-change
11368 from gnus-mouse-face-prop nil end)
11370 ;; If no mouse-face prop on line we will have to = from = end,
11371 ;; so we highlight the entire line instead.
11372 (when (= (+ to 2) from)
11375 (if gnus-newsgroup-selected-overlay
11376 ;; Move old overlay.
11378 gnus-newsgroup-selected-overlay from to (current-buffer))
11379 ;; Create new overlay.
11381 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11382 'face gnus-summary-selected-face))))))
11384 (defvar gnus-summary-highlight-line-cached nil)
11385 (defvar gnus-summary-highlight-line-trigger nil)
11387 (defun gnus-summary-highlight-line-0 ()
11388 (if (and (eq gnus-summary-highlight-line-trigger
11389 gnus-summary-highlight)
11390 gnus-summary-highlight-line-cached)
11391 gnus-summary-highlight-line-cached
11392 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11393 gnus-summary-highlight-line-cached
11394 (let* ((cond (list 'cond))
11396 (list gnus-summary-highlight))
11398 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11402 (gnus-byte-compile (list 'lambda nil cond))))))
11404 (defun gnus-summary-highlight-line ()
11405 "Highlight current line according to `gnus-summary-highlight'."
11406 (let* ((beg (point-at-bol))
11407 (article (or (gnus-summary-article-number) gnus-current-article))
11408 (score (or (cdr (assq article
11409 gnus-newsgroup-scored))
11410 gnus-summary-default-score 0))
11411 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11412 (inhibit-read-only t)
11413 (default gnus-summary-default-score)
11414 (default-high gnus-summary-default-high-score)
11415 (default-low gnus-summary-default-low-score)
11416 (uncached (and gnus-summary-use-undownloaded-faces
11417 (memq article gnus-newsgroup-undownloaded)
11418 (not (memq article gnus-newsgroup-cached)))))
11419 (let ((face (funcall (gnus-summary-highlight-line-0))))
11420 (unless (eq face (get-text-property beg 'face))
11421 (gnus-put-text-property-excluding-characters-with-faces
11422 beg (point-at-eol) 'face
11423 (setq face (if (boundp face) (symbol-value face) face)))
11424 (when gnus-summary-highlight-line-function
11425 (funcall gnus-summary-highlight-line-function article face))))))
11427 (defun gnus-update-read-articles (group unread &optional compute)
11428 "Update the list of read articles in GROUP.
11429 UNREAD is a sorted list."
11430 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11431 (info (gnus-get-info group))
11434 (if (or (not info) (not active))
11435 ;; There is no info on this group if it was, in fact,
11436 ;; killed. Gnus stores no information on killed groups, so
11437 ;; there's nothing to be done.
11438 ;; One could store the information somewhere temporarily,
11439 ;; perhaps... Hmmm...
11441 ;; Remove any negative articles numbers.
11442 (while (and unread (< (car unread) 0))
11443 (setq unread (cdr unread)))
11444 ;; Remove any expired article numbers
11445 (while (and unread (< (car unread) (car active)))
11446 (setq unread (cdr unread)))
11447 ;; Compute the ranges of read articles by looking at the list of
11448 ;; unread articles.
11450 (when (/= (car unread) prev)
11451 (push (if (= prev (1- (car unread))) prev
11452 (cons prev (1- (car unread))))
11454 (setq prev (1+ (car unread)))
11455 (setq unread (cdr unread)))
11456 (when (<= prev (cdr active))
11457 (push (cons prev (cdr active)) read))
11458 (setq read (if (> (length read) 1) (nreverse read) read))
11463 ;; Propagate the read marks to the backend.
11464 (when (gnus-check-backend-function 'request-set-mark group)
11465 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11466 (add (gnus-remove-from-range read (gnus-info-read info))))
11468 (unless (gnus-check-group group)
11469 (error "Can't open server for %s" group))
11470 (gnus-request-set-mark
11471 group (delq nil (list (if add (list add 'add '(read)))
11472 (if del (list del 'del '(read))))))
11474 `(gnus-request-set-mark
11477 (if del (list del 'add '(read)))
11478 (if add (list add 'del '(read))))))))))
11479 (set-buffer gnus-group-buffer)
11480 (gnus-undo-register
11482 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11483 (gnus-info-set-read ',info ',(gnus-info-read info))
11484 (gnus-get-unread-articles-in-group ',info
11485 (gnus-active ,group))
11486 (gnus-group-update-group ,group t)
11488 ;; Enter this list into the group info.
11489 (gnus-info-set-read info read)
11490 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11491 (gnus-get-unread-articles-in-group info (gnus-active group))
11494 (defun gnus-offer-save-summaries ()
11495 "Offer to save all active summary buffers."
11497 ;; Go through all buffers and find all summaries.
11498 (dolist (buffer (buffer-list))
11499 (when (and (setq buffer (buffer-name buffer))
11500 (string-match "Summary" buffer)
11502 (set-buffer buffer)
11503 ;; We check that this is, indeed, a summary buffer.
11504 (and (eq major-mode 'gnus-summary-mode)
11505 ;; Also make sure this isn't bogus.
11506 gnus-newsgroup-prepared
11507 ;; Also make sure that this isn't a
11508 ;; dead summary buffer.
11509 (not gnus-dead-summary-mode))))
11510 (push buffer buffers)))
11511 ;; Go through all these summary buffers and offer to save them.
11515 "Update summary buffer %s? "
11517 (switch-to-buffer buf)
11518 (gnus-summary-exit))
11522 ;;; @ for mime-partial
11525 (defun gnus-request-partial-message ()
11527 (let ((number (gnus-summary-article-number))
11528 (group gnus-newsgroup-name)
11529 (mother gnus-article-buffer))
11530 (set-buffer (get-buffer-create " *Partial Article*"))
11532 (setq mime-preview-buffer mother)
11533 (gnus-request-article-this-buffer number group)
11534 (mime-parse-buffer)
11537 (autoload 'mime-combine-message/partial-pieces-automatically
11539 "Internal method to combine message/partial messages automatically.")
11541 (mime-add-condition
11542 'action '((type . message)(subtype . partial)
11543 (major-mode . gnus-original-article-mode)
11544 (method . mime-combine-message/partial-pieces-automatically)
11545 (summary-buffer-exp . gnus-summary-buffer)
11546 (request-partial-message-method . gnus-request-partial-message)
11550 ;;; @ for message/rfc822
11553 (defun gnus-mime-extract-message/rfc822 (entity situation)
11554 "Burst a forwarded article."
11556 (set-buffer gnus-summary-buffer)
11557 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11558 gnus-newsgroup-name 'gnus-group-history))
11559 (gnus-group-marked (list group))
11562 (mime-insert-entity-content entity)
11563 (setq article (gnus-request-accept-article group)))
11564 (when (and (consp article)
11565 (numberp (setq article (cdr article))))
11566 (setq info (gnus-get-info group))
11567 (gnus-info-set-read info
11568 (gnus-remove-from-range (gnus-info-read info)
11570 (when (string-equal group gnus-newsgroup-name)
11572 (let (gnus-show-threads)
11573 (gnus-summary-goto-subject article t))
11574 (gnus-summary-clear-mark-forward 1))
11575 (set-buffer gnus-group-buffer)
11576 (gnus-group-get-new-news-this-group nil t)))))
11578 (mime-add-condition
11579 'action '((type . message)(subtype . rfc822)
11580 (major-mode . gnus-original-article-mode)
11581 (method . gnus-mime-extract-message/rfc822)
11585 (mime-add-condition
11586 'action '((type . message)(subtype . news)
11587 (major-mode . gnus-original-article-mode)
11588 (method . gnus-mime-extract-message/rfc822)
11592 (defun gnus-mime-extract-multipart (entity situation)
11593 (let ((children (mime-entity-children entity))
11594 mime-acting-situation-to-override
11597 (mime-play-entity (car children)
11598 (cons (assq 'mode situation)
11599 mime-acting-situation-to-override))
11600 (setq children (cdr children)))
11601 (if (setq f (cdr (assq 'after-method
11602 mime-acting-situation-to-override)))
11606 (mime-add-condition
11607 'action '((type . multipart)
11608 (method . gnus-mime-extract-multipart)
11617 (defun gnus-summary-inherit-default-charset ()
11618 "Import `default-mime-charset' from summary buffer.
11619 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11621 (if (buffer-live-p gnus-summary-buffer)
11622 (let (d-m-c d-m-c-u)
11623 (with-current-buffer gnus-summary-buffer
11624 (setq d-m-c (if (local-variable-p 'default-mime-charset
11625 gnus-summary-buffer)
11626 default-mime-charset
11629 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11630 gnus-summary-buffer)
11631 (symbol-value 'default-mime-charset-unlimited)
11634 (kill-local-variable 'default-mime-charset)
11635 (set (make-local-variable 'default-mime-charset) d-m-c))
11637 (kill-local-variable 'default-mime-charset-unlimited)
11638 (set (make-local-variable 'default-mime-charset-unlimited)
11641 (defun gnus-summary-setup-default-charset ()
11642 "Setup newsgroup default charset."
11643 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11645 (setq gnus-newsgroup-charset nil)
11646 (set (make-local-variable 'default-mime-charset) nil)
11647 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11648 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11649 (let ((ignored-charsets
11650 (or gnus-newsgroup-ephemeral-ignored-charsets
11652 (and gnus-newsgroup-name
11653 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11654 gnus-newsgroup-ignored-charsets)))
11656 (setq gnus-newsgroup-charset
11657 (or gnus-newsgroup-ephemeral-charset
11658 (when (and gnus-newsgroup-name
11659 (setq charset (gnus-parameter-charset
11660 gnus-newsgroup-name)))
11661 (make-local-variable 'default-mime-charset)
11662 (setq default-mime-charset charset))
11663 gnus-default-charset))
11664 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11665 ignored-charsets))))
11671 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11672 "Display the current article buffer fully MIME-buttonized.
11673 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11674 treated as multipart/mixed."
11676 (require 'gnus-art)
11677 (let ((gnus-unbuttonized-mime-types nil)
11678 (gnus-mime-display-multipart-as-mixed show-all-parts))
11679 (gnus-summary-show-article)))
11681 (defun gnus-summary-repair-multipart (article)
11682 "Add a Content-Type header to a multipart article without one."
11683 (interactive (list (gnus-summary-article-number)))
11684 (gnus-with-article article
11685 (message-narrow-to-head)
11686 (message-remove-header "Mime-Version")
11687 (goto-char (point-max))
11688 (insert "Mime-Version: 1.0\n")
11690 (when (search-forward "\n--" nil t)
11691 (let ((separator (buffer-substring (point) (point-at-eol))))
11692 (message-narrow-to-head)
11693 (message-remove-header "Content-Type")
11694 (goto-char (point-max))
11695 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11698 (let (gnus-mark-article-hook)
11699 (gnus-summary-select-article t t nil article)))
11701 (defun gnus-summary-toggle-display-buttonized ()
11702 "Toggle the buttonizing of the article buffer."
11704 (require 'gnus-art)
11705 (if (setq gnus-inhibit-mime-unbuttonizing
11706 (not gnus-inhibit-mime-unbuttonizing))
11707 (let ((gnus-unbuttonized-mime-types nil))
11708 (gnus-summary-show-article))
11709 (gnus-summary-show-article)))
11712 ;;; Intelli-mouse commmands
11715 (defun gnus-wheel-summary-scroll (event)
11717 (let ((amount (if (memq 'shift (event-modifiers event))
11718 (car gnus-wheel-scroll-amount)
11719 (cdr gnus-wheel-scroll-amount)))
11720 (direction (- (* (static-if (featurep 'xemacs)
11721 (event-button event)
11722 (cond ((eq 'mouse-4 (event-basic-type event))
11724 ((eq 'mouse-5 (event-basic-type event))
11728 (gnus-summary-scroll-up (* amount direction))
11729 (when (gnus-eval-in-buffer-window gnus-article-buffer
11732 (and (if (< 0 direction)
11733 (gnus-article-next-page 0)
11734 (gnus-article-prev-page 0)
11736 (if (setq edge (get-text-property
11737 (point-min) 'gnus-wheel-edge))
11738 (setq edge (* edge direction))
11741 (let ((buffer-read-only nil)
11742 (inhibit-read-only t))
11743 (put-text-property (point-min) (point-max)
11744 'gnus-wheel-edge direction)
11746 (or (> edge gnus-wheel-edge-resistance)
11747 (let ((buffer-read-only nil)
11748 (inhibit-read-only t))
11749 (put-text-property (point-min) (point-max)
11751 (* (1+ edge) direction))
11753 (eq last-command 'gnus-wheel-summary-scroll))))
11754 (gnus-summary-next-article nil nil (minusp direction)))))
11756 (defun gnus-wheel-install ()
11757 "Enable mouse wheel support on summary window."
11758 (when gnus-use-wheel
11760 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11762 (define-key gnus-summary-mode-map key
11763 'gnus-wheel-summary-scroll)))))
11765 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11768 ;;; Traditional PGP commmands
11771 (defun gnus-summary-decrypt-article (&optional force)
11772 "Decrypt the current article in traditional PGP way.
11773 This will have permanent effect only in mail groups.
11774 If FORCE is non-nil, allow editing of articles even in read-only
11777 (gnus-summary-select-article t)
11778 (gnus-eval-in-buffer-window gnus-article-buffer
11782 (goto-char (point-min))
11783 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11784 (error "Not a traditional PGP message!"))
11785 (let ((armor-start (match-beginning 0)))
11786 (if (and (pgg-decrypt-region armor-start (point-max))
11787 (or force (not (gnus-group-read-only-p))))
11788 (let ((inhibit-read-only t)
11790 (delete-region armor-start
11792 (re-search-forward "^-+END PGP" nil t)
11793 (beginning-of-line 2)
11795 (insert-buffer-substring pgg-output-buffer))))))))
11797 (defun gnus-summary-verify-article ()
11798 "Verify the current article in traditional PGP way."
11801 (set-buffer gnus-original-article-buffer)
11802 (goto-char (point-min))
11803 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11804 (error "Not a traditional PGP message!"))
11805 (re-search-forward "^-+END PGP" nil t)
11806 (beginning-of-line 2)
11807 (call-interactively (function pgg-verify-region))))
11810 ;;; Generic summary marking commands
11813 (defvar gnus-summary-marking-alist
11814 '((read gnus-del-mark "d")
11815 (unread gnus-unread-mark "u")
11816 (ticked gnus-ticked-mark "!")
11817 (dormant gnus-dormant-mark "?")
11818 (expirable gnus-expirable-mark "e"))
11819 "An alist of names/marks/keystrokes.")
11821 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11822 (defvar gnus-summary-mark-map)
11824 (defun gnus-summary-make-all-marking-commands ()
11825 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11826 (dolist (elem gnus-summary-marking-alist)
11827 (apply 'gnus-summary-make-marking-command elem)))
11829 (defun gnus-summary-make-marking-command (name mark keystroke)
11830 (let ((map (make-sparse-keymap)))
11831 (define-key gnus-summary-generic-mark-map keystroke map)
11832 (dolist (lway `((next "next" next nil "n")
11833 (next-unread "next unread" next t "N")
11834 (prev "previous" prev nil "p")
11835 (prev-unread "previous unread" prev t "P")
11836 (nomove "" nil nil ,keystroke)))
11837 (let ((func (gnus-summary-make-marking-command-1
11838 mark (car lway) lway name)))
11839 (setq func (eval func))
11840 (define-key map (nth 4 lway) func)))))
11842 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11844 (format "gnus-summary-put-mark-as-%s%s"
11845 name (if (eq way 'nomove)
11847 (concat "-" (symbol-name way)))))
11850 "Mark the current article as %s%s.
11851 If N, the prefix, then repeat N times.
11852 If N is negative, move in reverse order.
11853 The difference between N and the actual number of articles marked is
11855 name (car (cdr lway)))
11857 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11859 (defun gnus-summary-generic-mark (n mark move unread)
11860 "Mark N articles with MARK."
11861 (unless (eq major-mode 'gnus-summary-mode)
11862 (error "This command can only be used in the summary buffer"))
11863 (gnus-summary-show-thread)
11866 ((eq move 'next) 1)
11867 ((eq move 'prev) -1)
11869 (if (zerop nummove)
11873 nummove (* -1 nummove))))
11874 (while (and (> n 0)
11875 (gnus-summary-mark-article nil mark)
11876 (zerop (gnus-summary-next-subject nummove unread t)))
11879 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11880 (gnus-summary-recenter)
11881 (gnus-summary-position-point)
11882 (gnus-set-mode-line 'summary)
11885 (defun gnus-summary-insert-articles (articles)
11886 (when (setq articles
11887 (gnus-sorted-difference articles
11888 (mapcar (lambda (h)
11889 (mail-header-number h))
11890 gnus-newsgroup-headers)))
11891 (setq gnus-newsgroup-headers
11893 gnus-newsgroup-headers
11894 (gnus-fetch-headers articles)
11895 'gnus-article-sort-by-number))
11896 ;; Suppress duplicates?
11897 (when gnus-suppress-duplicates
11898 (gnus-dup-suppress-articles))
11900 ;; We might want to build some more threads first.
11901 (when (and gnus-fetch-old-headers
11902 (eq gnus-headers-retrieved-by 'nov))
11903 (if (eq gnus-fetch-old-headers 'invisible)
11904 (gnus-build-all-threads)
11905 (gnus-build-old-threads)))
11906 ;; Let the Gnus agent mark articles as read.
11908 (gnus-agent-get-undownloaded-list))
11909 ;; Remove list identifiers from subject
11910 (when gnus-list-identifiers
11911 (gnus-summary-remove-list-identifiers))
11912 ;; First and last article in this newsgroup.
11913 (when gnus-newsgroup-headers
11914 (setq gnus-newsgroup-begin
11915 (mail-header-number (car gnus-newsgroup-headers))
11917 (mail-header-number
11918 (gnus-last-element gnus-newsgroup-headers))))
11919 (when gnus-use-scoring
11920 (gnus-possibly-score-headers))))
11922 (defun gnus-summary-insert-old-articles (&optional all)
11923 "Insert all old articles in this group.
11924 If ALL is non-nil, already read articles become readable.
11925 If ALL is a number, fetch this number of articles."
11928 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11931 ;; Some nntp servers lie about their active range. When
11932 ;; this happens, the active range can be in the millions.
11933 ;; Use a compressed range to avoid creating a huge list.
11934 (gnus-range-difference (list gnus-newsgroup-active) old))
11935 (setq len (gnus-range-length older))
11940 (let ((older-range (nreverse older)))
11944 (let* ((r (pop older-range))
11945 (min (if (numberp r) r (car r)))
11946 (max (if (numberp r) r (cdr r))))
11947 (while (and (<= min max)
11952 (setq older (gnus-uncompress-range older))))
11954 (setq older (gnus-uncompress-range older)))
11956 (when (and (numberp gnus-large-newsgroup)
11957 (> len gnus-large-newsgroup))
11958 (let* ((cursor-in-echo-area nil)
11959 (initial (gnus-parameter-large-newsgroup-initial
11960 gnus-newsgroup-name))
11964 "How many articles from %s (%s %d): "
11966 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11967 (if initial "max" "default")
11970 (cons (number-to-string initial)
11972 (unless (string-match "^[ \t]*$" input)
11973 (setq all (string-to-number input))
11975 (let ((older-range (nreverse older)))
11979 (let* ((r (pop older-range))
11980 (min (if (numberp r) r (car r)))
11981 (max (if (numberp r) r (cdr r))))
11982 (while (and (<= min max)
11986 max (1- max))))))))))
11987 (setq older (gnus-uncompress-range older))))
11989 (message "No old news.")
11990 (gnus-summary-insert-articles older)
11991 (gnus-summary-limit (gnus-sorted-nunion old older))))
11992 (gnus-summary-position-point)))
11994 (defun gnus-summary-insert-new-articles ()
11995 "Insert all new articles in this group."
11998 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11999 (old-active gnus-newsgroup-active)
12000 (nnmail-fetched-sources (list t))
12002 (setq gnus-newsgroup-active
12003 (gnus-activate-group gnus-newsgroup-name 'scan))
12004 (setq i (cdr gnus-newsgroup-active))
12005 (while (> i (cdr old-active))
12009 (message "No gnus is bad news")
12010 (gnus-summary-insert-articles new)
12011 (setq gnus-newsgroup-unreads
12012 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12013 (gnus-summary-limit (gnus-sorted-nunion old new))))
12014 (gnus-summary-position-point)))
12016 (gnus-summary-make-all-marking-commands)
12018 (gnus-ems-redefine)
12020 (provide 'gnus-sum)
12022 (run-hooks 'gnus-sum-load-hook)
12024 ;; Local Variables:
12025 ;; coding: iso-8859-1
12028 ;;; gnus-sum.el ends here