1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2016 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 (when (featurep 'xemacs)
31 (require 'easy-mmode))) ; for `define-minor-mode'
33 (defvar tool-bar-mode)
34 (defvar gnus-tmp-header)
47 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
48 (autoload 'gnus-cache-write-active "gnus-cache")
49 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
50 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
51 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
52 (autoload 'mm-uu-dissect "mm-uu")
53 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
54 "Deuglify broken Outlook (Express) articles and redisplay."
56 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
57 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
58 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
59 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
60 (autoload 'nnir-article-group "nnir" nil nil 'macro)
62 (defcustom gnus-kill-summary-on-exit t
63 "*If non-nil, kill the summary buffer when you exit from it.
64 If nil, the summary will become a \"*Dead Summary*\" buffer, and
65 it will be killed sometime later."
66 :group 'gnus-summary-exit
69 (defcustom gnus-summary-next-group-on-exit t
70 "If non-nil, go to the next unread newsgroup on summary exit.
71 See `gnus-group-goto-unread'."
72 :link '(custom-manual "(gnus)Group Maneuvering")
73 :group 'gnus-summary-exit
74 :version "23.1" ;; No Gnus
77 (defcustom gnus-summary-stop-at-end-of-message nil
78 "If non-nil, don't select the next message when using `SPC'."
79 :link '(custom-manual "(gnus)Group Maneuvering")
80 :group 'gnus-summary-maneuvering
84 (defcustom gnus-fetch-old-headers nil
85 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
86 If an unread article in the group refers to an older, already
87 read (or just marked as read) article, the old article will not
88 normally be displayed in the Summary buffer. If this variable is
89 t, Gnus will attempt to grab the headers to the old articles, and
90 thereby build complete threads. If it has the value `some', all
91 old headers will be fetched but only enough headers to connect
92 otherwise loose threads will be displayed. This variable can
93 also be a number. In that case, no more than that number of old
94 headers will be fetched. If it has the value `invisible', all
95 old headers will be fetched, but none will be displayed.
97 The server has to support NOV for any of this to work.
99 This feature can seriously impact performance it ignores all
100 locally cached header entries. Setting it to t for groups for a
101 server that doesn't expire articles (such as news.gmane.org),
102 leads to very slow summary generation."
104 :type '(choice (const :tag "off" nil)
109 (sexp :menu-tag "other" t)))
111 (defcustom gnus-refer-thread-limit 500
112 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
113 If t, fetch all the available old headers."
115 :type '(choice number
116 (sexp :menu-tag "other" t)))
118 (defcustom gnus-refer-thread-use-nnir nil
119 "*Use nnir to search an entire server when referring threads. A
120 nil value will only search for thread-related articles in the
126 (defcustom gnus-summary-make-false-root 'adopt
127 "*nil means that Gnus won't gather loose threads.
128 If the root of a thread has expired or been read in a previous
129 session, the information necessary to build a complete thread has been
130 lost. Instead of having many small sub-threads from this original thread
131 scattered all over the summary buffer, Gnus can gather them.
133 If non-nil, Gnus will try to gather all loose sub-threads from an
134 original thread into one large thread.
136 If this variable is non-nil, it should be one of `none', `adopt',
139 If this variable is `none', Gnus will not make a false root, but just
140 present the sub-threads after another.
141 If this variable is `dummy', Gnus will create a dummy root that will
142 have all the sub-threads as children.
143 If this variable is `adopt', Gnus will make one of the \"children\"
144 the parent and mark all the step-children as such.
145 If this variable is `empty', the \"children\" are printed with empty
146 subject fields. (Or rather, they will be printed with a string
147 given by the `gnus-summary-same-subject' variable.)"
149 :type '(choice (const :tag "off" nil)
155 (defcustom gnus-summary-make-false-root-always nil
156 "Always make a false dummy root."
161 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
162 "*A regexp to match subjects to be excluded from loose thread gathering.
163 As loose thread gathering is done on subjects only, that means that
164 there can be many false gatherings performed. By rooting out certain
165 common subjects, gathering might become saner."
169 (defcustom gnus-summary-gather-subject-limit nil
170 "*Maximum length of subject comparisons when gathering loose threads.
171 Use nil to compare full subjects. Setting this variable to a low
172 number will help gather threads that have been corrupted by
173 newsreaders chopping off subject lines, but it might also mean that
174 unrelated articles that have subject that happen to begin with the
175 same few characters will be incorrectly gathered.
177 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
180 :type '(choice (const :tag "off" nil)
182 (sexp :menu-tag "on" t)))
184 (defcustom gnus-simplify-subject-functions nil
185 "List of functions taking a string argument that simplify subjects.
186 The functions are applied recursively.
188 Useful functions to put in this list include:
189 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
190 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
192 :type '(repeat function))
194 (defcustom gnus-simplify-ignored-prefixes nil
195 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
197 :type '(choice (const :tag "off" nil)
200 (defcustom gnus-build-sparse-threads nil
201 "*If non-nil, fill in the gaps in threads.
202 If `some', only fill in the gaps that are needed to tie loose threads
203 together. If `more', fill in all leaf nodes that Gnus can find. If
204 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
206 :type '(choice (const :tag "off" nil)
209 (sexp :menu-tag "all" t)))
211 (defcustom gnus-summary-thread-gathering-function
212 'gnus-gather-threads-by-subject
213 "*Function used for gathering loose threads.
214 There are two pre-defined functions: `gnus-gather-threads-by-subject',
215 which only takes Subjects into consideration; and
216 `gnus-gather-threads-by-references', which compared the References
217 headers of the articles to find matches."
219 :type '(radio (function-item gnus-gather-threads-by-subject)
220 (function-item gnus-gather-threads-by-references)
221 (function :tag "other")))
223 (defcustom gnus-summary-same-subject ""
224 "*String indicating that the current article has the same subject as the previous.
225 This variable will only be used if the value of
226 `gnus-summary-make-false-root' is `empty'."
227 :group 'gnus-summary-format
230 (defcustom gnus-summary-goto-unread nil
231 "*If t, many commands will go to the next unread article.
232 This applies to marking commands as well as other commands that
233 \"naturally\" select the next article, like, for instance, `SPC' at
234 the end of an article.
236 If nil, the marking commands do NOT go to the next unread article
237 \(they go to the next article instead). If `never', commands that
238 usually go to the next unread article, will go to the next article,
239 whether it is read or not."
241 :group 'gnus-summary-marks
242 :link '(custom-manual "(gnus)Setting Marks")
243 :type '(choice (const :tag "off" nil)
245 (sexp :menu-tag "on" t)))
247 (defcustom gnus-summary-default-score 0
248 "*Default article score level.
249 All scores generated by the score files will be added to this score.
250 If this variable is nil, scoring will be disabled."
251 :group 'gnus-score-default
252 :type '(choice (const :tag "disable")
255 (defcustom gnus-summary-default-high-score 0
256 "*Default threshold for a high scored article.
257 An article will be highlighted as high scored if its score is greater
260 :group 'gnus-score-default
263 (defcustom gnus-summary-default-low-score 0
264 "*Default threshold for a low scored article.
265 An article will be highlighted as low scored if its score is smaller
268 :group 'gnus-score-default
271 (defcustom gnus-summary-zcore-fuzz 0
272 "*Fuzziness factor for the zcore in the summary buffer.
273 Articles with scores closer than this to `gnus-summary-default-score'
275 :group 'gnus-summary-format
278 (defcustom gnus-simplify-subject-fuzzy-regexp nil
279 "*Strings to be removed when doing fuzzy matches.
280 This can either be a regular expression or list of regular expressions
281 that will be removed from subject strings if fuzzy subject
282 simplification is selected."
284 :type '(repeat regexp))
286 (defcustom gnus-show-threads t
287 "*If non-nil, display threads in summary mode."
291 (defcustom gnus-thread-hide-subtree nil
292 "*If non-nil, hide all threads initially.
293 This can be a predicate specifier which says which threads to hide.
294 If threads are hidden, you have to run the command
295 `gnus-summary-show-thread' by hand or select an article."
297 :type '(radio (sexp :format "Non-nil\n"
298 :match (lambda (widget value)
299 (not (or (consp value) (functionp value))))
302 (sexp :tag "Predicate specifier")))
304 (defcustom gnus-thread-hide-killed t
305 "*If non-nil, hide killed threads automatically."
309 (defcustom gnus-thread-ignore-subject t
310 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
311 If nil, articles that have different subjects from their parents will
312 start separate threads."
316 (defcustom gnus-thread-operation-ignore-subject t
317 "*If non-nil, subjects will be ignored when doing thread commands.
318 This affects commands like `gnus-summary-kill-thread' and
319 `gnus-summary-lower-thread'.
321 If this variable is nil, articles in the same thread with different
322 subjects will not be included in the operation in question. If this
323 variable is `fuzzy', only articles that have subjects that are fuzzily
324 equal will be included."
326 :type '(choice (const :tag "off" nil)
330 (defcustom gnus-thread-indent-level 4
331 "*Number that says how much each sub-thread should be indented."
335 (defcustom gnus-auto-extend-newsgroup t
336 "*If non-nil, extend newsgroup forward and backward when requested."
337 :group 'gnus-summary-choose
340 (defcustom gnus-auto-select-first t
341 "If non-nil, select an article on group entry.
342 An article is selected automatically when entering a group
343 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
344 `gnus-summary-catchup-and-goto-next-group'.
346 Which article is selected is controlled by the variable
347 `gnus-auto-select-subject'.
349 If you want to prevent automatic selection of articles in some
350 newsgroups, set the variable to nil in `gnus-select-group-hook'."
351 ;; Commands include...
352 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
353 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
354 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
355 :group 'gnus-group-select
356 :type '(choice (const :tag "none" nil)
357 (sexp :menu-tag "first" t)))
359 (defcustom gnus-auto-select-subject 'unseen-or-unread
360 "*Says what subject to place under point when entering a group.
362 This variable can either be the symbols `first' (place point on the
363 first subject), `unread' (place point on the subject line of the first
364 unread article), `best' (place point on the subject line of the
365 highest-scored article), `unseen' (place point on the subject line of
366 the first unseen article), `unseen-or-unread' (place point on the subject
367 line of the first unseen article or, if all articles have been seen, on the
368 subject line of the first unread article), or a function to be called to
369 place point on some subject line."
371 :group 'gnus-group-select
372 :type '(choice (const best)
376 (const unseen-or-unread)
377 (function :tag "Function to call")))
379 (defcustom gnus-auto-select-next t
380 "*If non-nil, offer to go to the next group from the end of the previous.
381 If the value is t and the next newsgroup is empty, Gnus will exit
382 summary mode and go back to group mode. If the value is neither nil
383 nor t, Gnus will select the following unread newsgroup. In
384 particular, if the value is the symbol `quietly', the next unread
385 newsgroup will be selected without any confirmation, and if it is
386 `almost-quietly', the next group will be selected without any
387 confirmation if you are located on the last article in the group.
388 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
389 will go to the next group without confirmation."
390 :group 'gnus-summary-maneuvering
391 :type '(choice (const :tag "off" nil)
393 (const almost-quietly)
394 (const slightly-quietly)
395 (sexp :menu-tag "on" t)))
397 (defcustom gnus-auto-select-same nil
398 "*If non-nil, select the next article with the same subject.
399 If there are no more articles with the same subject, go to
400 the first unread article."
401 :group 'gnus-summary-maneuvering
404 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
405 "What article should be selected after exiting an ephemeral group.
406 Valid values include:
409 Select the next article.
411 Select the next unread article.
413 Move the cursor to the next article. This is the default.
414 `next-unread-noselect'
415 Move the cursor to the next unread article.
417 If it has any other value or there is no next (unread) article, the
418 article selected before entering to the ephemeral group will appear."
419 :version "23.1" ;; No Gnus
420 :group 'gnus-summary-maneuvering
421 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
422 (const next) (const next-unread)
423 (const next-noselect) (const next-unread-noselect)
424 (sexp :tag "other" :value nil)))
426 (defcustom gnus-auto-goto-ignores 'unfetched
427 "*Says how to handle unfetched articles when maneuvering.
429 This variable can either be the symbols nil (maneuver to any
430 article), `undownloaded' (maneuvering while unplugged ignores articles
431 that have not been fetched), `always-undownloaded' (maneuvering always
432 ignores articles that have not been fetched), `unfetched' (maneuvering
433 ignores articles whose headers have not been fetched).
435 NOTE: The list of unfetched articles will always be nil when plugged
436 and, when unplugged, a subset of the undownloaded article list."
438 :group 'gnus-summary-maneuvering
439 :type '(choice (const :tag "None" nil)
440 (const :tag "Undownloaded when unplugged" undownloaded)
441 (const :tag "Undownloaded" always-undownloaded)
442 (const :tag "Unfetched" unfetched)))
444 (defcustom gnus-summary-check-current nil
445 "*If non-nil, consider the current article when moving.
446 The \"unread\" movement commands will stay on the same line if the
447 current article is unread."
448 :group 'gnus-summary-maneuvering
451 (defcustom gnus-auto-center-summary
452 (max (or (bound-and-true-p scroll-margin) 0) 2)
453 "*If non-nil, always center the current summary buffer.
454 In particular, if `vertical' do only vertical recentering. If non-nil
455 and non-`vertical', do both horizontal and vertical recentering."
456 :group 'gnus-summary-maneuvering
457 :type '(choice (const :tag "none" nil)
459 (integer :tag "height")
460 (sexp :menu-tag "both" t)))
462 (defcustom gnus-auto-center-group t
463 "If non-nil, always center the group buffer."
464 :group 'gnus-summary-maneuvering
467 (defcustom gnus-show-all-headers nil
468 "*If non-nil, don't hide any headers."
469 :group 'gnus-article-hiding
470 :group 'gnus-article-headers
473 (defcustom gnus-summary-ignore-duplicates nil
474 "*If non-nil, ignore articles with identical Message-ID headers."
478 (defcustom gnus-single-article-buffer nil
479 "*If non-nil, display all articles in the same buffer.
480 If nil, each group will get its own article buffer."
482 :group 'gnus-article-various
485 (defcustom gnus-widen-article-window nil
486 "If non-nil, selecting the article buffer will display only the article buffer."
488 :group 'gnus-article-various
491 (defcustom gnus-break-pages t
492 "*If non-nil, do page breaking on articles.
493 The page delimiter is specified by the `gnus-page-delimiter'
495 :group 'gnus-article-various
498 (defcustom gnus-move-split-methods nil
499 "*Variable used to suggest where articles are to be moved to.
500 It uses the same syntax as the `gnus-split-methods' variable.
501 However, whereas `gnus-split-methods' specifies file names as targets,
502 this variable specifies group names."
503 :group 'gnus-summary-mail
504 :type '(repeat (choice (list :value (fun) function)
505 (cons :value ("" "") regexp (repeat string))
508 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
509 "Function used to compute default prefix for article move/copy/etc prompts.
510 The function should take one argument, a group name, and return a
511 string with the suggested prefix."
512 :group 'gnus-summary-mail
515 ;; FIXME: Although the custom type is `character' for the following variables,
516 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
518 (defcustom gnus-unread-mark ? ;Whitespace
519 "*Mark used for unread articles."
520 :group 'gnus-summary-marks
523 (defcustom gnus-ticked-mark ?!
524 "*Mark used for ticked articles."
525 :group 'gnus-summary-marks
528 (defcustom gnus-dormant-mark ??
529 "*Mark used for dormant articles."
530 :group 'gnus-summary-marks
533 (defcustom gnus-del-mark ?r
534 "*Mark used for del'd articles."
535 :group 'gnus-summary-marks
538 (defcustom gnus-read-mark ?R
539 "*Mark used for read articles."
540 :group 'gnus-summary-marks
543 (defcustom gnus-expirable-mark ?E
544 "*Mark used for expirable articles."
545 :group 'gnus-summary-marks
548 (defcustom gnus-killed-mark ?K
549 "*Mark used for killed articles."
550 :group 'gnus-summary-marks
553 (defcustom gnus-spam-mark ?$
554 "*Mark used for spam articles."
556 :group 'gnus-summary-marks
559 (defcustom gnus-kill-file-mark ?X
560 "*Mark used for articles killed by kill files."
561 :group 'gnus-summary-marks
564 (defcustom gnus-low-score-mark ?Y
565 "*Mark used for articles with a low score."
566 :group 'gnus-summary-marks
569 (defcustom gnus-catchup-mark ?C
570 "*Mark used for articles that are caught up."
571 :group 'gnus-summary-marks
574 (defcustom gnus-replied-mark ?A
575 "*Mark used for articles that have been replied to."
576 :group 'gnus-summary-marks
579 (defcustom gnus-forwarded-mark ?F
580 "*Mark used for articles that have been forwarded."
582 :group 'gnus-summary-marks
585 (defcustom gnus-recent-mark ?N
586 "*Mark used for articles that are recent."
588 :group 'gnus-summary-marks
591 (defcustom gnus-cached-mark ?*
592 "*Mark used for articles that are in the cache."
593 :group 'gnus-summary-marks
596 (defcustom gnus-saved-mark ?S
597 "*Mark used for articles that have been saved."
598 :group 'gnus-summary-marks
601 (defcustom gnus-unseen-mark ?.
602 "*Mark used for articles that haven't been seen."
604 :group 'gnus-summary-marks
607 (defcustom gnus-no-mark ? ;Whitespace
608 "*Mark used for articles that have no other secondary mark."
610 :group 'gnus-summary-marks
613 (defcustom gnus-ancient-mark ?O
614 "*Mark used for ancient articles."
615 :group 'gnus-summary-marks
618 (defcustom gnus-sparse-mark ?Q
619 "*Mark used for sparsely reffed articles."
620 :group 'gnus-summary-marks
623 (defcustom gnus-canceled-mark ?G
624 "*Mark used for canceled articles."
625 :group 'gnus-summary-marks
628 (defcustom gnus-duplicate-mark ?M
629 "*Mark used for duplicate articles."
630 :group 'gnus-summary-marks
633 (defcustom gnus-undownloaded-mark ?-
634 "*Mark used for articles that weren't downloaded."
636 :group 'gnus-summary-marks
639 (defcustom gnus-downloaded-mark ?+
640 "*Mark used for articles that were downloaded."
641 :group 'gnus-summary-marks
644 (defcustom gnus-downloadable-mark ?%
645 "*Mark used for articles that are to be downloaded."
646 :group 'gnus-summary-marks
649 (defcustom gnus-unsendable-mark ?=
650 "*Mark used for articles that won't be sent."
651 :group 'gnus-summary-marks
654 (defcustom gnus-score-over-mark ?+
655 "*Score mark used for articles with high scores."
656 :group 'gnus-summary-marks
659 (defcustom gnus-score-below-mark ?-
660 "*Score mark used for articles with low scores."
661 :group 'gnus-summary-marks
664 (defcustom gnus-empty-thread-mark ? ;Whitespace
665 "*There is no thread under the article."
666 :group 'gnus-summary-marks
669 (defcustom gnus-not-empty-thread-mark ?=
670 "*There is a thread under the article."
671 :group 'gnus-summary-marks
674 (defcustom gnus-view-pseudo-asynchronously nil
675 "*If non-nil, Gnus will view pseudo-articles asynchronously."
676 :group 'gnus-extract-view
679 (defcustom gnus-auto-expirable-marks
680 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
681 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
683 "*The list of marks converted into expiration if a group is auto-expirable."
686 :type '(repeat character))
688 (defcustom gnus-inhibit-user-auto-expire t
689 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
694 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
695 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
696 If nil, the expirable marks will be unchanged except that the marks
697 will be removed when copying or moving articles to a group that has
698 not turned auto-expire on. If non-nil, articles that have been read
699 will be marked as expirable when being copied or moved to a group in
700 which auto-expire is turned on."
703 :group 'gnus-summary-marks)
705 (defcustom gnus-view-pseudos nil
706 "*If `automatic', pseudo-articles will be viewed automatically.
707 If `not-confirm', pseudos will be viewed automatically, and the user
708 will not be asked to confirm the command."
709 :group 'gnus-extract-view
710 :type '(choice (const :tag "off" nil)
712 (const not-confirm)))
714 (defcustom gnus-view-pseudos-separately t
715 "*If non-nil, one pseudo-article will be created for each file to be viewed.
716 If nil, all files that use the same viewing command will be given as a
717 list of parameters to that command."
718 :group 'gnus-extract-view
721 (defcustom gnus-insert-pseudo-articles t
722 "*If non-nil, insert pseudo-articles when decoding articles."
723 :group 'gnus-extract-view
726 (defcustom gnus-summary-dummy-line-format
728 "*The format specification for the dummy roots in the summary buffer.
729 It works along the same lines as a normal formatting string,
730 with some simple extensions.
734 General format specifiers can also be used.
735 See `(gnus)Formatting Variables'."
736 :link '(custom-manual "(gnus)Formatting Variables")
737 :group 'gnus-threading
740 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
741 "*The format specification for the summary mode line.
742 It works along the same lines as a normal formatting string,
743 with some simple extensions:
746 %p Unprefixed group name
747 %A Current article number
748 %z Current article score
750 %U Number of unread articles in the group
751 %e Number of unselected articles in the group
752 %Z A string with unread/unselected article counts
753 %g Shortish group name
754 %S Subject of the current article
756 %s Current score file name
757 %d Number of dormant articles
758 %r Number of articles that have been marked as read in this session
759 %E Number of articles expunged by the score files"
760 :group 'gnus-summary-format
763 (defcustom gnus-list-identifiers nil
764 "Regexp that matches list identifiers to be removed from subject.
765 This can also be a list of regexps."
767 :group 'gnus-summary-format
768 :group 'gnus-article-hiding
769 :type '(choice (const :tag "none" nil)
771 (repeat :value (".*") regexp)))
773 (defcustom gnus-summary-mark-below 0
774 "*Mark all articles with a score below this variable as read.
775 This variable is local to each summary buffer and usually set by the
777 :group 'gnus-score-default
780 (defun gnus-widget-reversible-match (widget value)
781 "Ignoring WIDGET, convert VALUE to internal form.
782 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
786 (eq (length value) 2)
787 (eq (nth 0 value) 'not)
788 (symbolp (nth 1 value)))))
790 (defun gnus-widget-reversible-to-internal (widget value)
791 "Ignoring WIDGET, convert VALUE to internal form.
792 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
793 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
797 (list (nth 1 value) t)))
799 (defun gnus-widget-reversible-to-external (widget value)
800 "Ignoring WIDGET, convert VALUE to external form.
801 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
802 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
805 (list 'not (nth 0 value))
808 (define-widget 'gnus-widget-reversible 'group
809 "A `group' that convert values."
810 :match 'gnus-widget-reversible-match
811 :value-to-internal 'gnus-widget-reversible-to-internal
812 :value-to-external 'gnus-widget-reversible-to-external)
814 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
815 "*List of functions used for sorting articles in the summary buffer.
817 Each function takes two articles and returns non-nil if the first
818 article should be sorted before the other. If you use more than one
819 function, the primary sort function should be the last. You should
820 probably always include `gnus-article-sort-by-number' in the list of
821 sorting functions -- preferably first. Also note that sorting by date
822 is often much slower than sorting by number, and the sorting order is
823 very similar. (Sorting by date means sorting by the time the message
824 was sent, sorting by number means sorting by arrival time.)
826 Each item can also be a list `(not F)' where F is a function;
827 this reverses the sort order.
829 Ready-made functions include `gnus-article-sort-by-number',
830 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
831 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
832 and `gnus-article-sort-by-score'.
834 When threading is turned on, the variable `gnus-thread-sort-functions'
835 controls how articles are sorted."
836 :group 'gnus-summary-sort
837 :type '(repeat (gnus-widget-reversible
838 (choice (function-item gnus-article-sort-by-number)
839 (function-item gnus-article-sort-by-author)
840 (function-item gnus-article-sort-by-subject)
841 (function-item gnus-article-sort-by-date)
842 (function-item gnus-article-sort-by-score)
843 (function-item gnus-article-sort-by-random)
844 (function :tag "other"))
845 (boolean :tag "Reverse order"))))
847 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
848 "*List of functions used for sorting threads in the summary buffer.
849 By default, threads are sorted by article number.
851 Each function takes two threads and returns non-nil if the first
852 thread should be sorted before the other. If you use more than one
853 function, the primary sort function should be the last. You should
854 probably always include `gnus-thread-sort-by-number' in the list of
855 sorting functions -- preferably first. Also note that sorting by date
856 is often much slower than sorting by number, and the sorting order is
857 very similar. (Sorting by date means sorting by the time the message
858 was sent, sorting by number means sorting by arrival time.)
860 Each list item can also be a list `(not F)' where F is a
861 function; this specifies reversed sort order.
863 Ready-made functions include `gnus-thread-sort-by-number',
864 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
865 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
866 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
867 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
868 and `gnus-thread-sort-by-total-score' (see
869 `gnus-thread-score-function').
871 When threading is turned off, the variable
872 `gnus-article-sort-functions' controls how articles are sorted.
874 By default, threads and their subthreads are sorted according to
875 the value of this variable. To use a different sorting order for
876 subthreads, customize `gnus-subthread-sort-functions'."
877 :group 'gnus-summary-sort
879 (gnus-widget-reversible
880 (choice (function-item gnus-thread-sort-by-number)
881 (function-item gnus-thread-sort-by-author)
882 (function-item gnus-thread-sort-by-recipient)
883 (function-item gnus-thread-sort-by-subject)
884 (function-item gnus-thread-sort-by-date)
885 (function-item gnus-thread-sort-by-score)
886 (function-item gnus-thread-sort-by-most-recent-number)
887 (function-item gnus-thread-sort-by-most-recent-date)
888 (function-item gnus-thread-sort-by-random)
889 (function-item gnus-thread-sort-by-total-score)
890 (function :tag "other"))
891 (boolean :tag "Reverse order"))))
893 (defcustom gnus-subthread-sort-functions 'gnus-thread-sort-functions
894 "*List of functions used for sorting subthreads in the summary buffer.
895 By default, subthreads are sorted the same as threads, i.e.,
896 according to the value of `gnus-thread-sort-functions'."
898 :group 'gnus-summary-sort
900 (const :tag "Sort subthreads like threads" gnus-thread-sort-functions)
902 (gnus-widget-reversible
903 (choice (function-item gnus-thread-sort-by-number)
904 (function-item gnus-thread-sort-by-author)
905 (function-item gnus-thread-sort-by-recipient)
906 (function-item gnus-thread-sort-by-subject)
907 (function-item gnus-thread-sort-by-date)
908 (function-item gnus-thread-sort-by-score)
909 (function-item gnus-thread-sort-by-most-recent-number)
910 (function-item gnus-thread-sort-by-most-recent-date)
911 (function-item gnus-thread-sort-by-random)
912 (function-item gnus-thread-sort-by-total-score)
913 (function :tag "other"))
914 (boolean :tag "Reverse order")))))
916 (defcustom gnus-thread-score-function '+
917 "*Function used for calculating the total score of a thread.
919 The function is called with the scores of the article and each
920 subthread and should then return the score of the thread.
922 Some functions you can use are `+', `max', or `min'."
923 :group 'gnus-summary-sort
926 (defcustom gnus-summary-expunge-below nil
927 "All articles that have a score less than this variable will be expunged.
928 This variable is local to the summary buffers."
929 :group 'gnus-score-default
930 :type '(choice (const :tag "off" nil)
933 (defcustom gnus-thread-expunge-below nil
934 "All threads that have a total score less than this variable will be expunged.
935 See `gnus-thread-score-function' for en explanation of what a
938 This variable is local to the summary buffers."
939 :group 'gnus-threading
940 :group 'gnus-score-default
941 :type '(choice (const :tag "off" nil)
944 (defcustom gnus-summary-mode-hook nil
945 "*A hook for Gnus summary mode.
946 This hook is run before any variables are set in the summary buffer."
947 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
948 :group 'gnus-summary-various
951 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
952 (when (featurep 'xemacs)
953 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
954 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
955 (add-hook 'gnus-summary-mode-hook
956 'gnus-xmas-switch-horizontal-scrollbar-off))
958 (defcustom gnus-summary-menu-hook nil
959 "*Hook run after the creation of the summary mode menu."
960 :group 'gnus-summary-visual
963 (defcustom gnus-summary-exit-hook nil
964 "*A hook called on exit from the summary buffer.
965 It will be called with point in the group buffer."
966 :group 'gnus-summary-exit
969 (defcustom gnus-summary-prepare-hook nil
970 "*A hook called after the summary buffer has been generated.
971 If you want to modify the summary buffer, you can use this hook."
972 :group 'gnus-summary-various
975 (defcustom gnus-summary-prepared-hook nil
976 "*A hook called as the last thing after the summary buffer has been generated."
977 :group 'gnus-summary-various
980 (defcustom gnus-summary-generate-hook nil
981 "*A hook run just before generating the summary buffer.
982 This hook is commonly used to customize threading variables and the
984 :group 'gnus-summary-various
987 (defcustom gnus-select-group-hook nil
988 "*A hook called when a newsgroup is selected.
990 If you'd like to simplify subjects like the
991 `gnus-summary-next-same-subject' command does, you can use the
994 (add-hook gnus-select-group-hook
996 (mapcar (lambda (header)
997 (mail-header-set-subject
999 (gnus-simplify-subject
1000 (mail-header-subject header) \\='re-only)))
1001 gnus-newsgroup-headers)))"
1002 :group 'gnus-group-select
1005 (defcustom gnus-select-article-hook nil
1006 "*A hook called when an article is selected."
1007 :group 'gnus-summary-choose
1008 :options '(gnus-agent-fetch-selected-article)
1011 (defcustom gnus-visual-mark-article-hook
1012 (list 'gnus-highlight-selected-summary)
1013 "*Hook run after selecting an article in the summary buffer.
1014 It is meant to be used for highlighting the article in some way. It
1015 is not run if `gnus-visual' is nil."
1016 :group 'gnus-summary-visual
1019 (defcustom gnus-parse-headers-hook nil
1020 "*A hook called before parsing the headers."
1021 :group 'gnus-various
1024 (defcustom gnus-exit-group-hook nil
1025 "*A hook called when exiting summary mode.
1026 This hook is not called from the non-updating exit commands like `Q'."
1027 :group 'gnus-various
1030 (defcustom gnus-summary-update-hook nil
1031 "*A hook called when a summary line is changed.
1032 The hook will not be called if `gnus-visual' is nil.
1034 The default function `gnus-summary-highlight-line' will
1035 highlight the line according to the `gnus-summary-highlight'
1037 :group 'gnus-summary-visual
1040 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1041 "*A hook called when an article is selected for the first time.
1042 The hook is intended to mark an article as read (or unread)
1043 automatically when it is selected."
1044 :group 'gnus-summary-choose
1047 (defcustom gnus-group-no-more-groups-hook nil
1048 "*A hook run when returning to group mode having no more (unread) groups."
1049 :group 'gnus-group-select
1052 (defcustom gnus-ps-print-hook nil
1053 "*A hook run before ps-printing something from Gnus."
1054 :group 'gnus-summary
1057 (defcustom gnus-summary-article-move-hook nil
1058 "*A hook called after an article is moved, copied, respooled, or crossposted."
1060 :group 'gnus-summary
1063 (defcustom gnus-summary-article-delete-hook nil
1064 "*A hook called after an article is deleted."
1066 :group 'gnus-summary
1069 (defcustom gnus-summary-article-expire-hook nil
1070 "*A hook called after an article is expired."
1072 :group 'gnus-summary
1075 (defcustom gnus-summary-display-arrow
1076 (and (fboundp 'display-graphic-p)
1077 (display-graphic-p))
1078 "*If non-nil, display an arrow highlighting the current article."
1080 :group 'gnus-summary
1083 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1084 "Face used for highlighting the current article in the summary buffer."
1085 :group 'gnus-summary-visual
1088 (defvar gnus-tmp-downloaded nil)
1090 (defcustom gnus-summary-highlight
1091 '(((eq mark gnus-canceled-mark)
1092 . gnus-summary-cancelled)
1093 ((and uncached (> score default-high))
1094 . gnus-summary-high-undownloaded)
1095 ((and uncached (< score default-low))
1096 . gnus-summary-low-undownloaded)
1098 . gnus-summary-normal-undownloaded)
1099 ((and (> score default-high)
1100 (or (eq mark gnus-dormant-mark)
1101 (eq mark gnus-ticked-mark)))
1102 . gnus-summary-high-ticked)
1103 ((and (< score default-low)
1104 (or (eq mark gnus-dormant-mark)
1105 (eq mark gnus-ticked-mark)))
1106 . gnus-summary-low-ticked)
1107 ((or (eq mark gnus-dormant-mark)
1108 (eq mark gnus-ticked-mark))
1109 . gnus-summary-normal-ticked)
1110 ((and (> score default-high) (eq mark gnus-ancient-mark))
1111 . gnus-summary-high-ancient)
1112 ((and (< score default-low) (eq mark gnus-ancient-mark))
1113 . gnus-summary-low-ancient)
1114 ((eq mark gnus-ancient-mark)
1115 . gnus-summary-normal-ancient)
1116 ((and (> score default-high) (eq mark gnus-unread-mark))
1117 . gnus-summary-high-unread)
1118 ((and (< score default-low) (eq mark gnus-unread-mark))
1119 . gnus-summary-low-unread)
1120 ((eq mark gnus-unread-mark)
1121 . gnus-summary-normal-unread)
1122 ((> score default-high)
1123 . gnus-summary-high-read)
1124 ((< score default-low)
1125 . gnus-summary-low-read)
1127 . gnus-summary-normal-read))
1128 "*Controls the highlighting of summary buffer lines.
1130 A list of (FORM . FACE) pairs. When deciding how a particular
1131 summary line should be displayed, each form is evaluated. The content
1132 of the face field after the first true form is used. You can change
1133 how those summary lines are displayed, by editing the face field.
1135 You can use the following variables in the FORM field.
1137 score: The article's score.
1138 default: The default article score.
1139 default-high: The default score for high scored articles.
1140 default-low: The default score for low scored articles.
1141 mark: The article's mark.
1142 uncached: Non-nil if the article is uncached."
1143 :group 'gnus-summary-visual
1144 :type '(repeat (cons (sexp :tag "Form" nil)
1146 (put 'gnus-summary-highlight 'risky-local-variable t)
1148 (defcustom gnus-alter-header-function nil
1149 "Function called to allow alteration of article header structures.
1150 The function is called with one parameter, the article header vector,
1151 which it may alter in any way."
1152 :type '(choice (const :tag "None" nil)
1154 :group 'gnus-summary)
1156 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1157 "Function used to decode a string with encoded words.")
1159 (defvar gnus-decode-encoded-address-function
1160 'mail-decode-encoded-address-string
1161 "Function used to decode addresses with encoded words.")
1163 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups X-GM-LABELS)
1164 "*Extra headers to parse."
1166 :group 'gnus-summary
1167 :type '(repeat symbol))
1169 (defcustom gnus-ignored-from-addresses
1170 (and user-mail-address
1171 (not (string= user-mail-address ""))
1172 (regexp-quote user-mail-address))
1173 "*From headers that may be suppressed in favor of To headers.
1174 This can be a regexp, a list of regexps or a function.
1176 If a function, an email string is passed as the argument."
1178 :group 'gnus-summary
1179 :type '(choice regexp
1180 (repeat :tag "Regexp List" regexp)
1183 (defsubst gnus-ignored-from-addresses ()
1184 (cond ((functionp gnus-ignored-from-addresses)
1185 gnus-ignored-from-addresses)
1186 (t (gmm-regexp-concat gnus-ignored-from-addresses))))
1188 (defcustom gnus-summary-to-prefix "-> "
1189 "*String prefixed to the To field in the summary line when
1190 using `gnus-ignored-from-addresses'."
1192 :group 'gnus-summary
1195 (defcustom gnus-summary-newsgroup-prefix "=> "
1196 "*String prefixed to the Newsgroup field in the summary
1197 line when using the option `gnus-ignored-from-addresses'."
1199 :group 'gnus-summary
1202 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1203 "List of charsets that should be ignored.
1204 When these charsets are used in the \"charset\" parameter, the
1205 default charset will be used instead."
1207 :type '(repeat symbol)
1208 :group 'gnus-charset)
1210 (defcustom gnus-newsgroup-maximum-articles nil
1211 "The maximum number of articles a newsgroup.
1212 If this is a number, old articles in a newsgroup exceeding this number
1213 are silently ignored. If it is nil, no article is ignored. Note that
1214 setting this variable to a number might prevent you from reading very
1216 :group 'gnus-group-select
1218 :type '(choice (const :tag "No limit" nil)
1221 (gnus-define-group-parameter
1225 "Return the ignored charsets of GROUP."
1226 :variable gnus-group-ignored-charsets-alist
1228 '(("alt\\.chinese\\.text" iso-8859-1))
1230 "Alist of regexps (to match group names) and charsets that should be ignored.
1231 When these charsets are used in the \"charset\" parameter, the
1232 default charset will be used instead."
1233 :variable-group gnus-charset
1234 :variable-type '(repeat (cons (regexp :tag "Group")
1236 :parameter-type '(choice :tag "Ignored charsets"
1239 :parameter-document "\
1240 List of charsets that should be ignored.
1242 When these charsets are used in the \"charset\" parameter, the
1243 default charset will be used instead.")
1245 (defcustom gnus-group-highlight-words-alist nil
1246 "Alist of group regexps and highlight regexps.
1247 This variable uses the same syntax as `gnus-emphasis-alist'."
1249 :type '(repeat (cons (regexp :tag "Group")
1250 (repeat (list (regexp :tag "Highlight regexp")
1251 (number :tag "Group for entire word" 0)
1252 (number :tag "Group for displayed part" 0)
1254 gnus-emphasis-highlight-words)))))
1255 :group 'gnus-summary-visual)
1257 (defcustom gnus-summary-show-article-charset-alist
1259 "Alist of number and charset.
1260 The article will be shown with the charset corresponding to the
1262 For example: ((1 . cn-gb-2312) (2 . big5))."
1264 :type '(repeat (cons (number :tag "Argument" 1)
1265 (symbol :tag "Charset")))
1266 :group 'gnus-charset)
1268 (defcustom gnus-preserve-marks t
1269 "Whether marks are preserved when moving, copying and respooling messages."
1272 :group 'gnus-summary-marks)
1274 (defcustom gnus-alter-articles-to-read-function nil
1275 "Function to be called to alter the list of articles to be selected."
1276 :type '(choice (const nil) function)
1277 :group 'gnus-summary)
1279 (defcustom gnus-orphan-score nil
1280 "*All orphans get this score added. Set in the score file."
1281 :group 'gnus-score-default
1282 :type '(choice (const nil)
1285 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1286 "*A regexp to match MIME parts when saving multiple parts of a
1287 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1288 This regexp will be used by default when prompting the user for which
1289 type of files to save."
1290 :group 'gnus-summary
1293 (defcustom gnus-read-all-available-headers nil
1294 "Whether Gnus should parse all headers made available to it.
1295 This is mostly relevant for slow back ends where the user may
1296 wish to widen the summary buffer to include all headers
1299 :group 'gnus-summary
1300 :type '(choice boolean regexp))
1302 (defcustom gnus-summary-pipe-output-default-command nil
1303 "Command (and optional arguments) used to pipe article to subprocess.
1304 This will be used as the default command if it is non-nil. The value
1305 will be updated if you modify it when executing the command
1306 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1307 :version "23.1" ;; No Gnus
1308 :group 'gnus-summary
1309 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1311 (defcustom gnus-summary-muttprint-program "muttprint"
1312 "Command (and optional arguments) used to run Muttprint.
1313 The value will be updated if you modify it when executing the command
1314 `gnus-summary-muttprint'."
1316 :group 'gnus-summary
1319 (defcustom gnus-article-loose-mime t
1320 "If non-nil, don't require MIME-Version header.
1321 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1322 supply the MIME-Version header or deliberately strip it from the mail.
1323 If non-nil (the default), Gnus will treat some articles as MIME
1324 even if the MIME-Version header is missing."
1327 :group 'gnus-article-mime)
1329 (defcustom gnus-article-emulate-mime t
1330 "If non-nil, use MIME emulation for uuencode and the like.
1331 This means that Gnus will search message bodies for text that look
1332 like uuencoded bits, yEncoded bits, and so on, and present that using
1333 the normal Gnus MIME machinery."
1336 :group 'gnus-article-mime)
1338 ;;; Internal variables
1340 (defvar gnus-summary-display-cache nil)
1341 (defvar gnus-article-mime-handles nil)
1342 (defvar gnus-article-decoded-p nil)
1343 (defvar gnus-article-charset nil)
1344 (defvar gnus-article-ignored-charsets nil)
1345 (defvar gnus-scores-exclude-files nil)
1346 (defvar gnus-page-broken nil)
1348 (defvar gnus-original-article nil)
1349 (defvar gnus-article-internal-prepare-hook nil)
1350 (defvar gnus-newsgroup-process-stack nil)
1352 (defvar gnus-thread-indent-array nil)
1353 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1354 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1355 "Function called to sort the articles within a thread after it has been gathered together.")
1357 (defvar gnus-summary-save-parts-type-history nil)
1358 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1360 ;; Avoid highlighting in kill files.
1361 (defvar gnus-summary-inhibit-highlight nil)
1362 (defvar gnus-newsgroup-selected-overlay nil)
1363 (defvar gnus-inhibit-limiting nil)
1364 (defvar gnus-newsgroup-adaptive-score-file nil)
1365 (defvar gnus-current-score-file nil)
1366 (defvar gnus-current-move-group nil)
1367 (defvar gnus-current-copy-group nil)
1368 (defvar gnus-current-crosspost-group nil)
1369 (defvar gnus-newsgroup-display nil)
1371 (defvar gnus-newsgroup-dependencies nil)
1372 (defvar gnus-newsgroup-adaptive nil)
1373 (defvar gnus-summary-display-article-function nil)
1374 (defvar gnus-summary-highlight-line-function nil
1375 "Function called after highlighting a summary line.")
1377 (defvar gnus-summary-line-format-alist
1378 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1379 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1380 (?s gnus-tmp-subject-or-nil ?s)
1381 (?n gnus-tmp-name ?s)
1382 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1384 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1386 (?F gnus-tmp-from ?s)
1387 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1388 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1389 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1390 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1391 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1392 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1393 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1394 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1395 (?L gnus-tmp-lines ?s)
1396 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1398 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1400 (?g (or (gnus-group-short-name
1401 (nnir-article-group (mail-header-number gnus-tmp-header)))
1403 (?O gnus-tmp-downloaded ?c)
1404 (?I gnus-tmp-indentation ?s)
1405 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1406 (?R gnus-tmp-replied ?c)
1407 (?\[ gnus-tmp-opening-bracket ?c)
1408 (?\] gnus-tmp-closing-bracket ?c)
1409 (?\> (make-string gnus-tmp-level ? ) ?s)
1410 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1411 (?i gnus-tmp-score ?d)
1412 (?z gnus-tmp-score-char ?c)
1413 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1414 (?U gnus-tmp-unread ?c)
1415 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1417 (?t (gnus-summary-number-of-articles-in-thread
1418 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1420 (?e (gnus-summary-number-of-articles-in-thread
1421 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1423 (?u gnus-tmp-user-defined ?s)
1424 (?P (gnus-pick-line-number) ?d)
1425 (?B gnus-tmp-thread-tree-header-string ?s)
1426 (user-date (gnus-user-date
1427 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1428 "An alist of format specifications that can appear in summary lines.
1429 These are paired with what variables they correspond with, along with
1430 the type of the variable (string, integer, character, etc).")
1432 (defvar gnus-summary-dummy-line-format-alist
1433 `((?S gnus-tmp-subject ?s)
1434 (?N gnus-tmp-number ?d)
1435 (?u gnus-tmp-user-defined ?s)))
1437 (defvar gnus-summary-mode-line-format-alist
1438 `((?G gnus-tmp-group-name ?s)
1439 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1440 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1441 (?A gnus-tmp-article-number ?d)
1442 (?Z gnus-tmp-unread-and-unselected ?s)
1443 (?V gnus-version ?s)
1444 (?U gnus-tmp-unread-and-unticked ?d)
1445 (?S gnus-tmp-subject ?s)
1446 (?e gnus-tmp-unselected ?d)
1447 (?u gnus-tmp-user-defined ?s)
1448 (?d (length gnus-newsgroup-dormant) ?d)
1449 (?t (length gnus-newsgroup-marked) ?d)
1450 (?h (length gnus-newsgroup-spam-marked) ?d)
1451 (?r (length gnus-newsgroup-reads) ?d)
1452 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1453 (?E gnus-newsgroup-expunged-tally ?d)
1454 (?s (gnus-current-score-file-nondirectory) ?s)))
1456 ;; This is here rather than in gnus-art for compilation reasons.
1457 (defvar gnus-article-mode-line-format-alist
1458 (nconc '((?w (gnus-article-wash-status) ?s)
1459 (?m (gnus-article-mime-part-status) ?s))
1460 gnus-summary-mode-line-format-alist))
1462 (defvar gnus-last-search-regexp nil
1463 "Default regexp for article search command.")
1465 (defvar gnus-last-shell-command nil
1466 "Default shell command on article.")
1468 (defvar gnus-newsgroup-agentized nil
1469 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1470 (defvar gnus-newsgroup-begin nil)
1471 (defvar gnus-newsgroup-end nil)
1472 (defvar gnus-newsgroup-last-rmail nil)
1473 (defvar gnus-newsgroup-last-mail nil)
1474 (defvar gnus-newsgroup-last-folder nil)
1475 (defvar gnus-newsgroup-last-file nil)
1476 (defvar gnus-newsgroup-last-directory nil)
1477 (defvar gnus-newsgroup-auto-expire nil)
1478 (defvar gnus-newsgroup-active nil)
1479 (defvar gnus-newsgroup-highest nil)
1481 (defvar gnus-newsgroup-data nil)
1482 (defvar gnus-newsgroup-data-reverse nil)
1483 (defvar gnus-newsgroup-limit nil)
1484 (defvar gnus-newsgroup-limits nil)
1485 (defvar gnus-summary-use-undownloaded-faces nil)
1487 (defvar gnus-newsgroup-unreads nil
1488 "Sorted list of unread articles in the current newsgroup.")
1490 (defvar gnus-newsgroup-unselected nil
1491 "Sorted list of unselected unread articles in the current newsgroup.")
1493 (defvar gnus-newsgroup-reads nil
1494 "Alist of read articles and article marks in the current newsgroup.")
1496 (defvar gnus-newsgroup-expunged-tally nil)
1498 (defvar gnus-newsgroup-marked nil
1499 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1501 (defvar gnus-newsgroup-spam-marked nil
1502 "List of ranges of articles that have been marked as spam.")
1504 (defvar gnus-newsgroup-killed nil
1505 "List of ranges of articles that have been through the scoring process.")
1507 (defvar gnus-newsgroup-cached nil
1508 "Sorted list of articles that come from the article cache.")
1510 (defvar gnus-newsgroup-saved nil
1511 "List of articles that have been saved.")
1513 (defvar gnus-newsgroup-kill-headers nil)
1515 (defvar gnus-newsgroup-replied nil
1516 "List of articles that have been replied to in the current newsgroup.")
1518 (defvar gnus-newsgroup-forwarded nil
1519 "List of articles that have been forwarded in the current newsgroup.")
1521 (defvar gnus-newsgroup-expirable nil
1522 "Sorted list of articles in the current newsgroup that can be expired.")
1524 (defvar gnus-newsgroup-processable nil
1525 "List of articles in the current newsgroup that can be processed.")
1527 (defvar gnus-newsgroup-downloadable nil
1528 "Sorted list of articles in the current newsgroup that can be processed.")
1530 (defvar gnus-newsgroup-unfetched nil
1531 "Sorted list of articles in the current newsgroup whose headers have
1532 not been fetched into the agent.
1534 This list will always be a subset of gnus-newsgroup-undownloaded.")
1536 (defvar gnus-newsgroup-undownloaded nil
1537 "List of articles in the current newsgroup that haven't been downloaded.")
1539 (defvar gnus-newsgroup-unsendable nil
1540 "List of articles in the current newsgroup that won't be sent.")
1542 (defvar gnus-newsgroup-bookmarks nil
1543 "List of articles in the current newsgroup that have bookmarks.")
1545 (defvar gnus-newsgroup-dormant nil
1546 "Sorted list of dormant articles in the current newsgroup.")
1548 (defvar gnus-newsgroup-unseen nil
1549 "List of unseen articles in the current newsgroup.")
1551 (defvar gnus-newsgroup-seen nil
1552 "Range of seen articles in the current newsgroup.")
1554 (defvar gnus-newsgroup-unexist nil
1555 "Range of unexisting articles in the current newsgroup.")
1557 (defvar gnus-newsgroup-articles nil
1558 "List of articles in the current newsgroup.")
1560 (defvar gnus-newsgroup-scored nil
1561 "List of scored articles in the current newsgroup.")
1563 (defvar gnus-newsgroup-headers nil
1564 "List of article headers in the current newsgroup.")
1566 (defvar gnus-newsgroup-threads nil)
1568 (defvar gnus-newsgroup-prepared nil
1569 "Whether the current group has been prepared properly.")
1571 (defvar gnus-newsgroup-ancient nil
1572 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1574 (defvar gnus-newsgroup-sparse nil)
1576 (defvar gnus-current-article nil)
1577 (defvar gnus-article-current nil)
1578 (defvar gnus-current-headers nil)
1579 (defvar gnus-have-all-headers nil)
1580 (defvar gnus-last-article nil)
1581 (defvar gnus-newsgroup-history nil)
1582 (defvar gnus-newsgroup-charset nil)
1583 (defvar gnus-newsgroup-ephemeral-charset nil)
1584 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1586 (defvar gnus-article-before-search nil)
1588 (defvar gnus-summary-local-variables
1589 '(gnus-newsgroup-name
1592 gnus-newsgroup-unreads
1593 gnus-newsgroup-unselected
1594 gnus-newsgroup-marked
1595 gnus-newsgroup-spam-marked
1596 gnus-newsgroup-reads
1597 gnus-newsgroup-saved
1598 gnus-newsgroup-replied
1599 gnus-newsgroup-forwarded
1600 gnus-newsgroup-expirable
1601 gnus-newsgroup-killed
1602 gnus-newsgroup-unseen
1604 gnus-newsgroup-unexist
1605 gnus-newsgroup-cached
1606 gnus-newsgroup-downloadable
1607 gnus-newsgroup-undownloaded
1608 gnus-newsgroup-unsendable
1610 gnus-newsgroup-begin gnus-newsgroup-end
1611 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1612 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1613 gnus-newsgroup-last-directory
1614 gnus-newsgroup-auto-expire
1615 gnus-newsgroup-processable
1616 gnus-newsgroup-unfetched
1617 gnus-newsgroup-articles
1618 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1619 gnus-newsgroup-headers gnus-newsgroup-threads
1620 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1621 gnus-current-article gnus-current-headers gnus-have-all-headers
1622 gnus-last-article gnus-article-internal-prepare-hook
1623 (gnus-summary-article-delete-hook . global)
1624 (gnus-summary-article-move-hook . global)
1625 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1626 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1627 gnus-thread-expunge-below
1628 gnus-score-alist gnus-current-score-file
1629 (gnus-summary-expunge-below . global)
1630 (gnus-summary-mark-below . global)
1631 (gnus-orphan-score . global)
1632 gnus-newsgroup-active gnus-scores-exclude-files
1633 gnus-newsgroup-highest
1634 gnus-newsgroup-history gnus-newsgroup-ancient
1635 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1636 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1637 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1638 (gnus-newsgroup-expunged-tally . 0)
1639 gnus-cache-removable-articles
1640 gnus-newsgroup-data gnus-newsgroup-data-reverse
1641 gnus-newsgroup-limit gnus-newsgroup-limits
1642 gnus-newsgroup-charset gnus-newsgroup-display
1643 gnus-summary-use-undownloaded-faces)
1644 "Variables that are buffer-local to the summary buffers.")
1646 (defvar gnus-newsgroup-variables nil
1647 "A list of variables that have separate values in different newsgroups.
1648 A list of newsgroup (summary buffer) local variables, or cons of
1649 variables and their default expressions to be evalled (when the default
1650 values are not nil), that should be made global while the summary buffer
1653 Note: The default expressions will be evaluated (using function `eval')
1654 before assignment to the local variable rather than just assigned to it.
1655 If the default expression is the symbol `global', that symbol will not
1656 be evaluated but the global value of the local variable will be used
1659 These variables can be used to set variables in the group parameters
1660 while still allowing them to affect operations done in other buffers.
1663 \(setq gnus-newsgroup-variables
1664 \\='(message-use-followup-to
1665 (gnus-visible-headers .
1666 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1670 ;; Bind features so that require will believe that gnus-sum has
1671 ;; already been loaded (avoids infinite recursion)
1672 (let ((features (cons 'gnus-sum features)))
1673 (require 'gnus-art)))
1677 (defvar gnus-decode-encoded-word-methods
1678 '(mail-decode-encoded-word-string)
1679 "List of methods used to decode encoded words.
1681 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1682 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1683 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1684 whose names match REGEXP.
1687 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1688 mail-decode-encoded-word-string
1689 (\"chinese\" . rfc1843-decode-string))")
1691 (defvar gnus-decode-encoded-word-methods-cache nil)
1693 (defun gnus-multi-decode-encoded-word-string (string)
1694 "Apply the functions from `gnus-encoded-word-methods' that match."
1695 (unless (and gnus-decode-encoded-word-methods-cache
1696 (eq gnus-newsgroup-name
1697 (car gnus-decode-encoded-word-methods-cache)))
1698 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1699 (dolist (method gnus-decode-encoded-word-methods)
1700 (if (symbolp method)
1701 (nconc gnus-decode-encoded-word-methods-cache (list method))
1702 (if (and gnus-newsgroup-name
1703 (string-match (car method) gnus-newsgroup-name))
1704 (nconc gnus-decode-encoded-word-methods-cache
1705 (list (cdr method)))))))
1706 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1707 (setq string (funcall method string))))
1709 ;; Subject simplification.
1711 (defun gnus-simplify-whitespace (str)
1712 "Remove excessive whitespace from STR."
1714 (while (string-match "[ \t][ \t]+" str)
1715 (setq str (concat (substring str 0 (match-beginning 0))
1717 (substring str (match-end 0)))))
1719 (when (string-match "^[ \t]+" str)
1720 (setq str (substring str (match-end 0))))
1722 (when (string-match "[ \t]+$" str)
1723 (setq str (substring str 0 (match-beginning 0))))
1726 (defun gnus-simplify-all-whitespace (str)
1727 "Remove all whitespace from STR."
1728 (while (string-match "[ \t\n]+" str)
1729 (setq str (replace-match "" nil nil str)))
1732 (defsubst gnus-simplify-subject-re (subject)
1733 "Remove \"Re:\" from subject lines."
1734 (if (string-match message-subject-re-regexp subject)
1735 (substring subject (match-end 0))
1738 (defun gnus-simplify-subject (subject &optional re-only)
1739 "Remove `Re:' and words in parentheses.
1740 If RE-ONLY is non-nil, strip leading `Re:'s only."
1741 (let ((case-fold-search t)) ;Ignore case.
1742 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1743 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1744 (setq subject (substring subject (match-end 0))))
1745 ;; Remove uninteresting prefixes.
1746 (when (and (not re-only)
1747 gnus-simplify-ignored-prefixes
1748 (string-match gnus-simplify-ignored-prefixes subject))
1749 (setq subject (substring subject (match-end 0))))
1750 ;; Remove words in parentheses from end.
1752 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1753 (setq subject (substring subject 0 (match-beginning 0)))))
1754 ;; Return subject string.
1757 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1759 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1760 (goto-char (point-min))
1761 (while (re-search-forward regexp nil t)
1762 (replace-match (or newtext ""))))
1764 (defun gnus-simplify-buffer-fuzzy (regexp)
1765 "Simplify string in the buffer fuzzily.
1766 The string in the accessible portion of the current buffer is simplified.
1767 It is assumed to be a single-line subject.
1768 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1769 matter is removed. Additional things can be deleted by setting
1770 `gnus-simplify-subject-fuzzy-regexp'."
1771 (let ((case-fold-search t)
1773 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1775 (while (not (eq modified-tick (buffer-modified-tick)))
1776 (setq modified-tick (buffer-modified-tick))
1779 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1781 (gnus-simplify-buffer-fuzzy-step regexp)))
1782 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1783 (gnus-simplify-buffer-fuzzy-step
1784 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1785 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1787 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1788 (gnus-simplify-buffer-fuzzy-step " +" " ")
1789 (gnus-simplify-buffer-fuzzy-step " $")
1790 (gnus-simplify-buffer-fuzzy-step "^ +")))
1792 (defun gnus-simplify-subject-fuzzy (subject)
1793 "Simplify a subject string fuzzily.
1794 See `gnus-simplify-buffer-fuzzy' for details."
1796 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1797 (gnus-set-work-buffer)
1798 (let ((case-fold-search t))
1799 ;; Remove uninteresting prefixes.
1800 (when (and gnus-simplify-ignored-prefixes
1801 (string-match gnus-simplify-ignored-prefixes subject))
1802 (setq subject (substring subject (match-end 0))))
1804 (inline (gnus-simplify-buffer-fuzzy regexp))
1807 (defsubst gnus-simplify-subject-fully (subject)
1808 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1810 (gnus-simplify-subject-functions
1811 (gnus-map-function gnus-simplify-subject-functions subject))
1812 ((null gnus-summary-gather-subject-limit)
1813 (gnus-simplify-subject-re subject))
1814 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1815 (gnus-simplify-subject-fuzzy subject))
1816 ((numberp gnus-summary-gather-subject-limit)
1817 (truncate-string-to-width (gnus-simplify-subject-re subject)
1818 gnus-summary-gather-subject-limit))
1822 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1823 "Check whether two subjects are equal.
1824 If optional argument SIMPLE-FIRST is t, first argument is already
1827 ((null simple-first)
1828 (equal (gnus-simplify-subject-fully s1)
1829 (gnus-simplify-subject-fully s2)))
1832 (gnus-simplify-subject-fully s2)))))
1834 (defun gnus-summary-bubble-group ()
1835 "Increase the score of the current group.
1836 This is a handy function to add to `gnus-summary-exit-hook' to
1837 increase the score of each group you read."
1838 (gnus-group-add-score gnus-newsgroup-name))
1842 ;;; Gnus summary mode
1845 (put 'gnus-summary-mode 'mode-class 'special)
1847 (defvar gnus-article-commands-menu)
1849 ;; Non-orthogonal keys
1851 (gnus-define-keys gnus-summary-mode-map
1852 " " gnus-summary-next-page
1853 [?\S-\ ] gnus-summary-prev-page
1854 "\177" gnus-summary-prev-page
1855 [delete] gnus-summary-prev-page
1856 "\r" gnus-summary-scroll-up
1857 "\M-\r" gnus-summary-scroll-down
1858 "n" gnus-summary-next-unread-article
1859 "p" gnus-summary-prev-unread-article
1860 "N" gnus-summary-next-article
1861 "P" gnus-summary-prev-article
1862 "\M-\C-n" gnus-summary-next-same-subject
1863 "\M-\C-p" gnus-summary-prev-same-subject
1864 "\M-n" gnus-summary-next-unread-subject
1865 "\M-p" gnus-summary-prev-unread-subject
1866 "." gnus-summary-first-unread-article
1867 "," gnus-summary-best-unread-article
1868 "\M-s" gnus-summary-search-article-forward
1869 "\M-r" gnus-summary-search-article-backward
1870 "\M-S" gnus-summary-repeat-search-article-forward
1871 "\M-R" gnus-summary-repeat-search-article-backward
1872 "<" gnus-summary-beginning-of-article
1873 ">" gnus-summary-end-of-article
1874 "j" gnus-summary-goto-article
1875 "^" gnus-summary-refer-parent-article
1876 "\M-^" gnus-summary-refer-article
1877 "u" gnus-summary-tick-article-forward
1878 "!" gnus-summary-tick-article-forward
1879 "U" gnus-summary-tick-article-backward
1880 "d" gnus-summary-mark-as-read-forward
1881 "D" gnus-summary-mark-as-read-backward
1882 "E" gnus-summary-mark-as-expirable
1883 "\M-u" gnus-summary-clear-mark-forward
1884 "\M-U" gnus-summary-clear-mark-backward
1885 "k" gnus-summary-kill-same-subject-and-select
1886 "\C-k" gnus-summary-kill-same-subject
1887 "\M-\C-k" gnus-summary-kill-thread
1888 "\M-\C-l" gnus-summary-lower-thread
1889 "e" gnus-summary-edit-article
1890 "#" gnus-summary-mark-as-processable
1891 "\M-#" gnus-summary-unmark-as-processable
1892 "\M-\C-t" gnus-summary-toggle-threads
1893 "\M-\C-s" gnus-summary-show-thread
1894 "\M-\C-h" gnus-summary-hide-thread
1895 "\M-\C-f" gnus-summary-next-thread
1896 "\M-\C-b" gnus-summary-prev-thread
1897 [(meta down)] gnus-summary-next-thread
1898 [(meta up)] gnus-summary-prev-thread
1899 "\M-\C-u" gnus-summary-up-thread
1900 "\M-\C-d" gnus-summary-down-thread
1901 "&" gnus-summary-execute-command
1902 "c" gnus-summary-catchup-and-exit
1903 "\C-w" gnus-summary-mark-region-as-read
1904 "\C-t" gnus-summary-toggle-truncation
1905 "?" gnus-summary-mark-as-dormant
1906 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1907 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1908 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1909 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1910 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1911 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1912 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1913 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1914 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1915 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1916 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1917 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1918 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1919 "=" gnus-summary-expand-window
1920 "\C-x\C-s" gnus-summary-reselect-current-group
1921 "\M-g" gnus-summary-rescan-group
1922 "\C-c\C-r" gnus-summary-caesar-message
1923 "f" gnus-summary-followup
1924 "F" gnus-summary-followup-with-original
1925 "C" gnus-summary-cancel-article
1926 "r" gnus-summary-reply
1927 "R" gnus-summary-reply-with-original
1928 "\C-c\C-f" gnus-summary-mail-forward
1929 "o" gnus-summary-save-article
1930 "\C-o" gnus-summary-save-article-mail
1931 "|" gnus-summary-pipe-output
1932 "\M-k" gnus-summary-edit-local-kill
1933 "\M-K" gnus-summary-edit-global-kill
1935 "\C-c\C-d" gnus-summary-describe-group
1936 "q" gnus-summary-exit
1937 "Q" gnus-summary-exit-no-update
1938 "\C-c\C-i" gnus-info-find-node
1939 gnus-mouse-2 gnus-mouse-pick-article
1940 [follow-link] mouse-face
1941 "m" gnus-summary-mail-other-window
1942 "a" gnus-summary-post-news
1943 "x" gnus-summary-limit-to-unread
1944 "s" gnus-summary-isearch-article
1945 "\t" gnus-summary-widget-forward
1946 [backtab] gnus-summary-widget-backward
1947 "t" gnus-summary-toggle-header
1948 "g" gnus-summary-show-article
1949 "l" gnus-summary-goto-last-article
1950 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1951 "\C-d" gnus-summary-enter-digest-group
1952 "\M-\C-d" gnus-summary-read-document
1953 "\M-\C-e" gnus-summary-edit-parameters
1954 "\M-\C-a" gnus-summary-customize-parameters
1956 "*" gnus-cache-enter-article
1957 "\M-*" gnus-cache-remove-article
1958 "\M-&" gnus-summary-universal-argument
1959 "\C-l" gnus-recenter
1960 "I" gnus-summary-increase-score
1961 "L" gnus-summary-lower-score
1962 "\M-i" gnus-symbolic-argument
1963 "h" gnus-summary-select-article-buffer
1965 "b" gnus-article-view-part
1966 "\M-t" gnus-summary-toggle-display-buttonized
1968 "V" gnus-summary-score-map
1969 "X" gnus-uu-extract-map
1970 "S" gnus-summary-send-map)
1972 ;; Sort of orthogonal keymap
1973 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1974 "t" gnus-summary-tick-article-forward
1975 "!" gnus-summary-tick-article-forward
1976 "d" gnus-summary-mark-as-read-forward
1977 "r" gnus-summary-mark-as-read-forward
1978 "c" gnus-summary-clear-mark-forward
1979 " " gnus-summary-clear-mark-forward
1980 "e" gnus-summary-mark-as-expirable
1981 "x" gnus-summary-mark-as-expirable
1982 "?" gnus-summary-mark-as-dormant
1983 "b" gnus-summary-set-bookmark
1984 "B" gnus-summary-remove-bookmark
1985 "#" gnus-summary-mark-as-processable
1986 "\M-#" gnus-summary-unmark-as-processable
1987 "S" gnus-summary-limit-include-expunged
1988 "C" gnus-summary-catchup
1989 "H" gnus-summary-catchup-to-here
1990 "h" gnus-summary-catchup-from-here
1991 "\C-c" gnus-summary-catchup-all
1992 "k" gnus-summary-kill-same-subject-and-select
1993 "K" gnus-summary-kill-same-subject
1994 "P" gnus-uu-mark-map)
1996 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1997 "c" gnus-summary-clear-above
1998 "u" gnus-summary-tick-above
1999 "m" gnus-summary-mark-above
2000 "k" gnus-summary-kill-below)
2002 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
2003 "/" gnus-summary-limit-to-subject
2004 "n" gnus-summary-limit-to-articles
2005 "b" gnus-summary-limit-to-bodies
2006 "h" gnus-summary-limit-to-headers
2007 "w" gnus-summary-pop-limit
2008 "s" gnus-summary-limit-to-subject
2009 "a" gnus-summary-limit-to-author
2010 "u" gnus-summary-limit-to-unread
2011 "m" gnus-summary-limit-to-marks
2012 "M" gnus-summary-limit-exclude-marks
2013 "v" gnus-summary-limit-to-score
2014 "*" gnus-summary-limit-include-cached
2015 "D" gnus-summary-limit-include-dormant
2016 "T" gnus-summary-limit-include-thread
2017 "d" gnus-summary-limit-exclude-dormant
2018 "t" gnus-summary-limit-to-age
2019 "." gnus-summary-limit-to-unseen
2020 "x" gnus-summary-limit-to-extra
2021 "p" gnus-summary-limit-to-display-predicate
2022 "E" gnus-summary-limit-include-expunged
2023 "c" gnus-summary-limit-exclude-childless-dormant
2024 "C" gnus-summary-limit-mark-excluded-as-read
2025 "o" gnus-summary-insert-old-articles
2026 "N" gnus-summary-insert-new-articles
2027 "S" gnus-summary-limit-to-singletons
2028 "r" gnus-summary-limit-to-replied
2029 "R" gnus-summary-limit-to-recipient
2030 "A" gnus-summary-limit-to-address)
2032 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2033 "n" gnus-summary-next-unread-article
2034 "p" gnus-summary-prev-unread-article
2035 "N" gnus-summary-next-article
2036 "P" gnus-summary-prev-article
2037 "\C-n" gnus-summary-next-same-subject
2038 "\C-p" gnus-summary-prev-same-subject
2039 "\M-n" gnus-summary-next-unread-subject
2040 "\M-p" gnus-summary-prev-unread-subject
2041 "f" gnus-summary-first-unread-article
2042 "b" gnus-summary-best-unread-article
2043 "j" gnus-summary-goto-article
2044 "g" gnus-summary-goto-subject
2045 "l" gnus-summary-goto-last-article
2046 "o" gnus-summary-pop-article)
2048 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2049 "k" gnus-summary-kill-thread
2050 "E" gnus-summary-expire-thread
2051 "l" gnus-summary-lower-thread
2052 "i" gnus-summary-raise-thread
2053 "T" gnus-summary-toggle-threads
2054 "t" gnus-summary-rethread-current
2055 "^" gnus-summary-reparent-thread
2056 "\M-^" gnus-summary-reparent-children
2057 "s" gnus-summary-show-thread
2058 "S" gnus-summary-show-all-threads
2059 "h" gnus-summary-hide-thread
2060 "H" gnus-summary-hide-all-threads
2061 "n" gnus-summary-next-thread
2062 "p" gnus-summary-prev-thread
2063 "u" gnus-summary-up-thread
2064 "o" gnus-summary-top-thread
2065 "d" gnus-summary-down-thread
2066 "#" gnus-uu-mark-thread
2067 "\M-#" gnus-uu-unmark-thread)
2069 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2070 "g" gnus-summary-prepare
2071 "c" gnus-summary-insert-cached-articles
2072 "d" gnus-summary-insert-dormant-articles
2073 "t" gnus-summary-insert-ticked-articles)
2075 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2076 "c" gnus-summary-catchup-and-exit
2077 "C" gnus-summary-catchup-all-and-exit
2078 "E" gnus-summary-exit-no-update
2079 "Q" gnus-summary-exit
2080 "Z" gnus-summary-exit
2081 "n" gnus-summary-catchup-and-goto-next-group
2082 "p" gnus-summary-catchup-and-goto-prev-group
2083 "R" gnus-summary-reselect-current-group
2084 "G" gnus-summary-rescan-group
2085 "N" gnus-summary-next-group
2086 "s" gnus-summary-save-newsrc
2087 "P" gnus-summary-prev-group)
2089 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2090 " " gnus-summary-next-page
2091 "n" gnus-summary-next-page
2092 [?\S-\ ] gnus-summary-prev-page
2093 "\177" gnus-summary-prev-page
2094 [delete] gnus-summary-prev-page
2095 "p" gnus-summary-prev-page
2096 "\r" gnus-summary-scroll-up
2097 "\M-\r" gnus-summary-scroll-down
2098 "<" gnus-summary-beginning-of-article
2099 ">" gnus-summary-end-of-article
2100 "b" gnus-summary-beginning-of-article
2101 "e" gnus-summary-end-of-article
2102 "^" gnus-summary-refer-parent-article
2103 "r" gnus-summary-refer-parent-article
2104 "C" gnus-summary-show-complete-article
2105 "D" gnus-summary-enter-digest-group
2106 "R" gnus-summary-refer-references
2107 "T" gnus-summary-refer-thread
2108 "W" gnus-warp-to-article
2109 "g" gnus-summary-show-article
2110 "s" gnus-summary-isearch-article
2111 "\t" gnus-summary-widget-forward
2112 [backtab] gnus-summary-widget-backward
2113 "P" gnus-summary-print-article
2114 "S" gnus-sticky-article
2115 "M" gnus-mailing-list-insinuate
2116 "t" gnus-article-babel)
2118 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2119 "b" gnus-article-add-buttons
2120 "B" gnus-article-add-buttons-to-head
2121 "o" gnus-article-treat-overstrike
2122 "e" gnus-article-emphasize
2123 "w" gnus-article-fill-cited-article
2124 "Q" gnus-article-fill-long-lines
2125 "L" gnus-article-toggle-truncate-lines
2126 "C" gnus-article-capitalize-sentences
2127 "c" gnus-article-remove-cr
2128 "q" gnus-article-de-quoted-unreadable
2129 "6" gnus-article-de-base64-unreadable
2130 "Z" gnus-article-decode-HZ
2131 "A" gnus-article-treat-ansi-sequences
2132 "h" gnus-article-wash-html
2133 "u" gnus-article-unsplit-urls
2134 "s" gnus-summary-force-verify-and-decrypt
2135 "f" gnus-article-display-x-face
2136 "l" gnus-summary-stop-page-breaking
2137 "r" gnus-summary-caesar-message
2138 "m" gnus-summary-morse-message
2139 "t" gnus-summary-toggle-header
2140 "g" gnus-treat-smiley
2141 "v" gnus-summary-verbose-headers
2142 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2143 "p" gnus-article-verify-x-pgp-sig
2144 "d" gnus-article-treat-dumbquotes
2145 "U" gnus-article-treat-non-ascii
2146 "i" gnus-summary-idna-message)
2148 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2149 ;; mnemonic: deuglif*Y*
2150 "u" gnus-article-outlook-unwrap-lines
2151 "a" gnus-article-outlook-repair-attribution
2152 "c" gnus-article-outlook-rearrange-citation
2153 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2155 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2156 "a" gnus-article-hide
2157 "h" gnus-article-hide-headers
2158 "b" gnus-article-hide-boring-headers
2159 "s" gnus-article-hide-signature
2160 "c" gnus-article-hide-citation
2161 "C" gnus-article-hide-citation-in-followups
2162 "l" gnus-article-hide-list-identifiers
2163 "B" gnus-article-strip-banner
2164 "P" gnus-article-hide-pem
2165 "\C-c" gnus-article-hide-citation-maybe)
2167 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2168 "a" gnus-article-highlight
2169 "h" gnus-article-highlight-headers
2170 "c" gnus-article-highlight-citation
2171 "s" gnus-article-highlight-signature)
2173 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2174 "f" gnus-article-treat-fold-headers
2175 "u" gnus-article-treat-unfold-headers
2176 "n" gnus-article-treat-fold-newsgroups)
2178 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2179 "x" gnus-article-display-x-face
2180 "d" gnus-article-display-face
2181 "s" gnus-treat-smiley
2182 "D" gnus-article-remove-images
2183 "W" gnus-article-show-images
2184 "f" gnus-treat-from-picon
2185 "m" gnus-treat-mail-picon
2186 "n" gnus-treat-newsgroups-picon
2187 "g" gnus-treat-from-gravatar
2188 "h" gnus-treat-mail-gravatar)
2190 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2191 "w" gnus-article-decode-mime-words
2192 "c" gnus-article-decode-charset
2193 "h" gnus-mime-buttonize-attachments-in-header
2194 "v" gnus-mime-view-all-parts
2195 "b" gnus-article-view-part)
2197 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2198 "z" gnus-article-date-ut
2199 "u" gnus-article-date-ut
2200 "l" gnus-article-date-local
2201 "p" gnus-article-date-english
2202 "e" gnus-article-date-lapsed
2203 "o" gnus-article-date-original
2204 "i" gnus-article-date-iso8601
2205 "s" gnus-article-date-user)
2207 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2208 "t" gnus-article-remove-trailing-blank-lines
2209 "l" gnus-article-strip-leading-blank-lines
2210 "m" gnus-article-strip-multiple-blank-lines
2211 "a" gnus-article-strip-blank-lines
2212 "A" gnus-article-strip-all-blank-lines
2213 "s" gnus-article-strip-leading-space
2214 "e" gnus-article-strip-trailing-space
2215 "w" gnus-article-remove-leading-whitespace)
2217 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2219 "d" gnus-summary-describe-group
2220 "h" gnus-summary-describe-briefly
2221 "i" gnus-info-find-node)
2223 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2224 "e" gnus-summary-expire-articles
2225 "\M-\C-e" gnus-summary-expire-articles-now
2226 "\177" gnus-summary-delete-article
2227 [delete] gnus-summary-delete-article
2228 [backspace] gnus-summary-delete-article
2229 "m" gnus-summary-move-article
2230 "r" gnus-summary-respool-article
2231 "w" gnus-summary-edit-article
2232 "c" gnus-summary-copy-article
2233 "B" gnus-summary-crosspost-article
2234 "q" gnus-summary-respool-query
2235 "t" gnus-summary-respool-trace
2236 "i" gnus-summary-import-article
2237 "I" gnus-summary-create-article
2238 "p" gnus-summary-article-posted-p)
2240 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2241 "o" gnus-summary-save-article
2242 "m" gnus-summary-save-article-mail
2243 "F" gnus-summary-write-article-file
2244 "r" gnus-summary-save-article-rmail
2245 "f" gnus-summary-save-article-file
2246 "b" gnus-summary-save-article-body-file
2247 "B" gnus-summary-write-article-body-file
2248 "h" gnus-summary-save-article-folder
2249 "v" gnus-summary-save-article-vm
2250 "p" gnus-summary-pipe-output
2251 "P" gnus-summary-muttprint)
2253 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2254 "b" gnus-summary-display-buttonized
2255 "m" gnus-summary-repair-multipart
2256 "v" gnus-article-view-part
2257 "o" gnus-article-save-part
2258 "O" gnus-article-save-part-and-strip
2259 "r" gnus-article-replace-part
2260 "d" gnus-article-delete-part
2261 "t" gnus-article-view-part-as-type
2262 "j" gnus-article-jump-to-part
2263 "c" gnus-article-copy-part
2264 "C" gnus-article-view-part-as-charset
2265 "e" gnus-article-view-part-externally
2266 "H" gnus-article-browse-html-article
2267 "E" gnus-article-encrypt-body
2268 "i" gnus-article-inline-part
2269 "|" gnus-article-pipe-part)
2271 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2272 "p" gnus-summary-mark-as-processable
2273 "u" gnus-summary-unmark-as-processable
2274 "U" gnus-summary-unmark-all-processable
2275 "v" gnus-uu-mark-over
2276 "s" gnus-uu-mark-series
2277 "r" gnus-uu-mark-region
2278 "g" gnus-uu-unmark-region
2279 "R" gnus-uu-mark-by-regexp
2280 "G" gnus-uu-unmark-by-regexp
2281 "t" gnus-uu-mark-thread
2282 "T" gnus-uu-unmark-thread
2283 "a" gnus-uu-mark-all
2284 "b" gnus-uu-mark-buffer
2285 "S" gnus-uu-mark-sparse
2286 "k" gnus-summary-kill-process-mark
2287 "y" gnus-summary-yank-process-mark
2288 "w" gnus-summary-save-process-mark
2289 "i" gnus-uu-invert-processable)
2291 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2292 ;;"x" gnus-uu-extract-any
2293 "m" gnus-summary-save-parts
2294 "u" gnus-uu-decode-uu
2295 "U" gnus-uu-decode-uu-and-save
2296 "s" gnus-uu-decode-unshar
2297 "S" gnus-uu-decode-unshar-and-save
2298 "o" gnus-uu-decode-save
2299 "O" gnus-uu-decode-save
2300 "b" gnus-uu-decode-binhex
2301 "B" gnus-uu-decode-binhex
2302 "Y" gnus-uu-decode-yenc
2303 "p" gnus-uu-decode-postscript
2304 "P" gnus-uu-decode-postscript-and-save)
2307 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2308 "u" gnus-uu-decode-uu-view
2309 "U" gnus-uu-decode-uu-and-save-view
2310 "s" gnus-uu-decode-unshar-view
2311 "S" gnus-uu-decode-unshar-and-save-view
2312 "o" gnus-uu-decode-save-view
2313 "O" gnus-uu-decode-save-view
2314 "b" gnus-uu-decode-binhex-view
2315 "B" gnus-uu-decode-binhex-view
2316 "p" gnus-uu-decode-postscript-view
2317 "P" gnus-uu-decode-postscript-and-save-view)
2319 (defvar gnus-article-post-menu nil)
2321 (defconst gnus-summary-menu-maxlen 20)
2323 (defun gnus-summary-menu-split (menu)
2324 ;; If we have lots of elements, divide them into groups of 20
2325 ;; and make a pane (or submenu) for each one.
2326 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2327 (let ((menu menu) sublists next
2330 ;; Pull off the next gnus-summary-menu-maxlen elements
2331 ;; and make them the next element of sublist.
2332 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2334 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2336 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2337 (aref (car (last menu)) 0)) menu)
2341 (nreverse sublists))
2342 ;; Few elements--put them all in one pane.
2345 (defun gnus-summary-make-menu-bar ()
2346 (gnus-turn-off-edit-menu 'summary)
2348 (unless (boundp 'gnus-summary-misc-menu)
2351 gnus-summary-kill-menu gnus-summary-mode-map ""
2356 ["Customize" gnus-score-customize t])
2357 (gnus-make-score-map 'increase)
2358 (gnus-make-score-map 'lower)
2360 ["Kill below" gnus-summary-kill-below t]
2361 ["Mark above" gnus-summary-mark-above t]
2362 ["Tick above" gnus-summary-tick-above t]
2363 ["Clear above" gnus-summary-clear-above t])
2364 ["Current article score" gnus-summary-current-score t]
2365 ["Current thread score" (gnus-summary-current-score 'total) t]
2366 ["Set score" gnus-summary-set-score t]
2367 ["Switch current score file..." gnus-score-change-score-file t]
2368 ["Set mark below..." gnus-score-set-mark-below t]
2369 ["Set expunge below..." gnus-score-set-expunge-below t]
2370 ["Edit current score file" gnus-score-edit-current-scores t]
2371 ["Edit score file..." gnus-score-edit-file t]
2372 ["Trace score" gnus-score-find-trace t]
2373 ["Find words" gnus-score-find-favourite-words t]
2374 ["Rescore buffer" gnus-summary-rescore t]
2375 ["Increase score..." gnus-summary-increase-score t]
2376 ["Lower score..." gnus-summary-lower-score t]))))
2378 ;; Define both the Article menu in the summary buffer and the
2379 ;; equivalent Commands menu in the article buffer here for
2383 ["All" gnus-article-hide t]
2384 ["Headers" gnus-article-hide-headers t]
2385 ["Signature" gnus-article-hide-signature t]
2386 ["Citation" gnus-article-hide-citation t]
2387 ["List identifiers" gnus-article-hide-list-identifiers t]
2388 ["Banner" gnus-article-strip-banner t]
2389 ["Boring headers" gnus-article-hide-boring-headers t])
2391 ["All" gnus-article-highlight t]
2392 ["Headers" gnus-article-highlight-headers t]
2393 ["Signature" gnus-article-highlight-signature t]
2394 ["Citation" gnus-article-highlight-citation t])
2396 ["Words" gnus-article-decode-mime-words t]
2397 ["Charset" gnus-article-decode-charset t]
2398 ["QP" gnus-article-de-quoted-unreadable t]
2399 ["Base64" gnus-article-de-base64-unreadable t]
2400 ["View MIME buttons" gnus-summary-display-buttonized t]
2401 ["View MIME buttons in header"
2402 gnus-mime-buttonize-attachments-in-header t]
2403 ["View all" gnus-mime-view-all-parts t]
2404 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2405 ["Encrypt body" gnus-article-encrypt-body
2406 :active (not (gnus-group-read-only-p))
2407 ,@(if (featurep 'xemacs) nil
2408 '(:help "Encrypt the message body on disk"))]
2409 ["Extract all parts..." gnus-summary-save-parts t]
2411 ["Repair multipart" gnus-summary-repair-multipart t]
2412 ["Pipe part..." gnus-article-pipe-part t]
2413 ["Inline part" gnus-article-inline-part t]
2414 ["View part as type..." gnus-article-view-part-as-type t]
2415 ["Encrypt body" gnus-article-encrypt-body
2416 :active (not (gnus-group-read-only-p))
2417 ,@(if (featurep 'xemacs) nil
2418 '(:help "Encrypt the message body on disk"))]
2419 ["View part externally" gnus-article-view-part-externally t]
2420 ["View HTML parts in browser" gnus-article-browse-html-article t]
2421 ["View part with charset..." gnus-article-view-part-as-charset t]
2422 ["Copy part" gnus-article-copy-part t]
2423 ["Save part..." gnus-article-save-part t]
2424 ["View part" gnus-article-view-part t]))
2426 ["Local" gnus-article-date-local t]
2427 ["ISO8601" gnus-article-date-iso8601 t]
2428 ["UT" gnus-article-date-ut t]
2429 ["Original" gnus-article-date-original t]
2430 ["Lapsed" gnus-article-date-lapsed t]
2431 ["User-defined" gnus-article-date-user t])
2433 ["Display HTML images" gnus-article-show-images t]
2434 ["Remove images" gnus-article-remove-images t]
2435 ["Toggle smiley" gnus-treat-smiley t]
2436 ["Show X-Face" gnus-article-display-x-face t]
2437 ["Show picons in From" gnus-treat-from-picon t]
2438 ["Show picons in mail headers" gnus-treat-mail-picon t]
2439 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2440 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2441 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2442 ("View as different encoding"
2443 ,@(gnus-summary-menu-split
2446 ;; Since easymenu under Emacs doesn't allow
2447 ;; lambda forms for menu commands, we should
2448 ;; provide intern'ed function symbols.
2449 (let ((command (intern (format "\
2450 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2454 (let ((gnus-summary-show-article-charset-alist
2456 (gnus-summary-show-article 1))))
2457 `[,(symbol-name cs) ,command t]))
2458 (sort (if (fboundp 'coding-system-list)
2459 (coding-system-list)
2460 (mapcar 'car mm-mime-mule-charset-alist))
2464 ["Leading" gnus-article-strip-leading-blank-lines t]
2465 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2466 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2467 ["All of the above" gnus-article-strip-blank-lines t]
2468 ["All" gnus-article-strip-all-blank-lines t]
2469 ["Leading space" gnus-article-strip-leading-space t]
2470 ["Trailing space" gnus-article-strip-trailing-space t]
2471 ["Leading space in headers"
2472 gnus-article-remove-leading-whitespace t])
2473 ["Overstrike" gnus-article-treat-overstrike t]
2474 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2475 ["Non-ASCII" gnus-article-treat-non-ascii t]
2476 ["Emphasis" gnus-article-emphasize t]
2477 ["Word wrap" gnus-article-fill-cited-article t]
2478 ["Fill long lines" gnus-article-fill-long-lines t]
2479 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2480 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2481 ["Remove CR" gnus-article-remove-cr t]
2482 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2483 ["Base64" gnus-article-de-base64-unreadable t]
2484 ["Rot 13" gnus-summary-caesar-message
2485 ,@(if (featurep 'xemacs) '(t)
2486 '(:help "\"Caesar rotate\" article by 13"))]
2487 ["De-IDNA" gnus-summary-idna-message t]
2488 ["Morse decode" gnus-summary-morse-message t]
2489 ["Unix pipe..." gnus-summary-pipe-message t]
2490 ["Add buttons" gnus-article-add-buttons t]
2491 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2492 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2493 ["Verbose header" gnus-summary-verbose-headers t]
2494 ["Toggle header" gnus-summary-toggle-header t]
2495 ["Unfold headers" gnus-article-treat-unfold-headers t]
2496 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2497 ["Html" gnus-article-wash-html t]
2498 ["Unsplit URLs" gnus-article-unsplit-urls t]
2499 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2500 ["Decode HZ" gnus-article-decode-HZ t]
2501 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2502 ("(Outlook) Deuglify"
2503 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2504 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2505 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2506 ["Full (Outlook) deuglify"
2507 gnus-article-outlook-deuglify-article t])
2510 ["Save in default format..." gnus-summary-save-article
2511 ,@(if (featurep 'xemacs) '(t)
2512 '(:help "Save article using default method"))]
2513 ["Save in file..." gnus-summary-save-article-file
2514 ,@(if (featurep 'xemacs) '(t)
2515 '(:help "Save article in file"))]
2516 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2517 ["Save in MH folder..." gnus-summary-save-article-folder t]
2518 ["Save in VM folder..." gnus-summary-save-article-vm t]
2519 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2520 ["Save body in file..." gnus-summary-save-article-body-file t]
2521 ["Pipe through a filter..." gnus-summary-pipe-output t]
2522 ["Print with Muttprint..." gnus-summary-muttprint t]
2523 ["Print" gnus-summary-print-article
2524 ,@(if (featurep 'xemacs) '(t)
2525 '(:help "Generate and print a PostScript image"))])
2526 ("Copy, move,... (Backend)"
2527 ,@(if (featurep 'xemacs) nil
2528 '(:help "Copying, moving, expiring articles..."))
2529 ["Respool article..." gnus-summary-respool-article t]
2530 ["Move article..." gnus-summary-move-article
2531 (gnus-check-backend-function
2532 'request-move-article gnus-newsgroup-name)]
2533 ["Copy article..." gnus-summary-copy-article t]
2534 ["Crosspost article..." gnus-summary-crosspost-article
2535 (gnus-check-backend-function
2536 'request-replace-article gnus-newsgroup-name)]
2537 ["Import file..." gnus-summary-import-article
2538 (gnus-check-backend-function
2539 'request-accept-article gnus-newsgroup-name)]
2540 ["Create article..." gnus-summary-create-article
2541 (gnus-check-backend-function
2542 'request-accept-article gnus-newsgroup-name)]
2543 ["Check if posted" gnus-summary-article-posted-p t]
2544 ["Edit article" gnus-summary-edit-article
2545 (not (gnus-group-read-only-p))]
2546 ["Delete article" gnus-summary-delete-article
2547 (gnus-check-backend-function
2548 'request-expire-articles gnus-newsgroup-name)]
2549 ["Query respool" gnus-summary-respool-query t]
2550 ["Trace respool" gnus-summary-respool-trace t]
2551 ["Delete expirable articles" gnus-summary-expire-articles-now
2552 (gnus-check-backend-function
2553 'request-expire-articles gnus-newsgroup-name)])
2555 ["Uudecode" gnus-uu-decode-uu
2556 ,@(if (featurep 'xemacs) '(t)
2557 '(:help "Decode uuencoded article(s)"))]
2558 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2559 ["Unshar" gnus-uu-decode-unshar t]
2560 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2561 ["Save" gnus-uu-decode-save t]
2562 ["Binhex" gnus-uu-decode-binhex t]
2563 ["PostScript" gnus-uu-decode-postscript t]
2564 ["All MIME parts" gnus-summary-save-parts t])
2566 ["Enter article" gnus-cache-enter-article t]
2567 ["Remove article" gnus-cache-remove-article t])
2568 ["Translate" gnus-article-babel t]
2569 ["Select article buffer" gnus-summary-select-article-buffer t]
2570 ["Make article buffer sticky" gnus-sticky-article t]
2571 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2572 ["Isearch article..." gnus-summary-isearch-article t]
2573 ["Beginning of the article" gnus-summary-beginning-of-article t]
2574 ["End of the article" gnus-summary-end-of-article t]
2575 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2576 ["Fetch referenced articles" gnus-summary-refer-references t]
2577 ["Fetch current thread" gnus-summary-refer-thread t]
2578 ["Fetch article with id..." gnus-summary-refer-article t]
2579 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2580 ["Redisplay" gnus-summary-show-article t]
2581 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2583 gnus-summary-article-menu gnus-summary-mode-map ""
2584 (cons "Article" innards))
2586 (if (not (keymapp gnus-summary-article-menu))
2588 gnus-article-commands-menu gnus-article-mode-map ""
2589 (cons "Commands" innards))
2590 ;; in Emacs, don't share menu.
2591 (setq gnus-article-commands-menu
2592 (copy-keymap gnus-summary-article-menu))
2593 (define-key gnus-article-mode-map [menu-bar commands]
2594 (cons "Commands" gnus-article-commands-menu))))
2597 gnus-summary-thread-menu gnus-summary-mode-map ""
2599 ["Find all messages in thread" gnus-summary-refer-thread t]
2600 ["Toggle threading" gnus-summary-toggle-threads t]
2601 ["Hide threads" gnus-summary-hide-all-threads t]
2602 ["Show threads" gnus-summary-show-all-threads t]
2603 ["Hide thread" gnus-summary-hide-thread t]
2604 ["Show thread" gnus-summary-show-thread t]
2605 ["Go to next thread" gnus-summary-next-thread t]
2606 ["Go to previous thread" gnus-summary-prev-thread t]
2607 ["Go down thread" gnus-summary-down-thread t]
2608 ["Go up thread" gnus-summary-up-thread t]
2609 ["Top of thread" gnus-summary-top-thread t]
2610 ["Mark thread as read" gnus-summary-kill-thread t]
2611 ["Mark thread as expired" gnus-summary-expire-thread t]
2612 ["Lower thread score" gnus-summary-lower-thread t]
2613 ["Raise thread score" gnus-summary-raise-thread t]
2614 ["Rethread current" gnus-summary-rethread-current t]))
2617 gnus-summary-post-menu gnus-summary-mode-map ""
2619 ["Send a message (mail or news)" gnus-summary-post-news
2620 ,@(if (featurep 'xemacs) '(t)
2621 '(:help "Compose a new message (mail or news)"))]
2622 ["Followup" gnus-summary-followup
2623 ,@(if (featurep 'xemacs) '(t)
2624 '(:help "Post followup to this article"))]
2625 ["Followup and yank" gnus-summary-followup-with-original
2626 ,@(if (featurep 'xemacs) '(t)
2627 '(:help "Post followup to this article, quoting its contents"))]
2628 ["Supersede article" gnus-summary-supersede-article t]
2629 ["Cancel article" gnus-summary-cancel-article
2630 ,@(if (featurep 'xemacs) '(t)
2631 '(:help "Cancel an article you posted"))]
2632 ["Reply" gnus-summary-reply t]
2633 ["Reply and yank" gnus-summary-reply-with-original t]
2634 ["Wide reply" gnus-summary-wide-reply t]
2635 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2636 ,@(if (featurep 'xemacs) '(t)
2637 '(:help "Mail a reply, quoting this article"))]
2638 ["Very wide reply" gnus-summary-very-wide-reply t]
2639 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2640 ,@(if (featurep 'xemacs) '(t)
2641 '(:help "Mail a very wide reply, quoting this article"))]
2642 ["Mail forward" gnus-summary-mail-forward t]
2643 ["Post forward" gnus-summary-post-forward t]
2644 ["Digest and mail" gnus-uu-digest-mail-forward t]
2645 ["Digest and post" gnus-uu-digest-post-forward t]
2646 ["Resend message" gnus-summary-resend-message t]
2647 ["Resend message edit" gnus-summary-resend-message-edit t]
2648 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2649 ["Send a mail" gnus-summary-mail-other-window t]
2650 ["Create a local message" gnus-summary-news-other-window t]
2651 ["Uuencode and post" gnus-uu-post-news
2652 ,@(if (featurep 'xemacs) '(t)
2653 '(:help "Post a uuencoded article"))]
2654 ["Followup via news" gnus-summary-followup-to-mail t]
2655 ["Followup via news and yank"
2656 gnus-summary-followup-to-mail-with-original t]
2657 ["Strip signature on reply"
2660 (if (not (memq message-cite-function
2661 '(message-cite-original-without-signature
2662 message-cite-original)))
2663 ;; Stupid workaround for XEmacs not honoring :visible.
2664 (message "Can't toggle this value of `message-cite-function'")
2665 (setq message-cite-function
2666 (if (eq message-cite-function
2667 'message-cite-original-without-signature)
2668 'message-cite-original
2669 'message-cite-original-without-signature))))
2670 ;; XEmacs barfs on :visible.
2671 ,@(if (featurep 'xemacs) nil
2672 '(:visible (memq message-cite-function
2673 '(message-cite-original-without-signature
2674 message-cite-original))))
2676 :selected (eq message-cite-function
2677 'message-cite-original-without-signature)
2678 ,@(if (featurep 'xemacs) nil
2679 '(:help "Strip signature from cited article when replying."))]
2681 ;;["Send" gnus-summary-send-draft t]
2682 ;;["Send bounced" gnus-resend-bounced-mail t])
2686 ((not (keymapp gnus-summary-post-menu))
2687 (setq gnus-article-post-menu gnus-summary-post-menu))
2688 ((not gnus-article-post-menu)
2689 ;; Don't share post menu.
2690 (setq gnus-article-post-menu
2691 (copy-keymap gnus-summary-post-menu))))
2692 (define-key gnus-article-mode-map [menu-bar post]
2693 (cons "Post" gnus-article-post-menu))
2696 gnus-summary-misc-menu gnus-summary-mode-map ""
2699 ["Mark as read" gnus-summary-mark-as-read-forward t]
2700 ["Mark same subject and select"
2701 gnus-summary-kill-same-subject-and-select t]
2702 ["Mark same subject" gnus-summary-kill-same-subject t]
2703 ["Catchup" gnus-summary-catchup
2704 ,@(if (featurep 'xemacs) '(t)
2705 '(:help "Mark unread articles in this group as read"))]
2706 ["Catchup all" gnus-summary-catchup-all t]
2707 ["Catchup to here" gnus-summary-catchup-to-here t]
2708 ["Catchup from here" gnus-summary-catchup-from-here t]
2709 ["Catchup region" gnus-summary-mark-region-as-read
2710 (gnus-mark-active-p)]
2711 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2713 ["Tick" gnus-summary-tick-article-forward t]
2714 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2715 ["Remove marks" gnus-summary-clear-mark-forward t]
2716 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2717 ["Set bookmark" gnus-summary-set-bookmark t]
2718 ["Remove bookmark" gnus-summary-remove-bookmark t])
2720 ["Marks..." gnus-summary-limit-to-marks t]
2721 ["Subject..." gnus-summary-limit-to-subject t]
2722 ["Author..." gnus-summary-limit-to-author t]
2723 ["Recipient..." gnus-summary-limit-to-recipient t]
2724 ["Address..." gnus-summary-limit-to-address t]
2725 ["Age..." gnus-summary-limit-to-age t]
2726 ["Extra..." gnus-summary-limit-to-extra t]
2727 ["Score..." gnus-summary-limit-to-score t]
2728 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2729 ["Unread" gnus-summary-limit-to-unread t]
2730 ["Unseen" gnus-summary-limit-to-unseen t]
2731 ["Singletons" gnus-summary-limit-to-singletons t]
2732 ["Replied" gnus-summary-limit-to-replied t]
2733 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2734 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2735 ["Pop limit" gnus-summary-pop-limit t]
2736 ["Show dormant" gnus-summary-limit-include-dormant t]
2737 ["Hide childless dormant"
2738 gnus-summary-limit-exclude-childless-dormant t]
2739 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2740 ["Hide marked" gnus-summary-limit-exclude-marks t]
2741 ["Show expunged" gnus-summary-limit-include-expunged t])
2743 ["Set mark" gnus-summary-mark-as-processable t]
2744 ["Remove mark" gnus-summary-unmark-as-processable t]
2745 ["Remove all marks" gnus-summary-unmark-all-processable t]
2746 ["Invert marks" gnus-uu-invert-processable t]
2747 ["Mark above" gnus-uu-mark-over t]
2748 ["Mark series" gnus-uu-mark-series t]
2749 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2750 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2751 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2752 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2753 ["Mark all" gnus-uu-mark-all t]
2754 ["Mark buffer" gnus-uu-mark-buffer t]
2755 ["Mark sparse" gnus-uu-mark-sparse t]
2756 ["Mark thread" gnus-uu-mark-thread t]
2757 ["Unmark thread" gnus-uu-unmark-thread t]
2758 ("Process Mark Sets"
2759 ["Kill" gnus-summary-kill-process-mark t]
2760 ["Yank" gnus-summary-yank-process-mark
2761 gnus-newsgroup-process-stack]
2762 ["Save" gnus-summary-save-process-mark t]
2763 ["Run command on marked..." gnus-summary-universal-argument t]))
2766 ["Page forward" gnus-summary-next-page
2767 ,@(if (featurep 'xemacs) '(t)
2768 '(:help "Show next page of article"))]
2769 ["Page backward" gnus-summary-prev-page
2770 ,@(if (featurep 'xemacs) '(t)
2771 '(:help "Show previous page of article"))]
2772 ["Line forward" gnus-summary-scroll-up t])
2774 ["Next unread article" gnus-summary-next-unread-article t]
2775 ["Previous unread article" gnus-summary-prev-unread-article t]
2776 ["Next article" gnus-summary-next-article t]
2777 ["Previous article" gnus-summary-prev-article t]
2778 ["Next unread subject" gnus-summary-next-unread-subject t]
2779 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2780 ["Next article same subject" gnus-summary-next-same-subject t]
2781 ["Previous article same subject" gnus-summary-prev-same-subject t]
2782 ["First unread article" gnus-summary-first-unread-article t]
2783 ["Best unread article" gnus-summary-best-unread-article t]
2784 ["Go to subject number..." gnus-summary-goto-subject t]
2785 ["Go to article number..." gnus-summary-goto-article t]
2786 ["Go to the last article" gnus-summary-goto-last-article t]
2787 ["Pop article off history" gnus-summary-pop-article t])
2789 ["Sort by number" gnus-summary-sort-by-number t]
2790 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2791 ["Sort by author" gnus-summary-sort-by-author t]
2792 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2793 ["Sort by subject" gnus-summary-sort-by-subject t]
2794 ["Sort by date" gnus-summary-sort-by-date t]
2795 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2796 ["Sort by score" gnus-summary-sort-by-score t]
2797 ["Sort by lines" gnus-summary-sort-by-lines t]
2798 ["Sort by characters" gnus-summary-sort-by-chars t]
2799 ["Randomize" gnus-summary-sort-by-random t]
2800 ["Original sort" gnus-summary-sort-by-original t])
2802 ["Describe group" gnus-summary-describe-group t]
2803 ["Read manual" gnus-info-find-node t])
2805 ["Pick and read" gnus-pick-mode t]
2806 ["Binary" gnus-binary-mode t])
2808 ["Regenerate" gnus-summary-prepare t]
2809 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2810 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2811 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2812 ["Toggle threading" gnus-summary-toggle-threads t])
2813 ["See old articles" gnus-summary-insert-old-articles t]
2814 ["See new articles" gnus-summary-insert-new-articles t]
2815 ["Filter articles..." gnus-summary-execute-command t]
2816 ["Run command on articles..." gnus-summary-universal-argument t]
2817 ["Search articles forward..." gnus-summary-search-article-forward t]
2818 ["Search articles backward..." gnus-summary-search-article-backward t]
2819 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2820 ["Expand window" gnus-summary-expand-window t]
2821 ["Expire expirable articles" gnus-summary-expire-articles
2822 (gnus-check-backend-function
2823 'request-expire-articles gnus-newsgroup-name)]
2824 ["Edit local kill file" gnus-summary-edit-local-kill t]
2825 ["Edit main kill file" gnus-summary-edit-global-kill t]
2826 ["Edit group parameters" gnus-summary-edit-parameters t]
2827 ["Customize group parameters" gnus-summary-customize-parameters t]
2828 ["Send a bug report" gnus-bug t]
2830 ["Catchup and exit" gnus-summary-catchup-and-exit
2831 ,@(if (featurep 'xemacs) '(t)
2832 '(:help "Mark unread articles in this group as read, then exit"))]
2833 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2834 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2835 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2836 ["Exit group" gnus-summary-exit
2837 ,@(if (featurep 'xemacs) '(t)
2838 '(:help "Exit current group, return to group selection mode"))]
2839 ["Exit group without updating" gnus-summary-exit-no-update t]
2840 ["Exit and goto next group" gnus-summary-next-group t]
2841 ["Exit and goto prev group" gnus-summary-prev-group t]
2842 ["Reselect group" gnus-summary-reselect-current-group t]
2843 ["Rescan group" gnus-summary-rescan-group t]
2844 ["Update dribble" gnus-summary-save-newsrc t])))
2846 (gnus-run-hooks 'gnus-summary-menu-hook)))
2848 (defvar gnus-summary-tool-bar-map nil)
2850 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2851 ;; affect _new_ message buffers. We might add a function that walks thru all
2852 ;; summary-mode buffers and force the update.
2853 (defun gnus-summary-tool-bar-update (&optional symbol value)
2854 "Update summary mode toolbar.
2855 Setter function for custom variables."
2856 (setq-default gnus-summary-tool-bar-map nil)
2858 ;; When used as ":set" function:
2859 (set-default symbol value))
2860 (when (gnus-buffer-live-p gnus-summary-buffer)
2861 (with-current-buffer gnus-summary-buffer
2862 (gnus-summary-make-tool-bar))))
2864 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2865 'gnus-summary-tool-bar-gnome
2866 'gnus-summary-tool-bar-retro)
2867 "Specifies the Gnus summary tool bar.
2869 It can be either a list or a symbol referring to a list. See
2870 `gmm-tool-bar-from-list' for the format of the list. The
2871 default key map is `gnus-summary-mode-map'.
2873 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2874 `gnus-summary-tool-bar-retro'."
2875 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2876 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2877 (repeat :tag "User defined list" gmm-tool-bar-item)
2879 :version "23.1" ;; No Gnus
2880 :initialize 'custom-initialize-default
2881 :set 'gnus-summary-tool-bar-update
2882 :group 'gnus-summary)
2884 (defcustom gnus-summary-tool-bar-gnome
2885 '((gnus-summary-post-news "mail/compose" nil)
2886 (gnus-summary-insert-new-articles "mail/inbox" nil
2887 :visible (or (not gnus-agent)
2889 (gnus-summary-reply-with-original "mail/reply")
2890 (gnus-summary-reply "mail/reply" nil :visible nil)
2891 (gnus-summary-followup-with-original "mail/reply-all")
2892 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2893 (gnus-summary-mail-forward "mail/forward")
2894 (gnus-summary-save-article "mail/save")
2895 (gnus-summary-search-article-forward "search" nil :visible nil)
2896 (gnus-summary-print-article "print")
2897 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2898 ;; Some new commands that may need more suitable icons:
2899 (gnus-summary-save-newsrc "save" nil :visible nil)
2900 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2901 (gnus-summary-prev-article "left-arrow")
2902 (gnus-summary-next-article "right-arrow")
2903 (gnus-summary-next-page "next-page")
2904 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2906 ;; Maybe some sort-by-... could be added:
2907 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2908 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2909 (gnus-summary-mark-as-expirable
2911 :visible (gnus-check-backend-function 'request-expire-articles
2912 gnus-newsgroup-name))
2913 (gnus-summary-mark-as-spam
2915 :visible (and (fboundp 'spam-group-ham-contents-p)
2916 (spam-group-ham-contents-p gnus-newsgroup-name))
2917 :help "Mark as spam")
2918 (gnus-summary-mark-as-read-forward
2920 :visible (and (fboundp 'spam-group-spam-contents-p)
2921 (spam-group-spam-contents-p gnus-newsgroup-name)))
2923 (gnus-summary-exit "exit")
2924 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2925 (gnus-info-find-node "help"))
2926 "List of functions for the summary tool bar (GNOME style).
2928 See `gmm-tool-bar-from-list' for the format of the list."
2929 :type '(repeat gmm-tool-bar-item)
2930 :version "23.1" ;; No Gnus
2931 :initialize 'custom-initialize-default
2932 :set 'gnus-summary-tool-bar-update
2933 :group 'gnus-summary)
2935 (defcustom gnus-summary-tool-bar-retro
2936 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2937 (gnus-summary-next-unread-article "gnus/next-ur")
2938 (gnus-summary-post-news "gnus/post")
2939 (gnus-summary-followup-with-original "gnus/fuwo")
2940 (gnus-summary-followup "gnus/followup")
2941 (gnus-summary-reply-with-original "gnus/reply-wo")
2942 (gnus-summary-reply "gnus/reply")
2943 (gnus-summary-caesar-message "gnus/rot13")
2944 (gnus-uu-decode-uu "gnus/uu-decode")
2945 (gnus-summary-save-article-file "gnus/save-aif")
2946 (gnus-summary-save-article "gnus/save-art")
2947 (gnus-uu-post-news "gnus/uu-post")
2948 (gnus-summary-catchup "gnus/catchup")
2949 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2950 (gnus-summary-exit "gnus/exit-summ")
2951 ;; Some new command that may need more suitable icons:
2952 (gnus-summary-print-article "gnus/print" nil :visible nil)
2953 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2954 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2955 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2956 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2957 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2958 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2960 (gnus-info-find-node "gnus/help" nil :visible nil))
2961 "List of functions for the summary tool bar (retro look).
2963 See `gmm-tool-bar-from-list' for the format of the list."
2964 :type '(repeat gmm-tool-bar-item)
2965 :version "23.1" ;; No Gnus
2966 :initialize 'custom-initialize-default
2967 :set 'gnus-summary-tool-bar-update
2968 :group 'gnus-summary)
2970 (defcustom gnus-summary-tool-bar-zap-list t
2971 "List of icon items from the global tool bar.
2972 These items are not displayed in the Gnus summary mode tool bar.
2974 See `gmm-tool-bar-from-list' for the format of the list."
2975 :type 'gmm-tool-bar-zap-list
2976 :version "23.1" ;; No Gnus
2977 :initialize 'custom-initialize-default
2978 :set 'gnus-summary-tool-bar-update
2979 :group 'gnus-summary)
2981 (defvar image-load-path)
2982 (defvar tool-bar-map)
2984 (defun gnus-summary-make-tool-bar (&optional force)
2985 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2986 When FORCE, rebuild the tool bar."
2987 (when (and (not (featurep 'xemacs))
2988 (boundp 'tool-bar-mode)
2990 (or (not gnus-summary-tool-bar-map) force))
2992 (gmm-image-load-path-for-library "gnus"
2995 (image-load-path (cons (car load-path)
2996 (when (boundp 'image-load-path)
2998 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2999 gnus-summary-tool-bar-zap-list
3000 'gnus-summary-mode-map)))
3002 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
3004 (setq gnus-summary-tool-bar-map map))))
3005 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
3007 (defun gnus-make-score-map (type)
3008 "Make a summary score map of type TYPE."
3011 (let ((headers '(("author" "from" string)
3012 ("subject" "subject" string)
3013 ("article body" "body" string)
3014 ("article head" "head" string)
3015 ("xref" "xref" string)
3016 ("extra header" "extra" string)
3017 ("lines" "lines" number)
3018 ("followups to author" "followup" string)))
3019 (types '((number ("less than" <)
3022 (string ("substring" s)
3026 (perms '(("temporary" (current-time-string))
3034 (if (eq type 'lower)
3039 (setq header (car headers))
3045 (let ((ts (cdr (assoc (nth 2 header) types)))
3061 'gnus-summary-score-entry
3063 (if (or (string= (nth 1 header)
3065 (string= (nth 1 header)
3068 (list 'gnus-summary-header
3070 (list 'quote (nth 1 (car ts)))
3071 (list 'gnus-score-delta-default
3078 (list (nreverse outp))))
3081 (list (nreverse outt))))
3083 (setq headers (cdr headers)))
3084 (list (nreverse outh))))))))
3087 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3088 (defvar bookmark-make-record-function)
3090 (defvar bidi-paragraph-direction)
3092 (defun gnus-summary-mode (&optional group)
3093 "Major mode for reading articles.
3095 All normal editing commands are switched off.
3096 \\<gnus-summary-mode-map>
3097 Each line in this buffer represents one article. To read an
3098 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3099 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3102 You can also post articles and send mail from this buffer. To
3103 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3104 of an article, type `\\[gnus-summary-reply]'.
3106 There are approx. one gazillion commands you can execute in this
3107 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3109 The following commands are available:
3111 \\{gnus-summary-mode-map}"
3112 ;; FIXME: Use define-derived-mode.
3114 (kill-all-local-variables)
3115 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3116 (gnus-summary-make-local-variables))
3117 (gnus-summary-make-local-variables)
3118 (setq gnus-newsgroup-name group)
3119 (when (gnus-visual-p 'summary-menu 'menu)
3120 (gnus-summary-make-menu-bar)
3121 (gnus-summary-make-tool-bar))
3122 (gnus-make-thread-indent-array)
3123 (gnus-simplify-mode-line)
3124 (setq major-mode 'gnus-summary-mode)
3125 (setq mode-name "Summary")
3126 (use-local-map gnus-summary-mode-map)
3127 (buffer-disable-undo)
3128 (setq buffer-read-only t ;Disable modification
3129 show-trailing-whitespace nil)
3130 (setq truncate-lines t)
3131 ;; Force paragraph direction to be left-to-right. Don't make it
3132 ;; bound globally in old Emacsen and XEmacsen.
3133 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3134 (add-to-invisibility-spec '(gnus-sum . t))
3135 (gnus-summary-set-display-table)
3136 (gnus-set-default-directory)
3137 (make-local-variable 'gnus-summary-line-format)
3138 (make-local-variable 'gnus-summary-line-format-spec)
3139 (make-local-variable 'gnus-summary-dummy-line-format)
3140 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3141 (make-local-variable 'gnus-summary-mark-positions)
3142 (gnus-make-local-hook 'pre-command-hook)
3143 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3144 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3145 (turn-on-gnus-mailing-list-mode)
3146 (mm-enable-multibyte)
3147 (set (make-local-variable 'bookmark-make-record-function)
3148 'gnus-summary-bookmark-make-record)
3149 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3150 (gnus-update-summary-mark-positions))
3152 (defun gnus-summary-make-local-variables ()
3153 "Make all the local summary buffer variables."
3155 (dolist (local gnus-summary-local-variables)
3158 (if (eq (cdr local) 'global)
3159 ;; Copy the global value of the variable.
3160 (setq global (symbol-value (car local)))
3161 ;; Use the value from the list.
3162 (setq global (eval (cdr local))))
3163 (set (make-local-variable (car local)) global))
3164 ;; Simple nil-valued local variable.
3165 (set (make-local-variable local) nil)))))
3167 ;; Summary data functions.
3169 (defmacro gnus-data-number (data)
3172 (defmacro gnus-data-set-number (data number)
3173 `(setcar ,data ,number))
3175 (defmacro gnus-data-mark (data)
3178 (defmacro gnus-data-set-mark (data mark)
3179 `(setcar (nthcdr 1 ,data) ,mark))
3181 (defmacro gnus-data-pos (data)
3184 (defmacro gnus-data-set-pos (data pos)
3185 `(setcar (nthcdr 2 ,data) ,pos))
3187 (defmacro gnus-data-header (data)
3190 (defmacro gnus-data-set-header (data header)
3191 `(setf (nth 3 ,data) ,header))
3193 (defmacro gnus-data-level (data)
3196 (defmacro gnus-data-unread-p (data)
3197 `(= (nth 1 ,data) gnus-unread-mark))
3199 (defmacro gnus-data-read-p (data)
3200 `(/= (nth 1 ,data) gnus-unread-mark))
3202 (defmacro gnus-data-pseudo-p (data)
3203 `(consp (nth 3 ,data)))
3205 (defmacro gnus-data-find (number)
3206 `(assq ,number gnus-newsgroup-data))
3208 (defmacro gnus-data-find-list (number &optional data)
3209 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3210 (memq (assq ,number bdata)
3213 (defmacro gnus-data-make (number mark pos header level)
3214 `(list ,number ,mark ,pos ,header ,level))
3216 (defun gnus-data-enter (after-article number mark pos header level offset)
3217 (let ((data (gnus-data-find-list after-article)))
3219 (error "No such article: %d" after-article))
3220 (setcdr data (cons (gnus-data-make number mark pos header level)
3222 (setq gnus-newsgroup-data-reverse nil)
3223 (gnus-data-update-list (cddr data) offset)))
3225 (defun gnus-data-enter-list (after-article list &optional offset)
3227 (let ((data (and after-article (gnus-data-find-list after-article)))
3231 (let ((odata gnus-newsgroup-data))
3232 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3234 (gnus-data-update-list odata offset)))
3235 ;; Find the last element in the list to be spliced into the main
3237 (setq list (last list))
3240 (setcdr list gnus-newsgroup-data)
3241 (setq gnus-newsgroup-data ilist)
3243 (gnus-data-update-list (cdr list) offset)))
3244 (setcdr list (cdr data))
3247 (gnus-data-update-list (cdr list) offset))))
3248 (setq gnus-newsgroup-data-reverse nil))))
3250 (defun gnus-data-remove (article &optional offset)
3251 (let ((data gnus-newsgroup-data))
3252 (if (= (gnus-data-number (car data)) article)
3254 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3255 gnus-newsgroup-data-reverse nil)
3257 (gnus-data-update-list gnus-newsgroup-data offset)))
3259 (when (= (gnus-data-number (cadr data)) article)
3260 (setcdr data (cddr data))
3262 (gnus-data-update-list (cdr data) offset))
3264 gnus-newsgroup-data-reverse nil))
3265 (setq data (cdr data))))))
3267 (defmacro gnus-data-list (backward)
3269 (or gnus-newsgroup-data-reverse
3270 (setq gnus-newsgroup-data-reverse
3271 (reverse gnus-newsgroup-data)))
3272 gnus-newsgroup-data))
3274 (defun gnus-data-update-list (data offset)
3275 "Add OFFSET to the POS of all data entries in DATA."
3276 (setq gnus-newsgroup-data-reverse nil)
3278 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3279 (setq data (cdr data))))
3281 (defun gnus-summary-article-pseudo-p (article)
3282 "Say whether this article is a pseudo article or not."
3283 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3285 (defmacro gnus-summary-article-sparse-p (article)
3286 "Say whether this article is a sparse article or not."
3287 `(memq ,article gnus-newsgroup-sparse))
3289 (defmacro gnus-summary-article-ancient-p (article)
3290 "Say whether this article is a sparse article or not."
3291 `(memq ,article gnus-newsgroup-ancient))
3293 (defun gnus-article-children (number)
3294 "Return a list of all children to NUMBER."
3295 (let* ((data (gnus-data-find-list number))
3296 (level (gnus-data-level (car data)))
3298 (setq data (cdr data))
3300 (= (gnus-data-level (car data)) (1+ level)))
3301 (push (gnus-data-number (car data)) children)
3302 (setq data (cdr data)))
3305 (defmacro gnus-summary-skip-intangible ()
3306 "If the current article is intangible, then jump to a different article."
3307 '(let ((to (get-text-property (point) 'gnus-intangible)))
3308 (and to (gnus-summary-goto-subject to))))
3310 (defmacro gnus-summary-article-intangible-p ()
3311 "Say whether this article is intangible or not."
3312 '(get-text-property (point) 'gnus-intangible))
3314 ;; Some summary mode macros.
3316 (defmacro gnus-summary-article-number ()
3317 "The article number of the article on the current line.
3318 If there isn't an article number here, then we return the current
3321 (gnus-summary-skip-intangible)
3322 (or (get-text-property (point) 'gnus-number)
3323 (gnus-summary-last-subject))))
3325 (defmacro gnus-summary-article-header (&optional number)
3326 "Return the header of article NUMBER."
3327 `(gnus-data-header (gnus-data-find
3328 ,(or number '(gnus-summary-article-number)))))
3330 (defmacro gnus-summary-thread-level (&optional number)
3331 "Return the level of thread that starts with article NUMBER."
3332 `(if (and (eq gnus-summary-make-false-root 'dummy)
3333 (get-text-property (point) 'gnus-intangible))
3335 (gnus-data-level (gnus-data-find
3336 ,(or number '(gnus-summary-article-number))))))
3338 (defmacro gnus-summary-article-mark (&optional number)
3339 "Return the mark of article NUMBER."
3340 `(gnus-data-mark (gnus-data-find
3341 ,(or number '(gnus-summary-article-number)))))
3343 (defmacro gnus-summary-article-pos (&optional number)
3344 "Return the position of the line of article NUMBER."
3345 `(gnus-data-pos (gnus-data-find
3346 ,(or number '(gnus-summary-article-number)))))
3348 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3349 (defmacro gnus-summary-article-subject (&optional number)
3350 "Return current subject string or nil if nothing."
3353 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3354 '(gnus-data-header (assq (gnus-summary-article-number)
3355 gnus-newsgroup-data)))))
3358 (mail-header-subject headers))))
3360 (defmacro gnus-summary-article-score (&optional number)
3361 "Return current article score."
3362 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3363 gnus-newsgroup-scored))
3364 gnus-summary-default-score 0))
3366 (defun gnus-summary-article-children (&optional number)
3367 "Return a list of article numbers that are children of article NUMBER."
3368 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3369 (level (gnus-data-level (car data)))
3371 (while (and (setq data (cdr data))
3372 (> (setq l (gnus-data-level (car data))) level))
3373 (and (= (1+ level) l)
3374 (push (gnus-data-number (car data))
3376 (nreverse children)))
3378 (defun gnus-summary-article-parent (&optional number)
3379 "Return the article number of the parent of article NUMBER."
3380 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3381 (gnus-data-list t)))
3382 (level (gnus-data-level (car data))))
3384 () ; This is a root.
3385 ;; We search until we find an article with a level less than
3386 ;; this one. That function has to be the parent.
3387 (while (and (setq data (cdr data))
3388 (not (< (gnus-data-level (car data)) level))))
3389 (and data (gnus-data-number (car data))))))
3391 (defun gnus-unread-mark-p (mark)
3392 "Say whether MARK is the unread mark."
3393 (= mark gnus-unread-mark))
3395 (defun gnus-read-mark-p (mark)
3396 "Say whether MARK is one of the marks that mark as read.
3397 This is all marks except unread, ticked, dormant, and expirable."
3398 (not (or (= mark gnus-unread-mark)
3399 (= mark gnus-ticked-mark)
3400 (= mark gnus-spam-mark)
3401 (= mark gnus-dormant-mark)
3402 (= mark gnus-expirable-mark))))
3404 (defmacro gnus-article-mark (number)
3405 "Return the MARK of article NUMBER.
3406 This macro should only be used when computing the mark the \"first\"
3407 time; i.e., when generating the summary lines. After that,
3408 `gnus-summary-article-mark' should be used to examine the
3411 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3412 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3413 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3414 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3415 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3416 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3417 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3418 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3419 gnus-ancient-mark))))
3421 ;; Saving hidden threads.
3423 (defmacro gnus-save-hidden-threads (&rest forms)
3424 "Save hidden threads, eval FORMS, and restore the hidden threads."
3425 (let ((config (make-symbol "config")))
3426 `(let ((,config (gnus-hidden-threads-configuration)))
3430 (gnus-restore-hidden-threads-configuration ,config)))))
3431 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3432 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3434 (defun gnus-data-compute-positions ()
3435 "Compute the positions of all articles."
3436 (setq gnus-newsgroup-data-reverse nil)
3437 (let ((data gnus-newsgroup-data))
3439 (gnus-save-hidden-threads
3440 (gnus-summary-show-all-threads)
3441 (goto-char (point-min))
3443 (while (get-text-property (point) 'gnus-intangible)
3445 (gnus-data-set-pos (car data) (+ (point) 3))
3446 (setq data (cdr data))
3447 (forward-line 1))))))
3449 (defun gnus-hidden-threads-configuration ()
3450 "Return the current hidden threads configuration."
3453 (goto-char (point-min))
3455 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3456 (push (save-excursion (forward-line 0) (point)) config))
3460 (defun gnus-restore-hidden-threads-configuration (config)
3461 "Restore hidden threads configuration from CONFIG."
3463 (let (point (inhibit-read-only t))
3464 (while (setq point (pop config))
3466 (gnus-summary-hide-thread)))))
3468 ;; Various summary mode internalish functions.
3470 (defun gnus-mouse-pick-article (e)
3473 (gnus-summary-next-page nil t))
3475 (defun gnus-summary-set-display-table ()
3476 "Change the display table.
3477 Odd characters have a tendency to mess
3478 up nicely formatted displays - we make all possible glyphs
3479 display only a single character."
3481 ;; We start from the standard display table, if any.
3482 (let ((table (or (copy-sequence standard-display-table)
3483 (make-display-table)))
3485 ;; Nix out all the control chars...
3486 (while (>= (setq i (1- i)) 0)
3487 (gnus-put-display-table i [??] table))
3488 ;; ... but not newline and cr, of course. (cr is necessary for the
3489 ;; selective display).
3490 (gnus-put-display-table ?\n nil table)
3491 (gnus-put-display-table ?\r nil table)
3492 ;; We keep TAB as well.
3493 (gnus-put-display-table ?\t nil table)
3494 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3495 ;; Emacs 23 (unicode), that are not set already.
3496 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3499 (while (>= (setq i (1- i)) 127)
3500 ;; Only modify if the entry is nil.
3501 (unless (gnus-get-display-table i table)
3502 (gnus-put-display-table i [??] table))))
3503 (setq buffer-display-table table)))
3505 (defun gnus-summary-set-article-display-arrow (pos)
3506 "Update the overlay arrow to point to line at position POS."
3507 (when gnus-summary-display-arrow
3508 (make-local-variable 'overlay-arrow-position)
3509 (make-local-variable 'overlay-arrow-string)
3513 (unless overlay-arrow-position
3514 (setq overlay-arrow-position (make-marker)))
3515 (setq overlay-arrow-string "=>"
3516 overlay-arrow-position (set-marker overlay-arrow-position
3518 (current-buffer))))))
3520 (defun gnus-summary-setup-buffer (group)
3521 "Initialize summary buffer.
3522 If the setup was successful, non-nil is returned."
3523 (let ((buffer (gnus-summary-buffer-name group))
3524 (dead-name (concat "*Dead Summary "
3525 (gnus-group-decoded-name group) "*")))
3526 ;; If a dead summary buffer exists, we kill it.
3527 (when (gnus-buffer-live-p dead-name)
3528 (gnus-kill-buffer dead-name))
3529 (if (get-buffer buffer)
3532 (setq gnus-summary-buffer (current-buffer))
3533 (not gnus-newsgroup-prepared))
3534 (set-buffer (gnus-get-buffer-create buffer))
3535 (setq gnus-summary-buffer (current-buffer))
3536 (gnus-summary-mode group)
3537 (when (gnus-group-quit-config group)
3538 (set (make-local-variable 'gnus-single-article-buffer) nil))
3539 (make-local-variable 'gnus-article-buffer)
3540 (make-local-variable 'gnus-article-current)
3541 (make-local-variable 'gnus-original-article-buffer)
3542 (setq gnus-newsgroup-name group)
3543 ;; Set any local variables in the group parameters.
3544 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3547 (defun gnus-set-global-variables ()
3548 "Set the global equivalents of the buffer-local variables.
3549 They are set to the latest values they had. These reflect the summary
3550 buffer that was in action when the last article was fetched."
3551 (when (derived-mode-p 'gnus-summary-mode)
3552 (setq gnus-summary-buffer (current-buffer))
3553 (let ((name gnus-newsgroup-name)
3554 (marked gnus-newsgroup-marked)
3555 (spam gnus-newsgroup-spam-marked)
3556 (unread gnus-newsgroup-unreads)
3557 (headers gnus-current-headers)
3558 (data gnus-newsgroup-data)
3559 (summary gnus-summary-buffer)
3560 (article-buffer gnus-article-buffer)
3561 (original gnus-original-article-buffer)
3562 (gac gnus-article-current)
3563 (reffed gnus-reffed-article-number)
3564 (score-file gnus-current-score-file)
3565 (default-charset gnus-newsgroup-charset)
3567 (let ((locals gnus-newsgroup-variables))
3569 (if (consp (car locals))
3570 (push (eval (caar locals)) vlist)
3571 (push (eval (car locals)) vlist))
3572 (setq locals (cdr locals)))
3573 (setq vlist (nreverse vlist)))
3575 (setq gnus-newsgroup-name name
3576 gnus-newsgroup-marked marked
3577 gnus-newsgroup-spam-marked spam
3578 gnus-newsgroup-unreads unread
3579 gnus-current-headers headers
3580 gnus-newsgroup-data data
3581 gnus-article-current gac
3582 gnus-summary-buffer summary
3583 gnus-article-buffer article-buffer
3584 gnus-original-article-buffer original
3585 gnus-reffed-article-number reffed
3586 gnus-current-score-file score-file
3587 gnus-newsgroup-charset default-charset)
3588 (let ((locals gnus-newsgroup-variables))
3590 (if (consp (car locals))
3591 (set (caar locals) (pop vlist))
3592 (set (car locals) (pop vlist)))
3593 (setq locals (cdr locals))))))))
3595 (defun gnus-summary-article-unread-p (article)
3596 "Say whether ARTICLE is unread or not."
3597 (memq article gnus-newsgroup-unreads))
3599 (defun gnus-summary-first-article-p (&optional article)
3600 "Return whether ARTICLE is the first article in the buffer."
3601 (if (not (setq article (or article (gnus-summary-article-number))))
3603 (eq article (caar gnus-newsgroup-data))))
3605 (defun gnus-summary-last-article-p (&optional article)
3606 "Return whether ARTICLE is the last article in the buffer."
3607 (if (not (setq article (or article (gnus-summary-article-number))))
3608 ;; All non-existent numbers are the last article. :-)
3610 (not (cdr (gnus-data-find-list article)))))
3612 (defun gnus-make-thread-indent-array (&optional n)
3614 (progn (setq n 200) nil)
3615 (null gnus-thread-indent-array)
3616 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3617 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3618 gnus-thread-indent-array-level gnus-thread-indent-level)
3620 (aset gnus-thread-indent-array n
3621 (make-string (* n gnus-thread-indent-level) ? ))
3624 (defun gnus-update-summary-mark-positions ()
3625 "Compute where the summary marks are to go."
3627 (when (gnus-buffer-exists-p gnus-summary-buffer)
3628 (set-buffer gnus-summary-buffer))
3629 (let ((spec gnus-summary-line-format-spec)
3632 (gnus-set-work-buffer)
3633 (let ((gnus-tmp-unread ?Z)
3634 (gnus-replied-mark ?Z)
3635 (gnus-score-below-mark ?Z)
3636 (gnus-score-over-mark ?Z)
3637 (gnus-undownloaded-mark ?Z)
3638 (gnus-summary-line-format-spec spec)
3639 (gnus-newsgroup-downloadable '(0))
3640 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3641 case-fold-search ignores)
3642 ;; Here, all marks are bound to Z.
3643 (gnus-summary-insert-line header
3644 0 nil t gnus-tmp-unread t nil "" nil 1)
3645 (goto-char (point-min))
3646 ;; Memorize the positions of the same characters as dummy marks.
3647 (while (re-search-forward "[A-D]" nil t)
3648 (push (point) ignores))
3650 ;; We use A-D as dummy marks in order to know column positions
3651 ;; where marks should be inserted.
3652 (setq gnus-tmp-unread ?A
3653 gnus-replied-mark ?B
3654 gnus-score-below-mark ?C
3655 gnus-score-over-mark ?C
3656 gnus-undownloaded-mark ?D)
3657 (gnus-summary-insert-line header
3658 0 nil t gnus-tmp-unread t nil "" nil 1)
3659 ;; Ignore characters which aren't dummy marks.
3661 (delete-region (goto-char (1- p)) p)
3663 (goto-char (point-min))
3664 (setq pos (list (cons 'unread
3665 (and (search-forward "A" nil t)
3666 (- (point) (point-min) 1)))))
3667 (goto-char (point-min))
3668 (push (cons 'replied (and (search-forward "B" nil t)
3669 (- (point) (point-min) 1)))
3671 (goto-char (point-min))
3672 (push (cons 'score (and (search-forward "C" nil t)
3673 (- (point) (point-min) 1)))
3675 (goto-char (point-min))
3676 (push (cons 'download (and (search-forward "D" nil t)
3677 (- (point) (point-min) 1)))
3679 (setq gnus-summary-mark-positions pos))))
3681 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3682 "Insert a dummy root in the summary buffer."
3684 (gnus-add-text-properties
3685 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3686 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3688 (defun gnus-summary-extract-address-component (from)
3689 (or (car (funcall gnus-extract-address-components from))
3692 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3693 (let ((mail-parse-charset gnus-newsgroup-charset)
3694 ;; Is it really necessary to do this next part for each summary line?
3695 ;; Luckily, doesn't seem to slow things down much.
3696 (mail-parse-ignored-charsets
3697 (with-current-buffer gnus-summary-buffer
3698 gnus-newsgroup-ignored-charsets)))
3700 (and gnus-ignored-from-addresses
3701 (cond ((functionp gnus-ignored-from-addresses)
3702 (funcall gnus-ignored-from-addresses
3703 (mail-strip-quoted-names gnus-tmp-from)))
3704 (t (string-match (gnus-ignored-from-addresses) gnus-tmp-from)))
3705 (let ((extra-headers (mail-header-extra header))
3709 ((setq to (cdr (assq 'To extra-headers)))
3710 (concat gnus-summary-to-prefix
3712 (gnus-summary-extract-address-component
3713 (funcall gnus-decode-encoded-address-function to)))))
3716 (cdr (assq 'Newsgroups extra-headers))
3718 (memq 'Newsgroups gnus-extra-headers)
3719 (eq (car (gnus-find-method-for-group
3720 gnus-newsgroup-name)) 'nntp)
3721 (gnus-group-real-name gnus-newsgroup-name))))
3722 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3723 (gnus-string-mark-left-to-right
3725 (gnus-summary-extract-address-component gnus-tmp-from))))))
3727 (defun gnus-summary-insert-line (gnus-tmp-header
3728 gnus-tmp-level gnus-tmp-current
3729 undownloaded gnus-tmp-unread gnus-tmp-replied
3730 gnus-tmp-expirable gnus-tmp-subject-or-nil
3731 &optional gnus-tmp-dummy gnus-tmp-score
3733 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3734 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3736 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3737 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3738 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3739 (gnus-tmp-score-char
3740 (if (or (null gnus-summary-default-score)
3741 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3742 gnus-summary-zcore-fuzz))
3744 (if (< gnus-tmp-score gnus-summary-default-score)
3745 gnus-score-below-mark gnus-score-over-mark)))
3746 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3748 (cond (gnus-tmp-process gnus-process-mark)
3749 ((memq gnus-tmp-current gnus-newsgroup-cached)
3751 (gnus-tmp-replied gnus-replied-mark)
3752 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3753 gnus-forwarded-mark)
3754 ((memq gnus-tmp-current gnus-newsgroup-saved)
3756 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3759 (gnus-tmp-downloaded
3761 gnus-undownloaded-mark)
3762 (gnus-newsgroup-agentized
3763 gnus-downloaded-mark)
3766 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3769 ((string-match "<[^>]+> *$" gnus-tmp-from)
3770 (let ((beg (match-beginning 0)))
3771 (or (and (string-match "^\".+\"" gnus-tmp-from)
3772 (substring gnus-tmp-from 1 (1- (match-end 0))))
3773 (substring gnus-tmp-from 0 beg))))
3774 ((string-match "(.+)" gnus-tmp-from)
3775 (substring gnus-tmp-from
3776 (1+ (match-beginning 0)) (1- (match-end 0))))
3778 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3779 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3780 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3781 (inhibit-read-only t))
3782 (when (string= gnus-tmp-name "")
3783 (setq gnus-tmp-name gnus-tmp-from))
3784 (unless (numberp gnus-tmp-lines)
3785 (setq gnus-tmp-lines -1))
3786 (if (= gnus-tmp-lines -1)
3787 (setq gnus-tmp-lines "?")
3788 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3790 (gnus-put-text-property
3792 (progn (eval gnus-summary-line-format-spec) (point))
3793 'gnus-number gnus-tmp-number)
3794 (error (gnus-message 5 "Error updating the summary line")))
3795 (when (gnus-visual-p 'summary-highlight 'highlight)
3797 (gnus-summary-highlight-line)
3798 (gnus-run-hooks 'gnus-summary-update-hook)
3801 (defun gnus-summary-update-line (&optional dont-update)
3802 "Update summary line after change."
3803 (when (and gnus-summary-default-score
3804 (not gnus-summary-inhibit-highlight))
3805 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3806 (article (gnus-summary-article-number))
3807 (score (gnus-summary-article-score article)))
3809 (if (and gnus-summary-mark-below
3810 (< (gnus-summary-article-score)
3811 gnus-summary-mark-below))
3812 ;; This article has a low score, so we mark it as read.
3813 (when (memq article gnus-newsgroup-unreads)
3814 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3815 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3816 ;; This article was previously marked as read on account
3817 ;; of a low score, but now it has risen, so we mark it as
3819 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3820 (gnus-summary-update-mark
3821 (if (or (null gnus-summary-default-score)
3822 (<= (abs (- score gnus-summary-default-score))
3823 gnus-summary-zcore-fuzz))
3825 (if (< score gnus-summary-default-score)
3826 gnus-score-below-mark gnus-score-over-mark))
3828 ;; Do visual highlighting.
3829 (when (gnus-visual-p 'summary-highlight 'highlight)
3830 (gnus-summary-highlight-line)
3831 (gnus-run-hooks 'gnus-summary-update-hook)))))
3833 (defvar gnus-tmp-new-adopts nil)
3835 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3836 "Return the number of articles in THREAD.
3837 This may be 0 in some cases -- if none of the articles in
3838 the thread are to be displayed."
3840 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3842 ((not (listp thread))
3844 ((and (consp thread) (cdr thread))
3847 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3850 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3853 (when (and level (zerop level) gnus-tmp-new-adopts)
3856 'gnus-summary-number-of-articles-in-thread
3857 gnus-tmp-new-adopts))))
3859 (if (> number 1) gnus-not-empty-thread-mark
3860 gnus-empty-thread-mark)
3863 (defsubst gnus-summary-line-message-size (head)
3864 "Return pretty-printed version of message size.
3865 This function is intended to be used in
3866 `gnus-summary-line-format-alist'."
3867 (let ((c (or (mail-header-chars head) -1)))
3868 (cond ((< c 0) "n/a") ; chars not available
3869 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3870 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3871 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3872 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3874 (defcustom gnus-user-date-format-alist
3875 '(((gnus-seconds-today) . "Today, %H:%M")
3876 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3877 (604800 . "%A %H:%M") ; That's one week
3878 ((gnus-seconds-month) . "%A %d")
3879 ((gnus-seconds-year) . "%B %d")
3880 (t . "%b %d %Y")) ; This one is used when no other
3882 "Specifies date format depending on age of article.
3883 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3884 seconds) or a Lisp expression evaluating to a number. When the age of
3885 the article is less than this number, then use `format-time-string'
3886 with the corresponding FORMAT for displaying the date of the article.
3887 If AGE is not a number or a Lisp expression evaluating to a
3888 non-number, then the corresponding FORMAT is used as a default value.
3890 Note that the list is processed from the beginning, so it should be
3891 sorted by ascending AGE. Also note that items following the first
3892 non-number AGE will be ignored.
3894 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3895 and `gnus-seconds-year' in the AGE spec. They return the number of
3896 seconds passed since the start of today, of this month, of this year,
3899 :group 'gnus-summary-format
3900 :type '(alist :key-type sexp :value-type string))
3902 (defun gnus-user-date (messy-date)
3903 "Format the messy-date according to `gnus-user-date-format-alist'.
3904 Returns \" ? \" if there's bad input or if another error occurs.
3905 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3907 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3908 (now (gnus-float-time))
3909 ;;If we don't find something suitable we'll use this one
3910 (my-format "%b %d '%y"))
3911 (let* ((difference (- now messy-date))
3912 (templist gnus-user-date-format-alist)
3913 (top (eval (caar templist))))
3914 (while (if (numberp top) (< top difference) (not top))
3916 (setq templist (cdr templist))
3917 (setq top (eval (caar templist)))))
3918 (if (stringp (cdr (car templist)))
3919 (setq my-format (cdr (car templist)))))
3920 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3923 (defun gnus-summary-set-local-parameters (group)
3924 "Go through the local params of GROUP and set all variable specs in that list."
3925 (let ((vars '(quit-config active))) ; Ignore things that aren't
3927 (dolist (elem (gnus-group-find-parameter group))
3928 (and (consp elem) ; Has to be a cons.
3929 (consp (cdr elem)) ; The cdr has to be a list.
3930 (symbolp (car elem)) ; Has to be a symbol in there.
3931 (not (memq (car elem) vars))
3933 (push (car elem) vars)
3934 ;; Variables like `gnus-show-threads' that are globally
3935 ;; bound, if used as group parameters, need to get to be
3936 ;; buffer-local, whereas just parameters like `gcc-self',
3937 ;; `timestamp', etc. should not be bound as variables.
3938 (if (boundp (car elem))
3939 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3940 (eval (nth 1 elem))))))))
3942 (defun gnus-summary-read-group (group &optional show-all no-article
3943 kill-buffer no-display backward
3945 "Start reading news in newsgroup GROUP.
3946 If SHOW-ALL is non-nil, already read articles are also listed.
3947 If NO-ARTICLE is non-nil, no article is selected initially.
3948 If NO-DISPLAY, don't generate the summary buffer contents.
3949 If KILL-BUFFER, it should be a buffer that's killed once the new
3950 summary buffer has been generated.
3951 If BACKWARD, move point to the previous group in the group buffer
3952 If SELECT-ARTICLES, only select those articles from GROUP."
3956 (let ((gnus-auto-select-next nil))
3957 (or (gnus-summary-read-group-1
3958 group show-all no-article
3959 kill-buffer no-display
3962 select-articles nil)))))
3963 (eq gnus-auto-select-next 'quietly))
3964 (set-buffer gnus-group-buffer)
3965 ;; The entry function called above goes to the next
3966 ;; group automatically, so we go two groups back
3967 ;; if we are searching for the previous group.
3969 (gnus-group-prev-unread-group 2))
3970 (if (not (equal group (gnus-group-group-name)))
3971 (setq group (gnus-group-group-name))
3975 (defun gnus-summary-read-group-1 (group show-all no-article
3976 kill-buffer no-display
3977 &optional select-articles)
3978 ;; Killed foreign groups can't be entered.
3979 ;; (when (and (not (gnus-group-native-p group))
3980 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3981 ;; (error "Dead non-native groups can't be entered"))
3982 (gnus-message 7 "Retrieving newsgroup: %s..."
3983 (gnus-group-decoded-name group))
3984 (let* ((new-group (gnus-summary-setup-buffer group))
3985 (quit-config (gnus-group-quit-config group))
3986 (did-select (and new-group (gnus-select-newsgroup
3987 group show-all select-articles))))
3989 ;; This summary buffer exists already, so we just select it.
3991 (gnus-set-global-variables)
3993 (gnus-kill-or-deaden-summary kill-buffer))
3994 (gnus-configure-windows 'summary 'force)
3995 (gnus-set-mode-line 'summary)
3996 (gnus-summary-position-point)
3999 ;; We couldn't select this group.
4001 (when (and (derived-mode-p 'gnus-summary-mode)
4002 (not (equal (current-buffer) kill-buffer)))
4003 (kill-buffer (current-buffer))
4004 (if (not quit-config)
4006 ;; Update the info -- marks might need to be removed,
4008 (gnus-summary-update-info)
4009 (set-buffer gnus-group-buffer)
4010 (gnus-group-jump-to-group group)
4011 (gnus-group-next-unread-group 1))
4012 (gnus-handle-ephemeral-exit quit-config)))
4013 (if (null (gnus-list-of-unread-articles group))
4014 (gnus-message 3 "Group %s contains no messages"
4015 (gnus-group-decoded-name group))
4016 (gnus-message 3 "Can't select group"))
4018 ;; The user did a `C-g' while prompting for number of articles,
4019 ;; so we exit this group.
4020 ((eq did-select 'quit)
4021 (and (derived-mode-p 'gnus-summary-mode)
4022 (not (equal (current-buffer) kill-buffer))
4023 (kill-buffer (current-buffer)))
4025 (gnus-kill-or-deaden-summary kill-buffer))
4026 (if (not quit-config)
4028 (set-buffer gnus-group-buffer)
4029 (gnus-group-jump-to-group group)
4030 (gnus-configure-windows 'group 'force))
4031 (gnus-handle-ephemeral-exit quit-config))
4032 ;; Finally signal the quit.
4034 ;; The group was successfully selected.
4036 (gnus-set-global-variables)
4037 (when (boundp 'spam-install-hooks)
4039 ;; Save the active value in effect when the group was entered.
4040 (setq gnus-newsgroup-active
4042 (gnus-active gnus-newsgroup-name)))
4043 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4044 ;; You can change the summary buffer in some way with this hook.
4045 (gnus-run-hooks 'gnus-select-group-hook)
4046 (when (memq 'summary (gnus-update-format-specifications
4047 nil 'summary 'summary-mode 'summary-dummy))
4048 ;; The format specification for the summary line was updated,
4049 ;; so we need to update the mark positions as well.
4050 (gnus-update-summary-mark-positions))
4051 ;; Do score processing.
4052 (when gnus-use-scoring
4053 (gnus-possibly-score-headers))
4054 ;; Check whether to fill in the gaps in the threads.
4055 (when gnus-build-sparse-threads
4056 (gnus-build-sparse-threads))
4057 ;; Find the initial limit.
4059 (let ((gnus-newsgroup-dormant nil))
4060 (gnus-summary-initial-limit show-all))
4061 (gnus-summary-initial-limit show-all))
4062 ;; Generate the summary buffer.
4064 (gnus-summary-prepare))
4065 (when gnus-use-trees
4067 (setq gnus-summary-highlight-line-function
4068 'gnus-tree-highlight-article))
4069 ;; If the summary buffer is empty, but there are some low-scored
4070 ;; articles or some excluded dormants, we include these in the
4072 (when (and (zerop (buffer-size))
4074 (cond (gnus-newsgroup-dormant
4075 (gnus-summary-limit-include-dormant))
4076 ((and gnus-newsgroup-scored show-all)
4077 (gnus-summary-limit-include-expunged t))))
4078 ;; Function `gnus-apply-kill-file' must be called in this hook.
4079 (gnus-run-hooks 'gnus-apply-kill-hook)
4080 (if (and (zerop (buffer-size))
4083 ;; This newsgroup is empty.
4084 (gnus-summary-catchup-and-exit nil t)
4085 (gnus-message 6 "No unread news")
4087 (gnus-kill-or-deaden-summary kill-buffer))
4088 ;; Return nil from this function.
4090 ;; Hide conversation thread subtrees. We cannot do this in
4091 ;; gnus-summary-prepare-hook since kill processing may not
4092 ;; work with hidden articles.
4093 (gnus-summary-maybe-hide-threads)
4094 (gnus-configure-windows 'summary)
4096 (gnus-kill-or-deaden-summary kill-buffer))
4097 (gnus-summary-auto-select-subject)
4098 ;; Show first unread article if requested.
4099 (if (and (not no-article)
4101 gnus-newsgroup-unreads
4102 gnus-auto-select-first)
4104 (let ((art (gnus-summary-article-number)))
4107 (not (memq art gnus-newsgroup-undownloaded))
4108 (not (memq art gnus-newsgroup-downloadable)))
4109 (gnus-summary-goto-article art))))
4110 ;; Don't select any articles.
4111 (gnus-summary-position-point)
4112 (gnus-configure-windows 'summary 'force)
4113 (gnus-set-mode-line 'summary))
4114 (when (and gnus-auto-center-group
4115 (get-buffer-window gnus-group-buffer t))
4116 ;; Gotta use windows, because recenter does weird stuff if
4117 ;; the current buffer ain't the displayed window.
4118 (let ((owin (selected-window)))
4119 (select-window (get-buffer-window gnus-group-buffer t))
4120 (when (gnus-group-goto-group group)
4122 (select-window owin)))
4123 ;; Mark this buffer as "prepared".
4124 (setq gnus-newsgroup-prepared t)
4125 (gnus-run-hooks 'gnus-summary-prepared-hook)
4126 (unless (gnus-ephemeral-group-p group)
4127 (gnus-group-update-group group nil t))
4130 (defun gnus-summary-auto-select-subject ()
4131 "Select the subject line on initial group entry."
4132 (goto-char (point-min))
4134 ((eq gnus-auto-select-subject 'best)
4135 (gnus-summary-best-unread-subject))
4136 ((eq gnus-auto-select-subject 'unread)
4137 (gnus-summary-first-unread-subject))
4138 ((eq gnus-auto-select-subject 'unseen)
4139 (gnus-summary-first-unseen-subject))
4140 ((eq gnus-auto-select-subject 'unseen-or-unread)
4141 (gnus-summary-first-unseen-or-unread-subject))
4142 ((eq gnus-auto-select-subject 'first)
4145 ((functionp gnus-auto-select-subject)
4146 (funcall gnus-auto-select-subject))))
4148 (defun gnus-summary-prepare ()
4149 "Generate the summary buffer."
4151 (let ((inhibit-read-only t))
4153 (setq gnus-newsgroup-data nil
4154 gnus-newsgroup-data-reverse nil)
4155 (gnus-run-hooks 'gnus-summary-generate-hook)
4156 ;; Generate the buffer, either with threads or without.
4157 (when gnus-newsgroup-headers
4158 (gnus-summary-prepare-threads
4159 (if gnus-show-threads
4160 (gnus-sort-gathered-threads
4161 (funcall gnus-summary-thread-gathering-function
4163 (gnus-cut-threads (gnus-make-threads)))))
4164 ;; Unthreaded display.
4165 (gnus-sort-articles gnus-newsgroup-headers))))
4166 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4167 ;; Call hooks for modifying summary buffer.
4168 (goto-char (point-min))
4169 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4171 (defsubst gnus-general-simplify-subject (subject)
4172 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4175 ;; Truncate the subject.
4176 (gnus-simplify-subject-functions
4177 (gnus-map-function gnus-simplify-subject-functions subject))
4178 ((numberp gnus-summary-gather-subject-limit)
4179 (setq subject (gnus-simplify-subject-re subject))
4180 (if (> (length subject) gnus-summary-gather-subject-limit)
4181 (substring subject 0 gnus-summary-gather-subject-limit)
4183 ;; Fuzzily simplify it.
4184 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4185 (gnus-simplify-subject-fuzzy subject))
4186 ;; Just remove the leading "Re:".
4188 (gnus-simplify-subject-re subject))))
4190 (if (and gnus-summary-gather-exclude-subject
4191 (string-match gnus-summary-gather-exclude-subject subject))
4192 nil ; This article shouldn't be gathered
4195 (defun gnus-summary-simplify-subject-query ()
4196 "Query where the respool algorithm would put this article."
4198 (gnus-summary-select-article)
4199 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4201 (defun gnus-gather-threads-by-subject (threads)
4202 "Gather threads by looking at Subject headers."
4203 (if (not gnus-summary-make-false-root)
4205 (let ((hashtb (gnus-make-hashtable 1024))
4208 subject hthread whole-subject)
4210 (setq subject (gnus-general-simplify-subject
4211 (setq whole-subject (mail-header-subject
4214 (if (setq hthread (gnus-gethash subject hashtb))
4216 ;; We enter a dummy root into the thread, if we
4217 ;; haven't done that already.
4218 (unless (stringp (caar hthread))
4219 (setcar hthread (list whole-subject (car hthread))))
4220 ;; We add this new gathered thread to this gathered
4222 (setcdr (car hthread)
4223 (nconc (cdar hthread) (list (car threads))))
4224 ;; Remove it from the list of threads.
4225 (setcdr prev (cdr threads))
4226 (setq threads prev))
4227 ;; Enter this thread into the hash table.
4228 (gnus-sethash subject
4229 (if gnus-summary-make-false-root-always
4231 ;; If you want a dummy root above all
4233 (setcar threads (list whole-subject
4239 (setq threads (cdr threads)))
4242 (defun gnus-gather-threads-by-references (threads)
4243 "Gather threads by looking at References headers."
4244 (let ((idhashtb (gnus-make-hashtable 1024))
4245 (thhashtb (gnus-make-hashtable 1024))
4248 ids references id gthread gid entered ref)
4250 (when (setq references (mail-header-references (caar threads)))
4251 (setq id (mail-header-id (caar threads))
4252 ids (inline (gnus-split-references references))
4254 (while (setq ref (pop ids))
4255 (setq ids (delete ref ids))
4256 (if (not (setq gid (gnus-gethash ref idhashtb)))
4258 (gnus-sethash ref id idhashtb)
4259 (gnus-sethash id threads thhashtb))
4260 (setq gthread (gnus-gethash gid thhashtb))
4262 ;; We enter a dummy root into the thread, if we
4263 ;; haven't done that already.
4264 (unless (stringp (caar gthread))
4265 (setcar gthread (list (mail-header-subject (caar gthread))
4267 ;; We add this new gathered thread to this gathered
4269 (setcdr (car gthread)
4270 (nconc (cdar gthread) (list (car threads)))))
4271 ;; Add it into the thread hash table.
4272 (gnus-sethash id gthread thhashtb)
4274 ;; Remove it from the list of threads.
4275 (setcdr prev (cdr threads))
4276 (setq threads prev))))
4278 (setq threads (cdr threads)))
4281 (defun gnus-sort-gathered-threads (threads)
4282 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4283 (let ((result threads))
4285 (when (stringp (caar threads))
4286 (setcdr (car threads)
4287 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4288 (setq threads (cdr threads)))
4291 (defun gnus-thread-loop-p (root thread)
4292 "Say whether ROOT is in THREAD."
4293 (let ((stack (list thread))
4296 (while (setq thread (pop stack))
4297 (setq th (cdr thread))
4299 (not (eq (caar th) root)))
4302 ;; We have found a loop.
4304 (setcdr thread (delq (car th) (cdr thread)))
4305 (if (boundp (setq ref-dep (intern "none"
4306 gnus-newsgroup-dependencies)))
4307 (setcdr (symbol-value ref-dep)
4308 (nconc (cdr (symbol-value ref-dep))
4310 (set ref-dep (list nil (car th))))
4313 ;; Push all the subthreads onto the stack.
4314 (push (cdr thread) stack)))
4317 (defun gnus-make-threads ()
4318 "Go through the dependency hashtb and find the roots. Return all threads."
4320 (while (catch 'infloop
4323 ;; Deal with self-referencing References loops.
4324 (when (and (car (symbol-value refs))
4331 (car (symbol-value refs)) thread))
4332 (cdr (symbol-value refs)))))))
4335 (unless (car (symbol-value refs))
4336 ;; These threads do not refer back to any other
4337 ;; articles, so they're roots.
4338 (setq threads (append (cdr (symbol-value refs)) threads))))
4339 gnus-newsgroup-dependencies)))
4342 ;; Build the thread tree.
4343 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4344 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4346 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4347 if it was already present.
4349 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4350 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4351 Message-IDs will be renamed to a unique Message-ID before being
4354 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4355 (let* ((id (mail-header-id header))
4356 (id-dep (and id (intern id dependencies)))
4357 parent-id ref ref-dep ref-header replaced)
4358 ;; Enter this `header' in the `dependencies' table.
4362 ;; The first two cases do the normal part: enter a new `header'
4363 ;; in the `dependencies' table.
4364 ((not (boundp id-dep))
4365 (set id-dep (list header)))
4366 ((null (car (symbol-value id-dep)))
4367 (setcar (symbol-value id-dep) header))
4369 ;; From here the `header' was already present in the
4370 ;; `dependencies' table.
4372 ;; Overrides an existing entry;
4373 ;; just set the header part of the entry.
4374 (setcar (symbol-value id-dep) header)
4377 ;; Renames the existing `header' to a unique Message-ID.
4378 ((not gnus-summary-ignore-duplicates)
4379 ;; An article with this Message-ID has already been seen.
4380 ;; We rename the Message-ID.
4381 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4383 (mail-header-set-id header id))
4385 ;; The last case ignores an existing entry, except it adds any
4386 ;; additional Xrefs (in case the two articles came from different
4388 ;; Also sets `header' to nil meaning that the `dependencies'
4389 ;; table was *not* modified.
4391 (mail-header-set-xref
4392 (car (symbol-value id-dep))
4393 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4395 (or (mail-header-xref header) "")))
4398 (when (and header (not replaced))
4399 ;; First check that we are not creating a References loop.
4400 (setq parent-id (gnus-parent-id (mail-header-references header)))
4401 (setq ref parent-id)
4403 (setq ref-dep (intern-soft ref dependencies))
4405 (setq ref-header (car (symbol-value ref-dep))))
4406 (if (string= id ref)
4407 ;; Yuk! This is a reference loop. Make the article be a
4410 (mail-header-set-references (car (symbol-value id-dep)) "none")
4412 (setq parent-id nil))
4413 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4414 (setq ref-dep (intern (or parent-id "none") dependencies))
4415 (if (boundp ref-dep)
4416 (setcdr (symbol-value ref-dep)
4417 (nconc (cdr (symbol-value ref-dep))
4418 (list (symbol-value id-dep))))
4419 (set ref-dep (list nil (symbol-value id-dep)))))
4422 (defun gnus-extract-message-id-from-in-reply-to (string)
4423 (if (string-match "<[^>]+>" string)
4424 (substring string (match-beginning 0) (match-end 0))
4427 (defun gnus-build-sparse-threads ()
4428 (let ((headers gnus-newsgroup-headers)
4429 (mail-parse-charset gnus-newsgroup-charset)
4430 (gnus-summary-ignore-duplicates t)
4431 header references generation relations
4432 subject child end new-child date)
4433 ;; First we create an alist of generations/relations, where
4434 ;; generations is how much we trust the relation, and the relation
4436 (gnus-message 7 "Making sparse threads...")
4438 (nnheader-set-temp-buffer " *gnus sparse threads*")
4439 (while (setq header (pop headers))
4440 (when (and (setq references (mail-header-references header))
4441 (not (string= references "")))
4443 (setq child (mail-header-id header)
4444 subject (mail-header-subject header)
4445 date (mail-header-date header)
4447 (while (search-backward ">" nil t)
4448 (setq end (1+ (point)))
4449 (when (search-backward "<" nil t)
4450 (setq new-child (buffer-substring (point) end))
4451 (push (list (incf generation)
4452 child (setq child new-child)
4456 (push (list (1+ generation) child nil subject) relations))
4458 (kill-buffer (current-buffer)))
4459 ;; Sort over trustworthiness.
4460 (dolist (relation (sort relations 'car-less-than-car))
4461 (when (gnus-dependencies-add-header
4462 (make-full-mail-header
4463 gnus-reffed-article-number
4464 (nth 3 relation) "" (or (nth 4 relation) "")
4466 (or (nth 2 relation) "") 0 0 "")
4467 gnus-newsgroup-dependencies nil)
4468 (push gnus-reffed-article-number gnus-newsgroup-limit)
4469 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4470 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4471 gnus-newsgroup-reads)
4472 (decf gnus-reffed-article-number)))
4473 (gnus-message 7 "Making sparse threads...done")))
4475 (defun gnus-build-old-threads ()
4476 ;; Look at all the articles that refer back to old articles, and
4477 ;; fetch the headers for the articles that aren't there. This will
4478 ;; build complete threads - if the roots haven't been expired by the
4480 (let ((mail-parse-charset gnus-newsgroup-charset)
4484 (when (not (car (symbol-value refs)))
4485 (setq heads (cdr (symbol-value refs)))
4487 (if (memq (mail-header-number (caar heads))
4488 gnus-newsgroup-dormant)
4489 (setq heads (cdr heads))
4490 (setq id (symbol-name refs))
4491 (while (and (setq id (gnus-build-get-header id))
4492 (not (car (gnus-id-to-thread id)))))
4493 (setq heads nil)))))
4494 gnus-newsgroup-dependencies)))
4496 (defsubst gnus-remove-odd-characters (string)
4497 "Translate STRING into something that doesn't contain weird characters."
4498 (mm-subst-char-in-string
4500 (mm-subst-char-in-string ?\n ?\- string t) t))
4502 ;; This function has to be called with point after the article number
4503 ;; on the beginning of the line.
4504 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4505 (let ((eol (point-at-eol))
4506 (buffer (current-buffer))
4507 header references in-reply-to)
4509 ;; overview: [num subject from date id refs chars lines misc]
4512 (narrow-to-region (point) eol)
4517 (make-full-mail-header
4519 (condition-case () ; subject
4520 (gnus-remove-odd-characters
4521 (funcall gnus-decode-encoded-word-function
4522 (setq x (nnheader-nov-field))))
4524 (condition-case () ; from
4525 (gnus-remove-odd-characters
4526 (funcall gnus-decode-encoded-address-function
4527 (setq x (nnheader-nov-field))))
4529 (nnheader-nov-field) ; date
4530 (nnheader-nov-read-message-id number) ; id
4531 (setq references (nnheader-nov-field)) ; refs
4532 (nnheader-nov-read-integer) ; chars
4533 (nnheader-nov-read-integer) ; lines
4535 (if (looking-at "Xref: ")
4536 (goto-char (match-end 0)))
4537 (nnheader-nov-field)) ; Xref
4538 (nnheader-nov-parse-extra)))) ; extra
4542 (when (and (string= references "")
4543 (setq in-reply-to (mail-header-extra header))
4544 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4545 (mail-header-set-references
4546 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4548 (when gnus-alter-header-function
4549 (funcall gnus-alter-header-function header))
4550 (gnus-dependencies-add-header header dependencies force-new)))
4552 (defun gnus-build-get-header (id)
4553 "Look through the buffer of NOV lines and find the header to ID.
4554 Enter this line into the dependencies hash table, and return
4555 the id of the parent article (if any)."
4556 (let ((deps gnus-newsgroup-dependencies)
4559 (with-current-buffer nntp-server-buffer
4560 (let ((case-fold-search nil))
4561 (goto-char (point-min))
4562 (while (and (not found)
4563 (search-forward id nil t))
4565 (setq found (looking-at
4566 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4567 (regexp-quote id))))
4568 (or found (beginning-of-line 2)))
4572 (setq header (gnus-nov-parse-line
4573 (read (current-buffer)) deps))
4574 (gnus-parent-id (mail-header-references header))))))
4576 (let ((number (mail-header-number header)))
4577 (push number gnus-newsgroup-limit)
4578 (push header gnus-newsgroup-headers)
4579 (if (memq number gnus-newsgroup-unselected)
4581 (setq gnus-newsgroup-unreads
4582 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4584 (setq gnus-newsgroup-unselected
4585 (delq number gnus-newsgroup-unselected)))
4586 (push number gnus-newsgroup-ancient)))))))
4588 (defun gnus-build-all-threads ()
4589 "Read all the headers."
4590 (let ((gnus-summary-ignore-duplicates t)
4591 (mail-parse-charset gnus-newsgroup-charset)
4592 (dependencies gnus-newsgroup-dependencies)
4594 (with-current-buffer nntp-server-buffer
4595 (let ((case-fold-search nil))
4596 (goto-char (point-min))
4599 (setq article (read (current-buffer))
4600 header (gnus-nov-parse-line article dependencies t)))
4602 (with-current-buffer gnus-summary-buffer
4603 (push header gnus-newsgroup-headers)
4604 (if (memq (setq article (mail-header-number header))
4605 gnus-newsgroup-unselected)
4607 (setq gnus-newsgroup-unreads
4608 (gnus-add-to-sorted-list
4609 gnus-newsgroup-unreads article))
4610 (setq gnus-newsgroup-unselected
4611 (delq article gnus-newsgroup-unselected)))
4612 (push article gnus-newsgroup-ancient)))
4613 (forward-line 1)))))))
4615 (defun gnus-summary-update-article-line (article header)
4616 "Update the line for ARTICLE using HEADER."
4617 (let* ((id (mail-header-id header))
4618 (thread (gnus-id-to-thread id)))
4620 (error "Article in no thread"))
4621 ;; Update the thread.
4622 (setcar thread header)
4623 (gnus-summary-goto-subject article)
4624 (let* ((datal (gnus-data-find-list article))
4626 (inhibit-read-only t)
4627 (level (gnus-summary-thread-level)))
4629 (let ((inserted (- (point)
4631 (gnus-summary-insert-line
4633 (memq article gnus-newsgroup-undownloaded)
4634 (gnus-article-mark article)
4635 (memq article gnus-newsgroup-replied)
4636 (memq article gnus-newsgroup-expirable)
4637 ;; Only insert the Subject string when it's different
4638 ;; from the previous Subject string.
4643 (mail-header-subject
4646 (gnus-data-find-list
4648 (gnus-data-list t)))))
4649 ;; Error on the side of excessive subjects.
4651 (mail-header-subject header)))
4653 (mail-header-subject header))
4654 nil (cdr (assq article gnus-newsgroup-scored))
4655 (memq article gnus-newsgroup-processable))
4658 (gnus-data-update-list
4660 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4662 (defun gnus-summary-update-article (article &optional iheader)
4663 "Update ARTICLE in the summary buffer."
4664 (set-buffer gnus-summary-buffer)
4665 (let* ((header (gnus-summary-article-header article))
4666 (id (mail-header-id header))
4667 (data (gnus-data-find article))
4668 (thread (gnus-id-to-thread id))
4669 (references (mail-header-references header))
4673 (when (and references
4674 (not (equal "" references)))
4677 (inhibit-read-only t)
4683 (delq thread parent)))
4684 (if (gnus-summary-insert-subject id header)
4685 ;; Set the (possibly) new article number in the data structure.
4686 (gnus-data-set-number data (gnus-id-to-article id))
4690 (defun gnus-rebuild-thread (id &optional line)
4691 "Rebuild the thread containing ID.
4692 If LINE, insert the rebuilt thread starting on line LINE."
4693 (let ((inhibit-read-only t)
4694 old-pos current thread data)
4695 (if (not gnus-show-threads)
4696 (setq thread (list (car (gnus-id-to-thread id))))
4697 ;; Get the thread this article is part of.
4698 (setq thread (gnus-remove-thread id)))
4699 (setq old-pos (point-at-bol))
4700 (setq current (save-excursion
4701 (and (re-search-backward "[\r\n]" nil t)
4702 (gnus-summary-article-number))))
4703 ;; If this is a gathered thread, we have to go some re-gathering.
4704 (when (stringp (car thread))
4705 (let ((subject (car thread))
4707 (setq thread (cdr thread))
4709 (unless (memq (setq thr (gnus-id-to-thread
4711 (mail-header-id (caar thread)))))
4714 (setq thread (cdr thread)))
4715 ;; We now have all (unique) roots.
4716 (if (= (length roots) 1)
4717 ;; All the loose roots are now one solid root.
4718 (setq thread (car roots))
4719 (setq thread (cons subject (gnus-sort-threads roots))))))
4721 ;; We then insert this thread into the summary buffer.
4723 (goto-char (point-min))
4724 (forward-line (1- line)))
4725 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4726 (if gnus-show-threads
4727 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4728 (gnus-summary-prepare-unthreaded thread))
4729 (setq data (nreverse gnus-newsgroup-data))
4730 (setq threads gnus-newsgroup-threads))
4731 ;; We splice the new data into the data structure.
4732 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4733 ;;!!! then we want to insert at the beginning of the buffer.
4734 ;;!!! That happens to be true with Gnus now, but that may
4735 ;;!!! change in the future. Perhaps.
4736 (gnus-data-enter-list
4737 (if line nil current) data (- (point) old-pos))
4738 (setq gnus-newsgroup-threads
4739 (nconc threads gnus-newsgroup-threads))
4740 (gnus-data-compute-positions))))
4742 (defun gnus-number-to-header (number)
4743 "Return the header for article NUMBER."
4744 (let ((headers gnus-newsgroup-headers))
4746 (not (= number (mail-header-number (car headers)))))
4751 (defun gnus-parent-headers (in-headers &optional generation)
4752 "Return the headers of the GENERATIONth parent of HEADERS."
4754 (setq generation 1))
4756 (headers in-headers)
4759 (not (zerop generation))
4760 (setq references (mail-header-references headers)))
4761 (setq headers (if (and references
4762 (setq parent (gnus-parent-id references)))
4763 (car (gnus-id-to-thread parent))
4766 (and (not (eq headers in-headers))
4769 (defun gnus-id-to-thread (id)
4770 "Return the (sub-)thread where ID appears."
4771 (gnus-gethash id gnus-newsgroup-dependencies))
4773 (defun gnus-id-to-article (id)
4774 "Return the article number of ID."
4775 (let ((thread (gnus-id-to-thread id)))
4778 (mail-header-number (car thread)))))
4780 (defun gnus-id-to-header (id)
4781 "Return the article headers of ID."
4782 (car (gnus-id-to-thread id)))
4784 (defun gnus-article-displayed-root-p (article)
4785 "Say whether ARTICLE is a root(ish) article."
4786 (let ((level (gnus-summary-thread-level article))
4787 (refs (mail-header-references (gnus-summary-article-header article)))
4793 ((null (gnus-parent-id refs)) t)
4795 (null (setq particle (gnus-id-to-article
4796 (gnus-parent-id refs))))
4797 (null (gnus-summary-thread-level particle)))))))
4799 (defun gnus-root-id (id)
4800 "Return the id of the root of the thread where ID appears."
4802 (while (and id (setq prev (car (gnus-id-to-thread id))))
4804 id (gnus-parent-id (mail-header-references prev))))
4807 (defun gnus-articles-in-thread (thread)
4808 "Return the list of articles in THREAD."
4809 (cons (mail-header-number (car thread))
4810 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4812 (defun gnus-remove-thread (id &optional dont-remove)
4813 "Remove the thread that has ID in it."
4814 (let (headers thread last-id)
4815 ;; First go up in this thread until we find the root.
4816 (setq last-id (gnus-root-id id)
4817 headers (message-flatten-list (gnus-id-to-thread last-id)))
4818 ;; We have now found the real root of this thread. It might have
4819 ;; been gathered into some loose thread, so we have to search
4820 ;; through the threads to find the thread we wanted.
4821 (let ((threads gnus-newsgroup-threads)
4824 (setq sub (car threads))
4825 (if (stringp (car sub))
4826 ;; This is a gathered thread, so we look at the roots
4827 ;; below it to find whether this article is in this
4830 (setq sub (cdr sub))
4832 (when (member (caar sub) headers)
4833 (setq thread (car threads)
4836 (setq sub (cdr sub))))
4837 ;; It's an ordinary thread, so we check it.
4838 (when (eq (car sub) (car headers))
4841 (setq threads (cdr threads)))
4842 ;; If this article is in no thread, then it's a root.
4845 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4846 (setq thread (gnus-id-to-thread last-id)))
4849 thread ; We return this thread.
4851 (if (stringp (car thread))
4853 ;; If we use dummy roots, then we have to remove the
4854 ;; dummy root as well.
4855 (when (eq gnus-summary-make-false-root 'dummy)
4856 ;; We go to the dummy root by going to
4857 ;; the first sub-"thread", and then one line up.
4858 (gnus-summary-goto-article
4859 (mail-header-number (caadr thread)))
4862 (gnus-data-compute-positions))
4863 (setq thread (cdr thread))
4865 (gnus-remove-thread-1 (car thread))
4866 (setq thread (cdr thread))))
4867 (gnus-remove-thread-1 thread))))))))
4869 (defun gnus-remove-thread-1 (thread)
4870 "Remove the thread THREAD recursively."
4871 (let ((number (mail-header-number (pop thread)))
4873 (setq thread (reverse thread))
4875 (gnus-remove-thread-1 (pop thread)))
4876 (when (setq d (gnus-data-find number))
4877 (goto-char (gnus-data-pos d))
4878 (gnus-summary-show-thread)
4884 (gnus-delete-line)))))))
4886 (defun gnus-sort-threads-recursive (threads func)
4887 ;; Responsible for sorting the root articles of threads.
4888 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4889 'gnus-thread-sort-functions)
4891 (gnus-make-sort-function
4892 gnus-subthread-sort-functions))))
4893 (sort (mapcar (lambda (thread)
4896 (gnus-sort-subthreads-recursive
4897 (cdr thread) subthread-sort-func))))
4900 (defun gnus-sort-subthreads-recursive (threads func)
4901 ;; Responsible for sorting subthreads.
4902 (sort (mapcar (lambda (thread)
4905 (gnus-sort-subthreads-recursive (cdr thread) func))))
4908 (defun gnus-sort-threads-loop (threads func)
4909 (let* ((superthread (cons nil threads))
4910 (stack (list (cons superthread threads)))
4911 remaining-threads thread)
4913 (setq remaining-threads (cdr (car stack)))
4914 (if remaining-threads
4915 (progn (setq thread (car remaining-threads))
4916 (setcdr (car stack) (cdr remaining-threads))
4918 (push (cons thread (cdr thread)) stack)))
4919 (setq thread (caar stack))
4920 (setcdr thread (sort (cdr thread) func))
4924 (defun gnus-sort-threads (threads)
4926 (if (not gnus-thread-sort-functions)
4928 (gnus-message 8 "Sorting threads...")
4931 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4932 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4933 (gnus-sort-threads-recursive threads sort-func))
4934 ;; Even after binding max-lisp-eval-depth, the recursive
4935 ;; sorter might fail for very long threads. In that case,
4936 ;; try using a (less well-tested) non-recursive sorter.
4937 (error (gnus-message 9 "Sorting threads with loop...")
4938 (gnus-sort-threads-loop
4939 threads (gnus-make-sort-function
4940 gnus-thread-sort-functions))))
4941 (gnus-message 8 "Sorting threads...done"))))
4943 (defun gnus-sort-articles (articles)
4945 (when gnus-article-sort-functions
4946 (gnus-message 7 "Sorting articles...")
4948 (setq gnus-newsgroup-headers
4949 (sort articles (gnus-make-sort-function
4950 gnus-article-sort-functions)))
4951 (gnus-message 7 "Sorting articles...done"))))
4953 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4954 (defmacro gnus-thread-header (thread)
4955 "Return header of first article in THREAD.
4956 Note that THREAD must never, ever be anything else than a variable -
4957 using some other form will lead to serious barfage."
4958 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4959 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4960 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4963 (defsubst gnus-article-sort-by-number (h1 h2)
4964 "Sort articles by article number."
4965 (< (mail-header-number h1)
4966 (mail-header-number h2)))
4968 (defun gnus-thread-sort-by-number (h1 h2)
4969 "Sort threads by root article number."
4970 (gnus-article-sort-by-number
4971 (gnus-thread-header h1) (gnus-thread-header h2)))
4973 (defsubst gnus-article-sort-by-random (h1 h2)
4974 "Sort articles randomly."
4977 (defun gnus-thread-sort-by-random (h1 h2)
4978 "Sort threads randomly."
4979 (gnus-article-sort-by-random
4980 (gnus-thread-header h1) (gnus-thread-header h2)))
4982 (defsubst gnus-article-sort-by-lines (h1 h2)
4983 "Sort articles by article Lines header."
4984 (< (mail-header-lines h1)
4985 (mail-header-lines h2)))
4987 (defun gnus-thread-sort-by-lines (h1 h2)
4988 "Sort threads by root article Lines header."
4989 (gnus-article-sort-by-lines
4990 (gnus-thread-header h1) (gnus-thread-header h2)))
4992 (defsubst gnus-article-sort-by-chars (h1 h2)
4993 "Sort articles by octet length."
4994 (< (mail-header-chars h1)
4995 (mail-header-chars h2)))
4997 (defun gnus-thread-sort-by-chars (h1 h2)
4998 "Sort threads by root article octet length."
4999 (gnus-article-sort-by-chars
5000 (gnus-thread-header h1) (gnus-thread-header h2)))
5002 (defsubst gnus-article-sort-by-author (h1 h2)
5003 "Sort articles by root author."
5005 (let ((extract (funcall
5006 gnus-extract-address-components
5007 (mail-header-from h1))))
5008 (or (car extract) (cadr extract) ""))
5009 (let ((extract (funcall
5010 gnus-extract-address-components
5011 (mail-header-from h2))))
5012 (or (car extract) (cadr extract) ""))))
5014 (defun gnus-thread-sort-by-author (h1 h2)
5015 "Sort threads by root author."
5016 (gnus-article-sort-by-author
5017 (gnus-thread-header h1) (gnus-thread-header h2)))
5019 (defsubst gnus-article-sort-by-recipient (h1 h2)
5020 "Sort articles by recipient."
5022 (let ((extract (funcall
5023 gnus-extract-address-components
5024 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
5025 (or (car extract) (cadr extract)))
5026 (let ((extract (funcall
5027 gnus-extract-address-components
5028 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5029 (or (car extract) (cadr extract)))))
5031 (defun gnus-thread-sort-by-recipient (h1 h2)
5032 "Sort threads by root recipient."
5033 (gnus-article-sort-by-recipient
5034 (gnus-thread-header h1) (gnus-thread-header h2)))
5036 (defsubst gnus-article-sort-by-subject (h1 h2)
5037 "Sort articles by root subject."
5039 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5040 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5042 (defun gnus-thread-sort-by-subject (h1 h2)
5043 "Sort threads by root subject."
5044 (gnus-article-sort-by-subject
5045 (gnus-thread-header h1) (gnus-thread-header h2)))
5047 (defsubst gnus-article-sort-by-date (h1 h2)
5048 "Sort articles by root article date."
5050 (gnus-date-get-time (mail-header-date h1))
5051 (gnus-date-get-time (mail-header-date h2))))
5053 (defun gnus-thread-sort-by-date (h1 h2)
5054 "Sort threads by root article date."
5055 (gnus-article-sort-by-date
5056 (gnus-thread-header h1) (gnus-thread-header h2)))
5058 (defsubst gnus-article-sort-by-score (h1 h2)
5059 "Sort articles by root article score.
5060 Unscored articles will be counted as having a score of zero."
5061 (> (or (cdr (assq (mail-header-number h1)
5062 gnus-newsgroup-scored))
5063 gnus-summary-default-score 0)
5064 (or (cdr (assq (mail-header-number h2)
5065 gnus-newsgroup-scored))
5066 gnus-summary-default-score 0)))
5068 (defun gnus-thread-sort-by-score (h1 h2)
5069 "Sort threads by root article score."
5070 (gnus-article-sort-by-score
5071 (gnus-thread-header h1) (gnus-thread-header h2)))
5073 (defun gnus-thread-sort-by-total-score (h1 h2)
5074 "Sort threads by the sum of all scores in the thread.
5075 Unscored articles will be counted as having a score of zero."
5076 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5078 (defun gnus-thread-total-score (thread)
5079 ;; This function find the total score of THREAD.
5084 (if (stringp (car thread))
5085 (apply gnus-thread-score-function 0
5086 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5087 (gnus-thread-total-score-1 thread)))
5089 (gnus-thread-total-score-1 (list thread)))))
5091 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5092 "Sort articles by number."
5093 (gnus-article-sort-by-number h1 h2))
5095 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5096 "Sort threads such that the thread with the most recently arrived article comes first."
5097 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5099 (defun gnus-thread-highest-number (thread)
5100 "Return the highest article number in THREAD."
5101 (apply 'max (mapcar (lambda (header)
5102 (mail-header-number header))
5103 (message-flatten-list thread))))
5105 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5106 "Sort articles by number."
5107 (gnus-article-sort-by-date h1 h2))
5109 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5110 "Sort threads such that the thread with the most recently dated article comes first."
5111 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5113 ; Since this is called not only to sort the top-level threads, but
5114 ; also in recursive sorts to order the articles within a thread, each
5115 ; article will be processed many times. Thus it speeds things up
5116 ; quite a bit to use gnus-date-get-time, which caches the time value.
5117 (defun gnus-thread-latest-date (thread)
5118 "Return the highest article date in THREAD."
5120 (mapcar (lambda (header) (gnus-float-time
5122 (mail-header-date header))))
5123 (message-flatten-list thread))))
5125 (defun gnus-thread-total-score-1 (root)
5126 ;; This function find the total score of the thread below ROOT.
5127 (setq root (car root))
5128 (apply gnus-thread-score-function
5130 (mapcar 'gnus-thread-total-score
5131 (cdr (gnus-id-to-thread (mail-header-id root))))
5132 (when (> (mail-header-number root) 0)
5133 (list (or (cdr (assq (mail-header-number root)
5134 gnus-newsgroup-scored))
5135 gnus-summary-default-score 0))))
5136 (list gnus-summary-default-score)
5139 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5140 (defvar gnus-tmp-prev-subject nil)
5141 (defvar gnus-tmp-false-parent nil)
5142 (defvar gnus-tmp-root-expunged nil)
5143 (defvar gnus-tmp-dummy-line nil)
5145 (defun gnus-extra-header (type &optional header)
5146 "Return the extra header of TYPE."
5147 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5150 (defvar gnus-tmp-thread-tree-header-string "")
5152 (defcustom gnus-sum-thread-tree-root "> "
5153 "With %B spec, used for the root of a thread.
5154 If nil, use subject instead."
5156 :type '(radio (const :format "%v " nil) string)
5157 :group 'gnus-thread)
5159 (defcustom gnus-sum-thread-tree-false-root "> "
5160 "With %B spec, used for a false root of a thread.
5161 If nil, use subject instead."
5163 :type '(radio (const :format "%v " nil) string)
5164 :group 'gnus-thread)
5166 (defcustom gnus-sum-thread-tree-single-indent ""
5167 "With %B spec, used for a thread with just one message.
5168 If nil, use subject instead."
5170 :type '(radio (const :format "%v " nil) string)
5171 :group 'gnus-thread)
5173 (defcustom gnus-sum-thread-tree-vertical "| "
5174 "With %B spec, used for drawing a vertical line."
5177 :group 'gnus-thread)
5179 (defcustom gnus-sum-thread-tree-indent " "
5180 "With %B spec, used for indenting."
5183 :group 'gnus-thread)
5185 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5186 "With %B spec, used for a leaf with brothers."
5189 :group 'gnus-thread)
5191 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5192 "With %B spec, used for a leaf without brothers."
5195 :group 'gnus-thread)
5197 (defcustom gnus-summary-display-while-building nil
5198 "If non-nil, show and update the summary buffer as it's being built.
5199 If the value is t, update the buffer after every line is inserted. If
5200 the value is an integer (N), update the display every N lines."
5203 :type '(choice (const :tag "off" nil)
5205 (const :tag "frequently" t)))
5207 (defun gnus-summary-prepare-threads (threads)
5208 "Prepare summary buffer from THREADS and indentation LEVEL.
5209 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5210 or a straight list of headers."
5211 (gnus-message 7 "Generating summary...")
5213 (setq gnus-newsgroup-threads threads)
5216 (let ((gnus-tmp-level 0)
5217 (default-score (or gnus-summary-default-score 0))
5218 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5219 (building-line-count gnus-summary-display-while-building)
5220 (building-count (integerp gnus-summary-display-while-building))
5221 thread number subject stack state gnus-tmp-gathered beg-match
5222 new-roots gnus-tmp-new-adopts thread-end simp-subject
5223 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5224 gnus-tmp-replied gnus-tmp-subject-or-nil
5225 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5226 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5227 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5230 (setq gnus-tmp-prev-subject nil
5231 gnus-tmp-thread-tree-header-string "")
5233 (if (vectorp (car threads))
5234 ;; If this is a straight (sic) list of headers, then a
5235 ;; threaded summary display isn't required, so we just create
5236 ;; an unthreaded one.
5237 (gnus-summary-prepare-unthreaded threads)
5239 ;; Do the threaded display.
5241 (if gnus-summary-display-while-building
5242 (switch-to-buffer (buffer-name)))
5243 (while (or threads stack gnus-tmp-new-adopts new-roots)
5245 (if (and (= gnus-tmp-level 0)
5248 (not gnus-tmp-false-parent)
5249 (or gnus-tmp-new-adopts new-roots))
5250 (if gnus-tmp-new-adopts
5251 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5252 thread (list (car gnus-tmp-new-adopts))
5253 gnus-tmp-header (caar thread)
5254 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5256 (setq thread (list (car new-roots))
5257 gnus-tmp-header (caar thread)
5258 new-roots (cdr new-roots))))
5261 ;; If there are some threads, we do them before the
5262 ;; threads on the stack.
5263 (setq thread threads
5264 gnus-tmp-header (caar thread))
5265 ;; There were no current threads, so we pop something off
5267 (setq state (car stack)
5268 gnus-tmp-level (car state)
5269 tree-stack (cadr state)
5270 thread (caddr state)
5272 gnus-tmp-header (caar thread))))
5274 (setq gnus-tmp-false-parent nil)
5275 (setq gnus-tmp-root-expunged nil)
5276 (setq thread-end nil)
5278 (if (stringp gnus-tmp-header)
5279 ;; The header is a dummy root.
5281 ((eq gnus-summary-make-false-root 'adopt)
5282 ;; We let the first article adopt the rest.
5283 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5285 (setq gnus-tmp-gathered
5287 (lambda (h) (mail-header-number (car h)))
5290 (setq thread (cons (list (caar thread)
5293 (setq gnus-tmp-level -1
5294 gnus-tmp-false-parent t))
5295 ((eq gnus-summary-make-false-root 'empty)
5296 ;; We print adopted articles with empty subject fields.
5297 (setq gnus-tmp-gathered
5299 (lambda (h) (mail-header-number (car h)))
5302 (setq gnus-tmp-level -1))
5303 ((eq gnus-summary-make-false-root 'dummy)
5304 ;; We remember that we probably want to output a dummy
5306 (setq gnus-tmp-dummy-line gnus-tmp-header)
5307 (setq gnus-tmp-prev-subject gnus-tmp-header))
5309 ;; We do not make a root for the gathered
5310 ;; sub-threads at all.
5311 (setq gnus-tmp-level -1)))
5313 (setq number (mail-header-number gnus-tmp-header)
5314 subject (mail-header-subject gnus-tmp-header)
5315 simp-subject (gnus-simplify-subject-fully subject))
5318 ;; If the thread has changed subject, we might want to make
5319 ;; this subthread into a root.
5320 ((and (null gnus-thread-ignore-subject)
5321 (not (zerop gnus-tmp-level))
5322 gnus-tmp-prev-subject
5323 (not (string= gnus-tmp-prev-subject simp-subject)))
5324 (setq new-roots (nconc new-roots (list (car thread)))
5326 gnus-tmp-header nil))
5327 ;; If the article lies outside the current limit,
5328 ;; then we do not display it.
5329 ((not (memq number gnus-newsgroup-limit))
5330 (setq gnus-tmp-gathered
5332 (lambda (h) (mail-header-number (car h)))
5335 (setq gnus-tmp-new-adopts (if (cdar thread)
5336 (append gnus-tmp-new-adopts
5338 gnus-tmp-new-adopts)
5340 gnus-tmp-header nil)
5341 (when (zerop gnus-tmp-level)
5342 (setq gnus-tmp-root-expunged t)))
5343 ;; Perhaps this article is to be marked as read?
5344 ((and gnus-summary-mark-below
5345 (< (or (cdr (assq number gnus-newsgroup-scored))
5347 gnus-summary-mark-below)
5348 ;; Don't touch sparse articles.
5349 (not (gnus-summary-article-sparse-p number))
5350 (not (gnus-summary-article-ancient-p number)))
5351 (setq gnus-newsgroup-unreads
5352 (delq number gnus-newsgroup-unreads))
5353 (if gnus-newsgroup-auto-expire
5354 (setq gnus-newsgroup-expirable
5355 (gnus-add-to-sorted-list
5356 gnus-newsgroup-expirable number))
5357 (push (cons number gnus-low-score-mark)
5358 gnus-newsgroup-reads))))
5360 (when gnus-tmp-header
5361 ;; We may have an old dummy line to output before this
5363 (when (and gnus-tmp-dummy-line
5366 (mail-header-subject gnus-tmp-header)))
5367 (gnus-summary-insert-dummy-line
5368 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5369 (setq gnus-tmp-dummy-line nil))
5371 ;; Compute the mark.
5372 (setq gnus-tmp-unread (gnus-article-mark number))
5374 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5375 gnus-tmp-header gnus-tmp-level)
5376 gnus-newsgroup-data)
5378 ;; Actually insert the line.
5380 gnus-tmp-subject-or-nil
5382 ((and gnus-thread-ignore-subject
5383 gnus-tmp-prev-subject
5384 (not (string= gnus-tmp-prev-subject simp-subject)))
5386 ((zerop gnus-tmp-level)
5387 (if (and (eq gnus-summary-make-false-root 'empty)
5388 (memq number gnus-tmp-gathered)
5389 gnus-tmp-prev-subject
5390 (string= gnus-tmp-prev-subject simp-subject))
5391 gnus-summary-same-subject
5393 (t gnus-summary-same-subject)))
5394 (if (and (eq gnus-summary-make-false-root 'adopt)
5395 (= gnus-tmp-level 1)
5396 (memq number gnus-tmp-gathered))
5397 (setq gnus-tmp-opening-bracket ?\<
5398 gnus-tmp-closing-bracket ?\>)
5399 (setq gnus-tmp-opening-bracket ?\[
5400 gnus-tmp-closing-bracket ?\]))
5401 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5402 (gnus-make-thread-indent-array
5403 (max (* 2 (length gnus-thread-indent-array))
5406 gnus-tmp-indentation
5407 (aref gnus-thread-indent-array gnus-tmp-level)
5408 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5409 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5410 gnus-summary-default-score 0)
5412 (if (or (null gnus-summary-default-score)
5413 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5414 gnus-summary-zcore-fuzz))
5416 (if (< gnus-tmp-score gnus-summary-default-score)
5417 gnus-score-below-mark gnus-score-over-mark))
5419 (cond ((memq number gnus-newsgroup-processable)
5421 ((memq number gnus-newsgroup-cached)
5423 ((memq number gnus-newsgroup-replied)
5425 ((memq number gnus-newsgroup-forwarded)
5426 gnus-forwarded-mark)
5427 ((memq number gnus-newsgroup-saved)
5429 ((memq number gnus-newsgroup-unseen)
5433 (cond ((memq number gnus-newsgroup-undownloaded)
5434 gnus-undownloaded-mark)
5435 (gnus-newsgroup-agentized
5436 gnus-downloaded-mark)
5439 gnus-tmp-from (mail-header-from gnus-tmp-header)
5442 ((string-match "<[^>]+> *$" gnus-tmp-from)
5443 (setq beg-match (match-beginning 0))
5444 (or (and (string-match "^\".+\"" gnus-tmp-from)
5445 (substring gnus-tmp-from 1 (1- (match-end 0))))
5446 (substring gnus-tmp-from 0 beg-match)))
5447 ((string-match "(.+)" gnus-tmp-from)
5448 (substring gnus-tmp-from
5449 (1+ (match-beginning 0)) (1- (match-end 0))))
5453 gnus-tmp-thread-tree-header-string
5455 ((not gnus-show-threads) "")
5456 ((zerop gnus-tmp-level)
5457 (cond ((cdar thread)
5458 (or gnus-sum-thread-tree-root subject))
5459 (gnus-tmp-new-adopts
5460 (or gnus-sum-thread-tree-false-root subject))
5462 (or gnus-sum-thread-tree-single-indent subject))))
5464 (concat (apply 'concat
5465 (mapcar (lambda (item)
5467 gnus-sum-thread-tree-vertical
5468 gnus-sum-thread-tree-indent))
5469 (cdr (reverse tree-stack))))
5471 gnus-sum-thread-tree-leaf-with-other
5472 gnus-sum-thread-tree-single-leaf)))))
5473 (when (string= gnus-tmp-name "")
5474 (setq gnus-tmp-name gnus-tmp-from))
5475 (unless (numberp gnus-tmp-lines)
5476 (setq gnus-tmp-lines -1))
5477 (if (= gnus-tmp-lines -1)
5478 (setq gnus-tmp-lines "?")
5479 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5480 (gnus-put-text-property
5482 (progn (eval gnus-summary-line-format-spec) (point))
5483 'gnus-number number)
5486 (gnus-summary-highlight-line)
5487 (when gnus-summary-update-hook
5488 (gnus-run-hooks 'gnus-summary-update-hook))
5491 (setq gnus-tmp-prev-subject simp-subject)))
5493 (when (nth 1 thread)
5494 (push (list (max 0 gnus-tmp-level)
5495 (copy-sequence tree-stack)
5498 (push (if (nth 1 thread) 1 0) tree-stack)
5499 (incf gnus-tmp-level)
5500 (setq threads (if thread-end nil (cdar thread)))
5501 (if gnus-summary-display-while-building
5504 ;; use a set frequency
5505 (setq building-line-count (1- building-line-count))
5506 (when (= building-line-count 0)
5508 (setq building-line-count
5509 gnus-summary-display-while-building)))
5513 (setq gnus-tmp-level 0)))))
5514 (gnus-message 7 "Generating summary...done"))
5516 (defun gnus-summary-prepare-unthreaded (headers)
5517 "Generate an unthreaded summary buffer based on HEADERS."
5518 (let (header number mark)
5523 ;; We may have to root out some bad articles...
5524 (when (memq (setq number (mail-header-number
5525 (setq header (pop headers))))
5526 gnus-newsgroup-limit)
5527 ;; Mark article as read when it has a low score.
5528 (when (and gnus-summary-mark-below
5529 (< (or (cdr (assq number gnus-newsgroup-scored))
5530 gnus-summary-default-score 0)
5531 gnus-summary-mark-below)
5532 (not (gnus-summary-article-ancient-p number)))
5533 (setq gnus-newsgroup-unreads
5534 (delq number gnus-newsgroup-unreads))
5535 (if gnus-newsgroup-auto-expire
5536 (push number gnus-newsgroup-expirable)
5537 (push (cons number gnus-low-score-mark)
5538 gnus-newsgroup-reads)))
5540 (setq mark (gnus-article-mark number))
5541 (push (gnus-data-make number mark (1+ (point)) header 0)
5542 gnus-newsgroup-data)
5543 (gnus-summary-insert-line
5545 (memq number gnus-newsgroup-undownloaded)
5546 mark (memq number gnus-newsgroup-replied)
5547 (memq number gnus-newsgroup-expirable)
5548 (mail-header-subject header) nil
5549 (cdr (assq number gnus-newsgroup-scored))
5550 (memq number gnus-newsgroup-processable))))))
5552 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5554 (defun gnus-group-get-list-identifiers (group)
5555 "Get list identifier regexp for GROUP."
5556 (or (gnus-parameter-list-identifier group)
5557 (if (consp gnus-list-identifiers)
5558 (mapconcat 'identity gnus-list-identifiers " *\\|")
5559 gnus-list-identifiers)))
5561 (defun gnus-summary-remove-list-identifiers ()
5562 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5563 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5566 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5567 (dolist (header gnus-newsgroup-headers)
5568 (setq subject (mail-header-subject header)
5570 (while (string-match regexp subject)
5572 (concat (substring subject 0 (match-beginning 1))
5573 (substring subject (match-end 0)))
5576 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5578 (concat (substring subject 0 (match-beginning 1))
5579 (substring subject (match-end 1)))))
5580 (mail-header-set-subject header subject))))))
5582 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5583 "Fetch headers of ARTICLES."
5584 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5585 (gnus-message 7 "Fetching headers for %s..." name)
5588 (setq gnus-headers-retrieved-by
5589 (gnus-retrieve-headers
5590 articles gnus-newsgroup-name
5592 ;; We might want to fetch old headers, but
5593 ;; not if there is only 1 article.
5595 (not (eq gnus-fetch-old-headers 'some))
5596 (not (numberp gnus-fetch-old-headers)))
5597 (> (length articles) 1))
5598 gnus-fetch-old-headers)))))
5599 (gnus-get-newsgroup-headers-xover
5600 articles force-new dependencies gnus-newsgroup-name t)
5601 (gnus-get-newsgroup-headers dependencies force-new))
5602 (gnus-message 7 "Fetching headers for %s...done" name))))
5604 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5605 "Select newsgroup GROUP.
5606 If READ-ALL is non-nil, all articles in the group are selected.
5607 If SELECT-ARTICLES, only select those articles from GROUP."
5608 (let* ((entry (gnus-group-entry group))
5609 ;;!!! Dirty hack; should be removed.
5610 (gnus-summary-ignore-duplicates
5611 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5613 gnus-summary-ignore-duplicates))
5614 (info (nth 2 entry))
5615 charset articles fetched-articles cached)
5617 (unless (gnus-check-server
5618 (set (make-local-variable 'gnus-current-select-method)
5619 (gnus-find-method-for-group group)))
5620 (error "Couldn't open server"))
5621 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5623 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5624 (gnus-activate-group group) ; Or we can activate it...
5625 (progn ; Or we bug out.
5626 (when (derived-mode-p 'gnus-summary-mode)
5627 (gnus-kill-buffer (current-buffer)))
5629 "Couldn't activate group %s: %s"
5630 (mm-decode-coding-string group charset)
5631 (mm-decode-coding-string (gnus-status-message group) charset))))
5633 (unless (gnus-request-group group t nil (gnus-get-info group))
5634 (when (derived-mode-p 'gnus-summary-mode)
5635 (gnus-kill-buffer (current-buffer)))
5636 (error "Couldn't request group %s: %s"
5637 (mm-decode-coding-string group charset)
5638 (mm-decode-coding-string (gnus-status-message group) charset)))
5640 (when (and gnus-agent
5641 (gnus-active group))
5642 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5644 (setq gnus-summary-use-undownloaded-faces
5645 (gnus-agent-find-parameter
5647 'agent-enable-undownloaded-faces)))
5649 (setq gnus-newsgroup-name group
5650 gnus-newsgroup-unselected nil
5651 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5653 (let ((display (gnus-group-find-parameter group 'display)))
5654 (setq gnus-newsgroup-display
5656 ((not (zerop (or (car-safe read-all) 0)))
5657 ;; The user entered the group with C-u SPC/RET, let's show
5663 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5665 ;; The following is probably the "correct" solution, but
5666 ;; it makes Gnus fetch all headers and then limit the
5667 ;; articles (which is slow), so instead we hack the
5668 ;; select-articles parameter instead. -- Simon Josefsson
5671 ;; (gnus-byte-compile
5672 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5674 (setq select-articles
5675 (gnus-uncompress-range
5676 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5680 (cdr (gnus-active group)))))
5685 (gnus-summary-setup-default-charset)
5687 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5688 (when (gnus-virtual-group-p group)
5689 (setq cached gnus-newsgroup-cached))
5691 (setq gnus-newsgroup-unreads
5692 (gnus-sorted-ndifference
5693 (gnus-sorted-ndifference gnus-newsgroup-unreads
5694 gnus-newsgroup-marked)
5695 gnus-newsgroup-dormant))
5697 (setq gnus-newsgroup-processable nil)
5699 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5701 ;; Adjust and set lists of article marks.
5703 (gnus-adjust-marked-articles info))
5704 (if (setq articles select-articles)
5705 (setq gnus-newsgroup-unselected
5706 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5707 (setq articles (gnus-articles-to-read group read-all)))
5711 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5713 ((eq articles 0) nil)
5715 ;; Init the dependencies hash table.
5716 (setq gnus-newsgroup-dependencies
5717 (gnus-make-hashtable (length articles)))
5718 (if (gnus-buffer-live-p gnus-group-buffer)
5719 (gnus-set-global-variables)
5720 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5721 ;; Retrieve the headers and read them in.
5723 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5725 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5727 (setq gnus-newsgroup-cached cached))
5729 ;; Suppress duplicates?
5730 (when gnus-suppress-duplicates
5731 (gnus-dup-suppress-articles))
5733 ;; Set the initial limit.
5734 (setq gnus-newsgroup-limit (copy-sequence articles))
5735 ;; Remove canceled articles from the list of unread articles.
5736 (setq fetched-articles
5737 (mapcar (lambda (headers) (mail-header-number headers))
5738 gnus-newsgroup-headers))
5739 (setq gnus-newsgroup-articles fetched-articles)
5740 (setq gnus-newsgroup-unreads
5741 (gnus-sorted-nintersection
5742 gnus-newsgroup-unreads fetched-articles))
5743 (gnus-compute-unseen-list)
5745 ;; Removed marked articles that do not exist.
5746 (gnus-update-missing-marks
5747 (gnus-sorted-difference articles fetched-articles))
5748 ;; We might want to build some more threads first.
5749 (when (and gnus-fetch-old-headers
5750 (eq gnus-headers-retrieved-by 'nov))
5751 (if (eq gnus-fetch-old-headers 'invisible)
5752 (gnus-build-all-threads)
5753 (gnus-build-old-threads)))
5754 ;; Let the Gnus agent mark articles as read.
5756 (gnus-agent-get-undownloaded-list))
5757 ;; Remove list identifiers from subject
5758 (gnus-summary-remove-list-identifiers)
5759 ;; Check whether auto-expire is to be done in this group.
5760 (setq gnus-newsgroup-auto-expire
5761 (and (gnus-group-auto-expirable-p group)
5762 (not (gnus-group-read-only-p group))))
5763 ;; Set up the article buffer now, if necessary.
5764 (unless (and gnus-single-article-buffer
5765 (equal gnus-article-buffer "*Article*"))
5766 (gnus-article-setup-buffer))
5767 ;; First and last article in this newsgroup.
5768 (when gnus-newsgroup-headers
5769 (setq gnus-newsgroup-begin
5770 (mail-header-number (car gnus-newsgroup-headers))
5773 (gnus-last-element gnus-newsgroup-headers))))
5774 ;; GROUP is successfully selected.
5775 (or gnus-newsgroup-headers t)))))
5777 (defun gnus-compute-unseen-list ()
5778 ;; The `seen' marks are treated specially.
5779 (if (not gnus-newsgroup-seen)
5780 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5781 (setq gnus-newsgroup-unseen
5782 (gnus-inverse-list-range-intersection
5783 gnus-newsgroup-articles gnus-newsgroup-seen))))
5785 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5787 (defun gnus-summary-display-make-predicate (display)
5788 (require 'gnus-agent)
5789 (when (= (length display) 1)
5790 (setq display (car display)))
5791 (unless gnus-summary-display-cache
5792 (dolist (elem (append '((unread . unread)
5795 gnus-article-mark-lists))
5796 (push (cons (cdr elem)
5797 (gnus-byte-compile ;Why bother?
5798 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5799 gnus-summary-display-cache)))
5800 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5801 (gnus-category-predicate-cache gnus-summary-display-cache))
5802 (gnus-get-predicate display)))
5804 ;; Uses the dynamically bound `gnus-number' variable.
5805 (defvar gnus-number)
5806 (defun gnus-article-marked-p (type &optional article)
5807 (let ((article (or article gnus-number)))
5810 (memq article gnus-newsgroup-marked))
5812 (memq article gnus-newsgroup-spam-marked))
5814 (memq article gnus-newsgroup-unsendable))
5815 ((eq type 'undownload)
5816 (memq article gnus-newsgroup-undownloaded))
5817 ((eq type 'download)
5818 (memq article gnus-newsgroup-downloadable))
5820 (memq article gnus-newsgroup-unreads))
5822 (memq article gnus-newsgroup-reads))
5824 (memq article gnus-newsgroup-dormant) )
5826 (memq article gnus-newsgroup-expirable))
5828 (memq article gnus-newsgroup-replied))
5830 (memq article gnus-newsgroup-killed))
5831 ((eq type 'bookmark)
5832 (assq article gnus-newsgroup-bookmarks))
5834 (assq article gnus-newsgroup-scored))
5836 (memq article gnus-newsgroup-saved))
5838 (memq article gnus-newsgroup-cached))
5840 (memq article gnus-newsgroup-forwarded))
5842 (not (memq article gnus-newsgroup-unseen)))
5845 (defun gnus-articles-to-read (group &optional read-all)
5846 "Find out what articles the user wants to read."
5847 (let* ((only-read-p t)
5849 (gnus-list-range-difference
5850 ;; Select all articles if `read-all' is non-nil, or if there
5851 ;; are no unread articles.
5853 (and (zerop (length gnus-newsgroup-marked))
5854 (zerop (length gnus-newsgroup-unreads)))
5855 ;; Fetch all if the predicate is non-nil.
5856 gnus-newsgroup-display)
5857 ;; We want to select the headers for all the articles in
5858 ;; the group, so we select either all the active
5859 ;; articles in the group, or (if that's nil), the
5860 ;; articles in the cache.
5862 (if gnus-newsgroup-maximum-articles
5863 (let ((active (gnus-active group)))
5864 (gnus-uncompress-range
5865 (cons (max (car active)
5867 gnus-newsgroup-maximum-articles
5870 (gnus-uncompress-range (gnus-active group)))
5871 (gnus-cache-articles-in-group group))
5872 ;; Select only the "normal" subset of articles.
5873 (setq only-read-p nil)
5875 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5876 gnus-newsgroup-unreads))
5877 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5878 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5879 (scored (length scored-list))
5880 (number (length articles))
5881 (marked (+ (length gnus-newsgroup-marked)
5882 (length gnus-newsgroup-dormant)))
5887 ((numberp gnus-newsgroup-display)
5888 gnus-newsgroup-display)
5892 ((and (or (<= scored marked) (= scored number))
5893 (numberp gnus-large-newsgroup)
5894 (> number gnus-large-newsgroup))
5895 (let* ((cursor-in-echo-area nil)
5896 (initial (gnus-parameter-large-newsgroup-initial
5897 gnus-newsgroup-name))
5898 (default (if only-read-p
5899 (or initial gnus-large-newsgroup)
5905 "How many articles from %s (available %d, default %d): "
5906 (gnus-group-decoded-name
5907 (gnus-group-real-name gnus-newsgroup-name))
5910 "How many articles from %s (%d default): "
5911 (gnus-group-decoded-name
5912 (gnus-group-real-name gnus-newsgroup-name))
5916 (number-to-string default))))
5917 (if (string-match "^[ \t]*$" input) number input)))
5918 ((and (> scored marked) (< scored number)
5919 (> (- scored number) 20))
5922 (format "%s %s (%d scored, %d total): "
5923 "How many articles from"
5924 (gnus-group-decoded-name
5925 (gnus-group-real-name gnus-newsgroup-name))
5927 (if (string-match "^[ \t]*$" input)
5931 (message "Quit getting the articles to read")
5933 (setq select (if (stringp select) (string-to-number select) select))
5934 (if (or (null select) (zerop select))
5936 (if (and (not (zerop scored)) (<= (abs select) scored))
5938 (setq articles (sort scored-list '<))
5939 (setq number (length articles)))
5940 (setq articles (copy-sequence articles)))
5942 (when (< (abs select) number)
5944 ;; Select the N oldest articles.
5945 (setcdr (nthcdr (1- (abs select)) articles) nil)
5946 ;; Select the N most recent articles.
5947 (setq articles (nthcdr (- number select) articles))))
5948 (setq gnus-newsgroup-unselected
5949 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5950 (when gnus-alter-articles-to-read-function
5953 (funcall gnus-alter-articles-to-read-function
5954 gnus-newsgroup-name articles)
5958 (defun gnus-killed-articles (killed articles)
5961 (when (inline (gnus-member-of-range (car articles) killed))
5962 (push (car articles) out))
5963 (setq articles (cdr articles)))
5966 (defun gnus-article-mark-to-type (mark)
5967 "Return the type of MARK."
5968 (or (cadr (assq mark gnus-article-special-mark-lists))
5971 (defun gnus-article-unpropagatable-p (mark)
5972 "Return whether MARK should be propagated to back end."
5973 (memq mark gnus-article-unpropagated-mark-lists))
5975 (defun gnus-adjust-marked-articles (info)
5976 "Set all article lists and remove all marks that are no longer valid."
5977 (let* ((marked-lists (gnus-info-marks info))
5978 (active (gnus-active (gnus-info-group info)))
5981 (types gnus-article-mark-lists)
5982 marks var articles article mark mark-type
5984 ;; Hack to avoid adjusting marks for imap.
5985 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5989 (dolist (marks marked-lists)
5990 (setq mark (car marks)
5991 mark-type (gnus-article-mark-to-type mark)
5992 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5993 ;; We set the variable according to the type of the marks list,
5994 ;; and then adjust the marks to a subset of the active articles.
5996 ;; Adjust "simple" lists - compressed yet unsorted
5997 ((eq mark-type 'list)
5998 ;; Simultaneously uncompress and clip to active range
5999 ;; See gnus-uncompress-range for a description of possible marks
6001 (if (not (cadr marks))
6003 (setq articles (if (numberp (cddr marks))
6009 (while (setq article (pop articles))
6010 (cond ((consp article)
6011 (setq bgn (max (car article) min)
6012 end (min (cdr article) max))
6014 (setq l (setcdr l (cons bgn nil))
6016 ((and (<= min article)
6018 (setq l (setcdr l (cons article nil))))))
6019 (set var (cdr lh)))))
6021 ((eq mark-type 'tuple)
6022 (set var (setq articles (cdr marks)))
6023 (when (not (listp (cdr (symbol-value var))))
6024 (set var (list (symbol-value var))))
6025 (when (not (listp (cdr articles)))
6026 (setq articles (list articles)))
6028 (when (or (not (consp (setq article (pop articles))))
6029 (< (car article) min)
6030 (> (car article) max))
6031 (set var (delq article (symbol-value var))))))
6032 ;; Adjust ranges (sloppily).
6033 ((eq mark-type 'range)
6036 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6037 ;; It should be (seen (NUM1 . NUM2)).
6038 (when (numberp (cddr marks))
6039 (setcdr marks (list (cdr marks))))
6040 (setq articles (cdr marks))
6041 (while (and articles
6042 (or (and (consp (car articles))
6043 (> min (cdar articles)))
6044 (and (numberp (car articles))
6045 (> min (car articles)))))
6049 (set var (cdr marks)))))))))
6051 (defun gnus-update-missing-marks (missing)
6052 "Go through the list of MISSING articles and remove them from the mark lists."
6055 ;; Go through all types.
6056 (dolist (elem gnus-article-mark-lists)
6057 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6058 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6059 (when (symbol-value var)
6060 ;; This list has articles. So we delete all missing
6061 ;; articles from it.
6064 (set var (delq (pop m) (symbol-value var))))))))))
6066 (defun gnus-update-marks ()
6067 "Enter the various lists of marked articles into the newsgroup info list."
6068 (let ((types gnus-article-mark-lists)
6069 (info (gnus-get-info gnus-newsgroup-name))
6070 type list newmarked symbol delta-marks)
6072 ;; Add all marks lists to the list of marks lists.
6073 (while (setq type (pop types))
6074 (setq list (symbol-value
6076 (intern (format "gnus-newsgroup-%s" (car type))))))
6079 ;; Get rid of the entries of the articles that have the
6081 (when (and (eq (cdr type) 'score)
6085 (prev (cons nil list))
6088 (if (or (not (consp (car arts)))
6089 (= (cdar arts) gnus-summary-default-score))
6090 (setcdr prev (cdr arts))
6092 (setq arts (cdr arts)))
6093 (setq list (cdr all)))))
6095 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6096 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6098 (when (and (gnus-check-backend-function
6099 'request-set-mark gnus-newsgroup-name)
6100 (not (gnus-article-unpropagatable-p (cdr type))))
6101 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6102 ;; Don't do anything about marks for articles we
6103 ;; didn't actually get any headers for.
6105 (gnus-list-range-intersection
6106 gnus-newsgroup-articles
6107 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6109 (gnus-list-range-intersection
6110 gnus-newsgroup-articles
6111 (gnus-remove-from-range
6112 (gnus-copy-sequence list) old))))
6114 (push (list add 'add (list (cdr type))) delta-marks))
6116 ;; Don't delete marks from outside the active range.
6117 ;; This shouldn't happen, but is a sanity check.
6118 (setq del (gnus-sorted-range-intersection
6119 (gnus-active gnus-newsgroup-name) del))
6120 (push (list del 'del (list (cdr type))) delta-marks))))
6123 (eq (cdr type) 'unexist))
6124 (push (cons (cdr type) list) newmarked)))
6127 (unless (gnus-check-group gnus-newsgroup-name)
6128 (error "Can't open server for %s" gnus-newsgroup-name))
6129 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6131 ;; Enter these new marks into the info of the group.
6133 (setcar (nthcdr 3 info) newmarked)
6134 ;; Add the marks lists to the end of the info.
6136 (setcdr (nthcdr 2 info) (list newmarked))))
6138 ;; Cut off the end of the info if there's nothing else there.
6142 (when (nthcdr (decf i) info)
6143 (setcdr (nthcdr i info) nil)))))))
6145 (defun gnus-set-mode-line (where)
6146 "Set the mode line of the article or summary buffers.
6147 If WHERE is `summary', the summary mode line format will be used."
6148 ;; Is this mode line one we keep updated?
6149 (when (and (memq where gnus-updated-mode-lines)
6151 (intern (format "gnus-%s-mode-line-format-spec" where))))
6153 ;; We evaluate this in the summary buffer since these
6154 ;; variables are buffer-local to that buffer.
6155 (with-current-buffer gnus-summary-buffer
6156 ;; We bind all these variables that are used in the `eval' form
6158 (let* ((mformat (symbol-value
6160 (format "gnus-%s-mode-line-format-spec" where))))
6161 (gnus-tmp-group-name (gnus-mode-string-quote
6162 (gnus-group-decoded-name
6163 gnus-newsgroup-name)))
6164 (gnus-tmp-article-number (or gnus-current-article 0))
6165 (gnus-tmp-unread gnus-newsgroup-unreads)
6166 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6167 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6168 (gnus-tmp-unread-and-unselected
6169 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6170 (zerop gnus-tmp-unselected))
6172 ((zerop gnus-tmp-unselected)
6173 (format "{%d more}" gnus-tmp-unread-and-unticked))
6174 (t (format "{%d(+%d) more}"
6175 gnus-tmp-unread-and-unticked
6176 gnus-tmp-unselected))))
6178 (if (and gnus-current-headers
6179 (vectorp gnus-current-headers))
6180 (gnus-mode-string-quote
6181 (mail-header-subject gnus-current-headers))
6183 bufname-length max-len
6184 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6185 (setq mode-string (eval mformat))
6186 (setq bufname-length (if (string-match "%b" mode-string)
6189 (if (eq where 'summary)
6191 (get-buffer gnus-article-buffer))))
6194 (setq max-len (max 4 (if gnus-mode-non-string-length
6196 gnus-mode-non-string-length
6198 (length mode-string))))
6199 ;; We might have to chop a bit of the string off...
6200 (when (> (length mode-string) max-len)
6202 (concat (truncate-string-to-width mode-string (- max-len 3))
6204 ;; Update the mode line.
6205 (setq mode-line-buffer-identification
6206 (gnus-mode-line-buffer-identification (list mode-string)))
6207 (set-buffer-modified-p t))))
6209 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6210 "Go through the HEADERS list and add all Xrefs to a hash table.
6211 The resulting hash table is returned, or nil if no Xrefs were found."
6212 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6213 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6214 (xref-hashtb (gnus-make-hashtable))
6215 start group entry number xrefs header)
6217 (setq header (pop headers))
6218 (when (and (setq xrefs (mail-header-xref header))
6219 (not (memq (setq number (mail-header-number header))
6222 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6223 (setq start (match-end 0))
6224 (setq group (if prefix
6225 (concat prefix (substring xrefs (match-beginning 1)
6227 (substring xrefs (match-beginning 1) (match-end 1))))
6229 (string-to-number (substring xrefs (match-beginning 2)
6231 (if (setq entry (gnus-gethash group xref-hashtb))
6232 (setcdr entry (cons number (cdr entry)))
6233 (gnus-sethash group (cons number nil) xref-hashtb)))))
6234 (and start xref-hashtb)))
6236 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6237 "Look through all the headers and mark the Xrefs as read."
6238 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6239 name info xref-hashtb idlist method nth4)
6240 (with-current-buffer gnus-group-buffer
6241 (when (setq xref-hashtb
6242 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6245 (unless (string= from-newsgroup (setq name (symbol-name group)))
6246 (setq idlist (symbol-value group))
6247 ;; Dead groups are not updated.
6249 (setq info (gnus-get-info name))
6250 (when (stringp (setq nth4 (gnus-info-method info)))
6251 (setq nth4 (gnus-server-to-method nth4))))
6252 ;; Only do the xrefs if the group has the same
6253 ;; select method as the group we have just read.
6254 (or (gnus-methods-equal-p
6255 nth4 (gnus-find-method-for-group from-newsgroup))
6257 (equal nth4 (setq method (gnus-find-method-for-group
6259 (and (equal (car nth4) (car method))
6260 (equal (nth 1 nth4) (nth 1 method))))
6261 gnus-use-cross-reference
6262 (or (not (eq gnus-use-cross-reference t))
6264 ;; Only do cross-references on subscribed
6265 ;; groups, if that is what is wanted.
6266 (<= (gnus-info-level info) gnus-level-subscribed))
6267 (gnus-group-make-articles-read name idlist))))
6270 (defun gnus-compute-read-articles (group articles)
6271 (let* ((entry (gnus-group-entry group))
6272 (info (nth 2 entry))
6273 (active (gnus-active group))
6276 ;; First peel off all invalid article numbers.
6278 (let ((ids articles)
6280 (while (setq id (pop ids))
6281 (when (and first (> id (cdr active)))
6282 ;; We'll end up in this situation in one particular
6283 ;; obscure situation. If you re-scan a group and get
6284 ;; a new article that is cross-posted to a different
6285 ;; group that has not been re-scanned, you might get
6286 ;; crossposted article that has a higher number than
6287 ;; Gnus believes possible. So we re-activate this
6288 ;; group as well. This might mean doing the
6289 ;; crossposting thingy will *increase* the number
6290 ;; of articles in some groups. Tsk, tsk.
6291 (setq active (or (gnus-activate-group group) active)))
6292 (when (or (> id (cdr active))
6293 (< id (car active)))
6294 (setq articles (delq id articles))))))
6295 ;; If the read list is nil, we init it.
6297 (null (gnus-info-read info))
6299 (setq ninfo (cons 1 (1- (car active))))
6300 (setq ninfo (gnus-info-read info)))
6301 ;; Then we add the read articles to the range.
6303 ninfo (setq articles (sort articles '<))))))
6305 (defun gnus-group-make-articles-read (group articles)
6306 "Update the info of GROUP to say that ARTICLES are read."
6308 (entry (gnus-group-entry group))
6309 (info (nth 2 entry))
6310 (active (gnus-active group))
6312 (gnus-method-option-p
6313 (gnus-find-method-for-group group)
6317 ;; Group that Gnus doesn't know exists, but still allow the
6318 ;; backend to set marks.
6320 (gnus-request-set-mark
6321 group (list (list (gnus-compress-sequence (sort articles #'<))
6323 ;; Normal, subscribed groups.
6324 (setq range (gnus-compute-read-articles group articles))
6325 (with-current-buffer gnus-group-buffer
6328 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6329 (gnus-info-set-read ',info ',(gnus-info-read info))
6330 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6332 (gnus-request-set-mark
6333 ,group (list (list ',range 'del '(read)))))
6334 (gnus-group-update-group ,group t))))
6335 ;; Add the read articles to the range.
6336 (gnus-info-set-read info range)
6338 (gnus-request-set-mark group (list (list range 'add '(read)))))
6339 ;; Then we have to re-compute how many unread
6340 ;; articles there are in this group.
6344 (setq num (- (1+ (cdr active)) (car active))))
6345 ((not (listp (cdr range)))
6346 (setq num (- (cdr active) (- (1+ (cdr range))
6350 (if (numberp (car range))
6352 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6353 (setq range (cdr range)))
6354 (setq num (- (cdr active) num))))
6355 ;; Update the number of unread articles.
6357 ;; Update the group buffer.
6358 (unless (gnus-ephemeral-group-p group)
6359 (gnus-group-update-group group t))))))
6361 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6362 (let ((cur nntp-server-buffer)
6365 (with-current-buffer gnus-summary-buffer
6366 gnus-newsgroup-dependencies)))
6367 headers id end ref number
6368 (mail-parse-charset gnus-newsgroup-charset)
6369 (mail-parse-ignored-charsets
6370 (save-current-buffer (condition-case nil
6371 (set-buffer gnus-summary-buffer)
6373 gnus-newsgroup-ignored-charsets)))
6374 (with-current-buffer nntp-server-buffer
6375 ;; Translate all TAB characters into SPACE characters.
6376 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6377 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6378 (ietf-drums-unfold-fws)
6379 (gnus-run-hooks 'gnus-parse-headers-hook)
6380 (let ((case-fold-search t)
6381 in-reply-to header p lines chars)
6382 (goto-char (point-min))
6383 ;; Search to the beginning of the next header. Error messages
6384 ;; do not begin with 2 or 3.
6385 (while (re-search-forward "^[23][0-9]+ " nil t)
6388 ;; This implementation of this function, with nine
6389 ;; search-forwards instead of the one re-search-forward and
6390 ;; a case (which basically was the old function) is actually
6391 ;; about twice as fast, even though it looks messier. You
6392 ;; can't have everything, I guess. Speed and elegance
6393 ;; doesn't always go hand in hand.
6399 (setq number (read cur))
6402 (narrow-to-region (point)
6403 (or (and (search-forward "\n.\n" nil t)
6409 (if (search-forward "\nsubject:" nil t)
6410 (funcall gnus-decode-encoded-word-function
6411 (nnheader-header-value))
6416 (if (search-forward "\nfrom:" nil t)
6417 (funcall gnus-decode-encoded-address-function
6418 (nnheader-header-value))
6423 (if (search-forward "\ndate:" nil t)
6424 (nnheader-header-value) ""))
6428 (setq id (if (re-search-forward
6429 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6430 ;; We do it this way to make sure the Message-ID
6431 ;; is (somewhat) syntactically valid.
6432 (buffer-substring (match-beginning 1)
6434 ;; If there was no message-id, we just fake one
6435 ;; to make subsequent routines simpler.
6436 (nnheader-generate-fake-message-id number))))
6440 (if (search-forward "\nreferences:" nil t)
6444 (nnheader-header-value)
6449 (search-backward ">" end t)
6452 (search-backward "<" end t)
6454 ;; Get the references from the in-reply-to header if there
6455 ;; were no references and the in-reply-to header looks
6457 (if (and (search-forward "\nin-reply-to:" nil t)
6458 (setq in-reply-to (nnheader-header-value))
6459 (string-match "<[^>]+>" in-reply-to))
6461 (setq ref (substring in-reply-to (match-beginning 0)
6463 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6464 (setq ref2 (substring in-reply-to (match-beginning 0)
6466 (when (> (length ref2) (length ref))
6473 (if (search-forward "\nchars: " nil t)
6474 (if (numberp (setq chars (ignore-errors (read cur))))
6480 (if (search-forward "\nlines: " nil t)
6481 (if (numberp (setq lines (ignore-errors (read cur))))
6487 (and (search-forward "\nxref:" nil t)
6488 (nnheader-header-value)))
6490 (when gnus-extra-headers
6491 (let ((extra gnus-extra-headers)
6495 (when (search-forward
6496 (concat "\n" (symbol-name (car extra)) ":") nil t)
6497 (push (cons (car extra) (nnheader-header-value))
6501 (when (equal id ref)
6504 (when gnus-alter-header-function
6505 (funcall gnus-alter-header-function header)
6506 (setq id (mail-header-id header)
6507 ref (gnus-parent-id (mail-header-references header))))
6510 (gnus-dependencies-add-header
6511 header dependencies force-new))
6512 (push header headers))
6513 (goto-char (point-max))
6515 (nreverse headers)))))
6517 ;; Goes through the xover lines and returns a list of vectors
6518 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6519 force-new dependencies
6520 group also-fetch-heads)
6521 "Parse the news overview data in the server buffer.
6522 Return a list of headers that match SEQUENCE (see
6523 `nntp-retrieve-headers')."
6524 ;; Get the Xref when the users reads the articles since most/some
6525 ;; NNTP servers do not include Xrefs when using XOVER.
6526 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6527 (let ((mail-parse-charset gnus-newsgroup-charset)
6528 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6529 (cur nntp-server-buffer)
6530 (dependencies (or dependencies gnus-newsgroup-dependencies))
6532 ((eq gnus-read-all-available-headers t)
6534 ((and (stringp gnus-read-all-available-headers)
6536 (string-match gnus-read-all-available-headers group))
6539 number headers header)
6540 (with-current-buffer nntp-server-buffer
6541 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6542 ;; Allow the user to mangle the headers before parsing them.
6543 (gnus-run-hooks 'gnus-parse-headers-hook)
6544 (goto-char (point-min))
6545 (gnus-parse-without-error
6546 (while (and (or sequence allp)
6548 (setq number (read cur))
6550 (while (and sequence
6551 (< (car sequence) number))
6552 (setq sequence (cdr sequence))))
6555 (eq number (car sequence))))
6557 (setq sequence (cdr sequence))
6558 (setq header (inline
6559 (gnus-nov-parse-line
6560 number dependencies force-new)))))
6561 (push header headers))
6563 ;; A common bug in inn is that if you have posted an article and
6564 ;; then retrieves the active file, it will answer correctly --
6565 ;; the new article is included. However, a NOV entry for the
6566 ;; article may not have been generated yet, so this may fail.
6567 ;; We work around this problem by retrieving the last few
6568 ;; headers using HEAD.
6569 (if (or (not also-fetch-heads)
6571 ;; We (probably) got all the headers.
6573 (let ((gnus-nov-is-evil t))
6576 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6577 (gnus-get-newsgroup-headers))))))))
6579 (defun gnus-article-get-xrefs ()
6580 "Fill in the Xref value in `gnus-current-headers', if necessary.
6581 This is meant to be called in `gnus-article-internal-prepare-hook'."
6582 (let ((headers (with-current-buffer gnus-summary-buffer
6583 gnus-current-headers)))
6584 (or (not gnus-use-cross-reference)
6586 (and (mail-header-xref headers)
6587 (not (string= (mail-header-xref headers) "")))
6588 (let ((case-fold-search t)
6591 (nnheader-narrow-to-headers)
6592 (goto-char (point-min))
6593 (when (or (and (not (eobp))
6594 (eq (downcase (char-after)) ?x)
6595 (looking-at "Xref:"))
6596 (search-forward "\nXref:" nil t))
6597 (goto-char (1+ (match-end 0)))
6598 (setq xref (buffer-substring (point) (point-at-eol)))
6599 (mail-header-set-xref headers xref)))))))
6601 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6602 "Find article ID and insert the summary line for that article.
6603 OLD-HEADER can either be a header or a line number to insert
6604 the subject line on.
6605 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6606 and OLD-HEADER will be used when the summary line is inserted,
6607 too, instead of trying to fetch new headers."
6608 (let* ((line (and (numberp old-header) old-header))
6609 (old-header (and (vectorp old-header) old-header))
6610 (header (cond ((and old-header use-old-header)
6613 (gnus-number-to-header id))
6614 (gnus-number-to-header id))
6616 (gnus-read-header id))))
6617 (number (and (numberp id) id))
6620 ;; Rebuild the thread that this article is part of and go to the
6621 ;; article we have fetched.
6622 (when (and (not gnus-show-threads)
6625 (setq d (gnus-data-find (mail-header-number old-header))))
6626 (goto-char (gnus-data-pos d))
6632 (gnus-delete-line))))))
6633 ;; Remove list identifiers from subject.
6634 (let ((gnus-newsgroup-headers (list header)))
6635 (gnus-summary-remove-list-identifiers))
6637 (mail-header-set-number header (mail-header-number old-header)))
6638 (setq gnus-newsgroup-sparse
6639 (delq (setq number (mail-header-number header))
6640 gnus-newsgroup-sparse))
6641 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6642 (push number gnus-newsgroup-limit)
6643 (gnus-rebuild-thread (mail-header-id header) line)
6644 (gnus-summary-goto-subject number nil t))
6645 (when (and (numberp number)
6647 ;; We have to update the boundaries even if we can't fetch the
6648 ;; article if ID is a number -- so that the next `P' or `N'
6649 ;; command will fetch the previous (or next) article even
6650 ;; if the one we tried to fetch this time has been canceled.
6651 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6652 (setq gnus-newsgroup-end number))
6653 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6654 (setq gnus-newsgroup-begin number))
6655 (setq gnus-newsgroup-unselected
6656 (delq number gnus-newsgroup-unselected)))
6657 ;; Report back a success?
6658 (and header (mail-header-number header))))
6660 ;;; Process/prefix in the summary buffer
6662 (defun gnus-summary-work-articles (n)
6663 "Return a list of articles to be worked upon.
6664 The prefix argument, the list of process marked articles, and the
6665 current article will be taken into consideration."
6666 (with-current-buffer gnus-summary-buffer
6669 ;; A numerical prefix has been given.
6670 (setq n (prefix-numeric-value n))
6671 (let ((backward (< n 0))
6672 (n (abs (prefix-numeric-value n)))
6677 (push (setq article (gnus-summary-article-number))
6680 (gnus-summary-find-prev nil article)
6681 (gnus-summary-find-next nil article)))
6683 (nreverse articles)))
6684 ((and (gnus-region-active-p) (mark))
6685 (message "region active")
6686 ;; Work on the region between point and mark.
6687 (let ((max (max (point) (mark)))
6690 (goto-char (min (point) (mark)))
6693 (push (setq article (gnus-summary-article-number)) articles)
6694 (gnus-summary-find-next nil article)
6696 (nreverse articles))))
6697 (gnus-newsgroup-processable
6698 ;; There are process-marked articles present.
6699 ;; Save current state.
6700 (gnus-summary-save-process-mark)
6702 (reverse gnus-newsgroup-processable))
6704 ;; Just return the current article.
6705 (list (gnus-summary-article-number))))))
6707 (defmacro gnus-summary-iterate (arg &rest forms)
6708 "Iterate over the process/prefixed articles and do FORMS.
6709 ARG is the interactive prefix given to the command. FORMS will be
6710 executed with point over the summary line of the articles."
6711 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6712 `(let ((,articles (gnus-summary-work-articles ,arg)))
6714 (gnus-summary-goto-subject (car ,articles))
6718 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6719 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6721 (defun gnus-summary-save-process-mark ()
6722 "Push the current set of process marked articles on the stack."
6724 (push (copy-sequence gnus-newsgroup-processable)
6725 gnus-newsgroup-process-stack))
6727 (defun gnus-summary-kill-process-mark ()
6728 "Push the current set of process marked articles on the stack and unmark."
6730 (gnus-summary-save-process-mark)
6731 (gnus-summary-unmark-all-processable))
6733 (defun gnus-summary-yank-process-mark ()
6734 "Pop the last process mark state off the stack and restore it."
6736 (unless gnus-newsgroup-process-stack
6737 (error "Empty mark stack"))
6738 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6740 (defun gnus-summary-process-mark-set (set)
6741 "Make SET into the current process marked articles."
6742 (gnus-summary-unmark-all-processable)
6743 (mapc 'gnus-summary-set-process-mark set))
6745 ;;; Searching and stuff
6747 (defun gnus-summary-search-group (&optional backward use-level)
6748 "Search for next unread newsgroup.
6749 If optional argument BACKWARD is non-nil, search backward instead."
6750 (with-current-buffer gnus-group-buffer
6751 (when (gnus-group-search-forward
6752 backward nil (if use-level (gnus-group-group-level) nil))
6753 (gnus-group-group-name))))
6755 (defun gnus-summary-best-group (&optional exclude-group)
6756 "Find the name of the best unread group.
6757 If EXCLUDE-GROUP, do not go to this group."
6758 (with-current-buffer gnus-group-buffer
6760 (gnus-group-best-unread-group exclude-group))))
6762 (defun gnus-summary-find-next (&optional unread article backward)
6764 (gnus-summary-find-prev unread article)
6765 (let* ((dummy (gnus-summary-article-intangible-p))
6766 (article (or article (gnus-summary-article-number)))
6767 (data (gnus-data-find-list article))
6769 (when (and (not dummy)
6770 (or (not gnus-summary-check-current)
6772 (not (gnus-data-unread-p (car data)))))
6773 (setq data (cdr data)))
6778 (unless (memq (gnus-data-number (car data))
6780 ((eq gnus-auto-goto-ignores
6781 'always-undownloaded)
6782 gnus-newsgroup-undownloaded)
6785 ((eq gnus-auto-goto-ignores
6787 gnus-newsgroup-unfetched)
6788 ((eq gnus-auto-goto-ignores
6790 gnus-newsgroup-undownloaded)))
6791 (when (gnus-data-unread-p (car data))
6792 (setq result (car data)
6794 (setq data (cdr data)))
6797 (goto-char (gnus-data-pos result))
6798 (gnus-data-number result)))))
6800 (defun gnus-summary-find-prev (&optional unread article)
6801 (let* ((eobp (eobp))
6802 (article (or article (gnus-summary-article-number)))
6803 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6805 (when (and (not eobp)
6806 (or (not gnus-summary-check-current)
6808 (not (gnus-data-unread-p (car data)))))
6809 (setq data (cdr data)))
6814 (unless (memq (gnus-data-number (car data))
6816 ((eq gnus-auto-goto-ignores
6817 'always-undownloaded)
6818 gnus-newsgroup-undownloaded)
6821 ((eq gnus-auto-goto-ignores
6823 gnus-newsgroup-unfetched)
6824 ((eq gnus-auto-goto-ignores
6826 gnus-newsgroup-undownloaded)))
6827 (when (gnus-data-unread-p (car data))
6828 (setq result (car data)
6830 (setq data (cdr data)))
6833 (goto-char (gnus-data-pos result))
6834 (gnus-data-number result))))
6836 (defun gnus-summary-find-subject (subject &optional unread backward article)
6837 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6838 (article (or article (gnus-summary-article-number)))
6839 (articles (gnus-data-list backward))
6840 (arts (gnus-data-find-list article articles))
6842 (when (or (not gnus-summary-check-current)
6844 (not (gnus-data-unread-p (car arts))))
6845 (setq arts (cdr arts)))
6847 (and (or (not unread)
6848 (gnus-data-unread-p (car arts)))
6849 (vectorp (gnus-data-header (car arts)))
6851 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6852 (setq result (car arts)
6854 (setq arts (cdr arts)))
6856 (goto-char (gnus-data-pos result))
6857 (gnus-data-number result))))
6859 (defun gnus-summary-search-forward (&optional unread subject backward)
6860 "Search forward for an article.
6861 If UNREAD, look for unread articles. If SUBJECT, look for
6862 articles with that subject. If BACKWARD, search backward instead."
6863 (cond (subject (gnus-summary-find-subject subject unread backward))
6864 (backward (gnus-summary-find-prev unread))
6865 (t (gnus-summary-find-next unread))))
6867 (defun gnus-recenter (&optional n)
6868 "Center point in window and redisplay frame.
6869 Also do horizontal recentering."
6871 (when (and gnus-auto-center-summary
6872 (not (eq gnus-auto-center-summary 'vertical)))
6873 (gnus-horizontal-recenter))
6874 (if (fboundp 'recenter-top-bottom)
6875 (recenter-top-bottom n)
6878 (put 'gnus-recenter 'isearch-scroll t)
6880 (defun gnus-forward-line-ignore-invisible (n)
6881 "Move N lines forward (backward if N is negative).
6882 Like forward-line, but skip over (and don't count) invisible lines."
6884 (while (and (> n 0) (not done))
6885 ;; If the following character is currently invisible,
6886 ;; skip all characters with that same `invisible' property value.
6887 (while (gnus-invisible-p (point))
6888 (goto-char (gnus-next-char-property-change (point))))
6893 (while (and (< n 0) (not done))
6895 (if (bobp) (setq done t)
6897 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6898 (goto-char (gnus-previous-char-property-change (point))))))))
6900 (defun gnus-summary-recenter ()
6901 "Center point in the summary window.
6902 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6903 displayed, no centering will be performed."
6904 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6905 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6907 ;; The user has to want it.
6908 (when gnus-auto-center-summary
6909 (let* ((top (cond ((< (window-height) 4) 0)
6910 ((< (window-height) 7) 1)
6911 (t (if (numberp gnus-auto-center-summary)
6912 gnus-auto-center-summary
6913 (/ (1- (window-height)) 2)))))
6914 (height (1- (window-height)))
6915 (bottom (save-excursion
6916 (goto-char (point-max))
6917 (gnus-forward-line-ignore-invisible (- height))
6919 (window (get-buffer-window (current-buffer))))
6920 (when (get-buffer-window gnus-article-buffer)
6921 ;; Only do recentering when the article buffer is displayed,
6922 ;; Set the window start to either `bottom', which is the biggest
6923 ;; possible valid number, or the second line from the top,
6924 ;; whichever is the least.
6925 (let ((top-pos (save-excursion
6926 (gnus-forward-line-ignore-invisible (- top))
6928 (if (> bottom top-pos)
6929 ;; Keep the second line from the top visible
6930 (set-window-start window top-pos)
6931 ;; Try to keep the bottom line visible; if it's partially
6932 ;; obscured, either scroll one more line to make it fully
6933 ;; visible, or revert to using TOP-POS.
6935 (goto-char (point-max))
6936 (gnus-forward-line-ignore-invisible -1)
6937 (let ((last-line-start (point)))
6939 (set-window-start window (point) t)
6940 (when (not (pos-visible-in-window-p last-line-start window))
6941 (gnus-forward-line-ignore-invisible 1)
6942 (set-window-start window (min (point) top-pos) t)))))))
6943 ;; Do horizontal recentering while we're at it.
6944 (when (and (get-buffer-window (current-buffer) t)
6945 (not (eq gnus-auto-center-summary 'vertical)))
6946 (let ((selected (selected-window)))
6947 (select-window (get-buffer-window (current-buffer) t))
6948 (gnus-summary-position-point)
6949 (gnus-horizontal-recenter)
6950 (select-window selected))))))
6952 (defun gnus-summary-jump-to-group (newsgroup)
6953 "Move point to NEWSGROUP in group mode buffer."
6954 ;; Keep update point of group mode buffer if visible.
6955 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6956 (save-window-excursion
6957 ;; Take care of tree window mode.
6958 (when (get-buffer-window gnus-group-buffer)
6959 (pop-to-buffer gnus-group-buffer))
6960 (gnus-group-jump-to-group newsgroup))
6962 ;; Take care of tree window mode.
6963 (if (get-buffer-window gnus-group-buffer 0)
6964 (pop-to-buffer gnus-group-buffer)
6965 (set-buffer gnus-group-buffer))
6966 (gnus-group-jump-to-group newsgroup))))
6968 ;; This function returns a list of article numbers based on the
6969 ;; difference between the ranges of read articles in this group and
6970 ;; the range of active articles.
6971 (defun gnus-list-of-unread-articles (group)
6972 (let* ((read (gnus-info-read (gnus-get-info group)))
6973 (active (or (gnus-active group) (gnus-activate-group group)))
6974 (last (or (cdr active)
6975 (error "Group %s couldn't be activated " group)))
6976 (bottom (if gnus-newsgroup-maximum-articles
6978 (- last gnus-newsgroup-maximum-articles -1))
6981 ;; If none are read, then all are unread.
6984 ;; If the range of read articles is a single range, then the
6985 ;; first unread article is the article after the last read
6986 ;; article. Sounds logical, doesn't it?
6987 (if (and (not (listp (cdr read)))
6988 (or (< (car read) bottom)
6989 (progn (setq read (list read))
6991 (setq first (max bottom (1+ (cdr read))))
6992 ;; `read' is a list of ranges.
6993 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6996 (setq first bottom))
6999 (while (< first nlast)
7000 (setq unread (cons first unread)
7002 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7003 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7004 (setq read (cdr read)))))
7005 ;; And add the last unread articles.
7006 (while (<= first last)
7007 (setq unread (cons first unread)
7009 ;; Return the list of unread articles.
7010 (delq 0 (nreverse unread))))
7012 (defun gnus-list-of-read-articles (group)
7013 "Return a list of unread, unticked and non-dormant articles."
7014 (let* ((info (gnus-get-info group))
7015 (marked (gnus-info-marks info))
7016 (active (gnus-active group)))
7018 (gnus-list-range-difference
7019 (gnus-list-range-difference
7020 (gnus-sorted-complement
7021 (gnus-uncompress-range
7022 (if gnus-newsgroup-maximum-articles
7023 (cons (max (car active)
7025 gnus-newsgroup-maximum-articles
7029 (gnus-list-of-unread-articles group))
7030 (cdr (assq 'dormant marked)))
7031 (cdr (assq 'tick marked))))))
7033 ;; This function returns a sequence of article numbers based on the
7034 ;; difference between the ranges of read articles in this group and
7035 ;; the range of active articles.
7036 (defun gnus-sequence-of-unread-articles (group)
7037 (let* ((read (gnus-info-read (gnus-get-info group)))
7038 (active (or (gnus-active group) (gnus-activate-group group)))
7040 (bottom (if gnus-newsgroup-maximum-articles
7042 (- last gnus-newsgroup-maximum-articles -1))
7045 ;; If none are read, then all are unread.
7048 ;; If the range of read articles is a single range, then the
7049 ;; first unread article is the article after the last read
7050 ;; article. Sounds logical, doesn't it?
7051 (if (and (not (listp (cdr read)))
7052 (or (< (car read) bottom)
7053 (progn (setq read (list read))
7055 (setq first (max bottom (1+ (cdr read))))
7056 ;; `read' is a list of ranges.
7057 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7060 (setq first bottom))
7063 (push (cons first nlast) unread))
7064 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7065 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7066 (setq read (cdr read)))))
7067 ;; And add the last unread articles.
7068 (cond ((not (and first last))
7071 (push (cons first last) unread))
7073 (push first unread)))
7074 ;; Return the sequence of unread articles.
7075 (delq 0 (nreverse unread))))
7077 ;; Various summary commands
7079 (defun gnus-summary-select-article-buffer ()
7080 "Reconfigure windows to show the article buffer.
7081 If `gnus-widen-article-window' is set, show only the article
7084 (if (not (gnus-buffer-live-p gnus-article-buffer))
7085 (error "There is no article buffer for this summary buffer")
7086 (unless (get-buffer-window gnus-article-buffer)
7087 (gnus-summary-show-article))
7088 (gnus-configure-windows
7089 (if gnus-widen-article-window
7093 (select-window (get-buffer-window gnus-article-buffer))))
7095 (defun gnus-summary-universal-argument (arg)
7096 "Perform any operation on all articles that are process/prefixed."
7098 (let ((articles (gnus-summary-work-articles arg))
7105 (substitute-command-keys
7106 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7108 (gnus-error 1 "Undefined key")
7111 (gnus-summary-goto-subject (setq article (pop articles)))
7112 (let (gnus-newsgroup-processable)
7113 (command-execute func))
7114 (gnus-summary-remove-process-mark article)))))
7115 (gnus-summary-position-point))
7117 (defun gnus-summary-toggle-truncation (&optional arg)
7118 "Toggle truncation of summary lines.
7119 With ARG, turn line truncation on if ARG is positive."
7121 (setq truncate-lines
7122 (if (null arg) (not truncate-lines)
7123 (> (prefix-numeric-value arg) 0)))
7126 (defun gnus-summary-find-for-reselect ()
7127 "Return the number of an article to stay on across a reselect.
7128 The current article is considered, then following articles, then previous
7129 articles. An article is sought which is not canceled and isn't a temporary
7130 insertion from another group. If there's no such then return a dummy 0."
7132 (dolist (rev '(nil t))
7133 (unless found ; don't demand the reverse list if we don't need it
7134 (let ((data (gnus-data-find-list
7135 (gnus-summary-article-number) (gnus-data-list rev))))
7136 (while (and data (not found))
7137 (if (and (< 0 (gnus-data-number (car data)))
7138 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7139 (setq found (gnus-data-number (car data))))
7140 (setq data (cdr data))))))
7143 (defun gnus-summary-reselect-current-group (&optional all rescan)
7144 "Exit and then reselect the current newsgroup.
7145 The prefix argument ALL means to select all articles."
7147 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7148 (error "Ephemeral groups can't be reselected"))
7149 (let ((current-subject (gnus-summary-find-for-reselect))
7150 (group gnus-newsgroup-name))
7151 (setq gnus-newsgroup-begin nil)
7152 (gnus-summary-exit nil 'leave-hidden)
7153 ;; We have to adjust the point of group mode buffer because
7154 ;; point was moved to the next unread newsgroup by exiting.
7155 (gnus-summary-jump-to-group group)
7158 (gnus-group-get-new-news-this-group 1)))
7159 (gnus-group-read-group all t)
7160 (gnus-summary-goto-subject current-subject nil t)))
7162 (defun gnus-summary-rescan-group (&optional all)
7163 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7165 (let ((config gnus-current-window-configuration))
7166 (gnus-summary-reselect-current-group all t)
7167 (gnus-configure-windows config)
7168 (when (eq config 'article)
7169 (gnus-summary-select-article))))
7171 (defun gnus-summary-update-info (&optional non-destructive)
7173 (let ((group gnus-newsgroup-name))
7175 (when gnus-newsgroup-kill-headers
7176 (setq gnus-newsgroup-killed
7177 (gnus-compress-sequence
7179 (gnus-list-range-intersection
7180 gnus-newsgroup-unselected gnus-newsgroup-killed)
7181 gnus-newsgroup-unreads)
7183 (unless (listp (cdr gnus-newsgroup-killed))
7184 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7185 (let ((headers gnus-newsgroup-headers)
7186 (ephemeral-p (gnus-ephemeral-group-p group))
7189 (setq info (copy-sequence (gnus-get-info group))
7190 info (delq (gnus-info-params info) info)))
7191 ;; Set the new ranges of read articles.
7192 (with-current-buffer gnus-group-buffer
7193 (gnus-undo-force-boundary))
7194 (gnus-update-read-articles
7195 group (gnus-sorted-union
7196 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7197 ;; Set the current article marks.
7198 (let ((gnus-newsgroup-scored
7199 (if (and (not gnus-save-score)
7200 (not non-destructive))
7202 gnus-newsgroup-scored)))
7204 (gnus-update-marks)))
7205 ;; Do the cross-ref thing.
7206 (when gnus-use-cross-reference
7207 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7208 ;; Do not switch windows but change the buffer to work.
7209 (set-buffer gnus-group-buffer)
7211 (gnus-group-update-group
7214 (setq info (copy-sequence (gnus-get-info group))
7215 info (delq (gnus-info-params info) info))))))))))
7217 (defun gnus-summary-save-newsrc (&optional force)
7218 "Save the current number of read/marked articles in the dribble buffer.
7219 The dribble buffer will then be saved.
7220 If FORCE (the prefix), also save the .newsrc file(s)."
7222 (gnus-summary-update-info t)
7224 (gnus-save-newsrc-file)
7225 (gnus-dribble-save)))
7227 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7228 (declare-function gnus-article-stop-animations "gnus-art" ())
7230 (defun gnus-summary-exit (&optional temporary leave-hidden)
7231 "Exit reading current newsgroup, and then return to group selection mode.
7232 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7234 (gnus-set-global-variables)
7235 (when (gnus-buffer-live-p gnus-article-buffer)
7236 (with-current-buffer gnus-article-buffer
7237 (mm-destroy-parts gnus-article-mime-handles)
7238 ;; Set it to nil for safety reason.
7239 (setq gnus-article-mime-handle-alist nil)
7240 (setq gnus-article-mime-handles nil)))
7241 (gnus-kill-save-kill-buffer)
7242 (gnus-async-halt-prefetch)
7243 (let* ((group gnus-newsgroup-name)
7244 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7245 (gnus-group-is-exiting-p t)
7246 (article-buffer gnus-article-buffer)
7247 (original-article-buffer gnus-original-article-buffer)
7250 (buf (current-buffer))
7251 ;; `gnus-single-article-buffer' is nil buffer-locally in
7252 ;; ephemeral group of which summary buffer will be killed,
7253 ;; but the global value may be non-nil.
7254 (single-article-buffer gnus-single-article-buffer))
7256 ;; Do adaptive scoring, and possibly save score files.
7257 (when gnus-newsgroup-adaptive
7258 (gnus-score-adaptive))
7259 (when gnus-use-scoring
7261 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7262 (when gnus-use-cache
7263 (gnus-cache-possibly-remove-articles)
7264 (gnus-cache-save-buffers))
7265 (gnus-async-prefetch-remove-group group)
7266 (when gnus-suppress-duplicates
7267 (gnus-dup-enter-articles))
7268 (when gnus-use-trees
7270 (when gnus-use-cache
7271 (gnus-cache-write-active))
7272 ;; Remove entries for this group.
7273 (nnmail-purge-split-history (gnus-group-real-name group))
7274 ;; Make all changes in this group permanent.
7276 (gnus-run-hooks 'gnus-exit-group-hook)
7277 (gnus-summary-update-info))
7278 (gnus-close-group group)
7279 ;; Make sure where we were, and go to next newsgroup.
7280 (when (buffer-live-p (get-buffer gnus-group-buffer))
7281 (set-buffer gnus-group-buffer))
7283 (gnus-group-jump-to-group group))
7284 (gnus-run-hooks 'gnus-summary-exit-hook)
7285 (unless (or quit-config
7286 (not gnus-summary-next-group-on-exit)
7287 ;; If this group has disappeared from the summary
7288 ;; buffer, don't skip forwards.
7289 (not (string= group (gnus-group-group-name))))
7290 (gnus-group-next-unread-group 1))
7291 (setq group-point (point))
7292 (gnus-article-stop-animations)
7296 (if (not gnus-kill-summary-on-exit)
7298 (gnus-deaden-summary)
7300 (when (get-buffer gnus-article-buffer)
7301 (bury-buffer gnus-article-buffer))
7302 ;; Return to group mode buffer.
7303 (when (eq mode 'gnus-summary-mode)
7304 (gnus-kill-buffer buf)))
7306 (setq gnus-current-select-method gnus-select-method)
7307 (when (gnus-buffer-live-p gnus-group-buffer)
7308 (set-buffer gnus-group-buffer))
7310 (gnus-handle-ephemeral-exit quit-config)
7311 (goto-char group-point)
7312 ;; If gnus-group-buffer is already displayed, make sure we also move
7313 ;; the cursor in the window that displays it.
7314 (let ((win (get-buffer-window (current-buffer) 0)))
7315 (if win (set-window-point win (point))))
7316 (unless leave-hidden
7317 (gnus-configure-windows 'group 'force)))
7319 ;; If we have several article buffers, we kill them at exit.
7320 (unless single-article-buffer
7321 (when (gnus-buffer-live-p article-buffer)
7322 (with-current-buffer article-buffer
7323 ;; Don't kill sticky article buffers
7324 (unless (eq major-mode 'gnus-sticky-article-mode)
7325 (gnus-kill-buffer article-buffer)
7326 (setq gnus-article-current nil))))
7327 (gnus-kill-buffer original-article-buffer))
7329 ;; Clear the current group name.
7331 (setq gnus-newsgroup-name nil)))))
7333 (declare-function gnus-stop-downloads "gnus-art" ())
7335 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7336 (defun gnus-summary-exit-no-update (&optional no-questions)
7337 "Quit reading current newsgroup without updating read article info."
7339 (let* ((group gnus-newsgroup-name)
7340 (gnus-group-is-exiting-p t)
7341 (gnus-group-is-exiting-without-update-p t)
7342 (quit-config (gnus-group-quit-config group)))
7343 (when (or no-questions
7344 (gnus-ephemeral-group-p group)
7346 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7347 (gnus-async-halt-prefetch)
7348 (run-hooks 'gnus-summary-prepare-exit-hook)
7349 (when (gnus-buffer-live-p gnus-article-buffer)
7350 (with-current-buffer gnus-article-buffer
7351 (gnus-article-stop-animations)
7352 (gnus-stop-downloads)
7353 (mm-destroy-parts gnus-article-mime-handles)
7354 ;; Set it to nil for safety reason.
7355 (setq gnus-article-mime-handle-alist nil)
7356 (setq gnus-article-mime-handles nil)))
7357 ;; If we have several article buffers, we kill them at exit.
7358 (unless gnus-single-article-buffer
7359 (gnus-kill-buffer gnus-article-buffer)
7360 (gnus-kill-buffer gnus-original-article-buffer)
7361 (setq gnus-article-current nil))
7362 ;; Return to the group buffer.
7363 (if (not gnus-kill-summary-on-exit)
7365 (gnus-deaden-summary)
7366 (gnus-configure-windows 'group 'force))
7367 (gnus-configure-windows 'group 'force)
7368 (gnus-close-group group)
7369 (gnus-kill-buffer gnus-summary-buffer))
7370 (unless gnus-single-article-buffer
7371 (setq gnus-article-current nil))
7372 (when gnus-use-trees
7374 (gnus-async-prefetch-remove-group group)
7375 (when (get-buffer gnus-article-buffer)
7376 (bury-buffer gnus-article-buffer))
7377 ;; Clear the current group name.
7378 (setq gnus-newsgroup-name nil)
7379 (unless (gnus-ephemeral-group-p group)
7380 (gnus-group-update-group group nil t))
7381 (when (equal (gnus-group-group-name) group)
7382 (gnus-group-next-unread-group 1))
7383 (gnus-article-stop-animations)
7385 (gnus-handle-ephemeral-exit quit-config)))))
7387 (defun gnus-handle-ephemeral-exit (quit-config)
7388 "Handle movement when leaving an ephemeral group.
7389 The state which existed when entering the ephemeral is reset."
7390 (if (not (buffer-live-p (car quit-config)))
7391 (when (gnus-buffer-live-p gnus-group-buffer)
7392 (gnus-configure-windows 'group 'force))
7393 (set-buffer (car quit-config))
7394 (unless (eq (cdr quit-config) 'group)
7395 (setq gnus-current-select-method
7396 (gnus-find-method-for-group gnus-newsgroup-name)))
7397 (cond ((derived-mode-p 'gnus-summary-mode)
7398 (gnus-set-global-variables))
7399 ((derived-mode-p 'gnus-article-mode)
7400 (save-current-buffer
7401 ;; The `gnus-summary-buffer' variable may point
7402 ;; to the old summary buffer when using a single
7404 (unless (gnus-buffer-live-p gnus-summary-buffer)
7405 (set-buffer gnus-group-buffer))
7406 (set-buffer gnus-summary-buffer)
7407 (gnus-set-global-variables))))
7408 (if (or (eq (cdr quit-config) 'article)
7409 (eq (cdr quit-config) 'pick))
7410 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7411 (gnus-configure-windows 'pick 'force)
7412 (gnus-configure-windows (cdr quit-config) 'force))
7413 (gnus-configure-windows (cdr quit-config) 'force))
7414 (when (derived-mode-p 'gnus-summary-mode)
7415 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7416 next-unread-noselect))
7417 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7419 (gnus-summary-next-subject 1 nil t))
7420 ((eq gnus-auto-select-on-ephemeral-exit
7421 'next-unread-noselect)
7422 (gnus-summary-next-subject 1 t t))))
7423 ;; Hide the article buffer which displays the article different
7424 ;; from the one that the cursor points to in the summary buffer.
7425 (gnus-configure-windows 'summary 'force))
7426 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7427 (gnus-summary-next-subject 1))
7428 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7429 (gnus-summary-next-subject 1 t))))
7430 (gnus-summary-recenter)
7431 (gnus-summary-position-point))))
7435 (defvar gnus-dead-summary-mode-map
7436 (let ((map (make-keymap)))
7437 (suppress-keymap map)
7438 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7439 (dolist (key '("\C-d" "\r" "\177" [delete]))
7440 (define-key map key 'gnus-summary-wake-up-the-dead))
7441 (dolist (key '("q" "Q"))
7442 (define-key map key 'bury-buffer))
7445 (define-minor-mode gnus-dead-summary-mode
7446 "Minor mode for Gnus summary buffers."
7447 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7448 (unless (derived-mode-p 'gnus-summary-mode)
7449 (setq gnus-dead-summary-mode nil)))
7451 (defun gnus-deaden-summary ()
7452 "Make the current summary buffer into a dead summary buffer."
7453 ;; Kill any previous dead summary buffer.
7454 (when (and gnus-dead-summary
7455 (buffer-name gnus-dead-summary))
7456 (with-current-buffer gnus-dead-summary
7457 (when gnus-dead-summary-mode
7458 (kill-buffer (current-buffer)))))
7459 ;; Make this the current dead summary.
7460 (setq gnus-dead-summary (current-buffer))
7461 (gnus-dead-summary-mode 1)
7462 (let ((name (buffer-name)))
7463 (when (string-match "Summary" name)
7465 (concat (substring name 0 (match-beginning 0)) "Dead "
7466 (substring name (match-beginning 0)))
7470 (defun gnus-kill-or-deaden-summary (buffer)
7471 "Kill or deaden the summary BUFFER."
7473 (when (and (buffer-name buffer)
7474 (not gnus-single-article-buffer))
7475 (with-current-buffer buffer
7476 (gnus-kill-buffer gnus-article-buffer)
7477 (gnus-kill-buffer gnus-original-article-buffer)))
7480 (gnus-kill-summary-on-exit
7481 (when (and gnus-use-trees
7482 (gnus-buffer-exists-p buffer))
7483 (with-current-buffer buffer
7485 (gnus-kill-buffer buffer))
7486 ;; Deaden the buffer.
7487 ((gnus-buffer-exists-p buffer)
7488 (with-current-buffer buffer
7489 (gnus-deaden-summary))))))
7491 (defun gnus-summary-wake-up-the-dead (&rest args)
7492 "Wake up the dead summary buffer."
7494 (gnus-dead-summary-mode -1)
7495 (let ((name (buffer-name)))
7496 (when (string-match "Dead " name)
7498 (concat (substring name 0 (match-beginning 0))
7499 (substring name (match-end 0)))
7501 (gnus-message 3 "This dead summary is now alive again"))
7503 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7504 (defun gnus-summary-describe-group (&optional force)
7505 "Describe the current newsgroup."
7507 (gnus-group-describe-group force gnus-newsgroup-name))
7509 (defun gnus-summary-describe-briefly ()
7510 "Describe summary mode commands briefly."
7512 (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")))
7514 ;; Walking around group mode buffer from summary mode.
7516 (defun gnus-summary-next-group (&optional no-article target-group backward)
7517 "Exit current newsgroup and then select next unread newsgroup.
7518 If prefix argument NO-ARTICLE is non-nil, no article is selected
7519 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7520 previous group instead."
7522 ;; Stop pre-fetching.
7523 (gnus-async-halt-prefetch)
7524 (let ((current-group gnus-newsgroup-name)
7525 (current-buffer (current-buffer))
7527 ;; First we semi-exit this group to update Xrefs and all variables.
7528 ;; We can't do a real exit, because the window conf must remain
7529 ;; the same in case the user is prompted for info, and we don't
7530 ;; want the window conf to change before that...
7531 (gnus-summary-exit t)
7532 (while (not entered)
7533 ;; Then we find what group we are supposed to enter.
7534 (set-buffer gnus-group-buffer)
7535 (gnus-group-jump-to-group current-group)
7538 (if (eq gnus-keep-same-level 'best)
7539 (gnus-summary-best-group gnus-newsgroup-name)
7540 (gnus-summary-search-group backward gnus-keep-same-level))))
7541 (if (not target-group)
7542 ;; There are no further groups, so we return to the group
7545 (gnus-message 5 "Returning to the group buffer")
7547 (when (gnus-buffer-live-p current-buffer)
7548 (set-buffer current-buffer)
7549 (gnus-summary-exit))
7550 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7551 ;; We try to enter the target group.
7552 (gnus-group-jump-to-group target-group)
7553 (let ((unreads (gnus-group-group-unread)))
7554 (if (and (or (eq t unreads)
7555 (and unreads (not (zerop unreads))))
7556 (gnus-summary-read-group
7557 target-group nil no-article
7558 (and (buffer-name current-buffer) current-buffer)
7561 (setq current-group target-group
7562 target-group nil)))))))
7564 (defun gnus-summary-prev-group (&optional no-article)
7565 "Exit current newsgroup and then select previous unread newsgroup.
7566 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7568 (gnus-summary-next-group no-article nil t))
7570 ;; Walking around summary lines.
7572 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7573 "Go to the first subject satisfying any non-nil constraint.
7574 If UNREAD is non-nil, the article should be unread.
7575 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7576 If UNSEEN is non-nil, the article should be unseen as well as unread.
7577 Returns the article selected or nil if there are no matching articles."
7581 ((null gnus-newsgroup-data)
7582 (gnus-message 3 "No articles in the group")
7584 ;; Pick the first article.
7585 ((not (or unread undownloaded unseen))
7586 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7587 (gnus-data-number (car gnus-newsgroup-data)))
7588 ;; Find the first unread article.
7590 (let ((data gnus-newsgroup-data))
7592 (let ((num (gnus-data-number (car data))))
7593 (or (memq num gnus-newsgroup-unfetched)
7594 (not (or (and unread
7595 (memq num gnus-newsgroup-unreads))
7597 (memq num gnus-newsgroup-undownloaded))
7599 (memq num gnus-newsgroup-unseen)
7600 (memq num gnus-newsgroup-unreads)))))))
7601 (setq data (cdr data)))
7605 (goto-char (gnus-data-pos (car data)))
7606 (gnus-data-number (car data)))
7607 (gnus-message 3 "No more%s articles"
7608 (let* ((r (when unread " unread"))
7609 (d (when undownloaded " undownloaded"))
7610 (s (when unseen " unseen"))
7611 (l (delq nil (list r d s))))
7612 (cond ((= 3 (length l))
7613 (concat r "," d ", or" s))
7615 (concat (car l) ", or" (cadr l)))
7622 (gnus-summary-position-point))))))
7624 (defun gnus-summary-next-subject (n &optional unread dont-display)
7625 "Go to next N'th summary line.
7626 If N is negative, go to the previous N'th subject line.
7627 If UNREAD is non-nil, only unread articles are selected.
7628 The difference between N and the actual number of steps taken is
7631 (let ((backward (< n 0))
7635 (gnus-summary-find-prev unread)
7636 (gnus-summary-find-next unread)))
7637 (unless (zerop (setq n (1- n)))
7638 (gnus-summary-show-thread)))
7640 (gnus-message 7 "No more%s articles"
7641 (if unread " unread" "")))
7642 (unless dont-display
7643 (gnus-summary-recenter)
7644 (gnus-summary-position-point))
7647 (defun gnus-summary-next-unread-subject (n)
7648 "Go to next N'th unread summary line."
7650 (gnus-summary-next-subject n t))
7652 (defun gnus-summary-prev-subject (n &optional unread)
7653 "Go to previous N'th summary line.
7654 If optional argument UNREAD is non-nil, only unread article is selected."
7656 (gnus-summary-next-subject (- n) unread))
7658 (defun gnus-summary-prev-unread-subject (n)
7659 "Go to previous N'th unread summary line."
7661 (gnus-summary-next-subject (- n) t))
7663 (defun gnus-summary-goto-subjects (articles)
7664 "Insert the subject header for ARTICLES in the current buffer."
7666 (dolist (article articles)
7667 (gnus-summary-goto-subject article t)))
7668 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7669 (gnus-summary-position-point))
7671 (defun gnus-summary-goto-subject (article &optional force silent)
7672 "Go to the subject line of ARTICLE.
7673 If FORCE, also allow jumping to articles not currently shown."
7674 (interactive "nArticle number: ")
7675 (unless (numberp article)
7676 (error "Article %s is not a number" article))
7678 (data (gnus-data-find article)))
7679 ;; We read in the article if we have to.
7682 (gnus-summary-insert-subject
7684 (if (or (numberp force) (vectorp force)) force)
7686 (setq data (gnus-data-find article)))
7691 (gnus-message 3 "Can't find article %d" article))
7693 (let ((pt (gnus-data-pos data)))
7695 (gnus-summary-set-article-display-arrow pt))
7696 (gnus-summary-position-point)
7699 ;; Walking around summary lines with displaying articles.
7701 (defun gnus-summary-expand-window (&optional arg)
7702 "Make the summary buffer take up the entire Emacs frame.
7703 Given a prefix, will force an `article' buffer configuration."
7706 (gnus-configure-windows 'article 'force)
7707 (gnus-configure-windows 'summary 'force)))
7709 (defun gnus-summary-display-article (article &optional all-header)
7710 "Display ARTICLE in article buffer."
7711 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7712 (with-current-buffer gnus-article-buffer
7713 (derived-mode-p 'gnus-article-mode)))
7714 (gnus-article-setup-buffer))
7715 (gnus-set-global-variables)
7716 (with-current-buffer gnus-article-buffer
7717 (setq gnus-article-charset gnus-newsgroup-charset)
7718 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7719 (mm-enable-multibyte))
7723 (if gnus-summary-display-article-function
7724 (funcall gnus-summary-display-article-function article all-header)
7725 (gnus-article-prepare article all-header))
7726 (gnus-run-hooks 'gnus-select-article-hook)
7727 (when (and gnus-current-article
7728 (not (zerop gnus-current-article)))
7729 (gnus-summary-goto-subject gnus-current-article))
7730 (gnus-summary-recenter)
7731 (when (and gnus-use-trees gnus-show-threads)
7732 (gnus-possibly-generate-tree article)
7733 (gnus-highlight-selected-tree article))
7734 ;; Successfully display article.
7735 (gnus-article-set-window-start
7736 (cdr (assq article gnus-newsgroup-bookmarks))))))
7738 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7739 "Select the current article.
7740 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7741 non-nil, the article will be re-fetched even if it already present in
7742 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7744 ;; Make sure we are in the summary buffer to work around bbdb bug.
7745 (unless (derived-mode-p 'gnus-summary-mode)
7746 (set-buffer gnus-summary-buffer))
7747 (let ((article (or article (gnus-summary-article-number)))
7748 (all-headers (not (not all-headers))) ;Must be t or nil.
7749 gnus-summary-display-article-function)
7751 (gnus-summary-article-pseudo-p article)
7752 (error "This is a pseudo-article"))
7753 (with-current-buffer gnus-summary-buffer
7754 (if (or (and gnus-single-article-buffer
7755 (or (null gnus-current-article)
7756 (null gnus-article-current)
7757 (null (get-buffer gnus-article-buffer))
7758 (not (eq article (cdr gnus-article-current)))
7759 (not (equal (car gnus-article-current)
7760 gnus-newsgroup-name))
7761 (not (get-buffer gnus-original-article-buffer))))
7762 (and (not gnus-single-article-buffer)
7763 (or (null gnus-current-article)
7764 (not (get-buffer gnus-original-article-buffer))
7765 (not (eq gnus-current-article article))))
7767 ;; The requested article is different from the current article.
7769 (gnus-summary-display-article article all-headers)
7770 (when (gnus-buffer-live-p gnus-article-buffer)
7771 (with-current-buffer gnus-article-buffer
7772 (if (not gnus-article-decoded-p) ;; a local variable
7773 (mm-disable-multibyte))))
7774 (gnus-article-set-window-start
7775 (cdr (assq article gnus-newsgroup-bookmarks)))
7779 (defun gnus-summary-force-verify-and-decrypt ()
7780 "Display buttons for signed/encrypted parts and verify/decrypt them."
7782 (let ((mm-verify-option 'known)
7783 (mm-decrypt-option 'known)
7784 (gnus-article-emulate-mime t)
7785 (gnus-buttonized-mime-types (append (list "multipart/signed"
7786 "multipart/encrypted")
7787 gnus-buttonized-mime-types)))
7788 (gnus-summary-select-article nil 'force)))
7790 (defun gnus-summary-next-article (&optional unread subject backward push)
7791 "Select the next article.
7792 If UNREAD, only unread articles are selected.
7793 If SUBJECT, only articles with SUBJECT are selected.
7794 If BACKWARD, the previous article is selected instead of the next."
7796 ;; Make sure we are in the summary buffer.
7797 (unless (derived-mode-p 'gnus-summary-mode)
7798 (set-buffer gnus-summary-buffer))
7800 ;; Is there such an article?
7801 ((and (gnus-summary-search-forward unread subject backward)
7802 (or (gnus-summary-display-article (gnus-summary-article-number))
7803 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7804 (gnus-summary-position-point))
7805 ;; If not, we try the first unread, if that is wanted.
7807 gnus-auto-select-same
7808 (gnus-summary-first-unread-article))
7809 (gnus-summary-position-point)
7810 (gnus-message 6 "Wrapped"))
7811 ;; Try to get next/previous article not displayed in this group.
7812 ((and gnus-auto-extend-newsgroup
7813 (not unread) (not subject))
7814 (gnus-summary-goto-article
7815 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7816 nil (count-lines (point-min) (point))))
7817 ;; Go to next/previous group.
7819 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7820 (gnus-summary-jump-to-group gnus-newsgroup-name))
7821 (let ((cmd (if (featurep 'xemacs)
7823 last-command-event))
7825 (with-current-buffer gnus-group-buffer
7827 (current-summary (current-buffer))
7829 (if (eq gnus-keep-same-level 'best)
7830 (gnus-summary-best-group gnus-newsgroup-name)
7831 (gnus-summary-search-group backward gnus-keep-same-level))))
7832 ;; Select next unread newsgroup automagically.
7834 ((or (not gnus-auto-select-next)
7836 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7837 ((or (eq gnus-auto-select-next 'quietly)
7838 (and (eq gnus-auto-select-next 'slightly-quietly)
7840 (and (eq gnus-auto-select-next 'almost-quietly)
7841 (gnus-summary-last-article-p)))
7843 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7845 (gnus-message 7 "No more%s articles (%s)..."
7846 (if unread " unread" "")
7847 (if group (concat "selecting " group)
7849 (gnus-summary-next-group nil group backward)))
7851 (when (gnus-key-press-event-p last-input-event)
7852 ;; Somehow or other, we may now have selected a different
7853 ;; window. Make point go back to the summary buffer.
7854 (when (eq current-summary (current-buffer))
7855 ;; FIXME: This burps when get-buffer-window returns nil.
7856 (select-window (get-buffer-window current-summary 0)))
7857 (gnus-summary-walk-group-buffer
7858 gnus-newsgroup-name cmd unread backward point))))))))
7860 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7861 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7862 (?\C-p (gnus-group-prev-unread-group 1))))
7863 (cursor-in-echo-area t)
7864 keve key group ended prompt)
7865 (with-current-buffer gnus-group-buffer
7868 (if (eq gnus-keep-same-level 'best)
7869 (gnus-summary-best-group gnus-newsgroup-name)
7870 (gnus-summary-search-group backward gnus-keep-same-level))))
7874 "No more%s articles%s " (if unread " unread" "")
7876 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7877 (format " (Type %s for %s [%s])"
7878 (single-key-description cmd)
7879 (gnus-group-decoded-name group)
7880 (gnus-group-unread group))
7881 (format " (Type %s to exit %s)"
7882 (single-key-description cmd)
7883 (gnus-group-decoded-name gnus-newsgroup-name)))))
7884 ;; Confirm auto selection.
7885 (setq key (car (setq keve (gnus-read-event-char prompt)))
7888 ((assq key keystrokes)
7889 (let ((obuf (current-buffer)))
7890 (switch-to-buffer gnus-group-buffer)
7892 (gnus-group-jump-to-group group))
7893 (eval (cadr (assq key keystrokes)))
7894 (setq group (gnus-group-group-name))
7895 (switch-to-buffer obuf))
7899 (gnus-ephemeral-group-p gnus-newsgroup-name))
7901 (gnus-summary-next-group nil group backward)))
7903 (push (cdr keve) unread-command-events))))))
7905 (defun gnus-summary-next-unread-article ()
7906 "Select unread article after current one."
7908 (gnus-summary-next-article
7909 (or (not (eq gnus-summary-goto-unread 'never))
7910 (gnus-summary-last-article-p (gnus-summary-article-number)))
7911 (and gnus-auto-select-same
7912 (gnus-summary-article-subject))))
7914 (defun gnus-summary-prev-article (&optional unread subject)
7915 "Select the article before the current one.
7916 If UNREAD is non-nil, only unread articles are selected."
7918 (gnus-summary-next-article unread subject t))
7920 (defun gnus-summary-prev-unread-article ()
7921 "Select unread article before current one."
7923 (gnus-summary-prev-article
7924 (or (not (eq gnus-summary-goto-unread 'never))
7925 (gnus-summary-first-article-p (gnus-summary-article-number)))
7926 (and gnus-auto-select-same
7927 (gnus-summary-article-subject))))
7929 (declare-function gnus-article-only-boring-p "gnus-art" ())
7931 (defun gnus-summary-next-page (&optional lines circular stop)
7932 "Show next page of the selected article.
7933 If at the end of the current article, select the next article.
7934 LINES says how many lines should be scrolled up.
7936 If CIRCULAR is non-nil, go to the start of the article instead of
7937 selecting the next article when reaching the end of the current
7940 If STOP is non-nil, just stop when reaching the end of the message.
7942 Also see the variable `gnus-article-skip-boring'."
7944 (gnus-set-global-variables)
7945 (let ((article (gnus-summary-article-number))
7946 (article-window (get-buffer-window gnus-article-buffer t))
7948 ;; If the buffer is empty, we have no article.
7950 (error "No article to select"))
7951 (gnus-configure-windows 'article)
7952 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7953 (if (and (eq gnus-summary-goto-unread 'never)
7954 (not (gnus-summary-last-article-p article)))
7955 (gnus-summary-next-article)
7956 (gnus-summary-next-unread-article))
7957 (if (or (null gnus-current-article)
7958 (null gnus-article-current)
7959 (/= article (cdr gnus-article-current))
7960 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7961 ;; Selected subject is different from current article's.
7962 (gnus-summary-display-article article)
7963 (when article-window
7964 (gnus-eval-in-buffer-window gnus-article-buffer
7965 (setq endp (or (gnus-article-next-page lines)
7966 (gnus-article-only-boring-p))))
7968 (cond ((or stop gnus-summary-stop-at-end-of-message)
7969 (gnus-message 3 "End of message"))
7971 (gnus-summary-beginning-of-article))
7973 (gnus-message 3 "End of message"))
7975 (if (and (eq gnus-summary-goto-unread 'never)
7976 (not (gnus-summary-last-article-p article)))
7977 (gnus-summary-next-article)
7978 (gnus-summary-next-unread-article))))))))
7979 (gnus-summary-recenter)
7980 (gnus-summary-position-point)))
7982 (defun gnus-summary-prev-page (&optional lines move)
7983 "Show previous page of selected article.
7984 Argument LINES specifies lines to be scrolled down.
7985 If MOVE, move to the previous unread article if point is at
7986 the beginning of the buffer."
7988 (let ((article (gnus-summary-article-number))
7989 (article-window (get-buffer-window gnus-article-buffer t))
7991 (gnus-configure-windows 'article)
7992 (if (or (null gnus-current-article)
7993 (null gnus-article-current)
7994 (/= article (cdr gnus-article-current))
7995 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7996 ;; Selected subject is different from current article's.
7997 (gnus-summary-display-article article)
7998 (gnus-summary-recenter)
7999 (when article-window
8000 (gnus-eval-in-buffer-window gnus-article-buffer
8001 (setq endp (gnus-article-prev-page lines)))
8002 (when (and move endp)
8004 (gnus-message 3 "Beginning of message"))
8006 (if (and (eq gnus-summary-goto-unread 'never)
8007 (not (gnus-summary-first-article-p article)))
8008 (gnus-summary-prev-article)
8009 (gnus-summary-prev-unread-article))))))))
8010 (gnus-summary-position-point))
8012 (defun gnus-summary-prev-page-or-article (&optional lines)
8013 "Show previous page of selected article.
8014 Argument LINES specifies lines to be scrolled down.
8015 If at the beginning of the article, go to the next article."
8017 (gnus-summary-prev-page lines t))
8019 (defun gnus-summary-scroll-up (lines)
8020 "Scroll up (or down) one line current article.
8021 Argument LINES specifies lines to be scrolled up (or down if negative).
8022 If no article is selected, then the current article will be selected first."
8024 (gnus-configure-windows 'article)
8025 (gnus-summary-show-thread)
8026 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8027 (gnus-eval-in-buffer-window gnus-article-buffer
8029 (when (gnus-article-next-page lines)
8030 (gnus-message 3 "End of message")))
8032 (gnus-article-prev-page (- lines))))))
8033 (gnus-summary-recenter)
8034 (gnus-summary-position-point))
8036 (defun gnus-summary-scroll-down (lines)
8037 "Scroll down (or up) one line current article.
8038 Argument LINES specifies lines to be scrolled down (or up if negative).
8039 If no article is selected, then the current article will be selected first."
8041 (gnus-summary-scroll-up (- lines)))
8043 (defun gnus-summary-next-same-subject ()
8044 "Select next article which has the same subject as current one."
8046 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8048 (defun gnus-summary-prev-same-subject ()
8049 "Select previous article which has the same subject as current one."
8051 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8053 (defun gnus-summary-next-unread-same-subject ()
8054 "Select next unread article which has the same subject as current one."
8056 (gnus-summary-next-article t (gnus-summary-article-subject)))
8058 (defun gnus-summary-prev-unread-same-subject ()
8059 "Select previous unread article which has the same subject as current one."
8061 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8063 (defun gnus-summary-first-unread-article ()
8064 "Select the first unread article.
8065 Return nil if there are no unread articles."
8068 (when (gnus-summary-first-subject t)
8069 (gnus-summary-show-thread)
8070 (gnus-summary-first-subject t)
8071 (gnus-summary-display-article (gnus-summary-article-number)))
8072 (gnus-summary-position-point)))
8074 (defun gnus-summary-first-unread-subject ()
8075 "Place the point on the subject line of the first unread article.
8076 Return nil if there are no unread articles."
8079 (when (gnus-summary-first-subject t)
8080 (gnus-summary-show-thread)
8081 (gnus-summary-first-subject t))
8082 (gnus-summary-position-point)))
8084 (defun gnus-summary-first-unseen-subject ()
8085 "Place the point on the subject line of the first unseen article.
8086 Return nil if there are no unseen articles."
8089 (when (gnus-summary-first-subject nil nil t)
8090 (gnus-summary-show-thread)
8091 (gnus-summary-first-subject nil nil t))
8092 (gnus-summary-position-point)))
8094 (defun gnus-summary-first-unseen-or-unread-subject ()
8095 "Place the point on the subject line of the first unseen and unread article.
8096 If all article have been seen, on the subject line of the first unread
8100 (unless (when (gnus-summary-first-subject nil nil t)
8101 (gnus-summary-show-thread)
8102 (gnus-summary-first-subject nil nil t))
8103 (when (gnus-summary-first-subject t)
8104 (gnus-summary-show-thread)
8105 (gnus-summary-first-subject t)))
8106 (gnus-summary-position-point)))
8108 (defun gnus-summary-first-article ()
8109 "Select the first article.
8110 Return nil if there are no articles."
8113 (when (gnus-summary-first-subject)
8114 (gnus-summary-show-thread)
8115 (gnus-summary-first-subject)
8116 (gnus-summary-display-article (gnus-summary-article-number)))
8117 (gnus-summary-position-point)))
8119 (defun gnus-summary-best-unread-article (&optional arg)
8120 "Select the unread article with the highest score.
8121 If given a prefix argument, select the next unread article that has a
8122 score higher than the default score."
8124 (let ((article (if arg
8125 (gnus-summary-better-unread-subject)
8126 (gnus-summary-best-unread-subject))))
8128 (gnus-summary-goto-article article)
8129 (error "No unread articles"))))
8131 (defun gnus-summary-best-unread-subject ()
8132 "Select the unread subject with the highest score."
8134 (let ((best -1000000)
8135 (data gnus-newsgroup-data)
8138 (and (gnus-data-unread-p (car data))
8140 (gnus-summary-article-score (gnus-data-number (car data))))
8143 article (gnus-data-number (car data))))
8144 (setq data (cdr data)))
8146 (gnus-summary-goto-subject article))
8147 (gnus-summary-position-point)
8150 (defun gnus-summary-better-unread-subject ()
8151 "Select the first unread subject that has a score over the default score."
8153 (let ((data gnus-newsgroup-data)
8155 (while (and (setq article (gnus-data-number (car data)))
8156 (or (gnus-data-read-p (car data))
8157 (not (> (gnus-summary-article-score article)
8158 gnus-summary-default-score))))
8159 (setq data (cdr data)))
8161 (gnus-summary-goto-subject article))
8162 (gnus-summary-position-point)
8165 (defun gnus-summary-last-subject ()
8166 "Go to the last displayed subject line in the group."
8167 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8169 (gnus-summary-goto-subject article))))
8171 (defun gnus-summary-goto-article (article &optional all-headers force)
8172 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8173 If ALL-HEADERS is non-nil, no header lines are hidden.
8174 If FORCE, go to the article even if it isn't displayed. If FORCE
8175 is a number, it is the line the article is to be displayed on."
8178 (gnus-completing-read
8179 "Article number or Message-ID"
8180 (mapcar 'int-to-string gnus-newsgroup-limit))
8184 (if (and (stringp article)
8185 (string-match "@\\|%40" article))
8186 (gnus-summary-refer-article article)
8187 (when (stringp article)
8188 (setq article (string-to-number article)))
8189 (if (gnus-summary-goto-subject article force)
8190 (gnus-summary-display-article article all-headers)
8191 (gnus-message 4 "Couldn't go to article %s" article) nil))
8192 (gnus-summary-position-point)))
8194 (defun gnus-summary-goto-last-article ()
8195 "Go to the previously read article."
8198 (when gnus-last-article
8199 (gnus-summary-goto-article gnus-last-article nil t))
8200 (gnus-summary-position-point)))
8202 (defun gnus-summary-pop-article (number)
8203 "Pop one article off the history and go to the previous.
8204 NUMBER articles will be popped off."
8207 (setq gnus-newsgroup-history
8208 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8210 (gnus-summary-goto-article (car to) nil t)
8211 (error "Article history empty")))
8212 (gnus-summary-position-point))
8214 ;; Summary commands and functions for limiting the summary buffer.
8216 (defun gnus-summary-limit-to-articles (n)
8217 "Limit the summary buffer to the next N articles.
8218 If not given a prefix, use the process marked articles instead."
8221 (let ((articles (gnus-summary-work-articles n)))
8222 (setq gnus-newsgroup-processable nil)
8223 (gnus-summary-limit articles))
8224 (gnus-summary-position-point)))
8226 (defun gnus-summary-pop-limit (&optional total)
8227 "Restore the previous limit.
8228 If given a prefix, remove all limits."
8231 (setq gnus-newsgroup-limits
8232 (list (mapcar (lambda (h) (mail-header-number h))
8233 gnus-newsgroup-headers))))
8234 (unless gnus-newsgroup-limits
8235 (error "No limit to pop"))
8237 (gnus-summary-limit nil 'pop)
8238 (gnus-summary-position-point)))
8240 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8241 "Limit the summary buffer to articles that have subjects that match a regexp.
8242 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8244 (list (read-string (if current-prefix-arg
8245 "Exclude subject (regexp): "
8246 "Limit to subject (regexp): "))
8247 nil current-prefix-arg))
8249 (setq header "subject"))
8250 (when (not (equal "" subject))
8252 (let ((articles (gnus-summary-find-matching
8253 (or header "subject") subject 'all nil nil
8256 (error "Found no matches for \"%s\"" subject))
8257 (gnus-summary-limit articles))
8258 (gnus-summary-position-point))))
8260 (defun gnus-summary-limit-to-author (from &optional not-matching)
8261 "Limit the summary buffer to articles that have authors that match a regexp.
8262 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8264 (list (let* ((header (gnus-summary-article-header))
8265 (default (and header (car (mail-header-parse-address
8266 (mail-header-from header))))))
8267 (read-string (concat (if current-prefix-arg
8268 "Exclude author (regexp"
8269 "Limit to author (regexp")
8271 (concat ", default \"" default "\"): ")
8275 current-prefix-arg))
8276 (gnus-summary-limit-to-subject from "from" not-matching))
8278 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8279 "Limit the summary buffer to articles with the given RECIPIENT.
8281 If NOT-MATCHING, exclude RECIPIENT.
8283 To and Cc headers are checked. You need to include them in
8284 `nnmail-extra-headers'."
8285 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8287 (list (read-string (format "%s recipient (regexp): "
8288 (if current-prefix-arg "Exclude" "Limit to")))
8289 current-prefix-arg))
8290 (when (not (equal "" recipient))
8292 (if (memq 'To nnmail-extra-headers)
8293 (gnus-summary-find-matching
8294 (cons 'extra 'To) recipient 'all nil nil
8297 1 "`To' isn't present in `nnmail-extra-headers'")
8301 (if (memq 'Cc nnmail-extra-headers)
8302 (gnus-summary-find-matching
8303 (cons 'extra 'Cc) recipient 'all nil nil
8306 1 "`Cc' isn't present in `nnmail-extra-headers'")
8311 ;; We need the numbers that are in both lists:
8313 (and (memq a to) a))
8317 (error "Found no matches for \"%s\"" recipient))
8318 (gnus-summary-limit articles))
8319 (gnus-summary-position-point))))
8321 (defun gnus-summary-limit-to-address (address &optional not-matching)
8322 "Limit the summary buffer to articles with the given ADDRESS.
8324 If NOT-MATCHING, exclude ADDRESS.
8326 To, Cc and From headers are checked. You need to include `To' and `Cc'
8327 in `nnmail-extra-headers'."
8329 (list (read-string (format "%s address (regexp): "
8330 (if current-prefix-arg "Exclude" "Limit to")))
8331 current-prefix-arg))
8332 (when (not (equal "" address))
8334 (if (memq 'To nnmail-extra-headers)
8335 (gnus-summary-find-matching
8336 (cons 'extra 'To) address 'all nil nil
8339 1 "`To' isn't present in `nnmail-extra-headers'")
8343 (if (memq 'Cc nnmail-extra-headers)
8344 (gnus-summary-find-matching
8345 (cons 'extra 'Cc) address 'all nil nil
8348 1 "`Cc' isn't present in `nnmail-extra-headers'")
8352 (gnus-summary-find-matching "from" address
8353 'all nil nil not-matching))
8356 ;; We need the numbers that are in all lists:
8360 (mapcar (lambda (a) (car (memq a from))) to))
8362 (mapcar (lambda (a) (car (memq a from))) cc)
8363 (mapcar (lambda (a) (car (memq a from)))
8364 (mapcar (lambda (a) (car (memq a to)))
8366 (nconc (if (eq to t) nil to)
8367 (if (eq cc t) nil cc)
8370 (error "Found no matches for \"%s\"" address))
8371 (gnus-summary-limit articles))
8372 (gnus-summary-position-point))))
8374 (defun gnus-summary-limit-strange-charsets-predicate (header)
8375 (when (fboundp 'char-charset)
8376 (let ((string (concat (mail-header-subject header)
8377 (mail-header-from header)))
8379 (dotimes (i (1- (length string)))
8380 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8381 (when (string-match "unicode\\|big\\|japanese" charset)
8385 (defun gnus-summary-limit-to-predicate (predicate)
8386 "Limit to articles where PREDICATE returns non-nil.
8387 PREDICATE will be called with the header structures of the
8389 (let ((articles nil)
8390 (case-fold-search t))
8391 (dolist (header gnus-newsgroup-headers)
8392 (when (funcall predicate header)
8393 (push (mail-header-number header) articles)))
8394 (gnus-summary-limit (nreverse articles))))
8396 (defun gnus-summary-limit-to-age (age &optional younger-p)
8397 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8398 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8399 articles that are younger than AGE days."
8401 (let ((younger current-prefix-arg)
8404 (while (not days-got)
8405 (setq days (if younger
8406 (read-string "Limit to articles younger than (in days, older when negative): ")
8408 "Limit to articles older than (in days, younger when negative): ")))
8409 (when (> (length days) 0)
8410 (setq days (read days)))
8415 (setq younger (not younger))
8416 (setq days (* days -1))))
8417 (message "Please enter a number.")
8419 (list days younger)))
8421 (let ((data gnus-newsgroup-data)
8422 (cutoff (days-to-time age))
8423 articles d date is-younger)
8424 (while (setq d (pop data))
8425 (when (and (vectorp (gnus-data-header d))
8426 (setq date (mail-header-date (gnus-data-header d))))
8427 (setq is-younger (time-less-p
8428 (time-since (gnus-date-get-time date))
8433 (push (gnus-data-number d) articles))))
8434 (gnus-summary-limit (nreverse articles)))
8435 (gnus-summary-position-point)))
8437 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8438 "Limit the summary buffer to articles that match an `extra' header."
8442 (gnus-completing-read
8443 (if current-prefix-arg
8444 "Exclude extra header"
8445 "Limit extra header")
8446 (mapcar 'symbol-name gnus-extra-headers)
8448 (symbol-name (car gnus-extra-headers))))))
8450 (read-string (format "%s header %s (regexp): "
8451 (if current-prefix-arg "Exclude" "Limit to")
8453 current-prefix-arg)))
8454 (when (not (equal "" regexp))
8456 (let ((articles (gnus-summary-find-matching
8457 (cons 'extra header) regexp 'all nil nil
8460 (error "Found no matches for \"%s\"" regexp))
8461 (gnus-summary-limit articles))
8462 (gnus-summary-position-point))))
8464 (defun gnus-summary-limit-to-display-predicate ()
8465 "Limit the summary buffer to the predicated in the `display' group parameter."
8467 (unless gnus-newsgroup-display
8468 (error "There is no `display' group parameter"))
8470 (dolist (gnus-number gnus-newsgroup-articles)
8471 (when (funcall gnus-newsgroup-display)
8472 (push gnus-number articles)))
8473 (gnus-summary-limit articles))
8474 (gnus-summary-position-point))
8476 (defun gnus-summary-limit-to-unread (&optional all)
8477 "Limit the summary buffer to articles that are not marked as read.
8478 If ALL is non-nil, limit strictly to unread articles."
8481 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8482 (gnus-summary-limit-to-marks
8483 ;; Concat all the marks that say that an article is read and have
8485 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8486 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8487 gnus-low-score-mark gnus-expirable-mark
8488 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8489 gnus-duplicate-mark)
8492 (defun gnus-summary-limit-to-headers (match &optional reverse)
8493 "Limit the summary buffer to articles that have headers that match MATCH.
8494 If REVERSE (the prefix), limit to articles that don't match."
8495 (interactive "sMatch headers (regexp): \nP")
8496 (gnus-summary-limit-to-bodies match reverse t))
8498 (declare-function article-goto-body "gnus-art" ())
8500 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8501 "Limit the summary buffer to articles that have bodies that match MATCH.
8502 If REVERSE (the prefix), limit to articles that don't match."
8503 (interactive "sMatch body (regexp): \nP")
8504 (let ((articles nil)
8505 (gnus-select-article-hook nil) ;Disable hook.
8506 (gnus-article-prepare-hook nil)
8507 (gnus-use-article-prefetch nil)
8508 (gnus-keep-backlog nil)
8509 (gnus-break-pages nil)
8510 (gnus-summary-display-arrow nil)
8511 (gnus-updated-mode-lines nil)
8512 (gnus-auto-center-summary nil)
8513 (gnus-display-mime-function nil))
8514 (dolist (data gnus-newsgroup-data)
8515 (let (gnus-mark-article-hook)
8516 (gnus-summary-select-article t t nil (gnus-data-number data)))
8517 (with-current-buffer gnus-article-buffer
8519 (let* ((case-fold-search t)
8521 (re-search-backward match nil t)
8522 (re-search-forward match nil t))))
8523 (when (or (and found
8527 (push (gnus-data-number data) articles)))))
8529 (message "No messages matched")
8530 (gnus-summary-limit articles)))
8531 (gnus-summary-position-point))
8533 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8534 "Limit the summary buffer to articles that aren't part on any thread.
8535 If THREADSP (the prefix), limit to articles that are in threads."
8537 (let ((articles nil)
8540 (dolist (thread gnus-newsgroup-threads)
8541 (if (stringp (car thread))
8542 (dolist (thread (cdr thread))
8543 (push thread threads))
8544 (push thread threads)))
8545 (dolist (thread threads)
8546 (setq thread-articles (gnus-articles-in-thread thread))
8547 (when (or (and threadsp
8548 (> (length thread-articles) 1))
8550 (= (length thread-articles) 1)))
8551 (setq articles (nconc thread-articles articles))))
8553 (message "No messages matched")
8554 (gnus-summary-limit articles))
8555 (gnus-summary-position-point)))
8557 (defun gnus-summary-limit-to-replied (&optional unreplied)
8558 "Limit the summary buffer to replied articles.
8559 If UNREPLIED (the prefix), limit to unreplied articles."
8563 (gnus-set-difference gnus-newsgroup-articles
8564 gnus-newsgroup-replied))
8565 (gnus-summary-limit gnus-newsgroup-replied))
8566 (gnus-summary-position-point))
8568 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8569 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8570 If REVERSE, limit the summary buffer to articles that are marked
8571 with MARKS. MARKS can either be a string of marks or a list of marks.
8572 Returns how many articles were removed."
8573 (interactive "sMarks: ")
8574 (gnus-summary-limit-to-marks marks t))
8576 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8577 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8578 If REVERSE (the prefix), limit the summary buffer to articles that are
8579 not marked with MARKS. MARKS can either be a string of marks or a
8581 Returns how many articles were removed."
8582 (interactive "sMarks: \nP")
8584 (let ((data gnus-newsgroup-data)
8585 (marks (if (listp marks) marks
8586 (append marks nil))) ; Transform to list.
8589 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8590 (memq (gnus-data-mark (car data)) marks))
8591 (push (gnus-data-number (car data)) articles))
8592 (setq data (cdr data)))
8593 (gnus-summary-limit articles))
8594 (gnus-summary-position-point)))
8596 (defun gnus-summary-limit-to-score (score)
8597 "Limit to articles with score at or above SCORE."
8598 (interactive "NLimit to articles with score of at least: ")
8599 (let ((data gnus-newsgroup-data)
8602 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8604 (push (gnus-data-number (car data)) articles))
8605 (setq data (cdr data)))
8607 (gnus-summary-limit articles)
8608 (gnus-summary-position-point))))
8610 (defun gnus-summary-limit-to-unseen ()
8611 "Limit to unseen articles."
8614 (gnus-summary-limit gnus-newsgroup-unseen)
8615 (gnus-summary-position-point)))
8617 (defun gnus-summary-limit-include-thread (id)
8618 "Display all the hidden articles that is in the thread with ID in it.
8619 When called interactively, ID is the Message-ID of the current
8621 (interactive (list (mail-header-id (gnus-summary-article-header))))
8622 (let ((articles (gnus-articles-in-thread
8623 (gnus-id-to-thread (gnus-root-id id))))
8624 ;;we REALLY want the whole thread---this prevents cut-threads
8625 ;;from removing the thread we want to include.
8626 (gnus-fetch-old-headers nil)
8627 (gnus-build-sparse-threads nil))
8629 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8630 (gnus-summary-limit-include-matching-articles
8632 (regexp-quote (gnus-simplify-subject-re
8633 (mail-header-subject (gnus-id-to-header id)))))
8634 (gnus-summary-position-point))))
8636 (defun gnus-summary-limit-include-matching-articles (header regexp)
8637 "Display all the hidden articles that have HEADERs that match REGEXP."
8638 (interactive (list (read-string "Match on header: ")
8639 (read-string "Regexp: ")))
8640 (let ((articles (gnus-find-matching-articles header regexp)))
8642 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8643 (gnus-summary-position-point))))
8645 (defun gnus-summary-insert-dormant-articles ()
8646 "Insert all the dormant articles for this group into the current buffer."
8648 (let ((gnus-verbose (max 6 gnus-verbose)))
8649 (if (not gnus-newsgroup-dormant)
8650 (gnus-message 3 "No dormant articles for this group")
8651 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8653 (defun gnus-summary-insert-ticked-articles ()
8654 "Insert ticked articles for this group into the current buffer."
8656 (let ((gnus-verbose (max 6 gnus-verbose)))
8657 (if (not gnus-newsgroup-marked)
8658 (gnus-message 3 "No ticked articles for this group")
8659 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8661 (defun gnus-summary-limit-include-dormant ()
8662 "Display all the hidden articles that are marked as dormant.
8663 Note that this command only works on a subset of the articles currently
8664 fetched for this group."
8666 (unless gnus-newsgroup-dormant
8667 (error "There are no dormant articles in this group"))
8669 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8670 (gnus-summary-position-point)))
8672 (defun gnus-summary-include-articles (articles)
8673 "Fetch the headers for ARTICLES and then display the summary lines."
8674 (let ((gnus-inhibit-demon t)
8676 (gnus-read-all-available-headers t))
8677 (setq gnus-newsgroup-headers
8679 'list gnus-newsgroup-headers
8680 (gnus-fetch-headers articles nil t)
8681 'gnus-article-sort-by-number))
8682 (setq gnus-newsgroup-articles
8683 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8684 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8686 (defun gnus-summary-limit-exclude-dormant ()
8687 "Hide all dormant articles."
8690 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8691 (gnus-summary-position-point)))
8693 (defun gnus-summary-limit-exclude-childless-dormant ()
8694 "Hide all dormant articles that have no children."
8696 (let ((data (gnus-data-list t))
8697 articles d children)
8698 ;; Find all articles that are either not dormant or have
8700 (while (setq d (pop data))
8701 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8703 (gnus-article-children (gnus-data-number d)))
8706 (when (memq (car children) articles)
8711 (push (gnus-data-number d) articles)))
8714 (gnus-summary-limit articles)
8715 (gnus-summary-position-point))))
8717 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8718 "Mark all unread excluded articles as read.
8719 If ALL, mark even excluded ticked and dormants as read."
8721 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8722 (let ((articles (gnus-sorted-ndifference
8724 (mapcar (lambda (h) (mail-header-number h))
8725 gnus-newsgroup-headers)
8727 gnus-newsgroup-limit))
8729 (setq gnus-newsgroup-unreads
8730 (gnus-sorted-intersection gnus-newsgroup-unreads
8731 gnus-newsgroup-limit))
8733 (setq gnus-newsgroup-dormant nil
8734 gnus-newsgroup-marked nil
8735 gnus-newsgroup-reads
8737 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8738 gnus-newsgroup-reads))
8739 (while (setq article (pop articles))
8740 (unless (or (memq article gnus-newsgroup-dormant)
8741 (memq article gnus-newsgroup-marked))
8742 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8744 (defun gnus-summary-limit (articles &optional pop)
8746 ;; We pop the previous limit off the stack and use that.
8747 (setq articles (car gnus-newsgroup-limits)
8748 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8749 ;; We use the new limit, so we push the old limit on the stack.
8750 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8752 (setq gnus-newsgroup-limit articles)
8753 (let ((total (length gnus-newsgroup-data))
8754 (data (gnus-data-find-list (gnus-summary-article-number)))
8755 (gnus-summary-mark-below nil) ; Inhibit this.
8757 ;; This will do all the work of generating the new summary buffer
8758 ;; according to the new limit.
8759 (gnus-summary-prepare)
8760 ;; Hide any threads, possibly.
8761 (gnus-summary-maybe-hide-threads)
8762 ;; Try to return to the article you were at, or one in the
8765 ;; We try to find some article after the current one.
8767 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8770 (setq data (cdr data))))
8772 ;; If there is no data, that means that we were after the last
8773 ;; article. The same goes when we can't find any articles
8774 ;; after the current one.
8775 (goto-char (point-max))
8776 (gnus-summary-find-prev))
8777 (gnus-set-mode-line 'summary)
8778 ;; We return how many articles were removed from the summary
8779 ;; buffer as a result of the new limit.
8780 (- total (length gnus-newsgroup-data))))
8782 (defsubst gnus-invisible-cut-children (threads)
8785 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8790 (defsubst gnus-cut-thread (thread)
8791 "Go forwards in the thread until we find an article that we want to display."
8792 (when (or (eq gnus-fetch-old-headers 'some)
8793 (eq gnus-fetch-old-headers 'invisible)
8794 (numberp gnus-fetch-old-headers)
8795 (eq gnus-build-sparse-threads 'some)
8796 (eq gnus-build-sparse-threads 'more))
8797 ;; Deal with old-fetched headers and sparse threads.
8801 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8802 (gnus-summary-article-ancient-p
8803 (mail-header-number (car thread))))
8804 (if (or (<= (length (cdr thread)) 1)
8805 (eq gnus-fetch-old-headers 'invisible))
8806 (setq gnus-newsgroup-limit
8807 (delq (mail-header-number (car thread))
8808 gnus-newsgroup-limit)
8809 thread (cadr thread))
8810 (when (gnus-invisible-cut-children (cdr thread))
8811 (let ((th (cdr thread)))
8813 (if (memq (mail-header-number (caar th))
8814 gnus-newsgroup-limit)
8815 (setq thread (car th)
8817 (setq th (cdr th))))))))))
8820 (defun gnus-cut-threads (threads)
8821 "Cut off all uninteresting articles from the beginning of THREADS."
8822 (when (or (eq gnus-fetch-old-headers 'some)
8823 (eq gnus-fetch-old-headers 'invisible)
8824 (numberp gnus-fetch-old-headers)
8825 (eq gnus-build-sparse-threads 'some)
8826 (eq gnus-build-sparse-threads 'more))
8829 (setcar th (gnus-cut-thread (car th)))
8830 (setq th (cdr th)))))
8831 ;; Remove nixed out threads.
8834 (defun gnus-summary-initial-limit (&optional show-if-empty)
8835 "Figure out what the initial limit is supposed to be on group entry.
8836 This entails weeding out unwanted dormants, low-scored articles,
8837 fetch-old-headers verbiage, and so on."
8838 ;; Most groups have nothing to remove.
8839 (unless (or gnus-inhibit-limiting
8840 (and (null gnus-newsgroup-dormant)
8841 (eq gnus-newsgroup-display 'gnus-not-ignore)
8842 (not (eq gnus-fetch-old-headers 'some))
8843 (not (numberp gnus-fetch-old-headers))
8844 (not (eq gnus-fetch-old-headers 'invisible))
8845 (null gnus-summary-expunge-below)
8846 (not (eq gnus-build-sparse-threads 'some))
8847 (not (eq gnus-build-sparse-threads 'more))
8848 (null gnus-thread-expunge-below)))
8849 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8850 (setq gnus-newsgroup-limit nil)
8853 (unless (car (symbol-value node))
8854 ;; These threads have no parents -- they are roots.
8855 (let ((nodes (cdr (symbol-value node)))
8858 (if (and gnus-thread-expunge-below
8859 (< (gnus-thread-total-score (car nodes))
8860 gnus-thread-expunge-below))
8861 (gnus-expunge-thread (pop nodes))
8862 (setq thread (pop nodes))
8863 (gnus-summary-limit-children thread))))))
8864 gnus-newsgroup-dependencies)
8865 ;; If this limitation resulted in an empty group, we might
8866 ;; pop the previous limit and use it instead.
8867 (when (and (not gnus-newsgroup-limit)
8869 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8870 gnus-newsgroup-limit))
8872 (defun gnus-summary-limit-children (thread)
8873 "Return 1 if this subthread is visible and 0 if it is not."
8874 ;; First we get the number of visible children to this thread. This
8875 ;; is done by recursing down the thread using this function, so this
8876 ;; will really go down to a leaf article first, before slowly
8877 ;; working its way up towards the root.
8879 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8882 (apply '+ (mapcar 'gnus-summary-limit-children
8885 (number (mail-header-number (car thread)))
8888 (not (memq number gnus-newsgroup-marked))
8890 ;; If this article is dormant and has absolutely no visible
8891 ;; children, then this article isn't visible.
8892 (and (memq number gnus-newsgroup-dormant)
8894 ;; If this is "fetch-old-headered" and there is no
8895 ;; visible children, then we don't want this article.
8896 (and (or (eq gnus-fetch-old-headers 'some)
8897 (numberp gnus-fetch-old-headers))
8898 (gnus-summary-article-ancient-p number)
8900 ;; If this is "fetch-old-headered" and `invisible', then
8901 ;; we don't want this article.
8902 (and (eq gnus-fetch-old-headers 'invisible)
8903 (gnus-summary-article-ancient-p number))
8904 ;; If this is a sparsely inserted article with no children,
8905 ;; we don't want it.
8906 (and (eq gnus-build-sparse-threads 'some)
8907 (gnus-summary-article-sparse-p number)
8909 ;; If we use expunging, and this article is really
8910 ;; low-scored, then we don't want this article.
8911 (when (and gnus-summary-expunge-below
8913 (or (cdr (assq number gnus-newsgroup-scored))
8914 gnus-summary-default-score))
8915 gnus-summary-expunge-below))
8916 ;; We increase the expunge-tally here, but that has
8917 ;; nothing to do with the limits, really.
8918 (incf gnus-newsgroup-expunged-tally)
8919 ;; We also mark as read here, if that's wanted.
8920 (when (and gnus-summary-mark-below
8921 (< score gnus-summary-mark-below))
8922 (setq gnus-newsgroup-unreads
8923 (delq number gnus-newsgroup-unreads))
8924 (if gnus-newsgroup-auto-expire
8925 (push number gnus-newsgroup-expirable)
8926 (push (cons number gnus-low-score-mark)
8927 gnus-newsgroup-reads)))
8929 ;; Do the `display' group parameter.
8930 (and gnus-newsgroup-display
8931 (let ((gnus-number number))
8932 (not (funcall gnus-newsgroup-display))))))
8933 ;; Nope, invisible article.
8935 ;; Ok, this article is to be visible, so we add it to the limit
8937 (push number gnus-newsgroup-limit)
8940 (defun gnus-expunge-thread (thread)
8941 "Mark all articles in THREAD as read."
8942 (let* ((number (mail-header-number (car thread))))
8943 (incf gnus-newsgroup-expunged-tally)
8944 ;; We also mark as read here, if that's wanted.
8945 (setq gnus-newsgroup-unreads
8946 (delq number gnus-newsgroup-unreads))
8947 (if gnus-newsgroup-auto-expire
8948 (push number gnus-newsgroup-expirable)
8949 (push (cons number gnus-low-score-mark)
8950 gnus-newsgroup-reads)))
8951 ;; Go recursively through all subthreads.
8952 (mapcar 'gnus-expunge-thread (cdr thread)))
8954 ;; Summary article oriented commands
8956 (defun gnus-summary-refer-parent-article (n)
8957 "Refer parent article N times.
8958 If N is negative, go to ancestor -N instead.
8959 The difference between N and the number of articles fetched is returned."
8963 (when (not (natnump n))
8968 (setq header (gnus-summary-article-header))
8969 (if (and (eq (mail-header-number header)
8970 (cdr gnus-article-current))
8971 (equal gnus-newsgroup-name
8972 (car gnus-article-current)))
8973 ;; If we try to find the parent of the currently
8974 ;; displayed article, then we take a look at the actual
8975 ;; References header, since this is slightly more
8976 ;; reliable than the References field we got from the
8978 (with-current-buffer gnus-original-article-buffer
8979 (nnheader-narrow-to-headers)
8980 (unless (setq ref (message-fetch-field "references"))
8981 (when (setq ref (message-fetch-field "in-reply-to"))
8982 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8985 ;; It's not the current article, so we take a bet on
8986 ;; the value we got from the server.
8987 (mail-header-references header)))
8989 (not (equal ref "")))
8990 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8991 (gnus-message 1 "Couldn't find parent"))
8992 (gnus-message 1 "No references in article %d"
8993 (gnus-summary-article-number))
8996 (gnus-summary-position-point)
8999 (defun gnus-summary-refer-references ()
9000 "Fetch all articles mentioned in the References header.
9001 Return the number of articles fetched."
9003 (let ((ref (mail-header-references (gnus-summary-article-header)))
9004 (current (gnus-summary-article-number))
9008 (error "No References in the current article")
9009 ;; For each Message-ID in the References header...
9010 (while (string-match "<[^>]*>" ref)
9012 ;; ... fetch that article.
9013 (gnus-summary-refer-article
9014 (prog1 (match-string 0 ref)
9015 (setq ref (substring ref (match-end 0))))))
9016 (gnus-summary-goto-subject current)
9017 (gnus-summary-position-point)
9020 (defun gnus-delete-duplicate-headers (headers)
9021 ;; First remove leading duplicates.
9022 (while (and (> (length headers) 1)
9023 (= (mail-header-number (car headers))
9024 (mail-header-number (cadr headers))))
9027 (let ((result headers))
9028 (while (> (length headers) 1)
9029 (if (= (mail-header-number (car headers))
9030 (mail-header-number (cadr headers)))
9031 (setcdr headers (cddr headers))
9035 (defun gnus-summary-refer-thread (&optional limit)
9036 "Fetch all articles in the current thread. For backends that
9037 know how to search for threads (currently only 'nnimap) a
9038 non-numeric prefix arg will use nnir to search the entire
9039 server; without a prefix arg only the current group is
9040 searched. If the variable `gnus-refer-thread-use-nnir' is
9041 non-nil the prefix arg has the reverse meaning. If no
9042 backend-specific 'request-thread function is available fetch
9043 LIMIT (the numerical prefix) old headers. If LIMIT is
9044 non-numeric or nil fetch the number specified by the
9045 `gnus-refer-thread-limit' variable."
9047 (gnus-warp-to-article)
9048 (let* ((header (gnus-summary-article-header))
9049 (id (mail-header-id header))
9050 (gnus-inhibit-demon t)
9051 (gnus-summary-ignore-duplicates t)
9052 (gnus-read-all-available-headers t)
9053 (gnus-refer-thread-use-nnir
9054 (if (and (not (null limit)) (listp limit))
9055 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9057 (if (gnus-check-backend-function
9058 'request-thread gnus-newsgroup-name)
9059 (gnus-request-thread header gnus-newsgroup-name)
9060 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9061 gnus-refer-thread-limit))
9062 (last (if (numberp limit)
9063 (min (+ (mail-header-number header)
9065 gnus-newsgroup-highest)
9066 gnus-newsgroup-highest))
9067 (subject (gnus-simplify-subject
9068 (mail-header-subject header)))
9069 (refs (split-string (or (mail-header-references header)
9071 (gnus-parse-headers-hook
9072 `(lambda () (goto-char (point-min))
9074 (regexp-opt ',(append refs (list id subject)))))))
9075 (gnus-fetch-headers (list last) (if (numberp limit)
9076 (* 2 limit) limit) t))))
9077 article-ids new-unreads)
9078 (when (listp new-headers)
9079 (dolist (header new-headers)
9080 (push (mail-header-number header) article-ids))
9081 (setq article-ids (nreverse article-ids))
9083 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9084 (setq gnus-newsgroup-unselected
9085 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9086 (setq gnus-newsgroup-unreads
9087 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9088 (setq gnus-newsgroup-headers
9089 (gnus-delete-duplicate-headers
9091 'list gnus-newsgroup-headers new-headers
9092 'gnus-article-sort-by-number)))
9093 (setq gnus-newsgroup-articles
9094 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9095 (gnus-summary-limit-include-thread id)))
9096 (gnus-summary-show-thread))
9098 (defun gnus-summary-open-group-with-article (message-id)
9099 "Open a group containing the article with the given MESSAGE-ID."
9100 (interactive "sMessage-ID: ")
9103 ;; Prepare a dummy article
9105 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9107 ;; Prepare pretty modelines for summary and article buffers
9108 (let ((gnus-summary-mode-line-format "Found %G")
9109 (gnus-article-mode-line-format
9110 ;; Group names just get in the way here, especially the
9112 (if (string-match "%[gG]" gnus-article-mode-line-format)
9113 (concat (substring gnus-article-mode-line-format
9114 0 (match-beginning 0))
9115 (substring gnus-article-mode-line-format (match-end 0)))
9116 gnus-article-mode-line-format)))
9118 ;; Build an ephemeral group containing the dummy article (hidden)
9119 (gnus-group-read-ephemeral-group
9122 (nndoc-address ,(current-buffer))
9123 (nndoc-article-type mbox))
9125 (cons (current-buffer) gnus-current-window-configuration)
9127 '(-1) ; :select-articles
9130 ;; Fetch the desired article
9131 (gnus-summary-refer-article message-id)))
9133 (defun gnus-summary-refer-article (message-id)
9134 "Fetch an article specified by MESSAGE-ID."
9135 (interactive "sMessage-ID: ")
9136 (gnus-warp-to-article)
9137 (when (and (stringp message-id)
9138 (not (zerop (length message-id))))
9139 (setq message-id (gnus-replace-in-string message-id " " ""))
9140 ;; Construct the correct Message-ID if necessary.
9141 ;; Suggested by tale@pawl.rpi.edu.
9142 (unless (string-match "^<" message-id)
9143 (setq message-id (concat "<" message-id)))
9144 (unless (string-match ">$" message-id)
9145 (setq message-id (concat message-id ">")))
9146 ;; People often post MIDs from URLs, so unhex it:
9147 (unless (string-match "@" message-id)
9148 (setq message-id (gnus-url-unhex-string message-id)))
9149 (let* ((header (gnus-id-to-header message-id))
9151 (gnus-summary-article-sparse-p
9152 (mail-header-number header))
9153 (memq (mail-header-number header)
9154 gnus-newsgroup-limit)))
9157 ;; If the article is present in the buffer we just go to it.
9159 (or (not (gnus-summary-article-sparse-p
9160 (mail-header-number header)))
9163 (gnus-summary-goto-article
9164 (mail-header-number header) nil t)
9166 (gnus-summary-update-article (mail-header-number header)))))
9168 ;; We fetch the article.
9170 (dolist (gnus-override-method (gnus-refer-article-methods))
9171 (when (and (gnus-check-server gnus-override-method)
9172 ;; Fetch the header,
9173 (setq number (gnus-summary-insert-subject message-id)))
9174 ;; and display the article.
9175 (gnus-summary-select-article nil nil nil number)
9177 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9179 (defun gnus-refer-article-methods ()
9180 "Return a list of referable methods."
9182 ;; No method, so we default to current and native.
9183 ((null gnus-refer-article-method)
9184 (list gnus-current-select-method gnus-select-method))
9186 ((eq 'current gnus-refer-article-method)
9187 (list gnus-current-select-method))
9188 ;; List of select methods.
9189 ((not (and (symbolp (car gnus-refer-article-method))
9190 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9192 (dolist (method gnus-refer-article-method)
9193 (push (if (eq 'current method)
9194 gnus-current-select-method
9195 (if (eq 'nnir (car method))
9199 (gnus-method-to-server gnus-current-select-method)))
9203 ;; One single select method.
9205 (list gnus-refer-article-method))))
9207 (defun gnus-summary-edit-parameters ()
9208 "Edit the group parameters of the current group."
9210 (gnus-group-edit-group gnus-newsgroup-name 'params))
9212 (defun gnus-summary-customize-parameters ()
9213 "Customize the group parameters of the current group."
9215 (gnus-group-customize gnus-newsgroup-name))
9217 (defun gnus-summary-enter-digest-group (&optional force)
9218 "Enter an nndoc group based on the current article.
9219 If FORCE, force a digest interpretation. If not, try to guess
9220 what the document format is.
9222 To control what happens when you exit the group, see the
9223 `gnus-auto-select-on-ephemeral-exit' variable."
9225 (let ((conf gnus-current-window-configuration))
9226 (save-window-excursion
9228 (let (gnus-article-prepare-hook
9229 gnus-display-mime-function
9231 (gnus-summary-select-article))))
9232 (setq gnus-current-window-configuration conf)
9233 (let* ((name (format "%s-%d"
9234 (gnus-group-prefixed-name
9235 gnus-newsgroup-name (list 'nndoc ""))
9236 (with-current-buffer gnus-summary-buffer
9237 gnus-current-article)))
9238 (ogroup gnus-newsgroup-name)
9239 (params (append (gnus-info-params (gnus-get-info ogroup))
9240 (list (cons 'to-group ogroup))
9241 (list (cons 'parent-group ogroup))
9242 (list (cons 'save-article-group ogroup))))
9243 (case-fold-search t)
9244 (buf (current-buffer))
9245 dig to-address charset)
9246 (with-current-buffer gnus-original-article-buffer
9247 ;; Have the digest group inherit the main mail address of
9248 ;; the parent article.
9249 (when (setq to-address (or (gnus-fetch-field "reply-to")
9250 (gnus-fetch-field "from")))
9254 (list (cons 'to-address
9255 (funcall gnus-decode-encoded-address-function
9257 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9258 (insert-buffer-substring gnus-original-article-buffer)
9260 (goto-char (point-min))
9261 (or (search-forward "\n\n" nil t) (point)))
9262 ;; Remove lines that may lead nndoc to misinterpret the
9264 (goto-char (point-min))
9265 (delete-matching-lines "^Path:\\|^From ")
9266 ;; Parse charset, and decode content transfer encoding.
9267 (setq charset (mail-content-type-get
9268 (mail-header-parse-content-type
9269 (or (gnus-fetch-field "content-type") ""))
9271 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9273 (message-remove-header "content-transfer-encoding")
9274 (goto-char (point-max))
9276 (narrow-to-region (point) (point-max))
9277 (mm-decode-content-transfer-encoding
9278 (intern (downcase (mail-header-strip encoding))))))
9281 (if (let ((gnus-newsgroup-ephemeral-charset
9283 (intern (downcase (gnus-strip-whitespace charset)))
9284 gnus-newsgroup-charset))
9285 (gnus-newsgroup-ephemeral-ignored-charsets
9286 gnus-newsgroup-ignored-charsets))
9287 (gnus-group-read-ephemeral-group
9288 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9290 ,(if force 'mbox 'guess)))
9292 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9294 ;; Make all postings to this group go to the parent group.
9295 (nconc (gnus-info-params (gnus-get-info name))
9297 ;; Couldn't select this doc group.
9298 (switch-to-buffer buf)
9299 (gnus-set-global-variables)
9300 (gnus-configure-windows 'summary)
9301 (gnus-message 3 "Article couldn't be entered?"))
9302 (kill-buffer dig)))))
9304 (defun gnus-summary-read-document (n)
9305 "Open a new group based on the current article(s).
9306 This will allow you to read digests and other similar
9307 documents as newsgroups.
9308 Obeys the standard process/prefix convention."
9310 (let* ((ogroup gnus-newsgroup-name)
9311 (params (append (gnus-info-params (gnus-get-info ogroup))
9312 (list (cons 'to-group ogroup))))
9313 group egroup groups vgroup)
9314 (dolist (article (gnus-summary-work-articles n))
9315 (setq group (format "%s-%d" gnus-newsgroup-name article))
9316 (gnus-summary-remove-process-mark article)
9317 (when (gnus-summary-display-article article)
9318 (save-excursion ;;What for?
9320 (insert-buffer-substring gnus-original-article-buffer)
9321 ;; Remove some headers that may lead nndoc to make
9323 (message-narrow-to-head)
9324 (goto-char (point-min))
9325 (delete-matching-lines "^Path:\\|^From ")
9328 (gnus-group-read-ephemeral-group
9329 group `(nndoc ,group (nndoc-address ,(current-buffer))
9330 (nndoc-article-type guess))
9333 ;; Make all postings to this group go to the parent group.
9334 (nconc (gnus-info-params (gnus-get-info egroup))
9336 (push egroup groups))
9337 ;; Couldn't select this doc group.
9338 (gnus-error 3 "Article couldn't be entered"))))))
9339 ;; Now we have selected all the documents.
9342 (error "None of the articles could be interpreted as documents"))
9343 ((gnus-group-read-ephemeral-group
9344 (setq vgroup (format
9345 "nnvirtual:%s-%s" gnus-newsgroup-name
9346 (format-time-string "%Y%m%dT%H%M%S")))
9347 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9349 (cons (current-buffer) 'summary)))
9351 (error "Couldn't select virtual nndoc group")))))
9353 (defun gnus-summary-widget-forward (arg)
9354 "Move point to the next field or button in the article.
9355 With optional ARG, move across that many fields."
9357 (gnus-summary-select-article)
9358 (gnus-configure-windows 'article)
9359 (select-window (gnus-get-buffer-window gnus-article-buffer))
9360 (widget-forward arg))
9362 (defun gnus-summary-widget-backward (arg)
9363 "Move point to the previous field or button in the article.
9364 With optional ARG, move across that many fields."
9366 (gnus-summary-select-article)
9367 (gnus-configure-windows 'article)
9368 (select-window (gnus-get-buffer-window gnus-article-buffer))
9369 (unless (widget-at (point))
9370 (goto-char (point-max)))
9371 (widget-backward arg))
9373 (defun gnus-summary-isearch-article (&optional regexp-p)
9374 "Do incremental search forward on the current article.
9375 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9377 (gnus-summary-select-article)
9378 (gnus-configure-windows 'article)
9379 (gnus-eval-in-buffer-window gnus-article-buffer
9382 (isearch-forward regexp-p))))
9384 (defun gnus-summary-repeat-search-article-forward ()
9385 "Repeat the previous search forwards."
9387 (unless gnus-last-search-regexp
9388 (error "No previous search"))
9389 (gnus-summary-search-article-forward gnus-last-search-regexp))
9391 (defun gnus-summary-repeat-search-article-backward ()
9392 "Repeat the previous search backwards."
9394 (unless gnus-last-search-regexp
9395 (error "No previous search"))
9396 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9398 (defun gnus-summary-search-article-forward (regexp &optional backward)
9399 "Search for an article containing REGEXP forward.
9400 If BACKWARD, search backward instead."
9403 (format "Search article %s (regexp%s): "
9404 (if current-prefix-arg "backward" "forward")
9405 (if gnus-last-search-regexp
9406 (concat ", default " gnus-last-search-regexp)
9408 current-prefix-arg))
9409 (if (string-equal regexp "")
9410 (setq regexp (or gnus-last-search-regexp ""))
9411 (setq gnus-last-search-regexp regexp)
9412 (setq gnus-article-before-search gnus-current-article))
9413 ;; Intentionally set gnus-last-article.
9414 (setq gnus-last-article gnus-article-before-search)
9415 (let ((gnus-last-article gnus-last-article))
9416 (if (gnus-summary-search-article regexp backward)
9417 (gnus-summary-show-thread)
9418 (signal 'search-failed (list regexp)))))
9420 (defun gnus-summary-search-article-backward (regexp)
9421 "Search for an article containing REGEXP backward."
9424 (format "Search article backward (regexp%s): "
9425 (if gnus-last-search-regexp
9426 (concat ", default " gnus-last-search-regexp)
9428 (gnus-summary-search-article-forward regexp 'backward))
9430 (defun gnus-summary-search-article (regexp &optional backward)
9431 "Search for an article containing REGEXP.
9432 Optional argument BACKWARD means do search for backward.
9433 `gnus-select-article-hook' is not called during the search."
9434 ;; We have to require this here to make sure that the following
9435 ;; dynamic binding isn't shadowed by autoloading.
9436 (require 'gnus-async)
9438 (let ((gnus-select-article-hook nil) ;Disable hook.
9439 (gnus-article-prepare-hook nil)
9440 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9441 (gnus-use-article-prefetch nil)
9442 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9443 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9445 (gnus-keep-backlog nil)
9446 (gnus-break-pages nil)
9447 (gnus-summary-display-arrow nil)
9448 (gnus-updated-mode-lines nil)
9449 (gnus-auto-center-summary nil)
9450 (sum (current-buffer))
9451 (gnus-display-mime-function nil)
9454 (gnus-save-hidden-threads
9455 (gnus-summary-select-article)
9456 (set-buffer gnus-article-buffer)
9457 (goto-char (window-point (get-buffer-window (current-buffer))))
9461 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9463 (re-search-backward regexp nil t)
9464 (re-search-forward regexp nil t))
9465 ;; We found the regexp.
9470 (get-buffer-window (current-buffer))
9474 (get-buffer-window (current-buffer))
9477 (setq point (point)))
9478 ;; We didn't find it, so we go to the next article.
9481 (while (eq found 'not)
9482 (if (not (if backward (gnus-summary-find-prev)
9483 (gnus-summary-find-next)))
9484 ;; No more articles.
9486 ;; Select the next article and adjust point.
9487 (unless (gnus-summary-article-sparse-p
9488 (gnus-summary-article-number))
9490 (gnus-summary-select-article)
9491 (set-buffer gnus-article-buffer)
9493 (goto-char (if backward (point-max) (point-min))))))))
9494 (gnus-message 7 ""))
9495 ;; Return whether we found the regexp.
9496 (when (eq found 'found)
9498 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9499 (gnus-summary-show-thread)
9500 (gnus-summary-goto-subject gnus-current-article)
9501 (gnus-summary-position-point)
9504 (defun gnus-find-matching-articles (header regexp)
9505 "Return a list of all articles that match REGEXP on HEADER.
9506 This search includes all articles in the current group that Gnus has
9507 fetched headers for, whether they are displayed or not."
9508 (let ((articles nil)
9509 ;; Can't eta-reduce because it's a macro.
9510 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9511 (case-fold-search t))
9512 (dolist (header gnus-newsgroup-headers)
9513 (when (string-match regexp (funcall func header))
9514 (push (mail-header-number header) articles)))
9515 (nreverse articles)))
9517 (defun gnus-summary-find-matching (header regexp &optional backward unread
9518 not-case-fold not-matching)
9519 "Return a list of all articles that match REGEXP on HEADER.
9520 The search stars on the current article and goes forwards unless
9521 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9522 If UNREAD is non-nil, only unread articles will
9523 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9524 in the comparisons. If NOT-MATCHING, return a list of all articles that
9525 not match REGEXP on HEADER."
9526 (let ((case-fold-search (not not-case-fold))
9529 (if (eq (car header) 'extra)
9532 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9534 (error "%s is an invalid header" header))
9535 (unless (fboundp (intern (concat "mail-header-" header)))
9536 (error "%s is not a valid header" header))
9537 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9538 (dolist (d (if (eq backward 'all)
9540 (gnus-data-find-list
9541 (gnus-summary-article-number)
9542 (gnus-data-list backward))))
9543 (when (and (or (not unread) ; We want all articles...
9544 (gnus-data-unread-p d)) ; Or just unreads.
9545 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9549 (funcall func (gnus-data-header d))))
9550 (string-match regexp
9551 (funcall func (gnus-data-header d)))))
9552 (push (gnus-data-number d) articles))) ; Success!
9553 (nreverse articles)))
9555 (defun gnus-summary-execute-command (header regexp command &optional backward)
9556 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9557 If HEADER is an empty string (or nil), the match is done on the entire
9558 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9560 (list (let ((completion-ignore-case t))
9561 (gnus-completing-read
9563 (mapcar 'symbol-name
9565 '(Number Subject From Lines Date
9566 Message-ID Xref References Body)
9567 gnus-extra-headers))
9569 (read-string "Regexp: ")
9570 (read-key-sequence "Command: ")
9571 current-prefix-arg))
9572 (when (equal header "Body")
9574 ;; Hidden thread subtrees must be searched as well.
9575 (gnus-summary-show-all-threads)
9576 ;; We don't want to change current point nor window configuration.
9578 (save-window-excursion
9580 gnus-treat-strip-trailing-blank-lines
9581 gnus-treat-strip-leading-blank-lines
9582 gnus-treat-strip-multiple-blank-lines
9583 gnus-treat-hide-boring-headers
9584 gnus-treat-fold-newsgroups
9585 gnus-article-prepare-hook)
9586 (gnus-message 6 "Executing %s..." (key-description command))
9587 ;; We'd like to execute COMMAND interactively so as to give arguments.
9588 (gnus-execute header regexp
9589 `(call-interactively ',(key-binding command))
9591 (gnus-message 6 "Executing %s...done" (key-description command))))))
9593 (defun gnus-summary-beginning-of-article ()
9594 "Scroll the article back to the beginning."
9596 (gnus-summary-select-article)
9597 (gnus-configure-windows 'article)
9598 (gnus-eval-in-buffer-window gnus-article-buffer
9600 (goto-char (point-min))
9601 (when gnus-break-pages
9602 (gnus-narrow-to-page))))
9604 (defun gnus-summary-end-of-article ()
9605 "Scroll to the end of the article."
9607 (gnus-summary-select-article)
9608 (gnus-configure-windows 'article)
9609 (gnus-eval-in-buffer-window gnus-article-buffer
9611 (goto-char (point-max))
9613 (when gnus-break-pages
9614 (gnus-narrow-to-page))))
9616 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9617 "Truncate to LEN and quote all \"(\"'s in STRING."
9618 (gnus-replace-in-string (if (and len (> (length string) len))
9619 (substring string 0 len)
9623 (defun gnus-summary-print-article (&optional filename n)
9624 "Generate and print a PostScript image of the process-marked (mail) articles.
9626 If used interactively, print the current article if none are
9627 process-marked. With prefix arg, prompt the user for the name of the
9630 When used from Lisp, accept two optional args FILENAME and N. N means
9631 to print the next N articles. If N is negative, print the N previous
9632 articles. If N is nil and articles have been marked with the process
9633 mark, print these instead.
9635 If the optional first argument FILENAME is nil, send the image to the
9636 printer. If FILENAME is a string, save the PostScript image in a file with
9637 that name. If FILENAME is a number, prompt the user for the name of the file
9639 (interactive (list (ps-print-preprint current-prefix-arg)))
9640 (dolist (article (gnus-summary-work-articles n))
9641 (gnus-summary-select-article nil nil 'pseudo article)
9642 (gnus-eval-in-buffer-window gnus-article-buffer
9643 (gnus-print-buffer))
9644 (gnus-summary-remove-process-mark article))
9645 (ps-despool filename))
9647 (defun gnus-print-buffer ()
9648 (let ((ps-left-header
9651 (gnus-summary-print-truncate-and-quote
9652 (mail-header-subject gnus-current-headers)
9655 (gnus-summary-print-truncate-and-quote
9656 (mail-header-from gnus-current-headers)
9660 "/pagenumberstring load"
9662 (mail-header-date gnus-current-headers) ")"))))
9663 (gnus-run-hooks 'gnus-ps-print-hook)
9665 (if ps-print-color-p
9666 (ps-spool-buffer-with-faces)
9667 (ps-spool-buffer)))))
9669 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9671 (defun gnus-summary-show-complete-article ()
9672 "Show a complete version of the current article.
9673 This is only useful if you're looking at a partial version of the
9676 (let ((gnus-keep-backlog nil)
9677 (gnus-use-cache nil)
9680 (format "%s-fetch-partial-articles"
9681 (car (gnus-find-method-for-group
9682 gnus-newsgroup-name)))
9687 (setq old-val (symbol-value variable))
9689 (gnus-flush-original-article-buffer)
9690 (gnus-summary-show-article))
9691 (set variable old-val))))
9693 (defun gnus-summary-show-article (&optional arg)
9694 "Force redisplaying of the current article.
9695 If ARG (the prefix) is a number, show the article with the charset
9696 defined in `gnus-summary-show-article-charset-alist', or the charset
9698 If ARG (the prefix) is non-nil and not a number, show the article,
9699 but without running any of the article treatment functions
9700 article. Normally, the keystroke is `C-u g'. When using `C-u
9701 C-u g', show the raw article."
9705 (gnus-summary-show-article t)
9706 (let ((gnus-newsgroup-charset
9707 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9708 (mm-read-coding-system
9709 "View as charset: " ;; actually it is coding system.
9710 (with-current-buffer gnus-article-buffer
9711 (mm-detect-coding-region (point) (point-max))))))
9712 (gnus-newsgroup-ignored-charsets 'gnus-all))
9713 (gnus-summary-select-article nil 'force)
9714 (let ((deps gnus-newsgroup-dependencies)
9716 (with-current-buffer gnus-original-article-buffer
9718 (message-narrow-to-head)
9719 (setq head (buffer-string))
9720 (goto-char (point-min))
9721 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9722 (goto-char (point-max))
9724 (setq lines (1- (count-lines (point) (point-max))))))
9726 (insert (format "211 %d Article retrieved.\n"
9727 (cdr gnus-article-current)))
9729 (if lines (insert (format "Lines: %d\n" lines)))
9731 (let ((nntp-server-buffer (current-buffer)))
9732 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9733 (gnus-data-set-header
9734 (gnus-data-find (cdr gnus-article-current))
9736 (gnus-summary-update-article-line
9737 (cdr gnus-article-current) header)
9738 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9739 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9741 ;; Select the article the normal way.
9742 (if (eq mm-text-html-renderer 'shr)
9745 (let ((shr-ignore-cache t))
9746 (gnus-summary-select-article nil 'force)))
9747 (gnus-summary-select-article nil 'force)))
9750 (let ((gnus-inhibit-article-treatments t))
9751 (gnus-summary-select-article nil 'force)))
9753 ;; We have to require this here to make sure that the following
9754 ;; dynamic binding isn't shadowed by autoloading.
9755 (require 'gnus-async)
9757 ;; Bind the article treatment functions to nil.
9758 (let ((gnus-have-all-headers t)
9759 gnus-article-prepare-hook
9760 gnus-article-decode-hook
9761 gnus-display-mime-function
9763 ;; Destroy any MIME parts.
9764 (when (gnus-buffer-live-p gnus-article-buffer)
9765 (with-current-buffer gnus-article-buffer
9766 (gnus-article-stop-animations)
9767 (gnus-stop-downloads)
9768 (mm-destroy-parts gnus-article-mime-handles)
9769 ;; Set it to nil for safety reason.
9770 (setq gnus-article-mime-handle-alist nil)
9771 (setq gnus-article-mime-handles nil)))
9772 (gnus-summary-select-article nil 'force))))
9773 (gnus-summary-goto-subject gnus-current-article)
9774 (gnus-summary-position-point))
9776 (defun gnus-summary-show-raw-article ()
9777 "Show the raw article without any article massaging functions being run."
9779 (gnus-summary-show-article t))
9781 (defun gnus-summary-verbose-headers (&optional arg)
9782 "Toggle permanent full header display.
9783 If ARG is a positive number, turn header display on.
9784 If ARG is a negative number, turn header display off."
9786 (setq gnus-show-all-headers
9787 (cond ((or (not (numberp arg))
9789 (not gnus-show-all-headers))
9792 (gnus-summary-show-article))
9794 (declare-function article-narrow-to-head "gnus-art" ())
9795 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9796 (declare-function gnus-delete-wash-type "gnus-art" (type))
9797 (declare-function gnus-mime-buttonize-attachments-in-header
9798 "gnus-art" (&optional interactive))
9800 (defun gnus-summary-toggle-header (&optional arg)
9801 "Show the headers if they are hidden, or hide them if they are shown.
9802 If ARG is a positive number, show the entire header.
9803 If ARG is a negative number, hide the unwanted header lines."
9805 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9806 (get-buffer-window gnus-article-buffer t))))
9807 (with-current-buffer gnus-article-buffer
9809 (article-narrow-to-head)
9810 (let* ((inhibit-read-only t)
9811 (inhibit-point-motion-hooks t)
9812 (hidden (if (numberp arg)
9814 (or (not (looking-at "[^ \t\n]+:"))
9815 (gnus-article-hidden-text-p 'headers))))
9817 (delete-region (point-min) (point-max))
9818 (with-current-buffer gnus-original-article-buffer
9819 (goto-char (setq s (point-min)))
9820 (setq e (if (search-forward "\n\n" nil t)
9823 (insert-buffer-substring gnus-original-article-buffer s e)
9824 (run-hooks 'gnus-article-decode-hook)
9826 (let ((gnus-treat-hide-headers nil)
9827 (gnus-treat-hide-boring-headers nil))
9828 (gnus-delete-wash-type 'headers)
9829 (gnus-treat-article 'head))
9830 (gnus-treat-article 'head)
9831 ;; Add attachment buttons to the header.
9832 (when gnus-mime-display-attachment-buttons-in-header
9833 (gnus-mime-buttonize-attachments-in-header)))
9836 (set-window-start window (goto-char (point-min))))
9837 (if gnus-break-pages
9838 (gnus-narrow-to-page)
9839 (when (gnus-visual-p 'page-marker)
9840 (let ((inhibit-read-only t))
9841 (gnus-remove-text-with-property 'gnus-prev)
9842 (gnus-remove-text-with-property 'gnus-next))))
9843 (gnus-set-mode-line 'article)))))
9845 (defun gnus-summary-show-all-headers ()
9846 "Make all header lines visible."
9848 (gnus-summary-toggle-header 1))
9850 (defun gnus-summary-caesar-message (&optional arg)
9851 "Caesar rotate the current article by 13.
9852 With a non-numerical prefix, also rotate headers. A numerical
9853 prefix specifies how many places to rotate each letter forward."
9855 (gnus-summary-select-article)
9856 (let ((mail-header-separator ""))
9857 (gnus-eval-in-buffer-window gnus-article-buffer
9860 (let ((start (window-start))
9861 (inhibit-read-only t))
9862 (if (equal arg '(4))
9863 (message-caesar-buffer-body nil t)
9864 (message-caesar-buffer-body arg))
9865 (set-window-start (get-buffer-window (current-buffer)) start)))))
9866 ;; Create buttons and stuff...
9867 (gnus-treat-article nil))
9869 (declare-function idna-to-unicode "ext:idna" (str))
9871 (defun gnus-summary-idna-message (&optional arg)
9872 "Decode IDNA encoded domain names in the current articles.
9873 IDNA encoded domain names looks like `xn--bar'. If a string
9874 remain unencoded after running this function, it is likely an
9875 invalid IDNA string (`xn--bar' is invalid).
9877 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9878 installed for this command to work."
9880 (if (not (and (mm-coding-system-p 'utf-8)
9884 (invalid-operation))
9885 (symbol-value 'idna-program)
9886 (executable-find (symbol-value 'idna-program))))
9888 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9889 (gnus-summary-select-article)
9890 (let ((mail-header-separator ""))
9891 (gnus-eval-in-buffer-window gnus-article-buffer
9894 (let ((start (window-start))
9896 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9897 (replace-match (idna-to-unicode (match-string 1))))
9898 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9900 (defun gnus-summary-morse-message (&optional arg)
9901 "Morse decode the current article."
9903 (gnus-summary-select-article)
9904 (let ((mail-header-separator ""))
9905 (gnus-eval-in-buffer-window gnus-article-buffer
9909 (let ((pos (window-start))
9910 (inhibit-read-only t))
9911 (goto-char (point-min))
9912 (when (message-goto-body)
9913 (gnus-narrow-to-body))
9914 (goto-char (point-min))
9915 (while (search-forward "·" (point-max) t)
9916 (replace-match "."))
9917 (unmorse-region (point-min) (point-max))
9919 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9921 (defun gnus-summary-stop-page-breaking ()
9922 "Stop page breaking in the current article."
9924 (gnus-summary-select-article)
9925 (gnus-eval-in-buffer-window gnus-article-buffer
9927 (when (gnus-visual-p 'page-marker)
9928 (let ((inhibit-read-only t))
9929 (gnus-remove-text-with-property 'gnus-prev)
9930 (gnus-remove-text-with-property 'gnus-next))
9931 (setq gnus-page-broken nil))))
9933 (defun gnus-summary-move-article (&optional n to-newsgroup
9934 select-method action)
9935 "Move the current article to a different newsgroup.
9936 If N is a positive number, move the N next articles.
9937 If N is a negative number, move the N previous articles.
9938 If N is nil and any articles have been marked with the process mark,
9939 move those articles instead.
9940 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9941 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9942 re-spool using this method.
9944 When called interactively with TO-NEWSGROUP being nil, the value of
9945 the variable `gnus-move-split-methods' is used for finding a default
9946 for the target newsgroup.
9948 For this function to work, both the current newsgroup and the
9949 newsgroup that you want to move to have to support the `request-move'
9950 and `request-accept' functions.
9952 ACTION can be either `move' (the default), `crosspost' or `copy'."
9955 (setq action 'move))
9956 ;; Check whether the source group supports the required functions.
9957 (cond ((and (eq action 'move)
9958 (not (gnus-check-backend-function
9959 'request-move-article gnus-newsgroup-name)))
9960 (error "The current group does not support article moving"))
9961 ((and (eq action 'crosspost)
9962 (not (gnus-check-backend-function
9963 'request-replace-article gnus-newsgroup-name)))
9964 (error "The current group does not support article editing")))
9965 (let ((articles (gnus-summary-work-articles n))
9966 (prefix (if (gnus-check-backend-function
9967 'request-move-article gnus-newsgroup-name)
9968 (funcall gnus-move-group-prefix-function
9969 gnus-newsgroup-name)
9971 (names '((move "Move" "Moving")
9972 (copy "Copy" "Copying")
9973 (crosspost "Crosspost" "Crossposting")))
9974 (copy-buf (save-excursion
9975 (nnheader-set-temp-buffer " *copy article*")))
9976 art-group to-method new-xref article to-groups
9977 articles-to-update-marks encoded)
9978 (unless (assq action names)
9979 (error "Unknown action %s" action))
9980 ;; Read the newsgroup name.
9981 (when (and (not to-newsgroup)
9982 (not select-method))
9983 (if (and gnus-move-split-methods
9985 (and (memq gnus-current-article articles)
9986 (gnus-buffer-live-p gnus-original-article-buffer))))
9987 ;; When `gnus-move-split-methods' is non-nil, we have to
9988 ;; select an article to give `gnus-read-move-group-name' an
9989 ;; opportunity to suggest an appropriate default. However,
9990 ;; we needn't render or mark the article.
9991 (let ((gnus-display-mime-function nil)
9992 (gnus-article-prepare-hook nil)
9993 (gnus-mark-article-hook nil))
9994 (gnus-summary-select-article nil nil nil (car articles))))
9995 (setq to-newsgroup (gnus-read-move-group-name
9996 (cadr (assq action names))
9998 (intern (format "gnus-current-%s-group" action)))
10000 encoded to-newsgroup
10001 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
10002 (set (intern (format "gnus-current-%s-group" action))
10003 (mm-decode-coding-string
10005 (gnus-group-name-charset to-method to-newsgroup))))
10007 (setq to-method (or select-method
10008 (gnus-server-to-method
10009 (gnus-group-method to-newsgroup)))))
10013 (mm-encode-coding-string
10015 (gnus-group-name-charset to-method to-newsgroup)))))
10016 ;; Check the method we are to move this article to...
10017 (unless (gnus-check-backend-function
10018 'request-accept-article (car to-method))
10019 (error "%s does not support article copying" (car to-method)))
10020 (unless (gnus-check-server to-method)
10021 (error "Can't open server %s" (car to-method)))
10022 (gnus-message 6 "%s to %s: %s..."
10023 (caddr (assq action names))
10024 (or (car select-method)
10025 (gnus-group-decoded-name to-newsgroup))
10028 (setq article (pop articles))
10029 ;; Set any marks that may have changed in the summary buffer.
10030 (when gnus-preserve-marks
10031 (gnus-summary-push-marks-to-backend article))
10035 ;; Move the article.
10037 ;; Remove this article from future suppression.
10038 (gnus-dup-unsuppress-article article)
10039 (let* ((from-method (gnus-find-method-for-group
10040 gnus-newsgroup-name))
10041 (to-method (or select-method
10042 (gnus-find-method-for-group to-newsgroup)))
10043 (move-is-internal (gnus-server-equal from-method to-method)))
10044 (gnus-request-move-article
10045 article ; Article to move
10046 gnus-newsgroup-name ; From newsgroup
10047 (nth 1 (gnus-find-method-for-group
10048 gnus-newsgroup-name)) ; Server
10049 (list 'gnus-request-accept-article
10050 to-newsgroup (list 'quote select-method)
10051 (not articles) t) ; Accept form
10052 (not articles) ; Only save nov last time
10053 (and move-is-internal
10054 to-newsgroup ; Not respooling
10055 ; Is this move internal?
10056 (gnus-group-real-name to-newsgroup)))))
10057 ;; Copy the article.
10059 (with-current-buffer copy-buf
10060 (when (gnus-request-article-this-buffer article
10061 gnus-newsgroup-name)
10063 (nnheader-narrow-to-headers)
10064 (dolist (hdr gnus-copy-article-ignored-headers)
10065 (message-remove-header hdr t)))
10066 (gnus-request-accept-article
10067 to-newsgroup select-method (not articles) t))))
10068 ;; Crosspost the article.
10069 ((eq action 'crosspost)
10070 (let ((xref (message-tokenize-header
10071 (mail-header-xref (gnus-summary-article-header
10074 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10075 ":" (number-to-string article)))
10077 (setq xref (list (system-name))))
10080 (mapconcat 'identity
10081 (delete "Xref:" (delete new-xref xref))
10084 (with-current-buffer copy-buf
10085 ;; First put the article in the destination group.
10086 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10087 (when (consp (setq art-group
10088 (gnus-request-accept-article
10089 to-newsgroup select-method (not articles)
10091 (setq new-xref (concat new-xref " " (car art-group)
10093 (number-to-string (cdr art-group))))
10094 ;; Now we have the new Xrefs header, so we insert
10095 ;; it and replace the new article.
10096 (nnheader-replace-header "Xref" new-xref)
10097 (gnus-request-replace-article
10098 (cdr art-group) to-newsgroup (current-buffer) t)
10102 (gnus-message 1 "Couldn't %s article %s: %s"
10103 (cadr (assq action names)) article
10104 (nnheader-get-report (car to-method))))
10105 ((eq art-group 'junk)
10106 (when (eq action 'move)
10107 (gnus-summary-mark-article article gnus-canceled-mark)
10108 (gnus-message 4 "Deleted article %s" article)
10109 ;; run the delete hook
10110 (run-hook-with-args 'gnus-summary-article-delete-hook
10113 (assoc article (gnus-data-list nil)))
10114 gnus-newsgroup-name nil
10117 (let* ((pto-group (gnus-group-prefixed-name
10118 (car art-group) to-method))
10119 (info (gnus-get-info pto-group))
10120 (to-group (gnus-info-group info))
10122 ;; Update the group that has been moved to.
10124 (memq action '(move copy)))
10125 (unless (member to-group to-groups)
10126 (push to-group to-groups))
10128 (when (and (not (memq article gnus-newsgroup-unreads))
10130 (push 'read to-marks)
10131 (gnus-info-set-read
10132 info (gnus-add-to-range (gnus-info-read info)
10133 (list (cdr art-group)))))
10135 ;; See whether the article is to be put in the cache.
10136 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10137 (marks (if expirable
10138 gnus-article-mark-lists
10139 (delete '(expirable . expire)
10141 gnus-article-mark-lists))))
10142 (to-article (cdr art-group)))
10144 ;; Enter the article into the cache in the new group,
10145 ;; if that is required.
10146 (when (and to-article
10148 (gnus-cache-possibly-enter-article
10149 to-group to-article
10150 (memq article gnus-newsgroup-marked)
10151 (memq article gnus-newsgroup-dormant)
10152 (memq article gnus-newsgroup-unreads)))
10154 (when (and gnus-preserve-marks
10156 ;; Copy any marks over to the new group.
10157 (when (and (equal to-group gnus-newsgroup-name)
10158 (not (memq article gnus-newsgroup-unreads)))
10159 ;; Mark this article as read in this group.
10160 (push (cons to-article gnus-read-mark)
10161 gnus-newsgroup-reads)
10162 ;; Increase the active status of this group.
10163 (setcdr (gnus-active to-group) to-article)
10164 (setcdr gnus-newsgroup-active to-article))
10167 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10168 (when (memq article (symbol-value
10169 (intern (format "gnus-newsgroup-%s"
10171 (push (cdar marks) to-marks)
10172 ;; If the other group is the same as this group,
10173 ;; then we have to add the mark to the list.
10174 (when (equal to-group gnus-newsgroup-name)
10175 (set (intern (format "gnus-newsgroup-%s"
10179 (intern (format "gnus-newsgroup-%s"
10181 ;; Copy the marks to other group.
10182 (gnus-add-marked-articles
10183 to-group (cdar marks) (list to-article) info)))
10184 (setq marks (cdr marks)))
10186 (when (and expirable
10187 gnus-mark-copied-or-moved-articles-as-expirable
10188 (not (memq 'expire to-marks)))
10189 ;; Mark this article as expirable.
10190 (push 'expire to-marks)
10191 (when (equal to-group gnus-newsgroup-name)
10192 (push to-article gnus-newsgroup-expirable))
10193 ;; Copy the expirable mark to other group.
10194 (gnus-add-marked-articles
10195 to-group 'expire (list to-article) info))
10197 (when (and to-marks
10198 (gnus-method-option-p
10199 (gnus-find-method-for-group to-group)
10201 (gnus-request-set-mark
10202 to-group (list (list (list to-article) 'add to-marks)))))
10204 (gnus-dribble-enter
10205 (concat "(gnus-group-set-info '"
10206 (gnus-prin1-to-string (gnus-get-info to-group))
10208 (concat "^(gnus-group-set-info '(\""
10209 (regexp-quote to-group) "\""))))
10211 ;; Update the Xref header in this article to point to
10212 ;; the new crossposted article we have just created.
10213 (when (eq action 'crosspost)
10214 (with-current-buffer copy-buf
10215 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10216 (nnheader-replace-header "Xref" new-xref)
10217 (gnus-request-replace-article
10218 article gnus-newsgroup-name (current-buffer) t)))
10220 ;; run the move/copy/crosspost/respool hook
10221 (run-hook-with-args 'gnus-summary-article-move-hook
10224 (assoc article (gnus-data-list nil)))
10225 gnus-newsgroup-name
10229 ;;;!!!Why is this necessary?
10230 (set-buffer gnus-summary-buffer)
10232 (when (eq action 'move)
10234 (gnus-summary-goto-subject article)
10235 (gnus-summary-mark-article article gnus-canceled-mark)))))
10236 (push article articles-to-update-marks))
10239 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10240 ;; Re-activate all groups that have been moved to.
10241 (with-current-buffer gnus-group-buffer
10242 (let ((gnus-group-marked to-groups))
10243 (gnus-group-get-new-news-this-group nil t)))
10245 (gnus-kill-buffer copy-buf)
10246 (gnus-summary-position-point)
10247 (gnus-set-mode-line 'summary)))
10249 (defun gnus-summary-push-marks-to-backend (article)
10252 (marks gnus-article-mark-lists))
10253 (unless (memq article gnus-newsgroup-unreads)
10256 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10257 (memq article (symbol-value
10258 (intern (format "gnus-newsgroup-%s"
10260 (push (cdar marks) set)
10261 (push (cdar marks) del))
10263 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10264 ((,article) del ,del)))))
10266 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10267 "Copy the current article to some other group.
10268 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10269 When called interactively, if TO-NEWSGROUP is nil, use the value of
10270 the variable `gnus-move-split-methods' for finding a default target
10272 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10273 re-spool using this method."
10275 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10277 (defun gnus-summary-crosspost-article (&optional n)
10278 "Crosspost the current article to some other group."
10280 (gnus-summary-move-article n nil nil 'crosspost))
10282 (defcustom gnus-summary-respool-default-method nil
10283 "Default method type for respooling an article.
10284 If nil, use to the current newsgroup method."
10286 :group 'gnus-summary-mail)
10288 (defun gnus-summary-respool-article (&optional n method)
10289 "Respool the current article.
10290 The article will be squeezed through the mail spooling process again,
10291 which means that it will be put in some mail newsgroup or other
10292 depending on `nnmail-split-methods'.
10293 If N is a positive number, respool the N next articles.
10294 If N is a negative number, respool the N previous articles.
10295 If N is nil and any articles have been marked with the process mark,
10296 respool those articles instead.
10298 Respooling can be done both from mail groups and \"real\" newsgroups.
10299 In the former case, the articles in question will be moved from the
10300 current group into whatever groups they are destined to. In the
10301 latter case, they will be copied into the relevant groups."
10303 (list current-prefix-arg
10304 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10306 (symbol-name (or gnus-summary-respool-default-method
10307 (car (gnus-find-method-for-group
10308 gnus-newsgroup-name)))))
10310 (gnus-completing-read
10311 "Backend to use when respooling"
10312 methods t nil 'gnus-mail-method-history methname))
10315 ((zerop (length (setq ms (gnus-servers-using-backend
10316 (intern method)))))
10317 (list (intern method) ""))
10321 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10322 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10325 (error "No method given for respooling"))
10326 (if (assoc (symbol-name
10327 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10328 (gnus-methods-using 'respool))
10329 (gnus-summary-move-article n nil method)
10330 (gnus-summary-copy-article n nil method)))
10332 (defun gnus-summary-import-article (file &optional edit)
10333 "Import an arbitrary file into a mail newsgroup."
10334 (interactive "fImport file: \nP")
10335 (let ((group gnus-newsgroup-name)
10336 (now (current-time))
10337 atts lines group-art)
10338 (unless (gnus-check-backend-function 'request-accept-article group)
10339 (error "%s does not support article importing" group))
10340 (or (file-readable-p file)
10341 (not (file-regular-p file))
10342 (error "Can't read %s" file))
10343 (with-current-buffer (gnus-get-buffer-create " *import file*")
10345 (nnheader-insert-file-contents file)
10346 (goto-char (point-min))
10347 (if (nnheader-article-p)
10349 (goto-char (point-min))
10350 (search-forward "\n\n" nil t)
10351 (narrow-to-region (point-min) (1- (point)))
10352 (goto-char (point-min))
10353 (unless (re-search-forward "^date:" nil t)
10354 (goto-char (point-max))
10355 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10356 ;; This doesn't look like an article, so we fudge some headers.
10357 (setq atts (file-attributes file)
10358 lines (count-lines (point-min) (point-max)))
10359 (insert "From: " (read-string "From: ") "\n"
10360 "Subject: " (read-string "Subject: ") "\n"
10361 "Date: " (message-make-date (nth 5 atts)) "\n"
10362 "Message-ID: " (message-make-message-id) "\n"
10363 "Lines: " (int-to-string lines) "\n"
10364 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10365 (setq group-art (gnus-request-accept-article group nil t))
10366 (kill-buffer (current-buffer)))
10367 (setq gnus-newsgroup-active (gnus-activate-group group))
10369 (gnus-summary-goto-article (cdr group-art) nil t)
10371 (gnus-summary-edit-article))))
10373 (defun gnus-summary-create-article ()
10374 "Create an article in a mail newsgroup."
10376 (let ((group gnus-newsgroup-name)
10377 (now (current-time))
10379 (unless (gnus-check-backend-function 'request-accept-article group)
10380 (error "%s does not support article importing" group))
10381 (with-current-buffer (gnus-get-buffer-create " *import file*")
10383 (goto-char (point-min))
10384 ;; This doesn't look like an article, so we fudge some headers.
10385 (insert "From: " (read-string "From: ") "\n"
10386 "Subject: " (read-string "Subject: ") "\n"
10387 "Date: " (message-make-date now) "\n"
10388 "Message-ID: " (message-make-message-id) "\n")
10389 (setq group-art (gnus-request-accept-article group nil t))
10390 (kill-buffer (current-buffer)))
10391 (setq gnus-newsgroup-active (gnus-activate-group group))
10393 (gnus-summary-goto-article (cdr group-art) nil t)
10394 (gnus-summary-edit-article)))
10396 (defun gnus-summary-article-posted-p ()
10397 "Say whether the current (mail) article is available from news as well.
10398 This will be the case if the article has both been mailed and posted."
10400 (let ((id (mail-header-references (gnus-summary-article-header)))
10401 (gnus-override-method (car (gnus-refer-article-methods))))
10402 (if (gnus-request-head id "")
10403 (gnus-message 2 "The current message was found on %s"
10404 gnus-override-method)
10405 (gnus-message 2 "The current message couldn't be found on %s"
10406 gnus-override-method)
10409 (defun gnus-summary-expire-articles (&optional now)
10410 "Expire all articles that are marked as expirable in the current group."
10412 (when (and (not gnus-group-is-exiting-without-update-p)
10413 (gnus-check-backend-function
10414 'request-expire-articles gnus-newsgroup-name))
10415 ;; This backend supports expiry.
10416 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10418 (gnus-list-range-difference
10421 ;; We need to update the info for
10422 ;; this group for `gnus-list-of-read-articles'
10423 ;; to give us the right answer.
10424 (gnus-run-hooks 'gnus-exit-group-hook)
10425 (gnus-summary-update-info)
10426 (gnus-list-of-read-articles gnus-newsgroup-name))
10427 (setq gnus-newsgroup-expirable
10428 (sort gnus-newsgroup-expirable '<)))
10429 gnus-newsgroup-unexist))
10430 (expiry-wait (if now 'immediate
10431 (gnus-group-find-parameter
10432 gnus-newsgroup-name 'expiry-wait)))
10433 (nnmail-expiry-target
10434 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10435 nnmail-expiry-target))
10438 ;; There are expirable articles in this group, so we run them
10439 ;; through the expiry process.
10440 (gnus-message 6 "Expiring articles...")
10441 (when (gnus-check-group gnus-newsgroup-name)
10442 ;; The list of articles that weren't expired is returned.
10445 (let ((nnmail-expiry-wait-function nil)
10446 (nnmail-expiry-wait expiry-wait))
10447 (setq es (gnus-request-expire-articles
10448 expirable gnus-newsgroup-name)))
10449 (setq es (gnus-request-expire-articles
10450 expirable gnus-newsgroup-name)))
10452 (setq gnus-newsgroup-expirable es))
10453 ;; We go through the old list of expirable, and mark all
10454 ;; really expired articles as nonexistent.
10455 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10456 (let ((gnus-use-cache nil))
10457 (dolist (article expirable)
10458 (when (and (not (memq article es))
10459 (gnus-data-find article))
10460 (gnus-summary-mark-article article gnus-canceled-mark)
10461 (run-hook-with-args
10462 'gnus-summary-article-expire-hook
10464 (gnus-data-header (assoc article (gnus-data-list nil)))
10465 gnus-newsgroup-name
10467 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10468 ((eq nnmail-expiry-target 'delete) nil)
10470 (let ((rescall (funcall nnmail-expiry-target
10471 gnus-newsgroup-name)))
10472 (if (stringp rescall) rescall nil))))
10474 (gnus-message 6 "Expiring articles...done")))))
10476 (defun gnus-summary-expire-articles-now ()
10477 "Expunge all expirable articles in the current group.
10478 This means that *all* articles that are marked as expirable will be
10479 deleted forever, right now."
10481 (or gnus-expert-user
10483 "Are you really, really sure you want to delete all expirable messages? ")
10485 (gnus-summary-expire-articles t))
10487 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10488 (defun gnus-summary-delete-article (&optional n)
10489 "Delete the N next (mail) articles.
10490 This command actually deletes articles. This is not a marking
10491 command. The article will disappear forever from your life, never to
10494 If N is negative, delete backwards.
10495 If N is nil and articles have been marked with the process mark,
10496 delete these instead.
10498 If `gnus-novice-user' is non-nil you will be asked for
10499 confirmation before the articles are deleted."
10501 (unless (gnus-check-backend-function 'request-expire-articles
10502 gnus-newsgroup-name)
10503 (error "The current newsgroup does not support article deletion"))
10504 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10505 (error "Couldn't open server"))
10506 ;; Compute the list of articles to delete.
10507 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10508 (nnmail-expiry-target 'delete)
10510 (if (and gnus-novice-user
10511 (not (gnus-yes-or-no-p
10512 (format "Do you really want to delete %s forever? "
10513 (if (> (length articles) 1)
10514 (format "these %s articles" (length articles))
10515 "this article")))))
10517 ;; Delete the articles.
10518 (setq not-deleted (gnus-request-expire-articles
10519 articles gnus-newsgroup-name 'force))
10522 (gnus-summary-remove-process-mark (car articles))
10523 ;; The backend might not have been able to delete the article
10525 (unless (memq (car articles) not-deleted)
10526 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10527 (let* ((article (car articles))
10528 (ghead (gnus-data-header
10529 (assoc article (gnus-data-list nil)))))
10530 (run-hook-with-args 'gnus-summary-article-delete-hook
10531 'delete ghead gnus-newsgroup-name nil
10533 (setq articles (cdr articles))))
10535 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10536 (gnus-summary-position-point)
10537 (gnus-set-mode-line 'summary)
10540 (defun gnus-summary-edit-article (&optional arg)
10541 "Edit the current article.
10542 This will have permanent effect only in mail groups.
10543 If ARG is nil, edit the decoded articles.
10544 If ARG is 1, edit the raw articles.
10545 If ARG is 2, edit the raw articles even in read-only groups.
10546 If ARG is 3, edit the articles with the current handles.
10547 Otherwise, allow editing of articles even in read-only
10550 (let (force raw current-handles)
10559 (setq current-handles
10560 (and (gnus-buffer-live-p gnus-article-buffer)
10561 (with-current-buffer gnus-article-buffer
10563 gnus-article-mime-handles
10564 (setq gnus-article-mime-handles nil))))))
10567 (when (and raw (not force)
10568 (member gnus-newsgroup-name '("nndraft:delayed"
10571 (error "Can't edit the raw article in group %s"
10572 gnus-newsgroup-name))
10573 (with-current-buffer gnus-summary-buffer
10574 (let ((mail-parse-charset gnus-newsgroup-charset)
10575 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10576 (gnus-set-global-variables)
10577 (when (and (not force)
10578 (gnus-group-read-only-p))
10579 (error "The current newsgroup does not support article editing"))
10580 (gnus-summary-show-article t)
10581 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10582 (with-current-buffer gnus-article-buffer
10583 (mm-enable-multibyte)))
10584 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10586 (gnus-article-edit-article
10589 (let ((mbl mml-buffer-list))
10590 (setq mml-buffer-list nil)
10591 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10592 (mime-to-mml ,'current-handles))
10593 (let ((mbl1 mml-buffer-list))
10594 (setq mml-buffer-list mbl)
10595 (set (make-local-variable 'mml-buffer-list) mbl1))
10596 (gnus-make-local-hook 'kill-buffer-hook)
10597 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10598 `(lambda (no-highlight)
10599 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10600 (message-options message-options)
10601 (message-options-set-recipient)
10602 (mail-parse-ignored-charsets
10603 ',gnus-newsgroup-ignored-charsets)
10604 (rfc2047-header-encoding-alist
10605 ',(let ((charset (gnus-group-name-charset
10606 (gnus-find-method-for-group
10607 gnus-newsgroup-name)
10608 gnus-newsgroup-name)))
10609 (append (list (cons "Newsgroups" charset)
10610 (cons "Followup-To" charset)
10611 (cons "Xref" charset))
10612 rfc2047-header-encoding-alist))))
10613 ,(if (not raw) '(progn
10615 (mml-destroy-buffers)
10616 (remove-hook 'kill-buffer-hook
10617 'mml-destroy-buffers t)
10618 (kill-local-variable 'mml-buffer-list)))
10619 (gnus-summary-edit-article-done
10620 ,(or (mail-header-references gnus-current-headers) "")
10621 ,(gnus-group-read-only-p)
10622 ,gnus-summary-buffer no-highlight))))))))
10624 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10626 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10628 "Make edits to the current article permanent."
10631 ;; The buffer restriction contains the entire article if it exists.
10632 (when (article-goto-body)
10633 (let ((lines (count-lines (point) (point-max)))
10634 (length (- (point-max) (point)))
10635 (case-fold-search t)
10636 (body (point-marker)))
10637 (goto-char (point-min))
10638 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10639 (delete-region (match-beginning 1) (match-end 1))
10640 (insert (number-to-string length)))
10641 (goto-char (point-min))
10642 (when (re-search-forward
10643 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10644 (delete-region (match-beginning 1) (match-end 1))
10645 (insert (number-to-string length)))
10646 (goto-char (point-min))
10647 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10648 (delete-region (match-beginning 1) (match-end 1))
10649 (insert (number-to-string lines))))))
10650 ;; Replace the article.
10651 (let ((buf (current-buffer))
10652 (article (cdr gnus-article-current))
10655 (insert-buffer-substring buf)
10656 (if (and (not read-only)
10657 (not (setq replace-result
10658 (gnus-request-replace-article
10659 article (car gnus-article-current)
10660 (current-buffer) t))))
10661 (error "Couldn't replace article")
10662 ;; If we got a number back, then that's the new article number
10663 ;; for this article. Otherwise, the article number didn't change.
10664 (when (numberp replace-result)
10665 (with-current-buffer gnus-summary-buffer
10666 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10667 (gnus-summary-limit gnus-newsgroup-limit)
10668 (setq article replace-result)
10669 (gnus-summary-goto-subject article t)))
10670 ;; Update the summary buffer.
10671 (if (and references
10672 (equal (message-tokenize-header references " ")
10673 (message-tokenize-header
10674 (or (message-fetch-field "references") "") " ")))
10675 ;; We only have to update this line.
10678 (message-narrow-to-head)
10679 (let ((head (buffer-substring-no-properties
10680 (point-min) (point-max)))
10683 (insert (format "211 %d Article retrieved.\n" article))
10686 (let ((nntp-server-buffer (current-buffer)))
10687 (setq header (car (gnus-get-newsgroup-headers nil t))))
10688 (with-current-buffer gnus-summary-buffer
10689 (gnus-data-set-header (gnus-data-find article) header)
10690 (gnus-summary-update-article-line article header)
10691 (if (gnus-summary-goto-subject article nil t)
10692 (gnus-summary-update-secondary-mark article)))))))
10694 (set-buffer (or buffer gnus-summary-buffer))
10695 (gnus-summary-update-article article)
10696 (if (gnus-summary-goto-subject article nil t)
10697 (gnus-summary-update-secondary-mark article)))
10698 ;; Prettify the article buffer again.
10699 (unless no-highlight
10700 (with-current-buffer gnus-article-buffer
10701 ;;!!! Fix this -- article should be rehighlighted.
10702 ;;(gnus-run-hooks 'gnus-article-display-hook)
10703 (set-buffer gnus-original-article-buffer)
10704 (gnus-request-article
10705 article (car gnus-article-current) (current-buffer))))
10706 ;; Prettify the summary buffer line.
10707 (when (gnus-visual-p 'summary-highlight 'highlight)
10708 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10710 (defun gnus-summary-edit-wash (key)
10711 "Perform editing command KEY in the article buffer."
10715 (message "%s" (concat (this-command-keys) "- "))
10718 (gnus-summary-edit-article)
10719 (execute-kbd-macro (concat (this-command-keys) key))
10720 (gnus-article-edit-done))
10724 (defvar nnimap-split-fancy)
10725 (defvar nnimap-split-methods)
10727 (defun gnus-summary-respool-query (&optional silent trace)
10728 "Query where the respool algorithm would put this article."
10730 (let (gnus-mark-article-hook)
10731 (gnus-summary-select-article)
10732 (with-current-buffer gnus-original-article-buffer
10734 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10736 ;; nnimap has its own splitting variables.
10737 (let ((nnmail-split-methods
10739 ((eq nnimap-split-methods 'default)
10740 nnmail-split-methods)
10741 (nnimap-split-methods
10742 nnimap-split-methods)
10743 (nnimap-split-fancy
10744 'nnmail-split-fancy)))
10745 (nnmail-split-fancy (or nnimap-split-fancy
10746 nnmail-split-fancy)))
10747 (nnmail-article-group 'identity trace))
10748 (nnmail-article-group 'identity trace))))
10751 (message "This message would go to %s"
10752 (mapconcat 'car groups ", "))
10753 (message "This message would go to no groups"))
10756 (defun gnus-summary-respool-trace ()
10757 "Trace where the respool algorithm would put this article.
10758 Display a buffer showing all fancy splitting patterns which matched."
10760 (gnus-summary-respool-query nil t))
10762 ;; Summary marking commands.
10764 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10765 "Mark articles which has the same subject as read, and then select the next.
10766 If UNMARK is positive, remove any kind of mark.
10767 If UNMARK is negative, tick articles."
10770 (setq unmark (prefix-numeric-value unmark)))
10772 (gnus-summary-mark-same-subject
10773 (gnus-summary-article-subject) unmark)))
10774 ;; Select next unread article. If auto-select-same mode, should
10775 ;; select the first unread article.
10776 (gnus-summary-next-article t (and gnus-auto-select-same
10777 (gnus-summary-article-subject)))
10778 (gnus-message 7 "%d article%s marked as %s"
10779 count (if (= count 1) " is" "s are")
10780 (if unmark "unread" "read"))))
10782 (defun gnus-summary-kill-same-subject (&optional unmark)
10783 "Mark articles which has the same subject as read.
10784 If UNMARK is positive, remove any kind of mark.
10785 If UNMARK is negative, tick articles."
10788 (setq unmark (prefix-numeric-value unmark)))
10790 (gnus-summary-mark-same-subject
10791 (gnus-summary-article-subject) unmark)))
10792 ;; If marked as read, go to next unread subject.
10793 (when (null unmark)
10794 ;; Go to next unread subject.
10795 (gnus-summary-next-subject 1 t))
10796 (gnus-message 7 "%d articles are marked as %s"
10797 count (if unmark "unread" "read"))))
10799 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10800 "Mark articles with same SUBJECT as read, and return marked number.
10801 If optional argument UNMARK is positive, remove any kinds of marks.
10802 If optional argument UNMARK is negative, mark articles as unread instead."
10806 ((null unmark) ; Mark as read.
10809 (gnus-summary-mark-article-as-read gnus-killed-mark)
10810 (gnus-summary-show-thread) t)
10811 (gnus-summary-find-subject subject))
10812 (setq count (1+ count))))
10813 ((> unmark 0) ; Tick.
10816 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10817 (gnus-summary-show-thread) t)
10818 (gnus-summary-find-subject subject))
10819 (setq count (1+ count))))
10820 (t ; Mark as unread.
10823 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10824 (gnus-summary-show-thread) t)
10825 (gnus-summary-find-subject subject))
10826 (setq count (1+ count)))))
10827 (gnus-set-mode-line 'summary)
10828 ;; Return the number of marked articles.
10831 (defun gnus-summary-mark-as-processable (n &optional unmark)
10832 "Set the process mark on the next N articles.
10833 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10834 the process mark instead. The difference between N and the actual
10835 number of articles marked is returned."
10837 (if (and (null n) (gnus-region-active-p))
10838 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10839 (setq n (prefix-numeric-value n))
10840 (let ((backward (< n 0))
10845 (gnus-summary-remove-process-mark
10846 (gnus-summary-article-number))
10847 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10848 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10851 (gnus-message 7 "No more articles"))
10852 (gnus-summary-recenter)
10853 (gnus-summary-position-point)
10856 (defun gnus-summary-unmark-as-processable (n)
10857 "Remove the process mark from the next N articles.
10858 If N is negative, unmark backward instead. The difference between N and
10859 the actual number of articles unmarked is returned."
10861 (gnus-summary-mark-as-processable n t))
10863 (defun gnus-summary-unmark-all-processable ()
10864 "Remove the process mark from all articles."
10867 (while gnus-newsgroup-processable
10868 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10869 (gnus-summary-position-point))
10871 (defun gnus-summary-add-mark (article type)
10872 "Mark ARTICLE with a mark of TYPE."
10873 (let ((vtype (car (assq type gnus-article-mark-lists)))
10876 (error "No such mark type: %s" type)
10877 (setq var (intern (format "gnus-newsgroup-%s" type)))
10878 (set var (cons article (symbol-value var)))
10879 (if (memq type '(processable cached replied forwarded recent saved))
10880 (gnus-summary-update-secondary-mark article)
10881 ;;; !!! This is bogus. We should find out what primary
10882 ;;; !!! mark we want to set.
10883 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10885 (defun gnus-summary-mark-as-expirable (n)
10886 "Mark N articles forward as expirable.
10887 If N is negative, mark backward instead. The difference between N and
10888 the actual number of articles marked is returned."
10890 (gnus-summary-mark-forward n gnus-expirable-mark))
10892 (defun gnus-summary-mark-as-spam (n)
10893 "Mark N articles forward as spam.
10894 If N is negative, mark backward instead. The difference between N and
10895 the actual number of articles marked is returned."
10897 (gnus-summary-mark-forward n gnus-spam-mark))
10899 (defun gnus-summary-mark-article-as-replied (article)
10900 "Mark ARTICLE as replied to and update the summary line.
10901 ARTICLE can also be a list of articles."
10902 (interactive (list (gnus-summary-article-number)))
10903 (let ((articles (if (listp article) article (list article))))
10904 (dolist (article articles)
10905 (unless (numberp article)
10906 (error "%s is not a number" article))
10907 (push article gnus-newsgroup-replied)
10908 (let ((inhibit-read-only t))
10909 (when (gnus-summary-goto-subject article nil t)
10910 (gnus-summary-update-secondary-mark article))))))
10912 (defun gnus-summary-mark-article-as-forwarded (article)
10913 "Mark ARTICLE as forwarded and update the summary line.
10914 ARTICLE can also be a list of articles."
10915 (let ((articles (if (listp article) article (list article))))
10916 (dolist (article articles)
10917 (push article gnus-newsgroup-forwarded)
10918 (let ((inhibit-read-only t))
10919 (when (gnus-summary-goto-subject article nil t)
10920 (gnus-summary-update-secondary-mark article))))))
10922 (defun gnus-summary-set-bookmark (article)
10923 "Set a bookmark in current article."
10924 (interactive (list (gnus-summary-article-number)))
10925 (when (or (not (get-buffer gnus-article-buffer))
10926 (not gnus-current-article)
10927 (not gnus-article-current)
10928 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10929 (error "No current article selected"))
10930 ;; Remove old bookmark, if one exists.
10931 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10932 ;; Set the new bookmark, which is on the form
10933 ;; (article-number . line-number-in-body).
10936 (with-current-buffer gnus-article-buffer
10940 (article-goto-body)
10943 gnus-newsgroup-bookmarks)
10944 (gnus-message 6 "A bookmark has been added to the current article."))
10946 (defun gnus-summary-remove-bookmark (article)
10947 "Remove the bookmark from the current article."
10948 (interactive (list (gnus-summary-article-number)))
10949 ;; Remove old bookmark, if one exists.
10950 (if (not (assq article gnus-newsgroup-bookmarks))
10951 (gnus-message 6 "No bookmark in current article.")
10952 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10953 (gnus-message 6 "Removed bookmark.")))
10955 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10956 (defun gnus-summary-mark-as-dormant (n)
10957 "Mark N articles forward as dormant.
10958 If N is negative, mark backward instead. The difference between N and
10959 the actual number of articles marked is returned."
10961 (gnus-summary-mark-forward n gnus-dormant-mark))
10963 (defun gnus-summary-set-process-mark (article)
10964 "Set the process mark on ARTICLE and update the summary line."
10965 (setq gnus-newsgroup-processable
10967 (delq article gnus-newsgroup-processable)))
10968 (when (gnus-summary-goto-subject article)
10969 (gnus-summary-show-thread)
10970 (gnus-summary-goto-subject article)
10971 (gnus-summary-update-secondary-mark article)))
10973 (defun gnus-summary-remove-process-mark (&rest articles)
10974 "Remove the process mark from ARTICLES and update the summary line."
10975 (dolist (article articles)
10976 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10977 (when (gnus-summary-goto-subject article)
10978 (gnus-summary-show-thread)
10979 (gnus-summary-goto-subject article)
10980 (gnus-summary-update-secondary-mark article)))
10983 (defun gnus-summary-set-saved-mark (article)
10984 "Set the process mark on ARTICLE and update the summary line."
10985 (push article gnus-newsgroup-saved)
10986 (when (gnus-summary-goto-subject article)
10987 (gnus-summary-update-secondary-mark article)))
10989 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10990 "Mark N articles as read forwards.
10991 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10992 The difference between N and the actual number of articles marked is
10994 If NO-EXPIRE, auto-expiry will be inhibited."
10996 (gnus-summary-show-thread)
10997 (let ((backward (< n 0))
10998 (gnus-summary-goto-unread
10999 (and gnus-summary-goto-unread
11000 (not (eq gnus-summary-goto-unread 'never))
11001 (not (memq mark (list gnus-unread-mark gnus-spam-mark
11002 gnus-ticked-mark gnus-dormant-mark)))))
11004 (mark (or mark gnus-del-mark)))
11005 (while (and (> n 0)
11006 (gnus-summary-mark-article nil mark no-expire)
11007 (zerop (gnus-summary-next-subject
11009 (and gnus-summary-goto-unread
11010 (not (eq gnus-summary-goto-unread 'never)))
11014 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11015 (gnus-summary-recenter)
11016 (gnus-summary-position-point)
11017 (gnus-set-mode-line 'summary)
11020 (defun gnus-summary-mark-article-as-read (mark)
11021 "Mark the current article quickly as read with MARK."
11022 (let ((article (gnus-summary-article-number)))
11023 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11024 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11025 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11026 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11027 (push (cons article mark) gnus-newsgroup-reads)
11028 ;; Possibly remove from cache, if that is used.
11029 (when gnus-use-cache
11030 (gnus-cache-enter-remove-article article))
11031 ;; Allow the backend to change the mark.
11032 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11033 ;; Check for auto-expiry.
11034 (when (and gnus-newsgroup-auto-expire
11035 (memq mark gnus-auto-expirable-marks))
11036 (setq mark gnus-expirable-mark)
11037 ;; Let the backend know about the mark change.
11038 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11039 (push article gnus-newsgroup-expirable))
11040 ;; Set the mark in the buffer.
11041 (gnus-summary-update-mark mark 'unread)
11044 (defun gnus-summary-mark-article-as-unread (mark)
11045 "Mark the current article quickly as unread with MARK."
11046 (let* ((article (gnus-summary-article-number))
11047 (old-mark (gnus-summary-article-mark article)))
11048 ;; Allow the backend to change the mark.
11049 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11050 (if (eq mark old-mark)
11054 (gnus-error 1 "Can't mark negative article numbers")
11056 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11057 (setq gnus-newsgroup-spam-marked
11058 (delq article gnus-newsgroup-spam-marked))
11059 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11060 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11061 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11062 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11063 (cond ((= mark gnus-ticked-mark)
11064 (setq gnus-newsgroup-marked
11065 (gnus-add-to-sorted-list gnus-newsgroup-marked
11067 ((= mark gnus-spam-mark)
11068 (setq gnus-newsgroup-spam-marked
11069 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11071 ((= mark gnus-dormant-mark)
11072 (setq gnus-newsgroup-dormant
11073 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11076 (setq gnus-newsgroup-unreads
11077 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11079 (gnus-alist-pull article gnus-newsgroup-reads)
11081 ;; See whether the article is to be put in the cache.
11082 (and gnus-use-cache
11083 (vectorp (gnus-summary-article-header article))
11085 (gnus-cache-possibly-enter-article
11086 gnus-newsgroup-name article
11087 (= mark gnus-ticked-mark)
11088 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11091 (gnus-summary-update-mark mark 'unread)
11094 (defun gnus-summary-mark-article (&optional article mark no-expire)
11095 "Mark ARTICLE with MARK. MARK can be any character.
11096 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11097 `??' (dormant) and `?E' (expirable).
11098 If MARK is nil, then the default character `?r' is used.
11099 If ARTICLE is nil, then the article on the current line will be
11101 If NO-EXPIRE, auto-expiry will be inhibited."
11102 ;; The mark might be a string.
11103 (when (stringp mark)
11104 (setq mark (aref mark 0)))
11105 ;; If no mark is given, then we check auto-expiring.
11107 (setq mark gnus-del-mark))
11108 (when (and (not no-expire)
11109 gnus-newsgroup-auto-expire
11110 (memq mark gnus-auto-expirable-marks))
11111 (setq mark gnus-expirable-mark))
11112 (let ((article (or article (gnus-summary-article-number)))
11113 (old-mark (gnus-summary-article-mark article)))
11114 ;; Allow the backend to change the mark.
11115 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11116 (if (eq mark old-mark)
11119 (error "No article on current line"))
11120 (if (not (if (or (= mark gnus-unread-mark)
11121 (= mark gnus-ticked-mark)
11122 (= mark gnus-spam-mark)
11123 (= mark gnus-dormant-mark))
11124 (gnus-mark-article-as-unread article mark)
11125 (gnus-mark-article-as-read article mark)))
11127 ;; See whether the article is to be put in the cache.
11128 (and gnus-use-cache
11129 (not (= mark gnus-canceled-mark))
11130 (vectorp (gnus-summary-article-header article))
11132 (gnus-cache-possibly-enter-article
11133 gnus-newsgroup-name article
11134 (= mark gnus-ticked-mark)
11135 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11137 (when (gnus-summary-goto-subject article nil t)
11138 (let ((inhibit-read-only t))
11139 (gnus-summary-show-thread)
11141 (gnus-summary-update-mark mark 'unread)
11144 (defun gnus-summary-update-secondary-mark (article)
11145 "Update the secondary (read, process, cache) mark."
11146 (gnus-summary-update-mark
11147 (cond ((memq article gnus-newsgroup-processable)
11149 ((memq article gnus-newsgroup-cached)
11151 ((memq article gnus-newsgroup-replied)
11153 ((memq article gnus-newsgroup-forwarded)
11154 gnus-forwarded-mark)
11155 ((memq article gnus-newsgroup-saved)
11157 ((memq article gnus-newsgroup-unseen)
11161 (when (gnus-visual-p 'summary-highlight 'highlight)
11162 (gnus-summary-highlight-line)
11163 (gnus-run-hooks 'gnus-summary-update-hook))
11166 (defun gnus-summary-update-download-mark (article)
11167 "Update the download mark."
11168 (gnus-summary-update-mark
11169 (cond ((memq article gnus-newsgroup-undownloaded)
11170 gnus-undownloaded-mark)
11171 (gnus-newsgroup-agentized
11172 gnus-downloaded-mark)
11176 (gnus-summary-update-line t)
11179 (defun gnus-summary-update-mark (mark type)
11180 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11181 (inhibit-read-only t))
11182 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11184 (when (looking-at "\r")
11186 (when (<= (+ forward (point)) (point-max))
11187 ;; Go to the right position on the line.
11188 (goto-char (+ forward (point)))
11189 ;; Replace the old mark with the new mark.
11191 (mm-subst-char-in-string
11193 (buffer-substring (point) (1+ (point))))))
11194 (delete-region (point) (1+ (point)))
11195 (insert to-insert))
11196 ;; Optionally update the marks by some user rule.
11197 (when (eq type 'unread)
11198 (gnus-data-set-mark
11199 (gnus-data-find (gnus-summary-article-number)) mark)
11200 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11202 (defun gnus-mark-article-as-read (article &optional mark)
11203 "Enter ARTICLE in the pertinent lists and remove it from others."
11204 ;; Make the article expirable.
11205 (let ((mark (or mark gnus-del-mark)))
11206 (setq gnus-newsgroup-expirable
11207 (if (= mark gnus-expirable-mark)
11208 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11209 (delq article gnus-newsgroup-expirable)))
11210 ;; Remove from unread and marked lists.
11211 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11212 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11213 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11214 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11215 (push (cons article mark) gnus-newsgroup-reads)
11216 ;; Possibly remove from cache, if that is used.
11217 (when gnus-use-cache
11218 (gnus-cache-enter-remove-article article))
11221 (defun gnus-mark-article-as-unread (article &optional mark)
11222 "Enter ARTICLE in the pertinent lists and remove it from others."
11223 (let ((mark (or mark gnus-ticked-mark)))
11226 (gnus-error 1 "Can't mark negative article numbers")
11228 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11229 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11230 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11231 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11232 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11234 ;; Unsuppress duplicates?
11235 (when gnus-suppress-duplicates
11236 (gnus-dup-unsuppress-article article))
11238 (cond ((= mark gnus-ticked-mark)
11239 (setq gnus-newsgroup-marked
11240 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11241 ((= mark gnus-spam-mark)
11242 (setq gnus-newsgroup-spam-marked
11243 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11245 ((= mark gnus-dormant-mark)
11246 (setq gnus-newsgroup-dormant
11247 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11249 (setq gnus-newsgroup-unreads
11250 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11251 (gnus-alist-pull article gnus-newsgroup-reads)
11254 (defun gnus-summary-tick-article-forward (n)
11255 "Tick N articles forwards.
11256 If N is negative, tick backwards instead.
11257 The difference between N and the number of articles ticked is returned."
11259 (gnus-summary-mark-forward n gnus-ticked-mark))
11261 (defun gnus-summary-tick-article-backward (n)
11262 "Tick N articles backwards.
11263 The difference between N and the number of articles ticked is returned."
11265 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11267 (defun gnus-summary-tick-article (&optional article clear-mark)
11268 "Mark current article as unread.
11269 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11270 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11272 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11273 gnus-ticked-mark)))
11275 (defun gnus-summary-mark-as-read-forward (n)
11276 "Mark N articles as read forwards.
11277 If N is negative, mark backwards instead.
11278 The difference between N and the actual number of articles marked is
11281 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11283 (defun gnus-summary-mark-as-read-backward (n)
11284 "Mark the N articles as read backwards.
11285 The difference between N and the actual number of articles marked is
11288 (gnus-summary-mark-forward
11289 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11291 (defun gnus-summary-mark-as-read (&optional article mark)
11292 "Mark current article as read.
11293 ARTICLE specifies the article to be marked as read.
11294 MARK specifies a string to be inserted at the beginning of the line."
11295 (gnus-summary-mark-article article mark))
11297 (defun gnus-summary-clear-mark-forward (n)
11298 "Clear marks from N articles forward.
11299 If N is negative, clear backward instead.
11300 The difference between N and the number of marks cleared is returned."
11302 (gnus-summary-mark-forward n gnus-unread-mark))
11304 (defun gnus-summary-clear-mark-backward (n)
11305 "Clear marks from N articles backward.
11306 The difference between N and the number of marks cleared is returned."
11308 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11310 (defun gnus-summary-mark-unread-as-read ()
11311 "Intended to be used by `gnus-mark-article-hook'."
11312 (when (memq gnus-current-article gnus-newsgroup-unreads)
11313 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11315 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11316 "Intended to be used by `gnus-mark-article-hook'."
11317 (let ((mark (gnus-summary-article-mark)))
11318 (when (or (gnus-unread-mark-p mark)
11319 (gnus-read-mark-p mark))
11320 (gnus-summary-mark-article gnus-current-article
11321 (or new-mark gnus-read-mark)))))
11323 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11324 "Intended to be used by `gnus-mark-article-hook'."
11325 (let ((mark (gnus-summary-article-mark)))
11326 (when (or (gnus-unread-mark-p mark)
11327 (gnus-read-mark-p mark))
11328 (gnus-summary-mark-article (gnus-summary-article-number)
11329 (or new-mark gnus-read-mark)))))
11331 (defun gnus-summary-mark-unread-as-ticked ()
11332 "Intended to be used by `gnus-mark-article-hook'."
11333 (when (memq gnus-current-article gnus-newsgroup-unreads)
11334 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11336 (defun gnus-summary-mark-region-as-read (point mark all)
11337 "Mark all unread articles between point and mark as read.
11338 If given a prefix, mark all articles between point and mark as read,
11339 even ticked and dormant ones."
11340 (interactive "r\nP")
11344 (beginning-of-line)
11349 (memq (setq article (gnus-summary-article-number))
11350 gnus-newsgroup-unreads))
11351 (gnus-summary-mark-article article gnus-del-mark))
11353 (gnus-summary-find-next))))))
11355 (defun gnus-summary-mark-below (score mark)
11356 "Mark articles with score less than SCORE with MARK."
11357 (interactive "P\ncMark: ")
11358 (setq score (if score
11359 (prefix-numeric-value score)
11360 (or gnus-summary-default-score 0)))
11361 (with-current-buffer gnus-summary-buffer
11362 (goto-char (point-min))
11365 (and (< (gnus-summary-article-score) score)
11366 (gnus-summary-mark-article nil mark))
11367 (gnus-summary-find-next)))))
11369 (defun gnus-summary-kill-below (&optional score)
11370 "Mark articles with score below SCORE as read."
11372 (gnus-summary-mark-below score gnus-killed-mark))
11374 (defun gnus-summary-clear-above (&optional score)
11375 "Clear all marks from articles with score above SCORE."
11377 (gnus-summary-mark-above score gnus-unread-mark))
11379 (defun gnus-summary-tick-above (&optional score)
11380 "Tick all articles with score above SCORE."
11382 (gnus-summary-mark-above score gnus-ticked-mark))
11384 (defun gnus-summary-mark-above (score mark)
11385 "Mark articles with score over SCORE with MARK."
11386 (interactive "P\ncMark: ")
11387 (setq score (if score
11388 (prefix-numeric-value score)
11389 (or gnus-summary-default-score 0)))
11390 (with-current-buffer gnus-summary-buffer
11391 (goto-char (point-min))
11393 (when (> (gnus-summary-article-score) score)
11394 (gnus-summary-mark-article nil mark))
11396 (gnus-summary-find-next)))))
11398 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11399 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11400 (defun gnus-summary-limit-include-expunged (&optional no-error)
11401 "Display all the hidden articles that were expunged for low scores."
11403 (let ((inhibit-read-only t))
11404 (let ((scored gnus-newsgroup-scored)
11407 (unless (gnus-summary-article-header (caar scored))
11408 (and (setq h (gnus-number-to-header (caar scored)))
11409 (< (cdar scored) gnus-summary-expunge-below)
11411 (setq scored (cdr scored)))
11413 (when (not no-error)
11414 (error "No expunged articles hidden"))
11415 (goto-char (point-min))
11416 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11417 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11418 (dolist (x headers)
11419 (push (mail-header-number x) gnus-newsgroup-limit))
11420 (gnus-summary-prepare-unthreaded (nreverse headers))
11421 (goto-char (point-min))
11422 (gnus-summary-position-point)
11425 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11426 "Mark all unread articles in this newsgroup as read.
11427 If prefix argument ALL is non-nil, ticked and dormant articles will
11428 also be marked as read.
11429 If QUIETLY is non-nil, no questions will be asked.
11431 If TO-HERE is non-nil, it should be a point in the buffer. All
11432 articles before (after, if REVERSE is set) this point will be marked
11435 Note that this function will only catch up the unread article
11436 in the current summary buffer limitation.
11438 The number of articles marked as read is returned."
11443 (not gnus-interactive-catchup) ;Without confirmation?
11447 "Mark absolutely all articles as read? "
11448 "Mark all unread articles as read? ")))
11450 (not gnus-newsgroup-adaptive)
11451 (not gnus-newsgroup-auto-expire)
11452 (not gnus-suppress-duplicates)
11453 (or (not gnus-use-cache)
11454 (eq gnus-use-cache 'passive)))
11457 (setq gnus-newsgroup-marked nil
11458 gnus-newsgroup-spam-marked nil
11459 gnus-newsgroup-dormant nil))
11460 (setq gnus-newsgroup-unreads
11461 (gnus-sorted-nunion
11462 (gnus-sorted-intersection gnus-newsgroup-unreads
11463 gnus-newsgroup-downloadable)
11464 (gnus-sorted-difference gnus-newsgroup-unfetched
11465 gnus-newsgroup-cached))))
11466 ;; We actually mark all articles as canceled, which we
11467 ;; have to do when using auto-expiry or adaptive scoring.
11468 (gnus-summary-show-all-threads)
11469 (if (and to-here reverse)
11471 (goto-char to-here)
11472 (gnus-summary-mark-current-read-and-unread-as-read
11474 (while (gnus-summary-find-next (not all))
11475 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11476 (when (gnus-summary-first-subject (not all))
11478 (if to-here (< (point) to-here) t)
11479 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11480 (gnus-summary-find-next (not all))))))
11481 (gnus-set-mode-line 'summary))
11483 (gnus-summary-position-point)))
11485 (defun gnus-summary-catchup-to-here (&optional all)
11486 "Mark all unticked articles before the current one as read.
11487 If ALL is non-nil, also mark ticked and dormant articles as read."
11490 (gnus-save-hidden-threads
11491 (let ((beg (point)))
11492 ;; We check that there are unread articles.
11493 (when (or all (gnus-summary-find-prev))
11494 (gnus-summary-catchup all t beg)))))
11495 (gnus-summary-position-point))
11497 (defun gnus-summary-catchup-from-here (&optional all)
11498 "Mark all unticked articles after (and including) the current one as read.
11499 If ALL is non-nil, also mark ticked and dormant articles as read."
11502 (gnus-save-hidden-threads
11503 (let ((beg (point)))
11504 ;; We check that there are unread articles.
11505 (when (or all (gnus-summary-find-next))
11506 (gnus-summary-catchup all t beg nil t)))))
11507 (gnus-summary-position-point))
11509 (defun gnus-summary-catchup-all (&optional quietly)
11510 "Mark all articles in this newsgroup as read.
11511 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11512 instead, which marks only unread articles as read."
11514 (gnus-summary-catchup t quietly))
11516 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11517 "Mark all unread articles in this group as read, then exit.
11518 If prefix argument ALL is non-nil, all articles are marked as read.
11519 If QUIETLY is non-nil, no questions will be asked."
11521 (when (gnus-summary-catchup all quietly nil 'fast)
11522 ;; Select next newsgroup or exit.
11523 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11524 (eq gnus-auto-select-next 'quietly))
11525 (gnus-summary-next-group nil)
11526 (gnus-summary-exit))))
11528 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11529 "Mark all articles in this newsgroup as read, and then exit.
11530 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11531 instead, which marks only unread articles as read."
11533 (gnus-summary-catchup-and-exit t quietly))
11535 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11536 "Mark all articles in this group as read and select the next group.
11537 If given a prefix, mark all articles, unread as well as ticked, as
11541 (gnus-summary-catchup all))
11542 (gnus-summary-next-group))
11544 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11545 "Mark all articles in this group as read and select the previous group.
11546 If given a prefix, mark all articles, unread as well as ticked, as
11550 (gnus-summary-catchup all))
11551 (gnus-summary-next-group nil nil t))
11557 (defmacro gnus-with-article (article &rest forms)
11558 "Select ARTICLE and perform FORMS in the original article buffer.
11559 Then replace the article with the result."
11561 ;; We don't want the article to be marked as read.
11562 (let (gnus-mark-article-hook)
11563 (gnus-summary-select-article t t nil ,article))
11564 (set-buffer gnus-original-article-buffer)
11566 (if (not (gnus-check-backend-function
11567 'request-replace-article (car gnus-article-current)))
11568 (gnus-message 5 "Read-only group; not replacing")
11569 (unless (gnus-request-replace-article
11570 ,article (car gnus-article-current)
11571 (current-buffer) t)
11572 (error "Couldn't replace article")))
11573 ;; The cache and backlog have to be flushed somewhat.
11574 (when gnus-keep-backlog
11575 (gnus-backlog-remove-article
11576 (car gnus-article-current) (cdr gnus-article-current)))
11577 (when gnus-use-cache
11578 (gnus-cache-update-article
11579 (car gnus-article-current) (cdr gnus-article-current)))))
11581 (put 'gnus-with-article 'lisp-indent-function 1)
11582 (put 'gnus-with-article 'edebug-form-spec '(form body))
11584 ;; Thread-based commands.
11586 (defun gnus-summary-articles-in-thread (&optional article)
11587 "Return a list of all articles in the current thread.
11588 If ARTICLE is non-nil, return all articles in the thread that starts
11589 with that article."
11590 (let* ((article (or article (gnus-summary-article-number)))
11591 (data (gnus-data-find-list article))
11592 (top-level (gnus-data-level (car data)))
11594 (cond ((null gnus-thread-operation-ignore-subject)
11595 (gnus-simplify-subject-re
11596 (mail-header-subject (gnus-data-header (car data)))))
11597 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11598 (gnus-simplify-subject-fuzzy
11599 (mail-header-subject (gnus-data-header (car data)))))
11601 (end-point (save-excursion
11602 (goto-char (gnus-data-pos (car data)))
11603 (if (gnus-summary-go-to-next-thread)
11604 (point) (point-max))))
11607 (< (gnus-data-pos (car data)) end-point))
11608 (when (or (not top-subject)
11609 (string= top-subject
11610 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11611 (gnus-simplify-subject-fuzzy
11612 (mail-header-subject
11613 (gnus-data-header (car data))))
11614 (gnus-simplify-subject-re
11615 (mail-header-subject
11616 (gnus-data-header (car data)))))))
11617 (push (gnus-data-number (car data)) articles))
11618 (unless (and (setq data (cdr data))
11619 (> (gnus-data-level (car data)) top-level))
11621 ;; Return the list of articles.
11622 (nreverse articles)))
11624 (defun gnus-summary-rethread-current ()
11625 "Rethread the thread the current article is part of."
11627 (let* ((gnus-show-threads t)
11628 (article (gnus-summary-article-number))
11629 (id (mail-header-id (gnus-summary-article-header)))
11630 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11632 (error "No article on the current line"))
11633 (gnus-rebuild-thread id)
11634 (gnus-summary-goto-subject article)))
11636 (defun gnus-summary-reparent-thread ()
11637 "Make the current article child of the marked (or previous) article.
11639 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11640 is non-nil or the Subject: of both articles are the same."
11642 (unless (not (gnus-group-read-only-p))
11643 (error "The current newsgroup does not support article editing"))
11644 (unless (<= (length gnus-newsgroup-processable) 1)
11645 (error "No more than one article may be marked"))
11646 (let ((child (gnus-summary-article-number))
11647 ;; First grab the marked article, otherwise one line up.
11648 (parent (if (not (null gnus-newsgroup-processable))
11649 (car gnus-newsgroup-processable)
11651 (if (eq (forward-line -1) 0)
11652 (gnus-summary-article-number)
11653 (error "Beginning of summary buffer"))))))
11654 (gnus-summary-reparent-children parent (list child))))
11656 (defun gnus-summary-reparent-children (parent children)
11657 "Make PARENT the parent of CHILDREN.
11658 When called interactively, PARENT is the current article and CHILDREN
11659 are the process-marked articles."
11661 (list (gnus-summary-article-number)
11662 (gnus-summary-work-articles nil)))
11663 (dolist (child children)
11664 (save-window-excursion
11665 (let ((gnus-article-buffer " *reparent*"))
11666 (unless (not (eq parent child))
11667 (error "An article may not be self-referential"))
11668 (let ((message-id (mail-header-id
11669 (gnus-summary-article-header parent))))
11670 (unless (and message-id (not (equal message-id "")))
11671 (error "No message-id in desired parent"))
11672 (gnus-with-article child
11674 (goto-char (point-min))
11675 (message-narrow-to-head)
11676 (if (re-search-forward "^References: " nil t)
11678 (re-search-forward "^[^ \t]" nil t)
11681 (insert " " message-id))
11682 (insert "References: " message-id "\n"))))
11683 (set-buffer gnus-summary-buffer)
11684 (gnus-summary-unmark-all-processable)
11685 (gnus-summary-update-article child)
11686 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11687 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11688 (gnus-summary-rethread-current)
11689 (gnus-message 3 "Article %d is now the child of article %d"
11692 (defun gnus-summary-toggle-threads (&optional arg)
11693 "Toggle showing conversation threads.
11694 If ARG is positive number, turn showing conversation threads on."
11696 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11697 (setq gnus-show-threads
11698 (if (null arg) (not gnus-show-threads)
11699 (> (prefix-numeric-value arg) 0)))
11700 (gnus-summary-prepare)
11701 (gnus-summary-goto-subject current)
11702 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11703 (gnus-summary-position-point)))
11705 (defun gnus-summary-show-all-threads ()
11706 "Show all threads."
11708 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11709 (gnus-summary-position-point))
11711 (defsubst gnus-summary--inv (p)
11712 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11714 (defun gnus-summary-show-thread ()
11715 "Show thread subtrees.
11716 Returns nil if no thread was there to be shown."
11718 (let* ((orig (point))
11719 (end (point-at-eol))
11720 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11721 ;; Leave point at bol
11722 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11724 (if (fboundp 'next-single-char-property-change)
11725 ;; Note: XEmacs version of n-s-c-p-c may return nil
11726 (or (next-single-char-property-change end 'invisible)
11731 (eq (get-char-property (point) 'invisible)
11735 (remove-overlays beg eoi 'invisible 'gnus-sum)
11737 (gnus-summary-position-point)
11740 (defun gnus-summary-maybe-hide-threads ()
11741 "If requested, hide the threads that should be hidden."
11742 (when (and gnus-show-threads
11743 gnus-thread-hide-subtree)
11744 (gnus-summary-hide-all-threads
11745 (if (or (consp gnus-thread-hide-subtree)
11746 (functionp gnus-thread-hide-subtree))
11747 (gnus-make-predicate gnus-thread-hide-subtree)
11750 ;;; Hiding predicates.
11752 (defun gnus-article-unread-p (header)
11753 (memq (mail-header-number header) gnus-newsgroup-unreads))
11755 (defun gnus-article-unseen-p (header)
11756 (memq (mail-header-number header) gnus-newsgroup-unseen))
11758 (defun gnus-map-articles (predicate articles)
11759 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11760 (apply 'gnus-or (mapcar predicate
11761 (mapcar (lambda (number)
11762 (gnus-summary-article-header number))
11765 (defun gnus-summary-hide-all-threads (&optional predicate)
11766 "Hide all thread subtrees.
11767 If PREDICATE is supplied, threads that satisfy this predicate
11768 will not be hidden."
11771 (goto-char (point-min))
11776 (when (zerop (mod count 1000))
11777 (message "Hiding all threads... %d" count))
11778 (when (or (not predicate)
11780 predicate (gnus-summary-article-children)))
11781 (gnus-summary-hide-thread))
11782 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11783 (gnus-summary-position-point))
11785 (defun gnus-summary-hide-thread ()
11786 "Hide thread subtrees.
11787 If PREDICATE is supplied, threads that satisfy this predicate
11788 will not be hidden.
11789 Returns nil if no threads were there to be hidden."
11791 (beginning-of-line)
11792 (let ((start (point))
11793 (starteol (line-end-position))
11794 (article (gnus-summary-article-number)))
11795 ;; Go forward until either the buffer ends or the subthread ends.
11796 (when (and (not (eobp))
11797 (or (zerop (gnus-summary-next-thread 1 t))
11798 (goto-char (point-max))))
11799 (if (and (> (point) start)
11800 ;; FIXME: this should actually search for a non-invisible \n.
11801 (search-backward "\n" start t))
11803 (when (> (point) starteol)
11804 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11805 (let ((ol (make-overlay starteol (point) nil t nil)))
11806 (overlay-put ol 'invisible 'gnus-sum)
11807 (overlay-put ol 'evaporate t)))
11808 (gnus-summary-goto-subject article)
11809 (when (> start (point))
11810 (message "Hiding the thread moved us backwards, aborting!")
11811 (goto-char (point-max))))
11815 (defun gnus-summary-go-to-next-thread (&optional previous)
11816 "Go to the same level (or less) next thread.
11817 If PREVIOUS is non-nil, go to previous thread instead.
11818 Return the article number moved to, or nil if moving was impossible."
11819 (let ((level (gnus-summary-thread-level))
11820 (way (if previous -1 1))
11823 (while (and (not (eobp))
11824 (< level (gnus-summary-thread-level)))
11825 (forward-line way))
11832 (gnus-summary-article-number)
11833 (goto-char beg)))))
11835 (defun gnus-summary-next-thread (n &optional silent)
11836 "Go to the same level next N'th thread.
11837 If N is negative, search backward instead.
11838 Returns the difference between N and the number of skips actually
11841 If SILENT, don't output messages."
11843 (let ((backward (< n 0))
11845 (while (and (> n 0)
11846 (gnus-summary-go-to-next-thread backward))
11849 (gnus-summary-position-point))
11850 (when (and (not silent) (/= 0 n))
11851 (gnus-message 7 "No more threads"))
11854 (defun gnus-summary-prev-thread (n)
11855 "Go to the same level previous N'th thread.
11856 Returns the difference between N and the number of skips actually
11859 (gnus-summary-next-thread (- n)))
11861 (defun gnus-summary-go-down-thread ()
11862 "Go down one level in the current thread."
11863 (let ((children (gnus-summary-article-children)))
11865 (gnus-summary-goto-subject (car children)))))
11867 (defun gnus-summary-go-up-thread ()
11868 "Go up one level in the current thread."
11869 (let ((parent (gnus-summary-article-parent)))
11871 (gnus-summary-goto-subject parent))))
11873 (defun gnus-summary-down-thread (n)
11874 "Go down thread N steps.
11875 If N is negative, go up instead.
11876 Returns the difference between N and how many steps down that were
11881 (while (and (> n 0)
11882 (if up (gnus-summary-go-up-thread)
11883 (gnus-summary-go-down-thread)))
11885 (gnus-summary-position-point)
11887 (gnus-message 7 "Can't go further"))
11890 (defun gnus-summary-up-thread (n)
11891 "Go up thread N steps.
11892 If N is negative, go down instead.
11893 Returns the difference between N and how many steps down that were
11896 (gnus-summary-down-thread (- n)))
11898 (defun gnus-summary-top-thread ()
11899 "Go to the top of the thread."
11901 (while (gnus-summary-go-up-thread))
11902 (gnus-summary-article-number))
11904 (defun gnus-summary-expire-thread ()
11905 "Mark articles under current thread as expired."
11907 (gnus-summary-kill-thread 0))
11909 (defun gnus-summary-kill-thread (&optional unmark)
11910 "Mark articles under current thread as read.
11911 If the prefix argument is positive, remove any kinds of marks.
11912 If the prefix argument is zero, mark thread as expired.
11913 If the prefix argument is negative, tick articles instead."
11916 (setq unmark (prefix-numeric-value unmark)))
11917 (let ((articles (gnus-summary-articles-in-thread))
11918 (hide (or (null unmark) (= unmark 0))))
11920 ;; Expand the thread.
11921 (gnus-summary-show-thread)
11922 ;; Mark all the articles.
11924 (gnus-summary-goto-subject (car articles))
11925 (cond ((null unmark)
11926 (gnus-summary-mark-article-as-read gnus-killed-mark))
11928 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11930 (gnus-summary-mark-article nil gnus-expirable-mark))
11932 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11933 (setq articles (cdr articles))))
11934 ;; Hide killed subtrees when hide is true.
11936 gnus-thread-hide-killed
11937 (gnus-summary-hide-thread))
11938 ;; If hide is t, go to next unread subject.
11940 ;; Go to next unread subject.
11941 (gnus-summary-next-subject 1 t)))
11942 (gnus-set-mode-line 'summary))
11944 ;; Summary sorting commands
11946 (defun gnus-summary-sort-by-number (&optional reverse)
11947 "Sort the summary buffer by article number.
11948 Argument REVERSE means reverse order."
11950 (gnus-summary-sort 'number reverse))
11952 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11953 "Sort the summary buffer by most recent article number.
11954 Argument REVERSE means reverse order."
11956 (gnus-summary-sort 'most-recent-number reverse))
11958 (defun gnus-summary-sort-by-random (&optional reverse)
11959 "Randomize the order in the summary buffer.
11960 Argument REVERSE means to randomize in reverse order."
11962 (gnus-summary-sort 'random reverse))
11964 (defun gnus-summary-sort-by-author (&optional reverse)
11965 "Sort the summary buffer by author name alphabetically.
11966 If `case-fold-search' is non-nil, case of letters is ignored.
11967 Argument REVERSE means reverse order."
11969 (gnus-summary-sort 'author reverse))
11971 (defun gnus-summary-sort-by-recipient (&optional reverse)
11972 "Sort the summary buffer by recipient name alphabetically.
11973 If `case-fold-search' is non-nil, case of letters is ignored.
11974 Argument REVERSE means reverse order."
11976 (gnus-summary-sort 'recipient reverse))
11978 (defun gnus-summary-sort-by-subject (&optional reverse)
11979 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11980 If `case-fold-search' is non-nil, case of letters is ignored.
11981 Argument REVERSE means reverse order."
11983 (gnus-summary-sort 'subject reverse))
11985 (defun gnus-summary-sort-by-date (&optional reverse)
11986 "Sort the summary buffer by date.
11987 Argument REVERSE means reverse order."
11989 (gnus-summary-sort 'date reverse))
11991 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11992 "Sort the summary buffer by most recent date.
11993 Argument REVERSE means reverse order."
11995 (gnus-summary-sort 'most-recent-date reverse))
11997 (defun gnus-summary-sort-by-score (&optional reverse)
11998 "Sort the summary buffer by score.
11999 Argument REVERSE means reverse order."
12001 (gnus-summary-sort 'score reverse))
12003 (defun gnus-summary-sort-by-lines (&optional reverse)
12004 "Sort the summary buffer by the number of lines.
12005 Argument REVERSE means reverse order."
12007 (gnus-summary-sort 'lines reverse))
12009 (defun gnus-summary-sort-by-chars (&optional reverse)
12010 "Sort the summary buffer by article length.
12011 Argument REVERSE means reverse order."
12013 (gnus-summary-sort 'chars reverse))
12015 (defun gnus-summary-sort-by-original (&optional reverse)
12016 "Sort the summary buffer using the default sorting method.
12017 Argument REVERSE means reverse order."
12019 (let* ((inhibit-read-only t)
12020 (gnus-summary-prepare-hook nil))
12021 ;; We do the sorting by regenerating the threads.
12022 (gnus-summary-prepare)
12023 ;; Hide subthreads if needed.
12024 (gnus-summary-maybe-hide-threads)))
12026 (defun gnus-summary-sort (predicate reverse)
12027 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12028 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12029 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12030 (gnus-thread-sort-functions
12035 (gnus-sort-gathered-threads-function
12036 gnus-thread-sort-functions)
12037 (gnus-article-sort-functions
12041 (,article t2 t1))))
12042 (inhibit-read-only t)
12043 (gnus-summary-prepare-hook nil))
12044 ;; We do the sorting by regenerating the threads.
12045 (gnus-summary-prepare)
12046 ;; Hide subthreads if needed.
12047 (gnus-summary-maybe-hide-threads)))
12049 ;; Summary saving commands.
12051 (defun gnus-summary-save-article (&optional n not-saved)
12052 "Save the current article using the default saver function.
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.
12057 The variable `gnus-default-article-saver' specifies the saver function.
12059 If the optional second argument NOT-SAVED is non-nil, articles saved
12060 will not be marked as saved."
12062 (require 'gnus-art)
12063 (let* ((articles (gnus-summary-work-articles n))
12064 (save-buffer (save-excursion
12065 (nnheader-set-temp-buffer " *Gnus Save*")))
12066 (num (length articles))
12067 ;; Whether to save decoded articles or raw articles.
12068 (decode (when gnus-article-save-coding-system
12069 (get gnus-default-article-saver :decode)))
12070 ;; When saving many articles in a single file, use the other
12071 ;; function to save articles other than the first one.
12072 (saver2 (get gnus-default-article-saver :function))
12073 (gnus-prompt-before-saving (if saver2
12075 gnus-prompt-before-saving))
12076 (gnus-default-article-saver gnus-default-article-saver)
12078 (dolist (article articles)
12079 (setq header (gnus-summary-article-header article))
12080 (if (not (vectorp header))
12081 ;; This is a pseudo-article.
12082 (if (assq 'name header)
12083 (gnus-copy-file (cdr (assq 'name header)))
12084 (gnus-message 1 "Article %d is unsavable" article))
12085 ;; This is a real article.
12086 (save-window-excursion
12087 (gnus-summary-select-article decode decode nil article)
12088 (gnus-summary-goto-subject article))
12089 (with-current-buffer save-buffer
12091 (insert-buffer-substring (if decode
12092 gnus-article-buffer
12093 gnus-original-article-buffer)))
12094 (setq file (gnus-article-save save-buffer file num))
12095 (gnus-summary-remove-process-mark article)
12097 (gnus-summary-set-saved-mark article)))
12099 (setq gnus-default-article-saver saver2
12101 (gnus-kill-buffer save-buffer)
12102 (gnus-summary-position-point)
12103 (gnus-set-mode-line 'summary)
12106 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12108 (defun gnus-summary-pipe-output (&optional n sym)
12109 "Pipe the current article to a subprocess.
12110 If N is a positive number, pipe the N next articles.
12111 If N is a negative number, pipe the N previous articles.
12112 If N is nil and any articles have been marked with the process mark,
12113 pipe those articles instead.
12114 The default command to which articles are piped is specified by the
12115 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12116 will be prompted for the command.
12118 The properties `:decode' and `:headers' that are put to the function
12119 symbol `gnus-summary-save-in-pipe' control whether this function
12120 decodes articles and what headers to keep (see the doc string for the
12121 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12122 is neither omitted nor the symbol `r', force including all headers
12123 regardless of the `:headers' property. If it is the symbol `r',
12124 articles that are not decoded and include all headers will be piped
12125 no matter what the properties `:decode' and `:headers' are."
12126 (interactive (gnus-interactive "P\ny"))
12127 (require 'gnus-art)
12128 (let* ((articles (gnus-summary-work-articles n))
12129 (result-buffer "*Shell Command Output*")
12130 (all-headers (not (memq sym '(nil r))))
12131 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12133 (headers (get 'gnus-summary-save-in-pipe :headers))
12135 (unless (numberp (car articles))
12136 (error "No article to pipe"))
12137 (setq command (gnus-read-shell-command
12138 (concat "Shell command on "
12140 (format "these %d articles" (length articles))
12143 gnus-summary-pipe-output-default-command))
12144 (when (string-equal command "")
12145 (error "A command is required"))
12147 (put 'gnus-summary-save-in-pipe :headers nil))
12150 (gnus-summary-goto-subject (pop articles))
12151 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12152 (when (and (get-buffer result-buffer)
12153 (not (zerop (buffer-size (get-buffer result-buffer)))))
12154 (setq result (concat result (with-current-buffer result-buffer
12155 (buffer-string))))))
12156 (put 'gnus-summary-save-in-pipe :headers headers))
12157 (unless (zerop (length result))
12158 (if (with-current-buffer (get-buffer-create result-buffer)
12162 (and (= (count-lines (point-min) (point)) 1)
12165 (<= (current-column)
12166 (window-width (minibuffer-window)))))
12167 (goto-char (point-min))))
12168 (message "%s" (substring result 0 -1))
12170 (gnus-configure-windows 'pipe)))))
12172 (defun gnus-summary-save-article-mail (&optional arg)
12173 "Append the current article to a Unix mail box file.
12174 If N is a positive number, save the N next articles.
12175 If N is a negative number, save the N previous articles.
12176 If N is nil and any articles have been marked with the process mark,
12177 save those articles instead."
12179 (require 'gnus-art)
12180 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12181 (gnus-summary-save-article arg)))
12183 (defun gnus-summary-save-article-rmail (&optional arg)
12184 "Append the current article to an rmail file.
12185 If N is a positive number, save the N next articles.
12186 If N is a negative number, save the N previous articles.
12187 If N is nil and any articles have been marked with the process mark,
12188 save those articles instead."
12190 (require 'gnus-art)
12191 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12192 (gnus-summary-save-article arg)))
12194 (defun gnus-summary-save-article-file (&optional arg)
12195 "Append the current article to a file.
12196 If N is a positive number, save the N next articles.
12197 If N is a negative number, save the N previous articles.
12198 If N is nil and any articles have been marked with the process mark,
12199 save those articles instead."
12201 (require 'gnus-art)
12202 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12203 (gnus-summary-save-article arg)))
12205 (defun gnus-summary-write-article-file (&optional arg)
12206 "Write the current article to a file, deleting the previous file.
12207 If N is a positive number, save the N next articles.
12208 If N is a negative number, save the N previous articles.
12209 If N is nil and any articles have been marked with the process mark,
12210 save those articles instead."
12212 (require 'gnus-art)
12213 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12214 (gnus-summary-save-article arg)))
12216 (defun gnus-summary-save-article-body-file (&optional arg)
12217 "Append the current article body to a file.
12218 If N is a positive number, save the N next articles.
12219 If N is a negative number, save the N previous articles.
12220 If N is nil and any articles have been marked with the process mark,
12221 save those articles instead."
12223 (require 'gnus-art)
12224 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12225 (gnus-summary-save-article arg)))
12227 (defun gnus-summary-write-article-body-file (&optional arg)
12228 "Write the current article body to a file, deleting the previous file.
12229 If N is a positive number, save the N next articles.
12230 If N is a negative number, save the N previous articles.
12231 If N is nil and any articles have been marked with the process mark,
12232 save those articles instead."
12234 (require 'gnus-art)
12235 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12236 (gnus-summary-save-article arg)))
12238 (defun gnus-summary-muttprint (&optional arg)
12239 "Print the current article using Muttprint.
12240 If N is a positive number, save the N next articles.
12241 If N is a negative number, save the N previous articles.
12242 If N is nil and any articles have been marked with the process mark,
12243 save those articles instead."
12245 (require 'gnus-art)
12246 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12247 (gnus-summary-save-article arg t)))
12249 (defun gnus-summary-pipe-message (program)
12250 "Pipe the current article through PROGRAM."
12251 (interactive "sProgram: ")
12252 (gnus-summary-select-article)
12253 (let ((mail-header-separator ""))
12254 (gnus-eval-in-buffer-window gnus-article-buffer
12257 (let ((start (window-start))
12258 (inhibit-read-only t))
12259 (message-pipe-buffer-body program)
12260 (set-window-start (get-buffer-window (current-buffer)) start))))))
12262 (defun gnus-get-split-value (methods)
12263 "Return a value based on the split METHODS."
12264 (let (split-name method result match)
12266 (with-current-buffer gnus-original-article-buffer
12268 (nnheader-narrow-to-headers)
12269 (while (and methods (not split-name))
12270 (goto-char (point-min))
12271 (setq method (pop methods))
12272 (setq match (car method))
12275 ;; Regular expression.
12277 (re-search-forward match nil t)))
12282 (setq result (funcall match gnus-newsgroup-name))))
12287 (setq result (eval match)))))
12288 (setq split-name (cdr method))
12289 (cond ((stringp result)
12290 (push (expand-file-name
12291 result gnus-article-save-directory)
12294 (setq split-name (append result split-name)))))))))
12295 (nreverse split-name)))
12297 (defun gnus-valid-move-group-p (group)
12298 (and (symbolp group)
12300 (symbol-name group)
12301 (symbol-value group)
12302 (gnus-get-function (gnus-find-method-for-group
12303 (symbol-name group)) 'request-accept-article t)))
12305 (defun gnus-read-move-group-name (prompt default articles prefix)
12306 "Read a group name."
12307 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12308 (minibuffer-confirm-incomplete nil) ; XEmacs
12312 (if (> (length articles) 1)
12313 (format "these %d articles" (length articles))
12318 (gnus-group-completing-read
12320 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12321 nil prefix nil default))
12322 ((= 1 (length split-name))
12323 (gnus-group-completing-read
12325 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12326 nil prefix 'gnus-group-history (car split-name)))
12328 (gnus-completing-read
12329 prom (nreverse split-name) nil nil 'gnus-group-history))))
12330 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12333 (if (or (string= to-newsgroup "")
12334 (string= to-newsgroup prefix))
12335 (setq to-newsgroup default))
12336 (unless to-newsgroup
12337 (error "No group name entered"))
12338 (setq encoded (mm-encode-coding-string
12340 (gnus-group-name-charset to-method to-newsgroup)))
12341 (or (gnus-active encoded)
12342 (gnus-activate-group encoded nil nil to-method)
12343 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12345 (or (and (gnus-request-create-group encoded to-method)
12346 (gnus-activate-group encoded nil nil to-method)
12347 (gnus-subscribe-group encoded))
12348 (error "Couldn't create group %s" to-newsgroup)))
12349 (error "No such group: %s" to-newsgroup))
12352 (defvar gnus-summary-save-parts-counter)
12353 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12355 (defun gnus-summary-save-parts (type dir n &optional reverse)
12356 "Save parts matching TYPE to DIR.
12357 If REVERSE, save parts that do not match TYPE."
12359 (list (read-string "Save parts of type: "
12360 (or (car gnus-summary-save-parts-type-history)
12361 gnus-summary-save-parts-default-mime)
12362 'gnus-summary-save-parts-type-history)
12363 (setq gnus-summary-save-parts-last-directory
12364 (read-directory-name "Save to directory: "
12365 gnus-summary-save-parts-last-directory
12367 current-prefix-arg))
12368 (gnus-summary-iterate n
12369 (let ((gnus-display-mime-function nil)
12370 gnus-article-prepare-hook
12371 gnus-article-decode-hook
12372 gnus-display-mime-function
12374 (gnus-inhibit-treatment t))
12375 (gnus-summary-select-article))
12376 (with-current-buffer gnus-article-buffer
12377 (let ((handles (or gnus-article-mime-handles
12378 (mm-dissect-buffer nil gnus-article-loose-mime)
12379 (and gnus-article-emulate-mime
12381 (gnus-summary-save-parts-counter 1))
12383 (gnus-summary-save-parts-1 type dir handles reverse)
12384 (unless gnus-article-mime-handles ;; Don't destroy this case.
12385 (mm-destroy-parts handles)))))))
12387 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12388 (if (stringp (car handle))
12389 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12392 (not (string-match type (mm-handle-media-type handle)))
12393 (string-match type (mm-handle-media-type handle)))
12394 (let ((file (expand-file-name
12396 mm-file-name-rewrite-functions
12397 (file-name-nondirectory
12399 (mm-handle-filename handle)
12400 (format "%s.%d.%d" gnus-newsgroup-name
12401 (cdr gnus-article-current)
12402 gnus-summary-save-parts-counter))))
12404 (incf gnus-summary-save-parts-counter)
12405 (unless (file-exists-p file)
12406 (mm-save-part-to-file handle file))))))
12408 ;; Summary extract commands
12410 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12411 (let ((inhibit-read-only t)
12412 (article (gnus-summary-article-number))
12414 (unless (gnus-summary-goto-subject article)
12415 (error "No such article: %d" article))
12416 (gnus-summary-position-point)
12417 ;; If all commands are to be bunched up on one line, we collect
12419 (unless gnus-view-pseudos-separately
12420 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12423 (setq action (cdr (assq 'action (car ps))))
12424 (setq files (list (cdr (assq 'name (car ps)))))
12425 (while (and ps (cdr ps)
12426 (string= (or action "1")
12427 (or (cdr (assq 'action (cadr ps))) "2")))
12428 (push (cdr (assq 'name (cadr ps))) files)
12429 (setcdr ps (cddr ps)))
12431 (when (not (string-match "%s" action))
12434 (when (assq 'execute (car ps))
12435 (setcdr (assq 'execute (car ps))
12436 (funcall (if (string-match "%s" action)
12443 (shell-quote-argument f)))
12445 (setq ps (cdr ps)))))
12446 (if (and gnus-view-pseudos (not not-view))
12448 (when (assq 'execute (car pslist))
12449 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12450 (eq gnus-view-pseudos 'not-confirm)))
12451 (setq pslist (cdr pslist)))
12454 (setq after-article (or (cdr (assq 'article (car pslist)))
12455 (gnus-summary-article-number)))
12456 (gnus-summary-goto-subject after-article)
12459 (insert " " (file-name-nondirectory
12460 (cdr (assq 'name (car pslist))))
12461 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12463 (forward-line -1) ; back to `b'
12464 (gnus-add-text-properties
12465 b (1- e) (list 'gnus-number gnus-reffed-article-number
12466 gnus-mouse-face-prop gnus-mouse-face))
12468 after-article gnus-reffed-article-number
12469 gnus-unread-mark b (car pslist) 0 (- e b))
12470 (setq gnus-newsgroup-unreads
12471 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12472 gnus-reffed-article-number))
12473 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12474 (setq pslist (cdr pslist)))))))
12476 (defun gnus-pseudos< (p1 p2)
12477 (let ((c1 (cdr (assq 'action p1)))
12478 (c2 (cdr (assq 'action p2))))
12479 (and c1 c2 (string< c1 c2))))
12481 (defun gnus-request-pseudo-article (props)
12482 (cond ((assq 'execute props)
12483 (gnus-execute-command (cdr (assq 'execute props)))))
12484 (let ((gnus-current-article (gnus-summary-article-number)))
12485 (gnus-run-hooks 'gnus-mark-article-hook)))
12487 (defun gnus-execute-command (command &optional automatic)
12489 (gnus-article-setup-buffer)
12490 (set-buffer gnus-article-buffer)
12491 (setq buffer-read-only nil)
12492 (let ((command (if automatic command
12493 (read-string "Command: " (cons command 0)))))
12495 (insert "$ " command "\n\n")
12496 (if gnus-view-pseudo-asynchronously
12497 (start-process "gnus-execute" (current-buffer) shell-file-name
12498 shell-command-switch command)
12499 (call-process shell-file-name nil t nil
12500 shell-command-switch command)))))
12502 ;; Summary kill commands.
12504 (defun gnus-summary-edit-global-kill (article)
12505 "Edit the \"global\" kill file."
12506 (interactive (list (gnus-summary-article-number)))
12507 (gnus-group-edit-global-kill article))
12509 (defun gnus-summary-edit-local-kill ()
12510 "Edit a local kill file applied to the current newsgroup."
12512 (setq gnus-current-headers (gnus-summary-article-header))
12513 (gnus-group-edit-local-kill
12514 (gnus-summary-article-number) gnus-newsgroup-name))
12516 ;;; Header reading.
12518 (defun gnus-read-header (id &optional header)
12519 "Read the headers of article ID and enter them into the Gnus system."
12520 (let ((group gnus-newsgroup-name)
12521 (gnus-override-method
12523 gnus-override-method
12524 (and (gnus-news-group-p gnus-newsgroup-name)
12525 (car (gnus-refer-article-methods)))))
12527 ;; First we check to see whether the header in question is already
12530 ;; This is a Message-ID.
12531 (setq header (or header (gnus-id-to-header id)))
12532 ;; This is an article number.
12533 (setq header (or header (gnus-summary-article-header id))))
12535 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12536 ;; We have found the header.
12538 ;; We have to really fetch the header to this article.
12539 (with-current-buffer nntp-server-buffer
12540 (when (setq where (gnus-request-head id group))
12541 (nnheader-fold-continuation-lines)
12542 (goto-char (point-max))
12544 (goto-char (point-min))
12548 ((cdr where) (cdr where))
12549 (header (mail-header-number header))
12550 (t gnus-reffed-article-number))
12552 (insert " Article retrieved.\n"))
12553 (if (or (not where)
12554 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12555 () ; Malformed head.
12556 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12557 (when (and (bound-and-true-p gnus-registry-enabled)
12558 (not (gnus-ephemeral-group-p (car where))))
12559 (gnus-registry-handle-action
12560 (mail-header-id header) nil
12561 (gnus-group-prefixed-name
12563 (or gnus-override-method (gnus-find-method-for-group group)))
12564 (mail-header-subject header)
12565 (mail-header-from header)))
12566 (when (and (stringp id)
12568 (not (string= (gnus-group-real-name group)
12570 (not (gnus-server-equal gnus-override-method
12571 (gnus-group-method group)))))
12572 ;; If we fetched by Message-ID and the article came from
12573 ;; a different group (or server), we fudge some bogus
12574 ;; article numbers for this article.
12575 (mail-header-set-number header gnus-reffed-article-number))
12576 (with-current-buffer gnus-summary-buffer
12577 (decf gnus-reffed-article-number)
12578 (gnus-remove-header (mail-header-number header))
12579 (push header gnus-newsgroup-headers)
12580 (setq gnus-current-headers header)
12581 (push (mail-header-number header) gnus-newsgroup-limit)))
12584 (defun gnus-remove-header (number)
12585 "Remove header NUMBER from `gnus-newsgroup-headers'."
12586 (if (and gnus-newsgroup-headers
12587 (= number (mail-header-number (car gnus-newsgroup-headers))))
12588 (pop gnus-newsgroup-headers)
12589 (let ((headers gnus-newsgroup-headers))
12590 (while (and (cdr headers)
12591 (not (= number (mail-header-number (cadr headers)))))
12593 (when (cdr headers)
12594 (setcdr headers (cddr headers))))))
12597 ;;; summary highlights
12600 (defun gnus-highlight-selected-summary ()
12601 "Highlight selected article in summary buffer."
12602 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12603 (when gnus-summary-selected-face
12605 (let* ((beg (point-at-bol))
12606 (end (point-at-eol))
12607 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12608 (from (if (get-text-property beg gnus-mouse-face-prop)
12610 (or (next-single-property-change
12611 beg gnus-mouse-face-prop nil end)
12616 (or (next-single-property-change
12617 from gnus-mouse-face-prop nil end)
12619 ;; If no mouse-face prop on line we will have to = from = end,
12620 ;; so we highlight the entire line instead.
12621 (when (= (+ to 2) from)
12624 (if gnus-newsgroup-selected-overlay
12625 ;; Move old overlay.
12627 gnus-newsgroup-selected-overlay from to (current-buffer))
12628 ;; Create new overlay.
12630 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12631 'face gnus-summary-selected-face))))))
12633 (defvar gnus-summary-highlight-line-cached nil)
12634 (defvar gnus-summary-highlight-line-trigger nil)
12636 (defun gnus-summary-highlight-line-0 ()
12637 (if (and (eq gnus-summary-highlight-line-trigger
12638 gnus-summary-highlight)
12639 gnus-summary-highlight-line-cached)
12640 gnus-summary-highlight-line-cached
12641 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12642 gnus-summary-highlight-line-cached
12643 (let* ((cond (list 'cond))
12645 (list gnus-summary-highlight))
12647 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12651 (gnus-byte-compile (list 'lambda nil cond))))))
12653 (defun gnus-summary-highlight-line ()
12654 "Highlight current line according to `gnus-summary-highlight'."
12655 (let* ((beg (point-at-bol))
12656 (article (or (gnus-summary-article-number) gnus-current-article))
12657 (score (or (cdr (assq article
12658 gnus-newsgroup-scored))
12659 gnus-summary-default-score 0))
12660 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12661 (inhibit-read-only t)
12662 (default gnus-summary-default-score)
12663 (default-high gnus-summary-default-high-score)
12664 (default-low gnus-summary-default-low-score)
12665 (uncached (and gnus-summary-use-undownloaded-faces
12666 (memq article gnus-newsgroup-undownloaded)
12667 (not (memq article gnus-newsgroup-cached)))))
12668 (let ((face (funcall (gnus-summary-highlight-line-0))))
12669 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12670 (gnus-put-text-property-excluding-characters-with-faces
12671 beg (point-at-eol) 'face
12672 (setq face (if (boundp face) (symbol-value face) face)))
12673 (when gnus-summary-highlight-line-function
12674 (funcall gnus-summary-highlight-line-function article face))))))
12676 (defun gnus-update-read-articles (group unread &optional compute)
12677 "Update the list of read articles in GROUP.
12678 UNREAD is a sorted list."
12679 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12680 (info (gnus-get-info group))
12683 (if (or (not info) (not active))
12684 ;; There is no info on this group if it was, in fact,
12685 ;; killed. Gnus stores no information on killed groups, so
12686 ;; there's nothing to be done.
12687 ;; One could store the information somewhere temporarily,
12688 ;; perhaps... Hmmm...
12690 ;; Remove any negative articles numbers.
12691 (while (and unread (< (car unread) 0))
12692 (setq unread (cdr unread)))
12693 ;; Remove any expired article numbers
12694 (while (and unread (< (car unread) (car active)))
12695 (setq unread (cdr unread)))
12696 ;; Compute the ranges of read articles by looking at the list of
12697 ;; unread articles.
12699 (when (/= (car unread) prev)
12700 (push (if (= prev (1- (car unread))) prev
12701 (cons prev (1- (car unread))))
12703 (setq prev (1+ (car unread)))
12704 (setq unread (cdr unread)))
12705 (when (<= prev (cdr active))
12706 (push (cons prev (cdr active)) read))
12707 (setq read (if (> (length read) 1) (nreverse read) read))
12712 ;; Propagate the read marks to the backend.
12713 (when (and (gnus-method-option-p
12714 (gnus-find-method-for-group group)
12716 (gnus-check-backend-function 'request-set-mark group))
12717 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12718 (add (gnus-remove-from-range read (gnus-info-read info))))
12720 (unless (gnus-check-group group)
12721 (error "Can't open server for %s" group))
12722 (gnus-request-set-mark
12723 group (delq nil (list (if add (list add 'add '(read)))
12724 (if del (list del 'del '(read))))))
12726 `(gnus-request-set-mark
12729 (if del (list del 'add '(read)))
12730 (if add (list add 'del '(read))))))))))
12731 (set-buffer gnus-group-buffer)
12732 (gnus-undo-register
12734 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12735 (gnus-info-set-read ',info ',(gnus-info-read info))
12736 (gnus-get-unread-articles-in-group ',info
12737 (gnus-active ,group))
12738 (gnus-group-update-group ,group t)
12740 ;; Enter this list into the group info.
12741 (gnus-info-set-read info read)
12742 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12743 (gnus-get-unread-articles-in-group info (gnus-active group))
12746 (defun gnus-offer-save-summaries ()
12747 "Offer to save all active summary buffers."
12749 ;; Go through all buffers and find all summaries.
12750 (dolist (buffer (buffer-list))
12751 (when (and (setq buffer (buffer-name buffer))
12752 (string-match "Summary" buffer)
12753 (with-current-buffer buffer
12754 ;; We check that this is, indeed, a summary buffer.
12755 (and (derived-mode-p 'gnus-summary-mode)
12756 ;; Also make sure this isn't bogus.
12757 gnus-newsgroup-prepared
12758 ;; Also make sure that this isn't a
12759 ;; dead summary buffer.
12760 (not gnus-dead-summary-mode))))
12761 (push buffer buffers)))
12762 ;; Go through all these summary buffers and offer to save them.
12765 (if (eq gnus-interactive-exit 'quiet)
12766 (dolist (buffer buffers)
12767 (switch-to-buffer buffer)
12768 (gnus-summary-exit))
12770 "Update summary buffer %s? "
12772 (switch-to-buffer buf)
12773 (gnus-summary-exit))
12776 (defun gnus-summary-setup-default-charset ()
12777 "Setup newsgroup default charset."
12778 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12779 (setq gnus-newsgroup-charset nil)
12780 (let* ((ignored-charsets
12781 (or gnus-newsgroup-ephemeral-ignored-charsets
12783 (and gnus-newsgroup-name
12784 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12785 gnus-newsgroup-ignored-charsets))))
12786 (setq gnus-newsgroup-charset
12787 (or gnus-newsgroup-ephemeral-charset
12788 (and gnus-newsgroup-name
12789 (gnus-parameter-charset gnus-newsgroup-name))
12790 gnus-default-charset))
12791 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12792 ignored-charsets))))
12798 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12799 "Display the current article buffer fully MIME-buttonized.
12800 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12801 treated as multipart/mixed."
12803 (require 'gnus-art)
12804 (let ((gnus-unbuttonized-mime-types nil)
12805 (gnus-mime-display-multipart-as-mixed show-all-parts))
12806 (gnus-summary-show-article)))
12808 (defun gnus-summary-repair-multipart (article)
12809 "Add a Content-Type header to a multipart article without one."
12810 (interactive (list (gnus-summary-article-number)))
12811 (gnus-with-article article
12812 (message-narrow-to-head)
12813 (message-remove-header "Mime-Version")
12814 (goto-char (point-max))
12815 (insert "Mime-Version: 1.0\n")
12817 (when (search-forward "\n--" nil t)
12818 (let ((separator (buffer-substring (point) (point-at-eol))))
12819 (message-narrow-to-head)
12820 (message-remove-header "Content-Type")
12821 (goto-char (point-max))
12822 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12825 (let (gnus-mark-article-hook)
12826 (gnus-summary-select-article t t nil article)))
12828 (defun gnus-summary-toggle-display-buttonized ()
12829 "Toggle the buttonizing of the article buffer."
12831 (require 'gnus-art)
12832 (if (setq gnus-inhibit-mime-unbuttonizing
12833 (not gnus-inhibit-mime-unbuttonizing))
12834 (let ((gnus-unbuttonized-mime-types nil))
12835 (gnus-summary-show-article))
12836 (gnus-summary-show-article)))
12839 ;;; Generic summary marking commands
12842 (defvar gnus-summary-marking-alist
12843 '((read gnus-del-mark "d")
12844 (unread gnus-unread-mark "u")
12845 (ticked gnus-ticked-mark "!")
12846 (dormant gnus-dormant-mark "?")
12847 (expirable gnus-expirable-mark "e"))
12848 "An alist of names/marks/keystrokes.")
12850 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12851 (defvar gnus-summary-mark-map)
12853 (defun gnus-summary-make-all-marking-commands ()
12854 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12855 (dolist (elem gnus-summary-marking-alist)
12856 (apply 'gnus-summary-make-marking-command elem)))
12858 (defun gnus-summary-make-marking-command (name mark keystroke)
12859 (let ((map (make-sparse-keymap)))
12860 (define-key gnus-summary-generic-mark-map keystroke map)
12861 (dolist (lway `((next "next" next nil "n")
12862 (next-unread "next unread" next t "N")
12863 (prev "previous" prev nil "p")
12864 (prev-unread "previous unread" prev t "P")
12865 (nomove "" nil nil ,keystroke)))
12866 (let ((func (gnus-summary-make-marking-command-1
12867 mark (car lway) lway name)))
12868 (setq func (eval func))
12869 (define-key map (nth 4 lway) func)))))
12871 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12873 (format "gnus-summary-put-mark-as-%s%s"
12874 name (if (eq way 'nomove)
12876 (concat "-" (symbol-name way)))))
12879 "Mark the current article as %s%s.
12880 If N, the prefix, then repeat N times.
12881 If N is negative, move in reverse order.
12882 The difference between N and the actual number of articles marked is
12886 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12888 (defun gnus-summary-generic-mark (n mark move unread)
12889 "Mark N articles with MARK."
12890 (unless (derived-mode-p 'gnus-summary-mode)
12891 (error "This command can only be used in the summary buffer"))
12892 (gnus-summary-show-thread)
12895 ((eq move 'next) 1)
12896 ((eq move 'prev) -1)
12898 (if (zerop nummove)
12902 nummove (* -1 nummove))))
12903 (while (and (> n 0)
12904 (gnus-summary-mark-article nil mark)
12905 (zerop (gnus-summary-next-subject nummove unread t)))
12908 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12909 (gnus-summary-recenter)
12910 (gnus-summary-position-point)
12911 (gnus-set-mode-line 'summary)
12914 (defun gnus-summary-insert-articles (articles)
12915 (when (setq articles
12916 (gnus-sorted-difference articles
12917 (mapcar (lambda (h)
12918 (mail-header-number h))
12919 gnus-newsgroup-headers)))
12920 (setq gnus-newsgroup-headers
12922 gnus-newsgroup-headers
12923 (gnus-fetch-headers articles nil t)
12924 'gnus-article-sort-by-number))
12925 (setq gnus-newsgroup-articles
12926 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12927 ;; Suppress duplicates?
12928 (when gnus-suppress-duplicates
12929 (gnus-dup-suppress-articles))
12931 (if (and gnus-fetch-old-headers
12932 (eq gnus-headers-retrieved-by 'nov))
12933 ;; We might want to build some more threads first.
12934 (if (eq gnus-fetch-old-headers 'invisible)
12935 (gnus-build-all-threads)
12936 (gnus-build-old-threads))
12937 ;; Mark the inserted articles that are unread as unread.
12938 (setq gnus-newsgroup-unreads
12939 (gnus-sorted-nunion
12940 gnus-newsgroup-unreads
12941 (gnus-sorted-nintersection
12942 (gnus-list-of-unread-articles gnus-newsgroup-name)
12944 ;; Mark the inserted articles as selected so that the information
12945 ;; of the marks having been changed by a user may be updated when
12946 ;; exiting this group. See `gnus-summary-update-info'.
12947 (dolist (art articles)
12948 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12949 ;; Let the Gnus agent mark articles as read.
12951 (gnus-agent-get-undownloaded-list))
12952 ;; Remove list identifiers from subject
12953 (gnus-summary-remove-list-identifiers)
12954 ;; First and last article in this newsgroup.
12955 (when gnus-newsgroup-headers
12956 (setq gnus-newsgroup-begin
12957 (mail-header-number (car gnus-newsgroup-headers))
12959 (mail-header-number
12960 (gnus-last-element gnus-newsgroup-headers))))
12961 (when gnus-use-scoring
12962 (gnus-possibly-score-headers))))
12964 (defun gnus-summary-insert-old-articles (&optional all)
12965 "Insert all old articles in this group.
12966 If ALL is non-nil, already read articles become readable.
12967 If ALL is a number, fetch this number of articles."
12970 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12973 ;; Some nntp servers lie about their active range. When
12974 ;; this happens, the active range can be in the millions.
12975 ;; Use a compressed range to avoid creating a huge list.
12976 (gnus-range-difference
12977 (gnus-range-difference (list gnus-newsgroup-active) old)
12978 gnus-newsgroup-unexist))
12979 (setq len (gnus-range-length older))
12984 (let ((older-range (nreverse older)))
12988 (let* ((r (pop older-range))
12989 (min (if (numberp r) r (car r)))
12990 (max (if (numberp r) r (cdr r))))
12991 (while (and (<= min max)
12996 (setq older (gnus-uncompress-range older))))
12998 (setq older (gnus-uncompress-range older)))
13000 (when (and (numberp gnus-large-newsgroup)
13001 (> len gnus-large-newsgroup))
13002 (let* ((cursor-in-echo-area nil)
13003 (initial (gnus-parameter-large-newsgroup-initial
13004 gnus-newsgroup-name))
13008 "How many articles from %s (%s %d): "
13009 (gnus-group-decoded-name gnus-newsgroup-name)
13010 (if initial "max" "default")
13014 (number-to-string initial)))))
13015 (unless (string-match "^[ \t]*$" input)
13016 (setq all (string-to-number input))
13018 (let ((older-range (nreverse older)))
13022 (let* ((r (pop older-range))
13023 (min (if (numberp r) r (car r)))
13024 (max (if (numberp r) r (cdr r))))
13025 (while (and (<= min max)
13029 max (1- max))))))))))
13030 (setq older (gnus-uncompress-range older))))
13032 (message "No old news.")
13033 (gnus-summary-insert-articles older)
13034 (gnus-summary-limit (gnus-sorted-nunion old older))))
13035 (gnus-summary-position-point)))
13037 (defun gnus-summary-insert-new-articles ()
13038 "Insert all new articles in this group."
13040 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
13041 (old-high gnus-newsgroup-highest)
13042 (nnmail-fetched-sources (list t))
13043 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
13046 (error "Couldn't fetch new data"))
13047 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
13048 (setq i (cdr gnus-newsgroup-active)
13049 gnus-newsgroup-highest i)
13050 (while (> i old-high)
13054 (message "No gnus is bad news")
13055 (gnus-summary-insert-articles new)
13056 (setq gnus-newsgroup-unreads
13057 (gnus-sorted-nunion gnus-newsgroup-unreads new))
13058 (gnus-summary-limit (gnus-sorted-nunion old new))))
13059 (gnus-summary-position-point))
13061 ;;; Bookmark support for Gnus.
13062 (declare-function gnus-article-show-summary "gnus-art" ())
13063 (declare-function bookmark-make-record-default
13064 "bookmark" (&optional no-file no-context posn))
13065 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13066 (declare-function bookmark-default-handler "bookmark" (bmk))
13067 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13068 (defvar bookmark-yank-point)
13069 (defvar bookmark-current-buffer)
13071 (defun gnus-summary-bookmark-make-record ()
13072 "Make a bookmark entry for a Gnus summary buffer."
13074 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13075 (save-restriction ; FIXME is it necessary to widen?
13076 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13077 (setq buf "art") ; We are recording bookmark from article buffer.
13078 (setq bookmark-yank-point (point))
13079 (setq bookmark-current-buffer (current-buffer))
13080 (gnus-article-show-summary)) ; Go back in summary buffer.
13081 ;; We are now recording bookmark from summary buffer.
13082 (unless buf (setq buf "sum"))
13083 (let* ((subject (elt (gnus-summary-article-header) 1))
13084 (grp (car gnus-article-current))
13085 (art (cdr gnus-article-current))
13086 (head (gnus-summary-article-header art))
13087 (id (mail-header-id head)))
13089 ,@(condition-case nil
13090 (bookmark-make-record-default 'no-file 'no-context pos)
13091 (wrong-number-of-arguments
13092 (bookmark-make-record-default 'point-only)))
13093 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13094 (group . ,grp) (article . ,art)
13095 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13098 (defun gnus-summary-bookmark-jump (bookmark)
13099 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13100 BOOKMARK is a bookmark name or a bookmark record."
13101 (let ((group (bookmark-prop-get bookmark 'group))
13102 (article (bookmark-prop-get bookmark 'article))
13103 (id (bookmark-prop-get bookmark 'message-id))
13104 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13105 (gnus-fetch-group group (list article))
13106 (gnus-summary-insert-cached-articles)
13107 (gnus-summary-goto-article id nil 'force)
13108 ;; FIXME we have to wait article buffer is ready (only large buffer)
13109 ;; Is there a better solution to know that?
13110 ;; If we don't wait `bookmark-default-handler' will have no chance
13111 ;; to set position. However there is no error, just wrong pos.
13113 (when (string= buf "Gnus-art")
13115 (bookmark-default-handler
13117 (buffer . ,(current-buffer))
13118 . ,(bookmark-get-bookmark-record bookmark)))))
13120 (gnus-summary-make-all-marking-commands)
13122 (gnus-ems-redefine)
13124 (provide 'gnus-sum)
13126 (run-hooks 'gnus-sum-load-hook)
13128 ;; Local Variables:
13132 ;;; gnus-sum.el ends here