1 ;;; gnus-sum.el --- summary mode commands for 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>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-cache-write-active "gnus-cache")
45 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
46 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
47 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
48 (autoload 'mm-uu-dissect "mm-uu")
49 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
50 "Deuglify broken Outlook (Express) articles and redisplay."
52 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
53 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
54 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
56 (defcustom gnus-kill-summary-on-exit t
57 "*If non-nil, kill the summary buffer when you exit from it.
58 If nil, the summary will become a \"*Dead Summary*\" buffer, and
59 it will be killed sometime later."
60 :group 'gnus-summary-exit
63 (defcustom gnus-fetch-old-headers nil
64 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
65 If an unread article in the group refers to an older, already read (or
66 just marked as read) article, the old article will not normally be
67 displayed in the Summary buffer. If this variable is non-nil, Gnus
68 will attempt to grab the headers to the old articles, and thereby
69 build complete threads. If it has the value `some', only enough
70 headers to connect otherwise loose threads will be displayed. This
71 variable can also be a number. In that case, no more than that number
72 of old headers will be fetched. If it has the value `invisible', all
73 old headers will be fetched, but none will be displayed.
75 The server has to support NOV for any of this to work."
77 :type '(choice (const :tag "off" nil)
80 (sexp :menu-tag "other" t)))
82 (defcustom gnus-refer-thread-limit 200
83 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
84 If t, fetch all the available old headers."
87 (sexp :menu-tag "other" t)))
89 (defcustom gnus-summary-make-false-root 'adopt
90 "*nil means that Gnus won't gather loose threads.
91 If the root of a thread has expired or been read in a previous
92 session, the information necessary to build a complete thread has been
93 lost. Instead of having many small sub-threads from this original thread
94 scattered all over the summary buffer, Gnus can gather them.
96 If non-nil, Gnus will try to gather all loose sub-threads from an
97 original thread into one large thread.
99 If this variable is non-nil, it should be one of `none', `adopt',
102 If this variable is `none', Gnus will not make a false root, but just
103 present the sub-threads after another.
104 If this variable is `dummy', Gnus will create a dummy root that will
105 have all the sub-threads as children.
106 If this variable is `adopt', Gnus will make one of the \"children\"
107 the parent and mark all the step-children as such.
108 If this variable is `empty', the \"children\" are printed with empty
109 subject fields. (Or rather, they will be printed with a string
110 given by the `gnus-summary-same-subject' variable.)"
112 :type '(choice (const :tag "off" nil)
118 (defcustom gnus-summary-make-false-root-always nil
119 "Always make a false dummy root."
123 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include:
151 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
152 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
154 :type '(repeat function))
156 (defcustom gnus-simplify-ignored-prefixes nil
157 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
159 :type '(choice (const :tag "off" nil)
162 (defcustom gnus-build-sparse-threads nil
163 "*If non-nil, fill in the gaps in threads.
164 If `some', only fill in the gaps that are needed to tie loose threads
165 together. If `more', fill in all leaf nodes that Gnus can find. If
166 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
168 :type '(choice (const :tag "off" nil)
171 (sexp :menu-tag "all" t)))
173 (defcustom gnus-summary-thread-gathering-function
174 'gnus-gather-threads-by-subject
175 "*Function used for gathering loose threads.
176 There are two pre-defined functions: `gnus-gather-threads-by-subject',
177 which only takes Subjects into consideration; and
178 `gnus-gather-threads-by-references', which compared the References
179 headers of the articles to find matches."
181 :type '(radio (function-item gnus-gather-threads-by-subject)
182 (function-item gnus-gather-threads-by-references)
183 (function :tag "other")))
185 (defcustom gnus-summary-same-subject ""
186 "*String indicating that the current article has the same subject as the previous.
187 This variable will only be used if the value of
188 `gnus-summary-make-false-root' is `empty'."
189 :group 'gnus-summary-format
192 (defcustom gnus-summary-goto-unread t
193 "*If t, many commands will go to the next unread article.
194 This applies to marking commands as well as other commands that
195 \"naturally\" select the next article, like, for instance, `SPC' at
196 the end of an article.
198 If nil, the marking commands do NOT go to the next unread article
199 \(they go to the next article instead). If `never', commands that
200 usually go to the next unread article, will go to the next article,
201 whether it is read or not."
202 :group 'gnus-summary-marks
203 :link '(custom-manual "(gnus)Setting Marks")
204 :type '(choice (const :tag "off" nil)
206 (sexp :menu-tag "on" t)))
208 (defcustom gnus-summary-default-score 0
209 "*Default article score level.
210 All scores generated by the score files will be added to this score.
211 If this variable is nil, scoring will be disabled."
212 :group 'gnus-score-default
213 :type '(choice (const :tag "disable")
216 (defcustom gnus-summary-default-high-score 0
217 "*Default threshold for a high scored article.
218 An article will be highlighted as high scored if its score is greater
220 :group 'gnus-score-default
223 (defcustom gnus-summary-default-low-score 0
224 "*Default threshold for a low scored article.
225 An article will be highlighted as low scored if its score is smaller
227 :group 'gnus-score-default
230 (defcustom gnus-summary-zcore-fuzz 0
231 "*Fuzziness factor for the zcore in the summary buffer.
232 Articles with scores closer than this to `gnus-summary-default-score'
234 :group 'gnus-summary-format
237 (defcustom gnus-simplify-subject-fuzzy-regexp nil
238 "*Strings to be removed when doing fuzzy matches.
239 This can either be a regular expression or list of regular expressions
240 that will be removed from subject strings if fuzzy subject
241 simplification is selected."
243 :type '(repeat regexp))
245 (defcustom gnus-show-threads t
246 "*If non-nil, display threads in summary mode."
250 (defcustom gnus-thread-hide-subtree nil
251 "*If non-nil, hide all threads initially.
252 This can be a predicate specifier which says which threads to hide.
253 If threads are hidden, you have to run the command
254 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
255 to expose hidden threads."
257 :type '(radio (sexp :format "Non-nil\n"
258 :match (lambda (widget value)
259 (not (or (consp value) (functionp value))))
262 (sexp :tag "Predicate specifier" :size 0)))
264 (defcustom gnus-thread-hide-killed t
265 "*If non-nil, hide killed threads automatically."
269 (defcustom gnus-thread-ignore-subject t
270 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
271 If nil, articles that have different subjects from their parents will
272 start separate threads."
276 (defcustom gnus-thread-operation-ignore-subject t
277 "*If non-nil, subjects will be ignored when doing thread commands.
278 This affects commands like `gnus-summary-kill-thread' and
279 `gnus-summary-lower-thread'.
281 If this variable is nil, articles in the same thread with different
282 subjects will not be included in the operation in question. If this
283 variable is `fuzzy', only articles that have subjects that are fuzzily
284 equal will be included."
286 :type '(choice (const :tag "off" nil)
290 (defcustom gnus-thread-indent-level 4
291 "*Number that says how much each sub-thread should be indented."
295 (defcustom gnus-auto-extend-newsgroup t
296 "*If non-nil, extend newsgroup forward and backward when requested."
297 :group 'gnus-summary-choose
300 (defcustom gnus-auto-select-first t
301 "*If non-nil, select the article under point.
302 Which article this is is controlled by the `gnus-auto-select-subject'
305 If you want to prevent automatic selection of articles in some
306 newsgroups, set the variable to nil in `gnus-select-group-hook'."
307 :group 'gnus-group-select
308 :type '(choice (const :tag "none" nil)
309 (sexp :menu-tag "first" t)))
311 (defcustom gnus-auto-select-subject 'unread
312 "*Says what subject to place under point when entering a group.
314 This variable can either be the symbols `first' (place point on the
315 first subject), `unread' (place point on the subject line of the first
316 unread article), `best' (place point on the subject line of the
317 higest-scored article), `unseen' (place point on the subject line of
318 the first unseen article), 'unseen-or-unread' (place point on the subject
319 line of the first unseen article or, if all article have been seen, on the
320 subject line of the first unread article), or a function to be called to
321 place point on some subject line."
322 :group 'gnus-group-select
323 :type '(choice (const best)
327 (const unseen-or-unread)))
329 (defcustom gnus-auto-select-next t
330 "*If non-nil, offer to go to the next group from the end of the previous.
331 If the value is t and the next newsgroup is empty, Gnus will exit
332 summary mode and go back to group mode. If the value is neither nil
333 nor t, Gnus will select the following unread newsgroup. In
334 particular, if the value is the symbol `quietly', the next unread
335 newsgroup will be selected without any confirmation, and if it is
336 `almost-quietly', the next group will be selected without any
337 confirmation if you are located on the last article in the group.
338 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
339 will go to the next group without confirmation."
340 :group 'gnus-summary-maneuvering
341 :type '(choice (const :tag "off" nil)
343 (const almost-quietly)
344 (const slightly-quietly)
345 (sexp :menu-tag "on" t)))
347 (defcustom gnus-auto-select-same nil
348 "*If non-nil, select the next article with the same subject.
349 If there are no more articles with the same subject, go to
350 the first unread article."
351 :group 'gnus-summary-maneuvering
354 (defcustom gnus-auto-goto-ignores 'unfetched
355 "*Says how to handle unfetched articles when maneuvering.
357 This variable can either be the symbols nil (maneuver to any
358 article), `undownloaded' (maneuvering while unplugged ignores articles
359 that have not been fetched), `always-undownloaded' (maneuvering always
360 ignores articles that have not been fetched), `unfetched' (maneuvering
361 ignores articles whose headers have not been fetched).
363 NOTE: The list of unfetched articles will always be nil when plugged
364 and, when unplugged, a subset of the undownloaded article list."
365 :group 'gnus-summary-maneuvering
366 :type '(choice (const :tag "None" nil)
367 (const :tag "Undownloaded when unplugged" undownloaded)
368 (const :tag "Undownloaded" always-undownloaded)
369 (const :tag "Unfetched" unfetched)))
371 (defcustom gnus-summary-check-current nil
372 "*If non-nil, consider the current article when moving.
373 The \"unread\" movement commands will stay on the same line if the
374 current article is unread."
375 :group 'gnus-summary-maneuvering
378 (defcustom gnus-auto-center-summary t
379 "*If non-nil, always center the current summary buffer.
380 In particular, if `vertical' do only vertical recentering. If non-nil
381 and non-`vertical', do both horizontal and vertical recentering."
382 :group 'gnus-summary-maneuvering
383 :type '(choice (const :tag "none" nil)
385 (integer :tag "height")
386 (sexp :menu-tag "both" t)))
388 (defvar gnus-auto-center-group t
389 "*If non-nil, always center the group buffer.")
391 (defcustom gnus-show-all-headers nil
392 "*If non-nil, don't hide any headers."
393 :group 'gnus-article-hiding
394 :group 'gnus-article-headers
397 (defcustom gnus-summary-ignore-duplicates nil
398 "*If non-nil, ignore articles with identical Message-ID headers."
402 (defcustom gnus-single-article-buffer t
403 "*If non-nil, display all articles in the same buffer.
404 If nil, each group will get its own article buffer."
405 :group 'gnus-article-various
408 (defcustom gnus-break-pages t
409 "*If non-nil, do page breaking on articles.
410 The page delimiter is specified by the `gnus-page-delimiter'
412 :group 'gnus-article-various
415 (defcustom gnus-move-split-methods nil
416 "*Variable used to suggest where articles are to be moved to.
417 It uses the same syntax as the `gnus-split-methods' variable.
418 However, whereas `gnus-split-methods' specifies file names as targets,
419 this variable specifies group names."
420 :group 'gnus-summary-mail
421 :type '(repeat (choice (list :value (fun) function)
422 (cons :value ("" "") regexp (repeat string))
425 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
426 "Function used to compute default prefix for article move/copy/etc prompts.
427 The function should take one argument, a group name, and return a
428 string with the suggested prefix."
429 :group 'gnus-summary-mail
432 (defcustom gnus-unread-mark ? ;Whitespace
433 "*Mark used for unread articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-ticked-mark ?!
438 "*Mark used for ticked articles."
439 :group 'gnus-summary-marks
442 (defcustom gnus-dormant-mark ??
443 "*Mark used for dormant articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-del-mark ?r
448 "*Mark used for del'd articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-read-mark ?R
453 "*Mark used for read articles."
454 :group 'gnus-summary-marks
457 (defcustom gnus-expirable-mark ?E
458 "*Mark used for expirable articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-killed-mark ?K
463 "*Mark used for killed articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-spam-mark ?$
468 "*Mark used for spam articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-souped-mark ?F
473 "*Mark used for souped articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-kill-file-mark ?X
478 "*Mark used for articles killed by kill files."
479 :group 'gnus-summary-marks
482 (defcustom gnus-low-score-mark ?Y
483 "*Mark used for articles with a low score."
484 :group 'gnus-summary-marks
487 (defcustom gnus-catchup-mark ?C
488 "*Mark used for articles that are caught up."
489 :group 'gnus-summary-marks
492 (defcustom gnus-replied-mark ?A
493 "*Mark used for articles that have been replied to."
494 :group 'gnus-summary-marks
497 (defcustom gnus-forwarded-mark ?F
498 "*Mark used for articles that have been forwarded."
499 :group 'gnus-summary-marks
502 (defcustom gnus-recent-mark ?N
503 "*Mark used for articles that are recent."
504 :group 'gnus-summary-marks
507 (defcustom gnus-cached-mark ?*
508 "*Mark used for articles that are in the cache."
509 :group 'gnus-summary-marks
512 (defcustom gnus-saved-mark ?S
513 "*Mark used for articles that have been saved."
514 :group 'gnus-summary-marks
517 (defcustom gnus-unseen-mark ?.
518 "*Mark used for articles that haven't been seen."
519 :group 'gnus-summary-marks
522 (defcustom gnus-no-mark ? ;Whitespace
523 "*Mark used for articles that have no other secondary mark."
524 :group 'gnus-summary-marks
527 (defcustom gnus-ancient-mark ?O
528 "*Mark used for ancient articles."
529 :group 'gnus-summary-marks
532 (defcustom gnus-sparse-mark ?Q
533 "*Mark used for sparsely reffed articles."
534 :group 'gnus-summary-marks
537 (defcustom gnus-canceled-mark ?G
538 "*Mark used for canceled articles."
539 :group 'gnus-summary-marks
542 (defcustom gnus-duplicate-mark ?M
543 "*Mark used for duplicate articles."
544 :group 'gnus-summary-marks
547 (defcustom gnus-undownloaded-mark ?-
548 "*Mark used for articles that weren't downloaded."
549 :group 'gnus-summary-marks
552 (defcustom gnus-downloaded-mark ?+
553 "*Mark used for articles that were downloaded."
554 :group 'gnus-summary-marks
557 (defcustom gnus-downloadable-mark ?%
558 "*Mark used for articles that are to be downloaded."
559 :group 'gnus-summary-marks
562 (defcustom gnus-unsendable-mark ?=
563 "*Mark used for articles that won't be sent."
564 :group 'gnus-summary-marks
567 (defcustom gnus-score-over-mark ?+
568 "*Score mark used for articles with high scores."
569 :group 'gnus-summary-marks
572 (defcustom gnus-score-below-mark ?-
573 "*Score mark used for articles with low scores."
574 :group 'gnus-summary-marks
577 (defcustom gnus-empty-thread-mark ? ;Whitespace
578 "*There is no thread under the article."
579 :group 'gnus-summary-marks
582 (defcustom gnus-not-empty-thread-mark ?=
583 "*There is a thread under the article."
584 :group 'gnus-summary-marks
587 (defcustom gnus-view-pseudo-asynchronously nil
588 "*If non-nil, Gnus will view pseudo-articles asynchronously."
589 :group 'gnus-extract-view
592 (defcustom gnus-auto-expirable-marks
593 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
594 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
595 gnus-souped-mark gnus-duplicate-mark)
596 "*The list of marks converted into expiration if a group is auto-expirable."
599 :type '(repeat character))
601 (defcustom gnus-inhibit-user-auto-expire t
602 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
607 (defcustom gnus-view-pseudos nil
608 "*If `automatic', pseudo-articles will be viewed automatically.
609 If `not-confirm', pseudos will be viewed automatically, and the user
610 will not be asked to confirm the command."
611 :group 'gnus-extract-view
612 :type '(choice (const :tag "off" nil)
614 (const not-confirm)))
616 (defcustom gnus-view-pseudos-separately t
617 "*If non-nil, one pseudo-article will be created for each file to be viewed.
618 If nil, all files that use the same viewing command will be given as a
619 list of parameters to that command."
620 :group 'gnus-extract-view
623 (defcustom gnus-insert-pseudo-articles t
624 "*If non-nil, insert pseudo-articles when decoding articles."
625 :group 'gnus-extract-view
628 (defcustom gnus-summary-dummy-line-format
630 "*The format specification for the dummy roots in the summary buffer.
631 It works along the same lines as a normal formatting string,
632 with some simple extensions.
636 General format specifiers can also be used.
637 See `(gnus)Formatting Variables'."
638 :link '(custom-manual "(gnus)Formatting Variables")
639 :group 'gnus-threading
642 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
643 "*The format specification for the summary mode line.
644 It works along the same lines as a normal formatting string,
645 with some simple extensions:
648 %p Unprefixed group name
649 %A Current article number
650 %z Current article score
652 %U Number of unread articles in the group
653 %e Number of unselected articles in the group
654 %Z A string with unread/unselected article counts
655 %g Shortish group name
656 %S Subject of the current article
658 %s Current score file name
659 %d Number of dormant articles
660 %r Number of articles that have been marked as read in this session
661 %E Number of articles expunged by the score files"
662 :group 'gnus-summary-format
665 (defcustom gnus-list-identifiers nil
666 "Regexp that matches list identifiers to be removed from subject.
667 This can also be a list of regexps."
669 :group 'gnus-summary-format
670 :group 'gnus-article-hiding
671 :type '(choice (const :tag "none" nil)
673 (repeat :value (".*") regexp)))
675 (defcustom gnus-summary-mark-below 0
676 "*Mark all articles with a score below this variable as read.
677 This variable is local to each summary buffer and usually set by the
679 :group 'gnus-score-default
682 (defun gnus-widget-reversible-match (widget value)
683 "Ignoring WIDGET, convert VALUE to internal form.
684 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
688 (eq (length value) 2)
689 (eq (nth 0 value) 'not)
690 (symbolp (nth 1 value)))))
692 (defun gnus-widget-reversible-to-internal (widget value)
693 "Ignoring WIDGET, convert VALUE to internal form.
694 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
695 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
699 (list (nth 1 value) t)))
701 (defun gnus-widget-reversible-to-external (widget value)
702 "Ignoring WIDGET, convert VALUE to external form.
703 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
704 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
707 (list 'not (nth 0 value))
710 (define-widget 'gnus-widget-reversible 'group
711 "A `group' that convert values."
712 :match 'gnus-widget-reversible-match
713 :value-to-internal 'gnus-widget-reversible-to-internal
714 :value-to-external 'gnus-widget-reversible-to-external)
717 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
718 "*List of functions used for sorting articles in the summary buffer.
720 Each function takes two articles and returns non-nil if the first
721 article should be sorted before the other. If you use more than one
722 function, the primary sort function should be the last. You should
723 probably always include `gnus-article-sort-by-number' in the list of
724 sorting functions -- preferably first. Also note that sorting by date
725 is often much slower than sorting by number, and the sorting order is
726 very similar. (Sorting by date means sorting by the time the message
727 was sent, sorting by number means sorting by arrival time.)
729 Each item can also be a list `(not F)' where F is a function;
730 this reverses the sort order.
732 Ready-made functions include `gnus-article-sort-by-number',
733 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
734 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
735 and `gnus-article-sort-by-score'.
737 When threading is turned on, the variable `gnus-thread-sort-functions'
738 controls how articles are sorted."
739 :group 'gnus-summary-sort
740 :type '(repeat (gnus-widget-reversible
741 (choice (function-item gnus-article-sort-by-number)
742 (function-item gnus-article-sort-by-author)
743 (function-item gnus-article-sort-by-subject)
744 (function-item gnus-article-sort-by-date)
745 (function-item gnus-article-sort-by-score)
746 (function-item gnus-article-sort-by-random)
747 (function :tag "other"))
748 (boolean :tag "Reverse order"))))
751 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
752 "*List of functions used for sorting threads in the summary buffer.
753 By default, threads are sorted by article number.
755 Each function takes two threads and returns non-nil if the first
756 thread should be sorted before the other. If you use more than one
757 function, the primary sort function should be the last. You should
758 probably always include `gnus-thread-sort-by-number' in the list of
759 sorting functions -- preferably first. Also note that sorting by date
760 is often much slower than sorting by number, and the sorting order is
761 very similar. (Sorting by date means sorting by the time the message
762 was sent, sorting by number means sorting by arrival time.)
764 Each list item can also be a list `(not F)' where F is a
765 function; this specifies reversed sort order.
767 Ready-made functions include `gnus-thread-sort-by-number',
768 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
769 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
770 `gnus-thread-sort-by-most-recent-number',
771 `gnus-thread-sort-by-most-recent-date',
772 `gnus-thread-sort-by-random', and
773 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
775 When threading is turned off, the variable
776 `gnus-article-sort-functions' controls how articles are sorted."
777 :group 'gnus-summary-sort
779 (gnus-widget-reversible
780 (choice (function-item gnus-thread-sort-by-number)
781 (function-item gnus-thread-sort-by-author)
782 (function-item gnus-thread-sort-by-subject)
783 (function-item gnus-thread-sort-by-date)
784 (function-item gnus-thread-sort-by-score)
785 (function-item gnus-thread-sort-by-most-recent-number)
786 (function-item gnus-thread-sort-by-most-recent-date)
787 (function-item gnus-thread-sort-by-random)
788 (function-item gnus-thread-sort-by-total-score)
789 (function :tag "other"))
790 (boolean :tag "Reverse order"))))
792 (defcustom gnus-thread-score-function '+
793 "*Function used for calculating the total score of a thread.
795 The function is called with the scores of the article and each
796 subthread and should then return the score of the thread.
798 Some functions you can use are `+', `max', or `min'."
799 :group 'gnus-summary-sort
802 (defcustom gnus-summary-expunge-below nil
803 "All articles that have a score less than this variable will be expunged.
804 This variable is local to the summary buffers."
805 :group 'gnus-score-default
806 :type '(choice (const :tag "off" nil)
809 (defcustom gnus-thread-expunge-below nil
810 "All threads that have a total score less than this variable will be expunged.
811 See `gnus-thread-score-function' for en explanation of what a
814 This variable is local to the summary buffers."
815 :group 'gnus-threading
816 :group 'gnus-score-default
817 :type '(choice (const :tag "off" nil)
820 (defcustom gnus-summary-mode-hook nil
821 "*A hook for Gnus summary mode.
822 This hook is run before any variables are set in the summary buffer."
823 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
824 :group 'gnus-summary-various
827 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
828 (when (featurep 'xemacs)
829 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
830 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
831 (add-hook 'gnus-summary-mode-hook
832 'gnus-xmas-switch-horizontal-scrollbar-off))
834 (defcustom gnus-summary-menu-hook nil
835 "*Hook run after the creation of the summary mode menu."
836 :group 'gnus-summary-visual
839 (defcustom gnus-summary-exit-hook nil
840 "*A hook called on exit from the summary buffer.
841 It will be called with point in the group buffer."
842 :group 'gnus-summary-exit
845 (defcustom gnus-summary-prepare-hook nil
846 "*A hook called after the summary buffer has been generated.
847 If you want to modify the summary buffer, you can use this hook."
848 :group 'gnus-summary-various
851 (defcustom gnus-summary-prepared-hook nil
852 "*A hook called as the last thing after the summary buffer has been generated."
853 :group 'gnus-summary-various
856 (defcustom gnus-summary-generate-hook nil
857 "*A hook run just before generating the summary buffer.
858 This hook is commonly used to customize threading variables and the
860 :group 'gnus-summary-various
863 (defcustom gnus-select-group-hook nil
864 "*A hook called when a newsgroup is selected.
866 If you'd like to simplify subjects like the
867 `gnus-summary-next-same-subject' command does, you can use the
870 (add-hook gnus-select-group-hook
872 (mapcar (lambda (header)
873 (mail-header-set-subject
875 (gnus-simplify-subject
876 (mail-header-subject header) 're-only)))
877 gnus-newsgroup-headers)))"
878 :group 'gnus-group-select
881 (defcustom gnus-select-article-hook nil
882 "*A hook called when an article is selected."
883 :group 'gnus-summary-choose
884 :options '(gnus-agent-fetch-selected-article)
887 (defcustom gnus-visual-mark-article-hook
888 (list 'gnus-highlight-selected-summary)
889 "*Hook run after selecting an article in the summary buffer.
890 It is meant to be used for highlighting the article in some way. It
891 is not run if `gnus-visual' is nil."
892 :group 'gnus-summary-visual
895 (defcustom gnus-parse-headers-hook nil
896 "*A hook called before parsing the headers."
900 (defcustom gnus-exit-group-hook nil
901 "*A hook called when exiting summary mode.
902 This hook is not called from the non-updating exit commands like `Q'."
906 (defcustom gnus-summary-update-hook
907 (list 'gnus-summary-highlight-line)
908 "*A hook called when a summary line is changed.
909 The hook will not be called if `gnus-visual' is nil.
911 The default function `gnus-summary-highlight-line' will
912 highlight the line according to the `gnus-summary-highlight'
914 :group 'gnus-summary-visual
917 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
918 "*A hook called when an article is selected for the first time.
919 The hook is intended to mark an article as read (or unread)
920 automatically when it is selected."
921 :group 'gnus-summary-choose
924 (defcustom gnus-group-no-more-groups-hook nil
925 "*A hook run when returning to group mode having no more (unread) groups."
926 :group 'gnus-group-select
929 (defcustom gnus-ps-print-hook nil
930 "*A hook run before ps-printing something from Gnus."
934 (defcustom gnus-summary-article-move-hook nil
935 "*A hook called after an article is moved, copied, respooled, or crossposted."
939 (defcustom gnus-summary-article-delete-hook nil
940 "*A hook called after an article is deleted."
944 (defcustom gnus-summary-article-expire-hook nil
945 "*A hook called after an article is expired."
949 (defcustom gnus-summary-display-arrow
950 (and (fboundp 'display-graphic-p)
952 "*If non-nil, display an arrow highlighting the current article."
957 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
958 "Face used for highlighting the current article in the summary buffer."
959 :group 'gnus-summary-visual
962 (defvar gnus-tmp-downloaded nil)
964 (defcustom gnus-summary-highlight
965 '(((eq mark gnus-canceled-mark)
966 . gnus-summary-cancelled-face)
967 ((and uncached (> score default-high))
968 . gnus-summary-high-undownloaded-face)
969 ((and uncached (< score default-low))
970 . gnus-summary-low-undownloaded-face)
972 . gnus-summary-normal-undownloaded-face)
973 ((and (> score default-high)
974 (or (eq mark gnus-dormant-mark)
975 (eq mark gnus-ticked-mark)))
976 . gnus-summary-high-ticked-face)
977 ((and (< score default-low)
978 (or (eq mark gnus-dormant-mark)
979 (eq mark gnus-ticked-mark)))
980 . gnus-summary-low-ticked-face)
981 ((or (eq mark gnus-dormant-mark)
982 (eq mark gnus-ticked-mark))
983 . gnus-summary-normal-ticked-face)
984 ((and (> score default-high) (eq mark gnus-ancient-mark))
985 . gnus-summary-high-ancient-face)
986 ((and (< score default-low) (eq mark gnus-ancient-mark))
987 . gnus-summary-low-ancient-face)
988 ((eq mark gnus-ancient-mark)
989 . gnus-summary-normal-ancient-face)
990 ((and (> score default-high) (eq mark gnus-unread-mark))
991 . gnus-summary-high-unread-face)
992 ((and (< score default-low) (eq mark gnus-unread-mark))
993 . gnus-summary-low-unread-face)
994 ((eq mark gnus-unread-mark)
995 . gnus-summary-normal-unread-face)
996 ((> score default-high)
997 . gnus-summary-high-read-face)
998 ((< score default-low)
999 . gnus-summary-low-read-face)
1001 . gnus-summary-normal-read-face))
1002 "*Controls the highlighting of summary buffer lines.
1004 A list of (FORM . FACE) pairs. When deciding how a a particular
1005 summary line should be displayed, each form is evaluated. The content
1006 of the face field after the first true form is used. You can change
1007 how those summary lines are displayed, by editing the face field.
1009 You can use the following variables in the FORM field.
1011 score: The article's score
1012 default: The default article score.
1013 default-high: The default score for high scored articles.
1014 default-low: The default score for low scored articles.
1015 below: The score below which articles are automatically marked as read.
1016 mark: The article's mark.
1017 uncached: Non-nil if the article is uncached."
1018 :group 'gnus-summary-visual
1019 :type '(repeat (cons (sexp :tag "Form" nil)
1022 (defcustom gnus-alter-header-function nil
1023 "Function called to allow alteration of article header structures.
1024 The function is called with one parameter, the article header vector,
1025 which it may alter in any way."
1026 :type '(choice (const :tag "None" nil)
1028 :group 'gnus-summary)
1030 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1031 "Variable that says which function should be used to decode a string with encoded words.")
1033 (defcustom gnus-extra-headers '(To Newsgroups)
1034 "*Extra headers to parse."
1036 :group 'gnus-summary
1037 :type '(repeat symbol))
1039 (defcustom gnus-ignored-from-addresses
1040 (and user-mail-address (regexp-quote user-mail-address))
1041 "*Regexp of From headers that may be suppressed in favor of To headers."
1043 :group 'gnus-summary
1046 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1047 "List of charsets that should be ignored.
1048 When these charsets are used in the \"charset\" parameter, the
1049 default charset will be used instead."
1051 :type '(repeat symbol)
1052 :group 'gnus-charset)
1054 (gnus-define-group-parameter
1058 "Return the ignored charsets of GROUP."
1059 :variable gnus-group-ignored-charsets-alist
1061 '(("alt\\.chinese\\.text" iso-8859-1))
1063 "Alist of regexps (to match group names) and charsets that should be ignored.
1064 When these charsets are used in the \"charset\" parameter, the
1065 default charset will be used instead."
1066 :variable-group gnus-charset
1067 :variable-type '(repeat (cons (regexp :tag "Group")
1069 :parameter-type '(choice :tag "Ignored charsets"
1072 :parameter-document "\
1073 List of charsets that should be ignored.
1075 When these charsets are used in the \"charset\" parameter, the
1076 default charset will be used instead.")
1078 (defcustom gnus-group-highlight-words-alist nil
1079 "Alist of group regexps and highlight regexps.
1080 This variable uses the same syntax as `gnus-emphasis-alist'."
1082 :type '(repeat (cons (regexp :tag "Group")
1083 (repeat (list (regexp :tag "Highlight regexp")
1084 (number :tag "Group for entire word" 0)
1085 (number :tag "Group for displayed part" 0)
1087 gnus-emphasis-highlight-words)))))
1088 :group 'gnus-summary-visual)
1090 (defcustom gnus-summary-show-article-charset-alist
1092 "Alist of number and charset.
1093 The article will be shown with the charset corresponding to the
1095 For example: ((1 . cn-gb-2312) (2 . big5))."
1097 :type '(repeat (cons (number :tag "Argument" 1)
1098 (symbol :tag "Charset")))
1099 :group 'gnus-charset)
1101 (defcustom gnus-preserve-marks t
1102 "Whether marks are preserved when moving, copying and respooling messages."
1105 :group 'gnus-summary-marks)
1107 (defcustom gnus-alter-articles-to-read-function nil
1108 "Function to be called to alter the list of articles to be selected."
1109 :type '(choice (const nil) function)
1110 :group 'gnus-summary)
1112 (defcustom gnus-orphan-score nil
1113 "*All orphans get this score added. Set in the score file."
1114 :group 'gnus-score-default
1115 :type '(choice (const nil)
1118 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1119 "*A regexp to match MIME parts when saving multiple parts of a
1120 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1121 This regexp will be used by default when prompting the user for which
1122 type of files to save."
1123 :group 'gnus-summary
1126 (defcustom gnus-read-all-available-headers nil
1127 "Whether Gnus should parse all headers made available to it.
1128 This is mostly relevant for slow back ends where the user may
1129 wish to widen the summary buffer to include all headers
1130 that were fetched. Say, for nnultimate groups."
1131 :group 'gnus-summary
1132 :type '(choice boolean regexp))
1134 (defcustom gnus-summary-muttprint-program "muttprint"
1135 "Command (and optional arguments) used to run Muttprint."
1137 :group 'gnus-summary
1140 (defcustom gnus-article-loose-mime nil
1141 "If non-nil, don't require MIME-Version header.
1142 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1143 supply the MIME-Version header or deliberately strip it From the mail.
1144 Set it to non-nil, Gnus will treat some articles as MIME even if
1145 the MIME-Version header is missed."
1148 :group 'gnus-article-mime)
1150 (defcustom gnus-article-emulate-mime t
1151 "If non-nil, use MIME emulation for uuencode and the like.
1152 This means that Gnus will search message bodies for text that look
1153 like uuencoded bits, yEncoded bits, and so on, and present that using
1154 the normal Gnus MIME machinery."
1156 :group 'gnus-article-mime)
1158 ;;; Internal variables
1160 (defvar gnus-summary-display-cache nil)
1161 (defvar gnus-article-mime-handles nil)
1162 (defvar gnus-article-decoded-p nil)
1163 (defvar gnus-article-charset nil)
1164 (defvar gnus-article-ignored-charsets nil)
1165 (defvar gnus-scores-exclude-files nil)
1166 (defvar gnus-page-broken nil)
1168 (defvar gnus-original-article nil)
1169 (defvar gnus-article-internal-prepare-hook nil)
1170 (defvar gnus-newsgroup-process-stack nil)
1172 (defvar gnus-thread-indent-array nil)
1173 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1174 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1175 "Function called to sort the articles within a thread after it has been gathered together.")
1177 (defvar gnus-summary-save-parts-type-history nil)
1178 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1180 ;; Avoid highlighting in kill files.
1181 (defvar gnus-summary-inhibit-highlight nil)
1182 (defvar gnus-newsgroup-selected-overlay nil)
1183 (defvar gnus-inhibit-limiting nil)
1184 (defvar gnus-newsgroup-adaptive-score-file nil)
1185 (defvar gnus-current-score-file nil)
1186 (defvar gnus-current-move-group nil)
1187 (defvar gnus-current-copy-group nil)
1188 (defvar gnus-current-crosspost-group nil)
1189 (defvar gnus-newsgroup-display nil)
1191 (defvar gnus-newsgroup-dependencies nil)
1192 (defvar gnus-newsgroup-adaptive nil)
1193 (defvar gnus-summary-display-article-function nil)
1194 (defvar gnus-summary-highlight-line-function nil
1195 "Function called after highlighting a summary line.")
1197 (defvar gnus-summary-line-format-alist
1198 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1199 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1200 (?s gnus-tmp-subject-or-nil ?s)
1201 (?n gnus-tmp-name ?s)
1202 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1204 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1206 (?F gnus-tmp-from ?s)
1207 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1208 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1209 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1210 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1211 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1212 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1213 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1214 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1215 (?L gnus-tmp-lines ?s)
1216 (?O gnus-tmp-downloaded ?c)
1217 (?I gnus-tmp-indentation ?s)
1218 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1219 (?R gnus-tmp-replied ?c)
1220 (?\[ gnus-tmp-opening-bracket ?c)
1221 (?\] gnus-tmp-closing-bracket ?c)
1222 (?\> (make-string gnus-tmp-level ? ) ?s)
1223 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1224 (?i gnus-tmp-score ?d)
1225 (?z gnus-tmp-score-char ?c)
1226 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1227 (?U gnus-tmp-unread ?c)
1228 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1230 (?t (gnus-summary-number-of-articles-in-thread
1231 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1233 (?e (gnus-summary-number-of-articles-in-thread
1234 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1236 (?u gnus-tmp-user-defined ?s)
1237 (?P (gnus-pick-line-number) ?d)
1238 (?B gnus-tmp-thread-tree-header-string ?s)
1239 (user-date (gnus-user-date
1240 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1241 "An alist of format specifications that can appear in summary lines.
1242 These are paired with what variables they correspond with, along with
1243 the type of the variable (string, integer, character, etc).")
1245 (defvar gnus-summary-dummy-line-format-alist
1246 `((?S gnus-tmp-subject ?s)
1247 (?N gnus-tmp-number ?d)
1248 (?u gnus-tmp-user-defined ?s)))
1250 (defvar gnus-summary-mode-line-format-alist
1251 `((?G gnus-tmp-group-name ?s)
1252 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1253 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1254 (?A gnus-tmp-article-number ?d)
1255 (?Z gnus-tmp-unread-and-unselected ?s)
1256 (?V gnus-version ?s)
1257 (?U gnus-tmp-unread-and-unticked ?d)
1258 (?S gnus-tmp-subject ?s)
1259 (?e gnus-tmp-unselected ?d)
1260 (?u gnus-tmp-user-defined ?s)
1261 (?d (length gnus-newsgroup-dormant) ?d)
1262 (?t (length gnus-newsgroup-marked) ?d)
1263 (?h (length gnus-newsgroup-spam-marked) ?d)
1264 (?r (length gnus-newsgroup-reads) ?d)
1265 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1266 (?E gnus-newsgroup-expunged-tally ?d)
1267 (?s (gnus-current-score-file-nondirectory) ?s)))
1269 (defvar gnus-last-search-regexp nil
1270 "Default regexp for article search command.")
1272 (defvar gnus-last-shell-command nil
1273 "Default shell command on article.")
1275 (defvar gnus-newsgroup-agentized nil
1276 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1277 (defvar gnus-newsgroup-begin nil)
1278 (defvar gnus-newsgroup-end nil)
1279 (defvar gnus-newsgroup-last-rmail nil)
1280 (defvar gnus-newsgroup-last-mail nil)
1281 (defvar gnus-newsgroup-last-folder nil)
1282 (defvar gnus-newsgroup-last-file nil)
1283 (defvar gnus-newsgroup-auto-expire nil)
1284 (defvar gnus-newsgroup-active nil)
1286 (defvar gnus-newsgroup-data nil)
1287 (defvar gnus-newsgroup-data-reverse nil)
1288 (defvar gnus-newsgroup-limit nil)
1289 (defvar gnus-newsgroup-limits nil)
1290 (defvar gnus-summary-use-undownloaded-faces nil)
1292 (defvar gnus-newsgroup-unreads nil
1293 "Sorted list of unread articles in the current newsgroup.")
1295 (defvar gnus-newsgroup-unselected nil
1296 "Sorted list of unselected unread articles in the current newsgroup.")
1298 (defvar gnus-newsgroup-reads nil
1299 "Alist of read articles and article marks in the current newsgroup.")
1301 (defvar gnus-newsgroup-expunged-tally nil)
1303 (defvar gnus-newsgroup-marked nil
1304 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1306 (defvar gnus-newsgroup-spam-marked nil
1307 "List of ranges of articles that have been marked as spam.")
1309 (defvar gnus-newsgroup-killed nil
1310 "List of ranges of articles that have been through the scoring process.")
1312 (defvar gnus-newsgroup-cached nil
1313 "Sorted list of articles that come from the article cache.")
1315 (defvar gnus-newsgroup-saved nil
1316 "List of articles that have been saved.")
1318 (defvar gnus-newsgroup-kill-headers nil)
1320 (defvar gnus-newsgroup-replied nil
1321 "List of articles that have been replied to in the current newsgroup.")
1323 (defvar gnus-newsgroup-forwarded nil
1324 "List of articles that have been forwarded in the current newsgroup.")
1326 (defvar gnus-newsgroup-recent nil
1327 "List of articles that have are recent in the current newsgroup.")
1329 (defvar gnus-newsgroup-expirable nil
1330 "Sorted list of articles in the current newsgroup that can be expired.")
1332 (defvar gnus-newsgroup-processable nil
1333 "List of articles in the current newsgroup that can be processed.")
1335 (defvar gnus-newsgroup-downloadable nil
1336 "Sorted list of articles in the current newsgroup that can be processed.")
1338 (defvar gnus-newsgroup-unfetched nil
1339 "Sorted list of articles in the current newsgroup whose headers have
1340 not been fetched into the agent.
1342 This list will always be a subset of gnus-newsgroup-undownloaded.")
1344 (defvar gnus-newsgroup-undownloaded nil
1345 "List of articles in the current newsgroup that haven't been downloaded.")
1347 (defvar gnus-newsgroup-unsendable nil
1348 "List of articles in the current newsgroup that won't be sent.")
1350 (defvar gnus-newsgroup-bookmarks nil
1351 "List of articles in the current newsgroup that have bookmarks.")
1353 (defvar gnus-newsgroup-dormant nil
1354 "Sorted list of dormant articles in the current newsgroup.")
1356 (defvar gnus-newsgroup-unseen nil
1357 "List of unseen articles in the current newsgroup.")
1359 (defvar gnus-newsgroup-seen nil
1360 "Range of seen articles in the current newsgroup.")
1362 (defvar gnus-newsgroup-articles nil
1363 "List of articles in the current newsgroup.")
1365 (defvar gnus-newsgroup-scored nil
1366 "List of scored articles in the current newsgroup.")
1368 (defvar gnus-newsgroup-headers nil
1369 "List of article headers in the current newsgroup.")
1371 (defvar gnus-newsgroup-threads nil)
1373 (defvar gnus-newsgroup-prepared nil
1374 "Whether the current group has been prepared properly.")
1376 (defvar gnus-newsgroup-ancient nil
1377 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1379 (defvar gnus-newsgroup-sparse nil)
1381 (defvar gnus-current-article nil)
1382 (defvar gnus-article-current nil)
1383 (defvar gnus-current-headers nil)
1384 (defvar gnus-have-all-headers nil)
1385 (defvar gnus-last-article nil)
1386 (defvar gnus-newsgroup-history nil)
1387 (defvar gnus-newsgroup-charset nil)
1388 (defvar gnus-newsgroup-ephemeral-charset nil)
1389 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1391 (defvar gnus-article-before-search nil)
1393 (defvar gnus-summary-local-variables
1394 '(gnus-newsgroup-name
1395 gnus-newsgroup-begin gnus-newsgroup-end
1396 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1397 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1398 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1399 gnus-newsgroup-unselected gnus-newsgroup-marked
1400 gnus-newsgroup-spam-marked
1401 gnus-newsgroup-reads gnus-newsgroup-saved
1402 gnus-newsgroup-replied gnus-newsgroup-forwarded
1403 gnus-newsgroup-recent
1404 gnus-newsgroup-expirable
1405 gnus-newsgroup-processable gnus-newsgroup-killed
1406 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1407 gnus-newsgroup-unfetched
1408 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1409 gnus-newsgroup-seen gnus-newsgroup-articles
1410 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1411 gnus-newsgroup-headers gnus-newsgroup-threads
1412 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1413 gnus-current-article gnus-current-headers gnus-have-all-headers
1414 gnus-last-article gnus-article-internal-prepare-hook
1415 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1416 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1417 gnus-thread-expunge-below
1418 gnus-score-alist gnus-current-score-file
1419 (gnus-summary-expunge-below . global)
1420 (gnus-summary-mark-below . global)
1421 (gnus-orphan-score . global)
1422 gnus-newsgroup-active gnus-scores-exclude-files
1423 gnus-newsgroup-history gnus-newsgroup-ancient
1424 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1425 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1426 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1427 (gnus-newsgroup-expunged-tally . 0)
1428 gnus-cache-removable-articles gnus-newsgroup-cached
1429 gnus-newsgroup-data gnus-newsgroup-data-reverse
1430 gnus-newsgroup-limit gnus-newsgroup-limits
1431 gnus-newsgroup-charset gnus-newsgroup-display
1432 gnus-summary-use-undownloaded-faces)
1433 "Variables that are buffer-local to the summary buffers.")
1435 (defvar gnus-newsgroup-variables nil
1436 "A list of variables that have separate values in different newsgroups.
1437 A list of newsgroup (summary buffer) local variables, or cons of
1438 variables and their default expressions to be evalled (when the default
1439 values are not nil), that should be made global while the summary buffer
1442 Note: The default expressions will be evaluated (using function `eval')
1443 before assignment to the local variable rather than just assigned to it.
1444 If the default expression is the symbol `global', that symbol will not
1445 be evaluated but the global value of the local variable will be used
1448 These variables can be used to set variables in the group parameters
1449 while still allowing them to affect operations done in other buffers.
1452 \(setq gnus-newsgroup-variables
1453 '(message-use-followup-to
1454 (gnus-visible-headers .
1455 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1458 ;; Byte-compiler warning.
1460 ;; Bind features so that require will believe that gnus-sum has
1461 ;; already been loaded (avoids infinite recursion)
1462 (let ((features (cons 'gnus-sum features)))
1463 ;; Several of the declarations in gnus-sum are needed to load the
1464 ;; following files. Right now, these definitions have been
1465 ;; compiled but not defined (evaluated). We could either do a
1466 ;; eval-and-compile about all of the declarations or evaluate the
1468 (if (boundp 'gnus-newsgroup-variables)
1470 (load "gnus-sum.el" t t t))
1472 (require 'gnus-agent)
1473 (require 'gnus-art)))
1477 (defvar gnus-decode-encoded-word-methods
1478 '(mail-decode-encoded-word-string)
1479 "List of methods used to decode encoded words.
1481 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1482 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1483 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1484 whose names match REGEXP.
1487 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1488 mail-decode-encoded-word-string
1489 (\"chinese\" . rfc1843-decode-string))")
1491 (defvar gnus-decode-encoded-word-methods-cache nil)
1493 (defun gnus-multi-decode-encoded-word-string (string)
1494 "Apply the functions from `gnus-encoded-word-methods' that match."
1495 (unless (and gnus-decode-encoded-word-methods-cache
1496 (eq gnus-newsgroup-name
1497 (car gnus-decode-encoded-word-methods-cache)))
1498 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1501 (nconc gnus-decode-encoded-word-methods-cache (list x))
1502 (if (and gnus-newsgroup-name
1503 (string-match (car x) gnus-newsgroup-name))
1504 (nconc gnus-decode-encoded-word-methods-cache
1506 gnus-decode-encoded-word-methods))
1507 (let ((xlist gnus-decode-encoded-word-methods-cache))
1510 (setq string (funcall (pop xlist) string))))
1513 ;; Subject simplification.
1515 (defun gnus-simplify-whitespace (str)
1516 "Remove excessive whitespace from STR."
1518 (while (string-match "[ \t][ \t]+" str)
1519 (setq str (concat (substring str 0 (match-beginning 0))
1521 (substring str (match-end 0)))))
1523 (when (string-match "^[ \t]+" str)
1524 (setq str (substring str (match-end 0))))
1526 (when (string-match "[ \t]+$" str)
1527 (setq str (substring str 0 (match-beginning 0))))
1530 (defun gnus-simplify-all-whitespace (str)
1531 "Remove all whitespace from STR."
1532 (while (string-match "[ \t\n]+" str)
1533 (setq str (replace-match "" nil nil str)))
1536 (defsubst gnus-simplify-subject-re (subject)
1537 "Remove \"Re:\" from subject lines."
1538 (if (string-match message-subject-re-regexp subject)
1539 (substring subject (match-end 0))
1542 (defun gnus-simplify-subject (subject &optional re-only)
1543 "Remove `Re:' and words in parentheses.
1544 If RE-ONLY is non-nil, strip leading `Re:'s only."
1545 (let ((case-fold-search t)) ;Ignore case.
1546 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1547 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1548 (setq subject (substring subject (match-end 0))))
1549 ;; Remove uninteresting prefixes.
1550 (when (and (not re-only)
1551 gnus-simplify-ignored-prefixes
1552 (string-match gnus-simplify-ignored-prefixes subject))
1553 (setq subject (substring subject (match-end 0))))
1554 ;; Remove words in parentheses from end.
1556 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1557 (setq subject (substring subject 0 (match-beginning 0)))))
1558 ;; Return subject string.
1561 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1563 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1564 (goto-char (point-min))
1565 (while (re-search-forward regexp nil t)
1566 (replace-match (or newtext ""))))
1568 (defun gnus-simplify-buffer-fuzzy ()
1569 "Simplify string in the buffer fuzzily.
1570 The string in the accessible portion of the current buffer is simplified.
1571 It is assumed to be a single-line subject.
1572 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1573 matter is removed. Additional things can be deleted by setting
1574 `gnus-simplify-subject-fuzzy-regexp'."
1575 (let ((case-fold-search t)
1577 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1579 (while (not (eq modified-tick (buffer-modified-tick)))
1580 (setq modified-tick (buffer-modified-tick))
1582 ((listp gnus-simplify-subject-fuzzy-regexp)
1583 (mapcar 'gnus-simplify-buffer-fuzzy-step
1584 gnus-simplify-subject-fuzzy-regexp))
1585 (gnus-simplify-subject-fuzzy-regexp
1586 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1587 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1588 (gnus-simplify-buffer-fuzzy-step
1589 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1590 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1592 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1593 (gnus-simplify-buffer-fuzzy-step " +" " ")
1594 (gnus-simplify-buffer-fuzzy-step " $")
1595 (gnus-simplify-buffer-fuzzy-step "^ +")))
1597 (defun gnus-simplify-subject-fuzzy (subject)
1598 "Simplify a subject string fuzzily.
1599 See `gnus-simplify-buffer-fuzzy' for details."
1601 (gnus-set-work-buffer)
1602 (let ((case-fold-search t))
1603 ;; Remove uninteresting prefixes.
1604 (when (and gnus-simplify-ignored-prefixes
1605 (string-match gnus-simplify-ignored-prefixes subject))
1606 (setq subject (substring subject (match-end 0))))
1608 (inline (gnus-simplify-buffer-fuzzy))
1611 (defsubst gnus-simplify-subject-fully (subject)
1612 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1614 (gnus-simplify-subject-functions
1615 (gnus-map-function gnus-simplify-subject-functions subject))
1616 ((null gnus-summary-gather-subject-limit)
1617 (gnus-simplify-subject-re subject))
1618 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1619 (gnus-simplify-subject-fuzzy subject))
1620 ((numberp gnus-summary-gather-subject-limit)
1621 (gnus-limit-string (gnus-simplify-subject-re subject)
1622 gnus-summary-gather-subject-limit))
1626 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1627 "Check whether two subjects are equal.
1628 If optional argument SIMPLE-FIRST is t, first argument is already
1631 ((null simple-first)
1632 (equal (gnus-simplify-subject-fully s1)
1633 (gnus-simplify-subject-fully s2)))
1636 (gnus-simplify-subject-fully s2)))))
1638 (defun gnus-summary-bubble-group ()
1639 "Increase the score of the current group.
1640 This is a handy function to add to `gnus-summary-exit-hook' to
1641 increase the score of each group you read."
1642 (gnus-group-add-score gnus-newsgroup-name))
1646 ;;; Gnus summary mode
1649 (put 'gnus-summary-mode 'mode-class 'special)
1651 (defvar gnus-article-commands-menu)
1653 ;; Non-orthogonal keys
1655 (gnus-define-keys gnus-summary-mode-map
1656 " " gnus-summary-next-page
1657 "\177" gnus-summary-prev-page
1658 [delete] gnus-summary-prev-page
1659 [backspace] gnus-summary-prev-page
1660 "\r" gnus-summary-scroll-up
1661 "\M-\r" gnus-summary-scroll-down
1662 "n" gnus-summary-next-unread-article
1663 "p" gnus-summary-prev-unread-article
1664 "N" gnus-summary-next-article
1665 "P" gnus-summary-prev-article
1666 "\M-\C-n" gnus-summary-next-same-subject
1667 "\M-\C-p" gnus-summary-prev-same-subject
1668 "\M-n" gnus-summary-next-unread-subject
1669 "\M-p" gnus-summary-prev-unread-subject
1670 "." gnus-summary-first-unread-article
1671 "," gnus-summary-best-unread-article
1672 "\M-s" gnus-summary-search-article-forward
1673 "\M-r" gnus-summary-search-article-backward
1674 "<" gnus-summary-beginning-of-article
1675 ">" gnus-summary-end-of-article
1676 "j" gnus-summary-goto-article
1677 "^" gnus-summary-refer-parent-article
1678 "\M-^" gnus-summary-refer-article
1679 "u" gnus-summary-tick-article-forward
1680 "!" gnus-summary-tick-article-forward
1681 "U" gnus-summary-tick-article-backward
1682 "d" gnus-summary-mark-as-read-forward
1683 "D" gnus-summary-mark-as-read-backward
1684 "E" gnus-summary-mark-as-expirable
1685 "\M-u" gnus-summary-clear-mark-forward
1686 "\M-U" gnus-summary-clear-mark-backward
1687 "k" gnus-summary-kill-same-subject-and-select
1688 "\C-k" gnus-summary-kill-same-subject
1689 "\M-\C-k" gnus-summary-kill-thread
1690 "\M-\C-l" gnus-summary-lower-thread
1691 "e" gnus-summary-edit-article
1692 "#" gnus-summary-mark-as-processable
1693 "\M-#" gnus-summary-unmark-as-processable
1694 "\M-\C-t" gnus-summary-toggle-threads
1695 "\M-\C-s" gnus-summary-show-thread
1696 "\M-\C-h" gnus-summary-hide-thread
1697 "\M-\C-f" gnus-summary-next-thread
1698 "\M-\C-b" gnus-summary-prev-thread
1699 [(meta down)] gnus-summary-next-thread
1700 [(meta up)] gnus-summary-prev-thread
1701 "\M-\C-u" gnus-summary-up-thread
1702 "\M-\C-d" gnus-summary-down-thread
1703 "&" gnus-summary-execute-command
1704 "c" gnus-summary-catchup-and-exit
1705 "\C-w" gnus-summary-mark-region-as-read
1706 "\C-t" gnus-summary-toggle-truncation
1707 "?" gnus-summary-mark-as-dormant
1708 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1709 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1710 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1711 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1712 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1713 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1714 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1715 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1716 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1717 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1718 "=" gnus-summary-expand-window
1719 "\C-x\C-s" gnus-summary-reselect-current-group
1720 "\M-g" gnus-summary-rescan-group
1721 "w" gnus-summary-stop-page-breaking
1722 "\C-c\C-r" gnus-summary-caesar-message
1723 "f" gnus-summary-followup
1724 "F" gnus-summary-followup-with-original
1725 "C" gnus-summary-cancel-article
1726 "r" gnus-summary-reply
1727 "R" gnus-summary-reply-with-original
1728 "\C-c\C-f" gnus-summary-mail-forward
1729 "o" gnus-summary-save-article
1730 "\C-o" gnus-summary-save-article-mail
1731 "|" gnus-summary-pipe-output
1732 "\M-k" gnus-summary-edit-local-kill
1733 "\M-K" gnus-summary-edit-global-kill
1735 "\C-c\C-d" gnus-summary-describe-group
1736 "q" gnus-summary-exit
1737 "Q" gnus-summary-exit-no-update
1738 "\C-c\C-i" gnus-info-find-node
1739 gnus-mouse-2 gnus-mouse-pick-article
1740 "m" gnus-summary-mail-other-window
1741 "a" gnus-summary-post-news
1742 "i" gnus-summary-news-other-window
1743 "x" gnus-summary-limit-to-unread
1744 "s" gnus-summary-isearch-article
1745 "t" gnus-summary-toggle-header
1746 "g" gnus-summary-show-article
1747 "l" gnus-summary-goto-last-article
1748 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1749 "\C-d" gnus-summary-enter-digest-group
1750 "\M-\C-d" gnus-summary-read-document
1751 "\M-\C-e" gnus-summary-edit-parameters
1752 "\M-\C-a" gnus-summary-customize-parameters
1754 "*" gnus-cache-enter-article
1755 "\M-*" gnus-cache-remove-article
1756 "\M-&" gnus-summary-universal-argument
1757 "\C-l" gnus-recenter
1758 "I" gnus-summary-increase-score
1759 "L" gnus-summary-lower-score
1760 "\M-i" gnus-symbolic-argument
1761 "h" gnus-summary-select-article-buffer
1763 "b" gnus-article-view-part
1764 "\M-t" gnus-summary-toggle-display-buttonized
1766 "V" gnus-summary-score-map
1767 "X" gnus-uu-extract-map
1768 "S" gnus-summary-send-map)
1770 ;; Sort of orthogonal keymap
1771 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1772 "t" gnus-summary-tick-article-forward
1773 "!" gnus-summary-tick-article-forward
1774 "d" gnus-summary-mark-as-read-forward
1775 "r" gnus-summary-mark-as-read-forward
1776 "c" gnus-summary-clear-mark-forward
1777 " " gnus-summary-clear-mark-forward
1778 "e" gnus-summary-mark-as-expirable
1779 "x" gnus-summary-mark-as-expirable
1780 "?" gnus-summary-mark-as-dormant
1781 "b" gnus-summary-set-bookmark
1782 "B" gnus-summary-remove-bookmark
1783 "#" gnus-summary-mark-as-processable
1784 "\M-#" gnus-summary-unmark-as-processable
1785 "S" gnus-summary-limit-include-expunged
1786 "C" gnus-summary-catchup
1787 "H" gnus-summary-catchup-to-here
1788 "h" gnus-summary-catchup-from-here
1789 "\C-c" gnus-summary-catchup-all
1790 "k" gnus-summary-kill-same-subject-and-select
1791 "K" gnus-summary-kill-same-subject
1792 "P" gnus-uu-mark-map)
1794 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1795 "c" gnus-summary-clear-above
1796 "u" gnus-summary-tick-above
1797 "m" gnus-summary-mark-above
1798 "k" gnus-summary-kill-below)
1800 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1801 "/" gnus-summary-limit-to-subject
1802 "n" gnus-summary-limit-to-articles
1803 "w" gnus-summary-pop-limit
1804 "s" gnus-summary-limit-to-subject
1805 "a" gnus-summary-limit-to-author
1806 "u" gnus-summary-limit-to-unread
1807 "m" gnus-summary-limit-to-marks
1808 "M" gnus-summary-limit-exclude-marks
1809 "v" gnus-summary-limit-to-score
1810 "*" gnus-summary-limit-include-cached
1811 "D" gnus-summary-limit-include-dormant
1812 "T" gnus-summary-limit-include-thread
1813 "d" gnus-summary-limit-exclude-dormant
1814 "t" gnus-summary-limit-to-age
1815 "." gnus-summary-limit-to-unseen
1816 "x" gnus-summary-limit-to-extra
1817 "p" gnus-summary-limit-to-display-predicate
1818 "E" gnus-summary-limit-include-expunged
1819 "c" gnus-summary-limit-exclude-childless-dormant
1820 "C" gnus-summary-limit-mark-excluded-as-read
1821 "o" gnus-summary-insert-old-articles
1822 "N" gnus-summary-insert-new-articles
1823 "r" gnus-summary-limit-to-replied)
1825 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1826 "n" gnus-summary-next-unread-article
1827 "p" gnus-summary-prev-unread-article
1828 "N" gnus-summary-next-article
1829 "P" gnus-summary-prev-article
1830 "\C-n" gnus-summary-next-same-subject
1831 "\C-p" gnus-summary-prev-same-subject
1832 "\M-n" gnus-summary-next-unread-subject
1833 "\M-p" gnus-summary-prev-unread-subject
1834 "f" gnus-summary-first-unread-article
1835 "b" gnus-summary-best-unread-article
1836 "j" gnus-summary-goto-article
1837 "g" gnus-summary-goto-subject
1838 "l" gnus-summary-goto-last-article
1839 "o" gnus-summary-pop-article)
1841 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1842 "k" gnus-summary-kill-thread
1843 "l" gnus-summary-lower-thread
1844 "i" gnus-summary-raise-thread
1845 "T" gnus-summary-toggle-threads
1846 "t" gnus-summary-rethread-current
1847 "^" gnus-summary-reparent-thread
1848 "s" gnus-summary-show-thread
1849 "S" gnus-summary-show-all-threads
1850 "h" gnus-summary-hide-thread
1851 "H" gnus-summary-hide-all-threads
1852 "n" gnus-summary-next-thread
1853 "p" gnus-summary-prev-thread
1854 "u" gnus-summary-up-thread
1855 "o" gnus-summary-top-thread
1856 "d" gnus-summary-down-thread
1857 "#" gnus-uu-mark-thread
1858 "\M-#" gnus-uu-unmark-thread)
1860 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1861 "g" gnus-summary-prepare
1862 "c" gnus-summary-insert-cached-articles
1863 "d" gnus-summary-insert-dormant-articles)
1865 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1866 "c" gnus-summary-catchup-and-exit
1867 "C" gnus-summary-catchup-all-and-exit
1868 "E" gnus-summary-exit-no-update
1869 "Q" gnus-summary-exit
1870 "Z" gnus-summary-exit
1871 "n" gnus-summary-catchup-and-goto-next-group
1872 "R" gnus-summary-reselect-current-group
1873 "G" gnus-summary-rescan-group
1874 "N" gnus-summary-next-group
1875 "s" gnus-summary-save-newsrc
1876 "P" gnus-summary-prev-group)
1878 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1879 " " gnus-summary-next-page
1880 "n" gnus-summary-next-page
1881 "\177" gnus-summary-prev-page
1882 [delete] gnus-summary-prev-page
1883 "p" gnus-summary-prev-page
1884 "\r" gnus-summary-scroll-up
1885 "\M-\r" gnus-summary-scroll-down
1886 "<" gnus-summary-beginning-of-article
1887 ">" gnus-summary-end-of-article
1888 "b" gnus-summary-beginning-of-article
1889 "e" gnus-summary-end-of-article
1890 "^" gnus-summary-refer-parent-article
1891 "r" gnus-summary-refer-parent-article
1892 "D" gnus-summary-enter-digest-group
1893 "R" gnus-summary-refer-references
1894 "T" gnus-summary-refer-thread
1895 "g" gnus-summary-show-article
1896 "s" gnus-summary-isearch-article
1897 "P" gnus-summary-print-article
1898 "M" gnus-mailing-list-insinuate
1899 "t" gnus-article-babel)
1901 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1902 "b" gnus-article-add-buttons
1903 "B" gnus-article-add-buttons-to-head
1904 "o" gnus-article-treat-overstrike
1905 "e" gnus-article-emphasize
1906 "w" gnus-article-fill-cited-article
1907 "Q" gnus-article-fill-long-lines
1908 "C" gnus-article-capitalize-sentences
1909 "c" gnus-article-remove-cr
1910 "q" gnus-article-de-quoted-unreadable
1911 "6" gnus-article-de-base64-unreadable
1912 "Z" gnus-article-decode-HZ
1913 "A" gnus-article-treat-ansi-sequences
1914 "h" gnus-article-wash-html
1915 "u" gnus-article-unsplit-urls
1916 "s" gnus-summary-force-verify-and-decrypt
1917 "f" gnus-article-display-x-face
1918 "l" gnus-summary-stop-page-breaking
1919 "r" gnus-summary-caesar-message
1920 "m" gnus-summary-morse-message
1921 "t" gnus-summary-toggle-header
1922 "g" gnus-treat-smiley
1923 "v" gnus-summary-verbose-headers
1924 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1925 "p" gnus-article-verify-x-pgp-sig
1926 "d" gnus-article-treat-dumbquotes)
1928 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1929 ;; mnemonic: deuglif*Y*
1930 "u" gnus-article-outlook-unwrap-lines
1931 "a" gnus-article-outlook-repair-attribution
1932 "c" gnus-article-outlook-rearrange-citation
1933 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1935 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1936 "a" gnus-article-hide
1937 "h" gnus-article-hide-headers
1938 "b" gnus-article-hide-boring-headers
1939 "s" gnus-article-hide-signature
1940 "c" gnus-article-hide-citation
1941 "C" gnus-article-hide-citation-in-followups
1942 "l" gnus-article-hide-list-identifiers
1943 "B" gnus-article-strip-banner
1944 "P" gnus-article-hide-pem
1945 "\C-c" gnus-article-hide-citation-maybe)
1947 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1948 "a" gnus-article-highlight
1949 "h" gnus-article-highlight-headers
1950 "c" gnus-article-highlight-citation
1951 "s" gnus-article-highlight-signature)
1953 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1954 "f" gnus-article-treat-fold-headers
1955 "u" gnus-article-treat-unfold-headers
1956 "n" gnus-article-treat-fold-newsgroups)
1958 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1959 "x" gnus-article-display-x-face
1960 "d" gnus-article-display-face
1961 "s" gnus-treat-smiley
1962 "D" gnus-article-remove-images
1963 "f" gnus-treat-from-picon
1964 "m" gnus-treat-mail-picon
1965 "n" gnus-treat-newsgroups-picon)
1967 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1968 "w" gnus-article-decode-mime-words
1969 "c" gnus-article-decode-charset
1970 "v" gnus-mime-view-all-parts
1971 "b" gnus-article-view-part)
1973 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1974 "z" gnus-article-date-ut
1975 "u" gnus-article-date-ut
1976 "l" gnus-article-date-local
1977 "p" gnus-article-date-english
1978 "e" gnus-article-date-lapsed
1979 "o" gnus-article-date-original
1980 "i" gnus-article-date-iso8601
1981 "s" gnus-article-date-user)
1983 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1984 "t" gnus-article-remove-trailing-blank-lines
1985 "l" gnus-article-strip-leading-blank-lines
1986 "m" gnus-article-strip-multiple-blank-lines
1987 "a" gnus-article-strip-blank-lines
1988 "A" gnus-article-strip-all-blank-lines
1989 "s" gnus-article-strip-leading-space
1990 "e" gnus-article-strip-trailing-space
1991 "w" gnus-article-remove-leading-whitespace)
1993 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1995 "f" gnus-summary-fetch-faq
1996 "d" gnus-summary-describe-group
1997 "h" gnus-summary-describe-briefly
1998 "i" gnus-info-find-node
1999 "c" gnus-group-fetch-charter
2000 "C" gnus-group-fetch-control)
2002 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2003 "e" gnus-summary-expire-articles
2004 "\M-\C-e" gnus-summary-expire-articles-now
2005 "\177" gnus-summary-delete-article
2006 [delete] gnus-summary-delete-article
2007 [backspace] gnus-summary-delete-article
2008 "m" gnus-summary-move-article
2009 "r" gnus-summary-respool-article
2010 "w" gnus-summary-edit-article
2011 "c" gnus-summary-copy-article
2012 "B" gnus-summary-crosspost-article
2013 "q" gnus-summary-respool-query
2014 "t" gnus-summary-respool-trace
2015 "i" gnus-summary-import-article
2016 "I" gnus-summary-create-article
2017 "p" gnus-summary-article-posted-p)
2019 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2020 "o" gnus-summary-save-article
2021 "m" gnus-summary-save-article-mail
2022 "F" gnus-summary-write-article-file
2023 "r" gnus-summary-save-article-rmail
2024 "f" gnus-summary-save-article-file
2025 "b" gnus-summary-save-article-body-file
2026 "h" gnus-summary-save-article-folder
2027 "v" gnus-summary-save-article-vm
2028 "p" gnus-summary-pipe-output
2029 "P" gnus-summary-muttprint
2030 "s" gnus-soup-add-article)
2032 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2033 "b" gnus-summary-display-buttonized
2034 "m" gnus-summary-repair-multipart
2035 "v" gnus-article-view-part
2036 "o" gnus-article-save-part
2037 "c" gnus-article-copy-part
2038 "C" gnus-article-view-part-as-charset
2039 "e" gnus-article-view-part-externally
2040 "E" gnus-article-encrypt-body
2041 "i" gnus-article-inline-part
2042 "|" gnus-article-pipe-part)
2044 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2045 "p" gnus-summary-mark-as-processable
2046 "u" gnus-summary-unmark-as-processable
2047 "U" gnus-summary-unmark-all-processable
2048 "v" gnus-uu-mark-over
2049 "s" gnus-uu-mark-series
2050 "r" gnus-uu-mark-region
2051 "g" gnus-uu-unmark-region
2052 "R" gnus-uu-mark-by-regexp
2053 "G" gnus-uu-unmark-by-regexp
2054 "t" gnus-uu-mark-thread
2055 "T" gnus-uu-unmark-thread
2056 "a" gnus-uu-mark-all
2057 "b" gnus-uu-mark-buffer
2058 "S" gnus-uu-mark-sparse
2059 "k" gnus-summary-kill-process-mark
2060 "y" gnus-summary-yank-process-mark
2061 "w" gnus-summary-save-process-mark
2062 "i" gnus-uu-invert-processable)
2064 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2065 ;;"x" gnus-uu-extract-any
2066 "m" gnus-summary-save-parts
2067 "u" gnus-uu-decode-uu
2068 "U" gnus-uu-decode-uu-and-save
2069 "s" gnus-uu-decode-unshar
2070 "S" gnus-uu-decode-unshar-and-save
2071 "o" gnus-uu-decode-save
2072 "O" gnus-uu-decode-save
2073 "b" gnus-uu-decode-binhex
2074 "B" gnus-uu-decode-binhex
2075 "p" gnus-uu-decode-postscript
2076 "P" gnus-uu-decode-postscript-and-save)
2079 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2080 "u" gnus-uu-decode-uu-view
2081 "U" gnus-uu-decode-uu-and-save-view
2082 "s" gnus-uu-decode-unshar-view
2083 "S" gnus-uu-decode-unshar-and-save-view
2084 "o" gnus-uu-decode-save-view
2085 "O" gnus-uu-decode-save-view
2086 "b" gnus-uu-decode-binhex-view
2087 "B" gnus-uu-decode-binhex-view
2088 "p" gnus-uu-decode-postscript-view
2089 "P" gnus-uu-decode-postscript-and-save-view)
2091 (defvar gnus-article-post-menu nil)
2093 (defconst gnus-summary-menu-maxlen 20)
2095 (defun gnus-summary-menu-split (menu)
2096 ;; If we have lots of elements, divide them into groups of 20
2097 ;; and make a pane (or submenu) for each one.
2098 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2099 (let ((menu menu) sublists next
2102 ;; Pull off the next gnus-summary-menu-maxlen elements
2103 ;; and make them the next element of sublist.
2104 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2106 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2108 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2109 (aref (car (last menu)) 0)) menu)
2113 (nreverse sublists))
2114 ;; Few elements--put them all in one pane.
2117 (defun gnus-summary-make-menu-bar ()
2118 (gnus-turn-off-edit-menu 'summary)
2120 (unless (boundp 'gnus-summary-misc-menu)
2123 gnus-summary-kill-menu gnus-summary-mode-map ""
2128 ["Customize" gnus-score-customize t])
2129 (gnus-make-score-map 'increase)
2130 (gnus-make-score-map 'lower)
2132 ["Kill below" gnus-summary-kill-below t]
2133 ["Mark above" gnus-summary-mark-above t]
2134 ["Tick above" gnus-summary-tick-above t]
2135 ["Clear above" gnus-summary-clear-above t])
2136 ["Current score" gnus-summary-current-score t]
2137 ["Set score" gnus-summary-set-score t]
2138 ["Switch current score file..." gnus-score-change-score-file t]
2139 ["Set mark below..." gnus-score-set-mark-below t]
2140 ["Set expunge below..." gnus-score-set-expunge-below t]
2141 ["Edit current score file" gnus-score-edit-current-scores t]
2142 ["Edit score file" gnus-score-edit-file t]
2143 ["Trace score" gnus-score-find-trace t]
2144 ["Find words" gnus-score-find-favourite-words t]
2145 ["Rescore buffer" gnus-summary-rescore t]
2146 ["Increase score..." gnus-summary-increase-score t]
2147 ["Lower score..." gnus-summary-lower-score t]))))
2149 ;; Define both the Article menu in the summary buffer and the
2150 ;; equivalent Commands menu in the article buffer here for
2154 ["All" gnus-article-hide t]
2155 ["Headers" gnus-article-hide-headers t]
2156 ["Signature" gnus-article-hide-signature t]
2157 ["Citation" gnus-article-hide-citation t]
2158 ["List identifiers" gnus-article-hide-list-identifiers t]
2159 ["Banner" gnus-article-strip-banner t]
2160 ["Boring headers" gnus-article-hide-boring-headers t])
2162 ["All" gnus-article-highlight t]
2163 ["Headers" gnus-article-highlight-headers t]
2164 ["Signature" gnus-article-highlight-signature t]
2165 ["Citation" gnus-article-highlight-citation t])
2167 ["Words" gnus-article-decode-mime-words t]
2168 ["Charset" gnus-article-decode-charset t]
2169 ["QP" gnus-article-de-quoted-unreadable t]
2170 ["Base64" gnus-article-de-base64-unreadable t]
2171 ["View MIME buttons" gnus-summary-display-buttonized t]
2172 ["View all" gnus-mime-view-all-parts t]
2173 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2174 ["Encrypt body" gnus-article-encrypt-body
2175 :active (not (gnus-group-read-only-p))
2176 ,@(if (featurep 'xemacs) nil
2177 '(:help "Encrypt the message body on disk"))]
2178 ["Extract all parts..." gnus-summary-save-parts t]
2180 ["Repair multipart" gnus-summary-repair-multipart t]
2181 ["Pipe part..." gnus-article-pipe-part t]
2182 ["Inline part" gnus-article-inline-part t]
2183 ["Encrypt body" gnus-article-encrypt-body
2184 :active (not (gnus-group-read-only-p))
2185 ,@(if (featurep 'xemacs) nil
2186 '(:help "Encrypt the message body on disk"))]
2187 ["View part externally" gnus-article-view-part-externally t]
2188 ["View part with charset..." gnus-article-view-part-as-charset t]
2189 ["Copy part" gnus-article-copy-part t]
2190 ["Save part..." gnus-article-save-part t]
2191 ["View part" gnus-article-view-part t]))
2193 ["Local" gnus-article-date-local t]
2194 ["ISO8601" gnus-article-date-iso8601 t]
2195 ["UT" gnus-article-date-ut t]
2196 ["Original" gnus-article-date-original t]
2197 ["Lapsed" gnus-article-date-lapsed t]
2198 ["User-defined" gnus-article-date-user t])
2200 ["Remove images" gnus-article-remove-images t]
2201 ["Toggle smiley" gnus-treat-smiley t]
2202 ["Show X-Face" gnus-article-display-x-face t]
2203 ["Show picons in From" gnus-treat-from-picon t]
2204 ["Show picons in mail headers" gnus-treat-mail-picon t]
2205 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2206 ("View as different encoding"
2207 ,@(gnus-summary-menu-split
2210 ;; Since easymenu under Emacs doesn't allow
2211 ;; lambda forms for menu commands, we should
2212 ;; provide intern'ed function symbols.
2213 (let ((command (intern (format "\
2214 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2218 (let ((gnus-summary-show-article-charset-alist
2220 (gnus-summary-show-article 1))))
2221 `[,(symbol-name cs) ,command t]))
2222 (sort (if (fboundp 'coding-system-list)
2223 (coding-system-list)
2224 (mapcar 'car mm-mime-mule-charset-alist))
2228 ["Leading" gnus-article-strip-leading-blank-lines t]
2229 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2230 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2231 ["All of the above" gnus-article-strip-blank-lines t]
2232 ["All" gnus-article-strip-all-blank-lines t]
2233 ["Leading space" gnus-article-strip-leading-space t]
2234 ["Trailing space" gnus-article-strip-trailing-space t]
2235 ["Leading space in headers"
2236 gnus-article-remove-leading-whitespace t])
2237 ["Overstrike" gnus-article-treat-overstrike t]
2238 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2239 ["Emphasis" gnus-article-emphasize t]
2240 ["Word wrap" gnus-article-fill-cited-article t]
2241 ["Fill long lines" gnus-article-fill-long-lines t]
2242 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2243 ["Remove CR" gnus-article-remove-cr t]
2244 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2245 ["Base64" gnus-article-de-base64-unreadable t]
2246 ["Rot 13" gnus-summary-caesar-message
2247 ,@(if (featurep 'xemacs) '(t)
2248 '(:help "\"Caesar rotate\" article by 13"))]
2249 ["Morse decode" gnus-summary-morse-message t]
2250 ["Unix pipe..." gnus-summary-pipe-message t]
2251 ["Add buttons" gnus-article-add-buttons t]
2252 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2253 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2254 ["Verbose header" gnus-summary-verbose-headers t]
2255 ["Toggle header" gnus-summary-toggle-header t]
2256 ["Unfold headers" gnus-article-treat-unfold-headers t]
2257 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2258 ["Html" gnus-article-wash-html t]
2259 ["Unsplit URLs" gnus-article-unsplit-urls t]
2260 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2261 ["Decode HZ" gnus-article-decode-HZ t]
2262 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2263 ("(Outlook) Deuglify"
2264 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2265 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2266 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2267 ["Full (Outlook) deuglify"
2268 gnus-article-outlook-deuglify-article t])
2271 ["Save in default format..." gnus-summary-save-article
2272 ,@(if (featurep 'xemacs) '(t)
2273 '(:help "Save article using default method"))]
2274 ["Save in file..." gnus-summary-save-article-file
2275 ,@(if (featurep 'xemacs) '(t)
2276 '(:help "Save article in file"))]
2277 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2278 ["Save in MH folder..." gnus-summary-save-article-folder t]
2279 ["Save in VM folder..." gnus-summary-save-article-vm t]
2280 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2281 ["Save body in file..." gnus-summary-save-article-body-file t]
2282 ["Pipe through a filter..." gnus-summary-pipe-output t]
2283 ["Add to SOUP packet" gnus-soup-add-article t]
2284 ["Print with Muttprint..." gnus-summary-muttprint t]
2285 ["Print" gnus-summary-print-article t])
2287 ["Respool article..." gnus-summary-respool-article t]
2288 ["Move article..." gnus-summary-move-article
2289 (gnus-check-backend-function
2290 'request-move-article gnus-newsgroup-name)]
2291 ["Copy article..." gnus-summary-copy-article t]
2292 ["Crosspost article..." gnus-summary-crosspost-article
2293 (gnus-check-backend-function
2294 'request-replace-article gnus-newsgroup-name)]
2295 ["Import file..." gnus-summary-import-article
2296 (gnus-check-backend-function
2297 'request-accept-article gnus-newsgroup-name)]
2298 ["Create article..." gnus-summary-create-article
2299 (gnus-check-backend-function
2300 'request-accept-article gnus-newsgroup-name)]
2301 ["Check if posted" gnus-summary-article-posted-p t]
2302 ["Edit article" gnus-summary-edit-article
2303 (not (gnus-group-read-only-p))]
2304 ["Delete article" gnus-summary-delete-article
2305 (gnus-check-backend-function
2306 'request-expire-articles gnus-newsgroup-name)]
2307 ["Query respool" gnus-summary-respool-query t]
2308 ["Trace respool" gnus-summary-respool-trace t]
2309 ["Delete expirable articles" gnus-summary-expire-articles-now
2310 (gnus-check-backend-function
2311 'request-expire-articles gnus-newsgroup-name)])
2313 ["Uudecode" gnus-uu-decode-uu
2314 ,@(if (featurep 'xemacs) '(t)
2315 '(:help "Decode uuencoded article(s)"))]
2316 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2317 ["Unshar" gnus-uu-decode-unshar t]
2318 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2319 ["Save" gnus-uu-decode-save t]
2320 ["Binhex" gnus-uu-decode-binhex t]
2321 ["Postscript" gnus-uu-decode-postscript t]
2322 ["All MIME parts" gnus-summary-save-parts t])
2324 ["Enter article" gnus-cache-enter-article t]
2325 ["Remove article" gnus-cache-remove-article t])
2326 ["Translate" gnus-article-babel t]
2327 ["Select article buffer" gnus-summary-select-article-buffer t]
2328 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2329 ["Isearch article..." gnus-summary-isearch-article t]
2330 ["Beginning of the article" gnus-summary-beginning-of-article t]
2331 ["End of the article" gnus-summary-end-of-article t]
2332 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2333 ["Fetch referenced articles" gnus-summary-refer-references t]
2334 ["Fetch current thread" gnus-summary-refer-thread t]
2335 ["Fetch article with id..." gnus-summary-refer-article t]
2336 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2337 ["Redisplay" gnus-summary-show-article t]
2338 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2340 gnus-summary-article-menu gnus-summary-mode-map ""
2341 (cons "Article" innards))
2343 (if (not (keymapp gnus-summary-article-menu))
2345 gnus-article-commands-menu gnus-article-mode-map ""
2346 (cons "Commands" innards))
2347 ;; in Emacs, don't share menu.
2348 (setq gnus-article-commands-menu
2349 (copy-keymap gnus-summary-article-menu))
2350 (define-key gnus-article-mode-map [menu-bar commands]
2351 (cons "Commands" gnus-article-commands-menu))))
2354 gnus-summary-thread-menu gnus-summary-mode-map ""
2356 ["Find all messages in thread" gnus-summary-refer-thread t]
2357 ["Toggle threading" gnus-summary-toggle-threads t]
2358 ["Hide threads" gnus-summary-hide-all-threads t]
2359 ["Show threads" gnus-summary-show-all-threads t]
2360 ["Hide thread" gnus-summary-hide-thread t]
2361 ["Show thread" gnus-summary-show-thread t]
2362 ["Go to next thread" gnus-summary-next-thread t]
2363 ["Go to previous thread" gnus-summary-prev-thread t]
2364 ["Go down thread" gnus-summary-down-thread t]
2365 ["Go up thread" gnus-summary-up-thread t]
2366 ["Top of thread" gnus-summary-top-thread t]
2367 ["Mark thread as read" gnus-summary-kill-thread t]
2368 ["Lower thread score" gnus-summary-lower-thread t]
2369 ["Raise thread score" gnus-summary-raise-thread t]
2370 ["Rethread current" gnus-summary-rethread-current t]))
2373 gnus-summary-post-menu gnus-summary-mode-map ""
2375 ["Send a message (mail or news)" gnus-summary-post-news
2376 ,@(if (featurep 'xemacs) '(t)
2377 '(:help "Post an article"))]
2378 ["Followup" gnus-summary-followup
2379 ,@(if (featurep 'xemacs) '(t)
2380 '(:help "Post followup to this article"))]
2381 ["Followup and yank" gnus-summary-followup-with-original
2382 ,@(if (featurep 'xemacs) '(t)
2383 '(:help "Post followup to this article, quoting its contents"))]
2384 ["Supersede article" gnus-summary-supersede-article t]
2385 ["Cancel article" gnus-summary-cancel-article
2386 ,@(if (featurep 'xemacs) '(t)
2387 '(:help "Cancel an article you posted"))]
2388 ["Reply" gnus-summary-reply t]
2389 ["Reply and yank" gnus-summary-reply-with-original t]
2390 ["Wide reply" gnus-summary-wide-reply t]
2391 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2392 ,@(if (featurep 'xemacs) '(t)
2393 '(:help "Mail a reply, quoting this article"))]
2394 ["Very wide reply" gnus-summary-very-wide-reply t]
2395 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2396 ,@(if (featurep 'xemacs) '(t)
2397 '(:help "Mail a very wide reply, quoting this article"))]
2398 ["Mail forward" gnus-summary-mail-forward t]
2399 ["Post forward" gnus-summary-post-forward t]
2400 ["Digest and mail" gnus-uu-digest-mail-forward t]
2401 ["Digest and post" gnus-uu-digest-post-forward t]
2402 ["Resend message" gnus-summary-resend-message t]
2403 ["Resend message edit" gnus-summary-resend-message-edit t]
2404 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2405 ["Send a mail" gnus-summary-mail-other-window t]
2406 ["Create a local message" gnus-summary-news-other-window t]
2407 ["Uuencode and post" gnus-uu-post-news
2408 ,@(if (featurep 'xemacs) '(t)
2409 '(:help "Post a uuencoded article"))]
2410 ["Followup via news" gnus-summary-followup-to-mail t]
2411 ["Followup via news and yank"
2412 gnus-summary-followup-to-mail-with-original t]
2414 ;;["Send" gnus-summary-send-draft t]
2415 ;;["Send bounced" gnus-resend-bounced-mail t])
2419 ((not (keymapp gnus-summary-post-menu))
2420 (setq gnus-article-post-menu gnus-summary-post-menu))
2421 ((not gnus-article-post-menu)
2422 ;; Don't share post menu.
2423 (setq gnus-article-post-menu
2424 (copy-keymap gnus-summary-post-menu))))
2425 (define-key gnus-article-mode-map [menu-bar post]
2426 (cons "Post" gnus-article-post-menu))
2429 gnus-summary-misc-menu gnus-summary-mode-map ""
2432 ["Mark as read" gnus-summary-mark-as-read-forward t]
2433 ["Mark same subject and select"
2434 gnus-summary-kill-same-subject-and-select t]
2435 ["Mark same subject" gnus-summary-kill-same-subject t]
2436 ["Catchup" gnus-summary-catchup
2437 ,@(if (featurep 'xemacs) '(t)
2438 '(:help "Mark unread articles in this group as read"))]
2439 ["Catchup all" gnus-summary-catchup-all t]
2440 ["Catchup to here" gnus-summary-catchup-to-here t]
2441 ["Catchup from here" gnus-summary-catchup-from-here t]
2442 ["Catchup region" gnus-summary-mark-region-as-read
2443 (gnus-mark-active-p)]
2444 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2446 ["Tick" gnus-summary-tick-article-forward t]
2447 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2448 ["Remove marks" gnus-summary-clear-mark-forward t]
2449 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2450 ["Set bookmark" gnus-summary-set-bookmark t]
2451 ["Remove bookmark" gnus-summary-remove-bookmark t])
2453 ["Marks..." gnus-summary-limit-to-marks t]
2454 ["Subject..." gnus-summary-limit-to-subject t]
2455 ["Author..." gnus-summary-limit-to-author t]
2456 ["Age..." gnus-summary-limit-to-age t]
2457 ["Extra..." gnus-summary-limit-to-extra t]
2458 ["Score..." gnus-summary-limit-to-score t]
2459 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2460 ["Unread" gnus-summary-limit-to-unread t]
2461 ["Unseen" gnus-summary-limit-to-unseen t]
2462 ["Replied" gnus-summary-limit-to-replied t]
2463 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2464 ["Next articles" gnus-summary-limit-to-articles t]
2465 ["Pop limit" gnus-summary-pop-limit t]
2466 ["Show dormant" gnus-summary-limit-include-dormant t]
2467 ["Hide childless dormant"
2468 gnus-summary-limit-exclude-childless-dormant t]
2469 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2470 ["Hide marked" gnus-summary-limit-exclude-marks t]
2471 ["Show expunged" gnus-summary-limit-include-expunged t])
2473 ["Set mark" gnus-summary-mark-as-processable t]
2474 ["Remove mark" gnus-summary-unmark-as-processable t]
2475 ["Remove all marks" gnus-summary-unmark-all-processable t]
2476 ["Mark above" gnus-uu-mark-over t]
2477 ["Mark series" gnus-uu-mark-series t]
2478 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2479 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2480 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2481 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2482 ["Mark all" gnus-uu-mark-all t]
2483 ["Mark buffer" gnus-uu-mark-buffer t]
2484 ["Mark sparse" gnus-uu-mark-sparse t]
2485 ["Mark thread" gnus-uu-mark-thread t]
2486 ["Unmark thread" gnus-uu-unmark-thread t]
2487 ("Process Mark Sets"
2488 ["Kill" gnus-summary-kill-process-mark t]
2489 ["Yank" gnus-summary-yank-process-mark
2490 gnus-newsgroup-process-stack]
2491 ["Save" gnus-summary-save-process-mark t]
2492 ["Run command on marked..." gnus-summary-universal-argument t]))
2494 ["Page forward" gnus-summary-next-page
2495 ,@(if (featurep 'xemacs) '(t)
2496 '(:help "Show next page of article"))]
2497 ["Page backward" gnus-summary-prev-page
2498 ,@(if (featurep 'xemacs) '(t)
2499 '(:help "Show previous page of article"))]
2500 ["Line forward" gnus-summary-scroll-up t])
2502 ["Next unread article" gnus-summary-next-unread-article t]
2503 ["Previous unread article" gnus-summary-prev-unread-article t]
2504 ["Next article" gnus-summary-next-article t]
2505 ["Previous article" gnus-summary-prev-article t]
2506 ["Next unread subject" gnus-summary-next-unread-subject t]
2507 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2508 ["Next article same subject" gnus-summary-next-same-subject t]
2509 ["Previous article same subject" gnus-summary-prev-same-subject t]
2510 ["First unread article" gnus-summary-first-unread-article t]
2511 ["Best unread article" gnus-summary-best-unread-article t]
2512 ["Go to subject number..." gnus-summary-goto-subject t]
2513 ["Go to article number..." gnus-summary-goto-article t]
2514 ["Go to the last article" gnus-summary-goto-last-article t]
2515 ["Pop article off history" gnus-summary-pop-article t])
2517 ["Sort by number" gnus-summary-sort-by-number t]
2518 ["Sort by author" gnus-summary-sort-by-author t]
2519 ["Sort by subject" gnus-summary-sort-by-subject t]
2520 ["Sort by date" gnus-summary-sort-by-date t]
2521 ["Sort by score" gnus-summary-sort-by-score t]
2522 ["Sort by lines" gnus-summary-sort-by-lines t]
2523 ["Sort by characters" gnus-summary-sort-by-chars t]
2524 ["Randomize" gnus-summary-sort-by-random t]
2525 ["Original sort" gnus-summary-sort-by-original t])
2527 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2528 ["Describe group" gnus-summary-describe-group t]
2529 ["Fetch charter" gnus-group-fetch-charter
2530 ,@(if (featurep 'xemacs) nil
2531 '(:help "Display the charter of the current group"))]
2532 ["Fetch control message" gnus-group-fetch-control
2533 ,@(if (featurep 'xemacs) nil
2534 '(:help "Display the archived control message for the current group"))]
2535 ["Read manual" gnus-info-find-node t])
2537 ["Pick and read" gnus-pick-mode t]
2538 ["Binary" gnus-binary-mode t])
2540 ["Regenerate" gnus-summary-prepare t]
2541 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2542 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2543 ["Toggle threading" gnus-summary-toggle-threads t])
2544 ["See old articles" gnus-summary-insert-old-articles t]
2545 ["See new articles" gnus-summary-insert-new-articles t]
2546 ["Filter articles..." gnus-summary-execute-command t]
2547 ["Run command on articles..." gnus-summary-universal-argument t]
2548 ["Search articles forward..." gnus-summary-search-article-forward t]
2549 ["Search articles backward..." gnus-summary-search-article-backward t]
2550 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2551 ["Expand window" gnus-summary-expand-window t]
2552 ["Expire expirable articles" gnus-summary-expire-articles
2553 (gnus-check-backend-function
2554 'request-expire-articles gnus-newsgroup-name)]
2555 ["Edit local kill file" gnus-summary-edit-local-kill t]
2556 ["Edit main kill file" gnus-summary-edit-global-kill t]
2557 ["Edit group parameters" gnus-summary-edit-parameters t]
2558 ["Customize group parameters" gnus-summary-customize-parameters t]
2559 ["Send a bug report" gnus-bug t]
2561 ["Catchup and exit" gnus-summary-catchup-and-exit
2562 ,@(if (featurep 'xemacs) '(t)
2563 '(:help "Mark unread articles in this group as read, then exit"))]
2564 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2565 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2566 ["Exit group" gnus-summary-exit
2567 ,@(if (featurep 'xemacs) '(t)
2568 '(:help "Exit current group, return to group selection mode"))]
2569 ["Exit group without updating" gnus-summary-exit-no-update t]
2570 ["Exit and goto next group" gnus-summary-next-group t]
2571 ["Exit and goto prev group" gnus-summary-prev-group t]
2572 ["Reselect group" gnus-summary-reselect-current-group t]
2573 ["Rescan group" gnus-summary-rescan-group t]
2574 ["Update dribble" gnus-summary-save-newsrc t])))
2576 (gnus-run-hooks 'gnus-summary-menu-hook)))
2578 (defvar gnus-summary-tool-bar-map nil)
2580 ;; Emacs 21 tool bar. Should be no-op otherwise.
2581 (defun gnus-summary-make-tool-bar ()
2582 (if (and (fboundp 'tool-bar-add-item-from-menu)
2583 (default-value 'tool-bar-mode)
2584 (not gnus-summary-tool-bar-map))
2585 (setq gnus-summary-tool-bar-map
2586 (let ((tool-bar-map (make-sparse-keymap))
2587 (load-path (mm-image-load-path)))
2588 (tool-bar-add-item-from-menu
2589 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2590 (tool-bar-add-item-from-menu
2591 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2592 (tool-bar-add-item-from-menu
2593 'gnus-summary-post-news "post" gnus-summary-mode-map)
2594 (tool-bar-add-item-from-menu
2595 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2596 (tool-bar-add-item-from-menu
2597 'gnus-summary-followup "followup" gnus-summary-mode-map)
2598 (tool-bar-add-item-from-menu
2599 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2600 (tool-bar-add-item-from-menu
2601 'gnus-summary-reply "reply" gnus-summary-mode-map)
2602 (tool-bar-add-item-from-menu
2603 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2604 (tool-bar-add-item-from-menu
2605 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2606 (tool-bar-add-item-from-menu
2607 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2608 (tool-bar-add-item-from-menu
2609 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2610 (tool-bar-add-item-from-menu
2611 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2612 (tool-bar-add-item-from-menu
2613 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2614 (tool-bar-add-item-from-menu
2615 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2616 (tool-bar-add-item-from-menu
2617 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2619 (if gnus-summary-tool-bar-map
2620 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2622 (defun gnus-score-set-default (var value)
2623 "A version of set that updates the GNU Emacs menu-bar."
2625 ;; It is the message that forces the active status to be updated.
2628 (defun gnus-make-score-map (type)
2629 "Make a summary score map of type TYPE."
2632 (let ((headers '(("author" "from" string)
2633 ("subject" "subject" string)
2634 ("article body" "body" string)
2635 ("article head" "head" string)
2636 ("xref" "xref" string)
2637 ("extra header" "extra" string)
2638 ("lines" "lines" number)
2639 ("followups to author" "followup" string)))
2640 (types '((number ("less than" <)
2643 (string ("substring" s)
2647 (perms '(("temporary" (current-time-string))
2655 (if (eq type 'lower)
2660 (setq header (car headers))
2666 (let ((ts (cdr (assoc (nth 2 header) types)))
2682 'gnus-summary-score-entry
2684 (if (or (string= (nth 1 header)
2686 (string= (nth 1 header)
2689 (list 'gnus-summary-header
2691 (list 'quote (nth 1 (car ts)))
2692 (list 'gnus-score-delta-default
2699 (list (nreverse outp))))
2702 (list (nreverse outt))))
2704 (setq headers (cdr headers)))
2705 (list (nreverse outh))))))))
2709 (defun gnus-summary-mode (&optional group)
2710 "Major mode for reading articles.
2712 All normal editing commands are switched off.
2713 \\<gnus-summary-mode-map>
2714 Each line in this buffer represents one article. To read an
2715 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2716 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2719 You can also post articles and send mail from this buffer. To
2720 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2721 of an article, type `\\[gnus-summary-reply]'.
2723 There are approx. one gazillion commands you can execute in this
2724 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2726 The following commands are available:
2728 \\{gnus-summary-mode-map}"
2730 (kill-all-local-variables)
2731 (when (gnus-visual-p 'summary-menu 'menu)
2732 (gnus-summary-make-menu-bar)
2733 (gnus-summary-make-tool-bar))
2734 (gnus-summary-make-local-variables)
2735 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2736 (gnus-summary-make-local-variables))
2737 (gnus-make-thread-indent-array)
2738 (gnus-simplify-mode-line)
2739 (setq major-mode 'gnus-summary-mode)
2740 (setq mode-name "Summary")
2741 (make-local-variable 'minor-mode-alist)
2742 (use-local-map gnus-summary-mode-map)
2743 (buffer-disable-undo)
2744 (setq buffer-read-only t) ;Disable modification
2745 (setq truncate-lines t)
2746 (setq selective-display t)
2747 (setq selective-display-ellipses t) ;Display `...'
2748 (gnus-summary-set-display-table)
2749 (gnus-set-default-directory)
2750 (setq gnus-newsgroup-name group)
2751 (make-local-variable 'gnus-summary-line-format)
2752 (make-local-variable 'gnus-summary-line-format-spec)
2753 (make-local-variable 'gnus-summary-dummy-line-format)
2754 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2755 (make-local-variable 'gnus-summary-mark-positions)
2756 (gnus-make-local-hook 'pre-command-hook)
2757 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2758 (gnus-run-hooks 'gnus-summary-mode-hook)
2759 (turn-on-gnus-mailing-list-mode)
2760 (mm-enable-multibyte)
2761 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2762 (gnus-update-summary-mark-positions))
2764 (defun gnus-summary-make-local-variables ()
2765 "Make all the local summary buffer variables."
2767 (dolist (local gnus-summary-local-variables)
2770 (if (eq (cdr local) 'global)
2771 ;; Copy the global value of the variable.
2772 (setq global (symbol-value (car local)))
2773 ;; Use the value from the list.
2774 (setq global (eval (cdr local))))
2775 (set (make-local-variable (car local)) global))
2776 ;; Simple nil-valued local variable.
2777 (set (make-local-variable local) nil)))))
2779 (defun gnus-summary-clear-local-variables ()
2780 (let ((locals gnus-summary-local-variables))
2782 (if (consp (car locals))
2783 (and (vectorp (caar locals))
2784 (set (caar locals) nil))
2785 (and (vectorp (car locals))
2786 (set (car locals) nil)))
2787 (setq locals (cdr locals)))))
2789 ;; Summary data functions.
2791 (defmacro gnus-data-number (data)
2794 (defmacro gnus-data-set-number (data number)
2795 `(setcar ,data ,number))
2797 (defmacro gnus-data-mark (data)
2800 (defmacro gnus-data-set-mark (data mark)
2801 `(setcar (nthcdr 1 ,data) ,mark))
2803 (defmacro gnus-data-pos (data)
2806 (defmacro gnus-data-set-pos (data pos)
2807 `(setcar (nthcdr 2 ,data) ,pos))
2809 (defmacro gnus-data-header (data)
2812 (defmacro gnus-data-set-header (data header)
2813 `(setf (nth 3 ,data) ,header))
2815 (defmacro gnus-data-level (data)
2818 (defmacro gnus-data-unread-p (data)
2819 `(= (nth 1 ,data) gnus-unread-mark))
2821 (defmacro gnus-data-read-p (data)
2822 `(/= (nth 1 ,data) gnus-unread-mark))
2824 (defmacro gnus-data-pseudo-p (data)
2825 `(consp (nth 3 ,data)))
2827 (defmacro gnus-data-find (number)
2828 `(assq ,number gnus-newsgroup-data))
2830 (defmacro gnus-data-find-list (number &optional data)
2831 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2832 (memq (assq ,number bdata)
2835 (defmacro gnus-data-make (number mark pos header level)
2836 `(list ,number ,mark ,pos ,header ,level))
2838 (defun gnus-data-enter (after-article number mark pos header level offset)
2839 (let ((data (gnus-data-find-list after-article)))
2841 (error "No such article: %d" after-article))
2842 (setcdr data (cons (gnus-data-make number mark pos header level)
2844 (setq gnus-newsgroup-data-reverse nil)
2845 (gnus-data-update-list (cddr data) offset)))
2847 (defun gnus-data-enter-list (after-article list &optional offset)
2849 (let ((data (and after-article (gnus-data-find-list after-article)))
2853 (let ((odata gnus-newsgroup-data))
2854 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2856 (gnus-data-update-list odata offset)))
2857 ;; Find the last element in the list to be spliced into the main
2860 (setq list (cdr list)))
2863 (setcdr list gnus-newsgroup-data)
2864 (setq gnus-newsgroup-data ilist)
2866 (gnus-data-update-list (cdr list) offset)))
2867 (setcdr list (cdr data))
2870 (gnus-data-update-list (cdr list) offset))))
2871 (setq gnus-newsgroup-data-reverse nil))))
2873 (defun gnus-data-remove (article &optional offset)
2874 (let ((data gnus-newsgroup-data))
2875 (if (= (gnus-data-number (car data)) article)
2877 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2878 gnus-newsgroup-data-reverse nil)
2880 (gnus-data-update-list gnus-newsgroup-data offset)))
2882 (when (= (gnus-data-number (cadr data)) article)
2883 (setcdr data (cddr data))
2885 (gnus-data-update-list (cdr data) offset))
2887 gnus-newsgroup-data-reverse nil))
2888 (setq data (cdr data))))))
2890 (defmacro gnus-data-list (backward)
2892 (or gnus-newsgroup-data-reverse
2893 (setq gnus-newsgroup-data-reverse
2894 (reverse gnus-newsgroup-data)))
2895 gnus-newsgroup-data))
2897 (defun gnus-data-update-list (data offset)
2898 "Add OFFSET to the POS of all data entries in DATA."
2899 (setq gnus-newsgroup-data-reverse nil)
2901 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2902 (setq data (cdr data))))
2904 (defun gnus-summary-article-pseudo-p (article)
2905 "Say whether this article is a pseudo article or not."
2906 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2908 (defmacro gnus-summary-article-sparse-p (article)
2909 "Say whether this article is a sparse article or not."
2910 `(memq ,article gnus-newsgroup-sparse))
2912 (defmacro gnus-summary-article-ancient-p (article)
2913 "Say whether this article is a sparse article or not."
2914 `(memq ,article gnus-newsgroup-ancient))
2916 (defun gnus-article-parent-p (number)
2917 "Say whether this article is a parent or not."
2918 (let ((data (gnus-data-find-list number)))
2919 (and (cdr data) ; There has to be an article after...
2920 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2921 (gnus-data-level (nth 1 data))))))
2923 (defun gnus-article-children (number)
2924 "Return a list of all children to NUMBER."
2925 (let* ((data (gnus-data-find-list number))
2926 (level (gnus-data-level (car data)))
2928 (setq data (cdr data))
2930 (= (gnus-data-level (car data)) (1+ level)))
2931 (push (gnus-data-number (car data)) children)
2932 (setq data (cdr data)))
2935 (defmacro gnus-summary-skip-intangible ()
2936 "If the current article is intangible, then jump to a different article."
2937 '(let ((to (get-text-property (point) 'gnus-intangible)))
2938 (and to (gnus-summary-goto-subject to))))
2940 (defmacro gnus-summary-article-intangible-p ()
2941 "Say whether this article is intangible or not."
2942 '(get-text-property (point) 'gnus-intangible))
2944 (defun gnus-article-read-p (article)
2945 "Say whether ARTICLE is read or not."
2946 (not (or (memq article gnus-newsgroup-marked)
2947 (memq article gnus-newsgroup-spam-marked)
2948 (memq article gnus-newsgroup-unreads)
2949 (memq article gnus-newsgroup-unselected)
2950 (memq article gnus-newsgroup-dormant))))
2952 ;; Some summary mode macros.
2954 (defmacro gnus-summary-article-number ()
2955 "The article number of the article on the current line.
2956 If there isn't an article number here, then we return the current
2959 (gnus-summary-skip-intangible)
2960 (or (get-text-property (point) 'gnus-number)
2961 (gnus-summary-last-subject))))
2963 (defmacro gnus-summary-article-header (&optional number)
2964 "Return the header of article NUMBER."
2965 `(gnus-data-header (gnus-data-find
2966 ,(or number '(gnus-summary-article-number)))))
2968 (defmacro gnus-summary-thread-level (&optional number)
2969 "Return the level of thread that starts with article NUMBER."
2970 `(if (and (eq gnus-summary-make-false-root 'dummy)
2971 (get-text-property (point) 'gnus-intangible))
2973 (gnus-data-level (gnus-data-find
2974 ,(or number '(gnus-summary-article-number))))))
2976 (defmacro gnus-summary-article-mark (&optional number)
2977 "Return the mark of article NUMBER."
2978 `(gnus-data-mark (gnus-data-find
2979 ,(or number '(gnus-summary-article-number)))))
2981 (defmacro gnus-summary-article-pos (&optional number)
2982 "Return the position of the line of article NUMBER."
2983 `(gnus-data-pos (gnus-data-find
2984 ,(or number '(gnus-summary-article-number)))))
2986 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2987 (defmacro gnus-summary-article-subject (&optional number)
2988 "Return current subject string or nil if nothing."
2991 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2992 '(gnus-data-header (assq (gnus-summary-article-number)
2993 gnus-newsgroup-data)))))
2996 (mail-header-subject headers))))
2998 (defmacro gnus-summary-article-score (&optional number)
2999 "Return current article score."
3000 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3001 gnus-newsgroup-scored))
3002 gnus-summary-default-score 0))
3004 (defun gnus-summary-article-children (&optional number)
3005 "Return a list of article numbers that are children of article NUMBER."
3006 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3007 (level (gnus-data-level (car data)))
3009 (while (and (setq data (cdr data))
3010 (> (setq l (gnus-data-level (car data))) level))
3011 (and (= (1+ level) l)
3012 (push (gnus-data-number (car data))
3014 (nreverse children)))
3016 (defun gnus-summary-article-parent (&optional number)
3017 "Return the article number of the parent of article NUMBER."
3018 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3019 (gnus-data-list t)))
3020 (level (gnus-data-level (car data))))
3022 () ; This is a root.
3023 ;; We search until we find an article with a level less than
3024 ;; this one. That function has to be the parent.
3025 (while (and (setq data (cdr data))
3026 (not (< (gnus-data-level (car data)) level))))
3027 (and data (gnus-data-number (car data))))))
3029 (defun gnus-unread-mark-p (mark)
3030 "Say whether MARK is the unread mark."
3031 (= mark gnus-unread-mark))
3033 (defun gnus-read-mark-p (mark)
3034 "Say whether MARK is one of the marks that mark as read.
3035 This is all marks except unread, ticked, dormant, and expirable."
3036 (not (or (= mark gnus-unread-mark)
3037 (= mark gnus-ticked-mark)
3038 (= mark gnus-spam-mark)
3039 (= mark gnus-dormant-mark)
3040 (= mark gnus-expirable-mark))))
3042 (defmacro gnus-article-mark (number)
3043 "Return the MARK of article NUMBER.
3044 This macro should only be used when computing the mark the \"first\"
3045 time; i.e., when generating the summary lines. After that,
3046 `gnus-summary-article-mark' should be used to examine the
3049 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3050 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3051 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3052 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3053 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3054 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3055 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3056 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3057 gnus-ancient-mark))))
3059 ;; Saving hidden threads.
3061 (defmacro gnus-save-hidden-threads (&rest forms)
3062 "Save hidden threads, eval FORMS, and restore the hidden threads."
3063 (let ((config (make-symbol "config")))
3064 `(let ((,config (gnus-hidden-threads-configuration)))
3068 (gnus-restore-hidden-threads-configuration ,config)))))
3069 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3070 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3072 (defun gnus-data-compute-positions ()
3073 "Compute the positions of all articles."
3074 (setq gnus-newsgroup-data-reverse nil)
3075 (let ((data gnus-newsgroup-data))
3077 (gnus-save-hidden-threads
3078 (gnus-summary-show-all-threads)
3079 (goto-char (point-min))
3081 (while (get-text-property (point) 'gnus-intangible)
3083 (gnus-data-set-pos (car data) (+ (point) 3))
3084 (setq data (cdr data))
3085 (forward-line 1))))))
3087 (defun gnus-hidden-threads-configuration ()
3088 "Return the current hidden threads configuration."
3091 (goto-char (point-min))
3092 (while (search-forward "\r" nil t)
3093 (push (1- (point)) config))
3096 (defun gnus-restore-hidden-threads-configuration (config)
3097 "Restore hidden threads configuration from CONFIG."
3099 (let (point buffer-read-only)
3100 (while (setq point (pop config))
3101 (when (and (< point (point-max))
3103 (eq (char-after) ?\n))
3104 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3106 ;; Various summary mode internalish functions.
3108 (defun gnus-mouse-pick-article (e)
3111 (gnus-summary-next-page nil t))
3113 (defun gnus-summary-set-display-table ()
3114 "Change the display table.
3115 Odd characters have a tendency to mess
3116 up nicely formatted displays - we make all possible glyphs
3117 display only a single character."
3119 ;; We start from the standard display table, if any.
3120 (let ((table (or (copy-sequence standard-display-table)
3121 (make-display-table)))
3123 ;; Nix out all the control chars...
3124 (while (>= (setq i (1- i)) 0)
3125 (aset table i [??]))
3126 ;; ... but not newline and cr, of course. (cr is necessary for the
3127 ;; selective display).
3128 (aset table ?\n nil)
3129 (aset table ?\r nil)
3130 ;; We keep TAB as well.
3131 (aset table ?\t nil)
3132 ;; We nix out any glyphs over 126 that are not set already.
3134 (while (>= (setq i (1- i)) 127)
3135 ;; Only modify if the entry is nil.
3136 (unless (aref table i)
3137 (aset table i [??]))))
3138 (setq buffer-display-table table)))
3140 (defun gnus-summary-set-article-display-arrow (pos)
3141 "Update the overlay arrow to point to line at position POS."
3142 (when (and gnus-summary-display-arrow
3143 (boundp 'overlay-arrow-position)
3144 (boundp 'overlay-arrow-string))
3148 (unless overlay-arrow-position
3149 (setq overlay-arrow-position (make-marker)))
3150 (setq overlay-arrow-string "=>"
3151 overlay-arrow-position (set-marker overlay-arrow-position
3153 (current-buffer))))))
3155 (defun gnus-summary-setup-buffer (group)
3156 "Initialize summary buffer."
3157 (let ((buffer (gnus-summary-buffer-name group))
3158 (dead-name (concat "*Dead Summary "
3159 (gnus-group-decoded-name group) "*")))
3160 ;; If a dead summary buffer exists, we kill it.
3161 (when (gnus-buffer-live-p dead-name)
3162 (gnus-kill-buffer dead-name))
3163 (if (get-buffer buffer)
3166 (setq gnus-summary-buffer (current-buffer))
3167 (not gnus-newsgroup-prepared))
3168 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3169 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3170 (gnus-summary-mode group)
3172 (gnus-carpal-setup-buffer 'summary))
3173 (unless gnus-single-article-buffer
3174 (make-local-variable 'gnus-article-buffer)
3175 (make-local-variable 'gnus-article-current)
3176 (make-local-variable 'gnus-original-article-buffer))
3177 (setq gnus-newsgroup-name group)
3178 ;; Set any local variables in the group parameters.
3179 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3182 (defun gnus-set-global-variables ()
3183 "Set the global equivalents of the buffer-local variables.
3184 They are set to the latest values they had. These reflect the summary
3185 buffer that was in action when the last article was fetched."
3186 (when (eq major-mode 'gnus-summary-mode)
3187 (setq gnus-summary-buffer (current-buffer))
3188 (let ((name gnus-newsgroup-name)
3189 (marked gnus-newsgroup-marked)
3190 (spam gnus-newsgroup-spam-marked)
3191 (unread gnus-newsgroup-unreads)
3192 (headers gnus-current-headers)
3193 (data gnus-newsgroup-data)
3194 (summary gnus-summary-buffer)
3195 (article-buffer gnus-article-buffer)
3196 (original gnus-original-article-buffer)
3197 (gac gnus-article-current)
3198 (reffed gnus-reffed-article-number)
3199 (score-file gnus-current-score-file)
3200 (default-charset gnus-newsgroup-charset)
3202 (let ((locals gnus-newsgroup-variables))
3204 (if (consp (car locals))
3205 (push (eval (caar locals)) vlist)
3206 (push (eval (car locals)) vlist))
3207 (setq locals (cdr locals)))
3208 (setq vlist (nreverse vlist)))
3209 (with-current-buffer gnus-group-buffer
3210 (setq gnus-newsgroup-name name
3211 gnus-newsgroup-marked marked
3212 gnus-newsgroup-spam-marked spam
3213 gnus-newsgroup-unreads unread
3214 gnus-current-headers headers
3215 gnus-newsgroup-data data
3216 gnus-article-current gac
3217 gnus-summary-buffer summary
3218 gnus-article-buffer article-buffer
3219 gnus-original-article-buffer original
3220 gnus-reffed-article-number reffed
3221 gnus-current-score-file score-file
3222 gnus-newsgroup-charset default-charset)
3223 (let ((locals gnus-newsgroup-variables))
3225 (if (consp (car locals))
3226 (set (caar locals) (pop vlist))
3227 (set (car locals) (pop vlist)))
3228 (setq locals (cdr locals))))
3229 ;; The article buffer also has local variables.
3230 (when (gnus-buffer-live-p gnus-article-buffer)
3231 (set-buffer gnus-article-buffer)
3232 (setq gnus-summary-buffer summary))))))
3234 (defun gnus-summary-article-unread-p (article)
3235 "Say whether ARTICLE is unread or not."
3236 (memq article gnus-newsgroup-unreads))
3238 (defun gnus-summary-first-article-p (&optional article)
3239 "Return whether ARTICLE is the first article in the buffer."
3240 (if (not (setq article (or article (gnus-summary-article-number))))
3242 (eq article (caar gnus-newsgroup-data))))
3244 (defun gnus-summary-last-article-p (&optional article)
3245 "Return whether ARTICLE is the last article in the buffer."
3246 (if (not (setq article (or article (gnus-summary-article-number))))
3247 ;; All non-existent numbers are the last article. :-)
3249 (not (cdr (gnus-data-find-list article)))))
3251 (defun gnus-make-thread-indent-array ()
3253 (unless (and gnus-thread-indent-array
3254 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3255 (setq gnus-thread-indent-array (make-vector 201 "")
3256 gnus-thread-indent-array-level gnus-thread-indent-level)
3258 (aset gnus-thread-indent-array n
3259 (make-string (* n gnus-thread-indent-level) ? ))
3262 (defun gnus-update-summary-mark-positions ()
3263 "Compute where the summary marks are to go."
3265 (when (gnus-buffer-exists-p gnus-summary-buffer)
3266 (set-buffer gnus-summary-buffer))
3267 (let ((gnus-replied-mark 129)
3268 (gnus-score-below-mark 130)
3269 (gnus-score-over-mark 130)
3270 (gnus-undownloaded-mark 131)
3271 (spec gnus-summary-line-format-spec)
3274 (gnus-set-work-buffer)
3275 (let ((gnus-summary-line-format-spec spec)
3276 (gnus-newsgroup-downloadable '(0)))
3277 (gnus-summary-insert-line
3278 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3279 0 nil t 128 t nil "" nil 1)
3280 (goto-char (point-min))
3281 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3282 (- (point) (point-min) 1)))))
3283 (goto-char (point-min))
3284 (push (cons 'replied (and (search-forward "\201" nil t)
3285 (- (point) (point-min) 1)))
3287 (goto-char (point-min))
3288 (push (cons 'score (and (search-forward "\202" nil t)
3289 (- (point) (point-min) 1)))
3291 (goto-char (point-min))
3292 (push (cons 'download
3293 (and (search-forward "\203" nil t)
3294 (- (point) (point-min) 1)))
3296 (setq gnus-summary-mark-positions pos))))
3298 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3299 "Insert a dummy root in the summary buffer."
3301 (gnus-add-text-properties
3302 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3303 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3305 (defun gnus-summary-extract-address-component (from)
3306 (or (car (funcall gnus-extract-address-components from))
3309 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3310 (let ((mail-parse-charset gnus-newsgroup-charset)
3311 ; Is it really necessary to do this next part for each summary line?
3312 ; Luckily, doesn't seem to slow things down much.
3313 (mail-parse-ignored-charsets
3314 (with-current-buffer gnus-summary-buffer
3315 gnus-newsgroup-ignored-charsets)))
3317 (and gnus-ignored-from-addresses
3318 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3319 (let ((extra-headers (mail-header-extra header))
3323 ((setq to (cdr (assq 'To extra-headers)))
3326 (gnus-summary-extract-address-component
3327 (funcall gnus-decode-encoded-word-function to)))))
3328 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3329 (concat "=> " newsgroups)))))
3330 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3332 (defun gnus-summary-insert-line (gnus-tmp-header
3333 gnus-tmp-level gnus-tmp-current
3334 undownloaded gnus-tmp-unread gnus-tmp-replied
3335 gnus-tmp-expirable gnus-tmp-subject-or-nil
3336 &optional gnus-tmp-dummy gnus-tmp-score
3338 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3339 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3340 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3341 (gnus-tmp-score-char
3342 (if (or (null gnus-summary-default-score)
3343 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3344 gnus-summary-zcore-fuzz))
3346 (if (< gnus-tmp-score gnus-summary-default-score)
3347 gnus-score-below-mark gnus-score-over-mark)))
3348 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3350 (cond (gnus-tmp-process gnus-process-mark)
3351 ((memq gnus-tmp-current gnus-newsgroup-cached)
3353 (gnus-tmp-replied gnus-replied-mark)
3354 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3355 gnus-forwarded-mark)
3356 ((memq gnus-tmp-current gnus-newsgroup-saved)
3358 ((memq gnus-tmp-number gnus-newsgroup-recent)
3360 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3363 (gnus-tmp-downloaded
3365 gnus-undownloaded-mark)
3366 (gnus-newsgroup-agentized
3367 gnus-downloaded-mark)
3370 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3373 ((string-match "<[^>]+> *$" gnus-tmp-from)
3374 (let ((beg (match-beginning 0)))
3375 (or (and (string-match "^\".+\"" gnus-tmp-from)
3376 (substring gnus-tmp-from 1 (1- (match-end 0))))
3377 (substring gnus-tmp-from 0 beg))))
3378 ((string-match "(.+)" gnus-tmp-from)
3379 (substring gnus-tmp-from
3380 (1+ (match-beginning 0)) (1- (match-end 0))))
3382 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3383 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3384 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3385 (buffer-read-only nil))
3386 (when (string= gnus-tmp-name "")
3387 (setq gnus-tmp-name gnus-tmp-from))
3388 (unless (numberp gnus-tmp-lines)
3389 (setq gnus-tmp-lines -1))
3390 (if (= gnus-tmp-lines -1)
3391 (setq gnus-tmp-lines "?")
3392 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3393 (gnus-put-text-property
3395 (progn (eval gnus-summary-line-format-spec) (point))
3396 'gnus-number gnus-tmp-number)
3397 (when (gnus-visual-p 'summary-highlight 'highlight)
3399 (gnus-run-hooks 'gnus-summary-update-hook)
3402 (defun gnus-summary-update-line (&optional dont-update)
3403 "Update summary line after change."
3404 (when (and gnus-summary-default-score
3405 (not gnus-summary-inhibit-highlight))
3406 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3407 (article (gnus-summary-article-number))
3408 (score (gnus-summary-article-score article)))
3410 (if (and gnus-summary-mark-below
3411 (< (gnus-summary-article-score)
3412 gnus-summary-mark-below))
3413 ;; This article has a low score, so we mark it as read.
3414 (when (memq article gnus-newsgroup-unreads)
3415 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3416 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3417 ;; This article was previously marked as read on account
3418 ;; of a low score, but now it has risen, so we mark it as
3420 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3421 (gnus-summary-update-mark
3422 (if (or (null gnus-summary-default-score)
3423 (<= (abs (- score gnus-summary-default-score))
3424 gnus-summary-zcore-fuzz))
3426 (if (< score gnus-summary-default-score)
3427 gnus-score-below-mark gnus-score-over-mark))
3429 ;; Do visual highlighting.
3430 (when (gnus-visual-p 'summary-highlight 'highlight)
3431 (gnus-run-hooks 'gnus-summary-update-hook)))))
3433 (defvar gnus-tmp-new-adopts nil)
3435 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3436 "Return the number of articles in THREAD.
3437 This may be 0 in some cases -- if none of the articles in
3438 the thread are to be displayed."
3440 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3442 ((not (listp thread))
3444 ((and (consp thread) (cdr thread))
3447 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3450 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3453 (when (and level (zerop level) gnus-tmp-new-adopts)
3456 'gnus-summary-number-of-articles-in-thread
3457 gnus-tmp-new-adopts))))
3459 (if (> number 1) gnus-not-empty-thread-mark
3460 gnus-empty-thread-mark)
3463 (defsubst gnus-summary-line-message-size (head)
3464 "Return pretty-printed version of message size.
3465 This function is intended to be used in
3466 `gnus-summary-line-format-alist'."
3467 (let ((c (or (mail-header-chars head) -1)))
3468 (cond ((< c 0) "n/a") ; chars not available
3469 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3470 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3471 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3472 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3475 (defun gnus-summary-set-local-parameters (group)
3476 "Go through the local params of GROUP and set all variable specs in that list."
3477 (let ((params (gnus-group-find-parameter group))
3478 (vars '(quit-config)) ; Ignore quit-config.
3481 (setq elem (car params)
3482 params (cdr params))
3483 (and (consp elem) ; Has to be a cons.
3484 (consp (cdr elem)) ; The cdr has to be a list.
3485 (symbolp (car elem)) ; Has to be a symbol in there.
3486 (not (memq (car elem) vars))
3487 (ignore-errors ; So we set it.
3488 (push (car elem) vars)
3489 (make-local-variable (car elem))
3490 (set (car elem) (eval (nth 1 elem))))))))
3492 (defun gnus-summary-read-group (group &optional show-all no-article
3493 kill-buffer no-display backward
3495 "Start reading news in newsgroup GROUP.
3496 If SHOW-ALL is non-nil, already read articles are also listed.
3497 If NO-ARTICLE is non-nil, no article is selected initially.
3498 If NO-DISPLAY, don't generate a summary buffer."
3502 (let ((gnus-auto-select-next nil))
3503 (or (gnus-summary-read-group-1
3504 group show-all no-article
3505 kill-buffer no-display
3508 select-articles nil)))))
3509 (eq gnus-auto-select-next 'quietly))
3510 (set-buffer gnus-group-buffer)
3511 ;; The entry function called above goes to the next
3512 ;; group automatically, so we go two groups back
3513 ;; if we are searching for the previous group.
3515 (gnus-group-prev-unread-group 2))
3516 (if (not (equal group (gnus-group-group-name)))
3517 (setq group (gnus-group-group-name))
3521 (defun gnus-summary-read-group-1 (group show-all no-article
3522 kill-buffer no-display
3523 &optional select-articles)
3524 ;; Killed foreign groups can't be entered.
3525 ;; (when (and (not (gnus-group-native-p group))
3526 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3527 ;; (error "Dead non-native groups can't be entered"))
3528 (gnus-message 5 "Retrieving newsgroup: %s..."
3529 (gnus-group-decoded-name group))
3530 (let* ((new-group (gnus-summary-setup-buffer group))
3531 (quit-config (gnus-group-quit-config group))
3532 (did-select (and new-group (gnus-select-newsgroup
3533 group show-all select-articles))))
3535 ;; This summary buffer exists already, so we just select it.
3537 (gnus-set-global-variables)
3539 (gnus-kill-or-deaden-summary kill-buffer))
3540 (gnus-configure-windows 'summary 'force)
3541 (gnus-set-mode-line 'summary)
3542 (gnus-summary-position-point)
3545 ;; We couldn't select this group.
3547 (when (and (eq major-mode 'gnus-summary-mode)
3548 (not (equal (current-buffer) kill-buffer)))
3549 (kill-buffer (current-buffer))
3550 (if (not quit-config)
3552 ;; Update the info -- marks might need to be removed,
3554 (gnus-summary-update-info)
3555 (set-buffer gnus-group-buffer)
3556 (gnus-group-jump-to-group group)
3557 (gnus-group-next-unread-group 1))
3558 (gnus-handle-ephemeral-exit quit-config)))
3559 (let ((grpinfo (gnus-get-info group)))
3560 (if (null (gnus-info-read grpinfo))
3561 (gnus-message 3 "Group %s contains no messages"
3562 (gnus-group-decoded-name group))
3563 (gnus-message 3 "Can't select group")))
3565 ;; The user did a `C-g' while prompting for number of articles,
3566 ;; so we exit this group.
3567 ((eq did-select 'quit)
3568 (and (eq major-mode 'gnus-summary-mode)
3569 (not (equal (current-buffer) kill-buffer))
3570 (kill-buffer (current-buffer)))
3572 (gnus-kill-or-deaden-summary kill-buffer))
3573 (if (not quit-config)
3575 (set-buffer gnus-group-buffer)
3576 (gnus-group-jump-to-group group)
3577 (gnus-group-next-unread-group 1)
3578 (gnus-configure-windows 'group 'force))
3579 (gnus-handle-ephemeral-exit quit-config))
3580 ;; Finally signal the quit.
3582 ;; The group was successfully selected.
3584 (gnus-set-global-variables)
3585 ;; Save the active value in effect when the group was entered.
3586 (setq gnus-newsgroup-active
3588 (gnus-active gnus-newsgroup-name)))
3589 ;; You can change the summary buffer in some way with this hook.
3590 (gnus-run-hooks 'gnus-select-group-hook)
3591 (gnus-update-format-specifications
3592 nil 'summary 'summary-mode 'summary-dummy)
3593 (gnus-update-summary-mark-positions)
3594 ;; Do score processing.
3595 (when gnus-use-scoring
3596 (gnus-possibly-score-headers))
3597 ;; Check whether to fill in the gaps in the threads.
3598 (when gnus-build-sparse-threads
3599 (gnus-build-sparse-threads))
3600 ;; Find the initial limit.
3601 (if gnus-show-threads
3603 (let ((gnus-newsgroup-dormant nil))
3604 (gnus-summary-initial-limit show-all))
3605 (gnus-summary-initial-limit show-all))
3606 ;; When unthreaded, all articles are always shown.
3607 (setq gnus-newsgroup-limit
3609 (lambda (header) (mail-header-number header))
3610 gnus-newsgroup-headers)))
3611 ;; Generate the summary buffer.
3613 (gnus-summary-prepare))
3614 (when gnus-use-trees
3615 (gnus-tree-open group)
3616 (setq gnus-summary-highlight-line-function
3617 'gnus-tree-highlight-article))
3618 ;; If the summary buffer is empty, but there are some low-scored
3619 ;; articles or some excluded dormants, we include these in the
3621 (when (and (zerop (buffer-size))
3623 (cond (gnus-newsgroup-dormant
3624 (gnus-summary-limit-include-dormant))
3625 ((and gnus-newsgroup-scored show-all)
3626 (gnus-summary-limit-include-expunged t))))
3627 ;; Function `gnus-apply-kill-file' must be called in this hook.
3628 (gnus-run-hooks 'gnus-apply-kill-hook)
3629 (if (and (zerop (buffer-size))
3632 ;; This newsgroup is empty.
3633 (gnus-summary-catchup-and-exit nil t)
3634 (gnus-message 6 "No unread news")
3636 (gnus-kill-or-deaden-summary kill-buffer))
3637 ;; Return nil from this function.
3639 ;; Hide conversation thread subtrees. We cannot do this in
3640 ;; gnus-summary-prepare-hook since kill processing may not
3641 ;; work with hidden articles.
3642 (gnus-summary-maybe-hide-threads)
3644 (gnus-kill-or-deaden-summary kill-buffer))
3645 (gnus-summary-auto-select-subject)
3646 ;; Show first unread article if requested.
3647 (if (and (not no-article)
3649 gnus-newsgroup-unreads
3650 gnus-auto-select-first)
3652 (gnus-configure-windows 'summary)
3653 (let ((art (gnus-summary-article-number)))
3654 (unless (and (not gnus-plugged)
3655 (or (memq art gnus-newsgroup-undownloaded)
3656 (memq art gnus-newsgroup-downloadable)))
3657 (gnus-summary-goto-article art))))
3658 ;; Don't select any articles.
3659 (gnus-summary-position-point)
3660 (gnus-configure-windows 'summary 'force)
3661 (gnus-set-mode-line 'summary))
3662 (when (and gnus-auto-center-group
3663 (get-buffer-window gnus-group-buffer t))
3664 ;; Gotta use windows, because recenter does weird stuff if
3665 ;; the current buffer ain't the displayed window.
3666 (let ((owin (selected-window)))
3667 (select-window (get-buffer-window gnus-group-buffer t))
3668 (when (gnus-group-goto-group group)
3670 (select-window owin)))
3671 ;; Mark this buffer as "prepared".
3672 (setq gnus-newsgroup-prepared t)
3673 (gnus-run-hooks 'gnus-summary-prepared-hook)
3674 (unless (gnus-ephemeral-group-p group)
3675 (gnus-group-update-group group))
3678 (defun gnus-summary-auto-select-subject ()
3679 "Select the subject line on initial group entry."
3680 (goto-char (point-min))
3682 ((eq gnus-auto-select-subject 'best)
3683 (gnus-summary-best-unread-subject))
3684 ((eq gnus-auto-select-subject 'unread)
3685 (gnus-summary-first-unread-subject))
3686 ((eq gnus-auto-select-subject 'unseen)
3687 (gnus-summary-first-unseen-subject))
3688 ((eq gnus-auto-select-subject 'unseen-or-unread)
3689 (gnus-summary-first-unseen-or-unread-subject))
3690 ((eq gnus-auto-select-subject 'first)
3693 ((functionp gnus-auto-select-subject)
3694 (funcall gnus-auto-select-subject))))
3696 (defun gnus-summary-prepare ()
3697 "Generate the summary buffer."
3699 (let ((buffer-read-only nil))
3701 (setq gnus-newsgroup-data nil
3702 gnus-newsgroup-data-reverse nil)
3703 (gnus-run-hooks 'gnus-summary-generate-hook)
3704 ;; Generate the buffer, either with threads or without.
3705 (when gnus-newsgroup-headers
3706 (gnus-summary-prepare-threads
3707 (if gnus-show-threads
3708 (gnus-sort-gathered-threads
3709 (funcall gnus-summary-thread-gathering-function
3711 (gnus-cut-threads (gnus-make-threads)))))
3712 ;; Unthreaded display.
3713 (gnus-sort-articles gnus-newsgroup-headers))))
3714 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3715 ;; Call hooks for modifying summary buffer.
3716 (goto-char (point-min))
3717 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3719 (defsubst gnus-general-simplify-subject (subject)
3720 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3723 ;; Truncate the subject.
3724 (gnus-simplify-subject-functions
3725 (gnus-map-function gnus-simplify-subject-functions subject))
3726 ((numberp gnus-summary-gather-subject-limit)
3727 (setq subject (gnus-simplify-subject-re subject))
3728 (if (> (length subject) gnus-summary-gather-subject-limit)
3729 (substring subject 0 gnus-summary-gather-subject-limit)
3731 ;; Fuzzily simplify it.
3732 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3733 (gnus-simplify-subject-fuzzy subject))
3734 ;; Just remove the leading "Re:".
3736 (gnus-simplify-subject-re subject))))
3738 (if (and gnus-summary-gather-exclude-subject
3739 (string-match gnus-summary-gather-exclude-subject subject))
3740 nil ; This article shouldn't be gathered
3743 (defun gnus-summary-simplify-subject-query ()
3744 "Query where the respool algorithm would put this article."
3746 (gnus-summary-select-article)
3747 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3749 (defun gnus-gather-threads-by-subject (threads)
3750 "Gather threads by looking at Subject headers."
3751 (if (not gnus-summary-make-false-root)
3753 (let ((hashtb (gnus-make-hashtable 1024))
3756 subject hthread whole-subject)
3758 (setq subject (gnus-general-simplify-subject
3759 (setq whole-subject (mail-header-subject
3762 (if (setq hthread (gnus-gethash subject hashtb))
3764 ;; We enter a dummy root into the thread, if we
3765 ;; haven't done that already.
3766 (unless (stringp (caar hthread))
3767 (setcar hthread (list whole-subject (car hthread))))
3768 ;; We add this new gathered thread to this gathered
3770 (setcdr (car hthread)
3771 (nconc (cdar hthread) (list (car threads))))
3772 ;; Remove it from the list of threads.
3773 (setcdr prev (cdr threads))
3774 (setq threads prev))
3775 ;; Enter this thread into the hash table.
3776 (gnus-sethash subject
3777 (if gnus-summary-make-false-root-always
3779 ;; If you want a dummy root above all
3781 (setcar threads (list whole-subject
3787 (setq threads (cdr threads)))
3790 (defun gnus-gather-threads-by-references (threads)
3791 "Gather threads by looking at References headers."
3792 (let ((idhashtb (gnus-make-hashtable 1024))
3793 (thhashtb (gnus-make-hashtable 1024))
3796 ids references id gthread gid entered ref)
3798 (when (setq references (mail-header-references (caar threads)))
3799 (setq id (mail-header-id (caar threads))
3800 ids (inline (gnus-split-references references))
3802 (while (setq ref (pop ids))
3803 (setq ids (delete ref ids))
3804 (if (not (setq gid (gnus-gethash ref idhashtb)))
3806 (gnus-sethash ref id idhashtb)
3807 (gnus-sethash id threads thhashtb))
3808 (setq gthread (gnus-gethash gid thhashtb))
3810 ;; We enter a dummy root into the thread, if we
3811 ;; haven't done that already.
3812 (unless (stringp (caar gthread))
3813 (setcar gthread (list (mail-header-subject (caar gthread))
3815 ;; We add this new gathered thread to this gathered
3817 (setcdr (car gthread)
3818 (nconc (cdar gthread) (list (car threads)))))
3819 ;; Add it into the thread hash table.
3820 (gnus-sethash id gthread thhashtb)
3822 ;; Remove it from the list of threads.
3823 (setcdr prev (cdr threads))
3824 (setq threads prev))))
3826 (setq threads (cdr threads)))
3829 (defun gnus-sort-gathered-threads (threads)
3830 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3831 (let ((result threads))
3833 (when (stringp (caar threads))
3834 (setcdr (car threads)
3835 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3836 (setq threads (cdr threads)))
3839 (defun gnus-thread-loop-p (root thread)
3840 "Say whether ROOT is in THREAD."
3841 (let ((stack (list thread))
3844 (while (setq thread (pop stack))
3845 (setq th (cdr thread))
3847 (not (eq (caar th) root)))
3850 ;; We have found a loop.
3852 (setcdr thread (delq (car th) (cdr thread)))
3853 (if (boundp (setq ref-dep (intern "none"
3854 gnus-newsgroup-dependencies)))
3855 (setcdr (symbol-value ref-dep)
3856 (nconc (cdr (symbol-value ref-dep))
3858 (set ref-dep (list nil (car th))))
3861 ;; Push all the subthreads onto the stack.
3862 (push (cdr thread) stack)))
3865 (defun gnus-make-threads ()
3866 "Go through the dependency hashtb and find the roots. Return all threads."
3868 (while (catch 'infloop
3871 ;; Deal with self-referencing References loops.
3872 (when (and (car (symbol-value refs))
3879 (car (symbol-value refs)) thread))
3880 (cdr (symbol-value refs)))))))
3883 (unless (car (symbol-value refs))
3884 ;; These threads do not refer back to any other
3885 ;; articles, so they're roots.
3886 (setq threads (append (cdr (symbol-value refs)) threads))))
3887 gnus-newsgroup-dependencies)))
3890 ;; Build the thread tree.
3891 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3892 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3894 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3895 if it was already present.
3897 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3898 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3899 Message-IDs will be renamed to a unique Message-ID before being
3902 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3903 (let* ((id (mail-header-id header))
3904 (id-dep (and id (intern id dependencies)))
3905 parent-id ref ref-dep ref-header replaced)
3906 ;; Enter this `header' in the `dependencies' table.
3910 ;; The first two cases do the normal part: enter a new `header'
3911 ;; in the `dependencies' table.
3912 ((not (boundp id-dep))
3913 (set id-dep (list header)))
3914 ((null (car (symbol-value id-dep)))
3915 (setcar (symbol-value id-dep) header))
3917 ;; From here the `header' was already present in the
3918 ;; `dependencies' table.
3920 ;; Overrides an existing entry;
3921 ;; just set the header part of the entry.
3922 (setcar (symbol-value id-dep) header)
3925 ;; Renames the existing `header' to a unique Message-ID.
3926 ((not gnus-summary-ignore-duplicates)
3927 ;; An article with this Message-ID has already been seen.
3928 ;; We rename the Message-ID.
3929 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3931 (mail-header-set-id header id))
3933 ;; The last case ignores an existing entry, except it adds any
3934 ;; additional Xrefs (in case the two articles came from different
3936 ;; Also sets `header' to `nil' meaning that the `dependencies'
3937 ;; table was *not* modified.
3939 (mail-header-set-xref
3940 (car (symbol-value id-dep))
3941 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3943 (or (mail-header-xref header) "")))
3946 (when (and header (not replaced))
3947 ;; First check that we are not creating a References loop.
3948 (setq parent-id (gnus-parent-id (mail-header-references header)))
3949 (setq ref parent-id)
3951 (setq ref-dep (intern-soft ref dependencies))
3953 (setq ref-header (car (symbol-value ref-dep))))
3954 (if (string= id ref)
3955 ;; Yuk! This is a reference loop. Make the article be a
3958 (mail-header-set-references (car (symbol-value id-dep)) "none")
3960 (setq parent-id nil))
3961 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3962 (setq ref-dep (intern (or parent-id "none") dependencies))
3963 (if (boundp ref-dep)
3964 (setcdr (symbol-value ref-dep)
3965 (nconc (cdr (symbol-value ref-dep))
3966 (list (symbol-value id-dep))))
3967 (set ref-dep (list nil (symbol-value id-dep)))))
3970 (defun gnus-extract-message-id-from-in-reply-to (string)
3971 (if (string-match "<[^>]+>" string)
3972 (substring string (match-beginning 0) (match-end 0))
3975 (defun gnus-build-sparse-threads ()
3976 (let ((headers gnus-newsgroup-headers)
3977 (mail-parse-charset gnus-newsgroup-charset)
3978 (gnus-summary-ignore-duplicates t)
3979 header references generation relations
3980 subject child end new-child date)
3981 ;; First we create an alist of generations/relations, where
3982 ;; generations is how much we trust the relation, and the relation
3984 (gnus-message 7 "Making sparse threads...")
3986 (nnheader-set-temp-buffer " *gnus sparse threads*")
3987 (while (setq header (pop headers))
3988 (when (and (setq references (mail-header-references header))
3989 (not (string= references "")))
3991 (setq child (mail-header-id header)
3992 subject (mail-header-subject header)
3993 date (mail-header-date header)
3995 (while (search-backward ">" nil t)
3996 (setq end (1+ (point)))
3997 (when (search-backward "<" nil t)
3998 (setq new-child (buffer-substring (point) end))
3999 (push (list (incf generation)
4000 child (setq child new-child)
4004 (push (list (1+ generation) child nil subject) relations))
4006 (kill-buffer (current-buffer)))
4007 ;; Sort over trustworthiness.
4010 (when (gnus-dependencies-add-header
4011 (make-full-mail-header
4012 gnus-reffed-article-number
4013 (nth 3 relation) "" (or (nth 4 relation) "")
4015 (or (nth 2 relation) "") 0 0 "")
4016 gnus-newsgroup-dependencies nil)
4017 (push gnus-reffed-article-number gnus-newsgroup-limit)
4018 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4019 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4020 gnus-newsgroup-reads)
4021 (decf gnus-reffed-article-number)))
4022 (sort relations 'car-less-than-car))
4023 (gnus-message 7 "Making sparse threads...done")))
4025 (defun gnus-build-old-threads ()
4026 ;; Look at all the articles that refer back to old articles, and
4027 ;; fetch the headers for the articles that aren't there. This will
4028 ;; build complete threads - if the roots haven't been expired by the
4030 (let ((mail-parse-charset gnus-newsgroup-charset)
4034 (when (not (car (symbol-value refs)))
4035 (setq heads (cdr (symbol-value refs)))
4037 (if (memq (mail-header-number (caar heads))
4038 gnus-newsgroup-dormant)
4039 (setq heads (cdr heads))
4040 (setq id (symbol-name refs))
4041 (while (and (setq id (gnus-build-get-header id))
4042 (not (car (gnus-id-to-thread id)))))
4043 (setq heads nil)))))
4044 gnus-newsgroup-dependencies)))
4046 (defsubst gnus-remove-odd-characters (string)
4047 "Translate STRING into something that doesn't contain weird characters."
4048 (mm-subst-char-in-string
4050 (mm-subst-char-in-string ?\n ?\- string t) t))
4052 ;; This function has to be called with point after the article number
4053 ;; on the beginning of the line.
4054 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4055 (let ((eol (point-at-eol))
4056 (buffer (current-buffer))
4057 header references in-reply-to)
4059 ;; overview: [num subject from date id refs chars lines misc]
4062 (narrow-to-region (point) eol)
4067 (make-full-mail-header
4069 (condition-case () ; subject
4070 (gnus-remove-odd-characters
4071 (funcall gnus-decode-encoded-word-function
4072 (setq x (nnheader-nov-field))))
4074 (condition-case () ; from
4075 (gnus-remove-odd-characters
4076 (funcall gnus-decode-encoded-word-function
4077 (setq x (nnheader-nov-field))))
4079 (nnheader-nov-field) ; date
4080 (nnheader-nov-read-message-id) ; id
4081 (setq references (nnheader-nov-field)) ; refs
4082 (nnheader-nov-read-integer) ; chars
4083 (nnheader-nov-read-integer) ; lines
4085 (if (looking-at "Xref: ")
4086 (goto-char (match-end 0)))
4087 (nnheader-nov-field)) ; Xref
4088 (nnheader-nov-parse-extra)))) ; extra
4092 (when (and (string= references "")
4093 (setq in-reply-to (mail-header-extra header))
4094 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4095 (mail-header-set-references
4096 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4098 (when gnus-alter-header-function
4099 (funcall gnus-alter-header-function header))
4100 (gnus-dependencies-add-header header dependencies force-new)))
4102 (defun gnus-build-get-header (id)
4103 "Look through the buffer of NOV lines and find the header to ID.
4104 Enter this line into the dependencies hash table, and return
4105 the id of the parent article (if any)."
4106 (let ((deps gnus-newsgroup-dependencies)
4110 (set-buffer nntp-server-buffer)
4111 (let ((case-fold-search nil))
4112 (goto-char (point-min))
4113 (while (and (not found)
4114 (search-forward id nil t))
4116 (setq found (looking-at
4117 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4118 (regexp-quote id))))
4119 (or found (beginning-of-line 2)))
4123 (setq header (gnus-nov-parse-line
4124 (read (current-buffer)) deps))
4125 (gnus-parent-id (mail-header-references header))))))
4127 (let ((number (mail-header-number header)))
4128 (push number gnus-newsgroup-limit)
4129 (push header gnus-newsgroup-headers)
4130 (if (memq number gnus-newsgroup-unselected)
4132 (setq gnus-newsgroup-unreads
4133 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4135 (setq gnus-newsgroup-unselected
4136 (delq number gnus-newsgroup-unselected)))
4137 (push number gnus-newsgroup-ancient)))))))
4139 (defun gnus-build-all-threads ()
4140 "Read all the headers."
4141 (let ((gnus-summary-ignore-duplicates t)
4142 (mail-parse-charset gnus-newsgroup-charset)
4143 (dependencies gnus-newsgroup-dependencies)
4146 (set-buffer nntp-server-buffer)
4147 (let ((case-fold-search nil))
4148 (goto-char (point-min))
4151 (setq article (read (current-buffer))
4152 header (gnus-nov-parse-line article dependencies)))
4154 (with-current-buffer gnus-summary-buffer
4155 (push header gnus-newsgroup-headers)
4156 (if (memq (setq article (mail-header-number header))
4157 gnus-newsgroup-unselected)
4159 (setq gnus-newsgroup-unreads
4160 (gnus-add-to-sorted-list
4161 gnus-newsgroup-unreads article))
4162 (setq gnus-newsgroup-unselected
4163 (delq article gnus-newsgroup-unselected)))
4164 (push article gnus-newsgroup-ancient)))
4165 (forward-line 1)))))))
4167 (defun gnus-summary-update-article-line (article header)
4168 "Update the line for ARTICLE using HEADER."
4169 (let* ((id (mail-header-id header))
4170 (thread (gnus-id-to-thread id)))
4172 (error "Article in no thread"))
4173 ;; Update the thread.
4174 (setcar thread header)
4175 (gnus-summary-goto-subject article)
4176 (let* ((datal (gnus-data-find-list article))
4178 (buffer-read-only nil)
4179 (level (gnus-summary-thread-level)))
4181 (let ((inserted (- (point)
4183 (gnus-summary-insert-line
4185 (memq article gnus-newsgroup-undownloaded)
4186 (gnus-article-mark article)
4187 (memq article gnus-newsgroup-replied)
4188 (memq article gnus-newsgroup-expirable)
4189 ;; Only insert the Subject string when it's different
4190 ;; from the previous Subject string.
4195 (mail-header-subject
4198 (gnus-data-find-list
4200 (gnus-data-list t)))))
4201 ;; Error on the side of excessive subjects.
4203 (mail-header-subject header)))
4205 (mail-header-subject header))
4206 nil (cdr (assq article gnus-newsgroup-scored))
4207 (memq article gnus-newsgroup-processable))
4210 (gnus-data-update-list
4212 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4214 (defun gnus-summary-update-article (article &optional iheader)
4215 "Update ARTICLE in the summary buffer."
4216 (set-buffer gnus-summary-buffer)
4217 (let* ((header (gnus-summary-article-header article))
4218 (id (mail-header-id header))
4219 (data (gnus-data-find article))
4220 (thread (gnus-id-to-thread id))
4221 (references (mail-header-references header))
4225 (when (and references
4226 (not (equal "" references)))
4229 (buffer-read-only nil)
4235 (delq thread parent)))
4236 (if (gnus-summary-insert-subject id header)
4237 ;; Set the (possibly) new article number in the data structure.
4238 (gnus-data-set-number data (gnus-id-to-article id))
4242 (defun gnus-rebuild-thread (id &optional line)
4243 "Rebuild the thread containing ID.
4244 If LINE, insert the rebuilt thread starting on line LINE."
4245 (let ((buffer-read-only nil)
4246 old-pos current thread data)
4247 (if (not gnus-show-threads)
4248 (setq thread (list (car (gnus-id-to-thread id))))
4249 ;; Get the thread this article is part of.
4250 (setq thread (gnus-remove-thread id)))
4251 (setq old-pos (point-at-bol))
4252 (setq current (save-excursion
4253 (and (re-search-backward "[\r\n]" nil t)
4254 (gnus-summary-article-number))))
4255 ;; If this is a gathered thread, we have to go some re-gathering.
4256 (when (stringp (car thread))
4257 (let ((subject (car thread))
4259 (setq thread (cdr thread))
4261 (unless (memq (setq thr (gnus-id-to-thread
4263 (mail-header-id (caar thread)))))
4266 (setq thread (cdr thread)))
4267 ;; We now have all (unique) roots.
4268 (if (= (length roots) 1)
4269 ;; All the loose roots are now one solid root.
4270 (setq thread (car roots))
4271 (setq thread (cons subject (gnus-sort-threads roots))))))
4273 ;; We then insert this thread into the summary buffer.
4275 (goto-char (point-min))
4276 (forward-line (1- line)))
4277 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4278 (if gnus-show-threads
4279 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4280 (gnus-summary-prepare-unthreaded thread))
4281 (setq data (nreverse gnus-newsgroup-data))
4282 (setq threads gnus-newsgroup-threads))
4283 ;; We splice the new data into the data structure.
4284 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4285 ;;!!! then we want to insert at the beginning of the buffer.
4286 ;;!!! That happens to be true with Gnus now, but that may
4287 ;;!!! change in the future. Perhaps.
4288 (gnus-data-enter-list
4289 (if line nil current) data (- (point) old-pos))
4290 (setq gnus-newsgroup-threads
4291 (nconc threads gnus-newsgroup-threads))
4292 (gnus-data-compute-positions))))
4294 (defun gnus-number-to-header (number)
4295 "Return the header for article NUMBER."
4296 (let ((headers gnus-newsgroup-headers))
4298 (not (= number (mail-header-number (car headers)))))
4303 (defun gnus-parent-headers (in-headers &optional generation)
4304 "Return the headers of the GENERATIONeth parent of HEADERS."
4306 (setq generation 1))
4308 (headers in-headers)
4311 (not (zerop generation))
4312 (setq references (mail-header-references headers)))
4313 (setq headers (if (and references
4314 (setq parent (gnus-parent-id references)))
4315 (car (gnus-id-to-thread parent))
4318 (and (not (eq headers in-headers))
4321 (defun gnus-id-to-thread (id)
4322 "Return the (sub-)thread where ID appears."
4323 (gnus-gethash id gnus-newsgroup-dependencies))
4325 (defun gnus-id-to-article (id)
4326 "Return the article number of ID."
4327 (let ((thread (gnus-id-to-thread id)))
4330 (mail-header-number (car thread)))))
4332 (defun gnus-id-to-header (id)
4333 "Return the article headers of ID."
4334 (car (gnus-id-to-thread id)))
4336 (defun gnus-article-displayed-root-p (article)
4337 "Say whether ARTICLE is a root(ish) article."
4338 (let ((level (gnus-summary-thread-level article))
4339 (refs (mail-header-references (gnus-summary-article-header article)))
4345 ((null (gnus-parent-id refs)) t)
4347 (null (setq particle (gnus-id-to-article
4348 (gnus-parent-id refs))))
4349 (null (gnus-summary-thread-level particle)))))))
4351 (defun gnus-root-id (id)
4352 "Return the id of the root of the thread where ID appears."
4354 (while (and id (setq prev (car (gnus-id-to-thread id))))
4356 id (gnus-parent-id (mail-header-references prev))))
4359 (defun gnus-articles-in-thread (thread)
4360 "Return the list of articles in THREAD."
4361 (cons (mail-header-number (car thread))
4362 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4364 (defun gnus-remove-thread (id &optional dont-remove)
4365 "Remove the thread that has ID in it."
4366 (let (headers thread last-id)
4367 ;; First go up in this thread until we find the root.
4368 (setq last-id (gnus-root-id id)
4369 headers (message-flatten-list (gnus-id-to-thread last-id)))
4370 ;; We have now found the real root of this thread. It might have
4371 ;; been gathered into some loose thread, so we have to search
4372 ;; through the threads to find the thread we wanted.
4373 (let ((threads gnus-newsgroup-threads)
4376 (setq sub (car threads))
4377 (if (stringp (car sub))
4378 ;; This is a gathered thread, so we look at the roots
4379 ;; below it to find whether this article is in this
4382 (setq sub (cdr sub))
4384 (when (member (caar sub) headers)
4385 (setq thread (car threads)
4388 (setq sub (cdr sub))))
4389 ;; It's an ordinary thread, so we check it.
4390 (when (eq (car sub) (car headers))
4393 (setq threads (cdr threads)))
4394 ;; If this article is in no thread, then it's a root.
4397 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4398 (setq thread (gnus-id-to-thread last-id)))
4401 thread ; We return this thread.
4403 (if (stringp (car thread))
4405 ;; If we use dummy roots, then we have to remove the
4406 ;; dummy root as well.
4407 (when (eq gnus-summary-make-false-root 'dummy)
4408 ;; We go to the dummy root by going to
4409 ;; the first sub-"thread", and then one line up.
4410 (gnus-summary-goto-article
4411 (mail-header-number (caadr thread)))
4414 (gnus-data-compute-positions))
4415 (setq thread (cdr thread))
4417 (gnus-remove-thread-1 (car thread))
4418 (setq thread (cdr thread))))
4419 (gnus-remove-thread-1 thread))))))))
4421 (defun gnus-remove-thread-1 (thread)
4422 "Remove the thread THREAD recursively."
4423 (let ((number (mail-header-number (pop thread)))
4425 (setq thread (reverse thread))
4427 (gnus-remove-thread-1 (pop thread)))
4428 (when (setq d (gnus-data-find number))
4429 (goto-char (gnus-data-pos d))
4430 (gnus-summary-show-thread)
4436 (gnus-delete-line)))))))
4438 (defun gnus-sort-threads-1 (threads func)
4439 (sort (mapcar (lambda (thread)
4442 (gnus-sort-threads-1 (cdr thread) func))))
4445 (defun gnus-sort-threads (threads)
4447 (if (not gnus-thread-sort-functions)
4449 (gnus-message 8 "Sorting threads...")
4450 (let ((max-lisp-eval-depth 5000))
4451 (prog1 (gnus-sort-threads-1
4453 (gnus-make-sort-function gnus-thread-sort-functions))
4454 (gnus-message 8 "Sorting threads...done")))))
4456 (defun gnus-sort-articles (articles)
4458 (when gnus-article-sort-functions
4459 (gnus-message 7 "Sorting articles...")
4461 (setq gnus-newsgroup-headers
4462 (sort articles (gnus-make-sort-function
4463 gnus-article-sort-functions)))
4464 (gnus-message 7 "Sorting articles...done"))))
4466 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4467 (defmacro gnus-thread-header (thread)
4468 "Return header of first article in THREAD.
4469 Note that THREAD must never, ever be anything else than a variable -
4470 using some other form will lead to serious barfage."
4471 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4472 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4473 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4476 (defsubst gnus-article-sort-by-number (h1 h2)
4477 "Sort articles by article number."
4478 (< (mail-header-number h1)
4479 (mail-header-number h2)))
4481 (defun gnus-thread-sort-by-number (h1 h2)
4482 "Sort threads by root article number."
4483 (gnus-article-sort-by-number
4484 (gnus-thread-header h1) (gnus-thread-header h2)))
4486 (defsubst gnus-article-sort-by-random (h1 h2)
4487 "Sort articles by article number."
4490 (defun gnus-thread-sort-by-random (h1 h2)
4491 "Sort threads by root article number."
4492 (gnus-article-sort-by-random
4493 (gnus-thread-header h1) (gnus-thread-header h2)))
4495 (defsubst gnus-article-sort-by-lines (h1 h2)
4496 "Sort articles by article Lines header."
4497 (< (mail-header-lines h1)
4498 (mail-header-lines h2)))
4500 (defun gnus-thread-sort-by-lines (h1 h2)
4501 "Sort threads by root article Lines header."
4502 (gnus-article-sort-by-lines
4503 (gnus-thread-header h1) (gnus-thread-header h2)))
4505 (defsubst gnus-article-sort-by-chars (h1 h2)
4506 "Sort articles by octet length."
4507 (< (mail-header-chars h1)
4508 (mail-header-chars h2)))
4510 (defun gnus-thread-sort-by-chars (h1 h2)
4511 "Sort threads by root article octet length."
4512 (gnus-article-sort-by-chars
4513 (gnus-thread-header h1) (gnus-thread-header h2)))
4515 (defsubst gnus-article-sort-by-author (h1 h2)
4516 "Sort articles by root author."
4518 (let ((extract (funcall
4519 gnus-extract-address-components
4520 (mail-header-from h1))))
4521 (or (car extract) (cadr extract) ""))
4522 (let ((extract (funcall
4523 gnus-extract-address-components
4524 (mail-header-from h2))))
4525 (or (car extract) (cadr extract) ""))))
4527 (defun gnus-thread-sort-by-author (h1 h2)
4528 "Sort threads by root author."
4529 (gnus-article-sort-by-author
4530 (gnus-thread-header h1) (gnus-thread-header h2)))
4532 (defsubst gnus-article-sort-by-subject (h1 h2)
4533 "Sort articles by root subject."
4535 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4536 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4538 (defun gnus-thread-sort-by-subject (h1 h2)
4539 "Sort threads by root subject."
4540 (gnus-article-sort-by-subject
4541 (gnus-thread-header h1) (gnus-thread-header h2)))
4543 (defsubst gnus-article-sort-by-date (h1 h2)
4544 "Sort articles by root article date."
4546 (gnus-date-get-time (mail-header-date h1))
4547 (gnus-date-get-time (mail-header-date h2))))
4549 (defun gnus-thread-sort-by-date (h1 h2)
4550 "Sort threads by root article date."
4551 (gnus-article-sort-by-date
4552 (gnus-thread-header h1) (gnus-thread-header h2)))
4554 (defsubst gnus-article-sort-by-score (h1 h2)
4555 "Sort articles by root article score.
4556 Unscored articles will be counted as having a score of zero."
4557 (> (or (cdr (assq (mail-header-number h1)
4558 gnus-newsgroup-scored))
4559 gnus-summary-default-score 0)
4560 (or (cdr (assq (mail-header-number h2)
4561 gnus-newsgroup-scored))
4562 gnus-summary-default-score 0)))
4564 (defun gnus-thread-sort-by-score (h1 h2)
4565 "Sort threads by root article score."
4566 (gnus-article-sort-by-score
4567 (gnus-thread-header h1) (gnus-thread-header h2)))
4569 (defun gnus-thread-sort-by-total-score (h1 h2)
4570 "Sort threads by the sum of all scores in the thread.
4571 Unscored articles will be counted as having a score of zero."
4572 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4574 (defun gnus-thread-total-score (thread)
4575 ;; This function find the total score of THREAD.
4580 (if (stringp (car thread))
4581 (apply gnus-thread-score-function 0
4582 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4583 (gnus-thread-total-score-1 thread)))
4585 (gnus-thread-total-score-1 (list thread)))))
4587 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4588 "Sort threads such that the thread with the most recently arrived article comes first."
4589 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4591 (defun gnus-thread-highest-number (thread)
4592 "Return the highest article number in THREAD."
4593 (apply 'max (mapcar (lambda (header)
4594 (mail-header-number header))
4595 (message-flatten-list thread))))
4597 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4598 "Sort threads such that the thread with the most recently dated article comes first."
4599 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4601 (defun gnus-thread-latest-date (thread)
4602 "Return the highest article date in THREAD."
4603 (let ((previous-time 0))
4609 (time-to-seconds (mail-header-parse-date
4610 (mail-header-date header)))
4611 (error previous-time))))
4613 (message-flatten-list thread)
4615 (< (mail-header-number h1)
4616 (mail-header-number h2))))))))
4618 (defun gnus-thread-total-score-1 (root)
4619 ;; This function find the total score of the thread below ROOT.
4620 (setq root (car root))
4621 (apply gnus-thread-score-function
4623 (mapcar 'gnus-thread-total-score
4624 (cdr (gnus-id-to-thread (mail-header-id root))))
4625 (when (> (mail-header-number root) 0)
4626 (list (or (cdr (assq (mail-header-number root)
4627 gnus-newsgroup-scored))
4628 gnus-summary-default-score 0))))
4629 (list gnus-summary-default-score)
4632 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4633 (defvar gnus-tmp-prev-subject nil)
4634 (defvar gnus-tmp-false-parent nil)
4635 (defvar gnus-tmp-root-expunged nil)
4636 (defvar gnus-tmp-dummy-line nil)
4638 (eval-when-compile (defvar gnus-tmp-header))
4639 (defun gnus-extra-header (type &optional header)
4640 "Return the extra header of TYPE."
4641 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4644 (defvar gnus-tmp-thread-tree-header-string "")
4646 (defcustom gnus-sum-thread-tree-root "> "
4647 "With %B spec, used for the root of a thread.
4648 If nil, use subject instead."
4649 :type '(radio (const :format "%v " nil) (string :size 0))
4650 :group 'gnus-thread)
4651 (defcustom gnus-sum-thread-tree-false-root "> "
4652 "With %B spec, used for a false root of a thread.
4653 If nil, use subject instead."
4654 :type '(radio (const :format "%v " nil) (string :size 0))
4655 :group 'gnus-thread)
4656 (defcustom gnus-sum-thread-tree-single-indent ""
4657 "With %B spec, used for a thread with just one message.
4658 If nil, use subject instead."
4659 :type '(radio (const :format "%v " nil) (string :size 0))
4660 :group 'gnus-thread)
4661 (defcustom gnus-sum-thread-tree-vertical "| "
4662 "With %B spec, used for drawing a vertical line."
4664 :group 'gnus-thread)
4665 (defcustom gnus-sum-thread-tree-indent " "
4666 "With %B spec, used for indenting."
4668 :group 'gnus-thread)
4669 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4670 "With %B spec, used for a leaf with brothers."
4672 :group 'gnus-thread)
4673 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4674 "With %B spec, used for a leaf without brothers."
4676 :group 'gnus-thread)
4678 (defun gnus-summary-prepare-threads (threads)
4679 "Prepare summary buffer from THREADS and indentation LEVEL.
4680 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4681 or a straight list of headers."
4682 (gnus-message 7 "Generating summary...")
4684 (setq gnus-newsgroup-threads threads)
4687 (let ((gnus-tmp-level 0)
4688 (default-score (or gnus-summary-default-score 0))
4689 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4690 (building-line-count gnus-summary-display-while-building)
4691 (building-count (integerp gnus-summary-display-while-building))
4692 thread number subject stack state gnus-tmp-gathered beg-match
4693 new-roots gnus-tmp-new-adopts thread-end simp-subject
4694 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4695 gnus-tmp-replied gnus-tmp-subject-or-nil
4696 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4697 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4698 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4701 (setq gnus-tmp-prev-subject nil
4702 gnus-tmp-thread-tree-header-string "")
4704 (if (vectorp (car threads))
4705 ;; If this is a straight (sic) list of headers, then a
4706 ;; threaded summary display isn't required, so we just create
4707 ;; an unthreaded one.
4708 (gnus-summary-prepare-unthreaded threads)
4710 ;; Do the threaded display.
4712 (if gnus-summary-display-while-building
4713 (switch-to-buffer (buffer-name)))
4714 (while (or threads stack gnus-tmp-new-adopts new-roots)
4716 (if (and (= gnus-tmp-level 0)
4719 (not gnus-tmp-false-parent)
4720 (or gnus-tmp-new-adopts new-roots))
4721 (if gnus-tmp-new-adopts
4722 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4723 thread (list (car gnus-tmp-new-adopts))
4724 gnus-tmp-header (caar thread)
4725 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4727 (setq thread (list (car new-roots))
4728 gnus-tmp-header (caar thread)
4729 new-roots (cdr new-roots))))
4732 ;; If there are some threads, we do them before the
4733 ;; threads on the stack.
4734 (setq thread threads
4735 gnus-tmp-header (caar thread))
4736 ;; There were no current threads, so we pop something off
4738 (setq state (car stack)
4739 gnus-tmp-level (car state)
4740 tree-stack (cadr state)
4741 thread (caddr state)
4743 gnus-tmp-header (caar thread))))
4745 (setq gnus-tmp-false-parent nil)
4746 (setq gnus-tmp-root-expunged nil)
4747 (setq thread-end nil)
4749 (if (stringp gnus-tmp-header)
4750 ;; The header is a dummy root.
4752 ((eq gnus-summary-make-false-root 'adopt)
4753 ;; We let the first article adopt the rest.
4754 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4756 (setq gnus-tmp-gathered
4758 (lambda (h) (mail-header-number (car h)))
4761 (setq thread (cons (list (caar thread)
4764 (setq gnus-tmp-level -1
4765 gnus-tmp-false-parent t))
4766 ((eq gnus-summary-make-false-root 'empty)
4767 ;; We print adopted articles with empty subject fields.
4768 (setq gnus-tmp-gathered
4770 (lambda (h) (mail-header-number (car h)))
4773 (setq gnus-tmp-level -1))
4774 ((eq gnus-summary-make-false-root 'dummy)
4775 ;; We remember that we probably want to output a dummy
4777 (setq gnus-tmp-dummy-line gnus-tmp-header)
4778 (setq gnus-tmp-prev-subject gnus-tmp-header))
4780 ;; We do not make a root for the gathered
4781 ;; sub-threads at all.
4782 (setq gnus-tmp-level -1)))
4784 (setq number (mail-header-number gnus-tmp-header)
4785 subject (mail-header-subject gnus-tmp-header)
4786 simp-subject (gnus-simplify-subject-fully subject))
4789 ;; If the thread has changed subject, we might want to make
4790 ;; this subthread into a root.
4791 ((and (null gnus-thread-ignore-subject)
4792 (not (zerop gnus-tmp-level))
4793 gnus-tmp-prev-subject
4794 (not (string= gnus-tmp-prev-subject simp-subject)))
4795 (setq new-roots (nconc new-roots (list (car thread)))
4797 gnus-tmp-header nil))
4798 ;; If the article lies outside the current limit,
4799 ;; then we do not display it.
4800 ((not (memq number gnus-newsgroup-limit))
4801 (setq gnus-tmp-gathered
4803 (lambda (h) (mail-header-number (car h)))
4806 (setq gnus-tmp-new-adopts (if (cdar thread)
4807 (append gnus-tmp-new-adopts
4809 gnus-tmp-new-adopts)
4811 gnus-tmp-header nil)
4812 (when (zerop gnus-tmp-level)
4813 (setq gnus-tmp-root-expunged t)))
4814 ;; Perhaps this article is to be marked as read?
4815 ((and gnus-summary-mark-below
4816 (< (or (cdr (assq number gnus-newsgroup-scored))
4818 gnus-summary-mark-below)
4819 ;; Don't touch sparse articles.
4820 (not (gnus-summary-article-sparse-p number))
4821 (not (gnus-summary-article-ancient-p number)))
4822 (setq gnus-newsgroup-unreads
4823 (delq number gnus-newsgroup-unreads))
4824 (if gnus-newsgroup-auto-expire
4825 (setq gnus-newsgroup-expirable
4826 (gnus-add-to-sorted-list
4827 gnus-newsgroup-expirable number))
4828 (push (cons number gnus-low-score-mark)
4829 gnus-newsgroup-reads))))
4831 (when gnus-tmp-header
4832 ;; We may have an old dummy line to output before this
4834 (when (and gnus-tmp-dummy-line
4837 (mail-header-subject gnus-tmp-header)))
4838 (gnus-summary-insert-dummy-line
4839 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4840 (setq gnus-tmp-dummy-line nil))
4842 ;; Compute the mark.
4843 (setq gnus-tmp-unread (gnus-article-mark number))
4845 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4846 gnus-tmp-header gnus-tmp-level)
4847 gnus-newsgroup-data)
4849 ;; Actually insert the line.
4851 gnus-tmp-subject-or-nil
4853 ((and gnus-thread-ignore-subject
4854 gnus-tmp-prev-subject
4855 (not (string= gnus-tmp-prev-subject simp-subject)))
4857 ((zerop gnus-tmp-level)
4858 (if (and (eq gnus-summary-make-false-root 'empty)
4859 (memq number gnus-tmp-gathered)
4860 gnus-tmp-prev-subject
4861 (string= gnus-tmp-prev-subject simp-subject))
4862 gnus-summary-same-subject
4864 (t gnus-summary-same-subject)))
4865 (if (and (eq gnus-summary-make-false-root 'adopt)
4866 (= gnus-tmp-level 1)
4867 (memq number gnus-tmp-gathered))
4868 (setq gnus-tmp-opening-bracket ?\<
4869 gnus-tmp-closing-bracket ?\>)
4870 (setq gnus-tmp-opening-bracket ?\[
4871 gnus-tmp-closing-bracket ?\]))
4873 gnus-tmp-indentation
4874 (aref gnus-thread-indent-array gnus-tmp-level)
4875 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4876 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4877 gnus-summary-default-score 0)
4879 (if (or (null gnus-summary-default-score)
4880 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4881 gnus-summary-zcore-fuzz))
4883 (if (< gnus-tmp-score gnus-summary-default-score)
4884 gnus-score-below-mark gnus-score-over-mark))
4886 (cond ((memq number gnus-newsgroup-processable)
4888 ((memq number gnus-newsgroup-cached)
4890 ((memq number gnus-newsgroup-replied)
4892 ((memq number gnus-newsgroup-forwarded)
4893 gnus-forwarded-mark)
4894 ((memq number gnus-newsgroup-saved)
4896 ((memq number gnus-newsgroup-recent)
4898 ((memq number gnus-newsgroup-unseen)
4902 (cond ((memq number gnus-newsgroup-undownloaded)
4903 gnus-undownloaded-mark)
4904 (gnus-newsgroup-agentized
4905 gnus-downloaded-mark)
4908 gnus-tmp-from (mail-header-from gnus-tmp-header)
4911 ((string-match "<[^>]+> *$" gnus-tmp-from)
4912 (setq beg-match (match-beginning 0))
4913 (or (and (string-match "^\".+\"" gnus-tmp-from)
4914 (substring gnus-tmp-from 1 (1- (match-end 0))))
4915 (substring gnus-tmp-from 0 beg-match)))
4916 ((string-match "(.+)" gnus-tmp-from)
4917 (substring gnus-tmp-from
4918 (1+ (match-beginning 0)) (1- (match-end 0))))
4922 gnus-tmp-thread-tree-header-string
4924 ((not gnus-show-threads) "")
4925 ((zerop gnus-tmp-level)
4926 (cond ((cdar thread)
4927 (or gnus-sum-thread-tree-root subject))
4928 (gnus-tmp-new-adopts
4929 (or gnus-sum-thread-tree-false-root subject))
4931 (or gnus-sum-thread-tree-single-indent subject))))
4933 (concat (apply 'concat
4934 (mapcar (lambda (item)
4936 gnus-sum-thread-tree-vertical
4937 gnus-sum-thread-tree-indent))
4938 (cdr (reverse tree-stack))))
4940 gnus-sum-thread-tree-leaf-with-other
4941 gnus-sum-thread-tree-single-leaf)))))
4942 (when (string= gnus-tmp-name "")
4943 (setq gnus-tmp-name gnus-tmp-from))
4944 (unless (numberp gnus-tmp-lines)
4945 (setq gnus-tmp-lines -1))
4946 (if (= gnus-tmp-lines -1)
4947 (setq gnus-tmp-lines "?")
4948 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4949 (gnus-put-text-property
4951 (progn (eval gnus-summary-line-format-spec) (point))
4952 'gnus-number number)
4955 (gnus-run-hooks 'gnus-summary-update-hook)
4958 (setq gnus-tmp-prev-subject simp-subject)))
4960 (when (nth 1 thread)
4961 (push (list (max 0 gnus-tmp-level)
4962 (copy-sequence tree-stack)
4965 (push (if (nth 1 thread) 1 0) tree-stack)
4966 (incf gnus-tmp-level)
4967 (setq threads (if thread-end nil (cdar thread)))
4968 (if gnus-summary-display-while-building
4971 ;; use a set frequency
4972 (setq building-line-count (1- building-line-count))
4973 (when (= building-line-count 0)
4975 (setq building-line-count
4976 gnus-summary-display-while-building)))
4980 (setq gnus-tmp-level 0)))))
4981 (gnus-message 7 "Generating summary...done"))
4983 (defun gnus-summary-prepare-unthreaded (headers)
4984 "Generate an unthreaded summary buffer based on HEADERS."
4985 (let (header number mark)
4990 ;; We may have to root out some bad articles...
4991 (when (memq (setq number (mail-header-number
4992 (setq header (pop headers))))
4993 gnus-newsgroup-limit)
4994 ;; Mark article as read when it has a low score.
4995 (when (and gnus-summary-mark-below
4996 (< (or (cdr (assq number gnus-newsgroup-scored))
4997 gnus-summary-default-score 0)
4998 gnus-summary-mark-below)
4999 (not (gnus-summary-article-ancient-p number)))
5000 (setq gnus-newsgroup-unreads
5001 (delq number gnus-newsgroup-unreads))
5002 (if gnus-newsgroup-auto-expire
5003 (push number gnus-newsgroup-expirable)
5004 (push (cons number gnus-low-score-mark)
5005 gnus-newsgroup-reads)))
5007 (setq mark (gnus-article-mark number))
5008 (push (gnus-data-make number mark (1+ (point)) header 0)
5009 gnus-newsgroup-data)
5010 (gnus-summary-insert-line
5012 (memq number gnus-newsgroup-undownloaded)
5013 mark (memq number gnus-newsgroup-replied)
5014 (memq number gnus-newsgroup-expirable)
5015 (mail-header-subject header) nil
5016 (cdr (assq number gnus-newsgroup-scored))
5017 (memq number gnus-newsgroup-processable))))))
5019 (defun gnus-summary-remove-list-identifiers ()
5020 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5021 (let ((regexp (if (consp gnus-list-identifiers)
5022 (mapconcat 'identity gnus-list-identifiers " *\\|")
5023 gnus-list-identifiers))
5026 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5027 (dolist (header gnus-newsgroup-headers)
5028 (setq subject (mail-header-subject header)
5030 (while (string-match regexp subject)
5032 (concat (substring subject 0 (match-beginning 1))
5033 (substring subject (match-end 0)))
5036 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5038 (concat (substring subject 0 (match-beginning 1))
5039 (substring subject (match-end 1)))))
5040 (mail-header-set-subject header subject))))))
5042 (defun gnus-fetch-headers (articles)
5043 "Fetch headers of ARTICLES."
5044 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5045 (gnus-message 5 "Fetching headers for %s..." name)
5048 (setq gnus-headers-retrieved-by
5049 (gnus-retrieve-headers
5050 articles gnus-newsgroup-name
5051 ;; We might want to fetch old headers, but
5052 ;; not if there is only 1 article.
5054 (not (eq gnus-fetch-old-headers 'some))
5055 (not (numberp gnus-fetch-old-headers)))
5056 (> (length articles) 1))
5057 gnus-fetch-old-headers))))
5058 (gnus-get-newsgroup-headers-xover
5059 articles nil nil gnus-newsgroup-name t)
5060 (gnus-get-newsgroup-headers))
5061 (gnus-message 5 "Fetching headers for %s...done" name))))
5063 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5064 "Select newsgroup GROUP.
5065 If READ-ALL is non-nil, all articles in the group are selected.
5066 If SELECT-ARTICLES, only select those articles from GROUP."
5067 (let* ((entry (gnus-group-entry group))
5068 ;;!!! Dirty hack; should be removed.
5069 (gnus-summary-ignore-duplicates
5070 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5072 gnus-summary-ignore-duplicates))
5073 (info (nth 2 entry))
5074 articles fetched-articles cached)
5076 (unless (gnus-check-server
5077 (set (make-local-variable 'gnus-current-select-method)
5078 (gnus-find-method-for-group group)))
5079 (error "Couldn't open server"))
5081 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5082 (gnus-activate-group group) ; Or we can activate it...
5083 (progn ; Or we bug out.
5084 (when (equal major-mode 'gnus-summary-mode)
5085 (gnus-kill-buffer (current-buffer)))
5086 (error "Couldn't activate group %s: %s"
5087 group (gnus-status-message group))))
5089 (unless (gnus-request-group group t)
5090 (when (equal major-mode 'gnus-summary-mode)
5091 (gnus-kill-buffer (current-buffer)))
5092 (error "Couldn't request group %s: %s"
5093 group (gnus-status-message group)))
5096 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5098 (setq gnus-summary-use-undownloaded-faces
5099 (gnus-agent-find-parameter
5101 'agent-enable-undownloaded-faces)))
5103 (setq gnus-newsgroup-name group
5104 gnus-newsgroup-unselected nil
5105 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5107 (let ((display (gnus-group-find-parameter group 'display)))
5108 (setq gnus-newsgroup-display
5110 ((not (zerop (or (car-safe read-all) 0)))
5111 ;; The user entered the group with C-u SPC/RET, let's show
5117 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5119 ;; The following is probably the "correct" solution, but
5120 ;; it makes Gnus fetch all headers and then limit the
5121 ;; articles (which is slow), so instead we hack the
5122 ;; select-articles parameter instead. -- Simon Josefsson
5125 ;; (gnus-byte-compile
5126 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5128 (setq select-articles
5129 (gnus-uncompress-range
5130 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5134 (cdr (gnus-active group)))))
5139 (gnus-summary-setup-default-charset)
5141 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5142 (when (gnus-virtual-group-p group)
5143 (setq cached gnus-newsgroup-cached))
5145 (setq gnus-newsgroup-unreads
5146 (gnus-sorted-ndifference
5147 (gnus-sorted-ndifference gnus-newsgroup-unreads
5148 gnus-newsgroup-marked)
5149 gnus-newsgroup-dormant))
5151 (setq gnus-newsgroup-processable nil)
5153 (gnus-update-read-articles group gnus-newsgroup-unreads)
5155 ;; Adjust and set lists of article marks.
5157 (gnus-adjust-marked-articles info))
5158 (if (setq articles select-articles)
5159 (setq gnus-newsgroup-unselected
5160 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5161 (setq articles (gnus-articles-to-read group read-all)))
5165 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5167 ((eq articles 0) nil)
5169 ;; Init the dependencies hash table.
5170 (setq gnus-newsgroup-dependencies
5171 (gnus-make-hashtable (length articles)))
5172 (gnus-set-global-variables)
5173 ;; Retrieve the headers and read them in.
5175 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5177 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5179 (setq gnus-newsgroup-cached cached))
5181 ;; Suppress duplicates?
5182 (when gnus-suppress-duplicates
5183 (gnus-dup-suppress-articles))
5185 ;; Set the initial limit.
5186 (setq gnus-newsgroup-limit (copy-sequence articles))
5187 ;; Remove canceled articles from the list of unread articles.
5188 (setq fetched-articles
5189 (mapcar (lambda (headers) (mail-header-number headers))
5190 gnus-newsgroup-headers))
5191 (setq gnus-newsgroup-articles fetched-articles)
5192 (setq gnus-newsgroup-unreads
5193 (gnus-sorted-nintersection
5194 gnus-newsgroup-unreads fetched-articles))
5195 (gnus-compute-unseen-list)
5197 ;; Removed marked articles that do not exist.
5198 (gnus-update-missing-marks
5199 (gnus-sorted-difference articles fetched-articles))
5200 ;; We might want to build some more threads first.
5201 (when (and gnus-fetch-old-headers
5202 (eq gnus-headers-retrieved-by 'nov))
5203 (if (eq gnus-fetch-old-headers 'invisible)
5204 (gnus-build-all-threads)
5205 (gnus-build-old-threads)))
5206 ;; Let the Gnus agent mark articles as read.
5208 (gnus-agent-get-undownloaded-list))
5209 ;; Remove list identifiers from subject
5210 (when gnus-list-identifiers
5211 (gnus-summary-remove-list-identifiers))
5212 ;; Check whether auto-expire is to be done in this group.
5213 (setq gnus-newsgroup-auto-expire
5214 (gnus-group-auto-expirable-p group))
5215 ;; Set up the article buffer now, if necessary.
5216 (unless gnus-single-article-buffer
5217 (gnus-article-setup-buffer))
5218 ;; First and last article in this newsgroup.
5219 (when gnus-newsgroup-headers
5220 (setq gnus-newsgroup-begin
5221 (mail-header-number (car gnus-newsgroup-headers))
5224 (gnus-last-element gnus-newsgroup-headers))))
5225 ;; GROUP is successfully selected.
5226 (or gnus-newsgroup-headers t)))))
5228 (defun gnus-compute-unseen-list ()
5229 ;; The `seen' marks are treated specially.
5230 (if (not gnus-newsgroup-seen)
5231 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5232 (setq gnus-newsgroup-unseen
5233 (gnus-inverse-list-range-intersection
5234 gnus-newsgroup-articles gnus-newsgroup-seen))))
5236 (defun gnus-summary-display-make-predicate (display)
5237 (require 'gnus-agent)
5238 (when (= (length display) 1)
5239 (setq display (car display)))
5240 (unless gnus-summary-display-cache
5241 (dolist (elem (append '((unread . unread)
5244 gnus-article-mark-lists))
5245 (push (cons (cdr elem)
5247 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5248 gnus-summary-display-cache)))
5249 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5250 (gnus-category-predicate-cache gnus-summary-display-cache))
5251 (gnus-get-predicate display)))
5253 ;; Uses the dynamically bound `number' variable.
5256 (defun gnus-article-marked-p (type &optional article)
5257 (let ((article (or article number)))
5260 (memq article gnus-newsgroup-marked))
5262 (memq article gnus-newsgroup-spam-marked))
5264 (memq article gnus-newsgroup-unsendable))
5265 ((eq type 'undownload)
5266 (memq article gnus-newsgroup-undownloaded))
5267 ((eq type 'download)
5268 (memq article gnus-newsgroup-downloadable))
5270 (memq article gnus-newsgroup-unreads))
5272 (memq article gnus-newsgroup-reads))
5274 (memq article gnus-newsgroup-dormant) )
5276 (memq article gnus-newsgroup-expirable))
5278 (memq article gnus-newsgroup-replied))
5280 (memq article gnus-newsgroup-killed))
5281 ((eq type 'bookmark)
5282 (assq article gnus-newsgroup-bookmarks))
5284 (assq article gnus-newsgroup-scored))
5286 (memq article gnus-newsgroup-saved))
5288 (memq article gnus-newsgroup-cached))
5290 (memq article gnus-newsgroup-forwarded))
5292 (not (memq article gnus-newsgroup-unseen)))
5294 (memq article gnus-newsgroup-recent))
5297 (defun gnus-articles-to-read (group &optional read-all)
5298 "Find out what articles the user wants to read."
5299 (let* ((display (gnus-group-find-parameter group 'display))
5301 ;; Select all articles if `read-all' is non-nil, or if there
5302 ;; are no unread articles.
5304 (and (zerop (length gnus-newsgroup-marked))
5305 (zerop (length gnus-newsgroup-unreads)))
5306 ;; Fetch all if the predicate is non-nil.
5307 gnus-newsgroup-display)
5308 ;; We want to select the headers for all the articles in
5309 ;; the group, so we select either all the active
5310 ;; articles in the group, or (if that's nil), the
5311 ;; articles in the cache.
5313 (gnus-uncompress-range (gnus-active group))
5314 (gnus-cache-articles-in-group group))
5315 ;; Select only the "normal" subset of articles.
5317 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5318 gnus-newsgroup-unreads)))
5319 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5320 (scored (length scored-list))
5321 (number (length articles))
5322 (marked (+ (length gnus-newsgroup-marked)
5323 (length gnus-newsgroup-dormant)))
5328 ((numberp gnus-newsgroup-display)
5329 gnus-newsgroup-display)
5333 ((and (or (<= scored marked) (= scored number))
5334 (numberp gnus-large-newsgroup)
5335 (> number gnus-large-newsgroup))
5336 (let* ((cursor-in-echo-area nil)
5337 (initial (gnus-parameter-large-newsgroup-initial
5338 gnus-newsgroup-name))
5342 "How many articles from %s (%s %d): "
5344 (gnus-group-decoded-name gnus-newsgroup-name)
5346 (if initial "max" "default")
5349 (cons (number-to-string initial)
5351 (if (string-match "^[ \t]*$" input) number input)))
5352 ((and (> scored marked) (< scored number)
5353 (> (- scored number) 20))
5356 (format "%s %s (%d scored, %d total): "
5357 "How many articles from"
5358 (gnus-group-decoded-name group)
5360 (if (string-match "^[ \t]*$" input)
5364 (message "Quit getting the articles to read")
5366 (setq select (if (stringp select) (string-to-number select) select))
5367 (if (or (null select) (zerop select))
5369 (if (and (not (zerop scored)) (<= (abs select) scored))
5371 (setq articles (sort scored-list '<))
5372 (setq number (length articles)))
5373 (setq articles (copy-sequence articles)))
5375 (when (< (abs select) number)
5377 ;; Select the N oldest articles.
5378 (setcdr (nthcdr (1- (abs select)) articles) nil)
5379 ;; Select the N most recent articles.
5380 (setq articles (nthcdr (- number select) articles))))
5381 (setq gnus-newsgroup-unselected
5382 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5383 (when gnus-alter-articles-to-read-function
5386 (funcall gnus-alter-articles-to-read-function
5387 gnus-newsgroup-name articles)
5391 (defun gnus-killed-articles (killed articles)
5394 (when (inline (gnus-member-of-range (car articles) killed))
5395 (push (car articles) out))
5396 (setq articles (cdr articles)))
5399 (defun gnus-uncompress-marks (marks)
5400 "Uncompress the mark ranges in MARKS."
5401 (let ((uncompressed '(score bookmark))
5404 (if (memq (caar marks) uncompressed)
5405 (push (car marks) out)
5406 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5407 (setq marks (cdr marks)))
5410 (defun gnus-article-mark-to-type (mark)
5411 "Return the type of MARK."
5412 (or (cadr (assq mark gnus-article-special-mark-lists))
5415 (defun gnus-article-unpropagatable-p (mark)
5416 "Return whether MARK should be propagated to back end."
5417 (memq mark gnus-article-unpropagated-mark-lists))
5419 (defun gnus-adjust-marked-articles (info)
5420 "Set all article lists and remove all marks that are no longer valid."
5421 (let* ((marked-lists (gnus-info-marks info))
5422 (active (gnus-active (gnus-info-group info)))
5425 (types gnus-article-mark-lists)
5426 marks var articles article mark mark-type
5429 (dolist (marks marked-lists)
5430 (setq mark (car marks)
5431 mark-type (gnus-article-mark-to-type mark)
5432 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5434 ;; We set the variable according to the type of the marks list,
5435 ;; and then adjust the marks to a subset of the active articles.
5437 ;; Adjust "simple" lists - compressed yet unsorted
5438 ((eq mark-type 'list)
5439 ;; Simultaneously uncompress and clip to active range
5440 ;; See gnus-uncompress-range for a description of possible marks
5442 (if (not (cadr marks))
5444 (setq articles (if (numberp (cddr marks))
5450 (while (setq article (pop articles))
5451 (cond ((consp article)
5452 (setq bgn (max (car article) min)
5453 end (min (cdr article) max))
5455 (setq l (setcdr l (cons bgn nil))
5457 ((and (<= min article)
5459 (setq l (setcdr l (cons article nil))))))
5460 (set var (cdr lh)))))
5462 ((eq mark-type 'tuple)
5463 (set var (setq articles (cdr marks)))
5464 (when (not (listp (cdr (symbol-value var))))
5465 (set var (list (symbol-value var))))
5466 (when (not (listp (cdr articles)))
5467 (setq articles (list articles)))
5469 (when (or (not (consp (setq article (pop articles))))
5470 (< (car article) min)
5471 (> (car article) max))
5472 (set var (delq article (symbol-value var))))))
5473 ;; Adjust ranges (sloppily).
5474 ((eq mark-type 'range)
5477 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5478 ;; It should be (seen (NUM1 . NUM2)).
5479 (when (numberp (cddr marks))
5480 (setcdr marks (list (cdr marks))))
5481 (setq articles (cdr marks))
5482 (while (and articles
5483 (or (and (consp (car articles))
5484 (> min (cdar articles)))
5485 (and (numberp (car articles))
5486 (> min (car articles)))))
5488 (set var articles))))))))
5490 (defun gnus-update-missing-marks (missing)
5491 "Go through the list of MISSING articles and remove them from the mark lists."
5494 ;; Go through all types.
5495 (dolist (elem gnus-article-mark-lists)
5496 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5497 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5498 (when (symbol-value var)
5499 ;; This list has articles. So we delete all missing
5500 ;; articles from it.
5503 (set var (delq (pop m) (symbol-value var))))))))))
5505 (defun gnus-update-marks ()
5506 "Enter the various lists of marked articles into the newsgroup info list."
5507 (let ((types gnus-article-mark-lists)
5508 (info (gnus-get-info gnus-newsgroup-name))
5509 type list newmarked symbol delta-marks)
5511 ;; Add all marks lists to the list of marks lists.
5512 (while (setq type (pop types))
5513 (setq list (symbol-value
5515 (intern (format "gnus-newsgroup-%s" (car type))))))
5518 ;; Get rid of the entries of the articles that have the
5520 (when (and (eq (cdr type) 'score)
5524 (prev (cons nil list))
5527 (if (or (not (consp (car arts)))
5528 (= (cdar arts) gnus-summary-default-score))
5529 (setcdr prev (cdr arts))
5531 (setq arts (cdr arts)))
5532 (setq list (cdr all)))))
5534 (when (eq (cdr type) 'seen)
5535 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5537 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5538 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5540 (when (and (gnus-check-backend-function
5541 'request-set-mark gnus-newsgroup-name)
5542 (not (gnus-article-unpropagatable-p (cdr type))))
5543 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5544 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5545 (add (gnus-remove-from-range
5546 (gnus-copy-sequence list) old)))
5548 (push (list add 'add (list (cdr type))) delta-marks))
5550 (push (list del 'del (list (cdr type))) delta-marks))))
5553 (push (cons (cdr type) list) newmarked)))
5556 (unless (gnus-check-group gnus-newsgroup-name)
5557 (error "Can't open server for %s" gnus-newsgroup-name))
5558 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5560 ;; Enter these new marks into the info of the group.
5562 (setcar (nthcdr 3 info) newmarked)
5563 ;; Add the marks lists to the end of the info.
5565 (setcdr (nthcdr 2 info) (list newmarked))))
5567 ;; Cut off the end of the info if there's nothing else there.
5571 (when (nthcdr (decf i) info)
5572 (setcdr (nthcdr i info) nil)))))))
5574 (defun gnus-set-mode-line (where)
5575 "Set the mode line of the article or summary buffers.
5576 If WHERE is `summary', the summary mode line format will be used."
5577 ;; Is this mode line one we keep updated?
5578 (when (and (memq where gnus-updated-mode-lines)
5580 (intern (format "gnus-%s-mode-line-format-spec" where))))
5583 ;; We evaluate this in the summary buffer since these
5584 ;; variables are buffer-local to that buffer.
5585 (set-buffer gnus-summary-buffer)
5586 ;; We bind all these variables that are used in the `eval' form
5588 (let* ((mformat (symbol-value
5590 (format "gnus-%s-mode-line-format-spec" where))))
5591 (gnus-tmp-group-name (gnus-group-decoded-name
5592 gnus-newsgroup-name))
5593 (gnus-tmp-article-number (or gnus-current-article 0))
5594 (gnus-tmp-unread gnus-newsgroup-unreads)
5595 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5596 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5597 (gnus-tmp-unread-and-unselected
5598 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5599 (zerop gnus-tmp-unselected))
5601 ((zerop gnus-tmp-unselected)
5602 (format "{%d more}" gnus-tmp-unread-and-unticked))
5603 (t (format "{%d(+%d) more}"
5604 gnus-tmp-unread-and-unticked
5605 gnus-tmp-unselected))))
5607 (if (and gnus-current-headers
5608 (vectorp gnus-current-headers))
5609 (gnus-mode-string-quote
5610 (mail-header-subject gnus-current-headers))
5612 bufname-length max-len
5613 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5614 (setq mode-string (eval mformat))
5615 (setq bufname-length (if (string-match "%b" mode-string)
5618 (if (eq where 'summary)
5620 (get-buffer gnus-article-buffer))))
5623 (setq max-len (max 4 (if gnus-mode-non-string-length
5625 gnus-mode-non-string-length
5627 (length mode-string))))
5628 ;; We might have to chop a bit of the string off...
5629 (when (> (length mode-string) max-len)
5631 (concat (truncate-string-to-width mode-string (- max-len 3))
5633 ;; Pad the mode string a bit.
5634 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5635 ;; Update the mode line.
5636 (setq mode-line-buffer-identification
5637 (gnus-mode-line-buffer-identification (list mode-string)))
5638 (set-buffer-modified-p t))))
5640 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5641 "Go through the HEADERS list and add all Xrefs to a hash table.
5642 The resulting hash table is returned, or nil if no Xrefs were found."
5643 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5644 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5645 (xref-hashtb (gnus-make-hashtable))
5646 start group entry number xrefs header)
5648 (setq header (pop headers))
5649 (when (and (setq xrefs (mail-header-xref header))
5650 (not (memq (setq number (mail-header-number header))
5653 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5654 (setq start (match-end 0))
5655 (setq group (if prefix
5656 (concat prefix (substring xrefs (match-beginning 1)
5658 (substring xrefs (match-beginning 1) (match-end 1))))
5660 (string-to-int (substring xrefs (match-beginning 2)
5662 (if (setq entry (gnus-gethash group xref-hashtb))
5663 (setcdr entry (cons number (cdr entry)))
5664 (gnus-sethash group (cons number nil) xref-hashtb)))))
5665 (and start xref-hashtb)))
5667 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5668 "Look through all the headers and mark the Xrefs as read."
5669 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5670 name info xref-hashtb idlist method nth4)
5672 (set-buffer gnus-group-buffer)
5673 (when (setq xref-hashtb
5674 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5677 (unless (string= from-newsgroup (setq name (symbol-name group)))
5678 (setq idlist (symbol-value group))
5679 ;; Dead groups are not updated.
5681 (setq info (gnus-get-info name))
5682 (when (stringp (setq nth4 (gnus-info-method info)))
5683 (setq nth4 (gnus-server-to-method nth4))))
5684 ;; Only do the xrefs if the group has the same
5685 ;; select method as the group we have just read.
5686 (or (gnus-methods-equal-p
5687 nth4 (gnus-find-method-for-group from-newsgroup))
5689 (equal nth4 (setq method (gnus-find-method-for-group
5691 (and (equal (car nth4) (car method))
5692 (equal (nth 1 nth4) (nth 1 method))))
5693 gnus-use-cross-reference
5694 (or (not (eq gnus-use-cross-reference t))
5696 ;; Only do cross-references on subscribed
5697 ;; groups, if that is what is wanted.
5698 (<= (gnus-info-level info) gnus-level-subscribed))
5699 (gnus-group-make-articles-read name idlist))))
5702 (defun gnus-compute-read-articles (group articles)
5703 (let* ((entry (gnus-group-entry group))
5704 (info (nth 2 entry))
5705 (active (gnus-active group))
5708 ;; First peel off all invalid article numbers.
5710 (let ((ids articles)
5712 (while (setq id (pop ids))
5713 (when (and first (> id (cdr active)))
5714 ;; We'll end up in this situation in one particular
5715 ;; obscure situation. If you re-scan a group and get
5716 ;; a new article that is cross-posted to a different
5717 ;; group that has not been re-scanned, you might get
5718 ;; crossposted article that has a higher number than
5719 ;; Gnus believes possible. So we re-activate this
5720 ;; group as well. This might mean doing the
5721 ;; crossposting thingy will *increase* the number
5722 ;; of articles in some groups. Tsk, tsk.
5723 (setq active (or (gnus-activate-group group) active)))
5724 (when (or (> id (cdr active))
5725 (< id (car active)))
5726 (setq articles (delq id articles))))))
5727 ;; If the read list is nil, we init it.
5729 (null (gnus-info-read info))
5731 (setq ninfo (cons 1 (1- (car active))))
5732 (setq ninfo (gnus-info-read info)))
5733 ;; Then we add the read articles to the range.
5735 ninfo (setq articles (sort articles '<))))))
5737 (defun gnus-group-make-articles-read (group articles)
5738 "Update the info of GROUP to say that ARTICLES are read."
5740 (entry (gnus-group-entry group))
5741 (info (nth 2 entry))
5742 (active (gnus-active group))
5745 (setq range (gnus-compute-read-articles group articles))
5746 (with-current-buffer gnus-group-buffer
5749 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5750 (gnus-info-set-read ',info ',(gnus-info-read info))
5751 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5752 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5753 (gnus-group-update-group ,group t))))
5754 ;; Add the read articles to the range.
5755 (gnus-info-set-read info range)
5756 (gnus-request-set-mark group (list (list range 'add '(read))))
5757 ;; Then we have to re-compute how many unread
5758 ;; articles there are in this group.
5762 (setq num (- (1+ (cdr active)) (car active))))
5763 ((not (listp (cdr range)))
5764 (setq num (- (cdr active) (- (1+ (cdr range))
5768 (if (numberp (car range))
5770 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5771 (setq range (cdr range)))
5772 (setq num (- (cdr active) num))))
5773 ;; Update the number of unread articles.
5775 ;; Update the group buffer.
5776 (unless (gnus-ephemeral-group-p group)
5777 (gnus-group-update-group group t))))))
5779 (defvar gnus-newsgroup-none-id 0)
5781 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5782 (let ((cur nntp-server-buffer)
5785 (with-current-buffer gnus-summary-buffer
5786 gnus-newsgroup-dependencies)))
5788 (mail-parse-charset gnus-newsgroup-charset)
5789 (mail-parse-ignored-charsets
5790 (save-excursion (condition-case nil
5791 (set-buffer gnus-summary-buffer)
5793 gnus-newsgroup-ignored-charsets)))
5795 (set-buffer nntp-server-buffer)
5796 ;; Translate all TAB characters into SPACE characters.
5797 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5798 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5799 (ietf-drums-unfold-fws)
5800 (gnus-run-hooks 'gnus-parse-headers-hook)
5801 (let ((case-fold-search t)
5802 in-reply-to header p lines chars)
5803 (goto-char (point-min))
5804 ;; Search to the beginning of the next header. Error messages
5805 ;; do not begin with 2 or 3.
5806 (while (re-search-forward "^[23][0-9]+ " nil t)
5809 ;; This implementation of this function, with nine
5810 ;; search-forwards instead of the one re-search-forward and
5811 ;; a case (which basically was the old function) is actually
5812 ;; about twice as fast, even though it looks messier. You
5813 ;; can't have everything, I guess. Speed and elegance
5814 ;; doesn't always go hand in hand.
5823 (narrow-to-region (point)
5824 (or (and (search-forward "\n.\n" nil t)
5830 (if (search-forward "\nsubject:" nil t)
5831 (funcall gnus-decode-encoded-word-function
5832 (nnheader-header-value))
5837 (if (search-forward "\nfrom:" nil t)
5838 (funcall gnus-decode-encoded-word-function
5839 (nnheader-header-value))
5844 (if (search-forward "\ndate:" nil t)
5845 (nnheader-header-value) ""))
5849 (setq id (if (re-search-forward
5850 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5851 ;; We do it this way to make sure the Message-ID
5852 ;; is (somewhat) syntactically valid.
5853 (buffer-substring (match-beginning 1)
5855 ;; If there was no message-id, we just fake one
5856 ;; to make subsequent routines simpler.
5857 (nnheader-generate-fake-message-id))))
5861 (if (search-forward "\nreferences:" nil t)
5865 (nnheader-header-value)
5870 (search-backward ">" end t)
5873 (search-backward "<" end t)
5875 ;; Get the references from the in-reply-to header if there
5876 ;; were no references and the in-reply-to header looks
5878 (if (and (search-forward "\nin-reply-to:" nil t)
5879 (setq in-reply-to (nnheader-header-value))
5880 (string-match "<[^>]+>" in-reply-to))
5882 (setq ref (substring in-reply-to (match-beginning 0)
5884 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5885 (setq ref2 (substring in-reply-to (match-beginning 0)
5887 (when (> (length ref2) (length ref))
5894 (if (search-forward "\nchars: " nil t)
5895 (if (numberp (setq chars (ignore-errors (read cur))))
5901 (if (search-forward "\nlines: " nil t)
5902 (if (numberp (setq lines (ignore-errors (read cur))))
5908 (and (search-forward "\nxref:" nil t)
5909 (nnheader-header-value)))
5911 (when gnus-extra-headers
5912 (let ((extra gnus-extra-headers)
5916 (when (search-forward
5917 (concat "\n" (symbol-name (car extra)) ":") nil t)
5918 (push (cons (car extra) (nnheader-header-value))
5922 (when (equal id ref)
5925 (when gnus-alter-header-function
5926 (funcall gnus-alter-header-function header)
5927 (setq id (mail-header-id header)
5928 ref (gnus-parent-id (mail-header-references header))))
5931 (gnus-dependencies-add-header
5932 header dependencies force-new))
5933 (push header headers))
5934 (goto-char (point-max))
5936 (nreverse headers)))))
5938 ;; Goes through the xover lines and returns a list of vectors
5939 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5940 force-new dependencies
5941 group also-fetch-heads)
5942 "Parse the news overview data in the server buffer.
5943 Return a list of headers that match SEQUENCE (see
5944 `nntp-retrieve-headers')."
5945 ;; Get the Xref when the users reads the articles since most/some
5946 ;; NNTP servers do not include Xrefs when using XOVER.
5947 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5948 (let ((mail-parse-charset gnus-newsgroup-charset)
5949 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5950 (cur nntp-server-buffer)
5951 (dependencies (or dependencies gnus-newsgroup-dependencies))
5953 ((eq gnus-read-all-available-headers t)
5955 ((stringp gnus-read-all-available-headers)
5956 (string-match gnus-read-all-available-headers group))
5959 number headers header)
5961 (set-buffer nntp-server-buffer)
5962 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5963 ;; Allow the user to mangle the headers before parsing them.
5964 (gnus-run-hooks 'gnus-parse-headers-hook)
5965 (goto-char (point-min))
5966 (gnus-parse-without-error
5967 (while (and (or sequence allp)
5969 (setq number (read cur))
5971 (while (and sequence
5972 (< (car sequence) number))
5973 (setq sequence (cdr sequence))))
5976 (eq number (car sequence))))
5978 (setq sequence (cdr sequence))
5979 (setq header (inline
5980 (gnus-nov-parse-line
5981 number dependencies force-new)))))
5982 (push header headers))
5984 ;; A common bug in inn is that if you have posted an article and
5985 ;; then retrieves the active file, it will answer correctly --
5986 ;; the new article is included. However, a NOV entry for the
5987 ;; article may not have been generated yet, so this may fail.
5988 ;; We work around this problem by retrieving the last few
5989 ;; headers using HEAD.
5990 (if (or (not also-fetch-heads)
5992 ;; We (probably) got all the headers.
5994 (let ((gnus-nov-is-evil t))
5997 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5998 (gnus-get-newsgroup-headers))))))))
6000 (defun gnus-article-get-xrefs ()
6001 "Fill in the Xref value in `gnus-current-headers', if necessary.
6002 This is meant to be called in `gnus-article-internal-prepare-hook'."
6003 (let ((headers (with-current-buffer gnus-summary-buffer
6004 gnus-current-headers)))
6005 (or (not gnus-use-cross-reference)
6007 (and (mail-header-xref headers)
6008 (not (string= (mail-header-xref headers) "")))
6009 (let ((case-fold-search t)
6012 (nnheader-narrow-to-headers)
6013 (goto-char (point-min))
6014 (when (or (and (not (eobp))
6015 (eq (downcase (char-after)) ?x)
6016 (looking-at "Xref:"))
6017 (search-forward "\nXref:" nil t))
6018 (goto-char (1+ (match-end 0)))
6019 (setq xref (buffer-substring (point) (point-at-eol)))
6020 (mail-header-set-xref headers xref)))))))
6022 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6023 "Find article ID and insert the summary line for that article.
6024 OLD-HEADER can either be a header or a line number to insert
6025 the subject line on."
6026 (let* ((line (and (numberp old-header) old-header))
6027 (old-header (and (vectorp old-header) old-header))
6028 (header (cond ((and old-header use-old-header)
6031 (gnus-number-to-header id))
6032 (gnus-number-to-header id))
6034 (gnus-read-header id))))
6035 (number (and (numberp id) id))
6038 ;; Rebuild the thread that this article is part of and go to the
6039 ;; article we have fetched.
6040 (when (and (not gnus-show-threads)
6043 (setq d (gnus-data-find (mail-header-number old-header))))
6044 (goto-char (gnus-data-pos d))
6050 (gnus-delete-line))))))
6052 (mail-header-set-number header (mail-header-number old-header)))
6053 (setq gnus-newsgroup-sparse
6054 (delq (setq number (mail-header-number header))
6055 gnus-newsgroup-sparse))
6056 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6057 (push number gnus-newsgroup-limit)
6058 (gnus-rebuild-thread (mail-header-id header) line)
6059 (gnus-summary-goto-subject number nil t))
6060 (when (and (numberp number)
6062 ;; We have to update the boundaries even if we can't fetch the
6063 ;; article if ID is a number -- so that the next `P' or `N'
6064 ;; command will fetch the previous (or next) article even
6065 ;; if the one we tried to fetch this time has been canceled.
6066 (when (> number gnus-newsgroup-end)
6067 (setq gnus-newsgroup-end number))
6068 (when (< number gnus-newsgroup-begin)
6069 (setq gnus-newsgroup-begin number))
6070 (setq gnus-newsgroup-unselected
6071 (delq number gnus-newsgroup-unselected)))
6072 ;; Report back a success?
6073 (and header (mail-header-number header))))
6075 ;;; Process/prefix in the summary buffer
6077 (defun gnus-summary-work-articles (n)
6078 "Return a list of articles to be worked upon.
6079 The prefix argument, the list of process marked articles, and the
6080 current article will be taken into consideration."
6082 (set-buffer gnus-summary-buffer)
6085 ;; A numerical prefix has been given.
6086 (setq n (prefix-numeric-value n))
6087 (let ((backward (< n 0))
6088 (n (abs (prefix-numeric-value n)))
6093 (push (setq article (gnus-summary-article-number))
6096 (gnus-summary-find-prev nil article)
6097 (gnus-summary-find-next nil article)))
6099 (nreverse articles)))
6100 ((and (gnus-region-active-p) (mark))
6101 (message "region active")
6102 ;; Work on the region between point and mark.
6103 (let ((max (max (point) (mark)))
6106 (goto-char (min (min (point) (mark))))
6109 (push (setq article (gnus-summary-article-number)) articles)
6110 (gnus-summary-find-next nil article)
6112 (nreverse articles))))
6113 (gnus-newsgroup-processable
6114 ;; There are process-marked articles present.
6115 ;; Save current state.
6116 (gnus-summary-save-process-mark)
6118 (reverse gnus-newsgroup-processable))
6120 ;; Just return the current article.
6121 (list (gnus-summary-article-number))))))
6123 (defmacro gnus-summary-iterate (arg &rest forms)
6124 "Iterate over the process/prefixed articles and do FORMS.
6125 ARG is the interactive prefix given to the command. FORMS will be
6126 executed with point over the summary line of the articles."
6127 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6128 `(let ((,articles (gnus-summary-work-articles ,arg)))
6130 (gnus-summary-goto-subject (car ,articles))
6134 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6135 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6137 (defun gnus-summary-save-process-mark ()
6138 "Push the current set of process marked articles on the stack."
6140 (push (copy-sequence gnus-newsgroup-processable)
6141 gnus-newsgroup-process-stack))
6143 (defun gnus-summary-kill-process-mark ()
6144 "Push the current set of process marked articles on the stack and unmark."
6146 (gnus-summary-save-process-mark)
6147 (gnus-summary-unmark-all-processable))
6149 (defun gnus-summary-yank-process-mark ()
6150 "Pop the last process mark state off the stack and restore it."
6152 (unless gnus-newsgroup-process-stack
6153 (error "Empty mark stack"))
6154 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6156 (defun gnus-summary-process-mark-set (set)
6157 "Make SET into the current process marked articles."
6158 (gnus-summary-unmark-all-processable)
6160 (gnus-summary-set-process-mark (pop set))))
6162 ;;; Searching and stuff
6164 (defun gnus-summary-search-group (&optional backward use-level)
6165 "Search for next unread newsgroup.
6166 If optional argument BACKWARD is non-nil, search backward instead."
6168 (set-buffer gnus-group-buffer)
6169 (when (gnus-group-search-forward
6170 backward nil (if use-level (gnus-group-group-level) nil))
6171 (gnus-group-group-name))))
6173 (defun gnus-summary-best-group (&optional exclude-group)
6174 "Find the name of the best unread group.
6175 If EXCLUDE-GROUP, do not go to this group."
6176 (with-current-buffer gnus-group-buffer
6178 (gnus-group-best-unread-group exclude-group))))
6180 (defun gnus-summary-find-next (&optional unread article backward)
6182 (gnus-summary-find-prev unread article)
6183 (let* ((dummy (gnus-summary-article-intangible-p))
6184 (article (or article (gnus-summary-article-number)))
6185 (data (gnus-data-find-list article))
6187 (when (and (not dummy)
6188 (or (not gnus-summary-check-current)
6190 (not (gnus-data-unread-p (car data)))))
6191 (setq data (cdr data)))
6196 (unless (memq (gnus-data-number (car data))
6198 ((eq gnus-auto-goto-ignores
6199 'always-undownloaded)
6200 gnus-newsgroup-undownloaded)
6203 ((eq gnus-auto-goto-ignores
6205 gnus-newsgroup-unfetched)
6206 ((eq gnus-auto-goto-ignores
6208 gnus-newsgroup-undownloaded)))
6209 (when (gnus-data-unread-p (car data))
6210 (setq result (car data)
6212 (setq data (cdr data)))
6215 (goto-char (gnus-data-pos result))
6216 (gnus-data-number result)))))
6218 (defun gnus-summary-find-prev (&optional unread article)
6219 (let* ((eobp (eobp))
6220 (article (or article (gnus-summary-article-number)))
6221 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6223 (when (and (not eobp)
6224 (or (not gnus-summary-check-current)
6226 (not (gnus-data-unread-p (car data)))))
6227 (setq data (cdr data)))
6232 (unless (memq (gnus-data-number (car data))
6234 ((eq gnus-auto-goto-ignores
6235 'always-undownloaded)
6236 gnus-newsgroup-undownloaded)
6239 ((eq gnus-auto-goto-ignores
6241 gnus-newsgroup-unfetched)
6242 ((eq gnus-auto-goto-ignores
6244 gnus-newsgroup-undownloaded)))
6245 (when (gnus-data-unread-p (car data))
6246 (setq result (car data)
6248 (setq data (cdr data)))
6251 (goto-char (gnus-data-pos result))
6252 (gnus-data-number result))))
6254 (defun gnus-summary-find-subject (subject &optional unread backward article)
6255 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6256 (article (or article (gnus-summary-article-number)))
6257 (articles (gnus-data-list backward))
6258 (arts (gnus-data-find-list article articles))
6260 (when (or (not gnus-summary-check-current)
6262 (not (gnus-data-unread-p (car arts))))
6263 (setq arts (cdr arts)))
6265 (and (or (not unread)
6266 (gnus-data-unread-p (car arts)))
6267 (vectorp (gnus-data-header (car arts)))
6269 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6270 (setq result (car arts)
6272 (setq arts (cdr arts)))
6274 (goto-char (gnus-data-pos result))
6275 (gnus-data-number result))))
6277 (defun gnus-summary-search-forward (&optional unread subject backward)
6278 "Search forward for an article.
6279 If UNREAD, look for unread articles. If SUBJECT, look for
6280 articles with that subject. If BACKWARD, search backward instead."
6281 (cond (subject (gnus-summary-find-subject subject unread backward))
6282 (backward (gnus-summary-find-prev unread))
6283 (t (gnus-summary-find-next unread))))
6285 (defun gnus-recenter (&optional n)
6286 "Center point in window and redisplay frame.
6287 Also do horizontal recentering."
6289 (when (and gnus-auto-center-summary
6290 (not (eq gnus-auto-center-summary 'vertical)))
6291 (gnus-horizontal-recenter))
6294 (defun gnus-summary-recenter ()
6295 "Center point in the summary window.
6296 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6297 displayed, no centering will be performed."
6298 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6299 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6301 ;; The user has to want it.
6302 (when gnus-auto-center-summary
6303 (let* ((top (cond ((< (window-height) 4) 0)
6304 ((< (window-height) 7) 1)
6305 (t (if (numberp gnus-auto-center-summary)
6306 gnus-auto-center-summary
6308 (height (1- (window-height)))
6309 (bottom (save-excursion (goto-char (point-max))
6310 (forward-line (- height))
6312 (window (get-buffer-window (current-buffer))))
6313 (when (get-buffer-window gnus-article-buffer)
6314 ;; Only do recentering when the article buffer is displayed,
6315 ;; Set the window start to either `bottom', which is the biggest
6316 ;; possible valid number, or the second line from the top,
6317 ;; whichever is the least.
6318 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6319 (if (> bottom top-pos)
6320 ;; Keep the second line from the top visible
6321 (set-window-start window top-pos t)
6322 ;; Try to keep the bottom line visible; if it's partially
6323 ;; obscured, either scroll one more line to make it fully
6324 ;; visible, or revert to using TOP-POS.
6326 (goto-char (point-max))
6328 (let ((last-line-start (point)))
6330 (set-window-start window (point) t)
6331 (when (not (pos-visible-in-window-p last-line-start window))
6333 (set-window-start window (min (point) top-pos) t)))))))
6334 ;; Do horizontal recentering while we're at it.
6335 (when (and (get-buffer-window (current-buffer) t)
6336 (not (eq gnus-auto-center-summary 'vertical)))
6337 (let ((selected (selected-window)))
6338 (select-window (get-buffer-window (current-buffer) t))
6339 (gnus-summary-position-point)
6340 (gnus-horizontal-recenter)
6341 (select-window selected))))))
6343 (defun gnus-summary-jump-to-group (newsgroup)
6344 "Move point to NEWSGROUP in group mode buffer."
6345 ;; Keep update point of group mode buffer if visible.
6346 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6347 (save-window-excursion
6348 ;; Take care of tree window mode.
6349 (when (get-buffer-window gnus-group-buffer)
6350 (pop-to-buffer gnus-group-buffer))
6351 (gnus-group-jump-to-group newsgroup))
6353 ;; Take care of tree window mode.
6354 (if (get-buffer-window gnus-group-buffer)
6355 (pop-to-buffer gnus-group-buffer)
6356 (set-buffer gnus-group-buffer))
6357 (gnus-group-jump-to-group newsgroup))))
6359 ;; This function returns a list of article numbers based on the
6360 ;; difference between the ranges of read articles in this group and
6361 ;; the range of active articles.
6362 (defun gnus-list-of-unread-articles (group)
6363 (let* ((read (gnus-info-read (gnus-get-info group)))
6364 (active (or (gnus-active group) (gnus-activate-group group)))
6367 ;; If none are read, then all are unread.
6369 (setq first (car active))
6370 ;; If the range of read articles is a single range, then the
6371 ;; first unread article is the article after the last read
6372 ;; article. Sounds logical, doesn't it?
6373 (if (and (not (listp (cdr read)))
6374 (or (< (car read) (car active))
6375 (progn (setq read (list read))
6377 (setq first (max (car active) (1+ (cdr read))))
6378 ;; `read' is a list of ranges.
6379 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6382 (setq first (car active)))
6385 (while (< first nlast)
6386 (setq unread (cons first unread)
6388 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6389 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6390 (setq read (cdr read)))))
6391 ;; And add the last unread articles.
6392 (while (<= first last)
6393 (setq unread (cons first unread)
6395 ;; Return the list of unread articles.
6396 (delq 0 (nreverse unread))))
6398 (defun gnus-list-of-read-articles (group)
6399 "Return a list of unread, unticked and non-dormant articles."
6400 (let* ((info (gnus-get-info group))
6401 (marked (gnus-info-marks info))
6402 (active (gnus-active group)))
6404 (gnus-list-range-difference
6405 (gnus-list-range-difference
6406 (gnus-sorted-complement
6407 (gnus-uncompress-range active)
6408 (gnus-list-of-unread-articles group))
6409 (cdr (assq 'dormant marked)))
6410 (cdr (assq 'tick marked))))))
6412 ;; This function returns a sequence of article numbers based on the
6413 ;; difference between the ranges of read articles in this group and
6414 ;; the range of active articles.
6415 (defun gnus-sequence-of-unread-articles (group)
6416 (let* ((read (gnus-info-read (gnus-get-info group)))
6417 (active (or (gnus-active group) (gnus-activate-group group)))
6420 ;; If none are read, then all are unread.
6422 (setq first (car active))
6423 ;; If the range of read articles is a single range, then the
6424 ;; first unread article is the article after the last read
6425 ;; article. Sounds logical, doesn't it?
6426 (if (and (not (listp (cdr read)))
6427 (or (< (car read) (car active))
6428 (progn (setq read (list read))
6430 (setq first (max (car active) (1+ (cdr read))))
6431 ;; `read' is a list of ranges.
6432 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6435 (setq first (car active)))
6438 (push (cons first nlast) unread))
6439 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6440 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6441 (setq read (cdr read)))))
6442 ;; And add the last unread articles.
6443 (cond ((< first last)
6444 (push (cons first last) unread))
6446 (push first unread)))
6447 ;; Return the sequence of unread articles.
6448 (delq 0 (nreverse unread))))
6450 ;; Various summary commands
6452 (defun gnus-summary-select-article-buffer ()
6453 "Reconfigure windows to show article buffer."
6455 (if (not (gnus-buffer-live-p gnus-article-buffer))
6456 (error "There is no article buffer for this summary buffer")
6457 (gnus-configure-windows 'article)
6458 (select-window (get-buffer-window gnus-article-buffer))))
6460 (defun gnus-summary-universal-argument (arg)
6461 "Perform any operation on all articles that are process/prefixed."
6463 (let ((articles (gnus-summary-work-articles arg))
6470 (substitute-command-keys
6471 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6473 (gnus-error 1 "Undefined key")
6476 (gnus-summary-goto-subject (setq article (pop articles)))
6477 (let (gnus-newsgroup-processable)
6478 (command-execute func))
6479 (gnus-summary-remove-process-mark article)))))
6480 (gnus-summary-position-point))
6482 (defun gnus-summary-toggle-truncation (&optional arg)
6483 "Toggle truncation of summary lines.
6484 With ARG, turn line truncation on if ARG is positive."
6486 (setq truncate-lines
6487 (if (null arg) (not truncate-lines)
6488 (> (prefix-numeric-value arg) 0)))
6491 (defun gnus-summary-find-for-reselect ()
6492 "Return the number of an article to stay on across a reselect.
6493 The current article is considered, then following articles, then previous
6494 articles. An article is sought which is not cancelled and isn't a temporary
6495 insertion from another group. If there's no such then return a dummy 0."
6497 (dolist (rev '(nil t))
6498 (unless found ; don't demand the reverse list if we don't need it
6499 (let ((data (gnus-data-find-list
6500 (gnus-summary-article-number) (gnus-data-list rev))))
6501 (while (and data (not found))
6502 (if (and (< 0 (gnus-data-number (car data)))
6503 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6504 (setq found (gnus-data-number (car data))))
6505 (setq data (cdr data))))))
6508 (defun gnus-summary-reselect-current-group (&optional all rescan)
6509 "Exit and then reselect the current newsgroup.
6510 The prefix argument ALL means to select all articles."
6512 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6513 (error "Ephemeral groups can't be reselected"))
6514 (let ((current-subject (gnus-summary-find-for-reselect))
6515 (group gnus-newsgroup-name))
6516 (setq gnus-newsgroup-begin nil)
6517 (gnus-summary-exit nil 'leave-hidden)
6518 ;; We have to adjust the point of group mode buffer because
6519 ;; point was moved to the next unread newsgroup by exiting.
6520 (gnus-summary-jump-to-group group)
6523 (gnus-group-get-new-news-this-group 1)))
6524 (gnus-group-read-group all t)
6525 (gnus-summary-goto-subject current-subject nil t)))
6527 (defun gnus-summary-rescan-group (&optional all)
6528 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6530 (gnus-summary-reselect-current-group all t))
6532 (defun gnus-summary-update-info (&optional non-destructive)
6534 (let ((group gnus-newsgroup-name))
6536 (when gnus-newsgroup-kill-headers
6537 (setq gnus-newsgroup-killed
6538 (gnus-compress-sequence
6540 (gnus-list-range-intersection
6541 gnus-newsgroup-unselected gnus-newsgroup-killed)
6542 gnus-newsgroup-unreads)
6544 (unless (listp (cdr gnus-newsgroup-killed))
6545 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6546 (let ((headers gnus-newsgroup-headers))
6547 ;; Set the new ranges of read articles.
6548 (with-current-buffer gnus-group-buffer
6549 (gnus-undo-force-boundary))
6550 (gnus-update-read-articles
6551 group (gnus-sorted-union
6552 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6553 ;; Set the current article marks.
6554 (let ((gnus-newsgroup-scored
6555 (if (and (not gnus-save-score)
6556 (not non-destructive))
6558 gnus-newsgroup-scored)))
6560 (gnus-update-marks)))
6561 ;; Do the cross-ref thing.
6562 (when gnus-use-cross-reference
6563 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6564 ;; Do not switch windows but change the buffer to work.
6565 (set-buffer gnus-group-buffer)
6566 (unless (gnus-ephemeral-group-p group)
6567 (gnus-group-update-group group)))))))
6569 (defun gnus-summary-save-newsrc (&optional force)
6570 "Save the current number of read/marked articles in the dribble buffer.
6571 The dribble buffer will then be saved.
6572 If FORCE (the prefix), also save the .newsrc file(s)."
6574 (gnus-summary-update-info t)
6576 (gnus-save-newsrc-file)
6577 (gnus-dribble-save)))
6579 (defun gnus-summary-exit (&optional temporary leave-hidden)
6580 "Exit reading current newsgroup, and then return to group selection mode.
6581 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6583 (gnus-set-global-variables)
6584 (when (gnus-buffer-live-p gnus-article-buffer)
6586 (set-buffer gnus-article-buffer)
6587 (mm-destroy-parts gnus-article-mime-handles)
6588 ;; Set it to nil for safety reason.
6589 (setq gnus-article-mime-handle-alist nil)
6590 (setq gnus-article-mime-handles nil)))
6591 (gnus-kill-save-kill-buffer)
6592 (gnus-async-halt-prefetch)
6593 (let* ((group gnus-newsgroup-name)
6594 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6595 (gnus-group-is-exiting-p t)
6598 (buf (current-buffer)))
6600 ;; Do adaptive scoring, and possibly save score files.
6601 (when gnus-newsgroup-adaptive
6602 (gnus-score-adaptive))
6603 (when gnus-use-scoring
6605 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6606 ;; If we have several article buffers, we kill them at exit.
6607 (unless gnus-single-article-buffer
6608 (gnus-kill-buffer gnus-original-article-buffer)
6609 (setq gnus-article-current nil))
6610 (when gnus-use-cache
6611 (gnus-cache-possibly-remove-articles)
6612 (gnus-cache-save-buffers))
6613 (gnus-async-prefetch-remove-group group)
6614 (when gnus-suppress-duplicates
6615 (gnus-dup-enter-articles))
6616 (when gnus-use-trees
6617 (gnus-tree-close group))
6618 (when gnus-use-cache
6619 (gnus-cache-write-active))
6620 ;; Remove entries for this group.
6621 (nnmail-purge-split-history (gnus-group-real-name group))
6622 ;; Make all changes in this group permanent.
6624 (gnus-run-hooks 'gnus-exit-group-hook)
6625 (gnus-summary-update-info))
6626 (gnus-close-group group)
6627 ;; Make sure where we were, and go to next newsgroup.
6628 (set-buffer gnus-group-buffer)
6630 (gnus-group-jump-to-group group))
6631 (gnus-run-hooks 'gnus-summary-exit-hook)
6632 (unless (or quit-config
6633 ;; If this group has disappeared from the summary
6634 ;; buffer, don't skip forwards.
6635 (not (string= group (gnus-group-group-name))))
6636 (gnus-group-next-unread-group 1))
6637 (setq group-point (point))
6640 ;; If we have several article buffers, we kill them at exit.
6641 (unless gnus-single-article-buffer
6642 (gnus-kill-buffer gnus-article-buffer)
6643 (gnus-kill-buffer gnus-original-article-buffer)
6644 (setq gnus-article-current nil))
6646 (if (not gnus-kill-summary-on-exit)
6648 (gnus-deaden-summary)
6650 ;; We set all buffer-local variables to nil. It is unclear why
6651 ;; this is needed, but if we don't, buffer-local variables are
6652 ;; not garbage-collected, it seems. This would the lead to en
6653 ;; ever-growing Emacs.
6654 (gnus-summary-clear-local-variables)
6655 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6656 (gnus-summary-clear-local-variables))
6657 (when (get-buffer gnus-article-buffer)
6658 (bury-buffer gnus-article-buffer))
6659 ;; We clear the global counterparts of the buffer-local
6660 ;; variables as well, just to be on the safe side.
6661 (set-buffer gnus-group-buffer)
6662 (gnus-summary-clear-local-variables)
6663 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6664 (gnus-summary-clear-local-variables))
6665 ;; Return to group mode buffer.
6666 (when (eq mode 'gnus-summary-mode)
6667 (gnus-kill-buffer buf)))
6668 (setq gnus-current-select-method gnus-select-method)
6670 (set-buffer gnus-group-buffer)
6671 (pop-to-buffer gnus-group-buffer))
6672 (if (not quit-config)
6674 (goto-char group-point)
6675 (unless leave-hidden
6676 (gnus-configure-windows 'group 'force)))
6677 (gnus-handle-ephemeral-exit quit-config))
6678 ;; Clear the current group name.
6680 (setq gnus-newsgroup-name nil)))))
6682 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6683 (defun gnus-summary-exit-no-update (&optional no-questions)
6684 "Quit reading current newsgroup without updating read article info."
6686 (let* ((group gnus-newsgroup-name)
6687 (gnus-group-is-exiting-p t)
6688 (gnus-group-is-exiting-without-update-p t)
6689 (quit-config (gnus-group-quit-config group)))
6690 (when (or no-questions
6692 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6693 (gnus-async-halt-prefetch)
6694 (run-hooks 'gnus-summary-prepare-exit-hook)
6695 (when (gnus-buffer-live-p gnus-article-buffer)
6697 (set-buffer gnus-article-buffer)
6698 (mm-destroy-parts gnus-article-mime-handles)
6699 ;; Set it to nil for safety reason.
6700 (setq gnus-article-mime-handle-alist nil)
6701 (setq gnus-article-mime-handles nil)))
6702 ;; If we have several article buffers, we kill them at exit.
6703 (unless gnus-single-article-buffer
6704 (gnus-kill-buffer gnus-article-buffer)
6705 (gnus-kill-buffer gnus-original-article-buffer)
6706 (setq gnus-article-current nil))
6707 (if (not gnus-kill-summary-on-exit)
6708 (gnus-deaden-summary)
6709 (gnus-close-group group)
6710 (gnus-summary-clear-local-variables)
6711 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6712 (gnus-summary-clear-local-variables))
6713 (set-buffer gnus-group-buffer)
6714 (gnus-summary-clear-local-variables)
6715 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6716 (gnus-summary-clear-local-variables))
6717 (gnus-kill-buffer gnus-summary-buffer))
6718 (unless gnus-single-article-buffer
6719 (setq gnus-article-current nil))
6720 (when gnus-use-trees
6721 (gnus-tree-close group))
6722 (gnus-async-prefetch-remove-group group)
6723 (when (get-buffer gnus-article-buffer)
6724 (bury-buffer gnus-article-buffer))
6725 ;; Return to the group buffer.
6726 (gnus-configure-windows 'group 'force)
6727 ;; Clear the current group name.
6728 (setq gnus-newsgroup-name nil)
6729 (unless (gnus-ephemeral-group-p group)
6730 (gnus-group-update-group group))
6731 (when (equal (gnus-group-group-name) group)
6732 (gnus-group-next-unread-group 1))
6734 (gnus-handle-ephemeral-exit quit-config)))))
6736 (defun gnus-handle-ephemeral-exit (quit-config)
6737 "Handle movement when leaving an ephemeral group.
6738 The state which existed when entering the ephemeral is reset."
6739 (if (not (buffer-name (car quit-config)))
6740 (gnus-configure-windows 'group 'force)
6741 (set-buffer (car quit-config))
6742 (cond ((eq major-mode 'gnus-summary-mode)
6743 (gnus-set-global-variables))
6744 ((eq major-mode 'gnus-article-mode)
6746 ;; The `gnus-summary-buffer' variable may point
6747 ;; to the old summary buffer when using a single
6749 (unless (gnus-buffer-live-p gnus-summary-buffer)
6750 (set-buffer gnus-group-buffer))
6751 (set-buffer gnus-summary-buffer)
6752 (gnus-set-global-variables))))
6753 (if (or (eq (cdr quit-config) 'article)
6754 (eq (cdr quit-config) 'pick))
6756 ;; The current article may be from the ephemeral group
6757 ;; thus it is best that we reload this article
6759 ;; If we're exiting from a large digest, this can be
6760 ;; extremely slow. So, it's better not to reload it. -- jh.
6761 ;;(gnus-summary-show-article)
6762 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6763 (gnus-configure-windows 'pick 'force)
6764 (gnus-configure-windows (cdr quit-config) 'force)))
6765 (gnus-configure-windows (cdr quit-config) 'force))
6766 (when (eq major-mode 'gnus-summary-mode)
6767 (gnus-summary-next-subject 1 nil t)
6768 (gnus-summary-recenter)
6769 (gnus-summary-position-point))))
6773 (defvar gnus-dead-summary-mode-map nil)
6775 (unless gnus-dead-summary-mode-map
6776 (setq gnus-dead-summary-mode-map (make-keymap))
6777 (suppress-keymap gnus-dead-summary-mode-map)
6778 (substitute-key-definition
6779 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6780 (dolist (key '("\C-d" "\r" "\177" [delete]))
6781 (define-key gnus-dead-summary-mode-map
6782 key 'gnus-summary-wake-up-the-dead))
6783 (dolist (key '("q" "Q"))
6784 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6786 (defvar gnus-dead-summary-mode nil
6787 "Minor mode for Gnus summary buffers.")
6789 (defun gnus-dead-summary-mode (&optional arg)
6790 "Minor mode for Gnus summary buffers."
6792 (when (eq major-mode 'gnus-summary-mode)
6793 (make-local-variable 'gnus-dead-summary-mode)
6794 (setq gnus-dead-summary-mode
6795 (if (null arg) (not gnus-dead-summary-mode)
6796 (> (prefix-numeric-value arg) 0)))
6797 (when gnus-dead-summary-mode
6799 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6801 (defun gnus-deaden-summary ()
6802 "Make the current summary buffer into a dead summary buffer."
6803 ;; Kill any previous dead summary buffer.
6804 (when (and gnus-dead-summary
6805 (buffer-name gnus-dead-summary))
6806 (with-current-buffer gnus-dead-summary
6807 (when gnus-dead-summary-mode
6808 (kill-buffer (current-buffer)))))
6809 ;; Make this the current dead summary.
6810 (setq gnus-dead-summary (current-buffer))
6811 (gnus-dead-summary-mode 1)
6812 (let ((name (buffer-name)))
6813 (when (string-match "Summary" name)
6815 (concat (substring name 0 (match-beginning 0)) "Dead "
6816 (substring name (match-beginning 0)))
6820 (defun gnus-kill-or-deaden-summary (buffer)
6821 "Kill or deaden the summary BUFFER."
6823 (when (and (buffer-name buffer)
6824 (not gnus-single-article-buffer))
6825 (with-current-buffer buffer
6826 (gnus-kill-buffer gnus-article-buffer)
6827 (gnus-kill-buffer gnus-original-article-buffer)))
6830 (gnus-kill-summary-on-exit
6831 (when (and gnus-use-trees
6832 (gnus-buffer-exists-p buffer))
6835 (gnus-tree-close gnus-newsgroup-name)))
6836 (gnus-kill-buffer buffer))
6837 ;; Deaden the buffer.
6838 ((gnus-buffer-exists-p buffer)
6841 (gnus-deaden-summary))))))
6843 (defun gnus-summary-wake-up-the-dead (&rest args)
6844 "Wake up the dead summary buffer."
6846 (gnus-dead-summary-mode -1)
6847 (let ((name (buffer-name)))
6848 (when (string-match "Dead " name)
6850 (concat (substring name 0 (match-beginning 0))
6851 (substring name (match-end 0)))
6853 (gnus-message 3 "This dead summary is now alive again"))
6855 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6856 (defun gnus-summary-fetch-faq (&optional faq-dir)
6857 "Fetch the FAQ for the current group.
6858 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6862 (when current-prefix-arg
6864 "FAQ dir: " (and (listp gnus-group-faq-directory)
6866 gnus-group-faq-directory))))))
6867 (let (gnus-faq-buffer)
6868 (when (setq gnus-faq-buffer
6869 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6870 (gnus-configure-windows 'summary-faq))))
6872 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6873 (defun gnus-summary-describe-group (&optional force)
6874 "Describe the current newsgroup."
6876 (gnus-group-describe-group force gnus-newsgroup-name))
6878 (defun gnus-summary-describe-briefly ()
6879 "Describe summary mode commands briefly."
6881 (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")))
6883 ;; Walking around group mode buffer from summary mode.
6885 (defun gnus-summary-next-group (&optional no-article target-group backward)
6886 "Exit current newsgroup and then select next unread newsgroup.
6887 If prefix argument NO-ARTICLE is non-nil, no article is selected
6888 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6889 previous group instead."
6891 ;; Stop pre-fetching.
6892 (gnus-async-halt-prefetch)
6893 (let ((current-group gnus-newsgroup-name)
6894 (current-buffer (current-buffer))
6896 ;; First we semi-exit this group to update Xrefs and all variables.
6897 ;; We can't do a real exit, because the window conf must remain
6898 ;; the same in case the user is prompted for info, and we don't
6899 ;; want the window conf to change before that...
6900 (gnus-summary-exit t)
6901 (while (not entered)
6902 ;; Then we find what group we are supposed to enter.
6903 (set-buffer gnus-group-buffer)
6904 (gnus-group-jump-to-group current-group)
6907 (if (eq gnus-keep-same-level 'best)
6908 (gnus-summary-best-group gnus-newsgroup-name)
6909 (gnus-summary-search-group backward gnus-keep-same-level))))
6910 (if (not target-group)
6911 ;; There are no further groups, so we return to the group
6914 (gnus-message 5 "Returning to the group buffer")
6916 (when (gnus-buffer-live-p current-buffer)
6917 (set-buffer current-buffer)
6918 (gnus-summary-exit))
6919 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6920 ;; We try to enter the target group.
6921 (gnus-group-jump-to-group target-group)
6922 (let ((unreads (gnus-group-group-unread)))
6923 (if (and (or (eq t unreads)
6924 (and unreads (not (zerop unreads))))
6925 (gnus-summary-read-group
6926 target-group nil no-article
6927 (and (buffer-name current-buffer) current-buffer)
6930 (setq current-group target-group
6931 target-group nil)))))))
6933 (defun gnus-summary-prev-group (&optional no-article)
6934 "Exit current newsgroup and then select previous unread newsgroup.
6935 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6937 (gnus-summary-next-group no-article nil t))
6939 ;; Walking around summary lines.
6941 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6942 "Go to the first subject satisfying any non-nil constraint.
6943 If UNREAD is non-nil, the article should be unread.
6944 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6945 If UNSEEN is non-nil, the article should be unseen.
6946 Returns the article selected or nil if there are no matching articles."
6950 ((null gnus-newsgroup-data)
6951 (gnus-message 3 "No articles in the group")
6953 ;; Pick the first article.
6954 ((not (or unread undownloaded unseen))
6955 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6956 (gnus-data-number (car gnus-newsgroup-data)))
6957 ;; Find the first unread article.
6959 (let ((data gnus-newsgroup-data))
6961 (let ((num (gnus-data-number (car data))))
6962 (or (memq num gnus-newsgroup-unfetched)
6963 (not (or (and unread
6964 (memq num gnus-newsgroup-unreads))
6966 (memq num gnus-newsgroup-undownloaded))
6968 (memq num gnus-newsgroup-unseen)))))))
6969 (setq data (cdr data)))
6973 (goto-char (gnus-data-pos (car data)))
6974 (gnus-data-number (car data)))
6975 (gnus-message 3 "No more%s articles"
6976 (let* ((r (when unread " unread"))
6977 (d (when undownloaded " undownloaded"))
6978 (s (when unseen " unseen"))
6979 (l (delq nil (list r d s))))
6980 (cond ((= 3 (length l))
6981 (concat r "," d ", or" s))
6983 (concat (car l) ", or" (cadr l)))
6990 (gnus-summary-position-point))))))
6992 (defun gnus-summary-next-subject (n &optional unread dont-display)
6993 "Go to next N'th summary line.
6994 If N is negative, go to the previous N'th subject line.
6995 If UNREAD is non-nil, only unread articles are selected.
6996 The difference between N and the actual number of steps taken is
6999 (let ((backward (< n 0))
7003 (gnus-summary-find-prev unread)
7004 (gnus-summary-find-next unread)))
7005 (unless (zerop (setq n (1- n)))
7006 (gnus-summary-show-thread)))
7008 (gnus-message 7 "No more%s articles"
7009 (if unread " unread" "")))
7010 (unless dont-display
7011 (gnus-summary-recenter)
7012 (gnus-summary-position-point))
7015 (defun gnus-summary-next-unread-subject (n)
7016 "Go to next N'th unread summary line."
7018 (gnus-summary-next-subject n t))
7020 (defun gnus-summary-prev-subject (n &optional unread)
7021 "Go to previous N'th summary line.
7022 If optional argument UNREAD is non-nil, only unread article is selected."
7024 (gnus-summary-next-subject (- n) unread))
7026 (defun gnus-summary-prev-unread-subject (n)
7027 "Go to previous N'th unread summary line."
7029 (gnus-summary-next-subject (- n) t))
7031 (defun gnus-summary-goto-subjects (articles)
7032 "Insert the subject header for ARTICLES in the current buffer."
7034 (dolist (article articles)
7035 (gnus-summary-goto-subject article t)))
7036 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7037 (gnus-summary-position-point))
7039 (defun gnus-summary-goto-subject (article &optional force silent)
7040 "Go the subject line of ARTICLE.
7041 If FORCE, also allow jumping to articles not currently shown."
7042 (interactive "nArticle number: ")
7043 (unless (numberp article)
7044 (error "Article %s is not a number" article))
7046 (data (gnus-data-find article)))
7047 ;; We read in the article if we have to.
7050 (gnus-summary-insert-subject
7052 (if (or (numberp force) (vectorp force)) force)
7054 (setq data (gnus-data-find article)))
7059 (gnus-message 3 "Can't find article %d" article))
7061 (let ((pt (gnus-data-pos data)))
7063 (gnus-summary-set-article-display-arrow pt))
7064 (gnus-summary-position-point)
7067 ;; Walking around summary lines with displaying articles.
7069 (defun gnus-summary-expand-window (&optional arg)
7070 "Make the summary buffer take up the entire Emacs frame.
7071 Given a prefix, will force an `article' buffer configuration."
7074 (gnus-configure-windows 'article 'force)
7075 (gnus-configure-windows 'summary 'force)))
7077 (defun gnus-summary-display-article (article &optional all-header)
7078 "Display ARTICLE in article buffer."
7079 (when (gnus-buffer-live-p gnus-article-buffer)
7080 (with-current-buffer gnus-article-buffer
7081 (mm-enable-multibyte)))
7082 (gnus-set-global-variables)
7083 (when (gnus-buffer-live-p gnus-article-buffer)
7084 (with-current-buffer gnus-article-buffer
7085 (setq gnus-article-charset gnus-newsgroup-charset)
7086 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7087 (mm-enable-multibyte)))
7091 (if gnus-summary-display-article-function
7092 (funcall gnus-summary-display-article-function article all-header)
7093 (gnus-article-prepare article all-header))
7094 (gnus-run-hooks 'gnus-select-article-hook)
7095 (when (and gnus-current-article
7096 (not (zerop gnus-current-article)))
7097 (gnus-summary-goto-subject gnus-current-article))
7098 (gnus-summary-recenter)
7099 (when (and gnus-use-trees gnus-show-threads)
7100 (gnus-possibly-generate-tree article)
7101 (gnus-highlight-selected-tree article))
7102 ;; Successfully display article.
7103 (gnus-article-set-window-start
7104 (cdr (assq article gnus-newsgroup-bookmarks))))))
7106 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7107 "Select the current article.
7108 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7109 non-nil, the article will be re-fetched even if it already present in
7110 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7112 ;; Make sure we are in the summary buffer to work around bbdb bug.
7113 (unless (eq major-mode 'gnus-summary-mode)
7114 (set-buffer gnus-summary-buffer))
7115 (let ((article (or article (gnus-summary-article-number)))
7116 (all-headers (not (not all-headers))) ;Must be t or nil.
7117 gnus-summary-display-article-function)
7119 (gnus-summary-article-pseudo-p article)
7120 (error "This is a pseudo-article"))
7122 (set-buffer gnus-summary-buffer)
7123 (if (or (and gnus-single-article-buffer
7124 (or (null gnus-current-article)
7125 (null gnus-article-current)
7126 (null (get-buffer gnus-article-buffer))
7127 (not (eq article (cdr gnus-article-current)))
7128 (not (equal (car gnus-article-current)
7129 gnus-newsgroup-name))))
7130 (and (not gnus-single-article-buffer)
7131 (or (null gnus-current-article)
7132 (not (eq gnus-current-article article))))
7134 ;; The requested article is different from the current article.
7136 (gnus-summary-display-article article all-headers)
7137 (when (gnus-buffer-live-p gnus-article-buffer)
7138 (with-current-buffer gnus-article-buffer
7139 (if (not gnus-article-decoded-p) ;; a local variable
7140 (mm-disable-multibyte))))
7141 (gnus-article-set-window-start
7142 (cdr (assq article gnus-newsgroup-bookmarks)))
7146 (defun gnus-summary-force-verify-and-decrypt ()
7147 "Display buttons for signed/encrypted parts and verify/decrypt them."
7149 (let ((mm-verify-option 'known)
7150 (mm-decrypt-option 'known)
7151 (gnus-article-emulate-mime t)
7152 (gnus-buttonized-mime-types (append (list "multipart/signed"
7153 "multipart/encrypted")
7154 gnus-buttonized-mime-types)))
7155 (gnus-summary-select-article nil 'force)))
7157 (defun gnus-summary-set-current-mark (&optional current-mark)
7158 "Obsolete function."
7161 (defun gnus-summary-next-article (&optional unread subject backward push)
7162 "Select the next article.
7163 If UNREAD, only unread articles are selected.
7164 If SUBJECT, only articles with SUBJECT are selected.
7165 If BACKWARD, the previous article is selected instead of the next."
7168 ;; Is there such an article?
7169 ((and (gnus-summary-search-forward unread subject backward)
7170 (or (gnus-summary-display-article (gnus-summary-article-number))
7171 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7172 (gnus-summary-position-point))
7173 ;; If not, we try the first unread, if that is wanted.
7175 gnus-auto-select-same
7176 (gnus-summary-first-unread-article))
7177 (gnus-summary-position-point)
7178 (gnus-message 6 "Wrapped"))
7179 ;; Try to get next/previous article not displayed in this group.
7180 ((and gnus-auto-extend-newsgroup
7181 (not unread) (not subject))
7182 (gnus-summary-goto-article
7183 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7184 nil (count-lines (point-min) (point))))
7185 ;; Go to next/previous group.
7187 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7188 (gnus-summary-jump-to-group gnus-newsgroup-name))
7189 (let ((cmd last-command-char)
7191 (with-current-buffer gnus-group-buffer
7194 (if (eq gnus-keep-same-level 'best)
7195 (gnus-summary-best-group gnus-newsgroup-name)
7196 (gnus-summary-search-group backward gnus-keep-same-level))))
7197 ;; For some reason, the group window gets selected. We change
7199 (select-window (get-buffer-window (current-buffer)))
7200 ;; Select next unread newsgroup automagically.
7202 ((or (not gnus-auto-select-next)
7204 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7205 ((or (eq gnus-auto-select-next 'quietly)
7206 (and (eq gnus-auto-select-next 'slightly-quietly)
7208 (and (eq gnus-auto-select-next 'almost-quietly)
7209 (gnus-summary-last-article-p)))
7211 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7213 (gnus-message 7 "No more%s articles (%s)..."
7214 (if unread " unread" "")
7215 (if group (concat "selecting " group)
7217 (gnus-summary-next-group nil group backward)))
7219 (when (gnus-key-press-event-p last-input-event)
7220 (gnus-summary-walk-group-buffer
7221 gnus-newsgroup-name cmd unread backward point))))))))
7223 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7224 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7225 (?\C-p (gnus-group-prev-unread-group 1))))
7226 (cursor-in-echo-area t)
7227 keve key group ended prompt)
7229 (set-buffer gnus-group-buffer)
7232 (if (eq gnus-keep-same-level 'best)
7233 (gnus-summary-best-group gnus-newsgroup-name)
7234 (gnus-summary-search-group backward gnus-keep-same-level))))
7238 "No more%s articles%s " (if unread " unread" "")
7240 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7241 (format " (Type %s for %s [%s])"
7242 (single-key-description cmd) group
7243 (gnus-group-unread group))
7244 (format " (Type %s to exit %s)"
7245 (single-key-description cmd)
7246 gnus-newsgroup-name))))
7247 ;; Confirm auto selection.
7248 (setq key (car (setq keve (gnus-read-event-char prompt)))
7251 ((assq key keystrokes)
7252 (let ((obuf (current-buffer)))
7253 (switch-to-buffer gnus-group-buffer)
7255 (gnus-group-jump-to-group group))
7256 (eval (cadr (assq key keystrokes)))
7257 (setq group (gnus-group-group-name))
7258 (switch-to-buffer obuf))
7262 (gnus-ephemeral-group-p gnus-newsgroup-name))
7264 (gnus-summary-next-group nil group backward)))
7266 (push (cdr keve) unread-command-events))))))
7268 (defun gnus-summary-next-unread-article ()
7269 "Select unread article after current one."
7271 (gnus-summary-next-article
7272 (or (not (eq gnus-summary-goto-unread 'never))
7273 (gnus-summary-last-article-p (gnus-summary-article-number)))
7274 (and gnus-auto-select-same
7275 (gnus-summary-article-subject))))
7277 (defun gnus-summary-prev-article (&optional unread subject)
7278 "Select the article after the current one.
7279 If UNREAD is non-nil, only unread articles are selected."
7281 (gnus-summary-next-article unread subject t))
7283 (defun gnus-summary-prev-unread-article ()
7284 "Select unread article before current one."
7286 (gnus-summary-prev-article
7287 (or (not (eq gnus-summary-goto-unread 'never))
7288 (gnus-summary-first-article-p (gnus-summary-article-number)))
7289 (and gnus-auto-select-same
7290 (gnus-summary-article-subject))))
7292 (defun gnus-summary-next-page (&optional lines circular stop)
7293 "Show next page of the selected article.
7294 If at the end of the current article, select the next article.
7295 LINES says how many lines should be scrolled up.
7297 If CIRCULAR is non-nil, go to the start of the article instead of
7298 selecting the next article when reaching the end of the current
7301 If STOP is non-nil, just stop when reaching the end of the message.
7303 Also see the variable `gnus-article-skip-boring'."
7305 (setq gnus-summary-buffer (current-buffer))
7306 (gnus-set-global-variables)
7307 (let ((article (gnus-summary-article-number))
7308 (article-window (get-buffer-window gnus-article-buffer t))
7310 ;; If the buffer is empty, we have no article.
7312 (error "No article to select"))
7313 (gnus-configure-windows 'article)
7314 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7315 (if (and (eq gnus-summary-goto-unread 'never)
7316 (not (gnus-summary-last-article-p article)))
7317 (gnus-summary-next-article)
7318 (gnus-summary-next-unread-article))
7319 (if (or (null gnus-current-article)
7320 (null gnus-article-current)
7321 (/= article (cdr gnus-article-current))
7322 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7323 ;; Selected subject is different from current article's.
7324 (gnus-summary-display-article article)
7325 (when article-window
7326 (gnus-eval-in-buffer-window gnus-article-buffer
7327 (setq endp (or (gnus-article-next-page lines)
7328 (gnus-article-only-boring-p))))
7331 (gnus-message 3 "End of message"))
7333 (gnus-summary-beginning-of-article))
7335 (gnus-message 3 "End of message"))
7337 (if (and (eq gnus-summary-goto-unread 'never)
7338 (not (gnus-summary-last-article-p article)))
7339 (gnus-summary-next-article)
7340 (gnus-summary-next-unread-article))))))))
7341 (gnus-summary-recenter)
7342 (gnus-summary-position-point)))
7344 (defun gnus-summary-prev-page (&optional lines move)
7345 "Show previous page of selected article.
7346 Argument LINES specifies lines to be scrolled down.
7347 If MOVE, move to the previous unread article if point is at
7348 the beginning of the buffer."
7350 (let ((article (gnus-summary-article-number))
7351 (article-window (get-buffer-window gnus-article-buffer t))
7353 (gnus-configure-windows 'article)
7354 (if (or (null gnus-current-article)
7355 (null gnus-article-current)
7356 (/= article (cdr gnus-article-current))
7357 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7358 ;; Selected subject is different from current article's.
7359 (gnus-summary-display-article article)
7360 (gnus-summary-recenter)
7361 (when article-window
7362 (gnus-eval-in-buffer-window gnus-article-buffer
7363 (setq endp (gnus-article-prev-page lines)))
7364 (when (and move endp)
7366 (gnus-message 3 "Beginning of message"))
7368 (if (and (eq gnus-summary-goto-unread 'never)
7369 (not (gnus-summary-first-article-p article)))
7370 (gnus-summary-prev-article)
7371 (gnus-summary-prev-unread-article))))))))
7372 (gnus-summary-position-point))
7374 (defun gnus-summary-prev-page-or-article (&optional lines)
7375 "Show previous page of selected article.
7376 Argument LINES specifies lines to be scrolled down.
7377 If at the beginning of the article, go to the next article."
7379 (gnus-summary-prev-page lines t))
7381 (defun gnus-summary-scroll-up (lines)
7382 "Scroll up (or down) one line current article.
7383 Argument LINES specifies lines to be scrolled up (or down if negative)."
7385 (gnus-configure-windows 'article)
7386 (gnus-summary-show-thread)
7387 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7388 (gnus-eval-in-buffer-window gnus-article-buffer
7390 (when (gnus-article-next-page lines)
7391 (gnus-message 3 "End of message")))
7393 (gnus-article-prev-page (- lines))))))
7394 (gnus-summary-recenter)
7395 (gnus-summary-position-point))
7397 (defun gnus-summary-scroll-down (lines)
7398 "Scroll down (or up) one line current article.
7399 Argument LINES specifies lines to be scrolled down (or up if negative)."
7401 (gnus-summary-scroll-up (- lines)))
7403 (defun gnus-summary-next-same-subject ()
7404 "Select next article which has the same subject as current one."
7406 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7408 (defun gnus-summary-prev-same-subject ()
7409 "Select previous article which has the same subject as current one."
7411 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7413 (defun gnus-summary-next-unread-same-subject ()
7414 "Select next unread article which has the same subject as current one."
7416 (gnus-summary-next-article t (gnus-summary-article-subject)))
7418 (defun gnus-summary-prev-unread-same-subject ()
7419 "Select previous unread article which has the same subject as current one."
7421 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7423 (defun gnus-summary-first-unread-article ()
7424 "Select the first unread article.
7425 Return nil if there are no unread articles."
7428 (when (gnus-summary-first-subject t)
7429 (gnus-summary-show-thread)
7430 (gnus-summary-first-subject t)
7431 (gnus-summary-display-article (gnus-summary-article-number)))
7432 (gnus-summary-position-point)))
7434 (defun gnus-summary-first-unread-subject ()
7435 "Place the point on the subject line of the first unread article.
7436 Return nil if there are no unread articles."
7439 (when (gnus-summary-first-subject t)
7440 (gnus-summary-show-thread)
7441 (gnus-summary-first-subject t))
7442 (gnus-summary-position-point)))
7444 (defun gnus-summary-first-unseen-subject ()
7445 "Place the point on the subject line of the first unseen article.
7446 Return nil if there are no unseen articles."
7449 (when (gnus-summary-first-subject nil nil t)
7450 (gnus-summary-show-thread)
7451 (gnus-summary-first-subject nil nil t))
7452 (gnus-summary-position-point)))
7454 (defun gnus-summary-first-unseen-or-unread-subject ()
7455 "Place the point on the subject line of the first unseen article or,
7456 if all article have been seen, on the subject line of the first unread
7460 (unless (when (gnus-summary-first-subject nil nil t)
7461 (gnus-summary-show-thread)
7462 (gnus-summary-first-subject nil nil t))
7463 (when (gnus-summary-first-subject t)
7464 (gnus-summary-show-thread)
7465 (gnus-summary-first-subject t)))
7466 (gnus-summary-position-point)))
7468 (defun gnus-summary-first-article ()
7469 "Select the first article.
7470 Return nil if there are no articles."
7473 (when (gnus-summary-first-subject)
7474 (gnus-summary-show-thread)
7475 (gnus-summary-first-subject)
7476 (gnus-summary-display-article (gnus-summary-article-number)))
7477 (gnus-summary-position-point)))
7479 (defun gnus-summary-best-unread-article (&optional arg)
7480 "Select the unread article with the highest score.
7481 If given a prefix argument, select the next unread article that has a
7482 score higher than the default score."
7484 (let ((article (if arg
7485 (gnus-summary-better-unread-subject)
7486 (gnus-summary-best-unread-subject))))
7488 (gnus-summary-goto-article article)
7489 (error "No unread articles"))))
7491 (defun gnus-summary-best-unread-subject ()
7492 "Select the unread subject with the highest score."
7494 (let ((best -1000000)
7495 (data gnus-newsgroup-data)
7498 (and (gnus-data-unread-p (car data))
7500 (gnus-summary-article-score (gnus-data-number (car data))))
7503 article (gnus-data-number (car data))))
7504 (setq data (cdr data)))
7506 (gnus-summary-goto-subject article))
7507 (gnus-summary-position-point)
7510 (defun gnus-summary-better-unread-subject ()
7511 "Select the first unread subject that has a score over the default score."
7513 (let ((data gnus-newsgroup-data)
7515 (while (and (setq article (gnus-data-number (car data)))
7516 (or (gnus-data-read-p (car data))
7517 (not (> (gnus-summary-article-score article)
7518 gnus-summary-default-score))))
7519 (setq data (cdr data)))
7521 (gnus-summary-goto-subject article))
7522 (gnus-summary-position-point)
7525 (defun gnus-summary-last-subject ()
7526 "Go to the last displayed subject line in the group."
7527 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7529 (gnus-summary-goto-subject article))))
7531 (defun gnus-summary-goto-article (article &optional all-headers force)
7532 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7533 If ALL-HEADERS is non-nil, no header lines are hidden.
7534 If FORCE, go to the article even if it isn't displayed. If FORCE
7535 is a number, it is the line the article is to be displayed on."
7539 "Article number or Message-ID: "
7540 (mapcar (lambda (number) (list (int-to-string number)))
7541 gnus-newsgroup-limit))
7545 (if (and (stringp article)
7546 (string-match "@\\|%40" article))
7547 (gnus-summary-refer-article article)
7548 (when (stringp article)
7549 (setq article (string-to-number article)))
7550 (if (gnus-summary-goto-subject article force)
7551 (gnus-summary-display-article article all-headers)
7552 (gnus-message 4 "Couldn't go to article %s" article) nil))
7553 (gnus-summary-position-point)))
7555 (defun gnus-summary-goto-last-article ()
7556 "Go to the previously read article."
7559 (when gnus-last-article
7560 (gnus-summary-goto-article gnus-last-article nil t))
7561 (gnus-summary-position-point)))
7563 (defun gnus-summary-pop-article (number)
7564 "Pop one article off the history and go to the previous.
7565 NUMBER articles will be popped off."
7568 (setq gnus-newsgroup-history
7569 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7571 (gnus-summary-goto-article (car to) nil t)
7572 (error "Article history empty")))
7573 (gnus-summary-position-point))
7575 ;; Summary commands and functions for limiting the summary buffer.
7577 (defun gnus-summary-limit-to-articles (n)
7578 "Limit the summary buffer to the next N articles.
7579 If not given a prefix, use the process marked articles instead."
7582 (let ((articles (gnus-summary-work-articles n)))
7583 (setq gnus-newsgroup-processable nil)
7584 (gnus-summary-limit articles))
7585 (gnus-summary-position-point)))
7587 (defun gnus-summary-pop-limit (&optional total)
7588 "Restore the previous limit.
7589 If given a prefix, remove all limits."
7592 (setq gnus-newsgroup-limits
7593 (list (mapcar (lambda (h) (mail-header-number h))
7594 gnus-newsgroup-headers))))
7595 (unless gnus-newsgroup-limits
7596 (error "No limit to pop"))
7598 (gnus-summary-limit nil 'pop)
7599 (gnus-summary-position-point)))
7601 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7602 "Limit the summary buffer to articles that have subjects that match a regexp.
7603 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7605 (list (read-string (if current-prefix-arg
7606 "Exclude subject (regexp): "
7607 "Limit to subject (regexp): "))
7608 nil current-prefix-arg))
7610 (setq header "subject"))
7611 (when (not (equal "" subject))
7613 (let ((articles (gnus-summary-find-matching
7614 (or header "subject") subject 'all nil nil
7617 (error "Found no matches for \"%s\"" subject))
7618 (gnus-summary-limit articles))
7619 (gnus-summary-position-point))))
7621 (defun gnus-summary-limit-to-author (from &optional not-matching)
7622 "Limit the summary buffer to articles that have authors that match a regexp.
7623 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7625 (list (read-string (if current-prefix-arg
7626 "Exclude author (regexp): "
7627 "Limit to author (regexp): "))
7628 current-prefix-arg))
7629 (gnus-summary-limit-to-subject from "from" not-matching))
7631 (defun gnus-summary-limit-to-age (age &optional younger-p)
7632 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7633 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7634 articles that are younger than AGE days."
7636 (let ((younger current-prefix-arg)
7639 (while (not days-got)
7640 (setq days (if younger
7641 (read-string "Limit to articles younger than (in days, older when negative): ")
7643 "Limit to articles older than (in days, younger when negative): ")))
7644 (when (> (length days) 0)
7645 (setq days (read days)))
7650 (setq younger (not younger))
7651 (setq days (* days -1))))
7652 (message "Please enter a number.")
7654 (list days younger)))
7656 (let ((data gnus-newsgroup-data)
7657 (cutoff (days-to-time age))
7658 articles d date is-younger)
7659 (while (setq d (pop data))
7660 (when (and (vectorp (gnus-data-header d))
7661 (setq date (mail-header-date (gnus-data-header d))))
7662 (setq is-younger (time-less-p
7663 (time-since (condition-case ()
7670 (push (gnus-data-number d) articles))))
7671 (gnus-summary-limit (nreverse articles)))
7672 (gnus-summary-position-point)))
7674 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7675 "Limit the summary buffer to articles that match an 'extra' header."
7679 (gnus-completing-read-with-default
7680 (symbol-name (car gnus-extra-headers))
7681 (if current-prefix-arg
7682 "Exclude extra header:"
7683 "Limit extra header:")
7685 (cons (symbol-name x) x))
7690 (read-string (format "%s header %s (regexp): "
7691 (if current-prefix-arg "Exclude" "Limit to")
7693 current-prefix-arg)))
7694 (when (not (equal "" regexp))
7696 (let ((articles (gnus-summary-find-matching
7697 (cons 'extra header) regexp 'all nil nil
7700 (error "Found no matches for \"%s\"" regexp))
7701 (gnus-summary-limit articles))
7702 (gnus-summary-position-point))))
7704 (defun gnus-summary-limit-to-display-predicate ()
7705 "Limit the summary buffer to the predicated in the `display' group parameter."
7707 (unless gnus-newsgroup-display
7708 (error "There is no `display' group parameter"))
7710 (dolist (number gnus-newsgroup-articles)
7711 (when (funcall gnus-newsgroup-display)
7712 (push number articles)))
7713 (gnus-summary-limit articles))
7714 (gnus-summary-position-point))
7716 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7718 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7720 (defun gnus-summary-limit-to-unread (&optional all)
7721 "Limit the summary buffer to articles that are not marked as read.
7722 If ALL is non-nil, limit strictly to unread articles."
7725 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7726 (gnus-summary-limit-to-marks
7727 ;; Concat all the marks that say that an article is read and have
7729 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7730 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7731 gnus-low-score-mark gnus-expirable-mark
7732 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7733 gnus-duplicate-mark gnus-souped-mark)
7736 (defun gnus-summary-limit-to-replied (&optional unreplied)
7737 "Limit the summary buffer to replied articles.
7738 If UNREPLIED (the prefix), limit to unreplied articles."
7742 (gnus-set-difference gnus-newsgroup-articles
7743 gnus-newsgroup-replied))
7744 (gnus-summary-limit gnus-newsgroup-replied))
7745 (gnus-summary-position-point))
7747 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7748 (make-obsolete 'gnus-summary-delete-marked-with
7749 'gnus-summary-limit-exclude-marks)
7751 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7752 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7753 If REVERSE, limit the summary buffer to articles that are marked
7754 with MARKS. MARKS can either be a string of marks or a list of marks.
7755 Returns how many articles were removed."
7756 (interactive "sMarks: ")
7757 (gnus-summary-limit-to-marks marks t))
7759 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7760 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7761 If REVERSE (the prefix), limit the summary buffer to articles that are
7762 not marked with MARKS. MARKS can either be a string of marks or a
7764 Returns how many articles were removed."
7765 (interactive "sMarks: \nP")
7767 (let ((data gnus-newsgroup-data)
7768 (marks (if (listp marks) marks
7769 (append marks nil))) ; Transform to list.
7772 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7773 (memq (gnus-data-mark (car data)) marks))
7774 (push (gnus-data-number (car data)) articles))
7775 (setq data (cdr data)))
7776 (gnus-summary-limit articles))
7777 (gnus-summary-position-point)))
7779 (defun gnus-summary-limit-to-score (score)
7780 "Limit to articles with score at or above SCORE."
7781 (interactive "NLimit to articles with score of at least: ")
7782 (let ((data gnus-newsgroup-data)
7785 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7787 (push (gnus-data-number (car data)) articles))
7788 (setq data (cdr data)))
7790 (gnus-summary-limit articles)
7791 (gnus-summary-position-point))))
7793 (defun gnus-summary-limit-to-unseen ()
7794 "Limit to unseen articles."
7797 (gnus-summary-limit gnus-newsgroup-unseen)
7798 (gnus-summary-position-point)))
7800 (defun gnus-summary-limit-include-thread (id)
7801 "Display all the hidden articles that is in the thread with ID in it.
7802 When called interactively, ID is the Message-ID of the current
7804 (interactive (list (mail-header-id (gnus-summary-article-header))))
7805 (let ((articles (gnus-articles-in-thread
7806 (gnus-id-to-thread (gnus-root-id id)))))
7808 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7809 (gnus-summary-limit-include-matching-articles
7811 (regexp-quote (gnus-simplify-subject-re
7812 (mail-header-subject (gnus-id-to-header id)))))
7813 (gnus-summary-position-point))))
7815 (defun gnus-summary-limit-include-matching-articles (header regexp)
7816 "Display all the hidden articles that have HEADERs that match REGEXP."
7817 (interactive (list (read-string "Match on header: ")
7818 (read-string "Regexp: ")))
7819 (let ((articles (gnus-find-matching-articles header regexp)))
7821 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7822 (gnus-summary-position-point))))
7824 (defun gnus-summary-insert-dormant-articles ()
7825 "Insert all the dormant articles for this group into the current buffer."
7827 (let ((gnus-verbose (max 6 gnus-verbose)))
7828 (if (not gnus-newsgroup-dormant)
7829 (gnus-message 3 "No cached articles for this group")
7830 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7832 (defun gnus-summary-limit-include-dormant ()
7833 "Display all the hidden articles that are marked as dormant.
7834 Note that this command only works on a subset of the articles currently
7835 fetched for this group."
7837 (unless gnus-newsgroup-dormant
7838 (error "There are no dormant articles in this group"))
7840 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7841 (gnus-summary-position-point)))
7843 (defun gnus-summary-limit-exclude-dormant ()
7844 "Hide all dormant articles."
7847 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7848 (gnus-summary-position-point)))
7850 (defun gnus-summary-limit-exclude-childless-dormant ()
7851 "Hide all dormant articles that have no children."
7853 (let ((data (gnus-data-list t))
7854 articles d children)
7855 ;; Find all articles that are either not dormant or have
7857 (while (setq d (pop data))
7858 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7860 (gnus-article-children (gnus-data-number d)))
7863 (when (memq (car children) articles)
7868 (push (gnus-data-number d) articles)))
7871 (gnus-summary-limit articles)
7872 (gnus-summary-position-point))))
7874 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7875 "Mark all unread excluded articles as read.
7876 If ALL, mark even excluded ticked and dormants as read."
7878 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7879 (let ((articles (gnus-sorted-ndifference
7881 (mapcar (lambda (h) (mail-header-number h))
7882 gnus-newsgroup-headers)
7884 gnus-newsgroup-limit))
7886 (setq gnus-newsgroup-unreads
7887 (gnus-sorted-intersection gnus-newsgroup-unreads
7888 gnus-newsgroup-limit))
7890 (setq gnus-newsgroup-dormant nil
7891 gnus-newsgroup-marked nil
7892 gnus-newsgroup-reads
7894 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7895 gnus-newsgroup-reads))
7896 (while (setq article (pop articles))
7897 (unless (or (memq article gnus-newsgroup-dormant)
7898 (memq article gnus-newsgroup-marked))
7899 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7901 (defun gnus-summary-limit (articles &optional pop)
7903 ;; We pop the previous limit off the stack and use that.
7904 (setq articles (car gnus-newsgroup-limits)
7905 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7906 ;; We use the new limit, so we push the old limit on the stack.
7907 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7909 (setq gnus-newsgroup-limit articles)
7910 (let ((total (length gnus-newsgroup-data))
7911 (data (gnus-data-find-list (gnus-summary-article-number)))
7912 (gnus-summary-mark-below nil) ; Inhibit this.
7914 ;; This will do all the work of generating the new summary buffer
7915 ;; according to the new limit.
7916 (gnus-summary-prepare)
7917 ;; Hide any threads, possibly.
7918 (gnus-summary-maybe-hide-threads)
7919 ;; Try to return to the article you were at, or one in the
7922 ;; We try to find some article after the current one.
7924 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7927 (setq data (cdr data))))
7929 ;; If there is no data, that means that we were after the last
7930 ;; article. The same goes when we can't find any articles
7931 ;; after the current one.
7932 (goto-char (point-max))
7933 (gnus-summary-find-prev))
7934 (gnus-set-mode-line 'summary)
7935 ;; We return how many articles were removed from the summary
7936 ;; buffer as a result of the new limit.
7937 (- total (length gnus-newsgroup-data))))
7939 (defsubst gnus-invisible-cut-children (threads)
7942 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7947 (defsubst gnus-cut-thread (thread)
7948 "Go forwards in the thread until we find an article that we want to display."
7949 (when (or (eq gnus-fetch-old-headers 'some)
7950 (eq gnus-fetch-old-headers 'invisible)
7951 (numberp gnus-fetch-old-headers)
7952 (eq gnus-build-sparse-threads 'some)
7953 (eq gnus-build-sparse-threads 'more))
7954 ;; Deal with old-fetched headers and sparse threads.
7958 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7959 (gnus-summary-article-ancient-p
7960 (mail-header-number (car thread))))
7961 (if (or (<= (length (cdr thread)) 1)
7962 (eq gnus-fetch-old-headers 'invisible))
7963 (setq gnus-newsgroup-limit
7964 (delq (mail-header-number (car thread))
7965 gnus-newsgroup-limit)
7966 thread (cadr thread))
7967 (when (gnus-invisible-cut-children (cdr thread))
7968 (let ((th (cdr thread)))
7970 (if (memq (mail-header-number (caar th))
7971 gnus-newsgroup-limit)
7972 (setq thread (car th)
7974 (setq th (cdr th))))))))))
7977 (defun gnus-cut-threads (threads)
7978 "Cut off all uninteresting articles from the beginning of THREADS."
7979 (when (or (eq gnus-fetch-old-headers 'some)
7980 (eq gnus-fetch-old-headers 'invisible)
7981 (numberp gnus-fetch-old-headers)
7982 (eq gnus-build-sparse-threads 'some)
7983 (eq gnus-build-sparse-threads 'more))
7986 (setcar th (gnus-cut-thread (car th)))
7987 (setq th (cdr th)))))
7988 ;; Remove nixed out threads.
7991 (defun gnus-summary-initial-limit (&optional show-if-empty)
7992 "Figure out what the initial limit is supposed to be on group entry.
7993 This entails weeding out unwanted dormants, low-scored articles,
7994 fetch-old-headers verbiage, and so on."
7995 ;; Most groups have nothing to remove.
7996 (if (or gnus-inhibit-limiting
7997 (and (null gnus-newsgroup-dormant)
7998 (eq gnus-newsgroup-display 'gnus-not-ignore)
7999 (not (eq gnus-fetch-old-headers 'some))
8000 (not (numberp gnus-fetch-old-headers))
8001 (not (eq gnus-fetch-old-headers 'invisible))
8002 (null gnus-summary-expunge-below)
8003 (not (eq gnus-build-sparse-threads 'some))
8004 (not (eq gnus-build-sparse-threads 'more))
8005 (null gnus-thread-expunge-below)
8006 (not gnus-use-nocem)))
8008 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8009 (setq gnus-newsgroup-limit nil)
8012 (unless (car (symbol-value node))
8013 ;; These threads have no parents -- they are roots.
8014 (let ((nodes (cdr (symbol-value node)))
8017 (if (and gnus-thread-expunge-below
8018 (< (gnus-thread-total-score (car nodes))
8019 gnus-thread-expunge-below))
8020 (gnus-expunge-thread (pop nodes))
8021 (setq thread (pop nodes))
8022 (gnus-summary-limit-children thread))))))
8023 gnus-newsgroup-dependencies)
8024 ;; If this limitation resulted in an empty group, we might
8025 ;; pop the previous limit and use it instead.
8026 (when (and (not gnus-newsgroup-limit)
8028 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8029 gnus-newsgroup-limit))
8031 (defun gnus-summary-limit-children (thread)
8032 "Return 1 if this subthread is visible and 0 if it is not."
8033 ;; First we get the number of visible children to this thread. This
8034 ;; is done by recursing down the thread using this function, so this
8035 ;; will really go down to a leaf article first, before slowly
8036 ;; working its way up towards the root.
8038 (let* ((max-lisp-eval-depth 5000)
8041 (apply '+ (mapcar 'gnus-summary-limit-children
8044 (number (mail-header-number (car thread)))
8047 (not (memq number gnus-newsgroup-marked))
8049 ;; If this article is dormant and has absolutely no visible
8050 ;; children, then this article isn't visible.
8051 (and (memq number gnus-newsgroup-dormant)
8053 ;; If this is "fetch-old-headered" and there is no
8054 ;; visible children, then we don't want this article.
8055 (and (or (eq gnus-fetch-old-headers 'some)
8056 (numberp gnus-fetch-old-headers))
8057 (gnus-summary-article-ancient-p number)
8059 ;; If this is "fetch-old-headered" and `invisible', then
8060 ;; we don't want this article.
8061 (and (eq gnus-fetch-old-headers 'invisible)
8062 (gnus-summary-article-ancient-p number))
8063 ;; If this is a sparsely inserted article with no children,
8064 ;; we don't want it.
8065 (and (eq gnus-build-sparse-threads 'some)
8066 (gnus-summary-article-sparse-p number)
8068 ;; If we use expunging, and this article is really
8069 ;; low-scored, then we don't want this article.
8070 (when (and gnus-summary-expunge-below
8072 (or (cdr (assq number gnus-newsgroup-scored))
8073 gnus-summary-default-score))
8074 gnus-summary-expunge-below))
8075 ;; We increase the expunge-tally here, but that has
8076 ;; nothing to do with the limits, really.
8077 (incf gnus-newsgroup-expunged-tally)
8078 ;; We also mark as read here, if that's wanted.
8079 (when (and gnus-summary-mark-below
8080 (< score gnus-summary-mark-below))
8081 (setq gnus-newsgroup-unreads
8082 (delq number gnus-newsgroup-unreads))
8083 (if gnus-newsgroup-auto-expire
8084 (push number gnus-newsgroup-expirable)
8085 (push (cons number gnus-low-score-mark)
8086 gnus-newsgroup-reads)))
8088 ;; Do the `display' group parameter.
8089 (and gnus-newsgroup-display
8090 (not (funcall gnus-newsgroup-display)))
8091 ;; Check NoCeM things.
8092 (when (and gnus-use-nocem
8093 (gnus-nocem-unwanted-article-p
8094 (mail-header-id (car thread))))
8095 (setq gnus-newsgroup-unreads
8096 (delq number gnus-newsgroup-unreads))
8098 ;; Nope, invisible article.
8100 ;; Ok, this article is to be visible, so we add it to the limit
8102 (push number gnus-newsgroup-limit)
8105 (defun gnus-expunge-thread (thread)
8106 "Mark all articles in THREAD as read."
8107 (let* ((number (mail-header-number (car thread))))
8108 (incf gnus-newsgroup-expunged-tally)
8109 ;; We also mark as read here, if that's wanted.
8110 (setq gnus-newsgroup-unreads
8111 (delq number gnus-newsgroup-unreads))
8112 (if gnus-newsgroup-auto-expire
8113 (push number gnus-newsgroup-expirable)
8114 (push (cons number gnus-low-score-mark)
8115 gnus-newsgroup-reads)))
8116 ;; Go recursively through all subthreads.
8117 (mapcar 'gnus-expunge-thread (cdr thread)))
8119 ;; Summary article oriented commands
8121 (defun gnus-summary-refer-parent-article (n)
8122 "Refer parent article N times.
8123 If N is negative, go to ancestor -N instead.
8124 The difference between N and the number of articles fetched is returned."
8128 (when (not (natnump n))
8133 (setq header (gnus-summary-article-header))
8134 (if (and (eq (mail-header-number header)
8135 (cdr gnus-article-current))
8136 (equal gnus-newsgroup-name
8137 (car gnus-article-current)))
8138 ;; If we try to find the parent of the currently
8139 ;; displayed article, then we take a look at the actual
8140 ;; References header, since this is slightly more
8141 ;; reliable than the References field we got from the
8144 (set-buffer gnus-original-article-buffer)
8145 (nnheader-narrow-to-headers)
8146 (unless (setq ref (message-fetch-field "references"))
8147 (when (setq ref (message-fetch-field "in-reply-to"))
8148 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8151 ;; It's not the current article, so we take a bet on
8152 ;; the value we got from the server.
8153 (mail-header-references header)))
8155 (not (equal ref "")))
8156 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8157 (gnus-message 1 "Couldn't find parent"))
8158 (gnus-message 1 "No references in article %d"
8159 (gnus-summary-article-number))
8162 (gnus-summary-position-point)
8165 (defun gnus-summary-refer-references ()
8166 "Fetch all articles mentioned in the References header.
8167 Return the number of articles fetched."
8169 (let ((ref (mail-header-references (gnus-summary-article-header)))
8170 (current (gnus-summary-article-number))
8174 (error "No References in the current article")
8175 ;; For each Message-ID in the References header...
8176 (while (string-match "<[^>]*>" ref)
8178 ;; ... fetch that article.
8179 (gnus-summary-refer-article
8180 (prog1 (match-string 0 ref)
8181 (setq ref (substring ref (match-end 0))))))
8182 (gnus-summary-goto-subject current)
8183 (gnus-summary-position-point)
8186 (defun gnus-summary-refer-thread (&optional limit)
8187 "Fetch all articles in the current thread.
8188 If LIMIT (the numerical prefix), fetch that many old headers instead
8189 of what's specified by the `gnus-refer-thread-limit' variable."
8191 (let ((id (mail-header-id (gnus-summary-article-header)))
8192 (limit (if limit (prefix-numeric-value limit)
8193 gnus-refer-thread-limit)))
8194 (unless (eq gnus-fetch-old-headers 'invisible)
8195 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8196 ;; Retrieve the headers and read them in.
8197 (if (eq (if (numberp limit)
8198 (gnus-retrieve-headers
8200 (+ (mail-header-number
8201 (gnus-summary-article-header))
8203 gnus-newsgroup-end))
8204 gnus-newsgroup-name (* limit 2))
8205 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8207 (gnus-retrieve-headers (list gnus-newsgroup-end)
8208 gnus-newsgroup-name limit))
8210 (gnus-build-all-threads)
8211 (error "Can't fetch thread from back ends that don't support NOV"))
8212 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8213 (gnus-summary-limit-include-thread id)))
8215 (defun gnus-summary-refer-article (message-id)
8216 "Fetch an article specified by MESSAGE-ID."
8217 (interactive "sMessage-ID: ")
8218 (when (and (stringp message-id)
8219 (not (zerop (length message-id))))
8220 (setq message-id (gnus-replace-in-string message-id " " ""))
8221 ;; Construct the correct Message-ID if necessary.
8222 ;; Suggested by tale@pawl.rpi.edu.
8223 (unless (string-match "^<" message-id)
8224 (setq message-id (concat "<" message-id)))
8225 (unless (string-match ">$" message-id)
8226 (setq message-id (concat message-id ">")))
8227 ;; People often post MIDs from URLs, so unhex it:
8228 (unless (string-match "@" message-id)
8229 (setq message-id (gnus-url-unhex-string message-id)))
8230 (let* ((header (gnus-id-to-header message-id))
8232 (gnus-summary-article-sparse-p
8233 (mail-header-number header))
8234 (memq (mail-header-number header)
8235 gnus-newsgroup-limit)))
8238 ;; If the article is present in the buffer we just go to it.
8240 (or (not (gnus-summary-article-sparse-p
8241 (mail-header-number header)))
8244 (gnus-summary-goto-article
8245 (mail-header-number header) nil t)
8247 (gnus-summary-update-article (mail-header-number header)))))
8249 ;; We fetch the article.
8251 (dolist (gnus-override-method (gnus-refer-article-methods))
8252 (when (and (gnus-check-server gnus-override-method)
8253 ;; Fetch the header,
8254 (setq number (gnus-summary-insert-subject message-id)))
8255 ;; and display the article.
8256 (gnus-summary-select-article nil nil nil number)
8258 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8260 (defun gnus-refer-article-methods ()
8261 "Return a list of referable methods."
8263 ;; No method, so we default to current and native.
8264 ((null gnus-refer-article-method)
8265 (list gnus-current-select-method gnus-select-method))
8267 ((eq 'current gnus-refer-article-method)
8268 (list gnus-current-select-method))
8269 ;; List of select methods.
8270 ((not (and (symbolp (car gnus-refer-article-method))
8271 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8273 (dolist (method gnus-refer-article-method)
8274 (push (if (eq 'current method)
8275 gnus-current-select-method
8279 ;; One single select method.
8281 (list gnus-refer-article-method))))
8283 (defun gnus-summary-edit-parameters ()
8284 "Edit the group parameters of the current group."
8286 (gnus-group-edit-group gnus-newsgroup-name 'params))
8288 (defun gnus-summary-customize-parameters ()
8289 "Customize the group parameters of the current group."
8291 (gnus-group-customize gnus-newsgroup-name))
8293 (defun gnus-summary-enter-digest-group (&optional force)
8294 "Enter an nndoc group based on the current article.
8295 If FORCE, force a digest interpretation. If not, try
8296 to guess what the document format is."
8298 (let ((conf gnus-current-window-configuration))
8299 (save-window-excursion
8301 (let (gnus-article-prepare-hook
8302 gnus-display-mime-function
8304 (gnus-summary-select-article))))
8305 (setq gnus-current-window-configuration conf)
8306 (let* ((name (format "%s-%d"
8307 (gnus-group-prefixed-name
8308 gnus-newsgroup-name (list 'nndoc ""))
8309 (with-current-buffer gnus-summary-buffer
8310 gnus-current-article)))
8311 (ogroup gnus-newsgroup-name)
8312 (params (append (gnus-info-params (gnus-get-info ogroup))
8313 (list (cons 'to-group ogroup))
8314 (list (cons 'parent-group ogroup))
8315 (list (cons 'save-article-group ogroup))))
8316 (case-fold-search t)
8317 (buf (current-buffer))
8320 (set-buffer gnus-original-article-buffer)
8321 ;; Have the digest group inherit the main mail address of
8322 ;; the parent article.
8323 (when (setq to-address (or (gnus-fetch-field "reply-to")
8324 (gnus-fetch-field "from")))
8325 (setq params (append
8326 (list (cons 'to-address
8327 (funcall gnus-decode-encoded-word-function
8329 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8330 (insert-buffer-substring gnus-original-article-buffer)
8331 ;; Remove lines that may lead nndoc to misinterpret the
8334 (goto-char (point-min))
8335 (or (search-forward "\n\n" nil t) (point)))
8336 (goto-char (point-min))
8337 (delete-matching-lines "^Path:\\|^From ")
8340 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8341 (gnus-newsgroup-ephemeral-ignored-charsets
8342 gnus-newsgroup-ignored-charsets))
8343 (gnus-group-read-ephemeral-group
8344 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8346 ,(if force 'mbox 'guess)))
8348 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8350 ;; Make all postings to this group go to the parent group.
8351 (nconc (gnus-info-params (gnus-get-info name))
8353 ;; Couldn't select this doc group.
8354 (switch-to-buffer buf)
8355 (gnus-set-global-variables)
8356 (gnus-configure-windows 'summary)
8357 (gnus-message 3 "Article couldn't be entered?"))
8358 (kill-buffer dig)))))
8360 (defun gnus-summary-read-document (n)
8361 "Open a new group based on the current article(s).
8362 This will allow you to read digests and other similar
8363 documents as newsgroups.
8364 Obeys the standard process/prefix convention."
8366 (let* ((articles (gnus-summary-work-articles n))
8367 (ogroup gnus-newsgroup-name)
8368 (params (append (gnus-info-params (gnus-get-info ogroup))
8369 (list (cons 'to-group ogroup))))
8370 article group egroup groups vgroup)
8371 (while (setq article (pop articles))
8372 (setq group (format "%s-%d" gnus-newsgroup-name article))
8373 (gnus-summary-remove-process-mark article)
8374 (when (gnus-summary-display-article article)
8377 (insert-buffer-substring gnus-original-article-buffer)
8378 ;; Remove some headers that may lead nndoc to make
8380 (message-narrow-to-head)
8381 (goto-char (point-min))
8382 (delete-matching-lines "^Path:\\|^From ")
8385 (gnus-group-read-ephemeral-group
8386 group `(nndoc ,group (nndoc-address ,(current-buffer))
8387 (nndoc-article-type guess))
8390 ;; Make all postings to this group go to the parent group.
8391 (nconc (gnus-info-params (gnus-get-info egroup))
8393 (push egroup groups))
8394 ;; Couldn't select this doc group.
8395 (gnus-error 3 "Article couldn't be entered"))))))
8396 ;; Now we have selected all the documents.
8399 (error "None of the articles could be interpreted as documents"))
8400 ((gnus-group-read-ephemeral-group
8401 (setq vgroup (format
8402 "nnvirtual:%s-%s" gnus-newsgroup-name
8403 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8404 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8406 (cons (current-buffer) 'summary)))
8408 (error "Couldn't select virtual nndoc group")))))
8410 (defun gnus-summary-isearch-article (&optional regexp-p)
8411 "Do incremental search forward on the current article.
8412 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8414 (gnus-summary-select-article)
8415 (gnus-configure-windows 'article)
8416 (gnus-eval-in-buffer-window gnus-article-buffer
8419 (isearch-forward regexp-p))))
8421 (defun gnus-summary-search-article-forward (regexp &optional backward)
8422 "Search for an article containing REGEXP forward.
8423 If BACKWARD, search backward instead."
8426 (format "Search article %s (regexp%s): "
8427 (if current-prefix-arg "backward" "forward")
8428 (if gnus-last-search-regexp
8429 (concat ", default " gnus-last-search-regexp)
8431 current-prefix-arg))
8432 (if (string-equal regexp "")
8433 (setq regexp (or gnus-last-search-regexp ""))
8434 (setq gnus-last-search-regexp regexp)
8435 (setq gnus-article-before-search gnus-current-article))
8436 ;; Intentionally set gnus-last-article.
8437 (setq gnus-last-article gnus-article-before-search)
8438 (let ((gnus-last-article gnus-last-article))
8439 (if (gnus-summary-search-article regexp backward)
8440 (gnus-summary-show-thread)
8441 (error "Search failed: \"%s\"" regexp))))
8443 (defun gnus-summary-search-article-backward (regexp)
8444 "Search for an article containing REGEXP backward."
8447 (format "Search article backward (regexp%s): "
8448 (if gnus-last-search-regexp
8449 (concat ", default " gnus-last-search-regexp)
8451 (gnus-summary-search-article-forward regexp 'backward))
8453 (defun gnus-summary-search-article (regexp &optional backward)
8454 "Search for an article containing REGEXP.
8455 Optional argument BACKWARD means do search for backward.
8456 `gnus-select-article-hook' is not called during the search."
8457 ;; We have to require this here to make sure that the following
8458 ;; dynamic binding isn't shadowed by autoloading.
8459 (require 'gnus-async)
8461 (let ((gnus-select-article-hook nil) ;Disable hook.
8462 (gnus-article-prepare-hook nil)
8463 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8464 (gnus-use-article-prefetch nil)
8465 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8466 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8468 (gnus-keep-backlog nil)
8469 (gnus-break-pages nil)
8470 (gnus-summary-display-arrow nil)
8471 (gnus-updated-mode-lines nil)
8472 (gnus-auto-center-summary nil)
8473 (sum (current-buffer))
8474 (gnus-display-mime-function nil)
8477 (gnus-save-hidden-threads
8478 (gnus-summary-select-article)
8479 (set-buffer gnus-article-buffer)
8480 (goto-char (window-point (get-buffer-window (current-buffer))))
8484 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8486 (re-search-backward regexp nil t)
8487 (re-search-forward regexp nil t))
8488 ;; We found the regexp.
8493 (get-buffer-window (current-buffer))
8497 (get-buffer-window (current-buffer))
8500 (setq point (point)))
8501 ;; We didn't find it, so we go to the next article.
8504 (while (eq found 'not)
8505 (if (not (if backward (gnus-summary-find-prev)
8506 (gnus-summary-find-next)))
8507 ;; No more articles.
8509 ;; Select the next article and adjust point.
8510 (unless (gnus-summary-article-sparse-p
8511 (gnus-summary-article-number))
8513 (gnus-summary-select-article)
8514 (set-buffer gnus-article-buffer)
8516 (goto-char (if backward (point-max) (point-min))))))))
8517 (gnus-message 7 ""))
8518 ;; Return whether we found the regexp.
8519 (when (eq found 'found)
8521 (gnus-summary-show-thread)
8522 (gnus-summary-goto-subject gnus-current-article)
8523 (gnus-summary-position-point)
8526 (defun gnus-find-matching-articles (header regexp)
8527 "Return a list of all articles that match REGEXP on HEADER.
8528 This search includes all articles in the current group that Gnus has
8529 fetched headers for, whether they are displayed or not."
8530 (let ((articles nil)
8531 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8532 (case-fold-search t))
8533 (dolist (header gnus-newsgroup-headers)
8534 (when (string-match regexp (funcall func header))
8535 (push (mail-header-number header) articles)))
8536 (nreverse articles)))
8538 (defun gnus-summary-find-matching (header regexp &optional backward unread
8539 not-case-fold not-matching)
8540 "Return a list of all articles that match REGEXP on HEADER.
8541 The search stars on the current article and goes forwards unless
8542 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8543 If UNREAD is non-nil, only unread articles will
8544 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8545 in the comparisons. If NOT-MATCHING, return a list of all articles that
8546 not match REGEXP on HEADER."
8547 (let ((case-fold-search (not not-case-fold))
8550 (if (eq (car header) 'extra)
8553 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8555 (error "%s is an invalid header" header))
8556 (unless (fboundp (intern (concat "mail-header-" header)))
8557 (error "%s is not a valid header" header))
8558 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8559 (dolist (d (if (eq backward 'all)
8561 (gnus-data-find-list
8562 (gnus-summary-article-number)
8563 (gnus-data-list backward))))
8564 (when (and (or (not unread) ; We want all articles...
8565 (gnus-data-unread-p d)) ; Or just unreads.
8566 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8570 (funcall func (gnus-data-header d))))
8571 (string-match regexp
8572 (funcall func (gnus-data-header d)))))
8573 (push (gnus-data-number d) articles))) ; Success!
8574 (nreverse articles)))
8576 (defun gnus-summary-execute-command (header regexp command &optional backward)
8577 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8578 If HEADER is an empty string (or nil), the match is done on the entire
8579 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8581 (list (let ((completion-ignore-case t))
8584 (mapcar (lambda (header) (list (format "%s" header)))
8586 '("Number" "Subject" "From" "Lines" "Date"
8587 "Message-ID" "Xref" "References" "Body")
8588 gnus-extra-headers))
8589 nil 'require-match))
8590 (read-string "Regexp: ")
8591 (read-key-sequence "Command: ")
8592 current-prefix-arg))
8593 (when (equal header "Body")
8595 ;; Hidden thread subtrees must be searched as well.
8596 (gnus-summary-show-all-threads)
8597 ;; We don't want to change current point nor window configuration.
8599 (save-window-excursion
8601 gnus-treat-strip-trailing-blank-lines
8602 gnus-treat-strip-leading-blank-lines
8603 gnus-treat-strip-multiple-blank-lines
8604 gnus-treat-hide-boring-headers
8605 gnus-treat-fold-newsgroups
8606 gnus-article-prepare-hook)
8607 (gnus-message 6 "Executing %s..." (key-description command))
8608 ;; We'd like to execute COMMAND interactively so as to give arguments.
8609 (gnus-execute header regexp
8610 `(call-interactively ',(key-binding command))
8612 (gnus-message 6 "Executing %s...done" (key-description command))))))
8614 (defun gnus-summary-beginning-of-article ()
8615 "Scroll the article back to the beginning."
8617 (gnus-summary-select-article)
8618 (gnus-configure-windows 'article)
8619 (gnus-eval-in-buffer-window gnus-article-buffer
8621 (goto-char (point-min))
8622 (when gnus-break-pages
8623 (gnus-narrow-to-page))))
8625 (defun gnus-summary-end-of-article ()
8626 "Scroll to the end of the article."
8628 (gnus-summary-select-article)
8629 (gnus-configure-windows 'article)
8630 (gnus-eval-in-buffer-window gnus-article-buffer
8632 (goto-char (point-max))
8634 (when gnus-break-pages
8635 (when (re-search-backward page-delimiter nil t)
8636 (narrow-to-region (match-end 0) (point-max)))
8637 (gnus-narrow-to-page))))
8639 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8640 "Truncate to LEN and quote all \"(\"'s in STRING."
8641 (gnus-replace-in-string (if (and len (> (length string) len))
8642 (substring string 0 len)
8646 (defun gnus-summary-print-article (&optional filename n)
8647 "Generate and print a PostScript image of the process-marked (mail) articles.
8649 If used interactively, print the current article if none are
8650 process-marked. With prefix arg, prompt the user for the name of the
8653 When used from Lisp, accept two optional args FILENAME and N. N means
8654 to print the next N articles. If N is negative, print the N previous
8655 articles. If N is nil and articles have been marked with the process
8656 mark, print these instead.
8658 If the optional first argument FILENAME is nil, send the image to the
8659 printer. If FILENAME is a string, save the PostScript image in a file with
8660 that name. If FILENAME is a number, prompt the user for the name of the file
8662 (interactive (list (ps-print-preprint current-prefix-arg)))
8663 (dolist (article (gnus-summary-work-articles n))
8664 (gnus-summary-select-article nil nil 'pseudo article)
8665 (gnus-eval-in-buffer-window gnus-article-buffer
8666 (gnus-print-buffer))
8667 (gnus-summary-remove-process-mark article))
8668 (ps-despool filename))
8670 (defun gnus-print-buffer ()
8671 (let ((buffer (generate-new-buffer " *print*")))
8674 (copy-to-buffer buffer (point-min) (point-max))
8676 (gnus-remove-text-with-property 'gnus-decoration)
8677 (when (gnus-visual-p 'article-highlight 'highlight)
8678 ;; Copy-to-buffer doesn't copy overlay. So redo
8680 (let ((gnus-article-buffer buffer))
8681 (gnus-article-highlight-citation t)
8682 (gnus-article-highlight-signature)
8683 (gnus-article-emphasize)
8684 (gnus-article-delete-invisible-text)))
8685 (let ((ps-left-header
8688 (gnus-summary-print-truncate-and-quote
8689 (mail-header-subject gnus-current-headers)
8692 (gnus-summary-print-truncate-and-quote
8693 (mail-header-from gnus-current-headers)
8697 "/pagenumberstring load"
8699 (mail-header-date gnus-current-headers) ")"))))
8700 (gnus-run-hooks 'gnus-ps-print-hook)
8703 (ps-spool-buffer-with-faces)
8704 (ps-spool-buffer)))))
8705 (kill-buffer buffer))))
8707 (defun gnus-summary-show-article (&optional arg)
8708 "Force redisplaying of the current article.
8709 If ARG (the prefix) is a number, show the article with the charset
8710 defined in `gnus-summary-show-article-charset-alist', or the charset
8712 If ARG (the prefix) is non-nil and not a number, show the raw article
8713 without any article massaging functions being run. Normally, the key
8714 strokes are `C-u g'."
8718 (gnus-summary-show-article t)
8719 (let ((gnus-newsgroup-charset
8720 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8721 (mm-read-coding-system
8722 "View as charset: " ;; actually it is coding system.
8724 (set-buffer gnus-article-buffer)
8725 (mm-detect-coding-region (point) (point-max))))))
8726 (gnus-newsgroup-ignored-charsets 'gnus-all))
8727 (gnus-summary-select-article nil 'force)
8728 (let ((deps gnus-newsgroup-dependencies)
8731 (set-buffer gnus-original-article-buffer)
8733 (message-narrow-to-head)
8734 (setq head (buffer-string))
8735 (goto-char (point-min))
8736 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8737 (goto-char (point-max))
8739 (setq lines (1- (count-lines (point) (point-max))))))
8741 (insert (format "211 %d Article retrieved.\n"
8742 (cdr gnus-article-current)))
8744 (if lines (insert (format "Lines: %d\n" lines)))
8746 (let ((nntp-server-buffer (current-buffer)))
8747 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8748 (gnus-data-set-header
8749 (gnus-data-find (cdr gnus-article-current))
8751 (gnus-summary-update-article-line
8752 (cdr gnus-article-current) header)
8753 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8754 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8756 ;; Select the article the normal way.
8757 (gnus-summary-select-article nil 'force))
8759 ;; We have to require this here to make sure that the following
8760 ;; dynamic binding isn't shadowed by autoloading.
8761 (require 'gnus-async)
8763 ;; Bind the article treatment functions to nil.
8764 (let ((gnus-have-all-headers t)
8765 gnus-article-prepare-hook
8766 gnus-article-decode-hook
8767 gnus-display-mime-function
8769 ;; Destroy any MIME parts.
8770 (when (gnus-buffer-live-p gnus-article-buffer)
8772 (set-buffer gnus-article-buffer)
8773 (mm-destroy-parts gnus-article-mime-handles)
8774 ;; Set it to nil for safety reason.
8775 (setq gnus-article-mime-handle-alist nil)
8776 (setq gnus-article-mime-handles nil)))
8777 (gnus-summary-select-article nil 'force))))
8778 (gnus-summary-goto-subject gnus-current-article)
8779 (gnus-summary-position-point))
8781 (defun gnus-summary-show-raw-article ()
8782 "Show the raw article without any article massaging functions being run."
8784 (gnus-summary-show-article t))
8786 (defun gnus-summary-verbose-headers (&optional arg)
8787 "Toggle permanent full header display.
8788 If ARG is a positive number, turn header display on.
8789 If ARG is a negative number, turn header display off."
8791 (setq gnus-show-all-headers
8792 (cond ((or (not (numberp arg))
8794 (not gnus-show-all-headers))
8797 (gnus-summary-show-article))
8799 (defun gnus-summary-toggle-header (&optional arg)
8800 "Show the headers if they are hidden, or hide them if they are shown.
8801 If ARG is a positive number, show the entire header.
8802 If ARG is a negative number, hide the unwanted header lines."
8804 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8805 (get-buffer-window gnus-article-buffer t))))
8806 (with-current-buffer gnus-article-buffer
8808 (article-narrow-to-head)
8809 (let* ((buffer-read-only nil)
8810 (inhibit-point-motion-hooks t)
8811 (hidden (if (numberp arg)
8813 (gnus-article-hidden-text-p 'headers)))
8815 (delete-region (point-min) (point-max))
8816 (with-current-buffer gnus-original-article-buffer
8817 (goto-char (setq s (point-min)))
8818 (setq e (if (search-forward "\n\n" nil t)
8821 (insert-buffer-substring gnus-original-article-buffer s e)
8822 (run-hooks 'gnus-article-decode-hook)
8824 (let ((gnus-treat-hide-headers nil)
8825 (gnus-treat-hide-boring-headers nil))
8826 (gnus-delete-wash-type 'headers)
8827 (gnus-treat-article 'head))
8828 (gnus-treat-article 'head))
8831 (set-window-start window (goto-char (point-min))))
8832 (if gnus-break-pages
8833 (gnus-narrow-to-page)
8834 (when (gnus-visual-p 'page-marker)
8835 (let ((buffer-read-only nil))
8836 (gnus-remove-text-with-property 'gnus-prev)
8837 (gnus-remove-text-with-property 'gnus-next))))
8838 (gnus-set-mode-line 'article)))))
8840 (defun gnus-summary-show-all-headers ()
8841 "Make all header lines visible."
8843 (gnus-summary-toggle-header 1))
8845 (defun gnus-summary-caesar-message (&optional arg)
8846 "Caesar rotate the current article by 13.
8847 The numerical prefix specifies how many places to rotate each letter
8850 (gnus-summary-select-article)
8851 (let ((mail-header-separator ""))
8852 (gnus-eval-in-buffer-window gnus-article-buffer
8855 (let ((start (window-start))
8857 (message-caesar-buffer-body arg)
8858 (set-window-start (get-buffer-window (current-buffer)) start))))))
8860 (autoload 'unmorse-region "morse"
8861 "Convert morse coded text in region to ordinary ASCII text."
8864 (defun gnus-summary-morse-message (&optional arg)
8865 "Morse decode the current article."
8867 (gnus-summary-select-article)
8868 (let ((mail-header-separator ""))
8869 (gnus-eval-in-buffer-window gnus-article-buffer
8873 (let ((pos (window-start))
8875 (goto-char (point-min))
8876 (when (message-goto-body)
8877 (gnus-narrow-to-body))
8878 (goto-char (point-min))
8879 (while (re-search-forward "·" (point-max) t)
8880 (replace-match "."))
8881 (unmorse-region (point-min) (point-max))
8883 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8885 (defun gnus-summary-stop-page-breaking ()
8886 "Stop page breaking in the current article."
8888 (gnus-summary-select-article)
8889 (gnus-eval-in-buffer-window gnus-article-buffer
8891 (when (gnus-visual-p 'page-marker)
8892 (let ((buffer-read-only nil))
8893 (gnus-remove-text-with-property 'gnus-prev)
8894 (gnus-remove-text-with-property 'gnus-next))
8895 (setq gnus-page-broken nil))))
8897 (defun gnus-summary-move-article (&optional n to-newsgroup
8898 select-method action)
8899 "Move the current article to a different newsgroup.
8900 If N is a positive number, move the N next articles.
8901 If N is a negative number, move the N previous articles.
8902 If N is nil and any articles have been marked with the process mark,
8903 move those articles instead.
8904 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8905 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8906 re-spool using this method.
8908 When called interactively with TO-NEWSGROUP being nil, the value of
8909 the variable `gnus-move-split-methods' is used for finding a default
8910 for the target newsgroup.
8912 For this function to work, both the current newsgroup and the
8913 newsgroup that you want to move to have to support the `request-move'
8914 and `request-accept' functions.
8916 ACTION can be either `move' (the default), `crosspost' or `copy'."
8919 (setq action 'move))
8920 ;; Check whether the source group supports the required functions.
8921 (cond ((and (eq action 'move)
8922 (not (gnus-check-backend-function
8923 'request-move-article gnus-newsgroup-name)))
8924 (error "The current group does not support article moving"))
8925 ((and (eq action 'crosspost)
8926 (not (gnus-check-backend-function
8927 'request-replace-article gnus-newsgroup-name)))
8928 (error "The current group does not support article editing")))
8929 (let ((articles (gnus-summary-work-articles n))
8930 (prefix (if (gnus-check-backend-function
8931 'request-move-article gnus-newsgroup-name)
8932 (funcall gnus-move-group-prefix-function
8933 gnus-newsgroup-name)
8935 (names '((move "Move" "Moving")
8936 (copy "Copy" "Copying")
8937 (crosspost "Crosspost" "Crossposting")))
8938 (copy-buf (save-excursion
8939 (nnheader-set-temp-buffer " *copy article*")))
8940 art-group to-method new-xref article to-groups)
8941 (unless (assq action names)
8942 (error "Unknown action %s" action))
8943 ;; Read the newsgroup name.
8944 (when (and (not to-newsgroup)
8945 (not select-method))
8946 (if (and gnus-move-split-methods
8948 (and (memq gnus-current-article articles)
8949 (gnus-buffer-live-p gnus-original-article-buffer))))
8950 ;; When `gnus-move-split-methods' is non-nil, we have to
8951 ;; select an article to give `gnus-read-move-group-name' an
8952 ;; opportunity to suggest an appropriate default. However,
8953 ;; we needn't render or mark the article.
8954 (let ((gnus-display-mime-function nil)
8955 (gnus-article-prepare-hook nil)
8956 (gnus-mark-article-hook nil))
8957 (gnus-summary-select-article nil nil nil (car articles))))
8959 (gnus-read-move-group-name
8960 (cadr (assq action names))
8961 (symbol-value (intern (format "gnus-current-%s-group" action)))
8963 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8964 (setq to-method (or select-method
8965 (gnus-server-to-method
8966 (gnus-group-method to-newsgroup))))
8967 ;; Check the method we are to move this article to...
8968 (unless (gnus-check-backend-function
8969 'request-accept-article (car to-method))
8970 (error "%s does not support article copying" (car to-method)))
8971 (unless (gnus-check-server to-method)
8972 (error "Can't open server %s" (car to-method)))
8973 (gnus-message 6 "%s to %s: %s..."
8974 (caddr (assq action names))
8975 (or (car select-method) to-newsgroup) articles)
8977 (setq article (pop articles))
8981 ;; Move the article.
8983 ;; Remove this article from future suppression.
8984 (gnus-dup-unsuppress-article article)
8985 (gnus-request-move-article
8986 article ; Article to move
8987 gnus-newsgroup-name ; From newsgroup
8988 (nth 1 (gnus-find-method-for-group
8989 gnus-newsgroup-name)) ; Server
8990 (list 'gnus-request-accept-article
8991 to-newsgroup (list 'quote select-method)
8992 (not articles) t) ; Accept form
8993 (not articles))) ; Only save nov last time
8994 ;; Copy the article.
8997 (set-buffer copy-buf)
8998 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8999 (gnus-request-accept-article
9000 to-newsgroup select-method (not articles) t))))
9001 ;; Crosspost the article.
9002 ((eq action 'crosspost)
9003 (let ((xref (message-tokenize-header
9004 (mail-header-xref (gnus-summary-article-header article))
9006 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9007 ":" (number-to-string article)))
9009 (setq xref (list (system-name))))
9012 (mapconcat 'identity
9013 (delete "Xref:" (delete new-xref xref))
9017 (set-buffer copy-buf)
9018 ;; First put the article in the destination group.
9019 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9020 (when (consp (setq art-group
9021 (gnus-request-accept-article
9022 to-newsgroup select-method (not articles))))
9023 (setq new-xref (concat new-xref " " (car art-group)
9025 (number-to-string (cdr art-group))))
9026 ;; Now we have the new Xrefs header, so we insert
9027 ;; it and replace the new article.
9028 (nnheader-replace-header "Xref" new-xref)
9029 (gnus-request-replace-article
9030 (cdr art-group) to-newsgroup (current-buffer))
9034 (gnus-message 1 "Couldn't %s article %s: %s"
9035 (cadr (assq action names)) article
9036 (nnheader-get-report (car to-method))))
9037 ((eq art-group 'junk)
9038 (when (eq action 'move)
9039 (gnus-summary-mark-article article gnus-canceled-mark)
9040 (gnus-message 4 "Deleted article %s" article)
9041 ;; run the delete hook
9042 (run-hook-with-args 'gnus-summary-article-delete-hook
9045 (assoc article (gnus-data-list nil)))
9046 gnus-newsgroup-name nil
9049 (let* ((pto-group (gnus-group-prefixed-name
9050 (car art-group) to-method))
9051 (info (gnus-get-info pto-group))
9052 (to-group (gnus-info-group info))
9054 ;; Update the group that has been moved to.
9056 (memq action '(move copy)))
9057 (unless (member to-group to-groups)
9058 (push to-group to-groups))
9060 (unless (memq article gnus-newsgroup-unreads)
9061 (push 'read to-marks)
9063 info (gnus-add-to-range (gnus-info-read info)
9064 (list (cdr art-group)))))
9066 ;; See whether the article is to be put in the cache.
9067 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9068 gnus-article-mark-lists
9069 (delete '(expirable . expire)
9070 (copy-sequence gnus-article-mark-lists))))
9071 (to-article (cdr art-group)))
9073 ;; Enter the article into the cache in the new group,
9074 ;; if that is required.
9075 (when gnus-use-cache
9076 (gnus-cache-possibly-enter-article
9078 (memq article gnus-newsgroup-marked)
9079 (memq article gnus-newsgroup-dormant)
9080 (memq article gnus-newsgroup-unreads)))
9082 (when gnus-preserve-marks
9083 ;; Copy any marks over to the new group.
9084 (when (and (equal to-group gnus-newsgroup-name)
9085 (not (memq article gnus-newsgroup-unreads)))
9086 ;; Mark this article as read in this group.
9087 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9088 (setcdr (gnus-active to-group) to-article)
9089 (setcdr gnus-newsgroup-active to-article))
9092 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9093 (when (memq article (symbol-value
9094 (intern (format "gnus-newsgroup-%s"
9096 (push (cdar marks) to-marks)
9097 ;; If the other group is the same as this group,
9098 ;; then we have to add the mark to the list.
9099 (when (equal to-group gnus-newsgroup-name)
9100 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9103 (intern (format "gnus-newsgroup-%s"
9105 ;; Copy the marks to other group.
9106 (gnus-add-marked-articles
9107 to-group (cdar marks) (list to-article) info)))
9108 (setq marks (cdr marks)))
9110 (gnus-request-set-mark
9111 to-group (list (list (list to-article) 'add to-marks))))
9114 (concat "(gnus-group-set-info '"
9115 (gnus-prin1-to-string (gnus-get-info to-group))
9118 ;; Update the Xref header in this article to point to
9119 ;; the new crossposted article we have just created.
9120 (when (eq action 'crosspost)
9122 (set-buffer copy-buf)
9123 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9124 (nnheader-replace-header "Xref" new-xref)
9125 (gnus-request-replace-article
9126 article gnus-newsgroup-name (current-buffer))))
9128 ;; run the move/copy/crosspost/respool hook
9129 (run-hook-with-args 'gnus-summary-article-move-hook
9132 (assoc article (gnus-data-list nil)))
9137 ;;;!!!Why is this necessary?
9138 (set-buffer gnus-summary-buffer)
9140 (gnus-summary-goto-subject article)
9141 (when (eq action 'move)
9142 (gnus-summary-mark-article article gnus-canceled-mark))))
9143 (gnus-summary-remove-process-mark article))
9144 ;; Re-activate all groups that have been moved to.
9146 (set-buffer gnus-group-buffer)
9147 (let ((gnus-group-marked to-groups))
9148 (gnus-group-get-new-news-this-group nil t)))
9150 (gnus-kill-buffer copy-buf)
9151 (gnus-summary-position-point)
9152 (gnus-set-mode-line 'summary)))
9154 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9155 "Move the current article to a different newsgroup.
9156 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9157 When called interactively, if TO-NEWSGROUP is nil, use the value of
9158 the variable `gnus-move-split-methods' for finding a default target
9160 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9161 re-spool using this method."
9163 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9165 (defun gnus-summary-crosspost-article (&optional n)
9166 "Crosspost the current article to some other group."
9168 (gnus-summary-move-article n nil nil 'crosspost))
9170 (defcustom gnus-summary-respool-default-method nil
9171 "Default method type for respooling an article.
9172 If nil, use to the current newsgroup method."
9174 :group 'gnus-summary-mail)
9176 (defcustom gnus-summary-display-while-building nil
9177 "If non-nil, show and update the summary buffer as it's being built.
9178 If the value is t, update the buffer after every line is inserted. If
9179 the value is an integer (N), update the display every N lines."
9181 :type '(choice (const :tag "off" nil)
9183 (const :tag "frequently" t)))
9185 (defun gnus-summary-respool-article (&optional n method)
9186 "Respool the current article.
9187 The article will be squeezed through the mail spooling process again,
9188 which means that it will be put in some mail newsgroup or other
9189 depending on `nnmail-split-methods'.
9190 If N is a positive number, respool the N next articles.
9191 If N is a negative number, respool the N previous articles.
9192 If N is nil and any articles have been marked with the process mark,
9193 respool those articles instead.
9195 Respooling can be done both from mail groups and \"real\" newsgroups.
9196 In the former case, the articles in question will be moved from the
9197 current group into whatever groups they are destined to. In the
9198 latter case, they will be copied into the relevant groups."
9200 (list current-prefix-arg
9201 (let* ((methods (gnus-methods-using 'respool))
9203 (symbol-name (or gnus-summary-respool-default-method
9204 (car (gnus-find-method-for-group
9205 gnus-newsgroup-name)))))
9207 (gnus-completing-read-with-default
9208 methname "What backend do you want to use when respooling?"
9209 methods nil t nil 'gnus-mail-method-history))
9212 ((zerop (length (setq ms (gnus-servers-using-backend
9214 (list (intern method) ""))
9218 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9219 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9222 (error "No method given for respooling"))
9223 (if (assoc (symbol-name
9224 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9225 (gnus-methods-using 'respool))
9226 (gnus-summary-move-article n nil method)
9227 (gnus-summary-copy-article n nil method)))
9229 (defun gnus-summary-import-article (file &optional edit)
9230 "Import an arbitrary file into a mail newsgroup."
9231 (interactive "fImport file: \nP")
9232 (let ((group gnus-newsgroup-name)
9233 (now (current-time))
9234 atts lines group-art)
9235 (unless (gnus-check-backend-function 'request-accept-article group)
9236 (error "%s does not support article importing" group))
9237 (or (file-readable-p file)
9238 (not (file-regular-p file))
9239 (error "Can't read %s" file))
9241 (set-buffer (gnus-get-buffer-create " *import file*"))
9243 (nnheader-insert-file-contents file)
9244 (goto-char (point-min))
9245 (if (nnheader-article-p)
9247 (goto-char (point-min))
9248 (search-forward "\n\n" nil t)
9249 (narrow-to-region (point-min) (1- (point)))
9250 (goto-char (point-min))
9251 (unless (re-search-forward "^date:" nil t)
9252 (goto-char (point-max))
9253 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9254 ;; This doesn't look like an article, so we fudge some headers.
9255 (setq atts (file-attributes file)
9256 lines (count-lines (point-min) (point-max)))
9257 (insert "From: " (read-string "From: ") "\n"
9258 "Subject: " (read-string "Subject: ") "\n"
9259 "Date: " (message-make-date (nth 5 atts)) "\n"
9260 "Message-ID: " (message-make-message-id) "\n"
9261 "Lines: " (int-to-string lines) "\n"
9262 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9263 (setq group-art (gnus-request-accept-article group nil t))
9264 (kill-buffer (current-buffer)))
9265 (setq gnus-newsgroup-active (gnus-activate-group group))
9267 (gnus-summary-goto-article (cdr group-art) nil t)
9269 (gnus-summary-edit-article))))
9271 (defun gnus-summary-create-article ()
9272 "Create an article in a mail newsgroup."
9274 (let ((group gnus-newsgroup-name)
9275 (now (current-time))
9277 (unless (gnus-check-backend-function 'request-accept-article group)
9278 (error "%s does not support article importing" group))
9280 (set-buffer (gnus-get-buffer-create " *import file*"))
9282 (goto-char (point-min))
9283 ;; This doesn't look like an article, so we fudge some headers.
9284 (insert "From: " (read-string "From: ") "\n"
9285 "Subject: " (read-string "Subject: ") "\n"
9286 "Date: " (message-make-date now) "\n"
9287 "Message-ID: " (message-make-message-id) "\n")
9288 (setq group-art (gnus-request-accept-article group nil t))
9289 (kill-buffer (current-buffer)))
9290 (setq gnus-newsgroup-active (gnus-activate-group group))
9292 (gnus-summary-goto-article (cdr group-art) nil t)
9293 (gnus-summary-edit-article)))
9295 (defun gnus-summary-article-posted-p ()
9296 "Say whether the current (mail) article is available from news as well.
9297 This will be the case if the article has both been mailed and posted."
9299 (let ((id (mail-header-references (gnus-summary-article-header)))
9300 (gnus-override-method (car (gnus-refer-article-methods))))
9301 (if (gnus-request-head id "")
9302 (gnus-message 2 "The current message was found on %s"
9303 gnus-override-method)
9304 (gnus-message 2 "The current message couldn't be found on %s"
9305 gnus-override-method)
9308 (defun gnus-summary-expire-articles (&optional now)
9309 "Expire all articles that are marked as expirable in the current group."
9311 (when (and (not gnus-group-is-exiting-without-update-p)
9312 (gnus-check-backend-function
9313 'request-expire-articles gnus-newsgroup-name))
9314 ;; This backend supports expiry.
9315 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9316 (expirable (if total
9318 ;; We need to update the info for
9319 ;; this group for `gnus-list-of-read-articles'
9320 ;; to give us the right answer.
9321 (gnus-run-hooks 'gnus-exit-group-hook)
9322 (gnus-summary-update-info)
9323 (gnus-list-of-read-articles gnus-newsgroup-name))
9324 (setq gnus-newsgroup-expirable
9325 (sort gnus-newsgroup-expirable '<))))
9326 (expiry-wait (if now 'immediate
9327 (gnus-group-find-parameter
9328 gnus-newsgroup-name 'expiry-wait)))
9329 (nnmail-expiry-target
9330 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9331 nnmail-expiry-target))
9334 ;; There are expirable articles in this group, so we run them
9335 ;; through the expiry process.
9336 (gnus-message 6 "Expiring articles...")
9337 (unless (gnus-check-group gnus-newsgroup-name)
9338 (error "Can't open server for %s" gnus-newsgroup-name))
9339 ;; The list of articles that weren't expired is returned.
9342 (let ((nnmail-expiry-wait-function nil)
9343 (nnmail-expiry-wait expiry-wait))
9344 (setq es (gnus-request-expire-articles
9345 expirable gnus-newsgroup-name)))
9346 (setq es (gnus-request-expire-articles
9347 expirable gnus-newsgroup-name)))
9349 (setq gnus-newsgroup-expirable es))
9350 ;; We go through the old list of expirable, and mark all
9351 ;; really expired articles as nonexistent.
9352 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9353 (let ((gnus-use-cache nil))
9354 (dolist (article expirable)
9355 (when (and (not (memq article es))
9356 (gnus-data-find article))
9357 (gnus-summary-mark-article article gnus-canceled-mark)
9358 (run-hook-with-args 'gnus-summary-article-expire-hook
9361 (assoc article (gnus-data-list nil)))
9365 (gnus-message 6 "Expiring articles...done")))))
9367 (defun gnus-summary-expire-articles-now ()
9368 "Expunge all expirable articles in the current group.
9369 This means that *all* articles that are marked as expirable will be
9370 deleted forever, right now."
9372 (or gnus-expert-user
9374 "Are you really, really, really sure you want to delete all these messages? ")
9376 (gnus-summary-expire-articles t))
9378 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9379 (defun gnus-summary-delete-article (&optional n)
9380 "Delete the N next (mail) articles.
9381 This command actually deletes articles. This is not a marking
9382 command. The article will disappear forever from your life, never to
9385 If N is negative, delete backwards.
9386 If N is nil and articles have been marked with the process mark,
9387 delete these instead.
9389 If `gnus-novice-user' is non-nil you will be asked for
9390 confirmation before the articles are deleted."
9392 (unless (gnus-check-backend-function 'request-expire-articles
9393 gnus-newsgroup-name)
9394 (error "The current newsgroup does not support article deletion"))
9395 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9396 (error "Couldn't open server"))
9397 ;; Compute the list of articles to delete.
9398 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9399 (nnmail-expiry-target 'delete)
9401 (if (and gnus-novice-user
9402 (not (gnus-yes-or-no-p
9403 (format "Do you really want to delete %s forever? "
9404 (if (> (length articles) 1)
9405 (format "these %s articles" (length articles))
9408 ;; Delete the articles.
9409 (setq not-deleted (gnus-request-expire-articles
9410 articles gnus-newsgroup-name 'force))
9412 (gnus-summary-remove-process-mark (car articles))
9413 ;; The backend might not have been able to delete the article
9415 (unless (memq (car articles) not-deleted)
9416 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9417 (let* ((article (car articles))
9418 (id (mail-header-id (gnus-data-header
9419 (assoc article (gnus-data-list nil))))))
9420 (run-hook-with-args 'gnus-summary-article-delete-hook
9421 'delete id gnus-newsgroup-name nil
9423 (setq articles (cdr articles)))
9425 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9426 (gnus-summary-position-point)
9427 (gnus-set-mode-line 'summary)
9430 (defun gnus-summary-edit-article (&optional arg)
9431 "Edit the current article.
9432 This will have permanent effect only in mail groups.
9433 If ARG is nil, edit the decoded articles.
9434 If ARG is 1, edit the raw articles.
9435 If ARG is 2, edit the raw articles even in read-only groups.
9436 If ARG is 3, edit the articles with the current handles.
9437 Otherwise, allow editing of articles even in read-only
9440 (let (force raw current-handles)
9449 (setq current-handles
9450 (and (gnus-buffer-live-p gnus-article-buffer)
9451 (with-current-buffer gnus-article-buffer
9453 gnus-article-mime-handles
9454 (setq gnus-article-mime-handles nil))))))
9457 (when (and raw (not force)
9458 (member gnus-newsgroup-name '("nndraft:delayed"
9461 (error "Can't edit the raw article in group %s"
9462 gnus-newsgroup-name))
9464 (set-buffer gnus-summary-buffer)
9465 (let ((mail-parse-charset gnus-newsgroup-charset)
9466 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9467 (gnus-set-global-variables)
9468 (when (and (not force)
9469 (gnus-group-read-only-p))
9470 (error "The current newsgroup does not support article editing"))
9471 (gnus-summary-show-article t)
9472 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9473 (with-current-buffer gnus-article-buffer
9474 (mm-enable-multibyte)))
9475 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9477 (gnus-article-edit-article
9480 (let ((mbl mml-buffer-list))
9481 (setq mml-buffer-list nil)
9482 (mime-to-mml ,'current-handles)
9483 (let ((mbl1 mml-buffer-list))
9484 (setq mml-buffer-list mbl)
9485 (set (make-local-variable 'mml-buffer-list) mbl1))
9486 (gnus-make-local-hook 'kill-buffer-hook)
9487 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9488 `(lambda (no-highlight)
9489 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9490 (message-options message-options)
9491 (message-options-set-recipient)
9492 (mail-parse-ignored-charsets
9493 ',gnus-newsgroup-ignored-charsets))
9494 ,(if (not raw) '(progn
9496 (mml-destroy-buffers)
9497 (remove-hook 'kill-buffer-hook
9498 'mml-destroy-buffers t)
9499 (kill-local-variable 'mml-buffer-list)))
9500 (gnus-summary-edit-article-done
9501 ,(or (mail-header-references gnus-current-headers) "")
9502 ,(gnus-group-read-only-p)
9503 ,gnus-summary-buffer no-highlight))))))))
9505 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9507 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9509 "Make edits to the current article permanent."
9512 ;; The buffer restriction contains the entire article if it exists.
9513 (when (article-goto-body)
9514 (let ((lines (count-lines (point) (point-max)))
9515 (length (- (point-max) (point)))
9516 (case-fold-search t)
9517 (body (copy-marker (point))))
9518 (goto-char (point-min))
9519 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9520 (delete-region (match-beginning 1) (match-end 1))
9521 (insert (number-to-string length)))
9522 (goto-char (point-min))
9523 (when (re-search-forward
9524 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9525 (delete-region (match-beginning 1) (match-end 1))
9526 (insert (number-to-string length)))
9527 (goto-char (point-min))
9528 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9529 (delete-region (match-beginning 1) (match-end 1))
9530 (insert (number-to-string lines))))))
9531 ;; Replace the article.
9532 (let ((buf (current-buffer)))
9534 (insert-buffer-substring buf)
9536 (if (and (not read-only)
9537 (not (gnus-request-replace-article
9538 (cdr gnus-article-current) (car gnus-article-current)
9539 (current-buffer) t)))
9540 (error "Couldn't replace article")
9541 ;; Update the summary buffer.
9543 (equal (message-tokenize-header references " ")
9544 (message-tokenize-header
9545 (or (message-fetch-field "references") "") " ")))
9546 ;; We only have to update this line.
9549 (message-narrow-to-head)
9550 (let ((head (buffer-string))
9553 (insert (format "211 %d Article retrieved.\n"
9554 (cdr gnus-article-current)))
9557 (let ((nntp-server-buffer (current-buffer)))
9558 (setq header (car (gnus-get-newsgroup-headers
9561 (set-buffer gnus-summary-buffer)
9562 (gnus-data-set-header
9563 (gnus-data-find (cdr gnus-article-current))
9565 (gnus-summary-update-article-line
9566 (cdr gnus-article-current) header)
9567 (if (gnus-summary-goto-subject
9568 (cdr gnus-article-current) nil t)
9569 (gnus-summary-update-secondary-mark
9570 (cdr gnus-article-current))))))))
9572 (set-buffer (or buffer gnus-summary-buffer))
9573 (gnus-summary-update-article (cdr gnus-article-current))
9574 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9575 (gnus-summary-update-secondary-mark
9576 (cdr gnus-article-current))))
9577 ;; Prettify the article buffer again.
9578 (unless no-highlight
9580 (set-buffer gnus-article-buffer)
9581 ;;;!!! Fix this -- article should be rehighlighted.
9582 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9583 (set-buffer gnus-original-article-buffer)
9584 (gnus-request-article
9585 (cdr gnus-article-current)
9586 (car gnus-article-current) (current-buffer))))
9587 ;; Prettify the summary buffer line.
9588 (when (gnus-visual-p 'summary-highlight 'highlight)
9589 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9591 (defun gnus-summary-edit-wash (key)
9592 "Perform editing command KEY in the article buffer."
9596 (message "%s" (concat (this-command-keys) "- "))
9599 (gnus-summary-edit-article)
9600 (execute-kbd-macro (concat (this-command-keys) key))
9601 (gnus-article-edit-done))
9605 (defun gnus-summary-respool-query (&optional silent trace)
9606 "Query where the respool algorithm would put this article."
9608 (let (gnus-mark-article-hook)
9609 (gnus-summary-select-article)
9611 (set-buffer gnus-original-article-buffer)
9612 (let ((groups (nnmail-article-group 'identity trace)))
9615 (message "This message would go to %s"
9616 (mapconcat 'car groups ", "))
9617 (message "This message would go to no groups"))
9620 (defun gnus-summary-respool-trace ()
9621 "Trace where the respool algorithm would put this article.
9622 Display a buffer showing all fancy splitting patterns which matched."
9624 (gnus-summary-respool-query nil t))
9626 ;; Summary marking commands.
9628 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9629 "Mark articles which has the same subject as read, and then select the next.
9630 If UNMARK is positive, remove any kind of mark.
9631 If UNMARK is negative, tick articles."
9634 (setq unmark (prefix-numeric-value unmark)))
9636 (gnus-summary-mark-same-subject
9637 (gnus-summary-article-subject) unmark)))
9638 ;; Select next unread article. If auto-select-same mode, should
9639 ;; select the first unread article.
9640 (gnus-summary-next-article t (and gnus-auto-select-same
9641 (gnus-summary-article-subject)))
9642 (gnus-message 7 "%d article%s marked as %s"
9643 count (if (= count 1) " is" "s are")
9644 (if unmark "unread" "read"))))
9646 (defun gnus-summary-kill-same-subject (&optional unmark)
9647 "Mark articles which has the same subject as read.
9648 If UNMARK is positive, remove any kind of mark.
9649 If UNMARK is negative, tick articles."
9652 (setq unmark (prefix-numeric-value unmark)))
9654 (gnus-summary-mark-same-subject
9655 (gnus-summary-article-subject) unmark)))
9656 ;; If marked as read, go to next unread subject.
9658 ;; Go to next unread subject.
9659 (gnus-summary-next-subject 1 t))
9660 (gnus-message 7 "%d articles are marked as %s"
9661 count (if unmark "unread" "read"))))
9663 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9664 "Mark articles with same SUBJECT as read, and return marked number.
9665 If optional argument UNMARK is positive, remove any kinds of marks.
9666 If optional argument UNMARK is negative, mark articles as unread instead."
9670 ((null unmark) ; Mark as read.
9673 (gnus-summary-mark-article-as-read gnus-killed-mark)
9674 (gnus-summary-show-thread) t)
9675 (gnus-summary-find-subject subject))
9676 (setq count (1+ count))))
9677 ((> unmark 0) ; Tick.
9680 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9681 (gnus-summary-show-thread) t)
9682 (gnus-summary-find-subject subject))
9683 (setq count (1+ count))))
9684 (t ; Mark as unread.
9687 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9688 (gnus-summary-show-thread) t)
9689 (gnus-summary-find-subject subject))
9690 (setq count (1+ count)))))
9691 (gnus-set-mode-line 'summary)
9692 ;; Return the number of marked articles.
9695 (defun gnus-summary-mark-as-processable (n &optional unmark)
9696 "Set the process mark on the next N articles.
9697 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9698 the process mark instead. The difference between N and the actual
9699 number of articles marked is returned."
9701 (if (and (null n) (gnus-region-active-p))
9702 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9703 (setq n (prefix-numeric-value n))
9704 (let ((backward (< n 0))
9709 (gnus-summary-remove-process-mark
9710 (gnus-summary-article-number))
9711 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9712 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9715 (gnus-message 7 "No more articles"))
9716 (gnus-summary-recenter)
9717 (gnus-summary-position-point)
9720 (defun gnus-summary-unmark-as-processable (n)
9721 "Remove the process mark from the next N articles.
9722 If N is negative, unmark backward instead. The difference between N and
9723 the actual number of articles unmarked is returned."
9725 (gnus-summary-mark-as-processable n t))
9727 (defun gnus-summary-unmark-all-processable ()
9728 "Remove the process mark from all articles."
9731 (while gnus-newsgroup-processable
9732 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9733 (gnus-summary-position-point))
9735 (defun gnus-summary-add-mark (article type)
9736 "Mark ARTICLE with a mark of TYPE."
9737 (let ((vtype (car (assq type gnus-article-mark-lists)))
9740 (error "No such mark type: %s" type)
9741 (setq var (intern (format "gnus-newsgroup-%s" type)))
9742 (set var (cons article (symbol-value var)))
9743 (if (memq type '(processable cached replied forwarded recent saved))
9744 (gnus-summary-update-secondary-mark article)
9745 ;;; !!! This is bogus. We should find out what primary
9746 ;;; !!! mark we want to set.
9747 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9749 (defun gnus-summary-mark-as-expirable (n)
9750 "Mark N articles forward as expirable.
9751 If N is negative, mark backward instead. The difference between N and
9752 the actual number of articles marked is returned."
9754 (gnus-summary-mark-forward n gnus-expirable-mark))
9756 (defun gnus-summary-mark-as-spam (n)
9757 "Mark N articles forward as spam.
9758 If N is negative, mark backward instead. The difference between N and
9759 the actual number of articles marked is returned."
9761 (gnus-summary-mark-forward n gnus-spam-mark))
9763 (defun gnus-summary-mark-article-as-replied (article)
9764 "Mark ARTICLE as replied to and update the summary line.
9765 ARTICLE can also be a list of articles."
9766 (interactive (list (gnus-summary-article-number)))
9767 (let ((articles (if (listp article) article (list article))))
9768 (dolist (article articles)
9769 (unless (numberp article)
9770 (error "%s is not a number" article))
9771 (push article gnus-newsgroup-replied)
9772 (let ((buffer-read-only nil))
9773 (when (gnus-summary-goto-subject article nil t)
9774 (gnus-summary-update-secondary-mark article))))))
9776 (defun gnus-summary-mark-article-as-forwarded (article)
9777 "Mark ARTICLE as forwarded and update the summary line.
9778 ARTICLE can also be a list of articles."
9779 (let ((articles (if (listp article) article (list article))))
9780 (dolist (article articles)
9781 (push article gnus-newsgroup-forwarded)
9782 (let ((buffer-read-only nil))
9783 (when (gnus-summary-goto-subject article nil t)
9784 (gnus-summary-update-secondary-mark article))))))
9786 (defun gnus-summary-set-bookmark (article)
9787 "Set a bookmark in current article."
9788 (interactive (list (gnus-summary-article-number)))
9789 (when (or (not (get-buffer gnus-article-buffer))
9790 (not gnus-current-article)
9791 (not gnus-article-current)
9792 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9793 (error "No current article selected"))
9794 ;; Remove old bookmark, if one exists.
9795 (gnus-pull article gnus-newsgroup-bookmarks)
9796 ;; Set the new bookmark, which is on the form
9797 ;; (article-number . line-number-in-body).
9800 (with-current-buffer gnus-article-buffer
9807 gnus-newsgroup-bookmarks)
9808 (gnus-message 6 "A bookmark has been added to the current article."))
9810 (defun gnus-summary-remove-bookmark (article)
9811 "Remove the bookmark from the current article."
9812 (interactive (list (gnus-summary-article-number)))
9813 ;; Remove old bookmark, if one exists.
9814 (if (not (assq article gnus-newsgroup-bookmarks))
9815 (gnus-message 6 "No bookmark in current article.")
9816 (gnus-pull article gnus-newsgroup-bookmarks)
9817 (gnus-message 6 "Removed bookmark.")))
9819 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9820 (defun gnus-summary-mark-as-dormant (n)
9821 "Mark N articles forward as dormant.
9822 If N is negative, mark backward instead. The difference between N and
9823 the actual number of articles marked is returned."
9825 (gnus-summary-mark-forward n gnus-dormant-mark))
9827 (defun gnus-summary-set-process-mark (article)
9828 "Set the process mark on ARTICLE and update the summary line."
9829 (setq gnus-newsgroup-processable
9831 (delq article gnus-newsgroup-processable)))
9832 (when (gnus-summary-goto-subject article)
9833 (gnus-summary-show-thread)
9834 (gnus-summary-goto-subject article)
9835 (gnus-summary-update-secondary-mark article)))
9837 (defun gnus-summary-remove-process-mark (article)
9838 "Remove the process mark from ARTICLE and update the summary line."
9839 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9840 (when (gnus-summary-goto-subject article)
9841 (gnus-summary-show-thread)
9842 (gnus-summary-goto-subject article)
9843 (gnus-summary-update-secondary-mark article)))
9845 (defun gnus-summary-set-saved-mark (article)
9846 "Set the process mark on ARTICLE and update the summary line."
9847 (push article gnus-newsgroup-saved)
9848 (when (gnus-summary-goto-subject article)
9849 (gnus-summary-update-secondary-mark article)))
9851 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9852 "Mark N articles as read forwards.
9853 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9854 The difference between N and the actual number of articles marked is
9856 If NO-EXPIRE, auto-expiry will be inhibited."
9858 (gnus-summary-show-thread)
9859 (let ((backward (< n 0))
9860 (gnus-summary-goto-unread
9861 (and gnus-summary-goto-unread
9862 (not (eq gnus-summary-goto-unread 'never))
9863 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9864 gnus-ticked-mark gnus-dormant-mark)))))
9866 (mark (or mark gnus-del-mark)))
9868 (gnus-summary-mark-article nil mark no-expire)
9869 (zerop (gnus-summary-next-subject
9871 (and gnus-summary-goto-unread
9872 (not (eq gnus-summary-goto-unread 'never)))
9876 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9877 (gnus-summary-recenter)
9878 (gnus-summary-position-point)
9879 (gnus-set-mode-line 'summary)
9882 (defun gnus-summary-mark-article-as-read (mark)
9883 "Mark the current article quickly as read with MARK."
9884 (let ((article (gnus-summary-article-number)))
9885 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9886 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9887 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9888 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9889 (push (cons article mark) gnus-newsgroup-reads)
9890 ;; Possibly remove from cache, if that is used.
9891 (when gnus-use-cache
9892 (gnus-cache-enter-remove-article article))
9893 ;; Allow the backend to change the mark.
9894 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9895 ;; Check for auto-expiry.
9896 (when (and gnus-newsgroup-auto-expire
9897 (memq mark gnus-auto-expirable-marks))
9898 (setq mark gnus-expirable-mark)
9899 ;; Let the backend know about the mark change.
9900 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9901 (push article gnus-newsgroup-expirable))
9902 ;; Set the mark in the buffer.
9903 (gnus-summary-update-mark mark 'unread)
9906 (defun gnus-summary-mark-article-as-unread (mark)
9907 "Mark the current article quickly as unread with MARK."
9908 (let* ((article (gnus-summary-article-number))
9909 (old-mark (gnus-summary-article-mark article)))
9910 ;; Allow the backend to change the mark.
9911 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9912 (if (eq mark old-mark)
9916 (gnus-error 1 "Can't mark negative article numbers")
9918 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9919 (setq gnus-newsgroup-spam-marked
9920 (delq article gnus-newsgroup-spam-marked))
9921 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9922 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9923 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9924 (cond ((= mark gnus-ticked-mark)
9925 (setq gnus-newsgroup-marked
9926 (gnus-add-to-sorted-list gnus-newsgroup-marked
9928 ((= mark gnus-spam-mark)
9929 (setq gnus-newsgroup-spam-marked
9930 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9932 ((= mark gnus-dormant-mark)
9933 (setq gnus-newsgroup-dormant
9934 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9937 (setq gnus-newsgroup-unreads
9938 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9940 (gnus-pull article gnus-newsgroup-reads)
9942 ;; See whether the article is to be put in the cache.
9944 (vectorp (gnus-summary-article-header article))
9946 (gnus-cache-possibly-enter-article
9947 gnus-newsgroup-name article
9948 (= mark gnus-ticked-mark)
9949 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9952 (gnus-summary-update-mark mark 'unread)
9955 (defun gnus-summary-mark-article (&optional article mark no-expire)
9956 "Mark ARTICLE with MARK. MARK can be any character.
9957 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9958 `??' (dormant) and `?E' (expirable).
9959 If MARK is nil, then the default character `?r' is used.
9960 If ARTICLE is nil, then the article on the current line will be
9962 If NO-EXPIRE, auto-expiry will be inhibited."
9963 ;; The mark might be a string.
9964 (when (stringp mark)
9965 (setq mark (aref mark 0)))
9966 ;; If no mark is given, then we check auto-expiring.
9968 (setq mark gnus-del-mark))
9969 (when (and (not no-expire)
9970 gnus-newsgroup-auto-expire
9971 (memq mark gnus-auto-expirable-marks))
9972 (setq mark gnus-expirable-mark))
9973 (let ((article (or article (gnus-summary-article-number)))
9974 (old-mark (gnus-summary-article-mark article)))
9975 ;; Allow the backend to change the mark.
9976 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9977 (if (eq mark old-mark)
9980 (error "No article on current line"))
9981 (if (not (if (or (= mark gnus-unread-mark)
9982 (= mark gnus-ticked-mark)
9983 (= mark gnus-spam-mark)
9984 (= mark gnus-dormant-mark))
9985 (gnus-mark-article-as-unread article mark)
9986 (gnus-mark-article-as-read article mark)))
9988 ;; See whether the article is to be put in the cache.
9990 (not (= mark gnus-canceled-mark))
9991 (vectorp (gnus-summary-article-header article))
9993 (gnus-cache-possibly-enter-article
9994 gnus-newsgroup-name article
9995 (= mark gnus-ticked-mark)
9996 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9998 (when (gnus-summary-goto-subject article nil t)
9999 (let ((buffer-read-only nil))
10000 (gnus-summary-show-thread)
10002 (gnus-summary-update-mark mark 'unread)
10005 (defun gnus-summary-update-secondary-mark (article)
10006 "Update the secondary (read, process, cache) mark."
10007 (gnus-summary-update-mark
10008 (cond ((memq article gnus-newsgroup-processable)
10010 ((memq article gnus-newsgroup-cached)
10012 ((memq article gnus-newsgroup-replied)
10014 ((memq article gnus-newsgroup-forwarded)
10015 gnus-forwarded-mark)
10016 ((memq article gnus-newsgroup-saved)
10018 ((memq article gnus-newsgroup-recent)
10020 ((memq article gnus-newsgroup-unseen)
10024 (when (gnus-visual-p 'summary-highlight 'highlight)
10025 (gnus-run-hooks 'gnus-summary-update-hook))
10028 (defun gnus-summary-update-download-mark (article)
10029 "Update the download mark."
10030 (gnus-summary-update-mark
10031 (cond ((memq article gnus-newsgroup-undownloaded)
10032 gnus-undownloaded-mark)
10033 (gnus-newsgroup-agentized
10034 gnus-downloaded-mark)
10038 (gnus-summary-update-line t)
10041 (defun gnus-summary-update-mark (mark type)
10042 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10043 (buffer-read-only nil))
10044 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10046 (when (looking-at "\r")
10048 (when (<= (+ forward (point)) (point-max))
10049 ;; Go to the right position on the line.
10050 (goto-char (+ forward (point)))
10051 ;; Replace the old mark with the new mark.
10052 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10053 ;; Optionally update the marks by some user rule.
10054 (when (eq type 'unread)
10055 (gnus-data-set-mark
10056 (gnus-data-find (gnus-summary-article-number)) mark)
10057 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10059 (defun gnus-mark-article-as-read (article &optional mark)
10060 "Enter ARTICLE in the pertinent lists and remove it from others."
10061 ;; Make the article expirable.
10062 (let ((mark (or mark gnus-del-mark)))
10063 (setq gnus-newsgroup-expirable
10064 (if (= mark gnus-expirable-mark)
10065 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10066 (delq article gnus-newsgroup-expirable)))
10067 ;; Remove from unread and marked lists.
10068 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10069 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10070 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10071 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10072 (push (cons article mark) gnus-newsgroup-reads)
10073 ;; Possibly remove from cache, if that is used.
10074 (when gnus-use-cache
10075 (gnus-cache-enter-remove-article article))
10078 (defun gnus-mark-article-as-unread (article &optional mark)
10079 "Enter ARTICLE in the pertinent lists and remove it from others."
10080 (let ((mark (or mark gnus-ticked-mark)))
10083 (gnus-error 1 "Can't mark negative article numbers")
10085 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10086 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10087 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10088 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10089 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10091 ;; Unsuppress duplicates?
10092 (when gnus-suppress-duplicates
10093 (gnus-dup-unsuppress-article article))
10095 (cond ((= mark gnus-ticked-mark)
10096 (setq gnus-newsgroup-marked
10097 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10098 ((= mark gnus-spam-mark)
10099 (setq gnus-newsgroup-spam-marked
10100 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10102 ((= mark gnus-dormant-mark)
10103 (setq gnus-newsgroup-dormant
10104 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10106 (setq gnus-newsgroup-unreads
10107 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10108 (gnus-pull article gnus-newsgroup-reads)
10111 (defalias 'gnus-summary-mark-as-unread-forward
10112 'gnus-summary-tick-article-forward)
10113 (make-obsolete 'gnus-summary-mark-as-unread-forward
10114 'gnus-summary-tick-article-forward)
10115 (defun gnus-summary-tick-article-forward (n)
10116 "Tick N articles forwards.
10117 If N is negative, tick backwards instead.
10118 The difference between N and the number of articles ticked is returned."
10120 (gnus-summary-mark-forward n gnus-ticked-mark))
10122 (defalias 'gnus-summary-mark-as-unread-backward
10123 'gnus-summary-tick-article-backward)
10124 (make-obsolete 'gnus-summary-mark-as-unread-backward
10125 'gnus-summary-tick-article-backward)
10126 (defun gnus-summary-tick-article-backward (n)
10127 "Tick N articles backwards.
10128 The difference between N and the number of articles ticked is returned."
10130 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10132 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10133 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10134 (defun gnus-summary-tick-article (&optional article clear-mark)
10135 "Mark current article as unread.
10136 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10137 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10139 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10140 gnus-ticked-mark)))
10142 (defun gnus-summary-mark-as-read-forward (n)
10143 "Mark N articles as read forwards.
10144 If N is negative, mark backwards instead.
10145 The difference between N and the actual number of articles marked is
10148 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10150 (defun gnus-summary-mark-as-read-backward (n)
10151 "Mark the N articles as read backwards.
10152 The difference between N and the actual number of articles marked is
10155 (gnus-summary-mark-forward
10156 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10158 (defun gnus-summary-mark-as-read (&optional article mark)
10159 "Mark current article as read.
10160 ARTICLE specifies the article to be marked as read.
10161 MARK specifies a string to be inserted at the beginning of the line."
10162 (gnus-summary-mark-article article mark))
10164 (defun gnus-summary-clear-mark-forward (n)
10165 "Clear marks from N articles forward.
10166 If N is negative, clear backward instead.
10167 The difference between N and the number of marks cleared is returned."
10169 (gnus-summary-mark-forward n gnus-unread-mark))
10171 (defun gnus-summary-clear-mark-backward (n)
10172 "Clear marks from N articles backward.
10173 The difference between N and the number of marks cleared is returned."
10175 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10177 (defun gnus-summary-mark-unread-as-read ()
10178 "Intended to be used by `gnus-summary-mark-article-hook'."
10179 (when (memq gnus-current-article gnus-newsgroup-unreads)
10180 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10182 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10183 "Intended to be used by `gnus-summary-mark-article-hook'."
10184 (let ((mark (gnus-summary-article-mark)))
10185 (when (or (gnus-unread-mark-p mark)
10186 (gnus-read-mark-p mark))
10187 (gnus-summary-mark-article gnus-current-article
10188 (or new-mark gnus-read-mark)))))
10190 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10191 "Intended to be used by `gnus-summary-mark-article-hook'."
10192 (let ((mark (gnus-summary-article-mark)))
10193 (when (or (gnus-unread-mark-p mark)
10194 (gnus-read-mark-p mark))
10195 (gnus-summary-mark-article (gnus-summary-article-number)
10196 (or new-mark gnus-read-mark)))))
10198 (defun gnus-summary-mark-unread-as-ticked ()
10199 "Intended to be used by `gnus-summary-mark-article-hook'."
10200 (when (memq gnus-current-article gnus-newsgroup-unreads)
10201 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10203 (defun gnus-summary-mark-region-as-read (point mark all)
10204 "Mark all unread articles between point and mark as read.
10205 If given a prefix, mark all articles between point and mark as read,
10206 even ticked and dormant ones."
10207 (interactive "r\nP")
10211 (beginning-of-line)
10216 (memq (setq article (gnus-summary-article-number))
10217 gnus-newsgroup-unreads))
10218 (gnus-summary-mark-article article gnus-del-mark))
10220 (gnus-summary-find-next))))))
10222 (defun gnus-summary-mark-below (score mark)
10223 "Mark articles with score less than SCORE with MARK."
10224 (interactive "P\ncMark: ")
10225 (setq score (if score
10226 (prefix-numeric-value score)
10227 (or gnus-summary-default-score 0)))
10229 (set-buffer gnus-summary-buffer)
10230 (goto-char (point-min))
10233 (and (< (gnus-summary-article-score) score)
10234 (gnus-summary-mark-article nil mark))
10235 (gnus-summary-find-next)))))
10237 (defun gnus-summary-kill-below (&optional score)
10238 "Mark articles with score below SCORE as read."
10240 (gnus-summary-mark-below score gnus-killed-mark))
10242 (defun gnus-summary-clear-above (&optional score)
10243 "Clear all marks from articles with score above SCORE."
10245 (gnus-summary-mark-above score gnus-unread-mark))
10247 (defun gnus-summary-tick-above (&optional score)
10248 "Tick all articles with score above SCORE."
10250 (gnus-summary-mark-above score gnus-ticked-mark))
10252 (defun gnus-summary-mark-above (score mark)
10253 "Mark articles with score over SCORE with MARK."
10254 (interactive "P\ncMark: ")
10255 (setq score (if score
10256 (prefix-numeric-value score)
10257 (or gnus-summary-default-score 0)))
10259 (set-buffer gnus-summary-buffer)
10260 (goto-char (point-min))
10262 (when (> (gnus-summary-article-score) score)
10263 (gnus-summary-mark-article nil mark))
10265 (gnus-summary-find-next)))))
10267 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10268 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10269 (defun gnus-summary-limit-include-expunged (&optional no-error)
10270 "Display all the hidden articles that were expunged for low scores."
10272 (let ((buffer-read-only nil))
10273 (let ((scored gnus-newsgroup-scored)
10276 (unless (gnus-summary-article-header (caar scored))
10277 (and (setq h (gnus-number-to-header (caar scored)))
10278 (< (cdar scored) gnus-summary-expunge-below)
10280 (setq scored (cdr scored)))
10282 (when (not no-error)
10283 (error "No expunged articles hidden"))
10284 (goto-char (point-min))
10285 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10286 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10287 (mapcar (lambda (x) (push (mail-header-number x)
10288 gnus-newsgroup-limit))
10290 (gnus-summary-prepare-unthreaded (nreverse headers))
10291 (goto-char (point-min))
10292 (gnus-summary-position-point)
10295 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10296 "Mark all unread articles in this newsgroup as read.
10297 If prefix argument ALL is non-nil, ticked and dormant articles will
10298 also be marked as read.
10299 If QUIETLY is non-nil, no questions will be asked.
10301 If TO-HERE is non-nil, it should be a point in the buffer. All
10302 articles before (after, if REVERSE is set) this point will be marked
10305 Note that this function will only catch up the unread article
10306 in the current summary buffer limitation.
10308 The number of articles marked as read is returned."
10313 (not gnus-interactive-catchup) ;Without confirmation?
10317 "Mark absolutely all articles as read? "
10318 "Mark all unread articles as read? ")))
10320 (not gnus-newsgroup-adaptive)
10321 (not gnus-newsgroup-auto-expire)
10322 (not gnus-suppress-duplicates)
10323 (or (not gnus-use-cache)
10324 (eq gnus-use-cache 'passive)))
10327 (setq gnus-newsgroup-marked nil
10328 gnus-newsgroup-spam-marked nil
10329 gnus-newsgroup-dormant nil))
10330 (setq gnus-newsgroup-unreads
10331 (gnus-sorted-nunion
10332 (gnus-intersection gnus-newsgroup-unreads
10333 gnus-newsgroup-downloadable)
10334 gnus-newsgroup-unfetched)))
10335 ;; We actually mark all articles as canceled, which we
10336 ;; have to do when using auto-expiry or adaptive scoring.
10337 (gnus-summary-show-all-threads)
10338 (if (and to-here reverse)
10340 (goto-char to-here)
10341 (gnus-summary-mark-current-read-and-unread-as-read
10343 (while (gnus-summary-find-next (not all))
10344 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10345 (when (gnus-summary-first-subject (not all))
10347 (if to-here (< (point) to-here) t)
10348 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10349 (gnus-summary-find-next (not all))))))
10350 (gnus-set-mode-line 'summary))
10352 (gnus-summary-position-point)))
10354 (defun gnus-summary-catchup-to-here (&optional all)
10355 "Mark all unticked articles before the current one as read.
10356 If ALL is non-nil, also mark ticked and dormant articles as read."
10359 (gnus-save-hidden-threads
10360 (let ((beg (point)))
10361 ;; We check that there are unread articles.
10362 (when (or all (gnus-summary-find-prev))
10363 (gnus-summary-catchup all t beg)))))
10364 (gnus-summary-position-point))
10366 (defun gnus-summary-catchup-from-here (&optional all)
10367 "Mark all unticked articles after (and including) the current one as read.
10368 If ALL is non-nil, also mark ticked and dormant articles as read."
10371 (gnus-save-hidden-threads
10372 (let ((beg (point)))
10373 ;; We check that there are unread articles.
10374 (when (or all (gnus-summary-find-next))
10375 (gnus-summary-catchup all t beg nil t)))))
10376 (gnus-summary-position-point))
10378 (defun gnus-summary-catchup-all (&optional quietly)
10379 "Mark all articles in this newsgroup as read.
10380 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10381 instead, which marks only unread articles as read."
10383 (gnus-summary-catchup t quietly))
10385 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10386 "Mark all unread articles in this group as read, then exit.
10387 If prefix argument ALL is non-nil, all articles are marked as read.
10388 If QUIETLY is non-nil, no questions will be asked."
10390 (when (gnus-summary-catchup all quietly nil 'fast)
10391 ;; Select next newsgroup or exit.
10392 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10393 (eq gnus-auto-select-next 'quietly))
10394 (gnus-summary-next-group nil)
10395 (gnus-summary-exit))))
10397 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10398 "Mark all articles in this newsgroup as read, and then exit.
10399 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10400 instead, which marks only unread articles as read."
10402 (gnus-summary-catchup-and-exit t quietly))
10404 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10405 "Mark all articles in this group as read and select the next group.
10406 If given a prefix, mark all articles, unread as well as ticked, as
10410 (gnus-summary-catchup all))
10411 (gnus-summary-next-group))
10417 (defmacro gnus-with-article (article &rest forms)
10418 "Select ARTICLE and perform FORMS in the original article buffer.
10419 Then replace the article with the result."
10421 ;; We don't want the article to be marked as read.
10422 (let (gnus-mark-article-hook)
10423 (gnus-summary-select-article t t nil ,article))
10424 (set-buffer gnus-original-article-buffer)
10426 (if (not (gnus-check-backend-function
10427 'request-replace-article (car gnus-article-current)))
10428 (gnus-message 5 "Read-only group; not replacing")
10429 (unless (gnus-request-replace-article
10430 ,article (car gnus-article-current)
10431 (current-buffer) t)
10432 (error "Couldn't replace article")))
10433 ;; The cache and backlog have to be flushed somewhat.
10434 (when gnus-keep-backlog
10435 (gnus-backlog-remove-article
10436 (car gnus-article-current) (cdr gnus-article-current)))
10437 (when gnus-use-cache
10438 (gnus-cache-update-article
10439 (car gnus-article-current) (cdr gnus-article-current)))))
10441 (put 'gnus-with-article 'lisp-indent-function 1)
10442 (put 'gnus-with-article 'edebug-form-spec '(form body))
10444 ;; Thread-based commands.
10446 (defun gnus-summary-articles-in-thread (&optional article)
10447 "Return a list of all articles in the current thread.
10448 If ARTICLE is non-nil, return all articles in the thread that starts
10449 with that article."
10450 (let* ((article (or article (gnus-summary-article-number)))
10451 (data (gnus-data-find-list article))
10452 (top-level (gnus-data-level (car data)))
10454 (cond ((null gnus-thread-operation-ignore-subject)
10455 (gnus-simplify-subject-re
10456 (mail-header-subject (gnus-data-header (car data)))))
10457 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10458 (gnus-simplify-subject-fuzzy
10459 (mail-header-subject (gnus-data-header (car data)))))
10461 (end-point (save-excursion
10462 (if (gnus-summary-go-to-next-thread)
10463 (point) (point-max))))
10466 (< (gnus-data-pos (car data)) end-point))
10467 (when (or (not top-subject)
10468 (string= top-subject
10469 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10470 (gnus-simplify-subject-fuzzy
10471 (mail-header-subject
10472 (gnus-data-header (car data))))
10473 (gnus-simplify-subject-re
10474 (mail-header-subject
10475 (gnus-data-header (car data)))))))
10476 (push (gnus-data-number (car data)) articles))
10477 (unless (and (setq data (cdr data))
10478 (> (gnus-data-level (car data)) top-level))
10480 ;; Return the list of articles.
10481 (nreverse articles)))
10483 (defun gnus-summary-rethread-current ()
10484 "Rethread the thread the current article is part of."
10486 (let* ((gnus-show-threads t)
10487 (article (gnus-summary-article-number))
10488 (id (mail-header-id (gnus-summary-article-header)))
10489 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10491 (error "No article on the current line"))
10492 (gnus-rebuild-thread id)
10493 (gnus-summary-goto-subject article)))
10495 (defun gnus-summary-reparent-thread ()
10496 "Make the current article child of the marked (or previous) article.
10498 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10499 is non-nil or the Subject: of both articles are the same."
10501 (unless (not (gnus-group-read-only-p))
10502 (error "The current newsgroup does not support article editing"))
10503 (unless (<= (length gnus-newsgroup-processable) 1)
10504 (error "No more than one article may be marked"))
10505 (save-window-excursion
10506 (let ((gnus-article-buffer " *reparent*")
10507 (current-article (gnus-summary-article-number))
10508 ;; First grab the marked article, otherwise one line up.
10509 (parent-article (if (not (null gnus-newsgroup-processable))
10510 (car gnus-newsgroup-processable)
10512 (if (eq (forward-line -1) 0)
10513 (gnus-summary-article-number)
10514 (error "Beginning of summary buffer"))))))
10515 (unless (not (eq current-article parent-article))
10516 (error "An article may not be self-referential"))
10517 (let ((message-id (mail-header-id
10518 (gnus-summary-article-header parent-article))))
10519 (unless (and message-id (not (equal message-id "")))
10520 (error "No message-id in desired parent"))
10521 (gnus-with-article current-article
10523 (goto-char (point-min))
10524 (message-narrow-to-head)
10525 (if (re-search-forward "^References: " nil t)
10527 (re-search-forward "^[^ \t]" nil t)
10530 (insert " " message-id))
10531 (insert "References: " message-id "\n"))))
10532 (set-buffer gnus-summary-buffer)
10533 (gnus-summary-unmark-all-processable)
10534 (gnus-summary-update-article current-article)
10535 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10536 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10537 (gnus-summary-rethread-current)
10538 (gnus-message 3 "Article %d is now the child of article %d"
10539 current-article parent-article)))))
10541 (defun gnus-summary-toggle-threads (&optional arg)
10542 "Toggle showing conversation threads.
10543 If ARG is positive number, turn showing conversation threads on."
10545 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10546 (setq gnus-show-threads
10547 (if (null arg) (not gnus-show-threads)
10548 (> (prefix-numeric-value arg) 0)))
10549 (gnus-summary-prepare)
10550 (gnus-summary-goto-subject current)
10551 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10552 (gnus-summary-position-point)))
10554 (defun gnus-summary-show-all-threads ()
10555 "Show all threads."
10558 (let ((buffer-read-only nil))
10559 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10560 (gnus-summary-position-point))
10562 (defun gnus-summary-show-thread ()
10563 "Show thread subtrees.
10564 Returns nil if no thread was there to be shown."
10566 (let ((buffer-read-only nil)
10568 (end (point-at-eol))
10569 ;; Leave point at bol
10570 (beg (progn (beginning-of-line) (point))))
10572 ;; Any hidden lines here?
10573 (search-forward "\r" end t)
10574 (subst-char-in-region beg end ?\^M ?\n t)
10576 (gnus-summary-position-point))))
10578 (defun gnus-summary-maybe-hide-threads ()
10579 "If requested, hide the threads that should be hidden."
10580 (when (and gnus-show-threads
10581 gnus-thread-hide-subtree)
10582 (gnus-summary-hide-all-threads
10583 (if (or (consp gnus-thread-hide-subtree)
10584 (functionp gnus-thread-hide-subtree))
10585 (gnus-make-predicate gnus-thread-hide-subtree)
10588 ;;; Hiding predicates.
10590 (defun gnus-article-unread-p (header)
10591 (memq (mail-header-number header) gnus-newsgroup-unreads))
10593 (defun gnus-article-unseen-p (header)
10594 (memq (mail-header-number header) gnus-newsgroup-unseen))
10596 (defun gnus-map-articles (predicate articles)
10597 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10598 (apply 'gnus-or (mapcar predicate
10599 (mapcar 'gnus-summary-article-header articles))))
10601 (defun gnus-summary-hide-all-threads (&optional predicate)
10602 "Hide all thread subtrees.
10603 If PREDICATE is supplied, threads that satisfy this predicate
10604 will not be hidden."
10607 (goto-char (point-min))
10610 (when (or (not predicate)
10612 predicate (gnus-summary-article-children)))
10613 (gnus-summary-hide-thread))
10614 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10615 (gnus-summary-position-point))
10617 (defun gnus-summary-hide-thread ()
10618 "Hide thread subtrees.
10619 If PREDICATE is supplied, threads that satisfy this predicate
10620 will not be hidden.
10621 Returns nil if no threads were there to be hidden."
10623 (let ((buffer-read-only nil)
10625 (article (gnus-summary-article-number)))
10627 ;; Go forward until either the buffer ends or the subthread
10629 (when (and (not (eobp))
10630 (or (zerop (gnus-summary-next-thread 1 t))
10631 (goto-char (point-max))))
10633 (if (and (> (point) start)
10634 (search-backward "\n" start t))
10636 (subst-char-in-region start (point) ?\n ?\^M)
10637 (gnus-summary-goto-subject article))
10641 (defun gnus-summary-go-to-next-thread (&optional previous)
10642 "Go to the same level (or less) next thread.
10643 If PREVIOUS is non-nil, go to previous thread instead.
10644 Return the article number moved to, or nil if moving was impossible."
10645 (let ((level (gnus-summary-thread-level))
10646 (way (if previous -1 1))
10649 (while (and (not (eobp))
10650 (< level (gnus-summary-thread-level)))
10651 (forward-line way))
10658 (gnus-summary-article-number)
10659 (goto-char beg)))))
10661 (defun gnus-summary-next-thread (n &optional silent)
10662 "Go to the same level next N'th thread.
10663 If N is negative, search backward instead.
10664 Returns the difference between N and the number of skips actually
10667 If SILENT, don't output messages."
10669 (let ((backward (< n 0))
10671 (while (and (> n 0)
10672 (gnus-summary-go-to-next-thread backward))
10675 (gnus-summary-position-point))
10676 (when (and (not silent) (/= 0 n))
10677 (gnus-message 7 "No more threads"))
10680 (defun gnus-summary-prev-thread (n)
10681 "Go to the same level previous N'th thread.
10682 Returns the difference between N and the number of skips actually
10685 (gnus-summary-next-thread (- n)))
10687 (defun gnus-summary-go-down-thread ()
10688 "Go down one level in the current thread."
10689 (let ((children (gnus-summary-article-children)))
10691 (gnus-summary-goto-subject (car children)))))
10693 (defun gnus-summary-go-up-thread ()
10694 "Go up one level in the current thread."
10695 (let ((parent (gnus-summary-article-parent)))
10697 (gnus-summary-goto-subject parent))))
10699 (defun gnus-summary-down-thread (n)
10700 "Go down thread N steps.
10701 If N is negative, go up instead.
10702 Returns the difference between N and how many steps down that were
10707 (while (and (> n 0)
10708 (if up (gnus-summary-go-up-thread)
10709 (gnus-summary-go-down-thread)))
10711 (gnus-summary-position-point)
10713 (gnus-message 7 "Can't go further"))
10716 (defun gnus-summary-up-thread (n)
10717 "Go up thread N steps.
10718 If N is negative, go down instead.
10719 Returns the difference between N and how many steps down that were
10722 (gnus-summary-down-thread (- n)))
10724 (defun gnus-summary-top-thread ()
10725 "Go to the top of the thread."
10727 (while (gnus-summary-go-up-thread))
10728 (gnus-summary-article-number))
10730 (defun gnus-summary-kill-thread (&optional unmark)
10731 "Mark articles under current thread as read.
10732 If the prefix argument is positive, remove any kinds of marks.
10733 If the prefix argument is negative, tick articles instead."
10736 (setq unmark (prefix-numeric-value unmark)))
10737 (let ((articles (gnus-summary-articles-in-thread)))
10739 ;; Expand the thread.
10740 (gnus-summary-show-thread)
10741 ;; Mark all the articles.
10743 (gnus-summary-goto-subject (car articles))
10744 (cond ((null unmark)
10745 (gnus-summary-mark-article-as-read gnus-killed-mark))
10747 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10749 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10750 (setq articles (cdr articles))))
10751 ;; Hide killed subtrees.
10753 gnus-thread-hide-killed
10754 (gnus-summary-hide-thread))
10755 ;; If marked as read, go to next unread subject.
10756 (when (null unmark)
10757 ;; Go to next unread subject.
10758 (gnus-summary-next-subject 1 t)))
10759 (gnus-set-mode-line 'summary))
10761 ;; Summary sorting commands
10763 (defun gnus-summary-sort-by-number (&optional reverse)
10764 "Sort the summary buffer by article number.
10765 Argument REVERSE means reverse order."
10767 (gnus-summary-sort 'number reverse))
10769 (defun gnus-summary-sort-by-random (&optional reverse)
10770 "Randomize the order in the summary buffer.
10771 Argument REVERSE means to randomize in reverse order."
10773 (gnus-summary-sort 'random reverse))
10775 (defun gnus-summary-sort-by-author (&optional reverse)
10776 "Sort the summary buffer by author name alphabetically.
10777 If `case-fold-search' is non-nil, case of letters is ignored.
10778 Argument REVERSE means reverse order."
10780 (gnus-summary-sort 'author reverse))
10782 (defun gnus-summary-sort-by-subject (&optional reverse)
10783 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10784 If `case-fold-search' is non-nil, case of letters is ignored.
10785 Argument REVERSE means reverse order."
10787 (gnus-summary-sort 'subject reverse))
10789 (defun gnus-summary-sort-by-date (&optional reverse)
10790 "Sort the summary buffer by date.
10791 Argument REVERSE means reverse order."
10793 (gnus-summary-sort 'date reverse))
10795 (defun gnus-summary-sort-by-score (&optional reverse)
10796 "Sort the summary buffer by score.
10797 Argument REVERSE means reverse order."
10799 (gnus-summary-sort 'score reverse))
10801 (defun gnus-summary-sort-by-lines (&optional reverse)
10802 "Sort the summary buffer by the number of lines.
10803 Argument REVERSE means reverse order."
10805 (gnus-summary-sort 'lines reverse))
10807 (defun gnus-summary-sort-by-chars (&optional reverse)
10808 "Sort the summary buffer by article length.
10809 Argument REVERSE means reverse order."
10811 (gnus-summary-sort 'chars reverse))
10813 (defun gnus-summary-sort-by-original (&optional reverse)
10814 "Sort the summary buffer using the default sorting method.
10815 Argument REVERSE means reverse order."
10817 (let* ((buffer-read-only)
10818 (gnus-summary-prepare-hook nil))
10819 ;; We do the sorting by regenerating the threads.
10820 (gnus-summary-prepare)
10821 ;; Hide subthreads if needed.
10822 (gnus-summary-maybe-hide-threads)))
10824 (defun gnus-summary-sort (predicate reverse)
10825 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10826 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10827 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10828 (gnus-thread-sort-functions
10833 (gnus-sort-gathered-threads-function
10834 gnus-thread-sort-functions)
10835 (gnus-article-sort-functions
10839 (,article t2 t1))))
10841 (gnus-summary-prepare-hook nil))
10842 ;; We do the sorting by regenerating the threads.
10843 (gnus-summary-prepare)
10844 ;; Hide subthreads if needed.
10845 (gnus-summary-maybe-hide-threads)))
10847 ;; Summary saving commands.
10849 (defun gnus-summary-save-article (&optional n not-saved)
10850 "Save the current article using the default saver function.
10851 If N is a positive number, save the N next articles.
10852 If N is a negative number, save the N previous articles.
10853 If N is nil and any articles have been marked with the process mark,
10854 save those articles instead.
10855 The variable `gnus-default-article-saver' specifies the saver function."
10857 (let* ((articles (gnus-summary-work-articles n))
10858 (save-buffer (save-excursion
10859 (nnheader-set-temp-buffer " *Gnus Save*")))
10860 (num (length articles))
10862 (dolist (article articles)
10863 (setq header (gnus-summary-article-header article))
10864 (if (not (vectorp header))
10865 ;; This is a pseudo-article.
10866 (if (assq 'name header)
10867 (gnus-copy-file (cdr (assq 'name header)))
10868 (gnus-message 1 "Article %d is unsaveable" article))
10869 ;; This is a real article.
10870 (save-window-excursion
10871 (let ((gnus-display-mime-function nil)
10872 (gnus-article-prepare-hook nil))
10873 (gnus-summary-select-article t nil nil article)))
10875 (set-buffer save-buffer)
10877 (insert-buffer-substring gnus-original-article-buffer))
10878 (setq file (gnus-article-save save-buffer file num))
10879 (gnus-summary-remove-process-mark article)
10881 (gnus-summary-set-saved-mark article))))
10882 (gnus-kill-buffer save-buffer)
10883 (gnus-summary-position-point)
10884 (gnus-set-mode-line 'summary)
10887 (defun gnus-summary-pipe-output (&optional arg headers)
10888 "Pipe the current article to a subprocess.
10889 If N is a positive number, pipe the N next articles.
10890 If N is a negative number, pipe the N previous articles.
10891 If N is nil and any articles have been marked with the process mark,
10892 pipe those articles instead.
10893 If HEADERS (the symbolic prefix), include the headers, too."
10894 (interactive (gnus-interactive "P\ny"))
10895 (require 'gnus-art)
10896 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10897 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10898 (gnus-summary-save-article arg t))
10899 (let ((buffer (get-buffer "*Shell Command Output*")))
10901 (not (zerop (buffer-size buffer))))
10902 (gnus-configure-windows 'pipe))))
10904 (defun gnus-summary-save-article-mail (&optional arg)
10905 "Append the current article to an mail file.
10906 If N is a positive number, save the N next articles.
10907 If N is a negative number, save the N previous articles.
10908 If N is nil and any articles have been marked with the process mark,
10909 save those articles instead."
10911 (require 'gnus-art)
10912 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10913 (gnus-summary-save-article arg)))
10915 (defun gnus-summary-save-article-rmail (&optional arg)
10916 "Append the current article to an rmail file.
10917 If N is a positive number, save the N next articles.
10918 If N is a negative number, save the N previous articles.
10919 If N is nil and any articles have been marked with the process mark,
10920 save those articles instead."
10922 (require 'gnus-art)
10923 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10924 (gnus-summary-save-article arg)))
10926 (defun gnus-summary-save-article-file (&optional arg)
10927 "Append the current article to a file.
10928 If N is a positive number, save the N next articles.
10929 If N is a negative number, save the N previous articles.
10930 If N is nil and any articles have been marked with the process mark,
10931 save those articles instead."
10933 (require 'gnus-art)
10934 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10935 (gnus-summary-save-article arg)))
10937 (defun gnus-summary-write-article-file (&optional arg)
10938 "Write the current article to a file, deleting the previous file.
10939 If N is a positive number, save the N next articles.
10940 If N is a negative number, save the N previous articles.
10941 If N is nil and any articles have been marked with the process mark,
10942 save those articles instead."
10944 (require 'gnus-art)
10945 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10946 (gnus-summary-save-article arg)))
10948 (defun gnus-summary-save-article-body-file (&optional arg)
10949 "Append the current article body to a file.
10950 If N is a positive number, save the N next articles.
10951 If N is a negative number, save the N previous articles.
10952 If N is nil and any articles have been marked with the process mark,
10953 save those articles instead."
10955 (require 'gnus-art)
10956 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10957 (gnus-summary-save-article arg)))
10959 (defun gnus-summary-muttprint (&optional arg)
10960 "Print the current article using Muttprint.
10961 If N is a positive number, save the N next articles.
10962 If N is a negative number, save the N previous articles.
10963 If N is nil and any articles have been marked with the process mark,
10964 save those articles instead."
10966 (require 'gnus-art)
10967 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10968 (gnus-summary-save-article arg t)))
10970 (defun gnus-summary-pipe-message (program)
10971 "Pipe the current article through PROGRAM."
10972 (interactive "sProgram: ")
10973 (gnus-summary-select-article)
10974 (let ((mail-header-separator ""))
10975 (gnus-eval-in-buffer-window gnus-article-buffer
10978 (let ((start (window-start))
10980 (message-pipe-buffer-body program)
10981 (set-window-start (get-buffer-window (current-buffer)) start))))))
10983 (defun gnus-get-split-value (methods)
10984 "Return a value based on the split METHODS."
10985 (let (split-name method result match)
10988 (set-buffer gnus-original-article-buffer)
10990 (nnheader-narrow-to-headers)
10991 (while (and methods (not split-name))
10992 (goto-char (point-min))
10993 (setq method (pop methods))
10994 (setq match (car method))
10997 ;; Regular expression.
10999 (re-search-forward match nil t)))
11004 (setq result (funcall match gnus-newsgroup-name))))
11009 (setq result (eval match)))))
11010 (setq split-name (cdr method))
11011 (cond ((stringp result)
11012 (push (expand-file-name
11013 result gnus-article-save-directory)
11016 (setq split-name (append result split-name)))))))))
11017 (nreverse split-name)))
11019 (defun gnus-valid-move-group-p (group)
11020 (and (boundp group)
11021 (symbol-name group)
11022 (symbol-value group)
11023 (gnus-get-function (gnus-find-method-for-group
11024 (symbol-name group)) 'request-accept-article t)))
11026 (defun gnus-read-move-group-name (prompt default articles prefix)
11027 "Read a group name."
11028 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11029 (minibuffer-confirm-incomplete nil) ; XEmacs
11031 (format "%s %s to:"
11033 (if (> (length articles) 1)
11034 (format "these %d articles" (length articles))
11039 (gnus-completing-read-with-default
11042 'gnus-valid-move-group-p
11044 'gnus-group-history))
11045 ((= 1 (length split-name))
11046 (gnus-completing-read-with-default
11047 (car split-name) prom
11049 'gnus-valid-move-group-p
11051 'gnus-group-history))
11053 (gnus-completing-read-with-default
11055 (mapcar 'list (nreverse split-name))
11057 'gnus-group-history))))
11058 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11060 (if (or (string= to-newsgroup "")
11061 (string= to-newsgroup prefix))
11062 (setq to-newsgroup default))
11063 (unless to-newsgroup
11064 (error "No group name entered"))
11065 (or (gnus-active to-newsgroup)
11066 (gnus-activate-group to-newsgroup nil nil to-method)
11067 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11069 (or (and (gnus-request-create-group to-newsgroup to-method)
11070 (gnus-activate-group
11071 to-newsgroup nil nil to-method)
11072 (gnus-subscribe-group to-newsgroup))
11073 (error "Couldn't create group %s" to-newsgroup)))
11074 (error "No such group: %s" to-newsgroup)))
11077 (defun gnus-summary-save-parts (type dir n &optional reverse)
11078 "Save parts matching TYPE to DIR.
11079 If REVERSE, save parts that do not match TYPE."
11081 (list (read-string "Save parts of type: "
11082 (or (car gnus-summary-save-parts-type-history)
11083 gnus-summary-save-parts-default-mime)
11084 'gnus-summary-save-parts-type-history)
11085 (setq gnus-summary-save-parts-last-directory
11086 (read-file-name "Save to directory: "
11087 gnus-summary-save-parts-last-directory
11089 current-prefix-arg))
11090 (gnus-summary-iterate n
11091 (let ((gnus-display-mime-function nil)
11092 (gnus-inhibit-treatment t))
11093 (gnus-summary-select-article))
11095 (set-buffer gnus-article-buffer)
11096 (let ((handles (or gnus-article-mime-handles
11097 (mm-dissect-buffer nil gnus-article-loose-mime)
11098 (and gnus-article-emulate-mime
11099 (mm-uu-dissect)))))
11101 (gnus-summary-save-parts-1 type dir handles reverse)
11102 (unless gnus-article-mime-handles ;; Don't destroy this case.
11103 (mm-destroy-parts handles)))))))
11105 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11106 (if (stringp (car handle))
11107 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11110 (not (string-match type (mm-handle-media-type handle)))
11111 (string-match type (mm-handle-media-type handle)))
11112 (let ((file (expand-file-name
11114 mm-file-name-rewrite-functions
11115 (file-name-nondirectory
11117 (mail-content-type-get
11118 (mm-handle-disposition handle) 'filename)
11119 (mail-content-type-get
11120 (mm-handle-type handle) 'name)
11121 (concat gnus-newsgroup-name
11122 "." (number-to-string
11123 (cdr gnus-article-current))))))
11125 (unless (file-exists-p file)
11126 (mm-save-part-to-file handle file))))))
11128 ;; Summary extract commands
11130 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11131 (let ((buffer-read-only nil)
11132 (article (gnus-summary-article-number))
11134 (unless (gnus-summary-goto-subject article)
11135 (error "No such article: %d" article))
11136 (gnus-summary-position-point)
11137 ;; If all commands are to be bunched up on one line, we collect
11139 (unless gnus-view-pseudos-separately
11140 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11143 (setq action (cdr (assq 'action (car ps))))
11144 (setq files (list (cdr (assq 'name (car ps)))))
11145 (while (and ps (cdr ps)
11146 (string= (or action "1")
11147 (or (cdr (assq 'action (cadr ps))) "2")))
11148 (push (cdr (assq 'name (cadr ps))) files)
11149 (setcdr ps (cddr ps)))
11151 (when (not (string-match "%s" action))
11154 (when (assq 'execute (car ps))
11155 (setcdr (assq 'execute (car ps))
11156 (funcall (if (string-match "%s" action)
11163 (shell-quote-argument f)))
11165 (setq ps (cdr ps)))))
11166 (if (and gnus-view-pseudos (not not-view))
11168 (when (assq 'execute (car pslist))
11169 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11170 (eq gnus-view-pseudos 'not-confirm)))
11171 (setq pslist (cdr pslist)))
11174 (setq after-article (or (cdr (assq 'article (car pslist)))
11175 (gnus-summary-article-number)))
11176 (gnus-summary-goto-subject after-article)
11179 (insert " " (file-name-nondirectory
11180 (cdr (assq 'name (car pslist))))
11181 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11183 (forward-line -1) ; back to `b'
11184 (gnus-add-text-properties
11185 b (1- e) (list 'gnus-number gnus-reffed-article-number
11186 gnus-mouse-face-prop gnus-mouse-face))
11188 after-article gnus-reffed-article-number
11189 gnus-unread-mark b (car pslist) 0 (- e b))
11190 (setq gnus-newsgroup-unreads
11191 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11192 gnus-reffed-article-number))
11193 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11194 (setq pslist (cdr pslist)))))))
11196 (defun gnus-pseudos< (p1 p2)
11197 (let ((c1 (cdr (assq 'action p1)))
11198 (c2 (cdr (assq 'action p2))))
11199 (and c1 c2 (string< c1 c2))))
11201 (defun gnus-request-pseudo-article (props)
11202 (cond ((assq 'execute props)
11203 (gnus-execute-command (cdr (assq 'execute props)))))
11204 (let ((gnus-current-article (gnus-summary-article-number)))
11205 (gnus-run-hooks 'gnus-mark-article-hook)))
11207 (defun gnus-execute-command (command &optional automatic)
11209 (gnus-article-setup-buffer)
11210 (set-buffer gnus-article-buffer)
11211 (setq buffer-read-only nil)
11212 (let ((command (if automatic command
11213 (read-string "Command: " (cons command 0)))))
11215 (insert "$ " command "\n\n")
11216 (if gnus-view-pseudo-asynchronously
11217 (start-process "gnus-execute" (current-buffer) shell-file-name
11218 shell-command-switch command)
11219 (call-process shell-file-name nil t nil
11220 shell-command-switch command)))))
11222 ;; Summary kill commands.
11224 (defun gnus-summary-edit-global-kill (article)
11225 "Edit the \"global\" kill file."
11226 (interactive (list (gnus-summary-article-number)))
11227 (gnus-group-edit-global-kill article))
11229 (defun gnus-summary-edit-local-kill ()
11230 "Edit a local kill file applied to the current newsgroup."
11232 (setq gnus-current-headers (gnus-summary-article-header))
11233 (gnus-group-edit-local-kill
11234 (gnus-summary-article-number) gnus-newsgroup-name))
11236 ;;; Header reading.
11238 (defun gnus-read-header (id &optional header)
11239 "Read the headers of article ID and enter them into the Gnus system."
11240 (let ((group gnus-newsgroup-name)
11241 (gnus-override-method
11243 gnus-override-method
11244 (and (gnus-news-group-p gnus-newsgroup-name)
11245 (car (gnus-refer-article-methods)))))
11247 ;; First we check to see whether the header in question is already
11250 ;; This is a Message-ID.
11251 (setq header (or header (gnus-id-to-header id)))
11252 ;; This is an article number.
11253 (setq header (or header (gnus-summary-article-header id))))
11255 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11256 ;; We have found the header.
11258 ;; We have to really fetch the header to this article.
11260 (set-buffer nntp-server-buffer)
11261 (when (setq where (gnus-request-head id group))
11262 (nnheader-fold-continuation-lines)
11263 (goto-char (point-max))
11265 (goto-char (point-min))
11269 ((cdr where) (cdr where))
11270 (header (mail-header-number header))
11271 (t gnus-reffed-article-number))
11273 (insert " Article retrieved.\n"))
11274 (if (or (not where)
11275 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11276 () ; Malformed head.
11277 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11278 (when (and (stringp id)
11279 (not (string= (gnus-group-real-name group)
11281 ;; If we fetched by Message-ID and the article came
11282 ;; from a different group, we fudge some bogus article
11283 ;; numbers for this article.
11284 (mail-header-set-number header gnus-reffed-article-number))
11286 (set-buffer gnus-summary-buffer)
11287 (decf gnus-reffed-article-number)
11288 (gnus-remove-header (mail-header-number header))
11289 (push header gnus-newsgroup-headers)
11290 (setq gnus-current-headers header)
11291 (push (mail-header-number header) gnus-newsgroup-limit)))
11294 (defun gnus-remove-header (number)
11295 "Remove header NUMBER from `gnus-newsgroup-headers'."
11296 (if (and gnus-newsgroup-headers
11297 (= number (mail-header-number (car gnus-newsgroup-headers))))
11298 (pop gnus-newsgroup-headers)
11299 (let ((headers gnus-newsgroup-headers))
11300 (while (and (cdr headers)
11301 (not (= number (mail-header-number (cadr headers)))))
11303 (when (cdr headers)
11304 (setcdr headers (cddr headers))))))
11307 ;;; summary highlights
11310 (defun gnus-highlight-selected-summary ()
11311 "Highlight selected article in summary buffer."
11312 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11313 (when gnus-summary-selected-face
11315 (let* ((beg (point-at-bol))
11316 (end (point-at-eol))
11317 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11318 (from (if (get-text-property beg gnus-mouse-face-prop)
11320 (or (next-single-property-change
11321 beg gnus-mouse-face-prop nil end)
11326 (or (next-single-property-change
11327 from gnus-mouse-face-prop nil end)
11329 ;; If no mouse-face prop on line we will have to = from = end,
11330 ;; so we highlight the entire line instead.
11331 (when (= (+ to 2) from)
11334 (if gnus-newsgroup-selected-overlay
11335 ;; Move old overlay.
11337 gnus-newsgroup-selected-overlay from to (current-buffer))
11338 ;; Create new overlay.
11340 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11341 'face gnus-summary-selected-face))))))
11343 (defvar gnus-summary-highlight-line-cached nil)
11344 (defvar gnus-summary-highlight-line-trigger nil)
11346 (defun gnus-summary-highlight-line-0 ()
11347 (if (and (eq gnus-summary-highlight-line-trigger
11348 gnus-summary-highlight)
11349 gnus-summary-highlight-line-cached)
11350 gnus-summary-highlight-line-cached
11351 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11352 gnus-summary-highlight-line-cached
11353 (let* ((cond (list 'cond))
11355 (list gnus-summary-highlight))
11357 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11361 (gnus-byte-compile (list 'lambda nil cond))))))
11363 (defun gnus-summary-highlight-line ()
11364 "Highlight current line according to `gnus-summary-highlight'."
11365 (let* ((beg (point-at-bol))
11366 (article (or (gnus-summary-article-number) gnus-current-article))
11367 (score (or (cdr (assq article
11368 gnus-newsgroup-scored))
11369 gnus-summary-default-score 0))
11370 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11371 (inhibit-read-only t)
11372 (default gnus-summary-default-score)
11373 (default-high gnus-summary-default-high-score)
11374 (default-low gnus-summary-default-low-score)
11375 (uncached (and gnus-summary-use-undownloaded-faces
11376 (memq article gnus-newsgroup-undownloaded)
11377 (not (memq article gnus-newsgroup-cached)))))
11378 (let ((face (funcall (gnus-summary-highlight-line-0))))
11379 (unless (eq face (get-text-property beg 'face))
11380 (gnus-put-text-property-excluding-characters-with-faces
11381 beg (point-at-eol) 'face
11382 (setq face (if (boundp face) (symbol-value face) face)))
11383 (when gnus-summary-highlight-line-function
11384 (funcall gnus-summary-highlight-line-function article face))))))
11386 (defun gnus-update-read-articles (group unread &optional compute)
11387 "Update the list of read articles in GROUP.
11388 UNREAD is a sorted list."
11389 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11390 (info (gnus-get-info group))
11393 (if (or (not info) (not active))
11394 ;; There is no info on this group if it was, in fact,
11395 ;; killed. Gnus stores no information on killed groups, so
11396 ;; there's nothing to be done.
11397 ;; One could store the information somewhere temporarily,
11398 ;; perhaps... Hmmm...
11400 ;; Remove any negative articles numbers.
11401 (while (and unread (< (car unread) 0))
11402 (setq unread (cdr unread)))
11403 ;; Remove any expired article numbers
11404 (while (and unread (< (car unread) (car active)))
11405 (setq unread (cdr unread)))
11406 ;; Compute the ranges of read articles by looking at the list of
11407 ;; unread articles.
11409 (when (/= (car unread) prev)
11410 (push (if (= prev (1- (car unread))) prev
11411 (cons prev (1- (car unread))))
11413 (setq prev (1+ (car unread)))
11414 (setq unread (cdr unread)))
11415 (when (<= prev (cdr active))
11416 (push (cons prev (cdr active)) read))
11417 (setq read (if (> (length read) 1) (nreverse read) read))
11422 ;; Propagate the read marks to the backend.
11423 (when (gnus-check-backend-function 'request-set-mark group)
11424 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11425 (add (gnus-remove-from-range read (gnus-info-read info))))
11427 (unless (gnus-check-group group)
11428 (error "Can't open server for %s" group))
11429 (gnus-request-set-mark
11430 group (delq nil (list (if add (list add 'add '(read)))
11431 (if del (list del 'del '(read))))))
11433 `(gnus-request-set-mark
11436 (if del (list del 'add '(read)))
11437 (if add (list add 'del '(read))))))))))
11438 (set-buffer gnus-group-buffer)
11439 (gnus-undo-register
11441 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11442 (gnus-info-set-read ',info ',(gnus-info-read info))
11443 (gnus-get-unread-articles-in-group ',info
11444 (gnus-active ,group))
11445 (gnus-group-update-group ,group t)
11447 ;; Enter this list into the group info.
11448 (gnus-info-set-read info read)
11449 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11450 (gnus-get-unread-articles-in-group info (gnus-active group))
11453 (defun gnus-offer-save-summaries ()
11454 "Offer to save all active summary buffers."
11456 ;; Go through all buffers and find all summaries.
11457 (dolist (buffer (buffer-list))
11458 (when (and (setq buffer (buffer-name buffer))
11459 (string-match "Summary" buffer)
11460 (with-current-buffer buffer
11461 ;; We check that this is, indeed, a summary buffer.
11462 (and (eq major-mode 'gnus-summary-mode)
11463 ;; Also make sure this isn't bogus.
11464 gnus-newsgroup-prepared
11465 ;; Also make sure that this isn't a
11466 ;; dead summary buffer.
11467 (not gnus-dead-summary-mode))))
11468 (push buffer buffers)))
11469 ;; Go through all these summary buffers and offer to save them.
11473 "Update summary buffer %s? "
11475 (switch-to-buffer buf)
11476 (gnus-summary-exit))
11479 (defun gnus-summary-setup-default-charset ()
11480 "Setup newsgroup default charset."
11481 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11482 (setq gnus-newsgroup-charset nil)
11483 (let* ((ignored-charsets
11484 (or gnus-newsgroup-ephemeral-ignored-charsets
11486 (and gnus-newsgroup-name
11487 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11488 gnus-newsgroup-ignored-charsets))))
11489 (setq gnus-newsgroup-charset
11490 (or gnus-newsgroup-ephemeral-charset
11491 (and gnus-newsgroup-name
11492 (gnus-parameter-charset gnus-newsgroup-name))
11493 gnus-default-charset))
11494 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11495 ignored-charsets))))
11501 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11502 "Display the current article buffer fully MIME-buttonized.
11503 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11504 treated as multipart/mixed."
11506 (require 'gnus-art)
11507 (let ((gnus-unbuttonized-mime-types nil)
11508 (gnus-mime-display-multipart-as-mixed show-all-parts))
11509 (gnus-summary-show-article)))
11511 (defun gnus-summary-repair-multipart (article)
11512 "Add a Content-Type header to a multipart article without one."
11513 (interactive (list (gnus-summary-article-number)))
11514 (gnus-with-article article
11515 (message-narrow-to-head)
11516 (message-remove-header "Mime-Version")
11517 (goto-char (point-max))
11518 (insert "Mime-Version: 1.0\n")
11520 (when (search-forward "\n--" nil t)
11521 (let ((separator (buffer-substring (point) (point-at-eol))))
11522 (message-narrow-to-head)
11523 (message-remove-header "Content-Type")
11524 (goto-char (point-max))
11525 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11528 (let (gnus-mark-article-hook)
11529 (gnus-summary-select-article t t nil article)))
11531 (defun gnus-summary-toggle-display-buttonized ()
11532 "Toggle the buttonizing of the article buffer."
11534 (require 'gnus-art)
11535 (if (setq gnus-inhibit-mime-unbuttonizing
11536 (not gnus-inhibit-mime-unbuttonizing))
11537 (let ((gnus-unbuttonized-mime-types nil))
11538 (gnus-summary-show-article))
11539 (gnus-summary-show-article)))
11542 ;;; Generic summary marking commands
11545 (defvar gnus-summary-marking-alist
11546 '((read gnus-del-mark "d")
11547 (unread gnus-unread-mark "u")
11548 (ticked gnus-ticked-mark "!")
11549 (dormant gnus-dormant-mark "?")
11550 (expirable gnus-expirable-mark "e"))
11551 "An alist of names/marks/keystrokes.")
11553 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11554 (defvar gnus-summary-mark-map)
11556 (defun gnus-summary-make-all-marking-commands ()
11557 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11558 (dolist (elem gnus-summary-marking-alist)
11559 (apply 'gnus-summary-make-marking-command elem)))
11561 (defun gnus-summary-make-marking-command (name mark keystroke)
11562 (let ((map (make-sparse-keymap)))
11563 (define-key gnus-summary-generic-mark-map keystroke map)
11564 (dolist (lway `((next "next" next nil "n")
11565 (next-unread "next unread" next t "N")
11566 (prev "previous" prev nil "p")
11567 (prev-unread "previous unread" prev t "P")
11568 (nomove "" nil nil ,keystroke)))
11569 (let ((func (gnus-summary-make-marking-command-1
11570 mark (car lway) lway name)))
11571 (setq func (eval func))
11572 (define-key map (nth 4 lway) func)))))
11574 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11576 (format "gnus-summary-put-mark-as-%s%s"
11577 name (if (eq way 'nomove)
11579 (concat "-" (symbol-name way)))))
11582 "Mark the current article as %s%s.
11583 If N, the prefix, then repeat N times.
11584 If N is negative, move in reverse order.
11585 The difference between N and the actual number of articles marked is
11589 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11591 (defun gnus-summary-generic-mark (n mark move unread)
11592 "Mark N articles with MARK."
11593 (unless (eq major-mode 'gnus-summary-mode)
11594 (error "This command can only be used in the summary buffer"))
11595 (gnus-summary-show-thread)
11598 ((eq move 'next) 1)
11599 ((eq move 'prev) -1)
11601 (if (zerop nummove)
11605 nummove (* -1 nummove))))
11606 (while (and (> n 0)
11607 (gnus-summary-mark-article nil mark)
11608 (zerop (gnus-summary-next-subject nummove unread t)))
11611 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11612 (gnus-summary-recenter)
11613 (gnus-summary-position-point)
11614 (gnus-set-mode-line 'summary)
11617 (defun gnus-summary-insert-articles (articles)
11618 (when (setq articles
11619 (gnus-sorted-difference articles
11620 (mapcar (lambda (h)
11621 (mail-header-number h))
11622 gnus-newsgroup-headers)))
11623 (setq gnus-newsgroup-headers
11625 gnus-newsgroup-headers
11626 (gnus-fetch-headers articles)
11627 'gnus-article-sort-by-number))
11628 ;; Suppress duplicates?
11629 (when gnus-suppress-duplicates
11630 (gnus-dup-suppress-articles))
11632 ;; We might want to build some more threads first.
11633 (when (and gnus-fetch-old-headers
11634 (eq gnus-headers-retrieved-by 'nov))
11635 (if (eq gnus-fetch-old-headers 'invisible)
11636 (gnus-build-all-threads)
11637 (gnus-build-old-threads)))
11638 ;; Let the Gnus agent mark articles as read.
11640 (gnus-agent-get-undownloaded-list))
11641 ;; Remove list identifiers from subject
11642 (when gnus-list-identifiers
11643 (gnus-summary-remove-list-identifiers))
11644 ;; First and last article in this newsgroup.
11645 (when gnus-newsgroup-headers
11646 (setq gnus-newsgroup-begin
11647 (mail-header-number (car gnus-newsgroup-headers))
11649 (mail-header-number
11650 (gnus-last-element gnus-newsgroup-headers))))
11651 (when gnus-use-scoring
11652 (gnus-possibly-score-headers))))
11654 (defun gnus-summary-insert-old-articles (&optional all)
11655 "Insert all old articles in this group.
11656 If ALL is non-nil, already read articles become readable.
11657 If ALL is a number, fetch this number of articles."
11660 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11663 ;; Some nntp servers lie about their active range. When
11664 ;; this happens, the active range can be in the millions.
11665 ;; Use a compressed range to avoid creating a huge list.
11666 (gnus-range-difference (list gnus-newsgroup-active) old))
11667 (setq len (gnus-range-length older))
11672 (let ((older-range (nreverse older)))
11676 (let* ((r (pop older-range))
11677 (min (if (numberp r) r (car r)))
11678 (max (if (numberp r) r (cdr r))))
11679 (while (and (<= min max)
11684 (setq older (gnus-uncompress-range older))))
11686 (setq older (gnus-uncompress-range older)))
11688 (when (and (numberp gnus-large-newsgroup)
11689 (> len gnus-large-newsgroup))
11690 (let* ((cursor-in-echo-area nil)
11691 (initial (gnus-parameter-large-newsgroup-initial
11692 gnus-newsgroup-name))
11696 "How many articles from %s (%s %d): "
11698 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11699 (if initial "max" "default")
11702 (cons (number-to-string initial)
11704 (unless (string-match "^[ \t]*$" input)
11705 (setq all (string-to-number input))
11707 (let ((older-range (nreverse older)))
11711 (let* ((r (pop older-range))
11712 (min (if (numberp r) r (car r)))
11713 (max (if (numberp r) r (cdr r))))
11714 (while (and (<= min max)
11718 max (1- max))))))))))
11719 (setq older (gnus-uncompress-range older))))
11721 (message "No old news.")
11722 (gnus-summary-insert-articles older)
11723 (gnus-summary-limit (gnus-sorted-nunion old older))))
11724 (gnus-summary-position-point)))
11726 (defun gnus-summary-insert-new-articles ()
11727 "Insert all new articles in this group."
11730 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11731 (old-active gnus-newsgroup-active)
11732 (nnmail-fetched-sources (list t))
11734 (setq gnus-newsgroup-active
11735 (gnus-activate-group gnus-newsgroup-name 'scan))
11736 (setq i (cdr gnus-newsgroup-active))
11737 (while (> i (cdr old-active))
11741 (message "No gnus is bad news")
11742 (gnus-summary-insert-articles new)
11743 (setq gnus-newsgroup-unreads
11744 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11745 (gnus-summary-limit (gnus-sorted-nunion old new))))
11746 (gnus-summary-position-point)))
11748 (gnus-summary-make-all-marking-commands)
11750 (gnus-ems-redefine)
11752 (provide 'gnus-sum)
11754 (run-hooks 'gnus-sum-load-hook)
11756 ;; Local Variables:
11757 ;; coding: iso-8859-1
11760 ;;; gnus-sum.el ends here