1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
32 (defvar tool-bar-mode))
45 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
46 (autoload 'gnus-cache-write-active "gnus-cache")
47 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
48 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
49 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
50 (autoload 'mm-uu-dissect "mm-uu")
51 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
52 "Deuglify broken Outlook (Express) articles and redisplay."
54 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
55 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
56 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
58 (defcustom gnus-kill-summary-on-exit t
59 "*If non-nil, kill the summary buffer when you exit from it.
60 If nil, the summary will become a \"*Dead Summary*\" buffer, and
61 it will be killed sometime later."
62 :group 'gnus-summary-exit
65 (defcustom gnus-fetch-old-headers nil
66 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
67 If an unread article in the group refers to an older, already
68 read (or just marked as read) article, the old article will not
69 normally be displayed in the Summary buffer. If this variable is
70 t, Gnus will attempt to grab the headers to the old articles, and
71 thereby build complete threads. If it has the value `some', all
72 old headers will be fetched but only enough headers to connect
73 otherwise loose threads will be displayed. This variable can
74 also be a number. In that case, no more than that number of old
75 headers will be fetched. If it has the value `invisible', all
76 old headers will be fetched, but none will be displayed.
78 The server has to support NOV for any of this to work.
80 This feature can seriously impact performance it ignores all
81 locally cached header entries."
83 :type '(choice (const :tag "off" nil)
88 (sexp :menu-tag "other" t)))
90 (defcustom gnus-refer-thread-limit 200
91 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
92 If t, fetch all the available old headers."
95 (sexp :menu-tag "other" t)))
97 (defcustom gnus-summary-make-false-root 'adopt
98 "*nil means that Gnus won't gather loose threads.
99 If the root of a thread has expired or been read in a previous
100 session, the information necessary to build a complete thread has been
101 lost. Instead of having many small sub-threads from this original thread
102 scattered all over the summary buffer, Gnus can gather them.
104 If non-nil, Gnus will try to gather all loose sub-threads from an
105 original thread into one large thread.
107 If this variable is non-nil, it should be one of `none', `adopt',
110 If this variable is `none', Gnus will not make a false root, but just
111 present the sub-threads after another.
112 If this variable is `dummy', Gnus will create a dummy root that will
113 have all the sub-threads as children.
114 If this variable is `adopt', Gnus will make one of the \"children\"
115 the parent and mark all the step-children as such.
116 If this variable is `empty', the \"children\" are printed with empty
117 subject fields. (Or rather, they will be printed with a string
118 given by the `gnus-summary-same-subject' variable.)"
120 :type '(choice (const :tag "off" nil)
126 (defcustom gnus-summary-make-false-root-always nil
127 "Always make a false dummy root."
132 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
133 "*A regexp to match subjects to be excluded from loose thread gathering.
134 As loose thread gathering is done on subjects only, that means that
135 there can be many false gatherings performed. By rooting out certain
136 common subjects, gathering might become saner."
140 (defcustom gnus-summary-gather-subject-limit nil
141 "*Maximum length of subject comparisons when gathering loose threads.
142 Use nil to compare full subjects. Setting this variable to a low
143 number will help gather threads that have been corrupted by
144 newsreaders chopping off subject lines, but it might also mean that
145 unrelated articles that have subject that happen to begin with the
146 same few characters will be incorrectly gathered.
148 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
151 :type '(choice (const :tag "off" nil)
153 (sexp :menu-tag "on" t)))
155 (defcustom gnus-simplify-subject-functions nil
156 "List of functions taking a string argument that simplify subjects.
157 The functions are applied recursively.
159 Useful functions to put in this list include:
160 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
161 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
163 :type '(repeat function))
165 (defcustom gnus-simplify-ignored-prefixes nil
166 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
168 :type '(choice (const :tag "off" nil)
171 (defcustom gnus-build-sparse-threads nil
172 "*If non-nil, fill in the gaps in threads.
173 If `some', only fill in the gaps that are needed to tie loose threads
174 together. If `more', fill in all leaf nodes that Gnus can find. If
175 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
177 :type '(choice (const :tag "off" nil)
180 (sexp :menu-tag "all" t)))
182 (defcustom gnus-summary-thread-gathering-function
183 'gnus-gather-threads-by-subject
184 "*Function used for gathering loose threads.
185 There are two pre-defined functions: `gnus-gather-threads-by-subject',
186 which only takes Subjects into consideration; and
187 `gnus-gather-threads-by-references', which compared the References
188 headers of the articles to find matches."
190 :type '(radio (function-item gnus-gather-threads-by-subject)
191 (function-item gnus-gather-threads-by-references)
192 (function :tag "other")))
194 (defcustom gnus-summary-same-subject ""
195 "*String indicating that the current article has the same subject as the previous.
196 This variable will only be used if the value of
197 `gnus-summary-make-false-root' is `empty'."
198 :group 'gnus-summary-format
201 (defcustom gnus-summary-goto-unread t
202 "*If t, many commands will go to the next unread article.
203 This applies to marking commands as well as other commands that
204 \"naturally\" select the next article, like, for instance, `SPC' at
205 the end of an article.
207 If nil, the marking commands do NOT go to the next unread article
208 \(they go to the next article instead). If `never', commands that
209 usually go to the next unread article, will go to the next article,
210 whether it is read or not."
211 :group 'gnus-summary-marks
212 :link '(custom-manual "(gnus)Setting Marks")
213 :type '(choice (const :tag "off" nil)
215 (sexp :menu-tag "on" t)))
217 (defcustom gnus-summary-default-score 0
218 "*Default article score level.
219 All scores generated by the score files will be added to this score.
220 If this variable is nil, scoring will be disabled."
221 :group 'gnus-score-default
222 :type '(choice (const :tag "disable")
225 (defcustom gnus-summary-default-high-score 0
226 "*Default threshold for a high scored article.
227 An article will be highlighted as high scored if its score is greater
230 :group 'gnus-score-default
233 (defcustom gnus-summary-default-low-score 0
234 "*Default threshold for a low scored article.
235 An article will be highlighted as low scored if its score is smaller
238 :group 'gnus-score-default
241 (defcustom gnus-summary-zcore-fuzz 0
242 "*Fuzziness factor for the zcore in the summary buffer.
243 Articles with scores closer than this to `gnus-summary-default-score'
245 :group 'gnus-summary-format
248 (defcustom gnus-simplify-subject-fuzzy-regexp nil
249 "*Strings to be removed when doing fuzzy matches.
250 This can either be a regular expression or list of regular expressions
251 that will be removed from subject strings if fuzzy subject
252 simplification is selected."
254 :type '(repeat regexp))
256 (defcustom gnus-show-threads t
257 "*If non-nil, display threads in summary mode."
261 (defcustom gnus-thread-hide-subtree nil
262 "*If non-nil, hide all threads initially.
263 This can be a predicate specifier which says which threads to hide.
264 If threads are hidden, you have to run the command
265 `gnus-summary-show-thread' by hand or select an article."
267 :type '(radio (sexp :format "Non-nil\n"
268 :match (lambda (widget value)
269 (not (or (consp value) (functionp value))))
272 (sexp :tag "Predicate specifier")))
274 (defcustom gnus-thread-hide-killed t
275 "*If non-nil, hide killed threads automatically."
279 (defcustom gnus-thread-ignore-subject t
280 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
281 If nil, articles that have different subjects from their parents will
282 start separate threads."
286 (defcustom gnus-thread-operation-ignore-subject t
287 "*If non-nil, subjects will be ignored when doing thread commands.
288 This affects commands like `gnus-summary-kill-thread' and
289 `gnus-summary-lower-thread'.
291 If this variable is nil, articles in the same thread with different
292 subjects will not be included in the operation in question. If this
293 variable is `fuzzy', only articles that have subjects that are fuzzily
294 equal will be included."
296 :type '(choice (const :tag "off" nil)
300 (defcustom gnus-thread-indent-level 4
301 "*Number that says how much each sub-thread should be indented."
305 (defcustom gnus-auto-extend-newsgroup t
306 "*If non-nil, extend newsgroup forward and backward when requested."
307 :group 'gnus-summary-choose
310 (defcustom gnus-auto-select-first t
311 "*If non-nil, select the article under point.
312 Which article this is is controlled by the `gnus-auto-select-subject'
315 If you want to prevent automatic selection of articles in some
316 newsgroups, set the variable to nil in `gnus-select-group-hook'."
317 :group 'gnus-group-select
318 :type '(choice (const :tag "none" nil)
319 (sexp :menu-tag "first" t)))
321 (defcustom gnus-auto-select-subject 'unread
322 "*Says what subject to place under point when entering a group.
324 This variable can either be the symbols `first' (place point on the
325 first subject), `unread' (place point on the subject line of the first
326 unread article), `best' (place point on the subject line of the
327 higest-scored article), `unseen' (place point on the subject line of
328 the first unseen article), `unseen-or-unread' (place point on the subject
329 line of the first unseen article or, if all article have been seen, on the
330 subject line of the first unread article), or a function to be called to
331 place point on some subject line."
333 :group 'gnus-group-select
334 :type '(choice (const best)
338 (const unseen-or-unread)))
340 (defcustom gnus-auto-select-next t
341 "*If non-nil, offer to go to the next group from the end of the previous.
342 If the value is t and the next newsgroup is empty, Gnus will exit
343 summary mode and go back to group mode. If the value is neither nil
344 nor t, Gnus will select the following unread newsgroup. In
345 particular, if the value is the symbol `quietly', the next unread
346 newsgroup will be selected without any confirmation, and if it is
347 `almost-quietly', the next group will be selected without any
348 confirmation if you are located on the last article in the group.
349 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
350 will go to the next group without confirmation."
351 :group 'gnus-summary-maneuvering
352 :type '(choice (const :tag "off" nil)
354 (const almost-quietly)
355 (const slightly-quietly)
356 (sexp :menu-tag "on" t)))
358 (defcustom gnus-auto-select-same nil
359 "*If non-nil, select the next article with the same subject.
360 If there are no more articles with the same subject, go to
361 the first unread article."
362 :group 'gnus-summary-maneuvering
365 (defcustom gnus-auto-goto-ignores 'unfetched
366 "*Says how to handle unfetched articles when maneuvering.
368 This variable can either be the symbols nil (maneuver to any
369 article), `undownloaded' (maneuvering while unplugged ignores articles
370 that have not been fetched), `always-undownloaded' (maneuvering always
371 ignores articles that have not been fetched), `unfetched' (maneuvering
372 ignores articles whose headers have not been fetched).
374 NOTE: The list of unfetched articles will always be nil when plugged
375 and, when unplugged, a subset of the undownloaded article list."
377 :group 'gnus-summary-maneuvering
378 :type '(choice (const :tag "None" nil)
379 (const :tag "Undownloaded when unplugged" undownloaded)
380 (const :tag "Undownloaded" always-undownloaded)
381 (const :tag "Unfetched" unfetched)))
383 (defcustom gnus-summary-check-current nil
384 "*If non-nil, consider the current article when moving.
385 The \"unread\" movement commands will stay on the same line if the
386 current article is unread."
387 :group 'gnus-summary-maneuvering
390 (defcustom gnus-auto-center-summary 2
391 "*If non-nil, always center the current summary buffer.
392 In particular, if `vertical' do only vertical recentering. If non-nil
393 and non-`vertical', do both horizontal and vertical recentering."
394 :group 'gnus-summary-maneuvering
395 :type '(choice (const :tag "none" nil)
397 (integer :tag "height")
398 (sexp :menu-tag "both" t)))
400 (defvar gnus-auto-center-group t
401 "*If non-nil, always center the group buffer.")
403 (defcustom gnus-show-all-headers nil
404 "*If non-nil, don't hide any headers."
405 :group 'gnus-article-hiding
406 :group 'gnus-article-headers
409 (defcustom gnus-summary-ignore-duplicates nil
410 "*If non-nil, ignore articles with identical Message-ID headers."
414 (defcustom gnus-single-article-buffer t
415 "*If non-nil, display all articles in the same buffer.
416 If nil, each group will get its own article buffer."
417 :group 'gnus-article-various
420 (defcustom gnus-break-pages t
421 "*If non-nil, do page breaking on articles.
422 The page delimiter is specified by the `gnus-page-delimiter'
424 :group 'gnus-article-various
427 (defcustom gnus-move-split-methods nil
428 "*Variable used to suggest where articles are to be moved to.
429 It uses the same syntax as the `gnus-split-methods' variable.
430 However, whereas `gnus-split-methods' specifies file names as targets,
431 this variable specifies group names."
432 :group 'gnus-summary-mail
433 :type '(repeat (choice (list :value (fun) function)
434 (cons :value ("" "") regexp (repeat string))
437 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
438 "Function used to compute default prefix for article move/copy/etc prompts.
439 The function should take one argument, a group name, and return a
440 string with the suggested prefix."
441 :group 'gnus-summary-mail
444 ;; FIXME: Although the custom type is `character' for the following variables,
445 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
447 (defcustom gnus-unread-mark ? ;Whitespace
448 "*Mark used for unread articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-ticked-mark ?!
453 "*Mark used for ticked articles."
454 :group 'gnus-summary-marks
457 (defcustom gnus-dormant-mark ??
458 "*Mark used for dormant articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-del-mark ?r
463 "*Mark used for del'd articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-read-mark ?R
468 "*Mark used for read articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-expirable-mark ?E
473 "*Mark used for expirable articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-killed-mark ?K
478 "*Mark used for killed articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-spam-mark ?$
483 "*Mark used for spam articles."
485 :group 'gnus-summary-marks
488 (defcustom gnus-souped-mark ?F
489 "*Mark used for souped articles."
490 :group 'gnus-summary-marks
493 (defcustom gnus-kill-file-mark ?X
494 "*Mark used for articles killed by kill files."
495 :group 'gnus-summary-marks
498 (defcustom gnus-low-score-mark ?Y
499 "*Mark used for articles with a low score."
500 :group 'gnus-summary-marks
503 (defcustom gnus-catchup-mark ?C
504 "*Mark used for articles that are caught up."
505 :group 'gnus-summary-marks
508 (defcustom gnus-replied-mark ?A
509 "*Mark used for articles that have been replied to."
510 :group 'gnus-summary-marks
513 (defcustom gnus-forwarded-mark ?F
514 "*Mark used for articles that have been forwarded."
516 :group 'gnus-summary-marks
519 (defcustom gnus-recent-mark ?N
520 "*Mark used for articles that are recent."
522 :group 'gnus-summary-marks
525 (defcustom gnus-cached-mark ?*
526 "*Mark used for articles that are in the cache."
527 :group 'gnus-summary-marks
530 (defcustom gnus-saved-mark ?S
531 "*Mark used for articles that have been saved."
532 :group 'gnus-summary-marks
535 (defcustom gnus-unseen-mark ?.
536 "*Mark used for articles that haven't been seen."
538 :group 'gnus-summary-marks
541 (defcustom gnus-no-mark ? ;Whitespace
542 "*Mark used for articles that have no other secondary mark."
544 :group 'gnus-summary-marks
547 (defcustom gnus-ancient-mark ?O
548 "*Mark used for ancient articles."
549 :group 'gnus-summary-marks
552 (defcustom gnus-sparse-mark ?Q
553 "*Mark used for sparsely reffed articles."
554 :group 'gnus-summary-marks
557 (defcustom gnus-canceled-mark ?G
558 "*Mark used for canceled articles."
559 :group 'gnus-summary-marks
562 (defcustom gnus-duplicate-mark ?M
563 "*Mark used for duplicate articles."
564 :group 'gnus-summary-marks
567 (defcustom gnus-undownloaded-mark ?-
568 "*Mark used for articles that weren't downloaded."
570 :group 'gnus-summary-marks
573 (defcustom gnus-downloaded-mark ?+
574 "*Mark used for articles that were downloaded."
575 :group 'gnus-summary-marks
578 (defcustom gnus-downloadable-mark ?%
579 "*Mark used for articles that are to be downloaded."
580 :group 'gnus-summary-marks
583 (defcustom gnus-unsendable-mark ?=
584 "*Mark used for articles that won't be sent."
585 :group 'gnus-summary-marks
588 (defcustom gnus-score-over-mark ?+
589 "*Score mark used for articles with high scores."
590 :group 'gnus-summary-marks
593 (defcustom gnus-score-below-mark ?-
594 "*Score mark used for articles with low scores."
595 :group 'gnus-summary-marks
598 (defcustom gnus-empty-thread-mark ? ;Whitespace
599 "*There is no thread under the article."
600 :group 'gnus-summary-marks
603 (defcustom gnus-not-empty-thread-mark ?=
604 "*There is a thread under the article."
605 :group 'gnus-summary-marks
608 (defcustom gnus-view-pseudo-asynchronously nil
609 "*If non-nil, Gnus will view pseudo-articles asynchronously."
610 :group 'gnus-extract-view
613 (defcustom gnus-auto-expirable-marks
614 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
615 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
616 gnus-souped-mark gnus-duplicate-mark)
617 "*The list of marks converted into expiration if a group is auto-expirable."
620 :type '(repeat character))
622 (defcustom gnus-inhibit-user-auto-expire t
623 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
628 (defcustom gnus-view-pseudos nil
629 "*If `automatic', pseudo-articles will be viewed automatically.
630 If `not-confirm', pseudos will be viewed automatically, and the user
631 will not be asked to confirm the command."
632 :group 'gnus-extract-view
633 :type '(choice (const :tag "off" nil)
635 (const not-confirm)))
637 (defcustom gnus-view-pseudos-separately t
638 "*If non-nil, one pseudo-article will be created for each file to be viewed.
639 If nil, all files that use the same viewing command will be given as a
640 list of parameters to that command."
641 :group 'gnus-extract-view
644 (defcustom gnus-insert-pseudo-articles t
645 "*If non-nil, insert pseudo-articles when decoding articles."
646 :group 'gnus-extract-view
649 (defcustom gnus-summary-dummy-line-format
651 "*The format specification for the dummy roots in the summary buffer.
652 It works along the same lines as a normal formatting string,
653 with some simple extensions.
657 General format specifiers can also be used.
658 See `(gnus)Formatting Variables'."
659 :link '(custom-manual "(gnus)Formatting Variables")
660 :group 'gnus-threading
663 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
664 "*The format specification for the summary mode line.
665 It works along the same lines as a normal formatting string,
666 with some simple extensions:
669 %p Unprefixed group name
670 %A Current article number
671 %z Current article score
673 %U Number of unread articles in the group
674 %e Number of unselected articles in the group
675 %Z A string with unread/unselected article counts
676 %g Shortish group name
677 %S Subject of the current article
679 %s Current score file name
680 %d Number of dormant articles
681 %r Number of articles that have been marked as read in this session
682 %E Number of articles expunged by the score files"
683 :group 'gnus-summary-format
686 (defcustom gnus-list-identifiers nil
687 "Regexp that matches list identifiers to be removed from subject.
688 This can also be a list of regexps."
690 :group 'gnus-summary-format
691 :group 'gnus-article-hiding
692 :type '(choice (const :tag "none" nil)
694 (repeat :value (".*") regexp)))
696 (defcustom gnus-summary-mark-below 0
697 "*Mark all articles with a score below this variable as read.
698 This variable is local to each summary buffer and usually set by the
700 :group 'gnus-score-default
703 (defun gnus-widget-reversible-match (widget value)
704 "Ignoring WIDGET, convert VALUE to internal form.
705 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
709 (eq (length value) 2)
710 (eq (nth 0 value) 'not)
711 (symbolp (nth 1 value)))))
713 (defun gnus-widget-reversible-to-internal (widget value)
714 "Ignoring WIDGET, convert VALUE to internal form.
715 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
716 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
720 (list (nth 1 value) t)))
722 (defun gnus-widget-reversible-to-external (widget value)
723 "Ignoring WIDGET, convert VALUE to external form.
724 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
725 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
728 (list 'not (nth 0 value))
731 (define-widget 'gnus-widget-reversible 'group
732 "A `group' that convert values."
733 :match 'gnus-widget-reversible-match
734 :value-to-internal 'gnus-widget-reversible-to-internal
735 :value-to-external 'gnus-widget-reversible-to-external)
737 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
738 "*List of functions used for sorting articles in the summary buffer.
740 Each function takes two articles and returns non-nil if the first
741 article should be sorted before the other. If you use more than one
742 function, the primary sort function should be the last. You should
743 probably always include `gnus-article-sort-by-number' in the list of
744 sorting functions -- preferably first. Also note that sorting by date
745 is often much slower than sorting by number, and the sorting order is
746 very similar. (Sorting by date means sorting by the time the message
747 was sent, sorting by number means sorting by arrival time.)
749 Each item can also be a list `(not F)' where F is a function;
750 this reverses the sort order.
752 Ready-made functions include `gnus-article-sort-by-number',
753 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
754 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
755 and `gnus-article-sort-by-score'.
757 When threading is turned on, the variable `gnus-thread-sort-functions'
758 controls how articles are sorted."
759 :group 'gnus-summary-sort
760 :type '(repeat (gnus-widget-reversible
761 (choice (function-item gnus-article-sort-by-number)
762 (function-item gnus-article-sort-by-author)
763 (function-item gnus-article-sort-by-subject)
764 (function-item gnus-article-sort-by-date)
765 (function-item gnus-article-sort-by-score)
766 (function-item gnus-article-sort-by-random)
767 (function :tag "other"))
768 (boolean :tag "Reverse order"))))
771 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
772 "*List of functions used for sorting threads in the summary buffer.
773 By default, threads are sorted by article number.
775 Each function takes two threads and returns non-nil if the first
776 thread should be sorted before the other. If you use more than one
777 function, the primary sort function should be the last. You should
778 probably always include `gnus-thread-sort-by-number' in the list of
779 sorting functions -- preferably first. Also note that sorting by date
780 is often much slower than sorting by number, and the sorting order is
781 very similar. (Sorting by date means sorting by the time the message
782 was sent, sorting by number means sorting by arrival time.)
784 Each list item can also be a list `(not F)' where F is a
785 function; this specifies reversed sort order.
787 Ready-made functions include `gnus-thread-sort-by-number',
788 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
789 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
790 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
791 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
792 and `gnus-thread-sort-by-total-score' (see
793 `gnus-thread-score-function').
795 When threading is turned off, the variable
796 `gnus-article-sort-functions' controls how articles are sorted."
797 :group 'gnus-summary-sort
799 (gnus-widget-reversible
800 (choice (function-item gnus-thread-sort-by-number)
801 (function-item gnus-thread-sort-by-author)
802 (function-item gnus-thread-sort-by-recipient)
803 (function-item gnus-thread-sort-by-subject)
804 (function-item gnus-thread-sort-by-date)
805 (function-item gnus-thread-sort-by-score)
806 (function-item gnus-thread-sort-by-most-recent-number)
807 (function-item gnus-thread-sort-by-most-recent-date)
808 (function-item gnus-thread-sort-by-random)
809 (function-item gnus-thread-sort-by-total-score)
810 (function :tag "other"))
811 (boolean :tag "Reverse order"))))
813 (defcustom gnus-thread-score-function '+
814 "*Function used for calculating the total score of a thread.
816 The function is called with the scores of the article and each
817 subthread and should then return the score of the thread.
819 Some functions you can use are `+', `max', or `min'."
820 :group 'gnus-summary-sort
823 (defcustom gnus-summary-expunge-below nil
824 "All articles that have a score less than this variable will be expunged.
825 This variable is local to the summary buffers."
826 :group 'gnus-score-default
827 :type '(choice (const :tag "off" nil)
830 (defcustom gnus-thread-expunge-below nil
831 "All threads that have a total score less than this variable will be expunged.
832 See `gnus-thread-score-function' for en explanation of what a
835 This variable is local to the summary buffers."
836 :group 'gnus-threading
837 :group 'gnus-score-default
838 :type '(choice (const :tag "off" nil)
841 (defcustom gnus-summary-mode-hook nil
842 "*A hook for Gnus summary mode.
843 This hook is run before any variables are set in the summary buffer."
844 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
845 :group 'gnus-summary-various
848 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
849 (when (featurep 'xemacs)
850 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
851 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
852 (add-hook 'gnus-summary-mode-hook
853 'gnus-xmas-switch-horizontal-scrollbar-off))
855 (defcustom gnus-summary-menu-hook nil
856 "*Hook run after the creation of the summary mode menu."
857 :group 'gnus-summary-visual
860 (defcustom gnus-summary-exit-hook nil
861 "*A hook called on exit from the summary buffer.
862 It will be called with point in the group buffer."
863 :group 'gnus-summary-exit
866 (defcustom gnus-summary-prepare-hook nil
867 "*A hook called after the summary buffer has been generated.
868 If you want to modify the summary buffer, you can use this hook."
869 :group 'gnus-summary-various
872 (defcustom gnus-summary-prepared-hook nil
873 "*A hook called as the last thing after the summary buffer has been generated."
874 :group 'gnus-summary-various
877 (defcustom gnus-summary-generate-hook nil
878 "*A hook run just before generating the summary buffer.
879 This hook is commonly used to customize threading variables and the
881 :group 'gnus-summary-various
884 (defcustom gnus-select-group-hook nil
885 "*A hook called when a newsgroup is selected.
887 If you'd like to simplify subjects like the
888 `gnus-summary-next-same-subject' command does, you can use the
891 (add-hook gnus-select-group-hook
893 (mapcar (lambda (header)
894 (mail-header-set-subject
896 (gnus-simplify-subject
897 (mail-header-subject header) 're-only)))
898 gnus-newsgroup-headers)))"
899 :group 'gnus-group-select
902 (defcustom gnus-select-article-hook nil
903 "*A hook called when an article is selected."
904 :group 'gnus-summary-choose
905 :options '(gnus-agent-fetch-selected-article)
908 (defcustom gnus-visual-mark-article-hook
909 (list 'gnus-highlight-selected-summary)
910 "*Hook run after selecting an article in the summary buffer.
911 It is meant to be used for highlighting the article in some way. It
912 is not run if `gnus-visual' is nil."
913 :group 'gnus-summary-visual
916 (defcustom gnus-parse-headers-hook nil
917 "*A hook called before parsing the headers."
921 (defcustom gnus-exit-group-hook nil
922 "*A hook called when exiting summary mode.
923 This hook is not called from the non-updating exit commands like `Q'."
927 (defcustom gnus-summary-update-hook
928 (list 'gnus-summary-highlight-line)
929 "*A hook called when a summary line is changed.
930 The hook will not be called if `gnus-visual' is nil.
932 The default function `gnus-summary-highlight-line' will
933 highlight the line according to the `gnus-summary-highlight'
935 :group 'gnus-summary-visual
938 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
939 "*A hook called when an article is selected for the first time.
940 The hook is intended to mark an article as read (or unread)
941 automatically when it is selected."
942 :group 'gnus-summary-choose
945 (defcustom gnus-group-no-more-groups-hook nil
946 "*A hook run when returning to group mode having no more (unread) groups."
947 :group 'gnus-group-select
950 (defcustom gnus-ps-print-hook nil
951 "*A hook run before ps-printing something from Gnus."
955 (defcustom gnus-summary-article-move-hook nil
956 "*A hook called after an article is moved, copied, respooled, or crossposted."
961 (defcustom gnus-summary-article-delete-hook nil
962 "*A hook called after an article is deleted."
967 (defcustom gnus-summary-article-expire-hook nil
968 "*A hook called after an article is expired."
973 (defcustom gnus-summary-display-arrow
974 (and (fboundp 'display-graphic-p)
976 "*If non-nil, display an arrow highlighting the current article."
981 (defcustom gnus-summary-selected-face 'gnus-summary-selected
982 "Face used for highlighting the current article in the summary buffer."
983 :group 'gnus-summary-visual
986 (defvar gnus-tmp-downloaded nil)
988 (defcustom gnus-summary-highlight
989 '(((eq mark gnus-canceled-mark)
990 . gnus-summary-cancelled)
991 ((and uncached (> score default-high))
992 . gnus-summary-high-undownloaded)
993 ((and uncached (< score default-low))
994 . gnus-summary-low-undownloaded)
996 . gnus-summary-normal-undownloaded)
997 ((and (> score default-high)
998 (or (eq mark gnus-dormant-mark)
999 (eq mark gnus-ticked-mark)))
1000 . gnus-summary-high-ticked)
1001 ((and (< score default-low)
1002 (or (eq mark gnus-dormant-mark)
1003 (eq mark gnus-ticked-mark)))
1004 . gnus-summary-low-ticked)
1005 ((or (eq mark gnus-dormant-mark)
1006 (eq mark gnus-ticked-mark))
1007 . gnus-summary-normal-ticked)
1008 ((and (> score default-high) (eq mark gnus-ancient-mark))
1009 . gnus-summary-high-ancient)
1010 ((and (< score default-low) (eq mark gnus-ancient-mark))
1011 . gnus-summary-low-ancient)
1012 ((eq mark gnus-ancient-mark)
1013 . gnus-summary-normal-ancient)
1014 ((and (> score default-high) (eq mark gnus-unread-mark))
1015 . gnus-summary-high-unread)
1016 ((and (< score default-low) (eq mark gnus-unread-mark))
1017 . gnus-summary-low-unread)
1018 ((eq mark gnus-unread-mark)
1019 . gnus-summary-normal-unread)
1020 ((> score default-high)
1021 . gnus-summary-high-read)
1022 ((< score default-low)
1023 . gnus-summary-low-read)
1025 . gnus-summary-normal-read))
1026 "*Controls the highlighting of summary buffer lines.
1028 A list of (FORM . FACE) pairs. When deciding how a a particular
1029 summary line should be displayed, each form is evaluated. The content
1030 of the face field after the first true form is used. You can change
1031 how those summary lines are displayed, by editing the face field.
1033 You can use the following variables in the FORM field.
1035 score: The article's score
1036 default: The default article score.
1037 default-high: The default score for high scored articles.
1038 default-low: The default score for low scored articles.
1039 below: The score below which articles are automatically marked as read.
1040 mark: The article's mark.
1041 uncached: Non-nil if the article is uncached."
1042 :group 'gnus-summary-visual
1043 :type '(repeat (cons (sexp :tag "Form" nil)
1046 (defcustom gnus-alter-header-function nil
1047 "Function called to allow alteration of article header structures.
1048 The function is called with one parameter, the article header vector,
1049 which it may alter in any way."
1050 :type '(choice (const :tag "None" nil)
1052 :group 'gnus-summary)
1054 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1055 "Variable that says which function should be used to decode a string with encoded words.")
1057 (defcustom gnus-extra-headers '(To Newsgroups)
1058 "*Extra headers to parse."
1060 :group 'gnus-summary
1061 :type '(repeat symbol))
1063 (defcustom gnus-ignored-from-addresses
1064 (and user-mail-address
1065 (not (string= user-mail-address ""))
1066 (regexp-quote user-mail-address))
1067 "*Regexp of From headers that may be suppressed in favor of To headers."
1069 :group 'gnus-summary
1072 (defcustom gnus-summary-to-prefix "-> "
1073 "*String prefixed to the To field in the summary line when
1074 using `gnus-ignored-from-addresses'."
1076 :group 'gnus-summary
1079 (defcustom gnus-summary-newsgroup-prefix "=> "
1080 "*String prefixed to the Newsgroup field in the summary
1081 line when using `gnus-ignored-from-addresses'."
1083 :group 'gnus-summary
1086 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1087 "List of charsets that should be ignored.
1088 When these charsets are used in the \"charset\" parameter, the
1089 default charset will be used instead."
1091 :type '(repeat symbol)
1092 :group 'gnus-charset)
1094 (gnus-define-group-parameter
1098 "Return the ignored charsets of GROUP."
1099 :variable gnus-group-ignored-charsets-alist
1101 '(("alt\\.chinese\\.text" iso-8859-1))
1103 "Alist of regexps (to match group names) and charsets that should be ignored.
1104 When these charsets are used in the \"charset\" parameter, the
1105 default charset will be used instead."
1106 :variable-group gnus-charset
1107 :variable-type '(repeat (cons (regexp :tag "Group")
1109 :parameter-type '(choice :tag "Ignored charsets"
1112 :parameter-document "\
1113 List of charsets that should be ignored.
1115 When these charsets are used in the \"charset\" parameter, the
1116 default charset will be used instead.")
1118 (defcustom gnus-group-highlight-words-alist nil
1119 "Alist of group regexps and highlight regexps.
1120 This variable uses the same syntax as `gnus-emphasis-alist'."
1122 :type '(repeat (cons (regexp :tag "Group")
1123 (repeat (list (regexp :tag "Highlight regexp")
1124 (number :tag "Group for entire word" 0)
1125 (number :tag "Group for displayed part" 0)
1127 gnus-emphasis-highlight-words)))))
1128 :group 'gnus-summary-visual)
1130 (defcustom gnus-summary-show-article-charset-alist
1132 "Alist of number and charset.
1133 The article will be shown with the charset corresponding to the
1135 For example: ((1 . cn-gb-2312) (2 . big5))."
1137 :type '(repeat (cons (number :tag "Argument" 1)
1138 (symbol :tag "Charset")))
1139 :group 'gnus-charset)
1141 (defcustom gnus-preserve-marks t
1142 "Whether marks are preserved when moving, copying and respooling messages."
1145 :group 'gnus-summary-marks)
1147 (defcustom gnus-alter-articles-to-read-function nil
1148 "Function to be called to alter the list of articles to be selected."
1149 :type '(choice (const nil) function)
1150 :group 'gnus-summary)
1152 (defcustom gnus-orphan-score nil
1153 "*All orphans get this score added. Set in the score file."
1154 :group 'gnus-score-default
1155 :type '(choice (const nil)
1158 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1159 "*A regexp to match MIME parts when saving multiple parts of a
1160 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1161 This regexp will be used by default when prompting the user for which
1162 type of files to save."
1163 :group 'gnus-summary
1166 (defcustom gnus-read-all-available-headers nil
1167 "Whether Gnus should parse all headers made available to it.
1168 This is mostly relevant for slow back ends where the user may
1169 wish to widen the summary buffer to include all headers
1170 that were fetched. Say, for nnultimate groups."
1172 :group 'gnus-summary
1173 :type '(choice boolean regexp))
1175 (defcustom gnus-summary-muttprint-program "muttprint"
1176 "Command (and optional arguments) used to run Muttprint."
1178 :group 'gnus-summary
1181 (defcustom gnus-article-loose-mime t
1182 "If non-nil, don't require MIME-Version header.
1183 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1184 supply the MIME-Version header or deliberately strip it from the mail.
1185 If non-nil (the default), Gnus will treat some articles as MIME
1186 even if the MIME-Version header is missing."
1189 :group 'gnus-article-mime)
1191 (defcustom gnus-article-emulate-mime t
1192 "If non-nil, use MIME emulation for uuencode and the like.
1193 This means that Gnus will search message bodies for text that look
1194 like uuencoded bits, yEncoded bits, and so on, and present that using
1195 the normal Gnus MIME machinery."
1198 :group 'gnus-article-mime)
1200 ;;; Internal variables
1202 (defvar gnus-summary-display-cache nil)
1203 (defvar gnus-article-mime-handles nil)
1204 (defvar gnus-article-decoded-p nil)
1205 (defvar gnus-article-charset nil)
1206 (defvar gnus-article-ignored-charsets nil)
1207 (defvar gnus-scores-exclude-files nil)
1208 (defvar gnus-page-broken nil)
1210 (defvar gnus-original-article nil)
1211 (defvar gnus-article-internal-prepare-hook nil)
1212 (defvar gnus-newsgroup-process-stack nil)
1214 (defvar gnus-thread-indent-array nil)
1215 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1216 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1217 "Function called to sort the articles within a thread after it has been gathered together.")
1219 (defvar gnus-summary-save-parts-type-history nil)
1220 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1222 ;; Avoid highlighting in kill files.
1223 (defvar gnus-summary-inhibit-highlight nil)
1224 (defvar gnus-newsgroup-selected-overlay nil)
1225 (defvar gnus-inhibit-limiting nil)
1226 (defvar gnus-newsgroup-adaptive-score-file nil)
1227 (defvar gnus-current-score-file nil)
1228 (defvar gnus-current-move-group nil)
1229 (defvar gnus-current-copy-group nil)
1230 (defvar gnus-current-crosspost-group nil)
1231 (defvar gnus-newsgroup-display nil)
1233 (defvar gnus-newsgroup-dependencies nil)
1234 (defvar gnus-newsgroup-adaptive nil)
1235 (defvar gnus-summary-display-article-function nil)
1236 (defvar gnus-summary-highlight-line-function nil
1237 "Function called after highlighting a summary line.")
1239 (defvar gnus-summary-line-format-alist
1240 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1241 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1242 (?s gnus-tmp-subject-or-nil ?s)
1243 (?n gnus-tmp-name ?s)
1244 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1246 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1248 (?F gnus-tmp-from ?s)
1249 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1250 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1251 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1252 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1253 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1254 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1255 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1256 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1257 (?L gnus-tmp-lines ?s)
1258 (?O gnus-tmp-downloaded ?c)
1259 (?I gnus-tmp-indentation ?s)
1260 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1261 (?R gnus-tmp-replied ?c)
1262 (?\[ gnus-tmp-opening-bracket ?c)
1263 (?\] gnus-tmp-closing-bracket ?c)
1264 (?\> (make-string gnus-tmp-level ? ) ?s)
1265 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1266 (?i gnus-tmp-score ?d)
1267 (?z gnus-tmp-score-char ?c)
1268 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1269 (?U gnus-tmp-unread ?c)
1270 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1272 (?t (gnus-summary-number-of-articles-in-thread
1273 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1275 (?e (gnus-summary-number-of-articles-in-thread
1276 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1278 (?u gnus-tmp-user-defined ?s)
1279 (?P (gnus-pick-line-number) ?d)
1280 (?B gnus-tmp-thread-tree-header-string ?s)
1281 (user-date (gnus-user-date
1282 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1283 "An alist of format specifications that can appear in summary lines.
1284 These are paired with what variables they correspond with, along with
1285 the type of the variable (string, integer, character, etc).")
1287 (defvar gnus-summary-dummy-line-format-alist
1288 `((?S gnus-tmp-subject ?s)
1289 (?N gnus-tmp-number ?d)
1290 (?u gnus-tmp-user-defined ?s)))
1292 (defvar gnus-summary-mode-line-format-alist
1293 `((?G gnus-tmp-group-name ?s)
1294 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1295 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1296 (?A gnus-tmp-article-number ?d)
1297 (?Z gnus-tmp-unread-and-unselected ?s)
1298 (?V gnus-version ?s)
1299 (?U gnus-tmp-unread-and-unticked ?d)
1300 (?S gnus-tmp-subject ?s)
1301 (?e gnus-tmp-unselected ?d)
1302 (?u gnus-tmp-user-defined ?s)
1303 (?d (length gnus-newsgroup-dormant) ?d)
1304 (?t (length gnus-newsgroup-marked) ?d)
1305 (?h (length gnus-newsgroup-spam-marked) ?d)
1306 (?r (length gnus-newsgroup-reads) ?d)
1307 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1308 (?E gnus-newsgroup-expunged-tally ?d)
1309 (?s (gnus-current-score-file-nondirectory) ?s)))
1311 (defvar gnus-last-search-regexp nil
1312 "Default regexp for article search command.")
1314 (defvar gnus-last-shell-command nil
1315 "Default shell command on article.")
1317 (defvar gnus-newsgroup-agentized nil
1318 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1319 (defvar gnus-newsgroup-begin nil)
1320 (defvar gnus-newsgroup-end nil)
1321 (defvar gnus-newsgroup-last-rmail nil)
1322 (defvar gnus-newsgroup-last-mail nil)
1323 (defvar gnus-newsgroup-last-folder nil)
1324 (defvar gnus-newsgroup-last-file nil)
1325 (defvar gnus-newsgroup-auto-expire nil)
1326 (defvar gnus-newsgroup-active nil)
1328 (defvar gnus-newsgroup-data nil)
1329 (defvar gnus-newsgroup-data-reverse nil)
1330 (defvar gnus-newsgroup-limit nil)
1331 (defvar gnus-newsgroup-limits nil)
1332 (defvar gnus-summary-use-undownloaded-faces nil)
1334 (defvar gnus-newsgroup-unreads nil
1335 "Sorted list of unread articles in the current newsgroup.")
1337 (defvar gnus-newsgroup-unselected nil
1338 "Sorted list of unselected unread articles in the current newsgroup.")
1340 (defvar gnus-newsgroup-reads nil
1341 "Alist of read articles and article marks in the current newsgroup.")
1343 (defvar gnus-newsgroup-expunged-tally nil)
1345 (defvar gnus-newsgroup-marked nil
1346 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1348 (defvar gnus-newsgroup-spam-marked nil
1349 "List of ranges of articles that have been marked as spam.")
1351 (defvar gnus-newsgroup-killed nil
1352 "List of ranges of articles that have been through the scoring process.")
1354 (defvar gnus-newsgroup-cached nil
1355 "Sorted list of articles that come from the article cache.")
1357 (defvar gnus-newsgroup-saved nil
1358 "List of articles that have been saved.")
1360 (defvar gnus-newsgroup-kill-headers nil)
1362 (defvar gnus-newsgroup-replied nil
1363 "List of articles that have been replied to in the current newsgroup.")
1365 (defvar gnus-newsgroup-forwarded nil
1366 "List of articles that have been forwarded in the current newsgroup.")
1368 (defvar gnus-newsgroup-recent nil
1369 "List of articles that have are recent in the current newsgroup.")
1371 (defvar gnus-newsgroup-expirable nil
1372 "Sorted list of articles in the current newsgroup that can be expired.")
1374 (defvar gnus-newsgroup-processable nil
1375 "List of articles in the current newsgroup that can be processed.")
1377 (defvar gnus-newsgroup-downloadable nil
1378 "Sorted list of articles in the current newsgroup that can be processed.")
1380 (defvar gnus-newsgroup-unfetched nil
1381 "Sorted list of articles in the current newsgroup whose headers have
1382 not been fetched into the agent.
1384 This list will always be a subset of gnus-newsgroup-undownloaded.")
1386 (defvar gnus-newsgroup-undownloaded nil
1387 "List of articles in the current newsgroup that haven't been downloaded.")
1389 (defvar gnus-newsgroup-unsendable nil
1390 "List of articles in the current newsgroup that won't be sent.")
1392 (defvar gnus-newsgroup-bookmarks nil
1393 "List of articles in the current newsgroup that have bookmarks.")
1395 (defvar gnus-newsgroup-dormant nil
1396 "Sorted list of dormant articles in the current newsgroup.")
1398 (defvar gnus-newsgroup-unseen nil
1399 "List of unseen articles in the current newsgroup.")
1401 (defvar gnus-newsgroup-seen nil
1402 "Range of seen articles in the current newsgroup.")
1404 (defvar gnus-newsgroup-articles nil
1405 "List of articles in the current newsgroup.")
1407 (defvar gnus-newsgroup-scored nil
1408 "List of scored articles in the current newsgroup.")
1410 (defvar gnus-newsgroup-headers nil
1411 "List of article headers in the current newsgroup.")
1413 (defvar gnus-newsgroup-threads nil)
1415 (defvar gnus-newsgroup-prepared nil
1416 "Whether the current group has been prepared properly.")
1418 (defvar gnus-newsgroup-ancient nil
1419 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1421 (defvar gnus-newsgroup-sparse nil)
1423 (defvar gnus-current-article nil)
1424 (defvar gnus-article-current nil)
1425 (defvar gnus-current-headers nil)
1426 (defvar gnus-have-all-headers nil)
1427 (defvar gnus-last-article nil)
1428 (defvar gnus-newsgroup-history nil)
1429 (defvar gnus-newsgroup-charset nil)
1430 (defvar gnus-newsgroup-ephemeral-charset nil)
1431 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1433 (defvar gnus-article-before-search nil)
1435 (defvar gnus-summary-local-variables
1436 '(gnus-newsgroup-name
1437 gnus-newsgroup-begin gnus-newsgroup-end
1438 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1439 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1440 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1441 gnus-newsgroup-unselected gnus-newsgroup-marked
1442 gnus-newsgroup-spam-marked
1443 gnus-newsgroup-reads gnus-newsgroup-saved
1444 gnus-newsgroup-replied gnus-newsgroup-forwarded
1445 gnus-newsgroup-recent
1446 gnus-newsgroup-expirable
1447 gnus-newsgroup-processable gnus-newsgroup-killed
1448 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1449 gnus-newsgroup-unfetched
1450 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1451 gnus-newsgroup-seen gnus-newsgroup-articles
1452 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1453 gnus-newsgroup-headers gnus-newsgroup-threads
1454 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1455 gnus-current-article gnus-current-headers gnus-have-all-headers
1456 gnus-last-article gnus-article-internal-prepare-hook
1457 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1458 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1459 gnus-thread-expunge-below
1460 gnus-score-alist gnus-current-score-file
1461 (gnus-summary-expunge-below . global)
1462 (gnus-summary-mark-below . global)
1463 (gnus-orphan-score . global)
1464 gnus-newsgroup-active gnus-scores-exclude-files
1465 gnus-newsgroup-history gnus-newsgroup-ancient
1466 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1467 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1468 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1469 (gnus-newsgroup-expunged-tally . 0)
1470 gnus-cache-removable-articles gnus-newsgroup-cached
1471 gnus-newsgroup-data gnus-newsgroup-data-reverse
1472 gnus-newsgroup-limit gnus-newsgroup-limits
1473 gnus-newsgroup-charset gnus-newsgroup-display
1474 gnus-summary-use-undownloaded-faces)
1475 "Variables that are buffer-local to the summary buffers.")
1477 (defvar gnus-newsgroup-variables nil
1478 "A list of variables that have separate values in different newsgroups.
1479 A list of newsgroup (summary buffer) local variables, or cons of
1480 variables and their default expressions to be evalled (when the default
1481 values are not nil), that should be made global while the summary buffer
1484 Note: The default expressions will be evaluated (using function `eval')
1485 before assignment to the local variable rather than just assigned to it.
1486 If the default expression is the symbol `global', that symbol will not
1487 be evaluated but the global value of the local variable will be used
1490 These variables can be used to set variables in the group parameters
1491 while still allowing them to affect operations done in other buffers.
1494 \(setq gnus-newsgroup-variables
1495 '(message-use-followup-to
1496 (gnus-visible-headers .
1497 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1500 ;; Byte-compiler warning.
1502 ;; Bind features so that require will believe that gnus-sum has
1503 ;; already been loaded (avoids infinite recursion)
1504 (let ((features (cons 'gnus-sum features)))
1505 ;; Several of the declarations in gnus-sum are needed to load the
1506 ;; following files. Right now, these definitions have been
1507 ;; compiled but not defined (evaluated). We could either do a
1508 ;; eval-and-compile about all of the declarations or evaluate the
1510 (if (boundp 'gnus-newsgroup-variables)
1512 (load "gnus-sum.el" t t t))
1514 (require 'gnus-art)))
1518 (defvar gnus-decode-encoded-word-methods
1519 '(mail-decode-encoded-word-string)
1520 "List of methods used to decode encoded words.
1522 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1523 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1524 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1525 whose names match REGEXP.
1528 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1529 mail-decode-encoded-word-string
1530 (\"chinese\" . rfc1843-decode-string))")
1532 (defvar gnus-decode-encoded-word-methods-cache nil)
1534 (defun gnus-multi-decode-encoded-word-string (string)
1535 "Apply the functions from `gnus-encoded-word-methods' that match."
1536 (unless (and gnus-decode-encoded-word-methods-cache
1537 (eq gnus-newsgroup-name
1538 (car gnus-decode-encoded-word-methods-cache)))
1539 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1542 (nconc gnus-decode-encoded-word-methods-cache (list x))
1543 (if (and gnus-newsgroup-name
1544 (string-match (car x) gnus-newsgroup-name))
1545 (nconc gnus-decode-encoded-word-methods-cache
1547 gnus-decode-encoded-word-methods))
1548 (let ((xlist gnus-decode-encoded-word-methods-cache))
1551 (setq string (funcall (pop xlist) string))))
1554 ;; Subject simplification.
1556 (defun gnus-simplify-whitespace (str)
1557 "Remove excessive whitespace from STR."
1559 (while (string-match "[ \t][ \t]+" str)
1560 (setq str (concat (substring str 0 (match-beginning 0))
1562 (substring str (match-end 0)))))
1564 (when (string-match "^[ \t]+" str)
1565 (setq str (substring str (match-end 0))))
1567 (when (string-match "[ \t]+$" str)
1568 (setq str (substring str 0 (match-beginning 0))))
1571 (defun gnus-simplify-all-whitespace (str)
1572 "Remove all whitespace from STR."
1573 (while (string-match "[ \t\n]+" str)
1574 (setq str (replace-match "" nil nil str)))
1577 (defsubst gnus-simplify-subject-re (subject)
1578 "Remove \"Re:\" from subject lines."
1579 (if (string-match message-subject-re-regexp subject)
1580 (substring subject (match-end 0))
1583 (defun gnus-simplify-subject (subject &optional re-only)
1584 "Remove `Re:' and words in parentheses.
1585 If RE-ONLY is non-nil, strip leading `Re:'s only."
1586 (let ((case-fold-search t)) ;Ignore case.
1587 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1588 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1589 (setq subject (substring subject (match-end 0))))
1590 ;; Remove uninteresting prefixes.
1591 (when (and (not re-only)
1592 gnus-simplify-ignored-prefixes
1593 (string-match gnus-simplify-ignored-prefixes subject))
1594 (setq subject (substring subject (match-end 0))))
1595 ;; Remove words in parentheses from end.
1597 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1598 (setq subject (substring subject 0 (match-beginning 0)))))
1599 ;; Return subject string.
1602 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1604 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1605 (goto-char (point-min))
1606 (while (re-search-forward regexp nil t)
1607 (replace-match (or newtext ""))))
1609 (defun gnus-simplify-buffer-fuzzy ()
1610 "Simplify string in the buffer fuzzily.
1611 The string in the accessible portion of the current buffer is simplified.
1612 It is assumed to be a single-line subject.
1613 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1614 matter is removed. Additional things can be deleted by setting
1615 `gnus-simplify-subject-fuzzy-regexp'."
1616 (let ((case-fold-search t)
1618 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1620 (while (not (eq modified-tick (buffer-modified-tick)))
1621 (setq modified-tick (buffer-modified-tick))
1623 ((listp gnus-simplify-subject-fuzzy-regexp)
1624 (mapcar 'gnus-simplify-buffer-fuzzy-step
1625 gnus-simplify-subject-fuzzy-regexp))
1626 (gnus-simplify-subject-fuzzy-regexp
1627 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1628 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1629 (gnus-simplify-buffer-fuzzy-step
1630 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1631 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1633 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1634 (gnus-simplify-buffer-fuzzy-step " +" " ")
1635 (gnus-simplify-buffer-fuzzy-step " $")
1636 (gnus-simplify-buffer-fuzzy-step "^ +")))
1638 (defun gnus-simplify-subject-fuzzy (subject)
1639 "Simplify a subject string fuzzily.
1640 See `gnus-simplify-buffer-fuzzy' for details."
1642 (gnus-set-work-buffer)
1643 (let ((case-fold-search t))
1644 ;; Remove uninteresting prefixes.
1645 (when (and gnus-simplify-ignored-prefixes
1646 (string-match gnus-simplify-ignored-prefixes subject))
1647 (setq subject (substring subject (match-end 0))))
1649 (inline (gnus-simplify-buffer-fuzzy))
1652 (defsubst gnus-simplify-subject-fully (subject)
1653 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1655 (gnus-simplify-subject-functions
1656 (gnus-map-function gnus-simplify-subject-functions subject))
1657 ((null gnus-summary-gather-subject-limit)
1658 (gnus-simplify-subject-re subject))
1659 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1660 (gnus-simplify-subject-fuzzy subject))
1661 ((numberp gnus-summary-gather-subject-limit)
1662 (gnus-limit-string (gnus-simplify-subject-re subject)
1663 gnus-summary-gather-subject-limit))
1667 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1668 "Check whether two subjects are equal.
1669 If optional argument SIMPLE-FIRST is t, first argument is already
1672 ((null simple-first)
1673 (equal (gnus-simplify-subject-fully s1)
1674 (gnus-simplify-subject-fully s2)))
1677 (gnus-simplify-subject-fully s2)))))
1679 (defun gnus-summary-bubble-group ()
1680 "Increase the score of the current group.
1681 This is a handy function to add to `gnus-summary-exit-hook' to
1682 increase the score of each group you read."
1683 (gnus-group-add-score gnus-newsgroup-name))
1687 ;;; Gnus summary mode
1690 (put 'gnus-summary-mode 'mode-class 'special)
1692 (defvar gnus-article-commands-menu)
1694 ;; Non-orthogonal keys
1696 (gnus-define-keys gnus-summary-mode-map
1697 " " gnus-summary-next-page
1698 "\177" gnus-summary-prev-page
1699 [delete] gnus-summary-prev-page
1700 [backspace] gnus-summary-prev-page
1701 "\r" gnus-summary-scroll-up
1702 "\M-\r" gnus-summary-scroll-down
1703 "n" gnus-summary-next-unread-article
1704 "p" gnus-summary-prev-unread-article
1705 "N" gnus-summary-next-article
1706 "P" gnus-summary-prev-article
1707 "\M-\C-n" gnus-summary-next-same-subject
1708 "\M-\C-p" gnus-summary-prev-same-subject
1709 "\M-n" gnus-summary-next-unread-subject
1710 "\M-p" gnus-summary-prev-unread-subject
1711 "." gnus-summary-first-unread-article
1712 "," gnus-summary-best-unread-article
1713 "\M-s" gnus-summary-search-article-forward
1714 "\M-r" gnus-summary-search-article-backward
1715 "<" gnus-summary-beginning-of-article
1716 ">" gnus-summary-end-of-article
1717 "j" gnus-summary-goto-article
1718 "^" gnus-summary-refer-parent-article
1719 "\M-^" gnus-summary-refer-article
1720 "u" gnus-summary-tick-article-forward
1721 "!" gnus-summary-tick-article-forward
1722 "U" gnus-summary-tick-article-backward
1723 "d" gnus-summary-mark-as-read-forward
1724 "D" gnus-summary-mark-as-read-backward
1725 "E" gnus-summary-mark-as-expirable
1726 "\M-u" gnus-summary-clear-mark-forward
1727 "\M-U" gnus-summary-clear-mark-backward
1728 "k" gnus-summary-kill-same-subject-and-select
1729 "\C-k" gnus-summary-kill-same-subject
1730 "\M-\C-k" gnus-summary-kill-thread
1731 "\M-\C-l" gnus-summary-lower-thread
1732 "e" gnus-summary-edit-article
1733 "#" gnus-summary-mark-as-processable
1734 "\M-#" gnus-summary-unmark-as-processable
1735 "\M-\C-t" gnus-summary-toggle-threads
1736 "\M-\C-s" gnus-summary-show-thread
1737 "\M-\C-h" gnus-summary-hide-thread
1738 "\M-\C-f" gnus-summary-next-thread
1739 "\M-\C-b" gnus-summary-prev-thread
1740 [(meta down)] gnus-summary-next-thread
1741 [(meta up)] gnus-summary-prev-thread
1742 "\M-\C-u" gnus-summary-up-thread
1743 "\M-\C-d" gnus-summary-down-thread
1744 "&" gnus-summary-execute-command
1745 "c" gnus-summary-catchup-and-exit
1746 "\C-w" gnus-summary-mark-region-as-read
1747 "\C-t" gnus-summary-toggle-truncation
1748 "?" gnus-summary-mark-as-dormant
1749 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1750 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1751 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1752 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1753 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1754 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1755 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1756 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1757 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1758 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1759 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1760 "=" gnus-summary-expand-window
1761 "\C-x\C-s" gnus-summary-reselect-current-group
1762 "\M-g" gnus-summary-rescan-group
1763 "w" gnus-summary-stop-page-breaking
1764 "\C-c\C-r" gnus-summary-caesar-message
1765 "f" gnus-summary-followup
1766 "F" gnus-summary-followup-with-original
1767 "C" gnus-summary-cancel-article
1768 "r" gnus-summary-reply
1769 "R" gnus-summary-reply-with-original
1770 "\C-c\C-f" gnus-summary-mail-forward
1771 "o" gnus-summary-save-article
1772 "\C-o" gnus-summary-save-article-mail
1773 "|" gnus-summary-pipe-output
1774 "\M-k" gnus-summary-edit-local-kill
1775 "\M-K" gnus-summary-edit-global-kill
1777 "\C-c\C-d" gnus-summary-describe-group
1778 "q" gnus-summary-exit
1779 "Q" gnus-summary-exit-no-update
1780 "\C-c\C-i" gnus-info-find-node
1781 gnus-mouse-2 gnus-mouse-pick-article
1782 [follow-link] mouse-face
1783 "m" gnus-summary-mail-other-window
1784 "a" gnus-summary-post-news
1785 "i" gnus-summary-news-other-window
1786 "x" gnus-summary-limit-to-unread
1787 "s" gnus-summary-isearch-article
1788 "t" gnus-summary-toggle-header
1789 "g" gnus-summary-show-article
1790 "l" gnus-summary-goto-last-article
1791 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1792 "\C-d" gnus-summary-enter-digest-group
1793 "\M-\C-d" gnus-summary-read-document
1794 "\M-\C-e" gnus-summary-edit-parameters
1795 "\M-\C-a" gnus-summary-customize-parameters
1797 "*" gnus-cache-enter-article
1798 "\M-*" gnus-cache-remove-article
1799 "\M-&" gnus-summary-universal-argument
1800 "\C-l" gnus-recenter
1801 "I" gnus-summary-increase-score
1802 "L" gnus-summary-lower-score
1803 "\M-i" gnus-symbolic-argument
1804 "h" gnus-summary-select-article-buffer
1806 "b" gnus-article-view-part
1807 "\M-t" gnus-summary-toggle-display-buttonized
1809 "V" gnus-summary-score-map
1810 "X" gnus-uu-extract-map
1811 "S" gnus-summary-send-map)
1813 ;; Sort of orthogonal keymap
1814 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1815 "t" gnus-summary-tick-article-forward
1816 "!" gnus-summary-tick-article-forward
1817 "d" gnus-summary-mark-as-read-forward
1818 "r" gnus-summary-mark-as-read-forward
1819 "c" gnus-summary-clear-mark-forward
1820 " " gnus-summary-clear-mark-forward
1821 "e" gnus-summary-mark-as-expirable
1822 "x" gnus-summary-mark-as-expirable
1823 "?" gnus-summary-mark-as-dormant
1824 "b" gnus-summary-set-bookmark
1825 "B" gnus-summary-remove-bookmark
1826 "#" gnus-summary-mark-as-processable
1827 "\M-#" gnus-summary-unmark-as-processable
1828 "S" gnus-summary-limit-include-expunged
1829 "C" gnus-summary-catchup
1830 "H" gnus-summary-catchup-to-here
1831 "h" gnus-summary-catchup-from-here
1832 "\C-c" gnus-summary-catchup-all
1833 "k" gnus-summary-kill-same-subject-and-select
1834 "K" gnus-summary-kill-same-subject
1835 "P" gnus-uu-mark-map)
1837 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1838 "c" gnus-summary-clear-above
1839 "u" gnus-summary-tick-above
1840 "m" gnus-summary-mark-above
1841 "k" gnus-summary-kill-below)
1843 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1844 "/" gnus-summary-limit-to-subject
1845 "n" gnus-summary-limit-to-articles
1846 "w" gnus-summary-pop-limit
1847 "s" gnus-summary-limit-to-subject
1848 "a" gnus-summary-limit-to-author
1849 "u" gnus-summary-limit-to-unread
1850 "m" gnus-summary-limit-to-marks
1851 "M" gnus-summary-limit-exclude-marks
1852 "v" gnus-summary-limit-to-score
1853 "*" gnus-summary-limit-include-cached
1854 "D" gnus-summary-limit-include-dormant
1855 "T" gnus-summary-limit-include-thread
1856 "d" gnus-summary-limit-exclude-dormant
1857 "t" gnus-summary-limit-to-age
1858 "." gnus-summary-limit-to-unseen
1859 "x" gnus-summary-limit-to-extra
1860 "p" gnus-summary-limit-to-display-predicate
1861 "E" gnus-summary-limit-include-expunged
1862 "c" gnus-summary-limit-exclude-childless-dormant
1863 "C" gnus-summary-limit-mark-excluded-as-read
1864 "o" gnus-summary-insert-old-articles
1865 "N" gnus-summary-insert-new-articles
1866 "r" gnus-summary-limit-to-replied
1867 "R" gnus-summary-limit-to-recipient)
1869 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1870 "n" gnus-summary-next-unread-article
1871 "p" gnus-summary-prev-unread-article
1872 "N" gnus-summary-next-article
1873 "P" gnus-summary-prev-article
1874 "\C-n" gnus-summary-next-same-subject
1875 "\C-p" gnus-summary-prev-same-subject
1876 "\M-n" gnus-summary-next-unread-subject
1877 "\M-p" gnus-summary-prev-unread-subject
1878 "f" gnus-summary-first-unread-article
1879 "b" gnus-summary-best-unread-article
1880 "j" gnus-summary-goto-article
1881 "g" gnus-summary-goto-subject
1882 "l" gnus-summary-goto-last-article
1883 "o" gnus-summary-pop-article)
1885 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1886 "k" gnus-summary-kill-thread
1887 "l" gnus-summary-lower-thread
1888 "i" gnus-summary-raise-thread
1889 "T" gnus-summary-toggle-threads
1890 "t" gnus-summary-rethread-current
1891 "^" gnus-summary-reparent-thread
1892 "s" gnus-summary-show-thread
1893 "S" gnus-summary-show-all-threads
1894 "h" gnus-summary-hide-thread
1895 "H" gnus-summary-hide-all-threads
1896 "n" gnus-summary-next-thread
1897 "p" gnus-summary-prev-thread
1898 "u" gnus-summary-up-thread
1899 "o" gnus-summary-top-thread
1900 "d" gnus-summary-down-thread
1901 "#" gnus-uu-mark-thread
1902 "\M-#" gnus-uu-unmark-thread)
1904 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1905 "g" gnus-summary-prepare
1906 "c" gnus-summary-insert-cached-articles
1907 "d" gnus-summary-insert-dormant-articles)
1909 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1910 "c" gnus-summary-catchup-and-exit
1911 "C" gnus-summary-catchup-all-and-exit
1912 "E" gnus-summary-exit-no-update
1913 "Q" gnus-summary-exit
1914 "Z" gnus-summary-exit
1915 "n" gnus-summary-catchup-and-goto-next-group
1916 "p" gnus-summary-catchup-and-goto-prev-group
1917 "R" gnus-summary-reselect-current-group
1918 "G" gnus-summary-rescan-group
1919 "N" gnus-summary-next-group
1920 "s" gnus-summary-save-newsrc
1921 "P" gnus-summary-prev-group)
1923 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1924 " " gnus-summary-next-page
1925 "n" gnus-summary-next-page
1926 "\177" gnus-summary-prev-page
1927 [delete] gnus-summary-prev-page
1928 "p" gnus-summary-prev-page
1929 "\r" gnus-summary-scroll-up
1930 "\M-\r" gnus-summary-scroll-down
1931 "<" gnus-summary-beginning-of-article
1932 ">" gnus-summary-end-of-article
1933 "b" gnus-summary-beginning-of-article
1934 "e" gnus-summary-end-of-article
1935 "^" gnus-summary-refer-parent-article
1936 "r" gnus-summary-refer-parent-article
1937 "D" gnus-summary-enter-digest-group
1938 "R" gnus-summary-refer-references
1939 "T" gnus-summary-refer-thread
1940 "g" gnus-summary-show-article
1941 "s" gnus-summary-isearch-article
1942 "P" gnus-summary-print-article
1943 "M" gnus-mailing-list-insinuate
1944 "t" gnus-article-babel)
1946 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1947 "b" gnus-article-add-buttons
1948 "B" gnus-article-add-buttons-to-head
1949 "o" gnus-article-treat-overstrike
1950 "e" gnus-article-emphasize
1951 "w" gnus-article-fill-cited-article
1952 "Q" gnus-article-fill-long-lines
1953 "C" gnus-article-capitalize-sentences
1954 "c" gnus-article-remove-cr
1955 "q" gnus-article-de-quoted-unreadable
1956 "6" gnus-article-de-base64-unreadable
1957 "Z" gnus-article-decode-HZ
1958 "A" gnus-article-treat-ansi-sequences
1959 "h" gnus-article-wash-html
1960 "u" gnus-article-unsplit-urls
1961 "s" gnus-summary-force-verify-and-decrypt
1962 "f" gnus-article-display-x-face
1963 "l" gnus-summary-stop-page-breaking
1964 "r" gnus-summary-caesar-message
1965 "m" gnus-summary-morse-message
1966 "t" gnus-summary-toggle-header
1967 "g" gnus-treat-smiley
1968 "v" gnus-summary-verbose-headers
1969 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1970 "p" gnus-article-verify-x-pgp-sig
1971 "d" gnus-article-treat-dumbquotes
1972 "i" gnus-summary-idna-message)
1974 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1975 ;; mnemonic: deuglif*Y*
1976 "u" gnus-article-outlook-unwrap-lines
1977 "a" gnus-article-outlook-repair-attribution
1978 "c" gnus-article-outlook-rearrange-citation
1979 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1981 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1982 "a" gnus-article-hide
1983 "h" gnus-article-hide-headers
1984 "b" gnus-article-hide-boring-headers
1985 "s" gnus-article-hide-signature
1986 "c" gnus-article-hide-citation
1987 "C" gnus-article-hide-citation-in-followups
1988 "l" gnus-article-hide-list-identifiers
1989 "B" gnus-article-strip-banner
1990 "P" gnus-article-hide-pem
1991 "\C-c" gnus-article-hide-citation-maybe)
1993 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1994 "a" gnus-article-highlight
1995 "h" gnus-article-highlight-headers
1996 "c" gnus-article-highlight-citation
1997 "s" gnus-article-highlight-signature)
1999 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2000 "f" gnus-article-treat-fold-headers
2001 "u" gnus-article-treat-unfold-headers
2002 "n" gnus-article-treat-fold-newsgroups)
2004 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2005 "x" gnus-article-display-x-face
2006 "d" gnus-article-display-face
2007 "s" gnus-treat-smiley
2008 "D" gnus-article-remove-images
2009 "f" gnus-treat-from-picon
2010 "m" gnus-treat-mail-picon
2011 "n" gnus-treat-newsgroups-picon)
2013 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2014 "w" gnus-article-decode-mime-words
2015 "c" gnus-article-decode-charset
2016 "v" gnus-mime-view-all-parts
2017 "b" gnus-article-view-part)
2019 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2020 "z" gnus-article-date-ut
2021 "u" gnus-article-date-ut
2022 "l" gnus-article-date-local
2023 "p" gnus-article-date-english
2024 "e" gnus-article-date-lapsed
2025 "o" gnus-article-date-original
2026 "i" gnus-article-date-iso8601
2027 "s" gnus-article-date-user)
2029 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2030 "t" gnus-article-remove-trailing-blank-lines
2031 "l" gnus-article-strip-leading-blank-lines
2032 "m" gnus-article-strip-multiple-blank-lines
2033 "a" gnus-article-strip-blank-lines
2034 "A" gnus-article-strip-all-blank-lines
2035 "s" gnus-article-strip-leading-space
2036 "e" gnus-article-strip-trailing-space
2037 "w" gnus-article-remove-leading-whitespace)
2039 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2041 "f" gnus-summary-fetch-faq
2042 "d" gnus-summary-describe-group
2043 "h" gnus-summary-describe-briefly
2044 "i" gnus-info-find-node
2045 "c" gnus-group-fetch-charter
2046 "C" gnus-group-fetch-control)
2048 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2049 "e" gnus-summary-expire-articles
2050 "\M-\C-e" gnus-summary-expire-articles-now
2051 "\177" gnus-summary-delete-article
2052 [delete] gnus-summary-delete-article
2053 [backspace] gnus-summary-delete-article
2054 "m" gnus-summary-move-article
2055 "r" gnus-summary-respool-article
2056 "w" gnus-summary-edit-article
2057 "c" gnus-summary-copy-article
2058 "B" gnus-summary-crosspost-article
2059 "q" gnus-summary-respool-query
2060 "t" gnus-summary-respool-trace
2061 "i" gnus-summary-import-article
2062 "I" gnus-summary-create-article
2063 "p" gnus-summary-article-posted-p)
2065 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2066 "o" gnus-summary-save-article
2067 "m" gnus-summary-save-article-mail
2068 "F" gnus-summary-write-article-file
2069 "r" gnus-summary-save-article-rmail
2070 "f" gnus-summary-save-article-file
2071 "b" gnus-summary-save-article-body-file
2072 "h" gnus-summary-save-article-folder
2073 "v" gnus-summary-save-article-vm
2074 "p" gnus-summary-pipe-output
2075 "P" gnus-summary-muttprint
2076 "s" gnus-soup-add-article)
2078 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2079 "b" gnus-summary-display-buttonized
2080 "m" gnus-summary-repair-multipart
2081 "v" gnus-article-view-part
2082 "o" gnus-article-save-part
2083 "O" gnus-article-save-part-and-strip
2084 "r" gnus-article-replace-part
2085 "d" gnus-article-delete-part
2086 "j" gnus-article-jump-to-part
2087 "c" gnus-article-copy-part
2088 "C" gnus-article-view-part-as-charset
2089 "e" gnus-article-view-part-externally
2090 "E" gnus-article-encrypt-body
2091 "i" gnus-article-inline-part
2092 "|" gnus-article-pipe-part)
2094 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2095 "p" gnus-summary-mark-as-processable
2096 "u" gnus-summary-unmark-as-processable
2097 "U" gnus-summary-unmark-all-processable
2098 "v" gnus-uu-mark-over
2099 "s" gnus-uu-mark-series
2100 "r" gnus-uu-mark-region
2101 "g" gnus-uu-unmark-region
2102 "R" gnus-uu-mark-by-regexp
2103 "G" gnus-uu-unmark-by-regexp
2104 "t" gnus-uu-mark-thread
2105 "T" gnus-uu-unmark-thread
2106 "a" gnus-uu-mark-all
2107 "b" gnus-uu-mark-buffer
2108 "S" gnus-uu-mark-sparse
2109 "k" gnus-summary-kill-process-mark
2110 "y" gnus-summary-yank-process-mark
2111 "w" gnus-summary-save-process-mark
2112 "i" gnus-uu-invert-processable)
2114 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2115 ;;"x" gnus-uu-extract-any
2116 "m" gnus-summary-save-parts
2117 "u" gnus-uu-decode-uu
2118 "U" gnus-uu-decode-uu-and-save
2119 "s" gnus-uu-decode-unshar
2120 "S" gnus-uu-decode-unshar-and-save
2121 "o" gnus-uu-decode-save
2122 "O" gnus-uu-decode-save
2123 "b" gnus-uu-decode-binhex
2124 "B" gnus-uu-decode-binhex
2125 "p" gnus-uu-decode-postscript
2126 "P" gnus-uu-decode-postscript-and-save)
2129 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2130 "u" gnus-uu-decode-uu-view
2131 "U" gnus-uu-decode-uu-and-save-view
2132 "s" gnus-uu-decode-unshar-view
2133 "S" gnus-uu-decode-unshar-and-save-view
2134 "o" gnus-uu-decode-save-view
2135 "O" gnus-uu-decode-save-view
2136 "b" gnus-uu-decode-binhex-view
2137 "B" gnus-uu-decode-binhex-view
2138 "p" gnus-uu-decode-postscript-view
2139 "P" gnus-uu-decode-postscript-and-save-view)
2141 (defvar gnus-article-post-menu nil)
2143 (defconst gnus-summary-menu-maxlen 20)
2145 (defun gnus-summary-menu-split (menu)
2146 ;; If we have lots of elements, divide them into groups of 20
2147 ;; and make a pane (or submenu) for each one.
2148 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2149 (let ((menu menu) sublists next
2152 ;; Pull off the next gnus-summary-menu-maxlen elements
2153 ;; and make them the next element of sublist.
2154 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2156 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2158 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2159 (aref (car (last menu)) 0)) menu)
2163 (nreverse sublists))
2164 ;; Few elements--put them all in one pane.
2167 (defun gnus-summary-make-menu-bar ()
2168 (gnus-turn-off-edit-menu 'summary)
2170 (unless (boundp 'gnus-summary-misc-menu)
2173 gnus-summary-kill-menu gnus-summary-mode-map ""
2178 ["Customize" gnus-score-customize t])
2179 (gnus-make-score-map 'increase)
2180 (gnus-make-score-map 'lower)
2182 ["Kill below" gnus-summary-kill-below t]
2183 ["Mark above" gnus-summary-mark-above t]
2184 ["Tick above" gnus-summary-tick-above t]
2185 ["Clear above" gnus-summary-clear-above t])
2186 ["Current score" gnus-summary-current-score t]
2187 ["Set score" gnus-summary-set-score t]
2188 ["Switch current score file..." gnus-score-change-score-file t]
2189 ["Set mark below..." gnus-score-set-mark-below t]
2190 ["Set expunge below..." gnus-score-set-expunge-below t]
2191 ["Edit current score file" gnus-score-edit-current-scores t]
2192 ["Edit score file" gnus-score-edit-file t]
2193 ["Trace score" gnus-score-find-trace t]
2194 ["Find words" gnus-score-find-favourite-words t]
2195 ["Rescore buffer" gnus-summary-rescore t]
2196 ["Increase score..." gnus-summary-increase-score t]
2197 ["Lower score..." gnus-summary-lower-score t]))))
2199 ;; Define both the Article menu in the summary buffer and the
2200 ;; equivalent Commands menu in the article buffer here for
2204 ["All" gnus-article-hide t]
2205 ["Headers" gnus-article-hide-headers t]
2206 ["Signature" gnus-article-hide-signature t]
2207 ["Citation" gnus-article-hide-citation t]
2208 ["List identifiers" gnus-article-hide-list-identifiers t]
2209 ["Banner" gnus-article-strip-banner t]
2210 ["Boring headers" gnus-article-hide-boring-headers t])
2212 ["All" gnus-article-highlight t]
2213 ["Headers" gnus-article-highlight-headers t]
2214 ["Signature" gnus-article-highlight-signature t]
2215 ["Citation" gnus-article-highlight-citation t])
2217 ["Words" gnus-article-decode-mime-words t]
2218 ["Charset" gnus-article-decode-charset t]
2219 ["QP" gnus-article-de-quoted-unreadable t]
2220 ["Base64" gnus-article-de-base64-unreadable t]
2221 ["View MIME buttons" gnus-summary-display-buttonized t]
2222 ["View all" gnus-mime-view-all-parts t]
2223 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2224 ["Encrypt body" gnus-article-encrypt-body
2225 :active (not (gnus-group-read-only-p))
2226 ,@(if (featurep 'xemacs) nil
2227 '(:help "Encrypt the message body on disk"))]
2228 ["Extract all parts..." gnus-summary-save-parts t]
2230 ["Repair multipart" gnus-summary-repair-multipart t]
2231 ["Pipe part..." gnus-article-pipe-part t]
2232 ["Inline part" gnus-article-inline-part t]
2233 ["Encrypt body" gnus-article-encrypt-body
2234 :active (not (gnus-group-read-only-p))
2235 ,@(if (featurep 'xemacs) nil
2236 '(:help "Encrypt the message body on disk"))]
2237 ["View part externally" gnus-article-view-part-externally t]
2238 ["View part with charset..." gnus-article-view-part-as-charset t]
2239 ["Copy part" gnus-article-copy-part t]
2240 ["Save part..." gnus-article-save-part t]
2241 ["View part" gnus-article-view-part t]))
2243 ["Local" gnus-article-date-local t]
2244 ["ISO8601" gnus-article-date-iso8601 t]
2245 ["UT" gnus-article-date-ut t]
2246 ["Original" gnus-article-date-original t]
2247 ["Lapsed" gnus-article-date-lapsed t]
2248 ["User-defined" gnus-article-date-user t])
2250 ["Remove images" gnus-article-remove-images t]
2251 ["Toggle smiley" gnus-treat-smiley t]
2252 ["Show X-Face" gnus-article-display-x-face t]
2253 ["Show picons in From" gnus-treat-from-picon t]
2254 ["Show picons in mail headers" gnus-treat-mail-picon t]
2255 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2256 ("View as different encoding"
2257 ,@(gnus-summary-menu-split
2260 ;; Since easymenu under Emacs doesn't allow
2261 ;; lambda forms for menu commands, we should
2262 ;; provide intern'ed function symbols.
2263 (let ((command (intern (format "\
2264 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2268 (let ((gnus-summary-show-article-charset-alist
2270 (gnus-summary-show-article 1))))
2271 `[,(symbol-name cs) ,command t]))
2272 (sort (if (fboundp 'coding-system-list)
2273 (coding-system-list)
2274 (mapcar 'car mm-mime-mule-charset-alist))
2278 ["Leading" gnus-article-strip-leading-blank-lines t]
2279 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2280 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2281 ["All of the above" gnus-article-strip-blank-lines t]
2282 ["All" gnus-article-strip-all-blank-lines t]
2283 ["Leading space" gnus-article-strip-leading-space t]
2284 ["Trailing space" gnus-article-strip-trailing-space t]
2285 ["Leading space in headers"
2286 gnus-article-remove-leading-whitespace t])
2287 ["Overstrike" gnus-article-treat-overstrike t]
2288 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2289 ["Emphasis" gnus-article-emphasize t]
2290 ["Word wrap" gnus-article-fill-cited-article t]
2291 ["Fill long lines" gnus-article-fill-long-lines t]
2292 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2293 ["Remove CR" gnus-article-remove-cr t]
2294 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2295 ["Base64" gnus-article-de-base64-unreadable t]
2296 ["Rot 13" gnus-summary-caesar-message
2297 ,@(if (featurep 'xemacs) '(t)
2298 '(:help "\"Caesar rotate\" article by 13"))]
2299 ["De-IDNA" gnus-summary-idna-message t]
2300 ["Morse decode" gnus-summary-morse-message t]
2301 ["Unix pipe..." gnus-summary-pipe-message t]
2302 ["Add buttons" gnus-article-add-buttons t]
2303 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2304 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2305 ["Verbose header" gnus-summary-verbose-headers t]
2306 ["Toggle header" gnus-summary-toggle-header t]
2307 ["Unfold headers" gnus-article-treat-unfold-headers t]
2308 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2309 ["Html" gnus-article-wash-html t]
2310 ["Unsplit URLs" gnus-article-unsplit-urls t]
2311 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2312 ["Decode HZ" gnus-article-decode-HZ t]
2313 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2314 ("(Outlook) Deuglify"
2315 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2316 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2317 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2318 ["Full (Outlook) deuglify"
2319 gnus-article-outlook-deuglify-article t])
2322 ["Save in default format..." gnus-summary-save-article
2323 ,@(if (featurep 'xemacs) '(t)
2324 '(:help "Save article using default method"))]
2325 ["Save in file..." gnus-summary-save-article-file
2326 ,@(if (featurep 'xemacs) '(t)
2327 '(:help "Save article in file"))]
2328 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2329 ["Save in MH folder..." gnus-summary-save-article-folder t]
2330 ["Save in VM folder..." gnus-summary-save-article-vm t]
2331 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2332 ["Save body in file..." gnus-summary-save-article-body-file t]
2333 ["Pipe through a filter..." gnus-summary-pipe-output t]
2334 ["Add to SOUP packet" gnus-soup-add-article t]
2335 ["Print with Muttprint..." gnus-summary-muttprint t]
2336 ["Print" gnus-summary-print-article
2337 ,@(if (featurep 'xemacs) '(t)
2338 '(:help "Generate and print a PostScript image"))])
2339 ("Copy, move,... (Backend)"
2340 ,@(if (featurep 'xemacs) nil
2341 '(:help "Copying, moving, expiring articles..."))
2342 ["Respool article..." gnus-summary-respool-article t]
2343 ["Move article..." gnus-summary-move-article
2344 (gnus-check-backend-function
2345 'request-move-article gnus-newsgroup-name)]
2346 ["Copy article..." gnus-summary-copy-article t]
2347 ["Crosspost article..." gnus-summary-crosspost-article
2348 (gnus-check-backend-function
2349 'request-replace-article gnus-newsgroup-name)]
2350 ["Import file..." gnus-summary-import-article
2351 (gnus-check-backend-function
2352 'request-accept-article gnus-newsgroup-name)]
2353 ["Create article..." gnus-summary-create-article
2354 (gnus-check-backend-function
2355 'request-accept-article gnus-newsgroup-name)]
2356 ["Check if posted" gnus-summary-article-posted-p t]
2357 ["Edit article" gnus-summary-edit-article
2358 (not (gnus-group-read-only-p))]
2359 ["Delete article" gnus-summary-delete-article
2360 (gnus-check-backend-function
2361 'request-expire-articles gnus-newsgroup-name)]
2362 ["Query respool" gnus-summary-respool-query t]
2363 ["Trace respool" gnus-summary-respool-trace t]
2364 ["Delete expirable articles" gnus-summary-expire-articles-now
2365 (gnus-check-backend-function
2366 'request-expire-articles gnus-newsgroup-name)])
2368 ["Uudecode" gnus-uu-decode-uu
2369 ,@(if (featurep 'xemacs) '(t)
2370 '(:help "Decode uuencoded article(s)"))]
2371 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2372 ["Unshar" gnus-uu-decode-unshar t]
2373 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2374 ["Save" gnus-uu-decode-save t]
2375 ["Binhex" gnus-uu-decode-binhex t]
2376 ["Postscript" gnus-uu-decode-postscript t]
2377 ["All MIME parts" gnus-summary-save-parts t])
2379 ["Enter article" gnus-cache-enter-article t]
2380 ["Remove article" gnus-cache-remove-article t])
2381 ["Translate" gnus-article-babel t]
2382 ["Select article buffer" gnus-summary-select-article-buffer t]
2383 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2384 ["Isearch article..." gnus-summary-isearch-article t]
2385 ["Beginning of the article" gnus-summary-beginning-of-article t]
2386 ["End of the article" gnus-summary-end-of-article t]
2387 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2388 ["Fetch referenced articles" gnus-summary-refer-references t]
2389 ["Fetch current thread" gnus-summary-refer-thread t]
2390 ["Fetch article with id..." gnus-summary-refer-article t]
2391 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2392 ["Redisplay" gnus-summary-show-article t]
2393 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2395 gnus-summary-article-menu gnus-summary-mode-map ""
2396 (cons "Article" innards))
2398 (if (not (keymapp gnus-summary-article-menu))
2400 gnus-article-commands-menu gnus-article-mode-map ""
2401 (cons "Commands" innards))
2402 ;; in Emacs, don't share menu.
2403 (setq gnus-article-commands-menu
2404 (copy-keymap gnus-summary-article-menu))
2405 (define-key gnus-article-mode-map [menu-bar commands]
2406 (cons "Commands" gnus-article-commands-menu))))
2409 gnus-summary-thread-menu gnus-summary-mode-map ""
2411 ["Find all messages in thread" gnus-summary-refer-thread t]
2412 ["Toggle threading" gnus-summary-toggle-threads t]
2413 ["Hide threads" gnus-summary-hide-all-threads t]
2414 ["Show threads" gnus-summary-show-all-threads t]
2415 ["Hide thread" gnus-summary-hide-thread t]
2416 ["Show thread" gnus-summary-show-thread t]
2417 ["Go to next thread" gnus-summary-next-thread t]
2418 ["Go to previous thread" gnus-summary-prev-thread t]
2419 ["Go down thread" gnus-summary-down-thread t]
2420 ["Go up thread" gnus-summary-up-thread t]
2421 ["Top of thread" gnus-summary-top-thread t]
2422 ["Mark thread as read" gnus-summary-kill-thread t]
2423 ["Lower thread score" gnus-summary-lower-thread t]
2424 ["Raise thread score" gnus-summary-raise-thread t]
2425 ["Rethread current" gnus-summary-rethread-current t]))
2428 gnus-summary-post-menu gnus-summary-mode-map ""
2430 ["Send a message (mail or news)" gnus-summary-post-news
2431 ,@(if (featurep 'xemacs) '(t)
2432 '(:help "Compose a new message (mail or news)"))]
2433 ["Followup" gnus-summary-followup
2434 ,@(if (featurep 'xemacs) '(t)
2435 '(:help "Post followup to this article"))]
2436 ["Followup and yank" gnus-summary-followup-with-original
2437 ,@(if (featurep 'xemacs) '(t)
2438 '(:help "Post followup to this article, quoting its contents"))]
2439 ["Supersede article" gnus-summary-supersede-article t]
2440 ["Cancel article" gnus-summary-cancel-article
2441 ,@(if (featurep 'xemacs) '(t)
2442 '(:help "Cancel an article you posted"))]
2443 ["Reply" gnus-summary-reply t]
2444 ["Reply and yank" gnus-summary-reply-with-original t]
2445 ["Wide reply" gnus-summary-wide-reply t]
2446 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2447 ,@(if (featurep 'xemacs) '(t)
2448 '(:help "Mail a reply, quoting this article"))]
2449 ["Very wide reply" gnus-summary-very-wide-reply t]
2450 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2451 ,@(if (featurep 'xemacs) '(t)
2452 '(:help "Mail a very wide reply, quoting this article"))]
2453 ["Mail forward" gnus-summary-mail-forward t]
2454 ["Post forward" gnus-summary-post-forward t]
2455 ["Digest and mail" gnus-uu-digest-mail-forward t]
2456 ["Digest and post" gnus-uu-digest-post-forward t]
2457 ["Resend message" gnus-summary-resend-message t]
2458 ["Resend message edit" gnus-summary-resend-message-edit t]
2459 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2460 ["Send a mail" gnus-summary-mail-other-window t]
2461 ["Create a local message" gnus-summary-news-other-window t]
2462 ["Uuencode and post" gnus-uu-post-news
2463 ,@(if (featurep 'xemacs) '(t)
2464 '(:help "Post a uuencoded article"))]
2465 ["Followup via news" gnus-summary-followup-to-mail t]
2466 ["Followup via news and yank"
2467 gnus-summary-followup-to-mail-with-original t]
2469 ;;["Send" gnus-summary-send-draft t]
2470 ;;["Send bounced" gnus-resend-bounced-mail t])
2474 ((not (keymapp gnus-summary-post-menu))
2475 (setq gnus-article-post-menu gnus-summary-post-menu))
2476 ((not gnus-article-post-menu)
2477 ;; Don't share post menu.
2478 (setq gnus-article-post-menu
2479 (copy-keymap gnus-summary-post-menu))))
2480 (define-key gnus-article-mode-map [menu-bar post]
2481 (cons "Post" gnus-article-post-menu))
2484 gnus-summary-misc-menu gnus-summary-mode-map ""
2487 ["Mark as read" gnus-summary-mark-as-read-forward t]
2488 ["Mark same subject and select"
2489 gnus-summary-kill-same-subject-and-select t]
2490 ["Mark same subject" gnus-summary-kill-same-subject t]
2491 ["Catchup" gnus-summary-catchup
2492 ,@(if (featurep 'xemacs) '(t)
2493 '(:help "Mark unread articles in this group as read"))]
2494 ["Catchup all" gnus-summary-catchup-all t]
2495 ["Catchup to here" gnus-summary-catchup-to-here t]
2496 ["Catchup from here" gnus-summary-catchup-from-here t]
2497 ["Catchup region" gnus-summary-mark-region-as-read
2498 (gnus-mark-active-p)]
2499 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2501 ["Tick" gnus-summary-tick-article-forward t]
2502 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2503 ["Remove marks" gnus-summary-clear-mark-forward t]
2504 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2505 ["Set bookmark" gnus-summary-set-bookmark t]
2506 ["Remove bookmark" gnus-summary-remove-bookmark t])
2508 ["Marks..." gnus-summary-limit-to-marks t]
2509 ["Subject..." gnus-summary-limit-to-subject t]
2510 ["Author..." gnus-summary-limit-to-author t]
2511 ["Recipient..." gnus-summary-limit-to-recipient t]
2512 ["Age..." gnus-summary-limit-to-age t]
2513 ["Extra..." gnus-summary-limit-to-extra t]
2514 ["Score..." gnus-summary-limit-to-score t]
2515 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2516 ["Unread" gnus-summary-limit-to-unread t]
2517 ["Unseen" gnus-summary-limit-to-unseen t]
2518 ["Replied" gnus-summary-limit-to-replied t]
2519 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2520 ["Next articles" gnus-summary-limit-to-articles t]
2521 ["Pop limit" gnus-summary-pop-limit t]
2522 ["Show dormant" gnus-summary-limit-include-dormant t]
2523 ["Hide childless dormant"
2524 gnus-summary-limit-exclude-childless-dormant t]
2525 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2526 ["Hide marked" gnus-summary-limit-exclude-marks t]
2527 ["Show expunged" gnus-summary-limit-include-expunged t])
2529 ["Set mark" gnus-summary-mark-as-processable t]
2530 ["Remove mark" gnus-summary-unmark-as-processable t]
2531 ["Remove all marks" gnus-summary-unmark-all-processable t]
2532 ["Invert marks" gnus-uu-invert-processable t]
2533 ["Mark above" gnus-uu-mark-over t]
2534 ["Mark series" gnus-uu-mark-series t]
2535 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2536 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2537 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2538 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2539 ["Mark all" gnus-uu-mark-all t]
2540 ["Mark buffer" gnus-uu-mark-buffer t]
2541 ["Mark sparse" gnus-uu-mark-sparse t]
2542 ["Mark thread" gnus-uu-mark-thread t]
2543 ["Unmark thread" gnus-uu-unmark-thread t]
2544 ("Process Mark Sets"
2545 ["Kill" gnus-summary-kill-process-mark t]
2546 ["Yank" gnus-summary-yank-process-mark
2547 gnus-newsgroup-process-stack]
2548 ["Save" gnus-summary-save-process-mark t]
2549 ["Run command on marked..." gnus-summary-universal-argument t]))
2551 ["Page forward" gnus-summary-next-page
2552 ,@(if (featurep 'xemacs) '(t)
2553 '(:help "Show next page of article"))]
2554 ["Page backward" gnus-summary-prev-page
2555 ,@(if (featurep 'xemacs) '(t)
2556 '(:help "Show previous page of article"))]
2557 ["Line forward" gnus-summary-scroll-up t])
2559 ["Next unread article" gnus-summary-next-unread-article t]
2560 ["Previous unread article" gnus-summary-prev-unread-article t]
2561 ["Next article" gnus-summary-next-article t]
2562 ["Previous article" gnus-summary-prev-article t]
2563 ["Next unread subject" gnus-summary-next-unread-subject t]
2564 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2565 ["Next article same subject" gnus-summary-next-same-subject t]
2566 ["Previous article same subject" gnus-summary-prev-same-subject t]
2567 ["First unread article" gnus-summary-first-unread-article t]
2568 ["Best unread article" gnus-summary-best-unread-article t]
2569 ["Go to subject number..." gnus-summary-goto-subject t]
2570 ["Go to article number..." gnus-summary-goto-article t]
2571 ["Go to the last article" gnus-summary-goto-last-article t]
2572 ["Pop article off history" gnus-summary-pop-article t])
2574 ["Sort by number" gnus-summary-sort-by-number t]
2575 ["Sort by author" gnus-summary-sort-by-author t]
2576 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2577 ["Sort by subject" gnus-summary-sort-by-subject t]
2578 ["Sort by date" gnus-summary-sort-by-date t]
2579 ["Sort by score" gnus-summary-sort-by-score t]
2580 ["Sort by lines" gnus-summary-sort-by-lines t]
2581 ["Sort by characters" gnus-summary-sort-by-chars t]
2582 ["Randomize" gnus-summary-sort-by-random t]
2583 ["Original sort" gnus-summary-sort-by-original t])
2585 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2586 ["Describe group" gnus-summary-describe-group t]
2587 ["Fetch charter" gnus-group-fetch-charter
2588 ,@(if (featurep 'xemacs) nil
2589 '(:help "Display the charter of the current group"))]
2590 ["Fetch control message" gnus-group-fetch-control
2591 ,@(if (featurep 'xemacs) nil
2592 '(:help "Display the archived control message for the current group"))]
2593 ["Read manual" gnus-info-find-node t])
2595 ["Pick and read" gnus-pick-mode t]
2596 ["Binary" gnus-binary-mode t])
2598 ["Regenerate" gnus-summary-prepare t]
2599 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2600 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2601 ["Toggle threading" gnus-summary-toggle-threads t])
2602 ["See old articles" gnus-summary-insert-old-articles t]
2603 ["See new articles" gnus-summary-insert-new-articles t]
2604 ["Filter articles..." gnus-summary-execute-command t]
2605 ["Run command on articles..." gnus-summary-universal-argument t]
2606 ["Search articles forward..." gnus-summary-search-article-forward t]
2607 ["Search articles backward..." gnus-summary-search-article-backward t]
2608 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2609 ["Expand window" gnus-summary-expand-window t]
2610 ["Expire expirable articles" gnus-summary-expire-articles
2611 (gnus-check-backend-function
2612 'request-expire-articles gnus-newsgroup-name)]
2613 ["Edit local kill file" gnus-summary-edit-local-kill t]
2614 ["Edit main kill file" gnus-summary-edit-global-kill t]
2615 ["Edit group parameters" gnus-summary-edit-parameters t]
2616 ["Customize group parameters" gnus-summary-customize-parameters t]
2617 ["Send a bug report" gnus-bug t]
2619 ["Catchup and exit" gnus-summary-catchup-and-exit
2620 ,@(if (featurep 'xemacs) '(t)
2621 '(:help "Mark unread articles in this group as read, then exit"))]
2622 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2623 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2624 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2625 ["Exit group" gnus-summary-exit
2626 ,@(if (featurep 'xemacs) '(t)
2627 '(:help "Exit current group, return to group selection mode"))]
2628 ["Exit group without updating" gnus-summary-exit-no-update t]
2629 ["Exit and goto next group" gnus-summary-next-group t]
2630 ["Exit and goto prev group" gnus-summary-prev-group t]
2631 ["Reselect group" gnus-summary-reselect-current-group t]
2632 ["Rescan group" gnus-summary-rescan-group t]
2633 ["Update dribble" gnus-summary-save-newsrc t])))
2635 (gnus-run-hooks 'gnus-summary-menu-hook)))
2637 (defvar gnus-summary-tool-bar-map nil)
2639 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2640 ;; affect _new_ message buffers. We might add a function that walks thru all
2641 ;; summary-mode buffers and force the update.
2642 (defun gnus-summary-tool-bar-update (&optional symbol value)
2643 "Update summary mode toolbar.
2644 Setter function for custom variables."
2645 (setq-default gnus-summary-tool-bar-map nil)
2647 ;; When used as ":set" function:
2648 (set-default symbol value))
2649 (when (gnus-buffer-live-p gnus-summary-buffer)
2650 (with-current-buffer gnus-summary-buffer
2651 (gnus-summary-make-tool-bar))))
2653 ;; The default will be changed when the new icons have been checked in:
2654 (defcustom gnus-summary-tool-bar 'gnus-summary-tool-bar-retro
2655 "Specifies the Gnus summary tool bar.
2657 It can be either a list or a symbol refering to a list. See
2658 `gmm-tool-bar-from-list' for the format of the list. The
2659 default key map is `gnus-summary-mode-map'.
2661 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2662 `gnus-summary-tool-bar-retro'."
2663 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2664 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2665 (repeat :tag "User defined list" gmm-tool-bar-item)
2667 :version "23.0" ;; No Gnus
2668 :initialize 'custom-initialize-default
2669 :set 'gnus-summary-tool-bar-update
2670 :group 'gnus-summary)
2672 (defcustom gnus-summary-tool-bar-gnome
2673 '((gnus-summary-post-news "compose" nil)
2674 (gnus-summary-reply-with-original "reply-author")
2675 (gnus-summary-reply "reply-author" nil :visible nil)
2676 (gnus-summary-followup-with-original "reply-all")
2677 (gnus-summary-followup "reply-all" nil :visible nil)
2678 (gnus-summary-mail-forward "forward")
2679 (gnus-summary-save-article "save") ;; stock_mail-copy
2680 (gnus-summary-search-article-forward "search")
2681 (gnus-summary-print-article "print")
2682 (gnus-summary-mark-as-expirable
2684 :visible (gnus-check-backend-function 'request-expire-articles
2685 gnus-newsgroup-name))
2686 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2687 (gnus-summary-mark-as-spam
2688 "spam" t :visible (spam-group-ham-contents-p gnus-newsgroup-name)
2689 :help "Mark as spam")
2690 (gnus-summary-mark-as-read-forward
2691 "not-spam" nil :visible (spam-group-spam-contents-p gnus-newsgroup-name))
2692 ;; Some new commands that may need more suitable icons:
2693 (gnus-summary-save-newsrc "save" nil :visible nil)
2694 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2695 (gnus-summary-prev-article "left-arrow" nil :visible nil) ;; Emacs 22
2696 (gnus-summary-next-article "right-arrow" nil :visible nil) ;; Emacs 22
2697 (gnus-summary-prev-unread-article "prev-node") ;; Emacs 22
2698 (gnus-summary-next-unread-article "next-node") ;; Emacs 22
2699 (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2701 ;; Maybe some sort-by-... could be added:
2702 (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2703 (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2705 (gnus-summary-insert-new-articles "inbox")
2707 (gnus-summary-exit "exit-mode")
2708 ;; (customize-group 'gnus-summary) "preferences"
2709 (gnus-info-find-node "help"))
2710 "List of functions for the summary tool bar (GNOME style).
2712 See `gmm-tool-bar-from-list' for the format of the list."
2713 :type '(repeat gmm-tool-bar-item)
2714 :version "23.0" ;; No Gnus
2715 :initialize 'custom-initialize-default
2716 :set 'gnus-summary-tool-bar-update
2717 :group 'gnus-summary)
2719 (defcustom gnus-summary-tool-bar-retro
2720 '((gnus-summary-prev-unread-article "prev-ur")
2721 (gnus-summary-next-unread-article "next-ur")
2722 (gnus-summary-post-news "post")
2723 (gnus-summary-followup-with-original "fuwo")
2724 (gnus-summary-followup "followup")
2725 (gnus-summary-reply-with-original "reply-wo")
2726 (gnus-summary-reply "reply")
2727 (gnus-summary-caesar-message "rot13")
2728 (gnus-uu-decode-uu "uu-decode")
2729 (gnus-summary-save-article-file "save-aif")
2730 (gnus-summary-save-article "save-art")
2731 (gnus-uu-post-news "uu-post")
2732 (gnus-summary-catchup "catchup")
2733 (gnus-summary-catchup-and-exit "cu-exit")
2734 (gnus-summary-exit "exit-summ")
2735 ;; Some new command that may need more suitable icons:
2736 (gnus-summary-print-article "print" nil :visible nil)
2737 (gnus-summary-mark-as-expirable "close" nil :visible nil)
2738 (gnus-summary-save-newsrc "save" nil :visible nil)
2739 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2740 (gnus-summary-search-article-forward "search" nil :visible nil)
2741 ;; (gnus-summary-insert-new-articles "paste" nil :visible nil)
2742 ;; (gnus-summary-toggle-threads "open" nil :visible nil)
2744 (gnus-info-find-node "help" nil :visible nil))
2745 "List of functions for the summary tool bar (retro look).
2747 See `gmm-tool-bar-from-list' for the format of the list."
2748 :type '(repeat gmm-tool-bar-item)
2749 :version "23.0" ;; No Gnus
2750 :initialize 'custom-initialize-default
2751 :set 'gnus-summary-tool-bar-update
2752 :group 'gnus-summary)
2754 (defcustom gnus-summary-tool-bar-zap-list t
2755 "List of icon items from the global tool bar.
2756 These items are not displayed in the Gnus summary mode tool bar.
2758 See `gmm-tool-bar-from-list' for the format of the list."
2759 :type 'gmm-tool-bar-zap-list
2760 :version "23.0" ;; No Gnus
2761 :initialize 'custom-initialize-default
2762 :set 'gnus-summary-tool-bar-update
2763 :group 'gnus-summary)
2765 (defun gnus-summary-make-tool-bar (&optional force)
2766 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2767 When FORCE, rebuild the tool bar."
2768 (when (and (not (featurep 'xemacs))
2769 (boundp 'tool-bar-mode)
2771 (or (not gnus-summary-tool-bar-map) force))
2772 (let* ((load-path (mm-image-load-path))
2773 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2774 gnus-summary-tool-bar-zap-list
2775 'gnus-summary-mode-map)))
2777 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2779 (setq gnus-summary-tool-bar-map map))))
2780 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2782 (defun gnus-score-set-default (var value)
2783 "A version of set that updates the GNU Emacs menu-bar."
2785 ;; It is the message that forces the active status to be updated.
2788 (defun gnus-make-score-map (type)
2789 "Make a summary score map of type TYPE."
2792 (let ((headers '(("author" "from" string)
2793 ("subject" "subject" string)
2794 ("article body" "body" string)
2795 ("article head" "head" string)
2796 ("xref" "xref" string)
2797 ("extra header" "extra" string)
2798 ("lines" "lines" number)
2799 ("followups to author" "followup" string)))
2800 (types '((number ("less than" <)
2803 (string ("substring" s)
2807 (perms '(("temporary" (current-time-string))
2815 (if (eq type 'lower)
2820 (setq header (car headers))
2826 (let ((ts (cdr (assoc (nth 2 header) types)))
2842 'gnus-summary-score-entry
2844 (if (or (string= (nth 1 header)
2846 (string= (nth 1 header)
2849 (list 'gnus-summary-header
2851 (list 'quote (nth 1 (car ts)))
2852 (list 'gnus-score-delta-default
2859 (list (nreverse outp))))
2862 (list (nreverse outt))))
2864 (setq headers (cdr headers)))
2865 (list (nreverse outh))))))))
2869 (defun gnus-summary-mode (&optional group)
2870 "Major mode for reading articles.
2872 All normal editing commands are switched off.
2873 \\<gnus-summary-mode-map>
2874 Each line in this buffer represents one article. To read an
2875 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2876 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2879 You can also post articles and send mail from this buffer. To
2880 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2881 of an article, type `\\[gnus-summary-reply]'.
2883 There are approx. one gazillion commands you can execute in this
2884 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2886 The following commands are available:
2888 \\{gnus-summary-mode-map}"
2890 (kill-all-local-variables)
2891 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2892 (gnus-summary-make-local-variables))
2893 (gnus-summary-make-local-variables)
2894 (setq gnus-newsgroup-name group)
2895 (when (gnus-visual-p 'summary-menu 'menu)
2896 (gnus-summary-make-menu-bar)
2897 (gnus-summary-make-tool-bar))
2898 (gnus-make-thread-indent-array)
2899 (gnus-simplify-mode-line)
2900 (setq major-mode 'gnus-summary-mode)
2901 (setq mode-name "Summary")
2902 (make-local-variable 'minor-mode-alist)
2903 (use-local-map gnus-summary-mode-map)
2904 (buffer-disable-undo)
2905 (setq buffer-read-only t ;Disable modification
2906 show-trailing-whitespace nil)
2907 (setq truncate-lines t)
2908 (setq selective-display t)
2909 (setq selective-display-ellipses t) ;Display `...'
2910 (gnus-summary-set-display-table)
2911 (gnus-set-default-directory)
2912 (make-local-variable 'gnus-summary-line-format)
2913 (make-local-variable 'gnus-summary-line-format-spec)
2914 (make-local-variable 'gnus-summary-dummy-line-format)
2915 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2916 (make-local-variable 'gnus-summary-mark-positions)
2917 (gnus-make-local-hook 'pre-command-hook)
2918 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2919 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2920 (turn-on-gnus-mailing-list-mode)
2921 (mm-enable-multibyte)
2922 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2923 (gnus-update-summary-mark-positions))
2925 (defun gnus-summary-make-local-variables ()
2926 "Make all the local summary buffer variables."
2928 (dolist (local gnus-summary-local-variables)
2931 (if (eq (cdr local) 'global)
2932 ;; Copy the global value of the variable.
2933 (setq global (symbol-value (car local)))
2934 ;; Use the value from the list.
2935 (setq global (eval (cdr local))))
2936 (set (make-local-variable (car local)) global))
2937 ;; Simple nil-valued local variable.
2938 (set (make-local-variable local) nil)))))
2940 (defun gnus-summary-clear-local-variables ()
2941 (let ((locals gnus-summary-local-variables))
2943 (if (consp (car locals))
2944 (and (symbolp (caar locals))
2945 (set (caar locals) nil))
2946 (and (symbolp (car locals))
2947 (set (car locals) nil)))
2948 (setq locals (cdr locals)))))
2950 ;; Summary data functions.
2952 (defmacro gnus-data-number (data)
2955 (defmacro gnus-data-set-number (data number)
2956 `(setcar ,data ,number))
2958 (defmacro gnus-data-mark (data)
2961 (defmacro gnus-data-set-mark (data mark)
2962 `(setcar (nthcdr 1 ,data) ,mark))
2964 (defmacro gnus-data-pos (data)
2967 (defmacro gnus-data-set-pos (data pos)
2968 `(setcar (nthcdr 2 ,data) ,pos))
2970 (defmacro gnus-data-header (data)
2973 (defmacro gnus-data-set-header (data header)
2974 `(setf (nth 3 ,data) ,header))
2976 (defmacro gnus-data-level (data)
2979 (defmacro gnus-data-unread-p (data)
2980 `(= (nth 1 ,data) gnus-unread-mark))
2982 (defmacro gnus-data-read-p (data)
2983 `(/= (nth 1 ,data) gnus-unread-mark))
2985 (defmacro gnus-data-pseudo-p (data)
2986 `(consp (nth 3 ,data)))
2988 (defmacro gnus-data-find (number)
2989 `(assq ,number gnus-newsgroup-data))
2991 (defmacro gnus-data-find-list (number &optional data)
2992 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2993 (memq (assq ,number bdata)
2996 (defmacro gnus-data-make (number mark pos header level)
2997 `(list ,number ,mark ,pos ,header ,level))
2999 (defun gnus-data-enter (after-article number mark pos header level offset)
3000 (let ((data (gnus-data-find-list after-article)))
3002 (error "No such article: %d" after-article))
3003 (setcdr data (cons (gnus-data-make number mark pos header level)
3005 (setq gnus-newsgroup-data-reverse nil)
3006 (gnus-data-update-list (cddr data) offset)))
3008 (defun gnus-data-enter-list (after-article list &optional offset)
3010 (let ((data (and after-article (gnus-data-find-list after-article)))
3014 (let ((odata gnus-newsgroup-data))
3015 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3017 (gnus-data-update-list odata offset)))
3018 ;; Find the last element in the list to be spliced into the main
3020 (setq list (last list))
3023 (setcdr list gnus-newsgroup-data)
3024 (setq gnus-newsgroup-data ilist)
3026 (gnus-data-update-list (cdr list) offset)))
3027 (setcdr list (cdr data))
3030 (gnus-data-update-list (cdr list) offset))))
3031 (setq gnus-newsgroup-data-reverse nil))))
3033 (defun gnus-data-remove (article &optional offset)
3034 (let ((data gnus-newsgroup-data))
3035 (if (= (gnus-data-number (car data)) article)
3037 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3038 gnus-newsgroup-data-reverse nil)
3040 (gnus-data-update-list gnus-newsgroup-data offset)))
3042 (when (= (gnus-data-number (cadr data)) article)
3043 (setcdr data (cddr data))
3045 (gnus-data-update-list (cdr data) offset))
3047 gnus-newsgroup-data-reverse nil))
3048 (setq data (cdr data))))))
3050 (defmacro gnus-data-list (backward)
3052 (or gnus-newsgroup-data-reverse
3053 (setq gnus-newsgroup-data-reverse
3054 (reverse gnus-newsgroup-data)))
3055 gnus-newsgroup-data))
3057 (defun gnus-data-update-list (data offset)
3058 "Add OFFSET to the POS of all data entries in DATA."
3059 (setq gnus-newsgroup-data-reverse nil)
3061 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3062 (setq data (cdr data))))
3064 (defun gnus-summary-article-pseudo-p (article)
3065 "Say whether this article is a pseudo article or not."
3066 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3068 (defmacro gnus-summary-article-sparse-p (article)
3069 "Say whether this article is a sparse article or not."
3070 `(memq ,article gnus-newsgroup-sparse))
3072 (defmacro gnus-summary-article-ancient-p (article)
3073 "Say whether this article is a sparse article or not."
3074 `(memq ,article gnus-newsgroup-ancient))
3076 (defun gnus-article-parent-p (number)
3077 "Say whether this article is a parent or not."
3078 (let ((data (gnus-data-find-list number)))
3079 (and (cdr data) ; There has to be an article after...
3080 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3081 (gnus-data-level (nth 1 data))))))
3083 (defun gnus-article-children (number)
3084 "Return a list of all children to NUMBER."
3085 (let* ((data (gnus-data-find-list number))
3086 (level (gnus-data-level (car data)))
3088 (setq data (cdr data))
3090 (= (gnus-data-level (car data)) (1+ level)))
3091 (push (gnus-data-number (car data)) children)
3092 (setq data (cdr data)))
3095 (defmacro gnus-summary-skip-intangible ()
3096 "If the current article is intangible, then jump to a different article."
3097 '(let ((to (get-text-property (point) 'gnus-intangible)))
3098 (and to (gnus-summary-goto-subject to))))
3100 (defmacro gnus-summary-article-intangible-p ()
3101 "Say whether this article is intangible or not."
3102 '(get-text-property (point) 'gnus-intangible))
3104 (defun gnus-article-read-p (article)
3105 "Say whether ARTICLE is read or not."
3106 (not (or (memq article gnus-newsgroup-marked)
3107 (memq article gnus-newsgroup-spam-marked)
3108 (memq article gnus-newsgroup-unreads)
3109 (memq article gnus-newsgroup-unselected)
3110 (memq article gnus-newsgroup-dormant))))
3112 ;; Some summary mode macros.
3114 (defmacro gnus-summary-article-number ()
3115 "The article number of the article on the current line.
3116 If there isn't an article number here, then we return the current
3119 (gnus-summary-skip-intangible)
3120 (or (get-text-property (point) 'gnus-number)
3121 (gnus-summary-last-subject))))
3123 (defmacro gnus-summary-article-header (&optional number)
3124 "Return the header of article NUMBER."
3125 `(gnus-data-header (gnus-data-find
3126 ,(or number '(gnus-summary-article-number)))))
3128 (defmacro gnus-summary-thread-level (&optional number)
3129 "Return the level of thread that starts with article NUMBER."
3130 `(if (and (eq gnus-summary-make-false-root 'dummy)
3131 (get-text-property (point) 'gnus-intangible))
3133 (gnus-data-level (gnus-data-find
3134 ,(or number '(gnus-summary-article-number))))))
3136 (defmacro gnus-summary-article-mark (&optional number)
3137 "Return the mark of article NUMBER."
3138 `(gnus-data-mark (gnus-data-find
3139 ,(or number '(gnus-summary-article-number)))))
3141 (defmacro gnus-summary-article-pos (&optional number)
3142 "Return the position of the line of article NUMBER."
3143 `(gnus-data-pos (gnus-data-find
3144 ,(or number '(gnus-summary-article-number)))))
3146 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3147 (defmacro gnus-summary-article-subject (&optional number)
3148 "Return current subject string or nil if nothing."
3151 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3152 '(gnus-data-header (assq (gnus-summary-article-number)
3153 gnus-newsgroup-data)))))
3156 (mail-header-subject headers))))
3158 (defmacro gnus-summary-article-score (&optional number)
3159 "Return current article score."
3160 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3161 gnus-newsgroup-scored))
3162 gnus-summary-default-score 0))
3164 (defun gnus-summary-article-children (&optional number)
3165 "Return a list of article numbers that are children of article NUMBER."
3166 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3167 (level (gnus-data-level (car data)))
3169 (while (and (setq data (cdr data))
3170 (> (setq l (gnus-data-level (car data))) level))
3171 (and (= (1+ level) l)
3172 (push (gnus-data-number (car data))
3174 (nreverse children)))
3176 (defun gnus-summary-article-parent (&optional number)
3177 "Return the article number of the parent of article NUMBER."
3178 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3179 (gnus-data-list t)))
3180 (level (gnus-data-level (car data))))
3182 () ; This is a root.
3183 ;; We search until we find an article with a level less than
3184 ;; this one. That function has to be the parent.
3185 (while (and (setq data (cdr data))
3186 (not (< (gnus-data-level (car data)) level))))
3187 (and data (gnus-data-number (car data))))))
3189 (defun gnus-unread-mark-p (mark)
3190 "Say whether MARK is the unread mark."
3191 (= mark gnus-unread-mark))
3193 (defun gnus-read-mark-p (mark)
3194 "Say whether MARK is one of the marks that mark as read.
3195 This is all marks except unread, ticked, dormant, and expirable."
3196 (not (or (= mark gnus-unread-mark)
3197 (= mark gnus-ticked-mark)
3198 (= mark gnus-spam-mark)
3199 (= mark gnus-dormant-mark)
3200 (= mark gnus-expirable-mark))))
3202 (defmacro gnus-article-mark (number)
3203 "Return the MARK of article NUMBER.
3204 This macro should only be used when computing the mark the \"first\"
3205 time; i.e., when generating the summary lines. After that,
3206 `gnus-summary-article-mark' should be used to examine the
3209 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3210 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3211 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3212 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3213 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3214 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3215 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3216 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3217 gnus-ancient-mark))))
3219 ;; Saving hidden threads.
3221 (defmacro gnus-save-hidden-threads (&rest forms)
3222 "Save hidden threads, eval FORMS, and restore the hidden threads."
3223 (let ((config (make-symbol "config")))
3224 `(let ((,config (gnus-hidden-threads-configuration)))
3228 (gnus-restore-hidden-threads-configuration ,config)))))
3229 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3230 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3232 (defun gnus-data-compute-positions ()
3233 "Compute the positions of all articles."
3234 (setq gnus-newsgroup-data-reverse nil)
3235 (let ((data gnus-newsgroup-data))
3237 (gnus-save-hidden-threads
3238 (gnus-summary-show-all-threads)
3239 (goto-char (point-min))
3241 (while (get-text-property (point) 'gnus-intangible)
3243 (gnus-data-set-pos (car data) (+ (point) 3))
3244 (setq data (cdr data))
3245 (forward-line 1))))))
3247 (defun gnus-hidden-threads-configuration ()
3248 "Return the current hidden threads configuration."
3251 (goto-char (point-min))
3252 (while (search-forward "\r" nil t)
3253 (push (1- (point)) config))
3256 (defun gnus-restore-hidden-threads-configuration (config)
3257 "Restore hidden threads configuration from CONFIG."
3259 (let (point buffer-read-only)
3260 (while (setq point (pop config))
3261 (when (and (< point (point-max))
3263 (eq (char-after) ?\n))
3264 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3266 ;; Various summary mode internalish functions.
3268 (defun gnus-mouse-pick-article (e)
3271 (gnus-summary-next-page nil t))
3273 (defun gnus-summary-set-display-table ()
3274 "Change the display table.
3275 Odd characters have a tendency to mess
3276 up nicely formatted displays - we make all possible glyphs
3277 display only a single character."
3279 ;; We start from the standard display table, if any.
3280 (let ((table (or (copy-sequence standard-display-table)
3281 (make-display-table)))
3283 ;; Nix out all the control chars...
3284 (while (>= (setq i (1- i)) 0)
3285 (aset table i [??]))
3286 ;; ... but not newline and cr, of course. (cr is necessary for the
3287 ;; selective display).
3288 (aset table ?\n nil)
3289 (aset table ?\r nil)
3290 ;; We keep TAB as well.
3291 (aset table ?\t nil)
3292 ;; We nix out any glyphs over 126 that are not set already.
3294 (while (>= (setq i (1- i)) 127)
3295 ;; Only modify if the entry is nil.
3296 (unless (aref table i)
3297 (aset table i [??]))))
3298 (setq buffer-display-table table)))
3300 (defun gnus-summary-set-article-display-arrow (pos)
3301 "Update the overlay arrow to point to line at position POS."
3302 (when (and gnus-summary-display-arrow
3303 (boundp 'overlay-arrow-position)
3304 (boundp 'overlay-arrow-string))
3308 (unless overlay-arrow-position
3309 (setq overlay-arrow-position (make-marker)))
3310 (setq overlay-arrow-string "=>"
3311 overlay-arrow-position (set-marker overlay-arrow-position
3313 (current-buffer))))))
3315 (defun gnus-summary-setup-buffer (group)
3316 "Initialize summary buffer."
3317 (let ((buffer (gnus-summary-buffer-name group))
3318 (dead-name (concat "*Dead Summary "
3319 (gnus-group-decoded-name group) "*")))
3320 ;; If a dead summary buffer exists, we kill it.
3321 (when (gnus-buffer-live-p dead-name)
3322 (gnus-kill-buffer dead-name))
3323 (if (get-buffer buffer)
3326 (setq gnus-summary-buffer (current-buffer))
3327 (not gnus-newsgroup-prepared))
3328 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3329 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3330 (gnus-summary-mode group)
3332 (gnus-carpal-setup-buffer 'summary))
3333 (unless gnus-single-article-buffer
3334 (make-local-variable 'gnus-article-buffer)
3335 (make-local-variable 'gnus-article-current)
3336 (make-local-variable 'gnus-original-article-buffer))
3337 (setq gnus-newsgroup-name group)
3338 ;; Set any local variables in the group parameters.
3339 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3342 (defun gnus-set-global-variables ()
3343 "Set the global equivalents of the buffer-local variables.
3344 They are set to the latest values they had. These reflect the summary
3345 buffer that was in action when the last article was fetched."
3346 (when (eq major-mode 'gnus-summary-mode)
3347 (setq gnus-summary-buffer (current-buffer))
3348 (let ((name gnus-newsgroup-name)
3349 (marked gnus-newsgroup-marked)
3350 (spam gnus-newsgroup-spam-marked)
3351 (unread gnus-newsgroup-unreads)
3352 (headers gnus-current-headers)
3353 (data gnus-newsgroup-data)
3354 (summary gnus-summary-buffer)
3355 (article-buffer gnus-article-buffer)
3356 (original gnus-original-article-buffer)
3357 (gac gnus-article-current)
3358 (reffed gnus-reffed-article-number)
3359 (score-file gnus-current-score-file)
3360 (default-charset gnus-newsgroup-charset)
3362 (let ((locals gnus-newsgroup-variables))
3364 (if (consp (car locals))
3365 (push (eval (caar locals)) vlist)
3366 (push (eval (car locals)) vlist))
3367 (setq locals (cdr locals)))
3368 (setq vlist (nreverse vlist)))
3369 (with-current-buffer gnus-group-buffer
3370 (setq gnus-newsgroup-name name
3371 gnus-newsgroup-marked marked
3372 gnus-newsgroup-spam-marked spam
3373 gnus-newsgroup-unreads unread
3374 gnus-current-headers headers
3375 gnus-newsgroup-data data
3376 gnus-article-current gac
3377 gnus-summary-buffer summary
3378 gnus-article-buffer article-buffer
3379 gnus-original-article-buffer original
3380 gnus-reffed-article-number reffed
3381 gnus-current-score-file score-file
3382 gnus-newsgroup-charset default-charset)
3383 (let ((locals gnus-newsgroup-variables))
3385 (if (consp (car locals))
3386 (set (caar locals) (pop vlist))
3387 (set (car locals) (pop vlist)))
3388 (setq locals (cdr locals))))
3389 ;; The article buffer also has local variables.
3390 (when (gnus-buffer-live-p gnus-article-buffer)
3391 (set-buffer gnus-article-buffer)
3392 (setq gnus-summary-buffer summary))))))
3394 (defun gnus-summary-article-unread-p (article)
3395 "Say whether ARTICLE is unread or not."
3396 (memq article gnus-newsgroup-unreads))
3398 (defun gnus-summary-first-article-p (&optional article)
3399 "Return whether ARTICLE is the first article in the buffer."
3400 (if (not (setq article (or article (gnus-summary-article-number))))
3402 (eq article (caar gnus-newsgroup-data))))
3404 (defun gnus-summary-last-article-p (&optional article)
3405 "Return whether ARTICLE is the last article in the buffer."
3406 (if (not (setq article (or article (gnus-summary-article-number))))
3407 ;; All non-existent numbers are the last article. :-)
3409 (not (cdr (gnus-data-find-list article)))))
3411 (defun gnus-make-thread-indent-array ()
3413 (unless (and gnus-thread-indent-array
3414 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3415 (setq gnus-thread-indent-array (make-vector 201 "")
3416 gnus-thread-indent-array-level gnus-thread-indent-level)
3418 (aset gnus-thread-indent-array n
3419 (make-string (* n gnus-thread-indent-level) ? ))
3422 (defun gnus-update-summary-mark-positions ()
3423 "Compute where the summary marks are to go."
3425 (when (gnus-buffer-exists-p gnus-summary-buffer)
3426 (set-buffer gnus-summary-buffer))
3427 (let ((spec gnus-summary-line-format-spec)
3430 (gnus-set-work-buffer)
3431 (let ((gnus-tmp-unread ?Z)
3432 (gnus-replied-mark ?Z)
3433 (gnus-score-below-mark ?Z)
3434 (gnus-score-over-mark ?Z)
3435 (gnus-undownloaded-mark ?Z)
3436 (gnus-summary-line-format-spec spec)
3437 (gnus-newsgroup-downloadable '(0))
3438 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3439 case-fold-search ignores)
3440 ;; Here, all marks are bound to Z.
3441 (gnus-summary-insert-line header
3442 0 nil t gnus-tmp-unread t nil "" nil 1)
3443 (goto-char (point-min))
3444 ;; Memorize the positions of the same characters as dummy marks.
3445 (while (re-search-forward "[A-D]" nil t)
3446 (push (point) ignores))
3448 ;; We use A-D as dummy marks in order to know column positions
3449 ;; where marks should be inserted.
3450 (setq gnus-tmp-unread ?A
3451 gnus-replied-mark ?B
3452 gnus-score-below-mark ?C
3453 gnus-score-over-mark ?C
3454 gnus-undownloaded-mark ?D)
3455 (gnus-summary-insert-line header
3456 0 nil t gnus-tmp-unread t nil "" nil 1)
3457 ;; Ignore characters which aren't dummy marks.
3459 (delete-region (goto-char (1- p)) p)
3461 (goto-char (point-min))
3462 (setq pos (list (cons 'unread
3463 (and (search-forward "A" nil t)
3464 (- (point) (point-min) 1)))))
3465 (goto-char (point-min))
3466 (push (cons 'replied (and (search-forward "B" nil t)
3467 (- (point) (point-min) 1)))
3469 (goto-char (point-min))
3470 (push (cons 'score (and (search-forward "C" nil t)
3471 (- (point) (point-min) 1)))
3473 (goto-char (point-min))
3474 (push (cons 'download (and (search-forward "D" nil t)
3475 (- (point) (point-min) 1)))
3477 (setq gnus-summary-mark-positions pos))))
3479 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3480 "Insert a dummy root in the summary buffer."
3482 (gnus-add-text-properties
3483 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3484 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3486 (defun gnus-summary-extract-address-component (from)
3487 (or (car (funcall gnus-extract-address-components from))
3490 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3491 (let ((mail-parse-charset gnus-newsgroup-charset)
3492 ; Is it really necessary to do this next part for each summary line?
3493 ; Luckily, doesn't seem to slow things down much.
3494 (mail-parse-ignored-charsets
3495 (with-current-buffer gnus-summary-buffer
3496 gnus-newsgroup-ignored-charsets)))
3498 (and gnus-ignored-from-addresses
3499 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3500 (let ((extra-headers (mail-header-extra header))
3504 ((setq to (cdr (assq 'To extra-headers)))
3505 (concat gnus-summary-to-prefix
3507 (gnus-summary-extract-address-component
3508 (funcall gnus-decode-encoded-word-function to)))))
3509 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3510 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3511 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3513 (defun gnus-summary-insert-line (gnus-tmp-header
3514 gnus-tmp-level gnus-tmp-current
3515 undownloaded gnus-tmp-unread gnus-tmp-replied
3516 gnus-tmp-expirable gnus-tmp-subject-or-nil
3517 &optional gnus-tmp-dummy gnus-tmp-score
3519 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3520 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3521 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3522 (gnus-tmp-score-char
3523 (if (or (null gnus-summary-default-score)
3524 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3525 gnus-summary-zcore-fuzz))
3527 (if (< gnus-tmp-score gnus-summary-default-score)
3528 gnus-score-below-mark gnus-score-over-mark)))
3529 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3531 (cond (gnus-tmp-process gnus-process-mark)
3532 ((memq gnus-tmp-current gnus-newsgroup-cached)
3534 (gnus-tmp-replied gnus-replied-mark)
3535 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3536 gnus-forwarded-mark)
3537 ((memq gnus-tmp-current gnus-newsgroup-saved)
3539 ((memq gnus-tmp-number gnus-newsgroup-recent)
3541 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3544 (gnus-tmp-downloaded
3546 gnus-undownloaded-mark)
3547 (gnus-newsgroup-agentized
3548 gnus-downloaded-mark)
3551 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3554 ((string-match "<[^>]+> *$" gnus-tmp-from)
3555 (let ((beg (match-beginning 0)))
3556 (or (and (string-match "^\".+\"" gnus-tmp-from)
3557 (substring gnus-tmp-from 1 (1- (match-end 0))))
3558 (substring gnus-tmp-from 0 beg))))
3559 ((string-match "(.+)" gnus-tmp-from)
3560 (substring gnus-tmp-from
3561 (1+ (match-beginning 0)) (1- (match-end 0))))
3563 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3564 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3565 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3566 (buffer-read-only nil))
3567 (when (string= gnus-tmp-name "")
3568 (setq gnus-tmp-name gnus-tmp-from))
3569 (unless (numberp gnus-tmp-lines)
3570 (setq gnus-tmp-lines -1))
3571 (if (= gnus-tmp-lines -1)
3572 (setq gnus-tmp-lines "?")
3573 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3574 (gnus-put-text-property
3576 (progn (eval gnus-summary-line-format-spec) (point))
3577 'gnus-number gnus-tmp-number)
3578 (when (gnus-visual-p 'summary-highlight 'highlight)
3580 (gnus-run-hooks 'gnus-summary-update-hook)
3583 (defun gnus-summary-update-line (&optional dont-update)
3584 "Update summary line after change."
3585 (when (and gnus-summary-default-score
3586 (not gnus-summary-inhibit-highlight))
3587 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3588 (article (gnus-summary-article-number))
3589 (score (gnus-summary-article-score article)))
3591 (if (and gnus-summary-mark-below
3592 (< (gnus-summary-article-score)
3593 gnus-summary-mark-below))
3594 ;; This article has a low score, so we mark it as read.
3595 (when (memq article gnus-newsgroup-unreads)
3596 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3597 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3598 ;; This article was previously marked as read on account
3599 ;; of a low score, but now it has risen, so we mark it as
3601 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3602 (gnus-summary-update-mark
3603 (if (or (null gnus-summary-default-score)
3604 (<= (abs (- score gnus-summary-default-score))
3605 gnus-summary-zcore-fuzz))
3607 (if (< score gnus-summary-default-score)
3608 gnus-score-below-mark gnus-score-over-mark))
3610 ;; Do visual highlighting.
3611 (when (gnus-visual-p 'summary-highlight 'highlight)
3612 (gnus-run-hooks 'gnus-summary-update-hook)))))
3614 (defvar gnus-tmp-new-adopts nil)
3616 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3617 "Return the number of articles in THREAD.
3618 This may be 0 in some cases -- if none of the articles in
3619 the thread are to be displayed."
3621 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3623 ((not (listp thread))
3625 ((and (consp thread) (cdr thread))
3628 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3631 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3634 (when (and level (zerop level) gnus-tmp-new-adopts)
3637 'gnus-summary-number-of-articles-in-thread
3638 gnus-tmp-new-adopts))))
3640 (if (> number 1) gnus-not-empty-thread-mark
3641 gnus-empty-thread-mark)
3644 (defsubst gnus-summary-line-message-size (head)
3645 "Return pretty-printed version of message size.
3646 This function is intended to be used in
3647 `gnus-summary-line-format-alist'."
3648 (let ((c (or (mail-header-chars head) -1)))
3649 (cond ((< c 0) "n/a") ; chars not available
3650 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3651 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3652 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3653 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3656 (defun gnus-summary-set-local-parameters (group)
3657 "Go through the local params of GROUP and set all variable specs in that list."
3658 (let ((vars '(quit-config))) ; Ignore quit-config.
3659 (dolist (elem (gnus-group-find-parameter group))
3660 (and (consp elem) ; Has to be a cons.
3661 (consp (cdr elem)) ; The cdr has to be a list.
3662 (symbolp (car elem)) ; Has to be a symbol in there.
3663 (not (memq (car elem) vars))
3664 (ignore-errors ; So we set it.
3665 (push (car elem) vars)
3666 (make-local-variable (car elem))
3667 (set (car elem) (eval (nth 1 elem))))))))
3669 (defun gnus-summary-read-group (group &optional show-all no-article
3670 kill-buffer no-display backward
3672 "Start reading news in newsgroup GROUP.
3673 If SHOW-ALL is non-nil, already read articles are also listed.
3674 If NO-ARTICLE is non-nil, no article is selected initially.
3675 If NO-DISPLAY, don't generate a summary buffer."
3679 (let ((gnus-auto-select-next nil))
3680 (or (gnus-summary-read-group-1
3681 group show-all no-article
3682 kill-buffer no-display
3685 select-articles nil)))))
3686 (eq gnus-auto-select-next 'quietly))
3687 (set-buffer gnus-group-buffer)
3688 ;; The entry function called above goes to the next
3689 ;; group automatically, so we go two groups back
3690 ;; if we are searching for the previous group.
3692 (gnus-group-prev-unread-group 2))
3693 (if (not (equal group (gnus-group-group-name)))
3694 (setq group (gnus-group-group-name))
3698 (defun gnus-summary-read-group-1 (group show-all no-article
3699 kill-buffer no-display
3700 &optional select-articles)
3701 ;; Killed foreign groups can't be entered.
3702 ;; (when (and (not (gnus-group-native-p group))
3703 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3704 ;; (error "Dead non-native groups can't be entered"))
3705 (gnus-message 5 "Retrieving newsgroup: %s..."
3706 (gnus-group-decoded-name group))
3707 (let* ((new-group (gnus-summary-setup-buffer group))
3708 (quit-config (gnus-group-quit-config group))
3709 (did-select (and new-group (gnus-select-newsgroup
3710 group show-all select-articles))))
3712 ;; This summary buffer exists already, so we just select it.
3714 (gnus-set-global-variables)
3716 (gnus-kill-or-deaden-summary kill-buffer))
3717 (gnus-configure-windows 'summary 'force)
3718 (gnus-set-mode-line 'summary)
3719 (gnus-summary-position-point)
3722 ;; We couldn't select this group.
3724 (when (and (eq major-mode 'gnus-summary-mode)
3725 (not (equal (current-buffer) kill-buffer)))
3726 (kill-buffer (current-buffer))
3727 (if (not quit-config)
3729 ;; Update the info -- marks might need to be removed,
3731 (gnus-summary-update-info)
3732 (set-buffer gnus-group-buffer)
3733 (gnus-group-jump-to-group group)
3734 (gnus-group-next-unread-group 1))
3735 (gnus-handle-ephemeral-exit quit-config)))
3736 (let ((grpinfo (gnus-get-info group)))
3737 (if (null (gnus-info-read grpinfo))
3738 (gnus-message 3 "Group %s contains no messages"
3739 (gnus-group-decoded-name group))
3740 (gnus-message 3 "Can't select group")))
3742 ;; The user did a `C-g' while prompting for number of articles,
3743 ;; so we exit this group.
3744 ((eq did-select 'quit)
3745 (and (eq major-mode 'gnus-summary-mode)
3746 (not (equal (current-buffer) kill-buffer))
3747 (kill-buffer (current-buffer)))
3749 (gnus-kill-or-deaden-summary kill-buffer))
3750 (if (not quit-config)
3752 (set-buffer gnus-group-buffer)
3753 (gnus-group-jump-to-group group)
3754 (gnus-group-next-unread-group 1)
3755 (gnus-configure-windows 'group 'force))
3756 (gnus-handle-ephemeral-exit quit-config))
3757 ;; Finally signal the quit.
3759 ;; The group was successfully selected.
3761 (gnus-set-global-variables)
3762 ;; Save the active value in effect when the group was entered.
3763 (setq gnus-newsgroup-active
3765 (gnus-active gnus-newsgroup-name)))
3766 ;; You can change the summary buffer in some way with this hook.
3767 (gnus-run-hooks 'gnus-select-group-hook)
3768 (when (memq 'summary (gnus-update-format-specifications
3769 nil 'summary 'summary-mode 'summary-dummy))
3770 ;; The format specification for the summary line was updated,
3771 ;; so we need to update the mark positions as well.
3772 (gnus-update-summary-mark-positions))
3773 ;; Do score processing.
3774 (when gnus-use-scoring
3775 (gnus-possibly-score-headers))
3776 ;; Check whether to fill in the gaps in the threads.
3777 (when gnus-build-sparse-threads
3778 (gnus-build-sparse-threads))
3779 ;; Find the initial limit.
3781 (let ((gnus-newsgroup-dormant nil))
3782 (gnus-summary-initial-limit show-all))
3783 (gnus-summary-initial-limit show-all))
3784 ;; Generate the summary buffer.
3786 (gnus-summary-prepare))
3787 (when gnus-use-trees
3788 (gnus-tree-open group)
3789 (setq gnus-summary-highlight-line-function
3790 'gnus-tree-highlight-article))
3791 ;; If the summary buffer is empty, but there are some low-scored
3792 ;; articles or some excluded dormants, we include these in the
3794 (when (and (zerop (buffer-size))
3796 (cond (gnus-newsgroup-dormant
3797 (gnus-summary-limit-include-dormant))
3798 ((and gnus-newsgroup-scored show-all)
3799 (gnus-summary-limit-include-expunged t))))
3800 ;; Function `gnus-apply-kill-file' must be called in this hook.
3801 (gnus-run-hooks 'gnus-apply-kill-hook)
3802 (if (and (zerop (buffer-size))
3805 ;; This newsgroup is empty.
3806 (gnus-summary-catchup-and-exit nil t)
3807 (gnus-message 6 "No unread news")
3809 (gnus-kill-or-deaden-summary kill-buffer))
3810 ;; Return nil from this function.
3812 ;; Hide conversation thread subtrees. We cannot do this in
3813 ;; gnus-summary-prepare-hook since kill processing may not
3814 ;; work with hidden articles.
3815 (gnus-summary-maybe-hide-threads)
3817 (gnus-kill-or-deaden-summary kill-buffer))
3818 (gnus-summary-auto-select-subject)
3819 ;; Show first unread article if requested.
3820 (if (and (not no-article)
3822 gnus-newsgroup-unreads
3823 gnus-auto-select-first)
3825 (gnus-configure-windows 'summary)
3826 (let ((art (gnus-summary-article-number)))
3827 (unless (and (not gnus-plugged)
3828 (or (memq art gnus-newsgroup-undownloaded)
3829 (memq art gnus-newsgroup-downloadable)))
3830 (gnus-summary-goto-article art))))
3831 ;; Don't select any articles.
3832 (gnus-summary-position-point)
3833 (gnus-configure-windows 'summary 'force)
3834 (gnus-set-mode-line 'summary))
3835 (when (and gnus-auto-center-group
3836 (get-buffer-window gnus-group-buffer t))
3837 ;; Gotta use windows, because recenter does weird stuff if
3838 ;; the current buffer ain't the displayed window.
3839 (let ((owin (selected-window)))
3840 (select-window (get-buffer-window gnus-group-buffer t))
3841 (when (gnus-group-goto-group group)
3843 (select-window owin)))
3844 ;; Mark this buffer as "prepared".
3845 (setq gnus-newsgroup-prepared t)
3846 (gnus-run-hooks 'gnus-summary-prepared-hook)
3847 (unless (gnus-ephemeral-group-p group)
3848 (gnus-group-update-group group))
3851 (defun gnus-summary-auto-select-subject ()
3852 "Select the subject line on initial group entry."
3853 (goto-char (point-min))
3855 ((eq gnus-auto-select-subject 'best)
3856 (gnus-summary-best-unread-subject))
3857 ((eq gnus-auto-select-subject 'unread)
3858 (gnus-summary-first-unread-subject))
3859 ((eq gnus-auto-select-subject 'unseen)
3860 (gnus-summary-first-unseen-subject))
3861 ((eq gnus-auto-select-subject 'unseen-or-unread)
3862 (gnus-summary-first-unseen-or-unread-subject))
3863 ((eq gnus-auto-select-subject 'first)
3866 ((functionp gnus-auto-select-subject)
3867 (funcall gnus-auto-select-subject))))
3869 (defun gnus-summary-prepare ()
3870 "Generate the summary buffer."
3872 (let ((buffer-read-only nil))
3874 (setq gnus-newsgroup-data nil
3875 gnus-newsgroup-data-reverse nil)
3876 (gnus-run-hooks 'gnus-summary-generate-hook)
3877 ;; Generate the buffer, either with threads or without.
3878 (when gnus-newsgroup-headers
3879 (gnus-summary-prepare-threads
3880 (if gnus-show-threads
3881 (gnus-sort-gathered-threads
3882 (funcall gnus-summary-thread-gathering-function
3884 (gnus-cut-threads (gnus-make-threads)))))
3885 ;; Unthreaded display.
3886 (gnus-sort-articles gnus-newsgroup-headers))))
3887 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3888 ;; Call hooks for modifying summary buffer.
3889 (goto-char (point-min))
3890 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3892 (defsubst gnus-general-simplify-subject (subject)
3893 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3896 ;; Truncate the subject.
3897 (gnus-simplify-subject-functions
3898 (gnus-map-function gnus-simplify-subject-functions subject))
3899 ((numberp gnus-summary-gather-subject-limit)
3900 (setq subject (gnus-simplify-subject-re subject))
3901 (if (> (length subject) gnus-summary-gather-subject-limit)
3902 (substring subject 0 gnus-summary-gather-subject-limit)
3904 ;; Fuzzily simplify it.
3905 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3906 (gnus-simplify-subject-fuzzy subject))
3907 ;; Just remove the leading "Re:".
3909 (gnus-simplify-subject-re subject))))
3911 (if (and gnus-summary-gather-exclude-subject
3912 (string-match gnus-summary-gather-exclude-subject subject))
3913 nil ; This article shouldn't be gathered
3916 (defun gnus-summary-simplify-subject-query ()
3917 "Query where the respool algorithm would put this article."
3919 (gnus-summary-select-article)
3920 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3922 (defun gnus-gather-threads-by-subject (threads)
3923 "Gather threads by looking at Subject headers."
3924 (if (not gnus-summary-make-false-root)
3926 (let ((hashtb (gnus-make-hashtable 1024))
3929 subject hthread whole-subject)
3931 (setq subject (gnus-general-simplify-subject
3932 (setq whole-subject (mail-header-subject
3935 (if (setq hthread (gnus-gethash subject hashtb))
3937 ;; We enter a dummy root into the thread, if we
3938 ;; haven't done that already.
3939 (unless (stringp (caar hthread))
3940 (setcar hthread (list whole-subject (car hthread))))
3941 ;; We add this new gathered thread to this gathered
3943 (setcdr (car hthread)
3944 (nconc (cdar hthread) (list (car threads))))
3945 ;; Remove it from the list of threads.
3946 (setcdr prev (cdr threads))
3947 (setq threads prev))
3948 ;; Enter this thread into the hash table.
3949 (gnus-sethash subject
3950 (if gnus-summary-make-false-root-always
3952 ;; If you want a dummy root above all
3954 (setcar threads (list whole-subject
3960 (setq threads (cdr threads)))
3963 (defun gnus-gather-threads-by-references (threads)
3964 "Gather threads by looking at References headers."
3965 (let ((idhashtb (gnus-make-hashtable 1024))
3966 (thhashtb (gnus-make-hashtable 1024))
3969 ids references id gthread gid entered ref)
3971 (when (setq references (mail-header-references (caar threads)))
3972 (setq id (mail-header-id (caar threads))
3973 ids (inline (gnus-split-references references))
3975 (while (setq ref (pop ids))
3976 (setq ids (delete ref ids))
3977 (if (not (setq gid (gnus-gethash ref idhashtb)))
3979 (gnus-sethash ref id idhashtb)
3980 (gnus-sethash id threads thhashtb))
3981 (setq gthread (gnus-gethash gid thhashtb))
3983 ;; We enter a dummy root into the thread, if we
3984 ;; haven't done that already.
3985 (unless (stringp (caar gthread))
3986 (setcar gthread (list (mail-header-subject (caar gthread))
3988 ;; We add this new gathered thread to this gathered
3990 (setcdr (car gthread)
3991 (nconc (cdar gthread) (list (car threads)))))
3992 ;; Add it into the thread hash table.
3993 (gnus-sethash id gthread thhashtb)
3995 ;; Remove it from the list of threads.
3996 (setcdr prev (cdr threads))
3997 (setq threads prev))))
3999 (setq threads (cdr threads)))
4002 (defun gnus-sort-gathered-threads (threads)
4003 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4004 (let ((result threads))
4006 (when (stringp (caar threads))
4007 (setcdr (car threads)
4008 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4009 (setq threads (cdr threads)))
4012 (defun gnus-thread-loop-p (root thread)
4013 "Say whether ROOT is in THREAD."
4014 (let ((stack (list thread))
4017 (while (setq thread (pop stack))
4018 (setq th (cdr thread))
4020 (not (eq (caar th) root)))
4023 ;; We have found a loop.
4025 (setcdr thread (delq (car th) (cdr thread)))
4026 (if (boundp (setq ref-dep (intern "none"
4027 gnus-newsgroup-dependencies)))
4028 (setcdr (symbol-value ref-dep)
4029 (nconc (cdr (symbol-value ref-dep))
4031 (set ref-dep (list nil (car th))))
4034 ;; Push all the subthreads onto the stack.
4035 (push (cdr thread) stack)))
4038 (defun gnus-make-threads ()
4039 "Go through the dependency hashtb and find the roots. Return all threads."
4041 (while (catch 'infloop
4044 ;; Deal with self-referencing References loops.
4045 (when (and (car (symbol-value refs))
4052 (car (symbol-value refs)) thread))
4053 (cdr (symbol-value refs)))))))
4056 (unless (car (symbol-value refs))
4057 ;; These threads do not refer back to any other
4058 ;; articles, so they're roots.
4059 (setq threads (append (cdr (symbol-value refs)) threads))))
4060 gnus-newsgroup-dependencies)))
4063 ;; Build the thread tree.
4064 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4065 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4067 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4068 if it was already present.
4070 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4071 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4072 Message-IDs will be renamed to a unique Message-ID before being
4075 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4076 (let* ((id (mail-header-id header))
4077 (id-dep (and id (intern id dependencies)))
4078 parent-id ref ref-dep ref-header replaced)
4079 ;; Enter this `header' in the `dependencies' table.
4083 ;; The first two cases do the normal part: enter a new `header'
4084 ;; in the `dependencies' table.
4085 ((not (boundp id-dep))
4086 (set id-dep (list header)))
4087 ((null (car (symbol-value id-dep)))
4088 (setcar (symbol-value id-dep) header))
4090 ;; From here the `header' was already present in the
4091 ;; `dependencies' table.
4093 ;; Overrides an existing entry;
4094 ;; just set the header part of the entry.
4095 (setcar (symbol-value id-dep) header)
4098 ;; Renames the existing `header' to a unique Message-ID.
4099 ((not gnus-summary-ignore-duplicates)
4100 ;; An article with this Message-ID has already been seen.
4101 ;; We rename the Message-ID.
4102 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4104 (mail-header-set-id header id))
4106 ;; The last case ignores an existing entry, except it adds any
4107 ;; additional Xrefs (in case the two articles came from different
4109 ;; Also sets `header' to `nil' meaning that the `dependencies'
4110 ;; table was *not* modified.
4112 (mail-header-set-xref
4113 (car (symbol-value id-dep))
4114 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4116 (or (mail-header-xref header) "")))
4119 (when (and header (not replaced))
4120 ;; First check that we are not creating a References loop.
4121 (setq parent-id (gnus-parent-id (mail-header-references header)))
4122 (setq ref parent-id)
4124 (setq ref-dep (intern-soft ref dependencies))
4126 (setq ref-header (car (symbol-value ref-dep))))
4127 (if (string= id ref)
4128 ;; Yuk! This is a reference loop. Make the article be a
4131 (mail-header-set-references (car (symbol-value id-dep)) "none")
4133 (setq parent-id nil))
4134 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4135 (setq ref-dep (intern (or parent-id "none") dependencies))
4136 (if (boundp ref-dep)
4137 (setcdr (symbol-value ref-dep)
4138 (nconc (cdr (symbol-value ref-dep))
4139 (list (symbol-value id-dep))))
4140 (set ref-dep (list nil (symbol-value id-dep)))))
4143 (defun gnus-extract-message-id-from-in-reply-to (string)
4144 (if (string-match "<[^>]+>" string)
4145 (substring string (match-beginning 0) (match-end 0))
4148 (defun gnus-build-sparse-threads ()
4149 (let ((headers gnus-newsgroup-headers)
4150 (mail-parse-charset gnus-newsgroup-charset)
4151 (gnus-summary-ignore-duplicates t)
4152 header references generation relations
4153 subject child end new-child date)
4154 ;; First we create an alist of generations/relations, where
4155 ;; generations is how much we trust the relation, and the relation
4157 (gnus-message 7 "Making sparse threads...")
4159 (nnheader-set-temp-buffer " *gnus sparse threads*")
4160 (while (setq header (pop headers))
4161 (when (and (setq references (mail-header-references header))
4162 (not (string= references "")))
4164 (setq child (mail-header-id header)
4165 subject (mail-header-subject header)
4166 date (mail-header-date header)
4168 (while (search-backward ">" nil t)
4169 (setq end (1+ (point)))
4170 (when (search-backward "<" nil t)
4171 (setq new-child (buffer-substring (point) end))
4172 (push (list (incf generation)
4173 child (setq child new-child)
4177 (push (list (1+ generation) child nil subject) relations))
4179 (kill-buffer (current-buffer)))
4180 ;; Sort over trustworthiness.
4183 (when (gnus-dependencies-add-header
4184 (make-full-mail-header
4185 gnus-reffed-article-number
4186 (nth 3 relation) "" (or (nth 4 relation) "")
4188 (or (nth 2 relation) "") 0 0 "")
4189 gnus-newsgroup-dependencies nil)
4190 (push gnus-reffed-article-number gnus-newsgroup-limit)
4191 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4192 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4193 gnus-newsgroup-reads)
4194 (decf gnus-reffed-article-number)))
4195 (sort relations 'car-less-than-car))
4196 (gnus-message 7 "Making sparse threads...done")))
4198 (defun gnus-build-old-threads ()
4199 ;; Look at all the articles that refer back to old articles, and
4200 ;; fetch the headers for the articles that aren't there. This will
4201 ;; build complete threads - if the roots haven't been expired by the
4203 (let ((mail-parse-charset gnus-newsgroup-charset)
4207 (when (not (car (symbol-value refs)))
4208 (setq heads (cdr (symbol-value refs)))
4210 (if (memq (mail-header-number (caar heads))
4211 gnus-newsgroup-dormant)
4212 (setq heads (cdr heads))
4213 (setq id (symbol-name refs))
4214 (while (and (setq id (gnus-build-get-header id))
4215 (not (car (gnus-id-to-thread id)))))
4216 (setq heads nil)))))
4217 gnus-newsgroup-dependencies)))
4219 (defsubst gnus-remove-odd-characters (string)
4220 "Translate STRING into something that doesn't contain weird characters."
4221 (mm-subst-char-in-string
4223 (mm-subst-char-in-string ?\n ?\- string t) t))
4225 ;; This function has to be called with point after the article number
4226 ;; on the beginning of the line.
4227 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4228 (let ((eol (point-at-eol))
4229 (buffer (current-buffer))
4230 header references in-reply-to)
4232 ;; overview: [num subject from date id refs chars lines misc]
4235 (narrow-to-region (point) eol)
4240 (make-full-mail-header
4242 (condition-case () ; subject
4243 (gnus-remove-odd-characters
4244 (funcall gnus-decode-encoded-word-function
4245 (setq x (nnheader-nov-field))))
4247 (condition-case () ; from
4248 (gnus-remove-odd-characters
4249 (funcall gnus-decode-encoded-word-function
4250 (setq x (nnheader-nov-field))))
4252 (nnheader-nov-field) ; date
4253 (nnheader-nov-read-message-id number) ; id
4254 (setq references (nnheader-nov-field)) ; refs
4255 (nnheader-nov-read-integer) ; chars
4256 (nnheader-nov-read-integer) ; lines
4258 (if (looking-at "Xref: ")
4259 (goto-char (match-end 0)))
4260 (nnheader-nov-field)) ; Xref
4261 (nnheader-nov-parse-extra)))) ; extra
4265 (when (and (string= references "")
4266 (setq in-reply-to (mail-header-extra header))
4267 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4268 (mail-header-set-references
4269 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4271 (when gnus-alter-header-function
4272 (funcall gnus-alter-header-function header))
4273 (gnus-dependencies-add-header header dependencies force-new)))
4275 (defun gnus-build-get-header (id)
4276 "Look through the buffer of NOV lines and find the header to ID.
4277 Enter this line into the dependencies hash table, and return
4278 the id of the parent article (if any)."
4279 (let ((deps gnus-newsgroup-dependencies)
4283 (set-buffer nntp-server-buffer)
4284 (let ((case-fold-search nil))
4285 (goto-char (point-min))
4286 (while (and (not found)
4287 (search-forward id nil t))
4289 (setq found (looking-at
4290 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4291 (regexp-quote id))))
4292 (or found (beginning-of-line 2)))
4296 (setq header (gnus-nov-parse-line
4297 (read (current-buffer)) deps))
4298 (gnus-parent-id (mail-header-references header))))))
4300 (let ((number (mail-header-number header)))
4301 (push number gnus-newsgroup-limit)
4302 (push header gnus-newsgroup-headers)
4303 (if (memq number gnus-newsgroup-unselected)
4305 (setq gnus-newsgroup-unreads
4306 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4308 (setq gnus-newsgroup-unselected
4309 (delq number gnus-newsgroup-unselected)))
4310 (push number gnus-newsgroup-ancient)))))))
4312 (defun gnus-build-all-threads ()
4313 "Read all the headers."
4314 (let ((gnus-summary-ignore-duplicates t)
4315 (mail-parse-charset gnus-newsgroup-charset)
4316 (dependencies gnus-newsgroup-dependencies)
4319 (set-buffer nntp-server-buffer)
4320 (let ((case-fold-search nil))
4321 (goto-char (point-min))
4324 (setq article (read (current-buffer))
4325 header (gnus-nov-parse-line article dependencies)))
4327 (with-current-buffer gnus-summary-buffer
4328 (push header gnus-newsgroup-headers)
4329 (if (memq (setq article (mail-header-number header))
4330 gnus-newsgroup-unselected)
4332 (setq gnus-newsgroup-unreads
4333 (gnus-add-to-sorted-list
4334 gnus-newsgroup-unreads article))
4335 (setq gnus-newsgroup-unselected
4336 (delq article gnus-newsgroup-unselected)))
4337 (push article gnus-newsgroup-ancient)))
4338 (forward-line 1)))))))
4340 (defun gnus-summary-update-article-line (article header)
4341 "Update the line for ARTICLE using HEADER."
4342 (let* ((id (mail-header-id header))
4343 (thread (gnus-id-to-thread id)))
4345 (error "Article in no thread"))
4346 ;; Update the thread.
4347 (setcar thread header)
4348 (gnus-summary-goto-subject article)
4349 (let* ((datal (gnus-data-find-list article))
4351 (buffer-read-only nil)
4352 (level (gnus-summary-thread-level)))
4354 (let ((inserted (- (point)
4356 (gnus-summary-insert-line
4358 (memq article gnus-newsgroup-undownloaded)
4359 (gnus-article-mark article)
4360 (memq article gnus-newsgroup-replied)
4361 (memq article gnus-newsgroup-expirable)
4362 ;; Only insert the Subject string when it's different
4363 ;; from the previous Subject string.
4368 (mail-header-subject
4371 (gnus-data-find-list
4373 (gnus-data-list t)))))
4374 ;; Error on the side of excessive subjects.
4376 (mail-header-subject header)))
4378 (mail-header-subject header))
4379 nil (cdr (assq article gnus-newsgroup-scored))
4380 (memq article gnus-newsgroup-processable))
4383 (gnus-data-update-list
4385 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4387 (defun gnus-summary-update-article (article &optional iheader)
4388 "Update ARTICLE in the summary buffer."
4389 (set-buffer gnus-summary-buffer)
4390 (let* ((header (gnus-summary-article-header article))
4391 (id (mail-header-id header))
4392 (data (gnus-data-find article))
4393 (thread (gnus-id-to-thread id))
4394 (references (mail-header-references header))
4398 (when (and references
4399 (not (equal "" references)))
4402 (buffer-read-only nil)
4408 (delq thread parent)))
4409 (if (gnus-summary-insert-subject id header)
4410 ;; Set the (possibly) new article number in the data structure.
4411 (gnus-data-set-number data (gnus-id-to-article id))
4415 (defun gnus-rebuild-thread (id &optional line)
4416 "Rebuild the thread containing ID.
4417 If LINE, insert the rebuilt thread starting on line LINE."
4418 (let ((buffer-read-only nil)
4419 old-pos current thread data)
4420 (if (not gnus-show-threads)
4421 (setq thread (list (car (gnus-id-to-thread id))))
4422 ;; Get the thread this article is part of.
4423 (setq thread (gnus-remove-thread id)))
4424 (setq old-pos (point-at-bol))
4425 (setq current (save-excursion
4426 (and (re-search-backward "[\r\n]" nil t)
4427 (gnus-summary-article-number))))
4428 ;; If this is a gathered thread, we have to go some re-gathering.
4429 (when (stringp (car thread))
4430 (let ((subject (car thread))
4432 (setq thread (cdr thread))
4434 (unless (memq (setq thr (gnus-id-to-thread
4436 (mail-header-id (caar thread)))))
4439 (setq thread (cdr thread)))
4440 ;; We now have all (unique) roots.
4441 (if (= (length roots) 1)
4442 ;; All the loose roots are now one solid root.
4443 (setq thread (car roots))
4444 (setq thread (cons subject (gnus-sort-threads roots))))))
4446 ;; We then insert this thread into the summary buffer.
4448 (goto-char (point-min))
4449 (forward-line (1- line)))
4450 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4451 (if gnus-show-threads
4452 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4453 (gnus-summary-prepare-unthreaded thread))
4454 (setq data (nreverse gnus-newsgroup-data))
4455 (setq threads gnus-newsgroup-threads))
4456 ;; We splice the new data into the data structure.
4457 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4458 ;;!!! then we want to insert at the beginning of the buffer.
4459 ;;!!! That happens to be true with Gnus now, but that may
4460 ;;!!! change in the future. Perhaps.
4461 (gnus-data-enter-list
4462 (if line nil current) data (- (point) old-pos))
4463 (setq gnus-newsgroup-threads
4464 (nconc threads gnus-newsgroup-threads))
4465 (gnus-data-compute-positions))))
4467 (defun gnus-number-to-header (number)
4468 "Return the header for article NUMBER."
4469 (let ((headers gnus-newsgroup-headers))
4471 (not (= number (mail-header-number (car headers)))))
4476 (defun gnus-parent-headers (in-headers &optional generation)
4477 "Return the headers of the GENERATIONeth parent of HEADERS."
4479 (setq generation 1))
4481 (headers in-headers)
4484 (not (zerop generation))
4485 (setq references (mail-header-references headers)))
4486 (setq headers (if (and references
4487 (setq parent (gnus-parent-id references)))
4488 (car (gnus-id-to-thread parent))
4491 (and (not (eq headers in-headers))
4494 (defun gnus-id-to-thread (id)
4495 "Return the (sub-)thread where ID appears."
4496 (gnus-gethash id gnus-newsgroup-dependencies))
4498 (defun gnus-id-to-article (id)
4499 "Return the article number of ID."
4500 (let ((thread (gnus-id-to-thread id)))
4503 (mail-header-number (car thread)))))
4505 (defun gnus-id-to-header (id)
4506 "Return the article headers of ID."
4507 (car (gnus-id-to-thread id)))
4509 (defun gnus-article-displayed-root-p (article)
4510 "Say whether ARTICLE is a root(ish) article."
4511 (let ((level (gnus-summary-thread-level article))
4512 (refs (mail-header-references (gnus-summary-article-header article)))
4518 ((null (gnus-parent-id refs)) t)
4520 (null (setq particle (gnus-id-to-article
4521 (gnus-parent-id refs))))
4522 (null (gnus-summary-thread-level particle)))))))
4524 (defun gnus-root-id (id)
4525 "Return the id of the root of the thread where ID appears."
4527 (while (and id (setq prev (car (gnus-id-to-thread id))))
4529 id (gnus-parent-id (mail-header-references prev))))
4532 (defun gnus-articles-in-thread (thread)
4533 "Return the list of articles in THREAD."
4534 (cons (mail-header-number (car thread))
4535 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4537 (defun gnus-remove-thread (id &optional dont-remove)
4538 "Remove the thread that has ID in it."
4539 (let (headers thread last-id)
4540 ;; First go up in this thread until we find the root.
4541 (setq last-id (gnus-root-id id)
4542 headers (message-flatten-list (gnus-id-to-thread last-id)))
4543 ;; We have now found the real root of this thread. It might have
4544 ;; been gathered into some loose thread, so we have to search
4545 ;; through the threads to find the thread we wanted.
4546 (let ((threads gnus-newsgroup-threads)
4549 (setq sub (car threads))
4550 (if (stringp (car sub))
4551 ;; This is a gathered thread, so we look at the roots
4552 ;; below it to find whether this article is in this
4555 (setq sub (cdr sub))
4557 (when (member (caar sub) headers)
4558 (setq thread (car threads)
4561 (setq sub (cdr sub))))
4562 ;; It's an ordinary thread, so we check it.
4563 (when (eq (car sub) (car headers))
4566 (setq threads (cdr threads)))
4567 ;; If this article is in no thread, then it's a root.
4570 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4571 (setq thread (gnus-id-to-thread last-id)))
4574 thread ; We return this thread.
4576 (if (stringp (car thread))
4578 ;; If we use dummy roots, then we have to remove the
4579 ;; dummy root as well.
4580 (when (eq gnus-summary-make-false-root 'dummy)
4581 ;; We go to the dummy root by going to
4582 ;; the first sub-"thread", and then one line up.
4583 (gnus-summary-goto-article
4584 (mail-header-number (caadr thread)))
4587 (gnus-data-compute-positions))
4588 (setq thread (cdr thread))
4590 (gnus-remove-thread-1 (car thread))
4591 (setq thread (cdr thread))))
4592 (gnus-remove-thread-1 thread))))))))
4594 (defun gnus-remove-thread-1 (thread)
4595 "Remove the thread THREAD recursively."
4596 (let ((number (mail-header-number (pop thread)))
4598 (setq thread (reverse thread))
4600 (gnus-remove-thread-1 (pop thread)))
4601 (when (setq d (gnus-data-find number))
4602 (goto-char (gnus-data-pos d))
4603 (gnus-summary-show-thread)
4609 (gnus-delete-line)))))))
4611 (defun gnus-sort-threads-1 (threads func)
4612 (sort (mapcar (lambda (thread)
4615 (gnus-sort-threads-1 (cdr thread) func))))
4618 (defun gnus-sort-threads (threads)
4620 (if (not gnus-thread-sort-functions)
4622 (gnus-message 8 "Sorting threads...")
4623 (let ((max-lisp-eval-depth 5000))
4624 (prog1 (gnus-sort-threads-1
4626 (gnus-make-sort-function gnus-thread-sort-functions))
4627 (gnus-message 8 "Sorting threads...done")))))
4629 (defun gnus-sort-articles (articles)
4631 (when gnus-article-sort-functions
4632 (gnus-message 7 "Sorting articles...")
4634 (setq gnus-newsgroup-headers
4635 (sort articles (gnus-make-sort-function
4636 gnus-article-sort-functions)))
4637 (gnus-message 7 "Sorting articles...done"))))
4639 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4640 (defmacro gnus-thread-header (thread)
4641 "Return header of first article in THREAD.
4642 Note that THREAD must never, ever be anything else than a variable -
4643 using some other form will lead to serious barfage."
4644 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4645 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4646 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4649 (defsubst gnus-article-sort-by-number (h1 h2)
4650 "Sort articles by article number."
4651 (< (mail-header-number h1)
4652 (mail-header-number h2)))
4654 (defun gnus-thread-sort-by-number (h1 h2)
4655 "Sort threads by root article number."
4656 (gnus-article-sort-by-number
4657 (gnus-thread-header h1) (gnus-thread-header h2)))
4659 (defsubst gnus-article-sort-by-random (h1 h2)
4660 "Sort articles by article number."
4663 (defun gnus-thread-sort-by-random (h1 h2)
4664 "Sort threads by root article number."
4665 (gnus-article-sort-by-random
4666 (gnus-thread-header h1) (gnus-thread-header h2)))
4668 (defsubst gnus-article-sort-by-lines (h1 h2)
4669 "Sort articles by article Lines header."
4670 (< (mail-header-lines h1)
4671 (mail-header-lines h2)))
4673 (defun gnus-thread-sort-by-lines (h1 h2)
4674 "Sort threads by root article Lines header."
4675 (gnus-article-sort-by-lines
4676 (gnus-thread-header h1) (gnus-thread-header h2)))
4678 (defsubst gnus-article-sort-by-chars (h1 h2)
4679 "Sort articles by octet length."
4680 (< (mail-header-chars h1)
4681 (mail-header-chars h2)))
4683 (defun gnus-thread-sort-by-chars (h1 h2)
4684 "Sort threads by root article octet length."
4685 (gnus-article-sort-by-chars
4686 (gnus-thread-header h1) (gnus-thread-header h2)))
4688 (defsubst gnus-article-sort-by-author (h1 h2)
4689 "Sort articles by root author."
4691 (let ((extract (funcall
4692 gnus-extract-address-components
4693 (mail-header-from h1))))
4694 (or (car extract) (cadr extract) ""))
4695 (let ((extract (funcall
4696 gnus-extract-address-components
4697 (mail-header-from h2))))
4698 (or (car extract) (cadr extract) ""))))
4700 (defun gnus-thread-sort-by-author (h1 h2)
4701 "Sort threads by root author."
4702 (gnus-article-sort-by-author
4703 (gnus-thread-header h1) (gnus-thread-header h2)))
4705 (defsubst gnus-article-sort-by-recipient (h1 h2)
4706 "Sort articles by recipient."
4708 (let ((extract (funcall
4709 gnus-extract-address-components
4710 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4711 (or (car extract) (cadr extract)))
4712 (let ((extract (funcall
4713 gnus-extract-address-components
4714 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4715 (or (car extract) (cadr extract)))))
4717 (defun gnus-thread-sort-by-recipient (h1 h2)
4718 "Sort threads by root recipient."
4719 (gnus-article-sort-by-recipient
4720 (gnus-thread-header h1) (gnus-thread-header h2)))
4722 (defsubst gnus-article-sort-by-subject (h1 h2)
4723 "Sort articles by root subject."
4725 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4726 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4728 (defun gnus-thread-sort-by-subject (h1 h2)
4729 "Sort threads by root subject."
4730 (gnus-article-sort-by-subject
4731 (gnus-thread-header h1) (gnus-thread-header h2)))
4733 (defsubst gnus-article-sort-by-date (h1 h2)
4734 "Sort articles by root article date."
4736 (gnus-date-get-time (mail-header-date h1))
4737 (gnus-date-get-time (mail-header-date h2))))
4739 (defun gnus-thread-sort-by-date (h1 h2)
4740 "Sort threads by root article date."
4741 (gnus-article-sort-by-date
4742 (gnus-thread-header h1) (gnus-thread-header h2)))
4744 (defsubst gnus-article-sort-by-score (h1 h2)
4745 "Sort articles by root article score.
4746 Unscored articles will be counted as having a score of zero."
4747 (> (or (cdr (assq (mail-header-number h1)
4748 gnus-newsgroup-scored))
4749 gnus-summary-default-score 0)
4750 (or (cdr (assq (mail-header-number h2)
4751 gnus-newsgroup-scored))
4752 gnus-summary-default-score 0)))
4754 (defun gnus-thread-sort-by-score (h1 h2)
4755 "Sort threads by root article score."
4756 (gnus-article-sort-by-score
4757 (gnus-thread-header h1) (gnus-thread-header h2)))
4759 (defun gnus-thread-sort-by-total-score (h1 h2)
4760 "Sort threads by the sum of all scores in the thread.
4761 Unscored articles will be counted as having a score of zero."
4762 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4764 (defun gnus-thread-total-score (thread)
4765 ;; This function find the total score of THREAD.
4770 (if (stringp (car thread))
4771 (apply gnus-thread-score-function 0
4772 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4773 (gnus-thread-total-score-1 thread)))
4775 (gnus-thread-total-score-1 (list thread)))))
4777 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4778 "Sort threads such that the thread with the most recently arrived article comes first."
4779 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4781 (defun gnus-thread-highest-number (thread)
4782 "Return the highest article number in THREAD."
4783 (apply 'max (mapcar (lambda (header)
4784 (mail-header-number header))
4785 (message-flatten-list thread))))
4787 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4788 "Sort threads such that the thread with the most recently dated article comes first."
4789 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4791 (defun gnus-thread-latest-date (thread)
4792 "Return the highest article date in THREAD."
4793 (let ((previous-time 0))
4799 (time-to-seconds (mail-header-parse-date
4800 (mail-header-date header)))
4801 (error previous-time))))
4803 (message-flatten-list thread)
4805 (< (mail-header-number h1)
4806 (mail-header-number h2))))))))
4808 (defun gnus-thread-total-score-1 (root)
4809 ;; This function find the total score of the thread below ROOT.
4810 (setq root (car root))
4811 (apply gnus-thread-score-function
4813 (mapcar 'gnus-thread-total-score
4814 (cdr (gnus-id-to-thread (mail-header-id root))))
4815 (when (> (mail-header-number root) 0)
4816 (list (or (cdr (assq (mail-header-number root)
4817 gnus-newsgroup-scored))
4818 gnus-summary-default-score 0))))
4819 (list gnus-summary-default-score)
4822 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4823 (defvar gnus-tmp-prev-subject nil)
4824 (defvar gnus-tmp-false-parent nil)
4825 (defvar gnus-tmp-root-expunged nil)
4826 (defvar gnus-tmp-dummy-line nil)
4828 (eval-when-compile (defvar gnus-tmp-header))
4829 (defun gnus-extra-header (type &optional header)
4830 "Return the extra header of TYPE."
4831 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4834 (defvar gnus-tmp-thread-tree-header-string "")
4836 (defcustom gnus-sum-thread-tree-root "> "
4837 "With %B spec, used for the root of a thread.
4838 If nil, use subject instead."
4840 :type '(radio (const :format "%v " nil) string)
4841 :group 'gnus-thread)
4843 (defcustom gnus-sum-thread-tree-false-root "> "
4844 "With %B spec, used for a false root of a thread.
4845 If nil, use subject instead."
4847 :type '(radio (const :format "%v " nil) string)
4848 :group 'gnus-thread)
4850 (defcustom gnus-sum-thread-tree-single-indent ""
4851 "With %B spec, used for a thread with just one message.
4852 If nil, use subject instead."
4854 :type '(radio (const :format "%v " nil) string)
4855 :group 'gnus-thread)
4857 (defcustom gnus-sum-thread-tree-vertical "| "
4858 "With %B spec, used for drawing a vertical line."
4861 :group 'gnus-thread)
4863 (defcustom gnus-sum-thread-tree-indent " "
4864 "With %B spec, used for indenting."
4867 :group 'gnus-thread)
4869 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4870 "With %B spec, used for a leaf with brothers."
4873 :group 'gnus-thread)
4875 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4876 "With %B spec, used for a leaf without brothers."
4879 :group 'gnus-thread)
4881 (defun gnus-summary-prepare-threads (threads)
4882 "Prepare summary buffer from THREADS and indentation LEVEL.
4883 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4884 or a straight list of headers."
4885 (gnus-message 7 "Generating summary...")
4887 (setq gnus-newsgroup-threads threads)
4890 (let ((gnus-tmp-level 0)
4891 (default-score (or gnus-summary-default-score 0))
4892 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4893 (building-line-count gnus-summary-display-while-building)
4894 (building-count (integerp gnus-summary-display-while-building))
4895 thread number subject stack state gnus-tmp-gathered beg-match
4896 new-roots gnus-tmp-new-adopts thread-end simp-subject
4897 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4898 gnus-tmp-replied gnus-tmp-subject-or-nil
4899 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4900 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4901 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4904 (setq gnus-tmp-prev-subject nil
4905 gnus-tmp-thread-tree-header-string "")
4907 (if (vectorp (car threads))
4908 ;; If this is a straight (sic) list of headers, then a
4909 ;; threaded summary display isn't required, so we just create
4910 ;; an unthreaded one.
4911 (gnus-summary-prepare-unthreaded threads)
4913 ;; Do the threaded display.
4915 (if gnus-summary-display-while-building
4916 (switch-to-buffer (buffer-name)))
4917 (while (or threads stack gnus-tmp-new-adopts new-roots)
4919 (if (and (= gnus-tmp-level 0)
4922 (not gnus-tmp-false-parent)
4923 (or gnus-tmp-new-adopts new-roots))
4924 (if gnus-tmp-new-adopts
4925 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4926 thread (list (car gnus-tmp-new-adopts))
4927 gnus-tmp-header (caar thread)
4928 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4930 (setq thread (list (car new-roots))
4931 gnus-tmp-header (caar thread)
4932 new-roots (cdr new-roots))))
4935 ;; If there are some threads, we do them before the
4936 ;; threads on the stack.
4937 (setq thread threads
4938 gnus-tmp-header (caar thread))
4939 ;; There were no current threads, so we pop something off
4941 (setq state (car stack)
4942 gnus-tmp-level (car state)
4943 tree-stack (cadr state)
4944 thread (caddr state)
4946 gnus-tmp-header (caar thread))))
4948 (setq gnus-tmp-false-parent nil)
4949 (setq gnus-tmp-root-expunged nil)
4950 (setq thread-end nil)
4952 (if (stringp gnus-tmp-header)
4953 ;; The header is a dummy root.
4955 ((eq gnus-summary-make-false-root 'adopt)
4956 ;; We let the first article adopt the rest.
4957 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4959 (setq gnus-tmp-gathered
4961 (lambda (h) (mail-header-number (car h)))
4964 (setq thread (cons (list (caar thread)
4967 (setq gnus-tmp-level -1
4968 gnus-tmp-false-parent t))
4969 ((eq gnus-summary-make-false-root 'empty)
4970 ;; We print adopted articles with empty subject fields.
4971 (setq gnus-tmp-gathered
4973 (lambda (h) (mail-header-number (car h)))
4976 (setq gnus-tmp-level -1))
4977 ((eq gnus-summary-make-false-root 'dummy)
4978 ;; We remember that we probably want to output a dummy
4980 (setq gnus-tmp-dummy-line gnus-tmp-header)
4981 (setq gnus-tmp-prev-subject gnus-tmp-header))
4983 ;; We do not make a root for the gathered
4984 ;; sub-threads at all.
4985 (setq gnus-tmp-level -1)))
4987 (setq number (mail-header-number gnus-tmp-header)
4988 subject (mail-header-subject gnus-tmp-header)
4989 simp-subject (gnus-simplify-subject-fully subject))
4992 ;; If the thread has changed subject, we might want to make
4993 ;; this subthread into a root.
4994 ((and (null gnus-thread-ignore-subject)
4995 (not (zerop gnus-tmp-level))
4996 gnus-tmp-prev-subject
4997 (not (string= gnus-tmp-prev-subject simp-subject)))
4998 (setq new-roots (nconc new-roots (list (car thread)))
5000 gnus-tmp-header nil))
5001 ;; If the article lies outside the current limit,
5002 ;; then we do not display it.
5003 ((not (memq number gnus-newsgroup-limit))
5004 (setq gnus-tmp-gathered
5006 (lambda (h) (mail-header-number (car h)))
5009 (setq gnus-tmp-new-adopts (if (cdar thread)
5010 (append gnus-tmp-new-adopts
5012 gnus-tmp-new-adopts)
5014 gnus-tmp-header nil)
5015 (when (zerop gnus-tmp-level)
5016 (setq gnus-tmp-root-expunged t)))
5017 ;; Perhaps this article is to be marked as read?
5018 ((and gnus-summary-mark-below
5019 (< (or (cdr (assq number gnus-newsgroup-scored))
5021 gnus-summary-mark-below)
5022 ;; Don't touch sparse articles.
5023 (not (gnus-summary-article-sparse-p number))
5024 (not (gnus-summary-article-ancient-p number)))
5025 (setq gnus-newsgroup-unreads
5026 (delq number gnus-newsgroup-unreads))
5027 (if gnus-newsgroup-auto-expire
5028 (setq gnus-newsgroup-expirable
5029 (gnus-add-to-sorted-list
5030 gnus-newsgroup-expirable number))
5031 (push (cons number gnus-low-score-mark)
5032 gnus-newsgroup-reads))))
5034 (when gnus-tmp-header
5035 ;; We may have an old dummy line to output before this
5037 (when (and gnus-tmp-dummy-line
5040 (mail-header-subject gnus-tmp-header)))
5041 (gnus-summary-insert-dummy-line
5042 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5043 (setq gnus-tmp-dummy-line nil))
5045 ;; Compute the mark.
5046 (setq gnus-tmp-unread (gnus-article-mark number))
5048 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5049 gnus-tmp-header gnus-tmp-level)
5050 gnus-newsgroup-data)
5052 ;; Actually insert the line.
5054 gnus-tmp-subject-or-nil
5056 ((and gnus-thread-ignore-subject
5057 gnus-tmp-prev-subject
5058 (not (string= gnus-tmp-prev-subject simp-subject)))
5060 ((zerop gnus-tmp-level)
5061 (if (and (eq gnus-summary-make-false-root 'empty)
5062 (memq number gnus-tmp-gathered)
5063 gnus-tmp-prev-subject
5064 (string= gnus-tmp-prev-subject simp-subject))
5065 gnus-summary-same-subject
5067 (t gnus-summary-same-subject)))
5068 (if (and (eq gnus-summary-make-false-root 'adopt)
5069 (= gnus-tmp-level 1)
5070 (memq number gnus-tmp-gathered))
5071 (setq gnus-tmp-opening-bracket ?\<
5072 gnus-tmp-closing-bracket ?\>)
5073 (setq gnus-tmp-opening-bracket ?\[
5074 gnus-tmp-closing-bracket ?\]))
5076 gnus-tmp-indentation
5077 (aref gnus-thread-indent-array gnus-tmp-level)
5078 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5079 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5080 gnus-summary-default-score 0)
5082 (if (or (null gnus-summary-default-score)
5083 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5084 gnus-summary-zcore-fuzz))
5086 (if (< gnus-tmp-score gnus-summary-default-score)
5087 gnus-score-below-mark gnus-score-over-mark))
5089 (cond ((memq number gnus-newsgroup-processable)
5091 ((memq number gnus-newsgroup-cached)
5093 ((memq number gnus-newsgroup-replied)
5095 ((memq number gnus-newsgroup-forwarded)
5096 gnus-forwarded-mark)
5097 ((memq number gnus-newsgroup-saved)
5099 ((memq number gnus-newsgroup-recent)
5101 ((memq number gnus-newsgroup-unseen)
5105 (cond ((memq number gnus-newsgroup-undownloaded)
5106 gnus-undownloaded-mark)
5107 (gnus-newsgroup-agentized
5108 gnus-downloaded-mark)
5111 gnus-tmp-from (mail-header-from gnus-tmp-header)
5114 ((string-match "<[^>]+> *$" gnus-tmp-from)
5115 (setq beg-match (match-beginning 0))
5116 (or (and (string-match "^\".+\"" gnus-tmp-from)
5117 (substring gnus-tmp-from 1 (1- (match-end 0))))
5118 (substring gnus-tmp-from 0 beg-match)))
5119 ((string-match "(.+)" gnus-tmp-from)
5120 (substring gnus-tmp-from
5121 (1+ (match-beginning 0)) (1- (match-end 0))))
5125 gnus-tmp-thread-tree-header-string
5127 ((not gnus-show-threads) "")
5128 ((zerop gnus-tmp-level)
5129 (cond ((cdar thread)
5130 (or gnus-sum-thread-tree-root subject))
5131 (gnus-tmp-new-adopts
5132 (or gnus-sum-thread-tree-false-root subject))
5134 (or gnus-sum-thread-tree-single-indent subject))))
5136 (concat (apply 'concat
5137 (mapcar (lambda (item)
5139 gnus-sum-thread-tree-vertical
5140 gnus-sum-thread-tree-indent))
5141 (cdr (reverse tree-stack))))
5143 gnus-sum-thread-tree-leaf-with-other
5144 gnus-sum-thread-tree-single-leaf)))))
5145 (when (string= gnus-tmp-name "")
5146 (setq gnus-tmp-name gnus-tmp-from))
5147 (unless (numberp gnus-tmp-lines)
5148 (setq gnus-tmp-lines -1))
5149 (if (= gnus-tmp-lines -1)
5150 (setq gnus-tmp-lines "?")
5151 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5152 (gnus-put-text-property
5154 (progn (eval gnus-summary-line-format-spec) (point))
5155 'gnus-number number)
5158 (gnus-run-hooks 'gnus-summary-update-hook)
5161 (setq gnus-tmp-prev-subject simp-subject)))
5163 (when (nth 1 thread)
5164 (push (list (max 0 gnus-tmp-level)
5165 (copy-sequence tree-stack)
5168 (push (if (nth 1 thread) 1 0) tree-stack)
5169 (incf gnus-tmp-level)
5170 (setq threads (if thread-end nil (cdar thread)))
5171 (if gnus-summary-display-while-building
5174 ;; use a set frequency
5175 (setq building-line-count (1- building-line-count))
5176 (when (= building-line-count 0)
5178 (setq building-line-count
5179 gnus-summary-display-while-building)))
5183 (setq gnus-tmp-level 0)))))
5184 (gnus-message 7 "Generating summary...done"))
5186 (defun gnus-summary-prepare-unthreaded (headers)
5187 "Generate an unthreaded summary buffer based on HEADERS."
5188 (let (header number mark)
5193 ;; We may have to root out some bad articles...
5194 (when (memq (setq number (mail-header-number
5195 (setq header (pop headers))))
5196 gnus-newsgroup-limit)
5197 ;; Mark article as read when it has a low score.
5198 (when (and gnus-summary-mark-below
5199 (< (or (cdr (assq number gnus-newsgroup-scored))
5200 gnus-summary-default-score 0)
5201 gnus-summary-mark-below)
5202 (not (gnus-summary-article-ancient-p number)))
5203 (setq gnus-newsgroup-unreads
5204 (delq number gnus-newsgroup-unreads))
5205 (if gnus-newsgroup-auto-expire
5206 (push number gnus-newsgroup-expirable)
5207 (push (cons number gnus-low-score-mark)
5208 gnus-newsgroup-reads)))
5210 (setq mark (gnus-article-mark number))
5211 (push (gnus-data-make number mark (1+ (point)) header 0)
5212 gnus-newsgroup-data)
5213 (gnus-summary-insert-line
5215 (memq number gnus-newsgroup-undownloaded)
5216 mark (memq number gnus-newsgroup-replied)
5217 (memq number gnus-newsgroup-expirable)
5218 (mail-header-subject header) nil
5219 (cdr (assq number gnus-newsgroup-scored))
5220 (memq number gnus-newsgroup-processable))))))
5222 (defun gnus-summary-remove-list-identifiers ()
5223 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5224 (let ((regexp (if (consp gnus-list-identifiers)
5225 (mapconcat 'identity gnus-list-identifiers " *\\|")
5226 gnus-list-identifiers))
5229 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5230 (dolist (header gnus-newsgroup-headers)
5231 (setq subject (mail-header-subject header)
5233 (while (string-match regexp subject)
5235 (concat (substring subject 0 (match-beginning 1))
5236 (substring subject (match-end 0)))
5239 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5241 (concat (substring subject 0 (match-beginning 1))
5242 (substring subject (match-end 1)))))
5243 (mail-header-set-subject header subject))))))
5245 (defun gnus-fetch-headers (articles)
5246 "Fetch headers of ARTICLES."
5247 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5248 (gnus-message 5 "Fetching headers for %s..." name)
5251 (setq gnus-headers-retrieved-by
5252 (gnus-retrieve-headers
5253 articles gnus-newsgroup-name
5254 ;; We might want to fetch old headers, but
5255 ;; not if there is only 1 article.
5257 (not (eq gnus-fetch-old-headers 'some))
5258 (not (numberp gnus-fetch-old-headers)))
5259 (> (length articles) 1))
5260 gnus-fetch-old-headers))))
5261 (gnus-get-newsgroup-headers-xover
5262 articles nil nil gnus-newsgroup-name t)
5263 (gnus-get-newsgroup-headers))
5264 (gnus-message 5 "Fetching headers for %s...done" name))))
5266 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5267 "Select newsgroup GROUP.
5268 If READ-ALL is non-nil, all articles in the group are selected.
5269 If SELECT-ARTICLES, only select those articles from GROUP."
5270 (let* ((entry (gnus-group-entry group))
5271 ;;!!! Dirty hack; should be removed.
5272 (gnus-summary-ignore-duplicates
5273 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5275 gnus-summary-ignore-duplicates))
5276 (info (nth 2 entry))
5277 articles fetched-articles cached)
5279 (unless (gnus-check-server
5280 (set (make-local-variable 'gnus-current-select-method)
5281 (gnus-find-method-for-group group)))
5282 (error "Couldn't open server"))
5284 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5285 (gnus-activate-group group) ; Or we can activate it...
5286 (progn ; Or we bug out.
5287 (when (equal major-mode 'gnus-summary-mode)
5288 (gnus-kill-buffer (current-buffer)))
5289 (error "Couldn't activate group %s: %s"
5290 group (gnus-status-message group))))
5292 (unless (gnus-request-group group t)
5293 (when (equal major-mode 'gnus-summary-mode)
5294 (gnus-kill-buffer (current-buffer)))
5295 (error "Couldn't request group %s: %s"
5296 group (gnus-status-message group)))
5299 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5301 (setq gnus-summary-use-undownloaded-faces
5302 (gnus-agent-find-parameter
5304 'agent-enable-undownloaded-faces)))
5306 (setq gnus-newsgroup-name group
5307 gnus-newsgroup-unselected nil
5308 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5310 (let ((display (gnus-group-find-parameter group 'display)))
5311 (setq gnus-newsgroup-display
5313 ((not (zerop (or (car-safe read-all) 0)))
5314 ;; The user entered the group with C-u SPC/RET, let's show
5320 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5322 ;; The following is probably the "correct" solution, but
5323 ;; it makes Gnus fetch all headers and then limit the
5324 ;; articles (which is slow), so instead we hack the
5325 ;; select-articles parameter instead. -- Simon Josefsson
5328 ;; (gnus-byte-compile
5329 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5331 (setq select-articles
5332 (gnus-uncompress-range
5333 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5337 (cdr (gnus-active group)))))
5342 (gnus-summary-setup-default-charset)
5344 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5345 (when (gnus-virtual-group-p group)
5346 (setq cached gnus-newsgroup-cached))
5348 (setq gnus-newsgroup-unreads
5349 (gnus-sorted-ndifference
5350 (gnus-sorted-ndifference gnus-newsgroup-unreads
5351 gnus-newsgroup-marked)
5352 gnus-newsgroup-dormant))
5354 (setq gnus-newsgroup-processable nil)
5356 (gnus-update-read-articles group gnus-newsgroup-unreads)
5358 ;; Adjust and set lists of article marks.
5360 (gnus-adjust-marked-articles info))
5361 (if (setq articles select-articles)
5362 (setq gnus-newsgroup-unselected
5363 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5364 (setq articles (gnus-articles-to-read group read-all)))
5368 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5370 ((eq articles 0) nil)
5372 ;; Init the dependencies hash table.
5373 (setq gnus-newsgroup-dependencies
5374 (gnus-make-hashtable (length articles)))
5375 (gnus-set-global-variables)
5376 ;; Retrieve the headers and read them in.
5378 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5380 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5382 (setq gnus-newsgroup-cached cached))
5384 ;; Suppress duplicates?
5385 (when gnus-suppress-duplicates
5386 (gnus-dup-suppress-articles))
5388 ;; Set the initial limit.
5389 (setq gnus-newsgroup-limit (copy-sequence articles))
5390 ;; Remove canceled articles from the list of unread articles.
5391 (setq fetched-articles
5392 (mapcar (lambda (headers) (mail-header-number headers))
5393 gnus-newsgroup-headers))
5394 (setq gnus-newsgroup-articles fetched-articles)
5395 (setq gnus-newsgroup-unreads
5396 (gnus-sorted-nintersection
5397 gnus-newsgroup-unreads fetched-articles))
5398 (gnus-compute-unseen-list)
5400 ;; Removed marked articles that do not exist.
5401 (gnus-update-missing-marks
5402 (gnus-sorted-difference articles fetched-articles))
5403 ;; We might want to build some more threads first.
5404 (when (and gnus-fetch-old-headers
5405 (eq gnus-headers-retrieved-by 'nov))
5406 (if (eq gnus-fetch-old-headers 'invisible)
5407 (gnus-build-all-threads)
5408 (gnus-build-old-threads)))
5409 ;; Let the Gnus agent mark articles as read.
5411 (gnus-agent-get-undownloaded-list))
5412 ;; Remove list identifiers from subject
5413 (when gnus-list-identifiers
5414 (gnus-summary-remove-list-identifiers))
5415 ;; Check whether auto-expire is to be done in this group.
5416 (setq gnus-newsgroup-auto-expire
5417 (gnus-group-auto-expirable-p group))
5418 ;; Set up the article buffer now, if necessary.
5419 (unless gnus-single-article-buffer
5420 (gnus-article-setup-buffer))
5421 ;; First and last article in this newsgroup.
5422 (when gnus-newsgroup-headers
5423 (setq gnus-newsgroup-begin
5424 (mail-header-number (car gnus-newsgroup-headers))
5427 (gnus-last-element gnus-newsgroup-headers))))
5428 ;; GROUP is successfully selected.
5429 (or gnus-newsgroup-headers t)))))
5431 (defun gnus-compute-unseen-list ()
5432 ;; The `seen' marks are treated specially.
5433 (if (not gnus-newsgroup-seen)
5434 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5435 (setq gnus-newsgroup-unseen
5436 (gnus-inverse-list-range-intersection
5437 gnus-newsgroup-articles gnus-newsgroup-seen))))
5439 (defun gnus-summary-display-make-predicate (display)
5440 (require 'gnus-agent)
5441 (when (= (length display) 1)
5442 (setq display (car display)))
5443 (unless gnus-summary-display-cache
5444 (dolist (elem (append '((unread . unread)
5447 gnus-article-mark-lists))
5448 (push (cons (cdr elem)
5450 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5451 gnus-summary-display-cache)))
5452 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5453 (gnus-category-predicate-cache gnus-summary-display-cache))
5454 (gnus-get-predicate display)))
5456 ;; Uses the dynamically bound `number' variable.
5459 (defun gnus-article-marked-p (type &optional article)
5460 (let ((article (or article number)))
5463 (memq article gnus-newsgroup-marked))
5465 (memq article gnus-newsgroup-spam-marked))
5467 (memq article gnus-newsgroup-unsendable))
5468 ((eq type 'undownload)
5469 (memq article gnus-newsgroup-undownloaded))
5470 ((eq type 'download)
5471 (memq article gnus-newsgroup-downloadable))
5473 (memq article gnus-newsgroup-unreads))
5475 (memq article gnus-newsgroup-reads))
5477 (memq article gnus-newsgroup-dormant) )
5479 (memq article gnus-newsgroup-expirable))
5481 (memq article gnus-newsgroup-replied))
5483 (memq article gnus-newsgroup-killed))
5484 ((eq type 'bookmark)
5485 (assq article gnus-newsgroup-bookmarks))
5487 (assq article gnus-newsgroup-scored))
5489 (memq article gnus-newsgroup-saved))
5491 (memq article gnus-newsgroup-cached))
5493 (memq article gnus-newsgroup-forwarded))
5495 (not (memq article gnus-newsgroup-unseen)))
5497 (memq article gnus-newsgroup-recent))
5500 (defun gnus-articles-to-read (group &optional read-all)
5501 "Find out what articles the user wants to read."
5503 ;; Select all articles if `read-all' is non-nil, or if there
5504 ;; are no unread articles.
5506 (and (zerop (length gnus-newsgroup-marked))
5507 (zerop (length gnus-newsgroup-unreads)))
5508 ;; Fetch all if the predicate is non-nil.
5509 gnus-newsgroup-display)
5510 ;; We want to select the headers for all the articles in
5511 ;; the group, so we select either all the active
5512 ;; articles in the group, or (if that's nil), the
5513 ;; articles in the cache.
5515 (gnus-uncompress-range (gnus-active group))
5516 (gnus-cache-articles-in-group group))
5517 ;; Select only the "normal" subset of articles.
5519 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5520 gnus-newsgroup-unreads)))
5521 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5522 (scored (length scored-list))
5523 (number (length articles))
5524 (marked (+ (length gnus-newsgroup-marked)
5525 (length gnus-newsgroup-dormant)))
5530 ((numberp gnus-newsgroup-display)
5531 gnus-newsgroup-display)
5535 ((and (or (<= scored marked) (= scored number))
5536 (numberp gnus-large-newsgroup)
5537 (> number gnus-large-newsgroup))
5538 (let* ((cursor-in-echo-area nil)
5539 (initial (gnus-parameter-large-newsgroup-initial
5540 gnus-newsgroup-name))
5544 "How many articles from %s (%s %d): "
5546 (gnus-group-decoded-name gnus-newsgroup-name)
5548 (if initial "max" "default")
5551 (cons (number-to-string initial)
5553 (if (string-match "^[ \t]*$" input) number input)))
5554 ((and (> scored marked) (< scored number)
5555 (> (- scored number) 20))
5558 (format "%s %s (%d scored, %d total): "
5559 "How many articles from"
5560 (gnus-group-decoded-name group)
5562 (if (string-match "^[ \t]*$" input)
5566 (message "Quit getting the articles to read")
5568 (setq select (if (stringp select) (string-to-number select) select))
5569 (if (or (null select) (zerop select))
5571 (if (and (not (zerop scored)) (<= (abs select) scored))
5573 (setq articles (sort scored-list '<))
5574 (setq number (length articles)))
5575 (setq articles (copy-sequence articles)))
5577 (when (< (abs select) number)
5579 ;; Select the N oldest articles.
5580 (setcdr (nthcdr (1- (abs select)) articles) nil)
5581 ;; Select the N most recent articles.
5582 (setq articles (nthcdr (- number select) articles))))
5583 (setq gnus-newsgroup-unselected
5584 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5585 (when gnus-alter-articles-to-read-function
5588 (funcall gnus-alter-articles-to-read-function
5589 gnus-newsgroup-name articles)
5593 (defun gnus-killed-articles (killed articles)
5596 (when (inline (gnus-member-of-range (car articles) killed))
5597 (push (car articles) out))
5598 (setq articles (cdr articles)))
5601 (defun gnus-uncompress-marks (marks)
5602 "Uncompress the mark ranges in MARKS."
5603 (let ((uncompressed '(score bookmark))
5606 (if (memq (caar marks) uncompressed)
5607 (push (car marks) out)
5608 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5609 (setq marks (cdr marks)))
5612 (defun gnus-article-mark-to-type (mark)
5613 "Return the type of MARK."
5614 (or (cadr (assq mark gnus-article-special-mark-lists))
5617 (defun gnus-article-unpropagatable-p (mark)
5618 "Return whether MARK should be propagated to back end."
5619 (memq mark gnus-article-unpropagated-mark-lists))
5621 (defun gnus-adjust-marked-articles (info)
5622 "Set all article lists and remove all marks that are no longer valid."
5623 (let* ((marked-lists (gnus-info-marks info))
5624 (active (gnus-active (gnus-info-group info)))
5627 (types gnus-article-mark-lists)
5628 marks var articles article mark mark-type
5631 (dolist (marks marked-lists)
5632 (setq mark (car marks)
5633 mark-type (gnus-article-mark-to-type mark)
5634 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5636 ;; We set the variable according to the type of the marks list,
5637 ;; and then adjust the marks to a subset of the active articles.
5639 ;; Adjust "simple" lists - compressed yet unsorted
5640 ((eq mark-type 'list)
5641 ;; Simultaneously uncompress and clip to active range
5642 ;; See gnus-uncompress-range for a description of possible marks
5644 (if (not (cadr marks))
5646 (setq articles (if (numberp (cddr marks))
5652 (while (setq article (pop articles))
5653 (cond ((consp article)
5654 (setq bgn (max (car article) min)
5655 end (min (cdr article) max))
5657 (setq l (setcdr l (cons bgn nil))
5659 ((and (<= min article)
5661 (setq l (setcdr l (cons article nil))))))
5662 (set var (cdr lh)))))
5664 ((eq mark-type 'tuple)
5665 (set var (setq articles (cdr marks)))
5666 (when (not (listp (cdr (symbol-value var))))
5667 (set var (list (symbol-value var))))
5668 (when (not (listp (cdr articles)))
5669 (setq articles (list articles)))
5671 (when (or (not (consp (setq article (pop articles))))
5672 (< (car article) min)
5673 (> (car article) max))
5674 (set var (delq article (symbol-value var))))))
5675 ;; Adjust ranges (sloppily).
5676 ((eq mark-type 'range)
5679 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5680 ;; It should be (seen (NUM1 . NUM2)).
5681 (when (numberp (cddr marks))
5682 (setcdr marks (list (cdr marks))))
5683 (setq articles (cdr marks))
5684 (while (and articles
5685 (or (and (consp (car articles))
5686 (> min (cdar articles)))
5687 (and (numberp (car articles))
5688 (> min (car articles)))))
5690 (set var articles))))))))
5692 (defun gnus-update-missing-marks (missing)
5693 "Go through the list of MISSING articles and remove them from the mark lists."
5696 ;; Go through all types.
5697 (dolist (elem gnus-article-mark-lists)
5698 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5699 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5700 (when (symbol-value var)
5701 ;; This list has articles. So we delete all missing
5702 ;; articles from it.
5705 (set var (delq (pop m) (symbol-value var))))))))))
5707 (defun gnus-update-marks ()
5708 "Enter the various lists of marked articles into the newsgroup info list."
5709 (let ((types gnus-article-mark-lists)
5710 (info (gnus-get-info gnus-newsgroup-name))
5711 type list newmarked symbol delta-marks)
5713 ;; Add all marks lists to the list of marks lists.
5714 (while (setq type (pop types))
5715 (setq list (symbol-value
5717 (intern (format "gnus-newsgroup-%s" (car type))))))
5720 ;; Get rid of the entries of the articles that have the
5722 (when (and (eq (cdr type) 'score)
5726 (prev (cons nil list))
5729 (if (or (not (consp (car arts)))
5730 (= (cdar arts) gnus-summary-default-score))
5731 (setcdr prev (cdr arts))
5733 (setq arts (cdr arts)))
5734 (setq list (cdr all)))))
5736 (when (eq (cdr type) 'seen)
5737 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5739 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5740 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5742 (when (and (gnus-check-backend-function
5743 'request-set-mark gnus-newsgroup-name)
5744 (not (gnus-article-unpropagatable-p (cdr type))))
5745 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5746 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5747 (add (gnus-remove-from-range
5748 (gnus-copy-sequence list) old)))
5750 (push (list add 'add (list (cdr type))) delta-marks))
5752 (push (list del 'del (list (cdr type))) delta-marks))))
5755 (push (cons (cdr type) list) newmarked)))
5758 (unless (gnus-check-group gnus-newsgroup-name)
5759 (error "Can't open server for %s" gnus-newsgroup-name))
5760 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5762 ;; Enter these new marks into the info of the group.
5764 (setcar (nthcdr 3 info) newmarked)
5765 ;; Add the marks lists to the end of the info.
5767 (setcdr (nthcdr 2 info) (list newmarked))))
5769 ;; Cut off the end of the info if there's nothing else there.
5773 (when (nthcdr (decf i) info)
5774 (setcdr (nthcdr i info) nil)))))))
5776 (defun gnus-set-mode-line (where)
5777 "Set the mode line of the article or summary buffers.
5778 If WHERE is `summary', the summary mode line format will be used."
5779 ;; Is this mode line one we keep updated?
5780 (when (and (memq where gnus-updated-mode-lines)
5782 (intern (format "gnus-%s-mode-line-format-spec" where))))
5785 ;; We evaluate this in the summary buffer since these
5786 ;; variables are buffer-local to that buffer.
5787 (set-buffer gnus-summary-buffer)
5788 ;; We bind all these variables that are used in the `eval' form
5790 (let* ((mformat (symbol-value
5792 (format "gnus-%s-mode-line-format-spec" where))))
5793 (gnus-tmp-group-name (gnus-group-decoded-name
5794 gnus-newsgroup-name))
5795 (gnus-tmp-article-number (or gnus-current-article 0))
5796 (gnus-tmp-unread gnus-newsgroup-unreads)
5797 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5798 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5799 (gnus-tmp-unread-and-unselected
5800 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5801 (zerop gnus-tmp-unselected))
5803 ((zerop gnus-tmp-unselected)
5804 (format "{%d more}" gnus-tmp-unread-and-unticked))
5805 (t (format "{%d(+%d) more}"
5806 gnus-tmp-unread-and-unticked
5807 gnus-tmp-unselected))))
5809 (if (and gnus-current-headers
5810 (vectorp gnus-current-headers))
5811 (gnus-mode-string-quote
5812 (mail-header-subject gnus-current-headers))
5814 bufname-length max-len
5815 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5816 (setq mode-string (eval mformat))
5817 (setq bufname-length (if (string-match "%b" mode-string)
5820 (if (eq where 'summary)
5822 (get-buffer gnus-article-buffer))))
5825 (setq max-len (max 4 (if gnus-mode-non-string-length
5827 gnus-mode-non-string-length
5829 (length mode-string))))
5830 ;; We might have to chop a bit of the string off...
5831 (when (> (length mode-string) max-len)
5833 (concat (truncate-string-to-width mode-string (- max-len 3))
5835 ;; Pad the mode string a bit.
5836 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5837 ;; Update the mode line.
5838 (setq mode-line-buffer-identification
5839 (gnus-mode-line-buffer-identification (list mode-string)))
5840 (set-buffer-modified-p t))))
5842 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5843 "Go through the HEADERS list and add all Xrefs to a hash table.
5844 The resulting hash table is returned, or nil if no Xrefs were found."
5845 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5846 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5847 (xref-hashtb (gnus-make-hashtable))
5848 start group entry number xrefs header)
5850 (setq header (pop headers))
5851 (when (and (setq xrefs (mail-header-xref header))
5852 (not (memq (setq number (mail-header-number header))
5855 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5856 (setq start (match-end 0))
5857 (setq group (if prefix
5858 (concat prefix (substring xrefs (match-beginning 1)
5860 (substring xrefs (match-beginning 1) (match-end 1))))
5862 (string-to-number (substring xrefs (match-beginning 2)
5864 (if (setq entry (gnus-gethash group xref-hashtb))
5865 (setcdr entry (cons number (cdr entry)))
5866 (gnus-sethash group (cons number nil) xref-hashtb)))))
5867 (and start xref-hashtb)))
5869 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5870 "Look through all the headers and mark the Xrefs as read."
5871 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5872 name info xref-hashtb idlist method nth4)
5874 (set-buffer gnus-group-buffer)
5875 (when (setq xref-hashtb
5876 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5879 (unless (string= from-newsgroup (setq name (symbol-name group)))
5880 (setq idlist (symbol-value group))
5881 ;; Dead groups are not updated.
5883 (setq info (gnus-get-info name))
5884 (when (stringp (setq nth4 (gnus-info-method info)))
5885 (setq nth4 (gnus-server-to-method nth4))))
5886 ;; Only do the xrefs if the group has the same
5887 ;; select method as the group we have just read.
5888 (or (gnus-methods-equal-p
5889 nth4 (gnus-find-method-for-group from-newsgroup))
5891 (equal nth4 (setq method (gnus-find-method-for-group
5893 (and (equal (car nth4) (car method))
5894 (equal (nth 1 nth4) (nth 1 method))))
5895 gnus-use-cross-reference
5896 (or (not (eq gnus-use-cross-reference t))
5898 ;; Only do cross-references on subscribed
5899 ;; groups, if that is what is wanted.
5900 (<= (gnus-info-level info) gnus-level-subscribed))
5901 (gnus-group-make-articles-read name idlist))))
5904 (defun gnus-compute-read-articles (group articles)
5905 (let* ((entry (gnus-group-entry group))
5906 (info (nth 2 entry))
5907 (active (gnus-active group))
5910 ;; First peel off all invalid article numbers.
5912 (let ((ids articles)
5914 (while (setq id (pop ids))
5915 (when (and first (> id (cdr active)))
5916 ;; We'll end up in this situation in one particular
5917 ;; obscure situation. If you re-scan a group and get
5918 ;; a new article that is cross-posted to a different
5919 ;; group that has not been re-scanned, you might get
5920 ;; crossposted article that has a higher number than
5921 ;; Gnus believes possible. So we re-activate this
5922 ;; group as well. This might mean doing the
5923 ;; crossposting thingy will *increase* the number
5924 ;; of articles in some groups. Tsk, tsk.
5925 (setq active (or (gnus-activate-group group) active)))
5926 (when (or (> id (cdr active))
5927 (< id (car active)))
5928 (setq articles (delq id articles))))))
5929 ;; If the read list is nil, we init it.
5931 (null (gnus-info-read info))
5933 (setq ninfo (cons 1 (1- (car active))))
5934 (setq ninfo (gnus-info-read info)))
5935 ;; Then we add the read articles to the range.
5937 ninfo (setq articles (sort articles '<))))))
5939 (defun gnus-group-make-articles-read (group articles)
5940 "Update the info of GROUP to say that ARTICLES are read."
5942 (entry (gnus-group-entry group))
5943 (info (nth 2 entry))
5944 (active (gnus-active group))
5947 (setq range (gnus-compute-read-articles group articles))
5948 (with-current-buffer gnus-group-buffer
5951 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5952 (gnus-info-set-read ',info ',(gnus-info-read info))
5953 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5954 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5955 (gnus-group-update-group ,group t))))
5956 ;; Add the read articles to the range.
5957 (gnus-info-set-read info range)
5958 (gnus-request-set-mark group (list (list range 'add '(read))))
5959 ;; Then we have to re-compute how many unread
5960 ;; articles there are in this group.
5964 (setq num (- (1+ (cdr active)) (car active))))
5965 ((not (listp (cdr range)))
5966 (setq num (- (cdr active) (- (1+ (cdr range))
5970 (if (numberp (car range))
5972 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5973 (setq range (cdr range)))
5974 (setq num (- (cdr active) num))))
5975 ;; Update the number of unread articles.
5977 ;; Update the group buffer.
5978 (unless (gnus-ephemeral-group-p group)
5979 (gnus-group-update-group group t))))))
5981 (defvar gnus-newsgroup-none-id 0)
5983 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5984 (let ((cur nntp-server-buffer)
5987 (with-current-buffer gnus-summary-buffer
5988 gnus-newsgroup-dependencies)))
5989 headers id end ref number
5990 (mail-parse-charset gnus-newsgroup-charset)
5991 (mail-parse-ignored-charsets
5992 (save-excursion (condition-case nil
5993 (set-buffer gnus-summary-buffer)
5995 gnus-newsgroup-ignored-charsets)))
5997 (set-buffer nntp-server-buffer)
5998 ;; Translate all TAB characters into SPACE characters.
5999 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6000 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6001 (ietf-drums-unfold-fws)
6002 (gnus-run-hooks 'gnus-parse-headers-hook)
6003 (let ((case-fold-search t)
6004 in-reply-to header p lines chars)
6005 (goto-char (point-min))
6006 ;; Search to the beginning of the next header. Error messages
6007 ;; do not begin with 2 or 3.
6008 (while (re-search-forward "^[23][0-9]+ " nil t)
6011 ;; This implementation of this function, with nine
6012 ;; search-forwards instead of the one re-search-forward and
6013 ;; a case (which basically was the old function) is actually
6014 ;; about twice as fast, even though it looks messier. You
6015 ;; can't have everything, I guess. Speed and elegance
6016 ;; doesn't always go hand in hand.
6022 (setq number (read cur))
6025 (narrow-to-region (point)
6026 (or (and (search-forward "\n.\n" nil t)
6032 (if (search-forward "\nsubject:" nil t)
6033 (funcall gnus-decode-encoded-word-function
6034 (nnheader-header-value))
6039 (if (search-forward "\nfrom:" nil t)
6040 (funcall gnus-decode-encoded-word-function
6041 (nnheader-header-value))
6046 (if (search-forward "\ndate:" nil t)
6047 (nnheader-header-value) ""))
6051 (setq id (if (re-search-forward
6052 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6053 ;; We do it this way to make sure the Message-ID
6054 ;; is (somewhat) syntactically valid.
6055 (buffer-substring (match-beginning 1)
6057 ;; If there was no message-id, we just fake one
6058 ;; to make subsequent routines simpler.
6059 (nnheader-generate-fake-message-id number))))
6063 (if (search-forward "\nreferences:" nil t)
6067 (nnheader-header-value)
6072 (search-backward ">" end t)
6075 (search-backward "<" end t)
6077 ;; Get the references from the in-reply-to header if there
6078 ;; were no references and the in-reply-to header looks
6080 (if (and (search-forward "\nin-reply-to:" nil t)
6081 (setq in-reply-to (nnheader-header-value))
6082 (string-match "<[^>]+>" in-reply-to))
6084 (setq ref (substring in-reply-to (match-beginning 0)
6086 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6087 (setq ref2 (substring in-reply-to (match-beginning 0)
6089 (when (> (length ref2) (length ref))
6096 (if (search-forward "\nchars: " nil t)
6097 (if (numberp (setq chars (ignore-errors (read cur))))
6103 (if (search-forward "\nlines: " nil t)
6104 (if (numberp (setq lines (ignore-errors (read cur))))
6110 (and (search-forward "\nxref:" nil t)
6111 (nnheader-header-value)))
6113 (when gnus-extra-headers
6114 (let ((extra gnus-extra-headers)
6118 (when (search-forward
6119 (concat "\n" (symbol-name (car extra)) ":") nil t)
6120 (push (cons (car extra) (nnheader-header-value))
6124 (when (equal id ref)
6127 (when gnus-alter-header-function
6128 (funcall gnus-alter-header-function header)
6129 (setq id (mail-header-id header)
6130 ref (gnus-parent-id (mail-header-references header))))
6133 (gnus-dependencies-add-header
6134 header dependencies force-new))
6135 (push header headers))
6136 (goto-char (point-max))
6138 (nreverse headers)))))
6140 ;; Goes through the xover lines and returns a list of vectors
6141 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6142 force-new dependencies
6143 group also-fetch-heads)
6144 "Parse the news overview data in the server buffer.
6145 Return a list of headers that match SEQUENCE (see
6146 `nntp-retrieve-headers')."
6147 ;; Get the Xref when the users reads the articles since most/some
6148 ;; NNTP servers do not include Xrefs when using XOVER.
6149 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6150 (let ((mail-parse-charset gnus-newsgroup-charset)
6151 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6152 (cur nntp-server-buffer)
6153 (dependencies (or dependencies gnus-newsgroup-dependencies))
6155 ((eq gnus-read-all-available-headers t)
6157 ((stringp gnus-read-all-available-headers)
6158 (string-match gnus-read-all-available-headers group))
6161 number headers header)
6163 (set-buffer nntp-server-buffer)
6164 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6165 ;; Allow the user to mangle the headers before parsing them.
6166 (gnus-run-hooks 'gnus-parse-headers-hook)
6167 (goto-char (point-min))
6168 (gnus-parse-without-error
6169 (while (and (or sequence allp)
6171 (setq number (read cur))
6173 (while (and sequence
6174 (< (car sequence) number))
6175 (setq sequence (cdr sequence))))
6178 (eq number (car sequence))))
6180 (setq sequence (cdr sequence))
6181 (setq header (inline
6182 (gnus-nov-parse-line
6183 number dependencies force-new)))))
6184 (push header headers))
6186 ;; A common bug in inn is that if you have posted an article and
6187 ;; then retrieves the active file, it will answer correctly --
6188 ;; the new article is included. However, a NOV entry for the
6189 ;; article may not have been generated yet, so this may fail.
6190 ;; We work around this problem by retrieving the last few
6191 ;; headers using HEAD.
6192 (if (or (not also-fetch-heads)
6194 ;; We (probably) got all the headers.
6196 (let ((gnus-nov-is-evil t))
6199 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6200 (gnus-get-newsgroup-headers))))))))
6202 (defun gnus-article-get-xrefs ()
6203 "Fill in the Xref value in `gnus-current-headers', if necessary.
6204 This is meant to be called in `gnus-article-internal-prepare-hook'."
6205 (let ((headers (with-current-buffer gnus-summary-buffer
6206 gnus-current-headers)))
6207 (or (not gnus-use-cross-reference)
6209 (and (mail-header-xref headers)
6210 (not (string= (mail-header-xref headers) "")))
6211 (let ((case-fold-search t)
6214 (nnheader-narrow-to-headers)
6215 (goto-char (point-min))
6216 (when (or (and (not (eobp))
6217 (eq (downcase (char-after)) ?x)
6218 (looking-at "Xref:"))
6219 (search-forward "\nXref:" nil t))
6220 (goto-char (1+ (match-end 0)))
6221 (setq xref (buffer-substring (point) (point-at-eol)))
6222 (mail-header-set-xref headers xref)))))))
6224 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6225 "Find article ID and insert the summary line for that article.
6226 OLD-HEADER can either be a header or a line number to insert
6227 the subject line on."
6228 (let* ((line (and (numberp old-header) old-header))
6229 (old-header (and (vectorp old-header) old-header))
6230 (header (cond ((and old-header use-old-header)
6233 (gnus-number-to-header id))
6234 (gnus-number-to-header id))
6236 (gnus-read-header id))))
6237 (number (and (numberp id) id))
6240 ;; Rebuild the thread that this article is part of and go to the
6241 ;; article we have fetched.
6242 (when (and (not gnus-show-threads)
6245 (setq d (gnus-data-find (mail-header-number old-header))))
6246 (goto-char (gnus-data-pos d))
6252 (gnus-delete-line))))))
6253 ;; Remove list identifiers from subject.
6254 (when gnus-list-identifiers
6255 (let ((gnus-newsgroup-headers (list header)))
6256 (gnus-summary-remove-list-identifiers)))
6258 (mail-header-set-number header (mail-header-number old-header)))
6259 (setq gnus-newsgroup-sparse
6260 (delq (setq number (mail-header-number header))
6261 gnus-newsgroup-sparse))
6262 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6263 (push number gnus-newsgroup-limit)
6264 (gnus-rebuild-thread (mail-header-id header) line)
6265 (gnus-summary-goto-subject number nil t))
6266 (when (and (numberp number)
6268 ;; We have to update the boundaries even if we can't fetch the
6269 ;; article if ID is a number -- so that the next `P' or `N'
6270 ;; command will fetch the previous (or next) article even
6271 ;; if the one we tried to fetch this time has been canceled.
6272 (when (> number gnus-newsgroup-end)
6273 (setq gnus-newsgroup-end number))
6274 (when (< number gnus-newsgroup-begin)
6275 (setq gnus-newsgroup-begin number))
6276 (setq gnus-newsgroup-unselected
6277 (delq number gnus-newsgroup-unselected)))
6278 ;; Report back a success?
6279 (and header (mail-header-number header))))
6281 ;;; Process/prefix in the summary buffer
6283 (defun gnus-summary-work-articles (n)
6284 "Return a list of articles to be worked upon.
6285 The prefix argument, the list of process marked articles, and the
6286 current article will be taken into consideration."
6288 (set-buffer gnus-summary-buffer)
6291 ;; A numerical prefix has been given.
6292 (setq n (prefix-numeric-value n))
6293 (let ((backward (< n 0))
6294 (n (abs (prefix-numeric-value n)))
6299 (push (setq article (gnus-summary-article-number))
6302 (gnus-summary-find-prev nil article)
6303 (gnus-summary-find-next nil article)))
6305 (nreverse articles)))
6306 ((and (gnus-region-active-p) (mark))
6307 (message "region active")
6308 ;; Work on the region between point and mark.
6309 (let ((max (max (point) (mark)))
6312 (goto-char (min (point) (mark)))
6315 (push (setq article (gnus-summary-article-number)) articles)
6316 (gnus-summary-find-next nil article)
6318 (nreverse articles))))
6319 (gnus-newsgroup-processable
6320 ;; There are process-marked articles present.
6321 ;; Save current state.
6322 (gnus-summary-save-process-mark)
6324 (reverse gnus-newsgroup-processable))
6326 ;; Just return the current article.
6327 (list (gnus-summary-article-number))))))
6329 (defmacro gnus-summary-iterate (arg &rest forms)
6330 "Iterate over the process/prefixed articles and do FORMS.
6331 ARG is the interactive prefix given to the command. FORMS will be
6332 executed with point over the summary line of the articles."
6333 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6334 `(let ((,articles (gnus-summary-work-articles ,arg)))
6336 (gnus-summary-goto-subject (car ,articles))
6340 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6341 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6343 (defun gnus-summary-save-process-mark ()
6344 "Push the current set of process marked articles on the stack."
6346 (push (copy-sequence gnus-newsgroup-processable)
6347 gnus-newsgroup-process-stack))
6349 (defun gnus-summary-kill-process-mark ()
6350 "Push the current set of process marked articles on the stack and unmark."
6352 (gnus-summary-save-process-mark)
6353 (gnus-summary-unmark-all-processable))
6355 (defun gnus-summary-yank-process-mark ()
6356 "Pop the last process mark state off the stack and restore it."
6358 (unless gnus-newsgroup-process-stack
6359 (error "Empty mark stack"))
6360 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6362 (defun gnus-summary-process-mark-set (set)
6363 "Make SET into the current process marked articles."
6364 (gnus-summary-unmark-all-processable)
6365 (mapc 'gnus-summary-set-process-mark set))
6367 ;;; Searching and stuff
6369 (defun gnus-summary-search-group (&optional backward use-level)
6370 "Search for next unread newsgroup.
6371 If optional argument BACKWARD is non-nil, search backward instead."
6373 (set-buffer gnus-group-buffer)
6374 (when (gnus-group-search-forward
6375 backward nil (if use-level (gnus-group-group-level) nil))
6376 (gnus-group-group-name))))
6378 (defun gnus-summary-best-group (&optional exclude-group)
6379 "Find the name of the best unread group.
6380 If EXCLUDE-GROUP, do not go to this group."
6381 (with-current-buffer gnus-group-buffer
6383 (gnus-group-best-unread-group exclude-group))))
6385 (defun gnus-summary-find-next (&optional unread article backward)
6387 (gnus-summary-find-prev unread article)
6388 (let* ((dummy (gnus-summary-article-intangible-p))
6389 (article (or article (gnus-summary-article-number)))
6390 (data (gnus-data-find-list article))
6392 (when (and (not dummy)
6393 (or (not gnus-summary-check-current)
6395 (not (gnus-data-unread-p (car data)))))
6396 (setq data (cdr data)))
6401 (unless (memq (gnus-data-number (car data))
6403 ((eq gnus-auto-goto-ignores
6404 'always-undownloaded)
6405 gnus-newsgroup-undownloaded)
6408 ((eq gnus-auto-goto-ignores
6410 gnus-newsgroup-unfetched)
6411 ((eq gnus-auto-goto-ignores
6413 gnus-newsgroup-undownloaded)))
6414 (when (gnus-data-unread-p (car data))
6415 (setq result (car data)
6417 (setq data (cdr data)))
6420 (goto-char (gnus-data-pos result))
6421 (gnus-data-number result)))))
6423 (defun gnus-summary-find-prev (&optional unread article)
6424 (let* ((eobp (eobp))
6425 (article (or article (gnus-summary-article-number)))
6426 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6428 (when (and (not eobp)
6429 (or (not gnus-summary-check-current)
6431 (not (gnus-data-unread-p (car data)))))
6432 (setq data (cdr data)))
6437 (unless (memq (gnus-data-number (car data))
6439 ((eq gnus-auto-goto-ignores
6440 'always-undownloaded)
6441 gnus-newsgroup-undownloaded)
6444 ((eq gnus-auto-goto-ignores
6446 gnus-newsgroup-unfetched)
6447 ((eq gnus-auto-goto-ignores
6449 gnus-newsgroup-undownloaded)))
6450 (when (gnus-data-unread-p (car data))
6451 (setq result (car data)
6453 (setq data (cdr data)))
6456 (goto-char (gnus-data-pos result))
6457 (gnus-data-number result))))
6459 (defun gnus-summary-find-subject (subject &optional unread backward article)
6460 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6461 (article (or article (gnus-summary-article-number)))
6462 (articles (gnus-data-list backward))
6463 (arts (gnus-data-find-list article articles))
6465 (when (or (not gnus-summary-check-current)
6467 (not (gnus-data-unread-p (car arts))))
6468 (setq arts (cdr arts)))
6470 (and (or (not unread)
6471 (gnus-data-unread-p (car arts)))
6472 (vectorp (gnus-data-header (car arts)))
6474 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6475 (setq result (car arts)
6477 (setq arts (cdr arts)))
6479 (goto-char (gnus-data-pos result))
6480 (gnus-data-number result))))
6482 (defun gnus-summary-search-forward (&optional unread subject backward)
6483 "Search forward for an article.
6484 If UNREAD, look for unread articles. If SUBJECT, look for
6485 articles with that subject. If BACKWARD, search backward instead."
6486 (cond (subject (gnus-summary-find-subject subject unread backward))
6487 (backward (gnus-summary-find-prev unread))
6488 (t (gnus-summary-find-next unread))))
6490 (defun gnus-recenter (&optional n)
6491 "Center point in window and redisplay frame.
6492 Also do horizontal recentering."
6494 (when (and gnus-auto-center-summary
6495 (not (eq gnus-auto-center-summary 'vertical)))
6496 (gnus-horizontal-recenter))
6499 (defun gnus-summary-recenter ()
6500 "Center point in the summary window.
6501 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6502 displayed, no centering will be performed."
6503 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6504 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6506 ;; The user has to want it.
6507 (when gnus-auto-center-summary
6508 (let* ((top (cond ((< (window-height) 4) 0)
6509 ((< (window-height) 7) 1)
6510 (t (if (numberp gnus-auto-center-summary)
6511 gnus-auto-center-summary
6512 (/ (1- (window-height)) 2)))))
6513 (height (1- (window-height)))
6514 (bottom (save-excursion (goto-char (point-max))
6515 (forward-line (- height))
6517 (window (get-buffer-window (current-buffer))))
6518 (when (get-buffer-window gnus-article-buffer)
6519 ;; Only do recentering when the article buffer is displayed,
6520 ;; Set the window start to either `bottom', which is the biggest
6521 ;; possible valid number, or the second line from the top,
6522 ;; whichever is the least.
6523 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6524 (if (> bottom top-pos)
6525 ;; Keep the second line from the top visible
6526 (set-window-start window top-pos t)
6527 ;; Try to keep the bottom line visible; if it's partially
6528 ;; obscured, either scroll one more line to make it fully
6529 ;; visible, or revert to using TOP-POS.
6531 (goto-char (point-max))
6533 (let ((last-line-start (point)))
6535 (set-window-start window (point) t)
6536 (when (not (pos-visible-in-window-p last-line-start window))
6538 (set-window-start window (min (point) top-pos) t)))))))
6539 ;; Do horizontal recentering while we're at it.
6540 (when (and (get-buffer-window (current-buffer) t)
6541 (not (eq gnus-auto-center-summary 'vertical)))
6542 (let ((selected (selected-window)))
6543 (select-window (get-buffer-window (current-buffer) t))
6544 (gnus-summary-position-point)
6545 (gnus-horizontal-recenter)
6546 (select-window selected))))))
6548 (defun gnus-summary-jump-to-group (newsgroup)
6549 "Move point to NEWSGROUP in group mode buffer."
6550 ;; Keep update point of group mode buffer if visible.
6551 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6552 (save-window-excursion
6553 ;; Take care of tree window mode.
6554 (when (get-buffer-window gnus-group-buffer)
6555 (pop-to-buffer gnus-group-buffer))
6556 (gnus-group-jump-to-group newsgroup))
6558 ;; Take care of tree window mode.
6559 (if (get-buffer-window gnus-group-buffer)
6560 (pop-to-buffer gnus-group-buffer)
6561 (set-buffer gnus-group-buffer))
6562 (gnus-group-jump-to-group newsgroup))))
6564 ;; This function returns a list of article numbers based on the
6565 ;; difference between the ranges of read articles in this group and
6566 ;; the range of active articles.
6567 (defun gnus-list-of-unread-articles (group)
6568 (let* ((read (gnus-info-read (gnus-get-info group)))
6569 (active (or (gnus-active group) (gnus-activate-group group)))
6570 (last (or (cdr active)
6571 (error "Group %s couldn't be activated " group)))
6573 ;; If none are read, then all are unread.
6575 (setq first (car active))
6576 ;; If the range of read articles is a single range, then the
6577 ;; first unread article is the article after the last read
6578 ;; article. Sounds logical, doesn't it?
6579 (if (and (not (listp (cdr read)))
6580 (or (< (car read) (car active))
6581 (progn (setq read (list read))
6583 (setq first (max (car active) (1+ (cdr read))))
6584 ;; `read' is a list of ranges.
6585 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6588 (setq first (car active)))
6591 (while (< first nlast)
6592 (setq unread (cons first unread)
6594 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6595 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6596 (setq read (cdr read)))))
6597 ;; And add the last unread articles.
6598 (while (<= first last)
6599 (setq unread (cons first unread)
6601 ;; Return the list of unread articles.
6602 (delq 0 (nreverse unread))))
6604 (defun gnus-list-of-read-articles (group)
6605 "Return a list of unread, unticked and non-dormant articles."
6606 (let* ((info (gnus-get-info group))
6607 (marked (gnus-info-marks info))
6608 (active (gnus-active group)))
6610 (gnus-list-range-difference
6611 (gnus-list-range-difference
6612 (gnus-sorted-complement
6613 (gnus-uncompress-range active)
6614 (gnus-list-of-unread-articles group))
6615 (cdr (assq 'dormant marked)))
6616 (cdr (assq 'tick marked))))))
6618 ;; This function returns a sequence of article numbers based on the
6619 ;; difference between the ranges of read articles in this group and
6620 ;; the range of active articles.
6621 (defun gnus-sequence-of-unread-articles (group)
6622 (let* ((read (gnus-info-read (gnus-get-info group)))
6623 (active (or (gnus-active group) (gnus-activate-group group)))
6626 ;; If none are read, then all are unread.
6628 (setq first (car active))
6629 ;; If the range of read articles is a single range, then the
6630 ;; first unread article is the article after the last read
6631 ;; article. Sounds logical, doesn't it?
6632 (if (and (not (listp (cdr read)))
6633 (or (< (car read) (car active))
6634 (progn (setq read (list read))
6636 (setq first (max (car active) (1+ (cdr read))))
6637 ;; `read' is a list of ranges.
6638 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6641 (setq first (car active)))
6644 (push (cons first nlast) unread))
6645 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6646 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6647 (setq read (cdr read)))))
6648 ;; And add the last unread articles.
6649 (cond ((< first last)
6650 (push (cons first last) unread))
6652 (push first unread)))
6653 ;; Return the sequence of unread articles.
6654 (delq 0 (nreverse unread))))
6656 ;; Various summary commands
6658 (defun gnus-summary-select-article-buffer ()
6659 "Reconfigure windows to show article buffer."
6661 (if (not (gnus-buffer-live-p gnus-article-buffer))
6662 (error "There is no article buffer for this summary buffer")
6663 (gnus-configure-windows 'article)
6664 (select-window (get-buffer-window gnus-article-buffer))))
6666 (defun gnus-summary-universal-argument (arg)
6667 "Perform any operation on all articles that are process/prefixed."
6669 (let ((articles (gnus-summary-work-articles arg))
6676 (substitute-command-keys
6677 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6679 (gnus-error 1 "Undefined key")
6682 (gnus-summary-goto-subject (setq article (pop articles)))
6683 (let (gnus-newsgroup-processable)
6684 (command-execute func))
6685 (gnus-summary-remove-process-mark article)))))
6686 (gnus-summary-position-point))
6688 (defun gnus-summary-toggle-truncation (&optional arg)
6689 "Toggle truncation of summary lines.
6690 With ARG, turn line truncation on if ARG is positive."
6692 (setq truncate-lines
6693 (if (null arg) (not truncate-lines)
6694 (> (prefix-numeric-value arg) 0)))
6697 (defun gnus-summary-find-for-reselect ()
6698 "Return the number of an article to stay on across a reselect.
6699 The current article is considered, then following articles, then previous
6700 articles. An article is sought which is not cancelled and isn't a temporary
6701 insertion from another group. If there's no such then return a dummy 0."
6703 (dolist (rev '(nil t))
6704 (unless found ; don't demand the reverse list if we don't need it
6705 (let ((data (gnus-data-find-list
6706 (gnus-summary-article-number) (gnus-data-list rev))))
6707 (while (and data (not found))
6708 (if (and (< 0 (gnus-data-number (car data)))
6709 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6710 (setq found (gnus-data-number (car data))))
6711 (setq data (cdr data))))))
6714 (defun gnus-summary-reselect-current-group (&optional all rescan)
6715 "Exit and then reselect the current newsgroup.
6716 The prefix argument ALL means to select all articles."
6718 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6719 (error "Ephemeral groups can't be reselected"))
6720 (let ((current-subject (gnus-summary-find-for-reselect))
6721 (group gnus-newsgroup-name))
6722 (setq gnus-newsgroup-begin nil)
6723 (gnus-summary-exit nil 'leave-hidden)
6724 ;; We have to adjust the point of group mode buffer because
6725 ;; point was moved to the next unread newsgroup by exiting.
6726 (gnus-summary-jump-to-group group)
6729 (gnus-group-get-new-news-this-group 1)))
6730 (gnus-group-read-group all t)
6731 (gnus-summary-goto-subject current-subject nil t)))
6733 (defun gnus-summary-rescan-group (&optional all)
6734 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6736 (gnus-summary-reselect-current-group all t))
6738 (defun gnus-summary-update-info (&optional non-destructive)
6740 (let ((group gnus-newsgroup-name))
6742 (when gnus-newsgroup-kill-headers
6743 (setq gnus-newsgroup-killed
6744 (gnus-compress-sequence
6746 (gnus-list-range-intersection
6747 gnus-newsgroup-unselected gnus-newsgroup-killed)
6748 gnus-newsgroup-unreads)
6750 (unless (listp (cdr gnus-newsgroup-killed))
6751 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6752 (let ((headers gnus-newsgroup-headers))
6753 ;; Set the new ranges of read articles.
6754 (with-current-buffer gnus-group-buffer
6755 (gnus-undo-force-boundary))
6756 (gnus-update-read-articles
6757 group (gnus-sorted-union
6758 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6759 ;; Set the current article marks.
6760 (let ((gnus-newsgroup-scored
6761 (if (and (not gnus-save-score)
6762 (not non-destructive))
6764 gnus-newsgroup-scored)))
6766 (gnus-update-marks)))
6767 ;; Do the cross-ref thing.
6768 (when gnus-use-cross-reference
6769 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6770 ;; Do not switch windows but change the buffer to work.
6771 (set-buffer gnus-group-buffer)
6772 (unless (gnus-ephemeral-group-p group)
6773 (gnus-group-update-group group)))))))
6775 (defun gnus-summary-save-newsrc (&optional force)
6776 "Save the current number of read/marked articles in the dribble buffer.
6777 The dribble buffer will then be saved.
6778 If FORCE (the prefix), also save the .newsrc file(s)."
6780 (gnus-summary-update-info t)
6782 (gnus-save-newsrc-file)
6783 (gnus-dribble-save)))
6785 (defun gnus-summary-exit (&optional temporary leave-hidden)
6786 "Exit reading current newsgroup, and then return to group selection mode.
6787 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6789 (gnus-set-global-variables)
6790 (when (gnus-buffer-live-p gnus-article-buffer)
6792 (set-buffer gnus-article-buffer)
6793 (mm-destroy-parts gnus-article-mime-handles)
6794 ;; Set it to nil for safety reason.
6795 (setq gnus-article-mime-handle-alist nil)
6796 (setq gnus-article-mime-handles nil)))
6797 (gnus-kill-save-kill-buffer)
6798 (gnus-async-halt-prefetch)
6799 (let* ((group gnus-newsgroup-name)
6800 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6801 (gnus-group-is-exiting-p t)
6804 (buf (current-buffer)))
6806 ;; Do adaptive scoring, and possibly save score files.
6807 (when gnus-newsgroup-adaptive
6808 (gnus-score-adaptive))
6809 (when gnus-use-scoring
6811 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6812 ;; If we have several article buffers, we kill them at exit.
6813 (unless gnus-single-article-buffer
6814 (gnus-kill-buffer gnus-original-article-buffer)
6815 (setq gnus-article-current nil))
6816 (when gnus-use-cache
6817 (gnus-cache-possibly-remove-articles)
6818 (gnus-cache-save-buffers))
6819 (gnus-async-prefetch-remove-group group)
6820 (when gnus-suppress-duplicates
6821 (gnus-dup-enter-articles))
6822 (when gnus-use-trees
6823 (gnus-tree-close group))
6824 (when gnus-use-cache
6825 (gnus-cache-write-active))
6826 ;; Remove entries for this group.
6827 (nnmail-purge-split-history (gnus-group-real-name group))
6828 ;; Make all changes in this group permanent.
6830 (gnus-run-hooks 'gnus-exit-group-hook)
6831 (gnus-summary-update-info))
6832 (gnus-close-group group)
6833 ;; Make sure where we were, and go to next newsgroup.
6834 (set-buffer gnus-group-buffer)
6836 (gnus-group-jump-to-group group))
6837 (gnus-run-hooks 'gnus-summary-exit-hook)
6838 (unless (or quit-config
6839 ;; If this group has disappeared from the summary
6840 ;; buffer, don't skip forwards.
6841 (not (string= group (gnus-group-group-name))))
6842 (gnus-group-next-unread-group 1))
6843 (setq group-point (point))
6846 ;; If we have several article buffers, we kill them at exit.
6847 (unless gnus-single-article-buffer
6848 (gnus-kill-buffer gnus-article-buffer)
6849 (gnus-kill-buffer gnus-original-article-buffer)
6850 (setq gnus-article-current nil))
6852 (if (not gnus-kill-summary-on-exit)
6854 (gnus-deaden-summary)
6856 ;; We set all buffer-local variables to nil. It is unclear why
6857 ;; this is needed, but if we don't, buffer-local variables are
6858 ;; not garbage-collected, it seems. This would the lead to en
6859 ;; ever-growing Emacs.
6860 (gnus-summary-clear-local-variables)
6861 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6862 (gnus-summary-clear-local-variables))
6863 (when (get-buffer gnus-article-buffer)
6864 (bury-buffer gnus-article-buffer))
6865 ;; Return to group mode buffer.
6866 (when (eq mode 'gnus-summary-mode)
6867 (gnus-kill-buffer buf)))
6868 (setq gnus-current-select-method gnus-select-method)
6869 (set-buffer gnus-group-buffer)
6871 (gnus-handle-ephemeral-exit quit-config)
6872 (goto-char group-point)
6873 ;; If gnus-group-buffer is already displayed, make sure we also move
6874 ;; the cursor in the window that displays it.
6875 (let ((win (get-buffer-window (current-buffer) 0)))
6876 (if win (set-window-point win (point))))
6877 (unless leave-hidden
6878 (gnus-configure-windows 'group 'force)))
6879 ;; Clear the current group name.
6881 (setq gnus-newsgroup-name nil)))))
6883 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6884 (defun gnus-summary-exit-no-update (&optional no-questions)
6885 "Quit reading current newsgroup without updating read article info."
6887 (let* ((group gnus-newsgroup-name)
6888 (gnus-group-is-exiting-p t)
6889 (gnus-group-is-exiting-without-update-p t)
6890 (quit-config (gnus-group-quit-config group)))
6891 (when (or no-questions
6893 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6894 (gnus-async-halt-prefetch)
6895 (run-hooks 'gnus-summary-prepare-exit-hook)
6896 (when (gnus-buffer-live-p gnus-article-buffer)
6898 (set-buffer gnus-article-buffer)
6899 (mm-destroy-parts gnus-article-mime-handles)
6900 ;; Set it to nil for safety reason.
6901 (setq gnus-article-mime-handle-alist nil)
6902 (setq gnus-article-mime-handles nil)))
6903 ;; If we have several article buffers, we kill them at exit.
6904 (unless gnus-single-article-buffer
6905 (gnus-kill-buffer gnus-article-buffer)
6906 (gnus-kill-buffer gnus-original-article-buffer)
6907 (setq gnus-article-current nil))
6908 (if (not gnus-kill-summary-on-exit)
6909 (gnus-deaden-summary)
6910 (gnus-close-group group)
6911 (gnus-summary-clear-local-variables)
6912 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6913 (gnus-summary-clear-local-variables))
6914 (gnus-kill-buffer gnus-summary-buffer))
6915 (unless gnus-single-article-buffer
6916 (setq gnus-article-current nil))
6917 (when gnus-use-trees
6918 (gnus-tree-close group))
6919 (gnus-async-prefetch-remove-group group)
6920 (when (get-buffer gnus-article-buffer)
6921 (bury-buffer gnus-article-buffer))
6922 ;; Return to the group buffer.
6923 (gnus-configure-windows 'group 'force)
6924 ;; Clear the current group name.
6925 (setq gnus-newsgroup-name nil)
6926 (unless (gnus-ephemeral-group-p group)
6927 (gnus-group-update-group group))
6928 (when (equal (gnus-group-group-name) group)
6929 (gnus-group-next-unread-group 1))
6931 (gnus-handle-ephemeral-exit quit-config)))))
6933 (defun gnus-handle-ephemeral-exit (quit-config)
6934 "Handle movement when leaving an ephemeral group.
6935 The state which existed when entering the ephemeral is reset."
6936 (if (not (buffer-name (car quit-config)))
6937 (gnus-configure-windows 'group 'force)
6938 (set-buffer (car quit-config))
6939 (cond ((eq major-mode 'gnus-summary-mode)
6940 (gnus-set-global-variables))
6941 ((eq major-mode 'gnus-article-mode)
6943 ;; The `gnus-summary-buffer' variable may point
6944 ;; to the old summary buffer when using a single
6946 (unless (gnus-buffer-live-p gnus-summary-buffer)
6947 (set-buffer gnus-group-buffer))
6948 (set-buffer gnus-summary-buffer)
6949 (gnus-set-global-variables))))
6950 (if (or (eq (cdr quit-config) 'article)
6951 (eq (cdr quit-config) 'pick))
6953 ;; The current article may be from the ephemeral group
6954 ;; thus it is best that we reload this article
6956 ;; If we're exiting from a large digest, this can be
6957 ;; extremely slow. So, it's better not to reload it. -- jh.
6958 ;;(gnus-summary-show-article)
6959 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6960 (gnus-configure-windows 'pick 'force)
6961 (gnus-configure-windows (cdr quit-config) 'force)))
6962 (gnus-configure-windows (cdr quit-config) 'force))
6963 (when (eq major-mode 'gnus-summary-mode)
6964 (gnus-summary-next-subject 1 nil t)
6965 (gnus-summary-recenter)
6966 (gnus-summary-position-point))))
6970 (defvar gnus-dead-summary-mode-map nil)
6972 (unless gnus-dead-summary-mode-map
6973 (setq gnus-dead-summary-mode-map (make-keymap))
6974 (suppress-keymap gnus-dead-summary-mode-map)
6975 (substitute-key-definition
6976 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6977 (dolist (key '("\C-d" "\r" "\177" [delete]))
6978 (define-key gnus-dead-summary-mode-map
6979 key 'gnus-summary-wake-up-the-dead))
6980 (dolist (key '("q" "Q"))
6981 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6983 (defvar gnus-dead-summary-mode nil
6984 "Minor mode for Gnus summary buffers.")
6986 (defun gnus-dead-summary-mode (&optional arg)
6987 "Minor mode for Gnus summary buffers."
6989 (when (eq major-mode 'gnus-summary-mode)
6990 (make-local-variable 'gnus-dead-summary-mode)
6991 (setq gnus-dead-summary-mode
6992 (if (null arg) (not gnus-dead-summary-mode)
6993 (> (prefix-numeric-value arg) 0)))
6994 (when gnus-dead-summary-mode
6996 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6998 (defun gnus-deaden-summary ()
6999 "Make the current summary buffer into a dead summary buffer."
7000 ;; Kill any previous dead summary buffer.
7001 (when (and gnus-dead-summary
7002 (buffer-name gnus-dead-summary))
7003 (with-current-buffer gnus-dead-summary
7004 (when gnus-dead-summary-mode
7005 (kill-buffer (current-buffer)))))
7006 ;; Make this the current dead summary.
7007 (setq gnus-dead-summary (current-buffer))
7008 (gnus-dead-summary-mode 1)
7009 (let ((name (buffer-name)))
7010 (when (string-match "Summary" name)
7012 (concat (substring name 0 (match-beginning 0)) "Dead "
7013 (substring name (match-beginning 0)))
7017 (defun gnus-kill-or-deaden-summary (buffer)
7018 "Kill or deaden the summary BUFFER."
7020 (when (and (buffer-name buffer)
7021 (not gnus-single-article-buffer))
7022 (with-current-buffer buffer
7023 (gnus-kill-buffer gnus-article-buffer)
7024 (gnus-kill-buffer gnus-original-article-buffer)))
7027 (gnus-kill-summary-on-exit
7028 (when (and gnus-use-trees
7029 (gnus-buffer-exists-p buffer))
7032 (gnus-tree-close gnus-newsgroup-name)))
7033 (gnus-kill-buffer buffer))
7034 ;; Deaden the buffer.
7035 ((gnus-buffer-exists-p buffer)
7038 (gnus-deaden-summary))))))
7040 (defun gnus-summary-wake-up-the-dead (&rest args)
7041 "Wake up the dead summary buffer."
7043 (gnus-dead-summary-mode -1)
7044 (let ((name (buffer-name)))
7045 (when (string-match "Dead " name)
7047 (concat (substring name 0 (match-beginning 0))
7048 (substring name (match-end 0)))
7050 (gnus-message 3 "This dead summary is now alive again"))
7052 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7053 (defun gnus-summary-fetch-faq (&optional faq-dir)
7054 "Fetch the FAQ for the current group.
7055 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7059 (when current-prefix-arg
7061 "FAQ dir: " (and (listp gnus-group-faq-directory)
7063 gnus-group-faq-directory))))))
7064 (let (gnus-faq-buffer)
7065 (when (setq gnus-faq-buffer
7066 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7067 (gnus-configure-windows 'summary-faq))))
7069 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7070 (defun gnus-summary-describe-group (&optional force)
7071 "Describe the current newsgroup."
7073 (gnus-group-describe-group force gnus-newsgroup-name))
7075 (defun gnus-summary-describe-briefly ()
7076 "Describe summary mode commands briefly."
7078 (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")))
7080 ;; Walking around group mode buffer from summary mode.
7082 (defun gnus-summary-next-group (&optional no-article target-group backward)
7083 "Exit current newsgroup and then select next unread newsgroup.
7084 If prefix argument NO-ARTICLE is non-nil, no article is selected
7085 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7086 previous group instead."
7088 ;; Stop pre-fetching.
7089 (gnus-async-halt-prefetch)
7090 (let ((current-group gnus-newsgroup-name)
7091 (current-buffer (current-buffer))
7093 ;; First we semi-exit this group to update Xrefs and all variables.
7094 ;; We can't do a real exit, because the window conf must remain
7095 ;; the same in case the user is prompted for info, and we don't
7096 ;; want the window conf to change before that...
7097 (gnus-summary-exit t)
7098 (while (not entered)
7099 ;; Then we find what group we are supposed to enter.
7100 (set-buffer gnus-group-buffer)
7101 (gnus-group-jump-to-group current-group)
7104 (if (eq gnus-keep-same-level 'best)
7105 (gnus-summary-best-group gnus-newsgroup-name)
7106 (gnus-summary-search-group backward gnus-keep-same-level))))
7107 (if (not target-group)
7108 ;; There are no further groups, so we return to the group
7111 (gnus-message 5 "Returning to the group buffer")
7113 (when (gnus-buffer-live-p current-buffer)
7114 (set-buffer current-buffer)
7115 (gnus-summary-exit))
7116 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7117 ;; We try to enter the target group.
7118 (gnus-group-jump-to-group target-group)
7119 (let ((unreads (gnus-group-group-unread)))
7120 (if (and (or (eq t unreads)
7121 (and unreads (not (zerop unreads))))
7122 (gnus-summary-read-group
7123 target-group nil no-article
7124 (and (buffer-name current-buffer) current-buffer)
7127 (setq current-group target-group
7128 target-group nil)))))))
7130 (defun gnus-summary-prev-group (&optional no-article)
7131 "Exit current newsgroup and then select previous unread newsgroup.
7132 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7134 (gnus-summary-next-group no-article nil t))
7136 ;; Walking around summary lines.
7138 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7139 "Go to the first subject satisfying any non-nil constraint.
7140 If UNREAD is non-nil, the article should be unread.
7141 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7142 If UNSEEN is non-nil, the article should be unseen.
7143 Returns the article selected or nil if there are no matching articles."
7147 ((null gnus-newsgroup-data)
7148 (gnus-message 3 "No articles in the group")
7150 ;; Pick the first article.
7151 ((not (or unread undownloaded unseen))
7152 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7153 (gnus-data-number (car gnus-newsgroup-data)))
7154 ;; Find the first unread article.
7156 (let ((data gnus-newsgroup-data))
7158 (let ((num (gnus-data-number (car data))))
7159 (or (memq num gnus-newsgroup-unfetched)
7160 (not (or (and unread
7161 (memq num gnus-newsgroup-unreads))
7163 (memq num gnus-newsgroup-undownloaded))
7165 (memq num gnus-newsgroup-unseen)))))))
7166 (setq data (cdr data)))
7170 (goto-char (gnus-data-pos (car data)))
7171 (gnus-data-number (car data)))
7172 (gnus-message 3 "No more%s articles"
7173 (let* ((r (when unread " unread"))
7174 (d (when undownloaded " undownloaded"))
7175 (s (when unseen " unseen"))
7176 (l (delq nil (list r d s))))
7177 (cond ((= 3 (length l))
7178 (concat r "," d ", or" s))
7180 (concat (car l) ", or" (cadr l)))
7187 (gnus-summary-position-point))))))
7189 (defun gnus-summary-next-subject (n &optional unread dont-display)
7190 "Go to next N'th summary line.
7191 If N is negative, go to the previous N'th subject line.
7192 If UNREAD is non-nil, only unread articles are selected.
7193 The difference between N and the actual number of steps taken is
7196 (let ((backward (< n 0))
7200 (gnus-summary-find-prev unread)
7201 (gnus-summary-find-next unread)))
7202 (unless (zerop (setq n (1- n)))
7203 (gnus-summary-show-thread)))
7205 (gnus-message 7 "No more%s articles"
7206 (if unread " unread" "")))
7207 (unless dont-display
7208 (gnus-summary-recenter)
7209 (gnus-summary-position-point))
7212 (defun gnus-summary-next-unread-subject (n)
7213 "Go to next N'th unread summary line."
7215 (gnus-summary-next-subject n t))
7217 (defun gnus-summary-prev-subject (n &optional unread)
7218 "Go to previous N'th summary line.
7219 If optional argument UNREAD is non-nil, only unread article is selected."
7221 (gnus-summary-next-subject (- n) unread))
7223 (defun gnus-summary-prev-unread-subject (n)
7224 "Go to previous N'th unread summary line."
7226 (gnus-summary-next-subject (- n) t))
7228 (defun gnus-summary-goto-subjects (articles)
7229 "Insert the subject header for ARTICLES in the current buffer."
7231 (dolist (article articles)
7232 (gnus-summary-goto-subject article t)))
7233 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7234 (gnus-summary-position-point))
7236 (defun gnus-summary-goto-subject (article &optional force silent)
7237 "Go the subject line of ARTICLE.
7238 If FORCE, also allow jumping to articles not currently shown."
7239 (interactive "nArticle number: ")
7240 (unless (numberp article)
7241 (error "Article %s is not a number" article))
7243 (data (gnus-data-find article)))
7244 ;; We read in the article if we have to.
7247 (gnus-summary-insert-subject
7249 (if (or (numberp force) (vectorp force)) force)
7251 (setq data (gnus-data-find article)))
7256 (gnus-message 3 "Can't find article %d" article))
7258 (let ((pt (gnus-data-pos data)))
7260 (gnus-summary-set-article-display-arrow pt))
7261 (gnus-summary-position-point)
7264 ;; Walking around summary lines with displaying articles.
7266 (defun gnus-summary-expand-window (&optional arg)
7267 "Make the summary buffer take up the entire Emacs frame.
7268 Given a prefix, will force an `article' buffer configuration."
7271 (gnus-configure-windows 'article 'force)
7272 (gnus-configure-windows 'summary 'force)))
7274 (defun gnus-summary-display-article (article &optional all-header)
7275 "Display ARTICLE in article buffer."
7276 (when (gnus-buffer-live-p gnus-article-buffer)
7277 (with-current-buffer gnus-article-buffer
7278 (mm-enable-multibyte)))
7279 (gnus-set-global-variables)
7280 (when (gnus-buffer-live-p gnus-article-buffer)
7281 (with-current-buffer gnus-article-buffer
7282 (setq gnus-article-charset gnus-newsgroup-charset)
7283 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7284 (mm-enable-multibyte)))
7288 (if gnus-summary-display-article-function
7289 (funcall gnus-summary-display-article-function article all-header)
7290 (gnus-article-prepare article all-header))
7291 (gnus-run-hooks 'gnus-select-article-hook)
7292 (when (and gnus-current-article
7293 (not (zerop gnus-current-article)))
7294 (gnus-summary-goto-subject gnus-current-article))
7295 (gnus-summary-recenter)
7296 (when (and gnus-use-trees gnus-show-threads)
7297 (gnus-possibly-generate-tree article)
7298 (gnus-highlight-selected-tree article))
7299 ;; Successfully display article.
7300 (gnus-article-set-window-start
7301 (cdr (assq article gnus-newsgroup-bookmarks))))))
7303 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7304 "Select the current article.
7305 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7306 non-nil, the article will be re-fetched even if it already present in
7307 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7309 ;; Make sure we are in the summary buffer to work around bbdb bug.
7310 (unless (eq major-mode 'gnus-summary-mode)
7311 (set-buffer gnus-summary-buffer))
7312 (let ((article (or article (gnus-summary-article-number)))
7313 (all-headers (not (not all-headers))) ;Must be t or nil.
7314 gnus-summary-display-article-function)
7316 (gnus-summary-article-pseudo-p article)
7317 (error "This is a pseudo-article"))
7319 (set-buffer gnus-summary-buffer)
7320 (if (or (and gnus-single-article-buffer
7321 (or (null gnus-current-article)
7322 (null gnus-article-current)
7323 (null (get-buffer gnus-article-buffer))
7324 (not (eq article (cdr gnus-article-current)))
7325 (not (equal (car gnus-article-current)
7326 gnus-newsgroup-name))))
7327 (and (not gnus-single-article-buffer)
7328 (or (null gnus-current-article)
7329 (not (eq gnus-current-article article))))
7331 ;; The requested article is different from the current article.
7333 (gnus-summary-display-article article all-headers)
7334 (when (gnus-buffer-live-p gnus-article-buffer)
7335 (with-current-buffer gnus-article-buffer
7336 (if (not gnus-article-decoded-p) ;; a local variable
7337 (mm-disable-multibyte))))
7338 (gnus-article-set-window-start
7339 (cdr (assq article gnus-newsgroup-bookmarks)))
7343 (defun gnus-summary-force-verify-and-decrypt ()
7344 "Display buttons for signed/encrypted parts and verify/decrypt them."
7346 (let ((mm-verify-option 'known)
7347 (mm-decrypt-option 'known)
7348 (gnus-article-emulate-mime t)
7349 (gnus-buttonized-mime-types (append (list "multipart/signed"
7350 "multipart/encrypted")
7351 gnus-buttonized-mime-types)))
7352 (gnus-summary-select-article nil 'force)))
7354 (defun gnus-summary-set-current-mark (&optional current-mark)
7355 "Obsolete function."
7358 (defun gnus-summary-next-article (&optional unread subject backward push)
7359 "Select the next article.
7360 If UNREAD, only unread articles are selected.
7361 If SUBJECT, only articles with SUBJECT are selected.
7362 If BACKWARD, the previous article is selected instead of the next."
7365 ;; Is there such an article?
7366 ((and (gnus-summary-search-forward unread subject backward)
7367 (or (gnus-summary-display-article (gnus-summary-article-number))
7368 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7369 (gnus-summary-position-point))
7370 ;; If not, we try the first unread, if that is wanted.
7372 gnus-auto-select-same
7373 (gnus-summary-first-unread-article))
7374 (gnus-summary-position-point)
7375 (gnus-message 6 "Wrapped"))
7376 ;; Try to get next/previous article not displayed in this group.
7377 ((and gnus-auto-extend-newsgroup
7378 (not unread) (not subject))
7379 (gnus-summary-goto-article
7380 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7381 nil (count-lines (point-min) (point))))
7382 ;; Go to next/previous group.
7384 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7385 (gnus-summary-jump-to-group gnus-newsgroup-name))
7386 (let ((cmd last-command-char)
7388 (with-current-buffer gnus-group-buffer
7391 (if (eq gnus-keep-same-level 'best)
7392 (gnus-summary-best-group gnus-newsgroup-name)
7393 (gnus-summary-search-group backward gnus-keep-same-level))))
7394 ;; For some reason, the group window gets selected. We change
7396 (select-window (get-buffer-window (current-buffer)))
7397 ;; Select next unread newsgroup automagically.
7399 ((or (not gnus-auto-select-next)
7401 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7402 ((or (eq gnus-auto-select-next 'quietly)
7403 (and (eq gnus-auto-select-next 'slightly-quietly)
7405 (and (eq gnus-auto-select-next 'almost-quietly)
7406 (gnus-summary-last-article-p)))
7408 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7410 (gnus-message 7 "No more%s articles (%s)..."
7411 (if unread " unread" "")
7412 (if group (concat "selecting " group)
7414 (gnus-summary-next-group nil group backward)))
7416 (when (gnus-key-press-event-p last-input-event)
7417 (gnus-summary-walk-group-buffer
7418 gnus-newsgroup-name cmd unread backward point))))))))
7420 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7421 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7422 (?\C-p (gnus-group-prev-unread-group 1))))
7423 (cursor-in-echo-area t)
7424 keve key group ended prompt)
7426 (set-buffer gnus-group-buffer)
7429 (if (eq gnus-keep-same-level 'best)
7430 (gnus-summary-best-group gnus-newsgroup-name)
7431 (gnus-summary-search-group backward gnus-keep-same-level))))
7435 "No more%s articles%s " (if unread " unread" "")
7437 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7438 (format " (Type %s for %s [%s])"
7439 (single-key-description cmd)
7440 (gnus-group-decoded-name group)
7441 (gnus-group-unread group))
7442 (format " (Type %s to exit %s)"
7443 (single-key-description cmd)
7444 (gnus-group-decoded-name gnus-newsgroup-name)))))
7445 ;; Confirm auto selection.
7446 (setq key (car (setq keve (gnus-read-event-char prompt)))
7449 ((assq key keystrokes)
7450 (let ((obuf (current-buffer)))
7451 (switch-to-buffer gnus-group-buffer)
7453 (gnus-group-jump-to-group group))
7454 (eval (cadr (assq key keystrokes)))
7455 (setq group (gnus-group-group-name))
7456 (switch-to-buffer obuf))
7460 (gnus-ephemeral-group-p gnus-newsgroup-name))
7462 (gnus-summary-next-group nil group backward)))
7464 (push (cdr keve) unread-command-events))))))
7466 (defun gnus-summary-next-unread-article ()
7467 "Select unread article after current one."
7469 (gnus-summary-next-article
7470 (or (not (eq gnus-summary-goto-unread 'never))
7471 (gnus-summary-last-article-p (gnus-summary-article-number)))
7472 (and gnus-auto-select-same
7473 (gnus-summary-article-subject))))
7475 (defun gnus-summary-prev-article (&optional unread subject)
7476 "Select the article after the current one.
7477 If UNREAD is non-nil, only unread articles are selected."
7479 (gnus-summary-next-article unread subject t))
7481 (defun gnus-summary-prev-unread-article ()
7482 "Select unread article before current one."
7484 (gnus-summary-prev-article
7485 (or (not (eq gnus-summary-goto-unread 'never))
7486 (gnus-summary-first-article-p (gnus-summary-article-number)))
7487 (and gnus-auto-select-same
7488 (gnus-summary-article-subject))))
7490 (defun gnus-summary-next-page (&optional lines circular stop)
7491 "Show next page of the selected article.
7492 If at the end of the current article, select the next article.
7493 LINES says how many lines should be scrolled up.
7495 If CIRCULAR is non-nil, go to the start of the article instead of
7496 selecting the next article when reaching the end of the current
7499 If STOP is non-nil, just stop when reaching the end of the message.
7501 Also see the variable `gnus-article-skip-boring'."
7503 (setq gnus-summary-buffer (current-buffer))
7504 (gnus-set-global-variables)
7505 (let ((article (gnus-summary-article-number))
7506 (article-window (get-buffer-window gnus-article-buffer t))
7508 ;; If the buffer is empty, we have no article.
7510 (error "No article to select"))
7511 (gnus-configure-windows 'article)
7512 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7513 (if (and (eq gnus-summary-goto-unread 'never)
7514 (not (gnus-summary-last-article-p article)))
7515 (gnus-summary-next-article)
7516 (gnus-summary-next-unread-article))
7517 (if (or (null gnus-current-article)
7518 (null gnus-article-current)
7519 (/= article (cdr gnus-article-current))
7520 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7521 ;; Selected subject is different from current article's.
7522 (gnus-summary-display-article article)
7523 (when article-window
7524 (gnus-eval-in-buffer-window gnus-article-buffer
7525 (setq endp (or (gnus-article-next-page lines)
7526 (gnus-article-only-boring-p))))
7529 (gnus-message 3 "End of message"))
7531 (gnus-summary-beginning-of-article))
7533 (gnus-message 3 "End of message"))
7535 (if (and (eq gnus-summary-goto-unread 'never)
7536 (not (gnus-summary-last-article-p article)))
7537 (gnus-summary-next-article)
7538 (gnus-summary-next-unread-article))))))))
7539 (gnus-summary-recenter)
7540 (gnus-summary-position-point)))
7542 (defun gnus-summary-prev-page (&optional lines move)
7543 "Show previous page of selected article.
7544 Argument LINES specifies lines to be scrolled down.
7545 If MOVE, move to the previous unread article if point is at
7546 the beginning of the buffer."
7548 (let ((article (gnus-summary-article-number))
7549 (article-window (get-buffer-window gnus-article-buffer t))
7551 (gnus-configure-windows 'article)
7552 (if (or (null gnus-current-article)
7553 (null gnus-article-current)
7554 (/= article (cdr gnus-article-current))
7555 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7556 ;; Selected subject is different from current article's.
7557 (gnus-summary-display-article article)
7558 (gnus-summary-recenter)
7559 (when article-window
7560 (gnus-eval-in-buffer-window gnus-article-buffer
7561 (setq endp (gnus-article-prev-page lines)))
7562 (when (and move endp)
7564 (gnus-message 3 "Beginning of message"))
7566 (if (and (eq gnus-summary-goto-unread 'never)
7567 (not (gnus-summary-first-article-p article)))
7568 (gnus-summary-prev-article)
7569 (gnus-summary-prev-unread-article))))))))
7570 (gnus-summary-position-point))
7572 (defun gnus-summary-prev-page-or-article (&optional lines)
7573 "Show previous page of selected article.
7574 Argument LINES specifies lines to be scrolled down.
7575 If at the beginning of the article, go to the next article."
7577 (gnus-summary-prev-page lines t))
7579 (defun gnus-summary-scroll-up (lines)
7580 "Scroll up (or down) one line current article.
7581 Argument LINES specifies lines to be scrolled up (or down if negative)."
7583 (gnus-configure-windows 'article)
7584 (gnus-summary-show-thread)
7585 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7586 (gnus-eval-in-buffer-window gnus-article-buffer
7588 (when (gnus-article-next-page lines)
7589 (gnus-message 3 "End of message")))
7591 (gnus-article-prev-page (- lines))))))
7592 (gnus-summary-recenter)
7593 (gnus-summary-position-point))
7595 (defun gnus-summary-scroll-down (lines)
7596 "Scroll down (or up) one line current article.
7597 Argument LINES specifies lines to be scrolled down (or up if negative)."
7599 (gnus-summary-scroll-up (- lines)))
7601 (defun gnus-summary-next-same-subject ()
7602 "Select next article which has the same subject as current one."
7604 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7606 (defun gnus-summary-prev-same-subject ()
7607 "Select previous article which has the same subject as current one."
7609 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7611 (defun gnus-summary-next-unread-same-subject ()
7612 "Select next unread article which has the same subject as current one."
7614 (gnus-summary-next-article t (gnus-summary-article-subject)))
7616 (defun gnus-summary-prev-unread-same-subject ()
7617 "Select previous unread article which has the same subject as current one."
7619 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7621 (defun gnus-summary-first-unread-article ()
7622 "Select the first unread article.
7623 Return nil if there are no unread articles."
7626 (when (gnus-summary-first-subject t)
7627 (gnus-summary-show-thread)
7628 (gnus-summary-first-subject t)
7629 (gnus-summary-display-article (gnus-summary-article-number)))
7630 (gnus-summary-position-point)))
7632 (defun gnus-summary-first-unread-subject ()
7633 "Place the point on the subject line of the first unread article.
7634 Return nil if there are no unread articles."
7637 (when (gnus-summary-first-subject t)
7638 (gnus-summary-show-thread)
7639 (gnus-summary-first-subject t))
7640 (gnus-summary-position-point)))
7642 (defun gnus-summary-first-unseen-subject ()
7643 "Place the point on the subject line of the first unseen article.
7644 Return nil if there are no unseen articles."
7647 (when (gnus-summary-first-subject nil nil t)
7648 (gnus-summary-show-thread)
7649 (gnus-summary-first-subject nil nil t))
7650 (gnus-summary-position-point)))
7652 (defun gnus-summary-first-unseen-or-unread-subject ()
7653 "Place the point on the subject line of the first unseen article or,
7654 if all article have been seen, on the subject line of the first unread
7658 (unless (when (gnus-summary-first-subject nil nil t)
7659 (gnus-summary-show-thread)
7660 (gnus-summary-first-subject nil nil t))
7661 (when (gnus-summary-first-subject t)
7662 (gnus-summary-show-thread)
7663 (gnus-summary-first-subject t)))
7664 (gnus-summary-position-point)))
7666 (defun gnus-summary-first-article ()
7667 "Select the first article.
7668 Return nil if there are no articles."
7671 (when (gnus-summary-first-subject)
7672 (gnus-summary-show-thread)
7673 (gnus-summary-first-subject)
7674 (gnus-summary-display-article (gnus-summary-article-number)))
7675 (gnus-summary-position-point)))
7677 (defun gnus-summary-best-unread-article (&optional arg)
7678 "Select the unread article with the highest score.
7679 If given a prefix argument, select the next unread article that has a
7680 score higher than the default score."
7682 (let ((article (if arg
7683 (gnus-summary-better-unread-subject)
7684 (gnus-summary-best-unread-subject))))
7686 (gnus-summary-goto-article article)
7687 (error "No unread articles"))))
7689 (defun gnus-summary-best-unread-subject ()
7690 "Select the unread subject with the highest score."
7692 (let ((best -1000000)
7693 (data gnus-newsgroup-data)
7696 (and (gnus-data-unread-p (car data))
7698 (gnus-summary-article-score (gnus-data-number (car data))))
7701 article (gnus-data-number (car data))))
7702 (setq data (cdr data)))
7704 (gnus-summary-goto-subject article))
7705 (gnus-summary-position-point)
7708 (defun gnus-summary-better-unread-subject ()
7709 "Select the first unread subject that has a score over the default score."
7711 (let ((data gnus-newsgroup-data)
7713 (while (and (setq article (gnus-data-number (car data)))
7714 (or (gnus-data-read-p (car data))
7715 (not (> (gnus-summary-article-score article)
7716 gnus-summary-default-score))))
7717 (setq data (cdr data)))
7719 (gnus-summary-goto-subject article))
7720 (gnus-summary-position-point)
7723 (defun gnus-summary-last-subject ()
7724 "Go to the last displayed subject line in the group."
7725 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7727 (gnus-summary-goto-subject article))))
7729 (defun gnus-summary-goto-article (article &optional all-headers force)
7730 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7731 If ALL-HEADERS is non-nil, no header lines are hidden.
7732 If FORCE, go to the article even if it isn't displayed. If FORCE
7733 is a number, it is the line the article is to be displayed on."
7737 "Article number or Message-ID: "
7738 (mapcar (lambda (number) (list (int-to-string number)))
7739 gnus-newsgroup-limit))
7743 (if (and (stringp article)
7744 (string-match "@\\|%40" article))
7745 (gnus-summary-refer-article article)
7746 (when (stringp article)
7747 (setq article (string-to-number article)))
7748 (if (gnus-summary-goto-subject article force)
7749 (gnus-summary-display-article article all-headers)
7750 (gnus-message 4 "Couldn't go to article %s" article) nil))
7751 (gnus-summary-position-point)))
7753 (defun gnus-summary-goto-last-article ()
7754 "Go to the previously read article."
7757 (when gnus-last-article
7758 (gnus-summary-goto-article gnus-last-article nil t))
7759 (gnus-summary-position-point)))
7761 (defun gnus-summary-pop-article (number)
7762 "Pop one article off the history and go to the previous.
7763 NUMBER articles will be popped off."
7766 (setq gnus-newsgroup-history
7767 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7769 (gnus-summary-goto-article (car to) nil t)
7770 (error "Article history empty")))
7771 (gnus-summary-position-point))
7773 ;; Summary commands and functions for limiting the summary buffer.
7775 (defun gnus-summary-limit-to-articles (n)
7776 "Limit the summary buffer to the next N articles.
7777 If not given a prefix, use the process marked articles instead."
7780 (let ((articles (gnus-summary-work-articles n)))
7781 (setq gnus-newsgroup-processable nil)
7782 (gnus-summary-limit articles))
7783 (gnus-summary-position-point)))
7785 (defun gnus-summary-pop-limit (&optional total)
7786 "Restore the previous limit.
7787 If given a prefix, remove all limits."
7790 (setq gnus-newsgroup-limits
7791 (list (mapcar (lambda (h) (mail-header-number h))
7792 gnus-newsgroup-headers))))
7793 (unless gnus-newsgroup-limits
7794 (error "No limit to pop"))
7796 (gnus-summary-limit nil 'pop)
7797 (gnus-summary-position-point)))
7799 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7800 "Limit the summary buffer to articles that have subjects that match a regexp.
7801 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7803 (list (read-string (if current-prefix-arg
7804 "Exclude subject (regexp): "
7805 "Limit to subject (regexp): "))
7806 nil current-prefix-arg))
7808 (setq header "subject"))
7809 (when (not (equal "" subject))
7811 (let ((articles (gnus-summary-find-matching
7812 (or header "subject") subject 'all nil nil
7815 (error "Found no matches for \"%s\"" subject))
7816 (gnus-summary-limit articles))
7817 (gnus-summary-position-point))))
7819 (defun gnus-summary-limit-to-author (from &optional not-matching)
7820 "Limit the summary buffer to articles that have authors that match a regexp.
7821 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7823 (list (read-string (if current-prefix-arg
7824 "Exclude author (regexp): "
7825 "Limit to author (regexp): "))
7826 current-prefix-arg))
7827 (gnus-summary-limit-to-subject from "from" not-matching))
7829 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
7830 "Limit the summary buffer to articles with the given RECIPIENT.
7832 If NOT-MATCHING, exclude RECIPIENT.
7834 To and Cc headers are checked. You need to include them in
7835 `nnmail-extra-headers'."
7836 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
7838 (list (read-string (format "%s recipient (regexp): "
7839 (if current-prefix-arg "Exclude" "Limit to")))
7840 current-prefix-arg))
7841 (when (not (equal "" recipient))
7843 (if (memq 'To nnmail-extra-headers)
7844 (gnus-summary-find-matching
7845 (cons 'extra 'To) recipient 'all nil nil
7848 1 "`To' isn't present in `nnmail-extra-headers'")
7852 (if (memq 'Cc nnmail-extra-headers)
7853 (gnus-summary-find-matching
7854 (cons 'extra 'Cc) recipient 'all nil nil
7857 1 "`Cc' isn't present in `nnmail-extra-headers'")
7862 ;; We need the numbers that are in both lists:
7864 (and (memq a to) a))
7868 (error "Found no matches for \"%s\"" recipient))
7869 (gnus-summary-limit articles))
7870 (gnus-summary-position-point))))
7872 (defun gnus-summary-limit-to-age (age &optional younger-p)
7873 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7874 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7875 articles that are younger than AGE days."
7877 (let ((younger current-prefix-arg)
7880 (while (not days-got)
7881 (setq days (if younger
7882 (read-string "Limit to articles younger than (in days, older when negative): ")
7884 "Limit to articles older than (in days, younger when negative): ")))
7885 (when (> (length days) 0)
7886 (setq days (read days)))
7891 (setq younger (not younger))
7892 (setq days (* days -1))))
7893 (message "Please enter a number.")
7895 (list days younger)))
7897 (let ((data gnus-newsgroup-data)
7898 (cutoff (days-to-time age))
7899 articles d date is-younger)
7900 (while (setq d (pop data))
7901 (when (and (vectorp (gnus-data-header d))
7902 (setq date (mail-header-date (gnus-data-header d))))
7903 (setq is-younger (time-less-p
7904 (time-since (condition-case ()
7911 (push (gnus-data-number d) articles))))
7912 (gnus-summary-limit (nreverse articles)))
7913 (gnus-summary-position-point)))
7915 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7916 "Limit the summary buffer to articles that match an 'extra' header."
7920 (gnus-completing-read-with-default
7921 (symbol-name (car gnus-extra-headers))
7922 (if current-prefix-arg
7923 "Exclude extra header"
7924 "Limit extra header")
7926 (cons (symbol-name x) x))
7931 (read-string (format "%s header %s (regexp): "
7932 (if current-prefix-arg "Exclude" "Limit to")
7934 current-prefix-arg)))
7935 (when (not (equal "" regexp))
7937 (let ((articles (gnus-summary-find-matching
7938 (cons 'extra header) regexp 'all nil nil
7941 (error "Found no matches for \"%s\"" regexp))
7942 (gnus-summary-limit articles))
7943 (gnus-summary-position-point))))
7945 (defun gnus-summary-limit-to-display-predicate ()
7946 "Limit the summary buffer to the predicated in the `display' group parameter."
7948 (unless gnus-newsgroup-display
7949 (error "There is no `display' group parameter"))
7951 (dolist (number gnus-newsgroup-articles)
7952 (when (funcall gnus-newsgroup-display)
7953 (push number articles)))
7954 (gnus-summary-limit articles))
7955 (gnus-summary-position-point))
7957 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7959 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7961 (defun gnus-summary-limit-to-unread (&optional all)
7962 "Limit the summary buffer to articles that are not marked as read.
7963 If ALL is non-nil, limit strictly to unread articles."
7966 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7967 (gnus-summary-limit-to-marks
7968 ;; Concat all the marks that say that an article is read and have
7970 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7971 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7972 gnus-low-score-mark gnus-expirable-mark
7973 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7974 gnus-duplicate-mark gnus-souped-mark)
7977 (defun gnus-summary-limit-to-replied (&optional unreplied)
7978 "Limit the summary buffer to replied articles.
7979 If UNREPLIED (the prefix), limit to unreplied articles."
7983 (gnus-set-difference gnus-newsgroup-articles
7984 gnus-newsgroup-replied))
7985 (gnus-summary-limit gnus-newsgroup-replied))
7986 (gnus-summary-position-point))
7988 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7989 (make-obsolete 'gnus-summary-delete-marked-with
7990 'gnus-summary-limit-exclude-marks)
7992 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7993 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7994 If REVERSE, limit the summary buffer to articles that are marked
7995 with MARKS. MARKS can either be a string of marks or a list of marks.
7996 Returns how many articles were removed."
7997 (interactive "sMarks: ")
7998 (gnus-summary-limit-to-marks marks t))
8000 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8001 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8002 If REVERSE (the prefix), limit the summary buffer to articles that are
8003 not marked with MARKS. MARKS can either be a string of marks or a
8005 Returns how many articles were removed."
8006 (interactive "sMarks: \nP")
8008 (let ((data gnus-newsgroup-data)
8009 (marks (if (listp marks) marks
8010 (append marks nil))) ; Transform to list.
8013 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8014 (memq (gnus-data-mark (car data)) marks))
8015 (push (gnus-data-number (car data)) articles))
8016 (setq data (cdr data)))
8017 (gnus-summary-limit articles))
8018 (gnus-summary-position-point)))
8020 (defun gnus-summary-limit-to-score (score)
8021 "Limit to articles with score at or above SCORE."
8022 (interactive "NLimit to articles with score of at least: ")
8023 (let ((data gnus-newsgroup-data)
8026 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8028 (push (gnus-data-number (car data)) articles))
8029 (setq data (cdr data)))
8031 (gnus-summary-limit articles)
8032 (gnus-summary-position-point))))
8034 (defun gnus-summary-limit-to-unseen ()
8035 "Limit to unseen articles."
8038 (gnus-summary-limit gnus-newsgroup-unseen)
8039 (gnus-summary-position-point)))
8041 (defun gnus-summary-limit-include-thread (id)
8042 "Display all the hidden articles that is in the thread with ID in it.
8043 When called interactively, ID is the Message-ID of the current
8045 (interactive (list (mail-header-id (gnus-summary-article-header))))
8046 (let ((articles (gnus-articles-in-thread
8047 (gnus-id-to-thread (gnus-root-id id)))))
8049 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8050 (gnus-summary-limit-include-matching-articles
8052 (regexp-quote (gnus-simplify-subject-re
8053 (mail-header-subject (gnus-id-to-header id)))))
8054 (gnus-summary-position-point))))
8056 (defun gnus-summary-limit-include-matching-articles (header regexp)
8057 "Display all the hidden articles that have HEADERs that match REGEXP."
8058 (interactive (list (read-string "Match on header: ")
8059 (read-string "Regexp: ")))
8060 (let ((articles (gnus-find-matching-articles header regexp)))
8062 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8063 (gnus-summary-position-point))))
8065 (defun gnus-summary-insert-dormant-articles ()
8066 "Insert all the dormant articles for this group into the current buffer."
8068 (let ((gnus-verbose (max 6 gnus-verbose)))
8069 (if (not gnus-newsgroup-dormant)
8070 (gnus-message 3 "No cached articles for this group")
8071 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8073 (defun gnus-summary-limit-include-dormant ()
8074 "Display all the hidden articles that are marked as dormant.
8075 Note that this command only works on a subset of the articles currently
8076 fetched for this group."
8078 (unless gnus-newsgroup-dormant
8079 (error "There are no dormant articles in this group"))
8081 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8082 (gnus-summary-position-point)))
8084 (defun gnus-summary-limit-exclude-dormant ()
8085 "Hide all dormant articles."
8088 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8089 (gnus-summary-position-point)))
8091 (defun gnus-summary-limit-exclude-childless-dormant ()
8092 "Hide all dormant articles that have no children."
8094 (let ((data (gnus-data-list t))
8095 articles d children)
8096 ;; Find all articles that are either not dormant or have
8098 (while (setq d (pop data))
8099 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8101 (gnus-article-children (gnus-data-number d)))
8104 (when (memq (car children) articles)
8109 (push (gnus-data-number d) articles)))
8112 (gnus-summary-limit articles)
8113 (gnus-summary-position-point))))
8115 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8116 "Mark all unread excluded articles as read.
8117 If ALL, mark even excluded ticked and dormants as read."
8119 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8120 (let ((articles (gnus-sorted-ndifference
8122 (mapcar (lambda (h) (mail-header-number h))
8123 gnus-newsgroup-headers)
8125 gnus-newsgroup-limit))
8127 (setq gnus-newsgroup-unreads
8128 (gnus-sorted-intersection gnus-newsgroup-unreads
8129 gnus-newsgroup-limit))
8131 (setq gnus-newsgroup-dormant nil
8132 gnus-newsgroup-marked nil
8133 gnus-newsgroup-reads
8135 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8136 gnus-newsgroup-reads))
8137 (while (setq article (pop articles))
8138 (unless (or (memq article gnus-newsgroup-dormant)
8139 (memq article gnus-newsgroup-marked))
8140 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8142 (defun gnus-summary-limit (articles &optional pop)
8144 ;; We pop the previous limit off the stack and use that.
8145 (setq articles (car gnus-newsgroup-limits)
8146 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8147 ;; We use the new limit, so we push the old limit on the stack.
8148 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8150 (setq gnus-newsgroup-limit articles)
8151 (let ((total (length gnus-newsgroup-data))
8152 (data (gnus-data-find-list (gnus-summary-article-number)))
8153 (gnus-summary-mark-below nil) ; Inhibit this.
8155 ;; This will do all the work of generating the new summary buffer
8156 ;; according to the new limit.
8157 (gnus-summary-prepare)
8158 ;; Hide any threads, possibly.
8159 (gnus-summary-maybe-hide-threads)
8160 ;; Try to return to the article you were at, or one in the
8163 ;; We try to find some article after the current one.
8165 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8168 (setq data (cdr data))))
8170 ;; If there is no data, that means that we were after the last
8171 ;; article. The same goes when we can't find any articles
8172 ;; after the current one.
8173 (goto-char (point-max))
8174 (gnus-summary-find-prev))
8175 (gnus-set-mode-line 'summary)
8176 ;; We return how many articles were removed from the summary
8177 ;; buffer as a result of the new limit.
8178 (- total (length gnus-newsgroup-data))))
8180 (defsubst gnus-invisible-cut-children (threads)
8183 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8188 (defsubst gnus-cut-thread (thread)
8189 "Go forwards in the thread until we find an article that we want to display."
8190 (when (or (eq gnus-fetch-old-headers 'some)
8191 (eq gnus-fetch-old-headers 'invisible)
8192 (numberp gnus-fetch-old-headers)
8193 (eq gnus-build-sparse-threads 'some)
8194 (eq gnus-build-sparse-threads 'more))
8195 ;; Deal with old-fetched headers and sparse threads.
8199 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8200 (gnus-summary-article-ancient-p
8201 (mail-header-number (car thread))))
8202 (if (or (<= (length (cdr thread)) 1)
8203 (eq gnus-fetch-old-headers 'invisible))
8204 (setq gnus-newsgroup-limit
8205 (delq (mail-header-number (car thread))
8206 gnus-newsgroup-limit)
8207 thread (cadr thread))
8208 (when (gnus-invisible-cut-children (cdr thread))
8209 (let ((th (cdr thread)))
8211 (if (memq (mail-header-number (caar th))
8212 gnus-newsgroup-limit)
8213 (setq thread (car th)
8215 (setq th (cdr th))))))))))
8218 (defun gnus-cut-threads (threads)
8219 "Cut off all uninteresting articles from the beginning of THREADS."
8220 (when (or (eq gnus-fetch-old-headers 'some)
8221 (eq gnus-fetch-old-headers 'invisible)
8222 (numberp gnus-fetch-old-headers)
8223 (eq gnus-build-sparse-threads 'some)
8224 (eq gnus-build-sparse-threads 'more))
8227 (setcar th (gnus-cut-thread (car th)))
8228 (setq th (cdr th)))))
8229 ;; Remove nixed out threads.
8232 (defun gnus-summary-initial-limit (&optional show-if-empty)
8233 "Figure out what the initial limit is supposed to be on group entry.
8234 This entails weeding out unwanted dormants, low-scored articles,
8235 fetch-old-headers verbiage, and so on."
8236 ;; Most groups have nothing to remove.
8237 (if (or gnus-inhibit-limiting
8238 (and (null gnus-newsgroup-dormant)
8239 (eq gnus-newsgroup-display 'gnus-not-ignore)
8240 (not (eq gnus-fetch-old-headers 'some))
8241 (not (numberp gnus-fetch-old-headers))
8242 (not (eq gnus-fetch-old-headers 'invisible))
8243 (null gnus-summary-expunge-below)
8244 (not (eq gnus-build-sparse-threads 'some))
8245 (not (eq gnus-build-sparse-threads 'more))
8246 (null gnus-thread-expunge-below)
8247 (not gnus-use-nocem)))
8249 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8250 (setq gnus-newsgroup-limit nil)
8253 (unless (car (symbol-value node))
8254 ;; These threads have no parents -- they are roots.
8255 (let ((nodes (cdr (symbol-value node)))
8258 (if (and gnus-thread-expunge-below
8259 (< (gnus-thread-total-score (car nodes))
8260 gnus-thread-expunge-below))
8261 (gnus-expunge-thread (pop nodes))
8262 (setq thread (pop nodes))
8263 (gnus-summary-limit-children thread))))))
8264 gnus-newsgroup-dependencies)
8265 ;; If this limitation resulted in an empty group, we might
8266 ;; pop the previous limit and use it instead.
8267 (when (and (not gnus-newsgroup-limit)
8269 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8270 gnus-newsgroup-limit))
8272 (defun gnus-summary-limit-children (thread)
8273 "Return 1 if this subthread is visible and 0 if it is not."
8274 ;; First we get the number of visible children to this thread. This
8275 ;; is done by recursing down the thread using this function, so this
8276 ;; will really go down to a leaf article first, before slowly
8277 ;; working its way up towards the root.
8279 (let* ((max-lisp-eval-depth 5000)
8282 (apply '+ (mapcar 'gnus-summary-limit-children
8285 (number (mail-header-number (car thread)))
8288 (not (memq number gnus-newsgroup-marked))
8290 ;; If this article is dormant and has absolutely no visible
8291 ;; children, then this article isn't visible.
8292 (and (memq number gnus-newsgroup-dormant)
8294 ;; If this is "fetch-old-headered" and there is no
8295 ;; visible children, then we don't want this article.
8296 (and (or (eq gnus-fetch-old-headers 'some)
8297 (numberp gnus-fetch-old-headers))
8298 (gnus-summary-article-ancient-p number)
8300 ;; If this is "fetch-old-headered" and `invisible', then
8301 ;; we don't want this article.
8302 (and (eq gnus-fetch-old-headers 'invisible)
8303 (gnus-summary-article-ancient-p number))
8304 ;; If this is a sparsely inserted article with no children,
8305 ;; we don't want it.
8306 (and (eq gnus-build-sparse-threads 'some)
8307 (gnus-summary-article-sparse-p number)
8309 ;; If we use expunging, and this article is really
8310 ;; low-scored, then we don't want this article.
8311 (when (and gnus-summary-expunge-below
8313 (or (cdr (assq number gnus-newsgroup-scored))
8314 gnus-summary-default-score))
8315 gnus-summary-expunge-below))
8316 ;; We increase the expunge-tally here, but that has
8317 ;; nothing to do with the limits, really.
8318 (incf gnus-newsgroup-expunged-tally)
8319 ;; We also mark as read here, if that's wanted.
8320 (when (and gnus-summary-mark-below
8321 (< score gnus-summary-mark-below))
8322 (setq gnus-newsgroup-unreads
8323 (delq number gnus-newsgroup-unreads))
8324 (if gnus-newsgroup-auto-expire
8325 (push number gnus-newsgroup-expirable)
8326 (push (cons number gnus-low-score-mark)
8327 gnus-newsgroup-reads)))
8329 ;; Do the `display' group parameter.
8330 (and gnus-newsgroup-display
8331 (not (funcall gnus-newsgroup-display)))
8332 ;; Check NoCeM things.
8333 (when (and gnus-use-nocem
8334 (gnus-nocem-unwanted-article-p
8335 (mail-header-id (car thread))))
8336 (setq gnus-newsgroup-unreads
8337 (delq number gnus-newsgroup-unreads))
8339 ;; Nope, invisible article.
8341 ;; Ok, this article is to be visible, so we add it to the limit
8343 (push number gnus-newsgroup-limit)
8346 (defun gnus-expunge-thread (thread)
8347 "Mark all articles in THREAD as read."
8348 (let* ((number (mail-header-number (car thread))))
8349 (incf gnus-newsgroup-expunged-tally)
8350 ;; We also mark as read here, if that's wanted.
8351 (setq gnus-newsgroup-unreads
8352 (delq number gnus-newsgroup-unreads))
8353 (if gnus-newsgroup-auto-expire
8354 (push number gnus-newsgroup-expirable)
8355 (push (cons number gnus-low-score-mark)
8356 gnus-newsgroup-reads)))
8357 ;; Go recursively through all subthreads.
8358 (mapcar 'gnus-expunge-thread (cdr thread)))
8360 ;; Summary article oriented commands
8362 (defun gnus-summary-refer-parent-article (n)
8363 "Refer parent article N times.
8364 If N is negative, go to ancestor -N instead.
8365 The difference between N and the number of articles fetched is returned."
8369 (when (not (natnump n))
8374 (setq header (gnus-summary-article-header))
8375 (if (and (eq (mail-header-number header)
8376 (cdr gnus-article-current))
8377 (equal gnus-newsgroup-name
8378 (car gnus-article-current)))
8379 ;; If we try to find the parent of the currently
8380 ;; displayed article, then we take a look at the actual
8381 ;; References header, since this is slightly more
8382 ;; reliable than the References field we got from the
8385 (set-buffer gnus-original-article-buffer)
8386 (nnheader-narrow-to-headers)
8387 (unless (setq ref (message-fetch-field "references"))
8388 (when (setq ref (message-fetch-field "in-reply-to"))
8389 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8392 ;; It's not the current article, so we take a bet on
8393 ;; the value we got from the server.
8394 (mail-header-references header)))
8396 (not (equal ref "")))
8397 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8398 (gnus-message 1 "Couldn't find parent"))
8399 (gnus-message 1 "No references in article %d"
8400 (gnus-summary-article-number))
8403 (gnus-summary-position-point)
8406 (defun gnus-summary-refer-references ()
8407 "Fetch all articles mentioned in the References header.
8408 Return the number of articles fetched."
8410 (let ((ref (mail-header-references (gnus-summary-article-header)))
8411 (current (gnus-summary-article-number))
8415 (error "No References in the current article")
8416 ;; For each Message-ID in the References header...
8417 (while (string-match "<[^>]*>" ref)
8419 ;; ... fetch that article.
8420 (gnus-summary-refer-article
8421 (prog1 (match-string 0 ref)
8422 (setq ref (substring ref (match-end 0))))))
8423 (gnus-summary-goto-subject current)
8424 (gnus-summary-position-point)
8427 (defun gnus-summary-refer-thread (&optional limit)
8428 "Fetch all articles in the current thread.
8429 If LIMIT (the numerical prefix), fetch that many old headers instead
8430 of what's specified by the `gnus-refer-thread-limit' variable."
8432 (let ((id (mail-header-id (gnus-summary-article-header)))
8433 (limit (if limit (prefix-numeric-value limit)
8434 gnus-refer-thread-limit)))
8435 (unless (eq gnus-fetch-old-headers 'invisible)
8436 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8437 ;; Retrieve the headers and read them in.
8438 (if (eq (if (numberp limit)
8439 (gnus-retrieve-headers
8441 (+ (mail-header-number
8442 (gnus-summary-article-header))
8444 gnus-newsgroup-end))
8445 gnus-newsgroup-name (* limit 2))
8446 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8448 (gnus-retrieve-headers (list gnus-newsgroup-end)
8449 gnus-newsgroup-name limit))
8451 (gnus-build-all-threads)
8452 (error "Can't fetch thread from back ends that don't support NOV"))
8453 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8454 (gnus-summary-limit-include-thread id)))
8456 (defun gnus-summary-refer-article (message-id)
8457 "Fetch an article specified by MESSAGE-ID."
8458 (interactive "sMessage-ID: ")
8459 (when (and (stringp message-id)
8460 (not (zerop (length message-id))))
8461 (setq message-id (gnus-replace-in-string message-id " " ""))
8462 ;; Construct the correct Message-ID if necessary.
8463 ;; Suggested by tale@pawl.rpi.edu.
8464 (unless (string-match "^<" message-id)
8465 (setq message-id (concat "<" message-id)))
8466 (unless (string-match ">$" message-id)
8467 (setq message-id (concat message-id ">")))
8468 ;; People often post MIDs from URLs, so unhex it:
8469 (unless (string-match "@" message-id)
8470 (setq message-id (gnus-url-unhex-string message-id)))
8471 (let* ((header (gnus-id-to-header message-id))
8473 (gnus-summary-article-sparse-p
8474 (mail-header-number header))
8475 (memq (mail-header-number header)
8476 gnus-newsgroup-limit)))
8479 ;; If the article is present in the buffer we just go to it.
8481 (or (not (gnus-summary-article-sparse-p
8482 (mail-header-number header)))
8485 (gnus-summary-goto-article
8486 (mail-header-number header) nil t)
8488 (gnus-summary-update-article (mail-header-number header)))))
8490 ;; We fetch the article.
8492 (dolist (gnus-override-method (gnus-refer-article-methods))
8493 (when (and (gnus-check-server gnus-override-method)
8494 ;; Fetch the header,
8495 (setq number (gnus-summary-insert-subject message-id)))
8496 ;; and display the article.
8497 (gnus-summary-select-article nil nil nil number)
8499 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8501 (defun gnus-refer-article-methods ()
8502 "Return a list of referable methods."
8504 ;; No method, so we default to current and native.
8505 ((null gnus-refer-article-method)
8506 (list gnus-current-select-method gnus-select-method))
8508 ((eq 'current gnus-refer-article-method)
8509 (list gnus-current-select-method))
8510 ;; List of select methods.
8511 ((not (and (symbolp (car gnus-refer-article-method))
8512 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8514 (dolist (method gnus-refer-article-method)
8515 (push (if (eq 'current method)
8516 gnus-current-select-method
8520 ;; One single select method.
8522 (list gnus-refer-article-method))))
8524 (defun gnus-summary-edit-parameters ()
8525 "Edit the group parameters of the current group."
8527 (gnus-group-edit-group gnus-newsgroup-name 'params))
8529 (defun gnus-summary-customize-parameters ()
8530 "Customize the group parameters of the current group."
8532 (gnus-group-customize gnus-newsgroup-name))
8534 (defun gnus-summary-enter-digest-group (&optional force)
8535 "Enter an nndoc group based on the current article.
8536 If FORCE, force a digest interpretation. If not, try
8537 to guess what the document format is."
8539 (let ((conf gnus-current-window-configuration))
8540 (save-window-excursion
8542 (let (gnus-article-prepare-hook
8543 gnus-display-mime-function
8545 (gnus-summary-select-article))))
8546 (setq gnus-current-window-configuration conf)
8547 (let* ((name (format "%s-%d"
8548 (gnus-group-prefixed-name
8549 gnus-newsgroup-name (list 'nndoc ""))
8550 (with-current-buffer gnus-summary-buffer
8551 gnus-current-article)))
8552 (ogroup gnus-newsgroup-name)
8553 (params (append (gnus-info-params (gnus-get-info ogroup))
8554 (list (cons 'to-group ogroup))
8555 (list (cons 'parent-group ogroup))
8556 (list (cons 'save-article-group ogroup))))
8557 (case-fold-search t)
8558 (buf (current-buffer))
8561 (set-buffer gnus-original-article-buffer)
8562 ;; Have the digest group inherit the main mail address of
8563 ;; the parent article.
8564 (when (setq to-address (or (gnus-fetch-field "reply-to")
8565 (gnus-fetch-field "from")))
8566 (setq params (append
8567 (list (cons 'to-address
8568 (funcall gnus-decode-encoded-word-function
8570 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8571 (insert-buffer-substring gnus-original-article-buffer)
8572 ;; Remove lines that may lead nndoc to misinterpret the
8575 (goto-char (point-min))
8576 (or (search-forward "\n\n" nil t) (point)))
8577 (goto-char (point-min))
8578 (delete-matching-lines "^Path:\\|^From ")
8581 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8582 (gnus-newsgroup-ephemeral-ignored-charsets
8583 gnus-newsgroup-ignored-charsets))
8584 (gnus-group-read-ephemeral-group
8585 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8587 ,(if force 'mbox 'guess)))
8589 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8591 ;; Make all postings to this group go to the parent group.
8592 (nconc (gnus-info-params (gnus-get-info name))
8594 ;; Couldn't select this doc group.
8595 (switch-to-buffer buf)
8596 (gnus-set-global-variables)
8597 (gnus-configure-windows 'summary)
8598 (gnus-message 3 "Article couldn't be entered?"))
8599 (kill-buffer dig)))))
8601 (defun gnus-summary-read-document (n)
8602 "Open a new group based on the current article(s).
8603 This will allow you to read digests and other similar
8604 documents as newsgroups.
8605 Obeys the standard process/prefix convention."
8607 (let* ((ogroup gnus-newsgroup-name)
8608 (params (append (gnus-info-params (gnus-get-info ogroup))
8609 (list (cons 'to-group ogroup))))
8610 group egroup groups vgroup)
8611 (dolist (article (gnus-summary-work-articles n))
8612 (setq group (format "%s-%d" gnus-newsgroup-name article))
8613 (gnus-summary-remove-process-mark article)
8614 (when (gnus-summary-display-article article)
8617 (insert-buffer-substring gnus-original-article-buffer)
8618 ;; Remove some headers that may lead nndoc to make
8620 (message-narrow-to-head)
8621 (goto-char (point-min))
8622 (delete-matching-lines "^Path:\\|^From ")
8625 (gnus-group-read-ephemeral-group
8626 group `(nndoc ,group (nndoc-address ,(current-buffer))
8627 (nndoc-article-type guess))
8630 ;; Make all postings to this group go to the parent group.
8631 (nconc (gnus-info-params (gnus-get-info egroup))
8633 (push egroup groups))
8634 ;; Couldn't select this doc group.
8635 (gnus-error 3 "Article couldn't be entered"))))))
8636 ;; Now we have selected all the documents.
8639 (error "None of the articles could be interpreted as documents"))
8640 ((gnus-group-read-ephemeral-group
8641 (setq vgroup (format
8642 "nnvirtual:%s-%s" gnus-newsgroup-name
8643 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8644 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8646 (cons (current-buffer) 'summary)))
8648 (error "Couldn't select virtual nndoc group")))))
8650 (defun gnus-summary-isearch-article (&optional regexp-p)
8651 "Do incremental search forward on the current article.
8652 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8654 (gnus-summary-select-article)
8655 (gnus-configure-windows 'article)
8656 (gnus-eval-in-buffer-window gnus-article-buffer
8659 (isearch-forward regexp-p))))
8661 (defun gnus-summary-search-article-forward (regexp &optional backward)
8662 "Search for an article containing REGEXP forward.
8663 If BACKWARD, search backward instead."
8666 (format "Search article %s (regexp%s): "
8667 (if current-prefix-arg "backward" "forward")
8668 (if gnus-last-search-regexp
8669 (concat ", default " gnus-last-search-regexp)
8671 current-prefix-arg))
8672 (if (string-equal regexp "")
8673 (setq regexp (or gnus-last-search-regexp ""))
8674 (setq gnus-last-search-regexp regexp)
8675 (setq gnus-article-before-search gnus-current-article))
8676 ;; Intentionally set gnus-last-article.
8677 (setq gnus-last-article gnus-article-before-search)
8678 (let ((gnus-last-article gnus-last-article))
8679 (if (gnus-summary-search-article regexp backward)
8680 (gnus-summary-show-thread)
8681 (signal 'search-failed (list regexp)))))
8683 (defun gnus-summary-search-article-backward (regexp)
8684 "Search for an article containing REGEXP backward."
8687 (format "Search article backward (regexp%s): "
8688 (if gnus-last-search-regexp
8689 (concat ", default " gnus-last-search-regexp)
8691 (gnus-summary-search-article-forward regexp 'backward))
8693 (defun gnus-summary-search-article (regexp &optional backward)
8694 "Search for an article containing REGEXP.
8695 Optional argument BACKWARD means do search for backward.
8696 `gnus-select-article-hook' is not called during the search."
8697 ;; We have to require this here to make sure that the following
8698 ;; dynamic binding isn't shadowed by autoloading.
8699 (require 'gnus-async)
8701 (let ((gnus-select-article-hook nil) ;Disable hook.
8702 (gnus-article-prepare-hook nil)
8703 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8704 (gnus-use-article-prefetch nil)
8705 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8706 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8708 (gnus-keep-backlog nil)
8709 (gnus-break-pages nil)
8710 (gnus-summary-display-arrow nil)
8711 (gnus-updated-mode-lines nil)
8712 (gnus-auto-center-summary nil)
8713 (sum (current-buffer))
8714 (gnus-display-mime-function nil)
8717 (gnus-save-hidden-threads
8718 (gnus-summary-select-article)
8719 (set-buffer gnus-article-buffer)
8720 (goto-char (window-point (get-buffer-window (current-buffer))))
8724 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8726 (re-search-backward regexp nil t)
8727 (re-search-forward regexp nil t))
8728 ;; We found the regexp.
8733 (get-buffer-window (current-buffer))
8737 (get-buffer-window (current-buffer))
8740 (setq point (point)))
8741 ;; We didn't find it, so we go to the next article.
8744 (while (eq found 'not)
8745 (if (not (if backward (gnus-summary-find-prev)
8746 (gnus-summary-find-next)))
8747 ;; No more articles.
8749 ;; Select the next article and adjust point.
8750 (unless (gnus-summary-article-sparse-p
8751 (gnus-summary-article-number))
8753 (gnus-summary-select-article)
8754 (set-buffer gnus-article-buffer)
8756 (goto-char (if backward (point-max) (point-min))))))))
8757 (gnus-message 7 ""))
8758 ;; Return whether we found the regexp.
8759 (when (eq found 'found)
8761 (gnus-summary-show-thread)
8762 (gnus-summary-goto-subject gnus-current-article)
8763 (gnus-summary-position-point)
8766 (defun gnus-find-matching-articles (header regexp)
8767 "Return a list of all articles that match REGEXP on HEADER.
8768 This search includes all articles in the current group that Gnus has
8769 fetched headers for, whether they are displayed or not."
8770 (let ((articles nil)
8771 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8772 (case-fold-search t))
8773 (dolist (header gnus-newsgroup-headers)
8774 (when (string-match regexp (funcall func header))
8775 (push (mail-header-number header) articles)))
8776 (nreverse articles)))
8778 (defun gnus-summary-find-matching (header regexp &optional backward unread
8779 not-case-fold not-matching)
8780 "Return a list of all articles that match REGEXP on HEADER.
8781 The search stars on the current article and goes forwards unless
8782 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8783 If UNREAD is non-nil, only unread articles will
8784 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8785 in the comparisons. If NOT-MATCHING, return a list of all articles that
8786 not match REGEXP on HEADER."
8787 (let ((case-fold-search (not not-case-fold))
8790 (if (eq (car header) 'extra)
8793 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8795 (error "%s is an invalid header" header))
8796 (unless (fboundp (intern (concat "mail-header-" header)))
8797 (error "%s is not a valid header" header))
8798 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8799 (dolist (d (if (eq backward 'all)
8801 (gnus-data-find-list
8802 (gnus-summary-article-number)
8803 (gnus-data-list backward))))
8804 (when (and (or (not unread) ; We want all articles...
8805 (gnus-data-unread-p d)) ; Or just unreads.
8806 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8810 (funcall func (gnus-data-header d))))
8811 (string-match regexp
8812 (funcall func (gnus-data-header d)))))
8813 (push (gnus-data-number d) articles))) ; Success!
8814 (nreverse articles)))
8816 (defun gnus-summary-execute-command (header regexp command &optional backward)
8817 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8818 If HEADER is an empty string (or nil), the match is done on the entire
8819 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8821 (list (let ((completion-ignore-case t))
8824 (mapcar (lambda (header) (list (format "%s" header)))
8826 '("Number" "Subject" "From" "Lines" "Date"
8827 "Message-ID" "Xref" "References" "Body")
8828 gnus-extra-headers))
8829 nil 'require-match))
8830 (read-string "Regexp: ")
8831 (read-key-sequence "Command: ")
8832 current-prefix-arg))
8833 (when (equal header "Body")
8835 ;; Hidden thread subtrees must be searched as well.
8836 (gnus-summary-show-all-threads)
8837 ;; We don't want to change current point nor window configuration.
8839 (save-window-excursion
8841 gnus-treat-strip-trailing-blank-lines
8842 gnus-treat-strip-leading-blank-lines
8843 gnus-treat-strip-multiple-blank-lines
8844 gnus-treat-hide-boring-headers
8845 gnus-treat-fold-newsgroups
8846 gnus-article-prepare-hook)
8847 (gnus-message 6 "Executing %s..." (key-description command))
8848 ;; We'd like to execute COMMAND interactively so as to give arguments.
8849 (gnus-execute header regexp
8850 `(call-interactively ',(key-binding command))
8852 (gnus-message 6 "Executing %s...done" (key-description command))))))
8854 (defun gnus-summary-beginning-of-article ()
8855 "Scroll the article back to the beginning."
8857 (gnus-summary-select-article)
8858 (gnus-configure-windows 'article)
8859 (gnus-eval-in-buffer-window gnus-article-buffer
8861 (goto-char (point-min))
8862 (when gnus-break-pages
8863 (gnus-narrow-to-page))))
8865 (defun gnus-summary-end-of-article ()
8866 "Scroll to the end of the article."
8868 (gnus-summary-select-article)
8869 (gnus-configure-windows 'article)
8870 (gnus-eval-in-buffer-window gnus-article-buffer
8872 (goto-char (point-max))
8874 (when gnus-break-pages
8875 (when (re-search-backward page-delimiter nil t)
8876 (narrow-to-region (match-end 0) (point-max)))
8877 (gnus-narrow-to-page))))
8879 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8880 "Truncate to LEN and quote all \"(\"'s in STRING."
8881 (gnus-replace-in-string (if (and len (> (length string) len))
8882 (substring string 0 len)
8886 (defun gnus-summary-print-article (&optional filename n)
8887 "Generate and print a PostScript image of the process-marked (mail) articles.
8889 If used interactively, print the current article if none are
8890 process-marked. With prefix arg, prompt the user for the name of the
8893 When used from Lisp, accept two optional args FILENAME and N. N means
8894 to print the next N articles. If N is negative, print the N previous
8895 articles. If N is nil and articles have been marked with the process
8896 mark, print these instead.
8898 If the optional first argument FILENAME is nil, send the image to the
8899 printer. If FILENAME is a string, save the PostScript image in a file with
8900 that name. If FILENAME is a number, prompt the user for the name of the file
8902 (interactive (list (ps-print-preprint current-prefix-arg)))
8903 (dolist (article (gnus-summary-work-articles n))
8904 (gnus-summary-select-article nil nil 'pseudo article)
8905 (gnus-eval-in-buffer-window gnus-article-buffer
8906 (gnus-print-buffer))
8907 (gnus-summary-remove-process-mark article))
8908 (ps-despool filename))
8910 (defun gnus-print-buffer ()
8911 (let ((buffer (generate-new-buffer " *print*")))
8914 (copy-to-buffer buffer (point-min) (point-max))
8916 (gnus-remove-text-with-property 'gnus-decoration)
8917 (when (gnus-visual-p 'article-highlight 'highlight)
8918 ;; Copy-to-buffer doesn't copy overlay. So redo
8920 (let ((gnus-article-buffer buffer))
8921 (gnus-article-highlight-citation t)
8922 (gnus-article-highlight-signature)
8923 (gnus-article-emphasize)
8924 (gnus-article-delete-invisible-text)))
8925 (let ((ps-left-header
8928 (gnus-summary-print-truncate-and-quote
8929 (mail-header-subject gnus-current-headers)
8932 (gnus-summary-print-truncate-and-quote
8933 (mail-header-from gnus-current-headers)
8937 "/pagenumberstring load"
8939 (mail-header-date gnus-current-headers) ")"))))
8940 (gnus-run-hooks 'gnus-ps-print-hook)
8943 (ps-spool-buffer-with-faces)
8944 (ps-spool-buffer)))))
8945 (kill-buffer buffer))))
8947 (defun gnus-summary-show-article (&optional arg)
8948 "Force redisplaying of the current article.
8949 If ARG (the prefix) is a number, show the article with the charset
8950 defined in `gnus-summary-show-article-charset-alist', or the charset
8952 If ARG (the prefix) is non-nil and not a number, show the raw article
8953 without any article massaging functions being run. Normally, the key
8954 strokes are `C-u g'."
8958 (gnus-summary-show-article t)
8959 (let ((gnus-newsgroup-charset
8960 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8961 (mm-read-coding-system
8962 "View as charset: " ;; actually it is coding system.
8963 (with-current-buffer gnus-article-buffer
8964 (mm-detect-coding-region (point) (point-max))))))
8965 (gnus-newsgroup-ignored-charsets 'gnus-all))
8966 (gnus-summary-select-article nil 'force)
8967 (let ((deps gnus-newsgroup-dependencies)
8970 (set-buffer gnus-original-article-buffer)
8972 (message-narrow-to-head)
8973 (setq head (buffer-string))
8974 (goto-char (point-min))
8975 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8976 (goto-char (point-max))
8978 (setq lines (1- (count-lines (point) (point-max))))))
8980 (insert (format "211 %d Article retrieved.\n"
8981 (cdr gnus-article-current)))
8983 (if lines (insert (format "Lines: %d\n" lines)))
8985 (let ((nntp-server-buffer (current-buffer)))
8986 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8987 (gnus-data-set-header
8988 (gnus-data-find (cdr gnus-article-current))
8990 (gnus-summary-update-article-line
8991 (cdr gnus-article-current) header)
8992 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8993 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8995 ;; Select the article the normal way.
8996 (gnus-summary-select-article nil 'force))
8998 ;; We have to require this here to make sure that the following
8999 ;; dynamic binding isn't shadowed by autoloading.
9000 (require 'gnus-async)
9002 ;; Bind the article treatment functions to nil.
9003 (let ((gnus-have-all-headers t)
9004 gnus-article-prepare-hook
9005 gnus-article-decode-hook
9006 gnus-display-mime-function
9008 ;; Destroy any MIME parts.
9009 (when (gnus-buffer-live-p gnus-article-buffer)
9011 (set-buffer gnus-article-buffer)
9012 (mm-destroy-parts gnus-article-mime-handles)
9013 ;; Set it to nil for safety reason.
9014 (setq gnus-article-mime-handle-alist nil)
9015 (setq gnus-article-mime-handles nil)))
9016 (gnus-summary-select-article nil 'force))))
9017 (gnus-summary-goto-subject gnus-current-article)
9018 (gnus-summary-position-point))
9020 (defun gnus-summary-show-raw-article ()
9021 "Show the raw article without any article massaging functions being run."
9023 (gnus-summary-show-article t))
9025 (defun gnus-summary-verbose-headers (&optional arg)
9026 "Toggle permanent full header display.
9027 If ARG is a positive number, turn header display on.
9028 If ARG is a negative number, turn header display off."
9030 (setq gnus-show-all-headers
9031 (cond ((or (not (numberp arg))
9033 (not gnus-show-all-headers))
9036 (gnus-summary-show-article))
9038 (defun gnus-summary-toggle-header (&optional arg)
9039 "Show the headers if they are hidden, or hide them if they are shown.
9040 If ARG is a positive number, show the entire header.
9041 If ARG is a negative number, hide the unwanted header lines."
9043 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9044 (get-buffer-window gnus-article-buffer t))))
9045 (with-current-buffer gnus-article-buffer
9047 (article-narrow-to-head)
9048 (let* ((buffer-read-only nil)
9049 (inhibit-point-motion-hooks t)
9050 (hidden (if (numberp arg)
9052 (or (not (looking-at "[^ \t\n]+:"))
9053 (gnus-article-hidden-text-p 'headers))))
9055 (delete-region (point-min) (point-max))
9056 (with-current-buffer gnus-original-article-buffer
9057 (goto-char (setq s (point-min)))
9058 (setq e (if (search-forward "\n\n" nil t)
9061 (insert-buffer-substring gnus-original-article-buffer s e)
9062 (run-hooks 'gnus-article-decode-hook)
9064 (let ((gnus-treat-hide-headers nil)
9065 (gnus-treat-hide-boring-headers nil))
9066 (gnus-delete-wash-type 'headers)
9067 (gnus-treat-article 'head))
9068 (gnus-treat-article 'head))
9071 (set-window-start window (goto-char (point-min))))
9072 (if gnus-break-pages
9073 (gnus-narrow-to-page)
9074 (when (gnus-visual-p 'page-marker)
9075 (let ((buffer-read-only nil))
9076 (gnus-remove-text-with-property 'gnus-prev)
9077 (gnus-remove-text-with-property 'gnus-next))))
9078 (gnus-set-mode-line 'article)))))
9080 (defun gnus-summary-show-all-headers ()
9081 "Make all header lines visible."
9083 (gnus-summary-toggle-header 1))
9085 (defun gnus-summary-caesar-message (&optional arg)
9086 "Caesar rotate the current article by 13.
9087 The numerical prefix specifies how many places to rotate each letter
9090 (gnus-summary-select-article)
9091 (let ((mail-header-separator ""))
9092 (gnus-eval-in-buffer-window gnus-article-buffer
9095 (let ((start (window-start))
9097 (message-caesar-buffer-body arg)
9098 (set-window-start (get-buffer-window (current-buffer)) start)))))
9099 ;; Create buttons and stuff...
9100 (gnus-treat-article nil))
9102 (defun gnus-summary-idna-message (&optional arg)
9103 "Decode IDNA encoded domain names in the current articles.
9104 IDNA encoded domain names looks like `xn--bar'. If a string
9105 remain unencoded after running this function, it is likely an
9106 invalid IDNA string (`xn--bar' is invalid).
9108 You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9109 installed for this command to work."
9111 (if (not (and (condition-case nil (require 'idna)
9113 (mm-coding-system-p 'utf-8)
9114 (executable-find (symbol-value 'idna-program))))
9116 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9117 (gnus-summary-select-article)
9118 (let ((mail-header-separator ""))
9119 (gnus-eval-in-buffer-window gnus-article-buffer
9122 (let ((start (window-start))
9124 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9125 (replace-match (idna-to-unicode (match-string 1))))
9126 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9128 (autoload 'unmorse-region "morse"
9129 "Convert morse coded text in region to ordinary ASCII text."
9132 (defun gnus-summary-morse-message (&optional arg)
9133 "Morse decode the current article."
9135 (gnus-summary-select-article)
9136 (let ((mail-header-separator ""))
9137 (gnus-eval-in-buffer-window gnus-article-buffer
9141 (let ((pos (window-start))
9143 (goto-char (point-min))
9144 (when (message-goto-body)
9145 (gnus-narrow-to-body))
9146 (goto-char (point-min))
9147 (while (search-forward "·" (point-max) t)
9148 (replace-match "."))
9149 (unmorse-region (point-min) (point-max))
9151 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9153 (defun gnus-summary-stop-page-breaking ()
9154 "Stop page breaking in the current article."
9156 (gnus-summary-select-article)
9157 (gnus-eval-in-buffer-window gnus-article-buffer
9159 (when (gnus-visual-p 'page-marker)
9160 (let ((buffer-read-only nil))
9161 (gnus-remove-text-with-property 'gnus-prev)
9162 (gnus-remove-text-with-property 'gnus-next))
9163 (setq gnus-page-broken nil))))
9165 (defun gnus-summary-move-article (&optional n to-newsgroup
9166 select-method action)
9167 "Move the current article to a different newsgroup.
9168 If N is a positive number, move the N next articles.
9169 If N is a negative number, move the N previous articles.
9170 If N is nil and any articles have been marked with the process mark,
9171 move those articles instead.
9172 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9173 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9174 re-spool using this method.
9176 When called interactively with TO-NEWSGROUP being nil, the value of
9177 the variable `gnus-move-split-methods' is used for finding a default
9178 for the target newsgroup.
9180 For this function to work, both the current newsgroup and the
9181 newsgroup that you want to move to have to support the `request-move'
9182 and `request-accept' functions.
9184 ACTION can be either `move' (the default), `crosspost' or `copy'."
9187 (setq action 'move))
9188 ;; Check whether the source group supports the required functions.
9189 (cond ((and (eq action 'move)
9190 (not (gnus-check-backend-function
9191 'request-move-article gnus-newsgroup-name)))
9192 (error "The current group does not support article moving"))
9193 ((and (eq action 'crosspost)
9194 (not (gnus-check-backend-function
9195 'request-replace-article gnus-newsgroup-name)))
9196 (error "The current group does not support article editing")))
9197 (let ((articles (gnus-summary-work-articles n))
9198 (prefix (if (gnus-check-backend-function
9199 'request-move-article gnus-newsgroup-name)
9200 (funcall gnus-move-group-prefix-function
9201 gnus-newsgroup-name)
9203 (names '((move "Move" "Moving")
9204 (copy "Copy" "Copying")
9205 (crosspost "Crosspost" "Crossposting")))
9206 (copy-buf (save-excursion
9207 (nnheader-set-temp-buffer " *copy article*")))
9208 art-group to-method new-xref article to-groups articles-to-update-marks)
9209 (unless (assq action names)
9210 (error "Unknown action %s" action))
9211 ;; Read the newsgroup name.
9212 (when (and (not to-newsgroup)
9213 (not select-method))
9214 (if (and gnus-move-split-methods
9216 (and (memq gnus-current-article articles)
9217 (gnus-buffer-live-p gnus-original-article-buffer))))
9218 ;; When `gnus-move-split-methods' is non-nil, we have to
9219 ;; select an article to give `gnus-read-move-group-name' an
9220 ;; opportunity to suggest an appropriate default. However,
9221 ;; we needn't render or mark the article.
9222 (let ((gnus-display-mime-function nil)
9223 (gnus-article-prepare-hook nil)
9224 (gnus-mark-article-hook nil))
9225 (gnus-summary-select-article nil nil nil (car articles))))
9227 (gnus-read-move-group-name
9228 (cadr (assq action names))
9229 (symbol-value (intern (format "gnus-current-%s-group" action)))
9231 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9232 (setq to-method (or select-method
9233 (gnus-server-to-method
9234 (gnus-group-method to-newsgroup))))
9235 ;; Check the method we are to move this article to...
9236 (unless (gnus-check-backend-function
9237 'request-accept-article (car to-method))
9238 (error "%s does not support article copying" (car to-method)))
9239 (unless (gnus-check-server to-method)
9240 (error "Can't open server %s" (car to-method)))
9241 (gnus-message 6 "%s to %s: %s..."
9242 (caddr (assq action names))
9243 (or (car select-method) to-newsgroup) articles)
9245 (setq article (pop articles))
9249 ;; Move the article.
9251 ;; Remove this article from future suppression.
9252 (gnus-dup-unsuppress-article article)
9253 (let* ((from-method (gnus-find-method-for-group
9254 gnus-newsgroup-name))
9255 (to-method (gnus-find-method-for-group
9257 (move-is-internal (gnus-method-equal from-method to-method)))
9258 (gnus-request-move-article
9259 article ; Article to move
9260 gnus-newsgroup-name ; From newsgroup
9261 (nth 1 (gnus-find-method-for-group
9262 gnus-newsgroup-name)) ; Server
9263 (list 'gnus-request-accept-article
9264 to-newsgroup (list 'quote select-method)
9265 (not articles) t) ; Accept form
9266 (not articles) ; Only save nov last time
9267 move-is-internal))) ; is this move internal?
9268 ;; Copy the article.
9271 (set-buffer copy-buf)
9272 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9274 (nnheader-narrow-to-headers)
9275 (dolist (hdr gnus-copy-article-ignored-headers)
9276 (message-remove-header hdr t)))
9277 (gnus-request-accept-article
9278 to-newsgroup select-method (not articles) t))))
9279 ;; Crosspost the article.
9280 ((eq action 'crosspost)
9281 (let ((xref (message-tokenize-header
9282 (mail-header-xref (gnus-summary-article-header article))
9284 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9285 ":" (number-to-string article)))
9287 (setq xref (list (system-name))))
9290 (mapconcat 'identity
9291 (delete "Xref:" (delete new-xref xref))
9295 (set-buffer copy-buf)
9296 ;; First put the article in the destination group.
9297 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9298 (when (consp (setq art-group
9299 (gnus-request-accept-article
9300 to-newsgroup select-method (not articles))))
9301 (setq new-xref (concat new-xref " " (car art-group)
9303 (number-to-string (cdr art-group))))
9304 ;; Now we have the new Xrefs header, so we insert
9305 ;; it and replace the new article.
9306 (nnheader-replace-header "Xref" new-xref)
9307 (gnus-request-replace-article
9308 (cdr art-group) to-newsgroup (current-buffer))
9312 (gnus-message 1 "Couldn't %s article %s: %s"
9313 (cadr (assq action names)) article
9314 (nnheader-get-report (car to-method))))
9315 ((eq art-group 'junk)
9316 (when (eq action 'move)
9317 (gnus-summary-mark-article article gnus-canceled-mark)
9318 (gnus-message 4 "Deleted article %s" article)
9319 ;; run the delete hook
9320 (run-hook-with-args 'gnus-summary-article-delete-hook
9323 (assoc article (gnus-data-list nil)))
9324 gnus-newsgroup-name nil
9327 (let* ((pto-group (gnus-group-prefixed-name
9328 (car art-group) to-method))
9329 (info (gnus-get-info pto-group))
9330 (to-group (gnus-info-group info))
9332 ;; Update the group that has been moved to.
9334 (memq action '(move copy)))
9335 (unless (member to-group to-groups)
9336 (push to-group to-groups))
9338 (unless (memq article gnus-newsgroup-unreads)
9339 (push 'read to-marks)
9341 info (gnus-add-to-range (gnus-info-read info)
9342 (list (cdr art-group)))))
9344 ;; See whether the article is to be put in the cache.
9345 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9346 gnus-article-mark-lists
9347 (delete '(expirable . expire)
9348 (copy-sequence gnus-article-mark-lists))))
9349 (to-article (cdr art-group)))
9351 ;; Enter the article into the cache in the new group,
9352 ;; if that is required.
9353 (when gnus-use-cache
9354 (gnus-cache-possibly-enter-article
9356 (memq article gnus-newsgroup-marked)
9357 (memq article gnus-newsgroup-dormant)
9358 (memq article gnus-newsgroup-unreads)))
9360 (when gnus-preserve-marks
9361 ;; Copy any marks over to the new group.
9362 (when (and (equal to-group gnus-newsgroup-name)
9363 (not (memq article gnus-newsgroup-unreads)))
9364 ;; Mark this article as read in this group.
9365 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9366 (setcdr (gnus-active to-group) to-article)
9367 (setcdr gnus-newsgroup-active to-article))
9370 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9371 (when (memq article (symbol-value
9372 (intern (format "gnus-newsgroup-%s"
9374 (push (cdar marks) to-marks)
9375 ;; If the other group is the same as this group,
9376 ;; then we have to add the mark to the list.
9377 (when (equal to-group gnus-newsgroup-name)
9378 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9381 (intern (format "gnus-newsgroup-%s"
9383 ;; Copy the marks to other group.
9384 (gnus-add-marked-articles
9385 to-group (cdar marks) (list to-article) info)))
9386 (setq marks (cdr marks)))
9388 (gnus-request-set-mark
9389 to-group (list (list (list to-article) 'add to-marks))))
9392 (concat "(gnus-group-set-info '"
9393 (gnus-prin1-to-string (gnus-get-info to-group))
9396 ;; Update the Xref header in this article to point to
9397 ;; the new crossposted article we have just created.
9398 (when (eq action 'crosspost)
9400 (set-buffer copy-buf)
9401 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9402 (nnheader-replace-header "Xref" new-xref)
9403 (gnus-request-replace-article
9404 article gnus-newsgroup-name (current-buffer))))
9406 ;; run the move/copy/crosspost/respool hook
9407 (run-hook-with-args 'gnus-summary-article-move-hook
9410 (assoc article (gnus-data-list nil)))
9415 ;;;!!!Why is this necessary?
9416 (set-buffer gnus-summary-buffer)
9418 (gnus-summary-goto-subject article)
9419 (when (eq action 'move)
9420 (gnus-summary-mark-article article gnus-canceled-mark))))
9421 (push article articles-to-update-marks))
9423 (apply 'gnus-summary-remove-process-mark articles-to-update-marks)
9424 ;; Re-activate all groups that have been moved to.
9426 (set-buffer gnus-group-buffer)
9427 (let ((gnus-group-marked to-groups))
9428 (gnus-group-get-new-news-this-group nil t)))
9430 (gnus-kill-buffer copy-buf)
9431 (gnus-summary-position-point)
9432 (gnus-set-mode-line 'summary)))
9434 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9435 "Copy the current article to some other group.
9436 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9437 When called interactively, if TO-NEWSGROUP is nil, use the value of
9438 the variable `gnus-move-split-methods' for finding a default target
9440 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9441 re-spool using this method."
9443 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9445 (defun gnus-summary-crosspost-article (&optional n)
9446 "Crosspost the current article to some other group."
9448 (gnus-summary-move-article n nil nil 'crosspost))
9450 (defcustom gnus-summary-respool-default-method nil
9451 "Default method type for respooling an article.
9452 If nil, use to the current newsgroup method."
9454 :group 'gnus-summary-mail)
9456 (defcustom gnus-summary-display-while-building nil
9457 "If non-nil, show and update the summary buffer as it's being built.
9458 If the value is t, update the buffer after every line is inserted. If
9459 the value is an integer (N), update the display every N lines."
9462 :type '(choice (const :tag "off" nil)
9464 (const :tag "frequently" t)))
9466 (defun gnus-summary-respool-article (&optional n method)
9467 "Respool the current article.
9468 The article will be squeezed through the mail spooling process again,
9469 which means that it will be put in some mail newsgroup or other
9470 depending on `nnmail-split-methods'.
9471 If N is a positive number, respool the N next articles.
9472 If N is a negative number, respool the N previous articles.
9473 If N is nil and any articles have been marked with the process mark,
9474 respool those articles instead.
9476 Respooling can be done both from mail groups and \"real\" newsgroups.
9477 In the former case, the articles in question will be moved from the
9478 current group into whatever groups they are destined to. In the
9479 latter case, they will be copied into the relevant groups."
9481 (list current-prefix-arg
9482 (let* ((methods (gnus-methods-using 'respool))
9484 (symbol-name (or gnus-summary-respool-default-method
9485 (car (gnus-find-method-for-group
9486 gnus-newsgroup-name)))))
9488 (gnus-completing-read-with-default
9489 methname "Backend to use when respooling"
9490 methods nil t nil 'gnus-mail-method-history))
9493 ((zerop (length (setq ms (gnus-servers-using-backend
9495 (list (intern method) ""))
9499 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9500 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9503 (error "No method given for respooling"))
9504 (if (assoc (symbol-name
9505 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9506 (gnus-methods-using 'respool))
9507 (gnus-summary-move-article n nil method)
9508 (gnus-summary-copy-article n nil method)))
9510 (defun gnus-summary-import-article (file &optional edit)
9511 "Import an arbitrary file into a mail newsgroup."
9512 (interactive "fImport file: \nP")
9513 (let ((group gnus-newsgroup-name)
9514 (now (current-time))
9515 atts lines group-art)
9516 (unless (gnus-check-backend-function 'request-accept-article group)
9517 (error "%s does not support article importing" group))
9518 (or (file-readable-p file)
9519 (not (file-regular-p file))
9520 (error "Can't read %s" file))
9522 (set-buffer (gnus-get-buffer-create " *import file*"))
9524 (nnheader-insert-file-contents file)
9525 (goto-char (point-min))
9526 (if (nnheader-article-p)
9528 (goto-char (point-min))
9529 (search-forward "\n\n" nil t)
9530 (narrow-to-region (point-min) (1- (point)))
9531 (goto-char (point-min))
9532 (unless (re-search-forward "^date:" nil t)
9533 (goto-char (point-max))
9534 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9535 ;; This doesn't look like an article, so we fudge some headers.
9536 (setq atts (file-attributes file)
9537 lines (count-lines (point-min) (point-max)))
9538 (insert "From: " (read-string "From: ") "\n"
9539 "Subject: " (read-string "Subject: ") "\n"
9540 "Date: " (message-make-date (nth 5 atts)) "\n"
9541 "Message-ID: " (message-make-message-id) "\n"
9542 "Lines: " (int-to-string lines) "\n"
9543 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9544 (setq group-art (gnus-request-accept-article group nil t))
9545 (kill-buffer (current-buffer)))
9546 (setq gnus-newsgroup-active (gnus-activate-group group))
9548 (gnus-summary-goto-article (cdr group-art) nil t)
9550 (gnus-summary-edit-article))))
9552 (defun gnus-summary-create-article ()
9553 "Create an article in a mail newsgroup."
9555 (let ((group gnus-newsgroup-name)
9556 (now (current-time))
9558 (unless (gnus-check-backend-function 'request-accept-article group)
9559 (error "%s does not support article importing" group))
9561 (set-buffer (gnus-get-buffer-create " *import file*"))
9563 (goto-char (point-min))
9564 ;; This doesn't look like an article, so we fudge some headers.
9565 (insert "From: " (read-string "From: ") "\n"
9566 "Subject: " (read-string "Subject: ") "\n"
9567 "Date: " (message-make-date now) "\n"
9568 "Message-ID: " (message-make-message-id) "\n")
9569 (setq group-art (gnus-request-accept-article group nil t))
9570 (kill-buffer (current-buffer)))
9571 (setq gnus-newsgroup-active (gnus-activate-group group))
9573 (gnus-summary-goto-article (cdr group-art) nil t)
9574 (gnus-summary-edit-article)))
9576 (defun gnus-summary-article-posted-p ()
9577 "Say whether the current (mail) article is available from news as well.
9578 This will be the case if the article has both been mailed and posted."
9580 (let ((id (mail-header-references (gnus-summary-article-header)))
9581 (gnus-override-method (car (gnus-refer-article-methods))))
9582 (if (gnus-request-head id "")
9583 (gnus-message 2 "The current message was found on %s"
9584 gnus-override-method)
9585 (gnus-message 2 "The current message couldn't be found on %s"
9586 gnus-override-method)
9589 (defun gnus-summary-expire-articles (&optional now)
9590 "Expire all articles that are marked as expirable in the current group."
9592 (when (and (not gnus-group-is-exiting-without-update-p)
9593 (gnus-check-backend-function
9594 'request-expire-articles gnus-newsgroup-name))
9595 ;; This backend supports expiry.
9596 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9597 (expirable (if total
9599 ;; We need to update the info for
9600 ;; this group for `gnus-list-of-read-articles'
9601 ;; to give us the right answer.
9602 (gnus-run-hooks 'gnus-exit-group-hook)
9603 (gnus-summary-update-info)
9604 (gnus-list-of-read-articles gnus-newsgroup-name))
9605 (setq gnus-newsgroup-expirable
9606 (sort gnus-newsgroup-expirable '<))))
9607 (expiry-wait (if now 'immediate
9608 (gnus-group-find-parameter
9609 gnus-newsgroup-name 'expiry-wait)))
9610 (nnmail-expiry-target
9611 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9612 nnmail-expiry-target))
9615 ;; There are expirable articles in this group, so we run them
9616 ;; through the expiry process.
9617 (gnus-message 6 "Expiring articles...")
9618 (unless (gnus-check-group gnus-newsgroup-name)
9619 (error "Can't open server for %s" gnus-newsgroup-name))
9620 ;; The list of articles that weren't expired is returned.
9623 (let ((nnmail-expiry-wait-function nil)
9624 (nnmail-expiry-wait expiry-wait))
9625 (setq es (gnus-request-expire-articles
9626 expirable gnus-newsgroup-name)))
9627 (setq es (gnus-request-expire-articles
9628 expirable gnus-newsgroup-name)))
9630 (setq gnus-newsgroup-expirable es))
9631 ;; We go through the old list of expirable, and mark all
9632 ;; really expired articles as nonexistent.
9633 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9634 (let ((gnus-use-cache nil))
9635 (dolist (article expirable)
9636 (when (and (not (memq article es))
9637 (gnus-data-find article))
9638 (gnus-summary-mark-article article gnus-canceled-mark)
9639 (run-hook-with-args 'gnus-summary-article-expire-hook
9642 (assoc article (gnus-data-list nil)))
9646 (gnus-message 6 "Expiring articles...done")))))
9648 (defun gnus-summary-expire-articles-now ()
9649 "Expunge all expirable articles in the current group.
9650 This means that *all* articles that are marked as expirable will be
9651 deleted forever, right now."
9653 (or gnus-expert-user
9655 "Are you really, really, really sure you want to delete all these messages? ")
9657 (gnus-summary-expire-articles t))
9659 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9660 (defun gnus-summary-delete-article (&optional n)
9661 "Delete the N next (mail) articles.
9662 This command actually deletes articles. This is not a marking
9663 command. The article will disappear forever from your life, never to
9666 If N is negative, delete backwards.
9667 If N is nil and articles have been marked with the process mark,
9668 delete these instead.
9670 If `gnus-novice-user' is non-nil you will be asked for
9671 confirmation before the articles are deleted."
9673 (unless (gnus-check-backend-function 'request-expire-articles
9674 gnus-newsgroup-name)
9675 (error "The current newsgroup does not support article deletion"))
9676 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9677 (error "Couldn't open server"))
9678 ;; Compute the list of articles to delete.
9679 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9680 (nnmail-expiry-target 'delete)
9682 (if (and gnus-novice-user
9683 (not (gnus-yes-or-no-p
9684 (format "Do you really want to delete %s forever? "
9685 (if (> (length articles) 1)
9686 (format "these %s articles" (length articles))
9689 ;; Delete the articles.
9690 (setq not-deleted (gnus-request-expire-articles
9691 articles gnus-newsgroup-name 'force))
9693 (gnus-summary-remove-process-mark (car articles))
9694 ;; The backend might not have been able to delete the article
9696 (unless (memq (car articles) not-deleted)
9697 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9698 (let* ((article (car articles))
9699 (ghead (gnus-data-header
9700 (assoc article (gnus-data-list nil)))))
9701 (run-hook-with-args 'gnus-summary-article-delete-hook
9702 'delete ghead gnus-newsgroup-name nil
9704 (setq articles (cdr articles)))
9706 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9707 (gnus-summary-position-point)
9708 (gnus-set-mode-line 'summary)
9711 (defun gnus-summary-edit-article (&optional arg)
9712 "Edit the current article.
9713 This will have permanent effect only in mail groups.
9714 If ARG is nil, edit the decoded articles.
9715 If ARG is 1, edit the raw articles.
9716 If ARG is 2, edit the raw articles even in read-only groups.
9717 If ARG is 3, edit the articles with the current handles.
9718 Otherwise, allow editing of articles even in read-only
9721 (let (force raw current-handles)
9730 (setq current-handles
9731 (and (gnus-buffer-live-p gnus-article-buffer)
9732 (with-current-buffer gnus-article-buffer
9734 gnus-article-mime-handles
9735 (setq gnus-article-mime-handles nil))))))
9738 (when (and raw (not force)
9739 (member gnus-newsgroup-name '("nndraft:delayed"
9742 (error "Can't edit the raw article in group %s"
9743 gnus-newsgroup-name))
9745 (set-buffer gnus-summary-buffer)
9746 (let ((mail-parse-charset gnus-newsgroup-charset)
9747 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9748 (gnus-set-global-variables)
9749 (when (and (not force)
9750 (gnus-group-read-only-p))
9751 (error "The current newsgroup does not support article editing"))
9752 (gnus-summary-show-article t)
9753 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9754 (with-current-buffer gnus-article-buffer
9755 (mm-enable-multibyte)))
9756 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9758 (gnus-article-edit-article
9761 (let ((mbl mml-buffer-list))
9762 (setq mml-buffer-list nil)
9763 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9764 (mime-to-mml ,'current-handles))
9765 (let ((mbl1 mml-buffer-list))
9766 (setq mml-buffer-list mbl)
9767 (set (make-local-variable 'mml-buffer-list) mbl1))
9768 (gnus-make-local-hook 'kill-buffer-hook)
9769 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9770 `(lambda (no-highlight)
9771 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9772 (message-options message-options)
9773 (message-options-set-recipient)
9774 (mail-parse-ignored-charsets
9775 ',gnus-newsgroup-ignored-charsets))
9776 ,(if (not raw) '(progn
9778 (mml-destroy-buffers)
9779 (remove-hook 'kill-buffer-hook
9780 'mml-destroy-buffers t)
9781 (kill-local-variable 'mml-buffer-list)))
9782 (gnus-summary-edit-article-done
9783 ,(or (mail-header-references gnus-current-headers) "")
9784 ,(gnus-group-read-only-p)
9785 ,gnus-summary-buffer no-highlight))))))))
9787 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9789 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9791 "Make edits to the current article permanent."
9794 ;; The buffer restriction contains the entire article if it exists.
9795 (when (article-goto-body)
9796 (let ((lines (count-lines (point) (point-max)))
9797 (length (- (point-max) (point)))
9798 (case-fold-search t)
9799 (body (copy-marker (point))))
9800 (goto-char (point-min))
9801 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9802 (delete-region (match-beginning 1) (match-end 1))
9803 (insert (number-to-string length)))
9804 (goto-char (point-min))
9805 (when (re-search-forward
9806 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9807 (delete-region (match-beginning 1) (match-end 1))
9808 (insert (number-to-string length)))
9809 (goto-char (point-min))
9810 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9811 (delete-region (match-beginning 1) (match-end 1))
9812 (insert (number-to-string lines))))))
9813 ;; Replace the article.
9814 (let ((buf (current-buffer)))
9816 (insert-buffer-substring buf)
9818 (if (and (not read-only)
9819 (not (gnus-request-replace-article
9820 (cdr gnus-article-current) (car gnus-article-current)
9821 (current-buffer) t)))
9822 (error "Couldn't replace article")
9823 ;; Update the summary buffer.
9825 (equal (message-tokenize-header references " ")
9826 (message-tokenize-header
9827 (or (message-fetch-field "references") "") " ")))
9828 ;; We only have to update this line.
9831 (message-narrow-to-head)
9832 (let ((head (buffer-substring-no-properties
9833 (point-min) (point-max)))
9836 (insert (format "211 %d Article retrieved.\n"
9837 (cdr gnus-article-current)))
9840 (let ((nntp-server-buffer (current-buffer)))
9841 (setq header (car (gnus-get-newsgroup-headers
9844 (set-buffer gnus-summary-buffer)
9845 (gnus-data-set-header
9846 (gnus-data-find (cdr gnus-article-current))
9848 (gnus-summary-update-article-line
9849 (cdr gnus-article-current) header)
9850 (if (gnus-summary-goto-subject
9851 (cdr gnus-article-current) nil t)
9852 (gnus-summary-update-secondary-mark
9853 (cdr gnus-article-current))))))))
9855 (set-buffer (or buffer gnus-summary-buffer))
9856 (gnus-summary-update-article (cdr gnus-article-current))
9857 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9858 (gnus-summary-update-secondary-mark
9859 (cdr gnus-article-current))))
9860 ;; Prettify the article buffer again.
9861 (unless no-highlight
9863 (set-buffer gnus-article-buffer)
9864 ;;;!!! Fix this -- article should be rehighlighted.
9865 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9866 (set-buffer gnus-original-article-buffer)
9867 (gnus-request-article
9868 (cdr gnus-article-current)
9869 (car gnus-article-current) (current-buffer))))
9870 ;; Prettify the summary buffer line.
9871 (when (gnus-visual-p 'summary-highlight 'highlight)
9872 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9874 (defun gnus-summary-edit-wash (key)
9875 "Perform editing command KEY in the article buffer."
9879 (message "%s" (concat (this-command-keys) "- "))
9882 (gnus-summary-edit-article)
9883 (execute-kbd-macro (concat (this-command-keys) key))
9884 (gnus-article-edit-done))
9888 (defun gnus-summary-respool-query (&optional silent trace)
9889 "Query where the respool algorithm would put this article."
9891 (let (gnus-mark-article-hook)
9892 (gnus-summary-select-article)
9894 (set-buffer gnus-original-article-buffer)
9895 (let ((groups (nnmail-article-group 'identity trace)))
9898 (message "This message would go to %s"
9899 (mapconcat 'car groups ", "))
9900 (message "This message would go to no groups"))
9903 (defun gnus-summary-respool-trace ()
9904 "Trace where the respool algorithm would put this article.
9905 Display a buffer showing all fancy splitting patterns which matched."
9907 (gnus-summary-respool-query nil t))
9909 ;; Summary marking commands.
9911 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9912 "Mark articles which has the same subject as read, and then select the next.
9913 If UNMARK is positive, remove any kind of mark.
9914 If UNMARK is negative, tick articles."
9917 (setq unmark (prefix-numeric-value unmark)))
9919 (gnus-summary-mark-same-subject
9920 (gnus-summary-article-subject) unmark)))
9921 ;; Select next unread article. If auto-select-same mode, should
9922 ;; select the first unread article.
9923 (gnus-summary-next-article t (and gnus-auto-select-same
9924 (gnus-summary-article-subject)))
9925 (gnus-message 7 "%d article%s marked as %s"
9926 count (if (= count 1) " is" "s are")
9927 (if unmark "unread" "read"))))
9929 (defun gnus-summary-kill-same-subject (&optional unmark)
9930 "Mark articles which has the same subject as read.
9931 If UNMARK is positive, remove any kind of mark.
9932 If UNMARK is negative, tick articles."
9935 (setq unmark (prefix-numeric-value unmark)))
9937 (gnus-summary-mark-same-subject
9938 (gnus-summary-article-subject) unmark)))
9939 ;; If marked as read, go to next unread subject.
9941 ;; Go to next unread subject.
9942 (gnus-summary-next-subject 1 t))
9943 (gnus-message 7 "%d articles are marked as %s"
9944 count (if unmark "unread" "read"))))
9946 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9947 "Mark articles with same SUBJECT as read, and return marked number.
9948 If optional argument UNMARK is positive, remove any kinds of marks.
9949 If optional argument UNMARK is negative, mark articles as unread instead."
9953 ((null unmark) ; Mark as read.
9956 (gnus-summary-mark-article-as-read gnus-killed-mark)
9957 (gnus-summary-show-thread) t)
9958 (gnus-summary-find-subject subject))
9959 (setq count (1+ count))))
9960 ((> unmark 0) ; Tick.
9963 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9964 (gnus-summary-show-thread) t)
9965 (gnus-summary-find-subject subject))
9966 (setq count (1+ count))))
9967 (t ; Mark as unread.
9970 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9971 (gnus-summary-show-thread) t)
9972 (gnus-summary-find-subject subject))
9973 (setq count (1+ count)))))
9974 (gnus-set-mode-line 'summary)
9975 ;; Return the number of marked articles.
9978 (defun gnus-summary-mark-as-processable (n &optional unmark)
9979 "Set the process mark on the next N articles.
9980 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9981 the process mark instead. The difference between N and the actual
9982 number of articles marked is returned."
9984 (if (and (null n) (gnus-region-active-p))
9985 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9986 (setq n (prefix-numeric-value n))
9987 (let ((backward (< n 0))
9992 (gnus-summary-remove-process-mark
9993 (gnus-summary-article-number))
9994 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9995 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9998 (gnus-message 7 "No more articles"))
9999 (gnus-summary-recenter)
10000 (gnus-summary-position-point)
10003 (defun gnus-summary-unmark-as-processable (n)
10004 "Remove the process mark from the next N articles.
10005 If N is negative, unmark backward instead. The difference between N and
10006 the actual number of articles unmarked is returned."
10008 (gnus-summary-mark-as-processable n t))
10010 (defun gnus-summary-unmark-all-processable ()
10011 "Remove the process mark from all articles."
10014 (while gnus-newsgroup-processable
10015 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10016 (gnus-summary-position-point))
10018 (defun gnus-summary-add-mark (article type)
10019 "Mark ARTICLE with a mark of TYPE."
10020 (let ((vtype (car (assq type gnus-article-mark-lists)))
10023 (error "No such mark type: %s" type)
10024 (setq var (intern (format "gnus-newsgroup-%s" type)))
10025 (set var (cons article (symbol-value var)))
10026 (if (memq type '(processable cached replied forwarded recent saved))
10027 (gnus-summary-update-secondary-mark article)
10028 ;;; !!! This is bogus. We should find out what primary
10029 ;;; !!! mark we want to set.
10030 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10032 (defun gnus-summary-mark-as-expirable (n)
10033 "Mark N articles forward as expirable.
10034 If N is negative, mark backward instead. The difference between N and
10035 the actual number of articles marked is returned."
10037 (gnus-summary-mark-forward n gnus-expirable-mark))
10039 (defun gnus-summary-mark-as-spam (n)
10040 "Mark N articles forward as spam.
10041 If N is negative, mark backward instead. The difference between N and
10042 the actual number of articles marked is returned."
10044 (gnus-summary-mark-forward n gnus-spam-mark))
10046 (defun gnus-summary-mark-article-as-replied (article)
10047 "Mark ARTICLE as replied to and update the summary line.
10048 ARTICLE can also be a list of articles."
10049 (interactive (list (gnus-summary-article-number)))
10050 (let ((articles (if (listp article) article (list article))))
10051 (dolist (article articles)
10052 (unless (numberp article)
10053 (error "%s is not a number" article))
10054 (push article gnus-newsgroup-replied)
10055 (let ((buffer-read-only nil))
10056 (when (gnus-summary-goto-subject article nil t)
10057 (gnus-summary-update-secondary-mark article))))))
10059 (defun gnus-summary-mark-article-as-forwarded (article)
10060 "Mark ARTICLE as forwarded and update the summary line.
10061 ARTICLE can also be a list of articles."
10062 (let ((articles (if (listp article) article (list article))))
10063 (dolist (article articles)
10064 (push article gnus-newsgroup-forwarded)
10065 (let ((buffer-read-only nil))
10066 (when (gnus-summary-goto-subject article nil t)
10067 (gnus-summary-update-secondary-mark article))))))
10069 (defun gnus-summary-set-bookmark (article)
10070 "Set a bookmark in current article."
10071 (interactive (list (gnus-summary-article-number)))
10072 (when (or (not (get-buffer gnus-article-buffer))
10073 (not gnus-current-article)
10074 (not gnus-article-current)
10075 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10076 (error "No current article selected"))
10077 ;; Remove old bookmark, if one exists.
10078 (gnus-pull article gnus-newsgroup-bookmarks)
10079 ;; Set the new bookmark, which is on the form
10080 ;; (article-number . line-number-in-body).
10083 (with-current-buffer gnus-article-buffer
10087 (article-goto-body)
10090 gnus-newsgroup-bookmarks)
10091 (gnus-message 6 "A bookmark has been added to the current article."))
10093 (defun gnus-summary-remove-bookmark (article)
10094 "Remove the bookmark from the current article."
10095 (interactive (list (gnus-summary-article-number)))
10096 ;; Remove old bookmark, if one exists.
10097 (if (not (assq article gnus-newsgroup-bookmarks))
10098 (gnus-message 6 "No bookmark in current article.")
10099 (gnus-pull article gnus-newsgroup-bookmarks)
10100 (gnus-message 6 "Removed bookmark.")))
10102 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10103 (defun gnus-summary-mark-as-dormant (n)
10104 "Mark N articles forward as dormant.
10105 If N is negative, mark backward instead. The difference between N and
10106 the actual number of articles marked is returned."
10108 (gnus-summary-mark-forward n gnus-dormant-mark))
10110 (defun gnus-summary-set-process-mark (article)
10111 "Set the process mark on ARTICLE and update the summary line."
10112 (setq gnus-newsgroup-processable
10114 (delq article gnus-newsgroup-processable)))
10115 (when (gnus-summary-goto-subject article)
10116 (gnus-summary-show-thread)
10117 (gnus-summary-goto-subject article)
10118 (gnus-summary-update-secondary-mark article)))
10120 (defun gnus-summary-remove-process-mark (&rest articles)
10121 "Remove the process mark from ARTICLES and update the summary line."
10122 (dolist (article articles)
10123 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10124 (when (gnus-summary-goto-subject article)
10125 (gnus-summary-show-thread)
10126 (gnus-summary-goto-subject article)
10127 (gnus-summary-update-secondary-mark article)))
10130 (defun gnus-summary-set-saved-mark (article)
10131 "Set the process mark on ARTICLE and update the summary line."
10132 (push article gnus-newsgroup-saved)
10133 (when (gnus-summary-goto-subject article)
10134 (gnus-summary-update-secondary-mark article)))
10136 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10137 "Mark N articles as read forwards.
10138 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10139 The difference between N and the actual number of articles marked is
10141 If NO-EXPIRE, auto-expiry will be inhibited."
10143 (gnus-summary-show-thread)
10144 (let ((backward (< n 0))
10145 (gnus-summary-goto-unread
10146 (and gnus-summary-goto-unread
10147 (not (eq gnus-summary-goto-unread 'never))
10148 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10149 gnus-ticked-mark gnus-dormant-mark)))))
10151 (mark (or mark gnus-del-mark)))
10152 (while (and (> n 0)
10153 (gnus-summary-mark-article nil mark no-expire)
10154 (zerop (gnus-summary-next-subject
10156 (and gnus-summary-goto-unread
10157 (not (eq gnus-summary-goto-unread 'never)))
10161 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10162 (gnus-summary-recenter)
10163 (gnus-summary-position-point)
10164 (gnus-set-mode-line 'summary)
10167 (defun gnus-summary-mark-article-as-read (mark)
10168 "Mark the current article quickly as read with MARK."
10169 (let ((article (gnus-summary-article-number)))
10170 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10171 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10172 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10173 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10174 (push (cons article mark) gnus-newsgroup-reads)
10175 ;; Possibly remove from cache, if that is used.
10176 (when gnus-use-cache
10177 (gnus-cache-enter-remove-article article))
10178 ;; Allow the backend to change the mark.
10179 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10180 ;; Check for auto-expiry.
10181 (when (and gnus-newsgroup-auto-expire
10182 (memq mark gnus-auto-expirable-marks))
10183 (setq mark gnus-expirable-mark)
10184 ;; Let the backend know about the mark change.
10185 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10186 (push article gnus-newsgroup-expirable))
10187 ;; Set the mark in the buffer.
10188 (gnus-summary-update-mark mark 'unread)
10191 (defun gnus-summary-mark-article-as-unread (mark)
10192 "Mark the current article quickly as unread with MARK."
10193 (let* ((article (gnus-summary-article-number))
10194 (old-mark (gnus-summary-article-mark article)))
10195 ;; Allow the backend to change the mark.
10196 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10197 (if (eq mark old-mark)
10201 (gnus-error 1 "Can't mark negative article numbers")
10203 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10204 (setq gnus-newsgroup-spam-marked
10205 (delq article gnus-newsgroup-spam-marked))
10206 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10207 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10208 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10209 (cond ((= mark gnus-ticked-mark)
10210 (setq gnus-newsgroup-marked
10211 (gnus-add-to-sorted-list gnus-newsgroup-marked
10213 ((= mark gnus-spam-mark)
10214 (setq gnus-newsgroup-spam-marked
10215 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10217 ((= mark gnus-dormant-mark)
10218 (setq gnus-newsgroup-dormant
10219 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10222 (setq gnus-newsgroup-unreads
10223 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10225 (gnus-pull article gnus-newsgroup-reads)
10227 ;; See whether the article is to be put in the cache.
10228 (and gnus-use-cache
10229 (vectorp (gnus-summary-article-header article))
10231 (gnus-cache-possibly-enter-article
10232 gnus-newsgroup-name article
10233 (= mark gnus-ticked-mark)
10234 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10237 (gnus-summary-update-mark mark 'unread)
10240 (defun gnus-summary-mark-article (&optional article mark no-expire)
10241 "Mark ARTICLE with MARK. MARK can be any character.
10242 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10243 `??' (dormant) and `?E' (expirable).
10244 If MARK is nil, then the default character `?r' is used.
10245 If ARTICLE is nil, then the article on the current line will be
10247 If NO-EXPIRE, auto-expiry will be inhibited."
10248 ;; The mark might be a string.
10249 (when (stringp mark)
10250 (setq mark (aref mark 0)))
10251 ;; If no mark is given, then we check auto-expiring.
10253 (setq mark gnus-del-mark))
10254 (when (and (not no-expire)
10255 gnus-newsgroup-auto-expire
10256 (memq mark gnus-auto-expirable-marks))
10257 (setq mark gnus-expirable-mark))
10258 (let ((article (or article (gnus-summary-article-number)))
10259 (old-mark (gnus-summary-article-mark article)))
10260 ;; Allow the backend to change the mark.
10261 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10262 (if (eq mark old-mark)
10265 (error "No article on current line"))
10266 (if (not (if (or (= mark gnus-unread-mark)
10267 (= mark gnus-ticked-mark)
10268 (= mark gnus-spam-mark)
10269 (= mark gnus-dormant-mark))
10270 (gnus-mark-article-as-unread article mark)
10271 (gnus-mark-article-as-read article mark)))
10273 ;; See whether the article is to be put in the cache.
10274 (and gnus-use-cache
10275 (not (= mark gnus-canceled-mark))
10276 (vectorp (gnus-summary-article-header article))
10278 (gnus-cache-possibly-enter-article
10279 gnus-newsgroup-name article
10280 (= mark gnus-ticked-mark)
10281 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10283 (when (gnus-summary-goto-subject article nil t)
10284 (let ((buffer-read-only nil))
10285 (gnus-summary-show-thread)
10287 (gnus-summary-update-mark mark 'unread)
10290 (defun gnus-summary-update-secondary-mark (article)
10291 "Update the secondary (read, process, cache) mark."
10292 (gnus-summary-update-mark
10293 (cond ((memq article gnus-newsgroup-processable)
10295 ((memq article gnus-newsgroup-cached)
10297 ((memq article gnus-newsgroup-replied)
10299 ((memq article gnus-newsgroup-forwarded)
10300 gnus-forwarded-mark)
10301 ((memq article gnus-newsgroup-saved)
10303 ((memq article gnus-newsgroup-recent)
10305 ((memq article gnus-newsgroup-unseen)
10309 (when (gnus-visual-p 'summary-highlight 'highlight)
10310 (gnus-run-hooks 'gnus-summary-update-hook))
10313 (defun gnus-summary-update-download-mark (article)
10314 "Update the download mark."
10315 (gnus-summary-update-mark
10316 (cond ((memq article gnus-newsgroup-undownloaded)
10317 gnus-undownloaded-mark)
10318 (gnus-newsgroup-agentized
10319 gnus-downloaded-mark)
10323 (gnus-summary-update-line t)
10326 (defun gnus-summary-update-mark (mark type)
10327 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10328 (buffer-read-only nil))
10329 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10331 (when (looking-at "\r")
10333 (when (<= (+ forward (point)) (point-max))
10334 ;; Go to the right position on the line.
10335 (goto-char (+ forward (point)))
10336 ;; Replace the old mark with the new mark.
10337 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10338 ;; Optionally update the marks by some user rule.
10339 (when (eq type 'unread)
10340 (gnus-data-set-mark
10341 (gnus-data-find (gnus-summary-article-number)) mark)
10342 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10344 (defun gnus-mark-article-as-read (article &optional mark)
10345 "Enter ARTICLE in the pertinent lists and remove it from others."
10346 ;; Make the article expirable.
10347 (let ((mark (or mark gnus-del-mark)))
10348 (setq gnus-newsgroup-expirable
10349 (if (= mark gnus-expirable-mark)
10350 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10351 (delq article gnus-newsgroup-expirable)))
10352 ;; Remove from unread and marked lists.
10353 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10354 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10355 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10356 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10357 (push (cons article mark) gnus-newsgroup-reads)
10358 ;; Possibly remove from cache, if that is used.
10359 (when gnus-use-cache
10360 (gnus-cache-enter-remove-article article))
10363 (defun gnus-mark-article-as-unread (article &optional mark)
10364 "Enter ARTICLE in the pertinent lists and remove it from others."
10365 (let ((mark (or mark gnus-ticked-mark)))
10368 (gnus-error 1 "Can't mark negative article numbers")
10370 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10371 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10372 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10373 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10374 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10376 ;; Unsuppress duplicates?
10377 (when gnus-suppress-duplicates
10378 (gnus-dup-unsuppress-article article))
10380 (cond ((= mark gnus-ticked-mark)
10381 (setq gnus-newsgroup-marked
10382 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10383 ((= mark gnus-spam-mark)
10384 (setq gnus-newsgroup-spam-marked
10385 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10387 ((= mark gnus-dormant-mark)
10388 (setq gnus-newsgroup-dormant
10389 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10391 (setq gnus-newsgroup-unreads
10392 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10393 (gnus-pull article gnus-newsgroup-reads)
10396 (defalias 'gnus-summary-mark-as-unread-forward
10397 'gnus-summary-tick-article-forward)
10398 (make-obsolete 'gnus-summary-mark-as-unread-forward
10399 'gnus-summary-tick-article-forward)
10400 (defun gnus-summary-tick-article-forward (n)
10401 "Tick N articles forwards.
10402 If N is negative, tick backwards instead.
10403 The difference between N and the number of articles ticked is returned."
10405 (gnus-summary-mark-forward n gnus-ticked-mark))
10407 (defalias 'gnus-summary-mark-as-unread-backward
10408 'gnus-summary-tick-article-backward)
10409 (make-obsolete 'gnus-summary-mark-as-unread-backward
10410 'gnus-summary-tick-article-backward)
10411 (defun gnus-summary-tick-article-backward (n)
10412 "Tick N articles backwards.
10413 The difference between N and the number of articles ticked is returned."
10415 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10417 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10418 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10419 (defun gnus-summary-tick-article (&optional article clear-mark)
10420 "Mark current article as unread.
10421 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10422 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10424 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10425 gnus-ticked-mark)))
10427 (defun gnus-summary-mark-as-read-forward (n)
10428 "Mark N articles as read forwards.
10429 If N is negative, mark backwards instead.
10430 The difference between N and the actual number of articles marked is
10433 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10435 (defun gnus-summary-mark-as-read-backward (n)
10436 "Mark the N articles as read backwards.
10437 The difference between N and the actual number of articles marked is
10440 (gnus-summary-mark-forward
10441 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10443 (defun gnus-summary-mark-as-read (&optional article mark)
10444 "Mark current article as read.
10445 ARTICLE specifies the article to be marked as read.
10446 MARK specifies a string to be inserted at the beginning of the line."
10447 (gnus-summary-mark-article article mark))
10449 (defun gnus-summary-clear-mark-forward (n)
10450 "Clear marks from N articles forward.
10451 If N is negative, clear backward instead.
10452 The difference between N and the number of marks cleared is returned."
10454 (gnus-summary-mark-forward n gnus-unread-mark))
10456 (defun gnus-summary-clear-mark-backward (n)
10457 "Clear marks from N articles backward.
10458 The difference between N and the number of marks cleared is returned."
10460 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10462 (defun gnus-summary-mark-unread-as-read ()
10463 "Intended to be used by `gnus-summary-mark-article-hook'."
10464 (when (memq gnus-current-article gnus-newsgroup-unreads)
10465 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10467 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10468 "Intended to be used by `gnus-summary-mark-article-hook'."
10469 (let ((mark (gnus-summary-article-mark)))
10470 (when (or (gnus-unread-mark-p mark)
10471 (gnus-read-mark-p mark))
10472 (gnus-summary-mark-article gnus-current-article
10473 (or new-mark gnus-read-mark)))))
10475 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10476 "Intended to be used by `gnus-summary-mark-article-hook'."
10477 (let ((mark (gnus-summary-article-mark)))
10478 (when (or (gnus-unread-mark-p mark)
10479 (gnus-read-mark-p mark))
10480 (gnus-summary-mark-article (gnus-summary-article-number)
10481 (or new-mark gnus-read-mark)))))
10483 (defun gnus-summary-mark-unread-as-ticked ()
10484 "Intended to be used by `gnus-summary-mark-article-hook'."
10485 (when (memq gnus-current-article gnus-newsgroup-unreads)
10486 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10488 (defun gnus-summary-mark-region-as-read (point mark all)
10489 "Mark all unread articles between point and mark as read.
10490 If given a prefix, mark all articles between point and mark as read,
10491 even ticked and dormant ones."
10492 (interactive "r\nP")
10496 (beginning-of-line)
10501 (memq (setq article (gnus-summary-article-number))
10502 gnus-newsgroup-unreads))
10503 (gnus-summary-mark-article article gnus-del-mark))
10505 (gnus-summary-find-next))))))
10507 (defun gnus-summary-mark-below (score mark)
10508 "Mark articles with score less than SCORE with MARK."
10509 (interactive "P\ncMark: ")
10510 (setq score (if score
10511 (prefix-numeric-value score)
10512 (or gnus-summary-default-score 0)))
10514 (set-buffer gnus-summary-buffer)
10515 (goto-char (point-min))
10518 (and (< (gnus-summary-article-score) score)
10519 (gnus-summary-mark-article nil mark))
10520 (gnus-summary-find-next)))))
10522 (defun gnus-summary-kill-below (&optional score)
10523 "Mark articles with score below SCORE as read."
10525 (gnus-summary-mark-below score gnus-killed-mark))
10527 (defun gnus-summary-clear-above (&optional score)
10528 "Clear all marks from articles with score above SCORE."
10530 (gnus-summary-mark-above score gnus-unread-mark))
10532 (defun gnus-summary-tick-above (&optional score)
10533 "Tick all articles with score above SCORE."
10535 (gnus-summary-mark-above score gnus-ticked-mark))
10537 (defun gnus-summary-mark-above (score mark)
10538 "Mark articles with score over SCORE with MARK."
10539 (interactive "P\ncMark: ")
10540 (setq score (if score
10541 (prefix-numeric-value score)
10542 (or gnus-summary-default-score 0)))
10544 (set-buffer gnus-summary-buffer)
10545 (goto-char (point-min))
10547 (when (> (gnus-summary-article-score) score)
10548 (gnus-summary-mark-article nil mark))
10550 (gnus-summary-find-next)))))
10552 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10553 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10554 (defun gnus-summary-limit-include-expunged (&optional no-error)
10555 "Display all the hidden articles that were expunged for low scores."
10557 (let ((buffer-read-only nil))
10558 (let ((scored gnus-newsgroup-scored)
10561 (unless (gnus-summary-article-header (caar scored))
10562 (and (setq h (gnus-number-to-header (caar scored)))
10563 (< (cdar scored) gnus-summary-expunge-below)
10565 (setq scored (cdr scored)))
10567 (when (not no-error)
10568 (error "No expunged articles hidden"))
10569 (goto-char (point-min))
10570 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10571 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10572 (mapcar (lambda (x) (push (mail-header-number x)
10573 gnus-newsgroup-limit))
10575 (gnus-summary-prepare-unthreaded (nreverse headers))
10576 (goto-char (point-min))
10577 (gnus-summary-position-point)
10580 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10581 "Mark all unread articles in this newsgroup as read.
10582 If prefix argument ALL is non-nil, ticked and dormant articles will
10583 also be marked as read.
10584 If QUIETLY is non-nil, no questions will be asked.
10586 If TO-HERE is non-nil, it should be a point in the buffer. All
10587 articles before (after, if REVERSE is set) this point will be marked
10590 Note that this function will only catch up the unread article
10591 in the current summary buffer limitation.
10593 The number of articles marked as read is returned."
10598 (not gnus-interactive-catchup) ;Without confirmation?
10602 "Mark absolutely all articles as read? "
10603 "Mark all unread articles as read? ")))
10605 (not gnus-newsgroup-adaptive)
10606 (not gnus-newsgroup-auto-expire)
10607 (not gnus-suppress-duplicates)
10608 (or (not gnus-use-cache)
10609 (eq gnus-use-cache 'passive)))
10612 (setq gnus-newsgroup-marked nil
10613 gnus-newsgroup-spam-marked nil
10614 gnus-newsgroup-dormant nil))
10615 (setq gnus-newsgroup-unreads
10616 (gnus-sorted-nunion
10617 (gnus-intersection gnus-newsgroup-unreads
10618 gnus-newsgroup-downloadable)
10619 gnus-newsgroup-unfetched)))
10620 ;; We actually mark all articles as canceled, which we
10621 ;; have to do when using auto-expiry or adaptive scoring.
10622 (gnus-summary-show-all-threads)
10623 (if (and to-here reverse)
10625 (goto-char to-here)
10626 (gnus-summary-mark-current-read-and-unread-as-read
10628 (while (gnus-summary-find-next (not all))
10629 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10630 (when (gnus-summary-first-subject (not all))
10632 (if to-here (< (point) to-here) t)
10633 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10634 (gnus-summary-find-next (not all))))))
10635 (gnus-set-mode-line 'summary))
10637 (gnus-summary-position-point)))
10639 (defun gnus-summary-catchup-to-here (&optional all)
10640 "Mark all unticked articles before the current one as read.
10641 If ALL is non-nil, also mark ticked and dormant articles as read."
10644 (gnus-save-hidden-threads
10645 (let ((beg (point)))
10646 ;; We check that there are unread articles.
10647 (when (or all (gnus-summary-find-prev))
10648 (gnus-summary-catchup all t beg)))))
10649 (gnus-summary-position-point))
10651 (defun gnus-summary-catchup-from-here (&optional all)
10652 "Mark all unticked articles after (and including) the current one as read.
10653 If ALL is non-nil, also mark ticked and dormant articles as read."
10656 (gnus-save-hidden-threads
10657 (let ((beg (point)))
10658 ;; We check that there are unread articles.
10659 (when (or all (gnus-summary-find-next))
10660 (gnus-summary-catchup all t beg nil t)))))
10661 (gnus-summary-position-point))
10663 (defun gnus-summary-catchup-all (&optional quietly)
10664 "Mark all articles in this newsgroup as read.
10665 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10666 instead, which marks only unread articles as read."
10668 (gnus-summary-catchup t quietly))
10670 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10671 "Mark all unread articles in this group as read, then exit.
10672 If prefix argument ALL is non-nil, all articles are marked as read.
10673 If QUIETLY is non-nil, no questions will be asked."
10675 (when (gnus-summary-catchup all quietly nil 'fast)
10676 ;; Select next newsgroup or exit.
10677 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10678 (eq gnus-auto-select-next 'quietly))
10679 (gnus-summary-next-group nil)
10680 (gnus-summary-exit))))
10682 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10683 "Mark all articles in this newsgroup as read, and then exit.
10684 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10685 instead, which marks only unread articles as read."
10687 (gnus-summary-catchup-and-exit t quietly))
10689 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10690 "Mark all articles in this group as read and select the next group.
10691 If given a prefix, mark all articles, unread as well as ticked, as
10695 (gnus-summary-catchup all))
10696 (gnus-summary-next-group))
10698 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
10699 "Mark all articles in this group as read and select the previous group.
10700 If given a prefix, mark all articles, unread as well as ticked, as
10704 (gnus-summary-catchup all))
10705 (gnus-summary-next-group nil nil t))
10711 (defmacro gnus-with-article (article &rest forms)
10712 "Select ARTICLE and perform FORMS in the original article buffer.
10713 Then replace the article with the result."
10715 ;; We don't want the article to be marked as read.
10716 (let (gnus-mark-article-hook)
10717 (gnus-summary-select-article t t nil ,article))
10718 (set-buffer gnus-original-article-buffer)
10720 (if (not (gnus-check-backend-function
10721 'request-replace-article (car gnus-article-current)))
10722 (gnus-message 5 "Read-only group; not replacing")
10723 (unless (gnus-request-replace-article
10724 ,article (car gnus-article-current)
10725 (current-buffer) t)
10726 (error "Couldn't replace article")))
10727 ;; The cache and backlog have to be flushed somewhat.
10728 (when gnus-keep-backlog
10729 (gnus-backlog-remove-article
10730 (car gnus-article-current) (cdr gnus-article-current)))
10731 (when gnus-use-cache
10732 (gnus-cache-update-article
10733 (car gnus-article-current) (cdr gnus-article-current)))))
10735 (put 'gnus-with-article 'lisp-indent-function 1)
10736 (put 'gnus-with-article 'edebug-form-spec '(form body))
10738 ;; Thread-based commands.
10740 (defun gnus-summary-articles-in-thread (&optional article)
10741 "Return a list of all articles in the current thread.
10742 If ARTICLE is non-nil, return all articles in the thread that starts
10743 with that article."
10744 (let* ((article (or article (gnus-summary-article-number)))
10745 (data (gnus-data-find-list article))
10746 (top-level (gnus-data-level (car data)))
10748 (cond ((null gnus-thread-operation-ignore-subject)
10749 (gnus-simplify-subject-re
10750 (mail-header-subject (gnus-data-header (car data)))))
10751 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10752 (gnus-simplify-subject-fuzzy
10753 (mail-header-subject (gnus-data-header (car data)))))
10755 (end-point (save-excursion
10756 (if (gnus-summary-go-to-next-thread)
10757 (point) (point-max))))
10760 (< (gnus-data-pos (car data)) end-point))
10761 (when (or (not top-subject)
10762 (string= top-subject
10763 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10764 (gnus-simplify-subject-fuzzy
10765 (mail-header-subject
10766 (gnus-data-header (car data))))
10767 (gnus-simplify-subject-re
10768 (mail-header-subject
10769 (gnus-data-header (car data)))))))
10770 (push (gnus-data-number (car data)) articles))
10771 (unless (and (setq data (cdr data))
10772 (> (gnus-data-level (car data)) top-level))
10774 ;; Return the list of articles.
10775 (nreverse articles)))
10777 (defun gnus-summary-rethread-current ()
10778 "Rethread the thread the current article is part of."
10780 (let* ((gnus-show-threads t)
10781 (article (gnus-summary-article-number))
10782 (id (mail-header-id (gnus-summary-article-header)))
10783 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10785 (error "No article on the current line"))
10786 (gnus-rebuild-thread id)
10787 (gnus-summary-goto-subject article)))
10789 (defun gnus-summary-reparent-thread ()
10790 "Make the current article child of the marked (or previous) article.
10792 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10793 is non-nil or the Subject: of both articles are the same."
10795 (unless (not (gnus-group-read-only-p))
10796 (error "The current newsgroup does not support article editing"))
10797 (unless (<= (length gnus-newsgroup-processable) 1)
10798 (error "No more than one article may be marked"))
10799 (save-window-excursion
10800 (let ((gnus-article-buffer " *reparent*")
10801 (current-article (gnus-summary-article-number))
10802 ;; First grab the marked article, otherwise one line up.
10803 (parent-article (if (not (null gnus-newsgroup-processable))
10804 (car gnus-newsgroup-processable)
10806 (if (eq (forward-line -1) 0)
10807 (gnus-summary-article-number)
10808 (error "Beginning of summary buffer"))))))
10809 (unless (not (eq current-article parent-article))
10810 (error "An article may not be self-referential"))
10811 (let ((message-id (mail-header-id
10812 (gnus-summary-article-header parent-article))))
10813 (unless (and message-id (not (equal message-id "")))
10814 (error "No message-id in desired parent"))
10815 (gnus-with-article current-article
10817 (goto-char (point-min))
10818 (message-narrow-to-head)
10819 (if (re-search-forward "^References: " nil t)
10821 (re-search-forward "^[^ \t]" nil t)
10824 (insert " " message-id))
10825 (insert "References: " message-id "\n"))))
10826 (set-buffer gnus-summary-buffer)
10827 (gnus-summary-unmark-all-processable)
10828 (gnus-summary-update-article current-article)
10829 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10830 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10831 (gnus-summary-rethread-current)
10832 (gnus-message 3 "Article %d is now the child of article %d"
10833 current-article parent-article)))))
10835 (defun gnus-summary-toggle-threads (&optional arg)
10836 "Toggle showing conversation threads.
10837 If ARG is positive number, turn showing conversation threads on."
10839 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10840 (setq gnus-show-threads
10841 (if (null arg) (not gnus-show-threads)
10842 (> (prefix-numeric-value arg) 0)))
10843 (gnus-summary-prepare)
10844 (gnus-summary-goto-subject current)
10845 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10846 (gnus-summary-position-point)))
10848 (defun gnus-summary-show-all-threads ()
10849 "Show all threads."
10852 (let ((buffer-read-only nil))
10853 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10854 (gnus-summary-position-point))
10856 (defun gnus-summary-show-thread ()
10857 "Show thread subtrees.
10858 Returns nil if no thread was there to be shown."
10860 (let ((buffer-read-only nil)
10862 (end (point-at-eol))
10863 ;; Leave point at bol
10864 (beg (progn (beginning-of-line) (point))))
10866 ;; Any hidden lines here?
10867 (search-forward "\r" end t)
10868 (subst-char-in-region beg end ?\^M ?\n t)
10870 (gnus-summary-position-point))))
10872 (defun gnus-summary-maybe-hide-threads ()
10873 "If requested, hide the threads that should be hidden."
10874 (when (and gnus-show-threads
10875 gnus-thread-hide-subtree)
10876 (gnus-summary-hide-all-threads
10877 (if (or (consp gnus-thread-hide-subtree)
10878 (functionp gnus-thread-hide-subtree))
10879 (gnus-make-predicate gnus-thread-hide-subtree)
10882 ;;; Hiding predicates.
10884 (defun gnus-article-unread-p (header)
10885 (memq (mail-header-number header) gnus-newsgroup-unreads))
10887 (defun gnus-article-unseen-p (header)
10888 (memq (mail-header-number header) gnus-newsgroup-unseen))
10890 (defun gnus-map-articles (predicate articles)
10891 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10892 (apply 'gnus-or (mapcar predicate
10893 (mapcar 'gnus-summary-article-header articles))))
10895 (defun gnus-summary-hide-all-threads (&optional predicate)
10896 "Hide all thread subtrees.
10897 If PREDICATE is supplied, threads that satisfy this predicate
10898 will not be hidden."
10901 (goto-char (point-min))
10904 (when (or (not predicate)
10906 predicate (gnus-summary-article-children)))
10907 (gnus-summary-hide-thread))
10908 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10909 (gnus-summary-position-point))
10911 (defun gnus-summary-hide-thread ()
10912 "Hide thread subtrees.
10913 If PREDICATE is supplied, threads that satisfy this predicate
10914 will not be hidden.
10915 Returns nil if no threads were there to be hidden."
10917 (let ((buffer-read-only nil)
10919 (article (gnus-summary-article-number)))
10921 ;; Go forward until either the buffer ends or the subthread
10923 (when (and (not (eobp))
10924 (or (zerop (gnus-summary-next-thread 1 t))
10925 (goto-char (point-max))))
10927 (if (and (> (point) start)
10928 (search-backward "\n" start t))
10930 (subst-char-in-region start (point) ?\n ?\^M)
10931 (gnus-summary-goto-subject article))
10935 (defun gnus-summary-go-to-next-thread (&optional previous)
10936 "Go to the same level (or less) next thread.
10937 If PREVIOUS is non-nil, go to previous thread instead.
10938 Return the article number moved to, or nil if moving was impossible."
10939 (let ((level (gnus-summary-thread-level))
10940 (way (if previous -1 1))
10943 (while (and (not (eobp))
10944 (< level (gnus-summary-thread-level)))
10945 (forward-line way))
10952 (gnus-summary-article-number)
10953 (goto-char beg)))))
10955 (defun gnus-summary-next-thread (n &optional silent)
10956 "Go to the same level next N'th thread.
10957 If N is negative, search backward instead.
10958 Returns the difference between N and the number of skips actually
10961 If SILENT, don't output messages."
10963 (let ((backward (< n 0))
10965 (while (and (> n 0)
10966 (gnus-summary-go-to-next-thread backward))
10969 (gnus-summary-position-point))
10970 (when (and (not silent) (/= 0 n))
10971 (gnus-message 7 "No more threads"))
10974 (defun gnus-summary-prev-thread (n)
10975 "Go to the same level previous N'th thread.
10976 Returns the difference between N and the number of skips actually
10979 (gnus-summary-next-thread (- n)))
10981 (defun gnus-summary-go-down-thread ()
10982 "Go down one level in the current thread."
10983 (let ((children (gnus-summary-article-children)))
10985 (gnus-summary-goto-subject (car children)))))
10987 (defun gnus-summary-go-up-thread ()
10988 "Go up one level in the current thread."
10989 (let ((parent (gnus-summary-article-parent)))
10991 (gnus-summary-goto-subject parent))))
10993 (defun gnus-summary-down-thread (n)
10994 "Go down thread N steps.
10995 If N is negative, go up instead.
10996 Returns the difference between N and how many steps down that were
11001 (while (and (> n 0)
11002 (if up (gnus-summary-go-up-thread)
11003 (gnus-summary-go-down-thread)))
11005 (gnus-summary-position-point)
11007 (gnus-message 7 "Can't go further"))
11010 (defun gnus-summary-up-thread (n)
11011 "Go up thread N steps.
11012 If N is negative, go down instead.
11013 Returns the difference between N and how many steps down that were
11016 (gnus-summary-down-thread (- n)))
11018 (defun gnus-summary-top-thread ()
11019 "Go to the top of the thread."
11021 (while (gnus-summary-go-up-thread))
11022 (gnus-summary-article-number))
11024 (defun gnus-summary-kill-thread (&optional unmark)
11025 "Mark articles under current thread as read.
11026 If the prefix argument is positive, remove any kinds of marks.
11027 If the prefix argument is negative, tick articles instead."
11030 (setq unmark (prefix-numeric-value unmark)))
11031 (let ((articles (gnus-summary-articles-in-thread)))
11033 ;; Expand the thread.
11034 (gnus-summary-show-thread)
11035 ;; Mark all the articles.
11037 (gnus-summary-goto-subject (car articles))
11038 (cond ((null unmark)
11039 (gnus-summary-mark-article-as-read gnus-killed-mark))
11041 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11043 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11044 (setq articles (cdr articles))))
11045 ;; Hide killed subtrees.
11047 gnus-thread-hide-killed
11048 (gnus-summary-hide-thread))
11049 ;; If marked as read, go to next unread subject.
11050 (when (null unmark)
11051 ;; Go to next unread subject.
11052 (gnus-summary-next-subject 1 t)))
11053 (gnus-set-mode-line 'summary))
11055 ;; Summary sorting commands
11057 (defun gnus-summary-sort-by-number (&optional reverse)
11058 "Sort the summary buffer by article number.
11059 Argument REVERSE means reverse order."
11061 (gnus-summary-sort 'number reverse))
11063 (defun gnus-summary-sort-by-random (&optional reverse)
11064 "Randomize the order in the summary buffer.
11065 Argument REVERSE means to randomize in reverse order."
11067 (gnus-summary-sort 'random reverse))
11069 (defun gnus-summary-sort-by-author (&optional reverse)
11070 "Sort the summary buffer by author name alphabetically.
11071 If `case-fold-search' is non-nil, case of letters is ignored.
11072 Argument REVERSE means reverse order."
11074 (gnus-summary-sort 'author reverse))
11076 (defun gnus-summary-sort-by-recipient (&optional reverse)
11077 "Sort the summary buffer by recipient name alphabetically.
11078 If `case-fold-search' is non-nil, case of letters is ignored.
11079 Argument REVERSE means reverse order."
11081 (gnus-summary-sort 'recipient reverse))
11083 (defun gnus-summary-sort-by-subject (&optional reverse)
11084 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11085 If `case-fold-search' is non-nil, case of letters is ignored.
11086 Argument REVERSE means reverse order."
11088 (gnus-summary-sort 'subject reverse))
11090 (defun gnus-summary-sort-by-date (&optional reverse)
11091 "Sort the summary buffer by date.
11092 Argument REVERSE means reverse order."
11094 (gnus-summary-sort 'date reverse))
11096 (defun gnus-summary-sort-by-score (&optional reverse)
11097 "Sort the summary buffer by score.
11098 Argument REVERSE means reverse order."
11100 (gnus-summary-sort 'score reverse))
11102 (defun gnus-summary-sort-by-lines (&optional reverse)
11103 "Sort the summary buffer by the number of lines.
11104 Argument REVERSE means reverse order."
11106 (gnus-summary-sort 'lines reverse))
11108 (defun gnus-summary-sort-by-chars (&optional reverse)
11109 "Sort the summary buffer by article length.
11110 Argument REVERSE means reverse order."
11112 (gnus-summary-sort 'chars reverse))
11114 (defun gnus-summary-sort-by-original (&optional reverse)
11115 "Sort the summary buffer using the default sorting method.
11116 Argument REVERSE means reverse order."
11118 (let* ((buffer-read-only)
11119 (gnus-summary-prepare-hook nil))
11120 ;; We do the sorting by regenerating the threads.
11121 (gnus-summary-prepare)
11122 ;; Hide subthreads if needed.
11123 (gnus-summary-maybe-hide-threads)))
11125 (defun gnus-summary-sort (predicate reverse)
11126 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11127 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11128 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11129 (gnus-thread-sort-functions
11134 (gnus-sort-gathered-threads-function
11135 gnus-thread-sort-functions)
11136 (gnus-article-sort-functions
11140 (,article t2 t1))))
11142 (gnus-summary-prepare-hook nil))
11143 ;; We do the sorting by regenerating the threads.
11144 (gnus-summary-prepare)
11145 ;; Hide subthreads if needed.
11146 (gnus-summary-maybe-hide-threads)))
11148 ;; Summary saving commands.
11150 (defun gnus-summary-save-article (&optional n not-saved)
11151 "Save the current article using the default saver function.
11152 If N is a positive number, save the N next articles.
11153 If N is a negative number, save the N previous articles.
11154 If N is nil and any articles have been marked with the process mark,
11155 save those articles instead.
11156 The variable `gnus-default-article-saver' specifies the saver function."
11158 (let* ((articles (gnus-summary-work-articles n))
11159 (save-buffer (save-excursion
11160 (nnheader-set-temp-buffer " *Gnus Save*")))
11161 (num (length articles))
11163 (dolist (article articles)
11164 (setq header (gnus-summary-article-header article))
11165 (if (not (vectorp header))
11166 ;; This is a pseudo-article.
11167 (if (assq 'name header)
11168 (gnus-copy-file (cdr (assq 'name header)))
11169 (gnus-message 1 "Article %d is unsaveable" article))
11170 ;; This is a real article.
11171 (save-window-excursion
11172 (let ((gnus-display-mime-function nil)
11173 (gnus-article-prepare-hook nil))
11174 (gnus-summary-select-article t nil nil article)))
11176 (set-buffer save-buffer)
11178 (insert-buffer-substring gnus-original-article-buffer))
11179 (setq file (gnus-article-save save-buffer file num))
11180 (gnus-summary-remove-process-mark article)
11182 (gnus-summary-set-saved-mark article))))
11183 (gnus-kill-buffer save-buffer)
11184 (gnus-summary-position-point)
11185 (gnus-set-mode-line 'summary)
11188 (defun gnus-summary-pipe-output (&optional arg headers)
11189 "Pipe the current article to a subprocess.
11190 If N is a positive number, pipe the N next articles.
11191 If N is a negative number, pipe the N previous articles.
11192 If N is nil and any articles have been marked with the process mark,
11193 pipe those articles instead.
11194 If HEADERS (the symbolic prefix), include the headers, too."
11195 (interactive (gnus-interactive "P\ny"))
11196 (require 'gnus-art)
11197 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11198 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11199 (gnus-summary-save-article arg t))
11200 (let ((buffer (get-buffer "*Shell Command Output*")))
11202 (not (zerop (buffer-size buffer))))
11203 (gnus-configure-windows 'pipe))))
11205 (defun gnus-summary-save-article-mail (&optional arg)
11206 "Append the current article to an mail file.
11207 If N is a positive number, save the N next articles.
11208 If N is a negative number, save the N previous articles.
11209 If N is nil and any articles have been marked with the process mark,
11210 save those articles instead."
11212 (require 'gnus-art)
11213 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11214 (gnus-summary-save-article arg)))
11216 (defun gnus-summary-save-article-rmail (&optional arg)
11217 "Append the current article to an rmail file.
11218 If N is a positive number, save the N next articles.
11219 If N is a negative number, save the N previous articles.
11220 If N is nil and any articles have been marked with the process mark,
11221 save those articles instead."
11223 (require 'gnus-art)
11224 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11225 (gnus-summary-save-article arg)))
11227 (defun gnus-summary-save-article-file (&optional arg)
11228 "Append the current article to a file.
11229 If N is a positive number, save the N next articles.
11230 If N is a negative number, save the N previous articles.
11231 If N is nil and any articles have been marked with the process mark,
11232 save those articles instead."
11234 (require 'gnus-art)
11235 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11236 (gnus-summary-save-article arg)))
11238 (defun gnus-summary-write-article-file (&optional arg)
11239 "Write the current article to a file, deleting the previous file.
11240 If N is a positive number, save the N next articles.
11241 If N is a negative number, save the N previous articles.
11242 If N is nil and any articles have been marked with the process mark,
11243 save those articles instead."
11245 (require 'gnus-art)
11246 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11247 (gnus-summary-save-article arg)))
11249 (defun gnus-summary-save-article-body-file (&optional arg)
11250 "Append the current article body to a file.
11251 If N is a positive number, save the N next articles.
11252 If N is a negative number, save the N previous articles.
11253 If N is nil and any articles have been marked with the process mark,
11254 save those articles instead."
11256 (require 'gnus-art)
11257 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11258 (gnus-summary-save-article arg)))
11260 (defun gnus-summary-muttprint (&optional arg)
11261 "Print the current article using Muttprint.
11262 If N is a positive number, save the N next articles.
11263 If N is a negative number, save the N previous articles.
11264 If N is nil and any articles have been marked with the process mark,
11265 save those articles instead."
11267 (require 'gnus-art)
11268 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11269 (gnus-summary-save-article arg t)))
11271 (defun gnus-summary-pipe-message (program)
11272 "Pipe the current article through PROGRAM."
11273 (interactive "sProgram: ")
11274 (gnus-summary-select-article)
11275 (let ((mail-header-separator ""))
11276 (gnus-eval-in-buffer-window gnus-article-buffer
11279 (let ((start (window-start))
11281 (message-pipe-buffer-body program)
11282 (set-window-start (get-buffer-window (current-buffer)) start))))))
11284 (defun gnus-get-split-value (methods)
11285 "Return a value based on the split METHODS."
11286 (let (split-name method result match)
11289 (set-buffer gnus-original-article-buffer)
11291 (nnheader-narrow-to-headers)
11292 (while (and methods (not split-name))
11293 (goto-char (point-min))
11294 (setq method (pop methods))
11295 (setq match (car method))
11298 ;; Regular expression.
11300 (re-search-forward match nil t)))
11305 (setq result (funcall match gnus-newsgroup-name))))
11310 (setq result (eval match)))))
11311 (setq split-name (cdr method))
11312 (cond ((stringp result)
11313 (push (expand-file-name
11314 result gnus-article-save-directory)
11317 (setq split-name (append result split-name)))))))))
11318 (nreverse split-name)))
11320 (defun gnus-valid-move-group-p (group)
11321 (and (boundp group)
11322 (symbol-name group)
11323 (symbol-value group)
11324 (gnus-get-function (gnus-find-method-for-group
11325 (symbol-name group)) 'request-accept-article t)))
11327 (defun gnus-read-move-group-name (prompt default articles prefix)
11328 "Read a group name."
11329 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11330 (minibuffer-confirm-incomplete nil) ; XEmacs
11334 (if (> (length articles) 1)
11335 (format "these %d articles" (length articles))
11340 (gnus-completing-read-with-default
11343 'gnus-valid-move-group-p
11345 'gnus-group-history))
11346 ((= 1 (length split-name))
11347 (gnus-completing-read-with-default
11348 (car split-name) prom
11350 'gnus-valid-move-group-p
11352 'gnus-group-history))
11354 (gnus-completing-read-with-default
11356 (mapcar 'list (nreverse split-name))
11358 'gnus-group-history))))
11359 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11361 (if (or (string= to-newsgroup "")
11362 (string= to-newsgroup prefix))
11363 (setq to-newsgroup default))
11364 (unless to-newsgroup
11365 (error "No group name entered"))
11366 (or (gnus-active to-newsgroup)
11367 (gnus-activate-group to-newsgroup nil nil to-method)
11368 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11370 (or (and (gnus-request-create-group to-newsgroup to-method)
11371 (gnus-activate-group
11372 to-newsgroup nil nil to-method)
11373 (gnus-subscribe-group to-newsgroup))
11374 (error "Couldn't create group %s" to-newsgroup)))
11375 (error "No such group: %s" to-newsgroup)))
11378 (defun gnus-summary-save-parts (type dir n &optional reverse)
11379 "Save parts matching TYPE to DIR.
11380 If REVERSE, save parts that do not match TYPE."
11382 (list (read-string "Save parts of type: "
11383 (or (car gnus-summary-save-parts-type-history)
11384 gnus-summary-save-parts-default-mime)
11385 'gnus-summary-save-parts-type-history)
11386 (setq gnus-summary-save-parts-last-directory
11387 (read-file-name "Save to directory: "
11388 gnus-summary-save-parts-last-directory
11390 current-prefix-arg))
11391 (gnus-summary-iterate n
11392 (let ((gnus-display-mime-function nil)
11393 (gnus-inhibit-treatment t))
11394 (gnus-summary-select-article))
11396 (set-buffer gnus-article-buffer)
11397 (let ((handles (or gnus-article-mime-handles
11398 (mm-dissect-buffer nil gnus-article-loose-mime)
11399 (and gnus-article-emulate-mime
11400 (mm-uu-dissect)))))
11402 (gnus-summary-save-parts-1 type dir handles reverse)
11403 (unless gnus-article-mime-handles ;; Don't destroy this case.
11404 (mm-destroy-parts handles)))))))
11406 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11407 (if (stringp (car handle))
11408 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11411 (not (string-match type (mm-handle-media-type handle)))
11412 (string-match type (mm-handle-media-type handle)))
11413 (let ((file (expand-file-name
11415 mm-file-name-rewrite-functions
11416 (file-name-nondirectory
11418 (mail-content-type-get
11419 (mm-handle-disposition handle) 'filename)
11420 (mail-content-type-get
11421 (mm-handle-type handle) 'name)
11422 (concat gnus-newsgroup-name
11423 "." (number-to-string
11424 (cdr gnus-article-current))))))
11426 (unless (file-exists-p file)
11427 (mm-save-part-to-file handle file))))))
11429 ;; Summary extract commands
11431 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11432 (let ((buffer-read-only nil)
11433 (article (gnus-summary-article-number))
11435 (unless (gnus-summary-goto-subject article)
11436 (error "No such article: %d" article))
11437 (gnus-summary-position-point)
11438 ;; If all commands are to be bunched up on one line, we collect
11440 (unless gnus-view-pseudos-separately
11441 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11444 (setq action (cdr (assq 'action (car ps))))
11445 (setq files (list (cdr (assq 'name (car ps)))))
11446 (while (and ps (cdr ps)
11447 (string= (or action "1")
11448 (or (cdr (assq 'action (cadr ps))) "2")))
11449 (push (cdr (assq 'name (cadr ps))) files)
11450 (setcdr ps (cddr ps)))
11452 (when (not (string-match "%s" action))
11455 (when (assq 'execute (car ps))
11456 (setcdr (assq 'execute (car ps))
11457 (funcall (if (string-match "%s" action)
11464 (shell-quote-argument f)))
11466 (setq ps (cdr ps)))))
11467 (if (and gnus-view-pseudos (not not-view))
11469 (when (assq 'execute (car pslist))
11470 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11471 (eq gnus-view-pseudos 'not-confirm)))
11472 (setq pslist (cdr pslist)))
11475 (setq after-article (or (cdr (assq 'article (car pslist)))
11476 (gnus-summary-article-number)))
11477 (gnus-summary-goto-subject after-article)
11480 (insert " " (file-name-nondirectory
11481 (cdr (assq 'name (car pslist))))
11482 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11484 (forward-line -1) ; back to `b'
11485 (gnus-add-text-properties
11486 b (1- e) (list 'gnus-number gnus-reffed-article-number
11487 gnus-mouse-face-prop gnus-mouse-face))
11489 after-article gnus-reffed-article-number
11490 gnus-unread-mark b (car pslist) 0 (- e b))
11491 (setq gnus-newsgroup-unreads
11492 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11493 gnus-reffed-article-number))
11494 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11495 (setq pslist (cdr pslist)))))))
11497 (defun gnus-pseudos< (p1 p2)
11498 (let ((c1 (cdr (assq 'action p1)))
11499 (c2 (cdr (assq 'action p2))))
11500 (and c1 c2 (string< c1 c2))))
11502 (defun gnus-request-pseudo-article (props)
11503 (cond ((assq 'execute props)
11504 (gnus-execute-command (cdr (assq 'execute props)))))
11505 (let ((gnus-current-article (gnus-summary-article-number)))
11506 (gnus-run-hooks 'gnus-mark-article-hook)))
11508 (defun gnus-execute-command (command &optional automatic)
11510 (gnus-article-setup-buffer)
11511 (set-buffer gnus-article-buffer)
11512 (setq buffer-read-only nil)
11513 (let ((command (if automatic command
11514 (read-string "Command: " (cons command 0)))))
11516 (insert "$ " command "\n\n")
11517 (if gnus-view-pseudo-asynchronously
11518 (start-process "gnus-execute" (current-buffer) shell-file-name
11519 shell-command-switch command)
11520 (call-process shell-file-name nil t nil
11521 shell-command-switch command)))))
11523 ;; Summary kill commands.
11525 (defun gnus-summary-edit-global-kill (article)
11526 "Edit the \"global\" kill file."
11527 (interactive (list (gnus-summary-article-number)))
11528 (gnus-group-edit-global-kill article))
11530 (defun gnus-summary-edit-local-kill ()
11531 "Edit a local kill file applied to the current newsgroup."
11533 (setq gnus-current-headers (gnus-summary-article-header))
11534 (gnus-group-edit-local-kill
11535 (gnus-summary-article-number) gnus-newsgroup-name))
11537 ;;; Header reading.
11539 (defun gnus-read-header (id &optional header)
11540 "Read the headers of article ID and enter them into the Gnus system."
11541 (let ((group gnus-newsgroup-name)
11542 (gnus-override-method
11544 gnus-override-method
11545 (and (gnus-news-group-p gnus-newsgroup-name)
11546 (car (gnus-refer-article-methods)))))
11548 ;; First we check to see whether the header in question is already
11551 ;; This is a Message-ID.
11552 (setq header (or header (gnus-id-to-header id)))
11553 ;; This is an article number.
11554 (setq header (or header (gnus-summary-article-header id))))
11556 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11557 ;; We have found the header.
11559 ;; We have to really fetch the header to this article.
11561 (set-buffer nntp-server-buffer)
11562 (when (setq where (gnus-request-head id group))
11563 (nnheader-fold-continuation-lines)
11564 (goto-char (point-max))
11566 (goto-char (point-min))
11570 ((cdr where) (cdr where))
11571 (header (mail-header-number header))
11572 (t gnus-reffed-article-number))
11574 (insert " Article retrieved.\n"))
11575 (if (or (not where)
11576 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11577 () ; Malformed head.
11578 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11579 (when (and (stringp id)
11580 (not (string= (gnus-group-real-name group)
11582 ;; If we fetched by Message-ID and the article came
11583 ;; from a different group, we fudge some bogus article
11584 ;; numbers for this article.
11585 (mail-header-set-number header gnus-reffed-article-number))
11587 (set-buffer gnus-summary-buffer)
11588 (decf gnus-reffed-article-number)
11589 (gnus-remove-header (mail-header-number header))
11590 (push header gnus-newsgroup-headers)
11591 (setq gnus-current-headers header)
11592 (push (mail-header-number header) gnus-newsgroup-limit)))
11595 (defun gnus-remove-header (number)
11596 "Remove header NUMBER from `gnus-newsgroup-headers'."
11597 (if (and gnus-newsgroup-headers
11598 (= number (mail-header-number (car gnus-newsgroup-headers))))
11599 (pop gnus-newsgroup-headers)
11600 (let ((headers gnus-newsgroup-headers))
11601 (while (and (cdr headers)
11602 (not (= number (mail-header-number (cadr headers)))))
11604 (when (cdr headers)
11605 (setcdr headers (cddr headers))))))
11608 ;;; summary highlights
11611 (defun gnus-highlight-selected-summary ()
11612 "Highlight selected article in summary buffer."
11613 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11614 (when gnus-summary-selected-face
11616 (let* ((beg (point-at-bol))
11617 (end (point-at-eol))
11618 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11619 (from (if (get-text-property beg gnus-mouse-face-prop)
11621 (or (next-single-property-change
11622 beg gnus-mouse-face-prop nil end)
11627 (or (next-single-property-change
11628 from gnus-mouse-face-prop nil end)
11630 ;; If no mouse-face prop on line we will have to = from = end,
11631 ;; so we highlight the entire line instead.
11632 (when (= (+ to 2) from)
11635 (if gnus-newsgroup-selected-overlay
11636 ;; Move old overlay.
11638 gnus-newsgroup-selected-overlay from to (current-buffer))
11639 ;; Create new overlay.
11641 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11642 'face gnus-summary-selected-face))))))
11644 (defvar gnus-summary-highlight-line-cached nil)
11645 (defvar gnus-summary-highlight-line-trigger nil)
11647 (defun gnus-summary-highlight-line-0 ()
11648 (if (and (eq gnus-summary-highlight-line-trigger
11649 gnus-summary-highlight)
11650 gnus-summary-highlight-line-cached)
11651 gnus-summary-highlight-line-cached
11652 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11653 gnus-summary-highlight-line-cached
11654 (let* ((cond (list 'cond))
11656 (list gnus-summary-highlight))
11658 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11662 (gnus-byte-compile (list 'lambda nil cond))))))
11664 (defun gnus-summary-highlight-line ()
11665 "Highlight current line according to `gnus-summary-highlight'."
11666 (let* ((beg (point-at-bol))
11667 (article (or (gnus-summary-article-number) gnus-current-article))
11668 (score (or (cdr (assq article
11669 gnus-newsgroup-scored))
11670 gnus-summary-default-score 0))
11671 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11672 (inhibit-read-only t)
11673 (default gnus-summary-default-score)
11674 (default-high gnus-summary-default-high-score)
11675 (default-low gnus-summary-default-low-score)
11676 (uncached (and gnus-summary-use-undownloaded-faces
11677 (memq article gnus-newsgroup-undownloaded)
11678 (not (memq article gnus-newsgroup-cached)))))
11679 (let ((face (funcall (gnus-summary-highlight-line-0))))
11680 (unless (eq face (get-text-property beg 'face))
11681 (gnus-put-text-property-excluding-characters-with-faces
11682 beg (point-at-eol) 'face
11683 (setq face (if (boundp face) (symbol-value face) face)))
11684 (when gnus-summary-highlight-line-function
11685 (funcall gnus-summary-highlight-line-function article face))))))
11687 (defun gnus-update-read-articles (group unread &optional compute)
11688 "Update the list of read articles in GROUP.
11689 UNREAD is a sorted list."
11690 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11691 (info (gnus-get-info group))
11694 (if (or (not info) (not active))
11695 ;; There is no info on this group if it was, in fact,
11696 ;; killed. Gnus stores no information on killed groups, so
11697 ;; there's nothing to be done.
11698 ;; One could store the information somewhere temporarily,
11699 ;; perhaps... Hmmm...
11701 ;; Remove any negative articles numbers.
11702 (while (and unread (< (car unread) 0))
11703 (setq unread (cdr unread)))
11704 ;; Remove any expired article numbers
11705 (while (and unread (< (car unread) (car active)))
11706 (setq unread (cdr unread)))
11707 ;; Compute the ranges of read articles by looking at the list of
11708 ;; unread articles.
11710 (when (/= (car unread) prev)
11711 (push (if (= prev (1- (car unread))) prev
11712 (cons prev (1- (car unread))))
11714 (setq prev (1+ (car unread)))
11715 (setq unread (cdr unread)))
11716 (when (<= prev (cdr active))
11717 (push (cons prev (cdr active)) read))
11718 (setq read (if (> (length read) 1) (nreverse read) read))
11723 ;; Propagate the read marks to the backend.
11724 (when (gnus-check-backend-function 'request-set-mark group)
11725 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11726 (add (gnus-remove-from-range read (gnus-info-read info))))
11728 (unless (gnus-check-group group)
11729 (error "Can't open server for %s" group))
11730 (gnus-request-set-mark
11731 group (delq nil (list (if add (list add 'add '(read)))
11732 (if del (list del 'del '(read))))))
11734 `(gnus-request-set-mark
11737 (if del (list del 'add '(read)))
11738 (if add (list add 'del '(read))))))))))
11739 (set-buffer gnus-group-buffer)
11740 (gnus-undo-register
11742 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11743 (gnus-info-set-read ',info ',(gnus-info-read info))
11744 (gnus-get-unread-articles-in-group ',info
11745 (gnus-active ,group))
11746 (gnus-group-update-group ,group t)
11748 ;; Enter this list into the group info.
11749 (gnus-info-set-read info read)
11750 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11751 (gnus-get-unread-articles-in-group info (gnus-active group))
11754 (defun gnus-offer-save-summaries ()
11755 "Offer to save all active summary buffers."
11757 ;; Go through all buffers and find all summaries.
11758 (dolist (buffer (buffer-list))
11759 (when (and (setq buffer (buffer-name buffer))
11760 (string-match "Summary" buffer)
11761 (with-current-buffer buffer
11762 ;; We check that this is, indeed, a summary buffer.
11763 (and (eq major-mode 'gnus-summary-mode)
11764 ;; Also make sure this isn't bogus.
11765 gnus-newsgroup-prepared
11766 ;; Also make sure that this isn't a
11767 ;; dead summary buffer.
11768 (not gnus-dead-summary-mode))))
11769 (push buffer buffers)))
11770 ;; Go through all these summary buffers and offer to save them.
11774 "Update summary buffer %s? "
11776 (switch-to-buffer buf)
11777 (gnus-summary-exit))
11780 (defun gnus-summary-setup-default-charset ()
11781 "Setup newsgroup default charset."
11782 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11783 (setq gnus-newsgroup-charset nil)
11784 (let* ((ignored-charsets
11785 (or gnus-newsgroup-ephemeral-ignored-charsets
11787 (and gnus-newsgroup-name
11788 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11789 gnus-newsgroup-ignored-charsets))))
11790 (setq gnus-newsgroup-charset
11791 (or gnus-newsgroup-ephemeral-charset
11792 (and gnus-newsgroup-name
11793 (gnus-parameter-charset gnus-newsgroup-name))
11794 gnus-default-charset))
11795 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11796 ignored-charsets))))
11802 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11803 "Display the current article buffer fully MIME-buttonized.
11804 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11805 treated as multipart/mixed."
11807 (require 'gnus-art)
11808 (let ((gnus-unbuttonized-mime-types nil)
11809 (gnus-mime-display-multipart-as-mixed show-all-parts))
11810 (gnus-summary-show-article)))
11812 (defun gnus-summary-repair-multipart (article)
11813 "Add a Content-Type header to a multipart article without one."
11814 (interactive (list (gnus-summary-article-number)))
11815 (gnus-with-article article
11816 (message-narrow-to-head)
11817 (message-remove-header "Mime-Version")
11818 (goto-char (point-max))
11819 (insert "Mime-Version: 1.0\n")
11821 (when (search-forward "\n--" nil t)
11822 (let ((separator (buffer-substring (point) (point-at-eol))))
11823 (message-narrow-to-head)
11824 (message-remove-header "Content-Type")
11825 (goto-char (point-max))
11826 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11829 (let (gnus-mark-article-hook)
11830 (gnus-summary-select-article t t nil article)))
11832 (defun gnus-summary-toggle-display-buttonized ()
11833 "Toggle the buttonizing of the article buffer."
11835 (require 'gnus-art)
11836 (if (setq gnus-inhibit-mime-unbuttonizing
11837 (not gnus-inhibit-mime-unbuttonizing))
11838 (let ((gnus-unbuttonized-mime-types nil))
11839 (gnus-summary-show-article))
11840 (gnus-summary-show-article)))
11843 ;;; Generic summary marking commands
11846 (defvar gnus-summary-marking-alist
11847 '((read gnus-del-mark "d")
11848 (unread gnus-unread-mark "u")
11849 (ticked gnus-ticked-mark "!")
11850 (dormant gnus-dormant-mark "?")
11851 (expirable gnus-expirable-mark "e"))
11852 "An alist of names/marks/keystrokes.")
11854 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11855 (defvar gnus-summary-mark-map)
11857 (defun gnus-summary-make-all-marking-commands ()
11858 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11859 (dolist (elem gnus-summary-marking-alist)
11860 (apply 'gnus-summary-make-marking-command elem)))
11862 (defun gnus-summary-make-marking-command (name mark keystroke)
11863 (let ((map (make-sparse-keymap)))
11864 (define-key gnus-summary-generic-mark-map keystroke map)
11865 (dolist (lway `((next "next" next nil "n")
11866 (next-unread "next unread" next t "N")
11867 (prev "previous" prev nil "p")
11868 (prev-unread "previous unread" prev t "P")
11869 (nomove "" nil nil ,keystroke)))
11870 (let ((func (gnus-summary-make-marking-command-1
11871 mark (car lway) lway name)))
11872 (setq func (eval func))
11873 (define-key map (nth 4 lway) func)))))
11875 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11877 (format "gnus-summary-put-mark-as-%s%s"
11878 name (if (eq way 'nomove)
11880 (concat "-" (symbol-name way)))))
11883 "Mark the current article as %s%s.
11884 If N, the prefix, then repeat N times.
11885 If N is negative, move in reverse order.
11886 The difference between N and the actual number of articles marked is
11890 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11892 (defun gnus-summary-generic-mark (n mark move unread)
11893 "Mark N articles with MARK."
11894 (unless (eq major-mode 'gnus-summary-mode)
11895 (error "This command can only be used in the summary buffer"))
11896 (gnus-summary-show-thread)
11899 ((eq move 'next) 1)
11900 ((eq move 'prev) -1)
11902 (if (zerop nummove)
11906 nummove (* -1 nummove))))
11907 (while (and (> n 0)
11908 (gnus-summary-mark-article nil mark)
11909 (zerop (gnus-summary-next-subject nummove unread t)))
11912 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11913 (gnus-summary-recenter)
11914 (gnus-summary-position-point)
11915 (gnus-set-mode-line 'summary)
11918 (defun gnus-summary-insert-articles (articles)
11919 (when (setq articles
11920 (gnus-sorted-difference articles
11921 (mapcar (lambda (h)
11922 (mail-header-number h))
11923 gnus-newsgroup-headers)))
11924 (setq gnus-newsgroup-headers
11926 gnus-newsgroup-headers
11927 (gnus-fetch-headers articles)
11928 'gnus-article-sort-by-number))
11929 ;; Suppress duplicates?
11930 (when gnus-suppress-duplicates
11931 (gnus-dup-suppress-articles))
11933 ;; We might want to build some more threads first.
11934 (when (and gnus-fetch-old-headers
11935 (eq gnus-headers-retrieved-by 'nov))
11936 (if (eq gnus-fetch-old-headers 'invisible)
11937 (gnus-build-all-threads)
11938 (gnus-build-old-threads)))
11939 ;; Let the Gnus agent mark articles as read.
11941 (gnus-agent-get-undownloaded-list))
11942 ;; Remove list identifiers from subject
11943 (when gnus-list-identifiers
11944 (gnus-summary-remove-list-identifiers))
11945 ;; First and last article in this newsgroup.
11946 (when gnus-newsgroup-headers
11947 (setq gnus-newsgroup-begin
11948 (mail-header-number (car gnus-newsgroup-headers))
11950 (mail-header-number
11951 (gnus-last-element gnus-newsgroup-headers))))
11952 (when gnus-use-scoring
11953 (gnus-possibly-score-headers))))
11955 (defun gnus-summary-insert-old-articles (&optional all)
11956 "Insert all old articles in this group.
11957 If ALL is non-nil, already read articles become readable.
11958 If ALL is a number, fetch this number of articles."
11961 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11964 ;; Some nntp servers lie about their active range. When
11965 ;; this happens, the active range can be in the millions.
11966 ;; Use a compressed range to avoid creating a huge list.
11967 (gnus-range-difference (list gnus-newsgroup-active) old))
11968 (setq len (gnus-range-length older))
11973 (let ((older-range (nreverse older)))
11977 (let* ((r (pop older-range))
11978 (min (if (numberp r) r (car r)))
11979 (max (if (numberp r) r (cdr r))))
11980 (while (and (<= min max)
11985 (setq older (gnus-uncompress-range older))))
11987 (setq older (gnus-uncompress-range older)))
11989 (when (and (numberp gnus-large-newsgroup)
11990 (> len gnus-large-newsgroup))
11991 (let* ((cursor-in-echo-area nil)
11992 (initial (gnus-parameter-large-newsgroup-initial
11993 gnus-newsgroup-name))
11997 "How many articles from %s (%s %d): "
11999 (gnus-group-decoded-name gnus-newsgroup-name) 35)
12000 (if initial "max" "default")
12003 (cons (number-to-string initial)
12005 (unless (string-match "^[ \t]*$" input)
12006 (setq all (string-to-number input))
12008 (let ((older-range (nreverse older)))
12012 (let* ((r (pop older-range))
12013 (min (if (numberp r) r (car r)))
12014 (max (if (numberp r) r (cdr r))))
12015 (while (and (<= min max)
12019 max (1- max))))))))))
12020 (setq older (gnus-uncompress-range older))))
12022 (message "No old news.")
12023 (gnus-summary-insert-articles older)
12024 (gnus-summary-limit (gnus-sorted-nunion old older))))
12025 (gnus-summary-position-point)))
12027 (defun gnus-summary-insert-new-articles ()
12028 "Insert all new articles in this group."
12031 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12032 (old-active gnus-newsgroup-active)
12033 (nnmail-fetched-sources (list t))
12035 (setq gnus-newsgroup-active
12036 (gnus-activate-group gnus-newsgroup-name 'scan))
12037 (setq i (cdr gnus-newsgroup-active))
12038 (while (> i (cdr old-active))
12042 (message "No gnus is bad news")
12043 (gnus-summary-insert-articles new)
12044 (setq gnus-newsgroup-unreads
12045 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12046 (gnus-summary-limit (gnus-sorted-nunion old new))))
12047 (gnus-summary-position-point)))
12049 (gnus-summary-make-all-marking-commands)
12051 (gnus-ems-redefine)
12053 (provide 'gnus-sum)
12055 (run-hooks 'gnus-sum-load-hook)
12057 ;; Local Variables:
12058 ;; coding: iso-8859-1
12061 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
12062 ;;; gnus-sum.el ends here