1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2012 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/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function
) (defmacro declare-function
(&rest r
))))
33 (when (featurep 'xemacs
)
34 (require 'easy-mmode
))) ; for `define-minor-mode'
36 (defvar tool-bar-mode
)
37 (defvar gnus-tmp-header
)
50 (autoload 'gnus-summary-limit-include-cached
"gnus-cache" nil t
)
51 (autoload 'gnus-cache-write-active
"gnus-cache")
52 (autoload 'gnus-mailing-list-insinuate
"gnus-ml" nil t
)
53 (autoload 'turn-on-gnus-mailing-list-mode
"gnus-ml" nil t
)
54 (autoload 'gnus-pick-line-number
"gnus-salt" nil t
)
55 (autoload 'mm-uu-dissect
"mm-uu")
56 (autoload 'gnus-article-outlook-deuglify-article
"deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
59 (autoload 'gnus-article-outlook-unwrap-lines
"deuglify" nil t
)
60 (autoload 'gnus-article-outlook-repair-attribution
"deuglify" nil t
)
61 (autoload 'gnus-article-outlook-rearrange-citation
"deuglify" nil t
)
62 (autoload 'nnir-article-rsv
"nnir" nil nil
'macro
)
63 (autoload 'nnir-article-group
"nnir" nil nil
'macro
)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group
'gnus-summary-exit
72 (defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74 See `gnus-group-goto-unread'."
75 :link
'(custom-manual "(gnus)Group Maneuvering")
76 :group
'gnus-summary-exit
77 :version
"23.1" ;; No Gnus
80 (defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link
'(custom-manual "(gnus)Group Maneuvering")
83 :group
'gnus-summary-maneuvering
87 (defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
89 If an unread article in the group refers to an older, already
90 read (or just marked as read) article, the old article will not
91 normally be displayed in the Summary buffer. If this variable is
92 t, Gnus will attempt to grab the headers to the old articles, and
93 thereby build complete threads. If it has the value `some', all
94 old headers will be fetched but only enough headers to connect
95 otherwise loose threads will be displayed. This variable can
96 also be a number. In that case, no more than that number of old
97 headers will be fetched. If it has the value `invisible', all
98 old headers will be fetched, but none will be displayed.
100 The server has to support NOV for any of this to work.
102 This feature can seriously impact performance it ignores all
103 locally cached header entries. Setting it to t for groups for a
104 server that doesn't expire articles (such as news.gmane.org),
105 leads to very slow summary generation."
107 :type
'(choice (const :tag
"off" nil
)
112 (sexp :menu-tag
"other" t
)))
114 (defcustom gnus-refer-thread-limit
500
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116 If t, fetch all the available old headers."
118 :type
'(choice number
119 (sexp :menu-tag
"other" t
)))
121 (defcustom gnus-refer-thread-use-nnir nil
122 "*Use nnir to search an entire server when referring threads. A
123 nil value will only search for thread-related articles in the
129 (defcustom gnus-summary-make-false-root
'adopt
130 "*nil means that Gnus won't gather loose threads.
131 If the root of a thread has expired or been read in a previous
132 session, the information necessary to build a complete thread has been
133 lost. Instead of having many small sub-threads from this original thread
134 scattered all over the summary buffer, Gnus can gather them.
136 If non-nil, Gnus will try to gather all loose sub-threads from an
137 original thread into one large thread.
139 If this variable is non-nil, it should be one of `none', `adopt',
142 If this variable is `none', Gnus will not make a false root, but just
143 present the sub-threads after another.
144 If this variable is `dummy', Gnus will create a dummy root that will
145 have all the sub-threads as children.
146 If this variable is `adopt', Gnus will make one of the \"children\"
147 the parent and mark all the step-children as such.
148 If this variable is `empty', the \"children\" are printed with empty
149 subject fields. (Or rather, they will be printed with a string
150 given by the `gnus-summary-same-subject' variable.)"
152 :type
'(choice (const :tag
"off" nil
)
158 (defcustom gnus-summary-make-false-root-always nil
159 "Always make a false dummy root."
164 (defcustom gnus-summary-gather-exclude-subject
"^ *$\\|^(none)$"
165 "*A regexp to match subjects to be excluded from loose thread gathering.
166 As loose thread gathering is done on subjects only, that means that
167 there can be many false gatherings performed. By rooting out certain
168 common subjects, gathering might become saner."
172 (defcustom gnus-summary-gather-subject-limit nil
173 "*Maximum length of subject comparisons when gathering loose threads.
174 Use nil to compare full subjects. Setting this variable to a low
175 number will help gather threads that have been corrupted by
176 newsreaders chopping off subject lines, but it might also mean that
177 unrelated articles that have subject that happen to begin with the
178 same few characters will be incorrectly gathered.
180 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
183 :type
'(choice (const :tag
"off" nil
)
185 (sexp :menu-tag
"on" t
)))
187 (defcustom gnus-simplify-subject-functions nil
188 "List of functions taking a string argument that simplify subjects.
189 The functions are applied recursively.
191 Useful functions to put in this list include:
192 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
193 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
195 :type
'(repeat function
))
197 (defcustom gnus-simplify-ignored-prefixes nil
198 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
200 :type
'(choice (const :tag
"off" nil
)
203 (defcustom gnus-build-sparse-threads nil
204 "*If non-nil, fill in the gaps in threads.
205 If `some', only fill in the gaps that are needed to tie loose threads
206 together. If `more', fill in all leaf nodes that Gnus can find. If
207 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
209 :type
'(choice (const :tag
"off" nil
)
212 (sexp :menu-tag
"all" t
)))
214 (defcustom gnus-summary-thread-gathering-function
215 'gnus-gather-threads-by-subject
216 "*Function used for gathering loose threads.
217 There are two pre-defined functions: `gnus-gather-threads-by-subject',
218 which only takes Subjects into consideration; and
219 `gnus-gather-threads-by-references', which compared the References
220 headers of the articles to find matches."
222 :type
'(radio (function-item gnus-gather-threads-by-subject
)
223 (function-item gnus-gather-threads-by-references
)
224 (function :tag
"other")))
226 (defcustom gnus-summary-same-subject
""
227 "*String indicating that the current article has the same subject as the previous.
228 This variable will only be used if the value of
229 `gnus-summary-make-false-root' is `empty'."
230 :group
'gnus-summary-format
233 (defcustom gnus-summary-goto-unread nil
234 "*If t, many commands will go to the next unread article.
235 This applies to marking commands as well as other commands that
236 \"naturally\" select the next article, like, for instance, `SPC' at
237 the end of an article.
239 If nil, the marking commands do NOT go to the next unread article
240 \(they go to the next article instead). If `never', commands that
241 usually go to the next unread article, will go to the next article,
242 whether it is read or not."
244 :group
'gnus-summary-marks
245 :link
'(custom-manual "(gnus)Setting Marks")
246 :type
'(choice (const :tag
"off" nil
)
248 (sexp :menu-tag
"on" t
)))
250 (defcustom gnus-summary-default-score
0
251 "*Default article score level.
252 All scores generated by the score files will be added to this score.
253 If this variable is nil, scoring will be disabled."
254 :group
'gnus-score-default
255 :type
'(choice (const :tag
"disable")
258 (defcustom gnus-summary-default-high-score
0
259 "*Default threshold for a high scored article.
260 An article will be highlighted as high scored if its score is greater
263 :group
'gnus-score-default
266 (defcustom gnus-summary-default-low-score
0
267 "*Default threshold for a low scored article.
268 An article will be highlighted as low scored if its score is smaller
271 :group
'gnus-score-default
274 (defcustom gnus-summary-zcore-fuzz
0
275 "*Fuzziness factor for the zcore in the summary buffer.
276 Articles with scores closer than this to `gnus-summary-default-score'
278 :group
'gnus-summary-format
281 (defcustom gnus-simplify-subject-fuzzy-regexp nil
282 "*Strings to be removed when doing fuzzy matches.
283 This can either be a regular expression or list of regular expressions
284 that will be removed from subject strings if fuzzy subject
285 simplification is selected."
287 :type
'(repeat regexp
))
289 (defcustom gnus-show-threads t
290 "*If non-nil, display threads in summary mode."
294 (defcustom gnus-thread-hide-subtree nil
295 "*If non-nil, hide all threads initially.
296 This can be a predicate specifier which says which threads to hide.
297 If threads are hidden, you have to run the command
298 `gnus-summary-show-thread' by hand or select an article."
300 :type
'(radio (sexp :format
"Non-nil\n"
301 :match
(lambda (widget value
)
302 (not (or (consp value
) (functionp value
))))
305 (sexp :tag
"Predicate specifier")))
307 (defcustom gnus-thread-hide-killed t
308 "*If non-nil, hide killed threads automatically."
312 (defcustom gnus-thread-ignore-subject t
313 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
314 If nil, articles that have different subjects from their parents will
315 start separate threads."
319 (defcustom gnus-thread-operation-ignore-subject t
320 "*If non-nil, subjects will be ignored when doing thread commands.
321 This affects commands like `gnus-summary-kill-thread' and
322 `gnus-summary-lower-thread'.
324 If this variable is nil, articles in the same thread with different
325 subjects will not be included in the operation in question. If this
326 variable is `fuzzy', only articles that have subjects that are fuzzily
327 equal will be included."
329 :type
'(choice (const :tag
"off" nil
)
333 (defcustom gnus-thread-indent-level
4
334 "*Number that says how much each sub-thread should be indented."
338 (defcustom gnus-auto-extend-newsgroup t
339 "*If non-nil, extend newsgroup forward and backward when requested."
340 :group
'gnus-summary-choose
343 (defcustom gnus-auto-select-first t
344 "If non-nil, select an article on group entry.
345 An article is selected automatically when entering a group
346 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
347 `gnus-summary-catchup-and-goto-next-group'.
349 Which article is selected is controlled by the variable
350 `gnus-auto-select-subject'.
352 If you want to prevent automatic selection of articles in some
353 newsgroups, set the variable to nil in `gnus-select-group-hook'."
354 ;; Commands include...
355 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
356 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
357 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
358 :group
'gnus-group-select
359 :type
'(choice (const :tag
"none" nil
)
360 (sexp :menu-tag
"first" t
)))
362 (defcustom gnus-auto-select-subject
'unseen-or-unread
363 "*Says what subject to place under point when entering a group.
365 This variable can either be the symbols `first' (place point on the
366 first subject), `unread' (place point on the subject line of the first
367 unread article), `best' (place point on the subject line of the
368 highest-scored article), `unseen' (place point on the subject line of
369 the first unseen article), `unseen-or-unread' (place point on the subject
370 line of the first unseen article or, if all articles have been seen, on the
371 subject line of the first unread article), or a function to be called to
372 place point on some subject line."
374 :group
'gnus-group-select
375 :type
'(choice (const best
)
379 (const unseen-or-unread
)
380 (function :tag
"Function to call")))
382 (defcustom gnus-auto-select-next t
383 "*If non-nil, offer to go to the next group from the end of the previous.
384 If the value is t and the next newsgroup is empty, Gnus will exit
385 summary mode and go back to group mode. If the value is neither nil
386 nor t, Gnus will select the following unread newsgroup. In
387 particular, if the value is the symbol `quietly', the next unread
388 newsgroup will be selected without any confirmation, and if it is
389 `almost-quietly', the next group will be selected without any
390 confirmation if you are located on the last article in the group.
391 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
392 will go to the next group without confirmation."
393 :group
'gnus-summary-maneuvering
394 :type
'(choice (const :tag
"off" nil
)
396 (const almost-quietly
)
397 (const slightly-quietly
)
398 (sexp :menu-tag
"on" t
)))
400 (defcustom gnus-auto-select-same nil
401 "*If non-nil, select the next article with the same subject.
402 If there are no more articles with the same subject, go to
403 the first unread article."
404 :group
'gnus-summary-maneuvering
407 (defcustom gnus-auto-select-on-ephemeral-exit
'next-noselect
408 "What article should be selected after exiting an ephemeral group.
409 Valid values include:
412 Select the next article.
414 Select the next unread article.
416 Move the cursor to the next article. This is the default.
417 `next-unread-noselect'
418 Move the cursor to the next unread article.
420 If it has any other value or there is no next (unread) article, the
421 article selected before entering to the ephemeral group will appear."
422 :version
"23.1" ;; No Gnus
423 :group
'gnus-summary-maneuvering
424 :type
'(choice :format
"%{%t%}:\n %[Value Menu%] %v"
425 (const next
) (const next-unread
)
426 (const next-noselect
) (const next-unread-noselect
)
427 (sexp :tag
"other" :value nil
)))
429 (defcustom gnus-auto-goto-ignores
'unfetched
430 "*Says how to handle unfetched articles when maneuvering.
432 This variable can either be the symbols nil (maneuver to any
433 article), `undownloaded' (maneuvering while unplugged ignores articles
434 that have not been fetched), `always-undownloaded' (maneuvering always
435 ignores articles that have not been fetched), `unfetched' (maneuvering
436 ignores articles whose headers have not been fetched).
438 NOTE: The list of unfetched articles will always be nil when plugged
439 and, when unplugged, a subset of the undownloaded article list."
441 :group
'gnus-summary-maneuvering
442 :type
'(choice (const :tag
"None" nil
)
443 (const :tag
"Undownloaded when unplugged" undownloaded
)
444 (const :tag
"Undownloaded" always-undownloaded
)
445 (const :tag
"Unfetched" unfetched
)))
447 (defcustom gnus-summary-check-current nil
448 "*If non-nil, consider the current article when moving.
449 The \"unread\" movement commands will stay on the same line if the
450 current article is unread."
451 :group
'gnus-summary-maneuvering
454 (defcustom gnus-auto-center-summary
455 (max (or (bound-and-true-p scroll-margin
) 0) 2)
456 "*If non-nil, always center the current summary buffer.
457 In particular, if `vertical' do only vertical recentering. If non-nil
458 and non-`vertical', do both horizontal and vertical recentering."
459 :group
'gnus-summary-maneuvering
460 :type
'(choice (const :tag
"none" nil
)
462 (integer :tag
"height")
463 (sexp :menu-tag
"both" t
)))
465 (defcustom gnus-auto-center-group t
466 "If non-nil, always center the group buffer."
467 :group
'gnus-summary-maneuvering
470 (defcustom gnus-show-all-headers nil
471 "*If non-nil, don't hide any headers."
472 :group
'gnus-article-hiding
473 :group
'gnus-article-headers
476 (defcustom gnus-summary-ignore-duplicates nil
477 "*If non-nil, ignore articles with identical Message-ID headers."
481 (defcustom gnus-single-article-buffer nil
482 "*If non-nil, display all articles in the same buffer.
483 If nil, each group will get its own article buffer."
485 :group
'gnus-article-various
488 (defcustom gnus-widen-article-window nil
489 "If non-nil, selecting the article buffer will display only the article buffer."
491 :group
'gnus-article-various
494 (defcustom gnus-break-pages t
495 "*If non-nil, do page breaking on articles.
496 The page delimiter is specified by the `gnus-page-delimiter'
498 :group
'gnus-article-various
501 (defcustom gnus-move-split-methods nil
502 "*Variable used to suggest where articles are to be moved to.
503 It uses the same syntax as the `gnus-split-methods' variable.
504 However, whereas `gnus-split-methods' specifies file names as targets,
505 this variable specifies group names."
506 :group
'gnus-summary-mail
507 :type
'(repeat (choice (list :value
(fun) function
)
508 (cons :value
("" "") regexp
(repeat string
))
511 (defcustom gnus-move-group-prefix-function
'gnus-group-real-prefix
512 "Function used to compute default prefix for article move/copy/etc prompts.
513 The function should take one argument, a group name, and return a
514 string with the suggested prefix."
515 :group
'gnus-summary-mail
518 ;; FIXME: Although the custom type is `character' for the following variables,
519 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
521 (defcustom gnus-unread-mark ?
;Whitespace
522 "*Mark used for unread articles."
523 :group
'gnus-summary-marks
526 (defcustom gnus-ticked-mark ?
!
527 "*Mark used for ticked articles."
528 :group
'gnus-summary-marks
531 (defcustom gnus-dormant-mark ??
532 "*Mark used for dormant articles."
533 :group
'gnus-summary-marks
536 (defcustom gnus-del-mark ?r
537 "*Mark used for del'd articles."
538 :group
'gnus-summary-marks
541 (defcustom gnus-read-mark ?R
542 "*Mark used for read articles."
543 :group
'gnus-summary-marks
546 (defcustom gnus-expirable-mark ?E
547 "*Mark used for expirable articles."
548 :group
'gnus-summary-marks
551 (defcustom gnus-killed-mark ?K
552 "*Mark used for killed articles."
553 :group
'gnus-summary-marks
556 (defcustom gnus-spam-mark ?$
557 "*Mark used for spam articles."
559 :group
'gnus-summary-marks
562 (defcustom gnus-kill-file-mark ?X
563 "*Mark used for articles killed by kill files."
564 :group
'gnus-summary-marks
567 (defcustom gnus-low-score-mark ?Y
568 "*Mark used for articles with a low score."
569 :group
'gnus-summary-marks
572 (defcustom gnus-catchup-mark ?C
573 "*Mark used for articles that are caught up."
574 :group
'gnus-summary-marks
577 (defcustom gnus-replied-mark ?A
578 "*Mark used for articles that have been replied to."
579 :group
'gnus-summary-marks
582 (defcustom gnus-forwarded-mark ?F
583 "*Mark used for articles that have been forwarded."
585 :group
'gnus-summary-marks
588 (defcustom gnus-recent-mark ?N
589 "*Mark used for articles that are recent."
591 :group
'gnus-summary-marks
594 (defcustom gnus-cached-mark ?
*
595 "*Mark used for articles that are in the cache."
596 :group
'gnus-summary-marks
599 (defcustom gnus-saved-mark ?S
600 "*Mark used for articles that have been saved."
601 :group
'gnus-summary-marks
604 (defcustom gnus-unseen-mark ?.
605 "*Mark used for articles that haven't been seen."
607 :group
'gnus-summary-marks
610 (defcustom gnus-no-mark ?
;Whitespace
611 "*Mark used for articles that have no other secondary mark."
613 :group
'gnus-summary-marks
616 (defcustom gnus-ancient-mark ?O
617 "*Mark used for ancient articles."
618 :group
'gnus-summary-marks
621 (defcustom gnus-sparse-mark ?Q
622 "*Mark used for sparsely reffed articles."
623 :group
'gnus-summary-marks
626 (defcustom gnus-canceled-mark ?G
627 "*Mark used for canceled articles."
628 :group
'gnus-summary-marks
631 (defcustom gnus-duplicate-mark ?M
632 "*Mark used for duplicate articles."
633 :group
'gnus-summary-marks
636 (defcustom gnus-undownloaded-mark ?-
637 "*Mark used for articles that weren't downloaded."
639 :group
'gnus-summary-marks
642 (defcustom gnus-downloaded-mark ?
+
643 "*Mark used for articles that were downloaded."
644 :group
'gnus-summary-marks
647 (defcustom gnus-downloadable-mark ?%
648 "*Mark used for articles that are to be downloaded."
649 :group
'gnus-summary-marks
652 (defcustom gnus-unsendable-mark ?
=
653 "*Mark used for articles that won't be sent."
654 :group
'gnus-summary-marks
657 (defcustom gnus-score-over-mark ?
+
658 "*Score mark used for articles with high scores."
659 :group
'gnus-summary-marks
662 (defcustom gnus-score-below-mark ?-
663 "*Score mark used for articles with low scores."
664 :group
'gnus-summary-marks
667 (defcustom gnus-empty-thread-mark ?
;Whitespace
668 "*There is no thread under the article."
669 :group
'gnus-summary-marks
672 (defcustom gnus-not-empty-thread-mark ?
=
673 "*There is a thread under the article."
674 :group
'gnus-summary-marks
677 (defcustom gnus-view-pseudo-asynchronously nil
678 "*If non-nil, Gnus will view pseudo-articles asynchronously."
679 :group
'gnus-extract-view
682 (defcustom gnus-auto-expirable-marks
683 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
684 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
686 "*The list of marks converted into expiration if a group is auto-expirable."
689 :type
'(repeat character
))
691 (defcustom gnus-inhibit-user-auto-expire t
692 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
697 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
698 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
699 If nil, the expirable marks will be unchanged except that the marks
700 will be removed when copying or moving articles to a group that has
701 not turned auto-expire on. If non-nil, articles that have been read
702 will be marked as expirable when being copied or moved to a group in
703 which auto-expire is turned on."
706 :group
'gnus-summary-marks
)
708 (defcustom gnus-view-pseudos nil
709 "*If `automatic', pseudo-articles will be viewed automatically.
710 If `not-confirm', pseudos will be viewed automatically, and the user
711 will not be asked to confirm the command."
712 :group
'gnus-extract-view
713 :type
'(choice (const :tag
"off" nil
)
715 (const not-confirm
)))
717 (defcustom gnus-view-pseudos-separately t
718 "*If non-nil, one pseudo-article will be created for each file to be viewed.
719 If nil, all files that use the same viewing command will be given as a
720 list of parameters to that command."
721 :group
'gnus-extract-view
724 (defcustom gnus-insert-pseudo-articles t
725 "*If non-nil, insert pseudo-articles when decoding articles."
726 :group
'gnus-extract-view
729 (defcustom gnus-summary-dummy-line-format
731 "*The format specification for the dummy roots in the summary buffer.
732 It works along the same lines as a normal formatting string,
733 with some simple extensions.
737 General format specifiers can also be used.
738 See `(gnus)Formatting Variables'."
739 :link
'(custom-manual "(gnus)Formatting Variables")
740 :group
'gnus-threading
743 (defcustom gnus-summary-mode-line-format
"Gnus: %g [%A] %Z"
744 "*The format specification for the summary mode line.
745 It works along the same lines as a normal formatting string,
746 with some simple extensions:
749 %p Unprefixed group name
750 %A Current article number
751 %z Current article score
753 %U Number of unread articles in the group
754 %e Number of unselected articles in the group
755 %Z A string with unread/unselected article counts
756 %g Shortish group name
757 %S Subject of the current article
759 %s Current score file name
760 %d Number of dormant articles
761 %r Number of articles that have been marked as read in this session
762 %E Number of articles expunged by the score files"
763 :group
'gnus-summary-format
766 (defcustom gnus-list-identifiers nil
767 "Regexp that matches list identifiers to be removed from subject.
768 This can also be a list of regexps."
770 :group
'gnus-summary-format
771 :group
'gnus-article-hiding
772 :type
'(choice (const :tag
"none" nil
)
774 (repeat :value
(".*") regexp
)))
776 (defcustom gnus-summary-mark-below
0
777 "*Mark all articles with a score below this variable as read.
778 This variable is local to each summary buffer and usually set by the
780 :group
'gnus-score-default
783 (defun gnus-widget-reversible-match (widget value
)
784 "Ignoring WIDGET, convert VALUE to internal form.
785 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
789 (eq (length value
) 2)
790 (eq (nth 0 value
) 'not
)
791 (symbolp (nth 1 value
)))))
793 (defun gnus-widget-reversible-to-internal (widget value
)
794 "Ignoring WIDGET, convert VALUE to internal form.
795 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
796 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
800 (list (nth 1 value
) t
)))
802 (defun gnus-widget-reversible-to-external (widget value
)
803 "Ignoring WIDGET, convert VALUE to external form.
804 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
805 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
808 (list 'not
(nth 0 value
))
811 (define-widget 'gnus-widget-reversible
'group
812 "A `group' that convert values."
813 :match
'gnus-widget-reversible-match
814 :value-to-internal
'gnus-widget-reversible-to-internal
815 :value-to-external
'gnus-widget-reversible-to-external
)
817 (defcustom gnus-article-sort-functions
'(gnus-article-sort-by-number)
818 "*List of functions used for sorting articles in the summary buffer.
820 Each function takes two articles and returns non-nil if the first
821 article should be sorted before the other. If you use more than one
822 function, the primary sort function should be the last. You should
823 probably always include `gnus-article-sort-by-number' in the list of
824 sorting functions -- preferably first. Also note that sorting by date
825 is often much slower than sorting by number, and the sorting order is
826 very similar. (Sorting by date means sorting by the time the message
827 was sent, sorting by number means sorting by arrival time.)
829 Each item can also be a list `(not F)' where F is a function;
830 this reverses the sort order.
832 Ready-made functions include `gnus-article-sort-by-number',
833 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
834 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
835 and `gnus-article-sort-by-score'.
837 When threading is turned on, the variable `gnus-thread-sort-functions'
838 controls how articles are sorted."
839 :group
'gnus-summary-sort
840 :type
'(repeat (gnus-widget-reversible
841 (choice (function-item gnus-article-sort-by-number
)
842 (function-item gnus-article-sort-by-author
)
843 (function-item gnus-article-sort-by-subject
)
844 (function-item gnus-article-sort-by-date
)
845 (function-item gnus-article-sort-by-score
)
846 (function-item gnus-article-sort-by-random
)
847 (function :tag
"other"))
848 (boolean :tag
"Reverse order"))))
851 (defcustom gnus-thread-sort-functions
'(gnus-thread-sort-by-number)
852 "*List of functions used for sorting threads in the summary buffer.
853 By default, threads are sorted by article number.
855 Each function takes two threads and returns non-nil if the first
856 thread should be sorted before the other. If you use more than one
857 function, the primary sort function should be the last. You should
858 probably always include `gnus-thread-sort-by-number' in the list of
859 sorting functions -- preferably first. Also note that sorting by date
860 is often much slower than sorting by number, and the sorting order is
861 very similar. (Sorting by date means sorting by the time the message
862 was sent, sorting by number means sorting by arrival time.)
864 Each list item can also be a list `(not F)' where F is a
865 function; this specifies reversed sort order.
867 Ready-made functions include `gnus-thread-sort-by-number',
868 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
869 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
870 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
871 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
872 and `gnus-thread-sort-by-total-score' (see
873 `gnus-thread-score-function').
875 When threading is turned off, the variable
876 `gnus-article-sort-functions' controls how articles are sorted."
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-thread-score-function
'+
894 "*Function used for calculating the total score of a thread.
896 The function is called with the scores of the article and each
897 subthread and should then return the score of the thread.
899 Some functions you can use are `+', `max', or `min'."
900 :group
'gnus-summary-sort
903 (defcustom gnus-summary-expunge-below nil
904 "All articles that have a score less than this variable will be expunged.
905 This variable is local to the summary buffers."
906 :group
'gnus-score-default
907 :type
'(choice (const :tag
"off" nil
)
910 (defcustom gnus-thread-expunge-below nil
911 "All threads that have a total score less than this variable will be expunged.
912 See `gnus-thread-score-function' for en explanation of what a
915 This variable is local to the summary buffers."
916 :group
'gnus-threading
917 :group
'gnus-score-default
918 :type
'(choice (const :tag
"off" nil
)
921 (defcustom gnus-summary-mode-hook nil
922 "*A hook for Gnus summary mode.
923 This hook is run before any variables are set in the summary buffer."
924 :options
'(turn-on-gnus-mailing-list-mode gnus-pick-mode
)
925 :group
'gnus-summary-various
928 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
929 (when (featurep 'xemacs
)
930 (add-hook 'gnus-summary-mode-hook
'gnus-xmas-summary-menu-add
)
931 (add-hook 'gnus-summary-mode-hook
'gnus-xmas-setup-summary-toolbar
)
932 (add-hook 'gnus-summary-mode-hook
933 'gnus-xmas-switch-horizontal-scrollbar-off
))
935 (defcustom gnus-summary-menu-hook nil
936 "*Hook run after the creation of the summary mode menu."
937 :group
'gnus-summary-visual
940 (defcustom gnus-summary-exit-hook nil
941 "*A hook called on exit from the summary buffer.
942 It will be called with point in the group buffer."
943 :group
'gnus-summary-exit
946 (defcustom gnus-summary-prepare-hook nil
947 "*A hook called after the summary buffer has been generated.
948 If you want to modify the summary buffer, you can use this hook."
949 :group
'gnus-summary-various
952 (defcustom gnus-summary-prepared-hook nil
953 "*A hook called as the last thing after the summary buffer has been generated."
954 :group
'gnus-summary-various
957 (defcustom gnus-summary-generate-hook nil
958 "*A hook run just before generating the summary buffer.
959 This hook is commonly used to customize threading variables and the
961 :group
'gnus-summary-various
964 (defcustom gnus-select-group-hook nil
965 "*A hook called when a newsgroup is selected.
967 If you'd like to simplify subjects like the
968 `gnus-summary-next-same-subject' command does, you can use the
971 (add-hook gnus-select-group-hook
973 (mapcar (lambda (header)
974 (mail-header-set-subject
976 (gnus-simplify-subject
977 (mail-header-subject header) 're-only)))
978 gnus-newsgroup-headers)))"
979 :group
'gnus-group-select
982 (defcustom gnus-select-article-hook nil
983 "*A hook called when an article is selected."
984 :group
'gnus-summary-choose
985 :options
'(gnus-agent-fetch-selected-article)
988 (defcustom gnus-visual-mark-article-hook
989 (list 'gnus-highlight-selected-summary
)
990 "*Hook run after selecting an article in the summary buffer.
991 It is meant to be used for highlighting the article in some way. It
992 is not run if `gnus-visual' is nil."
993 :group
'gnus-summary-visual
996 (defcustom gnus-parse-headers-hook nil
997 "*A hook called before parsing the headers."
1001 (defcustom gnus-exit-group-hook nil
1002 "*A hook called when exiting summary mode.
1003 This hook is not called from the non-updating exit commands like `Q'."
1004 :group
'gnus-various
1007 (defcustom gnus-summary-update-hook nil
1008 "*A hook called when a summary line is changed.
1009 The hook will not be called if `gnus-visual' is nil.
1011 The default function `gnus-summary-highlight-line' will
1012 highlight the line according to the `gnus-summary-highlight'
1014 :group
'gnus-summary-visual
1017 (defcustom gnus-mark-article-hook
'(gnus-summary-mark-read-and-unread-as-read)
1018 "*A hook called when an article is selected for the first time.
1019 The hook is intended to mark an article as read (or unread)
1020 automatically when it is selected."
1021 :group
'gnus-summary-choose
1024 (defcustom gnus-group-no-more-groups-hook nil
1025 "*A hook run when returning to group mode having no more (unread) groups."
1026 :group
'gnus-group-select
1029 (defcustom gnus-ps-print-hook nil
1030 "*A hook run before ps-printing something from Gnus."
1031 :group
'gnus-summary
1034 (defcustom gnus-summary-article-move-hook nil
1035 "*A hook called after an article is moved, copied, respooled, or crossposted."
1037 :group
'gnus-summary
1040 (defcustom gnus-summary-article-delete-hook nil
1041 "*A hook called after an article is deleted."
1043 :group
'gnus-summary
1046 (defcustom gnus-summary-article-expire-hook nil
1047 "*A hook called after an article is expired."
1049 :group
'gnus-summary
1052 (defcustom gnus-summary-display-arrow
1053 (and (fboundp 'display-graphic-p
)
1054 (display-graphic-p))
1055 "*If non-nil, display an arrow highlighting the current article."
1057 :group
'gnus-summary
1060 (defcustom gnus-summary-selected-face
'gnus-summary-selected
1061 "Face used for highlighting the current article in the summary buffer."
1062 :group
'gnus-summary-visual
1065 (defvar gnus-tmp-downloaded nil
)
1067 (defcustom gnus-summary-highlight
1068 '(((eq mark gnus-canceled-mark
)
1069 . gnus-summary-cancelled
)
1070 ((and uncached
(> score default-high
))
1071 . gnus-summary-high-undownloaded
)
1072 ((and uncached
(< score default-low
))
1073 . gnus-summary-low-undownloaded
)
1075 . gnus-summary-normal-undownloaded
)
1076 ((and (> score default-high
)
1077 (or (eq mark gnus-dormant-mark
)
1078 (eq mark gnus-ticked-mark
)))
1079 . gnus-summary-high-ticked
)
1080 ((and (< score default-low
)
1081 (or (eq mark gnus-dormant-mark
)
1082 (eq mark gnus-ticked-mark
)))
1083 . gnus-summary-low-ticked
)
1084 ((or (eq mark gnus-dormant-mark
)
1085 (eq mark gnus-ticked-mark
))
1086 . gnus-summary-normal-ticked
)
1087 ((and (> score default-high
) (eq mark gnus-ancient-mark
))
1088 . gnus-summary-high-ancient
)
1089 ((and (< score default-low
) (eq mark gnus-ancient-mark
))
1090 . gnus-summary-low-ancient
)
1091 ((eq mark gnus-ancient-mark
)
1092 . gnus-summary-normal-ancient
)
1093 ((and (> score default-high
) (eq mark gnus-unread-mark
))
1094 . gnus-summary-high-unread
)
1095 ((and (< score default-low
) (eq mark gnus-unread-mark
))
1096 . gnus-summary-low-unread
)
1097 ((eq mark gnus-unread-mark
)
1098 . gnus-summary-normal-unread
)
1099 ((> score default-high
)
1100 . gnus-summary-high-read
)
1101 ((< score default-low
)
1102 . gnus-summary-low-read
)
1104 . gnus-summary-normal-read
))
1105 "*Controls the highlighting of summary buffer lines.
1107 A list of (FORM . FACE) pairs. When deciding how a particular
1108 summary line should be displayed, each form is evaluated. The content
1109 of the face field after the first true form is used. You can change
1110 how those summary lines are displayed, by editing the face field.
1112 You can use the following variables in the FORM field.
1114 score: The article's score.
1115 default: The default article score.
1116 default-high: The default score for high scored articles.
1117 default-low: The default score for low scored articles.
1118 below: The score below which articles are automatically marked as read.
1119 mark: The article's mark.
1120 uncached: Non-nil if the article is uncached."
1121 :group
'gnus-summary-visual
1122 :type
'(repeat (cons (sexp :tag
"Form" nil
)
1124 (put 'gnus-summary-highlight
'risky-local-variable t
)
1126 (defcustom gnus-alter-header-function nil
1127 "Function called to allow alteration of article header structures.
1128 The function is called with one parameter, the article header vector,
1129 which it may alter in any way."
1130 :type
'(choice (const :tag
"None" nil
)
1132 :group
'gnus-summary
)
1134 (defvar gnus-decode-encoded-word-function
'mail-decode-encoded-word-string
1135 "Function used to decode a string with encoded words.")
1137 (defvar gnus-decode-encoded-address-function
1138 'mail-decode-encoded-address-string
1139 "Function used to decode addresses with encoded words.")
1141 (defcustom gnus-extra-headers
'(To Cc Keywords Gcc Newsgroups
)
1142 "*Extra headers to parse."
1143 :version
"24.1" ; added Cc Keywords Gcc
1144 :group
'gnus-summary
1145 :type
'(repeat symbol
))
1147 (defcustom gnus-ignored-from-addresses
1148 (and user-mail-address
1149 (not (string= user-mail-address
""))
1150 (regexp-quote user-mail-address
))
1151 "*From headers that may be suppressed in favor of To headers.
1152 This can be a regexp or a list of regexps."
1154 :group
'gnus-summary
1155 :type
'(choice regexp
1156 (repeat :tag
"Regexp List" regexp
)))
1158 (defsubst gnus-ignored-from-addresses
()
1159 (gmm-regexp-concat gnus-ignored-from-addresses
))
1161 (defcustom gnus-summary-to-prefix
"-> "
1162 "*String prefixed to the To field in the summary line when
1163 using `gnus-ignored-from-addresses'."
1165 :group
'gnus-summary
1168 (defcustom gnus-summary-newsgroup-prefix
"=> "
1169 "*String prefixed to the Newsgroup field in the summary
1170 line when using `gnus-ignored-from-addresses'."
1172 :group
'gnus-summary
1175 (defcustom gnus-newsgroup-ignored-charsets
'(unknown-8bit x-unknown
)
1176 "List of charsets that should be ignored.
1177 When these charsets are used in the \"charset\" parameter, the
1178 default charset will be used instead."
1180 :type
'(repeat symbol
)
1181 :group
'gnus-charset
)
1183 (defcustom gnus-newsgroup-maximum-articles nil
1184 "The maximum number of articles a newsgroup.
1185 If this is a number, old articles in a newsgroup exceeding this number
1186 are silently ignored. If it is nil, no article is ignored. Note that
1187 setting this variable to a number might prevent you from reading very
1189 :group
'gnus-group-select
1191 :type
'(choice (const :tag
"No limit" nil
)
1194 (gnus-define-group-parameter
1198 "Return the ignored charsets of GROUP."
1199 :variable gnus-group-ignored-charsets-alist
1201 '(("alt\\.chinese\\.text" iso-8859-1
))
1203 "Alist of regexps (to match group names) and charsets that should be ignored.
1204 When these charsets are used in the \"charset\" parameter, the
1205 default charset will be used instead."
1206 :variable-group gnus-charset
1207 :variable-type
'(repeat (cons (regexp :tag
"Group")
1209 :parameter-type
'(choice :tag
"Ignored charsets"
1212 :parameter-document
"\
1213 List of charsets that should be ignored.
1215 When these charsets are used in the \"charset\" parameter, the
1216 default charset will be used instead.")
1218 (defcustom gnus-group-highlight-words-alist nil
1219 "Alist of group regexps and highlight regexps.
1220 This variable uses the same syntax as `gnus-emphasis-alist'."
1222 :type
'(repeat (cons (regexp :tag
"Group")
1223 (repeat (list (regexp :tag
"Highlight regexp")
1224 (number :tag
"Group for entire word" 0)
1225 (number :tag
"Group for displayed part" 0)
1227 gnus-emphasis-highlight-words
)))))
1228 :group
'gnus-summary-visual
)
1230 (defcustom gnus-summary-show-article-charset-alist
1232 "Alist of number and charset.
1233 The article will be shown with the charset corresponding to the
1235 For example: ((1 . cn-gb-2312) (2 . big5))."
1237 :type
'(repeat (cons (number :tag
"Argument" 1)
1238 (symbol :tag
"Charset")))
1239 :group
'gnus-charset
)
1241 (defcustom gnus-preserve-marks t
1242 "Whether marks are preserved when moving, copying and respooling messages."
1245 :group
'gnus-summary-marks
)
1247 (defcustom gnus-alter-articles-to-read-function nil
1248 "Function to be called to alter the list of articles to be selected."
1249 :type
'(choice (const nil
) function
)
1250 :group
'gnus-summary
)
1252 (defcustom gnus-orphan-score nil
1253 "*All orphans get this score added. Set in the score file."
1254 :group
'gnus-score-default
1255 :type
'(choice (const nil
)
1258 (defcustom gnus-summary-save-parts-default-mime
"image/.*"
1259 "*A regexp to match MIME parts when saving multiple parts of a
1260 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1261 This regexp will be used by default when prompting the user for which
1262 type of files to save."
1263 :group
'gnus-summary
1266 (defcustom gnus-read-all-available-headers nil
1267 "Whether Gnus should parse all headers made available to it.
1268 This is mostly relevant for slow back ends where the user may
1269 wish to widen the summary buffer to include all headers
1272 :group
'gnus-summary
1273 :type
'(choice boolean regexp
))
1275 (defcustom gnus-summary-pipe-output-default-command nil
1276 "Command (and optional arguments) used to pipe article to subprocess.
1277 This will be used as the default command if it is non-nil. The value
1278 will be updated if you modify it when executing the command
1279 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1280 :version
"23.1" ;; No Gnus
1281 :group
'gnus-summary
1282 :type
'(radio (const :tag
"None" nil
) (string :tag
"Command")))
1284 (defcustom gnus-summary-muttprint-program
"muttprint"
1285 "Command (and optional arguments) used to run Muttprint.
1286 The value will be updated if you modify it when executing the command
1287 `gnus-summary-muttprint'."
1289 :group
'gnus-summary
1292 (defcustom gnus-article-loose-mime t
1293 "If non-nil, don't require MIME-Version header.
1294 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1295 supply the MIME-Version header or deliberately strip it from the mail.
1296 If non-nil (the default), Gnus will treat some articles as MIME
1297 even if the MIME-Version header is missing."
1300 :group
'gnus-article-mime
)
1302 (defcustom gnus-article-emulate-mime t
1303 "If non-nil, use MIME emulation for uuencode and the like.
1304 This means that Gnus will search message bodies for text that look
1305 like uuencoded bits, yEncoded bits, and so on, and present that using
1306 the normal Gnus MIME machinery."
1309 :group
'gnus-article-mime
)
1311 ;;; Internal variables
1313 (defvar gnus-summary-display-cache nil
)
1314 (defvar gnus-article-mime-handles nil
)
1315 (defvar gnus-article-decoded-p nil
)
1316 (defvar gnus-article-charset nil
)
1317 (defvar gnus-article-ignored-charsets nil
)
1318 (defvar gnus-scores-exclude-files nil
)
1319 (defvar gnus-page-broken nil
)
1321 (defvar gnus-original-article nil
)
1322 (defvar gnus-article-internal-prepare-hook nil
)
1323 (defvar gnus-newsgroup-process-stack nil
)
1325 (defvar gnus-thread-indent-array nil
)
1326 (defvar gnus-thread-indent-array-level gnus-thread-indent-level
)
1327 (defvar gnus-sort-gathered-threads-function
'gnus-thread-sort-by-number
1328 "Function called to sort the articles within a thread after it has been gathered together.")
1330 (defvar gnus-summary-save-parts-type-history nil
)
1331 (defvar gnus-summary-save-parts-last-directory mm-default-directory
)
1333 ;; Avoid highlighting in kill files.
1334 (defvar gnus-summary-inhibit-highlight nil
)
1335 (defvar gnus-newsgroup-selected-overlay nil
)
1336 (defvar gnus-inhibit-limiting nil
)
1337 (defvar gnus-newsgroup-adaptive-score-file nil
)
1338 (defvar gnus-current-score-file nil
)
1339 (defvar gnus-current-move-group nil
)
1340 (defvar gnus-current-copy-group nil
)
1341 (defvar gnus-current-crosspost-group nil
)
1342 (defvar gnus-newsgroup-display nil
)
1344 (defvar gnus-newsgroup-dependencies nil
)
1345 (defvar gnus-newsgroup-adaptive nil
)
1346 (defvar gnus-summary-display-article-function nil
)
1347 (defvar gnus-summary-highlight-line-function nil
1348 "Function called after highlighting a summary line.")
1350 (defvar gnus-summary-line-format-alist
1351 `((?N
,(macroexpand '(mail-header-number gnus-tmp-header
)) ?d
)
1352 (?S
,(macroexpand '(mail-header-subject gnus-tmp-header
)) ?s
)
1353 (?s gnus-tmp-subject-or-nil ?s
)
1354 (?n gnus-tmp-name ?s
)
1355 (?A
(car (cdr (funcall gnus-extract-address-components gnus-tmp-from
)))
1357 (?a
(or (car (funcall gnus-extract-address-components gnus-tmp-from
))
1359 (?F gnus-tmp-from ?s
)
1360 (?x
,(macroexpand '(mail-header-xref gnus-tmp-header
)) ?s
)
1361 (?D
,(macroexpand '(mail-header-date gnus-tmp-header
)) ?s
)
1362 (?d
(gnus-dd-mmm (mail-header-date gnus-tmp-header
)) ?s
)
1363 (?o
(gnus-date-iso8601 (mail-header-date gnus-tmp-header
)) ?s
)
1364 (?M
,(macroexpand '(mail-header-id gnus-tmp-header
)) ?s
)
1365 (?r
,(macroexpand '(mail-header-references gnus-tmp-header
)) ?s
)
1366 (?c
(or (mail-header-chars gnus-tmp-header
) 0) ?d
)
1367 (?k
(gnus-summary-line-message-size gnus-tmp-header
) ?s
)
1368 (?L gnus-tmp-lines ?s
)
1369 (?Z
(or (nnir-article-rsv (mail-header-number gnus-tmp-header
))
1371 (?G
(or (nnir-article-group (mail-header-number gnus-tmp-header
))
1373 (?g
(or (gnus-group-short-name
1374 (nnir-article-group (mail-header-number gnus-tmp-header
)))
1376 (?O gnus-tmp-downloaded ?c
)
1377 (?I gnus-tmp-indentation ?s
)
1378 (?T
(if (= gnus-tmp-level
0) "" (make-string (frame-width) ?
)) ?s
)
1379 (?R gnus-tmp-replied ?c
)
1380 (?\
[ gnus-tmp-opening-bracket ?c
)
1381 (?\
] gnus-tmp-closing-bracket ?c
)
1382 (?\
> (make-string gnus-tmp-level ?
) ?s
)
1383 (?\
< (make-string (max 0 (- 20 gnus-tmp-level
)) ?
) ?s
)
1384 (?i gnus-tmp-score ?d
)
1385 (?z gnus-tmp-score-char ?c
)
1386 (?V
(gnus-thread-total-score (and (boundp 'thread
) (car thread
))) ?d
)
1387 (?U gnus-tmp-unread ?c
)
1388 (?f
(gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from
)
1390 (?t
(gnus-summary-number-of-articles-in-thread
1391 (and (boundp 'thread
) (car thread
)) gnus-tmp-level
)
1393 (?e
(gnus-summary-number-of-articles-in-thread
1394 (and (boundp 'thread
) (car thread
)) gnus-tmp-level t
)
1396 (?u gnus-tmp-user-defined ?s
)
1397 (?P
(gnus-pick-line-number) ?d
)
1398 (?B gnus-tmp-thread-tree-header-string ?s
)
1399 (user-date (gnus-user-date
1400 ,(macroexpand '(mail-header-date gnus-tmp-header
))) ?s
))
1401 "An alist of format specifications that can appear in summary lines.
1402 These are paired with what variables they correspond with, along with
1403 the type of the variable (string, integer, character, etc).")
1405 (defvar gnus-summary-dummy-line-format-alist
1406 `((?S gnus-tmp-subject ?s
)
1407 (?N gnus-tmp-number ?d
)
1408 (?u gnus-tmp-user-defined ?s
)))
1410 (defvar gnus-summary-mode-line-format-alist
1411 `((?G gnus-tmp-group-name ?s
)
1412 (?g
(gnus-short-group-name gnus-tmp-group-name
) ?s
)
1413 (?p
(gnus-group-real-name gnus-tmp-group-name
) ?s
)
1414 (?A gnus-tmp-article-number ?d
)
1415 (?Z gnus-tmp-unread-and-unselected ?s
)
1416 (?V gnus-version ?s
)
1417 (?U gnus-tmp-unread-and-unticked ?d
)
1418 (?S gnus-tmp-subject ?s
)
1419 (?e gnus-tmp-unselected ?d
)
1420 (?u gnus-tmp-user-defined ?s
)
1421 (?d
(length gnus-newsgroup-dormant
) ?d
)
1422 (?t
(length gnus-newsgroup-marked
) ?d
)
1423 (?h
(length gnus-newsgroup-spam-marked
) ?d
)
1424 (?r
(length gnus-newsgroup-reads
) ?d
)
1425 (?z
(gnus-summary-article-score gnus-tmp-article-number
) ?d
)
1426 (?E gnus-newsgroup-expunged-tally ?d
)
1427 (?s
(gnus-current-score-file-nondirectory) ?s
)))
1429 ;; This is here rather than in gnus-art for compilation reasons.
1430 (defvar gnus-article-mode-line-format-alist
1431 (nconc '((?w
(gnus-article-wash-status) ?s
)
1432 (?m
(gnus-article-mime-part-status) ?s
))
1433 gnus-summary-mode-line-format-alist
))
1435 (defvar gnus-last-search-regexp nil
1436 "Default regexp for article search command.")
1438 (defvar gnus-last-shell-command nil
1439 "Default shell command on article.")
1441 (defvar gnus-newsgroup-agentized nil
1442 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1443 (defvar gnus-newsgroup-begin nil
)
1444 (defvar gnus-newsgroup-end nil
)
1445 (defvar gnus-newsgroup-last-rmail nil
)
1446 (defvar gnus-newsgroup-last-mail nil
)
1447 (defvar gnus-newsgroup-last-folder nil
)
1448 (defvar gnus-newsgroup-last-file nil
)
1449 (defvar gnus-newsgroup-last-directory nil
)
1450 (defvar gnus-newsgroup-auto-expire nil
)
1451 (defvar gnus-newsgroup-active nil
)
1452 (defvar gnus-newsgroup-highest nil
)
1454 (defvar gnus-newsgroup-data nil
)
1455 (defvar gnus-newsgroup-data-reverse nil
)
1456 (defvar gnus-newsgroup-limit nil
)
1457 (defvar gnus-newsgroup-limits nil
)
1458 (defvar gnus-summary-use-undownloaded-faces nil
)
1460 (defvar gnus-newsgroup-unreads nil
1461 "Sorted list of unread articles in the current newsgroup.")
1463 (defvar gnus-newsgroup-unselected nil
1464 "Sorted list of unselected unread articles in the current newsgroup.")
1466 (defvar gnus-newsgroup-reads nil
1467 "Alist of read articles and article marks in the current newsgroup.")
1469 (defvar gnus-newsgroup-expunged-tally nil
)
1471 (defvar gnus-newsgroup-marked nil
1472 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1474 (defvar gnus-newsgroup-spam-marked nil
1475 "List of ranges of articles that have been marked as spam.")
1477 (defvar gnus-newsgroup-killed nil
1478 "List of ranges of articles that have been through the scoring process.")
1480 (defvar gnus-newsgroup-cached nil
1481 "Sorted list of articles that come from the article cache.")
1483 (defvar gnus-newsgroup-saved nil
1484 "List of articles that have been saved.")
1486 (defvar gnus-newsgroup-kill-headers nil
)
1488 (defvar gnus-newsgroup-replied nil
1489 "List of articles that have been replied to in the current newsgroup.")
1491 (defvar gnus-newsgroup-forwarded nil
1492 "List of articles that have been forwarded in the current newsgroup.")
1494 (defvar gnus-newsgroup-expirable nil
1495 "Sorted list of articles in the current newsgroup that can be expired.")
1497 (defvar gnus-newsgroup-processable nil
1498 "List of articles in the current newsgroup that can be processed.")
1500 (defvar gnus-newsgroup-downloadable nil
1501 "Sorted list of articles in the current newsgroup that can be processed.")
1503 (defvar gnus-newsgroup-unfetched nil
1504 "Sorted list of articles in the current newsgroup whose headers have
1505 not been fetched into the agent.
1507 This list will always be a subset of gnus-newsgroup-undownloaded.")
1509 (defvar gnus-newsgroup-undownloaded nil
1510 "List of articles in the current newsgroup that haven't been downloaded.")
1512 (defvar gnus-newsgroup-unsendable nil
1513 "List of articles in the current newsgroup that won't be sent.")
1515 (defvar gnus-newsgroup-bookmarks nil
1516 "List of articles in the current newsgroup that have bookmarks.")
1518 (defvar gnus-newsgroup-dormant nil
1519 "Sorted list of dormant articles in the current newsgroup.")
1521 (defvar gnus-newsgroup-unseen nil
1522 "List of unseen articles in the current newsgroup.")
1524 (defvar gnus-newsgroup-seen nil
1525 "Range of seen articles in the current newsgroup.")
1527 (defvar gnus-newsgroup-articles nil
1528 "List of articles in the current newsgroup.")
1530 (defvar gnus-newsgroup-scored nil
1531 "List of scored articles in the current newsgroup.")
1533 (defvar gnus-newsgroup-headers nil
1534 "List of article headers in the current newsgroup.")
1536 (defvar gnus-newsgroup-threads nil
)
1538 (defvar gnus-newsgroup-prepared nil
1539 "Whether the current group has been prepared properly.")
1541 (defvar gnus-newsgroup-ancient nil
1542 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1544 (defvar gnus-newsgroup-sparse nil
)
1546 (defvar gnus-current-article nil
)
1547 (defvar gnus-article-current nil
)
1548 (defvar gnus-current-headers nil
)
1549 (defvar gnus-have-all-headers nil
)
1550 (defvar gnus-last-article nil
)
1551 (defvar gnus-newsgroup-history nil
)
1552 (defvar gnus-newsgroup-charset nil
)
1553 (defvar gnus-newsgroup-ephemeral-charset nil
)
1554 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil
)
1556 (defvar gnus-article-before-search nil
)
1558 (defvar gnus-summary-local-variables
1559 '(gnus-newsgroup-name
1562 gnus-newsgroup-unreads
1563 gnus-newsgroup-unselected
1564 gnus-newsgroup-marked
1565 gnus-newsgroup-spam-marked
1566 gnus-newsgroup-reads
1567 gnus-newsgroup-saved
1568 gnus-newsgroup-replied
1569 gnus-newsgroup-forwarded
1570 gnus-newsgroup-expirable
1571 gnus-newsgroup-killed
1572 gnus-newsgroup-unseen
1574 gnus-newsgroup-cached
1575 gnus-newsgroup-downloadable
1576 gnus-newsgroup-undownloaded
1577 gnus-newsgroup-unsendable
1579 gnus-newsgroup-begin gnus-newsgroup-end
1580 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1581 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1582 gnus-newsgroup-last-directory
1583 gnus-newsgroup-auto-expire
1584 gnus-newsgroup-processable
1585 gnus-newsgroup-unfetched
1586 gnus-newsgroup-articles
1587 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1588 gnus-newsgroup-headers gnus-newsgroup-threads
1589 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1590 gnus-current-article gnus-current-headers gnus-have-all-headers
1591 gnus-last-article gnus-article-internal-prepare-hook
1592 (gnus-summary-article-delete-hook . global
)
1593 (gnus-summary-article-move-hook . global
)
1594 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1595 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1596 gnus-thread-expunge-below
1597 gnus-score-alist gnus-current-score-file
1598 (gnus-summary-expunge-below . global
)
1599 (gnus-summary-mark-below . global
)
1600 (gnus-orphan-score . global
)
1601 gnus-newsgroup-active gnus-scores-exclude-files
1602 gnus-newsgroup-highest
1603 gnus-newsgroup-history gnus-newsgroup-ancient
1604 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1605 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring
)
1606 gnus-newsgroup-adaptive-score-file
(gnus-reffed-article-number . -
1)
1607 (gnus-newsgroup-expunged-tally .
0)
1608 gnus-cache-removable-articles
1609 gnus-newsgroup-data gnus-newsgroup-data-reverse
1610 gnus-newsgroup-limit gnus-newsgroup-limits
1611 gnus-newsgroup-charset gnus-newsgroup-display
1612 gnus-summary-use-undownloaded-faces
)
1613 "Variables that are buffer-local to the summary buffers.")
1615 (defvar gnus-newsgroup-variables nil
1616 "A list of variables that have separate values in different newsgroups.
1617 A list of newsgroup (summary buffer) local variables, or cons of
1618 variables and their default expressions to be evalled (when the default
1619 values are not nil), that should be made global while the summary buffer
1622 Note: The default expressions will be evaluated (using function `eval')
1623 before assignment to the local variable rather than just assigned to it.
1624 If the default expression is the symbol `global', that symbol will not
1625 be evaluated but the global value of the local variable will be used
1628 These variables can be used to set variables in the group parameters
1629 while still allowing them to affect operations done in other buffers.
1632 \(setq gnus-newsgroup-variables
1633 '(message-use-followup-to
1634 (gnus-visible-headers .
1635 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1639 ;; Bind features so that require will believe that gnus-sum has
1640 ;; already been loaded (avoids infinite recursion)
1641 (let ((features (cons 'gnus-sum features
)))
1642 (require 'gnus-art
)))
1646 (defvar gnus-decode-encoded-word-methods
1647 '(mail-decode-encoded-word-string)
1648 "List of methods used to decode encoded words.
1650 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1651 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1652 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1653 whose names match REGEXP.
1656 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1657 mail-decode-encoded-word-string
1658 (\"chinese\" . rfc1843-decode-string))")
1660 (defvar gnus-decode-encoded-word-methods-cache nil
)
1662 (defun gnus-multi-decode-encoded-word-string (string)
1663 "Apply the functions from `gnus-encoded-word-methods' that match."
1664 (unless (and gnus-decode-encoded-word-methods-cache
1665 (eq gnus-newsgroup-name
1666 (car gnus-decode-encoded-word-methods-cache
)))
1667 (setq gnus-decode-encoded-word-methods-cache
(list gnus-newsgroup-name
))
1668 (dolist (method gnus-decode-encoded-word-methods
)
1669 (if (symbolp method
)
1670 (nconc gnus-decode-encoded-word-methods-cache
(list method
))
1671 (if (and gnus-newsgroup-name
1672 (string-match (car method
) gnus-newsgroup-name
))
1673 (nconc gnus-decode-encoded-word-methods-cache
1674 (list (cdr method
)))))))
1675 (dolist (method (cdr gnus-decode-encoded-word-methods-cache
) string
)
1676 (setq string
(funcall method string
))))
1678 ;; Subject simplification.
1680 (defun gnus-simplify-whitespace (str)
1681 "Remove excessive whitespace from STR."
1683 (while (string-match "[ \t][ \t]+" str
)
1684 (setq str
(concat (substring str
0 (match-beginning 0))
1686 (substring str
(match-end 0)))))
1688 (when (string-match "^[ \t]+" str
)
1689 (setq str
(substring str
(match-end 0))))
1691 (when (string-match "[ \t]+$" str
)
1692 (setq str
(substring str
0 (match-beginning 0))))
1695 (defun gnus-simplify-all-whitespace (str)
1696 "Remove all whitespace from STR."
1697 (while (string-match "[ \t\n]+" str
)
1698 (setq str
(replace-match "" nil nil str
)))
1701 (defsubst gnus-simplify-subject-re
(subject)
1702 "Remove \"Re:\" from subject lines."
1703 (if (string-match message-subject-re-regexp subject
)
1704 (substring subject
(match-end 0))
1707 (defun gnus-simplify-subject (subject &optional re-only
)
1708 "Remove `Re:' and words in parentheses.
1709 If RE-ONLY is non-nil, strip leading `Re:'s only."
1710 (let ((case-fold-search t
)) ;Ignore case.
1711 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1712 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject
)
1713 (setq subject
(substring subject
(match-end 0))))
1714 ;; Remove uninteresting prefixes.
1715 (when (and (not re-only
)
1716 gnus-simplify-ignored-prefixes
1717 (string-match gnus-simplify-ignored-prefixes subject
))
1718 (setq subject
(substring subject
(match-end 0))))
1719 ;; Remove words in parentheses from end.
1721 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject
)
1722 (setq subject
(substring subject
0 (match-beginning 0)))))
1723 ;; Return subject string.
1726 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1728 (defsubst gnus-simplify-buffer-fuzzy-step
(regexp &optional newtext
)
1729 (goto-char (point-min))
1730 (while (re-search-forward regexp nil t
)
1731 (replace-match (or newtext
""))))
1733 (defun gnus-simplify-buffer-fuzzy (regexp)
1734 "Simplify string in the buffer fuzzily.
1735 The string in the accessible portion of the current buffer is simplified.
1736 It is assumed to be a single-line subject.
1737 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1738 matter is removed. Additional things can be deleted by setting
1739 `gnus-simplify-subject-fuzzy-regexp'."
1740 (let ((case-fold-search t
)
1742 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1744 (while (not (eq modified-tick
(buffer-modified-tick)))
1745 (setq modified-tick
(buffer-modified-tick))
1748 (mapc 'gnus-simplify-buffer-fuzzy-step regexp
))
1750 (gnus-simplify-buffer-fuzzy-step regexp
)))
1751 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1752 (gnus-simplify-buffer-fuzzy-step
1753 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1754 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1756 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1757 (gnus-simplify-buffer-fuzzy-step " +" " ")
1758 (gnus-simplify-buffer-fuzzy-step " $")
1759 (gnus-simplify-buffer-fuzzy-step "^ +")))
1761 (defun gnus-simplify-subject-fuzzy (subject)
1762 "Simplify a subject string fuzzily.
1763 See `gnus-simplify-buffer-fuzzy' for details."
1765 (let ((regexp gnus-simplify-subject-fuzzy-regexp
))
1766 (gnus-set-work-buffer)
1767 (let ((case-fold-search t
))
1768 ;; Remove uninteresting prefixes.
1769 (when (and gnus-simplify-ignored-prefixes
1770 (string-match gnus-simplify-ignored-prefixes subject
))
1771 (setq subject
(substring subject
(match-end 0))))
1773 (inline (gnus-simplify-buffer-fuzzy regexp
))
1776 (defsubst gnus-simplify-subject-fully
(subject)
1777 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1779 (gnus-simplify-subject-functions
1780 (gnus-map-function gnus-simplify-subject-functions subject
))
1781 ((null gnus-summary-gather-subject-limit
)
1782 (gnus-simplify-subject-re subject
))
1783 ((eq gnus-summary-gather-subject-limit
'fuzzy
)
1784 (gnus-simplify-subject-fuzzy subject
))
1785 ((numberp gnus-summary-gather-subject-limit
)
1786 (truncate-string-to-width (gnus-simplify-subject-re subject
)
1787 gnus-summary-gather-subject-limit
))
1791 (defsubst gnus-subject-equal
(s1 s2
&optional simple-first
)
1792 "Check whether two subjects are equal.
1793 If optional argument SIMPLE-FIRST is t, first argument is already
1796 ((null simple-first
)
1797 (equal (gnus-simplify-subject-fully s1
)
1798 (gnus-simplify-subject-fully s2
)))
1801 (gnus-simplify-subject-fully s2
)))))
1803 (defun gnus-summary-bubble-group ()
1804 "Increase the score of the current group.
1805 This is a handy function to add to `gnus-summary-exit-hook' to
1806 increase the score of each group you read."
1807 (gnus-group-add-score gnus-newsgroup-name
))
1811 ;;; Gnus summary mode
1814 (put 'gnus-summary-mode
'mode-class
'special
)
1816 (defvar gnus-article-commands-menu
)
1818 ;; Non-orthogonal keys
1820 (gnus-define-keys gnus-summary-mode-map
1821 " " gnus-summary-next-page
1822 "\177" gnus-summary-prev-page
1823 [delete] gnus-summary-prev-page
1824 [backspace] gnus-summary-prev-page
1825 "\r" gnus-summary-scroll-up
1826 "\M-\r" gnus-summary-scroll-down
1827 "n" gnus-summary-next-unread-article
1828 "p" gnus-summary-prev-unread-article
1829 "N" gnus-summary-next-article
1830 "P" gnus-summary-prev-article
1831 "\M-\C-n" gnus-summary-next-same-subject
1832 "\M-\C-p" gnus-summary-prev-same-subject
1833 "\M-n" gnus-summary-next-unread-subject
1834 "\M-p" gnus-summary-prev-unread-subject
1835 "." gnus-summary-first-unread-article
1836 "," gnus-summary-best-unread-article
1837 "\M-s" gnus-summary-search-article-forward
1838 "\M-r" gnus-summary-search-article-backward
1839 "\M-S" gnus-summary-repeat-search-article-forward
1840 "\M-R" gnus-summary-repeat-search-article-backward
1841 "<" gnus-summary-beginning-of-article
1842 ">" gnus-summary-end-of-article
1843 "j" gnus-summary-goto-article
1844 "^" gnus-summary-refer-parent-article
1845 "\M-^" gnus-summary-refer-article
1846 "u" gnus-summary-tick-article-forward
1847 "!" gnus-summary-tick-article-forward
1848 "U" gnus-summary-tick-article-backward
1849 "d" gnus-summary-mark-as-read-forward
1850 "D" gnus-summary-mark-as-read-backward
1851 "E" gnus-summary-mark-as-expirable
1852 "\M-u" gnus-summary-clear-mark-forward
1853 "\M-U" gnus-summary-clear-mark-backward
1854 "k" gnus-summary-kill-same-subject-and-select
1855 "\C-k" gnus-summary-kill-same-subject
1856 "\M-\C-k" gnus-summary-kill-thread
1857 "\M-\C-l" gnus-summary-lower-thread
1858 "e" gnus-summary-edit-article
1859 "#" gnus-summary-mark-as-processable
1860 "\M-#" gnus-summary-unmark-as-processable
1861 "\M-\C-t" gnus-summary-toggle-threads
1862 "\M-\C-s" gnus-summary-show-thread
1863 "\M-\C-h" gnus-summary-hide-thread
1864 "\M-\C-f" gnus-summary-next-thread
1865 "\M-\C-b" gnus-summary-prev-thread
1866 [(meta down)] gnus-summary-next-thread
1867 [(meta up)] gnus-summary-prev-thread
1868 "\M-\C-u" gnus-summary-up-thread
1869 "\M-\C-d" gnus-summary-down-thread
1870 "&" gnus-summary-execute-command
1871 "c" gnus-summary-catchup-and-exit
1872 "\C-w" gnus-summary-mark-region-as-read
1873 "\C-t" gnus-summary-toggle-truncation
1874 "?" gnus-summary-mark-as-dormant
1875 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1876 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1877 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1878 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1879 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1880 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1881 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1882 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1883 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1884 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1885 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1886 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1887 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1888 "=" gnus-summary-expand-window
1889 "\C-x\C-s" gnus-summary-reselect-current-group
1890 "\M-g" gnus-summary-rescan-group
1891 "\C-c\C-r" gnus-summary-caesar-message
1892 "f" gnus-summary-followup
1893 "F" gnus-summary-followup-with-original
1894 "C" gnus-summary-cancel-article
1895 "r" gnus-summary-reply
1896 "R" gnus-summary-reply-with-original
1897 "\C-c\C-f" gnus-summary-mail-forward
1898 "o" gnus-summary-save-article
1899 "\C-o" gnus-summary-save-article-mail
1900 "|" gnus-summary-pipe-output
1901 "\M-k" gnus-summary-edit-local-kill
1902 "\M-K" gnus-summary-edit-global-kill
1904 "\C-c\C-d" gnus-summary-describe-group
1905 "q" gnus-summary-exit
1906 "Q" gnus-summary-exit-no-update
1907 "\C-c\C-i" gnus-info-find-node
1908 gnus-mouse-2 gnus-mouse-pick-article
1909 [follow-link] mouse-face
1910 "m" gnus-summary-mail-other-window
1911 "a" gnus-summary-post-news
1912 "x" gnus-summary-limit-to-unread
1913 "s" gnus-summary-isearch-article
1914 [tab] gnus-summary-widget-forward
1915 [backtab] gnus-summary-widget-backward
1916 "t" gnus-summary-toggle-header
1917 "g" gnus-summary-show-article
1918 "l" gnus-summary-goto-last-article
1919 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1920 "\C-d" gnus-summary-enter-digest-group
1921 "\M-\C-d" gnus-summary-read-document
1922 "\M-\C-e" gnus-summary-edit-parameters
1923 "\M-\C-a" gnus-summary-customize-parameters
1925 "*" gnus-cache-enter-article
1926 "\M-*" gnus-cache-remove-article
1927 "\M-&" gnus-summary-universal-argument
1928 "\C-l" gnus-recenter
1929 "I" gnus-summary-increase-score
1930 "L" gnus-summary-lower-score
1931 "\M-i" gnus-symbolic-argument
1932 "h" gnus-summary-select-article-buffer
1934 "b" gnus-article-view-part
1935 "\M-t" gnus-summary-toggle-display-buttonized
1937 "V" gnus-summary-score-map
1938 "X" gnus-uu-extract-map
1939 "S" gnus-summary-send-map)
1941 ;; Sort of orthogonal keymap
1942 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1943 "t" gnus-summary-tick-article-forward
1944 "!" gnus-summary-tick-article-forward
1945 "d" gnus-summary-mark-as-read-forward
1946 "r" gnus-summary-mark-as-read-forward
1947 "c" gnus-summary-clear-mark-forward
1948 " " gnus-summary-clear-mark-forward
1949 "e" gnus-summary-mark-as-expirable
1950 "x" gnus-summary-mark-as-expirable
1951 "?" gnus-summary-mark-as-dormant
1952 "b" gnus-summary-set-bookmark
1953 "B" gnus-summary-remove-bookmark
1954 "#" gnus-summary-mark-as-processable
1955 "\M-#" gnus-summary-unmark-as-processable
1956 "S" gnus-summary-limit-include-expunged
1957 "C" gnus-summary-catchup
1958 "H" gnus-summary-catchup-to-here
1959 "h" gnus-summary-catchup-from-here
1960 "\C-c" gnus-summary-catchup-all
1961 "k" gnus-summary-kill-same-subject-and-select
1962 "K" gnus-summary-kill-same-subject
1963 "P" gnus-uu-mark-map)
1965 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1966 "c" gnus-summary-clear-above
1967 "u" gnus-summary-tick-above
1968 "m" gnus-summary-mark-above
1969 "k" gnus-summary-kill-below)
1971 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1972 "/" gnus-summary-limit-to-subject
1973 "n" gnus-summary-limit-to-articles
1974 "b" gnus-summary-limit-to-bodies
1975 "h" gnus-summary-limit-to-headers
1976 "w" gnus-summary-pop-limit
1977 "s" gnus-summary-limit-to-subject
1978 "a" gnus-summary-limit-to-author
1979 "u" gnus-summary-limit-to-unread
1980 "m" gnus-summary-limit-to-marks
1981 "M" gnus-summary-limit-exclude-marks
1982 "v" gnus-summary-limit-to-score
1983 "*" gnus-summary-limit-include-cached
1984 "D" gnus-summary-limit-include-dormant
1985 "T" gnus-summary-limit-include-thread
1986 "d" gnus-summary-limit-exclude-dormant
1987 "t" gnus-summary-limit-to-age
1988 "." gnus-summary-limit-to-unseen
1989 "x" gnus-summary-limit-to-extra
1990 "p" gnus-summary-limit-to-display-predicate
1991 "E" gnus-summary-limit-include-expunged
1992 "c" gnus-summary-limit-exclude-childless-dormant
1993 "C" gnus-summary-limit-mark-excluded-as-read
1994 "o" gnus-summary-insert-old-articles
1995 "N" gnus-summary-insert-new-articles
1996 "S" gnus-summary-limit-to-singletons
1997 "r" gnus-summary-limit-to-replied
1998 "R" gnus-summary-limit-to-recipient
1999 "A" gnus-summary-limit-to-address)
2001 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2002 "n" gnus-summary-next-unread-article
2003 "p" gnus-summary-prev-unread-article
2004 "N" gnus-summary-next-article
2005 "P" gnus-summary-prev-article
2006 "\C-n" gnus-summary-next-same-subject
2007 "\C-p" gnus-summary-prev-same-subject
2008 "\M-n" gnus-summary-next-unread-subject
2009 "\M-p" gnus-summary-prev-unread-subject
2010 "f" gnus-summary-first-unread-article
2011 "b" gnus-summary-best-unread-article
2012 "j" gnus-summary-goto-article
2013 "g" gnus-summary-goto-subject
2014 "l" gnus-summary-goto-last-article
2015 "o" gnus-summary-pop-article)
2017 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2018 "k" gnus-summary-kill-thread
2019 "E" gnus-summary-expire-thread
2020 "l" gnus-summary-lower-thread
2021 "i" gnus-summary-raise-thread
2022 "T" gnus-summary-toggle-threads
2023 "t" gnus-summary-rethread-current
2024 "^" gnus-summary-reparent-thread
2025 "\M-^" gnus-summary-reparent-children
2026 "s" gnus-summary-show-thread
2027 "S" gnus-summary-show-all-threads
2028 "h" gnus-summary-hide-thread
2029 "H" gnus-summary-hide-all-threads
2030 "n" gnus-summary-next-thread
2031 "p" gnus-summary-prev-thread
2032 "u" gnus-summary-up-thread
2033 "o" gnus-summary-top-thread
2034 "d" gnus-summary-down-thread
2035 "#" gnus-uu-mark-thread
2036 "\M-#" gnus-uu-unmark-thread)
2038 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2039 "g" gnus-summary-prepare
2040 "c" gnus-summary-insert-cached-articles
2041 "d" gnus-summary-insert-dormant-articles
2042 "t" gnus-summary-insert-ticked-articles)
2044 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2045 "c" gnus-summary-catchup-and-exit
2046 "C" gnus-summary-catchup-all-and-exit
2047 "E" gnus-summary-exit-no-update
2048 "Q" gnus-summary-exit
2049 "Z" gnus-summary-exit
2050 "n" gnus-summary-catchup-and-goto-next-group
2051 "p" gnus-summary-catchup-and-goto-prev-group
2052 "R" gnus-summary-reselect-current-group
2053 "G" gnus-summary-rescan-group
2054 "N" gnus-summary-next-group
2055 "s" gnus-summary-save-newsrc
2056 "P" gnus-summary-prev-group)
2058 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2059 " " gnus-summary-next-page
2060 "n" gnus-summary-next-page
2061 "\177" gnus-summary-prev-page
2062 [delete] gnus-summary-prev-page
2063 "p" gnus-summary-prev-page
2064 "\r" gnus-summary-scroll-up
2065 "\M-\r" gnus-summary-scroll-down
2066 "<" gnus-summary-beginning-of-article
2067 ">" gnus-summary-end-of-article
2068 "b" gnus-summary-beginning-of-article
2069 "e" gnus-summary-end-of-article
2070 "^" gnus-summary-refer-parent-article
2071 "r" gnus-summary-refer-parent-article
2072 "C" gnus-summary-show-complete-article
2073 "D" gnus-summary-enter-digest-group
2074 "R" gnus-summary-refer-references
2075 "T" gnus-summary-refer-thread
2076 "W" gnus-warp-to-article
2077 "g" gnus-summary-show-article
2078 "s" gnus-summary-isearch-article
2079 [tab] gnus-summary-widget-forward
2080 [backtab] gnus-summary-widget-backward
2081 "P" gnus-summary-print-article
2082 "S" gnus-sticky-article
2083 "M" gnus-mailing-list-insinuate
2084 "t" gnus-article-babel)
2086 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2087 "b" gnus-article-add-buttons
2088 "B" gnus-article-add-buttons-to-head
2089 "o" gnus-article-treat-overstrike
2090 "e" gnus-article-emphasize
2091 "w" gnus-article-fill-cited-article
2092 "Q" gnus-article-fill-long-lines
2093 "L" gnus-article-toggle-truncate-lines
2094 "C" gnus-article-capitalize-sentences
2095 "c" gnus-article-remove-cr
2096 "q" gnus-article-de-quoted-unreadable
2097 "6" gnus-article-de-base64-unreadable
2098 "Z" gnus-article-decode-HZ
2099 "A" gnus-article-treat-ansi-sequences
2100 "h" gnus-article-wash-html
2101 "u" gnus-article-unsplit-urls
2102 "s" gnus-summary-force-verify-and-decrypt
2103 "f" gnus-article-display-x-face
2104 "l" gnus-summary-stop-page-breaking
2105 "r" gnus-summary-caesar-message
2106 "m" gnus-summary-morse-message
2107 "t" gnus-summary-toggle-header
2108 "g" gnus-treat-smiley
2109 "v" gnus-summary-verbose-headers
2110 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2111 "p" gnus-article-verify-x-pgp-sig
2112 "d" gnus-article-treat-dumbquotes
2113 "U" gnus-article-treat-non-ascii
2114 "i" gnus-summary-idna-message)
2116 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2117 ;; mnemonic: deuglif*Y*
2118 "u" gnus-article-outlook-unwrap-lines
2119 "a" gnus-article-outlook-repair-attribution
2120 "c" gnus-article-outlook-rearrange-citation
2121 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2123 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2124 "a" gnus-article-hide
2125 "h" gnus-article-hide-headers
2126 "b" gnus-article-hide-boring-headers
2127 "s" gnus-article-hide-signature
2128 "c" gnus-article-hide-citation
2129 "C" gnus-article-hide-citation-in-followups
2130 "l" gnus-article-hide-list-identifiers
2131 "B" gnus-article-strip-banner
2132 "P" gnus-article-hide-pem
2133 "\C-c" gnus-article-hide-citation-maybe)
2135 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2136 "a" gnus-article-highlight
2137 "h" gnus-article-highlight-headers
2138 "c" gnus-article-highlight-citation
2139 "s" gnus-article-highlight-signature)
2141 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2142 "f" gnus-article-treat-fold-headers
2143 "u" gnus-article-treat-unfold-headers
2144 "n" gnus-article-treat-fold-newsgroups)
2146 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2147 "x" gnus-article-display-x-face
2148 "d" gnus-article-display-face
2149 "s" gnus-treat-smiley
2150 "D" gnus-article-remove-images
2151 "W" gnus-article-show-images
2152 "f" gnus-treat-from-picon
2153 "m" gnus-treat-mail-picon
2154 "n" gnus-treat-newsgroups-picon
2155 "g" gnus-treat-from-gravatar
2156 "h" gnus-treat-mail-gravatar)
2158 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2159 "w" gnus-article-decode-mime-words
2160 "c" gnus-article-decode-charset
2161 "v" gnus-mime-view-all-parts
2162 "b" gnus-article-view-part)
2164 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2165 "z" gnus-article-date-ut
2166 "u" gnus-article-date-ut
2167 "l" gnus-article-date-local
2168 "p" gnus-article-date-english
2169 "e" gnus-article-date-lapsed
2170 "o" gnus-article-date-original
2171 "i" gnus-article-date-iso8601
2172 "s" gnus-article-date-user)
2174 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2175 "t" gnus-article-remove-trailing-blank-lines
2176 "l" gnus-article-strip-leading-blank-lines
2177 "m" gnus-article-strip-multiple-blank-lines
2178 "a" gnus-article-strip-blank-lines
2179 "A" gnus-article-strip-all-blank-lines
2180 "s" gnus-article-strip-leading-space
2181 "e" gnus-article-strip-trailing-space
2182 "w" gnus-article-remove-leading-whitespace)
2184 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2186 "d" gnus-summary-describe-group
2187 "h" gnus-summary-describe-briefly
2188 "i" gnus-info-find-node)
2190 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2191 "e" gnus-summary-expire-articles
2192 "\M-\C-e" gnus-summary-expire-articles-now
2193 "\177" gnus-summary-delete-article
2194 [delete] gnus-summary-delete-article
2195 [backspace] gnus-summary-delete-article
2196 "m" gnus-summary-move-article
2197 "r" gnus-summary-respool-article
2198 "w" gnus-summary-edit-article
2199 "c" gnus-summary-copy-article
2200 "B" gnus-summary-crosspost-article
2201 "q" gnus-summary-respool-query
2202 "t" gnus-summary-respool-trace
2203 "i" gnus-summary-import-article
2204 "I" gnus-summary-create-article
2205 "p" gnus-summary-article-posted-p)
2207 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2208 "o" gnus-summary-save-article
2209 "m" gnus-summary-save-article-mail
2210 "F" gnus-summary-write-article-file
2211 "r" gnus-summary-save-article-rmail
2212 "f" gnus-summary-save-article-file
2213 "b" gnus-summary-save-article-body-file
2214 "B" gnus-summary-write-article-body-file
2215 "h" gnus-summary-save-article-folder
2216 "v" gnus-summary-save-article-vm
2217 "p" gnus-summary-pipe-output
2218 "P" gnus-summary-muttprint)
2220 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2221 "b" gnus-summary-display-buttonized
2222 "m" gnus-summary-repair-multipart
2223 "v" gnus-article-view-part
2224 "o" gnus-article-save-part
2225 "O" gnus-article-save-part-and-strip
2226 "r" gnus-article-replace-part
2227 "d" gnus-article-delete-part
2228 "t" gnus-article-view-part-as-type
2229 "j" gnus-article-jump-to-part
2230 "c" gnus-article-copy-part
2231 "C" gnus-article-view-part-as-charset
2232 "e" gnus-article-view-part-externally
2233 "H" gnus-article-browse-html-article
2234 "E" gnus-article-encrypt-body
2235 "i" gnus-article-inline-part
2236 "|" gnus-article-pipe-part)
2238 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2239 "p" gnus-summary-mark-as-processable
2240 "u" gnus-summary-unmark-as-processable
2241 "U" gnus-summary-unmark-all-processable
2242 "v" gnus-uu-mark-over
2243 "s" gnus-uu-mark-series
2244 "r" gnus-uu-mark-region
2245 "g" gnus-uu-unmark-region
2246 "R" gnus-uu-mark-by-regexp
2247 "G" gnus-uu-unmark-by-regexp
2248 "t" gnus-uu-mark-thread
2249 "T" gnus-uu-unmark-thread
2250 "a" gnus-uu-mark-all
2251 "b" gnus-uu-mark-buffer
2252 "S" gnus-uu-mark-sparse
2253 "k" gnus-summary-kill-process-mark
2254 "y" gnus-summary-yank-process-mark
2255 "w" gnus-summary-save-process-mark
2256 "i" gnus-uu-invert-processable)
2258 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2259 ;;"x" gnus-uu-extract-any
2260 "m" gnus-summary-save-parts
2261 "u" gnus-uu-decode-uu
2262 "U" gnus-uu-decode-uu-and-save
2263 "s" gnus-uu-decode-unshar
2264 "S" gnus-uu-decode-unshar-and-save
2265 "o" gnus-uu-decode-save
2266 "O" gnus-uu-decode-save
2267 "b" gnus-uu-decode-binhex
2268 "B" gnus-uu-decode-binhex
2269 "Y" gnus-uu-decode-yenc
2270 "p" gnus-uu-decode-postscript
2271 "P" gnus-uu-decode-postscript-and-save)
2274 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2275 "u" gnus-uu-decode-uu-view
2276 "U" gnus-uu-decode-uu-and-save-view
2277 "s" gnus-uu-decode-unshar-view
2278 "S" gnus-uu-decode-unshar-and-save-view
2279 "o" gnus-uu-decode-save-view
2280 "O" gnus-uu-decode-save-view
2281 "b" gnus-uu-decode-binhex-view
2282 "B" gnus-uu-decode-binhex-view
2283 "p" gnus-uu-decode-postscript-view
2284 "P" gnus-uu-decode-postscript-and-save-view)
2286 (defvar gnus-article-post-menu nil)
2288 (defconst gnus-summary-menu-maxlen 20)
2290 (defun gnus-summary-menu-split (menu)
2291 ;; If we have lots of elements, divide them into groups of 20
2292 ;; and make a pane (or submenu) for each one.
2293 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2294 (let ((menu menu) sublists next
2297 ;; Pull off the next gnus-summary-menu-maxlen elements
2298 ;; and make them the next element of sublist.
2299 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2301 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2303 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2304 (aref (car (last menu)) 0)) menu)
2308 (nreverse sublists))
2309 ;; Few elements--put them all in one pane.
2312 (defun gnus-summary-make-menu-bar ()
2313 (gnus-turn-off-edit-menu 'summary)
2315 (unless (boundp 'gnus-summary-misc-menu)
2318 gnus-summary-kill-menu gnus-summary-mode-map ""
2323 ["Customize" gnus-score-customize t])
2324 (gnus-make-score-map 'increase)
2325 (gnus-make-score-map 'lower)
2327 ["Kill below" gnus-summary-kill-below t]
2328 ["Mark above" gnus-summary-mark-above t]
2329 ["Tick above" gnus-summary-tick-above t]
2330 ["Clear above" gnus-summary-clear-above t])
2331 ["Current score" gnus-summary-current-score t]
2332 ["Set score" gnus-summary-set-score t]
2333 ["Switch current score file..." gnus-score-change-score-file t]
2334 ["Set mark below..." gnus-score-set-mark-below t]
2335 ["Set expunge below..." gnus-score-set-expunge-below t]
2336 ["Edit current score file" gnus-score-edit-current-scores t]
2337 ["Edit score file..." gnus-score-edit-file t]
2338 ["Trace score" gnus-score-find-trace t]
2339 ["Find words" gnus-score-find-favourite-words t]
2340 ["Rescore buffer" gnus-summary-rescore t]
2341 ["Increase score..." gnus-summary-increase-score t]
2342 ["Lower score..." gnus-summary-lower-score t]))))
2344 ;; Define both the Article menu in the summary buffer and the
2345 ;; equivalent Commands menu in the article buffer here for
2349 ["All" gnus-article-hide t]
2350 ["Headers" gnus-article-hide-headers t]
2351 ["Signature" gnus-article-hide-signature t]
2352 ["Citation" gnus-article-hide-citation t]
2353 ["List identifiers" gnus-article-hide-list-identifiers t]
2354 ["Banner" gnus-article-strip-banner t]
2355 ["Boring headers" gnus-article-hide-boring-headers t])
2357 ["All" gnus-article-highlight t]
2358 ["Headers" gnus-article-highlight-headers t]
2359 ["Signature" gnus-article-highlight-signature t]
2360 ["Citation" gnus-article-highlight-citation t])
2362 ["Words" gnus-article-decode-mime-words t]
2363 ["Charset" gnus-article-decode-charset t]
2364 ["QP" gnus-article-de-quoted-unreadable t]
2365 ["Base64" gnus-article-de-base64-unreadable t]
2366 ["View MIME buttons" gnus-summary-display-buttonized t]
2367 ["View all" gnus-mime-view-all-parts t]
2368 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2369 ["Encrypt body" gnus-article-encrypt-body
2370 :active (not (gnus-group-read-only-p))
2371 ,@(if (featurep 'xemacs) nil
2372 '(:help "Encrypt the message body on disk"))]
2373 ["Extract all parts..." gnus-summary-save-parts t]
2375 ["Repair multipart" gnus-summary-repair-multipart t]
2376 ["Pipe part..." gnus-article-pipe-part t]
2377 ["Inline part" gnus-article-inline-part t]
2378 ["View part as type..." gnus-article-view-part-as-type t]
2379 ["Encrypt body" gnus-article-encrypt-body
2380 :active (not (gnus-group-read-only-p))
2381 ,@(if (featurep 'xemacs) nil
2382 '(:help "Encrypt the message body on disk"))]
2383 ["View part externally" gnus-article-view-part-externally t]
2384 ["View HTML parts in browser" gnus-article-browse-html-article t]
2385 ["View part with charset..." gnus-article-view-part-as-charset t]
2386 ["Copy part" gnus-article-copy-part t]
2387 ["Save part..." gnus-article-save-part t]
2388 ["View part" gnus-article-view-part t]))
2390 ["Local" gnus-article-date-local t]
2391 ["ISO8601" gnus-article-date-iso8601 t]
2392 ["UT" gnus-article-date-ut t]
2393 ["Original" gnus-article-date-original t]
2394 ["Lapsed" gnus-article-date-lapsed t]
2395 ["User-defined" gnus-article-date-user t])
2397 ["Remove images" gnus-article-remove-images t]
2398 ["Toggle smiley" gnus-treat-smiley t]
2399 ["Show X-Face" gnus-article-display-x-face t]
2400 ["Show picons in From" gnus-treat-from-picon t]
2401 ["Show picons in mail headers" gnus-treat-mail-picon t]
2402 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2403 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2404 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2405 ("View as different encoding"
2406 ,@(gnus-summary-menu-split
2409 ;; Since easymenu under Emacs doesn't allow
2410 ;; lambda forms for menu commands, we should
2411 ;; provide intern'ed function symbols.
2412 (let ((command (intern (format "\
2413 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2417 (let ((gnus-summary-show-article-charset-alist
2419 (gnus-summary-show-article 1))))
2420 `[,(symbol-name cs) ,command t]))
2421 (sort (if (fboundp 'coding-system-list)
2422 (coding-system-list)
2423 (mapcar 'car mm-mime-mule-charset-alist))
2427 ["Leading" gnus-article-strip-leading-blank-lines t]
2428 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2429 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2430 ["All of the above" gnus-article-strip-blank-lines t]
2431 ["All" gnus-article-strip-all-blank-lines t]
2432 ["Leading space" gnus-article-strip-leading-space t]
2433 ["Trailing space" gnus-article-strip-trailing-space t]
2434 ["Leading space in headers"
2435 gnus-article-remove-leading-whitespace t])
2436 ["Overstrike" gnus-article-treat-overstrike t]
2437 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2438 ["Non-ASCII" gnus-article-treat-non-ascii t]
2439 ["Emphasis" gnus-article-emphasize t]
2440 ["Word wrap" gnus-article-fill-cited-article t]
2441 ["Fill long lines" gnus-article-fill-long-lines t]
2442 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2443 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2444 ["Remove CR" gnus-article-remove-cr t]
2445 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2446 ["Base64" gnus-article-de-base64-unreadable t]
2447 ["Rot 13" gnus-summary-caesar-message
2448 ,@(if (featurep 'xemacs) '(t)
2449 '(:help "\"Caesar rotate\" article by 13"))]
2450 ["De-IDNA" gnus-summary-idna-message t]
2451 ["Morse decode" gnus-summary-morse-message t]
2452 ["Unix pipe..." gnus-summary-pipe-message t]
2453 ["Add buttons" gnus-article-add-buttons t]
2454 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2455 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2456 ["Verbose header" gnus-summary-verbose-headers t]
2457 ["Toggle header" gnus-summary-toggle-header t]
2458 ["Unfold headers" gnus-article-treat-unfold-headers t]
2459 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2460 ["Html" gnus-article-wash-html t]
2461 ["Unsplit URLs" gnus-article-unsplit-urls t]
2462 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2463 ["Decode HZ" gnus-article-decode-HZ t]
2464 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2465 ("(Outlook) Deuglify"
2466 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2467 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2468 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2469 ["Full (Outlook) deuglify"
2470 gnus-article-outlook-deuglify-article t])
2473 ["Save in default format..." gnus-summary-save-article
2474 ,@(if (featurep 'xemacs) '(t)
2475 '(:help "Save article using default method"))]
2476 ["Save in file..." gnus-summary-save-article-file
2477 ,@(if (featurep 'xemacs) '(t)
2478 '(:help "Save article in file"))]
2479 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2480 ["Save in MH folder..." gnus-summary-save-article-folder t]
2481 ["Save in VM folder..." gnus-summary-save-article-vm t]
2482 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2483 ["Save body in file..." gnus-summary-save-article-body-file t]
2484 ["Pipe through a filter..." gnus-summary-pipe-output t]
2485 ["Print with Muttprint..." gnus-summary-muttprint t]
2486 ["Print" gnus-summary-print-article
2487 ,@(if (featurep 'xemacs) '(t)
2488 '(:help "Generate and print a PostScript image"))])
2489 ("Copy, move,... (Backend)"
2490 ,@(if (featurep 'xemacs) nil
2491 '(:help "Copying, moving, expiring articles..."))
2492 ["Respool article..." gnus-summary-respool-article t]
2493 ["Move article..." gnus-summary-move-article
2494 (gnus-check-backend-function
2495 'request-move-article gnus-newsgroup-name)]
2496 ["Copy article..." gnus-summary-copy-article t]
2497 ["Crosspost article..." gnus-summary-crosspost-article
2498 (gnus-check-backend-function
2499 'request-replace-article gnus-newsgroup-name)]
2500 ["Import file..." gnus-summary-import-article
2501 (gnus-check-backend-function
2502 'request-accept-article gnus-newsgroup-name)]
2503 ["Create article..." gnus-summary-create-article
2504 (gnus-check-backend-function
2505 'request-accept-article gnus-newsgroup-name)]
2506 ["Check if posted" gnus-summary-article-posted-p t]
2507 ["Edit article" gnus-summary-edit-article
2508 (not (gnus-group-read-only-p))]
2509 ["Delete article" gnus-summary-delete-article
2510 (gnus-check-backend-function
2511 'request-expire-articles gnus-newsgroup-name)]
2512 ["Query respool" gnus-summary-respool-query t]
2513 ["Trace respool" gnus-summary-respool-trace t]
2514 ["Delete expirable articles" gnus-summary-expire-articles-now
2515 (gnus-check-backend-function
2516 'request-expire-articles gnus-newsgroup-name)])
2518 ["Uudecode" gnus-uu-decode-uu
2519 ,@(if (featurep 'xemacs) '(t)
2520 '(:help "Decode uuencoded article(s)"))]
2521 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2522 ["Unshar" gnus-uu-decode-unshar t]
2523 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2524 ["Save" gnus-uu-decode-save t]
2525 ["Binhex" gnus-uu-decode-binhex t]
2526 ["PostScript" gnus-uu-decode-postscript t]
2527 ["All MIME parts" gnus-summary-save-parts t])
2529 ["Enter article" gnus-cache-enter-article t]
2530 ["Remove article" gnus-cache-remove-article t])
2531 ["Translate" gnus-article-babel t]
2532 ["Select article buffer" gnus-summary-select-article-buffer t]
2533 ["Make article buffer sticky" gnus-sticky-article t]
2534 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2535 ["Isearch article..." gnus-summary-isearch-article t]
2536 ["Beginning of the article" gnus-summary-beginning-of-article t]
2537 ["End of the article" gnus-summary-end-of-article t]
2538 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2539 ["Fetch referenced articles" gnus-summary-refer-references t]
2540 ["Fetch current thread" gnus-summary-refer-thread t]
2541 ["Fetch article with id..." gnus-summary-refer-article t]
2542 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2543 ["Redisplay" gnus-summary-show-article t]
2544 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2546 gnus-summary-article-menu gnus-summary-mode-map ""
2547 (cons "Article" innards))
2549 (if (not (keymapp gnus-summary-article-menu))
2551 gnus-article-commands-menu gnus-article-mode-map ""
2552 (cons "Commands" innards))
2553 ;; in Emacs, don't share menu.
2554 (setq gnus-article-commands-menu
2555 (copy-keymap gnus-summary-article-menu))
2556 (define-key gnus-article-mode-map [menu-bar commands]
2557 (cons "Commands" gnus-article-commands-menu))))
2560 gnus-summary-thread-menu gnus-summary-mode-map ""
2562 ["Find all messages in thread" gnus-summary-refer-thread t]
2563 ["Toggle threading" gnus-summary-toggle-threads t]
2564 ["Hide threads" gnus-summary-hide-all-threads t]
2565 ["Show threads" gnus-summary-show-all-threads t]
2566 ["Hide thread" gnus-summary-hide-thread t]
2567 ["Show thread" gnus-summary-show-thread t]
2568 ["Go to next thread" gnus-summary-next-thread t]
2569 ["Go to previous thread" gnus-summary-prev-thread t]
2570 ["Go down thread" gnus-summary-down-thread t]
2571 ["Go up thread" gnus-summary-up-thread t]
2572 ["Top of thread" gnus-summary-top-thread t]
2573 ["Mark thread as read" gnus-summary-kill-thread t]
2574 ["Mark thread as expired" gnus-summary-expire-thread t]
2575 ["Lower thread score" gnus-summary-lower-thread t]
2576 ["Raise thread score" gnus-summary-raise-thread t]
2577 ["Rethread current" gnus-summary-rethread-current t]))
2580 gnus-summary-post-menu gnus-summary-mode-map ""
2582 ["Send a message (mail or news)" gnus-summary-post-news
2583 ,@(if (featurep 'xemacs) '(t)
2584 '(:help "Compose a new message (mail or news)"))]
2585 ["Followup" gnus-summary-followup
2586 ,@(if (featurep 'xemacs) '(t)
2587 '(:help "Post followup to this article"))]
2588 ["Followup and yank" gnus-summary-followup-with-original
2589 ,@(if (featurep 'xemacs) '(t)
2590 '(:help "Post followup to this article, quoting its contents"))]
2591 ["Supersede article" gnus-summary-supersede-article t]
2592 ["Cancel article" gnus-summary-cancel-article
2593 ,@(if (featurep 'xemacs) '(t)
2594 '(:help "Cancel an article you posted"))]
2595 ["Reply" gnus-summary-reply t]
2596 ["Reply and yank" gnus-summary-reply-with-original t]
2597 ["Wide reply" gnus-summary-wide-reply t]
2598 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2599 ,@(if (featurep 'xemacs) '(t)
2600 '(:help "Mail a reply, quoting this article"))]
2601 ["Very wide reply" gnus-summary-very-wide-reply t]
2602 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2603 ,@(if (featurep 'xemacs) '(t)
2604 '(:help "Mail a very wide reply, quoting this article"))]
2605 ["Mail forward" gnus-summary-mail-forward t]
2606 ["Post forward" gnus-summary-post-forward t]
2607 ["Digest and mail" gnus-uu-digest-mail-forward t]
2608 ["Digest and post" gnus-uu-digest-post-forward t]
2609 ["Resend message" gnus-summary-resend-message t]
2610 ["Resend message edit" gnus-summary-resend-message-edit t]
2611 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2612 ["Send a mail" gnus-summary-mail-other-window t]
2613 ["Create a local message" gnus-summary-news-other-window t]
2614 ["Uuencode and post" gnus-uu-post-news
2615 ,@(if (featurep 'xemacs) '(t)
2616 '(:help "Post a uuencoded article"))]
2617 ["Followup via news" gnus-summary-followup-to-mail t]
2618 ["Followup via news and yank"
2619 gnus-summary-followup-to-mail-with-original t]
2620 ["Strip signature on reply"
2623 (if (not (memq message-cite-function
2624 '(message-cite-original-without-signature
2625 message-cite-original)))
2626 ;; Stupid workaround for XEmacs not honoring :visible.
2627 (message "Can't toggle this value of `message-cite-function'")
2628 (setq message-cite-function
2629 (if (eq message-cite-function
2630 'message-cite-original-without-signature)
2631 'message-cite-original
2632 'message-cite-original-without-signature))))
2633 ;; XEmacs barfs on :visible.
2634 ,@(if (featurep 'xemacs) nil
2635 '(:visible (memq message-cite-function
2636 '(message-cite-original-without-signature
2637 message-cite-original))))
2639 :selected (eq message-cite-function
2640 'message-cite-original-without-signature)
2641 ,@(if (featurep 'xemacs) nil
2642 '(:help "Strip signature from cited article when replying."))]
2644 ;;["Send" gnus-summary-send-draft t]
2645 ;;["Send bounced" gnus-resend-bounced-mail t])
2649 ((not (keymapp gnus-summary-post-menu))
2650 (setq gnus-article-post-menu gnus-summary-post-menu))
2651 ((not gnus-article-post-menu)
2652 ;; Don't share post menu.
2653 (setq gnus-article-post-menu
2654 (copy-keymap gnus-summary-post-menu))))
2655 (define-key gnus-article-mode-map [menu-bar post]
2656 (cons "Post" gnus-article-post-menu))
2659 gnus-summary-misc-menu gnus-summary-mode-map ""
2662 ["Mark as read" gnus-summary-mark-as-read-forward t]
2663 ["Mark same subject and select"
2664 gnus-summary-kill-same-subject-and-select t]
2665 ["Mark same subject" gnus-summary-kill-same-subject t]
2666 ["Catchup" gnus-summary-catchup
2667 ,@(if (featurep 'xemacs) '(t)
2668 '(:help "Mark unread articles in this group as read"))]
2669 ["Catchup all" gnus-summary-catchup-all t]
2670 ["Catchup to here" gnus-summary-catchup-to-here t]
2671 ["Catchup from here" gnus-summary-catchup-from-here t]
2672 ["Catchup region" gnus-summary-mark-region-as-read
2673 (gnus-mark-active-p)]
2674 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2676 ["Tick" gnus-summary-tick-article-forward t]
2677 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2678 ["Remove marks" gnus-summary-clear-mark-forward t]
2679 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2680 ["Set bookmark" gnus-summary-set-bookmark t]
2681 ["Remove bookmark" gnus-summary-remove-bookmark t])
2683 ["Marks..." gnus-summary-limit-to-marks t]
2684 ["Subject..." gnus-summary-limit-to-subject t]
2685 ["Author..." gnus-summary-limit-to-author t]
2686 ["Recipient..." gnus-summary-limit-to-recipient t]
2687 ["Address..." gnus-summary-limit-to-address t]
2688 ["Age..." gnus-summary-limit-to-age t]
2689 ["Extra..." gnus-summary-limit-to-extra t]
2690 ["Score..." gnus-summary-limit-to-score t]
2691 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2692 ["Unread" gnus-summary-limit-to-unread t]
2693 ["Unseen" gnus-summary-limit-to-unseen t]
2694 ["Singletons" gnus-summary-limit-to-singletons t]
2695 ["Replied" gnus-summary-limit-to-replied t]
2696 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2697 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2698 ["Pop limit" gnus-summary-pop-limit t]
2699 ["Show dormant" gnus-summary-limit-include-dormant t]
2700 ["Hide childless dormant"
2701 gnus-summary-limit-exclude-childless-dormant t]
2702 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2703 ["Hide marked" gnus-summary-limit-exclude-marks t]
2704 ["Show expunged" gnus-summary-limit-include-expunged t])
2706 ["Set mark" gnus-summary-mark-as-processable t]
2707 ["Remove mark" gnus-summary-unmark-as-processable t]
2708 ["Remove all marks" gnus-summary-unmark-all-processable t]
2709 ["Invert marks" gnus-uu-invert-processable t]
2710 ["Mark above" gnus-uu-mark-over t]
2711 ["Mark series" gnus-uu-mark-series t]
2712 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2713 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2714 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2715 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2716 ["Mark all" gnus-uu-mark-all t]
2717 ["Mark buffer" gnus-uu-mark-buffer t]
2718 ["Mark sparse" gnus-uu-mark-sparse t]
2719 ["Mark thread" gnus-uu-mark-thread t]
2720 ["Unmark thread" gnus-uu-unmark-thread t]
2721 ("Process Mark Sets"
2722 ["Kill" gnus-summary-kill-process-mark t]
2723 ["Yank" gnus-summary-yank-process-mark
2724 gnus-newsgroup-process-stack]
2725 ["Save" gnus-summary-save-process-mark t]
2726 ["Run command on marked..." gnus-summary-universal-argument t]))
2729 ["Page forward" gnus-summary-next-page
2730 ,@(if (featurep 'xemacs) '(t)
2731 '(:help "Show next page of article"))]
2732 ["Page backward" gnus-summary-prev-page
2733 ,@(if (featurep 'xemacs) '(t)
2734 '(:help "Show previous page of article"))]
2735 ["Line forward" gnus-summary-scroll-up t])
2737 ["Next unread article" gnus-summary-next-unread-article t]
2738 ["Previous unread article" gnus-summary-prev-unread-article t]
2739 ["Next article" gnus-summary-next-article t]
2740 ["Previous article" gnus-summary-prev-article t]
2741 ["Next unread subject" gnus-summary-next-unread-subject t]
2742 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2743 ["Next article same subject" gnus-summary-next-same-subject t]
2744 ["Previous article same subject" gnus-summary-prev-same-subject t]
2745 ["First unread article" gnus-summary-first-unread-article t]
2746 ["Best unread article" gnus-summary-best-unread-article t]
2747 ["Go to subject number..." gnus-summary-goto-subject t]
2748 ["Go to article number..." gnus-summary-goto-article t]
2749 ["Go to the last article" gnus-summary-goto-last-article t]
2750 ["Pop article off history" gnus-summary-pop-article t])
2752 ["Sort by number" gnus-summary-sort-by-number t]
2753 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2754 ["Sort by author" gnus-summary-sort-by-author t]
2755 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2756 ["Sort by subject" gnus-summary-sort-by-subject t]
2757 ["Sort by date" gnus-summary-sort-by-date t]
2758 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2759 ["Sort by score" gnus-summary-sort-by-score t]
2760 ["Sort by lines" gnus-summary-sort-by-lines t]
2761 ["Sort by characters" gnus-summary-sort-by-chars t]
2762 ["Randomize" gnus-summary-sort-by-random t]
2763 ["Original sort" gnus-summary-sort-by-original t])
2765 ["Describe group" gnus-summary-describe-group t]
2766 ["Read manual" gnus-info-find-node t])
2768 ["Pick and read" gnus-pick-mode t]
2769 ["Binary" gnus-binary-mode t])
2771 ["Regenerate" gnus-summary-prepare t]
2772 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2773 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2774 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2775 ["Toggle threading" gnus-summary-toggle-threads t])
2776 ["See old articles" gnus-summary-insert-old-articles t]
2777 ["See new articles" gnus-summary-insert-new-articles t]
2778 ["Filter articles..." gnus-summary-execute-command t]
2779 ["Run command on articles..." gnus-summary-universal-argument t]
2780 ["Search articles forward..." gnus-summary-search-article-forward t]
2781 ["Search articles backward..." gnus-summary-search-article-backward t]
2782 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2783 ["Expand window" gnus-summary-expand-window t]
2784 ["Expire expirable articles" gnus-summary-expire-articles
2785 (gnus-check-backend-function
2786 'request-expire-articles gnus-newsgroup-name)]
2787 ["Edit local kill file" gnus-summary-edit-local-kill t]
2788 ["Edit main kill file" gnus-summary-edit-global-kill t]
2789 ["Edit group parameters" gnus-summary-edit-parameters t]
2790 ["Customize group parameters" gnus-summary-customize-parameters t]
2791 ["Send a bug report" gnus-bug t]
2793 ["Catchup and exit" gnus-summary-catchup-and-exit
2794 ,@(if (featurep 'xemacs) '(t)
2795 '(:help "Mark unread articles in this group as read, then exit"))]
2796 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2797 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2798 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2799 ["Exit group" gnus-summary-exit
2800 ,@(if (featurep 'xemacs) '(t)
2801 '(:help "Exit current group, return to group selection mode"))]
2802 ["Exit group without updating" gnus-summary-exit-no-update t]
2803 ["Exit and goto next group" gnus-summary-next-group t]
2804 ["Exit and goto prev group" gnus-summary-prev-group t]
2805 ["Reselect group" gnus-summary-reselect-current-group t]
2806 ["Rescan group" gnus-summary-rescan-group t]
2807 ["Update dribble" gnus-summary-save-newsrc t])))
2809 (gnus-run-hooks 'gnus-summary-menu-hook)))
2811 (defvar gnus-summary-tool-bar-map nil)
2813 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2814 ;; affect _new_ message buffers. We might add a function that walks thru all
2815 ;; summary-mode buffers and force the update.
2816 (defun gnus-summary-tool-bar-update (&optional symbol value)
2817 "Update summary mode toolbar.
2818 Setter function for custom variables."
2819 (setq-default gnus-summary-tool-bar-map nil)
2821 ;; When used as ":set" function:
2822 (set-default symbol value))
2823 (when (gnus-buffer-live-p gnus-summary-buffer)
2824 (with-current-buffer gnus-summary-buffer
2825 (gnus-summary-make-tool-bar))))
2827 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2828 'gnus-summary-tool-bar-gnome
2829 'gnus-summary-tool-bar-retro)
2830 "Specifies the Gnus summary tool bar.
2832 It can be either a list or a symbol referring to a list. See
2833 `gmm-tool-bar-from-list' for the format of the list. The
2834 default key map is `gnus-summary-mode-map'.
2836 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2837 `gnus-summary-tool-bar-retro'."
2838 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2839 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2840 (repeat :tag "User defined list" gmm-tool-bar-item)
2842 :version "23.1" ;; No Gnus
2843 :initialize 'custom-initialize-default
2844 :set 'gnus-summary-tool-bar-update
2845 :group 'gnus-summary)
2847 (defcustom gnus-summary-tool-bar-gnome
2848 '((gnus-summary-post-news "mail/compose" nil)
2849 (gnus-summary-insert-new-articles "mail/inbox" nil
2850 :visible (or (not gnus-agent)
2852 (gnus-summary-reply-with-original "mail/reply")
2853 (gnus-summary-reply "mail/reply" nil :visible nil)
2854 (gnus-summary-followup-with-original "mail/reply-all")
2855 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2856 (gnus-summary-mail-forward "mail/forward")
2857 (gnus-summary-save-article "mail/save")
2858 (gnus-summary-search-article-forward "search" nil :visible nil)
2859 (gnus-summary-print-article "print")
2860 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2861 ;; Some new commands that may need more suitable icons:
2862 (gnus-summary-save-newsrc "save" nil :visible nil)
2863 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2864 (gnus-summary-prev-article "left-arrow")
2865 (gnus-summary-next-article "right-arrow")
2866 (gnus-summary-next-page "next-page")
2867 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2869 ;; Maybe some sort-by-... could be added:
2870 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2871 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2872 (gnus-summary-mark-as-expirable
2874 :visible (gnus-check-backend-function 'request-expire-articles
2875 gnus-newsgroup-name))
2876 (gnus-summary-mark-as-spam
2878 :visible (and (fboundp 'spam-group-ham-contents-p)
2879 (spam-group-ham-contents-p gnus-newsgroup-name))
2880 :help "Mark as spam")
2881 (gnus-summary-mark-as-read-forward
2883 :visible (and (fboundp 'spam-group-spam-contents-p)
2884 (spam-group-spam-contents-p gnus-newsgroup-name)))
2886 (gnus-summary-exit "exit")
2887 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2888 (gnus-info-find-node "help"))
2889 "List of functions for the summary tool bar (GNOME style).
2891 See `gmm-tool-bar-from-list' for the format of the list."
2892 :type '(repeat gmm-tool-bar-item)
2893 :version "23.1" ;; No Gnus
2894 :initialize 'custom-initialize-default
2895 :set 'gnus-summary-tool-bar-update
2896 :group 'gnus-summary)
2898 (defcustom gnus-summary-tool-bar-retro
2899 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2900 (gnus-summary-next-unread-article "gnus/next-ur")
2901 (gnus-summary-post-news "gnus/post")
2902 (gnus-summary-followup-with-original "gnus/fuwo")
2903 (gnus-summary-followup "gnus/followup")
2904 (gnus-summary-reply-with-original "gnus/reply-wo")
2905 (gnus-summary-reply "gnus/reply")
2906 (gnus-summary-caesar-message "gnus/rot13")
2907 (gnus-uu-decode-uu "gnus/uu-decode")
2908 (gnus-summary-save-article-file "gnus/save-aif")
2909 (gnus-summary-save-article "gnus/save-art")
2910 (gnus-uu-post-news "gnus/uu-post")
2911 (gnus-summary-catchup "gnus/catchup")
2912 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2913 (gnus-summary-exit "gnus/exit-summ")
2914 ;; Some new command that may need more suitable icons:
2915 (gnus-summary-print-article "gnus/print" nil :visible nil)
2916 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2917 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2918 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2919 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2920 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2921 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2923 (gnus-info-find-node "gnus/help" nil :visible nil))
2924 "List of functions for the summary tool bar (retro look).
2926 See `gmm-tool-bar-from-list' for the format of the list."
2927 :type '(repeat gmm-tool-bar-item)
2928 :version "23.1" ;; No Gnus
2929 :initialize 'custom-initialize-default
2930 :set 'gnus-summary-tool-bar-update
2931 :group 'gnus-summary)
2933 (defcustom gnus-summary-tool-bar-zap-list t
2934 "List of icon items from the global tool bar.
2935 These items are not displayed in the Gnus summary mode tool bar.
2937 See `gmm-tool-bar-from-list' for the format of the list."
2938 :type 'gmm-tool-bar-zap-list
2939 :version "23.1" ;; No Gnus
2940 :initialize 'custom-initialize-default
2941 :set 'gnus-summary-tool-bar-update
2942 :group 'gnus-summary)
2944 (defvar image-load-path)
2945 (defvar tool-bar-map)
2947 (defun gnus-summary-make-tool-bar (&optional force)
2948 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2949 When FORCE, rebuild the tool bar."
2950 (when (and (not (featurep 'xemacs))
2951 (boundp 'tool-bar-mode)
2953 (or (not gnus-summary-tool-bar-map) force))
2955 (gmm-image-load-path-for-library "gnus"
2958 (image-load-path (cons (car load-path)
2959 (when (boundp 'image-load-path)
2961 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2962 gnus-summary-tool-bar-zap-list
2963 'gnus-summary-mode-map)))
2965 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2967 (setq gnus-summary-tool-bar-map map))))
2968 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2970 (defun gnus-make-score-map (type)
2971 "Make a summary score map of type TYPE."
2974 (let ((headers '(("author" "from" string)
2975 ("subject" "subject" string)
2976 ("article body" "body" string)
2977 ("article head" "head" string)
2978 ("xref" "xref" string)
2979 ("extra header" "extra" string)
2980 ("lines" "lines" number)
2981 ("followups to author" "followup" string)))
2982 (types '((number ("less than" <)
2985 (string ("substring" s)
2989 (perms '(("temporary" (current-time-string))
2997 (if (eq type 'lower)
3002 (setq header (car headers))
3008 (let ((ts (cdr (assoc (nth 2 header) types)))
3024 'gnus-summary-score-entry
3026 (if (or (string= (nth 1 header)
3028 (string= (nth 1 header)
3031 (list 'gnus-summary-header
3033 (list 'quote (nth 1 (car ts)))
3034 (list 'gnus-score-delta-default
3041 (list (nreverse outp))))
3044 (list (nreverse outt))))
3046 (setq headers (cdr headers)))
3047 (list (nreverse outh))))))))
3050 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3051 (defvar bookmark-make-record-function)
3053 (defvar bidi-paragraph-direction)
3055 (defun gnus-summary-mode (&optional group)
3056 "Major mode for reading articles.
3058 All normal editing commands are switched off.
3059 \\<gnus-summary-mode-map>
3060 Each line in this buffer represents one article. To read an
3061 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3062 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3065 You can also post articles and send mail from this buffer. To
3066 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3067 of an article, type `\\[gnus-summary-reply]'.
3069 There are approx. one gazillion commands you can execute in this
3070 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3072 The following commands are available:
3074 \\{gnus-summary-mode-map}"
3076 (kill-all-local-variables)
3077 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3078 (gnus-summary-make-local-variables))
3079 (gnus-summary-make-local-variables)
3080 (setq gnus-newsgroup-name group)
3081 (when (gnus-visual-p 'summary-menu 'menu)
3082 (gnus-summary-make-menu-bar)
3083 (gnus-summary-make-tool-bar))
3084 (gnus-make-thread-indent-array)
3085 (gnus-simplify-mode-line)
3086 (setq major-mode 'gnus-summary-mode)
3087 (setq mode-name "Summary")
3088 (use-local-map gnus-summary-mode-map)
3089 (buffer-disable-undo)
3090 (setq buffer-read-only t ;Disable modification
3091 show-trailing-whitespace nil)
3092 (setq truncate-lines t)
3093 ;; Force paragraph direction to be left-to-right. Don't make it
3094 ;; bound globally in old Emacsen and XEmacsen.
3095 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3096 (add-to-invisibility-spec '(gnus-sum . t))
3097 (gnus-summary-set-display-table)
3098 (gnus-set-default-directory)
3099 (make-local-variable 'gnus-summary-line-format)
3100 (make-local-variable 'gnus-summary-line-format-spec)
3101 (make-local-variable 'gnus-summary-dummy-line-format)
3102 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3103 (make-local-variable 'gnus-summary-mark-positions)
3104 (gnus-make-local-hook 'pre-command-hook)
3105 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3106 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3107 (turn-on-gnus-mailing-list-mode)
3108 (mm-enable-multibyte)
3109 (set (make-local-variable 'bookmark-make-record-function)
3110 'gnus-summary-bookmark-make-record)
3111 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3112 (gnus-update-summary-mark-positions))
3114 (defun gnus-summary-make-local-variables ()
3115 "Make all the local summary buffer variables."
3117 (dolist (local gnus-summary-local-variables)
3120 (if (eq (cdr local) 'global)
3121 ;; Copy the global value of the variable.
3122 (setq global (symbol-value (car local)))
3123 ;; Use the value from the list.
3124 (setq global (eval (cdr local))))
3125 (set (make-local-variable (car local)) global))
3126 ;; Simple nil-valued local variable.
3127 (set (make-local-variable local) nil)))))
3129 ;; Summary data functions.
3131 (defmacro gnus-data-number (data)
3134 (defmacro gnus-data-set-number (data number)
3135 `(setcar ,data ,number))
3137 (defmacro gnus-data-mark (data)
3140 (defmacro gnus-data-set-mark (data mark)
3141 `(setcar (nthcdr 1 ,data) ,mark))
3143 (defmacro gnus-data-pos (data)
3146 (defmacro gnus-data-set-pos (data pos)
3147 `(setcar (nthcdr 2 ,data) ,pos))
3149 (defmacro gnus-data-header (data)
3152 (defmacro gnus-data-set-header (data header)
3153 `(setf (nth 3 ,data) ,header))
3155 (defmacro gnus-data-level (data)
3158 (defmacro gnus-data-unread-p (data)
3159 `(= (nth 1 ,data) gnus-unread-mark))
3161 (defmacro gnus-data-read-p (data)
3162 `(/= (nth 1 ,data) gnus-unread-mark))
3164 (defmacro gnus-data-pseudo-p (data)
3165 `(consp (nth 3 ,data)))
3167 (defmacro gnus-data-find (number)
3168 `(assq ,number gnus-newsgroup-data))
3170 (defmacro gnus-data-find-list (number &optional data)
3171 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3172 (memq (assq ,number bdata)
3175 (defmacro gnus-data-make (number mark pos header level)
3176 `(list ,number ,mark ,pos ,header ,level))
3178 (defun gnus-data-enter (after-article number mark pos header level offset)
3179 (let ((data (gnus-data-find-list after-article)))
3181 (error "No such article: %d" after-article))
3182 (setcdr data (cons (gnus-data-make number mark pos header level)
3184 (setq gnus-newsgroup-data-reverse nil)
3185 (gnus-data-update-list (cddr data) offset)))
3187 (defun gnus-data-enter-list (after-article list &optional offset)
3189 (let ((data (and after-article (gnus-data-find-list after-article)))
3193 (let ((odata gnus-newsgroup-data))
3194 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3196 (gnus-data-update-list odata offset)))
3197 ;; Find the last element in the list to be spliced into the main
3199 (setq list (last list))
3202 (setcdr list gnus-newsgroup-data)
3203 (setq gnus-newsgroup-data ilist)
3205 (gnus-data-update-list (cdr list) offset)))
3206 (setcdr list (cdr data))
3209 (gnus-data-update-list (cdr list) offset))))
3210 (setq gnus-newsgroup-data-reverse nil))))
3212 (defun gnus-data-remove (article &optional offset)
3213 (let ((data gnus-newsgroup-data))
3214 (if (= (gnus-data-number (car data)) article)
3216 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3217 gnus-newsgroup-data-reverse nil)
3219 (gnus-data-update-list gnus-newsgroup-data offset)))
3221 (when (= (gnus-data-number (cadr data)) article)
3222 (setcdr data (cddr data))
3224 (gnus-data-update-list (cdr data) offset))
3226 gnus-newsgroup-data-reverse nil))
3227 (setq data (cdr data))))))
3229 (defmacro gnus-data-list (backward)
3231 (or gnus-newsgroup-data-reverse
3232 (setq gnus-newsgroup-data-reverse
3233 (reverse gnus-newsgroup-data)))
3234 gnus-newsgroup-data))
3236 (defun gnus-data-update-list (data offset)
3237 "Add OFFSET to the POS of all data entries in DATA."
3238 (setq gnus-newsgroup-data-reverse nil)
3240 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3241 (setq data (cdr data))))
3243 (defun gnus-summary-article-pseudo-p (article)
3244 "Say whether this article is a pseudo article or not."
3245 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3247 (defmacro gnus-summary-article-sparse-p (article)
3248 "Say whether this article is a sparse article or not."
3249 `(memq ,article gnus-newsgroup-sparse))
3251 (defmacro gnus-summary-article-ancient-p (article)
3252 "Say whether this article is a sparse article or not."
3253 `(memq ,article gnus-newsgroup-ancient))
3255 (defun gnus-article-children (number)
3256 "Return a list of all children to NUMBER."
3257 (let* ((data (gnus-data-find-list number))
3258 (level (gnus-data-level (car data)))
3260 (setq data (cdr data))
3262 (= (gnus-data-level (car data)) (1+ level)))
3263 (push (gnus-data-number (car data)) children)
3264 (setq data (cdr data)))
3267 (defmacro gnus-summary-skip-intangible ()
3268 "If the current article is intangible, then jump to a different article."
3269 '(let ((to (get-text-property (point) 'gnus-intangible)))
3270 (and to (gnus-summary-goto-subject to))))
3272 (defmacro gnus-summary-article-intangible-p ()
3273 "Say whether this article is intangible or not."
3274 '(get-text-property (point) 'gnus-intangible))
3276 ;; Some summary mode macros.
3278 (defmacro gnus-summary-article-number ()
3279 "The article number of the article on the current line.
3280 If there isn't an article number here, then we return the current
3283 (gnus-summary-skip-intangible)
3284 (or (get-text-property (point) 'gnus-number)
3285 (gnus-summary-last-subject))))
3287 (defmacro gnus-summary-article-header (&optional number)
3288 "Return the header of article NUMBER."
3289 `(gnus-data-header (gnus-data-find
3290 ,(or number '(gnus-summary-article-number)))))
3292 (defmacro gnus-summary-thread-level (&optional number)
3293 "Return the level of thread that starts with article NUMBER."
3294 `(if (and (eq gnus-summary-make-false-root 'dummy)
3295 (get-text-property (point) 'gnus-intangible))
3297 (gnus-data-level (gnus-data-find
3298 ,(or number '(gnus-summary-article-number))))))
3300 (defmacro gnus-summary-article-mark (&optional number)
3301 "Return the mark of article NUMBER."
3302 `(gnus-data-mark (gnus-data-find
3303 ,(or number '(gnus-summary-article-number)))))
3305 (defmacro gnus-summary-article-pos (&optional number)
3306 "Return the position of the line of article NUMBER."
3307 `(gnus-data-pos (gnus-data-find
3308 ,(or number '(gnus-summary-article-number)))))
3310 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3311 (defmacro gnus-summary-article-subject (&optional number)
3312 "Return current subject string or nil if nothing."
3315 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3316 '(gnus-data-header (assq (gnus-summary-article-number)
3317 gnus-newsgroup-data)))))
3320 (mail-header-subject headers))))
3322 (defmacro gnus-summary-article-score (&optional number)
3323 "Return current article score."
3324 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3325 gnus-newsgroup-scored))
3326 gnus-summary-default-score 0))
3328 (defun gnus-summary-article-children (&optional number)
3329 "Return a list of article numbers that are children of article NUMBER."
3330 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3331 (level (gnus-data-level (car data)))
3333 (while (and (setq data (cdr data))
3334 (> (setq l (gnus-data-level (car data))) level))
3335 (and (= (1+ level) l)
3336 (push (gnus-data-number (car data))
3338 (nreverse children)))
3340 (defun gnus-summary-article-parent (&optional number)
3341 "Return the article number of the parent of article NUMBER."
3342 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3343 (gnus-data-list t)))
3344 (level (gnus-data-level (car data))))
3346 () ; This is a root.
3347 ;; We search until we find an article with a level less than
3348 ;; this one. That function has to be the parent.
3349 (while (and (setq data (cdr data))
3350 (not (< (gnus-data-level (car data)) level))))
3351 (and data (gnus-data-number (car data))))))
3353 (defun gnus-unread-mark-p (mark)
3354 "Say whether MARK is the unread mark."
3355 (= mark gnus-unread-mark))
3357 (defun gnus-read-mark-p (mark)
3358 "Say whether MARK is one of the marks that mark as read.
3359 This is all marks except unread, ticked, dormant, and expirable."
3360 (not (or (= mark gnus-unread-mark)
3361 (= mark gnus-ticked-mark)
3362 (= mark gnus-spam-mark)
3363 (= mark gnus-dormant-mark)
3364 (= mark gnus-expirable-mark))))
3366 (defmacro gnus-article-mark (number)
3367 "Return the MARK of article NUMBER.
3368 This macro should only be used when computing the mark the \"first\"
3369 time; i.e., when generating the summary lines. After that,
3370 `gnus-summary-article-mark' should be used to examine the
3373 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3374 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3375 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3376 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3377 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3378 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3379 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3380 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3381 gnus-ancient-mark))))
3383 ;; Saving hidden threads.
3385 (defmacro gnus-save-hidden-threads (&rest forms)
3386 "Save hidden threads, eval FORMS, and restore the hidden threads."
3387 (let ((config (make-symbol "config")))
3388 `(let ((,config (gnus-hidden-threads-configuration)))
3392 (gnus-restore-hidden-threads-configuration ,config)))))
3393 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3394 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3396 (defun gnus-data-compute-positions ()
3397 "Compute the positions of all articles."
3398 (setq gnus-newsgroup-data-reverse nil)
3399 (let ((data gnus-newsgroup-data))
3401 (gnus-save-hidden-threads
3402 (gnus-summary-show-all-threads)
3403 (goto-char (point-min))
3405 (while (get-text-property (point) 'gnus-intangible)
3407 (gnus-data-set-pos (car data) (+ (point) 3))
3408 (setq data (cdr data))
3409 (forward-line 1))))))
3411 (defun gnus-hidden-threads-configuration ()
3412 "Return the current hidden threads configuration."
3415 (goto-char (point-min))
3417 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3418 (push (save-excursion (forward-line 0) (point)) config))
3422 (defun gnus-restore-hidden-threads-configuration (config)
3423 "Restore hidden threads configuration from CONFIG."
3425 (let (point (inhibit-read-only t))
3426 (while (setq point (pop config))
3428 (gnus-summary-hide-thread)))))
3430 ;; Various summary mode internalish functions.
3432 (defun gnus-mouse-pick-article (e)
3435 (gnus-summary-next-page nil t))
3437 (defun gnus-summary-set-display-table ()
3438 "Change the display table.
3439 Odd characters have a tendency to mess
3440 up nicely formatted displays - we make all possible glyphs
3441 display only a single character."
3443 ;; We start from the standard display table, if any.
3444 (let ((table (or (copy-sequence standard-display-table)
3445 (make-display-table)))
3447 ;; Nix out all the control chars...
3448 (while (>= (setq i (1- i)) 0)
3449 (gnus-put-display-table i [??] table))
3450 ;; ... but not newline and cr, of course. (cr is necessary for the
3451 ;; selective display).
3452 (gnus-put-display-table ?\n nil table)
3453 (gnus-put-display-table ?\r nil table)
3454 ;; We keep TAB as well.
3455 (gnus-put-display-table ?\t nil table)
3456 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3457 ;; Emacs 23 (unicode), that are not set already.
3458 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3461 (while (>= (setq i (1- i)) 127)
3462 ;; Only modify if the entry is nil.
3463 (unless (gnus-get-display-table i table)
3464 (gnus-put-display-table i [??] table))))
3465 (setq buffer-display-table table)))
3467 (defun gnus-summary-set-article-display-arrow (pos)
3468 "Update the overlay arrow to point to line at position POS."
3469 (when gnus-summary-display-arrow
3470 (make-local-variable 'overlay-arrow-position)
3471 (make-local-variable 'overlay-arrow-string)
3475 (unless overlay-arrow-position
3476 (setq overlay-arrow-position (make-marker)))
3477 (setq overlay-arrow-string "=>"
3478 overlay-arrow-position (set-marker overlay-arrow-position
3480 (current-buffer))))))
3482 (defun gnus-summary-setup-buffer (group)
3483 "Initialize summary buffer.
3484 If the setup was successful, non-nil is returned."
3485 (let ((buffer (gnus-summary-buffer-name group))
3486 (dead-name (concat "*Dead Summary "
3487 (gnus-group-decoded-name group) "*")))
3488 ;; If a dead summary buffer exists, we kill it.
3489 (when (gnus-buffer-live-p dead-name)
3490 (gnus-kill-buffer dead-name))
3491 (if (get-buffer buffer)
3494 (setq gnus-summary-buffer (current-buffer))
3495 (not gnus-newsgroup-prepared))
3496 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3497 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3498 (gnus-summary-mode group)
3499 (when (gnus-group-quit-config group)
3500 (set (make-local-variable 'gnus-single-article-buffer) nil))
3501 (make-local-variable 'gnus-article-buffer)
3502 (make-local-variable 'gnus-article-current)
3503 (make-local-variable 'gnus-original-article-buffer)
3504 (setq gnus-newsgroup-name group)
3505 ;; Set any local variables in the group parameters.
3506 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3509 (defun gnus-set-global-variables ()
3510 "Set the global equivalents of the buffer-local variables.
3511 They are set to the latest values they had. These reflect the summary
3512 buffer that was in action when the last article was fetched."
3513 (when (eq major-mode 'gnus-summary-mode)
3514 (setq gnus-summary-buffer (current-buffer))
3515 (let ((name gnus-newsgroup-name)
3516 (marked gnus-newsgroup-marked)
3517 (spam gnus-newsgroup-spam-marked)
3518 (unread gnus-newsgroup-unreads)
3519 (headers gnus-current-headers)
3520 (data gnus-newsgroup-data)
3521 (summary gnus-summary-buffer)
3522 (article-buffer gnus-article-buffer)
3523 (original gnus-original-article-buffer)
3524 (gac gnus-article-current)
3525 (reffed gnus-reffed-article-number)
3526 (score-file gnus-current-score-file)
3527 (default-charset gnus-newsgroup-charset)
3529 (let ((locals gnus-newsgroup-variables))
3531 (if (consp (car locals))
3532 (push (eval (caar locals)) vlist)
3533 (push (eval (car locals)) vlist))
3534 (setq locals (cdr locals)))
3535 (setq vlist (nreverse vlist)))
3537 (setq gnus-newsgroup-name name
3538 gnus-newsgroup-marked marked
3539 gnus-newsgroup-spam-marked spam
3540 gnus-newsgroup-unreads unread
3541 gnus-current-headers headers
3542 gnus-newsgroup-data data
3543 gnus-article-current gac
3544 gnus-summary-buffer summary
3545 gnus-article-buffer article-buffer
3546 gnus-original-article-buffer original
3547 gnus-reffed-article-number reffed
3548 gnus-current-score-file score-file
3549 gnus-newsgroup-charset default-charset)
3550 (let ((locals gnus-newsgroup-variables))
3552 (if (consp (car locals))
3553 (set (caar locals) (pop vlist))
3554 (set (car locals) (pop vlist)))
3555 (setq locals (cdr locals))))
3556 ;; The article buffer also has local variables.
3557 (when (gnus-buffer-live-p gnus-article-buffer)
3558 (set-buffer gnus-article-buffer)
3559 (setq gnus-summary-buffer summary))))))
3561 (defun gnus-summary-article-unread-p (article)
3562 "Say whether ARTICLE is unread or not."
3563 (memq article gnus-newsgroup-unreads))
3565 (defun gnus-summary-first-article-p (&optional article)
3566 "Return whether ARTICLE is the first article in the buffer."
3567 (if (not (setq article (or article (gnus-summary-article-number))))
3569 (eq article (caar gnus-newsgroup-data))))
3571 (defun gnus-summary-last-article-p (&optional article)
3572 "Return whether ARTICLE is the last article in the buffer."
3573 (if (not (setq article (or article (gnus-summary-article-number))))
3574 ;; All non-existent numbers are the last article. :-)
3576 (not (cdr (gnus-data-find-list article)))))
3578 (defun gnus-make-thread-indent-array (&optional n)
3580 (progn (setq n 200) nil)
3581 (null gnus-thread-indent-array)
3582 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3583 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3584 gnus-thread-indent-array-level gnus-thread-indent-level)
3586 (aset gnus-thread-indent-array n
3587 (make-string (* n gnus-thread-indent-level) ? ))
3590 (defun gnus-update-summary-mark-positions ()
3591 "Compute where the summary marks are to go."
3593 (when (gnus-buffer-exists-p gnus-summary-buffer)
3594 (set-buffer gnus-summary-buffer))
3595 (let ((spec gnus-summary-line-format-spec)
3598 (gnus-set-work-buffer)
3599 (let ((gnus-tmp-unread ?Z)
3600 (gnus-replied-mark ?Z)
3601 (gnus-score-below-mark ?Z)
3602 (gnus-score-over-mark ?Z)
3603 (gnus-undownloaded-mark ?Z)
3604 (gnus-summary-line-format-spec spec)
3605 (gnus-newsgroup-downloadable '(0))
3606 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3607 case-fold-search ignores)
3608 ;; Here, all marks are bound to Z.
3609 (gnus-summary-insert-line header
3610 0 nil t gnus-tmp-unread t nil "" nil 1)
3611 (goto-char (point-min))
3612 ;; Memorize the positions of the same characters as dummy marks.
3613 (while (re-search-forward "[A-D]" nil t)
3614 (push (point) ignores))
3616 ;; We use A-D as dummy marks in order to know column positions
3617 ;; where marks should be inserted.
3618 (setq gnus-tmp-unread ?A
3619 gnus-replied-mark ?B
3620 gnus-score-below-mark ?C
3621 gnus-score-over-mark ?C
3622 gnus-undownloaded-mark ?D)
3623 (gnus-summary-insert-line header
3624 0 nil t gnus-tmp-unread t nil "" nil 1)
3625 ;; Ignore characters which aren't dummy marks.
3627 (delete-region (goto-char (1- p)) p)
3629 (goto-char (point-min))
3630 (setq pos (list (cons 'unread
3631 (and (search-forward "A" nil t)
3632 (- (point) (point-min) 1)))))
3633 (goto-char (point-min))
3634 (push (cons 'replied (and (search-forward "B" nil t)
3635 (- (point) (point-min) 1)))
3637 (goto-char (point-min))
3638 (push (cons 'score (and (search-forward "C" nil t)
3639 (- (point) (point-min) 1)))
3641 (goto-char (point-min))
3642 (push (cons 'download (and (search-forward "D" nil t)
3643 (- (point) (point-min) 1)))
3645 (setq gnus-summary-mark-positions pos))))
3647 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3648 "Insert a dummy root in the summary buffer."
3650 (gnus-add-text-properties
3651 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3652 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3654 (defun gnus-summary-extract-address-component (from)
3655 (or (car (funcall gnus-extract-address-components from))
3658 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3659 (let ((mail-parse-charset gnus-newsgroup-charset)
3660 (ignored-from-addresses (gnus-ignored-from-addresses))
3661 ; Is it really necessary to do this next part for each summary line?
3662 ; Luckily, doesn't seem to slow things down much.
3663 (mail-parse-ignored-charsets
3664 (with-current-buffer gnus-summary-buffer
3665 gnus-newsgroup-ignored-charsets)))
3667 (and ignored-from-addresses
3668 (string-match ignored-from-addresses gnus-tmp-from)
3669 (let ((extra-headers (mail-header-extra header))
3673 ((setq to (cdr (assq 'To extra-headers)))
3674 (concat gnus-summary-to-prefix
3676 (gnus-summary-extract-address-component
3677 (funcall gnus-decode-encoded-address-function to)))))
3680 (cdr (assq 'Newsgroups extra-headers))
3682 (memq 'Newsgroups gnus-extra-headers)
3683 (eq (car (gnus-find-method-for-group
3684 gnus-newsgroup-name)) 'nntp)
3685 (gnus-group-real-name gnus-newsgroup-name))))
3686 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3687 (gnus-string-mark-left-to-right
3689 (gnus-summary-extract-address-component gnus-tmp-from))))))
3691 (defun gnus-summary-insert-line (gnus-tmp-header
3692 gnus-tmp-level gnus-tmp-current
3693 undownloaded gnus-tmp-unread gnus-tmp-replied
3694 gnus-tmp-expirable gnus-tmp-subject-or-nil
3695 &optional gnus-tmp-dummy gnus-tmp-score
3697 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3698 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3700 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3701 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3702 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3703 (gnus-tmp-score-char
3704 (if (or (null gnus-summary-default-score)
3705 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3706 gnus-summary-zcore-fuzz))
3708 (if (< gnus-tmp-score gnus-summary-default-score)
3709 gnus-score-below-mark gnus-score-over-mark)))
3710 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3712 (cond (gnus-tmp-process gnus-process-mark)
3713 ((memq gnus-tmp-current gnus-newsgroup-cached)
3715 (gnus-tmp-replied gnus-replied-mark)
3716 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3717 gnus-forwarded-mark)
3718 ((memq gnus-tmp-current gnus-newsgroup-saved)
3720 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3723 (gnus-tmp-downloaded
3725 gnus-undownloaded-mark)
3726 (gnus-newsgroup-agentized
3727 gnus-downloaded-mark)
3730 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3733 ((string-match "<[^>]+> *$" gnus-tmp-from)
3734 (let ((beg (match-beginning 0)))
3735 (or (and (string-match "^\".+\"" gnus-tmp-from)
3736 (substring gnus-tmp-from 1 (1- (match-end 0))))
3737 (substring gnus-tmp-from 0 beg))))
3738 ((string-match "(.+)" gnus-tmp-from)
3739 (substring gnus-tmp-from
3740 (1+ (match-beginning 0)) (1- (match-end 0))))
3742 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3743 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3744 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3745 (inhibit-read-only t))
3746 (when (string= gnus-tmp-name "")
3747 (setq gnus-tmp-name gnus-tmp-from))
3748 (unless (numberp gnus-tmp-lines)
3749 (setq gnus-tmp-lines -1))
3750 (if (= gnus-tmp-lines -1)
3751 (setq gnus-tmp-lines "?")
3752 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3754 (gnus-put-text-property
3756 (progn (eval gnus-summary-line-format-spec) (point))
3757 'gnus-number gnus-tmp-number)
3758 (error (gnus-message 5 "Error updating the summary line")))
3759 (when (gnus-visual-p 'summary-highlight 'highlight)
3761 (gnus-summary-highlight-line)
3762 (gnus-run-hooks 'gnus-summary-update-hook)
3765 (defun gnus-summary-update-line (&optional dont-update)
3766 "Update summary line after change."
3767 (when (and gnus-summary-default-score
3768 (not gnus-summary-inhibit-highlight))
3769 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3770 (article (gnus-summary-article-number))
3771 (score (gnus-summary-article-score article)))
3773 (if (and gnus-summary-mark-below
3774 (< (gnus-summary-article-score)
3775 gnus-summary-mark-below))
3776 ;; This article has a low score, so we mark it as read.
3777 (when (memq article gnus-newsgroup-unreads)
3778 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3779 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3780 ;; This article was previously marked as read on account
3781 ;; of a low score, but now it has risen, so we mark it as
3783 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3784 (gnus-summary-update-mark
3785 (if (or (null gnus-summary-default-score)
3786 (<= (abs (- score gnus-summary-default-score))
3787 gnus-summary-zcore-fuzz))
3789 (if (< score gnus-summary-default-score)
3790 gnus-score-below-mark gnus-score-over-mark))
3792 ;; Do visual highlighting.
3793 (when (gnus-visual-p 'summary-highlight 'highlight)
3794 (gnus-summary-highlight-line)
3795 (gnus-run-hooks 'gnus-summary-update-hook)))))
3797 (defvar gnus-tmp-new-adopts nil)
3799 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3800 "Return the number of articles in THREAD.
3801 This may be 0 in some cases -- if none of the articles in
3802 the thread are to be displayed."
3804 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3806 ((not (listp thread))
3808 ((and (consp thread) (cdr thread))
3811 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3814 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3817 (when (and level (zerop level) gnus-tmp-new-adopts)
3820 'gnus-summary-number-of-articles-in-thread
3821 gnus-tmp-new-adopts))))
3823 (if (> number 1) gnus-not-empty-thread-mark
3824 gnus-empty-thread-mark)
3827 (defsubst gnus-summary-line-message-size (head)
3828 "Return pretty-printed version of message size.
3829 This function is intended to be used in
3830 `gnus-summary-line-format-alist'."
3831 (let ((c (or (mail-header-chars head) -1)))
3832 (cond ((< c 0) "n/a") ; chars not available
3833 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3834 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3835 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3836 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3838 (defcustom gnus-user-date-format-alist
3839 '(((gnus-seconds-today) . "Today, %H:%M")
3840 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3841 (604800 . "%A %H:%M") ; That's one week
3842 ((gnus-seconds-month) . "%A %d")
3843 ((gnus-seconds-year) . "%B %d")
3844 (t . "%b %d %Y")) ; This one is used when no other
3846 "Specifies date format depending on age of article.
3847 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3848 seconds) or a Lisp expression evaluating to a number. When the age of
3849 the article is less than this number, then use `format-time-string'
3850 with the corresponding FORMAT for displaying the date of the article.
3851 If AGE is not a number or a Lisp expression evaluating to a
3852 non-number, then the corresponding FORMAT is used as a default value.
3854 Note that the list is processed from the beginning, so it should be
3855 sorted by ascending AGE. Also note that items following the first
3856 non-number AGE will be ignored.
3858 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3859 and `gnus-seconds-year' in the AGE spec. They return the number of
3860 seconds passed since the start of today, of this month, of this year,
3863 :group 'gnus-summary-format
3864 :type '(alist :key-type sexp :value-type string))
3866 (defun gnus-user-date (messy-date)
3867 "Format the messy-date according to `gnus-user-date-format-alist'.
3868 Returns \" ? \" if there's bad input or if another error occurs.
3869 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3871 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3872 (now (gnus-float-time))
3873 ;;If we don't find something suitable we'll use this one
3874 (my-format "%b %d '%y"))
3875 (let* ((difference (- now messy-date))
3876 (templist gnus-user-date-format-alist)
3877 (top (eval (caar templist))))
3878 (while (if (numberp top) (< top difference) (not top))
3880 (setq templist (cdr templist))
3881 (setq top (eval (caar templist)))))
3882 (if (stringp (cdr (car templist)))
3883 (setq my-format (cdr (car templist)))))
3884 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3887 (defun gnus-summary-set-local-parameters (group)
3888 "Go through the local params of GROUP and set all variable specs in that list."
3889 (let ((vars '(quit-config active))) ; Ignore things that aren't
3891 (dolist (elem (gnus-group-find-parameter group))
3892 (and (consp elem) ; Has to be a cons.
3893 (consp (cdr elem)) ; The cdr has to be a list.
3894 (symbolp (car elem)) ; Has to be a symbol in there.
3895 (not (memq (car elem) vars))
3897 (push (car elem) vars)
3898 ;; Variables like `gnus-show-threads' that are globally
3899 ;; bound, if used as group parameters, need to get to be
3900 ;; buffer-local, whereas just parameters like `gcc-self',
3901 ;; `timestamp', etc. should not be bound as variables.
3902 (if (boundp (car elem))
3903 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3904 (eval (nth 1 elem))))))))
3906 (defun gnus-summary-read-group (group &optional show-all no-article
3907 kill-buffer no-display backward
3909 "Start reading news in newsgroup GROUP.
3910 If SHOW-ALL is non-nil, already read articles are also listed.
3911 If NO-ARTICLE is non-nil, no article is selected initially.
3912 If NO-DISPLAY, don't generate the summary buffer contents.
3913 If KILL-BUFFER, it should be a buffer that's killed once the new
3914 summary buffer has been generated.
3915 If BACKWARD, move point to the previous group in the group buffer
3916 If SELECT-ARTICLES, only select those articles from GROUP."
3920 (let ((gnus-auto-select-next nil))
3921 (or (gnus-summary-read-group-1
3922 group show-all no-article
3923 kill-buffer no-display
3926 select-articles nil)))))
3927 (eq gnus-auto-select-next 'quietly))
3928 (set-buffer gnus-group-buffer)
3929 ;; The entry function called above goes to the next
3930 ;; group automatically, so we go two groups back
3931 ;; if we are searching for the previous group.
3933 (gnus-group-prev-unread-group 2))
3934 (if (not (equal group (gnus-group-group-name)))
3935 (setq group (gnus-group-group-name))
3939 (defun gnus-summary-read-group-1 (group show-all no-article
3940 kill-buffer no-display
3941 &optional select-articles)
3942 ;; Killed foreign groups can't be entered.
3943 ;; (when (and (not (gnus-group-native-p group))
3944 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3945 ;; (error "Dead non-native groups can't be entered"))
3946 (gnus-message 7 "Retrieving newsgroup: %s..."
3947 (gnus-group-decoded-name group))
3948 (let* ((new-group (gnus-summary-setup-buffer group))
3949 (quit-config (gnus-group-quit-config group))
3950 (did-select (and new-group (gnus-select-newsgroup
3951 group show-all select-articles))))
3953 ;; This summary buffer exists already, so we just select it.
3955 (gnus-set-global-variables)
3957 (gnus-kill-or-deaden-summary kill-buffer))
3958 (gnus-configure-windows 'summary 'force)
3959 (gnus-set-mode-line 'summary)
3960 (gnus-summary-position-point)
3963 ;; We couldn't select this group.
3965 (when (and (eq major-mode 'gnus-summary-mode)
3966 (not (equal (current-buffer) kill-buffer)))
3967 (kill-buffer (current-buffer))
3968 (if (not quit-config)
3970 ;; Update the info -- marks might need to be removed,
3972 (gnus-summary-update-info)
3973 (set-buffer gnus-group-buffer)
3974 (gnus-group-jump-to-group group)
3975 (gnus-group-next-unread-group 1))
3976 (gnus-handle-ephemeral-exit quit-config)))
3977 (if (null (gnus-list-of-unread-articles group))
3978 (gnus-message 3 "Group %s contains no messages" group)
3979 (gnus-message 3 "Can't select group"))
3981 ;; The user did a `C-g' while prompting for number of articles,
3982 ;; so we exit this group.
3983 ((eq did-select 'quit)
3984 (and (eq major-mode 'gnus-summary-mode)
3985 (not (equal (current-buffer) kill-buffer))
3986 (kill-buffer (current-buffer)))
3988 (gnus-kill-or-deaden-summary kill-buffer))
3989 (if (not quit-config)
3991 (set-buffer gnus-group-buffer)
3992 (gnus-group-jump-to-group group)
3993 (gnus-configure-windows 'group 'force))
3994 (gnus-handle-ephemeral-exit quit-config))
3995 ;; Finally signal the quit.
3997 ;; The group was successfully selected.
3999 (gnus-set-global-variables)
4000 ;; Save the active value in effect when the group was entered.
4001 (setq gnus-newsgroup-active
4003 (gnus-active gnus-newsgroup-name)))
4004 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4005 ;; You can change the summary buffer in some way with this hook.
4006 (gnus-run-hooks 'gnus-select-group-hook)
4007 (when (memq 'summary (gnus-update-format-specifications
4008 nil 'summary 'summary-mode 'summary-dummy))
4009 ;; The format specification for the summary line was updated,
4010 ;; so we need to update the mark positions as well.
4011 (gnus-update-summary-mark-positions))
4012 ;; Do score processing.
4013 (when gnus-use-scoring
4014 (gnus-possibly-score-headers))
4015 ;; Check whether to fill in the gaps in the threads.
4016 (when gnus-build-sparse-threads
4017 (gnus-build-sparse-threads))
4018 ;; Find the initial limit.
4020 (let ((gnus-newsgroup-dormant nil))
4021 (gnus-summary-initial-limit show-all))
4022 (gnus-summary-initial-limit show-all))
4023 ;; Generate the summary buffer.
4025 (gnus-summary-prepare))
4026 (when gnus-use-trees
4027 (gnus-tree-open group)
4028 (setq gnus-summary-highlight-line-function
4029 'gnus-tree-highlight-article))
4030 ;; If the summary buffer is empty, but there are some low-scored
4031 ;; articles or some excluded dormants, we include these in the
4033 (when (and (zerop (buffer-size))
4035 (cond (gnus-newsgroup-dormant
4036 (gnus-summary-limit-include-dormant))
4037 ((and gnus-newsgroup-scored show-all)
4038 (gnus-summary-limit-include-expunged t))))
4039 ;; Function `gnus-apply-kill-file' must be called in this hook.
4040 (gnus-run-hooks 'gnus-apply-kill-hook)
4041 (if (and (zerop (buffer-size))
4044 ;; This newsgroup is empty.
4045 (gnus-summary-catchup-and-exit nil t)
4046 (gnus-message 6 "No unread news")
4048 (gnus-kill-or-deaden-summary kill-buffer))
4049 ;; Return nil from this function.
4051 ;; Hide conversation thread subtrees. We cannot do this in
4052 ;; gnus-summary-prepare-hook since kill processing may not
4053 ;; work with hidden articles.
4054 (gnus-summary-maybe-hide-threads)
4055 (gnus-configure-windows 'summary)
4057 (gnus-kill-or-deaden-summary kill-buffer))
4058 (gnus-summary-auto-select-subject)
4059 ;; Show first unread article if requested.
4060 (if (and (not no-article)
4062 gnus-newsgroup-unreads
4063 gnus-auto-select-first)
4065 (let ((art (gnus-summary-article-number)))
4066 (unless (and (not gnus-plugged)
4067 (or (memq art gnus-newsgroup-undownloaded)
4068 (memq art gnus-newsgroup-downloadable)))
4069 (gnus-summary-goto-article art))))
4070 ;; Don't select any articles.
4071 (gnus-summary-position-point)
4072 (gnus-configure-windows 'summary 'force)
4073 (gnus-set-mode-line 'summary))
4074 (when (and gnus-auto-center-group
4075 (get-buffer-window gnus-group-buffer t))
4076 ;; Gotta use windows, because recenter does weird stuff if
4077 ;; the current buffer ain't the displayed window.
4078 (let ((owin (selected-window)))
4079 (select-window (get-buffer-window gnus-group-buffer t))
4080 (when (gnus-group-goto-group group)
4082 (select-window owin)))
4083 ;; Mark this buffer as "prepared".
4084 (setq gnus-newsgroup-prepared t)
4085 (gnus-run-hooks 'gnus-summary-prepared-hook)
4086 (unless (gnus-ephemeral-group-p group)
4087 (gnus-group-update-group group nil t))
4090 (defun gnus-summary-auto-select-subject ()
4091 "Select the subject line on initial group entry."
4092 (goto-char (point-min))
4094 ((eq gnus-auto-select-subject 'best)
4095 (gnus-summary-best-unread-subject))
4096 ((eq gnus-auto-select-subject 'unread)
4097 (gnus-summary-first-unread-subject))
4098 ((eq gnus-auto-select-subject 'unseen)
4099 (gnus-summary-first-unseen-subject))
4100 ((eq gnus-auto-select-subject 'unseen-or-unread)
4101 (gnus-summary-first-unseen-or-unread-subject))
4102 ((eq gnus-auto-select-subject 'first)
4105 ((functionp gnus-auto-select-subject)
4106 (funcall gnus-auto-select-subject))))
4108 (defun gnus-summary-prepare ()
4109 "Generate the summary buffer."
4111 (let ((inhibit-read-only t))
4113 (setq gnus-newsgroup-data nil
4114 gnus-newsgroup-data-reverse nil)
4115 (gnus-run-hooks 'gnus-summary-generate-hook)
4116 ;; Generate the buffer, either with threads or without.
4117 (when gnus-newsgroup-headers
4118 (gnus-summary-prepare-threads
4119 (if gnus-show-threads
4120 (gnus-sort-gathered-threads
4121 (funcall gnus-summary-thread-gathering-function
4123 (gnus-cut-threads (gnus-make-threads)))))
4124 ;; Unthreaded display.
4125 (gnus-sort-articles gnus-newsgroup-headers))))
4126 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4127 ;; Call hooks for modifying summary buffer.
4128 (goto-char (point-min))
4129 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4131 (defsubst gnus-general-simplify-subject (subject)
4132 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4135 ;; Truncate the subject.
4136 (gnus-simplify-subject-functions
4137 (gnus-map-function gnus-simplify-subject-functions subject))
4138 ((numberp gnus-summary-gather-subject-limit)
4139 (setq subject (gnus-simplify-subject-re subject))
4140 (if (> (length subject) gnus-summary-gather-subject-limit)
4141 (substring subject 0 gnus-summary-gather-subject-limit)
4143 ;; Fuzzily simplify it.
4144 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4145 (gnus-simplify-subject-fuzzy subject))
4146 ;; Just remove the leading "Re:".
4148 (gnus-simplify-subject-re subject))))
4150 (if (and gnus-summary-gather-exclude-subject
4151 (string-match gnus-summary-gather-exclude-subject subject))
4152 nil ; This article shouldn't be gathered
4155 (defun gnus-summary-simplify-subject-query ()
4156 "Query where the respool algorithm would put this article."
4158 (gnus-summary-select-article)
4159 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4161 (defun gnus-gather-threads-by-subject (threads)
4162 "Gather threads by looking at Subject headers."
4163 (if (not gnus-summary-make-false-root)
4165 (let ((hashtb (gnus-make-hashtable 1024))
4168 subject hthread whole-subject)
4170 (setq subject (gnus-general-simplify-subject
4171 (setq whole-subject (mail-header-subject
4174 (if (setq hthread (gnus-gethash subject hashtb))
4176 ;; We enter a dummy root into the thread, if we
4177 ;; haven't done that already.
4178 (unless (stringp (caar hthread))
4179 (setcar hthread (list whole-subject (car hthread))))
4180 ;; We add this new gathered thread to this gathered
4182 (setcdr (car hthread)
4183 (nconc (cdar hthread) (list (car threads))))
4184 ;; Remove it from the list of threads.
4185 (setcdr prev (cdr threads))
4186 (setq threads prev))
4187 ;; Enter this thread into the hash table.
4188 (gnus-sethash subject
4189 (if gnus-summary-make-false-root-always
4191 ;; If you want a dummy root above all
4193 (setcar threads (list whole-subject
4199 (setq threads (cdr threads)))
4202 (defun gnus-gather-threads-by-references (threads)
4203 "Gather threads by looking at References headers."
4204 (let ((idhashtb (gnus-make-hashtable 1024))
4205 (thhashtb (gnus-make-hashtable 1024))
4208 ids references id gthread gid entered ref)
4210 (when (setq references (mail-header-references (caar threads)))
4211 (setq id (mail-header-id (caar threads))
4212 ids (inline (gnus-split-references references))
4214 (while (setq ref (pop ids))
4215 (setq ids (delete ref ids))
4216 (if (not (setq gid (gnus-gethash ref idhashtb)))
4218 (gnus-sethash ref id idhashtb)
4219 (gnus-sethash id threads thhashtb))
4220 (setq gthread (gnus-gethash gid thhashtb))
4222 ;; We enter a dummy root into the thread, if we
4223 ;; haven't done that already.
4224 (unless (stringp (caar gthread))
4225 (setcar gthread (list (mail-header-subject (caar gthread))
4227 ;; We add this new gathered thread to this gathered
4229 (setcdr (car gthread)
4230 (nconc (cdar gthread) (list (car threads)))))
4231 ;; Add it into the thread hash table.
4232 (gnus-sethash id gthread thhashtb)
4234 ;; Remove it from the list of threads.
4235 (setcdr prev (cdr threads))
4236 (setq threads prev))))
4238 (setq threads (cdr threads)))
4241 (defun gnus-sort-gathered-threads (threads)
4242 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4243 (let ((result threads))
4245 (when (stringp (caar threads))
4246 (setcdr (car threads)
4247 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4248 (setq threads (cdr threads)))
4251 (defun gnus-thread-loop-p (root thread)
4252 "Say whether ROOT is in THREAD."
4253 (let ((stack (list thread))
4256 (while (setq thread (pop stack))
4257 (setq th (cdr thread))
4259 (not (eq (caar th) root)))
4262 ;; We have found a loop.
4264 (setcdr thread (delq (car th) (cdr thread)))
4265 (if (boundp (setq ref-dep (intern "none"
4266 gnus-newsgroup-dependencies)))
4267 (setcdr (symbol-value ref-dep)
4268 (nconc (cdr (symbol-value ref-dep))
4270 (set ref-dep (list nil (car th))))
4273 ;; Push all the subthreads onto the stack.
4274 (push (cdr thread) stack)))
4277 (defun gnus-make-threads ()
4278 "Go through the dependency hashtb and find the roots. Return all threads."
4280 (while (catch 'infloop
4283 ;; Deal with self-referencing References loops.
4284 (when (and (car (symbol-value refs))
4291 (car (symbol-value refs)) thread))
4292 (cdr (symbol-value refs)))))))
4295 (unless (car (symbol-value refs))
4296 ;; These threads do not refer back to any other
4297 ;; articles, so they're roots.
4298 (setq threads (append (cdr (symbol-value refs)) threads))))
4299 gnus-newsgroup-dependencies)))
4302 ;; Build the thread tree.
4303 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4304 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4306 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4307 if it was already present.
4309 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4310 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4311 Message-IDs will be renamed to a unique Message-ID before being
4314 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4315 (let* ((id (mail-header-id header))
4316 (id-dep (and id (intern id dependencies)))
4317 parent-id ref ref-dep ref-header replaced)
4318 ;; Enter this `header' in the `dependencies' table.
4322 ;; The first two cases do the normal part: enter a new `header'
4323 ;; in the `dependencies' table.
4324 ((not (boundp id-dep))
4325 (set id-dep (list header)))
4326 ((null (car (symbol-value id-dep)))
4327 (setcar (symbol-value id-dep) header))
4329 ;; From here the `header' was already present in the
4330 ;; `dependencies' table.
4332 ;; Overrides an existing entry;
4333 ;; just set the header part of the entry.
4334 (setcar (symbol-value id-dep) header)
4337 ;; Renames the existing `header' to a unique Message-ID.
4338 ((not gnus-summary-ignore-duplicates)
4339 ;; An article with this Message-ID has already been seen.
4340 ;; We rename the Message-ID.
4341 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4343 (mail-header-set-id header id))
4345 ;; The last case ignores an existing entry, except it adds any
4346 ;; additional Xrefs (in case the two articles came from different
4348 ;; Also sets `header' to `nil' meaning that the `dependencies'
4349 ;; table was *not* modified.
4351 (mail-header-set-xref
4352 (car (symbol-value id-dep))
4353 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4355 (or (mail-header-xref header) "")))
4358 (when (and header (not replaced))
4359 ;; First check that we are not creating a References loop.
4360 (setq parent-id (gnus-parent-id (mail-header-references header)))
4361 (setq ref parent-id)
4363 (setq ref-dep (intern-soft ref dependencies))
4365 (setq ref-header (car (symbol-value ref-dep))))
4366 (if (string= id ref)
4367 ;; Yuk! This is a reference loop. Make the article be a
4370 (mail-header-set-references (car (symbol-value id-dep)) "none")
4372 (setq parent-id nil))
4373 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4374 (setq ref-dep (intern (or parent-id "none") dependencies))
4375 (if (boundp ref-dep)
4376 (setcdr (symbol-value ref-dep)
4377 (nconc (cdr (symbol-value ref-dep))
4378 (list (symbol-value id-dep))))
4379 (set ref-dep (list nil (symbol-value id-dep)))))
4382 (defun gnus-extract-message-id-from-in-reply-to (string)
4383 (if (string-match "<[^>]+>" string)
4384 (substring string (match-beginning 0) (match-end 0))
4387 (defun gnus-build-sparse-threads ()
4388 (let ((headers gnus-newsgroup-headers)
4389 (mail-parse-charset gnus-newsgroup-charset)
4390 (gnus-summary-ignore-duplicates t)
4391 header references generation relations
4392 subject child end new-child date)
4393 ;; First we create an alist of generations/relations, where
4394 ;; generations is how much we trust the relation, and the relation
4396 (gnus-message 7 "Making sparse threads...")
4398 (nnheader-set-temp-buffer " *gnus sparse threads*")
4399 (while (setq header (pop headers))
4400 (when (and (setq references (mail-header-references header))
4401 (not (string= references "")))
4403 (setq child (mail-header-id header)
4404 subject (mail-header-subject header)
4405 date (mail-header-date header)
4407 (while (search-backward ">" nil t)
4408 (setq end (1+ (point)))
4409 (when (search-backward "<" nil t)
4410 (setq new-child (buffer-substring (point) end))
4411 (push (list (incf generation)
4412 child (setq child new-child)
4416 (push (list (1+ generation) child nil subject) relations))
4418 (kill-buffer (current-buffer)))
4419 ;; Sort over trustworthiness.
4420 (dolist (relation (sort relations 'car-less-than-car))
4421 (when (gnus-dependencies-add-header
4422 (make-full-mail-header
4423 gnus-reffed-article-number
4424 (nth 3 relation) "" (or (nth 4 relation) "")
4426 (or (nth 2 relation) "") 0 0 "")
4427 gnus-newsgroup-dependencies nil)
4428 (push gnus-reffed-article-number gnus-newsgroup-limit)
4429 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4430 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4431 gnus-newsgroup-reads)
4432 (decf gnus-reffed-article-number)))
4433 (gnus-message 7 "Making sparse threads...done")))
4435 (defun gnus-build-old-threads ()
4436 ;; Look at all the articles that refer back to old articles, and
4437 ;; fetch the headers for the articles that aren't there. This will
4438 ;; build complete threads - if the roots haven't been expired by the
4440 (let ((mail-parse-charset gnus-newsgroup-charset)
4444 (when (not (car (symbol-value refs)))
4445 (setq heads (cdr (symbol-value refs)))
4447 (if (memq (mail-header-number (caar heads))
4448 gnus-newsgroup-dormant)
4449 (setq heads (cdr heads))
4450 (setq id (symbol-name refs))
4451 (while (and (setq id (gnus-build-get-header id))
4452 (not (car (gnus-id-to-thread id)))))
4453 (setq heads nil)))))
4454 gnus-newsgroup-dependencies)))
4456 (defsubst gnus-remove-odd-characters (string)
4457 "Translate STRING into something that doesn't contain weird characters."
4458 (mm-subst-char-in-string
4460 (mm-subst-char-in-string ?\n ?\- string t) t))
4462 ;; This function has to be called with point after the article number
4463 ;; on the beginning of the line.
4464 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4465 (let ((eol (point-at-eol))
4466 (buffer (current-buffer))
4467 header references in-reply-to)
4469 ;; overview: [num subject from date id refs chars lines misc]
4472 (narrow-to-region (point) eol)
4477 (make-full-mail-header
4479 (condition-case () ; subject
4480 (gnus-remove-odd-characters
4481 (funcall gnus-decode-encoded-word-function
4482 (setq x (nnheader-nov-field))))
4484 (condition-case () ; from
4485 (gnus-remove-odd-characters
4486 (funcall gnus-decode-encoded-address-function
4487 (setq x (nnheader-nov-field))))
4489 (nnheader-nov-field) ; date
4490 (nnheader-nov-read-message-id number) ; id
4491 (setq references (nnheader-nov-field)) ; refs
4492 (nnheader-nov-read-integer) ; chars
4493 (nnheader-nov-read-integer) ; lines
4495 (if (looking-at "Xref: ")
4496 (goto-char (match-end 0)))
4497 (nnheader-nov-field)) ; Xref
4498 (nnheader-nov-parse-extra)))) ; extra
4502 (when (and (string= references "")
4503 (setq in-reply-to (mail-header-extra header))
4504 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4505 (mail-header-set-references
4506 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4508 (when gnus-alter-header-function
4509 (funcall gnus-alter-header-function header))
4510 (gnus-dependencies-add-header header dependencies force-new)))
4512 (defun gnus-build-get-header (id)
4513 "Look through the buffer of NOV lines and find the header to ID.
4514 Enter this line into the dependencies hash table, and return
4515 the id of the parent article (if any)."
4516 (let ((deps gnus-newsgroup-dependencies)
4519 (with-current-buffer nntp-server-buffer
4520 (let ((case-fold-search nil))
4521 (goto-char (point-min))
4522 (while (and (not found)
4523 (search-forward id nil t))
4525 (setq found (looking-at
4526 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4527 (regexp-quote id))))
4528 (or found (beginning-of-line 2)))
4532 (setq header (gnus-nov-parse-line
4533 (read (current-buffer)) deps))
4534 (gnus-parent-id (mail-header-references header))))))
4536 (let ((number (mail-header-number header)))
4537 (push number gnus-newsgroup-limit)
4538 (push header gnus-newsgroup-headers)
4539 (if (memq number gnus-newsgroup-unselected)
4541 (setq gnus-newsgroup-unreads
4542 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4544 (setq gnus-newsgroup-unselected
4545 (delq number gnus-newsgroup-unselected)))
4546 (push number gnus-newsgroup-ancient)))))))
4548 (defun gnus-build-all-threads ()
4549 "Read all the headers."
4550 (let ((gnus-summary-ignore-duplicates t)
4551 (mail-parse-charset gnus-newsgroup-charset)
4552 (dependencies gnus-newsgroup-dependencies)
4554 (with-current-buffer nntp-server-buffer
4555 (let ((case-fold-search nil))
4556 (goto-char (point-min))
4559 (setq article (read (current-buffer))
4560 header (gnus-nov-parse-line article dependencies t)))
4562 (with-current-buffer gnus-summary-buffer
4563 (push header gnus-newsgroup-headers)
4564 (if (memq (setq article (mail-header-number header))
4565 gnus-newsgroup-unselected)
4567 (setq gnus-newsgroup-unreads
4568 (gnus-add-to-sorted-list
4569 gnus-newsgroup-unreads article))
4570 (setq gnus-newsgroup-unselected
4571 (delq article gnus-newsgroup-unselected)))
4572 (push article gnus-newsgroup-ancient)))
4573 (forward-line 1)))))))
4575 (defun gnus-summary-update-article-line (article header)
4576 "Update the line for ARTICLE using HEADER."
4577 (let* ((id (mail-header-id header))
4578 (thread (gnus-id-to-thread id)))
4580 (error "Article in no thread"))
4581 ;; Update the thread.
4582 (setcar thread header)
4583 (gnus-summary-goto-subject article)
4584 (let* ((datal (gnus-data-find-list article))
4586 (inhibit-read-only t)
4587 (level (gnus-summary-thread-level)))
4589 (let ((inserted (- (point)
4591 (gnus-summary-insert-line
4593 (memq article gnus-newsgroup-undownloaded)
4594 (gnus-article-mark article)
4595 (memq article gnus-newsgroup-replied)
4596 (memq article gnus-newsgroup-expirable)
4597 ;; Only insert the Subject string when it's different
4598 ;; from the previous Subject string.
4603 (mail-header-subject
4606 (gnus-data-find-list
4608 (gnus-data-list t)))))
4609 ;; Error on the side of excessive subjects.
4611 (mail-header-subject header)))
4613 (mail-header-subject header))
4614 nil (cdr (assq article gnus-newsgroup-scored))
4615 (memq article gnus-newsgroup-processable))
4618 (gnus-data-update-list
4620 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4622 (defun gnus-summary-update-article (article &optional iheader)
4623 "Update ARTICLE in the summary buffer."
4624 (set-buffer gnus-summary-buffer)
4625 (let* ((header (gnus-summary-article-header article))
4626 (id (mail-header-id header))
4627 (data (gnus-data-find article))
4628 (thread (gnus-id-to-thread id))
4629 (references (mail-header-references header))
4633 (when (and references
4634 (not (equal "" references)))
4637 (inhibit-read-only t)
4643 (delq thread parent)))
4644 (if (gnus-summary-insert-subject id header)
4645 ;; Set the (possibly) new article number in the data structure.
4646 (gnus-data-set-number data (gnus-id-to-article id))
4650 (defun gnus-rebuild-thread (id &optional line)
4651 "Rebuild the thread containing ID.
4652 If LINE, insert the rebuilt thread starting on line LINE."
4653 (let ((inhibit-read-only t)
4654 old-pos current thread data)
4655 (if (not gnus-show-threads)
4656 (setq thread (list (car (gnus-id-to-thread id))))
4657 ;; Get the thread this article is part of.
4658 (setq thread (gnus-remove-thread id)))
4659 (setq old-pos (point-at-bol))
4660 (setq current (save-excursion
4661 (and (re-search-backward "[\r\n]" nil t)
4662 (gnus-summary-article-number))))
4663 ;; If this is a gathered thread, we have to go some re-gathering.
4664 (when (stringp (car thread))
4665 (let ((subject (car thread))
4667 (setq thread (cdr thread))
4669 (unless (memq (setq thr (gnus-id-to-thread
4671 (mail-header-id (caar thread)))))
4674 (setq thread (cdr thread)))
4675 ;; We now have all (unique) roots.
4676 (if (= (length roots) 1)
4677 ;; All the loose roots are now one solid root.
4678 (setq thread (car roots))
4679 (setq thread (cons subject (gnus-sort-threads roots))))))
4681 ;; We then insert this thread into the summary buffer.
4683 (goto-char (point-min))
4684 (forward-line (1- line)))
4685 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4686 (if gnus-show-threads
4687 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4688 (gnus-summary-prepare-unthreaded thread))
4689 (setq data (nreverse gnus-newsgroup-data))
4690 (setq threads gnus-newsgroup-threads))
4691 ;; We splice the new data into the data structure.
4692 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4693 ;;!!! then we want to insert at the beginning of the buffer.
4694 ;;!!! That happens to be true with Gnus now, but that may
4695 ;;!!! change in the future. Perhaps.
4696 (gnus-data-enter-list
4697 (if line nil current) data (- (point) old-pos))
4698 (setq gnus-newsgroup-threads
4699 (nconc threads gnus-newsgroup-threads))
4700 (gnus-data-compute-positions))))
4702 (defun gnus-number-to-header (number)
4703 "Return the header for article NUMBER."
4704 (let ((headers gnus-newsgroup-headers))
4706 (not (= number (mail-header-number (car headers)))))
4711 (defun gnus-parent-headers (in-headers &optional generation)
4712 "Return the headers of the GENERATIONth parent of HEADERS."
4714 (setq generation 1))
4716 (headers in-headers)
4719 (not (zerop generation))
4720 (setq references (mail-header-references headers)))
4721 (setq headers (if (and references
4722 (setq parent (gnus-parent-id references)))
4723 (car (gnus-id-to-thread parent))
4726 (and (not (eq headers in-headers))
4729 (defun gnus-id-to-thread (id)
4730 "Return the (sub-)thread where ID appears."
4731 (gnus-gethash id gnus-newsgroup-dependencies))
4733 (defun gnus-id-to-article (id)
4734 "Return the article number of ID."
4735 (let ((thread (gnus-id-to-thread id)))
4738 (mail-header-number (car thread)))))
4740 (defun gnus-id-to-header (id)
4741 "Return the article headers of ID."
4742 (car (gnus-id-to-thread id)))
4744 (defun gnus-article-displayed-root-p (article)
4745 "Say whether ARTICLE is a root(ish) article."
4746 (let ((level (gnus-summary-thread-level article))
4747 (refs (mail-header-references (gnus-summary-article-header article)))
4753 ((null (gnus-parent-id refs)) t)
4755 (null (setq particle (gnus-id-to-article
4756 (gnus-parent-id refs))))
4757 (null (gnus-summary-thread-level particle)))))))
4759 (defun gnus-root-id (id)
4760 "Return the id of the root of the thread where ID appears."
4762 (while (and id (setq prev (car (gnus-id-to-thread id))))
4764 id (gnus-parent-id (mail-header-references prev))))
4767 (defun gnus-articles-in-thread (thread)
4768 "Return the list of articles in THREAD."
4769 (cons (mail-header-number (car thread))
4770 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4772 (defun gnus-remove-thread (id &optional dont-remove)
4773 "Remove the thread that has ID in it."
4774 (let (headers thread last-id)
4775 ;; First go up in this thread until we find the root.
4776 (setq last-id (gnus-root-id id)
4777 headers (message-flatten-list (gnus-id-to-thread last-id)))
4778 ;; We have now found the real root of this thread. It might have
4779 ;; been gathered into some loose thread, so we have to search
4780 ;; through the threads to find the thread we wanted.
4781 (let ((threads gnus-newsgroup-threads)
4784 (setq sub (car threads))
4785 (if (stringp (car sub))
4786 ;; This is a gathered thread, so we look at the roots
4787 ;; below it to find whether this article is in this
4790 (setq sub (cdr sub))
4792 (when (member (caar sub) headers)
4793 (setq thread (car threads)
4796 (setq sub (cdr sub))))
4797 ;; It's an ordinary thread, so we check it.
4798 (when (eq (car sub) (car headers))
4801 (setq threads (cdr threads)))
4802 ;; If this article is in no thread, then it's a root.
4805 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4806 (setq thread (gnus-id-to-thread last-id)))
4809 thread ; We return this thread.
4811 (if (stringp (car thread))
4813 ;; If we use dummy roots, then we have to remove the
4814 ;; dummy root as well.
4815 (when (eq gnus-summary-make-false-root 'dummy)
4816 ;; We go to the dummy root by going to
4817 ;; the first sub-"thread", and then one line up.
4818 (gnus-summary-goto-article
4819 (mail-header-number (caadr thread)))
4822 (gnus-data-compute-positions))
4823 (setq thread (cdr thread))
4825 (gnus-remove-thread-1 (car thread))
4826 (setq thread (cdr thread))))
4827 (gnus-remove-thread-1 thread))))))))
4829 (defun gnus-remove-thread-1 (thread)
4830 "Remove the thread THREAD recursively."
4831 (let ((number (mail-header-number (pop thread)))
4833 (setq thread (reverse thread))
4835 (gnus-remove-thread-1 (pop thread)))
4836 (when (setq d (gnus-data-find number))
4837 (goto-char (gnus-data-pos d))
4838 (gnus-summary-show-thread)
4844 (gnus-delete-line)))))))
4846 (defun gnus-sort-threads-recursive (threads func)
4847 (sort (mapcar (lambda (thread)
4850 (gnus-sort-threads-recursive (cdr thread) func))))
4853 (defun gnus-sort-threads-loop (threads func)
4854 (let* ((superthread (cons nil threads))
4855 (stack (list (cons superthread threads)))
4856 remaining-threads thread)
4858 (setq remaining-threads (cdr (car stack)))
4859 (if remaining-threads
4860 (progn (setq thread (car remaining-threads))
4861 (setcdr (car stack) (cdr remaining-threads))
4863 (push (cons thread (cdr thread)) stack)))
4864 (setq thread (caar stack))
4865 (setcdr thread (sort (cdr thread) func))
4869 (defun gnus-sort-threads (threads)
4871 (if (not gnus-thread-sort-functions)
4873 (gnus-message 8 "Sorting threads...")
4876 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4877 (gnus-sort-threads-recursive
4878 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4879 ;; Even after binding max-lisp-eval-depth, the recursive
4880 ;; sorter might fail for very long threads. In that case,
4881 ;; try using a (less well-tested) non-recursive sorter.
4882 (error (gnus-message 9 "Sorting threads with loop...")
4883 (gnus-sort-threads-loop
4884 threads (gnus-make-sort-function
4885 gnus-thread-sort-functions))))
4886 (gnus-message 8 "Sorting threads...done"))))
4888 (defun gnus-sort-articles (articles)
4890 (when gnus-article-sort-functions
4891 (gnus-message 7 "Sorting articles...")
4893 (setq gnus-newsgroup-headers
4894 (sort articles (gnus-make-sort-function
4895 gnus-article-sort-functions)))
4896 (gnus-message 7 "Sorting articles...done"))))
4898 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4899 (defmacro gnus-thread-header (thread)
4900 "Return header of first article in THREAD.
4901 Note that THREAD must never, ever be anything else than a variable -
4902 using some other form will lead to serious barfage."
4903 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4904 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4905 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4908 (defsubst gnus-article-sort-by-number (h1 h2)
4909 "Sort articles by article number."
4910 (< (mail-header-number h1)
4911 (mail-header-number h2)))
4913 (defun gnus-thread-sort-by-number (h1 h2)
4914 "Sort threads by root article number."
4915 (gnus-article-sort-by-number
4916 (gnus-thread-header h1) (gnus-thread-header h2)))
4918 (defsubst gnus-article-sort-by-random (h1 h2)
4919 "Sort articles randomly."
4922 (defun gnus-thread-sort-by-random (h1 h2)
4923 "Sort threads randomly."
4924 (gnus-article-sort-by-random
4925 (gnus-thread-header h1) (gnus-thread-header h2)))
4927 (defsubst gnus-article-sort-by-lines (h1 h2)
4928 "Sort articles by article Lines header."
4929 (< (mail-header-lines h1)
4930 (mail-header-lines h2)))
4932 (defun gnus-thread-sort-by-lines (h1 h2)
4933 "Sort threads by root article Lines header."
4934 (gnus-article-sort-by-lines
4935 (gnus-thread-header h1) (gnus-thread-header h2)))
4937 (defsubst gnus-article-sort-by-chars (h1 h2)
4938 "Sort articles by octet length."
4939 (< (mail-header-chars h1)
4940 (mail-header-chars h2)))
4942 (defun gnus-thread-sort-by-chars (h1 h2)
4943 "Sort threads by root article octet length."
4944 (gnus-article-sort-by-chars
4945 (gnus-thread-header h1) (gnus-thread-header h2)))
4947 (defsubst gnus-article-sort-by-author (h1 h2)
4948 "Sort articles by root author."
4950 (let ((extract (funcall
4951 gnus-extract-address-components
4952 (mail-header-from h1))))
4953 (or (car extract) (cadr extract) ""))
4954 (let ((extract (funcall
4955 gnus-extract-address-components
4956 (mail-header-from h2))))
4957 (or (car extract) (cadr extract) ""))))
4959 (defun gnus-thread-sort-by-author (h1 h2)
4960 "Sort threads by root author."
4961 (gnus-article-sort-by-author
4962 (gnus-thread-header h1) (gnus-thread-header h2)))
4964 (defsubst gnus-article-sort-by-recipient (h1 h2)
4965 "Sort articles by recipient."
4967 (let ((extract (funcall
4968 gnus-extract-address-components
4969 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4970 (or (car extract) (cadr extract)))
4971 (let ((extract (funcall
4972 gnus-extract-address-components
4973 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4974 (or (car extract) (cadr extract)))))
4976 (defun gnus-thread-sort-by-recipient (h1 h2)
4977 "Sort threads by root recipient."
4978 (gnus-article-sort-by-recipient
4979 (gnus-thread-header h1) (gnus-thread-header h2)))
4981 (defsubst gnus-article-sort-by-subject (h1 h2)
4982 "Sort articles by root subject."
4984 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4985 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4987 (defun gnus-thread-sort-by-subject (h1 h2)
4988 "Sort threads by root subject."
4989 (gnus-article-sort-by-subject
4990 (gnus-thread-header h1) (gnus-thread-header h2)))
4992 (defsubst gnus-article-sort-by-date (h1 h2)
4993 "Sort articles by root article date."
4995 (gnus-date-get-time (mail-header-date h1))
4996 (gnus-date-get-time (mail-header-date h2))))
4998 (defun gnus-thread-sort-by-date (h1 h2)
4999 "Sort threads by root article date."
5000 (gnus-article-sort-by-date
5001 (gnus-thread-header h1) (gnus-thread-header h2)))
5003 (defsubst gnus-article-sort-by-score (h1 h2)
5004 "Sort articles by root article score.
5005 Unscored articles will be counted as having a score of zero."
5006 (> (or (cdr (assq (mail-header-number h1)
5007 gnus-newsgroup-scored))
5008 gnus-summary-default-score 0)
5009 (or (cdr (assq (mail-header-number h2)
5010 gnus-newsgroup-scored))
5011 gnus-summary-default-score 0)))
5013 (defun gnus-thread-sort-by-score (h1 h2)
5014 "Sort threads by root article score."
5015 (gnus-article-sort-by-score
5016 (gnus-thread-header h1) (gnus-thread-header h2)))
5018 (defun gnus-thread-sort-by-total-score (h1 h2)
5019 "Sort threads by the sum of all scores in the thread.
5020 Unscored articles will be counted as having a score of zero."
5021 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5023 (defun gnus-thread-total-score (thread)
5024 ;; This function find the total score of THREAD.
5029 (if (stringp (car thread))
5030 (apply gnus-thread-score-function 0
5031 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5032 (gnus-thread-total-score-1 thread)))
5034 (gnus-thread-total-score-1 (list thread)))))
5036 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5037 "Sort articles by number."
5038 (gnus-article-sort-by-number h1 h2))
5040 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5041 "Sort threads such that the thread with the most recently arrived article comes first."
5042 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5044 (defun gnus-thread-highest-number (thread)
5045 "Return the highest article number in THREAD."
5046 (apply 'max (mapcar (lambda (header)
5047 (mail-header-number header))
5048 (message-flatten-list thread))))
5050 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5051 "Sort articles by number."
5052 (gnus-article-sort-by-date h1 h2))
5054 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5055 "Sort threads such that the thread with the most recently dated article comes first."
5056 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5058 ; Since this is called not only to sort the top-level threads, but
5059 ; also in recursive sorts to order the articles within a thread, each
5060 ; article will be processed many times. Thus it speeds things up
5061 ; quite a bit to use gnus-date-get-time, which caches the time value.
5062 (defun gnus-thread-latest-date (thread)
5063 "Return the highest article date in THREAD."
5065 (mapcar (lambda (header) (gnus-float-time
5067 (mail-header-date header))))
5068 (message-flatten-list thread))))
5070 (defun gnus-thread-total-score-1 (root)
5071 ;; This function find the total score of the thread below ROOT.
5072 (setq root (car root))
5073 (apply gnus-thread-score-function
5075 (mapcar 'gnus-thread-total-score
5076 (cdr (gnus-id-to-thread (mail-header-id root))))
5077 (when (> (mail-header-number root) 0)
5078 (list (or (cdr (assq (mail-header-number root)
5079 gnus-newsgroup-scored))
5080 gnus-summary-default-score 0))))
5081 (list gnus-summary-default-score)
5084 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5085 (defvar gnus-tmp-prev-subject nil)
5086 (defvar gnus-tmp-false-parent nil)
5087 (defvar gnus-tmp-root-expunged nil)
5088 (defvar gnus-tmp-dummy-line nil)
5090 (defun gnus-extra-header (type &optional header)
5091 "Return the extra header of TYPE."
5092 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5095 (defvar gnus-tmp-thread-tree-header-string "")
5097 (defcustom gnus-sum-thread-tree-root "> "
5098 "With %B spec, used for the root of a thread.
5099 If nil, use subject instead."
5101 :type '(radio (const :format "%v " nil) string)
5102 :group 'gnus-thread)
5104 (defcustom gnus-sum-thread-tree-false-root "> "
5105 "With %B spec, used for a false root of a thread.
5106 If nil, use subject instead."
5108 :type '(radio (const :format "%v " nil) string)
5109 :group 'gnus-thread)
5111 (defcustom gnus-sum-thread-tree-single-indent ""
5112 "With %B spec, used for a thread with just one message.
5113 If nil, use subject instead."
5115 :type '(radio (const :format "%v " nil) string)
5116 :group 'gnus-thread)
5118 (defcustom gnus-sum-thread-tree-vertical "| "
5119 "With %B spec, used for drawing a vertical line."
5122 :group 'gnus-thread)
5124 (defcustom gnus-sum-thread-tree-indent " "
5125 "With %B spec, used for indenting."
5128 :group 'gnus-thread)
5130 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5131 "With %B spec, used for a leaf with brothers."
5134 :group 'gnus-thread)
5136 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5137 "With %B spec, used for a leaf without brothers."
5140 :group 'gnus-thread)
5142 (defcustom gnus-summary-display-while-building nil
5143 "If non-nil, show and update the summary buffer as it's being built.
5144 If the value is t, update the buffer after every line is inserted. If
5145 the value is an integer (N), update the display every N lines."
5148 :type '(choice (const :tag "off" nil)
5150 (const :tag "frequently" t)))
5152 (defun gnus-summary-prepare-threads (threads)
5153 "Prepare summary buffer from THREADS and indentation LEVEL.
5154 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5155 or a straight list of headers."
5156 (gnus-message 7 "Generating summary...")
5158 (setq gnus-newsgroup-threads threads)
5161 (let ((gnus-tmp-level 0)
5162 (default-score (or gnus-summary-default-score 0))
5163 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5164 (building-line-count gnus-summary-display-while-building)
5165 (building-count (integerp gnus-summary-display-while-building))
5166 thread number subject stack state gnus-tmp-gathered beg-match
5167 new-roots gnus-tmp-new-adopts thread-end simp-subject
5168 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5169 gnus-tmp-replied gnus-tmp-subject-or-nil
5170 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5171 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5172 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5175 (setq gnus-tmp-prev-subject nil
5176 gnus-tmp-thread-tree-header-string "")
5178 (if (vectorp (car threads))
5179 ;; If this is a straight (sic) list of headers, then a
5180 ;; threaded summary display isn't required, so we just create
5181 ;; an unthreaded one.
5182 (gnus-summary-prepare-unthreaded threads)
5184 ;; Do the threaded display.
5186 (if gnus-summary-display-while-building
5187 (switch-to-buffer (buffer-name)))
5188 (while (or threads stack gnus-tmp-new-adopts new-roots)
5190 (if (and (= gnus-tmp-level 0)
5193 (not gnus-tmp-false-parent)
5194 (or gnus-tmp-new-adopts new-roots))
5195 (if gnus-tmp-new-adopts
5196 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5197 thread (list (car gnus-tmp-new-adopts))
5198 gnus-tmp-header (caar thread)
5199 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5201 (setq thread (list (car new-roots))
5202 gnus-tmp-header (caar thread)
5203 new-roots (cdr new-roots))))
5206 ;; If there are some threads, we do them before the
5207 ;; threads on the stack.
5208 (setq thread threads
5209 gnus-tmp-header (caar thread))
5210 ;; There were no current threads, so we pop something off
5212 (setq state (car stack)
5213 gnus-tmp-level (car state)
5214 tree-stack (cadr state)
5215 thread (caddr state)
5217 gnus-tmp-header (caar thread))))
5219 (setq gnus-tmp-false-parent nil)
5220 (setq gnus-tmp-root-expunged nil)
5221 (setq thread-end nil)
5223 (if (stringp gnus-tmp-header)
5224 ;; The header is a dummy root.
5226 ((eq gnus-summary-make-false-root 'adopt)
5227 ;; We let the first article adopt the rest.
5228 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5230 (setq gnus-tmp-gathered
5232 (lambda (h) (mail-header-number (car h)))
5235 (setq thread (cons (list (caar thread)
5238 (setq gnus-tmp-level -1
5239 gnus-tmp-false-parent t))
5240 ((eq gnus-summary-make-false-root 'empty)
5241 ;; We print adopted articles with empty subject fields.
5242 (setq gnus-tmp-gathered
5244 (lambda (h) (mail-header-number (car h)))
5247 (setq gnus-tmp-level -1))
5248 ((eq gnus-summary-make-false-root 'dummy)
5249 ;; We remember that we probably want to output a dummy
5251 (setq gnus-tmp-dummy-line gnus-tmp-header)
5252 (setq gnus-tmp-prev-subject gnus-tmp-header))
5254 ;; We do not make a root for the gathered
5255 ;; sub-threads at all.
5256 (setq gnus-tmp-level -1)))
5258 (setq number (mail-header-number gnus-tmp-header)
5259 subject (mail-header-subject gnus-tmp-header)
5260 simp-subject (gnus-simplify-subject-fully subject))
5263 ;; If the thread has changed subject, we might want to make
5264 ;; this subthread into a root.
5265 ((and (null gnus-thread-ignore-subject)
5266 (not (zerop gnus-tmp-level))
5267 gnus-tmp-prev-subject
5268 (not (string= gnus-tmp-prev-subject simp-subject)))
5269 (setq new-roots (nconc new-roots (list (car thread)))
5271 gnus-tmp-header nil))
5272 ;; If the article lies outside the current limit,
5273 ;; then we do not display it.
5274 ((not (memq number gnus-newsgroup-limit))
5275 (setq gnus-tmp-gathered
5277 (lambda (h) (mail-header-number (car h)))
5280 (setq gnus-tmp-new-adopts (if (cdar thread)
5281 (append gnus-tmp-new-adopts
5283 gnus-tmp-new-adopts)
5285 gnus-tmp-header nil)
5286 (when (zerop gnus-tmp-level)
5287 (setq gnus-tmp-root-expunged t)))
5288 ;; Perhaps this article is to be marked as read?
5289 ((and gnus-summary-mark-below
5290 (< (or (cdr (assq number gnus-newsgroup-scored))
5292 gnus-summary-mark-below)
5293 ;; Don't touch sparse articles.
5294 (not (gnus-summary-article-sparse-p number))
5295 (not (gnus-summary-article-ancient-p number)))
5296 (setq gnus-newsgroup-unreads
5297 (delq number gnus-newsgroup-unreads))
5298 (if gnus-newsgroup-auto-expire
5299 (setq gnus-newsgroup-expirable
5300 (gnus-add-to-sorted-list
5301 gnus-newsgroup-expirable number))
5302 (push (cons number gnus-low-score-mark)
5303 gnus-newsgroup-reads))))
5305 (when gnus-tmp-header
5306 ;; We may have an old dummy line to output before this
5308 (when (and gnus-tmp-dummy-line
5311 (mail-header-subject gnus-tmp-header)))
5312 (gnus-summary-insert-dummy-line
5313 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5314 (setq gnus-tmp-dummy-line nil))
5316 ;; Compute the mark.
5317 (setq gnus-tmp-unread (gnus-article-mark number))
5319 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5320 gnus-tmp-header gnus-tmp-level)
5321 gnus-newsgroup-data)
5323 ;; Actually insert the line.
5325 gnus-tmp-subject-or-nil
5327 ((and gnus-thread-ignore-subject
5328 gnus-tmp-prev-subject
5329 (not (string= gnus-tmp-prev-subject simp-subject)))
5331 ((zerop gnus-tmp-level)
5332 (if (and (eq gnus-summary-make-false-root 'empty)
5333 (memq number gnus-tmp-gathered)
5334 gnus-tmp-prev-subject
5335 (string= gnus-tmp-prev-subject simp-subject))
5336 gnus-summary-same-subject
5338 (t gnus-summary-same-subject)))
5339 (if (and (eq gnus-summary-make-false-root 'adopt)
5340 (= gnus-tmp-level 1)
5341 (memq number gnus-tmp-gathered))
5342 (setq gnus-tmp-opening-bracket ?\<
5343 gnus-tmp-closing-bracket ?\>)
5344 (setq gnus-tmp-opening-bracket ?\[
5345 gnus-tmp-closing-bracket ?\]))
5346 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5347 (gnus-make-thread-indent-array
5348 (max (* 2 (length gnus-thread-indent-array))
5351 gnus-tmp-indentation
5352 (aref gnus-thread-indent-array gnus-tmp-level)
5353 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5354 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5355 gnus-summary-default-score 0)
5357 (if (or (null gnus-summary-default-score)
5358 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5359 gnus-summary-zcore-fuzz))
5361 (if (< gnus-tmp-score gnus-summary-default-score)
5362 gnus-score-below-mark gnus-score-over-mark))
5364 (cond ((memq number gnus-newsgroup-processable)
5366 ((memq number gnus-newsgroup-cached)
5368 ((memq number gnus-newsgroup-replied)
5370 ((memq number gnus-newsgroup-forwarded)
5371 gnus-forwarded-mark)
5372 ((memq number gnus-newsgroup-saved)
5374 ((memq number gnus-newsgroup-unseen)
5378 (cond ((memq number gnus-newsgroup-undownloaded)
5379 gnus-undownloaded-mark)
5380 (gnus-newsgroup-agentized
5381 gnus-downloaded-mark)
5384 gnus-tmp-from (mail-header-from gnus-tmp-header)
5387 ((string-match "<[^>]+> *$" gnus-tmp-from)
5388 (setq beg-match (match-beginning 0))
5389 (or (and (string-match "^\".+\"" gnus-tmp-from)
5390 (substring gnus-tmp-from 1 (1- (match-end 0))))
5391 (substring gnus-tmp-from 0 beg-match)))
5392 ((string-match "(.+)" gnus-tmp-from)
5393 (substring gnus-tmp-from
5394 (1+ (match-beginning 0)) (1- (match-end 0))))
5398 gnus-tmp-thread-tree-header-string
5400 ((not gnus-show-threads) "")
5401 ((zerop gnus-tmp-level)
5402 (cond ((cdar thread)
5403 (or gnus-sum-thread-tree-root subject))
5404 (gnus-tmp-new-adopts
5405 (or gnus-sum-thread-tree-false-root subject))
5407 (or gnus-sum-thread-tree-single-indent subject))))
5409 (concat (apply 'concat
5410 (mapcar (lambda (item)
5412 gnus-sum-thread-tree-vertical
5413 gnus-sum-thread-tree-indent))
5414 (cdr (reverse tree-stack))))
5416 gnus-sum-thread-tree-leaf-with-other
5417 gnus-sum-thread-tree-single-leaf)))))
5418 (when (string= gnus-tmp-name "")
5419 (setq gnus-tmp-name gnus-tmp-from))
5420 (unless (numberp gnus-tmp-lines)
5421 (setq gnus-tmp-lines -1))
5422 (if (= gnus-tmp-lines -1)
5423 (setq gnus-tmp-lines "?")
5424 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5425 (gnus-put-text-property
5427 (progn (eval gnus-summary-line-format-spec) (point))
5428 'gnus-number number)
5431 (gnus-summary-highlight-line)
5432 (when gnus-summary-update-hook
5433 (gnus-run-hooks 'gnus-summary-update-hook))
5436 (setq gnus-tmp-prev-subject simp-subject)))
5438 (when (nth 1 thread)
5439 (push (list (max 0 gnus-tmp-level)
5440 (copy-sequence tree-stack)
5443 (push (if (nth 1 thread) 1 0) tree-stack)
5444 (incf gnus-tmp-level)
5445 (setq threads (if thread-end nil (cdar thread)))
5446 (if gnus-summary-display-while-building
5449 ;; use a set frequency
5450 (setq building-line-count (1- building-line-count))
5451 (when (= building-line-count 0)
5453 (setq building-line-count
5454 gnus-summary-display-while-building)))
5458 (setq gnus-tmp-level 0)))))
5459 (gnus-message 7 "Generating summary...done"))
5461 (defun gnus-summary-prepare-unthreaded (headers)
5462 "Generate an unthreaded summary buffer based on HEADERS."
5463 (let (header number mark)
5468 ;; We may have to root out some bad articles...
5469 (when (memq (setq number (mail-header-number
5470 (setq header (pop headers))))
5471 gnus-newsgroup-limit)
5472 ;; Mark article as read when it has a low score.
5473 (when (and gnus-summary-mark-below
5474 (< (or (cdr (assq number gnus-newsgroup-scored))
5475 gnus-summary-default-score 0)
5476 gnus-summary-mark-below)
5477 (not (gnus-summary-article-ancient-p number)))
5478 (setq gnus-newsgroup-unreads
5479 (delq number gnus-newsgroup-unreads))
5480 (if gnus-newsgroup-auto-expire
5481 (push number gnus-newsgroup-expirable)
5482 (push (cons number gnus-low-score-mark)
5483 gnus-newsgroup-reads)))
5485 (setq mark (gnus-article-mark number))
5486 (push (gnus-data-make number mark (1+ (point)) header 0)
5487 gnus-newsgroup-data)
5488 (gnus-summary-insert-line
5490 (memq number gnus-newsgroup-undownloaded)
5491 mark (memq number gnus-newsgroup-replied)
5492 (memq number gnus-newsgroup-expirable)
5493 (mail-header-subject header) nil
5494 (cdr (assq number gnus-newsgroup-scored))
5495 (memq number gnus-newsgroup-processable))))))
5497 (defun gnus-group-get-list-identifiers (group)
5498 "Get list identifier regexp for GROUP."
5499 (or (gnus-parameter-list-identifier group)
5500 (if (consp gnus-list-identifiers)
5501 (mapconcat 'identity gnus-list-identifiers " *\\|")
5502 gnus-list-identifiers)))
5504 (defun gnus-summary-remove-list-identifiers ()
5505 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5506 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5509 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5510 (dolist (header gnus-newsgroup-headers)
5511 (setq subject (mail-header-subject header)
5513 (while (string-match regexp subject)
5515 (concat (substring subject 0 (match-beginning 1))
5516 (substring subject (match-end 0)))
5519 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5521 (concat (substring subject 0 (match-beginning 1))
5522 (substring subject (match-end 1)))))
5523 (mail-header-set-subject header subject))))))
5525 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5526 "Fetch headers of ARTICLES."
5527 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5528 (gnus-message 7 "Fetching headers for %s..." name)
5531 (setq gnus-headers-retrieved-by
5532 (gnus-retrieve-headers
5533 articles gnus-newsgroup-name
5535 ;; We might want to fetch old headers, but
5536 ;; not if there is only 1 article.
5538 (not (eq gnus-fetch-old-headers 'some))
5539 (not (numberp gnus-fetch-old-headers)))
5540 (> (length articles) 1))
5541 gnus-fetch-old-headers)))))
5542 (gnus-get-newsgroup-headers-xover
5543 articles force-new dependencies gnus-newsgroup-name t)
5544 (gnus-get-newsgroup-headers dependencies force-new))
5545 (gnus-message 7 "Fetching headers for %s...done" name))))
5547 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5548 "Select newsgroup GROUP.
5549 If READ-ALL is non-nil, all articles in the group are selected.
5550 If SELECT-ARTICLES, only select those articles from GROUP."
5551 (let* ((entry (gnus-group-entry group))
5552 ;;!!! Dirty hack; should be removed.
5553 (gnus-summary-ignore-duplicates
5554 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5556 gnus-summary-ignore-duplicates))
5557 (info (nth 2 entry))
5558 charset articles fetched-articles cached)
5560 (unless (gnus-check-server
5561 (set (make-local-variable 'gnus-current-select-method)
5562 (gnus-find-method-for-group group)))
5563 (error "Couldn't open server"))
5564 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5566 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5567 (gnus-activate-group group) ; Or we can activate it...
5568 (progn ; Or we bug out.
5569 (when (equal major-mode 'gnus-summary-mode)
5570 (gnus-kill-buffer (current-buffer)))
5572 "Couldn't activate group %s: %s"
5573 (mm-decode-coding-string group charset)
5574 (mm-decode-coding-string (gnus-status-message group) charset))))
5576 (unless (gnus-request-group group t)
5577 (when (equal major-mode 'gnus-summary-mode)
5578 (gnus-kill-buffer (current-buffer)))
5579 (error "Couldn't request group %s: %s"
5580 (mm-decode-coding-string group charset)
5581 (mm-decode-coding-string (gnus-status-message group) charset)))
5583 (when (and gnus-agent
5584 (gnus-active group))
5585 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5587 (setq gnus-summary-use-undownloaded-faces
5588 (gnus-agent-find-parameter
5590 'agent-enable-undownloaded-faces)))
5592 (setq gnus-newsgroup-name group
5593 gnus-newsgroup-unselected nil
5594 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5596 (let ((display (gnus-group-find-parameter group 'display)))
5597 (setq gnus-newsgroup-display
5599 ((not (zerop (or (car-safe read-all) 0)))
5600 ;; The user entered the group with C-u SPC/RET, let's show
5606 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5608 ;; The following is probably the "correct" solution, but
5609 ;; it makes Gnus fetch all headers and then limit the
5610 ;; articles (which is slow), so instead we hack the
5611 ;; select-articles parameter instead. -- Simon Josefsson
5614 ;; (gnus-byte-compile
5615 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5617 (setq select-articles
5618 (gnus-uncompress-range
5619 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5623 (cdr (gnus-active group)))))
5628 (gnus-summary-setup-default-charset)
5630 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5631 (when (gnus-virtual-group-p group)
5632 (setq cached gnus-newsgroup-cached))
5634 (setq gnus-newsgroup-unreads
5635 (gnus-sorted-ndifference
5636 (gnus-sorted-ndifference gnus-newsgroup-unreads
5637 gnus-newsgroup-marked)
5638 gnus-newsgroup-dormant))
5640 (setq gnus-newsgroup-processable nil)
5642 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5644 ;; Adjust and set lists of article marks.
5646 (gnus-adjust-marked-articles info))
5647 (if (setq articles select-articles)
5648 (setq gnus-newsgroup-unselected
5649 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5650 (setq articles (gnus-articles-to-read group read-all)))
5654 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5656 ((eq articles 0) nil)
5658 ;; Init the dependencies hash table.
5659 (setq gnus-newsgroup-dependencies
5660 (gnus-make-hashtable (length articles)))
5661 (if (gnus-buffer-live-p gnus-group-buffer)
5662 (gnus-set-global-variables)
5663 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5664 ;; Retrieve the headers and read them in.
5666 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5668 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5670 (setq gnus-newsgroup-cached cached))
5672 ;; Suppress duplicates?
5673 (when gnus-suppress-duplicates
5674 (gnus-dup-suppress-articles))
5676 ;; Set the initial limit.
5677 (setq gnus-newsgroup-limit (copy-sequence articles))
5678 ;; Remove canceled articles from the list of unread articles.
5679 (setq fetched-articles
5680 (mapcar (lambda (headers) (mail-header-number headers))
5681 gnus-newsgroup-headers))
5682 (setq gnus-newsgroup-articles fetched-articles)
5683 (setq gnus-newsgroup-unreads
5684 (gnus-sorted-nintersection
5685 gnus-newsgroup-unreads fetched-articles))
5686 (gnus-compute-unseen-list)
5688 ;; Removed marked articles that do not exist.
5689 (gnus-update-missing-marks
5690 (gnus-sorted-difference articles fetched-articles))
5691 ;; We might want to build some more threads first.
5692 (when (and gnus-fetch-old-headers
5693 (eq gnus-headers-retrieved-by 'nov))
5694 (if (eq gnus-fetch-old-headers 'invisible)
5695 (gnus-build-all-threads)
5696 (gnus-build-old-threads)))
5697 ;; Let the Gnus agent mark articles as read.
5699 (gnus-agent-get-undownloaded-list))
5700 ;; Remove list identifiers from subject
5701 (gnus-summary-remove-list-identifiers)
5702 ;; Check whether auto-expire is to be done in this group.
5703 (setq gnus-newsgroup-auto-expire
5704 (and (gnus-group-auto-expirable-p group)
5705 (not (gnus-group-read-only-p group))))
5706 ;; Set up the article buffer now, if necessary.
5707 (unless (and gnus-single-article-buffer
5708 (equal gnus-article-buffer "*Article*"))
5709 (gnus-article-setup-buffer))
5710 ;; First and last article in this newsgroup.
5711 (when gnus-newsgroup-headers
5712 (setq gnus-newsgroup-begin
5713 (mail-header-number (car gnus-newsgroup-headers))
5716 (gnus-last-element gnus-newsgroup-headers))))
5717 ;; GROUP is successfully selected.
5718 (or gnus-newsgroup-headers t)))))
5720 (defun gnus-compute-unseen-list ()
5721 ;; The `seen' marks are treated specially.
5722 (if (not gnus-newsgroup-seen)
5723 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5724 (setq gnus-newsgroup-unseen
5725 (gnus-inverse-list-range-intersection
5726 gnus-newsgroup-articles gnus-newsgroup-seen))))
5728 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5730 (defun gnus-summary-display-make-predicate (display)
5731 (require 'gnus-agent)
5732 (when (= (length display) 1)
5733 (setq display (car display)))
5734 (unless gnus-summary-display-cache
5735 (dolist (elem (append '((unread . unread)
5738 gnus-article-mark-lists))
5739 (push (cons (cdr elem)
5740 (gnus-byte-compile ;Why bother?
5741 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5742 gnus-summary-display-cache)))
5743 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5744 (gnus-category-predicate-cache gnus-summary-display-cache))
5745 (gnus-get-predicate display)))
5747 ;; Uses the dynamically bound `gnus-number' variable.
5748 (defvar gnus-number)
5749 (defun gnus-article-marked-p (type &optional article)
5750 (let ((article (or article gnus-number)))
5753 (memq article gnus-newsgroup-marked))
5755 (memq article gnus-newsgroup-spam-marked))
5757 (memq article gnus-newsgroup-unsendable))
5758 ((eq type 'undownload)
5759 (memq article gnus-newsgroup-undownloaded))
5760 ((eq type 'download)
5761 (memq article gnus-newsgroup-downloadable))
5763 (memq article gnus-newsgroup-unreads))
5765 (memq article gnus-newsgroup-reads))
5767 (memq article gnus-newsgroup-dormant) )
5769 (memq article gnus-newsgroup-expirable))
5771 (memq article gnus-newsgroup-replied))
5773 (memq article gnus-newsgroup-killed))
5774 ((eq type 'bookmark)
5775 (assq article gnus-newsgroup-bookmarks))
5777 (assq article gnus-newsgroup-scored))
5779 (memq article gnus-newsgroup-saved))
5781 (memq article gnus-newsgroup-cached))
5783 (memq article gnus-newsgroup-forwarded))
5785 (not (memq article gnus-newsgroup-unseen)))
5788 (defun gnus-articles-to-read (group &optional read-all)
5789 "Find out what articles the user wants to read."
5790 (let* ((only-read-p t)
5792 ;; Select all articles if `read-all' is non-nil, or if there
5793 ;; are no unread articles.
5795 (and (zerop (length gnus-newsgroup-marked))
5796 (zerop (length gnus-newsgroup-unreads)))
5797 ;; Fetch all if the predicate is non-nil.
5798 gnus-newsgroup-display)
5799 ;; We want to select the headers for all the articles in
5800 ;; the group, so we select either all the active
5801 ;; articles in the group, or (if that's nil), the
5802 ;; articles in the cache.
5804 (if gnus-newsgroup-maximum-articles
5805 (let ((active (gnus-active group)))
5806 (gnus-uncompress-range
5807 (cons (max (car active)
5809 gnus-newsgroup-maximum-articles
5812 (gnus-uncompress-range (gnus-active group)))
5813 (gnus-cache-articles-in-group group))
5814 ;; Select only the "normal" subset of articles.
5815 (setq only-read-p nil)
5817 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5818 gnus-newsgroup-unreads)))
5819 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5820 (scored (length scored-list))
5821 (number (length articles))
5822 (marked (+ (length gnus-newsgroup-marked)
5823 (length gnus-newsgroup-dormant)))
5828 ((numberp gnus-newsgroup-display)
5829 gnus-newsgroup-display)
5833 ((and (or (<= scored marked) (= scored number))
5834 (numberp gnus-large-newsgroup)
5835 (> number gnus-large-newsgroup))
5836 (let* ((cursor-in-echo-area nil)
5837 (initial (gnus-parameter-large-newsgroup-initial
5838 gnus-newsgroup-name))
5839 (default (if only-read-p
5840 (or initial gnus-large-newsgroup)
5846 "How many articles from %s (available %d, default %d): "
5847 (gnus-group-decoded-name
5848 (gnus-group-real-name gnus-newsgroup-name))
5851 "How many articles from %s (%d default): "
5852 (gnus-group-decoded-name
5853 (gnus-group-real-name gnus-newsgroup-name))
5857 (number-to-string default))))
5858 (if (string-match "^[ \t]*$" input) number input)))
5859 ((and (> scored marked) (< scored number)
5860 (> (- scored number) 20))
5863 (format "%s %s (%d scored, %d total): "
5864 "How many articles from"
5865 (gnus-group-decoded-name
5866 (gnus-group-real-name gnus-newsgroup-name))
5868 (if (string-match "^[ \t]*$" input)
5872 (message "Quit getting the articles to read")
5874 (setq select (if (stringp select) (string-to-number select) select))
5875 (if (or (null select) (zerop select))
5877 (if (and (not (zerop scored)) (<= (abs select) scored))
5879 (setq articles (sort scored-list '<))
5880 (setq number (length articles)))
5881 (setq articles (copy-sequence articles)))
5883 (when (< (abs select) number)
5885 ;; Select the N oldest articles.
5886 (setcdr (nthcdr (1- (abs select)) articles) nil)
5887 ;; Select the N most recent articles.
5888 (setq articles (nthcdr (- number select) articles))))
5889 (setq gnus-newsgroup-unselected
5890 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5891 (when gnus-alter-articles-to-read-function
5894 (funcall gnus-alter-articles-to-read-function
5895 gnus-newsgroup-name articles)
5899 (defun gnus-killed-articles (killed articles)
5902 (when (inline (gnus-member-of-range (car articles) killed))
5903 (push (car articles) out))
5904 (setq articles (cdr articles)))
5907 (defun gnus-article-mark-to-type (mark)
5908 "Return the type of MARK."
5909 (or (cadr (assq mark gnus-article-special-mark-lists))
5912 (defun gnus-article-unpropagatable-p (mark)
5913 "Return whether MARK should be propagated to back end."
5914 (memq mark gnus-article-unpropagated-mark-lists))
5916 (defun gnus-adjust-marked-articles (info)
5917 "Set all article lists and remove all marks that are no longer valid."
5918 (let* ((marked-lists (gnus-info-marks info))
5919 (active (gnus-active (gnus-info-group info)))
5922 (types gnus-article-mark-lists)
5923 marks var articles article mark mark-type
5925 ;; Hack to avoid adjusting marks for imap.
5926 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5930 (dolist (marks marked-lists)
5931 (setq mark (car marks)
5932 mark-type (gnus-article-mark-to-type mark)
5933 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5934 ;; We set the variable according to the type of the marks list,
5935 ;; and then adjust the marks to a subset of the active articles.
5937 ;; Adjust "simple" lists - compressed yet unsorted
5938 ((eq mark-type 'list)
5939 ;; Simultaneously uncompress and clip to active range
5940 ;; See gnus-uncompress-range for a description of possible marks
5942 (if (not (cadr marks))
5944 (setq articles (if (numberp (cddr marks))
5950 (while (setq article (pop articles))
5951 (cond ((consp article)
5952 (setq bgn (max (car article) min)
5953 end (min (cdr article) max))
5955 (setq l (setcdr l (cons bgn nil))
5957 ((and (<= min article)
5959 (setq l (setcdr l (cons article nil))))))
5960 (set var (cdr lh)))))
5962 ((eq mark-type 'tuple)
5963 (set var (setq articles (cdr marks)))
5964 (when (not (listp (cdr (symbol-value var))))
5965 (set var (list (symbol-value var))))
5966 (when (not (listp (cdr articles)))
5967 (setq articles (list articles)))
5969 (when (or (not (consp (setq article (pop articles))))
5970 (< (car article) min)
5971 (> (car article) max))
5972 (set var (delq article (symbol-value var))))))
5973 ;; Adjust ranges (sloppily).
5974 ((eq mark-type 'range)
5977 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5978 ;; It should be (seen (NUM1 . NUM2)).
5979 (when (numberp (cddr marks))
5980 (setcdr marks (list (cdr marks))))
5981 (setq articles (cdr marks))
5982 (while (and articles
5983 (or (and (consp (car articles))
5984 (> min (cdar articles)))
5985 (and (numberp (car articles))
5986 (> min (car articles)))))
5988 (set var articles))))))))
5990 (defun gnus-update-missing-marks (missing)
5991 "Go through the list of MISSING articles and remove them from the mark lists."
5994 ;; Go through all types.
5995 (dolist (elem gnus-article-mark-lists)
5996 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5997 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5998 (when (symbol-value var)
5999 ;; This list has articles. So we delete all missing
6000 ;; articles from it.
6003 (set var (delq (pop m) (symbol-value var))))))))))
6005 (defun gnus-update-marks ()
6006 "Enter the various lists of marked articles into the newsgroup info list."
6007 (let ((types gnus-article-mark-lists)
6008 (info (gnus-get-info gnus-newsgroup-name))
6009 type list newmarked symbol delta-marks)
6011 ;; Add all marks lists to the list of marks lists.
6012 (while (setq type (pop types))
6013 (setq list (symbol-value
6015 (intern (format "gnus-newsgroup-%s" (car type))))))
6018 ;; Get rid of the entries of the articles that have the
6020 (when (and (eq (cdr type) 'score)
6024 (prev (cons nil list))
6027 (if (or (not (consp (car arts)))
6028 (= (cdar arts) gnus-summary-default-score))
6029 (setcdr prev (cdr arts))
6031 (setq arts (cdr arts)))
6032 (setq list (cdr all)))))
6034 (when (eq (cdr type) 'seen)
6035 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6037 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6038 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6040 (when (and (gnus-check-backend-function
6041 'request-set-mark gnus-newsgroup-name)
6042 (not (gnus-article-unpropagatable-p (cdr type))))
6043 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6044 ;; Don't do anything about marks for articles we
6045 ;; didn't actually get any headers for.
6047 (gnus-list-range-intersection
6048 gnus-newsgroup-articles
6049 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6051 (gnus-list-range-intersection
6052 gnus-newsgroup-articles
6053 (gnus-remove-from-range
6054 (gnus-copy-sequence list) old))))
6056 (push (list add 'add (list (cdr type))) delta-marks))
6058 ;; Don't delete marks from outside the active range.
6059 ;; This shouldn't happen, but is a sanity check.
6060 (setq del (gnus-sorted-range-intersection
6061 (gnus-active gnus-newsgroup-name) del))
6062 (push (list del 'del (list (cdr type))) delta-marks))))
6065 (push (cons (cdr type) list) newmarked)))
6068 (unless (gnus-check-group gnus-newsgroup-name)
6069 (error "Can't open server for %s" gnus-newsgroup-name))
6070 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6072 ;; Enter these new marks into the info of the group.
6074 (setcar (nthcdr 3 info) newmarked)
6075 ;; Add the marks lists to the end of the info.
6077 (setcdr (nthcdr 2 info) (list newmarked))))
6079 ;; Cut off the end of the info if there's nothing else there.
6083 (when (nthcdr (decf i) info)
6084 (setcdr (nthcdr i info) nil)))))))
6086 (defun gnus-set-mode-line (where)
6087 "Set the mode line of the article or summary buffers.
6088 If WHERE is `summary', the summary mode line format will be used."
6089 ;; Is this mode line one we keep updated?
6090 (when (and (memq where gnus-updated-mode-lines)
6092 (intern (format "gnus-%s-mode-line-format-spec" where))))
6094 ;; We evaluate this in the summary buffer since these
6095 ;; variables are buffer-local to that buffer.
6096 (with-current-buffer gnus-summary-buffer
6097 ;; We bind all these variables that are used in the `eval' form
6099 (let* ((mformat (symbol-value
6101 (format "gnus-%s-mode-line-format-spec" where))))
6102 (gnus-tmp-group-name (gnus-mode-string-quote
6103 (gnus-group-decoded-name
6104 gnus-newsgroup-name)))
6105 (gnus-tmp-article-number (or gnus-current-article 0))
6106 (gnus-tmp-unread gnus-newsgroup-unreads)
6107 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6108 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6109 (gnus-tmp-unread-and-unselected
6110 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6111 (zerop gnus-tmp-unselected))
6113 ((zerop gnus-tmp-unselected)
6114 (format "{%d more}" gnus-tmp-unread-and-unticked))
6115 (t (format "{%d(+%d) more}"
6116 gnus-tmp-unread-and-unticked
6117 gnus-tmp-unselected))))
6119 (if (and gnus-current-headers
6120 (vectorp gnus-current-headers))
6121 (gnus-mode-string-quote
6122 (mail-header-subject gnus-current-headers))
6124 bufname-length max-len
6125 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6126 (setq mode-string (eval mformat))
6127 (setq bufname-length (if (string-match "%b" mode-string)
6130 (if (eq where 'summary)
6132 (get-buffer gnus-article-buffer))))
6135 (setq max-len (max 4 (if gnus-mode-non-string-length
6137 gnus-mode-non-string-length
6139 (length mode-string))))
6140 ;; We might have to chop a bit of the string off...
6141 (when (> (length mode-string) max-len)
6143 (concat (truncate-string-to-width mode-string (- max-len 3))
6145 ;; Update the mode line.
6146 (setq mode-line-buffer-identification
6147 (gnus-mode-line-buffer-identification (list mode-string)))
6148 (set-buffer-modified-p t))))
6150 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6151 "Go through the HEADERS list and add all Xrefs to a hash table.
6152 The resulting hash table is returned, or nil if no Xrefs were found."
6153 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6154 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6155 (xref-hashtb (gnus-make-hashtable))
6156 start group entry number xrefs header)
6158 (setq header (pop headers))
6159 (when (and (setq xrefs (mail-header-xref header))
6160 (not (memq (setq number (mail-header-number header))
6163 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6164 (setq start (match-end 0))
6165 (setq group (if prefix
6166 (concat prefix (substring xrefs (match-beginning 1)
6168 (substring xrefs (match-beginning 1) (match-end 1))))
6170 (string-to-number (substring xrefs (match-beginning 2)
6172 (if (setq entry (gnus-gethash group xref-hashtb))
6173 (setcdr entry (cons number (cdr entry)))
6174 (gnus-sethash group (cons number nil) xref-hashtb)))))
6175 (and start xref-hashtb)))
6177 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6178 "Look through all the headers and mark the Xrefs as read."
6179 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6180 name info xref-hashtb idlist method nth4)
6181 (with-current-buffer gnus-group-buffer
6182 (when (setq xref-hashtb
6183 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6186 (unless (string= from-newsgroup (setq name (symbol-name group)))
6187 (setq idlist (symbol-value group))
6188 ;; Dead groups are not updated.
6190 (setq info (gnus-get-info name))
6191 (when (stringp (setq nth4 (gnus-info-method info)))
6192 (setq nth4 (gnus-server-to-method nth4))))
6193 ;; Only do the xrefs if the group has the same
6194 ;; select method as the group we have just read.
6195 (or (gnus-methods-equal-p
6196 nth4 (gnus-find-method-for-group from-newsgroup))
6198 (equal nth4 (setq method (gnus-find-method-for-group
6200 (and (equal (car nth4) (car method))
6201 (equal (nth 1 nth4) (nth 1 method))))
6202 gnus-use-cross-reference
6203 (or (not (eq gnus-use-cross-reference t))
6205 ;; Only do cross-references on subscribed
6206 ;; groups, if that is what is wanted.
6207 (<= (gnus-info-level info) gnus-level-subscribed))
6208 (gnus-group-make-articles-read name idlist))))
6211 (defun gnus-compute-read-articles (group articles)
6212 (let* ((entry (gnus-group-entry group))
6213 (info (nth 2 entry))
6214 (active (gnus-active group))
6217 ;; First peel off all invalid article numbers.
6219 (let ((ids articles)
6221 (while (setq id (pop ids))
6222 (when (and first (> id (cdr active)))
6223 ;; We'll end up in this situation in one particular
6224 ;; obscure situation. If you re-scan a group and get
6225 ;; a new article that is cross-posted to a different
6226 ;; group that has not been re-scanned, you might get
6227 ;; crossposted article that has a higher number than
6228 ;; Gnus believes possible. So we re-activate this
6229 ;; group as well. This might mean doing the
6230 ;; crossposting thingy will *increase* the number
6231 ;; of articles in some groups. Tsk, tsk.
6232 (setq active (or (gnus-activate-group group) active)))
6233 (when (or (> id (cdr active))
6234 (< id (car active)))
6235 (setq articles (delq id articles))))))
6236 ;; If the read list is nil, we init it.
6238 (null (gnus-info-read info))
6240 (setq ninfo (cons 1 (1- (car active))))
6241 (setq ninfo (gnus-info-read info)))
6242 ;; Then we add the read articles to the range.
6244 ninfo (setq articles (sort articles '<))))))
6246 (defun gnus-group-make-articles-read (group articles)
6247 "Update the info of GROUP to say that ARTICLES are read."
6249 (entry (gnus-group-entry group))
6250 (info (nth 2 entry))
6251 (active (gnus-active group))
6253 (gnus-method-option-p
6254 (gnus-find-method-for-group group)
6258 ;; Group that Gnus doesn't know exists, but still allow the
6259 ;; backend to set marks.
6261 (gnus-request-set-mark
6262 group (list (list (gnus-compress-sequence (sort articles #'<))
6264 ;; Normal, subscribed groups.
6265 (setq range (gnus-compute-read-articles group articles))
6266 (with-current-buffer gnus-group-buffer
6269 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6270 (gnus-info-set-read ',info ',(gnus-info-read info))
6271 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6273 (gnus-request-set-mark
6274 ,group (list (list ',range 'del '(read)))))
6275 (gnus-group-update-group ,group t))))
6276 ;; Add the read articles to the range.
6277 (gnus-info-set-read info range)
6279 (gnus-request-set-mark group (list (list range 'add '(read)))))
6280 ;; Then we have to re-compute how many unread
6281 ;; articles there are in this group.
6285 (setq num (- (1+ (cdr active)) (car active))))
6286 ((not (listp (cdr range)))
6287 (setq num (- (cdr active) (- (1+ (cdr range))
6291 (if (numberp (car range))
6293 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6294 (setq range (cdr range)))
6295 (setq num (- (cdr active) num))))
6296 ;; Update the number of unread articles.
6298 ;; Update the group buffer.
6299 (unless (gnus-ephemeral-group-p group)
6300 (gnus-group-update-group group t))))))
6302 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6303 (let ((cur nntp-server-buffer)
6306 (with-current-buffer gnus-summary-buffer
6307 gnus-newsgroup-dependencies)))
6308 headers id end ref number
6309 (mail-parse-charset gnus-newsgroup-charset)
6310 (mail-parse-ignored-charsets
6311 (save-current-buffer (condition-case nil
6312 (set-buffer gnus-summary-buffer)
6314 gnus-newsgroup-ignored-charsets)))
6315 (with-current-buffer nntp-server-buffer
6316 ;; Translate all TAB characters into SPACE characters.
6317 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6318 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6319 (ietf-drums-unfold-fws)
6320 (gnus-run-hooks 'gnus-parse-headers-hook)
6321 (let ((case-fold-search t)
6322 in-reply-to header p lines chars)
6323 (goto-char (point-min))
6324 ;; Search to the beginning of the next header. Error messages
6325 ;; do not begin with 2 or 3.
6326 (while (re-search-forward "^[23][0-9]+ " nil t)
6329 ;; This implementation of this function, with nine
6330 ;; search-forwards instead of the one re-search-forward and
6331 ;; a case (which basically was the old function) is actually
6332 ;; about twice as fast, even though it looks messier. You
6333 ;; can't have everything, I guess. Speed and elegance
6334 ;; doesn't always go hand in hand.
6340 (setq number (read cur))
6343 (narrow-to-region (point)
6344 (or (and (search-forward "\n.\n" nil t)
6350 (if (search-forward "\nsubject:" nil t)
6351 (funcall gnus-decode-encoded-word-function
6352 (nnheader-header-value))
6357 (if (search-forward "\nfrom:" nil t)
6358 (funcall gnus-decode-encoded-address-function
6359 (nnheader-header-value))
6364 (if (search-forward "\ndate:" nil t)
6365 (nnheader-header-value) ""))
6369 (setq id (if (re-search-forward
6370 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6371 ;; We do it this way to make sure the Message-ID
6372 ;; is (somewhat) syntactically valid.
6373 (buffer-substring (match-beginning 1)
6375 ;; If there was no message-id, we just fake one
6376 ;; to make subsequent routines simpler.
6377 (nnheader-generate-fake-message-id number))))
6381 (if (search-forward "\nreferences:" nil t)
6385 (nnheader-header-value)
6390 (search-backward ">" end t)
6393 (search-backward "<" end t)
6395 ;; Get the references from the in-reply-to header if there
6396 ;; were no references and the in-reply-to header looks
6398 (if (and (search-forward "\nin-reply-to:" nil t)
6399 (setq in-reply-to (nnheader-header-value))
6400 (string-match "<[^>]+>" in-reply-to))
6402 (setq ref (substring in-reply-to (match-beginning 0)
6404 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6405 (setq ref2 (substring in-reply-to (match-beginning 0)
6407 (when (> (length ref2) (length ref))
6414 (if (search-forward "\nchars: " nil t)
6415 (if (numberp (setq chars (ignore-errors (read cur))))
6421 (if (search-forward "\nlines: " nil t)
6422 (if (numberp (setq lines (ignore-errors (read cur))))
6428 (and (search-forward "\nxref:" nil t)
6429 (nnheader-header-value)))
6431 (when gnus-extra-headers
6432 (let ((extra gnus-extra-headers)
6436 (when (search-forward
6437 (concat "\n" (symbol-name (car extra)) ":") nil t)
6438 (push (cons (car extra) (nnheader-header-value))
6442 (when (equal id ref)
6445 (when gnus-alter-header-function
6446 (funcall gnus-alter-header-function header)
6447 (setq id (mail-header-id header)
6448 ref (gnus-parent-id (mail-header-references header))))
6451 (gnus-dependencies-add-header
6452 header dependencies force-new))
6453 (push header headers))
6454 (goto-char (point-max))
6456 (nreverse headers)))))
6458 ;; Goes through the xover lines and returns a list of vectors
6459 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6460 force-new dependencies
6461 group also-fetch-heads)
6462 "Parse the news overview data in the server buffer.
6463 Return a list of headers that match SEQUENCE (see
6464 `nntp-retrieve-headers')."
6465 ;; Get the Xref when the users reads the articles since most/some
6466 ;; NNTP servers do not include Xrefs when using XOVER.
6467 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6468 (let ((mail-parse-charset gnus-newsgroup-charset)
6469 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6470 (cur nntp-server-buffer)
6471 (dependencies (or dependencies gnus-newsgroup-dependencies))
6473 ((eq gnus-read-all-available-headers t)
6475 ((and (stringp gnus-read-all-available-headers)
6477 (string-match gnus-read-all-available-headers group))
6480 number headers header)
6481 (with-current-buffer nntp-server-buffer
6482 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6483 ;; Allow the user to mangle the headers before parsing them.
6484 (gnus-run-hooks 'gnus-parse-headers-hook)
6485 (goto-char (point-min))
6486 (gnus-parse-without-error
6487 (while (and (or sequence allp)
6489 (setq number (read cur))
6491 (while (and sequence
6492 (< (car sequence) number))
6493 (setq sequence (cdr sequence))))
6496 (eq number (car sequence))))
6498 (setq sequence (cdr sequence))
6499 (setq header (inline
6500 (gnus-nov-parse-line
6501 number dependencies force-new)))))
6502 (push header headers))
6504 ;; A common bug in inn is that if you have posted an article and
6505 ;; then retrieves the active file, it will answer correctly --
6506 ;; the new article is included. However, a NOV entry for the
6507 ;; article may not have been generated yet, so this may fail.
6508 ;; We work around this problem by retrieving the last few
6509 ;; headers using HEAD.
6510 (if (or (not also-fetch-heads)
6512 ;; We (probably) got all the headers.
6514 (let ((gnus-nov-is-evil t))
6517 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6518 (gnus-get-newsgroup-headers))))))))
6520 (defun gnus-article-get-xrefs ()
6521 "Fill in the Xref value in `gnus-current-headers', if necessary.
6522 This is meant to be called in `gnus-article-internal-prepare-hook'."
6523 (let ((headers (with-current-buffer gnus-summary-buffer
6524 gnus-current-headers)))
6525 (or (not gnus-use-cross-reference)
6527 (and (mail-header-xref headers)
6528 (not (string= (mail-header-xref headers) "")))
6529 (let ((case-fold-search t)
6532 (nnheader-narrow-to-headers)
6533 (goto-char (point-min))
6534 (when (or (and (not (eobp))
6535 (eq (downcase (char-after)) ?x)
6536 (looking-at "Xref:"))
6537 (search-forward "\nXref:" nil t))
6538 (goto-char (1+ (match-end 0)))
6539 (setq xref (buffer-substring (point) (point-at-eol)))
6540 (mail-header-set-xref headers xref)))))))
6542 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6543 "Find article ID and insert the summary line for that article.
6544 OLD-HEADER can either be a header or a line number to insert
6545 the subject line on.
6546 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6547 and OLD-HEADER will be used when the summary line is inserted,
6548 too, instead of trying to fetch new headers."
6549 (let* ((line (and (numberp old-header) old-header))
6550 (old-header (and (vectorp old-header) old-header))
6551 (header (cond ((and old-header use-old-header)
6554 (gnus-number-to-header id))
6555 (gnus-number-to-header id))
6557 (gnus-read-header id))))
6558 (number (and (numberp id) id))
6561 ;; Rebuild the thread that this article is part of and go to the
6562 ;; article we have fetched.
6563 (when (and (not gnus-show-threads)
6566 (setq d (gnus-data-find (mail-header-number old-header))))
6567 (goto-char (gnus-data-pos d))
6573 (gnus-delete-line))))))
6574 ;; Remove list identifiers from subject.
6575 (let ((gnus-newsgroup-headers (list header)))
6576 (gnus-summary-remove-list-identifiers))
6578 (mail-header-set-number header (mail-header-number old-header)))
6579 (setq gnus-newsgroup-sparse
6580 (delq (setq number (mail-header-number header))
6581 gnus-newsgroup-sparse))
6582 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6583 (push number gnus-newsgroup-limit)
6584 (gnus-rebuild-thread (mail-header-id header) line)
6585 (gnus-summary-goto-subject number nil t))
6586 (when (and (numberp number)
6588 ;; We have to update the boundaries even if we can't fetch the
6589 ;; article if ID is a number -- so that the next `P' or `N'
6590 ;; command will fetch the previous (or next) article even
6591 ;; if the one we tried to fetch this time has been canceled.
6592 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6593 (setq gnus-newsgroup-end number))
6594 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6595 (setq gnus-newsgroup-begin number))
6596 (setq gnus-newsgroup-unselected
6597 (delq number gnus-newsgroup-unselected)))
6598 ;; Report back a success?
6599 (and header (mail-header-number header))))
6601 ;;; Process/prefix in the summary buffer
6603 (defun gnus-summary-work-articles (n)
6604 "Return a list of articles to be worked upon.
6605 The prefix argument, the list of process marked articles, and the
6606 current article will be taken into consideration."
6607 (with-current-buffer gnus-summary-buffer
6610 ;; A numerical prefix has been given.
6611 (setq n (prefix-numeric-value n))
6612 (let ((backward (< n 0))
6613 (n (abs (prefix-numeric-value n)))
6618 (push (setq article (gnus-summary-article-number))
6621 (gnus-summary-find-prev nil article)
6622 (gnus-summary-find-next nil article)))
6624 (nreverse articles)))
6625 ((and (gnus-region-active-p) (mark))
6626 (message "region active")
6627 ;; Work on the region between point and mark.
6628 (let ((max (max (point) (mark)))
6631 (goto-char (min (point) (mark)))
6634 (push (setq article (gnus-summary-article-number)) articles)
6635 (gnus-summary-find-next nil article)
6637 (nreverse articles))))
6638 (gnus-newsgroup-processable
6639 ;; There are process-marked articles present.
6640 ;; Save current state.
6641 (gnus-summary-save-process-mark)
6643 (reverse gnus-newsgroup-processable))
6645 ;; Just return the current article.
6646 (list (gnus-summary-article-number))))))
6648 (defmacro gnus-summary-iterate (arg &rest forms)
6649 "Iterate over the process/prefixed articles and do FORMS.
6650 ARG is the interactive prefix given to the command. FORMS will be
6651 executed with point over the summary line of the articles."
6652 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6653 `(let ((,articles (gnus-summary-work-articles ,arg)))
6655 (gnus-summary-goto-subject (car ,articles))
6659 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6660 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6662 (defun gnus-summary-save-process-mark ()
6663 "Push the current set of process marked articles on the stack."
6665 (push (copy-sequence gnus-newsgroup-processable)
6666 gnus-newsgroup-process-stack))
6668 (defun gnus-summary-kill-process-mark ()
6669 "Push the current set of process marked articles on the stack and unmark."
6671 (gnus-summary-save-process-mark)
6672 (gnus-summary-unmark-all-processable))
6674 (defun gnus-summary-yank-process-mark ()
6675 "Pop the last process mark state off the stack and restore it."
6677 (unless gnus-newsgroup-process-stack
6678 (error "Empty mark stack"))
6679 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6681 (defun gnus-summary-process-mark-set (set)
6682 "Make SET into the current process marked articles."
6683 (gnus-summary-unmark-all-processable)
6684 (mapc 'gnus-summary-set-process-mark set))
6686 ;;; Searching and stuff
6688 (defun gnus-summary-search-group (&optional backward use-level)
6689 "Search for next unread newsgroup.
6690 If optional argument BACKWARD is non-nil, search backward instead."
6691 (with-current-buffer gnus-group-buffer
6692 (when (gnus-group-search-forward
6693 backward nil (if use-level (gnus-group-group-level) nil))
6694 (gnus-group-group-name))))
6696 (defun gnus-summary-best-group (&optional exclude-group)
6697 "Find the name of the best unread group.
6698 If EXCLUDE-GROUP, do not go to this group."
6699 (with-current-buffer gnus-group-buffer
6701 (gnus-group-best-unread-group exclude-group))))
6703 (defun gnus-summary-find-next (&optional unread article backward)
6705 (gnus-summary-find-prev unread article)
6706 (let* ((dummy (gnus-summary-article-intangible-p))
6707 (article (or article (gnus-summary-article-number)))
6708 (data (gnus-data-find-list article))
6710 (when (and (not dummy)
6711 (or (not gnus-summary-check-current)
6713 (not (gnus-data-unread-p (car data)))))
6714 (setq data (cdr data)))
6719 (unless (memq (gnus-data-number (car data))
6721 ((eq gnus-auto-goto-ignores
6722 'always-undownloaded)
6723 gnus-newsgroup-undownloaded)
6726 ((eq gnus-auto-goto-ignores
6728 gnus-newsgroup-unfetched)
6729 ((eq gnus-auto-goto-ignores
6731 gnus-newsgroup-undownloaded)))
6732 (when (gnus-data-unread-p (car data))
6733 (setq result (car data)
6735 (setq data (cdr data)))
6738 (goto-char (gnus-data-pos result))
6739 (gnus-data-number result)))))
6741 (defun gnus-summary-find-prev (&optional unread article)
6742 (let* ((eobp (eobp))
6743 (article (or article (gnus-summary-article-number)))
6744 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6746 (when (and (not eobp)
6747 (or (not gnus-summary-check-current)
6749 (not (gnus-data-unread-p (car data)))))
6750 (setq data (cdr data)))
6755 (unless (memq (gnus-data-number (car data))
6757 ((eq gnus-auto-goto-ignores
6758 'always-undownloaded)
6759 gnus-newsgroup-undownloaded)
6762 ((eq gnus-auto-goto-ignores
6764 gnus-newsgroup-unfetched)
6765 ((eq gnus-auto-goto-ignores
6767 gnus-newsgroup-undownloaded)))
6768 (when (gnus-data-unread-p (car data))
6769 (setq result (car data)
6771 (setq data (cdr data)))
6774 (goto-char (gnus-data-pos result))
6775 (gnus-data-number result))))
6777 (defun gnus-summary-find-subject (subject &optional unread backward article)
6778 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6779 (article (or article (gnus-summary-article-number)))
6780 (articles (gnus-data-list backward))
6781 (arts (gnus-data-find-list article articles))
6783 (when (or (not gnus-summary-check-current)
6785 (not (gnus-data-unread-p (car arts))))
6786 (setq arts (cdr arts)))
6788 (and (or (not unread)
6789 (gnus-data-unread-p (car arts)))
6790 (vectorp (gnus-data-header (car arts)))
6792 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6793 (setq result (car arts)
6795 (setq arts (cdr arts)))
6797 (goto-char (gnus-data-pos result))
6798 (gnus-data-number result))))
6800 (defun gnus-summary-search-forward (&optional unread subject backward)
6801 "Search forward for an article.
6802 If UNREAD, look for unread articles. If SUBJECT, look for
6803 articles with that subject. If BACKWARD, search backward instead."
6804 (cond (subject (gnus-summary-find-subject subject unread backward))
6805 (backward (gnus-summary-find-prev unread))
6806 (t (gnus-summary-find-next unread))))
6808 (defun gnus-recenter (&optional n)
6809 "Center point in window and redisplay frame.
6810 Also do horizontal recentering."
6812 (when (and gnus-auto-center-summary
6813 (not (eq gnus-auto-center-summary 'vertical)))
6814 (gnus-horizontal-recenter))
6815 (if (fboundp 'recenter-top-bottom)
6816 (recenter-top-bottom n)
6819 (put 'gnus-recenter 'isearch-scroll t)
6821 (defun gnus-forward-line-ignore-invisible (n)
6822 "Move N lines forward (backward if N is negative).
6823 Like forward-line, but skip over (and don't count) invisible lines."
6825 (while (and (> n 0) (not done))
6826 ;; If the following character is currently invisible,
6827 ;; skip all characters with that same `invisible' property value.
6828 (while (gnus-invisible-p (point))
6829 (goto-char (gnus-next-char-property-change (point))))
6834 (while (and (< n 0) (not done))
6836 (if (bobp) (setq done t)
6838 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6839 (goto-char (gnus-previous-char-property-change (point))))))))
6841 (defun gnus-summary-recenter ()
6842 "Center point in the summary window.
6843 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6844 displayed, no centering will be performed."
6845 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6846 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6848 ;; The user has to want it.
6849 (when gnus-auto-center-summary
6850 (let* ((top (cond ((< (window-height) 4) 0)
6851 ((< (window-height) 7) 1)
6852 (t (if (numberp gnus-auto-center-summary)
6853 gnus-auto-center-summary
6854 (/ (1- (window-height)) 2)))))
6855 (height (1- (window-height)))
6856 (bottom (save-excursion
6857 (goto-char (point-max))
6858 (gnus-forward-line-ignore-invisible (- height))
6860 (window (get-buffer-window (current-buffer))))
6861 (when (get-buffer-window gnus-article-buffer)
6862 ;; Only do recentering when the article buffer is displayed,
6863 ;; Set the window start to either `bottom', which is the biggest
6864 ;; possible valid number, or the second line from the top,
6865 ;; whichever is the least.
6866 (let ((top-pos (save-excursion
6867 (gnus-forward-line-ignore-invisible (- top))
6869 (if (> bottom top-pos)
6870 ;; Keep the second line from the top visible
6871 (set-window-start window top-pos)
6872 ;; Try to keep the bottom line visible; if it's partially
6873 ;; obscured, either scroll one more line to make it fully
6874 ;; visible, or revert to using TOP-POS.
6876 (goto-char (point-max))
6877 (gnus-forward-line-ignore-invisible -1)
6878 (let ((last-line-start (point)))
6880 (set-window-start window (point) t)
6881 (when (not (pos-visible-in-window-p last-line-start window))
6882 (gnus-forward-line-ignore-invisible 1)
6883 (set-window-start window (min (point) top-pos) t)))))))
6884 ;; Do horizontal recentering while we're at it.
6885 (when (and (get-buffer-window (current-buffer) t)
6886 (not (eq gnus-auto-center-summary 'vertical)))
6887 (let ((selected (selected-window)))
6888 (select-window (get-buffer-window (current-buffer) t))
6889 (gnus-summary-position-point)
6890 (gnus-horizontal-recenter)
6891 (select-window selected))))))
6893 (defun gnus-summary-jump-to-group (newsgroup)
6894 "Move point to NEWSGROUP in group mode buffer."
6895 ;; Keep update point of group mode buffer if visible.
6896 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6897 (save-window-excursion
6898 ;; Take care of tree window mode.
6899 (when (get-buffer-window gnus-group-buffer)
6900 (pop-to-buffer gnus-group-buffer))
6901 (gnus-group-jump-to-group newsgroup))
6903 ;; Take care of tree window mode.
6904 (if (get-buffer-window gnus-group-buffer 0)
6905 (pop-to-buffer gnus-group-buffer)
6906 (set-buffer gnus-group-buffer))
6907 (gnus-group-jump-to-group newsgroup))))
6909 ;; This function returns a list of article numbers based on the
6910 ;; difference between the ranges of read articles in this group and
6911 ;; the range of active articles.
6912 (defun gnus-list-of-unread-articles (group)
6913 (let* ((read (gnus-info-read (gnus-get-info group)))
6914 (active (or (gnus-active group) (gnus-activate-group group)))
6915 (last (or (cdr active)
6916 (error "Group %s couldn't be activated " group)))
6917 (bottom (if gnus-newsgroup-maximum-articles
6919 (- last gnus-newsgroup-maximum-articles -1))
6922 ;; If none are read, then all are unread.
6925 ;; If the range of read articles is a single range, then the
6926 ;; first unread article is the article after the last read
6927 ;; article. Sounds logical, doesn't it?
6928 (if (and (not (listp (cdr read)))
6929 (or (< (car read) bottom)
6930 (progn (setq read (list read))
6932 (setq first (max bottom (1+ (cdr read))))
6933 ;; `read' is a list of ranges.
6934 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6937 (setq first bottom))
6940 (while (< first nlast)
6941 (setq unread (cons first unread)
6943 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6944 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6945 (setq read (cdr read)))))
6946 ;; And add the last unread articles.
6947 (while (<= first last)
6948 (setq unread (cons first unread)
6950 ;; Return the list of unread articles.
6951 (delq 0 (nreverse unread))))
6953 (defun gnus-list-of-read-articles (group)
6954 "Return a list of unread, unticked and non-dormant articles."
6955 (let* ((info (gnus-get-info group))
6956 (marked (gnus-info-marks info))
6957 (active (gnus-active group)))
6959 (gnus-list-range-difference
6960 (gnus-list-range-difference
6961 (gnus-sorted-complement
6962 (gnus-uncompress-range
6963 (if gnus-newsgroup-maximum-articles
6964 (cons (max (car active)
6966 gnus-newsgroup-maximum-articles
6970 (gnus-list-of-unread-articles group))
6971 (cdr (assq 'dormant marked)))
6972 (cdr (assq 'tick marked))))))
6974 ;; This function returns a sequence of article numbers based on the
6975 ;; difference between the ranges of read articles in this group and
6976 ;; the range of active articles.
6977 (defun gnus-sequence-of-unread-articles (group)
6978 (let* ((read (gnus-info-read (gnus-get-info group)))
6979 (active (or (gnus-active group) (gnus-activate-group group)))
6981 (bottom (if gnus-newsgroup-maximum-articles
6983 (- last gnus-newsgroup-maximum-articles -1))
6986 ;; If none are read, then all are unread.
6989 ;; If the range of read articles is a single range, then the
6990 ;; first unread article is the article after the last read
6991 ;; article. Sounds logical, doesn't it?
6992 (if (and (not (listp (cdr read)))
6993 (or (< (car read) bottom)
6994 (progn (setq read (list read))
6996 (setq first (max bottom (1+ (cdr read))))
6997 ;; `read' is a list of ranges.
6998 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7001 (setq first bottom))
7004 (push (cons first nlast) unread))
7005 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7006 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7007 (setq read (cdr read)))))
7008 ;; And add the last unread articles.
7009 (cond ((not (and first last))
7012 (push (cons first last) unread))
7014 (push first unread)))
7015 ;; Return the sequence of unread articles.
7016 (delq 0 (nreverse unread))))
7018 ;; Various summary commands
7020 (defun gnus-summary-select-article-buffer ()
7021 "Reconfigure windows to show the article buffer.
7022 If `gnus-widen-article-window' is set, show only the article
7025 (if (not (gnus-buffer-live-p gnus-article-buffer))
7026 (error "There is no article buffer for this summary buffer")
7027 (unless (get-buffer-window gnus-article-buffer)
7028 (gnus-summary-show-article))
7029 (gnus-configure-windows
7030 (if gnus-widen-article-window
7034 (select-window (get-buffer-window gnus-article-buffer))))
7036 (defun gnus-summary-universal-argument (arg)
7037 "Perform any operation on all articles that are process/prefixed."
7039 (let ((articles (gnus-summary-work-articles arg))
7046 (substitute-command-keys
7047 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7049 (gnus-error 1 "Undefined key")
7052 (gnus-summary-goto-subject (setq article (pop articles)))
7053 (let (gnus-newsgroup-processable)
7054 (command-execute func))
7055 (gnus-summary-remove-process-mark article)))))
7056 (gnus-summary-position-point))
7058 (defun gnus-summary-toggle-truncation (&optional arg)
7059 "Toggle truncation of summary lines.
7060 With ARG, turn line truncation on if ARG is positive."
7062 (setq truncate-lines
7063 (if (null arg) (not truncate-lines)
7064 (> (prefix-numeric-value arg) 0)))
7067 (defun gnus-summary-find-for-reselect ()
7068 "Return the number of an article to stay on across a reselect.
7069 The current article is considered, then following articles, then previous
7070 articles. An article is sought which is not canceled and isn't a temporary
7071 insertion from another group. If there's no such then return a dummy 0."
7073 (dolist (rev '(nil t))
7074 (unless found ; don't demand the reverse list if we don't need it
7075 (let ((data (gnus-data-find-list
7076 (gnus-summary-article-number) (gnus-data-list rev))))
7077 (while (and data (not found))
7078 (if (and (< 0 (gnus-data-number (car data)))
7079 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7080 (setq found (gnus-data-number (car data))))
7081 (setq data (cdr data))))))
7084 (defun gnus-summary-reselect-current-group (&optional all rescan)
7085 "Exit and then reselect the current newsgroup.
7086 The prefix argument ALL means to select all articles."
7088 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7089 (error "Ephemeral groups can't be reselected"))
7090 (let ((current-subject (gnus-summary-find-for-reselect))
7091 (group gnus-newsgroup-name))
7092 (setq gnus-newsgroup-begin nil)
7093 (gnus-summary-exit nil 'leave-hidden)
7094 ;; We have to adjust the point of group mode buffer because
7095 ;; point was moved to the next unread newsgroup by exiting.
7096 (gnus-summary-jump-to-group group)
7099 (gnus-group-get-new-news-this-group 1)))
7100 (gnus-group-read-group all t)
7101 (gnus-summary-goto-subject current-subject nil t)))
7103 (defun gnus-summary-rescan-group (&optional all)
7104 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7106 (let ((config gnus-current-window-configuration))
7107 (gnus-summary-reselect-current-group all t)
7108 (gnus-configure-windows config)
7109 (when (eq config 'article)
7110 (gnus-summary-select-article))))
7112 (defun gnus-summary-update-info (&optional non-destructive)
7114 (let ((group gnus-newsgroup-name))
7116 (when gnus-newsgroup-kill-headers
7117 (setq gnus-newsgroup-killed
7118 (gnus-compress-sequence
7120 (gnus-list-range-intersection
7121 gnus-newsgroup-unselected gnus-newsgroup-killed)
7122 gnus-newsgroup-unreads)
7124 (unless (listp (cdr gnus-newsgroup-killed))
7125 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7126 (let ((headers gnus-newsgroup-headers)
7127 (ephemeral-p (gnus-ephemeral-group-p group))
7130 (setq info (copy-sequence (gnus-get-info group))
7131 info (delq (gnus-info-params info) info)))
7132 ;; Set the new ranges of read articles.
7133 (with-current-buffer gnus-group-buffer
7134 (gnus-undo-force-boundary))
7135 (gnus-update-read-articles
7136 group (gnus-sorted-union
7137 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7138 ;; Set the current article marks.
7139 (let ((gnus-newsgroup-scored
7140 (if (and (not gnus-save-score)
7141 (not non-destructive))
7143 gnus-newsgroup-scored)))
7145 (gnus-update-marks)))
7146 ;; Do the cross-ref thing.
7147 (when gnus-use-cross-reference
7148 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7149 ;; Do not switch windows but change the buffer to work.
7150 (set-buffer gnus-group-buffer)
7152 (gnus-group-update-group
7155 (setq info (copy-sequence (gnus-get-info group))
7156 info (delq (gnus-info-params info) info))))))))))
7158 (defun gnus-summary-save-newsrc (&optional force)
7159 "Save the current number of read/marked articles in the dribble buffer.
7160 The dribble buffer will then be saved.
7161 If FORCE (the prefix), also save the .newsrc file(s)."
7163 (gnus-summary-update-info t)
7165 (gnus-save-newsrc-file)
7166 (gnus-dribble-save)))
7168 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7170 (defun gnus-summary-exit (&optional temporary leave-hidden)
7171 "Exit reading current newsgroup, and then return to group selection mode.
7172 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7174 (gnus-set-global-variables)
7175 (when (gnus-buffer-live-p gnus-article-buffer)
7176 (with-current-buffer gnus-article-buffer
7177 (mm-destroy-parts gnus-article-mime-handles)
7178 ;; Set it to nil for safety reason.
7179 (setq gnus-article-mime-handle-alist nil)
7180 (setq gnus-article-mime-handles nil)))
7181 (gnus-kill-save-kill-buffer)
7182 (gnus-async-halt-prefetch)
7183 (let* ((group gnus-newsgroup-name)
7184 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7185 (gnus-group-is-exiting-p t)
7186 (article-buffer gnus-article-buffer)
7187 (original-article-buffer gnus-original-article-buffer)
7190 (buf (current-buffer))
7191 ;; `gnus-single-article-buffer' is nil buffer-locally in
7192 ;; ephemeral group of which summary buffer will be killed,
7193 ;; but the global value may be non-nil.
7194 (single-article-buffer gnus-single-article-buffer))
7196 ;; Do adaptive scoring, and possibly save score files.
7197 (when gnus-newsgroup-adaptive
7198 (gnus-score-adaptive))
7199 (when gnus-use-scoring
7201 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7202 (when gnus-use-cache
7203 (gnus-cache-possibly-remove-articles)
7204 (gnus-cache-save-buffers))
7205 (gnus-async-prefetch-remove-group group)
7206 (when gnus-suppress-duplicates
7207 (gnus-dup-enter-articles))
7208 (when gnus-use-trees
7209 (gnus-tree-close group))
7210 (when gnus-use-cache
7211 (gnus-cache-write-active))
7212 ;; Remove entries for this group.
7213 (nnmail-purge-split-history (gnus-group-real-name group))
7214 ;; Make all changes in this group permanent.
7216 (gnus-run-hooks 'gnus-exit-group-hook)
7217 (gnus-summary-update-info))
7218 (gnus-close-group group)
7219 ;; Make sure where we were, and go to next newsgroup.
7220 (when (buffer-live-p (get-buffer gnus-group-buffer))
7221 (set-buffer gnus-group-buffer))
7223 (gnus-group-jump-to-group group))
7224 (gnus-run-hooks 'gnus-summary-exit-hook)
7225 (unless (or quit-config
7226 (not gnus-summary-next-group-on-exit)
7227 ;; If this group has disappeared from the summary
7228 ;; buffer, don't skip forwards.
7229 (not (string= group (gnus-group-group-name))))
7230 (gnus-group-next-unread-group 1))
7231 (setq group-point (point))
7235 (if (not gnus-kill-summary-on-exit)
7237 (gnus-deaden-summary)
7239 (when (get-buffer gnus-article-buffer)
7240 (bury-buffer gnus-article-buffer))
7241 ;; Return to group mode buffer.
7242 (when (eq mode 'gnus-summary-mode)
7243 (gnus-kill-buffer buf)))
7245 (setq gnus-current-select-method gnus-select-method)
7246 (when (gnus-buffer-live-p gnus-group-buffer)
7247 (set-buffer gnus-group-buffer))
7249 (gnus-handle-ephemeral-exit quit-config)
7250 (goto-char group-point)
7251 ;; If gnus-group-buffer is already displayed, make sure we also move
7252 ;; the cursor in the window that displays it.
7253 (let ((win (get-buffer-window (current-buffer) 0)))
7254 (if win (set-window-point win (point))))
7255 (unless leave-hidden
7256 (gnus-configure-windows 'group 'force)))
7258 ;; If we have several article buffers, we kill them at exit.
7259 (unless single-article-buffer
7260 (when (gnus-buffer-live-p article-buffer)
7261 (with-current-buffer article-buffer
7262 ;; Don't kill sticky article buffers
7263 (unless (eq major-mode 'gnus-sticky-article-mode)
7264 (gnus-kill-buffer article-buffer)
7265 (setq gnus-article-current nil))))
7266 (gnus-kill-buffer original-article-buffer))
7268 ;; Clear the current group name.
7270 (setq gnus-newsgroup-name nil)))))
7272 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7273 (defun gnus-summary-exit-no-update (&optional no-questions)
7274 "Quit reading current newsgroup without updating read article info."
7276 (let* ((group gnus-newsgroup-name)
7277 (gnus-group-is-exiting-p t)
7278 (gnus-group-is-exiting-without-update-p t)
7279 (quit-config (gnus-group-quit-config group)))
7280 (when (or no-questions
7282 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7283 (gnus-async-halt-prefetch)
7284 (run-hooks 'gnus-summary-prepare-exit-hook)
7285 (when (gnus-buffer-live-p gnus-article-buffer)
7286 (with-current-buffer gnus-article-buffer
7287 (gnus-article-stop-animations)
7288 (gnus-stop-downloads)
7289 (mm-destroy-parts gnus-article-mime-handles)
7290 ;; Set it to nil for safety reason.
7291 (setq gnus-article-mime-handle-alist nil)
7292 (setq gnus-article-mime-handles nil)))
7293 ;; If we have several article buffers, we kill them at exit.
7294 (unless gnus-single-article-buffer
7295 (gnus-kill-buffer gnus-article-buffer)
7296 (gnus-kill-buffer gnus-original-article-buffer)
7297 (setq gnus-article-current nil))
7298 ;; Return to the group buffer.
7299 (if (not gnus-kill-summary-on-exit)
7301 (gnus-deaden-summary)
7302 (gnus-configure-windows 'group 'force))
7303 (gnus-configure-windows 'group 'force)
7304 (gnus-close-group group)
7305 (gnus-kill-buffer gnus-summary-buffer))
7306 (unless gnus-single-article-buffer
7307 (setq gnus-article-current nil))
7308 (when gnus-use-trees
7309 (gnus-tree-close group))
7310 (gnus-async-prefetch-remove-group group)
7311 (when (get-buffer gnus-article-buffer)
7312 (bury-buffer gnus-article-buffer))
7313 ;; Clear the current group name.
7314 (setq gnus-newsgroup-name nil)
7315 (unless (gnus-ephemeral-group-p group)
7316 (gnus-group-update-group group nil t))
7317 (when (equal (gnus-group-group-name) group)
7318 (gnus-group-next-unread-group 1))
7320 (gnus-handle-ephemeral-exit quit-config)))))
7322 (defun gnus-handle-ephemeral-exit (quit-config)
7323 "Handle movement when leaving an ephemeral group.
7324 The state which existed when entering the ephemeral is reset."
7325 (if (not (buffer-live-p (car quit-config)))
7326 (when (gnus-buffer-live-p gnus-group-buffer)
7327 (gnus-configure-windows 'group 'force))
7328 (set-buffer (car quit-config))
7329 (unless (eq (cdr quit-config) 'group)
7330 (setq gnus-current-select-method
7331 (gnus-find-method-for-group gnus-newsgroup-name)))
7332 (cond ((eq major-mode 'gnus-summary-mode)
7333 (gnus-set-global-variables))
7334 ((eq major-mode 'gnus-article-mode)
7335 (save-current-buffer
7336 ;; The `gnus-summary-buffer' variable may point
7337 ;; to the old summary buffer when using a single
7339 (unless (gnus-buffer-live-p gnus-summary-buffer)
7340 (set-buffer gnus-group-buffer))
7341 (set-buffer gnus-summary-buffer)
7342 (gnus-set-global-variables))))
7343 (if (or (eq (cdr quit-config) 'article)
7344 (eq (cdr quit-config) 'pick))
7345 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7346 (gnus-configure-windows 'pick 'force)
7347 (gnus-configure-windows (cdr quit-config) 'force))
7348 (gnus-configure-windows (cdr quit-config) 'force))
7349 (when (eq major-mode 'gnus-summary-mode)
7350 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7351 next-unread-noselect))
7352 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7354 (gnus-summary-next-subject 1 nil t))
7355 ((eq gnus-auto-select-on-ephemeral-exit
7356 'next-unread-noselect)
7357 (gnus-summary-next-subject 1 t t))))
7358 ;; Hide the article buffer which displays the article different
7359 ;; from the one that the cursor points to in the summary buffer.
7360 (gnus-configure-windows 'summary 'force))
7361 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7362 (gnus-summary-next-subject 1))
7363 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7364 (gnus-summary-next-subject 1 t))))
7365 (gnus-summary-recenter)
7366 (gnus-summary-position-point))))
7370 (defvar gnus-dead-summary-mode-map
7371 (let ((map (make-keymap)))
7372 (suppress-keymap map)
7373 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7374 (dolist (key '("\C-d" "\r" "\177" [delete]))
7375 (define-key map key 'gnus-summary-wake-up-the-dead))
7376 (dolist (key '("q" "Q"))
7377 (define-key map key 'bury-buffer))
7380 (define-minor-mode gnus-dead-summary-mode
7381 "Minor mode for Gnus summary buffers."
7382 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7383 (unless (derived-mode-p 'gnus-summary-mode)
7384 (setq gnus-dead-summary-mode nil)))
7386 (defun gnus-deaden-summary ()
7387 "Make the current summary buffer into a dead summary buffer."
7388 ;; Kill any previous dead summary buffer.
7389 (when (and gnus-dead-summary
7390 (buffer-name gnus-dead-summary))
7391 (with-current-buffer gnus-dead-summary
7392 (when gnus-dead-summary-mode
7393 (kill-buffer (current-buffer)))))
7394 ;; Make this the current dead summary.
7395 (setq gnus-dead-summary (current-buffer))
7396 (gnus-dead-summary-mode 1)
7397 (let ((name (buffer-name)))
7398 (when (string-match "Summary" name)
7400 (concat (substring name 0 (match-beginning 0)) "Dead "
7401 (substring name (match-beginning 0)))
7405 (defun gnus-kill-or-deaden-summary (buffer)
7406 "Kill or deaden the summary BUFFER."
7408 (when (and (buffer-name buffer)
7409 (not gnus-single-article-buffer))
7410 (with-current-buffer buffer
7411 (gnus-kill-buffer gnus-article-buffer)
7412 (gnus-kill-buffer gnus-original-article-buffer)))
7415 (gnus-kill-summary-on-exit
7416 (when (and gnus-use-trees
7417 (gnus-buffer-exists-p buffer))
7418 (with-current-buffer buffer
7419 (gnus-tree-close gnus-newsgroup-name)))
7420 (gnus-kill-buffer buffer))
7421 ;; Deaden the buffer.
7422 ((gnus-buffer-exists-p buffer)
7423 (with-current-buffer buffer
7424 (gnus-deaden-summary))))))
7426 (defun gnus-summary-wake-up-the-dead (&rest args)
7427 "Wake up the dead summary buffer."
7429 (gnus-dead-summary-mode -1)
7430 (let ((name (buffer-name)))
7431 (when (string-match "Dead " name)
7433 (concat (substring name 0 (match-beginning 0))
7434 (substring name (match-end 0)))
7436 (gnus-message 3 "This dead summary is now alive again"))
7438 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7439 (defun gnus-summary-describe-group (&optional force)
7440 "Describe the current newsgroup."
7442 (gnus-group-describe-group force gnus-newsgroup-name))
7444 (defun gnus-summary-describe-briefly ()
7445 "Describe summary mode commands briefly."
7447 (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")))
7449 ;; Walking around group mode buffer from summary mode.
7451 (defun gnus-summary-next-group (&optional no-article target-group backward)
7452 "Exit current newsgroup and then select next unread newsgroup.
7453 If prefix argument NO-ARTICLE is non-nil, no article is selected
7454 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7455 previous group instead."
7457 ;; Stop pre-fetching.
7458 (gnus-async-halt-prefetch)
7459 (let ((current-group gnus-newsgroup-name)
7460 (current-buffer (current-buffer))
7462 ;; First we semi-exit this group to update Xrefs and all variables.
7463 ;; We can't do a real exit, because the window conf must remain
7464 ;; the same in case the user is prompted for info, and we don't
7465 ;; want the window conf to change before that...
7466 (gnus-summary-exit t)
7467 (while (not entered)
7468 ;; Then we find what group we are supposed to enter.
7469 (set-buffer gnus-group-buffer)
7470 (gnus-group-jump-to-group current-group)
7473 (if (eq gnus-keep-same-level 'best)
7474 (gnus-summary-best-group gnus-newsgroup-name)
7475 (gnus-summary-search-group backward gnus-keep-same-level))))
7476 (if (not target-group)
7477 ;; There are no further groups, so we return to the group
7480 (gnus-message 5 "Returning to the group buffer")
7482 (when (gnus-buffer-live-p current-buffer)
7483 (set-buffer current-buffer)
7484 (gnus-summary-exit))
7485 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7486 ;; We try to enter the target group.
7487 (gnus-group-jump-to-group target-group)
7488 (let ((unreads (gnus-group-group-unread)))
7489 (if (and (or (eq t unreads)
7490 (and unreads (not (zerop unreads))))
7491 (gnus-summary-read-group
7492 target-group nil no-article
7493 (and (buffer-name current-buffer) current-buffer)
7496 (setq current-group target-group
7497 target-group nil)))))))
7499 (defun gnus-summary-prev-group (&optional no-article)
7500 "Exit current newsgroup and then select previous unread newsgroup.
7501 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7503 (gnus-summary-next-group no-article nil t))
7505 ;; Walking around summary lines.
7507 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7508 "Go to the first subject satisfying any non-nil constraint.
7509 If UNREAD is non-nil, the article should be unread.
7510 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7511 If UNSEEN is non-nil, the article should be unseen as well as unread.
7512 Returns the article selected or nil if there are no matching articles."
7516 ((null gnus-newsgroup-data)
7517 (gnus-message 3 "No articles in the group")
7519 ;; Pick the first article.
7520 ((not (or unread undownloaded unseen))
7521 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7522 (gnus-data-number (car gnus-newsgroup-data)))
7523 ;; Find the first unread article.
7525 (let ((data gnus-newsgroup-data))
7527 (let ((num (gnus-data-number (car data))))
7528 (or (memq num gnus-newsgroup-unfetched)
7529 (not (or (and unread
7530 (memq num gnus-newsgroup-unreads))
7532 (memq num gnus-newsgroup-undownloaded))
7534 (memq num gnus-newsgroup-unseen)
7535 (memq num gnus-newsgroup-unreads)))))))
7536 (setq data (cdr data)))
7540 (goto-char (gnus-data-pos (car data)))
7541 (gnus-data-number (car data)))
7542 (gnus-message 3 "No more%s articles"
7543 (let* ((r (when unread " unread"))
7544 (d (when undownloaded " undownloaded"))
7545 (s (when unseen " unseen"))
7546 (l (delq nil (list r d s))))
7547 (cond ((= 3 (length l))
7548 (concat r "," d ", or" s))
7550 (concat (car l) ", or" (cadr l)))
7557 (gnus-summary-position-point))))))
7559 (defun gnus-summary-next-subject (n &optional unread dont-display)
7560 "Go to next N'th summary line.
7561 If N is negative, go to the previous N'th subject line.
7562 If UNREAD is non-nil, only unread articles are selected.
7563 The difference between N and the actual number of steps taken is
7566 (let ((backward (< n 0))
7570 (gnus-summary-find-prev unread)
7571 (gnus-summary-find-next unread)))
7572 (unless (zerop (setq n (1- n)))
7573 (gnus-summary-show-thread)))
7575 (gnus-message 7 "No more%s articles"
7576 (if unread " unread" "")))
7577 (unless dont-display
7578 (gnus-summary-recenter)
7579 (gnus-summary-position-point))
7582 (defun gnus-summary-next-unread-subject (n)
7583 "Go to next N'th unread summary line."
7585 (gnus-summary-next-subject n t))
7587 (defun gnus-summary-prev-subject (n &optional unread)
7588 "Go to previous N'th summary line.
7589 If optional argument UNREAD is non-nil, only unread article is selected."
7591 (gnus-summary-next-subject (- n) unread))
7593 (defun gnus-summary-prev-unread-subject (n)
7594 "Go to previous N'th unread summary line."
7596 (gnus-summary-next-subject (- n) t))
7598 (defun gnus-summary-goto-subjects (articles)
7599 "Insert the subject header for ARTICLES in the current buffer."
7601 (dolist (article articles)
7602 (gnus-summary-goto-subject article t)))
7603 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7604 (gnus-summary-position-point))
7606 (defun gnus-summary-goto-subject (article &optional force silent)
7607 "Go to the subject line of ARTICLE.
7608 If FORCE, also allow jumping to articles not currently shown."
7609 (interactive "nArticle number: ")
7610 (unless (numberp article)
7611 (error "Article %s is not a number" article))
7613 (data (gnus-data-find article)))
7614 ;; We read in the article if we have to.
7617 (gnus-summary-insert-subject
7619 (if (or (numberp force) (vectorp force)) force)
7621 (setq data (gnus-data-find article)))
7626 (gnus-message 3 "Can't find article %d" article))
7628 (let ((pt (gnus-data-pos data)))
7630 (gnus-summary-set-article-display-arrow pt))
7631 (gnus-summary-position-point)
7634 ;; Walking around summary lines with displaying articles.
7636 (defun gnus-summary-expand-window (&optional arg)
7637 "Make the summary buffer take up the entire Emacs frame.
7638 Given a prefix, will force an `article' buffer configuration."
7641 (gnus-configure-windows 'article 'force)
7642 (gnus-configure-windows 'summary 'force)))
7644 (defun gnus-summary-display-article (article &optional all-header)
7645 "Display ARTICLE in article buffer."
7646 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7647 (with-current-buffer gnus-article-buffer
7648 (eq major-mode 'gnus-article-mode)))
7649 (gnus-article-setup-buffer))
7650 (gnus-set-global-variables)
7651 (with-current-buffer gnus-article-buffer
7652 (setq gnus-article-charset gnus-newsgroup-charset)
7653 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7654 (mm-enable-multibyte))
7658 (if gnus-summary-display-article-function
7659 (funcall gnus-summary-display-article-function article all-header)
7660 (gnus-article-prepare article all-header))
7661 (gnus-run-hooks 'gnus-select-article-hook)
7662 (when (and gnus-current-article
7663 (not (zerop gnus-current-article)))
7664 (gnus-summary-goto-subject gnus-current-article))
7665 (gnus-summary-recenter)
7666 (when (and gnus-use-trees gnus-show-threads)
7667 (gnus-possibly-generate-tree article)
7668 (gnus-highlight-selected-tree article))
7669 ;; Successfully display article.
7670 (gnus-article-set-window-start
7671 (cdr (assq article gnus-newsgroup-bookmarks))))))
7673 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7674 "Select the current article.
7675 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7676 non-nil, the article will be re-fetched even if it already present in
7677 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7679 ;; Make sure we are in the summary buffer to work around bbdb bug.
7680 (unless (eq major-mode 'gnus-summary-mode)
7681 (set-buffer gnus-summary-buffer))
7682 (let ((article (or article (gnus-summary-article-number)))
7683 (all-headers (not (not all-headers))) ;Must be t or nil.
7684 gnus-summary-display-article-function)
7686 (gnus-summary-article-pseudo-p article)
7687 (error "This is a pseudo-article"))
7688 (with-current-buffer gnus-summary-buffer
7689 (if (or (and gnus-single-article-buffer
7690 (or (null gnus-current-article)
7691 (null gnus-article-current)
7692 (null (get-buffer gnus-article-buffer))
7693 (not (eq article (cdr gnus-article-current)))
7694 (not (equal (car gnus-article-current)
7695 gnus-newsgroup-name))
7696 (not (get-buffer gnus-original-article-buffer))))
7697 (and (not gnus-single-article-buffer)
7698 (or (null gnus-current-article)
7699 (not (get-buffer gnus-original-article-buffer))
7700 (not (eq gnus-current-article article))))
7702 ;; The requested article is different from the current article.
7704 (gnus-summary-display-article article all-headers)
7705 (when (gnus-buffer-live-p gnus-article-buffer)
7706 (with-current-buffer gnus-article-buffer
7707 (if (not gnus-article-decoded-p) ;; a local variable
7708 (mm-disable-multibyte))))
7709 (gnus-article-set-window-start
7710 (cdr (assq article gnus-newsgroup-bookmarks)))
7714 (defun gnus-summary-force-verify-and-decrypt ()
7715 "Display buttons for signed/encrypted parts and verify/decrypt them."
7717 (let ((mm-verify-option 'known)
7718 (mm-decrypt-option 'known)
7719 (gnus-article-emulate-mime t)
7720 (gnus-buttonized-mime-types (append (list "multipart/signed"
7721 "multipart/encrypted")
7722 gnus-buttonized-mime-types)))
7723 (gnus-summary-select-article nil 'force)))
7725 (defun gnus-summary-next-article (&optional unread subject backward push)
7726 "Select the next article.
7727 If UNREAD, only unread articles are selected.
7728 If SUBJECT, only articles with SUBJECT are selected.
7729 If BACKWARD, the previous article is selected instead of the next."
7731 ;; Make sure we are in the summary buffer.
7732 (unless (eq major-mode 'gnus-summary-mode)
7733 (set-buffer gnus-summary-buffer))
7735 ;; Is there such an article?
7736 ((and (gnus-summary-search-forward unread subject backward)
7737 (or (gnus-summary-display-article (gnus-summary-article-number))
7738 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7739 (gnus-summary-position-point))
7740 ;; If not, we try the first unread, if that is wanted.
7742 gnus-auto-select-same
7743 (gnus-summary-first-unread-article))
7744 (gnus-summary-position-point)
7745 (gnus-message 6 "Wrapped"))
7746 ;; Try to get next/previous article not displayed in this group.
7747 ((and gnus-auto-extend-newsgroup
7748 (not unread) (not subject))
7749 (gnus-summary-goto-article
7750 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7751 nil (count-lines (point-min) (point))))
7752 ;; Go to next/previous group.
7754 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7755 (gnus-summary-jump-to-group gnus-newsgroup-name))
7756 (let ((cmd (if (featurep 'xemacs)
7758 last-command-event))
7760 (with-current-buffer gnus-group-buffer
7762 (current-summary (current-buffer))
7764 (if (eq gnus-keep-same-level 'best)
7765 (gnus-summary-best-group gnus-newsgroup-name)
7766 (gnus-summary-search-group backward gnus-keep-same-level))))
7767 ;; Select next unread newsgroup automagically.
7769 ((or (not gnus-auto-select-next)
7771 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7772 ((or (eq gnus-auto-select-next 'quietly)
7773 (and (eq gnus-auto-select-next 'slightly-quietly)
7775 (and (eq gnus-auto-select-next 'almost-quietly)
7776 (gnus-summary-last-article-p)))
7778 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7780 (gnus-message 7 "No more%s articles (%s)..."
7781 (if unread " unread" "")
7782 (if group (concat "selecting " group)
7784 (gnus-summary-next-group nil group backward)))
7786 (when (gnus-key-press-event-p last-input-event)
7787 ;; Somehow or other, we may now have selected a different
7788 ;; window. Make point go back to the summary buffer.
7789 (when (eq current-summary (current-buffer))
7790 ;; FIXME: This burps when get-buffer-window returns nil.
7791 (select-window (get-buffer-window current-summary 0)))
7792 (gnus-summary-walk-group-buffer
7793 gnus-newsgroup-name cmd unread backward point))))))))
7795 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7796 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7797 (?\C-p (gnus-group-prev-unread-group 1))))
7798 (cursor-in-echo-area t)
7799 keve key group ended prompt)
7800 (with-current-buffer gnus-group-buffer
7803 (if (eq gnus-keep-same-level 'best)
7804 (gnus-summary-best-group gnus-newsgroup-name)
7805 (gnus-summary-search-group backward gnus-keep-same-level))))
7809 "No more%s articles%s " (if unread " unread" "")
7811 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7812 (format " (Type %s for %s [%s])"
7813 (single-key-description cmd)
7814 (gnus-group-decoded-name group)
7815 (gnus-group-unread group))
7816 (format " (Type %s to exit %s)"
7817 (single-key-description cmd)
7818 (gnus-group-decoded-name gnus-newsgroup-name)))))
7819 ;; Confirm auto selection.
7820 (setq key (car (setq keve (gnus-read-event-char prompt)))
7823 ((assq key keystrokes)
7824 (let ((obuf (current-buffer)))
7825 (switch-to-buffer gnus-group-buffer)
7827 (gnus-group-jump-to-group group))
7828 (eval (cadr (assq key keystrokes)))
7829 (setq group (gnus-group-group-name))
7830 (switch-to-buffer obuf))
7834 (gnus-ephemeral-group-p gnus-newsgroup-name))
7836 (gnus-summary-next-group nil group backward)))
7838 (push (cdr keve) unread-command-events))))))
7840 (defun gnus-summary-next-unread-article ()
7841 "Select unread article after current one."
7843 (gnus-summary-next-article
7844 (or (not (eq gnus-summary-goto-unread 'never))
7845 (gnus-summary-last-article-p (gnus-summary-article-number)))
7846 (and gnus-auto-select-same
7847 (gnus-summary-article-subject))))
7849 (defun gnus-summary-prev-article (&optional unread subject)
7850 "Select the article before the current one.
7851 If UNREAD is non-nil, only unread articles are selected."
7853 (gnus-summary-next-article unread subject t))
7855 (defun gnus-summary-prev-unread-article ()
7856 "Select unread article before current one."
7858 (gnus-summary-prev-article
7859 (or (not (eq gnus-summary-goto-unread 'never))
7860 (gnus-summary-first-article-p (gnus-summary-article-number)))
7861 (and gnus-auto-select-same
7862 (gnus-summary-article-subject))))
7864 (defun gnus-summary-next-page (&optional lines circular stop)
7865 "Show next page of the selected article.
7866 If at the end of the current article, select the next article.
7867 LINES says how many lines should be scrolled up.
7869 If CIRCULAR is non-nil, go to the start of the article instead of
7870 selecting the next article when reaching the end of the current
7873 If STOP is non-nil, just stop when reaching the end of the message.
7875 Also see the variable `gnus-article-skip-boring'."
7877 (setq gnus-summary-buffer (current-buffer))
7878 (gnus-set-global-variables)
7879 (let ((article (gnus-summary-article-number))
7880 (article-window (get-buffer-window gnus-article-buffer t))
7882 ;; If the buffer is empty, we have no article.
7884 (error "No article to select"))
7885 (gnus-configure-windows 'article)
7886 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7887 (if (and (eq gnus-summary-goto-unread 'never)
7888 (not (gnus-summary-last-article-p article)))
7889 (gnus-summary-next-article)
7890 (gnus-summary-next-unread-article))
7891 (if (or (null gnus-current-article)
7892 (null gnus-article-current)
7893 (/= article (cdr gnus-article-current))
7894 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7895 ;; Selected subject is different from current article's.
7896 (gnus-summary-display-article article)
7897 (when article-window
7898 (gnus-eval-in-buffer-window gnus-article-buffer
7899 (setq endp (or (gnus-article-next-page lines)
7900 (gnus-article-only-boring-p))))
7902 (cond ((or stop gnus-summary-stop-at-end-of-message)
7903 (gnus-message 3 "End of message"))
7905 (gnus-summary-beginning-of-article))
7907 (gnus-message 3 "End of message"))
7909 (if (and (eq gnus-summary-goto-unread 'never)
7910 (not (gnus-summary-last-article-p article)))
7911 (gnus-summary-next-article)
7912 (gnus-summary-next-unread-article))))))))
7913 (gnus-summary-recenter)
7914 (gnus-summary-position-point)))
7916 (defun gnus-summary-prev-page (&optional lines move)
7917 "Show previous page of selected article.
7918 Argument LINES specifies lines to be scrolled down.
7919 If MOVE, move to the previous unread article if point is at
7920 the beginning of the buffer."
7922 (let ((article (gnus-summary-article-number))
7923 (article-window (get-buffer-window gnus-article-buffer t))
7925 (gnus-configure-windows 'article)
7926 (if (or (null gnus-current-article)
7927 (null gnus-article-current)
7928 (/= article (cdr gnus-article-current))
7929 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7930 ;; Selected subject is different from current article's.
7931 (gnus-summary-display-article article)
7932 (gnus-summary-recenter)
7933 (when article-window
7934 (gnus-eval-in-buffer-window gnus-article-buffer
7935 (setq endp (gnus-article-prev-page lines)))
7936 (when (and move endp)
7938 (gnus-message 3 "Beginning of message"))
7940 (if (and (eq gnus-summary-goto-unread 'never)
7941 (not (gnus-summary-first-article-p article)))
7942 (gnus-summary-prev-article)
7943 (gnus-summary-prev-unread-article))))))))
7944 (gnus-summary-position-point))
7946 (defun gnus-summary-prev-page-or-article (&optional lines)
7947 "Show previous page of selected article.
7948 Argument LINES specifies lines to be scrolled down.
7949 If at the beginning of the article, go to the next article."
7951 (gnus-summary-prev-page lines t))
7953 (defun gnus-summary-scroll-up (lines)
7954 "Scroll up (or down) one line current article.
7955 Argument LINES specifies lines to be scrolled up (or down if negative).
7956 If no article is selected, then the current article will be selected first."
7958 (gnus-configure-windows 'article)
7959 (gnus-summary-show-thread)
7960 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7961 (gnus-eval-in-buffer-window gnus-article-buffer
7963 (when (gnus-article-next-page lines)
7964 (gnus-message 3 "End of message")))
7966 (gnus-article-prev-page (- lines))))))
7967 (gnus-summary-recenter)
7968 (gnus-summary-position-point))
7970 (defun gnus-summary-scroll-down (lines)
7971 "Scroll down (or up) one line current article.
7972 Argument LINES specifies lines to be scrolled down (or up if negative).
7973 If no article is selected, then the current article will be selected first."
7975 (gnus-summary-scroll-up (- lines)))
7977 (defun gnus-summary-next-same-subject ()
7978 "Select next article which has the same subject as current one."
7980 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7982 (defun gnus-summary-prev-same-subject ()
7983 "Select previous article which has the same subject as current one."
7985 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7987 (defun gnus-summary-next-unread-same-subject ()
7988 "Select next unread article which has the same subject as current one."
7990 (gnus-summary-next-article t (gnus-summary-article-subject)))
7992 (defun gnus-summary-prev-unread-same-subject ()
7993 "Select previous unread article which has the same subject as current one."
7995 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7997 (defun gnus-summary-first-unread-article ()
7998 "Select the first unread article.
7999 Return nil if there are no unread articles."
8002 (when (gnus-summary-first-subject t)
8003 (gnus-summary-show-thread)
8004 (gnus-summary-first-subject t)
8005 (gnus-summary-display-article (gnus-summary-article-number)))
8006 (gnus-summary-position-point)))
8008 (defun gnus-summary-first-unread-subject ()
8009 "Place the point on the subject line of the first unread article.
8010 Return nil if there are no unread articles."
8013 (when (gnus-summary-first-subject t)
8014 (gnus-summary-show-thread)
8015 (gnus-summary-first-subject t))
8016 (gnus-summary-position-point)))
8018 (defun gnus-summary-first-unseen-subject ()
8019 "Place the point on the subject line of the first unseen article.
8020 Return nil if there are no unseen articles."
8023 (when (gnus-summary-first-subject nil nil t)
8024 (gnus-summary-show-thread)
8025 (gnus-summary-first-subject nil nil t))
8026 (gnus-summary-position-point)))
8028 (defun gnus-summary-first-unseen-or-unread-subject ()
8029 "Place the point on the subject line of the first unseen and unread article.
8030 If all article have been seen, on the subject line of the first unread
8034 (unless (when (gnus-summary-first-subject nil nil t)
8035 (gnus-summary-show-thread)
8036 (gnus-summary-first-subject nil nil t))
8037 (when (gnus-summary-first-subject t)
8038 (gnus-summary-show-thread)
8039 (gnus-summary-first-subject t)))
8040 (gnus-summary-position-point)))
8042 (defun gnus-summary-first-article ()
8043 "Select the first article.
8044 Return nil if there are no articles."
8047 (when (gnus-summary-first-subject)
8048 (gnus-summary-show-thread)
8049 (gnus-summary-first-subject)
8050 (gnus-summary-display-article (gnus-summary-article-number)))
8051 (gnus-summary-position-point)))
8053 (defun gnus-summary-best-unread-article (&optional arg)
8054 "Select the unread article with the highest score.
8055 If given a prefix argument, select the next unread article that has a
8056 score higher than the default score."
8058 (let ((article (if arg
8059 (gnus-summary-better-unread-subject)
8060 (gnus-summary-best-unread-subject))))
8062 (gnus-summary-goto-article article)
8063 (error "No unread articles"))))
8065 (defun gnus-summary-best-unread-subject ()
8066 "Select the unread subject with the highest score."
8068 (let ((best -1000000)
8069 (data gnus-newsgroup-data)
8072 (and (gnus-data-unread-p (car data))
8074 (gnus-summary-article-score (gnus-data-number (car data))))
8077 article (gnus-data-number (car data))))
8078 (setq data (cdr data)))
8080 (gnus-summary-goto-subject article))
8081 (gnus-summary-position-point)
8084 (defun gnus-summary-better-unread-subject ()
8085 "Select the first unread subject that has a score over the default score."
8087 (let ((data gnus-newsgroup-data)
8089 (while (and (setq article (gnus-data-number (car data)))
8090 (or (gnus-data-read-p (car data))
8091 (not (> (gnus-summary-article-score article)
8092 gnus-summary-default-score))))
8093 (setq data (cdr data)))
8095 (gnus-summary-goto-subject article))
8096 (gnus-summary-position-point)
8099 (defun gnus-summary-last-subject ()
8100 "Go to the last displayed subject line in the group."
8101 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8103 (gnus-summary-goto-subject article))))
8105 (defun gnus-summary-goto-article (article &optional all-headers force)
8106 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8107 If ALL-HEADERS is non-nil, no header lines are hidden.
8108 If FORCE, go to the article even if it isn't displayed. If FORCE
8109 is a number, it is the line the article is to be displayed on."
8112 (gnus-completing-read
8113 "Article number or Message-ID"
8114 (mapcar 'int-to-string gnus-newsgroup-limit))
8118 (if (and (stringp article)
8119 (string-match "@\\|%40" article))
8120 (gnus-summary-refer-article article)
8121 (when (stringp article)
8122 (setq article (string-to-number article)))
8123 (if (gnus-summary-goto-subject article force)
8124 (gnus-summary-display-article article all-headers)
8125 (gnus-message 4 "Couldn't go to article %s" article) nil))
8126 (gnus-summary-position-point)))
8128 (defun gnus-summary-goto-last-article ()
8129 "Go to the previously read article."
8132 (when gnus-last-article
8133 (gnus-summary-goto-article gnus-last-article nil t))
8134 (gnus-summary-position-point)))
8136 (defun gnus-summary-pop-article (number)
8137 "Pop one article off the history and go to the previous.
8138 NUMBER articles will be popped off."
8141 (setq gnus-newsgroup-history
8142 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8144 (gnus-summary-goto-article (car to) nil t)
8145 (error "Article history empty")))
8146 (gnus-summary-position-point))
8148 ;; Summary commands and functions for limiting the summary buffer.
8150 (defun gnus-summary-limit-to-articles (n)
8151 "Limit the summary buffer to the next N articles.
8152 If not given a prefix, use the process marked articles instead."
8155 (let ((articles (gnus-summary-work-articles n)))
8156 (setq gnus-newsgroup-processable nil)
8157 (gnus-summary-limit articles))
8158 (gnus-summary-position-point)))
8160 (defun gnus-summary-pop-limit (&optional total)
8161 "Restore the previous limit.
8162 If given a prefix, remove all limits."
8165 (setq gnus-newsgroup-limits
8166 (list (mapcar (lambda (h) (mail-header-number h))
8167 gnus-newsgroup-headers))))
8168 (unless gnus-newsgroup-limits
8169 (error "No limit to pop"))
8171 (gnus-summary-limit nil 'pop)
8172 (gnus-summary-position-point)))
8174 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8175 "Limit the summary buffer to articles that have subjects that match a regexp.
8176 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8178 (list (read-string (if current-prefix-arg
8179 "Exclude subject (regexp): "
8180 "Limit to subject (regexp): "))
8181 nil current-prefix-arg))
8183 (setq header "subject"))
8184 (when (not (equal "" subject))
8186 (let ((articles (gnus-summary-find-matching
8187 (or header "subject") subject 'all nil nil
8190 (error "Found no matches for \"%s\"" subject))
8191 (gnus-summary-limit articles))
8192 (gnus-summary-position-point))))
8194 (defun gnus-summary-limit-to-author (from &optional not-matching)
8195 "Limit the summary buffer to articles that have authors that match a regexp.
8196 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8198 (list (let* ((header (gnus-summary-article-header))
8199 (default (and header (car (mail-header-parse-address
8200 (mail-header-from header))))))
8201 (read-string (concat (if current-prefix-arg
8202 "Exclude author (regexp"
8203 "Limit to author (regexp")
8205 (concat ", default \"" default "\"): ")
8209 current-prefix-arg))
8210 (gnus-summary-limit-to-subject from "from" not-matching))
8212 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8213 "Limit the summary buffer to articles with the given RECIPIENT.
8215 If NOT-MATCHING, exclude RECIPIENT.
8217 To and Cc headers are checked. You need to include them in
8218 `nnmail-extra-headers'."
8219 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8221 (list (read-string (format "%s recipient (regexp): "
8222 (if current-prefix-arg "Exclude" "Limit to")))
8223 current-prefix-arg))
8224 (when (not (equal "" recipient))
8226 (if (memq 'To nnmail-extra-headers)
8227 (gnus-summary-find-matching
8228 (cons 'extra 'To) recipient 'all nil nil
8231 1 "`To' isn't present in `nnmail-extra-headers'")
8235 (if (memq 'Cc nnmail-extra-headers)
8236 (gnus-summary-find-matching
8237 (cons 'extra 'Cc) recipient 'all nil nil
8240 1 "`Cc' isn't present in `nnmail-extra-headers'")
8245 ;; We need the numbers that are in both lists:
8247 (and (memq a to) a))
8251 (error "Found no matches for \"%s\"" recipient))
8252 (gnus-summary-limit articles))
8253 (gnus-summary-position-point))))
8255 (defun gnus-summary-limit-to-address (address &optional not-matching)
8256 "Limit the summary buffer to articles with the given ADDRESS.
8258 If NOT-MATCHING, exclude ADDRESS.
8260 To, Cc and From headers are checked. You need to include `To' and `Cc'
8261 in `nnmail-extra-headers'."
8263 (list (read-string (format "%s address (regexp): "
8264 (if current-prefix-arg "Exclude" "Limit to")))
8265 current-prefix-arg))
8266 (when (not (equal "" address))
8268 (if (memq 'To nnmail-extra-headers)
8269 (gnus-summary-find-matching
8270 (cons 'extra 'To) address 'all nil nil
8273 1 "`To' isn't present in `nnmail-extra-headers'")
8277 (if (memq 'Cc nnmail-extra-headers)
8278 (gnus-summary-find-matching
8279 (cons 'extra 'Cc) address 'all nil nil
8282 1 "`Cc' isn't present in `nnmail-extra-headers'")
8286 (gnus-summary-find-matching "from" address
8287 'all nil nil not-matching))
8290 ;; We need the numbers that are in all lists:
8294 (mapcar (lambda (a) (car (memq a from))) to))
8296 (mapcar (lambda (a) (car (memq a from))) cc)
8297 (mapcar (lambda (a) (car (memq a from)))
8298 (mapcar (lambda (a) (car (memq a to)))
8300 (nconc (if (eq to t) nil to)
8301 (if (eq cc t) nil cc)
8304 (error "Found no matches for \"%s\"" address))
8305 (gnus-summary-limit articles))
8306 (gnus-summary-position-point))))
8308 (defun gnus-summary-limit-strange-charsets-predicate (header)
8309 (when (fboundp 'char-charset)
8310 (let ((string (concat (mail-header-subject header)
8311 (mail-header-from header)))
8313 (dotimes (i (1- (length string)))
8314 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8315 (when (string-match "unicode\\|big\\|japanese" charset)
8319 (defun gnus-summary-limit-to-predicate (predicate)
8320 "Limit to articles where PREDICATE returns non-nil.
8321 PREDICATE will be called with the header structures of the
8323 (let ((articles nil)
8324 (case-fold-search t))
8325 (dolist (header gnus-newsgroup-headers)
8326 (when (funcall predicate header)
8327 (push (mail-header-number header) articles)))
8328 (gnus-summary-limit (nreverse articles))))
8330 (defun gnus-summary-limit-to-age (age &optional younger-p)
8331 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8332 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8333 articles that are younger than AGE days."
8335 (let ((younger current-prefix-arg)
8338 (while (not days-got)
8339 (setq days (if younger
8340 (read-string "Limit to articles younger than (in days, older when negative): ")
8342 "Limit to articles older than (in days, younger when negative): ")))
8343 (when (> (length days) 0)
8344 (setq days (read days)))
8349 (setq younger (not younger))
8350 (setq days (* days -1))))
8351 (message "Please enter a number.")
8353 (list days younger)))
8355 (let ((data gnus-newsgroup-data)
8356 (cutoff (days-to-time age))
8357 articles d date is-younger)
8358 (while (setq d (pop data))
8359 (when (and (vectorp (gnus-data-header d))
8360 (setq date (mail-header-date (gnus-data-header d))))
8361 (setq is-younger (time-less-p
8362 (time-since (gnus-date-get-time date))
8367 (push (gnus-data-number d) articles))))
8368 (gnus-summary-limit (nreverse articles)))
8369 (gnus-summary-position-point)))
8371 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8372 "Limit the summary buffer to articles that match an 'extra' header."
8376 (gnus-completing-read
8377 (if current-prefix-arg
8378 "Exclude extra header"
8379 "Limit extra header")
8380 (mapcar 'symbol-name gnus-extra-headers)
8382 (symbol-name (car gnus-extra-headers))))))
8384 (read-string (format "%s header %s (regexp): "
8385 (if current-prefix-arg "Exclude" "Limit to")
8387 current-prefix-arg)))
8388 (when (not (equal "" regexp))
8390 (let ((articles (gnus-summary-find-matching
8391 (cons 'extra header) regexp 'all nil nil
8394 (error "Found no matches for \"%s\"" regexp))
8395 (gnus-summary-limit articles))
8396 (gnus-summary-position-point))))
8398 (defun gnus-summary-limit-to-display-predicate ()
8399 "Limit the summary buffer to the predicated in the `display' group parameter."
8401 (unless gnus-newsgroup-display
8402 (error "There is no `display' group parameter"))
8404 (dolist (gnus-number gnus-newsgroup-articles)
8405 (when (funcall gnus-newsgroup-display)
8406 (push gnus-number articles)))
8407 (gnus-summary-limit articles))
8408 (gnus-summary-position-point))
8410 (defun gnus-summary-limit-to-unread (&optional all)
8411 "Limit the summary buffer to articles that are not marked as read.
8412 If ALL is non-nil, limit strictly to unread articles."
8415 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8416 (gnus-summary-limit-to-marks
8417 ;; Concat all the marks that say that an article is read and have
8419 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8420 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8421 gnus-low-score-mark gnus-expirable-mark
8422 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8423 gnus-duplicate-mark)
8426 (defun gnus-summary-limit-to-headers (match &optional reverse)
8427 "Limit the summary buffer to articles that have headers that match MATCH.
8428 If REVERSE (the prefix), limit to articles that don't match."
8429 (interactive "sMatch headers (regexp): \nP")
8430 (gnus-summary-limit-to-bodies match reverse t))
8432 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8433 "Limit the summary buffer to articles that have bodies that match MATCH.
8434 If REVERSE (the prefix), limit to articles that don't match."
8435 (interactive "sMatch body (regexp): \nP")
8436 (let ((articles nil)
8437 (gnus-select-article-hook nil) ;Disable hook.
8438 (gnus-article-prepare-hook nil)
8439 (gnus-use-article-prefetch nil)
8440 (gnus-keep-backlog nil)
8441 (gnus-break-pages nil)
8442 (gnus-summary-display-arrow nil)
8443 (gnus-updated-mode-lines nil)
8444 (gnus-auto-center-summary nil)
8445 (gnus-display-mime-function nil))
8446 (dolist (data gnus-newsgroup-data)
8447 (let (gnus-mark-article-hook)
8448 (gnus-summary-select-article t t nil (gnus-data-number data)))
8449 (with-current-buffer gnus-article-buffer
8451 (let* ((case-fold-search t)
8453 (re-search-backward match nil t)
8454 (re-search-forward match nil t))))
8455 (when (or (and found
8459 (push (gnus-data-number data) articles)))))
8461 (message "No messages matched")
8462 (gnus-summary-limit articles)))
8463 (gnus-summary-position-point))
8465 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8466 "Limit the summary buffer to articles that aren't part on any thread.
8467 If THREADSP (the prefix), limit to articles that are in threads."
8469 (let ((articles nil)
8472 (dolist (thread gnus-newsgroup-threads)
8473 (if (stringp (car thread))
8474 (dolist (thread (cdr thread))
8475 (push thread threads))
8476 (push thread threads)))
8477 (dolist (thread threads)
8478 (setq thread-articles (gnus-articles-in-thread thread))
8479 (when (or (and threadsp
8480 (> (length thread-articles) 1))
8482 (= (length thread-articles) 1)))
8483 (setq articles (nconc thread-articles articles))))
8485 (message "No messages matched")
8486 (gnus-summary-limit articles))
8487 (gnus-summary-position-point)))
8489 (defun gnus-summary-limit-to-replied (&optional unreplied)
8490 "Limit the summary buffer to replied articles.
8491 If UNREPLIED (the prefix), limit to unreplied articles."
8495 (gnus-set-difference gnus-newsgroup-articles
8496 gnus-newsgroup-replied))
8497 (gnus-summary-limit gnus-newsgroup-replied))
8498 (gnus-summary-position-point))
8500 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8501 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8502 If REVERSE, limit the summary buffer to articles that are marked
8503 with MARKS. MARKS can either be a string of marks or a list of marks.
8504 Returns how many articles were removed."
8505 (interactive "sMarks: ")
8506 (gnus-summary-limit-to-marks marks t))
8508 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8509 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8510 If REVERSE (the prefix), limit the summary buffer to articles that are
8511 not marked with MARKS. MARKS can either be a string of marks or a
8513 Returns how many articles were removed."
8514 (interactive "sMarks: \nP")
8516 (let ((data gnus-newsgroup-data)
8517 (marks (if (listp marks) marks
8518 (append marks nil))) ; Transform to list.
8521 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8522 (memq (gnus-data-mark (car data)) marks))
8523 (push (gnus-data-number (car data)) articles))
8524 (setq data (cdr data)))
8525 (gnus-summary-limit articles))
8526 (gnus-summary-position-point)))
8528 (defun gnus-summary-limit-to-score (score)
8529 "Limit to articles with score at or above SCORE."
8530 (interactive "NLimit to articles with score of at least: ")
8531 (let ((data gnus-newsgroup-data)
8534 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8536 (push (gnus-data-number (car data)) articles))
8537 (setq data (cdr data)))
8539 (gnus-summary-limit articles)
8540 (gnus-summary-position-point))))
8542 (defun gnus-summary-limit-to-unseen ()
8543 "Limit to unseen articles."
8546 (gnus-summary-limit gnus-newsgroup-unseen)
8547 (gnus-summary-position-point)))
8549 (defun gnus-summary-limit-include-thread (id)
8550 "Display all the hidden articles that is in the thread with ID in it.
8551 When called interactively, ID is the Message-ID of the current
8553 (interactive (list (mail-header-id (gnus-summary-article-header))))
8554 (let ((articles (gnus-articles-in-thread
8555 (gnus-id-to-thread (gnus-root-id id))))
8556 ;;we REALLY want the whole thread---this prevents cut-threads
8557 ;;from removing the thread we want to include.
8558 (gnus-fetch-old-headers nil)
8559 (gnus-build-sparse-threads nil))
8561 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8562 (gnus-summary-limit-include-matching-articles
8564 (regexp-quote (gnus-simplify-subject-re
8565 (mail-header-subject (gnus-id-to-header id)))))
8566 (gnus-summary-position-point))))
8568 (defun gnus-summary-limit-include-matching-articles (header regexp)
8569 "Display all the hidden articles that have HEADERs that match REGEXP."
8570 (interactive (list (read-string "Match on header: ")
8571 (read-string "Regexp: ")))
8572 (let ((articles (gnus-find-matching-articles header regexp)))
8574 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8575 (gnus-summary-position-point))))
8577 (defun gnus-summary-insert-dormant-articles ()
8578 "Insert all the dormant articles for this group into the current buffer."
8580 (let ((gnus-verbose (max 6 gnus-verbose)))
8581 (if (not gnus-newsgroup-dormant)
8582 (gnus-message 3 "No dormant articles for this group")
8583 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8585 (defun gnus-summary-insert-ticked-articles ()
8586 "Insert ticked articles for this group into the current buffer."
8588 (let ((gnus-verbose (max 6 gnus-verbose)))
8589 (if (not gnus-newsgroup-marked)
8590 (gnus-message 3 "No ticked articles for this group")
8591 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8593 (defun gnus-summary-limit-include-dormant ()
8594 "Display all the hidden articles that are marked as dormant.
8595 Note that this command only works on a subset of the articles currently
8596 fetched for this group."
8598 (unless gnus-newsgroup-dormant
8599 (error "There are no dormant articles in this group"))
8601 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8602 (gnus-summary-position-point)))
8604 (defun gnus-summary-include-articles (articles)
8605 "Fetch the headers for ARTICLES and then display the summary lines."
8606 (let ((gnus-inhibit-demon t)
8608 (gnus-read-all-available-headers t))
8609 (setq gnus-newsgroup-headers
8611 'list gnus-newsgroup-headers
8612 (gnus-fetch-headers articles nil t)
8613 'gnus-article-sort-by-number))
8614 (setq gnus-newsgroup-articles
8615 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8616 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8618 (defun gnus-summary-limit-exclude-dormant ()
8619 "Hide all dormant articles."
8622 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8623 (gnus-summary-position-point)))
8625 (defun gnus-summary-limit-exclude-childless-dormant ()
8626 "Hide all dormant articles that have no children."
8628 (let ((data (gnus-data-list t))
8629 articles d children)
8630 ;; Find all articles that are either not dormant or have
8632 (while (setq d (pop data))
8633 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8635 (gnus-article-children (gnus-data-number d)))
8638 (when (memq (car children) articles)
8643 (push (gnus-data-number d) articles)))
8646 (gnus-summary-limit articles)
8647 (gnus-summary-position-point))))
8649 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8650 "Mark all unread excluded articles as read.
8651 If ALL, mark even excluded ticked and dormants as read."
8653 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8654 (let ((articles (gnus-sorted-ndifference
8656 (mapcar (lambda (h) (mail-header-number h))
8657 gnus-newsgroup-headers)
8659 gnus-newsgroup-limit))
8661 (setq gnus-newsgroup-unreads
8662 (gnus-sorted-intersection gnus-newsgroup-unreads
8663 gnus-newsgroup-limit))
8665 (setq gnus-newsgroup-dormant nil
8666 gnus-newsgroup-marked nil
8667 gnus-newsgroup-reads
8669 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8670 gnus-newsgroup-reads))
8671 (while (setq article (pop articles))
8672 (unless (or (memq article gnus-newsgroup-dormant)
8673 (memq article gnus-newsgroup-marked))
8674 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8676 (defun gnus-summary-limit (articles &optional pop)
8678 ;; We pop the previous limit off the stack and use that.
8679 (setq articles (car gnus-newsgroup-limits)
8680 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8681 ;; We use the new limit, so we push the old limit on the stack.
8682 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8684 (setq gnus-newsgroup-limit articles)
8685 (let ((total (length gnus-newsgroup-data))
8686 (data (gnus-data-find-list (gnus-summary-article-number)))
8687 (gnus-summary-mark-below nil) ; Inhibit this.
8689 ;; This will do all the work of generating the new summary buffer
8690 ;; according to the new limit.
8691 (gnus-summary-prepare)
8692 ;; Hide any threads, possibly.
8693 (gnus-summary-maybe-hide-threads)
8694 ;; Try to return to the article you were at, or one in the
8697 ;; We try to find some article after the current one.
8699 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8702 (setq data (cdr data))))
8704 ;; If there is no data, that means that we were after the last
8705 ;; article. The same goes when we can't find any articles
8706 ;; after the current one.
8707 (goto-char (point-max))
8708 (gnus-summary-find-prev))
8709 (gnus-set-mode-line 'summary)
8710 ;; We return how many articles were removed from the summary
8711 ;; buffer as a result of the new limit.
8712 (- total (length gnus-newsgroup-data))))
8714 (defsubst gnus-invisible-cut-children (threads)
8717 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8722 (defsubst gnus-cut-thread (thread)
8723 "Go forwards in the thread until we find an article that we want to display."
8724 (when (or (eq gnus-fetch-old-headers 'some)
8725 (eq gnus-fetch-old-headers 'invisible)
8726 (numberp gnus-fetch-old-headers)
8727 (eq gnus-build-sparse-threads 'some)
8728 (eq gnus-build-sparse-threads 'more))
8729 ;; Deal with old-fetched headers and sparse threads.
8733 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8734 (gnus-summary-article-ancient-p
8735 (mail-header-number (car thread))))
8736 (if (or (<= (length (cdr thread)) 1)
8737 (eq gnus-fetch-old-headers 'invisible))
8738 (setq gnus-newsgroup-limit
8739 (delq (mail-header-number (car thread))
8740 gnus-newsgroup-limit)
8741 thread (cadr thread))
8742 (when (gnus-invisible-cut-children (cdr thread))
8743 (let ((th (cdr thread)))
8745 (if (memq (mail-header-number (caar th))
8746 gnus-newsgroup-limit)
8747 (setq thread (car th)
8749 (setq th (cdr th))))))))))
8752 (defun gnus-cut-threads (threads)
8753 "Cut off all uninteresting articles from the beginning of THREADS."
8754 (when (or (eq gnus-fetch-old-headers 'some)
8755 (eq gnus-fetch-old-headers 'invisible)
8756 (numberp gnus-fetch-old-headers)
8757 (eq gnus-build-sparse-threads 'some)
8758 (eq gnus-build-sparse-threads 'more))
8761 (setcar th (gnus-cut-thread (car th)))
8762 (setq th (cdr th)))))
8763 ;; Remove nixed out threads.
8766 (defun gnus-summary-initial-limit (&optional show-if-empty)
8767 "Figure out what the initial limit is supposed to be on group entry.
8768 This entails weeding out unwanted dormants, low-scored articles,
8769 fetch-old-headers verbiage, and so on."
8770 ;; Most groups have nothing to remove.
8771 (unless (or gnus-inhibit-limiting
8772 (and (null gnus-newsgroup-dormant)
8773 (eq gnus-newsgroup-display 'gnus-not-ignore)
8774 (not (eq gnus-fetch-old-headers 'some))
8775 (not (numberp gnus-fetch-old-headers))
8776 (not (eq gnus-fetch-old-headers 'invisible))
8777 (null gnus-summary-expunge-below)
8778 (not (eq gnus-build-sparse-threads 'some))
8779 (not (eq gnus-build-sparse-threads 'more))
8780 (null gnus-thread-expunge-below)))
8781 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8782 (setq gnus-newsgroup-limit nil)
8785 (unless (car (symbol-value node))
8786 ;; These threads have no parents -- they are roots.
8787 (let ((nodes (cdr (symbol-value node)))
8790 (if (and gnus-thread-expunge-below
8791 (< (gnus-thread-total-score (car nodes))
8792 gnus-thread-expunge-below))
8793 (gnus-expunge-thread (pop nodes))
8794 (setq thread (pop nodes))
8795 (gnus-summary-limit-children thread))))))
8796 gnus-newsgroup-dependencies)
8797 ;; If this limitation resulted in an empty group, we might
8798 ;; pop the previous limit and use it instead.
8799 (when (and (not gnus-newsgroup-limit)
8801 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8802 gnus-newsgroup-limit))
8804 (defun gnus-summary-limit-children (thread)
8805 "Return 1 if this subthread is visible and 0 if it is not."
8806 ;; First we get the number of visible children to this thread. This
8807 ;; is done by recursing down the thread using this function, so this
8808 ;; will really go down to a leaf article first, before slowly
8809 ;; working its way up towards the root.
8811 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8814 (apply '+ (mapcar 'gnus-summary-limit-children
8817 (number (mail-header-number (car thread)))
8820 (not (memq number gnus-newsgroup-marked))
8822 ;; If this article is dormant and has absolutely no visible
8823 ;; children, then this article isn't visible.
8824 (and (memq number gnus-newsgroup-dormant)
8826 ;; If this is "fetch-old-headered" and there is no
8827 ;; visible children, then we don't want this article.
8828 (and (or (eq gnus-fetch-old-headers 'some)
8829 (numberp gnus-fetch-old-headers))
8830 (gnus-summary-article-ancient-p number)
8832 ;; If this is "fetch-old-headered" and `invisible', then
8833 ;; we don't want this article.
8834 (and (eq gnus-fetch-old-headers 'invisible)
8835 (gnus-summary-article-ancient-p number))
8836 ;; If this is a sparsely inserted article with no children,
8837 ;; we don't want it.
8838 (and (eq gnus-build-sparse-threads 'some)
8839 (gnus-summary-article-sparse-p number)
8841 ;; If we use expunging, and this article is really
8842 ;; low-scored, then we don't want this article.
8843 (when (and gnus-summary-expunge-below
8845 (or (cdr (assq number gnus-newsgroup-scored))
8846 gnus-summary-default-score))
8847 gnus-summary-expunge-below))
8848 ;; We increase the expunge-tally here, but that has
8849 ;; nothing to do with the limits, really.
8850 (incf gnus-newsgroup-expunged-tally)
8851 ;; We also mark as read here, if that's wanted.
8852 (when (and gnus-summary-mark-below
8853 (< score gnus-summary-mark-below))
8854 (setq gnus-newsgroup-unreads
8855 (delq number gnus-newsgroup-unreads))
8856 (if gnus-newsgroup-auto-expire
8857 (push number gnus-newsgroup-expirable)
8858 (push (cons number gnus-low-score-mark)
8859 gnus-newsgroup-reads)))
8861 ;; Do the `display' group parameter.
8862 (and gnus-newsgroup-display
8863 (let ((gnus-number number))
8864 (not (funcall gnus-newsgroup-display))))))
8865 ;; Nope, invisible article.
8867 ;; Ok, this article is to be visible, so we add it to the limit
8869 (push number gnus-newsgroup-limit)
8872 (defun gnus-expunge-thread (thread)
8873 "Mark all articles in THREAD as read."
8874 (let* ((number (mail-header-number (car thread))))
8875 (incf gnus-newsgroup-expunged-tally)
8876 ;; We also mark as read here, if that's wanted.
8877 (setq gnus-newsgroup-unreads
8878 (delq number gnus-newsgroup-unreads))
8879 (if gnus-newsgroup-auto-expire
8880 (push number gnus-newsgroup-expirable)
8881 (push (cons number gnus-low-score-mark)
8882 gnus-newsgroup-reads)))
8883 ;; Go recursively through all subthreads.
8884 (mapcar 'gnus-expunge-thread (cdr thread)))
8886 ;; Summary article oriented commands
8888 (defun gnus-summary-refer-parent-article (n)
8889 "Refer parent article N times.
8890 If N is negative, go to ancestor -N instead.
8891 The difference between N and the number of articles fetched is returned."
8895 (when (not (natnump n))
8900 (setq header (gnus-summary-article-header))
8901 (if (and (eq (mail-header-number header)
8902 (cdr gnus-article-current))
8903 (equal gnus-newsgroup-name
8904 (car gnus-article-current)))
8905 ;; If we try to find the parent of the currently
8906 ;; displayed article, then we take a look at the actual
8907 ;; References header, since this is slightly more
8908 ;; reliable than the References field we got from the
8910 (with-current-buffer gnus-original-article-buffer
8911 (nnheader-narrow-to-headers)
8912 (unless (setq ref (message-fetch-field "references"))
8913 (when (setq ref (message-fetch-field "in-reply-to"))
8914 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8917 ;; It's not the current article, so we take a bet on
8918 ;; the value we got from the server.
8919 (mail-header-references header)))
8921 (not (equal ref "")))
8922 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8923 (gnus-message 1 "Couldn't find parent"))
8924 (gnus-message 1 "No references in article %d"
8925 (gnus-summary-article-number))
8928 (gnus-summary-position-point)
8931 (defun gnus-summary-refer-references ()
8932 "Fetch all articles mentioned in the References header.
8933 Return the number of articles fetched."
8935 (let ((ref (mail-header-references (gnus-summary-article-header)))
8936 (current (gnus-summary-article-number))
8940 (error "No References in the current article")
8941 ;; For each Message-ID in the References header...
8942 (while (string-match "<[^>]*>" ref)
8944 ;; ... fetch that article.
8945 (gnus-summary-refer-article
8946 (prog1 (match-string 0 ref)
8947 (setq ref (substring ref (match-end 0))))))
8948 (gnus-summary-goto-subject current)
8949 (gnus-summary-position-point)
8952 (defun gnus-delete-duplicate-headers (headers)
8953 ;; First remove leading duplicates.
8954 (while (and (> (length headers) 1)
8955 (= (mail-header-number (car headers))
8956 (mail-header-number (cadr headers))))
8959 (let ((result headers))
8960 (while (> (length headers) 1)
8961 (if (= (mail-header-number (car headers))
8962 (mail-header-number (cadr headers)))
8963 (setcdr headers (cddr headers))
8967 (defun gnus-summary-refer-thread (&optional limit)
8968 "Fetch all articles in the current thread. For backends that
8969 know how to search for threads (currently only 'nnimap) a
8970 non-numeric prefix arg will use nnir to search the entire
8971 server; without a prefix arg only the current group is
8972 searched. If the variable `gnus-refer-thread-use-nnir' is
8973 non-nil the prefix arg has the reverse meaning. If no
8974 backend-specific 'request-thread function is available fetch
8975 LIMIT (the numerical prefix) old headers. If LIMIT is
8976 non-numeric or nil fetch the number specified by the
8977 `gnus-refer-thread-limit' variable."
8979 (gnus-warp-to-article)
8980 (let* ((header (gnus-summary-article-header))
8981 (id (mail-header-id header))
8982 (gnus-inhibit-demon t)
8983 (gnus-summary-ignore-duplicates t)
8984 (gnus-read-all-available-headers t)
8985 (gnus-refer-thread-use-nnir
8986 (if (and (not (null limit)) (listp limit))
8987 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
8989 (if (gnus-check-backend-function
8990 'request-thread gnus-newsgroup-name)
8991 (gnus-request-thread header gnus-newsgroup-name)
8992 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
8993 gnus-refer-thread-limit))
8994 (last (if (numberp limit)
8995 (min (+ (mail-header-number header)
8997 gnus-newsgroup-highest)
8998 gnus-newsgroup-highest))
8999 (subject (gnus-simplify-subject
9000 (mail-header-subject header)))
9001 (refs (split-string (or (mail-header-references header)
9003 (gnus-parse-headers-hook
9004 `(lambda () (goto-char (point-min))
9006 (regexp-opt ',(append refs (list id subject)))))))
9007 (gnus-fetch-headers (list last) (if (numberp limit)
9008 (* 2 limit) limit) t))))
9010 (when (listp new-headers)
9011 (dolist (header new-headers)
9012 (push (mail-header-number header) article-ids)
9013 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9014 (push (mail-header-number header) gnus-newsgroup-unreads)
9015 (setq gnus-newsgroup-unselected
9016 (delete (mail-header-number header)
9017 gnus-newsgroup-unselected))))
9018 (setq gnus-newsgroup-headers
9019 (gnus-delete-duplicate-headers
9021 'list gnus-newsgroup-headers new-headers
9022 'gnus-article-sort-by-number)))
9023 (setq gnus-newsgroup-articles
9024 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9025 (gnus-summary-limit-include-thread id)))
9026 (gnus-summary-show-thread))
9028 (defun gnus-summary-refer-article (message-id)
9029 "Fetch an article specified by MESSAGE-ID."
9030 (interactive "sMessage-ID: ")
9031 (gnus-warp-to-article)
9032 (when (and (stringp message-id)
9033 (not (zerop (length message-id))))
9034 (setq message-id (gnus-replace-in-string message-id " " ""))
9035 ;; Construct the correct Message-ID if necessary.
9036 ;; Suggested by tale@pawl.rpi.edu.
9037 (unless (string-match "^<" message-id)
9038 (setq message-id (concat "<" message-id)))
9039 (unless (string-match ">$" message-id)
9040 (setq message-id (concat message-id ">")))
9041 ;; People often post MIDs from URLs, so unhex it:
9042 (unless (string-match "@" message-id)
9043 (setq message-id (gnus-url-unhex-string message-id)))
9044 (let* ((header (gnus-id-to-header message-id))
9046 (gnus-summary-article-sparse-p
9047 (mail-header-number header))
9048 (memq (mail-header-number header)
9049 gnus-newsgroup-limit)))
9052 ;; If the article is present in the buffer we just go to it.
9054 (or (not (gnus-summary-article-sparse-p
9055 (mail-header-number header)))
9058 (gnus-summary-goto-article
9059 (mail-header-number header) nil t)
9061 (gnus-summary-update-article (mail-header-number header)))))
9063 ;; We fetch the article.
9065 (dolist (gnus-override-method (gnus-refer-article-methods))
9066 (when (and (gnus-check-server gnus-override-method)
9067 ;; Fetch the header,
9068 (setq number (gnus-summary-insert-subject message-id)))
9069 ;; and display the article.
9070 (gnus-summary-select-article nil nil nil number)
9072 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9074 (defun gnus-refer-article-methods ()
9075 "Return a list of referable methods."
9077 ;; No method, so we default to current and native.
9078 ((null gnus-refer-article-method)
9079 (list gnus-current-select-method gnus-select-method))
9081 ((eq 'current gnus-refer-article-method)
9082 (list gnus-current-select-method))
9083 ;; List of select methods.
9084 ((not (and (symbolp (car gnus-refer-article-method))
9085 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9087 (dolist (method gnus-refer-article-method)
9088 (push (if (eq 'current method)
9089 gnus-current-select-method
9090 (if (eq 'nnir (car method))
9094 (gnus-method-to-server gnus-current-select-method)))
9098 ;; One single select method.
9100 (list gnus-refer-article-method))))
9102 (defun gnus-summary-edit-parameters ()
9103 "Edit the group parameters of the current group."
9105 (gnus-group-edit-group gnus-newsgroup-name 'params))
9107 (defun gnus-summary-customize-parameters ()
9108 "Customize the group parameters of the current group."
9110 (gnus-group-customize gnus-newsgroup-name))
9112 (defun gnus-summary-enter-digest-group (&optional force)
9113 "Enter an nndoc group based on the current article.
9114 If FORCE, force a digest interpretation. If not, try to guess
9115 what the document format is.
9117 To control what happens when you exit the group, see the
9118 `gnus-auto-select-on-ephemeral-exit' variable."
9120 (let ((conf gnus-current-window-configuration))
9121 (save-window-excursion
9123 (let (gnus-article-prepare-hook
9124 gnus-display-mime-function
9126 (gnus-summary-select-article))))
9127 (setq gnus-current-window-configuration conf)
9128 (let* ((name (format "%s-%d"
9129 (gnus-group-prefixed-name
9130 gnus-newsgroup-name (list 'nndoc ""))
9131 (with-current-buffer gnus-summary-buffer
9132 gnus-current-article)))
9133 (ogroup gnus-newsgroup-name)
9134 (params (append (gnus-info-params (gnus-get-info ogroup))
9135 (list (cons 'to-group ogroup))
9136 (list (cons 'parent-group ogroup))
9137 (list (cons 'save-article-group ogroup))))
9138 (case-fold-search t)
9139 (buf (current-buffer))
9140 dig to-address charset)
9141 (with-current-buffer gnus-original-article-buffer
9142 ;; Have the digest group inherit the main mail address of
9143 ;; the parent article.
9144 (when (setq to-address (or (gnus-fetch-field "reply-to")
9145 (gnus-fetch-field "from")))
9148 (list (cons 'to-address
9149 (funcall gnus-decode-encoded-address-function
9151 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9152 (insert-buffer-substring gnus-original-article-buffer)
9154 (goto-char (point-min))
9155 (or (search-forward "\n\n" nil t) (point)))
9156 ;; Remove lines that may lead nndoc to misinterpret the
9158 (goto-char (point-min))
9159 (delete-matching-lines "^Path:\\|^From ")
9160 ;; Parse charset, and decode content transfer encoding.
9161 (setq charset (mail-content-type-get
9162 (mail-header-parse-content-type
9163 (or (gnus-fetch-field "content-type") ""))
9165 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9167 (message-remove-header "content-transfer-encoding")
9168 (goto-char (point-max))
9170 (narrow-to-region (point) (point-max))
9171 (mm-decode-content-transfer-encoding
9172 (intern (downcase (mail-header-strip encoding))))))
9175 (if (let ((gnus-newsgroup-ephemeral-charset
9177 (intern (downcase (gnus-strip-whitespace charset)))
9178 gnus-newsgroup-charset))
9179 (gnus-newsgroup-ephemeral-ignored-charsets
9180 gnus-newsgroup-ignored-charsets))
9181 (gnus-group-read-ephemeral-group
9182 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9184 ,(if force 'mbox 'guess)))
9186 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9188 ;; Make all postings to this group go to the parent group.
9189 (nconc (gnus-info-params (gnus-get-info name))
9191 ;; Couldn't select this doc group.
9192 (switch-to-buffer buf)
9193 (gnus-set-global-variables)
9194 (gnus-configure-windows 'summary)
9195 (gnus-message 3 "Article couldn't be entered?"))
9196 (kill-buffer dig)))))
9198 (defun gnus-summary-read-document (n)
9199 "Open a new group based on the current article(s).
9200 This will allow you to read digests and other similar
9201 documents as newsgroups.
9202 Obeys the standard process/prefix convention."
9204 (let* ((ogroup gnus-newsgroup-name)
9205 (params (append (gnus-info-params (gnus-get-info ogroup))
9206 (list (cons 'to-group ogroup))))
9207 group egroup groups vgroup)
9208 (dolist (article (gnus-summary-work-articles n))
9209 (setq group (format "%s-%d" gnus-newsgroup-name article))
9210 (gnus-summary-remove-process-mark article)
9211 (when (gnus-summary-display-article article)
9212 (save-excursion ;;What for?
9214 (insert-buffer-substring gnus-original-article-buffer)
9215 ;; Remove some headers that may lead nndoc to make
9217 (message-narrow-to-head)
9218 (goto-char (point-min))
9219 (delete-matching-lines "^Path:\\|^From ")
9222 (gnus-group-read-ephemeral-group
9223 group `(nndoc ,group (nndoc-address ,(current-buffer))
9224 (nndoc-article-type guess))
9227 ;; Make all postings to this group go to the parent group.
9228 (nconc (gnus-info-params (gnus-get-info egroup))
9230 (push egroup groups))
9231 ;; Couldn't select this doc group.
9232 (gnus-error 3 "Article couldn't be entered"))))))
9233 ;; Now we have selected all the documents.
9236 (error "None of the articles could be interpreted as documents"))
9237 ((gnus-group-read-ephemeral-group
9238 (setq vgroup (format
9239 "nnvirtual:%s-%s" gnus-newsgroup-name
9240 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9241 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9243 (cons (current-buffer) 'summary)))
9245 (error "Couldn't select virtual nndoc group")))))
9247 (defun gnus-summary-widget-forward (arg)
9248 "Move point to the next field or button in the article.
9249 With optional ARG, move across that many fields."
9251 (gnus-summary-select-article)
9252 (gnus-configure-windows 'article)
9253 (select-window (gnus-get-buffer-window gnus-article-buffer))
9254 (widget-forward arg))
9256 (defun gnus-summary-widget-backward (arg)
9257 "Move point to the previous field or button in the article.
9258 With optional ARG, move across that many fields."
9260 (gnus-summary-select-article)
9261 (gnus-configure-windows 'article)
9262 (select-window (gnus-get-buffer-window gnus-article-buffer))
9263 (unless (widget-at (point))
9264 (goto-char (point-max)))
9265 (widget-backward arg))
9267 (defun gnus-summary-isearch-article (&optional regexp-p)
9268 "Do incremental search forward on the current article.
9269 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9271 (gnus-summary-select-article)
9272 (gnus-configure-windows 'article)
9273 (gnus-eval-in-buffer-window gnus-article-buffer
9276 (isearch-forward regexp-p))))
9278 (defun gnus-summary-repeat-search-article-forward ()
9279 "Repeat the previous search forwards."
9281 (unless gnus-last-search-regexp
9282 (error "No previous search"))
9283 (gnus-summary-search-article-forward gnus-last-search-regexp))
9285 (defun gnus-summary-repeat-search-article-backward ()
9286 "Repeat the previous search backwards."
9288 (unless gnus-last-search-regexp
9289 (error "No previous search"))
9290 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9292 (defun gnus-summary-search-article-forward (regexp &optional backward)
9293 "Search for an article containing REGEXP forward.
9294 If BACKWARD, search backward instead."
9297 (format "Search article %s (regexp%s): "
9298 (if current-prefix-arg "backward" "forward")
9299 (if gnus-last-search-regexp
9300 (concat ", default " gnus-last-search-regexp)
9302 current-prefix-arg))
9303 (if (string-equal regexp "")
9304 (setq regexp (or gnus-last-search-regexp ""))
9305 (setq gnus-last-search-regexp regexp)
9306 (setq gnus-article-before-search gnus-current-article))
9307 ;; Intentionally set gnus-last-article.
9308 (setq gnus-last-article gnus-article-before-search)
9309 (let ((gnus-last-article gnus-last-article))
9310 (if (gnus-summary-search-article regexp backward)
9311 (gnus-summary-show-thread)
9312 (signal 'search-failed (list regexp)))))
9314 (defun gnus-summary-search-article-backward (regexp)
9315 "Search for an article containing REGEXP backward."
9318 (format "Search article backward (regexp%s): "
9319 (if gnus-last-search-regexp
9320 (concat ", default " gnus-last-search-regexp)
9322 (gnus-summary-search-article-forward regexp 'backward))
9324 (defun gnus-summary-search-article (regexp &optional backward)
9325 "Search for an article containing REGEXP.
9326 Optional argument BACKWARD means do search for backward.
9327 `gnus-select-article-hook' is not called during the search."
9328 ;; We have to require this here to make sure that the following
9329 ;; dynamic binding isn't shadowed by autoloading.
9330 (require 'gnus-async)
9332 (let ((gnus-select-article-hook nil) ;Disable hook.
9333 (gnus-article-prepare-hook nil)
9334 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9335 (gnus-use-article-prefetch nil)
9336 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9337 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9339 (gnus-keep-backlog nil)
9340 (gnus-break-pages nil)
9341 (gnus-summary-display-arrow nil)
9342 (gnus-updated-mode-lines nil)
9343 (gnus-auto-center-summary nil)
9344 (sum (current-buffer))
9345 (gnus-display-mime-function nil)
9348 (gnus-save-hidden-threads
9349 (gnus-summary-select-article)
9350 (set-buffer gnus-article-buffer)
9351 (goto-char (window-point (get-buffer-window (current-buffer))))
9355 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9357 (re-search-backward regexp nil t)
9358 (re-search-forward regexp nil t))
9359 ;; We found the regexp.
9364 (get-buffer-window (current-buffer))
9368 (get-buffer-window (current-buffer))
9371 (setq point (point)))
9372 ;; We didn't find it, so we go to the next article.
9375 (while (eq found 'not)
9376 (if (not (if backward (gnus-summary-find-prev)
9377 (gnus-summary-find-next)))
9378 ;; No more articles.
9380 ;; Select the next article and adjust point.
9381 (unless (gnus-summary-article-sparse-p
9382 (gnus-summary-article-number))
9384 (gnus-summary-select-article)
9385 (set-buffer gnus-article-buffer)
9387 (goto-char (if backward (point-max) (point-min))))))))
9388 (gnus-message 7 ""))
9389 ;; Return whether we found the regexp.
9390 (when (eq found 'found)
9392 (gnus-summary-show-thread)
9393 (gnus-summary-goto-subject gnus-current-article)
9394 (gnus-summary-position-point)
9397 (defun gnus-find-matching-articles (header regexp)
9398 "Return a list of all articles that match REGEXP on HEADER.
9399 This search includes all articles in the current group that Gnus has
9400 fetched headers for, whether they are displayed or not."
9401 (let ((articles nil)
9402 ;; Can't eta-reduce because it's a macro.
9403 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9404 (case-fold-search t))
9405 (dolist (header gnus-newsgroup-headers)
9406 (when (string-match regexp (funcall func header))
9407 (push (mail-header-number header) articles)))
9408 (nreverse articles)))
9410 (defun gnus-summary-find-matching (header regexp &optional backward unread
9411 not-case-fold not-matching)
9412 "Return a list of all articles that match REGEXP on HEADER.
9413 The search stars on the current article and goes forwards unless
9414 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9415 If UNREAD is non-nil, only unread articles will
9416 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9417 in the comparisons. If NOT-MATCHING, return a list of all articles that
9418 not match REGEXP on HEADER."
9419 (let ((case-fold-search (not not-case-fold))
9422 (if (eq (car header) 'extra)
9425 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9427 (error "%s is an invalid header" header))
9428 (unless (fboundp (intern (concat "mail-header-" header)))
9429 (error "%s is not a valid header" header))
9430 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9431 (dolist (d (if (eq backward 'all)
9433 (gnus-data-find-list
9434 (gnus-summary-article-number)
9435 (gnus-data-list backward))))
9436 (when (and (or (not unread) ; We want all articles...
9437 (gnus-data-unread-p d)) ; Or just unreads.
9438 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9442 (funcall func (gnus-data-header d))))
9443 (string-match regexp
9444 (funcall func (gnus-data-header d)))))
9445 (push (gnus-data-number d) articles))) ; Success!
9446 (nreverse articles)))
9448 (defun gnus-summary-execute-command (header regexp command &optional backward)
9449 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9450 If HEADER is an empty string (or nil), the match is done on the entire
9451 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9453 (list (let ((completion-ignore-case t))
9454 (gnus-completing-read
9456 (mapcar 'symbol-name
9458 '(Number Subject From Lines Date
9459 Message-ID Xref References Body)
9460 gnus-extra-headers))
9462 (read-string "Regexp: ")
9463 (read-key-sequence "Command: ")
9464 current-prefix-arg))
9465 (when (equal header "Body")
9467 ;; Hidden thread subtrees must be searched as well.
9468 (gnus-summary-show-all-threads)
9469 ;; We don't want to change current point nor window configuration.
9471 (save-window-excursion
9473 gnus-treat-strip-trailing-blank-lines
9474 gnus-treat-strip-leading-blank-lines
9475 gnus-treat-strip-multiple-blank-lines
9476 gnus-treat-hide-boring-headers
9477 gnus-treat-fold-newsgroups
9478 gnus-article-prepare-hook)
9479 (gnus-message 6 "Executing %s..." (key-description command))
9480 ;; We'd like to execute COMMAND interactively so as to give arguments.
9481 (gnus-execute header regexp
9482 `(call-interactively ',(key-binding command))
9484 (gnus-message 6 "Executing %s...done" (key-description command))))))
9486 (defun gnus-summary-beginning-of-article ()
9487 "Scroll the article back to the beginning."
9489 (gnus-summary-select-article)
9490 (gnus-configure-windows 'article)
9491 (gnus-eval-in-buffer-window gnus-article-buffer
9493 (goto-char (point-min))
9494 (when gnus-break-pages
9495 (gnus-narrow-to-page))))
9497 (defun gnus-summary-end-of-article ()
9498 "Scroll to the end of the article."
9500 (gnus-summary-select-article)
9501 (gnus-configure-windows 'article)
9502 (gnus-eval-in-buffer-window gnus-article-buffer
9504 (goto-char (point-max))
9506 (when gnus-break-pages
9507 (gnus-narrow-to-page))))
9509 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9510 "Truncate to LEN and quote all \"(\"'s in STRING."
9511 (gnus-replace-in-string (if (and len (> (length string) len))
9512 (substring string 0 len)
9516 (defun gnus-summary-print-article (&optional filename n)
9517 "Generate and print a PostScript image of the process-marked (mail) articles.
9519 If used interactively, print the current article if none are
9520 process-marked. With prefix arg, prompt the user for the name of the
9523 When used from Lisp, accept two optional args FILENAME and N. N means
9524 to print the next N articles. If N is negative, print the N previous
9525 articles. If N is nil and articles have been marked with the process
9526 mark, print these instead.
9528 If the optional first argument FILENAME is nil, send the image to the
9529 printer. If FILENAME is a string, save the PostScript image in a file with
9530 that name. If FILENAME is a number, prompt the user for the name of the file
9532 (interactive (list (ps-print-preprint current-prefix-arg)))
9533 (dolist (article (gnus-summary-work-articles n))
9534 (gnus-summary-select-article nil nil 'pseudo article)
9535 (gnus-eval-in-buffer-window gnus-article-buffer
9536 (gnus-print-buffer))
9537 (gnus-summary-remove-process-mark article))
9538 (ps-despool filename))
9540 (defun gnus-print-buffer ()
9541 (let ((ps-left-header
9544 (gnus-summary-print-truncate-and-quote
9545 (mail-header-subject gnus-current-headers)
9548 (gnus-summary-print-truncate-and-quote
9549 (mail-header-from gnus-current-headers)
9553 "/pagenumberstring load"
9555 (mail-header-date gnus-current-headers) ")"))))
9556 (gnus-run-hooks 'gnus-ps-print-hook)
9558 (if ps-print-color-p
9559 (ps-spool-buffer-with-faces)
9560 (ps-spool-buffer)))))
9562 (defun gnus-summary-show-complete-article ()
9563 "Show a complete version of the current article.
9564 This is only useful if you're looking at a partial version of the
9567 (let ((gnus-keep-backlog nil)
9568 (gnus-use-cache nil)
9571 (format "%s-fetch-partial-articles"
9572 (car (gnus-find-method-for-group
9573 gnus-newsgroup-name)))
9578 (setq old-val (symbol-value variable))
9580 (gnus-flush-original-article-buffer)
9581 (gnus-summary-show-article))
9582 (set variable old-val))))
9584 (defun gnus-summary-show-article (&optional arg)
9585 "Force redisplaying of the current article.
9586 If ARG (the prefix) is a number, show the article with the charset
9587 defined in `gnus-summary-show-article-charset-alist', or the charset
9589 If ARG (the prefix) is non-nil and not a number, show the article,
9590 but without running any of the article treatment functions
9591 article. Normally, the keystroke is `C-u g'. When using `C-u
9592 C-u g', show the raw article."
9596 (gnus-summary-show-article t)
9597 (let ((gnus-newsgroup-charset
9598 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9599 (mm-read-coding-system
9600 "View as charset: " ;; actually it is coding system.
9601 (with-current-buffer gnus-article-buffer
9602 (mm-detect-coding-region (point) (point-max))))))
9603 (gnus-newsgroup-ignored-charsets 'gnus-all))
9604 (gnus-summary-select-article nil 'force)
9605 (let ((deps gnus-newsgroup-dependencies)
9607 (with-current-buffer gnus-original-article-buffer
9609 (message-narrow-to-head)
9610 (setq head (buffer-string))
9611 (goto-char (point-min))
9612 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9613 (goto-char (point-max))
9615 (setq lines (1- (count-lines (point) (point-max))))))
9617 (insert (format "211 %d Article retrieved.\n"
9618 (cdr gnus-article-current)))
9620 (if lines (insert (format "Lines: %d\n" lines)))
9622 (let ((nntp-server-buffer (current-buffer)))
9623 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9624 (gnus-data-set-header
9625 (gnus-data-find (cdr gnus-article-current))
9627 (gnus-summary-update-article-line
9628 (cdr gnus-article-current) header)
9629 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9630 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9632 ;; Select the article the normal way.
9633 (if (eq mm-text-html-renderer 'shr)
9636 (let ((shr-ignore-cache t))
9637 (gnus-summary-select-article nil 'force)))
9638 (gnus-summary-select-article nil 'force)))
9641 (let ((gnus-inhibit-article-treatments t))
9642 (gnus-summary-select-article nil 'force)))
9644 ;; We have to require this here to make sure that the following
9645 ;; dynamic binding isn't shadowed by autoloading.
9646 (require 'gnus-async)
9648 ;; Bind the article treatment functions to nil.
9649 (let ((gnus-have-all-headers t)
9650 gnus-article-prepare-hook
9651 gnus-article-decode-hook
9652 gnus-display-mime-function
9654 ;; Destroy any MIME parts.
9655 (when (gnus-buffer-live-p gnus-article-buffer)
9656 (with-current-buffer gnus-article-buffer
9657 (gnus-article-stop-animations)
9658 (gnus-stop-downloads)
9659 (mm-destroy-parts gnus-article-mime-handles)
9660 ;; Set it to nil for safety reason.
9661 (setq gnus-article-mime-handle-alist nil)
9662 (setq gnus-article-mime-handles nil)))
9663 (gnus-summary-select-article nil 'force))))
9664 (gnus-summary-goto-subject gnus-current-article)
9665 (gnus-summary-position-point))
9667 (defun gnus-summary-show-raw-article ()
9668 "Show the raw article without any article massaging functions being run."
9670 (gnus-summary-show-article t))
9672 (defun gnus-summary-verbose-headers (&optional arg)
9673 "Toggle permanent full header display.
9674 If ARG is a positive number, turn header display on.
9675 If ARG is a negative number, turn header display off."
9677 (setq gnus-show-all-headers
9678 (cond ((or (not (numberp arg))
9680 (not gnus-show-all-headers))
9683 (gnus-summary-show-article))
9685 (defun gnus-summary-toggle-header (&optional arg)
9686 "Show the headers if they are hidden, or hide them if they are shown.
9687 If ARG is a positive number, show the entire header.
9688 If ARG is a negative number, hide the unwanted header lines."
9690 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9691 (get-buffer-window gnus-article-buffer t))))
9692 (with-current-buffer gnus-article-buffer
9694 (article-narrow-to-head)
9695 (let* ((inhibit-read-only t)
9696 (inhibit-point-motion-hooks t)
9697 (hidden (if (numberp arg)
9699 (or (not (looking-at "[^ \t\n]+:"))
9700 (gnus-article-hidden-text-p 'headers))))
9702 (delete-region (point-min) (point-max))
9703 (with-current-buffer gnus-original-article-buffer
9704 (goto-char (setq s (point-min)))
9705 (setq e (if (search-forward "\n\n" nil t)
9708 (insert-buffer-substring gnus-original-article-buffer s e)
9709 (run-hooks 'gnus-article-decode-hook)
9711 (let ((gnus-treat-hide-headers nil)
9712 (gnus-treat-hide-boring-headers nil))
9713 (gnus-delete-wash-type 'headers)
9714 (gnus-treat-article 'head))
9715 (gnus-treat-article 'head))
9718 (set-window-start window (goto-char (point-min))))
9719 (if gnus-break-pages
9720 (gnus-narrow-to-page)
9721 (when (gnus-visual-p 'page-marker)
9722 (let ((inhibit-read-only t))
9723 (gnus-remove-text-with-property 'gnus-prev)
9724 (gnus-remove-text-with-property 'gnus-next))))
9725 (gnus-set-mode-line 'article)))))
9727 (defun gnus-summary-show-all-headers ()
9728 "Make all header lines visible."
9730 (gnus-summary-toggle-header 1))
9732 (defun gnus-summary-caesar-message (&optional arg)
9733 "Caesar rotate the current article by 13.
9734 With a non-numerical prefix, also rotate headers. A numerical
9735 prefix specifies how many places to rotate each letter forward."
9737 (gnus-summary-select-article)
9738 (let ((mail-header-separator ""))
9739 (gnus-eval-in-buffer-window gnus-article-buffer
9742 (let ((start (window-start))
9743 (inhibit-read-only t))
9744 (if (equal arg '(4))
9745 (message-caesar-buffer-body nil t)
9746 (message-caesar-buffer-body arg))
9747 (set-window-start (get-buffer-window (current-buffer)) start)))))
9748 ;; Create buttons and stuff...
9749 (gnus-treat-article nil))
9751 (declare-function idna-to-unicode "ext:idna" (str))
9753 (defun gnus-summary-idna-message (&optional arg)
9754 "Decode IDNA encoded domain names in the current articles.
9755 IDNA encoded domain names looks like `xn--bar'. If a string
9756 remain unencoded after running this function, it is likely an
9757 invalid IDNA string (`xn--bar' is invalid).
9759 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9760 installed for this command to work."
9762 (if (not (and (condition-case nil (require 'idna)
9764 (mm-coding-system-p 'utf-8)
9765 (executable-find (symbol-value 'idna-program))))
9767 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9768 (gnus-summary-select-article)
9769 (let ((mail-header-separator ""))
9770 (gnus-eval-in-buffer-window gnus-article-buffer
9773 (let ((start (window-start))
9775 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9776 (replace-match (idna-to-unicode (match-string 1))))
9777 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9779 (defun gnus-summary-morse-message (&optional arg)
9780 "Morse decode the current article."
9782 (gnus-summary-select-article)
9783 (let ((mail-header-separator ""))
9784 (gnus-eval-in-buffer-window gnus-article-buffer
9788 (let ((pos (window-start))
9789 (inhibit-read-only t))
9790 (goto-char (point-min))
9791 (when (message-goto-body)
9792 (gnus-narrow-to-body))
9793 (goto-char (point-min))
9794 (while (search-forward "·" (point-max) t)
9795 (replace-match "."))
9796 (unmorse-region (point-min) (point-max))
9798 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9800 (defun gnus-summary-stop-page-breaking ()
9801 "Stop page breaking in the current article."
9803 (gnus-summary-select-article)
9804 (gnus-eval-in-buffer-window gnus-article-buffer
9806 (when (gnus-visual-p 'page-marker)
9807 (let ((inhibit-read-only t))
9808 (gnus-remove-text-with-property 'gnus-prev)
9809 (gnus-remove-text-with-property 'gnus-next))
9810 (setq gnus-page-broken nil))))
9812 (defun gnus-summary-move-article (&optional n to-newsgroup
9813 select-method action)
9814 "Move the current article to a different newsgroup.
9815 If N is a positive number, move the N next articles.
9816 If N is a negative number, move the N previous articles.
9817 If N is nil and any articles have been marked with the process mark,
9818 move those articles instead.
9819 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9820 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9821 re-spool using this method.
9823 When called interactively with TO-NEWSGROUP being nil, the value of
9824 the variable `gnus-move-split-methods' is used for finding a default
9825 for the target newsgroup.
9827 For this function to work, both the current newsgroup and the
9828 newsgroup that you want to move to have to support the `request-move'
9829 and `request-accept' functions.
9831 ACTION can be either `move' (the default), `crosspost' or `copy'."
9834 (setq action 'move))
9835 ;; Check whether the source group supports the required functions.
9836 (cond ((and (eq action 'move)
9837 (not (gnus-check-backend-function
9838 'request-move-article gnus-newsgroup-name)))
9839 (error "The current group does not support article moving"))
9840 ((and (eq action 'crosspost)
9841 (not (gnus-check-backend-function
9842 'request-replace-article gnus-newsgroup-name)))
9843 (error "The current group does not support article editing")))
9844 (let ((articles (gnus-summary-work-articles n))
9845 (prefix (if (gnus-check-backend-function
9846 'request-move-article gnus-newsgroup-name)
9847 (funcall gnus-move-group-prefix-function
9848 gnus-newsgroup-name)
9850 (names '((move "Move" "Moving")
9851 (copy "Copy" "Copying")
9852 (crosspost "Crosspost" "Crossposting")))
9853 (copy-buf (save-excursion
9854 (nnheader-set-temp-buffer " *copy article*")))
9855 art-group to-method new-xref article to-groups
9856 articles-to-update-marks encoded)
9857 (unless (assq action names)
9858 (error "Unknown action %s" action))
9859 ;; Read the newsgroup name.
9860 (when (and (not to-newsgroup)
9861 (not select-method))
9862 (if (and gnus-move-split-methods
9864 (and (memq gnus-current-article articles)
9865 (gnus-buffer-live-p gnus-original-article-buffer))))
9866 ;; When `gnus-move-split-methods' is non-nil, we have to
9867 ;; select an article to give `gnus-read-move-group-name' an
9868 ;; opportunity to suggest an appropriate default. However,
9869 ;; we needn't render or mark the article.
9870 (let ((gnus-display-mime-function nil)
9871 (gnus-article-prepare-hook nil)
9872 (gnus-mark-article-hook nil))
9873 (gnus-summary-select-article nil nil nil (car articles))))
9874 (setq to-newsgroup (gnus-read-move-group-name
9875 (cadr (assq action names))
9877 (intern (format "gnus-current-%s-group" action)))
9879 encoded to-newsgroup
9880 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9881 (set (intern (format "gnus-current-%s-group" action))
9882 (mm-decode-coding-string
9884 (gnus-group-name-charset to-method to-newsgroup))))
9886 (setq to-method (or select-method
9887 (gnus-server-to-method
9888 (gnus-group-method to-newsgroup)))))
9892 (mm-encode-coding-string
9894 (gnus-group-name-charset to-method to-newsgroup)))))
9895 ;; Check the method we are to move this article to...
9896 (unless (gnus-check-backend-function
9897 'request-accept-article (car to-method))
9898 (error "%s does not support article copying" (car to-method)))
9899 (unless (gnus-check-server to-method)
9900 (error "Can't open server %s" (car to-method)))
9901 (gnus-message 6 "%s to %s: %s..."
9902 (caddr (assq action names))
9903 (or (car select-method)
9904 (gnus-group-decoded-name to-newsgroup))
9907 (setq article (pop articles))
9908 ;; Set any marks that may have changed in the summary buffer.
9909 (when gnus-preserve-marks
9910 (gnus-summary-push-marks-to-backend article))
9914 ;; Move the article.
9916 ;; Remove this article from future suppression.
9917 (gnus-dup-unsuppress-article article)
9918 (let* ((from-method (gnus-find-method-for-group
9919 gnus-newsgroup-name))
9920 (to-method (or select-method
9921 (gnus-find-method-for-group to-newsgroup)))
9922 (move-is-internal (gnus-server-equal from-method to-method)))
9923 (gnus-request-move-article
9924 article ; Article to move
9925 gnus-newsgroup-name ; From newsgroup
9926 (nth 1 (gnus-find-method-for-group
9927 gnus-newsgroup-name)) ; Server
9928 (list 'gnus-request-accept-article
9929 to-newsgroup (list 'quote select-method)
9930 (not articles) t) ; Accept form
9931 (not articles) ; Only save nov last time
9932 (and move-is-internal
9933 to-newsgroup ; Not respooling
9934 ; Is this move internal?
9935 (gnus-group-real-name to-newsgroup)))))
9936 ;; Copy the article.
9938 (with-current-buffer copy-buf
9939 (when (gnus-request-article-this-buffer article
9940 gnus-newsgroup-name)
9942 (nnheader-narrow-to-headers)
9943 (dolist (hdr gnus-copy-article-ignored-headers)
9944 (message-remove-header hdr t)))
9945 (gnus-request-accept-article
9946 to-newsgroup select-method (not articles) t))))
9947 ;; Crosspost the article.
9948 ((eq action 'crosspost)
9949 (let ((xref (message-tokenize-header
9950 (mail-header-xref (gnus-summary-article-header
9953 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9954 ":" (number-to-string article)))
9956 (setq xref (list (system-name))))
9959 (mapconcat 'identity
9960 (delete "Xref:" (delete new-xref xref))
9963 (with-current-buffer copy-buf
9964 ;; First put the article in the destination group.
9965 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9966 (when (consp (setq art-group
9967 (gnus-request-accept-article
9968 to-newsgroup select-method (not articles)
9970 (setq new-xref (concat new-xref " " (car art-group)
9972 (number-to-string (cdr art-group))))
9973 ;; Now we have the new Xrefs header, so we insert
9974 ;; it and replace the new article.
9975 (nnheader-replace-header "Xref" new-xref)
9976 (gnus-request-replace-article
9977 (cdr art-group) to-newsgroup (current-buffer) t)
9981 (gnus-message 1 "Couldn't %s article %s: %s"
9982 (cadr (assq action names)) article
9983 (nnheader-get-report (car to-method))))
9984 ((eq art-group 'junk)
9985 (when (eq action 'move)
9986 (gnus-summary-mark-article article gnus-canceled-mark)
9987 (gnus-message 4 "Deleted article %s" article)
9988 ;; run the delete hook
9989 (run-hook-with-args 'gnus-summary-article-delete-hook
9992 (assoc article (gnus-data-list nil)))
9993 gnus-newsgroup-name nil
9996 (let* ((pto-group (gnus-group-prefixed-name
9997 (car art-group) to-method))
9998 (info (gnus-get-info pto-group))
9999 (to-group (gnus-info-group info))
10001 ;; Update the group that has been moved to.
10003 (memq action '(move copy)))
10004 (unless (member to-group to-groups)
10005 (push to-group to-groups))
10007 (when (and (not (memq article gnus-newsgroup-unreads))
10009 (push 'read to-marks)
10010 (gnus-info-set-read
10011 info (gnus-add-to-range (gnus-info-read info)
10012 (list (cdr art-group)))))
10014 ;; See whether the article is to be put in the cache.
10015 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10016 (marks (if expirable
10017 gnus-article-mark-lists
10018 (delete '(expirable . expire)
10020 gnus-article-mark-lists))))
10021 (to-article (cdr art-group)))
10023 ;; Enter the article into the cache in the new group,
10024 ;; if that is required.
10025 (when (and to-article
10027 (gnus-cache-possibly-enter-article
10028 to-group to-article
10029 (memq article gnus-newsgroup-marked)
10030 (memq article gnus-newsgroup-dormant)
10031 (memq article gnus-newsgroup-unreads)))
10033 (when (and gnus-preserve-marks
10035 ;; Copy any marks over to the new group.
10036 (when (and (equal to-group gnus-newsgroup-name)
10037 (not (memq article gnus-newsgroup-unreads)))
10038 ;; Mark this article as read in this group.
10039 (push (cons to-article gnus-read-mark)
10040 gnus-newsgroup-reads)
10041 ;; Increase the active status of this group.
10042 (setcdr (gnus-active to-group) to-article)
10043 (setcdr gnus-newsgroup-active to-article))
10046 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10047 (when (memq article (symbol-value
10048 (intern (format "gnus-newsgroup-%s"
10050 (push (cdar marks) to-marks)
10051 ;; If the other group is the same as this group,
10052 ;; then we have to add the mark to the list.
10053 (when (equal to-group gnus-newsgroup-name)
10054 (set (intern (format "gnus-newsgroup-%s"
10058 (intern (format "gnus-newsgroup-%s"
10060 ;; Copy the marks to other group.
10061 (gnus-add-marked-articles
10062 to-group (cdar marks) (list to-article) info)))
10063 (setq marks (cdr marks)))
10065 (when (and expirable
10066 gnus-mark-copied-or-moved-articles-as-expirable
10067 (not (memq 'expire to-marks)))
10068 ;; Mark this article as expirable.
10069 (push 'expire to-marks)
10070 (when (equal to-group gnus-newsgroup-name)
10071 (push to-article gnus-newsgroup-expirable))
10072 ;; Copy the expirable mark to other group.
10073 (gnus-add-marked-articles
10074 to-group 'expire (list to-article) info))
10076 (when (and to-marks
10077 (gnus-method-option-p
10078 (gnus-find-method-for-group to-group)
10080 (gnus-request-set-mark
10081 to-group (list (list (list to-article) 'add to-marks)))))
10083 (gnus-dribble-enter
10084 (concat "(gnus-group-set-info '"
10085 (gnus-prin1-to-string (gnus-get-info to-group))
10087 (concat "^(gnus-group-set-info '(\""
10088 (regexp-quote to-group) "\""))))
10090 ;; Update the Xref header in this article to point to
10091 ;; the new crossposted article we have just created.
10092 (when (eq action 'crosspost)
10093 (with-current-buffer copy-buf
10094 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10095 (nnheader-replace-header "Xref" new-xref)
10096 (gnus-request-replace-article
10097 article gnus-newsgroup-name (current-buffer) t)))
10099 ;; run the move/copy/crosspost/respool hook
10100 (run-hook-with-args 'gnus-summary-article-move-hook
10103 (assoc article (gnus-data-list nil)))
10104 gnus-newsgroup-name
10108 ;;;!!!Why is this necessary?
10109 (set-buffer gnus-summary-buffer)
10111 (when (eq action 'move)
10113 (gnus-summary-goto-subject article)
10114 (gnus-summary-mark-article article gnus-canceled-mark)))))
10115 (push article articles-to-update-marks))
10118 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10119 ;; Re-activate all groups that have been moved to.
10120 (with-current-buffer gnus-group-buffer
10121 (let ((gnus-group-marked to-groups))
10122 (gnus-group-get-new-news-this-group nil t)))
10124 (gnus-kill-buffer copy-buf)
10125 (gnus-summary-position-point)
10126 (gnus-set-mode-line 'summary)))
10128 (defun gnus-summary-push-marks-to-backend (article)
10130 (marks gnus-article-mark-lists))
10131 (unless (memq article gnus-newsgroup-unreads)
10134 (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10135 (memq article (symbol-value
10136 (intern (format "gnus-newsgroup-%s"
10138 (push (cdar marks) set))
10140 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)))))
10142 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10143 "Copy the current article to some other group.
10144 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10145 When called interactively, if TO-NEWSGROUP is nil, use the value of
10146 the variable `gnus-move-split-methods' for finding a default target
10148 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10149 re-spool using this method."
10151 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10153 (defun gnus-summary-crosspost-article (&optional n)
10154 "Crosspost the current article to some other group."
10156 (gnus-summary-move-article n nil nil 'crosspost))
10158 (defcustom gnus-summary-respool-default-method nil
10159 "Default method type for respooling an article.
10160 If nil, use to the current newsgroup method."
10162 :group 'gnus-summary-mail)
10164 (defun gnus-summary-respool-article (&optional n method)
10165 "Respool the current article.
10166 The article will be squeezed through the mail spooling process again,
10167 which means that it will be put in some mail newsgroup or other
10168 depending on `nnmail-split-methods'.
10169 If N is a positive number, respool the N next articles.
10170 If N is a negative number, respool the N previous articles.
10171 If N is nil and any articles have been marked with the process mark,
10172 respool those articles instead.
10174 Respooling can be done both from mail groups and \"real\" newsgroups.
10175 In the former case, the articles in question will be moved from the
10176 current group into whatever groups they are destined to. In the
10177 latter case, they will be copied into the relevant groups."
10179 (list current-prefix-arg
10180 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10182 (symbol-name (or gnus-summary-respool-default-method
10183 (car (gnus-find-method-for-group
10184 gnus-newsgroup-name)))))
10186 (gnus-completing-read
10187 "Backend to use when respooling"
10188 methods t nil 'gnus-mail-method-history methname))
10191 ((zerop (length (setq ms (gnus-servers-using-backend
10192 (intern method)))))
10193 (list (intern method) ""))
10197 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10198 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10201 (error "No method given for respooling"))
10202 (if (assoc (symbol-name
10203 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10204 (gnus-methods-using 'respool))
10205 (gnus-summary-move-article n nil method)
10206 (gnus-summary-copy-article n nil method)))
10208 (defun gnus-summary-import-article (file &optional edit)
10209 "Import an arbitrary file into a mail newsgroup."
10210 (interactive "fImport file: \nP")
10211 (let ((group gnus-newsgroup-name)
10212 (now (current-time))
10213 atts lines group-art)
10214 (unless (gnus-check-backend-function 'request-accept-article group)
10215 (error "%s does not support article importing" group))
10216 (or (file-readable-p file)
10217 (not (file-regular-p file))
10218 (error "Can't read %s" file))
10219 (with-current-buffer (gnus-get-buffer-create " *import file*")
10221 (nnheader-insert-file-contents file)
10222 (goto-char (point-min))
10223 (if (nnheader-article-p)
10225 (goto-char (point-min))
10226 (search-forward "\n\n" nil t)
10227 (narrow-to-region (point-min) (1- (point)))
10228 (goto-char (point-min))
10229 (unless (re-search-forward "^date:" nil t)
10230 (goto-char (point-max))
10231 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10232 ;; This doesn't look like an article, so we fudge some headers.
10233 (setq atts (file-attributes file)
10234 lines (count-lines (point-min) (point-max)))
10235 (insert "From: " (read-string "From: ") "\n"
10236 "Subject: " (read-string "Subject: ") "\n"
10237 "Date: " (message-make-date (nth 5 atts)) "\n"
10238 "Message-ID: " (message-make-message-id) "\n"
10239 "Lines: " (int-to-string lines) "\n"
10240 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10241 (setq group-art (gnus-request-accept-article group nil t))
10242 (kill-buffer (current-buffer)))
10243 (setq gnus-newsgroup-active (gnus-activate-group group))
10245 (gnus-summary-goto-article (cdr group-art) nil t)
10247 (gnus-summary-edit-article))))
10249 (defun gnus-summary-create-article ()
10250 "Create an article in a mail newsgroup."
10252 (let ((group gnus-newsgroup-name)
10253 (now (current-time))
10255 (unless (gnus-check-backend-function 'request-accept-article group)
10256 (error "%s does not support article importing" group))
10257 (with-current-buffer (gnus-get-buffer-create " *import file*")
10259 (goto-char (point-min))
10260 ;; This doesn't look like an article, so we fudge some headers.
10261 (insert "From: " (read-string "From: ") "\n"
10262 "Subject: " (read-string "Subject: ") "\n"
10263 "Date: " (message-make-date now) "\n"
10264 "Message-ID: " (message-make-message-id) "\n")
10265 (setq group-art (gnus-request-accept-article group nil t))
10266 (kill-buffer (current-buffer)))
10267 (setq gnus-newsgroup-active (gnus-activate-group group))
10269 (gnus-summary-goto-article (cdr group-art) nil t)
10270 (gnus-summary-edit-article)))
10272 (defun gnus-summary-article-posted-p ()
10273 "Say whether the current (mail) article is available from news as well.
10274 This will be the case if the article has both been mailed and posted."
10276 (let ((id (mail-header-references (gnus-summary-article-header)))
10277 (gnus-override-method (car (gnus-refer-article-methods))))
10278 (if (gnus-request-head id "")
10279 (gnus-message 2 "The current message was found on %s"
10280 gnus-override-method)
10281 (gnus-message 2 "The current message couldn't be found on %s"
10282 gnus-override-method)
10285 (defun gnus-summary-expire-articles (&optional now)
10286 "Expire all articles that are marked as expirable in the current group."
10288 (when (and (not gnus-group-is-exiting-without-update-p)
10289 (gnus-check-backend-function
10290 'request-expire-articles gnus-newsgroup-name))
10291 ;; This backend supports expiry.
10292 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10293 (expirable (if total
10295 ;; We need to update the info for
10296 ;; this group for `gnus-list-of-read-articles'
10297 ;; to give us the right answer.
10298 (gnus-run-hooks 'gnus-exit-group-hook)
10299 (gnus-summary-update-info)
10300 (gnus-list-of-read-articles gnus-newsgroup-name))
10301 (setq gnus-newsgroup-expirable
10302 (sort gnus-newsgroup-expirable '<))))
10303 (expiry-wait (if now 'immediate
10304 (gnus-group-find-parameter
10305 gnus-newsgroup-name 'expiry-wait)))
10306 (nnmail-expiry-target
10307 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10308 nnmail-expiry-target))
10311 ;; There are expirable articles in this group, so we run them
10312 ;; through the expiry process.
10313 (gnus-message 6 "Expiring articles...")
10314 (when (gnus-check-group gnus-newsgroup-name)
10315 ;; The list of articles that weren't expired is returned.
10318 (let ((nnmail-expiry-wait-function nil)
10319 (nnmail-expiry-wait expiry-wait))
10320 (setq es (gnus-request-expire-articles
10321 expirable gnus-newsgroup-name)))
10322 (setq es (gnus-request-expire-articles
10323 expirable gnus-newsgroup-name)))
10325 (setq gnus-newsgroup-expirable es))
10326 ;; We go through the old list of expirable, and mark all
10327 ;; really expired articles as nonexistent.
10328 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10329 (let ((gnus-use-cache nil))
10330 (dolist (article expirable)
10331 (when (and (not (memq article es))
10332 (gnus-data-find article))
10333 (gnus-summary-mark-article article gnus-canceled-mark)
10334 (run-hook-with-args 'gnus-summary-article-expire-hook
10337 (assoc article (gnus-data-list nil)))
10338 gnus-newsgroup-name
10341 (gnus-message 6 "Expiring articles...done")))))
10343 (defun gnus-summary-expire-articles-now ()
10344 "Expunge all expirable articles in the current group.
10345 This means that *all* articles that are marked as expirable will be
10346 deleted forever, right now."
10348 (or gnus-expert-user
10350 "Are you really, really sure you want to delete all expirable messages? ")
10352 (gnus-summary-expire-articles t))
10354 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10355 (defun gnus-summary-delete-article (&optional n)
10356 "Delete the N next (mail) articles.
10357 This command actually deletes articles. This is not a marking
10358 command. The article will disappear forever from your life, never to
10361 If N is negative, delete backwards.
10362 If N is nil and articles have been marked with the process mark,
10363 delete these instead.
10365 If `gnus-novice-user' is non-nil you will be asked for
10366 confirmation before the articles are deleted."
10368 (unless (gnus-check-backend-function 'request-expire-articles
10369 gnus-newsgroup-name)
10370 (error "The current newsgroup does not support article deletion"))
10371 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10372 (error "Couldn't open server"))
10373 ;; Compute the list of articles to delete.
10374 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10375 (nnmail-expiry-target 'delete)
10377 (if (and gnus-novice-user
10378 (not (gnus-yes-or-no-p
10379 (format "Do you really want to delete %s forever? "
10380 (if (> (length articles) 1)
10381 (format "these %s articles" (length articles))
10382 "this article")))))
10384 ;; Delete the articles.
10385 (setq not-deleted (gnus-request-expire-articles
10386 articles gnus-newsgroup-name 'force))
10389 (gnus-summary-remove-process-mark (car articles))
10390 ;; The backend might not have been able to delete the article
10392 (unless (memq (car articles) not-deleted)
10393 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10394 (let* ((article (car articles))
10395 (ghead (gnus-data-header
10396 (assoc article (gnus-data-list nil)))))
10397 (run-hook-with-args 'gnus-summary-article-delete-hook
10398 'delete ghead gnus-newsgroup-name nil
10400 (setq articles (cdr articles))))
10402 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10403 (gnus-summary-position-point)
10404 (gnus-set-mode-line 'summary)
10407 (defun gnus-summary-edit-article (&optional arg)
10408 "Edit the current article.
10409 This will have permanent effect only in mail groups.
10410 If ARG is nil, edit the decoded articles.
10411 If ARG is 1, edit the raw articles.
10412 If ARG is 2, edit the raw articles even in read-only groups.
10413 If ARG is 3, edit the articles with the current handles.
10414 Otherwise, allow editing of articles even in read-only
10417 (let (force raw current-handles)
10426 (setq current-handles
10427 (and (gnus-buffer-live-p gnus-article-buffer)
10428 (with-current-buffer gnus-article-buffer
10430 gnus-article-mime-handles
10431 (setq gnus-article-mime-handles nil))))))
10434 (when (and raw (not force)
10435 (member gnus-newsgroup-name '("nndraft:delayed"
10438 (error "Can't edit the raw article in group %s"
10439 gnus-newsgroup-name))
10440 (with-current-buffer gnus-summary-buffer
10441 (let ((mail-parse-charset gnus-newsgroup-charset)
10442 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10443 (gnus-set-global-variables)
10444 (when (and (not force)
10445 (gnus-group-read-only-p))
10446 (error "The current newsgroup does not support article editing"))
10447 (gnus-summary-show-article t)
10448 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10449 (with-current-buffer gnus-article-buffer
10450 (mm-enable-multibyte)))
10451 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10453 (gnus-article-edit-article
10456 (let ((mbl mml-buffer-list))
10457 (setq mml-buffer-list nil)
10458 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10459 (mime-to-mml ,'current-handles))
10460 (let ((mbl1 mml-buffer-list))
10461 (setq mml-buffer-list mbl)
10462 (set (make-local-variable 'mml-buffer-list) mbl1))
10463 (gnus-make-local-hook 'kill-buffer-hook)
10464 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10465 `(lambda (no-highlight)
10466 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10467 (message-options message-options)
10468 (message-options-set-recipient)
10469 (mail-parse-ignored-charsets
10470 ',gnus-newsgroup-ignored-charsets)
10471 (rfc2047-header-encoding-alist
10472 ',(let ((charset (gnus-group-name-charset
10473 (gnus-find-method-for-group
10474 gnus-newsgroup-name)
10475 gnus-newsgroup-name)))
10476 (append (list (cons "Newsgroups" charset)
10477 (cons "Followup-To" charset)
10478 (cons "Xref" charset))
10479 rfc2047-header-encoding-alist))))
10480 ,(if (not raw) '(progn
10482 (mml-destroy-buffers)
10483 (remove-hook 'kill-buffer-hook
10484 'mml-destroy-buffers t)
10485 (kill-local-variable 'mml-buffer-list)))
10486 (gnus-summary-edit-article-done
10487 ,(or (mail-header-references gnus-current-headers) "")
10488 ,(gnus-group-read-only-p)
10489 ,gnus-summary-buffer no-highlight))))))))
10491 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10493 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10495 "Make edits to the current article permanent."
10498 ;; The buffer restriction contains the entire article if it exists.
10499 (when (article-goto-body)
10500 (let ((lines (count-lines (point) (point-max)))
10501 (length (- (point-max) (point)))
10502 (case-fold-search t)
10503 (body (copy-marker (point))))
10504 (goto-char (point-min))
10505 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10506 (delete-region (match-beginning 1) (match-end 1))
10507 (insert (number-to-string length)))
10508 (goto-char (point-min))
10509 (when (re-search-forward
10510 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10511 (delete-region (match-beginning 1) (match-end 1))
10512 (insert (number-to-string length)))
10513 (goto-char (point-min))
10514 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10515 (delete-region (match-beginning 1) (match-end 1))
10516 (insert (number-to-string lines))))))
10517 ;; Replace the article.
10518 (let ((buf (current-buffer))
10519 (article (cdr gnus-article-current))
10522 (insert-buffer-substring buf)
10523 (if (and (not read-only)
10524 (not (setq replace-result
10525 (gnus-request-replace-article
10526 article (car gnus-article-current)
10527 (current-buffer) t))))
10528 (error "Couldn't replace article")
10529 ;; If we got a number back, then that's the new article number
10530 ;; for this article. Otherwise, the article number didn't change.
10531 (when (numberp replace-result)
10532 (with-current-buffer gnus-summary-buffer
10533 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10534 (gnus-summary-limit gnus-newsgroup-limit)
10535 (setq article replace-result)
10536 (gnus-summary-goto-subject article t)))
10537 ;; Update the summary buffer.
10538 (if (and references
10539 (equal (message-tokenize-header references " ")
10540 (message-tokenize-header
10541 (or (message-fetch-field "references") "") " ")))
10542 ;; We only have to update this line.
10545 (message-narrow-to-head)
10546 (let ((head (buffer-substring-no-properties
10547 (point-min) (point-max)))
10550 (insert (format "211 %d Article retrieved.\n" article))
10553 (let ((nntp-server-buffer (current-buffer)))
10554 (setq header (car (gnus-get-newsgroup-headers nil t))))
10555 (with-current-buffer gnus-summary-buffer
10556 (gnus-data-set-header (gnus-data-find article) header)
10557 (gnus-summary-update-article-line article header)
10558 (if (gnus-summary-goto-subject article nil t)
10559 (gnus-summary-update-secondary-mark article)))))))
10561 (set-buffer (or buffer gnus-summary-buffer))
10562 (gnus-summary-update-article article)
10563 (if (gnus-summary-goto-subject article nil t)
10564 (gnus-summary-update-secondary-mark article)))
10565 ;; Prettify the article buffer again.
10566 (unless no-highlight
10567 (with-current-buffer gnus-article-buffer
10568 ;;!!! Fix this -- article should be rehighlighted.
10569 ;;(gnus-run-hooks 'gnus-article-display-hook)
10570 (set-buffer gnus-original-article-buffer)
10571 (gnus-request-article
10572 article (car gnus-article-current) (current-buffer))))
10573 ;; Prettify the summary buffer line.
10574 (when (gnus-visual-p 'summary-highlight 'highlight)
10575 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10577 (defun gnus-summary-edit-wash (key)
10578 "Perform editing command KEY in the article buffer."
10582 (message "%s" (concat (this-command-keys) "- "))
10585 (gnus-summary-edit-article)
10586 (execute-kbd-macro (concat (this-command-keys) key))
10587 (gnus-article-edit-done))
10591 (defun gnus-summary-respool-query (&optional silent trace)
10592 "Query where the respool algorithm would put this article."
10594 (let (gnus-mark-article-hook)
10595 (gnus-summary-select-article)
10596 (with-current-buffer gnus-original-article-buffer
10597 (let ((groups (nnmail-article-group 'identity trace)))
10600 (message "This message would go to %s"
10601 (mapconcat 'car groups ", "))
10602 (message "This message would go to no groups"))
10605 (defun gnus-summary-respool-trace ()
10606 "Trace where the respool algorithm would put this article.
10607 Display a buffer showing all fancy splitting patterns which matched."
10609 (gnus-summary-respool-query nil t))
10611 ;; Summary marking commands.
10613 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10614 "Mark articles which has the same subject as read, and then select the next.
10615 If UNMARK is positive, remove any kind of mark.
10616 If UNMARK is negative, tick articles."
10619 (setq unmark (prefix-numeric-value unmark)))
10621 (gnus-summary-mark-same-subject
10622 (gnus-summary-article-subject) unmark)))
10623 ;; Select next unread article. If auto-select-same mode, should
10624 ;; select the first unread article.
10625 (gnus-summary-next-article t (and gnus-auto-select-same
10626 (gnus-summary-article-subject)))
10627 (gnus-message 7 "%d article%s marked as %s"
10628 count (if (= count 1) " is" "s are")
10629 (if unmark "unread" "read"))))
10631 (defun gnus-summary-kill-same-subject (&optional unmark)
10632 "Mark articles which has the same subject as read.
10633 If UNMARK is positive, remove any kind of mark.
10634 If UNMARK is negative, tick articles."
10637 (setq unmark (prefix-numeric-value unmark)))
10639 (gnus-summary-mark-same-subject
10640 (gnus-summary-article-subject) unmark)))
10641 ;; If marked as read, go to next unread subject.
10642 (when (null unmark)
10643 ;; Go to next unread subject.
10644 (gnus-summary-next-subject 1 t))
10645 (gnus-message 7 "%d articles are marked as %s"
10646 count (if unmark "unread" "read"))))
10648 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10649 "Mark articles with same SUBJECT as read, and return marked number.
10650 If optional argument UNMARK is positive, remove any kinds of marks.
10651 If optional argument UNMARK is negative, mark articles as unread instead."
10655 ((null unmark) ; Mark as read.
10658 (gnus-summary-mark-article-as-read gnus-killed-mark)
10659 (gnus-summary-show-thread) t)
10660 (gnus-summary-find-subject subject))
10661 (setq count (1+ count))))
10662 ((> unmark 0) ; Tick.
10665 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10666 (gnus-summary-show-thread) t)
10667 (gnus-summary-find-subject subject))
10668 (setq count (1+ count))))
10669 (t ; Mark as unread.
10672 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10673 (gnus-summary-show-thread) t)
10674 (gnus-summary-find-subject subject))
10675 (setq count (1+ count)))))
10676 (gnus-set-mode-line 'summary)
10677 ;; Return the number of marked articles.
10680 (defun gnus-summary-mark-as-processable (n &optional unmark)
10681 "Set the process mark on the next N articles.
10682 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10683 the process mark instead. The difference between N and the actual
10684 number of articles marked is returned."
10686 (if (and (null n) (gnus-region-active-p))
10687 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10688 (setq n (prefix-numeric-value n))
10689 (let ((backward (< n 0))
10694 (gnus-summary-remove-process-mark
10695 (gnus-summary-article-number))
10696 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10697 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10700 (gnus-message 7 "No more articles"))
10701 (gnus-summary-recenter)
10702 (gnus-summary-position-point)
10705 (defun gnus-summary-unmark-as-processable (n)
10706 "Remove the process mark from the next N articles.
10707 If N is negative, unmark backward instead. The difference between N and
10708 the actual number of articles unmarked is returned."
10710 (gnus-summary-mark-as-processable n t))
10712 (defun gnus-summary-unmark-all-processable ()
10713 "Remove the process mark from all articles."
10716 (while gnus-newsgroup-processable
10717 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10718 (gnus-summary-position-point))
10720 (defun gnus-summary-add-mark (article type)
10721 "Mark ARTICLE with a mark of TYPE."
10722 (let ((vtype (car (assq type gnus-article-mark-lists)))
10725 (error "No such mark type: %s" type)
10726 (setq var (intern (format "gnus-newsgroup-%s" type)))
10727 (set var (cons article (symbol-value var)))
10728 (if (memq type '(processable cached replied forwarded recent saved))
10729 (gnus-summary-update-secondary-mark article)
10730 ;;; !!! This is bogus. We should find out what primary
10731 ;;; !!! mark we want to set.
10732 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10734 (defun gnus-summary-mark-as-expirable (n)
10735 "Mark N articles forward as expirable.
10736 If N is negative, mark backward instead. The difference between N and
10737 the actual number of articles marked is returned."
10739 (gnus-summary-mark-forward n gnus-expirable-mark))
10741 (defun gnus-summary-mark-as-spam (n)
10742 "Mark N articles forward as spam.
10743 If N is negative, mark backward instead. The difference between N and
10744 the actual number of articles marked is returned."
10746 (gnus-summary-mark-forward n gnus-spam-mark))
10748 (defun gnus-summary-mark-article-as-replied (article)
10749 "Mark ARTICLE as replied to and update the summary line.
10750 ARTICLE can also be a list of articles."
10751 (interactive (list (gnus-summary-article-number)))
10752 (let ((articles (if (listp article) article (list article))))
10753 (dolist (article articles)
10754 (unless (numberp article)
10755 (error "%s is not a number" article))
10756 (push article gnus-newsgroup-replied)
10757 (let ((inhibit-read-only t))
10758 (when (gnus-summary-goto-subject article nil t)
10759 (gnus-summary-update-secondary-mark article))))))
10761 (defun gnus-summary-mark-article-as-forwarded (article)
10762 "Mark ARTICLE as forwarded and update the summary line.
10763 ARTICLE can also be a list of articles."
10764 (let ((articles (if (listp article) article (list article))))
10765 (dolist (article articles)
10766 (push article gnus-newsgroup-forwarded)
10767 (let ((inhibit-read-only t))
10768 (when (gnus-summary-goto-subject article nil t)
10769 (gnus-summary-update-secondary-mark article))))))
10771 (defun gnus-summary-set-bookmark (article)
10772 "Set a bookmark in current article."
10773 (interactive (list (gnus-summary-article-number)))
10774 (when (or (not (get-buffer gnus-article-buffer))
10775 (not gnus-current-article)
10776 (not gnus-article-current)
10777 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10778 (error "No current article selected"))
10779 ;; Remove old bookmark, if one exists.
10780 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10781 ;; Set the new bookmark, which is on the form
10782 ;; (article-number . line-number-in-body).
10785 (with-current-buffer gnus-article-buffer
10789 (article-goto-body)
10792 gnus-newsgroup-bookmarks)
10793 (gnus-message 6 "A bookmark has been added to the current article."))
10795 (defun gnus-summary-remove-bookmark (article)
10796 "Remove the bookmark from the current article."
10797 (interactive (list (gnus-summary-article-number)))
10798 ;; Remove old bookmark, if one exists.
10799 (if (not (assq article gnus-newsgroup-bookmarks))
10800 (gnus-message 6 "No bookmark in current article.")
10801 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10802 (gnus-message 6 "Removed bookmark.")))
10804 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10805 (defun gnus-summary-mark-as-dormant (n)
10806 "Mark N articles forward as dormant.
10807 If N is negative, mark backward instead. The difference between N and
10808 the actual number of articles marked is returned."
10810 (gnus-summary-mark-forward n gnus-dormant-mark))
10812 (defun gnus-summary-set-process-mark (article)
10813 "Set the process mark on ARTICLE and update the summary line."
10814 (setq gnus-newsgroup-processable
10816 (delq article gnus-newsgroup-processable)))
10817 (when (gnus-summary-goto-subject article)
10818 (gnus-summary-show-thread)
10819 (gnus-summary-goto-subject article)
10820 (gnus-summary-update-secondary-mark article)))
10822 (defun gnus-summary-remove-process-mark (&rest articles)
10823 "Remove the process mark from ARTICLES and update the summary line."
10824 (dolist (article articles)
10825 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10826 (when (gnus-summary-goto-subject article)
10827 (gnus-summary-show-thread)
10828 (gnus-summary-goto-subject article)
10829 (gnus-summary-update-secondary-mark article)))
10832 (defun gnus-summary-set-saved-mark (article)
10833 "Set the process mark on ARTICLE and update the summary line."
10834 (push article gnus-newsgroup-saved)
10835 (when (gnus-summary-goto-subject article)
10836 (gnus-summary-update-secondary-mark article)))
10838 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10839 "Mark N articles as read forwards.
10840 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10841 The difference between N and the actual number of articles marked is
10843 If NO-EXPIRE, auto-expiry will be inhibited."
10845 (gnus-summary-show-thread)
10846 (let ((backward (< n 0))
10847 (gnus-summary-goto-unread
10848 (and gnus-summary-goto-unread
10849 (not (eq gnus-summary-goto-unread 'never))
10850 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10851 gnus-ticked-mark gnus-dormant-mark)))))
10853 (mark (or mark gnus-del-mark)))
10854 (while (and (> n 0)
10855 (gnus-summary-mark-article nil mark no-expire)
10856 (zerop (gnus-summary-next-subject
10858 (and gnus-summary-goto-unread
10859 (not (eq gnus-summary-goto-unread 'never)))
10863 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10864 (gnus-summary-recenter)
10865 (gnus-summary-position-point)
10866 (gnus-set-mode-line 'summary)
10869 (defun gnus-summary-mark-article-as-read (mark)
10870 "Mark the current article quickly as read with MARK."
10871 (let ((article (gnus-summary-article-number)))
10872 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10873 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10874 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10875 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10876 (push (cons article mark) gnus-newsgroup-reads)
10877 ;; Possibly remove from cache, if that is used.
10878 (when gnus-use-cache
10879 (gnus-cache-enter-remove-article article))
10880 ;; Allow the backend to change the mark.
10881 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10882 ;; Check for auto-expiry.
10883 (when (and gnus-newsgroup-auto-expire
10884 (memq mark gnus-auto-expirable-marks))
10885 (setq mark gnus-expirable-mark)
10886 ;; Let the backend know about the mark change.
10887 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10888 (push article gnus-newsgroup-expirable))
10889 ;; Set the mark in the buffer.
10890 (gnus-summary-update-mark mark 'unread)
10893 (defun gnus-summary-mark-article-as-unread (mark)
10894 "Mark the current article quickly as unread with MARK."
10895 (let* ((article (gnus-summary-article-number))
10896 (old-mark (gnus-summary-article-mark article)))
10897 ;; Allow the backend to change the mark.
10898 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10899 (if (eq mark old-mark)
10903 (gnus-error 1 "Can't mark negative article numbers")
10905 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10906 (setq gnus-newsgroup-spam-marked
10907 (delq article gnus-newsgroup-spam-marked))
10908 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10909 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10910 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10911 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10912 (cond ((= mark gnus-ticked-mark)
10913 (setq gnus-newsgroup-marked
10914 (gnus-add-to-sorted-list gnus-newsgroup-marked
10916 ((= mark gnus-spam-mark)
10917 (setq gnus-newsgroup-spam-marked
10918 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10920 ((= mark gnus-dormant-mark)
10921 (setq gnus-newsgroup-dormant
10922 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10925 (setq gnus-newsgroup-unreads
10926 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10928 (gnus-alist-pull article gnus-newsgroup-reads)
10930 ;; See whether the article is to be put in the cache.
10931 (and gnus-use-cache
10932 (vectorp (gnus-summary-article-header article))
10934 (gnus-cache-possibly-enter-article
10935 gnus-newsgroup-name article
10936 (= mark gnus-ticked-mark)
10937 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10940 (gnus-summary-update-mark mark 'unread)
10943 (defun gnus-summary-mark-article (&optional article mark no-expire)
10944 "Mark ARTICLE with MARK. MARK can be any character.
10945 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10946 `??' (dormant) and `?E' (expirable).
10947 If MARK is nil, then the default character `?r' is used.
10948 If ARTICLE is nil, then the article on the current line will be
10950 If NO-EXPIRE, auto-expiry will be inhibited."
10951 ;; The mark might be a string.
10952 (when (stringp mark)
10953 (setq mark (aref mark 0)))
10954 ;; If no mark is given, then we check auto-expiring.
10956 (setq mark gnus-del-mark))
10957 (when (and (not no-expire)
10958 gnus-newsgroup-auto-expire
10959 (memq mark gnus-auto-expirable-marks))
10960 (setq mark gnus-expirable-mark))
10961 (let ((article (or article (gnus-summary-article-number)))
10962 (old-mark (gnus-summary-article-mark article)))
10963 ;; Allow the backend to change the mark.
10964 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10965 (if (eq mark old-mark)
10968 (error "No article on current line"))
10969 (if (not (if (or (= mark gnus-unread-mark)
10970 (= mark gnus-ticked-mark)
10971 (= mark gnus-spam-mark)
10972 (= mark gnus-dormant-mark))
10973 (gnus-mark-article-as-unread article mark)
10974 (gnus-mark-article-as-read article mark)))
10976 ;; See whether the article is to be put in the cache.
10977 (and gnus-use-cache
10978 (not (= mark gnus-canceled-mark))
10979 (vectorp (gnus-summary-article-header article))
10981 (gnus-cache-possibly-enter-article
10982 gnus-newsgroup-name article
10983 (= mark gnus-ticked-mark)
10984 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10986 (when (gnus-summary-goto-subject article nil t)
10987 (let ((inhibit-read-only t))
10988 (gnus-summary-show-thread)
10990 (gnus-summary-update-mark mark 'unread)
10993 (defun gnus-summary-update-secondary-mark (article)
10994 "Update the secondary (read, process, cache) mark."
10995 (gnus-summary-update-mark
10996 (cond ((memq article gnus-newsgroup-processable)
10998 ((memq article gnus-newsgroup-cached)
11000 ((memq article gnus-newsgroup-replied)
11002 ((memq article gnus-newsgroup-forwarded)
11003 gnus-forwarded-mark)
11004 ((memq article gnus-newsgroup-saved)
11006 ((memq article gnus-newsgroup-unseen)
11010 (when (gnus-visual-p 'summary-highlight 'highlight)
11011 (gnus-summary-highlight-line)
11012 (gnus-run-hooks 'gnus-summary-update-hook))
11015 (defun gnus-summary-update-download-mark (article)
11016 "Update the download mark."
11017 (gnus-summary-update-mark
11018 (cond ((memq article gnus-newsgroup-undownloaded)
11019 gnus-undownloaded-mark)
11020 (gnus-newsgroup-agentized
11021 gnus-downloaded-mark)
11025 (gnus-summary-update-line t)
11028 (defun gnus-summary-update-mark (mark type)
11029 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11030 (inhibit-read-only t))
11031 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11033 (when (looking-at "\r")
11035 (when (<= (+ forward (point)) (point-max))
11036 ;; Go to the right position on the line.
11037 (goto-char (+ forward (point)))
11038 ;; Replace the old mark with the new mark.
11040 (mm-subst-char-in-string
11042 (buffer-substring (point) (1+ (point))))))
11043 (delete-region (point) (1+ (point)))
11044 (insert to-insert))
11045 ;; Optionally update the marks by some user rule.
11046 (when (eq type 'unread)
11047 (gnus-data-set-mark
11048 (gnus-data-find (gnus-summary-article-number)) mark)
11049 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11051 (defun gnus-mark-article-as-read (article &optional mark)
11052 "Enter ARTICLE in the pertinent lists and remove it from others."
11053 ;; Make the article expirable.
11054 (let ((mark (or mark gnus-del-mark)))
11055 (setq gnus-newsgroup-expirable
11056 (if (= mark gnus-expirable-mark)
11057 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11058 (delq article gnus-newsgroup-expirable)))
11059 ;; Remove from unread and marked lists.
11060 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11061 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11062 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11063 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11064 (push (cons article mark) gnus-newsgroup-reads)
11065 ;; Possibly remove from cache, if that is used.
11066 (when gnus-use-cache
11067 (gnus-cache-enter-remove-article article))
11070 (defun gnus-mark-article-as-unread (article &optional mark)
11071 "Enter ARTICLE in the pertinent lists and remove it from others."
11072 (let ((mark (or mark gnus-ticked-mark)))
11075 (gnus-error 1 "Can't mark negative article numbers")
11077 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11078 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11079 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11080 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11081 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11083 ;; Unsuppress duplicates?
11084 (when gnus-suppress-duplicates
11085 (gnus-dup-unsuppress-article article))
11087 (cond ((= mark gnus-ticked-mark)
11088 (setq gnus-newsgroup-marked
11089 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11090 ((= mark gnus-spam-mark)
11091 (setq gnus-newsgroup-spam-marked
11092 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11094 ((= mark gnus-dormant-mark)
11095 (setq gnus-newsgroup-dormant
11096 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11098 (setq gnus-newsgroup-unreads
11099 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11100 (gnus-alist-pull article gnus-newsgroup-reads)
11103 (defun gnus-summary-tick-article-forward (n)
11104 "Tick N articles forwards.
11105 If N is negative, tick backwards instead.
11106 The difference between N and the number of articles ticked is returned."
11108 (gnus-summary-mark-forward n gnus-ticked-mark))
11110 (defun gnus-summary-tick-article-backward (n)
11111 "Tick N articles backwards.
11112 The difference between N and the number of articles ticked is returned."
11114 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11116 (defun gnus-summary-tick-article (&optional article clear-mark)
11117 "Mark current article as unread.
11118 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11119 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11121 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11122 gnus-ticked-mark)))
11124 (defun gnus-summary-mark-as-read-forward (n)
11125 "Mark N articles as read forwards.
11126 If N is negative, mark backwards instead.
11127 The difference between N and the actual number of articles marked is
11130 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11132 (defun gnus-summary-mark-as-read-backward (n)
11133 "Mark the N articles as read backwards.
11134 The difference between N and the actual number of articles marked is
11137 (gnus-summary-mark-forward
11138 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11140 (defun gnus-summary-mark-as-read (&optional article mark)
11141 "Mark current article as read.
11142 ARTICLE specifies the article to be marked as read.
11143 MARK specifies a string to be inserted at the beginning of the line."
11144 (gnus-summary-mark-article article mark))
11146 (defun gnus-summary-clear-mark-forward (n)
11147 "Clear marks from N articles forward.
11148 If N is negative, clear backward instead.
11149 The difference between N and the number of marks cleared is returned."
11151 (gnus-summary-mark-forward n gnus-unread-mark))
11153 (defun gnus-summary-clear-mark-backward (n)
11154 "Clear marks from N articles backward.
11155 The difference between N and the number of marks cleared is returned."
11157 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11159 (defun gnus-summary-mark-unread-as-read ()
11160 "Intended to be used by `gnus-mark-article-hook'."
11161 (when (memq gnus-current-article gnus-newsgroup-unreads)
11162 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11164 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11165 "Intended to be used by `gnus-mark-article-hook'."
11166 (let ((mark (gnus-summary-article-mark)))
11167 (when (or (gnus-unread-mark-p mark)
11168 (gnus-read-mark-p mark))
11169 (gnus-summary-mark-article gnus-current-article
11170 (or new-mark gnus-read-mark)))))
11172 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11173 "Intended to be used by `gnus-mark-article-hook'."
11174 (let ((mark (gnus-summary-article-mark)))
11175 (when (or (gnus-unread-mark-p mark)
11176 (gnus-read-mark-p mark))
11177 (gnus-summary-mark-article (gnus-summary-article-number)
11178 (or new-mark gnus-read-mark)))))
11180 (defun gnus-summary-mark-unread-as-ticked ()
11181 "Intended to be used by `gnus-mark-article-hook'."
11182 (when (memq gnus-current-article gnus-newsgroup-unreads)
11183 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11185 (defun gnus-summary-mark-region-as-read (point mark all)
11186 "Mark all unread articles between point and mark as read.
11187 If given a prefix, mark all articles between point and mark as read,
11188 even ticked and dormant ones."
11189 (interactive "r\nP")
11193 (beginning-of-line)
11198 (memq (setq article (gnus-summary-article-number))
11199 gnus-newsgroup-unreads))
11200 (gnus-summary-mark-article article gnus-del-mark))
11202 (gnus-summary-find-next))))))
11204 (defun gnus-summary-mark-below (score mark)
11205 "Mark articles with score less than SCORE with MARK."
11206 (interactive "P\ncMark: ")
11207 (setq score (if score
11208 (prefix-numeric-value score)
11209 (or gnus-summary-default-score 0)))
11210 (with-current-buffer gnus-summary-buffer
11211 (goto-char (point-min))
11214 (and (< (gnus-summary-article-score) score)
11215 (gnus-summary-mark-article nil mark))
11216 (gnus-summary-find-next)))))
11218 (defun gnus-summary-kill-below (&optional score)
11219 "Mark articles with score below SCORE as read."
11221 (gnus-summary-mark-below score gnus-killed-mark))
11223 (defun gnus-summary-clear-above (&optional score)
11224 "Clear all marks from articles with score above SCORE."
11226 (gnus-summary-mark-above score gnus-unread-mark))
11228 (defun gnus-summary-tick-above (&optional score)
11229 "Tick all articles with score above SCORE."
11231 (gnus-summary-mark-above score gnus-ticked-mark))
11233 (defun gnus-summary-mark-above (score mark)
11234 "Mark articles with score over SCORE with MARK."
11235 (interactive "P\ncMark: ")
11236 (setq score (if score
11237 (prefix-numeric-value score)
11238 (or gnus-summary-default-score 0)))
11239 (with-current-buffer gnus-summary-buffer
11240 (goto-char (point-min))
11242 (when (> (gnus-summary-article-score) score)
11243 (gnus-summary-mark-article nil mark))
11245 (gnus-summary-find-next)))))
11247 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11248 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11249 (defun gnus-summary-limit-include-expunged (&optional no-error)
11250 "Display all the hidden articles that were expunged for low scores."
11252 (let ((inhibit-read-only t))
11253 (let ((scored gnus-newsgroup-scored)
11256 (unless (gnus-summary-article-header (caar scored))
11257 (and (setq h (gnus-number-to-header (caar scored)))
11258 (< (cdar scored) gnus-summary-expunge-below)
11260 (setq scored (cdr scored)))
11262 (when (not no-error)
11263 (error "No expunged articles hidden"))
11264 (goto-char (point-min))
11265 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11266 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11267 (dolist (x headers)
11268 (push (mail-header-number x) gnus-newsgroup-limit))
11269 (gnus-summary-prepare-unthreaded (nreverse headers))
11270 (goto-char (point-min))
11271 (gnus-summary-position-point)
11274 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11275 "Mark all unread articles in this newsgroup as read.
11276 If prefix argument ALL is non-nil, ticked and dormant articles will
11277 also be marked as read.
11278 If QUIETLY is non-nil, no questions will be asked.
11280 If TO-HERE is non-nil, it should be a point in the buffer. All
11281 articles before (after, if REVERSE is set) this point will be marked
11284 Note that this function will only catch up the unread article
11285 in the current summary buffer limitation.
11287 The number of articles marked as read is returned."
11292 (not gnus-interactive-catchup) ;Without confirmation?
11296 "Mark absolutely all articles as read? "
11297 "Mark all unread articles as read? ")))
11299 (not gnus-newsgroup-adaptive)
11300 (not gnus-newsgroup-auto-expire)
11301 (not gnus-suppress-duplicates)
11302 (or (not gnus-use-cache)
11303 (eq gnus-use-cache 'passive)))
11306 (setq gnus-newsgroup-marked nil
11307 gnus-newsgroup-spam-marked nil
11308 gnus-newsgroup-dormant nil))
11309 (setq gnus-newsgroup-unreads
11310 (gnus-sorted-nunion
11311 (gnus-sorted-intersection gnus-newsgroup-unreads
11312 gnus-newsgroup-downloadable)
11313 (gnus-sorted-difference gnus-newsgroup-unfetched
11314 gnus-newsgroup-cached))))
11315 ;; We actually mark all articles as canceled, which we
11316 ;; have to do when using auto-expiry or adaptive scoring.
11317 (gnus-summary-show-all-threads)
11318 (if (and to-here reverse)
11320 (goto-char to-here)
11321 (gnus-summary-mark-current-read-and-unread-as-read
11323 (while (gnus-summary-find-next (not all))
11324 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11325 (when (gnus-summary-first-subject (not all))
11327 (if to-here (< (point) to-here) t)
11328 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11329 (gnus-summary-find-next (not all))))))
11330 (gnus-set-mode-line 'summary))
11332 (gnus-summary-position-point)))
11334 (defun gnus-summary-catchup-to-here (&optional all)
11335 "Mark all unticked articles before the current one as read.
11336 If ALL is non-nil, also mark ticked and dormant articles as read."
11339 (gnus-save-hidden-threads
11340 (let ((beg (point)))
11341 ;; We check that there are unread articles.
11342 (when (or all (gnus-summary-find-prev))
11343 (gnus-summary-catchup all t beg)))))
11344 (gnus-summary-position-point))
11346 (defun gnus-summary-catchup-from-here (&optional all)
11347 "Mark all unticked articles after (and including) the current one as read.
11348 If ALL is non-nil, also mark ticked and dormant articles as read."
11351 (gnus-save-hidden-threads
11352 (let ((beg (point)))
11353 ;; We check that there are unread articles.
11354 (when (or all (gnus-summary-find-next))
11355 (gnus-summary-catchup all t beg nil t)))))
11356 (gnus-summary-position-point))
11358 (defun gnus-summary-catchup-all (&optional quietly)
11359 "Mark all articles in this newsgroup as read.
11360 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11361 instead, which marks only unread articles as read."
11363 (gnus-summary-catchup t quietly))
11365 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11366 "Mark all unread articles in this group as read, then exit.
11367 If prefix argument ALL is non-nil, all articles are marked as read.
11368 If QUIETLY is non-nil, no questions will be asked."
11370 (when (gnus-summary-catchup all quietly nil 'fast)
11371 ;; Select next newsgroup or exit.
11372 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11373 (eq gnus-auto-select-next 'quietly))
11374 (gnus-summary-next-group nil)
11375 (gnus-summary-exit))))
11377 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11378 "Mark all articles in this newsgroup as read, and then exit.
11379 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11380 instead, which marks only unread articles as read."
11382 (gnus-summary-catchup-and-exit t quietly))
11384 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11385 "Mark all articles in this group as read and select the next group.
11386 If given a prefix, mark all articles, unread as well as ticked, as
11390 (gnus-summary-catchup all))
11391 (gnus-summary-next-group))
11393 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11394 "Mark all articles in this group as read and select the previous group.
11395 If given a prefix, mark all articles, unread as well as ticked, as
11399 (gnus-summary-catchup all))
11400 (gnus-summary-next-group nil nil t))
11406 (defmacro gnus-with-article (article &rest forms)
11407 "Select ARTICLE and perform FORMS in the original article buffer.
11408 Then replace the article with the result."
11410 ;; We don't want the article to be marked as read.
11411 (let (gnus-mark-article-hook)
11412 (gnus-summary-select-article t t nil ,article))
11413 (set-buffer gnus-original-article-buffer)
11415 (if (not (gnus-check-backend-function
11416 'request-replace-article (car gnus-article-current)))
11417 (gnus-message 5 "Read-only group; not replacing")
11418 (unless (gnus-request-replace-article
11419 ,article (car gnus-article-current)
11420 (current-buffer) t)
11421 (error "Couldn't replace article")))
11422 ;; The cache and backlog have to be flushed somewhat.
11423 (when gnus-keep-backlog
11424 (gnus-backlog-remove-article
11425 (car gnus-article-current) (cdr gnus-article-current)))
11426 (when gnus-use-cache
11427 (gnus-cache-update-article
11428 (car gnus-article-current) (cdr gnus-article-current)))))
11430 (put 'gnus-with-article 'lisp-indent-function 1)
11431 (put 'gnus-with-article 'edebug-form-spec '(form body))
11433 ;; Thread-based commands.
11435 (defun gnus-summary-articles-in-thread (&optional article)
11436 "Return a list of all articles in the current thread.
11437 If ARTICLE is non-nil, return all articles in the thread that starts
11438 with that article."
11439 (let* ((article (or article (gnus-summary-article-number)))
11440 (data (gnus-data-find-list article))
11441 (top-level (gnus-data-level (car data)))
11443 (cond ((null gnus-thread-operation-ignore-subject)
11444 (gnus-simplify-subject-re
11445 (mail-header-subject (gnus-data-header (car data)))))
11446 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11447 (gnus-simplify-subject-fuzzy
11448 (mail-header-subject (gnus-data-header (car data)))))
11450 (end-point (save-excursion
11451 (goto-char (gnus-data-pos (car data)))
11452 (if (gnus-summary-go-to-next-thread)
11453 (point) (point-max))))
11456 (< (gnus-data-pos (car data)) end-point))
11457 (when (or (not top-subject)
11458 (string= top-subject
11459 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11460 (gnus-simplify-subject-fuzzy
11461 (mail-header-subject
11462 (gnus-data-header (car data))))
11463 (gnus-simplify-subject-re
11464 (mail-header-subject
11465 (gnus-data-header (car data)))))))
11466 (push (gnus-data-number (car data)) articles))
11467 (unless (and (setq data (cdr data))
11468 (> (gnus-data-level (car data)) top-level))
11470 ;; Return the list of articles.
11471 (nreverse articles)))
11473 (defun gnus-summary-rethread-current ()
11474 "Rethread the thread the current article is part of."
11476 (let* ((gnus-show-threads t)
11477 (article (gnus-summary-article-number))
11478 (id (mail-header-id (gnus-summary-article-header)))
11479 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11481 (error "No article on the current line"))
11482 (gnus-rebuild-thread id)
11483 (gnus-summary-goto-subject article)))
11485 (defun gnus-summary-reparent-thread ()
11486 "Make the current article child of the marked (or previous) article.
11488 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11489 is non-nil or the Subject: of both articles are the same."
11491 (unless (not (gnus-group-read-only-p))
11492 (error "The current newsgroup does not support article editing"))
11493 (unless (<= (length gnus-newsgroup-processable) 1)
11494 (error "No more than one article may be marked"))
11495 (let ((child (gnus-summary-article-number))
11496 ;; First grab the marked article, otherwise one line up.
11497 (parent (if (not (null gnus-newsgroup-processable))
11498 (car gnus-newsgroup-processable)
11500 (if (eq (forward-line -1) 0)
11501 (gnus-summary-article-number)
11502 (error "Beginning of summary buffer"))))))
11503 (gnus-summary-reparent-children parent (list child))))
11505 (defun gnus-summary-reparent-children (parent children)
11506 "Make PARENT the parent of CHILDREN.
11507 When called interactively, PARENT is the current article and CHILDREN
11508 are the process-marked articles."
11510 (list (gnus-summary-article-number)
11511 (gnus-summary-work-articles nil)))
11512 (dolist (child children)
11513 (save-window-excursion
11514 (let ((gnus-article-buffer " *reparent*"))
11515 (unless (not (eq parent child))
11516 (error "An article may not be self-referential"))
11517 (let ((message-id (mail-header-id
11518 (gnus-summary-article-header parent))))
11519 (unless (and message-id (not (equal message-id "")))
11520 (error "No message-id in desired parent"))
11521 (gnus-with-article child
11523 (goto-char (point-min))
11524 (message-narrow-to-head)
11525 (if (re-search-forward "^References: " nil t)
11527 (re-search-forward "^[^ \t]" nil t)
11530 (insert " " message-id))
11531 (insert "References: " message-id "\n"))))
11532 (set-buffer gnus-summary-buffer)
11533 (gnus-summary-unmark-all-processable)
11534 (gnus-summary-update-article child)
11535 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11536 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11537 (gnus-summary-rethread-current)
11538 (gnus-message 3 "Article %d is now the child of article %d"
11541 (defun gnus-summary-toggle-threads (&optional arg)
11542 "Toggle showing conversation threads.
11543 If ARG is positive number, turn showing conversation threads on."
11545 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11546 (setq gnus-show-threads
11547 (if (null arg) (not gnus-show-threads)
11548 (> (prefix-numeric-value arg) 0)))
11549 (gnus-summary-prepare)
11550 (gnus-summary-goto-subject current)
11551 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11552 (gnus-summary-position-point)))
11555 (if (fboundp 'remove-overlays)
11556 (defalias 'gnus-remove-overlays 'remove-overlays)
11557 (defun gnus-remove-overlays (beg end name val)
11558 "Clear BEG and END of overlays whose property NAME has value VAL.
11559 For compatibility with XEmacs."
11560 (dolist (ov (gnus-overlays-in beg end))
11561 (when (eq (gnus-overlay-get ov name) val)
11562 (gnus-delete-overlay ov))))))
11564 (defun gnus-summary-show-all-threads ()
11565 "Show all threads."
11567 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11568 (gnus-summary-position-point))
11570 (defsubst gnus-summary--inv (p)
11571 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11573 (defun gnus-summary-show-thread ()
11574 "Show thread subtrees.
11575 Returns nil if no thread was there to be shown."
11577 (let* ((orig (point))
11578 (end (point-at-eol))
11579 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11580 ;; Leave point at bol
11581 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11583 (if (fboundp 'next-single-char-property-change)
11584 ;; Note: XEmacs version of n-s-c-p-c may return nil
11585 (or (next-single-char-property-change end 'invisible)
11590 (eq (get-char-property (point) 'invisible)
11594 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11596 (gnus-summary-position-point)
11599 (defun gnus-summary-maybe-hide-threads ()
11600 "If requested, hide the threads that should be hidden."
11601 (when (and gnus-show-threads
11602 gnus-thread-hide-subtree)
11603 (gnus-summary-hide-all-threads
11604 (if (or (consp gnus-thread-hide-subtree)
11605 (functionp gnus-thread-hide-subtree))
11606 (gnus-make-predicate gnus-thread-hide-subtree)
11609 ;;; Hiding predicates.
11611 (defun gnus-article-unread-p (header)
11612 (memq (mail-header-number header) gnus-newsgroup-unreads))
11614 (defun gnus-article-unseen-p (header)
11615 (memq (mail-header-number header) gnus-newsgroup-unseen))
11617 (defun gnus-map-articles (predicate articles)
11618 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11619 (apply 'gnus-or (mapcar predicate
11620 (mapcar (lambda (number)
11621 (gnus-summary-article-header number))
11624 (defun gnus-summary-hide-all-threads (&optional predicate)
11625 "Hide all thread subtrees.
11626 If PREDICATE is supplied, threads that satisfy this predicate
11627 will not be hidden."
11630 (goto-char (point-min))
11635 (when (zerop (mod count 1000))
11636 (message "Hiding all threads... %d" count))
11637 (when (or (not predicate)
11639 predicate (gnus-summary-article-children)))
11640 (gnus-summary-hide-thread))
11641 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11642 (gnus-summary-position-point))
11644 (defun gnus-summary-hide-thread ()
11645 "Hide thread subtrees.
11646 If PREDICATE is supplied, threads that satisfy this predicate
11647 will not be hidden.
11648 Returns nil if no threads were there to be hidden."
11650 (let ((start (point))
11651 (starteol (line-end-position))
11652 (article (gnus-summary-article-number)))
11654 ;; Go forward until either the buffer ends or the subthread ends.
11655 (when (and (not (eobp))
11656 (or (zerop (gnus-summary-next-thread 1 t))
11657 (goto-char (point-max))))
11658 (if (and (> (point) start)
11659 ;; FIXME: this should actually search for a non-invisible \n.
11660 (search-backward "\n" start t))
11662 (when (> (point) starteol)
11663 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11664 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11665 (gnus-overlay-put ol 'invisible 'gnus-sum)
11666 (gnus-overlay-put ol 'evaporate t)))
11667 (gnus-summary-goto-subject article)
11668 (when (> start (point))
11669 (message "Hiding the thread moved us backwards, aborting!")
11670 (goto-char (point-max))))
11674 (defun gnus-summary-go-to-next-thread (&optional previous)
11675 "Go to the same level (or less) next thread.
11676 If PREVIOUS is non-nil, go to previous thread instead.
11677 Return the article number moved to, or nil if moving was impossible."
11678 (let ((level (gnus-summary-thread-level))
11679 (way (if previous -1 1))
11682 (while (and (not (eobp))
11683 (< level (gnus-summary-thread-level)))
11684 (forward-line way))
11691 (gnus-summary-article-number)
11692 (goto-char beg)))))
11694 (defun gnus-summary-next-thread (n &optional silent)
11695 "Go to the same level next N'th thread.
11696 If N is negative, search backward instead.
11697 Returns the difference between N and the number of skips actually
11700 If SILENT, don't output messages."
11702 (let ((backward (< n 0))
11704 (while (and (> n 0)
11705 (gnus-summary-go-to-next-thread backward))
11708 (gnus-summary-position-point))
11709 (when (and (not silent) (/= 0 n))
11710 (gnus-message 7 "No more threads"))
11713 (defun gnus-summary-prev-thread (n)
11714 "Go to the same level previous N'th thread.
11715 Returns the difference between N and the number of skips actually
11718 (gnus-summary-next-thread (- n)))
11720 (defun gnus-summary-go-down-thread ()
11721 "Go down one level in the current thread."
11722 (let ((children (gnus-summary-article-children)))
11724 (gnus-summary-goto-subject (car children)))))
11726 (defun gnus-summary-go-up-thread ()
11727 "Go up one level in the current thread."
11728 (let ((parent (gnus-summary-article-parent)))
11730 (gnus-summary-goto-subject parent))))
11732 (defun gnus-summary-down-thread (n)
11733 "Go down thread N steps.
11734 If N is negative, go up instead.
11735 Returns the difference between N and how many steps down that were
11740 (while (and (> n 0)
11741 (if up (gnus-summary-go-up-thread)
11742 (gnus-summary-go-down-thread)))
11744 (gnus-summary-position-point)
11746 (gnus-message 7 "Can't go further"))
11749 (defun gnus-summary-up-thread (n)
11750 "Go up thread N steps.
11751 If N is negative, go down instead.
11752 Returns the difference between N and how many steps down that were
11755 (gnus-summary-down-thread (- n)))
11757 (defun gnus-summary-top-thread ()
11758 "Go to the top of the thread."
11760 (while (gnus-summary-go-up-thread))
11761 (gnus-summary-article-number))
11763 (defun gnus-summary-expire-thread ()
11764 "Mark articles under current thread as expired."
11766 (gnus-summary-kill-thread 0))
11768 (defun gnus-summary-kill-thread (&optional unmark)
11769 "Mark articles under current thread as read.
11770 If the prefix argument is positive, remove any kinds of marks.
11771 If the prefix argument is zero, mark thread as expired.
11772 If the prefix argument is negative, tick articles instead."
11775 (setq unmark (prefix-numeric-value unmark)))
11776 (let ((articles (gnus-summary-articles-in-thread))
11777 (hide (or (null unmark) (= unmark 0))))
11779 ;; Expand the thread.
11780 (gnus-summary-show-thread)
11781 ;; Mark all the articles.
11783 (gnus-summary-goto-subject (car articles))
11784 (cond ((null unmark)
11785 (gnus-summary-mark-article-as-read gnus-killed-mark))
11787 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11789 (gnus-summary-mark-article nil gnus-expirable-mark))
11791 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11792 (setq articles (cdr articles))))
11793 ;; Hide killed subtrees when hide is true.
11795 gnus-thread-hide-killed
11796 (gnus-summary-hide-thread))
11797 ;; If hide is t, go to next unread subject.
11799 ;; Go to next unread subject.
11800 (gnus-summary-next-subject 1 t)))
11801 (gnus-set-mode-line 'summary))
11803 ;; Summary sorting commands
11805 (defun gnus-summary-sort-by-number (&optional reverse)
11806 "Sort the summary buffer by article number.
11807 Argument REVERSE means reverse order."
11809 (gnus-summary-sort 'number reverse))
11811 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11812 "Sort the summary buffer by most recent article number.
11813 Argument REVERSE means reverse order."
11815 (gnus-summary-sort 'most-recent-number reverse))
11817 (defun gnus-summary-sort-by-random (&optional reverse)
11818 "Randomize the order in the summary buffer.
11819 Argument REVERSE means to randomize in reverse order."
11821 (gnus-summary-sort 'random reverse))
11823 (defun gnus-summary-sort-by-author (&optional reverse)
11824 "Sort the summary buffer by author name alphabetically.
11825 If `case-fold-search' is non-nil, case of letters is ignored.
11826 Argument REVERSE means reverse order."
11828 (gnus-summary-sort 'author reverse))
11830 (defun gnus-summary-sort-by-recipient (&optional reverse)
11831 "Sort the summary buffer by recipient name alphabetically.
11832 If `case-fold-search' is non-nil, case of letters is ignored.
11833 Argument REVERSE means reverse order."
11835 (gnus-summary-sort 'recipient reverse))
11837 (defun gnus-summary-sort-by-subject (&optional reverse)
11838 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11839 If `case-fold-search' is non-nil, case of letters is ignored.
11840 Argument REVERSE means reverse order."
11842 (gnus-summary-sort 'subject reverse))
11844 (defun gnus-summary-sort-by-date (&optional reverse)
11845 "Sort the summary buffer by date.
11846 Argument REVERSE means reverse order."
11848 (gnus-summary-sort 'date reverse))
11850 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11851 "Sort the summary buffer by most recent date.
11852 Argument REVERSE means reverse order."
11854 (gnus-summary-sort 'most-recent-date reverse))
11856 (defun gnus-summary-sort-by-score (&optional reverse)
11857 "Sort the summary buffer by score.
11858 Argument REVERSE means reverse order."
11860 (gnus-summary-sort 'score reverse))
11862 (defun gnus-summary-sort-by-lines (&optional reverse)
11863 "Sort the summary buffer by the number of lines.
11864 Argument REVERSE means reverse order."
11866 (gnus-summary-sort 'lines reverse))
11868 (defun gnus-summary-sort-by-chars (&optional reverse)
11869 "Sort the summary buffer by article length.
11870 Argument REVERSE means reverse order."
11872 (gnus-summary-sort 'chars reverse))
11874 (defun gnus-summary-sort-by-original (&optional reverse)
11875 "Sort the summary buffer using the default sorting method.
11876 Argument REVERSE means reverse order."
11878 (let* ((inhibit-read-only t)
11879 (gnus-summary-prepare-hook nil))
11880 ;; We do the sorting by regenerating the threads.
11881 (gnus-summary-prepare)
11882 ;; Hide subthreads if needed.
11883 (gnus-summary-maybe-hide-threads)))
11885 (defun gnus-summary-sort (predicate reverse)
11886 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11887 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11888 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11889 (gnus-thread-sort-functions
11894 (gnus-sort-gathered-threads-function
11895 gnus-thread-sort-functions)
11896 (gnus-article-sort-functions
11900 (,article t2 t1))))
11901 (inhibit-read-only t)
11902 (gnus-summary-prepare-hook nil))
11903 ;; We do the sorting by regenerating the threads.
11904 (gnus-summary-prepare)
11905 ;; Hide subthreads if needed.
11906 (gnus-summary-maybe-hide-threads)))
11908 ;; Summary saving commands.
11910 (defun gnus-summary-save-article (&optional n not-saved)
11911 "Save the current article using the default saver function.
11912 If N is a positive number, save the N next articles.
11913 If N is a negative number, save the N previous articles.
11914 If N is nil and any articles have been marked with the process mark,
11915 save those articles instead.
11916 The variable `gnus-default-article-saver' specifies the saver function.
11918 If the optional second argument NOT-SAVED is non-nil, articles saved
11919 will not be marked as saved."
11921 (require 'gnus-art)
11922 (let* ((articles (gnus-summary-work-articles n))
11923 (save-buffer (save-excursion
11924 (nnheader-set-temp-buffer " *Gnus Save*")))
11925 (num (length articles))
11926 ;; Whether to save decoded articles or raw articles.
11927 (decode (when gnus-article-save-coding-system
11928 (get gnus-default-article-saver :decode)))
11929 ;; When saving many articles in a single file, use the other
11930 ;; function to save articles other than the first one.
11931 (saver2 (get gnus-default-article-saver :function))
11932 (gnus-prompt-before-saving (if saver2
11934 gnus-prompt-before-saving))
11935 (gnus-default-article-saver gnus-default-article-saver)
11937 (dolist (article articles)
11938 (setq header (gnus-summary-article-header article))
11939 (if (not (vectorp header))
11940 ;; This is a pseudo-article.
11941 (if (assq 'name header)
11942 (gnus-copy-file (cdr (assq 'name header)))
11943 (gnus-message 1 "Article %d is unsavable" article))
11944 ;; This is a real article.
11945 (save-window-excursion
11946 (gnus-summary-select-article decode decode nil article)
11947 (gnus-summary-goto-subject article))
11948 (with-current-buffer save-buffer
11950 (insert-buffer-substring (if decode
11951 gnus-article-buffer
11952 gnus-original-article-buffer)))
11953 (setq file (gnus-article-save save-buffer file num))
11954 (gnus-summary-remove-process-mark article)
11956 (gnus-summary-set-saved-mark article)))
11958 (setq gnus-default-article-saver saver2
11960 (gnus-kill-buffer save-buffer)
11961 (gnus-summary-position-point)
11962 (gnus-set-mode-line 'summary)
11965 (defun gnus-summary-pipe-output (&optional n sym)
11966 "Pipe the current article to a subprocess.
11967 If N is a positive number, pipe the N next articles.
11968 If N is a negative number, pipe the N previous articles.
11969 If N is nil and any articles have been marked with the process mark,
11970 pipe those articles instead.
11971 The default command to which articles are piped is specified by the
11972 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11973 will be prompted for the command.
11975 The properties `:decode' and `:headers' that are put to the function
11976 symbol `gnus-summary-save-in-pipe' control whether this function
11977 decodes articles and what headers to keep (see the doc string for the
11978 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11979 is neither omitted nor the symbol `r', force including all headers
11980 regardless of the `:headers' property. If it is the symbol `r',
11981 articles that are not decoded and include all headers will be piped
11982 no matter what the properties `:decode' and `:headers' are."
11983 (interactive (gnus-interactive "P\ny"))
11984 (require 'gnus-art)
11985 (let* ((articles (gnus-summary-work-articles n))
11986 (result-buffer "*Shell Command Output*")
11987 (all-headers (not (memq sym '(nil r))))
11988 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11990 (headers (get 'gnus-summary-save-in-pipe :headers))
11992 (unless (numberp (car articles))
11993 (error "No article to pipe"))
11994 (setq command (gnus-read-shell-command
11995 (concat "Shell command on "
11997 (format "these %d articles" (length articles))
12000 gnus-summary-pipe-output-default-command))
12001 (when (string-equal command "")
12002 (error "A command is required"))
12004 (put 'gnus-summary-save-in-pipe :headers nil))
12007 (gnus-summary-goto-subject (pop articles))
12008 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12009 (when (and (get-buffer result-buffer)
12010 (not (zerop (buffer-size (get-buffer result-buffer)))))
12011 (setq result (concat result (with-current-buffer result-buffer
12012 (buffer-string))))))
12013 (put 'gnus-summary-save-in-pipe :headers headers))
12014 (unless (zerop (length result))
12015 (if (with-current-buffer (get-buffer-create result-buffer)
12019 (and (= (count-lines (point-min) (point)) 1)
12022 (<= (current-column)
12023 (window-width (minibuffer-window)))))
12024 (goto-char (point-min))))
12025 (message "%s" (substring result 0 -1))
12027 (gnus-configure-windows 'pipe)))))
12029 (defun gnus-summary-save-article-mail (&optional arg)
12030 "Append the current article to a Unix mail box file.
12031 If N is a positive number, save the N next articles.
12032 If N is a negative number, save the N previous articles.
12033 If N is nil and any articles have been marked with the process mark,
12034 save those articles instead."
12036 (require 'gnus-art)
12037 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12038 (gnus-summary-save-article arg)))
12040 (defun gnus-summary-save-article-rmail (&optional arg)
12041 "Append the current article to an rmail file.
12042 If N is a positive number, save the N next articles.
12043 If N is a negative number, save the N previous articles.
12044 If N is nil and any articles have been marked with the process mark,
12045 save those articles instead."
12047 (require 'gnus-art)
12048 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12049 (gnus-summary-save-article arg)))
12051 (defun gnus-summary-save-article-file (&optional arg)
12052 "Append the current article to a file.
12053 If N is a positive number, save the N next articles.
12054 If N is a negative number, save the N previous articles.
12055 If N is nil and any articles have been marked with the process mark,
12056 save those articles instead."
12058 (require 'gnus-art)
12059 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12060 (gnus-summary-save-article arg)))
12062 (defun gnus-summary-write-article-file (&optional arg)
12063 "Write the current article to a file, deleting the previous file.
12064 If N is a positive number, save the N next articles.
12065 If N is a negative number, save the N previous articles.
12066 If N is nil and any articles have been marked with the process mark,
12067 save those articles instead."
12069 (require 'gnus-art)
12070 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12071 (gnus-summary-save-article arg)))
12073 (defun gnus-summary-save-article-body-file (&optional arg)
12074 "Append the current article body to a file.
12075 If N is a positive number, save the N next articles.
12076 If N is a negative number, save the N previous articles.
12077 If N is nil and any articles have been marked with the process mark,
12078 save those articles instead."
12080 (require 'gnus-art)
12081 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12082 (gnus-summary-save-article arg)))
12084 (defun gnus-summary-write-article-body-file (&optional arg)
12085 "Write the current article body to a file, deleting the previous file.
12086 If N is a positive number, save the N next articles.
12087 If N is a negative number, save the N previous articles.
12088 If N is nil and any articles have been marked with the process mark,
12089 save those articles instead."
12091 (require 'gnus-art)
12092 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12093 (gnus-summary-save-article arg)))
12095 (defun gnus-summary-muttprint (&optional arg)
12096 "Print the current article using Muttprint.
12097 If N is a positive number, save the N next articles.
12098 If N is a negative number, save the N previous articles.
12099 If N is nil and any articles have been marked with the process mark,
12100 save those articles instead."
12102 (require 'gnus-art)
12103 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12104 (gnus-summary-save-article arg t)))
12106 (defun gnus-summary-pipe-message (program)
12107 "Pipe the current article through PROGRAM."
12108 (interactive "sProgram: ")
12109 (gnus-summary-select-article)
12110 (let ((mail-header-separator ""))
12111 (gnus-eval-in-buffer-window gnus-article-buffer
12114 (let ((start (window-start))
12115 (inhibit-read-only t))
12116 (message-pipe-buffer-body program)
12117 (set-window-start (get-buffer-window (current-buffer)) start))))))
12119 (defun gnus-get-split-value (methods)
12120 "Return a value based on the split METHODS."
12121 (let (split-name method result match)
12123 (with-current-buffer gnus-original-article-buffer
12125 (nnheader-narrow-to-headers)
12126 (while (and methods (not split-name))
12127 (goto-char (point-min))
12128 (setq method (pop methods))
12129 (setq match (car method))
12132 ;; Regular expression.
12134 (re-search-forward match nil t)))
12139 (setq result (funcall match gnus-newsgroup-name))))
12144 (setq result (eval match)))))
12145 (setq split-name (cdr method))
12146 (cond ((stringp result)
12147 (push (expand-file-name
12148 result gnus-article-save-directory)
12151 (setq split-name (append result split-name)))))))))
12152 (nreverse split-name)))
12154 (defun gnus-valid-move-group-p (group)
12155 (and (symbolp group)
12157 (symbol-name group)
12158 (symbol-value group)
12159 (gnus-get-function (gnus-find-method-for-group
12160 (symbol-name group)) 'request-accept-article t)))
12162 (defun gnus-read-move-group-name (prompt default articles prefix)
12163 "Read a group name."
12164 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12165 (minibuffer-confirm-incomplete nil) ; XEmacs
12169 (if (> (length articles) 1)
12170 (format "these %d articles" (length articles))
12175 (gnus-group-completing-read
12177 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12178 nil prefix nil default))
12179 ((= 1 (length split-name))
12180 (gnus-group-completing-read
12182 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12183 nil prefix 'gnus-group-history (car split-name)))
12185 (gnus-completing-read
12186 prom (nreverse split-name) nil nil 'gnus-group-history))))
12187 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12190 (if (or (string= to-newsgroup "")
12191 (string= to-newsgroup prefix))
12192 (setq to-newsgroup default))
12193 (unless to-newsgroup
12194 (error "No group name entered"))
12195 (setq encoded (mm-encode-coding-string
12197 (gnus-group-name-charset to-method to-newsgroup)))
12198 (or (gnus-active encoded)
12199 (gnus-activate-group encoded nil nil to-method)
12200 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12202 (or (and (gnus-request-create-group encoded to-method)
12203 (gnus-activate-group encoded nil nil to-method)
12204 (gnus-subscribe-group encoded))
12205 (error "Couldn't create group %s" to-newsgroup)))
12206 (error "No such group: %s" to-newsgroup))
12209 (defvar gnus-summary-save-parts-counter)
12210 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12212 (defun gnus-summary-save-parts (type dir n &optional reverse)
12213 "Save parts matching TYPE to DIR.
12214 If REVERSE, save parts that do not match TYPE."
12216 (list (read-string "Save parts of type: "
12217 (or (car gnus-summary-save-parts-type-history)
12218 gnus-summary-save-parts-default-mime)
12219 'gnus-summary-save-parts-type-history)
12220 (setq gnus-summary-save-parts-last-directory
12221 (read-directory-name "Save to directory: "
12222 gnus-summary-save-parts-last-directory
12224 current-prefix-arg))
12225 (gnus-summary-iterate n
12226 (let ((gnus-display-mime-function nil)
12227 gnus-article-prepare-hook
12228 gnus-article-decode-hook
12229 gnus-display-mime-function
12231 (gnus-inhibit-treatment t))
12232 (gnus-summary-select-article))
12233 (with-current-buffer gnus-article-buffer
12234 (let ((handles (or gnus-article-mime-handles
12235 (mm-dissect-buffer nil gnus-article-loose-mime)
12236 (and gnus-article-emulate-mime
12238 (gnus-summary-save-parts-counter 1))
12240 (gnus-summary-save-parts-1 type dir handles reverse)
12241 (unless gnus-article-mime-handles ;; Don't destroy this case.
12242 (mm-destroy-parts handles)))))))
12244 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12245 (if (stringp (car handle))
12246 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12249 (not (string-match type (mm-handle-media-type handle)))
12250 (string-match type (mm-handle-media-type handle)))
12251 (let ((file (expand-file-name
12253 mm-file-name-rewrite-functions
12254 (file-name-nondirectory
12256 (mm-handle-filename handle)
12257 (format "%s.%d.%d" gnus-newsgroup-name
12258 (cdr gnus-article-current)
12259 gnus-summary-save-parts-counter))))
12261 (incf gnus-summary-save-parts-counter)
12262 (unless (file-exists-p file)
12263 (mm-save-part-to-file handle file))))))
12265 ;; Summary extract commands
12267 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12268 (let ((inhibit-read-only t)
12269 (article (gnus-summary-article-number))
12271 (unless (gnus-summary-goto-subject article)
12272 (error "No such article: %d" article))
12273 (gnus-summary-position-point)
12274 ;; If all commands are to be bunched up on one line, we collect
12276 (unless gnus-view-pseudos-separately
12277 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12280 (setq action (cdr (assq 'action (car ps))))
12281 (setq files (list (cdr (assq 'name (car ps)))))
12282 (while (and ps (cdr ps)
12283 (string= (or action "1")
12284 (or (cdr (assq 'action (cadr ps))) "2")))
12285 (push (cdr (assq 'name (cadr ps))) files)
12286 (setcdr ps (cddr ps)))
12288 (when (not (string-match "%s" action))
12291 (when (assq 'execute (car ps))
12292 (setcdr (assq 'execute (car ps))
12293 (funcall (if (string-match "%s" action)
12300 (shell-quote-argument f)))
12302 (setq ps (cdr ps)))))
12303 (if (and gnus-view-pseudos (not not-view))
12305 (when (assq 'execute (car pslist))
12306 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12307 (eq gnus-view-pseudos 'not-confirm)))
12308 (setq pslist (cdr pslist)))
12311 (setq after-article (or (cdr (assq 'article (car pslist)))
12312 (gnus-summary-article-number)))
12313 (gnus-summary-goto-subject after-article)
12316 (insert " " (file-name-nondirectory
12317 (cdr (assq 'name (car pslist))))
12318 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12320 (forward-line -1) ; back to `b'
12321 (gnus-add-text-properties
12322 b (1- e) (list 'gnus-number gnus-reffed-article-number
12323 gnus-mouse-face-prop gnus-mouse-face))
12325 after-article gnus-reffed-article-number
12326 gnus-unread-mark b (car pslist) 0 (- e b))
12327 (setq gnus-newsgroup-unreads
12328 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12329 gnus-reffed-article-number))
12330 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12331 (setq pslist (cdr pslist)))))))
12333 (defun gnus-pseudos< (p1 p2)
12334 (let ((c1 (cdr (assq 'action p1)))
12335 (c2 (cdr (assq 'action p2))))
12336 (and c1 c2 (string< c1 c2))))
12338 (defun gnus-request-pseudo-article (props)
12339 (cond ((assq 'execute props)
12340 (gnus-execute-command (cdr (assq 'execute props)))))
12341 (let ((gnus-current-article (gnus-summary-article-number)))
12342 (gnus-run-hooks 'gnus-mark-article-hook)))
12344 (defun gnus-execute-command (command &optional automatic)
12346 (gnus-article-setup-buffer)
12347 (set-buffer gnus-article-buffer)
12348 (setq buffer-read-only nil)
12349 (let ((command (if automatic command
12350 (read-string "Command: " (cons command 0)))))
12352 (insert "$ " command "\n\n")
12353 (if gnus-view-pseudo-asynchronously
12354 (start-process "gnus-execute" (current-buffer) shell-file-name
12355 shell-command-switch command)
12356 (call-process shell-file-name nil t nil
12357 shell-command-switch command)))))
12359 ;; Summary kill commands.
12361 (defun gnus-summary-edit-global-kill (article)
12362 "Edit the \"global\" kill file."
12363 (interactive (list (gnus-summary-article-number)))
12364 (gnus-group-edit-global-kill article))
12366 (defun gnus-summary-edit-local-kill ()
12367 "Edit a local kill file applied to the current newsgroup."
12369 (setq gnus-current-headers (gnus-summary-article-header))
12370 (gnus-group-edit-local-kill
12371 (gnus-summary-article-number) gnus-newsgroup-name))
12373 ;;; Header reading.
12375 (defun gnus-read-header (id &optional header)
12376 "Read the headers of article ID and enter them into the Gnus system."
12377 (let ((group gnus-newsgroup-name)
12378 (gnus-override-method
12380 gnus-override-method
12381 (and (gnus-news-group-p gnus-newsgroup-name)
12382 (car (gnus-refer-article-methods)))))
12384 ;; First we check to see whether the header in question is already
12387 ;; This is a Message-ID.
12388 (setq header (or header (gnus-id-to-header id)))
12389 ;; This is an article number.
12390 (setq header (or header (gnus-summary-article-header id))))
12392 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12393 ;; We have found the header.
12395 ;; We have to really fetch the header to this article.
12396 (with-current-buffer nntp-server-buffer
12397 (when (setq where (gnus-request-head id group))
12398 (nnheader-fold-continuation-lines)
12399 (goto-char (point-max))
12401 (goto-char (point-min))
12405 ((cdr where) (cdr where))
12406 (header (mail-header-number header))
12407 (t gnus-reffed-article-number))
12409 (insert " Article retrieved.\n"))
12410 (if (or (not where)
12411 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12412 () ; Malformed head.
12413 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12414 (when (and (bound-and-true-p gnus-registry-enabled)
12415 (not (gnus-ephemeral-group-p (car where))))
12416 (gnus-registry-handle-action
12417 (mail-header-id header) nil
12418 (gnus-group-prefixed-name (car where) gnus-override-method)
12419 (mail-header-subject header)
12420 (mail-header-from header)))
12421 (when (and (stringp id)
12423 (not (string= (gnus-group-real-name group)
12425 (not (gnus-server-equal gnus-override-method
12426 (gnus-group-method group)))))
12427 ;; If we fetched by Message-ID and the article came from
12428 ;; a different group (or server), we fudge some bogus
12429 ;; article numbers for this article.
12430 (mail-header-set-number header gnus-reffed-article-number))
12431 (with-current-buffer gnus-summary-buffer
12432 (decf gnus-reffed-article-number)
12433 (gnus-remove-header (mail-header-number header))
12434 (push header gnus-newsgroup-headers)
12435 (setq gnus-current-headers header)
12436 (push (mail-header-number header) gnus-newsgroup-limit)))
12439 (defun gnus-remove-header (number)
12440 "Remove header NUMBER from `gnus-newsgroup-headers'."
12441 (if (and gnus-newsgroup-headers
12442 (= number (mail-header-number (car gnus-newsgroup-headers))))
12443 (pop gnus-newsgroup-headers)
12444 (let ((headers gnus-newsgroup-headers))
12445 (while (and (cdr headers)
12446 (not (= number (mail-header-number (cadr headers)))))
12448 (when (cdr headers)
12449 (setcdr headers (cddr headers))))))
12452 ;;; summary highlights
12455 (defun gnus-highlight-selected-summary ()
12456 "Highlight selected article in summary buffer."
12457 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12458 (when gnus-summary-selected-face
12460 (let* ((beg (point-at-bol))
12461 (end (point-at-eol))
12462 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12463 (from (if (get-text-property beg gnus-mouse-face-prop)
12465 (or (next-single-property-change
12466 beg gnus-mouse-face-prop nil end)
12471 (or (next-single-property-change
12472 from gnus-mouse-face-prop nil end)
12474 ;; If no mouse-face prop on line we will have to = from = end,
12475 ;; so we highlight the entire line instead.
12476 (when (= (+ to 2) from)
12479 (if gnus-newsgroup-selected-overlay
12480 ;; Move old overlay.
12482 gnus-newsgroup-selected-overlay from to (current-buffer))
12483 ;; Create new overlay.
12485 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12486 'face gnus-summary-selected-face))))))
12488 (defvar gnus-summary-highlight-line-cached nil)
12489 (defvar gnus-summary-highlight-line-trigger nil)
12491 (defun gnus-summary-highlight-line-0 ()
12492 (if (and (eq gnus-summary-highlight-line-trigger
12493 gnus-summary-highlight)
12494 gnus-summary-highlight-line-cached)
12495 gnus-summary-highlight-line-cached
12496 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12497 gnus-summary-highlight-line-cached
12498 (let* ((cond (list 'cond))
12500 (list gnus-summary-highlight))
12502 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12506 (gnus-byte-compile (list 'lambda nil cond))))))
12508 (defun gnus-summary-highlight-line ()
12509 "Highlight current line according to `gnus-summary-highlight'."
12510 (let* ((beg (point-at-bol))
12511 (article (or (gnus-summary-article-number) gnus-current-article))
12512 (score (or (cdr (assq article
12513 gnus-newsgroup-scored))
12514 gnus-summary-default-score 0))
12515 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12516 (inhibit-read-only t)
12517 (default gnus-summary-default-score)
12518 (default-high gnus-summary-default-high-score)
12519 (default-low gnus-summary-default-low-score)
12520 (uncached (and gnus-summary-use-undownloaded-faces
12521 (memq article gnus-newsgroup-undownloaded)
12522 (not (memq article gnus-newsgroup-cached)))))
12523 (let ((face (funcall (gnus-summary-highlight-line-0))))
12524 (unless (eq face (get-text-property beg 'face))
12525 (gnus-put-text-property-excluding-characters-with-faces
12526 beg (point-at-eol) 'face
12527 (setq face (if (boundp face) (symbol-value face) face)))
12528 (when gnus-summary-highlight-line-function
12529 (funcall gnus-summary-highlight-line-function article face))))))
12531 (defun gnus-update-read-articles (group unread &optional compute)
12532 "Update the list of read articles in GROUP.
12533 UNREAD is a sorted list."
12534 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12535 (info (gnus-get-info group))
12538 (if (or (not info) (not active))
12539 ;; There is no info on this group if it was, in fact,
12540 ;; killed. Gnus stores no information on killed groups, so
12541 ;; there's nothing to be done.
12542 ;; One could store the information somewhere temporarily,
12543 ;; perhaps... Hmmm...
12545 ;; Remove any negative articles numbers.
12546 (while (and unread (< (car unread) 0))
12547 (setq unread (cdr unread)))
12548 ;; Remove any expired article numbers
12549 (while (and unread (< (car unread) (car active)))
12550 (setq unread (cdr unread)))
12551 ;; Compute the ranges of read articles by looking at the list of
12552 ;; unread articles.
12554 (when (/= (car unread) prev)
12555 (push (if (= prev (1- (car unread))) prev
12556 (cons prev (1- (car unread))))
12558 (setq prev (1+ (car unread)))
12559 (setq unread (cdr unread)))
12560 (when (<= prev (cdr active))
12561 (push (cons prev (cdr active)) read))
12562 (setq read (if (> (length read) 1) (nreverse read) read))
12567 ;; Propagate the read marks to the backend.
12568 (when (and (gnus-method-option-p
12569 (gnus-find-method-for-group group)
12571 (gnus-check-backend-function 'request-set-mark group))
12572 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12573 (add (gnus-remove-from-range read (gnus-info-read info))))
12575 (unless (gnus-check-group group)
12576 (error "Can't open server for %s" group))
12577 (gnus-request-set-mark
12578 group (delq nil (list (if add (list add 'add '(read)))
12579 (if del (list del 'del '(read))))))
12581 `(gnus-request-set-mark
12584 (if del (list del 'add '(read)))
12585 (if add (list add 'del '(read))))))))))
12586 (set-buffer gnus-group-buffer)
12587 (gnus-undo-register
12589 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12590 (gnus-info-set-read ',info ',(gnus-info-read info))
12591 (gnus-get-unread-articles-in-group ',info
12592 (gnus-active ,group))
12593 (gnus-group-update-group ,group t)
12595 ;; Enter this list into the group info.
12596 (gnus-info-set-read info read)
12597 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12598 (gnus-get-unread-articles-in-group info (gnus-active group))
12601 (defun gnus-offer-save-summaries ()
12602 "Offer to save all active summary buffers."
12604 ;; Go through all buffers and find all summaries.
12605 (dolist (buffer (buffer-list))
12606 (when (and (setq buffer (buffer-name buffer))
12607 (string-match "Summary" buffer)
12608 (with-current-buffer buffer
12609 ;; We check that this is, indeed, a summary buffer.
12610 (and (eq major-mode 'gnus-summary-mode)
12611 ;; Also make sure this isn't bogus.
12612 gnus-newsgroup-prepared
12613 ;; Also make sure that this isn't a
12614 ;; dead summary buffer.
12615 (not gnus-dead-summary-mode))))
12616 (push buffer buffers)))
12617 ;; Go through all these summary buffers and offer to save them.
12620 (if (eq gnus-interactive-exit 'quiet)
12621 (dolist (buffer buffers)
12622 (switch-to-buffer buffer)
12623 (gnus-summary-exit))
12625 "Update summary buffer %s? "
12627 (switch-to-buffer buf)
12628 (gnus-summary-exit))
12631 (defun gnus-summary-setup-default-charset ()
12632 "Setup newsgroup default charset."
12633 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12634 (setq gnus-newsgroup-charset nil)
12635 (let* ((ignored-charsets
12636 (or gnus-newsgroup-ephemeral-ignored-charsets
12638 (and gnus-newsgroup-name
12639 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12640 gnus-newsgroup-ignored-charsets))))
12641 (setq gnus-newsgroup-charset
12642 (or gnus-newsgroup-ephemeral-charset
12643 (and gnus-newsgroup-name
12644 (gnus-parameter-charset gnus-newsgroup-name))
12645 gnus-default-charset))
12646 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12647 ignored-charsets))))
12653 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12654 "Display the current article buffer fully MIME-buttonized.
12655 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12656 treated as multipart/mixed."
12658 (require 'gnus-art)
12659 (let ((gnus-unbuttonized-mime-types nil)
12660 (gnus-mime-display-multipart-as-mixed show-all-parts))
12661 (gnus-summary-show-article)))
12663 (defun gnus-summary-repair-multipart (article)
12664 "Add a Content-Type header to a multipart article without one."
12665 (interactive (list (gnus-summary-article-number)))
12666 (gnus-with-article article
12667 (message-narrow-to-head)
12668 (message-remove-header "Mime-Version")
12669 (goto-char (point-max))
12670 (insert "Mime-Version: 1.0\n")
12672 (when (search-forward "\n--" nil t)
12673 (let ((separator (buffer-substring (point) (point-at-eol))))
12674 (message-narrow-to-head)
12675 (message-remove-header "Content-Type")
12676 (goto-char (point-max))
12677 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12680 (let (gnus-mark-article-hook)
12681 (gnus-summary-select-article t t nil article)))
12683 (defun gnus-summary-toggle-display-buttonized ()
12684 "Toggle the buttonizing of the article buffer."
12686 (require 'gnus-art)
12687 (if (setq gnus-inhibit-mime-unbuttonizing
12688 (not gnus-inhibit-mime-unbuttonizing))
12689 (let ((gnus-unbuttonized-mime-types nil))
12690 (gnus-summary-show-article))
12691 (gnus-summary-show-article)))
12694 ;;; Generic summary marking commands
12697 (defvar gnus-summary-marking-alist
12698 '((read gnus-del-mark "d")
12699 (unread gnus-unread-mark "u")
12700 (ticked gnus-ticked-mark "!")
12701 (dormant gnus-dormant-mark "?")
12702 (expirable gnus-expirable-mark "e"))
12703 "An alist of names/marks/keystrokes.")
12705 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12706 (defvar gnus-summary-mark-map)
12708 (defun gnus-summary-make-all-marking-commands ()
12709 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12710 (dolist (elem gnus-summary-marking-alist)
12711 (apply 'gnus-summary-make-marking-command elem)))
12713 (defun gnus-summary-make-marking-command (name mark keystroke)
12714 (let ((map (make-sparse-keymap)))
12715 (define-key gnus-summary-generic-mark-map keystroke map)
12716 (dolist (lway `((next "next" next nil "n")
12717 (next-unread "next unread" next t "N")
12718 (prev "previous" prev nil "p")
12719 (prev-unread "previous unread" prev t "P")
12720 (nomove "" nil nil ,keystroke)))
12721 (let ((func (gnus-summary-make-marking-command-1
12722 mark (car lway) lway name)))
12723 (setq func (eval func))
12724 (define-key map (nth 4 lway) func)))))
12726 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12728 (format "gnus-summary-put-mark-as-%s%s"
12729 name (if (eq way 'nomove)
12731 (concat "-" (symbol-name way)))))
12734 "Mark the current article as %s%s.
12735 If N, the prefix, then repeat N times.
12736 If N is negative, move in reverse order.
12737 The difference between N and the actual number of articles marked is
12741 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12743 (defun gnus-summary-generic-mark (n mark move unread)
12744 "Mark N articles with MARK."
12745 (unless (eq major-mode 'gnus-summary-mode)
12746 (error "This command can only be used in the summary buffer"))
12747 (gnus-summary-show-thread)
12750 ((eq move 'next) 1)
12751 ((eq move 'prev) -1)
12753 (if (zerop nummove)
12757 nummove (* -1 nummove))))
12758 (while (and (> n 0)
12759 (gnus-summary-mark-article nil mark)
12760 (zerop (gnus-summary-next-subject nummove unread t)))
12763 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12764 (gnus-summary-recenter)
12765 (gnus-summary-position-point)
12766 (gnus-set-mode-line 'summary)
12769 (defun gnus-summary-insert-articles (articles)
12770 (when (setq articles
12771 (gnus-sorted-difference articles
12772 (mapcar (lambda (h)
12773 (mail-header-number h))
12774 gnus-newsgroup-headers)))
12775 (setq gnus-newsgroup-headers
12777 gnus-newsgroup-headers
12778 (gnus-fetch-headers articles)
12779 'gnus-article-sort-by-number))
12780 (setq gnus-newsgroup-articles
12781 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12782 ;; Suppress duplicates?
12783 (when gnus-suppress-duplicates
12784 (gnus-dup-suppress-articles))
12786 (if (and gnus-fetch-old-headers
12787 (eq gnus-headers-retrieved-by 'nov))
12788 ;; We might want to build some more threads first.
12789 (if (eq gnus-fetch-old-headers 'invisible)
12790 (gnus-build-all-threads)
12791 (gnus-build-old-threads))
12792 ;; Mark the inserted articles that are unread as unread.
12793 (setq gnus-newsgroup-unreads
12794 (gnus-sorted-nunion
12795 gnus-newsgroup-unreads
12796 (gnus-sorted-nintersection
12797 (gnus-list-of-unread-articles gnus-newsgroup-name)
12799 ;; Mark the inserted articles as selected so that the information
12800 ;; of the marks having been changed by a user may be updated when
12801 ;; exiting this group. See `gnus-summary-update-info'.
12802 (dolist (art articles)
12803 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12804 ;; Let the Gnus agent mark articles as read.
12806 (gnus-agent-get-undownloaded-list))
12807 ;; Remove list identifiers from subject
12808 (gnus-summary-remove-list-identifiers)
12809 ;; First and last article in this newsgroup.
12810 (when gnus-newsgroup-headers
12811 (setq gnus-newsgroup-begin
12812 (mail-header-number (car gnus-newsgroup-headers))
12814 (mail-header-number
12815 (gnus-last-element gnus-newsgroup-headers))))
12816 (when gnus-use-scoring
12817 (gnus-possibly-score-headers))))
12819 (defun gnus-summary-insert-old-articles (&optional all)
12820 "Insert all old articles in this group.
12821 If ALL is non-nil, already read articles become readable.
12822 If ALL is a number, fetch this number of articles."
12825 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12828 ;; Some nntp servers lie about their active range. When
12829 ;; this happens, the active range can be in the millions.
12830 ;; Use a compressed range to avoid creating a huge list.
12831 (gnus-range-difference (list gnus-newsgroup-active) old))
12832 (setq len (gnus-range-length older))
12837 (let ((older-range (nreverse older)))
12841 (let* ((r (pop older-range))
12842 (min (if (numberp r) r (car r)))
12843 (max (if (numberp r) r (cdr r))))
12844 (while (and (<= min max)
12849 (setq older (gnus-uncompress-range older))))
12851 (setq older (gnus-uncompress-range older)))
12853 (when (and (numberp gnus-large-newsgroup)
12854 (> len gnus-large-newsgroup))
12855 (let* ((cursor-in-echo-area nil)
12856 (initial (gnus-parameter-large-newsgroup-initial
12857 gnus-newsgroup-name))
12861 "How many articles from %s (%s %d): "
12862 (gnus-group-decoded-name gnus-newsgroup-name)
12863 (if initial "max" "default")
12867 (number-to-string initial)))))
12868 (unless (string-match "^[ \t]*$" input)
12869 (setq all (string-to-number input))
12871 (let ((older-range (nreverse older)))
12875 (let* ((r (pop older-range))
12876 (min (if (numberp r) r (car r)))
12877 (max (if (numberp r) r (cdr r))))
12878 (while (and (<= min max)
12882 max (1- max))))))))))
12883 (setq older (gnus-uncompress-range older))))
12885 (message "No old news.")
12886 (gnus-summary-insert-articles older)
12887 (gnus-summary-limit (gnus-sorted-nunion old older))))
12888 (gnus-summary-position-point)))
12890 (defun gnus-summary-insert-new-articles ()
12891 "Insert all new articles in this group."
12893 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12894 (old-high gnus-newsgroup-highest)
12895 (nnmail-fetched-sources (list t))
12896 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12899 (error "Couldn't fetch new data"))
12900 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12901 (setq i (cdr gnus-newsgroup-active)
12902 gnus-newsgroup-highest i)
12903 (while (> i old-high)
12907 (message "No gnus is bad news")
12908 (gnus-summary-insert-articles new)
12909 (setq gnus-newsgroup-unreads
12910 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12911 (gnus-summary-limit (gnus-sorted-nunion old new))))
12912 (gnus-summary-position-point))
12914 ;;; Bookmark support for Gnus.
12915 (declare-function bookmark-make-record-default
12916 "bookmark" (&optional no-file no-context posn))
12917 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12918 (declare-function bookmark-default-handler "bookmark" (bmk))
12919 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12920 (defvar bookmark-yank-point)
12921 (defvar bookmark-current-buffer)
12923 (defun gnus-summary-bookmark-make-record ()
12924 "Make a bookmark entry for a Gnus summary buffer."
12926 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12927 (save-restriction ; FIXME is it necessary to widen?
12928 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12929 (setq buf "art") ; We are recording bookmark from article buffer.
12930 (setq bookmark-yank-point (point))
12931 (setq bookmark-current-buffer (current-buffer))
12932 (gnus-article-show-summary)) ; Go back in summary buffer.
12933 ;; We are now recording bookmark from summary buffer.
12934 (unless buf (setq buf "sum"))
12935 (let* ((subject (elt (gnus-summary-article-header) 1))
12936 (grp (car gnus-article-current))
12937 (art (cdr gnus-article-current))
12938 (head (gnus-summary-article-header art))
12939 (id (mail-header-id head)))
12941 ,@(condition-case nil
12942 (bookmark-make-record-default 'no-file 'no-context pos)
12943 (wrong-number-of-arguments
12944 (bookmark-make-record-default 'point-only)))
12945 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12946 (group . ,grp) (article . ,art)
12947 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12950 (defun gnus-summary-bookmark-jump (bookmark)
12951 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12952 BOOKMARK is a bookmark name or a bookmark record."
12953 (let ((group (bookmark-prop-get bookmark 'group))
12954 (article (bookmark-prop-get bookmark 'article))
12955 (id (bookmark-prop-get bookmark 'message-id))
12956 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12957 (gnus-fetch-group group (list article))
12958 (gnus-summary-insert-cached-articles)
12959 (gnus-summary-goto-article id nil 'force)
12960 ;; FIXME we have to wait article buffer is ready (only large buffer)
12961 ;; Is there a better solution to know that?
12962 ;; If we don't wait `bookmark-default-handler' will have no chance
12963 ;; to set position. However there is no error, just wrong pos.
12965 (when (string= buf "Gnus-art")
12967 (bookmark-default-handler
12969 (buffer . ,(current-buffer))
12970 . ,(bookmark-get-bookmark-record bookmark)))))
12972 (gnus-summary-make-all-marking-commands)
12974 (gnus-ems-redefine)
12976 (provide 'gnus-sum)
12978 (run-hooks 'gnus-sum-load-hook)
12980 ;; Local Variables:
12981 ;; coding: iso-8859-1
12984 ;;; gnus-sum.el ends here