1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
36 (defvar tool-bar-mode)
37 (defvar gnus-tmp-header)
50 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
51 (autoload 'gnus-cache-write-active "gnus-cache")
52 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
54 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
55 (autoload 'mm-uu-dissect "mm-uu")
56 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
59 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
62 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63 (autoload 'nnir-article-group "nnir" nil nil 'macro)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74 See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
77 :version "23.1" ;; No Gnus
80 (defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
87 (defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
89 If an unread article in the group refers to an older, already
90 read (or just marked as read) article, the old article will not
91 normally be displayed in the Summary buffer. If this variable is
92 t, Gnus will attempt to grab the headers to the old articles, and
93 thereby build complete threads. If it has the value `some', all
94 old headers will be fetched but only enough headers to connect
95 otherwise loose threads will be displayed. This variable can
96 also be a number. In that case, no more than that number of old
97 headers will be fetched. If it has the value `invisible', all
98 old headers will be fetched, but none will be displayed.
100 The server has to support NOV for any of this to work.
102 This feature can seriously impact performance it ignores all
103 locally cached header entries. Setting it to t for groups for a
104 server that doesn't expire articles (such as news.gmane.org),
105 leads to very slow summary generation."
107 :type '(choice (const :tag "off" nil)
112 (sexp :menu-tag "other" t)))
114 (defcustom gnus-refer-thread-limit 500
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116 If t, fetch all the available old headers."
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
121 (defcustom gnus-summary-make-false-root 'adopt
122 "*nil means that Gnus won't gather loose threads.
123 If the root of a thread has expired or been read in a previous
124 session, the information necessary to build a complete thread has been
125 lost. Instead of having many small sub-threads from this original thread
126 scattered all over the summary buffer, Gnus can gather them.
128 If non-nil, Gnus will try to gather all loose sub-threads from an
129 original thread into one large thread.
131 If this variable is non-nil, it should be one of `none', `adopt',
134 If this variable is `none', Gnus will not make a false root, but just
135 present the sub-threads after another.
136 If this variable is `dummy', Gnus will create a dummy root that will
137 have all the sub-threads as children.
138 If this variable is `adopt', Gnus will make one of the \"children\"
139 the parent and mark all the step-children as such.
140 If this variable is `empty', the \"children\" are printed with empty
141 subject fields. (Or rather, they will be printed with a string
142 given by the `gnus-summary-same-subject' variable.)"
144 :type '(choice (const :tag "off" nil)
150 (defcustom gnus-summary-make-false-root-always nil
151 "Always make a false dummy root."
156 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
157 "*A regexp to match subjects to be excluded from loose thread gathering.
158 As loose thread gathering is done on subjects only, that means that
159 there can be many false gatherings performed. By rooting out certain
160 common subjects, gathering might become saner."
164 (defcustom gnus-summary-gather-subject-limit nil
165 "*Maximum length of subject comparisons when gathering loose threads.
166 Use nil to compare full subjects. Setting this variable to a low
167 number will help gather threads that have been corrupted by
168 newsreaders chopping off subject lines, but it might also mean that
169 unrelated articles that have subject that happen to begin with the
170 same few characters will be incorrectly gathered.
172 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
175 :type '(choice (const :tag "off" nil)
177 (sexp :menu-tag "on" t)))
179 (defcustom gnus-simplify-subject-functions nil
180 "List of functions taking a string argument that simplify subjects.
181 The functions are applied recursively.
183 Useful functions to put in this list include:
184 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
185 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
187 :type '(repeat function))
189 (defcustom gnus-simplify-ignored-prefixes nil
190 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
192 :type '(choice (const :tag "off" nil)
195 (defcustom gnus-build-sparse-threads nil
196 "*If non-nil, fill in the gaps in threads.
197 If `some', only fill in the gaps that are needed to tie loose threads
198 together. If `more', fill in all leaf nodes that Gnus can find. If
199 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
201 :type '(choice (const :tag "off" nil)
204 (sexp :menu-tag "all" t)))
206 (defcustom gnus-summary-thread-gathering-function
207 'gnus-gather-threads-by-subject
208 "*Function used for gathering loose threads.
209 There are two pre-defined functions: `gnus-gather-threads-by-subject',
210 which only takes Subjects into consideration; and
211 `gnus-gather-threads-by-references', which compared the References
212 headers of the articles to find matches."
214 :type '(radio (function-item gnus-gather-threads-by-subject)
215 (function-item gnus-gather-threads-by-references)
216 (function :tag "other")))
218 (defcustom gnus-summary-same-subject ""
219 "*String indicating that the current article has the same subject as the previous.
220 This variable will only be used if the value of
221 `gnus-summary-make-false-root' is `empty'."
222 :group 'gnus-summary-format
225 (defcustom gnus-summary-goto-unread nil
226 "*If t, many commands will go to the next unread article.
227 This applies to marking commands as well as other commands that
228 \"naturally\" select the next article, like, for instance, `SPC' at
229 the end of an article.
231 If nil, the marking commands do NOT go to the next unread article
232 \(they go to the next article instead). If `never', commands that
233 usually go to the next unread article, will go to the next article,
234 whether it is read or not."
236 :group 'gnus-summary-marks
237 :link '(custom-manual "(gnus)Setting Marks")
238 :type '(choice (const :tag "off" nil)
240 (sexp :menu-tag "on" t)))
242 (defcustom gnus-summary-default-score 0
243 "*Default article score level.
244 All scores generated by the score files will be added to this score.
245 If this variable is nil, scoring will be disabled."
246 :group 'gnus-score-default
247 :type '(choice (const :tag "disable")
250 (defcustom gnus-summary-default-high-score 0
251 "*Default threshold for a high scored article.
252 An article will be highlighted as high scored if its score is greater
255 :group 'gnus-score-default
258 (defcustom gnus-summary-default-low-score 0
259 "*Default threshold for a low scored article.
260 An article will be highlighted as low scored if its score is smaller
263 :group 'gnus-score-default
266 (defcustom gnus-summary-zcore-fuzz 0
267 "*Fuzziness factor for the zcore in the summary buffer.
268 Articles with scores closer than this to `gnus-summary-default-score'
270 :group 'gnus-summary-format
273 (defcustom gnus-simplify-subject-fuzzy-regexp nil
274 "*Strings to be removed when doing fuzzy matches.
275 This can either be a regular expression or list of regular expressions
276 that will be removed from subject strings if fuzzy subject
277 simplification is selected."
279 :type '(repeat regexp))
281 (defcustom gnus-show-threads t
282 "*If non-nil, display threads in summary mode."
286 (defcustom gnus-thread-hide-subtree nil
287 "*If non-nil, hide all threads initially.
288 This can be a predicate specifier which says which threads to hide.
289 If threads are hidden, you have to run the command
290 `gnus-summary-show-thread' by hand or select an article."
292 :type '(radio (sexp :format "Non-nil\n"
293 :match (lambda (widget value)
294 (not (or (consp value) (functionp value))))
297 (sexp :tag "Predicate specifier")))
299 (defcustom gnus-thread-hide-killed t
300 "*If non-nil, hide killed threads automatically."
304 (defcustom gnus-thread-ignore-subject t
305 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
306 If nil, articles that have different subjects from their parents will
307 start separate threads."
311 (defcustom gnus-thread-operation-ignore-subject t
312 "*If non-nil, subjects will be ignored when doing thread commands.
313 This affects commands like `gnus-summary-kill-thread' and
314 `gnus-summary-lower-thread'.
316 If this variable is nil, articles in the same thread with different
317 subjects will not be included in the operation in question. If this
318 variable is `fuzzy', only articles that have subjects that are fuzzily
319 equal will be included."
321 :type '(choice (const :tag "off" nil)
325 (defcustom gnus-thread-indent-level 4
326 "*Number that says how much each sub-thread should be indented."
330 (defcustom gnus-auto-extend-newsgroup t
331 "*If non-nil, extend newsgroup forward and backward when requested."
332 :group 'gnus-summary-choose
335 (defcustom gnus-auto-select-first t
336 "If non-nil, select an article on group entry.
337 An article is selected automatically when entering a group
338 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
339 `gnus-summary-catchup-and-goto-next-group'.
341 Which article is selected is controlled by the variable
342 `gnus-auto-select-subject'.
344 If you want to prevent automatic selection of articles in some
345 newsgroups, set the variable to nil in `gnus-select-group-hook'."
346 ;; Commands include...
347 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
348 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
349 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
350 :group 'gnus-group-select
351 :type '(choice (const :tag "none" nil)
352 (sexp :menu-tag "first" t)))
354 (defcustom gnus-auto-select-subject 'unseen-or-unread
355 "*Says what subject to place under point when entering a group.
357 This variable can either be the symbols `first' (place point on the
358 first subject), `unread' (place point on the subject line of the first
359 unread article), `best' (place point on the subject line of the
360 higest-scored article), `unseen' (place point on the subject line of
361 the first unseen article), `unseen-or-unread' (place point on the subject
362 line of the first unseen article or, if all articles have been seen, on the
363 subject line of the first unread article), or a function to be called to
364 place point on some subject line."
366 :group 'gnus-group-select
367 :type '(choice (const best)
371 (const unseen-or-unread)))
373 (defcustom gnus-auto-select-next t
374 "*If non-nil, offer to go to the next group from the end of the previous.
375 If the value is t and the next newsgroup is empty, Gnus will exit
376 summary mode and go back to group mode. If the value is neither nil
377 nor t, Gnus will select the following unread newsgroup. In
378 particular, if the value is the symbol `quietly', the next unread
379 newsgroup will be selected without any confirmation, and if it is
380 `almost-quietly', the next group will be selected without any
381 confirmation if you are located on the last article in the group.
382 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
383 will go to the next group without confirmation."
384 :group 'gnus-summary-maneuvering
385 :type '(choice (const :tag "off" nil)
387 (const almost-quietly)
388 (const slightly-quietly)
389 (sexp :menu-tag "on" t)))
391 (defcustom gnus-auto-select-same nil
392 "*If non-nil, select the next article with the same subject.
393 If there are no more articles with the same subject, go to
394 the first unread article."
395 :group 'gnus-summary-maneuvering
398 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
399 "What article should be selected after exiting an ephemeral group.
400 Valid values include:
403 Select the next article.
405 Select the next unread article.
407 Move the cursor to the next article. This is the default.
408 `next-unread-noselect'
409 Move the cursor to the next unread article.
411 If it has any other value or there is no next (unread) article, the
412 article selected before entering to the ephemeral group will appear."
413 :version "23.1" ;; No Gnus
414 :group 'gnus-summary-maneuvering
415 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
416 (const next) (const next-unread)
417 (const next-noselect) (const next-unread-noselect)
418 (sexp :tag "other" :value nil)))
420 (defcustom gnus-auto-goto-ignores 'unfetched
421 "*Says how to handle unfetched articles when maneuvering.
423 This variable can either be the symbols nil (maneuver to any
424 article), `undownloaded' (maneuvering while unplugged ignores articles
425 that have not been fetched), `always-undownloaded' (maneuvering always
426 ignores articles that have not been fetched), `unfetched' (maneuvering
427 ignores articles whose headers have not been fetched).
429 NOTE: The list of unfetched articles will always be nil when plugged
430 and, when unplugged, a subset of the undownloaded article list."
432 :group 'gnus-summary-maneuvering
433 :type '(choice (const :tag "None" nil)
434 (const :tag "Undownloaded when unplugged" undownloaded)
435 (const :tag "Undownloaded" always-undownloaded)
436 (const :tag "Unfetched" unfetched)))
438 (defcustom gnus-summary-check-current nil
439 "*If non-nil, consider the current article when moving.
440 The \"unread\" movement commands will stay on the same line if the
441 current article is unread."
442 :group 'gnus-summary-maneuvering
445 (defcustom gnus-auto-center-summary 2
446 "*If non-nil, always center the current summary buffer.
447 In particular, if `vertical' do only vertical recentering. If non-nil
448 and non-`vertical', do both horizontal and vertical recentering."
449 :group 'gnus-summary-maneuvering
450 :type '(choice (const :tag "none" nil)
452 (integer :tag "height")
453 (sexp :menu-tag "both" t)))
455 (defcustom gnus-auto-center-group t
456 "If non-nil, always center the group buffer."
457 :group 'gnus-summary-maneuvering
460 (defcustom gnus-show-all-headers nil
461 "*If non-nil, don't hide any headers."
462 :group 'gnus-article-hiding
463 :group 'gnus-article-headers
466 (defcustom gnus-summary-ignore-duplicates nil
467 "*If non-nil, ignore articles with identical Message-ID headers."
471 (defcustom gnus-single-article-buffer nil
472 "*If non-nil, display all articles in the same buffer.
473 If nil, each group will get its own article buffer."
475 :group 'gnus-article-various
478 (defcustom gnus-widen-article-window nil
479 "If non-nil, selecting the article buffer will display only the article buffer."
481 :group 'gnus-article-various
484 (defcustom gnus-break-pages t
485 "*If non-nil, do page breaking on articles.
486 The page delimiter is specified by the `gnus-page-delimiter'
488 :group 'gnus-article-various
491 (defcustom gnus-move-split-methods nil
492 "*Variable used to suggest where articles are to be moved to.
493 It uses the same syntax as the `gnus-split-methods' variable.
494 However, whereas `gnus-split-methods' specifies file names as targets,
495 this variable specifies group names."
496 :group 'gnus-summary-mail
497 :type '(repeat (choice (list :value (fun) function)
498 (cons :value ("" "") regexp (repeat string))
501 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
502 "Function used to compute default prefix for article move/copy/etc prompts.
503 The function should take one argument, a group name, and return a
504 string with the suggested prefix."
505 :group 'gnus-summary-mail
508 ;; FIXME: Although the custom type is `character' for the following variables,
509 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
511 (defcustom gnus-unread-mark ? ;Whitespace
512 "*Mark used for unread articles."
513 :group 'gnus-summary-marks
516 (defcustom gnus-ticked-mark ?!
517 "*Mark used for ticked articles."
518 :group 'gnus-summary-marks
521 (defcustom gnus-dormant-mark ??
522 "*Mark used for dormant articles."
523 :group 'gnus-summary-marks
526 (defcustom gnus-del-mark ?r
527 "*Mark used for del'd articles."
528 :group 'gnus-summary-marks
531 (defcustom gnus-read-mark ?R
532 "*Mark used for read articles."
533 :group 'gnus-summary-marks
536 (defcustom gnus-expirable-mark ?E
537 "*Mark used for expirable articles."
538 :group 'gnus-summary-marks
541 (defcustom gnus-killed-mark ?K
542 "*Mark used for killed articles."
543 :group 'gnus-summary-marks
546 (defcustom gnus-spam-mark ?$
547 "*Mark used for spam articles."
549 :group 'gnus-summary-marks
552 (defcustom gnus-kill-file-mark ?X
553 "*Mark used for articles killed by kill files."
554 :group 'gnus-summary-marks
557 (defcustom gnus-low-score-mark ?Y
558 "*Mark used for articles with a low score."
559 :group 'gnus-summary-marks
562 (defcustom gnus-catchup-mark ?C
563 "*Mark used for articles that are caught up."
564 :group 'gnus-summary-marks
567 (defcustom gnus-replied-mark ?A
568 "*Mark used for articles that have been replied to."
569 :group 'gnus-summary-marks
572 (defcustom gnus-forwarded-mark ?F
573 "*Mark used for articles that have been forwarded."
575 :group 'gnus-summary-marks
578 (defcustom gnus-recent-mark ?N
579 "*Mark used for articles that are recent."
581 :group 'gnus-summary-marks
584 (defcustom gnus-cached-mark ?*
585 "*Mark used for articles that are in the cache."
586 :group 'gnus-summary-marks
589 (defcustom gnus-saved-mark ?S
590 "*Mark used for articles that have been saved."
591 :group 'gnus-summary-marks
594 (defcustom gnus-unseen-mark ?.
595 "*Mark used for articles that haven't been seen."
597 :group 'gnus-summary-marks
600 (defcustom gnus-no-mark ? ;Whitespace
601 "*Mark used for articles that have no other secondary mark."
603 :group 'gnus-summary-marks
606 (defcustom gnus-ancient-mark ?O
607 "*Mark used for ancient articles."
608 :group 'gnus-summary-marks
611 (defcustom gnus-sparse-mark ?Q
612 "*Mark used for sparsely reffed articles."
613 :group 'gnus-summary-marks
616 (defcustom gnus-canceled-mark ?G
617 "*Mark used for canceled articles."
618 :group 'gnus-summary-marks
621 (defcustom gnus-duplicate-mark ?M
622 "*Mark used for duplicate articles."
623 :group 'gnus-summary-marks
626 (defcustom gnus-undownloaded-mark ?-
627 "*Mark used for articles that weren't downloaded."
629 :group 'gnus-summary-marks
632 (defcustom gnus-downloaded-mark ?+
633 "*Mark used for articles that were downloaded."
634 :group 'gnus-summary-marks
637 (defcustom gnus-downloadable-mark ?%
638 "*Mark used for articles that are to be downloaded."
639 :group 'gnus-summary-marks
642 (defcustom gnus-unsendable-mark ?=
643 "*Mark used for articles that won't be sent."
644 :group 'gnus-summary-marks
647 (defcustom gnus-score-over-mark ?+
648 "*Score mark used for articles with high scores."
649 :group 'gnus-summary-marks
652 (defcustom gnus-score-below-mark ?-
653 "*Score mark used for articles with low scores."
654 :group 'gnus-summary-marks
657 (defcustom gnus-empty-thread-mark ? ;Whitespace
658 "*There is no thread under the article."
659 :group 'gnus-summary-marks
662 (defcustom gnus-not-empty-thread-mark ?=
663 "*There is a thread under the article."
664 :group 'gnus-summary-marks
667 (defcustom gnus-view-pseudo-asynchronously nil
668 "*If non-nil, Gnus will view pseudo-articles asynchronously."
669 :group 'gnus-extract-view
672 (defcustom gnus-auto-expirable-marks
673 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
674 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
676 "*The list of marks converted into expiration if a group is auto-expirable."
679 :type '(repeat character))
681 (defcustom gnus-inhibit-user-auto-expire t
682 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
687 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
688 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
689 If nil, the expirable marks will be unchanged except that the marks
690 will be removed when copying or moving articles to a group that has
691 not turned auto-expire on. If non-nil, articles that have been read
692 will be marked as expirable when being copied or moved to a group in
693 which auto-expire is turned on."
696 :group 'gnus-summary-marks)
698 (defcustom gnus-view-pseudos nil
699 "*If `automatic', pseudo-articles will be viewed automatically.
700 If `not-confirm', pseudos will be viewed automatically, and the user
701 will not be asked to confirm the command."
702 :group 'gnus-extract-view
703 :type '(choice (const :tag "off" nil)
705 (const not-confirm)))
707 (defcustom gnus-view-pseudos-separately t
708 "*If non-nil, one pseudo-article will be created for each file to be viewed.
709 If nil, all files that use the same viewing command will be given as a
710 list of parameters to that command."
711 :group 'gnus-extract-view
714 (defcustom gnus-insert-pseudo-articles t
715 "*If non-nil, insert pseudo-articles when decoding articles."
716 :group 'gnus-extract-view
719 (defcustom gnus-summary-dummy-line-format
721 "*The format specification for the dummy roots in the summary buffer.
722 It works along the same lines as a normal formatting string,
723 with some simple extensions.
727 General format specifiers can also be used.
728 See `(gnus)Formatting Variables'."
729 :link '(custom-manual "(gnus)Formatting Variables")
730 :group 'gnus-threading
733 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
734 "*The format specification for the summary mode line.
735 It works along the same lines as a normal formatting string,
736 with some simple extensions:
739 %p Unprefixed group name
740 %A Current article number
741 %z Current article score
743 %U Number of unread articles in the group
744 %e Number of unselected articles in the group
745 %Z A string with unread/unselected article counts
746 %g Shortish group name
747 %S Subject of the current article
749 %s Current score file name
750 %d Number of dormant articles
751 %r Number of articles that have been marked as read in this session
752 %E Number of articles expunged by the score files"
753 :group 'gnus-summary-format
756 (defcustom gnus-list-identifiers nil
757 "Regexp that matches list identifiers to be removed from subject.
758 This can also be a list of regexps."
760 :group 'gnus-summary-format
761 :group 'gnus-article-hiding
762 :type '(choice (const :tag "none" nil)
764 (repeat :value (".*") regexp)))
766 (defcustom gnus-summary-mark-below 0
767 "*Mark all articles with a score below this variable as read.
768 This variable is local to each summary buffer and usually set by the
770 :group 'gnus-score-default
773 (defun gnus-widget-reversible-match (widget value)
774 "Ignoring WIDGET, convert VALUE to internal form.
775 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
779 (eq (length value) 2)
780 (eq (nth 0 value) 'not)
781 (symbolp (nth 1 value)))))
783 (defun gnus-widget-reversible-to-internal (widget value)
784 "Ignoring WIDGET, convert VALUE to internal form.
785 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
786 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
790 (list (nth 1 value) t)))
792 (defun gnus-widget-reversible-to-external (widget value)
793 "Ignoring WIDGET, convert VALUE to external form.
794 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
795 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
798 (list 'not (nth 0 value))
801 (define-widget 'gnus-widget-reversible 'group
802 "A `group' that convert values."
803 :match 'gnus-widget-reversible-match
804 :value-to-internal 'gnus-widget-reversible-to-internal
805 :value-to-external 'gnus-widget-reversible-to-external)
807 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
808 "*List of functions used for sorting articles in the summary buffer.
810 Each function takes two articles and returns non-nil if the first
811 article should be sorted before the other. If you use more than one
812 function, the primary sort function should be the last. You should
813 probably always include `gnus-article-sort-by-number' in the list of
814 sorting functions -- preferably first. Also note that sorting by date
815 is often much slower than sorting by number, and the sorting order is
816 very similar. (Sorting by date means sorting by the time the message
817 was sent, sorting by number means sorting by arrival time.)
819 Each item can also be a list `(not F)' where F is a function;
820 this reverses the sort order.
822 Ready-made functions include `gnus-article-sort-by-number',
823 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
824 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
825 and `gnus-article-sort-by-score'.
827 When threading is turned on, the variable `gnus-thread-sort-functions'
828 controls how articles are sorted."
829 :group 'gnus-summary-sort
830 :type '(repeat (gnus-widget-reversible
831 (choice (function-item gnus-article-sort-by-number)
832 (function-item gnus-article-sort-by-author)
833 (function-item gnus-article-sort-by-subject)
834 (function-item gnus-article-sort-by-date)
835 (function-item gnus-article-sort-by-score)
836 (function-item gnus-article-sort-by-random)
837 (function :tag "other"))
838 (boolean :tag "Reverse order"))))
841 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
842 "*List of functions used for sorting threads in the summary buffer.
843 By default, threads are sorted by article number.
845 Each function takes two threads and returns non-nil if the first
846 thread should be sorted before the other. If you use more than one
847 function, the primary sort function should be the last. You should
848 probably always include `gnus-thread-sort-by-number' in the list of
849 sorting functions -- preferably first. Also note that sorting by date
850 is often much slower than sorting by number, and the sorting order is
851 very similar. (Sorting by date means sorting by the time the message
852 was sent, sorting by number means sorting by arrival time.)
854 Each list item can also be a list `(not F)' where F is a
855 function; this specifies reversed sort order.
857 Ready-made functions include `gnus-thread-sort-by-number',
858 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
859 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
860 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
861 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
862 and `gnus-thread-sort-by-total-score' (see
863 `gnus-thread-score-function').
865 When threading is turned off, the variable
866 `gnus-article-sort-functions' controls how articles are sorted."
867 :group 'gnus-summary-sort
869 (gnus-widget-reversible
870 (choice (function-item gnus-thread-sort-by-number)
871 (function-item gnus-thread-sort-by-author)
872 (function-item gnus-thread-sort-by-recipient)
873 (function-item gnus-thread-sort-by-subject)
874 (function-item gnus-thread-sort-by-date)
875 (function-item gnus-thread-sort-by-score)
876 (function-item gnus-thread-sort-by-most-recent-number)
877 (function-item gnus-thread-sort-by-most-recent-date)
878 (function-item gnus-thread-sort-by-random)
879 (function-item gnus-thread-sort-by-total-score)
880 (function :tag "other"))
881 (boolean :tag "Reverse order"))))
883 (defcustom gnus-thread-score-function '+
884 "*Function used for calculating the total score of a thread.
886 The function is called with the scores of the article and each
887 subthread and should then return the score of the thread.
889 Some functions you can use are `+', `max', or `min'."
890 :group 'gnus-summary-sort
893 (defcustom gnus-summary-expunge-below nil
894 "All articles that have a score less than this variable will be expunged.
895 This variable is local to the summary buffers."
896 :group 'gnus-score-default
897 :type '(choice (const :tag "off" nil)
900 (defcustom gnus-thread-expunge-below nil
901 "All threads that have a total score less than this variable will be expunged.
902 See `gnus-thread-score-function' for en explanation of what a
905 This variable is local to the summary buffers."
906 :group 'gnus-threading
907 :group 'gnus-score-default
908 :type '(choice (const :tag "off" nil)
911 (defcustom gnus-summary-mode-hook nil
912 "*A hook for Gnus summary mode.
913 This hook is run before any variables are set in the summary buffer."
914 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
915 :group 'gnus-summary-various
918 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
919 (when (featurep 'xemacs)
920 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
921 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
922 (add-hook 'gnus-summary-mode-hook
923 'gnus-xmas-switch-horizontal-scrollbar-off))
925 (defcustom gnus-summary-menu-hook nil
926 "*Hook run after the creation of the summary mode menu."
927 :group 'gnus-summary-visual
930 (defcustom gnus-summary-exit-hook nil
931 "*A hook called on exit from the summary buffer.
932 It will be called with point in the group buffer."
933 :group 'gnus-summary-exit
936 (defcustom gnus-summary-prepare-hook nil
937 "*A hook called after the summary buffer has been generated.
938 If you want to modify the summary buffer, you can use this hook."
939 :group 'gnus-summary-various
942 (defcustom gnus-summary-prepared-hook nil
943 "*A hook called as the last thing after the summary buffer has been generated."
944 :group 'gnus-summary-various
947 (defcustom gnus-summary-generate-hook nil
948 "*A hook run just before generating the summary buffer.
949 This hook is commonly used to customize threading variables and the
951 :group 'gnus-summary-various
954 (defcustom gnus-select-group-hook nil
955 "*A hook called when a newsgroup is selected.
957 If you'd like to simplify subjects like the
958 `gnus-summary-next-same-subject' command does, you can use the
961 (add-hook gnus-select-group-hook
963 (mapcar (lambda (header)
964 (mail-header-set-subject
966 (gnus-simplify-subject
967 (mail-header-subject header) 're-only)))
968 gnus-newsgroup-headers)))"
969 :group 'gnus-group-select
972 (defcustom gnus-select-article-hook nil
973 "*A hook called when an article is selected."
974 :group 'gnus-summary-choose
975 :options '(gnus-agent-fetch-selected-article)
978 (defcustom gnus-visual-mark-article-hook
979 (list 'gnus-highlight-selected-summary)
980 "*Hook run after selecting an article in the summary buffer.
981 It is meant to be used for highlighting the article in some way. It
982 is not run if `gnus-visual' is nil."
983 :group 'gnus-summary-visual
986 (defcustom gnus-parse-headers-hook nil
987 "*A hook called before parsing the headers."
991 (defcustom gnus-exit-group-hook nil
992 "*A hook called when exiting summary mode.
993 This hook is not called from the non-updating exit commands like `Q'."
997 (defcustom gnus-summary-update-hook nil
998 "*A hook called when a summary line is changed.
999 The hook will not be called if `gnus-visual' is nil.
1001 The default function `gnus-summary-highlight-line' will
1002 highlight the line according to the `gnus-summary-highlight'
1004 :group 'gnus-summary-visual
1007 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1008 "*A hook called when an article is selected for the first time.
1009 The hook is intended to mark an article as read (or unread)
1010 automatically when it is selected."
1011 :group 'gnus-summary-choose
1014 (defcustom gnus-group-no-more-groups-hook nil
1015 "*A hook run when returning to group mode having no more (unread) groups."
1016 :group 'gnus-group-select
1019 (defcustom gnus-ps-print-hook nil
1020 "*A hook run before ps-printing something from Gnus."
1021 :group 'gnus-summary
1024 (defcustom gnus-summary-article-move-hook nil
1025 "*A hook called after an article is moved, copied, respooled, or crossposted."
1027 :group 'gnus-summary
1030 (defcustom gnus-summary-article-delete-hook nil
1031 "*A hook called after an article is deleted."
1033 :group 'gnus-summary
1036 (defcustom gnus-summary-article-expire-hook nil
1037 "*A hook called after an article is expired."
1039 :group 'gnus-summary
1042 (defcustom gnus-summary-display-arrow
1043 (and (fboundp 'display-graphic-p)
1044 (display-graphic-p))
1045 "*If non-nil, display an arrow highlighting the current article."
1047 :group 'gnus-summary
1050 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1051 "Face used for highlighting the current article in the summary buffer."
1052 :group 'gnus-summary-visual
1055 (defvar gnus-tmp-downloaded nil)
1057 (defcustom gnus-summary-highlight
1058 '(((eq mark gnus-canceled-mark)
1059 . gnus-summary-cancelled)
1060 ((and uncached (> score default-high))
1061 . gnus-summary-high-undownloaded)
1062 ((and uncached (< score default-low))
1063 . gnus-summary-low-undownloaded)
1065 . gnus-summary-normal-undownloaded)
1066 ((and (> score default-high)
1067 (or (eq mark gnus-dormant-mark)
1068 (eq mark gnus-ticked-mark)))
1069 . gnus-summary-high-ticked)
1070 ((and (< score default-low)
1071 (or (eq mark gnus-dormant-mark)
1072 (eq mark gnus-ticked-mark)))
1073 . gnus-summary-low-ticked)
1074 ((or (eq mark gnus-dormant-mark)
1075 (eq mark gnus-ticked-mark))
1076 . gnus-summary-normal-ticked)
1077 ((and (> score default-high) (eq mark gnus-ancient-mark))
1078 . gnus-summary-high-ancient)
1079 ((and (< score default-low) (eq mark gnus-ancient-mark))
1080 . gnus-summary-low-ancient)
1081 ((eq mark gnus-ancient-mark)
1082 . gnus-summary-normal-ancient)
1083 ((and (> score default-high) (eq mark gnus-unread-mark))
1084 . gnus-summary-high-unread)
1085 ((and (< score default-low) (eq mark gnus-unread-mark))
1086 . gnus-summary-low-unread)
1087 ((eq mark gnus-unread-mark)
1088 . gnus-summary-normal-unread)
1089 ((> score default-high)
1090 . gnus-summary-high-read)
1091 ((< score default-low)
1092 . gnus-summary-low-read)
1094 . gnus-summary-normal-read))
1095 "*Controls the highlighting of summary buffer lines.
1097 A list of (FORM . FACE) pairs. When deciding how a particular
1098 summary line should be displayed, each form is evaluated. The content
1099 of the face field after the first true form is used. You can change
1100 how those summary lines are displayed, by editing the face field.
1102 You can use the following variables in the FORM field.
1104 score: The article's score.
1105 default: The default article score.
1106 default-high: The default score for high scored articles.
1107 default-low: The default score for low scored articles.
1108 below: The score below which articles are automatically marked as read.
1109 mark: The article's mark.
1110 uncached: Non-nil if the article is uncached."
1111 :group 'gnus-summary-visual
1112 :type '(repeat (cons (sexp :tag "Form" nil)
1114 (put 'gnus-summary-highlight 'risky-local-variable t)
1116 (defcustom gnus-alter-header-function nil
1117 "Function called to allow alteration of article header structures.
1118 The function is called with one parameter, the article header vector,
1119 which it may alter in any way."
1120 :type '(choice (const :tag "None" nil)
1122 :group 'gnus-summary)
1124 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1125 "Function used to decode a string with encoded words.")
1127 (defvar gnus-decode-encoded-address-function
1128 'mail-decode-encoded-address-string
1129 "Function used to decode addresses with encoded words.")
1131 (defcustom gnus-extra-headers '(To Newsgroups)
1132 "*Extra headers to parse."
1134 :group 'gnus-summary
1135 :type '(repeat symbol))
1137 (defcustom gnus-ignored-from-addresses
1138 (and user-mail-address
1139 (not (string= user-mail-address ""))
1140 (regexp-quote user-mail-address))
1141 "*From headers that may be suppressed in favor of To headers.
1142 This can be a regexp or a list of regexps."
1144 :group 'gnus-summary
1145 :type '(choice regexp
1146 (repeat :tag "Regexp List" regexp)))
1148 (defsubst gnus-ignored-from-addresses ()
1149 (gmm-regexp-concat gnus-ignored-from-addresses))
1151 (defcustom gnus-summary-to-prefix "-> "
1152 "*String prefixed to the To field in the summary line when
1153 using `gnus-ignored-from-addresses'."
1155 :group 'gnus-summary
1158 (defcustom gnus-summary-newsgroup-prefix "=> "
1159 "*String prefixed to the Newsgroup field in the summary
1160 line when using `gnus-ignored-from-addresses'."
1162 :group 'gnus-summary
1165 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1166 "List of charsets that should be ignored.
1167 When these charsets are used in the \"charset\" parameter, the
1168 default charset will be used instead."
1170 :type '(repeat symbol)
1171 :group 'gnus-charset)
1173 (defcustom gnus-newsgroup-maximum-articles nil
1174 "The maximum number of articles a newsgroup.
1175 If this is a number, old articles in a newsgroup exceeding this number
1176 are silently ignored. If it is nil, no article is ignored. Note that
1177 setting this variable to a number might prevent you from reading very
1179 :group 'gnus-group-select
1181 :type '(choice (const :tag "No limit" nil)
1184 (gnus-define-group-parameter
1188 "Return the ignored charsets of GROUP."
1189 :variable gnus-group-ignored-charsets-alist
1191 '(("alt\\.chinese\\.text" iso-8859-1))
1193 "Alist of regexps (to match group names) and charsets that should be ignored.
1194 When these charsets are used in the \"charset\" parameter, the
1195 default charset will be used instead."
1196 :variable-group gnus-charset
1197 :variable-type '(repeat (cons (regexp :tag "Group")
1199 :parameter-type '(choice :tag "Ignored charsets"
1202 :parameter-document "\
1203 List of charsets that should be ignored.
1205 When these charsets are used in the \"charset\" parameter, the
1206 default charset will be used instead.")
1208 (defcustom gnus-group-highlight-words-alist nil
1209 "Alist of group regexps and highlight regexps.
1210 This variable uses the same syntax as `gnus-emphasis-alist'."
1212 :type '(repeat (cons (regexp :tag "Group")
1213 (repeat (list (regexp :tag "Highlight regexp")
1214 (number :tag "Group for entire word" 0)
1215 (number :tag "Group for displayed part" 0)
1217 gnus-emphasis-highlight-words)))))
1218 :group 'gnus-summary-visual)
1220 (defcustom gnus-summary-show-article-charset-alist
1222 "Alist of number and charset.
1223 The article will be shown with the charset corresponding to the
1225 For example: ((1 . cn-gb-2312) (2 . big5))."
1227 :type '(repeat (cons (number :tag "Argument" 1)
1228 (symbol :tag "Charset")))
1229 :group 'gnus-charset)
1231 (defcustom gnus-preserve-marks t
1232 "Whether marks are preserved when moving, copying and respooling messages."
1235 :group 'gnus-summary-marks)
1237 (defcustom gnus-propagate-marks t
1238 "If non-nil, do not propagate marks to the backends."
1239 :version "23.1" ;; No Gnus
1241 :group 'gnus-summary-marks)
1243 (defcustom gnus-alter-articles-to-read-function nil
1244 "Function to be called to alter the list of articles to be selected."
1245 :type '(choice (const nil) function)
1246 :group 'gnus-summary)
1248 (defcustom gnus-orphan-score nil
1249 "*All orphans get this score added. Set in the score file."
1250 :group 'gnus-score-default
1251 :type '(choice (const nil)
1254 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1255 "*A regexp to match MIME parts when saving multiple parts of a
1256 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1257 This regexp will be used by default when prompting the user for which
1258 type of files to save."
1259 :group 'gnus-summary
1262 (defcustom gnus-read-all-available-headers nil
1263 "Whether Gnus should parse all headers made available to it.
1264 This is mostly relevant for slow back ends where the user may
1265 wish to widen the summary buffer to include all headers
1268 :group 'gnus-summary
1269 :type '(choice boolean regexp))
1271 (defcustom gnus-summary-pipe-output-default-command nil
1272 "Command (and optional arguments) used to pipe article to subprocess.
1273 This will be used as the default command if it is non-nil. The value
1274 will be updated if you modify it when executing the command
1275 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1276 :version "23.1" ;; No Gnus
1277 :group 'gnus-summary
1278 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1280 (defcustom gnus-summary-muttprint-program "muttprint"
1281 "Command (and optional arguments) used to run Muttprint.
1282 The value will be updated if you modify it when executing the command
1283 `gnus-summary-muttprint'."
1285 :group 'gnus-summary
1288 (defcustom gnus-article-loose-mime t
1289 "If non-nil, don't require MIME-Version header.
1290 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1291 supply the MIME-Version header or deliberately strip it from the mail.
1292 If non-nil (the default), Gnus will treat some articles as MIME
1293 even if the MIME-Version header is missing."
1296 :group 'gnus-article-mime)
1298 (defcustom gnus-article-emulate-mime t
1299 "If non-nil, use MIME emulation for uuencode and the like.
1300 This means that Gnus will search message bodies for text that look
1301 like uuencoded bits, yEncoded bits, and so on, and present that using
1302 the normal Gnus MIME machinery."
1305 :group 'gnus-article-mime)
1307 ;;; Internal variables
1309 (defvar gnus-summary-display-cache nil)
1310 (defvar gnus-article-mime-handles nil)
1311 (defvar gnus-article-decoded-p nil)
1312 (defvar gnus-article-charset nil)
1313 (defvar gnus-article-ignored-charsets nil)
1314 (defvar gnus-scores-exclude-files nil)
1315 (defvar gnus-page-broken nil)
1317 (defvar gnus-original-article nil)
1318 (defvar gnus-article-internal-prepare-hook nil)
1319 (defvar gnus-newsgroup-process-stack nil)
1321 (defvar gnus-thread-indent-array nil)
1322 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1323 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1324 "Function called to sort the articles within a thread after it has been gathered together.")
1326 (defvar gnus-summary-save-parts-type-history nil)
1327 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1329 ;; Avoid highlighting in kill files.
1330 (defvar gnus-summary-inhibit-highlight nil)
1331 (defvar gnus-newsgroup-selected-overlay nil)
1332 (defvar gnus-inhibit-limiting nil)
1333 (defvar gnus-newsgroup-adaptive-score-file nil)
1334 (defvar gnus-current-score-file nil)
1335 (defvar gnus-current-move-group nil)
1336 (defvar gnus-current-copy-group nil)
1337 (defvar gnus-current-crosspost-group nil)
1338 (defvar gnus-newsgroup-display nil)
1340 (defvar gnus-newsgroup-dependencies nil)
1341 (defvar gnus-newsgroup-adaptive nil)
1342 (defvar gnus-summary-display-article-function nil)
1343 (defvar gnus-summary-highlight-line-function nil
1344 "Function called after highlighting a summary line.")
1346 (defvar gnus-summary-line-format-alist
1347 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1348 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1349 (?s gnus-tmp-subject-or-nil ?s)
1350 (?n gnus-tmp-name ?s)
1351 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1353 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1355 (?F gnus-tmp-from ?s)
1356 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1357 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1358 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1359 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1360 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1361 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1362 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1363 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1364 (?L gnus-tmp-lines ?s)
1365 (?Z (or ,(gnus-macroexpand-all
1366 '(nnir-article-rsv (mail-header-number gnus-tmp-header)))
1368 (?G (or ,(gnus-macroexpand-all
1369 '(nnir-article-group (mail-header-number gnus-tmp-header)))
1371 (?g (or ,(gnus-macroexpand-all
1372 '(gnus-group-short-name
1373 (nnir-article-group (mail-header-number gnus-tmp-header))))
1375 (?O gnus-tmp-downloaded ?c)
1376 (?I gnus-tmp-indentation ?s)
1377 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1378 (?R gnus-tmp-replied ?c)
1379 (?\[ gnus-tmp-opening-bracket ?c)
1380 (?\] gnus-tmp-closing-bracket ?c)
1381 (?\> (make-string gnus-tmp-level ? ) ?s)
1382 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1383 (?i gnus-tmp-score ?d)
1384 (?z gnus-tmp-score-char ?c)
1385 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1386 (?U gnus-tmp-unread ?c)
1387 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1389 (?t (gnus-summary-number-of-articles-in-thread
1390 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1392 (?e (gnus-summary-number-of-articles-in-thread
1393 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1395 (?u gnus-tmp-user-defined ?s)
1396 (?P (gnus-pick-line-number) ?d)
1397 (?B gnus-tmp-thread-tree-header-string ?s)
1398 (user-date (gnus-summary-user-date
1399 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1400 "An alist of format specifications that can appear in summary lines.
1401 These are paired with what variables they correspond with, along with
1402 the type of the variable (string, integer, character, etc).")
1404 (defvar gnus-summary-dummy-line-format-alist
1405 `((?S gnus-tmp-subject ?s)
1406 (?N gnus-tmp-number ?d)
1407 (?u gnus-tmp-user-defined ?s)))
1409 (defvar gnus-summary-mode-line-format-alist
1410 `((?G gnus-tmp-group-name ?s)
1411 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1412 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1413 (?A gnus-tmp-article-number ?d)
1414 (?Z gnus-tmp-unread-and-unselected ?s)
1415 (?V gnus-version ?s)
1416 (?U gnus-tmp-unread-and-unticked ?d)
1417 (?S gnus-tmp-subject ?s)
1418 (?e gnus-tmp-unselected ?d)
1419 (?u gnus-tmp-user-defined ?s)
1420 (?d (length gnus-newsgroup-dormant) ?d)
1421 (?t (length gnus-newsgroup-marked) ?d)
1422 (?h (length gnus-newsgroup-spam-marked) ?d)
1423 (?r (length gnus-newsgroup-reads) ?d)
1424 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1425 (?E gnus-newsgroup-expunged-tally ?d)
1426 (?s (gnus-current-score-file-nondirectory) ?s)))
1428 ;; This is here rather than in gnus-art for compilation reasons.
1429 (defvar gnus-article-mode-line-format-alist
1430 (nconc '((?w (gnus-article-wash-status) ?s)
1431 (?m (gnus-article-mime-part-status) ?s))
1432 gnus-summary-mode-line-format-alist))
1434 (defvar gnus-last-search-regexp nil
1435 "Default regexp for article search command.")
1437 (defvar gnus-last-shell-command nil
1438 "Default shell command on article.")
1440 (defvar gnus-newsgroup-agentized nil
1441 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1442 (defvar gnus-newsgroup-begin nil)
1443 (defvar gnus-newsgroup-end nil)
1444 (defvar gnus-newsgroup-last-rmail nil)
1445 (defvar gnus-newsgroup-last-mail nil)
1446 (defvar gnus-newsgroup-last-folder nil)
1447 (defvar gnus-newsgroup-last-file nil)
1448 (defvar gnus-newsgroup-last-directory nil)
1449 (defvar gnus-newsgroup-auto-expire nil)
1450 (defvar gnus-newsgroup-active nil)
1451 (defvar gnus-newsgroup-highest nil)
1453 (defvar gnus-newsgroup-data nil)
1454 (defvar gnus-newsgroup-data-reverse nil)
1455 (defvar gnus-newsgroup-limit nil)
1456 (defvar gnus-newsgroup-limits nil)
1457 (defvar gnus-summary-use-undownloaded-faces nil)
1459 (defvar gnus-newsgroup-unreads nil
1460 "Sorted list of unread articles in the current newsgroup.")
1462 (defvar gnus-newsgroup-unselected nil
1463 "Sorted list of unselected unread articles in the current newsgroup.")
1465 (defvar gnus-newsgroup-reads nil
1466 "Alist of read articles and article marks in the current newsgroup.")
1468 (defvar gnus-newsgroup-expunged-tally nil)
1470 (defvar gnus-newsgroup-marked nil
1471 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1473 (defvar gnus-newsgroup-spam-marked nil
1474 "List of ranges of articles that have been marked as spam.")
1476 (defvar gnus-newsgroup-killed nil
1477 "List of ranges of articles that have been through the scoring process.")
1479 (defvar gnus-newsgroup-cached nil
1480 "Sorted list of articles that come from the article cache.")
1482 (defvar gnus-newsgroup-saved nil
1483 "List of articles that have been saved.")
1485 (defvar gnus-newsgroup-kill-headers nil)
1487 (defvar gnus-newsgroup-replied nil
1488 "List of articles that have been replied to in the current newsgroup.")
1490 (defvar gnus-newsgroup-forwarded nil
1491 "List of articles that have been forwarded in the current newsgroup.")
1493 (defvar gnus-newsgroup-recent nil
1494 "List of articles that have are recent in the current newsgroup.")
1496 (defvar gnus-newsgroup-expirable nil
1497 "Sorted list of articles in the current newsgroup that can be expired.")
1499 (defvar gnus-newsgroup-processable nil
1500 "List of articles in the current newsgroup that can be processed.")
1502 (defvar gnus-newsgroup-downloadable nil
1503 "Sorted list of articles in the current newsgroup that can be processed.")
1505 (defvar gnus-newsgroup-unfetched nil
1506 "Sorted list of articles in the current newsgroup whose headers have
1507 not been fetched into the agent.
1509 This list will always be a subset of gnus-newsgroup-undownloaded.")
1511 (defvar gnus-newsgroup-undownloaded nil
1512 "List of articles in the current newsgroup that haven't been downloaded.")
1514 (defvar gnus-newsgroup-unsendable nil
1515 "List of articles in the current newsgroup that won't be sent.")
1517 (defvar gnus-newsgroup-bookmarks nil
1518 "List of articles in the current newsgroup that have bookmarks.")
1520 (defvar gnus-newsgroup-dormant nil
1521 "Sorted list of dormant articles in the current newsgroup.")
1523 (defvar gnus-newsgroup-unseen nil
1524 "List of unseen articles in the current newsgroup.")
1526 (defvar gnus-newsgroup-seen nil
1527 "Range of seen articles in the current newsgroup.")
1529 (defvar gnus-newsgroup-articles nil
1530 "List of articles in the current newsgroup.")
1532 (defvar gnus-newsgroup-scored nil
1533 "List of scored articles in the current newsgroup.")
1535 (defvar gnus-newsgroup-headers nil
1536 "List of article headers in the current newsgroup.")
1538 (defvar gnus-newsgroup-threads nil)
1540 (defvar gnus-newsgroup-prepared nil
1541 "Whether the current group has been prepared properly.")
1543 (defvar gnus-newsgroup-ancient nil
1544 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1546 (defvar gnus-newsgroup-sparse nil)
1548 (defvar gnus-current-article nil)
1549 (defvar gnus-article-current nil)
1550 (defvar gnus-current-headers nil)
1551 (defvar gnus-have-all-headers nil)
1552 (defvar gnus-last-article nil)
1553 (defvar gnus-newsgroup-history nil)
1554 (defvar gnus-newsgroup-charset nil)
1555 (defvar gnus-newsgroup-ephemeral-charset nil)
1556 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1558 (defvar gnus-article-before-search nil)
1560 (defvar gnus-summary-local-variables
1561 '(gnus-newsgroup-name
1564 gnus-newsgroup-unreads
1565 gnus-newsgroup-unselected
1566 gnus-newsgroup-marked
1567 gnus-newsgroup-spam-marked
1568 gnus-newsgroup-reads
1569 gnus-newsgroup-saved
1570 gnus-newsgroup-replied
1571 gnus-newsgroup-forwarded
1572 gnus-newsgroup-recent
1573 gnus-newsgroup-expirable
1574 gnus-newsgroup-killed
1575 gnus-newsgroup-unseen
1577 gnus-newsgroup-cached
1578 gnus-newsgroup-downloadable
1579 gnus-newsgroup-undownloaded
1580 gnus-newsgroup-unsendable
1582 gnus-newsgroup-begin gnus-newsgroup-end
1583 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1584 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1585 gnus-newsgroup-last-directory
1586 gnus-newsgroup-auto-expire
1587 gnus-newsgroup-processable
1588 gnus-newsgroup-unfetched
1589 gnus-newsgroup-articles
1590 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1591 gnus-newsgroup-headers gnus-newsgroup-threads
1592 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1593 gnus-current-article gnus-current-headers gnus-have-all-headers
1594 gnus-last-article gnus-article-internal-prepare-hook
1595 (gnus-summary-article-delete-hook . global)
1596 (gnus-summary-article-move-hook . global)
1597 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1598 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1599 gnus-thread-expunge-below
1600 gnus-score-alist gnus-current-score-file
1601 (gnus-summary-expunge-below . global)
1602 (gnus-summary-mark-below . global)
1603 (gnus-orphan-score . global)
1604 gnus-newsgroup-active gnus-scores-exclude-files
1605 gnus-newsgroup-highest
1606 gnus-newsgroup-history gnus-newsgroup-ancient
1607 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1608 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1609 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1610 (gnus-newsgroup-expunged-tally . 0)
1611 gnus-cache-removable-articles
1612 gnus-newsgroup-data gnus-newsgroup-data-reverse
1613 gnus-newsgroup-limit gnus-newsgroup-limits
1614 gnus-newsgroup-charset gnus-newsgroup-display
1615 gnus-summary-use-undownloaded-faces)
1616 "Variables that are buffer-local to the summary buffers.")
1618 (defvar gnus-newsgroup-variables nil
1619 "A list of variables that have separate values in different newsgroups.
1620 A list of newsgroup (summary buffer) local variables, or cons of
1621 variables and their default expressions to be evalled (when the default
1622 values are not nil), that should be made global while the summary buffer
1625 Note: The default expressions will be evaluated (using function `eval')
1626 before assignment to the local variable rather than just assigned to it.
1627 If the default expression is the symbol `global', that symbol will not
1628 be evaluated but the global value of the local variable will be used
1631 These variables can be used to set variables in the group parameters
1632 while still allowing them to affect operations done in other buffers.
1635 \(setq gnus-newsgroup-variables
1636 '(message-use-followup-to
1637 (gnus-visible-headers .
1638 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1642 ;; Bind features so that require will believe that gnus-sum has
1643 ;; already been loaded (avoids infinite recursion)
1644 (let ((features (cons 'gnus-sum features)))
1645 (require 'gnus-art)))
1649 (defvar gnus-decode-encoded-word-methods
1650 '(mail-decode-encoded-word-string)
1651 "List of methods used to decode encoded words.
1653 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1654 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1655 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1656 whose names match REGEXP.
1659 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1660 mail-decode-encoded-word-string
1661 (\"chinese\" . rfc1843-decode-string))")
1663 (defvar gnus-decode-encoded-word-methods-cache nil)
1665 (defun gnus-multi-decode-encoded-word-string (string)
1666 "Apply the functions from `gnus-encoded-word-methods' that match."
1667 (unless (and gnus-decode-encoded-word-methods-cache
1668 (eq gnus-newsgroup-name
1669 (car gnus-decode-encoded-word-methods-cache)))
1670 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1671 (dolist (method gnus-decode-encoded-word-methods)
1672 (if (symbolp method)
1673 (nconc gnus-decode-encoded-word-methods-cache (list method))
1674 (if (and gnus-newsgroup-name
1675 (string-match (car method) gnus-newsgroup-name))
1676 (nconc gnus-decode-encoded-word-methods-cache
1677 (list (cdr method)))))))
1678 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1679 (setq string (funcall method string))))
1681 ;; Subject simplification.
1683 (defun gnus-simplify-whitespace (str)
1684 "Remove excessive whitespace from STR."
1686 (while (string-match "[ \t][ \t]+" str)
1687 (setq str (concat (substring str 0 (match-beginning 0))
1689 (substring str (match-end 0)))))
1691 (when (string-match "^[ \t]+" str)
1692 (setq str (substring str (match-end 0))))
1694 (when (string-match "[ \t]+$" str)
1695 (setq str (substring str 0 (match-beginning 0))))
1698 (defun gnus-simplify-all-whitespace (str)
1699 "Remove all whitespace from STR."
1700 (while (string-match "[ \t\n]+" str)
1701 (setq str (replace-match "" nil nil str)))
1704 (defsubst gnus-simplify-subject-re (subject)
1705 "Remove \"Re:\" from subject lines."
1706 (if (string-match message-subject-re-regexp subject)
1707 (substring subject (match-end 0))
1710 (defun gnus-simplify-subject (subject &optional re-only)
1711 "Remove `Re:' and words in parentheses.
1712 If RE-ONLY is non-nil, strip leading `Re:'s only."
1713 (let ((case-fold-search t)) ;Ignore case.
1714 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1715 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1716 (setq subject (substring subject (match-end 0))))
1717 ;; Remove uninteresting prefixes.
1718 (when (and (not re-only)
1719 gnus-simplify-ignored-prefixes
1720 (string-match gnus-simplify-ignored-prefixes subject))
1721 (setq subject (substring subject (match-end 0))))
1722 ;; Remove words in parentheses from end.
1724 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1725 (setq subject (substring subject 0 (match-beginning 0)))))
1726 ;; Return subject string.
1729 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1731 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1732 (goto-char (point-min))
1733 (while (re-search-forward regexp nil t)
1734 (replace-match (or newtext ""))))
1736 (defun gnus-simplify-buffer-fuzzy ()
1737 "Simplify string in the buffer fuzzily.
1738 The string in the accessible portion of the current buffer is simplified.
1739 It is assumed to be a single-line subject.
1740 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1741 matter is removed. Additional things can be deleted by setting
1742 `gnus-simplify-subject-fuzzy-regexp'."
1743 (let ((case-fold-search t)
1745 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1747 (while (not (eq modified-tick (buffer-modified-tick)))
1748 (setq modified-tick (buffer-modified-tick))
1750 ((listp gnus-simplify-subject-fuzzy-regexp)
1751 (mapc 'gnus-simplify-buffer-fuzzy-step
1752 gnus-simplify-subject-fuzzy-regexp))
1753 (gnus-simplify-subject-fuzzy-regexp
1754 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1755 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1756 (gnus-simplify-buffer-fuzzy-step
1757 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1758 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1760 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1761 (gnus-simplify-buffer-fuzzy-step " +" " ")
1762 (gnus-simplify-buffer-fuzzy-step " $")
1763 (gnus-simplify-buffer-fuzzy-step "^ +")))
1765 (defun gnus-simplify-subject-fuzzy (subject)
1766 "Simplify a subject string fuzzily.
1767 See `gnus-simplify-buffer-fuzzy' for details."
1769 (gnus-set-work-buffer)
1770 (let ((case-fold-search t))
1771 ;; Remove uninteresting prefixes.
1772 (when (and gnus-simplify-ignored-prefixes
1773 (string-match gnus-simplify-ignored-prefixes subject))
1774 (setq subject (substring subject (match-end 0))))
1776 (inline (gnus-simplify-buffer-fuzzy))
1779 (defsubst gnus-simplify-subject-fully (subject)
1780 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1782 (gnus-simplify-subject-functions
1783 (gnus-map-function gnus-simplify-subject-functions subject))
1784 ((null gnus-summary-gather-subject-limit)
1785 (gnus-simplify-subject-re subject))
1786 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1787 (gnus-simplify-subject-fuzzy subject))
1788 ((numberp gnus-summary-gather-subject-limit)
1789 (truncate-string-to-width (gnus-simplify-subject-re subject)
1790 gnus-summary-gather-subject-limit))
1794 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1795 "Check whether two subjects are equal.
1796 If optional argument SIMPLE-FIRST is t, first argument is already
1799 ((null simple-first)
1800 (equal (gnus-simplify-subject-fully s1)
1801 (gnus-simplify-subject-fully s2)))
1804 (gnus-simplify-subject-fully s2)))))
1806 (defun gnus-summary-bubble-group ()
1807 "Increase the score of the current group.
1808 This is a handy function to add to `gnus-summary-exit-hook' to
1809 increase the score of each group you read."
1810 (gnus-group-add-score gnus-newsgroup-name))
1814 ;;; Gnus summary mode
1817 (put 'gnus-summary-mode 'mode-class 'special)
1819 (defvar gnus-article-commands-menu)
1821 ;; Non-orthogonal keys
1823 (gnus-define-keys gnus-summary-mode-map
1824 " " gnus-summary-next-page
1825 "\177" gnus-summary-prev-page
1826 [delete] gnus-summary-prev-page
1827 [backspace] gnus-summary-prev-page
1828 "\r" gnus-summary-scroll-up
1829 "\M-\r" gnus-summary-scroll-down
1830 "n" gnus-summary-next-unread-article
1831 "p" gnus-summary-prev-unread-article
1832 "N" gnus-summary-next-article
1833 "P" gnus-summary-prev-article
1834 "\M-\C-n" gnus-summary-next-same-subject
1835 "\M-\C-p" gnus-summary-prev-same-subject
1836 "\M-n" gnus-summary-next-unread-subject
1837 "\M-p" gnus-summary-prev-unread-subject
1838 "." gnus-summary-first-unread-article
1839 "," gnus-summary-best-unread-article
1840 "\M-s" gnus-summary-search-article-forward
1841 "\M-r" gnus-summary-search-article-backward
1842 "\M-S" gnus-summary-repeat-search-article-forward
1843 "\M-R" gnus-summary-repeat-search-article-backward
1844 "<" gnus-summary-beginning-of-article
1845 ">" gnus-summary-end-of-article
1846 "j" gnus-summary-goto-article
1847 "^" gnus-summary-refer-parent-article
1848 "\M-^" gnus-summary-refer-article
1849 "u" gnus-summary-tick-article-forward
1850 "!" gnus-summary-tick-article-forward
1851 "U" gnus-summary-tick-article-backward
1852 "d" gnus-summary-mark-as-read-forward
1853 "D" gnus-summary-mark-as-read-backward
1854 "E" gnus-summary-mark-as-expirable
1855 "\M-u" gnus-summary-clear-mark-forward
1856 "\M-U" gnus-summary-clear-mark-backward
1857 "k" gnus-summary-kill-same-subject-and-select
1858 "\C-k" gnus-summary-kill-same-subject
1859 "\M-\C-k" gnus-summary-kill-thread
1860 "\M-\C-l" gnus-summary-lower-thread
1861 "e" gnus-summary-edit-article
1862 "#" gnus-summary-mark-as-processable
1863 "\M-#" gnus-summary-unmark-as-processable
1864 "\M-\C-t" gnus-summary-toggle-threads
1865 "\M-\C-s" gnus-summary-show-thread
1866 "\M-\C-h" gnus-summary-hide-thread
1867 "\M-\C-f" gnus-summary-next-thread
1868 "\M-\C-b" gnus-summary-prev-thread
1869 [(meta down)] gnus-summary-next-thread
1870 [(meta up)] gnus-summary-prev-thread
1871 "\M-\C-u" gnus-summary-up-thread
1872 "\M-\C-d" gnus-summary-down-thread
1873 "&" gnus-summary-execute-command
1874 "c" gnus-summary-catchup-and-exit
1875 "\C-w" gnus-summary-mark-region-as-read
1876 "\C-t" gnus-summary-toggle-truncation
1877 "?" gnus-summary-mark-as-dormant
1878 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1879 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1880 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1881 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1882 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1883 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1884 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1885 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1886 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1887 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1888 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1889 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1890 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1891 "=" gnus-summary-expand-window
1892 "\C-x\C-s" gnus-summary-reselect-current-group
1893 "\M-g" gnus-summary-rescan-group
1894 "\C-c\C-r" gnus-summary-caesar-message
1895 "f" gnus-summary-followup
1896 "F" gnus-summary-followup-with-original
1897 "C" gnus-summary-cancel-article
1898 "r" gnus-summary-reply
1899 "R" gnus-summary-reply-with-original
1900 "\C-c\C-f" gnus-summary-mail-forward
1901 "o" gnus-summary-save-article
1902 "\C-o" gnus-summary-save-article-mail
1903 "|" gnus-summary-pipe-output
1904 "\M-k" gnus-summary-edit-local-kill
1905 "\M-K" gnus-summary-edit-global-kill
1907 "\C-c\C-d" gnus-summary-describe-group
1908 "q" gnus-summary-exit
1909 "Q" gnus-summary-exit-no-update
1910 "\C-c\C-i" gnus-info-find-node
1911 gnus-mouse-2 gnus-mouse-pick-article
1912 [follow-link] mouse-face
1913 "m" gnus-summary-mail-other-window
1914 "a" gnus-summary-post-news
1915 "x" gnus-summary-limit-to-unread
1916 "s" gnus-summary-isearch-article
1917 [tab] gnus-summary-widget-forward
1918 "t" gnus-summary-toggle-header
1919 "g" gnus-summary-show-article
1920 "l" gnus-summary-goto-last-article
1921 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1922 "\C-d" gnus-summary-enter-digest-group
1923 "\M-\C-d" gnus-summary-read-document
1924 "\M-\C-e" gnus-summary-edit-parameters
1925 "\M-\C-a" gnus-summary-customize-parameters
1927 "*" gnus-cache-enter-article
1928 "\M-*" gnus-cache-remove-article
1929 "\M-&" gnus-summary-universal-argument
1930 "\C-l" gnus-recenter
1931 "I" gnus-summary-increase-score
1932 "L" gnus-summary-lower-score
1933 "\M-i" gnus-symbolic-argument
1934 "h" gnus-summary-select-article-buffer
1936 "b" gnus-article-view-part
1937 "\M-t" gnus-summary-toggle-display-buttonized
1939 "V" gnus-summary-score-map
1940 "X" gnus-uu-extract-map
1941 "S" gnus-summary-send-map)
1943 ;; Sort of orthogonal keymap
1944 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1945 "t" gnus-summary-tick-article-forward
1946 "!" gnus-summary-tick-article-forward
1947 "d" gnus-summary-mark-as-read-forward
1948 "r" gnus-summary-mark-as-read-forward
1949 "c" gnus-summary-clear-mark-forward
1950 " " gnus-summary-clear-mark-forward
1951 "e" gnus-summary-mark-as-expirable
1952 "x" gnus-summary-mark-as-expirable
1953 "?" gnus-summary-mark-as-dormant
1954 "b" gnus-summary-set-bookmark
1955 "B" gnus-summary-remove-bookmark
1956 "#" gnus-summary-mark-as-processable
1957 "\M-#" gnus-summary-unmark-as-processable
1958 "S" gnus-summary-limit-include-expunged
1959 "C" gnus-summary-catchup
1960 "H" gnus-summary-catchup-to-here
1961 "h" gnus-summary-catchup-from-here
1962 "\C-c" gnus-summary-catchup-all
1963 "k" gnus-summary-kill-same-subject-and-select
1964 "K" gnus-summary-kill-same-subject
1965 "P" gnus-uu-mark-map)
1967 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1968 "c" gnus-summary-clear-above
1969 "u" gnus-summary-tick-above
1970 "m" gnus-summary-mark-above
1971 "k" gnus-summary-kill-below)
1973 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1974 "/" gnus-summary-limit-to-subject
1975 "n" gnus-summary-limit-to-articles
1976 "b" gnus-summary-limit-to-bodies
1977 "h" gnus-summary-limit-to-headers
1978 "w" gnus-summary-pop-limit
1979 "s" gnus-summary-limit-to-subject
1980 "a" gnus-summary-limit-to-author
1981 "u" gnus-summary-limit-to-unread
1982 "m" gnus-summary-limit-to-marks
1983 "M" gnus-summary-limit-exclude-marks
1984 "v" gnus-summary-limit-to-score
1985 "*" gnus-summary-limit-include-cached
1986 "D" gnus-summary-limit-include-dormant
1987 "T" gnus-summary-limit-include-thread
1988 "d" gnus-summary-limit-exclude-dormant
1989 "t" gnus-summary-limit-to-age
1990 "." gnus-summary-limit-to-unseen
1991 "x" gnus-summary-limit-to-extra
1992 "p" gnus-summary-limit-to-display-predicate
1993 "E" gnus-summary-limit-include-expunged
1994 "c" gnus-summary-limit-exclude-childless-dormant
1995 "C" gnus-summary-limit-mark-excluded-as-read
1996 "o" gnus-summary-insert-old-articles
1997 "N" gnus-summary-insert-new-articles
1998 "S" gnus-summary-limit-to-singletons
1999 "r" gnus-summary-limit-to-replied
2000 "R" gnus-summary-limit-to-recipient
2001 "A" gnus-summary-limit-to-address)
2003 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2004 "n" gnus-summary-next-unread-article
2005 "p" gnus-summary-prev-unread-article
2006 "N" gnus-summary-next-article
2007 "P" gnus-summary-prev-article
2008 "\C-n" gnus-summary-next-same-subject
2009 "\C-p" gnus-summary-prev-same-subject
2010 "\M-n" gnus-summary-next-unread-subject
2011 "\M-p" gnus-summary-prev-unread-subject
2012 "f" gnus-summary-first-unread-article
2013 "b" gnus-summary-best-unread-article
2014 "j" gnus-summary-goto-article
2015 "g" gnus-summary-goto-subject
2016 "l" gnus-summary-goto-last-article
2017 "o" gnus-summary-pop-article)
2019 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2020 "k" gnus-summary-kill-thread
2021 "E" gnus-summary-expire-thread
2022 "l" gnus-summary-lower-thread
2023 "i" gnus-summary-raise-thread
2024 "T" gnus-summary-toggle-threads
2025 "t" gnus-summary-rethread-current
2026 "^" gnus-summary-reparent-thread
2027 "\M-^" gnus-summary-reparent-children
2028 "s" gnus-summary-show-thread
2029 "S" gnus-summary-show-all-threads
2030 "h" gnus-summary-hide-thread
2031 "H" gnus-summary-hide-all-threads
2032 "n" gnus-summary-next-thread
2033 "p" gnus-summary-prev-thread
2034 "u" gnus-summary-up-thread
2035 "o" gnus-summary-top-thread
2036 "d" gnus-summary-down-thread
2037 "#" gnus-uu-mark-thread
2038 "\M-#" gnus-uu-unmark-thread)
2040 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2041 "g" gnus-summary-prepare
2042 "c" gnus-summary-insert-cached-articles
2043 "d" gnus-summary-insert-dormant-articles
2044 "t" gnus-summary-insert-ticked-articles)
2046 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2047 "c" gnus-summary-catchup-and-exit
2048 "C" gnus-summary-catchup-all-and-exit
2049 "E" gnus-summary-exit-no-update
2050 "Q" gnus-summary-exit
2051 "Z" gnus-summary-exit
2052 "n" gnus-summary-catchup-and-goto-next-group
2053 "p" gnus-summary-catchup-and-goto-prev-group
2054 "R" gnus-summary-reselect-current-group
2055 "G" gnus-summary-rescan-group
2056 "N" gnus-summary-next-group
2057 "s" gnus-summary-save-newsrc
2058 "P" gnus-summary-prev-group)
2060 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2061 " " gnus-summary-next-page
2062 "n" gnus-summary-next-page
2063 "\177" gnus-summary-prev-page
2064 [delete] gnus-summary-prev-page
2065 "p" gnus-summary-prev-page
2066 "\r" gnus-summary-scroll-up
2067 "\M-\r" gnus-summary-scroll-down
2068 "<" gnus-summary-beginning-of-article
2069 ">" gnus-summary-end-of-article
2070 "b" gnus-summary-beginning-of-article
2071 "e" gnus-summary-end-of-article
2072 "^" gnus-summary-refer-parent-article
2073 "r" gnus-summary-refer-parent-article
2074 "C" gnus-summary-show-complete-article
2075 "D" gnus-summary-enter-digest-group
2076 "R" gnus-summary-refer-references
2077 "T" gnus-summary-refer-thread
2078 "W" gnus-warp-to-article
2079 "g" gnus-summary-show-article
2080 "s" gnus-summary-isearch-article
2081 [tab] gnus-summary-widget-forward
2082 "P" gnus-summary-print-article
2083 "S" gnus-sticky-article
2084 "M" gnus-mailing-list-insinuate
2085 "t" gnus-article-babel)
2087 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2088 "b" gnus-article-add-buttons
2089 "B" gnus-article-add-buttons-to-head
2090 "o" gnus-article-treat-overstrike
2091 "e" gnus-article-emphasize
2092 "w" gnus-article-fill-cited-article
2093 "Q" gnus-article-fill-long-lines
2094 "L" gnus-article-toggle-truncate-lines
2095 "C" gnus-article-capitalize-sentences
2096 "c" gnus-article-remove-cr
2097 "q" gnus-article-de-quoted-unreadable
2098 "6" gnus-article-de-base64-unreadable
2099 "Z" gnus-article-decode-HZ
2100 "A" gnus-article-treat-ansi-sequences
2101 "h" gnus-article-wash-html
2102 "u" gnus-article-unsplit-urls
2103 "s" gnus-summary-force-verify-and-decrypt
2104 "f" gnus-article-display-x-face
2105 "l" gnus-summary-stop-page-breaking
2106 "r" gnus-summary-caesar-message
2107 "m" gnus-summary-morse-message
2108 "t" gnus-summary-toggle-header
2109 "g" gnus-treat-smiley
2110 "v" gnus-summary-verbose-headers
2111 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2112 "p" gnus-article-verify-x-pgp-sig
2113 "d" gnus-article-treat-dumbquotes
2114 "U" gnus-article-treat-non-ascii
2115 "i" gnus-summary-idna-message)
2117 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2118 ;; mnemonic: deuglif*Y*
2119 "u" gnus-article-outlook-unwrap-lines
2120 "a" gnus-article-outlook-repair-attribution
2121 "c" gnus-article-outlook-rearrange-citation
2122 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2124 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2125 "a" gnus-article-hide
2126 "h" gnus-article-hide-headers
2127 "b" gnus-article-hide-boring-headers
2128 "s" gnus-article-hide-signature
2129 "c" gnus-article-hide-citation
2130 "C" gnus-article-hide-citation-in-followups
2131 "l" gnus-article-hide-list-identifiers
2132 "B" gnus-article-strip-banner
2133 "P" gnus-article-hide-pem
2134 "\C-c" gnus-article-hide-citation-maybe)
2136 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2137 "a" gnus-article-highlight
2138 "h" gnus-article-highlight-headers
2139 "c" gnus-article-highlight-citation
2140 "s" gnus-article-highlight-signature)
2142 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2143 "f" gnus-article-treat-fold-headers
2144 "u" gnus-article-treat-unfold-headers
2145 "n" gnus-article-treat-fold-newsgroups)
2147 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2148 "x" gnus-article-display-x-face
2149 "d" gnus-article-display-face
2150 "s" gnus-treat-smiley
2151 "D" gnus-article-remove-images
2152 "W" gnus-article-show-images
2153 "f" gnus-treat-from-picon
2154 "m" gnus-treat-mail-picon
2155 "n" gnus-treat-newsgroups-picon
2156 "g" gnus-treat-from-gravatar
2157 "h" gnus-treat-mail-gravatar)
2159 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2160 "w" gnus-article-decode-mime-words
2161 "c" gnus-article-decode-charset
2162 "v" gnus-mime-view-all-parts
2163 "b" gnus-article-view-part)
2165 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2166 "z" gnus-article-date-ut
2167 "u" gnus-article-date-ut
2168 "l" gnus-article-date-local
2169 "p" gnus-article-date-english
2170 "e" gnus-article-date-lapsed
2171 "o" gnus-article-date-original
2172 "i" gnus-article-date-iso8601
2173 "s" gnus-article-date-user)
2175 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2176 "t" gnus-article-remove-trailing-blank-lines
2177 "l" gnus-article-strip-leading-blank-lines
2178 "m" gnus-article-strip-multiple-blank-lines
2179 "a" gnus-article-strip-blank-lines
2180 "A" gnus-article-strip-all-blank-lines
2181 "s" gnus-article-strip-leading-space
2182 "e" gnus-article-strip-trailing-space
2183 "w" gnus-article-remove-leading-whitespace)
2185 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2187 "d" gnus-summary-describe-group
2188 "h" gnus-summary-describe-briefly
2189 "i" gnus-info-find-node)
2191 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2192 "e" gnus-summary-expire-articles
2193 "\M-\C-e" gnus-summary-expire-articles-now
2194 "\177" gnus-summary-delete-article
2195 [delete] gnus-summary-delete-article
2196 [backspace] gnus-summary-delete-article
2197 "m" gnus-summary-move-article
2198 "r" gnus-summary-respool-article
2199 "w" gnus-summary-edit-article
2200 "c" gnus-summary-copy-article
2201 "B" gnus-summary-crosspost-article
2202 "q" gnus-summary-respool-query
2203 "t" gnus-summary-respool-trace
2204 "i" gnus-summary-import-article
2205 "I" gnus-summary-create-article
2206 "p" gnus-summary-article-posted-p)
2208 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2209 "o" gnus-summary-save-article
2210 "m" gnus-summary-save-article-mail
2211 "F" gnus-summary-write-article-file
2212 "r" gnus-summary-save-article-rmail
2213 "f" gnus-summary-save-article-file
2214 "b" gnus-summary-save-article-body-file
2215 "B" gnus-summary-write-article-body-file
2216 "h" gnus-summary-save-article-folder
2217 "v" gnus-summary-save-article-vm
2218 "p" gnus-summary-pipe-output
2219 "P" gnus-summary-muttprint)
2221 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2222 "b" gnus-summary-display-buttonized
2223 "m" gnus-summary-repair-multipart
2224 "v" gnus-article-view-part
2225 "o" gnus-article-save-part
2226 "O" gnus-article-save-part-and-strip
2227 "r" gnus-article-replace-part
2228 "d" gnus-article-delete-part
2229 "t" gnus-article-view-part-as-type
2230 "j" gnus-article-jump-to-part
2231 "c" gnus-article-copy-part
2232 "C" gnus-article-view-part-as-charset
2233 "e" gnus-article-view-part-externally
2234 "H" gnus-article-browse-html-article
2235 "E" gnus-article-encrypt-body
2236 "i" gnus-article-inline-part
2237 "|" gnus-article-pipe-part)
2239 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2240 "p" gnus-summary-mark-as-processable
2241 "u" gnus-summary-unmark-as-processable
2242 "U" gnus-summary-unmark-all-processable
2243 "v" gnus-uu-mark-over
2244 "s" gnus-uu-mark-series
2245 "r" gnus-uu-mark-region
2246 "g" gnus-uu-unmark-region
2247 "R" gnus-uu-mark-by-regexp
2248 "G" gnus-uu-unmark-by-regexp
2249 "t" gnus-uu-mark-thread
2250 "T" gnus-uu-unmark-thread
2251 "a" gnus-uu-mark-all
2252 "b" gnus-uu-mark-buffer
2253 "S" gnus-uu-mark-sparse
2254 "k" gnus-summary-kill-process-mark
2255 "y" gnus-summary-yank-process-mark
2256 "w" gnus-summary-save-process-mark
2257 "i" gnus-uu-invert-processable)
2259 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2260 ;;"x" gnus-uu-extract-any
2261 "m" gnus-summary-save-parts
2262 "u" gnus-uu-decode-uu
2263 "U" gnus-uu-decode-uu-and-save
2264 "s" gnus-uu-decode-unshar
2265 "S" gnus-uu-decode-unshar-and-save
2266 "o" gnus-uu-decode-save
2267 "O" gnus-uu-decode-save
2268 "b" gnus-uu-decode-binhex
2269 "B" gnus-uu-decode-binhex
2270 "Y" gnus-uu-decode-yenc
2271 "p" gnus-uu-decode-postscript
2272 "P" gnus-uu-decode-postscript-and-save)
2275 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2276 "u" gnus-uu-decode-uu-view
2277 "U" gnus-uu-decode-uu-and-save-view
2278 "s" gnus-uu-decode-unshar-view
2279 "S" gnus-uu-decode-unshar-and-save-view
2280 "o" gnus-uu-decode-save-view
2281 "O" gnus-uu-decode-save-view
2282 "b" gnus-uu-decode-binhex-view
2283 "B" gnus-uu-decode-binhex-view
2284 "p" gnus-uu-decode-postscript-view
2285 "P" gnus-uu-decode-postscript-and-save-view)
2287 (defvar gnus-article-post-menu nil)
2289 (defconst gnus-summary-menu-maxlen 20)
2291 (defun gnus-summary-menu-split (menu)
2292 ;; If we have lots of elements, divide them into groups of 20
2293 ;; and make a pane (or submenu) for each one.
2294 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2295 (let ((menu menu) sublists next
2298 ;; Pull off the next gnus-summary-menu-maxlen elements
2299 ;; and make them the next element of sublist.
2300 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2302 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2304 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2305 (aref (car (last menu)) 0)) menu)
2309 (nreverse sublists))
2310 ;; Few elements--put them all in one pane.
2313 (defun gnus-summary-make-menu-bar ()
2314 (gnus-turn-off-edit-menu 'summary)
2316 (unless (boundp 'gnus-summary-misc-menu)
2319 gnus-summary-kill-menu gnus-summary-mode-map ""
2324 ["Customize" gnus-score-customize t])
2325 (gnus-make-score-map 'increase)
2326 (gnus-make-score-map 'lower)
2328 ["Kill below" gnus-summary-kill-below t]
2329 ["Mark above" gnus-summary-mark-above t]
2330 ["Tick above" gnus-summary-tick-above t]
2331 ["Clear above" gnus-summary-clear-above t])
2332 ["Current score" gnus-summary-current-score t]
2333 ["Set score" gnus-summary-set-score t]
2334 ["Switch current score file..." gnus-score-change-score-file t]
2335 ["Set mark below..." gnus-score-set-mark-below t]
2336 ["Set expunge below..." gnus-score-set-expunge-below t]
2337 ["Edit current score file" gnus-score-edit-current-scores t]
2338 ["Edit score file..." gnus-score-edit-file t]
2339 ["Trace score" gnus-score-find-trace t]
2340 ["Find words" gnus-score-find-favourite-words t]
2341 ["Rescore buffer" gnus-summary-rescore t]
2342 ["Increase score..." gnus-summary-increase-score t]
2343 ["Lower score..." gnus-summary-lower-score t]))))
2345 ;; Define both the Article menu in the summary buffer and the
2346 ;; equivalent Commands menu in the article buffer here for
2350 ["All" gnus-article-hide t]
2351 ["Headers" gnus-article-hide-headers t]
2352 ["Signature" gnus-article-hide-signature t]
2353 ["Citation" gnus-article-hide-citation t]
2354 ["List identifiers" gnus-article-hide-list-identifiers t]
2355 ["Banner" gnus-article-strip-banner t]
2356 ["Boring headers" gnus-article-hide-boring-headers t])
2358 ["All" gnus-article-highlight t]
2359 ["Headers" gnus-article-highlight-headers t]
2360 ["Signature" gnus-article-highlight-signature t]
2361 ["Citation" gnus-article-highlight-citation t])
2363 ["Words" gnus-article-decode-mime-words t]
2364 ["Charset" gnus-article-decode-charset t]
2365 ["QP" gnus-article-de-quoted-unreadable t]
2366 ["Base64" gnus-article-de-base64-unreadable t]
2367 ["View MIME buttons" gnus-summary-display-buttonized t]
2368 ["View all" gnus-mime-view-all-parts t]
2369 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2370 ["Encrypt body" gnus-article-encrypt-body
2371 :active (not (gnus-group-read-only-p))
2372 ,@(if (featurep 'xemacs) nil
2373 '(:help "Encrypt the message body on disk"))]
2374 ["Extract all parts..." gnus-summary-save-parts t]
2376 ["Repair multipart" gnus-summary-repair-multipart t]
2377 ["Pipe part..." gnus-article-pipe-part t]
2378 ["Inline part" gnus-article-inline-part t]
2379 ["View part as type..." gnus-article-view-part-as-type t]
2380 ["Encrypt body" gnus-article-encrypt-body
2381 :active (not (gnus-group-read-only-p))
2382 ,@(if (featurep 'xemacs) nil
2383 '(:help "Encrypt the message body on disk"))]
2384 ["View part externally" gnus-article-view-part-externally t]
2385 ["View HTML parts in browser" gnus-article-browse-html-article t]
2386 ["View part with charset..." gnus-article-view-part-as-charset t]
2387 ["Copy part" gnus-article-copy-part t]
2388 ["Save part..." gnus-article-save-part t]
2389 ["View part" gnus-article-view-part t]))
2391 ["Local" gnus-article-date-local t]
2392 ["ISO8601" gnus-article-date-iso8601 t]
2393 ["UT" gnus-article-date-ut t]
2394 ["Original" gnus-article-date-original t]
2395 ["Lapsed" gnus-article-date-lapsed t]
2396 ["User-defined" gnus-article-date-user t])
2398 ["Remove images" gnus-article-remove-images t]
2399 ["Toggle smiley" gnus-treat-smiley t]
2400 ["Show X-Face" gnus-article-display-x-face t]
2401 ["Show picons in From" gnus-treat-from-picon t]
2402 ["Show picons in mail headers" gnus-treat-mail-picon t]
2403 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2404 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2405 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2406 ("View as different encoding"
2407 ,@(gnus-summary-menu-split
2410 ;; Since easymenu under Emacs doesn't allow
2411 ;; lambda forms for menu commands, we should
2412 ;; provide intern'ed function symbols.
2413 (let ((command (intern (format "\
2414 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2418 (let ((gnus-summary-show-article-charset-alist
2420 (gnus-summary-show-article 1))))
2421 `[,(symbol-name cs) ,command t]))
2422 (sort (if (fboundp 'coding-system-list)
2423 (coding-system-list)
2424 (mapcar 'car mm-mime-mule-charset-alist))
2428 ["Leading" gnus-article-strip-leading-blank-lines t]
2429 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2430 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2431 ["All of the above" gnus-article-strip-blank-lines t]
2432 ["All" gnus-article-strip-all-blank-lines t]
2433 ["Leading space" gnus-article-strip-leading-space t]
2434 ["Trailing space" gnus-article-strip-trailing-space t]
2435 ["Leading space in headers"
2436 gnus-article-remove-leading-whitespace t])
2437 ["Overstrike" gnus-article-treat-overstrike t]
2438 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2439 ["Non-ASCII" gnus-article-treat-non-ascii t]
2440 ["Emphasis" gnus-article-emphasize t]
2441 ["Word wrap" gnus-article-fill-cited-article t]
2442 ["Fill long lines" gnus-article-fill-long-lines t]
2443 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2444 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2445 ["Remove CR" gnus-article-remove-cr t]
2446 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2447 ["Base64" gnus-article-de-base64-unreadable t]
2448 ["Rot 13" gnus-summary-caesar-message
2449 ,@(if (featurep 'xemacs) '(t)
2450 '(:help "\"Caesar rotate\" article by 13"))]
2451 ["De-IDNA" gnus-summary-idna-message t]
2452 ["Morse decode" gnus-summary-morse-message t]
2453 ["Unix pipe..." gnus-summary-pipe-message t]
2454 ["Add buttons" gnus-article-add-buttons t]
2455 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2456 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2457 ["Verbose header" gnus-summary-verbose-headers t]
2458 ["Toggle header" gnus-summary-toggle-header t]
2459 ["Unfold headers" gnus-article-treat-unfold-headers t]
2460 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2461 ["Html" gnus-article-wash-html t]
2462 ["Unsplit URLs" gnus-article-unsplit-urls t]
2463 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2464 ["Decode HZ" gnus-article-decode-HZ t]
2465 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2466 ("(Outlook) Deuglify"
2467 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2468 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2469 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2470 ["Full (Outlook) deuglify"
2471 gnus-article-outlook-deuglify-article t])
2474 ["Save in default format..." gnus-summary-save-article
2475 ,@(if (featurep 'xemacs) '(t)
2476 '(:help "Save article using default method"))]
2477 ["Save in file..." gnus-summary-save-article-file
2478 ,@(if (featurep 'xemacs) '(t)
2479 '(:help "Save article in file"))]
2480 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2481 ["Save in MH folder..." gnus-summary-save-article-folder t]
2482 ["Save in VM folder..." gnus-summary-save-article-vm t]
2483 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2484 ["Save body in file..." gnus-summary-save-article-body-file t]
2485 ["Pipe through a filter..." gnus-summary-pipe-output t]
2486 ["Print with Muttprint..." gnus-summary-muttprint t]
2487 ["Print" gnus-summary-print-article
2488 ,@(if (featurep 'xemacs) '(t)
2489 '(:help "Generate and print a PostScript image"))])
2490 ("Copy, move,... (Backend)"
2491 ,@(if (featurep 'xemacs) nil
2492 '(:help "Copying, moving, expiring articles..."))
2493 ["Respool article..." gnus-summary-respool-article t]
2494 ["Move article..." gnus-summary-move-article
2495 (gnus-check-backend-function
2496 'request-move-article gnus-newsgroup-name)]
2497 ["Copy article..." gnus-summary-copy-article t]
2498 ["Crosspost article..." gnus-summary-crosspost-article
2499 (gnus-check-backend-function
2500 'request-replace-article gnus-newsgroup-name)]
2501 ["Import file..." gnus-summary-import-article
2502 (gnus-check-backend-function
2503 'request-accept-article gnus-newsgroup-name)]
2504 ["Create article..." gnus-summary-create-article
2505 (gnus-check-backend-function
2506 'request-accept-article gnus-newsgroup-name)]
2507 ["Check if posted" gnus-summary-article-posted-p t]
2508 ["Edit article" gnus-summary-edit-article
2509 (not (gnus-group-read-only-p))]
2510 ["Delete article" gnus-summary-delete-article
2511 (gnus-check-backend-function
2512 'request-expire-articles gnus-newsgroup-name)]
2513 ["Query respool" gnus-summary-respool-query t]
2514 ["Trace respool" gnus-summary-respool-trace t]
2515 ["Delete expirable articles" gnus-summary-expire-articles-now
2516 (gnus-check-backend-function
2517 'request-expire-articles gnus-newsgroup-name)])
2519 ["Uudecode" gnus-uu-decode-uu
2520 ,@(if (featurep 'xemacs) '(t)
2521 '(:help "Decode uuencoded article(s)"))]
2522 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2523 ["Unshar" gnus-uu-decode-unshar t]
2524 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2525 ["Save" gnus-uu-decode-save t]
2526 ["Binhex" gnus-uu-decode-binhex t]
2527 ["Postscript" gnus-uu-decode-postscript t]
2528 ["All MIME parts" gnus-summary-save-parts t])
2530 ["Enter article" gnus-cache-enter-article t]
2531 ["Remove article" gnus-cache-remove-article t])
2532 ["Translate" gnus-article-babel t]
2533 ["Select article buffer" gnus-summary-select-article-buffer t]
2534 ["Make article buffer sticky" gnus-sticky-article t]
2535 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2536 ["Isearch article..." gnus-summary-isearch-article t]
2537 ["Beginning of the article" gnus-summary-beginning-of-article t]
2538 ["End of the article" gnus-summary-end-of-article t]
2539 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2540 ["Fetch referenced articles" gnus-summary-refer-references t]
2541 ["Fetch current thread" gnus-summary-refer-thread t]
2542 ["Fetch article with id..." gnus-summary-refer-article t]
2543 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2544 ["Redisplay" gnus-summary-show-article t]
2545 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2547 gnus-summary-article-menu gnus-summary-mode-map ""
2548 (cons "Article" innards))
2550 (if (not (keymapp gnus-summary-article-menu))
2552 gnus-article-commands-menu gnus-article-mode-map ""
2553 (cons "Commands" innards))
2554 ;; in Emacs, don't share menu.
2555 (setq gnus-article-commands-menu
2556 (copy-keymap gnus-summary-article-menu))
2557 (define-key gnus-article-mode-map [menu-bar commands]
2558 (cons "Commands" gnus-article-commands-menu))))
2561 gnus-summary-thread-menu gnus-summary-mode-map ""
2563 ["Find all messages in thread" gnus-summary-refer-thread t]
2564 ["Toggle threading" gnus-summary-toggle-threads t]
2565 ["Hide threads" gnus-summary-hide-all-threads t]
2566 ["Show threads" gnus-summary-show-all-threads t]
2567 ["Hide thread" gnus-summary-hide-thread t]
2568 ["Show thread" gnus-summary-show-thread t]
2569 ["Go to next thread" gnus-summary-next-thread t]
2570 ["Go to previous thread" gnus-summary-prev-thread t]
2571 ["Go down thread" gnus-summary-down-thread t]
2572 ["Go up thread" gnus-summary-up-thread t]
2573 ["Top of thread" gnus-summary-top-thread t]
2574 ["Mark thread as read" gnus-summary-kill-thread t]
2575 ["Mark thread as expired" gnus-summary-expire-thread t]
2576 ["Lower thread score" gnus-summary-lower-thread t]
2577 ["Raise thread score" gnus-summary-raise-thread t]
2578 ["Rethread current" gnus-summary-rethread-current t]))
2581 gnus-summary-post-menu gnus-summary-mode-map ""
2583 ["Send a message (mail or news)" gnus-summary-post-news
2584 ,@(if (featurep 'xemacs) '(t)
2585 '(:help "Compose a new message (mail or news)"))]
2586 ["Followup" gnus-summary-followup
2587 ,@(if (featurep 'xemacs) '(t)
2588 '(:help "Post followup to this article"))]
2589 ["Followup and yank" gnus-summary-followup-with-original
2590 ,@(if (featurep 'xemacs) '(t)
2591 '(:help "Post followup to this article, quoting its contents"))]
2592 ["Supersede article" gnus-summary-supersede-article t]
2593 ["Cancel article" gnus-summary-cancel-article
2594 ,@(if (featurep 'xemacs) '(t)
2595 '(:help "Cancel an article you posted"))]
2596 ["Reply" gnus-summary-reply t]
2597 ["Reply and yank" gnus-summary-reply-with-original t]
2598 ["Wide reply" gnus-summary-wide-reply t]
2599 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2600 ,@(if (featurep 'xemacs) '(t)
2601 '(:help "Mail a reply, quoting this article"))]
2602 ["Very wide reply" gnus-summary-very-wide-reply t]
2603 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2604 ,@(if (featurep 'xemacs) '(t)
2605 '(:help "Mail a very wide reply, quoting this article"))]
2606 ["Mail forward" gnus-summary-mail-forward t]
2607 ["Post forward" gnus-summary-post-forward t]
2608 ["Digest and mail" gnus-uu-digest-mail-forward t]
2609 ["Digest and post" gnus-uu-digest-post-forward t]
2610 ["Resend message" gnus-summary-resend-message t]
2611 ["Resend message edit" gnus-summary-resend-message-edit t]
2612 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2613 ["Send a mail" gnus-summary-mail-other-window t]
2614 ["Create a local message" gnus-summary-news-other-window t]
2615 ["Uuencode and post" gnus-uu-post-news
2616 ,@(if (featurep 'xemacs) '(t)
2617 '(:help "Post a uuencoded article"))]
2618 ["Followup via news" gnus-summary-followup-to-mail t]
2619 ["Followup via news and yank"
2620 gnus-summary-followup-to-mail-with-original t]
2621 ["Strip signature on reply"
2624 (if (not (memq message-cite-function
2625 '(message-cite-original-without-signature
2626 message-cite-original)))
2627 ;; Stupid workaround for XEmacs not honoring :visible.
2628 (message "Can't toggle this value of `message-cite-function'")
2629 (setq message-cite-function
2630 (if (eq message-cite-function
2631 'message-cite-original-without-signature)
2632 'message-cite-original
2633 'message-cite-original-without-signature))))
2634 ;; XEmacs barfs on :visible.
2635 ,@(if (featurep 'xemacs) nil
2636 '(:visible (memq message-cite-function
2637 '(message-cite-original-without-signature
2638 message-cite-original))))
2640 :selected (eq message-cite-function
2641 'message-cite-original-without-signature)
2642 ,@(if (featurep 'xemacs) nil
2643 '(:help "Strip signature from cited article when replying."))]
2645 ;;["Send" gnus-summary-send-draft t]
2646 ;;["Send bounced" gnus-resend-bounced-mail t])
2650 ((not (keymapp gnus-summary-post-menu))
2651 (setq gnus-article-post-menu gnus-summary-post-menu))
2652 ((not gnus-article-post-menu)
2653 ;; Don't share post menu.
2654 (setq gnus-article-post-menu
2655 (copy-keymap gnus-summary-post-menu))))
2656 (define-key gnus-article-mode-map [menu-bar post]
2657 (cons "Post" gnus-article-post-menu))
2660 gnus-summary-misc-menu gnus-summary-mode-map ""
2663 ["Mark as read" gnus-summary-mark-as-read-forward t]
2664 ["Mark same subject and select"
2665 gnus-summary-kill-same-subject-and-select t]
2666 ["Mark same subject" gnus-summary-kill-same-subject t]
2667 ["Catchup" gnus-summary-catchup
2668 ,@(if (featurep 'xemacs) '(t)
2669 '(:help "Mark unread articles in this group as read"))]
2670 ["Catchup all" gnus-summary-catchup-all t]
2671 ["Catchup to here" gnus-summary-catchup-to-here t]
2672 ["Catchup from here" gnus-summary-catchup-from-here t]
2673 ["Catchup region" gnus-summary-mark-region-as-read
2674 (gnus-mark-active-p)]
2675 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2677 ["Tick" gnus-summary-tick-article-forward t]
2678 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2679 ["Remove marks" gnus-summary-clear-mark-forward t]
2680 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2681 ["Set bookmark" gnus-summary-set-bookmark t]
2682 ["Remove bookmark" gnus-summary-remove-bookmark t])
2684 ["Marks..." gnus-summary-limit-to-marks t]
2685 ["Subject..." gnus-summary-limit-to-subject t]
2686 ["Author..." gnus-summary-limit-to-author t]
2687 ["Recipient..." gnus-summary-limit-to-recipient t]
2688 ["Address..." gnus-summary-limit-to-address t]
2689 ["Age..." gnus-summary-limit-to-age t]
2690 ["Extra..." gnus-summary-limit-to-extra t]
2691 ["Score..." gnus-summary-limit-to-score t]
2692 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2693 ["Unread" gnus-summary-limit-to-unread t]
2694 ["Unseen" gnus-summary-limit-to-unseen t]
2695 ["Singletons" gnus-summary-limit-to-singletons t]
2696 ["Replied" gnus-summary-limit-to-replied t]
2697 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2698 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2699 ["Pop limit" gnus-summary-pop-limit t]
2700 ["Show dormant" gnus-summary-limit-include-dormant t]
2701 ["Hide childless dormant"
2702 gnus-summary-limit-exclude-childless-dormant t]
2703 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2704 ["Hide marked" gnus-summary-limit-exclude-marks t]
2705 ["Show expunged" gnus-summary-limit-include-expunged t])
2707 ["Set mark" gnus-summary-mark-as-processable t]
2708 ["Remove mark" gnus-summary-unmark-as-processable t]
2709 ["Remove all marks" gnus-summary-unmark-all-processable t]
2710 ["Invert marks" gnus-uu-invert-processable t]
2711 ["Mark above" gnus-uu-mark-over t]
2712 ["Mark series" gnus-uu-mark-series t]
2713 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2714 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2715 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2716 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2717 ["Mark all" gnus-uu-mark-all t]
2718 ["Mark buffer" gnus-uu-mark-buffer t]
2719 ["Mark sparse" gnus-uu-mark-sparse t]
2720 ["Mark thread" gnus-uu-mark-thread t]
2721 ["Unmark thread" gnus-uu-unmark-thread t]
2722 ("Process Mark Sets"
2723 ["Kill" gnus-summary-kill-process-mark t]
2724 ["Yank" gnus-summary-yank-process-mark
2725 gnus-newsgroup-process-stack]
2726 ["Save" gnus-summary-save-process-mark t]
2727 ["Run command on marked..." gnus-summary-universal-argument t]))
2730 ["Page forward" gnus-summary-next-page
2731 ,@(if (featurep 'xemacs) '(t)
2732 '(:help "Show next page of article"))]
2733 ["Page backward" gnus-summary-prev-page
2734 ,@(if (featurep 'xemacs) '(t)
2735 '(:help "Show previous page of article"))]
2736 ["Line forward" gnus-summary-scroll-up t])
2738 ["Next unread article" gnus-summary-next-unread-article t]
2739 ["Previous unread article" gnus-summary-prev-unread-article t]
2740 ["Next article" gnus-summary-next-article t]
2741 ["Previous article" gnus-summary-prev-article t]
2742 ["Next unread subject" gnus-summary-next-unread-subject t]
2743 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2744 ["Next article same subject" gnus-summary-next-same-subject t]
2745 ["Previous article same subject" gnus-summary-prev-same-subject t]
2746 ["First unread article" gnus-summary-first-unread-article t]
2747 ["Best unread article" gnus-summary-best-unread-article t]
2748 ["Go to subject number..." gnus-summary-goto-subject t]
2749 ["Go to article number..." gnus-summary-goto-article t]
2750 ["Go to the last article" gnus-summary-goto-last-article t]
2751 ["Pop article off history" gnus-summary-pop-article t])
2753 ["Sort by number" gnus-summary-sort-by-number t]
2754 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2755 ["Sort by author" gnus-summary-sort-by-author t]
2756 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2757 ["Sort by subject" gnus-summary-sort-by-subject t]
2758 ["Sort by date" gnus-summary-sort-by-date t]
2759 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2760 ["Sort by score" gnus-summary-sort-by-score t]
2761 ["Sort by lines" gnus-summary-sort-by-lines t]
2762 ["Sort by characters" gnus-summary-sort-by-chars t]
2763 ["Randomize" gnus-summary-sort-by-random t]
2764 ["Original sort" gnus-summary-sort-by-original t])
2766 ["Describe group" gnus-summary-describe-group t]
2767 ["Read manual" gnus-info-find-node t])
2769 ["Pick and read" gnus-pick-mode t]
2770 ["Binary" gnus-binary-mode t])
2772 ["Regenerate" gnus-summary-prepare t]
2773 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2774 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2775 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2776 ["Toggle threading" gnus-summary-toggle-threads t])
2777 ["See old articles" gnus-summary-insert-old-articles t]
2778 ["See new articles" gnus-summary-insert-new-articles t]
2779 ["Filter articles..." gnus-summary-execute-command t]
2780 ["Run command on articles..." gnus-summary-universal-argument t]
2781 ["Search articles forward..." gnus-summary-search-article-forward t]
2782 ["Search articles backward..." gnus-summary-search-article-backward t]
2783 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2784 ["Expand window" gnus-summary-expand-window t]
2785 ["Expire expirable articles" gnus-summary-expire-articles
2786 (gnus-check-backend-function
2787 'request-expire-articles gnus-newsgroup-name)]
2788 ["Edit local kill file" gnus-summary-edit-local-kill t]
2789 ["Edit main kill file" gnus-summary-edit-global-kill t]
2790 ["Edit group parameters" gnus-summary-edit-parameters t]
2791 ["Customize group parameters" gnus-summary-customize-parameters t]
2792 ["Send a bug report" gnus-bug t]
2794 ["Catchup and exit" gnus-summary-catchup-and-exit
2795 ,@(if (featurep 'xemacs) '(t)
2796 '(:help "Mark unread articles in this group as read, then exit"))]
2797 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2798 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2799 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2800 ["Exit group" gnus-summary-exit
2801 ,@(if (featurep 'xemacs) '(t)
2802 '(:help "Exit current group, return to group selection mode"))]
2803 ["Exit group without updating" gnus-summary-exit-no-update t]
2804 ["Exit and goto next group" gnus-summary-next-group t]
2805 ["Exit and goto prev group" gnus-summary-prev-group t]
2806 ["Reselect group" gnus-summary-reselect-current-group t]
2807 ["Rescan group" gnus-summary-rescan-group t]
2808 ["Update dribble" gnus-summary-save-newsrc t])))
2810 (gnus-run-hooks 'gnus-summary-menu-hook)))
2812 (defvar gnus-summary-tool-bar-map nil)
2814 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2815 ;; affect _new_ message buffers. We might add a function that walks thru all
2816 ;; summary-mode buffers and force the update.
2817 (defun gnus-summary-tool-bar-update (&optional symbol value)
2818 "Update summary mode toolbar.
2819 Setter function for custom variables."
2820 (setq-default gnus-summary-tool-bar-map nil)
2822 ;; When used as ":set" function:
2823 (set-default symbol value))
2824 (when (gnus-buffer-live-p gnus-summary-buffer)
2825 (with-current-buffer gnus-summary-buffer
2826 (gnus-summary-make-tool-bar))))
2828 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2829 'gnus-summary-tool-bar-gnome
2830 'gnus-summary-tool-bar-retro)
2831 "Specifies the Gnus summary tool bar.
2833 It can be either a list or a symbol refering to a list. See
2834 `gmm-tool-bar-from-list' for the format of the list. The
2835 default key map is `gnus-summary-mode-map'.
2837 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2838 `gnus-summary-tool-bar-retro'."
2839 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2840 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2841 (repeat :tag "User defined list" gmm-tool-bar-item)
2843 :version "23.1" ;; No Gnus
2844 :initialize 'custom-initialize-default
2845 :set 'gnus-summary-tool-bar-update
2846 :group 'gnus-summary)
2848 (defcustom gnus-summary-tool-bar-gnome
2849 '((gnus-summary-post-news "mail/compose" nil)
2850 (gnus-summary-insert-new-articles "mail/inbox" nil
2851 :visible (or (not gnus-agent)
2853 (gnus-summary-reply-with-original "mail/reply")
2854 (gnus-summary-reply "mail/reply" nil :visible nil)
2855 (gnus-summary-followup-with-original "mail/reply-all")
2856 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2857 (gnus-summary-mail-forward "mail/forward")
2858 (gnus-summary-save-article "mail/save")
2859 (gnus-summary-search-article-forward "search" nil :visible nil)
2860 (gnus-summary-print-article "print")
2861 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2862 ;; Some new commands that may need more suitable icons:
2863 (gnus-summary-save-newsrc "save" nil :visible nil)
2864 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2865 (gnus-summary-prev-article "left-arrow")
2866 (gnus-summary-next-article "right-arrow")
2867 (gnus-summary-next-page "next-page")
2868 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2870 ;; Maybe some sort-by-... could be added:
2871 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2872 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2873 (gnus-summary-mark-as-expirable
2875 :visible (gnus-check-backend-function 'request-expire-articles
2876 gnus-newsgroup-name))
2877 (gnus-summary-mark-as-spam
2879 :visible (and (fboundp 'spam-group-ham-contents-p)
2880 (spam-group-ham-contents-p gnus-newsgroup-name))
2881 :help "Mark as spam")
2882 (gnus-summary-mark-as-read-forward
2884 :visible (and (fboundp 'spam-group-spam-contents-p)
2885 (spam-group-spam-contents-p gnus-newsgroup-name)))
2887 (gnus-summary-exit "exit")
2888 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2889 (gnus-info-find-node "help"))
2890 "List of functions for the summary tool bar (GNOME style).
2892 See `gmm-tool-bar-from-list' for the format of the list."
2893 :type '(repeat gmm-tool-bar-item)
2894 :version "23.1" ;; No Gnus
2895 :initialize 'custom-initialize-default
2896 :set 'gnus-summary-tool-bar-update
2897 :group 'gnus-summary)
2899 (defcustom gnus-summary-tool-bar-retro
2900 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2901 (gnus-summary-next-unread-article "gnus/next-ur")
2902 (gnus-summary-post-news "gnus/post")
2903 (gnus-summary-followup-with-original "gnus/fuwo")
2904 (gnus-summary-followup "gnus/followup")
2905 (gnus-summary-reply-with-original "gnus/reply-wo")
2906 (gnus-summary-reply "gnus/reply")
2907 (gnus-summary-caesar-message "gnus/rot13")
2908 (gnus-uu-decode-uu "gnus/uu-decode")
2909 (gnus-summary-save-article-file "gnus/save-aif")
2910 (gnus-summary-save-article "gnus/save-art")
2911 (gnus-uu-post-news "gnus/uu-post")
2912 (gnus-summary-catchup "gnus/catchup")
2913 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2914 (gnus-summary-exit "gnus/exit-summ")
2915 ;; Some new command that may need more suitable icons:
2916 (gnus-summary-print-article "gnus/print" nil :visible nil)
2917 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2918 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2919 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2920 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2921 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2922 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2924 (gnus-info-find-node "gnus/help" nil :visible nil))
2925 "List of functions for the summary tool bar (retro look).
2927 See `gmm-tool-bar-from-list' for the format of the list."
2928 :type '(repeat gmm-tool-bar-item)
2929 :version "23.1" ;; No Gnus
2930 :initialize 'custom-initialize-default
2931 :set 'gnus-summary-tool-bar-update
2932 :group 'gnus-summary)
2934 (defcustom gnus-summary-tool-bar-zap-list t
2935 "List of icon items from the global tool bar.
2936 These items are not displayed in the Gnus summary mode tool bar.
2938 See `gmm-tool-bar-from-list' for the format of the list."
2939 :type 'gmm-tool-bar-zap-list
2940 :version "23.1" ;; No Gnus
2941 :initialize 'custom-initialize-default
2942 :set 'gnus-summary-tool-bar-update
2943 :group 'gnus-summary)
2945 (defvar image-load-path)
2946 (defvar tool-bar-map)
2948 (defun gnus-summary-make-tool-bar (&optional force)
2949 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2950 When FORCE, rebuild the tool bar."
2951 (when (and (not (featurep 'xemacs))
2952 (boundp 'tool-bar-mode)
2954 (or (not gnus-summary-tool-bar-map) force))
2956 (gmm-image-load-path-for-library "gnus"
2959 (image-load-path (cons (car load-path)
2960 (when (boundp 'image-load-path)
2962 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2963 gnus-summary-tool-bar-zap-list
2964 'gnus-summary-mode-map)))
2966 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2968 (setq gnus-summary-tool-bar-map map))))
2969 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2971 (defun gnus-score-set-default (var value)
2972 "A version of set that updates the GNU Emacs menu-bar."
2974 ;; It is the message that forces the active status to be updated.
2977 (defun gnus-make-score-map (type)
2978 "Make a summary score map of type TYPE."
2981 (let ((headers '(("author" "from" string)
2982 ("subject" "subject" string)
2983 ("article body" "body" string)
2984 ("article head" "head" string)
2985 ("xref" "xref" string)
2986 ("extra header" "extra" string)
2987 ("lines" "lines" number)
2988 ("followups to author" "followup" string)))
2989 (types '((number ("less than" <)
2992 (string ("substring" s)
2996 (perms '(("temporary" (current-time-string))
3004 (if (eq type 'lower)
3009 (setq header (car headers))
3015 (let ((ts (cdr (assoc (nth 2 header) types)))
3031 'gnus-summary-score-entry
3033 (if (or (string= (nth 1 header)
3035 (string= (nth 1 header)
3038 (list 'gnus-summary-header
3040 (list 'quote (nth 1 (car ts)))
3041 (list 'gnus-score-delta-default
3048 (list (nreverse outp))))
3051 (list (nreverse outt))))
3053 (setq headers (cdr headers)))
3054 (list (nreverse outh))))))))
3057 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3058 (defvar bookmark-make-record-function)
3061 (defun gnus-summary-mode (&optional group)
3062 "Major mode for reading articles.
3064 All normal editing commands are switched off.
3065 \\<gnus-summary-mode-map>
3066 Each line in this buffer represents one article. To read an
3067 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3068 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3071 You can also post articles and send mail from this buffer. To
3072 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3073 of an article, type `\\[gnus-summary-reply]'.
3075 There are approx. one gazillion commands you can execute in this
3076 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3078 The following commands are available:
3080 \\{gnus-summary-mode-map}"
3082 (kill-all-local-variables)
3083 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3084 (gnus-summary-make-local-variables))
3085 (gnus-summary-make-local-variables)
3086 (setq gnus-newsgroup-name group)
3087 (when (gnus-visual-p 'summary-menu 'menu)
3088 (gnus-summary-make-menu-bar)
3089 (gnus-summary-make-tool-bar))
3090 (gnus-make-thread-indent-array)
3091 (gnus-simplify-mode-line)
3092 (setq major-mode 'gnus-summary-mode)
3093 (setq mode-name "Summary")
3094 (use-local-map gnus-summary-mode-map)
3095 (buffer-disable-undo)
3096 (setq buffer-read-only t ;Disable modification
3097 show-trailing-whitespace nil)
3098 (setq truncate-lines t)
3099 (add-to-invisibility-spec '(gnus-sum . t))
3100 (gnus-summary-set-display-table)
3101 (gnus-set-default-directory)
3102 (make-local-variable 'gnus-summary-line-format)
3103 (make-local-variable 'gnus-summary-line-format-spec)
3104 (make-local-variable 'gnus-summary-dummy-line-format)
3105 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3106 (make-local-variable 'gnus-summary-mark-positions)
3107 (gnus-make-local-hook 'pre-command-hook)
3108 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3109 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3110 (turn-on-gnus-mailing-list-mode)
3111 (mm-enable-multibyte)
3112 (set (make-local-variable 'bookmark-make-record-function)
3113 'gnus-summary-bookmark-make-record)
3114 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3115 (gnus-update-summary-mark-positions))
3117 (defun gnus-summary-make-local-variables ()
3118 "Make all the local summary buffer variables."
3120 (dolist (local gnus-summary-local-variables)
3123 (if (eq (cdr local) 'global)
3124 ;; Copy the global value of the variable.
3125 (setq global (symbol-value (car local)))
3126 ;; Use the value from the list.
3127 (setq global (eval (cdr local))))
3128 (set (make-local-variable (car local)) global))
3129 ;; Simple nil-valued local variable.
3130 (set (make-local-variable local) nil)))))
3132 ;; Summary data functions.
3134 (defmacro gnus-data-number (data)
3137 (defmacro gnus-data-set-number (data number)
3138 `(setcar ,data ,number))
3140 (defmacro gnus-data-mark (data)
3143 (defmacro gnus-data-set-mark (data mark)
3144 `(setcar (nthcdr 1 ,data) ,mark))
3146 (defmacro gnus-data-pos (data)
3149 (defmacro gnus-data-set-pos (data pos)
3150 `(setcar (nthcdr 2 ,data) ,pos))
3152 (defmacro gnus-data-header (data)
3155 (defmacro gnus-data-set-header (data header)
3156 `(setf (nth 3 ,data) ,header))
3158 (defmacro gnus-data-level (data)
3161 (defmacro gnus-data-unread-p (data)
3162 `(= (nth 1 ,data) gnus-unread-mark))
3164 (defmacro gnus-data-read-p (data)
3165 `(/= (nth 1 ,data) gnus-unread-mark))
3167 (defmacro gnus-data-pseudo-p (data)
3168 `(consp (nth 3 ,data)))
3170 (defmacro gnus-data-find (number)
3171 `(assq ,number gnus-newsgroup-data))
3173 (defmacro gnus-data-find-list (number &optional data)
3174 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3175 (memq (assq ,number bdata)
3178 (defmacro gnus-data-make (number mark pos header level)
3179 `(list ,number ,mark ,pos ,header ,level))
3181 (defun gnus-data-enter (after-article number mark pos header level offset)
3182 (let ((data (gnus-data-find-list after-article)))
3184 (error "No such article: %d" after-article))
3185 (setcdr data (cons (gnus-data-make number mark pos header level)
3187 (setq gnus-newsgroup-data-reverse nil)
3188 (gnus-data-update-list (cddr data) offset)))
3190 (defun gnus-data-enter-list (after-article list &optional offset)
3192 (let ((data (and after-article (gnus-data-find-list after-article)))
3196 (let ((odata gnus-newsgroup-data))
3197 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3199 (gnus-data-update-list odata offset)))
3200 ;; Find the last element in the list to be spliced into the main
3202 (setq list (last list))
3205 (setcdr list gnus-newsgroup-data)
3206 (setq gnus-newsgroup-data ilist)
3208 (gnus-data-update-list (cdr list) offset)))
3209 (setcdr list (cdr data))
3212 (gnus-data-update-list (cdr list) offset))))
3213 (setq gnus-newsgroup-data-reverse nil))))
3215 (defun gnus-data-remove (article &optional offset)
3216 (let ((data gnus-newsgroup-data))
3217 (if (= (gnus-data-number (car data)) article)
3219 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3220 gnus-newsgroup-data-reverse nil)
3222 (gnus-data-update-list gnus-newsgroup-data offset)))
3224 (when (= (gnus-data-number (cadr data)) article)
3225 (setcdr data (cddr data))
3227 (gnus-data-update-list (cdr data) offset))
3229 gnus-newsgroup-data-reverse nil))
3230 (setq data (cdr data))))))
3232 (defmacro gnus-data-list (backward)
3234 (or gnus-newsgroup-data-reverse
3235 (setq gnus-newsgroup-data-reverse
3236 (reverse gnus-newsgroup-data)))
3237 gnus-newsgroup-data))
3239 (defun gnus-data-update-list (data offset)
3240 "Add OFFSET to the POS of all data entries in DATA."
3241 (setq gnus-newsgroup-data-reverse nil)
3243 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3244 (setq data (cdr data))))
3246 (defun gnus-summary-article-pseudo-p (article)
3247 "Say whether this article is a pseudo article or not."
3248 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3250 (defmacro gnus-summary-article-sparse-p (article)
3251 "Say whether this article is a sparse article or not."
3252 `(memq ,article gnus-newsgroup-sparse))
3254 (defmacro gnus-summary-article-ancient-p (article)
3255 "Say whether this article is a sparse article or not."
3256 `(memq ,article gnus-newsgroup-ancient))
3258 (defun gnus-article-parent-p (number)
3259 "Say whether this article is a parent or not."
3260 (let ((data (gnus-data-find-list number)))
3261 (and (cdr data) ; There has to be an article after...
3262 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3263 (gnus-data-level (nth 1 data))))))
3265 (defun gnus-article-children (number)
3266 "Return a list of all children to NUMBER."
3267 (let* ((data (gnus-data-find-list number))
3268 (level (gnus-data-level (car data)))
3270 (setq data (cdr data))
3272 (= (gnus-data-level (car data)) (1+ level)))
3273 (push (gnus-data-number (car data)) children)
3274 (setq data (cdr data)))
3277 (defmacro gnus-summary-skip-intangible ()
3278 "If the current article is intangible, then jump to a different article."
3279 '(let ((to (get-text-property (point) 'gnus-intangible)))
3280 (and to (gnus-summary-goto-subject to))))
3282 (defmacro gnus-summary-article-intangible-p ()
3283 "Say whether this article is intangible or not."
3284 '(get-text-property (point) 'gnus-intangible))
3286 (defun gnus-article-read-p (article)
3287 "Say whether ARTICLE is read or not."
3288 (not (or (memq article gnus-newsgroup-marked)
3289 (memq article gnus-newsgroup-spam-marked)
3290 (memq article gnus-newsgroup-unreads)
3291 (memq article gnus-newsgroup-unselected)
3292 (memq article gnus-newsgroup-dormant))))
3294 ;; Some summary mode macros.
3296 (defmacro gnus-summary-article-number ()
3297 "The article number of the article on the current line.
3298 If there isn't an article number here, then we return the current
3301 (gnus-summary-skip-intangible)
3302 (or (get-text-property (point) 'gnus-number)
3303 (gnus-summary-last-subject))))
3305 (defmacro gnus-summary-article-header (&optional number)
3306 "Return the header of article NUMBER."
3307 `(gnus-data-header (gnus-data-find
3308 ,(or number '(gnus-summary-article-number)))))
3310 (defmacro gnus-summary-thread-level (&optional number)
3311 "Return the level of thread that starts with article NUMBER."
3312 `(if (and (eq gnus-summary-make-false-root 'dummy)
3313 (get-text-property (point) 'gnus-intangible))
3315 (gnus-data-level (gnus-data-find
3316 ,(or number '(gnus-summary-article-number))))))
3318 (defmacro gnus-summary-article-mark (&optional number)
3319 "Return the mark of article NUMBER."
3320 `(gnus-data-mark (gnus-data-find
3321 ,(or number '(gnus-summary-article-number)))))
3323 (defmacro gnus-summary-article-pos (&optional number)
3324 "Return the position of the line of article NUMBER."
3325 `(gnus-data-pos (gnus-data-find
3326 ,(or number '(gnus-summary-article-number)))))
3328 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3329 (defmacro gnus-summary-article-subject (&optional number)
3330 "Return current subject string or nil if nothing."
3333 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3334 '(gnus-data-header (assq (gnus-summary-article-number)
3335 gnus-newsgroup-data)))))
3338 (mail-header-subject headers))))
3340 (defmacro gnus-summary-article-score (&optional number)
3341 "Return current article score."
3342 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3343 gnus-newsgroup-scored))
3344 gnus-summary-default-score 0))
3346 (defun gnus-summary-article-children (&optional number)
3347 "Return a list of article numbers that are children of article NUMBER."
3348 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3349 (level (gnus-data-level (car data)))
3351 (while (and (setq data (cdr data))
3352 (> (setq l (gnus-data-level (car data))) level))
3353 (and (= (1+ level) l)
3354 (push (gnus-data-number (car data))
3356 (nreverse children)))
3358 (defun gnus-summary-article-parent (&optional number)
3359 "Return the article number of the parent of article NUMBER."
3360 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3361 (gnus-data-list t)))
3362 (level (gnus-data-level (car data))))
3364 () ; This is a root.
3365 ;; We search until we find an article with a level less than
3366 ;; this one. That function has to be the parent.
3367 (while (and (setq data (cdr data))
3368 (not (< (gnus-data-level (car data)) level))))
3369 (and data (gnus-data-number (car data))))))
3371 (defun gnus-unread-mark-p (mark)
3372 "Say whether MARK is the unread mark."
3373 (= mark gnus-unread-mark))
3375 (defun gnus-read-mark-p (mark)
3376 "Say whether MARK is one of the marks that mark as read.
3377 This is all marks except unread, ticked, dormant, and expirable."
3378 (not (or (= mark gnus-unread-mark)
3379 (= mark gnus-ticked-mark)
3380 (= mark gnus-spam-mark)
3381 (= mark gnus-dormant-mark)
3382 (= mark gnus-expirable-mark))))
3384 (defmacro gnus-article-mark (number)
3385 "Return the MARK of article NUMBER.
3386 This macro should only be used when computing the mark the \"first\"
3387 time; i.e., when generating the summary lines. After that,
3388 `gnus-summary-article-mark' should be used to examine the
3391 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3392 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3393 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3394 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3395 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3396 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3397 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3398 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3399 gnus-ancient-mark))))
3401 ;; Saving hidden threads.
3403 (defmacro gnus-save-hidden-threads (&rest forms)
3404 "Save hidden threads, eval FORMS, and restore the hidden threads."
3405 (let ((config (make-symbol "config")))
3406 `(let ((,config (gnus-hidden-threads-configuration)))
3410 (gnus-restore-hidden-threads-configuration ,config)))))
3411 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3412 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3414 (defun gnus-data-compute-positions ()
3415 "Compute the positions of all articles."
3416 (setq gnus-newsgroup-data-reverse nil)
3417 (let ((data gnus-newsgroup-data))
3419 (gnus-save-hidden-threads
3420 (gnus-summary-show-all-threads)
3421 (goto-char (point-min))
3423 (while (get-text-property (point) 'gnus-intangible)
3425 (gnus-data-set-pos (car data) (+ (point) 3))
3426 (setq data (cdr data))
3427 (forward-line 1))))))
3429 (defun gnus-hidden-threads-configuration ()
3430 "Return the current hidden threads configuration."
3433 (goto-char (point-min))
3435 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3436 (push (save-excursion (forward-line 0) (point)) config))
3440 (defun gnus-restore-hidden-threads-configuration (config)
3441 "Restore hidden threads configuration from CONFIG."
3443 (let (point (inhibit-read-only t))
3444 (while (setq point (pop config))
3446 (gnus-summary-hide-thread)))))
3448 ;; Various summary mode internalish functions.
3450 (defun gnus-mouse-pick-article (e)
3453 (gnus-summary-next-page nil t))
3455 (defun gnus-summary-set-display-table ()
3456 "Change the display table.
3457 Odd characters have a tendency to mess
3458 up nicely formatted displays - we make all possible glyphs
3459 display only a single character."
3461 ;; We start from the standard display table, if any.
3462 (let ((table (or (copy-sequence standard-display-table)
3463 (make-display-table)))
3465 ;; Nix out all the control chars...
3466 (while (>= (setq i (1- i)) 0)
3467 (gnus-put-display-table i [??] table))
3468 ;; ... but not newline and cr, of course. (cr is necessary for the
3469 ;; selective display).
3470 (gnus-put-display-table ?\n nil table)
3471 (gnus-put-display-table ?\r nil table)
3472 ;; We keep TAB as well.
3473 (gnus-put-display-table ?\t nil table)
3474 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3475 ;; Emacs 23 (unicode), that are not set already.
3476 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3479 (while (>= (setq i (1- i)) 127)
3480 ;; Only modify if the entry is nil.
3481 (unless (gnus-get-display-table i table)
3482 (gnus-put-display-table i [??] table))))
3483 (setq buffer-display-table table)))
3485 (defun gnus-summary-set-article-display-arrow (pos)
3486 "Update the overlay arrow to point to line at position POS."
3487 (when gnus-summary-display-arrow
3488 (make-local-variable 'overlay-arrow-position)
3489 (make-local-variable 'overlay-arrow-string)
3493 (unless overlay-arrow-position
3494 (setq overlay-arrow-position (make-marker)))
3495 (setq overlay-arrow-string "=>"
3496 overlay-arrow-position (set-marker overlay-arrow-position
3498 (current-buffer))))))
3500 (defun gnus-summary-setup-buffer (group)
3501 "Initialize summary buffer."
3502 (let ((buffer (gnus-summary-buffer-name group))
3503 (dead-name (concat "*Dead Summary "
3504 (gnus-group-decoded-name group) "*")))
3505 ;; If a dead summary buffer exists, we kill it.
3506 (when (gnus-buffer-live-p dead-name)
3507 (gnus-kill-buffer dead-name))
3508 (if (get-buffer buffer)
3511 (setq gnus-summary-buffer (current-buffer))
3512 (not gnus-newsgroup-prepared))
3513 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3514 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3515 (gnus-summary-mode group)
3516 (when (gnus-group-quit-config group)
3517 (set (make-local-variable 'gnus-single-article-buffer) nil))
3518 (make-local-variable 'gnus-article-buffer)
3519 (make-local-variable 'gnus-article-current)
3520 (make-local-variable 'gnus-original-article-buffer)
3521 (setq gnus-newsgroup-name group)
3522 ;; Set any local variables in the group parameters.
3523 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3526 (defun gnus-set-global-variables ()
3527 "Set the global equivalents of the buffer-local variables.
3528 They are set to the latest values they had. These reflect the summary
3529 buffer that was in action when the last article was fetched."
3530 (when (eq major-mode 'gnus-summary-mode)
3531 (setq gnus-summary-buffer (current-buffer))
3532 (let ((name gnus-newsgroup-name)
3533 (marked gnus-newsgroup-marked)
3534 (spam gnus-newsgroup-spam-marked)
3535 (unread gnus-newsgroup-unreads)
3536 (headers gnus-current-headers)
3537 (data gnus-newsgroup-data)
3538 (summary gnus-summary-buffer)
3539 (article-buffer gnus-article-buffer)
3540 (original gnus-original-article-buffer)
3541 (gac gnus-article-current)
3542 (reffed gnus-reffed-article-number)
3543 (score-file gnus-current-score-file)
3544 (default-charset gnus-newsgroup-charset)
3546 (let ((locals gnus-newsgroup-variables))
3548 (if (consp (car locals))
3549 (push (eval (caar locals)) vlist)
3550 (push (eval (car locals)) vlist))
3551 (setq locals (cdr locals)))
3552 (setq vlist (nreverse vlist)))
3553 (with-current-buffer gnus-group-buffer
3554 (setq gnus-newsgroup-name name
3555 gnus-newsgroup-marked marked
3556 gnus-newsgroup-spam-marked spam
3557 gnus-newsgroup-unreads unread
3558 gnus-current-headers headers
3559 gnus-newsgroup-data data
3560 gnus-article-current gac
3561 gnus-summary-buffer summary
3562 gnus-article-buffer article-buffer
3563 gnus-original-article-buffer original
3564 gnus-reffed-article-number reffed
3565 gnus-current-score-file score-file
3566 gnus-newsgroup-charset default-charset)
3567 (let ((locals gnus-newsgroup-variables))
3569 (if (consp (car locals))
3570 (set (caar locals) (pop vlist))
3571 (set (car locals) (pop vlist)))
3572 (setq locals (cdr locals))))
3573 ;; The article buffer also has local variables.
3574 (when (gnus-buffer-live-p gnus-article-buffer)
3575 (set-buffer gnus-article-buffer)
3576 (setq gnus-summary-buffer summary))))))
3578 (defun gnus-summary-article-unread-p (article)
3579 "Say whether ARTICLE is unread or not."
3580 (memq article gnus-newsgroup-unreads))
3582 (defun gnus-summary-first-article-p (&optional article)
3583 "Return whether ARTICLE is the first article in the buffer."
3584 (if (not (setq article (or article (gnus-summary-article-number))))
3586 (eq article (caar gnus-newsgroup-data))))
3588 (defun gnus-summary-last-article-p (&optional article)
3589 "Return whether ARTICLE is the last article in the buffer."
3590 (if (not (setq article (or article (gnus-summary-article-number))))
3591 ;; All non-existent numbers are the last article. :-)
3593 (not (cdr (gnus-data-find-list article)))))
3595 (defun gnus-make-thread-indent-array (&optional n)
3597 (progn (setq n 200) nil)
3598 (null gnus-thread-indent-array)
3599 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3600 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3601 gnus-thread-indent-array-level gnus-thread-indent-level)
3603 (aset gnus-thread-indent-array n
3604 (make-string (* n gnus-thread-indent-level) ? ))
3607 (defun gnus-update-summary-mark-positions ()
3608 "Compute where the summary marks are to go."
3610 (when (gnus-buffer-exists-p gnus-summary-buffer)
3611 (set-buffer gnus-summary-buffer))
3612 (let ((spec gnus-summary-line-format-spec)
3615 (gnus-set-work-buffer)
3616 (let ((gnus-tmp-unread ?Z)
3617 (gnus-replied-mark ?Z)
3618 (gnus-score-below-mark ?Z)
3619 (gnus-score-over-mark ?Z)
3620 (gnus-undownloaded-mark ?Z)
3621 (gnus-summary-line-format-spec spec)
3622 (gnus-newsgroup-downloadable '(0))
3623 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3624 case-fold-search ignores)
3625 ;; Here, all marks are bound to Z.
3626 (gnus-summary-insert-line header
3627 0 nil t gnus-tmp-unread t nil "" nil 1)
3628 (goto-char (point-min))
3629 ;; Memorize the positions of the same characters as dummy marks.
3630 (while (re-search-forward "[A-D]" nil t)
3631 (push (point) ignores))
3633 ;; We use A-D as dummy marks in order to know column positions
3634 ;; where marks should be inserted.
3635 (setq gnus-tmp-unread ?A
3636 gnus-replied-mark ?B
3637 gnus-score-below-mark ?C
3638 gnus-score-over-mark ?C
3639 gnus-undownloaded-mark ?D)
3640 (gnus-summary-insert-line header
3641 0 nil t gnus-tmp-unread t nil "" nil 1)
3642 ;; Ignore characters which aren't dummy marks.
3644 (delete-region (goto-char (1- p)) p)
3646 (goto-char (point-min))
3647 (setq pos (list (cons 'unread
3648 (and (search-forward "A" nil t)
3649 (- (point) (point-min) 1)))))
3650 (goto-char (point-min))
3651 (push (cons 'replied (and (search-forward "B" nil t)
3652 (- (point) (point-min) 1)))
3654 (goto-char (point-min))
3655 (push (cons 'score (and (search-forward "C" nil t)
3656 (- (point) (point-min) 1)))
3658 (goto-char (point-min))
3659 (push (cons 'download (and (search-forward "D" nil t)
3660 (- (point) (point-min) 1)))
3662 (setq gnus-summary-mark-positions pos))))
3664 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3665 "Insert a dummy root in the summary buffer."
3667 (gnus-add-text-properties
3668 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3669 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3671 (defun gnus-summary-extract-address-component (from)
3672 (or (car (funcall gnus-extract-address-components from))
3675 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3676 (let ((mail-parse-charset gnus-newsgroup-charset)
3677 (ignored-from-addresses (gnus-ignored-from-addresses))
3678 ; Is it really necessary to do this next part for each summary line?
3679 ; Luckily, doesn't seem to slow things down much.
3680 (mail-parse-ignored-charsets
3681 (with-current-buffer gnus-summary-buffer
3682 gnus-newsgroup-ignored-charsets)))
3684 (and ignored-from-addresses
3685 (string-match ignored-from-addresses gnus-tmp-from)
3686 (let ((extra-headers (mail-header-extra header))
3690 ((setq to (cdr (assq 'To extra-headers)))
3691 (concat gnus-summary-to-prefix
3693 (gnus-summary-extract-address-component
3694 (funcall gnus-decode-encoded-address-function to)))))
3697 (cdr (assq 'Newsgroups extra-headers))
3699 (memq 'Newsgroups gnus-extra-headers)
3700 (eq (car (gnus-find-method-for-group
3701 gnus-newsgroup-name)) 'nntp)
3702 (gnus-group-real-name gnus-newsgroup-name))))
3703 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3704 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3706 (defun gnus-summary-insert-line (gnus-tmp-header
3707 gnus-tmp-level gnus-tmp-current
3708 undownloaded gnus-tmp-unread gnus-tmp-replied
3709 gnus-tmp-expirable gnus-tmp-subject-or-nil
3710 &optional gnus-tmp-dummy gnus-tmp-score
3712 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3713 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3715 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3716 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3717 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3718 (gnus-tmp-score-char
3719 (if (or (null gnus-summary-default-score)
3720 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3721 gnus-summary-zcore-fuzz))
3723 (if (< gnus-tmp-score gnus-summary-default-score)
3724 gnus-score-below-mark gnus-score-over-mark)))
3725 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3727 (cond (gnus-tmp-process gnus-process-mark)
3728 ((memq gnus-tmp-current gnus-newsgroup-cached)
3730 (gnus-tmp-replied gnus-replied-mark)
3731 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3732 gnus-forwarded-mark)
3733 ((memq gnus-tmp-current gnus-newsgroup-saved)
3735 ((memq gnus-tmp-number gnus-newsgroup-recent)
3737 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3740 (gnus-tmp-downloaded
3742 gnus-undownloaded-mark)
3743 (gnus-newsgroup-agentized
3744 gnus-downloaded-mark)
3747 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3750 ((string-match "<[^>]+> *$" gnus-tmp-from)
3751 (let ((beg (match-beginning 0)))
3752 (or (and (string-match "^\".+\"" gnus-tmp-from)
3753 (substring gnus-tmp-from 1 (1- (match-end 0))))
3754 (substring gnus-tmp-from 0 beg))))
3755 ((string-match "(.+)" gnus-tmp-from)
3756 (substring gnus-tmp-from
3757 (1+ (match-beginning 0)) (1- (match-end 0))))
3759 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3760 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3761 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3762 (inhibit-read-only t))
3763 (when (string= gnus-tmp-name "")
3764 (setq gnus-tmp-name gnus-tmp-from))
3765 (unless (numberp gnus-tmp-lines)
3766 (setq gnus-tmp-lines -1))
3767 (if (= gnus-tmp-lines -1)
3768 (setq gnus-tmp-lines "?")
3769 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3771 (gnus-put-text-property
3773 (progn (eval gnus-summary-line-format-spec) (point))
3774 'gnus-number gnus-tmp-number)
3775 (error (gnus-message 5 "Error updating the summary line")))
3776 (when (gnus-visual-p 'summary-highlight 'highlight)
3778 (gnus-summary-highlight-line)
3779 (gnus-run-hooks 'gnus-summary-update-hook)
3782 (defun gnus-summary-update-line (&optional dont-update)
3783 "Update summary line after change."
3784 (when (and gnus-summary-default-score
3785 (not gnus-summary-inhibit-highlight))
3786 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3787 (article (gnus-summary-article-number))
3788 (score (gnus-summary-article-score article)))
3790 (if (and gnus-summary-mark-below
3791 (< (gnus-summary-article-score)
3792 gnus-summary-mark-below))
3793 ;; This article has a low score, so we mark it as read.
3794 (when (memq article gnus-newsgroup-unreads)
3795 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3796 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3797 ;; This article was previously marked as read on account
3798 ;; of a low score, but now it has risen, so we mark it as
3800 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3801 (gnus-summary-update-mark
3802 (if (or (null gnus-summary-default-score)
3803 (<= (abs (- score gnus-summary-default-score))
3804 gnus-summary-zcore-fuzz))
3806 (if (< score gnus-summary-default-score)
3807 gnus-score-below-mark gnus-score-over-mark))
3809 ;; Do visual highlighting.
3810 (when (gnus-visual-p 'summary-highlight 'highlight)
3811 (gnus-summary-highlight-line)
3812 (gnus-run-hooks 'gnus-summary-update-hook)))))
3814 (defvar gnus-tmp-new-adopts nil)
3816 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3817 "Return the number of articles in THREAD.
3818 This may be 0 in some cases -- if none of the articles in
3819 the thread are to be displayed."
3821 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3823 ((not (listp thread))
3825 ((and (consp thread) (cdr thread))
3828 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3831 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3834 (when (and level (zerop level) gnus-tmp-new-adopts)
3837 'gnus-summary-number-of-articles-in-thread
3838 gnus-tmp-new-adopts))))
3840 (if (> number 1) gnus-not-empty-thread-mark
3841 gnus-empty-thread-mark)
3844 (defsubst gnus-summary-line-message-size (head)
3845 "Return pretty-printed version of message size.
3846 This function is intended to be used in
3847 `gnus-summary-line-format-alist'."
3848 (let ((c (or (mail-header-chars head) -1)))
3849 (cond ((< c 0) "n/a") ; chars not available
3850 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3851 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3852 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3853 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3855 (defcustom gnus-summary-user-date-format-alist
3856 '(((gnus-seconds-today) . "Today, %H:%M")
3857 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3858 (604800 . "%A %H:%M") ; That's one week
3859 ((gnus-seconds-month) . "%A %d")
3860 ((gnus-seconds-year) . "%B %d")
3861 (t . "%b %d %Y")) ; This one is used when no other
3863 "Specifies date format depending on age of article.
3864 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3865 seconds) or a Lisp expression evaluating to a number. When the age of
3866 the article is less than this number, then use `format-time-string'
3867 with the corresponding FORMAT for displaying the date of the article.
3868 If AGE is not a number or a Lisp expression evaluating to a
3869 non-number, then the corresponding FORMAT is used as a default value.
3871 Note that the list is processed from the beginning, so it should be
3872 sorted by ascending AGE. Also note that items following the first
3873 non-number AGE will be ignored.
3875 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3876 and `gnus-seconds-year' in the AGE spec. They return the number of
3877 seconds passed since the start of today, of this month, of this year,
3880 :group 'gnus-summary-format
3881 :type '(alist :key-type sexp :value-type string))
3882 (make-obsolete-variable 'gnus-user-date-format-alist
3883 'gnus-summary-user-date-format-alist "24.1")
3885 (defun gnus-summary-user-date (messy-date)
3886 "Format the messy-date according to `gnus-summary-user-date-format-alist'.
3887 Returns \" ? \" if there's bad input or if another error occurs.
3888 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3890 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3891 (now (gnus-float-time))
3892 ;;If we don't find something suitable we'll use this one
3893 (my-format "%b %d '%y"))
3894 (let* ((difference (- now messy-date))
3895 (templist gnus-summary-user-date-format-alist)
3896 (top (eval (caar templist))))
3897 (while (if (numberp top) (< top difference) (not top))
3899 (setq templist (cdr templist))
3900 (setq top (eval (caar templist)))))
3901 (if (stringp (cdr (car templist)))
3902 (setq my-format (cdr (car templist)))))
3903 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3906 (defun gnus-summary-set-local-parameters (group)
3907 "Go through the local params of GROUP and set all variable specs in that list."
3908 (let ((vars '(quit-config active))) ; Ignore things that aren't
3910 (dolist (elem (gnus-group-find-parameter group))
3911 (and (consp elem) ; Has to be a cons.
3912 (consp (cdr elem)) ; The cdr has to be a list.
3913 (symbolp (car elem)) ; Has to be a symbol in there.
3914 (not (memq (car elem) vars))
3916 (push (car elem) vars)
3917 ;; Variables like `gnus-show-threads' that are globally
3918 ;; bound, if used as group parameters, need to get to be
3919 ;; buffer-local, whereas just parameters like `gcc-self',
3920 ;; `timestamp', etc. should not be bound as variables.
3921 (if (boundp (car elem))
3922 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3923 (eval (nth 1 elem))))))))
3925 (defun gnus-summary-read-group (group &optional show-all no-article
3926 kill-buffer no-display backward
3928 "Start reading news in newsgroup GROUP.
3929 If SHOW-ALL is non-nil, already read articles are also listed.
3930 If NO-ARTICLE is non-nil, no article is selected initially.
3931 If NO-DISPLAY, don't generate a summary buffer."
3935 (let ((gnus-auto-select-next nil))
3936 (or (gnus-summary-read-group-1
3937 group show-all no-article
3938 kill-buffer no-display
3941 select-articles nil)))))
3942 (eq gnus-auto-select-next 'quietly))
3943 (set-buffer gnus-group-buffer)
3944 ;; The entry function called above goes to the next
3945 ;; group automatically, so we go two groups back
3946 ;; if we are searching for the previous group.
3948 (gnus-group-prev-unread-group 2))
3949 (if (not (equal group (gnus-group-group-name)))
3950 (setq group (gnus-group-group-name))
3954 (defun gnus-summary-read-group-1 (group show-all no-article
3955 kill-buffer no-display
3956 &optional select-articles)
3957 ;; Killed foreign groups can't be entered.
3958 ;; (when (and (not (gnus-group-native-p group))
3959 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3960 ;; (error "Dead non-native groups can't be entered"))
3961 (gnus-message 5 "Retrieving newsgroup: %s..."
3962 (gnus-group-decoded-name group))
3963 (let* ((new-group (gnus-summary-setup-buffer group))
3964 (quit-config (gnus-group-quit-config group))
3965 (did-select (and new-group (gnus-select-newsgroup
3966 group show-all select-articles))))
3968 ;; This summary buffer exists already, so we just select it.
3970 (gnus-set-global-variables)
3972 (gnus-kill-or-deaden-summary kill-buffer))
3973 (gnus-configure-windows 'summary 'force)
3974 (gnus-set-mode-line 'summary)
3975 (gnus-summary-position-point)
3978 ;; We couldn't select this group.
3980 (when (and (eq major-mode 'gnus-summary-mode)
3981 (not (equal (current-buffer) kill-buffer)))
3982 (kill-buffer (current-buffer))
3983 (if (not quit-config)
3985 ;; Update the info -- marks might need to be removed,
3987 (gnus-summary-update-info)
3988 (set-buffer gnus-group-buffer)
3989 (gnus-group-jump-to-group group)
3990 (gnus-group-next-unread-group 1))
3991 (gnus-handle-ephemeral-exit quit-config)))
3992 (if (null (gnus-list-of-unread-articles group))
3993 (gnus-message 3 "Group %s contains no messages" group)
3994 (gnus-message 3 "Can't select group"))
3996 ;; The user did a `C-g' while prompting for number of articles,
3997 ;; so we exit this group.
3998 ((eq did-select 'quit)
3999 (and (eq major-mode 'gnus-summary-mode)
4000 (not (equal (current-buffer) kill-buffer))
4001 (kill-buffer (current-buffer)))
4003 (gnus-kill-or-deaden-summary kill-buffer))
4004 (if (not quit-config)
4006 (set-buffer gnus-group-buffer)
4007 (gnus-group-jump-to-group group)
4008 (gnus-configure-windows 'group 'force))
4009 (gnus-handle-ephemeral-exit quit-config))
4010 ;; Finally signal the quit.
4012 ;; The group was successfully selected.
4014 (gnus-set-global-variables)
4015 ;; Save the active value in effect when the group was entered.
4016 (setq gnus-newsgroup-active
4018 (gnus-active gnus-newsgroup-name)))
4019 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4020 ;; You can change the summary buffer in some way with this hook.
4021 (gnus-run-hooks 'gnus-select-group-hook)
4022 (when (memq 'summary (gnus-update-format-specifications
4023 nil 'summary 'summary-mode 'summary-dummy))
4024 ;; The format specification for the summary line was updated,
4025 ;; so we need to update the mark positions as well.
4026 (gnus-update-summary-mark-positions))
4027 ;; Do score processing.
4028 (when gnus-use-scoring
4029 (gnus-possibly-score-headers))
4030 ;; Check whether to fill in the gaps in the threads.
4031 (when gnus-build-sparse-threads
4032 (gnus-build-sparse-threads))
4033 ;; Find the initial limit.
4035 (let ((gnus-newsgroup-dormant nil))
4036 (gnus-summary-initial-limit show-all))
4037 (gnus-summary-initial-limit show-all))
4038 ;; Generate the summary buffer.
4040 (gnus-summary-prepare))
4041 (when gnus-use-trees
4042 (gnus-tree-open group)
4043 (setq gnus-summary-highlight-line-function
4044 'gnus-tree-highlight-article))
4045 ;; If the summary buffer is empty, but there are some low-scored
4046 ;; articles or some excluded dormants, we include these in the
4048 (when (and (zerop (buffer-size))
4050 (cond (gnus-newsgroup-dormant
4051 (gnus-summary-limit-include-dormant))
4052 ((and gnus-newsgroup-scored show-all)
4053 (gnus-summary-limit-include-expunged t))))
4054 ;; Function `gnus-apply-kill-file' must be called in this hook.
4055 (gnus-run-hooks 'gnus-apply-kill-hook)
4056 (if (and (zerop (buffer-size))
4059 ;; This newsgroup is empty.
4060 (gnus-summary-catchup-and-exit nil t)
4061 (gnus-message 6 "No unread news")
4063 (gnus-kill-or-deaden-summary kill-buffer))
4064 ;; Return nil from this function.
4066 ;; Hide conversation thread subtrees. We cannot do this in
4067 ;; gnus-summary-prepare-hook since kill processing may not
4068 ;; work with hidden articles.
4069 (gnus-summary-maybe-hide-threads)
4071 (gnus-kill-or-deaden-summary kill-buffer))
4072 (gnus-summary-auto-select-subject)
4073 ;; Show first unread article if requested.
4074 (if (and (not no-article)
4076 gnus-newsgroup-unreads
4077 gnus-auto-select-first)
4079 (gnus-configure-windows 'summary)
4080 (let ((art (gnus-summary-article-number)))
4081 (unless (and (not gnus-plugged)
4082 (or (memq art gnus-newsgroup-undownloaded)
4083 (memq art gnus-newsgroup-downloadable)))
4084 (gnus-summary-goto-article art))))
4085 ;; Don't select any articles.
4086 (gnus-summary-position-point)
4087 (gnus-configure-windows 'summary 'force)
4088 (gnus-set-mode-line 'summary))
4089 (when (and gnus-auto-center-group
4090 (get-buffer-window gnus-group-buffer t))
4091 ;; Gotta use windows, because recenter does weird stuff if
4092 ;; the current buffer ain't the displayed window.
4093 (let ((owin (selected-window)))
4094 (select-window (get-buffer-window gnus-group-buffer t))
4095 (when (gnus-group-goto-group group)
4097 (select-window owin)))
4098 ;; Mark this buffer as "prepared".
4099 (setq gnus-newsgroup-prepared t)
4100 (gnus-run-hooks 'gnus-summary-prepared-hook)
4101 (unless (gnus-ephemeral-group-p group)
4102 (gnus-group-update-group group))
4105 (defun gnus-summary-auto-select-subject ()
4106 "Select the subject line on initial group entry."
4107 (goto-char (point-min))
4109 ((eq gnus-auto-select-subject 'best)
4110 (gnus-summary-best-unread-subject))
4111 ((eq gnus-auto-select-subject 'unread)
4112 (gnus-summary-first-unread-subject))
4113 ((eq gnus-auto-select-subject 'unseen)
4114 (gnus-summary-first-unseen-subject))
4115 ((eq gnus-auto-select-subject 'unseen-or-unread)
4116 (gnus-summary-first-unseen-or-unread-subject))
4117 ((eq gnus-auto-select-subject 'first)
4120 ((functionp gnus-auto-select-subject)
4121 (funcall gnus-auto-select-subject))))
4123 (defun gnus-summary-prepare ()
4124 "Generate the summary buffer."
4126 (let ((inhibit-read-only t))
4128 (setq gnus-newsgroup-data nil
4129 gnus-newsgroup-data-reverse nil)
4130 (gnus-run-hooks 'gnus-summary-generate-hook)
4131 ;; Generate the buffer, either with threads or without.
4132 (when gnus-newsgroup-headers
4133 (gnus-summary-prepare-threads
4134 (if gnus-show-threads
4135 (gnus-sort-gathered-threads
4136 (funcall gnus-summary-thread-gathering-function
4138 (gnus-cut-threads (gnus-make-threads)))))
4139 ;; Unthreaded display.
4140 (gnus-sort-articles gnus-newsgroup-headers))))
4141 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4142 ;; Call hooks for modifying summary buffer.
4143 (goto-char (point-min))
4144 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4146 (defsubst gnus-general-simplify-subject (subject)
4147 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4150 ;; Truncate the subject.
4151 (gnus-simplify-subject-functions
4152 (gnus-map-function gnus-simplify-subject-functions subject))
4153 ((numberp gnus-summary-gather-subject-limit)
4154 (setq subject (gnus-simplify-subject-re subject))
4155 (if (> (length subject) gnus-summary-gather-subject-limit)
4156 (substring subject 0 gnus-summary-gather-subject-limit)
4158 ;; Fuzzily simplify it.
4159 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4160 (gnus-simplify-subject-fuzzy subject))
4161 ;; Just remove the leading "Re:".
4163 (gnus-simplify-subject-re subject))))
4165 (if (and gnus-summary-gather-exclude-subject
4166 (string-match gnus-summary-gather-exclude-subject subject))
4167 nil ; This article shouldn't be gathered
4170 (defun gnus-summary-simplify-subject-query ()
4171 "Query where the respool algorithm would put this article."
4173 (gnus-summary-select-article)
4174 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4176 (defun gnus-gather-threads-by-subject (threads)
4177 "Gather threads by looking at Subject headers."
4178 (if (not gnus-summary-make-false-root)
4180 (let ((hashtb (gnus-make-hashtable 1024))
4183 subject hthread whole-subject)
4185 (setq subject (gnus-general-simplify-subject
4186 (setq whole-subject (mail-header-subject
4189 (if (setq hthread (gnus-gethash subject hashtb))
4191 ;; We enter a dummy root into the thread, if we
4192 ;; haven't done that already.
4193 (unless (stringp (caar hthread))
4194 (setcar hthread (list whole-subject (car hthread))))
4195 ;; We add this new gathered thread to this gathered
4197 (setcdr (car hthread)
4198 (nconc (cdar hthread) (list (car threads))))
4199 ;; Remove it from the list of threads.
4200 (setcdr prev (cdr threads))
4201 (setq threads prev))
4202 ;; Enter this thread into the hash table.
4203 (gnus-sethash subject
4204 (if gnus-summary-make-false-root-always
4206 ;; If you want a dummy root above all
4208 (setcar threads (list whole-subject
4214 (setq threads (cdr threads)))
4217 (defun gnus-gather-threads-by-references (threads)
4218 "Gather threads by looking at References headers."
4219 (let ((idhashtb (gnus-make-hashtable 1024))
4220 (thhashtb (gnus-make-hashtable 1024))
4223 ids references id gthread gid entered ref)
4225 (when (setq references (mail-header-references (caar threads)))
4226 (setq id (mail-header-id (caar threads))
4227 ids (inline (gnus-split-references references))
4229 (while (setq ref (pop ids))
4230 (setq ids (delete ref ids))
4231 (if (not (setq gid (gnus-gethash ref idhashtb)))
4233 (gnus-sethash ref id idhashtb)
4234 (gnus-sethash id threads thhashtb))
4235 (setq gthread (gnus-gethash gid thhashtb))
4237 ;; We enter a dummy root into the thread, if we
4238 ;; haven't done that already.
4239 (unless (stringp (caar gthread))
4240 (setcar gthread (list (mail-header-subject (caar gthread))
4242 ;; We add this new gathered thread to this gathered
4244 (setcdr (car gthread)
4245 (nconc (cdar gthread) (list (car threads)))))
4246 ;; Add it into the thread hash table.
4247 (gnus-sethash id gthread thhashtb)
4249 ;; Remove it from the list of threads.
4250 (setcdr prev (cdr threads))
4251 (setq threads prev))))
4253 (setq threads (cdr threads)))
4256 (defun gnus-sort-gathered-threads (threads)
4257 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4258 (let ((result threads))
4260 (when (stringp (caar threads))
4261 (setcdr (car threads)
4262 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4263 (setq threads (cdr threads)))
4266 (defun gnus-thread-loop-p (root thread)
4267 "Say whether ROOT is in THREAD."
4268 (let ((stack (list thread))
4271 (while (setq thread (pop stack))
4272 (setq th (cdr thread))
4274 (not (eq (caar th) root)))
4277 ;; We have found a loop.
4279 (setcdr thread (delq (car th) (cdr thread)))
4280 (if (boundp (setq ref-dep (intern "none"
4281 gnus-newsgroup-dependencies)))
4282 (setcdr (symbol-value ref-dep)
4283 (nconc (cdr (symbol-value ref-dep))
4285 (set ref-dep (list nil (car th))))
4288 ;; Push all the subthreads onto the stack.
4289 (push (cdr thread) stack)))
4292 (defun gnus-make-threads ()
4293 "Go through the dependency hashtb and find the roots. Return all threads."
4295 (while (catch 'infloop
4298 ;; Deal with self-referencing References loops.
4299 (when (and (car (symbol-value refs))
4306 (car (symbol-value refs)) thread))
4307 (cdr (symbol-value refs)))))))
4310 (unless (car (symbol-value refs))
4311 ;; These threads do not refer back to any other
4312 ;; articles, so they're roots.
4313 (setq threads (append (cdr (symbol-value refs)) threads))))
4314 gnus-newsgroup-dependencies)))
4317 ;; Build the thread tree.
4318 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4319 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4321 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4322 if it was already present.
4324 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4325 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4326 Message-IDs will be renamed to a unique Message-ID before being
4329 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4330 (let* ((id (mail-header-id header))
4331 (id-dep (and id (intern id dependencies)))
4332 parent-id ref ref-dep ref-header replaced)
4333 ;; Enter this `header' in the `dependencies' table.
4337 ;; The first two cases do the normal part: enter a new `header'
4338 ;; in the `dependencies' table.
4339 ((not (boundp id-dep))
4340 (set id-dep (list header)))
4341 ((null (car (symbol-value id-dep)))
4342 (setcar (symbol-value id-dep) header))
4344 ;; From here the `header' was already present in the
4345 ;; `dependencies' table.
4347 ;; Overrides an existing entry;
4348 ;; just set the header part of the entry.
4349 (setcar (symbol-value id-dep) header)
4352 ;; Renames the existing `header' to a unique Message-ID.
4353 ((not gnus-summary-ignore-duplicates)
4354 ;; An article with this Message-ID has already been seen.
4355 ;; We rename the Message-ID.
4356 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4358 (mail-header-set-id header id))
4360 ;; The last case ignores an existing entry, except it adds any
4361 ;; additional Xrefs (in case the two articles came from different
4363 ;; Also sets `header' to `nil' meaning that the `dependencies'
4364 ;; table was *not* modified.
4366 (mail-header-set-xref
4367 (car (symbol-value id-dep))
4368 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4370 (or (mail-header-xref header) "")))
4373 (when (and header (not replaced))
4374 ;; First check that we are not creating a References loop.
4375 (setq parent-id (gnus-parent-id (mail-header-references header)))
4376 (setq ref parent-id)
4378 (setq ref-dep (intern-soft ref dependencies))
4380 (setq ref-header (car (symbol-value ref-dep))))
4381 (if (string= id ref)
4382 ;; Yuk! This is a reference loop. Make the article be a
4385 (mail-header-set-references (car (symbol-value id-dep)) "none")
4387 (setq parent-id nil))
4388 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4389 (setq ref-dep (intern (or parent-id "none") dependencies))
4390 (if (boundp ref-dep)
4391 (setcdr (symbol-value ref-dep)
4392 (nconc (cdr (symbol-value ref-dep))
4393 (list (symbol-value id-dep))))
4394 (set ref-dep (list nil (symbol-value id-dep)))))
4397 (defun gnus-extract-message-id-from-in-reply-to (string)
4398 (if (string-match "<[^>]+>" string)
4399 (substring string (match-beginning 0) (match-end 0))
4402 (defun gnus-build-sparse-threads ()
4403 (let ((headers gnus-newsgroup-headers)
4404 (mail-parse-charset gnus-newsgroup-charset)
4405 (gnus-summary-ignore-duplicates t)
4406 header references generation relations
4407 subject child end new-child date)
4408 ;; First we create an alist of generations/relations, where
4409 ;; generations is how much we trust the relation, and the relation
4411 (gnus-message 7 "Making sparse threads...")
4413 (nnheader-set-temp-buffer " *gnus sparse threads*")
4414 (while (setq header (pop headers))
4415 (when (and (setq references (mail-header-references header))
4416 (not (string= references "")))
4418 (setq child (mail-header-id header)
4419 subject (mail-header-subject header)
4420 date (mail-header-date header)
4422 (while (search-backward ">" nil t)
4423 (setq end (1+ (point)))
4424 (when (search-backward "<" nil t)
4425 (setq new-child (buffer-substring (point) end))
4426 (push (list (incf generation)
4427 child (setq child new-child)
4431 (push (list (1+ generation) child nil subject) relations))
4433 (kill-buffer (current-buffer)))
4434 ;; Sort over trustworthiness.
4435 (dolist (relation (sort relations 'car-less-than-car))
4436 (when (gnus-dependencies-add-header
4437 (make-full-mail-header
4438 gnus-reffed-article-number
4439 (nth 3 relation) "" (or (nth 4 relation) "")
4441 (or (nth 2 relation) "") 0 0 "")
4442 gnus-newsgroup-dependencies nil)
4443 (push gnus-reffed-article-number gnus-newsgroup-limit)
4444 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4445 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4446 gnus-newsgroup-reads)
4447 (decf gnus-reffed-article-number)))
4448 (gnus-message 7 "Making sparse threads...done")))
4450 (defun gnus-build-old-threads ()
4451 ;; Look at all the articles that refer back to old articles, and
4452 ;; fetch the headers for the articles that aren't there. This will
4453 ;; build complete threads - if the roots haven't been expired by the
4455 (let ((mail-parse-charset gnus-newsgroup-charset)
4459 (when (not (car (symbol-value refs)))
4460 (setq heads (cdr (symbol-value refs)))
4462 (if (memq (mail-header-number (caar heads))
4463 gnus-newsgroup-dormant)
4464 (setq heads (cdr heads))
4465 (setq id (symbol-name refs))
4466 (while (and (setq id (gnus-build-get-header id))
4467 (not (car (gnus-id-to-thread id)))))
4468 (setq heads nil)))))
4469 gnus-newsgroup-dependencies)))
4471 (defsubst gnus-remove-odd-characters (string)
4472 "Translate STRING into something that doesn't contain weird characters."
4473 (mm-subst-char-in-string
4475 (mm-subst-char-in-string ?\n ?\- string t) t))
4477 ;; This function has to be called with point after the article number
4478 ;; on the beginning of the line.
4479 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4480 (let ((eol (point-at-eol))
4481 (buffer (current-buffer))
4482 header references in-reply-to)
4484 ;; overview: [num subject from date id refs chars lines misc]
4487 (narrow-to-region (point) eol)
4492 (make-full-mail-header
4494 (condition-case () ; subject
4495 (gnus-remove-odd-characters
4496 (funcall gnus-decode-encoded-word-function
4497 (setq x (nnheader-nov-field))))
4499 (condition-case () ; from
4500 (gnus-remove-odd-characters
4501 (funcall gnus-decode-encoded-address-function
4502 (setq x (nnheader-nov-field))))
4504 (nnheader-nov-field) ; date
4505 (nnheader-nov-read-message-id number) ; id
4506 (setq references (nnheader-nov-field)) ; refs
4507 (nnheader-nov-read-integer) ; chars
4508 (nnheader-nov-read-integer) ; lines
4510 (if (looking-at "Xref: ")
4511 (goto-char (match-end 0)))
4512 (nnheader-nov-field)) ; Xref
4513 (nnheader-nov-parse-extra)))) ; extra
4517 (when (and (string= references "")
4518 (setq in-reply-to (mail-header-extra header))
4519 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4520 (mail-header-set-references
4521 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4523 (when gnus-alter-header-function
4524 (funcall gnus-alter-header-function header))
4525 (gnus-dependencies-add-header header dependencies force-new)))
4527 (defun gnus-build-get-header (id)
4528 "Look through the buffer of NOV lines and find the header to ID.
4529 Enter this line into the dependencies hash table, and return
4530 the id of the parent article (if any)."
4531 (let ((deps gnus-newsgroup-dependencies)
4534 (with-current-buffer nntp-server-buffer
4535 (let ((case-fold-search nil))
4536 (goto-char (point-min))
4537 (while (and (not found)
4538 (search-forward id nil t))
4540 (setq found (looking-at
4541 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4542 (regexp-quote id))))
4543 (or found (beginning-of-line 2)))
4547 (setq header (gnus-nov-parse-line
4548 (read (current-buffer)) deps))
4549 (gnus-parent-id (mail-header-references header))))))
4551 (let ((number (mail-header-number header)))
4552 (push number gnus-newsgroup-limit)
4553 (push header gnus-newsgroup-headers)
4554 (if (memq number gnus-newsgroup-unselected)
4556 (setq gnus-newsgroup-unreads
4557 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4559 (setq gnus-newsgroup-unselected
4560 (delq number gnus-newsgroup-unselected)))
4561 (push number gnus-newsgroup-ancient)))))))
4563 (defun gnus-build-all-threads ()
4564 "Read all the headers."
4565 (let ((gnus-summary-ignore-duplicates t)
4566 (mail-parse-charset gnus-newsgroup-charset)
4567 (dependencies gnus-newsgroup-dependencies)
4569 (with-current-buffer nntp-server-buffer
4570 (let ((case-fold-search nil))
4571 (goto-char (point-min))
4574 (setq article (read (current-buffer))
4575 header (gnus-nov-parse-line article dependencies t)))
4577 (with-current-buffer gnus-summary-buffer
4578 (push header gnus-newsgroup-headers)
4579 (if (memq (setq article (mail-header-number header))
4580 gnus-newsgroup-unselected)
4582 (setq gnus-newsgroup-unreads
4583 (gnus-add-to-sorted-list
4584 gnus-newsgroup-unreads article))
4585 (setq gnus-newsgroup-unselected
4586 (delq article gnus-newsgroup-unselected)))
4587 (push article gnus-newsgroup-ancient)))
4588 (forward-line 1)))))))
4590 (defun gnus-summary-update-article-line (article header)
4591 "Update the line for ARTICLE using HEADER."
4592 (let* ((id (mail-header-id header))
4593 (thread (gnus-id-to-thread id)))
4595 (error "Article in no thread"))
4596 ;; Update the thread.
4597 (setcar thread header)
4598 (gnus-summary-goto-subject article)
4599 (let* ((datal (gnus-data-find-list article))
4601 (inhibit-read-only t)
4602 (level (gnus-summary-thread-level)))
4604 (let ((inserted (- (point)
4606 (gnus-summary-insert-line
4608 (memq article gnus-newsgroup-undownloaded)
4609 (gnus-article-mark article)
4610 (memq article gnus-newsgroup-replied)
4611 (memq article gnus-newsgroup-expirable)
4612 ;; Only insert the Subject string when it's different
4613 ;; from the previous Subject string.
4618 (mail-header-subject
4621 (gnus-data-find-list
4623 (gnus-data-list t)))))
4624 ;; Error on the side of excessive subjects.
4626 (mail-header-subject header)))
4628 (mail-header-subject header))
4629 nil (cdr (assq article gnus-newsgroup-scored))
4630 (memq article gnus-newsgroup-processable))
4633 (gnus-data-update-list
4635 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4637 (defun gnus-summary-update-article (article &optional iheader)
4638 "Update ARTICLE in the summary buffer."
4639 (set-buffer gnus-summary-buffer)
4640 (let* ((header (gnus-summary-article-header article))
4641 (id (mail-header-id header))
4642 (data (gnus-data-find article))
4643 (thread (gnus-id-to-thread id))
4644 (references (mail-header-references header))
4648 (when (and references
4649 (not (equal "" references)))
4652 (inhibit-read-only t)
4658 (delq thread parent)))
4659 (if (gnus-summary-insert-subject id header)
4660 ;; Set the (possibly) new article number in the data structure.
4661 (gnus-data-set-number data (gnus-id-to-article id))
4665 (defun gnus-rebuild-thread (id &optional line)
4666 "Rebuild the thread containing ID.
4667 If LINE, insert the rebuilt thread starting on line LINE."
4668 (let ((inhibit-read-only t)
4669 old-pos current thread data)
4670 (if (not gnus-show-threads)
4671 (setq thread (list (car (gnus-id-to-thread id))))
4672 ;; Get the thread this article is part of.
4673 (setq thread (gnus-remove-thread id)))
4674 (setq old-pos (point-at-bol))
4675 (setq current (save-excursion
4676 (and (re-search-backward "[\r\n]" nil t)
4677 (gnus-summary-article-number))))
4678 ;; If this is a gathered thread, we have to go some re-gathering.
4679 (when (stringp (car thread))
4680 (let ((subject (car thread))
4682 (setq thread (cdr thread))
4684 (unless (memq (setq thr (gnus-id-to-thread
4686 (mail-header-id (caar thread)))))
4689 (setq thread (cdr thread)))
4690 ;; We now have all (unique) roots.
4691 (if (= (length roots) 1)
4692 ;; All the loose roots are now one solid root.
4693 (setq thread (car roots))
4694 (setq thread (cons subject (gnus-sort-threads roots))))))
4696 ;; We then insert this thread into the summary buffer.
4698 (goto-char (point-min))
4699 (forward-line (1- line)))
4700 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4701 (if gnus-show-threads
4702 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4703 (gnus-summary-prepare-unthreaded thread))
4704 (setq data (nreverse gnus-newsgroup-data))
4705 (setq threads gnus-newsgroup-threads))
4706 ;; We splice the new data into the data structure.
4707 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4708 ;;!!! then we want to insert at the beginning of the buffer.
4709 ;;!!! That happens to be true with Gnus now, but that may
4710 ;;!!! change in the future. Perhaps.
4711 (gnus-data-enter-list
4712 (if line nil current) data (- (point) old-pos))
4713 (setq gnus-newsgroup-threads
4714 (nconc threads gnus-newsgroup-threads))
4715 (gnus-data-compute-positions))))
4717 (defun gnus-number-to-header (number)
4718 "Return the header for article NUMBER."
4719 (let ((headers gnus-newsgroup-headers))
4721 (not (= number (mail-header-number (car headers)))))
4726 (defun gnus-parent-headers (in-headers &optional generation)
4727 "Return the headers of the GENERATIONeth parent of HEADERS."
4729 (setq generation 1))
4731 (headers in-headers)
4734 (not (zerop generation))
4735 (setq references (mail-header-references headers)))
4736 (setq headers (if (and references
4737 (setq parent (gnus-parent-id references)))
4738 (car (gnus-id-to-thread parent))
4741 (and (not (eq headers in-headers))
4744 (defun gnus-id-to-thread (id)
4745 "Return the (sub-)thread where ID appears."
4746 (gnus-gethash id gnus-newsgroup-dependencies))
4748 (defun gnus-id-to-article (id)
4749 "Return the article number of ID."
4750 (let ((thread (gnus-id-to-thread id)))
4753 (mail-header-number (car thread)))))
4755 (defun gnus-id-to-header (id)
4756 "Return the article headers of ID."
4757 (car (gnus-id-to-thread id)))
4759 (defun gnus-article-displayed-root-p (article)
4760 "Say whether ARTICLE is a root(ish) article."
4761 (let ((level (gnus-summary-thread-level article))
4762 (refs (mail-header-references (gnus-summary-article-header article)))
4768 ((null (gnus-parent-id refs)) t)
4770 (null (setq particle (gnus-id-to-article
4771 (gnus-parent-id refs))))
4772 (null (gnus-summary-thread-level particle)))))))
4774 (defun gnus-root-id (id)
4775 "Return the id of the root of the thread where ID appears."
4777 (while (and id (setq prev (car (gnus-id-to-thread id))))
4779 id (gnus-parent-id (mail-header-references prev))))
4782 (defun gnus-articles-in-thread (thread)
4783 "Return the list of articles in THREAD."
4784 (cons (mail-header-number (car thread))
4785 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4787 (defun gnus-remove-thread (id &optional dont-remove)
4788 "Remove the thread that has ID in it."
4789 (let (headers thread last-id)
4790 ;; First go up in this thread until we find the root.
4791 (setq last-id (gnus-root-id id)
4792 headers (message-flatten-list (gnus-id-to-thread last-id)))
4793 ;; We have now found the real root of this thread. It might have
4794 ;; been gathered into some loose thread, so we have to search
4795 ;; through the threads to find the thread we wanted.
4796 (let ((threads gnus-newsgroup-threads)
4799 (setq sub (car threads))
4800 (if (stringp (car sub))
4801 ;; This is a gathered thread, so we look at the roots
4802 ;; below it to find whether this article is in this
4805 (setq sub (cdr sub))
4807 (when (member (caar sub) headers)
4808 (setq thread (car threads)
4811 (setq sub (cdr sub))))
4812 ;; It's an ordinary thread, so we check it.
4813 (when (eq (car sub) (car headers))
4816 (setq threads (cdr threads)))
4817 ;; If this article is in no thread, then it's a root.
4820 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4821 (setq thread (gnus-id-to-thread last-id)))
4824 thread ; We return this thread.
4826 (if (stringp (car thread))
4828 ;; If we use dummy roots, then we have to remove the
4829 ;; dummy root as well.
4830 (when (eq gnus-summary-make-false-root 'dummy)
4831 ;; We go to the dummy root by going to
4832 ;; the first sub-"thread", and then one line up.
4833 (gnus-summary-goto-article
4834 (mail-header-number (caadr thread)))
4837 (gnus-data-compute-positions))
4838 (setq thread (cdr thread))
4840 (gnus-remove-thread-1 (car thread))
4841 (setq thread (cdr thread))))
4842 (gnus-remove-thread-1 thread))))))))
4844 (defun gnus-remove-thread-1 (thread)
4845 "Remove the thread THREAD recursively."
4846 (let ((number (mail-header-number (pop thread)))
4848 (setq thread (reverse thread))
4850 (gnus-remove-thread-1 (pop thread)))
4851 (when (setq d (gnus-data-find number))
4852 (goto-char (gnus-data-pos d))
4853 (gnus-summary-show-thread)
4859 (gnus-delete-line)))))))
4861 (defun gnus-sort-threads-recursive (threads func)
4862 (sort (mapcar (lambda (thread)
4865 (gnus-sort-threads-recursive (cdr thread) func))))
4868 (defun gnus-sort-threads-loop (threads func)
4869 (let* ((superthread (cons nil threads))
4870 (stack (list (cons superthread threads)))
4871 remaining-threads thread)
4873 (setq remaining-threads (cdr (car stack)))
4874 (if remaining-threads
4875 (progn (setq thread (car remaining-threads))
4876 (setcdr (car stack) (cdr remaining-threads))
4878 (push (cons thread (cdr thread)) stack)))
4879 (setq thread (caar stack))
4880 (setcdr thread (sort (cdr thread) func))
4884 (defun gnus-sort-threads (threads)
4886 (if (not gnus-thread-sort-functions)
4888 (gnus-message 8 "Sorting threads...")
4891 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4892 (gnus-sort-threads-recursive
4893 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4894 ;; Even after binding max-lisp-eval-depth, the recursive
4895 ;; sorter might fail for very long threads. In that case,
4896 ;; try using a (less well-tested) non-recursive sorter.
4897 (error (gnus-message 9 "Sorting threads with loop...")
4898 (gnus-sort-threads-loop
4899 threads (gnus-make-sort-function
4900 gnus-thread-sort-functions))))
4901 (gnus-message 8 "Sorting threads...done"))))
4903 (defun gnus-sort-articles (articles)
4905 (when gnus-article-sort-functions
4906 (gnus-message 7 "Sorting articles...")
4908 (setq gnus-newsgroup-headers
4909 (sort articles (gnus-make-sort-function
4910 gnus-article-sort-functions)))
4911 (gnus-message 7 "Sorting articles...done"))))
4913 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4914 (defmacro gnus-thread-header (thread)
4915 "Return header of first article in THREAD.
4916 Note that THREAD must never, ever be anything else than a variable -
4917 using some other form will lead to serious barfage."
4918 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4919 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4920 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4923 (defsubst gnus-article-sort-by-number (h1 h2)
4924 "Sort articles by article number."
4925 (< (mail-header-number h1)
4926 (mail-header-number h2)))
4928 (defun gnus-thread-sort-by-number (h1 h2)
4929 "Sort threads by root article number."
4930 (gnus-article-sort-by-number
4931 (gnus-thread-header h1) (gnus-thread-header h2)))
4933 (defsubst gnus-article-sort-by-random (h1 h2)
4934 "Sort articles randomly."
4937 (defun gnus-thread-sort-by-random (h1 h2)
4938 "Sort threads randomly."
4939 (gnus-article-sort-by-random
4940 (gnus-thread-header h1) (gnus-thread-header h2)))
4942 (defsubst gnus-article-sort-by-lines (h1 h2)
4943 "Sort articles by article Lines header."
4944 (< (mail-header-lines h1)
4945 (mail-header-lines h2)))
4947 (defun gnus-thread-sort-by-lines (h1 h2)
4948 "Sort threads by root article Lines header."
4949 (gnus-article-sort-by-lines
4950 (gnus-thread-header h1) (gnus-thread-header h2)))
4952 (defsubst gnus-article-sort-by-chars (h1 h2)
4953 "Sort articles by octet length."
4954 (< (mail-header-chars h1)
4955 (mail-header-chars h2)))
4957 (defun gnus-thread-sort-by-chars (h1 h2)
4958 "Sort threads by root article octet length."
4959 (gnus-article-sort-by-chars
4960 (gnus-thread-header h1) (gnus-thread-header h2)))
4962 (defsubst gnus-article-sort-by-author (h1 h2)
4963 "Sort articles by root author."
4965 (let ((extract (funcall
4966 gnus-extract-address-components
4967 (mail-header-from h1))))
4968 (or (car extract) (cadr extract) ""))
4969 (let ((extract (funcall
4970 gnus-extract-address-components
4971 (mail-header-from h2))))
4972 (or (car extract) (cadr extract) ""))))
4974 (defun gnus-thread-sort-by-author (h1 h2)
4975 "Sort threads by root author."
4976 (gnus-article-sort-by-author
4977 (gnus-thread-header h1) (gnus-thread-header h2)))
4979 (defsubst gnus-article-sort-by-recipient (h1 h2)
4980 "Sort articles by recipient."
4982 (let ((extract (funcall
4983 gnus-extract-address-components
4984 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4985 (or (car extract) (cadr extract)))
4986 (let ((extract (funcall
4987 gnus-extract-address-components
4988 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4989 (or (car extract) (cadr extract)))))
4991 (defun gnus-thread-sort-by-recipient (h1 h2)
4992 "Sort threads by root recipient."
4993 (gnus-article-sort-by-recipient
4994 (gnus-thread-header h1) (gnus-thread-header h2)))
4996 (defsubst gnus-article-sort-by-subject (h1 h2)
4997 "Sort articles by root subject."
4999 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5000 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5002 (defun gnus-thread-sort-by-subject (h1 h2)
5003 "Sort threads by root subject."
5004 (gnus-article-sort-by-subject
5005 (gnus-thread-header h1) (gnus-thread-header h2)))
5007 (defsubst gnus-article-sort-by-date (h1 h2)
5008 "Sort articles by root article date."
5010 (gnus-date-get-time (mail-header-date h1))
5011 (gnus-date-get-time (mail-header-date h2))))
5013 (defun gnus-thread-sort-by-date (h1 h2)
5014 "Sort threads by root article date."
5015 (gnus-article-sort-by-date
5016 (gnus-thread-header h1) (gnus-thread-header h2)))
5018 (defsubst gnus-article-sort-by-score (h1 h2)
5019 "Sort articles by root article score.
5020 Unscored articles will be counted as having a score of zero."
5021 (> (or (cdr (assq (mail-header-number h1)
5022 gnus-newsgroup-scored))
5023 gnus-summary-default-score 0)
5024 (or (cdr (assq (mail-header-number h2)
5025 gnus-newsgroup-scored))
5026 gnus-summary-default-score 0)))
5028 (defun gnus-thread-sort-by-score (h1 h2)
5029 "Sort threads by root article score."
5030 (gnus-article-sort-by-score
5031 (gnus-thread-header h1) (gnus-thread-header h2)))
5033 (defun gnus-thread-sort-by-total-score (h1 h2)
5034 "Sort threads by the sum of all scores in the thread.
5035 Unscored articles will be counted as having a score of zero."
5036 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5038 (defun gnus-thread-total-score (thread)
5039 ;; This function find the total score of THREAD.
5044 (if (stringp (car thread))
5045 (apply gnus-thread-score-function 0
5046 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5047 (gnus-thread-total-score-1 thread)))
5049 (gnus-thread-total-score-1 (list thread)))))
5051 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5052 "Sort articles by number."
5053 (gnus-article-sort-by-number h1 h2))
5055 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5056 "Sort threads such that the thread with the most recently arrived article comes first."
5057 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5059 (defun gnus-thread-highest-number (thread)
5060 "Return the highest article number in THREAD."
5061 (apply 'max (mapcar (lambda (header)
5062 (mail-header-number header))
5063 (message-flatten-list thread))))
5065 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5066 "Sort articles by number."
5067 (gnus-article-sort-by-date h1 h2))
5069 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5070 "Sort threads such that the thread with the most recently dated article comes first."
5071 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5073 ; Since this is called not only to sort the top-level threads, but
5074 ; also in recursive sorts to order the articles within a thread, each
5075 ; article will be processed many times. Thus it speeds things up
5076 ; quite a bit to use gnus-date-get-time, which caches the time value.
5077 (defun gnus-thread-latest-date (thread)
5078 "Return the highest article date in THREAD."
5080 (mapcar (lambda (header) (gnus-float-time
5082 (mail-header-date header))))
5083 (message-flatten-list thread))))
5085 (defun gnus-thread-total-score-1 (root)
5086 ;; This function find the total score of the thread below ROOT.
5087 (setq root (car root))
5088 (apply gnus-thread-score-function
5090 (mapcar 'gnus-thread-total-score
5091 (cdr (gnus-id-to-thread (mail-header-id root))))
5092 (when (> (mail-header-number root) 0)
5093 (list (or (cdr (assq (mail-header-number root)
5094 gnus-newsgroup-scored))
5095 gnus-summary-default-score 0))))
5096 (list gnus-summary-default-score)
5099 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5100 (defvar gnus-tmp-prev-subject nil)
5101 (defvar gnus-tmp-false-parent nil)
5102 (defvar gnus-tmp-root-expunged nil)
5103 (defvar gnus-tmp-dummy-line nil)
5105 (defun gnus-extra-header (type &optional header)
5106 "Return the extra header of TYPE."
5107 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5110 (defvar gnus-tmp-thread-tree-header-string "")
5112 (defcustom gnus-sum-thread-tree-root "> "
5113 "With %B spec, used for the root of a thread.
5114 If nil, use subject instead."
5116 :type '(radio (const :format "%v " nil) string)
5117 :group 'gnus-thread)
5119 (defcustom gnus-sum-thread-tree-false-root "> "
5120 "With %B spec, used for a false root of a thread.
5121 If nil, use subject instead."
5123 :type '(radio (const :format "%v " nil) string)
5124 :group 'gnus-thread)
5126 (defcustom gnus-sum-thread-tree-single-indent ""
5127 "With %B spec, used for a thread with just one message.
5128 If nil, use subject instead."
5130 :type '(radio (const :format "%v " nil) string)
5131 :group 'gnus-thread)
5133 (defcustom gnus-sum-thread-tree-vertical "| "
5134 "With %B spec, used for drawing a vertical line."
5137 :group 'gnus-thread)
5139 (defcustom gnus-sum-thread-tree-indent " "
5140 "With %B spec, used for indenting."
5143 :group 'gnus-thread)
5145 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5146 "With %B spec, used for a leaf with brothers."
5149 :group 'gnus-thread)
5151 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5152 "With %B spec, used for a leaf without brothers."
5155 :group 'gnus-thread)
5157 (defcustom gnus-summary-display-while-building nil
5158 "If non-nil, show and update the summary buffer as it's being built.
5159 If the value is t, update the buffer after every line is inserted. If
5160 the value is an integer (N), update the display every N lines."
5163 :type '(choice (const :tag "off" nil)
5165 (const :tag "frequently" t)))
5167 (defun gnus-summary-prepare-threads (threads)
5168 "Prepare summary buffer from THREADS and indentation LEVEL.
5169 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5170 or a straight list of headers."
5171 (gnus-message 7 "Generating summary...")
5173 (setq gnus-newsgroup-threads threads)
5176 (let ((gnus-tmp-level 0)
5177 (default-score (or gnus-summary-default-score 0))
5178 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5179 (building-line-count gnus-summary-display-while-building)
5180 (building-count (integerp gnus-summary-display-while-building))
5181 thread number subject stack state gnus-tmp-gathered beg-match
5182 new-roots gnus-tmp-new-adopts thread-end simp-subject
5183 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5184 gnus-tmp-replied gnus-tmp-subject-or-nil
5185 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5186 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5187 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5190 (setq gnus-tmp-prev-subject nil
5191 gnus-tmp-thread-tree-header-string "")
5193 (if (vectorp (car threads))
5194 ;; If this is a straight (sic) list of headers, then a
5195 ;; threaded summary display isn't required, so we just create
5196 ;; an unthreaded one.
5197 (gnus-summary-prepare-unthreaded threads)
5199 ;; Do the threaded display.
5201 (if gnus-summary-display-while-building
5202 (switch-to-buffer (buffer-name)))
5203 (while (or threads stack gnus-tmp-new-adopts new-roots)
5205 (if (and (= gnus-tmp-level 0)
5208 (not gnus-tmp-false-parent)
5209 (or gnus-tmp-new-adopts new-roots))
5210 (if gnus-tmp-new-adopts
5211 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5212 thread (list (car gnus-tmp-new-adopts))
5213 gnus-tmp-header (caar thread)
5214 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5216 (setq thread (list (car new-roots))
5217 gnus-tmp-header (caar thread)
5218 new-roots (cdr new-roots))))
5221 ;; If there are some threads, we do them before the
5222 ;; threads on the stack.
5223 (setq thread threads
5224 gnus-tmp-header (caar thread))
5225 ;; There were no current threads, so we pop something off
5227 (setq state (car stack)
5228 gnus-tmp-level (car state)
5229 tree-stack (cadr state)
5230 thread (caddr state)
5232 gnus-tmp-header (caar thread))))
5234 (setq gnus-tmp-false-parent nil)
5235 (setq gnus-tmp-root-expunged nil)
5236 (setq thread-end nil)
5238 (if (stringp gnus-tmp-header)
5239 ;; The header is a dummy root.
5241 ((eq gnus-summary-make-false-root 'adopt)
5242 ;; We let the first article adopt the rest.
5243 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5245 (setq gnus-tmp-gathered
5247 (lambda (h) (mail-header-number (car h)))
5250 (setq thread (cons (list (caar thread)
5253 (setq gnus-tmp-level -1
5254 gnus-tmp-false-parent t))
5255 ((eq gnus-summary-make-false-root 'empty)
5256 ;; We print adopted articles with empty subject fields.
5257 (setq gnus-tmp-gathered
5259 (lambda (h) (mail-header-number (car h)))
5262 (setq gnus-tmp-level -1))
5263 ((eq gnus-summary-make-false-root 'dummy)
5264 ;; We remember that we probably want to output a dummy
5266 (setq gnus-tmp-dummy-line gnus-tmp-header)
5267 (setq gnus-tmp-prev-subject gnus-tmp-header))
5269 ;; We do not make a root for the gathered
5270 ;; sub-threads at all.
5271 (setq gnus-tmp-level -1)))
5273 (setq number (mail-header-number gnus-tmp-header)
5274 subject (mail-header-subject gnus-tmp-header)
5275 simp-subject (gnus-simplify-subject-fully subject))
5278 ;; If the thread has changed subject, we might want to make
5279 ;; this subthread into a root.
5280 ((and (null gnus-thread-ignore-subject)
5281 (not (zerop gnus-tmp-level))
5282 gnus-tmp-prev-subject
5283 (not (string= gnus-tmp-prev-subject simp-subject)))
5284 (setq new-roots (nconc new-roots (list (car thread)))
5286 gnus-tmp-header nil))
5287 ;; If the article lies outside the current limit,
5288 ;; then we do not display it.
5289 ((not (memq number gnus-newsgroup-limit))
5290 (setq gnus-tmp-gathered
5292 (lambda (h) (mail-header-number (car h)))
5295 (setq gnus-tmp-new-adopts (if (cdar thread)
5296 (append gnus-tmp-new-adopts
5298 gnus-tmp-new-adopts)
5300 gnus-tmp-header nil)
5301 (when (zerop gnus-tmp-level)
5302 (setq gnus-tmp-root-expunged t)))
5303 ;; Perhaps this article is to be marked as read?
5304 ((and gnus-summary-mark-below
5305 (< (or (cdr (assq number gnus-newsgroup-scored))
5307 gnus-summary-mark-below)
5308 ;; Don't touch sparse articles.
5309 (not (gnus-summary-article-sparse-p number))
5310 (not (gnus-summary-article-ancient-p number)))
5311 (setq gnus-newsgroup-unreads
5312 (delq number gnus-newsgroup-unreads))
5313 (if gnus-newsgroup-auto-expire
5314 (setq gnus-newsgroup-expirable
5315 (gnus-add-to-sorted-list
5316 gnus-newsgroup-expirable number))
5317 (push (cons number gnus-low-score-mark)
5318 gnus-newsgroup-reads))))
5320 (when gnus-tmp-header
5321 ;; We may have an old dummy line to output before this
5323 (when (and gnus-tmp-dummy-line
5326 (mail-header-subject gnus-tmp-header)))
5327 (gnus-summary-insert-dummy-line
5328 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5329 (setq gnus-tmp-dummy-line nil))
5331 ;; Compute the mark.
5332 (setq gnus-tmp-unread (gnus-article-mark number))
5334 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5335 gnus-tmp-header gnus-tmp-level)
5336 gnus-newsgroup-data)
5338 ;; Actually insert the line.
5340 gnus-tmp-subject-or-nil
5342 ((and gnus-thread-ignore-subject
5343 gnus-tmp-prev-subject
5344 (not (string= gnus-tmp-prev-subject simp-subject)))
5346 ((zerop gnus-tmp-level)
5347 (if (and (eq gnus-summary-make-false-root 'empty)
5348 (memq number gnus-tmp-gathered)
5349 gnus-tmp-prev-subject
5350 (string= gnus-tmp-prev-subject simp-subject))
5351 gnus-summary-same-subject
5353 (t gnus-summary-same-subject)))
5354 (if (and (eq gnus-summary-make-false-root 'adopt)
5355 (= gnus-tmp-level 1)
5356 (memq number gnus-tmp-gathered))
5357 (setq gnus-tmp-opening-bracket ?\<
5358 gnus-tmp-closing-bracket ?\>)
5359 (setq gnus-tmp-opening-bracket ?\[
5360 gnus-tmp-closing-bracket ?\]))
5361 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5362 (gnus-make-thread-indent-array
5363 (max (* 2 (length gnus-thread-indent-array))
5366 gnus-tmp-indentation
5367 (aref gnus-thread-indent-array gnus-tmp-level)
5368 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5369 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5370 gnus-summary-default-score 0)
5372 (if (or (null gnus-summary-default-score)
5373 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5374 gnus-summary-zcore-fuzz))
5376 (if (< gnus-tmp-score gnus-summary-default-score)
5377 gnus-score-below-mark gnus-score-over-mark))
5379 (cond ((memq number gnus-newsgroup-processable)
5381 ((memq number gnus-newsgroup-cached)
5383 ((memq number gnus-newsgroup-replied)
5385 ((memq number gnus-newsgroup-forwarded)
5386 gnus-forwarded-mark)
5387 ((memq number gnus-newsgroup-saved)
5389 ((memq number gnus-newsgroup-recent)
5391 ((memq number gnus-newsgroup-unseen)
5395 (cond ((memq number gnus-newsgroup-undownloaded)
5396 gnus-undownloaded-mark)
5397 (gnus-newsgroup-agentized
5398 gnus-downloaded-mark)
5401 gnus-tmp-from (mail-header-from gnus-tmp-header)
5404 ((string-match "<[^>]+> *$" gnus-tmp-from)
5405 (setq beg-match (match-beginning 0))
5406 (or (and (string-match "^\".+\"" gnus-tmp-from)
5407 (substring gnus-tmp-from 1 (1- (match-end 0))))
5408 (substring gnus-tmp-from 0 beg-match)))
5409 ((string-match "(.+)" gnus-tmp-from)
5410 (substring gnus-tmp-from
5411 (1+ (match-beginning 0)) (1- (match-end 0))))
5415 gnus-tmp-thread-tree-header-string
5417 ((not gnus-show-threads) "")
5418 ((zerop gnus-tmp-level)
5419 (cond ((cdar thread)
5420 (or gnus-sum-thread-tree-root subject))
5421 (gnus-tmp-new-adopts
5422 (or gnus-sum-thread-tree-false-root subject))
5424 (or gnus-sum-thread-tree-single-indent subject))))
5426 (concat (apply 'concat
5427 (mapcar (lambda (item)
5429 gnus-sum-thread-tree-vertical
5430 gnus-sum-thread-tree-indent))
5431 (cdr (reverse tree-stack))))
5433 gnus-sum-thread-tree-leaf-with-other
5434 gnus-sum-thread-tree-single-leaf)))))
5435 (when (string= gnus-tmp-name "")
5436 (setq gnus-tmp-name gnus-tmp-from))
5437 (unless (numberp gnus-tmp-lines)
5438 (setq gnus-tmp-lines -1))
5439 (if (= gnus-tmp-lines -1)
5440 (setq gnus-tmp-lines "?")
5441 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5442 (gnus-put-text-property
5444 (progn (eval gnus-summary-line-format-spec) (point))
5445 'gnus-number number)
5448 (gnus-summary-highlight-line)
5449 (when gnus-summary-update-hook
5450 (gnus-run-hooks 'gnus-summary-update-hook))
5453 (setq gnus-tmp-prev-subject simp-subject)))
5455 (when (nth 1 thread)
5456 (push (list (max 0 gnus-tmp-level)
5457 (copy-sequence tree-stack)
5460 (push (if (nth 1 thread) 1 0) tree-stack)
5461 (incf gnus-tmp-level)
5462 (setq threads (if thread-end nil (cdar thread)))
5463 (if gnus-summary-display-while-building
5466 ;; use a set frequency
5467 (setq building-line-count (1- building-line-count))
5468 (when (= building-line-count 0)
5470 (setq building-line-count
5471 gnus-summary-display-while-building)))
5475 (setq gnus-tmp-level 0)))))
5476 (gnus-message 7 "Generating summary...done"))
5478 (defun gnus-summary-prepare-unthreaded (headers)
5479 "Generate an unthreaded summary buffer based on HEADERS."
5480 (let (header number mark)
5485 ;; We may have to root out some bad articles...
5486 (when (memq (setq number (mail-header-number
5487 (setq header (pop headers))))
5488 gnus-newsgroup-limit)
5489 ;; Mark article as read when it has a low score.
5490 (when (and gnus-summary-mark-below
5491 (< (or (cdr (assq number gnus-newsgroup-scored))
5492 gnus-summary-default-score 0)
5493 gnus-summary-mark-below)
5494 (not (gnus-summary-article-ancient-p number)))
5495 (setq gnus-newsgroup-unreads
5496 (delq number gnus-newsgroup-unreads))
5497 (if gnus-newsgroup-auto-expire
5498 (push number gnus-newsgroup-expirable)
5499 (push (cons number gnus-low-score-mark)
5500 gnus-newsgroup-reads)))
5502 (setq mark (gnus-article-mark number))
5503 (push (gnus-data-make number mark (1+ (point)) header 0)
5504 gnus-newsgroup-data)
5505 (gnus-summary-insert-line
5507 (memq number gnus-newsgroup-undownloaded)
5508 mark (memq number gnus-newsgroup-replied)
5509 (memq number gnus-newsgroup-expirable)
5510 (mail-header-subject header) nil
5511 (cdr (assq number gnus-newsgroup-scored))
5512 (memq number gnus-newsgroup-processable))))))
5514 (defun gnus-summary-remove-list-identifiers ()
5515 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5516 (let ((regexp (if (consp gnus-list-identifiers)
5517 (mapconcat 'identity gnus-list-identifiers " *\\|")
5518 gnus-list-identifiers))
5521 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5522 (dolist (header gnus-newsgroup-headers)
5523 (setq subject (mail-header-subject header)
5525 (while (string-match regexp subject)
5527 (concat (substring subject 0 (match-beginning 1))
5528 (substring subject (match-end 0)))
5531 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5533 (concat (substring subject 0 (match-beginning 1))
5534 (substring subject (match-end 1)))))
5535 (mail-header-set-subject header subject))))))
5537 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5538 "Fetch headers of ARTICLES."
5539 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5540 (gnus-message 5 "Fetching headers for %s..." name)
5543 (setq gnus-headers-retrieved-by
5544 (gnus-retrieve-headers
5545 articles gnus-newsgroup-name
5547 ;; We might want to fetch old headers, but
5548 ;; not if there is only 1 article.
5550 (not (eq gnus-fetch-old-headers 'some))
5551 (not (numberp gnus-fetch-old-headers)))
5552 (> (length articles) 1))
5553 gnus-fetch-old-headers)))))
5554 (gnus-get-newsgroup-headers-xover
5555 articles force-new dependencies gnus-newsgroup-name t)
5556 (gnus-get-newsgroup-headers dependencies force-new))
5557 (gnus-message 5 "Fetching headers for %s...done" name))))
5559 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5560 "Select newsgroup GROUP.
5561 If READ-ALL is non-nil, all articles in the group are selected.
5562 If SELECT-ARTICLES, only select those articles from GROUP."
5563 (let* ((entry (gnus-group-entry group))
5564 ;;!!! Dirty hack; should be removed.
5565 (gnus-summary-ignore-duplicates
5566 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5568 gnus-summary-ignore-duplicates))
5569 (info (nth 2 entry))
5570 charset articles fetched-articles cached)
5572 (unless (gnus-check-server
5573 (set (make-local-variable 'gnus-current-select-method)
5574 (gnus-find-method-for-group group)))
5575 (error "Couldn't open server"))
5576 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5578 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5579 (gnus-activate-group group) ; Or we can activate it...
5580 (progn ; Or we bug out.
5581 (when (equal major-mode 'gnus-summary-mode)
5582 (gnus-kill-buffer (current-buffer)))
5584 "Couldn't activate group %s: %s"
5585 (mm-decode-coding-string group charset)
5586 (mm-decode-coding-string (gnus-status-message group) charset))))
5588 (unless (gnus-request-group group t)
5589 (when (equal major-mode 'gnus-summary-mode)
5590 (gnus-kill-buffer (current-buffer)))
5591 (error "Couldn't request group %s: %s"
5592 (mm-decode-coding-string group charset)
5593 (mm-decode-coding-string (gnus-status-message group) charset)))
5595 (when (and gnus-agent
5596 (gnus-active group))
5597 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5599 (setq gnus-summary-use-undownloaded-faces
5600 (gnus-agent-find-parameter
5602 'agent-enable-undownloaded-faces)))
5604 (setq gnus-newsgroup-name group
5605 gnus-newsgroup-unselected nil
5606 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5608 (let ((display (gnus-group-find-parameter group 'display)))
5609 (setq gnus-newsgroup-display
5611 ((not (zerop (or (car-safe read-all) 0)))
5612 ;; The user entered the group with C-u SPC/RET, let's show
5618 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5620 ;; The following is probably the "correct" solution, but
5621 ;; it makes Gnus fetch all headers and then limit the
5622 ;; articles (which is slow), so instead we hack the
5623 ;; select-articles parameter instead. -- Simon Josefsson
5626 ;; (gnus-byte-compile
5627 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5629 (setq select-articles
5630 (gnus-uncompress-range
5631 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5635 (cdr (gnus-active group)))))
5640 (gnus-summary-setup-default-charset)
5642 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5643 (when (gnus-virtual-group-p group)
5644 (setq cached gnus-newsgroup-cached))
5646 (setq gnus-newsgroup-unreads
5647 (gnus-sorted-ndifference
5648 (gnus-sorted-ndifference gnus-newsgroup-unreads
5649 gnus-newsgroup-marked)
5650 gnus-newsgroup-dormant))
5652 (setq gnus-newsgroup-processable nil)
5654 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5656 ;; Adjust and set lists of article marks.
5658 (gnus-adjust-marked-articles info))
5659 (if (setq articles select-articles)
5660 (setq gnus-newsgroup-unselected
5661 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5662 (setq articles (gnus-articles-to-read group read-all)))
5666 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5668 ((eq articles 0) nil)
5670 ;; Init the dependencies hash table.
5671 (setq gnus-newsgroup-dependencies
5672 (gnus-make-hashtable (length articles)))
5673 (gnus-set-global-variables)
5674 ;; Retrieve the headers and read them in.
5676 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5678 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5680 (setq gnus-newsgroup-cached cached))
5682 ;; Suppress duplicates?
5683 (when gnus-suppress-duplicates
5684 (gnus-dup-suppress-articles))
5686 ;; Set the initial limit.
5687 (setq gnus-newsgroup-limit (copy-sequence articles))
5688 ;; Remove canceled articles from the list of unread articles.
5689 (setq fetched-articles
5690 (mapcar (lambda (headers) (mail-header-number headers))
5691 gnus-newsgroup-headers))
5692 (setq gnus-newsgroup-articles fetched-articles)
5693 (setq gnus-newsgroup-unreads
5694 (gnus-sorted-nintersection
5695 gnus-newsgroup-unreads fetched-articles))
5696 (gnus-compute-unseen-list)
5698 ;; Removed marked articles that do not exist.
5699 (gnus-update-missing-marks
5700 (gnus-sorted-difference articles fetched-articles))
5701 ;; We might want to build some more threads first.
5702 (when (and gnus-fetch-old-headers
5703 (eq gnus-headers-retrieved-by 'nov))
5704 (if (eq gnus-fetch-old-headers 'invisible)
5705 (gnus-build-all-threads)
5706 (gnus-build-old-threads)))
5707 ;; Let the Gnus agent mark articles as read.
5709 (gnus-agent-get-undownloaded-list))
5710 ;; Remove list identifiers from subject
5711 (when gnus-list-identifiers
5712 (gnus-summary-remove-list-identifiers))
5713 ;; Check whether auto-expire is to be done in this group.
5714 (setq gnus-newsgroup-auto-expire
5715 (gnus-group-auto-expirable-p group))
5716 ;; Set up the article buffer now, if necessary.
5717 (unless (and gnus-single-article-buffer
5718 (equal gnus-article-buffer "*Article*"))
5719 (gnus-article-setup-buffer))
5720 ;; First and last article in this newsgroup.
5721 (when gnus-newsgroup-headers
5722 (setq gnus-newsgroup-begin
5723 (mail-header-number (car gnus-newsgroup-headers))
5726 (gnus-last-element gnus-newsgroup-headers))))
5727 ;; GROUP is successfully selected.
5728 (or gnus-newsgroup-headers t)))))
5730 (defun gnus-compute-unseen-list ()
5731 ;; The `seen' marks are treated specially.
5732 (if (not gnus-newsgroup-seen)
5733 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5734 (setq gnus-newsgroup-unseen
5735 (gnus-inverse-list-range-intersection
5736 gnus-newsgroup-articles gnus-newsgroup-seen))))
5738 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5740 (defun gnus-summary-display-make-predicate (display)
5741 (require 'gnus-agent)
5742 (when (= (length display) 1)
5743 (setq display (car display)))
5744 (unless gnus-summary-display-cache
5745 (dolist (elem (append '((unread . unread)
5748 gnus-article-mark-lists))
5749 (push (cons (cdr elem)
5750 (gnus-byte-compile ;Why bother?
5751 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5752 gnus-summary-display-cache)))
5753 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5754 (gnus-category-predicate-cache gnus-summary-display-cache))
5755 (gnus-get-predicate display)))
5757 ;; Uses the dynamically bound `gnus-number' variable.
5758 (defvar gnus-number)
5759 (defun gnus-article-marked-p (type &optional article)
5760 (let ((article (or article gnus-number)))
5763 (memq article gnus-newsgroup-marked))
5765 (memq article gnus-newsgroup-spam-marked))
5767 (memq article gnus-newsgroup-unsendable))
5768 ((eq type 'undownload)
5769 (memq article gnus-newsgroup-undownloaded))
5770 ((eq type 'download)
5771 (memq article gnus-newsgroup-downloadable))
5773 (memq article gnus-newsgroup-unreads))
5775 (memq article gnus-newsgroup-reads))
5777 (memq article gnus-newsgroup-dormant) )
5779 (memq article gnus-newsgroup-expirable))
5781 (memq article gnus-newsgroup-replied))
5783 (memq article gnus-newsgroup-killed))
5784 ((eq type 'bookmark)
5785 (assq article gnus-newsgroup-bookmarks))
5787 (assq article gnus-newsgroup-scored))
5789 (memq article gnus-newsgroup-saved))
5791 (memq article gnus-newsgroup-cached))
5793 (memq article gnus-newsgroup-forwarded))
5795 (not (memq article gnus-newsgroup-unseen)))
5797 (memq article gnus-newsgroup-recent))
5800 (defun gnus-articles-to-read (group &optional read-all)
5801 "Find out what articles the user wants to read."
5803 ;; Select all articles if `read-all' is non-nil, or if there
5804 ;; are no unread articles.
5806 (and (zerop (length gnus-newsgroup-marked))
5807 (zerop (length gnus-newsgroup-unreads)))
5808 ;; Fetch all if the predicate is non-nil.
5809 gnus-newsgroup-display)
5810 ;; We want to select the headers for all the articles in
5811 ;; the group, so we select either all the active
5812 ;; articles in the group, or (if that's nil), the
5813 ;; articles in the cache.
5815 (if gnus-newsgroup-maximum-articles
5816 (let ((active (gnus-active group)))
5817 (gnus-uncompress-range
5818 (cons (max (car active)
5820 gnus-newsgroup-maximum-articles
5823 (gnus-uncompress-range (gnus-active group)))
5824 (gnus-cache-articles-in-group group))
5825 ;; Select only the "normal" subset of articles.
5827 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5828 gnus-newsgroup-unreads)))
5829 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5830 (scored (length scored-list))
5831 (number (length articles))
5832 (marked (+ (length gnus-newsgroup-marked)
5833 (length gnus-newsgroup-dormant)))
5838 ((numberp gnus-newsgroup-display)
5839 gnus-newsgroup-display)
5843 ((and (or (<= scored marked) (= scored number))
5844 (numberp gnus-large-newsgroup)
5845 (> number gnus-large-newsgroup))
5846 (let* ((cursor-in-echo-area nil)
5847 (initial (gnus-parameter-large-newsgroup-initial
5848 gnus-newsgroup-name))
5852 "How many articles from %s (%s %d): "
5853 (gnus-group-decoded-name gnus-newsgroup-name)
5854 (if initial "max" "default")
5857 (cons (number-to-string initial)
5859 (if (string-match "^[ \t]*$" input) number input)))
5860 ((and (> scored marked) (< scored number)
5861 (> (- scored number) 20))
5864 (format "%s %s (%d scored, %d total): "
5865 "How many articles from"
5866 (gnus-group-decoded-name group)
5868 (if (string-match "^[ \t]*$" input)
5872 (message "Quit getting the articles to read")
5874 (setq select (if (stringp select) (string-to-number select) select))
5875 (if (or (null select) (zerop select))
5877 (if (and (not (zerop scored)) (<= (abs select) scored))
5879 (setq articles (sort scored-list '<))
5880 (setq number (length articles)))
5881 (setq articles (copy-sequence articles)))
5883 (when (< (abs select) number)
5885 ;; Select the N oldest articles.
5886 (setcdr (nthcdr (1- (abs select)) articles) nil)
5887 ;; Select the N most recent articles.
5888 (setq articles (nthcdr (- number select) articles))))
5889 (setq gnus-newsgroup-unselected
5890 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5891 (when gnus-alter-articles-to-read-function
5894 (funcall gnus-alter-articles-to-read-function
5895 gnus-newsgroup-name articles)
5899 (defun gnus-killed-articles (killed articles)
5902 (when (inline (gnus-member-of-range (car articles) killed))
5903 (push (car articles) out))
5904 (setq articles (cdr articles)))
5907 (defun gnus-uncompress-marks (marks)
5908 "Uncompress the mark ranges in MARKS."
5909 (let ((uncompressed '(score bookmark))
5912 (if (memq (caar marks) uncompressed)
5913 (push (car marks) out)
5914 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5915 (setq marks (cdr marks)))
5918 (defun gnus-article-mark-to-type (mark)
5919 "Return the type of MARK."
5920 (or (cadr (assq mark gnus-article-special-mark-lists))
5923 (defun gnus-article-unpropagatable-p (mark)
5924 "Return whether MARK should be propagated to back end."
5925 (memq mark gnus-article-unpropagated-mark-lists))
5927 (defun gnus-adjust-marked-articles (info)
5928 "Set all article lists and remove all marks that are no longer valid."
5929 (let* ((marked-lists (gnus-info-marks info))
5930 (active (gnus-active (gnus-info-group info)))
5933 (types gnus-article-mark-lists)
5934 marks var articles article mark mark-type
5936 ;; Hack to avoid adjusting marks for imap.
5937 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5941 (dolist (marks marked-lists)
5942 (setq mark (car marks)
5943 mark-type (gnus-article-mark-to-type mark)
5944 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5946 ;; We set the variable according to the type of the marks list,
5947 ;; and then adjust the marks to a subset of the active articles.
5949 ;; Adjust "simple" lists - compressed yet unsorted
5950 ((eq mark-type 'list)
5951 ;; Simultaneously uncompress and clip to active range
5952 ;; See gnus-uncompress-range for a description of possible marks
5954 (if (not (cadr marks))
5956 (setq articles (if (numberp (cddr marks))
5962 (while (setq article (pop articles))
5963 (cond ((consp article)
5964 (setq bgn (max (car article) min)
5965 end (min (cdr article) max))
5967 (setq l (setcdr l (cons bgn nil))
5969 ((and (<= min article)
5971 (setq l (setcdr l (cons article nil))))))
5972 (set var (cdr lh)))))
5974 ((eq mark-type 'tuple)
5975 (set var (setq articles (cdr marks)))
5976 (when (not (listp (cdr (symbol-value var))))
5977 (set var (list (symbol-value var))))
5978 (when (not (listp (cdr articles)))
5979 (setq articles (list articles)))
5981 (when (or (not (consp (setq article (pop articles))))
5982 (< (car article) min)
5983 (> (car article) max))
5984 (set var (delq article (symbol-value var))))))
5985 ;; Adjust ranges (sloppily).
5986 ((eq mark-type 'range)
5989 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5990 ;; It should be (seen (NUM1 . NUM2)).
5991 (when (numberp (cddr marks))
5992 (setcdr marks (list (cdr marks))))
5993 (setq articles (cdr marks))
5994 (while (and articles
5995 (or (and (consp (car articles))
5996 (> min (cdar articles)))
5997 (and (numberp (car articles))
5998 (> min (car articles)))))
6000 (set var articles))))))))
6002 (defun gnus-update-missing-marks (missing)
6003 "Go through the list of MISSING articles and remove them from the mark lists."
6006 ;; Go through all types.
6007 (dolist (elem gnus-article-mark-lists)
6008 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6009 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6010 (when (symbol-value var)
6011 ;; This list has articles. So we delete all missing
6012 ;; articles from it.
6015 (set var (delq (pop m) (symbol-value var))))))))))
6017 (defun gnus-update-marks ()
6018 "Enter the various lists of marked articles into the newsgroup info list."
6019 (let ((types gnus-article-mark-lists)
6020 (info (gnus-get-info gnus-newsgroup-name))
6021 type list newmarked symbol delta-marks)
6023 ;; Add all marks lists to the list of marks lists.
6024 (while (setq type (pop types))
6025 (setq list (symbol-value
6027 (intern (format "gnus-newsgroup-%s" (car type))))))
6030 ;; Get rid of the entries of the articles that have the
6032 (when (and (eq (cdr type) 'score)
6036 (prev (cons nil list))
6039 (if (or (not (consp (car arts)))
6040 (= (cdar arts) gnus-summary-default-score))
6041 (setcdr prev (cdr arts))
6043 (setq arts (cdr arts)))
6044 (setq list (cdr all)))))
6046 (when (eq (cdr type) 'seen)
6047 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6049 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6050 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6052 (when (and (gnus-check-backend-function
6053 'request-set-mark gnus-newsgroup-name)
6054 (not (gnus-article-unpropagatable-p (cdr type))))
6055 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6056 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
6057 (add (gnus-remove-from-range
6058 (gnus-copy-sequence list) old)))
6060 (push (list add 'add (list (cdr type))) delta-marks))
6062 ;; Don't delete marks from outside the active range. This
6063 ;; shouldn't happen, but is a sanity check.
6064 (setq del (gnus-sorted-range-intersection
6065 (gnus-active gnus-newsgroup-name) del))
6066 (push (list del 'del (list (cdr type))) delta-marks))))
6069 (push (cons (cdr type) list) newmarked)))
6072 (unless (gnus-check-group gnus-newsgroup-name)
6073 (error "Can't open server for %s" gnus-newsgroup-name))
6074 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6076 ;; Enter these new marks into the info of the group.
6078 (setcar (nthcdr 3 info) newmarked)
6079 ;; Add the marks lists to the end of the info.
6081 (setcdr (nthcdr 2 info) (list newmarked))))
6083 ;; Cut off the end of the info if there's nothing else there.
6087 (when (nthcdr (decf i) info)
6088 (setcdr (nthcdr i info) nil)))))))
6090 (defun gnus-set-mode-line (where)
6091 "Set the mode line of the article or summary buffers.
6092 If WHERE is `summary', the summary mode line format will be used."
6093 ;; Is this mode line one we keep updated?
6094 (when (and (memq where gnus-updated-mode-lines)
6096 (intern (format "gnus-%s-mode-line-format-spec" where))))
6098 ;; We evaluate this in the summary buffer since these
6099 ;; variables are buffer-local to that buffer.
6100 (with-current-buffer gnus-summary-buffer
6101 ;; We bind all these variables that are used in the `eval' form
6103 (let* ((mformat (symbol-value
6105 (format "gnus-%s-mode-line-format-spec" where))))
6106 (gnus-tmp-group-name (gnus-mode-string-quote
6107 (gnus-group-decoded-name
6108 gnus-newsgroup-name)))
6109 (gnus-tmp-article-number (or gnus-current-article 0))
6110 (gnus-tmp-unread gnus-newsgroup-unreads)
6111 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6112 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6113 (gnus-tmp-unread-and-unselected
6114 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6115 (zerop gnus-tmp-unselected))
6117 ((zerop gnus-tmp-unselected)
6118 (format "{%d more}" gnus-tmp-unread-and-unticked))
6119 (t (format "{%d(+%d) more}"
6120 gnus-tmp-unread-and-unticked
6121 gnus-tmp-unselected))))
6123 (if (and gnus-current-headers
6124 (vectorp gnus-current-headers))
6125 (gnus-mode-string-quote
6126 (mail-header-subject gnus-current-headers))
6128 bufname-length max-len
6129 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6130 (setq mode-string (eval mformat))
6131 (setq bufname-length (if (string-match "%b" mode-string)
6134 (if (eq where 'summary)
6136 (get-buffer gnus-article-buffer))))
6139 (setq max-len (max 4 (if gnus-mode-non-string-length
6141 gnus-mode-non-string-length
6143 (length mode-string))))
6144 ;; We might have to chop a bit of the string off...
6145 (when (> (length mode-string) max-len)
6147 (concat (truncate-string-to-width mode-string (- max-len 3))
6149 ;; Update the mode line.
6150 (setq mode-line-buffer-identification
6151 (gnus-mode-line-buffer-identification (list mode-string)))
6152 (set-buffer-modified-p t))))
6154 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6155 "Go through the HEADERS list and add all Xrefs to a hash table.
6156 The resulting hash table is returned, or nil if no Xrefs were found."
6157 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6158 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6159 (xref-hashtb (gnus-make-hashtable))
6160 start group entry number xrefs header)
6162 (setq header (pop headers))
6163 (when (and (setq xrefs (mail-header-xref header))
6164 (not (memq (setq number (mail-header-number header))
6167 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6168 (setq start (match-end 0))
6169 (setq group (if prefix
6170 (concat prefix (substring xrefs (match-beginning 1)
6172 (substring xrefs (match-beginning 1) (match-end 1))))
6174 (string-to-number (substring xrefs (match-beginning 2)
6176 (if (setq entry (gnus-gethash group xref-hashtb))
6177 (setcdr entry (cons number (cdr entry)))
6178 (gnus-sethash group (cons number nil) xref-hashtb)))))
6179 (and start xref-hashtb)))
6181 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6182 "Look through all the headers and mark the Xrefs as read."
6183 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6184 name info xref-hashtb idlist method nth4)
6185 (with-current-buffer gnus-group-buffer
6186 (when (setq xref-hashtb
6187 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6190 (unless (string= from-newsgroup (setq name (symbol-name group)))
6191 (setq idlist (symbol-value group))
6192 ;; Dead groups are not updated.
6194 (setq info (gnus-get-info name))
6195 (when (stringp (setq nth4 (gnus-info-method info)))
6196 (setq nth4 (gnus-server-to-method nth4))))
6197 ;; Only do the xrefs if the group has the same
6198 ;; select method as the group we have just read.
6199 (or (gnus-methods-equal-p
6200 nth4 (gnus-find-method-for-group from-newsgroup))
6202 (equal nth4 (setq method (gnus-find-method-for-group
6204 (and (equal (car nth4) (car method))
6205 (equal (nth 1 nth4) (nth 1 method))))
6206 gnus-use-cross-reference
6207 (or (not (eq gnus-use-cross-reference t))
6209 ;; Only do cross-references on subscribed
6210 ;; groups, if that is what is wanted.
6211 (<= (gnus-info-level info) gnus-level-subscribed))
6212 (gnus-group-make-articles-read name idlist))))
6215 (defun gnus-compute-read-articles (group articles)
6216 (let* ((entry (gnus-group-entry group))
6217 (info (nth 2 entry))
6218 (active (gnus-active group))
6221 ;; First peel off all invalid article numbers.
6223 (let ((ids articles)
6225 (while (setq id (pop ids))
6226 (when (and first (> id (cdr active)))
6227 ;; We'll end up in this situation in one particular
6228 ;; obscure situation. If you re-scan a group and get
6229 ;; a new article that is cross-posted to a different
6230 ;; group that has not been re-scanned, you might get
6231 ;; crossposted article that has a higher number than
6232 ;; Gnus believes possible. So we re-activate this
6233 ;; group as well. This might mean doing the
6234 ;; crossposting thingy will *increase* the number
6235 ;; of articles in some groups. Tsk, tsk.
6236 (setq active (or (gnus-activate-group group) active)))
6237 (when (or (> id (cdr active))
6238 (< id (car active)))
6239 (setq articles (delq id articles))))))
6240 ;; If the read list is nil, we init it.
6242 (null (gnus-info-read info))
6244 (setq ninfo (cons 1 (1- (car active))))
6245 (setq ninfo (gnus-info-read info)))
6246 ;; Then we add the read articles to the range.
6248 ninfo (setq articles (sort articles '<))))))
6250 (defun gnus-group-make-articles-read (group articles)
6251 "Update the info of GROUP to say that ARTICLES are read."
6253 (entry (gnus-group-entry group))
6254 (info (nth 2 entry))
6255 (active (gnus-active group))
6258 ;; Group that Gnus doesn't know exists, but still allow the
6259 ;; backend to set marks.
6260 (gnus-request-set-mark
6261 group (list (list (gnus-compress-sequence (sort articles #'<))
6263 ;; Normal, subscribed groups.
6264 (setq range (gnus-compute-read-articles group articles))
6265 (with-current-buffer gnus-group-buffer
6268 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6269 (gnus-info-set-read ',info ',(gnus-info-read info))
6270 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6271 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6272 (gnus-group-update-group ,group t))))
6273 ;; Add the read articles to the range.
6274 (gnus-info-set-read info range)
6275 (gnus-request-set-mark group (list (list range 'add '(read))))
6276 ;; Then we have to re-compute how many unread
6277 ;; articles there are in this group.
6281 (setq num (- (1+ (cdr active)) (car active))))
6282 ((not (listp (cdr range)))
6283 (setq num (- (cdr active) (- (1+ (cdr range))
6287 (if (numberp (car range))
6289 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6290 (setq range (cdr range)))
6291 (setq num (- (cdr active) num))))
6292 ;; Update the number of unread articles.
6294 ;; Update the group buffer.
6295 (unless (gnus-ephemeral-group-p group)
6296 (gnus-group-update-group group t))))))
6298 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6299 (let ((cur nntp-server-buffer)
6302 (with-current-buffer gnus-summary-buffer
6303 gnus-newsgroup-dependencies)))
6304 headers id end ref number
6305 (mail-parse-charset gnus-newsgroup-charset)
6306 (mail-parse-ignored-charsets
6307 (save-current-buffer (condition-case nil
6308 (set-buffer gnus-summary-buffer)
6310 gnus-newsgroup-ignored-charsets)))
6311 (with-current-buffer nntp-server-buffer
6312 ;; Translate all TAB characters into SPACE characters.
6313 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6314 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6315 (ietf-drums-unfold-fws)
6316 (gnus-run-hooks 'gnus-parse-headers-hook)
6317 (let ((case-fold-search t)
6318 in-reply-to header p lines chars)
6319 (goto-char (point-min))
6320 ;; Search to the beginning of the next header. Error messages
6321 ;; do not begin with 2 or 3.
6322 (while (re-search-forward "^[23][0-9]+ " nil t)
6325 ;; This implementation of this function, with nine
6326 ;; search-forwards instead of the one re-search-forward and
6327 ;; a case (which basically was the old function) is actually
6328 ;; about twice as fast, even though it looks messier. You
6329 ;; can't have everything, I guess. Speed and elegance
6330 ;; doesn't always go hand in hand.
6336 (setq number (read cur))
6339 (narrow-to-region (point)
6340 (or (and (search-forward "\n.\n" nil t)
6346 (if (search-forward "\nsubject:" nil t)
6347 (funcall gnus-decode-encoded-word-function
6348 (nnheader-header-value))
6353 (if (search-forward "\nfrom:" nil t)
6354 (funcall gnus-decode-encoded-address-function
6355 (nnheader-header-value))
6360 (if (search-forward "\ndate:" nil t)
6361 (nnheader-header-value) ""))
6365 (setq id (if (re-search-forward
6366 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6367 ;; We do it this way to make sure the Message-ID
6368 ;; is (somewhat) syntactically valid.
6369 (buffer-substring (match-beginning 1)
6371 ;; If there was no message-id, we just fake one
6372 ;; to make subsequent routines simpler.
6373 (nnheader-generate-fake-message-id number))))
6377 (if (search-forward "\nreferences:" nil t)
6381 (nnheader-header-value)
6386 (search-backward ">" end t)
6389 (search-backward "<" end t)
6391 ;; Get the references from the in-reply-to header if there
6392 ;; were no references and the in-reply-to header looks
6394 (if (and (search-forward "\nin-reply-to:" nil t)
6395 (setq in-reply-to (nnheader-header-value))
6396 (string-match "<[^>]+>" in-reply-to))
6398 (setq ref (substring in-reply-to (match-beginning 0)
6400 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6401 (setq ref2 (substring in-reply-to (match-beginning 0)
6403 (when (> (length ref2) (length ref))
6410 (if (search-forward "\nchars: " nil t)
6411 (if (numberp (setq chars (ignore-errors (read cur))))
6417 (if (search-forward "\nlines: " nil t)
6418 (if (numberp (setq lines (ignore-errors (read cur))))
6424 (and (search-forward "\nxref:" nil t)
6425 (nnheader-header-value)))
6427 (when gnus-extra-headers
6428 (let ((extra gnus-extra-headers)
6432 (when (search-forward
6433 (concat "\n" (symbol-name (car extra)) ":") nil t)
6434 (push (cons (car extra) (nnheader-header-value))
6438 (when (equal id ref)
6441 (when gnus-alter-header-function
6442 (funcall gnus-alter-header-function header)
6443 (setq id (mail-header-id header)
6444 ref (gnus-parent-id (mail-header-references header))))
6447 (gnus-dependencies-add-header
6448 header dependencies force-new))
6449 (push header headers))
6450 (goto-char (point-max))
6452 (nreverse headers)))))
6454 ;; Goes through the xover lines and returns a list of vectors
6455 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6456 force-new dependencies
6457 group also-fetch-heads)
6458 "Parse the news overview data in the server buffer.
6459 Return a list of headers that match SEQUENCE (see
6460 `nntp-retrieve-headers')."
6461 ;; Get the Xref when the users reads the articles since most/some
6462 ;; NNTP servers do not include Xrefs when using XOVER.
6463 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6464 (let ((mail-parse-charset gnus-newsgroup-charset)
6465 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6466 (cur nntp-server-buffer)
6467 (dependencies (or dependencies gnus-newsgroup-dependencies))
6469 ((eq gnus-read-all-available-headers t)
6471 ((and (stringp gnus-read-all-available-headers)
6473 (string-match gnus-read-all-available-headers group))
6476 number headers header)
6477 (with-current-buffer nntp-server-buffer
6478 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6479 ;; Allow the user to mangle the headers before parsing them.
6480 (gnus-run-hooks 'gnus-parse-headers-hook)
6481 (goto-char (point-min))
6482 (gnus-parse-without-error
6483 (while (and (or sequence allp)
6485 (setq number (read cur))
6487 (while (and sequence
6488 (< (car sequence) number))
6489 (setq sequence (cdr sequence))))
6492 (eq number (car sequence))))
6494 (setq sequence (cdr sequence))
6495 (setq header (inline
6496 (gnus-nov-parse-line
6497 number dependencies force-new)))))
6498 (push header headers))
6500 ;; A common bug in inn is that if you have posted an article and
6501 ;; then retrieves the active file, it will answer correctly --
6502 ;; the new article is included. However, a NOV entry for the
6503 ;; article may not have been generated yet, so this may fail.
6504 ;; We work around this problem by retrieving the last few
6505 ;; headers using HEAD.
6506 (if (or (not also-fetch-heads)
6508 ;; We (probably) got all the headers.
6510 (let ((gnus-nov-is-evil t))
6513 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6514 (gnus-get-newsgroup-headers))))))))
6516 (defun gnus-article-get-xrefs ()
6517 "Fill in the Xref value in `gnus-current-headers', if necessary.
6518 This is meant to be called in `gnus-article-internal-prepare-hook'."
6519 (let ((headers (with-current-buffer gnus-summary-buffer
6520 gnus-current-headers)))
6521 (or (not gnus-use-cross-reference)
6523 (and (mail-header-xref headers)
6524 (not (string= (mail-header-xref headers) "")))
6525 (let ((case-fold-search t)
6528 (nnheader-narrow-to-headers)
6529 (goto-char (point-min))
6530 (when (or (and (not (eobp))
6531 (eq (downcase (char-after)) ?x)
6532 (looking-at "Xref:"))
6533 (search-forward "\nXref:" nil t))
6534 (goto-char (1+ (match-end 0)))
6535 (setq xref (buffer-substring (point) (point-at-eol)))
6536 (mail-header-set-xref headers xref)))))))
6538 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6539 "Find article ID and insert the summary line for that article.
6540 OLD-HEADER can either be a header or a line number to insert
6541 the subject line on."
6542 (let* ((line (and (numberp old-header) old-header))
6543 (old-header (and (vectorp old-header) old-header))
6544 (header (cond ((and old-header use-old-header)
6547 (gnus-number-to-header id))
6548 (gnus-number-to-header id))
6550 (gnus-read-header id))))
6551 (number (and (numberp id) id))
6554 ;; Rebuild the thread that this article is part of and go to the
6555 ;; article we have fetched.
6556 (when (and (not gnus-show-threads)
6559 (setq d (gnus-data-find (mail-header-number old-header))))
6560 (goto-char (gnus-data-pos d))
6566 (gnus-delete-line))))))
6567 ;; Remove list identifiers from subject.
6568 (when gnus-list-identifiers
6569 (let ((gnus-newsgroup-headers (list header)))
6570 (gnus-summary-remove-list-identifiers)))
6572 (mail-header-set-number header (mail-header-number old-header)))
6573 (setq gnus-newsgroup-sparse
6574 (delq (setq number (mail-header-number header))
6575 gnus-newsgroup-sparse))
6576 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6577 (push number gnus-newsgroup-limit)
6578 (gnus-rebuild-thread (mail-header-id header) line)
6579 (gnus-summary-goto-subject number nil t))
6580 (when (and (numberp number)
6582 ;; We have to update the boundaries even if we can't fetch the
6583 ;; article if ID is a number -- so that the next `P' or `N'
6584 ;; command will fetch the previous (or next) article even
6585 ;; if the one we tried to fetch this time has been canceled.
6586 (when (> number gnus-newsgroup-end)
6587 (setq gnus-newsgroup-end number))
6588 (when (< number gnus-newsgroup-begin)
6589 (setq gnus-newsgroup-begin number))
6590 (setq gnus-newsgroup-unselected
6591 (delq number gnus-newsgroup-unselected)))
6592 ;; Report back a success?
6593 (and header (mail-header-number header))))
6595 ;;; Process/prefix in the summary buffer
6597 (defun gnus-summary-work-articles (n)
6598 "Return a list of articles to be worked upon.
6599 The prefix argument, the list of process marked articles, and the
6600 current article will be taken into consideration."
6601 (with-current-buffer gnus-summary-buffer
6604 ;; A numerical prefix has been given.
6605 (setq n (prefix-numeric-value n))
6606 (let ((backward (< n 0))
6607 (n (abs (prefix-numeric-value n)))
6612 (push (setq article (gnus-summary-article-number))
6615 (gnus-summary-find-prev nil article)
6616 (gnus-summary-find-next nil article)))
6618 (nreverse articles)))
6619 ((and (gnus-region-active-p) (mark))
6620 (message "region active")
6621 ;; Work on the region between point and mark.
6622 (let ((max (max (point) (mark)))
6625 (goto-char (min (point) (mark)))
6628 (push (setq article (gnus-summary-article-number)) articles)
6629 (gnus-summary-find-next nil article)
6631 (nreverse articles))))
6632 (gnus-newsgroup-processable
6633 ;; There are process-marked articles present.
6634 ;; Save current state.
6635 (gnus-summary-save-process-mark)
6637 (reverse gnus-newsgroup-processable))
6639 ;; Just return the current article.
6640 (list (gnus-summary-article-number))))))
6642 (defmacro gnus-summary-iterate (arg &rest forms)
6643 "Iterate over the process/prefixed articles and do FORMS.
6644 ARG is the interactive prefix given to the command. FORMS will be
6645 executed with point over the summary line of the articles."
6646 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6647 `(let ((,articles (gnus-summary-work-articles ,arg)))
6649 (gnus-summary-goto-subject (car ,articles))
6653 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6654 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6656 (defun gnus-summary-save-process-mark ()
6657 "Push the current set of process marked articles on the stack."
6659 (push (copy-sequence gnus-newsgroup-processable)
6660 gnus-newsgroup-process-stack))
6662 (defun gnus-summary-kill-process-mark ()
6663 "Push the current set of process marked articles on the stack and unmark."
6665 (gnus-summary-save-process-mark)
6666 (gnus-summary-unmark-all-processable))
6668 (defun gnus-summary-yank-process-mark ()
6669 "Pop the last process mark state off the stack and restore it."
6671 (unless gnus-newsgroup-process-stack
6672 (error "Empty mark stack"))
6673 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6675 (defun gnus-summary-process-mark-set (set)
6676 "Make SET into the current process marked articles."
6677 (gnus-summary-unmark-all-processable)
6678 (mapc 'gnus-summary-set-process-mark set))
6680 ;;; Searching and stuff
6682 (defun gnus-summary-search-group (&optional backward use-level)
6683 "Search for next unread newsgroup.
6684 If optional argument BACKWARD is non-nil, search backward instead."
6685 (with-current-buffer gnus-group-buffer
6686 (when (gnus-group-search-forward
6687 backward nil (if use-level (gnus-group-group-level) nil))
6688 (gnus-group-group-name))))
6690 (defun gnus-summary-best-group (&optional exclude-group)
6691 "Find the name of the best unread group.
6692 If EXCLUDE-GROUP, do not go to this group."
6693 (with-current-buffer gnus-group-buffer
6695 (gnus-group-best-unread-group exclude-group))))
6697 (defun gnus-summary-find-next (&optional unread article backward)
6699 (gnus-summary-find-prev unread article)
6700 (let* ((dummy (gnus-summary-article-intangible-p))
6701 (article (or article (gnus-summary-article-number)))
6702 (data (gnus-data-find-list article))
6704 (when (and (not dummy)
6705 (or (not gnus-summary-check-current)
6707 (not (gnus-data-unread-p (car data)))))
6708 (setq data (cdr data)))
6713 (unless (memq (gnus-data-number (car data))
6715 ((eq gnus-auto-goto-ignores
6716 'always-undownloaded)
6717 gnus-newsgroup-undownloaded)
6720 ((eq gnus-auto-goto-ignores
6722 gnus-newsgroup-unfetched)
6723 ((eq gnus-auto-goto-ignores
6725 gnus-newsgroup-undownloaded)))
6726 (when (gnus-data-unread-p (car data))
6727 (setq result (car data)
6729 (setq data (cdr data)))
6732 (goto-char (gnus-data-pos result))
6733 (gnus-data-number result)))))
6735 (defun gnus-summary-find-prev (&optional unread article)
6736 (let* ((eobp (eobp))
6737 (article (or article (gnus-summary-article-number)))
6738 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6740 (when (and (not eobp)
6741 (or (not gnus-summary-check-current)
6743 (not (gnus-data-unread-p (car data)))))
6744 (setq data (cdr data)))
6749 (unless (memq (gnus-data-number (car data))
6751 ((eq gnus-auto-goto-ignores
6752 'always-undownloaded)
6753 gnus-newsgroup-undownloaded)
6756 ((eq gnus-auto-goto-ignores
6758 gnus-newsgroup-unfetched)
6759 ((eq gnus-auto-goto-ignores
6761 gnus-newsgroup-undownloaded)))
6762 (when (gnus-data-unread-p (car data))
6763 (setq result (car data)
6765 (setq data (cdr data)))
6768 (goto-char (gnus-data-pos result))
6769 (gnus-data-number result))))
6771 (defun gnus-summary-find-subject (subject &optional unread backward article)
6772 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6773 (article (or article (gnus-summary-article-number)))
6774 (articles (gnus-data-list backward))
6775 (arts (gnus-data-find-list article articles))
6777 (when (or (not gnus-summary-check-current)
6779 (not (gnus-data-unread-p (car arts))))
6780 (setq arts (cdr arts)))
6782 (and (or (not unread)
6783 (gnus-data-unread-p (car arts)))
6784 (vectorp (gnus-data-header (car arts)))
6786 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6787 (setq result (car arts)
6789 (setq arts (cdr arts)))
6791 (goto-char (gnus-data-pos result))
6792 (gnus-data-number result))))
6794 (defun gnus-summary-search-forward (&optional unread subject backward)
6795 "Search forward for an article.
6796 If UNREAD, look for unread articles. If SUBJECT, look for
6797 articles with that subject. If BACKWARD, search backward instead."
6798 (cond (subject (gnus-summary-find-subject subject unread backward))
6799 (backward (gnus-summary-find-prev unread))
6800 (t (gnus-summary-find-next unread))))
6802 (defun gnus-recenter (&optional n)
6803 "Center point in window and redisplay frame.
6804 Also do horizontal recentering."
6806 (when (and gnus-auto-center-summary
6807 (not (eq gnus-auto-center-summary 'vertical)))
6808 (gnus-horizontal-recenter))
6809 (if (fboundp 'recenter-top-bottom)
6810 (recenter-top-bottom n)
6813 (put 'gnus-recenter 'isearch-scroll t)
6815 (defun gnus-forward-line-ignore-invisible (n)
6816 "Move N lines forward (backward if N is negative).
6817 Like forward-line, but skip over (and don't count) invisible lines."
6819 (while (and (> n 0) (not done))
6820 ;; If the following character is currently invisible,
6821 ;; skip all characters with that same `invisible' property value.
6822 (while (gnus-invisible-p (point))
6823 (goto-char (gnus-next-char-property-change (point))))
6828 (while (and (< n 0) (not done))
6830 (if (bobp) (setq done t)
6832 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6833 (goto-char (gnus-previous-char-property-change (point))))))))
6835 (defun gnus-summary-recenter ()
6836 "Center point in the summary window.
6837 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6838 displayed, no centering will be performed."
6839 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6840 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6842 ;; The user has to want it.
6843 (when gnus-auto-center-summary
6844 (let* ((top (cond ((< (window-height) 4) 0)
6845 ((< (window-height) 7) 1)
6846 (t (if (numberp gnus-auto-center-summary)
6847 gnus-auto-center-summary
6848 (/ (1- (window-height)) 2)))))
6849 (height (1- (window-height)))
6850 (bottom (save-excursion
6851 (goto-char (point-max))
6852 (gnus-forward-line-ignore-invisible (- height))
6854 (window (get-buffer-window (current-buffer))))
6855 (when (get-buffer-window gnus-article-buffer)
6856 ;; Only do recentering when the article buffer is displayed,
6857 ;; Set the window start to either `bottom', which is the biggest
6858 ;; possible valid number, or the second line from the top,
6859 ;; whichever is the least.
6860 (let ((top-pos (save-excursion
6861 (gnus-forward-line-ignore-invisible (- top))
6863 (if (> bottom top-pos)
6864 ;; Keep the second line from the top visible
6865 (set-window-start window top-pos)
6866 ;; Try to keep the bottom line visible; if it's partially
6867 ;; obscured, either scroll one more line to make it fully
6868 ;; visible, or revert to using TOP-POS.
6870 (goto-char (point-max))
6871 (gnus-forward-line-ignore-invisible -1)
6872 (let ((last-line-start (point)))
6874 (set-window-start window (point) t)
6875 (when (not (pos-visible-in-window-p last-line-start window))
6876 (gnus-forward-line-ignore-invisible 1)
6877 (set-window-start window (min (point) top-pos) t)))))))
6878 ;; Do horizontal recentering while we're at it.
6879 (when (and (get-buffer-window (current-buffer) t)
6880 (not (eq gnus-auto-center-summary 'vertical)))
6881 (let ((selected (selected-window)))
6882 (select-window (get-buffer-window (current-buffer) t))
6883 (gnus-summary-position-point)
6884 (gnus-horizontal-recenter)
6885 (select-window selected))))))
6887 (defun gnus-summary-jump-to-group (newsgroup)
6888 "Move point to NEWSGROUP in group mode buffer."
6889 ;; Keep update point of group mode buffer if visible.
6890 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6891 (save-window-excursion
6892 ;; Take care of tree window mode.
6893 (when (get-buffer-window gnus-group-buffer)
6894 (pop-to-buffer gnus-group-buffer))
6895 (gnus-group-jump-to-group newsgroup))
6897 ;; Take care of tree window mode.
6898 (if (get-buffer-window gnus-group-buffer 0)
6899 (pop-to-buffer gnus-group-buffer)
6900 (set-buffer gnus-group-buffer))
6901 (gnus-group-jump-to-group newsgroup))))
6903 ;; This function returns a list of article numbers based on the
6904 ;; difference between the ranges of read articles in this group and
6905 ;; the range of active articles.
6906 (defun gnus-list-of-unread-articles (group)
6907 (let* ((read (gnus-info-read (gnus-get-info group)))
6908 (active (or (gnus-active group) (gnus-activate-group group)))
6909 (last (or (cdr active)
6910 (error "Group %s couldn't be activated " group)))
6911 (bottom (if gnus-newsgroup-maximum-articles
6913 (- last gnus-newsgroup-maximum-articles -1))
6916 ;; If none are read, then all are unread.
6919 ;; If the range of read articles is a single range, then the
6920 ;; first unread article is the article after the last read
6921 ;; article. Sounds logical, doesn't it?
6922 (if (and (not (listp (cdr read)))
6923 (or (< (car read) bottom)
6924 (progn (setq read (list read))
6926 (setq first (max bottom (1+ (cdr read))))
6927 ;; `read' is a list of ranges.
6928 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6931 (setq first bottom))
6934 (while (< first nlast)
6935 (setq unread (cons first unread)
6937 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6938 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6939 (setq read (cdr read)))))
6940 ;; And add the last unread articles.
6941 (while (<= first last)
6942 (setq unread (cons first unread)
6944 ;; Return the list of unread articles.
6945 (delq 0 (nreverse unread))))
6947 (defun gnus-list-of-read-articles (group)
6948 "Return a list of unread, unticked and non-dormant articles."
6949 (let* ((info (gnus-get-info group))
6950 (marked (gnus-info-marks info))
6951 (active (gnus-active group)))
6953 (gnus-list-range-difference
6954 (gnus-list-range-difference
6955 (gnus-sorted-complement
6956 (gnus-uncompress-range
6957 (if gnus-newsgroup-maximum-articles
6958 (cons (max (car active)
6960 gnus-newsgroup-maximum-articles
6964 (gnus-list-of-unread-articles group))
6965 (cdr (assq 'dormant marked)))
6966 (cdr (assq 'tick marked))))))
6968 ;; This function returns a sequence 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-sequence-of-unread-articles (group)
6972 (let* ((read (gnus-info-read (gnus-get-info group)))
6973 (active (or (gnus-active group) (gnus-activate-group group)))
6975 (bottom (if gnus-newsgroup-maximum-articles
6977 (- last gnus-newsgroup-maximum-articles -1))
6980 ;; If none are read, then all are unread.
6983 ;; If the range of read articles is a single range, then the
6984 ;; first unread article is the article after the last read
6985 ;; article. Sounds logical, doesn't it?
6986 (if (and (not (listp (cdr read)))
6987 (or (< (car read) bottom)
6988 (progn (setq read (list read))
6990 (setq first (max bottom (1+ (cdr read))))
6991 ;; `read' is a list of ranges.
6992 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6995 (setq first bottom))
6998 (push (cons first nlast) unread))
6999 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7000 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7001 (setq read (cdr read)))))
7002 ;; And add the last unread articles.
7003 (cond ((not (and first last))
7006 (push (cons first last) unread))
7008 (push first unread)))
7009 ;; Return the sequence of unread articles.
7010 (delq 0 (nreverse unread))))
7012 ;; Various summary commands
7014 (defun gnus-summary-select-article-buffer ()
7015 "Reconfigure windows to show the article buffer.
7016 If `gnus-widen-article-buffer' is set, show only the article
7019 (if (not (gnus-buffer-live-p gnus-article-buffer))
7020 (error "There is no article buffer for this summary buffer")
7021 (unless (get-buffer-window gnus-article-buffer)
7022 (gnus-summary-show-article))
7023 (gnus-configure-windows
7024 (if gnus-widen-article-window
7028 (select-window (get-buffer-window gnus-article-buffer))))
7030 (defun gnus-summary-universal-argument (arg)
7031 "Perform any operation on all articles that are process/prefixed."
7033 (let ((articles (gnus-summary-work-articles arg))
7040 (substitute-command-keys
7041 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7043 (gnus-error 1 "Undefined key")
7046 (gnus-summary-goto-subject (setq article (pop articles)))
7047 (let (gnus-newsgroup-processable)
7048 (command-execute func))
7049 (gnus-summary-remove-process-mark article)))))
7050 (gnus-summary-position-point))
7052 (defun gnus-summary-toggle-truncation (&optional arg)
7053 "Toggle truncation of summary lines.
7054 With ARG, turn line truncation on if ARG is positive."
7056 (setq truncate-lines
7057 (if (null arg) (not truncate-lines)
7058 (> (prefix-numeric-value arg) 0)))
7061 (defun gnus-summary-find-for-reselect ()
7062 "Return the number of an article to stay on across a reselect.
7063 The current article is considered, then following articles, then previous
7064 articles. An article is sought which is not cancelled and isn't a temporary
7065 insertion from another group. If there's no such then return a dummy 0."
7067 (dolist (rev '(nil t))
7068 (unless found ; don't demand the reverse list if we don't need it
7069 (let ((data (gnus-data-find-list
7070 (gnus-summary-article-number) (gnus-data-list rev))))
7071 (while (and data (not found))
7072 (if (and (< 0 (gnus-data-number (car data)))
7073 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7074 (setq found (gnus-data-number (car data))))
7075 (setq data (cdr data))))))
7078 (defun gnus-summary-reselect-current-group (&optional all rescan)
7079 "Exit and then reselect the current newsgroup.
7080 The prefix argument ALL means to select all articles."
7082 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7083 (error "Ephemeral groups can't be reselected"))
7084 (let ((current-subject (gnus-summary-find-for-reselect))
7085 (group gnus-newsgroup-name))
7086 (setq gnus-newsgroup-begin nil)
7087 (gnus-summary-exit nil 'leave-hidden)
7088 ;; We have to adjust the point of group mode buffer because
7089 ;; point was moved to the next unread newsgroup by exiting.
7090 (gnus-summary-jump-to-group group)
7093 (gnus-group-get-new-news-this-group 1)))
7094 (gnus-group-read-group all t)
7095 (gnus-summary-goto-subject current-subject nil t)))
7097 (defun gnus-summary-rescan-group (&optional all)
7098 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7100 (let ((config gnus-current-window-configuration))
7101 (gnus-summary-reselect-current-group all t)
7102 (gnus-configure-windows config)
7103 (when (eq config 'article)
7104 (gnus-summary-select-article))))
7106 (defun gnus-summary-update-info (&optional non-destructive)
7108 (let ((group gnus-newsgroup-name))
7110 (when gnus-newsgroup-kill-headers
7111 (setq gnus-newsgroup-killed
7112 (gnus-compress-sequence
7114 (gnus-list-range-intersection
7115 gnus-newsgroup-unselected gnus-newsgroup-killed)
7116 gnus-newsgroup-unreads)
7118 (unless (listp (cdr gnus-newsgroup-killed))
7119 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7120 (let ((headers gnus-newsgroup-headers))
7121 ;; Set the new ranges of read articles.
7122 (with-current-buffer gnus-group-buffer
7123 (gnus-undo-force-boundary))
7124 (gnus-update-read-articles
7125 group (gnus-sorted-union
7126 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7127 ;; Set the current article marks.
7128 (let ((gnus-newsgroup-scored
7129 (if (and (not gnus-save-score)
7130 (not non-destructive))
7132 gnus-newsgroup-scored)))
7134 (gnus-update-marks)))
7135 ;; Do the cross-ref thing.
7136 (when gnus-use-cross-reference
7137 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7138 ;; Do not switch windows but change the buffer to work.
7139 (set-buffer gnus-group-buffer)
7140 (unless (gnus-ephemeral-group-p group)
7141 (gnus-group-update-group group)))))))
7143 (defun gnus-summary-save-newsrc (&optional force)
7144 "Save the current number of read/marked articles in the dribble buffer.
7145 The dribble buffer will then be saved.
7146 If FORCE (the prefix), also save the .newsrc file(s)."
7148 (gnus-summary-update-info t)
7150 (gnus-save-newsrc-file)
7151 (gnus-dribble-save)))
7153 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7155 (defun gnus-summary-exit (&optional temporary leave-hidden)
7156 "Exit reading current newsgroup, and then return to group selection mode.
7157 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7159 (gnus-set-global-variables)
7160 (when (gnus-buffer-live-p gnus-article-buffer)
7161 (with-current-buffer gnus-article-buffer
7162 (mm-destroy-parts gnus-article-mime-handles)
7163 ;; Set it to nil for safety reason.
7164 (setq gnus-article-mime-handle-alist nil)
7165 (setq gnus-article-mime-handles nil)))
7166 (gnus-kill-save-kill-buffer)
7167 (gnus-async-halt-prefetch)
7168 (let* ((group gnus-newsgroup-name)
7169 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7170 (gnus-group-is-exiting-p t)
7173 (buf (current-buffer)))
7175 ;; Do adaptive scoring, and possibly save score files.
7176 (when gnus-newsgroup-adaptive
7177 (gnus-score-adaptive))
7178 (when gnus-use-scoring
7180 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7181 (when gnus-use-cache
7182 (gnus-cache-possibly-remove-articles)
7183 (gnus-cache-save-buffers))
7184 (gnus-async-prefetch-remove-group group)
7185 (when gnus-suppress-duplicates
7186 (gnus-dup-enter-articles))
7187 (when gnus-use-trees
7188 (gnus-tree-close group))
7189 (when gnus-use-cache
7190 (gnus-cache-write-active))
7191 ;; Remove entries for this group.
7192 (nnmail-purge-split-history (gnus-group-real-name group))
7193 ;; Make all changes in this group permanent.
7195 (gnus-run-hooks 'gnus-exit-group-hook)
7196 (gnus-summary-update-info))
7197 (gnus-close-group group)
7198 ;; Make sure where we were, and go to next newsgroup.
7199 (set-buffer gnus-group-buffer)
7201 (gnus-group-jump-to-group group))
7202 (gnus-run-hooks 'gnus-summary-exit-hook)
7203 (unless (or quit-config
7204 (not gnus-summary-next-group-on-exit)
7205 ;; If this group has disappeared from the summary
7206 ;; buffer, don't skip forwards.
7207 (not (string= group (gnus-group-group-name))))
7208 (gnus-group-next-unread-group 1))
7209 (setq group-point (point))
7213 (if (not gnus-kill-summary-on-exit)
7215 (gnus-deaden-summary)
7217 (when (get-buffer gnus-article-buffer)
7218 (bury-buffer gnus-article-buffer))
7219 ;; Return to group mode buffer.
7220 (when (eq mode 'gnus-summary-mode)
7221 (gnus-kill-buffer buf)))
7223 ;; If we have several article buffers, we kill them at exit.
7224 (unless gnus-single-article-buffer
7225 (when (gnus-buffer-live-p gnus-article-buffer)
7226 (with-current-buffer gnus-article-buffer
7227 ;; Don't kill sticky article buffers
7228 (unless (eq major-mode 'gnus-sticky-article-mode)
7229 (gnus-kill-buffer gnus-article-buffer)
7230 (setq gnus-article-current nil))))
7231 (gnus-kill-buffer gnus-original-article-buffer))
7233 (setq gnus-current-select-method gnus-select-method)
7234 (set-buffer gnus-group-buffer)
7236 (gnus-handle-ephemeral-exit quit-config)
7237 (goto-char group-point)
7238 ;; If gnus-group-buffer is already displayed, make sure we also move
7239 ;; the cursor in the window that displays it.
7240 (let ((win (get-buffer-window (current-buffer) 0)))
7241 (if win (set-window-point win (point))))
7242 (unless leave-hidden
7243 (gnus-configure-windows 'group 'force)))
7244 ;; Clear the current group name.
7246 (setq gnus-newsgroup-name nil)))))
7248 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7249 (defun gnus-summary-exit-no-update (&optional no-questions)
7250 "Quit reading current newsgroup without updating read article info."
7252 (let* ((group gnus-newsgroup-name)
7253 (gnus-group-is-exiting-p t)
7254 (gnus-group-is-exiting-without-update-p t)
7255 (quit-config (gnus-group-quit-config group)))
7256 (when (or no-questions
7258 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7259 (gnus-async-halt-prefetch)
7260 (run-hooks 'gnus-summary-prepare-exit-hook)
7261 (when (gnus-buffer-live-p gnus-article-buffer)
7262 (with-current-buffer gnus-article-buffer
7263 (mm-destroy-parts gnus-article-mime-handles)
7264 ;; Set it to nil for safety reason.
7265 (setq gnus-article-mime-handle-alist nil)
7266 (setq gnus-article-mime-handles nil)))
7267 ;; If we have several article buffers, we kill them at exit.
7268 (unless gnus-single-article-buffer
7269 (gnus-kill-buffer gnus-article-buffer)
7270 (gnus-kill-buffer gnus-original-article-buffer)
7271 (setq gnus-article-current nil))
7272 (if (not gnus-kill-summary-on-exit)
7273 (gnus-deaden-summary)
7274 (gnus-close-group group)
7275 (gnus-kill-buffer gnus-summary-buffer))
7276 (unless gnus-single-article-buffer
7277 (setq gnus-article-current nil))
7278 (when gnus-use-trees
7279 (gnus-tree-close group))
7280 (gnus-async-prefetch-remove-group group)
7281 (when (get-buffer gnus-article-buffer)
7282 (bury-buffer gnus-article-buffer))
7283 ;; Return to the group buffer.
7284 (gnus-configure-windows 'group 'force)
7285 ;; Clear the current group name.
7286 (setq gnus-newsgroup-name nil)
7287 (unless (gnus-ephemeral-group-p group)
7288 (gnus-group-update-group group))
7289 (when (equal (gnus-group-group-name) group)
7290 (gnus-group-next-unread-group 1))
7292 (gnus-handle-ephemeral-exit quit-config)))))
7294 (defun gnus-handle-ephemeral-exit (quit-config)
7295 "Handle movement when leaving an ephemeral group.
7296 The state which existed when entering the ephemeral is reset."
7297 (if (not (buffer-name (car quit-config)))
7298 (gnus-configure-windows 'group 'force)
7299 (set-buffer (car quit-config))
7300 (cond ((eq major-mode 'gnus-summary-mode)
7301 (gnus-set-global-variables))
7302 ((eq major-mode 'gnus-article-mode)
7303 (save-current-buffer
7304 ;; The `gnus-summary-buffer' variable may point
7305 ;; to the old summary buffer when using a single
7307 (unless (gnus-buffer-live-p gnus-summary-buffer)
7308 (set-buffer gnus-group-buffer))
7309 (set-buffer gnus-summary-buffer)
7310 (gnus-set-global-variables))))
7311 (if (or (eq (cdr quit-config) 'article)
7312 (eq (cdr quit-config) 'pick))
7313 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7314 (gnus-configure-windows 'pick 'force)
7315 (gnus-configure-windows (cdr quit-config) 'force))
7316 (gnus-configure-windows (cdr quit-config) 'force))
7317 (when (eq major-mode 'gnus-summary-mode)
7318 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7319 next-unread-noselect))
7320 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7322 (gnus-summary-next-subject 1 nil t))
7323 ((eq gnus-auto-select-on-ephemeral-exit
7324 'next-unread-noselect)
7325 (gnus-summary-next-subject 1 t t))))
7326 ;; Hide the article buffer which displays the article different
7327 ;; from the one that the cursor points to in the summary buffer.
7328 (gnus-configure-windows 'summary 'force))
7329 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7330 (gnus-summary-next-subject 1))
7331 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7332 (gnus-summary-next-subject 1 t))))
7333 (gnus-summary-recenter)
7334 (gnus-summary-position-point))))
7338 (defvar gnus-dead-summary-mode-map
7339 (let ((map (make-keymap)))
7340 (suppress-keymap map)
7341 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7342 (dolist (key '("\C-d" "\r" "\177" [delete]))
7343 (define-key map key 'gnus-summary-wake-up-the-dead))
7344 (dolist (key '("q" "Q"))
7345 (define-key map key 'bury-buffer))
7348 (define-minor-mode gnus-dead-summary-mode
7349 "Minor mode for Gnus summary buffers."
7350 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7351 (unless (derived-mode-p 'gnus-summary-mode)
7352 (setq gnus-dead-summary-mode nil)))
7354 (defun gnus-deaden-summary ()
7355 "Make the current summary buffer into a dead summary buffer."
7356 ;; Kill any previous dead summary buffer.
7357 (when (and gnus-dead-summary
7358 (buffer-name gnus-dead-summary))
7359 (with-current-buffer gnus-dead-summary
7360 (when gnus-dead-summary-mode
7361 (kill-buffer (current-buffer)))))
7362 ;; Make this the current dead summary.
7363 (setq gnus-dead-summary (current-buffer))
7364 (gnus-dead-summary-mode 1)
7365 (let ((name (buffer-name)))
7366 (when (string-match "Summary" name)
7368 (concat (substring name 0 (match-beginning 0)) "Dead "
7369 (substring name (match-beginning 0)))
7373 (defun gnus-kill-or-deaden-summary (buffer)
7374 "Kill or deaden the summary BUFFER."
7376 (when (and (buffer-name buffer)
7377 (not gnus-single-article-buffer))
7378 (with-current-buffer buffer
7379 (gnus-kill-buffer gnus-article-buffer)
7380 (gnus-kill-buffer gnus-original-article-buffer)))
7383 (gnus-kill-summary-on-exit
7384 (when (and gnus-use-trees
7385 (gnus-buffer-exists-p buffer))
7386 (with-current-buffer buffer
7387 (gnus-tree-close gnus-newsgroup-name)))
7388 (gnus-kill-buffer buffer))
7389 ;; Deaden the buffer.
7390 ((gnus-buffer-exists-p buffer)
7391 (with-current-buffer buffer
7392 (gnus-deaden-summary))))))
7394 (defun gnus-summary-wake-up-the-dead (&rest args)
7395 "Wake up the dead summary buffer."
7397 (gnus-dead-summary-mode -1)
7398 (let ((name (buffer-name)))
7399 (when (string-match "Dead " name)
7401 (concat (substring name 0 (match-beginning 0))
7402 (substring name (match-end 0)))
7404 (gnus-message 3 "This dead summary is now alive again"))
7406 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7407 (defun gnus-summary-describe-group (&optional force)
7408 "Describe the current newsgroup."
7410 (gnus-group-describe-group force gnus-newsgroup-name))
7412 (defun gnus-summary-describe-briefly ()
7413 "Describe summary mode commands briefly."
7415 (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")))
7417 ;; Walking around group mode buffer from summary mode.
7419 (defun gnus-summary-next-group (&optional no-article target-group backward)
7420 "Exit current newsgroup and then select next unread newsgroup.
7421 If prefix argument NO-ARTICLE is non-nil, no article is selected
7422 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7423 previous group instead."
7425 ;; Stop pre-fetching.
7426 (gnus-async-halt-prefetch)
7427 (let ((current-group gnus-newsgroup-name)
7428 (current-buffer (current-buffer))
7430 ;; First we semi-exit this group to update Xrefs and all variables.
7431 ;; We can't do a real exit, because the window conf must remain
7432 ;; the same in case the user is prompted for info, and we don't
7433 ;; want the window conf to change before that...
7434 (gnus-summary-exit t)
7435 (while (not entered)
7436 ;; Then we find what group we are supposed to enter.
7437 (set-buffer gnus-group-buffer)
7438 (gnus-group-jump-to-group current-group)
7441 (if (eq gnus-keep-same-level 'best)
7442 (gnus-summary-best-group gnus-newsgroup-name)
7443 (gnus-summary-search-group backward gnus-keep-same-level))))
7444 (if (not target-group)
7445 ;; There are no further groups, so we return to the group
7448 (gnus-message 5 "Returning to the group buffer")
7450 (when (gnus-buffer-live-p current-buffer)
7451 (set-buffer current-buffer)
7452 (gnus-summary-exit))
7453 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7454 ;; We try to enter the target group.
7455 (gnus-group-jump-to-group target-group)
7456 (let ((unreads (gnus-group-group-unread)))
7457 (if (and (or (eq t unreads)
7458 (and unreads (not (zerop unreads))))
7459 (gnus-summary-read-group
7460 target-group nil no-article
7461 (and (buffer-name current-buffer) current-buffer)
7464 (setq current-group target-group
7465 target-group nil)))))))
7467 (defun gnus-summary-prev-group (&optional no-article)
7468 "Exit current newsgroup and then select previous unread newsgroup.
7469 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7471 (gnus-summary-next-group no-article nil t))
7473 ;; Walking around summary lines.
7475 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7476 "Go to the first subject satisfying any non-nil constraint.
7477 If UNREAD is non-nil, the article should be unread.
7478 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7479 If UNSEEN is non-nil, the article should be unseen as well as unread.
7480 Returns the article selected or nil if there are no matching articles."
7484 ((null gnus-newsgroup-data)
7485 (gnus-message 3 "No articles in the group")
7487 ;; Pick the first article.
7488 ((not (or unread undownloaded unseen))
7489 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7490 (gnus-data-number (car gnus-newsgroup-data)))
7491 ;; Find the first unread article.
7493 (let ((data gnus-newsgroup-data))
7495 (let ((num (gnus-data-number (car data))))
7496 (or (memq num gnus-newsgroup-unfetched)
7497 (not (or (and unread
7498 (memq num gnus-newsgroup-unreads))
7500 (memq num gnus-newsgroup-undownloaded))
7502 (memq num gnus-newsgroup-unseen)
7503 (memq num gnus-newsgroup-unreads)))))))
7504 (setq data (cdr data)))
7508 (goto-char (gnus-data-pos (car data)))
7509 (gnus-data-number (car data)))
7510 (gnus-message 3 "No more%s articles"
7511 (let* ((r (when unread " unread"))
7512 (d (when undownloaded " undownloaded"))
7513 (s (when unseen " unseen"))
7514 (l (delq nil (list r d s))))
7515 (cond ((= 3 (length l))
7516 (concat r "," d ", or" s))
7518 (concat (car l) ", or" (cadr l)))
7525 (gnus-summary-position-point))))))
7527 (defun gnus-summary-next-subject (n &optional unread dont-display)
7528 "Go to next N'th summary line.
7529 If N is negative, go to the previous N'th subject line.
7530 If UNREAD is non-nil, only unread articles are selected.
7531 The difference between N and the actual number of steps taken is
7534 (let ((backward (< n 0))
7538 (gnus-summary-find-prev unread)
7539 (gnus-summary-find-next unread)))
7540 (unless (zerop (setq n (1- n)))
7541 (gnus-summary-show-thread)))
7543 (gnus-message 7 "No more%s articles"
7544 (if unread " unread" "")))
7545 (unless dont-display
7546 (gnus-summary-recenter)
7547 (gnus-summary-position-point))
7550 (defun gnus-summary-next-unread-subject (n)
7551 "Go to next N'th unread summary line."
7553 (gnus-summary-next-subject n t))
7555 (defun gnus-summary-prev-subject (n &optional unread)
7556 "Go to previous N'th summary line.
7557 If optional argument UNREAD is non-nil, only unread article is selected."
7559 (gnus-summary-next-subject (- n) unread))
7561 (defun gnus-summary-prev-unread-subject (n)
7562 "Go to previous N'th unread summary line."
7564 (gnus-summary-next-subject (- n) t))
7566 (defun gnus-summary-goto-subjects (articles)
7567 "Insert the subject header for ARTICLES in the current buffer."
7569 (dolist (article articles)
7570 (gnus-summary-goto-subject article t)))
7571 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7572 (gnus-summary-position-point))
7574 (defun gnus-summary-goto-subject (article &optional force silent)
7575 "Go to the subject line of ARTICLE.
7576 If FORCE, also allow jumping to articles not currently shown."
7577 (interactive "nArticle number: ")
7578 (unless (numberp article)
7579 (error "Article %s is not a number" article))
7581 (data (gnus-data-find article)))
7582 ;; We read in the article if we have to.
7585 (gnus-summary-insert-subject
7587 (if (or (numberp force) (vectorp force)) force)
7589 (setq data (gnus-data-find article)))
7594 (gnus-message 3 "Can't find article %d" article))
7596 (let ((pt (gnus-data-pos data)))
7598 (gnus-summary-set-article-display-arrow pt))
7599 (gnus-summary-position-point)
7602 ;; Walking around summary lines with displaying articles.
7604 (defun gnus-summary-expand-window (&optional arg)
7605 "Make the summary buffer take up the entire Emacs frame.
7606 Given a prefix, will force an `article' buffer configuration."
7609 (gnus-configure-windows 'article 'force)
7610 (gnus-configure-windows 'summary 'force)))
7612 (defun gnus-summary-display-article (article &optional all-header)
7613 "Display ARTICLE in article buffer."
7614 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7615 (with-current-buffer gnus-article-buffer
7616 (eq major-mode 'gnus-article-mode)))
7617 (gnus-article-setup-buffer))
7618 (gnus-set-global-variables)
7619 (with-current-buffer gnus-article-buffer
7620 (setq gnus-article-charset gnus-newsgroup-charset)
7621 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7622 (mm-enable-multibyte))
7626 (if gnus-summary-display-article-function
7627 (funcall gnus-summary-display-article-function article all-header)
7628 (gnus-article-prepare article all-header))
7629 (gnus-run-hooks 'gnus-select-article-hook)
7630 (when (and gnus-current-article
7631 (not (zerop gnus-current-article)))
7632 (gnus-summary-goto-subject gnus-current-article))
7633 (gnus-summary-recenter)
7634 (when (and gnus-use-trees gnus-show-threads)
7635 (gnus-possibly-generate-tree article)
7636 (gnus-highlight-selected-tree article))
7637 ;; Successfully display article.
7638 (gnus-article-set-window-start
7639 (cdr (assq article gnus-newsgroup-bookmarks))))))
7641 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7642 "Select the current article.
7643 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7644 non-nil, the article will be re-fetched even if it already present in
7645 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7647 ;; Make sure we are in the summary buffer to work around bbdb bug.
7648 (unless (eq major-mode 'gnus-summary-mode)
7649 (set-buffer gnus-summary-buffer))
7650 (let ((article (or article (gnus-summary-article-number)))
7651 (all-headers (not (not all-headers))) ;Must be t or nil.
7652 gnus-summary-display-article-function)
7654 (gnus-summary-article-pseudo-p article)
7655 (error "This is a pseudo-article"))
7656 (with-current-buffer gnus-summary-buffer
7657 (if (or (and gnus-single-article-buffer
7658 (or (null gnus-current-article)
7659 (null gnus-article-current)
7660 (null (get-buffer gnus-article-buffer))
7661 (not (eq article (cdr gnus-article-current)))
7662 (not (equal (car gnus-article-current)
7663 gnus-newsgroup-name))
7664 (not (get-buffer gnus-original-article-buffer))))
7665 (and (not gnus-single-article-buffer)
7666 (or (null gnus-current-article)
7667 (not (get-buffer gnus-original-article-buffer))
7668 (not (eq gnus-current-article article))))
7670 ;; The requested article is different from the current article.
7672 (gnus-summary-display-article article all-headers)
7673 (when (gnus-buffer-live-p gnus-article-buffer)
7674 (with-current-buffer gnus-article-buffer
7675 (if (not gnus-article-decoded-p) ;; a local variable
7676 (mm-disable-multibyte))))
7677 (gnus-article-set-window-start
7678 (cdr (assq article gnus-newsgroup-bookmarks)))
7682 (defun gnus-summary-force-verify-and-decrypt ()
7683 "Display buttons for signed/encrypted parts and verify/decrypt them."
7685 (let ((mm-verify-option 'known)
7686 (mm-decrypt-option 'known)
7687 (gnus-article-emulate-mime t)
7688 (gnus-buttonized-mime-types (append (list "multipart/signed"
7689 "multipart/encrypted")
7690 gnus-buttonized-mime-types)))
7691 (gnus-summary-select-article nil 'force)))
7693 (defun gnus-summary-set-current-mark (&optional current-mark)
7694 "Obsolete function."
7697 (defun gnus-summary-next-article (&optional unread subject backward push)
7698 "Select the next article.
7699 If UNREAD, only unread articles are selected.
7700 If SUBJECT, only articles with SUBJECT are selected.
7701 If BACKWARD, the previous article is selected instead of the next."
7703 ;; Make sure we are in the summary buffer.
7704 (unless (eq major-mode 'gnus-summary-mode)
7705 (set-buffer gnus-summary-buffer))
7707 ;; Is there such an article?
7708 ((and (gnus-summary-search-forward unread subject backward)
7709 (or (gnus-summary-display-article (gnus-summary-article-number))
7710 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7711 (gnus-summary-position-point))
7712 ;; If not, we try the first unread, if that is wanted.
7714 gnus-auto-select-same
7715 (gnus-summary-first-unread-article))
7716 (gnus-summary-position-point)
7717 (gnus-message 6 "Wrapped"))
7718 ;; Try to get next/previous article not displayed in this group.
7719 ((and gnus-auto-extend-newsgroup
7720 (not unread) (not subject))
7721 (gnus-summary-goto-article
7722 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7723 nil (count-lines (point-min) (point))))
7724 ;; Go to next/previous group.
7726 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7727 (gnus-summary-jump-to-group gnus-newsgroup-name))
7728 (let ((cmd (if (featurep 'xemacs)
7730 last-command-event))
7732 (with-current-buffer gnus-group-buffer
7735 (if (eq gnus-keep-same-level 'best)
7736 (gnus-summary-best-group gnus-newsgroup-name)
7737 (gnus-summary-search-group backward gnus-keep-same-level))))
7738 ;; Select next unread newsgroup automagically.
7740 ((or (not gnus-auto-select-next)
7742 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7743 ((or (eq gnus-auto-select-next 'quietly)
7744 (and (eq gnus-auto-select-next 'slightly-quietly)
7746 (and (eq gnus-auto-select-next 'almost-quietly)
7747 (gnus-summary-last-article-p)))
7749 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7751 (gnus-message 7 "No more%s articles (%s)..."
7752 (if unread " unread" "")
7753 (if group (concat "selecting " group)
7755 (gnus-summary-next-group nil group backward)))
7757 (when (gnus-key-press-event-p last-input-event)
7758 (gnus-summary-walk-group-buffer
7759 gnus-newsgroup-name cmd unread backward point))))))))
7761 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7762 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7763 (?\C-p (gnus-group-prev-unread-group 1))))
7764 (cursor-in-echo-area t)
7765 keve key group ended prompt)
7766 (with-current-buffer gnus-group-buffer
7769 (if (eq gnus-keep-same-level 'best)
7770 (gnus-summary-best-group gnus-newsgroup-name)
7771 (gnus-summary-search-group backward gnus-keep-same-level))))
7775 "No more%s articles%s " (if unread " unread" "")
7777 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7778 (format " (Type %s for %s [%s])"
7779 (single-key-description cmd)
7780 (gnus-group-decoded-name group)
7781 (gnus-group-unread group))
7782 (format " (Type %s to exit %s)"
7783 (single-key-description cmd)
7784 (gnus-group-decoded-name gnus-newsgroup-name)))))
7785 ;; Confirm auto selection.
7786 (setq key (car (setq keve (gnus-read-event-char prompt)))
7789 ((assq key keystrokes)
7790 (let ((obuf (current-buffer)))
7791 (switch-to-buffer gnus-group-buffer)
7793 (gnus-group-jump-to-group group))
7794 (eval (cadr (assq key keystrokes)))
7795 (setq group (gnus-group-group-name))
7796 (switch-to-buffer obuf))
7800 (gnus-ephemeral-group-p gnus-newsgroup-name))
7802 (gnus-summary-next-group nil group backward)))
7804 (push (cdr keve) unread-command-events))))))
7806 (defun gnus-summary-next-unread-article ()
7807 "Select unread article after current one."
7809 (gnus-summary-next-article
7810 (or (not (eq gnus-summary-goto-unread 'never))
7811 (gnus-summary-last-article-p (gnus-summary-article-number)))
7812 (and gnus-auto-select-same
7813 (gnus-summary-article-subject))))
7815 (defun gnus-summary-prev-article (&optional unread subject)
7816 "Select the article before the current one.
7817 If UNREAD is non-nil, only unread articles are selected."
7819 (gnus-summary-next-article unread subject t))
7821 (defun gnus-summary-prev-unread-article ()
7822 "Select unread article before current one."
7824 (gnus-summary-prev-article
7825 (or (not (eq gnus-summary-goto-unread 'never))
7826 (gnus-summary-first-article-p (gnus-summary-article-number)))
7827 (and gnus-auto-select-same
7828 (gnus-summary-article-subject))))
7830 (defun gnus-summary-next-page (&optional lines circular stop)
7831 "Show next page of the selected article.
7832 If at the end of the current article, select the next article.
7833 LINES says how many lines should be scrolled up.
7835 If CIRCULAR is non-nil, go to the start of the article instead of
7836 selecting the next article when reaching the end of the current
7839 If STOP is non-nil, just stop when reaching the end of the message.
7841 Also see the variable `gnus-article-skip-boring'."
7843 (setq gnus-summary-buffer (current-buffer))
7844 (gnus-set-global-variables)
7845 (let ((article (gnus-summary-article-number))
7846 (article-window (get-buffer-window gnus-article-buffer t))
7848 ;; If the buffer is empty, we have no article.
7850 (error "No article to select"))
7851 (gnus-configure-windows 'article)
7852 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7853 (if (and (eq gnus-summary-goto-unread 'never)
7854 (not (gnus-summary-last-article-p article)))
7855 (gnus-summary-next-article)
7856 (gnus-summary-next-unread-article))
7857 (if (or (null gnus-current-article)
7858 (null gnus-article-current)
7859 (/= article (cdr gnus-article-current))
7860 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7861 ;; Selected subject is different from current article's.
7862 (gnus-summary-display-article article)
7863 (when article-window
7864 (gnus-eval-in-buffer-window gnus-article-buffer
7865 (setq endp (or (gnus-article-next-page lines)
7866 (gnus-article-only-boring-p))))
7868 (cond ((or stop gnus-summary-stop-at-end-of-message)
7869 (gnus-message 3 "End of message"))
7871 (gnus-summary-beginning-of-article))
7873 (gnus-message 3 "End of message"))
7875 (if (and (eq gnus-summary-goto-unread 'never)
7876 (not (gnus-summary-last-article-p article)))
7877 (gnus-summary-next-article)
7878 (gnus-summary-next-unread-article))))))))
7879 (gnus-summary-recenter)
7880 (gnus-summary-position-point)))
7882 (defun gnus-summary-prev-page (&optional lines move)
7883 "Show previous page of selected article.
7884 Argument LINES specifies lines to be scrolled down.
7885 If MOVE, move to the previous unread article if point is at
7886 the beginning of the buffer."
7888 (let ((article (gnus-summary-article-number))
7889 (article-window (get-buffer-window gnus-article-buffer t))
7891 (gnus-configure-windows 'article)
7892 (if (or (null gnus-current-article)
7893 (null gnus-article-current)
7894 (/= article (cdr gnus-article-current))
7895 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7896 ;; Selected subject is different from current article's.
7897 (gnus-summary-display-article article)
7898 (gnus-summary-recenter)
7899 (when article-window
7900 (gnus-eval-in-buffer-window gnus-article-buffer
7901 (setq endp (gnus-article-prev-page lines)))
7902 (when (and move endp)
7904 (gnus-message 3 "Beginning of message"))
7906 (if (and (eq gnus-summary-goto-unread 'never)
7907 (not (gnus-summary-first-article-p article)))
7908 (gnus-summary-prev-article)
7909 (gnus-summary-prev-unread-article))))))))
7910 (gnus-summary-position-point))
7912 (defun gnus-summary-prev-page-or-article (&optional lines)
7913 "Show previous page of selected article.
7914 Argument LINES specifies lines to be scrolled down.
7915 If at the beginning of the article, go to the next article."
7917 (gnus-summary-prev-page lines t))
7919 (defun gnus-summary-scroll-up (lines)
7920 "Scroll up (or down) one line current article.
7921 Argument LINES specifies lines to be scrolled up (or down if negative).
7922 If no article is selected, then the current article will be selected first."
7924 (gnus-configure-windows 'article)
7925 (gnus-summary-show-thread)
7926 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7927 (gnus-eval-in-buffer-window gnus-article-buffer
7929 (when (gnus-article-next-page lines)
7930 (gnus-message 3 "End of message")))
7932 (gnus-article-prev-page (- lines))))))
7933 (gnus-summary-recenter)
7934 (gnus-summary-position-point))
7936 (defun gnus-summary-scroll-down (lines)
7937 "Scroll down (or up) one line current article.
7938 Argument LINES specifies lines to be scrolled down (or up if negative).
7939 If no article is selected, then the current article will be selected first."
7941 (gnus-summary-scroll-up (- lines)))
7943 (defun gnus-summary-next-same-subject ()
7944 "Select next article which has the same subject as current one."
7946 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7948 (defun gnus-summary-prev-same-subject ()
7949 "Select previous article which has the same subject as current one."
7951 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7953 (defun gnus-summary-next-unread-same-subject ()
7954 "Select next unread article which has the same subject as current one."
7956 (gnus-summary-next-article t (gnus-summary-article-subject)))
7958 (defun gnus-summary-prev-unread-same-subject ()
7959 "Select previous unread article which has the same subject as current one."
7961 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7963 (defun gnus-summary-first-unread-article ()
7964 "Select the first unread article.
7965 Return nil if there are no unread articles."
7968 (when (gnus-summary-first-subject t)
7969 (gnus-summary-show-thread)
7970 (gnus-summary-first-subject t)
7971 (gnus-summary-display-article (gnus-summary-article-number)))
7972 (gnus-summary-position-point)))
7974 (defun gnus-summary-first-unread-subject ()
7975 "Place the point on the subject line of the first unread article.
7976 Return nil if there are no unread articles."
7979 (when (gnus-summary-first-subject t)
7980 (gnus-summary-show-thread)
7981 (gnus-summary-first-subject t))
7982 (gnus-summary-position-point)))
7984 (defun gnus-summary-first-unseen-subject ()
7985 "Place the point on the subject line of the first unseen article.
7986 Return nil if there are no unseen articles."
7989 (when (gnus-summary-first-subject nil nil t)
7990 (gnus-summary-show-thread)
7991 (gnus-summary-first-subject nil nil t))
7992 (gnus-summary-position-point)))
7994 (defun gnus-summary-first-unseen-or-unread-subject ()
7995 "Place the point on the subject line of the first unseen and unread article.
7996 If all article have been seen, on the subject line of the first unread
8000 (unless (when (gnus-summary-first-subject nil nil t)
8001 (gnus-summary-show-thread)
8002 (gnus-summary-first-subject nil nil t))
8003 (when (gnus-summary-first-subject t)
8004 (gnus-summary-show-thread)
8005 (gnus-summary-first-subject t)))
8006 (gnus-summary-position-point)))
8008 (defun gnus-summary-first-article ()
8009 "Select the first article.
8010 Return nil if there are no articles."
8013 (when (gnus-summary-first-subject)
8014 (gnus-summary-show-thread)
8015 (gnus-summary-first-subject)
8016 (gnus-summary-display-article (gnus-summary-article-number)))
8017 (gnus-summary-position-point)))
8019 (defun gnus-summary-best-unread-article (&optional arg)
8020 "Select the unread article with the highest score.
8021 If given a prefix argument, select the next unread article that has a
8022 score higher than the default score."
8024 (let ((article (if arg
8025 (gnus-summary-better-unread-subject)
8026 (gnus-summary-best-unread-subject))))
8028 (gnus-summary-goto-article article)
8029 (error "No unread articles"))))
8031 (defun gnus-summary-best-unread-subject ()
8032 "Select the unread subject with the highest score."
8034 (let ((best -1000000)
8035 (data gnus-newsgroup-data)
8038 (and (gnus-data-unread-p (car data))
8040 (gnus-summary-article-score (gnus-data-number (car data))))
8043 article (gnus-data-number (car data))))
8044 (setq data (cdr data)))
8046 (gnus-summary-goto-subject article))
8047 (gnus-summary-position-point)
8050 (defun gnus-summary-better-unread-subject ()
8051 "Select the first unread subject that has a score over the default score."
8053 (let ((data gnus-newsgroup-data)
8055 (while (and (setq article (gnus-data-number (car data)))
8056 (or (gnus-data-read-p (car data))
8057 (not (> (gnus-summary-article-score article)
8058 gnus-summary-default-score))))
8059 (setq data (cdr data)))
8061 (gnus-summary-goto-subject article))
8062 (gnus-summary-position-point)
8065 (defun gnus-summary-last-subject ()
8066 "Go to the last displayed subject line in the group."
8067 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8069 (gnus-summary-goto-subject article))))
8071 (defun gnus-summary-goto-article (article &optional all-headers force)
8072 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8073 If ALL-HEADERS is non-nil, no header lines are hidden.
8074 If FORCE, go to the article even if it isn't displayed. If FORCE
8075 is a number, it is the line the article is to be displayed on."
8078 (gnus-completing-read
8079 "Article number or Message-ID"
8080 (mapcar 'int-to-string gnus-newsgroup-limit))
8084 (if (and (stringp article)
8085 (string-match "@\\|%40" article))
8086 (gnus-summary-refer-article article)
8087 (when (stringp article)
8088 (setq article (string-to-number article)))
8089 (if (gnus-summary-goto-subject article force)
8090 (gnus-summary-display-article article all-headers)
8091 (gnus-message 4 "Couldn't go to article %s" article) nil))
8092 (gnus-summary-position-point)))
8094 (defun gnus-summary-goto-last-article ()
8095 "Go to the previously read article."
8098 (when gnus-last-article
8099 (gnus-summary-goto-article gnus-last-article nil t))
8100 (gnus-summary-position-point)))
8102 (defun gnus-summary-pop-article (number)
8103 "Pop one article off the history and go to the previous.
8104 NUMBER articles will be popped off."
8107 (setq gnus-newsgroup-history
8108 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8110 (gnus-summary-goto-article (car to) nil t)
8111 (error "Article history empty")))
8112 (gnus-summary-position-point))
8114 ;; Summary commands and functions for limiting the summary buffer.
8116 (defun gnus-summary-limit-to-articles (n)
8117 "Limit the summary buffer to the next N articles.
8118 If not given a prefix, use the process marked articles instead."
8121 (let ((articles (gnus-summary-work-articles n)))
8122 (setq gnus-newsgroup-processable nil)
8123 (gnus-summary-limit articles))
8124 (gnus-summary-position-point)))
8126 (defun gnus-summary-pop-limit (&optional total)
8127 "Restore the previous limit.
8128 If given a prefix, remove all limits."
8131 (setq gnus-newsgroup-limits
8132 (list (mapcar (lambda (h) (mail-header-number h))
8133 gnus-newsgroup-headers))))
8134 (unless gnus-newsgroup-limits
8135 (error "No limit to pop"))
8137 (gnus-summary-limit nil 'pop)
8138 (gnus-summary-position-point)))
8140 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8141 "Limit the summary buffer to articles that have subjects that match a regexp.
8142 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8144 (list (read-string (if current-prefix-arg
8145 "Exclude subject (regexp): "
8146 "Limit to subject (regexp): "))
8147 nil current-prefix-arg))
8149 (setq header "subject"))
8150 (when (not (equal "" subject))
8152 (let ((articles (gnus-summary-find-matching
8153 (or header "subject") subject 'all nil nil
8156 (error "Found no matches for \"%s\"" subject))
8157 (gnus-summary-limit articles))
8158 (gnus-summary-position-point))))
8160 (defun gnus-summary-limit-to-author (from &optional not-matching)
8161 "Limit the summary buffer to articles that have authors that match a regexp.
8162 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8164 (list (read-string (if current-prefix-arg
8165 "Exclude author (regexp): "
8166 "Limit to author (regexp): "))
8167 current-prefix-arg))
8168 (gnus-summary-limit-to-subject from "from" not-matching))
8170 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8171 "Limit the summary buffer to articles with the given RECIPIENT.
8173 If NOT-MATCHING, exclude RECIPIENT.
8175 To and Cc headers are checked. You need to include them in
8176 `nnmail-extra-headers'."
8177 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8179 (list (read-string (format "%s recipient (regexp): "
8180 (if current-prefix-arg "Exclude" "Limit to")))
8181 current-prefix-arg))
8182 (when (not (equal "" recipient))
8184 (if (memq 'To nnmail-extra-headers)
8185 (gnus-summary-find-matching
8186 (cons 'extra 'To) recipient 'all nil nil
8189 1 "`To' isn't present in `nnmail-extra-headers'")
8193 (if (memq 'Cc nnmail-extra-headers)
8194 (gnus-summary-find-matching
8195 (cons 'extra 'Cc) recipient 'all nil nil
8198 1 "`Cc' isn't present in `nnmail-extra-headers'")
8203 ;; We need the numbers that are in both lists:
8205 (and (memq a to) a))
8209 (error "Found no matches for \"%s\"" recipient))
8210 (gnus-summary-limit articles))
8211 (gnus-summary-position-point))))
8213 (defun gnus-summary-limit-to-address (address &optional not-matching)
8214 "Limit the summary buffer to articles with the given ADDRESS.
8216 If NOT-MATCHING, exclude ADDRESS.
8218 To, Cc and From headers are checked. You need to include `To' and `Cc'
8219 in `nnmail-extra-headers'."
8221 (list (read-string (format "%s address (regexp): "
8222 (if current-prefix-arg "Exclude" "Limit to")))
8223 current-prefix-arg))
8224 (when (not (equal "" address))
8226 (if (memq 'To nnmail-extra-headers)
8227 (gnus-summary-find-matching
8228 (cons 'extra 'To) address 'all nil nil
8231 1 "`To' isn't present in `nnmail-extra-headers'")
8235 (if (memq 'Cc nnmail-extra-headers)
8236 (gnus-summary-find-matching
8237 (cons 'extra 'Cc) address 'all nil nil
8240 1 "`Cc' isn't present in `nnmail-extra-headers'")
8244 (gnus-summary-find-matching "from" address
8245 'all nil nil not-matching))
8248 ;; We need the numbers that are in all lists:
8252 (mapcar (lambda (a) (car (memq a from))) to))
8254 (mapcar (lambda (a) (car (memq a from))) cc)
8255 (mapcar (lambda (a) (car (memq a from)))
8256 (mapcar (lambda (a) (car (memq a to)))
8258 (nconc (if (eq to t) nil to)
8259 (if (eq cc t) nil cc)
8262 (error "Found no matches for \"%s\"" address))
8263 (gnus-summary-limit articles))
8264 (gnus-summary-position-point))))
8266 (defun gnus-summary-limit-strange-charsets-predicate (header)
8267 (when (fboundp 'char-charset)
8268 (let ((string (concat (mail-header-subject header)
8269 (mail-header-from header)))
8271 (dotimes (i (1- (length string)))
8272 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8273 (when (string-match "unicode\\|big\\|japanese" charset)
8277 (defun gnus-summary-limit-to-predicate (predicate)
8278 "Limit to articles where PREDICATE returns non-nil.
8279 PREDICATE will be called with the header structures of the
8281 (let ((articles nil)
8282 (case-fold-search t))
8283 (dolist (header gnus-newsgroup-headers)
8284 (when (funcall predicate header)
8285 (push (mail-header-number header) articles)))
8286 (gnus-summary-limit (nreverse articles))))
8288 (defun gnus-summary-limit-to-age (age &optional younger-p)
8289 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8290 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8291 articles that are younger than AGE days."
8293 (let ((younger current-prefix-arg)
8296 (while (not days-got)
8297 (setq days (if younger
8298 (read-string "Limit to articles younger than (in days, older when negative): ")
8300 "Limit to articles older than (in days, younger when negative): ")))
8301 (when (> (length days) 0)
8302 (setq days (read days)))
8307 (setq younger (not younger))
8308 (setq days (* days -1))))
8309 (message "Please enter a number.")
8311 (list days younger)))
8313 (let ((data gnus-newsgroup-data)
8314 (cutoff (days-to-time age))
8315 articles d date is-younger)
8316 (while (setq d (pop data))
8317 (when (and (vectorp (gnus-data-header d))
8318 (setq date (mail-header-date (gnus-data-header d))))
8319 (setq is-younger (time-less-p
8320 (time-since (gnus-date-get-time date))
8325 (push (gnus-data-number d) articles))))
8326 (gnus-summary-limit (nreverse articles)))
8327 (gnus-summary-position-point)))
8329 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8330 "Limit the summary buffer to articles that match an 'extra' header."
8334 (gnus-completing-read
8335 (if current-prefix-arg
8336 "Exclude extra header"
8337 "Limit extra header")
8338 (mapcar 'symbol-name gnus-extra-headers)
8340 (symbol-name (car gnus-extra-headers))))))
8342 (read-string (format "%s header %s (regexp): "
8343 (if current-prefix-arg "Exclude" "Limit to")
8345 current-prefix-arg)))
8346 (when (not (equal "" regexp))
8348 (let ((articles (gnus-summary-find-matching
8349 (cons 'extra header) regexp 'all nil nil
8352 (error "Found no matches for \"%s\"" regexp))
8353 (gnus-summary-limit articles))
8354 (gnus-summary-position-point))))
8356 (defun gnus-summary-limit-to-display-predicate ()
8357 "Limit the summary buffer to the predicated in the `display' group parameter."
8359 (unless gnus-newsgroup-display
8360 (error "There is no `display' group parameter"))
8362 (dolist (gnus-number gnus-newsgroup-articles)
8363 (when (funcall gnus-newsgroup-display)
8364 (push gnus-number articles)))
8365 (gnus-summary-limit articles))
8366 (gnus-summary-position-point))
8368 (defun gnus-summary-limit-to-unread (&optional all)
8369 "Limit the summary buffer to articles that are not marked as read.
8370 If ALL is non-nil, limit strictly to unread articles."
8373 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8374 (gnus-summary-limit-to-marks
8375 ;; Concat all the marks that say that an article is read and have
8377 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8378 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8379 gnus-low-score-mark gnus-expirable-mark
8380 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8381 gnus-duplicate-mark)
8384 (defun gnus-summary-limit-to-headers (match &optional reverse)
8385 "Limit the summary buffer to articles that have headers that match MATCH.
8386 If REVERSE (the prefix), limit to articles that don't match."
8387 (interactive "sMatch headers (regexp): \nP")
8388 (gnus-summary-limit-to-bodies match reverse t))
8390 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8391 "Limit the summary buffer to articles that have bodies that match MATCH.
8392 If REVERSE (the prefix), limit to articles that don't match."
8393 (interactive "sMatch body (regexp): \nP")
8394 (let ((articles nil)
8395 (gnus-select-article-hook nil) ;Disable hook.
8396 (gnus-article-prepare-hook nil)
8397 (gnus-use-article-prefetch nil)
8398 (gnus-keep-backlog nil)
8399 (gnus-break-pages nil)
8400 (gnus-summary-display-arrow nil)
8401 (gnus-updated-mode-lines nil)
8402 (gnus-auto-center-summary nil)
8403 (gnus-display-mime-function nil))
8404 (dolist (data gnus-newsgroup-data)
8405 (let (gnus-mark-article-hook)
8406 (gnus-summary-select-article t t nil (gnus-data-number data)))
8407 (with-current-buffer gnus-article-buffer
8409 (let* ((case-fold-search t)
8411 (re-search-backward match nil t)
8412 (re-search-forward match nil t))))
8413 (when (or (and found
8417 (push (gnus-data-number data) articles)))))
8419 (message "No messages matched")
8420 (gnus-summary-limit articles)))
8421 (gnus-summary-position-point))
8423 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8424 "Limit the summary buffer to articles that aren't part on any thread.
8425 If THREADSP (the prefix), limit to articles that are in threads."
8427 (let ((articles nil)
8430 (dolist (thread gnus-newsgroup-threads)
8431 (if (stringp (car thread))
8432 (dolist (thread (cdr thread))
8433 (push thread threads))
8434 (push thread threads)))
8435 (dolist (thread threads)
8436 (setq thread-articles (gnus-articles-in-thread thread))
8437 (when (or (and threadsp
8438 (> (length thread-articles) 1))
8440 (= (length thread-articles) 1)))
8441 (setq articles (nconc thread-articles articles))))
8443 (message "No messages matched")
8444 (gnus-summary-limit articles))
8445 (gnus-summary-position-point)))
8447 (defun gnus-summary-limit-to-replied (&optional unreplied)
8448 "Limit the summary buffer to replied articles.
8449 If UNREPLIED (the prefix), limit to unreplied articles."
8453 (gnus-set-difference gnus-newsgroup-articles
8454 gnus-newsgroup-replied))
8455 (gnus-summary-limit gnus-newsgroup-replied))
8456 (gnus-summary-position-point))
8458 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8459 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8460 If REVERSE, limit the summary buffer to articles that are marked
8461 with MARKS. MARKS can either be a string of marks or a list of marks.
8462 Returns how many articles were removed."
8463 (interactive "sMarks: ")
8464 (gnus-summary-limit-to-marks marks t))
8466 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8467 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8468 If REVERSE (the prefix), limit the summary buffer to articles that are
8469 not marked with MARKS. MARKS can either be a string of marks or a
8471 Returns how many articles were removed."
8472 (interactive "sMarks: \nP")
8474 (let ((data gnus-newsgroup-data)
8475 (marks (if (listp marks) marks
8476 (append marks nil))) ; Transform to list.
8479 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8480 (memq (gnus-data-mark (car data)) marks))
8481 (push (gnus-data-number (car data)) articles))
8482 (setq data (cdr data)))
8483 (gnus-summary-limit articles))
8484 (gnus-summary-position-point)))
8486 (defun gnus-summary-limit-to-score (score)
8487 "Limit to articles with score at or above SCORE."
8488 (interactive "NLimit to articles with score of at least: ")
8489 (let ((data gnus-newsgroup-data)
8492 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8494 (push (gnus-data-number (car data)) articles))
8495 (setq data (cdr data)))
8497 (gnus-summary-limit articles)
8498 (gnus-summary-position-point))))
8500 (defun gnus-summary-limit-to-unseen ()
8501 "Limit to unseen articles."
8504 (gnus-summary-limit gnus-newsgroup-unseen)
8505 (gnus-summary-position-point)))
8507 (defun gnus-summary-limit-include-thread (id)
8508 "Display all the hidden articles that is in the thread with ID in it.
8509 When called interactively, ID is the Message-ID of the current
8511 (interactive (list (mail-header-id (gnus-summary-article-header))))
8512 (let ((articles (gnus-articles-in-thread
8513 (gnus-id-to-thread (gnus-root-id id))))
8514 ;;we REALLY want the whole thread---this prevents cut-threads
8515 ;;from removing the thread we want to include.
8516 (gnus-fetch-old-headers nil)
8517 (gnus-build-sparse-threads nil))
8519 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8520 (gnus-summary-limit-include-matching-articles
8522 (regexp-quote (gnus-simplify-subject-re
8523 (mail-header-subject (gnus-id-to-header id)))))
8524 (gnus-summary-position-point))))
8526 (defun gnus-summary-limit-include-matching-articles (header regexp)
8527 "Display all the hidden articles that have HEADERs that match REGEXP."
8528 (interactive (list (read-string "Match on header: ")
8529 (read-string "Regexp: ")))
8530 (let ((articles (gnus-find-matching-articles header regexp)))
8532 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8533 (gnus-summary-position-point))))
8535 (defun gnus-summary-insert-dormant-articles ()
8536 "Insert all the dormant articles for this group into the current buffer."
8538 (let ((gnus-verbose (max 6 gnus-verbose)))
8539 (if (not gnus-newsgroup-dormant)
8540 (gnus-message 3 "No dormant articles for this group")
8541 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8543 (defun gnus-summary-insert-ticked-articles ()
8544 "Insert ticked articles for this group into the current buffer."
8546 (let ((gnus-verbose (max 6 gnus-verbose)))
8547 (if (not gnus-newsgroup-marked)
8548 (gnus-message 3 "No ticked articles for this group")
8549 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8551 (defun gnus-summary-limit-include-dormant ()
8552 "Display all the hidden articles that are marked as dormant.
8553 Note that this command only works on a subset of the articles currently
8554 fetched for this group."
8556 (unless gnus-newsgroup-dormant
8557 (error "There are no dormant articles in this group"))
8559 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8560 (gnus-summary-position-point)))
8562 (defun gnus-summary-include-articles (articles)
8563 "Fetch the headers for ARTICLES and then display the summary lines."
8564 (let ((gnus-inhibit-demon t)
8566 (gnus-read-all-available-headers t))
8567 (setq gnus-newsgroup-headers
8569 'list gnus-newsgroup-headers
8570 (gnus-fetch-headers articles nil t)
8571 'gnus-article-sort-by-number))
8572 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8574 (defun gnus-summary-limit-exclude-dormant ()
8575 "Hide all dormant articles."
8578 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8579 (gnus-summary-position-point)))
8581 (defun gnus-summary-limit-exclude-childless-dormant ()
8582 "Hide all dormant articles that have no children."
8584 (let ((data (gnus-data-list t))
8585 articles d children)
8586 ;; Find all articles that are either not dormant or have
8588 (while (setq d (pop data))
8589 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8591 (gnus-article-children (gnus-data-number d)))
8594 (when (memq (car children) articles)
8599 (push (gnus-data-number d) articles)))
8602 (gnus-summary-limit articles)
8603 (gnus-summary-position-point))))
8605 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8606 "Mark all unread excluded articles as read.
8607 If ALL, mark even excluded ticked and dormants as read."
8609 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8610 (let ((articles (gnus-sorted-ndifference
8612 (mapcar (lambda (h) (mail-header-number h))
8613 gnus-newsgroup-headers)
8615 gnus-newsgroup-limit))
8617 (setq gnus-newsgroup-unreads
8618 (gnus-sorted-intersection gnus-newsgroup-unreads
8619 gnus-newsgroup-limit))
8621 (setq gnus-newsgroup-dormant nil
8622 gnus-newsgroup-marked nil
8623 gnus-newsgroup-reads
8625 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8626 gnus-newsgroup-reads))
8627 (while (setq article (pop articles))
8628 (unless (or (memq article gnus-newsgroup-dormant)
8629 (memq article gnus-newsgroup-marked))
8630 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8632 (defun gnus-summary-limit (articles &optional pop)
8634 ;; We pop the previous limit off the stack and use that.
8635 (setq articles (car gnus-newsgroup-limits)
8636 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8637 ;; We use the new limit, so we push the old limit on the stack.
8638 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8640 (setq gnus-newsgroup-limit articles)
8641 (let ((total (length gnus-newsgroup-data))
8642 (data (gnus-data-find-list (gnus-summary-article-number)))
8643 (gnus-summary-mark-below nil) ; Inhibit this.
8645 ;; This will do all the work of generating the new summary buffer
8646 ;; according to the new limit.
8647 (gnus-summary-prepare)
8648 ;; Hide any threads, possibly.
8649 (gnus-summary-maybe-hide-threads)
8650 ;; Try to return to the article you were at, or one in the
8653 ;; We try to find some article after the current one.
8655 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8658 (setq data (cdr data))))
8660 ;; If there is no data, that means that we were after the last
8661 ;; article. The same goes when we can't find any articles
8662 ;; after the current one.
8663 (goto-char (point-max))
8664 (gnus-summary-find-prev))
8665 (gnus-set-mode-line 'summary)
8666 ;; We return how many articles were removed from the summary
8667 ;; buffer as a result of the new limit.
8668 (- total (length gnus-newsgroup-data))))
8670 (defsubst gnus-invisible-cut-children (threads)
8673 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8678 (defsubst gnus-cut-thread (thread)
8679 "Go forwards in the thread until we find an article that we want to display."
8680 (when (or (eq gnus-fetch-old-headers 'some)
8681 (eq gnus-fetch-old-headers 'invisible)
8682 (numberp gnus-fetch-old-headers)
8683 (eq gnus-build-sparse-threads 'some)
8684 (eq gnus-build-sparse-threads 'more))
8685 ;; Deal with old-fetched headers and sparse threads.
8689 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8690 (gnus-summary-article-ancient-p
8691 (mail-header-number (car thread))))
8692 (if (or (<= (length (cdr thread)) 1)
8693 (eq gnus-fetch-old-headers 'invisible))
8694 (setq gnus-newsgroup-limit
8695 (delq (mail-header-number (car thread))
8696 gnus-newsgroup-limit)
8697 thread (cadr thread))
8698 (when (gnus-invisible-cut-children (cdr thread))
8699 (let ((th (cdr thread)))
8701 (if (memq (mail-header-number (caar th))
8702 gnus-newsgroup-limit)
8703 (setq thread (car th)
8705 (setq th (cdr th))))))))))
8708 (defun gnus-cut-threads (threads)
8709 "Cut off all uninteresting articles from the beginning of THREADS."
8710 (when (or (eq gnus-fetch-old-headers 'some)
8711 (eq gnus-fetch-old-headers 'invisible)
8712 (numberp gnus-fetch-old-headers)
8713 (eq gnus-build-sparse-threads 'some)
8714 (eq gnus-build-sparse-threads 'more))
8717 (setcar th (gnus-cut-thread (car th)))
8718 (setq th (cdr th)))))
8719 ;; Remove nixed out threads.
8722 (defun gnus-summary-initial-limit (&optional show-if-empty)
8723 "Figure out what the initial limit is supposed to be on group entry.
8724 This entails weeding out unwanted dormants, low-scored articles,
8725 fetch-old-headers verbiage, and so on."
8726 ;; Most groups have nothing to remove.
8727 (unless (or gnus-inhibit-limiting
8728 (and (null gnus-newsgroup-dormant)
8729 (eq gnus-newsgroup-display 'gnus-not-ignore)
8730 (not (eq gnus-fetch-old-headers 'some))
8731 (not (numberp gnus-fetch-old-headers))
8732 (not (eq gnus-fetch-old-headers 'invisible))
8733 (null gnus-summary-expunge-below)
8734 (not (eq gnus-build-sparse-threads 'some))
8735 (not (eq gnus-build-sparse-threads 'more))
8736 (null gnus-thread-expunge-below)))
8737 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8738 (setq gnus-newsgroup-limit nil)
8741 (unless (car (symbol-value node))
8742 ;; These threads have no parents -- they are roots.
8743 (let ((nodes (cdr (symbol-value node)))
8746 (if (and gnus-thread-expunge-below
8747 (< (gnus-thread-total-score (car nodes))
8748 gnus-thread-expunge-below))
8749 (gnus-expunge-thread (pop nodes))
8750 (setq thread (pop nodes))
8751 (gnus-summary-limit-children thread))))))
8752 gnus-newsgroup-dependencies)
8753 ;; If this limitation resulted in an empty group, we might
8754 ;; pop the previous limit and use it instead.
8755 (when (and (not gnus-newsgroup-limit)
8757 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8758 gnus-newsgroup-limit))
8760 (defun gnus-summary-limit-children (thread)
8761 "Return 1 if this subthread is visible and 0 if it is not."
8762 ;; First we get the number of visible children to this thread. This
8763 ;; is done by recursing down the thread using this function, so this
8764 ;; will really go down to a leaf article first, before slowly
8765 ;; working its way up towards the root.
8767 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8770 (apply '+ (mapcar 'gnus-summary-limit-children
8773 (number (mail-header-number (car thread)))
8776 (not (memq number gnus-newsgroup-marked))
8778 ;; If this article is dormant and has absolutely no visible
8779 ;; children, then this article isn't visible.
8780 (and (memq number gnus-newsgroup-dormant)
8782 ;; If this is "fetch-old-headered" and there is no
8783 ;; visible children, then we don't want this article.
8784 (and (or (eq gnus-fetch-old-headers 'some)
8785 (numberp gnus-fetch-old-headers))
8786 (gnus-summary-article-ancient-p number)
8788 ;; If this is "fetch-old-headered" and `invisible', then
8789 ;; we don't want this article.
8790 (and (eq gnus-fetch-old-headers 'invisible)
8791 (gnus-summary-article-ancient-p number))
8792 ;; If this is a sparsely inserted article with no children,
8793 ;; we don't want it.
8794 (and (eq gnus-build-sparse-threads 'some)
8795 (gnus-summary-article-sparse-p number)
8797 ;; If we use expunging, and this article is really
8798 ;; low-scored, then we don't want this article.
8799 (when (and gnus-summary-expunge-below
8801 (or (cdr (assq number gnus-newsgroup-scored))
8802 gnus-summary-default-score))
8803 gnus-summary-expunge-below))
8804 ;; We increase the expunge-tally here, but that has
8805 ;; nothing to do with the limits, really.
8806 (incf gnus-newsgroup-expunged-tally)
8807 ;; We also mark as read here, if that's wanted.
8808 (when (and gnus-summary-mark-below
8809 (< score gnus-summary-mark-below))
8810 (setq gnus-newsgroup-unreads
8811 (delq number gnus-newsgroup-unreads))
8812 (if gnus-newsgroup-auto-expire
8813 (push number gnus-newsgroup-expirable)
8814 (push (cons number gnus-low-score-mark)
8815 gnus-newsgroup-reads)))
8817 ;; Do the `display' group parameter.
8818 (and gnus-newsgroup-display
8819 (let ((gnus-number number))
8820 (not (funcall gnus-newsgroup-display))))))
8821 ;; Nope, invisible article.
8823 ;; Ok, this article is to be visible, so we add it to the limit
8825 (push number gnus-newsgroup-limit)
8828 (defun gnus-expunge-thread (thread)
8829 "Mark all articles in THREAD as read."
8830 (let* ((number (mail-header-number (car thread))))
8831 (incf gnus-newsgroup-expunged-tally)
8832 ;; We also mark as read here, if that's wanted.
8833 (setq gnus-newsgroup-unreads
8834 (delq number gnus-newsgroup-unreads))
8835 (if gnus-newsgroup-auto-expire
8836 (push number gnus-newsgroup-expirable)
8837 (push (cons number gnus-low-score-mark)
8838 gnus-newsgroup-reads)))
8839 ;; Go recursively through all subthreads.
8840 (mapcar 'gnus-expunge-thread (cdr thread)))
8842 ;; Summary article oriented commands
8844 (defun gnus-summary-refer-parent-article (n)
8845 "Refer parent article N times.
8846 If N is negative, go to ancestor -N instead.
8847 The difference between N and the number of articles fetched is returned."
8851 (when (not (natnump n))
8856 (setq header (gnus-summary-article-header))
8857 (if (and (eq (mail-header-number header)
8858 (cdr gnus-article-current))
8859 (equal gnus-newsgroup-name
8860 (car gnus-article-current)))
8861 ;; If we try to find the parent of the currently
8862 ;; displayed article, then we take a look at the actual
8863 ;; References header, since this is slightly more
8864 ;; reliable than the References field we got from the
8866 (with-current-buffer gnus-original-article-buffer
8867 (nnheader-narrow-to-headers)
8868 (unless (setq ref (message-fetch-field "references"))
8869 (when (setq ref (message-fetch-field "in-reply-to"))
8870 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8873 ;; It's not the current article, so we take a bet on
8874 ;; the value we got from the server.
8875 (mail-header-references header)))
8877 (not (equal ref "")))
8878 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8879 (gnus-message 1 "Couldn't find parent"))
8880 (gnus-message 1 "No references in article %d"
8881 (gnus-summary-article-number))
8884 (gnus-summary-position-point)
8887 (defun gnus-summary-refer-references ()
8888 "Fetch all articles mentioned in the References header.
8889 Return the number of articles fetched."
8891 (let ((ref (mail-header-references (gnus-summary-article-header)))
8892 (current (gnus-summary-article-number))
8896 (error "No References in the current article")
8897 ;; For each Message-ID in the References header...
8898 (while (string-match "<[^>]*>" ref)
8900 ;; ... fetch that article.
8901 (gnus-summary-refer-article
8902 (prog1 (match-string 0 ref)
8903 (setq ref (substring ref (match-end 0))))))
8904 (gnus-summary-goto-subject current)
8905 (gnus-summary-position-point)
8908 (defun gnus-summary-refer-thread (&optional limit)
8909 "Fetch all articles in the current thread.
8910 If no backend-specific 'request-thread function is available
8911 fetch LIMIT (the numerical prefix) old headers. If LIMIT is nil
8912 fetch what's specified by the `gnus-refer-thread-limit'
8915 (gnus-warp-to-article)
8916 (let* ((header (gnus-summary-article-header))
8917 (id (mail-header-id header))
8918 (gnus-inhibit-demon t)
8919 (gnus-summary-ignore-duplicates t)
8920 (gnus-read-all-available-headers t)
8921 (limit (if limit (prefix-numeric-value limit)
8922 gnus-refer-thread-limit)))
8923 (setq gnus-newsgroup-headers
8925 'list gnus-newsgroup-headers
8926 (if (gnus-check-backend-function
8927 'request-thread gnus-newsgroup-name)
8928 (gnus-request-thread header)
8929 (let* ((last (if (numberp limit)
8930 (min (+ (mail-header-number header)
8932 gnus-newsgroup-highest)
8933 gnus-newsgroup-highest))
8934 (subject (gnus-simplify-subject
8935 (mail-header-subject header)))
8936 (refs (split-string (or (mail-header-references header)
8938 (gnus-parse-headers-hook
8939 (lambda () (goto-char (point-min))
8941 (regexp-opt (append refs (list id subject)))))))
8942 (gnus-fetch-headers (list last) (if (numberp limit)
8943 (* 2 limit) limit) t)))
8944 'gnus-article-sort-by-number))
8945 (gnus-summary-limit-include-thread id)))
8947 (defun gnus-summary-refer-article (message-id)
8948 "Fetch an article specified by MESSAGE-ID."
8949 (interactive "sMessage-ID: ")
8950 (when (and (stringp message-id)
8951 (not (zerop (length message-id))))
8952 (setq message-id (gnus-replace-in-string message-id " " ""))
8953 ;; Construct the correct Message-ID if necessary.
8954 ;; Suggested by tale@pawl.rpi.edu.
8955 (unless (string-match "^<" message-id)
8956 (setq message-id (concat "<" message-id)))
8957 (unless (string-match ">$" message-id)
8958 (setq message-id (concat message-id ">")))
8959 ;; People often post MIDs from URLs, so unhex it:
8960 (unless (string-match "@" message-id)
8961 (setq message-id (gnus-url-unhex-string message-id)))
8962 (let* ((header (gnus-id-to-header message-id))
8964 (gnus-summary-article-sparse-p
8965 (mail-header-number header))
8966 (memq (mail-header-number header)
8967 gnus-newsgroup-limit)))
8970 ;; If the article is present in the buffer we just go to it.
8972 (or (not (gnus-summary-article-sparse-p
8973 (mail-header-number header)))
8976 (gnus-summary-goto-article
8977 (mail-header-number header) nil t)
8979 (gnus-summary-update-article (mail-header-number header)))))
8981 ;; We fetch the article.
8983 (dolist (gnus-override-method (gnus-refer-article-methods))
8984 (when (and (gnus-check-server gnus-override-method)
8985 ;; Fetch the header,
8986 (setq number (gnus-summary-insert-subject message-id)))
8987 ;; and display the article.
8988 (gnus-summary-select-article nil nil nil number)
8990 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8992 (defun gnus-refer-article-methods ()
8993 "Return a list of referable methods."
8995 ;; No method, so we default to current and native.
8996 ((null gnus-refer-article-method)
8997 (list gnus-current-select-method gnus-select-method))
8999 ((eq 'current gnus-refer-article-method)
9000 (list gnus-current-select-method))
9001 ;; List of select methods.
9002 ((not (and (symbolp (car gnus-refer-article-method))
9003 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9005 (dolist (method gnus-refer-article-method)
9006 (push (if (eq 'current method)
9007 gnus-current-select-method
9011 ;; One single select method.
9013 (list gnus-refer-article-method))))
9015 (defun gnus-summary-edit-parameters ()
9016 "Edit the group parameters of the current group."
9018 (gnus-group-edit-group gnus-newsgroup-name 'params))
9020 (defun gnus-summary-customize-parameters ()
9021 "Customize the group parameters of the current group."
9023 (gnus-group-customize gnus-newsgroup-name))
9025 (defun gnus-summary-enter-digest-group (&optional force)
9026 "Enter an nndoc group based on the current article.
9027 If FORCE, force a digest interpretation. If not, try to guess
9028 what the document format is.
9030 To control what happens when you exit the group, see the
9031 `gnus-auto-select-on-ephemeral-exit' variable."
9033 (let ((conf gnus-current-window-configuration))
9034 (save-window-excursion
9036 (let (gnus-article-prepare-hook
9037 gnus-display-mime-function
9039 (gnus-summary-select-article))))
9040 (setq gnus-current-window-configuration conf)
9041 (let* ((name (format "%s-%d"
9042 (gnus-group-prefixed-name
9043 gnus-newsgroup-name (list 'nndoc ""))
9044 (with-current-buffer gnus-summary-buffer
9045 gnus-current-article)))
9046 (ogroup gnus-newsgroup-name)
9047 (params (append (gnus-info-params (gnus-get-info ogroup))
9048 (list (cons 'to-group ogroup))
9049 (list (cons 'parent-group ogroup))
9050 (list (cons 'save-article-group ogroup))))
9051 (case-fold-search t)
9052 (buf (current-buffer))
9054 (with-current-buffer gnus-original-article-buffer
9055 ;; Have the digest group inherit the main mail address of
9056 ;; the parent article.
9057 (when (setq to-address (or (gnus-fetch-field "reply-to")
9058 (gnus-fetch-field "from")))
9061 (list (cons 'to-address
9062 (funcall gnus-decode-encoded-address-function
9064 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9065 (insert-buffer-substring gnus-original-article-buffer)
9066 ;; Remove lines that may lead nndoc to misinterpret the
9069 (goto-char (point-min))
9070 (or (search-forward "\n\n" nil t) (point)))
9071 (goto-char (point-min))
9072 (delete-matching-lines "^Path:\\|^From ")
9075 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
9076 (gnus-newsgroup-ephemeral-ignored-charsets
9077 gnus-newsgroup-ignored-charsets))
9078 (gnus-group-read-ephemeral-group
9079 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9081 ,(if force 'mbox 'guess)))
9083 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9085 ;; Make all postings to this group go to the parent group.
9086 (nconc (gnus-info-params (gnus-get-info name))
9088 ;; Couldn't select this doc group.
9089 (switch-to-buffer buf)
9090 (gnus-set-global-variables)
9091 (gnus-configure-windows 'summary)
9092 (gnus-message 3 "Article couldn't be entered?"))
9093 (kill-buffer dig)))))
9095 (defun gnus-summary-read-document (n)
9096 "Open a new group based on the current article(s).
9097 This will allow you to read digests and other similar
9098 documents as newsgroups.
9099 Obeys the standard process/prefix convention."
9101 (let* ((ogroup gnus-newsgroup-name)
9102 (params (append (gnus-info-params (gnus-get-info ogroup))
9103 (list (cons 'to-group ogroup))))
9104 group egroup groups vgroup)
9105 (dolist (article (gnus-summary-work-articles n))
9106 (setq group (format "%s-%d" gnus-newsgroup-name article))
9107 (gnus-summary-remove-process-mark article)
9108 (when (gnus-summary-display-article article)
9109 (save-excursion ;;What for?
9111 (insert-buffer-substring gnus-original-article-buffer)
9112 ;; Remove some headers that may lead nndoc to make
9114 (message-narrow-to-head)
9115 (goto-char (point-min))
9116 (delete-matching-lines "^Path:\\|^From ")
9119 (gnus-group-read-ephemeral-group
9120 group `(nndoc ,group (nndoc-address ,(current-buffer))
9121 (nndoc-article-type guess))
9124 ;; Make all postings to this group go to the parent group.
9125 (nconc (gnus-info-params (gnus-get-info egroup))
9127 (push egroup groups))
9128 ;; Couldn't select this doc group.
9129 (gnus-error 3 "Article couldn't be entered"))))))
9130 ;; Now we have selected all the documents.
9133 (error "None of the articles could be interpreted as documents"))
9134 ((gnus-group-read-ephemeral-group
9135 (setq vgroup (format
9136 "nnvirtual:%s-%s" gnus-newsgroup-name
9137 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9138 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9140 (cons (current-buffer) 'summary)))
9142 (error "Couldn't select virtual nndoc group")))))
9144 (defun gnus-summary-widget-forward (arg)
9145 "Move point to the next field or button in the article.
9146 With optional ARG, move across that many fields."
9148 (gnus-summary-select-article)
9149 (gnus-configure-windows 'article)
9150 (select-window (gnus-get-buffer-window gnus-article-buffer))
9151 (widget-forward arg))
9153 (defun gnus-summary-isearch-article (&optional regexp-p)
9154 "Do incremental search forward on the current article.
9155 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9157 (gnus-summary-select-article)
9158 (gnus-configure-windows 'article)
9159 (gnus-eval-in-buffer-window gnus-article-buffer
9162 (isearch-forward regexp-p))))
9164 (defun gnus-summary-repeat-search-article-forward ()
9165 "Repeat the previous search forwards."
9167 (unless gnus-last-search-regexp
9168 (error "No previous search"))
9169 (gnus-summary-search-article-forward gnus-last-search-regexp))
9171 (defun gnus-summary-repeat-search-article-backward ()
9172 "Repeat the previous search backwards."
9174 (unless gnus-last-search-regexp
9175 (error "No previous search"))
9176 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9178 (defun gnus-summary-search-article-forward (regexp &optional backward)
9179 "Search for an article containing REGEXP forward.
9180 If BACKWARD, search backward instead."
9183 (format "Search article %s (regexp%s): "
9184 (if current-prefix-arg "backward" "forward")
9185 (if gnus-last-search-regexp
9186 (concat ", default " gnus-last-search-regexp)
9188 current-prefix-arg))
9189 (if (string-equal regexp "")
9190 (setq regexp (or gnus-last-search-regexp ""))
9191 (setq gnus-last-search-regexp regexp)
9192 (setq gnus-article-before-search gnus-current-article))
9193 ;; Intentionally set gnus-last-article.
9194 (setq gnus-last-article gnus-article-before-search)
9195 (let ((gnus-last-article gnus-last-article))
9196 (if (gnus-summary-search-article regexp backward)
9197 (gnus-summary-show-thread)
9198 (signal 'search-failed (list regexp)))))
9200 (defun gnus-summary-search-article-backward (regexp)
9201 "Search for an article containing REGEXP backward."
9204 (format "Search article backward (regexp%s): "
9205 (if gnus-last-search-regexp
9206 (concat ", default " gnus-last-search-regexp)
9208 (gnus-summary-search-article-forward regexp 'backward))
9210 (defun gnus-summary-search-article (regexp &optional backward)
9211 "Search for an article containing REGEXP.
9212 Optional argument BACKWARD means do search for backward.
9213 `gnus-select-article-hook' is not called during the search."
9214 ;; We have to require this here to make sure that the following
9215 ;; dynamic binding isn't shadowed by autoloading.
9216 (require 'gnus-async)
9218 (let ((gnus-select-article-hook nil) ;Disable hook.
9219 (gnus-article-prepare-hook nil)
9220 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9221 (gnus-use-article-prefetch nil)
9222 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9223 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9225 (gnus-keep-backlog nil)
9226 (gnus-break-pages nil)
9227 (gnus-summary-display-arrow nil)
9228 (gnus-updated-mode-lines nil)
9229 (gnus-auto-center-summary nil)
9230 (sum (current-buffer))
9231 (gnus-display-mime-function nil)
9234 (gnus-save-hidden-threads
9235 (gnus-summary-select-article)
9236 (set-buffer gnus-article-buffer)
9237 (goto-char (window-point (get-buffer-window (current-buffer))))
9241 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9243 (re-search-backward regexp nil t)
9244 (re-search-forward regexp nil t))
9245 ;; We found the regexp.
9250 (get-buffer-window (current-buffer))
9254 (get-buffer-window (current-buffer))
9257 (setq point (point)))
9258 ;; We didn't find it, so we go to the next article.
9261 (while (eq found 'not)
9262 (if (not (if backward (gnus-summary-find-prev)
9263 (gnus-summary-find-next)))
9264 ;; No more articles.
9266 ;; Select the next article and adjust point.
9267 (unless (gnus-summary-article-sparse-p
9268 (gnus-summary-article-number))
9270 (gnus-summary-select-article)
9271 (set-buffer gnus-article-buffer)
9273 (goto-char (if backward (point-max) (point-min))))))))
9274 (gnus-message 7 ""))
9275 ;; Return whether we found the regexp.
9276 (when (eq found 'found)
9278 (gnus-summary-show-thread)
9279 (gnus-summary-goto-subject gnus-current-article)
9280 (gnus-summary-position-point)
9283 (defun gnus-find-matching-articles (header regexp)
9284 "Return a list of all articles that match REGEXP on HEADER.
9285 This search includes all articles in the current group that Gnus has
9286 fetched headers for, whether they are displayed or not."
9287 (let ((articles nil)
9288 ;; Can't eta-reduce because it's a macro.
9289 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9290 (case-fold-search t))
9291 (dolist (header gnus-newsgroup-headers)
9292 (when (string-match regexp (funcall func header))
9293 (push (mail-header-number header) articles)))
9294 (nreverse articles)))
9296 (defun gnus-summary-find-matching (header regexp &optional backward unread
9297 not-case-fold not-matching)
9298 "Return a list of all articles that match REGEXP on HEADER.
9299 The search stars on the current article and goes forwards unless
9300 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9301 If UNREAD is non-nil, only unread articles will
9302 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9303 in the comparisons. If NOT-MATCHING, return a list of all articles that
9304 not match REGEXP on HEADER."
9305 (let ((case-fold-search (not not-case-fold))
9308 (if (eq (car header) 'extra)
9311 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9313 (error "%s is an invalid header" header))
9314 (unless (fboundp (intern (concat "mail-header-" header)))
9315 (error "%s is not a valid header" header))
9316 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9317 (dolist (d (if (eq backward 'all)
9319 (gnus-data-find-list
9320 (gnus-summary-article-number)
9321 (gnus-data-list backward))))
9322 (when (and (or (not unread) ; We want all articles...
9323 (gnus-data-unread-p d)) ; Or just unreads.
9324 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9328 (funcall func (gnus-data-header d))))
9329 (string-match regexp
9330 (funcall func (gnus-data-header d)))))
9331 (push (gnus-data-number d) articles))) ; Success!
9332 (nreverse articles)))
9334 (defun gnus-summary-execute-command (header regexp command &optional backward)
9335 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9336 If HEADER is an empty string (or nil), the match is done on the entire
9337 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9339 (list (let ((completion-ignore-case t))
9340 (gnus-completing-read
9342 (mapcar 'symbol-name
9344 '(Number Subject From Lines Date
9345 Message-ID Xref References Body)
9346 gnus-extra-headers))
9348 (read-string "Regexp: ")
9349 (read-key-sequence "Command: ")
9350 current-prefix-arg))
9351 (when (equal header "Body")
9353 ;; Hidden thread subtrees must be searched as well.
9354 (gnus-summary-show-all-threads)
9355 ;; We don't want to change current point nor window configuration.
9357 (save-window-excursion
9359 gnus-treat-strip-trailing-blank-lines
9360 gnus-treat-strip-leading-blank-lines
9361 gnus-treat-strip-multiple-blank-lines
9362 gnus-treat-hide-boring-headers
9363 gnus-treat-fold-newsgroups
9364 gnus-article-prepare-hook)
9365 (gnus-message 6 "Executing %s..." (key-description command))
9366 ;; We'd like to execute COMMAND interactively so as to give arguments.
9367 (gnus-execute header regexp
9368 `(call-interactively ',(key-binding command))
9370 (gnus-message 6 "Executing %s...done" (key-description command))))))
9372 (defun gnus-summary-beginning-of-article ()
9373 "Scroll the article back to the beginning."
9375 (gnus-summary-select-article)
9376 (gnus-configure-windows 'article)
9377 (gnus-eval-in-buffer-window gnus-article-buffer
9379 (goto-char (point-min))
9380 (when gnus-break-pages
9381 (gnus-narrow-to-page))))
9383 (defun gnus-summary-end-of-article ()
9384 "Scroll to the end of the article."
9386 (gnus-summary-select-article)
9387 (gnus-configure-windows 'article)
9388 (gnus-eval-in-buffer-window gnus-article-buffer
9390 (goto-char (point-max))
9392 (when gnus-break-pages
9393 (gnus-narrow-to-page))))
9395 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9396 "Truncate to LEN and quote all \"(\"'s in STRING."
9397 (gnus-replace-in-string (if (and len (> (length string) len))
9398 (substring string 0 len)
9402 (defun gnus-summary-print-article (&optional filename n)
9403 "Generate and print a PostScript image of the process-marked (mail) articles.
9405 If used interactively, print the current article if none are
9406 process-marked. With prefix arg, prompt the user for the name of the
9409 When used from Lisp, accept two optional args FILENAME and N. N means
9410 to print the next N articles. If N is negative, print the N previous
9411 articles. If N is nil and articles have been marked with the process
9412 mark, print these instead.
9414 If the optional first argument FILENAME is nil, send the image to the
9415 printer. If FILENAME is a string, save the PostScript image in a file with
9416 that name. If FILENAME is a number, prompt the user for the name of the file
9418 (interactive (list (ps-print-preprint current-prefix-arg)))
9419 (dolist (article (gnus-summary-work-articles n))
9420 (gnus-summary-select-article nil nil 'pseudo article)
9421 (gnus-eval-in-buffer-window gnus-article-buffer
9422 (gnus-print-buffer))
9423 (gnus-summary-remove-process-mark article))
9424 (ps-despool filename))
9426 (defun gnus-print-buffer ()
9427 (let ((ps-left-header
9430 (gnus-summary-print-truncate-and-quote
9431 (mail-header-subject gnus-current-headers)
9434 (gnus-summary-print-truncate-and-quote
9435 (mail-header-from gnus-current-headers)
9439 "/pagenumberstring load"
9441 (mail-header-date gnus-current-headers) ")"))))
9442 (gnus-run-hooks 'gnus-ps-print-hook)
9444 (if ps-print-color-p
9445 (ps-spool-buffer-with-faces)
9446 (ps-spool-buffer)))))
9448 (defun gnus-summary-show-complete-article ()
9449 "Show a complete version of the current article.
9450 This is only useful if you're looking at a partial version of the
9453 (let ((gnus-keep-backlog nil)
9454 (gnus-use-cache nil)
9457 (format "%s-fetch-partial-articles"
9458 (car (gnus-find-method-for-group
9459 gnus-newsgroup-name)))
9464 (setq old-val (symbol-value variable))
9466 (gnus-flush-original-article-buffer)
9467 (gnus-summary-show-article))
9468 (set variable old-val))))
9470 (defun gnus-summary-show-article (&optional arg)
9471 "Force redisplaying of the current article.
9472 If ARG (the prefix) is a number, show the article with the charset
9473 defined in `gnus-summary-show-article-charset-alist', or the charset
9475 If ARG (the prefix) is non-nil and not a number, show the article,
9476 but without running any of the article treatment functions
9477 article. Normally, the keystroke is `C-u g'. When using `C-u
9478 C-u g', show the raw article."
9482 (gnus-summary-show-article t)
9483 (let ((gnus-newsgroup-charset
9484 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9485 (mm-read-coding-system
9486 "View as charset: " ;; actually it is coding system.
9487 (with-current-buffer gnus-article-buffer
9488 (mm-detect-coding-region (point) (point-max))))))
9489 (gnus-newsgroup-ignored-charsets 'gnus-all))
9490 (gnus-summary-select-article nil 'force)
9491 (let ((deps gnus-newsgroup-dependencies)
9493 (with-current-buffer gnus-original-article-buffer
9495 (message-narrow-to-head)
9496 (setq head (buffer-string))
9497 (goto-char (point-min))
9498 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9499 (goto-char (point-max))
9501 (setq lines (1- (count-lines (point) (point-max))))))
9503 (insert (format "211 %d Article retrieved.\n"
9504 (cdr gnus-article-current)))
9506 (if lines (insert (format "Lines: %d\n" lines)))
9508 (let ((nntp-server-buffer (current-buffer)))
9509 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9510 (gnus-data-set-header
9511 (gnus-data-find (cdr gnus-article-current))
9513 (gnus-summary-update-article-line
9514 (cdr gnus-article-current) header)
9515 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9516 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9518 ;; Select the article the normal way.
9519 (gnus-summary-select-article nil 'force))
9520 ((or (equal arg '(16))
9523 (let ((gnus-inhibit-article-treatments t))
9524 (gnus-summary-select-article nil 'force)))
9526 ;; We have to require this here to make sure that the following
9527 ;; dynamic binding isn't shadowed by autoloading.
9528 (require 'gnus-async)
9530 ;; Bind the article treatment functions to nil.
9531 (let ((gnus-have-all-headers t)
9532 gnus-article-prepare-hook
9533 gnus-article-decode-hook
9534 gnus-display-mime-function
9536 ;; Destroy any MIME parts.
9537 (when (gnus-buffer-live-p gnus-article-buffer)
9538 (with-current-buffer gnus-article-buffer
9539 (mm-destroy-parts gnus-article-mime-handles)
9540 ;; Set it to nil for safety reason.
9541 (setq gnus-article-mime-handle-alist nil)
9542 (setq gnus-article-mime-handles nil)))
9543 (gnus-summary-select-article nil 'force))))
9544 (gnus-summary-goto-subject gnus-current-article)
9545 (gnus-summary-position-point))
9547 (defun gnus-summary-show-raw-article ()
9548 "Show the raw article without any article massaging functions being run."
9550 (gnus-summary-show-article t))
9552 (defun gnus-summary-verbose-headers (&optional arg)
9553 "Toggle permanent full header display.
9554 If ARG is a positive number, turn header display on.
9555 If ARG is a negative number, turn header display off."
9557 (setq gnus-show-all-headers
9558 (cond ((or (not (numberp arg))
9560 (not gnus-show-all-headers))
9563 (gnus-summary-show-article))
9565 (defun gnus-summary-toggle-header (&optional arg)
9566 "Show the headers if they are hidden, or hide them if they are shown.
9567 If ARG is a positive number, show the entire header.
9568 If ARG is a negative number, hide the unwanted header lines."
9570 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9571 (get-buffer-window gnus-article-buffer t))))
9572 (with-current-buffer gnus-article-buffer
9574 (article-narrow-to-head)
9575 (let* ((inhibit-read-only t)
9576 (inhibit-point-motion-hooks t)
9577 (hidden (if (numberp arg)
9579 (or (not (looking-at "[^ \t\n]+:"))
9580 (gnus-article-hidden-text-p 'headers))))
9582 (delete-region (point-min) (point-max))
9583 (with-current-buffer gnus-original-article-buffer
9584 (goto-char (setq s (point-min)))
9585 (setq e (if (search-forward "\n\n" nil t)
9588 (insert-buffer-substring gnus-original-article-buffer s e)
9589 (run-hooks 'gnus-article-decode-hook)
9591 (let ((gnus-treat-hide-headers nil)
9592 (gnus-treat-hide-boring-headers nil))
9593 (gnus-delete-wash-type 'headers)
9594 (gnus-treat-article 'head))
9595 (gnus-treat-article 'head))
9598 (set-window-start window (goto-char (point-min))))
9599 (if gnus-break-pages
9600 (gnus-narrow-to-page)
9601 (when (gnus-visual-p 'page-marker)
9602 (let ((inhibit-read-only t))
9603 (gnus-remove-text-with-property 'gnus-prev)
9604 (gnus-remove-text-with-property 'gnus-next))))
9605 (gnus-set-mode-line 'article)))))
9607 (defun gnus-summary-show-all-headers ()
9608 "Make all header lines visible."
9610 (gnus-summary-toggle-header 1))
9612 (defun gnus-summary-caesar-message (&optional arg)
9613 "Caesar rotate the current article by 13.
9614 With a non-numerical prefix, also rotate headers. A numerical
9615 prefix specifies how many places to rotate each letter forward."
9617 (gnus-summary-select-article)
9618 (let ((mail-header-separator ""))
9619 (gnus-eval-in-buffer-window gnus-article-buffer
9622 (let ((start (window-start))
9623 (inhibit-read-only t))
9624 (if (equal arg '(4))
9625 (message-caesar-buffer-body nil t)
9626 (message-caesar-buffer-body arg))
9627 (set-window-start (get-buffer-window (current-buffer)) start)))))
9628 ;; Create buttons and stuff...
9629 (gnus-treat-article nil))
9631 (declare-function idna-to-unicode "ext:idna" (str))
9633 (defun gnus-summary-idna-message (&optional arg)
9634 "Decode IDNA encoded domain names in the current articles.
9635 IDNA encoded domain names looks like `xn--bar'. If a string
9636 remain unencoded after running this function, it is likely an
9637 invalid IDNA string (`xn--bar' is invalid).
9639 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9640 installed for this command to work."
9642 (if (not (and (condition-case nil (require 'idna)
9644 (mm-coding-system-p 'utf-8)
9645 (executable-find (symbol-value 'idna-program))))
9647 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9648 (gnus-summary-select-article)
9649 (let ((mail-header-separator ""))
9650 (gnus-eval-in-buffer-window gnus-article-buffer
9653 (let ((start (window-start))
9655 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9656 (replace-match (idna-to-unicode (match-string 1))))
9657 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9659 (defun gnus-summary-morse-message (&optional arg)
9660 "Morse decode the current article."
9662 (gnus-summary-select-article)
9663 (let ((mail-header-separator ""))
9664 (gnus-eval-in-buffer-window gnus-article-buffer
9668 (let ((pos (window-start))
9669 (inhibit-read-only t))
9670 (goto-char (point-min))
9671 (when (message-goto-body)
9672 (gnus-narrow-to-body))
9673 (goto-char (point-min))
9674 (while (search-forward "·" (point-max) t)
9675 (replace-match "."))
9676 (unmorse-region (point-min) (point-max))
9678 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9680 (defun gnus-summary-stop-page-breaking ()
9681 "Stop page breaking in the current article."
9683 (gnus-summary-select-article)
9684 (gnus-eval-in-buffer-window gnus-article-buffer
9686 (when (gnus-visual-p 'page-marker)
9687 (let ((inhibit-read-only t))
9688 (gnus-remove-text-with-property 'gnus-prev)
9689 (gnus-remove-text-with-property 'gnus-next))
9690 (setq gnus-page-broken nil))))
9692 (defun gnus-summary-move-article (&optional n to-newsgroup
9693 select-method action)
9694 "Move the current article to a different newsgroup.
9695 If N is a positive number, move the N next articles.
9696 If N is a negative number, move the N previous articles.
9697 If N is nil and any articles have been marked with the process mark,
9698 move those articles instead.
9699 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9700 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9701 re-spool using this method.
9703 When called interactively with TO-NEWSGROUP being nil, the value of
9704 the variable `gnus-move-split-methods' is used for finding a default
9705 for the target newsgroup.
9707 For this function to work, both the current newsgroup and the
9708 newsgroup that you want to move to have to support the `request-move'
9709 and `request-accept' functions.
9711 ACTION can be either `move' (the default), `crosspost' or `copy'."
9714 (setq action 'move))
9715 ;; Check whether the source group supports the required functions.
9716 (cond ((and (eq action 'move)
9717 (not (gnus-check-backend-function
9718 'request-move-article gnus-newsgroup-name)))
9719 (error "The current group does not support article moving"))
9720 ((and (eq action 'crosspost)
9721 (not (gnus-check-backend-function
9722 'request-replace-article gnus-newsgroup-name)))
9723 (error "The current group does not support article editing")))
9724 (let ((articles (gnus-summary-work-articles n))
9725 (prefix (if (gnus-check-backend-function
9726 'request-move-article gnus-newsgroup-name)
9727 (funcall gnus-move-group-prefix-function
9728 gnus-newsgroup-name)
9730 (names '((move "Move" "Moving")
9731 (copy "Copy" "Copying")
9732 (crosspost "Crosspost" "Crossposting")))
9733 (copy-buf (save-excursion
9734 (nnheader-set-temp-buffer " *copy article*")))
9735 art-group to-method new-xref article to-groups
9736 articles-to-update-marks encoded)
9737 (unless (assq action names)
9738 (error "Unknown action %s" action))
9739 ;; Read the newsgroup name.
9740 (when (and (not to-newsgroup)
9741 (not select-method))
9742 (if (and gnus-move-split-methods
9744 (and (memq gnus-current-article articles)
9745 (gnus-buffer-live-p gnus-original-article-buffer))))
9746 ;; When `gnus-move-split-methods' is non-nil, we have to
9747 ;; select an article to give `gnus-read-move-group-name' an
9748 ;; opportunity to suggest an appropriate default. However,
9749 ;; we needn't render or mark the article.
9750 (let ((gnus-display-mime-function nil)
9751 (gnus-article-prepare-hook nil)
9752 (gnus-mark-article-hook nil))
9753 (gnus-summary-select-article nil nil nil (car articles))))
9754 (setq to-newsgroup (gnus-read-move-group-name
9755 (cadr (assq action names))
9757 (intern (format "gnus-current-%s-group" action)))
9759 encoded to-newsgroup
9760 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9761 (set (intern (format "gnus-current-%s-group" action))
9762 (mm-decode-coding-string
9764 (gnus-group-name-charset to-method to-newsgroup))))
9766 (setq to-method (or select-method
9767 (gnus-server-to-method
9768 (gnus-group-method to-newsgroup)))))
9772 (mm-encode-coding-string
9774 (gnus-group-name-charset to-method to-newsgroup)))))
9775 ;; Check the method we are to move this article to...
9776 (unless (gnus-check-backend-function
9777 'request-accept-article (car to-method))
9778 (error "%s does not support article copying" (car to-method)))
9779 (unless (gnus-check-server to-method)
9780 (error "Can't open server %s" (car to-method)))
9781 (gnus-message 6 "%s to %s: %s..."
9782 (caddr (assq action names))
9783 (or (car select-method)
9784 (gnus-group-decoded-name to-newsgroup))
9787 (setq article (pop articles))
9788 ;; Set any marks that may have changed in the summary buffer.
9789 (when gnus-preserve-marks
9790 (gnus-summary-push-marks-to-backend article))
9794 ;; Move the article.
9796 ;; Remove this article from future suppression.
9797 (gnus-dup-unsuppress-article article)
9798 (let* ((from-method (gnus-find-method-for-group
9799 gnus-newsgroup-name))
9800 (to-method (or select-method
9801 (gnus-find-method-for-group to-newsgroup)))
9802 (move-is-internal (gnus-server-equal from-method to-method)))
9803 (gnus-request-move-article
9804 article ; Article to move
9805 gnus-newsgroup-name ; From newsgroup
9806 (nth 1 (gnus-find-method-for-group
9807 gnus-newsgroup-name)) ; Server
9808 (list 'gnus-request-accept-article
9809 to-newsgroup (list 'quote select-method)
9810 (not articles) t) ; Accept form
9811 (not articles) ; Only save nov last time
9812 (and move-is-internal
9813 to-newsgroup ; Not respooling
9814 ; Is this move internal?
9815 (gnus-group-real-name to-newsgroup)))))
9816 ;; Copy the article.
9818 (with-current-buffer copy-buf
9819 (when (gnus-request-article-this-buffer article
9820 gnus-newsgroup-name)
9822 (nnheader-narrow-to-headers)
9823 (dolist (hdr gnus-copy-article-ignored-headers)
9824 (message-remove-header hdr t)))
9825 (gnus-request-accept-article
9826 to-newsgroup select-method (not articles) t))))
9827 ;; Crosspost the article.
9828 ((eq action 'crosspost)
9829 (let ((xref (message-tokenize-header
9830 (mail-header-xref (gnus-summary-article-header
9833 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9834 ":" (number-to-string article)))
9836 (setq xref (list (system-name))))
9839 (mapconcat 'identity
9840 (delete "Xref:" (delete new-xref xref))
9843 (with-current-buffer copy-buf
9844 ;; First put the article in the destination group.
9845 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9846 (when (consp (setq art-group
9847 (gnus-request-accept-article
9848 to-newsgroup select-method (not articles)
9850 (setq new-xref (concat new-xref " " (car art-group)
9852 (number-to-string (cdr art-group))))
9853 ;; Now we have the new Xrefs header, so we insert
9854 ;; it and replace the new article.
9855 (nnheader-replace-header "Xref" new-xref)
9856 (gnus-request-replace-article
9857 (cdr art-group) to-newsgroup (current-buffer) t)
9861 (gnus-message 1 "Couldn't %s article %s: %s"
9862 (cadr (assq action names)) article
9863 (nnheader-get-report (car to-method))))
9864 ((eq art-group 'junk)
9865 (when (eq action 'move)
9866 (gnus-summary-mark-article article gnus-canceled-mark)
9867 (gnus-message 4 "Deleted article %s" article)
9868 ;; run the delete hook
9869 (run-hook-with-args 'gnus-summary-article-delete-hook
9872 (assoc article (gnus-data-list nil)))
9873 gnus-newsgroup-name nil
9876 (let* ((pto-group (gnus-group-prefixed-name
9877 (car art-group) to-method))
9878 (info (gnus-get-info pto-group))
9879 (to-group (gnus-info-group info))
9881 ;; Update the group that has been moved to.
9883 (memq action '(move copy)))
9884 (unless (member to-group to-groups)
9885 (push to-group to-groups))
9887 (when (and (not (memq article gnus-newsgroup-unreads))
9889 (push 'read to-marks)
9891 info (gnus-add-to-range (gnus-info-read info)
9892 (list (cdr art-group)))))
9894 ;; See whether the article is to be put in the cache.
9895 (let* ((expirable (gnus-group-auto-expirable-p to-group))
9896 (marks (if expirable
9897 gnus-article-mark-lists
9898 (delete '(expirable . expire)
9900 gnus-article-mark-lists))))
9901 (to-article (cdr art-group)))
9903 ;; Enter the article into the cache in the new group,
9904 ;; if that is required.
9905 (when (and to-article
9907 (gnus-cache-possibly-enter-article
9909 (memq article gnus-newsgroup-marked)
9910 (memq article gnus-newsgroup-dormant)
9911 (memq article gnus-newsgroup-unreads)))
9913 (when (and gnus-preserve-marks
9915 ;; Copy any marks over to the new group.
9916 (when (and (equal to-group gnus-newsgroup-name)
9917 (not (memq article gnus-newsgroup-unreads)))
9918 ;; Mark this article as read in this group.
9919 (push (cons to-article gnus-read-mark)
9920 gnus-newsgroup-reads)
9921 ;; Increase the active status of this group.
9922 (setcdr (gnus-active to-group) to-article)
9923 (setcdr gnus-newsgroup-active to-article))
9926 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9927 (when (memq article (symbol-value
9928 (intern (format "gnus-newsgroup-%s"
9930 (push (cdar marks) to-marks)
9931 ;; If the other group is the same as this group,
9932 ;; then we have to add the mark to the list.
9933 (when (equal to-group gnus-newsgroup-name)
9934 (set (intern (format "gnus-newsgroup-%s"
9938 (intern (format "gnus-newsgroup-%s"
9940 ;; Copy the marks to other group.
9941 (gnus-add-marked-articles
9942 to-group (cdar marks) (list to-article) info)))
9943 (setq marks (cdr marks)))
9945 (when (and expirable
9946 gnus-mark-copied-or-moved-articles-as-expirable
9947 (not (memq 'expire to-marks)))
9948 ;; Mark this article as expirable.
9949 (push 'expire to-marks)
9950 (when (equal to-group gnus-newsgroup-name)
9951 (push to-article gnus-newsgroup-expirable))
9952 ;; Copy the expirable mark to other group.
9953 (gnus-add-marked-articles
9954 to-group 'expire (list to-article) info))
9957 (gnus-request-set-mark
9958 to-group (list (list (list to-article) 'add to-marks)))))
9961 (concat "(gnus-group-set-info '"
9962 (gnus-prin1-to-string (gnus-get-info to-group))
9965 ;; Update the Xref header in this article to point to
9966 ;; the new crossposted article we have just created.
9967 (when (eq action 'crosspost)
9968 (with-current-buffer copy-buf
9969 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9970 (nnheader-replace-header "Xref" new-xref)
9971 (gnus-request-replace-article
9972 article gnus-newsgroup-name (current-buffer) t)))
9974 ;; run the move/copy/crosspost/respool hook
9975 (run-hook-with-args 'gnus-summary-article-move-hook
9978 (assoc article (gnus-data-list nil)))
9983 ;;;!!!Why is this necessary?
9984 (set-buffer gnus-summary-buffer)
9986 (when (eq action 'move)
9988 (gnus-summary-goto-subject article)
9989 (gnus-summary-mark-article article gnus-canceled-mark)))))
9990 (push article articles-to-update-marks))
9993 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
9994 ;; Re-activate all groups that have been moved to.
9995 (with-current-buffer gnus-group-buffer
9996 (let ((gnus-group-marked to-groups))
9997 (gnus-group-get-new-news-this-group nil t)))
9999 (gnus-kill-buffer copy-buf)
10000 (gnus-summary-position-point)
10001 (gnus-set-mode-line 'summary)))
10003 (defun gnus-summary-push-marks-to-backend (article)
10005 (marks gnus-article-mark-lists))
10006 (unless (memq article gnus-newsgroup-unreads)
10009 (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10010 (memq article (symbol-value
10011 (intern (format "gnus-newsgroup-%s"
10013 (push (cdar marks) set))
10015 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)))))
10017 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10018 "Copy the current article to some other group.
10019 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10020 When called interactively, if TO-NEWSGROUP is nil, use the value of
10021 the variable `gnus-move-split-methods' for finding a default target
10023 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10024 re-spool using this method."
10026 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10028 (defun gnus-summary-crosspost-article (&optional n)
10029 "Crosspost the current article to some other group."
10031 (gnus-summary-move-article n nil nil 'crosspost))
10033 (defcustom gnus-summary-respool-default-method nil
10034 "Default method type for respooling an article.
10035 If nil, use to the current newsgroup method."
10037 :group 'gnus-summary-mail)
10039 (defun gnus-summary-respool-article (&optional n method)
10040 "Respool the current article.
10041 The article will be squeezed through the mail spooling process again,
10042 which means that it will be put in some mail newsgroup or other
10043 depending on `nnmail-split-methods'.
10044 If N is a positive number, respool the N next articles.
10045 If N is a negative number, respool the N previous articles.
10046 If N is nil and any articles have been marked with the process mark,
10047 respool those articles instead.
10049 Respooling can be done both from mail groups and \"real\" newsgroups.
10050 In the former case, the articles in question will be moved from the
10051 current group into whatever groups they are destined to. In the
10052 latter case, they will be copied into the relevant groups."
10054 (list current-prefix-arg
10055 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10057 (symbol-name (or gnus-summary-respool-default-method
10058 (car (gnus-find-method-for-group
10059 gnus-newsgroup-name)))))
10061 (gnus-completing-read
10062 "Backend to use when respooling"
10063 methods t nil 'gnus-mail-method-history methname))
10066 ((zerop (length (setq ms (gnus-servers-using-backend
10067 (intern method)))))
10068 (list (intern method) ""))
10072 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10073 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10076 (error "No method given for respooling"))
10077 (if (assoc (symbol-name
10078 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10079 (gnus-methods-using 'respool))
10080 (gnus-summary-move-article n nil method)
10081 (gnus-summary-copy-article n nil method)))
10083 (defun gnus-summary-import-article (file &optional edit)
10084 "Import an arbitrary file into a mail newsgroup."
10085 (interactive "fImport file: \nP")
10086 (let ((group gnus-newsgroup-name)
10087 (now (current-time))
10088 atts lines group-art)
10089 (unless (gnus-check-backend-function 'request-accept-article group)
10090 (error "%s does not support article importing" group))
10091 (or (file-readable-p file)
10092 (not (file-regular-p file))
10093 (error "Can't read %s" file))
10094 (with-current-buffer (gnus-get-buffer-create " *import file*")
10096 (nnheader-insert-file-contents file)
10097 (goto-char (point-min))
10098 (if (nnheader-article-p)
10100 (goto-char (point-min))
10101 (search-forward "\n\n" nil t)
10102 (narrow-to-region (point-min) (1- (point)))
10103 (goto-char (point-min))
10104 (unless (re-search-forward "^date:" nil t)
10105 (goto-char (point-max))
10106 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10107 ;; This doesn't look like an article, so we fudge some headers.
10108 (setq atts (file-attributes file)
10109 lines (count-lines (point-min) (point-max)))
10110 (insert "From: " (read-string "From: ") "\n"
10111 "Subject: " (read-string "Subject: ") "\n"
10112 "Date: " (message-make-date (nth 5 atts)) "\n"
10113 "Message-ID: " (message-make-message-id) "\n"
10114 "Lines: " (int-to-string lines) "\n"
10115 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10116 (setq group-art (gnus-request-accept-article group nil t))
10117 (kill-buffer (current-buffer)))
10118 (setq gnus-newsgroup-active (gnus-activate-group group))
10120 (gnus-summary-goto-article (cdr group-art) nil t)
10122 (gnus-summary-edit-article))))
10124 (defun gnus-summary-create-article ()
10125 "Create an article in a mail newsgroup."
10127 (let ((group gnus-newsgroup-name)
10128 (now (current-time))
10130 (unless (gnus-check-backend-function 'request-accept-article group)
10131 (error "%s does not support article importing" group))
10132 (with-current-buffer (gnus-get-buffer-create " *import file*")
10134 (goto-char (point-min))
10135 ;; This doesn't look like an article, so we fudge some headers.
10136 (insert "From: " (read-string "From: ") "\n"
10137 "Subject: " (read-string "Subject: ") "\n"
10138 "Date: " (message-make-date now) "\n"
10139 "Message-ID: " (message-make-message-id) "\n")
10140 (setq group-art (gnus-request-accept-article group nil t))
10141 (kill-buffer (current-buffer)))
10142 (setq gnus-newsgroup-active (gnus-activate-group group))
10144 (gnus-summary-goto-article (cdr group-art) nil t)
10145 (gnus-summary-edit-article)))
10147 (defun gnus-summary-article-posted-p ()
10148 "Say whether the current (mail) article is available from news as well.
10149 This will be the case if the article has both been mailed and posted."
10151 (let ((id (mail-header-references (gnus-summary-article-header)))
10152 (gnus-override-method (car (gnus-refer-article-methods))))
10153 (if (gnus-request-head id "")
10154 (gnus-message 2 "The current message was found on %s"
10155 gnus-override-method)
10156 (gnus-message 2 "The current message couldn't be found on %s"
10157 gnus-override-method)
10160 (defun gnus-summary-expire-articles (&optional now)
10161 "Expire all articles that are marked as expirable in the current group."
10163 (when (and (not gnus-group-is-exiting-without-update-p)
10164 (gnus-check-backend-function
10165 'request-expire-articles gnus-newsgroup-name))
10166 ;; This backend supports expiry.
10167 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10168 (expirable (if total
10170 ;; We need to update the info for
10171 ;; this group for `gnus-list-of-read-articles'
10172 ;; to give us the right answer.
10173 (gnus-run-hooks 'gnus-exit-group-hook)
10174 (gnus-summary-update-info)
10175 (gnus-list-of-read-articles gnus-newsgroup-name))
10176 (setq gnus-newsgroup-expirable
10177 (sort gnus-newsgroup-expirable '<))))
10178 (expiry-wait (if now 'immediate
10179 (gnus-group-find-parameter
10180 gnus-newsgroup-name 'expiry-wait)))
10181 (nnmail-expiry-target
10182 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10183 nnmail-expiry-target))
10186 ;; There are expirable articles in this group, so we run them
10187 ;; through the expiry process.
10188 (gnus-message 6 "Expiring articles...")
10189 (unless (gnus-check-group gnus-newsgroup-name)
10190 (error "Can't open server for %s" gnus-newsgroup-name))
10191 ;; The list of articles that weren't expired is returned.
10194 (let ((nnmail-expiry-wait-function nil)
10195 (nnmail-expiry-wait expiry-wait))
10196 (setq es (gnus-request-expire-articles
10197 expirable gnus-newsgroup-name)))
10198 (setq es (gnus-request-expire-articles
10199 expirable gnus-newsgroup-name)))
10201 (setq gnus-newsgroup-expirable es))
10202 ;; We go through the old list of expirable, and mark all
10203 ;; really expired articles as nonexistent.
10204 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10205 (let ((gnus-use-cache nil))
10206 (dolist (article expirable)
10207 (when (and (not (memq article es))
10208 (gnus-data-find article))
10209 (gnus-summary-mark-article article gnus-canceled-mark)
10210 (run-hook-with-args 'gnus-summary-article-expire-hook
10213 (assoc article (gnus-data-list nil)))
10214 gnus-newsgroup-name
10217 (gnus-message 6 "Expiring articles...done")))))
10219 (defun gnus-summary-expire-articles-now ()
10220 "Expunge all expirable articles in the current group.
10221 This means that *all* articles that are marked as expirable will be
10222 deleted forever, right now."
10224 (or gnus-expert-user
10226 "Are you really, really sure you want to delete all expirable messages? ")
10228 (gnus-summary-expire-articles t))
10230 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10231 (defun gnus-summary-delete-article (&optional n)
10232 "Delete the N next (mail) articles.
10233 This command actually deletes articles. This is not a marking
10234 command. The article will disappear forever from your life, never to
10237 If N is negative, delete backwards.
10238 If N is nil and articles have been marked with the process mark,
10239 delete these instead.
10241 If `gnus-novice-user' is non-nil you will be asked for
10242 confirmation before the articles are deleted."
10244 (unless (gnus-check-backend-function 'request-expire-articles
10245 gnus-newsgroup-name)
10246 (error "The current newsgroup does not support article deletion"))
10247 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10248 (error "Couldn't open server"))
10249 ;; Compute the list of articles to delete.
10250 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10251 (nnmail-expiry-target 'delete)
10253 (if (and gnus-novice-user
10254 (not (gnus-yes-or-no-p
10255 (format "Do you really want to delete %s forever? "
10256 (if (> (length articles) 1)
10257 (format "these %s articles" (length articles))
10258 "this article")))))
10260 ;; Delete the articles.
10261 (setq not-deleted (gnus-request-expire-articles
10262 articles gnus-newsgroup-name 'force))
10265 (gnus-summary-remove-process-mark (car articles))
10266 ;; The backend might not have been able to delete the article
10268 (unless (memq (car articles) not-deleted)
10269 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10270 (let* ((article (car articles))
10271 (ghead (gnus-data-header
10272 (assoc article (gnus-data-list nil)))))
10273 (run-hook-with-args 'gnus-summary-article-delete-hook
10274 'delete ghead gnus-newsgroup-name nil
10276 (setq articles (cdr articles))))
10278 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10279 (gnus-summary-position-point)
10280 (gnus-set-mode-line 'summary)
10283 (defun gnus-summary-edit-article (&optional arg)
10284 "Edit the current article.
10285 This will have permanent effect only in mail groups.
10286 If ARG is nil, edit the decoded articles.
10287 If ARG is 1, edit the raw articles.
10288 If ARG is 2, edit the raw articles even in read-only groups.
10289 If ARG is 3, edit the articles with the current handles.
10290 Otherwise, allow editing of articles even in read-only
10293 (let (force raw current-handles)
10302 (setq current-handles
10303 (and (gnus-buffer-live-p gnus-article-buffer)
10304 (with-current-buffer gnus-article-buffer
10306 gnus-article-mime-handles
10307 (setq gnus-article-mime-handles nil))))))
10310 (when (and raw (not force)
10311 (member gnus-newsgroup-name '("nndraft:delayed"
10314 (error "Can't edit the raw article in group %s"
10315 gnus-newsgroup-name))
10316 (with-current-buffer gnus-summary-buffer
10317 (let ((mail-parse-charset gnus-newsgroup-charset)
10318 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10319 (gnus-set-global-variables)
10320 (when (and (not force)
10321 (gnus-group-read-only-p))
10322 (error "The current newsgroup does not support article editing"))
10323 (gnus-summary-show-article t)
10324 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10325 (with-current-buffer gnus-article-buffer
10326 (mm-enable-multibyte)))
10327 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10329 (gnus-article-edit-article
10332 (let ((mbl mml-buffer-list))
10333 (setq mml-buffer-list nil)
10334 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10335 (mime-to-mml ,'current-handles))
10336 (let ((mbl1 mml-buffer-list))
10337 (setq mml-buffer-list mbl)
10338 (set (make-local-variable 'mml-buffer-list) mbl1))
10339 (gnus-make-local-hook 'kill-buffer-hook)
10340 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10341 `(lambda (no-highlight)
10342 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10343 (message-options message-options)
10344 (message-options-set-recipient)
10345 (mail-parse-ignored-charsets
10346 ',gnus-newsgroup-ignored-charsets)
10347 (rfc2047-header-encoding-alist
10348 ',(let ((charset (gnus-group-name-charset
10349 (gnus-find-method-for-group
10350 gnus-newsgroup-name)
10351 gnus-newsgroup-name)))
10352 (append (list (cons "Newsgroups" charset)
10353 (cons "Followup-To" charset)
10354 (cons "Xref" charset))
10355 rfc2047-header-encoding-alist))))
10356 ,(if (not raw) '(progn
10358 (mml-destroy-buffers)
10359 (remove-hook 'kill-buffer-hook
10360 'mml-destroy-buffers t)
10361 (kill-local-variable 'mml-buffer-list)))
10362 (gnus-summary-edit-article-done
10363 ,(or (mail-header-references gnus-current-headers) "")
10364 ,(gnus-group-read-only-p)
10365 ,gnus-summary-buffer no-highlight))))))))
10367 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10369 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10371 "Make edits to the current article permanent."
10374 ;; The buffer restriction contains the entire article if it exists.
10375 (when (article-goto-body)
10376 (let ((lines (count-lines (point) (point-max)))
10377 (length (- (point-max) (point)))
10378 (case-fold-search t)
10379 (body (copy-marker (point))))
10380 (goto-char (point-min))
10381 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10382 (delete-region (match-beginning 1) (match-end 1))
10383 (insert (number-to-string length)))
10384 (goto-char (point-min))
10385 (when (re-search-forward
10386 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10387 (delete-region (match-beginning 1) (match-end 1))
10388 (insert (number-to-string length)))
10389 (goto-char (point-min))
10390 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10391 (delete-region (match-beginning 1) (match-end 1))
10392 (insert (number-to-string lines))))))
10393 ;; Replace the article.
10394 (let ((buf (current-buffer))
10395 (article (cdr gnus-article-current))
10398 (insert-buffer-substring buf)
10399 (if (and (not read-only)
10400 (not (setq replace-result
10401 (gnus-request-replace-article
10402 article (car gnus-article-current)
10403 (current-buffer) t))))
10404 (error "Couldn't replace article")
10405 ;; If we got a number back, then that's the new article number
10406 ;; for this article. Otherwise, the article number didn't change.
10407 (when (numberp replace-result)
10408 (with-current-buffer gnus-summary-buffer
10409 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10410 (gnus-summary-limit gnus-newsgroup-limit)
10411 (setq article replace-result)
10412 (gnus-summary-goto-subject article t)))
10413 ;; Update the summary buffer.
10414 (if (and references
10415 (equal (message-tokenize-header references " ")
10416 (message-tokenize-header
10417 (or (message-fetch-field "references") "") " ")))
10418 ;; We only have to update this line.
10421 (message-narrow-to-head)
10422 (let ((head (buffer-substring-no-properties
10423 (point-min) (point-max)))
10426 (insert (format "211 %d Article retrieved.\n" article))
10429 (let ((nntp-server-buffer (current-buffer)))
10430 (setq header (car (gnus-get-newsgroup-headers nil t))))
10431 (with-current-buffer gnus-summary-buffer
10432 (gnus-data-set-header (gnus-data-find article) header)
10433 (gnus-summary-update-article-line article header)
10434 (if (gnus-summary-goto-subject article nil t)
10435 (gnus-summary-update-secondary-mark article)))))))
10437 (set-buffer (or buffer gnus-summary-buffer))
10438 (gnus-summary-update-article article)
10439 (if (gnus-summary-goto-subject article nil t)
10440 (gnus-summary-update-secondary-mark article)))
10441 ;; Prettify the article buffer again.
10442 (unless no-highlight
10443 (with-current-buffer gnus-article-buffer
10444 ;;!!! Fix this -- article should be rehighlighted.
10445 ;;(gnus-run-hooks 'gnus-article-display-hook)
10446 (set-buffer gnus-original-article-buffer)
10447 (gnus-request-article
10448 article (car gnus-article-current) (current-buffer))))
10449 ;; Prettify the summary buffer line.
10450 (when (gnus-visual-p 'summary-highlight 'highlight)
10451 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10453 (defun gnus-summary-edit-wash (key)
10454 "Perform editing command KEY in the article buffer."
10458 (message "%s" (concat (this-command-keys) "- "))
10461 (gnus-summary-edit-article)
10462 (execute-kbd-macro (concat (this-command-keys) key))
10463 (gnus-article-edit-done))
10467 (defun gnus-summary-respool-query (&optional silent trace)
10468 "Query where the respool algorithm would put this article."
10470 (let (gnus-mark-article-hook)
10471 (gnus-summary-select-article)
10472 (with-current-buffer gnus-original-article-buffer
10473 (let ((groups (nnmail-article-group 'identity trace)))
10476 (message "This message would go to %s"
10477 (mapconcat 'car groups ", "))
10478 (message "This message would go to no groups"))
10481 (defun gnus-summary-respool-trace ()
10482 "Trace where the respool algorithm would put this article.
10483 Display a buffer showing all fancy splitting patterns which matched."
10485 (gnus-summary-respool-query nil t))
10487 ;; Summary marking commands.
10489 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10490 "Mark articles which has the same subject as read, and then select the next.
10491 If UNMARK is positive, remove any kind of mark.
10492 If UNMARK is negative, tick articles."
10495 (setq unmark (prefix-numeric-value unmark)))
10497 (gnus-summary-mark-same-subject
10498 (gnus-summary-article-subject) unmark)))
10499 ;; Select next unread article. If auto-select-same mode, should
10500 ;; select the first unread article.
10501 (gnus-summary-next-article t (and gnus-auto-select-same
10502 (gnus-summary-article-subject)))
10503 (gnus-message 7 "%d article%s marked as %s"
10504 count (if (= count 1) " is" "s are")
10505 (if unmark "unread" "read"))))
10507 (defun gnus-summary-kill-same-subject (&optional unmark)
10508 "Mark articles which has the same subject as read.
10509 If UNMARK is positive, remove any kind of mark.
10510 If UNMARK is negative, tick articles."
10513 (setq unmark (prefix-numeric-value unmark)))
10515 (gnus-summary-mark-same-subject
10516 (gnus-summary-article-subject) unmark)))
10517 ;; If marked as read, go to next unread subject.
10518 (when (null unmark)
10519 ;; Go to next unread subject.
10520 (gnus-summary-next-subject 1 t))
10521 (gnus-message 7 "%d articles are marked as %s"
10522 count (if unmark "unread" "read"))))
10524 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10525 "Mark articles with same SUBJECT as read, and return marked number.
10526 If optional argument UNMARK is positive, remove any kinds of marks.
10527 If optional argument UNMARK is negative, mark articles as unread instead."
10531 ((null unmark) ; Mark as read.
10534 (gnus-summary-mark-article-as-read gnus-killed-mark)
10535 (gnus-summary-show-thread) t)
10536 (gnus-summary-find-subject subject))
10537 (setq count (1+ count))))
10538 ((> unmark 0) ; Tick.
10541 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10542 (gnus-summary-show-thread) t)
10543 (gnus-summary-find-subject subject))
10544 (setq count (1+ count))))
10545 (t ; Mark as unread.
10548 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10549 (gnus-summary-show-thread) t)
10550 (gnus-summary-find-subject subject))
10551 (setq count (1+ count)))))
10552 (gnus-set-mode-line 'summary)
10553 ;; Return the number of marked articles.
10556 (defun gnus-summary-mark-as-processable (n &optional unmark)
10557 "Set the process mark on the next N articles.
10558 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10559 the process mark instead. The difference between N and the actual
10560 number of articles marked is returned."
10562 (if (and (null n) (gnus-region-active-p))
10563 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10564 (setq n (prefix-numeric-value n))
10565 (let ((backward (< n 0))
10570 (gnus-summary-remove-process-mark
10571 (gnus-summary-article-number))
10572 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10573 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10576 (gnus-message 7 "No more articles"))
10577 (gnus-summary-recenter)
10578 (gnus-summary-position-point)
10581 (defun gnus-summary-unmark-as-processable (n)
10582 "Remove the process mark from the next N articles.
10583 If N is negative, unmark backward instead. The difference between N and
10584 the actual number of articles unmarked is returned."
10586 (gnus-summary-mark-as-processable n t))
10588 (defun gnus-summary-unmark-all-processable ()
10589 "Remove the process mark from all articles."
10592 (while gnus-newsgroup-processable
10593 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10594 (gnus-summary-position-point))
10596 (defun gnus-summary-add-mark (article type)
10597 "Mark ARTICLE with a mark of TYPE."
10598 (let ((vtype (car (assq type gnus-article-mark-lists)))
10601 (error "No such mark type: %s" type)
10602 (setq var (intern (format "gnus-newsgroup-%s" type)))
10603 (set var (cons article (symbol-value var)))
10604 (if (memq type '(processable cached replied forwarded recent saved))
10605 (gnus-summary-update-secondary-mark article)
10606 ;;; !!! This is bogus. We should find out what primary
10607 ;;; !!! mark we want to set.
10608 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10610 (defun gnus-summary-mark-as-expirable (n)
10611 "Mark N articles forward as expirable.
10612 If N is negative, mark backward instead. The difference between N and
10613 the actual number of articles marked is returned."
10615 (gnus-summary-mark-forward n gnus-expirable-mark))
10617 (defun gnus-summary-mark-as-spam (n)
10618 "Mark N articles forward as spam.
10619 If N is negative, mark backward instead. The difference between N and
10620 the actual number of articles marked is returned."
10622 (gnus-summary-mark-forward n gnus-spam-mark))
10624 (defun gnus-summary-mark-article-as-replied (article)
10625 "Mark ARTICLE as replied to and update the summary line.
10626 ARTICLE can also be a list of articles."
10627 (interactive (list (gnus-summary-article-number)))
10628 (let ((articles (if (listp article) article (list article))))
10629 (dolist (article articles)
10630 (unless (numberp article)
10631 (error "%s is not a number" article))
10632 (push article gnus-newsgroup-replied)
10633 (let ((inhibit-read-only t))
10634 (when (gnus-summary-goto-subject article nil t)
10635 (gnus-summary-update-secondary-mark article))))))
10637 (defun gnus-summary-mark-article-as-forwarded (article)
10638 "Mark ARTICLE as forwarded and update the summary line.
10639 ARTICLE can also be a list of articles."
10640 (let ((articles (if (listp article) article (list article))))
10641 (dolist (article articles)
10642 (push article gnus-newsgroup-forwarded)
10643 (let ((inhibit-read-only t))
10644 (when (gnus-summary-goto-subject article nil t)
10645 (gnus-summary-update-secondary-mark article))))))
10647 (defun gnus-summary-set-bookmark (article)
10648 "Set a bookmark in current article."
10649 (interactive (list (gnus-summary-article-number)))
10650 (when (or (not (get-buffer gnus-article-buffer))
10651 (not gnus-current-article)
10652 (not gnus-article-current)
10653 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10654 (error "No current article selected"))
10655 ;; Remove old bookmark, if one exists.
10656 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10657 ;; Set the new bookmark, which is on the form
10658 ;; (article-number . line-number-in-body).
10661 (with-current-buffer gnus-article-buffer
10665 (article-goto-body)
10668 gnus-newsgroup-bookmarks)
10669 (gnus-message 6 "A bookmark has been added to the current article."))
10671 (defun gnus-summary-remove-bookmark (article)
10672 "Remove the bookmark from the current article."
10673 (interactive (list (gnus-summary-article-number)))
10674 ;; Remove old bookmark, if one exists.
10675 (if (not (assq article gnus-newsgroup-bookmarks))
10676 (gnus-message 6 "No bookmark in current article.")
10677 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10678 (gnus-message 6 "Removed bookmark.")))
10680 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10681 (defun gnus-summary-mark-as-dormant (n)
10682 "Mark N articles forward as dormant.
10683 If N is negative, mark backward instead. The difference between N and
10684 the actual number of articles marked is returned."
10686 (gnus-summary-mark-forward n gnus-dormant-mark))
10688 (defun gnus-summary-set-process-mark (article)
10689 "Set the process mark on ARTICLE and update the summary line."
10690 (setq gnus-newsgroup-processable
10692 (delq article gnus-newsgroup-processable)))
10693 (when (gnus-summary-goto-subject article)
10694 (gnus-summary-show-thread)
10695 (gnus-summary-goto-subject article)
10696 (gnus-summary-update-secondary-mark article)))
10698 (defun gnus-summary-remove-process-mark (&rest articles)
10699 "Remove the process mark from ARTICLES and update the summary line."
10700 (dolist (article articles)
10701 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10702 (when (gnus-summary-goto-subject article)
10703 (gnus-summary-show-thread)
10704 (gnus-summary-goto-subject article)
10705 (gnus-summary-update-secondary-mark article)))
10708 (defun gnus-summary-set-saved-mark (article)
10709 "Set the process mark on ARTICLE and update the summary line."
10710 (push article gnus-newsgroup-saved)
10711 (when (gnus-summary-goto-subject article)
10712 (gnus-summary-update-secondary-mark article)))
10714 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10715 "Mark N articles as read forwards.
10716 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10717 The difference between N and the actual number of articles marked is
10719 If NO-EXPIRE, auto-expiry will be inhibited."
10721 (gnus-summary-show-thread)
10722 (let ((backward (< n 0))
10723 (gnus-summary-goto-unread
10724 (and gnus-summary-goto-unread
10725 (not (eq gnus-summary-goto-unread 'never))
10726 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10727 gnus-ticked-mark gnus-dormant-mark)))))
10729 (mark (or mark gnus-del-mark)))
10730 (while (and (> n 0)
10731 (gnus-summary-mark-article nil mark no-expire)
10732 (zerop (gnus-summary-next-subject
10734 (and gnus-summary-goto-unread
10735 (not (eq gnus-summary-goto-unread 'never)))
10739 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10740 (gnus-summary-recenter)
10741 (gnus-summary-position-point)
10742 (gnus-set-mode-line 'summary)
10745 (defun gnus-summary-mark-article-as-read (mark)
10746 "Mark the current article quickly as read with MARK."
10747 (let ((article (gnus-summary-article-number)))
10748 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10749 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10750 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10751 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10752 (push (cons article mark) gnus-newsgroup-reads)
10753 ;; Possibly remove from cache, if that is used.
10754 (when gnus-use-cache
10755 (gnus-cache-enter-remove-article article))
10756 ;; Allow the backend to change the mark.
10757 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10758 ;; Check for auto-expiry.
10759 (when (and gnus-newsgroup-auto-expire
10760 (memq mark gnus-auto-expirable-marks))
10761 (setq mark gnus-expirable-mark)
10762 ;; Let the backend know about the mark change.
10763 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10764 (push article gnus-newsgroup-expirable))
10765 ;; Set the mark in the buffer.
10766 (gnus-summary-update-mark mark 'unread)
10769 (defun gnus-summary-mark-article-as-unread (mark)
10770 "Mark the current article quickly as unread with MARK."
10771 (let* ((article (gnus-summary-article-number))
10772 (old-mark (gnus-summary-article-mark article)))
10773 ;; Allow the backend to change the mark.
10774 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10775 (if (eq mark old-mark)
10779 (gnus-error 1 "Can't mark negative article numbers")
10781 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10782 (setq gnus-newsgroup-spam-marked
10783 (delq article gnus-newsgroup-spam-marked))
10784 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10785 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10786 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10787 (cond ((= mark gnus-ticked-mark)
10788 (setq gnus-newsgroup-marked
10789 (gnus-add-to-sorted-list gnus-newsgroup-marked
10791 ((= mark gnus-spam-mark)
10792 (setq gnus-newsgroup-spam-marked
10793 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10795 ((= mark gnus-dormant-mark)
10796 (setq gnus-newsgroup-dormant
10797 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10800 (setq gnus-newsgroup-unreads
10801 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10803 (gnus-alist-pull article gnus-newsgroup-reads)
10805 ;; See whether the article is to be put in the cache.
10806 (and gnus-use-cache
10807 (vectorp (gnus-summary-article-header article))
10809 (gnus-cache-possibly-enter-article
10810 gnus-newsgroup-name article
10811 (= mark gnus-ticked-mark)
10812 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10815 (gnus-summary-update-mark mark 'unread)
10818 (defun gnus-summary-mark-article (&optional article mark no-expire)
10819 "Mark ARTICLE with MARK. MARK can be any character.
10820 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10821 `??' (dormant) and `?E' (expirable).
10822 If MARK is nil, then the default character `?r' is used.
10823 If ARTICLE is nil, then the article on the current line will be
10825 If NO-EXPIRE, auto-expiry will be inhibited."
10826 ;; The mark might be a string.
10827 (when (stringp mark)
10828 (setq mark (aref mark 0)))
10829 ;; If no mark is given, then we check auto-expiring.
10831 (setq mark gnus-del-mark))
10832 (when (and (not no-expire)
10833 gnus-newsgroup-auto-expire
10834 (memq mark gnus-auto-expirable-marks))
10835 (setq mark gnus-expirable-mark))
10836 (let ((article (or article (gnus-summary-article-number)))
10837 (old-mark (gnus-summary-article-mark article)))
10838 ;; Allow the backend to change the mark.
10839 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10840 (if (eq mark old-mark)
10843 (error "No article on current line"))
10844 (if (not (if (or (= mark gnus-unread-mark)
10845 (= mark gnus-ticked-mark)
10846 (= mark gnus-spam-mark)
10847 (= mark gnus-dormant-mark))
10848 (gnus-mark-article-as-unread article mark)
10849 (gnus-mark-article-as-read article mark)))
10851 ;; See whether the article is to be put in the cache.
10852 (and gnus-use-cache
10853 (not (= mark gnus-canceled-mark))
10854 (vectorp (gnus-summary-article-header article))
10856 (gnus-cache-possibly-enter-article
10857 gnus-newsgroup-name article
10858 (= mark gnus-ticked-mark)
10859 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10861 (when (gnus-summary-goto-subject article nil t)
10862 (let ((inhibit-read-only t))
10863 (gnus-summary-show-thread)
10865 (gnus-summary-update-mark mark 'unread)
10868 (defun gnus-summary-update-secondary-mark (article)
10869 "Update the secondary (read, process, cache) mark."
10870 (gnus-summary-update-mark
10871 (cond ((memq article gnus-newsgroup-processable)
10873 ((memq article gnus-newsgroup-cached)
10875 ((memq article gnus-newsgroup-replied)
10877 ((memq article gnus-newsgroup-forwarded)
10878 gnus-forwarded-mark)
10879 ((memq article gnus-newsgroup-saved)
10881 ((memq article gnus-newsgroup-recent)
10883 ((memq article gnus-newsgroup-unseen)
10887 (when (gnus-visual-p 'summary-highlight 'highlight)
10888 (gnus-summary-highlight-line)
10889 (gnus-run-hooks 'gnus-summary-update-hook))
10892 (defun gnus-summary-update-download-mark (article)
10893 "Update the download mark."
10894 (gnus-summary-update-mark
10895 (cond ((memq article gnus-newsgroup-undownloaded)
10896 gnus-undownloaded-mark)
10897 (gnus-newsgroup-agentized
10898 gnus-downloaded-mark)
10902 (gnus-summary-update-line t)
10905 (defun gnus-summary-update-mark (mark type)
10906 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10907 (inhibit-read-only t))
10908 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10910 (when (looking-at "\r")
10912 (when (<= (+ forward (point)) (point-max))
10913 ;; Go to the right position on the line.
10914 (goto-char (+ forward (point)))
10915 ;; Replace the old mark with the new mark.
10917 (mm-subst-char-in-string
10919 (buffer-substring (point) (1+ (point))))))
10920 (delete-region (point) (1+ (point)))
10921 (insert to-insert))
10922 ;; Optionally update the marks by some user rule.
10923 (when (eq type 'unread)
10924 (gnus-data-set-mark
10925 (gnus-data-find (gnus-summary-article-number)) mark)
10926 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10928 (defun gnus-mark-article-as-read (article &optional mark)
10929 "Enter ARTICLE in the pertinent lists and remove it from others."
10930 ;; Make the article expirable.
10931 (let ((mark (or mark gnus-del-mark)))
10932 (setq gnus-newsgroup-expirable
10933 (if (= mark gnus-expirable-mark)
10934 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10935 (delq article gnus-newsgroup-expirable)))
10936 ;; Remove from unread and marked lists.
10937 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10938 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10939 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10940 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10941 (push (cons article mark) gnus-newsgroup-reads)
10942 ;; Possibly remove from cache, if that is used.
10943 (when gnus-use-cache
10944 (gnus-cache-enter-remove-article article))
10947 (defun gnus-mark-article-as-unread (article &optional mark)
10948 "Enter ARTICLE in the pertinent lists and remove it from others."
10949 (let ((mark (or mark gnus-ticked-mark)))
10952 (gnus-error 1 "Can't mark negative article numbers")
10954 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10955 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10956 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10957 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10958 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10960 ;; Unsuppress duplicates?
10961 (when gnus-suppress-duplicates
10962 (gnus-dup-unsuppress-article article))
10964 (cond ((= mark gnus-ticked-mark)
10965 (setq gnus-newsgroup-marked
10966 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10967 ((= mark gnus-spam-mark)
10968 (setq gnus-newsgroup-spam-marked
10969 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10971 ((= mark gnus-dormant-mark)
10972 (setq gnus-newsgroup-dormant
10973 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10975 (setq gnus-newsgroup-unreads
10976 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10977 (gnus-alist-pull article gnus-newsgroup-reads)
10980 (defun gnus-summary-tick-article-forward (n)
10981 "Tick N articles forwards.
10982 If N is negative, tick backwards instead.
10983 The difference between N and the number of articles ticked is returned."
10985 (gnus-summary-mark-forward n gnus-ticked-mark))
10987 (defun gnus-summary-tick-article-backward (n)
10988 "Tick N articles backwards.
10989 The difference between N and the number of articles ticked is returned."
10991 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10993 (defun gnus-summary-tick-article (&optional article clear-mark)
10994 "Mark current article as unread.
10995 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10996 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10998 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10999 gnus-ticked-mark)))
11001 (defun gnus-summary-mark-as-read-forward (n)
11002 "Mark N articles as read forwards.
11003 If N is negative, mark backwards instead.
11004 The difference between N and the actual number of articles marked is
11007 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11009 (defun gnus-summary-mark-as-read-backward (n)
11010 "Mark the N articles as read backwards.
11011 The difference between N and the actual number of articles marked is
11014 (gnus-summary-mark-forward
11015 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11017 (defun gnus-summary-mark-as-read (&optional article mark)
11018 "Mark current article as read.
11019 ARTICLE specifies the article to be marked as read.
11020 MARK specifies a string to be inserted at the beginning of the line."
11021 (gnus-summary-mark-article article mark))
11023 (defun gnus-summary-clear-mark-forward (n)
11024 "Clear marks from N articles forward.
11025 If N is negative, clear backward instead.
11026 The difference between N and the number of marks cleared is returned."
11028 (gnus-summary-mark-forward n gnus-unread-mark))
11030 (defun gnus-summary-clear-mark-backward (n)
11031 "Clear marks from N articles backward.
11032 The difference between N and the number of marks cleared is returned."
11034 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11036 (defun gnus-summary-mark-unread-as-read ()
11037 "Intended to be used by `gnus-mark-article-hook'."
11038 (when (memq gnus-current-article gnus-newsgroup-unreads)
11039 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11041 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11042 "Intended to be used by `gnus-mark-article-hook'."
11043 (let ((mark (gnus-summary-article-mark)))
11044 (when (or (gnus-unread-mark-p mark)
11045 (gnus-read-mark-p mark))
11046 (gnus-summary-mark-article gnus-current-article
11047 (or new-mark gnus-read-mark)))))
11049 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11050 "Intended to be used by `gnus-mark-article-hook'."
11051 (let ((mark (gnus-summary-article-mark)))
11052 (when (or (gnus-unread-mark-p mark)
11053 (gnus-read-mark-p mark))
11054 (gnus-summary-mark-article (gnus-summary-article-number)
11055 (or new-mark gnus-read-mark)))))
11057 (defun gnus-summary-mark-unread-as-ticked ()
11058 "Intended to be used by `gnus-mark-article-hook'."
11059 (when (memq gnus-current-article gnus-newsgroup-unreads)
11060 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11062 (defun gnus-summary-mark-region-as-read (point mark all)
11063 "Mark all unread articles between point and mark as read.
11064 If given a prefix, mark all articles between point and mark as read,
11065 even ticked and dormant ones."
11066 (interactive "r\nP")
11070 (beginning-of-line)
11075 (memq (setq article (gnus-summary-article-number))
11076 gnus-newsgroup-unreads))
11077 (gnus-summary-mark-article article gnus-del-mark))
11079 (gnus-summary-find-next))))))
11081 (defun gnus-summary-mark-below (score mark)
11082 "Mark articles with score less than SCORE with MARK."
11083 (interactive "P\ncMark: ")
11084 (setq score (if score
11085 (prefix-numeric-value score)
11086 (or gnus-summary-default-score 0)))
11087 (with-current-buffer gnus-summary-buffer
11088 (goto-char (point-min))
11091 (and (< (gnus-summary-article-score) score)
11092 (gnus-summary-mark-article nil mark))
11093 (gnus-summary-find-next)))))
11095 (defun gnus-summary-kill-below (&optional score)
11096 "Mark articles with score below SCORE as read."
11098 (gnus-summary-mark-below score gnus-killed-mark))
11100 (defun gnus-summary-clear-above (&optional score)
11101 "Clear all marks from articles with score above SCORE."
11103 (gnus-summary-mark-above score gnus-unread-mark))
11105 (defun gnus-summary-tick-above (&optional score)
11106 "Tick all articles with score above SCORE."
11108 (gnus-summary-mark-above score gnus-ticked-mark))
11110 (defun gnus-summary-mark-above (score mark)
11111 "Mark articles with score over SCORE with MARK."
11112 (interactive "P\ncMark: ")
11113 (setq score (if score
11114 (prefix-numeric-value score)
11115 (or gnus-summary-default-score 0)))
11116 (with-current-buffer gnus-summary-buffer
11117 (goto-char (point-min))
11119 (when (> (gnus-summary-article-score) score)
11120 (gnus-summary-mark-article nil mark))
11122 (gnus-summary-find-next)))))
11124 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11125 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11126 (defun gnus-summary-limit-include-expunged (&optional no-error)
11127 "Display all the hidden articles that were expunged for low scores."
11129 (let ((inhibit-read-only t))
11130 (let ((scored gnus-newsgroup-scored)
11133 (unless (gnus-summary-article-header (caar scored))
11134 (and (setq h (gnus-number-to-header (caar scored)))
11135 (< (cdar scored) gnus-summary-expunge-below)
11137 (setq scored (cdr scored)))
11139 (when (not no-error)
11140 (error "No expunged articles hidden"))
11141 (goto-char (point-min))
11142 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11143 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11144 (dolist (x headers)
11145 (push (mail-header-number x) gnus-newsgroup-limit))
11146 (gnus-summary-prepare-unthreaded (nreverse headers))
11147 (goto-char (point-min))
11148 (gnus-summary-position-point)
11151 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11152 "Mark all unread articles in this newsgroup as read.
11153 If prefix argument ALL is non-nil, ticked and dormant articles will
11154 also be marked as read.
11155 If QUIETLY is non-nil, no questions will be asked.
11157 If TO-HERE is non-nil, it should be a point in the buffer. All
11158 articles before (after, if REVERSE is set) this point will be marked
11161 Note that this function will only catch up the unread article
11162 in the current summary buffer limitation.
11164 The number of articles marked as read is returned."
11169 (not gnus-interactive-catchup) ;Without confirmation?
11173 "Mark absolutely all articles as read? "
11174 "Mark all unread articles as read? ")))
11176 (not gnus-newsgroup-adaptive)
11177 (not gnus-newsgroup-auto-expire)
11178 (not gnus-suppress-duplicates)
11179 (or (not gnus-use-cache)
11180 (eq gnus-use-cache 'passive)))
11183 (setq gnus-newsgroup-marked nil
11184 gnus-newsgroup-spam-marked nil
11185 gnus-newsgroup-dormant nil))
11186 (setq gnus-newsgroup-unreads
11187 (gnus-sorted-nunion
11188 (gnus-sorted-intersection gnus-newsgroup-unreads
11189 gnus-newsgroup-downloadable)
11190 (gnus-sorted-difference gnus-newsgroup-unfetched
11191 gnus-newsgroup-cached))))
11192 ;; We actually mark all articles as canceled, which we
11193 ;; have to do when using auto-expiry or adaptive scoring.
11194 (gnus-summary-show-all-threads)
11195 (if (and to-here reverse)
11197 (goto-char to-here)
11198 (gnus-summary-mark-current-read-and-unread-as-read
11200 (while (gnus-summary-find-next (not all))
11201 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11202 (when (gnus-summary-first-subject (not all))
11204 (if to-here (< (point) to-here) t)
11205 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11206 (gnus-summary-find-next (not all))))))
11207 (gnus-set-mode-line 'summary))
11209 (gnus-summary-position-point)))
11211 (defun gnus-summary-catchup-to-here (&optional all)
11212 "Mark all unticked articles before the current one as read.
11213 If ALL is non-nil, also mark ticked and dormant articles as read."
11216 (gnus-save-hidden-threads
11217 (let ((beg (point)))
11218 ;; We check that there are unread articles.
11219 (when (or all (gnus-summary-find-prev))
11220 (gnus-summary-catchup all t beg)))))
11221 (gnus-summary-position-point))
11223 (defun gnus-summary-catchup-from-here (&optional all)
11224 "Mark all unticked articles after (and including) the current one as read.
11225 If ALL is non-nil, also mark ticked and dormant articles as read."
11228 (gnus-save-hidden-threads
11229 (let ((beg (point)))
11230 ;; We check that there are unread articles.
11231 (when (or all (gnus-summary-find-next))
11232 (gnus-summary-catchup all t beg nil t)))))
11233 (gnus-summary-position-point))
11235 (defun gnus-summary-catchup-all (&optional quietly)
11236 "Mark all articles in this newsgroup as read.
11237 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11238 instead, which marks only unread articles as read."
11240 (gnus-summary-catchup t quietly))
11242 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11243 "Mark all unread articles in this group as read, then exit.
11244 If prefix argument ALL is non-nil, all articles are marked as read.
11245 If QUIETLY is non-nil, no questions will be asked."
11247 (when (gnus-summary-catchup all quietly nil 'fast)
11248 ;; Select next newsgroup or exit.
11249 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11250 (eq gnus-auto-select-next 'quietly))
11251 (gnus-summary-next-group nil)
11252 (gnus-summary-exit))))
11254 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11255 "Mark all articles in this newsgroup as read, and then exit.
11256 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11257 instead, which marks only unread articles as read."
11259 (gnus-summary-catchup-and-exit t quietly))
11261 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11262 "Mark all articles in this group as read and select the next group.
11263 If given a prefix, mark all articles, unread as well as ticked, as
11267 (gnus-summary-catchup all))
11268 (gnus-summary-next-group))
11270 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11271 "Mark all articles in this group as read and select the previous group.
11272 If given a prefix, mark all articles, unread as well as ticked, as
11276 (gnus-summary-catchup all))
11277 (gnus-summary-next-group nil nil t))
11283 (defmacro gnus-with-article (article &rest forms)
11284 "Select ARTICLE and perform FORMS in the original article buffer.
11285 Then replace the article with the result."
11287 ;; We don't want the article to be marked as read.
11288 (let (gnus-mark-article-hook)
11289 (gnus-summary-select-article t t nil ,article))
11290 (set-buffer gnus-original-article-buffer)
11292 (if (not (gnus-check-backend-function
11293 'request-replace-article (car gnus-article-current)))
11294 (gnus-message 5 "Read-only group; not replacing")
11295 (unless (gnus-request-replace-article
11296 ,article (car gnus-article-current)
11297 (current-buffer) t)
11298 (error "Couldn't replace article")))
11299 ;; The cache and backlog have to be flushed somewhat.
11300 (when gnus-keep-backlog
11301 (gnus-backlog-remove-article
11302 (car gnus-article-current) (cdr gnus-article-current)))
11303 (when gnus-use-cache
11304 (gnus-cache-update-article
11305 (car gnus-article-current) (cdr gnus-article-current)))))
11307 (put 'gnus-with-article 'lisp-indent-function 1)
11308 (put 'gnus-with-article 'edebug-form-spec '(form body))
11310 ;; Thread-based commands.
11312 (defun gnus-summary-articles-in-thread (&optional article)
11313 "Return a list of all articles in the current thread.
11314 If ARTICLE is non-nil, return all articles in the thread that starts
11315 with that article."
11316 (let* ((article (or article (gnus-summary-article-number)))
11317 (data (gnus-data-find-list article))
11318 (top-level (gnus-data-level (car data)))
11320 (cond ((null gnus-thread-operation-ignore-subject)
11321 (gnus-simplify-subject-re
11322 (mail-header-subject (gnus-data-header (car data)))))
11323 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11324 (gnus-simplify-subject-fuzzy
11325 (mail-header-subject (gnus-data-header (car data)))))
11327 (end-point (save-excursion
11328 (goto-char (gnus-data-pos (car data)))
11329 (if (gnus-summary-go-to-next-thread)
11330 (point) (point-max))))
11333 (< (gnus-data-pos (car data)) end-point))
11334 (when (or (not top-subject)
11335 (string= top-subject
11336 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11337 (gnus-simplify-subject-fuzzy
11338 (mail-header-subject
11339 (gnus-data-header (car data))))
11340 (gnus-simplify-subject-re
11341 (mail-header-subject
11342 (gnus-data-header (car data)))))))
11343 (push (gnus-data-number (car data)) articles))
11344 (unless (and (setq data (cdr data))
11345 (> (gnus-data-level (car data)) top-level))
11347 ;; Return the list of articles.
11348 (nreverse articles)))
11350 (defun gnus-summary-rethread-current ()
11351 "Rethread the thread the current article is part of."
11353 (let* ((gnus-show-threads t)
11354 (article (gnus-summary-article-number))
11355 (id (mail-header-id (gnus-summary-article-header)))
11356 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11358 (error "No article on the current line"))
11359 (gnus-rebuild-thread id)
11360 (gnus-summary-goto-subject article)))
11362 (defun gnus-summary-reparent-thread ()
11363 "Make the current article child of the marked (or previous) article.
11365 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11366 is non-nil or the Subject: of both articles are the same."
11368 (unless (not (gnus-group-read-only-p))
11369 (error "The current newsgroup does not support article editing"))
11370 (unless (<= (length gnus-newsgroup-processable) 1)
11371 (error "No more than one article may be marked"))
11372 (let ((child (gnus-summary-article-number))
11373 ;; First grab the marked article, otherwise one line up.
11374 (parent (if (not (null gnus-newsgroup-processable))
11375 (car gnus-newsgroup-processable)
11377 (if (eq (forward-line -1) 0)
11378 (gnus-summary-article-number)
11379 (error "Beginning of summary buffer"))))))
11380 (gnus-summary-reparent-children parent (list child))))
11382 (defun gnus-summary-reparent-children (parent children)
11383 "Make PARENT the parent of CHILDREN.
11384 When called interactively, PARENT is the current article and CHILDREN
11385 are the process-marked articles."
11387 (list (gnus-summary-article-number)
11388 (gnus-summary-work-articles nil)))
11389 (dolist (child children)
11390 (save-window-excursion
11391 (let ((gnus-article-buffer " *reparent*"))
11392 (unless (not (eq parent child))
11393 (error "An article may not be self-referential"))
11394 (let ((message-id (mail-header-id
11395 (gnus-summary-article-header parent))))
11396 (unless (and message-id (not (equal message-id "")))
11397 (error "No message-id in desired parent"))
11398 (gnus-with-article child
11400 (goto-char (point-min))
11401 (message-narrow-to-head)
11402 (if (re-search-forward "^References: " nil t)
11404 (re-search-forward "^[^ \t]" nil t)
11407 (insert " " message-id))
11408 (insert "References: " message-id "\n"))))
11409 (set-buffer gnus-summary-buffer)
11410 (gnus-summary-unmark-all-processable)
11411 (gnus-summary-update-article child)
11412 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11413 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11414 (gnus-summary-rethread-current)
11415 (gnus-message 3 "Article %d is now the child of article %d"
11418 (defun gnus-summary-toggle-threads (&optional arg)
11419 "Toggle showing conversation threads.
11420 If ARG is positive number, turn showing conversation threads on."
11422 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11423 (setq gnus-show-threads
11424 (if (null arg) (not gnus-show-threads)
11425 (> (prefix-numeric-value arg) 0)))
11426 (gnus-summary-prepare)
11427 (gnus-summary-goto-subject current)
11428 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11429 (gnus-summary-position-point)))
11432 (if (fboundp 'remove-overlays)
11433 (defalias 'gnus-remove-overlays 'remove-overlays)
11434 (defun gnus-remove-overlays (beg end name val)
11435 "Clear BEG and END of overlays whose property NAME has value VAL.
11436 For compatibility with XEmacs."
11437 (dolist (ov (gnus-overlays-in beg end))
11438 (when (eq (gnus-overlay-get ov name) val)
11439 (gnus-delete-overlay ov))))))
11441 (defun gnus-summary-show-all-threads ()
11442 "Show all threads."
11444 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11445 (gnus-summary-position-point))
11447 (defsubst gnus-summary--inv (p)
11448 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11450 (defun gnus-summary-show-thread ()
11451 "Show thread subtrees.
11452 Returns nil if no thread was there to be shown."
11454 (let* ((orig (point))
11455 (end (point-at-eol))
11456 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11457 ;; Leave point at bol
11458 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11460 (if (fboundp 'next-single-char-property-change)
11461 (or (next-single-char-property-change end 'invisible)
11466 (eq (get-char-property (point) 'invisible)
11470 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11472 (gnus-summary-position-point)
11475 (defun gnus-summary-maybe-hide-threads ()
11476 "If requested, hide the threads that should be hidden."
11477 (when (and gnus-show-threads
11478 gnus-thread-hide-subtree)
11479 (gnus-summary-hide-all-threads
11480 (if (or (consp gnus-thread-hide-subtree)
11481 (functionp gnus-thread-hide-subtree))
11482 (gnus-make-predicate gnus-thread-hide-subtree)
11485 ;;; Hiding predicates.
11487 (defun gnus-article-unread-p (header)
11488 (memq (mail-header-number header) gnus-newsgroup-unreads))
11490 (defun gnus-article-unseen-p (header)
11491 (memq (mail-header-number header) gnus-newsgroup-unseen))
11493 (defun gnus-map-articles (predicate articles)
11494 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11495 (apply 'gnus-or (mapcar predicate
11496 (mapcar (lambda (number)
11497 (gnus-summary-article-header number))
11500 (defun gnus-summary-hide-all-threads (&optional predicate)
11501 "Hide all thread subtrees.
11502 If PREDICATE is supplied, threads that satisfy this predicate
11503 will not be hidden."
11506 (goto-char (point-min))
11509 (when (or (not predicate)
11511 predicate (gnus-summary-article-children)))
11512 (gnus-summary-hide-thread))
11513 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11514 (gnus-summary-position-point))
11516 (defun gnus-summary-hide-thread ()
11517 "Hide thread subtrees.
11518 If PREDICATE is supplied, threads that satisfy this predicate
11519 will not be hidden.
11520 Returns nil if no threads were there to be hidden."
11522 (let ((start (point))
11523 (starteol (line-end-position))
11524 (article (gnus-summary-article-number)))
11526 ;; Go forward until either the buffer ends or the subthread ends.
11527 (when (and (not (eobp))
11528 (or (zerop (gnus-summary-next-thread 1 t))
11529 (goto-char (point-max))))
11530 (if (and (> (point) start)
11531 ;; FIXME: this should actually search for a non-invisible \n.
11532 (search-backward "\n" start t))
11534 (when (> (point) starteol)
11535 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11536 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11537 (gnus-overlay-put ol 'invisible 'gnus-sum)
11538 (gnus-overlay-put ol 'evaporate t)))
11539 (gnus-summary-goto-subject article))
11543 (defun gnus-summary-go-to-next-thread (&optional previous)
11544 "Go to the same level (or less) next thread.
11545 If PREVIOUS is non-nil, go to previous thread instead.
11546 Return the article number moved to, or nil if moving was impossible."
11547 (let ((level (gnus-summary-thread-level))
11548 (way (if previous -1 1))
11551 (while (and (not (eobp))
11552 (< level (gnus-summary-thread-level)))
11553 (forward-line way))
11560 (gnus-summary-article-number)
11561 (goto-char beg)))))
11563 (defun gnus-summary-next-thread (n &optional silent)
11564 "Go to the same level next N'th thread.
11565 If N is negative, search backward instead.
11566 Returns the difference between N and the number of skips actually
11569 If SILENT, don't output messages."
11571 (let ((backward (< n 0))
11573 (while (and (> n 0)
11574 (gnus-summary-go-to-next-thread backward))
11577 (gnus-summary-position-point))
11578 (when (and (not silent) (/= 0 n))
11579 (gnus-message 7 "No more threads"))
11582 (defun gnus-summary-prev-thread (n)
11583 "Go to the same level previous N'th thread.
11584 Returns the difference between N and the number of skips actually
11587 (gnus-summary-next-thread (- n)))
11589 (defun gnus-summary-go-down-thread ()
11590 "Go down one level in the current thread."
11591 (let ((children (gnus-summary-article-children)))
11593 (gnus-summary-goto-subject (car children)))))
11595 (defun gnus-summary-go-up-thread ()
11596 "Go up one level in the current thread."
11597 (let ((parent (gnus-summary-article-parent)))
11599 (gnus-summary-goto-subject parent))))
11601 (defun gnus-summary-down-thread (n)
11602 "Go down thread N steps.
11603 If N is negative, go up instead.
11604 Returns the difference between N and how many steps down that were
11609 (while (and (> n 0)
11610 (if up (gnus-summary-go-up-thread)
11611 (gnus-summary-go-down-thread)))
11613 (gnus-summary-position-point)
11615 (gnus-message 7 "Can't go further"))
11618 (defun gnus-summary-up-thread (n)
11619 "Go up thread N steps.
11620 If N is negative, go down instead.
11621 Returns the difference between N and how many steps down that were
11624 (gnus-summary-down-thread (- n)))
11626 (defun gnus-summary-top-thread ()
11627 "Go to the top of the thread."
11629 (while (gnus-summary-go-up-thread))
11630 (gnus-summary-article-number))
11632 (defun gnus-summary-expire-thread ()
11633 "Mark articles under current thread as expired."
11635 (gnus-summary-kill-thread 0))
11637 (defun gnus-summary-kill-thread (&optional unmark)
11638 "Mark articles under current thread as read.
11639 If the prefix argument is positive, remove any kinds of marks.
11640 If the prefix argument is zero, mark thread as expired.
11641 If the prefix argument is negative, tick articles instead."
11644 (setq unmark (prefix-numeric-value unmark)))
11645 (let ((articles (gnus-summary-articles-in-thread))
11646 (hide (or (null unmark) (= unmark 0))))
11648 ;; Expand the thread.
11649 (gnus-summary-show-thread)
11650 ;; Mark all the articles.
11652 (gnus-summary-goto-subject (car articles))
11653 (cond ((null unmark)
11654 (gnus-summary-mark-article-as-read gnus-killed-mark))
11656 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11658 (gnus-summary-mark-article nil gnus-expirable-mark))
11660 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11661 (setq articles (cdr articles))))
11662 ;; Hide killed subtrees when hide is true.
11664 gnus-thread-hide-killed
11665 (gnus-summary-hide-thread))
11666 ;; If hide is t, go to next unread subject.
11668 ;; Go to next unread subject.
11669 (gnus-summary-next-subject 1 t)))
11670 (gnus-set-mode-line 'summary))
11672 ;; Summary sorting commands
11674 (defun gnus-summary-sort-by-number (&optional reverse)
11675 "Sort the summary buffer by article number.
11676 Argument REVERSE means reverse order."
11678 (gnus-summary-sort 'number reverse))
11680 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11681 "Sort the summary buffer by most recent article number.
11682 Argument REVERSE means reverse order."
11684 (gnus-summary-sort 'most-recent-number reverse))
11686 (defun gnus-summary-sort-by-random (&optional reverse)
11687 "Randomize the order in the summary buffer.
11688 Argument REVERSE means to randomize in reverse order."
11690 (gnus-summary-sort 'random reverse))
11692 (defun gnus-summary-sort-by-author (&optional reverse)
11693 "Sort the summary buffer by author name alphabetically.
11694 If `case-fold-search' is non-nil, case of letters is ignored.
11695 Argument REVERSE means reverse order."
11697 (gnus-summary-sort 'author reverse))
11699 (defun gnus-summary-sort-by-recipient (&optional reverse)
11700 "Sort the summary buffer by recipient name alphabetically.
11701 If `case-fold-search' is non-nil, case of letters is ignored.
11702 Argument REVERSE means reverse order."
11704 (gnus-summary-sort 'recipient reverse))
11706 (defun gnus-summary-sort-by-subject (&optional reverse)
11707 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11708 If `case-fold-search' is non-nil, case of letters is ignored.
11709 Argument REVERSE means reverse order."
11711 (gnus-summary-sort 'subject reverse))
11713 (defun gnus-summary-sort-by-date (&optional reverse)
11714 "Sort the summary buffer by date.
11715 Argument REVERSE means reverse order."
11717 (gnus-summary-sort 'date reverse))
11719 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11720 "Sort the summary buffer by most recent date.
11721 Argument REVERSE means reverse order."
11723 (gnus-summary-sort 'most-recent-date reverse))
11725 (defun gnus-summary-sort-by-score (&optional reverse)
11726 "Sort the summary buffer by score.
11727 Argument REVERSE means reverse order."
11729 (gnus-summary-sort 'score reverse))
11731 (defun gnus-summary-sort-by-lines (&optional reverse)
11732 "Sort the summary buffer by the number of lines.
11733 Argument REVERSE means reverse order."
11735 (gnus-summary-sort 'lines reverse))
11737 (defun gnus-summary-sort-by-chars (&optional reverse)
11738 "Sort the summary buffer by article length.
11739 Argument REVERSE means reverse order."
11741 (gnus-summary-sort 'chars reverse))
11743 (defun gnus-summary-sort-by-original (&optional reverse)
11744 "Sort the summary buffer using the default sorting method.
11745 Argument REVERSE means reverse order."
11747 (let* ((inhibit-read-only t)
11748 (gnus-summary-prepare-hook nil))
11749 ;; We do the sorting by regenerating the threads.
11750 (gnus-summary-prepare)
11751 ;; Hide subthreads if needed.
11752 (gnus-summary-maybe-hide-threads)))
11754 (defun gnus-summary-sort (predicate reverse)
11755 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11756 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11757 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11758 (gnus-thread-sort-functions
11763 (gnus-sort-gathered-threads-function
11764 gnus-thread-sort-functions)
11765 (gnus-article-sort-functions
11769 (,article t2 t1))))
11770 (inhibit-read-only t)
11771 (gnus-summary-prepare-hook nil))
11772 ;; We do the sorting by regenerating the threads.
11773 (gnus-summary-prepare)
11774 ;; Hide subthreads if needed.
11775 (gnus-summary-maybe-hide-threads)))
11777 ;; Summary saving commands.
11779 (defun gnus-summary-save-article (&optional n not-saved)
11780 "Save the current article using the default saver function.
11781 If N is a positive number, save the N next articles.
11782 If N is a negative number, save the N previous articles.
11783 If N is nil and any articles have been marked with the process mark,
11784 save those articles instead.
11785 The variable `gnus-default-article-saver' specifies the saver function.
11787 If the optional second argument NOT-SAVED is non-nil, articles saved
11788 will not be marked as saved."
11790 (require 'gnus-art)
11791 (let* ((articles (gnus-summary-work-articles n))
11792 (save-buffer (save-excursion
11793 (nnheader-set-temp-buffer " *Gnus Save*")))
11794 (num (length articles))
11795 ;; Whether to save decoded articles or raw articles.
11796 (decode (when gnus-article-save-coding-system
11797 (get gnus-default-article-saver :decode)))
11798 ;; When saving many articles in a single file, use the other
11799 ;; function to save articles other than the first one.
11800 (saver2 (get gnus-default-article-saver :function))
11801 (gnus-prompt-before-saving (if saver2
11803 gnus-prompt-before-saving))
11804 (gnus-default-article-saver gnus-default-article-saver)
11806 (dolist (article articles)
11807 (setq header (gnus-summary-article-header article))
11808 (if (not (vectorp header))
11809 ;; This is a pseudo-article.
11810 (if (assq 'name header)
11811 (gnus-copy-file (cdr (assq 'name header)))
11812 (gnus-message 1 "Article %d is unsaveable" article))
11813 ;; This is a real article.
11814 (save-window-excursion
11815 (gnus-summary-select-article decode decode nil article)
11816 (gnus-summary-goto-subject article))
11817 (with-current-buffer save-buffer
11819 (insert-buffer-substring (if decode
11820 gnus-article-buffer
11821 gnus-original-article-buffer)))
11822 (setq file (gnus-article-save save-buffer file num))
11823 (gnus-summary-remove-process-mark article)
11825 (gnus-summary-set-saved-mark article)))
11827 (setq gnus-default-article-saver saver2
11829 (gnus-kill-buffer save-buffer)
11830 (gnus-summary-position-point)
11831 (gnus-set-mode-line 'summary)
11834 (defun gnus-summary-pipe-output (&optional n sym)
11835 "Pipe the current article to a subprocess.
11836 If N is a positive number, pipe the N next articles.
11837 If N is a negative number, pipe the N previous articles.
11838 If N is nil and any articles have been marked with the process mark,
11839 pipe those articles instead.
11840 The default command to which articles are piped is specified by the
11841 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11842 will be prompted for the command.
11844 The properties `:decode' and `:headers' that are put to the function
11845 symbol `gnus-summary-save-in-pipe' control whether this function
11846 decodes articles and what headers to keep (see the doc string for the
11847 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11848 is neither omitted nor the symbol `r', force including all headers
11849 regardless of the `:headers' property. If it is the symbol `r',
11850 articles that are not decoded and include all headers will be piped
11851 no matter what the properties `:decode' and `:headers' are."
11852 (interactive (gnus-interactive "P\ny"))
11853 (require 'gnus-art)
11854 (let* ((articles (gnus-summary-work-articles n))
11855 (result-buffer "*Shell Command Output*")
11856 (all-headers (not (memq sym '(nil r))))
11857 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11859 (headers (get 'gnus-summary-save-in-pipe :headers))
11861 (unless (numberp (car articles))
11862 (error "No article to pipe"))
11863 (setq command (gnus-read-shell-command
11864 (concat "Shell command on "
11866 (format "these %d articles" (length articles))
11869 gnus-summary-pipe-output-default-command))
11870 (when (string-equal command "")
11871 (error "A command is required"))
11873 (put 'gnus-summary-save-in-pipe :headers nil))
11876 (gnus-summary-goto-subject (pop articles))
11877 (save-window-excursion (gnus-summary-save-in-pipe command raw))
11878 (when (and (get-buffer result-buffer)
11879 (not (zerop (buffer-size (get-buffer result-buffer)))))
11880 (setq result (concat result (with-current-buffer result-buffer
11881 (buffer-string))))))
11882 (put 'gnus-summary-save-in-pipe :headers headers))
11883 (unless (zerop (length result))
11884 (if (with-current-buffer (get-buffer-create result-buffer)
11888 (and (= (count-lines (point-min) (point)) 1)
11891 (<= (current-column)
11892 (window-width (minibuffer-window)))))
11893 (goto-char (point-min))))
11894 (message "%s" (substring result 0 -1))
11896 (gnus-configure-windows 'pipe)))))
11898 (defun gnus-summary-save-article-mail (&optional arg)
11899 "Append the current article to a Unix mail box file.
11900 If N is a positive number, save the N next articles.
11901 If N is a negative number, save the N previous articles.
11902 If N is nil and any articles have been marked with the process mark,
11903 save those articles instead."
11905 (require 'gnus-art)
11906 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11907 (gnus-summary-save-article arg)))
11909 (defun gnus-summary-save-article-rmail (&optional arg)
11910 "Append the current article to an rmail file.
11911 If N is a positive number, save the N next articles.
11912 If N is a negative number, save the N previous articles.
11913 If N is nil and any articles have been marked with the process mark,
11914 save those articles instead."
11916 (require 'gnus-art)
11917 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11918 (gnus-summary-save-article arg)))
11920 (defun gnus-summary-save-article-file (&optional arg)
11921 "Append the current article to a file.
11922 If N is a positive number, save the N next articles.
11923 If N is a negative number, save the N previous articles.
11924 If N is nil and any articles have been marked with the process mark,
11925 save those articles instead."
11927 (require 'gnus-art)
11928 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11929 (gnus-summary-save-article arg)))
11931 (defun gnus-summary-write-article-file (&optional arg)
11932 "Write the current article to a file, deleting the previous file.
11933 If N is a positive number, save the N next articles.
11934 If N is a negative number, save the N previous articles.
11935 If N is nil and any articles have been marked with the process mark,
11936 save those articles instead."
11938 (require 'gnus-art)
11939 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11940 (gnus-summary-save-article arg)))
11942 (defun gnus-summary-save-article-body-file (&optional arg)
11943 "Append the current article body to a file.
11944 If N is a positive number, save the N next articles.
11945 If N is a negative number, save the N previous articles.
11946 If N is nil and any articles have been marked with the process mark,
11947 save those articles instead."
11949 (require 'gnus-art)
11950 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11951 (gnus-summary-save-article arg)))
11953 (defun gnus-summary-write-article-body-file (&optional arg)
11954 "Write the current article body to a file, deleting the previous file.
11955 If N is a positive number, save the N next articles.
11956 If N is a negative number, save the N previous articles.
11957 If N is nil and any articles have been marked with the process mark,
11958 save those articles instead."
11960 (require 'gnus-art)
11961 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
11962 (gnus-summary-save-article arg)))
11964 (defun gnus-summary-muttprint (&optional arg)
11965 "Print the current article using Muttprint.
11966 If N is a positive number, save the N next articles.
11967 If N is a negative number, save the N previous articles.
11968 If N is nil and any articles have been marked with the process mark,
11969 save those articles instead."
11971 (require 'gnus-art)
11972 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11973 (gnus-summary-save-article arg t)))
11975 (defun gnus-summary-pipe-message (program)
11976 "Pipe the current article through PROGRAM."
11977 (interactive "sProgram: ")
11978 (gnus-summary-select-article)
11979 (let ((mail-header-separator ""))
11980 (gnus-eval-in-buffer-window gnus-article-buffer
11983 (let ((start (window-start))
11984 (inhibit-read-only t))
11985 (message-pipe-buffer-body program)
11986 (set-window-start (get-buffer-window (current-buffer)) start))))))
11988 (defun gnus-get-split-value (methods)
11989 "Return a value based on the split METHODS."
11990 (let (split-name method result match)
11992 (with-current-buffer gnus-original-article-buffer
11994 (nnheader-narrow-to-headers)
11995 (while (and methods (not split-name))
11996 (goto-char (point-min))
11997 (setq method (pop methods))
11998 (setq match (car method))
12001 ;; Regular expression.
12003 (re-search-forward match nil t)))
12008 (setq result (funcall match gnus-newsgroup-name))))
12013 (setq result (eval match)))))
12014 (setq split-name (cdr method))
12015 (cond ((stringp result)
12016 (push (expand-file-name
12017 result gnus-article-save-directory)
12020 (setq split-name (append result split-name)))))))))
12021 (nreverse split-name)))
12023 (defun gnus-valid-move-group-p (group)
12024 (and (symbolp group)
12026 (symbol-name group)
12027 (symbol-value group)
12028 (gnus-get-function (gnus-find-method-for-group
12029 (symbol-name group)) 'request-accept-article t)))
12031 (defun gnus-read-move-group-name (prompt default articles prefix)
12032 "Read a group name."
12033 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12034 (minibuffer-confirm-incomplete nil) ; XEmacs
12038 (if (> (length articles) 1)
12039 (format "these %d articles" (length articles))
12044 (gnus-group-completing-read
12046 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12047 nil prefix nil default))
12048 ((= 1 (length split-name))
12049 (gnus-group-completing-read
12051 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12052 nil prefix 'gnus-group-history (car split-name)))
12054 (gnus-completing-read
12055 prom (nreverse split-name) nil nil 'gnus-group-history))))
12056 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12059 (if (or (string= to-newsgroup "")
12060 (string= to-newsgroup prefix))
12061 (setq to-newsgroup default))
12062 (unless to-newsgroup
12063 (error "No group name entered"))
12064 (setq encoded (mm-encode-coding-string
12066 (gnus-group-name-charset to-method to-newsgroup)))
12067 (or (gnus-active encoded)
12068 (gnus-activate-group encoded nil nil to-method)
12069 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12071 (or (and (gnus-request-create-group encoded to-method)
12072 (gnus-activate-group encoded nil nil to-method)
12073 (gnus-subscribe-group encoded))
12074 (error "Couldn't create group %s" to-newsgroup)))
12075 (error "No such group: %s" to-newsgroup))
12078 (defvar gnus-summary-save-parts-counter)
12079 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12081 (defun gnus-summary-save-parts (type dir n &optional reverse)
12082 "Save parts matching TYPE to DIR.
12083 If REVERSE, save parts that do not match TYPE."
12085 (list (read-string "Save parts of type: "
12086 (or (car gnus-summary-save-parts-type-history)
12087 gnus-summary-save-parts-default-mime)
12088 'gnus-summary-save-parts-type-history)
12089 (setq gnus-summary-save-parts-last-directory
12090 (read-file-name "Save to directory: "
12091 gnus-summary-save-parts-last-directory
12093 current-prefix-arg))
12094 (gnus-summary-iterate n
12095 (let ((gnus-display-mime-function nil)
12096 gnus-article-prepare-hook
12097 gnus-article-decode-hook
12098 gnus-display-mime-function
12100 (gnus-inhibit-treatment t))
12101 (gnus-summary-select-article))
12102 (with-current-buffer gnus-article-buffer
12103 (let ((handles (or gnus-article-mime-handles
12104 (mm-dissect-buffer nil gnus-article-loose-mime)
12105 (and gnus-article-emulate-mime
12107 (gnus-summary-save-parts-counter 1))
12109 (gnus-summary-save-parts-1 type dir handles reverse)
12110 (unless gnus-article-mime-handles ;; Don't destroy this case.
12111 (mm-destroy-parts handles)))))))
12113 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12114 (if (stringp (car handle))
12115 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12118 (not (string-match type (mm-handle-media-type handle)))
12119 (string-match type (mm-handle-media-type handle)))
12120 (let ((file (expand-file-name
12122 mm-file-name-rewrite-functions
12123 (file-name-nondirectory
12125 (mail-content-type-get
12126 (mm-handle-disposition handle) 'filename)
12127 (mail-content-type-get
12128 (mm-handle-type handle) 'name)
12129 (format "%s.%d.%d" gnus-newsgroup-name
12130 (cdr gnus-article-current)
12131 gnus-summary-save-parts-counter))))
12133 (incf gnus-summary-save-parts-counter)
12134 (unless (file-exists-p file)
12135 (mm-save-part-to-file handle file))))))
12137 ;; Summary extract commands
12139 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12140 (let ((inhibit-read-only t)
12141 (article (gnus-summary-article-number))
12143 (unless (gnus-summary-goto-subject article)
12144 (error "No such article: %d" article))
12145 (gnus-summary-position-point)
12146 ;; If all commands are to be bunched up on one line, we collect
12148 (unless gnus-view-pseudos-separately
12149 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12152 (setq action (cdr (assq 'action (car ps))))
12153 (setq files (list (cdr (assq 'name (car ps)))))
12154 (while (and ps (cdr ps)
12155 (string= (or action "1")
12156 (or (cdr (assq 'action (cadr ps))) "2")))
12157 (push (cdr (assq 'name (cadr ps))) files)
12158 (setcdr ps (cddr ps)))
12160 (when (not (string-match "%s" action))
12163 (when (assq 'execute (car ps))
12164 (setcdr (assq 'execute (car ps))
12165 (funcall (if (string-match "%s" action)
12172 (shell-quote-argument f)))
12174 (setq ps (cdr ps)))))
12175 (if (and gnus-view-pseudos (not not-view))
12177 (when (assq 'execute (car pslist))
12178 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12179 (eq gnus-view-pseudos 'not-confirm)))
12180 (setq pslist (cdr pslist)))
12183 (setq after-article (or (cdr (assq 'article (car pslist)))
12184 (gnus-summary-article-number)))
12185 (gnus-summary-goto-subject after-article)
12188 (insert " " (file-name-nondirectory
12189 (cdr (assq 'name (car pslist))))
12190 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12192 (forward-line -1) ; back to `b'
12193 (gnus-add-text-properties
12194 b (1- e) (list 'gnus-number gnus-reffed-article-number
12195 gnus-mouse-face-prop gnus-mouse-face))
12197 after-article gnus-reffed-article-number
12198 gnus-unread-mark b (car pslist) 0 (- e b))
12199 (setq gnus-newsgroup-unreads
12200 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12201 gnus-reffed-article-number))
12202 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12203 (setq pslist (cdr pslist)))))))
12205 (defun gnus-pseudos< (p1 p2)
12206 (let ((c1 (cdr (assq 'action p1)))
12207 (c2 (cdr (assq 'action p2))))
12208 (and c1 c2 (string< c1 c2))))
12210 (defun gnus-request-pseudo-article (props)
12211 (cond ((assq 'execute props)
12212 (gnus-execute-command (cdr (assq 'execute props)))))
12213 (let ((gnus-current-article (gnus-summary-article-number)))
12214 (gnus-run-hooks 'gnus-mark-article-hook)))
12216 (defun gnus-execute-command (command &optional automatic)
12218 (gnus-article-setup-buffer)
12219 (set-buffer gnus-article-buffer)
12220 (setq buffer-read-only nil)
12221 (let ((command (if automatic command
12222 (read-string "Command: " (cons command 0)))))
12224 (insert "$ " command "\n\n")
12225 (if gnus-view-pseudo-asynchronously
12226 (start-process "gnus-execute" (current-buffer) shell-file-name
12227 shell-command-switch command)
12228 (call-process shell-file-name nil t nil
12229 shell-command-switch command)))))
12231 ;; Summary kill commands.
12233 (defun gnus-summary-edit-global-kill (article)
12234 "Edit the \"global\" kill file."
12235 (interactive (list (gnus-summary-article-number)))
12236 (gnus-group-edit-global-kill article))
12238 (defun gnus-summary-edit-local-kill ()
12239 "Edit a local kill file applied to the current newsgroup."
12241 (setq gnus-current-headers (gnus-summary-article-header))
12242 (gnus-group-edit-local-kill
12243 (gnus-summary-article-number) gnus-newsgroup-name))
12245 ;;; Header reading.
12247 (defun gnus-read-header (id &optional header)
12248 "Read the headers of article ID and enter them into the Gnus system."
12249 (let ((group gnus-newsgroup-name)
12250 (gnus-override-method
12252 gnus-override-method
12253 (and (gnus-news-group-p gnus-newsgroup-name)
12254 (car (gnus-refer-article-methods)))))
12256 ;; First we check to see whether the header in question is already
12259 ;; This is a Message-ID.
12260 (setq header (or header (gnus-id-to-header id)))
12261 ;; This is an article number.
12262 (setq header (or header (gnus-summary-article-header id))))
12264 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12265 ;; We have found the header.
12267 ;; We have to really fetch the header to this article.
12268 (with-current-buffer nntp-server-buffer
12269 (when (setq where (gnus-request-head id group))
12270 (nnheader-fold-continuation-lines)
12271 (goto-char (point-max))
12273 (goto-char (point-min))
12277 ((cdr where) (cdr where))
12278 (header (mail-header-number header))
12279 (t gnus-reffed-article-number))
12281 (insert " Article retrieved.\n"))
12282 (if (or (not where)
12283 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12284 () ; Malformed head.
12285 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12286 (when (and (stringp id)
12288 (not (string= (gnus-group-real-name group)
12290 (not (gnus-server-equal gnus-override-method
12291 (gnus-group-method group)))))
12292 ;; If we fetched by Message-ID and the article came from
12293 ;; a different group (or server), we fudge some bogus
12294 ;; article numbers for this article.
12295 (mail-header-set-number header gnus-reffed-article-number))
12296 (with-current-buffer gnus-summary-buffer
12297 (decf gnus-reffed-article-number)
12298 (gnus-remove-header (mail-header-number header))
12299 (push header gnus-newsgroup-headers)
12300 (setq gnus-current-headers header)
12301 (push (mail-header-number header) gnus-newsgroup-limit)))
12304 (defun gnus-remove-header (number)
12305 "Remove header NUMBER from `gnus-newsgroup-headers'."
12306 (if (and gnus-newsgroup-headers
12307 (= number (mail-header-number (car gnus-newsgroup-headers))))
12308 (pop gnus-newsgroup-headers)
12309 (let ((headers gnus-newsgroup-headers))
12310 (while (and (cdr headers)
12311 (not (= number (mail-header-number (cadr headers)))))
12313 (when (cdr headers)
12314 (setcdr headers (cddr headers))))))
12317 ;;; summary highlights
12320 (defun gnus-highlight-selected-summary ()
12321 "Highlight selected article in summary buffer."
12322 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12323 (when gnus-summary-selected-face
12325 (let* ((beg (point-at-bol))
12326 (end (point-at-eol))
12327 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12328 (from (if (get-text-property beg gnus-mouse-face-prop)
12330 (or (next-single-property-change
12331 beg gnus-mouse-face-prop nil end)
12336 (or (next-single-property-change
12337 from gnus-mouse-face-prop nil end)
12339 ;; If no mouse-face prop on line we will have to = from = end,
12340 ;; so we highlight the entire line instead.
12341 (when (= (+ to 2) from)
12344 (if gnus-newsgroup-selected-overlay
12345 ;; Move old overlay.
12347 gnus-newsgroup-selected-overlay from to (current-buffer))
12348 ;; Create new overlay.
12350 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12351 'face gnus-summary-selected-face))))))
12353 (defvar gnus-summary-highlight-line-cached nil)
12354 (defvar gnus-summary-highlight-line-trigger nil)
12356 (defun gnus-summary-highlight-line-0 ()
12357 (if (and (eq gnus-summary-highlight-line-trigger
12358 gnus-summary-highlight)
12359 gnus-summary-highlight-line-cached)
12360 gnus-summary-highlight-line-cached
12361 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12362 gnus-summary-highlight-line-cached
12363 (let* ((cond (list 'cond))
12365 (list gnus-summary-highlight))
12367 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12371 (gnus-byte-compile (list 'lambda nil cond))))))
12373 (defun gnus-summary-highlight-line ()
12374 "Highlight current line according to `gnus-summary-highlight'."
12375 (let* ((beg (point-at-bol))
12376 (article (or (gnus-summary-article-number) gnus-current-article))
12377 (score (or (cdr (assq article
12378 gnus-newsgroup-scored))
12379 gnus-summary-default-score 0))
12380 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12381 (inhibit-read-only t)
12382 (default gnus-summary-default-score)
12383 (default-high gnus-summary-default-high-score)
12384 (default-low gnus-summary-default-low-score)
12385 (uncached (and gnus-summary-use-undownloaded-faces
12386 (memq article gnus-newsgroup-undownloaded)
12387 (not (memq article gnus-newsgroup-cached)))))
12388 (let ((face (funcall (gnus-summary-highlight-line-0))))
12389 (unless (eq face (get-text-property beg 'face))
12390 (gnus-put-text-property-excluding-characters-with-faces
12391 beg (point-at-eol) 'face
12392 (setq face (if (boundp face) (symbol-value face) face)))
12393 (when gnus-summary-highlight-line-function
12394 (funcall gnus-summary-highlight-line-function article face))))))
12396 (defun gnus-update-read-articles (group unread &optional compute)
12397 "Update the list of read articles in GROUP.
12398 UNREAD is a sorted list."
12399 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12400 (info (gnus-get-info group))
12403 (if (or (not info) (not active))
12404 ;; There is no info on this group if it was, in fact,
12405 ;; killed. Gnus stores no information on killed groups, so
12406 ;; there's nothing to be done.
12407 ;; One could store the information somewhere temporarily,
12408 ;; perhaps... Hmmm...
12410 ;; Remove any negative articles numbers.
12411 (while (and unread (< (car unread) 0))
12412 (setq unread (cdr unread)))
12413 ;; Remove any expired article numbers
12414 (while (and unread (< (car unread) (car active)))
12415 (setq unread (cdr unread)))
12416 ;; Compute the ranges of read articles by looking at the list of
12417 ;; unread articles.
12419 (when (/= (car unread) prev)
12420 (push (if (= prev (1- (car unread))) prev
12421 (cons prev (1- (car unread))))
12423 (setq prev (1+ (car unread)))
12424 (setq unread (cdr unread)))
12425 (when (<= prev (cdr active))
12426 (push (cons prev (cdr active)) read))
12427 (setq read (if (> (length read) 1) (nreverse read) read))
12432 ;; Propagate the read marks to the backend.
12433 (when (and gnus-propagate-marks
12434 (gnus-check-backend-function 'request-set-mark group))
12435 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12436 (add (gnus-remove-from-range read (gnus-info-read info))))
12438 (unless (gnus-check-group group)
12439 (error "Can't open server for %s" group))
12440 (gnus-request-set-mark
12441 group (delq nil (list (if add (list add 'add '(read)))
12442 (if del (list del 'del '(read))))))
12444 `(gnus-request-set-mark
12447 (if del (list del 'add '(read)))
12448 (if add (list add 'del '(read))))))))))
12449 (set-buffer gnus-group-buffer)
12450 (gnus-undo-register
12452 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12453 (gnus-info-set-read ',info ',(gnus-info-read info))
12454 (gnus-get-unread-articles-in-group ',info
12455 (gnus-active ,group))
12456 (gnus-group-update-group ,group t)
12458 ;; Enter this list into the group info.
12459 (gnus-info-set-read info read)
12460 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12461 (gnus-get-unread-articles-in-group info (gnus-active group))
12464 (defun gnus-offer-save-summaries ()
12465 "Offer to save all active summary buffers."
12467 ;; Go through all buffers and find all summaries.
12468 (dolist (buffer (buffer-list))
12469 (when (and (setq buffer (buffer-name buffer))
12470 (string-match "Summary" buffer)
12471 (with-current-buffer buffer
12472 ;; We check that this is, indeed, a summary buffer.
12473 (and (eq major-mode 'gnus-summary-mode)
12474 ;; Also make sure this isn't bogus.
12475 gnus-newsgroup-prepared
12476 ;; Also make sure that this isn't a
12477 ;; dead summary buffer.
12478 (not gnus-dead-summary-mode))))
12479 (push buffer buffers)))
12480 ;; Go through all these summary buffers and offer to save them.
12484 "Update summary buffer %s? "
12486 (switch-to-buffer buf)
12487 (gnus-summary-exit))
12490 (defun gnus-summary-setup-default-charset ()
12491 "Setup newsgroup default charset."
12492 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12493 (setq gnus-newsgroup-charset nil)
12494 (let* ((ignored-charsets
12495 (or gnus-newsgroup-ephemeral-ignored-charsets
12497 (and gnus-newsgroup-name
12498 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12499 gnus-newsgroup-ignored-charsets))))
12500 (setq gnus-newsgroup-charset
12501 (or gnus-newsgroup-ephemeral-charset
12502 (and gnus-newsgroup-name
12503 (gnus-parameter-charset gnus-newsgroup-name))
12504 gnus-default-charset))
12505 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12506 ignored-charsets))))
12512 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12513 "Display the current article buffer fully MIME-buttonized.
12514 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12515 treated as multipart/mixed."
12517 (require 'gnus-art)
12518 (let ((gnus-unbuttonized-mime-types nil)
12519 (gnus-mime-display-multipart-as-mixed show-all-parts))
12520 (gnus-summary-show-article)))
12522 (defun gnus-summary-repair-multipart (article)
12523 "Add a Content-Type header to a multipart article without one."
12524 (interactive (list (gnus-summary-article-number)))
12525 (gnus-with-article article
12526 (message-narrow-to-head)
12527 (message-remove-header "Mime-Version")
12528 (goto-char (point-max))
12529 (insert "Mime-Version: 1.0\n")
12531 (when (search-forward "\n--" nil t)
12532 (let ((separator (buffer-substring (point) (point-at-eol))))
12533 (message-narrow-to-head)
12534 (message-remove-header "Content-Type")
12535 (goto-char (point-max))
12536 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12539 (let (gnus-mark-article-hook)
12540 (gnus-summary-select-article t t nil article)))
12542 (defun gnus-summary-toggle-display-buttonized ()
12543 "Toggle the buttonizing of the article buffer."
12545 (require 'gnus-art)
12546 (if (setq gnus-inhibit-mime-unbuttonizing
12547 (not gnus-inhibit-mime-unbuttonizing))
12548 (let ((gnus-unbuttonized-mime-types nil))
12549 (gnus-summary-show-article))
12550 (gnus-summary-show-article)))
12553 ;;; Generic summary marking commands
12556 (defvar gnus-summary-marking-alist
12557 '((read gnus-del-mark "d")
12558 (unread gnus-unread-mark "u")
12559 (ticked gnus-ticked-mark "!")
12560 (dormant gnus-dormant-mark "?")
12561 (expirable gnus-expirable-mark "e"))
12562 "An alist of names/marks/keystrokes.")
12564 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12565 (defvar gnus-summary-mark-map)
12567 (defun gnus-summary-make-all-marking-commands ()
12568 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12569 (dolist (elem gnus-summary-marking-alist)
12570 (apply 'gnus-summary-make-marking-command elem)))
12572 (defun gnus-summary-make-marking-command (name mark keystroke)
12573 (let ((map (make-sparse-keymap)))
12574 (define-key gnus-summary-generic-mark-map keystroke map)
12575 (dolist (lway `((next "next" next nil "n")
12576 (next-unread "next unread" next t "N")
12577 (prev "previous" prev nil "p")
12578 (prev-unread "previous unread" prev t "P")
12579 (nomove "" nil nil ,keystroke)))
12580 (let ((func (gnus-summary-make-marking-command-1
12581 mark (car lway) lway name)))
12582 (setq func (eval func))
12583 (define-key map (nth 4 lway) func)))))
12585 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12587 (format "gnus-summary-put-mark-as-%s%s"
12588 name (if (eq way 'nomove)
12590 (concat "-" (symbol-name way)))))
12593 "Mark the current article as %s%s.
12594 If N, the prefix, then repeat N times.
12595 If N is negative, move in reverse order.
12596 The difference between N and the actual number of articles marked is
12600 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12602 (defun gnus-summary-generic-mark (n mark move unread)
12603 "Mark N articles with MARK."
12604 (unless (eq major-mode 'gnus-summary-mode)
12605 (error "This command can only be used in the summary buffer"))
12606 (gnus-summary-show-thread)
12609 ((eq move 'next) 1)
12610 ((eq move 'prev) -1)
12612 (if (zerop nummove)
12616 nummove (* -1 nummove))))
12617 (while (and (> n 0)
12618 (gnus-summary-mark-article nil mark)
12619 (zerop (gnus-summary-next-subject nummove unread t)))
12622 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12623 (gnus-summary-recenter)
12624 (gnus-summary-position-point)
12625 (gnus-set-mode-line 'summary)
12628 (defun gnus-summary-insert-articles (articles)
12629 (when (setq articles
12630 (gnus-sorted-difference articles
12631 (mapcar (lambda (h)
12632 (mail-header-number h))
12633 gnus-newsgroup-headers)))
12634 (setq gnus-newsgroup-headers
12636 gnus-newsgroup-headers
12637 (gnus-fetch-headers articles)
12638 'gnus-article-sort-by-number))
12639 ;; Suppress duplicates?
12640 (when gnus-suppress-duplicates
12641 (gnus-dup-suppress-articles))
12643 (if (and gnus-fetch-old-headers
12644 (eq gnus-headers-retrieved-by 'nov))
12645 ;; We might want to build some more threads first.
12646 (if (eq gnus-fetch-old-headers 'invisible)
12647 (gnus-build-all-threads)
12648 (gnus-build-old-threads))
12649 ;; Mark the inserted articles that are unread as unread.
12650 (setq gnus-newsgroup-unreads
12651 (gnus-sorted-nunion
12652 gnus-newsgroup-unreads
12653 (gnus-sorted-nintersection
12654 (gnus-list-of-unread-articles gnus-newsgroup-name)
12656 ;; Mark the inserted articles as selected so that the information
12657 ;; of the marks having been changed by a user may be updated when
12658 ;; exiting this group. See `gnus-summary-update-info'.
12659 (dolist (art articles)
12660 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12661 ;; Let the Gnus agent mark articles as read.
12663 (gnus-agent-get-undownloaded-list))
12664 ;; Remove list identifiers from subject
12665 (when gnus-list-identifiers
12666 (gnus-summary-remove-list-identifiers))
12667 ;; First and last article in this newsgroup.
12668 (when gnus-newsgroup-headers
12669 (setq gnus-newsgroup-begin
12670 (mail-header-number (car gnus-newsgroup-headers))
12672 (mail-header-number
12673 (gnus-last-element gnus-newsgroup-headers))))
12674 (when gnus-use-scoring
12675 (gnus-possibly-score-headers))))
12677 (defun gnus-summary-insert-old-articles (&optional all)
12678 "Insert all old articles in this group.
12679 If ALL is non-nil, already read articles become readable.
12680 If ALL is a number, fetch this number of articles."
12683 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12686 ;; Some nntp servers lie about their active range. When
12687 ;; this happens, the active range can be in the millions.
12688 ;; Use a compressed range to avoid creating a huge list.
12689 (gnus-range-difference (list gnus-newsgroup-active) old))
12690 (setq len (gnus-range-length older))
12695 (let ((older-range (nreverse older)))
12699 (let* ((r (pop older-range))
12700 (min (if (numberp r) r (car r)))
12701 (max (if (numberp r) r (cdr r))))
12702 (while (and (<= min max)
12707 (setq older (gnus-uncompress-range older))))
12709 (setq older (gnus-uncompress-range older)))
12711 (when (and (numberp gnus-large-newsgroup)
12712 (> len gnus-large-newsgroup))
12713 (let* ((cursor-in-echo-area nil)
12714 (initial (gnus-parameter-large-newsgroup-initial
12715 gnus-newsgroup-name))
12719 "How many articles from %s (%s %d): "
12720 (gnus-group-decoded-name gnus-newsgroup-name)
12721 (if initial "max" "default")
12724 (cons (number-to-string initial)
12726 (unless (string-match "^[ \t]*$" input)
12727 (setq all (string-to-number input))
12729 (let ((older-range (nreverse older)))
12733 (let* ((r (pop older-range))
12734 (min (if (numberp r) r (car r)))
12735 (max (if (numberp r) r (cdr r))))
12736 (while (and (<= min max)
12740 max (1- max))))))))))
12741 (setq older (gnus-uncompress-range older))))
12743 (message "No old news.")
12744 (gnus-summary-insert-articles older)
12745 (gnus-summary-limit (gnus-sorted-nunion old older))))
12746 (gnus-summary-position-point)))
12748 (defun gnus-summary-insert-new-articles ()
12749 "Insert all new articles in this group."
12752 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12753 (old-high gnus-newsgroup-highest)
12754 (nnmail-fetched-sources (list t))
12756 (setq gnus-newsgroup-active
12757 (gnus-copy-sequence
12758 (gnus-activate-group gnus-newsgroup-name 'scan)))
12759 (setq i (cdr gnus-newsgroup-active)
12760 gnus-newsgroup-highest i)
12761 (while (> i old-high)
12765 (message "No gnus is bad news")
12766 (gnus-summary-insert-articles new)
12767 (setq gnus-newsgroup-unreads
12768 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12769 (gnus-summary-limit (gnus-sorted-nunion old new))))
12770 (gnus-summary-position-point)))
12772 ;;; Bookmark support for Gnus.
12773 (declare-function bookmark-make-record-default
12774 "bookmark" (&optional no-file no-context posn))
12775 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12776 (declare-function bookmark-default-handler "bookmark" (bmk))
12777 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12778 (defvar bookmark-yank-point)
12779 (defvar bookmark-current-buffer)
12781 (defun gnus-summary-bookmark-make-record ()
12782 "Make a bookmark entry for a Gnus summary buffer."
12784 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12785 (save-restriction ; FIXME is it necessary to widen?
12786 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12787 (setq buf "art") ; We are recording bookmark from article buffer.
12788 (setq bookmark-yank-point (point))
12789 (setq bookmark-current-buffer (current-buffer))
12790 (gnus-article-show-summary)) ; Go back in summary buffer.
12791 ;; We are now recording bookmark from summary buffer.
12792 (unless buf (setq buf "sum"))
12793 (let* ((subject (elt (gnus-summary-article-header) 1))
12794 (grp (car gnus-article-current))
12795 (art (cdr gnus-article-current))
12796 (head (gnus-summary-article-header art))
12797 (id (mail-header-id head)))
12799 ,@(condition-case nil
12800 (bookmark-make-record-default 'no-file 'no-context pos)
12801 (wrong-number-of-arguments
12802 (bookmark-make-record-default 'point-only)))
12803 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12804 (group . ,grp) (article . ,art)
12805 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12808 (defun gnus-summary-bookmark-jump (bookmark)
12809 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12810 BOOKMARK is a bookmark name or a bookmark record."
12811 (let ((group (bookmark-prop-get bookmark 'group))
12812 (article (bookmark-prop-get bookmark 'article))
12813 (id (bookmark-prop-get bookmark 'message-id))
12814 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12815 (gnus-fetch-group group (list article))
12816 (gnus-summary-insert-cached-articles)
12817 (gnus-summary-goto-article id nil 'force)
12818 ;; FIXME we have to wait article buffer is ready (only large buffer)
12819 ;; Is there a better solution to know that?
12820 ;; If we don't wait `bookmark-default-handler' will have no chance
12821 ;; to set position. However there is no error, just wrong pos.
12823 (when (string= buf "Gnus-art")
12825 (bookmark-default-handler
12827 (buffer . ,(current-buffer))
12828 . ,(bookmark-get-bookmark-record bookmark)))))
12830 (gnus-summary-make-all-marking-commands)
12832 (gnus-ems-redefine)
12834 (provide 'gnus-sum)
12836 (run-hooks 'gnus-sum-load-hook)
12838 ;; Local Variables:
12839 ;; coding: iso-8859-1
12842 ;;; gnus-sum.el ends here