1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2015 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 "m" gnus-summary-move-article
2224 "r" gnus-summary-respool-article
2225 "w" gnus-summary-edit-article
2226 "c" gnus-summary-copy-article
2227 "B" gnus-summary-crosspost-article
2228 "q" gnus-summary-respool-query
2229 "t" gnus-summary-respool-trace
2230 "i" gnus-summary-import-article
2231 "I" gnus-summary-create-article
2232 "p" gnus-summary-article-posted-p)
2234 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2235 "o" gnus-summary-save-article
2236 "m" gnus-summary-save-article-mail
2237 "F" gnus-summary-write-article-file
2238 "r" gnus-summary-save-article-rmail
2239 "f" gnus-summary-save-article-file
2240 "b" gnus-summary-save-article-body-file
2241 "B" gnus-summary-write-article-body-file
2242 "h" gnus-summary-save-article-folder
2243 "v" gnus-summary-save-article-vm
2244 "p" gnus-summary-pipe-output
2245 "P" gnus-summary-muttprint)
2247 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2248 "b" gnus-summary-display-buttonized
2249 "m" gnus-summary-repair-multipart
2250 "v" gnus-article-view-part
2251 "o" gnus-article-save-part
2252 "O" gnus-article-save-part-and-strip
2253 "r" gnus-article-replace-part
2254 "d" gnus-article-delete-part
2255 "t" gnus-article-view-part-as-type
2256 "j" gnus-article-jump-to-part
2257 "c" gnus-article-copy-part
2258 "C" gnus-article-view-part-as-charset
2259 "e" gnus-article-view-part-externally
2260 "H" gnus-article-browse-html-article
2261 "E" gnus-article-encrypt-body
2262 "i" gnus-article-inline-part
2263 "|" gnus-article-pipe-part)
2265 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2266 "p" gnus-summary-mark-as-processable
2267 "u" gnus-summary-unmark-as-processable
2268 "U" gnus-summary-unmark-all-processable
2269 "v" gnus-uu-mark-over
2270 "s" gnus-uu-mark-series
2271 "r" gnus-uu-mark-region
2272 "g" gnus-uu-unmark-region
2273 "R" gnus-uu-mark-by-regexp
2274 "G" gnus-uu-unmark-by-regexp
2275 "t" gnus-uu-mark-thread
2276 "T" gnus-uu-unmark-thread
2277 "a" gnus-uu-mark-all
2278 "b" gnus-uu-mark-buffer
2279 "S" gnus-uu-mark-sparse
2280 "k" gnus-summary-kill-process-mark
2281 "y" gnus-summary-yank-process-mark
2282 "w" gnus-summary-save-process-mark
2283 "i" gnus-uu-invert-processable)
2285 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2286 ;;"x" gnus-uu-extract-any
2287 "m" gnus-summary-save-parts
2288 "u" gnus-uu-decode-uu
2289 "U" gnus-uu-decode-uu-and-save
2290 "s" gnus-uu-decode-unshar
2291 "S" gnus-uu-decode-unshar-and-save
2292 "o" gnus-uu-decode-save
2293 "O" gnus-uu-decode-save
2294 "b" gnus-uu-decode-binhex
2295 "B" gnus-uu-decode-binhex
2296 "Y" gnus-uu-decode-yenc
2297 "p" gnus-uu-decode-postscript
2298 "P" gnus-uu-decode-postscript-and-save)
2301 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2302 "u" gnus-uu-decode-uu-view
2303 "U" gnus-uu-decode-uu-and-save-view
2304 "s" gnus-uu-decode-unshar-view
2305 "S" gnus-uu-decode-unshar-and-save-view
2306 "o" gnus-uu-decode-save-view
2307 "O" gnus-uu-decode-save-view
2308 "b" gnus-uu-decode-binhex-view
2309 "B" gnus-uu-decode-binhex-view
2310 "p" gnus-uu-decode-postscript-view
2311 "P" gnus-uu-decode-postscript-and-save-view)
2313 (defvar gnus-article-post-menu nil)
2315 (defconst gnus-summary-menu-maxlen 20)
2317 (defun gnus-summary-menu-split (menu)
2318 ;; If we have lots of elements, divide them into groups of 20
2319 ;; and make a pane (or submenu) for each one.
2320 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2321 (let ((menu menu) sublists next
2324 ;; Pull off the next gnus-summary-menu-maxlen elements
2325 ;; and make them the next element of sublist.
2326 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2328 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2330 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2331 (aref (car (last menu)) 0)) menu)
2335 (nreverse sublists))
2336 ;; Few elements--put them all in one pane.
2339 (defun gnus-summary-make-menu-bar ()
2340 (gnus-turn-off-edit-menu 'summary)
2342 (unless (boundp 'gnus-summary-misc-menu)
2345 gnus-summary-kill-menu gnus-summary-mode-map ""
2350 ["Customize" gnus-score-customize t])
2351 (gnus-make-score-map 'increase)
2352 (gnus-make-score-map 'lower)
2354 ["Kill below" gnus-summary-kill-below t]
2355 ["Mark above" gnus-summary-mark-above t]
2356 ["Tick above" gnus-summary-tick-above t]
2357 ["Clear above" gnus-summary-clear-above t])
2358 ["Current article score" gnus-summary-current-score t]
2359 ["Current thread score" (gnus-summary-current-score 'total) t]
2360 ["Set score" gnus-summary-set-score t]
2361 ["Switch current score file..." gnus-score-change-score-file t]
2362 ["Set mark below..." gnus-score-set-mark-below t]
2363 ["Set expunge below..." gnus-score-set-expunge-below t]
2364 ["Edit current score file" gnus-score-edit-current-scores t]
2365 ["Edit score file..." gnus-score-edit-file t]
2366 ["Trace score" gnus-score-find-trace t]
2367 ["Find words" gnus-score-find-favourite-words t]
2368 ["Rescore buffer" gnus-summary-rescore t]
2369 ["Increase score..." gnus-summary-increase-score t]
2370 ["Lower score..." gnus-summary-lower-score t]))))
2372 ;; Define both the Article menu in the summary buffer and the
2373 ;; equivalent Commands menu in the article buffer here for
2377 ["All" gnus-article-hide t]
2378 ["Headers" gnus-article-hide-headers t]
2379 ["Signature" gnus-article-hide-signature t]
2380 ["Citation" gnus-article-hide-citation t]
2381 ["List identifiers" gnus-article-hide-list-identifiers t]
2382 ["Banner" gnus-article-strip-banner t]
2383 ["Boring headers" gnus-article-hide-boring-headers t])
2385 ["All" gnus-article-highlight t]
2386 ["Headers" gnus-article-highlight-headers t]
2387 ["Signature" gnus-article-highlight-signature t]
2388 ["Citation" gnus-article-highlight-citation t])
2390 ["Words" gnus-article-decode-mime-words t]
2391 ["Charset" gnus-article-decode-charset t]
2392 ["QP" gnus-article-de-quoted-unreadable t]
2393 ["Base64" gnus-article-de-base64-unreadable t]
2394 ["View MIME buttons" gnus-summary-display-buttonized t]
2395 ["View MIME buttons in header"
2396 gnus-mime-buttonize-attachments-in-header t]
2397 ["View all" gnus-mime-view-all-parts t]
2398 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2399 ["Encrypt body" gnus-article-encrypt-body
2400 :active (not (gnus-group-read-only-p))
2401 ,@(if (featurep 'xemacs) nil
2402 '(:help "Encrypt the message body on disk"))]
2403 ["Extract all parts..." gnus-summary-save-parts t]
2405 ["Repair multipart" gnus-summary-repair-multipart t]
2406 ["Pipe part..." gnus-article-pipe-part t]
2407 ["Inline part" gnus-article-inline-part t]
2408 ["View part as type..." gnus-article-view-part-as-type t]
2409 ["Encrypt body" gnus-article-encrypt-body
2410 :active (not (gnus-group-read-only-p))
2411 ,@(if (featurep 'xemacs) nil
2412 '(:help "Encrypt the message body on disk"))]
2413 ["View part externally" gnus-article-view-part-externally t]
2414 ["View HTML parts in browser" gnus-article-browse-html-article t]
2415 ["View part with charset..." gnus-article-view-part-as-charset t]
2416 ["Copy part" gnus-article-copy-part t]
2417 ["Save part..." gnus-article-save-part t]
2418 ["View part" gnus-article-view-part t]))
2420 ["Local" gnus-article-date-local t]
2421 ["ISO8601" gnus-article-date-iso8601 t]
2422 ["UT" gnus-article-date-ut t]
2423 ["Original" gnus-article-date-original t]
2424 ["Lapsed" gnus-article-date-lapsed t]
2425 ["User-defined" gnus-article-date-user t])
2427 ["Display HTML images" gnus-article-show-images t]
2428 ["Remove images" gnus-article-remove-images t]
2429 ["Toggle smiley" gnus-treat-smiley t]
2430 ["Show X-Face" gnus-article-display-x-face t]
2431 ["Show picons in From" gnus-treat-from-picon t]
2432 ["Show picons in mail headers" gnus-treat-mail-picon t]
2433 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2434 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2435 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2436 ("View as different encoding"
2437 ,@(gnus-summary-menu-split
2440 ;; Since easymenu under Emacs doesn't allow
2441 ;; lambda forms for menu commands, we should
2442 ;; provide intern'ed function symbols.
2443 (let ((command (intern (format "\
2444 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2448 (let ((gnus-summary-show-article-charset-alist
2450 (gnus-summary-show-article 1))))
2451 `[,(symbol-name cs) ,command t]))
2452 (sort (if (fboundp 'coding-system-list)
2453 (coding-system-list)
2454 (mapcar 'car mm-mime-mule-charset-alist))
2458 ["Leading" gnus-article-strip-leading-blank-lines t]
2459 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2460 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2461 ["All of the above" gnus-article-strip-blank-lines t]
2462 ["All" gnus-article-strip-all-blank-lines t]
2463 ["Leading space" gnus-article-strip-leading-space t]
2464 ["Trailing space" gnus-article-strip-trailing-space t]
2465 ["Leading space in headers"
2466 gnus-article-remove-leading-whitespace t])
2467 ["Overstrike" gnus-article-treat-overstrike t]
2468 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2469 ["Non-ASCII" gnus-article-treat-non-ascii t]
2470 ["Emphasis" gnus-article-emphasize t]
2471 ["Word wrap" gnus-article-fill-cited-article t]
2472 ["Fill long lines" gnus-article-fill-long-lines t]
2473 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2474 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2475 ["Remove CR" gnus-article-remove-cr t]
2476 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2477 ["Base64" gnus-article-de-base64-unreadable t]
2478 ["Rot 13" gnus-summary-caesar-message
2479 ,@(if (featurep 'xemacs) '(t)
2480 '(:help "\"Caesar rotate\" article by 13"))]
2481 ["De-IDNA" gnus-summary-idna-message t]
2482 ["Morse decode" gnus-summary-morse-message t]
2483 ["Unix pipe..." gnus-summary-pipe-message t]
2484 ["Add buttons" gnus-article-add-buttons t]
2485 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2486 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2487 ["Verbose header" gnus-summary-verbose-headers t]
2488 ["Toggle header" gnus-summary-toggle-header t]
2489 ["Unfold headers" gnus-article-treat-unfold-headers t]
2490 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2491 ["Html" gnus-article-wash-html t]
2492 ["Unsplit URLs" gnus-article-unsplit-urls t]
2493 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2494 ["Decode HZ" gnus-article-decode-HZ t]
2495 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2496 ("(Outlook) Deuglify"
2497 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2498 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2499 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2500 ["Full (Outlook) deuglify"
2501 gnus-article-outlook-deuglify-article t])
2504 ["Save in default format..." gnus-summary-save-article
2505 ,@(if (featurep 'xemacs) '(t)
2506 '(:help "Save article using default method"))]
2507 ["Save in file..." gnus-summary-save-article-file
2508 ,@(if (featurep 'xemacs) '(t)
2509 '(:help "Save article in file"))]
2510 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2511 ["Save in MH folder..." gnus-summary-save-article-folder t]
2512 ["Save in VM folder..." gnus-summary-save-article-vm t]
2513 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2514 ["Save body in file..." gnus-summary-save-article-body-file t]
2515 ["Pipe through a filter..." gnus-summary-pipe-output t]
2516 ["Print with Muttprint..." gnus-summary-muttprint t]
2517 ["Print" gnus-summary-print-article
2518 ,@(if (featurep 'xemacs) '(t)
2519 '(:help "Generate and print a PostScript image"))])
2520 ("Copy, move,... (Backend)"
2521 ,@(if (featurep 'xemacs) nil
2522 '(:help "Copying, moving, expiring articles..."))
2523 ["Respool article..." gnus-summary-respool-article t]
2524 ["Move article..." gnus-summary-move-article
2525 (gnus-check-backend-function
2526 'request-move-article gnus-newsgroup-name)]
2527 ["Copy article..." gnus-summary-copy-article t]
2528 ["Crosspost article..." gnus-summary-crosspost-article
2529 (gnus-check-backend-function
2530 'request-replace-article gnus-newsgroup-name)]
2531 ["Import file..." gnus-summary-import-article
2532 (gnus-check-backend-function
2533 'request-accept-article gnus-newsgroup-name)]
2534 ["Create article..." gnus-summary-create-article
2535 (gnus-check-backend-function
2536 'request-accept-article gnus-newsgroup-name)]
2537 ["Check if posted" gnus-summary-article-posted-p t]
2538 ["Edit article" gnus-summary-edit-article
2539 (not (gnus-group-read-only-p))]
2540 ["Delete article" gnus-summary-delete-article
2541 (gnus-check-backend-function
2542 'request-expire-articles gnus-newsgroup-name)]
2543 ["Query respool" gnus-summary-respool-query t]
2544 ["Trace respool" gnus-summary-respool-trace t]
2545 ["Delete expirable articles" gnus-summary-expire-articles-now
2546 (gnus-check-backend-function
2547 'request-expire-articles gnus-newsgroup-name)])
2549 ["Uudecode" gnus-uu-decode-uu
2550 ,@(if (featurep 'xemacs) '(t)
2551 '(:help "Decode uuencoded article(s)"))]
2552 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2553 ["Unshar" gnus-uu-decode-unshar t]
2554 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2555 ["Save" gnus-uu-decode-save t]
2556 ["Binhex" gnus-uu-decode-binhex t]
2557 ["PostScript" gnus-uu-decode-postscript t]
2558 ["All MIME parts" gnus-summary-save-parts t])
2560 ["Enter article" gnus-cache-enter-article t]
2561 ["Remove article" gnus-cache-remove-article t])
2562 ["Translate" gnus-article-babel t]
2563 ["Select article buffer" gnus-summary-select-article-buffer t]
2564 ["Make article buffer sticky" gnus-sticky-article t]
2565 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2566 ["Isearch article..." gnus-summary-isearch-article t]
2567 ["Beginning of the article" gnus-summary-beginning-of-article t]
2568 ["End of the article" gnus-summary-end-of-article t]
2569 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2570 ["Fetch referenced articles" gnus-summary-refer-references t]
2571 ["Fetch current thread" gnus-summary-refer-thread t]
2572 ["Fetch article with id..." gnus-summary-refer-article t]
2573 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2574 ["Redisplay" gnus-summary-show-article t]
2575 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2577 gnus-summary-article-menu gnus-summary-mode-map ""
2578 (cons "Article" innards))
2580 (if (not (keymapp gnus-summary-article-menu))
2582 gnus-article-commands-menu gnus-article-mode-map ""
2583 (cons "Commands" innards))
2584 ;; in Emacs, don't share menu.
2585 (setq gnus-article-commands-menu
2586 (copy-keymap gnus-summary-article-menu))
2587 (define-key gnus-article-mode-map [menu-bar commands]
2588 (cons "Commands" gnus-article-commands-menu))))
2591 gnus-summary-thread-menu gnus-summary-mode-map ""
2593 ["Find all messages in thread" gnus-summary-refer-thread t]
2594 ["Toggle threading" gnus-summary-toggle-threads t]
2595 ["Hide threads" gnus-summary-hide-all-threads t]
2596 ["Show threads" gnus-summary-show-all-threads t]
2597 ["Hide thread" gnus-summary-hide-thread t]
2598 ["Show thread" gnus-summary-show-thread t]
2599 ["Go to next thread" gnus-summary-next-thread t]
2600 ["Go to previous thread" gnus-summary-prev-thread t]
2601 ["Go down thread" gnus-summary-down-thread t]
2602 ["Go up thread" gnus-summary-up-thread t]
2603 ["Top of thread" gnus-summary-top-thread t]
2604 ["Mark thread as read" gnus-summary-kill-thread t]
2605 ["Mark thread as expired" gnus-summary-expire-thread t]
2606 ["Lower thread score" gnus-summary-lower-thread t]
2607 ["Raise thread score" gnus-summary-raise-thread t]
2608 ["Rethread current" gnus-summary-rethread-current t]))
2611 gnus-summary-post-menu gnus-summary-mode-map ""
2613 ["Send a message (mail or news)" gnus-summary-post-news
2614 ,@(if (featurep 'xemacs) '(t)
2615 '(:help "Compose a new message (mail or news)"))]
2616 ["Followup" gnus-summary-followup
2617 ,@(if (featurep 'xemacs) '(t)
2618 '(:help "Post followup to this article"))]
2619 ["Followup and yank" gnus-summary-followup-with-original
2620 ,@(if (featurep 'xemacs) '(t)
2621 '(:help "Post followup to this article, quoting its contents"))]
2622 ["Supersede article" gnus-summary-supersede-article t]
2623 ["Cancel article" gnus-summary-cancel-article
2624 ,@(if (featurep 'xemacs) '(t)
2625 '(:help "Cancel an article you posted"))]
2626 ["Reply" gnus-summary-reply t]
2627 ["Reply and yank" gnus-summary-reply-with-original t]
2628 ["Wide reply" gnus-summary-wide-reply t]
2629 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2630 ,@(if (featurep 'xemacs) '(t)
2631 '(:help "Mail a reply, quoting this article"))]
2632 ["Very wide reply" gnus-summary-very-wide-reply t]
2633 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2634 ,@(if (featurep 'xemacs) '(t)
2635 '(:help "Mail a very wide reply, quoting this article"))]
2636 ["Mail forward" gnus-summary-mail-forward t]
2637 ["Post forward" gnus-summary-post-forward t]
2638 ["Digest and mail" gnus-uu-digest-mail-forward t]
2639 ["Digest and post" gnus-uu-digest-post-forward t]
2640 ["Resend message" gnus-summary-resend-message t]
2641 ["Resend message edit" gnus-summary-resend-message-edit t]
2642 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2643 ["Send a mail" gnus-summary-mail-other-window t]
2644 ["Create a local message" gnus-summary-news-other-window t]
2645 ["Uuencode and post" gnus-uu-post-news
2646 ,@(if (featurep 'xemacs) '(t)
2647 '(:help "Post a uuencoded article"))]
2648 ["Followup via news" gnus-summary-followup-to-mail t]
2649 ["Followup via news and yank"
2650 gnus-summary-followup-to-mail-with-original t]
2651 ["Strip signature on reply"
2654 (if (not (memq message-cite-function
2655 '(message-cite-original-without-signature
2656 message-cite-original)))
2657 ;; Stupid workaround for XEmacs not honoring :visible.
2658 (message "Can't toggle this value of `message-cite-function'")
2659 (setq message-cite-function
2660 (if (eq message-cite-function
2661 'message-cite-original-without-signature)
2662 'message-cite-original
2663 'message-cite-original-without-signature))))
2664 ;; XEmacs barfs on :visible.
2665 ,@(if (featurep 'xemacs) nil
2666 '(:visible (memq message-cite-function
2667 '(message-cite-original-without-signature
2668 message-cite-original))))
2670 :selected (eq message-cite-function
2671 'message-cite-original-without-signature)
2672 ,@(if (featurep 'xemacs) nil
2673 '(:help "Strip signature from cited article when replying."))]
2675 ;;["Send" gnus-summary-send-draft t]
2676 ;;["Send bounced" gnus-resend-bounced-mail t])
2680 ((not (keymapp gnus-summary-post-menu))
2681 (setq gnus-article-post-menu gnus-summary-post-menu))
2682 ((not gnus-article-post-menu)
2683 ;; Don't share post menu.
2684 (setq gnus-article-post-menu
2685 (copy-keymap gnus-summary-post-menu))))
2686 (define-key gnus-article-mode-map [menu-bar post]
2687 (cons "Post" gnus-article-post-menu))
2690 gnus-summary-misc-menu gnus-summary-mode-map ""
2693 ["Mark as read" gnus-summary-mark-as-read-forward t]
2694 ["Mark same subject and select"
2695 gnus-summary-kill-same-subject-and-select t]
2696 ["Mark same subject" gnus-summary-kill-same-subject t]
2697 ["Catchup" gnus-summary-catchup
2698 ,@(if (featurep 'xemacs) '(t)
2699 '(:help "Mark unread articles in this group as read"))]
2700 ["Catchup all" gnus-summary-catchup-all t]
2701 ["Catchup to here" gnus-summary-catchup-to-here t]
2702 ["Catchup from here" gnus-summary-catchup-from-here t]
2703 ["Catchup region" gnus-summary-mark-region-as-read
2704 (gnus-mark-active-p)]
2705 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2707 ["Tick" gnus-summary-tick-article-forward t]
2708 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2709 ["Remove marks" gnus-summary-clear-mark-forward t]
2710 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2711 ["Set bookmark" gnus-summary-set-bookmark t]
2712 ["Remove bookmark" gnus-summary-remove-bookmark t])
2714 ["Marks..." gnus-summary-limit-to-marks t]
2715 ["Subject..." gnus-summary-limit-to-subject t]
2716 ["Author..." gnus-summary-limit-to-author t]
2717 ["Recipient..." gnus-summary-limit-to-recipient t]
2718 ["Address..." gnus-summary-limit-to-address t]
2719 ["Age..." gnus-summary-limit-to-age t]
2720 ["Extra..." gnus-summary-limit-to-extra t]
2721 ["Score..." gnus-summary-limit-to-score t]
2722 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2723 ["Unread" gnus-summary-limit-to-unread t]
2724 ["Unseen" gnus-summary-limit-to-unseen t]
2725 ["Singletons" gnus-summary-limit-to-singletons t]
2726 ["Replied" gnus-summary-limit-to-replied t]
2727 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2728 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2729 ["Pop limit" gnus-summary-pop-limit t]
2730 ["Show dormant" gnus-summary-limit-include-dormant t]
2731 ["Hide childless dormant"
2732 gnus-summary-limit-exclude-childless-dormant t]
2733 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2734 ["Hide marked" gnus-summary-limit-exclude-marks t]
2735 ["Show expunged" gnus-summary-limit-include-expunged t])
2737 ["Set mark" gnus-summary-mark-as-processable t]
2738 ["Remove mark" gnus-summary-unmark-as-processable t]
2739 ["Remove all marks" gnus-summary-unmark-all-processable t]
2740 ["Invert marks" gnus-uu-invert-processable t]
2741 ["Mark above" gnus-uu-mark-over t]
2742 ["Mark series" gnus-uu-mark-series t]
2743 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2744 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2745 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2746 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2747 ["Mark all" gnus-uu-mark-all t]
2748 ["Mark buffer" gnus-uu-mark-buffer t]
2749 ["Mark sparse" gnus-uu-mark-sparse t]
2750 ["Mark thread" gnus-uu-mark-thread t]
2751 ["Unmark thread" gnus-uu-unmark-thread t]
2752 ("Process Mark Sets"
2753 ["Kill" gnus-summary-kill-process-mark t]
2754 ["Yank" gnus-summary-yank-process-mark
2755 gnus-newsgroup-process-stack]
2756 ["Save" gnus-summary-save-process-mark t]
2757 ["Run command on marked..." gnus-summary-universal-argument t]))
2760 ["Page forward" gnus-summary-next-page
2761 ,@(if (featurep 'xemacs) '(t)
2762 '(:help "Show next page of article"))]
2763 ["Page backward" gnus-summary-prev-page
2764 ,@(if (featurep 'xemacs) '(t)
2765 '(:help "Show previous page of article"))]
2766 ["Line forward" gnus-summary-scroll-up t])
2768 ["Next unread article" gnus-summary-next-unread-article t]
2769 ["Previous unread article" gnus-summary-prev-unread-article t]
2770 ["Next article" gnus-summary-next-article t]
2771 ["Previous article" gnus-summary-prev-article t]
2772 ["Next unread subject" gnus-summary-next-unread-subject t]
2773 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2774 ["Next article same subject" gnus-summary-next-same-subject t]
2775 ["Previous article same subject" gnus-summary-prev-same-subject t]
2776 ["First unread article" gnus-summary-first-unread-article t]
2777 ["Best unread article" gnus-summary-best-unread-article t]
2778 ["Go to subject number..." gnus-summary-goto-subject t]
2779 ["Go to article number..." gnus-summary-goto-article t]
2780 ["Go to the last article" gnus-summary-goto-last-article t]
2781 ["Pop article off history" gnus-summary-pop-article t])
2783 ["Sort by number" gnus-summary-sort-by-number t]
2784 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2785 ["Sort by author" gnus-summary-sort-by-author t]
2786 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2787 ["Sort by subject" gnus-summary-sort-by-subject t]
2788 ["Sort by date" gnus-summary-sort-by-date t]
2789 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2790 ["Sort by score" gnus-summary-sort-by-score t]
2791 ["Sort by lines" gnus-summary-sort-by-lines t]
2792 ["Sort by characters" gnus-summary-sort-by-chars t]
2793 ["Randomize" gnus-summary-sort-by-random t]
2794 ["Original sort" gnus-summary-sort-by-original t])
2796 ["Describe group" gnus-summary-describe-group t]
2797 ["Read manual" gnus-info-find-node t])
2799 ["Pick and read" gnus-pick-mode t]
2800 ["Binary" gnus-binary-mode t])
2802 ["Regenerate" gnus-summary-prepare t]
2803 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2804 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2805 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2806 ["Toggle threading" gnus-summary-toggle-threads t])
2807 ["See old articles" gnus-summary-insert-old-articles t]
2808 ["See new articles" gnus-summary-insert-new-articles t]
2809 ["Filter articles..." gnus-summary-execute-command t]
2810 ["Run command on articles..." gnus-summary-universal-argument t]
2811 ["Search articles forward..." gnus-summary-search-article-forward t]
2812 ["Search articles backward..." gnus-summary-search-article-backward t]
2813 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2814 ["Expand window" gnus-summary-expand-window t]
2815 ["Expire expirable articles" gnus-summary-expire-articles
2816 (gnus-check-backend-function
2817 'request-expire-articles gnus-newsgroup-name)]
2818 ["Edit local kill file" gnus-summary-edit-local-kill t]
2819 ["Edit main kill file" gnus-summary-edit-global-kill t]
2820 ["Edit group parameters" gnus-summary-edit-parameters t]
2821 ["Customize group parameters" gnus-summary-customize-parameters t]
2822 ["Send a bug report" gnus-bug t]
2824 ["Catchup and exit" gnus-summary-catchup-and-exit
2825 ,@(if (featurep 'xemacs) '(t)
2826 '(:help "Mark unread articles in this group as read, then exit"))]
2827 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2828 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2829 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2830 ["Exit group" gnus-summary-exit
2831 ,@(if (featurep 'xemacs) '(t)
2832 '(:help "Exit current group, return to group selection mode"))]
2833 ["Exit group without updating" gnus-summary-exit-no-update t]
2834 ["Exit and goto next group" gnus-summary-next-group t]
2835 ["Exit and goto prev group" gnus-summary-prev-group t]
2836 ["Reselect group" gnus-summary-reselect-current-group t]
2837 ["Rescan group" gnus-summary-rescan-group t]
2838 ["Update dribble" gnus-summary-save-newsrc t])))
2840 (gnus-run-hooks 'gnus-summary-menu-hook)))
2842 (defvar gnus-summary-tool-bar-map nil)
2844 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2845 ;; affect _new_ message buffers. We might add a function that walks thru all
2846 ;; summary-mode buffers and force the update.
2847 (defun gnus-summary-tool-bar-update (&optional symbol value)
2848 "Update summary mode toolbar.
2849 Setter function for custom variables."
2850 (setq-default gnus-summary-tool-bar-map nil)
2852 ;; When used as ":set" function:
2853 (set-default symbol value))
2854 (when (gnus-buffer-live-p gnus-summary-buffer)
2855 (with-current-buffer gnus-summary-buffer
2856 (gnus-summary-make-tool-bar))))
2858 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2859 'gnus-summary-tool-bar-gnome
2860 'gnus-summary-tool-bar-retro)
2861 "Specifies the Gnus summary tool bar.
2863 It can be either a list or a symbol referring to a list. See
2864 `gmm-tool-bar-from-list' for the format of the list. The
2865 default key map is `gnus-summary-mode-map'.
2867 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2868 `gnus-summary-tool-bar-retro'."
2869 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2870 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2871 (repeat :tag "User defined list" gmm-tool-bar-item)
2873 :version "23.1" ;; No Gnus
2874 :initialize 'custom-initialize-default
2875 :set 'gnus-summary-tool-bar-update
2876 :group 'gnus-summary)
2878 (defcustom gnus-summary-tool-bar-gnome
2879 '((gnus-summary-post-news "mail/compose" nil)
2880 (gnus-summary-insert-new-articles "mail/inbox" nil
2881 :visible (or (not gnus-agent)
2883 (gnus-summary-reply-with-original "mail/reply")
2884 (gnus-summary-reply "mail/reply" nil :visible nil)
2885 (gnus-summary-followup-with-original "mail/reply-all")
2886 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2887 (gnus-summary-mail-forward "mail/forward")
2888 (gnus-summary-save-article "mail/save")
2889 (gnus-summary-search-article-forward "search" nil :visible nil)
2890 (gnus-summary-print-article "print")
2891 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2892 ;; Some new commands that may need more suitable icons:
2893 (gnus-summary-save-newsrc "save" nil :visible nil)
2894 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2895 (gnus-summary-prev-article "left-arrow")
2896 (gnus-summary-next-article "right-arrow")
2897 (gnus-summary-next-page "next-page")
2898 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2900 ;; Maybe some sort-by-... could be added:
2901 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2902 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2903 (gnus-summary-mark-as-expirable
2905 :visible (gnus-check-backend-function 'request-expire-articles
2906 gnus-newsgroup-name))
2907 (gnus-summary-mark-as-spam
2909 :visible (and (fboundp 'spam-group-ham-contents-p)
2910 (spam-group-ham-contents-p gnus-newsgroup-name))
2911 :help "Mark as spam")
2912 (gnus-summary-mark-as-read-forward
2914 :visible (and (fboundp 'spam-group-spam-contents-p)
2915 (spam-group-spam-contents-p gnus-newsgroup-name)))
2917 (gnus-summary-exit "exit")
2918 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2919 (gnus-info-find-node "help"))
2920 "List of functions for the summary tool bar (GNOME style).
2922 See `gmm-tool-bar-from-list' for the format of the list."
2923 :type '(repeat gmm-tool-bar-item)
2924 :version "23.1" ;; No Gnus
2925 :initialize 'custom-initialize-default
2926 :set 'gnus-summary-tool-bar-update
2927 :group 'gnus-summary)
2929 (defcustom gnus-summary-tool-bar-retro
2930 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2931 (gnus-summary-next-unread-article "gnus/next-ur")
2932 (gnus-summary-post-news "gnus/post")
2933 (gnus-summary-followup-with-original "gnus/fuwo")
2934 (gnus-summary-followup "gnus/followup")
2935 (gnus-summary-reply-with-original "gnus/reply-wo")
2936 (gnus-summary-reply "gnus/reply")
2937 (gnus-summary-caesar-message "gnus/rot13")
2938 (gnus-uu-decode-uu "gnus/uu-decode")
2939 (gnus-summary-save-article-file "gnus/save-aif")
2940 (gnus-summary-save-article "gnus/save-art")
2941 (gnus-uu-post-news "gnus/uu-post")
2942 (gnus-summary-catchup "gnus/catchup")
2943 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2944 (gnus-summary-exit "gnus/exit-summ")
2945 ;; Some new command that may need more suitable icons:
2946 (gnus-summary-print-article "gnus/print" nil :visible nil)
2947 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2948 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2949 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2950 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2951 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2952 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2954 (gnus-info-find-node "gnus/help" nil :visible nil))
2955 "List of functions for the summary tool bar (retro look).
2957 See `gmm-tool-bar-from-list' for the format of the list."
2958 :type '(repeat gmm-tool-bar-item)
2959 :version "23.1" ;; No Gnus
2960 :initialize 'custom-initialize-default
2961 :set 'gnus-summary-tool-bar-update
2962 :group 'gnus-summary)
2964 (defcustom gnus-summary-tool-bar-zap-list t
2965 "List of icon items from the global tool bar.
2966 These items are not displayed in the Gnus summary mode tool bar.
2968 See `gmm-tool-bar-from-list' for the format of the list."
2969 :type 'gmm-tool-bar-zap-list
2970 :version "23.1" ;; No Gnus
2971 :initialize 'custom-initialize-default
2972 :set 'gnus-summary-tool-bar-update
2973 :group 'gnus-summary)
2975 (defvar image-load-path)
2976 (defvar tool-bar-map)
2978 (defun gnus-summary-make-tool-bar (&optional force)
2979 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2980 When FORCE, rebuild the tool bar."
2981 (when (and (not (featurep 'xemacs))
2982 (boundp 'tool-bar-mode)
2984 (or (not gnus-summary-tool-bar-map) force))
2986 (gmm-image-load-path-for-library "gnus"
2989 (image-load-path (cons (car load-path)
2990 (when (boundp 'image-load-path)
2992 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2993 gnus-summary-tool-bar-zap-list
2994 'gnus-summary-mode-map)))
2996 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2998 (setq gnus-summary-tool-bar-map map))))
2999 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
3001 (defun gnus-make-score-map (type)
3002 "Make a summary score map of type TYPE."
3005 (let ((headers '(("author" "from" string)
3006 ("subject" "subject" string)
3007 ("article body" "body" string)
3008 ("article head" "head" string)
3009 ("xref" "xref" string)
3010 ("extra header" "extra" string)
3011 ("lines" "lines" number)
3012 ("followups to author" "followup" string)))
3013 (types '((number ("less than" <)
3016 (string ("substring" s)
3020 (perms '(("temporary" (current-time-string))
3028 (if (eq type 'lower)
3033 (setq header (car headers))
3039 (let ((ts (cdr (assoc (nth 2 header) types)))
3055 'gnus-summary-score-entry
3057 (if (or (string= (nth 1 header)
3059 (string= (nth 1 header)
3062 (list 'gnus-summary-header
3064 (list 'quote (nth 1 (car ts)))
3065 (list 'gnus-score-delta-default
3072 (list (nreverse outp))))
3075 (list (nreverse outt))))
3077 (setq headers (cdr headers)))
3078 (list (nreverse outh))))))))
3081 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3082 (defvar bookmark-make-record-function)
3084 (defvar bidi-paragraph-direction)
3086 (defun gnus-summary-mode (&optional group)
3087 "Major mode for reading articles.
3089 All normal editing commands are switched off.
3090 \\<gnus-summary-mode-map>
3091 Each line in this buffer represents one article. To read an
3092 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3093 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3096 You can also post articles and send mail from this buffer. To
3097 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3098 of an article, type `\\[gnus-summary-reply]'.
3100 There are approx. one gazillion commands you can execute in this
3101 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3103 The following commands are available:
3105 \\{gnus-summary-mode-map}"
3106 ;; FIXME: Use define-derived-mode.
3108 (kill-all-local-variables)
3109 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3110 (gnus-summary-make-local-variables))
3111 (gnus-summary-make-local-variables)
3112 (setq gnus-newsgroup-name group)
3113 (when (gnus-visual-p 'summary-menu 'menu)
3114 (gnus-summary-make-menu-bar)
3115 (gnus-summary-make-tool-bar))
3116 (gnus-make-thread-indent-array)
3117 (gnus-simplify-mode-line)
3118 (setq major-mode 'gnus-summary-mode)
3119 (setq mode-name "Summary")
3120 (use-local-map gnus-summary-mode-map)
3121 (buffer-disable-undo)
3122 (setq buffer-read-only t ;Disable modification
3123 show-trailing-whitespace nil)
3124 (setq truncate-lines t)
3125 ;; Force paragraph direction to be left-to-right. Don't make it
3126 ;; bound globally in old Emacsen and XEmacsen.
3127 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3128 (add-to-invisibility-spec '(gnus-sum . t))
3129 (gnus-summary-set-display-table)
3130 (gnus-set-default-directory)
3131 (make-local-variable 'gnus-summary-line-format)
3132 (make-local-variable 'gnus-summary-line-format-spec)
3133 (make-local-variable 'gnus-summary-dummy-line-format)
3134 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3135 (make-local-variable 'gnus-summary-mark-positions)
3136 (gnus-make-local-hook 'pre-command-hook)
3137 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3138 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3139 (turn-on-gnus-mailing-list-mode)
3140 (mm-enable-multibyte)
3141 (set (make-local-variable 'bookmark-make-record-function)
3142 'gnus-summary-bookmark-make-record)
3143 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3144 (gnus-update-summary-mark-positions))
3146 (defun gnus-summary-make-local-variables ()
3147 "Make all the local summary buffer variables."
3149 (dolist (local gnus-summary-local-variables)
3152 (if (eq (cdr local) 'global)
3153 ;; Copy the global value of the variable.
3154 (setq global (symbol-value (car local)))
3155 ;; Use the value from the list.
3156 (setq global (eval (cdr local))))
3157 (set (make-local-variable (car local)) global))
3158 ;; Simple nil-valued local variable.
3159 (set (make-local-variable local) nil)))))
3161 ;; Summary data functions.
3163 (defmacro gnus-data-number (data)
3166 (defmacro gnus-data-set-number (data number)
3167 `(setcar ,data ,number))
3169 (defmacro gnus-data-mark (data)
3172 (defmacro gnus-data-set-mark (data mark)
3173 `(setcar (nthcdr 1 ,data) ,mark))
3175 (defmacro gnus-data-pos (data)
3178 (defmacro gnus-data-set-pos (data pos)
3179 `(setcar (nthcdr 2 ,data) ,pos))
3181 (defmacro gnus-data-header (data)
3184 (defmacro gnus-data-set-header (data header)
3185 `(setf (nth 3 ,data) ,header))
3187 (defmacro gnus-data-level (data)
3190 (defmacro gnus-data-unread-p (data)
3191 `(= (nth 1 ,data) gnus-unread-mark))
3193 (defmacro gnus-data-read-p (data)
3194 `(/= (nth 1 ,data) gnus-unread-mark))
3196 (defmacro gnus-data-pseudo-p (data)
3197 `(consp (nth 3 ,data)))
3199 (defmacro gnus-data-find (number)
3200 `(assq ,number gnus-newsgroup-data))
3202 (defmacro gnus-data-find-list (number &optional data)
3203 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3204 (memq (assq ,number bdata)
3207 (defmacro gnus-data-make (number mark pos header level)
3208 `(list ,number ,mark ,pos ,header ,level))
3210 (defun gnus-data-enter (after-article number mark pos header level offset)
3211 (let ((data (gnus-data-find-list after-article)))
3213 (error "No such article: %d" after-article))
3214 (setcdr data (cons (gnus-data-make number mark pos header level)
3216 (setq gnus-newsgroup-data-reverse nil)
3217 (gnus-data-update-list (cddr data) offset)))
3219 (defun gnus-data-enter-list (after-article list &optional offset)
3221 (let ((data (and after-article (gnus-data-find-list after-article)))
3225 (let ((odata gnus-newsgroup-data))
3226 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3228 (gnus-data-update-list odata offset)))
3229 ;; Find the last element in the list to be spliced into the main
3231 (setq list (last list))
3234 (setcdr list gnus-newsgroup-data)
3235 (setq gnus-newsgroup-data ilist)
3237 (gnus-data-update-list (cdr list) offset)))
3238 (setcdr list (cdr data))
3241 (gnus-data-update-list (cdr list) offset))))
3242 (setq gnus-newsgroup-data-reverse nil))))
3244 (defun gnus-data-remove (article &optional offset)
3245 (let ((data gnus-newsgroup-data))
3246 (if (= (gnus-data-number (car data)) article)
3248 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3249 gnus-newsgroup-data-reverse nil)
3251 (gnus-data-update-list gnus-newsgroup-data offset)))
3253 (when (= (gnus-data-number (cadr data)) article)
3254 (setcdr data (cddr data))
3256 (gnus-data-update-list (cdr data) offset))
3258 gnus-newsgroup-data-reverse nil))
3259 (setq data (cdr data))))))
3261 (defmacro gnus-data-list (backward)
3263 (or gnus-newsgroup-data-reverse
3264 (setq gnus-newsgroup-data-reverse
3265 (reverse gnus-newsgroup-data)))
3266 gnus-newsgroup-data))
3268 (defun gnus-data-update-list (data offset)
3269 "Add OFFSET to the POS of all data entries in DATA."
3270 (setq gnus-newsgroup-data-reverse nil)
3272 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3273 (setq data (cdr data))))
3275 (defun gnus-summary-article-pseudo-p (article)
3276 "Say whether this article is a pseudo article or not."
3277 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3279 (defmacro gnus-summary-article-sparse-p (article)
3280 "Say whether this article is a sparse article or not."
3281 `(memq ,article gnus-newsgroup-sparse))
3283 (defmacro gnus-summary-article-ancient-p (article)
3284 "Say whether this article is a sparse article or not."
3285 `(memq ,article gnus-newsgroup-ancient))
3287 (defun gnus-article-children (number)
3288 "Return a list of all children to NUMBER."
3289 (let* ((data (gnus-data-find-list number))
3290 (level (gnus-data-level (car data)))
3292 (setq data (cdr data))
3294 (= (gnus-data-level (car data)) (1+ level)))
3295 (push (gnus-data-number (car data)) children)
3296 (setq data (cdr data)))
3299 (defmacro gnus-summary-skip-intangible ()
3300 "If the current article is intangible, then jump to a different article."
3301 '(let ((to (get-text-property (point) 'gnus-intangible)))
3302 (and to (gnus-summary-goto-subject to))))
3304 (defmacro gnus-summary-article-intangible-p ()
3305 "Say whether this article is intangible or not."
3306 '(get-text-property (point) 'gnus-intangible))
3308 ;; Some summary mode macros.
3310 (defmacro gnus-summary-article-number ()
3311 "The article number of the article on the current line.
3312 If there isn't an article number here, then we return the current
3315 (gnus-summary-skip-intangible)
3316 (or (get-text-property (point) 'gnus-number)
3317 (gnus-summary-last-subject))))
3319 (defmacro gnus-summary-article-header (&optional number)
3320 "Return the header of article NUMBER."
3321 `(gnus-data-header (gnus-data-find
3322 ,(or number '(gnus-summary-article-number)))))
3324 (defmacro gnus-summary-thread-level (&optional number)
3325 "Return the level of thread that starts with article NUMBER."
3326 `(if (and (eq gnus-summary-make-false-root 'dummy)
3327 (get-text-property (point) 'gnus-intangible))
3329 (gnus-data-level (gnus-data-find
3330 ,(or number '(gnus-summary-article-number))))))
3332 (defmacro gnus-summary-article-mark (&optional number)
3333 "Return the mark of article NUMBER."
3334 `(gnus-data-mark (gnus-data-find
3335 ,(or number '(gnus-summary-article-number)))))
3337 (defmacro gnus-summary-article-pos (&optional number)
3338 "Return the position of the line of article NUMBER."
3339 `(gnus-data-pos (gnus-data-find
3340 ,(or number '(gnus-summary-article-number)))))
3342 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3343 (defmacro gnus-summary-article-subject (&optional number)
3344 "Return current subject string or nil if nothing."
3347 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3348 '(gnus-data-header (assq (gnus-summary-article-number)
3349 gnus-newsgroup-data)))))
3352 (mail-header-subject headers))))
3354 (defmacro gnus-summary-article-score (&optional number)
3355 "Return current article score."
3356 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3357 gnus-newsgroup-scored))
3358 gnus-summary-default-score 0))
3360 (defun gnus-summary-article-children (&optional number)
3361 "Return a list of article numbers that are children of article NUMBER."
3362 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3363 (level (gnus-data-level (car data)))
3365 (while (and (setq data (cdr data))
3366 (> (setq l (gnus-data-level (car data))) level))
3367 (and (= (1+ level) l)
3368 (push (gnus-data-number (car data))
3370 (nreverse children)))
3372 (defun gnus-summary-article-parent (&optional number)
3373 "Return the article number of the parent of article NUMBER."
3374 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3375 (gnus-data-list t)))
3376 (level (gnus-data-level (car data))))
3378 () ; This is a root.
3379 ;; We search until we find an article with a level less than
3380 ;; this one. That function has to be the parent.
3381 (while (and (setq data (cdr data))
3382 (not (< (gnus-data-level (car data)) level))))
3383 (and data (gnus-data-number (car data))))))
3385 (defun gnus-unread-mark-p (mark)
3386 "Say whether MARK is the unread mark."
3387 (= mark gnus-unread-mark))
3389 (defun gnus-read-mark-p (mark)
3390 "Say whether MARK is one of the marks that mark as read.
3391 This is all marks except unread, ticked, dormant, and expirable."
3392 (not (or (= mark gnus-unread-mark)
3393 (= mark gnus-ticked-mark)
3394 (= mark gnus-spam-mark)
3395 (= mark gnus-dormant-mark)
3396 (= mark gnus-expirable-mark))))
3398 (defmacro gnus-article-mark (number)
3399 "Return the MARK of article NUMBER.
3400 This macro should only be used when computing the mark the \"first\"
3401 time; i.e., when generating the summary lines. After that,
3402 `gnus-summary-article-mark' should be used to examine the
3405 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3406 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3407 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3408 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3409 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3410 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3411 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3412 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3413 gnus-ancient-mark))))
3415 ;; Saving hidden threads.
3417 (defmacro gnus-save-hidden-threads (&rest forms)
3418 "Save hidden threads, eval FORMS, and restore the hidden threads."
3419 (let ((config (make-symbol "config")))
3420 `(let ((,config (gnus-hidden-threads-configuration)))
3424 (gnus-restore-hidden-threads-configuration ,config)))))
3425 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3426 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3428 (defun gnus-data-compute-positions ()
3429 "Compute the positions of all articles."
3430 (setq gnus-newsgroup-data-reverse nil)
3431 (let ((data gnus-newsgroup-data))
3433 (gnus-save-hidden-threads
3434 (gnus-summary-show-all-threads)
3435 (goto-char (point-min))
3437 (while (get-text-property (point) 'gnus-intangible)
3439 (gnus-data-set-pos (car data) (+ (point) 3))
3440 (setq data (cdr data))
3441 (forward-line 1))))))
3443 (defun gnus-hidden-threads-configuration ()
3444 "Return the current hidden threads configuration."
3447 (goto-char (point-min))
3449 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3450 (push (save-excursion (forward-line 0) (point)) config))
3454 (defun gnus-restore-hidden-threads-configuration (config)
3455 "Restore hidden threads configuration from CONFIG."
3457 (let (point (inhibit-read-only t))
3458 (while (setq point (pop config))
3460 (gnus-summary-hide-thread)))))
3462 ;; Various summary mode internalish functions.
3464 (defun gnus-mouse-pick-article (e)
3467 (gnus-summary-next-page nil t))
3469 (defun gnus-summary-set-display-table ()
3470 "Change the display table.
3471 Odd characters have a tendency to mess
3472 up nicely formatted displays - we make all possible glyphs
3473 display only a single character."
3475 ;; We start from the standard display table, if any.
3476 (let ((table (or (copy-sequence standard-display-table)
3477 (make-display-table)))
3479 ;; Nix out all the control chars...
3480 (while (>= (setq i (1- i)) 0)
3481 (gnus-put-display-table i [??] table))
3482 ;; ... but not newline and cr, of course. (cr is necessary for the
3483 ;; selective display).
3484 (gnus-put-display-table ?\n nil table)
3485 (gnus-put-display-table ?\r nil table)
3486 ;; We keep TAB as well.
3487 (gnus-put-display-table ?\t nil table)
3488 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3489 ;; Emacs 23 (unicode), that are not set already.
3490 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3493 (while (>= (setq i (1- i)) 127)
3494 ;; Only modify if the entry is nil.
3495 (unless (gnus-get-display-table i table)
3496 (gnus-put-display-table i [??] table))))
3497 (setq buffer-display-table table)))
3499 (defun gnus-summary-set-article-display-arrow (pos)
3500 "Update the overlay arrow to point to line at position POS."
3501 (when gnus-summary-display-arrow
3502 (make-local-variable 'overlay-arrow-position)
3503 (make-local-variable 'overlay-arrow-string)
3507 (unless overlay-arrow-position
3508 (setq overlay-arrow-position (make-marker)))
3509 (setq overlay-arrow-string "=>"
3510 overlay-arrow-position (set-marker overlay-arrow-position
3512 (current-buffer))))))
3514 (defun gnus-summary-setup-buffer (group)
3515 "Initialize summary buffer.
3516 If the setup was successful, non-nil is returned."
3517 (let ((buffer (gnus-summary-buffer-name group))
3518 (dead-name (concat "*Dead Summary "
3519 (gnus-group-decoded-name group) "*")))
3520 ;; If a dead summary buffer exists, we kill it.
3521 (when (gnus-buffer-live-p dead-name)
3522 (gnus-kill-buffer dead-name))
3523 (if (get-buffer buffer)
3526 (setq gnus-summary-buffer (current-buffer))
3527 (not gnus-newsgroup-prepared))
3528 (set-buffer (gnus-get-buffer-create buffer))
3529 (setq gnus-summary-buffer (current-buffer))
3530 (gnus-summary-mode group)
3531 (when (gnus-group-quit-config group)
3532 (set (make-local-variable 'gnus-single-article-buffer) nil))
3533 (make-local-variable 'gnus-article-buffer)
3534 (make-local-variable 'gnus-article-current)
3535 (make-local-variable 'gnus-original-article-buffer)
3536 (setq gnus-newsgroup-name group)
3537 ;; Set any local variables in the group parameters.
3538 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3541 (defun gnus-set-global-variables ()
3542 "Set the global equivalents of the buffer-local variables.
3543 They are set to the latest values they had. These reflect the summary
3544 buffer that was in action when the last article was fetched."
3545 (when (derived-mode-p 'gnus-summary-mode)
3546 (setq gnus-summary-buffer (current-buffer))
3547 (let ((name gnus-newsgroup-name)
3548 (marked gnus-newsgroup-marked)
3549 (spam gnus-newsgroup-spam-marked)
3550 (unread gnus-newsgroup-unreads)
3551 (headers gnus-current-headers)
3552 (data gnus-newsgroup-data)
3553 (summary gnus-summary-buffer)
3554 (article-buffer gnus-article-buffer)
3555 (original gnus-original-article-buffer)
3556 (gac gnus-article-current)
3557 (reffed gnus-reffed-article-number)
3558 (score-file gnus-current-score-file)
3559 (default-charset gnus-newsgroup-charset)
3561 (let ((locals gnus-newsgroup-variables))
3563 (if (consp (car locals))
3564 (push (eval (caar locals)) vlist)
3565 (push (eval (car locals)) vlist))
3566 (setq locals (cdr locals)))
3567 (setq vlist (nreverse vlist)))
3569 (setq gnus-newsgroup-name name
3570 gnus-newsgroup-marked marked
3571 gnus-newsgroup-spam-marked spam
3572 gnus-newsgroup-unreads unread
3573 gnus-current-headers headers
3574 gnus-newsgroup-data data
3575 gnus-article-current gac
3576 gnus-summary-buffer summary
3577 gnus-article-buffer article-buffer
3578 gnus-original-article-buffer original
3579 gnus-reffed-article-number reffed
3580 gnus-current-score-file score-file
3581 gnus-newsgroup-charset default-charset)
3582 (let ((locals gnus-newsgroup-variables))
3584 (if (consp (car locals))
3585 (set (caar locals) (pop vlist))
3586 (set (car locals) (pop vlist)))
3587 (setq locals (cdr locals))))))))
3589 (defun gnus-summary-article-unread-p (article)
3590 "Say whether ARTICLE is unread or not."
3591 (memq article gnus-newsgroup-unreads))
3593 (defun gnus-summary-first-article-p (&optional article)
3594 "Return whether ARTICLE is the first article in the buffer."
3595 (if (not (setq article (or article (gnus-summary-article-number))))
3597 (eq article (caar gnus-newsgroup-data))))
3599 (defun gnus-summary-last-article-p (&optional article)
3600 "Return whether ARTICLE is the last article in the buffer."
3601 (if (not (setq article (or article (gnus-summary-article-number))))
3602 ;; All non-existent numbers are the last article. :-)
3604 (not (cdr (gnus-data-find-list article)))))
3606 (defun gnus-make-thread-indent-array (&optional n)
3608 (progn (setq n 200) nil)
3609 (null gnus-thread-indent-array)
3610 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3611 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3612 gnus-thread-indent-array-level gnus-thread-indent-level)
3614 (aset gnus-thread-indent-array n
3615 (make-string (* n gnus-thread-indent-level) ? ))
3618 (defun gnus-update-summary-mark-positions ()
3619 "Compute where the summary marks are to go."
3621 (when (gnus-buffer-exists-p gnus-summary-buffer)
3622 (set-buffer gnus-summary-buffer))
3623 (let ((spec gnus-summary-line-format-spec)
3626 (gnus-set-work-buffer)
3627 (let ((gnus-tmp-unread ?Z)
3628 (gnus-replied-mark ?Z)
3629 (gnus-score-below-mark ?Z)
3630 (gnus-score-over-mark ?Z)
3631 (gnus-undownloaded-mark ?Z)
3632 (gnus-summary-line-format-spec spec)
3633 (gnus-newsgroup-downloadable '(0))
3634 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3635 case-fold-search ignores)
3636 ;; Here, all marks are bound to Z.
3637 (gnus-summary-insert-line header
3638 0 nil t gnus-tmp-unread t nil "" nil 1)
3639 (goto-char (point-min))
3640 ;; Memorize the positions of the same characters as dummy marks.
3641 (while (re-search-forward "[A-D]" nil t)
3642 (push (point) ignores))
3644 ;; We use A-D as dummy marks in order to know column positions
3645 ;; where marks should be inserted.
3646 (setq gnus-tmp-unread ?A
3647 gnus-replied-mark ?B
3648 gnus-score-below-mark ?C
3649 gnus-score-over-mark ?C
3650 gnus-undownloaded-mark ?D)
3651 (gnus-summary-insert-line header
3652 0 nil t gnus-tmp-unread t nil "" nil 1)
3653 ;; Ignore characters which aren't dummy marks.
3655 (delete-region (goto-char (1- p)) p)
3657 (goto-char (point-min))
3658 (setq pos (list (cons 'unread
3659 (and (search-forward "A" nil t)
3660 (- (point) (point-min) 1)))))
3661 (goto-char (point-min))
3662 (push (cons 'replied (and (search-forward "B" nil t)
3663 (- (point) (point-min) 1)))
3665 (goto-char (point-min))
3666 (push (cons 'score (and (search-forward "C" nil t)
3667 (- (point) (point-min) 1)))
3669 (goto-char (point-min))
3670 (push (cons 'download (and (search-forward "D" nil t)
3671 (- (point) (point-min) 1)))
3673 (setq gnus-summary-mark-positions pos))))
3675 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3676 "Insert a dummy root in the summary buffer."
3678 (gnus-add-text-properties
3679 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3680 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3682 (defun gnus-summary-extract-address-component (from)
3683 (or (car (funcall gnus-extract-address-components from))
3686 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3687 (let ((mail-parse-charset gnus-newsgroup-charset)
3688 (ignored-from-addresses (gnus-ignored-from-addresses))
3689 ;; Is it really necessary to do this next part for each summary line?
3690 ;; Luckily, doesn't seem to slow things down much.
3691 (mail-parse-ignored-charsets
3692 (with-current-buffer gnus-summary-buffer
3693 gnus-newsgroup-ignored-charsets)))
3695 (and ignored-from-addresses
3696 (string-match ignored-from-addresses gnus-tmp-from)
3697 (let ((extra-headers (mail-header-extra header))
3701 ((setq to (cdr (assq 'To extra-headers)))
3702 (concat gnus-summary-to-prefix
3704 (gnus-summary-extract-address-component
3705 (funcall gnus-decode-encoded-address-function to)))))
3708 (cdr (assq 'Newsgroups extra-headers))
3710 (memq 'Newsgroups gnus-extra-headers)
3711 (eq (car (gnus-find-method-for-group
3712 gnus-newsgroup-name)) 'nntp)
3713 (gnus-group-real-name gnus-newsgroup-name))))
3714 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3715 (gnus-string-mark-left-to-right
3717 (gnus-summary-extract-address-component gnus-tmp-from))))))
3719 (defun gnus-summary-insert-line (gnus-tmp-header
3720 gnus-tmp-level gnus-tmp-current
3721 undownloaded gnus-tmp-unread gnus-tmp-replied
3722 gnus-tmp-expirable gnus-tmp-subject-or-nil
3723 &optional gnus-tmp-dummy gnus-tmp-score
3725 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3726 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3728 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3729 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3730 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3731 (gnus-tmp-score-char
3732 (if (or (null gnus-summary-default-score)
3733 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3734 gnus-summary-zcore-fuzz))
3736 (if (< gnus-tmp-score gnus-summary-default-score)
3737 gnus-score-below-mark gnus-score-over-mark)))
3738 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3740 (cond (gnus-tmp-process gnus-process-mark)
3741 ((memq gnus-tmp-current gnus-newsgroup-cached)
3743 (gnus-tmp-replied gnus-replied-mark)
3744 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3745 gnus-forwarded-mark)
3746 ((memq gnus-tmp-current gnus-newsgroup-saved)
3748 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3751 (gnus-tmp-downloaded
3753 gnus-undownloaded-mark)
3754 (gnus-newsgroup-agentized
3755 gnus-downloaded-mark)
3758 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3761 ((string-match "<[^>]+> *$" gnus-tmp-from)
3762 (let ((beg (match-beginning 0)))
3763 (or (and (string-match "^\".+\"" gnus-tmp-from)
3764 (substring gnus-tmp-from 1 (1- (match-end 0))))
3765 (substring gnus-tmp-from 0 beg))))
3766 ((string-match "(.+)" gnus-tmp-from)
3767 (substring gnus-tmp-from
3768 (1+ (match-beginning 0)) (1- (match-end 0))))
3770 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3771 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3772 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3773 (inhibit-read-only t))
3774 (when (string= gnus-tmp-name "")
3775 (setq gnus-tmp-name gnus-tmp-from))
3776 (unless (numberp gnus-tmp-lines)
3777 (setq gnus-tmp-lines -1))
3778 (if (= gnus-tmp-lines -1)
3779 (setq gnus-tmp-lines "?")
3780 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3782 (gnus-put-text-property
3784 (progn (eval gnus-summary-line-format-spec) (point))
3785 'gnus-number gnus-tmp-number)
3786 (error (gnus-message 5 "Error updating the summary line")))
3787 (when (gnus-visual-p 'summary-highlight 'highlight)
3789 (gnus-summary-highlight-line)
3790 (gnus-run-hooks 'gnus-summary-update-hook)
3793 (defun gnus-summary-update-line (&optional dont-update)
3794 "Update summary line after change."
3795 (when (and gnus-summary-default-score
3796 (not gnus-summary-inhibit-highlight))
3797 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3798 (article (gnus-summary-article-number))
3799 (score (gnus-summary-article-score article)))
3801 (if (and gnus-summary-mark-below
3802 (< (gnus-summary-article-score)
3803 gnus-summary-mark-below))
3804 ;; This article has a low score, so we mark it as read.
3805 (when (memq article gnus-newsgroup-unreads)
3806 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3807 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3808 ;; This article was previously marked as read on account
3809 ;; of a low score, but now it has risen, so we mark it as
3811 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3812 (gnus-summary-update-mark
3813 (if (or (null gnus-summary-default-score)
3814 (<= (abs (- score gnus-summary-default-score))
3815 gnus-summary-zcore-fuzz))
3817 (if (< score gnus-summary-default-score)
3818 gnus-score-below-mark gnus-score-over-mark))
3820 ;; Do visual highlighting.
3821 (when (gnus-visual-p 'summary-highlight 'highlight)
3822 (gnus-summary-highlight-line)
3823 (gnus-run-hooks 'gnus-summary-update-hook)))))
3825 (defvar gnus-tmp-new-adopts nil)
3827 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3828 "Return the number of articles in THREAD.
3829 This may be 0 in some cases -- if none of the articles in
3830 the thread are to be displayed."
3832 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3834 ((not (listp thread))
3836 ((and (consp thread) (cdr thread))
3839 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3842 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3845 (when (and level (zerop level) gnus-tmp-new-adopts)
3848 'gnus-summary-number-of-articles-in-thread
3849 gnus-tmp-new-adopts))))
3851 (if (> number 1) gnus-not-empty-thread-mark
3852 gnus-empty-thread-mark)
3855 (defsubst gnus-summary-line-message-size (head)
3856 "Return pretty-printed version of message size.
3857 This function is intended to be used in
3858 `gnus-summary-line-format-alist'."
3859 (let ((c (or (mail-header-chars head) -1)))
3860 (cond ((< c 0) "n/a") ; chars not available
3861 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3862 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3863 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3864 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3866 (defcustom gnus-user-date-format-alist
3867 '(((gnus-seconds-today) . "Today, %H:%M")
3868 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3869 (604800 . "%A %H:%M") ; That's one week
3870 ((gnus-seconds-month) . "%A %d")
3871 ((gnus-seconds-year) . "%B %d")
3872 (t . "%b %d %Y")) ; This one is used when no other
3874 "Specifies date format depending on age of article.
3875 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3876 seconds) or a Lisp expression evaluating to a number. When the age of
3877 the article is less than this number, then use `format-time-string'
3878 with the corresponding FORMAT for displaying the date of the article.
3879 If AGE is not a number or a Lisp expression evaluating to a
3880 non-number, then the corresponding FORMAT is used as a default value.
3882 Note that the list is processed from the beginning, so it should be
3883 sorted by ascending AGE. Also note that items following the first
3884 non-number AGE will be ignored.
3886 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3887 and `gnus-seconds-year' in the AGE spec. They return the number of
3888 seconds passed since the start of today, of this month, of this year,
3891 :group 'gnus-summary-format
3892 :type '(alist :key-type sexp :value-type string))
3894 (defun gnus-user-date (messy-date)
3895 "Format the messy-date according to `gnus-user-date-format-alist'.
3896 Returns \" ? \" if there's bad input or if another error occurs.
3897 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3899 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3900 (now (gnus-float-time))
3901 ;;If we don't find something suitable we'll use this one
3902 (my-format "%b %d '%y"))
3903 (let* ((difference (- now messy-date))
3904 (templist gnus-user-date-format-alist)
3905 (top (eval (caar templist))))
3906 (while (if (numberp top) (< top difference) (not top))
3908 (setq templist (cdr templist))
3909 (setq top (eval (caar templist)))))
3910 (if (stringp (cdr (car templist)))
3911 (setq my-format (cdr (car templist)))))
3912 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3915 (defun gnus-summary-set-local-parameters (group)
3916 "Go through the local params of GROUP and set all variable specs in that list."
3917 (let ((vars '(quit-config active))) ; Ignore things that aren't
3919 (dolist (elem (gnus-group-find-parameter group))
3920 (and (consp elem) ; Has to be a cons.
3921 (consp (cdr elem)) ; The cdr has to be a list.
3922 (symbolp (car elem)) ; Has to be a symbol in there.
3923 (not (memq (car elem) vars))
3925 (push (car elem) vars)
3926 ;; Variables like `gnus-show-threads' that are globally
3927 ;; bound, if used as group parameters, need to get to be
3928 ;; buffer-local, whereas just parameters like `gcc-self',
3929 ;; `timestamp', etc. should not be bound as variables.
3930 (if (boundp (car elem))
3931 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3932 (eval (nth 1 elem))))))))
3934 (defun gnus-summary-read-group (group &optional show-all no-article
3935 kill-buffer no-display backward
3937 "Start reading news in newsgroup GROUP.
3938 If SHOW-ALL is non-nil, already read articles are also listed.
3939 If NO-ARTICLE is non-nil, no article is selected initially.
3940 If NO-DISPLAY, don't generate the summary buffer contents.
3941 If KILL-BUFFER, it should be a buffer that's killed once the new
3942 summary buffer has been generated.
3943 If BACKWARD, move point to the previous group in the group buffer
3944 If SELECT-ARTICLES, only select those articles from GROUP."
3948 (let ((gnus-auto-select-next nil))
3949 (or (gnus-summary-read-group-1
3950 group show-all no-article
3951 kill-buffer no-display
3954 select-articles nil)))))
3955 (eq gnus-auto-select-next 'quietly))
3956 (set-buffer gnus-group-buffer)
3957 ;; The entry function called above goes to the next
3958 ;; group automatically, so we go two groups back
3959 ;; if we are searching for the previous group.
3961 (gnus-group-prev-unread-group 2))
3962 (if (not (equal group (gnus-group-group-name)))
3963 (setq group (gnus-group-group-name))
3967 (defun gnus-summary-read-group-1 (group show-all no-article
3968 kill-buffer no-display
3969 &optional select-articles)
3970 ;; Killed foreign groups can't be entered.
3971 ;; (when (and (not (gnus-group-native-p group))
3972 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3973 ;; (error "Dead non-native groups can't be entered"))
3974 (gnus-message 7 "Retrieving newsgroup: %s..."
3975 (gnus-group-decoded-name group))
3976 (let* ((new-group (gnus-summary-setup-buffer group))
3977 (quit-config (gnus-group-quit-config group))
3978 (did-select (and new-group (gnus-select-newsgroup
3979 group show-all select-articles))))
3981 ;; This summary buffer exists already, so we just select it.
3983 (gnus-set-global-variables)
3985 (gnus-kill-or-deaden-summary kill-buffer))
3986 (gnus-configure-windows 'summary 'force)
3987 (gnus-set-mode-line 'summary)
3988 (gnus-summary-position-point)
3991 ;; We couldn't select this group.
3993 (when (and (derived-mode-p 'gnus-summary-mode)
3994 (not (equal (current-buffer) kill-buffer)))
3995 (kill-buffer (current-buffer))
3996 (if (not quit-config)
3998 ;; Update the info -- marks might need to be removed,
4000 (gnus-summary-update-info)
4001 (set-buffer gnus-group-buffer)
4002 (gnus-group-jump-to-group group)
4003 (gnus-group-next-unread-group 1))
4004 (gnus-handle-ephemeral-exit quit-config)))
4005 (if (null (gnus-list-of-unread-articles group))
4006 (gnus-message 3 "Group %s contains no messages" group)
4007 (gnus-message 3 "Can't select group"))
4009 ;; The user did a `C-g' while prompting for number of articles,
4010 ;; so we exit this group.
4011 ((eq did-select 'quit)
4012 (and (derived-mode-p 'gnus-summary-mode)
4013 (not (equal (current-buffer) kill-buffer))
4014 (kill-buffer (current-buffer)))
4016 (gnus-kill-or-deaden-summary kill-buffer))
4017 (if (not quit-config)
4019 (set-buffer gnus-group-buffer)
4020 (gnus-group-jump-to-group group)
4021 (gnus-configure-windows 'group 'force))
4022 (gnus-handle-ephemeral-exit quit-config))
4023 ;; Finally signal the quit.
4025 ;; The group was successfully selected.
4027 (gnus-set-global-variables)
4028 (when (boundp 'spam-install-hooks)
4030 ;; Save the active value in effect when the group was entered.
4031 (setq gnus-newsgroup-active
4033 (gnus-active gnus-newsgroup-name)))
4034 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4035 ;; You can change the summary buffer in some way with this hook.
4036 (gnus-run-hooks 'gnus-select-group-hook)
4037 (when (memq 'summary (gnus-update-format-specifications
4038 nil 'summary 'summary-mode 'summary-dummy))
4039 ;; The format specification for the summary line was updated,
4040 ;; so we need to update the mark positions as well.
4041 (gnus-update-summary-mark-positions))
4042 ;; Do score processing.
4043 (when gnus-use-scoring
4044 (gnus-possibly-score-headers))
4045 ;; Check whether to fill in the gaps in the threads.
4046 (when gnus-build-sparse-threads
4047 (gnus-build-sparse-threads))
4048 ;; Find the initial limit.
4050 (let ((gnus-newsgroup-dormant nil))
4051 (gnus-summary-initial-limit show-all))
4052 (gnus-summary-initial-limit show-all))
4053 ;; Generate the summary buffer.
4055 (gnus-summary-prepare))
4056 (when gnus-use-trees
4058 (setq gnus-summary-highlight-line-function
4059 'gnus-tree-highlight-article))
4060 ;; If the summary buffer is empty, but there are some low-scored
4061 ;; articles or some excluded dormants, we include these in the
4063 (when (and (zerop (buffer-size))
4065 (cond (gnus-newsgroup-dormant
4066 (gnus-summary-limit-include-dormant))
4067 ((and gnus-newsgroup-scored show-all)
4068 (gnus-summary-limit-include-expunged t))))
4069 ;; Function `gnus-apply-kill-file' must be called in this hook.
4070 (gnus-run-hooks 'gnus-apply-kill-hook)
4071 (if (and (zerop (buffer-size))
4074 ;; This newsgroup is empty.
4075 (gnus-summary-catchup-and-exit nil t)
4076 (gnus-message 6 "No unread news")
4078 (gnus-kill-or-deaden-summary kill-buffer))
4079 ;; Return nil from this function.
4081 ;; Hide conversation thread subtrees. We cannot do this in
4082 ;; gnus-summary-prepare-hook since kill processing may not
4083 ;; work with hidden articles.
4084 (gnus-summary-maybe-hide-threads)
4085 (gnus-configure-windows 'summary)
4087 (gnus-kill-or-deaden-summary kill-buffer))
4088 (gnus-summary-auto-select-subject)
4089 ;; Show first unread article if requested.
4090 (if (and (not no-article)
4092 gnus-newsgroup-unreads
4093 gnus-auto-select-first)
4095 (let ((art (gnus-summary-article-number)))
4098 (not (memq art gnus-newsgroup-undownloaded))
4099 (not (memq art gnus-newsgroup-downloadable)))
4100 (gnus-summary-goto-article art))))
4101 ;; Don't select any articles.
4102 (gnus-summary-position-point)
4103 (gnus-configure-windows 'summary 'force)
4104 (gnus-set-mode-line 'summary))
4105 (when (and gnus-auto-center-group
4106 (get-buffer-window gnus-group-buffer t))
4107 ;; Gotta use windows, because recenter does weird stuff if
4108 ;; the current buffer ain't the displayed window.
4109 (let ((owin (selected-window)))
4110 (select-window (get-buffer-window gnus-group-buffer t))
4111 (when (gnus-group-goto-group group)
4113 (select-window owin)))
4114 ;; Mark this buffer as "prepared".
4115 (setq gnus-newsgroup-prepared t)
4116 (gnus-run-hooks 'gnus-summary-prepared-hook)
4117 (unless (gnus-ephemeral-group-p group)
4118 (gnus-group-update-group group nil t))
4121 (defun gnus-summary-auto-select-subject ()
4122 "Select the subject line on initial group entry."
4123 (goto-char (point-min))
4125 ((eq gnus-auto-select-subject 'best)
4126 (gnus-summary-best-unread-subject))
4127 ((eq gnus-auto-select-subject 'unread)
4128 (gnus-summary-first-unread-subject))
4129 ((eq gnus-auto-select-subject 'unseen)
4130 (gnus-summary-first-unseen-subject))
4131 ((eq gnus-auto-select-subject 'unseen-or-unread)
4132 (gnus-summary-first-unseen-or-unread-subject))
4133 ((eq gnus-auto-select-subject 'first)
4136 ((functionp gnus-auto-select-subject)
4137 (funcall gnus-auto-select-subject))))
4139 (defun gnus-summary-prepare ()
4140 "Generate the summary buffer."
4142 (let ((inhibit-read-only t))
4144 (setq gnus-newsgroup-data nil
4145 gnus-newsgroup-data-reverse nil)
4146 (gnus-run-hooks 'gnus-summary-generate-hook)
4147 ;; Generate the buffer, either with threads or without.
4148 (when gnus-newsgroup-headers
4149 (gnus-summary-prepare-threads
4150 (if gnus-show-threads
4151 (gnus-sort-gathered-threads
4152 (funcall gnus-summary-thread-gathering-function
4154 (gnus-cut-threads (gnus-make-threads)))))
4155 ;; Unthreaded display.
4156 (gnus-sort-articles gnus-newsgroup-headers))))
4157 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4158 ;; Call hooks for modifying summary buffer.
4159 (goto-char (point-min))
4160 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4162 (defsubst gnus-general-simplify-subject (subject)
4163 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4166 ;; Truncate the subject.
4167 (gnus-simplify-subject-functions
4168 (gnus-map-function gnus-simplify-subject-functions subject))
4169 ((numberp gnus-summary-gather-subject-limit)
4170 (setq subject (gnus-simplify-subject-re subject))
4171 (if (> (length subject) gnus-summary-gather-subject-limit)
4172 (substring subject 0 gnus-summary-gather-subject-limit)
4174 ;; Fuzzily simplify it.
4175 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4176 (gnus-simplify-subject-fuzzy subject))
4177 ;; Just remove the leading "Re:".
4179 (gnus-simplify-subject-re subject))))
4181 (if (and gnus-summary-gather-exclude-subject
4182 (string-match gnus-summary-gather-exclude-subject subject))
4183 nil ; This article shouldn't be gathered
4186 (defun gnus-summary-simplify-subject-query ()
4187 "Query where the respool algorithm would put this article."
4189 (gnus-summary-select-article)
4190 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4192 (defun gnus-gather-threads-by-subject (threads)
4193 "Gather threads by looking at Subject headers."
4194 (if (not gnus-summary-make-false-root)
4196 (let ((hashtb (gnus-make-hashtable 1024))
4199 subject hthread whole-subject)
4201 (setq subject (gnus-general-simplify-subject
4202 (setq whole-subject (mail-header-subject
4205 (if (setq hthread (gnus-gethash subject hashtb))
4207 ;; We enter a dummy root into the thread, if we
4208 ;; haven't done that already.
4209 (unless (stringp (caar hthread))
4210 (setcar hthread (list whole-subject (car hthread))))
4211 ;; We add this new gathered thread to this gathered
4213 (setcdr (car hthread)
4214 (nconc (cdar hthread) (list (car threads))))
4215 ;; Remove it from the list of threads.
4216 (setcdr prev (cdr threads))
4217 (setq threads prev))
4218 ;; Enter this thread into the hash table.
4219 (gnus-sethash subject
4220 (if gnus-summary-make-false-root-always
4222 ;; If you want a dummy root above all
4224 (setcar threads (list whole-subject
4230 (setq threads (cdr threads)))
4233 (defun gnus-gather-threads-by-references (threads)
4234 "Gather threads by looking at References headers."
4235 (let ((idhashtb (gnus-make-hashtable 1024))
4236 (thhashtb (gnus-make-hashtable 1024))
4239 ids references id gthread gid entered ref)
4241 (when (setq references (mail-header-references (caar threads)))
4242 (setq id (mail-header-id (caar threads))
4243 ids (inline (gnus-split-references references))
4245 (while (setq ref (pop ids))
4246 (setq ids (delete ref ids))
4247 (if (not (setq gid (gnus-gethash ref idhashtb)))
4249 (gnus-sethash ref id idhashtb)
4250 (gnus-sethash id threads thhashtb))
4251 (setq gthread (gnus-gethash gid thhashtb))
4253 ;; We enter a dummy root into the thread, if we
4254 ;; haven't done that already.
4255 (unless (stringp (caar gthread))
4256 (setcar gthread (list (mail-header-subject (caar gthread))
4258 ;; We add this new gathered thread to this gathered
4260 (setcdr (car gthread)
4261 (nconc (cdar gthread) (list (car threads)))))
4262 ;; Add it into the thread hash table.
4263 (gnus-sethash id gthread thhashtb)
4265 ;; Remove it from the list of threads.
4266 (setcdr prev (cdr threads))
4267 (setq threads prev))))
4269 (setq threads (cdr threads)))
4272 (defun gnus-sort-gathered-threads (threads)
4273 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4274 (let ((result threads))
4276 (when (stringp (caar threads))
4277 (setcdr (car threads)
4278 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4279 (setq threads (cdr threads)))
4282 (defun gnus-thread-loop-p (root thread)
4283 "Say whether ROOT is in THREAD."
4284 (let ((stack (list thread))
4287 (while (setq thread (pop stack))
4288 (setq th (cdr thread))
4290 (not (eq (caar th) root)))
4293 ;; We have found a loop.
4295 (setcdr thread (delq (car th) (cdr thread)))
4296 (if (boundp (setq ref-dep (intern "none"
4297 gnus-newsgroup-dependencies)))
4298 (setcdr (symbol-value ref-dep)
4299 (nconc (cdr (symbol-value ref-dep))
4301 (set ref-dep (list nil (car th))))
4304 ;; Push all the subthreads onto the stack.
4305 (push (cdr thread) stack)))
4308 (defun gnus-make-threads ()
4309 "Go through the dependency hashtb and find the roots. Return all threads."
4311 (while (catch 'infloop
4314 ;; Deal with self-referencing References loops.
4315 (when (and (car (symbol-value refs))
4322 (car (symbol-value refs)) thread))
4323 (cdr (symbol-value refs)))))))
4326 (unless (car (symbol-value refs))
4327 ;; These threads do not refer back to any other
4328 ;; articles, so they're roots.
4329 (setq threads (append (cdr (symbol-value refs)) threads))))
4330 gnus-newsgroup-dependencies)))
4333 ;; Build the thread tree.
4334 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4335 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4337 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4338 if it was already present.
4340 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4341 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4342 Message-IDs will be renamed to a unique Message-ID before being
4345 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4346 (let* ((id (mail-header-id header))
4347 (id-dep (and id (intern id dependencies)))
4348 parent-id ref ref-dep ref-header replaced)
4349 ;; Enter this `header' in the `dependencies' table.
4353 ;; The first two cases do the normal part: enter a new `header'
4354 ;; in the `dependencies' table.
4355 ((not (boundp id-dep))
4356 (set id-dep (list header)))
4357 ((null (car (symbol-value id-dep)))
4358 (setcar (symbol-value id-dep) header))
4360 ;; From here the `header' was already present in the
4361 ;; `dependencies' table.
4363 ;; Overrides an existing entry;
4364 ;; just set the header part of the entry.
4365 (setcar (symbol-value id-dep) header)
4368 ;; Renames the existing `header' to a unique Message-ID.
4369 ((not gnus-summary-ignore-duplicates)
4370 ;; An article with this Message-ID has already been seen.
4371 ;; We rename the Message-ID.
4372 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4374 (mail-header-set-id header id))
4376 ;; The last case ignores an existing entry, except it adds any
4377 ;; additional Xrefs (in case the two articles came from different
4379 ;; Also sets `header' to `nil' meaning that the `dependencies'
4380 ;; table was *not* modified.
4382 (mail-header-set-xref
4383 (car (symbol-value id-dep))
4384 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4386 (or (mail-header-xref header) "")))
4389 (when (and header (not replaced))
4390 ;; First check that we are not creating a References loop.
4391 (setq parent-id (gnus-parent-id (mail-header-references header)))
4392 (setq ref parent-id)
4394 (setq ref-dep (intern-soft ref dependencies))
4396 (setq ref-header (car (symbol-value ref-dep))))
4397 (if (string= id ref)
4398 ;; Yuk! This is a reference loop. Make the article be a
4401 (mail-header-set-references (car (symbol-value id-dep)) "none")
4403 (setq parent-id nil))
4404 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4405 (setq ref-dep (intern (or parent-id "none") dependencies))
4406 (if (boundp ref-dep)
4407 (setcdr (symbol-value ref-dep)
4408 (nconc (cdr (symbol-value ref-dep))
4409 (list (symbol-value id-dep))))
4410 (set ref-dep (list nil (symbol-value id-dep)))))
4413 (defun gnus-extract-message-id-from-in-reply-to (string)
4414 (if (string-match "<[^>]+>" string)
4415 (substring string (match-beginning 0) (match-end 0))
4418 (defun gnus-build-sparse-threads ()
4419 (let ((headers gnus-newsgroup-headers)
4420 (mail-parse-charset gnus-newsgroup-charset)
4421 (gnus-summary-ignore-duplicates t)
4422 header references generation relations
4423 subject child end new-child date)
4424 ;; First we create an alist of generations/relations, where
4425 ;; generations is how much we trust the relation, and the relation
4427 (gnus-message 7 "Making sparse threads...")
4429 (nnheader-set-temp-buffer " *gnus sparse threads*")
4430 (while (setq header (pop headers))
4431 (when (and (setq references (mail-header-references header))
4432 (not (string= references "")))
4434 (setq child (mail-header-id header)
4435 subject (mail-header-subject header)
4436 date (mail-header-date header)
4438 (while (search-backward ">" nil t)
4439 (setq end (1+ (point)))
4440 (when (search-backward "<" nil t)
4441 (setq new-child (buffer-substring (point) end))
4442 (push (list (incf generation)
4443 child (setq child new-child)
4447 (push (list (1+ generation) child nil subject) relations))
4449 (kill-buffer (current-buffer)))
4450 ;; Sort over trustworthiness.
4451 (dolist (relation (sort relations 'car-less-than-car))
4452 (when (gnus-dependencies-add-header
4453 (make-full-mail-header
4454 gnus-reffed-article-number
4455 (nth 3 relation) "" (or (nth 4 relation) "")
4457 (or (nth 2 relation) "") 0 0 "")
4458 gnus-newsgroup-dependencies nil)
4459 (push gnus-reffed-article-number gnus-newsgroup-limit)
4460 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4461 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4462 gnus-newsgroup-reads)
4463 (decf gnus-reffed-article-number)))
4464 (gnus-message 7 "Making sparse threads...done")))
4466 (defun gnus-build-old-threads ()
4467 ;; Look at all the articles that refer back to old articles, and
4468 ;; fetch the headers for the articles that aren't there. This will
4469 ;; build complete threads - if the roots haven't been expired by the
4471 (let ((mail-parse-charset gnus-newsgroup-charset)
4475 (when (not (car (symbol-value refs)))
4476 (setq heads (cdr (symbol-value refs)))
4478 (if (memq (mail-header-number (caar heads))
4479 gnus-newsgroup-dormant)
4480 (setq heads (cdr heads))
4481 (setq id (symbol-name refs))
4482 (while (and (setq id (gnus-build-get-header id))
4483 (not (car (gnus-id-to-thread id)))))
4484 (setq heads nil)))))
4485 gnus-newsgroup-dependencies)))
4487 (defsubst gnus-remove-odd-characters (string)
4488 "Translate STRING into something that doesn't contain weird characters."
4489 (mm-subst-char-in-string
4491 (mm-subst-char-in-string ?\n ?\- string t) t))
4493 ;; This function has to be called with point after the article number
4494 ;; on the beginning of the line.
4495 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4496 (let ((eol (point-at-eol))
4497 (buffer (current-buffer))
4498 header references in-reply-to)
4500 ;; overview: [num subject from date id refs chars lines misc]
4503 (narrow-to-region (point) eol)
4508 (make-full-mail-header
4510 (condition-case () ; subject
4511 (gnus-remove-odd-characters
4512 (funcall gnus-decode-encoded-word-function
4513 (setq x (nnheader-nov-field))))
4515 (condition-case () ; from
4516 (gnus-remove-odd-characters
4517 (funcall gnus-decode-encoded-address-function
4518 (setq x (nnheader-nov-field))))
4520 (nnheader-nov-field) ; date
4521 (nnheader-nov-read-message-id number) ; id
4522 (setq references (nnheader-nov-field)) ; refs
4523 (nnheader-nov-read-integer) ; chars
4524 (nnheader-nov-read-integer) ; lines
4526 (if (looking-at "Xref: ")
4527 (goto-char (match-end 0)))
4528 (nnheader-nov-field)) ; Xref
4529 (nnheader-nov-parse-extra)))) ; extra
4533 (when (and (string= references "")
4534 (setq in-reply-to (mail-header-extra header))
4535 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4536 (mail-header-set-references
4537 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4539 (when gnus-alter-header-function
4540 (funcall gnus-alter-header-function header))
4541 (gnus-dependencies-add-header header dependencies force-new)))
4543 (defun gnus-build-get-header (id)
4544 "Look through the buffer of NOV lines and find the header to ID.
4545 Enter this line into the dependencies hash table, and return
4546 the id of the parent article (if any)."
4547 (let ((deps gnus-newsgroup-dependencies)
4550 (with-current-buffer nntp-server-buffer
4551 (let ((case-fold-search nil))
4552 (goto-char (point-min))
4553 (while (and (not found)
4554 (search-forward id nil t))
4556 (setq found (looking-at
4557 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4558 (regexp-quote id))))
4559 (or found (beginning-of-line 2)))
4563 (setq header (gnus-nov-parse-line
4564 (read (current-buffer)) deps))
4565 (gnus-parent-id (mail-header-references header))))))
4567 (let ((number (mail-header-number header)))
4568 (push number gnus-newsgroup-limit)
4569 (push header gnus-newsgroup-headers)
4570 (if (memq number gnus-newsgroup-unselected)
4572 (setq gnus-newsgroup-unreads
4573 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4575 (setq gnus-newsgroup-unselected
4576 (delq number gnus-newsgroup-unselected)))
4577 (push number gnus-newsgroup-ancient)))))))
4579 (defun gnus-build-all-threads ()
4580 "Read all the headers."
4581 (let ((gnus-summary-ignore-duplicates t)
4582 (mail-parse-charset gnus-newsgroup-charset)
4583 (dependencies gnus-newsgroup-dependencies)
4585 (with-current-buffer nntp-server-buffer
4586 (let ((case-fold-search nil))
4587 (goto-char (point-min))
4590 (setq article (read (current-buffer))
4591 header (gnus-nov-parse-line article dependencies t)))
4593 (with-current-buffer gnus-summary-buffer
4594 (push header gnus-newsgroup-headers)
4595 (if (memq (setq article (mail-header-number header))
4596 gnus-newsgroup-unselected)
4598 (setq gnus-newsgroup-unreads
4599 (gnus-add-to-sorted-list
4600 gnus-newsgroup-unreads article))
4601 (setq gnus-newsgroup-unselected
4602 (delq article gnus-newsgroup-unselected)))
4603 (push article gnus-newsgroup-ancient)))
4604 (forward-line 1)))))))
4606 (defun gnus-summary-update-article-line (article header)
4607 "Update the line for ARTICLE using HEADER."
4608 (let* ((id (mail-header-id header))
4609 (thread (gnus-id-to-thread id)))
4611 (error "Article in no thread"))
4612 ;; Update the thread.
4613 (setcar thread header)
4614 (gnus-summary-goto-subject article)
4615 (let* ((datal (gnus-data-find-list article))
4617 (inhibit-read-only t)
4618 (level (gnus-summary-thread-level)))
4620 (let ((inserted (- (point)
4622 (gnus-summary-insert-line
4624 (memq article gnus-newsgroup-undownloaded)
4625 (gnus-article-mark article)
4626 (memq article gnus-newsgroup-replied)
4627 (memq article gnus-newsgroup-expirable)
4628 ;; Only insert the Subject string when it's different
4629 ;; from the previous Subject string.
4634 (mail-header-subject
4637 (gnus-data-find-list
4639 (gnus-data-list t)))))
4640 ;; Error on the side of excessive subjects.
4642 (mail-header-subject header)))
4644 (mail-header-subject header))
4645 nil (cdr (assq article gnus-newsgroup-scored))
4646 (memq article gnus-newsgroup-processable))
4649 (gnus-data-update-list
4651 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4653 (defun gnus-summary-update-article (article &optional iheader)
4654 "Update ARTICLE in the summary buffer."
4655 (set-buffer gnus-summary-buffer)
4656 (let* ((header (gnus-summary-article-header article))
4657 (id (mail-header-id header))
4658 (data (gnus-data-find article))
4659 (thread (gnus-id-to-thread id))
4660 (references (mail-header-references header))
4664 (when (and references
4665 (not (equal "" references)))
4668 (inhibit-read-only t)
4674 (delq thread parent)))
4675 (if (gnus-summary-insert-subject id header)
4676 ;; Set the (possibly) new article number in the data structure.
4677 (gnus-data-set-number data (gnus-id-to-article id))
4681 (defun gnus-rebuild-thread (id &optional line)
4682 "Rebuild the thread containing ID.
4683 If LINE, insert the rebuilt thread starting on line LINE."
4684 (let ((inhibit-read-only t)
4685 old-pos current thread data)
4686 (if (not gnus-show-threads)
4687 (setq thread (list (car (gnus-id-to-thread id))))
4688 ;; Get the thread this article is part of.
4689 (setq thread (gnus-remove-thread id)))
4690 (setq old-pos (point-at-bol))
4691 (setq current (save-excursion
4692 (and (re-search-backward "[\r\n]" nil t)
4693 (gnus-summary-article-number))))
4694 ;; If this is a gathered thread, we have to go some re-gathering.
4695 (when (stringp (car thread))
4696 (let ((subject (car thread))
4698 (setq thread (cdr thread))
4700 (unless (memq (setq thr (gnus-id-to-thread
4702 (mail-header-id (caar thread)))))
4705 (setq thread (cdr thread)))
4706 ;; We now have all (unique) roots.
4707 (if (= (length roots) 1)
4708 ;; All the loose roots are now one solid root.
4709 (setq thread (car roots))
4710 (setq thread (cons subject (gnus-sort-threads roots))))))
4712 ;; We then insert this thread into the summary buffer.
4714 (goto-char (point-min))
4715 (forward-line (1- line)))
4716 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4717 (if gnus-show-threads
4718 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4719 (gnus-summary-prepare-unthreaded thread))
4720 (setq data (nreverse gnus-newsgroup-data))
4721 (setq threads gnus-newsgroup-threads))
4722 ;; We splice the new data into the data structure.
4723 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4724 ;;!!! then we want to insert at the beginning of the buffer.
4725 ;;!!! That happens to be true with Gnus now, but that may
4726 ;;!!! change in the future. Perhaps.
4727 (gnus-data-enter-list
4728 (if line nil current) data (- (point) old-pos))
4729 (setq gnus-newsgroup-threads
4730 (nconc threads gnus-newsgroup-threads))
4731 (gnus-data-compute-positions))))
4733 (defun gnus-number-to-header (number)
4734 "Return the header for article NUMBER."
4735 (let ((headers gnus-newsgroup-headers))
4737 (not (= number (mail-header-number (car headers)))))
4742 (defun gnus-parent-headers (in-headers &optional generation)
4743 "Return the headers of the GENERATIONth parent of HEADERS."
4745 (setq generation 1))
4747 (headers in-headers)
4750 (not (zerop generation))
4751 (setq references (mail-header-references headers)))
4752 (setq headers (if (and references
4753 (setq parent (gnus-parent-id references)))
4754 (car (gnus-id-to-thread parent))
4757 (and (not (eq headers in-headers))
4760 (defun gnus-id-to-thread (id)
4761 "Return the (sub-)thread where ID appears."
4762 (gnus-gethash id gnus-newsgroup-dependencies))
4764 (defun gnus-id-to-article (id)
4765 "Return the article number of ID."
4766 (let ((thread (gnus-id-to-thread id)))
4769 (mail-header-number (car thread)))))
4771 (defun gnus-id-to-header (id)
4772 "Return the article headers of ID."
4773 (car (gnus-id-to-thread id)))
4775 (defun gnus-article-displayed-root-p (article)
4776 "Say whether ARTICLE is a root(ish) article."
4777 (let ((level (gnus-summary-thread-level article))
4778 (refs (mail-header-references (gnus-summary-article-header article)))
4784 ((null (gnus-parent-id refs)) t)
4786 (null (setq particle (gnus-id-to-article
4787 (gnus-parent-id refs))))
4788 (null (gnus-summary-thread-level particle)))))))
4790 (defun gnus-root-id (id)
4791 "Return the id of the root of the thread where ID appears."
4793 (while (and id (setq prev (car (gnus-id-to-thread id))))
4795 id (gnus-parent-id (mail-header-references prev))))
4798 (defun gnus-articles-in-thread (thread)
4799 "Return the list of articles in THREAD."
4800 (cons (mail-header-number (car thread))
4801 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4803 (defun gnus-remove-thread (id &optional dont-remove)
4804 "Remove the thread that has ID in it."
4805 (let (headers thread last-id)
4806 ;; First go up in this thread until we find the root.
4807 (setq last-id (gnus-root-id id)
4808 headers (message-flatten-list (gnus-id-to-thread last-id)))
4809 ;; We have now found the real root of this thread. It might have
4810 ;; been gathered into some loose thread, so we have to search
4811 ;; through the threads to find the thread we wanted.
4812 (let ((threads gnus-newsgroup-threads)
4815 (setq sub (car threads))
4816 (if (stringp (car sub))
4817 ;; This is a gathered thread, so we look at the roots
4818 ;; below it to find whether this article is in this
4821 (setq sub (cdr sub))
4823 (when (member (caar sub) headers)
4824 (setq thread (car threads)
4827 (setq sub (cdr sub))))
4828 ;; It's an ordinary thread, so we check it.
4829 (when (eq (car sub) (car headers))
4832 (setq threads (cdr threads)))
4833 ;; If this article is in no thread, then it's a root.
4836 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4837 (setq thread (gnus-id-to-thread last-id)))
4840 thread ; We return this thread.
4842 (if (stringp (car thread))
4844 ;; If we use dummy roots, then we have to remove the
4845 ;; dummy root as well.
4846 (when (eq gnus-summary-make-false-root 'dummy)
4847 ;; We go to the dummy root by going to
4848 ;; the first sub-"thread", and then one line up.
4849 (gnus-summary-goto-article
4850 (mail-header-number (caadr thread)))
4853 (gnus-data-compute-positions))
4854 (setq thread (cdr thread))
4856 (gnus-remove-thread-1 (car thread))
4857 (setq thread (cdr thread))))
4858 (gnus-remove-thread-1 thread))))))))
4860 (defun gnus-remove-thread-1 (thread)
4861 "Remove the thread THREAD recursively."
4862 (let ((number (mail-header-number (pop thread)))
4864 (setq thread (reverse thread))
4866 (gnus-remove-thread-1 (pop thread)))
4867 (when (setq d (gnus-data-find number))
4868 (goto-char (gnus-data-pos d))
4869 (gnus-summary-show-thread)
4875 (gnus-delete-line)))))))
4877 (defun gnus-sort-threads-recursive (threads func)
4878 ;; Responsible for sorting the root articles of threads.
4879 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4880 'gnus-thread-sort-functions)
4882 (gnus-make-sort-function
4883 gnus-subthread-sort-functions))))
4884 (sort (mapcar (lambda (thread)
4887 (gnus-sort-subthreads-recursive
4888 (cdr thread) subthread-sort-func))))
4891 (defun gnus-sort-subthreads-recursive (threads func)
4892 ;; Responsible for sorting subthreads.
4893 (sort (mapcar (lambda (thread)
4896 (gnus-sort-subthreads-recursive (cdr thread) func))))
4899 (defun gnus-sort-threads-loop (threads func)
4900 (let* ((superthread (cons nil threads))
4901 (stack (list (cons superthread threads)))
4902 remaining-threads thread)
4904 (setq remaining-threads (cdr (car stack)))
4905 (if remaining-threads
4906 (progn (setq thread (car remaining-threads))
4907 (setcdr (car stack) (cdr remaining-threads))
4909 (push (cons thread (cdr thread)) stack)))
4910 (setq thread (caar stack))
4911 (setcdr thread (sort (cdr thread) func))
4915 (defun gnus-sort-threads (threads)
4917 (if (not gnus-thread-sort-functions)
4919 (gnus-message 8 "Sorting threads...")
4922 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4923 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4924 (gnus-sort-threads-recursive threads sort-func))
4925 ;; Even after binding max-lisp-eval-depth, the recursive
4926 ;; sorter might fail for very long threads. In that case,
4927 ;; try using a (less well-tested) non-recursive sorter.
4928 (error (gnus-message 9 "Sorting threads with loop...")
4929 (gnus-sort-threads-loop
4930 threads (gnus-make-sort-function
4931 gnus-thread-sort-functions))))
4932 (gnus-message 8 "Sorting threads...done"))))
4934 (defun gnus-sort-articles (articles)
4936 (when gnus-article-sort-functions
4937 (gnus-message 7 "Sorting articles...")
4939 (setq gnus-newsgroup-headers
4940 (sort articles (gnus-make-sort-function
4941 gnus-article-sort-functions)))
4942 (gnus-message 7 "Sorting articles...done"))))
4944 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4945 (defmacro gnus-thread-header (thread)
4946 "Return header of first article in THREAD.
4947 Note that THREAD must never, ever be anything else than a variable -
4948 using some other form will lead to serious barfage."
4949 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4950 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4951 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4954 (defsubst gnus-article-sort-by-number (h1 h2)
4955 "Sort articles by article number."
4956 (< (mail-header-number h1)
4957 (mail-header-number h2)))
4959 (defun gnus-thread-sort-by-number (h1 h2)
4960 "Sort threads by root article number."
4961 (gnus-article-sort-by-number
4962 (gnus-thread-header h1) (gnus-thread-header h2)))
4964 (defsubst gnus-article-sort-by-random (h1 h2)
4965 "Sort articles randomly."
4968 (defun gnus-thread-sort-by-random (h1 h2)
4969 "Sort threads randomly."
4970 (gnus-article-sort-by-random
4971 (gnus-thread-header h1) (gnus-thread-header h2)))
4973 (defsubst gnus-article-sort-by-lines (h1 h2)
4974 "Sort articles by article Lines header."
4975 (< (mail-header-lines h1)
4976 (mail-header-lines h2)))
4978 (defun gnus-thread-sort-by-lines (h1 h2)
4979 "Sort threads by root article Lines header."
4980 (gnus-article-sort-by-lines
4981 (gnus-thread-header h1) (gnus-thread-header h2)))
4983 (defsubst gnus-article-sort-by-chars (h1 h2)
4984 "Sort articles by octet length."
4985 (< (mail-header-chars h1)
4986 (mail-header-chars h2)))
4988 (defun gnus-thread-sort-by-chars (h1 h2)
4989 "Sort threads by root article octet length."
4990 (gnus-article-sort-by-chars
4991 (gnus-thread-header h1) (gnus-thread-header h2)))
4993 (defsubst gnus-article-sort-by-author (h1 h2)
4994 "Sort articles by root author."
4996 (let ((extract (funcall
4997 gnus-extract-address-components
4998 (mail-header-from h1))))
4999 (or (car extract) (cadr extract) ""))
5000 (let ((extract (funcall
5001 gnus-extract-address-components
5002 (mail-header-from h2))))
5003 (or (car extract) (cadr extract) ""))))
5005 (defun gnus-thread-sort-by-author (h1 h2)
5006 "Sort threads by root author."
5007 (gnus-article-sort-by-author
5008 (gnus-thread-header h1) (gnus-thread-header h2)))
5010 (defsubst gnus-article-sort-by-recipient (h1 h2)
5011 "Sort articles by recipient."
5013 (let ((extract (funcall
5014 gnus-extract-address-components
5015 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
5016 (or (car extract) (cadr extract)))
5017 (let ((extract (funcall
5018 gnus-extract-address-components
5019 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5020 (or (car extract) (cadr extract)))))
5022 (defun gnus-thread-sort-by-recipient (h1 h2)
5023 "Sort threads by root recipient."
5024 (gnus-article-sort-by-recipient
5025 (gnus-thread-header h1) (gnus-thread-header h2)))
5027 (defsubst gnus-article-sort-by-subject (h1 h2)
5028 "Sort articles by root subject."
5030 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5031 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5033 (defun gnus-thread-sort-by-subject (h1 h2)
5034 "Sort threads by root subject."
5035 (gnus-article-sort-by-subject
5036 (gnus-thread-header h1) (gnus-thread-header h2)))
5038 (defsubst gnus-article-sort-by-date (h1 h2)
5039 "Sort articles by root article date."
5041 (gnus-date-get-time (mail-header-date h1))
5042 (gnus-date-get-time (mail-header-date h2))))
5044 (defun gnus-thread-sort-by-date (h1 h2)
5045 "Sort threads by root article date."
5046 (gnus-article-sort-by-date
5047 (gnus-thread-header h1) (gnus-thread-header h2)))
5049 (defsubst gnus-article-sort-by-score (h1 h2)
5050 "Sort articles by root article score.
5051 Unscored articles will be counted as having a score of zero."
5052 (> (or (cdr (assq (mail-header-number h1)
5053 gnus-newsgroup-scored))
5054 gnus-summary-default-score 0)
5055 (or (cdr (assq (mail-header-number h2)
5056 gnus-newsgroup-scored))
5057 gnus-summary-default-score 0)))
5059 (defun gnus-thread-sort-by-score (h1 h2)
5060 "Sort threads by root article score."
5061 (gnus-article-sort-by-score
5062 (gnus-thread-header h1) (gnus-thread-header h2)))
5064 (defun gnus-thread-sort-by-total-score (h1 h2)
5065 "Sort threads by the sum of all scores in the thread.
5066 Unscored articles will be counted as having a score of zero."
5067 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5069 (defun gnus-thread-total-score (thread)
5070 ;; This function find the total score of THREAD.
5075 (if (stringp (car thread))
5076 (apply gnus-thread-score-function 0
5077 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5078 (gnus-thread-total-score-1 thread)))
5080 (gnus-thread-total-score-1 (list thread)))))
5082 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5083 "Sort articles by number."
5084 (gnus-article-sort-by-number h1 h2))
5086 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5087 "Sort threads such that the thread with the most recently arrived article comes first."
5088 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5090 (defun gnus-thread-highest-number (thread)
5091 "Return the highest article number in THREAD."
5092 (apply 'max (mapcar (lambda (header)
5093 (mail-header-number header))
5094 (message-flatten-list thread))))
5096 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5097 "Sort articles by number."
5098 (gnus-article-sort-by-date h1 h2))
5100 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5101 "Sort threads such that the thread with the most recently dated article comes first."
5102 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5104 ; Since this is called not only to sort the top-level threads, but
5105 ; also in recursive sorts to order the articles within a thread, each
5106 ; article will be processed many times. Thus it speeds things up
5107 ; quite a bit to use gnus-date-get-time, which caches the time value.
5108 (defun gnus-thread-latest-date (thread)
5109 "Return the highest article date in THREAD."
5111 (mapcar (lambda (header) (gnus-float-time
5113 (mail-header-date header))))
5114 (message-flatten-list thread))))
5116 (defun gnus-thread-total-score-1 (root)
5117 ;; This function find the total score of the thread below ROOT.
5118 (setq root (car root))
5119 (apply gnus-thread-score-function
5121 (mapcar 'gnus-thread-total-score
5122 (cdr (gnus-id-to-thread (mail-header-id root))))
5123 (when (> (mail-header-number root) 0)
5124 (list (or (cdr (assq (mail-header-number root)
5125 gnus-newsgroup-scored))
5126 gnus-summary-default-score 0))))
5127 (list gnus-summary-default-score)
5130 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5131 (defvar gnus-tmp-prev-subject nil)
5132 (defvar gnus-tmp-false-parent nil)
5133 (defvar gnus-tmp-root-expunged nil)
5134 (defvar gnus-tmp-dummy-line nil)
5136 (defun gnus-extra-header (type &optional header)
5137 "Return the extra header of TYPE."
5138 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5141 (defvar gnus-tmp-thread-tree-header-string "")
5143 (defcustom gnus-sum-thread-tree-root "> "
5144 "With %B spec, used for the root of a thread.
5145 If nil, use subject instead."
5147 :type '(radio (const :format "%v " nil) string)
5148 :group 'gnus-thread)
5150 (defcustom gnus-sum-thread-tree-false-root "> "
5151 "With %B spec, used for a false root of a thread.
5152 If nil, use subject instead."
5154 :type '(radio (const :format "%v " nil) string)
5155 :group 'gnus-thread)
5157 (defcustom gnus-sum-thread-tree-single-indent ""
5158 "With %B spec, used for a thread with just one message.
5159 If nil, use subject instead."
5161 :type '(radio (const :format "%v " nil) string)
5162 :group 'gnus-thread)
5164 (defcustom gnus-sum-thread-tree-vertical "| "
5165 "With %B spec, used for drawing a vertical line."
5168 :group 'gnus-thread)
5170 (defcustom gnus-sum-thread-tree-indent " "
5171 "With %B spec, used for indenting."
5174 :group 'gnus-thread)
5176 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5177 "With %B spec, used for a leaf with brothers."
5180 :group 'gnus-thread)
5182 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5183 "With %B spec, used for a leaf without brothers."
5186 :group 'gnus-thread)
5188 (defcustom gnus-summary-display-while-building nil
5189 "If non-nil, show and update the summary buffer as it's being built.
5190 If the value is t, update the buffer after every line is inserted. If
5191 the value is an integer (N), update the display every N lines."
5194 :type '(choice (const :tag "off" nil)
5196 (const :tag "frequently" t)))
5198 (defun gnus-summary-prepare-threads (threads)
5199 "Prepare summary buffer from THREADS and indentation LEVEL.
5200 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5201 or a straight list of headers."
5202 (gnus-message 7 "Generating summary...")
5204 (setq gnus-newsgroup-threads threads)
5207 (let ((gnus-tmp-level 0)
5208 (default-score (or gnus-summary-default-score 0))
5209 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5210 (building-line-count gnus-summary-display-while-building)
5211 (building-count (integerp gnus-summary-display-while-building))
5212 thread number subject stack state gnus-tmp-gathered beg-match
5213 new-roots gnus-tmp-new-adopts thread-end simp-subject
5214 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5215 gnus-tmp-replied gnus-tmp-subject-or-nil
5216 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5217 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5218 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5221 (setq gnus-tmp-prev-subject nil
5222 gnus-tmp-thread-tree-header-string "")
5224 (if (vectorp (car threads))
5225 ;; If this is a straight (sic) list of headers, then a
5226 ;; threaded summary display isn't required, so we just create
5227 ;; an unthreaded one.
5228 (gnus-summary-prepare-unthreaded threads)
5230 ;; Do the threaded display.
5232 (if gnus-summary-display-while-building
5233 (switch-to-buffer (buffer-name)))
5234 (while (or threads stack gnus-tmp-new-adopts new-roots)
5236 (if (and (= gnus-tmp-level 0)
5239 (not gnus-tmp-false-parent)
5240 (or gnus-tmp-new-adopts new-roots))
5241 (if gnus-tmp-new-adopts
5242 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5243 thread (list (car gnus-tmp-new-adopts))
5244 gnus-tmp-header (caar thread)
5245 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5247 (setq thread (list (car new-roots))
5248 gnus-tmp-header (caar thread)
5249 new-roots (cdr new-roots))))
5252 ;; If there are some threads, we do them before the
5253 ;; threads on the stack.
5254 (setq thread threads
5255 gnus-tmp-header (caar thread))
5256 ;; There were no current threads, so we pop something off
5258 (setq state (car stack)
5259 gnus-tmp-level (car state)
5260 tree-stack (cadr state)
5261 thread (caddr state)
5263 gnus-tmp-header (caar thread))))
5265 (setq gnus-tmp-false-parent nil)
5266 (setq gnus-tmp-root-expunged nil)
5267 (setq thread-end nil)
5269 (if (stringp gnus-tmp-header)
5270 ;; The header is a dummy root.
5272 ((eq gnus-summary-make-false-root 'adopt)
5273 ;; We let the first article adopt the rest.
5274 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5276 (setq gnus-tmp-gathered
5278 (lambda (h) (mail-header-number (car h)))
5281 (setq thread (cons (list (caar thread)
5284 (setq gnus-tmp-level -1
5285 gnus-tmp-false-parent t))
5286 ((eq gnus-summary-make-false-root 'empty)
5287 ;; We print adopted articles with empty subject fields.
5288 (setq gnus-tmp-gathered
5290 (lambda (h) (mail-header-number (car h)))
5293 (setq gnus-tmp-level -1))
5294 ((eq gnus-summary-make-false-root 'dummy)
5295 ;; We remember that we probably want to output a dummy
5297 (setq gnus-tmp-dummy-line gnus-tmp-header)
5298 (setq gnus-tmp-prev-subject gnus-tmp-header))
5300 ;; We do not make a root for the gathered
5301 ;; sub-threads at all.
5302 (setq gnus-tmp-level -1)))
5304 (setq number (mail-header-number gnus-tmp-header)
5305 subject (mail-header-subject gnus-tmp-header)
5306 simp-subject (gnus-simplify-subject-fully subject))
5309 ;; If the thread has changed subject, we might want to make
5310 ;; this subthread into a root.
5311 ((and (null gnus-thread-ignore-subject)
5312 (not (zerop gnus-tmp-level))
5313 gnus-tmp-prev-subject
5314 (not (string= gnus-tmp-prev-subject simp-subject)))
5315 (setq new-roots (nconc new-roots (list (car thread)))
5317 gnus-tmp-header nil))
5318 ;; If the article lies outside the current limit,
5319 ;; then we do not display it.
5320 ((not (memq number gnus-newsgroup-limit))
5321 (setq gnus-tmp-gathered
5323 (lambda (h) (mail-header-number (car h)))
5326 (setq gnus-tmp-new-adopts (if (cdar thread)
5327 (append gnus-tmp-new-adopts
5329 gnus-tmp-new-adopts)
5331 gnus-tmp-header nil)
5332 (when (zerop gnus-tmp-level)
5333 (setq gnus-tmp-root-expunged t)))
5334 ;; Perhaps this article is to be marked as read?
5335 ((and gnus-summary-mark-below
5336 (< (or (cdr (assq number gnus-newsgroup-scored))
5338 gnus-summary-mark-below)
5339 ;; Don't touch sparse articles.
5340 (not (gnus-summary-article-sparse-p number))
5341 (not (gnus-summary-article-ancient-p number)))
5342 (setq gnus-newsgroup-unreads
5343 (delq number gnus-newsgroup-unreads))
5344 (if gnus-newsgroup-auto-expire
5345 (setq gnus-newsgroup-expirable
5346 (gnus-add-to-sorted-list
5347 gnus-newsgroup-expirable number))
5348 (push (cons number gnus-low-score-mark)
5349 gnus-newsgroup-reads))))
5351 (when gnus-tmp-header
5352 ;; We may have an old dummy line to output before this
5354 (when (and gnus-tmp-dummy-line
5357 (mail-header-subject gnus-tmp-header)))
5358 (gnus-summary-insert-dummy-line
5359 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5360 (setq gnus-tmp-dummy-line nil))
5362 ;; Compute the mark.
5363 (setq gnus-tmp-unread (gnus-article-mark number))
5365 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5366 gnus-tmp-header gnus-tmp-level)
5367 gnus-newsgroup-data)
5369 ;; Actually insert the line.
5371 gnus-tmp-subject-or-nil
5373 ((and gnus-thread-ignore-subject
5374 gnus-tmp-prev-subject
5375 (not (string= gnus-tmp-prev-subject simp-subject)))
5377 ((zerop gnus-tmp-level)
5378 (if (and (eq gnus-summary-make-false-root 'empty)
5379 (memq number gnus-tmp-gathered)
5380 gnus-tmp-prev-subject
5381 (string= gnus-tmp-prev-subject simp-subject))
5382 gnus-summary-same-subject
5384 (t gnus-summary-same-subject)))
5385 (if (and (eq gnus-summary-make-false-root 'adopt)
5386 (= gnus-tmp-level 1)
5387 (memq number gnus-tmp-gathered))
5388 (setq gnus-tmp-opening-bracket ?\<
5389 gnus-tmp-closing-bracket ?\>)
5390 (setq gnus-tmp-opening-bracket ?\[
5391 gnus-tmp-closing-bracket ?\]))
5392 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5393 (gnus-make-thread-indent-array
5394 (max (* 2 (length gnus-thread-indent-array))
5397 gnus-tmp-indentation
5398 (aref gnus-thread-indent-array gnus-tmp-level)
5399 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5400 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5401 gnus-summary-default-score 0)
5403 (if (or (null gnus-summary-default-score)
5404 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5405 gnus-summary-zcore-fuzz))
5407 (if (< gnus-tmp-score gnus-summary-default-score)
5408 gnus-score-below-mark gnus-score-over-mark))
5410 (cond ((memq number gnus-newsgroup-processable)
5412 ((memq number gnus-newsgroup-cached)
5414 ((memq number gnus-newsgroup-replied)
5416 ((memq number gnus-newsgroup-forwarded)
5417 gnus-forwarded-mark)
5418 ((memq number gnus-newsgroup-saved)
5420 ((memq number gnus-newsgroup-unseen)
5424 (cond ((memq number gnus-newsgroup-undownloaded)
5425 gnus-undownloaded-mark)
5426 (gnus-newsgroup-agentized
5427 gnus-downloaded-mark)
5430 gnus-tmp-from (mail-header-from gnus-tmp-header)
5433 ((string-match "<[^>]+> *$" gnus-tmp-from)
5434 (setq beg-match (match-beginning 0))
5435 (or (and (string-match "^\".+\"" gnus-tmp-from)
5436 (substring gnus-tmp-from 1 (1- (match-end 0))))
5437 (substring gnus-tmp-from 0 beg-match)))
5438 ((string-match "(.+)" gnus-tmp-from)
5439 (substring gnus-tmp-from
5440 (1+ (match-beginning 0)) (1- (match-end 0))))
5444 gnus-tmp-thread-tree-header-string
5446 ((not gnus-show-threads) "")
5447 ((zerop gnus-tmp-level)
5448 (cond ((cdar thread)
5449 (or gnus-sum-thread-tree-root subject))
5450 (gnus-tmp-new-adopts
5451 (or gnus-sum-thread-tree-false-root subject))
5453 (or gnus-sum-thread-tree-single-indent subject))))
5455 (concat (apply 'concat
5456 (mapcar (lambda (item)
5458 gnus-sum-thread-tree-vertical
5459 gnus-sum-thread-tree-indent))
5460 (cdr (reverse tree-stack))))
5462 gnus-sum-thread-tree-leaf-with-other
5463 gnus-sum-thread-tree-single-leaf)))))
5464 (when (string= gnus-tmp-name "")
5465 (setq gnus-tmp-name gnus-tmp-from))
5466 (unless (numberp gnus-tmp-lines)
5467 (setq gnus-tmp-lines -1))
5468 (if (= gnus-tmp-lines -1)
5469 (setq gnus-tmp-lines "?")
5470 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5471 (gnus-put-text-property
5473 (progn (eval gnus-summary-line-format-spec) (point))
5474 'gnus-number number)
5477 (gnus-summary-highlight-line)
5478 (when gnus-summary-update-hook
5479 (gnus-run-hooks 'gnus-summary-update-hook))
5482 (setq gnus-tmp-prev-subject simp-subject)))
5484 (when (nth 1 thread)
5485 (push (list (max 0 gnus-tmp-level)
5486 (copy-sequence tree-stack)
5489 (push (if (nth 1 thread) 1 0) tree-stack)
5490 (incf gnus-tmp-level)
5491 (setq threads (if thread-end nil (cdar thread)))
5492 (if gnus-summary-display-while-building
5495 ;; use a set frequency
5496 (setq building-line-count (1- building-line-count))
5497 (when (= building-line-count 0)
5499 (setq building-line-count
5500 gnus-summary-display-while-building)))
5504 (setq gnus-tmp-level 0)))))
5505 (gnus-message 7 "Generating summary...done"))
5507 (defun gnus-summary-prepare-unthreaded (headers)
5508 "Generate an unthreaded summary buffer based on HEADERS."
5509 (let (header number mark)
5514 ;; We may have to root out some bad articles...
5515 (when (memq (setq number (mail-header-number
5516 (setq header (pop headers))))
5517 gnus-newsgroup-limit)
5518 ;; Mark article as read when it has a low score.
5519 (when (and gnus-summary-mark-below
5520 (< (or (cdr (assq number gnus-newsgroup-scored))
5521 gnus-summary-default-score 0)
5522 gnus-summary-mark-below)
5523 (not (gnus-summary-article-ancient-p number)))
5524 (setq gnus-newsgroup-unreads
5525 (delq number gnus-newsgroup-unreads))
5526 (if gnus-newsgroup-auto-expire
5527 (push number gnus-newsgroup-expirable)
5528 (push (cons number gnus-low-score-mark)
5529 gnus-newsgroup-reads)))
5531 (setq mark (gnus-article-mark number))
5532 (push (gnus-data-make number mark (1+ (point)) header 0)
5533 gnus-newsgroup-data)
5534 (gnus-summary-insert-line
5536 (memq number gnus-newsgroup-undownloaded)
5537 mark (memq number gnus-newsgroup-replied)
5538 (memq number gnus-newsgroup-expirable)
5539 (mail-header-subject header) nil
5540 (cdr (assq number gnus-newsgroup-scored))
5541 (memq number gnus-newsgroup-processable))))))
5543 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5545 (defun gnus-group-get-list-identifiers (group)
5546 "Get list identifier regexp for GROUP."
5547 (or (gnus-parameter-list-identifier group)
5548 (if (consp gnus-list-identifiers)
5549 (mapconcat 'identity gnus-list-identifiers " *\\|")
5550 gnus-list-identifiers)))
5552 (defun gnus-summary-remove-list-identifiers ()
5553 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5554 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5557 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5558 (dolist (header gnus-newsgroup-headers)
5559 (setq subject (mail-header-subject header)
5561 (while (string-match regexp subject)
5563 (concat (substring subject 0 (match-beginning 1))
5564 (substring subject (match-end 0)))
5567 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5569 (concat (substring subject 0 (match-beginning 1))
5570 (substring subject (match-end 1)))))
5571 (mail-header-set-subject header subject))))))
5573 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5574 "Fetch headers of ARTICLES."
5575 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5576 (gnus-message 7 "Fetching headers for %s..." name)
5579 (setq gnus-headers-retrieved-by
5580 (gnus-retrieve-headers
5581 articles gnus-newsgroup-name
5583 ;; We might want to fetch old headers, but
5584 ;; not if there is only 1 article.
5586 (not (eq gnus-fetch-old-headers 'some))
5587 (not (numberp gnus-fetch-old-headers)))
5588 (> (length articles) 1))
5589 gnus-fetch-old-headers)))))
5590 (gnus-get-newsgroup-headers-xover
5591 articles force-new dependencies gnus-newsgroup-name t)
5592 (gnus-get-newsgroup-headers dependencies force-new))
5593 (gnus-message 7 "Fetching headers for %s...done" name))))
5595 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5596 "Select newsgroup GROUP.
5597 If READ-ALL is non-nil, all articles in the group are selected.
5598 If SELECT-ARTICLES, only select those articles from GROUP."
5599 (let* ((entry (gnus-group-entry group))
5600 ;;!!! Dirty hack; should be removed.
5601 (gnus-summary-ignore-duplicates
5602 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5604 gnus-summary-ignore-duplicates))
5605 (info (nth 2 entry))
5606 charset articles fetched-articles cached)
5608 (unless (gnus-check-server
5609 (set (make-local-variable 'gnus-current-select-method)
5610 (gnus-find-method-for-group group)))
5611 (error "Couldn't open server"))
5612 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5614 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5615 (gnus-activate-group group) ; Or we can activate it...
5616 (progn ; Or we bug out.
5617 (when (derived-mode-p 'gnus-summary-mode)
5618 (gnus-kill-buffer (current-buffer)))
5620 "Couldn't activate group %s: %s"
5621 (mm-decode-coding-string group charset)
5622 (mm-decode-coding-string (gnus-status-message group) charset))))
5624 (unless (gnus-request-group group t nil (gnus-get-info group))
5625 (when (derived-mode-p 'gnus-summary-mode)
5626 (gnus-kill-buffer (current-buffer)))
5627 (error "Couldn't request group %s: %s"
5628 (mm-decode-coding-string group charset)
5629 (mm-decode-coding-string (gnus-status-message group) charset)))
5631 (when (and gnus-agent
5632 (gnus-active group))
5633 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5635 (setq gnus-summary-use-undownloaded-faces
5636 (gnus-agent-find-parameter
5638 'agent-enable-undownloaded-faces)))
5640 (setq gnus-newsgroup-name group
5641 gnus-newsgroup-unselected nil
5642 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5644 (let ((display (gnus-group-find-parameter group 'display)))
5645 (setq gnus-newsgroup-display
5647 ((not (zerop (or (car-safe read-all) 0)))
5648 ;; The user entered the group with C-u SPC/RET, let's show
5654 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5656 ;; The following is probably the "correct" solution, but
5657 ;; it makes Gnus fetch all headers and then limit the
5658 ;; articles (which is slow), so instead we hack the
5659 ;; select-articles parameter instead. -- Simon Josefsson
5662 ;; (gnus-byte-compile
5663 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5665 (setq select-articles
5666 (gnus-uncompress-range
5667 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5671 (cdr (gnus-active group)))))
5676 (gnus-summary-setup-default-charset)
5678 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5679 (when (gnus-virtual-group-p group)
5680 (setq cached gnus-newsgroup-cached))
5682 (setq gnus-newsgroup-unreads
5683 (gnus-sorted-ndifference
5684 (gnus-sorted-ndifference gnus-newsgroup-unreads
5685 gnus-newsgroup-marked)
5686 gnus-newsgroup-dormant))
5688 (setq gnus-newsgroup-processable nil)
5690 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5692 ;; Adjust and set lists of article marks.
5694 (gnus-adjust-marked-articles info))
5695 (if (setq articles select-articles)
5696 (setq gnus-newsgroup-unselected
5697 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5698 (setq articles (gnus-articles-to-read group read-all)))
5702 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5704 ((eq articles 0) nil)
5706 ;; Init the dependencies hash table.
5707 (setq gnus-newsgroup-dependencies
5708 (gnus-make-hashtable (length articles)))
5709 (if (gnus-buffer-live-p gnus-group-buffer)
5710 (gnus-set-global-variables)
5711 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5712 ;; Retrieve the headers and read them in.
5714 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5716 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5718 (setq gnus-newsgroup-cached cached))
5720 ;; Suppress duplicates?
5721 (when gnus-suppress-duplicates
5722 (gnus-dup-suppress-articles))
5724 ;; Set the initial limit.
5725 (setq gnus-newsgroup-limit (copy-sequence articles))
5726 ;; Remove canceled articles from the list of unread articles.
5727 (setq fetched-articles
5728 (mapcar (lambda (headers) (mail-header-number headers))
5729 gnus-newsgroup-headers))
5730 (setq gnus-newsgroup-articles fetched-articles)
5731 (setq gnus-newsgroup-unreads
5732 (gnus-sorted-nintersection
5733 gnus-newsgroup-unreads fetched-articles))
5734 (gnus-compute-unseen-list)
5736 ;; Removed marked articles that do not exist.
5737 (gnus-update-missing-marks
5738 (gnus-sorted-difference articles fetched-articles))
5739 ;; We might want to build some more threads first.
5740 (when (and gnus-fetch-old-headers
5741 (eq gnus-headers-retrieved-by 'nov))
5742 (if (eq gnus-fetch-old-headers 'invisible)
5743 (gnus-build-all-threads)
5744 (gnus-build-old-threads)))
5745 ;; Let the Gnus agent mark articles as read.
5747 (gnus-agent-get-undownloaded-list))
5748 ;; Remove list identifiers from subject
5749 (gnus-summary-remove-list-identifiers)
5750 ;; Check whether auto-expire is to be done in this group.
5751 (setq gnus-newsgroup-auto-expire
5752 (and (gnus-group-auto-expirable-p group)
5753 (not (gnus-group-read-only-p group))))
5754 ;; Set up the article buffer now, if necessary.
5755 (unless (and gnus-single-article-buffer
5756 (equal gnus-article-buffer "*Article*"))
5757 (gnus-article-setup-buffer))
5758 ;; First and last article in this newsgroup.
5759 (when gnus-newsgroup-headers
5760 (setq gnus-newsgroup-begin
5761 (mail-header-number (car gnus-newsgroup-headers))
5764 (gnus-last-element gnus-newsgroup-headers))))
5765 ;; GROUP is successfully selected.
5766 (or gnus-newsgroup-headers t)))))
5768 (defun gnus-compute-unseen-list ()
5769 ;; The `seen' marks are treated specially.
5770 (if (not gnus-newsgroup-seen)
5771 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5772 (setq gnus-newsgroup-unseen
5773 (gnus-inverse-list-range-intersection
5774 gnus-newsgroup-articles gnus-newsgroup-seen))))
5776 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5778 (defun gnus-summary-display-make-predicate (display)
5779 (require 'gnus-agent)
5780 (when (= (length display) 1)
5781 (setq display (car display)))
5782 (unless gnus-summary-display-cache
5783 (dolist (elem (append '((unread . unread)
5786 gnus-article-mark-lists))
5787 (push (cons (cdr elem)
5788 (gnus-byte-compile ;Why bother?
5789 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5790 gnus-summary-display-cache)))
5791 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5792 (gnus-category-predicate-cache gnus-summary-display-cache))
5793 (gnus-get-predicate display)))
5795 ;; Uses the dynamically bound `gnus-number' variable.
5796 (defvar gnus-number)
5797 (defun gnus-article-marked-p (type &optional article)
5798 (let ((article (or article gnus-number)))
5801 (memq article gnus-newsgroup-marked))
5803 (memq article gnus-newsgroup-spam-marked))
5805 (memq article gnus-newsgroup-unsendable))
5806 ((eq type 'undownload)
5807 (memq article gnus-newsgroup-undownloaded))
5808 ((eq type 'download)
5809 (memq article gnus-newsgroup-downloadable))
5811 (memq article gnus-newsgroup-unreads))
5813 (memq article gnus-newsgroup-reads))
5815 (memq article gnus-newsgroup-dormant) )
5817 (memq article gnus-newsgroup-expirable))
5819 (memq article gnus-newsgroup-replied))
5821 (memq article gnus-newsgroup-killed))
5822 ((eq type 'bookmark)
5823 (assq article gnus-newsgroup-bookmarks))
5825 (assq article gnus-newsgroup-scored))
5827 (memq article gnus-newsgroup-saved))
5829 (memq article gnus-newsgroup-cached))
5831 (memq article gnus-newsgroup-forwarded))
5833 (not (memq article gnus-newsgroup-unseen)))
5836 (defun gnus-articles-to-read (group &optional read-all)
5837 "Find out what articles the user wants to read."
5838 (let* ((only-read-p t)
5840 (gnus-list-range-difference
5841 ;; Select all articles if `read-all' is non-nil, or if there
5842 ;; are no unread articles.
5844 (and (zerop (length gnus-newsgroup-marked))
5845 (zerop (length gnus-newsgroup-unreads)))
5846 ;; Fetch all if the predicate is non-nil.
5847 gnus-newsgroup-display)
5848 ;; We want to select the headers for all the articles in
5849 ;; the group, so we select either all the active
5850 ;; articles in the group, or (if that's nil), the
5851 ;; articles in the cache.
5853 (if gnus-newsgroup-maximum-articles
5854 (let ((active (gnus-active group)))
5855 (gnus-uncompress-range
5856 (cons (max (car active)
5858 gnus-newsgroup-maximum-articles
5861 (gnus-uncompress-range (gnus-active group)))
5862 (gnus-cache-articles-in-group group))
5863 ;; Select only the "normal" subset of articles.
5864 (setq only-read-p nil)
5866 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5867 gnus-newsgroup-unreads))
5868 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5869 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5870 (scored (length scored-list))
5871 (number (length articles))
5872 (marked (+ (length gnus-newsgroup-marked)
5873 (length gnus-newsgroup-dormant)))
5878 ((numberp gnus-newsgroup-display)
5879 gnus-newsgroup-display)
5883 ((and (or (<= scored marked) (= scored number))
5884 (numberp gnus-large-newsgroup)
5885 (> number gnus-large-newsgroup))
5886 (let* ((cursor-in-echo-area nil)
5887 (initial (gnus-parameter-large-newsgroup-initial
5888 gnus-newsgroup-name))
5889 (default (if only-read-p
5890 (or initial gnus-large-newsgroup)
5896 "How many articles from %s (available %d, default %d): "
5897 (gnus-group-decoded-name
5898 (gnus-group-real-name gnus-newsgroup-name))
5901 "How many articles from %s (%d default): "
5902 (gnus-group-decoded-name
5903 (gnus-group-real-name gnus-newsgroup-name))
5907 (number-to-string default))))
5908 (if (string-match "^[ \t]*$" input) number input)))
5909 ((and (> scored marked) (< scored number)
5910 (> (- scored number) 20))
5913 (format "%s %s (%d scored, %d total): "
5914 "How many articles from"
5915 (gnus-group-decoded-name
5916 (gnus-group-real-name gnus-newsgroup-name))
5918 (if (string-match "^[ \t]*$" input)
5922 (message "Quit getting the articles to read")
5924 (setq select (if (stringp select) (string-to-number select) select))
5925 (if (or (null select) (zerop select))
5927 (if (and (not (zerop scored)) (<= (abs select) scored))
5929 (setq articles (sort scored-list '<))
5930 (setq number (length articles)))
5931 (setq articles (copy-sequence articles)))
5933 (when (< (abs select) number)
5935 ;; Select the N oldest articles.
5936 (setcdr (nthcdr (1- (abs select)) articles) nil)
5937 ;; Select the N most recent articles.
5938 (setq articles (nthcdr (- number select) articles))))
5939 (setq gnus-newsgroup-unselected
5940 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5941 (when gnus-alter-articles-to-read-function
5944 (funcall gnus-alter-articles-to-read-function
5945 gnus-newsgroup-name articles)
5949 (defun gnus-killed-articles (killed articles)
5952 (when (inline (gnus-member-of-range (car articles) killed))
5953 (push (car articles) out))
5954 (setq articles (cdr articles)))
5957 (defun gnus-article-mark-to-type (mark)
5958 "Return the type of MARK."
5959 (or (cadr (assq mark gnus-article-special-mark-lists))
5962 (defun gnus-article-unpropagatable-p (mark)
5963 "Return whether MARK should be propagated to back end."
5964 (memq mark gnus-article-unpropagated-mark-lists))
5966 (defun gnus-adjust-marked-articles (info)
5967 "Set all article lists and remove all marks that are no longer valid."
5968 (let* ((marked-lists (gnus-info-marks info))
5969 (active (gnus-active (gnus-info-group info)))
5972 (types gnus-article-mark-lists)
5973 marks var articles article mark mark-type
5975 ;; Hack to avoid adjusting marks for imap.
5976 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5980 (dolist (marks marked-lists)
5981 (setq mark (car marks)
5982 mark-type (gnus-article-mark-to-type mark)
5983 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5984 ;; We set the variable according to the type of the marks list,
5985 ;; and then adjust the marks to a subset of the active articles.
5987 ;; Adjust "simple" lists - compressed yet unsorted
5988 ((eq mark-type 'list)
5989 ;; Simultaneously uncompress and clip to active range
5990 ;; See gnus-uncompress-range for a description of possible marks
5992 (if (not (cadr marks))
5994 (setq articles (if (numberp (cddr marks))
6000 (while (setq article (pop articles))
6001 (cond ((consp article)
6002 (setq bgn (max (car article) min)
6003 end (min (cdr article) max))
6005 (setq l (setcdr l (cons bgn nil))
6007 ((and (<= min article)
6009 (setq l (setcdr l (cons article nil))))))
6010 (set var (cdr lh)))))
6012 ((eq mark-type 'tuple)
6013 (set var (setq articles (cdr marks)))
6014 (when (not (listp (cdr (symbol-value var))))
6015 (set var (list (symbol-value var))))
6016 (when (not (listp (cdr articles)))
6017 (setq articles (list articles)))
6019 (when (or (not (consp (setq article (pop articles))))
6020 (< (car article) min)
6021 (> (car article) max))
6022 (set var (delq article (symbol-value var))))))
6023 ;; Adjust ranges (sloppily).
6024 ((eq mark-type 'range)
6027 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6028 ;; It should be (seen (NUM1 . NUM2)).
6029 (when (numberp (cddr marks))
6030 (setcdr marks (list (cdr marks))))
6031 (setq articles (cdr marks))
6032 (while (and articles
6033 (or (and (consp (car articles))
6034 (> min (cdar articles)))
6035 (and (numberp (car articles))
6036 (> min (car articles)))))
6040 (set var (cdr marks)))))))))
6042 (defun gnus-update-missing-marks (missing)
6043 "Go through the list of MISSING articles and remove them from the mark lists."
6046 ;; Go through all types.
6047 (dolist (elem gnus-article-mark-lists)
6048 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6049 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6050 (when (symbol-value var)
6051 ;; This list has articles. So we delete all missing
6052 ;; articles from it.
6055 (set var (delq (pop m) (symbol-value var))))))))))
6057 (defun gnus-update-marks ()
6058 "Enter the various lists of marked articles into the newsgroup info list."
6059 (let ((types gnus-article-mark-lists)
6060 (info (gnus-get-info gnus-newsgroup-name))
6061 type list newmarked symbol delta-marks)
6063 ;; Add all marks lists to the list of marks lists.
6064 (while (setq type (pop types))
6065 (setq list (symbol-value
6067 (intern (format "gnus-newsgroup-%s" (car type))))))
6070 ;; Get rid of the entries of the articles that have the
6072 (when (and (eq (cdr type) 'score)
6076 (prev (cons nil list))
6079 (if (or (not (consp (car arts)))
6080 (= (cdar arts) gnus-summary-default-score))
6081 (setcdr prev (cdr arts))
6083 (setq arts (cdr arts)))
6084 (setq list (cdr all)))))
6086 (when (eq (cdr type) 'seen)
6087 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6089 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6090 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6092 (when (and (gnus-check-backend-function
6093 'request-set-mark gnus-newsgroup-name)
6094 (not (gnus-article-unpropagatable-p (cdr type))))
6095 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6096 ;; Don't do anything about marks for articles we
6097 ;; didn't actually get any headers for.
6099 (gnus-list-range-intersection
6100 gnus-newsgroup-articles
6101 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6103 (gnus-list-range-intersection
6104 gnus-newsgroup-articles
6105 (gnus-remove-from-range
6106 (gnus-copy-sequence list) old))))
6108 (push (list add 'add (list (cdr type))) delta-marks))
6110 ;; Don't delete marks from outside the active range.
6111 ;; This shouldn't happen, but is a sanity check.
6112 (setq del (gnus-sorted-range-intersection
6113 (gnus-active gnus-newsgroup-name) del))
6114 (push (list del 'del (list (cdr type))) delta-marks))))
6117 (eq (cdr type) 'unexist))
6118 (push (cons (cdr type) list) newmarked)))
6121 (unless (gnus-check-group gnus-newsgroup-name)
6122 (error "Can't open server for %s" gnus-newsgroup-name))
6123 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6125 ;; Enter these new marks into the info of the group.
6127 (setcar (nthcdr 3 info) newmarked)
6128 ;; Add the marks lists to the end of the info.
6130 (setcdr (nthcdr 2 info) (list newmarked))))
6132 ;; Cut off the end of the info if there's nothing else there.
6136 (when (nthcdr (decf i) info)
6137 (setcdr (nthcdr i info) nil)))))))
6139 (defun gnus-set-mode-line (where)
6140 "Set the mode line of the article or summary buffers.
6141 If WHERE is `summary', the summary mode line format will be used."
6142 ;; Is this mode line one we keep updated?
6143 (when (and (memq where gnus-updated-mode-lines)
6145 (intern (format "gnus-%s-mode-line-format-spec" where))))
6147 ;; We evaluate this in the summary buffer since these
6148 ;; variables are buffer-local to that buffer.
6149 (with-current-buffer gnus-summary-buffer
6150 ;; We bind all these variables that are used in the `eval' form
6152 (let* ((mformat (symbol-value
6154 (format "gnus-%s-mode-line-format-spec" where))))
6155 (gnus-tmp-group-name (gnus-mode-string-quote
6156 (gnus-group-decoded-name
6157 gnus-newsgroup-name)))
6158 (gnus-tmp-article-number (or gnus-current-article 0))
6159 (gnus-tmp-unread gnus-newsgroup-unreads)
6160 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6161 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6162 (gnus-tmp-unread-and-unselected
6163 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6164 (zerop gnus-tmp-unselected))
6166 ((zerop gnus-tmp-unselected)
6167 (format "{%d more}" gnus-tmp-unread-and-unticked))
6168 (t (format "{%d(+%d) more}"
6169 gnus-tmp-unread-and-unticked
6170 gnus-tmp-unselected))))
6172 (if (and gnus-current-headers
6173 (vectorp gnus-current-headers))
6174 (gnus-mode-string-quote
6175 (mail-header-subject gnus-current-headers))
6177 bufname-length max-len
6178 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6179 (setq mode-string (eval mformat))
6180 (setq bufname-length (if (string-match "%b" mode-string)
6183 (if (eq where 'summary)
6185 (get-buffer gnus-article-buffer))))
6188 (setq max-len (max 4 (if gnus-mode-non-string-length
6190 gnus-mode-non-string-length
6192 (length mode-string))))
6193 ;; We might have to chop a bit of the string off...
6194 (when (> (length mode-string) max-len)
6196 (concat (truncate-string-to-width mode-string (- max-len 3))
6198 ;; Update the mode line.
6199 (setq mode-line-buffer-identification
6200 (gnus-mode-line-buffer-identification (list mode-string)))
6201 (set-buffer-modified-p t))))
6203 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6204 "Go through the HEADERS list and add all Xrefs to a hash table.
6205 The resulting hash table is returned, or nil if no Xrefs were found."
6206 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6207 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6208 (xref-hashtb (gnus-make-hashtable))
6209 start group entry number xrefs header)
6211 (setq header (pop headers))
6212 (when (and (setq xrefs (mail-header-xref header))
6213 (not (memq (setq number (mail-header-number header))
6216 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6217 (setq start (match-end 0))
6218 (setq group (if prefix
6219 (concat prefix (substring xrefs (match-beginning 1)
6221 (substring xrefs (match-beginning 1) (match-end 1))))
6223 (string-to-number (substring xrefs (match-beginning 2)
6225 (if (setq entry (gnus-gethash group xref-hashtb))
6226 (setcdr entry (cons number (cdr entry)))
6227 (gnus-sethash group (cons number nil) xref-hashtb)))))
6228 (and start xref-hashtb)))
6230 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6231 "Look through all the headers and mark the Xrefs as read."
6232 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6233 name info xref-hashtb idlist method nth4)
6234 (with-current-buffer gnus-group-buffer
6235 (when (setq xref-hashtb
6236 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6239 (unless (string= from-newsgroup (setq name (symbol-name group)))
6240 (setq idlist (symbol-value group))
6241 ;; Dead groups are not updated.
6243 (setq info (gnus-get-info name))
6244 (when (stringp (setq nth4 (gnus-info-method info)))
6245 (setq nth4 (gnus-server-to-method nth4))))
6246 ;; Only do the xrefs if the group has the same
6247 ;; select method as the group we have just read.
6248 (or (gnus-methods-equal-p
6249 nth4 (gnus-find-method-for-group from-newsgroup))
6251 (equal nth4 (setq method (gnus-find-method-for-group
6253 (and (equal (car nth4) (car method))
6254 (equal (nth 1 nth4) (nth 1 method))))
6255 gnus-use-cross-reference
6256 (or (not (eq gnus-use-cross-reference t))
6258 ;; Only do cross-references on subscribed
6259 ;; groups, if that is what is wanted.
6260 (<= (gnus-info-level info) gnus-level-subscribed))
6261 (gnus-group-make-articles-read name idlist))))
6264 (defun gnus-compute-read-articles (group articles)
6265 (let* ((entry (gnus-group-entry group))
6266 (info (nth 2 entry))
6267 (active (gnus-active group))
6270 ;; First peel off all invalid article numbers.
6272 (let ((ids articles)
6274 (while (setq id (pop ids))
6275 (when (and first (> id (cdr active)))
6276 ;; We'll end up in this situation in one particular
6277 ;; obscure situation. If you re-scan a group and get
6278 ;; a new article that is cross-posted to a different
6279 ;; group that has not been re-scanned, you might get
6280 ;; crossposted article that has a higher number than
6281 ;; Gnus believes possible. So we re-activate this
6282 ;; group as well. This might mean doing the
6283 ;; crossposting thingy will *increase* the number
6284 ;; of articles in some groups. Tsk, tsk.
6285 (setq active (or (gnus-activate-group group) active)))
6286 (when (or (> id (cdr active))
6287 (< id (car active)))
6288 (setq articles (delq id articles))))))
6289 ;; If the read list is nil, we init it.
6291 (null (gnus-info-read info))
6293 (setq ninfo (cons 1 (1- (car active))))
6294 (setq ninfo (gnus-info-read info)))
6295 ;; Then we add the read articles to the range.
6297 ninfo (setq articles (sort articles '<))))))
6299 (defun gnus-group-make-articles-read (group articles)
6300 "Update the info of GROUP to say that ARTICLES are read."
6302 (entry (gnus-group-entry group))
6303 (info (nth 2 entry))
6304 (active (gnus-active group))
6306 (gnus-method-option-p
6307 (gnus-find-method-for-group group)
6311 ;; Group that Gnus doesn't know exists, but still allow the
6312 ;; backend to set marks.
6314 (gnus-request-set-mark
6315 group (list (list (gnus-compress-sequence (sort articles #'<))
6317 ;; Normal, subscribed groups.
6318 (setq range (gnus-compute-read-articles group articles))
6319 (with-current-buffer gnus-group-buffer
6322 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6323 (gnus-info-set-read ',info ',(gnus-info-read info))
6324 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6326 (gnus-request-set-mark
6327 ,group (list (list ',range 'del '(read)))))
6328 (gnus-group-update-group ,group t))))
6329 ;; Add the read articles to the range.
6330 (gnus-info-set-read info range)
6332 (gnus-request-set-mark group (list (list range 'add '(read)))))
6333 ;; Then we have to re-compute how many unread
6334 ;; articles there are in this group.
6338 (setq num (- (1+ (cdr active)) (car active))))
6339 ((not (listp (cdr range)))
6340 (setq num (- (cdr active) (- (1+ (cdr range))
6344 (if (numberp (car range))
6346 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6347 (setq range (cdr range)))
6348 (setq num (- (cdr active) num))))
6349 ;; Update the number of unread articles.
6351 ;; Update the group buffer.
6352 (unless (gnus-ephemeral-group-p group)
6353 (gnus-group-update-group group t))))))
6355 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6356 (let ((cur nntp-server-buffer)
6359 (with-current-buffer gnus-summary-buffer
6360 gnus-newsgroup-dependencies)))
6361 headers id end ref number
6362 (mail-parse-charset gnus-newsgroup-charset)
6363 (mail-parse-ignored-charsets
6364 (save-current-buffer (condition-case nil
6365 (set-buffer gnus-summary-buffer)
6367 gnus-newsgroup-ignored-charsets)))
6368 (with-current-buffer nntp-server-buffer
6369 ;; Translate all TAB characters into SPACE characters.
6370 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6371 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6372 (ietf-drums-unfold-fws)
6373 (gnus-run-hooks 'gnus-parse-headers-hook)
6374 (let ((case-fold-search t)
6375 in-reply-to header p lines chars)
6376 (goto-char (point-min))
6377 ;; Search to the beginning of the next header. Error messages
6378 ;; do not begin with 2 or 3.
6379 (while (re-search-forward "^[23][0-9]+ " nil t)
6382 ;; This implementation of this function, with nine
6383 ;; search-forwards instead of the one re-search-forward and
6384 ;; a case (which basically was the old function) is actually
6385 ;; about twice as fast, even though it looks messier. You
6386 ;; can't have everything, I guess. Speed and elegance
6387 ;; doesn't always go hand in hand.
6393 (setq number (read cur))
6396 (narrow-to-region (point)
6397 (or (and (search-forward "\n.\n" nil t)
6403 (if (search-forward "\nsubject:" nil t)
6404 (funcall gnus-decode-encoded-word-function
6405 (nnheader-header-value))
6410 (if (search-forward "\nfrom:" nil t)
6411 (funcall gnus-decode-encoded-address-function
6412 (nnheader-header-value))
6417 (if (search-forward "\ndate:" nil t)
6418 (nnheader-header-value) ""))
6422 (setq id (if (re-search-forward
6423 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6424 ;; We do it this way to make sure the Message-ID
6425 ;; is (somewhat) syntactically valid.
6426 (buffer-substring (match-beginning 1)
6428 ;; If there was no message-id, we just fake one
6429 ;; to make subsequent routines simpler.
6430 (nnheader-generate-fake-message-id number))))
6434 (if (search-forward "\nreferences:" nil t)
6438 (nnheader-header-value)
6443 (search-backward ">" end t)
6446 (search-backward "<" end t)
6448 ;; Get the references from the in-reply-to header if there
6449 ;; were no references and the in-reply-to header looks
6451 (if (and (search-forward "\nin-reply-to:" nil t)
6452 (setq in-reply-to (nnheader-header-value))
6453 (string-match "<[^>]+>" in-reply-to))
6455 (setq ref (substring in-reply-to (match-beginning 0)
6457 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6458 (setq ref2 (substring in-reply-to (match-beginning 0)
6460 (when (> (length ref2) (length ref))
6467 (if (search-forward "\nchars: " nil t)
6468 (if (numberp (setq chars (ignore-errors (read cur))))
6474 (if (search-forward "\nlines: " nil t)
6475 (if (numberp (setq lines (ignore-errors (read cur))))
6481 (and (search-forward "\nxref:" nil t)
6482 (nnheader-header-value)))
6484 (when gnus-extra-headers
6485 (let ((extra gnus-extra-headers)
6489 (when (search-forward
6490 (concat "\n" (symbol-name (car extra)) ":") nil t)
6491 (push (cons (car extra) (nnheader-header-value))
6495 (when (equal id ref)
6498 (when gnus-alter-header-function
6499 (funcall gnus-alter-header-function header)
6500 (setq id (mail-header-id header)
6501 ref (gnus-parent-id (mail-header-references header))))
6504 (gnus-dependencies-add-header
6505 header dependencies force-new))
6506 (push header headers))
6507 (goto-char (point-max))
6509 (nreverse headers)))))
6511 ;; Goes through the xover lines and returns a list of vectors
6512 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6513 force-new dependencies
6514 group also-fetch-heads)
6515 "Parse the news overview data in the server buffer.
6516 Return a list of headers that match SEQUENCE (see
6517 `nntp-retrieve-headers')."
6518 ;; Get the Xref when the users reads the articles since most/some
6519 ;; NNTP servers do not include Xrefs when using XOVER.
6520 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6521 (let ((mail-parse-charset gnus-newsgroup-charset)
6522 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6523 (cur nntp-server-buffer)
6524 (dependencies (or dependencies gnus-newsgroup-dependencies))
6526 ((eq gnus-read-all-available-headers t)
6528 ((and (stringp gnus-read-all-available-headers)
6530 (string-match gnus-read-all-available-headers group))
6533 number headers header)
6534 (with-current-buffer nntp-server-buffer
6535 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6536 ;; Allow the user to mangle the headers before parsing them.
6537 (gnus-run-hooks 'gnus-parse-headers-hook)
6538 (goto-char (point-min))
6539 (gnus-parse-without-error
6540 (while (and (or sequence allp)
6542 (setq number (read cur))
6544 (while (and sequence
6545 (< (car sequence) number))
6546 (setq sequence (cdr sequence))))
6549 (eq number (car sequence))))
6551 (setq sequence (cdr sequence))
6552 (setq header (inline
6553 (gnus-nov-parse-line
6554 number dependencies force-new)))))
6555 (push header headers))
6557 ;; A common bug in inn is that if you have posted an article and
6558 ;; then retrieves the active file, it will answer correctly --
6559 ;; the new article is included. However, a NOV entry for the
6560 ;; article may not have been generated yet, so this may fail.
6561 ;; We work around this problem by retrieving the last few
6562 ;; headers using HEAD.
6563 (if (or (not also-fetch-heads)
6565 ;; We (probably) got all the headers.
6567 (let ((gnus-nov-is-evil t))
6570 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6571 (gnus-get-newsgroup-headers))))))))
6573 (defun gnus-article-get-xrefs ()
6574 "Fill in the Xref value in `gnus-current-headers', if necessary.
6575 This is meant to be called in `gnus-article-internal-prepare-hook'."
6576 (let ((headers (with-current-buffer gnus-summary-buffer
6577 gnus-current-headers)))
6578 (or (not gnus-use-cross-reference)
6580 (and (mail-header-xref headers)
6581 (not (string= (mail-header-xref headers) "")))
6582 (let ((case-fold-search t)
6585 (nnheader-narrow-to-headers)
6586 (goto-char (point-min))
6587 (when (or (and (not (eobp))
6588 (eq (downcase (char-after)) ?x)
6589 (looking-at "Xref:"))
6590 (search-forward "\nXref:" nil t))
6591 (goto-char (1+ (match-end 0)))
6592 (setq xref (buffer-substring (point) (point-at-eol)))
6593 (mail-header-set-xref headers xref)))))))
6595 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6596 "Find article ID and insert the summary line for that article.
6597 OLD-HEADER can either be a header or a line number to insert
6598 the subject line on.
6599 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6600 and OLD-HEADER will be used when the summary line is inserted,
6601 too, instead of trying to fetch new headers."
6602 (let* ((line (and (numberp old-header) old-header))
6603 (old-header (and (vectorp old-header) old-header))
6604 (header (cond ((and old-header use-old-header)
6607 (gnus-number-to-header id))
6608 (gnus-number-to-header id))
6610 (gnus-read-header id))))
6611 (number (and (numberp id) id))
6614 ;; Rebuild the thread that this article is part of and go to the
6615 ;; article we have fetched.
6616 (when (and (not gnus-show-threads)
6619 (setq d (gnus-data-find (mail-header-number old-header))))
6620 (goto-char (gnus-data-pos d))
6626 (gnus-delete-line))))))
6627 ;; Remove list identifiers from subject.
6628 (let ((gnus-newsgroup-headers (list header)))
6629 (gnus-summary-remove-list-identifiers))
6631 (mail-header-set-number header (mail-header-number old-header)))
6632 (setq gnus-newsgroup-sparse
6633 (delq (setq number (mail-header-number header))
6634 gnus-newsgroup-sparse))
6635 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6636 (push number gnus-newsgroup-limit)
6637 (gnus-rebuild-thread (mail-header-id header) line)
6638 (gnus-summary-goto-subject number nil t))
6639 (when (and (numberp number)
6641 ;; We have to update the boundaries even if we can't fetch the
6642 ;; article if ID is a number -- so that the next `P' or `N'
6643 ;; command will fetch the previous (or next) article even
6644 ;; if the one we tried to fetch this time has been canceled.
6645 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6646 (setq gnus-newsgroup-end number))
6647 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6648 (setq gnus-newsgroup-begin number))
6649 (setq gnus-newsgroup-unselected
6650 (delq number gnus-newsgroup-unselected)))
6651 ;; Report back a success?
6652 (and header (mail-header-number header))))
6654 ;;; Process/prefix in the summary buffer
6656 (defun gnus-summary-work-articles (n)
6657 "Return a list of articles to be worked upon.
6658 The prefix argument, the list of process marked articles, and the
6659 current article will be taken into consideration."
6660 (with-current-buffer gnus-summary-buffer
6663 ;; A numerical prefix has been given.
6664 (setq n (prefix-numeric-value n))
6665 (let ((backward (< n 0))
6666 (n (abs (prefix-numeric-value n)))
6671 (push (setq article (gnus-summary-article-number))
6674 (gnus-summary-find-prev nil article)
6675 (gnus-summary-find-next nil article)))
6677 (nreverse articles)))
6678 ((and (gnus-region-active-p) (mark))
6679 (message "region active")
6680 ;; Work on the region between point and mark.
6681 (let ((max (max (point) (mark)))
6684 (goto-char (min (point) (mark)))
6687 (push (setq article (gnus-summary-article-number)) articles)
6688 (gnus-summary-find-next nil article)
6690 (nreverse articles))))
6691 (gnus-newsgroup-processable
6692 ;; There are process-marked articles present.
6693 ;; Save current state.
6694 (gnus-summary-save-process-mark)
6696 (reverse gnus-newsgroup-processable))
6698 ;; Just return the current article.
6699 (list (gnus-summary-article-number))))))
6701 (defmacro gnus-summary-iterate (arg &rest forms)
6702 "Iterate over the process/prefixed articles and do FORMS.
6703 ARG is the interactive prefix given to the command. FORMS will be
6704 executed with point over the summary line of the articles."
6705 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6706 `(let ((,articles (gnus-summary-work-articles ,arg)))
6708 (gnus-summary-goto-subject (car ,articles))
6712 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6713 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6715 (defun gnus-summary-save-process-mark ()
6716 "Push the current set of process marked articles on the stack."
6718 (push (copy-sequence gnus-newsgroup-processable)
6719 gnus-newsgroup-process-stack))
6721 (defun gnus-summary-kill-process-mark ()
6722 "Push the current set of process marked articles on the stack and unmark."
6724 (gnus-summary-save-process-mark)
6725 (gnus-summary-unmark-all-processable))
6727 (defun gnus-summary-yank-process-mark ()
6728 "Pop the last process mark state off the stack and restore it."
6730 (unless gnus-newsgroup-process-stack
6731 (error "Empty mark stack"))
6732 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6734 (defun gnus-summary-process-mark-set (set)
6735 "Make SET into the current process marked articles."
6736 (gnus-summary-unmark-all-processable)
6737 (mapc 'gnus-summary-set-process-mark set))
6739 ;;; Searching and stuff
6741 (defun gnus-summary-search-group (&optional backward use-level)
6742 "Search for next unread newsgroup.
6743 If optional argument BACKWARD is non-nil, search backward instead."
6744 (with-current-buffer gnus-group-buffer
6745 (when (gnus-group-search-forward
6746 backward nil (if use-level (gnus-group-group-level) nil))
6747 (gnus-group-group-name))))
6749 (defun gnus-summary-best-group (&optional exclude-group)
6750 "Find the name of the best unread group.
6751 If EXCLUDE-GROUP, do not go to this group."
6752 (with-current-buffer gnus-group-buffer
6754 (gnus-group-best-unread-group exclude-group))))
6756 (defun gnus-summary-find-next (&optional unread article backward)
6758 (gnus-summary-find-prev unread article)
6759 (let* ((dummy (gnus-summary-article-intangible-p))
6760 (article (or article (gnus-summary-article-number)))
6761 (data (gnus-data-find-list article))
6763 (when (and (not dummy)
6764 (or (not gnus-summary-check-current)
6766 (not (gnus-data-unread-p (car data)))))
6767 (setq data (cdr data)))
6772 (unless (memq (gnus-data-number (car data))
6774 ((eq gnus-auto-goto-ignores
6775 'always-undownloaded)
6776 gnus-newsgroup-undownloaded)
6779 ((eq gnus-auto-goto-ignores
6781 gnus-newsgroup-unfetched)
6782 ((eq gnus-auto-goto-ignores
6784 gnus-newsgroup-undownloaded)))
6785 (when (gnus-data-unread-p (car data))
6786 (setq result (car data)
6788 (setq data (cdr data)))
6791 (goto-char (gnus-data-pos result))
6792 (gnus-data-number result)))))
6794 (defun gnus-summary-find-prev (&optional unread article)
6795 (let* ((eobp (eobp))
6796 (article (or article (gnus-summary-article-number)))
6797 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6799 (when (and (not eobp)
6800 (or (not gnus-summary-check-current)
6802 (not (gnus-data-unread-p (car data)))))
6803 (setq data (cdr data)))
6808 (unless (memq (gnus-data-number (car data))
6810 ((eq gnus-auto-goto-ignores
6811 'always-undownloaded)
6812 gnus-newsgroup-undownloaded)
6815 ((eq gnus-auto-goto-ignores
6817 gnus-newsgroup-unfetched)
6818 ((eq gnus-auto-goto-ignores
6820 gnus-newsgroup-undownloaded)))
6821 (when (gnus-data-unread-p (car data))
6822 (setq result (car data)
6824 (setq data (cdr data)))
6827 (goto-char (gnus-data-pos result))
6828 (gnus-data-number result))))
6830 (defun gnus-summary-find-subject (subject &optional unread backward article)
6831 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6832 (article (or article (gnus-summary-article-number)))
6833 (articles (gnus-data-list backward))
6834 (arts (gnus-data-find-list article articles))
6836 (when (or (not gnus-summary-check-current)
6838 (not (gnus-data-unread-p (car arts))))
6839 (setq arts (cdr arts)))
6841 (and (or (not unread)
6842 (gnus-data-unread-p (car arts)))
6843 (vectorp (gnus-data-header (car arts)))
6845 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6846 (setq result (car arts)
6848 (setq arts (cdr arts)))
6850 (goto-char (gnus-data-pos result))
6851 (gnus-data-number result))))
6853 (defun gnus-summary-search-forward (&optional unread subject backward)
6854 "Search forward for an article.
6855 If UNREAD, look for unread articles. If SUBJECT, look for
6856 articles with that subject. If BACKWARD, search backward instead."
6857 (cond (subject (gnus-summary-find-subject subject unread backward))
6858 (backward (gnus-summary-find-prev unread))
6859 (t (gnus-summary-find-next unread))))
6861 (defun gnus-recenter (&optional n)
6862 "Center point in window and redisplay frame.
6863 Also do horizontal recentering."
6865 (when (and gnus-auto-center-summary
6866 (not (eq gnus-auto-center-summary 'vertical)))
6867 (gnus-horizontal-recenter))
6868 (if (fboundp 'recenter-top-bottom)
6869 (recenter-top-bottom n)
6872 (put 'gnus-recenter 'isearch-scroll t)
6874 (defun gnus-forward-line-ignore-invisible (n)
6875 "Move N lines forward (backward if N is negative).
6876 Like forward-line, but skip over (and don't count) invisible lines."
6878 (while (and (> n 0) (not done))
6879 ;; If the following character is currently invisible,
6880 ;; skip all characters with that same `invisible' property value.
6881 (while (gnus-invisible-p (point))
6882 (goto-char (gnus-next-char-property-change (point))))
6887 (while (and (< n 0) (not done))
6889 (if (bobp) (setq done t)
6891 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6892 (goto-char (gnus-previous-char-property-change (point))))))))
6894 (defun gnus-summary-recenter ()
6895 "Center point in the summary window.
6896 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6897 displayed, no centering will be performed."
6898 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6899 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6901 ;; The user has to want it.
6902 (when gnus-auto-center-summary
6903 (let* ((top (cond ((< (window-height) 4) 0)
6904 ((< (window-height) 7) 1)
6905 (t (if (numberp gnus-auto-center-summary)
6906 gnus-auto-center-summary
6907 (/ (1- (window-height)) 2)))))
6908 (height (1- (window-height)))
6909 (bottom (save-excursion
6910 (goto-char (point-max))
6911 (gnus-forward-line-ignore-invisible (- height))
6913 (window (get-buffer-window (current-buffer))))
6914 (when (get-buffer-window gnus-article-buffer)
6915 ;; Only do recentering when the article buffer is displayed,
6916 ;; Set the window start to either `bottom', which is the biggest
6917 ;; possible valid number, or the second line from the top,
6918 ;; whichever is the least.
6919 (let ((top-pos (save-excursion
6920 (gnus-forward-line-ignore-invisible (- top))
6922 (if (> bottom top-pos)
6923 ;; Keep the second line from the top visible
6924 (set-window-start window top-pos)
6925 ;; Try to keep the bottom line visible; if it's partially
6926 ;; obscured, either scroll one more line to make it fully
6927 ;; visible, or revert to using TOP-POS.
6929 (goto-char (point-max))
6930 (gnus-forward-line-ignore-invisible -1)
6931 (let ((last-line-start (point)))
6933 (set-window-start window (point) t)
6934 (when (not (pos-visible-in-window-p last-line-start window))
6935 (gnus-forward-line-ignore-invisible 1)
6936 (set-window-start window (min (point) top-pos) t)))))))
6937 ;; Do horizontal recentering while we're at it.
6938 (when (and (get-buffer-window (current-buffer) t)
6939 (not (eq gnus-auto-center-summary 'vertical)))
6940 (let ((selected (selected-window)))
6941 (select-window (get-buffer-window (current-buffer) t))
6942 (gnus-summary-position-point)
6943 (gnus-horizontal-recenter)
6944 (select-window selected))))))
6946 (defun gnus-summary-jump-to-group (newsgroup)
6947 "Move point to NEWSGROUP in group mode buffer."
6948 ;; Keep update point of group mode buffer if visible.
6949 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6950 (save-window-excursion
6951 ;; Take care of tree window mode.
6952 (when (get-buffer-window gnus-group-buffer)
6953 (pop-to-buffer gnus-group-buffer))
6954 (gnus-group-jump-to-group newsgroup))
6956 ;; Take care of tree window mode.
6957 (if (get-buffer-window gnus-group-buffer 0)
6958 (pop-to-buffer gnus-group-buffer)
6959 (set-buffer gnus-group-buffer))
6960 (gnus-group-jump-to-group newsgroup))))
6962 ;; This function returns a list of article numbers based on the
6963 ;; difference between the ranges of read articles in this group and
6964 ;; the range of active articles.
6965 (defun gnus-list-of-unread-articles (group)
6966 (let* ((read (gnus-info-read (gnus-get-info group)))
6967 (active (or (gnus-active group) (gnus-activate-group group)))
6968 (last (or (cdr active)
6969 (error "Group %s couldn't be activated " group)))
6970 (bottom (if gnus-newsgroup-maximum-articles
6972 (- last gnus-newsgroup-maximum-articles -1))
6975 ;; If none are read, then all are unread.
6978 ;; If the range of read articles is a single range, then the
6979 ;; first unread article is the article after the last read
6980 ;; article. Sounds logical, doesn't it?
6981 (if (and (not (listp (cdr read)))
6982 (or (< (car read) bottom)
6983 (progn (setq read (list read))
6985 (setq first (max bottom (1+ (cdr read))))
6986 ;; `read' is a list of ranges.
6987 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6990 (setq first bottom))
6993 (while (< first nlast)
6994 (setq unread (cons first unread)
6996 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6997 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6998 (setq read (cdr read)))))
6999 ;; And add the last unread articles.
7000 (while (<= first last)
7001 (setq unread (cons first unread)
7003 ;; Return the list of unread articles.
7004 (delq 0 (nreverse unread))))
7006 (defun gnus-list-of-read-articles (group)
7007 "Return a list of unread, unticked and non-dormant articles."
7008 (let* ((info (gnus-get-info group))
7009 (marked (gnus-info-marks info))
7010 (active (gnus-active group)))
7012 (gnus-list-range-difference
7013 (gnus-list-range-difference
7014 (gnus-sorted-complement
7015 (gnus-uncompress-range
7016 (if gnus-newsgroup-maximum-articles
7017 (cons (max (car active)
7019 gnus-newsgroup-maximum-articles
7023 (gnus-list-of-unread-articles group))
7024 (cdr (assq 'dormant marked)))
7025 (cdr (assq 'tick marked))))))
7027 ;; This function returns a sequence of article numbers based on the
7028 ;; difference between the ranges of read articles in this group and
7029 ;; the range of active articles.
7030 (defun gnus-sequence-of-unread-articles (group)
7031 (let* ((read (gnus-info-read (gnus-get-info group)))
7032 (active (or (gnus-active group) (gnus-activate-group group)))
7034 (bottom (if gnus-newsgroup-maximum-articles
7036 (- last gnus-newsgroup-maximum-articles -1))
7039 ;; If none are read, then all are unread.
7042 ;; If the range of read articles is a single range, then the
7043 ;; first unread article is the article after the last read
7044 ;; article. Sounds logical, doesn't it?
7045 (if (and (not (listp (cdr read)))
7046 (or (< (car read) bottom)
7047 (progn (setq read (list read))
7049 (setq first (max bottom (1+ (cdr read))))
7050 ;; `read' is a list of ranges.
7051 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7054 (setq first bottom))
7057 (push (cons first nlast) unread))
7058 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7059 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7060 (setq read (cdr read)))))
7061 ;; And add the last unread articles.
7062 (cond ((not (and first last))
7065 (push (cons first last) unread))
7067 (push first unread)))
7068 ;; Return the sequence of unread articles.
7069 (delq 0 (nreverse unread))))
7071 ;; Various summary commands
7073 (defun gnus-summary-select-article-buffer ()
7074 "Reconfigure windows to show the article buffer.
7075 If `gnus-widen-article-window' is set, show only the article
7078 (if (not (gnus-buffer-live-p gnus-article-buffer))
7079 (error "There is no article buffer for this summary buffer")
7080 (unless (get-buffer-window gnus-article-buffer)
7081 (gnus-summary-show-article))
7082 (gnus-configure-windows
7083 (if gnus-widen-article-window
7087 (select-window (get-buffer-window gnus-article-buffer))))
7089 (defun gnus-summary-universal-argument (arg)
7090 "Perform any operation on all articles that are process/prefixed."
7092 (let ((articles (gnus-summary-work-articles arg))
7099 (substitute-command-keys
7100 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7102 (gnus-error 1 "Undefined key")
7105 (gnus-summary-goto-subject (setq article (pop articles)))
7106 (let (gnus-newsgroup-processable)
7107 (command-execute func))
7108 (gnus-summary-remove-process-mark article)))))
7109 (gnus-summary-position-point))
7111 (defun gnus-summary-toggle-truncation (&optional arg)
7112 "Toggle truncation of summary lines.
7113 With ARG, turn line truncation on if ARG is positive."
7115 (setq truncate-lines
7116 (if (null arg) (not truncate-lines)
7117 (> (prefix-numeric-value arg) 0)))
7120 (defun gnus-summary-find-for-reselect ()
7121 "Return the number of an article to stay on across a reselect.
7122 The current article is considered, then following articles, then previous
7123 articles. An article is sought which is not canceled and isn't a temporary
7124 insertion from another group. If there's no such then return a dummy 0."
7126 (dolist (rev '(nil t))
7127 (unless found ; don't demand the reverse list if we don't need it
7128 (let ((data (gnus-data-find-list
7129 (gnus-summary-article-number) (gnus-data-list rev))))
7130 (while (and data (not found))
7131 (if (and (< 0 (gnus-data-number (car data)))
7132 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7133 (setq found (gnus-data-number (car data))))
7134 (setq data (cdr data))))))
7137 (defun gnus-summary-reselect-current-group (&optional all rescan)
7138 "Exit and then reselect the current newsgroup.
7139 The prefix argument ALL means to select all articles."
7141 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7142 (error "Ephemeral groups can't be reselected"))
7143 (let ((current-subject (gnus-summary-find-for-reselect))
7144 (group gnus-newsgroup-name))
7145 (setq gnus-newsgroup-begin nil)
7146 (gnus-summary-exit nil 'leave-hidden)
7147 ;; We have to adjust the point of group mode buffer because
7148 ;; point was moved to the next unread newsgroup by exiting.
7149 (gnus-summary-jump-to-group group)
7152 (gnus-group-get-new-news-this-group 1)))
7153 (gnus-group-read-group all t)
7154 (gnus-summary-goto-subject current-subject nil t)))
7156 (defun gnus-summary-rescan-group (&optional all)
7157 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7159 (let ((config gnus-current-window-configuration))
7160 (gnus-summary-reselect-current-group all t)
7161 (gnus-configure-windows config)
7162 (when (eq config 'article)
7163 (gnus-summary-select-article))))
7165 (defun gnus-summary-update-info (&optional non-destructive)
7167 (let ((group gnus-newsgroup-name))
7169 (when gnus-newsgroup-kill-headers
7170 (setq gnus-newsgroup-killed
7171 (gnus-compress-sequence
7173 (gnus-list-range-intersection
7174 gnus-newsgroup-unselected gnus-newsgroup-killed)
7175 gnus-newsgroup-unreads)
7177 (unless (listp (cdr gnus-newsgroup-killed))
7178 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7179 (let ((headers gnus-newsgroup-headers)
7180 (ephemeral-p (gnus-ephemeral-group-p group))
7183 (setq info (copy-sequence (gnus-get-info group))
7184 info (delq (gnus-info-params info) info)))
7185 ;; Set the new ranges of read articles.
7186 (with-current-buffer gnus-group-buffer
7187 (gnus-undo-force-boundary))
7188 (gnus-update-read-articles
7189 group (gnus-sorted-union
7190 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7191 ;; Set the current article marks.
7192 (let ((gnus-newsgroup-scored
7193 (if (and (not gnus-save-score)
7194 (not non-destructive))
7196 gnus-newsgroup-scored)))
7198 (gnus-update-marks)))
7199 ;; Do the cross-ref thing.
7200 (when gnus-use-cross-reference
7201 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7202 ;; Do not switch windows but change the buffer to work.
7203 (set-buffer gnus-group-buffer)
7205 (gnus-group-update-group
7208 (setq info (copy-sequence (gnus-get-info group))
7209 info (delq (gnus-info-params info) info))))))))))
7211 (defun gnus-summary-save-newsrc (&optional force)
7212 "Save the current number of read/marked articles in the dribble buffer.
7213 The dribble buffer will then be saved.
7214 If FORCE (the prefix), also save the .newsrc file(s)."
7216 (gnus-summary-update-info t)
7218 (gnus-save-newsrc-file)
7219 (gnus-dribble-save)))
7221 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7222 (declare-function gnus-article-stop-animations "gnus-art" ())
7224 (defun gnus-summary-exit (&optional temporary leave-hidden)
7225 "Exit reading current newsgroup, and then return to group selection mode.
7226 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7228 (gnus-set-global-variables)
7229 (when (gnus-buffer-live-p gnus-article-buffer)
7230 (with-current-buffer gnus-article-buffer
7231 (mm-destroy-parts gnus-article-mime-handles)
7232 ;; Set it to nil for safety reason.
7233 (setq gnus-article-mime-handle-alist nil)
7234 (setq gnus-article-mime-handles nil)))
7235 (gnus-kill-save-kill-buffer)
7236 (gnus-async-halt-prefetch)
7237 (let* ((group gnus-newsgroup-name)
7238 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7239 (gnus-group-is-exiting-p t)
7240 (article-buffer gnus-article-buffer)
7241 (original-article-buffer gnus-original-article-buffer)
7244 (buf (current-buffer))
7245 ;; `gnus-single-article-buffer' is nil buffer-locally in
7246 ;; ephemeral group of which summary buffer will be killed,
7247 ;; but the global value may be non-nil.
7248 (single-article-buffer gnus-single-article-buffer))
7250 ;; Do adaptive scoring, and possibly save score files.
7251 (when gnus-newsgroup-adaptive
7252 (gnus-score-adaptive))
7253 (when gnus-use-scoring
7255 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7256 (when gnus-use-cache
7257 (gnus-cache-possibly-remove-articles)
7258 (gnus-cache-save-buffers))
7259 (gnus-async-prefetch-remove-group group)
7260 (when gnus-suppress-duplicates
7261 (gnus-dup-enter-articles))
7262 (when gnus-use-trees
7264 (when gnus-use-cache
7265 (gnus-cache-write-active))
7266 ;; Remove entries for this group.
7267 (nnmail-purge-split-history (gnus-group-real-name group))
7268 ;; Make all changes in this group permanent.
7270 (gnus-run-hooks 'gnus-exit-group-hook)
7271 (gnus-summary-update-info))
7272 (gnus-close-group group)
7273 ;; Make sure where we were, and go to next newsgroup.
7274 (when (buffer-live-p (get-buffer gnus-group-buffer))
7275 (set-buffer gnus-group-buffer))
7277 (gnus-group-jump-to-group group))
7278 (gnus-run-hooks 'gnus-summary-exit-hook)
7279 (unless (or quit-config
7280 (not gnus-summary-next-group-on-exit)
7281 ;; If this group has disappeared from the summary
7282 ;; buffer, don't skip forwards.
7283 (not (string= group (gnus-group-group-name))))
7284 (gnus-group-next-unread-group 1))
7285 (setq group-point (point))
7286 (gnus-article-stop-animations)
7290 (if (not gnus-kill-summary-on-exit)
7292 (gnus-deaden-summary)
7294 (when (get-buffer gnus-article-buffer)
7295 (bury-buffer gnus-article-buffer))
7296 ;; Return to group mode buffer.
7297 (when (eq mode 'gnus-summary-mode)
7298 (gnus-kill-buffer buf)))
7300 (setq gnus-current-select-method gnus-select-method)
7301 (when (gnus-buffer-live-p gnus-group-buffer)
7302 (set-buffer gnus-group-buffer))
7304 (gnus-handle-ephemeral-exit quit-config)
7305 (goto-char group-point)
7306 ;; If gnus-group-buffer is already displayed, make sure we also move
7307 ;; the cursor in the window that displays it.
7308 (let ((win (get-buffer-window (current-buffer) 0)))
7309 (if win (set-window-point win (point))))
7310 (unless leave-hidden
7311 (gnus-configure-windows 'group 'force)))
7313 ;; If we have several article buffers, we kill them at exit.
7314 (unless single-article-buffer
7315 (when (gnus-buffer-live-p article-buffer)
7316 (with-current-buffer article-buffer
7317 ;; Don't kill sticky article buffers
7318 (unless (eq major-mode 'gnus-sticky-article-mode)
7319 (gnus-kill-buffer article-buffer)
7320 (setq gnus-article-current nil))))
7321 (gnus-kill-buffer original-article-buffer))
7323 ;; Clear the current group name.
7325 (setq gnus-newsgroup-name nil)))))
7327 (declare-function gnus-stop-downloads "gnus-art" ())
7329 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7330 (defun gnus-summary-exit-no-update (&optional no-questions)
7331 "Quit reading current newsgroup without updating read article info."
7333 (let* ((group gnus-newsgroup-name)
7334 (gnus-group-is-exiting-p t)
7335 (gnus-group-is-exiting-without-update-p t)
7336 (quit-config (gnus-group-quit-config group)))
7337 (when (or no-questions
7338 (gnus-ephemeral-group-p group)
7340 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7341 (gnus-async-halt-prefetch)
7342 (run-hooks 'gnus-summary-prepare-exit-hook)
7343 (when (gnus-buffer-live-p gnus-article-buffer)
7344 (with-current-buffer gnus-article-buffer
7345 (gnus-article-stop-animations)
7346 (gnus-stop-downloads)
7347 (mm-destroy-parts gnus-article-mime-handles)
7348 ;; Set it to nil for safety reason.
7349 (setq gnus-article-mime-handle-alist nil)
7350 (setq gnus-article-mime-handles nil)))
7351 ;; If we have several article buffers, we kill them at exit.
7352 (unless gnus-single-article-buffer
7353 (gnus-kill-buffer gnus-article-buffer)
7354 (gnus-kill-buffer gnus-original-article-buffer)
7355 (setq gnus-article-current nil))
7356 ;; Return to the group buffer.
7357 (if (not gnus-kill-summary-on-exit)
7359 (gnus-deaden-summary)
7360 (gnus-configure-windows 'group 'force))
7361 (gnus-configure-windows 'group 'force)
7362 (gnus-close-group group)
7363 (gnus-kill-buffer gnus-summary-buffer))
7364 (unless gnus-single-article-buffer
7365 (setq gnus-article-current nil))
7366 (when gnus-use-trees
7368 (gnus-async-prefetch-remove-group group)
7369 (when (get-buffer gnus-article-buffer)
7370 (bury-buffer gnus-article-buffer))
7371 ;; Clear the current group name.
7372 (setq gnus-newsgroup-name nil)
7373 (unless (gnus-ephemeral-group-p group)
7374 (gnus-group-update-group group nil t))
7375 (when (equal (gnus-group-group-name) group)
7376 (gnus-group-next-unread-group 1))
7377 (gnus-article-stop-animations)
7379 (gnus-handle-ephemeral-exit quit-config)))))
7381 (defun gnus-handle-ephemeral-exit (quit-config)
7382 "Handle movement when leaving an ephemeral group.
7383 The state which existed when entering the ephemeral is reset."
7384 (if (not (buffer-live-p (car quit-config)))
7385 (when (gnus-buffer-live-p gnus-group-buffer)
7386 (gnus-configure-windows 'group 'force))
7387 (set-buffer (car quit-config))
7388 (unless (eq (cdr quit-config) 'group)
7389 (setq gnus-current-select-method
7390 (gnus-find-method-for-group gnus-newsgroup-name)))
7391 (cond ((derived-mode-p 'gnus-summary-mode)
7392 (gnus-set-global-variables))
7393 ((derived-mode-p 'gnus-article-mode)
7394 (save-current-buffer
7395 ;; The `gnus-summary-buffer' variable may point
7396 ;; to the old summary buffer when using a single
7398 (unless (gnus-buffer-live-p gnus-summary-buffer)
7399 (set-buffer gnus-group-buffer))
7400 (set-buffer gnus-summary-buffer)
7401 (gnus-set-global-variables))))
7402 (if (or (eq (cdr quit-config) 'article)
7403 (eq (cdr quit-config) 'pick))
7404 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7405 (gnus-configure-windows 'pick 'force)
7406 (gnus-configure-windows (cdr quit-config) 'force))
7407 (gnus-configure-windows (cdr quit-config) 'force))
7408 (when (derived-mode-p 'gnus-summary-mode)
7409 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7410 next-unread-noselect))
7411 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7413 (gnus-summary-next-subject 1 nil t))
7414 ((eq gnus-auto-select-on-ephemeral-exit
7415 'next-unread-noselect)
7416 (gnus-summary-next-subject 1 t t))))
7417 ;; Hide the article buffer which displays the article different
7418 ;; from the one that the cursor points to in the summary buffer.
7419 (gnus-configure-windows 'summary 'force))
7420 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7421 (gnus-summary-next-subject 1))
7422 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7423 (gnus-summary-next-subject 1 t))))
7424 (gnus-summary-recenter)
7425 (gnus-summary-position-point))))
7429 (defvar gnus-dead-summary-mode-map
7430 (let ((map (make-keymap)))
7431 (suppress-keymap map)
7432 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7433 (dolist (key '("\C-d" "\r" "\177" [delete]))
7434 (define-key map key 'gnus-summary-wake-up-the-dead))
7435 (dolist (key '("q" "Q"))
7436 (define-key map key 'bury-buffer))
7439 (define-minor-mode gnus-dead-summary-mode
7440 "Minor mode for Gnus summary buffers."
7441 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7442 (unless (derived-mode-p 'gnus-summary-mode)
7443 (setq gnus-dead-summary-mode nil)))
7445 (defun gnus-deaden-summary ()
7446 "Make the current summary buffer into a dead summary buffer."
7447 ;; Kill any previous dead summary buffer.
7448 (when (and gnus-dead-summary
7449 (buffer-name gnus-dead-summary))
7450 (with-current-buffer gnus-dead-summary
7451 (when gnus-dead-summary-mode
7452 (kill-buffer (current-buffer)))))
7453 ;; Make this the current dead summary.
7454 (setq gnus-dead-summary (current-buffer))
7455 (gnus-dead-summary-mode 1)
7456 (let ((name (buffer-name)))
7457 (when (string-match "Summary" name)
7459 (concat (substring name 0 (match-beginning 0)) "Dead "
7460 (substring name (match-beginning 0)))
7464 (defun gnus-kill-or-deaden-summary (buffer)
7465 "Kill or deaden the summary BUFFER."
7467 (when (and (buffer-name buffer)
7468 (not gnus-single-article-buffer))
7469 (with-current-buffer buffer
7470 (gnus-kill-buffer gnus-article-buffer)
7471 (gnus-kill-buffer gnus-original-article-buffer)))
7474 (gnus-kill-summary-on-exit
7475 (when (and gnus-use-trees
7476 (gnus-buffer-exists-p buffer))
7477 (with-current-buffer buffer
7479 (gnus-kill-buffer buffer))
7480 ;; Deaden the buffer.
7481 ((gnus-buffer-exists-p buffer)
7482 (with-current-buffer buffer
7483 (gnus-deaden-summary))))))
7485 (defun gnus-summary-wake-up-the-dead (&rest args)
7486 "Wake up the dead summary buffer."
7488 (gnus-dead-summary-mode -1)
7489 (let ((name (buffer-name)))
7490 (when (string-match "Dead " name)
7492 (concat (substring name 0 (match-beginning 0))
7493 (substring name (match-end 0)))
7495 (gnus-message 3 "This dead summary is now alive again"))
7497 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7498 (defun gnus-summary-describe-group (&optional force)
7499 "Describe the current newsgroup."
7501 (gnus-group-describe-group force gnus-newsgroup-name))
7503 (defun gnus-summary-describe-briefly ()
7504 "Describe summary mode commands briefly."
7506 (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")))
7508 ;; Walking around group mode buffer from summary mode.
7510 (defun gnus-summary-next-group (&optional no-article target-group backward)
7511 "Exit current newsgroup and then select next unread newsgroup.
7512 If prefix argument NO-ARTICLE is non-nil, no article is selected
7513 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7514 previous group instead."
7516 ;; Stop pre-fetching.
7517 (gnus-async-halt-prefetch)
7518 (let ((current-group gnus-newsgroup-name)
7519 (current-buffer (current-buffer))
7521 ;; First we semi-exit this group to update Xrefs and all variables.
7522 ;; We can't do a real exit, because the window conf must remain
7523 ;; the same in case the user is prompted for info, and we don't
7524 ;; want the window conf to change before that...
7525 (gnus-summary-exit t)
7526 (while (not entered)
7527 ;; Then we find what group we are supposed to enter.
7528 (set-buffer gnus-group-buffer)
7529 (gnus-group-jump-to-group current-group)
7532 (if (eq gnus-keep-same-level 'best)
7533 (gnus-summary-best-group gnus-newsgroup-name)
7534 (gnus-summary-search-group backward gnus-keep-same-level))))
7535 (if (not target-group)
7536 ;; There are no further groups, so we return to the group
7539 (gnus-message 5 "Returning to the group buffer")
7541 (when (gnus-buffer-live-p current-buffer)
7542 (set-buffer current-buffer)
7543 (gnus-summary-exit))
7544 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7545 ;; We try to enter the target group.
7546 (gnus-group-jump-to-group target-group)
7547 (let ((unreads (gnus-group-group-unread)))
7548 (if (and (or (eq t unreads)
7549 (and unreads (not (zerop unreads))))
7550 (gnus-summary-read-group
7551 target-group nil no-article
7552 (and (buffer-name current-buffer) current-buffer)
7555 (setq current-group target-group
7556 target-group nil)))))))
7558 (defun gnus-summary-prev-group (&optional no-article)
7559 "Exit current newsgroup and then select previous unread newsgroup.
7560 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7562 (gnus-summary-next-group no-article nil t))
7564 ;; Walking around summary lines.
7566 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7567 "Go to the first subject satisfying any non-nil constraint.
7568 If UNREAD is non-nil, the article should be unread.
7569 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7570 If UNSEEN is non-nil, the article should be unseen as well as unread.
7571 Returns the article selected or nil if there are no matching articles."
7575 ((null gnus-newsgroup-data)
7576 (gnus-message 3 "No articles in the group")
7578 ;; Pick the first article.
7579 ((not (or unread undownloaded unseen))
7580 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7581 (gnus-data-number (car gnus-newsgroup-data)))
7582 ;; Find the first unread article.
7584 (let ((data gnus-newsgroup-data))
7586 (let ((num (gnus-data-number (car data))))
7587 (or (memq num gnus-newsgroup-unfetched)
7588 (not (or (and unread
7589 (memq num gnus-newsgroup-unreads))
7591 (memq num gnus-newsgroup-undownloaded))
7593 (memq num gnus-newsgroup-unseen)
7594 (memq num gnus-newsgroup-unreads)))))))
7595 (setq data (cdr data)))
7599 (goto-char (gnus-data-pos (car data)))
7600 (gnus-data-number (car data)))
7601 (gnus-message 3 "No more%s articles"
7602 (let* ((r (when unread " unread"))
7603 (d (when undownloaded " undownloaded"))
7604 (s (when unseen " unseen"))
7605 (l (delq nil (list r d s))))
7606 (cond ((= 3 (length l))
7607 (concat r "," d ", or" s))
7609 (concat (car l) ", or" (cadr l)))
7616 (gnus-summary-position-point))))))
7618 (defun gnus-summary-next-subject (n &optional unread dont-display)
7619 "Go to next N'th summary line.
7620 If N is negative, go to the previous N'th subject line.
7621 If UNREAD is non-nil, only unread articles are selected.
7622 The difference between N and the actual number of steps taken is
7625 (let ((backward (< n 0))
7629 (gnus-summary-find-prev unread)
7630 (gnus-summary-find-next unread)))
7631 (unless (zerop (setq n (1- n)))
7632 (gnus-summary-show-thread)))
7634 (gnus-message 7 "No more%s articles"
7635 (if unread " unread" "")))
7636 (unless dont-display
7637 (gnus-summary-recenter)
7638 (gnus-summary-position-point))
7641 (defun gnus-summary-next-unread-subject (n)
7642 "Go to next N'th unread summary line."
7644 (gnus-summary-next-subject n t))
7646 (defun gnus-summary-prev-subject (n &optional unread)
7647 "Go to previous N'th summary line.
7648 If optional argument UNREAD is non-nil, only unread article is selected."
7650 (gnus-summary-next-subject (- n) unread))
7652 (defun gnus-summary-prev-unread-subject (n)
7653 "Go to previous N'th unread summary line."
7655 (gnus-summary-next-subject (- n) t))
7657 (defun gnus-summary-goto-subjects (articles)
7658 "Insert the subject header for ARTICLES in the current buffer."
7660 (dolist (article articles)
7661 (gnus-summary-goto-subject article t)))
7662 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7663 (gnus-summary-position-point))
7665 (defun gnus-summary-goto-subject (article &optional force silent)
7666 "Go to the subject line of ARTICLE.
7667 If FORCE, also allow jumping to articles not currently shown."
7668 (interactive "nArticle number: ")
7669 (unless (numberp article)
7670 (error "Article %s is not a number" article))
7672 (data (gnus-data-find article)))
7673 ;; We read in the article if we have to.
7676 (gnus-summary-insert-subject
7678 (if (or (numberp force) (vectorp force)) force)
7680 (setq data (gnus-data-find article)))
7685 (gnus-message 3 "Can't find article %d" article))
7687 (let ((pt (gnus-data-pos data)))
7689 (gnus-summary-set-article-display-arrow pt))
7690 (gnus-summary-position-point)
7693 ;; Walking around summary lines with displaying articles.
7695 (defun gnus-summary-expand-window (&optional arg)
7696 "Make the summary buffer take up the entire Emacs frame.
7697 Given a prefix, will force an `article' buffer configuration."
7700 (gnus-configure-windows 'article 'force)
7701 (gnus-configure-windows 'summary 'force)))
7703 (defun gnus-summary-display-article (article &optional all-header)
7704 "Display ARTICLE in article buffer."
7705 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7706 (with-current-buffer gnus-article-buffer
7707 (derived-mode-p 'gnus-article-mode)))
7708 (gnus-article-setup-buffer))
7709 (gnus-set-global-variables)
7710 (with-current-buffer gnus-article-buffer
7711 (setq gnus-article-charset gnus-newsgroup-charset)
7712 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7713 (mm-enable-multibyte))
7717 (if gnus-summary-display-article-function
7718 (funcall gnus-summary-display-article-function article all-header)
7719 (gnus-article-prepare article all-header))
7720 (gnus-run-hooks 'gnus-select-article-hook)
7721 (when (and gnus-current-article
7722 (not (zerop gnus-current-article)))
7723 (gnus-summary-goto-subject gnus-current-article))
7724 (gnus-summary-recenter)
7725 (when (and gnus-use-trees gnus-show-threads)
7726 (gnus-possibly-generate-tree article)
7727 (gnus-highlight-selected-tree article))
7728 ;; Successfully display article.
7729 (gnus-article-set-window-start
7730 (cdr (assq article gnus-newsgroup-bookmarks))))))
7732 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7733 "Select the current article.
7734 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7735 non-nil, the article will be re-fetched even if it already present in
7736 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7738 ;; Make sure we are in the summary buffer to work around bbdb bug.
7739 (unless (derived-mode-p 'gnus-summary-mode)
7740 (set-buffer gnus-summary-buffer))
7741 (let ((article (or article (gnus-summary-article-number)))
7742 (all-headers (not (not all-headers))) ;Must be t or nil.
7743 gnus-summary-display-article-function)
7745 (gnus-summary-article-pseudo-p article)
7746 (error "This is a pseudo-article"))
7747 (with-current-buffer gnus-summary-buffer
7748 (if (or (and gnus-single-article-buffer
7749 (or (null gnus-current-article)
7750 (null gnus-article-current)
7751 (null (get-buffer gnus-article-buffer))
7752 (not (eq article (cdr gnus-article-current)))
7753 (not (equal (car gnus-article-current)
7754 gnus-newsgroup-name))
7755 (not (get-buffer gnus-original-article-buffer))))
7756 (and (not gnus-single-article-buffer)
7757 (or (null gnus-current-article)
7758 (not (get-buffer gnus-original-article-buffer))
7759 (not (eq gnus-current-article article))))
7761 ;; The requested article is different from the current article.
7763 (gnus-summary-display-article article all-headers)
7764 (when (gnus-buffer-live-p gnus-article-buffer)
7765 (with-current-buffer gnus-article-buffer
7766 (if (not gnus-article-decoded-p) ;; a local variable
7767 (mm-disable-multibyte))))
7768 (gnus-article-set-window-start
7769 (cdr (assq article gnus-newsgroup-bookmarks)))
7773 (defun gnus-summary-force-verify-and-decrypt ()
7774 "Display buttons for signed/encrypted parts and verify/decrypt them."
7776 (let ((mm-verify-option 'known)
7777 (mm-decrypt-option 'known)
7778 (gnus-article-emulate-mime t)
7779 (gnus-buttonized-mime-types (append (list "multipart/signed"
7780 "multipart/encrypted")
7781 gnus-buttonized-mime-types)))
7782 (gnus-summary-select-article nil 'force)))
7784 (defun gnus-summary-next-article (&optional unread subject backward push)
7785 "Select the next article.
7786 If UNREAD, only unread articles are selected.
7787 If SUBJECT, only articles with SUBJECT are selected.
7788 If BACKWARD, the previous article is selected instead of the next."
7790 ;; Make sure we are in the summary buffer.
7791 (unless (derived-mode-p 'gnus-summary-mode)
7792 (set-buffer gnus-summary-buffer))
7794 ;; Is there such an article?
7795 ((and (gnus-summary-search-forward unread subject backward)
7796 (or (gnus-summary-display-article (gnus-summary-article-number))
7797 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7798 (gnus-summary-position-point))
7799 ;; If not, we try the first unread, if that is wanted.
7801 gnus-auto-select-same
7802 (gnus-summary-first-unread-article))
7803 (gnus-summary-position-point)
7804 (gnus-message 6 "Wrapped"))
7805 ;; Try to get next/previous article not displayed in this group.
7806 ((and gnus-auto-extend-newsgroup
7807 (not unread) (not subject))
7808 (gnus-summary-goto-article
7809 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7810 nil (count-lines (point-min) (point))))
7811 ;; Go to next/previous group.
7813 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7814 (gnus-summary-jump-to-group gnus-newsgroup-name))
7815 (let ((cmd (if (featurep 'xemacs)
7817 last-command-event))
7819 (with-current-buffer gnus-group-buffer
7821 (current-summary (current-buffer))
7823 (if (eq gnus-keep-same-level 'best)
7824 (gnus-summary-best-group gnus-newsgroup-name)
7825 (gnus-summary-search-group backward gnus-keep-same-level))))
7826 ;; Select next unread newsgroup automagically.
7828 ((or (not gnus-auto-select-next)
7830 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7831 ((or (eq gnus-auto-select-next 'quietly)
7832 (and (eq gnus-auto-select-next 'slightly-quietly)
7834 (and (eq gnus-auto-select-next 'almost-quietly)
7835 (gnus-summary-last-article-p)))
7837 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7839 (gnus-message 7 "No more%s articles (%s)..."
7840 (if unread " unread" "")
7841 (if group (concat "selecting " group)
7843 (gnus-summary-next-group nil group backward)))
7845 (when (gnus-key-press-event-p last-input-event)
7846 ;; Somehow or other, we may now have selected a different
7847 ;; window. Make point go back to the summary buffer.
7848 (when (eq current-summary (current-buffer))
7849 ;; FIXME: This burps when get-buffer-window returns nil.
7850 (select-window (get-buffer-window current-summary 0)))
7851 (gnus-summary-walk-group-buffer
7852 gnus-newsgroup-name cmd unread backward point))))))))
7854 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7855 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7856 (?\C-p (gnus-group-prev-unread-group 1))))
7857 (cursor-in-echo-area t)
7858 keve key group ended prompt)
7859 (with-current-buffer gnus-group-buffer
7862 (if (eq gnus-keep-same-level 'best)
7863 (gnus-summary-best-group gnus-newsgroup-name)
7864 (gnus-summary-search-group backward gnus-keep-same-level))))
7868 "No more%s articles%s " (if unread " unread" "")
7870 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7871 (format " (Type %s for %s [%s])"
7872 (single-key-description cmd)
7873 (gnus-group-decoded-name group)
7874 (gnus-group-unread group))
7875 (format " (Type %s to exit %s)"
7876 (single-key-description cmd)
7877 (gnus-group-decoded-name gnus-newsgroup-name)))))
7878 ;; Confirm auto selection.
7879 (setq key (car (setq keve (gnus-read-event-char prompt)))
7882 ((assq key keystrokes)
7883 (let ((obuf (current-buffer)))
7884 (switch-to-buffer gnus-group-buffer)
7886 (gnus-group-jump-to-group group))
7887 (eval (cadr (assq key keystrokes)))
7888 (setq group (gnus-group-group-name))
7889 (switch-to-buffer obuf))
7893 (gnus-ephemeral-group-p gnus-newsgroup-name))
7895 (gnus-summary-next-group nil group backward)))
7897 (push (cdr keve) unread-command-events))))))
7899 (defun gnus-summary-next-unread-article ()
7900 "Select unread article after current one."
7902 (gnus-summary-next-article
7903 (or (not (eq gnus-summary-goto-unread 'never))
7904 (gnus-summary-last-article-p (gnus-summary-article-number)))
7905 (and gnus-auto-select-same
7906 (gnus-summary-article-subject))))
7908 (defun gnus-summary-prev-article (&optional unread subject)
7909 "Select the article before the current one.
7910 If UNREAD is non-nil, only unread articles are selected."
7912 (gnus-summary-next-article unread subject t))
7914 (defun gnus-summary-prev-unread-article ()
7915 "Select unread article before current one."
7917 (gnus-summary-prev-article
7918 (or (not (eq gnus-summary-goto-unread 'never))
7919 (gnus-summary-first-article-p (gnus-summary-article-number)))
7920 (and gnus-auto-select-same
7921 (gnus-summary-article-subject))))
7923 (declare-function gnus-article-only-boring-p "gnus-art" ())
7925 (defun gnus-summary-next-page (&optional lines circular stop)
7926 "Show next page of the selected article.
7927 If at the end of the current article, select the next article.
7928 LINES says how many lines should be scrolled up.
7930 If CIRCULAR is non-nil, go to the start of the article instead of
7931 selecting the next article when reaching the end of the current
7934 If STOP is non-nil, just stop when reaching the end of the message.
7936 Also see the variable `gnus-article-skip-boring'."
7938 (gnus-set-global-variables)
7939 (let ((article (gnus-summary-article-number))
7940 (article-window (get-buffer-window gnus-article-buffer t))
7942 ;; If the buffer is empty, we have no article.
7944 (error "No article to select"))
7945 (gnus-configure-windows 'article)
7946 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7947 (if (and (eq gnus-summary-goto-unread 'never)
7948 (not (gnus-summary-last-article-p article)))
7949 (gnus-summary-next-article)
7950 (gnus-summary-next-unread-article))
7951 (if (or (null gnus-current-article)
7952 (null gnus-article-current)
7953 (/= article (cdr gnus-article-current))
7954 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7955 ;; Selected subject is different from current article's.
7956 (gnus-summary-display-article article)
7957 (when article-window
7958 (gnus-eval-in-buffer-window gnus-article-buffer
7959 (setq endp (or (gnus-article-next-page lines)
7960 (gnus-article-only-boring-p))))
7962 (cond ((or stop gnus-summary-stop-at-end-of-message)
7963 (gnus-message 3 "End of message"))
7965 (gnus-summary-beginning-of-article))
7967 (gnus-message 3 "End of message"))
7969 (if (and (eq gnus-summary-goto-unread 'never)
7970 (not (gnus-summary-last-article-p article)))
7971 (gnus-summary-next-article)
7972 (gnus-summary-next-unread-article))))))))
7973 (gnus-summary-recenter)
7974 (gnus-summary-position-point)))
7976 (defun gnus-summary-prev-page (&optional lines move)
7977 "Show previous page of selected article.
7978 Argument LINES specifies lines to be scrolled down.
7979 If MOVE, move to the previous unread article if point is at
7980 the beginning of the buffer."
7982 (let ((article (gnus-summary-article-number))
7983 (article-window (get-buffer-window gnus-article-buffer t))
7985 (gnus-configure-windows 'article)
7986 (if (or (null gnus-current-article)
7987 (null gnus-article-current)
7988 (/= article (cdr gnus-article-current))
7989 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7990 ;; Selected subject is different from current article's.
7991 (gnus-summary-display-article article)
7992 (gnus-summary-recenter)
7993 (when article-window
7994 (gnus-eval-in-buffer-window gnus-article-buffer
7995 (setq endp (gnus-article-prev-page lines)))
7996 (when (and move endp)
7998 (gnus-message 3 "Beginning of message"))
8000 (if (and (eq gnus-summary-goto-unread 'never)
8001 (not (gnus-summary-first-article-p article)))
8002 (gnus-summary-prev-article)
8003 (gnus-summary-prev-unread-article))))))))
8004 (gnus-summary-position-point))
8006 (defun gnus-summary-prev-page-or-article (&optional lines)
8007 "Show previous page of selected article.
8008 Argument LINES specifies lines to be scrolled down.
8009 If at the beginning of the article, go to the next article."
8011 (gnus-summary-prev-page lines t))
8013 (defun gnus-summary-scroll-up (lines)
8014 "Scroll up (or down) one line current article.
8015 Argument LINES specifies lines to be scrolled up (or down if negative).
8016 If no article is selected, then the current article will be selected first."
8018 (gnus-configure-windows 'article)
8019 (gnus-summary-show-thread)
8020 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8021 (gnus-eval-in-buffer-window gnus-article-buffer
8023 (when (gnus-article-next-page lines)
8024 (gnus-message 3 "End of message")))
8026 (gnus-article-prev-page (- lines))))))
8027 (gnus-summary-recenter)
8028 (gnus-summary-position-point))
8030 (defun gnus-summary-scroll-down (lines)
8031 "Scroll down (or up) one line current article.
8032 Argument LINES specifies lines to be scrolled down (or up if negative).
8033 If no article is selected, then the current article will be selected first."
8035 (gnus-summary-scroll-up (- lines)))
8037 (defun gnus-summary-next-same-subject ()
8038 "Select next article which has the same subject as current one."
8040 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8042 (defun gnus-summary-prev-same-subject ()
8043 "Select previous article which has the same subject as current one."
8045 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8047 (defun gnus-summary-next-unread-same-subject ()
8048 "Select next unread article which has the same subject as current one."
8050 (gnus-summary-next-article t (gnus-summary-article-subject)))
8052 (defun gnus-summary-prev-unread-same-subject ()
8053 "Select previous unread article which has the same subject as current one."
8055 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8057 (defun gnus-summary-first-unread-article ()
8058 "Select the first unread article.
8059 Return nil if there are no unread articles."
8062 (when (gnus-summary-first-subject t)
8063 (gnus-summary-show-thread)
8064 (gnus-summary-first-subject t)
8065 (gnus-summary-display-article (gnus-summary-article-number)))
8066 (gnus-summary-position-point)))
8068 (defun gnus-summary-first-unread-subject ()
8069 "Place the point on the subject line of the first unread article.
8070 Return nil if there are no unread articles."
8073 (when (gnus-summary-first-subject t)
8074 (gnus-summary-show-thread)
8075 (gnus-summary-first-subject t))
8076 (gnus-summary-position-point)))
8078 (defun gnus-summary-first-unseen-subject ()
8079 "Place the point on the subject line of the first unseen article.
8080 Return nil if there are no unseen articles."
8083 (when (gnus-summary-first-subject nil nil t)
8084 (gnus-summary-show-thread)
8085 (gnus-summary-first-subject nil nil t))
8086 (gnus-summary-position-point)))
8088 (defun gnus-summary-first-unseen-or-unread-subject ()
8089 "Place the point on the subject line of the first unseen and unread article.
8090 If all article have been seen, on the subject line of the first unread
8094 (unless (when (gnus-summary-first-subject nil nil t)
8095 (gnus-summary-show-thread)
8096 (gnus-summary-first-subject nil nil t))
8097 (when (gnus-summary-first-subject t)
8098 (gnus-summary-show-thread)
8099 (gnus-summary-first-subject t)))
8100 (gnus-summary-position-point)))
8102 (defun gnus-summary-first-article ()
8103 "Select the first article.
8104 Return nil if there are no articles."
8107 (when (gnus-summary-first-subject)
8108 (gnus-summary-show-thread)
8109 (gnus-summary-first-subject)
8110 (gnus-summary-display-article (gnus-summary-article-number)))
8111 (gnus-summary-position-point)))
8113 (defun gnus-summary-best-unread-article (&optional arg)
8114 "Select the unread article with the highest score.
8115 If given a prefix argument, select the next unread article that has a
8116 score higher than the default score."
8118 (let ((article (if arg
8119 (gnus-summary-better-unread-subject)
8120 (gnus-summary-best-unread-subject))))
8122 (gnus-summary-goto-article article)
8123 (error "No unread articles"))))
8125 (defun gnus-summary-best-unread-subject ()
8126 "Select the unread subject with the highest score."
8128 (let ((best -1000000)
8129 (data gnus-newsgroup-data)
8132 (and (gnus-data-unread-p (car data))
8134 (gnus-summary-article-score (gnus-data-number (car data))))
8137 article (gnus-data-number (car data))))
8138 (setq data (cdr data)))
8140 (gnus-summary-goto-subject article))
8141 (gnus-summary-position-point)
8144 (defun gnus-summary-better-unread-subject ()
8145 "Select the first unread subject that has a score over the default score."
8147 (let ((data gnus-newsgroup-data)
8149 (while (and (setq article (gnus-data-number (car data)))
8150 (or (gnus-data-read-p (car data))
8151 (not (> (gnus-summary-article-score article)
8152 gnus-summary-default-score))))
8153 (setq data (cdr data)))
8155 (gnus-summary-goto-subject article))
8156 (gnus-summary-position-point)
8159 (defun gnus-summary-last-subject ()
8160 "Go to the last displayed subject line in the group."
8161 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8163 (gnus-summary-goto-subject article))))
8165 (defun gnus-summary-goto-article (article &optional all-headers force)
8166 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8167 If ALL-HEADERS is non-nil, no header lines are hidden.
8168 If FORCE, go to the article even if it isn't displayed. If FORCE
8169 is a number, it is the line the article is to be displayed on."
8172 (gnus-completing-read
8173 "Article number or Message-ID"
8174 (mapcar 'int-to-string gnus-newsgroup-limit))
8178 (if (and (stringp article)
8179 (string-match "@\\|%40" article))
8180 (gnus-summary-refer-article article)
8181 (when (stringp article)
8182 (setq article (string-to-number article)))
8183 (if (gnus-summary-goto-subject article force)
8184 (gnus-summary-display-article article all-headers)
8185 (gnus-message 4 "Couldn't go to article %s" article) nil))
8186 (gnus-summary-position-point)))
8188 (defun gnus-summary-goto-last-article ()
8189 "Go to the previously read article."
8192 (when gnus-last-article
8193 (gnus-summary-goto-article gnus-last-article nil t))
8194 (gnus-summary-position-point)))
8196 (defun gnus-summary-pop-article (number)
8197 "Pop one article off the history and go to the previous.
8198 NUMBER articles will be popped off."
8201 (setq gnus-newsgroup-history
8202 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8204 (gnus-summary-goto-article (car to) nil t)
8205 (error "Article history empty")))
8206 (gnus-summary-position-point))
8208 ;; Summary commands and functions for limiting the summary buffer.
8210 (defun gnus-summary-limit-to-articles (n)
8211 "Limit the summary buffer to the next N articles.
8212 If not given a prefix, use the process marked articles instead."
8215 (let ((articles (gnus-summary-work-articles n)))
8216 (setq gnus-newsgroup-processable nil)
8217 (gnus-summary-limit articles))
8218 (gnus-summary-position-point)))
8220 (defun gnus-summary-pop-limit (&optional total)
8221 "Restore the previous limit.
8222 If given a prefix, remove all limits."
8225 (setq gnus-newsgroup-limits
8226 (list (mapcar (lambda (h) (mail-header-number h))
8227 gnus-newsgroup-headers))))
8228 (unless gnus-newsgroup-limits
8229 (error "No limit to pop"))
8231 (gnus-summary-limit nil 'pop)
8232 (gnus-summary-position-point)))
8234 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8235 "Limit the summary buffer to articles that have subjects that match a regexp.
8236 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8238 (list (read-string (if current-prefix-arg
8239 "Exclude subject (regexp): "
8240 "Limit to subject (regexp): "))
8241 nil current-prefix-arg))
8243 (setq header "subject"))
8244 (when (not (equal "" subject))
8246 (let ((articles (gnus-summary-find-matching
8247 (or header "subject") subject 'all nil nil
8250 (error "Found no matches for \"%s\"" subject))
8251 (gnus-summary-limit articles))
8252 (gnus-summary-position-point))))
8254 (defun gnus-summary-limit-to-author (from &optional not-matching)
8255 "Limit the summary buffer to articles that have authors that match a regexp.
8256 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8258 (list (let* ((header (gnus-summary-article-header))
8259 (default (and header (car (mail-header-parse-address
8260 (mail-header-from header))))))
8261 (read-string (concat (if current-prefix-arg
8262 "Exclude author (regexp"
8263 "Limit to author (regexp")
8265 (concat ", default \"" default "\"): ")
8269 current-prefix-arg))
8270 (gnus-summary-limit-to-subject from "from" not-matching))
8272 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8273 "Limit the summary buffer to articles with the given RECIPIENT.
8275 If NOT-MATCHING, exclude RECIPIENT.
8277 To and Cc headers are checked. You need to include them in
8278 `nnmail-extra-headers'."
8279 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8281 (list (read-string (format "%s recipient (regexp): "
8282 (if current-prefix-arg "Exclude" "Limit to")))
8283 current-prefix-arg))
8284 (when (not (equal "" recipient))
8286 (if (memq 'To nnmail-extra-headers)
8287 (gnus-summary-find-matching
8288 (cons 'extra 'To) recipient 'all nil nil
8291 1 "`To' isn't present in `nnmail-extra-headers'")
8295 (if (memq 'Cc nnmail-extra-headers)
8296 (gnus-summary-find-matching
8297 (cons 'extra 'Cc) recipient 'all nil nil
8300 1 "`Cc' isn't present in `nnmail-extra-headers'")
8305 ;; We need the numbers that are in both lists:
8307 (and (memq a to) a))
8311 (error "Found no matches for \"%s\"" recipient))
8312 (gnus-summary-limit articles))
8313 (gnus-summary-position-point))))
8315 (defun gnus-summary-limit-to-address (address &optional not-matching)
8316 "Limit the summary buffer to articles with the given ADDRESS.
8318 If NOT-MATCHING, exclude ADDRESS.
8320 To, Cc and From headers are checked. You need to include `To' and `Cc'
8321 in `nnmail-extra-headers'."
8323 (list (read-string (format "%s address (regexp): "
8324 (if current-prefix-arg "Exclude" "Limit to")))
8325 current-prefix-arg))
8326 (when (not (equal "" address))
8328 (if (memq 'To nnmail-extra-headers)
8329 (gnus-summary-find-matching
8330 (cons 'extra 'To) address 'all nil nil
8333 1 "`To' isn't present in `nnmail-extra-headers'")
8337 (if (memq 'Cc nnmail-extra-headers)
8338 (gnus-summary-find-matching
8339 (cons 'extra 'Cc) address 'all nil nil
8342 1 "`Cc' isn't present in `nnmail-extra-headers'")
8346 (gnus-summary-find-matching "from" address
8347 'all nil nil not-matching))
8350 ;; We need the numbers that are in all lists:
8354 (mapcar (lambda (a) (car (memq a from))) to))
8356 (mapcar (lambda (a) (car (memq a from))) cc)
8357 (mapcar (lambda (a) (car (memq a from)))
8358 (mapcar (lambda (a) (car (memq a to)))
8360 (nconc (if (eq to t) nil to)
8361 (if (eq cc t) nil cc)
8364 (error "Found no matches for \"%s\"" address))
8365 (gnus-summary-limit articles))
8366 (gnus-summary-position-point))))
8368 (defun gnus-summary-limit-strange-charsets-predicate (header)
8369 (when (fboundp 'char-charset)
8370 (let ((string (concat (mail-header-subject header)
8371 (mail-header-from header)))
8373 (dotimes (i (1- (length string)))
8374 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8375 (when (string-match "unicode\\|big\\|japanese" charset)
8379 (defun gnus-summary-limit-to-predicate (predicate)
8380 "Limit to articles where PREDICATE returns non-nil.
8381 PREDICATE will be called with the header structures of the
8383 (let ((articles nil)
8384 (case-fold-search t))
8385 (dolist (header gnus-newsgroup-headers)
8386 (when (funcall predicate header)
8387 (push (mail-header-number header) articles)))
8388 (gnus-summary-limit (nreverse articles))))
8390 (defun gnus-summary-limit-to-age (age &optional younger-p)
8391 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8392 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8393 articles that are younger than AGE days."
8395 (let ((younger current-prefix-arg)
8398 (while (not days-got)
8399 (setq days (if younger
8400 (read-string "Limit to articles younger than (in days, older when negative): ")
8402 "Limit to articles older than (in days, younger when negative): ")))
8403 (when (> (length days) 0)
8404 (setq days (read days)))
8409 (setq younger (not younger))
8410 (setq days (* days -1))))
8411 (message "Please enter a number.")
8413 (list days younger)))
8415 (let ((data gnus-newsgroup-data)
8416 (cutoff (days-to-time age))
8417 articles d date is-younger)
8418 (while (setq d (pop data))
8419 (when (and (vectorp (gnus-data-header d))
8420 (setq date (mail-header-date (gnus-data-header d))))
8421 (setq is-younger (time-less-p
8422 (time-since (gnus-date-get-time date))
8427 (push (gnus-data-number d) articles))))
8428 (gnus-summary-limit (nreverse articles)))
8429 (gnus-summary-position-point)))
8431 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8432 "Limit the summary buffer to articles that match an 'extra' header."
8436 (gnus-completing-read
8437 (if current-prefix-arg
8438 "Exclude extra header"
8439 "Limit extra header")
8440 (mapcar 'symbol-name gnus-extra-headers)
8442 (symbol-name (car gnus-extra-headers))))))
8444 (read-string (format "%s header %s (regexp): "
8445 (if current-prefix-arg "Exclude" "Limit to")
8447 current-prefix-arg)))
8448 (when (not (equal "" regexp))
8450 (let ((articles (gnus-summary-find-matching
8451 (cons 'extra header) regexp 'all nil nil
8454 (error "Found no matches for \"%s\"" regexp))
8455 (gnus-summary-limit articles))
8456 (gnus-summary-position-point))))
8458 (defun gnus-summary-limit-to-display-predicate ()
8459 "Limit the summary buffer to the predicated in the `display' group parameter."
8461 (unless gnus-newsgroup-display
8462 (error "There is no `display' group parameter"))
8464 (dolist (gnus-number gnus-newsgroup-articles)
8465 (when (funcall gnus-newsgroup-display)
8466 (push gnus-number articles)))
8467 (gnus-summary-limit articles))
8468 (gnus-summary-position-point))
8470 (defun gnus-summary-limit-to-unread (&optional all)
8471 "Limit the summary buffer to articles that are not marked as read.
8472 If ALL is non-nil, limit strictly to unread articles."
8475 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8476 (gnus-summary-limit-to-marks
8477 ;; Concat all the marks that say that an article is read and have
8479 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8480 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8481 gnus-low-score-mark gnus-expirable-mark
8482 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8483 gnus-duplicate-mark)
8486 (defun gnus-summary-limit-to-headers (match &optional reverse)
8487 "Limit the summary buffer to articles that have headers that match MATCH.
8488 If REVERSE (the prefix), limit to articles that don't match."
8489 (interactive "sMatch headers (regexp): \nP")
8490 (gnus-summary-limit-to-bodies match reverse t))
8492 (declare-function article-goto-body "gnus-art" ())
8494 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8495 "Limit the summary buffer to articles that have bodies that match MATCH.
8496 If REVERSE (the prefix), limit to articles that don't match."
8497 (interactive "sMatch body (regexp): \nP")
8498 (let ((articles nil)
8499 (gnus-select-article-hook nil) ;Disable hook.
8500 (gnus-article-prepare-hook nil)
8501 (gnus-use-article-prefetch nil)
8502 (gnus-keep-backlog nil)
8503 (gnus-break-pages nil)
8504 (gnus-summary-display-arrow nil)
8505 (gnus-updated-mode-lines nil)
8506 (gnus-auto-center-summary nil)
8507 (gnus-display-mime-function nil))
8508 (dolist (data gnus-newsgroup-data)
8509 (let (gnus-mark-article-hook)
8510 (gnus-summary-select-article t t nil (gnus-data-number data)))
8511 (with-current-buffer gnus-article-buffer
8513 (let* ((case-fold-search t)
8515 (re-search-backward match nil t)
8516 (re-search-forward match nil t))))
8517 (when (or (and found
8521 (push (gnus-data-number data) articles)))))
8523 (message "No messages matched")
8524 (gnus-summary-limit articles)))
8525 (gnus-summary-position-point))
8527 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8528 "Limit the summary buffer to articles that aren't part on any thread.
8529 If THREADSP (the prefix), limit to articles that are in threads."
8531 (let ((articles nil)
8534 (dolist (thread gnus-newsgroup-threads)
8535 (if (stringp (car thread))
8536 (dolist (thread (cdr thread))
8537 (push thread threads))
8538 (push thread threads)))
8539 (dolist (thread threads)
8540 (setq thread-articles (gnus-articles-in-thread thread))
8541 (when (or (and threadsp
8542 (> (length thread-articles) 1))
8544 (= (length thread-articles) 1)))
8545 (setq articles (nconc thread-articles articles))))
8547 (message "No messages matched")
8548 (gnus-summary-limit articles))
8549 (gnus-summary-position-point)))
8551 (defun gnus-summary-limit-to-replied (&optional unreplied)
8552 "Limit the summary buffer to replied articles.
8553 If UNREPLIED (the prefix), limit to unreplied articles."
8557 (gnus-set-difference gnus-newsgroup-articles
8558 gnus-newsgroup-replied))
8559 (gnus-summary-limit gnus-newsgroup-replied))
8560 (gnus-summary-position-point))
8562 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8563 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8564 If REVERSE, limit the summary buffer to articles that are marked
8565 with MARKS. MARKS can either be a string of marks or a list of marks.
8566 Returns how many articles were removed."
8567 (interactive "sMarks: ")
8568 (gnus-summary-limit-to-marks marks t))
8570 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8571 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8572 If REVERSE (the prefix), limit the summary buffer to articles that are
8573 not marked with MARKS. MARKS can either be a string of marks or a
8575 Returns how many articles were removed."
8576 (interactive "sMarks: \nP")
8578 (let ((data gnus-newsgroup-data)
8579 (marks (if (listp marks) marks
8580 (append marks nil))) ; Transform to list.
8583 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8584 (memq (gnus-data-mark (car data)) marks))
8585 (push (gnus-data-number (car data)) articles))
8586 (setq data (cdr data)))
8587 (gnus-summary-limit articles))
8588 (gnus-summary-position-point)))
8590 (defun gnus-summary-limit-to-score (score)
8591 "Limit to articles with score at or above SCORE."
8592 (interactive "NLimit to articles with score of at least: ")
8593 (let ((data gnus-newsgroup-data)
8596 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8598 (push (gnus-data-number (car data)) articles))
8599 (setq data (cdr data)))
8601 (gnus-summary-limit articles)
8602 (gnus-summary-position-point))))
8604 (defun gnus-summary-limit-to-unseen ()
8605 "Limit to unseen articles."
8608 (gnus-summary-limit gnus-newsgroup-unseen)
8609 (gnus-summary-position-point)))
8611 (defun gnus-summary-limit-include-thread (id)
8612 "Display all the hidden articles that is in the thread with ID in it.
8613 When called interactively, ID is the Message-ID of the current
8615 (interactive (list (mail-header-id (gnus-summary-article-header))))
8616 (let ((articles (gnus-articles-in-thread
8617 (gnus-id-to-thread (gnus-root-id id))))
8618 ;;we REALLY want the whole thread---this prevents cut-threads
8619 ;;from removing the thread we want to include.
8620 (gnus-fetch-old-headers nil)
8621 (gnus-build-sparse-threads nil))
8623 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8624 (gnus-summary-limit-include-matching-articles
8626 (regexp-quote (gnus-simplify-subject-re
8627 (mail-header-subject (gnus-id-to-header id)))))
8628 (gnus-summary-position-point))))
8630 (defun gnus-summary-limit-include-matching-articles (header regexp)
8631 "Display all the hidden articles that have HEADERs that match REGEXP."
8632 (interactive (list (read-string "Match on header: ")
8633 (read-string "Regexp: ")))
8634 (let ((articles (gnus-find-matching-articles header regexp)))
8636 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8637 (gnus-summary-position-point))))
8639 (defun gnus-summary-insert-dormant-articles ()
8640 "Insert all the dormant articles for this group into the current buffer."
8642 (let ((gnus-verbose (max 6 gnus-verbose)))
8643 (if (not gnus-newsgroup-dormant)
8644 (gnus-message 3 "No dormant articles for this group")
8645 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8647 (defun gnus-summary-insert-ticked-articles ()
8648 "Insert ticked articles for this group into the current buffer."
8650 (let ((gnus-verbose (max 6 gnus-verbose)))
8651 (if (not gnus-newsgroup-marked)
8652 (gnus-message 3 "No ticked articles for this group")
8653 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8655 (defun gnus-summary-limit-include-dormant ()
8656 "Display all the hidden articles that are marked as dormant.
8657 Note that this command only works on a subset of the articles currently
8658 fetched for this group."
8660 (unless gnus-newsgroup-dormant
8661 (error "There are no dormant articles in this group"))
8663 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8664 (gnus-summary-position-point)))
8666 (defun gnus-summary-include-articles (articles)
8667 "Fetch the headers for ARTICLES and then display the summary lines."
8668 (let ((gnus-inhibit-demon t)
8670 (gnus-read-all-available-headers t))
8671 (setq gnus-newsgroup-headers
8673 'list gnus-newsgroup-headers
8674 (gnus-fetch-headers articles nil t)
8675 'gnus-article-sort-by-number))
8676 (setq gnus-newsgroup-articles
8677 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8678 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8680 (defun gnus-summary-limit-exclude-dormant ()
8681 "Hide all dormant articles."
8684 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8685 (gnus-summary-position-point)))
8687 (defun gnus-summary-limit-exclude-childless-dormant ()
8688 "Hide all dormant articles that have no children."
8690 (let ((data (gnus-data-list t))
8691 articles d children)
8692 ;; Find all articles that are either not dormant or have
8694 (while (setq d (pop data))
8695 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8697 (gnus-article-children (gnus-data-number d)))
8700 (when (memq (car children) articles)
8705 (push (gnus-data-number d) articles)))
8708 (gnus-summary-limit articles)
8709 (gnus-summary-position-point))))
8711 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8712 "Mark all unread excluded articles as read.
8713 If ALL, mark even excluded ticked and dormants as read."
8715 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8716 (let ((articles (gnus-sorted-ndifference
8718 (mapcar (lambda (h) (mail-header-number h))
8719 gnus-newsgroup-headers)
8721 gnus-newsgroup-limit))
8723 (setq gnus-newsgroup-unreads
8724 (gnus-sorted-intersection gnus-newsgroup-unreads
8725 gnus-newsgroup-limit))
8727 (setq gnus-newsgroup-dormant nil
8728 gnus-newsgroup-marked nil
8729 gnus-newsgroup-reads
8731 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8732 gnus-newsgroup-reads))
8733 (while (setq article (pop articles))
8734 (unless (or (memq article gnus-newsgroup-dormant)
8735 (memq article gnus-newsgroup-marked))
8736 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8738 (defun gnus-summary-limit (articles &optional pop)
8740 ;; We pop the previous limit off the stack and use that.
8741 (setq articles (car gnus-newsgroup-limits)
8742 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8743 ;; We use the new limit, so we push the old limit on the stack.
8744 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8746 (setq gnus-newsgroup-limit articles)
8747 (let ((total (length gnus-newsgroup-data))
8748 (data (gnus-data-find-list (gnus-summary-article-number)))
8749 (gnus-summary-mark-below nil) ; Inhibit this.
8751 ;; This will do all the work of generating the new summary buffer
8752 ;; according to the new limit.
8753 (gnus-summary-prepare)
8754 ;; Hide any threads, possibly.
8755 (gnus-summary-maybe-hide-threads)
8756 ;; Try to return to the article you were at, or one in the
8759 ;; We try to find some article after the current one.
8761 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8764 (setq data (cdr data))))
8766 ;; If there is no data, that means that we were after the last
8767 ;; article. The same goes when we can't find any articles
8768 ;; after the current one.
8769 (goto-char (point-max))
8770 (gnus-summary-find-prev))
8771 (gnus-set-mode-line 'summary)
8772 ;; We return how many articles were removed from the summary
8773 ;; buffer as a result of the new limit.
8774 (- total (length gnus-newsgroup-data))))
8776 (defsubst gnus-invisible-cut-children (threads)
8779 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8784 (defsubst gnus-cut-thread (thread)
8785 "Go forwards in the thread until we find an article that we want to display."
8786 (when (or (eq gnus-fetch-old-headers 'some)
8787 (eq gnus-fetch-old-headers 'invisible)
8788 (numberp gnus-fetch-old-headers)
8789 (eq gnus-build-sparse-threads 'some)
8790 (eq gnus-build-sparse-threads 'more))
8791 ;; Deal with old-fetched headers and sparse threads.
8795 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8796 (gnus-summary-article-ancient-p
8797 (mail-header-number (car thread))))
8798 (if (or (<= (length (cdr thread)) 1)
8799 (eq gnus-fetch-old-headers 'invisible))
8800 (setq gnus-newsgroup-limit
8801 (delq (mail-header-number (car thread))
8802 gnus-newsgroup-limit)
8803 thread (cadr thread))
8804 (when (gnus-invisible-cut-children (cdr thread))
8805 (let ((th (cdr thread)))
8807 (if (memq (mail-header-number (caar th))
8808 gnus-newsgroup-limit)
8809 (setq thread (car th)
8811 (setq th (cdr th))))))))))
8814 (defun gnus-cut-threads (threads)
8815 "Cut off all uninteresting articles from the beginning of THREADS."
8816 (when (or (eq gnus-fetch-old-headers 'some)
8817 (eq gnus-fetch-old-headers 'invisible)
8818 (numberp gnus-fetch-old-headers)
8819 (eq gnus-build-sparse-threads 'some)
8820 (eq gnus-build-sparse-threads 'more))
8823 (setcar th (gnus-cut-thread (car th)))
8824 (setq th (cdr th)))))
8825 ;; Remove nixed out threads.
8828 (defun gnus-summary-initial-limit (&optional show-if-empty)
8829 "Figure out what the initial limit is supposed to be on group entry.
8830 This entails weeding out unwanted dormants, low-scored articles,
8831 fetch-old-headers verbiage, and so on."
8832 ;; Most groups have nothing to remove.
8833 (unless (or gnus-inhibit-limiting
8834 (and (null gnus-newsgroup-dormant)
8835 (eq gnus-newsgroup-display 'gnus-not-ignore)
8836 (not (eq gnus-fetch-old-headers 'some))
8837 (not (numberp gnus-fetch-old-headers))
8838 (not (eq gnus-fetch-old-headers 'invisible))
8839 (null gnus-summary-expunge-below)
8840 (not (eq gnus-build-sparse-threads 'some))
8841 (not (eq gnus-build-sparse-threads 'more))
8842 (null gnus-thread-expunge-below)))
8843 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8844 (setq gnus-newsgroup-limit nil)
8847 (unless (car (symbol-value node))
8848 ;; These threads have no parents -- they are roots.
8849 (let ((nodes (cdr (symbol-value node)))
8852 (if (and gnus-thread-expunge-below
8853 (< (gnus-thread-total-score (car nodes))
8854 gnus-thread-expunge-below))
8855 (gnus-expunge-thread (pop nodes))
8856 (setq thread (pop nodes))
8857 (gnus-summary-limit-children thread))))))
8858 gnus-newsgroup-dependencies)
8859 ;; If this limitation resulted in an empty group, we might
8860 ;; pop the previous limit and use it instead.
8861 (when (and (not gnus-newsgroup-limit)
8863 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8864 gnus-newsgroup-limit))
8866 (defun gnus-summary-limit-children (thread)
8867 "Return 1 if this subthread is visible and 0 if it is not."
8868 ;; First we get the number of visible children to this thread. This
8869 ;; is done by recursing down the thread using this function, so this
8870 ;; will really go down to a leaf article first, before slowly
8871 ;; working its way up towards the root.
8873 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8876 (apply '+ (mapcar 'gnus-summary-limit-children
8879 (number (mail-header-number (car thread)))
8882 (not (memq number gnus-newsgroup-marked))
8884 ;; If this article is dormant and has absolutely no visible
8885 ;; children, then this article isn't visible.
8886 (and (memq number gnus-newsgroup-dormant)
8888 ;; If this is "fetch-old-headered" and there is no
8889 ;; visible children, then we don't want this article.
8890 (and (or (eq gnus-fetch-old-headers 'some)
8891 (numberp gnus-fetch-old-headers))
8892 (gnus-summary-article-ancient-p number)
8894 ;; If this is "fetch-old-headered" and `invisible', then
8895 ;; we don't want this article.
8896 (and (eq gnus-fetch-old-headers 'invisible)
8897 (gnus-summary-article-ancient-p number))
8898 ;; If this is a sparsely inserted article with no children,
8899 ;; we don't want it.
8900 (and (eq gnus-build-sparse-threads 'some)
8901 (gnus-summary-article-sparse-p number)
8903 ;; If we use expunging, and this article is really
8904 ;; low-scored, then we don't want this article.
8905 (when (and gnus-summary-expunge-below
8907 (or (cdr (assq number gnus-newsgroup-scored))
8908 gnus-summary-default-score))
8909 gnus-summary-expunge-below))
8910 ;; We increase the expunge-tally here, but that has
8911 ;; nothing to do with the limits, really.
8912 (incf gnus-newsgroup-expunged-tally)
8913 ;; We also mark as read here, if that's wanted.
8914 (when (and gnus-summary-mark-below
8915 (< score gnus-summary-mark-below))
8916 (setq gnus-newsgroup-unreads
8917 (delq number gnus-newsgroup-unreads))
8918 (if gnus-newsgroup-auto-expire
8919 (push number gnus-newsgroup-expirable)
8920 (push (cons number gnus-low-score-mark)
8921 gnus-newsgroup-reads)))
8923 ;; Do the `display' group parameter.
8924 (and gnus-newsgroup-display
8925 (let ((gnus-number number))
8926 (not (funcall gnus-newsgroup-display))))))
8927 ;; Nope, invisible article.
8929 ;; Ok, this article is to be visible, so we add it to the limit
8931 (push number gnus-newsgroup-limit)
8934 (defun gnus-expunge-thread (thread)
8935 "Mark all articles in THREAD as read."
8936 (let* ((number (mail-header-number (car thread))))
8937 (incf gnus-newsgroup-expunged-tally)
8938 ;; We also mark as read here, if that's wanted.
8939 (setq gnus-newsgroup-unreads
8940 (delq number gnus-newsgroup-unreads))
8941 (if gnus-newsgroup-auto-expire
8942 (push number gnus-newsgroup-expirable)
8943 (push (cons number gnus-low-score-mark)
8944 gnus-newsgroup-reads)))
8945 ;; Go recursively through all subthreads.
8946 (mapcar 'gnus-expunge-thread (cdr thread)))
8948 ;; Summary article oriented commands
8950 (defun gnus-summary-refer-parent-article (n)
8951 "Refer parent article N times.
8952 If N is negative, go to ancestor -N instead.
8953 The difference between N and the number of articles fetched is returned."
8957 (when (not (natnump n))
8962 (setq header (gnus-summary-article-header))
8963 (if (and (eq (mail-header-number header)
8964 (cdr gnus-article-current))
8965 (equal gnus-newsgroup-name
8966 (car gnus-article-current)))
8967 ;; If we try to find the parent of the currently
8968 ;; displayed article, then we take a look at the actual
8969 ;; References header, since this is slightly more
8970 ;; reliable than the References field we got from the
8972 (with-current-buffer gnus-original-article-buffer
8973 (nnheader-narrow-to-headers)
8974 (unless (setq ref (message-fetch-field "references"))
8975 (when (setq ref (message-fetch-field "in-reply-to"))
8976 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8979 ;; It's not the current article, so we take a bet on
8980 ;; the value we got from the server.
8981 (mail-header-references header)))
8983 (not (equal ref "")))
8984 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8985 (gnus-message 1 "Couldn't find parent"))
8986 (gnus-message 1 "No references in article %d"
8987 (gnus-summary-article-number))
8990 (gnus-summary-position-point)
8993 (defun gnus-summary-refer-references ()
8994 "Fetch all articles mentioned in the References header.
8995 Return the number of articles fetched."
8997 (let ((ref (mail-header-references (gnus-summary-article-header)))
8998 (current (gnus-summary-article-number))
9002 (error "No References in the current article")
9003 ;; For each Message-ID in the References header...
9004 (while (string-match "<[^>]*>" ref)
9006 ;; ... fetch that article.
9007 (gnus-summary-refer-article
9008 (prog1 (match-string 0 ref)
9009 (setq ref (substring ref (match-end 0))))))
9010 (gnus-summary-goto-subject current)
9011 (gnus-summary-position-point)
9014 (defun gnus-delete-duplicate-headers (headers)
9015 ;; First remove leading duplicates.
9016 (while (and (> (length headers) 1)
9017 (= (mail-header-number (car headers))
9018 (mail-header-number (cadr headers))))
9021 (let ((result headers))
9022 (while (> (length headers) 1)
9023 (if (= (mail-header-number (car headers))
9024 (mail-header-number (cadr headers)))
9025 (setcdr headers (cddr headers))
9029 (defun gnus-summary-refer-thread (&optional limit)
9030 "Fetch all articles in the current thread. For backends that
9031 know how to search for threads (currently only 'nnimap) a
9032 non-numeric prefix arg will use nnir to search the entire
9033 server; without a prefix arg only the current group is
9034 searched. If the variable `gnus-refer-thread-use-nnir' is
9035 non-nil the prefix arg has the reverse meaning. If no
9036 backend-specific 'request-thread function is available fetch
9037 LIMIT (the numerical prefix) old headers. If LIMIT is
9038 non-numeric or nil fetch the number specified by the
9039 `gnus-refer-thread-limit' variable."
9041 (gnus-warp-to-article)
9042 (let* ((header (gnus-summary-article-header))
9043 (id (mail-header-id header))
9044 (gnus-inhibit-demon t)
9045 (gnus-summary-ignore-duplicates t)
9046 (gnus-read-all-available-headers t)
9047 (gnus-refer-thread-use-nnir
9048 (if (and (not (null limit)) (listp limit))
9049 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9051 (if (gnus-check-backend-function
9052 'request-thread gnus-newsgroup-name)
9053 (gnus-request-thread header gnus-newsgroup-name)
9054 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9055 gnus-refer-thread-limit))
9056 (last (if (numberp limit)
9057 (min (+ (mail-header-number header)
9059 gnus-newsgroup-highest)
9060 gnus-newsgroup-highest))
9061 (subject (gnus-simplify-subject
9062 (mail-header-subject header)))
9063 (refs (split-string (or (mail-header-references header)
9065 (gnus-parse-headers-hook
9066 `(lambda () (goto-char (point-min))
9068 (regexp-opt ',(append refs (list id subject)))))))
9069 (gnus-fetch-headers (list last) (if (numberp limit)
9070 (* 2 limit) limit) t))))
9071 article-ids new-unreads)
9072 (when (listp new-headers)
9073 (dolist (header new-headers)
9074 (push (mail-header-number header) article-ids))
9075 (setq article-ids (nreverse article-ids))
9077 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9078 (setq gnus-newsgroup-unselected
9079 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9080 (setq gnus-newsgroup-unreads
9081 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9082 (setq gnus-newsgroup-headers
9083 (gnus-delete-duplicate-headers
9085 'list gnus-newsgroup-headers new-headers
9086 'gnus-article-sort-by-number)))
9087 (setq gnus-newsgroup-articles
9088 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9089 (gnus-summary-limit-include-thread id)))
9090 (gnus-summary-show-thread))
9092 (defun gnus-summary-open-group-with-article (message-id)
9093 "Open a group containing the article with the given MESSAGE-ID."
9094 (interactive "sMessage-ID: ")
9097 ;; Prepare a dummy article
9099 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9101 ;; Prepare pretty modelines for summary and article buffers
9102 (let ((gnus-summary-mode-line-format "Found %G")
9103 (gnus-article-mode-line-format
9104 ;; Group names just get in the way here, especially the
9106 (if (string-match "%[gG]" gnus-article-mode-line-format)
9107 (concat (substring gnus-article-mode-line-format
9108 0 (match-beginning 0))
9109 (substring gnus-article-mode-line-format (match-end 0)))
9110 gnus-article-mode-line-format)))
9112 ;; Build an ephemeral group containing the dummy article (hidden)
9113 (gnus-group-read-ephemeral-group
9116 (nndoc-address ,(current-buffer))
9117 (nndoc-article-type mbox))
9119 (cons (current-buffer) gnus-current-window-configuration)
9121 '(-1) ; :select-articles
9124 ;; Fetch the desired article
9125 (gnus-summary-refer-article message-id)))
9127 (defun gnus-summary-refer-article (message-id)
9128 "Fetch an article specified by MESSAGE-ID."
9129 (interactive "sMessage-ID: ")
9130 (gnus-warp-to-article)
9131 (when (and (stringp message-id)
9132 (not (zerop (length message-id))))
9133 (setq message-id (gnus-replace-in-string message-id " " ""))
9134 ;; Construct the correct Message-ID if necessary.
9135 ;; Suggested by tale@pawl.rpi.edu.
9136 (unless (string-match "^<" message-id)
9137 (setq message-id (concat "<" message-id)))
9138 (unless (string-match ">$" message-id)
9139 (setq message-id (concat message-id ">")))
9140 ;; People often post MIDs from URLs, so unhex it:
9141 (unless (string-match "@" message-id)
9142 (setq message-id (gnus-url-unhex-string message-id)))
9143 (let* ((header (gnus-id-to-header message-id))
9145 (gnus-summary-article-sparse-p
9146 (mail-header-number header))
9147 (memq (mail-header-number header)
9148 gnus-newsgroup-limit)))
9151 ;; If the article is present in the buffer we just go to it.
9153 (or (not (gnus-summary-article-sparse-p
9154 (mail-header-number header)))
9157 (gnus-summary-goto-article
9158 (mail-header-number header) nil t)
9160 (gnus-summary-update-article (mail-header-number header)))))
9162 ;; We fetch the article.
9164 (dolist (gnus-override-method (gnus-refer-article-methods))
9165 (when (and (gnus-check-server gnus-override-method)
9166 ;; Fetch the header,
9167 (setq number (gnus-summary-insert-subject message-id)))
9168 ;; and display the article.
9169 (gnus-summary-select-article nil nil nil number)
9171 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9173 (defun gnus-refer-article-methods ()
9174 "Return a list of referable methods."
9176 ;; No method, so we default to current and native.
9177 ((null gnus-refer-article-method)
9178 (list gnus-current-select-method gnus-select-method))
9180 ((eq 'current gnus-refer-article-method)
9181 (list gnus-current-select-method))
9182 ;; List of select methods.
9183 ((not (and (symbolp (car gnus-refer-article-method))
9184 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9186 (dolist (method gnus-refer-article-method)
9187 (push (if (eq 'current method)
9188 gnus-current-select-method
9189 (if (eq 'nnir (car method))
9193 (gnus-method-to-server gnus-current-select-method)))
9197 ;; One single select method.
9199 (list gnus-refer-article-method))))
9201 (defun gnus-summary-edit-parameters ()
9202 "Edit the group parameters of the current group."
9204 (gnus-group-edit-group gnus-newsgroup-name 'params))
9206 (defun gnus-summary-customize-parameters ()
9207 "Customize the group parameters of the current group."
9209 (gnus-group-customize gnus-newsgroup-name))
9211 (defun gnus-summary-enter-digest-group (&optional force)
9212 "Enter an nndoc group based on the current article.
9213 If FORCE, force a digest interpretation. If not, try to guess
9214 what the document format is.
9216 To control what happens when you exit the group, see the
9217 `gnus-auto-select-on-ephemeral-exit' variable."
9219 (let ((conf gnus-current-window-configuration))
9220 (save-window-excursion
9222 (let (gnus-article-prepare-hook
9223 gnus-display-mime-function
9225 (gnus-summary-select-article))))
9226 (setq gnus-current-window-configuration conf)
9227 (let* ((name (format "%s-%d"
9228 (gnus-group-prefixed-name
9229 gnus-newsgroup-name (list 'nndoc ""))
9230 (with-current-buffer gnus-summary-buffer
9231 gnus-current-article)))
9232 (ogroup gnus-newsgroup-name)
9233 (params (append (gnus-info-params (gnus-get-info ogroup))
9234 (list (cons 'to-group ogroup))
9235 (list (cons 'parent-group ogroup))
9236 (list (cons 'save-article-group ogroup))))
9237 (case-fold-search t)
9238 (buf (current-buffer))
9239 dig to-address charset)
9240 (with-current-buffer gnus-original-article-buffer
9241 ;; Have the digest group inherit the main mail address of
9242 ;; the parent article.
9243 (when (setq to-address (or (gnus-fetch-field "reply-to")
9244 (gnus-fetch-field "from")))
9248 (list (cons 'to-address
9249 (funcall gnus-decode-encoded-address-function
9251 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9252 (insert-buffer-substring gnus-original-article-buffer)
9254 (goto-char (point-min))
9255 (or (search-forward "\n\n" nil t) (point)))
9256 ;; Remove lines that may lead nndoc to misinterpret the
9258 (goto-char (point-min))
9259 (delete-matching-lines "^Path:\\|^From ")
9260 ;; Parse charset, and decode content transfer encoding.
9261 (setq charset (mail-content-type-get
9262 (mail-header-parse-content-type
9263 (or (gnus-fetch-field "content-type") ""))
9265 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9267 (message-remove-header "content-transfer-encoding")
9268 (goto-char (point-max))
9270 (narrow-to-region (point) (point-max))
9271 (mm-decode-content-transfer-encoding
9272 (intern (downcase (mail-header-strip encoding))))))
9275 (if (let ((gnus-newsgroup-ephemeral-charset
9277 (intern (downcase (gnus-strip-whitespace charset)))
9278 gnus-newsgroup-charset))
9279 (gnus-newsgroup-ephemeral-ignored-charsets
9280 gnus-newsgroup-ignored-charsets))
9281 (gnus-group-read-ephemeral-group
9282 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9284 ,(if force 'mbox 'guess)))
9286 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9288 ;; Make all postings to this group go to the parent group.
9289 (nconc (gnus-info-params (gnus-get-info name))
9291 ;; Couldn't select this doc group.
9292 (switch-to-buffer buf)
9293 (gnus-set-global-variables)
9294 (gnus-configure-windows 'summary)
9295 (gnus-message 3 "Article couldn't be entered?"))
9296 (kill-buffer dig)))))
9298 (defun gnus-summary-read-document (n)
9299 "Open a new group based on the current article(s).
9300 This will allow you to read digests and other similar
9301 documents as newsgroups.
9302 Obeys the standard process/prefix convention."
9304 (let* ((ogroup gnus-newsgroup-name)
9305 (params (append (gnus-info-params (gnus-get-info ogroup))
9306 (list (cons 'to-group ogroup))))
9307 group egroup groups vgroup)
9308 (dolist (article (gnus-summary-work-articles n))
9309 (setq group (format "%s-%d" gnus-newsgroup-name article))
9310 (gnus-summary-remove-process-mark article)
9311 (when (gnus-summary-display-article article)
9312 (save-excursion ;;What for?
9314 (insert-buffer-substring gnus-original-article-buffer)
9315 ;; Remove some headers that may lead nndoc to make
9317 (message-narrow-to-head)
9318 (goto-char (point-min))
9319 (delete-matching-lines "^Path:\\|^From ")
9322 (gnus-group-read-ephemeral-group
9323 group `(nndoc ,group (nndoc-address ,(current-buffer))
9324 (nndoc-article-type guess))
9327 ;; Make all postings to this group go to the parent group.
9328 (nconc (gnus-info-params (gnus-get-info egroup))
9330 (push egroup groups))
9331 ;; Couldn't select this doc group.
9332 (gnus-error 3 "Article couldn't be entered"))))))
9333 ;; Now we have selected all the documents.
9336 (error "None of the articles could be interpreted as documents"))
9337 ((gnus-group-read-ephemeral-group
9338 (setq vgroup (format
9339 "nnvirtual:%s-%s" gnus-newsgroup-name
9340 (format-time-string "%Y%m%dT%H%M%S")))
9341 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9343 (cons (current-buffer) 'summary)))
9345 (error "Couldn't select virtual nndoc group")))))
9347 (defun gnus-summary-widget-forward (arg)
9348 "Move point to the next field or button in the article.
9349 With optional ARG, move across that many fields."
9351 (gnus-summary-select-article)
9352 (gnus-configure-windows 'article)
9353 (select-window (gnus-get-buffer-window gnus-article-buffer))
9354 (widget-forward arg))
9356 (defun gnus-summary-widget-backward (arg)
9357 "Move point to the previous field or button in the article.
9358 With optional ARG, move across that many fields."
9360 (gnus-summary-select-article)
9361 (gnus-configure-windows 'article)
9362 (select-window (gnus-get-buffer-window gnus-article-buffer))
9363 (unless (widget-at (point))
9364 (goto-char (point-max)))
9365 (widget-backward arg))
9367 (defun gnus-summary-isearch-article (&optional regexp-p)
9368 "Do incremental search forward on the current article.
9369 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9371 (gnus-summary-select-article)
9372 (gnus-configure-windows 'article)
9373 (gnus-eval-in-buffer-window gnus-article-buffer
9376 (isearch-forward regexp-p))))
9378 (defun gnus-summary-repeat-search-article-forward ()
9379 "Repeat the previous search forwards."
9381 (unless gnus-last-search-regexp
9382 (error "No previous search"))
9383 (gnus-summary-search-article-forward gnus-last-search-regexp))
9385 (defun gnus-summary-repeat-search-article-backward ()
9386 "Repeat the previous search backwards."
9388 (unless gnus-last-search-regexp
9389 (error "No previous search"))
9390 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9392 (defun gnus-summary-search-article-forward (regexp &optional backward)
9393 "Search for an article containing REGEXP forward.
9394 If BACKWARD, search backward instead."
9397 (format "Search article %s (regexp%s): "
9398 (if current-prefix-arg "backward" "forward")
9399 (if gnus-last-search-regexp
9400 (concat ", default " gnus-last-search-regexp)
9402 current-prefix-arg))
9403 (if (string-equal regexp "")
9404 (setq regexp (or gnus-last-search-regexp ""))
9405 (setq gnus-last-search-regexp regexp)
9406 (setq gnus-article-before-search gnus-current-article))
9407 ;; Intentionally set gnus-last-article.
9408 (setq gnus-last-article gnus-article-before-search)
9409 (let ((gnus-last-article gnus-last-article))
9410 (if (gnus-summary-search-article regexp backward)
9411 (gnus-summary-show-thread)
9412 (signal 'search-failed (list regexp)))))
9414 (defun gnus-summary-search-article-backward (regexp)
9415 "Search for an article containing REGEXP backward."
9418 (format "Search article backward (regexp%s): "
9419 (if gnus-last-search-regexp
9420 (concat ", default " gnus-last-search-regexp)
9422 (gnus-summary-search-article-forward regexp 'backward))
9424 (defun gnus-summary-search-article (regexp &optional backward)
9425 "Search for an article containing REGEXP.
9426 Optional argument BACKWARD means do search for backward.
9427 `gnus-select-article-hook' is not called during the search."
9428 ;; We have to require this here to make sure that the following
9429 ;; dynamic binding isn't shadowed by autoloading.
9430 (require 'gnus-async)
9432 (let ((gnus-select-article-hook nil) ;Disable hook.
9433 (gnus-article-prepare-hook nil)
9434 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9435 (gnus-use-article-prefetch nil)
9436 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9437 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9439 (gnus-keep-backlog nil)
9440 (gnus-break-pages nil)
9441 (gnus-summary-display-arrow nil)
9442 (gnus-updated-mode-lines nil)
9443 (gnus-auto-center-summary nil)
9444 (sum (current-buffer))
9445 (gnus-display-mime-function nil)
9448 (gnus-save-hidden-threads
9449 (gnus-summary-select-article)
9450 (set-buffer gnus-article-buffer)
9451 (goto-char (window-point (get-buffer-window (current-buffer))))
9455 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9457 (re-search-backward regexp nil t)
9458 (re-search-forward regexp nil t))
9459 ;; We found the regexp.
9464 (get-buffer-window (current-buffer))
9468 (get-buffer-window (current-buffer))
9471 (setq point (point)))
9472 ;; We didn't find it, so we go to the next article.
9475 (while (eq found 'not)
9476 (if (not (if backward (gnus-summary-find-prev)
9477 (gnus-summary-find-next)))
9478 ;; No more articles.
9480 ;; Select the next article and adjust point.
9481 (unless (gnus-summary-article-sparse-p
9482 (gnus-summary-article-number))
9484 (gnus-summary-select-article)
9485 (set-buffer gnus-article-buffer)
9487 (goto-char (if backward (point-max) (point-min))))))))
9488 (gnus-message 7 ""))
9489 ;; Return whether we found the regexp.
9490 (when (eq found 'found)
9492 (gnus-summary-show-thread)
9493 (gnus-summary-goto-subject gnus-current-article)
9494 (gnus-summary-position-point)
9497 (defun gnus-find-matching-articles (header regexp)
9498 "Return a list of all articles that match REGEXP on HEADER.
9499 This search includes all articles in the current group that Gnus has
9500 fetched headers for, whether they are displayed or not."
9501 (let ((articles nil)
9502 ;; Can't eta-reduce because it's a macro.
9503 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9504 (case-fold-search t))
9505 (dolist (header gnus-newsgroup-headers)
9506 (when (string-match regexp (funcall func header))
9507 (push (mail-header-number header) articles)))
9508 (nreverse articles)))
9510 (defun gnus-summary-find-matching (header regexp &optional backward unread
9511 not-case-fold not-matching)
9512 "Return a list of all articles that match REGEXP on HEADER.
9513 The search stars on the current article and goes forwards unless
9514 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9515 If UNREAD is non-nil, only unread articles will
9516 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9517 in the comparisons. If NOT-MATCHING, return a list of all articles that
9518 not match REGEXP on HEADER."
9519 (let ((case-fold-search (not not-case-fold))
9522 (if (eq (car header) 'extra)
9525 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9527 (error "%s is an invalid header" header))
9528 (unless (fboundp (intern (concat "mail-header-" header)))
9529 (error "%s is not a valid header" header))
9530 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9531 (dolist (d (if (eq backward 'all)
9533 (gnus-data-find-list
9534 (gnus-summary-article-number)
9535 (gnus-data-list backward))))
9536 (when (and (or (not unread) ; We want all articles...
9537 (gnus-data-unread-p d)) ; Or just unreads.
9538 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9542 (funcall func (gnus-data-header d))))
9543 (string-match regexp
9544 (funcall func (gnus-data-header d)))))
9545 (push (gnus-data-number d) articles))) ; Success!
9546 (nreverse articles)))
9548 (defun gnus-summary-execute-command (header regexp command &optional backward)
9549 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9550 If HEADER is an empty string (or nil), the match is done on the entire
9551 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9553 (list (let ((completion-ignore-case t))
9554 (gnus-completing-read
9556 (mapcar 'symbol-name
9558 '(Number Subject From Lines Date
9559 Message-ID Xref References Body)
9560 gnus-extra-headers))
9562 (read-string "Regexp: ")
9563 (read-key-sequence "Command: ")
9564 current-prefix-arg))
9565 (when (equal header "Body")
9567 ;; Hidden thread subtrees must be searched as well.
9568 (gnus-summary-show-all-threads)
9569 ;; We don't want to change current point nor window configuration.
9571 (save-window-excursion
9573 gnus-treat-strip-trailing-blank-lines
9574 gnus-treat-strip-leading-blank-lines
9575 gnus-treat-strip-multiple-blank-lines
9576 gnus-treat-hide-boring-headers
9577 gnus-treat-fold-newsgroups
9578 gnus-article-prepare-hook)
9579 (gnus-message 6 "Executing %s..." (key-description command))
9580 ;; We'd like to execute COMMAND interactively so as to give arguments.
9581 (gnus-execute header regexp
9582 `(call-interactively ',(key-binding command))
9584 (gnus-message 6 "Executing %s...done" (key-description command))))))
9586 (defun gnus-summary-beginning-of-article ()
9587 "Scroll the article back to the beginning."
9589 (gnus-summary-select-article)
9590 (gnus-configure-windows 'article)
9591 (gnus-eval-in-buffer-window gnus-article-buffer
9593 (goto-char (point-min))
9594 (when gnus-break-pages
9595 (gnus-narrow-to-page))))
9597 (defun gnus-summary-end-of-article ()
9598 "Scroll to the end of the article."
9600 (gnus-summary-select-article)
9601 (gnus-configure-windows 'article)
9602 (gnus-eval-in-buffer-window gnus-article-buffer
9604 (goto-char (point-max))
9606 (when gnus-break-pages
9607 (gnus-narrow-to-page))))
9609 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9610 "Truncate to LEN and quote all \"(\"'s in STRING."
9611 (gnus-replace-in-string (if (and len (> (length string) len))
9612 (substring string 0 len)
9616 (defun gnus-summary-print-article (&optional filename n)
9617 "Generate and print a PostScript image of the process-marked (mail) articles.
9619 If used interactively, print the current article if none are
9620 process-marked. With prefix arg, prompt the user for the name of the
9623 When used from Lisp, accept two optional args FILENAME and N. N means
9624 to print the next N articles. If N is negative, print the N previous
9625 articles. If N is nil and articles have been marked with the process
9626 mark, print these instead.
9628 If the optional first argument FILENAME is nil, send the image to the
9629 printer. If FILENAME is a string, save the PostScript image in a file with
9630 that name. If FILENAME is a number, prompt the user for the name of the file
9632 (interactive (list (ps-print-preprint current-prefix-arg)))
9633 (dolist (article (gnus-summary-work-articles n))
9634 (gnus-summary-select-article nil nil 'pseudo article)
9635 (gnus-eval-in-buffer-window gnus-article-buffer
9636 (gnus-print-buffer))
9637 (gnus-summary-remove-process-mark article))
9638 (ps-despool filename))
9640 (defun gnus-print-buffer ()
9641 (let ((ps-left-header
9644 (gnus-summary-print-truncate-and-quote
9645 (mail-header-subject gnus-current-headers)
9648 (gnus-summary-print-truncate-and-quote
9649 (mail-header-from gnus-current-headers)
9653 "/pagenumberstring load"
9655 (mail-header-date gnus-current-headers) ")"))))
9656 (gnus-run-hooks 'gnus-ps-print-hook)
9658 (if ps-print-color-p
9659 (ps-spool-buffer-with-faces)
9660 (ps-spool-buffer)))))
9662 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9664 (defun gnus-summary-show-complete-article ()
9665 "Show a complete version of the current article.
9666 This is only useful if you're looking at a partial version of the
9669 (let ((gnus-keep-backlog nil)
9670 (gnus-use-cache nil)
9673 (format "%s-fetch-partial-articles"
9674 (car (gnus-find-method-for-group
9675 gnus-newsgroup-name)))
9680 (setq old-val (symbol-value variable))
9682 (gnus-flush-original-article-buffer)
9683 (gnus-summary-show-article))
9684 (set variable old-val))))
9686 (defun gnus-summary-show-article (&optional arg)
9687 "Force redisplaying of the current article.
9688 If ARG (the prefix) is a number, show the article with the charset
9689 defined in `gnus-summary-show-article-charset-alist', or the charset
9691 If ARG (the prefix) is non-nil and not a number, show the article,
9692 but without running any of the article treatment functions
9693 article. Normally, the keystroke is `C-u g'. When using `C-u
9694 C-u g', show the raw article."
9698 (gnus-summary-show-article t)
9699 (let ((gnus-newsgroup-charset
9700 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9701 (mm-read-coding-system
9702 "View as charset: " ;; actually it is coding system.
9703 (with-current-buffer gnus-article-buffer
9704 (mm-detect-coding-region (point) (point-max))))))
9705 (gnus-newsgroup-ignored-charsets 'gnus-all))
9706 (gnus-summary-select-article nil 'force)
9707 (let ((deps gnus-newsgroup-dependencies)
9709 (with-current-buffer gnus-original-article-buffer
9711 (message-narrow-to-head)
9712 (setq head (buffer-string))
9713 (goto-char (point-min))
9714 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9715 (goto-char (point-max))
9717 (setq lines (1- (count-lines (point) (point-max))))))
9719 (insert (format "211 %d Article retrieved.\n"
9720 (cdr gnus-article-current)))
9722 (if lines (insert (format "Lines: %d\n" lines)))
9724 (let ((nntp-server-buffer (current-buffer)))
9725 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9726 (gnus-data-set-header
9727 (gnus-data-find (cdr gnus-article-current))
9729 (gnus-summary-update-article-line
9730 (cdr gnus-article-current) header)
9731 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9732 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9734 ;; Select the article the normal way.
9735 (if (eq mm-text-html-renderer 'shr)
9738 (let ((shr-ignore-cache t))
9739 (gnus-summary-select-article nil 'force)))
9740 (gnus-summary-select-article nil 'force)))
9743 (let ((gnus-inhibit-article-treatments t))
9744 (gnus-summary-select-article nil 'force)))
9746 ;; We have to require this here to make sure that the following
9747 ;; dynamic binding isn't shadowed by autoloading.
9748 (require 'gnus-async)
9750 ;; Bind the article treatment functions to nil.
9751 (let ((gnus-have-all-headers t)
9752 gnus-article-prepare-hook
9753 gnus-article-decode-hook
9754 gnus-display-mime-function
9756 ;; Destroy any MIME parts.
9757 (when (gnus-buffer-live-p gnus-article-buffer)
9758 (with-current-buffer gnus-article-buffer
9759 (gnus-article-stop-animations)
9760 (gnus-stop-downloads)
9761 (mm-destroy-parts gnus-article-mime-handles)
9762 ;; Set it to nil for safety reason.
9763 (setq gnus-article-mime-handle-alist nil)
9764 (setq gnus-article-mime-handles nil)))
9765 (gnus-summary-select-article nil 'force))))
9766 (gnus-summary-goto-subject gnus-current-article)
9767 (gnus-summary-position-point))
9769 (defun gnus-summary-show-raw-article ()
9770 "Show the raw article without any article massaging functions being run."
9772 (gnus-summary-show-article t))
9774 (defun gnus-summary-verbose-headers (&optional arg)
9775 "Toggle permanent full header display.
9776 If ARG is a positive number, turn header display on.
9777 If ARG is a negative number, turn header display off."
9779 (setq gnus-show-all-headers
9780 (cond ((or (not (numberp arg))
9782 (not gnus-show-all-headers))
9785 (gnus-summary-show-article))
9787 (declare-function article-narrow-to-head "gnus-art" ())
9788 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9789 (declare-function gnus-delete-wash-type "gnus-art" (type))
9790 (declare-function gnus-mime-buttonize-attachments-in-header
9791 "gnus-art" (&optional interactive))
9793 (defun gnus-summary-toggle-header (&optional arg)
9794 "Show the headers if they are hidden, or hide them if they are shown.
9795 If ARG is a positive number, show the entire header.
9796 If ARG is a negative number, hide the unwanted header lines."
9798 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9799 (get-buffer-window gnus-article-buffer t))))
9800 (with-current-buffer gnus-article-buffer
9802 (article-narrow-to-head)
9803 (let* ((inhibit-read-only t)
9804 (inhibit-point-motion-hooks t)
9805 (hidden (if (numberp arg)
9807 (or (not (looking-at "[^ \t\n]+:"))
9808 (gnus-article-hidden-text-p 'headers))))
9810 (delete-region (point-min) (point-max))
9811 (with-current-buffer gnus-original-article-buffer
9812 (goto-char (setq s (point-min)))
9813 (setq e (if (search-forward "\n\n" nil t)
9816 (insert-buffer-substring gnus-original-article-buffer s e)
9817 (run-hooks 'gnus-article-decode-hook)
9819 (let ((gnus-treat-hide-headers nil)
9820 (gnus-treat-hide-boring-headers nil))
9821 (gnus-delete-wash-type 'headers)
9822 (gnus-treat-article 'head))
9823 (gnus-treat-article 'head)
9824 ;; Add attachment buttons to the header.
9825 (when gnus-mime-display-attachment-buttons-in-header
9826 (gnus-mime-buttonize-attachments-in-header)))
9829 (set-window-start window (goto-char (point-min))))
9830 (if gnus-break-pages
9831 (gnus-narrow-to-page)
9832 (when (gnus-visual-p 'page-marker)
9833 (let ((inhibit-read-only t))
9834 (gnus-remove-text-with-property 'gnus-prev)
9835 (gnus-remove-text-with-property 'gnus-next))))
9836 (gnus-set-mode-line 'article)))))
9838 (defun gnus-summary-show-all-headers ()
9839 "Make all header lines visible."
9841 (gnus-summary-toggle-header 1))
9843 (defun gnus-summary-caesar-message (&optional arg)
9844 "Caesar rotate the current article by 13.
9845 With a non-numerical prefix, also rotate headers. A numerical
9846 prefix specifies how many places to rotate each letter forward."
9848 (gnus-summary-select-article)
9849 (let ((mail-header-separator ""))
9850 (gnus-eval-in-buffer-window gnus-article-buffer
9853 (let ((start (window-start))
9854 (inhibit-read-only t))
9855 (if (equal arg '(4))
9856 (message-caesar-buffer-body nil t)
9857 (message-caesar-buffer-body arg))
9858 (set-window-start (get-buffer-window (current-buffer)) start)))))
9859 ;; Create buttons and stuff...
9860 (gnus-treat-article nil))
9862 (declare-function idna-to-unicode "ext:idna" (str))
9864 (defun gnus-summary-idna-message (&optional arg)
9865 "Decode IDNA encoded domain names in the current articles.
9866 IDNA encoded domain names looks like `xn--bar'. If a string
9867 remain unencoded after running this function, it is likely an
9868 invalid IDNA string (`xn--bar' is invalid).
9870 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9871 installed for this command to work."
9873 (if (not (and (condition-case nil (require 'idna)
9875 (mm-coding-system-p 'utf-8)
9876 (symbol-value 'idna-program)
9877 (executable-find (symbol-value 'idna-program))))
9879 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9880 (gnus-summary-select-article)
9881 (let ((mail-header-separator ""))
9882 (gnus-eval-in-buffer-window gnus-article-buffer
9885 (let ((start (window-start))
9887 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9888 (replace-match (idna-to-unicode (match-string 1))))
9889 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9891 (defun gnus-summary-morse-message (&optional arg)
9892 "Morse decode the current article."
9894 (gnus-summary-select-article)
9895 (let ((mail-header-separator ""))
9896 (gnus-eval-in-buffer-window gnus-article-buffer
9900 (let ((pos (window-start))
9901 (inhibit-read-only t))
9902 (goto-char (point-min))
9903 (when (message-goto-body)
9904 (gnus-narrow-to-body))
9905 (goto-char (point-min))
9906 (while (search-forward "·" (point-max) t)
9907 (replace-match "."))
9908 (unmorse-region (point-min) (point-max))
9910 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9912 (defun gnus-summary-stop-page-breaking ()
9913 "Stop page breaking in the current article."
9915 (gnus-summary-select-article)
9916 (gnus-eval-in-buffer-window gnus-article-buffer
9918 (when (gnus-visual-p 'page-marker)
9919 (let ((inhibit-read-only t))
9920 (gnus-remove-text-with-property 'gnus-prev)
9921 (gnus-remove-text-with-property 'gnus-next))
9922 (setq gnus-page-broken nil))))
9924 (defun gnus-summary-move-article (&optional n to-newsgroup
9925 select-method action)
9926 "Move the current article to a different newsgroup.
9927 If N is a positive number, move the N next articles.
9928 If N is a negative number, move the N previous articles.
9929 If N is nil and any articles have been marked with the process mark,
9930 move those articles instead.
9931 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9932 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9933 re-spool using this method.
9935 When called interactively with TO-NEWSGROUP being nil, the value of
9936 the variable `gnus-move-split-methods' is used for finding a default
9937 for the target newsgroup.
9939 For this function to work, both the current newsgroup and the
9940 newsgroup that you want to move to have to support the `request-move'
9941 and `request-accept' functions.
9943 ACTION can be either `move' (the default), `crosspost' or `copy'."
9946 (setq action 'move))
9947 ;; Check whether the source group supports the required functions.
9948 (cond ((and (eq action 'move)
9949 (not (gnus-check-backend-function
9950 'request-move-article gnus-newsgroup-name)))
9951 (error "The current group does not support article moving"))
9952 ((and (eq action 'crosspost)
9953 (not (gnus-check-backend-function
9954 'request-replace-article gnus-newsgroup-name)))
9955 (error "The current group does not support article editing")))
9956 (let ((articles (gnus-summary-work-articles n))
9957 (prefix (if (gnus-check-backend-function
9958 'request-move-article gnus-newsgroup-name)
9959 (funcall gnus-move-group-prefix-function
9960 gnus-newsgroup-name)
9962 (names '((move "Move" "Moving")
9963 (copy "Copy" "Copying")
9964 (crosspost "Crosspost" "Crossposting")))
9965 (copy-buf (save-excursion
9966 (nnheader-set-temp-buffer " *copy article*")))
9967 art-group to-method new-xref article to-groups
9968 articles-to-update-marks encoded)
9969 (unless (assq action names)
9970 (error "Unknown action %s" action))
9971 ;; Read the newsgroup name.
9972 (when (and (not to-newsgroup)
9973 (not select-method))
9974 (if (and gnus-move-split-methods
9976 (and (memq gnus-current-article articles)
9977 (gnus-buffer-live-p gnus-original-article-buffer))))
9978 ;; When `gnus-move-split-methods' is non-nil, we have to
9979 ;; select an article to give `gnus-read-move-group-name' an
9980 ;; opportunity to suggest an appropriate default. However,
9981 ;; we needn't render or mark the article.
9982 (let ((gnus-display-mime-function nil)
9983 (gnus-article-prepare-hook nil)
9984 (gnus-mark-article-hook nil))
9985 (gnus-summary-select-article nil nil nil (car articles))))
9986 (setq to-newsgroup (gnus-read-move-group-name
9987 (cadr (assq action names))
9989 (intern (format "gnus-current-%s-group" action)))
9991 encoded to-newsgroup
9992 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9993 (set (intern (format "gnus-current-%s-group" action))
9994 (mm-decode-coding-string
9996 (gnus-group-name-charset to-method to-newsgroup))))
9998 (setq to-method (or select-method
9999 (gnus-server-to-method
10000 (gnus-group-method to-newsgroup)))))
10004 (mm-encode-coding-string
10006 (gnus-group-name-charset to-method to-newsgroup)))))
10007 ;; Check the method we are to move this article to...
10008 (unless (gnus-check-backend-function
10009 'request-accept-article (car to-method))
10010 (error "%s does not support article copying" (car to-method)))
10011 (unless (gnus-check-server to-method)
10012 (error "Can't open server %s" (car to-method)))
10013 (gnus-message 6 "%s to %s: %s..."
10014 (caddr (assq action names))
10015 (or (car select-method)
10016 (gnus-group-decoded-name to-newsgroup))
10019 (setq article (pop articles))
10020 ;; Set any marks that may have changed in the summary buffer.
10021 (when gnus-preserve-marks
10022 (gnus-summary-push-marks-to-backend article))
10026 ;; Move the article.
10028 ;; Remove this article from future suppression.
10029 (gnus-dup-unsuppress-article article)
10030 (let* ((from-method (gnus-find-method-for-group
10031 gnus-newsgroup-name))
10032 (to-method (or select-method
10033 (gnus-find-method-for-group to-newsgroup)))
10034 (move-is-internal (gnus-server-equal from-method to-method)))
10035 (gnus-request-move-article
10036 article ; Article to move
10037 gnus-newsgroup-name ; From newsgroup
10038 (nth 1 (gnus-find-method-for-group
10039 gnus-newsgroup-name)) ; Server
10040 (list 'gnus-request-accept-article
10041 to-newsgroup (list 'quote select-method)
10042 (not articles) t) ; Accept form
10043 (not articles) ; Only save nov last time
10044 (and move-is-internal
10045 to-newsgroup ; Not respooling
10046 ; Is this move internal?
10047 (gnus-group-real-name to-newsgroup)))))
10048 ;; Copy the article.
10050 (with-current-buffer copy-buf
10051 (when (gnus-request-article-this-buffer article
10052 gnus-newsgroup-name)
10054 (nnheader-narrow-to-headers)
10055 (dolist (hdr gnus-copy-article-ignored-headers)
10056 (message-remove-header hdr t)))
10057 (gnus-request-accept-article
10058 to-newsgroup select-method (not articles) t))))
10059 ;; Crosspost the article.
10060 ((eq action 'crosspost)
10061 (let ((xref (message-tokenize-header
10062 (mail-header-xref (gnus-summary-article-header
10065 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10066 ":" (number-to-string article)))
10068 (setq xref (list (system-name))))
10071 (mapconcat 'identity
10072 (delete "Xref:" (delete new-xref xref))
10075 (with-current-buffer copy-buf
10076 ;; First put the article in the destination group.
10077 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10078 (when (consp (setq art-group
10079 (gnus-request-accept-article
10080 to-newsgroup select-method (not articles)
10082 (setq new-xref (concat new-xref " " (car art-group)
10084 (number-to-string (cdr art-group))))
10085 ;; Now we have the new Xrefs header, so we insert
10086 ;; it and replace the new article.
10087 (nnheader-replace-header "Xref" new-xref)
10088 (gnus-request-replace-article
10089 (cdr art-group) to-newsgroup (current-buffer) t)
10093 (gnus-message 1 "Couldn't %s article %s: %s"
10094 (cadr (assq action names)) article
10095 (nnheader-get-report (car to-method))))
10096 ((eq art-group 'junk)
10097 (when (eq action 'move)
10098 (gnus-summary-mark-article article gnus-canceled-mark)
10099 (gnus-message 4 "Deleted article %s" article)
10100 ;; run the delete hook
10101 (run-hook-with-args 'gnus-summary-article-delete-hook
10104 (assoc article (gnus-data-list nil)))
10105 gnus-newsgroup-name nil
10108 (let* ((pto-group (gnus-group-prefixed-name
10109 (car art-group) to-method))
10110 (info (gnus-get-info pto-group))
10111 (to-group (gnus-info-group info))
10113 ;; Update the group that has been moved to.
10115 (memq action '(move copy)))
10116 (unless (member to-group to-groups)
10117 (push to-group to-groups))
10119 (when (and (not (memq article gnus-newsgroup-unreads))
10121 (push 'read to-marks)
10122 (gnus-info-set-read
10123 info (gnus-add-to-range (gnus-info-read info)
10124 (list (cdr art-group)))))
10126 ;; See whether the article is to be put in the cache.
10127 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10128 (marks (if expirable
10129 gnus-article-mark-lists
10130 (delete '(expirable . expire)
10132 gnus-article-mark-lists))))
10133 (to-article (cdr art-group)))
10135 ;; Enter the article into the cache in the new group,
10136 ;; if that is required.
10137 (when (and to-article
10139 (gnus-cache-possibly-enter-article
10140 to-group to-article
10141 (memq article gnus-newsgroup-marked)
10142 (memq article gnus-newsgroup-dormant)
10143 (memq article gnus-newsgroup-unreads)))
10145 (when (and gnus-preserve-marks
10147 ;; Copy any marks over to the new group.
10148 (when (and (equal to-group gnus-newsgroup-name)
10149 (not (memq article gnus-newsgroup-unreads)))
10150 ;; Mark this article as read in this group.
10151 (push (cons to-article gnus-read-mark)
10152 gnus-newsgroup-reads)
10153 ;; Increase the active status of this group.
10154 (setcdr (gnus-active to-group) to-article)
10155 (setcdr gnus-newsgroup-active to-article))
10158 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10159 (when (memq article (symbol-value
10160 (intern (format "gnus-newsgroup-%s"
10162 (push (cdar marks) to-marks)
10163 ;; If the other group is the same as this group,
10164 ;; then we have to add the mark to the list.
10165 (when (equal to-group gnus-newsgroup-name)
10166 (set (intern (format "gnus-newsgroup-%s"
10170 (intern (format "gnus-newsgroup-%s"
10172 ;; Copy the marks to other group.
10173 (gnus-add-marked-articles
10174 to-group (cdar marks) (list to-article) info)))
10175 (setq marks (cdr marks)))
10177 (when (and expirable
10178 gnus-mark-copied-or-moved-articles-as-expirable
10179 (not (memq 'expire to-marks)))
10180 ;; Mark this article as expirable.
10181 (push 'expire to-marks)
10182 (when (equal to-group gnus-newsgroup-name)
10183 (push to-article gnus-newsgroup-expirable))
10184 ;; Copy the expirable mark to other group.
10185 (gnus-add-marked-articles
10186 to-group 'expire (list to-article) info))
10188 (when (and to-marks
10189 (gnus-method-option-p
10190 (gnus-find-method-for-group to-group)
10192 (gnus-request-set-mark
10193 to-group (list (list (list to-article) 'add to-marks)))))
10195 (gnus-dribble-enter
10196 (concat "(gnus-group-set-info '"
10197 (gnus-prin1-to-string (gnus-get-info to-group))
10199 (concat "^(gnus-group-set-info '(\""
10200 (regexp-quote to-group) "\""))))
10202 ;; Update the Xref header in this article to point to
10203 ;; the new crossposted article we have just created.
10204 (when (eq action 'crosspost)
10205 (with-current-buffer copy-buf
10206 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10207 (nnheader-replace-header "Xref" new-xref)
10208 (gnus-request-replace-article
10209 article gnus-newsgroup-name (current-buffer) t)))
10211 ;; run the move/copy/crosspost/respool hook
10212 (run-hook-with-args 'gnus-summary-article-move-hook
10215 (assoc article (gnus-data-list nil)))
10216 gnus-newsgroup-name
10220 ;;;!!!Why is this necessary?
10221 (set-buffer gnus-summary-buffer)
10223 (when (eq action 'move)
10225 (gnus-summary-goto-subject article)
10226 (gnus-summary-mark-article article gnus-canceled-mark)))))
10227 (push article articles-to-update-marks))
10230 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10231 ;; Re-activate all groups that have been moved to.
10232 (with-current-buffer gnus-group-buffer
10233 (let ((gnus-group-marked to-groups))
10234 (gnus-group-get-new-news-this-group nil t)))
10236 (gnus-kill-buffer copy-buf)
10237 (gnus-summary-position-point)
10238 (gnus-set-mode-line 'summary)))
10240 (defun gnus-summary-push-marks-to-backend (article)
10243 (marks gnus-article-mark-lists))
10244 (unless (memq article gnus-newsgroup-unreads)
10247 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10248 (memq article (symbol-value
10249 (intern (format "gnus-newsgroup-%s"
10251 (push (cdar marks) set)
10252 (push (cdar marks) del))
10254 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10255 ((,article) del ,del)))))
10257 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10258 "Copy the current article to some other group.
10259 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10260 When called interactively, if TO-NEWSGROUP is nil, use the value of
10261 the variable `gnus-move-split-methods' for finding a default target
10263 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10264 re-spool using this method."
10266 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10268 (defun gnus-summary-crosspost-article (&optional n)
10269 "Crosspost the current article to some other group."
10271 (gnus-summary-move-article n nil nil 'crosspost))
10273 (defcustom gnus-summary-respool-default-method nil
10274 "Default method type for respooling an article.
10275 If nil, use to the current newsgroup method."
10277 :group 'gnus-summary-mail)
10279 (defun gnus-summary-respool-article (&optional n method)
10280 "Respool the current article.
10281 The article will be squeezed through the mail spooling process again,
10282 which means that it will be put in some mail newsgroup or other
10283 depending on `nnmail-split-methods'.
10284 If N is a positive number, respool the N next articles.
10285 If N is a negative number, respool the N previous articles.
10286 If N is nil and any articles have been marked with the process mark,
10287 respool those articles instead.
10289 Respooling can be done both from mail groups and \"real\" newsgroups.
10290 In the former case, the articles in question will be moved from the
10291 current group into whatever groups they are destined to. In the
10292 latter case, they will be copied into the relevant groups."
10294 (list current-prefix-arg
10295 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10297 (symbol-name (or gnus-summary-respool-default-method
10298 (car (gnus-find-method-for-group
10299 gnus-newsgroup-name)))))
10301 (gnus-completing-read
10302 "Backend to use when respooling"
10303 methods t nil 'gnus-mail-method-history methname))
10306 ((zerop (length (setq ms (gnus-servers-using-backend
10307 (intern method)))))
10308 (list (intern method) ""))
10312 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10313 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10316 (error "No method given for respooling"))
10317 (if (assoc (symbol-name
10318 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10319 (gnus-methods-using 'respool))
10320 (gnus-summary-move-article n nil method)
10321 (gnus-summary-copy-article n nil method)))
10323 (defun gnus-summary-import-article (file &optional edit)
10324 "Import an arbitrary file into a mail newsgroup."
10325 (interactive "fImport file: \nP")
10326 (let ((group gnus-newsgroup-name)
10327 (now (current-time))
10328 atts lines group-art)
10329 (unless (gnus-check-backend-function 'request-accept-article group)
10330 (error "%s does not support article importing" group))
10331 (or (file-readable-p file)
10332 (not (file-regular-p file))
10333 (error "Can't read %s" file))
10334 (with-current-buffer (gnus-get-buffer-create " *import file*")
10336 (nnheader-insert-file-contents file)
10337 (goto-char (point-min))
10338 (if (nnheader-article-p)
10340 (goto-char (point-min))
10341 (search-forward "\n\n" nil t)
10342 (narrow-to-region (point-min) (1- (point)))
10343 (goto-char (point-min))
10344 (unless (re-search-forward "^date:" nil t)
10345 (goto-char (point-max))
10346 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10347 ;; This doesn't look like an article, so we fudge some headers.
10348 (setq atts (file-attributes file)
10349 lines (count-lines (point-min) (point-max)))
10350 (insert "From: " (read-string "From: ") "\n"
10351 "Subject: " (read-string "Subject: ") "\n"
10352 "Date: " (message-make-date (nth 5 atts)) "\n"
10353 "Message-ID: " (message-make-message-id) "\n"
10354 "Lines: " (int-to-string lines) "\n"
10355 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10356 (setq group-art (gnus-request-accept-article group nil t))
10357 (kill-buffer (current-buffer)))
10358 (setq gnus-newsgroup-active (gnus-activate-group group))
10360 (gnus-summary-goto-article (cdr group-art) nil t)
10362 (gnus-summary-edit-article))))
10364 (defun gnus-summary-create-article ()
10365 "Create an article in a mail newsgroup."
10367 (let ((group gnus-newsgroup-name)
10368 (now (current-time))
10370 (unless (gnus-check-backend-function 'request-accept-article group)
10371 (error "%s does not support article importing" group))
10372 (with-current-buffer (gnus-get-buffer-create " *import file*")
10374 (goto-char (point-min))
10375 ;; This doesn't look like an article, so we fudge some headers.
10376 (insert "From: " (read-string "From: ") "\n"
10377 "Subject: " (read-string "Subject: ") "\n"
10378 "Date: " (message-make-date now) "\n"
10379 "Message-ID: " (message-make-message-id) "\n")
10380 (setq group-art (gnus-request-accept-article group nil t))
10381 (kill-buffer (current-buffer)))
10382 (setq gnus-newsgroup-active (gnus-activate-group group))
10384 (gnus-summary-goto-article (cdr group-art) nil t)
10385 (gnus-summary-edit-article)))
10387 (defun gnus-summary-article-posted-p ()
10388 "Say whether the current (mail) article is available from news as well.
10389 This will be the case if the article has both been mailed and posted."
10391 (let ((id (mail-header-references (gnus-summary-article-header)))
10392 (gnus-override-method (car (gnus-refer-article-methods))))
10393 (if (gnus-request-head id "")
10394 (gnus-message 2 "The current message was found on %s"
10395 gnus-override-method)
10396 (gnus-message 2 "The current message couldn't be found on %s"
10397 gnus-override-method)
10400 (defun gnus-summary-expire-articles (&optional now)
10401 "Expire all articles that are marked as expirable in the current group."
10403 (when (and (not gnus-group-is-exiting-without-update-p)
10404 (gnus-check-backend-function
10405 'request-expire-articles gnus-newsgroup-name))
10406 ;; This backend supports expiry.
10407 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10409 (gnus-list-range-difference
10412 ;; We need to update the info for
10413 ;; this group for `gnus-list-of-read-articles'
10414 ;; to give us the right answer.
10415 (gnus-run-hooks 'gnus-exit-group-hook)
10416 (gnus-summary-update-info)
10417 (gnus-list-of-read-articles gnus-newsgroup-name))
10418 (setq gnus-newsgroup-expirable
10419 (sort gnus-newsgroup-expirable '<)))
10420 gnus-newsgroup-unexist))
10421 (expiry-wait (if now 'immediate
10422 (gnus-group-find-parameter
10423 gnus-newsgroup-name 'expiry-wait)))
10424 (nnmail-expiry-target
10425 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10426 nnmail-expiry-target))
10429 ;; There are expirable articles in this group, so we run them
10430 ;; through the expiry process.
10431 (gnus-message 6 "Expiring articles...")
10432 (when (gnus-check-group gnus-newsgroup-name)
10433 ;; The list of articles that weren't expired is returned.
10436 (let ((nnmail-expiry-wait-function nil)
10437 (nnmail-expiry-wait expiry-wait))
10438 (setq es (gnus-request-expire-articles
10439 expirable gnus-newsgroup-name)))
10440 (setq es (gnus-request-expire-articles
10441 expirable gnus-newsgroup-name)))
10443 (setq gnus-newsgroup-expirable es))
10444 ;; We go through the old list of expirable, and mark all
10445 ;; really expired articles as nonexistent.
10446 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10447 (let ((gnus-use-cache nil))
10448 (dolist (article expirable)
10449 (when (and (not (memq article es))
10450 (gnus-data-find article))
10451 (gnus-summary-mark-article article gnus-canceled-mark)
10452 (run-hook-with-args
10453 'gnus-summary-article-expire-hook
10455 (gnus-data-header (assoc article (gnus-data-list nil)))
10456 gnus-newsgroup-name
10458 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10459 ((eq nnmail-expiry-target 'delete) nil)
10461 (let ((rescall (funcall nnmail-expiry-target
10462 gnus-newsgroup-name)))
10463 (if (stringp rescall) rescall nil))))
10465 (gnus-message 6 "Expiring articles...done")))))
10467 (defun gnus-summary-expire-articles-now ()
10468 "Expunge all expirable articles in the current group.
10469 This means that *all* articles that are marked as expirable will be
10470 deleted forever, right now."
10472 (or gnus-expert-user
10474 "Are you really, really sure you want to delete all expirable messages? ")
10476 (gnus-summary-expire-articles t))
10478 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10479 (defun gnus-summary-delete-article (&optional n)
10480 "Delete the N next (mail) articles.
10481 This command actually deletes articles. This is not a marking
10482 command. The article will disappear forever from your life, never to
10485 If N is negative, delete backwards.
10486 If N is nil and articles have been marked with the process mark,
10487 delete these instead.
10489 If `gnus-novice-user' is non-nil you will be asked for
10490 confirmation before the articles are deleted."
10492 (unless (gnus-check-backend-function 'request-expire-articles
10493 gnus-newsgroup-name)
10494 (error "The current newsgroup does not support article deletion"))
10495 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10496 (error "Couldn't open server"))
10497 ;; Compute the list of articles to delete.
10498 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10499 (nnmail-expiry-target 'delete)
10501 (if (and gnus-novice-user
10502 (not (gnus-yes-or-no-p
10503 (format "Do you really want to delete %s forever? "
10504 (if (> (length articles) 1)
10505 (format "these %s articles" (length articles))
10506 "this article")))))
10508 ;; Delete the articles.
10509 (setq not-deleted (gnus-request-expire-articles
10510 articles gnus-newsgroup-name 'force))
10513 (gnus-summary-remove-process-mark (car articles))
10514 ;; The backend might not have been able to delete the article
10516 (unless (memq (car articles) not-deleted)
10517 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10518 (let* ((article (car articles))
10519 (ghead (gnus-data-header
10520 (assoc article (gnus-data-list nil)))))
10521 (run-hook-with-args 'gnus-summary-article-delete-hook
10522 'delete ghead gnus-newsgroup-name nil
10524 (setq articles (cdr articles))))
10526 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10527 (gnus-summary-position-point)
10528 (gnus-set-mode-line 'summary)
10531 (defun gnus-summary-edit-article (&optional arg)
10532 "Edit the current article.
10533 This will have permanent effect only in mail groups.
10534 If ARG is nil, edit the decoded articles.
10535 If ARG is 1, edit the raw articles.
10536 If ARG is 2, edit the raw articles even in read-only groups.
10537 If ARG is 3, edit the articles with the current handles.
10538 Otherwise, allow editing of articles even in read-only
10541 (let (force raw current-handles)
10550 (setq current-handles
10551 (and (gnus-buffer-live-p gnus-article-buffer)
10552 (with-current-buffer gnus-article-buffer
10554 gnus-article-mime-handles
10555 (setq gnus-article-mime-handles nil))))))
10558 (when (and raw (not force)
10559 (member gnus-newsgroup-name '("nndraft:delayed"
10562 (error "Can't edit the raw article in group %s"
10563 gnus-newsgroup-name))
10564 (with-current-buffer gnus-summary-buffer
10565 (let ((mail-parse-charset gnus-newsgroup-charset)
10566 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10567 (gnus-set-global-variables)
10568 (when (and (not force)
10569 (gnus-group-read-only-p))
10570 (error "The current newsgroup does not support article editing"))
10571 (gnus-summary-show-article t)
10572 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10573 (with-current-buffer gnus-article-buffer
10574 (mm-enable-multibyte)))
10575 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10577 (gnus-article-edit-article
10580 (let ((mbl mml-buffer-list))
10581 (setq mml-buffer-list nil)
10582 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10583 (mime-to-mml ,'current-handles))
10584 (let ((mbl1 mml-buffer-list))
10585 (setq mml-buffer-list mbl)
10586 (set (make-local-variable 'mml-buffer-list) mbl1))
10587 (gnus-make-local-hook 'kill-buffer-hook)
10588 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10589 `(lambda (no-highlight)
10590 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10591 (message-options message-options)
10592 (message-options-set-recipient)
10593 (mail-parse-ignored-charsets
10594 ',gnus-newsgroup-ignored-charsets)
10595 (rfc2047-header-encoding-alist
10596 ',(let ((charset (gnus-group-name-charset
10597 (gnus-find-method-for-group
10598 gnus-newsgroup-name)
10599 gnus-newsgroup-name)))
10600 (append (list (cons "Newsgroups" charset)
10601 (cons "Followup-To" charset)
10602 (cons "Xref" charset))
10603 rfc2047-header-encoding-alist))))
10604 ,(if (not raw) '(progn
10606 (mml-destroy-buffers)
10607 (remove-hook 'kill-buffer-hook
10608 'mml-destroy-buffers t)
10609 (kill-local-variable 'mml-buffer-list)))
10610 (gnus-summary-edit-article-done
10611 ,(or (mail-header-references gnus-current-headers) "")
10612 ,(gnus-group-read-only-p)
10613 ,gnus-summary-buffer no-highlight))))))))
10615 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10617 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10619 "Make edits to the current article permanent."
10622 ;; The buffer restriction contains the entire article if it exists.
10623 (when (article-goto-body)
10624 (let ((lines (count-lines (point) (point-max)))
10625 (length (- (point-max) (point)))
10626 (case-fold-search t)
10627 (body (point-marker)))
10628 (goto-char (point-min))
10629 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10630 (delete-region (match-beginning 1) (match-end 1))
10631 (insert (number-to-string length)))
10632 (goto-char (point-min))
10633 (when (re-search-forward
10634 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10635 (delete-region (match-beginning 1) (match-end 1))
10636 (insert (number-to-string length)))
10637 (goto-char (point-min))
10638 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10639 (delete-region (match-beginning 1) (match-end 1))
10640 (insert (number-to-string lines))))))
10641 ;; Replace the article.
10642 (let ((buf (current-buffer))
10643 (article (cdr gnus-article-current))
10646 (insert-buffer-substring buf)
10647 (if (and (not read-only)
10648 (not (setq replace-result
10649 (gnus-request-replace-article
10650 article (car gnus-article-current)
10651 (current-buffer) t))))
10652 (error "Couldn't replace article")
10653 ;; If we got a number back, then that's the new article number
10654 ;; for this article. Otherwise, the article number didn't change.
10655 (when (numberp replace-result)
10656 (with-current-buffer gnus-summary-buffer
10657 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10658 (gnus-summary-limit gnus-newsgroup-limit)
10659 (setq article replace-result)
10660 (gnus-summary-goto-subject article t)))
10661 ;; Update the summary buffer.
10662 (if (and references
10663 (equal (message-tokenize-header references " ")
10664 (message-tokenize-header
10665 (or (message-fetch-field "references") "") " ")))
10666 ;; We only have to update this line.
10669 (message-narrow-to-head)
10670 (let ((head (buffer-substring-no-properties
10671 (point-min) (point-max)))
10674 (insert (format "211 %d Article retrieved.\n" article))
10677 (let ((nntp-server-buffer (current-buffer)))
10678 (setq header (car (gnus-get-newsgroup-headers nil t))))
10679 (with-current-buffer gnus-summary-buffer
10680 (gnus-data-set-header (gnus-data-find article) header)
10681 (gnus-summary-update-article-line article header)
10682 (if (gnus-summary-goto-subject article nil t)
10683 (gnus-summary-update-secondary-mark article)))))))
10685 (set-buffer (or buffer gnus-summary-buffer))
10686 (gnus-summary-update-article article)
10687 (if (gnus-summary-goto-subject article nil t)
10688 (gnus-summary-update-secondary-mark article)))
10689 ;; Prettify the article buffer again.
10690 (unless no-highlight
10691 (with-current-buffer gnus-article-buffer
10692 ;;!!! Fix this -- article should be rehighlighted.
10693 ;;(gnus-run-hooks 'gnus-article-display-hook)
10694 (set-buffer gnus-original-article-buffer)
10695 (gnus-request-article
10696 article (car gnus-article-current) (current-buffer))))
10697 ;; Prettify the summary buffer line.
10698 (when (gnus-visual-p 'summary-highlight 'highlight)
10699 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10701 (defun gnus-summary-edit-wash (key)
10702 "Perform editing command KEY in the article buffer."
10706 (message "%s" (concat (this-command-keys) "- "))
10709 (gnus-summary-edit-article)
10710 (execute-kbd-macro (concat (this-command-keys) key))
10711 (gnus-article-edit-done))
10715 (defvar nnimap-split-fancy)
10716 (defvar nnimap-split-methods)
10718 (defun gnus-summary-respool-query (&optional silent trace)
10719 "Query where the respool algorithm would put this article."
10721 (let (gnus-mark-article-hook)
10722 (gnus-summary-select-article)
10723 (with-current-buffer gnus-original-article-buffer
10725 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10727 ;; nnimap has its own splitting variables.
10728 (let ((nnmail-split-methods
10730 ((eq nnimap-split-methods 'default)
10731 nnmail-split-methods)
10732 (nnimap-split-methods
10733 nnimap-split-methods)
10734 (nnimap-split-fancy
10735 'nnmail-split-fancy)))
10736 (nnmail-split-fancy (or nnimap-split-fancy
10737 nnmail-split-fancy)))
10738 (nnmail-article-group 'identity trace))
10739 (nnmail-article-group 'identity trace))))
10742 (message "This message would go to %s"
10743 (mapconcat 'car groups ", "))
10744 (message "This message would go to no groups"))
10747 (defun gnus-summary-respool-trace ()
10748 "Trace where the respool algorithm would put this article.
10749 Display a buffer showing all fancy splitting patterns which matched."
10751 (gnus-summary-respool-query nil t))
10753 ;; Summary marking commands.
10755 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10756 "Mark articles which has the same subject as read, and then select the next.
10757 If UNMARK is positive, remove any kind of mark.
10758 If UNMARK is negative, tick articles."
10761 (setq unmark (prefix-numeric-value unmark)))
10763 (gnus-summary-mark-same-subject
10764 (gnus-summary-article-subject) unmark)))
10765 ;; Select next unread article. If auto-select-same mode, should
10766 ;; select the first unread article.
10767 (gnus-summary-next-article t (and gnus-auto-select-same
10768 (gnus-summary-article-subject)))
10769 (gnus-message 7 "%d article%s marked as %s"
10770 count (if (= count 1) " is" "s are")
10771 (if unmark "unread" "read"))))
10773 (defun gnus-summary-kill-same-subject (&optional unmark)
10774 "Mark articles which has the same subject as read.
10775 If UNMARK is positive, remove any kind of mark.
10776 If UNMARK is negative, tick articles."
10779 (setq unmark (prefix-numeric-value unmark)))
10781 (gnus-summary-mark-same-subject
10782 (gnus-summary-article-subject) unmark)))
10783 ;; If marked as read, go to next unread subject.
10784 (when (null unmark)
10785 ;; Go to next unread subject.
10786 (gnus-summary-next-subject 1 t))
10787 (gnus-message 7 "%d articles are marked as %s"
10788 count (if unmark "unread" "read"))))
10790 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10791 "Mark articles with same SUBJECT as read, and return marked number.
10792 If optional argument UNMARK is positive, remove any kinds of marks.
10793 If optional argument UNMARK is negative, mark articles as unread instead."
10797 ((null unmark) ; Mark as read.
10800 (gnus-summary-mark-article-as-read gnus-killed-mark)
10801 (gnus-summary-show-thread) t)
10802 (gnus-summary-find-subject subject))
10803 (setq count (1+ count))))
10804 ((> unmark 0) ; Tick.
10807 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10808 (gnus-summary-show-thread) t)
10809 (gnus-summary-find-subject subject))
10810 (setq count (1+ count))))
10811 (t ; Mark as unread.
10814 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10815 (gnus-summary-show-thread) t)
10816 (gnus-summary-find-subject subject))
10817 (setq count (1+ count)))))
10818 (gnus-set-mode-line 'summary)
10819 ;; Return the number of marked articles.
10822 (defun gnus-summary-mark-as-processable (n &optional unmark)
10823 "Set the process mark on the next N articles.
10824 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10825 the process mark instead. The difference between N and the actual
10826 number of articles marked is returned."
10828 (if (and (null n) (gnus-region-active-p))
10829 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10830 (setq n (prefix-numeric-value n))
10831 (let ((backward (< n 0))
10836 (gnus-summary-remove-process-mark
10837 (gnus-summary-article-number))
10838 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10839 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10842 (gnus-message 7 "No more articles"))
10843 (gnus-summary-recenter)
10844 (gnus-summary-position-point)
10847 (defun gnus-summary-unmark-as-processable (n)
10848 "Remove the process mark from the next N articles.
10849 If N is negative, unmark backward instead. The difference between N and
10850 the actual number of articles unmarked is returned."
10852 (gnus-summary-mark-as-processable n t))
10854 (defun gnus-summary-unmark-all-processable ()
10855 "Remove the process mark from all articles."
10858 (while gnus-newsgroup-processable
10859 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10860 (gnus-summary-position-point))
10862 (defun gnus-summary-add-mark (article type)
10863 "Mark ARTICLE with a mark of TYPE."
10864 (let ((vtype (car (assq type gnus-article-mark-lists)))
10867 (error "No such mark type: %s" type)
10868 (setq var (intern (format "gnus-newsgroup-%s" type)))
10869 (set var (cons article (symbol-value var)))
10870 (if (memq type '(processable cached replied forwarded recent saved))
10871 (gnus-summary-update-secondary-mark article)
10872 ;;; !!! This is bogus. We should find out what primary
10873 ;;; !!! mark we want to set.
10874 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10876 (defun gnus-summary-mark-as-expirable (n)
10877 "Mark N articles forward as expirable.
10878 If N is negative, mark backward instead. The difference between N and
10879 the actual number of articles marked is returned."
10881 (gnus-summary-mark-forward n gnus-expirable-mark))
10883 (defun gnus-summary-mark-as-spam (n)
10884 "Mark N articles forward as spam.
10885 If N is negative, mark backward instead. The difference between N and
10886 the actual number of articles marked is returned."
10888 (gnus-summary-mark-forward n gnus-spam-mark))
10890 (defun gnus-summary-mark-article-as-replied (article)
10891 "Mark ARTICLE as replied to and update the summary line.
10892 ARTICLE can also be a list of articles."
10893 (interactive (list (gnus-summary-article-number)))
10894 (let ((articles (if (listp article) article (list article))))
10895 (dolist (article articles)
10896 (unless (numberp article)
10897 (error "%s is not a number" article))
10898 (push article gnus-newsgroup-replied)
10899 (let ((inhibit-read-only t))
10900 (when (gnus-summary-goto-subject article nil t)
10901 (gnus-summary-update-secondary-mark article))))))
10903 (defun gnus-summary-mark-article-as-forwarded (article)
10904 "Mark ARTICLE as forwarded and update the summary line.
10905 ARTICLE can also be a list of articles."
10906 (let ((articles (if (listp article) article (list article))))
10907 (dolist (article articles)
10908 (push article gnus-newsgroup-forwarded)
10909 (let ((inhibit-read-only t))
10910 (when (gnus-summary-goto-subject article nil t)
10911 (gnus-summary-update-secondary-mark article))))))
10913 (defun gnus-summary-set-bookmark (article)
10914 "Set a bookmark in current article."
10915 (interactive (list (gnus-summary-article-number)))
10916 (when (or (not (get-buffer gnus-article-buffer))
10917 (not gnus-current-article)
10918 (not gnus-article-current)
10919 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10920 (error "No current article selected"))
10921 ;; Remove old bookmark, if one exists.
10922 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10923 ;; Set the new bookmark, which is on the form
10924 ;; (article-number . line-number-in-body).
10927 (with-current-buffer gnus-article-buffer
10931 (article-goto-body)
10934 gnus-newsgroup-bookmarks)
10935 (gnus-message 6 "A bookmark has been added to the current article."))
10937 (defun gnus-summary-remove-bookmark (article)
10938 "Remove the bookmark from the current article."
10939 (interactive (list (gnus-summary-article-number)))
10940 ;; Remove old bookmark, if one exists.
10941 (if (not (assq article gnus-newsgroup-bookmarks))
10942 (gnus-message 6 "No bookmark in current article.")
10943 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10944 (gnus-message 6 "Removed bookmark.")))
10946 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10947 (defun gnus-summary-mark-as-dormant (n)
10948 "Mark N articles forward as dormant.
10949 If N is negative, mark backward instead. The difference between N and
10950 the actual number of articles marked is returned."
10952 (gnus-summary-mark-forward n gnus-dormant-mark))
10954 (defun gnus-summary-set-process-mark (article)
10955 "Set the process mark on ARTICLE and update the summary line."
10956 (setq gnus-newsgroup-processable
10958 (delq article gnus-newsgroup-processable)))
10959 (when (gnus-summary-goto-subject article)
10960 (gnus-summary-show-thread)
10961 (gnus-summary-goto-subject article)
10962 (gnus-summary-update-secondary-mark article)))
10964 (defun gnus-summary-remove-process-mark (&rest articles)
10965 "Remove the process mark from ARTICLES and update the summary line."
10966 (dolist (article articles)
10967 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10968 (when (gnus-summary-goto-subject article)
10969 (gnus-summary-show-thread)
10970 (gnus-summary-goto-subject article)
10971 (gnus-summary-update-secondary-mark article)))
10974 (defun gnus-summary-set-saved-mark (article)
10975 "Set the process mark on ARTICLE and update the summary line."
10976 (push article gnus-newsgroup-saved)
10977 (when (gnus-summary-goto-subject article)
10978 (gnus-summary-update-secondary-mark article)))
10980 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10981 "Mark N articles as read forwards.
10982 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10983 The difference between N and the actual number of articles marked is
10985 If NO-EXPIRE, auto-expiry will be inhibited."
10987 (gnus-summary-show-thread)
10988 (let ((backward (< n 0))
10989 (gnus-summary-goto-unread
10990 (and gnus-summary-goto-unread
10991 (not (eq gnus-summary-goto-unread 'never))
10992 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10993 gnus-ticked-mark gnus-dormant-mark)))))
10995 (mark (or mark gnus-del-mark)))
10996 (while (and (> n 0)
10997 (gnus-summary-mark-article nil mark no-expire)
10998 (zerop (gnus-summary-next-subject
11000 (and gnus-summary-goto-unread
11001 (not (eq gnus-summary-goto-unread 'never)))
11005 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11006 (gnus-summary-recenter)
11007 (gnus-summary-position-point)
11008 (gnus-set-mode-line 'summary)
11011 (defun gnus-summary-mark-article-as-read (mark)
11012 "Mark the current article quickly as read with MARK."
11013 (let ((article (gnus-summary-article-number)))
11014 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11015 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11016 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11017 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11018 (push (cons article mark) gnus-newsgroup-reads)
11019 ;; Possibly remove from cache, if that is used.
11020 (when gnus-use-cache
11021 (gnus-cache-enter-remove-article article))
11022 ;; Allow the backend to change the mark.
11023 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11024 ;; Check for auto-expiry.
11025 (when (and gnus-newsgroup-auto-expire
11026 (memq mark gnus-auto-expirable-marks))
11027 (setq mark gnus-expirable-mark)
11028 ;; Let the backend know about the mark change.
11029 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11030 (push article gnus-newsgroup-expirable))
11031 ;; Set the mark in the buffer.
11032 (gnus-summary-update-mark mark 'unread)
11035 (defun gnus-summary-mark-article-as-unread (mark)
11036 "Mark the current article quickly as unread with MARK."
11037 (let* ((article (gnus-summary-article-number))
11038 (old-mark (gnus-summary-article-mark article)))
11039 ;; Allow the backend to change the mark.
11040 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11041 (if (eq mark old-mark)
11045 (gnus-error 1 "Can't mark negative article numbers")
11047 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11048 (setq gnus-newsgroup-spam-marked
11049 (delq article gnus-newsgroup-spam-marked))
11050 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11051 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11052 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11053 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11054 (cond ((= mark gnus-ticked-mark)
11055 (setq gnus-newsgroup-marked
11056 (gnus-add-to-sorted-list gnus-newsgroup-marked
11058 ((= mark gnus-spam-mark)
11059 (setq gnus-newsgroup-spam-marked
11060 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11062 ((= mark gnus-dormant-mark)
11063 (setq gnus-newsgroup-dormant
11064 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11067 (setq gnus-newsgroup-unreads
11068 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11070 (gnus-alist-pull article gnus-newsgroup-reads)
11072 ;; See whether the article is to be put in the cache.
11073 (and gnus-use-cache
11074 (vectorp (gnus-summary-article-header article))
11076 (gnus-cache-possibly-enter-article
11077 gnus-newsgroup-name article
11078 (= mark gnus-ticked-mark)
11079 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11082 (gnus-summary-update-mark mark 'unread)
11085 (defun gnus-summary-mark-article (&optional article mark no-expire)
11086 "Mark ARTICLE with MARK. MARK can be any character.
11087 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11088 `??' (dormant) and `?E' (expirable).
11089 If MARK is nil, then the default character `?r' is used.
11090 If ARTICLE is nil, then the article on the current line will be
11092 If NO-EXPIRE, auto-expiry will be inhibited."
11093 ;; The mark might be a string.
11094 (when (stringp mark)
11095 (setq mark (aref mark 0)))
11096 ;; If no mark is given, then we check auto-expiring.
11098 (setq mark gnus-del-mark))
11099 (when (and (not no-expire)
11100 gnus-newsgroup-auto-expire
11101 (memq mark gnus-auto-expirable-marks))
11102 (setq mark gnus-expirable-mark))
11103 (let ((article (or article (gnus-summary-article-number)))
11104 (old-mark (gnus-summary-article-mark article)))
11105 ;; Allow the backend to change the mark.
11106 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11107 (if (eq mark old-mark)
11110 (error "No article on current line"))
11111 (if (not (if (or (= mark gnus-unread-mark)
11112 (= mark gnus-ticked-mark)
11113 (= mark gnus-spam-mark)
11114 (= mark gnus-dormant-mark))
11115 (gnus-mark-article-as-unread article mark)
11116 (gnus-mark-article-as-read article mark)))
11118 ;; See whether the article is to be put in the cache.
11119 (and gnus-use-cache
11120 (not (= mark gnus-canceled-mark))
11121 (vectorp (gnus-summary-article-header article))
11123 (gnus-cache-possibly-enter-article
11124 gnus-newsgroup-name article
11125 (= mark gnus-ticked-mark)
11126 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11128 (when (gnus-summary-goto-subject article nil t)
11129 (let ((inhibit-read-only t))
11130 (gnus-summary-show-thread)
11132 (gnus-summary-update-mark mark 'unread)
11135 (defun gnus-summary-update-secondary-mark (article)
11136 "Update the secondary (read, process, cache) mark."
11137 (gnus-summary-update-mark
11138 (cond ((memq article gnus-newsgroup-processable)
11140 ((memq article gnus-newsgroup-cached)
11142 ((memq article gnus-newsgroup-replied)
11144 ((memq article gnus-newsgroup-forwarded)
11145 gnus-forwarded-mark)
11146 ((memq article gnus-newsgroup-saved)
11148 ((memq article gnus-newsgroup-unseen)
11152 (when (gnus-visual-p 'summary-highlight 'highlight)
11153 (gnus-summary-highlight-line)
11154 (gnus-run-hooks 'gnus-summary-update-hook))
11157 (defun gnus-summary-update-download-mark (article)
11158 "Update the download mark."
11159 (gnus-summary-update-mark
11160 (cond ((memq article gnus-newsgroup-undownloaded)
11161 gnus-undownloaded-mark)
11162 (gnus-newsgroup-agentized
11163 gnus-downloaded-mark)
11167 (gnus-summary-update-line t)
11170 (defun gnus-summary-update-mark (mark type)
11171 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11172 (inhibit-read-only t))
11173 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11175 (when (looking-at "\r")
11177 (when (<= (+ forward (point)) (point-max))
11178 ;; Go to the right position on the line.
11179 (goto-char (+ forward (point)))
11180 ;; Replace the old mark with the new mark.
11182 (mm-subst-char-in-string
11184 (buffer-substring (point) (1+ (point))))))
11185 (delete-region (point) (1+ (point)))
11186 (insert to-insert))
11187 ;; Optionally update the marks by some user rule.
11188 (when (eq type 'unread)
11189 (gnus-data-set-mark
11190 (gnus-data-find (gnus-summary-article-number)) mark)
11191 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11193 (defun gnus-mark-article-as-read (article &optional mark)
11194 "Enter ARTICLE in the pertinent lists and remove it from others."
11195 ;; Make the article expirable.
11196 (let ((mark (or mark gnus-del-mark)))
11197 (setq gnus-newsgroup-expirable
11198 (if (= mark gnus-expirable-mark)
11199 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11200 (delq article gnus-newsgroup-expirable)))
11201 ;; Remove from unread and marked lists.
11202 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11203 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11204 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11205 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11206 (push (cons article mark) gnus-newsgroup-reads)
11207 ;; Possibly remove from cache, if that is used.
11208 (when gnus-use-cache
11209 (gnus-cache-enter-remove-article article))
11212 (defun gnus-mark-article-as-unread (article &optional mark)
11213 "Enter ARTICLE in the pertinent lists and remove it from others."
11214 (let ((mark (or mark gnus-ticked-mark)))
11217 (gnus-error 1 "Can't mark negative article numbers")
11219 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11220 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11221 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11222 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11223 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11225 ;; Unsuppress duplicates?
11226 (when gnus-suppress-duplicates
11227 (gnus-dup-unsuppress-article article))
11229 (cond ((= mark gnus-ticked-mark)
11230 (setq gnus-newsgroup-marked
11231 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11232 ((= mark gnus-spam-mark)
11233 (setq gnus-newsgroup-spam-marked
11234 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11236 ((= mark gnus-dormant-mark)
11237 (setq gnus-newsgroup-dormant
11238 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11240 (setq gnus-newsgroup-unreads
11241 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11242 (gnus-alist-pull article gnus-newsgroup-reads)
11245 (defun gnus-summary-tick-article-forward (n)
11246 "Tick N articles forwards.
11247 If N is negative, tick backwards instead.
11248 The difference between N and the number of articles ticked is returned."
11250 (gnus-summary-mark-forward n gnus-ticked-mark))
11252 (defun gnus-summary-tick-article-backward (n)
11253 "Tick N articles backwards.
11254 The difference between N and the number of articles ticked is returned."
11256 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11258 (defun gnus-summary-tick-article (&optional article clear-mark)
11259 "Mark current article as unread.
11260 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11261 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11263 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11264 gnus-ticked-mark)))
11266 (defun gnus-summary-mark-as-read-forward (n)
11267 "Mark N articles as read forwards.
11268 If N is negative, mark backwards instead.
11269 The difference between N and the actual number of articles marked is
11272 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11274 (defun gnus-summary-mark-as-read-backward (n)
11275 "Mark the N articles as read backwards.
11276 The difference between N and the actual number of articles marked is
11279 (gnus-summary-mark-forward
11280 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11282 (defun gnus-summary-mark-as-read (&optional article mark)
11283 "Mark current article as read.
11284 ARTICLE specifies the article to be marked as read.
11285 MARK specifies a string to be inserted at the beginning of the line."
11286 (gnus-summary-mark-article article mark))
11288 (defun gnus-summary-clear-mark-forward (n)
11289 "Clear marks from N articles forward.
11290 If N is negative, clear backward instead.
11291 The difference between N and the number of marks cleared is returned."
11293 (gnus-summary-mark-forward n gnus-unread-mark))
11295 (defun gnus-summary-clear-mark-backward (n)
11296 "Clear marks from N articles backward.
11297 The difference between N and the number of marks cleared is returned."
11299 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11301 (defun gnus-summary-mark-unread-as-read ()
11302 "Intended to be used by `gnus-mark-article-hook'."
11303 (when (memq gnus-current-article gnus-newsgroup-unreads)
11304 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11306 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11307 "Intended to be used by `gnus-mark-article-hook'."
11308 (let ((mark (gnus-summary-article-mark)))
11309 (when (or (gnus-unread-mark-p mark)
11310 (gnus-read-mark-p mark))
11311 (gnus-summary-mark-article gnus-current-article
11312 (or new-mark gnus-read-mark)))))
11314 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11315 "Intended to be used by `gnus-mark-article-hook'."
11316 (let ((mark (gnus-summary-article-mark)))
11317 (when (or (gnus-unread-mark-p mark)
11318 (gnus-read-mark-p mark))
11319 (gnus-summary-mark-article (gnus-summary-article-number)
11320 (or new-mark gnus-read-mark)))))
11322 (defun gnus-summary-mark-unread-as-ticked ()
11323 "Intended to be used by `gnus-mark-article-hook'."
11324 (when (memq gnus-current-article gnus-newsgroup-unreads)
11325 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11327 (defun gnus-summary-mark-region-as-read (point mark all)
11328 "Mark all unread articles between point and mark as read.
11329 If given a prefix, mark all articles between point and mark as read,
11330 even ticked and dormant ones."
11331 (interactive "r\nP")
11335 (beginning-of-line)
11340 (memq (setq article (gnus-summary-article-number))
11341 gnus-newsgroup-unreads))
11342 (gnus-summary-mark-article article gnus-del-mark))
11344 (gnus-summary-find-next))))))
11346 (defun gnus-summary-mark-below (score mark)
11347 "Mark articles with score less than SCORE with MARK."
11348 (interactive "P\ncMark: ")
11349 (setq score (if score
11350 (prefix-numeric-value score)
11351 (or gnus-summary-default-score 0)))
11352 (with-current-buffer gnus-summary-buffer
11353 (goto-char (point-min))
11356 (and (< (gnus-summary-article-score) score)
11357 (gnus-summary-mark-article nil mark))
11358 (gnus-summary-find-next)))))
11360 (defun gnus-summary-kill-below (&optional score)
11361 "Mark articles with score below SCORE as read."
11363 (gnus-summary-mark-below score gnus-killed-mark))
11365 (defun gnus-summary-clear-above (&optional score)
11366 "Clear all marks from articles with score above SCORE."
11368 (gnus-summary-mark-above score gnus-unread-mark))
11370 (defun gnus-summary-tick-above (&optional score)
11371 "Tick all articles with score above SCORE."
11373 (gnus-summary-mark-above score gnus-ticked-mark))
11375 (defun gnus-summary-mark-above (score mark)
11376 "Mark articles with score over SCORE with MARK."
11377 (interactive "P\ncMark: ")
11378 (setq score (if score
11379 (prefix-numeric-value score)
11380 (or gnus-summary-default-score 0)))
11381 (with-current-buffer gnus-summary-buffer
11382 (goto-char (point-min))
11384 (when (> (gnus-summary-article-score) score)
11385 (gnus-summary-mark-article nil mark))
11387 (gnus-summary-find-next)))))
11389 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11390 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11391 (defun gnus-summary-limit-include-expunged (&optional no-error)
11392 "Display all the hidden articles that were expunged for low scores."
11394 (let ((inhibit-read-only t))
11395 (let ((scored gnus-newsgroup-scored)
11398 (unless (gnus-summary-article-header (caar scored))
11399 (and (setq h (gnus-number-to-header (caar scored)))
11400 (< (cdar scored) gnus-summary-expunge-below)
11402 (setq scored (cdr scored)))
11404 (when (not no-error)
11405 (error "No expunged articles hidden"))
11406 (goto-char (point-min))
11407 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11408 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11409 (dolist (x headers)
11410 (push (mail-header-number x) gnus-newsgroup-limit))
11411 (gnus-summary-prepare-unthreaded (nreverse headers))
11412 (goto-char (point-min))
11413 (gnus-summary-position-point)
11416 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11417 "Mark all unread articles in this newsgroup as read.
11418 If prefix argument ALL is non-nil, ticked and dormant articles will
11419 also be marked as read.
11420 If QUIETLY is non-nil, no questions will be asked.
11422 If TO-HERE is non-nil, it should be a point in the buffer. All
11423 articles before (after, if REVERSE is set) this point will be marked
11426 Note that this function will only catch up the unread article
11427 in the current summary buffer limitation.
11429 The number of articles marked as read is returned."
11434 (not gnus-interactive-catchup) ;Without confirmation?
11438 "Mark absolutely all articles as read? "
11439 "Mark all unread articles as read? ")))
11441 (not gnus-newsgroup-adaptive)
11442 (not gnus-newsgroup-auto-expire)
11443 (not gnus-suppress-duplicates)
11444 (or (not gnus-use-cache)
11445 (eq gnus-use-cache 'passive)))
11448 (setq gnus-newsgroup-marked nil
11449 gnus-newsgroup-spam-marked nil
11450 gnus-newsgroup-dormant nil))
11451 (setq gnus-newsgroup-unreads
11452 (gnus-sorted-nunion
11453 (gnus-sorted-intersection gnus-newsgroup-unreads
11454 gnus-newsgroup-downloadable)
11455 (gnus-sorted-difference gnus-newsgroup-unfetched
11456 gnus-newsgroup-cached))))
11457 ;; We actually mark all articles as canceled, which we
11458 ;; have to do when using auto-expiry or adaptive scoring.
11459 (gnus-summary-show-all-threads)
11460 (if (and to-here reverse)
11462 (goto-char to-here)
11463 (gnus-summary-mark-current-read-and-unread-as-read
11465 (while (gnus-summary-find-next (not all))
11466 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11467 (when (gnus-summary-first-subject (not all))
11469 (if to-here (< (point) to-here) t)
11470 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11471 (gnus-summary-find-next (not all))))))
11472 (gnus-set-mode-line 'summary))
11474 (gnus-summary-position-point)))
11476 (defun gnus-summary-catchup-to-here (&optional all)
11477 "Mark all unticked articles before the current one as read.
11478 If ALL is non-nil, also mark ticked and dormant articles as read."
11481 (gnus-save-hidden-threads
11482 (let ((beg (point)))
11483 ;; We check that there are unread articles.
11484 (when (or all (gnus-summary-find-prev))
11485 (gnus-summary-catchup all t beg)))))
11486 (gnus-summary-position-point))
11488 (defun gnus-summary-catchup-from-here (&optional all)
11489 "Mark all unticked articles after (and including) the current one as read.
11490 If ALL is non-nil, also mark ticked and dormant articles as read."
11493 (gnus-save-hidden-threads
11494 (let ((beg (point)))
11495 ;; We check that there are unread articles.
11496 (when (or all (gnus-summary-find-next))
11497 (gnus-summary-catchup all t beg nil t)))))
11498 (gnus-summary-position-point))
11500 (defun gnus-summary-catchup-all (&optional quietly)
11501 "Mark all articles in this newsgroup as read.
11502 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11503 instead, which marks only unread articles as read."
11505 (gnus-summary-catchup t quietly))
11507 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11508 "Mark all unread articles in this group as read, then exit.
11509 If prefix argument ALL is non-nil, all articles are marked as read.
11510 If QUIETLY is non-nil, no questions will be asked."
11512 (when (gnus-summary-catchup all quietly nil 'fast)
11513 ;; Select next newsgroup or exit.
11514 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11515 (eq gnus-auto-select-next 'quietly))
11516 (gnus-summary-next-group nil)
11517 (gnus-summary-exit))))
11519 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11520 "Mark all articles in this newsgroup as read, and then exit.
11521 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11522 instead, which marks only unread articles as read."
11524 (gnus-summary-catchup-and-exit t quietly))
11526 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11527 "Mark all articles in this group as read and select the next group.
11528 If given a prefix, mark all articles, unread as well as ticked, as
11532 (gnus-summary-catchup all))
11533 (gnus-summary-next-group))
11535 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11536 "Mark all articles in this group as read and select the previous group.
11537 If given a prefix, mark all articles, unread as well as ticked, as
11541 (gnus-summary-catchup all))
11542 (gnus-summary-next-group nil nil t))
11548 (defmacro gnus-with-article (article &rest forms)
11549 "Select ARTICLE and perform FORMS in the original article buffer.
11550 Then replace the article with the result."
11552 ;; We don't want the article to be marked as read.
11553 (let (gnus-mark-article-hook)
11554 (gnus-summary-select-article t t nil ,article))
11555 (set-buffer gnus-original-article-buffer)
11557 (if (not (gnus-check-backend-function
11558 'request-replace-article (car gnus-article-current)))
11559 (gnus-message 5 "Read-only group; not replacing")
11560 (unless (gnus-request-replace-article
11561 ,article (car gnus-article-current)
11562 (current-buffer) t)
11563 (error "Couldn't replace article")))
11564 ;; The cache and backlog have to be flushed somewhat.
11565 (when gnus-keep-backlog
11566 (gnus-backlog-remove-article
11567 (car gnus-article-current) (cdr gnus-article-current)))
11568 (when gnus-use-cache
11569 (gnus-cache-update-article
11570 (car gnus-article-current) (cdr gnus-article-current)))))
11572 (put 'gnus-with-article 'lisp-indent-function 1)
11573 (put 'gnus-with-article 'edebug-form-spec '(form body))
11575 ;; Thread-based commands.
11577 (defun gnus-summary-articles-in-thread (&optional article)
11578 "Return a list of all articles in the current thread.
11579 If ARTICLE is non-nil, return all articles in the thread that starts
11580 with that article."
11581 (let* ((article (or article (gnus-summary-article-number)))
11582 (data (gnus-data-find-list article))
11583 (top-level (gnus-data-level (car data)))
11585 (cond ((null gnus-thread-operation-ignore-subject)
11586 (gnus-simplify-subject-re
11587 (mail-header-subject (gnus-data-header (car data)))))
11588 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11589 (gnus-simplify-subject-fuzzy
11590 (mail-header-subject (gnus-data-header (car data)))))
11592 (end-point (save-excursion
11593 (goto-char (gnus-data-pos (car data)))
11594 (if (gnus-summary-go-to-next-thread)
11595 (point) (point-max))))
11598 (< (gnus-data-pos (car data)) end-point))
11599 (when (or (not top-subject)
11600 (string= top-subject
11601 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11602 (gnus-simplify-subject-fuzzy
11603 (mail-header-subject
11604 (gnus-data-header (car data))))
11605 (gnus-simplify-subject-re
11606 (mail-header-subject
11607 (gnus-data-header (car data)))))))
11608 (push (gnus-data-number (car data)) articles))
11609 (unless (and (setq data (cdr data))
11610 (> (gnus-data-level (car data)) top-level))
11612 ;; Return the list of articles.
11613 (nreverse articles)))
11615 (defun gnus-summary-rethread-current ()
11616 "Rethread the thread the current article is part of."
11618 (let* ((gnus-show-threads t)
11619 (article (gnus-summary-article-number))
11620 (id (mail-header-id (gnus-summary-article-header)))
11621 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11623 (error "No article on the current line"))
11624 (gnus-rebuild-thread id)
11625 (gnus-summary-goto-subject article)))
11627 (defun gnus-summary-reparent-thread ()
11628 "Make the current article child of the marked (or previous) article.
11630 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11631 is non-nil or the Subject: of both articles are the same."
11633 (unless (not (gnus-group-read-only-p))
11634 (error "The current newsgroup does not support article editing"))
11635 (unless (<= (length gnus-newsgroup-processable) 1)
11636 (error "No more than one article may be marked"))
11637 (let ((child (gnus-summary-article-number))
11638 ;; First grab the marked article, otherwise one line up.
11639 (parent (if (not (null gnus-newsgroup-processable))
11640 (car gnus-newsgroup-processable)
11642 (if (eq (forward-line -1) 0)
11643 (gnus-summary-article-number)
11644 (error "Beginning of summary buffer"))))))
11645 (gnus-summary-reparent-children parent (list child))))
11647 (defun gnus-summary-reparent-children (parent children)
11648 "Make PARENT the parent of CHILDREN.
11649 When called interactively, PARENT is the current article and CHILDREN
11650 are the process-marked articles."
11652 (list (gnus-summary-article-number)
11653 (gnus-summary-work-articles nil)))
11654 (dolist (child children)
11655 (save-window-excursion
11656 (let ((gnus-article-buffer " *reparent*"))
11657 (unless (not (eq parent child))
11658 (error "An article may not be self-referential"))
11659 (let ((message-id (mail-header-id
11660 (gnus-summary-article-header parent))))
11661 (unless (and message-id (not (equal message-id "")))
11662 (error "No message-id in desired parent"))
11663 (gnus-with-article child
11665 (goto-char (point-min))
11666 (message-narrow-to-head)
11667 (if (re-search-forward "^References: " nil t)
11669 (re-search-forward "^[^ \t]" nil t)
11672 (insert " " message-id))
11673 (insert "References: " message-id "\n"))))
11674 (set-buffer gnus-summary-buffer)
11675 (gnus-summary-unmark-all-processable)
11676 (gnus-summary-update-article child)
11677 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11678 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11679 (gnus-summary-rethread-current)
11680 (gnus-message 3 "Article %d is now the child of article %d"
11683 (defun gnus-summary-toggle-threads (&optional arg)
11684 "Toggle showing conversation threads.
11685 If ARG is positive number, turn showing conversation threads on."
11687 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11688 (setq gnus-show-threads
11689 (if (null arg) (not gnus-show-threads)
11690 (> (prefix-numeric-value arg) 0)))
11691 (gnus-summary-prepare)
11692 (gnus-summary-goto-subject current)
11693 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11694 (gnus-summary-position-point)))
11697 (if (fboundp 'remove-overlays)
11698 (defalias 'gnus-remove-overlays 'remove-overlays)
11699 (defun gnus-remove-overlays (beg end name val)
11700 "Clear BEG and END of overlays whose property NAME has value VAL.
11701 For compatibility with XEmacs."
11702 (dolist (ov (gnus-overlays-in beg end))
11703 (when (eq (gnus-overlay-get ov name) val)
11704 (gnus-delete-overlay ov))))))
11706 (defun gnus-summary-show-all-threads ()
11707 "Show all threads."
11709 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11710 (gnus-summary-position-point))
11712 (defsubst gnus-summary--inv (p)
11713 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11715 (defun gnus-summary-show-thread ()
11716 "Show thread subtrees.
11717 Returns nil if no thread was there to be shown."
11719 (let* ((orig (point))
11720 (end (point-at-eol))
11721 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11722 ;; Leave point at bol
11723 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11725 (if (fboundp 'next-single-char-property-change)
11726 ;; Note: XEmacs version of n-s-c-p-c may return nil
11727 (or (next-single-char-property-change end 'invisible)
11732 (eq (get-char-property (point) 'invisible)
11736 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11738 (gnus-summary-position-point)
11741 (defun gnus-summary-maybe-hide-threads ()
11742 "If requested, hide the threads that should be hidden."
11743 (when (and gnus-show-threads
11744 gnus-thread-hide-subtree)
11745 (gnus-summary-hide-all-threads
11746 (if (or (consp gnus-thread-hide-subtree)
11747 (functionp gnus-thread-hide-subtree))
11748 (gnus-make-predicate gnus-thread-hide-subtree)
11751 ;;; Hiding predicates.
11753 (defun gnus-article-unread-p (header)
11754 (memq (mail-header-number header) gnus-newsgroup-unreads))
11756 (defun gnus-article-unseen-p (header)
11757 (memq (mail-header-number header) gnus-newsgroup-unseen))
11759 (defun gnus-map-articles (predicate articles)
11760 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11761 (apply 'gnus-or (mapcar predicate
11762 (mapcar (lambda (number)
11763 (gnus-summary-article-header number))
11766 (defun gnus-summary-hide-all-threads (&optional predicate)
11767 "Hide all thread subtrees.
11768 If PREDICATE is supplied, threads that satisfy this predicate
11769 will not be hidden."
11772 (goto-char (point-min))
11777 (when (zerop (mod count 1000))
11778 (message "Hiding all threads... %d" count))
11779 (when (or (not predicate)
11781 predicate (gnus-summary-article-children)))
11782 (gnus-summary-hide-thread))
11783 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11784 (gnus-summary-position-point))
11786 (defun gnus-summary-hide-thread ()
11787 "Hide thread subtrees.
11788 If PREDICATE is supplied, threads that satisfy this predicate
11789 will not be hidden.
11790 Returns nil if no threads were there to be hidden."
11792 (beginning-of-line)
11793 (let ((start (point))
11794 (starteol (line-end-position))
11795 (article (gnus-summary-article-number)))
11796 ;; Go forward until either the buffer ends or the subthread ends.
11797 (when (and (not (eobp))
11798 (or (zerop (gnus-summary-next-thread 1 t))
11799 (goto-char (point-max))))
11800 (if (and (> (point) start)
11801 ;; FIXME: this should actually search for a non-invisible \n.
11802 (search-backward "\n" start t))
11804 (when (> (point) starteol)
11805 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11806 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11807 (gnus-overlay-put ol 'invisible 'gnus-sum)
11808 (gnus-overlay-put ol 'evaporate t)))
11809 (gnus-summary-goto-subject article)
11810 (when (> start (point))
11811 (message "Hiding the thread moved us backwards, aborting!")
11812 (goto-char (point-max))))
11816 (defun gnus-summary-go-to-next-thread (&optional previous)
11817 "Go to the same level (or less) next thread.
11818 If PREVIOUS is non-nil, go to previous thread instead.
11819 Return the article number moved to, or nil if moving was impossible."
11820 (let ((level (gnus-summary-thread-level))
11821 (way (if previous -1 1))
11824 (while (and (not (eobp))
11825 (< level (gnus-summary-thread-level)))
11826 (forward-line way))
11833 (gnus-summary-article-number)
11834 (goto-char beg)))))
11836 (defun gnus-summary-next-thread (n &optional silent)
11837 "Go to the same level next N'th thread.
11838 If N is negative, search backward instead.
11839 Returns the difference between N and the number of skips actually
11842 If SILENT, don't output messages."
11844 (let ((backward (< n 0))
11846 (while (and (> n 0)
11847 (gnus-summary-go-to-next-thread backward))
11850 (gnus-summary-position-point))
11851 (when (and (not silent) (/= 0 n))
11852 (gnus-message 7 "No more threads"))
11855 (defun gnus-summary-prev-thread (n)
11856 "Go to the same level previous N'th thread.
11857 Returns the difference between N and the number of skips actually
11860 (gnus-summary-next-thread (- n)))
11862 (defun gnus-summary-go-down-thread ()
11863 "Go down one level in the current thread."
11864 (let ((children (gnus-summary-article-children)))
11866 (gnus-summary-goto-subject (car children)))))
11868 (defun gnus-summary-go-up-thread ()
11869 "Go up one level in the current thread."
11870 (let ((parent (gnus-summary-article-parent)))
11872 (gnus-summary-goto-subject parent))))
11874 (defun gnus-summary-down-thread (n)
11875 "Go down thread N steps.
11876 If N is negative, go up instead.
11877 Returns the difference between N and how many steps down that were
11882 (while (and (> n 0)
11883 (if up (gnus-summary-go-up-thread)
11884 (gnus-summary-go-down-thread)))
11886 (gnus-summary-position-point)
11888 (gnus-message 7 "Can't go further"))
11891 (defun gnus-summary-up-thread (n)
11892 "Go up thread N steps.
11893 If N is negative, go down instead.
11894 Returns the difference between N and how many steps down that were
11897 (gnus-summary-down-thread (- n)))
11899 (defun gnus-summary-top-thread ()
11900 "Go to the top of the thread."
11902 (while (gnus-summary-go-up-thread))
11903 (gnus-summary-article-number))
11905 (defun gnus-summary-expire-thread ()
11906 "Mark articles under current thread as expired."
11908 (gnus-summary-kill-thread 0))
11910 (defun gnus-summary-kill-thread (&optional unmark)
11911 "Mark articles under current thread as read.
11912 If the prefix argument is positive, remove any kinds of marks.
11913 If the prefix argument is zero, mark thread as expired.
11914 If the prefix argument is negative, tick articles instead."
11917 (setq unmark (prefix-numeric-value unmark)))
11918 (let ((articles (gnus-summary-articles-in-thread))
11919 (hide (or (null unmark) (= unmark 0))))
11921 ;; Expand the thread.
11922 (gnus-summary-show-thread)
11923 ;; Mark all the articles.
11925 (gnus-summary-goto-subject (car articles))
11926 (cond ((null unmark)
11927 (gnus-summary-mark-article-as-read gnus-killed-mark))
11929 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11931 (gnus-summary-mark-article nil gnus-expirable-mark))
11933 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11934 (setq articles (cdr articles))))
11935 ;; Hide killed subtrees when hide is true.
11937 gnus-thread-hide-killed
11938 (gnus-summary-hide-thread))
11939 ;; If hide is t, go to next unread subject.
11941 ;; Go to next unread subject.
11942 (gnus-summary-next-subject 1 t)))
11943 (gnus-set-mode-line 'summary))
11945 ;; Summary sorting commands
11947 (defun gnus-summary-sort-by-number (&optional reverse)
11948 "Sort the summary buffer by article number.
11949 Argument REVERSE means reverse order."
11951 (gnus-summary-sort 'number reverse))
11953 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11954 "Sort the summary buffer by most recent article number.
11955 Argument REVERSE means reverse order."
11957 (gnus-summary-sort 'most-recent-number reverse))
11959 (defun gnus-summary-sort-by-random (&optional reverse)
11960 "Randomize the order in the summary buffer.
11961 Argument REVERSE means to randomize in reverse order."
11963 (gnus-summary-sort 'random reverse))
11965 (defun gnus-summary-sort-by-author (&optional reverse)
11966 "Sort the summary buffer by author name alphabetically.
11967 If `case-fold-search' is non-nil, case of letters is ignored.
11968 Argument REVERSE means reverse order."
11970 (gnus-summary-sort 'author reverse))
11972 (defun gnus-summary-sort-by-recipient (&optional reverse)
11973 "Sort the summary buffer by recipient name alphabetically.
11974 If `case-fold-search' is non-nil, case of letters is ignored.
11975 Argument REVERSE means reverse order."
11977 (gnus-summary-sort 'recipient reverse))
11979 (defun gnus-summary-sort-by-subject (&optional reverse)
11980 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11981 If `case-fold-search' is non-nil, case of letters is ignored.
11982 Argument REVERSE means reverse order."
11984 (gnus-summary-sort 'subject reverse))
11986 (defun gnus-summary-sort-by-date (&optional reverse)
11987 "Sort the summary buffer by date.
11988 Argument REVERSE means reverse order."
11990 (gnus-summary-sort 'date reverse))
11992 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11993 "Sort the summary buffer by most recent date.
11994 Argument REVERSE means reverse order."
11996 (gnus-summary-sort 'most-recent-date reverse))
11998 (defun gnus-summary-sort-by-score (&optional reverse)
11999 "Sort the summary buffer by score.
12000 Argument REVERSE means reverse order."
12002 (gnus-summary-sort 'score reverse))
12004 (defun gnus-summary-sort-by-lines (&optional reverse)
12005 "Sort the summary buffer by the number of lines.
12006 Argument REVERSE means reverse order."
12008 (gnus-summary-sort 'lines reverse))
12010 (defun gnus-summary-sort-by-chars (&optional reverse)
12011 "Sort the summary buffer by article length.
12012 Argument REVERSE means reverse order."
12014 (gnus-summary-sort 'chars reverse))
12016 (defun gnus-summary-sort-by-original (&optional reverse)
12017 "Sort the summary buffer using the default sorting method.
12018 Argument REVERSE means reverse order."
12020 (let* ((inhibit-read-only t)
12021 (gnus-summary-prepare-hook nil))
12022 ;; We do the sorting by regenerating the threads.
12023 (gnus-summary-prepare)
12024 ;; Hide subthreads if needed.
12025 (gnus-summary-maybe-hide-threads)))
12027 (defun gnus-summary-sort (predicate reverse)
12028 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12029 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12030 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12031 (gnus-thread-sort-functions
12036 (gnus-sort-gathered-threads-function
12037 gnus-thread-sort-functions)
12038 (gnus-article-sort-functions
12042 (,article t2 t1))))
12043 (inhibit-read-only t)
12044 (gnus-summary-prepare-hook nil))
12045 ;; We do the sorting by regenerating the threads.
12046 (gnus-summary-prepare)
12047 ;; Hide subthreads if needed.
12048 (gnus-summary-maybe-hide-threads)))
12050 ;; Summary saving commands.
12052 (defun gnus-summary-save-article (&optional n not-saved)
12053 "Save the current article using the default saver function.
12054 If N is a positive number, save the N next articles.
12055 If N is a negative number, save the N previous articles.
12056 If N is nil and any articles have been marked with the process mark,
12057 save those articles instead.
12058 The variable `gnus-default-article-saver' specifies the saver function.
12060 If the optional second argument NOT-SAVED is non-nil, articles saved
12061 will not be marked as saved."
12063 (require 'gnus-art)
12064 (let* ((articles (gnus-summary-work-articles n))
12065 (save-buffer (save-excursion
12066 (nnheader-set-temp-buffer " *Gnus Save*")))
12067 (num (length articles))
12068 ;; Whether to save decoded articles or raw articles.
12069 (decode (when gnus-article-save-coding-system
12070 (get gnus-default-article-saver :decode)))
12071 ;; When saving many articles in a single file, use the other
12072 ;; function to save articles other than the first one.
12073 (saver2 (get gnus-default-article-saver :function))
12074 (gnus-prompt-before-saving (if saver2
12076 gnus-prompt-before-saving))
12077 (gnus-default-article-saver gnus-default-article-saver)
12079 (dolist (article articles)
12080 (setq header (gnus-summary-article-header article))
12081 (if (not (vectorp header))
12082 ;; This is a pseudo-article.
12083 (if (assq 'name header)
12084 (gnus-copy-file (cdr (assq 'name header)))
12085 (gnus-message 1 "Article %d is unsavable" article))
12086 ;; This is a real article.
12087 (save-window-excursion
12088 (gnus-summary-select-article decode decode nil article)
12089 (gnus-summary-goto-subject article))
12090 (with-current-buffer save-buffer
12092 (insert-buffer-substring (if decode
12093 gnus-article-buffer
12094 gnus-original-article-buffer)))
12095 (setq file (gnus-article-save save-buffer file num))
12096 (gnus-summary-remove-process-mark article)
12098 (gnus-summary-set-saved-mark article)))
12100 (setq gnus-default-article-saver saver2
12102 (gnus-kill-buffer save-buffer)
12103 (gnus-summary-position-point)
12104 (gnus-set-mode-line 'summary)
12107 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12109 (defun gnus-summary-pipe-output (&optional n sym)
12110 "Pipe the current article to a subprocess.
12111 If N is a positive number, pipe the N next articles.
12112 If N is a negative number, pipe the N previous articles.
12113 If N is nil and any articles have been marked with the process mark,
12114 pipe those articles instead.
12115 The default command to which articles are piped is specified by the
12116 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12117 will be prompted for the command.
12119 The properties `:decode' and `:headers' that are put to the function
12120 symbol `gnus-summary-save-in-pipe' control whether this function
12121 decodes articles and what headers to keep (see the doc string for the
12122 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12123 is neither omitted nor the symbol `r', force including all headers
12124 regardless of the `:headers' property. If it is the symbol `r',
12125 articles that are not decoded and include all headers will be piped
12126 no matter what the properties `:decode' and `:headers' are."
12127 (interactive (gnus-interactive "P\ny"))
12128 (require 'gnus-art)
12129 (let* ((articles (gnus-summary-work-articles n))
12130 (result-buffer "*Shell Command Output*")
12131 (all-headers (not (memq sym '(nil r))))
12132 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12134 (headers (get 'gnus-summary-save-in-pipe :headers))
12136 (unless (numberp (car articles))
12137 (error "No article to pipe"))
12138 (setq command (gnus-read-shell-command
12139 (concat "Shell command on "
12141 (format "these %d articles" (length articles))
12144 gnus-summary-pipe-output-default-command))
12145 (when (string-equal command "")
12146 (error "A command is required"))
12148 (put 'gnus-summary-save-in-pipe :headers nil))
12151 (gnus-summary-goto-subject (pop articles))
12152 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12153 (when (and (get-buffer result-buffer)
12154 (not (zerop (buffer-size (get-buffer result-buffer)))))
12155 (setq result (concat result (with-current-buffer result-buffer
12156 (buffer-string))))))
12157 (put 'gnus-summary-save-in-pipe :headers headers))
12158 (unless (zerop (length result))
12159 (if (with-current-buffer (get-buffer-create result-buffer)
12163 (and (= (count-lines (point-min) (point)) 1)
12166 (<= (current-column)
12167 (window-width (minibuffer-window)))))
12168 (goto-char (point-min))))
12169 (message "%s" (substring result 0 -1))
12171 (gnus-configure-windows 'pipe)))))
12173 (defun gnus-summary-save-article-mail (&optional arg)
12174 "Append the current article to a Unix mail box file.
12175 If N is a positive number, save the N next articles.
12176 If N is a negative number, save the N previous articles.
12177 If N is nil and any articles have been marked with the process mark,
12178 save those articles instead."
12180 (require 'gnus-art)
12181 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12182 (gnus-summary-save-article arg)))
12184 (defun gnus-summary-save-article-rmail (&optional arg)
12185 "Append the current article to an rmail file.
12186 If N is a positive number, save the N next articles.
12187 If N is a negative number, save the N previous articles.
12188 If N is nil and any articles have been marked with the process mark,
12189 save those articles instead."
12191 (require 'gnus-art)
12192 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12193 (gnus-summary-save-article arg)))
12195 (defun gnus-summary-save-article-file (&optional arg)
12196 "Append the current article to a file.
12197 If N is a positive number, save the N next articles.
12198 If N is a negative number, save the N previous articles.
12199 If N is nil and any articles have been marked with the process mark,
12200 save those articles instead."
12202 (require 'gnus-art)
12203 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12204 (gnus-summary-save-article arg)))
12206 (defun gnus-summary-write-article-file (&optional arg)
12207 "Write the current article to a file, deleting the previous file.
12208 If N is a positive number, save the N next articles.
12209 If N is a negative number, save the N previous articles.
12210 If N is nil and any articles have been marked with the process mark,
12211 save those articles instead."
12213 (require 'gnus-art)
12214 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12215 (gnus-summary-save-article arg)))
12217 (defun gnus-summary-save-article-body-file (&optional arg)
12218 "Append the current article body to a file.
12219 If N is a positive number, save the N next articles.
12220 If N is a negative number, save the N previous articles.
12221 If N is nil and any articles have been marked with the process mark,
12222 save those articles instead."
12224 (require 'gnus-art)
12225 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12226 (gnus-summary-save-article arg)))
12228 (defun gnus-summary-write-article-body-file (&optional arg)
12229 "Write the current article body to a file, deleting the previous file.
12230 If N is a positive number, save the N next articles.
12231 If N is a negative number, save the N previous articles.
12232 If N is nil and any articles have been marked with the process mark,
12233 save those articles instead."
12235 (require 'gnus-art)
12236 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12237 (gnus-summary-save-article arg)))
12239 (defun gnus-summary-muttprint (&optional arg)
12240 "Print the current article using Muttprint.
12241 If N is a positive number, save the N next articles.
12242 If N is a negative number, save the N previous articles.
12243 If N is nil and any articles have been marked with the process mark,
12244 save those articles instead."
12246 (require 'gnus-art)
12247 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12248 (gnus-summary-save-article arg t)))
12250 (defun gnus-summary-pipe-message (program)
12251 "Pipe the current article through PROGRAM."
12252 (interactive "sProgram: ")
12253 (gnus-summary-select-article)
12254 (let ((mail-header-separator ""))
12255 (gnus-eval-in-buffer-window gnus-article-buffer
12258 (let ((start (window-start))
12259 (inhibit-read-only t))
12260 (message-pipe-buffer-body program)
12261 (set-window-start (get-buffer-window (current-buffer)) start))))))
12263 (defun gnus-get-split-value (methods)
12264 "Return a value based on the split METHODS."
12265 (let (split-name method result match)
12267 (with-current-buffer gnus-original-article-buffer
12269 (nnheader-narrow-to-headers)
12270 (while (and methods (not split-name))
12271 (goto-char (point-min))
12272 (setq method (pop methods))
12273 (setq match (car method))
12276 ;; Regular expression.
12278 (re-search-forward match nil t)))
12283 (setq result (funcall match gnus-newsgroup-name))))
12288 (setq result (eval match)))))
12289 (setq split-name (cdr method))
12290 (cond ((stringp result)
12291 (push (expand-file-name
12292 result gnus-article-save-directory)
12295 (setq split-name (append result split-name)))))))))
12296 (nreverse split-name)))
12298 (defun gnus-valid-move-group-p (group)
12299 (and (symbolp group)
12301 (symbol-name group)
12302 (symbol-value group)
12303 (gnus-get-function (gnus-find-method-for-group
12304 (symbol-name group)) 'request-accept-article t)))
12306 (defun gnus-read-move-group-name (prompt default articles prefix)
12307 "Read a group name."
12308 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12309 (minibuffer-confirm-incomplete nil) ; XEmacs
12313 (if (> (length articles) 1)
12314 (format "these %d articles" (length articles))
12319 (gnus-group-completing-read
12321 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12322 nil prefix nil default))
12323 ((= 1 (length split-name))
12324 (gnus-group-completing-read
12326 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12327 nil prefix 'gnus-group-history (car split-name)))
12329 (gnus-completing-read
12330 prom (nreverse split-name) nil nil 'gnus-group-history))))
12331 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12334 (if (or (string= to-newsgroup "")
12335 (string= to-newsgroup prefix))
12336 (setq to-newsgroup default))
12337 (unless to-newsgroup
12338 (error "No group name entered"))
12339 (setq encoded (mm-encode-coding-string
12341 (gnus-group-name-charset to-method to-newsgroup)))
12342 (or (gnus-active encoded)
12343 (gnus-activate-group encoded nil nil to-method)
12344 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12346 (or (and (gnus-request-create-group encoded to-method)
12347 (gnus-activate-group encoded nil nil to-method)
12348 (gnus-subscribe-group encoded))
12349 (error "Couldn't create group %s" to-newsgroup)))
12350 (error "No such group: %s" to-newsgroup))
12353 (defvar gnus-summary-save-parts-counter)
12354 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12356 (defun gnus-summary-save-parts (type dir n &optional reverse)
12357 "Save parts matching TYPE to DIR.
12358 If REVERSE, save parts that do not match TYPE."
12360 (list (read-string "Save parts of type: "
12361 (or (car gnus-summary-save-parts-type-history)
12362 gnus-summary-save-parts-default-mime)
12363 'gnus-summary-save-parts-type-history)
12364 (setq gnus-summary-save-parts-last-directory
12365 (read-directory-name "Save to directory: "
12366 gnus-summary-save-parts-last-directory
12368 current-prefix-arg))
12369 (gnus-summary-iterate n
12370 (let ((gnus-display-mime-function nil)
12371 gnus-article-prepare-hook
12372 gnus-article-decode-hook
12373 gnus-display-mime-function
12375 (gnus-inhibit-treatment t))
12376 (gnus-summary-select-article))
12377 (with-current-buffer gnus-article-buffer
12378 (let ((handles (or gnus-article-mime-handles
12379 (mm-dissect-buffer nil gnus-article-loose-mime)
12380 (and gnus-article-emulate-mime
12382 (gnus-summary-save-parts-counter 1))
12384 (gnus-summary-save-parts-1 type dir handles reverse)
12385 (unless gnus-article-mime-handles ;; Don't destroy this case.
12386 (mm-destroy-parts handles)))))))
12388 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12389 (if (stringp (car handle))
12390 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12393 (not (string-match type (mm-handle-media-type handle)))
12394 (string-match type (mm-handle-media-type handle)))
12395 (let ((file (expand-file-name
12397 mm-file-name-rewrite-functions
12398 (file-name-nondirectory
12400 (mm-handle-filename handle)
12401 (format "%s.%d.%d" gnus-newsgroup-name
12402 (cdr gnus-article-current)
12403 gnus-summary-save-parts-counter))))
12405 (incf gnus-summary-save-parts-counter)
12406 (unless (file-exists-p file)
12407 (mm-save-part-to-file handle file))))))
12409 ;; Summary extract commands
12411 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12412 (let ((inhibit-read-only t)
12413 (article (gnus-summary-article-number))
12415 (unless (gnus-summary-goto-subject article)
12416 (error "No such article: %d" article))
12417 (gnus-summary-position-point)
12418 ;; If all commands are to be bunched up on one line, we collect
12420 (unless gnus-view-pseudos-separately
12421 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12424 (setq action (cdr (assq 'action (car ps))))
12425 (setq files (list (cdr (assq 'name (car ps)))))
12426 (while (and ps (cdr ps)
12427 (string= (or action "1")
12428 (or (cdr (assq 'action (cadr ps))) "2")))
12429 (push (cdr (assq 'name (cadr ps))) files)
12430 (setcdr ps (cddr ps)))
12432 (when (not (string-match "%s" action))
12435 (when (assq 'execute (car ps))
12436 (setcdr (assq 'execute (car ps))
12437 (funcall (if (string-match "%s" action)
12444 (shell-quote-argument f)))
12446 (setq ps (cdr ps)))))
12447 (if (and gnus-view-pseudos (not not-view))
12449 (when (assq 'execute (car pslist))
12450 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12451 (eq gnus-view-pseudos 'not-confirm)))
12452 (setq pslist (cdr pslist)))
12455 (setq after-article (or (cdr (assq 'article (car pslist)))
12456 (gnus-summary-article-number)))
12457 (gnus-summary-goto-subject after-article)
12460 (insert " " (file-name-nondirectory
12461 (cdr (assq 'name (car pslist))))
12462 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12464 (forward-line -1) ; back to `b'
12465 (gnus-add-text-properties
12466 b (1- e) (list 'gnus-number gnus-reffed-article-number
12467 gnus-mouse-face-prop gnus-mouse-face))
12469 after-article gnus-reffed-article-number
12470 gnus-unread-mark b (car pslist) 0 (- e b))
12471 (setq gnus-newsgroup-unreads
12472 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12473 gnus-reffed-article-number))
12474 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12475 (setq pslist (cdr pslist)))))))
12477 (defun gnus-pseudos< (p1 p2)
12478 (let ((c1 (cdr (assq 'action p1)))
12479 (c2 (cdr (assq 'action p2))))
12480 (and c1 c2 (string< c1 c2))))
12482 (defun gnus-request-pseudo-article (props)
12483 (cond ((assq 'execute props)
12484 (gnus-execute-command (cdr (assq 'execute props)))))
12485 (let ((gnus-current-article (gnus-summary-article-number)))
12486 (gnus-run-hooks 'gnus-mark-article-hook)))
12488 (defun gnus-execute-command (command &optional automatic)
12490 (gnus-article-setup-buffer)
12491 (set-buffer gnus-article-buffer)
12492 (setq buffer-read-only nil)
12493 (let ((command (if automatic command
12494 (read-string "Command: " (cons command 0)))))
12496 (insert "$ " command "\n\n")
12497 (if gnus-view-pseudo-asynchronously
12498 (start-process "gnus-execute" (current-buffer) shell-file-name
12499 shell-command-switch command)
12500 (call-process shell-file-name nil t nil
12501 shell-command-switch command)))))
12503 ;; Summary kill commands.
12505 (defun gnus-summary-edit-global-kill (article)
12506 "Edit the \"global\" kill file."
12507 (interactive (list (gnus-summary-article-number)))
12508 (gnus-group-edit-global-kill article))
12510 (defun gnus-summary-edit-local-kill ()
12511 "Edit a local kill file applied to the current newsgroup."
12513 (setq gnus-current-headers (gnus-summary-article-header))
12514 (gnus-group-edit-local-kill
12515 (gnus-summary-article-number) gnus-newsgroup-name))
12517 ;;; Header reading.
12519 (defun gnus-read-header (id &optional header)
12520 "Read the headers of article ID and enter them into the Gnus system."
12521 (let ((group gnus-newsgroup-name)
12522 (gnus-override-method
12524 gnus-override-method
12525 (and (gnus-news-group-p gnus-newsgroup-name)
12526 (car (gnus-refer-article-methods)))))
12528 ;; First we check to see whether the header in question is already
12531 ;; This is a Message-ID.
12532 (setq header (or header (gnus-id-to-header id)))
12533 ;; This is an article number.
12534 (setq header (or header (gnus-summary-article-header id))))
12536 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12537 ;; We have found the header.
12539 ;; We have to really fetch the header to this article.
12540 (with-current-buffer nntp-server-buffer
12541 (when (setq where (gnus-request-head id group))
12542 (nnheader-fold-continuation-lines)
12543 (goto-char (point-max))
12545 (goto-char (point-min))
12549 ((cdr where) (cdr where))
12550 (header (mail-header-number header))
12551 (t gnus-reffed-article-number))
12553 (insert " Article retrieved.\n"))
12554 (if (or (not where)
12555 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12556 () ; Malformed head.
12557 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12558 (when (and (bound-and-true-p gnus-registry-enabled)
12559 (not (gnus-ephemeral-group-p (car where))))
12560 (gnus-registry-handle-action
12561 (mail-header-id header) nil
12562 (gnus-group-prefixed-name
12564 (or gnus-override-method (gnus-find-method-for-group group)))
12565 (mail-header-subject header)
12566 (mail-header-from header)))
12567 (when (and (stringp id)
12569 (not (string= (gnus-group-real-name group)
12571 (not (gnus-server-equal gnus-override-method
12572 (gnus-group-method group)))))
12573 ;; If we fetched by Message-ID and the article came from
12574 ;; a different group (or server), we fudge some bogus
12575 ;; article numbers for this article.
12576 (mail-header-set-number header gnus-reffed-article-number))
12577 (with-current-buffer gnus-summary-buffer
12578 (decf gnus-reffed-article-number)
12579 (gnus-remove-header (mail-header-number header))
12580 (push header gnus-newsgroup-headers)
12581 (setq gnus-current-headers header)
12582 (push (mail-header-number header) gnus-newsgroup-limit)))
12585 (defun gnus-remove-header (number)
12586 "Remove header NUMBER from `gnus-newsgroup-headers'."
12587 (if (and gnus-newsgroup-headers
12588 (= number (mail-header-number (car gnus-newsgroup-headers))))
12589 (pop gnus-newsgroup-headers)
12590 (let ((headers gnus-newsgroup-headers))
12591 (while (and (cdr headers)
12592 (not (= number (mail-header-number (cadr headers)))))
12594 (when (cdr headers)
12595 (setcdr headers (cddr headers))))))
12598 ;;; summary highlights
12601 (defun gnus-highlight-selected-summary ()
12602 "Highlight selected article in summary buffer."
12603 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12604 (when gnus-summary-selected-face
12606 (let* ((beg (point-at-bol))
12607 (end (point-at-eol))
12608 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12609 (from (if (get-text-property beg gnus-mouse-face-prop)
12611 (or (next-single-property-change
12612 beg gnus-mouse-face-prop nil end)
12617 (or (next-single-property-change
12618 from gnus-mouse-face-prop nil end)
12620 ;; If no mouse-face prop on line we will have to = from = end,
12621 ;; so we highlight the entire line instead.
12622 (when (= (+ to 2) from)
12625 (if gnus-newsgroup-selected-overlay
12626 ;; Move old overlay.
12628 gnus-newsgroup-selected-overlay from to (current-buffer))
12629 ;; Create new overlay.
12631 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12632 'face gnus-summary-selected-face))))))
12634 (defvar gnus-summary-highlight-line-cached nil)
12635 (defvar gnus-summary-highlight-line-trigger nil)
12637 (defun gnus-summary-highlight-line-0 ()
12638 (if (and (eq gnus-summary-highlight-line-trigger
12639 gnus-summary-highlight)
12640 gnus-summary-highlight-line-cached)
12641 gnus-summary-highlight-line-cached
12642 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12643 gnus-summary-highlight-line-cached
12644 (let* ((cond (list 'cond))
12646 (list gnus-summary-highlight))
12648 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12652 (gnus-byte-compile (list 'lambda nil cond))))))
12654 (defun gnus-summary-highlight-line ()
12655 "Highlight current line according to `gnus-summary-highlight'."
12656 (let* ((beg (point-at-bol))
12657 (article (or (gnus-summary-article-number) gnus-current-article))
12658 (score (or (cdr (assq article
12659 gnus-newsgroup-scored))
12660 gnus-summary-default-score 0))
12661 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12662 (inhibit-read-only t)
12663 (default gnus-summary-default-score)
12664 (default-high gnus-summary-default-high-score)
12665 (default-low gnus-summary-default-low-score)
12666 (uncached (and gnus-summary-use-undownloaded-faces
12667 (memq article gnus-newsgroup-undownloaded)
12668 (not (memq article gnus-newsgroup-cached)))))
12669 (let ((face (funcall (gnus-summary-highlight-line-0))))
12670 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12671 (gnus-put-text-property-excluding-characters-with-faces
12672 beg (point-at-eol) 'face
12673 (setq face (if (boundp face) (symbol-value face) face)))
12674 (when gnus-summary-highlight-line-function
12675 (funcall gnus-summary-highlight-line-function article face))))))
12677 (defun gnus-update-read-articles (group unread &optional compute)
12678 "Update the list of read articles in GROUP.
12679 UNREAD is a sorted list."
12680 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12681 (info (gnus-get-info group))
12684 (if (or (not info) (not active))
12685 ;; There is no info on this group if it was, in fact,
12686 ;; killed. Gnus stores no information on killed groups, so
12687 ;; there's nothing to be done.
12688 ;; One could store the information somewhere temporarily,
12689 ;; perhaps... Hmmm...
12691 ;; Remove any negative articles numbers.
12692 (while (and unread (< (car unread) 0))
12693 (setq unread (cdr unread)))
12694 ;; Remove any expired article numbers
12695 (while (and unread (< (car unread) (car active)))
12696 (setq unread (cdr unread)))
12697 ;; Compute the ranges of read articles by looking at the list of
12698 ;; unread articles.
12700 (when (/= (car unread) prev)
12701 (push (if (= prev (1- (car unread))) prev
12702 (cons prev (1- (car unread))))
12704 (setq prev (1+ (car unread)))
12705 (setq unread (cdr unread)))
12706 (when (<= prev (cdr active))
12707 (push (cons prev (cdr active)) read))
12708 (setq read (if (> (length read) 1) (nreverse read) read))
12713 ;; Propagate the read marks to the backend.
12714 (when (and (gnus-method-option-p
12715 (gnus-find-method-for-group group)
12717 (gnus-check-backend-function 'request-set-mark group))
12718 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12719 (add (gnus-remove-from-range read (gnus-info-read info))))
12721 (unless (gnus-check-group group)
12722 (error "Can't open server for %s" group))
12723 (gnus-request-set-mark
12724 group (delq nil (list (if add (list add 'add '(read)))
12725 (if del (list del 'del '(read))))))
12727 `(gnus-request-set-mark
12730 (if del (list del 'add '(read)))
12731 (if add (list add 'del '(read))))))))))
12732 (set-buffer gnus-group-buffer)
12733 (gnus-undo-register
12735 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12736 (gnus-info-set-read ',info ',(gnus-info-read info))
12737 (gnus-get-unread-articles-in-group ',info
12738 (gnus-active ,group))
12739 (gnus-group-update-group ,group t)
12741 ;; Enter this list into the group info.
12742 (gnus-info-set-read info read)
12743 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12744 (gnus-get-unread-articles-in-group info (gnus-active group))
12747 (defun gnus-offer-save-summaries ()
12748 "Offer to save all active summary buffers."
12750 ;; Go through all buffers and find all summaries.
12751 (dolist (buffer (buffer-list))
12752 (when (and (setq buffer (buffer-name buffer))
12753 (string-match "Summary" buffer)
12754 (with-current-buffer buffer
12755 ;; We check that this is, indeed, a summary buffer.
12756 (and (derived-mode-p 'gnus-summary-mode)
12757 ;; Also make sure this isn't bogus.
12758 gnus-newsgroup-prepared
12759 ;; Also make sure that this isn't a
12760 ;; dead summary buffer.
12761 (not gnus-dead-summary-mode))))
12762 (push buffer buffers)))
12763 ;; Go through all these summary buffers and offer to save them.
12766 (if (eq gnus-interactive-exit 'quiet)
12767 (dolist (buffer buffers)
12768 (switch-to-buffer buffer)
12769 (gnus-summary-exit))
12771 "Update summary buffer %s? "
12773 (switch-to-buffer buf)
12774 (gnus-summary-exit))
12777 (defun gnus-summary-setup-default-charset ()
12778 "Setup newsgroup default charset."
12779 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12780 (setq gnus-newsgroup-charset nil)
12781 (let* ((ignored-charsets
12782 (or gnus-newsgroup-ephemeral-ignored-charsets
12784 (and gnus-newsgroup-name
12785 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12786 gnus-newsgroup-ignored-charsets))))
12787 (setq gnus-newsgroup-charset
12788 (or gnus-newsgroup-ephemeral-charset
12789 (and gnus-newsgroup-name
12790 (gnus-parameter-charset gnus-newsgroup-name))
12791 gnus-default-charset))
12792 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12793 ignored-charsets))))
12799 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12800 "Display the current article buffer fully MIME-buttonized.
12801 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12802 treated as multipart/mixed."
12804 (require 'gnus-art)
12805 (let ((gnus-unbuttonized-mime-types nil)
12806 (gnus-mime-display-multipart-as-mixed show-all-parts))
12807 (gnus-summary-show-article)))
12809 (defun gnus-summary-repair-multipart (article)
12810 "Add a Content-Type header to a multipart article without one."
12811 (interactive (list (gnus-summary-article-number)))
12812 (gnus-with-article article
12813 (message-narrow-to-head)
12814 (message-remove-header "Mime-Version")
12815 (goto-char (point-max))
12816 (insert "Mime-Version: 1.0\n")
12818 (when (search-forward "\n--" nil t)
12819 (let ((separator (buffer-substring (point) (point-at-eol))))
12820 (message-narrow-to-head)
12821 (message-remove-header "Content-Type")
12822 (goto-char (point-max))
12823 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12826 (let (gnus-mark-article-hook)
12827 (gnus-summary-select-article t t nil article)))
12829 (defun gnus-summary-toggle-display-buttonized ()
12830 "Toggle the buttonizing of the article buffer."
12832 (require 'gnus-art)
12833 (if (setq gnus-inhibit-mime-unbuttonizing
12834 (not gnus-inhibit-mime-unbuttonizing))
12835 (let ((gnus-unbuttonized-mime-types nil))
12836 (gnus-summary-show-article))
12837 (gnus-summary-show-article)))
12840 ;;; Generic summary marking commands
12843 (defvar gnus-summary-marking-alist
12844 '((read gnus-del-mark "d")
12845 (unread gnus-unread-mark "u")
12846 (ticked gnus-ticked-mark "!")
12847 (dormant gnus-dormant-mark "?")
12848 (expirable gnus-expirable-mark "e"))
12849 "An alist of names/marks/keystrokes.")
12851 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12852 (defvar gnus-summary-mark-map)
12854 (defun gnus-summary-make-all-marking-commands ()
12855 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12856 (dolist (elem gnus-summary-marking-alist)
12857 (apply 'gnus-summary-make-marking-command elem)))
12859 (defun gnus-summary-make-marking-command (name mark keystroke)
12860 (let ((map (make-sparse-keymap)))
12861 (define-key gnus-summary-generic-mark-map keystroke map)
12862 (dolist (lway `((next "next" next nil "n")
12863 (next-unread "next unread" next t "N")
12864 (prev "previous" prev nil "p")
12865 (prev-unread "previous unread" prev t "P")
12866 (nomove "" nil nil ,keystroke)))
12867 (let ((func (gnus-summary-make-marking-command-1
12868 mark (car lway) lway name)))
12869 (setq func (eval func))
12870 (define-key map (nth 4 lway) func)))))
12872 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12874 (format "gnus-summary-put-mark-as-%s%s"
12875 name (if (eq way 'nomove)
12877 (concat "-" (symbol-name way)))))
12880 "Mark the current article as %s%s.
12881 If N, the prefix, then repeat N times.
12882 If N is negative, move in reverse order.
12883 The difference between N and the actual number of articles marked is
12887 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12889 (defun gnus-summary-generic-mark (n mark move unread)
12890 "Mark N articles with MARK."
12891 (unless (derived-mode-p 'gnus-summary-mode)
12892 (error "This command can only be used in the summary buffer"))
12893 (gnus-summary-show-thread)
12896 ((eq move 'next) 1)
12897 ((eq move 'prev) -1)
12899 (if (zerop nummove)
12903 nummove (* -1 nummove))))
12904 (while (and (> n 0)
12905 (gnus-summary-mark-article nil mark)
12906 (zerop (gnus-summary-next-subject nummove unread t)))
12909 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12910 (gnus-summary-recenter)
12911 (gnus-summary-position-point)
12912 (gnus-set-mode-line 'summary)
12915 (defun gnus-summary-insert-articles (articles)
12916 (when (setq articles
12917 (gnus-sorted-difference articles
12918 (mapcar (lambda (h)
12919 (mail-header-number h))
12920 gnus-newsgroup-headers)))
12921 (setq gnus-newsgroup-headers
12923 gnus-newsgroup-headers
12924 (gnus-fetch-headers articles nil t)
12925 'gnus-article-sort-by-number))
12926 (setq gnus-newsgroup-articles
12927 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12928 ;; Suppress duplicates?
12929 (when gnus-suppress-duplicates
12930 (gnus-dup-suppress-articles))
12932 (if (and gnus-fetch-old-headers
12933 (eq gnus-headers-retrieved-by 'nov))
12934 ;; We might want to build some more threads first.
12935 (if (eq gnus-fetch-old-headers 'invisible)
12936 (gnus-build-all-threads)
12937 (gnus-build-old-threads))
12938 ;; Mark the inserted articles that are unread as unread.
12939 (setq gnus-newsgroup-unreads
12940 (gnus-sorted-nunion
12941 gnus-newsgroup-unreads
12942 (gnus-sorted-nintersection
12943 (gnus-list-of-unread-articles gnus-newsgroup-name)
12945 ;; Mark the inserted articles as selected so that the information
12946 ;; of the marks having been changed by a user may be updated when
12947 ;; exiting this group. See `gnus-summary-update-info'.
12948 (dolist (art articles)
12949 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12950 ;; Let the Gnus agent mark articles as read.
12952 (gnus-agent-get-undownloaded-list))
12953 ;; Remove list identifiers from subject
12954 (gnus-summary-remove-list-identifiers)
12955 ;; First and last article in this newsgroup.
12956 (when gnus-newsgroup-headers
12957 (setq gnus-newsgroup-begin
12958 (mail-header-number (car gnus-newsgroup-headers))
12960 (mail-header-number
12961 (gnus-last-element gnus-newsgroup-headers))))
12962 (when gnus-use-scoring
12963 (gnus-possibly-score-headers))))
12965 (defun gnus-summary-insert-old-articles (&optional all)
12966 "Insert all old articles in this group.
12967 If ALL is non-nil, already read articles become readable.
12968 If ALL is a number, fetch this number of articles."
12971 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12974 ;; Some nntp servers lie about their active range. When
12975 ;; this happens, the active range can be in the millions.
12976 ;; Use a compressed range to avoid creating a huge list.
12977 (gnus-range-difference
12978 (gnus-range-difference (list gnus-newsgroup-active) old)
12979 gnus-newsgroup-unexist))
12980 (setq len (gnus-range-length older))
12985 (let ((older-range (nreverse older)))
12989 (let* ((r (pop older-range))
12990 (min (if (numberp r) r (car r)))
12991 (max (if (numberp r) r (cdr r))))
12992 (while (and (<= min max)
12997 (setq older (gnus-uncompress-range older))))
12999 (setq older (gnus-uncompress-range older)))
13001 (when (and (numberp gnus-large-newsgroup)
13002 (> len gnus-large-newsgroup))
13003 (let* ((cursor-in-echo-area nil)
13004 (initial (gnus-parameter-large-newsgroup-initial
13005 gnus-newsgroup-name))
13009 "How many articles from %s (%s %d): "
13010 (gnus-group-decoded-name gnus-newsgroup-name)
13011 (if initial "max" "default")
13015 (number-to-string initial)))))
13016 (unless (string-match "^[ \t]*$" input)
13017 (setq all (string-to-number input))
13019 (let ((older-range (nreverse older)))
13023 (let* ((r (pop older-range))
13024 (min (if (numberp r) r (car r)))
13025 (max (if (numberp r) r (cdr r))))
13026 (while (and (<= min max)
13030 max (1- max))))))))))
13031 (setq older (gnus-uncompress-range older))))
13033 (message "No old news.")
13034 (gnus-summary-insert-articles older)
13035 (gnus-summary-limit (gnus-sorted-nunion old older))))
13036 (gnus-summary-position-point)))
13038 (defun gnus-summary-insert-new-articles ()
13039 "Insert all new articles in this group."
13041 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
13042 (old-high gnus-newsgroup-highest)
13043 (nnmail-fetched-sources (list t))
13044 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
13047 (error "Couldn't fetch new data"))
13048 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
13049 (setq i (cdr gnus-newsgroup-active)
13050 gnus-newsgroup-highest i)
13051 (while (> i old-high)
13055 (message "No gnus is bad news")
13056 (gnus-summary-insert-articles new)
13057 (setq gnus-newsgroup-unreads
13058 (gnus-sorted-nunion gnus-newsgroup-unreads new))
13059 (gnus-summary-limit (gnus-sorted-nunion old new))))
13060 (gnus-summary-position-point))
13062 ;;; Bookmark support for Gnus.
13063 (declare-function gnus-article-show-summary "gnus-art" ())
13064 (declare-function bookmark-make-record-default
13065 "bookmark" (&optional no-file no-context posn))
13066 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13067 (declare-function bookmark-default-handler "bookmark" (bmk))
13068 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13069 (defvar bookmark-yank-point)
13070 (defvar bookmark-current-buffer)
13072 (defun gnus-summary-bookmark-make-record ()
13073 "Make a bookmark entry for a Gnus summary buffer."
13075 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13076 (save-restriction ; FIXME is it necessary to widen?
13077 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13078 (setq buf "art") ; We are recording bookmark from article buffer.
13079 (setq bookmark-yank-point (point))
13080 (setq bookmark-current-buffer (current-buffer))
13081 (gnus-article-show-summary)) ; Go back in summary buffer.
13082 ;; We are now recording bookmark from summary buffer.
13083 (unless buf (setq buf "sum"))
13084 (let* ((subject (elt (gnus-summary-article-header) 1))
13085 (grp (car gnus-article-current))
13086 (art (cdr gnus-article-current))
13087 (head (gnus-summary-article-header art))
13088 (id (mail-header-id head)))
13090 ,@(condition-case nil
13091 (bookmark-make-record-default 'no-file 'no-context pos)
13092 (wrong-number-of-arguments
13093 (bookmark-make-record-default 'point-only)))
13094 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13095 (group . ,grp) (article . ,art)
13096 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13099 (defun gnus-summary-bookmark-jump (bookmark)
13100 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13101 BOOKMARK is a bookmark name or a bookmark record."
13102 (let ((group (bookmark-prop-get bookmark 'group))
13103 (article (bookmark-prop-get bookmark 'article))
13104 (id (bookmark-prop-get bookmark 'message-id))
13105 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13106 (gnus-fetch-group group (list article))
13107 (gnus-summary-insert-cached-articles)
13108 (gnus-summary-goto-article id nil 'force)
13109 ;; FIXME we have to wait article buffer is ready (only large buffer)
13110 ;; Is there a better solution to know that?
13111 ;; If we don't wait `bookmark-default-handler' will have no chance
13112 ;; to set position. However there is no error, just wrong pos.
13114 (when (string= buf "Gnus-art")
13116 (bookmark-default-handler
13118 (buffer . ,(current-buffer))
13119 . ,(bookmark-get-bookmark-record bookmark)))))
13121 (gnus-summary-make-all-marking-commands)
13123 (gnus-ems-redefine)
13125 (provide 'gnus-sum)
13127 (run-hooks 'gnus-sum-load-hook)
13129 ;; Local Variables:
13133 ;;; gnus-sum.el ends here