1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2016 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 (when (featurep 'xemacs
)
31 (require 'easy-mmode
))) ; for `define-minor-mode'
33 (defvar tool-bar-mode
)
34 (defvar gnus-tmp-header
)
47 (autoload 'gnus-summary-limit-include-cached
"gnus-cache" nil t
)
48 (autoload 'gnus-cache-write-active
"gnus-cache")
49 (autoload 'gnus-mailing-list-insinuate
"gnus-ml" nil t
)
50 (autoload 'turn-on-gnus-mailing-list-mode
"gnus-ml" nil t
)
51 (autoload 'gnus-pick-line-number
"gnus-salt" nil t
)
52 (autoload 'mm-uu-dissect
"mm-uu")
53 (autoload 'gnus-article-outlook-deuglify-article
"deuglify"
54 "Deuglify broken Outlook (Express) articles and redisplay."
56 (autoload 'gnus-article-outlook-unwrap-lines
"deuglify" nil t
)
57 (autoload 'gnus-article-outlook-repair-attribution
"deuglify" nil t
)
58 (autoload 'gnus-article-outlook-rearrange-citation
"deuglify" nil t
)
59 (autoload 'nnir-article-rsv
"nnir" nil nil
'macro
)
60 (autoload 'nnir-article-group
"nnir" nil nil
'macro
)
62 (defcustom gnus-kill-summary-on-exit t
63 "*If non-nil, kill the summary buffer when you exit from it.
64 If nil, the summary will become a \"*Dead Summary*\" buffer, and
65 it will be killed sometime later."
66 :group
'gnus-summary-exit
69 (defcustom gnus-summary-next-group-on-exit t
70 "If non-nil, go to the next unread newsgroup on summary exit.
71 See `gnus-group-goto-unread'."
72 :link
'(custom-manual "(gnus)Group Maneuvering")
73 :group
'gnus-summary-exit
74 :version
"23.1" ;; No Gnus
77 (defcustom gnus-summary-stop-at-end-of-message nil
78 "If non-nil, don't select the next message when using `SPC'."
79 :link
'(custom-manual "(gnus)Group Maneuvering")
80 :group
'gnus-summary-maneuvering
84 (defcustom gnus-fetch-old-headers nil
85 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
86 If an unread article in the group refers to an older, already
87 read (or just marked as read) article, the old article will not
88 normally be displayed in the Summary buffer. If this variable is
89 t, Gnus will attempt to grab the headers to the old articles, and
90 thereby build complete threads. If it has the value `some', all
91 old headers will be fetched but only enough headers to connect
92 otherwise loose threads will be displayed. This variable can
93 also be a number. In that case, no more than that number of old
94 headers will be fetched. If it has the value `invisible', all
95 old headers will be fetched, but none will be displayed.
97 The server has to support NOV for any of this to work.
99 This feature can seriously impact performance it ignores all
100 locally cached header entries. Setting it to t for groups for a
101 server that doesn't expire articles (such as news.gmane.org),
102 leads to very slow summary generation."
104 :type
'(choice (const :tag
"off" nil
)
109 (sexp :menu-tag
"other" t
)))
111 (defcustom gnus-refer-thread-limit
500
112 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
113 If t, fetch all the available old headers."
115 :type
'(choice number
116 (sexp :menu-tag
"other" t
)))
118 (defcustom gnus-refer-thread-use-nnir nil
119 "*Use nnir to search an entire server when referring threads. A
120 nil value will only search for thread-related articles in the
126 (defcustom gnus-summary-make-false-root
'adopt
127 "*nil means that Gnus won't gather loose threads.
128 If the root of a thread has expired or been read in a previous
129 session, the information necessary to build a complete thread has been
130 lost. Instead of having many small sub-threads from this original thread
131 scattered all over the summary buffer, Gnus can gather them.
133 If non-nil, Gnus will try to gather all loose sub-threads from an
134 original thread into one large thread.
136 If this variable is non-nil, it should be one of `none', `adopt',
139 If this variable is `none', Gnus will not make a false root, but just
140 present the sub-threads after another.
141 If this variable is `dummy', Gnus will create a dummy root that will
142 have all the sub-threads as children.
143 If this variable is `adopt', Gnus will make one of the \"children\"
144 the parent and mark all the step-children as such.
145 If this variable is `empty', the \"children\" are printed with empty
146 subject fields. (Or rather, they will be printed with a string
147 given by the `gnus-summary-same-subject' variable.)"
149 :type
'(choice (const :tag
"off" nil
)
155 (defcustom gnus-summary-make-false-root-always nil
156 "Always make a false dummy root."
161 (defcustom gnus-summary-gather-exclude-subject
"^ *$\\|^(none)$"
162 "*A regexp to match subjects to be excluded from loose thread gathering.
163 As loose thread gathering is done on subjects only, that means that
164 there can be many false gatherings performed. By rooting out certain
165 common subjects, gathering might become saner."
169 (defcustom gnus-summary-gather-subject-limit nil
170 "*Maximum length of subject comparisons when gathering loose threads.
171 Use nil to compare full subjects. Setting this variable to a low
172 number will help gather threads that have been corrupted by
173 newsreaders chopping off subject lines, but it might also mean that
174 unrelated articles that have subject that happen to begin with the
175 same few characters will be incorrectly gathered.
177 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
180 :type
'(choice (const :tag
"off" nil
)
182 (sexp :menu-tag
"on" t
)))
184 (defcustom gnus-simplify-subject-functions nil
185 "List of functions taking a string argument that simplify subjects.
186 The functions are applied recursively.
188 Useful functions to put in this list include:
189 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
190 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
192 :type
'(repeat function
))
194 (defcustom gnus-simplify-ignored-prefixes nil
195 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
197 :type
'(choice (const :tag
"off" nil
)
200 (defcustom gnus-build-sparse-threads nil
201 "*If non-nil, fill in the gaps in threads.
202 If `some', only fill in the gaps that are needed to tie loose threads
203 together. If `more', fill in all leaf nodes that Gnus can find. If
204 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
206 :type
'(choice (const :tag
"off" nil
)
209 (sexp :menu-tag
"all" t
)))
211 (defcustom gnus-summary-thread-gathering-function
212 'gnus-gather-threads-by-subject
213 "*Function used for gathering loose threads.
214 There are two pre-defined functions: `gnus-gather-threads-by-subject',
215 which only takes Subjects into consideration; and
216 `gnus-gather-threads-by-references', which compared the References
217 headers of the articles to find matches."
219 :type
'(radio (function-item gnus-gather-threads-by-subject
)
220 (function-item gnus-gather-threads-by-references
)
221 (function :tag
"other")))
223 (defcustom gnus-summary-same-subject
""
224 "*String indicating that the current article has the same subject as the previous.
225 This variable will only be used if the value of
226 `gnus-summary-make-false-root' is `empty'."
227 :group
'gnus-summary-format
230 (defcustom gnus-summary-goto-unread nil
231 "*If t, many commands will go to the next unread article.
232 This applies to marking commands as well as other commands that
233 \"naturally\" select the next article, like, for instance, `SPC' at
234 the end of an article.
236 If nil, the marking commands do NOT go to the next unread article
237 \(they go to the next article instead). If `never', commands that
238 usually go to the next unread article, will go to the next article,
239 whether it is read or not."
241 :group
'gnus-summary-marks
242 :link
'(custom-manual "(gnus)Setting Marks")
243 :type
'(choice (const :tag
"off" nil
)
245 (sexp :menu-tag
"on" t
)))
247 (defcustom gnus-summary-default-score
0
248 "*Default article score level.
249 All scores generated by the score files will be added to this score.
250 If this variable is nil, scoring will be disabled."
251 :group
'gnus-score-default
252 :type
'(choice (const :tag
"disable")
255 (defcustom gnus-summary-default-high-score
0
256 "*Default threshold for a high scored article.
257 An article will be highlighted as high scored if its score is greater
260 :group
'gnus-score-default
263 (defcustom gnus-summary-default-low-score
0
264 "*Default threshold for a low scored article.
265 An article will be highlighted as low scored if its score is smaller
268 :group
'gnus-score-default
271 (defcustom gnus-summary-zcore-fuzz
0
272 "*Fuzziness factor for the zcore in the summary buffer.
273 Articles with scores closer than this to `gnus-summary-default-score'
275 :group
'gnus-summary-format
278 (defcustom gnus-simplify-subject-fuzzy-regexp nil
279 "*Strings to be removed when doing fuzzy matches.
280 This can either be a regular expression or list of regular expressions
281 that will be removed from subject strings if fuzzy subject
282 simplification is selected."
284 :type
'(repeat regexp
))
286 (defcustom gnus-show-threads t
287 "*If non-nil, display threads in summary mode."
291 (defcustom gnus-thread-hide-subtree nil
292 "*If non-nil, hide all threads initially.
293 This can be a predicate specifier which says which threads to hide.
294 If threads are hidden, you have to run the command
295 `gnus-summary-show-thread' by hand or select an article."
297 :type
'(radio (sexp :format
"Non-nil\n"
298 :match
(lambda (widget value
)
299 (not (or (consp value
) (functionp value
))))
302 (sexp :tag
"Predicate specifier")))
304 (defcustom gnus-thread-hide-killed t
305 "*If non-nil, hide killed threads automatically."
309 (defcustom gnus-thread-ignore-subject t
310 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
311 If nil, articles that have different subjects from their parents will
312 start separate threads."
316 (defcustom gnus-thread-operation-ignore-subject t
317 "*If non-nil, subjects will be ignored when doing thread commands.
318 This affects commands like `gnus-summary-kill-thread' and
319 `gnus-summary-lower-thread'.
321 If this variable is nil, articles in the same thread with different
322 subjects will not be included in the operation in question. If this
323 variable is `fuzzy', only articles that have subjects that are fuzzily
324 equal will be included."
326 :type
'(choice (const :tag
"off" nil
)
330 (defcustom gnus-thread-indent-level
4
331 "*Number that says how much each sub-thread should be indented."
335 (defcustom gnus-auto-extend-newsgroup t
336 "*If non-nil, extend newsgroup forward and backward when requested."
337 :group
'gnus-summary-choose
340 (defcustom gnus-auto-select-first t
341 "If non-nil, select an article on group entry.
342 An article is selected automatically when entering a group
343 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
344 `gnus-summary-catchup-and-goto-next-group'.
346 Which article is selected is controlled by the variable
347 `gnus-auto-select-subject'.
349 If you want to prevent automatic selection of articles in some
350 newsgroups, set the variable to nil in `gnus-select-group-hook'."
351 ;; Commands include...
352 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
353 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
354 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
355 :group
'gnus-group-select
356 :type
'(choice (const :tag
"none" nil
)
357 (sexp :menu-tag
"first" t
)))
359 (defcustom gnus-auto-select-subject
'unseen-or-unread
360 "*Says what subject to place under point when entering a group.
362 This variable can either be the symbols `first' (place point on the
363 first subject), `unread' (place point on the subject line of the first
364 unread article), `best' (place point on the subject line of the
365 highest-scored article), `unseen' (place point on the subject line of
366 the first unseen article), `unseen-or-unread' (place point on the subject
367 line of the first unseen article or, if all articles have been seen, on the
368 subject line of the first unread article), or a function to be called to
369 place point on some subject line."
371 :group
'gnus-group-select
372 :type
'(choice (const best
)
376 (const unseen-or-unread
)
377 (function :tag
"Function to call")))
379 (defcustom gnus-auto-select-next t
380 "*If non-nil, offer to go to the next group from the end of the previous.
381 If the value is t and the next newsgroup is empty, Gnus will exit
382 summary mode and go back to group mode. If the value is neither nil
383 nor t, Gnus will select the following unread newsgroup. In
384 particular, if the value is the symbol `quietly', the next unread
385 newsgroup will be selected without any confirmation, and if it is
386 `almost-quietly', the next group will be selected without any
387 confirmation if you are located on the last article in the group.
388 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
389 will go to the next group without confirmation."
390 :group
'gnus-summary-maneuvering
391 :type
'(choice (const :tag
"off" nil
)
393 (const almost-quietly
)
394 (const slightly-quietly
)
395 (sexp :menu-tag
"on" t
)))
397 (defcustom gnus-auto-select-same nil
398 "*If non-nil, select the next article with the same subject.
399 If there are no more articles with the same subject, go to
400 the first unread article."
401 :group
'gnus-summary-maneuvering
404 (defcustom gnus-auto-select-on-ephemeral-exit
'next-noselect
405 "What article should be selected after exiting an ephemeral group.
406 Valid values include:
409 Select the next article.
411 Select the next unread article.
413 Move the cursor to the next article. This is the default.
414 `next-unread-noselect'
415 Move the cursor to the next unread article.
417 If it has any other value or there is no next (unread) article, the
418 article selected before entering to the ephemeral group will appear."
419 :version
"23.1" ;; No Gnus
420 :group
'gnus-summary-maneuvering
421 :type
'(choice :format
"%{%t%}:\n %[Value Menu%] %v"
422 (const next
) (const next-unread
)
423 (const next-noselect
) (const next-unread-noselect
)
424 (sexp :tag
"other" :value nil
)))
426 (defcustom gnus-auto-goto-ignores
'unfetched
427 "*Says how to handle unfetched articles when maneuvering.
429 This variable can either be the symbols nil (maneuver to any
430 article), `undownloaded' (maneuvering while unplugged ignores articles
431 that have not been fetched), `always-undownloaded' (maneuvering always
432 ignores articles that have not been fetched), `unfetched' (maneuvering
433 ignores articles whose headers have not been fetched).
435 NOTE: The list of unfetched articles will always be nil when plugged
436 and, when unplugged, a subset of the undownloaded article list."
438 :group
'gnus-summary-maneuvering
439 :type
'(choice (const :tag
"None" nil
)
440 (const :tag
"Undownloaded when unplugged" undownloaded
)
441 (const :tag
"Undownloaded" always-undownloaded
)
442 (const :tag
"Unfetched" unfetched
)))
444 (defcustom gnus-summary-check-current nil
445 "*If non-nil, consider the current article when moving.
446 The \"unread\" movement commands will stay on the same line if the
447 current article is unread."
448 :group
'gnus-summary-maneuvering
451 (defcustom gnus-auto-center-summary
452 (max (or (bound-and-true-p scroll-margin
) 0) 2)
453 "*If non-nil, always center the current summary buffer.
454 In particular, if `vertical' do only vertical recentering. If non-nil
455 and non-`vertical', do both horizontal and vertical recentering."
456 :group
'gnus-summary-maneuvering
457 :type
'(choice (const :tag
"none" nil
)
459 (integer :tag
"height")
460 (sexp :menu-tag
"both" t
)))
462 (defcustom gnus-auto-center-group t
463 "If non-nil, always center the group buffer."
464 :group
'gnus-summary-maneuvering
467 (defcustom gnus-show-all-headers nil
468 "*If non-nil, don't hide any headers."
469 :group
'gnus-article-hiding
470 :group
'gnus-article-headers
473 (defcustom gnus-summary-ignore-duplicates nil
474 "*If non-nil, ignore articles with identical Message-ID headers."
478 (defcustom gnus-single-article-buffer nil
479 "*If non-nil, display all articles in the same buffer.
480 If nil, each group will get its own article buffer."
482 :group
'gnus-article-various
485 (defcustom gnus-widen-article-window nil
486 "If non-nil, selecting the article buffer will display only the article buffer."
488 :group
'gnus-article-various
491 (defcustom gnus-break-pages t
492 "*If non-nil, do page breaking on articles.
493 The page delimiter is specified by the `gnus-page-delimiter'
495 :group
'gnus-article-various
498 (defcustom gnus-move-split-methods nil
499 "*Variable used to suggest where articles are to be moved to.
500 It uses the same syntax as the `gnus-split-methods' variable.
501 However, whereas `gnus-split-methods' specifies file names as targets,
502 this variable specifies group names."
503 :group
'gnus-summary-mail
504 :type
'(repeat (choice (list :value
(fun) function
)
505 (cons :value
("" "") regexp
(repeat string
))
508 (defcustom gnus-move-group-prefix-function
'gnus-group-real-prefix
509 "Function used to compute default prefix for article move/copy/etc prompts.
510 The function should take one argument, a group name, and return a
511 string with the suggested prefix."
512 :group
'gnus-summary-mail
515 ;; FIXME: Although the custom type is `character' for the following variables,
516 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
518 (defcustom gnus-unread-mark ?
;Whitespace
519 "*Mark used for unread articles."
520 :group
'gnus-summary-marks
523 (defcustom gnus-ticked-mark ?
!
524 "*Mark used for ticked articles."
525 :group
'gnus-summary-marks
528 (defcustom gnus-dormant-mark ??
529 "*Mark used for dormant articles."
530 :group
'gnus-summary-marks
533 (defcustom gnus-del-mark ?r
534 "*Mark used for del'd articles."
535 :group
'gnus-summary-marks
538 (defcustom gnus-read-mark ?R
539 "*Mark used for read articles."
540 :group
'gnus-summary-marks
543 (defcustom gnus-expirable-mark ?E
544 "*Mark used for expirable articles."
545 :group
'gnus-summary-marks
548 (defcustom gnus-killed-mark ?K
549 "*Mark used for killed articles."
550 :group
'gnus-summary-marks
553 (defcustom gnus-spam-mark ?$
554 "*Mark used for spam articles."
556 :group
'gnus-summary-marks
559 (defcustom gnus-kill-file-mark ?X
560 "*Mark used for articles killed by kill files."
561 :group
'gnus-summary-marks
564 (defcustom gnus-low-score-mark ?Y
565 "*Mark used for articles with a low score."
566 :group
'gnus-summary-marks
569 (defcustom gnus-catchup-mark ?C
570 "*Mark used for articles that are caught up."
571 :group
'gnus-summary-marks
574 (defcustom gnus-replied-mark ?A
575 "*Mark used for articles that have been replied to."
576 :group
'gnus-summary-marks
579 (defcustom gnus-forwarded-mark ?F
580 "*Mark used for articles that have been forwarded."
582 :group
'gnus-summary-marks
585 (defcustom gnus-recent-mark ?N
586 "*Mark used for articles that are recent."
588 :group
'gnus-summary-marks
591 (defcustom gnus-cached-mark ?
*
592 "*Mark used for articles that are in the cache."
593 :group
'gnus-summary-marks
596 (defcustom gnus-saved-mark ?S
597 "*Mark used for articles that have been saved."
598 :group
'gnus-summary-marks
601 (defcustom gnus-unseen-mark ?.
602 "*Mark used for articles that haven't been seen."
604 :group
'gnus-summary-marks
607 (defcustom gnus-no-mark ?
;Whitespace
608 "*Mark used for articles that have no other secondary mark."
610 :group
'gnus-summary-marks
613 (defcustom gnus-ancient-mark ?O
614 "*Mark used for ancient articles."
615 :group
'gnus-summary-marks
618 (defcustom gnus-sparse-mark ?Q
619 "*Mark used for sparsely reffed articles."
620 :group
'gnus-summary-marks
623 (defcustom gnus-canceled-mark ?G
624 "*Mark used for canceled articles."
625 :group
'gnus-summary-marks
628 (defcustom gnus-duplicate-mark ?M
629 "*Mark used for duplicate articles."
630 :group
'gnus-summary-marks
633 (defcustom gnus-undownloaded-mark ?-
634 "*Mark used for articles that weren't downloaded."
636 :group
'gnus-summary-marks
639 (defcustom gnus-downloaded-mark ?
+
640 "*Mark used for articles that were downloaded."
641 :group
'gnus-summary-marks
644 (defcustom gnus-downloadable-mark ?%
645 "*Mark used for articles that are to be downloaded."
646 :group
'gnus-summary-marks
649 (defcustom gnus-unsendable-mark ?
=
650 "*Mark used for articles that won't be sent."
651 :group
'gnus-summary-marks
654 (defcustom gnus-score-over-mark ?
+
655 "*Score mark used for articles with high scores."
656 :group
'gnus-summary-marks
659 (defcustom gnus-score-below-mark ?-
660 "*Score mark used for articles with low scores."
661 :group
'gnus-summary-marks
664 (defcustom gnus-empty-thread-mark ?
;Whitespace
665 "*There is no thread under the article."
666 :group
'gnus-summary-marks
669 (defcustom gnus-not-empty-thread-mark ?
=
670 "*There is a thread under the article."
671 :group
'gnus-summary-marks
674 (defcustom gnus-view-pseudo-asynchronously nil
675 "*If non-nil, Gnus will view pseudo-articles asynchronously."
676 :group
'gnus-extract-view
679 (defcustom gnus-auto-expirable-marks
680 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
681 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
683 "*The list of marks converted into expiration if a group is auto-expirable."
686 :type
'(repeat character
))
688 (defcustom gnus-inhibit-user-auto-expire t
689 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
694 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
695 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
696 If nil, the expirable marks will be unchanged except that the marks
697 will be removed when copying or moving articles to a group that has
698 not turned auto-expire on. If non-nil, articles that have been read
699 will be marked as expirable when being copied or moved to a group in
700 which auto-expire is turned on."
703 :group
'gnus-summary-marks
)
705 (defcustom gnus-view-pseudos nil
706 "*If `automatic', pseudo-articles will be viewed automatically.
707 If `not-confirm', pseudos will be viewed automatically, and the user
708 will not be asked to confirm the command."
709 :group
'gnus-extract-view
710 :type
'(choice (const :tag
"off" nil
)
712 (const not-confirm
)))
714 (defcustom gnus-view-pseudos-separately t
715 "*If non-nil, one pseudo-article will be created for each file to be viewed.
716 If nil, all files that use the same viewing command will be given as a
717 list of parameters to that command."
718 :group
'gnus-extract-view
721 (defcustom gnus-insert-pseudo-articles t
722 "*If non-nil, insert pseudo-articles when decoding articles."
723 :group
'gnus-extract-view
726 (defcustom gnus-summary-dummy-line-format
728 "*The format specification for the dummy roots in the summary buffer.
729 It works along the same lines as a normal formatting string,
730 with some simple extensions.
734 General format specifiers can also be used.
735 See `(gnus)Formatting Variables'."
736 :link
'(custom-manual "(gnus)Formatting Variables")
737 :group
'gnus-threading
740 (defcustom gnus-summary-mode-line-format
"Gnus: %g [%A] %Z"
741 "*The format specification for the summary mode line.
742 It works along the same lines as a normal formatting string,
743 with some simple extensions:
746 %p Unprefixed group name
747 %A Current article number
748 %z Current article score
750 %U Number of unread articles in the group
751 %e Number of unselected articles in the group
752 %Z A string with unread/unselected article counts
753 %g Shortish group name
754 %S Subject of the current article
756 %s Current score file name
757 %d Number of dormant articles
758 %r Number of articles that have been marked as read in this session
759 %E Number of articles expunged by the score files"
760 :group
'gnus-summary-format
763 (defcustom gnus-list-identifiers nil
764 "Regexp that matches list identifiers to be removed from subject.
765 This can also be a list of regexps."
767 :group
'gnus-summary-format
768 :group
'gnus-article-hiding
769 :type
'(choice (const :tag
"none" nil
)
771 (repeat :value
(".*") regexp
)))
773 (defcustom gnus-summary-mark-below
0
774 "*Mark all articles with a score below this variable as read.
775 This variable is local to each summary buffer and usually set by the
777 :group
'gnus-score-default
780 (defun gnus-widget-reversible-match (widget value
)
781 "Ignoring WIDGET, convert VALUE to internal form.
782 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
786 (eq (length value
) 2)
787 (eq (nth 0 value
) 'not
)
788 (symbolp (nth 1 value
)))))
790 (defun gnus-widget-reversible-to-internal (widget value
)
791 "Ignoring WIDGET, convert VALUE to internal form.
792 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
793 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
797 (list (nth 1 value
) t
)))
799 (defun gnus-widget-reversible-to-external (widget value
)
800 "Ignoring WIDGET, convert VALUE to external form.
801 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
802 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
805 (list 'not
(nth 0 value
))
808 (define-widget 'gnus-widget-reversible
'group
809 "A `group' that convert values."
810 :match
'gnus-widget-reversible-match
811 :value-to-internal
'gnus-widget-reversible-to-internal
812 :value-to-external
'gnus-widget-reversible-to-external
)
814 (defcustom gnus-article-sort-functions
'(gnus-article-sort-by-number)
815 "*List of functions used for sorting articles in the summary buffer.
817 Each function takes two articles and returns non-nil if the first
818 article should be sorted before the other. If you use more than one
819 function, the primary sort function should be the last. You should
820 probably always include `gnus-article-sort-by-number' in the list of
821 sorting functions -- preferably first. Also note that sorting by date
822 is often much slower than sorting by number, and the sorting order is
823 very similar. (Sorting by date means sorting by the time the message
824 was sent, sorting by number means sorting by arrival time.)
826 Each item can also be a list `(not F)' where F is a function;
827 this reverses the sort order.
829 Ready-made functions include `gnus-article-sort-by-number',
830 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
831 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
832 and `gnus-article-sort-by-score'.
834 When threading is turned on, the variable `gnus-thread-sort-functions'
835 controls how articles are sorted."
836 :group
'gnus-summary-sort
837 :type
'(repeat (gnus-widget-reversible
838 (choice (function-item gnus-article-sort-by-number
)
839 (function-item gnus-article-sort-by-author
)
840 (function-item gnus-article-sort-by-subject
)
841 (function-item gnus-article-sort-by-date
)
842 (function-item gnus-article-sort-by-score
)
843 (function-item gnus-article-sort-by-random
)
844 (function :tag
"other"))
845 (boolean :tag
"Reverse order"))))
847 (defcustom gnus-thread-sort-functions
'(gnus-thread-sort-by-number)
848 "*List of functions used for sorting threads in the summary buffer.
849 By default, threads are sorted by article number.
851 Each function takes two threads and returns non-nil if the first
852 thread should be sorted before the other. If you use more than one
853 function, the primary sort function should be the last. You should
854 probably always include `gnus-thread-sort-by-number' in the list of
855 sorting functions -- preferably first. Also note that sorting by date
856 is often much slower than sorting by number, and the sorting order is
857 very similar. (Sorting by date means sorting by the time the message
858 was sent, sorting by number means sorting by arrival time.)
860 Each list item can also be a list `(not F)' where F is a
861 function; this specifies reversed sort order.
863 Ready-made functions include `gnus-thread-sort-by-number',
864 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
865 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
866 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
867 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
868 and `gnus-thread-sort-by-total-score' (see
869 `gnus-thread-score-function').
871 When threading is turned off, the variable
872 `gnus-article-sort-functions' controls how articles are sorted.
874 By default, threads and their subthreads are sorted according to
875 the value of this variable. To use a different sorting order for
876 subthreads, customize `gnus-subthread-sort-functions'."
877 :group
'gnus-summary-sort
879 (gnus-widget-reversible
880 (choice (function-item gnus-thread-sort-by-number
)
881 (function-item gnus-thread-sort-by-author
)
882 (function-item gnus-thread-sort-by-recipient
)
883 (function-item gnus-thread-sort-by-subject
)
884 (function-item gnus-thread-sort-by-date
)
885 (function-item gnus-thread-sort-by-score
)
886 (function-item gnus-thread-sort-by-most-recent-number
)
887 (function-item gnus-thread-sort-by-most-recent-date
)
888 (function-item gnus-thread-sort-by-random
)
889 (function-item gnus-thread-sort-by-total-score
)
890 (function :tag
"other"))
891 (boolean :tag
"Reverse order"))))
893 (defcustom gnus-subthread-sort-functions
'gnus-thread-sort-functions
894 "*List of functions used for sorting subthreads in the summary buffer.
895 By default, subthreads are sorted the same as threads, i.e.,
896 according to the value of `gnus-thread-sort-functions'."
898 :group
'gnus-summary-sort
900 (const :tag
"Sort subthreads like threads" gnus-thread-sort-functions
)
902 (gnus-widget-reversible
903 (choice (function-item gnus-thread-sort-by-number
)
904 (function-item gnus-thread-sort-by-author
)
905 (function-item gnus-thread-sort-by-recipient
)
906 (function-item gnus-thread-sort-by-subject
)
907 (function-item gnus-thread-sort-by-date
)
908 (function-item gnus-thread-sort-by-score
)
909 (function-item gnus-thread-sort-by-most-recent-number
)
910 (function-item gnus-thread-sort-by-most-recent-date
)
911 (function-item gnus-thread-sort-by-random
)
912 (function-item gnus-thread-sort-by-total-score
)
913 (function :tag
"other"))
914 (boolean :tag
"Reverse order")))))
916 (defcustom gnus-thread-score-function
'+
917 "*Function used for calculating the total score of a thread.
919 The function is called with the scores of the article and each
920 subthread and should then return the score of the thread.
922 Some functions you can use are `+', `max', or `min'."
923 :group
'gnus-summary-sort
926 (defcustom gnus-summary-expunge-below nil
927 "All articles that have a score less than this variable will be expunged.
928 This variable is local to the summary buffers."
929 :group
'gnus-score-default
930 :type
'(choice (const :tag
"off" nil
)
933 (defcustom gnus-thread-expunge-below nil
934 "All threads that have a total score less than this variable will be expunged.
935 See `gnus-thread-score-function' for en explanation of what a
938 This variable is local to the summary buffers."
939 :group
'gnus-threading
940 :group
'gnus-score-default
941 :type
'(choice (const :tag
"off" nil
)
944 (defcustom gnus-summary-mode-hook nil
945 "*A hook for Gnus summary mode.
946 This hook is run before any variables are set in the summary buffer."
947 :options
'(turn-on-gnus-mailing-list-mode gnus-pick-mode
)
948 :group
'gnus-summary-various
951 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
952 (when (featurep 'xemacs
)
953 (add-hook 'gnus-summary-mode-hook
'gnus-xmas-summary-menu-add
)
954 (add-hook 'gnus-summary-mode-hook
'gnus-xmas-setup-summary-toolbar
)
955 (add-hook 'gnus-summary-mode-hook
956 'gnus-xmas-switch-horizontal-scrollbar-off
))
958 (defcustom gnus-summary-menu-hook nil
959 "*Hook run after the creation of the summary mode menu."
960 :group
'gnus-summary-visual
963 (defcustom gnus-summary-exit-hook nil
964 "*A hook called on exit from the summary buffer.
965 It will be called with point in the group buffer."
966 :group
'gnus-summary-exit
969 (defcustom gnus-summary-prepare-hook nil
970 "*A hook called after the summary buffer has been generated.
971 If you want to modify the summary buffer, you can use this hook."
972 :group
'gnus-summary-various
975 (defcustom gnus-summary-prepared-hook nil
976 "*A hook called as the last thing after the summary buffer has been generated."
977 :group
'gnus-summary-various
980 (defcustom gnus-summary-generate-hook nil
981 "*A hook run just before generating the summary buffer.
982 This hook is commonly used to customize threading variables and the
984 :group
'gnus-summary-various
987 (defcustom gnus-select-group-hook nil
988 "*A hook called when a newsgroup is selected.
990 If you'd like to simplify subjects like the
991 `gnus-summary-next-same-subject' command does, you can use the
994 (add-hook gnus-select-group-hook
996 (mapcar (lambda (header)
997 (mail-header-set-subject
999 (gnus-simplify-subject
1000 (mail-header-subject header) \\='re-only)))
1001 gnus-newsgroup-headers)))"
1002 :group
'gnus-group-select
1005 (defcustom gnus-select-article-hook nil
1006 "*A hook called when an article is selected."
1007 :group
'gnus-summary-choose
1008 :options
'(gnus-agent-fetch-selected-article)
1011 (defcustom gnus-visual-mark-article-hook
1012 (list 'gnus-highlight-selected-summary
)
1013 "*Hook run after selecting an article in the summary buffer.
1014 It is meant to be used for highlighting the article in some way. It
1015 is not run if `gnus-visual' is nil."
1016 :group
'gnus-summary-visual
1019 (defcustom gnus-parse-headers-hook nil
1020 "*A hook called before parsing the headers."
1021 :group
'gnus-various
1024 (defcustom gnus-exit-group-hook nil
1025 "*A hook called when exiting summary mode.
1026 This hook is not called from the non-updating exit commands like `Q'."
1027 :group
'gnus-various
1030 (defcustom gnus-summary-update-hook nil
1031 "*A hook called when a summary line is changed.
1032 The hook will not be called if `gnus-visual' is nil.
1034 The default function `gnus-summary-highlight-line' will
1035 highlight the line according to the `gnus-summary-highlight'
1037 :group
'gnus-summary-visual
1040 (defcustom gnus-mark-article-hook
'(gnus-summary-mark-read-and-unread-as-read)
1041 "*A hook called when an article is selected for the first time.
1042 The hook is intended to mark an article as read (or unread)
1043 automatically when it is selected."
1044 :group
'gnus-summary-choose
1047 (defcustom gnus-group-no-more-groups-hook nil
1048 "*A hook run when returning to group mode having no more (unread) groups."
1049 :group
'gnus-group-select
1052 (defcustom gnus-ps-print-hook nil
1053 "*A hook run before ps-printing something from Gnus."
1054 :group
'gnus-summary
1057 (defcustom gnus-summary-article-move-hook nil
1058 "*A hook called after an article is moved, copied, respooled, or crossposted."
1060 :group
'gnus-summary
1063 (defcustom gnus-summary-article-delete-hook nil
1064 "*A hook called after an article is deleted."
1066 :group
'gnus-summary
1069 (defcustom gnus-summary-article-expire-hook nil
1070 "*A hook called after an article is expired."
1072 :group
'gnus-summary
1075 (defcustom gnus-summary-display-arrow
1076 (and (fboundp 'display-graphic-p
)
1077 (display-graphic-p))
1078 "*If non-nil, display an arrow highlighting the current article."
1080 :group
'gnus-summary
1083 (defcustom gnus-summary-selected-face
'gnus-summary-selected
1084 "Face used for highlighting the current article in the summary buffer."
1085 :group
'gnus-summary-visual
1088 (defvar gnus-tmp-downloaded nil
)
1090 (defcustom gnus-summary-highlight
1091 '(((eq mark gnus-canceled-mark
)
1092 . gnus-summary-cancelled
)
1093 ((and uncached
(> score default-high
))
1094 . gnus-summary-high-undownloaded
)
1095 ((and uncached
(< score default-low
))
1096 . gnus-summary-low-undownloaded
)
1098 . gnus-summary-normal-undownloaded
)
1099 ((and (> score default-high
)
1100 (or (eq mark gnus-dormant-mark
)
1101 (eq mark gnus-ticked-mark
)))
1102 . gnus-summary-high-ticked
)
1103 ((and (< score default-low
)
1104 (or (eq mark gnus-dormant-mark
)
1105 (eq mark gnus-ticked-mark
)))
1106 . gnus-summary-low-ticked
)
1107 ((or (eq mark gnus-dormant-mark
)
1108 (eq mark gnus-ticked-mark
))
1109 . gnus-summary-normal-ticked
)
1110 ((and (> score default-high
) (eq mark gnus-ancient-mark
))
1111 . gnus-summary-high-ancient
)
1112 ((and (< score default-low
) (eq mark gnus-ancient-mark
))
1113 . gnus-summary-low-ancient
)
1114 ((eq mark gnus-ancient-mark
)
1115 . gnus-summary-normal-ancient
)
1116 ((and (> score default-high
) (eq mark gnus-unread-mark
))
1117 . gnus-summary-high-unread
)
1118 ((and (< score default-low
) (eq mark gnus-unread-mark
))
1119 . gnus-summary-low-unread
)
1120 ((eq mark gnus-unread-mark
)
1121 . gnus-summary-normal-unread
)
1122 ((> score default-high
)
1123 . gnus-summary-high-read
)
1124 ((< score default-low
)
1125 . gnus-summary-low-read
)
1127 . gnus-summary-normal-read
))
1128 "*Controls the highlighting of summary buffer lines.
1130 A list of (FORM . FACE) pairs. When deciding how a particular
1131 summary line should be displayed, each form is evaluated. The content
1132 of the face field after the first true form is used. You can change
1133 how those summary lines are displayed, by editing the face field.
1135 You can use the following variables in the FORM field.
1137 score: The article's score.
1138 default: The default article score.
1139 default-high: The default score for high scored articles.
1140 default-low: The default score for low scored articles.
1141 mark: The article's mark.
1142 uncached: Non-nil if the article is uncached."
1143 :group
'gnus-summary-visual
1144 :type
'(repeat (cons (sexp :tag
"Form" nil
)
1146 (put 'gnus-summary-highlight
'risky-local-variable t
)
1148 (defcustom gnus-alter-header-function nil
1149 "Function called to allow alteration of article header structures.
1150 The function is called with one parameter, the article header vector,
1151 which it may alter in any way."
1152 :type
'(choice (const :tag
"None" nil
)
1154 :group
'gnus-summary
)
1156 (defvar gnus-decode-encoded-word-function
'mail-decode-encoded-word-string
1157 "Function used to decode a string with encoded words.")
1159 (defvar gnus-decode-encoded-address-function
1160 'mail-decode-encoded-address-string
1161 "Function used to decode addresses with encoded words.")
1163 (defcustom gnus-extra-headers
'(To Cc Keywords Gcc Newsgroups X-GM-LABELS
)
1164 "*Extra headers to parse."
1166 :group
'gnus-summary
1167 :type
'(repeat symbol
))
1169 (defcustom gnus-ignored-from-addresses
1170 (and user-mail-address
1171 (not (string= user-mail-address
""))
1172 (regexp-quote user-mail-address
))
1173 "*From headers that may be suppressed in favor of To headers.
1174 This can be a regexp or a list of regexps."
1176 :group
'gnus-summary
1177 :type
'(choice regexp
1178 (repeat :tag
"Regexp List" regexp
)))
1180 (defsubst gnus-ignored-from-addresses
()
1181 (gmm-regexp-concat gnus-ignored-from-addresses
))
1183 (defcustom gnus-summary-to-prefix
"-> "
1184 "*String prefixed to the To field in the summary line when
1185 using `gnus-ignored-from-addresses'."
1187 :group
'gnus-summary
1190 (defcustom gnus-summary-newsgroup-prefix
"=> "
1191 "*String prefixed to the Newsgroup field in the summary
1192 line when using the option `gnus-ignored-from-addresses'."
1194 :group
'gnus-summary
1197 (defcustom gnus-newsgroup-ignored-charsets
'(unknown-8bit x-unknown
)
1198 "List of charsets that should be ignored.
1199 When these charsets are used in the \"charset\" parameter, the
1200 default charset will be used instead."
1202 :type
'(repeat symbol
)
1203 :group
'gnus-charset
)
1205 (defcustom gnus-newsgroup-maximum-articles nil
1206 "The maximum number of articles a newsgroup.
1207 If this is a number, old articles in a newsgroup exceeding this number
1208 are silently ignored. If it is nil, no article is ignored. Note that
1209 setting this variable to a number might prevent you from reading very
1211 :group
'gnus-group-select
1213 :type
'(choice (const :tag
"No limit" nil
)
1216 (gnus-define-group-parameter
1220 "Return the ignored charsets of GROUP."
1221 :variable gnus-group-ignored-charsets-alist
1223 '(("alt\\.chinese\\.text" iso-8859-1
))
1225 "Alist of regexps (to match group names) and charsets that should be ignored.
1226 When these charsets are used in the \"charset\" parameter, the
1227 default charset will be used instead."
1228 :variable-group gnus-charset
1229 :variable-type
'(repeat (cons (regexp :tag
"Group")
1231 :parameter-type
'(choice :tag
"Ignored charsets"
1234 :parameter-document
"\
1235 List of charsets that should be ignored.
1237 When these charsets are used in the \"charset\" parameter, the
1238 default charset will be used instead.")
1240 (defcustom gnus-group-highlight-words-alist nil
1241 "Alist of group regexps and highlight regexps.
1242 This variable uses the same syntax as `gnus-emphasis-alist'."
1244 :type
'(repeat (cons (regexp :tag
"Group")
1245 (repeat (list (regexp :tag
"Highlight regexp")
1246 (number :tag
"Group for entire word" 0)
1247 (number :tag
"Group for displayed part" 0)
1249 gnus-emphasis-highlight-words
)))))
1250 :group
'gnus-summary-visual
)
1252 (defcustom gnus-summary-show-article-charset-alist
1254 "Alist of number and charset.
1255 The article will be shown with the charset corresponding to the
1257 For example: ((1 . cn-gb-2312) (2 . big5))."
1259 :type
'(repeat (cons (number :tag
"Argument" 1)
1260 (symbol :tag
"Charset")))
1261 :group
'gnus-charset
)
1263 (defcustom gnus-preserve-marks t
1264 "Whether marks are preserved when moving, copying and respooling messages."
1267 :group
'gnus-summary-marks
)
1269 (defcustom gnus-alter-articles-to-read-function nil
1270 "Function to be called to alter the list of articles to be selected."
1271 :type
'(choice (const nil
) function
)
1272 :group
'gnus-summary
)
1274 (defcustom gnus-orphan-score nil
1275 "*All orphans get this score added. Set in the score file."
1276 :group
'gnus-score-default
1277 :type
'(choice (const nil
)
1280 (defcustom gnus-summary-save-parts-default-mime
"image/.*"
1281 "*A regexp to match MIME parts when saving multiple parts of a
1282 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1283 This regexp will be used by default when prompting the user for which
1284 type of files to save."
1285 :group
'gnus-summary
1288 (defcustom gnus-read-all-available-headers nil
1289 "Whether Gnus should parse all headers made available to it.
1290 This is mostly relevant for slow back ends where the user may
1291 wish to widen the summary buffer to include all headers
1294 :group
'gnus-summary
1295 :type
'(choice boolean regexp
))
1297 (defcustom gnus-summary-pipe-output-default-command nil
1298 "Command (and optional arguments) used to pipe article to subprocess.
1299 This will be used as the default command if it is non-nil. The value
1300 will be updated if you modify it when executing the command
1301 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1302 :version
"23.1" ;; No Gnus
1303 :group
'gnus-summary
1304 :type
'(radio (const :tag
"None" nil
) (string :tag
"Command")))
1306 (defcustom gnus-summary-muttprint-program
"muttprint"
1307 "Command (and optional arguments) used to run Muttprint.
1308 The value will be updated if you modify it when executing the command
1309 `gnus-summary-muttprint'."
1311 :group
'gnus-summary
1314 (defcustom gnus-article-loose-mime t
1315 "If non-nil, don't require MIME-Version header.
1316 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1317 supply the MIME-Version header or deliberately strip it from the mail.
1318 If non-nil (the default), Gnus will treat some articles as MIME
1319 even if the MIME-Version header is missing."
1322 :group
'gnus-article-mime
)
1324 (defcustom gnus-article-emulate-mime t
1325 "If non-nil, use MIME emulation for uuencode and the like.
1326 This means that Gnus will search message bodies for text that look
1327 like uuencoded bits, yEncoded bits, and so on, and present that using
1328 the normal Gnus MIME machinery."
1331 :group
'gnus-article-mime
)
1333 ;;; Internal variables
1335 (defvar gnus-summary-display-cache nil
)
1336 (defvar gnus-article-mime-handles nil
)
1337 (defvar gnus-article-decoded-p nil
)
1338 (defvar gnus-article-charset nil
)
1339 (defvar gnus-article-ignored-charsets nil
)
1340 (defvar gnus-scores-exclude-files nil
)
1341 (defvar gnus-page-broken nil
)
1343 (defvar gnus-original-article nil
)
1344 (defvar gnus-article-internal-prepare-hook nil
)
1345 (defvar gnus-newsgroup-process-stack nil
)
1347 (defvar gnus-thread-indent-array nil
)
1348 (defvar gnus-thread-indent-array-level gnus-thread-indent-level
)
1349 (defvar gnus-sort-gathered-threads-function
'gnus-thread-sort-by-number
1350 "Function called to sort the articles within a thread after it has been gathered together.")
1352 (defvar gnus-summary-save-parts-type-history nil
)
1353 (defvar gnus-summary-save-parts-last-directory mm-default-directory
)
1355 ;; Avoid highlighting in kill files.
1356 (defvar gnus-summary-inhibit-highlight nil
)
1357 (defvar gnus-newsgroup-selected-overlay nil
)
1358 (defvar gnus-inhibit-limiting nil
)
1359 (defvar gnus-newsgroup-adaptive-score-file nil
)
1360 (defvar gnus-current-score-file nil
)
1361 (defvar gnus-current-move-group nil
)
1362 (defvar gnus-current-copy-group nil
)
1363 (defvar gnus-current-crosspost-group nil
)
1364 (defvar gnus-newsgroup-display nil
)
1366 (defvar gnus-newsgroup-dependencies nil
)
1367 (defvar gnus-newsgroup-adaptive nil
)
1368 (defvar gnus-summary-display-article-function nil
)
1369 (defvar gnus-summary-highlight-line-function nil
1370 "Function called after highlighting a summary line.")
1372 (defvar gnus-summary-line-format-alist
1373 `((?N
,(macroexpand '(mail-header-number gnus-tmp-header
)) ?d
)
1374 (?S
,(macroexpand '(mail-header-subject gnus-tmp-header
)) ?s
)
1375 (?s gnus-tmp-subject-or-nil ?s
)
1376 (?n gnus-tmp-name ?s
)
1377 (?A
(car (cdr (funcall gnus-extract-address-components gnus-tmp-from
)))
1379 (?a
(or (car (funcall gnus-extract-address-components gnus-tmp-from
))
1381 (?F gnus-tmp-from ?s
)
1382 (?x
,(macroexpand '(mail-header-xref gnus-tmp-header
)) ?s
)
1383 (?D
,(macroexpand '(mail-header-date gnus-tmp-header
)) ?s
)
1384 (?d
(gnus-dd-mmm (mail-header-date gnus-tmp-header
)) ?s
)
1385 (?o
(gnus-date-iso8601 (mail-header-date gnus-tmp-header
)) ?s
)
1386 (?M
,(macroexpand '(mail-header-id gnus-tmp-header
)) ?s
)
1387 (?r
,(macroexpand '(mail-header-references gnus-tmp-header
)) ?s
)
1388 (?c
(or (mail-header-chars gnus-tmp-header
) 0) ?d
)
1389 (?k
(gnus-summary-line-message-size gnus-tmp-header
) ?s
)
1390 (?L gnus-tmp-lines ?s
)
1391 (?Z
(or (nnir-article-rsv (mail-header-number gnus-tmp-header
))
1393 (?G
(or (nnir-article-group (mail-header-number gnus-tmp-header
))
1395 (?g
(or (gnus-group-short-name
1396 (nnir-article-group (mail-header-number gnus-tmp-header
)))
1398 (?O gnus-tmp-downloaded ?c
)
1399 (?I gnus-tmp-indentation ?s
)
1400 (?T
(if (= gnus-tmp-level
0) "" (make-string (frame-width) ?
)) ?s
)
1401 (?R gnus-tmp-replied ?c
)
1402 (?\
[ gnus-tmp-opening-bracket ?c
)
1403 (?\
] gnus-tmp-closing-bracket ?c
)
1404 (?\
> (make-string gnus-tmp-level ?
) ?s
)
1405 (?\
< (make-string (max 0 (- 20 gnus-tmp-level
)) ?
) ?s
)
1406 (?i gnus-tmp-score ?d
)
1407 (?z gnus-tmp-score-char ?c
)
1408 (?V
(gnus-thread-total-score (and (boundp 'thread
) (car thread
))) ?d
)
1409 (?U gnus-tmp-unread ?c
)
1410 (?f
(gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from
)
1412 (?t
(gnus-summary-number-of-articles-in-thread
1413 (and (boundp 'thread
) (car thread
)) gnus-tmp-level
)
1415 (?e
(gnus-summary-number-of-articles-in-thread
1416 (and (boundp 'thread
) (car thread
)) gnus-tmp-level t
)
1418 (?u gnus-tmp-user-defined ?s
)
1419 (?P
(gnus-pick-line-number) ?d
)
1420 (?B gnus-tmp-thread-tree-header-string ?s
)
1421 (user-date (gnus-user-date
1422 ,(macroexpand '(mail-header-date gnus-tmp-header
))) ?s
))
1423 "An alist of format specifications that can appear in summary lines.
1424 These are paired with what variables they correspond with, along with
1425 the type of the variable (string, integer, character, etc).")
1427 (defvar gnus-summary-dummy-line-format-alist
1428 `((?S gnus-tmp-subject ?s
)
1429 (?N gnus-tmp-number ?d
)
1430 (?u gnus-tmp-user-defined ?s
)))
1432 (defvar gnus-summary-mode-line-format-alist
1433 `((?G gnus-tmp-group-name ?s
)
1434 (?g
(gnus-short-group-name gnus-tmp-group-name
) ?s
)
1435 (?p
(gnus-group-real-name gnus-tmp-group-name
) ?s
)
1436 (?A gnus-tmp-article-number ?d
)
1437 (?Z gnus-tmp-unread-and-unselected ?s
)
1438 (?V gnus-version ?s
)
1439 (?U gnus-tmp-unread-and-unticked ?d
)
1440 (?S gnus-tmp-subject ?s
)
1441 (?e gnus-tmp-unselected ?d
)
1442 (?u gnus-tmp-user-defined ?s
)
1443 (?d
(length gnus-newsgroup-dormant
) ?d
)
1444 (?t
(length gnus-newsgroup-marked
) ?d
)
1445 (?h
(length gnus-newsgroup-spam-marked
) ?d
)
1446 (?r
(length gnus-newsgroup-reads
) ?d
)
1447 (?z
(gnus-summary-article-score gnus-tmp-article-number
) ?d
)
1448 (?E gnus-newsgroup-expunged-tally ?d
)
1449 (?s
(gnus-current-score-file-nondirectory) ?s
)))
1451 ;; This is here rather than in gnus-art for compilation reasons.
1452 (defvar gnus-article-mode-line-format-alist
1453 (nconc '((?w
(gnus-article-wash-status) ?s
)
1454 (?m
(gnus-article-mime-part-status) ?s
))
1455 gnus-summary-mode-line-format-alist
))
1457 (defvar gnus-last-search-regexp nil
1458 "Default regexp for article search command.")
1460 (defvar gnus-last-shell-command nil
1461 "Default shell command on article.")
1463 (defvar gnus-newsgroup-agentized nil
1464 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1465 (defvar gnus-newsgroup-begin nil
)
1466 (defvar gnus-newsgroup-end nil
)
1467 (defvar gnus-newsgroup-last-rmail nil
)
1468 (defvar gnus-newsgroup-last-mail nil
)
1469 (defvar gnus-newsgroup-last-folder nil
)
1470 (defvar gnus-newsgroup-last-file nil
)
1471 (defvar gnus-newsgroup-last-directory nil
)
1472 (defvar gnus-newsgroup-auto-expire nil
)
1473 (defvar gnus-newsgroup-active nil
)
1474 (defvar gnus-newsgroup-highest nil
)
1476 (defvar gnus-newsgroup-data nil
)
1477 (defvar gnus-newsgroup-data-reverse nil
)
1478 (defvar gnus-newsgroup-limit nil
)
1479 (defvar gnus-newsgroup-limits nil
)
1480 (defvar gnus-summary-use-undownloaded-faces nil
)
1482 (defvar gnus-newsgroup-unreads nil
1483 "Sorted list of unread articles in the current newsgroup.")
1485 (defvar gnus-newsgroup-unselected nil
1486 "Sorted list of unselected unread articles in the current newsgroup.")
1488 (defvar gnus-newsgroup-reads nil
1489 "Alist of read articles and article marks in the current newsgroup.")
1491 (defvar gnus-newsgroup-expunged-tally nil
)
1493 (defvar gnus-newsgroup-marked nil
1494 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1496 (defvar gnus-newsgroup-spam-marked nil
1497 "List of ranges of articles that have been marked as spam.")
1499 (defvar gnus-newsgroup-killed nil
1500 "List of ranges of articles that have been through the scoring process.")
1502 (defvar gnus-newsgroup-cached nil
1503 "Sorted list of articles that come from the article cache.")
1505 (defvar gnus-newsgroup-saved nil
1506 "List of articles that have been saved.")
1508 (defvar gnus-newsgroup-kill-headers nil
)
1510 (defvar gnus-newsgroup-replied nil
1511 "List of articles that have been replied to in the current newsgroup.")
1513 (defvar gnus-newsgroup-forwarded nil
1514 "List of articles that have been forwarded in the current newsgroup.")
1516 (defvar gnus-newsgroup-expirable nil
1517 "Sorted list of articles in the current newsgroup that can be expired.")
1519 (defvar gnus-newsgroup-processable nil
1520 "List of articles in the current newsgroup that can be processed.")
1522 (defvar gnus-newsgroup-downloadable nil
1523 "Sorted list of articles in the current newsgroup that can be processed.")
1525 (defvar gnus-newsgroup-unfetched nil
1526 "Sorted list of articles in the current newsgroup whose headers have
1527 not been fetched into the agent.
1529 This list will always be a subset of gnus-newsgroup-undownloaded.")
1531 (defvar gnus-newsgroup-undownloaded nil
1532 "List of articles in the current newsgroup that haven't been downloaded.")
1534 (defvar gnus-newsgroup-unsendable nil
1535 "List of articles in the current newsgroup that won't be sent.")
1537 (defvar gnus-newsgroup-bookmarks nil
1538 "List of articles in the current newsgroup that have bookmarks.")
1540 (defvar gnus-newsgroup-dormant nil
1541 "Sorted list of dormant articles in the current newsgroup.")
1543 (defvar gnus-newsgroup-unseen nil
1544 "List of unseen articles in the current newsgroup.")
1546 (defvar gnus-newsgroup-seen nil
1547 "Range of seen articles in the current newsgroup.")
1549 (defvar gnus-newsgroup-unexist nil
1550 "Range of unexisting articles in the current newsgroup.")
1552 (defvar gnus-newsgroup-articles nil
1553 "List of articles in the current newsgroup.")
1555 (defvar gnus-newsgroup-scored nil
1556 "List of scored articles in the current newsgroup.")
1558 (defvar gnus-newsgroup-headers nil
1559 "List of article headers in the current newsgroup.")
1561 (defvar gnus-newsgroup-threads nil
)
1563 (defvar gnus-newsgroup-prepared nil
1564 "Whether the current group has been prepared properly.")
1566 (defvar gnus-newsgroup-ancient nil
1567 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1569 (defvar gnus-newsgroup-sparse nil
)
1571 (defvar gnus-current-article nil
)
1572 (defvar gnus-article-current nil
)
1573 (defvar gnus-current-headers nil
)
1574 (defvar gnus-have-all-headers nil
)
1575 (defvar gnus-last-article nil
)
1576 (defvar gnus-newsgroup-history nil
)
1577 (defvar gnus-newsgroup-charset nil
)
1578 (defvar gnus-newsgroup-ephemeral-charset nil
)
1579 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil
)
1581 (defvar gnus-article-before-search nil
)
1583 (defvar gnus-summary-local-variables
1584 '(gnus-newsgroup-name
1587 gnus-newsgroup-unreads
1588 gnus-newsgroup-unselected
1589 gnus-newsgroup-marked
1590 gnus-newsgroup-spam-marked
1591 gnus-newsgroup-reads
1592 gnus-newsgroup-saved
1593 gnus-newsgroup-replied
1594 gnus-newsgroup-forwarded
1595 gnus-newsgroup-expirable
1596 gnus-newsgroup-killed
1597 gnus-newsgroup-unseen
1599 gnus-newsgroup-unexist
1600 gnus-newsgroup-cached
1601 gnus-newsgroup-downloadable
1602 gnus-newsgroup-undownloaded
1603 gnus-newsgroup-unsendable
1605 gnus-newsgroup-begin gnus-newsgroup-end
1606 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1607 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1608 gnus-newsgroup-last-directory
1609 gnus-newsgroup-auto-expire
1610 gnus-newsgroup-processable
1611 gnus-newsgroup-unfetched
1612 gnus-newsgroup-articles
1613 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1614 gnus-newsgroup-headers gnus-newsgroup-threads
1615 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1616 gnus-current-article gnus-current-headers gnus-have-all-headers
1617 gnus-last-article gnus-article-internal-prepare-hook
1618 (gnus-summary-article-delete-hook . global
)
1619 (gnus-summary-article-move-hook . global
)
1620 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1621 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1622 gnus-thread-expunge-below
1623 gnus-score-alist gnus-current-score-file
1624 (gnus-summary-expunge-below . global
)
1625 (gnus-summary-mark-below . global
)
1626 (gnus-orphan-score . global
)
1627 gnus-newsgroup-active gnus-scores-exclude-files
1628 gnus-newsgroup-highest
1629 gnus-newsgroup-history gnus-newsgroup-ancient
1630 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1631 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring
)
1632 gnus-newsgroup-adaptive-score-file
(gnus-reffed-article-number . -
1)
1633 (gnus-newsgroup-expunged-tally .
0)
1634 gnus-cache-removable-articles
1635 gnus-newsgroup-data gnus-newsgroup-data-reverse
1636 gnus-newsgroup-limit gnus-newsgroup-limits
1637 gnus-newsgroup-charset gnus-newsgroup-display
1638 gnus-summary-use-undownloaded-faces
)
1639 "Variables that are buffer-local to the summary buffers.")
1641 (defvar gnus-newsgroup-variables nil
1642 "A list of variables that have separate values in different newsgroups.
1643 A list of newsgroup (summary buffer) local variables, or cons of
1644 variables and their default expressions to be evalled (when the default
1645 values are not nil), that should be made global while the summary buffer
1648 Note: The default expressions will be evaluated (using function `eval')
1649 before assignment to the local variable rather than just assigned to it.
1650 If the default expression is the symbol `global', that symbol will not
1651 be evaluated but the global value of the local variable will be used
1654 These variables can be used to set variables in the group parameters
1655 while still allowing them to affect operations done in other buffers.
1658 \(setq gnus-newsgroup-variables
1659 \\='(message-use-followup-to
1660 (gnus-visible-headers .
1661 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1665 ;; Bind features so that require will believe that gnus-sum has
1666 ;; already been loaded (avoids infinite recursion)
1667 (let ((features (cons 'gnus-sum features
)))
1668 (require 'gnus-art
)))
1672 (defvar gnus-decode-encoded-word-methods
1673 '(mail-decode-encoded-word-string)
1674 "List of methods used to decode encoded words.
1676 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1677 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1678 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1679 whose names match REGEXP.
1682 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1683 mail-decode-encoded-word-string
1684 (\"chinese\" . rfc1843-decode-string))")
1686 (defvar gnus-decode-encoded-word-methods-cache nil
)
1688 (defun gnus-multi-decode-encoded-word-string (string)
1689 "Apply the functions from `gnus-encoded-word-methods' that match."
1690 (unless (and gnus-decode-encoded-word-methods-cache
1691 (eq gnus-newsgroup-name
1692 (car gnus-decode-encoded-word-methods-cache
)))
1693 (setq gnus-decode-encoded-word-methods-cache
(list gnus-newsgroup-name
))
1694 (dolist (method gnus-decode-encoded-word-methods
)
1695 (if (symbolp method
)
1696 (nconc gnus-decode-encoded-word-methods-cache
(list method
))
1697 (if (and gnus-newsgroup-name
1698 (string-match (car method
) gnus-newsgroup-name
))
1699 (nconc gnus-decode-encoded-word-methods-cache
1700 (list (cdr method
)))))))
1701 (dolist (method (cdr gnus-decode-encoded-word-methods-cache
) string
)
1702 (setq string
(funcall method string
))))
1704 ;; Subject simplification.
1706 (defun gnus-simplify-whitespace (str)
1707 "Remove excessive whitespace from STR."
1709 (while (string-match "[ \t][ \t]+" str
)
1710 (setq str
(concat (substring str
0 (match-beginning 0))
1712 (substring str
(match-end 0)))))
1714 (when (string-match "^[ \t]+" str
)
1715 (setq str
(substring str
(match-end 0))))
1717 (when (string-match "[ \t]+$" str
)
1718 (setq str
(substring str
0 (match-beginning 0))))
1721 (defun gnus-simplify-all-whitespace (str)
1722 "Remove all whitespace from STR."
1723 (while (string-match "[ \t\n]+" str
)
1724 (setq str
(replace-match "" nil nil str
)))
1727 (defsubst gnus-simplify-subject-re
(subject)
1728 "Remove \"Re:\" from subject lines."
1729 (if (string-match message-subject-re-regexp subject
)
1730 (substring subject
(match-end 0))
1733 (defun gnus-simplify-subject (subject &optional re-only
)
1734 "Remove `Re:' and words in parentheses.
1735 If RE-ONLY is non-nil, strip leading `Re:'s only."
1736 (let ((case-fold-search t
)) ;Ignore case.
1737 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1738 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject
)
1739 (setq subject
(substring subject
(match-end 0))))
1740 ;; Remove uninteresting prefixes.
1741 (when (and (not re-only
)
1742 gnus-simplify-ignored-prefixes
1743 (string-match gnus-simplify-ignored-prefixes subject
))
1744 (setq subject
(substring subject
(match-end 0))))
1745 ;; Remove words in parentheses from end.
1747 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject
)
1748 (setq subject
(substring subject
0 (match-beginning 0)))))
1749 ;; Return subject string.
1752 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1754 (defsubst gnus-simplify-buffer-fuzzy-step
(regexp &optional newtext
)
1755 (goto-char (point-min))
1756 (while (re-search-forward regexp nil t
)
1757 (replace-match (or newtext
""))))
1759 (defun gnus-simplify-buffer-fuzzy (regexp)
1760 "Simplify string in the buffer fuzzily.
1761 The string in the accessible portion of the current buffer is simplified.
1762 It is assumed to be a single-line subject.
1763 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1764 matter is removed. Additional things can be deleted by setting
1765 `gnus-simplify-subject-fuzzy-regexp'."
1766 (let ((case-fold-search t
)
1768 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1770 (while (not (eq modified-tick
(buffer-modified-tick)))
1771 (setq modified-tick
(buffer-modified-tick))
1774 (mapc 'gnus-simplify-buffer-fuzzy-step regexp
))
1776 (gnus-simplify-buffer-fuzzy-step regexp
)))
1777 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1778 (gnus-simplify-buffer-fuzzy-step
1779 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1780 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1782 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1783 (gnus-simplify-buffer-fuzzy-step " +" " ")
1784 (gnus-simplify-buffer-fuzzy-step " $")
1785 (gnus-simplify-buffer-fuzzy-step "^ +")))
1787 (defun gnus-simplify-subject-fuzzy (subject)
1788 "Simplify a subject string fuzzily.
1789 See `gnus-simplify-buffer-fuzzy' for details."
1791 (let ((regexp gnus-simplify-subject-fuzzy-regexp
))
1792 (gnus-set-work-buffer)
1793 (let ((case-fold-search t
))
1794 ;; Remove uninteresting prefixes.
1795 (when (and gnus-simplify-ignored-prefixes
1796 (string-match gnus-simplify-ignored-prefixes subject
))
1797 (setq subject
(substring subject
(match-end 0))))
1799 (inline (gnus-simplify-buffer-fuzzy regexp
))
1802 (defsubst gnus-simplify-subject-fully
(subject)
1803 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1805 (gnus-simplify-subject-functions
1806 (gnus-map-function gnus-simplify-subject-functions subject
))
1807 ((null gnus-summary-gather-subject-limit
)
1808 (gnus-simplify-subject-re subject
))
1809 ((eq gnus-summary-gather-subject-limit
'fuzzy
)
1810 (gnus-simplify-subject-fuzzy subject
))
1811 ((numberp gnus-summary-gather-subject-limit
)
1812 (truncate-string-to-width (gnus-simplify-subject-re subject
)
1813 gnus-summary-gather-subject-limit
))
1817 (defsubst gnus-subject-equal
(s1 s2
&optional simple-first
)
1818 "Check whether two subjects are equal.
1819 If optional argument SIMPLE-FIRST is t, first argument is already
1822 ((null simple-first
)
1823 (equal (gnus-simplify-subject-fully s1
)
1824 (gnus-simplify-subject-fully s2
)))
1827 (gnus-simplify-subject-fully s2
)))))
1829 (defun gnus-summary-bubble-group ()
1830 "Increase the score of the current group.
1831 This is a handy function to add to `gnus-summary-exit-hook' to
1832 increase the score of each group you read."
1833 (gnus-group-add-score gnus-newsgroup-name
))
1837 ;;; Gnus summary mode
1840 (put 'gnus-summary-mode
'mode-class
'special
)
1842 (defvar gnus-article-commands-menu
)
1844 ;; Non-orthogonal keys
1846 (gnus-define-keys gnus-summary-mode-map
1847 " " gnus-summary-next-page
1848 [?\S-\
] gnus-summary-prev-page
1849 "\177" gnus-summary-prev-page
1850 [delete] gnus-summary-prev-page
1851 "\r" gnus-summary-scroll-up
1852 "\M-\r" gnus-summary-scroll-down
1853 "n" gnus-summary-next-unread-article
1854 "p" gnus-summary-prev-unread-article
1855 "N" gnus-summary-next-article
1856 "P" gnus-summary-prev-article
1857 "\M-\C-n" gnus-summary-next-same-subject
1858 "\M-\C-p" gnus-summary-prev-same-subject
1859 "\M-n" gnus-summary-next-unread-subject
1860 "\M-p" gnus-summary-prev-unread-subject
1861 "." gnus-summary-first-unread-article
1862 "," gnus-summary-best-unread-article
1863 "\M-s" gnus-summary-search-article-forward
1864 "\M-r" gnus-summary-search-article-backward
1865 "\M-S" gnus-summary-repeat-search-article-forward
1866 "\M-R" gnus-summary-repeat-search-article-backward
1867 "<" gnus-summary-beginning-of-article
1868 ">" gnus-summary-end-of-article
1869 "j" gnus-summary-goto-article
1870 "^" gnus-summary-refer-parent-article
1871 "\M-^" gnus-summary-refer-article
1872 "u" gnus-summary-tick-article-forward
1873 "!" gnus-summary-tick-article-forward
1874 "U" gnus-summary-tick-article-backward
1875 "d" gnus-summary-mark-as-read-forward
1876 "D" gnus-summary-mark-as-read-backward
1877 "E" gnus-summary-mark-as-expirable
1878 "\M-u" gnus-summary-clear-mark-forward
1879 "\M-U" gnus-summary-clear-mark-backward
1880 "k" gnus-summary-kill-same-subject-and-select
1881 "\C-k" gnus-summary-kill-same-subject
1882 "\M-\C-k" gnus-summary-kill-thread
1883 "\M-\C-l" gnus-summary-lower-thread
1884 "e" gnus-summary-edit-article
1885 "#" gnus-summary-mark-as-processable
1886 "\M-#" gnus-summary-unmark-as-processable
1887 "\M-\C-t" gnus-summary-toggle-threads
1888 "\M-\C-s" gnus-summary-show-thread
1889 "\M-\C-h" gnus-summary-hide-thread
1890 "\M-\C-f" gnus-summary-next-thread
1891 "\M-\C-b" gnus-summary-prev-thread
1892 [(meta down)] gnus-summary-next-thread
1893 [(meta up)] gnus-summary-prev-thread
1894 "\M-\C-u" gnus-summary-up-thread
1895 "\M-\C-d" gnus-summary-down-thread
1896 "&" gnus-summary-execute-command
1897 "c" gnus-summary-catchup-and-exit
1898 "\C-w" gnus-summary-mark-region-as-read
1899 "\C-t" gnus-summary-toggle-truncation
1900 "?" gnus-summary-mark-as-dormant
1901 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1902 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1903 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1904 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1905 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1906 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1907 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1908 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1909 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1910 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1911 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1912 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1913 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1914 "=" gnus-summary-expand-window
1915 "\C-x\C-s" gnus-summary-reselect-current-group
1916 "\M-g" gnus-summary-rescan-group
1917 "\C-c\C-r" gnus-summary-caesar-message
1918 "f" gnus-summary-followup
1919 "F" gnus-summary-followup-with-original
1920 "C" gnus-summary-cancel-article
1921 "r" gnus-summary-reply
1922 "R" gnus-summary-reply-with-original
1923 "\C-c\C-f" gnus-summary-mail-forward
1924 "o" gnus-summary-save-article
1925 "\C-o" gnus-summary-save-article-mail
1926 "|" gnus-summary-pipe-output
1927 "\M-k" gnus-summary-edit-local-kill
1928 "\M-K" gnus-summary-edit-global-kill
1930 "\C-c\C-d" gnus-summary-describe-group
1931 "q" gnus-summary-exit
1932 "Q" gnus-summary-exit-no-update
1933 "\C-c\C-i" gnus-info-find-node
1934 gnus-mouse-2 gnus-mouse-pick-article
1935 [follow-link] mouse-face
1936 "m" gnus-summary-mail-other-window
1937 "a" gnus-summary-post-news
1938 "x" gnus-summary-limit-to-unread
1939 "s" gnus-summary-isearch-article
1940 "\t" gnus-summary-widget-forward
1941 [backtab] gnus-summary-widget-backward
1942 "t" gnus-summary-toggle-header
1943 "g" gnus-summary-show-article
1944 "l" gnus-summary-goto-last-article
1945 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1946 "\C-d" gnus-summary-enter-digest-group
1947 "\M-\C-d" gnus-summary-read-document
1948 "\M-\C-e" gnus-summary-edit-parameters
1949 "\M-\C-a" gnus-summary-customize-parameters
1951 "*" gnus-cache-enter-article
1952 "\M-*" gnus-cache-remove-article
1953 "\M-&" gnus-summary-universal-argument
1954 "\C-l" gnus-recenter
1955 "I" gnus-summary-increase-score
1956 "L" gnus-summary-lower-score
1957 "\M-i" gnus-symbolic-argument
1958 "h" gnus-summary-select-article-buffer
1960 "b" gnus-article-view-part
1961 "\M-t" gnus-summary-toggle-display-buttonized
1963 "V" gnus-summary-score-map
1964 "X" gnus-uu-extract-map
1965 "S" gnus-summary-send-map)
1967 ;; Sort of orthogonal keymap
1968 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1969 "t" gnus-summary-tick-article-forward
1970 "!" gnus-summary-tick-article-forward
1971 "d" gnus-summary-mark-as-read-forward
1972 "r" gnus-summary-mark-as-read-forward
1973 "c" gnus-summary-clear-mark-forward
1974 " " gnus-summary-clear-mark-forward
1975 "e" gnus-summary-mark-as-expirable
1976 "x" gnus-summary-mark-as-expirable
1977 "?" gnus-summary-mark-as-dormant
1978 "b" gnus-summary-set-bookmark
1979 "B" gnus-summary-remove-bookmark
1980 "#" gnus-summary-mark-as-processable
1981 "\M-#" gnus-summary-unmark-as-processable
1982 "S" gnus-summary-limit-include-expunged
1983 "C" gnus-summary-catchup
1984 "H" gnus-summary-catchup-to-here
1985 "h" gnus-summary-catchup-from-here
1986 "\C-c" gnus-summary-catchup-all
1987 "k" gnus-summary-kill-same-subject-and-select
1988 "K" gnus-summary-kill-same-subject
1989 "P" gnus-uu-mark-map)
1991 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1992 "c" gnus-summary-clear-above
1993 "u" gnus-summary-tick-above
1994 "m" gnus-summary-mark-above
1995 "k" gnus-summary-kill-below)
1997 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1998 "/" gnus-summary-limit-to-subject
1999 "n" gnus-summary-limit-to-articles
2000 "b" gnus-summary-limit-to-bodies
2001 "h" gnus-summary-limit-to-headers
2002 "w" gnus-summary-pop-limit
2003 "s" gnus-summary-limit-to-subject
2004 "a" gnus-summary-limit-to-author
2005 "u" gnus-summary-limit-to-unread
2006 "m" gnus-summary-limit-to-marks
2007 "M" gnus-summary-limit-exclude-marks
2008 "v" gnus-summary-limit-to-score
2009 "*" gnus-summary-limit-include-cached
2010 "D" gnus-summary-limit-include-dormant
2011 "T" gnus-summary-limit-include-thread
2012 "d" gnus-summary-limit-exclude-dormant
2013 "t" gnus-summary-limit-to-age
2014 "." gnus-summary-limit-to-unseen
2015 "x" gnus-summary-limit-to-extra
2016 "p" gnus-summary-limit-to-display-predicate
2017 "E" gnus-summary-limit-include-expunged
2018 "c" gnus-summary-limit-exclude-childless-dormant
2019 "C" gnus-summary-limit-mark-excluded-as-read
2020 "o" gnus-summary-insert-old-articles
2021 "N" gnus-summary-insert-new-articles
2022 "S" gnus-summary-limit-to-singletons
2023 "r" gnus-summary-limit-to-replied
2024 "R" gnus-summary-limit-to-recipient
2025 "A" gnus-summary-limit-to-address)
2027 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2028 "n" gnus-summary-next-unread-article
2029 "p" gnus-summary-prev-unread-article
2030 "N" gnus-summary-next-article
2031 "P" gnus-summary-prev-article
2032 "\C-n" gnus-summary-next-same-subject
2033 "\C-p" gnus-summary-prev-same-subject
2034 "\M-n" gnus-summary-next-unread-subject
2035 "\M-p" gnus-summary-prev-unread-subject
2036 "f" gnus-summary-first-unread-article
2037 "b" gnus-summary-best-unread-article
2038 "j" gnus-summary-goto-article
2039 "g" gnus-summary-goto-subject
2040 "l" gnus-summary-goto-last-article
2041 "o" gnus-summary-pop-article)
2043 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2044 "k" gnus-summary-kill-thread
2045 "E" gnus-summary-expire-thread
2046 "l" gnus-summary-lower-thread
2047 "i" gnus-summary-raise-thread
2048 "T" gnus-summary-toggle-threads
2049 "t" gnus-summary-rethread-current
2050 "^" gnus-summary-reparent-thread
2051 "\M-^" gnus-summary-reparent-children
2052 "s" gnus-summary-show-thread
2053 "S" gnus-summary-show-all-threads
2054 "h" gnus-summary-hide-thread
2055 "H" gnus-summary-hide-all-threads
2056 "n" gnus-summary-next-thread
2057 "p" gnus-summary-prev-thread
2058 "u" gnus-summary-up-thread
2059 "o" gnus-summary-top-thread
2060 "d" gnus-summary-down-thread
2061 "#" gnus-uu-mark-thread
2062 "\M-#" gnus-uu-unmark-thread)
2064 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2065 "g" gnus-summary-prepare
2066 "c" gnus-summary-insert-cached-articles
2067 "d" gnus-summary-insert-dormant-articles
2068 "t" gnus-summary-insert-ticked-articles)
2070 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2071 "c" gnus-summary-catchup-and-exit
2072 "C" gnus-summary-catchup-all-and-exit
2073 "E" gnus-summary-exit-no-update
2074 "Q" gnus-summary-exit
2075 "Z" gnus-summary-exit
2076 "n" gnus-summary-catchup-and-goto-next-group
2077 "p" gnus-summary-catchup-and-goto-prev-group
2078 "R" gnus-summary-reselect-current-group
2079 "G" gnus-summary-rescan-group
2080 "N" gnus-summary-next-group
2081 "s" gnus-summary-save-newsrc
2082 "P" gnus-summary-prev-group)
2084 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2085 " " gnus-summary-next-page
2086 "n" gnus-summary-next-page
2087 [?\S-\ ] gnus-summary-prev-page
2088 "\177" gnus-summary-prev-page
2089 [delete] gnus-summary-prev-page
2090 "p" gnus-summary-prev-page
2091 "\r" gnus-summary-scroll-up
2092 "\M-\r" gnus-summary-scroll-down
2093 "<" gnus-summary-beginning-of-article
2094 ">" gnus-summary-end-of-article
2095 "b" gnus-summary-beginning-of-article
2096 "e" gnus-summary-end-of-article
2097 "^" gnus-summary-refer-parent-article
2098 "r" gnus-summary-refer-parent-article
2099 "C" gnus-summary-show-complete-article
2100 "D" gnus-summary-enter-digest-group
2101 "R" gnus-summary-refer-references
2102 "T" gnus-summary-refer-thread
2103 "W" gnus-warp-to-article
2104 "g" gnus-summary-show-article
2105 "s" gnus-summary-isearch-article
2106 "\t" gnus-summary-widget-forward
2107 [backtab] gnus-summary-widget-backward
2108 "P" gnus-summary-print-article
2109 "S" gnus-sticky-article
2110 "M" gnus-mailing-list-insinuate
2111 "t" gnus-article-babel)
2113 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2114 "b" gnus-article-add-buttons
2115 "B" gnus-article-add-buttons-to-head
2116 "o" gnus-article-treat-overstrike
2117 "e" gnus-article-emphasize
2118 "w" gnus-article-fill-cited-article
2119 "Q" gnus-article-fill-long-lines
2120 "L" gnus-article-toggle-truncate-lines
2121 "C" gnus-article-capitalize-sentences
2122 "c" gnus-article-remove-cr
2123 "q" gnus-article-de-quoted-unreadable
2124 "6" gnus-article-de-base64-unreadable
2125 "Z" gnus-article-decode-HZ
2126 "A" gnus-article-treat-ansi-sequences
2127 "h" gnus-article-wash-html
2128 "u" gnus-article-unsplit-urls
2129 "s" gnus-summary-force-verify-and-decrypt
2130 "f" gnus-article-display-x-face
2131 "l" gnus-summary-stop-page-breaking
2132 "r" gnus-summary-caesar-message
2133 "m" gnus-summary-morse-message
2134 "t" gnus-summary-toggle-header
2135 "g" gnus-treat-smiley
2136 "v" gnus-summary-verbose-headers
2137 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2138 "p" gnus-article-verify-x-pgp-sig
2139 "d" gnus-article-treat-dumbquotes
2140 "U" gnus-article-treat-non-ascii
2141 "i" gnus-summary-idna-message)
2143 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2144 ;; mnemonic: deuglif*Y*
2145 "u" gnus-article-outlook-unwrap-lines
2146 "a" gnus-article-outlook-repair-attribution
2147 "c" gnus-article-outlook-rearrange-citation
2148 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2150 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2151 "a" gnus-article-hide
2152 "h" gnus-article-hide-headers
2153 "b" gnus-article-hide-boring-headers
2154 "s" gnus-article-hide-signature
2155 "c" gnus-article-hide-citation
2156 "C" gnus-article-hide-citation-in-followups
2157 "l" gnus-article-hide-list-identifiers
2158 "B" gnus-article-strip-banner
2159 "P" gnus-article-hide-pem
2160 "\C-c" gnus-article-hide-citation-maybe)
2162 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2163 "a" gnus-article-highlight
2164 "h" gnus-article-highlight-headers
2165 "c" gnus-article-highlight-citation
2166 "s" gnus-article-highlight-signature)
2168 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2169 "f" gnus-article-treat-fold-headers
2170 "u" gnus-article-treat-unfold-headers
2171 "n" gnus-article-treat-fold-newsgroups)
2173 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2174 "x" gnus-article-display-x-face
2175 "d" gnus-article-display-face
2176 "s" gnus-treat-smiley
2177 "D" gnus-article-remove-images
2178 "W" gnus-article-show-images
2179 "f" gnus-treat-from-picon
2180 "m" gnus-treat-mail-picon
2181 "n" gnus-treat-newsgroups-picon
2182 "g" gnus-treat-from-gravatar
2183 "h" gnus-treat-mail-gravatar)
2185 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2186 "w" gnus-article-decode-mime-words
2187 "c" gnus-article-decode-charset
2188 "h" gnus-mime-buttonize-attachments-in-header
2189 "v" gnus-mime-view-all-parts
2190 "b" gnus-article-view-part)
2192 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2193 "z" gnus-article-date-ut
2194 "u" gnus-article-date-ut
2195 "l" gnus-article-date-local
2196 "p" gnus-article-date-english
2197 "e" gnus-article-date-lapsed
2198 "o" gnus-article-date-original
2199 "i" gnus-article-date-iso8601
2200 "s" gnus-article-date-user)
2202 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2203 "t" gnus-article-remove-trailing-blank-lines
2204 "l" gnus-article-strip-leading-blank-lines
2205 "m" gnus-article-strip-multiple-blank-lines
2206 "a" gnus-article-strip-blank-lines
2207 "A" gnus-article-strip-all-blank-lines
2208 "s" gnus-article-strip-leading-space
2209 "e" gnus-article-strip-trailing-space
2210 "w" gnus-article-remove-leading-whitespace)
2212 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2214 "d" gnus-summary-describe-group
2215 "h" gnus-summary-describe-briefly
2216 "i" gnus-info-find-node)
2218 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2219 "e" gnus-summary-expire-articles
2220 "\M-\C-e" gnus-summary-expire-articles-now
2221 "\177" gnus-summary-delete-article
2222 [delete] gnus-summary-delete-article
2223 [backspace] gnus-summary-delete-article
2224 "m" gnus-summary-move-article
2225 "r" gnus-summary-respool-article
2226 "w" gnus-summary-edit-article
2227 "c" gnus-summary-copy-article
2228 "B" gnus-summary-crosspost-article
2229 "q" gnus-summary-respool-query
2230 "t" gnus-summary-respool-trace
2231 "i" gnus-summary-import-article
2232 "I" gnus-summary-create-article
2233 "p" gnus-summary-article-posted-p)
2235 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2236 "o" gnus-summary-save-article
2237 "m" gnus-summary-save-article-mail
2238 "F" gnus-summary-write-article-file
2239 "r" gnus-summary-save-article-rmail
2240 "f" gnus-summary-save-article-file
2241 "b" gnus-summary-save-article-body-file
2242 "B" gnus-summary-write-article-body-file
2243 "h" gnus-summary-save-article-folder
2244 "v" gnus-summary-save-article-vm
2245 "p" gnus-summary-pipe-output
2246 "P" gnus-summary-muttprint)
2248 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2249 "b" gnus-summary-display-buttonized
2250 "m" gnus-summary-repair-multipart
2251 "v" gnus-article-view-part
2252 "o" gnus-article-save-part
2253 "O" gnus-article-save-part-and-strip
2254 "r" gnus-article-replace-part
2255 "d" gnus-article-delete-part
2256 "t" gnus-article-view-part-as-type
2257 "j" gnus-article-jump-to-part
2258 "c" gnus-article-copy-part
2259 "C" gnus-article-view-part-as-charset
2260 "e" gnus-article-view-part-externally
2261 "H" gnus-article-browse-html-article
2262 "E" gnus-article-encrypt-body
2263 "i" gnus-article-inline-part
2264 "|" gnus-article-pipe-part)
2266 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2267 "p" gnus-summary-mark-as-processable
2268 "u" gnus-summary-unmark-as-processable
2269 "U" gnus-summary-unmark-all-processable
2270 "v" gnus-uu-mark-over
2271 "s" gnus-uu-mark-series
2272 "r" gnus-uu-mark-region
2273 "g" gnus-uu-unmark-region
2274 "R" gnus-uu-mark-by-regexp
2275 "G" gnus-uu-unmark-by-regexp
2276 "t" gnus-uu-mark-thread
2277 "T" gnus-uu-unmark-thread
2278 "a" gnus-uu-mark-all
2279 "b" gnus-uu-mark-buffer
2280 "S" gnus-uu-mark-sparse
2281 "k" gnus-summary-kill-process-mark
2282 "y" gnus-summary-yank-process-mark
2283 "w" gnus-summary-save-process-mark
2284 "i" gnus-uu-invert-processable)
2286 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2287 ;;"x" gnus-uu-extract-any
2288 "m" gnus-summary-save-parts
2289 "u" gnus-uu-decode-uu
2290 "U" gnus-uu-decode-uu-and-save
2291 "s" gnus-uu-decode-unshar
2292 "S" gnus-uu-decode-unshar-and-save
2293 "o" gnus-uu-decode-save
2294 "O" gnus-uu-decode-save
2295 "b" gnus-uu-decode-binhex
2296 "B" gnus-uu-decode-binhex
2297 "Y" gnus-uu-decode-yenc
2298 "p" gnus-uu-decode-postscript
2299 "P" gnus-uu-decode-postscript-and-save)
2302 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2303 "u" gnus-uu-decode-uu-view
2304 "U" gnus-uu-decode-uu-and-save-view
2305 "s" gnus-uu-decode-unshar-view
2306 "S" gnus-uu-decode-unshar-and-save-view
2307 "o" gnus-uu-decode-save-view
2308 "O" gnus-uu-decode-save-view
2309 "b" gnus-uu-decode-binhex-view
2310 "B" gnus-uu-decode-binhex-view
2311 "p" gnus-uu-decode-postscript-view
2312 "P" gnus-uu-decode-postscript-and-save-view)
2314 (defvar gnus-article-post-menu nil)
2316 (defconst gnus-summary-menu-maxlen 20)
2318 (defun gnus-summary-menu-split (menu)
2319 ;; If we have lots of elements, divide them into groups of 20
2320 ;; and make a pane (or submenu) for each one.
2321 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2322 (let ((menu menu) sublists next
2325 ;; Pull off the next gnus-summary-menu-maxlen elements
2326 ;; and make them the next element of sublist.
2327 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2329 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2331 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2332 (aref (car (last menu)) 0)) menu)
2336 (nreverse sublists))
2337 ;; Few elements--put them all in one pane.
2340 (defun gnus-summary-make-menu-bar ()
2341 (gnus-turn-off-edit-menu 'summary)
2343 (unless (boundp 'gnus-summary-misc-menu)
2346 gnus-summary-kill-menu gnus-summary-mode-map ""
2351 ["Customize" gnus-score-customize t])
2352 (gnus-make-score-map 'increase)
2353 (gnus-make-score-map 'lower)
2355 ["Kill below" gnus-summary-kill-below t]
2356 ["Mark above" gnus-summary-mark-above t]
2357 ["Tick above" gnus-summary-tick-above t]
2358 ["Clear above" gnus-summary-clear-above t])
2359 ["Current article score" gnus-summary-current-score t]
2360 ["Current thread score" (gnus-summary-current-score 'total) t]
2361 ["Set score" gnus-summary-set-score t]
2362 ["Switch current score file..." gnus-score-change-score-file t]
2363 ["Set mark below..." gnus-score-set-mark-below t]
2364 ["Set expunge below..." gnus-score-set-expunge-below t]
2365 ["Edit current score file" gnus-score-edit-current-scores t]
2366 ["Edit score file..." gnus-score-edit-file t]
2367 ["Trace score" gnus-score-find-trace t]
2368 ["Find words" gnus-score-find-favourite-words t]
2369 ["Rescore buffer" gnus-summary-rescore t]
2370 ["Increase score..." gnus-summary-increase-score t]
2371 ["Lower score..." gnus-summary-lower-score t]))))
2373 ;; Define both the Article menu in the summary buffer and the
2374 ;; equivalent Commands menu in the article buffer here for
2378 ["All" gnus-article-hide t]
2379 ["Headers" gnus-article-hide-headers t]
2380 ["Signature" gnus-article-hide-signature t]
2381 ["Citation" gnus-article-hide-citation t]
2382 ["List identifiers" gnus-article-hide-list-identifiers t]
2383 ["Banner" gnus-article-strip-banner t]
2384 ["Boring headers" gnus-article-hide-boring-headers t])
2386 ["All" gnus-article-highlight t]
2387 ["Headers" gnus-article-highlight-headers t]
2388 ["Signature" gnus-article-highlight-signature t]
2389 ["Citation" gnus-article-highlight-citation t])
2391 ["Words" gnus-article-decode-mime-words t]
2392 ["Charset" gnus-article-decode-charset t]
2393 ["QP" gnus-article-de-quoted-unreadable t]
2394 ["Base64" gnus-article-de-base64-unreadable t]
2395 ["View MIME buttons" gnus-summary-display-buttonized t]
2396 ["View MIME buttons in header"
2397 gnus-mime-buttonize-attachments-in-header t]
2398 ["View all" gnus-mime-view-all-parts t]
2399 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2400 ["Encrypt body" gnus-article-encrypt-body
2401 :active (not (gnus-group-read-only-p))
2402 ,@(if (featurep 'xemacs) nil
2403 '(:help "Encrypt the message body on disk"))]
2404 ["Extract all parts..." gnus-summary-save-parts t]
2406 ["Repair multipart" gnus-summary-repair-multipart t]
2407 ["Pipe part..." gnus-article-pipe-part t]
2408 ["Inline part" gnus-article-inline-part t]
2409 ["View part as type..." gnus-article-view-part-as-type t]
2410 ["Encrypt body" gnus-article-encrypt-body
2411 :active (not (gnus-group-read-only-p))
2412 ,@(if (featurep 'xemacs) nil
2413 '(:help "Encrypt the message body on disk"))]
2414 ["View part externally" gnus-article-view-part-externally t]
2415 ["View HTML parts in browser" gnus-article-browse-html-article t]
2416 ["View part with charset..." gnus-article-view-part-as-charset t]
2417 ["Copy part" gnus-article-copy-part t]
2418 ["Save part..." gnus-article-save-part t]
2419 ["View part" gnus-article-view-part t]))
2421 ["Local" gnus-article-date-local t]
2422 ["ISO8601" gnus-article-date-iso8601 t]
2423 ["UT" gnus-article-date-ut t]
2424 ["Original" gnus-article-date-original t]
2425 ["Lapsed" gnus-article-date-lapsed t]
2426 ["User-defined" gnus-article-date-user t])
2428 ["Display HTML images" gnus-article-show-images t]
2429 ["Remove images" gnus-article-remove-images t]
2430 ["Toggle smiley" gnus-treat-smiley t]
2431 ["Show X-Face" gnus-article-display-x-face t]
2432 ["Show picons in From" gnus-treat-from-picon t]
2433 ["Show picons in mail headers" gnus-treat-mail-picon t]
2434 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2435 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2436 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2437 ("View as different encoding"
2438 ,@(gnus-summary-menu-split
2441 ;; Since easymenu under Emacs doesn't allow
2442 ;; lambda forms for menu commands, we should
2443 ;; provide intern'ed function symbols.
2444 (let ((command (intern (format "\
2445 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2449 (let ((gnus-summary-show-article-charset-alist
2451 (gnus-summary-show-article 1))))
2452 `[,(symbol-name cs) ,command t]))
2453 (sort (if (fboundp 'coding-system-list)
2454 (coding-system-list)
2455 (mapcar 'car mm-mime-mule-charset-alist))
2459 ["Leading" gnus-article-strip-leading-blank-lines t]
2460 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2461 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2462 ["All of the above" gnus-article-strip-blank-lines t]
2463 ["All" gnus-article-strip-all-blank-lines t]
2464 ["Leading space" gnus-article-strip-leading-space t]
2465 ["Trailing space" gnus-article-strip-trailing-space t]
2466 ["Leading space in headers"
2467 gnus-article-remove-leading-whitespace t])
2468 ["Overstrike" gnus-article-treat-overstrike t]
2469 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2470 ["Non-ASCII" gnus-article-treat-non-ascii t]
2471 ["Emphasis" gnus-article-emphasize t]
2472 ["Word wrap" gnus-article-fill-cited-article t]
2473 ["Fill long lines" gnus-article-fill-long-lines t]
2474 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2475 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2476 ["Remove CR" gnus-article-remove-cr t]
2477 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2478 ["Base64" gnus-article-de-base64-unreadable t]
2479 ["Rot 13" gnus-summary-caesar-message
2480 ,@(if (featurep 'xemacs) '(t)
2481 '(:help "\"Caesar rotate\" article by 13"))]
2482 ["De-IDNA" gnus-summary-idna-message t]
2483 ["Morse decode" gnus-summary-morse-message t]
2484 ["Unix pipe..." gnus-summary-pipe-message t]
2485 ["Add buttons" gnus-article-add-buttons t]
2486 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2487 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2488 ["Verbose header" gnus-summary-verbose-headers t]
2489 ["Toggle header" gnus-summary-toggle-header t]
2490 ["Unfold headers" gnus-article-treat-unfold-headers t]
2491 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2492 ["Html" gnus-article-wash-html t]
2493 ["Unsplit URLs" gnus-article-unsplit-urls t]
2494 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2495 ["Decode HZ" gnus-article-decode-HZ t]
2496 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2497 ("(Outlook) Deuglify"
2498 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2499 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2500 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2501 ["Full (Outlook) deuglify"
2502 gnus-article-outlook-deuglify-article t])
2505 ["Save in default format..." gnus-summary-save-article
2506 ,@(if (featurep 'xemacs) '(t)
2507 '(:help "Save article using default method"))]
2508 ["Save in file..." gnus-summary-save-article-file
2509 ,@(if (featurep 'xemacs) '(t)
2510 '(:help "Save article in file"))]
2511 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2512 ["Save in MH folder..." gnus-summary-save-article-folder t]
2513 ["Save in VM folder..." gnus-summary-save-article-vm t]
2514 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2515 ["Save body in file..." gnus-summary-save-article-body-file t]
2516 ["Pipe through a filter..." gnus-summary-pipe-output t]
2517 ["Print with Muttprint..." gnus-summary-muttprint t]
2518 ["Print" gnus-summary-print-article
2519 ,@(if (featurep 'xemacs) '(t)
2520 '(:help "Generate and print a PostScript image"))])
2521 ("Copy, move,... (Backend)"
2522 ,@(if (featurep 'xemacs) nil
2523 '(:help "Copying, moving, expiring articles..."))
2524 ["Respool article..." gnus-summary-respool-article t]
2525 ["Move article..." gnus-summary-move-article
2526 (gnus-check-backend-function
2527 'request-move-article gnus-newsgroup-name)]
2528 ["Copy article..." gnus-summary-copy-article t]
2529 ["Crosspost article..." gnus-summary-crosspost-article
2530 (gnus-check-backend-function
2531 'request-replace-article gnus-newsgroup-name)]
2532 ["Import file..." gnus-summary-import-article
2533 (gnus-check-backend-function
2534 'request-accept-article gnus-newsgroup-name)]
2535 ["Create article..." gnus-summary-create-article
2536 (gnus-check-backend-function
2537 'request-accept-article gnus-newsgroup-name)]
2538 ["Check if posted" gnus-summary-article-posted-p t]
2539 ["Edit article" gnus-summary-edit-article
2540 (not (gnus-group-read-only-p))]
2541 ["Delete article" gnus-summary-delete-article
2542 (gnus-check-backend-function
2543 'request-expire-articles gnus-newsgroup-name)]
2544 ["Query respool" gnus-summary-respool-query t]
2545 ["Trace respool" gnus-summary-respool-trace t]
2546 ["Delete expirable articles" gnus-summary-expire-articles-now
2547 (gnus-check-backend-function
2548 'request-expire-articles gnus-newsgroup-name)])
2550 ["Uudecode" gnus-uu-decode-uu
2551 ,@(if (featurep 'xemacs) '(t)
2552 '(:help "Decode uuencoded article(s)"))]
2553 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2554 ["Unshar" gnus-uu-decode-unshar t]
2555 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2556 ["Save" gnus-uu-decode-save t]
2557 ["Binhex" gnus-uu-decode-binhex t]
2558 ["PostScript" gnus-uu-decode-postscript t]
2559 ["All MIME parts" gnus-summary-save-parts t])
2561 ["Enter article" gnus-cache-enter-article t]
2562 ["Remove article" gnus-cache-remove-article t])
2563 ["Translate" gnus-article-babel t]
2564 ["Select article buffer" gnus-summary-select-article-buffer t]
2565 ["Make article buffer sticky" gnus-sticky-article t]
2566 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2567 ["Isearch article..." gnus-summary-isearch-article t]
2568 ["Beginning of the article" gnus-summary-beginning-of-article t]
2569 ["End of the article" gnus-summary-end-of-article t]
2570 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2571 ["Fetch referenced articles" gnus-summary-refer-references t]
2572 ["Fetch current thread" gnus-summary-refer-thread t]
2573 ["Fetch article with id..." gnus-summary-refer-article t]
2574 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2575 ["Redisplay" gnus-summary-show-article t]
2576 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2578 gnus-summary-article-menu gnus-summary-mode-map ""
2579 (cons "Article" innards))
2581 (if (not (keymapp gnus-summary-article-menu))
2583 gnus-article-commands-menu gnus-article-mode-map ""
2584 (cons "Commands" innards))
2585 ;; in Emacs, don't share menu.
2586 (setq gnus-article-commands-menu
2587 (copy-keymap gnus-summary-article-menu))
2588 (define-key gnus-article-mode-map [menu-bar commands]
2589 (cons "Commands" gnus-article-commands-menu))))
2592 gnus-summary-thread-menu gnus-summary-mode-map ""
2594 ["Find all messages in thread" gnus-summary-refer-thread t]
2595 ["Toggle threading" gnus-summary-toggle-threads t]
2596 ["Hide threads" gnus-summary-hide-all-threads t]
2597 ["Show threads" gnus-summary-show-all-threads t]
2598 ["Hide thread" gnus-summary-hide-thread t]
2599 ["Show thread" gnus-summary-show-thread t]
2600 ["Go to next thread" gnus-summary-next-thread t]
2601 ["Go to previous thread" gnus-summary-prev-thread t]
2602 ["Go down thread" gnus-summary-down-thread t]
2603 ["Go up thread" gnus-summary-up-thread t]
2604 ["Top of thread" gnus-summary-top-thread t]
2605 ["Mark thread as read" gnus-summary-kill-thread t]
2606 ["Mark thread as expired" gnus-summary-expire-thread t]
2607 ["Lower thread score" gnus-summary-lower-thread t]
2608 ["Raise thread score" gnus-summary-raise-thread t]
2609 ["Rethread current" gnus-summary-rethread-current t]))
2612 gnus-summary-post-menu gnus-summary-mode-map ""
2614 ["Send a message (mail or news)" gnus-summary-post-news
2615 ,@(if (featurep 'xemacs) '(t)
2616 '(:help "Compose a new message (mail or news)"))]
2617 ["Followup" gnus-summary-followup
2618 ,@(if (featurep 'xemacs) '(t)
2619 '(:help "Post followup to this article"))]
2620 ["Followup and yank" gnus-summary-followup-with-original
2621 ,@(if (featurep 'xemacs) '(t)
2622 '(:help "Post followup to this article, quoting its contents"))]
2623 ["Supersede article" gnus-summary-supersede-article t]
2624 ["Cancel article" gnus-summary-cancel-article
2625 ,@(if (featurep 'xemacs) '(t)
2626 '(:help "Cancel an article you posted"))]
2627 ["Reply" gnus-summary-reply t]
2628 ["Reply and yank" gnus-summary-reply-with-original t]
2629 ["Wide reply" gnus-summary-wide-reply t]
2630 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2631 ,@(if (featurep 'xemacs) '(t)
2632 '(:help "Mail a reply, quoting this article"))]
2633 ["Very wide reply" gnus-summary-very-wide-reply t]
2634 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2635 ,@(if (featurep 'xemacs) '(t)
2636 '(:help "Mail a very wide reply, quoting this article"))]
2637 ["Mail forward" gnus-summary-mail-forward t]
2638 ["Post forward" gnus-summary-post-forward t]
2639 ["Digest and mail" gnus-uu-digest-mail-forward t]
2640 ["Digest and post" gnus-uu-digest-post-forward t]
2641 ["Resend message" gnus-summary-resend-message t]
2642 ["Resend message edit" gnus-summary-resend-message-edit t]
2643 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2644 ["Send a mail" gnus-summary-mail-other-window t]
2645 ["Create a local message" gnus-summary-news-other-window t]
2646 ["Uuencode and post" gnus-uu-post-news
2647 ,@(if (featurep 'xemacs) '(t)
2648 '(:help "Post a uuencoded article"))]
2649 ["Followup via news" gnus-summary-followup-to-mail t]
2650 ["Followup via news and yank"
2651 gnus-summary-followup-to-mail-with-original t]
2652 ["Strip signature on reply"
2655 (if (not (memq message-cite-function
2656 '(message-cite-original-without-signature
2657 message-cite-original)))
2658 ;; Stupid workaround for XEmacs not honoring :visible.
2659 (message "Can't toggle this value of `message-cite-function'")
2660 (setq message-cite-function
2661 (if (eq message-cite-function
2662 'message-cite-original-without-signature)
2663 'message-cite-original
2664 'message-cite-original-without-signature))))
2665 ;; XEmacs barfs on :visible.
2666 ,@(if (featurep 'xemacs) nil
2667 '(:visible (memq message-cite-function
2668 '(message-cite-original-without-signature
2669 message-cite-original))))
2671 :selected (eq message-cite-function
2672 'message-cite-original-without-signature)
2673 ,@(if (featurep 'xemacs) nil
2674 '(:help "Strip signature from cited article when replying."))]
2676 ;;["Send" gnus-summary-send-draft t]
2677 ;;["Send bounced" gnus-resend-bounced-mail t])
2681 ((not (keymapp gnus-summary-post-menu))
2682 (setq gnus-article-post-menu gnus-summary-post-menu))
2683 ((not gnus-article-post-menu)
2684 ;; Don't share post menu.
2685 (setq gnus-article-post-menu
2686 (copy-keymap gnus-summary-post-menu))))
2687 (define-key gnus-article-mode-map [menu-bar post]
2688 (cons "Post" gnus-article-post-menu))
2691 gnus-summary-misc-menu gnus-summary-mode-map ""
2694 ["Mark as read" gnus-summary-mark-as-read-forward t]
2695 ["Mark same subject and select"
2696 gnus-summary-kill-same-subject-and-select t]
2697 ["Mark same subject" gnus-summary-kill-same-subject t]
2698 ["Catchup" gnus-summary-catchup
2699 ,@(if (featurep 'xemacs) '(t)
2700 '(:help "Mark unread articles in this group as read"))]
2701 ["Catchup all" gnus-summary-catchup-all t]
2702 ["Catchup to here" gnus-summary-catchup-to-here t]
2703 ["Catchup from here" gnus-summary-catchup-from-here t]
2704 ["Catchup region" gnus-summary-mark-region-as-read
2705 (gnus-mark-active-p)]
2706 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2708 ["Tick" gnus-summary-tick-article-forward t]
2709 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2710 ["Remove marks" gnus-summary-clear-mark-forward t]
2711 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2712 ["Set bookmark" gnus-summary-set-bookmark t]
2713 ["Remove bookmark" gnus-summary-remove-bookmark t])
2715 ["Marks..." gnus-summary-limit-to-marks t]
2716 ["Subject..." gnus-summary-limit-to-subject t]
2717 ["Author..." gnus-summary-limit-to-author t]
2718 ["Recipient..." gnus-summary-limit-to-recipient t]
2719 ["Address..." gnus-summary-limit-to-address t]
2720 ["Age..." gnus-summary-limit-to-age t]
2721 ["Extra..." gnus-summary-limit-to-extra t]
2722 ["Score..." gnus-summary-limit-to-score t]
2723 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2724 ["Unread" gnus-summary-limit-to-unread t]
2725 ["Unseen" gnus-summary-limit-to-unseen t]
2726 ["Singletons" gnus-summary-limit-to-singletons t]
2727 ["Replied" gnus-summary-limit-to-replied t]
2728 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2729 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2730 ["Pop limit" gnus-summary-pop-limit t]
2731 ["Show dormant" gnus-summary-limit-include-dormant t]
2732 ["Hide childless dormant"
2733 gnus-summary-limit-exclude-childless-dormant t]
2734 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2735 ["Hide marked" gnus-summary-limit-exclude-marks t]
2736 ["Show expunged" gnus-summary-limit-include-expunged t])
2738 ["Set mark" gnus-summary-mark-as-processable t]
2739 ["Remove mark" gnus-summary-unmark-as-processable t]
2740 ["Remove all marks" gnus-summary-unmark-all-processable t]
2741 ["Invert marks" gnus-uu-invert-processable t]
2742 ["Mark above" gnus-uu-mark-over t]
2743 ["Mark series" gnus-uu-mark-series t]
2744 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2745 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2746 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2747 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2748 ["Mark all" gnus-uu-mark-all t]
2749 ["Mark buffer" gnus-uu-mark-buffer t]
2750 ["Mark sparse" gnus-uu-mark-sparse t]
2751 ["Mark thread" gnus-uu-mark-thread t]
2752 ["Unmark thread" gnus-uu-unmark-thread t]
2753 ("Process Mark Sets"
2754 ["Kill" gnus-summary-kill-process-mark t]
2755 ["Yank" gnus-summary-yank-process-mark
2756 gnus-newsgroup-process-stack]
2757 ["Save" gnus-summary-save-process-mark t]
2758 ["Run command on marked..." gnus-summary-universal-argument t]))
2761 ["Page forward" gnus-summary-next-page
2762 ,@(if (featurep 'xemacs) '(t)
2763 '(:help "Show next page of article"))]
2764 ["Page backward" gnus-summary-prev-page
2765 ,@(if (featurep 'xemacs) '(t)
2766 '(:help "Show previous page of article"))]
2767 ["Line forward" gnus-summary-scroll-up t])
2769 ["Next unread article" gnus-summary-next-unread-article t]
2770 ["Previous unread article" gnus-summary-prev-unread-article t]
2771 ["Next article" gnus-summary-next-article t]
2772 ["Previous article" gnus-summary-prev-article t]
2773 ["Next unread subject" gnus-summary-next-unread-subject t]
2774 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2775 ["Next article same subject" gnus-summary-next-same-subject t]
2776 ["Previous article same subject" gnus-summary-prev-same-subject t]
2777 ["First unread article" gnus-summary-first-unread-article t]
2778 ["Best unread article" gnus-summary-best-unread-article t]
2779 ["Go to subject number..." gnus-summary-goto-subject t]
2780 ["Go to article number..." gnus-summary-goto-article t]
2781 ["Go to the last article" gnus-summary-goto-last-article t]
2782 ["Pop article off history" gnus-summary-pop-article t])
2784 ["Sort by number" gnus-summary-sort-by-number t]
2785 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2786 ["Sort by author" gnus-summary-sort-by-author t]
2787 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2788 ["Sort by subject" gnus-summary-sort-by-subject t]
2789 ["Sort by date" gnus-summary-sort-by-date t]
2790 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2791 ["Sort by score" gnus-summary-sort-by-score t]
2792 ["Sort by lines" gnus-summary-sort-by-lines t]
2793 ["Sort by characters" gnus-summary-sort-by-chars t]
2794 ["Randomize" gnus-summary-sort-by-random t]
2795 ["Original sort" gnus-summary-sort-by-original t])
2797 ["Describe group" gnus-summary-describe-group t]
2798 ["Read manual" gnus-info-find-node t])
2800 ["Pick and read" gnus-pick-mode t]
2801 ["Binary" gnus-binary-mode t])
2803 ["Regenerate" gnus-summary-prepare t]
2804 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2805 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2806 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2807 ["Toggle threading" gnus-summary-toggle-threads t])
2808 ["See old articles" gnus-summary-insert-old-articles t]
2809 ["See new articles" gnus-summary-insert-new-articles t]
2810 ["Filter articles..." gnus-summary-execute-command t]
2811 ["Run command on articles..." gnus-summary-universal-argument t]
2812 ["Search articles forward..." gnus-summary-search-article-forward t]
2813 ["Search articles backward..." gnus-summary-search-article-backward t]
2814 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2815 ["Expand window" gnus-summary-expand-window t]
2816 ["Expire expirable articles" gnus-summary-expire-articles
2817 (gnus-check-backend-function
2818 'request-expire-articles gnus-newsgroup-name)]
2819 ["Edit local kill file" gnus-summary-edit-local-kill t]
2820 ["Edit main kill file" gnus-summary-edit-global-kill t]
2821 ["Edit group parameters" gnus-summary-edit-parameters t]
2822 ["Customize group parameters" gnus-summary-customize-parameters t]
2823 ["Send a bug report" gnus-bug t]
2825 ["Catchup and exit" gnus-summary-catchup-and-exit
2826 ,@(if (featurep 'xemacs) '(t)
2827 '(:help "Mark unread articles in this group as read, then exit"))]
2828 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2829 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2830 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2831 ["Exit group" gnus-summary-exit
2832 ,@(if (featurep 'xemacs) '(t)
2833 '(:help "Exit current group, return to group selection mode"))]
2834 ["Exit group without updating" gnus-summary-exit-no-update t]
2835 ["Exit and goto next group" gnus-summary-next-group t]
2836 ["Exit and goto prev group" gnus-summary-prev-group t]
2837 ["Reselect group" gnus-summary-reselect-current-group t]
2838 ["Rescan group" gnus-summary-rescan-group t]
2839 ["Update dribble" gnus-summary-save-newsrc t])))
2841 (gnus-run-hooks 'gnus-summary-menu-hook)))
2843 (defvar gnus-summary-tool-bar-map nil)
2845 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2846 ;; affect _new_ message buffers. We might add a function that walks thru all
2847 ;; summary-mode buffers and force the update.
2848 (defun gnus-summary-tool-bar-update (&optional symbol value)
2849 "Update summary mode toolbar.
2850 Setter function for custom variables."
2851 (setq-default gnus-summary-tool-bar-map nil)
2853 ;; When used as ":set" function:
2854 (set-default symbol value))
2855 (when (gnus-buffer-live-p gnus-summary-buffer)
2856 (with-current-buffer gnus-summary-buffer
2857 (gnus-summary-make-tool-bar))))
2859 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2860 'gnus-summary-tool-bar-gnome
2861 'gnus-summary-tool-bar-retro)
2862 "Specifies the Gnus summary tool bar.
2864 It can be either a list or a symbol referring to a list. See
2865 `gmm-tool-bar-from-list' for the format of the list. The
2866 default key map is `gnus-summary-mode-map'.
2868 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2869 `gnus-summary-tool-bar-retro'."
2870 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2871 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2872 (repeat :tag "User defined list" gmm-tool-bar-item)
2874 :version "23.1" ;; No Gnus
2875 :initialize 'custom-initialize-default
2876 :set 'gnus-summary-tool-bar-update
2877 :group 'gnus-summary)
2879 (defcustom gnus-summary-tool-bar-gnome
2880 '((gnus-summary-post-news "mail/compose" nil)
2881 (gnus-summary-insert-new-articles "mail/inbox" nil
2882 :visible (or (not gnus-agent)
2884 (gnus-summary-reply-with-original "mail/reply")
2885 (gnus-summary-reply "mail/reply" nil :visible nil)
2886 (gnus-summary-followup-with-original "mail/reply-all")
2887 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2888 (gnus-summary-mail-forward "mail/forward")
2889 (gnus-summary-save-article "mail/save")
2890 (gnus-summary-search-article-forward "search" nil :visible nil)
2891 (gnus-summary-print-article "print")
2892 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2893 ;; Some new commands that may need more suitable icons:
2894 (gnus-summary-save-newsrc "save" nil :visible nil)
2895 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2896 (gnus-summary-prev-article "left-arrow")
2897 (gnus-summary-next-article "right-arrow")
2898 (gnus-summary-next-page "next-page")
2899 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2901 ;; Maybe some sort-by-... could be added:
2902 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2903 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2904 (gnus-summary-mark-as-expirable
2906 :visible (gnus-check-backend-function 'request-expire-articles
2907 gnus-newsgroup-name))
2908 (gnus-summary-mark-as-spam
2910 :visible (and (fboundp 'spam-group-ham-contents-p)
2911 (spam-group-ham-contents-p gnus-newsgroup-name))
2912 :help "Mark as spam")
2913 (gnus-summary-mark-as-read-forward
2915 :visible (and (fboundp 'spam-group-spam-contents-p)
2916 (spam-group-spam-contents-p gnus-newsgroup-name)))
2918 (gnus-summary-exit "exit")
2919 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2920 (gnus-info-find-node "help"))
2921 "List of functions for the summary tool bar (GNOME style).
2923 See `gmm-tool-bar-from-list' for the format of the list."
2924 :type '(repeat gmm-tool-bar-item)
2925 :version "23.1" ;; No Gnus
2926 :initialize 'custom-initialize-default
2927 :set 'gnus-summary-tool-bar-update
2928 :group 'gnus-summary)
2930 (defcustom gnus-summary-tool-bar-retro
2931 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2932 (gnus-summary-next-unread-article "gnus/next-ur")
2933 (gnus-summary-post-news "gnus/post")
2934 (gnus-summary-followup-with-original "gnus/fuwo")
2935 (gnus-summary-followup "gnus/followup")
2936 (gnus-summary-reply-with-original "gnus/reply-wo")
2937 (gnus-summary-reply "gnus/reply")
2938 (gnus-summary-caesar-message "gnus/rot13")
2939 (gnus-uu-decode-uu "gnus/uu-decode")
2940 (gnus-summary-save-article-file "gnus/save-aif")
2941 (gnus-summary-save-article "gnus/save-art")
2942 (gnus-uu-post-news "gnus/uu-post")
2943 (gnus-summary-catchup "gnus/catchup")
2944 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2945 (gnus-summary-exit "gnus/exit-summ")
2946 ;; Some new command that may need more suitable icons:
2947 (gnus-summary-print-article "gnus/print" nil :visible nil)
2948 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2949 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2950 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2951 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2952 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2953 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2955 (gnus-info-find-node "gnus/help" nil :visible nil))
2956 "List of functions for the summary tool bar (retro look).
2958 See `gmm-tool-bar-from-list' for the format of the list."
2959 :type '(repeat gmm-tool-bar-item)
2960 :version "23.1" ;; No Gnus
2961 :initialize 'custom-initialize-default
2962 :set 'gnus-summary-tool-bar-update
2963 :group 'gnus-summary)
2965 (defcustom gnus-summary-tool-bar-zap-list t
2966 "List of icon items from the global tool bar.
2967 These items are not displayed in the Gnus summary mode tool bar.
2969 See `gmm-tool-bar-from-list' for the format of the list."
2970 :type 'gmm-tool-bar-zap-list
2971 :version "23.1" ;; No Gnus
2972 :initialize 'custom-initialize-default
2973 :set 'gnus-summary-tool-bar-update
2974 :group 'gnus-summary)
2976 (defvar image-load-path)
2977 (defvar tool-bar-map)
2979 (defun gnus-summary-make-tool-bar (&optional force)
2980 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2981 When FORCE, rebuild the tool bar."
2982 (when (and (not (featurep 'xemacs))
2983 (boundp 'tool-bar-mode)
2985 (or (not gnus-summary-tool-bar-map) force))
2987 (gmm-image-load-path-for-library "gnus"
2990 (image-load-path (cons (car load-path)
2991 (when (boundp 'image-load-path)
2993 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2994 gnus-summary-tool-bar-zap-list
2995 'gnus-summary-mode-map)))
2997 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2999 (setq gnus-summary-tool-bar-map map))))
3000 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
3002 (defun gnus-make-score-map (type)
3003 "Make a summary score map of type TYPE."
3006 (let ((headers '(("author" "from" string)
3007 ("subject" "subject" string)
3008 ("article body" "body" string)
3009 ("article head" "head" string)
3010 ("xref" "xref" string)
3011 ("extra header" "extra" string)
3012 ("lines" "lines" number)
3013 ("followups to author" "followup" string)))
3014 (types '((number ("less than" <)
3017 (string ("substring" s)
3021 (perms '(("temporary" (current-time-string))
3029 (if (eq type 'lower)
3034 (setq header (car headers))
3040 (let ((ts (cdr (assoc (nth 2 header) types)))
3056 'gnus-summary-score-entry
3058 (if (or (string= (nth 1 header)
3060 (string= (nth 1 header)
3063 (list 'gnus-summary-header
3065 (list 'quote (nth 1 (car ts)))
3066 (list 'gnus-score-delta-default
3073 (list (nreverse outp))))
3076 (list (nreverse outt))))
3078 (setq headers (cdr headers)))
3079 (list (nreverse outh))))))))
3082 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3083 (defvar bookmark-make-record-function)
3085 (defvar bidi-paragraph-direction)
3087 (defun gnus-summary-mode (&optional group)
3088 "Major mode for reading articles.
3090 All normal editing commands are switched off.
3091 \\<gnus-summary-mode-map>
3092 Each line in this buffer represents one article. To read an
3093 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3094 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3097 You can also post articles and send mail from this buffer. To
3098 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3099 of an article, type `\\[gnus-summary-reply]'.
3101 There are approx. one gazillion commands you can execute in this
3102 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3104 The following commands are available:
3106 \\{gnus-summary-mode-map}"
3107 ;; FIXME: Use define-derived-mode.
3109 (kill-all-local-variables)
3110 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3111 (gnus-summary-make-local-variables))
3112 (gnus-summary-make-local-variables)
3113 (setq gnus-newsgroup-name group)
3114 (when (gnus-visual-p 'summary-menu 'menu)
3115 (gnus-summary-make-menu-bar)
3116 (gnus-summary-make-tool-bar))
3117 (gnus-make-thread-indent-array)
3118 (gnus-simplify-mode-line)
3119 (setq major-mode 'gnus-summary-mode)
3120 (setq mode-name "Summary")
3121 (use-local-map gnus-summary-mode-map)
3122 (buffer-disable-undo)
3123 (setq buffer-read-only t ;Disable modification
3124 show-trailing-whitespace nil)
3125 (setq truncate-lines t)
3126 ;; Force paragraph direction to be left-to-right. Don't make it
3127 ;; bound globally in old Emacsen and XEmacsen.
3128 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3129 (add-to-invisibility-spec '(gnus-sum . t))
3130 (gnus-summary-set-display-table)
3131 (gnus-set-default-directory)
3132 (make-local-variable 'gnus-summary-line-format)
3133 (make-local-variable 'gnus-summary-line-format-spec)
3134 (make-local-variable 'gnus-summary-dummy-line-format)
3135 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3136 (make-local-variable 'gnus-summary-mark-positions)
3137 (gnus-make-local-hook 'pre-command-hook)
3138 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3139 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3140 (turn-on-gnus-mailing-list-mode)
3141 (mm-enable-multibyte)
3142 (set (make-local-variable 'bookmark-make-record-function)
3143 'gnus-summary-bookmark-make-record)
3144 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3145 (gnus-update-summary-mark-positions))
3147 (defun gnus-summary-make-local-variables ()
3148 "Make all the local summary buffer variables."
3150 (dolist (local gnus-summary-local-variables)
3153 (if (eq (cdr local) 'global)
3154 ;; Copy the global value of the variable.
3155 (setq global (symbol-value (car local)))
3156 ;; Use the value from the list.
3157 (setq global (eval (cdr local))))
3158 (set (make-local-variable (car local)) global))
3159 ;; Simple nil-valued local variable.
3160 (set (make-local-variable local) nil)))))
3162 ;; Summary data functions.
3164 (defmacro gnus-data-number (data)
3167 (defmacro gnus-data-set-number (data number)
3168 `(setcar ,data ,number))
3170 (defmacro gnus-data-mark (data)
3173 (defmacro gnus-data-set-mark (data mark)
3174 `(setcar (nthcdr 1 ,data) ,mark))
3176 (defmacro gnus-data-pos (data)
3179 (defmacro gnus-data-set-pos (data pos)
3180 `(setcar (nthcdr 2 ,data) ,pos))
3182 (defmacro gnus-data-header (data)
3185 (defmacro gnus-data-set-header (data header)
3186 `(setf (nth 3 ,data) ,header))
3188 (defmacro gnus-data-level (data)
3191 (defmacro gnus-data-unread-p (data)
3192 `(= (nth 1 ,data) gnus-unread-mark))
3194 (defmacro gnus-data-read-p (data)
3195 `(/= (nth 1 ,data) gnus-unread-mark))
3197 (defmacro gnus-data-pseudo-p (data)
3198 `(consp (nth 3 ,data)))
3200 (defmacro gnus-data-find (number)
3201 `(assq ,number gnus-newsgroup-data))
3203 (defmacro gnus-data-find-list (number &optional data)
3204 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3205 (memq (assq ,number bdata)
3208 (defmacro gnus-data-make (number mark pos header level)
3209 `(list ,number ,mark ,pos ,header ,level))
3211 (defun gnus-data-enter (after-article number mark pos header level offset)
3212 (let ((data (gnus-data-find-list after-article)))
3214 (error "No such article: %d" after-article))
3215 (setcdr data (cons (gnus-data-make number mark pos header level)
3217 (setq gnus-newsgroup-data-reverse nil)
3218 (gnus-data-update-list (cddr data) offset)))
3220 (defun gnus-data-enter-list (after-article list &optional offset)
3222 (let ((data (and after-article (gnus-data-find-list after-article)))
3226 (let ((odata gnus-newsgroup-data))
3227 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3229 (gnus-data-update-list odata offset)))
3230 ;; Find the last element in the list to be spliced into the main
3232 (setq list (last list))
3235 (setcdr list gnus-newsgroup-data)
3236 (setq gnus-newsgroup-data ilist)
3238 (gnus-data-update-list (cdr list) offset)))
3239 (setcdr list (cdr data))
3242 (gnus-data-update-list (cdr list) offset))))
3243 (setq gnus-newsgroup-data-reverse nil))))
3245 (defun gnus-data-remove (article &optional offset)
3246 (let ((data gnus-newsgroup-data))
3247 (if (= (gnus-data-number (car data)) article)
3249 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3250 gnus-newsgroup-data-reverse nil)
3252 (gnus-data-update-list gnus-newsgroup-data offset)))
3254 (when (= (gnus-data-number (cadr data)) article)
3255 (setcdr data (cddr data))
3257 (gnus-data-update-list (cdr data) offset))
3259 gnus-newsgroup-data-reverse nil))
3260 (setq data (cdr data))))))
3262 (defmacro gnus-data-list (backward)
3264 (or gnus-newsgroup-data-reverse
3265 (setq gnus-newsgroup-data-reverse
3266 (reverse gnus-newsgroup-data)))
3267 gnus-newsgroup-data))
3269 (defun gnus-data-update-list (data offset)
3270 "Add OFFSET to the POS of all data entries in DATA."
3271 (setq gnus-newsgroup-data-reverse nil)
3273 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3274 (setq data (cdr data))))
3276 (defun gnus-summary-article-pseudo-p (article)
3277 "Say whether this article is a pseudo article or not."
3278 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3280 (defmacro gnus-summary-article-sparse-p (article)
3281 "Say whether this article is a sparse article or not."
3282 `(memq ,article gnus-newsgroup-sparse))
3284 (defmacro gnus-summary-article-ancient-p (article)
3285 "Say whether this article is a sparse article or not."
3286 `(memq ,article gnus-newsgroup-ancient))
3288 (defun gnus-article-children (number)
3289 "Return a list of all children to NUMBER."
3290 (let* ((data (gnus-data-find-list number))
3291 (level (gnus-data-level (car data)))
3293 (setq data (cdr data))
3295 (= (gnus-data-level (car data)) (1+ level)))
3296 (push (gnus-data-number (car data)) children)
3297 (setq data (cdr data)))
3300 (defmacro gnus-summary-skip-intangible ()
3301 "If the current article is intangible, then jump to a different article."
3302 '(let ((to (get-text-property (point) 'gnus-intangible)))
3303 (and to (gnus-summary-goto-subject to))))
3305 (defmacro gnus-summary-article-intangible-p ()
3306 "Say whether this article is intangible or not."
3307 '(get-text-property (point) 'gnus-intangible))
3309 ;; Some summary mode macros.
3311 (defmacro gnus-summary-article-number ()
3312 "The article number of the article on the current line.
3313 If there isn't an article number here, then we return the current
3316 (gnus-summary-skip-intangible)
3317 (or (get-text-property (point) 'gnus-number)
3318 (gnus-summary-last-subject))))
3320 (defmacro gnus-summary-article-header (&optional number)
3321 "Return the header of article NUMBER."
3322 `(gnus-data-header (gnus-data-find
3323 ,(or number '(gnus-summary-article-number)))))
3325 (defmacro gnus-summary-thread-level (&optional number)
3326 "Return the level of thread that starts with article NUMBER."
3327 `(if (and (eq gnus-summary-make-false-root 'dummy)
3328 (get-text-property (point) 'gnus-intangible))
3330 (gnus-data-level (gnus-data-find
3331 ,(or number '(gnus-summary-article-number))))))
3333 (defmacro gnus-summary-article-mark (&optional number)
3334 "Return the mark of article NUMBER."
3335 `(gnus-data-mark (gnus-data-find
3336 ,(or number '(gnus-summary-article-number)))))
3338 (defmacro gnus-summary-article-pos (&optional number)
3339 "Return the position of the line of article NUMBER."
3340 `(gnus-data-pos (gnus-data-find
3341 ,(or number '(gnus-summary-article-number)))))
3343 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3344 (defmacro gnus-summary-article-subject (&optional number)
3345 "Return current subject string or nil if nothing."
3348 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3349 '(gnus-data-header (assq (gnus-summary-article-number)
3350 gnus-newsgroup-data)))))
3353 (mail-header-subject headers))))
3355 (defmacro gnus-summary-article-score (&optional number)
3356 "Return current article score."
3357 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3358 gnus-newsgroup-scored))
3359 gnus-summary-default-score 0))
3361 (defun gnus-summary-article-children (&optional number)
3362 "Return a list of article numbers that are children of article NUMBER."
3363 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3364 (level (gnus-data-level (car data)))
3366 (while (and (setq data (cdr data))
3367 (> (setq l (gnus-data-level (car data))) level))
3368 (and (= (1+ level) l)
3369 (push (gnus-data-number (car data))
3371 (nreverse children)))
3373 (defun gnus-summary-article-parent (&optional number)
3374 "Return the article number of the parent of article NUMBER."
3375 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3376 (gnus-data-list t)))
3377 (level (gnus-data-level (car data))))
3379 () ; This is a root.
3380 ;; We search until we find an article with a level less than
3381 ;; this one. That function has to be the parent.
3382 (while (and (setq data (cdr data))
3383 (not (< (gnus-data-level (car data)) level))))
3384 (and data (gnus-data-number (car data))))))
3386 (defun gnus-unread-mark-p (mark)
3387 "Say whether MARK is the unread mark."
3388 (= mark gnus-unread-mark))
3390 (defun gnus-read-mark-p (mark)
3391 "Say whether MARK is one of the marks that mark as read.
3392 This is all marks except unread, ticked, dormant, and expirable."
3393 (not (or (= mark gnus-unread-mark)
3394 (= mark gnus-ticked-mark)
3395 (= mark gnus-spam-mark)
3396 (= mark gnus-dormant-mark)
3397 (= mark gnus-expirable-mark))))
3399 (defmacro gnus-article-mark (number)
3400 "Return the MARK of article NUMBER.
3401 This macro should only be used when computing the mark the \"first\"
3402 time; i.e., when generating the summary lines. After that,
3403 `gnus-summary-article-mark' should be used to examine the
3406 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3407 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3408 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3409 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3410 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3411 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3412 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3413 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3414 gnus-ancient-mark))))
3416 ;; Saving hidden threads.
3418 (defmacro gnus-save-hidden-threads (&rest forms)
3419 "Save hidden threads, eval FORMS, and restore the hidden threads."
3420 (let ((config (make-symbol "config")))
3421 `(let ((,config (gnus-hidden-threads-configuration)))
3425 (gnus-restore-hidden-threads-configuration ,config)))))
3426 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3427 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3429 (defun gnus-data-compute-positions ()
3430 "Compute the positions of all articles."
3431 (setq gnus-newsgroup-data-reverse nil)
3432 (let ((data gnus-newsgroup-data))
3434 (gnus-save-hidden-threads
3435 (gnus-summary-show-all-threads)
3436 (goto-char (point-min))
3438 (while (get-text-property (point) 'gnus-intangible)
3440 (gnus-data-set-pos (car data) (+ (point) 3))
3441 (setq data (cdr data))
3442 (forward-line 1))))))
3444 (defun gnus-hidden-threads-configuration ()
3445 "Return the current hidden threads configuration."
3448 (goto-char (point-min))
3450 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3451 (push (save-excursion (forward-line 0) (point)) config))
3455 (defun gnus-restore-hidden-threads-configuration (config)
3456 "Restore hidden threads configuration from CONFIG."
3458 (let (point (inhibit-read-only t))
3459 (while (setq point (pop config))
3461 (gnus-summary-hide-thread)))))
3463 ;; Various summary mode internalish functions.
3465 (defun gnus-mouse-pick-article (e)
3468 (gnus-summary-next-page nil t))
3470 (defun gnus-summary-set-display-table ()
3471 "Change the display table.
3472 Odd characters have a tendency to mess
3473 up nicely formatted displays - we make all possible glyphs
3474 display only a single character."
3476 ;; We start from the standard display table, if any.
3477 (let ((table (or (copy-sequence standard-display-table)
3478 (make-display-table)))
3480 ;; Nix out all the control chars...
3481 (while (>= (setq i (1- i)) 0)
3482 (gnus-put-display-table i [??] table))
3483 ;; ... but not newline and cr, of course. (cr is necessary for the
3484 ;; selective display).
3485 (gnus-put-display-table ?\n nil table)
3486 (gnus-put-display-table ?\r nil table)
3487 ;; We keep TAB as well.
3488 (gnus-put-display-table ?\t nil table)
3489 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3490 ;; Emacs 23 (unicode), that are not set already.
3491 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3494 (while (>= (setq i (1- i)) 127)
3495 ;; Only modify if the entry is nil.
3496 (unless (gnus-get-display-table i table)
3497 (gnus-put-display-table i [??] table))))
3498 (setq buffer-display-table table)))
3500 (defun gnus-summary-set-article-display-arrow (pos)
3501 "Update the overlay arrow to point to line at position POS."
3502 (when gnus-summary-display-arrow
3503 (make-local-variable 'overlay-arrow-position)
3504 (make-local-variable 'overlay-arrow-string)
3508 (unless overlay-arrow-position
3509 (setq overlay-arrow-position (make-marker)))
3510 (setq overlay-arrow-string "=>"
3511 overlay-arrow-position (set-marker overlay-arrow-position
3513 (current-buffer))))))
3515 (defun gnus-summary-setup-buffer (group)
3516 "Initialize summary buffer.
3517 If the setup was successful, non-nil is returned."
3518 (let ((buffer (gnus-summary-buffer-name group))
3519 (dead-name (concat "*Dead Summary "
3520 (gnus-group-decoded-name group) "*")))
3521 ;; If a dead summary buffer exists, we kill it.
3522 (when (gnus-buffer-live-p dead-name)
3523 (gnus-kill-buffer dead-name))
3524 (if (get-buffer buffer)
3527 (setq gnus-summary-buffer (current-buffer))
3528 (not gnus-newsgroup-prepared))
3529 (set-buffer (gnus-get-buffer-create buffer))
3530 (setq gnus-summary-buffer (current-buffer))
3531 (gnus-summary-mode group)
3532 (when (gnus-group-quit-config group)
3533 (set (make-local-variable 'gnus-single-article-buffer) nil))
3534 (make-local-variable 'gnus-article-buffer)
3535 (make-local-variable 'gnus-article-current)
3536 (make-local-variable 'gnus-original-article-buffer)
3537 (setq gnus-newsgroup-name group)
3538 ;; Set any local variables in the group parameters.
3539 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3542 (defun gnus-set-global-variables ()
3543 "Set the global equivalents of the buffer-local variables.
3544 They are set to the latest values they had. These reflect the summary
3545 buffer that was in action when the last article was fetched."
3546 (when (derived-mode-p 'gnus-summary-mode)
3547 (setq gnus-summary-buffer (current-buffer))
3548 (let ((name gnus-newsgroup-name)
3549 (marked gnus-newsgroup-marked)
3550 (spam gnus-newsgroup-spam-marked)
3551 (unread gnus-newsgroup-unreads)
3552 (headers gnus-current-headers)
3553 (data gnus-newsgroup-data)
3554 (summary gnus-summary-buffer)
3555 (article-buffer gnus-article-buffer)
3556 (original gnus-original-article-buffer)
3557 (gac gnus-article-current)
3558 (reffed gnus-reffed-article-number)
3559 (score-file gnus-current-score-file)
3560 (default-charset gnus-newsgroup-charset)
3562 (let ((locals gnus-newsgroup-variables))
3564 (if (consp (car locals))
3565 (push (eval (caar locals)) vlist)
3566 (push (eval (car locals)) vlist))
3567 (setq locals (cdr locals)))
3568 (setq vlist (nreverse vlist)))
3570 (setq gnus-newsgroup-name name
3571 gnus-newsgroup-marked marked
3572 gnus-newsgroup-spam-marked spam
3573 gnus-newsgroup-unreads unread
3574 gnus-current-headers headers
3575 gnus-newsgroup-data data
3576 gnus-article-current gac
3577 gnus-summary-buffer summary
3578 gnus-article-buffer article-buffer
3579 gnus-original-article-buffer original
3580 gnus-reffed-article-number reffed
3581 gnus-current-score-file score-file
3582 gnus-newsgroup-charset default-charset)
3583 (let ((locals gnus-newsgroup-variables))
3585 (if (consp (car locals))
3586 (set (caar locals) (pop vlist))
3587 (set (car locals) (pop vlist)))
3588 (setq locals (cdr locals))))))))
3590 (defun gnus-summary-article-unread-p (article)
3591 "Say whether ARTICLE is unread or not."
3592 (memq article gnus-newsgroup-unreads))
3594 (defun gnus-summary-first-article-p (&optional article)
3595 "Return whether ARTICLE is the first article in the buffer."
3596 (if (not (setq article (or article (gnus-summary-article-number))))
3598 (eq article (caar gnus-newsgroup-data))))
3600 (defun gnus-summary-last-article-p (&optional article)
3601 "Return whether ARTICLE is the last article in the buffer."
3602 (if (not (setq article (or article (gnus-summary-article-number))))
3603 ;; All non-existent numbers are the last article. :-)
3605 (not (cdr (gnus-data-find-list article)))))
3607 (defun gnus-make-thread-indent-array (&optional n)
3609 (progn (setq n 200) nil)
3610 (null gnus-thread-indent-array)
3611 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3612 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3613 gnus-thread-indent-array-level gnus-thread-indent-level)
3615 (aset gnus-thread-indent-array n
3616 (make-string (* n gnus-thread-indent-level) ? ))
3619 (defun gnus-update-summary-mark-positions ()
3620 "Compute where the summary marks are to go."
3622 (when (gnus-buffer-exists-p gnus-summary-buffer)
3623 (set-buffer gnus-summary-buffer))
3624 (let ((spec gnus-summary-line-format-spec)
3627 (gnus-set-work-buffer)
3628 (let ((gnus-tmp-unread ?Z)
3629 (gnus-replied-mark ?Z)
3630 (gnus-score-below-mark ?Z)
3631 (gnus-score-over-mark ?Z)
3632 (gnus-undownloaded-mark ?Z)
3633 (gnus-summary-line-format-spec spec)
3634 (gnus-newsgroup-downloadable '(0))
3635 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3636 case-fold-search ignores)
3637 ;; Here, all marks are bound to Z.
3638 (gnus-summary-insert-line header
3639 0 nil t gnus-tmp-unread t nil "" nil 1)
3640 (goto-char (point-min))
3641 ;; Memorize the positions of the same characters as dummy marks.
3642 (while (re-search-forward "[A-D]" nil t)
3643 (push (point) ignores))
3645 ;; We use A-D as dummy marks in order to know column positions
3646 ;; where marks should be inserted.
3647 (setq gnus-tmp-unread ?A
3648 gnus-replied-mark ?B
3649 gnus-score-below-mark ?C
3650 gnus-score-over-mark ?C
3651 gnus-undownloaded-mark ?D)
3652 (gnus-summary-insert-line header
3653 0 nil t gnus-tmp-unread t nil "" nil 1)
3654 ;; Ignore characters which aren't dummy marks.
3656 (delete-region (goto-char (1- p)) p)
3658 (goto-char (point-min))
3659 (setq pos (list (cons 'unread
3660 (and (search-forward "A" nil t)
3661 (- (point) (point-min) 1)))))
3662 (goto-char (point-min))
3663 (push (cons 'replied (and (search-forward "B" nil t)
3664 (- (point) (point-min) 1)))
3666 (goto-char (point-min))
3667 (push (cons 'score (and (search-forward "C" nil t)
3668 (- (point) (point-min) 1)))
3670 (goto-char (point-min))
3671 (push (cons 'download (and (search-forward "D" nil t)
3672 (- (point) (point-min) 1)))
3674 (setq gnus-summary-mark-positions pos))))
3676 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3677 "Insert a dummy root in the summary buffer."
3679 (gnus-add-text-properties
3680 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3681 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3683 (defun gnus-summary-extract-address-component (from)
3684 (or (car (funcall gnus-extract-address-components from))
3687 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3688 (let ((mail-parse-charset gnus-newsgroup-charset)
3689 (ignored-from-addresses (gnus-ignored-from-addresses))
3690 ;; Is it really necessary to do this next part for each summary line?
3691 ;; Luckily, doesn't seem to slow things down much.
3692 (mail-parse-ignored-charsets
3693 (with-current-buffer gnus-summary-buffer
3694 gnus-newsgroup-ignored-charsets)))
3696 (and ignored-from-addresses
3697 (string-match ignored-from-addresses gnus-tmp-from)
3698 (let ((extra-headers (mail-header-extra header))
3702 ((setq to (cdr (assq 'To extra-headers)))
3703 (concat gnus-summary-to-prefix
3705 (gnus-summary-extract-address-component
3706 (funcall gnus-decode-encoded-address-function to)))))
3709 (cdr (assq 'Newsgroups extra-headers))
3711 (memq 'Newsgroups gnus-extra-headers)
3712 (eq (car (gnus-find-method-for-group
3713 gnus-newsgroup-name)) 'nntp)
3714 (gnus-group-real-name gnus-newsgroup-name))))
3715 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3716 (gnus-string-mark-left-to-right
3718 (gnus-summary-extract-address-component gnus-tmp-from))))))
3720 (defun gnus-summary-insert-line (gnus-tmp-header
3721 gnus-tmp-level gnus-tmp-current
3722 undownloaded gnus-tmp-unread gnus-tmp-replied
3723 gnus-tmp-expirable gnus-tmp-subject-or-nil
3724 &optional gnus-tmp-dummy gnus-tmp-score
3726 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3727 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3729 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3730 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3731 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3732 (gnus-tmp-score-char
3733 (if (or (null gnus-summary-default-score)
3734 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3735 gnus-summary-zcore-fuzz))
3737 (if (< gnus-tmp-score gnus-summary-default-score)
3738 gnus-score-below-mark gnus-score-over-mark)))
3739 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3741 (cond (gnus-tmp-process gnus-process-mark)
3742 ((memq gnus-tmp-current gnus-newsgroup-cached)
3744 (gnus-tmp-replied gnus-replied-mark)
3745 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3746 gnus-forwarded-mark)
3747 ((memq gnus-tmp-current gnus-newsgroup-saved)
3749 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3752 (gnus-tmp-downloaded
3754 gnus-undownloaded-mark)
3755 (gnus-newsgroup-agentized
3756 gnus-downloaded-mark)
3759 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3762 ((string-match "<[^>]+> *$" gnus-tmp-from)
3763 (let ((beg (match-beginning 0)))
3764 (or (and (string-match "^\".+\"" gnus-tmp-from)
3765 (substring gnus-tmp-from 1 (1- (match-end 0))))
3766 (substring gnus-tmp-from 0 beg))))
3767 ((string-match "(.+)" gnus-tmp-from)
3768 (substring gnus-tmp-from
3769 (1+ (match-beginning 0)) (1- (match-end 0))))
3771 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3772 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3773 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3774 (inhibit-read-only t))
3775 (when (string= gnus-tmp-name "")
3776 (setq gnus-tmp-name gnus-tmp-from))
3777 (unless (numberp gnus-tmp-lines)
3778 (setq gnus-tmp-lines -1))
3779 (if (= gnus-tmp-lines -1)
3780 (setq gnus-tmp-lines "?")
3781 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3783 (gnus-put-text-property
3785 (progn (eval gnus-summary-line-format-spec) (point))
3786 'gnus-number gnus-tmp-number)
3787 (error (gnus-message 5 "Error updating the summary line")))
3788 (when (gnus-visual-p 'summary-highlight 'highlight)
3790 (gnus-summary-highlight-line)
3791 (gnus-run-hooks 'gnus-summary-update-hook)
3794 (defun gnus-summary-update-line (&optional dont-update)
3795 "Update summary line after change."
3796 (when (and gnus-summary-default-score
3797 (not gnus-summary-inhibit-highlight))
3798 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3799 (article (gnus-summary-article-number))
3800 (score (gnus-summary-article-score article)))
3802 (if (and gnus-summary-mark-below
3803 (< (gnus-summary-article-score)
3804 gnus-summary-mark-below))
3805 ;; This article has a low score, so we mark it as read.
3806 (when (memq article gnus-newsgroup-unreads)
3807 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3808 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3809 ;; This article was previously marked as read on account
3810 ;; of a low score, but now it has risen, so we mark it as
3812 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3813 (gnus-summary-update-mark
3814 (if (or (null gnus-summary-default-score)
3815 (<= (abs (- score gnus-summary-default-score))
3816 gnus-summary-zcore-fuzz))
3818 (if (< score gnus-summary-default-score)
3819 gnus-score-below-mark gnus-score-over-mark))
3821 ;; Do visual highlighting.
3822 (when (gnus-visual-p 'summary-highlight 'highlight)
3823 (gnus-summary-highlight-line)
3824 (gnus-run-hooks 'gnus-summary-update-hook)))))
3826 (defvar gnus-tmp-new-adopts nil)
3828 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3829 "Return the number of articles in THREAD.
3830 This may be 0 in some cases -- if none of the articles in
3831 the thread are to be displayed."
3833 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3835 ((not (listp thread))
3837 ((and (consp thread) (cdr thread))
3840 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3843 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3846 (when (and level (zerop level) gnus-tmp-new-adopts)
3849 'gnus-summary-number-of-articles-in-thread
3850 gnus-tmp-new-adopts))))
3852 (if (> number 1) gnus-not-empty-thread-mark
3853 gnus-empty-thread-mark)
3856 (defsubst gnus-summary-line-message-size (head)
3857 "Return pretty-printed version of message size.
3858 This function is intended to be used in
3859 `gnus-summary-line-format-alist'."
3860 (let ((c (or (mail-header-chars head) -1)))
3861 (cond ((< c 0) "n/a") ; chars not available
3862 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3863 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3864 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3865 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3867 (defcustom gnus-user-date-format-alist
3868 '(((gnus-seconds-today) . "Today, %H:%M")
3869 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3870 (604800 . "%A %H:%M") ; That's one week
3871 ((gnus-seconds-month) . "%A %d")
3872 ((gnus-seconds-year) . "%B %d")
3873 (t . "%b %d %Y")) ; This one is used when no other
3875 "Specifies date format depending on age of article.
3876 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3877 seconds) or a Lisp expression evaluating to a number. When the age of
3878 the article is less than this number, then use `format-time-string'
3879 with the corresponding FORMAT for displaying the date of the article.
3880 If AGE is not a number or a Lisp expression evaluating to a
3881 non-number, then the corresponding FORMAT is used as a default value.
3883 Note that the list is processed from the beginning, so it should be
3884 sorted by ascending AGE. Also note that items following the first
3885 non-number AGE will be ignored.
3887 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3888 and `gnus-seconds-year' in the AGE spec. They return the number of
3889 seconds passed since the start of today, of this month, of this year,
3892 :group 'gnus-summary-format
3893 :type '(alist :key-type sexp :value-type string))
3895 (defun gnus-user-date (messy-date)
3896 "Format the messy-date according to `gnus-user-date-format-alist'.
3897 Returns \" ? \" if there's bad input or if another error occurs.
3898 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3900 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3901 (now (gnus-float-time))
3902 ;;If we don't find something suitable we'll use this one
3903 (my-format "%b %d '%y"))
3904 (let* ((difference (- now messy-date))
3905 (templist gnus-user-date-format-alist)
3906 (top (eval (caar templist))))
3907 (while (if (numberp top) (< top difference) (not top))
3909 (setq templist (cdr templist))
3910 (setq top (eval (caar templist)))))
3911 (if (stringp (cdr (car templist)))
3912 (setq my-format (cdr (car templist)))))
3913 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3916 (defun gnus-summary-set-local-parameters (group)
3917 "Go through the local params of GROUP and set all variable specs in that list."
3918 (let ((vars '(quit-config active))) ; Ignore things that aren't
3920 (dolist (elem (gnus-group-find-parameter group))
3921 (and (consp elem) ; Has to be a cons.
3922 (consp (cdr elem)) ; The cdr has to be a list.
3923 (symbolp (car elem)) ; Has to be a symbol in there.
3924 (not (memq (car elem) vars))
3926 (push (car elem) vars)
3927 ;; Variables like `gnus-show-threads' that are globally
3928 ;; bound, if used as group parameters, need to get to be
3929 ;; buffer-local, whereas just parameters like `gcc-self',
3930 ;; `timestamp', etc. should not be bound as variables.
3931 (if (boundp (car elem))
3932 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3933 (eval (nth 1 elem))))))))
3935 (defun gnus-summary-read-group (group &optional show-all no-article
3936 kill-buffer no-display backward
3938 "Start reading news in newsgroup GROUP.
3939 If SHOW-ALL is non-nil, already read articles are also listed.
3940 If NO-ARTICLE is non-nil, no article is selected initially.
3941 If NO-DISPLAY, don't generate the summary buffer contents.
3942 If KILL-BUFFER, it should be a buffer that's killed once the new
3943 summary buffer has been generated.
3944 If BACKWARD, move point to the previous group in the group buffer
3945 If SELECT-ARTICLES, only select those articles from GROUP."
3949 (let ((gnus-auto-select-next nil))
3950 (or (gnus-summary-read-group-1
3951 group show-all no-article
3952 kill-buffer no-display
3955 select-articles nil)))))
3956 (eq gnus-auto-select-next 'quietly))
3957 (set-buffer gnus-group-buffer)
3958 ;; The entry function called above goes to the next
3959 ;; group automatically, so we go two groups back
3960 ;; if we are searching for the previous group.
3962 (gnus-group-prev-unread-group 2))
3963 (if (not (equal group (gnus-group-group-name)))
3964 (setq group (gnus-group-group-name))
3968 (defun gnus-summary-read-group-1 (group show-all no-article
3969 kill-buffer no-display
3970 &optional select-articles)
3971 ;; Killed foreign groups can't be entered.
3972 ;; (when (and (not (gnus-group-native-p group))
3973 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3974 ;; (error "Dead non-native groups can't be entered"))
3975 (gnus-message 7 "Retrieving newsgroup: %s..."
3976 (gnus-group-decoded-name group))
3977 (let* ((new-group (gnus-summary-setup-buffer group))
3978 (quit-config (gnus-group-quit-config group))
3979 (did-select (and new-group (gnus-select-newsgroup
3980 group show-all select-articles))))
3982 ;; This summary buffer exists already, so we just select it.
3984 (gnus-set-global-variables)
3986 (gnus-kill-or-deaden-summary kill-buffer))
3987 (gnus-configure-windows 'summary 'force)
3988 (gnus-set-mode-line 'summary)
3989 (gnus-summary-position-point)
3992 ;; We couldn't select this group.
3994 (when (and (derived-mode-p 'gnus-summary-mode)
3995 (not (equal (current-buffer) kill-buffer)))
3996 (kill-buffer (current-buffer))
3997 (if (not quit-config)
3999 ;; Update the info -- marks might need to be removed,
4001 (gnus-summary-update-info)
4002 (set-buffer gnus-group-buffer)
4003 (gnus-group-jump-to-group group)
4004 (gnus-group-next-unread-group 1))
4005 (gnus-handle-ephemeral-exit quit-config)))
4006 (if (null (gnus-list-of-unread-articles group))
4007 (gnus-message 3 "Group %s contains no messages" group)
4008 (gnus-message 3 "Can't select group"))
4010 ;; The user did a `C-g' while prompting for number of articles,
4011 ;; so we exit this group.
4012 ((eq did-select 'quit)
4013 (and (derived-mode-p 'gnus-summary-mode)
4014 (not (equal (current-buffer) kill-buffer))
4015 (kill-buffer (current-buffer)))
4017 (gnus-kill-or-deaden-summary kill-buffer))
4018 (if (not quit-config)
4020 (set-buffer gnus-group-buffer)
4021 (gnus-group-jump-to-group group)
4022 (gnus-configure-windows 'group 'force))
4023 (gnus-handle-ephemeral-exit quit-config))
4024 ;; Finally signal the quit.
4026 ;; The group was successfully selected.
4028 (gnus-set-global-variables)
4029 (when (boundp 'spam-install-hooks)
4031 ;; Save the active value in effect when the group was entered.
4032 (setq gnus-newsgroup-active
4034 (gnus-active gnus-newsgroup-name)))
4035 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4036 ;; You can change the summary buffer in some way with this hook.
4037 (gnus-run-hooks 'gnus-select-group-hook)
4038 (when (memq 'summary (gnus-update-format-specifications
4039 nil 'summary 'summary-mode 'summary-dummy))
4040 ;; The format specification for the summary line was updated,
4041 ;; so we need to update the mark positions as well.
4042 (gnus-update-summary-mark-positions))
4043 ;; Do score processing.
4044 (when gnus-use-scoring
4045 (gnus-possibly-score-headers))
4046 ;; Check whether to fill in the gaps in the threads.
4047 (when gnus-build-sparse-threads
4048 (gnus-build-sparse-threads))
4049 ;; Find the initial limit.
4051 (let ((gnus-newsgroup-dormant nil))
4052 (gnus-summary-initial-limit show-all))
4053 (gnus-summary-initial-limit show-all))
4054 ;; Generate the summary buffer.
4056 (gnus-summary-prepare))
4057 (when gnus-use-trees
4059 (setq gnus-summary-highlight-line-function
4060 'gnus-tree-highlight-article))
4061 ;; If the summary buffer is empty, but there are some low-scored
4062 ;; articles or some excluded dormants, we include these in the
4064 (when (and (zerop (buffer-size))
4066 (cond (gnus-newsgroup-dormant
4067 (gnus-summary-limit-include-dormant))
4068 ((and gnus-newsgroup-scored show-all)
4069 (gnus-summary-limit-include-expunged t))))
4070 ;; Function `gnus-apply-kill-file' must be called in this hook.
4071 (gnus-run-hooks 'gnus-apply-kill-hook)
4072 (if (and (zerop (buffer-size))
4075 ;; This newsgroup is empty.
4076 (gnus-summary-catchup-and-exit nil t)
4077 (gnus-message 6 "No unread news")
4079 (gnus-kill-or-deaden-summary kill-buffer))
4080 ;; Return nil from this function.
4082 ;; Hide conversation thread subtrees. We cannot do this in
4083 ;; gnus-summary-prepare-hook since kill processing may not
4084 ;; work with hidden articles.
4085 (gnus-summary-maybe-hide-threads)
4086 (gnus-configure-windows 'summary)
4088 (gnus-kill-or-deaden-summary kill-buffer))
4089 (gnus-summary-auto-select-subject)
4090 ;; Show first unread article if requested.
4091 (if (and (not no-article)
4093 gnus-newsgroup-unreads
4094 gnus-auto-select-first)
4096 (let ((art (gnus-summary-article-number)))
4099 (not (memq art gnus-newsgroup-undownloaded))
4100 (not (memq art gnus-newsgroup-downloadable)))
4101 (gnus-summary-goto-article art))))
4102 ;; Don't select any articles.
4103 (gnus-summary-position-point)
4104 (gnus-configure-windows 'summary 'force)
4105 (gnus-set-mode-line 'summary))
4106 (when (and gnus-auto-center-group
4107 (get-buffer-window gnus-group-buffer t))
4108 ;; Gotta use windows, because recenter does weird stuff if
4109 ;; the current buffer ain't the displayed window.
4110 (let ((owin (selected-window)))
4111 (select-window (get-buffer-window gnus-group-buffer t))
4112 (when (gnus-group-goto-group group)
4114 (select-window owin)))
4115 ;; Mark this buffer as "prepared".
4116 (setq gnus-newsgroup-prepared t)
4117 (gnus-run-hooks 'gnus-summary-prepared-hook)
4118 (unless (gnus-ephemeral-group-p group)
4119 (gnus-group-update-group group nil t))
4122 (defun gnus-summary-auto-select-subject ()
4123 "Select the subject line on initial group entry."
4124 (goto-char (point-min))
4126 ((eq gnus-auto-select-subject 'best)
4127 (gnus-summary-best-unread-subject))
4128 ((eq gnus-auto-select-subject 'unread)
4129 (gnus-summary-first-unread-subject))
4130 ((eq gnus-auto-select-subject 'unseen)
4131 (gnus-summary-first-unseen-subject))
4132 ((eq gnus-auto-select-subject 'unseen-or-unread)
4133 (gnus-summary-first-unseen-or-unread-subject))
4134 ((eq gnus-auto-select-subject 'first)
4137 ((functionp gnus-auto-select-subject)
4138 (funcall gnus-auto-select-subject))))
4140 (defun gnus-summary-prepare ()
4141 "Generate the summary buffer."
4143 (let ((inhibit-read-only t))
4145 (setq gnus-newsgroup-data nil
4146 gnus-newsgroup-data-reverse nil)
4147 (gnus-run-hooks 'gnus-summary-generate-hook)
4148 ;; Generate the buffer, either with threads or without.
4149 (when gnus-newsgroup-headers
4150 (gnus-summary-prepare-threads
4151 (if gnus-show-threads
4152 (gnus-sort-gathered-threads
4153 (funcall gnus-summary-thread-gathering-function
4155 (gnus-cut-threads (gnus-make-threads)))))
4156 ;; Unthreaded display.
4157 (gnus-sort-articles gnus-newsgroup-headers))))
4158 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4159 ;; Call hooks for modifying summary buffer.
4160 (goto-char (point-min))
4161 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4163 (defsubst gnus-general-simplify-subject (subject)
4164 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4167 ;; Truncate the subject.
4168 (gnus-simplify-subject-functions
4169 (gnus-map-function gnus-simplify-subject-functions subject))
4170 ((numberp gnus-summary-gather-subject-limit)
4171 (setq subject (gnus-simplify-subject-re subject))
4172 (if (> (length subject) gnus-summary-gather-subject-limit)
4173 (substring subject 0 gnus-summary-gather-subject-limit)
4175 ;; Fuzzily simplify it.
4176 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4177 (gnus-simplify-subject-fuzzy subject))
4178 ;; Just remove the leading "Re:".
4180 (gnus-simplify-subject-re subject))))
4182 (if (and gnus-summary-gather-exclude-subject
4183 (string-match gnus-summary-gather-exclude-subject subject))
4184 nil ; This article shouldn't be gathered
4187 (defun gnus-summary-simplify-subject-query ()
4188 "Query where the respool algorithm would put this article."
4190 (gnus-summary-select-article)
4191 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4193 (defun gnus-gather-threads-by-subject (threads)
4194 "Gather threads by looking at Subject headers."
4195 (if (not gnus-summary-make-false-root)
4197 (let ((hashtb (gnus-make-hashtable 1024))
4200 subject hthread whole-subject)
4202 (setq subject (gnus-general-simplify-subject
4203 (setq whole-subject (mail-header-subject
4206 (if (setq hthread (gnus-gethash subject hashtb))
4208 ;; We enter a dummy root into the thread, if we
4209 ;; haven't done that already.
4210 (unless (stringp (caar hthread))
4211 (setcar hthread (list whole-subject (car hthread))))
4212 ;; We add this new gathered thread to this gathered
4214 (setcdr (car hthread)
4215 (nconc (cdar hthread) (list (car threads))))
4216 ;; Remove it from the list of threads.
4217 (setcdr prev (cdr threads))
4218 (setq threads prev))
4219 ;; Enter this thread into the hash table.
4220 (gnus-sethash subject
4221 (if gnus-summary-make-false-root-always
4223 ;; If you want a dummy root above all
4225 (setcar threads (list whole-subject
4231 (setq threads (cdr threads)))
4234 (defun gnus-gather-threads-by-references (threads)
4235 "Gather threads by looking at References headers."
4236 (let ((idhashtb (gnus-make-hashtable 1024))
4237 (thhashtb (gnus-make-hashtable 1024))
4240 ids references id gthread gid entered ref)
4242 (when (setq references (mail-header-references (caar threads)))
4243 (setq id (mail-header-id (caar threads))
4244 ids (inline (gnus-split-references references))
4246 (while (setq ref (pop ids))
4247 (setq ids (delete ref ids))
4248 (if (not (setq gid (gnus-gethash ref idhashtb)))
4250 (gnus-sethash ref id idhashtb)
4251 (gnus-sethash id threads thhashtb))
4252 (setq gthread (gnus-gethash gid thhashtb))
4254 ;; We enter a dummy root into the thread, if we
4255 ;; haven't done that already.
4256 (unless (stringp (caar gthread))
4257 (setcar gthread (list (mail-header-subject (caar gthread))
4259 ;; We add this new gathered thread to this gathered
4261 (setcdr (car gthread)
4262 (nconc (cdar gthread) (list (car threads)))))
4263 ;; Add it into the thread hash table.
4264 (gnus-sethash id gthread thhashtb)
4266 ;; Remove it from the list of threads.
4267 (setcdr prev (cdr threads))
4268 (setq threads prev))))
4270 (setq threads (cdr threads)))
4273 (defun gnus-sort-gathered-threads (threads)
4274 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4275 (let ((result threads))
4277 (when (stringp (caar threads))
4278 (setcdr (car threads)
4279 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4280 (setq threads (cdr threads)))
4283 (defun gnus-thread-loop-p (root thread)
4284 "Say whether ROOT is in THREAD."
4285 (let ((stack (list thread))
4288 (while (setq thread (pop stack))
4289 (setq th (cdr thread))
4291 (not (eq (caar th) root)))
4294 ;; We have found a loop.
4296 (setcdr thread (delq (car th) (cdr thread)))
4297 (if (boundp (setq ref-dep (intern "none"
4298 gnus-newsgroup-dependencies)))
4299 (setcdr (symbol-value ref-dep)
4300 (nconc (cdr (symbol-value ref-dep))
4302 (set ref-dep (list nil (car th))))
4305 ;; Push all the subthreads onto the stack.
4306 (push (cdr thread) stack)))
4309 (defun gnus-make-threads ()
4310 "Go through the dependency hashtb and find the roots. Return all threads."
4312 (while (catch 'infloop
4315 ;; Deal with self-referencing References loops.
4316 (when (and (car (symbol-value refs))
4323 (car (symbol-value refs)) thread))
4324 (cdr (symbol-value refs)))))))
4327 (unless (car (symbol-value refs))
4328 ;; These threads do not refer back to any other
4329 ;; articles, so they're roots.
4330 (setq threads (append (cdr (symbol-value refs)) threads))))
4331 gnus-newsgroup-dependencies)))
4334 ;; Build the thread tree.
4335 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4336 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4338 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4339 if it was already present.
4341 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4342 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4343 Message-IDs will be renamed to a unique Message-ID before being
4346 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4347 (let* ((id (mail-header-id header))
4348 (id-dep (and id (intern id dependencies)))
4349 parent-id ref ref-dep ref-header replaced)
4350 ;; Enter this `header' in the `dependencies' table.
4354 ;; The first two cases do the normal part: enter a new `header'
4355 ;; in the `dependencies' table.
4356 ((not (boundp id-dep))
4357 (set id-dep (list header)))
4358 ((null (car (symbol-value id-dep)))
4359 (setcar (symbol-value id-dep) header))
4361 ;; From here the `header' was already present in the
4362 ;; `dependencies' table.
4364 ;; Overrides an existing entry;
4365 ;; just set the header part of the entry.
4366 (setcar (symbol-value id-dep) header)
4369 ;; Renames the existing `header' to a unique Message-ID.
4370 ((not gnus-summary-ignore-duplicates)
4371 ;; An article with this Message-ID has already been seen.
4372 ;; We rename the Message-ID.
4373 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4375 (mail-header-set-id header id))
4377 ;; The last case ignores an existing entry, except it adds any
4378 ;; additional Xrefs (in case the two articles came from different
4380 ;; Also sets `header' to nil meaning that the `dependencies'
4381 ;; table was *not* modified.
4383 (mail-header-set-xref
4384 (car (symbol-value id-dep))
4385 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4387 (or (mail-header-xref header) "")))
4390 (when (and header (not replaced))
4391 ;; First check that we are not creating a References loop.
4392 (setq parent-id (gnus-parent-id (mail-header-references header)))
4393 (setq ref parent-id)
4395 (setq ref-dep (intern-soft ref dependencies))
4397 (setq ref-header (car (symbol-value ref-dep))))
4398 (if (string= id ref)
4399 ;; Yuk! This is a reference loop. Make the article be a
4402 (mail-header-set-references (car (symbol-value id-dep)) "none")
4404 (setq parent-id nil))
4405 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4406 (setq ref-dep (intern (or parent-id "none") dependencies))
4407 (if (boundp ref-dep)
4408 (setcdr (symbol-value ref-dep)
4409 (nconc (cdr (symbol-value ref-dep))
4410 (list (symbol-value id-dep))))
4411 (set ref-dep (list nil (symbol-value id-dep)))))
4414 (defun gnus-extract-message-id-from-in-reply-to (string)
4415 (if (string-match "<[^>]+>" string)
4416 (substring string (match-beginning 0) (match-end 0))
4419 (defun gnus-build-sparse-threads ()
4420 (let ((headers gnus-newsgroup-headers)
4421 (mail-parse-charset gnus-newsgroup-charset)
4422 (gnus-summary-ignore-duplicates t)
4423 header references generation relations
4424 subject child end new-child date)
4425 ;; First we create an alist of generations/relations, where
4426 ;; generations is how much we trust the relation, and the relation
4428 (gnus-message 7 "Making sparse threads...")
4430 (nnheader-set-temp-buffer " *gnus sparse threads*")
4431 (while (setq header (pop headers))
4432 (when (and (setq references (mail-header-references header))
4433 (not (string= references "")))
4435 (setq child (mail-header-id header)
4436 subject (mail-header-subject header)
4437 date (mail-header-date header)
4439 (while (search-backward ">" nil t)
4440 (setq end (1+ (point)))
4441 (when (search-backward "<" nil t)
4442 (setq new-child (buffer-substring (point) end))
4443 (push (list (incf generation)
4444 child (setq child new-child)
4448 (push (list (1+ generation) child nil subject) relations))
4450 (kill-buffer (current-buffer)))
4451 ;; Sort over trustworthiness.
4452 (dolist (relation (sort relations 'car-less-than-car))
4453 (when (gnus-dependencies-add-header
4454 (make-full-mail-header
4455 gnus-reffed-article-number
4456 (nth 3 relation) "" (or (nth 4 relation) "")
4458 (or (nth 2 relation) "") 0 0 "")
4459 gnus-newsgroup-dependencies nil)
4460 (push gnus-reffed-article-number gnus-newsgroup-limit)
4461 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4462 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4463 gnus-newsgroup-reads)
4464 (decf gnus-reffed-article-number)))
4465 (gnus-message 7 "Making sparse threads...done")))
4467 (defun gnus-build-old-threads ()
4468 ;; Look at all the articles that refer back to old articles, and
4469 ;; fetch the headers for the articles that aren't there. This will
4470 ;; build complete threads - if the roots haven't been expired by the
4472 (let ((mail-parse-charset gnus-newsgroup-charset)
4476 (when (not (car (symbol-value refs)))
4477 (setq heads (cdr (symbol-value refs)))
4479 (if (memq (mail-header-number (caar heads))
4480 gnus-newsgroup-dormant)
4481 (setq heads (cdr heads))
4482 (setq id (symbol-name refs))
4483 (while (and (setq id (gnus-build-get-header id))
4484 (not (car (gnus-id-to-thread id)))))
4485 (setq heads nil)))))
4486 gnus-newsgroup-dependencies)))
4488 (defsubst gnus-remove-odd-characters (string)
4489 "Translate STRING into something that doesn't contain weird characters."
4490 (mm-subst-char-in-string
4492 (mm-subst-char-in-string ?\n ?\- string t) t))
4494 ;; This function has to be called with point after the article number
4495 ;; on the beginning of the line.
4496 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4497 (let ((eol (point-at-eol))
4498 (buffer (current-buffer))
4499 header references in-reply-to)
4501 ;; overview: [num subject from date id refs chars lines misc]
4504 (narrow-to-region (point) eol)
4509 (make-full-mail-header
4511 (condition-case () ; subject
4512 (gnus-remove-odd-characters
4513 (funcall gnus-decode-encoded-word-function
4514 (setq x (nnheader-nov-field))))
4516 (condition-case () ; from
4517 (gnus-remove-odd-characters
4518 (funcall gnus-decode-encoded-address-function
4519 (setq x (nnheader-nov-field))))
4521 (nnheader-nov-field) ; date
4522 (nnheader-nov-read-message-id number) ; id
4523 (setq references (nnheader-nov-field)) ; refs
4524 (nnheader-nov-read-integer) ; chars
4525 (nnheader-nov-read-integer) ; lines
4527 (if (looking-at "Xref: ")
4528 (goto-char (match-end 0)))
4529 (nnheader-nov-field)) ; Xref
4530 (nnheader-nov-parse-extra)))) ; extra
4534 (when (and (string= references "")
4535 (setq in-reply-to (mail-header-extra header))
4536 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4537 (mail-header-set-references
4538 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4540 (when gnus-alter-header-function
4541 (funcall gnus-alter-header-function header))
4542 (gnus-dependencies-add-header header dependencies force-new)))
4544 (defun gnus-build-get-header (id)
4545 "Look through the buffer of NOV lines and find the header to ID.
4546 Enter this line into the dependencies hash table, and return
4547 the id of the parent article (if any)."
4548 (let ((deps gnus-newsgroup-dependencies)
4551 (with-current-buffer nntp-server-buffer
4552 (let ((case-fold-search nil))
4553 (goto-char (point-min))
4554 (while (and (not found)
4555 (search-forward id nil t))
4557 (setq found (looking-at
4558 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4559 (regexp-quote id))))
4560 (or found (beginning-of-line 2)))
4564 (setq header (gnus-nov-parse-line
4565 (read (current-buffer)) deps))
4566 (gnus-parent-id (mail-header-references header))))))
4568 (let ((number (mail-header-number header)))
4569 (push number gnus-newsgroup-limit)
4570 (push header gnus-newsgroup-headers)
4571 (if (memq number gnus-newsgroup-unselected)
4573 (setq gnus-newsgroup-unreads
4574 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4576 (setq gnus-newsgroup-unselected
4577 (delq number gnus-newsgroup-unselected)))
4578 (push number gnus-newsgroup-ancient)))))))
4580 (defun gnus-build-all-threads ()
4581 "Read all the headers."
4582 (let ((gnus-summary-ignore-duplicates t)
4583 (mail-parse-charset gnus-newsgroup-charset)
4584 (dependencies gnus-newsgroup-dependencies)
4586 (with-current-buffer nntp-server-buffer
4587 (let ((case-fold-search nil))
4588 (goto-char (point-min))
4591 (setq article (read (current-buffer))
4592 header (gnus-nov-parse-line article dependencies t)))
4594 (with-current-buffer gnus-summary-buffer
4595 (push header gnus-newsgroup-headers)
4596 (if (memq (setq article (mail-header-number header))
4597 gnus-newsgroup-unselected)
4599 (setq gnus-newsgroup-unreads
4600 (gnus-add-to-sorted-list
4601 gnus-newsgroup-unreads article))
4602 (setq gnus-newsgroup-unselected
4603 (delq article gnus-newsgroup-unselected)))
4604 (push article gnus-newsgroup-ancient)))
4605 (forward-line 1)))))))
4607 (defun gnus-summary-update-article-line (article header)
4608 "Update the line for ARTICLE using HEADER."
4609 (let* ((id (mail-header-id header))
4610 (thread (gnus-id-to-thread id)))
4612 (error "Article in no thread"))
4613 ;; Update the thread.
4614 (setcar thread header)
4615 (gnus-summary-goto-subject article)
4616 (let* ((datal (gnus-data-find-list article))
4618 (inhibit-read-only t)
4619 (level (gnus-summary-thread-level)))
4621 (let ((inserted (- (point)
4623 (gnus-summary-insert-line
4625 (memq article gnus-newsgroup-undownloaded)
4626 (gnus-article-mark article)
4627 (memq article gnus-newsgroup-replied)
4628 (memq article gnus-newsgroup-expirable)
4629 ;; Only insert the Subject string when it's different
4630 ;; from the previous Subject string.
4635 (mail-header-subject
4638 (gnus-data-find-list
4640 (gnus-data-list t)))))
4641 ;; Error on the side of excessive subjects.
4643 (mail-header-subject header)))
4645 (mail-header-subject header))
4646 nil (cdr (assq article gnus-newsgroup-scored))
4647 (memq article gnus-newsgroup-processable))
4650 (gnus-data-update-list
4652 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4654 (defun gnus-summary-update-article (article &optional iheader)
4655 "Update ARTICLE in the summary buffer."
4656 (set-buffer gnus-summary-buffer)
4657 (let* ((header (gnus-summary-article-header article))
4658 (id (mail-header-id header))
4659 (data (gnus-data-find article))
4660 (thread (gnus-id-to-thread id))
4661 (references (mail-header-references header))
4665 (when (and references
4666 (not (equal "" references)))
4669 (inhibit-read-only t)
4675 (delq thread parent)))
4676 (if (gnus-summary-insert-subject id header)
4677 ;; Set the (possibly) new article number in the data structure.
4678 (gnus-data-set-number data (gnus-id-to-article id))
4682 (defun gnus-rebuild-thread (id &optional line)
4683 "Rebuild the thread containing ID.
4684 If LINE, insert the rebuilt thread starting on line LINE."
4685 (let ((inhibit-read-only t)
4686 old-pos current thread data)
4687 (if (not gnus-show-threads)
4688 (setq thread (list (car (gnus-id-to-thread id))))
4689 ;; Get the thread this article is part of.
4690 (setq thread (gnus-remove-thread id)))
4691 (setq old-pos (point-at-bol))
4692 (setq current (save-excursion
4693 (and (re-search-backward "[\r\n]" nil t)
4694 (gnus-summary-article-number))))
4695 ;; If this is a gathered thread, we have to go some re-gathering.
4696 (when (stringp (car thread))
4697 (let ((subject (car thread))
4699 (setq thread (cdr thread))
4701 (unless (memq (setq thr (gnus-id-to-thread
4703 (mail-header-id (caar thread)))))
4706 (setq thread (cdr thread)))
4707 ;; We now have all (unique) roots.
4708 (if (= (length roots) 1)
4709 ;; All the loose roots are now one solid root.
4710 (setq thread (car roots))
4711 (setq thread (cons subject (gnus-sort-threads roots))))))
4713 ;; We then insert this thread into the summary buffer.
4715 (goto-char (point-min))
4716 (forward-line (1- line)))
4717 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4718 (if gnus-show-threads
4719 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4720 (gnus-summary-prepare-unthreaded thread))
4721 (setq data (nreverse gnus-newsgroup-data))
4722 (setq threads gnus-newsgroup-threads))
4723 ;; We splice the new data into the data structure.
4724 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4725 ;;!!! then we want to insert at the beginning of the buffer.
4726 ;;!!! That happens to be true with Gnus now, but that may
4727 ;;!!! change in the future. Perhaps.
4728 (gnus-data-enter-list
4729 (if line nil current) data (- (point) old-pos))
4730 (setq gnus-newsgroup-threads
4731 (nconc threads gnus-newsgroup-threads))
4732 (gnus-data-compute-positions))))
4734 (defun gnus-number-to-header (number)
4735 "Return the header for article NUMBER."
4736 (let ((headers gnus-newsgroup-headers))
4738 (not (= number (mail-header-number (car headers)))))
4743 (defun gnus-parent-headers (in-headers &optional generation)
4744 "Return the headers of the GENERATIONth parent of HEADERS."
4746 (setq generation 1))
4748 (headers in-headers)
4751 (not (zerop generation))
4752 (setq references (mail-header-references headers)))
4753 (setq headers (if (and references
4754 (setq parent (gnus-parent-id references)))
4755 (car (gnus-id-to-thread parent))
4758 (and (not (eq headers in-headers))
4761 (defun gnus-id-to-thread (id)
4762 "Return the (sub-)thread where ID appears."
4763 (gnus-gethash id gnus-newsgroup-dependencies))
4765 (defun gnus-id-to-article (id)
4766 "Return the article number of ID."
4767 (let ((thread (gnus-id-to-thread id)))
4770 (mail-header-number (car thread)))))
4772 (defun gnus-id-to-header (id)
4773 "Return the article headers of ID."
4774 (car (gnus-id-to-thread id)))
4776 (defun gnus-article-displayed-root-p (article)
4777 "Say whether ARTICLE is a root(ish) article."
4778 (let ((level (gnus-summary-thread-level article))
4779 (refs (mail-header-references (gnus-summary-article-header article)))
4785 ((null (gnus-parent-id refs)) t)
4787 (null (setq particle (gnus-id-to-article
4788 (gnus-parent-id refs))))
4789 (null (gnus-summary-thread-level particle)))))))
4791 (defun gnus-root-id (id)
4792 "Return the id of the root of the thread where ID appears."
4794 (while (and id (setq prev (car (gnus-id-to-thread id))))
4796 id (gnus-parent-id (mail-header-references prev))))
4799 (defun gnus-articles-in-thread (thread)
4800 "Return the list of articles in THREAD."
4801 (cons (mail-header-number (car thread))
4802 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4804 (defun gnus-remove-thread (id &optional dont-remove)
4805 "Remove the thread that has ID in it."
4806 (let (headers thread last-id)
4807 ;; First go up in this thread until we find the root.
4808 (setq last-id (gnus-root-id id)
4809 headers (message-flatten-list (gnus-id-to-thread last-id)))
4810 ;; We have now found the real root of this thread. It might have
4811 ;; been gathered into some loose thread, so we have to search
4812 ;; through the threads to find the thread we wanted.
4813 (let ((threads gnus-newsgroup-threads)
4816 (setq sub (car threads))
4817 (if (stringp (car sub))
4818 ;; This is a gathered thread, so we look at the roots
4819 ;; below it to find whether this article is in this
4822 (setq sub (cdr sub))
4824 (when (member (caar sub) headers)
4825 (setq thread (car threads)
4828 (setq sub (cdr sub))))
4829 ;; It's an ordinary thread, so we check it.
4830 (when (eq (car sub) (car headers))
4833 (setq threads (cdr threads)))
4834 ;; If this article is in no thread, then it's a root.
4837 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4838 (setq thread (gnus-id-to-thread last-id)))
4841 thread ; We return this thread.
4843 (if (stringp (car thread))
4845 ;; If we use dummy roots, then we have to remove the
4846 ;; dummy root as well.
4847 (when (eq gnus-summary-make-false-root 'dummy)
4848 ;; We go to the dummy root by going to
4849 ;; the first sub-"thread", and then one line up.
4850 (gnus-summary-goto-article
4851 (mail-header-number (caadr thread)))
4854 (gnus-data-compute-positions))
4855 (setq thread (cdr thread))
4857 (gnus-remove-thread-1 (car thread))
4858 (setq thread (cdr thread))))
4859 (gnus-remove-thread-1 thread))))))))
4861 (defun gnus-remove-thread-1 (thread)
4862 "Remove the thread THREAD recursively."
4863 (let ((number (mail-header-number (pop thread)))
4865 (setq thread (reverse thread))
4867 (gnus-remove-thread-1 (pop thread)))
4868 (when (setq d (gnus-data-find number))
4869 (goto-char (gnus-data-pos d))
4870 (gnus-summary-show-thread)
4876 (gnus-delete-line)))))))
4878 (defun gnus-sort-threads-recursive (threads func)
4879 ;; Responsible for sorting the root articles of threads.
4880 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4881 'gnus-thread-sort-functions)
4883 (gnus-make-sort-function
4884 gnus-subthread-sort-functions))))
4885 (sort (mapcar (lambda (thread)
4888 (gnus-sort-subthreads-recursive
4889 (cdr thread) subthread-sort-func))))
4892 (defun gnus-sort-subthreads-recursive (threads func)
4893 ;; Responsible for sorting subthreads.
4894 (sort (mapcar (lambda (thread)
4897 (gnus-sort-subthreads-recursive (cdr thread) func))))
4900 (defun gnus-sort-threads-loop (threads func)
4901 (let* ((superthread (cons nil threads))
4902 (stack (list (cons superthread threads)))
4903 remaining-threads thread)
4905 (setq remaining-threads (cdr (car stack)))
4906 (if remaining-threads
4907 (progn (setq thread (car remaining-threads))
4908 (setcdr (car stack) (cdr remaining-threads))
4910 (push (cons thread (cdr thread)) stack)))
4911 (setq thread (caar stack))
4912 (setcdr thread (sort (cdr thread) func))
4916 (defun gnus-sort-threads (threads)
4918 (if (not gnus-thread-sort-functions)
4920 (gnus-message 8 "Sorting threads...")
4923 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4924 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4925 (gnus-sort-threads-recursive threads sort-func))
4926 ;; Even after binding max-lisp-eval-depth, the recursive
4927 ;; sorter might fail for very long threads. In that case,
4928 ;; try using a (less well-tested) non-recursive sorter.
4929 (error (gnus-message 9 "Sorting threads with loop...")
4930 (gnus-sort-threads-loop
4931 threads (gnus-make-sort-function
4932 gnus-thread-sort-functions))))
4933 (gnus-message 8 "Sorting threads...done"))))
4935 (defun gnus-sort-articles (articles)
4937 (when gnus-article-sort-functions
4938 (gnus-message 7 "Sorting articles...")
4940 (setq gnus-newsgroup-headers
4941 (sort articles (gnus-make-sort-function
4942 gnus-article-sort-functions)))
4943 (gnus-message 7 "Sorting articles...done"))))
4945 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4946 (defmacro gnus-thread-header (thread)
4947 "Return header of first article in THREAD.
4948 Note that THREAD must never, ever be anything else than a variable -
4949 using some other form will lead to serious barfage."
4950 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4951 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4952 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4955 (defsubst gnus-article-sort-by-number (h1 h2)
4956 "Sort articles by article number."
4957 (< (mail-header-number h1)
4958 (mail-header-number h2)))
4960 (defun gnus-thread-sort-by-number (h1 h2)
4961 "Sort threads by root article number."
4962 (gnus-article-sort-by-number
4963 (gnus-thread-header h1) (gnus-thread-header h2)))
4965 (defsubst gnus-article-sort-by-random (h1 h2)
4966 "Sort articles randomly."
4969 (defun gnus-thread-sort-by-random (h1 h2)
4970 "Sort threads randomly."
4971 (gnus-article-sort-by-random
4972 (gnus-thread-header h1) (gnus-thread-header h2)))
4974 (defsubst gnus-article-sort-by-lines (h1 h2)
4975 "Sort articles by article Lines header."
4976 (< (mail-header-lines h1)
4977 (mail-header-lines h2)))
4979 (defun gnus-thread-sort-by-lines (h1 h2)
4980 "Sort threads by root article Lines header."
4981 (gnus-article-sort-by-lines
4982 (gnus-thread-header h1) (gnus-thread-header h2)))
4984 (defsubst gnus-article-sort-by-chars (h1 h2)
4985 "Sort articles by octet length."
4986 (< (mail-header-chars h1)
4987 (mail-header-chars h2)))
4989 (defun gnus-thread-sort-by-chars (h1 h2)
4990 "Sort threads by root article octet length."
4991 (gnus-article-sort-by-chars
4992 (gnus-thread-header h1) (gnus-thread-header h2)))
4994 (defsubst gnus-article-sort-by-author (h1 h2)
4995 "Sort articles by root author."
4997 (let ((extract (funcall
4998 gnus-extract-address-components
4999 (mail-header-from h1))))
5000 (or (car extract) (cadr extract) ""))
5001 (let ((extract (funcall
5002 gnus-extract-address-components
5003 (mail-header-from h2))))
5004 (or (car extract) (cadr extract) ""))))
5006 (defun gnus-thread-sort-by-author (h1 h2)
5007 "Sort threads by root author."
5008 (gnus-article-sort-by-author
5009 (gnus-thread-header h1) (gnus-thread-header h2)))
5011 (defsubst gnus-article-sort-by-recipient (h1 h2)
5012 "Sort articles by recipient."
5014 (let ((extract (funcall
5015 gnus-extract-address-components
5016 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
5017 (or (car extract) (cadr extract)))
5018 (let ((extract (funcall
5019 gnus-extract-address-components
5020 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5021 (or (car extract) (cadr extract)))))
5023 (defun gnus-thread-sort-by-recipient (h1 h2)
5024 "Sort threads by root recipient."
5025 (gnus-article-sort-by-recipient
5026 (gnus-thread-header h1) (gnus-thread-header h2)))
5028 (defsubst gnus-article-sort-by-subject (h1 h2)
5029 "Sort articles by root subject."
5031 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5032 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5034 (defun gnus-thread-sort-by-subject (h1 h2)
5035 "Sort threads by root subject."
5036 (gnus-article-sort-by-subject
5037 (gnus-thread-header h1) (gnus-thread-header h2)))
5039 (defsubst gnus-article-sort-by-date (h1 h2)
5040 "Sort articles by root article date."
5042 (gnus-date-get-time (mail-header-date h1))
5043 (gnus-date-get-time (mail-header-date h2))))
5045 (defun gnus-thread-sort-by-date (h1 h2)
5046 "Sort threads by root article date."
5047 (gnus-article-sort-by-date
5048 (gnus-thread-header h1) (gnus-thread-header h2)))
5050 (defsubst gnus-article-sort-by-score (h1 h2)
5051 "Sort articles by root article score.
5052 Unscored articles will be counted as having a score of zero."
5053 (> (or (cdr (assq (mail-header-number h1)
5054 gnus-newsgroup-scored))
5055 gnus-summary-default-score 0)
5056 (or (cdr (assq (mail-header-number h2)
5057 gnus-newsgroup-scored))
5058 gnus-summary-default-score 0)))
5060 (defun gnus-thread-sort-by-score (h1 h2)
5061 "Sort threads by root article score."
5062 (gnus-article-sort-by-score
5063 (gnus-thread-header h1) (gnus-thread-header h2)))
5065 (defun gnus-thread-sort-by-total-score (h1 h2)
5066 "Sort threads by the sum of all scores in the thread.
5067 Unscored articles will be counted as having a score of zero."
5068 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5070 (defun gnus-thread-total-score (thread)
5071 ;; This function find the total score of THREAD.
5076 (if (stringp (car thread))
5077 (apply gnus-thread-score-function 0
5078 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5079 (gnus-thread-total-score-1 thread)))
5081 (gnus-thread-total-score-1 (list thread)))))
5083 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5084 "Sort articles by number."
5085 (gnus-article-sort-by-number h1 h2))
5087 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5088 "Sort threads such that the thread with the most recently arrived article comes first."
5089 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5091 (defun gnus-thread-highest-number (thread)
5092 "Return the highest article number in THREAD."
5093 (apply 'max (mapcar (lambda (header)
5094 (mail-header-number header))
5095 (message-flatten-list thread))))
5097 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5098 "Sort articles by number."
5099 (gnus-article-sort-by-date h1 h2))
5101 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5102 "Sort threads such that the thread with the most recently dated article comes first."
5103 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5105 ; Since this is called not only to sort the top-level threads, but
5106 ; also in recursive sorts to order the articles within a thread, each
5107 ; article will be processed many times. Thus it speeds things up
5108 ; quite a bit to use gnus-date-get-time, which caches the time value.
5109 (defun gnus-thread-latest-date (thread)
5110 "Return the highest article date in THREAD."
5112 (mapcar (lambda (header) (gnus-float-time
5114 (mail-header-date header))))
5115 (message-flatten-list thread))))
5117 (defun gnus-thread-total-score-1 (root)
5118 ;; This function find the total score of the thread below ROOT.
5119 (setq root (car root))
5120 (apply gnus-thread-score-function
5122 (mapcar 'gnus-thread-total-score
5123 (cdr (gnus-id-to-thread (mail-header-id root))))
5124 (when (> (mail-header-number root) 0)
5125 (list (or (cdr (assq (mail-header-number root)
5126 gnus-newsgroup-scored))
5127 gnus-summary-default-score 0))))
5128 (list gnus-summary-default-score)
5131 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5132 (defvar gnus-tmp-prev-subject nil)
5133 (defvar gnus-tmp-false-parent nil)
5134 (defvar gnus-tmp-root-expunged nil)
5135 (defvar gnus-tmp-dummy-line nil)
5137 (defun gnus-extra-header (type &optional header)
5138 "Return the extra header of TYPE."
5139 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5142 (defvar gnus-tmp-thread-tree-header-string "")
5144 (defcustom gnus-sum-thread-tree-root "> "
5145 "With %B spec, used for the root of a thread.
5146 If nil, use subject instead."
5148 :type '(radio (const :format "%v " nil) string)
5149 :group 'gnus-thread)
5151 (defcustom gnus-sum-thread-tree-false-root "> "
5152 "With %B spec, used for a false root of a thread.
5153 If nil, use subject instead."
5155 :type '(radio (const :format "%v " nil) string)
5156 :group 'gnus-thread)
5158 (defcustom gnus-sum-thread-tree-single-indent ""
5159 "With %B spec, used for a thread with just one message.
5160 If nil, use subject instead."
5162 :type '(radio (const :format "%v " nil) string)
5163 :group 'gnus-thread)
5165 (defcustom gnus-sum-thread-tree-vertical "| "
5166 "With %B spec, used for drawing a vertical line."
5169 :group 'gnus-thread)
5171 (defcustom gnus-sum-thread-tree-indent " "
5172 "With %B spec, used for indenting."
5175 :group 'gnus-thread)
5177 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5178 "With %B spec, used for a leaf with brothers."
5181 :group 'gnus-thread)
5183 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5184 "With %B spec, used for a leaf without brothers."
5187 :group 'gnus-thread)
5189 (defcustom gnus-summary-display-while-building nil
5190 "If non-nil, show and update the summary buffer as it's being built.
5191 If the value is t, update the buffer after every line is inserted. If
5192 the value is an integer (N), update the display every N lines."
5195 :type '(choice (const :tag "off" nil)
5197 (const :tag "frequently" t)))
5199 (defun gnus-summary-prepare-threads (threads)
5200 "Prepare summary buffer from THREADS and indentation LEVEL.
5201 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5202 or a straight list of headers."
5203 (gnus-message 7 "Generating summary...")
5205 (setq gnus-newsgroup-threads threads)
5208 (let ((gnus-tmp-level 0)
5209 (default-score (or gnus-summary-default-score 0))
5210 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5211 (building-line-count gnus-summary-display-while-building)
5212 (building-count (integerp gnus-summary-display-while-building))
5213 thread number subject stack state gnus-tmp-gathered beg-match
5214 new-roots gnus-tmp-new-adopts thread-end simp-subject
5215 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5216 gnus-tmp-replied gnus-tmp-subject-or-nil
5217 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5218 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5219 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5222 (setq gnus-tmp-prev-subject nil
5223 gnus-tmp-thread-tree-header-string "")
5225 (if (vectorp (car threads))
5226 ;; If this is a straight (sic) list of headers, then a
5227 ;; threaded summary display isn't required, so we just create
5228 ;; an unthreaded one.
5229 (gnus-summary-prepare-unthreaded threads)
5231 ;; Do the threaded display.
5233 (if gnus-summary-display-while-building
5234 (switch-to-buffer (buffer-name)))
5235 (while (or threads stack gnus-tmp-new-adopts new-roots)
5237 (if (and (= gnus-tmp-level 0)
5240 (not gnus-tmp-false-parent)
5241 (or gnus-tmp-new-adopts new-roots))
5242 (if gnus-tmp-new-adopts
5243 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5244 thread (list (car gnus-tmp-new-adopts))
5245 gnus-tmp-header (caar thread)
5246 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5248 (setq thread (list (car new-roots))
5249 gnus-tmp-header (caar thread)
5250 new-roots (cdr new-roots))))
5253 ;; If there are some threads, we do them before the
5254 ;; threads on the stack.
5255 (setq thread threads
5256 gnus-tmp-header (caar thread))
5257 ;; There were no current threads, so we pop something off
5259 (setq state (car stack)
5260 gnus-tmp-level (car state)
5261 tree-stack (cadr state)
5262 thread (caddr state)
5264 gnus-tmp-header (caar thread))))
5266 (setq gnus-tmp-false-parent nil)
5267 (setq gnus-tmp-root-expunged nil)
5268 (setq thread-end nil)
5270 (if (stringp gnus-tmp-header)
5271 ;; The header is a dummy root.
5273 ((eq gnus-summary-make-false-root 'adopt)
5274 ;; We let the first article adopt the rest.
5275 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5277 (setq gnus-tmp-gathered
5279 (lambda (h) (mail-header-number (car h)))
5282 (setq thread (cons (list (caar thread)
5285 (setq gnus-tmp-level -1
5286 gnus-tmp-false-parent t))
5287 ((eq gnus-summary-make-false-root 'empty)
5288 ;; We print adopted articles with empty subject fields.
5289 (setq gnus-tmp-gathered
5291 (lambda (h) (mail-header-number (car h)))
5294 (setq gnus-tmp-level -1))
5295 ((eq gnus-summary-make-false-root 'dummy)
5296 ;; We remember that we probably want to output a dummy
5298 (setq gnus-tmp-dummy-line gnus-tmp-header)
5299 (setq gnus-tmp-prev-subject gnus-tmp-header))
5301 ;; We do not make a root for the gathered
5302 ;; sub-threads at all.
5303 (setq gnus-tmp-level -1)))
5305 (setq number (mail-header-number gnus-tmp-header)
5306 subject (mail-header-subject gnus-tmp-header)
5307 simp-subject (gnus-simplify-subject-fully subject))
5310 ;; If the thread has changed subject, we might want to make
5311 ;; this subthread into a root.
5312 ((and (null gnus-thread-ignore-subject)
5313 (not (zerop gnus-tmp-level))
5314 gnus-tmp-prev-subject
5315 (not (string= gnus-tmp-prev-subject simp-subject)))
5316 (setq new-roots (nconc new-roots (list (car thread)))
5318 gnus-tmp-header nil))
5319 ;; If the article lies outside the current limit,
5320 ;; then we do not display it.
5321 ((not (memq number gnus-newsgroup-limit))
5322 (setq gnus-tmp-gathered
5324 (lambda (h) (mail-header-number (car h)))
5327 (setq gnus-tmp-new-adopts (if (cdar thread)
5328 (append gnus-tmp-new-adopts
5330 gnus-tmp-new-adopts)
5332 gnus-tmp-header nil)
5333 (when (zerop gnus-tmp-level)
5334 (setq gnus-tmp-root-expunged t)))
5335 ;; Perhaps this article is to be marked as read?
5336 ((and gnus-summary-mark-below
5337 (< (or (cdr (assq number gnus-newsgroup-scored))
5339 gnus-summary-mark-below)
5340 ;; Don't touch sparse articles.
5341 (not (gnus-summary-article-sparse-p number))
5342 (not (gnus-summary-article-ancient-p number)))
5343 (setq gnus-newsgroup-unreads
5344 (delq number gnus-newsgroup-unreads))
5345 (if gnus-newsgroup-auto-expire
5346 (setq gnus-newsgroup-expirable
5347 (gnus-add-to-sorted-list
5348 gnus-newsgroup-expirable number))
5349 (push (cons number gnus-low-score-mark)
5350 gnus-newsgroup-reads))))
5352 (when gnus-tmp-header
5353 ;; We may have an old dummy line to output before this
5355 (when (and gnus-tmp-dummy-line
5358 (mail-header-subject gnus-tmp-header)))
5359 (gnus-summary-insert-dummy-line
5360 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5361 (setq gnus-tmp-dummy-line nil))
5363 ;; Compute the mark.
5364 (setq gnus-tmp-unread (gnus-article-mark number))
5366 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5367 gnus-tmp-header gnus-tmp-level)
5368 gnus-newsgroup-data)
5370 ;; Actually insert the line.
5372 gnus-tmp-subject-or-nil
5374 ((and gnus-thread-ignore-subject
5375 gnus-tmp-prev-subject
5376 (not (string= gnus-tmp-prev-subject simp-subject)))
5378 ((zerop gnus-tmp-level)
5379 (if (and (eq gnus-summary-make-false-root 'empty)
5380 (memq number gnus-tmp-gathered)
5381 gnus-tmp-prev-subject
5382 (string= gnus-tmp-prev-subject simp-subject))
5383 gnus-summary-same-subject
5385 (t gnus-summary-same-subject)))
5386 (if (and (eq gnus-summary-make-false-root 'adopt)
5387 (= gnus-tmp-level 1)
5388 (memq number gnus-tmp-gathered))
5389 (setq gnus-tmp-opening-bracket ?\<
5390 gnus-tmp-closing-bracket ?\>)
5391 (setq gnus-tmp-opening-bracket ?\[
5392 gnus-tmp-closing-bracket ?\]))
5393 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5394 (gnus-make-thread-indent-array
5395 (max (* 2 (length gnus-thread-indent-array))
5398 gnus-tmp-indentation
5399 (aref gnus-thread-indent-array gnus-tmp-level)
5400 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5401 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5402 gnus-summary-default-score 0)
5404 (if (or (null gnus-summary-default-score)
5405 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5406 gnus-summary-zcore-fuzz))
5408 (if (< gnus-tmp-score gnus-summary-default-score)
5409 gnus-score-below-mark gnus-score-over-mark))
5411 (cond ((memq number gnus-newsgroup-processable)
5413 ((memq number gnus-newsgroup-cached)
5415 ((memq number gnus-newsgroup-replied)
5417 ((memq number gnus-newsgroup-forwarded)
5418 gnus-forwarded-mark)
5419 ((memq number gnus-newsgroup-saved)
5421 ((memq number gnus-newsgroup-unseen)
5425 (cond ((memq number gnus-newsgroup-undownloaded)
5426 gnus-undownloaded-mark)
5427 (gnus-newsgroup-agentized
5428 gnus-downloaded-mark)
5431 gnus-tmp-from (mail-header-from gnus-tmp-header)
5434 ((string-match "<[^>]+> *$" gnus-tmp-from)
5435 (setq beg-match (match-beginning 0))
5436 (or (and (string-match "^\".+\"" gnus-tmp-from)
5437 (substring gnus-tmp-from 1 (1- (match-end 0))))
5438 (substring gnus-tmp-from 0 beg-match)))
5439 ((string-match "(.+)" gnus-tmp-from)
5440 (substring gnus-tmp-from
5441 (1+ (match-beginning 0)) (1- (match-end 0))))
5445 gnus-tmp-thread-tree-header-string
5447 ((not gnus-show-threads) "")
5448 ((zerop gnus-tmp-level)
5449 (cond ((cdar thread)
5450 (or gnus-sum-thread-tree-root subject))
5451 (gnus-tmp-new-adopts
5452 (or gnus-sum-thread-tree-false-root subject))
5454 (or gnus-sum-thread-tree-single-indent subject))))
5456 (concat (apply 'concat
5457 (mapcar (lambda (item)
5459 gnus-sum-thread-tree-vertical
5460 gnus-sum-thread-tree-indent))
5461 (cdr (reverse tree-stack))))
5463 gnus-sum-thread-tree-leaf-with-other
5464 gnus-sum-thread-tree-single-leaf)))))
5465 (when (string= gnus-tmp-name "")
5466 (setq gnus-tmp-name gnus-tmp-from))
5467 (unless (numberp gnus-tmp-lines)
5468 (setq gnus-tmp-lines -1))
5469 (if (= gnus-tmp-lines -1)
5470 (setq gnus-tmp-lines "?")
5471 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5472 (gnus-put-text-property
5474 (progn (eval gnus-summary-line-format-spec) (point))
5475 'gnus-number number)
5478 (gnus-summary-highlight-line)
5479 (when gnus-summary-update-hook
5480 (gnus-run-hooks 'gnus-summary-update-hook))
5483 (setq gnus-tmp-prev-subject simp-subject)))
5485 (when (nth 1 thread)
5486 (push (list (max 0 gnus-tmp-level)
5487 (copy-sequence tree-stack)
5490 (push (if (nth 1 thread) 1 0) tree-stack)
5491 (incf gnus-tmp-level)
5492 (setq threads (if thread-end nil (cdar thread)))
5493 (if gnus-summary-display-while-building
5496 ;; use a set frequency
5497 (setq building-line-count (1- building-line-count))
5498 (when (= building-line-count 0)
5500 (setq building-line-count
5501 gnus-summary-display-while-building)))
5505 (setq gnus-tmp-level 0)))))
5506 (gnus-message 7 "Generating summary...done"))
5508 (defun gnus-summary-prepare-unthreaded (headers)
5509 "Generate an unthreaded summary buffer based on HEADERS."
5510 (let (header number mark)
5515 ;; We may have to root out some bad articles...
5516 (when (memq (setq number (mail-header-number
5517 (setq header (pop headers))))
5518 gnus-newsgroup-limit)
5519 ;; Mark article as read when it has a low score.
5520 (when (and gnus-summary-mark-below
5521 (< (or (cdr (assq number gnus-newsgroup-scored))
5522 gnus-summary-default-score 0)
5523 gnus-summary-mark-below)
5524 (not (gnus-summary-article-ancient-p number)))
5525 (setq gnus-newsgroup-unreads
5526 (delq number gnus-newsgroup-unreads))
5527 (if gnus-newsgroup-auto-expire
5528 (push number gnus-newsgroup-expirable)
5529 (push (cons number gnus-low-score-mark)
5530 gnus-newsgroup-reads)))
5532 (setq mark (gnus-article-mark number))
5533 (push (gnus-data-make number mark (1+ (point)) header 0)
5534 gnus-newsgroup-data)
5535 (gnus-summary-insert-line
5537 (memq number gnus-newsgroup-undownloaded)
5538 mark (memq number gnus-newsgroup-replied)
5539 (memq number gnus-newsgroup-expirable)
5540 (mail-header-subject header) nil
5541 (cdr (assq number gnus-newsgroup-scored))
5542 (memq number gnus-newsgroup-processable))))))
5544 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5546 (defun gnus-group-get-list-identifiers (group)
5547 "Get list identifier regexp for GROUP."
5548 (or (gnus-parameter-list-identifier group)
5549 (if (consp gnus-list-identifiers)
5550 (mapconcat 'identity gnus-list-identifiers " *\\|")
5551 gnus-list-identifiers)))
5553 (defun gnus-summary-remove-list-identifiers ()
5554 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5555 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5558 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5559 (dolist (header gnus-newsgroup-headers)
5560 (setq subject (mail-header-subject header)
5562 (while (string-match regexp subject)
5564 (concat (substring subject 0 (match-beginning 1))
5565 (substring subject (match-end 0)))
5568 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5570 (concat (substring subject 0 (match-beginning 1))
5571 (substring subject (match-end 1)))))
5572 (mail-header-set-subject header subject))))))
5574 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5575 "Fetch headers of ARTICLES."
5576 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5577 (gnus-message 7 "Fetching headers for %s..." name)
5580 (setq gnus-headers-retrieved-by
5581 (gnus-retrieve-headers
5582 articles gnus-newsgroup-name
5584 ;; We might want to fetch old headers, but
5585 ;; not if there is only 1 article.
5587 (not (eq gnus-fetch-old-headers 'some))
5588 (not (numberp gnus-fetch-old-headers)))
5589 (> (length articles) 1))
5590 gnus-fetch-old-headers)))))
5591 (gnus-get-newsgroup-headers-xover
5592 articles force-new dependencies gnus-newsgroup-name t)
5593 (gnus-get-newsgroup-headers dependencies force-new))
5594 (gnus-message 7 "Fetching headers for %s...done" name))))
5596 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5597 "Select newsgroup GROUP.
5598 If READ-ALL is non-nil, all articles in the group are selected.
5599 If SELECT-ARTICLES, only select those articles from GROUP."
5600 (let* ((entry (gnus-group-entry group))
5601 ;;!!! Dirty hack; should be removed.
5602 (gnus-summary-ignore-duplicates
5603 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5605 gnus-summary-ignore-duplicates))
5606 (info (nth 2 entry))
5607 charset articles fetched-articles cached)
5609 (unless (gnus-check-server
5610 (set (make-local-variable 'gnus-current-select-method)
5611 (gnus-find-method-for-group group)))
5612 (error "Couldn't open server"))
5613 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5615 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5616 (gnus-activate-group group) ; Or we can activate it...
5617 (progn ; Or we bug out.
5618 (when (derived-mode-p 'gnus-summary-mode)
5619 (gnus-kill-buffer (current-buffer)))
5621 "Couldn't activate group %s: %s"
5622 (mm-decode-coding-string group charset)
5623 (mm-decode-coding-string (gnus-status-message group) charset))))
5625 (unless (gnus-request-group group t nil (gnus-get-info group))
5626 (when (derived-mode-p 'gnus-summary-mode)
5627 (gnus-kill-buffer (current-buffer)))
5628 (error "Couldn't request group %s: %s"
5629 (mm-decode-coding-string group charset)
5630 (mm-decode-coding-string (gnus-status-message group) charset)))
5632 (when (and gnus-agent
5633 (gnus-active group))
5634 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5636 (setq gnus-summary-use-undownloaded-faces
5637 (gnus-agent-find-parameter
5639 'agent-enable-undownloaded-faces)))
5641 (setq gnus-newsgroup-name group
5642 gnus-newsgroup-unselected nil
5643 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5645 (let ((display (gnus-group-find-parameter group 'display)))
5646 (setq gnus-newsgroup-display
5648 ((not (zerop (or (car-safe read-all) 0)))
5649 ;; The user entered the group with C-u SPC/RET, let's show
5655 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5657 ;; The following is probably the "correct" solution, but
5658 ;; it makes Gnus fetch all headers and then limit the
5659 ;; articles (which is slow), so instead we hack the
5660 ;; select-articles parameter instead. -- Simon Josefsson
5663 ;; (gnus-byte-compile
5664 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5666 (setq select-articles
5667 (gnus-uncompress-range
5668 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5672 (cdr (gnus-active group)))))
5677 (gnus-summary-setup-default-charset)
5679 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5680 (when (gnus-virtual-group-p group)
5681 (setq cached gnus-newsgroup-cached))
5683 (setq gnus-newsgroup-unreads
5684 (gnus-sorted-ndifference
5685 (gnus-sorted-ndifference gnus-newsgroup-unreads
5686 gnus-newsgroup-marked)
5687 gnus-newsgroup-dormant))
5689 (setq gnus-newsgroup-processable nil)
5691 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5693 ;; Adjust and set lists of article marks.
5695 (gnus-adjust-marked-articles info))
5696 (if (setq articles select-articles)
5697 (setq gnus-newsgroup-unselected
5698 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5699 (setq articles (gnus-articles-to-read group read-all)))
5703 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5705 ((eq articles 0) nil)
5707 ;; Init the dependencies hash table.
5708 (setq gnus-newsgroup-dependencies
5709 (gnus-make-hashtable (length articles)))
5710 (if (gnus-buffer-live-p gnus-group-buffer)
5711 (gnus-set-global-variables)
5712 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5713 ;; Retrieve the headers and read them in.
5715 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5717 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5719 (setq gnus-newsgroup-cached cached))
5721 ;; Suppress duplicates?
5722 (when gnus-suppress-duplicates
5723 (gnus-dup-suppress-articles))
5725 ;; Set the initial limit.
5726 (setq gnus-newsgroup-limit (copy-sequence articles))
5727 ;; Remove canceled articles from the list of unread articles.
5728 (setq fetched-articles
5729 (mapcar (lambda (headers) (mail-header-number headers))
5730 gnus-newsgroup-headers))
5731 (setq gnus-newsgroup-articles fetched-articles)
5732 (setq gnus-newsgroup-unreads
5733 (gnus-sorted-nintersection
5734 gnus-newsgroup-unreads fetched-articles))
5735 (gnus-compute-unseen-list)
5737 ;; Removed marked articles that do not exist.
5738 (gnus-update-missing-marks
5739 (gnus-sorted-difference articles fetched-articles))
5740 ;; We might want to build some more threads first.
5741 (when (and gnus-fetch-old-headers
5742 (eq gnus-headers-retrieved-by 'nov))
5743 (if (eq gnus-fetch-old-headers 'invisible)
5744 (gnus-build-all-threads)
5745 (gnus-build-old-threads)))
5746 ;; Let the Gnus agent mark articles as read.
5748 (gnus-agent-get-undownloaded-list))
5749 ;; Remove list identifiers from subject
5750 (gnus-summary-remove-list-identifiers)
5751 ;; Check whether auto-expire is to be done in this group.
5752 (setq gnus-newsgroup-auto-expire
5753 (and (gnus-group-auto-expirable-p group)
5754 (not (gnus-group-read-only-p group))))
5755 ;; Set up the article buffer now, if necessary.
5756 (unless (and gnus-single-article-buffer
5757 (equal gnus-article-buffer "*Article*"))
5758 (gnus-article-setup-buffer))
5759 ;; First and last article in this newsgroup.
5760 (when gnus-newsgroup-headers
5761 (setq gnus-newsgroup-begin
5762 (mail-header-number (car gnus-newsgroup-headers))
5765 (gnus-last-element gnus-newsgroup-headers))))
5766 ;; GROUP is successfully selected.
5767 (or gnus-newsgroup-headers t)))))
5769 (defun gnus-compute-unseen-list ()
5770 ;; The `seen' marks are treated specially.
5771 (if (not gnus-newsgroup-seen)
5772 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5773 (setq gnus-newsgroup-unseen
5774 (gnus-inverse-list-range-intersection
5775 gnus-newsgroup-articles gnus-newsgroup-seen))))
5777 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5779 (defun gnus-summary-display-make-predicate (display)
5780 (require 'gnus-agent)
5781 (when (= (length display) 1)
5782 (setq display (car display)))
5783 (unless gnus-summary-display-cache
5784 (dolist (elem (append '((unread . unread)
5787 gnus-article-mark-lists))
5788 (push (cons (cdr elem)
5789 (gnus-byte-compile ;Why bother?
5790 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5791 gnus-summary-display-cache)))
5792 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5793 (gnus-category-predicate-cache gnus-summary-display-cache))
5794 (gnus-get-predicate display)))
5796 ;; Uses the dynamically bound `gnus-number' variable.
5797 (defvar gnus-number)
5798 (defun gnus-article-marked-p (type &optional article)
5799 (let ((article (or article gnus-number)))
5802 (memq article gnus-newsgroup-marked))
5804 (memq article gnus-newsgroup-spam-marked))
5806 (memq article gnus-newsgroup-unsendable))
5807 ((eq type 'undownload)
5808 (memq article gnus-newsgroup-undownloaded))
5809 ((eq type 'download)
5810 (memq article gnus-newsgroup-downloadable))
5812 (memq article gnus-newsgroup-unreads))
5814 (memq article gnus-newsgroup-reads))
5816 (memq article gnus-newsgroup-dormant) )
5818 (memq article gnus-newsgroup-expirable))
5820 (memq article gnus-newsgroup-replied))
5822 (memq article gnus-newsgroup-killed))
5823 ((eq type 'bookmark)
5824 (assq article gnus-newsgroup-bookmarks))
5826 (assq article gnus-newsgroup-scored))
5828 (memq article gnus-newsgroup-saved))
5830 (memq article gnus-newsgroup-cached))
5832 (memq article gnus-newsgroup-forwarded))
5834 (not (memq article gnus-newsgroup-unseen)))
5837 (defun gnus-articles-to-read (group &optional read-all)
5838 "Find out what articles the user wants to read."
5839 (let* ((only-read-p t)
5841 (gnus-list-range-difference
5842 ;; Select all articles if `read-all' is non-nil, or if there
5843 ;; are no unread articles.
5845 (and (zerop (length gnus-newsgroup-marked))
5846 (zerop (length gnus-newsgroup-unreads)))
5847 ;; Fetch all if the predicate is non-nil.
5848 gnus-newsgroup-display)
5849 ;; We want to select the headers for all the articles in
5850 ;; the group, so we select either all the active
5851 ;; articles in the group, or (if that's nil), the
5852 ;; articles in the cache.
5854 (if gnus-newsgroup-maximum-articles
5855 (let ((active (gnus-active group)))
5856 (gnus-uncompress-range
5857 (cons (max (car active)
5859 gnus-newsgroup-maximum-articles
5862 (gnus-uncompress-range (gnus-active group)))
5863 (gnus-cache-articles-in-group group))
5864 ;; Select only the "normal" subset of articles.
5865 (setq only-read-p nil)
5867 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5868 gnus-newsgroup-unreads))
5869 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5870 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5871 (scored (length scored-list))
5872 (number (length articles))
5873 (marked (+ (length gnus-newsgroup-marked)
5874 (length gnus-newsgroup-dormant)))
5879 ((numberp gnus-newsgroup-display)
5880 gnus-newsgroup-display)
5884 ((and (or (<= scored marked) (= scored number))
5885 (numberp gnus-large-newsgroup)
5886 (> number gnus-large-newsgroup))
5887 (let* ((cursor-in-echo-area nil)
5888 (initial (gnus-parameter-large-newsgroup-initial
5889 gnus-newsgroup-name))
5890 (default (if only-read-p
5891 (or initial gnus-large-newsgroup)
5897 "How many articles from %s (available %d, default %d): "
5898 (gnus-group-decoded-name
5899 (gnus-group-real-name gnus-newsgroup-name))
5902 "How many articles from %s (%d default): "
5903 (gnus-group-decoded-name
5904 (gnus-group-real-name gnus-newsgroup-name))
5908 (number-to-string default))))
5909 (if (string-match "^[ \t]*$" input) number input)))
5910 ((and (> scored marked) (< scored number)
5911 (> (- scored number) 20))
5914 (format "%s %s (%d scored, %d total): "
5915 "How many articles from"
5916 (gnus-group-decoded-name
5917 (gnus-group-real-name gnus-newsgroup-name))
5919 (if (string-match "^[ \t]*$" input)
5923 (message "Quit getting the articles to read")
5925 (setq select (if (stringp select) (string-to-number select) select))
5926 (if (or (null select) (zerop select))
5928 (if (and (not (zerop scored)) (<= (abs select) scored))
5930 (setq articles (sort scored-list '<))
5931 (setq number (length articles)))
5932 (setq articles (copy-sequence articles)))
5934 (when (< (abs select) number)
5936 ;; Select the N oldest articles.
5937 (setcdr (nthcdr (1- (abs select)) articles) nil)
5938 ;; Select the N most recent articles.
5939 (setq articles (nthcdr (- number select) articles))))
5940 (setq gnus-newsgroup-unselected
5941 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5942 (when gnus-alter-articles-to-read-function
5945 (funcall gnus-alter-articles-to-read-function
5946 gnus-newsgroup-name articles)
5950 (defun gnus-killed-articles (killed articles)
5953 (when (inline (gnus-member-of-range (car articles) killed))
5954 (push (car articles) out))
5955 (setq articles (cdr articles)))
5958 (defun gnus-article-mark-to-type (mark)
5959 "Return the type of MARK."
5960 (or (cadr (assq mark gnus-article-special-mark-lists))
5963 (defun gnus-article-unpropagatable-p (mark)
5964 "Return whether MARK should be propagated to back end."
5965 (memq mark gnus-article-unpropagated-mark-lists))
5967 (defun gnus-adjust-marked-articles (info)
5968 "Set all article lists and remove all marks that are no longer valid."
5969 (let* ((marked-lists (gnus-info-marks info))
5970 (active (gnus-active (gnus-info-group info)))
5973 (types gnus-article-mark-lists)
5974 marks var articles article mark mark-type
5976 ;; Hack to avoid adjusting marks for imap.
5977 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5981 (dolist (marks marked-lists)
5982 (setq mark (car marks)
5983 mark-type (gnus-article-mark-to-type mark)
5984 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5985 ;; We set the variable according to the type of the marks list,
5986 ;; and then adjust the marks to a subset of the active articles.
5988 ;; Adjust "simple" lists - compressed yet unsorted
5989 ((eq mark-type 'list)
5990 ;; Simultaneously uncompress and clip to active range
5991 ;; See gnus-uncompress-range for a description of possible marks
5993 (if (not (cadr marks))
5995 (setq articles (if (numberp (cddr marks))
6001 (while (setq article (pop articles))
6002 (cond ((consp article)
6003 (setq bgn (max (car article) min)
6004 end (min (cdr article) max))
6006 (setq l (setcdr l (cons bgn nil))
6008 ((and (<= min article)
6010 (setq l (setcdr l (cons article nil))))))
6011 (set var (cdr lh)))))
6013 ((eq mark-type 'tuple)
6014 (set var (setq articles (cdr marks)))
6015 (when (not (listp (cdr (symbol-value var))))
6016 (set var (list (symbol-value var))))
6017 (when (not (listp (cdr articles)))
6018 (setq articles (list articles)))
6020 (when (or (not (consp (setq article (pop articles))))
6021 (< (car article) min)
6022 (> (car article) max))
6023 (set var (delq article (symbol-value var))))))
6024 ;; Adjust ranges (sloppily).
6025 ((eq mark-type 'range)
6028 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6029 ;; It should be (seen (NUM1 . NUM2)).
6030 (when (numberp (cddr marks))
6031 (setcdr marks (list (cdr marks))))
6032 (setq articles (cdr marks))
6033 (while (and articles
6034 (or (and (consp (car articles))
6035 (> min (cdar articles)))
6036 (and (numberp (car articles))
6037 (> min (car articles)))))
6041 (set var (cdr marks)))))))))
6043 (defun gnus-update-missing-marks (missing)
6044 "Go through the list of MISSING articles and remove them from the mark lists."
6047 ;; Go through all types.
6048 (dolist (elem gnus-article-mark-lists)
6049 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6050 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6051 (when (symbol-value var)
6052 ;; This list has articles. So we delete all missing
6053 ;; articles from it.
6056 (set var (delq (pop m) (symbol-value var))))))))))
6058 (defun gnus-update-marks ()
6059 "Enter the various lists of marked articles into the newsgroup info list."
6060 (let ((types gnus-article-mark-lists)
6061 (info (gnus-get-info gnus-newsgroup-name))
6062 type list newmarked symbol delta-marks)
6064 ;; Add all marks lists to the list of marks lists.
6065 (while (setq type (pop types))
6066 (setq list (symbol-value
6068 (intern (format "gnus-newsgroup-%s" (car type))))))
6071 ;; Get rid of the entries of the articles that have the
6073 (when (and (eq (cdr type) 'score)
6077 (prev (cons nil list))
6080 (if (or (not (consp (car arts)))
6081 (= (cdar arts) gnus-summary-default-score))
6082 (setcdr prev (cdr arts))
6084 (setq arts (cdr arts)))
6085 (setq list (cdr all)))))
6087 (when (eq (cdr type) 'seen)
6088 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6090 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6091 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6093 (when (and (gnus-check-backend-function
6094 'request-set-mark gnus-newsgroup-name)
6095 (not (gnus-article-unpropagatable-p (cdr type))))
6096 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6097 ;; Don't do anything about marks for articles we
6098 ;; didn't actually get any headers for.
6100 (gnus-list-range-intersection
6101 gnus-newsgroup-articles
6102 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6104 (gnus-list-range-intersection
6105 gnus-newsgroup-articles
6106 (gnus-remove-from-range
6107 (gnus-copy-sequence list) old))))
6109 (push (list add 'add (list (cdr type))) delta-marks))
6111 ;; Don't delete marks from outside the active range.
6112 ;; This shouldn't happen, but is a sanity check.
6113 (setq del (gnus-sorted-range-intersection
6114 (gnus-active gnus-newsgroup-name) del))
6115 (push (list del 'del (list (cdr type))) delta-marks))))
6118 (eq (cdr type) 'unexist))
6119 (push (cons (cdr type) list) newmarked)))
6122 (unless (gnus-check-group gnus-newsgroup-name)
6123 (error "Can't open server for %s" gnus-newsgroup-name))
6124 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6126 ;; Enter these new marks into the info of the group.
6128 (setcar (nthcdr 3 info) newmarked)
6129 ;; Add the marks lists to the end of the info.
6131 (setcdr (nthcdr 2 info) (list newmarked))))
6133 ;; Cut off the end of the info if there's nothing else there.
6137 (when (nthcdr (decf i) info)
6138 (setcdr (nthcdr i info) nil)))))))
6140 (defun gnus-set-mode-line (where)
6141 "Set the mode line of the article or summary buffers.
6142 If WHERE is `summary', the summary mode line format will be used."
6143 ;; Is this mode line one we keep updated?
6144 (when (and (memq where gnus-updated-mode-lines)
6146 (intern (format "gnus-%s-mode-line-format-spec" where))))
6148 ;; We evaluate this in the summary buffer since these
6149 ;; variables are buffer-local to that buffer.
6150 (with-current-buffer gnus-summary-buffer
6151 ;; We bind all these variables that are used in the `eval' form
6153 (let* ((mformat (symbol-value
6155 (format "gnus-%s-mode-line-format-spec" where))))
6156 (gnus-tmp-group-name (gnus-mode-string-quote
6157 (gnus-group-decoded-name
6158 gnus-newsgroup-name)))
6159 (gnus-tmp-article-number (or gnus-current-article 0))
6160 (gnus-tmp-unread gnus-newsgroup-unreads)
6161 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6162 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6163 (gnus-tmp-unread-and-unselected
6164 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6165 (zerop gnus-tmp-unselected))
6167 ((zerop gnus-tmp-unselected)
6168 (format "{%d more}" gnus-tmp-unread-and-unticked))
6169 (t (format "{%d(+%d) more}"
6170 gnus-tmp-unread-and-unticked
6171 gnus-tmp-unselected))))
6173 (if (and gnus-current-headers
6174 (vectorp gnus-current-headers))
6175 (gnus-mode-string-quote
6176 (mail-header-subject gnus-current-headers))
6178 bufname-length max-len
6179 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6180 (setq mode-string (eval mformat))
6181 (setq bufname-length (if (string-match "%b" mode-string)
6184 (if (eq where 'summary)
6186 (get-buffer gnus-article-buffer))))
6189 (setq max-len (max 4 (if gnus-mode-non-string-length
6191 gnus-mode-non-string-length
6193 (length mode-string))))
6194 ;; We might have to chop a bit of the string off...
6195 (when (> (length mode-string) max-len)
6197 (concat (truncate-string-to-width mode-string (- max-len 3))
6199 ;; Update the mode line.
6200 (setq mode-line-buffer-identification
6201 (gnus-mode-line-buffer-identification (list mode-string)))
6202 (set-buffer-modified-p t))))
6204 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6205 "Go through the HEADERS list and add all Xrefs to a hash table.
6206 The resulting hash table is returned, or nil if no Xrefs were found."
6207 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6208 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6209 (xref-hashtb (gnus-make-hashtable))
6210 start group entry number xrefs header)
6212 (setq header (pop headers))
6213 (when (and (setq xrefs (mail-header-xref header))
6214 (not (memq (setq number (mail-header-number header))
6217 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6218 (setq start (match-end 0))
6219 (setq group (if prefix
6220 (concat prefix (substring xrefs (match-beginning 1)
6222 (substring xrefs (match-beginning 1) (match-end 1))))
6224 (string-to-number (substring xrefs (match-beginning 2)
6226 (if (setq entry (gnus-gethash group xref-hashtb))
6227 (setcdr entry (cons number (cdr entry)))
6228 (gnus-sethash group (cons number nil) xref-hashtb)))))
6229 (and start xref-hashtb)))
6231 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6232 "Look through all the headers and mark the Xrefs as read."
6233 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6234 name info xref-hashtb idlist method nth4)
6235 (with-current-buffer gnus-group-buffer
6236 (when (setq xref-hashtb
6237 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6240 (unless (string= from-newsgroup (setq name (symbol-name group)))
6241 (setq idlist (symbol-value group))
6242 ;; Dead groups are not updated.
6244 (setq info (gnus-get-info name))
6245 (when (stringp (setq nth4 (gnus-info-method info)))
6246 (setq nth4 (gnus-server-to-method nth4))))
6247 ;; Only do the xrefs if the group has the same
6248 ;; select method as the group we have just read.
6249 (or (gnus-methods-equal-p
6250 nth4 (gnus-find-method-for-group from-newsgroup))
6252 (equal nth4 (setq method (gnus-find-method-for-group
6254 (and (equal (car nth4) (car method))
6255 (equal (nth 1 nth4) (nth 1 method))))
6256 gnus-use-cross-reference
6257 (or (not (eq gnus-use-cross-reference t))
6259 ;; Only do cross-references on subscribed
6260 ;; groups, if that is what is wanted.
6261 (<= (gnus-info-level info) gnus-level-subscribed))
6262 (gnus-group-make-articles-read name idlist))))
6265 (defun gnus-compute-read-articles (group articles)
6266 (let* ((entry (gnus-group-entry group))
6267 (info (nth 2 entry))
6268 (active (gnus-active group))
6271 ;; First peel off all invalid article numbers.
6273 (let ((ids articles)
6275 (while (setq id (pop ids))
6276 (when (and first (> id (cdr active)))
6277 ;; We'll end up in this situation in one particular
6278 ;; obscure situation. If you re-scan a group and get
6279 ;; a new article that is cross-posted to a different
6280 ;; group that has not been re-scanned, you might get
6281 ;; crossposted article that has a higher number than
6282 ;; Gnus believes possible. So we re-activate this
6283 ;; group as well. This might mean doing the
6284 ;; crossposting thingy will *increase* the number
6285 ;; of articles in some groups. Tsk, tsk.
6286 (setq active (or (gnus-activate-group group) active)))
6287 (when (or (> id (cdr active))
6288 (< id (car active)))
6289 (setq articles (delq id articles))))))
6290 ;; If the read list is nil, we init it.
6292 (null (gnus-info-read info))
6294 (setq ninfo (cons 1 (1- (car active))))
6295 (setq ninfo (gnus-info-read info)))
6296 ;; Then we add the read articles to the range.
6298 ninfo (setq articles (sort articles '<))))))
6300 (defun gnus-group-make-articles-read (group articles)
6301 "Update the info of GROUP to say that ARTICLES are read."
6303 (entry (gnus-group-entry group))
6304 (info (nth 2 entry))
6305 (active (gnus-active group))
6307 (gnus-method-option-p
6308 (gnus-find-method-for-group group)
6312 ;; Group that Gnus doesn't know exists, but still allow the
6313 ;; backend to set marks.
6315 (gnus-request-set-mark
6316 group (list (list (gnus-compress-sequence (sort articles #'<))
6318 ;; Normal, subscribed groups.
6319 (setq range (gnus-compute-read-articles group articles))
6320 (with-current-buffer gnus-group-buffer
6323 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6324 (gnus-info-set-read ',info ',(gnus-info-read info))
6325 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6327 (gnus-request-set-mark
6328 ,group (list (list ',range 'del '(read)))))
6329 (gnus-group-update-group ,group t))))
6330 ;; Add the read articles to the range.
6331 (gnus-info-set-read info range)
6333 (gnus-request-set-mark group (list (list range 'add '(read)))))
6334 ;; Then we have to re-compute how many unread
6335 ;; articles there are in this group.
6339 (setq num (- (1+ (cdr active)) (car active))))
6340 ((not (listp (cdr range)))
6341 (setq num (- (cdr active) (- (1+ (cdr range))
6345 (if (numberp (car range))
6347 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6348 (setq range (cdr range)))
6349 (setq num (- (cdr active) num))))
6350 ;; Update the number of unread articles.
6352 ;; Update the group buffer.
6353 (unless (gnus-ephemeral-group-p group)
6354 (gnus-group-update-group group t))))))
6356 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6357 (let ((cur nntp-server-buffer)
6360 (with-current-buffer gnus-summary-buffer
6361 gnus-newsgroup-dependencies)))
6362 headers id end ref number
6363 (mail-parse-charset gnus-newsgroup-charset)
6364 (mail-parse-ignored-charsets
6365 (save-current-buffer (condition-case nil
6366 (set-buffer gnus-summary-buffer)
6368 gnus-newsgroup-ignored-charsets)))
6369 (with-current-buffer nntp-server-buffer
6370 ;; Translate all TAB characters into SPACE characters.
6371 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6372 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6373 (ietf-drums-unfold-fws)
6374 (gnus-run-hooks 'gnus-parse-headers-hook)
6375 (let ((case-fold-search t)
6376 in-reply-to header p lines chars)
6377 (goto-char (point-min))
6378 ;; Search to the beginning of the next header. Error messages
6379 ;; do not begin with 2 or 3.
6380 (while (re-search-forward "^[23][0-9]+ " nil t)
6383 ;; This implementation of this function, with nine
6384 ;; search-forwards instead of the one re-search-forward and
6385 ;; a case (which basically was the old function) is actually
6386 ;; about twice as fast, even though it looks messier. You
6387 ;; can't have everything, I guess. Speed and elegance
6388 ;; doesn't always go hand in hand.
6394 (setq number (read cur))
6397 (narrow-to-region (point)
6398 (or (and (search-forward "\n.\n" nil t)
6404 (if (search-forward "\nsubject:" nil t)
6405 (funcall gnus-decode-encoded-word-function
6406 (nnheader-header-value))
6411 (if (search-forward "\nfrom:" nil t)
6412 (funcall gnus-decode-encoded-address-function
6413 (nnheader-header-value))
6418 (if (search-forward "\ndate:" nil t)
6419 (nnheader-header-value) ""))
6423 (setq id (if (re-search-forward
6424 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6425 ;; We do it this way to make sure the Message-ID
6426 ;; is (somewhat) syntactically valid.
6427 (buffer-substring (match-beginning 1)
6429 ;; If there was no message-id, we just fake one
6430 ;; to make subsequent routines simpler.
6431 (nnheader-generate-fake-message-id number))))
6435 (if (search-forward "\nreferences:" nil t)
6439 (nnheader-header-value)
6444 (search-backward ">" end t)
6447 (search-backward "<" end t)
6449 ;; Get the references from the in-reply-to header if there
6450 ;; were no references and the in-reply-to header looks
6452 (if (and (search-forward "\nin-reply-to:" nil t)
6453 (setq in-reply-to (nnheader-header-value))
6454 (string-match "<[^>]+>" in-reply-to))
6456 (setq ref (substring in-reply-to (match-beginning 0)
6458 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6459 (setq ref2 (substring in-reply-to (match-beginning 0)
6461 (when (> (length ref2) (length ref))
6468 (if (search-forward "\nchars: " nil t)
6469 (if (numberp (setq chars (ignore-errors (read cur))))
6475 (if (search-forward "\nlines: " nil t)
6476 (if (numberp (setq lines (ignore-errors (read cur))))
6482 (and (search-forward "\nxref:" nil t)
6483 (nnheader-header-value)))
6485 (when gnus-extra-headers
6486 (let ((extra gnus-extra-headers)
6490 (when (search-forward
6491 (concat "\n" (symbol-name (car extra)) ":") nil t)
6492 (push (cons (car extra) (nnheader-header-value))
6496 (when (equal id ref)
6499 (when gnus-alter-header-function
6500 (funcall gnus-alter-header-function header)
6501 (setq id (mail-header-id header)
6502 ref (gnus-parent-id (mail-header-references header))))
6505 (gnus-dependencies-add-header
6506 header dependencies force-new))
6507 (push header headers))
6508 (goto-char (point-max))
6510 (nreverse headers)))))
6512 ;; Goes through the xover lines and returns a list of vectors
6513 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6514 force-new dependencies
6515 group also-fetch-heads)
6516 "Parse the news overview data in the server buffer.
6517 Return a list of headers that match SEQUENCE (see
6518 `nntp-retrieve-headers')."
6519 ;; Get the Xref when the users reads the articles since most/some
6520 ;; NNTP servers do not include Xrefs when using XOVER.
6521 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6522 (let ((mail-parse-charset gnus-newsgroup-charset)
6523 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6524 (cur nntp-server-buffer)
6525 (dependencies (or dependencies gnus-newsgroup-dependencies))
6527 ((eq gnus-read-all-available-headers t)
6529 ((and (stringp gnus-read-all-available-headers)
6531 (string-match gnus-read-all-available-headers group))
6534 number headers header)
6535 (with-current-buffer nntp-server-buffer
6536 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6537 ;; Allow the user to mangle the headers before parsing them.
6538 (gnus-run-hooks 'gnus-parse-headers-hook)
6539 (goto-char (point-min))
6540 (gnus-parse-without-error
6541 (while (and (or sequence allp)
6543 (setq number (read cur))
6545 (while (and sequence
6546 (< (car sequence) number))
6547 (setq sequence (cdr sequence))))
6550 (eq number (car sequence))))
6552 (setq sequence (cdr sequence))
6553 (setq header (inline
6554 (gnus-nov-parse-line
6555 number dependencies force-new)))))
6556 (push header headers))
6558 ;; A common bug in inn is that if you have posted an article and
6559 ;; then retrieves the active file, it will answer correctly --
6560 ;; the new article is included. However, a NOV entry for the
6561 ;; article may not have been generated yet, so this may fail.
6562 ;; We work around this problem by retrieving the last few
6563 ;; headers using HEAD.
6564 (if (or (not also-fetch-heads)
6566 ;; We (probably) got all the headers.
6568 (let ((gnus-nov-is-evil t))
6571 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6572 (gnus-get-newsgroup-headers))))))))
6574 (defun gnus-article-get-xrefs ()
6575 "Fill in the Xref value in `gnus-current-headers', if necessary.
6576 This is meant to be called in `gnus-article-internal-prepare-hook'."
6577 (let ((headers (with-current-buffer gnus-summary-buffer
6578 gnus-current-headers)))
6579 (or (not gnus-use-cross-reference)
6581 (and (mail-header-xref headers)
6582 (not (string= (mail-header-xref headers) "")))
6583 (let ((case-fold-search t)
6586 (nnheader-narrow-to-headers)
6587 (goto-char (point-min))
6588 (when (or (and (not (eobp))
6589 (eq (downcase (char-after)) ?x)
6590 (looking-at "Xref:"))
6591 (search-forward "\nXref:" nil t))
6592 (goto-char (1+ (match-end 0)))
6593 (setq xref (buffer-substring (point) (point-at-eol)))
6594 (mail-header-set-xref headers xref)))))))
6596 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6597 "Find article ID and insert the summary line for that article.
6598 OLD-HEADER can either be a header or a line number to insert
6599 the subject line on.
6600 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6601 and OLD-HEADER will be used when the summary line is inserted,
6602 too, instead of trying to fetch new headers."
6603 (let* ((line (and (numberp old-header) old-header))
6604 (old-header (and (vectorp old-header) old-header))
6605 (header (cond ((and old-header use-old-header)
6608 (gnus-number-to-header id))
6609 (gnus-number-to-header id))
6611 (gnus-read-header id))))
6612 (number (and (numberp id) id))
6615 ;; Rebuild the thread that this article is part of and go to the
6616 ;; article we have fetched.
6617 (when (and (not gnus-show-threads)
6620 (setq d (gnus-data-find (mail-header-number old-header))))
6621 (goto-char (gnus-data-pos d))
6627 (gnus-delete-line))))))
6628 ;; Remove list identifiers from subject.
6629 (let ((gnus-newsgroup-headers (list header)))
6630 (gnus-summary-remove-list-identifiers))
6632 (mail-header-set-number header (mail-header-number old-header)))
6633 (setq gnus-newsgroup-sparse
6634 (delq (setq number (mail-header-number header))
6635 gnus-newsgroup-sparse))
6636 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6637 (push number gnus-newsgroup-limit)
6638 (gnus-rebuild-thread (mail-header-id header) line)
6639 (gnus-summary-goto-subject number nil t))
6640 (when (and (numberp number)
6642 ;; We have to update the boundaries even if we can't fetch the
6643 ;; article if ID is a number -- so that the next `P' or `N'
6644 ;; command will fetch the previous (or next) article even
6645 ;; if the one we tried to fetch this time has been canceled.
6646 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6647 (setq gnus-newsgroup-end number))
6648 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6649 (setq gnus-newsgroup-begin number))
6650 (setq gnus-newsgroup-unselected
6651 (delq number gnus-newsgroup-unselected)))
6652 ;; Report back a success?
6653 (and header (mail-header-number header))))
6655 ;;; Process/prefix in the summary buffer
6657 (defun gnus-summary-work-articles (n)
6658 "Return a list of articles to be worked upon.
6659 The prefix argument, the list of process marked articles, and the
6660 current article will be taken into consideration."
6661 (with-current-buffer gnus-summary-buffer
6664 ;; A numerical prefix has been given.
6665 (setq n (prefix-numeric-value n))
6666 (let ((backward (< n 0))
6667 (n (abs (prefix-numeric-value n)))
6672 (push (setq article (gnus-summary-article-number))
6675 (gnus-summary-find-prev nil article)
6676 (gnus-summary-find-next nil article)))
6678 (nreverse articles)))
6679 ((and (gnus-region-active-p) (mark))
6680 (message "region active")
6681 ;; Work on the region between point and mark.
6682 (let ((max (max (point) (mark)))
6685 (goto-char (min (point) (mark)))
6688 (push (setq article (gnus-summary-article-number)) articles)
6689 (gnus-summary-find-next nil article)
6691 (nreverse articles))))
6692 (gnus-newsgroup-processable
6693 ;; There are process-marked articles present.
6694 ;; Save current state.
6695 (gnus-summary-save-process-mark)
6697 (reverse gnus-newsgroup-processable))
6699 ;; Just return the current article.
6700 (list (gnus-summary-article-number))))))
6702 (defmacro gnus-summary-iterate (arg &rest forms)
6703 "Iterate over the process/prefixed articles and do FORMS.
6704 ARG is the interactive prefix given to the command. FORMS will be
6705 executed with point over the summary line of the articles."
6706 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6707 `(let ((,articles (gnus-summary-work-articles ,arg)))
6709 (gnus-summary-goto-subject (car ,articles))
6713 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6714 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6716 (defun gnus-summary-save-process-mark ()
6717 "Push the current set of process marked articles on the stack."
6719 (push (copy-sequence gnus-newsgroup-processable)
6720 gnus-newsgroup-process-stack))
6722 (defun gnus-summary-kill-process-mark ()
6723 "Push the current set of process marked articles on the stack and unmark."
6725 (gnus-summary-save-process-mark)
6726 (gnus-summary-unmark-all-processable))
6728 (defun gnus-summary-yank-process-mark ()
6729 "Pop the last process mark state off the stack and restore it."
6731 (unless gnus-newsgroup-process-stack
6732 (error "Empty mark stack"))
6733 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6735 (defun gnus-summary-process-mark-set (set)
6736 "Make SET into the current process marked articles."
6737 (gnus-summary-unmark-all-processable)
6738 (mapc 'gnus-summary-set-process-mark set))
6740 ;;; Searching and stuff
6742 (defun gnus-summary-search-group (&optional backward use-level)
6743 "Search for next unread newsgroup.
6744 If optional argument BACKWARD is non-nil, search backward instead."
6745 (with-current-buffer gnus-group-buffer
6746 (when (gnus-group-search-forward
6747 backward nil (if use-level (gnus-group-group-level) nil))
6748 (gnus-group-group-name))))
6750 (defun gnus-summary-best-group (&optional exclude-group)
6751 "Find the name of the best unread group.
6752 If EXCLUDE-GROUP, do not go to this group."
6753 (with-current-buffer gnus-group-buffer
6755 (gnus-group-best-unread-group exclude-group))))
6757 (defun gnus-summary-find-next (&optional unread article backward)
6759 (gnus-summary-find-prev unread article)
6760 (let* ((dummy (gnus-summary-article-intangible-p))
6761 (article (or article (gnus-summary-article-number)))
6762 (data (gnus-data-find-list article))
6764 (when (and (not dummy)
6765 (or (not gnus-summary-check-current)
6767 (not (gnus-data-unread-p (car data)))))
6768 (setq data (cdr data)))
6773 (unless (memq (gnus-data-number (car data))
6775 ((eq gnus-auto-goto-ignores
6776 'always-undownloaded)
6777 gnus-newsgroup-undownloaded)
6780 ((eq gnus-auto-goto-ignores
6782 gnus-newsgroup-unfetched)
6783 ((eq gnus-auto-goto-ignores
6785 gnus-newsgroup-undownloaded)))
6786 (when (gnus-data-unread-p (car data))
6787 (setq result (car data)
6789 (setq data (cdr data)))
6792 (goto-char (gnus-data-pos result))
6793 (gnus-data-number result)))))
6795 (defun gnus-summary-find-prev (&optional unread article)
6796 (let* ((eobp (eobp))
6797 (article (or article (gnus-summary-article-number)))
6798 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6800 (when (and (not eobp)
6801 (or (not gnus-summary-check-current)
6803 (not (gnus-data-unread-p (car data)))))
6804 (setq data (cdr data)))
6809 (unless (memq (gnus-data-number (car data))
6811 ((eq gnus-auto-goto-ignores
6812 'always-undownloaded)
6813 gnus-newsgroup-undownloaded)
6816 ((eq gnus-auto-goto-ignores
6818 gnus-newsgroup-unfetched)
6819 ((eq gnus-auto-goto-ignores
6821 gnus-newsgroup-undownloaded)))
6822 (when (gnus-data-unread-p (car data))
6823 (setq result (car data)
6825 (setq data (cdr data)))
6828 (goto-char (gnus-data-pos result))
6829 (gnus-data-number result))))
6831 (defun gnus-summary-find-subject (subject &optional unread backward article)
6832 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6833 (article (or article (gnus-summary-article-number)))
6834 (articles (gnus-data-list backward))
6835 (arts (gnus-data-find-list article articles))
6837 (when (or (not gnus-summary-check-current)
6839 (not (gnus-data-unread-p (car arts))))
6840 (setq arts (cdr arts)))
6842 (and (or (not unread)
6843 (gnus-data-unread-p (car arts)))
6844 (vectorp (gnus-data-header (car arts)))
6846 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6847 (setq result (car arts)
6849 (setq arts (cdr arts)))
6851 (goto-char (gnus-data-pos result))
6852 (gnus-data-number result))))
6854 (defun gnus-summary-search-forward (&optional unread subject backward)
6855 "Search forward for an article.
6856 If UNREAD, look for unread articles. If SUBJECT, look for
6857 articles with that subject. If BACKWARD, search backward instead."
6858 (cond (subject (gnus-summary-find-subject subject unread backward))
6859 (backward (gnus-summary-find-prev unread))
6860 (t (gnus-summary-find-next unread))))
6862 (defun gnus-recenter (&optional n)
6863 "Center point in window and redisplay frame.
6864 Also do horizontal recentering."
6866 (when (and gnus-auto-center-summary
6867 (not (eq gnus-auto-center-summary 'vertical)))
6868 (gnus-horizontal-recenter))
6869 (if (fboundp 'recenter-top-bottom)
6870 (recenter-top-bottom n)
6873 (put 'gnus-recenter 'isearch-scroll t)
6875 (defun gnus-forward-line-ignore-invisible (n)
6876 "Move N lines forward (backward if N is negative).
6877 Like forward-line, but skip over (and don't count) invisible lines."
6879 (while (and (> n 0) (not done))
6880 ;; If the following character is currently invisible,
6881 ;; skip all characters with that same `invisible' property value.
6882 (while (gnus-invisible-p (point))
6883 (goto-char (gnus-next-char-property-change (point))))
6888 (while (and (< n 0) (not done))
6890 (if (bobp) (setq done t)
6892 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6893 (goto-char (gnus-previous-char-property-change (point))))))))
6895 (defun gnus-summary-recenter ()
6896 "Center point in the summary window.
6897 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6898 displayed, no centering will be performed."
6899 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6900 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6902 ;; The user has to want it.
6903 (when gnus-auto-center-summary
6904 (let* ((top (cond ((< (window-height) 4) 0)
6905 ((< (window-height) 7) 1)
6906 (t (if (numberp gnus-auto-center-summary)
6907 gnus-auto-center-summary
6908 (/ (1- (window-height)) 2)))))
6909 (height (1- (window-height)))
6910 (bottom (save-excursion
6911 (goto-char (point-max))
6912 (gnus-forward-line-ignore-invisible (- height))
6914 (window (get-buffer-window (current-buffer))))
6915 (when (get-buffer-window gnus-article-buffer)
6916 ;; Only do recentering when the article buffer is displayed,
6917 ;; Set the window start to either `bottom', which is the biggest
6918 ;; possible valid number, or the second line from the top,
6919 ;; whichever is the least.
6920 (let ((top-pos (save-excursion
6921 (gnus-forward-line-ignore-invisible (- top))
6923 (if (> bottom top-pos)
6924 ;; Keep the second line from the top visible
6925 (set-window-start window top-pos)
6926 ;; Try to keep the bottom line visible; if it's partially
6927 ;; obscured, either scroll one more line to make it fully
6928 ;; visible, or revert to using TOP-POS.
6930 (goto-char (point-max))
6931 (gnus-forward-line-ignore-invisible -1)
6932 (let ((last-line-start (point)))
6934 (set-window-start window (point) t)
6935 (when (not (pos-visible-in-window-p last-line-start window))
6936 (gnus-forward-line-ignore-invisible 1)
6937 (set-window-start window (min (point) top-pos) t)))))))
6938 ;; Do horizontal recentering while we're at it.
6939 (when (and (get-buffer-window (current-buffer) t)
6940 (not (eq gnus-auto-center-summary 'vertical)))
6941 (let ((selected (selected-window)))
6942 (select-window (get-buffer-window (current-buffer) t))
6943 (gnus-summary-position-point)
6944 (gnus-horizontal-recenter)
6945 (select-window selected))))))
6947 (defun gnus-summary-jump-to-group (newsgroup)
6948 "Move point to NEWSGROUP in group mode buffer."
6949 ;; Keep update point of group mode buffer if visible.
6950 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6951 (save-window-excursion
6952 ;; Take care of tree window mode.
6953 (when (get-buffer-window gnus-group-buffer)
6954 (pop-to-buffer gnus-group-buffer))
6955 (gnus-group-jump-to-group newsgroup))
6957 ;; Take care of tree window mode.
6958 (if (get-buffer-window gnus-group-buffer 0)
6959 (pop-to-buffer gnus-group-buffer)
6960 (set-buffer gnus-group-buffer))
6961 (gnus-group-jump-to-group newsgroup))))
6963 ;; This function returns a list of article numbers based on the
6964 ;; difference between the ranges of read articles in this group and
6965 ;; the range of active articles.
6966 (defun gnus-list-of-unread-articles (group)
6967 (let* ((read (gnus-info-read (gnus-get-info group)))
6968 (active (or (gnus-active group) (gnus-activate-group group)))
6969 (last (or (cdr active)
6970 (error "Group %s couldn't be activated " group)))
6971 (bottom (if gnus-newsgroup-maximum-articles
6973 (- last gnus-newsgroup-maximum-articles -1))
6976 ;; If none are read, then all are unread.
6979 ;; If the range of read articles is a single range, then the
6980 ;; first unread article is the article after the last read
6981 ;; article. Sounds logical, doesn't it?
6982 (if (and (not (listp (cdr read)))
6983 (or (< (car read) bottom)
6984 (progn (setq read (list read))
6986 (setq first (max bottom (1+ (cdr read))))
6987 ;; `read' is a list of ranges.
6988 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6991 (setq first bottom))
6994 (while (< first nlast)
6995 (setq unread (cons first unread)
6997 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6998 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6999 (setq read (cdr read)))))
7000 ;; And add the last unread articles.
7001 (while (<= first last)
7002 (setq unread (cons first unread)
7004 ;; Return the list of unread articles.
7005 (delq 0 (nreverse unread))))
7007 (defun gnus-list-of-read-articles (group)
7008 "Return a list of unread, unticked and non-dormant articles."
7009 (let* ((info (gnus-get-info group))
7010 (marked (gnus-info-marks info))
7011 (active (gnus-active group)))
7013 (gnus-list-range-difference
7014 (gnus-list-range-difference
7015 (gnus-sorted-complement
7016 (gnus-uncompress-range
7017 (if gnus-newsgroup-maximum-articles
7018 (cons (max (car active)
7020 gnus-newsgroup-maximum-articles
7024 (gnus-list-of-unread-articles group))
7025 (cdr (assq 'dormant marked)))
7026 (cdr (assq 'tick marked))))))
7028 ;; This function returns a sequence of article numbers based on the
7029 ;; difference between the ranges of read articles in this group and
7030 ;; the range of active articles.
7031 (defun gnus-sequence-of-unread-articles (group)
7032 (let* ((read (gnus-info-read (gnus-get-info group)))
7033 (active (or (gnus-active group) (gnus-activate-group group)))
7035 (bottom (if gnus-newsgroup-maximum-articles
7037 (- last gnus-newsgroup-maximum-articles -1))
7040 ;; If none are read, then all are unread.
7043 ;; If the range of read articles is a single range, then the
7044 ;; first unread article is the article after the last read
7045 ;; article. Sounds logical, doesn't it?
7046 (if (and (not (listp (cdr read)))
7047 (or (< (car read) bottom)
7048 (progn (setq read (list read))
7050 (setq first (max bottom (1+ (cdr read))))
7051 ;; `read' is a list of ranges.
7052 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7055 (setq first bottom))
7058 (push (cons first nlast) unread))
7059 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7060 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7061 (setq read (cdr read)))))
7062 ;; And add the last unread articles.
7063 (cond ((not (and first last))
7066 (push (cons first last) unread))
7068 (push first unread)))
7069 ;; Return the sequence of unread articles.
7070 (delq 0 (nreverse unread))))
7072 ;; Various summary commands
7074 (defun gnus-summary-select-article-buffer ()
7075 "Reconfigure windows to show the article buffer.
7076 If `gnus-widen-article-window' is set, show only the article
7079 (if (not (gnus-buffer-live-p gnus-article-buffer))
7080 (error "There is no article buffer for this summary buffer")
7081 (unless (get-buffer-window gnus-article-buffer)
7082 (gnus-summary-show-article))
7083 (gnus-configure-windows
7084 (if gnus-widen-article-window
7088 (select-window (get-buffer-window gnus-article-buffer))))
7090 (defun gnus-summary-universal-argument (arg)
7091 "Perform any operation on all articles that are process/prefixed."
7093 (let ((articles (gnus-summary-work-articles arg))
7100 (substitute-command-keys
7101 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7103 (gnus-error 1 "Undefined key")
7106 (gnus-summary-goto-subject (setq article (pop articles)))
7107 (let (gnus-newsgroup-processable)
7108 (command-execute func))
7109 (gnus-summary-remove-process-mark article)))))
7110 (gnus-summary-position-point))
7112 (defun gnus-summary-toggle-truncation (&optional arg)
7113 "Toggle truncation of summary lines.
7114 With ARG, turn line truncation on if ARG is positive."
7116 (setq truncate-lines
7117 (if (null arg) (not truncate-lines)
7118 (> (prefix-numeric-value arg) 0)))
7121 (defun gnus-summary-find-for-reselect ()
7122 "Return the number of an article to stay on across a reselect.
7123 The current article is considered, then following articles, then previous
7124 articles. An article is sought which is not canceled and isn't a temporary
7125 insertion from another group. If there's no such then return a dummy 0."
7127 (dolist (rev '(nil t))
7128 (unless found ; don't demand the reverse list if we don't need it
7129 (let ((data (gnus-data-find-list
7130 (gnus-summary-article-number) (gnus-data-list rev))))
7131 (while (and data (not found))
7132 (if (and (< 0 (gnus-data-number (car data)))
7133 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7134 (setq found (gnus-data-number (car data))))
7135 (setq data (cdr data))))))
7138 (defun gnus-summary-reselect-current-group (&optional all rescan)
7139 "Exit and then reselect the current newsgroup.
7140 The prefix argument ALL means to select all articles."
7142 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7143 (error "Ephemeral groups can't be reselected"))
7144 (let ((current-subject (gnus-summary-find-for-reselect))
7145 (group gnus-newsgroup-name))
7146 (setq gnus-newsgroup-begin nil)
7147 (gnus-summary-exit nil 'leave-hidden)
7148 ;; We have to adjust the point of group mode buffer because
7149 ;; point was moved to the next unread newsgroup by exiting.
7150 (gnus-summary-jump-to-group group)
7153 (gnus-group-get-new-news-this-group 1)))
7154 (gnus-group-read-group all t)
7155 (gnus-summary-goto-subject current-subject nil t)))
7157 (defun gnus-summary-rescan-group (&optional all)
7158 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7160 (let ((config gnus-current-window-configuration))
7161 (gnus-summary-reselect-current-group all t)
7162 (gnus-configure-windows config)
7163 (when (eq config 'article)
7164 (gnus-summary-select-article))))
7166 (defun gnus-summary-update-info (&optional non-destructive)
7168 (let ((group gnus-newsgroup-name))
7170 (when gnus-newsgroup-kill-headers
7171 (setq gnus-newsgroup-killed
7172 (gnus-compress-sequence
7174 (gnus-list-range-intersection
7175 gnus-newsgroup-unselected gnus-newsgroup-killed)
7176 gnus-newsgroup-unreads)
7178 (unless (listp (cdr gnus-newsgroup-killed))
7179 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7180 (let ((headers gnus-newsgroup-headers)
7181 (ephemeral-p (gnus-ephemeral-group-p group))
7184 (setq info (copy-sequence (gnus-get-info group))
7185 info (delq (gnus-info-params info) info)))
7186 ;; Set the new ranges of read articles.
7187 (with-current-buffer gnus-group-buffer
7188 (gnus-undo-force-boundary))
7189 (gnus-update-read-articles
7190 group (gnus-sorted-union
7191 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7192 ;; Set the current article marks.
7193 (let ((gnus-newsgroup-scored
7194 (if (and (not gnus-save-score)
7195 (not non-destructive))
7197 gnus-newsgroup-scored)))
7199 (gnus-update-marks)))
7200 ;; Do the cross-ref thing.
7201 (when gnus-use-cross-reference
7202 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7203 ;; Do not switch windows but change the buffer to work.
7204 (set-buffer gnus-group-buffer)
7206 (gnus-group-update-group
7209 (setq info (copy-sequence (gnus-get-info group))
7210 info (delq (gnus-info-params info) info))))))))))
7212 (defun gnus-summary-save-newsrc (&optional force)
7213 "Save the current number of read/marked articles in the dribble buffer.
7214 The dribble buffer will then be saved.
7215 If FORCE (the prefix), also save the .newsrc file(s)."
7217 (gnus-summary-update-info t)
7219 (gnus-save-newsrc-file)
7220 (gnus-dribble-save)))
7222 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7223 (declare-function gnus-article-stop-animations "gnus-art" ())
7225 (defun gnus-summary-exit (&optional temporary leave-hidden)
7226 "Exit reading current newsgroup, and then return to group selection mode.
7227 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7229 (gnus-set-global-variables)
7230 (when (gnus-buffer-live-p gnus-article-buffer)
7231 (with-current-buffer gnus-article-buffer
7232 (mm-destroy-parts gnus-article-mime-handles)
7233 ;; Set it to nil for safety reason.
7234 (setq gnus-article-mime-handle-alist nil)
7235 (setq gnus-article-mime-handles nil)))
7236 (gnus-kill-save-kill-buffer)
7237 (gnus-async-halt-prefetch)
7238 (let* ((group gnus-newsgroup-name)
7239 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7240 (gnus-group-is-exiting-p t)
7241 (article-buffer gnus-article-buffer)
7242 (original-article-buffer gnus-original-article-buffer)
7245 (buf (current-buffer))
7246 ;; `gnus-single-article-buffer' is nil buffer-locally in
7247 ;; ephemeral group of which summary buffer will be killed,
7248 ;; but the global value may be non-nil.
7249 (single-article-buffer gnus-single-article-buffer))
7251 ;; Do adaptive scoring, and possibly save score files.
7252 (when gnus-newsgroup-adaptive
7253 (gnus-score-adaptive))
7254 (when gnus-use-scoring
7256 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7257 (when gnus-use-cache
7258 (gnus-cache-possibly-remove-articles)
7259 (gnus-cache-save-buffers))
7260 (gnus-async-prefetch-remove-group group)
7261 (when gnus-suppress-duplicates
7262 (gnus-dup-enter-articles))
7263 (when gnus-use-trees
7265 (when gnus-use-cache
7266 (gnus-cache-write-active))
7267 ;; Remove entries for this group.
7268 (nnmail-purge-split-history (gnus-group-real-name group))
7269 ;; Make all changes in this group permanent.
7271 (gnus-run-hooks 'gnus-exit-group-hook)
7272 (gnus-summary-update-info))
7273 (gnus-close-group group)
7274 ;; Make sure where we were, and go to next newsgroup.
7275 (when (buffer-live-p (get-buffer gnus-group-buffer))
7276 (set-buffer gnus-group-buffer))
7278 (gnus-group-jump-to-group group))
7279 (gnus-run-hooks 'gnus-summary-exit-hook)
7280 (unless (or quit-config
7281 (not gnus-summary-next-group-on-exit)
7282 ;; If this group has disappeared from the summary
7283 ;; buffer, don't skip forwards.
7284 (not (string= group (gnus-group-group-name))))
7285 (gnus-group-next-unread-group 1))
7286 (setq group-point (point))
7287 (gnus-article-stop-animations)
7291 (if (not gnus-kill-summary-on-exit)
7293 (gnus-deaden-summary)
7295 (when (get-buffer gnus-article-buffer)
7296 (bury-buffer gnus-article-buffer))
7297 ;; Return to group mode buffer.
7298 (when (eq mode 'gnus-summary-mode)
7299 (gnus-kill-buffer buf)))
7301 (setq gnus-current-select-method gnus-select-method)
7302 (when (gnus-buffer-live-p gnus-group-buffer)
7303 (set-buffer gnus-group-buffer))
7305 (gnus-handle-ephemeral-exit quit-config)
7306 (goto-char group-point)
7307 ;; If gnus-group-buffer is already displayed, make sure we also move
7308 ;; the cursor in the window that displays it.
7309 (let ((win (get-buffer-window (current-buffer) 0)))
7310 (if win (set-window-point win (point))))
7311 (unless leave-hidden
7312 (gnus-configure-windows 'group 'force)))
7314 ;; If we have several article buffers, we kill them at exit.
7315 (unless single-article-buffer
7316 (when (gnus-buffer-live-p article-buffer)
7317 (with-current-buffer article-buffer
7318 ;; Don't kill sticky article buffers
7319 (unless (eq major-mode 'gnus-sticky-article-mode)
7320 (gnus-kill-buffer article-buffer)
7321 (setq gnus-article-current nil))))
7322 (gnus-kill-buffer original-article-buffer))
7324 ;; Clear the current group name.
7326 (setq gnus-newsgroup-name nil)))))
7328 (declare-function gnus-stop-downloads "gnus-art" ())
7330 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7331 (defun gnus-summary-exit-no-update (&optional no-questions)
7332 "Quit reading current newsgroup without updating read article info."
7334 (let* ((group gnus-newsgroup-name)
7335 (gnus-group-is-exiting-p t)
7336 (gnus-group-is-exiting-without-update-p t)
7337 (quit-config (gnus-group-quit-config group)))
7338 (when (or no-questions
7339 (gnus-ephemeral-group-p group)
7341 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7342 (gnus-async-halt-prefetch)
7343 (run-hooks 'gnus-summary-prepare-exit-hook)
7344 (when (gnus-buffer-live-p gnus-article-buffer)
7345 (with-current-buffer gnus-article-buffer
7346 (gnus-article-stop-animations)
7347 (gnus-stop-downloads)
7348 (mm-destroy-parts gnus-article-mime-handles)
7349 ;; Set it to nil for safety reason.
7350 (setq gnus-article-mime-handle-alist nil)
7351 (setq gnus-article-mime-handles nil)))
7352 ;; If we have several article buffers, we kill them at exit.
7353 (unless gnus-single-article-buffer
7354 (gnus-kill-buffer gnus-article-buffer)
7355 (gnus-kill-buffer gnus-original-article-buffer)
7356 (setq gnus-article-current nil))
7357 ;; Return to the group buffer.
7358 (if (not gnus-kill-summary-on-exit)
7360 (gnus-deaden-summary)
7361 (gnus-configure-windows 'group 'force))
7362 (gnus-configure-windows 'group 'force)
7363 (gnus-close-group group)
7364 (gnus-kill-buffer gnus-summary-buffer))
7365 (unless gnus-single-article-buffer
7366 (setq gnus-article-current nil))
7367 (when gnus-use-trees
7369 (gnus-async-prefetch-remove-group group)
7370 (when (get-buffer gnus-article-buffer)
7371 (bury-buffer gnus-article-buffer))
7372 ;; Clear the current group name.
7373 (setq gnus-newsgroup-name nil)
7374 (unless (gnus-ephemeral-group-p group)
7375 (gnus-group-update-group group nil t))
7376 (when (equal (gnus-group-group-name) group)
7377 (gnus-group-next-unread-group 1))
7378 (gnus-article-stop-animations)
7380 (gnus-handle-ephemeral-exit quit-config)))))
7382 (defun gnus-handle-ephemeral-exit (quit-config)
7383 "Handle movement when leaving an ephemeral group.
7384 The state which existed when entering the ephemeral is reset."
7385 (if (not (buffer-live-p (car quit-config)))
7386 (when (gnus-buffer-live-p gnus-group-buffer)
7387 (gnus-configure-windows 'group 'force))
7388 (set-buffer (car quit-config))
7389 (unless (eq (cdr quit-config) 'group)
7390 (setq gnus-current-select-method
7391 (gnus-find-method-for-group gnus-newsgroup-name)))
7392 (cond ((derived-mode-p 'gnus-summary-mode)
7393 (gnus-set-global-variables))
7394 ((derived-mode-p 'gnus-article-mode)
7395 (save-current-buffer
7396 ;; The `gnus-summary-buffer' variable may point
7397 ;; to the old summary buffer when using a single
7399 (unless (gnus-buffer-live-p gnus-summary-buffer)
7400 (set-buffer gnus-group-buffer))
7401 (set-buffer gnus-summary-buffer)
7402 (gnus-set-global-variables))))
7403 (if (or (eq (cdr quit-config) 'article)
7404 (eq (cdr quit-config) 'pick))
7405 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7406 (gnus-configure-windows 'pick 'force)
7407 (gnus-configure-windows (cdr quit-config) 'force))
7408 (gnus-configure-windows (cdr quit-config) 'force))
7409 (when (derived-mode-p 'gnus-summary-mode)
7410 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7411 next-unread-noselect))
7412 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7414 (gnus-summary-next-subject 1 nil t))
7415 ((eq gnus-auto-select-on-ephemeral-exit
7416 'next-unread-noselect)
7417 (gnus-summary-next-subject 1 t t))))
7418 ;; Hide the article buffer which displays the article different
7419 ;; from the one that the cursor points to in the summary buffer.
7420 (gnus-configure-windows 'summary 'force))
7421 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7422 (gnus-summary-next-subject 1))
7423 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7424 (gnus-summary-next-subject 1 t))))
7425 (gnus-summary-recenter)
7426 (gnus-summary-position-point))))
7430 (defvar gnus-dead-summary-mode-map
7431 (let ((map (make-keymap)))
7432 (suppress-keymap map)
7433 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7434 (dolist (key '("\C-d" "\r" "\177" [delete]))
7435 (define-key map key 'gnus-summary-wake-up-the-dead))
7436 (dolist (key '("q" "Q"))
7437 (define-key map key 'bury-buffer))
7440 (define-minor-mode gnus-dead-summary-mode
7441 "Minor mode for Gnus summary buffers."
7442 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7443 (unless (derived-mode-p 'gnus-summary-mode)
7444 (setq gnus-dead-summary-mode nil)))
7446 (defun gnus-deaden-summary ()
7447 "Make the current summary buffer into a dead summary buffer."
7448 ;; Kill any previous dead summary buffer.
7449 (when (and gnus-dead-summary
7450 (buffer-name gnus-dead-summary))
7451 (with-current-buffer gnus-dead-summary
7452 (when gnus-dead-summary-mode
7453 (kill-buffer (current-buffer)))))
7454 ;; Make this the current dead summary.
7455 (setq gnus-dead-summary (current-buffer))
7456 (gnus-dead-summary-mode 1)
7457 (let ((name (buffer-name)))
7458 (when (string-match "Summary" name)
7460 (concat (substring name 0 (match-beginning 0)) "Dead "
7461 (substring name (match-beginning 0)))
7465 (defun gnus-kill-or-deaden-summary (buffer)
7466 "Kill or deaden the summary BUFFER."
7468 (when (and (buffer-name buffer)
7469 (not gnus-single-article-buffer))
7470 (with-current-buffer buffer
7471 (gnus-kill-buffer gnus-article-buffer)
7472 (gnus-kill-buffer gnus-original-article-buffer)))
7475 (gnus-kill-summary-on-exit
7476 (when (and gnus-use-trees
7477 (gnus-buffer-exists-p buffer))
7478 (with-current-buffer buffer
7480 (gnus-kill-buffer buffer))
7481 ;; Deaden the buffer.
7482 ((gnus-buffer-exists-p buffer)
7483 (with-current-buffer buffer
7484 (gnus-deaden-summary))))))
7486 (defun gnus-summary-wake-up-the-dead (&rest args)
7487 "Wake up the dead summary buffer."
7489 (gnus-dead-summary-mode -1)
7490 (let ((name (buffer-name)))
7491 (when (string-match "Dead " name)
7493 (concat (substring name 0 (match-beginning 0))
7494 (substring name (match-end 0)))
7496 (gnus-message 3 "This dead summary is now alive again"))
7498 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7499 (defun gnus-summary-describe-group (&optional force)
7500 "Describe the current newsgroup."
7502 (gnus-group-describe-group force gnus-newsgroup-name))
7504 (defun gnus-summary-describe-briefly ()
7505 "Describe summary mode commands briefly."
7507 (gnus-message 6 "%s" (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")))
7509 ;; Walking around group mode buffer from summary mode.
7511 (defun gnus-summary-next-group (&optional no-article target-group backward)
7512 "Exit current newsgroup and then select next unread newsgroup.
7513 If prefix argument NO-ARTICLE is non-nil, no article is selected
7514 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7515 previous group instead."
7517 ;; Stop pre-fetching.
7518 (gnus-async-halt-prefetch)
7519 (let ((current-group gnus-newsgroup-name)
7520 (current-buffer (current-buffer))
7522 ;; First we semi-exit this group to update Xrefs and all variables.
7523 ;; We can't do a real exit, because the window conf must remain
7524 ;; the same in case the user is prompted for info, and we don't
7525 ;; want the window conf to change before that...
7526 (gnus-summary-exit t)
7527 (while (not entered)
7528 ;; Then we find what group we are supposed to enter.
7529 (set-buffer gnus-group-buffer)
7530 (gnus-group-jump-to-group current-group)
7533 (if (eq gnus-keep-same-level 'best)
7534 (gnus-summary-best-group gnus-newsgroup-name)
7535 (gnus-summary-search-group backward gnus-keep-same-level))))
7536 (if (not target-group)
7537 ;; There are no further groups, so we return to the group
7540 (gnus-message 5 "Returning to the group buffer")
7542 (when (gnus-buffer-live-p current-buffer)
7543 (set-buffer current-buffer)
7544 (gnus-summary-exit))
7545 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7546 ;; We try to enter the target group.
7547 (gnus-group-jump-to-group target-group)
7548 (let ((unreads (gnus-group-group-unread)))
7549 (if (and (or (eq t unreads)
7550 (and unreads (not (zerop unreads))))
7551 (gnus-summary-read-group
7552 target-group nil no-article
7553 (and (buffer-name current-buffer) current-buffer)
7556 (setq current-group target-group
7557 target-group nil)))))))
7559 (defun gnus-summary-prev-group (&optional no-article)
7560 "Exit current newsgroup and then select previous unread newsgroup.
7561 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7563 (gnus-summary-next-group no-article nil t))
7565 ;; Walking around summary lines.
7567 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7568 "Go to the first subject satisfying any non-nil constraint.
7569 If UNREAD is non-nil, the article should be unread.
7570 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7571 If UNSEEN is non-nil, the article should be unseen as well as unread.
7572 Returns the article selected or nil if there are no matching articles."
7576 ((null gnus-newsgroup-data)
7577 (gnus-message 3 "No articles in the group")
7579 ;; Pick the first article.
7580 ((not (or unread undownloaded unseen))
7581 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7582 (gnus-data-number (car gnus-newsgroup-data)))
7583 ;; Find the first unread article.
7585 (let ((data gnus-newsgroup-data))
7587 (let ((num (gnus-data-number (car data))))
7588 (or (memq num gnus-newsgroup-unfetched)
7589 (not (or (and unread
7590 (memq num gnus-newsgroup-unreads))
7592 (memq num gnus-newsgroup-undownloaded))
7594 (memq num gnus-newsgroup-unseen)
7595 (memq num gnus-newsgroup-unreads)))))))
7596 (setq data (cdr data)))
7600 (goto-char (gnus-data-pos (car data)))
7601 (gnus-data-number (car data)))
7602 (gnus-message 3 "No more%s articles"
7603 (let* ((r (when unread " unread"))
7604 (d (when undownloaded " undownloaded"))
7605 (s (when unseen " unseen"))
7606 (l (delq nil (list r d s))))
7607 (cond ((= 3 (length l))
7608 (concat r "," d ", or" s))
7610 (concat (car l) ", or" (cadr l)))
7617 (gnus-summary-position-point))))))
7619 (defun gnus-summary-next-subject (n &optional unread dont-display)
7620 "Go to next N'th summary line.
7621 If N is negative, go to the previous N'th subject line.
7622 If UNREAD is non-nil, only unread articles are selected.
7623 The difference between N and the actual number of steps taken is
7626 (let ((backward (< n 0))
7630 (gnus-summary-find-prev unread)
7631 (gnus-summary-find-next unread)))
7632 (unless (zerop (setq n (1- n)))
7633 (gnus-summary-show-thread)))
7635 (gnus-message 7 "No more%s articles"
7636 (if unread " unread" "")))
7637 (unless dont-display
7638 (gnus-summary-recenter)
7639 (gnus-summary-position-point))
7642 (defun gnus-summary-next-unread-subject (n)
7643 "Go to next N'th unread summary line."
7645 (gnus-summary-next-subject n t))
7647 (defun gnus-summary-prev-subject (n &optional unread)
7648 "Go to previous N'th summary line.
7649 If optional argument UNREAD is non-nil, only unread article is selected."
7651 (gnus-summary-next-subject (- n) unread))
7653 (defun gnus-summary-prev-unread-subject (n)
7654 "Go to previous N'th unread summary line."
7656 (gnus-summary-next-subject (- n) t))
7658 (defun gnus-summary-goto-subjects (articles)
7659 "Insert the subject header for ARTICLES in the current buffer."
7661 (dolist (article articles)
7662 (gnus-summary-goto-subject article t)))
7663 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7664 (gnus-summary-position-point))
7666 (defun gnus-summary-goto-subject (article &optional force silent)
7667 "Go to the subject line of ARTICLE.
7668 If FORCE, also allow jumping to articles not currently shown."
7669 (interactive "nArticle number: ")
7670 (unless (numberp article)
7671 (error "Article %s is not a number" article))
7673 (data (gnus-data-find article)))
7674 ;; We read in the article if we have to.
7677 (gnus-summary-insert-subject
7679 (if (or (numberp force) (vectorp force)) force)
7681 (setq data (gnus-data-find article)))
7686 (gnus-message 3 "Can't find article %d" article))
7688 (let ((pt (gnus-data-pos data)))
7690 (gnus-summary-set-article-display-arrow pt))
7691 (gnus-summary-position-point)
7694 ;; Walking around summary lines with displaying articles.
7696 (defun gnus-summary-expand-window (&optional arg)
7697 "Make the summary buffer take up the entire Emacs frame.
7698 Given a prefix, will force an `article' buffer configuration."
7701 (gnus-configure-windows 'article 'force)
7702 (gnus-configure-windows 'summary 'force)))
7704 (defun gnus-summary-display-article (article &optional all-header)
7705 "Display ARTICLE in article buffer."
7706 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7707 (with-current-buffer gnus-article-buffer
7708 (derived-mode-p 'gnus-article-mode)))
7709 (gnus-article-setup-buffer))
7710 (gnus-set-global-variables)
7711 (with-current-buffer gnus-article-buffer
7712 (setq gnus-article-charset gnus-newsgroup-charset)
7713 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7714 (mm-enable-multibyte))
7718 (if gnus-summary-display-article-function
7719 (funcall gnus-summary-display-article-function article all-header)
7720 (gnus-article-prepare article all-header))
7721 (gnus-run-hooks 'gnus-select-article-hook)
7722 (when (and gnus-current-article
7723 (not (zerop gnus-current-article)))
7724 (gnus-summary-goto-subject gnus-current-article))
7725 (gnus-summary-recenter)
7726 (when (and gnus-use-trees gnus-show-threads)
7727 (gnus-possibly-generate-tree article)
7728 (gnus-highlight-selected-tree article))
7729 ;; Successfully display article.
7730 (gnus-article-set-window-start
7731 (cdr (assq article gnus-newsgroup-bookmarks))))))
7733 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7734 "Select the current article.
7735 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7736 non-nil, the article will be re-fetched even if it already present in
7737 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7739 ;; Make sure we are in the summary buffer to work around bbdb bug.
7740 (unless (derived-mode-p 'gnus-summary-mode)
7741 (set-buffer gnus-summary-buffer))
7742 (let ((article (or article (gnus-summary-article-number)))
7743 (all-headers (not (not all-headers))) ;Must be t or nil.
7744 gnus-summary-display-article-function)
7746 (gnus-summary-article-pseudo-p article)
7747 (error "This is a pseudo-article"))
7748 (with-current-buffer gnus-summary-buffer
7749 (if (or (and gnus-single-article-buffer
7750 (or (null gnus-current-article)
7751 (null gnus-article-current)
7752 (null (get-buffer gnus-article-buffer))
7753 (not (eq article (cdr gnus-article-current)))
7754 (not (equal (car gnus-article-current)
7755 gnus-newsgroup-name))
7756 (not (get-buffer gnus-original-article-buffer))))
7757 (and (not gnus-single-article-buffer)
7758 (or (null gnus-current-article)
7759 (not (get-buffer gnus-original-article-buffer))
7760 (not (eq gnus-current-article article))))
7762 ;; The requested article is different from the current article.
7764 (gnus-summary-display-article article all-headers)
7765 (when (gnus-buffer-live-p gnus-article-buffer)
7766 (with-current-buffer gnus-article-buffer
7767 (if (not gnus-article-decoded-p) ;; a local variable
7768 (mm-disable-multibyte))))
7769 (gnus-article-set-window-start
7770 (cdr (assq article gnus-newsgroup-bookmarks)))
7774 (defun gnus-summary-force-verify-and-decrypt ()
7775 "Display buttons for signed/encrypted parts and verify/decrypt them."
7777 (let ((mm-verify-option 'known)
7778 (mm-decrypt-option 'known)
7779 (gnus-article-emulate-mime t)
7780 (gnus-buttonized-mime-types (append (list "multipart/signed"
7781 "multipart/encrypted")
7782 gnus-buttonized-mime-types)))
7783 (gnus-summary-select-article nil 'force)))
7785 (defun gnus-summary-next-article (&optional unread subject backward push)
7786 "Select the next article.
7787 If UNREAD, only unread articles are selected.
7788 If SUBJECT, only articles with SUBJECT are selected.
7789 If BACKWARD, the previous article is selected instead of the next."
7791 ;; Make sure we are in the summary buffer.
7792 (unless (derived-mode-p 'gnus-summary-mode)
7793 (set-buffer gnus-summary-buffer))
7795 ;; Is there such an article?
7796 ((and (gnus-summary-search-forward unread subject backward)
7797 (or (gnus-summary-display-article (gnus-summary-article-number))
7798 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7799 (gnus-summary-position-point))
7800 ;; If not, we try the first unread, if that is wanted.
7802 gnus-auto-select-same
7803 (gnus-summary-first-unread-article))
7804 (gnus-summary-position-point)
7805 (gnus-message 6 "Wrapped"))
7806 ;; Try to get next/previous article not displayed in this group.
7807 ((and gnus-auto-extend-newsgroup
7808 (not unread) (not subject))
7809 (gnus-summary-goto-article
7810 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7811 nil (count-lines (point-min) (point))))
7812 ;; Go to next/previous group.
7814 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7815 (gnus-summary-jump-to-group gnus-newsgroup-name))
7816 (let ((cmd (if (featurep 'xemacs)
7818 last-command-event))
7820 (with-current-buffer gnus-group-buffer
7822 (current-summary (current-buffer))
7824 (if (eq gnus-keep-same-level 'best)
7825 (gnus-summary-best-group gnus-newsgroup-name)
7826 (gnus-summary-search-group backward gnus-keep-same-level))))
7827 ;; Select next unread newsgroup automagically.
7829 ((or (not gnus-auto-select-next)
7831 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7832 ((or (eq gnus-auto-select-next 'quietly)
7833 (and (eq gnus-auto-select-next 'slightly-quietly)
7835 (and (eq gnus-auto-select-next 'almost-quietly)
7836 (gnus-summary-last-article-p)))
7838 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7840 (gnus-message 7 "No more%s articles (%s)..."
7841 (if unread " unread" "")
7842 (if group (concat "selecting " group)
7844 (gnus-summary-next-group nil group backward)))
7846 (when (gnus-key-press-event-p last-input-event)
7847 ;; Somehow or other, we may now have selected a different
7848 ;; window. Make point go back to the summary buffer.
7849 (when (eq current-summary (current-buffer))
7850 ;; FIXME: This burps when get-buffer-window returns nil.
7851 (select-window (get-buffer-window current-summary 0)))
7852 (gnus-summary-walk-group-buffer
7853 gnus-newsgroup-name cmd unread backward point))))))))
7855 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7856 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7857 (?\C-p (gnus-group-prev-unread-group 1))))
7858 (cursor-in-echo-area t)
7859 keve key group ended prompt)
7860 (with-current-buffer gnus-group-buffer
7863 (if (eq gnus-keep-same-level 'best)
7864 (gnus-summary-best-group gnus-newsgroup-name)
7865 (gnus-summary-search-group backward gnus-keep-same-level))))
7869 "No more%s articles%s " (if unread " unread" "")
7871 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7872 (format " (Type %s for %s [%s])"
7873 (single-key-description cmd)
7874 (gnus-group-decoded-name group)
7875 (gnus-group-unread group))
7876 (format " (Type %s to exit %s)"
7877 (single-key-description cmd)
7878 (gnus-group-decoded-name gnus-newsgroup-name)))))
7879 ;; Confirm auto selection.
7880 (setq key (car (setq keve (gnus-read-event-char prompt)))
7883 ((assq key keystrokes)
7884 (let ((obuf (current-buffer)))
7885 (switch-to-buffer gnus-group-buffer)
7887 (gnus-group-jump-to-group group))
7888 (eval (cadr (assq key keystrokes)))
7889 (setq group (gnus-group-group-name))
7890 (switch-to-buffer obuf))
7894 (gnus-ephemeral-group-p gnus-newsgroup-name))
7896 (gnus-summary-next-group nil group backward)))
7898 (push (cdr keve) unread-command-events))))))
7900 (defun gnus-summary-next-unread-article ()
7901 "Select unread article after current one."
7903 (gnus-summary-next-article
7904 (or (not (eq gnus-summary-goto-unread 'never))
7905 (gnus-summary-last-article-p (gnus-summary-article-number)))
7906 (and gnus-auto-select-same
7907 (gnus-summary-article-subject))))
7909 (defun gnus-summary-prev-article (&optional unread subject)
7910 "Select the article before the current one.
7911 If UNREAD is non-nil, only unread articles are selected."
7913 (gnus-summary-next-article unread subject t))
7915 (defun gnus-summary-prev-unread-article ()
7916 "Select unread article before current one."
7918 (gnus-summary-prev-article
7919 (or (not (eq gnus-summary-goto-unread 'never))
7920 (gnus-summary-first-article-p (gnus-summary-article-number)))
7921 (and gnus-auto-select-same
7922 (gnus-summary-article-subject))))
7924 (declare-function gnus-article-only-boring-p "gnus-art" ())
7926 (defun gnus-summary-next-page (&optional lines circular stop)
7927 "Show next page of the selected article.
7928 If at the end of the current article, select the next article.
7929 LINES says how many lines should be scrolled up.
7931 If CIRCULAR is non-nil, go to the start of the article instead of
7932 selecting the next article when reaching the end of the current
7935 If STOP is non-nil, just stop when reaching the end of the message.
7937 Also see the variable `gnus-article-skip-boring'."
7939 (gnus-set-global-variables)
7940 (let ((article (gnus-summary-article-number))
7941 (article-window (get-buffer-window gnus-article-buffer t))
7943 ;; If the buffer is empty, we have no article.
7945 (error "No article to select"))
7946 (gnus-configure-windows 'article)
7947 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7948 (if (and (eq gnus-summary-goto-unread 'never)
7949 (not (gnus-summary-last-article-p article)))
7950 (gnus-summary-next-article)
7951 (gnus-summary-next-unread-article))
7952 (if (or (null gnus-current-article)
7953 (null gnus-article-current)
7954 (/= article (cdr gnus-article-current))
7955 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7956 ;; Selected subject is different from current article's.
7957 (gnus-summary-display-article article)
7958 (when article-window
7959 (gnus-eval-in-buffer-window gnus-article-buffer
7960 (setq endp (or (gnus-article-next-page lines)
7961 (gnus-article-only-boring-p))))
7963 (cond ((or stop gnus-summary-stop-at-end-of-message)
7964 (gnus-message 3 "End of message"))
7966 (gnus-summary-beginning-of-article))
7968 (gnus-message 3 "End of message"))
7970 (if (and (eq gnus-summary-goto-unread 'never)
7971 (not (gnus-summary-last-article-p article)))
7972 (gnus-summary-next-article)
7973 (gnus-summary-next-unread-article))))))))
7974 (gnus-summary-recenter)
7975 (gnus-summary-position-point)))
7977 (defun gnus-summary-prev-page (&optional lines move)
7978 "Show previous page of selected article.
7979 Argument LINES specifies lines to be scrolled down.
7980 If MOVE, move to the previous unread article if point is at
7981 the beginning of the buffer."
7983 (let ((article (gnus-summary-article-number))
7984 (article-window (get-buffer-window gnus-article-buffer t))
7986 (gnus-configure-windows 'article)
7987 (if (or (null gnus-current-article)
7988 (null gnus-article-current)
7989 (/= article (cdr gnus-article-current))
7990 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7991 ;; Selected subject is different from current article's.
7992 (gnus-summary-display-article article)
7993 (gnus-summary-recenter)
7994 (when article-window
7995 (gnus-eval-in-buffer-window gnus-article-buffer
7996 (setq endp (gnus-article-prev-page lines)))
7997 (when (and move endp)
7999 (gnus-message 3 "Beginning of message"))
8001 (if (and (eq gnus-summary-goto-unread 'never)
8002 (not (gnus-summary-first-article-p article)))
8003 (gnus-summary-prev-article)
8004 (gnus-summary-prev-unread-article))))))))
8005 (gnus-summary-position-point))
8007 (defun gnus-summary-prev-page-or-article (&optional lines)
8008 "Show previous page of selected article.
8009 Argument LINES specifies lines to be scrolled down.
8010 If at the beginning of the article, go to the next article."
8012 (gnus-summary-prev-page lines t))
8014 (defun gnus-summary-scroll-up (lines)
8015 "Scroll up (or down) one line current article.
8016 Argument LINES specifies lines to be scrolled up (or down if negative).
8017 If no article is selected, then the current article will be selected first."
8019 (gnus-configure-windows 'article)
8020 (gnus-summary-show-thread)
8021 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8022 (gnus-eval-in-buffer-window gnus-article-buffer
8024 (when (gnus-article-next-page lines)
8025 (gnus-message 3 "End of message")))
8027 (gnus-article-prev-page (- lines))))))
8028 (gnus-summary-recenter)
8029 (gnus-summary-position-point))
8031 (defun gnus-summary-scroll-down (lines)
8032 "Scroll down (or up) one line current article.
8033 Argument LINES specifies lines to be scrolled down (or up if negative).
8034 If no article is selected, then the current article will be selected first."
8036 (gnus-summary-scroll-up (- lines)))
8038 (defun gnus-summary-next-same-subject ()
8039 "Select next article which has the same subject as current one."
8041 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8043 (defun gnus-summary-prev-same-subject ()
8044 "Select previous article which has the same subject as current one."
8046 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8048 (defun gnus-summary-next-unread-same-subject ()
8049 "Select next unread article which has the same subject as current one."
8051 (gnus-summary-next-article t (gnus-summary-article-subject)))
8053 (defun gnus-summary-prev-unread-same-subject ()
8054 "Select previous unread article which has the same subject as current one."
8056 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8058 (defun gnus-summary-first-unread-article ()
8059 "Select the first unread article.
8060 Return nil if there are no unread articles."
8063 (when (gnus-summary-first-subject t)
8064 (gnus-summary-show-thread)
8065 (gnus-summary-first-subject t)
8066 (gnus-summary-display-article (gnus-summary-article-number)))
8067 (gnus-summary-position-point)))
8069 (defun gnus-summary-first-unread-subject ()
8070 "Place the point on the subject line of the first unread article.
8071 Return nil if there are no unread articles."
8074 (when (gnus-summary-first-subject t)
8075 (gnus-summary-show-thread)
8076 (gnus-summary-first-subject t))
8077 (gnus-summary-position-point)))
8079 (defun gnus-summary-first-unseen-subject ()
8080 "Place the point on the subject line of the first unseen article.
8081 Return nil if there are no unseen articles."
8084 (when (gnus-summary-first-subject nil nil t)
8085 (gnus-summary-show-thread)
8086 (gnus-summary-first-subject nil nil t))
8087 (gnus-summary-position-point)))
8089 (defun gnus-summary-first-unseen-or-unread-subject ()
8090 "Place the point on the subject line of the first unseen and unread article.
8091 If all article have been seen, on the subject line of the first unread
8095 (unless (when (gnus-summary-first-subject nil nil t)
8096 (gnus-summary-show-thread)
8097 (gnus-summary-first-subject nil nil t))
8098 (when (gnus-summary-first-subject t)
8099 (gnus-summary-show-thread)
8100 (gnus-summary-first-subject t)))
8101 (gnus-summary-position-point)))
8103 (defun gnus-summary-first-article ()
8104 "Select the first article.
8105 Return nil if there are no articles."
8108 (when (gnus-summary-first-subject)
8109 (gnus-summary-show-thread)
8110 (gnus-summary-first-subject)
8111 (gnus-summary-display-article (gnus-summary-article-number)))
8112 (gnus-summary-position-point)))
8114 (defun gnus-summary-best-unread-article (&optional arg)
8115 "Select the unread article with the highest score.
8116 If given a prefix argument, select the next unread article that has a
8117 score higher than the default score."
8119 (let ((article (if arg
8120 (gnus-summary-better-unread-subject)
8121 (gnus-summary-best-unread-subject))))
8123 (gnus-summary-goto-article article)
8124 (error "No unread articles"))))
8126 (defun gnus-summary-best-unread-subject ()
8127 "Select the unread subject with the highest score."
8129 (let ((best -1000000)
8130 (data gnus-newsgroup-data)
8133 (and (gnus-data-unread-p (car data))
8135 (gnus-summary-article-score (gnus-data-number (car data))))
8138 article (gnus-data-number (car data))))
8139 (setq data (cdr data)))
8141 (gnus-summary-goto-subject article))
8142 (gnus-summary-position-point)
8145 (defun gnus-summary-better-unread-subject ()
8146 "Select the first unread subject that has a score over the default score."
8148 (let ((data gnus-newsgroup-data)
8150 (while (and (setq article (gnus-data-number (car data)))
8151 (or (gnus-data-read-p (car data))
8152 (not (> (gnus-summary-article-score article)
8153 gnus-summary-default-score))))
8154 (setq data (cdr data)))
8156 (gnus-summary-goto-subject article))
8157 (gnus-summary-position-point)
8160 (defun gnus-summary-last-subject ()
8161 "Go to the last displayed subject line in the group."
8162 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8164 (gnus-summary-goto-subject article))))
8166 (defun gnus-summary-goto-article (article &optional all-headers force)
8167 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8168 If ALL-HEADERS is non-nil, no header lines are hidden.
8169 If FORCE, go to the article even if it isn't displayed. If FORCE
8170 is a number, it is the line the article is to be displayed on."
8173 (gnus-completing-read
8174 "Article number or Message-ID"
8175 (mapcar 'int-to-string gnus-newsgroup-limit))
8179 (if (and (stringp article)
8180 (string-match "@\\|%40" article))
8181 (gnus-summary-refer-article article)
8182 (when (stringp article)
8183 (setq article (string-to-number article)))
8184 (if (gnus-summary-goto-subject article force)
8185 (gnus-summary-display-article article all-headers)
8186 (gnus-message 4 "Couldn't go to article %s" article) nil))
8187 (gnus-summary-position-point)))
8189 (defun gnus-summary-goto-last-article ()
8190 "Go to the previously read article."
8193 (when gnus-last-article
8194 (gnus-summary-goto-article gnus-last-article nil t))
8195 (gnus-summary-position-point)))
8197 (defun gnus-summary-pop-article (number)
8198 "Pop one article off the history and go to the previous.
8199 NUMBER articles will be popped off."
8202 (setq gnus-newsgroup-history
8203 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8205 (gnus-summary-goto-article (car to) nil t)
8206 (error "Article history empty")))
8207 (gnus-summary-position-point))
8209 ;; Summary commands and functions for limiting the summary buffer.
8211 (defun gnus-summary-limit-to-articles (n)
8212 "Limit the summary buffer to the next N articles.
8213 If not given a prefix, use the process marked articles instead."
8216 (let ((articles (gnus-summary-work-articles n)))
8217 (setq gnus-newsgroup-processable nil)
8218 (gnus-summary-limit articles))
8219 (gnus-summary-position-point)))
8221 (defun gnus-summary-pop-limit (&optional total)
8222 "Restore the previous limit.
8223 If given a prefix, remove all limits."
8226 (setq gnus-newsgroup-limits
8227 (list (mapcar (lambda (h) (mail-header-number h))
8228 gnus-newsgroup-headers))))
8229 (unless gnus-newsgroup-limits
8230 (error "No limit to pop"))
8232 (gnus-summary-limit nil 'pop)
8233 (gnus-summary-position-point)))
8235 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8236 "Limit the summary buffer to articles that have subjects that match a regexp.
8237 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8239 (list (read-string (if current-prefix-arg
8240 "Exclude subject (regexp): "
8241 "Limit to subject (regexp): "))
8242 nil current-prefix-arg))
8244 (setq header "subject"))
8245 (when (not (equal "" subject))
8247 (let ((articles (gnus-summary-find-matching
8248 (or header "subject") subject 'all nil nil
8251 (error "Found no matches for \"%s\"" subject))
8252 (gnus-summary-limit articles))
8253 (gnus-summary-position-point))))
8255 (defun gnus-summary-limit-to-author (from &optional not-matching)
8256 "Limit the summary buffer to articles that have authors that match a regexp.
8257 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8259 (list (let* ((header (gnus-summary-article-header))
8260 (default (and header (car (mail-header-parse-address
8261 (mail-header-from header))))))
8262 (read-string (concat (if current-prefix-arg
8263 "Exclude author (regexp"
8264 "Limit to author (regexp")
8266 (concat ", default \"" default "\"): ")
8270 current-prefix-arg))
8271 (gnus-summary-limit-to-subject from "from" not-matching))
8273 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8274 "Limit the summary buffer to articles with the given RECIPIENT.
8276 If NOT-MATCHING, exclude RECIPIENT.
8278 To and Cc headers are checked. You need to include them in
8279 `nnmail-extra-headers'."
8280 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8282 (list (read-string (format "%s recipient (regexp): "
8283 (if current-prefix-arg "Exclude" "Limit to")))
8284 current-prefix-arg))
8285 (when (not (equal "" recipient))
8287 (if (memq 'To nnmail-extra-headers)
8288 (gnus-summary-find-matching
8289 (cons 'extra 'To) recipient 'all nil nil
8292 1 "`To' isn't present in `nnmail-extra-headers'")
8296 (if (memq 'Cc nnmail-extra-headers)
8297 (gnus-summary-find-matching
8298 (cons 'extra 'Cc) recipient 'all nil nil
8301 1 "`Cc' isn't present in `nnmail-extra-headers'")
8306 ;; We need the numbers that are in both lists:
8308 (and (memq a to) a))
8312 (error "Found no matches for \"%s\"" recipient))
8313 (gnus-summary-limit articles))
8314 (gnus-summary-position-point))))
8316 (defun gnus-summary-limit-to-address (address &optional not-matching)
8317 "Limit the summary buffer to articles with the given ADDRESS.
8319 If NOT-MATCHING, exclude ADDRESS.
8321 To, Cc and From headers are checked. You need to include `To' and `Cc'
8322 in `nnmail-extra-headers'."
8324 (list (read-string (format "%s address (regexp): "
8325 (if current-prefix-arg "Exclude" "Limit to")))
8326 current-prefix-arg))
8327 (when (not (equal "" address))
8329 (if (memq 'To nnmail-extra-headers)
8330 (gnus-summary-find-matching
8331 (cons 'extra 'To) address 'all nil nil
8334 1 "`To' isn't present in `nnmail-extra-headers'")
8338 (if (memq 'Cc nnmail-extra-headers)
8339 (gnus-summary-find-matching
8340 (cons 'extra 'Cc) address 'all nil nil
8343 1 "`Cc' isn't present in `nnmail-extra-headers'")
8347 (gnus-summary-find-matching "from" address
8348 'all nil nil not-matching))
8351 ;; We need the numbers that are in all lists:
8355 (mapcar (lambda (a) (car (memq a from))) to))
8357 (mapcar (lambda (a) (car (memq a from))) cc)
8358 (mapcar (lambda (a) (car (memq a from)))
8359 (mapcar (lambda (a) (car (memq a to)))
8361 (nconc (if (eq to t) nil to)
8362 (if (eq cc t) nil cc)
8365 (error "Found no matches for \"%s\"" address))
8366 (gnus-summary-limit articles))
8367 (gnus-summary-position-point))))
8369 (defun gnus-summary-limit-strange-charsets-predicate (header)
8370 (when (fboundp 'char-charset)
8371 (let ((string (concat (mail-header-subject header)
8372 (mail-header-from header)))
8374 (dotimes (i (1- (length string)))
8375 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8376 (when (string-match "unicode\\|big\\|japanese" charset)
8380 (defun gnus-summary-limit-to-predicate (predicate)
8381 "Limit to articles where PREDICATE returns non-nil.
8382 PREDICATE will be called with the header structures of the
8384 (let ((articles nil)
8385 (case-fold-search t))
8386 (dolist (header gnus-newsgroup-headers)
8387 (when (funcall predicate header)
8388 (push (mail-header-number header) articles)))
8389 (gnus-summary-limit (nreverse articles))))
8391 (defun gnus-summary-limit-to-age (age &optional younger-p)
8392 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8393 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8394 articles that are younger than AGE days."
8396 (let ((younger current-prefix-arg)
8399 (while (not days-got)
8400 (setq days (if younger
8401 (read-string "Limit to articles younger than (in days, older when negative): ")
8403 "Limit to articles older than (in days, younger when negative): ")))
8404 (when (> (length days) 0)
8405 (setq days (read days)))
8410 (setq younger (not younger))
8411 (setq days (* days -1))))
8412 (message "Please enter a number.")
8414 (list days younger)))
8416 (let ((data gnus-newsgroup-data)
8417 (cutoff (days-to-time age))
8418 articles d date is-younger)
8419 (while (setq d (pop data))
8420 (when (and (vectorp (gnus-data-header d))
8421 (setq date (mail-header-date (gnus-data-header d))))
8422 (setq is-younger (time-less-p
8423 (time-since (gnus-date-get-time date))
8428 (push (gnus-data-number d) articles))))
8429 (gnus-summary-limit (nreverse articles)))
8430 (gnus-summary-position-point)))
8432 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8433 "Limit the summary buffer to articles that match an `extra' header."
8437 (gnus-completing-read
8438 (if current-prefix-arg
8439 "Exclude extra header"
8440 "Limit extra header")
8441 (mapcar 'symbol-name gnus-extra-headers)
8443 (symbol-name (car gnus-extra-headers))))))
8445 (read-string (format "%s header %s (regexp): "
8446 (if current-prefix-arg "Exclude" "Limit to")
8448 current-prefix-arg)))
8449 (when (not (equal "" regexp))
8451 (let ((articles (gnus-summary-find-matching
8452 (cons 'extra header) regexp 'all nil nil
8455 (error "Found no matches for \"%s\"" regexp))
8456 (gnus-summary-limit articles))
8457 (gnus-summary-position-point))))
8459 (defun gnus-summary-limit-to-display-predicate ()
8460 "Limit the summary buffer to the predicated in the `display' group parameter."
8462 (unless gnus-newsgroup-display
8463 (error "There is no `display' group parameter"))
8465 (dolist (gnus-number gnus-newsgroup-articles)
8466 (when (funcall gnus-newsgroup-display)
8467 (push gnus-number articles)))
8468 (gnus-summary-limit articles))
8469 (gnus-summary-position-point))
8471 (defun gnus-summary-limit-to-unread (&optional all)
8472 "Limit the summary buffer to articles that are not marked as read.
8473 If ALL is non-nil, limit strictly to unread articles."
8476 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8477 (gnus-summary-limit-to-marks
8478 ;; Concat all the marks that say that an article is read and have
8480 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8481 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8482 gnus-low-score-mark gnus-expirable-mark
8483 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8484 gnus-duplicate-mark)
8487 (defun gnus-summary-limit-to-headers (match &optional reverse)
8488 "Limit the summary buffer to articles that have headers that match MATCH.
8489 If REVERSE (the prefix), limit to articles that don't match."
8490 (interactive "sMatch headers (regexp): \nP")
8491 (gnus-summary-limit-to-bodies match reverse t))
8493 (declare-function article-goto-body "gnus-art" ())
8495 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8496 "Limit the summary buffer to articles that have bodies that match MATCH.
8497 If REVERSE (the prefix), limit to articles that don't match."
8498 (interactive "sMatch body (regexp): \nP")
8499 (let ((articles nil)
8500 (gnus-select-article-hook nil) ;Disable hook.
8501 (gnus-article-prepare-hook nil)
8502 (gnus-use-article-prefetch nil)
8503 (gnus-keep-backlog nil)
8504 (gnus-break-pages nil)
8505 (gnus-summary-display-arrow nil)
8506 (gnus-updated-mode-lines nil)
8507 (gnus-auto-center-summary nil)
8508 (gnus-display-mime-function nil))
8509 (dolist (data gnus-newsgroup-data)
8510 (let (gnus-mark-article-hook)
8511 (gnus-summary-select-article t t nil (gnus-data-number data)))
8512 (with-current-buffer gnus-article-buffer
8514 (let* ((case-fold-search t)
8516 (re-search-backward match nil t)
8517 (re-search-forward match nil t))))
8518 (when (or (and found
8522 (push (gnus-data-number data) articles)))))
8524 (message "No messages matched")
8525 (gnus-summary-limit articles)))
8526 (gnus-summary-position-point))
8528 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8529 "Limit the summary buffer to articles that aren't part on any thread.
8530 If THREADSP (the prefix), limit to articles that are in threads."
8532 (let ((articles nil)
8535 (dolist (thread gnus-newsgroup-threads)
8536 (if (stringp (car thread))
8537 (dolist (thread (cdr thread))
8538 (push thread threads))
8539 (push thread threads)))
8540 (dolist (thread threads)
8541 (setq thread-articles (gnus-articles-in-thread thread))
8542 (when (or (and threadsp
8543 (> (length thread-articles) 1))
8545 (= (length thread-articles) 1)))
8546 (setq articles (nconc thread-articles articles))))
8548 (message "No messages matched")
8549 (gnus-summary-limit articles))
8550 (gnus-summary-position-point)))
8552 (defun gnus-summary-limit-to-replied (&optional unreplied)
8553 "Limit the summary buffer to replied articles.
8554 If UNREPLIED (the prefix), limit to unreplied articles."
8558 (gnus-set-difference gnus-newsgroup-articles
8559 gnus-newsgroup-replied))
8560 (gnus-summary-limit gnus-newsgroup-replied))
8561 (gnus-summary-position-point))
8563 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8564 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8565 If REVERSE, limit the summary buffer to articles that are marked
8566 with MARKS. MARKS can either be a string of marks or a list of marks.
8567 Returns how many articles were removed."
8568 (interactive "sMarks: ")
8569 (gnus-summary-limit-to-marks marks t))
8571 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8572 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8573 If REVERSE (the prefix), limit the summary buffer to articles that are
8574 not marked with MARKS. MARKS can either be a string of marks or a
8576 Returns how many articles were removed."
8577 (interactive "sMarks: \nP")
8579 (let ((data gnus-newsgroup-data)
8580 (marks (if (listp marks) marks
8581 (append marks nil))) ; Transform to list.
8584 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8585 (memq (gnus-data-mark (car data)) marks))
8586 (push (gnus-data-number (car data)) articles))
8587 (setq data (cdr data)))
8588 (gnus-summary-limit articles))
8589 (gnus-summary-position-point)))
8591 (defun gnus-summary-limit-to-score (score)
8592 "Limit to articles with score at or above SCORE."
8593 (interactive "NLimit to articles with score of at least: ")
8594 (let ((data gnus-newsgroup-data)
8597 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8599 (push (gnus-data-number (car data)) articles))
8600 (setq data (cdr data)))
8602 (gnus-summary-limit articles)
8603 (gnus-summary-position-point))))
8605 (defun gnus-summary-limit-to-unseen ()
8606 "Limit to unseen articles."
8609 (gnus-summary-limit gnus-newsgroup-unseen)
8610 (gnus-summary-position-point)))
8612 (defun gnus-summary-limit-include-thread (id)
8613 "Display all the hidden articles that is in the thread with ID in it.
8614 When called interactively, ID is the Message-ID of the current
8616 (interactive (list (mail-header-id (gnus-summary-article-header))))
8617 (let ((articles (gnus-articles-in-thread
8618 (gnus-id-to-thread (gnus-root-id id))))
8619 ;;we REALLY want the whole thread---this prevents cut-threads
8620 ;;from removing the thread we want to include.
8621 (gnus-fetch-old-headers nil)
8622 (gnus-build-sparse-threads nil))
8624 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8625 (gnus-summary-limit-include-matching-articles
8627 (regexp-quote (gnus-simplify-subject-re
8628 (mail-header-subject (gnus-id-to-header id)))))
8629 (gnus-summary-position-point))))
8631 (defun gnus-summary-limit-include-matching-articles (header regexp)
8632 "Display all the hidden articles that have HEADERs that match REGEXP."
8633 (interactive (list (read-string "Match on header: ")
8634 (read-string "Regexp: ")))
8635 (let ((articles (gnus-find-matching-articles header regexp)))
8637 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8638 (gnus-summary-position-point))))
8640 (defun gnus-summary-insert-dormant-articles ()
8641 "Insert all the dormant articles for this group into the current buffer."
8643 (let ((gnus-verbose (max 6 gnus-verbose)))
8644 (if (not gnus-newsgroup-dormant)
8645 (gnus-message 3 "No dormant articles for this group")
8646 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8648 (defun gnus-summary-insert-ticked-articles ()
8649 "Insert ticked articles for this group into the current buffer."
8651 (let ((gnus-verbose (max 6 gnus-verbose)))
8652 (if (not gnus-newsgroup-marked)
8653 (gnus-message 3 "No ticked articles for this group")
8654 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8656 (defun gnus-summary-limit-include-dormant ()
8657 "Display all the hidden articles that are marked as dormant.
8658 Note that this command only works on a subset of the articles currently
8659 fetched for this group."
8661 (unless gnus-newsgroup-dormant
8662 (error "There are no dormant articles in this group"))
8664 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8665 (gnus-summary-position-point)))
8667 (defun gnus-summary-include-articles (articles)
8668 "Fetch the headers for ARTICLES and then display the summary lines."
8669 (let ((gnus-inhibit-demon t)
8671 (gnus-read-all-available-headers t))
8672 (setq gnus-newsgroup-headers
8674 'list gnus-newsgroup-headers
8675 (gnus-fetch-headers articles nil t)
8676 'gnus-article-sort-by-number))
8677 (setq gnus-newsgroup-articles
8678 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8679 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8681 (defun gnus-summary-limit-exclude-dormant ()
8682 "Hide all dormant articles."
8685 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8686 (gnus-summary-position-point)))
8688 (defun gnus-summary-limit-exclude-childless-dormant ()
8689 "Hide all dormant articles that have no children."
8691 (let ((data (gnus-data-list t))
8692 articles d children)
8693 ;; Find all articles that are either not dormant or have
8695 (while (setq d (pop data))
8696 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8698 (gnus-article-children (gnus-data-number d)))
8701 (when (memq (car children) articles)
8706 (push (gnus-data-number d) articles)))
8709 (gnus-summary-limit articles)
8710 (gnus-summary-position-point))))
8712 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8713 "Mark all unread excluded articles as read.
8714 If ALL, mark even excluded ticked and dormants as read."
8716 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8717 (let ((articles (gnus-sorted-ndifference
8719 (mapcar (lambda (h) (mail-header-number h))
8720 gnus-newsgroup-headers)
8722 gnus-newsgroup-limit))
8724 (setq gnus-newsgroup-unreads
8725 (gnus-sorted-intersection gnus-newsgroup-unreads
8726 gnus-newsgroup-limit))
8728 (setq gnus-newsgroup-dormant nil
8729 gnus-newsgroup-marked nil
8730 gnus-newsgroup-reads
8732 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8733 gnus-newsgroup-reads))
8734 (while (setq article (pop articles))
8735 (unless (or (memq article gnus-newsgroup-dormant)
8736 (memq article gnus-newsgroup-marked))
8737 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8739 (defun gnus-summary-limit (articles &optional pop)
8741 ;; We pop the previous limit off the stack and use that.
8742 (setq articles (car gnus-newsgroup-limits)
8743 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8744 ;; We use the new limit, so we push the old limit on the stack.
8745 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8747 (setq gnus-newsgroup-limit articles)
8748 (let ((total (length gnus-newsgroup-data))
8749 (data (gnus-data-find-list (gnus-summary-article-number)))
8750 (gnus-summary-mark-below nil) ; Inhibit this.
8752 ;; This will do all the work of generating the new summary buffer
8753 ;; according to the new limit.
8754 (gnus-summary-prepare)
8755 ;; Hide any threads, possibly.
8756 (gnus-summary-maybe-hide-threads)
8757 ;; Try to return to the article you were at, or one in the
8760 ;; We try to find some article after the current one.
8762 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8765 (setq data (cdr data))))
8767 ;; If there is no data, that means that we were after the last
8768 ;; article. The same goes when we can't find any articles
8769 ;; after the current one.
8770 (goto-char (point-max))
8771 (gnus-summary-find-prev))
8772 (gnus-set-mode-line 'summary)
8773 ;; We return how many articles were removed from the summary
8774 ;; buffer as a result of the new limit.
8775 (- total (length gnus-newsgroup-data))))
8777 (defsubst gnus-invisible-cut-children (threads)
8780 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8785 (defsubst gnus-cut-thread (thread)
8786 "Go forwards in the thread until we find an article that we want to display."
8787 (when (or (eq gnus-fetch-old-headers 'some)
8788 (eq gnus-fetch-old-headers 'invisible)
8789 (numberp gnus-fetch-old-headers)
8790 (eq gnus-build-sparse-threads 'some)
8791 (eq gnus-build-sparse-threads 'more))
8792 ;; Deal with old-fetched headers and sparse threads.
8796 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8797 (gnus-summary-article-ancient-p
8798 (mail-header-number (car thread))))
8799 (if (or (<= (length (cdr thread)) 1)
8800 (eq gnus-fetch-old-headers 'invisible))
8801 (setq gnus-newsgroup-limit
8802 (delq (mail-header-number (car thread))
8803 gnus-newsgroup-limit)
8804 thread (cadr thread))
8805 (when (gnus-invisible-cut-children (cdr thread))
8806 (let ((th (cdr thread)))
8808 (if (memq (mail-header-number (caar th))
8809 gnus-newsgroup-limit)
8810 (setq thread (car th)
8812 (setq th (cdr th))))))))))
8815 (defun gnus-cut-threads (threads)
8816 "Cut off all uninteresting articles from the beginning of THREADS."
8817 (when (or (eq gnus-fetch-old-headers 'some)
8818 (eq gnus-fetch-old-headers 'invisible)
8819 (numberp gnus-fetch-old-headers)
8820 (eq gnus-build-sparse-threads 'some)
8821 (eq gnus-build-sparse-threads 'more))
8824 (setcar th (gnus-cut-thread (car th)))
8825 (setq th (cdr th)))))
8826 ;; Remove nixed out threads.
8829 (defun gnus-summary-initial-limit (&optional show-if-empty)
8830 "Figure out what the initial limit is supposed to be on group entry.
8831 This entails weeding out unwanted dormants, low-scored articles,
8832 fetch-old-headers verbiage, and so on."
8833 ;; Most groups have nothing to remove.
8834 (unless (or gnus-inhibit-limiting
8835 (and (null gnus-newsgroup-dormant)
8836 (eq gnus-newsgroup-display 'gnus-not-ignore)
8837 (not (eq gnus-fetch-old-headers 'some))
8838 (not (numberp gnus-fetch-old-headers))
8839 (not (eq gnus-fetch-old-headers 'invisible))
8840 (null gnus-summary-expunge-below)
8841 (not (eq gnus-build-sparse-threads 'some))
8842 (not (eq gnus-build-sparse-threads 'more))
8843 (null gnus-thread-expunge-below)))
8844 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8845 (setq gnus-newsgroup-limit nil)
8848 (unless (car (symbol-value node))
8849 ;; These threads have no parents -- they are roots.
8850 (let ((nodes (cdr (symbol-value node)))
8853 (if (and gnus-thread-expunge-below
8854 (< (gnus-thread-total-score (car nodes))
8855 gnus-thread-expunge-below))
8856 (gnus-expunge-thread (pop nodes))
8857 (setq thread (pop nodes))
8858 (gnus-summary-limit-children thread))))))
8859 gnus-newsgroup-dependencies)
8860 ;; If this limitation resulted in an empty group, we might
8861 ;; pop the previous limit and use it instead.
8862 (when (and (not gnus-newsgroup-limit)
8864 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8865 gnus-newsgroup-limit))
8867 (defun gnus-summary-limit-children (thread)
8868 "Return 1 if this subthread is visible and 0 if it is not."
8869 ;; First we get the number of visible children to this thread. This
8870 ;; is done by recursing down the thread using this function, so this
8871 ;; will really go down to a leaf article first, before slowly
8872 ;; working its way up towards the root.
8874 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8877 (apply '+ (mapcar 'gnus-summary-limit-children
8880 (number (mail-header-number (car thread)))
8883 (not (memq number gnus-newsgroup-marked))
8885 ;; If this article is dormant and has absolutely no visible
8886 ;; children, then this article isn't visible.
8887 (and (memq number gnus-newsgroup-dormant)
8889 ;; If this is "fetch-old-headered" and there is no
8890 ;; visible children, then we don't want this article.
8891 (and (or (eq gnus-fetch-old-headers 'some)
8892 (numberp gnus-fetch-old-headers))
8893 (gnus-summary-article-ancient-p number)
8895 ;; If this is "fetch-old-headered" and `invisible', then
8896 ;; we don't want this article.
8897 (and (eq gnus-fetch-old-headers 'invisible)
8898 (gnus-summary-article-ancient-p number))
8899 ;; If this is a sparsely inserted article with no children,
8900 ;; we don't want it.
8901 (and (eq gnus-build-sparse-threads 'some)
8902 (gnus-summary-article-sparse-p number)
8904 ;; If we use expunging, and this article is really
8905 ;; low-scored, then we don't want this article.
8906 (when (and gnus-summary-expunge-below
8908 (or (cdr (assq number gnus-newsgroup-scored))
8909 gnus-summary-default-score))
8910 gnus-summary-expunge-below))
8911 ;; We increase the expunge-tally here, but that has
8912 ;; nothing to do with the limits, really.
8913 (incf gnus-newsgroup-expunged-tally)
8914 ;; We also mark as read here, if that's wanted.
8915 (when (and gnus-summary-mark-below
8916 (< score gnus-summary-mark-below))
8917 (setq gnus-newsgroup-unreads
8918 (delq number gnus-newsgroup-unreads))
8919 (if gnus-newsgroup-auto-expire
8920 (push number gnus-newsgroup-expirable)
8921 (push (cons number gnus-low-score-mark)
8922 gnus-newsgroup-reads)))
8924 ;; Do the `display' group parameter.
8925 (and gnus-newsgroup-display
8926 (let ((gnus-number number))
8927 (not (funcall gnus-newsgroup-display))))))
8928 ;; Nope, invisible article.
8930 ;; Ok, this article is to be visible, so we add it to the limit
8932 (push number gnus-newsgroup-limit)
8935 (defun gnus-expunge-thread (thread)
8936 "Mark all articles in THREAD as read."
8937 (let* ((number (mail-header-number (car thread))))
8938 (incf gnus-newsgroup-expunged-tally)
8939 ;; We also mark as read here, if that's wanted.
8940 (setq gnus-newsgroup-unreads
8941 (delq number gnus-newsgroup-unreads))
8942 (if gnus-newsgroup-auto-expire
8943 (push number gnus-newsgroup-expirable)
8944 (push (cons number gnus-low-score-mark)
8945 gnus-newsgroup-reads)))
8946 ;; Go recursively through all subthreads.
8947 (mapcar 'gnus-expunge-thread (cdr thread)))
8949 ;; Summary article oriented commands
8951 (defun gnus-summary-refer-parent-article (n)
8952 "Refer parent article N times.
8953 If N is negative, go to ancestor -N instead.
8954 The difference between N and the number of articles fetched is returned."
8958 (when (not (natnump n))
8963 (setq header (gnus-summary-article-header))
8964 (if (and (eq (mail-header-number header)
8965 (cdr gnus-article-current))
8966 (equal gnus-newsgroup-name
8967 (car gnus-article-current)))
8968 ;; If we try to find the parent of the currently
8969 ;; displayed article, then we take a look at the actual
8970 ;; References header, since this is slightly more
8971 ;; reliable than the References field we got from the
8973 (with-current-buffer gnus-original-article-buffer
8974 (nnheader-narrow-to-headers)
8975 (unless (setq ref (message-fetch-field "references"))
8976 (when (setq ref (message-fetch-field "in-reply-to"))
8977 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8980 ;; It's not the current article, so we take a bet on
8981 ;; the value we got from the server.
8982 (mail-header-references header)))
8984 (not (equal ref "")))
8985 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8986 (gnus-message 1 "Couldn't find parent"))
8987 (gnus-message 1 "No references in article %d"
8988 (gnus-summary-article-number))
8991 (gnus-summary-position-point)
8994 (defun gnus-summary-refer-references ()
8995 "Fetch all articles mentioned in the References header.
8996 Return the number of articles fetched."
8998 (let ((ref (mail-header-references (gnus-summary-article-header)))
8999 (current (gnus-summary-article-number))
9003 (error "No References in the current article")
9004 ;; For each Message-ID in the References header...
9005 (while (string-match "<[^>]*>" ref)
9007 ;; ... fetch that article.
9008 (gnus-summary-refer-article
9009 (prog1 (match-string 0 ref)
9010 (setq ref (substring ref (match-end 0))))))
9011 (gnus-summary-goto-subject current)
9012 (gnus-summary-position-point)
9015 (defun gnus-delete-duplicate-headers (headers)
9016 ;; First remove leading duplicates.
9017 (while (and (> (length headers) 1)
9018 (= (mail-header-number (car headers))
9019 (mail-header-number (cadr headers))))
9022 (let ((result headers))
9023 (while (> (length headers) 1)
9024 (if (= (mail-header-number (car headers))
9025 (mail-header-number (cadr headers)))
9026 (setcdr headers (cddr headers))
9030 (defun gnus-summary-refer-thread (&optional limit)
9031 "Fetch all articles in the current thread. For backends that
9032 know how to search for threads (currently only 'nnimap) a
9033 non-numeric prefix arg will use nnir to search the entire
9034 server; without a prefix arg only the current group is
9035 searched. If the variable `gnus-refer-thread-use-nnir' is
9036 non-nil the prefix arg has the reverse meaning. If no
9037 backend-specific 'request-thread function is available fetch
9038 LIMIT (the numerical prefix) old headers. If LIMIT is
9039 non-numeric or nil fetch the number specified by the
9040 `gnus-refer-thread-limit' variable."
9042 (gnus-warp-to-article)
9043 (let* ((header (gnus-summary-article-header))
9044 (id (mail-header-id header))
9045 (gnus-inhibit-demon t)
9046 (gnus-summary-ignore-duplicates t)
9047 (gnus-read-all-available-headers t)
9048 (gnus-refer-thread-use-nnir
9049 (if (and (not (null limit)) (listp limit))
9050 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9052 (if (gnus-check-backend-function
9053 'request-thread gnus-newsgroup-name)
9054 (gnus-request-thread header gnus-newsgroup-name)
9055 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9056 gnus-refer-thread-limit))
9057 (last (if (numberp limit)
9058 (min (+ (mail-header-number header)
9060 gnus-newsgroup-highest)
9061 gnus-newsgroup-highest))
9062 (subject (gnus-simplify-subject
9063 (mail-header-subject header)))
9064 (refs (split-string (or (mail-header-references header)
9066 (gnus-parse-headers-hook
9067 `(lambda () (goto-char (point-min))
9069 (regexp-opt ',(append refs (list id subject)))))))
9070 (gnus-fetch-headers (list last) (if (numberp limit)
9071 (* 2 limit) limit) t))))
9072 article-ids new-unreads)
9073 (when (listp new-headers)
9074 (dolist (header new-headers)
9075 (push (mail-header-number header) article-ids))
9076 (setq article-ids (nreverse article-ids))
9078 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9079 (setq gnus-newsgroup-unselected
9080 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9081 (setq gnus-newsgroup-unreads
9082 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9083 (setq gnus-newsgroup-headers
9084 (gnus-delete-duplicate-headers
9086 'list gnus-newsgroup-headers new-headers
9087 'gnus-article-sort-by-number)))
9088 (setq gnus-newsgroup-articles
9089 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9090 (gnus-summary-limit-include-thread id)))
9091 (gnus-summary-show-thread))
9093 (defun gnus-summary-open-group-with-article (message-id)
9094 "Open a group containing the article with the given MESSAGE-ID."
9095 (interactive "sMessage-ID: ")
9098 ;; Prepare a dummy article
9100 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9102 ;; Prepare pretty modelines for summary and article buffers
9103 (let ((gnus-summary-mode-line-format "Found %G")
9104 (gnus-article-mode-line-format
9105 ;; Group names just get in the way here, especially the
9107 (if (string-match "%[gG]" gnus-article-mode-line-format)
9108 (concat (substring gnus-article-mode-line-format
9109 0 (match-beginning 0))
9110 (substring gnus-article-mode-line-format (match-end 0)))
9111 gnus-article-mode-line-format)))
9113 ;; Build an ephemeral group containing the dummy article (hidden)
9114 (gnus-group-read-ephemeral-group
9117 (nndoc-address ,(current-buffer))
9118 (nndoc-article-type mbox))
9120 (cons (current-buffer) gnus-current-window-configuration)
9122 '(-1) ; :select-articles
9125 ;; Fetch the desired article
9126 (gnus-summary-refer-article message-id)))
9128 (defun gnus-summary-refer-article (message-id)
9129 "Fetch an article specified by MESSAGE-ID."
9130 (interactive "sMessage-ID: ")
9131 (gnus-warp-to-article)
9132 (when (and (stringp message-id)
9133 (not (zerop (length message-id))))
9134 (setq message-id (gnus-replace-in-string message-id " " ""))
9135 ;; Construct the correct Message-ID if necessary.
9136 ;; Suggested by tale@pawl.rpi.edu.
9137 (unless (string-match "^<" message-id)
9138 (setq message-id (concat "<" message-id)))
9139 (unless (string-match ">$" message-id)
9140 (setq message-id (concat message-id ">")))
9141 ;; People often post MIDs from URLs, so unhex it:
9142 (unless (string-match "@" message-id)
9143 (setq message-id (gnus-url-unhex-string message-id)))
9144 (let* ((header (gnus-id-to-header message-id))
9146 (gnus-summary-article-sparse-p
9147 (mail-header-number header))
9148 (memq (mail-header-number header)
9149 gnus-newsgroup-limit)))
9152 ;; If the article is present in the buffer we just go to it.
9154 (or (not (gnus-summary-article-sparse-p
9155 (mail-header-number header)))
9158 (gnus-summary-goto-article
9159 (mail-header-number header) nil t)
9161 (gnus-summary-update-article (mail-header-number header)))))
9163 ;; We fetch the article.
9165 (dolist (gnus-override-method (gnus-refer-article-methods))
9166 (when (and (gnus-check-server gnus-override-method)
9167 ;; Fetch the header,
9168 (setq number (gnus-summary-insert-subject message-id)))
9169 ;; and display the article.
9170 (gnus-summary-select-article nil nil nil number)
9172 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9174 (defun gnus-refer-article-methods ()
9175 "Return a list of referable methods."
9177 ;; No method, so we default to current and native.
9178 ((null gnus-refer-article-method)
9179 (list gnus-current-select-method gnus-select-method))
9181 ((eq 'current gnus-refer-article-method)
9182 (list gnus-current-select-method))
9183 ;; List of select methods.
9184 ((not (and (symbolp (car gnus-refer-article-method))
9185 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9187 (dolist (method gnus-refer-article-method)
9188 (push (if (eq 'current method)
9189 gnus-current-select-method
9190 (if (eq 'nnir (car method))
9194 (gnus-method-to-server gnus-current-select-method)))
9198 ;; One single select method.
9200 (list gnus-refer-article-method))))
9202 (defun gnus-summary-edit-parameters ()
9203 "Edit the group parameters of the current group."
9205 (gnus-group-edit-group gnus-newsgroup-name 'params))
9207 (defun gnus-summary-customize-parameters ()
9208 "Customize the group parameters of the current group."
9210 (gnus-group-customize gnus-newsgroup-name))
9212 (defun gnus-summary-enter-digest-group (&optional force)
9213 "Enter an nndoc group based on the current article.
9214 If FORCE, force a digest interpretation. If not, try to guess
9215 what the document format is.
9217 To control what happens when you exit the group, see the
9218 `gnus-auto-select-on-ephemeral-exit' variable."
9220 (let ((conf gnus-current-window-configuration))
9221 (save-window-excursion
9223 (let (gnus-article-prepare-hook
9224 gnus-display-mime-function
9226 (gnus-summary-select-article))))
9227 (setq gnus-current-window-configuration conf)
9228 (let* ((name (format "%s-%d"
9229 (gnus-group-prefixed-name
9230 gnus-newsgroup-name (list 'nndoc ""))
9231 (with-current-buffer gnus-summary-buffer
9232 gnus-current-article)))
9233 (ogroup gnus-newsgroup-name)
9234 (params (append (gnus-info-params (gnus-get-info ogroup))
9235 (list (cons 'to-group ogroup))
9236 (list (cons 'parent-group ogroup))
9237 (list (cons 'save-article-group ogroup))))
9238 (case-fold-search t)
9239 (buf (current-buffer))
9240 dig to-address charset)
9241 (with-current-buffer gnus-original-article-buffer
9242 ;; Have the digest group inherit the main mail address of
9243 ;; the parent article.
9244 (when (setq to-address (or (gnus-fetch-field "reply-to")
9245 (gnus-fetch-field "from")))
9249 (list (cons 'to-address
9250 (funcall gnus-decode-encoded-address-function
9252 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9253 (insert-buffer-substring gnus-original-article-buffer)
9255 (goto-char (point-min))
9256 (or (search-forward "\n\n" nil t) (point)))
9257 ;; Remove lines that may lead nndoc to misinterpret the
9259 (goto-char (point-min))
9260 (delete-matching-lines "^Path:\\|^From ")
9261 ;; Parse charset, and decode content transfer encoding.
9262 (setq charset (mail-content-type-get
9263 (mail-header-parse-content-type
9264 (or (gnus-fetch-field "content-type") ""))
9266 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9268 (message-remove-header "content-transfer-encoding")
9269 (goto-char (point-max))
9271 (narrow-to-region (point) (point-max))
9272 (mm-decode-content-transfer-encoding
9273 (intern (downcase (mail-header-strip encoding))))))
9276 (if (let ((gnus-newsgroup-ephemeral-charset
9278 (intern (downcase (gnus-strip-whitespace charset)))
9279 gnus-newsgroup-charset))
9280 (gnus-newsgroup-ephemeral-ignored-charsets
9281 gnus-newsgroup-ignored-charsets))
9282 (gnus-group-read-ephemeral-group
9283 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9285 ,(if force 'mbox 'guess)))
9287 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9289 ;; Make all postings to this group go to the parent group.
9290 (nconc (gnus-info-params (gnus-get-info name))
9292 ;; Couldn't select this doc group.
9293 (switch-to-buffer buf)
9294 (gnus-set-global-variables)
9295 (gnus-configure-windows 'summary)
9296 (gnus-message 3 "Article couldn't be entered?"))
9297 (kill-buffer dig)))))
9299 (defun gnus-summary-read-document (n)
9300 "Open a new group based on the current article(s).
9301 This will allow you to read digests and other similar
9302 documents as newsgroups.
9303 Obeys the standard process/prefix convention."
9305 (let* ((ogroup gnus-newsgroup-name)
9306 (params (append (gnus-info-params (gnus-get-info ogroup))
9307 (list (cons 'to-group ogroup))))
9308 group egroup groups vgroup)
9309 (dolist (article (gnus-summary-work-articles n))
9310 (setq group (format "%s-%d" gnus-newsgroup-name article))
9311 (gnus-summary-remove-process-mark article)
9312 (when (gnus-summary-display-article article)
9313 (save-excursion ;;What for?
9315 (insert-buffer-substring gnus-original-article-buffer)
9316 ;; Remove some headers that may lead nndoc to make
9318 (message-narrow-to-head)
9319 (goto-char (point-min))
9320 (delete-matching-lines "^Path:\\|^From ")
9323 (gnus-group-read-ephemeral-group
9324 group `(nndoc ,group (nndoc-address ,(current-buffer))
9325 (nndoc-article-type guess))
9328 ;; Make all postings to this group go to the parent group.
9329 (nconc (gnus-info-params (gnus-get-info egroup))
9331 (push egroup groups))
9332 ;; Couldn't select this doc group.
9333 (gnus-error 3 "Article couldn't be entered"))))))
9334 ;; Now we have selected all the documents.
9337 (error "None of the articles could be interpreted as documents"))
9338 ((gnus-group-read-ephemeral-group
9339 (setq vgroup (format
9340 "nnvirtual:%s-%s" gnus-newsgroup-name
9341 (format-time-string "%Y%m%dT%H%M%S")))
9342 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9344 (cons (current-buffer) 'summary)))
9346 (error "Couldn't select virtual nndoc group")))))
9348 (defun gnus-summary-widget-forward (arg)
9349 "Move point to the next field or button in the article.
9350 With optional ARG, move across that many fields."
9352 (gnus-summary-select-article)
9353 (gnus-configure-windows 'article)
9354 (select-window (gnus-get-buffer-window gnus-article-buffer))
9355 (widget-forward arg))
9357 (defun gnus-summary-widget-backward (arg)
9358 "Move point to the previous field or button in the article.
9359 With optional ARG, move across that many fields."
9361 (gnus-summary-select-article)
9362 (gnus-configure-windows 'article)
9363 (select-window (gnus-get-buffer-window gnus-article-buffer))
9364 (unless (widget-at (point))
9365 (goto-char (point-max)))
9366 (widget-backward arg))
9368 (defun gnus-summary-isearch-article (&optional regexp-p)
9369 "Do incremental search forward on the current article.
9370 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9372 (gnus-summary-select-article)
9373 (gnus-configure-windows 'article)
9374 (gnus-eval-in-buffer-window gnus-article-buffer
9377 (isearch-forward regexp-p))))
9379 (defun gnus-summary-repeat-search-article-forward ()
9380 "Repeat the previous search forwards."
9382 (unless gnus-last-search-regexp
9383 (error "No previous search"))
9384 (gnus-summary-search-article-forward gnus-last-search-regexp))
9386 (defun gnus-summary-repeat-search-article-backward ()
9387 "Repeat the previous search backwards."
9389 (unless gnus-last-search-regexp
9390 (error "No previous search"))
9391 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9393 (defun gnus-summary-search-article-forward (regexp &optional backward)
9394 "Search for an article containing REGEXP forward.
9395 If BACKWARD, search backward instead."
9398 (format "Search article %s (regexp%s): "
9399 (if current-prefix-arg "backward" "forward")
9400 (if gnus-last-search-regexp
9401 (concat ", default " gnus-last-search-regexp)
9403 current-prefix-arg))
9404 (if (string-equal regexp "")
9405 (setq regexp (or gnus-last-search-regexp ""))
9406 (setq gnus-last-search-regexp regexp)
9407 (setq gnus-article-before-search gnus-current-article))
9408 ;; Intentionally set gnus-last-article.
9409 (setq gnus-last-article gnus-article-before-search)
9410 (let ((gnus-last-article gnus-last-article))
9411 (if (gnus-summary-search-article regexp backward)
9412 (gnus-summary-show-thread)
9413 (signal 'search-failed (list regexp)))))
9415 (defun gnus-summary-search-article-backward (regexp)
9416 "Search for an article containing REGEXP backward."
9419 (format "Search article backward (regexp%s): "
9420 (if gnus-last-search-regexp
9421 (concat ", default " gnus-last-search-regexp)
9423 (gnus-summary-search-article-forward regexp 'backward))
9425 (defun gnus-summary-search-article (regexp &optional backward)
9426 "Search for an article containing REGEXP.
9427 Optional argument BACKWARD means do search for backward.
9428 `gnus-select-article-hook' is not called during the search."
9429 ;; We have to require this here to make sure that the following
9430 ;; dynamic binding isn't shadowed by autoloading.
9431 (require 'gnus-async)
9433 (let ((gnus-select-article-hook nil) ;Disable hook.
9434 (gnus-article-prepare-hook nil)
9435 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9436 (gnus-use-article-prefetch nil)
9437 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9438 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9440 (gnus-keep-backlog nil)
9441 (gnus-break-pages nil)
9442 (gnus-summary-display-arrow nil)
9443 (gnus-updated-mode-lines nil)
9444 (gnus-auto-center-summary nil)
9445 (sum (current-buffer))
9446 (gnus-display-mime-function nil)
9449 (gnus-save-hidden-threads
9450 (gnus-summary-select-article)
9451 (set-buffer gnus-article-buffer)
9452 (goto-char (window-point (get-buffer-window (current-buffer))))
9456 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9458 (re-search-backward regexp nil t)
9459 (re-search-forward regexp nil t))
9460 ;; We found the regexp.
9465 (get-buffer-window (current-buffer))
9469 (get-buffer-window (current-buffer))
9472 (setq point (point)))
9473 ;; We didn't find it, so we go to the next article.
9476 (while (eq found 'not)
9477 (if (not (if backward (gnus-summary-find-prev)
9478 (gnus-summary-find-next)))
9479 ;; No more articles.
9481 ;; Select the next article and adjust point.
9482 (unless (gnus-summary-article-sparse-p
9483 (gnus-summary-article-number))
9485 (gnus-summary-select-article)
9486 (set-buffer gnus-article-buffer)
9488 (goto-char (if backward (point-max) (point-min))))))))
9489 (gnus-message 7 ""))
9490 ;; Return whether we found the regexp.
9491 (when (eq found 'found)
9493 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9494 (gnus-summary-show-thread)
9495 (gnus-summary-goto-subject gnus-current-article)
9496 (gnus-summary-position-point)
9499 (defun gnus-find-matching-articles (header regexp)
9500 "Return a list of all articles that match REGEXP on HEADER.
9501 This search includes all articles in the current group that Gnus has
9502 fetched headers for, whether they are displayed or not."
9503 (let ((articles nil)
9504 ;; Can't eta-reduce because it's a macro.
9505 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9506 (case-fold-search t))
9507 (dolist (header gnus-newsgroup-headers)
9508 (when (string-match regexp (funcall func header))
9509 (push (mail-header-number header) articles)))
9510 (nreverse articles)))
9512 (defun gnus-summary-find-matching (header regexp &optional backward unread
9513 not-case-fold not-matching)
9514 "Return a list of all articles that match REGEXP on HEADER.
9515 The search stars on the current article and goes forwards unless
9516 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9517 If UNREAD is non-nil, only unread articles will
9518 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9519 in the comparisons. If NOT-MATCHING, return a list of all articles that
9520 not match REGEXP on HEADER."
9521 (let ((case-fold-search (not not-case-fold))
9524 (if (eq (car header) 'extra)
9527 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9529 (error "%s is an invalid header" header))
9530 (unless (fboundp (intern (concat "mail-header-" header)))
9531 (error "%s is not a valid header" header))
9532 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9533 (dolist (d (if (eq backward 'all)
9535 (gnus-data-find-list
9536 (gnus-summary-article-number)
9537 (gnus-data-list backward))))
9538 (when (and (or (not unread) ; We want all articles...
9539 (gnus-data-unread-p d)) ; Or just unreads.
9540 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9544 (funcall func (gnus-data-header d))))
9545 (string-match regexp
9546 (funcall func (gnus-data-header d)))))
9547 (push (gnus-data-number d) articles))) ; Success!
9548 (nreverse articles)))
9550 (defun gnus-summary-execute-command (header regexp command &optional backward)
9551 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9552 If HEADER is an empty string (or nil), the match is done on the entire
9553 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9555 (list (let ((completion-ignore-case t))
9556 (gnus-completing-read
9558 (mapcar 'symbol-name
9560 '(Number Subject From Lines Date
9561 Message-ID Xref References Body)
9562 gnus-extra-headers))
9564 (read-string "Regexp: ")
9565 (read-key-sequence "Command: ")
9566 current-prefix-arg))
9567 (when (equal header "Body")
9569 ;; Hidden thread subtrees must be searched as well.
9570 (gnus-summary-show-all-threads)
9571 ;; We don't want to change current point nor window configuration.
9573 (save-window-excursion
9575 gnus-treat-strip-trailing-blank-lines
9576 gnus-treat-strip-leading-blank-lines
9577 gnus-treat-strip-multiple-blank-lines
9578 gnus-treat-hide-boring-headers
9579 gnus-treat-fold-newsgroups
9580 gnus-article-prepare-hook)
9581 (gnus-message 6 "Executing %s..." (key-description command))
9582 ;; We'd like to execute COMMAND interactively so as to give arguments.
9583 (gnus-execute header regexp
9584 `(call-interactively ',(key-binding command))
9586 (gnus-message 6 "Executing %s...done" (key-description command))))))
9588 (defun gnus-summary-beginning-of-article ()
9589 "Scroll the article back to the beginning."
9591 (gnus-summary-select-article)
9592 (gnus-configure-windows 'article)
9593 (gnus-eval-in-buffer-window gnus-article-buffer
9595 (goto-char (point-min))
9596 (when gnus-break-pages
9597 (gnus-narrow-to-page))))
9599 (defun gnus-summary-end-of-article ()
9600 "Scroll to the end of the article."
9602 (gnus-summary-select-article)
9603 (gnus-configure-windows 'article)
9604 (gnus-eval-in-buffer-window gnus-article-buffer
9606 (goto-char (point-max))
9608 (when gnus-break-pages
9609 (gnus-narrow-to-page))))
9611 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9612 "Truncate to LEN and quote all \"(\"'s in STRING."
9613 (gnus-replace-in-string (if (and len (> (length string) len))
9614 (substring string 0 len)
9618 (defun gnus-summary-print-article (&optional filename n)
9619 "Generate and print a PostScript image of the process-marked (mail) articles.
9621 If used interactively, print the current article if none are
9622 process-marked. With prefix arg, prompt the user for the name of the
9625 When used from Lisp, accept two optional args FILENAME and N. N means
9626 to print the next N articles. If N is negative, print the N previous
9627 articles. If N is nil and articles have been marked with the process
9628 mark, print these instead.
9630 If the optional first argument FILENAME is nil, send the image to the
9631 printer. If FILENAME is a string, save the PostScript image in a file with
9632 that name. If FILENAME is a number, prompt the user for the name of the file
9634 (interactive (list (ps-print-preprint current-prefix-arg)))
9635 (dolist (article (gnus-summary-work-articles n))
9636 (gnus-summary-select-article nil nil 'pseudo article)
9637 (gnus-eval-in-buffer-window gnus-article-buffer
9638 (gnus-print-buffer))
9639 (gnus-summary-remove-process-mark article))
9640 (ps-despool filename))
9642 (defun gnus-print-buffer ()
9643 (let ((ps-left-header
9646 (gnus-summary-print-truncate-and-quote
9647 (mail-header-subject gnus-current-headers)
9650 (gnus-summary-print-truncate-and-quote
9651 (mail-header-from gnus-current-headers)
9655 "/pagenumberstring load"
9657 (mail-header-date gnus-current-headers) ")"))))
9658 (gnus-run-hooks 'gnus-ps-print-hook)
9660 (if ps-print-color-p
9661 (ps-spool-buffer-with-faces)
9662 (ps-spool-buffer)))))
9664 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9666 (defun gnus-summary-show-complete-article ()
9667 "Show a complete version of the current article.
9668 This is only useful if you're looking at a partial version of the
9671 (let ((gnus-keep-backlog nil)
9672 (gnus-use-cache nil)
9675 (format "%s-fetch-partial-articles"
9676 (car (gnus-find-method-for-group
9677 gnus-newsgroup-name)))
9682 (setq old-val (symbol-value variable))
9684 (gnus-flush-original-article-buffer)
9685 (gnus-summary-show-article))
9686 (set variable old-val))))
9688 (defun gnus-summary-show-article (&optional arg)
9689 "Force redisplaying of the current article.
9690 If ARG (the prefix) is a number, show the article with the charset
9691 defined in `gnus-summary-show-article-charset-alist', or the charset
9693 If ARG (the prefix) is non-nil and not a number, show the article,
9694 but without running any of the article treatment functions
9695 article. Normally, the keystroke is `C-u g'. When using `C-u
9696 C-u g', show the raw article."
9700 (gnus-summary-show-article t)
9701 (let ((gnus-newsgroup-charset
9702 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9703 (mm-read-coding-system
9704 "View as charset: " ;; actually it is coding system.
9705 (with-current-buffer gnus-article-buffer
9706 (mm-detect-coding-region (point) (point-max))))))
9707 (gnus-newsgroup-ignored-charsets 'gnus-all))
9708 (gnus-summary-select-article nil 'force)
9709 (let ((deps gnus-newsgroup-dependencies)
9711 (with-current-buffer gnus-original-article-buffer
9713 (message-narrow-to-head)
9714 (setq head (buffer-string))
9715 (goto-char (point-min))
9716 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9717 (goto-char (point-max))
9719 (setq lines (1- (count-lines (point) (point-max))))))
9721 (insert (format "211 %d Article retrieved.\n"
9722 (cdr gnus-article-current)))
9724 (if lines (insert (format "Lines: %d\n" lines)))
9726 (let ((nntp-server-buffer (current-buffer)))
9727 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9728 (gnus-data-set-header
9729 (gnus-data-find (cdr gnus-article-current))
9731 (gnus-summary-update-article-line
9732 (cdr gnus-article-current) header)
9733 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9734 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9736 ;; Select the article the normal way.
9737 (if (eq mm-text-html-renderer 'shr)
9740 (let ((shr-ignore-cache t))
9741 (gnus-summary-select-article nil 'force)))
9742 (gnus-summary-select-article nil 'force)))
9745 (let ((gnus-inhibit-article-treatments t))
9746 (gnus-summary-select-article nil 'force)))
9748 ;; We have to require this here to make sure that the following
9749 ;; dynamic binding isn't shadowed by autoloading.
9750 (require 'gnus-async)
9752 ;; Bind the article treatment functions to nil.
9753 (let ((gnus-have-all-headers t)
9754 gnus-article-prepare-hook
9755 gnus-article-decode-hook
9756 gnus-display-mime-function
9758 ;; Destroy any MIME parts.
9759 (when (gnus-buffer-live-p gnus-article-buffer)
9760 (with-current-buffer gnus-article-buffer
9761 (gnus-article-stop-animations)
9762 (gnus-stop-downloads)
9763 (mm-destroy-parts gnus-article-mime-handles)
9764 ;; Set it to nil for safety reason.
9765 (setq gnus-article-mime-handle-alist nil)
9766 (setq gnus-article-mime-handles nil)))
9767 (gnus-summary-select-article nil 'force))))
9768 (gnus-summary-goto-subject gnus-current-article)
9769 (gnus-summary-position-point))
9771 (defun gnus-summary-show-raw-article ()
9772 "Show the raw article without any article massaging functions being run."
9774 (gnus-summary-show-article t))
9776 (defun gnus-summary-verbose-headers (&optional arg)
9777 "Toggle permanent full header display.
9778 If ARG is a positive number, turn header display on.
9779 If ARG is a negative number, turn header display off."
9781 (setq gnus-show-all-headers
9782 (cond ((or (not (numberp arg))
9784 (not gnus-show-all-headers))
9787 (gnus-summary-show-article))
9789 (declare-function article-narrow-to-head "gnus-art" ())
9790 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9791 (declare-function gnus-delete-wash-type "gnus-art" (type))
9792 (declare-function gnus-mime-buttonize-attachments-in-header
9793 "gnus-art" (&optional interactive))
9795 (defun gnus-summary-toggle-header (&optional arg)
9796 "Show the headers if they are hidden, or hide them if they are shown.
9797 If ARG is a positive number, show the entire header.
9798 If ARG is a negative number, hide the unwanted header lines."
9800 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9801 (get-buffer-window gnus-article-buffer t))))
9802 (with-current-buffer gnus-article-buffer
9804 (article-narrow-to-head)
9805 (let* ((inhibit-read-only t)
9806 (inhibit-point-motion-hooks t)
9807 (hidden (if (numberp arg)
9809 (or (not (looking-at "[^ \t\n]+:"))
9810 (gnus-article-hidden-text-p 'headers))))
9812 (delete-region (point-min) (point-max))
9813 (with-current-buffer gnus-original-article-buffer
9814 (goto-char (setq s (point-min)))
9815 (setq e (if (search-forward "\n\n" nil t)
9818 (insert-buffer-substring gnus-original-article-buffer s e)
9819 (run-hooks 'gnus-article-decode-hook)
9821 (let ((gnus-treat-hide-headers nil)
9822 (gnus-treat-hide-boring-headers nil))
9823 (gnus-delete-wash-type 'headers)
9824 (gnus-treat-article 'head))
9825 (gnus-treat-article 'head)
9826 ;; Add attachment buttons to the header.
9827 (when gnus-mime-display-attachment-buttons-in-header
9828 (gnus-mime-buttonize-attachments-in-header)))
9831 (set-window-start window (goto-char (point-min))))
9832 (if gnus-break-pages
9833 (gnus-narrow-to-page)
9834 (when (gnus-visual-p 'page-marker)
9835 (let ((inhibit-read-only t))
9836 (gnus-remove-text-with-property 'gnus-prev)
9837 (gnus-remove-text-with-property 'gnus-next))))
9838 (gnus-set-mode-line 'article)))))
9840 (defun gnus-summary-show-all-headers ()
9841 "Make all header lines visible."
9843 (gnus-summary-toggle-header 1))
9845 (defun gnus-summary-caesar-message (&optional arg)
9846 "Caesar rotate the current article by 13.
9847 With a non-numerical prefix, also rotate headers. A numerical
9848 prefix specifies how many places to rotate each letter forward."
9850 (gnus-summary-select-article)
9851 (let ((mail-header-separator ""))
9852 (gnus-eval-in-buffer-window gnus-article-buffer
9855 (let ((start (window-start))
9856 (inhibit-read-only t))
9857 (if (equal arg '(4))
9858 (message-caesar-buffer-body nil t)
9859 (message-caesar-buffer-body arg))
9860 (set-window-start (get-buffer-window (current-buffer)) start)))))
9861 ;; Create buttons and stuff...
9862 (gnus-treat-article nil))
9864 (declare-function idna-to-unicode "ext:idna" (str))
9866 (defun gnus-summary-idna-message (&optional arg)
9867 "Decode IDNA encoded domain names in the current articles.
9868 IDNA encoded domain names looks like `xn--bar'. If a string
9869 remain unencoded after running this function, it is likely an
9870 invalid IDNA string (`xn--bar' is invalid).
9872 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9873 installed for this command to work."
9875 (if (not (and (mm-coding-system-p 'utf-8)
9879 (invalid-operation))
9880 (symbol-value 'idna-program)
9881 (executable-find (symbol-value 'idna-program))))
9883 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9884 (gnus-summary-select-article)
9885 (let ((mail-header-separator ""))
9886 (gnus-eval-in-buffer-window gnus-article-buffer
9889 (let ((start (window-start))
9891 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9892 (replace-match (idna-to-unicode (match-string 1))))
9893 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9895 (defun gnus-summary-morse-message (&optional arg)
9896 "Morse decode the current article."
9898 (gnus-summary-select-article)
9899 (let ((mail-header-separator ""))
9900 (gnus-eval-in-buffer-window gnus-article-buffer
9904 (let ((pos (window-start))
9905 (inhibit-read-only t))
9906 (goto-char (point-min))
9907 (when (message-goto-body)
9908 (gnus-narrow-to-body))
9909 (goto-char (point-min))
9910 (while (search-forward "·" (point-max) t)
9911 (replace-match "."))
9912 (unmorse-region (point-min) (point-max))
9914 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9916 (defun gnus-summary-stop-page-breaking ()
9917 "Stop page breaking in the current article."
9919 (gnus-summary-select-article)
9920 (gnus-eval-in-buffer-window gnus-article-buffer
9922 (when (gnus-visual-p 'page-marker)
9923 (let ((inhibit-read-only t))
9924 (gnus-remove-text-with-property 'gnus-prev)
9925 (gnus-remove-text-with-property 'gnus-next))
9926 (setq gnus-page-broken nil))))
9928 (defun gnus-summary-move-article (&optional n to-newsgroup
9929 select-method action)
9930 "Move the current article to a different newsgroup.
9931 If N is a positive number, move the N next articles.
9932 If N is a negative number, move the N previous articles.
9933 If N is nil and any articles have been marked with the process mark,
9934 move those articles instead.
9935 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9936 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9937 re-spool using this method.
9939 When called interactively with TO-NEWSGROUP being nil, the value of
9940 the variable `gnus-move-split-methods' is used for finding a default
9941 for the target newsgroup.
9943 For this function to work, both the current newsgroup and the
9944 newsgroup that you want to move to have to support the `request-move'
9945 and `request-accept' functions.
9947 ACTION can be either `move' (the default), `crosspost' or `copy'."
9950 (setq action 'move))
9951 ;; Check whether the source group supports the required functions.
9952 (cond ((and (eq action 'move)
9953 (not (gnus-check-backend-function
9954 'request-move-article gnus-newsgroup-name)))
9955 (error "The current group does not support article moving"))
9956 ((and (eq action 'crosspost)
9957 (not (gnus-check-backend-function
9958 'request-replace-article gnus-newsgroup-name)))
9959 (error "The current group does not support article editing")))
9960 (let ((articles (gnus-summary-work-articles n))
9961 (prefix (if (gnus-check-backend-function
9962 'request-move-article gnus-newsgroup-name)
9963 (funcall gnus-move-group-prefix-function
9964 gnus-newsgroup-name)
9966 (names '((move "Move" "Moving")
9967 (copy "Copy" "Copying")
9968 (crosspost "Crosspost" "Crossposting")))
9969 (copy-buf (save-excursion
9970 (nnheader-set-temp-buffer " *copy article*")))
9971 art-group to-method new-xref article to-groups
9972 articles-to-update-marks encoded)
9973 (unless (assq action names)
9974 (error "Unknown action %s" action))
9975 ;; Read the newsgroup name.
9976 (when (and (not to-newsgroup)
9977 (not select-method))
9978 (if (and gnus-move-split-methods
9980 (and (memq gnus-current-article articles)
9981 (gnus-buffer-live-p gnus-original-article-buffer))))
9982 ;; When `gnus-move-split-methods' is non-nil, we have to
9983 ;; select an article to give `gnus-read-move-group-name' an
9984 ;; opportunity to suggest an appropriate default. However,
9985 ;; we needn't render or mark the article.
9986 (let ((gnus-display-mime-function nil)
9987 (gnus-article-prepare-hook nil)
9988 (gnus-mark-article-hook nil))
9989 (gnus-summary-select-article nil nil nil (car articles))))
9990 (setq to-newsgroup (gnus-read-move-group-name
9991 (cadr (assq action names))
9993 (intern (format "gnus-current-%s-group" action)))
9995 encoded to-newsgroup
9996 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9997 (set (intern (format "gnus-current-%s-group" action))
9998 (mm-decode-coding-string
10000 (gnus-group-name-charset to-method to-newsgroup))))
10002 (setq to-method (or select-method
10003 (gnus-server-to-method
10004 (gnus-group-method to-newsgroup)))))
10008 (mm-encode-coding-string
10010 (gnus-group-name-charset to-method to-newsgroup)))))
10011 ;; Check the method we are to move this article to...
10012 (unless (gnus-check-backend-function
10013 'request-accept-article (car to-method))
10014 (error "%s does not support article copying" (car to-method)))
10015 (unless (gnus-check-server to-method)
10016 (error "Can't open server %s" (car to-method)))
10017 (gnus-message 6 "%s to %s: %s..."
10018 (caddr (assq action names))
10019 (or (car select-method)
10020 (gnus-group-decoded-name to-newsgroup))
10023 (setq article (pop articles))
10024 ;; Set any marks that may have changed in the summary buffer.
10025 (when gnus-preserve-marks
10026 (gnus-summary-push-marks-to-backend article))
10030 ;; Move the article.
10032 ;; Remove this article from future suppression.
10033 (gnus-dup-unsuppress-article article)
10034 (let* ((from-method (gnus-find-method-for-group
10035 gnus-newsgroup-name))
10036 (to-method (or select-method
10037 (gnus-find-method-for-group to-newsgroup)))
10038 (move-is-internal (gnus-server-equal from-method to-method)))
10039 (gnus-request-move-article
10040 article ; Article to move
10041 gnus-newsgroup-name ; From newsgroup
10042 (nth 1 (gnus-find-method-for-group
10043 gnus-newsgroup-name)) ; Server
10044 (list 'gnus-request-accept-article
10045 to-newsgroup (list 'quote select-method)
10046 (not articles) t) ; Accept form
10047 (not articles) ; Only save nov last time
10048 (and move-is-internal
10049 to-newsgroup ; Not respooling
10050 ; Is this move internal?
10051 (gnus-group-real-name to-newsgroup)))))
10052 ;; Copy the article.
10054 (with-current-buffer copy-buf
10055 (when (gnus-request-article-this-buffer article
10056 gnus-newsgroup-name)
10058 (nnheader-narrow-to-headers)
10059 (dolist (hdr gnus-copy-article-ignored-headers)
10060 (message-remove-header hdr t)))
10061 (gnus-request-accept-article
10062 to-newsgroup select-method (not articles) t))))
10063 ;; Crosspost the article.
10064 ((eq action 'crosspost)
10065 (let ((xref (message-tokenize-header
10066 (mail-header-xref (gnus-summary-article-header
10069 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10070 ":" (number-to-string article)))
10072 (setq xref (list (system-name))))
10075 (mapconcat 'identity
10076 (delete "Xref:" (delete new-xref xref))
10079 (with-current-buffer copy-buf
10080 ;; First put the article in the destination group.
10081 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10082 (when (consp (setq art-group
10083 (gnus-request-accept-article
10084 to-newsgroup select-method (not articles)
10086 (setq new-xref (concat new-xref " " (car art-group)
10088 (number-to-string (cdr art-group))))
10089 ;; Now we have the new Xrefs header, so we insert
10090 ;; it and replace the new article.
10091 (nnheader-replace-header "Xref" new-xref)
10092 (gnus-request-replace-article
10093 (cdr art-group) to-newsgroup (current-buffer) t)
10097 (gnus-message 1 "Couldn't %s article %s: %s"
10098 (cadr (assq action names)) article
10099 (nnheader-get-report (car to-method))))
10100 ((eq art-group 'junk)
10101 (when (eq action 'move)
10102 (gnus-summary-mark-article article gnus-canceled-mark)
10103 (gnus-message 4 "Deleted article %s" article)
10104 ;; run the delete hook
10105 (run-hook-with-args 'gnus-summary-article-delete-hook
10108 (assoc article (gnus-data-list nil)))
10109 gnus-newsgroup-name nil
10112 (let* ((pto-group (gnus-group-prefixed-name
10113 (car art-group) to-method))
10114 (info (gnus-get-info pto-group))
10115 (to-group (gnus-info-group info))
10117 ;; Update the group that has been moved to.
10119 (memq action '(move copy)))
10120 (unless (member to-group to-groups)
10121 (push to-group to-groups))
10123 (when (and (not (memq article gnus-newsgroup-unreads))
10125 (push 'read to-marks)
10126 (gnus-info-set-read
10127 info (gnus-add-to-range (gnus-info-read info)
10128 (list (cdr art-group)))))
10130 ;; See whether the article is to be put in the cache.
10131 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10132 (marks (if expirable
10133 gnus-article-mark-lists
10134 (delete '(expirable . expire)
10136 gnus-article-mark-lists))))
10137 (to-article (cdr art-group)))
10139 ;; Enter the article into the cache in the new group,
10140 ;; if that is required.
10141 (when (and to-article
10143 (gnus-cache-possibly-enter-article
10144 to-group to-article
10145 (memq article gnus-newsgroup-marked)
10146 (memq article gnus-newsgroup-dormant)
10147 (memq article gnus-newsgroup-unreads)))
10149 (when (and gnus-preserve-marks
10151 ;; Copy any marks over to the new group.
10152 (when (and (equal to-group gnus-newsgroup-name)
10153 (not (memq article gnus-newsgroup-unreads)))
10154 ;; Mark this article as read in this group.
10155 (push (cons to-article gnus-read-mark)
10156 gnus-newsgroup-reads)
10157 ;; Increase the active status of this group.
10158 (setcdr (gnus-active to-group) to-article)
10159 (setcdr gnus-newsgroup-active to-article))
10162 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10163 (when (memq article (symbol-value
10164 (intern (format "gnus-newsgroup-%s"
10166 (push (cdar marks) to-marks)
10167 ;; If the other group is the same as this group,
10168 ;; then we have to add the mark to the list.
10169 (when (equal to-group gnus-newsgroup-name)
10170 (set (intern (format "gnus-newsgroup-%s"
10174 (intern (format "gnus-newsgroup-%s"
10176 ;; Copy the marks to other group.
10177 (gnus-add-marked-articles
10178 to-group (cdar marks) (list to-article) info)))
10179 (setq marks (cdr marks)))
10181 (when (and expirable
10182 gnus-mark-copied-or-moved-articles-as-expirable
10183 (not (memq 'expire to-marks)))
10184 ;; Mark this article as expirable.
10185 (push 'expire to-marks)
10186 (when (equal to-group gnus-newsgroup-name)
10187 (push to-article gnus-newsgroup-expirable))
10188 ;; Copy the expirable mark to other group.
10189 (gnus-add-marked-articles
10190 to-group 'expire (list to-article) info))
10192 (when (and to-marks
10193 (gnus-method-option-p
10194 (gnus-find-method-for-group to-group)
10196 (gnus-request-set-mark
10197 to-group (list (list (list to-article) 'add to-marks)))))
10199 (gnus-dribble-enter
10200 (concat "(gnus-group-set-info '"
10201 (gnus-prin1-to-string (gnus-get-info to-group))
10203 (concat "^(gnus-group-set-info '(\""
10204 (regexp-quote to-group) "\""))))
10206 ;; Update the Xref header in this article to point to
10207 ;; the new crossposted article we have just created.
10208 (when (eq action 'crosspost)
10209 (with-current-buffer copy-buf
10210 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10211 (nnheader-replace-header "Xref" new-xref)
10212 (gnus-request-replace-article
10213 article gnus-newsgroup-name (current-buffer) t)))
10215 ;; run the move/copy/crosspost/respool hook
10216 (run-hook-with-args 'gnus-summary-article-move-hook
10219 (assoc article (gnus-data-list nil)))
10220 gnus-newsgroup-name
10224 ;;;!!!Why is this necessary?
10225 (set-buffer gnus-summary-buffer)
10227 (when (eq action 'move)
10229 (gnus-summary-goto-subject article)
10230 (gnus-summary-mark-article article gnus-canceled-mark)))))
10231 (push article articles-to-update-marks))
10234 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10235 ;; Re-activate all groups that have been moved to.
10236 (with-current-buffer gnus-group-buffer
10237 (let ((gnus-group-marked to-groups))
10238 (gnus-group-get-new-news-this-group nil t)))
10240 (gnus-kill-buffer copy-buf)
10241 (gnus-summary-position-point)
10242 (gnus-set-mode-line 'summary)))
10244 (defun gnus-summary-push-marks-to-backend (article)
10247 (marks gnus-article-mark-lists))
10248 (unless (memq article gnus-newsgroup-unreads)
10251 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10252 (memq article (symbol-value
10253 (intern (format "gnus-newsgroup-%s"
10255 (push (cdar marks) set)
10256 (push (cdar marks) del))
10258 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10259 ((,article) del ,del)))))
10261 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10262 "Copy the current article to some other group.
10263 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10264 When called interactively, if TO-NEWSGROUP is nil, use the value of
10265 the variable `gnus-move-split-methods' for finding a default target
10267 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10268 re-spool using this method."
10270 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10272 (defun gnus-summary-crosspost-article (&optional n)
10273 "Crosspost the current article to some other group."
10275 (gnus-summary-move-article n nil nil 'crosspost))
10277 (defcustom gnus-summary-respool-default-method nil
10278 "Default method type for respooling an article.
10279 If nil, use to the current newsgroup method."
10281 :group 'gnus-summary-mail)
10283 (defun gnus-summary-respool-article (&optional n method)
10284 "Respool the current article.
10285 The article will be squeezed through the mail spooling process again,
10286 which means that it will be put in some mail newsgroup or other
10287 depending on `nnmail-split-methods'.
10288 If N is a positive number, respool the N next articles.
10289 If N is a negative number, respool the N previous articles.
10290 If N is nil and any articles have been marked with the process mark,
10291 respool those articles instead.
10293 Respooling can be done both from mail groups and \"real\" newsgroups.
10294 In the former case, the articles in question will be moved from the
10295 current group into whatever groups they are destined to. In the
10296 latter case, they will be copied into the relevant groups."
10298 (list current-prefix-arg
10299 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10301 (symbol-name (or gnus-summary-respool-default-method
10302 (car (gnus-find-method-for-group
10303 gnus-newsgroup-name)))))
10305 (gnus-completing-read
10306 "Backend to use when respooling"
10307 methods t nil 'gnus-mail-method-history methname))
10310 ((zerop (length (setq ms (gnus-servers-using-backend
10311 (intern method)))))
10312 (list (intern method) ""))
10316 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10317 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10320 (error "No method given for respooling"))
10321 (if (assoc (symbol-name
10322 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10323 (gnus-methods-using 'respool))
10324 (gnus-summary-move-article n nil method)
10325 (gnus-summary-copy-article n nil method)))
10327 (defun gnus-summary-import-article (file &optional edit)
10328 "Import an arbitrary file into a mail newsgroup."
10329 (interactive "fImport file: \nP")
10330 (let ((group gnus-newsgroup-name)
10331 (now (current-time))
10332 atts lines group-art)
10333 (unless (gnus-check-backend-function 'request-accept-article group)
10334 (error "%s does not support article importing" group))
10335 (or (file-readable-p file)
10336 (not (file-regular-p file))
10337 (error "Can't read %s" file))
10338 (with-current-buffer (gnus-get-buffer-create " *import file*")
10340 (nnheader-insert-file-contents file)
10341 (goto-char (point-min))
10342 (if (nnheader-article-p)
10344 (goto-char (point-min))
10345 (search-forward "\n\n" nil t)
10346 (narrow-to-region (point-min) (1- (point)))
10347 (goto-char (point-min))
10348 (unless (re-search-forward "^date:" nil t)
10349 (goto-char (point-max))
10350 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10351 ;; This doesn't look like an article, so we fudge some headers.
10352 (setq atts (file-attributes file)
10353 lines (count-lines (point-min) (point-max)))
10354 (insert "From: " (read-string "From: ") "\n"
10355 "Subject: " (read-string "Subject: ") "\n"
10356 "Date: " (message-make-date (nth 5 atts)) "\n"
10357 "Message-ID: " (message-make-message-id) "\n"
10358 "Lines: " (int-to-string lines) "\n"
10359 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10360 (setq group-art (gnus-request-accept-article group nil t))
10361 (kill-buffer (current-buffer)))
10362 (setq gnus-newsgroup-active (gnus-activate-group group))
10364 (gnus-summary-goto-article (cdr group-art) nil t)
10366 (gnus-summary-edit-article))))
10368 (defun gnus-summary-create-article ()
10369 "Create an article in a mail newsgroup."
10371 (let ((group gnus-newsgroup-name)
10372 (now (current-time))
10374 (unless (gnus-check-backend-function 'request-accept-article group)
10375 (error "%s does not support article importing" group))
10376 (with-current-buffer (gnus-get-buffer-create " *import file*")
10378 (goto-char (point-min))
10379 ;; This doesn't look like an article, so we fudge some headers.
10380 (insert "From: " (read-string "From: ") "\n"
10381 "Subject: " (read-string "Subject: ") "\n"
10382 "Date: " (message-make-date now) "\n"
10383 "Message-ID: " (message-make-message-id) "\n")
10384 (setq group-art (gnus-request-accept-article group nil t))
10385 (kill-buffer (current-buffer)))
10386 (setq gnus-newsgroup-active (gnus-activate-group group))
10388 (gnus-summary-goto-article (cdr group-art) nil t)
10389 (gnus-summary-edit-article)))
10391 (defun gnus-summary-article-posted-p ()
10392 "Say whether the current (mail) article is available from news as well.
10393 This will be the case if the article has both been mailed and posted."
10395 (let ((id (mail-header-references (gnus-summary-article-header)))
10396 (gnus-override-method (car (gnus-refer-article-methods))))
10397 (if (gnus-request-head id "")
10398 (gnus-message 2 "The current message was found on %s"
10399 gnus-override-method)
10400 (gnus-message 2 "The current message couldn't be found on %s"
10401 gnus-override-method)
10404 (defun gnus-summary-expire-articles (&optional now)
10405 "Expire all articles that are marked as expirable in the current group."
10407 (when (and (not gnus-group-is-exiting-without-update-p)
10408 (gnus-check-backend-function
10409 'request-expire-articles gnus-newsgroup-name))
10410 ;; This backend supports expiry.
10411 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10413 (gnus-list-range-difference
10416 ;; We need to update the info for
10417 ;; this group for `gnus-list-of-read-articles'
10418 ;; to give us the right answer.
10419 (gnus-run-hooks 'gnus-exit-group-hook)
10420 (gnus-summary-update-info)
10421 (gnus-list-of-read-articles gnus-newsgroup-name))
10422 (setq gnus-newsgroup-expirable
10423 (sort gnus-newsgroup-expirable '<)))
10424 gnus-newsgroup-unexist))
10425 (expiry-wait (if now 'immediate
10426 (gnus-group-find-parameter
10427 gnus-newsgroup-name 'expiry-wait)))
10428 (nnmail-expiry-target
10429 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10430 nnmail-expiry-target))
10433 ;; There are expirable articles in this group, so we run them
10434 ;; through the expiry process.
10435 (gnus-message 6 "Expiring articles...")
10436 (when (gnus-check-group gnus-newsgroup-name)
10437 ;; The list of articles that weren't expired is returned.
10440 (let ((nnmail-expiry-wait-function nil)
10441 (nnmail-expiry-wait expiry-wait))
10442 (setq es (gnus-request-expire-articles
10443 expirable gnus-newsgroup-name)))
10444 (setq es (gnus-request-expire-articles
10445 expirable gnus-newsgroup-name)))
10447 (setq gnus-newsgroup-expirable es))
10448 ;; We go through the old list of expirable, and mark all
10449 ;; really expired articles as nonexistent.
10450 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10451 (let ((gnus-use-cache nil))
10452 (dolist (article expirable)
10453 (when (and (not (memq article es))
10454 (gnus-data-find article))
10455 (gnus-summary-mark-article article gnus-canceled-mark)
10456 (run-hook-with-args
10457 'gnus-summary-article-expire-hook
10459 (gnus-data-header (assoc article (gnus-data-list nil)))
10460 gnus-newsgroup-name
10462 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10463 ((eq nnmail-expiry-target 'delete) nil)
10465 (let ((rescall (funcall nnmail-expiry-target
10466 gnus-newsgroup-name)))
10467 (if (stringp rescall) rescall nil))))
10469 (gnus-message 6 "Expiring articles...done")))))
10471 (defun gnus-summary-expire-articles-now ()
10472 "Expunge all expirable articles in the current group.
10473 This means that *all* articles that are marked as expirable will be
10474 deleted forever, right now."
10476 (or gnus-expert-user
10478 "Are you really, really sure you want to delete all expirable messages? ")
10480 (gnus-summary-expire-articles t))
10482 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10483 (defun gnus-summary-delete-article (&optional n)
10484 "Delete the N next (mail) articles.
10485 This command actually deletes articles. This is not a marking
10486 command. The article will disappear forever from your life, never to
10489 If N is negative, delete backwards.
10490 If N is nil and articles have been marked with the process mark,
10491 delete these instead.
10493 If `gnus-novice-user' is non-nil you will be asked for
10494 confirmation before the articles are deleted."
10496 (unless (gnus-check-backend-function 'request-expire-articles
10497 gnus-newsgroup-name)
10498 (error "The current newsgroup does not support article deletion"))
10499 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10500 (error "Couldn't open server"))
10501 ;; Compute the list of articles to delete.
10502 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10503 (nnmail-expiry-target 'delete)
10505 (if (and gnus-novice-user
10506 (not (gnus-yes-or-no-p
10507 (format "Do you really want to delete %s forever? "
10508 (if (> (length articles) 1)
10509 (format "these %s articles" (length articles))
10510 "this article")))))
10512 ;; Delete the articles.
10513 (setq not-deleted (gnus-request-expire-articles
10514 articles gnus-newsgroup-name 'force))
10517 (gnus-summary-remove-process-mark (car articles))
10518 ;; The backend might not have been able to delete the article
10520 (unless (memq (car articles) not-deleted)
10521 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10522 (let* ((article (car articles))
10523 (ghead (gnus-data-header
10524 (assoc article (gnus-data-list nil)))))
10525 (run-hook-with-args 'gnus-summary-article-delete-hook
10526 'delete ghead gnus-newsgroup-name nil
10528 (setq articles (cdr articles))))
10530 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10531 (gnus-summary-position-point)
10532 (gnus-set-mode-line 'summary)
10535 (defun gnus-summary-edit-article (&optional arg)
10536 "Edit the current article.
10537 This will have permanent effect only in mail groups.
10538 If ARG is nil, edit the decoded articles.
10539 If ARG is 1, edit the raw articles.
10540 If ARG is 2, edit the raw articles even in read-only groups.
10541 If ARG is 3, edit the articles with the current handles.
10542 Otherwise, allow editing of articles even in read-only
10545 (let (force raw current-handles)
10554 (setq current-handles
10555 (and (gnus-buffer-live-p gnus-article-buffer)
10556 (with-current-buffer gnus-article-buffer
10558 gnus-article-mime-handles
10559 (setq gnus-article-mime-handles nil))))))
10562 (when (and raw (not force)
10563 (member gnus-newsgroup-name '("nndraft:delayed"
10566 (error "Can't edit the raw article in group %s"
10567 gnus-newsgroup-name))
10568 (with-current-buffer gnus-summary-buffer
10569 (let ((mail-parse-charset gnus-newsgroup-charset)
10570 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10571 (gnus-set-global-variables)
10572 (when (and (not force)
10573 (gnus-group-read-only-p))
10574 (error "The current newsgroup does not support article editing"))
10575 (gnus-summary-show-article t)
10576 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10577 (with-current-buffer gnus-article-buffer
10578 (mm-enable-multibyte)))
10579 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10581 (gnus-article-edit-article
10584 (let ((mbl mml-buffer-list))
10585 (setq mml-buffer-list nil)
10586 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10587 (mime-to-mml ,'current-handles))
10588 (let ((mbl1 mml-buffer-list))
10589 (setq mml-buffer-list mbl)
10590 (set (make-local-variable 'mml-buffer-list) mbl1))
10591 (gnus-make-local-hook 'kill-buffer-hook)
10592 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10593 `(lambda (no-highlight)
10594 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10595 (message-options message-options)
10596 (message-options-set-recipient)
10597 (mail-parse-ignored-charsets
10598 ',gnus-newsgroup-ignored-charsets)
10599 (rfc2047-header-encoding-alist
10600 ',(let ((charset (gnus-group-name-charset
10601 (gnus-find-method-for-group
10602 gnus-newsgroup-name)
10603 gnus-newsgroup-name)))
10604 (append (list (cons "Newsgroups" charset)
10605 (cons "Followup-To" charset)
10606 (cons "Xref" charset))
10607 rfc2047-header-encoding-alist))))
10608 ,(if (not raw) '(progn
10610 (mml-destroy-buffers)
10611 (remove-hook 'kill-buffer-hook
10612 'mml-destroy-buffers t)
10613 (kill-local-variable 'mml-buffer-list)))
10614 (gnus-summary-edit-article-done
10615 ,(or (mail-header-references gnus-current-headers) "")
10616 ,(gnus-group-read-only-p)
10617 ,gnus-summary-buffer no-highlight))))))))
10619 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10621 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10623 "Make edits to the current article permanent."
10626 ;; The buffer restriction contains the entire article if it exists.
10627 (when (article-goto-body)
10628 (let ((lines (count-lines (point) (point-max)))
10629 (length (- (point-max) (point)))
10630 (case-fold-search t)
10631 (body (point-marker)))
10632 (goto-char (point-min))
10633 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10634 (delete-region (match-beginning 1) (match-end 1))
10635 (insert (number-to-string length)))
10636 (goto-char (point-min))
10637 (when (re-search-forward
10638 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10639 (delete-region (match-beginning 1) (match-end 1))
10640 (insert (number-to-string length)))
10641 (goto-char (point-min))
10642 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10643 (delete-region (match-beginning 1) (match-end 1))
10644 (insert (number-to-string lines))))))
10645 ;; Replace the article.
10646 (let ((buf (current-buffer))
10647 (article (cdr gnus-article-current))
10650 (insert-buffer-substring buf)
10651 (if (and (not read-only)
10652 (not (setq replace-result
10653 (gnus-request-replace-article
10654 article (car gnus-article-current)
10655 (current-buffer) t))))
10656 (error "Couldn't replace article")
10657 ;; If we got a number back, then that's the new article number
10658 ;; for this article. Otherwise, the article number didn't change.
10659 (when (numberp replace-result)
10660 (with-current-buffer gnus-summary-buffer
10661 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10662 (gnus-summary-limit gnus-newsgroup-limit)
10663 (setq article replace-result)
10664 (gnus-summary-goto-subject article t)))
10665 ;; Update the summary buffer.
10666 (if (and references
10667 (equal (message-tokenize-header references " ")
10668 (message-tokenize-header
10669 (or (message-fetch-field "references") "") " ")))
10670 ;; We only have to update this line.
10673 (message-narrow-to-head)
10674 (let ((head (buffer-substring-no-properties
10675 (point-min) (point-max)))
10678 (insert (format "211 %d Article retrieved.\n" article))
10681 (let ((nntp-server-buffer (current-buffer)))
10682 (setq header (car (gnus-get-newsgroup-headers nil t))))
10683 (with-current-buffer gnus-summary-buffer
10684 (gnus-data-set-header (gnus-data-find article) header)
10685 (gnus-summary-update-article-line article header)
10686 (if (gnus-summary-goto-subject article nil t)
10687 (gnus-summary-update-secondary-mark article)))))))
10689 (set-buffer (or buffer gnus-summary-buffer))
10690 (gnus-summary-update-article article)
10691 (if (gnus-summary-goto-subject article nil t)
10692 (gnus-summary-update-secondary-mark article)))
10693 ;; Prettify the article buffer again.
10694 (unless no-highlight
10695 (with-current-buffer gnus-article-buffer
10696 ;;!!! Fix this -- article should be rehighlighted.
10697 ;;(gnus-run-hooks 'gnus-article-display-hook)
10698 (set-buffer gnus-original-article-buffer)
10699 (gnus-request-article
10700 article (car gnus-article-current) (current-buffer))))
10701 ;; Prettify the summary buffer line.
10702 (when (gnus-visual-p 'summary-highlight 'highlight)
10703 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10705 (defun gnus-summary-edit-wash (key)
10706 "Perform editing command KEY in the article buffer."
10710 (message "%s" (concat (this-command-keys) "- "))
10713 (gnus-summary-edit-article)
10714 (execute-kbd-macro (concat (this-command-keys) key))
10715 (gnus-article-edit-done))
10719 (defvar nnimap-split-fancy)
10720 (defvar nnimap-split-methods)
10722 (defun gnus-summary-respool-query (&optional silent trace)
10723 "Query where the respool algorithm would put this article."
10725 (let (gnus-mark-article-hook)
10726 (gnus-summary-select-article)
10727 (with-current-buffer gnus-original-article-buffer
10729 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10731 ;; nnimap has its own splitting variables.
10732 (let ((nnmail-split-methods
10734 ((eq nnimap-split-methods 'default)
10735 nnmail-split-methods)
10736 (nnimap-split-methods
10737 nnimap-split-methods)
10738 (nnimap-split-fancy
10739 'nnmail-split-fancy)))
10740 (nnmail-split-fancy (or nnimap-split-fancy
10741 nnmail-split-fancy)))
10742 (nnmail-article-group 'identity trace))
10743 (nnmail-article-group 'identity trace))))
10746 (message "This message would go to %s"
10747 (mapconcat 'car groups ", "))
10748 (message "This message would go to no groups"))
10751 (defun gnus-summary-respool-trace ()
10752 "Trace where the respool algorithm would put this article.
10753 Display a buffer showing all fancy splitting patterns which matched."
10755 (gnus-summary-respool-query nil t))
10757 ;; Summary marking commands.
10759 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10760 "Mark articles which has the same subject as read, and then select the next.
10761 If UNMARK is positive, remove any kind of mark.
10762 If UNMARK is negative, tick articles."
10765 (setq unmark (prefix-numeric-value unmark)))
10767 (gnus-summary-mark-same-subject
10768 (gnus-summary-article-subject) unmark)))
10769 ;; Select next unread article. If auto-select-same mode, should
10770 ;; select the first unread article.
10771 (gnus-summary-next-article t (and gnus-auto-select-same
10772 (gnus-summary-article-subject)))
10773 (gnus-message 7 "%d article%s marked as %s"
10774 count (if (= count 1) " is" "s are")
10775 (if unmark "unread" "read"))))
10777 (defun gnus-summary-kill-same-subject (&optional unmark)
10778 "Mark articles which has the same subject as read.
10779 If UNMARK is positive, remove any kind of mark.
10780 If UNMARK is negative, tick articles."
10783 (setq unmark (prefix-numeric-value unmark)))
10785 (gnus-summary-mark-same-subject
10786 (gnus-summary-article-subject) unmark)))
10787 ;; If marked as read, go to next unread subject.
10788 (when (null unmark)
10789 ;; Go to next unread subject.
10790 (gnus-summary-next-subject 1 t))
10791 (gnus-message 7 "%d articles are marked as %s"
10792 count (if unmark "unread" "read"))))
10794 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10795 "Mark articles with same SUBJECT as read, and return marked number.
10796 If optional argument UNMARK is positive, remove any kinds of marks.
10797 If optional argument UNMARK is negative, mark articles as unread instead."
10801 ((null unmark) ; Mark as read.
10804 (gnus-summary-mark-article-as-read gnus-killed-mark)
10805 (gnus-summary-show-thread) t)
10806 (gnus-summary-find-subject subject))
10807 (setq count (1+ count))))
10808 ((> unmark 0) ; Tick.
10811 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10812 (gnus-summary-show-thread) t)
10813 (gnus-summary-find-subject subject))
10814 (setq count (1+ count))))
10815 (t ; Mark as unread.
10818 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10819 (gnus-summary-show-thread) t)
10820 (gnus-summary-find-subject subject))
10821 (setq count (1+ count)))))
10822 (gnus-set-mode-line 'summary)
10823 ;; Return the number of marked articles.
10826 (defun gnus-summary-mark-as-processable (n &optional unmark)
10827 "Set the process mark on the next N articles.
10828 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10829 the process mark instead. The difference between N and the actual
10830 number of articles marked is returned."
10832 (if (and (null n) (gnus-region-active-p))
10833 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10834 (setq n (prefix-numeric-value n))
10835 (let ((backward (< n 0))
10840 (gnus-summary-remove-process-mark
10841 (gnus-summary-article-number))
10842 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10843 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10846 (gnus-message 7 "No more articles"))
10847 (gnus-summary-recenter)
10848 (gnus-summary-position-point)
10851 (defun gnus-summary-unmark-as-processable (n)
10852 "Remove the process mark from the next N articles.
10853 If N is negative, unmark backward instead. The difference between N and
10854 the actual number of articles unmarked is returned."
10856 (gnus-summary-mark-as-processable n t))
10858 (defun gnus-summary-unmark-all-processable ()
10859 "Remove the process mark from all articles."
10862 (while gnus-newsgroup-processable
10863 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10864 (gnus-summary-position-point))
10866 (defun gnus-summary-add-mark (article type)
10867 "Mark ARTICLE with a mark of TYPE."
10868 (let ((vtype (car (assq type gnus-article-mark-lists)))
10871 (error "No such mark type: %s" type)
10872 (setq var (intern (format "gnus-newsgroup-%s" type)))
10873 (set var (cons article (symbol-value var)))
10874 (if (memq type '(processable cached replied forwarded recent saved))
10875 (gnus-summary-update-secondary-mark article)
10876 ;;; !!! This is bogus. We should find out what primary
10877 ;;; !!! mark we want to set.
10878 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10880 (defun gnus-summary-mark-as-expirable (n)
10881 "Mark N articles forward as expirable.
10882 If N is negative, mark backward instead. The difference between N and
10883 the actual number of articles marked is returned."
10885 (gnus-summary-mark-forward n gnus-expirable-mark))
10887 (defun gnus-summary-mark-as-spam (n)
10888 "Mark N articles forward as spam.
10889 If N is negative, mark backward instead. The difference between N and
10890 the actual number of articles marked is returned."
10892 (gnus-summary-mark-forward n gnus-spam-mark))
10894 (defun gnus-summary-mark-article-as-replied (article)
10895 "Mark ARTICLE as replied to and update the summary line.
10896 ARTICLE can also be a list of articles."
10897 (interactive (list (gnus-summary-article-number)))
10898 (let ((articles (if (listp article) article (list article))))
10899 (dolist (article articles)
10900 (unless (numberp article)
10901 (error "%s is not a number" article))
10902 (push article gnus-newsgroup-replied)
10903 (let ((inhibit-read-only t))
10904 (when (gnus-summary-goto-subject article nil t)
10905 (gnus-summary-update-secondary-mark article))))))
10907 (defun gnus-summary-mark-article-as-forwarded (article)
10908 "Mark ARTICLE as forwarded and update the summary line.
10909 ARTICLE can also be a list of articles."
10910 (let ((articles (if (listp article) article (list article))))
10911 (dolist (article articles)
10912 (push article gnus-newsgroup-forwarded)
10913 (let ((inhibit-read-only t))
10914 (when (gnus-summary-goto-subject article nil t)
10915 (gnus-summary-update-secondary-mark article))))))
10917 (defun gnus-summary-set-bookmark (article)
10918 "Set a bookmark in current article."
10919 (interactive (list (gnus-summary-article-number)))
10920 (when (or (not (get-buffer gnus-article-buffer))
10921 (not gnus-current-article)
10922 (not gnus-article-current)
10923 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10924 (error "No current article selected"))
10925 ;; Remove old bookmark, if one exists.
10926 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10927 ;; Set the new bookmark, which is on the form
10928 ;; (article-number . line-number-in-body).
10931 (with-current-buffer gnus-article-buffer
10935 (article-goto-body)
10938 gnus-newsgroup-bookmarks)
10939 (gnus-message 6 "A bookmark has been added to the current article."))
10941 (defun gnus-summary-remove-bookmark (article)
10942 "Remove the bookmark from the current article."
10943 (interactive (list (gnus-summary-article-number)))
10944 ;; Remove old bookmark, if one exists.
10945 (if (not (assq article gnus-newsgroup-bookmarks))
10946 (gnus-message 6 "No bookmark in current article.")
10947 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10948 (gnus-message 6 "Removed bookmark.")))
10950 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10951 (defun gnus-summary-mark-as-dormant (n)
10952 "Mark N articles forward as dormant.
10953 If N is negative, mark backward instead. The difference between N and
10954 the actual number of articles marked is returned."
10956 (gnus-summary-mark-forward n gnus-dormant-mark))
10958 (defun gnus-summary-set-process-mark (article)
10959 "Set the process mark on ARTICLE and update the summary line."
10960 (setq gnus-newsgroup-processable
10962 (delq article gnus-newsgroup-processable)))
10963 (when (gnus-summary-goto-subject article)
10964 (gnus-summary-show-thread)
10965 (gnus-summary-goto-subject article)
10966 (gnus-summary-update-secondary-mark article)))
10968 (defun gnus-summary-remove-process-mark (&rest articles)
10969 "Remove the process mark from ARTICLES and update the summary line."
10970 (dolist (article articles)
10971 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10972 (when (gnus-summary-goto-subject article)
10973 (gnus-summary-show-thread)
10974 (gnus-summary-goto-subject article)
10975 (gnus-summary-update-secondary-mark article)))
10978 (defun gnus-summary-set-saved-mark (article)
10979 "Set the process mark on ARTICLE and update the summary line."
10980 (push article gnus-newsgroup-saved)
10981 (when (gnus-summary-goto-subject article)
10982 (gnus-summary-update-secondary-mark article)))
10984 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10985 "Mark N articles as read forwards.
10986 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10987 The difference between N and the actual number of articles marked is
10989 If NO-EXPIRE, auto-expiry will be inhibited."
10991 (gnus-summary-show-thread)
10992 (let ((backward (< n 0))
10993 (gnus-summary-goto-unread
10994 (and gnus-summary-goto-unread
10995 (not (eq gnus-summary-goto-unread 'never))
10996 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10997 gnus-ticked-mark gnus-dormant-mark)))))
10999 (mark (or mark gnus-del-mark)))
11000 (while (and (> n 0)
11001 (gnus-summary-mark-article nil mark no-expire)
11002 (zerop (gnus-summary-next-subject
11004 (and gnus-summary-goto-unread
11005 (not (eq gnus-summary-goto-unread 'never)))
11009 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11010 (gnus-summary-recenter)
11011 (gnus-summary-position-point)
11012 (gnus-set-mode-line 'summary)
11015 (defun gnus-summary-mark-article-as-read (mark)
11016 "Mark the current article quickly as read with MARK."
11017 (let ((article (gnus-summary-article-number)))
11018 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11019 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11020 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11021 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11022 (push (cons article mark) gnus-newsgroup-reads)
11023 ;; Possibly remove from cache, if that is used.
11024 (when gnus-use-cache
11025 (gnus-cache-enter-remove-article article))
11026 ;; Allow the backend to change the mark.
11027 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11028 ;; Check for auto-expiry.
11029 (when (and gnus-newsgroup-auto-expire
11030 (memq mark gnus-auto-expirable-marks))
11031 (setq mark gnus-expirable-mark)
11032 ;; Let the backend know about the mark change.
11033 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11034 (push article gnus-newsgroup-expirable))
11035 ;; Set the mark in the buffer.
11036 (gnus-summary-update-mark mark 'unread)
11039 (defun gnus-summary-mark-article-as-unread (mark)
11040 "Mark the current article quickly as unread with MARK."
11041 (let* ((article (gnus-summary-article-number))
11042 (old-mark (gnus-summary-article-mark article)))
11043 ;; Allow the backend to change the mark.
11044 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11045 (if (eq mark old-mark)
11049 (gnus-error 1 "Can't mark negative article numbers")
11051 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11052 (setq gnus-newsgroup-spam-marked
11053 (delq article gnus-newsgroup-spam-marked))
11054 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11055 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11056 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11057 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11058 (cond ((= mark gnus-ticked-mark)
11059 (setq gnus-newsgroup-marked
11060 (gnus-add-to-sorted-list gnus-newsgroup-marked
11062 ((= mark gnus-spam-mark)
11063 (setq gnus-newsgroup-spam-marked
11064 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11066 ((= mark gnus-dormant-mark)
11067 (setq gnus-newsgroup-dormant
11068 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11071 (setq gnus-newsgroup-unreads
11072 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11074 (gnus-alist-pull article gnus-newsgroup-reads)
11076 ;; See whether the article is to be put in the cache.
11077 (and gnus-use-cache
11078 (vectorp (gnus-summary-article-header article))
11080 (gnus-cache-possibly-enter-article
11081 gnus-newsgroup-name article
11082 (= mark gnus-ticked-mark)
11083 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11086 (gnus-summary-update-mark mark 'unread)
11089 (defun gnus-summary-mark-article (&optional article mark no-expire)
11090 "Mark ARTICLE with MARK. MARK can be any character.
11091 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11092 `??' (dormant) and `?E' (expirable).
11093 If MARK is nil, then the default character `?r' is used.
11094 If ARTICLE is nil, then the article on the current line will be
11096 If NO-EXPIRE, auto-expiry will be inhibited."
11097 ;; The mark might be a string.
11098 (when (stringp mark)
11099 (setq mark (aref mark 0)))
11100 ;; If no mark is given, then we check auto-expiring.
11102 (setq mark gnus-del-mark))
11103 (when (and (not no-expire)
11104 gnus-newsgroup-auto-expire
11105 (memq mark gnus-auto-expirable-marks))
11106 (setq mark gnus-expirable-mark))
11107 (let ((article (or article (gnus-summary-article-number)))
11108 (old-mark (gnus-summary-article-mark article)))
11109 ;; Allow the backend to change the mark.
11110 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11111 (if (eq mark old-mark)
11114 (error "No article on current line"))
11115 (if (not (if (or (= mark gnus-unread-mark)
11116 (= mark gnus-ticked-mark)
11117 (= mark gnus-spam-mark)
11118 (= mark gnus-dormant-mark))
11119 (gnus-mark-article-as-unread article mark)
11120 (gnus-mark-article-as-read article mark)))
11122 ;; See whether the article is to be put in the cache.
11123 (and gnus-use-cache
11124 (not (= mark gnus-canceled-mark))
11125 (vectorp (gnus-summary-article-header article))
11127 (gnus-cache-possibly-enter-article
11128 gnus-newsgroup-name article
11129 (= mark gnus-ticked-mark)
11130 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11132 (when (gnus-summary-goto-subject article nil t)
11133 (let ((inhibit-read-only t))
11134 (gnus-summary-show-thread)
11136 (gnus-summary-update-mark mark 'unread)
11139 (defun gnus-summary-update-secondary-mark (article)
11140 "Update the secondary (read, process, cache) mark."
11141 (gnus-summary-update-mark
11142 (cond ((memq article gnus-newsgroup-processable)
11144 ((memq article gnus-newsgroup-cached)
11146 ((memq article gnus-newsgroup-replied)
11148 ((memq article gnus-newsgroup-forwarded)
11149 gnus-forwarded-mark)
11150 ((memq article gnus-newsgroup-saved)
11152 ((memq article gnus-newsgroup-unseen)
11156 (when (gnus-visual-p 'summary-highlight 'highlight)
11157 (gnus-summary-highlight-line)
11158 (gnus-run-hooks 'gnus-summary-update-hook))
11161 (defun gnus-summary-update-download-mark (article)
11162 "Update the download mark."
11163 (gnus-summary-update-mark
11164 (cond ((memq article gnus-newsgroup-undownloaded)
11165 gnus-undownloaded-mark)
11166 (gnus-newsgroup-agentized
11167 gnus-downloaded-mark)
11171 (gnus-summary-update-line t)
11174 (defun gnus-summary-update-mark (mark type)
11175 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11176 (inhibit-read-only t))
11177 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11179 (when (looking-at "\r")
11181 (when (<= (+ forward (point)) (point-max))
11182 ;; Go to the right position on the line.
11183 (goto-char (+ forward (point)))
11184 ;; Replace the old mark with the new mark.
11186 (mm-subst-char-in-string
11188 (buffer-substring (point) (1+ (point))))))
11189 (delete-region (point) (1+ (point)))
11190 (insert to-insert))
11191 ;; Optionally update the marks by some user rule.
11192 (when (eq type 'unread)
11193 (gnus-data-set-mark
11194 (gnus-data-find (gnus-summary-article-number)) mark)
11195 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11197 (defun gnus-mark-article-as-read (article &optional mark)
11198 "Enter ARTICLE in the pertinent lists and remove it from others."
11199 ;; Make the article expirable.
11200 (let ((mark (or mark gnus-del-mark)))
11201 (setq gnus-newsgroup-expirable
11202 (if (= mark gnus-expirable-mark)
11203 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11204 (delq article gnus-newsgroup-expirable)))
11205 ;; Remove from unread and marked lists.
11206 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11207 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11208 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11209 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11210 (push (cons article mark) gnus-newsgroup-reads)
11211 ;; Possibly remove from cache, if that is used.
11212 (when gnus-use-cache
11213 (gnus-cache-enter-remove-article article))
11216 (defun gnus-mark-article-as-unread (article &optional mark)
11217 "Enter ARTICLE in the pertinent lists and remove it from others."
11218 (let ((mark (or mark gnus-ticked-mark)))
11221 (gnus-error 1 "Can't mark negative article numbers")
11223 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11224 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11225 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11226 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11227 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11229 ;; Unsuppress duplicates?
11230 (when gnus-suppress-duplicates
11231 (gnus-dup-unsuppress-article article))
11233 (cond ((= mark gnus-ticked-mark)
11234 (setq gnus-newsgroup-marked
11235 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11236 ((= mark gnus-spam-mark)
11237 (setq gnus-newsgroup-spam-marked
11238 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11240 ((= mark gnus-dormant-mark)
11241 (setq gnus-newsgroup-dormant
11242 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11244 (setq gnus-newsgroup-unreads
11245 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11246 (gnus-alist-pull article gnus-newsgroup-reads)
11249 (defun gnus-summary-tick-article-forward (n)
11250 "Tick N articles forwards.
11251 If N is negative, tick backwards instead.
11252 The difference between N and the number of articles ticked is returned."
11254 (gnus-summary-mark-forward n gnus-ticked-mark))
11256 (defun gnus-summary-tick-article-backward (n)
11257 "Tick N articles backwards.
11258 The difference between N and the number of articles ticked is returned."
11260 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11262 (defun gnus-summary-tick-article (&optional article clear-mark)
11263 "Mark current article as unread.
11264 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11265 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11267 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11268 gnus-ticked-mark)))
11270 (defun gnus-summary-mark-as-read-forward (n)
11271 "Mark N articles as read forwards.
11272 If N is negative, mark backwards instead.
11273 The difference between N and the actual number of articles marked is
11276 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11278 (defun gnus-summary-mark-as-read-backward (n)
11279 "Mark the N articles as read backwards.
11280 The difference between N and the actual number of articles marked is
11283 (gnus-summary-mark-forward
11284 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11286 (defun gnus-summary-mark-as-read (&optional article mark)
11287 "Mark current article as read.
11288 ARTICLE specifies the article to be marked as read.
11289 MARK specifies a string to be inserted at the beginning of the line."
11290 (gnus-summary-mark-article article mark))
11292 (defun gnus-summary-clear-mark-forward (n)
11293 "Clear marks from N articles forward.
11294 If N is negative, clear backward instead.
11295 The difference between N and the number of marks cleared is returned."
11297 (gnus-summary-mark-forward n gnus-unread-mark))
11299 (defun gnus-summary-clear-mark-backward (n)
11300 "Clear marks from N articles backward.
11301 The difference between N and the number of marks cleared is returned."
11303 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11305 (defun gnus-summary-mark-unread-as-read ()
11306 "Intended to be used by `gnus-mark-article-hook'."
11307 (when (memq gnus-current-article gnus-newsgroup-unreads)
11308 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11310 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11311 "Intended to be used by `gnus-mark-article-hook'."
11312 (let ((mark (gnus-summary-article-mark)))
11313 (when (or (gnus-unread-mark-p mark)
11314 (gnus-read-mark-p mark))
11315 (gnus-summary-mark-article gnus-current-article
11316 (or new-mark gnus-read-mark)))))
11318 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11319 "Intended to be used by `gnus-mark-article-hook'."
11320 (let ((mark (gnus-summary-article-mark)))
11321 (when (or (gnus-unread-mark-p mark)
11322 (gnus-read-mark-p mark))
11323 (gnus-summary-mark-article (gnus-summary-article-number)
11324 (or new-mark gnus-read-mark)))))
11326 (defun gnus-summary-mark-unread-as-ticked ()
11327 "Intended to be used by `gnus-mark-article-hook'."
11328 (when (memq gnus-current-article gnus-newsgroup-unreads)
11329 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11331 (defun gnus-summary-mark-region-as-read (point mark all)
11332 "Mark all unread articles between point and mark as read.
11333 If given a prefix, mark all articles between point and mark as read,
11334 even ticked and dormant ones."
11335 (interactive "r\nP")
11339 (beginning-of-line)
11344 (memq (setq article (gnus-summary-article-number))
11345 gnus-newsgroup-unreads))
11346 (gnus-summary-mark-article article gnus-del-mark))
11348 (gnus-summary-find-next))))))
11350 (defun gnus-summary-mark-below (score mark)
11351 "Mark articles with score less than SCORE with MARK."
11352 (interactive "P\ncMark: ")
11353 (setq score (if score
11354 (prefix-numeric-value score)
11355 (or gnus-summary-default-score 0)))
11356 (with-current-buffer gnus-summary-buffer
11357 (goto-char (point-min))
11360 (and (< (gnus-summary-article-score) score)
11361 (gnus-summary-mark-article nil mark))
11362 (gnus-summary-find-next)))))
11364 (defun gnus-summary-kill-below (&optional score)
11365 "Mark articles with score below SCORE as read."
11367 (gnus-summary-mark-below score gnus-killed-mark))
11369 (defun gnus-summary-clear-above (&optional score)
11370 "Clear all marks from articles with score above SCORE."
11372 (gnus-summary-mark-above score gnus-unread-mark))
11374 (defun gnus-summary-tick-above (&optional score)
11375 "Tick all articles with score above SCORE."
11377 (gnus-summary-mark-above score gnus-ticked-mark))
11379 (defun gnus-summary-mark-above (score mark)
11380 "Mark articles with score over SCORE with MARK."
11381 (interactive "P\ncMark: ")
11382 (setq score (if score
11383 (prefix-numeric-value score)
11384 (or gnus-summary-default-score 0)))
11385 (with-current-buffer gnus-summary-buffer
11386 (goto-char (point-min))
11388 (when (> (gnus-summary-article-score) score)
11389 (gnus-summary-mark-article nil mark))
11391 (gnus-summary-find-next)))))
11393 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11394 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11395 (defun gnus-summary-limit-include-expunged (&optional no-error)
11396 "Display all the hidden articles that were expunged for low scores."
11398 (let ((inhibit-read-only t))
11399 (let ((scored gnus-newsgroup-scored)
11402 (unless (gnus-summary-article-header (caar scored))
11403 (and (setq h (gnus-number-to-header (caar scored)))
11404 (< (cdar scored) gnus-summary-expunge-below)
11406 (setq scored (cdr scored)))
11408 (when (not no-error)
11409 (error "No expunged articles hidden"))
11410 (goto-char (point-min))
11411 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11412 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11413 (dolist (x headers)
11414 (push (mail-header-number x) gnus-newsgroup-limit))
11415 (gnus-summary-prepare-unthreaded (nreverse headers))
11416 (goto-char (point-min))
11417 (gnus-summary-position-point)
11420 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11421 "Mark all unread articles in this newsgroup as read.
11422 If prefix argument ALL is non-nil, ticked and dormant articles will
11423 also be marked as read.
11424 If QUIETLY is non-nil, no questions will be asked.
11426 If TO-HERE is non-nil, it should be a point in the buffer. All
11427 articles before (after, if REVERSE is set) this point will be marked
11430 Note that this function will only catch up the unread article
11431 in the current summary buffer limitation.
11433 The number of articles marked as read is returned."
11438 (not gnus-interactive-catchup) ;Without confirmation?
11442 "Mark absolutely all articles as read? "
11443 "Mark all unread articles as read? ")))
11445 (not gnus-newsgroup-adaptive)
11446 (not gnus-newsgroup-auto-expire)
11447 (not gnus-suppress-duplicates)
11448 (or (not gnus-use-cache)
11449 (eq gnus-use-cache 'passive)))
11452 (setq gnus-newsgroup-marked nil
11453 gnus-newsgroup-spam-marked nil
11454 gnus-newsgroup-dormant nil))
11455 (setq gnus-newsgroup-unreads
11456 (gnus-sorted-nunion
11457 (gnus-sorted-intersection gnus-newsgroup-unreads
11458 gnus-newsgroup-downloadable)
11459 (gnus-sorted-difference gnus-newsgroup-unfetched
11460 gnus-newsgroup-cached))))
11461 ;; We actually mark all articles as canceled, which we
11462 ;; have to do when using auto-expiry or adaptive scoring.
11463 (gnus-summary-show-all-threads)
11464 (if (and to-here reverse)
11466 (goto-char to-here)
11467 (gnus-summary-mark-current-read-and-unread-as-read
11469 (while (gnus-summary-find-next (not all))
11470 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11471 (when (gnus-summary-first-subject (not all))
11473 (if to-here (< (point) to-here) t)
11474 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11475 (gnus-summary-find-next (not all))))))
11476 (gnus-set-mode-line 'summary))
11478 (gnus-summary-position-point)))
11480 (defun gnus-summary-catchup-to-here (&optional all)
11481 "Mark all unticked articles before the current one as read.
11482 If ALL is non-nil, also mark ticked and dormant articles as read."
11485 (gnus-save-hidden-threads
11486 (let ((beg (point)))
11487 ;; We check that there are unread articles.
11488 (when (or all (gnus-summary-find-prev))
11489 (gnus-summary-catchup all t beg)))))
11490 (gnus-summary-position-point))
11492 (defun gnus-summary-catchup-from-here (&optional all)
11493 "Mark all unticked articles after (and including) the current one as read.
11494 If ALL is non-nil, also mark ticked and dormant articles as read."
11497 (gnus-save-hidden-threads
11498 (let ((beg (point)))
11499 ;; We check that there are unread articles.
11500 (when (or all (gnus-summary-find-next))
11501 (gnus-summary-catchup all t beg nil t)))))
11502 (gnus-summary-position-point))
11504 (defun gnus-summary-catchup-all (&optional quietly)
11505 "Mark all articles in this newsgroup as read.
11506 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11507 instead, which marks only unread articles as read."
11509 (gnus-summary-catchup t quietly))
11511 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11512 "Mark all unread articles in this group as read, then exit.
11513 If prefix argument ALL is non-nil, all articles are marked as read.
11514 If QUIETLY is non-nil, no questions will be asked."
11516 (when (gnus-summary-catchup all quietly nil 'fast)
11517 ;; Select next newsgroup or exit.
11518 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11519 (eq gnus-auto-select-next 'quietly))
11520 (gnus-summary-next-group nil)
11521 (gnus-summary-exit))))
11523 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11524 "Mark all articles in this newsgroup as read, and then exit.
11525 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11526 instead, which marks only unread articles as read."
11528 (gnus-summary-catchup-and-exit t quietly))
11530 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11531 "Mark all articles in this group as read and select the next group.
11532 If given a prefix, mark all articles, unread as well as ticked, as
11536 (gnus-summary-catchup all))
11537 (gnus-summary-next-group))
11539 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11540 "Mark all articles in this group as read and select the previous group.
11541 If given a prefix, mark all articles, unread as well as ticked, as
11545 (gnus-summary-catchup all))
11546 (gnus-summary-next-group nil nil t))
11552 (defmacro gnus-with-article (article &rest forms)
11553 "Select ARTICLE and perform FORMS in the original article buffer.
11554 Then replace the article with the result."
11556 ;; We don't want the article to be marked as read.
11557 (let (gnus-mark-article-hook)
11558 (gnus-summary-select-article t t nil ,article))
11559 (set-buffer gnus-original-article-buffer)
11561 (if (not (gnus-check-backend-function
11562 'request-replace-article (car gnus-article-current)))
11563 (gnus-message 5 "Read-only group; not replacing")
11564 (unless (gnus-request-replace-article
11565 ,article (car gnus-article-current)
11566 (current-buffer) t)
11567 (error "Couldn't replace article")))
11568 ;; The cache and backlog have to be flushed somewhat.
11569 (when gnus-keep-backlog
11570 (gnus-backlog-remove-article
11571 (car gnus-article-current) (cdr gnus-article-current)))
11572 (when gnus-use-cache
11573 (gnus-cache-update-article
11574 (car gnus-article-current) (cdr gnus-article-current)))))
11576 (put 'gnus-with-article 'lisp-indent-function 1)
11577 (put 'gnus-with-article 'edebug-form-spec '(form body))
11579 ;; Thread-based commands.
11581 (defun gnus-summary-articles-in-thread (&optional article)
11582 "Return a list of all articles in the current thread.
11583 If ARTICLE is non-nil, return all articles in the thread that starts
11584 with that article."
11585 (let* ((article (or article (gnus-summary-article-number)))
11586 (data (gnus-data-find-list article))
11587 (top-level (gnus-data-level (car data)))
11589 (cond ((null gnus-thread-operation-ignore-subject)
11590 (gnus-simplify-subject-re
11591 (mail-header-subject (gnus-data-header (car data)))))
11592 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11593 (gnus-simplify-subject-fuzzy
11594 (mail-header-subject (gnus-data-header (car data)))))
11596 (end-point (save-excursion
11597 (goto-char (gnus-data-pos (car data)))
11598 (if (gnus-summary-go-to-next-thread)
11599 (point) (point-max))))
11602 (< (gnus-data-pos (car data)) end-point))
11603 (when (or (not top-subject)
11604 (string= top-subject
11605 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11606 (gnus-simplify-subject-fuzzy
11607 (mail-header-subject
11608 (gnus-data-header (car data))))
11609 (gnus-simplify-subject-re
11610 (mail-header-subject
11611 (gnus-data-header (car data)))))))
11612 (push (gnus-data-number (car data)) articles))
11613 (unless (and (setq data (cdr data))
11614 (> (gnus-data-level (car data)) top-level))
11616 ;; Return the list of articles.
11617 (nreverse articles)))
11619 (defun gnus-summary-rethread-current ()
11620 "Rethread the thread the current article is part of."
11622 (let* ((gnus-show-threads t)
11623 (article (gnus-summary-article-number))
11624 (id (mail-header-id (gnus-summary-article-header)))
11625 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11627 (error "No article on the current line"))
11628 (gnus-rebuild-thread id)
11629 (gnus-summary-goto-subject article)))
11631 (defun gnus-summary-reparent-thread ()
11632 "Make the current article child of the marked (or previous) article.
11634 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11635 is non-nil or the Subject: of both articles are the same."
11637 (unless (not (gnus-group-read-only-p))
11638 (error "The current newsgroup does not support article editing"))
11639 (unless (<= (length gnus-newsgroup-processable) 1)
11640 (error "No more than one article may be marked"))
11641 (let ((child (gnus-summary-article-number))
11642 ;; First grab the marked article, otherwise one line up.
11643 (parent (if (not (null gnus-newsgroup-processable))
11644 (car gnus-newsgroup-processable)
11646 (if (eq (forward-line -1) 0)
11647 (gnus-summary-article-number)
11648 (error "Beginning of summary buffer"))))))
11649 (gnus-summary-reparent-children parent (list child))))
11651 (defun gnus-summary-reparent-children (parent children)
11652 "Make PARENT the parent of CHILDREN.
11653 When called interactively, PARENT is the current article and CHILDREN
11654 are the process-marked articles."
11656 (list (gnus-summary-article-number)
11657 (gnus-summary-work-articles nil)))
11658 (dolist (child children)
11659 (save-window-excursion
11660 (let ((gnus-article-buffer " *reparent*"))
11661 (unless (not (eq parent child))
11662 (error "An article may not be self-referential"))
11663 (let ((message-id (mail-header-id
11664 (gnus-summary-article-header parent))))
11665 (unless (and message-id (not (equal message-id "")))
11666 (error "No message-id in desired parent"))
11667 (gnus-with-article child
11669 (goto-char (point-min))
11670 (message-narrow-to-head)
11671 (if (re-search-forward "^References: " nil t)
11673 (re-search-forward "^[^ \t]" nil t)
11676 (insert " " message-id))
11677 (insert "References: " message-id "\n"))))
11678 (set-buffer gnus-summary-buffer)
11679 (gnus-summary-unmark-all-processable)
11680 (gnus-summary-update-article child)
11681 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11682 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11683 (gnus-summary-rethread-current)
11684 (gnus-message 3 "Article %d is now the child of article %d"
11687 (defun gnus-summary-toggle-threads (&optional arg)
11688 "Toggle showing conversation threads.
11689 If ARG is positive number, turn showing conversation threads on."
11691 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11692 (setq gnus-show-threads
11693 (if (null arg) (not gnus-show-threads)
11694 (> (prefix-numeric-value arg) 0)))
11695 (gnus-summary-prepare)
11696 (gnus-summary-goto-subject current)
11697 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11698 (gnus-summary-position-point)))
11700 (defun gnus-summary-show-all-threads ()
11701 "Show all threads."
11703 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11704 (gnus-summary-position-point))
11706 (defsubst gnus-summary--inv (p)
11707 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11709 (defun gnus-summary-show-thread ()
11710 "Show thread subtrees.
11711 Returns nil if no thread was there to be shown."
11713 (let* ((orig (point))
11714 (end (point-at-eol))
11715 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11716 ;; Leave point at bol
11717 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11719 (if (fboundp 'next-single-char-property-change)
11720 ;; Note: XEmacs version of n-s-c-p-c may return nil
11721 (or (next-single-char-property-change end 'invisible)
11726 (eq (get-char-property (point) 'invisible)
11730 (remove-overlays beg eoi 'invisible 'gnus-sum)
11732 (gnus-summary-position-point)
11735 (defun gnus-summary-maybe-hide-threads ()
11736 "If requested, hide the threads that should be hidden."
11737 (when (and gnus-show-threads
11738 gnus-thread-hide-subtree)
11739 (gnus-summary-hide-all-threads
11740 (if (or (consp gnus-thread-hide-subtree)
11741 (functionp gnus-thread-hide-subtree))
11742 (gnus-make-predicate gnus-thread-hide-subtree)
11745 ;;; Hiding predicates.
11747 (defun gnus-article-unread-p (header)
11748 (memq (mail-header-number header) gnus-newsgroup-unreads))
11750 (defun gnus-article-unseen-p (header)
11751 (memq (mail-header-number header) gnus-newsgroup-unseen))
11753 (defun gnus-map-articles (predicate articles)
11754 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11755 (apply 'gnus-or (mapcar predicate
11756 (mapcar (lambda (number)
11757 (gnus-summary-article-header number))
11760 (defun gnus-summary-hide-all-threads (&optional predicate)
11761 "Hide all thread subtrees.
11762 If PREDICATE is supplied, threads that satisfy this predicate
11763 will not be hidden."
11766 (goto-char (point-min))
11771 (when (zerop (mod count 1000))
11772 (message "Hiding all threads... %d" count))
11773 (when (or (not predicate)
11775 predicate (gnus-summary-article-children)))
11776 (gnus-summary-hide-thread))
11777 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11778 (gnus-summary-position-point))
11780 (defun gnus-summary-hide-thread ()
11781 "Hide thread subtrees.
11782 If PREDICATE is supplied, threads that satisfy this predicate
11783 will not be hidden.
11784 Returns nil if no threads were there to be hidden."
11786 (beginning-of-line)
11787 (let ((start (point))
11788 (starteol (line-end-position))
11789 (article (gnus-summary-article-number)))
11790 ;; Go forward until either the buffer ends or the subthread ends.
11791 (when (and (not (eobp))
11792 (or (zerop (gnus-summary-next-thread 1 t))
11793 (goto-char (point-max))))
11794 (if (and (> (point) start)
11795 ;; FIXME: this should actually search for a non-invisible \n.
11796 (search-backward "\n" start t))
11798 (when (> (point) starteol)
11799 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11800 (let ((ol (make-overlay starteol (point) nil t nil)))
11801 (overlay-put ol 'invisible 'gnus-sum)
11802 (overlay-put ol 'evaporate t)))
11803 (gnus-summary-goto-subject article)
11804 (when (> start (point))
11805 (message "Hiding the thread moved us backwards, aborting!")
11806 (goto-char (point-max))))
11810 (defun gnus-summary-go-to-next-thread (&optional previous)
11811 "Go to the same level (or less) next thread.
11812 If PREVIOUS is non-nil, go to previous thread instead.
11813 Return the article number moved to, or nil if moving was impossible."
11814 (let ((level (gnus-summary-thread-level))
11815 (way (if previous -1 1))
11818 (while (and (not (eobp))
11819 (< level (gnus-summary-thread-level)))
11820 (forward-line way))
11827 (gnus-summary-article-number)
11828 (goto-char beg)))))
11830 (defun gnus-summary-next-thread (n &optional silent)
11831 "Go to the same level next N'th thread.
11832 If N is negative, search backward instead.
11833 Returns the difference between N and the number of skips actually
11836 If SILENT, don't output messages."
11838 (let ((backward (< n 0))
11840 (while (and (> n 0)
11841 (gnus-summary-go-to-next-thread backward))
11844 (gnus-summary-position-point))
11845 (when (and (not silent) (/= 0 n))
11846 (gnus-message 7 "No more threads"))
11849 (defun gnus-summary-prev-thread (n)
11850 "Go to the same level previous N'th thread.
11851 Returns the difference between N and the number of skips actually
11854 (gnus-summary-next-thread (- n)))
11856 (defun gnus-summary-go-down-thread ()
11857 "Go down one level in the current thread."
11858 (let ((children (gnus-summary-article-children)))
11860 (gnus-summary-goto-subject (car children)))))
11862 (defun gnus-summary-go-up-thread ()
11863 "Go up one level in the current thread."
11864 (let ((parent (gnus-summary-article-parent)))
11866 (gnus-summary-goto-subject parent))))
11868 (defun gnus-summary-down-thread (n)
11869 "Go down thread N steps.
11870 If N is negative, go up instead.
11871 Returns the difference between N and how many steps down that were
11876 (while (and (> n 0)
11877 (if up (gnus-summary-go-up-thread)
11878 (gnus-summary-go-down-thread)))
11880 (gnus-summary-position-point)
11882 (gnus-message 7 "Can't go further"))
11885 (defun gnus-summary-up-thread (n)
11886 "Go up thread N steps.
11887 If N is negative, go down instead.
11888 Returns the difference between N and how many steps down that were
11891 (gnus-summary-down-thread (- n)))
11893 (defun gnus-summary-top-thread ()
11894 "Go to the top of the thread."
11896 (while (gnus-summary-go-up-thread))
11897 (gnus-summary-article-number))
11899 (defun gnus-summary-expire-thread ()
11900 "Mark articles under current thread as expired."
11902 (gnus-summary-kill-thread 0))
11904 (defun gnus-summary-kill-thread (&optional unmark)
11905 "Mark articles under current thread as read.
11906 If the prefix argument is positive, remove any kinds of marks.
11907 If the prefix argument is zero, mark thread as expired.
11908 If the prefix argument is negative, tick articles instead."
11911 (setq unmark (prefix-numeric-value unmark)))
11912 (let ((articles (gnus-summary-articles-in-thread))
11913 (hide (or (null unmark) (= unmark 0))))
11915 ;; Expand the thread.
11916 (gnus-summary-show-thread)
11917 ;; Mark all the articles.
11919 (gnus-summary-goto-subject (car articles))
11920 (cond ((null unmark)
11921 (gnus-summary-mark-article-as-read gnus-killed-mark))
11923 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11925 (gnus-summary-mark-article nil gnus-expirable-mark))
11927 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11928 (setq articles (cdr articles))))
11929 ;; Hide killed subtrees when hide is true.
11931 gnus-thread-hide-killed
11932 (gnus-summary-hide-thread))
11933 ;; If hide is t, go to next unread subject.
11935 ;; Go to next unread subject.
11936 (gnus-summary-next-subject 1 t)))
11937 (gnus-set-mode-line 'summary))
11939 ;; Summary sorting commands
11941 (defun gnus-summary-sort-by-number (&optional reverse)
11942 "Sort the summary buffer by article number.
11943 Argument REVERSE means reverse order."
11945 (gnus-summary-sort 'number reverse))
11947 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11948 "Sort the summary buffer by most recent article number.
11949 Argument REVERSE means reverse order."
11951 (gnus-summary-sort 'most-recent-number reverse))
11953 (defun gnus-summary-sort-by-random (&optional reverse)
11954 "Randomize the order in the summary buffer.
11955 Argument REVERSE means to randomize in reverse order."
11957 (gnus-summary-sort 'random reverse))
11959 (defun gnus-summary-sort-by-author (&optional reverse)
11960 "Sort the summary buffer by author name alphabetically.
11961 If `case-fold-search' is non-nil, case of letters is ignored.
11962 Argument REVERSE means reverse order."
11964 (gnus-summary-sort 'author reverse))
11966 (defun gnus-summary-sort-by-recipient (&optional reverse)
11967 "Sort the summary buffer by recipient name alphabetically.
11968 If `case-fold-search' is non-nil, case of letters is ignored.
11969 Argument REVERSE means reverse order."
11971 (gnus-summary-sort 'recipient reverse))
11973 (defun gnus-summary-sort-by-subject (&optional reverse)
11974 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11975 If `case-fold-search' is non-nil, case of letters is ignored.
11976 Argument REVERSE means reverse order."
11978 (gnus-summary-sort 'subject reverse))
11980 (defun gnus-summary-sort-by-date (&optional reverse)
11981 "Sort the summary buffer by date.
11982 Argument REVERSE means reverse order."
11984 (gnus-summary-sort 'date reverse))
11986 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11987 "Sort the summary buffer by most recent date.
11988 Argument REVERSE means reverse order."
11990 (gnus-summary-sort 'most-recent-date reverse))
11992 (defun gnus-summary-sort-by-score (&optional reverse)
11993 "Sort the summary buffer by score.
11994 Argument REVERSE means reverse order."
11996 (gnus-summary-sort 'score reverse))
11998 (defun gnus-summary-sort-by-lines (&optional reverse)
11999 "Sort the summary buffer by the number of lines.
12000 Argument REVERSE means reverse order."
12002 (gnus-summary-sort 'lines reverse))
12004 (defun gnus-summary-sort-by-chars (&optional reverse)
12005 "Sort the summary buffer by article length.
12006 Argument REVERSE means reverse order."
12008 (gnus-summary-sort 'chars reverse))
12010 (defun gnus-summary-sort-by-original (&optional reverse)
12011 "Sort the summary buffer using the default sorting method.
12012 Argument REVERSE means reverse order."
12014 (let* ((inhibit-read-only t)
12015 (gnus-summary-prepare-hook nil))
12016 ;; We do the sorting by regenerating the threads.
12017 (gnus-summary-prepare)
12018 ;; Hide subthreads if needed.
12019 (gnus-summary-maybe-hide-threads)))
12021 (defun gnus-summary-sort (predicate reverse)
12022 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12023 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12024 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12025 (gnus-thread-sort-functions
12030 (gnus-sort-gathered-threads-function
12031 gnus-thread-sort-functions)
12032 (gnus-article-sort-functions
12036 (,article t2 t1))))
12037 (inhibit-read-only t)
12038 (gnus-summary-prepare-hook nil))
12039 ;; We do the sorting by regenerating the threads.
12040 (gnus-summary-prepare)
12041 ;; Hide subthreads if needed.
12042 (gnus-summary-maybe-hide-threads)))
12044 ;; Summary saving commands.
12046 (defun gnus-summary-save-article (&optional n not-saved)
12047 "Save the current article using the default saver function.
12048 If N is a positive number, save the N next articles.
12049 If N is a negative number, save the N previous articles.
12050 If N is nil and any articles have been marked with the process mark,
12051 save those articles instead.
12052 The variable `gnus-default-article-saver' specifies the saver function.
12054 If the optional second argument NOT-SAVED is non-nil, articles saved
12055 will not be marked as saved."
12057 (require 'gnus-art)
12058 (let* ((articles (gnus-summary-work-articles n))
12059 (save-buffer (save-excursion
12060 (nnheader-set-temp-buffer " *Gnus Save*")))
12061 (num (length articles))
12062 ;; Whether to save decoded articles or raw articles.
12063 (decode (when gnus-article-save-coding-system
12064 (get gnus-default-article-saver :decode)))
12065 ;; When saving many articles in a single file, use the other
12066 ;; function to save articles other than the first one.
12067 (saver2 (get gnus-default-article-saver :function))
12068 (gnus-prompt-before-saving (if saver2
12070 gnus-prompt-before-saving))
12071 (gnus-default-article-saver gnus-default-article-saver)
12073 (dolist (article articles)
12074 (setq header (gnus-summary-article-header article))
12075 (if (not (vectorp header))
12076 ;; This is a pseudo-article.
12077 (if (assq 'name header)
12078 (gnus-copy-file (cdr (assq 'name header)))
12079 (gnus-message 1 "Article %d is unsavable" article))
12080 ;; This is a real article.
12081 (save-window-excursion
12082 (gnus-summary-select-article decode decode nil article)
12083 (gnus-summary-goto-subject article))
12084 (with-current-buffer save-buffer
12086 (insert-buffer-substring (if decode
12087 gnus-article-buffer
12088 gnus-original-article-buffer)))
12089 (setq file (gnus-article-save save-buffer file num))
12090 (gnus-summary-remove-process-mark article)
12092 (gnus-summary-set-saved-mark article)))
12094 (setq gnus-default-article-saver saver2
12096 (gnus-kill-buffer save-buffer)
12097 (gnus-summary-position-point)
12098 (gnus-set-mode-line 'summary)
12101 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12103 (defun gnus-summary-pipe-output (&optional n sym)
12104 "Pipe the current article to a subprocess.
12105 If N is a positive number, pipe the N next articles.
12106 If N is a negative number, pipe the N previous articles.
12107 If N is nil and any articles have been marked with the process mark,
12108 pipe those articles instead.
12109 The default command to which articles are piped is specified by the
12110 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12111 will be prompted for the command.
12113 The properties `:decode' and `:headers' that are put to the function
12114 symbol `gnus-summary-save-in-pipe' control whether this function
12115 decodes articles and what headers to keep (see the doc string for the
12116 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12117 is neither omitted nor the symbol `r', force including all headers
12118 regardless of the `:headers' property. If it is the symbol `r',
12119 articles that are not decoded and include all headers will be piped
12120 no matter what the properties `:decode' and `:headers' are."
12121 (interactive (gnus-interactive "P\ny"))
12122 (require 'gnus-art)
12123 (let* ((articles (gnus-summary-work-articles n))
12124 (result-buffer "*Shell Command Output*")
12125 (all-headers (not (memq sym '(nil r))))
12126 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12128 (headers (get 'gnus-summary-save-in-pipe :headers))
12130 (unless (numberp (car articles))
12131 (error "No article to pipe"))
12132 (setq command (gnus-read-shell-command
12133 (concat "Shell command on "
12135 (format "these %d articles" (length articles))
12138 gnus-summary-pipe-output-default-command))
12139 (when (string-equal command "")
12140 (error "A command is required"))
12142 (put 'gnus-summary-save-in-pipe :headers nil))
12145 (gnus-summary-goto-subject (pop articles))
12146 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12147 (when (and (get-buffer result-buffer)
12148 (not (zerop (buffer-size (get-buffer result-buffer)))))
12149 (setq result (concat result (with-current-buffer result-buffer
12150 (buffer-string))))))
12151 (put 'gnus-summary-save-in-pipe :headers headers))
12152 (unless (zerop (length result))
12153 (if (with-current-buffer (get-buffer-create result-buffer)
12157 (and (= (count-lines (point-min) (point)) 1)
12160 (<= (current-column)
12161 (window-width (minibuffer-window)))))
12162 (goto-char (point-min))))
12163 (message "%s" (substring result 0 -1))
12165 (gnus-configure-windows 'pipe)))))
12167 (defun gnus-summary-save-article-mail (&optional arg)
12168 "Append the current article to a Unix mail box file.
12169 If N is a positive number, save the N next articles.
12170 If N is a negative number, save the N previous articles.
12171 If N is nil and any articles have been marked with the process mark,
12172 save those articles instead."
12174 (require 'gnus-art)
12175 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12176 (gnus-summary-save-article arg)))
12178 (defun gnus-summary-save-article-rmail (&optional arg)
12179 "Append the current article to an rmail file.
12180 If N is a positive number, save the N next articles.
12181 If N is a negative number, save the N previous articles.
12182 If N is nil and any articles have been marked with the process mark,
12183 save those articles instead."
12185 (require 'gnus-art)
12186 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12187 (gnus-summary-save-article arg)))
12189 (defun gnus-summary-save-article-file (&optional arg)
12190 "Append the current article to a file.
12191 If N is a positive number, save the N next articles.
12192 If N is a negative number, save the N previous articles.
12193 If N is nil and any articles have been marked with the process mark,
12194 save those articles instead."
12196 (require 'gnus-art)
12197 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12198 (gnus-summary-save-article arg)))
12200 (defun gnus-summary-write-article-file (&optional arg)
12201 "Write the current article to a file, deleting the previous file.
12202 If N is a positive number, save the N next articles.
12203 If N is a negative number, save the N previous articles.
12204 If N is nil and any articles have been marked with the process mark,
12205 save those articles instead."
12207 (require 'gnus-art)
12208 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12209 (gnus-summary-save-article arg)))
12211 (defun gnus-summary-save-article-body-file (&optional arg)
12212 "Append the current article body to a file.
12213 If N is a positive number, save the N next articles.
12214 If N is a negative number, save the N previous articles.
12215 If N is nil and any articles have been marked with the process mark,
12216 save those articles instead."
12218 (require 'gnus-art)
12219 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12220 (gnus-summary-save-article arg)))
12222 (defun gnus-summary-write-article-body-file (&optional arg)
12223 "Write the current article body to a file, deleting the previous file.
12224 If N is a positive number, save the N next articles.
12225 If N is a negative number, save the N previous articles.
12226 If N is nil and any articles have been marked with the process mark,
12227 save those articles instead."
12229 (require 'gnus-art)
12230 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12231 (gnus-summary-save-article arg)))
12233 (defun gnus-summary-muttprint (&optional arg)
12234 "Print the current article using Muttprint.
12235 If N is a positive number, save the N next articles.
12236 If N is a negative number, save the N previous articles.
12237 If N is nil and any articles have been marked with the process mark,
12238 save those articles instead."
12240 (require 'gnus-art)
12241 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12242 (gnus-summary-save-article arg t)))
12244 (defun gnus-summary-pipe-message (program)
12245 "Pipe the current article through PROGRAM."
12246 (interactive "sProgram: ")
12247 (gnus-summary-select-article)
12248 (let ((mail-header-separator ""))
12249 (gnus-eval-in-buffer-window gnus-article-buffer
12252 (let ((start (window-start))
12253 (inhibit-read-only t))
12254 (message-pipe-buffer-body program)
12255 (set-window-start (get-buffer-window (current-buffer)) start))))))
12257 (defun gnus-get-split-value (methods)
12258 "Return a value based on the split METHODS."
12259 (let (split-name method result match)
12261 (with-current-buffer gnus-original-article-buffer
12263 (nnheader-narrow-to-headers)
12264 (while (and methods (not split-name))
12265 (goto-char (point-min))
12266 (setq method (pop methods))
12267 (setq match (car method))
12270 ;; Regular expression.
12272 (re-search-forward match nil t)))
12277 (setq result (funcall match gnus-newsgroup-name))))
12282 (setq result (eval match)))))
12283 (setq split-name (cdr method))
12284 (cond ((stringp result)
12285 (push (expand-file-name
12286 result gnus-article-save-directory)
12289 (setq split-name (append result split-name)))))))))
12290 (nreverse split-name)))
12292 (defun gnus-valid-move-group-p (group)
12293 (and (symbolp group)
12295 (symbol-name group)
12296 (symbol-value group)
12297 (gnus-get-function (gnus-find-method-for-group
12298 (symbol-name group)) 'request-accept-article t)))
12300 (defun gnus-read-move-group-name (prompt default articles prefix)
12301 "Read a group name."
12302 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12303 (minibuffer-confirm-incomplete nil) ; XEmacs
12307 (if (> (length articles) 1)
12308 (format "these %d articles" (length articles))
12313 (gnus-group-completing-read
12315 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12316 nil prefix nil default))
12317 ((= 1 (length split-name))
12318 (gnus-group-completing-read
12320 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12321 nil prefix 'gnus-group-history (car split-name)))
12323 (gnus-completing-read
12324 prom (nreverse split-name) nil nil 'gnus-group-history))))
12325 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12328 (if (or (string= to-newsgroup "")
12329 (string= to-newsgroup prefix))
12330 (setq to-newsgroup default))
12331 (unless to-newsgroup
12332 (error "No group name entered"))
12333 (setq encoded (mm-encode-coding-string
12335 (gnus-group-name-charset to-method to-newsgroup)))
12336 (or (gnus-active encoded)
12337 (gnus-activate-group encoded nil nil to-method)
12338 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12340 (or (and (gnus-request-create-group encoded to-method)
12341 (gnus-activate-group encoded nil nil to-method)
12342 (gnus-subscribe-group encoded))
12343 (error "Couldn't create group %s" to-newsgroup)))
12344 (error "No such group: %s" to-newsgroup))
12347 (defvar gnus-summary-save-parts-counter)
12348 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12350 (defun gnus-summary-save-parts (type dir n &optional reverse)
12351 "Save parts matching TYPE to DIR.
12352 If REVERSE, save parts that do not match TYPE."
12354 (list (read-string "Save parts of type: "
12355 (or (car gnus-summary-save-parts-type-history)
12356 gnus-summary-save-parts-default-mime)
12357 'gnus-summary-save-parts-type-history)
12358 (setq gnus-summary-save-parts-last-directory
12359 (read-directory-name "Save to directory: "
12360 gnus-summary-save-parts-last-directory
12362 current-prefix-arg))
12363 (gnus-summary-iterate n
12364 (let ((gnus-display-mime-function nil)
12365 gnus-article-prepare-hook
12366 gnus-article-decode-hook
12367 gnus-display-mime-function
12369 (gnus-inhibit-treatment t))
12370 (gnus-summary-select-article))
12371 (with-current-buffer gnus-article-buffer
12372 (let ((handles (or gnus-article-mime-handles
12373 (mm-dissect-buffer nil gnus-article-loose-mime)
12374 (and gnus-article-emulate-mime
12376 (gnus-summary-save-parts-counter 1))
12378 (gnus-summary-save-parts-1 type dir handles reverse)
12379 (unless gnus-article-mime-handles ;; Don't destroy this case.
12380 (mm-destroy-parts handles)))))))
12382 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12383 (if (stringp (car handle))
12384 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12387 (not (string-match type (mm-handle-media-type handle)))
12388 (string-match type (mm-handle-media-type handle)))
12389 (let ((file (expand-file-name
12391 mm-file-name-rewrite-functions
12392 (file-name-nondirectory
12394 (mm-handle-filename handle)
12395 (format "%s.%d.%d" gnus-newsgroup-name
12396 (cdr gnus-article-current)
12397 gnus-summary-save-parts-counter))))
12399 (incf gnus-summary-save-parts-counter)
12400 (unless (file-exists-p file)
12401 (mm-save-part-to-file handle file))))))
12403 ;; Summary extract commands
12405 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12406 (let ((inhibit-read-only t)
12407 (article (gnus-summary-article-number))
12409 (unless (gnus-summary-goto-subject article)
12410 (error "No such article: %d" article))
12411 (gnus-summary-position-point)
12412 ;; If all commands are to be bunched up on one line, we collect
12414 (unless gnus-view-pseudos-separately
12415 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12418 (setq action (cdr (assq 'action (car ps))))
12419 (setq files (list (cdr (assq 'name (car ps)))))
12420 (while (and ps (cdr ps)
12421 (string= (or action "1")
12422 (or (cdr (assq 'action (cadr ps))) "2")))
12423 (push (cdr (assq 'name (cadr ps))) files)
12424 (setcdr ps (cddr ps)))
12426 (when (not (string-match "%s" action))
12429 (when (assq 'execute (car ps))
12430 (setcdr (assq 'execute (car ps))
12431 (funcall (if (string-match "%s" action)
12438 (shell-quote-argument f)))
12440 (setq ps (cdr ps)))))
12441 (if (and gnus-view-pseudos (not not-view))
12443 (when (assq 'execute (car pslist))
12444 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12445 (eq gnus-view-pseudos 'not-confirm)))
12446 (setq pslist (cdr pslist)))
12449 (setq after-article (or (cdr (assq 'article (car pslist)))
12450 (gnus-summary-article-number)))
12451 (gnus-summary-goto-subject after-article)
12454 (insert " " (file-name-nondirectory
12455 (cdr (assq 'name (car pslist))))
12456 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12458 (forward-line -1) ; back to `b'
12459 (gnus-add-text-properties
12460 b (1- e) (list 'gnus-number gnus-reffed-article-number
12461 gnus-mouse-face-prop gnus-mouse-face))
12463 after-article gnus-reffed-article-number
12464 gnus-unread-mark b (car pslist) 0 (- e b))
12465 (setq gnus-newsgroup-unreads
12466 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12467 gnus-reffed-article-number))
12468 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12469 (setq pslist (cdr pslist)))))))
12471 (defun gnus-pseudos< (p1 p2)
12472 (let ((c1 (cdr (assq 'action p1)))
12473 (c2 (cdr (assq 'action p2))))
12474 (and c1 c2 (string< c1 c2))))
12476 (defun gnus-request-pseudo-article (props)
12477 (cond ((assq 'execute props)
12478 (gnus-execute-command (cdr (assq 'execute props)))))
12479 (let ((gnus-current-article (gnus-summary-article-number)))
12480 (gnus-run-hooks 'gnus-mark-article-hook)))
12482 (defun gnus-execute-command (command &optional automatic)
12484 (gnus-article-setup-buffer)
12485 (set-buffer gnus-article-buffer)
12486 (setq buffer-read-only nil)
12487 (let ((command (if automatic command
12488 (read-string "Command: " (cons command 0)))))
12490 (insert "$ " command "\n\n")
12491 (if gnus-view-pseudo-asynchronously
12492 (start-process "gnus-execute" (current-buffer) shell-file-name
12493 shell-command-switch command)
12494 (call-process shell-file-name nil t nil
12495 shell-command-switch command)))))
12497 ;; Summary kill commands.
12499 (defun gnus-summary-edit-global-kill (article)
12500 "Edit the \"global\" kill file."
12501 (interactive (list (gnus-summary-article-number)))
12502 (gnus-group-edit-global-kill article))
12504 (defun gnus-summary-edit-local-kill ()
12505 "Edit a local kill file applied to the current newsgroup."
12507 (setq gnus-current-headers (gnus-summary-article-header))
12508 (gnus-group-edit-local-kill
12509 (gnus-summary-article-number) gnus-newsgroup-name))
12511 ;;; Header reading.
12513 (defun gnus-read-header (id &optional header)
12514 "Read the headers of article ID and enter them into the Gnus system."
12515 (let ((group gnus-newsgroup-name)
12516 (gnus-override-method
12518 gnus-override-method
12519 (and (gnus-news-group-p gnus-newsgroup-name)
12520 (car (gnus-refer-article-methods)))))
12522 ;; First we check to see whether the header in question is already
12525 ;; This is a Message-ID.
12526 (setq header (or header (gnus-id-to-header id)))
12527 ;; This is an article number.
12528 (setq header (or header (gnus-summary-article-header id))))
12530 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12531 ;; We have found the header.
12533 ;; We have to really fetch the header to this article.
12534 (with-current-buffer nntp-server-buffer
12535 (when (setq where (gnus-request-head id group))
12536 (nnheader-fold-continuation-lines)
12537 (goto-char (point-max))
12539 (goto-char (point-min))
12543 ((cdr where) (cdr where))
12544 (header (mail-header-number header))
12545 (t gnus-reffed-article-number))
12547 (insert " Article retrieved.\n"))
12548 (if (or (not where)
12549 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12550 () ; Malformed head.
12551 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12552 (when (and (bound-and-true-p gnus-registry-enabled)
12553 (not (gnus-ephemeral-group-p (car where))))
12554 (gnus-registry-handle-action
12555 (mail-header-id header) nil
12556 (gnus-group-prefixed-name
12558 (or gnus-override-method (gnus-find-method-for-group group)))
12559 (mail-header-subject header)
12560 (mail-header-from header)))
12561 (when (and (stringp id)
12563 (not (string= (gnus-group-real-name group)
12565 (not (gnus-server-equal gnus-override-method
12566 (gnus-group-method group)))))
12567 ;; If we fetched by Message-ID and the article came from
12568 ;; a different group (or server), we fudge some bogus
12569 ;; article numbers for this article.
12570 (mail-header-set-number header gnus-reffed-article-number))
12571 (with-current-buffer gnus-summary-buffer
12572 (decf gnus-reffed-article-number)
12573 (gnus-remove-header (mail-header-number header))
12574 (push header gnus-newsgroup-headers)
12575 (setq gnus-current-headers header)
12576 (push (mail-header-number header) gnus-newsgroup-limit)))
12579 (defun gnus-remove-header (number)
12580 "Remove header NUMBER from `gnus-newsgroup-headers'."
12581 (if (and gnus-newsgroup-headers
12582 (= number (mail-header-number (car gnus-newsgroup-headers))))
12583 (pop gnus-newsgroup-headers)
12584 (let ((headers gnus-newsgroup-headers))
12585 (while (and (cdr headers)
12586 (not (= number (mail-header-number (cadr headers)))))
12588 (when (cdr headers)
12589 (setcdr headers (cddr headers))))))
12592 ;;; summary highlights
12595 (defun gnus-highlight-selected-summary ()
12596 "Highlight selected article in summary buffer."
12597 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12598 (when gnus-summary-selected-face
12600 (let* ((beg (point-at-bol))
12601 (end (point-at-eol))
12602 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12603 (from (if (get-text-property beg gnus-mouse-face-prop)
12605 (or (next-single-property-change
12606 beg gnus-mouse-face-prop nil end)
12611 (or (next-single-property-change
12612 from gnus-mouse-face-prop nil end)
12614 ;; If no mouse-face prop on line we will have to = from = end,
12615 ;; so we highlight the entire line instead.
12616 (when (= (+ to 2) from)
12619 (if gnus-newsgroup-selected-overlay
12620 ;; Move old overlay.
12622 gnus-newsgroup-selected-overlay from to (current-buffer))
12623 ;; Create new overlay.
12625 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12626 'face gnus-summary-selected-face))))))
12628 (defvar gnus-summary-highlight-line-cached nil)
12629 (defvar gnus-summary-highlight-line-trigger nil)
12631 (defun gnus-summary-highlight-line-0 ()
12632 (if (and (eq gnus-summary-highlight-line-trigger
12633 gnus-summary-highlight)
12634 gnus-summary-highlight-line-cached)
12635 gnus-summary-highlight-line-cached
12636 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12637 gnus-summary-highlight-line-cached
12638 (let* ((cond (list 'cond))
12640 (list gnus-summary-highlight))
12642 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12646 (gnus-byte-compile (list 'lambda nil cond))))))
12648 (defun gnus-summary-highlight-line ()
12649 "Highlight current line according to `gnus-summary-highlight'."
12650 (let* ((beg (point-at-bol))
12651 (article (or (gnus-summary-article-number) gnus-current-article))
12652 (score (or (cdr (assq article
12653 gnus-newsgroup-scored))
12654 gnus-summary-default-score 0))
12655 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12656 (inhibit-read-only t)
12657 (default gnus-summary-default-score)
12658 (default-high gnus-summary-default-high-score)
12659 (default-low gnus-summary-default-low-score)
12660 (uncached (and gnus-summary-use-undownloaded-faces
12661 (memq article gnus-newsgroup-undownloaded)
12662 (not (memq article gnus-newsgroup-cached)))))
12663 (let ((face (funcall (gnus-summary-highlight-line-0))))
12664 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12665 (gnus-put-text-property-excluding-characters-with-faces
12666 beg (point-at-eol) 'face
12667 (setq face (if (boundp face) (symbol-value face) face)))
12668 (when gnus-summary-highlight-line-function
12669 (funcall gnus-summary-highlight-line-function article face))))))
12671 (defun gnus-update-read-articles (group unread &optional compute)
12672 "Update the list of read articles in GROUP.
12673 UNREAD is a sorted list."
12674 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12675 (info (gnus-get-info group))
12678 (if (or (not info) (not active))
12679 ;; There is no info on this group if it was, in fact,
12680 ;; killed. Gnus stores no information on killed groups, so
12681 ;; there's nothing to be done.
12682 ;; One could store the information somewhere temporarily,
12683 ;; perhaps... Hmmm...
12685 ;; Remove any negative articles numbers.
12686 (while (and unread (< (car unread) 0))
12687 (setq unread (cdr unread)))
12688 ;; Remove any expired article numbers
12689 (while (and unread (< (car unread) (car active)))
12690 (setq unread (cdr unread)))
12691 ;; Compute the ranges of read articles by looking at the list of
12692 ;; unread articles.
12694 (when (/= (car unread) prev)
12695 (push (if (= prev (1- (car unread))) prev
12696 (cons prev (1- (car unread))))
12698 (setq prev (1+ (car unread)))
12699 (setq unread (cdr unread)))
12700 (when (<= prev (cdr active))
12701 (push (cons prev (cdr active)) read))
12702 (setq read (if (> (length read) 1) (nreverse read) read))
12707 ;; Propagate the read marks to the backend.
12708 (when (and (gnus-method-option-p
12709 (gnus-find-method-for-group group)
12711 (gnus-check-backend-function 'request-set-mark group))
12712 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12713 (add (gnus-remove-from-range read (gnus-info-read info))))
12715 (unless (gnus-check-group group)
12716 (error "Can't open server for %s" group))
12717 (gnus-request-set-mark
12718 group (delq nil (list (if add (list add 'add '(read)))
12719 (if del (list del 'del '(read))))))
12721 `(gnus-request-set-mark
12724 (if del (list del 'add '(read)))
12725 (if add (list add 'del '(read))))))))))
12726 (set-buffer gnus-group-buffer)
12727 (gnus-undo-register
12729 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12730 (gnus-info-set-read ',info ',(gnus-info-read info))
12731 (gnus-get-unread-articles-in-group ',info
12732 (gnus-active ,group))
12733 (gnus-group-update-group ,group t)
12735 ;; Enter this list into the group info.
12736 (gnus-info-set-read info read)
12737 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12738 (gnus-get-unread-articles-in-group info (gnus-active group))
12741 (defun gnus-offer-save-summaries ()
12742 "Offer to save all active summary buffers."
12744 ;; Go through all buffers and find all summaries.
12745 (dolist (buffer (buffer-list))
12746 (when (and (setq buffer (buffer-name buffer))
12747 (string-match "Summary" buffer)
12748 (with-current-buffer buffer
12749 ;; We check that this is, indeed, a summary buffer.
12750 (and (derived-mode-p 'gnus-summary-mode)
12751 ;; Also make sure this isn't bogus.
12752 gnus-newsgroup-prepared
12753 ;; Also make sure that this isn't a
12754 ;; dead summary buffer.
12755 (not gnus-dead-summary-mode))))
12756 (push buffer buffers)))
12757 ;; Go through all these summary buffers and offer to save them.
12760 (if (eq gnus-interactive-exit 'quiet)
12761 (dolist (buffer buffers)
12762 (switch-to-buffer buffer)
12763 (gnus-summary-exit))
12765 "Update summary buffer %s? "
12767 (switch-to-buffer buf)
12768 (gnus-summary-exit))
12771 (defun gnus-summary-setup-default-charset ()
12772 "Setup newsgroup default charset."
12773 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12774 (setq gnus-newsgroup-charset nil)
12775 (let* ((ignored-charsets
12776 (or gnus-newsgroup-ephemeral-ignored-charsets
12778 (and gnus-newsgroup-name
12779 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12780 gnus-newsgroup-ignored-charsets))))
12781 (setq gnus-newsgroup-charset
12782 (or gnus-newsgroup-ephemeral-charset
12783 (and gnus-newsgroup-name
12784 (gnus-parameter-charset gnus-newsgroup-name))
12785 gnus-default-charset))
12786 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12787 ignored-charsets))))
12793 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12794 "Display the current article buffer fully MIME-buttonized.
12795 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12796 treated as multipart/mixed."
12798 (require 'gnus-art)
12799 (let ((gnus-unbuttonized-mime-types nil)
12800 (gnus-mime-display-multipart-as-mixed show-all-parts))
12801 (gnus-summary-show-article)))
12803 (defun gnus-summary-repair-multipart (article)
12804 "Add a Content-Type header to a multipart article without one."
12805 (interactive (list (gnus-summary-article-number)))
12806 (gnus-with-article article
12807 (message-narrow-to-head)
12808 (message-remove-header "Mime-Version")
12809 (goto-char (point-max))
12810 (insert "Mime-Version: 1.0\n")
12812 (when (search-forward "\n--" nil t)
12813 (let ((separator (buffer-substring (point) (point-at-eol))))
12814 (message-narrow-to-head)
12815 (message-remove-header "Content-Type")
12816 (goto-char (point-max))
12817 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12820 (let (gnus-mark-article-hook)
12821 (gnus-summary-select-article t t nil article)))
12823 (defun gnus-summary-toggle-display-buttonized ()
12824 "Toggle the buttonizing of the article buffer."
12826 (require 'gnus-art)
12827 (if (setq gnus-inhibit-mime-unbuttonizing
12828 (not gnus-inhibit-mime-unbuttonizing))
12829 (let ((gnus-unbuttonized-mime-types nil))
12830 (gnus-summary-show-article))
12831 (gnus-summary-show-article)))
12834 ;;; Generic summary marking commands
12837 (defvar gnus-summary-marking-alist
12838 '((read gnus-del-mark "d")
12839 (unread gnus-unread-mark "u")
12840 (ticked gnus-ticked-mark "!")
12841 (dormant gnus-dormant-mark "?")
12842 (expirable gnus-expirable-mark "e"))
12843 "An alist of names/marks/keystrokes.")
12845 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12846 (defvar gnus-summary-mark-map)
12848 (defun gnus-summary-make-all-marking-commands ()
12849 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12850 (dolist (elem gnus-summary-marking-alist)
12851 (apply 'gnus-summary-make-marking-command elem)))
12853 (defun gnus-summary-make-marking-command (name mark keystroke)
12854 (let ((map (make-sparse-keymap)))
12855 (define-key gnus-summary-generic-mark-map keystroke map)
12856 (dolist (lway `((next "next" next nil "n")
12857 (next-unread "next unread" next t "N")
12858 (prev "previous" prev nil "p")
12859 (prev-unread "previous unread" prev t "P")
12860 (nomove "" nil nil ,keystroke)))
12861 (let ((func (gnus-summary-make-marking-command-1
12862 mark (car lway) lway name)))
12863 (setq func (eval func))
12864 (define-key map (nth 4 lway) func)))))
12866 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12868 (format "gnus-summary-put-mark-as-%s%s"
12869 name (if (eq way 'nomove)
12871 (concat "-" (symbol-name way)))))
12874 "Mark the current article as %s%s.
12875 If N, the prefix, then repeat N times.
12876 If N is negative, move in reverse order.
12877 The difference between N and the actual number of articles marked is
12881 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12883 (defun gnus-summary-generic-mark (n mark move unread)
12884 "Mark N articles with MARK."
12885 (unless (derived-mode-p 'gnus-summary-mode)
12886 (error "This command can only be used in the summary buffer"))
12887 (gnus-summary-show-thread)
12890 ((eq move 'next) 1)
12891 ((eq move 'prev) -1)
12893 (if (zerop nummove)
12897 nummove (* -1 nummove))))
12898 (while (and (> n 0)
12899 (gnus-summary-mark-article nil mark)
12900 (zerop (gnus-summary-next-subject nummove unread t)))
12903 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12904 (gnus-summary-recenter)
12905 (gnus-summary-position-point)
12906 (gnus-set-mode-line 'summary)
12909 (defun gnus-summary-insert-articles (articles)
12910 (when (setq articles
12911 (gnus-sorted-difference articles
12912 (mapcar (lambda (h)
12913 (mail-header-number h))
12914 gnus-newsgroup-headers)))
12915 (setq gnus-newsgroup-headers
12917 gnus-newsgroup-headers
12918 (gnus-fetch-headers articles nil t)
12919 'gnus-article-sort-by-number))
12920 (setq gnus-newsgroup-articles
12921 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12922 ;; Suppress duplicates?
12923 (when gnus-suppress-duplicates
12924 (gnus-dup-suppress-articles))
12926 (if (and gnus-fetch-old-headers
12927 (eq gnus-headers-retrieved-by 'nov))
12928 ;; We might want to build some more threads first.
12929 (if (eq gnus-fetch-old-headers 'invisible)
12930 (gnus-build-all-threads)
12931 (gnus-build-old-threads))
12932 ;; Mark the inserted articles that are unread as unread.
12933 (setq gnus-newsgroup-unreads
12934 (gnus-sorted-nunion
12935 gnus-newsgroup-unreads
12936 (gnus-sorted-nintersection
12937 (gnus-list-of-unread-articles gnus-newsgroup-name)
12939 ;; Mark the inserted articles as selected so that the information
12940 ;; of the marks having been changed by a user may be updated when
12941 ;; exiting this group. See `gnus-summary-update-info'.
12942 (dolist (art articles)
12943 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12944 ;; Let the Gnus agent mark articles as read.
12946 (gnus-agent-get-undownloaded-list))
12947 ;; Remove list identifiers from subject
12948 (gnus-summary-remove-list-identifiers)
12949 ;; First and last article in this newsgroup.
12950 (when gnus-newsgroup-headers
12951 (setq gnus-newsgroup-begin
12952 (mail-header-number (car gnus-newsgroup-headers))
12954 (mail-header-number
12955 (gnus-last-element gnus-newsgroup-headers))))
12956 (when gnus-use-scoring
12957 (gnus-possibly-score-headers))))
12959 (defun gnus-summary-insert-old-articles (&optional all)
12960 "Insert all old articles in this group.
12961 If ALL is non-nil, already read articles become readable.
12962 If ALL is a number, fetch this number of articles."
12965 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12968 ;; Some nntp servers lie about their active range. When
12969 ;; this happens, the active range can be in the millions.
12970 ;; Use a compressed range to avoid creating a huge list.
12971 (gnus-range-difference
12972 (gnus-range-difference (list gnus-newsgroup-active) old)
12973 gnus-newsgroup-unexist))
12974 (setq len (gnus-range-length older))
12979 (let ((older-range (nreverse older)))
12983 (let* ((r (pop older-range))
12984 (min (if (numberp r) r (car r)))
12985 (max (if (numberp r) r (cdr r))))
12986 (while (and (<= min max)
12991 (setq older (gnus-uncompress-range older))))
12993 (setq older (gnus-uncompress-range older)))
12995 (when (and (numberp gnus-large-newsgroup)
12996 (> len gnus-large-newsgroup))
12997 (let* ((cursor-in-echo-area nil)
12998 (initial (gnus-parameter-large-newsgroup-initial
12999 gnus-newsgroup-name))
13003 "How many articles from %s (%s %d): "
13004 (gnus-group-decoded-name gnus-newsgroup-name)
13005 (if initial "max" "default")
13009 (number-to-string initial)))))
13010 (unless (string-match "^[ \t]*$" input)
13011 (setq all (string-to-number input))
13013 (let ((older-range (nreverse older)))
13017 (let* ((r (pop older-range))
13018 (min (if (numberp r) r (car r)))
13019 (max (if (numberp r) r (cdr r))))
13020 (while (and (<= min max)
13024 max (1- max))))))))))
13025 (setq older (gnus-uncompress-range older))))
13027 (message "No old news.")
13028 (gnus-summary-insert-articles older)
13029 (gnus-summary-limit (gnus-sorted-nunion old older))))
13030 (gnus-summary-position-point)))
13032 (defun gnus-summary-insert-new-articles ()
13033 "Insert all new articles in this group."
13035 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
13036 (old-high gnus-newsgroup-highest)
13037 (nnmail-fetched-sources (list t))
13038 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
13041 (error "Couldn't fetch new data"))
13042 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
13043 (setq i (cdr gnus-newsgroup-active)
13044 gnus-newsgroup-highest i)
13045 (while (> i old-high)
13049 (message "No gnus is bad news")
13050 (gnus-summary-insert-articles new)
13051 (setq gnus-newsgroup-unreads
13052 (gnus-sorted-nunion gnus-newsgroup-unreads new))
13053 (gnus-summary-limit (gnus-sorted-nunion old new))))
13054 (gnus-summary-position-point))
13056 ;;; Bookmark support for Gnus.
13057 (declare-function gnus-article-show-summary "gnus-art" ())
13058 (declare-function bookmark-make-record-default
13059 "bookmark" (&optional no-file no-context posn))
13060 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13061 (declare-function bookmark-default-handler "bookmark" (bmk))
13062 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13063 (defvar bookmark-yank-point)
13064 (defvar bookmark-current-buffer)
13066 (defun gnus-summary-bookmark-make-record ()
13067 "Make a bookmark entry for a Gnus summary buffer."
13069 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13070 (save-restriction ; FIXME is it necessary to widen?
13071 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13072 (setq buf "art") ; We are recording bookmark from article buffer.
13073 (setq bookmark-yank-point (point))
13074 (setq bookmark-current-buffer (current-buffer))
13075 (gnus-article-show-summary)) ; Go back in summary buffer.
13076 ;; We are now recording bookmark from summary buffer.
13077 (unless buf (setq buf "sum"))
13078 (let* ((subject (elt (gnus-summary-article-header) 1))
13079 (grp (car gnus-article-current))
13080 (art (cdr gnus-article-current))
13081 (head (gnus-summary-article-header art))
13082 (id (mail-header-id head)))
13084 ,@(condition-case nil
13085 (bookmark-make-record-default 'no-file 'no-context pos)
13086 (wrong-number-of-arguments
13087 (bookmark-make-record-default 'point-only)))
13088 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13089 (group . ,grp) (article . ,art)
13090 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13093 (defun gnus-summary-bookmark-jump (bookmark)
13094 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13095 BOOKMARK is a bookmark name or a bookmark record."
13096 (let ((group (bookmark-prop-get bookmark 'group))
13097 (article (bookmark-prop-get bookmark 'article))
13098 (id (bookmark-prop-get bookmark 'message-id))
13099 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13100 (gnus-fetch-group group (list article))
13101 (gnus-summary-insert-cached-articles)
13102 (gnus-summary-goto-article id nil 'force)
13103 ;; FIXME we have to wait article buffer is ready (only large buffer)
13104 ;; Is there a better solution to know that?
13105 ;; If we don't wait `bookmark-default-handler' will have no chance
13106 ;; to set position. However there is no error, just wrong pos.
13108 (when (string= buf "Gnus-art")
13110 (bookmark-default-handler
13112 (buffer . ,(current-buffer))
13113 . ,(bookmark-get-bookmark-record bookmark)))))
13115 (gnus-summary-make-all-marking-commands)
13117 (gnus-ems-redefine)
13119 (provide 'gnus-sum)
13121 (run-hooks 'gnus-sum-load-hook)
13123 ;; Local Variables:
13127 ;;; gnus-sum.el ends here