1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2012 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
36 (defvar tool-bar-mode)
37 (defvar gnus-tmp-header)
50 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
51 (autoload 'gnus-cache-write-active "gnus-cache")
52 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
54 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
55 (autoload 'mm-uu-dissect "mm-uu")
56 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
59 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
62 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63 (autoload 'nnir-article-group "nnir" nil nil 'macro)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74 See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
77 :version "23.1" ;; No Gnus
80 (defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
87 (defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
89 If an unread article in the group refers to an older, already
90 read (or just marked as read) article, the old article will not
91 normally be displayed in the Summary buffer. If this variable is
92 t, Gnus will attempt to grab the headers to the old articles, and
93 thereby build complete threads. If it has the value `some', all
94 old headers will be fetched but only enough headers to connect
95 otherwise loose threads will be displayed. This variable can
96 also be a number. In that case, no more than that number of old
97 headers will be fetched. If it has the value `invisible', all
98 old headers will be fetched, but none will be displayed.
100 The server has to support NOV for any of this to work.
102 This feature can seriously impact performance it ignores all
103 locally cached header entries. Setting it to t for groups for a
104 server that doesn't expire articles (such as news.gmane.org),
105 leads to very slow summary generation."
107 :type '(choice (const :tag "off" nil)
112 (sexp :menu-tag "other" t)))
114 (defcustom gnus-refer-thread-limit 500
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116 If t, fetch all the available old headers."
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
121 (defcustom gnus-refer-thread-use-nnir nil
122 "*Use nnir to search an entire server when referring threads. A
123 nil value will only search for thread-related articles in the
128 (defcustom gnus-summary-make-false-root 'adopt
129 "*nil means that Gnus won't gather loose threads.
130 If the root of a thread has expired or been read in a previous
131 session, the information necessary to build a complete thread has been
132 lost. Instead of having many small sub-threads from this original thread
133 scattered all over the summary buffer, Gnus can gather them.
135 If non-nil, Gnus will try to gather all loose sub-threads from an
136 original thread into one large thread.
138 If this variable is non-nil, it should be one of `none', `adopt',
141 If this variable is `none', Gnus will not make a false root, but just
142 present the sub-threads after another.
143 If this variable is `dummy', Gnus will create a dummy root that will
144 have all the sub-threads as children.
145 If this variable is `adopt', Gnus will make one of the \"children\"
146 the parent and mark all the step-children as such.
147 If this variable is `empty', the \"children\" are printed with empty
148 subject fields. (Or rather, they will be printed with a string
149 given by the `gnus-summary-same-subject' variable.)"
151 :type '(choice (const :tag "off" nil)
157 (defcustom gnus-summary-make-false-root-always nil
158 "Always make a false dummy root."
163 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
164 "*A regexp to match subjects to be excluded from loose thread gathering.
165 As loose thread gathering is done on subjects only, that means that
166 there can be many false gatherings performed. By rooting out certain
167 common subjects, gathering might become saner."
171 (defcustom gnus-summary-gather-subject-limit nil
172 "*Maximum length of subject comparisons when gathering loose threads.
173 Use nil to compare full subjects. Setting this variable to a low
174 number will help gather threads that have been corrupted by
175 newsreaders chopping off subject lines, but it might also mean that
176 unrelated articles that have subject that happen to begin with the
177 same few characters will be incorrectly gathered.
179 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
182 :type '(choice (const :tag "off" nil)
184 (sexp :menu-tag "on" t)))
186 (defcustom gnus-simplify-subject-functions nil
187 "List of functions taking a string argument that simplify subjects.
188 The functions are applied recursively.
190 Useful functions to put in this list include:
191 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
192 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
194 :type '(repeat function))
196 (defcustom gnus-simplify-ignored-prefixes nil
197 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
199 :type '(choice (const :tag "off" nil)
202 (defcustom gnus-build-sparse-threads nil
203 "*If non-nil, fill in the gaps in threads.
204 If `some', only fill in the gaps that are needed to tie loose threads
205 together. If `more', fill in all leaf nodes that Gnus can find. If
206 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
208 :type '(choice (const :tag "off" nil)
211 (sexp :menu-tag "all" t)))
213 (defcustom gnus-summary-thread-gathering-function
214 'gnus-gather-threads-by-subject
215 "*Function used for gathering loose threads.
216 There are two pre-defined functions: `gnus-gather-threads-by-subject',
217 which only takes Subjects into consideration; and
218 `gnus-gather-threads-by-references', which compared the References
219 headers of the articles to find matches."
221 :type '(radio (function-item gnus-gather-threads-by-subject)
222 (function-item gnus-gather-threads-by-references)
223 (function :tag "other")))
225 (defcustom gnus-summary-same-subject ""
226 "*String indicating that the current article has the same subject as the previous.
227 This variable will only be used if the value of
228 `gnus-summary-make-false-root' is `empty'."
229 :group 'gnus-summary-format
232 (defcustom gnus-summary-goto-unread nil
233 "*If t, many commands will go to the next unread article.
234 This applies to marking commands as well as other commands that
235 \"naturally\" select the next article, like, for instance, `SPC' at
236 the end of an article.
238 If nil, the marking commands do NOT go to the next unread article
239 \(they go to the next article instead). If `never', commands that
240 usually go to the next unread article, will go to the next article,
241 whether it is read or not."
243 :group 'gnus-summary-marks
244 :link '(custom-manual "(gnus)Setting Marks")
245 :type '(choice (const :tag "off" nil)
247 (sexp :menu-tag "on" t)))
249 (defcustom gnus-summary-default-score 0
250 "*Default article score level.
251 All scores generated by the score files will be added to this score.
252 If this variable is nil, scoring will be disabled."
253 :group 'gnus-score-default
254 :type '(choice (const :tag "disable")
257 (defcustom gnus-summary-default-high-score 0
258 "*Default threshold for a high scored article.
259 An article will be highlighted as high scored if its score is greater
262 :group 'gnus-score-default
265 (defcustom gnus-summary-default-low-score 0
266 "*Default threshold for a low scored article.
267 An article will be highlighted as low scored if its score is smaller
270 :group 'gnus-score-default
273 (defcustom gnus-summary-zcore-fuzz 0
274 "*Fuzziness factor for the zcore in the summary buffer.
275 Articles with scores closer than this to `gnus-summary-default-score'
277 :group 'gnus-summary-format
280 (defcustom gnus-simplify-subject-fuzzy-regexp nil
281 "*Strings to be removed when doing fuzzy matches.
282 This can either be a regular expression or list of regular expressions
283 that will be removed from subject strings if fuzzy subject
284 simplification is selected."
286 :type '(repeat regexp))
288 (defcustom gnus-show-threads t
289 "*If non-nil, display threads in summary mode."
293 (defcustom gnus-thread-hide-subtree nil
294 "*If non-nil, hide all threads initially.
295 This can be a predicate specifier which says which threads to hide.
296 If threads are hidden, you have to run the command
297 `gnus-summary-show-thread' by hand or select an article."
299 :type '(radio (sexp :format "Non-nil\n"
300 :match (lambda (widget value)
301 (not (or (consp value) (functionp value))))
304 (sexp :tag "Predicate specifier")))
306 (defcustom gnus-thread-hide-killed t
307 "*If non-nil, hide killed threads automatically."
311 (defcustom gnus-thread-ignore-subject t
312 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
313 If nil, articles that have different subjects from their parents will
314 start separate threads."
318 (defcustom gnus-thread-operation-ignore-subject t
319 "*If non-nil, subjects will be ignored when doing thread commands.
320 This affects commands like `gnus-summary-kill-thread' and
321 `gnus-summary-lower-thread'.
323 If this variable is nil, articles in the same thread with different
324 subjects will not be included in the operation in question. If this
325 variable is `fuzzy', only articles that have subjects that are fuzzily
326 equal will be included."
328 :type '(choice (const :tag "off" nil)
332 (defcustom gnus-thread-indent-level 4
333 "*Number that says how much each sub-thread should be indented."
337 (defcustom gnus-auto-extend-newsgroup t
338 "*If non-nil, extend newsgroup forward and backward when requested."
339 :group 'gnus-summary-choose
342 (defcustom gnus-auto-select-first t
343 "If non-nil, select an article on group entry.
344 An article is selected automatically when entering a group
345 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
346 `gnus-summary-catchup-and-goto-next-group'.
348 Which article is selected is controlled by the variable
349 `gnus-auto-select-subject'.
351 If you want to prevent automatic selection of articles in some
352 newsgroups, set the variable to nil in `gnus-select-group-hook'."
353 ;; Commands include...
354 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
355 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
356 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
357 :group 'gnus-group-select
358 :type '(choice (const :tag "none" nil)
359 (sexp :menu-tag "first" t)))
361 (defcustom gnus-auto-select-subject 'unseen-or-unread
362 "*Says what subject to place under point when entering a group.
364 This variable can either be the symbols `first' (place point on the
365 first subject), `unread' (place point on the subject line of the first
366 unread article), `best' (place point on the subject line of the
367 highest-scored article), `unseen' (place point on the subject line of
368 the first unseen article), `unseen-or-unread' (place point on the subject
369 line of the first unseen article or, if all articles have been seen, on the
370 subject line of the first unread article), or a function to be called to
371 place point on some subject line."
373 :group 'gnus-group-select
374 :type '(choice (const best)
378 (const unseen-or-unread)
379 (function :tag "Function to call")))
381 (defcustom gnus-auto-select-next t
382 "*If non-nil, offer to go to the next group from the end of the previous.
383 If the value is t and the next newsgroup is empty, Gnus will exit
384 summary mode and go back to group mode. If the value is neither nil
385 nor t, Gnus will select the following unread newsgroup. In
386 particular, if the value is the symbol `quietly', the next unread
387 newsgroup will be selected without any confirmation, and if it is
388 `almost-quietly', the next group will be selected without any
389 confirmation if you are located on the last article in the group.
390 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
391 will go to the next group without confirmation."
392 :group 'gnus-summary-maneuvering
393 :type '(choice (const :tag "off" nil)
395 (const almost-quietly)
396 (const slightly-quietly)
397 (sexp :menu-tag "on" t)))
399 (defcustom gnus-auto-select-same nil
400 "*If non-nil, select the next article with the same subject.
401 If there are no more articles with the same subject, go to
402 the first unread article."
403 :group 'gnus-summary-maneuvering
406 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
407 "What article should be selected after exiting an ephemeral group.
408 Valid values include:
411 Select the next article.
413 Select the next unread article.
415 Move the cursor to the next article. This is the default.
416 `next-unread-noselect'
417 Move the cursor to the next unread article.
419 If it has any other value or there is no next (unread) article, the
420 article selected before entering to the ephemeral group will appear."
421 :version "23.1" ;; No Gnus
422 :group 'gnus-summary-maneuvering
423 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
424 (const next) (const next-unread)
425 (const next-noselect) (const next-unread-noselect)
426 (sexp :tag "other" :value nil)))
428 (defcustom gnus-auto-goto-ignores 'unfetched
429 "*Says how to handle unfetched articles when maneuvering.
431 This variable can either be the symbols nil (maneuver to any
432 article), `undownloaded' (maneuvering while unplugged ignores articles
433 that have not been fetched), `always-undownloaded' (maneuvering always
434 ignores articles that have not been fetched), `unfetched' (maneuvering
435 ignores articles whose headers have not been fetched).
437 NOTE: The list of unfetched articles will always be nil when plugged
438 and, when unplugged, a subset of the undownloaded article list."
440 :group 'gnus-summary-maneuvering
441 :type '(choice (const :tag "None" nil)
442 (const :tag "Undownloaded when unplugged" undownloaded)
443 (const :tag "Undownloaded" always-undownloaded)
444 (const :tag "Unfetched" unfetched)))
446 (defcustom gnus-summary-check-current nil
447 "*If non-nil, consider the current article when moving.
448 The \"unread\" movement commands will stay on the same line if the
449 current article is unread."
450 :group 'gnus-summary-maneuvering
453 (defcustom gnus-auto-center-summary 2
454 "*If non-nil, always center the current summary buffer.
455 In particular, if `vertical' do only vertical recentering. If non-nil
456 and non-`vertical', do both horizontal and vertical recentering."
457 :group 'gnus-summary-maneuvering
458 :type '(choice (const :tag "none" nil)
460 (integer :tag "height")
461 (sexp :menu-tag "both" t)))
463 (defcustom gnus-auto-center-group t
464 "If non-nil, always center the group buffer."
465 :group 'gnus-summary-maneuvering
468 (defcustom gnus-show-all-headers nil
469 "*If non-nil, don't hide any headers."
470 :group 'gnus-article-hiding
471 :group 'gnus-article-headers
474 (defcustom gnus-summary-ignore-duplicates nil
475 "*If non-nil, ignore articles with identical Message-ID headers."
479 (defcustom gnus-single-article-buffer nil
480 "*If non-nil, display all articles in the same buffer.
481 If nil, each group will get its own article buffer."
483 :group 'gnus-article-various
486 (defcustom gnus-widen-article-window nil
487 "If non-nil, selecting the article buffer will display only the article buffer."
489 :group 'gnus-article-various
492 (defcustom gnus-break-pages t
493 "*If non-nil, do page breaking on articles.
494 The page delimiter is specified by the `gnus-page-delimiter'
496 :group 'gnus-article-various
499 (defcustom gnus-move-split-methods nil
500 "*Variable used to suggest where articles are to be moved to.
501 It uses the same syntax as the `gnus-split-methods' variable.
502 However, whereas `gnus-split-methods' specifies file names as targets,
503 this variable specifies group names."
504 :group 'gnus-summary-mail
505 :type '(repeat (choice (list :value (fun) function)
506 (cons :value ("" "") regexp (repeat string))
509 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
510 "Function used to compute default prefix for article move/copy/etc prompts.
511 The function should take one argument, a group name, and return a
512 string with the suggested prefix."
513 :group 'gnus-summary-mail
516 ;; FIXME: Although the custom type is `character' for the following variables,
517 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
519 (defcustom gnus-unread-mark ? ;Whitespace
520 "*Mark used for unread articles."
521 :group 'gnus-summary-marks
524 (defcustom gnus-ticked-mark ?!
525 "*Mark used for ticked articles."
526 :group 'gnus-summary-marks
529 (defcustom gnus-dormant-mark ??
530 "*Mark used for dormant articles."
531 :group 'gnus-summary-marks
534 (defcustom gnus-del-mark ?r
535 "*Mark used for del'd articles."
536 :group 'gnus-summary-marks
539 (defcustom gnus-read-mark ?R
540 "*Mark used for read articles."
541 :group 'gnus-summary-marks
544 (defcustom gnus-expirable-mark ?E
545 "*Mark used for expirable articles."
546 :group 'gnus-summary-marks
549 (defcustom gnus-killed-mark ?K
550 "*Mark used for killed articles."
551 :group 'gnus-summary-marks
554 (defcustom gnus-spam-mark ?$
555 "*Mark used for spam articles."
557 :group 'gnus-summary-marks
560 (defcustom gnus-kill-file-mark ?X
561 "*Mark used for articles killed by kill files."
562 :group 'gnus-summary-marks
565 (defcustom gnus-low-score-mark ?Y
566 "*Mark used for articles with a low score."
567 :group 'gnus-summary-marks
570 (defcustom gnus-catchup-mark ?C
571 "*Mark used for articles that are caught up."
572 :group 'gnus-summary-marks
575 (defcustom gnus-replied-mark ?A
576 "*Mark used for articles that have been replied to."
577 :group 'gnus-summary-marks
580 (defcustom gnus-forwarded-mark ?F
581 "*Mark used for articles that have been forwarded."
583 :group 'gnus-summary-marks
586 (defcustom gnus-recent-mark ?N
587 "*Mark used for articles that are recent."
589 :group 'gnus-summary-marks
592 (defcustom gnus-cached-mark ?*
593 "*Mark used for articles that are in the cache."
594 :group 'gnus-summary-marks
597 (defcustom gnus-saved-mark ?S
598 "*Mark used for articles that have been saved."
599 :group 'gnus-summary-marks
602 (defcustom gnus-unseen-mark ?.
603 "*Mark used for articles that haven't been seen."
605 :group 'gnus-summary-marks
608 (defcustom gnus-no-mark ? ;Whitespace
609 "*Mark used for articles that have no other secondary mark."
611 :group 'gnus-summary-marks
614 (defcustom gnus-ancient-mark ?O
615 "*Mark used for ancient articles."
616 :group 'gnus-summary-marks
619 (defcustom gnus-sparse-mark ?Q
620 "*Mark used for sparsely reffed articles."
621 :group 'gnus-summary-marks
624 (defcustom gnus-canceled-mark ?G
625 "*Mark used for canceled articles."
626 :group 'gnus-summary-marks
629 (defcustom gnus-duplicate-mark ?M
630 "*Mark used for duplicate articles."
631 :group 'gnus-summary-marks
634 (defcustom gnus-undownloaded-mark ?-
635 "*Mark used for articles that weren't downloaded."
637 :group 'gnus-summary-marks
640 (defcustom gnus-downloaded-mark ?+
641 "*Mark used for articles that were downloaded."
642 :group 'gnus-summary-marks
645 (defcustom gnus-downloadable-mark ?%
646 "*Mark used for articles that are to be downloaded."
647 :group 'gnus-summary-marks
650 (defcustom gnus-unsendable-mark ?=
651 "*Mark used for articles that won't be sent."
652 :group 'gnus-summary-marks
655 (defcustom gnus-score-over-mark ?+
656 "*Score mark used for articles with high scores."
657 :group 'gnus-summary-marks
660 (defcustom gnus-score-below-mark ?-
661 "*Score mark used for articles with low scores."
662 :group 'gnus-summary-marks
665 (defcustom gnus-empty-thread-mark ? ;Whitespace
666 "*There is no thread under the article."
667 :group 'gnus-summary-marks
670 (defcustom gnus-not-empty-thread-mark ?=
671 "*There is a thread under the article."
672 :group 'gnus-summary-marks
675 (defcustom gnus-view-pseudo-asynchronously nil
676 "*If non-nil, Gnus will view pseudo-articles asynchronously."
677 :group 'gnus-extract-view
680 (defcustom gnus-auto-expirable-marks
681 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
682 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
684 "*The list of marks converted into expiration if a group is auto-expirable."
687 :type '(repeat character))
689 (defcustom gnus-inhibit-user-auto-expire t
690 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
695 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
696 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
697 If nil, the expirable marks will be unchanged except that the marks
698 will be removed when copying or moving articles to a group that has
699 not turned auto-expire on. If non-nil, articles that have been read
700 will be marked as expirable when being copied or moved to a group in
701 which auto-expire is turned on."
704 :group 'gnus-summary-marks)
706 (defcustom gnus-view-pseudos nil
707 "*If `automatic', pseudo-articles will be viewed automatically.
708 If `not-confirm', pseudos will be viewed automatically, and the user
709 will not be asked to confirm the command."
710 :group 'gnus-extract-view
711 :type '(choice (const :tag "off" nil)
713 (const not-confirm)))
715 (defcustom gnus-view-pseudos-separately t
716 "*If non-nil, one pseudo-article will be created for each file to be viewed.
717 If nil, all files that use the same viewing command will be given as a
718 list of parameters to that command."
719 :group 'gnus-extract-view
722 (defcustom gnus-insert-pseudo-articles t
723 "*If non-nil, insert pseudo-articles when decoding articles."
724 :group 'gnus-extract-view
727 (defcustom gnus-summary-dummy-line-format
729 "*The format specification for the dummy roots in the summary buffer.
730 It works along the same lines as a normal formatting string,
731 with some simple extensions.
735 General format specifiers can also be used.
736 See `(gnus)Formatting Variables'."
737 :link '(custom-manual "(gnus)Formatting Variables")
738 :group 'gnus-threading
741 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
742 "*The format specification for the summary mode line.
743 It works along the same lines as a normal formatting string,
744 with some simple extensions:
747 %p Unprefixed group name
748 %A Current article number
749 %z Current article score
751 %U Number of unread articles in the group
752 %e Number of unselected articles in the group
753 %Z A string with unread/unselected article counts
754 %g Shortish group name
755 %S Subject of the current article
757 %s Current score file name
758 %d Number of dormant articles
759 %r Number of articles that have been marked as read in this session
760 %E Number of articles expunged by the score files"
761 :group 'gnus-summary-format
764 (defcustom gnus-list-identifiers nil
765 "Regexp that matches list identifiers to be removed from subject.
766 This can also be a list of regexps."
768 :group 'gnus-summary-format
769 :group 'gnus-article-hiding
770 :type '(choice (const :tag "none" nil)
772 (repeat :value (".*") regexp)))
774 (defcustom gnus-summary-mark-below 0
775 "*Mark all articles with a score below this variable as read.
776 This variable is local to each summary buffer and usually set by the
778 :group 'gnus-score-default
781 (defun gnus-widget-reversible-match (widget value)
782 "Ignoring WIDGET, convert VALUE to internal form.
783 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
787 (eq (length value) 2)
788 (eq (nth 0 value) 'not)
789 (symbolp (nth 1 value)))))
791 (defun gnus-widget-reversible-to-internal (widget value)
792 "Ignoring WIDGET, convert VALUE to internal form.
793 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
794 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
798 (list (nth 1 value) t)))
800 (defun gnus-widget-reversible-to-external (widget value)
801 "Ignoring WIDGET, convert VALUE to external form.
802 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
803 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
806 (list 'not (nth 0 value))
809 (define-widget 'gnus-widget-reversible 'group
810 "A `group' that convert values."
811 :match 'gnus-widget-reversible-match
812 :value-to-internal 'gnus-widget-reversible-to-internal
813 :value-to-external 'gnus-widget-reversible-to-external)
815 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
816 "*List of functions used for sorting articles in the summary buffer.
818 Each function takes two articles and returns non-nil if the first
819 article should be sorted before the other. If you use more than one
820 function, the primary sort function should be the last. You should
821 probably always include `gnus-article-sort-by-number' in the list of
822 sorting functions -- preferably first. Also note that sorting by date
823 is often much slower than sorting by number, and the sorting order is
824 very similar. (Sorting by date means sorting by the time the message
825 was sent, sorting by number means sorting by arrival time.)
827 Each item can also be a list `(not F)' where F is a function;
828 this reverses the sort order.
830 Ready-made functions include `gnus-article-sort-by-number',
831 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
832 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
833 and `gnus-article-sort-by-score'.
835 When threading is turned on, the variable `gnus-thread-sort-functions'
836 controls how articles are sorted."
837 :group 'gnus-summary-sort
838 :type '(repeat (gnus-widget-reversible
839 (choice (function-item gnus-article-sort-by-number)
840 (function-item gnus-article-sort-by-author)
841 (function-item gnus-article-sort-by-subject)
842 (function-item gnus-article-sort-by-date)
843 (function-item gnus-article-sort-by-score)
844 (function-item gnus-article-sort-by-random)
845 (function :tag "other"))
846 (boolean :tag "Reverse order"))))
849 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
850 "*List of functions used for sorting threads in the summary buffer.
851 By default, threads are sorted by article number.
853 Each function takes two threads and returns non-nil if the first
854 thread should be sorted before the other. If you use more than one
855 function, the primary sort function should be the last. You should
856 probably always include `gnus-thread-sort-by-number' in the list of
857 sorting functions -- preferably first. Also note that sorting by date
858 is often much slower than sorting by number, and the sorting order is
859 very similar. (Sorting by date means sorting by the time the message
860 was sent, sorting by number means sorting by arrival time.)
862 Each list item can also be a list `(not F)' where F is a
863 function; this specifies reversed sort order.
865 Ready-made functions include `gnus-thread-sort-by-number',
866 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
867 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
868 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
869 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
870 and `gnus-thread-sort-by-total-score' (see
871 `gnus-thread-score-function').
873 When threading is turned off, the variable
874 `gnus-article-sort-functions' controls how articles are sorted."
875 :group 'gnus-summary-sort
877 (gnus-widget-reversible
878 (choice (function-item gnus-thread-sort-by-number)
879 (function-item gnus-thread-sort-by-author)
880 (function-item gnus-thread-sort-by-recipient)
881 (function-item gnus-thread-sort-by-subject)
882 (function-item gnus-thread-sort-by-date)
883 (function-item gnus-thread-sort-by-score)
884 (function-item gnus-thread-sort-by-most-recent-number)
885 (function-item gnus-thread-sort-by-most-recent-date)
886 (function-item gnus-thread-sort-by-random)
887 (function-item gnus-thread-sort-by-total-score)
888 (function :tag "other"))
889 (boolean :tag "Reverse order"))))
891 (defcustom gnus-thread-score-function '+
892 "*Function used for calculating the total score of a thread.
894 The function is called with the scores of the article and each
895 subthread and should then return the score of the thread.
897 Some functions you can use are `+', `max', or `min'."
898 :group 'gnus-summary-sort
901 (defcustom gnus-summary-expunge-below nil
902 "All articles that have a score less than this variable will be expunged.
903 This variable is local to the summary buffers."
904 :group 'gnus-score-default
905 :type '(choice (const :tag "off" nil)
908 (defcustom gnus-thread-expunge-below nil
909 "All threads that have a total score less than this variable will be expunged.
910 See `gnus-thread-score-function' for en explanation of what a
913 This variable is local to the summary buffers."
914 :group 'gnus-threading
915 :group 'gnus-score-default
916 :type '(choice (const :tag "off" nil)
919 (defcustom gnus-summary-mode-hook nil
920 "*A hook for Gnus summary mode.
921 This hook is run before any variables are set in the summary buffer."
922 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
923 :group 'gnus-summary-various
926 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
927 (when (featurep 'xemacs)
928 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
929 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
930 (add-hook 'gnus-summary-mode-hook
931 'gnus-xmas-switch-horizontal-scrollbar-off))
933 (defcustom gnus-summary-menu-hook nil
934 "*Hook run after the creation of the summary mode menu."
935 :group 'gnus-summary-visual
938 (defcustom gnus-summary-exit-hook nil
939 "*A hook called on exit from the summary buffer.
940 It will be called with point in the group buffer."
941 :group 'gnus-summary-exit
944 (defcustom gnus-summary-prepare-hook nil
945 "*A hook called after the summary buffer has been generated.
946 If you want to modify the summary buffer, you can use this hook."
947 :group 'gnus-summary-various
950 (defcustom gnus-summary-prepared-hook nil
951 "*A hook called as the last thing after the summary buffer has been generated."
952 :group 'gnus-summary-various
955 (defcustom gnus-summary-generate-hook nil
956 "*A hook run just before generating the summary buffer.
957 This hook is commonly used to customize threading variables and the
959 :group 'gnus-summary-various
962 (defcustom gnus-select-group-hook nil
963 "*A hook called when a newsgroup is selected.
965 If you'd like to simplify subjects like the
966 `gnus-summary-next-same-subject' command does, you can use the
969 (add-hook gnus-select-group-hook
971 (mapcar (lambda (header)
972 (mail-header-set-subject
974 (gnus-simplify-subject
975 (mail-header-subject header) 're-only)))
976 gnus-newsgroup-headers)))"
977 :group 'gnus-group-select
980 (defcustom gnus-select-article-hook nil
981 "*A hook called when an article is selected."
982 :group 'gnus-summary-choose
983 :options '(gnus-agent-fetch-selected-article)
986 (defcustom gnus-visual-mark-article-hook
987 (list 'gnus-highlight-selected-summary)
988 "*Hook run after selecting an article in the summary buffer.
989 It is meant to be used for highlighting the article in some way. It
990 is not run if `gnus-visual' is nil."
991 :group 'gnus-summary-visual
994 (defcustom gnus-parse-headers-hook nil
995 "*A hook called before parsing the headers."
999 (defcustom gnus-exit-group-hook nil
1000 "*A hook called when exiting summary mode.
1001 This hook is not called from the non-updating exit commands like `Q'."
1002 :group 'gnus-various
1005 (defcustom gnus-summary-update-hook nil
1006 "*A hook called when a summary line is changed.
1007 The hook will not be called if `gnus-visual' is nil.
1009 The default function `gnus-summary-highlight-line' will
1010 highlight the line according to the `gnus-summary-highlight'
1012 :group 'gnus-summary-visual
1015 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1016 "*A hook called when an article is selected for the first time.
1017 The hook is intended to mark an article as read (or unread)
1018 automatically when it is selected."
1019 :group 'gnus-summary-choose
1022 (defcustom gnus-group-no-more-groups-hook nil
1023 "*A hook run when returning to group mode having no more (unread) groups."
1024 :group 'gnus-group-select
1027 (defcustom gnus-ps-print-hook nil
1028 "*A hook run before ps-printing something from Gnus."
1029 :group 'gnus-summary
1032 (defcustom gnus-summary-article-move-hook nil
1033 "*A hook called after an article is moved, copied, respooled, or crossposted."
1035 :group 'gnus-summary
1038 (defcustom gnus-summary-article-delete-hook nil
1039 "*A hook called after an article is deleted."
1041 :group 'gnus-summary
1044 (defcustom gnus-summary-article-expire-hook nil
1045 "*A hook called after an article is expired."
1047 :group 'gnus-summary
1050 (defcustom gnus-summary-display-arrow
1051 (and (fboundp 'display-graphic-p)
1052 (display-graphic-p))
1053 "*If non-nil, display an arrow highlighting the current article."
1055 :group 'gnus-summary
1058 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1059 "Face used for highlighting the current article in the summary buffer."
1060 :group 'gnus-summary-visual
1063 (defvar gnus-tmp-downloaded nil)
1065 (defcustom gnus-summary-highlight
1066 '(((eq mark gnus-canceled-mark)
1067 . gnus-summary-cancelled)
1068 ((and uncached (> score default-high))
1069 . gnus-summary-high-undownloaded)
1070 ((and uncached (< score default-low))
1071 . gnus-summary-low-undownloaded)
1073 . gnus-summary-normal-undownloaded)
1074 ((and (> score default-high)
1075 (or (eq mark gnus-dormant-mark)
1076 (eq mark gnus-ticked-mark)))
1077 . gnus-summary-high-ticked)
1078 ((and (< score default-low)
1079 (or (eq mark gnus-dormant-mark)
1080 (eq mark gnus-ticked-mark)))
1081 . gnus-summary-low-ticked)
1082 ((or (eq mark gnus-dormant-mark)
1083 (eq mark gnus-ticked-mark))
1084 . gnus-summary-normal-ticked)
1085 ((and (> score default-high) (eq mark gnus-ancient-mark))
1086 . gnus-summary-high-ancient)
1087 ((and (< score default-low) (eq mark gnus-ancient-mark))
1088 . gnus-summary-low-ancient)
1089 ((eq mark gnus-ancient-mark)
1090 . gnus-summary-normal-ancient)
1091 ((and (> score default-high) (eq mark gnus-unread-mark))
1092 . gnus-summary-high-unread)
1093 ((and (< score default-low) (eq mark gnus-unread-mark))
1094 . gnus-summary-low-unread)
1095 ((eq mark gnus-unread-mark)
1096 . gnus-summary-normal-unread)
1097 ((> score default-high)
1098 . gnus-summary-high-read)
1099 ((< score default-low)
1100 . gnus-summary-low-read)
1102 . gnus-summary-normal-read))
1103 "*Controls the highlighting of summary buffer lines.
1105 A list of (FORM . FACE) pairs. When deciding how a particular
1106 summary line should be displayed, each form is evaluated. The content
1107 of the face field after the first true form is used. You can change
1108 how those summary lines are displayed, by editing the face field.
1110 You can use the following variables in the FORM field.
1112 score: The article's score.
1113 default: The default article score.
1114 default-high: The default score for high scored articles.
1115 default-low: The default score for low scored articles.
1116 below: The score below which articles are automatically marked as read.
1117 mark: The article's mark.
1118 uncached: Non-nil if the article is uncached."
1119 :group 'gnus-summary-visual
1120 :type '(repeat (cons (sexp :tag "Form" nil)
1122 (put 'gnus-summary-highlight 'risky-local-variable t)
1124 (defcustom gnus-alter-header-function nil
1125 "Function called to allow alteration of article header structures.
1126 The function is called with one parameter, the article header vector,
1127 which it may alter in any way."
1128 :type '(choice (const :tag "None" nil)
1130 :group 'gnus-summary)
1132 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1133 "Function used to decode a string with encoded words.")
1135 (defvar gnus-decode-encoded-address-function
1136 'mail-decode-encoded-address-string
1137 "Function used to decode addresses with encoded words.")
1139 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
1140 "*Extra headers to parse."
1141 :version "24.1" ; added Cc Keywords Gcc
1142 :group 'gnus-summary
1143 :type '(repeat symbol))
1145 (defcustom gnus-ignored-from-addresses
1146 (and user-mail-address
1147 (not (string= user-mail-address ""))
1148 (regexp-quote user-mail-address))
1149 "*From headers that may be suppressed in favor of To headers.
1150 This can be a regexp or a list of regexps."
1152 :group 'gnus-summary
1153 :type '(choice regexp
1154 (repeat :tag "Regexp List" regexp)))
1156 (defsubst gnus-ignored-from-addresses ()
1157 (gmm-regexp-concat gnus-ignored-from-addresses))
1159 (defcustom gnus-summary-to-prefix "-> "
1160 "*String prefixed to the To field in the summary line when
1161 using `gnus-ignored-from-addresses'."
1163 :group 'gnus-summary
1166 (defcustom gnus-summary-newsgroup-prefix "=> "
1167 "*String prefixed to the Newsgroup field in the summary
1168 line when using `gnus-ignored-from-addresses'."
1170 :group 'gnus-summary
1173 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1174 "List of charsets that should be ignored.
1175 When these charsets are used in the \"charset\" parameter, the
1176 default charset will be used instead."
1178 :type '(repeat symbol)
1179 :group 'gnus-charset)
1181 (defcustom gnus-newsgroup-maximum-articles nil
1182 "The maximum number of articles a newsgroup.
1183 If this is a number, old articles in a newsgroup exceeding this number
1184 are silently ignored. If it is nil, no article is ignored. Note that
1185 setting this variable to a number might prevent you from reading very
1187 :group 'gnus-group-select
1189 :type '(choice (const :tag "No limit" nil)
1192 (gnus-define-group-parameter
1196 "Return the ignored charsets of GROUP."
1197 :variable gnus-group-ignored-charsets-alist
1199 '(("alt\\.chinese\\.text" iso-8859-1))
1201 "Alist of regexps (to match group names) and charsets that should be ignored.
1202 When these charsets are used in the \"charset\" parameter, the
1203 default charset will be used instead."
1204 :variable-group gnus-charset
1205 :variable-type '(repeat (cons (regexp :tag "Group")
1207 :parameter-type '(choice :tag "Ignored charsets"
1210 :parameter-document "\
1211 List of charsets that should be ignored.
1213 When these charsets are used in the \"charset\" parameter, the
1214 default charset will be used instead.")
1216 (defcustom gnus-group-highlight-words-alist nil
1217 "Alist of group regexps and highlight regexps.
1218 This variable uses the same syntax as `gnus-emphasis-alist'."
1220 :type '(repeat (cons (regexp :tag "Group")
1221 (repeat (list (regexp :tag "Highlight regexp")
1222 (number :tag "Group for entire word" 0)
1223 (number :tag "Group for displayed part" 0)
1225 gnus-emphasis-highlight-words)))))
1226 :group 'gnus-summary-visual)
1228 (defcustom gnus-summary-show-article-charset-alist
1230 "Alist of number and charset.
1231 The article will be shown with the charset corresponding to the
1233 For example: ((1 . cn-gb-2312) (2 . big5))."
1235 :type '(repeat (cons (number :tag "Argument" 1)
1236 (symbol :tag "Charset")))
1237 :group 'gnus-charset)
1239 (defcustom gnus-preserve-marks t
1240 "Whether marks are preserved when moving, copying and respooling messages."
1243 :group 'gnus-summary-marks)
1245 (defcustom gnus-propagate-marks nil
1246 "If non-nil, Gnus will store and retrieve marks from the backends.
1247 This means that marks will be stored both in .newsrc.eld and in
1248 the backend, and will slow operation down somewhat."
1250 :group 'gnus-summary-marks)
1252 (defcustom gnus-alter-articles-to-read-function nil
1253 "Function to be called to alter the list of articles to be selected."
1254 :type '(choice (const nil) function)
1255 :group 'gnus-summary)
1257 (defcustom gnus-orphan-score nil
1258 "*All orphans get this score added. Set in the score file."
1259 :group 'gnus-score-default
1260 :type '(choice (const nil)
1263 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1264 "*A regexp to match MIME parts when saving multiple parts of a
1265 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1266 This regexp will be used by default when prompting the user for which
1267 type of files to save."
1268 :group 'gnus-summary
1271 (defcustom gnus-read-all-available-headers nil
1272 "Whether Gnus should parse all headers made available to it.
1273 This is mostly relevant for slow back ends where the user may
1274 wish to widen the summary buffer to include all headers
1277 :group 'gnus-summary
1278 :type '(choice boolean regexp))
1280 (defcustom gnus-summary-pipe-output-default-command nil
1281 "Command (and optional arguments) used to pipe article to subprocess.
1282 This will be used as the default command if it is non-nil. The value
1283 will be updated if you modify it when executing the command
1284 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1285 :version "23.1" ;; No Gnus
1286 :group 'gnus-summary
1287 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1289 (defcustom gnus-summary-muttprint-program "muttprint"
1290 "Command (and optional arguments) used to run Muttprint.
1291 The value will be updated if you modify it when executing the command
1292 `gnus-summary-muttprint'."
1294 :group 'gnus-summary
1297 (defcustom gnus-article-loose-mime t
1298 "If non-nil, don't require MIME-Version header.
1299 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1300 supply the MIME-Version header or deliberately strip it from the mail.
1301 If non-nil (the default), Gnus will treat some articles as MIME
1302 even if the MIME-Version header is missing."
1305 :group 'gnus-article-mime)
1307 (defcustom gnus-article-emulate-mime t
1308 "If non-nil, use MIME emulation for uuencode and the like.
1309 This means that Gnus will search message bodies for text that look
1310 like uuencoded bits, yEncoded bits, and so on, and present that using
1311 the normal Gnus MIME machinery."
1314 :group 'gnus-article-mime)
1316 ;;; Internal variables
1318 (defvar gnus-summary-display-cache nil)
1319 (defvar gnus-article-mime-handles nil)
1320 (defvar gnus-article-decoded-p nil)
1321 (defvar gnus-article-charset nil)
1322 (defvar gnus-article-ignored-charsets nil)
1323 (defvar gnus-scores-exclude-files nil)
1324 (defvar gnus-page-broken nil)
1326 (defvar gnus-original-article nil)
1327 (defvar gnus-article-internal-prepare-hook nil)
1328 (defvar gnus-newsgroup-process-stack nil)
1330 (defvar gnus-thread-indent-array nil)
1331 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1332 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1333 "Function called to sort the articles within a thread after it has been gathered together.")
1335 (defvar gnus-summary-save-parts-type-history nil)
1336 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1338 ;; Avoid highlighting in kill files.
1339 (defvar gnus-summary-inhibit-highlight nil)
1340 (defvar gnus-newsgroup-selected-overlay nil)
1341 (defvar gnus-inhibit-limiting nil)
1342 (defvar gnus-newsgroup-adaptive-score-file nil)
1343 (defvar gnus-current-score-file nil)
1344 (defvar gnus-current-move-group nil)
1345 (defvar gnus-current-copy-group nil)
1346 (defvar gnus-current-crosspost-group nil)
1347 (defvar gnus-newsgroup-display nil)
1349 (defvar gnus-newsgroup-dependencies nil)
1350 (defvar gnus-newsgroup-adaptive nil)
1351 (defvar gnus-summary-display-article-function nil)
1352 (defvar gnus-summary-highlight-line-function nil
1353 "Function called after highlighting a summary line.")
1355 (defvar gnus-summary-line-format-alist
1356 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1357 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1358 (?s gnus-tmp-subject-or-nil ?s)
1359 (?n gnus-tmp-name ?s)
1360 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1362 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1364 (?F gnus-tmp-from ?s)
1365 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1366 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1367 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1368 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1369 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1370 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1371 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1372 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1373 (?L gnus-tmp-lines ?s)
1374 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1376 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1378 (?g (or (gnus-group-short-name
1379 (nnir-article-group (mail-header-number gnus-tmp-header)))
1381 (?O gnus-tmp-downloaded ?c)
1382 (?I gnus-tmp-indentation ?s)
1383 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1384 (?R gnus-tmp-replied ?c)
1385 (?\[ gnus-tmp-opening-bracket ?c)
1386 (?\] gnus-tmp-closing-bracket ?c)
1387 (?\> (make-string gnus-tmp-level ? ) ?s)
1388 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1389 (?i gnus-tmp-score ?d)
1390 (?z gnus-tmp-score-char ?c)
1391 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1392 (?U gnus-tmp-unread ?c)
1393 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1395 (?t (gnus-summary-number-of-articles-in-thread
1396 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1398 (?e (gnus-summary-number-of-articles-in-thread
1399 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1401 (?u gnus-tmp-user-defined ?s)
1402 (?P (gnus-pick-line-number) ?d)
1403 (?B gnus-tmp-thread-tree-header-string ?s)
1404 (user-date (gnus-user-date
1405 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1406 "An alist of format specifications that can appear in summary lines.
1407 These are paired with what variables they correspond with, along with
1408 the type of the variable (string, integer, character, etc).")
1410 (defvar gnus-summary-dummy-line-format-alist
1411 `((?S gnus-tmp-subject ?s)
1412 (?N gnus-tmp-number ?d)
1413 (?u gnus-tmp-user-defined ?s)))
1415 (defvar gnus-summary-mode-line-format-alist
1416 `((?G gnus-tmp-group-name ?s)
1417 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1418 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1419 (?A gnus-tmp-article-number ?d)
1420 (?Z gnus-tmp-unread-and-unselected ?s)
1421 (?V gnus-version ?s)
1422 (?U gnus-tmp-unread-and-unticked ?d)
1423 (?S gnus-tmp-subject ?s)
1424 (?e gnus-tmp-unselected ?d)
1425 (?u gnus-tmp-user-defined ?s)
1426 (?d (length gnus-newsgroup-dormant) ?d)
1427 (?t (length gnus-newsgroup-marked) ?d)
1428 (?h (length gnus-newsgroup-spam-marked) ?d)
1429 (?r (length gnus-newsgroup-reads) ?d)
1430 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1431 (?E gnus-newsgroup-expunged-tally ?d)
1432 (?s (gnus-current-score-file-nondirectory) ?s)))
1434 ;; This is here rather than in gnus-art for compilation reasons.
1435 (defvar gnus-article-mode-line-format-alist
1436 (nconc '((?w (gnus-article-wash-status) ?s)
1437 (?m (gnus-article-mime-part-status) ?s))
1438 gnus-summary-mode-line-format-alist))
1440 (defvar gnus-last-search-regexp nil
1441 "Default regexp for article search command.")
1443 (defvar gnus-last-shell-command nil
1444 "Default shell command on article.")
1446 (defvar gnus-newsgroup-agentized nil
1447 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1448 (defvar gnus-newsgroup-begin nil)
1449 (defvar gnus-newsgroup-end nil)
1450 (defvar gnus-newsgroup-last-rmail nil)
1451 (defvar gnus-newsgroup-last-mail nil)
1452 (defvar gnus-newsgroup-last-folder nil)
1453 (defvar gnus-newsgroup-last-file nil)
1454 (defvar gnus-newsgroup-last-directory nil)
1455 (defvar gnus-newsgroup-auto-expire nil)
1456 (defvar gnus-newsgroup-active nil)
1457 (defvar gnus-newsgroup-highest nil)
1459 (defvar gnus-newsgroup-data nil)
1460 (defvar gnus-newsgroup-data-reverse nil)
1461 (defvar gnus-newsgroup-limit nil)
1462 (defvar gnus-newsgroup-limits nil)
1463 (defvar gnus-summary-use-undownloaded-faces nil)
1465 (defvar gnus-newsgroup-unreads nil
1466 "Sorted list of unread articles in the current newsgroup.")
1468 (defvar gnus-newsgroup-unselected nil
1469 "Sorted list of unselected unread articles in the current newsgroup.")
1471 (defvar gnus-newsgroup-reads nil
1472 "Alist of read articles and article marks in the current newsgroup.")
1474 (defvar gnus-newsgroup-expunged-tally nil)
1476 (defvar gnus-newsgroup-marked nil
1477 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1479 (defvar gnus-newsgroup-spam-marked nil
1480 "List of ranges of articles that have been marked as spam.")
1482 (defvar gnus-newsgroup-killed nil
1483 "List of ranges of articles that have been through the scoring process.")
1485 (defvar gnus-newsgroup-cached nil
1486 "Sorted list of articles that come from the article cache.")
1488 (defvar gnus-newsgroup-saved nil
1489 "List of articles that have been saved.")
1491 (defvar gnus-newsgroup-kill-headers nil)
1493 (defvar gnus-newsgroup-replied nil
1494 "List of articles that have been replied to in the current newsgroup.")
1496 (defvar gnus-newsgroup-forwarded nil
1497 "List of articles that have been forwarded in the current newsgroup.")
1499 (defvar gnus-newsgroup-expirable nil
1500 "Sorted list of articles in the current newsgroup that can be expired.")
1502 (defvar gnus-newsgroup-processable nil
1503 "List of articles in the current newsgroup that can be processed.")
1505 (defvar gnus-newsgroup-downloadable nil
1506 "Sorted list of articles in the current newsgroup that can be processed.")
1508 (defvar gnus-newsgroup-unfetched nil
1509 "Sorted list of articles in the current newsgroup whose headers have
1510 not been fetched into the agent.
1512 This list will always be a subset of gnus-newsgroup-undownloaded.")
1514 (defvar gnus-newsgroup-undownloaded nil
1515 "List of articles in the current newsgroup that haven't been downloaded.")
1517 (defvar gnus-newsgroup-unsendable nil
1518 "List of articles in the current newsgroup that won't be sent.")
1520 (defvar gnus-newsgroup-bookmarks nil
1521 "List of articles in the current newsgroup that have bookmarks.")
1523 (defvar gnus-newsgroup-dormant nil
1524 "Sorted list of dormant articles in the current newsgroup.")
1526 (defvar gnus-newsgroup-unseen nil
1527 "List of unseen articles in the current newsgroup.")
1529 (defvar gnus-newsgroup-seen nil
1530 "Range of seen articles in the current newsgroup.")
1532 (defvar gnus-newsgroup-articles nil
1533 "List of articles in the current newsgroup.")
1535 (defvar gnus-newsgroup-scored nil
1536 "List of scored articles in the current newsgroup.")
1538 (defvar gnus-newsgroup-headers nil
1539 "List of article headers in the current newsgroup.")
1541 (defvar gnus-newsgroup-threads nil)
1543 (defvar gnus-newsgroup-prepared nil
1544 "Whether the current group has been prepared properly.")
1546 (defvar gnus-newsgroup-ancient nil
1547 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1549 (defvar gnus-newsgroup-sparse nil)
1551 (defvar gnus-current-article nil)
1552 (defvar gnus-article-current nil)
1553 (defvar gnus-current-headers nil)
1554 (defvar gnus-have-all-headers nil)
1555 (defvar gnus-last-article nil)
1556 (defvar gnus-newsgroup-history nil)
1557 (defvar gnus-newsgroup-charset nil)
1558 (defvar gnus-newsgroup-ephemeral-charset nil)
1559 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1561 (defvar gnus-article-before-search nil)
1563 (defvar gnus-summary-local-variables
1564 '(gnus-newsgroup-name
1567 gnus-newsgroup-unreads
1568 gnus-newsgroup-unselected
1569 gnus-newsgroup-marked
1570 gnus-newsgroup-spam-marked
1571 gnus-newsgroup-reads
1572 gnus-newsgroup-saved
1573 gnus-newsgroup-replied
1574 gnus-newsgroup-forwarded
1575 gnus-newsgroup-expirable
1576 gnus-newsgroup-killed
1577 gnus-newsgroup-unseen
1579 gnus-newsgroup-cached
1580 gnus-newsgroup-downloadable
1581 gnus-newsgroup-undownloaded
1582 gnus-newsgroup-unsendable
1584 gnus-newsgroup-begin gnus-newsgroup-end
1585 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1586 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1587 gnus-newsgroup-last-directory
1588 gnus-newsgroup-auto-expire
1589 gnus-newsgroup-processable
1590 gnus-newsgroup-unfetched
1591 gnus-newsgroup-articles
1592 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1593 gnus-newsgroup-headers gnus-newsgroup-threads
1594 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1595 gnus-current-article gnus-current-headers gnus-have-all-headers
1596 gnus-last-article gnus-article-internal-prepare-hook
1597 (gnus-summary-article-delete-hook . global)
1598 (gnus-summary-article-move-hook . global)
1599 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1600 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1601 gnus-thread-expunge-below
1602 gnus-score-alist gnus-current-score-file
1603 (gnus-summary-expunge-below . global)
1604 (gnus-summary-mark-below . global)
1605 (gnus-orphan-score . global)
1606 gnus-newsgroup-active gnus-scores-exclude-files
1607 gnus-newsgroup-highest
1608 gnus-newsgroup-history gnus-newsgroup-ancient
1609 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1610 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1611 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1612 (gnus-newsgroup-expunged-tally . 0)
1613 gnus-cache-removable-articles
1614 gnus-newsgroup-data gnus-newsgroup-data-reverse
1615 gnus-newsgroup-limit gnus-newsgroup-limits
1616 gnus-newsgroup-charset gnus-newsgroup-display
1617 gnus-summary-use-undownloaded-faces)
1618 "Variables that are buffer-local to the summary buffers.")
1620 (defvar gnus-newsgroup-variables nil
1621 "A list of variables that have separate values in different newsgroups.
1622 A list of newsgroup (summary buffer) local variables, or cons of
1623 variables and their default expressions to be evalled (when the default
1624 values are not nil), that should be made global while the summary buffer
1627 Note: The default expressions will be evaluated (using function `eval')
1628 before assignment to the local variable rather than just assigned to it.
1629 If the default expression is the symbol `global', that symbol will not
1630 be evaluated but the global value of the local variable will be used
1633 These variables can be used to set variables in the group parameters
1634 while still allowing them to affect operations done in other buffers.
1637 \(setq gnus-newsgroup-variables
1638 '(message-use-followup-to
1639 (gnus-visible-headers .
1640 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1644 ;; Bind features so that require will believe that gnus-sum has
1645 ;; already been loaded (avoids infinite recursion)
1646 (let ((features (cons 'gnus-sum features)))
1647 (require 'gnus-art)))
1651 (defvar gnus-decode-encoded-word-methods
1652 '(mail-decode-encoded-word-string)
1653 "List of methods used to decode encoded words.
1655 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1656 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1657 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1658 whose names match REGEXP.
1661 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1662 mail-decode-encoded-word-string
1663 (\"chinese\" . rfc1843-decode-string))")
1665 (defvar gnus-decode-encoded-word-methods-cache nil)
1667 (defun gnus-multi-decode-encoded-word-string (string)
1668 "Apply the functions from `gnus-encoded-word-methods' that match."
1669 (unless (and gnus-decode-encoded-word-methods-cache
1670 (eq gnus-newsgroup-name
1671 (car gnus-decode-encoded-word-methods-cache)))
1672 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1673 (dolist (method gnus-decode-encoded-word-methods)
1674 (if (symbolp method)
1675 (nconc gnus-decode-encoded-word-methods-cache (list method))
1676 (if (and gnus-newsgroup-name
1677 (string-match (car method) gnus-newsgroup-name))
1678 (nconc gnus-decode-encoded-word-methods-cache
1679 (list (cdr method)))))))
1680 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1681 (setq string (funcall method string))))
1683 ;; Subject simplification.
1685 (defun gnus-simplify-whitespace (str)
1686 "Remove excessive whitespace from STR."
1688 (while (string-match "[ \t][ \t]+" str)
1689 (setq str (concat (substring str 0 (match-beginning 0))
1691 (substring str (match-end 0)))))
1693 (when (string-match "^[ \t]+" str)
1694 (setq str (substring str (match-end 0))))
1696 (when (string-match "[ \t]+$" str)
1697 (setq str (substring str 0 (match-beginning 0))))
1700 (defun gnus-simplify-all-whitespace (str)
1701 "Remove all whitespace from STR."
1702 (while (string-match "[ \t\n]+" str)
1703 (setq str (replace-match "" nil nil str)))
1706 (defsubst gnus-simplify-subject-re (subject)
1707 "Remove \"Re:\" from subject lines."
1708 (if (string-match message-subject-re-regexp subject)
1709 (substring subject (match-end 0))
1712 (defun gnus-simplify-subject (subject &optional re-only)
1713 "Remove `Re:' and words in parentheses.
1714 If RE-ONLY is non-nil, strip leading `Re:'s only."
1715 (let ((case-fold-search t)) ;Ignore case.
1716 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1717 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1718 (setq subject (substring subject (match-end 0))))
1719 ;; Remove uninteresting prefixes.
1720 (when (and (not re-only)
1721 gnus-simplify-ignored-prefixes
1722 (string-match gnus-simplify-ignored-prefixes subject))
1723 (setq subject (substring subject (match-end 0))))
1724 ;; Remove words in parentheses from end.
1726 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1727 (setq subject (substring subject 0 (match-beginning 0)))))
1728 ;; Return subject string.
1731 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1733 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1734 (goto-char (point-min))
1735 (while (re-search-forward regexp nil t)
1736 (replace-match (or newtext ""))))
1738 (defun gnus-simplify-buffer-fuzzy (regexp)
1739 "Simplify string in the buffer fuzzily.
1740 The string in the accessible portion of the current buffer is simplified.
1741 It is assumed to be a single-line subject.
1742 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1743 matter is removed. Additional things can be deleted by setting
1744 `gnus-simplify-subject-fuzzy-regexp'."
1745 (let ((case-fold-search t)
1747 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1749 (while (not (eq modified-tick (buffer-modified-tick)))
1750 (setq modified-tick (buffer-modified-tick))
1753 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1755 (gnus-simplify-buffer-fuzzy-step regexp)))
1756 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1757 (gnus-simplify-buffer-fuzzy-step
1758 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1759 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1761 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1762 (gnus-simplify-buffer-fuzzy-step " +" " ")
1763 (gnus-simplify-buffer-fuzzy-step " $")
1764 (gnus-simplify-buffer-fuzzy-step "^ +")))
1766 (defun gnus-simplify-subject-fuzzy (subject)
1767 "Simplify a subject string fuzzily.
1768 See `gnus-simplify-buffer-fuzzy' for details."
1770 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1771 (gnus-set-work-buffer)
1772 (let ((case-fold-search t))
1773 ;; Remove uninteresting prefixes.
1774 (when (and gnus-simplify-ignored-prefixes
1775 (string-match gnus-simplify-ignored-prefixes subject))
1776 (setq subject (substring subject (match-end 0))))
1778 (inline (gnus-simplify-buffer-fuzzy regexp))
1781 (defsubst gnus-simplify-subject-fully (subject)
1782 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1784 (gnus-simplify-subject-functions
1785 (gnus-map-function gnus-simplify-subject-functions subject))
1786 ((null gnus-summary-gather-subject-limit)
1787 (gnus-simplify-subject-re subject))
1788 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1789 (gnus-simplify-subject-fuzzy subject))
1790 ((numberp gnus-summary-gather-subject-limit)
1791 (truncate-string-to-width (gnus-simplify-subject-re subject)
1792 gnus-summary-gather-subject-limit))
1796 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1797 "Check whether two subjects are equal.
1798 If optional argument SIMPLE-FIRST is t, first argument is already
1801 ((null simple-first)
1802 (equal (gnus-simplify-subject-fully s1)
1803 (gnus-simplify-subject-fully s2)))
1806 (gnus-simplify-subject-fully s2)))))
1808 (defun gnus-summary-bubble-group ()
1809 "Increase the score of the current group.
1810 This is a handy function to add to `gnus-summary-exit-hook' to
1811 increase the score of each group you read."
1812 (gnus-group-add-score gnus-newsgroup-name))
1816 ;;; Gnus summary mode
1819 (put 'gnus-summary-mode 'mode-class 'special)
1821 (defvar gnus-article-commands-menu)
1823 ;; Non-orthogonal keys
1825 (gnus-define-keys gnus-summary-mode-map
1826 " " gnus-summary-next-page
1827 "\177" gnus-summary-prev-page
1828 [delete] gnus-summary-prev-page
1829 [backspace] gnus-summary-prev-page
1830 "\r" gnus-summary-scroll-up
1831 "\M-\r" gnus-summary-scroll-down
1832 "n" gnus-summary-next-unread-article
1833 "p" gnus-summary-prev-unread-article
1834 "N" gnus-summary-next-article
1835 "P" gnus-summary-prev-article
1836 "\M-\C-n" gnus-summary-next-same-subject
1837 "\M-\C-p" gnus-summary-prev-same-subject
1838 "\M-n" gnus-summary-next-unread-subject
1839 "\M-p" gnus-summary-prev-unread-subject
1840 "." gnus-summary-first-unread-article
1841 "," gnus-summary-best-unread-article
1842 "\M-s" gnus-summary-search-article-forward
1843 "\M-r" gnus-summary-search-article-backward
1844 "\M-S" gnus-summary-repeat-search-article-forward
1845 "\M-R" gnus-summary-repeat-search-article-backward
1846 "<" gnus-summary-beginning-of-article
1847 ">" gnus-summary-end-of-article
1848 "j" gnus-summary-goto-article
1849 "^" gnus-summary-refer-parent-article
1850 "\M-^" gnus-summary-refer-article
1851 "u" gnus-summary-tick-article-forward
1852 "!" gnus-summary-tick-article-forward
1853 "U" gnus-summary-tick-article-backward
1854 "d" gnus-summary-mark-as-read-forward
1855 "D" gnus-summary-mark-as-read-backward
1856 "E" gnus-summary-mark-as-expirable
1857 "\M-u" gnus-summary-clear-mark-forward
1858 "\M-U" gnus-summary-clear-mark-backward
1859 "k" gnus-summary-kill-same-subject-and-select
1860 "\C-k" gnus-summary-kill-same-subject
1861 "\M-\C-k" gnus-summary-kill-thread
1862 "\M-\C-l" gnus-summary-lower-thread
1863 "e" gnus-summary-edit-article
1864 "#" gnus-summary-mark-as-processable
1865 "\M-#" gnus-summary-unmark-as-processable
1866 "\M-\C-t" gnus-summary-toggle-threads
1867 "\M-\C-s" gnus-summary-show-thread
1868 "\M-\C-h" gnus-summary-hide-thread
1869 "\M-\C-f" gnus-summary-next-thread
1870 "\M-\C-b" gnus-summary-prev-thread
1871 [(meta down)] gnus-summary-next-thread
1872 [(meta up)] gnus-summary-prev-thread
1873 "\M-\C-u" gnus-summary-up-thread
1874 "\M-\C-d" gnus-summary-down-thread
1875 "&" gnus-summary-execute-command
1876 "c" gnus-summary-catchup-and-exit
1877 "\C-w" gnus-summary-mark-region-as-read
1878 "\C-t" gnus-summary-toggle-truncation
1879 "?" gnus-summary-mark-as-dormant
1880 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1881 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1882 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1883 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1884 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1885 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1886 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1887 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1888 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1889 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1890 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1891 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1892 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1893 "=" gnus-summary-expand-window
1894 "\C-x\C-s" gnus-summary-reselect-current-group
1895 "\M-g" gnus-summary-rescan-group
1896 "\C-c\C-r" gnus-summary-caesar-message
1897 "f" gnus-summary-followup
1898 "F" gnus-summary-followup-with-original
1899 "C" gnus-summary-cancel-article
1900 "r" gnus-summary-reply
1901 "R" gnus-summary-reply-with-original
1902 "\C-c\C-f" gnus-summary-mail-forward
1903 "o" gnus-summary-save-article
1904 "\C-o" gnus-summary-save-article-mail
1905 "|" gnus-summary-pipe-output
1906 "\M-k" gnus-summary-edit-local-kill
1907 "\M-K" gnus-summary-edit-global-kill
1909 "\C-c\C-d" gnus-summary-describe-group
1910 "q" gnus-summary-exit
1911 "Q" gnus-summary-exit-no-update
1912 "\C-c\C-i" gnus-info-find-node
1913 gnus-mouse-2 gnus-mouse-pick-article
1914 [follow-link] mouse-face
1915 "m" gnus-summary-mail-other-window
1916 "a" gnus-summary-post-news
1917 "x" gnus-summary-limit-to-unread
1918 "s" gnus-summary-isearch-article
1919 [tab] gnus-summary-widget-forward
1920 [backtab] gnus-summary-widget-backward
1921 "t" gnus-summary-toggle-header
1922 "g" gnus-summary-show-article
1923 "l" gnus-summary-goto-last-article
1924 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1925 "\C-d" gnus-summary-enter-digest-group
1926 "\M-\C-d" gnus-summary-read-document
1927 "\M-\C-e" gnus-summary-edit-parameters
1928 "\M-\C-a" gnus-summary-customize-parameters
1930 "*" gnus-cache-enter-article
1931 "\M-*" gnus-cache-remove-article
1932 "\M-&" gnus-summary-universal-argument
1933 "\C-l" gnus-recenter
1934 "I" gnus-summary-increase-score
1935 "L" gnus-summary-lower-score
1936 "\M-i" gnus-symbolic-argument
1937 "h" gnus-summary-select-article-buffer
1939 "b" gnus-article-view-part
1940 "\M-t" gnus-summary-toggle-display-buttonized
1942 "V" gnus-summary-score-map
1943 "X" gnus-uu-extract-map
1944 "S" gnus-summary-send-map)
1946 ;; Sort of orthogonal keymap
1947 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1948 "t" gnus-summary-tick-article-forward
1949 "!" gnus-summary-tick-article-forward
1950 "d" gnus-summary-mark-as-read-forward
1951 "r" gnus-summary-mark-as-read-forward
1952 "c" gnus-summary-clear-mark-forward
1953 " " gnus-summary-clear-mark-forward
1954 "e" gnus-summary-mark-as-expirable
1955 "x" gnus-summary-mark-as-expirable
1956 "?" gnus-summary-mark-as-dormant
1957 "b" gnus-summary-set-bookmark
1958 "B" gnus-summary-remove-bookmark
1959 "#" gnus-summary-mark-as-processable
1960 "\M-#" gnus-summary-unmark-as-processable
1961 "S" gnus-summary-limit-include-expunged
1962 "C" gnus-summary-catchup
1963 "H" gnus-summary-catchup-to-here
1964 "h" gnus-summary-catchup-from-here
1965 "\C-c" gnus-summary-catchup-all
1966 "k" gnus-summary-kill-same-subject-and-select
1967 "K" gnus-summary-kill-same-subject
1968 "P" gnus-uu-mark-map)
1970 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1971 "c" gnus-summary-clear-above
1972 "u" gnus-summary-tick-above
1973 "m" gnus-summary-mark-above
1974 "k" gnus-summary-kill-below)
1976 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1977 "/" gnus-summary-limit-to-subject
1978 "n" gnus-summary-limit-to-articles
1979 "b" gnus-summary-limit-to-bodies
1980 "h" gnus-summary-limit-to-headers
1981 "w" gnus-summary-pop-limit
1982 "s" gnus-summary-limit-to-subject
1983 "a" gnus-summary-limit-to-author
1984 "u" gnus-summary-limit-to-unread
1985 "m" gnus-summary-limit-to-marks
1986 "M" gnus-summary-limit-exclude-marks
1987 "v" gnus-summary-limit-to-score
1988 "*" gnus-summary-limit-include-cached
1989 "D" gnus-summary-limit-include-dormant
1990 "T" gnus-summary-limit-include-thread
1991 "d" gnus-summary-limit-exclude-dormant
1992 "t" gnus-summary-limit-to-age
1993 "." gnus-summary-limit-to-unseen
1994 "x" gnus-summary-limit-to-extra
1995 "p" gnus-summary-limit-to-display-predicate
1996 "E" gnus-summary-limit-include-expunged
1997 "c" gnus-summary-limit-exclude-childless-dormant
1998 "C" gnus-summary-limit-mark-excluded-as-read
1999 "o" gnus-summary-insert-old-articles
2000 "N" gnus-summary-insert-new-articles
2001 "S" gnus-summary-limit-to-singletons
2002 "r" gnus-summary-limit-to-replied
2003 "R" gnus-summary-limit-to-recipient
2004 "A" gnus-summary-limit-to-address)
2006 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2007 "n" gnus-summary-next-unread-article
2008 "p" gnus-summary-prev-unread-article
2009 "N" gnus-summary-next-article
2010 "P" gnus-summary-prev-article
2011 "\C-n" gnus-summary-next-same-subject
2012 "\C-p" gnus-summary-prev-same-subject
2013 "\M-n" gnus-summary-next-unread-subject
2014 "\M-p" gnus-summary-prev-unread-subject
2015 "f" gnus-summary-first-unread-article
2016 "b" gnus-summary-best-unread-article
2017 "j" gnus-summary-goto-article
2018 "g" gnus-summary-goto-subject
2019 "l" gnus-summary-goto-last-article
2020 "o" gnus-summary-pop-article)
2022 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2023 "k" gnus-summary-kill-thread
2024 "E" gnus-summary-expire-thread
2025 "l" gnus-summary-lower-thread
2026 "i" gnus-summary-raise-thread
2027 "T" gnus-summary-toggle-threads
2028 "t" gnus-summary-rethread-current
2029 "^" gnus-summary-reparent-thread
2030 "\M-^" gnus-summary-reparent-children
2031 "s" gnus-summary-show-thread
2032 "S" gnus-summary-show-all-threads
2033 "h" gnus-summary-hide-thread
2034 "H" gnus-summary-hide-all-threads
2035 "n" gnus-summary-next-thread
2036 "p" gnus-summary-prev-thread
2037 "u" gnus-summary-up-thread
2038 "o" gnus-summary-top-thread
2039 "d" gnus-summary-down-thread
2040 "#" gnus-uu-mark-thread
2041 "\M-#" gnus-uu-unmark-thread)
2043 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2044 "g" gnus-summary-prepare
2045 "c" gnus-summary-insert-cached-articles
2046 "d" gnus-summary-insert-dormant-articles
2047 "t" gnus-summary-insert-ticked-articles)
2049 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2050 "c" gnus-summary-catchup-and-exit
2051 "C" gnus-summary-catchup-all-and-exit
2052 "E" gnus-summary-exit-no-update
2053 "Q" gnus-summary-exit
2054 "Z" gnus-summary-exit
2055 "n" gnus-summary-catchup-and-goto-next-group
2056 "p" gnus-summary-catchup-and-goto-prev-group
2057 "R" gnus-summary-reselect-current-group
2058 "G" gnus-summary-rescan-group
2059 "N" gnus-summary-next-group
2060 "s" gnus-summary-save-newsrc
2061 "P" gnus-summary-prev-group)
2063 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2064 " " gnus-summary-next-page
2065 "n" gnus-summary-next-page
2066 "\177" gnus-summary-prev-page
2067 [delete] gnus-summary-prev-page
2068 "p" gnus-summary-prev-page
2069 "\r" gnus-summary-scroll-up
2070 "\M-\r" gnus-summary-scroll-down
2071 "<" gnus-summary-beginning-of-article
2072 ">" gnus-summary-end-of-article
2073 "b" gnus-summary-beginning-of-article
2074 "e" gnus-summary-end-of-article
2075 "^" gnus-summary-refer-parent-article
2076 "r" gnus-summary-refer-parent-article
2077 "C" gnus-summary-show-complete-article
2078 "D" gnus-summary-enter-digest-group
2079 "R" gnus-summary-refer-references
2080 "T" gnus-summary-refer-thread
2081 "W" gnus-warp-to-article
2082 "g" gnus-summary-show-article
2083 "s" gnus-summary-isearch-article
2084 [tab] gnus-summary-widget-forward
2085 [backtab] gnus-summary-widget-backward
2086 "P" gnus-summary-print-article
2087 "S" gnus-sticky-article
2088 "M" gnus-mailing-list-insinuate
2089 "t" gnus-article-babel)
2091 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2092 "b" gnus-article-add-buttons
2093 "B" gnus-article-add-buttons-to-head
2094 "o" gnus-article-treat-overstrike
2095 "e" gnus-article-emphasize
2096 "w" gnus-article-fill-cited-article
2097 "Q" gnus-article-fill-long-lines
2098 "L" gnus-article-toggle-truncate-lines
2099 "C" gnus-article-capitalize-sentences
2100 "c" gnus-article-remove-cr
2101 "q" gnus-article-de-quoted-unreadable
2102 "6" gnus-article-de-base64-unreadable
2103 "Z" gnus-article-decode-HZ
2104 "A" gnus-article-treat-ansi-sequences
2105 "h" gnus-article-wash-html
2106 "u" gnus-article-unsplit-urls
2107 "s" gnus-summary-force-verify-and-decrypt
2108 "f" gnus-article-display-x-face
2109 "l" gnus-summary-stop-page-breaking
2110 "r" gnus-summary-caesar-message
2111 "m" gnus-summary-morse-message
2112 "t" gnus-summary-toggle-header
2113 "g" gnus-treat-smiley
2114 "v" gnus-summary-verbose-headers
2115 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2116 "p" gnus-article-verify-x-pgp-sig
2117 "d" gnus-article-treat-dumbquotes
2118 "U" gnus-article-treat-non-ascii
2119 "i" gnus-summary-idna-message)
2121 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2122 ;; mnemonic: deuglif*Y*
2123 "u" gnus-article-outlook-unwrap-lines
2124 "a" gnus-article-outlook-repair-attribution
2125 "c" gnus-article-outlook-rearrange-citation
2126 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2128 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2129 "a" gnus-article-hide
2130 "h" gnus-article-hide-headers
2131 "b" gnus-article-hide-boring-headers
2132 "s" gnus-article-hide-signature
2133 "c" gnus-article-hide-citation
2134 "C" gnus-article-hide-citation-in-followups
2135 "l" gnus-article-hide-list-identifiers
2136 "B" gnus-article-strip-banner
2137 "P" gnus-article-hide-pem
2138 "\C-c" gnus-article-hide-citation-maybe)
2140 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2141 "a" gnus-article-highlight
2142 "h" gnus-article-highlight-headers
2143 "c" gnus-article-highlight-citation
2144 "s" gnus-article-highlight-signature)
2146 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2147 "f" gnus-article-treat-fold-headers
2148 "u" gnus-article-treat-unfold-headers
2149 "n" gnus-article-treat-fold-newsgroups)
2151 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2152 "x" gnus-article-display-x-face
2153 "d" gnus-article-display-face
2154 "s" gnus-treat-smiley
2155 "D" gnus-article-remove-images
2156 "W" gnus-article-show-images
2157 "f" gnus-treat-from-picon
2158 "m" gnus-treat-mail-picon
2159 "n" gnus-treat-newsgroups-picon
2160 "g" gnus-treat-from-gravatar
2161 "h" gnus-treat-mail-gravatar)
2163 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2164 "w" gnus-article-decode-mime-words
2165 "c" gnus-article-decode-charset
2166 "v" gnus-mime-view-all-parts
2167 "b" gnus-article-view-part)
2169 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2170 "z" gnus-article-date-ut
2171 "u" gnus-article-date-ut
2172 "l" gnus-article-date-local
2173 "p" gnus-article-date-english
2174 "e" gnus-article-date-lapsed
2175 "o" gnus-article-date-original
2176 "i" gnus-article-date-iso8601
2177 "s" gnus-article-date-user)
2179 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2180 "t" gnus-article-remove-trailing-blank-lines
2181 "l" gnus-article-strip-leading-blank-lines
2182 "m" gnus-article-strip-multiple-blank-lines
2183 "a" gnus-article-strip-blank-lines
2184 "A" gnus-article-strip-all-blank-lines
2185 "s" gnus-article-strip-leading-space
2186 "e" gnus-article-strip-trailing-space
2187 "w" gnus-article-remove-leading-whitespace)
2189 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2191 "d" gnus-summary-describe-group
2192 "h" gnus-summary-describe-briefly
2193 "i" gnus-info-find-node)
2195 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2196 "e" gnus-summary-expire-articles
2197 "\M-\C-e" gnus-summary-expire-articles-now
2198 "\177" gnus-summary-delete-article
2199 [delete] gnus-summary-delete-article
2200 [backspace] gnus-summary-delete-article
2201 "m" gnus-summary-move-article
2202 "r" gnus-summary-respool-article
2203 "w" gnus-summary-edit-article
2204 "c" gnus-summary-copy-article
2205 "B" gnus-summary-crosspost-article
2206 "q" gnus-summary-respool-query
2207 "t" gnus-summary-respool-trace
2208 "i" gnus-summary-import-article
2209 "I" gnus-summary-create-article
2210 "p" gnus-summary-article-posted-p)
2212 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2213 "o" gnus-summary-save-article
2214 "m" gnus-summary-save-article-mail
2215 "F" gnus-summary-write-article-file
2216 "r" gnus-summary-save-article-rmail
2217 "f" gnus-summary-save-article-file
2218 "b" gnus-summary-save-article-body-file
2219 "B" gnus-summary-write-article-body-file
2220 "h" gnus-summary-save-article-folder
2221 "v" gnus-summary-save-article-vm
2222 "p" gnus-summary-pipe-output
2223 "P" gnus-summary-muttprint)
2225 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2226 "b" gnus-summary-display-buttonized
2227 "m" gnus-summary-repair-multipart
2228 "v" gnus-article-view-part
2229 "o" gnus-article-save-part
2230 "O" gnus-article-save-part-and-strip
2231 "r" gnus-article-replace-part
2232 "d" gnus-article-delete-part
2233 "t" gnus-article-view-part-as-type
2234 "j" gnus-article-jump-to-part
2235 "c" gnus-article-copy-part
2236 "C" gnus-article-view-part-as-charset
2237 "e" gnus-article-view-part-externally
2238 "H" gnus-article-browse-html-article
2239 "E" gnus-article-encrypt-body
2240 "i" gnus-article-inline-part
2241 "|" gnus-article-pipe-part)
2243 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2244 "p" gnus-summary-mark-as-processable
2245 "u" gnus-summary-unmark-as-processable
2246 "U" gnus-summary-unmark-all-processable
2247 "v" gnus-uu-mark-over
2248 "s" gnus-uu-mark-series
2249 "r" gnus-uu-mark-region
2250 "g" gnus-uu-unmark-region
2251 "R" gnus-uu-mark-by-regexp
2252 "G" gnus-uu-unmark-by-regexp
2253 "t" gnus-uu-mark-thread
2254 "T" gnus-uu-unmark-thread
2255 "a" gnus-uu-mark-all
2256 "b" gnus-uu-mark-buffer
2257 "S" gnus-uu-mark-sparse
2258 "k" gnus-summary-kill-process-mark
2259 "y" gnus-summary-yank-process-mark
2260 "w" gnus-summary-save-process-mark
2261 "i" gnus-uu-invert-processable)
2263 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2264 ;;"x" gnus-uu-extract-any
2265 "m" gnus-summary-save-parts
2266 "u" gnus-uu-decode-uu
2267 "U" gnus-uu-decode-uu-and-save
2268 "s" gnus-uu-decode-unshar
2269 "S" gnus-uu-decode-unshar-and-save
2270 "o" gnus-uu-decode-save
2271 "O" gnus-uu-decode-save
2272 "b" gnus-uu-decode-binhex
2273 "B" gnus-uu-decode-binhex
2274 "Y" gnus-uu-decode-yenc
2275 "p" gnus-uu-decode-postscript
2276 "P" gnus-uu-decode-postscript-and-save)
2279 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2280 "u" gnus-uu-decode-uu-view
2281 "U" gnus-uu-decode-uu-and-save-view
2282 "s" gnus-uu-decode-unshar-view
2283 "S" gnus-uu-decode-unshar-and-save-view
2284 "o" gnus-uu-decode-save-view
2285 "O" gnus-uu-decode-save-view
2286 "b" gnus-uu-decode-binhex-view
2287 "B" gnus-uu-decode-binhex-view
2288 "p" gnus-uu-decode-postscript-view
2289 "P" gnus-uu-decode-postscript-and-save-view)
2291 (defvar gnus-article-post-menu nil)
2293 (defconst gnus-summary-menu-maxlen 20)
2295 (defun gnus-summary-menu-split (menu)
2296 ;; If we have lots of elements, divide them into groups of 20
2297 ;; and make a pane (or submenu) for each one.
2298 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2299 (let ((menu menu) sublists next
2302 ;; Pull off the next gnus-summary-menu-maxlen elements
2303 ;; and make them the next element of sublist.
2304 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2306 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2308 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2309 (aref (car (last menu)) 0)) menu)
2313 (nreverse sublists))
2314 ;; Few elements--put them all in one pane.
2317 (defun gnus-summary-make-menu-bar ()
2318 (gnus-turn-off-edit-menu 'summary)
2320 (unless (boundp 'gnus-summary-misc-menu)
2323 gnus-summary-kill-menu gnus-summary-mode-map ""
2328 ["Customize" gnus-score-customize t])
2329 (gnus-make-score-map 'increase)
2330 (gnus-make-score-map 'lower)
2332 ["Kill below" gnus-summary-kill-below t]
2333 ["Mark above" gnus-summary-mark-above t]
2334 ["Tick above" gnus-summary-tick-above t]
2335 ["Clear above" gnus-summary-clear-above t])
2336 ["Current score" gnus-summary-current-score t]
2337 ["Set score" gnus-summary-set-score t]
2338 ["Switch current score file..." gnus-score-change-score-file t]
2339 ["Set mark below..." gnus-score-set-mark-below t]
2340 ["Set expunge below..." gnus-score-set-expunge-below t]
2341 ["Edit current score file" gnus-score-edit-current-scores t]
2342 ["Edit score file..." gnus-score-edit-file t]
2343 ["Trace score" gnus-score-find-trace t]
2344 ["Find words" gnus-score-find-favourite-words t]
2345 ["Rescore buffer" gnus-summary-rescore t]
2346 ["Increase score..." gnus-summary-increase-score t]
2347 ["Lower score..." gnus-summary-lower-score t]))))
2349 ;; Define both the Article menu in the summary buffer and the
2350 ;; equivalent Commands menu in the article buffer here for
2354 ["All" gnus-article-hide t]
2355 ["Headers" gnus-article-hide-headers t]
2356 ["Signature" gnus-article-hide-signature t]
2357 ["Citation" gnus-article-hide-citation t]
2358 ["List identifiers" gnus-article-hide-list-identifiers t]
2359 ["Banner" gnus-article-strip-banner t]
2360 ["Boring headers" gnus-article-hide-boring-headers t])
2362 ["All" gnus-article-highlight t]
2363 ["Headers" gnus-article-highlight-headers t]
2364 ["Signature" gnus-article-highlight-signature t]
2365 ["Citation" gnus-article-highlight-citation t])
2367 ["Words" gnus-article-decode-mime-words t]
2368 ["Charset" gnus-article-decode-charset t]
2369 ["QP" gnus-article-de-quoted-unreadable t]
2370 ["Base64" gnus-article-de-base64-unreadable t]
2371 ["View MIME buttons" gnus-summary-display-buttonized t]
2372 ["View all" gnus-mime-view-all-parts t]
2373 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2374 ["Encrypt body" gnus-article-encrypt-body
2375 :active (not (gnus-group-read-only-p))
2376 ,@(if (featurep 'xemacs) nil
2377 '(:help "Encrypt the message body on disk"))]
2378 ["Extract all parts..." gnus-summary-save-parts t]
2380 ["Repair multipart" gnus-summary-repair-multipart t]
2381 ["Pipe part..." gnus-article-pipe-part t]
2382 ["Inline part" gnus-article-inline-part t]
2383 ["View part as type..." gnus-article-view-part-as-type t]
2384 ["Encrypt body" gnus-article-encrypt-body
2385 :active (not (gnus-group-read-only-p))
2386 ,@(if (featurep 'xemacs) nil
2387 '(:help "Encrypt the message body on disk"))]
2388 ["View part externally" gnus-article-view-part-externally t]
2389 ["View HTML parts in browser" gnus-article-browse-html-article t]
2390 ["View part with charset..." gnus-article-view-part-as-charset t]
2391 ["Copy part" gnus-article-copy-part t]
2392 ["Save part..." gnus-article-save-part t]
2393 ["View part" gnus-article-view-part t]))
2395 ["Local" gnus-article-date-local t]
2396 ["ISO8601" gnus-article-date-iso8601 t]
2397 ["UT" gnus-article-date-ut t]
2398 ["Original" gnus-article-date-original t]
2399 ["Lapsed" gnus-article-date-lapsed t]
2400 ["User-defined" gnus-article-date-user t])
2402 ["Remove images" gnus-article-remove-images t]
2403 ["Toggle smiley" gnus-treat-smiley t]
2404 ["Show X-Face" gnus-article-display-x-face t]
2405 ["Show picons in From" gnus-treat-from-picon t]
2406 ["Show picons in mail headers" gnus-treat-mail-picon t]
2407 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2408 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2409 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2410 ("View as different encoding"
2411 ,@(gnus-summary-menu-split
2414 ;; Since easymenu under Emacs doesn't allow
2415 ;; lambda forms for menu commands, we should
2416 ;; provide intern'ed function symbols.
2417 (let ((command (intern (format "\
2418 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2422 (let ((gnus-summary-show-article-charset-alist
2424 (gnus-summary-show-article 1))))
2425 `[,(symbol-name cs) ,command t]))
2426 (sort (if (fboundp 'coding-system-list)
2427 (coding-system-list)
2428 (mapcar 'car mm-mime-mule-charset-alist))
2432 ["Leading" gnus-article-strip-leading-blank-lines t]
2433 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2434 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2435 ["All of the above" gnus-article-strip-blank-lines t]
2436 ["All" gnus-article-strip-all-blank-lines t]
2437 ["Leading space" gnus-article-strip-leading-space t]
2438 ["Trailing space" gnus-article-strip-trailing-space t]
2439 ["Leading space in headers"
2440 gnus-article-remove-leading-whitespace t])
2441 ["Overstrike" gnus-article-treat-overstrike t]
2442 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2443 ["Non-ASCII" gnus-article-treat-non-ascii t]
2444 ["Emphasis" gnus-article-emphasize t]
2445 ["Word wrap" gnus-article-fill-cited-article t]
2446 ["Fill long lines" gnus-article-fill-long-lines t]
2447 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2448 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2449 ["Remove CR" gnus-article-remove-cr t]
2450 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2451 ["Base64" gnus-article-de-base64-unreadable t]
2452 ["Rot 13" gnus-summary-caesar-message
2453 ,@(if (featurep 'xemacs) '(t)
2454 '(:help "\"Caesar rotate\" article by 13"))]
2455 ["De-IDNA" gnus-summary-idna-message t]
2456 ["Morse decode" gnus-summary-morse-message t]
2457 ["Unix pipe..." gnus-summary-pipe-message t]
2458 ["Add buttons" gnus-article-add-buttons t]
2459 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2460 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2461 ["Verbose header" gnus-summary-verbose-headers t]
2462 ["Toggle header" gnus-summary-toggle-header t]
2463 ["Unfold headers" gnus-article-treat-unfold-headers t]
2464 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2465 ["Html" gnus-article-wash-html t]
2466 ["Unsplit URLs" gnus-article-unsplit-urls t]
2467 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2468 ["Decode HZ" gnus-article-decode-HZ t]
2469 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2470 ("(Outlook) Deuglify"
2471 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2472 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2473 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2474 ["Full (Outlook) deuglify"
2475 gnus-article-outlook-deuglify-article t])
2478 ["Save in default format..." gnus-summary-save-article
2479 ,@(if (featurep 'xemacs) '(t)
2480 '(:help "Save article using default method"))]
2481 ["Save in file..." gnus-summary-save-article-file
2482 ,@(if (featurep 'xemacs) '(t)
2483 '(:help "Save article in file"))]
2484 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2485 ["Save in MH folder..." gnus-summary-save-article-folder t]
2486 ["Save in VM folder..." gnus-summary-save-article-vm t]
2487 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2488 ["Save body in file..." gnus-summary-save-article-body-file t]
2489 ["Pipe through a filter..." gnus-summary-pipe-output t]
2490 ["Print with Muttprint..." gnus-summary-muttprint t]
2491 ["Print" gnus-summary-print-article
2492 ,@(if (featurep 'xemacs) '(t)
2493 '(:help "Generate and print a PostScript image"))])
2494 ("Copy, move,... (Backend)"
2495 ,@(if (featurep 'xemacs) nil
2496 '(:help "Copying, moving, expiring articles..."))
2497 ["Respool article..." gnus-summary-respool-article t]
2498 ["Move article..." gnus-summary-move-article
2499 (gnus-check-backend-function
2500 'request-move-article gnus-newsgroup-name)]
2501 ["Copy article..." gnus-summary-copy-article t]
2502 ["Crosspost article..." gnus-summary-crosspost-article
2503 (gnus-check-backend-function
2504 'request-replace-article gnus-newsgroup-name)]
2505 ["Import file..." gnus-summary-import-article
2506 (gnus-check-backend-function
2507 'request-accept-article gnus-newsgroup-name)]
2508 ["Create article..." gnus-summary-create-article
2509 (gnus-check-backend-function
2510 'request-accept-article gnus-newsgroup-name)]
2511 ["Check if posted" gnus-summary-article-posted-p t]
2512 ["Edit article" gnus-summary-edit-article
2513 (not (gnus-group-read-only-p))]
2514 ["Delete article" gnus-summary-delete-article
2515 (gnus-check-backend-function
2516 'request-expire-articles gnus-newsgroup-name)]
2517 ["Query respool" gnus-summary-respool-query t]
2518 ["Trace respool" gnus-summary-respool-trace t]
2519 ["Delete expirable articles" gnus-summary-expire-articles-now
2520 (gnus-check-backend-function
2521 'request-expire-articles gnus-newsgroup-name)])
2523 ["Uudecode" gnus-uu-decode-uu
2524 ,@(if (featurep 'xemacs) '(t)
2525 '(:help "Decode uuencoded article(s)"))]
2526 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2527 ["Unshar" gnus-uu-decode-unshar t]
2528 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2529 ["Save" gnus-uu-decode-save t]
2530 ["Binhex" gnus-uu-decode-binhex t]
2531 ["PostScript" gnus-uu-decode-postscript t]
2532 ["All MIME parts" gnus-summary-save-parts t])
2534 ["Enter article" gnus-cache-enter-article t]
2535 ["Remove article" gnus-cache-remove-article t])
2536 ["Translate" gnus-article-babel t]
2537 ["Select article buffer" gnus-summary-select-article-buffer t]
2538 ["Make article buffer sticky" gnus-sticky-article t]
2539 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2540 ["Isearch article..." gnus-summary-isearch-article t]
2541 ["Beginning of the article" gnus-summary-beginning-of-article t]
2542 ["End of the article" gnus-summary-end-of-article t]
2543 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2544 ["Fetch referenced articles" gnus-summary-refer-references t]
2545 ["Fetch current thread" gnus-summary-refer-thread t]
2546 ["Fetch article with id..." gnus-summary-refer-article t]
2547 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2548 ["Redisplay" gnus-summary-show-article t]
2549 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2551 gnus-summary-article-menu gnus-summary-mode-map ""
2552 (cons "Article" innards))
2554 (if (not (keymapp gnus-summary-article-menu))
2556 gnus-article-commands-menu gnus-article-mode-map ""
2557 (cons "Commands" innards))
2558 ;; in Emacs, don't share menu.
2559 (setq gnus-article-commands-menu
2560 (copy-keymap gnus-summary-article-menu))
2561 (define-key gnus-article-mode-map [menu-bar commands]
2562 (cons "Commands" gnus-article-commands-menu))))
2565 gnus-summary-thread-menu gnus-summary-mode-map ""
2567 ["Find all messages in thread" gnus-summary-refer-thread t]
2568 ["Toggle threading" gnus-summary-toggle-threads t]
2569 ["Hide threads" gnus-summary-hide-all-threads t]
2570 ["Show threads" gnus-summary-show-all-threads t]
2571 ["Hide thread" gnus-summary-hide-thread t]
2572 ["Show thread" gnus-summary-show-thread t]
2573 ["Go to next thread" gnus-summary-next-thread t]
2574 ["Go to previous thread" gnus-summary-prev-thread t]
2575 ["Go down thread" gnus-summary-down-thread t]
2576 ["Go up thread" gnus-summary-up-thread t]
2577 ["Top of thread" gnus-summary-top-thread t]
2578 ["Mark thread as read" gnus-summary-kill-thread t]
2579 ["Mark thread as expired" gnus-summary-expire-thread t]
2580 ["Lower thread score" gnus-summary-lower-thread t]
2581 ["Raise thread score" gnus-summary-raise-thread t]
2582 ["Rethread current" gnus-summary-rethread-current t]))
2585 gnus-summary-post-menu gnus-summary-mode-map ""
2587 ["Send a message (mail or news)" gnus-summary-post-news
2588 ,@(if (featurep 'xemacs) '(t)
2589 '(:help "Compose a new message (mail or news)"))]
2590 ["Followup" gnus-summary-followup
2591 ,@(if (featurep 'xemacs) '(t)
2592 '(:help "Post followup to this article"))]
2593 ["Followup and yank" gnus-summary-followup-with-original
2594 ,@(if (featurep 'xemacs) '(t)
2595 '(:help "Post followup to this article, quoting its contents"))]
2596 ["Supersede article" gnus-summary-supersede-article t]
2597 ["Cancel article" gnus-summary-cancel-article
2598 ,@(if (featurep 'xemacs) '(t)
2599 '(:help "Cancel an article you posted"))]
2600 ["Reply" gnus-summary-reply t]
2601 ["Reply and yank" gnus-summary-reply-with-original t]
2602 ["Wide reply" gnus-summary-wide-reply t]
2603 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2604 ,@(if (featurep 'xemacs) '(t)
2605 '(:help "Mail a reply, quoting this article"))]
2606 ["Very wide reply" gnus-summary-very-wide-reply t]
2607 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2608 ,@(if (featurep 'xemacs) '(t)
2609 '(:help "Mail a very wide reply, quoting this article"))]
2610 ["Mail forward" gnus-summary-mail-forward t]
2611 ["Post forward" gnus-summary-post-forward t]
2612 ["Digest and mail" gnus-uu-digest-mail-forward t]
2613 ["Digest and post" gnus-uu-digest-post-forward t]
2614 ["Resend message" gnus-summary-resend-message t]
2615 ["Resend message edit" gnus-summary-resend-message-edit t]
2616 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2617 ["Send a mail" gnus-summary-mail-other-window t]
2618 ["Create a local message" gnus-summary-news-other-window t]
2619 ["Uuencode and post" gnus-uu-post-news
2620 ,@(if (featurep 'xemacs) '(t)
2621 '(:help "Post a uuencoded article"))]
2622 ["Followup via news" gnus-summary-followup-to-mail t]
2623 ["Followup via news and yank"
2624 gnus-summary-followup-to-mail-with-original t]
2625 ["Strip signature on reply"
2628 (if (not (memq message-cite-function
2629 '(message-cite-original-without-signature
2630 message-cite-original)))
2631 ;; Stupid workaround for XEmacs not honoring :visible.
2632 (message "Can't toggle this value of `message-cite-function'")
2633 (setq message-cite-function
2634 (if (eq message-cite-function
2635 'message-cite-original-without-signature)
2636 'message-cite-original
2637 'message-cite-original-without-signature))))
2638 ;; XEmacs barfs on :visible.
2639 ,@(if (featurep 'xemacs) nil
2640 '(:visible (memq message-cite-function
2641 '(message-cite-original-without-signature
2642 message-cite-original))))
2644 :selected (eq message-cite-function
2645 'message-cite-original-without-signature)
2646 ,@(if (featurep 'xemacs) nil
2647 '(:help "Strip signature from cited article when replying."))]
2649 ;;["Send" gnus-summary-send-draft t]
2650 ;;["Send bounced" gnus-resend-bounced-mail t])
2654 ((not (keymapp gnus-summary-post-menu))
2655 (setq gnus-article-post-menu gnus-summary-post-menu))
2656 ((not gnus-article-post-menu)
2657 ;; Don't share post menu.
2658 (setq gnus-article-post-menu
2659 (copy-keymap gnus-summary-post-menu))))
2660 (define-key gnus-article-mode-map [menu-bar post]
2661 (cons "Post" gnus-article-post-menu))
2664 gnus-summary-misc-menu gnus-summary-mode-map ""
2667 ["Mark as read" gnus-summary-mark-as-read-forward t]
2668 ["Mark same subject and select"
2669 gnus-summary-kill-same-subject-and-select t]
2670 ["Mark same subject" gnus-summary-kill-same-subject t]
2671 ["Catchup" gnus-summary-catchup
2672 ,@(if (featurep 'xemacs) '(t)
2673 '(:help "Mark unread articles in this group as read"))]
2674 ["Catchup all" gnus-summary-catchup-all t]
2675 ["Catchup to here" gnus-summary-catchup-to-here t]
2676 ["Catchup from here" gnus-summary-catchup-from-here t]
2677 ["Catchup region" gnus-summary-mark-region-as-read
2678 (gnus-mark-active-p)]
2679 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2681 ["Tick" gnus-summary-tick-article-forward t]
2682 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2683 ["Remove marks" gnus-summary-clear-mark-forward t]
2684 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2685 ["Set bookmark" gnus-summary-set-bookmark t]
2686 ["Remove bookmark" gnus-summary-remove-bookmark t])
2688 ["Marks..." gnus-summary-limit-to-marks t]
2689 ["Subject..." gnus-summary-limit-to-subject t]
2690 ["Author..." gnus-summary-limit-to-author t]
2691 ["Recipient..." gnus-summary-limit-to-recipient t]
2692 ["Address..." gnus-summary-limit-to-address t]
2693 ["Age..." gnus-summary-limit-to-age t]
2694 ["Extra..." gnus-summary-limit-to-extra t]
2695 ["Score..." gnus-summary-limit-to-score t]
2696 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2697 ["Unread" gnus-summary-limit-to-unread t]
2698 ["Unseen" gnus-summary-limit-to-unseen t]
2699 ["Singletons" gnus-summary-limit-to-singletons t]
2700 ["Replied" gnus-summary-limit-to-replied t]
2701 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2702 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2703 ["Pop limit" gnus-summary-pop-limit t]
2704 ["Show dormant" gnus-summary-limit-include-dormant t]
2705 ["Hide childless dormant"
2706 gnus-summary-limit-exclude-childless-dormant t]
2707 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2708 ["Hide marked" gnus-summary-limit-exclude-marks t]
2709 ["Show expunged" gnus-summary-limit-include-expunged t])
2711 ["Set mark" gnus-summary-mark-as-processable t]
2712 ["Remove mark" gnus-summary-unmark-as-processable t]
2713 ["Remove all marks" gnus-summary-unmark-all-processable t]
2714 ["Invert marks" gnus-uu-invert-processable t]
2715 ["Mark above" gnus-uu-mark-over t]
2716 ["Mark series" gnus-uu-mark-series t]
2717 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2718 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2719 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2720 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2721 ["Mark all" gnus-uu-mark-all t]
2722 ["Mark buffer" gnus-uu-mark-buffer t]
2723 ["Mark sparse" gnus-uu-mark-sparse t]
2724 ["Mark thread" gnus-uu-mark-thread t]
2725 ["Unmark thread" gnus-uu-unmark-thread t]
2726 ("Process Mark Sets"
2727 ["Kill" gnus-summary-kill-process-mark t]
2728 ["Yank" gnus-summary-yank-process-mark
2729 gnus-newsgroup-process-stack]
2730 ["Save" gnus-summary-save-process-mark t]
2731 ["Run command on marked..." gnus-summary-universal-argument t]))
2734 ["Page forward" gnus-summary-next-page
2735 ,@(if (featurep 'xemacs) '(t)
2736 '(:help "Show next page of article"))]
2737 ["Page backward" gnus-summary-prev-page
2738 ,@(if (featurep 'xemacs) '(t)
2739 '(:help "Show previous page of article"))]
2740 ["Line forward" gnus-summary-scroll-up t])
2742 ["Next unread article" gnus-summary-next-unread-article t]
2743 ["Previous unread article" gnus-summary-prev-unread-article t]
2744 ["Next article" gnus-summary-next-article t]
2745 ["Previous article" gnus-summary-prev-article t]
2746 ["Next unread subject" gnus-summary-next-unread-subject t]
2747 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2748 ["Next article same subject" gnus-summary-next-same-subject t]
2749 ["Previous article same subject" gnus-summary-prev-same-subject t]
2750 ["First unread article" gnus-summary-first-unread-article t]
2751 ["Best unread article" gnus-summary-best-unread-article t]
2752 ["Go to subject number..." gnus-summary-goto-subject t]
2753 ["Go to article number..." gnus-summary-goto-article t]
2754 ["Go to the last article" gnus-summary-goto-last-article t]
2755 ["Pop article off history" gnus-summary-pop-article t])
2757 ["Sort by number" gnus-summary-sort-by-number t]
2758 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2759 ["Sort by author" gnus-summary-sort-by-author t]
2760 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2761 ["Sort by subject" gnus-summary-sort-by-subject t]
2762 ["Sort by date" gnus-summary-sort-by-date t]
2763 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2764 ["Sort by score" gnus-summary-sort-by-score t]
2765 ["Sort by lines" gnus-summary-sort-by-lines t]
2766 ["Sort by characters" gnus-summary-sort-by-chars t]
2767 ["Randomize" gnus-summary-sort-by-random t]
2768 ["Original sort" gnus-summary-sort-by-original t])
2770 ["Describe group" gnus-summary-describe-group t]
2771 ["Read manual" gnus-info-find-node t])
2773 ["Pick and read" gnus-pick-mode t]
2774 ["Binary" gnus-binary-mode t])
2776 ["Regenerate" gnus-summary-prepare t]
2777 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2778 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2779 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2780 ["Toggle threading" gnus-summary-toggle-threads t])
2781 ["See old articles" gnus-summary-insert-old-articles t]
2782 ["See new articles" gnus-summary-insert-new-articles t]
2783 ["Filter articles..." gnus-summary-execute-command t]
2784 ["Run command on articles..." gnus-summary-universal-argument t]
2785 ["Search articles forward..." gnus-summary-search-article-forward t]
2786 ["Search articles backward..." gnus-summary-search-article-backward t]
2787 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2788 ["Expand window" gnus-summary-expand-window t]
2789 ["Expire expirable articles" gnus-summary-expire-articles
2790 (gnus-check-backend-function
2791 'request-expire-articles gnus-newsgroup-name)]
2792 ["Edit local kill file" gnus-summary-edit-local-kill t]
2793 ["Edit main kill file" gnus-summary-edit-global-kill t]
2794 ["Edit group parameters" gnus-summary-edit-parameters t]
2795 ["Customize group parameters" gnus-summary-customize-parameters t]
2796 ["Send a bug report" gnus-bug t]
2798 ["Catchup and exit" gnus-summary-catchup-and-exit
2799 ,@(if (featurep 'xemacs) '(t)
2800 '(:help "Mark unread articles in this group as read, then exit"))]
2801 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2802 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2803 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2804 ["Exit group" gnus-summary-exit
2805 ,@(if (featurep 'xemacs) '(t)
2806 '(:help "Exit current group, return to group selection mode"))]
2807 ["Exit group without updating" gnus-summary-exit-no-update t]
2808 ["Exit and goto next group" gnus-summary-next-group t]
2809 ["Exit and goto prev group" gnus-summary-prev-group t]
2810 ["Reselect group" gnus-summary-reselect-current-group t]
2811 ["Rescan group" gnus-summary-rescan-group t]
2812 ["Update dribble" gnus-summary-save-newsrc t])))
2814 (gnus-run-hooks 'gnus-summary-menu-hook)))
2816 (defvar gnus-summary-tool-bar-map nil)
2818 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2819 ;; affect _new_ message buffers. We might add a function that walks thru all
2820 ;; summary-mode buffers and force the update.
2821 (defun gnus-summary-tool-bar-update (&optional symbol value)
2822 "Update summary mode toolbar.
2823 Setter function for custom variables."
2824 (setq-default gnus-summary-tool-bar-map nil)
2826 ;; When used as ":set" function:
2827 (set-default symbol value))
2828 (when (gnus-buffer-live-p gnus-summary-buffer)
2829 (with-current-buffer gnus-summary-buffer
2830 (gnus-summary-make-tool-bar))))
2832 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2833 'gnus-summary-tool-bar-gnome
2834 'gnus-summary-tool-bar-retro)
2835 "Specifies the Gnus summary tool bar.
2837 It can be either a list or a symbol referring to a list. See
2838 `gmm-tool-bar-from-list' for the format of the list. The
2839 default key map is `gnus-summary-mode-map'.
2841 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2842 `gnus-summary-tool-bar-retro'."
2843 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2844 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2845 (repeat :tag "User defined list" gmm-tool-bar-item)
2847 :version "23.1" ;; No Gnus
2848 :initialize 'custom-initialize-default
2849 :set 'gnus-summary-tool-bar-update
2850 :group 'gnus-summary)
2852 (defcustom gnus-summary-tool-bar-gnome
2853 '((gnus-summary-post-news "mail/compose" nil)
2854 (gnus-summary-insert-new-articles "mail/inbox" nil
2855 :visible (or (not gnus-agent)
2857 (gnus-summary-reply-with-original "mail/reply")
2858 (gnus-summary-reply "mail/reply" nil :visible nil)
2859 (gnus-summary-followup-with-original "mail/reply-all")
2860 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2861 (gnus-summary-mail-forward "mail/forward")
2862 (gnus-summary-save-article "mail/save")
2863 (gnus-summary-search-article-forward "search" nil :visible nil)
2864 (gnus-summary-print-article "print")
2865 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2866 ;; Some new commands that may need more suitable icons:
2867 (gnus-summary-save-newsrc "save" nil :visible nil)
2868 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2869 (gnus-summary-prev-article "left-arrow")
2870 (gnus-summary-next-article "right-arrow")
2871 (gnus-summary-next-page "next-page")
2872 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2874 ;; Maybe some sort-by-... could be added:
2875 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2876 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2877 (gnus-summary-mark-as-expirable
2879 :visible (gnus-check-backend-function 'request-expire-articles
2880 gnus-newsgroup-name))
2881 (gnus-summary-mark-as-spam
2883 :visible (and (fboundp 'spam-group-ham-contents-p)
2884 (spam-group-ham-contents-p gnus-newsgroup-name))
2885 :help "Mark as spam")
2886 (gnus-summary-mark-as-read-forward
2888 :visible (and (fboundp 'spam-group-spam-contents-p)
2889 (spam-group-spam-contents-p gnus-newsgroup-name)))
2891 (gnus-summary-exit "exit")
2892 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2893 (gnus-info-find-node "help"))
2894 "List of functions for the summary tool bar (GNOME style).
2896 See `gmm-tool-bar-from-list' for the format of the list."
2897 :type '(repeat gmm-tool-bar-item)
2898 :version "23.1" ;; No Gnus
2899 :initialize 'custom-initialize-default
2900 :set 'gnus-summary-tool-bar-update
2901 :group 'gnus-summary)
2903 (defcustom gnus-summary-tool-bar-retro
2904 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2905 (gnus-summary-next-unread-article "gnus/next-ur")
2906 (gnus-summary-post-news "gnus/post")
2907 (gnus-summary-followup-with-original "gnus/fuwo")
2908 (gnus-summary-followup "gnus/followup")
2909 (gnus-summary-reply-with-original "gnus/reply-wo")
2910 (gnus-summary-reply "gnus/reply")
2911 (gnus-summary-caesar-message "gnus/rot13")
2912 (gnus-uu-decode-uu "gnus/uu-decode")
2913 (gnus-summary-save-article-file "gnus/save-aif")
2914 (gnus-summary-save-article "gnus/save-art")
2915 (gnus-uu-post-news "gnus/uu-post")
2916 (gnus-summary-catchup "gnus/catchup")
2917 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2918 (gnus-summary-exit "gnus/exit-summ")
2919 ;; Some new command that may need more suitable icons:
2920 (gnus-summary-print-article "gnus/print" nil :visible nil)
2921 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2922 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2923 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2924 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2925 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2926 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2928 (gnus-info-find-node "gnus/help" nil :visible nil))
2929 "List of functions for the summary tool bar (retro look).
2931 See `gmm-tool-bar-from-list' for the format of the list."
2932 :type '(repeat gmm-tool-bar-item)
2933 :version "23.1" ;; No Gnus
2934 :initialize 'custom-initialize-default
2935 :set 'gnus-summary-tool-bar-update
2936 :group 'gnus-summary)
2938 (defcustom gnus-summary-tool-bar-zap-list t
2939 "List of icon items from the global tool bar.
2940 These items are not displayed in the Gnus summary mode tool bar.
2942 See `gmm-tool-bar-from-list' for the format of the list."
2943 :type 'gmm-tool-bar-zap-list
2944 :version "23.1" ;; No Gnus
2945 :initialize 'custom-initialize-default
2946 :set 'gnus-summary-tool-bar-update
2947 :group 'gnus-summary)
2949 (defvar image-load-path)
2950 (defvar tool-bar-map)
2952 (defun gnus-summary-make-tool-bar (&optional force)
2953 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2954 When FORCE, rebuild the tool bar."
2955 (when (and (not (featurep 'xemacs))
2956 (boundp 'tool-bar-mode)
2958 (or (not gnus-summary-tool-bar-map) force))
2960 (gmm-image-load-path-for-library "gnus"
2963 (image-load-path (cons (car load-path)
2964 (when (boundp 'image-load-path)
2966 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2967 gnus-summary-tool-bar-zap-list
2968 'gnus-summary-mode-map)))
2970 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2972 (setq gnus-summary-tool-bar-map map))))
2973 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2975 (defun gnus-score-set-default (var value)
2976 "A version of set that updates the GNU Emacs menu-bar."
2978 ;; It is the message that forces the active status to be updated.
2981 (defun gnus-make-score-map (type)
2982 "Make a summary score map of type TYPE."
2985 (let ((headers '(("author" "from" string)
2986 ("subject" "subject" string)
2987 ("article body" "body" string)
2988 ("article head" "head" string)
2989 ("xref" "xref" string)
2990 ("extra header" "extra" string)
2991 ("lines" "lines" number)
2992 ("followups to author" "followup" string)))
2993 (types '((number ("less than" <)
2996 (string ("substring" s)
3000 (perms '(("temporary" (current-time-string))
3008 (if (eq type 'lower)
3013 (setq header (car headers))
3019 (let ((ts (cdr (assoc (nth 2 header) types)))
3035 'gnus-summary-score-entry
3037 (if (or (string= (nth 1 header)
3039 (string= (nth 1 header)
3042 (list 'gnus-summary-header
3044 (list 'quote (nth 1 (car ts)))
3045 (list 'gnus-score-delta-default
3052 (list (nreverse outp))))
3055 (list (nreverse outt))))
3057 (setq headers (cdr headers)))
3058 (list (nreverse outh))))))))
3061 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3062 (defvar bookmark-make-record-function)
3064 (defvar bidi-paragraph-direction)
3066 (defun gnus-summary-mode (&optional group)
3067 "Major mode for reading articles.
3069 All normal editing commands are switched off.
3070 \\<gnus-summary-mode-map>
3071 Each line in this buffer represents one article. To read an
3072 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3073 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3076 You can also post articles and send mail from this buffer. To
3077 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3078 of an article, type `\\[gnus-summary-reply]'.
3080 There are approx. one gazillion commands you can execute in this
3081 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3083 The following commands are available:
3085 \\{gnus-summary-mode-map}"
3087 (kill-all-local-variables)
3088 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3089 (gnus-summary-make-local-variables))
3090 (gnus-summary-make-local-variables)
3091 (setq gnus-newsgroup-name group)
3092 (when (gnus-visual-p 'summary-menu 'menu)
3093 (gnus-summary-make-menu-bar)
3094 (gnus-summary-make-tool-bar))
3095 (gnus-make-thread-indent-array)
3096 (gnus-simplify-mode-line)
3097 (setq major-mode 'gnus-summary-mode)
3098 (setq mode-name "Summary")
3099 (use-local-map gnus-summary-mode-map)
3100 (buffer-disable-undo)
3101 (setq buffer-read-only t ;Disable modification
3102 show-trailing-whitespace nil)
3103 (setq truncate-lines t)
3104 ;; Force paragraph direction to be left-to-right. Don't make it
3105 ;; bound globally in old Emacsen and XEmacsen.
3106 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3107 (add-to-invisibility-spec '(gnus-sum . t))
3108 (gnus-summary-set-display-table)
3109 (gnus-set-default-directory)
3110 (make-local-variable 'gnus-summary-line-format)
3111 (make-local-variable 'gnus-summary-line-format-spec)
3112 (make-local-variable 'gnus-summary-dummy-line-format)
3113 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3114 (make-local-variable 'gnus-summary-mark-positions)
3115 (gnus-make-local-hook 'pre-command-hook)
3116 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3117 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3118 (turn-on-gnus-mailing-list-mode)
3119 (mm-enable-multibyte)
3120 (set (make-local-variable 'bookmark-make-record-function)
3121 'gnus-summary-bookmark-make-record)
3122 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3123 (gnus-update-summary-mark-positions))
3125 (defun gnus-summary-make-local-variables ()
3126 "Make all the local summary buffer variables."
3128 (dolist (local gnus-summary-local-variables)
3131 (if (eq (cdr local) 'global)
3132 ;; Copy the global value of the variable.
3133 (setq global (symbol-value (car local)))
3134 ;; Use the value from the list.
3135 (setq global (eval (cdr local))))
3136 (set (make-local-variable (car local)) global))
3137 ;; Simple nil-valued local variable.
3138 (set (make-local-variable local) nil)))))
3140 ;; Summary data functions.
3142 (defmacro gnus-data-number (data)
3145 (defmacro gnus-data-set-number (data number)
3146 `(setcar ,data ,number))
3148 (defmacro gnus-data-mark (data)
3151 (defmacro gnus-data-set-mark (data mark)
3152 `(setcar (nthcdr 1 ,data) ,mark))
3154 (defmacro gnus-data-pos (data)
3157 (defmacro gnus-data-set-pos (data pos)
3158 `(setcar (nthcdr 2 ,data) ,pos))
3160 (defmacro gnus-data-header (data)
3163 (defmacro gnus-data-set-header (data header)
3164 `(setf (nth 3 ,data) ,header))
3166 (defmacro gnus-data-level (data)
3169 (defmacro gnus-data-unread-p (data)
3170 `(= (nth 1 ,data) gnus-unread-mark))
3172 (defmacro gnus-data-read-p (data)
3173 `(/= (nth 1 ,data) gnus-unread-mark))
3175 (defmacro gnus-data-pseudo-p (data)
3176 `(consp (nth 3 ,data)))
3178 (defmacro gnus-data-find (number)
3179 `(assq ,number gnus-newsgroup-data))
3181 (defmacro gnus-data-find-list (number &optional data)
3182 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3183 (memq (assq ,number bdata)
3186 (defmacro gnus-data-make (number mark pos header level)
3187 `(list ,number ,mark ,pos ,header ,level))
3189 (defun gnus-data-enter (after-article number mark pos header level offset)
3190 (let ((data (gnus-data-find-list after-article)))
3192 (error "No such article: %d" after-article))
3193 (setcdr data (cons (gnus-data-make number mark pos header level)
3195 (setq gnus-newsgroup-data-reverse nil)
3196 (gnus-data-update-list (cddr data) offset)))
3198 (defun gnus-data-enter-list (after-article list &optional offset)
3200 (let ((data (and after-article (gnus-data-find-list after-article)))
3204 (let ((odata gnus-newsgroup-data))
3205 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3207 (gnus-data-update-list odata offset)))
3208 ;; Find the last element in the list to be spliced into the main
3210 (setq list (last list))
3213 (setcdr list gnus-newsgroup-data)
3214 (setq gnus-newsgroup-data ilist)
3216 (gnus-data-update-list (cdr list) offset)))
3217 (setcdr list (cdr data))
3220 (gnus-data-update-list (cdr list) offset))))
3221 (setq gnus-newsgroup-data-reverse nil))))
3223 (defun gnus-data-remove (article &optional offset)
3224 (let ((data gnus-newsgroup-data))
3225 (if (= (gnus-data-number (car data)) article)
3227 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3228 gnus-newsgroup-data-reverse nil)
3230 (gnus-data-update-list gnus-newsgroup-data offset)))
3232 (when (= (gnus-data-number (cadr data)) article)
3233 (setcdr data (cddr data))
3235 (gnus-data-update-list (cdr data) offset))
3237 gnus-newsgroup-data-reverse nil))
3238 (setq data (cdr data))))))
3240 (defmacro gnus-data-list (backward)
3242 (or gnus-newsgroup-data-reverse
3243 (setq gnus-newsgroup-data-reverse
3244 (reverse gnus-newsgroup-data)))
3245 gnus-newsgroup-data))
3247 (defun gnus-data-update-list (data offset)
3248 "Add OFFSET to the POS of all data entries in DATA."
3249 (setq gnus-newsgroup-data-reverse nil)
3251 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3252 (setq data (cdr data))))
3254 (defun gnus-summary-article-pseudo-p (article)
3255 "Say whether this article is a pseudo article or not."
3256 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3258 (defmacro gnus-summary-article-sparse-p (article)
3259 "Say whether this article is a sparse article or not."
3260 `(memq ,article gnus-newsgroup-sparse))
3262 (defmacro gnus-summary-article-ancient-p (article)
3263 "Say whether this article is a sparse article or not."
3264 `(memq ,article gnus-newsgroup-ancient))
3266 (defun gnus-article-parent-p (number)
3267 "Say whether this article is a parent or not."
3268 (let ((data (gnus-data-find-list number)))
3269 (and (cdr data) ; There has to be an article after...
3270 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3271 (gnus-data-level (nth 1 data))))))
3273 (defun gnus-article-children (number)
3274 "Return a list of all children to NUMBER."
3275 (let* ((data (gnus-data-find-list number))
3276 (level (gnus-data-level (car data)))
3278 (setq data (cdr data))
3280 (= (gnus-data-level (car data)) (1+ level)))
3281 (push (gnus-data-number (car data)) children)
3282 (setq data (cdr data)))
3285 (defmacro gnus-summary-skip-intangible ()
3286 "If the current article is intangible, then jump to a different article."
3287 '(let ((to (get-text-property (point) 'gnus-intangible)))
3288 (and to (gnus-summary-goto-subject to))))
3290 (defmacro gnus-summary-article-intangible-p ()
3291 "Say whether this article is intangible or not."
3292 '(get-text-property (point) 'gnus-intangible))
3294 (defun gnus-article-read-p (article)
3295 "Say whether ARTICLE is read or not."
3296 (not (or (memq article gnus-newsgroup-marked)
3297 (memq article gnus-newsgroup-spam-marked)
3298 (memq article gnus-newsgroup-unreads)
3299 (memq article gnus-newsgroup-unselected)
3300 (memq article gnus-newsgroup-dormant))))
3302 ;; Some summary mode macros.
3304 (defmacro gnus-summary-article-number ()
3305 "The article number of the article on the current line.
3306 If there isn't an article number here, then we return the current
3309 (gnus-summary-skip-intangible)
3310 (or (get-text-property (point) 'gnus-number)
3311 (gnus-summary-last-subject))))
3313 (defmacro gnus-summary-article-header (&optional number)
3314 "Return the header of article NUMBER."
3315 `(gnus-data-header (gnus-data-find
3316 ,(or number '(gnus-summary-article-number)))))
3318 (defmacro gnus-summary-thread-level (&optional number)
3319 "Return the level of thread that starts with article NUMBER."
3320 `(if (and (eq gnus-summary-make-false-root 'dummy)
3321 (get-text-property (point) 'gnus-intangible))
3323 (gnus-data-level (gnus-data-find
3324 ,(or number '(gnus-summary-article-number))))))
3326 (defmacro gnus-summary-article-mark (&optional number)
3327 "Return the mark of article NUMBER."
3328 `(gnus-data-mark (gnus-data-find
3329 ,(or number '(gnus-summary-article-number)))))
3331 (defmacro gnus-summary-article-pos (&optional number)
3332 "Return the position of the line of article NUMBER."
3333 `(gnus-data-pos (gnus-data-find
3334 ,(or number '(gnus-summary-article-number)))))
3336 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3337 (defmacro gnus-summary-article-subject (&optional number)
3338 "Return current subject string or nil if nothing."
3341 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3342 '(gnus-data-header (assq (gnus-summary-article-number)
3343 gnus-newsgroup-data)))))
3346 (mail-header-subject headers))))
3348 (defmacro gnus-summary-article-score (&optional number)
3349 "Return current article score."
3350 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3351 gnus-newsgroup-scored))
3352 gnus-summary-default-score 0))
3354 (defun gnus-summary-article-children (&optional number)
3355 "Return a list of article numbers that are children of article NUMBER."
3356 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3357 (level (gnus-data-level (car data)))
3359 (while (and (setq data (cdr data))
3360 (> (setq l (gnus-data-level (car data))) level))
3361 (and (= (1+ level) l)
3362 (push (gnus-data-number (car data))
3364 (nreverse children)))
3366 (defun gnus-summary-article-parent (&optional number)
3367 "Return the article number of the parent of article NUMBER."
3368 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3369 (gnus-data-list t)))
3370 (level (gnus-data-level (car data))))
3372 () ; This is a root.
3373 ;; We search until we find an article with a level less than
3374 ;; this one. That function has to be the parent.
3375 (while (and (setq data (cdr data))
3376 (not (< (gnus-data-level (car data)) level))))
3377 (and data (gnus-data-number (car data))))))
3379 (defun gnus-unread-mark-p (mark)
3380 "Say whether MARK is the unread mark."
3381 (= mark gnus-unread-mark))
3383 (defun gnus-read-mark-p (mark)
3384 "Say whether MARK is one of the marks that mark as read.
3385 This is all marks except unread, ticked, dormant, and expirable."
3386 (not (or (= mark gnus-unread-mark)
3387 (= mark gnus-ticked-mark)
3388 (= mark gnus-spam-mark)
3389 (= mark gnus-dormant-mark)
3390 (= mark gnus-expirable-mark))))
3392 (defmacro gnus-article-mark (number)
3393 "Return the MARK of article NUMBER.
3394 This macro should only be used when computing the mark the \"first\"
3395 time; i.e., when generating the summary lines. After that,
3396 `gnus-summary-article-mark' should be used to examine the
3399 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3400 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3401 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3402 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3403 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3404 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3405 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3406 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3407 gnus-ancient-mark))))
3409 ;; Saving hidden threads.
3411 (defmacro gnus-save-hidden-threads (&rest forms)
3412 "Save hidden threads, eval FORMS, and restore the hidden threads."
3413 (let ((config (make-symbol "config")))
3414 `(let ((,config (gnus-hidden-threads-configuration)))
3418 (gnus-restore-hidden-threads-configuration ,config)))))
3419 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3420 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3422 (defun gnus-data-compute-positions ()
3423 "Compute the positions of all articles."
3424 (setq gnus-newsgroup-data-reverse nil)
3425 (let ((data gnus-newsgroup-data))
3427 (gnus-save-hidden-threads
3428 (gnus-summary-show-all-threads)
3429 (goto-char (point-min))
3431 (while (get-text-property (point) 'gnus-intangible)
3433 (gnus-data-set-pos (car data) (+ (point) 3))
3434 (setq data (cdr data))
3435 (forward-line 1))))))
3437 (defun gnus-hidden-threads-configuration ()
3438 "Return the current hidden threads configuration."
3441 (goto-char (point-min))
3443 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3444 (push (save-excursion (forward-line 0) (point)) config))
3448 (defun gnus-restore-hidden-threads-configuration (config)
3449 "Restore hidden threads configuration from CONFIG."
3451 (let (point (inhibit-read-only t))
3452 (while (setq point (pop config))
3454 (gnus-summary-hide-thread)))))
3456 ;; Various summary mode internalish functions.
3458 (defun gnus-mouse-pick-article (e)
3461 (gnus-summary-next-page nil t))
3463 (defun gnus-summary-set-display-table ()
3464 "Change the display table.
3465 Odd characters have a tendency to mess
3466 up nicely formatted displays - we make all possible glyphs
3467 display only a single character."
3469 ;; We start from the standard display table, if any.
3470 (let ((table (or (copy-sequence standard-display-table)
3471 (make-display-table)))
3473 ;; Nix out all the control chars...
3474 (while (>= (setq i (1- i)) 0)
3475 (gnus-put-display-table i [??] table))
3476 ;; ... but not newline and cr, of course. (cr is necessary for the
3477 ;; selective display).
3478 (gnus-put-display-table ?\n nil table)
3479 (gnus-put-display-table ?\r nil table)
3480 ;; We keep TAB as well.
3481 (gnus-put-display-table ?\t nil table)
3482 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3483 ;; Emacs 23 (unicode), that are not set already.
3484 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3487 (while (>= (setq i (1- i)) 127)
3488 ;; Only modify if the entry is nil.
3489 (unless (gnus-get-display-table i table)
3490 (gnus-put-display-table i [??] table))))
3491 (setq buffer-display-table table)))
3493 (defun gnus-summary-set-article-display-arrow (pos)
3494 "Update the overlay arrow to point to line at position POS."
3495 (when gnus-summary-display-arrow
3496 (make-local-variable 'overlay-arrow-position)
3497 (make-local-variable 'overlay-arrow-string)
3501 (unless overlay-arrow-position
3502 (setq overlay-arrow-position (make-marker)))
3503 (setq overlay-arrow-string "=>"
3504 overlay-arrow-position (set-marker overlay-arrow-position
3506 (current-buffer))))))
3508 (defun gnus-summary-setup-buffer (group)
3509 "Initialize summary buffer.
3510 If the setup was successful, non-nil is returned."
3511 (let ((buffer (gnus-summary-buffer-name group))
3512 (dead-name (concat "*Dead Summary "
3513 (gnus-group-decoded-name group) "*")))
3514 ;; If a dead summary buffer exists, we kill it.
3515 (when (gnus-buffer-live-p dead-name)
3516 (gnus-kill-buffer dead-name))
3517 (if (get-buffer buffer)
3520 (setq gnus-summary-buffer (current-buffer))
3521 (not gnus-newsgroup-prepared))
3522 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3523 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3524 (gnus-summary-mode group)
3525 (when (gnus-group-quit-config group)
3526 (set (make-local-variable 'gnus-single-article-buffer) nil))
3527 (make-local-variable 'gnus-article-buffer)
3528 (make-local-variable 'gnus-article-current)
3529 (make-local-variable 'gnus-original-article-buffer)
3530 (setq gnus-newsgroup-name group)
3531 ;; Set any local variables in the group parameters.
3532 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3535 (defun gnus-set-global-variables ()
3536 "Set the global equivalents of the buffer-local variables.
3537 They are set to the latest values they had. These reflect the summary
3538 buffer that was in action when the last article was fetched."
3539 (when (eq major-mode 'gnus-summary-mode)
3540 (setq gnus-summary-buffer (current-buffer))
3541 (let ((name gnus-newsgroup-name)
3542 (marked gnus-newsgroup-marked)
3543 (spam gnus-newsgroup-spam-marked)
3544 (unread gnus-newsgroup-unreads)
3545 (headers gnus-current-headers)
3546 (data gnus-newsgroup-data)
3547 (summary gnus-summary-buffer)
3548 (article-buffer gnus-article-buffer)
3549 (original gnus-original-article-buffer)
3550 (gac gnus-article-current)
3551 (reffed gnus-reffed-article-number)
3552 (score-file gnus-current-score-file)
3553 (default-charset gnus-newsgroup-charset)
3555 (let ((locals gnus-newsgroup-variables))
3557 (if (consp (car locals))
3558 (push (eval (caar locals)) vlist)
3559 (push (eval (car locals)) vlist))
3560 (setq locals (cdr locals)))
3561 (setq vlist (nreverse vlist)))
3562 (with-current-buffer gnus-group-buffer
3563 (setq gnus-newsgroup-name name
3564 gnus-newsgroup-marked marked
3565 gnus-newsgroup-spam-marked spam
3566 gnus-newsgroup-unreads unread
3567 gnus-current-headers headers
3568 gnus-newsgroup-data data
3569 gnus-article-current gac
3570 gnus-summary-buffer summary
3571 gnus-article-buffer article-buffer
3572 gnus-original-article-buffer original
3573 gnus-reffed-article-number reffed
3574 gnus-current-score-file score-file
3575 gnus-newsgroup-charset default-charset)
3576 (let ((locals gnus-newsgroup-variables))
3578 (if (consp (car locals))
3579 (set (caar locals) (pop vlist))
3580 (set (car locals) (pop vlist)))
3581 (setq locals (cdr locals))))
3582 ;; The article buffer also has local variables.
3583 (when (gnus-buffer-live-p gnus-article-buffer)
3584 (set-buffer gnus-article-buffer)
3585 (setq gnus-summary-buffer summary))))))
3587 (defun gnus-summary-article-unread-p (article)
3588 "Say whether ARTICLE is unread or not."
3589 (memq article gnus-newsgroup-unreads))
3591 (defun gnus-summary-first-article-p (&optional article)
3592 "Return whether ARTICLE is the first article in the buffer."
3593 (if (not (setq article (or article (gnus-summary-article-number))))
3595 (eq article (caar gnus-newsgroup-data))))
3597 (defun gnus-summary-last-article-p (&optional article)
3598 "Return whether ARTICLE is the last article in the buffer."
3599 (if (not (setq article (or article (gnus-summary-article-number))))
3600 ;; All non-existent numbers are the last article. :-)
3602 (not (cdr (gnus-data-find-list article)))))
3604 (defun gnus-make-thread-indent-array (&optional n)
3606 (progn (setq n 200) nil)
3607 (null gnus-thread-indent-array)
3608 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3609 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3610 gnus-thread-indent-array-level gnus-thread-indent-level)
3612 (aset gnus-thread-indent-array n
3613 (make-string (* n gnus-thread-indent-level) ? ))
3616 (defun gnus-update-summary-mark-positions ()
3617 "Compute where the summary marks are to go."
3619 (when (gnus-buffer-exists-p gnus-summary-buffer)
3620 (set-buffer gnus-summary-buffer))
3621 (let ((spec gnus-summary-line-format-spec)
3624 (gnus-set-work-buffer)
3625 (let ((gnus-tmp-unread ?Z)
3626 (gnus-replied-mark ?Z)
3627 (gnus-score-below-mark ?Z)
3628 (gnus-score-over-mark ?Z)
3629 (gnus-undownloaded-mark ?Z)
3630 (gnus-summary-line-format-spec spec)
3631 (gnus-newsgroup-downloadable '(0))
3632 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3633 case-fold-search ignores)
3634 ;; Here, all marks are bound to Z.
3635 (gnus-summary-insert-line header
3636 0 nil t gnus-tmp-unread t nil "" nil 1)
3637 (goto-char (point-min))
3638 ;; Memorize the positions of the same characters as dummy marks.
3639 (while (re-search-forward "[A-D]" nil t)
3640 (push (point) ignores))
3642 ;; We use A-D as dummy marks in order to know column positions
3643 ;; where marks should be inserted.
3644 (setq gnus-tmp-unread ?A
3645 gnus-replied-mark ?B
3646 gnus-score-below-mark ?C
3647 gnus-score-over-mark ?C
3648 gnus-undownloaded-mark ?D)
3649 (gnus-summary-insert-line header
3650 0 nil t gnus-tmp-unread t nil "" nil 1)
3651 ;; Ignore characters which aren't dummy marks.
3653 (delete-region (goto-char (1- p)) p)
3655 (goto-char (point-min))
3656 (setq pos (list (cons 'unread
3657 (and (search-forward "A" nil t)
3658 (- (point) (point-min) 1)))))
3659 (goto-char (point-min))
3660 (push (cons 'replied (and (search-forward "B" nil t)
3661 (- (point) (point-min) 1)))
3663 (goto-char (point-min))
3664 (push (cons 'score (and (search-forward "C" nil t)
3665 (- (point) (point-min) 1)))
3667 (goto-char (point-min))
3668 (push (cons 'download (and (search-forward "D" nil t)
3669 (- (point) (point-min) 1)))
3671 (setq gnus-summary-mark-positions pos))))
3673 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3674 "Insert a dummy root in the summary buffer."
3676 (gnus-add-text-properties
3677 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3678 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3680 (defun gnus-summary-extract-address-component (from)
3681 (or (car (funcall gnus-extract-address-components from))
3684 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3685 (let ((mail-parse-charset gnus-newsgroup-charset)
3686 (ignored-from-addresses (gnus-ignored-from-addresses))
3687 ; Is it really necessary to do this next part for each summary line?
3688 ; Luckily, doesn't seem to slow things down much.
3689 (mail-parse-ignored-charsets
3690 (with-current-buffer gnus-summary-buffer
3691 gnus-newsgroup-ignored-charsets)))
3693 (and ignored-from-addresses
3694 (string-match ignored-from-addresses gnus-tmp-from)
3695 (let ((extra-headers (mail-header-extra header))
3699 ((setq to (cdr (assq 'To extra-headers)))
3700 (concat gnus-summary-to-prefix
3702 (gnus-summary-extract-address-component
3703 (funcall gnus-decode-encoded-address-function to)))))
3706 (cdr (assq 'Newsgroups extra-headers))
3708 (memq 'Newsgroups gnus-extra-headers)
3709 (eq (car (gnus-find-method-for-group
3710 gnus-newsgroup-name)) 'nntp)
3711 (gnus-group-real-name gnus-newsgroup-name))))
3712 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3713 (gnus-string-mark-left-to-right
3715 (gnus-summary-extract-address-component gnus-tmp-from))))))
3717 (defun gnus-summary-insert-line (gnus-tmp-header
3718 gnus-tmp-level gnus-tmp-current
3719 undownloaded gnus-tmp-unread gnus-tmp-replied
3720 gnus-tmp-expirable gnus-tmp-subject-or-nil
3721 &optional gnus-tmp-dummy gnus-tmp-score
3723 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3724 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3726 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3727 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3728 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3729 (gnus-tmp-score-char
3730 (if (or (null gnus-summary-default-score)
3731 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3732 gnus-summary-zcore-fuzz))
3734 (if (< gnus-tmp-score gnus-summary-default-score)
3735 gnus-score-below-mark gnus-score-over-mark)))
3736 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3738 (cond (gnus-tmp-process gnus-process-mark)
3739 ((memq gnus-tmp-current gnus-newsgroup-cached)
3741 (gnus-tmp-replied gnus-replied-mark)
3742 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3743 gnus-forwarded-mark)
3744 ((memq gnus-tmp-current gnus-newsgroup-saved)
3746 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3749 (gnus-tmp-downloaded
3751 gnus-undownloaded-mark)
3752 (gnus-newsgroup-agentized
3753 gnus-downloaded-mark)
3756 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3759 ((string-match "<[^>]+> *$" gnus-tmp-from)
3760 (let ((beg (match-beginning 0)))
3761 (or (and (string-match "^\".+\"" gnus-tmp-from)
3762 (substring gnus-tmp-from 1 (1- (match-end 0))))
3763 (substring gnus-tmp-from 0 beg))))
3764 ((string-match "(.+)" gnus-tmp-from)
3765 (substring gnus-tmp-from
3766 (1+ (match-beginning 0)) (1- (match-end 0))))
3768 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3769 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3770 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3771 (inhibit-read-only t))
3772 (when (string= gnus-tmp-name "")
3773 (setq gnus-tmp-name gnus-tmp-from))
3774 (unless (numberp gnus-tmp-lines)
3775 (setq gnus-tmp-lines -1))
3776 (if (= gnus-tmp-lines -1)
3777 (setq gnus-tmp-lines "?")
3778 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3780 (gnus-put-text-property
3782 (progn (eval gnus-summary-line-format-spec) (point))
3783 'gnus-number gnus-tmp-number)
3784 (error (gnus-message 5 "Error updating the summary line")))
3785 (when (gnus-visual-p 'summary-highlight 'highlight)
3787 (gnus-summary-highlight-line)
3788 (gnus-run-hooks 'gnus-summary-update-hook)
3791 (defun gnus-summary-update-line (&optional dont-update)
3792 "Update summary line after change."
3793 (when (and gnus-summary-default-score
3794 (not gnus-summary-inhibit-highlight))
3795 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3796 (article (gnus-summary-article-number))
3797 (score (gnus-summary-article-score article)))
3799 (if (and gnus-summary-mark-below
3800 (< (gnus-summary-article-score)
3801 gnus-summary-mark-below))
3802 ;; This article has a low score, so we mark it as read.
3803 (when (memq article gnus-newsgroup-unreads)
3804 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3805 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3806 ;; This article was previously marked as read on account
3807 ;; of a low score, but now it has risen, so we mark it as
3809 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3810 (gnus-summary-update-mark
3811 (if (or (null gnus-summary-default-score)
3812 (<= (abs (- score gnus-summary-default-score))
3813 gnus-summary-zcore-fuzz))
3815 (if (< score gnus-summary-default-score)
3816 gnus-score-below-mark gnus-score-over-mark))
3818 ;; Do visual highlighting.
3819 (when (gnus-visual-p 'summary-highlight 'highlight)
3820 (gnus-summary-highlight-line)
3821 (gnus-run-hooks 'gnus-summary-update-hook)))))
3823 (defvar gnus-tmp-new-adopts nil)
3825 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3826 "Return the number of articles in THREAD.
3827 This may be 0 in some cases -- if none of the articles in
3828 the thread are to be displayed."
3830 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3832 ((not (listp thread))
3834 ((and (consp thread) (cdr thread))
3837 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3840 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3843 (when (and level (zerop level) gnus-tmp-new-adopts)
3846 'gnus-summary-number-of-articles-in-thread
3847 gnus-tmp-new-adopts))))
3849 (if (> number 1) gnus-not-empty-thread-mark
3850 gnus-empty-thread-mark)
3853 (defsubst gnus-summary-line-message-size (head)
3854 "Return pretty-printed version of message size.
3855 This function is intended to be used in
3856 `gnus-summary-line-format-alist'."
3857 (let ((c (or (mail-header-chars head) -1)))
3858 (cond ((< c 0) "n/a") ; chars not available
3859 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3860 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3861 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3862 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3864 (defcustom gnus-user-date-format-alist
3865 '(((gnus-seconds-today) . "Today, %H:%M")
3866 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3867 (604800 . "%A %H:%M") ; That's one week
3868 ((gnus-seconds-month) . "%A %d")
3869 ((gnus-seconds-year) . "%B %d")
3870 (t . "%b %d %Y")) ; This one is used when no other
3872 "Specifies date format depending on age of article.
3873 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3874 seconds) or a Lisp expression evaluating to a number. When the age of
3875 the article is less than this number, then use `format-time-string'
3876 with the corresponding FORMAT for displaying the date of the article.
3877 If AGE is not a number or a Lisp expression evaluating to a
3878 non-number, then the corresponding FORMAT is used as a default value.
3880 Note that the list is processed from the beginning, so it should be
3881 sorted by ascending AGE. Also note that items following the first
3882 non-number AGE will be ignored.
3884 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3885 and `gnus-seconds-year' in the AGE spec. They return the number of
3886 seconds passed since the start of today, of this month, of this year,
3889 :group 'gnus-summary-format
3890 :type '(alist :key-type sexp :value-type string))
3892 (defun gnus-user-date (messy-date)
3893 "Format the messy-date according to `gnus-user-date-format-alist'.
3894 Returns \" ? \" if there's bad input or if another error occurs.
3895 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3897 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3898 (now (gnus-float-time))
3899 ;;If we don't find something suitable we'll use this one
3900 (my-format "%b %d '%y"))
3901 (let* ((difference (- now messy-date))
3902 (templist gnus-user-date-format-alist)
3903 (top (eval (caar templist))))
3904 (while (if (numberp top) (< top difference) (not top))
3906 (setq templist (cdr templist))
3907 (setq top (eval (caar templist)))))
3908 (if (stringp (cdr (car templist)))
3909 (setq my-format (cdr (car templist)))))
3910 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3913 (defun gnus-summary-set-local-parameters (group)
3914 "Go through the local params of GROUP and set all variable specs in that list."
3915 (let ((vars '(quit-config active))) ; Ignore things that aren't
3917 (dolist (elem (gnus-group-find-parameter group))
3918 (and (consp elem) ; Has to be a cons.
3919 (consp (cdr elem)) ; The cdr has to be a list.
3920 (symbolp (car elem)) ; Has to be a symbol in there.
3921 (not (memq (car elem) vars))
3923 (push (car elem) vars)
3924 ;; Variables like `gnus-show-threads' that are globally
3925 ;; bound, if used as group parameters, need to get to be
3926 ;; buffer-local, whereas just parameters like `gcc-self',
3927 ;; `timestamp', etc. should not be bound as variables.
3928 (if (boundp (car elem))
3929 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3930 (eval (nth 1 elem))))))))
3932 (defun gnus-summary-read-group (group &optional show-all no-article
3933 kill-buffer no-display backward
3935 "Start reading news in newsgroup GROUP.
3936 If SHOW-ALL is non-nil, already read articles are also listed.
3937 If NO-ARTICLE is non-nil, no article is selected initially.
3938 If NO-DISPLAY, don't generate the summary buffer contents.
3939 If KILL-BUFFER, it should be a buffer that's killed once the new
3940 summary buffer has been generated.
3941 If BACKWARD, move point to the previous group in the group buffer
3942 If SELECT-ARTICLES, only select those articles from GROUP."
3946 (let ((gnus-auto-select-next nil))
3947 (or (gnus-summary-read-group-1
3948 group show-all no-article
3949 kill-buffer no-display
3952 select-articles nil)))))
3953 (eq gnus-auto-select-next 'quietly))
3954 (set-buffer gnus-group-buffer)
3955 ;; The entry function called above goes to the next
3956 ;; group automatically, so we go two groups back
3957 ;; if we are searching for the previous group.
3959 (gnus-group-prev-unread-group 2))
3960 (if (not (equal group (gnus-group-group-name)))
3961 (setq group (gnus-group-group-name))
3965 (defun gnus-summary-read-group-1 (group show-all no-article
3966 kill-buffer no-display
3967 &optional select-articles)
3968 ;; Killed foreign groups can't be entered.
3969 ;; (when (and (not (gnus-group-native-p group))
3970 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3971 ;; (error "Dead non-native groups can't be entered"))
3972 (gnus-message 7 "Retrieving newsgroup: %s..."
3973 (gnus-group-decoded-name group))
3974 (let* ((new-group (gnus-summary-setup-buffer group))
3975 (quit-config (gnus-group-quit-config group))
3976 (did-select (and new-group (gnus-select-newsgroup
3977 group show-all select-articles))))
3979 ;; This summary buffer exists already, so we just select it.
3981 (gnus-set-global-variables)
3983 (gnus-kill-or-deaden-summary kill-buffer))
3984 (gnus-configure-windows 'summary 'force)
3985 (gnus-set-mode-line 'summary)
3986 (gnus-summary-position-point)
3989 ;; We couldn't select this group.
3991 (when (and (eq major-mode 'gnus-summary-mode)
3992 (not (equal (current-buffer) kill-buffer)))
3993 (kill-buffer (current-buffer))
3994 (if (not quit-config)
3996 ;; Update the info -- marks might need to be removed,
3998 (gnus-summary-update-info)
3999 (set-buffer gnus-group-buffer)
4000 (gnus-group-jump-to-group group)
4001 (gnus-group-next-unread-group 1))
4002 (gnus-handle-ephemeral-exit quit-config)))
4003 (if (null (gnus-list-of-unread-articles group))
4004 (gnus-message 3 "Group %s contains no messages" group)
4005 (gnus-message 3 "Can't select group"))
4007 ;; The user did a `C-g' while prompting for number of articles,
4008 ;; so we exit this group.
4009 ((eq did-select 'quit)
4010 (and (eq major-mode 'gnus-summary-mode)
4011 (not (equal (current-buffer) kill-buffer))
4012 (kill-buffer (current-buffer)))
4014 (gnus-kill-or-deaden-summary kill-buffer))
4015 (if (not quit-config)
4017 (set-buffer gnus-group-buffer)
4018 (gnus-group-jump-to-group group)
4019 (gnus-configure-windows 'group 'force))
4020 (gnus-handle-ephemeral-exit quit-config))
4021 ;; Finally signal the quit.
4023 ;; The group was successfully selected.
4025 (gnus-set-global-variables)
4026 ;; Save the active value in effect when the group was entered.
4027 (setq gnus-newsgroup-active
4029 (gnus-active gnus-newsgroup-name)))
4030 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4031 ;; You can change the summary buffer in some way with this hook.
4032 (gnus-run-hooks 'gnus-select-group-hook)
4033 (when (memq 'summary (gnus-update-format-specifications
4034 nil 'summary 'summary-mode 'summary-dummy))
4035 ;; The format specification for the summary line was updated,
4036 ;; so we need to update the mark positions as well.
4037 (gnus-update-summary-mark-positions))
4038 ;; Do score processing.
4039 (when gnus-use-scoring
4040 (gnus-possibly-score-headers))
4041 ;; Check whether to fill in the gaps in the threads.
4042 (when gnus-build-sparse-threads
4043 (gnus-build-sparse-threads))
4044 ;; Find the initial limit.
4046 (let ((gnus-newsgroup-dormant nil))
4047 (gnus-summary-initial-limit show-all))
4048 (gnus-summary-initial-limit show-all))
4049 ;; Generate the summary buffer.
4051 (gnus-summary-prepare))
4052 (when gnus-use-trees
4053 (gnus-tree-open group)
4054 (setq gnus-summary-highlight-line-function
4055 'gnus-tree-highlight-article))
4056 ;; If the summary buffer is empty, but there are some low-scored
4057 ;; articles or some excluded dormants, we include these in the
4059 (when (and (zerop (buffer-size))
4061 (cond (gnus-newsgroup-dormant
4062 (gnus-summary-limit-include-dormant))
4063 ((and gnus-newsgroup-scored show-all)
4064 (gnus-summary-limit-include-expunged t))))
4065 ;; Function `gnus-apply-kill-file' must be called in this hook.
4066 (gnus-run-hooks 'gnus-apply-kill-hook)
4067 (if (and (zerop (buffer-size))
4070 ;; This newsgroup is empty.
4071 (gnus-summary-catchup-and-exit nil t)
4072 (gnus-message 6 "No unread news")
4074 (gnus-kill-or-deaden-summary kill-buffer))
4075 ;; Return nil from this function.
4077 ;; Hide conversation thread subtrees. We cannot do this in
4078 ;; gnus-summary-prepare-hook since kill processing may not
4079 ;; work with hidden articles.
4080 (gnus-summary-maybe-hide-threads)
4081 (gnus-configure-windows 'summary)
4083 (gnus-kill-or-deaden-summary kill-buffer))
4084 (gnus-summary-auto-select-subject)
4085 ;; Show first unread article if requested.
4086 (if (and (not no-article)
4088 gnus-newsgroup-unreads
4089 gnus-auto-select-first)
4091 (let ((art (gnus-summary-article-number)))
4092 (unless (and (not gnus-plugged)
4093 (or (memq art gnus-newsgroup-undownloaded)
4094 (memq art gnus-newsgroup-downloadable)))
4095 (gnus-summary-goto-article art))))
4096 ;; Don't select any articles.
4097 (gnus-summary-position-point)
4098 (gnus-configure-windows 'summary 'force)
4099 (gnus-set-mode-line 'summary))
4100 (when (and gnus-auto-center-group
4101 (get-buffer-window gnus-group-buffer t))
4102 ;; Gotta use windows, because recenter does weird stuff if
4103 ;; the current buffer ain't the displayed window.
4104 (let ((owin (selected-window)))
4105 (select-window (get-buffer-window gnus-group-buffer t))
4106 (when (gnus-group-goto-group group)
4108 (select-window owin)))
4109 ;; Mark this buffer as "prepared".
4110 (setq gnus-newsgroup-prepared t)
4111 (gnus-run-hooks 'gnus-summary-prepared-hook)
4112 (unless (gnus-ephemeral-group-p group)
4113 (gnus-group-update-group group nil t))
4116 (defun gnus-summary-auto-select-subject ()
4117 "Select the subject line on initial group entry."
4118 (goto-char (point-min))
4120 ((eq gnus-auto-select-subject 'best)
4121 (gnus-summary-best-unread-subject))
4122 ((eq gnus-auto-select-subject 'unread)
4123 (gnus-summary-first-unread-subject))
4124 ((eq gnus-auto-select-subject 'unseen)
4125 (gnus-summary-first-unseen-subject))
4126 ((eq gnus-auto-select-subject 'unseen-or-unread)
4127 (gnus-summary-first-unseen-or-unread-subject))
4128 ((eq gnus-auto-select-subject 'first)
4131 ((functionp gnus-auto-select-subject)
4132 (funcall gnus-auto-select-subject))))
4134 (defun gnus-summary-prepare ()
4135 "Generate the summary buffer."
4137 (let ((inhibit-read-only t))
4139 (setq gnus-newsgroup-data nil
4140 gnus-newsgroup-data-reverse nil)
4141 (gnus-run-hooks 'gnus-summary-generate-hook)
4142 ;; Generate the buffer, either with threads or without.
4143 (when gnus-newsgroup-headers
4144 (gnus-summary-prepare-threads
4145 (if gnus-show-threads
4146 (gnus-sort-gathered-threads
4147 (funcall gnus-summary-thread-gathering-function
4149 (gnus-cut-threads (gnus-make-threads)))))
4150 ;; Unthreaded display.
4151 (gnus-sort-articles gnus-newsgroup-headers))))
4152 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4153 ;; Call hooks for modifying summary buffer.
4154 (goto-char (point-min))
4155 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4157 (defsubst gnus-general-simplify-subject (subject)
4158 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4161 ;; Truncate the subject.
4162 (gnus-simplify-subject-functions
4163 (gnus-map-function gnus-simplify-subject-functions subject))
4164 ((numberp gnus-summary-gather-subject-limit)
4165 (setq subject (gnus-simplify-subject-re subject))
4166 (if (> (length subject) gnus-summary-gather-subject-limit)
4167 (substring subject 0 gnus-summary-gather-subject-limit)
4169 ;; Fuzzily simplify it.
4170 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4171 (gnus-simplify-subject-fuzzy subject))
4172 ;; Just remove the leading "Re:".
4174 (gnus-simplify-subject-re subject))))
4176 (if (and gnus-summary-gather-exclude-subject
4177 (string-match gnus-summary-gather-exclude-subject subject))
4178 nil ; This article shouldn't be gathered
4181 (defun gnus-summary-simplify-subject-query ()
4182 "Query where the respool algorithm would put this article."
4184 (gnus-summary-select-article)
4185 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4187 (defun gnus-gather-threads-by-subject (threads)
4188 "Gather threads by looking at Subject headers."
4189 (if (not gnus-summary-make-false-root)
4191 (let ((hashtb (gnus-make-hashtable 1024))
4194 subject hthread whole-subject)
4196 (setq subject (gnus-general-simplify-subject
4197 (setq whole-subject (mail-header-subject
4200 (if (setq hthread (gnus-gethash subject hashtb))
4202 ;; We enter a dummy root into the thread, if we
4203 ;; haven't done that already.
4204 (unless (stringp (caar hthread))
4205 (setcar hthread (list whole-subject (car hthread))))
4206 ;; We add this new gathered thread to this gathered
4208 (setcdr (car hthread)
4209 (nconc (cdar hthread) (list (car threads))))
4210 ;; Remove it from the list of threads.
4211 (setcdr prev (cdr threads))
4212 (setq threads prev))
4213 ;; Enter this thread into the hash table.
4214 (gnus-sethash subject
4215 (if gnus-summary-make-false-root-always
4217 ;; If you want a dummy root above all
4219 (setcar threads (list whole-subject
4225 (setq threads (cdr threads)))
4228 (defun gnus-gather-threads-by-references (threads)
4229 "Gather threads by looking at References headers."
4230 (let ((idhashtb (gnus-make-hashtable 1024))
4231 (thhashtb (gnus-make-hashtable 1024))
4234 ids references id gthread gid entered ref)
4236 (when (setq references (mail-header-references (caar threads)))
4237 (setq id (mail-header-id (caar threads))
4238 ids (inline (gnus-split-references references))
4240 (while (setq ref (pop ids))
4241 (setq ids (delete ref ids))
4242 (if (not (setq gid (gnus-gethash ref idhashtb)))
4244 (gnus-sethash ref id idhashtb)
4245 (gnus-sethash id threads thhashtb))
4246 (setq gthread (gnus-gethash gid thhashtb))
4248 ;; We enter a dummy root into the thread, if we
4249 ;; haven't done that already.
4250 (unless (stringp (caar gthread))
4251 (setcar gthread (list (mail-header-subject (caar gthread))
4253 ;; We add this new gathered thread to this gathered
4255 (setcdr (car gthread)
4256 (nconc (cdar gthread) (list (car threads)))))
4257 ;; Add it into the thread hash table.
4258 (gnus-sethash id gthread thhashtb)
4260 ;; Remove it from the list of threads.
4261 (setcdr prev (cdr threads))
4262 (setq threads prev))))
4264 (setq threads (cdr threads)))
4267 (defun gnus-sort-gathered-threads (threads)
4268 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4269 (let ((result threads))
4271 (when (stringp (caar threads))
4272 (setcdr (car threads)
4273 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4274 (setq threads (cdr threads)))
4277 (defun gnus-thread-loop-p (root thread)
4278 "Say whether ROOT is in THREAD."
4279 (let ((stack (list thread))
4282 (while (setq thread (pop stack))
4283 (setq th (cdr thread))
4285 (not (eq (caar th) root)))
4288 ;; We have found a loop.
4290 (setcdr thread (delq (car th) (cdr thread)))
4291 (if (boundp (setq ref-dep (intern "none"
4292 gnus-newsgroup-dependencies)))
4293 (setcdr (symbol-value ref-dep)
4294 (nconc (cdr (symbol-value ref-dep))
4296 (set ref-dep (list nil (car th))))
4299 ;; Push all the subthreads onto the stack.
4300 (push (cdr thread) stack)))
4303 (defun gnus-make-threads ()
4304 "Go through the dependency hashtb and find the roots. Return all threads."
4306 (while (catch 'infloop
4309 ;; Deal with self-referencing References loops.
4310 (when (and (car (symbol-value refs))
4317 (car (symbol-value refs)) thread))
4318 (cdr (symbol-value refs)))))))
4321 (unless (car (symbol-value refs))
4322 ;; These threads do not refer back to any other
4323 ;; articles, so they're roots.
4324 (setq threads (append (cdr (symbol-value refs)) threads))))
4325 gnus-newsgroup-dependencies)))
4328 ;; Build the thread tree.
4329 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4330 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4332 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4333 if it was already present.
4335 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4336 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4337 Message-IDs will be renamed to a unique Message-ID before being
4340 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4341 (let* ((id (mail-header-id header))
4342 (id-dep (and id (intern id dependencies)))
4343 parent-id ref ref-dep ref-header replaced)
4344 ;; Enter this `header' in the `dependencies' table.
4348 ;; The first two cases do the normal part: enter a new `header'
4349 ;; in the `dependencies' table.
4350 ((not (boundp id-dep))
4351 (set id-dep (list header)))
4352 ((null (car (symbol-value id-dep)))
4353 (setcar (symbol-value id-dep) header))
4355 ;; From here the `header' was already present in the
4356 ;; `dependencies' table.
4358 ;; Overrides an existing entry;
4359 ;; just set the header part of the entry.
4360 (setcar (symbol-value id-dep) header)
4363 ;; Renames the existing `header' to a unique Message-ID.
4364 ((not gnus-summary-ignore-duplicates)
4365 ;; An article with this Message-ID has already been seen.
4366 ;; We rename the Message-ID.
4367 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4369 (mail-header-set-id header id))
4371 ;; The last case ignores an existing entry, except it adds any
4372 ;; additional Xrefs (in case the two articles came from different
4374 ;; Also sets `header' to `nil' meaning that the `dependencies'
4375 ;; table was *not* modified.
4377 (mail-header-set-xref
4378 (car (symbol-value id-dep))
4379 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4381 (or (mail-header-xref header) "")))
4384 (when (and header (not replaced))
4385 ;; First check that we are not creating a References loop.
4386 (setq parent-id (gnus-parent-id (mail-header-references header)))
4387 (setq ref parent-id)
4389 (setq ref-dep (intern-soft ref dependencies))
4391 (setq ref-header (car (symbol-value ref-dep))))
4392 (if (string= id ref)
4393 ;; Yuk! This is a reference loop. Make the article be a
4396 (mail-header-set-references (car (symbol-value id-dep)) "none")
4398 (setq parent-id nil))
4399 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4400 (setq ref-dep (intern (or parent-id "none") dependencies))
4401 (if (boundp ref-dep)
4402 (setcdr (symbol-value ref-dep)
4403 (nconc (cdr (symbol-value ref-dep))
4404 (list (symbol-value id-dep))))
4405 (set ref-dep (list nil (symbol-value id-dep)))))
4408 (defun gnus-extract-message-id-from-in-reply-to (string)
4409 (if (string-match "<[^>]+>" string)
4410 (substring string (match-beginning 0) (match-end 0))
4413 (defun gnus-build-sparse-threads ()
4414 (let ((headers gnus-newsgroup-headers)
4415 (mail-parse-charset gnus-newsgroup-charset)
4416 (gnus-summary-ignore-duplicates t)
4417 header references generation relations
4418 subject child end new-child date)
4419 ;; First we create an alist of generations/relations, where
4420 ;; generations is how much we trust the relation, and the relation
4422 (gnus-message 7 "Making sparse threads...")
4424 (nnheader-set-temp-buffer " *gnus sparse threads*")
4425 (while (setq header (pop headers))
4426 (when (and (setq references (mail-header-references header))
4427 (not (string= references "")))
4429 (setq child (mail-header-id header)
4430 subject (mail-header-subject header)
4431 date (mail-header-date header)
4433 (while (search-backward ">" nil t)
4434 (setq end (1+ (point)))
4435 (when (search-backward "<" nil t)
4436 (setq new-child (buffer-substring (point) end))
4437 (push (list (incf generation)
4438 child (setq child new-child)
4442 (push (list (1+ generation) child nil subject) relations))
4444 (kill-buffer (current-buffer)))
4445 ;; Sort over trustworthiness.
4446 (dolist (relation (sort relations 'car-less-than-car))
4447 (when (gnus-dependencies-add-header
4448 (make-full-mail-header
4449 gnus-reffed-article-number
4450 (nth 3 relation) "" (or (nth 4 relation) "")
4452 (or (nth 2 relation) "") 0 0 "")
4453 gnus-newsgroup-dependencies nil)
4454 (push gnus-reffed-article-number gnus-newsgroup-limit)
4455 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4456 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4457 gnus-newsgroup-reads)
4458 (decf gnus-reffed-article-number)))
4459 (gnus-message 7 "Making sparse threads...done")))
4461 (defun gnus-build-old-threads ()
4462 ;; Look at all the articles that refer back to old articles, and
4463 ;; fetch the headers for the articles that aren't there. This will
4464 ;; build complete threads - if the roots haven't been expired by the
4466 (let ((mail-parse-charset gnus-newsgroup-charset)
4470 (when (not (car (symbol-value refs)))
4471 (setq heads (cdr (symbol-value refs)))
4473 (if (memq (mail-header-number (caar heads))
4474 gnus-newsgroup-dormant)
4475 (setq heads (cdr heads))
4476 (setq id (symbol-name refs))
4477 (while (and (setq id (gnus-build-get-header id))
4478 (not (car (gnus-id-to-thread id)))))
4479 (setq heads nil)))))
4480 gnus-newsgroup-dependencies)))
4482 (defsubst gnus-remove-odd-characters (string)
4483 "Translate STRING into something that doesn't contain weird characters."
4484 (mm-subst-char-in-string
4486 (mm-subst-char-in-string ?\n ?\- string t) t))
4488 ;; This function has to be called with point after the article number
4489 ;; on the beginning of the line.
4490 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4491 (let ((eol (point-at-eol))
4492 (buffer (current-buffer))
4493 header references in-reply-to)
4495 ;; overview: [num subject from date id refs chars lines misc]
4498 (narrow-to-region (point) eol)
4503 (make-full-mail-header
4505 (condition-case () ; subject
4506 (gnus-remove-odd-characters
4507 (funcall gnus-decode-encoded-word-function
4508 (setq x (nnheader-nov-field))))
4510 (condition-case () ; from
4511 (gnus-remove-odd-characters
4512 (funcall gnus-decode-encoded-address-function
4513 (setq x (nnheader-nov-field))))
4515 (nnheader-nov-field) ; date
4516 (nnheader-nov-read-message-id number) ; id
4517 (setq references (nnheader-nov-field)) ; refs
4518 (nnheader-nov-read-integer) ; chars
4519 (nnheader-nov-read-integer) ; lines
4521 (if (looking-at "Xref: ")
4522 (goto-char (match-end 0)))
4523 (nnheader-nov-field)) ; Xref
4524 (nnheader-nov-parse-extra)))) ; extra
4528 (when (and (string= references "")
4529 (setq in-reply-to (mail-header-extra header))
4530 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4531 (mail-header-set-references
4532 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4534 (when gnus-alter-header-function
4535 (funcall gnus-alter-header-function header))
4536 (gnus-dependencies-add-header header dependencies force-new)))
4538 (defun gnus-build-get-header (id)
4539 "Look through the buffer of NOV lines and find the header to ID.
4540 Enter this line into the dependencies hash table, and return
4541 the id of the parent article (if any)."
4542 (let ((deps gnus-newsgroup-dependencies)
4545 (with-current-buffer nntp-server-buffer
4546 (let ((case-fold-search nil))
4547 (goto-char (point-min))
4548 (while (and (not found)
4549 (search-forward id nil t))
4551 (setq found (looking-at
4552 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4553 (regexp-quote id))))
4554 (or found (beginning-of-line 2)))
4558 (setq header (gnus-nov-parse-line
4559 (read (current-buffer)) deps))
4560 (gnus-parent-id (mail-header-references header))))))
4562 (let ((number (mail-header-number header)))
4563 (push number gnus-newsgroup-limit)
4564 (push header gnus-newsgroup-headers)
4565 (if (memq number gnus-newsgroup-unselected)
4567 (setq gnus-newsgroup-unreads
4568 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4570 (setq gnus-newsgroup-unselected
4571 (delq number gnus-newsgroup-unselected)))
4572 (push number gnus-newsgroup-ancient)))))))
4574 (defun gnus-build-all-threads ()
4575 "Read all the headers."
4576 (let ((gnus-summary-ignore-duplicates t)
4577 (mail-parse-charset gnus-newsgroup-charset)
4578 (dependencies gnus-newsgroup-dependencies)
4580 (with-current-buffer nntp-server-buffer
4581 (let ((case-fold-search nil))
4582 (goto-char (point-min))
4585 (setq article (read (current-buffer))
4586 header (gnus-nov-parse-line article dependencies t)))
4588 (with-current-buffer gnus-summary-buffer
4589 (push header gnus-newsgroup-headers)
4590 (if (memq (setq article (mail-header-number header))
4591 gnus-newsgroup-unselected)
4593 (setq gnus-newsgroup-unreads
4594 (gnus-add-to-sorted-list
4595 gnus-newsgroup-unreads article))
4596 (setq gnus-newsgroup-unselected
4597 (delq article gnus-newsgroup-unselected)))
4598 (push article gnus-newsgroup-ancient)))
4599 (forward-line 1)))))))
4601 (defun gnus-summary-update-article-line (article header)
4602 "Update the line for ARTICLE using HEADER."
4603 (let* ((id (mail-header-id header))
4604 (thread (gnus-id-to-thread id)))
4606 (error "Article in no thread"))
4607 ;; Update the thread.
4608 (setcar thread header)
4609 (gnus-summary-goto-subject article)
4610 (let* ((datal (gnus-data-find-list article))
4612 (inhibit-read-only t)
4613 (level (gnus-summary-thread-level)))
4615 (let ((inserted (- (point)
4617 (gnus-summary-insert-line
4619 (memq article gnus-newsgroup-undownloaded)
4620 (gnus-article-mark article)
4621 (memq article gnus-newsgroup-replied)
4622 (memq article gnus-newsgroup-expirable)
4623 ;; Only insert the Subject string when it's different
4624 ;; from the previous Subject string.
4629 (mail-header-subject
4632 (gnus-data-find-list
4634 (gnus-data-list t)))))
4635 ;; Error on the side of excessive subjects.
4637 (mail-header-subject header)))
4639 (mail-header-subject header))
4640 nil (cdr (assq article gnus-newsgroup-scored))
4641 (memq article gnus-newsgroup-processable))
4644 (gnus-data-update-list
4646 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4648 (defun gnus-summary-update-article (article &optional iheader)
4649 "Update ARTICLE in the summary buffer."
4650 (set-buffer gnus-summary-buffer)
4651 (let* ((header (gnus-summary-article-header article))
4652 (id (mail-header-id header))
4653 (data (gnus-data-find article))
4654 (thread (gnus-id-to-thread id))
4655 (references (mail-header-references header))
4659 (when (and references
4660 (not (equal "" references)))
4663 (inhibit-read-only t)
4669 (delq thread parent)))
4670 (if (gnus-summary-insert-subject id header)
4671 ;; Set the (possibly) new article number in the data structure.
4672 (gnus-data-set-number data (gnus-id-to-article id))
4676 (defun gnus-rebuild-thread (id &optional line)
4677 "Rebuild the thread containing ID.
4678 If LINE, insert the rebuilt thread starting on line LINE."
4679 (let ((inhibit-read-only t)
4680 old-pos current thread data)
4681 (if (not gnus-show-threads)
4682 (setq thread (list (car (gnus-id-to-thread id))))
4683 ;; Get the thread this article is part of.
4684 (setq thread (gnus-remove-thread id)))
4685 (setq old-pos (point-at-bol))
4686 (setq current (save-excursion
4687 (and (re-search-backward "[\r\n]" nil t)
4688 (gnus-summary-article-number))))
4689 ;; If this is a gathered thread, we have to go some re-gathering.
4690 (when (stringp (car thread))
4691 (let ((subject (car thread))
4693 (setq thread (cdr thread))
4695 (unless (memq (setq thr (gnus-id-to-thread
4697 (mail-header-id (caar thread)))))
4700 (setq thread (cdr thread)))
4701 ;; We now have all (unique) roots.
4702 (if (= (length roots) 1)
4703 ;; All the loose roots are now one solid root.
4704 (setq thread (car roots))
4705 (setq thread (cons subject (gnus-sort-threads roots))))))
4707 ;; We then insert this thread into the summary buffer.
4709 (goto-char (point-min))
4710 (forward-line (1- line)))
4711 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4712 (if gnus-show-threads
4713 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4714 (gnus-summary-prepare-unthreaded thread))
4715 (setq data (nreverse gnus-newsgroup-data))
4716 (setq threads gnus-newsgroup-threads))
4717 ;; We splice the new data into the data structure.
4718 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4719 ;;!!! then we want to insert at the beginning of the buffer.
4720 ;;!!! That happens to be true with Gnus now, but that may
4721 ;;!!! change in the future. Perhaps.
4722 (gnus-data-enter-list
4723 (if line nil current) data (- (point) old-pos))
4724 (setq gnus-newsgroup-threads
4725 (nconc threads gnus-newsgroup-threads))
4726 (gnus-data-compute-positions))))
4728 (defun gnus-number-to-header (number)
4729 "Return the header for article NUMBER."
4730 (let ((headers gnus-newsgroup-headers))
4732 (not (= number (mail-header-number (car headers)))))
4737 (defun gnus-parent-headers (in-headers &optional generation)
4738 "Return the headers of the GENERATIONth parent of HEADERS."
4740 (setq generation 1))
4742 (headers in-headers)
4745 (not (zerop generation))
4746 (setq references (mail-header-references headers)))
4747 (setq headers (if (and references
4748 (setq parent (gnus-parent-id references)))
4749 (car (gnus-id-to-thread parent))
4752 (and (not (eq headers in-headers))
4755 (defun gnus-id-to-thread (id)
4756 "Return the (sub-)thread where ID appears."
4757 (gnus-gethash id gnus-newsgroup-dependencies))
4759 (defun gnus-id-to-article (id)
4760 "Return the article number of ID."
4761 (let ((thread (gnus-id-to-thread id)))
4764 (mail-header-number (car thread)))))
4766 (defun gnus-id-to-header (id)
4767 "Return the article headers of ID."
4768 (car (gnus-id-to-thread id)))
4770 (defun gnus-article-displayed-root-p (article)
4771 "Say whether ARTICLE is a root(ish) article."
4772 (let ((level (gnus-summary-thread-level article))
4773 (refs (mail-header-references (gnus-summary-article-header article)))
4779 ((null (gnus-parent-id refs)) t)
4781 (null (setq particle (gnus-id-to-article
4782 (gnus-parent-id refs))))
4783 (null (gnus-summary-thread-level particle)))))))
4785 (defun gnus-root-id (id)
4786 "Return the id of the root of the thread where ID appears."
4788 (while (and id (setq prev (car (gnus-id-to-thread id))))
4790 id (gnus-parent-id (mail-header-references prev))))
4793 (defun gnus-articles-in-thread (thread)
4794 "Return the list of articles in THREAD."
4795 (cons (mail-header-number (car thread))
4796 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4798 (defun gnus-remove-thread (id &optional dont-remove)
4799 "Remove the thread that has ID in it."
4800 (let (headers thread last-id)
4801 ;; First go up in this thread until we find the root.
4802 (setq last-id (gnus-root-id id)
4803 headers (message-flatten-list (gnus-id-to-thread last-id)))
4804 ;; We have now found the real root of this thread. It might have
4805 ;; been gathered into some loose thread, so we have to search
4806 ;; through the threads to find the thread we wanted.
4807 (let ((threads gnus-newsgroup-threads)
4810 (setq sub (car threads))
4811 (if (stringp (car sub))
4812 ;; This is a gathered thread, so we look at the roots
4813 ;; below it to find whether this article is in this
4816 (setq sub (cdr sub))
4818 (when (member (caar sub) headers)
4819 (setq thread (car threads)
4822 (setq sub (cdr sub))))
4823 ;; It's an ordinary thread, so we check it.
4824 (when (eq (car sub) (car headers))
4827 (setq threads (cdr threads)))
4828 ;; If this article is in no thread, then it's a root.
4831 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4832 (setq thread (gnus-id-to-thread last-id)))
4835 thread ; We return this thread.
4837 (if (stringp (car thread))
4839 ;; If we use dummy roots, then we have to remove the
4840 ;; dummy root as well.
4841 (when (eq gnus-summary-make-false-root 'dummy)
4842 ;; We go to the dummy root by going to
4843 ;; the first sub-"thread", and then one line up.
4844 (gnus-summary-goto-article
4845 (mail-header-number (caadr thread)))
4848 (gnus-data-compute-positions))
4849 (setq thread (cdr thread))
4851 (gnus-remove-thread-1 (car thread))
4852 (setq thread (cdr thread))))
4853 (gnus-remove-thread-1 thread))))))))
4855 (defun gnus-remove-thread-1 (thread)
4856 "Remove the thread THREAD recursively."
4857 (let ((number (mail-header-number (pop thread)))
4859 (setq thread (reverse thread))
4861 (gnus-remove-thread-1 (pop thread)))
4862 (when (setq d (gnus-data-find number))
4863 (goto-char (gnus-data-pos d))
4864 (gnus-summary-show-thread)
4870 (gnus-delete-line)))))))
4872 (defun gnus-sort-threads-recursive (threads func)
4873 (sort (mapcar (lambda (thread)
4876 (gnus-sort-threads-recursive (cdr thread) func))))
4879 (defun gnus-sort-threads-loop (threads func)
4880 (let* ((superthread (cons nil threads))
4881 (stack (list (cons superthread threads)))
4882 remaining-threads thread)
4884 (setq remaining-threads (cdr (car stack)))
4885 (if remaining-threads
4886 (progn (setq thread (car remaining-threads))
4887 (setcdr (car stack) (cdr remaining-threads))
4889 (push (cons thread (cdr thread)) stack)))
4890 (setq thread (caar stack))
4891 (setcdr thread (sort (cdr thread) func))
4895 (defun gnus-sort-threads (threads)
4897 (if (not gnus-thread-sort-functions)
4899 (gnus-message 8 "Sorting threads...")
4902 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4903 (gnus-sort-threads-recursive
4904 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4905 ;; Even after binding max-lisp-eval-depth, the recursive
4906 ;; sorter might fail for very long threads. In that case,
4907 ;; try using a (less well-tested) non-recursive sorter.
4908 (error (gnus-message 9 "Sorting threads with loop...")
4909 (gnus-sort-threads-loop
4910 threads (gnus-make-sort-function
4911 gnus-thread-sort-functions))))
4912 (gnus-message 8 "Sorting threads...done"))))
4914 (defun gnus-sort-articles (articles)
4916 (when gnus-article-sort-functions
4917 (gnus-message 7 "Sorting articles...")
4919 (setq gnus-newsgroup-headers
4920 (sort articles (gnus-make-sort-function
4921 gnus-article-sort-functions)))
4922 (gnus-message 7 "Sorting articles...done"))))
4924 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4925 (defmacro gnus-thread-header (thread)
4926 "Return header of first article in THREAD.
4927 Note that THREAD must never, ever be anything else than a variable -
4928 using some other form will lead to serious barfage."
4929 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4930 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4931 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4934 (defsubst gnus-article-sort-by-number (h1 h2)
4935 "Sort articles by article number."
4936 (< (mail-header-number h1)
4937 (mail-header-number h2)))
4939 (defun gnus-thread-sort-by-number (h1 h2)
4940 "Sort threads by root article number."
4941 (gnus-article-sort-by-number
4942 (gnus-thread-header h1) (gnus-thread-header h2)))
4944 (defsubst gnus-article-sort-by-random (h1 h2)
4945 "Sort articles randomly."
4948 (defun gnus-thread-sort-by-random (h1 h2)
4949 "Sort threads randomly."
4950 (gnus-article-sort-by-random
4951 (gnus-thread-header h1) (gnus-thread-header h2)))
4953 (defsubst gnus-article-sort-by-lines (h1 h2)
4954 "Sort articles by article Lines header."
4955 (< (mail-header-lines h1)
4956 (mail-header-lines h2)))
4958 (defun gnus-thread-sort-by-lines (h1 h2)
4959 "Sort threads by root article Lines header."
4960 (gnus-article-sort-by-lines
4961 (gnus-thread-header h1) (gnus-thread-header h2)))
4963 (defsubst gnus-article-sort-by-chars (h1 h2)
4964 "Sort articles by octet length."
4965 (< (mail-header-chars h1)
4966 (mail-header-chars h2)))
4968 (defun gnus-thread-sort-by-chars (h1 h2)
4969 "Sort threads by root article octet length."
4970 (gnus-article-sort-by-chars
4971 (gnus-thread-header h1) (gnus-thread-header h2)))
4973 (defsubst gnus-article-sort-by-author (h1 h2)
4974 "Sort articles by root author."
4976 (let ((extract (funcall
4977 gnus-extract-address-components
4978 (mail-header-from h1))))
4979 (or (car extract) (cadr extract) ""))
4980 (let ((extract (funcall
4981 gnus-extract-address-components
4982 (mail-header-from h2))))
4983 (or (car extract) (cadr extract) ""))))
4985 (defun gnus-thread-sort-by-author (h1 h2)
4986 "Sort threads by root author."
4987 (gnus-article-sort-by-author
4988 (gnus-thread-header h1) (gnus-thread-header h2)))
4990 (defsubst gnus-article-sort-by-recipient (h1 h2)
4991 "Sort articles by recipient."
4993 (let ((extract (funcall
4994 gnus-extract-address-components
4995 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4996 (or (car extract) (cadr extract)))
4997 (let ((extract (funcall
4998 gnus-extract-address-components
4999 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5000 (or (car extract) (cadr extract)))))
5002 (defun gnus-thread-sort-by-recipient (h1 h2)
5003 "Sort threads by root recipient."
5004 (gnus-article-sort-by-recipient
5005 (gnus-thread-header h1) (gnus-thread-header h2)))
5007 (defsubst gnus-article-sort-by-subject (h1 h2)
5008 "Sort articles by root subject."
5010 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5011 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5013 (defun gnus-thread-sort-by-subject (h1 h2)
5014 "Sort threads by root subject."
5015 (gnus-article-sort-by-subject
5016 (gnus-thread-header h1) (gnus-thread-header h2)))
5018 (defsubst gnus-article-sort-by-date (h1 h2)
5019 "Sort articles by root article date."
5021 (gnus-date-get-time (mail-header-date h1))
5022 (gnus-date-get-time (mail-header-date h2))))
5024 (defun gnus-thread-sort-by-date (h1 h2)
5025 "Sort threads by root article date."
5026 (gnus-article-sort-by-date
5027 (gnus-thread-header h1) (gnus-thread-header h2)))
5029 (defsubst gnus-article-sort-by-score (h1 h2)
5030 "Sort articles by root article score.
5031 Unscored articles will be counted as having a score of zero."
5032 (> (or (cdr (assq (mail-header-number h1)
5033 gnus-newsgroup-scored))
5034 gnus-summary-default-score 0)
5035 (or (cdr (assq (mail-header-number h2)
5036 gnus-newsgroup-scored))
5037 gnus-summary-default-score 0)))
5039 (defun gnus-thread-sort-by-score (h1 h2)
5040 "Sort threads by root article score."
5041 (gnus-article-sort-by-score
5042 (gnus-thread-header h1) (gnus-thread-header h2)))
5044 (defun gnus-thread-sort-by-total-score (h1 h2)
5045 "Sort threads by the sum of all scores in the thread.
5046 Unscored articles will be counted as having a score of zero."
5047 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5049 (defun gnus-thread-total-score (thread)
5050 ;; This function find the total score of THREAD.
5055 (if (stringp (car thread))
5056 (apply gnus-thread-score-function 0
5057 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5058 (gnus-thread-total-score-1 thread)))
5060 (gnus-thread-total-score-1 (list thread)))))
5062 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5063 "Sort articles by number."
5064 (gnus-article-sort-by-number h1 h2))
5066 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5067 "Sort threads such that the thread with the most recently arrived article comes first."
5068 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5070 (defun gnus-thread-highest-number (thread)
5071 "Return the highest article number in THREAD."
5072 (apply 'max (mapcar (lambda (header)
5073 (mail-header-number header))
5074 (message-flatten-list thread))))
5076 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5077 "Sort articles by number."
5078 (gnus-article-sort-by-date h1 h2))
5080 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5081 "Sort threads such that the thread with the most recently dated article comes first."
5082 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5084 ; Since this is called not only to sort the top-level threads, but
5085 ; also in recursive sorts to order the articles within a thread, each
5086 ; article will be processed many times. Thus it speeds things up
5087 ; quite a bit to use gnus-date-get-time, which caches the time value.
5088 (defun gnus-thread-latest-date (thread)
5089 "Return the highest article date in THREAD."
5091 (mapcar (lambda (header) (gnus-float-time
5093 (mail-header-date header))))
5094 (message-flatten-list thread))))
5096 (defun gnus-thread-total-score-1 (root)
5097 ;; This function find the total score of the thread below ROOT.
5098 (setq root (car root))
5099 (apply gnus-thread-score-function
5101 (mapcar 'gnus-thread-total-score
5102 (cdr (gnus-id-to-thread (mail-header-id root))))
5103 (when (> (mail-header-number root) 0)
5104 (list (or (cdr (assq (mail-header-number root)
5105 gnus-newsgroup-scored))
5106 gnus-summary-default-score 0))))
5107 (list gnus-summary-default-score)
5110 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5111 (defvar gnus-tmp-prev-subject nil)
5112 (defvar gnus-tmp-false-parent nil)
5113 (defvar gnus-tmp-root-expunged nil)
5114 (defvar gnus-tmp-dummy-line nil)
5116 (defun gnus-extra-header (type &optional header)
5117 "Return the extra header of TYPE."
5118 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5121 (defvar gnus-tmp-thread-tree-header-string "")
5123 (defcustom gnus-sum-thread-tree-root "> "
5124 "With %B spec, used for the root of a thread.
5125 If nil, use subject instead."
5127 :type '(radio (const :format "%v " nil) string)
5128 :group 'gnus-thread)
5130 (defcustom gnus-sum-thread-tree-false-root "> "
5131 "With %B spec, used for a false root of a thread.
5132 If nil, use subject instead."
5134 :type '(radio (const :format "%v " nil) string)
5135 :group 'gnus-thread)
5137 (defcustom gnus-sum-thread-tree-single-indent ""
5138 "With %B spec, used for a thread with just one message.
5139 If nil, use subject instead."
5141 :type '(radio (const :format "%v " nil) string)
5142 :group 'gnus-thread)
5144 (defcustom gnus-sum-thread-tree-vertical "| "
5145 "With %B spec, used for drawing a vertical line."
5148 :group 'gnus-thread)
5150 (defcustom gnus-sum-thread-tree-indent " "
5151 "With %B spec, used for indenting."
5154 :group 'gnus-thread)
5156 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5157 "With %B spec, used for a leaf with brothers."
5160 :group 'gnus-thread)
5162 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5163 "With %B spec, used for a leaf without brothers."
5166 :group 'gnus-thread)
5168 (defcustom gnus-summary-display-while-building nil
5169 "If non-nil, show and update the summary buffer as it's being built.
5170 If the value is t, update the buffer after every line is inserted. If
5171 the value is an integer (N), update the display every N lines."
5174 :type '(choice (const :tag "off" nil)
5176 (const :tag "frequently" t)))
5178 (defun gnus-summary-prepare-threads (threads)
5179 "Prepare summary buffer from THREADS and indentation LEVEL.
5180 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5181 or a straight list of headers."
5182 (gnus-message 7 "Generating summary...")
5184 (setq gnus-newsgroup-threads threads)
5187 (let ((gnus-tmp-level 0)
5188 (default-score (or gnus-summary-default-score 0))
5189 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5190 (building-line-count gnus-summary-display-while-building)
5191 (building-count (integerp gnus-summary-display-while-building))
5192 thread number subject stack state gnus-tmp-gathered beg-match
5193 new-roots gnus-tmp-new-adopts thread-end simp-subject
5194 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5195 gnus-tmp-replied gnus-tmp-subject-or-nil
5196 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5197 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5198 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5201 (setq gnus-tmp-prev-subject nil
5202 gnus-tmp-thread-tree-header-string "")
5204 (if (vectorp (car threads))
5205 ;; If this is a straight (sic) list of headers, then a
5206 ;; threaded summary display isn't required, so we just create
5207 ;; an unthreaded one.
5208 (gnus-summary-prepare-unthreaded threads)
5210 ;; Do the threaded display.
5212 (if gnus-summary-display-while-building
5213 (switch-to-buffer (buffer-name)))
5214 (while (or threads stack gnus-tmp-new-adopts new-roots)
5216 (if (and (= gnus-tmp-level 0)
5219 (not gnus-tmp-false-parent)
5220 (or gnus-tmp-new-adopts new-roots))
5221 (if gnus-tmp-new-adopts
5222 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5223 thread (list (car gnus-tmp-new-adopts))
5224 gnus-tmp-header (caar thread)
5225 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5227 (setq thread (list (car new-roots))
5228 gnus-tmp-header (caar thread)
5229 new-roots (cdr new-roots))))
5232 ;; If there are some threads, we do them before the
5233 ;; threads on the stack.
5234 (setq thread threads
5235 gnus-tmp-header (caar thread))
5236 ;; There were no current threads, so we pop something off
5238 (setq state (car stack)
5239 gnus-tmp-level (car state)
5240 tree-stack (cadr state)
5241 thread (caddr state)
5243 gnus-tmp-header (caar thread))))
5245 (setq gnus-tmp-false-parent nil)
5246 (setq gnus-tmp-root-expunged nil)
5247 (setq thread-end nil)
5249 (if (stringp gnus-tmp-header)
5250 ;; The header is a dummy root.
5252 ((eq gnus-summary-make-false-root 'adopt)
5253 ;; We let the first article adopt the rest.
5254 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5256 (setq gnus-tmp-gathered
5258 (lambda (h) (mail-header-number (car h)))
5261 (setq thread (cons (list (caar thread)
5264 (setq gnus-tmp-level -1
5265 gnus-tmp-false-parent t))
5266 ((eq gnus-summary-make-false-root 'empty)
5267 ;; We print adopted articles with empty subject fields.
5268 (setq gnus-tmp-gathered
5270 (lambda (h) (mail-header-number (car h)))
5273 (setq gnus-tmp-level -1))
5274 ((eq gnus-summary-make-false-root 'dummy)
5275 ;; We remember that we probably want to output a dummy
5277 (setq gnus-tmp-dummy-line gnus-tmp-header)
5278 (setq gnus-tmp-prev-subject gnus-tmp-header))
5280 ;; We do not make a root for the gathered
5281 ;; sub-threads at all.
5282 (setq gnus-tmp-level -1)))
5284 (setq number (mail-header-number gnus-tmp-header)
5285 subject (mail-header-subject gnus-tmp-header)
5286 simp-subject (gnus-simplify-subject-fully subject))
5289 ;; If the thread has changed subject, we might want to make
5290 ;; this subthread into a root.
5291 ((and (null gnus-thread-ignore-subject)
5292 (not (zerop gnus-tmp-level))
5293 gnus-tmp-prev-subject
5294 (not (string= gnus-tmp-prev-subject simp-subject)))
5295 (setq new-roots (nconc new-roots (list (car thread)))
5297 gnus-tmp-header nil))
5298 ;; If the article lies outside the current limit,
5299 ;; then we do not display it.
5300 ((not (memq number gnus-newsgroup-limit))
5301 (setq gnus-tmp-gathered
5303 (lambda (h) (mail-header-number (car h)))
5306 (setq gnus-tmp-new-adopts (if (cdar thread)
5307 (append gnus-tmp-new-adopts
5309 gnus-tmp-new-adopts)
5311 gnus-tmp-header nil)
5312 (when (zerop gnus-tmp-level)
5313 (setq gnus-tmp-root-expunged t)))
5314 ;; Perhaps this article is to be marked as read?
5315 ((and gnus-summary-mark-below
5316 (< (or (cdr (assq number gnus-newsgroup-scored))
5318 gnus-summary-mark-below)
5319 ;; Don't touch sparse articles.
5320 (not (gnus-summary-article-sparse-p number))
5321 (not (gnus-summary-article-ancient-p number)))
5322 (setq gnus-newsgroup-unreads
5323 (delq number gnus-newsgroup-unreads))
5324 (if gnus-newsgroup-auto-expire
5325 (setq gnus-newsgroup-expirable
5326 (gnus-add-to-sorted-list
5327 gnus-newsgroup-expirable number))
5328 (push (cons number gnus-low-score-mark)
5329 gnus-newsgroup-reads))))
5331 (when gnus-tmp-header
5332 ;; We may have an old dummy line to output before this
5334 (when (and gnus-tmp-dummy-line
5337 (mail-header-subject gnus-tmp-header)))
5338 (gnus-summary-insert-dummy-line
5339 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5340 (setq gnus-tmp-dummy-line nil))
5342 ;; Compute the mark.
5343 (setq gnus-tmp-unread (gnus-article-mark number))
5345 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5346 gnus-tmp-header gnus-tmp-level)
5347 gnus-newsgroup-data)
5349 ;; Actually insert the line.
5351 gnus-tmp-subject-or-nil
5353 ((and gnus-thread-ignore-subject
5354 gnus-tmp-prev-subject
5355 (not (string= gnus-tmp-prev-subject simp-subject)))
5357 ((zerop gnus-tmp-level)
5358 (if (and (eq gnus-summary-make-false-root 'empty)
5359 (memq number gnus-tmp-gathered)
5360 gnus-tmp-prev-subject
5361 (string= gnus-tmp-prev-subject simp-subject))
5362 gnus-summary-same-subject
5364 (t gnus-summary-same-subject)))
5365 (if (and (eq gnus-summary-make-false-root 'adopt)
5366 (= gnus-tmp-level 1)
5367 (memq number gnus-tmp-gathered))
5368 (setq gnus-tmp-opening-bracket ?\<
5369 gnus-tmp-closing-bracket ?\>)
5370 (setq gnus-tmp-opening-bracket ?\[
5371 gnus-tmp-closing-bracket ?\]))
5372 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5373 (gnus-make-thread-indent-array
5374 (max (* 2 (length gnus-thread-indent-array))
5377 gnus-tmp-indentation
5378 (aref gnus-thread-indent-array gnus-tmp-level)
5379 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5380 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5381 gnus-summary-default-score 0)
5383 (if (or (null gnus-summary-default-score)
5384 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5385 gnus-summary-zcore-fuzz))
5387 (if (< gnus-tmp-score gnus-summary-default-score)
5388 gnus-score-below-mark gnus-score-over-mark))
5390 (cond ((memq number gnus-newsgroup-processable)
5392 ((memq number gnus-newsgroup-cached)
5394 ((memq number gnus-newsgroup-replied)
5396 ((memq number gnus-newsgroup-forwarded)
5397 gnus-forwarded-mark)
5398 ((memq number gnus-newsgroup-saved)
5400 ((memq number gnus-newsgroup-unseen)
5404 (cond ((memq number gnus-newsgroup-undownloaded)
5405 gnus-undownloaded-mark)
5406 (gnus-newsgroup-agentized
5407 gnus-downloaded-mark)
5410 gnus-tmp-from (mail-header-from gnus-tmp-header)
5413 ((string-match "<[^>]+> *$" gnus-tmp-from)
5414 (setq beg-match (match-beginning 0))
5415 (or (and (string-match "^\".+\"" gnus-tmp-from)
5416 (substring gnus-tmp-from 1 (1- (match-end 0))))
5417 (substring gnus-tmp-from 0 beg-match)))
5418 ((string-match "(.+)" gnus-tmp-from)
5419 (substring gnus-tmp-from
5420 (1+ (match-beginning 0)) (1- (match-end 0))))
5424 gnus-tmp-thread-tree-header-string
5426 ((not gnus-show-threads) "")
5427 ((zerop gnus-tmp-level)
5428 (cond ((cdar thread)
5429 (or gnus-sum-thread-tree-root subject))
5430 (gnus-tmp-new-adopts
5431 (or gnus-sum-thread-tree-false-root subject))
5433 (or gnus-sum-thread-tree-single-indent subject))))
5435 (concat (apply 'concat
5436 (mapcar (lambda (item)
5438 gnus-sum-thread-tree-vertical
5439 gnus-sum-thread-tree-indent))
5440 (cdr (reverse tree-stack))))
5442 gnus-sum-thread-tree-leaf-with-other
5443 gnus-sum-thread-tree-single-leaf)))))
5444 (when (string= gnus-tmp-name "")
5445 (setq gnus-tmp-name gnus-tmp-from))
5446 (unless (numberp gnus-tmp-lines)
5447 (setq gnus-tmp-lines -1))
5448 (if (= gnus-tmp-lines -1)
5449 (setq gnus-tmp-lines "?")
5450 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5451 (gnus-put-text-property
5453 (progn (eval gnus-summary-line-format-spec) (point))
5454 'gnus-number number)
5457 (gnus-summary-highlight-line)
5458 (when gnus-summary-update-hook
5459 (gnus-run-hooks 'gnus-summary-update-hook))
5462 (setq gnus-tmp-prev-subject simp-subject)))
5464 (when (nth 1 thread)
5465 (push (list (max 0 gnus-tmp-level)
5466 (copy-sequence tree-stack)
5469 (push (if (nth 1 thread) 1 0) tree-stack)
5470 (incf gnus-tmp-level)
5471 (setq threads (if thread-end nil (cdar thread)))
5472 (if gnus-summary-display-while-building
5475 ;; use a set frequency
5476 (setq building-line-count (1- building-line-count))
5477 (when (= building-line-count 0)
5479 (setq building-line-count
5480 gnus-summary-display-while-building)))
5484 (setq gnus-tmp-level 0)))))
5485 (gnus-message 7 "Generating summary...done"))
5487 (defun gnus-summary-prepare-unthreaded (headers)
5488 "Generate an unthreaded summary buffer based on HEADERS."
5489 (let (header number mark)
5494 ;; We may have to root out some bad articles...
5495 (when (memq (setq number (mail-header-number
5496 (setq header (pop headers))))
5497 gnus-newsgroup-limit)
5498 ;; Mark article as read when it has a low score.
5499 (when (and gnus-summary-mark-below
5500 (< (or (cdr (assq number gnus-newsgroup-scored))
5501 gnus-summary-default-score 0)
5502 gnus-summary-mark-below)
5503 (not (gnus-summary-article-ancient-p number)))
5504 (setq gnus-newsgroup-unreads
5505 (delq number gnus-newsgroup-unreads))
5506 (if gnus-newsgroup-auto-expire
5507 (push number gnus-newsgroup-expirable)
5508 (push (cons number gnus-low-score-mark)
5509 gnus-newsgroup-reads)))
5511 (setq mark (gnus-article-mark number))
5512 (push (gnus-data-make number mark (1+ (point)) header 0)
5513 gnus-newsgroup-data)
5514 (gnus-summary-insert-line
5516 (memq number gnus-newsgroup-undownloaded)
5517 mark (memq number gnus-newsgroup-replied)
5518 (memq number gnus-newsgroup-expirable)
5519 (mail-header-subject header) nil
5520 (cdr (assq number gnus-newsgroup-scored))
5521 (memq number gnus-newsgroup-processable))))))
5523 (defun gnus-group-get-list-identifiers (group)
5524 "Get list identifier regexp for GROUP."
5525 (or (gnus-parameter-list-identifier group)
5526 (if (consp gnus-list-identifiers)
5527 (mapconcat 'identity gnus-list-identifiers " *\\|")
5528 gnus-list-identifiers)))
5530 (defun gnus-summary-remove-list-identifiers ()
5531 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5532 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5535 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5536 (dolist (header gnus-newsgroup-headers)
5537 (setq subject (mail-header-subject header)
5539 (while (string-match regexp subject)
5541 (concat (substring subject 0 (match-beginning 1))
5542 (substring subject (match-end 0)))
5545 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5547 (concat (substring subject 0 (match-beginning 1))
5548 (substring subject (match-end 1)))))
5549 (mail-header-set-subject header subject))))))
5551 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5552 "Fetch headers of ARTICLES."
5553 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5554 (gnus-message 7 "Fetching headers for %s..." name)
5557 (setq gnus-headers-retrieved-by
5558 (gnus-retrieve-headers
5559 articles gnus-newsgroup-name
5561 ;; We might want to fetch old headers, but
5562 ;; not if there is only 1 article.
5564 (not (eq gnus-fetch-old-headers 'some))
5565 (not (numberp gnus-fetch-old-headers)))
5566 (> (length articles) 1))
5567 gnus-fetch-old-headers)))))
5568 (gnus-get-newsgroup-headers-xover
5569 articles force-new dependencies gnus-newsgroup-name t)
5570 (gnus-get-newsgroup-headers dependencies force-new))
5571 (gnus-message 7 "Fetching headers for %s...done" name))))
5573 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5574 "Select newsgroup GROUP.
5575 If READ-ALL is non-nil, all articles in the group are selected.
5576 If SELECT-ARTICLES, only select those articles from GROUP."
5577 (let* ((entry (gnus-group-entry group))
5578 ;;!!! Dirty hack; should be removed.
5579 (gnus-summary-ignore-duplicates
5580 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5582 gnus-summary-ignore-duplicates))
5583 (info (nth 2 entry))
5584 charset articles fetched-articles cached)
5586 (unless (gnus-check-server
5587 (set (make-local-variable 'gnus-current-select-method)
5588 (gnus-find-method-for-group group)))
5589 (error "Couldn't open server"))
5590 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5592 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5593 (gnus-activate-group group) ; Or we can activate it...
5594 (progn ; Or we bug out.
5595 (when (equal major-mode 'gnus-summary-mode)
5596 (gnus-kill-buffer (current-buffer)))
5598 "Couldn't activate group %s: %s"
5599 (mm-decode-coding-string group charset)
5600 (mm-decode-coding-string (gnus-status-message group) charset))))
5602 (unless (gnus-request-group group t)
5603 (when (equal major-mode 'gnus-summary-mode)
5604 (gnus-kill-buffer (current-buffer)))
5605 (error "Couldn't request group %s: %s"
5606 (mm-decode-coding-string group charset)
5607 (mm-decode-coding-string (gnus-status-message group) charset)))
5609 (when (and gnus-agent
5610 (gnus-active group))
5611 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5613 (setq gnus-summary-use-undownloaded-faces
5614 (gnus-agent-find-parameter
5616 'agent-enable-undownloaded-faces)))
5618 (setq gnus-newsgroup-name group
5619 gnus-newsgroup-unselected nil
5620 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5622 (let ((display (gnus-group-find-parameter group 'display)))
5623 (setq gnus-newsgroup-display
5625 ((not (zerop (or (car-safe read-all) 0)))
5626 ;; The user entered the group with C-u SPC/RET, let's show
5632 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5634 ;; The following is probably the "correct" solution, but
5635 ;; it makes Gnus fetch all headers and then limit the
5636 ;; articles (which is slow), so instead we hack the
5637 ;; select-articles parameter instead. -- Simon Josefsson
5640 ;; (gnus-byte-compile
5641 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5643 (setq select-articles
5644 (gnus-uncompress-range
5645 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5649 (cdr (gnus-active group)))))
5654 (gnus-summary-setup-default-charset)
5656 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5657 (when (gnus-virtual-group-p group)
5658 (setq cached gnus-newsgroup-cached))
5660 (setq gnus-newsgroup-unreads
5661 (gnus-sorted-ndifference
5662 (gnus-sorted-ndifference gnus-newsgroup-unreads
5663 gnus-newsgroup-marked)
5664 gnus-newsgroup-dormant))
5666 (setq gnus-newsgroup-processable nil)
5668 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5670 ;; Adjust and set lists of article marks.
5672 (gnus-adjust-marked-articles info))
5673 (if (setq articles select-articles)
5674 (setq gnus-newsgroup-unselected
5675 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5676 (setq articles (gnus-articles-to-read group read-all)))
5680 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5682 ((eq articles 0) nil)
5684 ;; Init the dependencies hash table.
5685 (setq gnus-newsgroup-dependencies
5686 (gnus-make-hashtable (length articles)))
5687 (gnus-set-global-variables)
5688 ;; Retrieve the headers and read them in.
5690 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5692 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5694 (setq gnus-newsgroup-cached cached))
5696 ;; Suppress duplicates?
5697 (when gnus-suppress-duplicates
5698 (gnus-dup-suppress-articles))
5700 ;; Set the initial limit.
5701 (setq gnus-newsgroup-limit (copy-sequence articles))
5702 ;; Remove canceled articles from the list of unread articles.
5703 (setq fetched-articles
5704 (mapcar (lambda (headers) (mail-header-number headers))
5705 gnus-newsgroup-headers))
5706 (setq gnus-newsgroup-articles fetched-articles)
5707 (setq gnus-newsgroup-unreads
5708 (gnus-sorted-nintersection
5709 gnus-newsgroup-unreads fetched-articles))
5710 (gnus-compute-unseen-list)
5712 ;; Removed marked articles that do not exist.
5713 (gnus-update-missing-marks
5714 (gnus-sorted-difference articles fetched-articles))
5715 ;; We might want to build some more threads first.
5716 (when (and gnus-fetch-old-headers
5717 (eq gnus-headers-retrieved-by 'nov))
5718 (if (eq gnus-fetch-old-headers 'invisible)
5719 (gnus-build-all-threads)
5720 (gnus-build-old-threads)))
5721 ;; Let the Gnus agent mark articles as read.
5723 (gnus-agent-get-undownloaded-list))
5724 ;; Remove list identifiers from subject
5725 (gnus-summary-remove-list-identifiers)
5726 ;; Check whether auto-expire is to be done in this group.
5727 (setq gnus-newsgroup-auto-expire
5728 (and (gnus-group-auto-expirable-p group)
5729 (not (gnus-group-read-only-p group))))
5730 ;; Set up the article buffer now, if necessary.
5731 (unless (and gnus-single-article-buffer
5732 (equal gnus-article-buffer "*Article*"))
5733 (gnus-article-setup-buffer))
5734 ;; First and last article in this newsgroup.
5735 (when gnus-newsgroup-headers
5736 (setq gnus-newsgroup-begin
5737 (mail-header-number (car gnus-newsgroup-headers))
5740 (gnus-last-element gnus-newsgroup-headers))))
5741 ;; GROUP is successfully selected.
5742 (or gnus-newsgroup-headers t)))))
5744 (defun gnus-compute-unseen-list ()
5745 ;; The `seen' marks are treated specially.
5746 (if (not gnus-newsgroup-seen)
5747 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5748 (setq gnus-newsgroup-unseen
5749 (gnus-inverse-list-range-intersection
5750 gnus-newsgroup-articles gnus-newsgroup-seen))))
5752 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5754 (defun gnus-summary-display-make-predicate (display)
5755 (require 'gnus-agent)
5756 (when (= (length display) 1)
5757 (setq display (car display)))
5758 (unless gnus-summary-display-cache
5759 (dolist (elem (append '((unread . unread)
5762 gnus-article-mark-lists))
5763 (push (cons (cdr elem)
5764 (gnus-byte-compile ;Why bother?
5765 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5766 gnus-summary-display-cache)))
5767 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5768 (gnus-category-predicate-cache gnus-summary-display-cache))
5769 (gnus-get-predicate display)))
5771 ;; Uses the dynamically bound `gnus-number' variable.
5772 (defvar gnus-number)
5773 (defun gnus-article-marked-p (type &optional article)
5774 (let ((article (or article gnus-number)))
5777 (memq article gnus-newsgroup-marked))
5779 (memq article gnus-newsgroup-spam-marked))
5781 (memq article gnus-newsgroup-unsendable))
5782 ((eq type 'undownload)
5783 (memq article gnus-newsgroup-undownloaded))
5784 ((eq type 'download)
5785 (memq article gnus-newsgroup-downloadable))
5787 (memq article gnus-newsgroup-unreads))
5789 (memq article gnus-newsgroup-reads))
5791 (memq article gnus-newsgroup-dormant) )
5793 (memq article gnus-newsgroup-expirable))
5795 (memq article gnus-newsgroup-replied))
5797 (memq article gnus-newsgroup-killed))
5798 ((eq type 'bookmark)
5799 (assq article gnus-newsgroup-bookmarks))
5801 (assq article gnus-newsgroup-scored))
5803 (memq article gnus-newsgroup-saved))
5805 (memq article gnus-newsgroup-cached))
5807 (memq article gnus-newsgroup-forwarded))
5809 (not (memq article gnus-newsgroup-unseen)))
5812 (defun gnus-articles-to-read (group &optional read-all)
5813 "Find out what articles the user wants to read."
5814 (let* ((only-read-p t)
5816 ;; Select all articles if `read-all' is non-nil, or if there
5817 ;; are no unread articles.
5819 (and (zerop (length gnus-newsgroup-marked))
5820 (zerop (length gnus-newsgroup-unreads)))
5821 ;; Fetch all if the predicate is non-nil.
5822 gnus-newsgroup-display)
5823 ;; We want to select the headers for all the articles in
5824 ;; the group, so we select either all the active
5825 ;; articles in the group, or (if that's nil), the
5826 ;; articles in the cache.
5828 (if gnus-newsgroup-maximum-articles
5829 (let ((active (gnus-active group)))
5830 (gnus-uncompress-range
5831 (cons (max (car active)
5833 gnus-newsgroup-maximum-articles
5836 (gnus-uncompress-range (gnus-active group)))
5837 (gnus-cache-articles-in-group group))
5838 ;; Select only the "normal" subset of articles.
5839 (setq only-read-p nil)
5841 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5842 gnus-newsgroup-unreads)))
5843 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5844 (scored (length scored-list))
5845 (number (length articles))
5846 (marked (+ (length gnus-newsgroup-marked)
5847 (length gnus-newsgroup-dormant)))
5852 ((numberp gnus-newsgroup-display)
5853 gnus-newsgroup-display)
5857 ((and (or (<= scored marked) (= scored number))
5858 (numberp gnus-large-newsgroup)
5859 (> number gnus-large-newsgroup))
5860 (let* ((cursor-in-echo-area nil)
5861 (initial (gnus-parameter-large-newsgroup-initial
5862 gnus-newsgroup-name))
5863 (default (if only-read-p
5864 (or initial gnus-large-newsgroup)
5870 "How many articles from %s (available %d, default %d): "
5871 (gnus-group-decoded-name
5872 (gnus-group-real-name gnus-newsgroup-name))
5875 "How many articles from %s (%d default): "
5876 (gnus-group-decoded-name
5877 (gnus-group-real-name gnus-newsgroup-name))
5881 (number-to-string default))))
5882 (if (string-match "^[ \t]*$" input) number input)))
5883 ((and (> scored marked) (< scored number)
5884 (> (- scored number) 20))
5887 (format "%s %s (%d scored, %d total): "
5888 "How many articles from"
5889 (gnus-group-decoded-name
5890 (gnus-group-real-name gnus-newsgroup-name))
5892 (if (string-match "^[ \t]*$" input)
5896 (message "Quit getting the articles to read")
5898 (setq select (if (stringp select) (string-to-number select) select))
5899 (if (or (null select) (zerop select))
5901 (if (and (not (zerop scored)) (<= (abs select) scored))
5903 (setq articles (sort scored-list '<))
5904 (setq number (length articles)))
5905 (setq articles (copy-sequence articles)))
5907 (when (< (abs select) number)
5909 ;; Select the N oldest articles.
5910 (setcdr (nthcdr (1- (abs select)) articles) nil)
5911 ;; Select the N most recent articles.
5912 (setq articles (nthcdr (- number select) articles))))
5913 (setq gnus-newsgroup-unselected
5914 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5915 (when gnus-alter-articles-to-read-function
5918 (funcall gnus-alter-articles-to-read-function
5919 gnus-newsgroup-name articles)
5923 (defun gnus-killed-articles (killed articles)
5926 (when (inline (gnus-member-of-range (car articles) killed))
5927 (push (car articles) out))
5928 (setq articles (cdr articles)))
5931 (defun gnus-uncompress-marks (marks)
5932 "Uncompress the mark ranges in MARKS."
5933 (let ((uncompressed '(score bookmark))
5936 (if (memq (caar marks) uncompressed)
5937 (push (car marks) out)
5938 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5939 (setq marks (cdr marks)))
5942 (defun gnus-article-mark-to-type (mark)
5943 "Return the type of MARK."
5944 (or (cadr (assq mark gnus-article-special-mark-lists))
5947 (defun gnus-article-unpropagatable-p (mark)
5948 "Return whether MARK should be propagated to back end."
5949 (memq mark gnus-article-unpropagated-mark-lists))
5951 (defun gnus-adjust-marked-articles (info)
5952 "Set all article lists and remove all marks that are no longer valid."
5953 (let* ((marked-lists (gnus-info-marks info))
5954 (active (gnus-active (gnus-info-group info)))
5957 (types gnus-article-mark-lists)
5958 marks var articles article mark mark-type
5960 ;; Hack to avoid adjusting marks for imap.
5961 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5965 (dolist (marks marked-lists)
5966 (setq mark (car marks)
5967 mark-type (gnus-article-mark-to-type mark)
5968 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5970 ;; We set the variable according to the type of the marks list,
5971 ;; and then adjust the marks to a subset of the active articles.
5973 ;; Adjust "simple" lists - compressed yet unsorted
5974 ((eq mark-type 'list)
5975 ;; Simultaneously uncompress and clip to active range
5976 ;; See gnus-uncompress-range for a description of possible marks
5978 (if (not (cadr marks))
5980 (setq articles (if (numberp (cddr marks))
5986 (while (setq article (pop articles))
5987 (cond ((consp article)
5988 (setq bgn (max (car article) min)
5989 end (min (cdr article) max))
5991 (setq l (setcdr l (cons bgn nil))
5993 ((and (<= min article)
5995 (setq l (setcdr l (cons article nil))))))
5996 (set var (cdr lh)))))
5998 ((eq mark-type 'tuple)
5999 (set var (setq articles (cdr marks)))
6000 (when (not (listp (cdr (symbol-value var))))
6001 (set var (list (symbol-value var))))
6002 (when (not (listp (cdr articles)))
6003 (setq articles (list articles)))
6005 (when (or (not (consp (setq article (pop articles))))
6006 (< (car article) min)
6007 (> (car article) max))
6008 (set var (delq article (symbol-value var))))))
6009 ;; Adjust ranges (sloppily).
6010 ((eq mark-type 'range)
6013 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6014 ;; It should be (seen (NUM1 . NUM2)).
6015 (when (numberp (cddr marks))
6016 (setcdr marks (list (cdr marks))))
6017 (setq articles (cdr marks))
6018 (while (and articles
6019 (or (and (consp (car articles))
6020 (> min (cdar articles)))
6021 (and (numberp (car articles))
6022 (> min (car articles)))))
6024 (set var articles))))))))
6026 (defun gnus-update-missing-marks (missing)
6027 "Go through the list of MISSING articles and remove them from the mark lists."
6030 ;; Go through all types.
6031 (dolist (elem gnus-article-mark-lists)
6032 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6033 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6034 (when (symbol-value var)
6035 ;; This list has articles. So we delete all missing
6036 ;; articles from it.
6039 (set var (delq (pop m) (symbol-value var))))))))))
6041 (defun gnus-update-marks ()
6042 "Enter the various lists of marked articles into the newsgroup info list."
6043 (let ((types gnus-article-mark-lists)
6044 (info (gnus-get-info gnus-newsgroup-name))
6045 type list newmarked symbol delta-marks)
6047 ;; Add all marks lists to the list of marks lists.
6048 (while (setq type (pop types))
6049 (setq list (symbol-value
6051 (intern (format "gnus-newsgroup-%s" (car type))))))
6054 ;; Get rid of the entries of the articles that have the
6056 (when (and (eq (cdr type) 'score)
6060 (prev (cons nil list))
6063 (if (or (not (consp (car arts)))
6064 (= (cdar arts) gnus-summary-default-score))
6065 (setcdr prev (cdr arts))
6067 (setq arts (cdr arts)))
6068 (setq list (cdr all)))))
6070 (when (eq (cdr type) 'seen)
6071 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6073 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6074 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6076 (when (and (gnus-check-backend-function
6077 'request-set-mark gnus-newsgroup-name)
6078 (not (gnus-article-unpropagatable-p (cdr type))))
6079 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6080 ;; Don't do anything about marks for articles we
6081 ;; didn't actually get any headers for.
6083 (gnus-list-range-intersection
6084 gnus-newsgroup-articles
6085 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6087 (gnus-list-range-intersection
6088 gnus-newsgroup-articles
6089 (gnus-remove-from-range
6090 (gnus-copy-sequence list) old))))
6092 (push (list add 'add (list (cdr type))) delta-marks))
6094 ;; Don't delete marks from outside the active range.
6095 ;; This shouldn't happen, but is a sanity check.
6096 (setq del (gnus-sorted-range-intersection
6097 (gnus-active gnus-newsgroup-name) del))
6098 (push (list del 'del (list (cdr type))) delta-marks))))
6101 (push (cons (cdr type) list) newmarked)))
6104 (unless (gnus-check-group gnus-newsgroup-name)
6105 (error "Can't open server for %s" gnus-newsgroup-name))
6106 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6108 ;; Enter these new marks into the info of the group.
6110 (setcar (nthcdr 3 info) newmarked)
6111 ;; Add the marks lists to the end of the info.
6113 (setcdr (nthcdr 2 info) (list newmarked))))
6115 ;; Cut off the end of the info if there's nothing else there.
6119 (when (nthcdr (decf i) info)
6120 (setcdr (nthcdr i info) nil)))))))
6122 (defun gnus-set-mode-line (where)
6123 "Set the mode line of the article or summary buffers.
6124 If WHERE is `summary', the summary mode line format will be used."
6125 ;; Is this mode line one we keep updated?
6126 (when (and (memq where gnus-updated-mode-lines)
6128 (intern (format "gnus-%s-mode-line-format-spec" where))))
6130 ;; We evaluate this in the summary buffer since these
6131 ;; variables are buffer-local to that buffer.
6132 (with-current-buffer gnus-summary-buffer
6133 ;; We bind all these variables that are used in the `eval' form
6135 (let* ((mformat (symbol-value
6137 (format "gnus-%s-mode-line-format-spec" where))))
6138 (gnus-tmp-group-name (gnus-mode-string-quote
6139 (gnus-group-decoded-name
6140 gnus-newsgroup-name)))
6141 (gnus-tmp-article-number (or gnus-current-article 0))
6142 (gnus-tmp-unread gnus-newsgroup-unreads)
6143 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6144 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6145 (gnus-tmp-unread-and-unselected
6146 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6147 (zerop gnus-tmp-unselected))
6149 ((zerop gnus-tmp-unselected)
6150 (format "{%d more}" gnus-tmp-unread-and-unticked))
6151 (t (format "{%d(+%d) more}"
6152 gnus-tmp-unread-and-unticked
6153 gnus-tmp-unselected))))
6155 (if (and gnus-current-headers
6156 (vectorp gnus-current-headers))
6157 (gnus-mode-string-quote
6158 (mail-header-subject gnus-current-headers))
6160 bufname-length max-len
6161 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6162 (setq mode-string (eval mformat))
6163 (setq bufname-length (if (string-match "%b" mode-string)
6166 (if (eq where 'summary)
6168 (get-buffer gnus-article-buffer))))
6171 (setq max-len (max 4 (if gnus-mode-non-string-length
6173 gnus-mode-non-string-length
6175 (length mode-string))))
6176 ;; We might have to chop a bit of the string off...
6177 (when (> (length mode-string) max-len)
6179 (concat (truncate-string-to-width mode-string (- max-len 3))
6181 ;; Update the mode line.
6182 (setq mode-line-buffer-identification
6183 (gnus-mode-line-buffer-identification (list mode-string)))
6184 (set-buffer-modified-p t))))
6186 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6187 "Go through the HEADERS list and add all Xrefs to a hash table.
6188 The resulting hash table is returned, or nil if no Xrefs were found."
6189 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6190 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6191 (xref-hashtb (gnus-make-hashtable))
6192 start group entry number xrefs header)
6194 (setq header (pop headers))
6195 (when (and (setq xrefs (mail-header-xref header))
6196 (not (memq (setq number (mail-header-number header))
6199 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6200 (setq start (match-end 0))
6201 (setq group (if prefix
6202 (concat prefix (substring xrefs (match-beginning 1)
6204 (substring xrefs (match-beginning 1) (match-end 1))))
6206 (string-to-number (substring xrefs (match-beginning 2)
6208 (if (setq entry (gnus-gethash group xref-hashtb))
6209 (setcdr entry (cons number (cdr entry)))
6210 (gnus-sethash group (cons number nil) xref-hashtb)))))
6211 (and start xref-hashtb)))
6213 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6214 "Look through all the headers and mark the Xrefs as read."
6215 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6216 name info xref-hashtb idlist method nth4)
6217 (with-current-buffer gnus-group-buffer
6218 (when (setq xref-hashtb
6219 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6222 (unless (string= from-newsgroup (setq name (symbol-name group)))
6223 (setq idlist (symbol-value group))
6224 ;; Dead groups are not updated.
6226 (setq info (gnus-get-info name))
6227 (when (stringp (setq nth4 (gnus-info-method info)))
6228 (setq nth4 (gnus-server-to-method nth4))))
6229 ;; Only do the xrefs if the group has the same
6230 ;; select method as the group we have just read.
6231 (or (gnus-methods-equal-p
6232 nth4 (gnus-find-method-for-group from-newsgroup))
6234 (equal nth4 (setq method (gnus-find-method-for-group
6236 (and (equal (car nth4) (car method))
6237 (equal (nth 1 nth4) (nth 1 method))))
6238 gnus-use-cross-reference
6239 (or (not (eq gnus-use-cross-reference t))
6241 ;; Only do cross-references on subscribed
6242 ;; groups, if that is what is wanted.
6243 (<= (gnus-info-level info) gnus-level-subscribed))
6244 (gnus-group-make-articles-read name idlist))))
6247 (defun gnus-compute-read-articles (group articles)
6248 (let* ((entry (gnus-group-entry group))
6249 (info (nth 2 entry))
6250 (active (gnus-active group))
6253 ;; First peel off all invalid article numbers.
6255 (let ((ids articles)
6257 (while (setq id (pop ids))
6258 (when (and first (> id (cdr active)))
6259 ;; We'll end up in this situation in one particular
6260 ;; obscure situation. If you re-scan a group and get
6261 ;; a new article that is cross-posted to a different
6262 ;; group that has not been re-scanned, you might get
6263 ;; crossposted article that has a higher number than
6264 ;; Gnus believes possible. So we re-activate this
6265 ;; group as well. This might mean doing the
6266 ;; crossposting thingy will *increase* the number
6267 ;; of articles in some groups. Tsk, tsk.
6268 (setq active (or (gnus-activate-group group) active)))
6269 (when (or (> id (cdr active))
6270 (< id (car active)))
6271 (setq articles (delq id articles))))))
6272 ;; If the read list is nil, we init it.
6274 (null (gnus-info-read info))
6276 (setq ninfo (cons 1 (1- (car active))))
6277 (setq ninfo (gnus-info-read info)))
6278 ;; Then we add the read articles to the range.
6280 ninfo (setq articles (sort articles '<))))))
6282 (defun gnus-group-make-articles-read (group articles)
6283 "Update the info of GROUP to say that ARTICLES are read."
6285 (entry (gnus-group-entry group))
6286 (info (nth 2 entry))
6287 (active (gnus-active group))
6289 (or gnus-propagate-marks
6290 (gnus-method-option-p
6291 (gnus-find-method-for-group group)
6295 ;; Group that Gnus doesn't know exists, but still allow the
6296 ;; backend to set marks.
6298 (gnus-request-set-mark
6299 group (list (list (gnus-compress-sequence (sort articles #'<))
6301 ;; Normal, subscribed groups.
6302 (setq range (gnus-compute-read-articles group articles))
6303 (with-current-buffer gnus-group-buffer
6306 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6307 (gnus-info-set-read ',info ',(gnus-info-read info))
6308 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6310 (gnus-request-set-mark
6311 ,group (list (list ',range 'del '(read)))))
6312 (gnus-group-update-group ,group t))))
6313 ;; Add the read articles to the range.
6314 (gnus-info-set-read info range)
6316 (gnus-request-set-mark group (list (list range 'add '(read)))))
6317 ;; Then we have to re-compute how many unread
6318 ;; articles there are in this group.
6322 (setq num (- (1+ (cdr active)) (car active))))
6323 ((not (listp (cdr range)))
6324 (setq num (- (cdr active) (- (1+ (cdr range))
6328 (if (numberp (car range))
6330 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6331 (setq range (cdr range)))
6332 (setq num (- (cdr active) num))))
6333 ;; Update the number of unread articles.
6335 ;; Update the group buffer.
6336 (unless (gnus-ephemeral-group-p group)
6337 (gnus-group-update-group group t))))))
6339 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6340 (let ((cur nntp-server-buffer)
6343 (with-current-buffer gnus-summary-buffer
6344 gnus-newsgroup-dependencies)))
6345 headers id end ref number
6346 (mail-parse-charset gnus-newsgroup-charset)
6347 (mail-parse-ignored-charsets
6348 (save-current-buffer (condition-case nil
6349 (set-buffer gnus-summary-buffer)
6351 gnus-newsgroup-ignored-charsets)))
6352 (with-current-buffer nntp-server-buffer
6353 ;; Translate all TAB characters into SPACE characters.
6354 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6355 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6356 (ietf-drums-unfold-fws)
6357 (gnus-run-hooks 'gnus-parse-headers-hook)
6358 (let ((case-fold-search t)
6359 in-reply-to header p lines chars)
6360 (goto-char (point-min))
6361 ;; Search to the beginning of the next header. Error messages
6362 ;; do not begin with 2 or 3.
6363 (while (re-search-forward "^[23][0-9]+ " nil t)
6366 ;; This implementation of this function, with nine
6367 ;; search-forwards instead of the one re-search-forward and
6368 ;; a case (which basically was the old function) is actually
6369 ;; about twice as fast, even though it looks messier. You
6370 ;; can't have everything, I guess. Speed and elegance
6371 ;; doesn't always go hand in hand.
6377 (setq number (read cur))
6380 (narrow-to-region (point)
6381 (or (and (search-forward "\n.\n" nil t)
6387 (if (search-forward "\nsubject:" nil t)
6388 (funcall gnus-decode-encoded-word-function
6389 (nnheader-header-value))
6394 (if (search-forward "\nfrom:" nil t)
6395 (funcall gnus-decode-encoded-address-function
6396 (nnheader-header-value))
6401 (if (search-forward "\ndate:" nil t)
6402 (nnheader-header-value) ""))
6406 (setq id (if (re-search-forward
6407 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6408 ;; We do it this way to make sure the Message-ID
6409 ;; is (somewhat) syntactically valid.
6410 (buffer-substring (match-beginning 1)
6412 ;; If there was no message-id, we just fake one
6413 ;; to make subsequent routines simpler.
6414 (nnheader-generate-fake-message-id number))))
6418 (if (search-forward "\nreferences:" nil t)
6422 (nnheader-header-value)
6427 (search-backward ">" end t)
6430 (search-backward "<" end t)
6432 ;; Get the references from the in-reply-to header if there
6433 ;; were no references and the in-reply-to header looks
6435 (if (and (search-forward "\nin-reply-to:" nil t)
6436 (setq in-reply-to (nnheader-header-value))
6437 (string-match "<[^>]+>" in-reply-to))
6439 (setq ref (substring in-reply-to (match-beginning 0)
6441 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6442 (setq ref2 (substring in-reply-to (match-beginning 0)
6444 (when (> (length ref2) (length ref))
6451 (if (search-forward "\nchars: " nil t)
6452 (if (numberp (setq chars (ignore-errors (read cur))))
6458 (if (search-forward "\nlines: " nil t)
6459 (if (numberp (setq lines (ignore-errors (read cur))))
6465 (and (search-forward "\nxref:" nil t)
6466 (nnheader-header-value)))
6468 (when gnus-extra-headers
6469 (let ((extra gnus-extra-headers)
6473 (when (search-forward
6474 (concat "\n" (symbol-name (car extra)) ":") nil t)
6475 (push (cons (car extra) (nnheader-header-value))
6479 (when (equal id ref)
6482 (when gnus-alter-header-function
6483 (funcall gnus-alter-header-function header)
6484 (setq id (mail-header-id header)
6485 ref (gnus-parent-id (mail-header-references header))))
6488 (gnus-dependencies-add-header
6489 header dependencies force-new))
6490 (push header headers))
6491 (goto-char (point-max))
6493 (nreverse headers)))))
6495 ;; Goes through the xover lines and returns a list of vectors
6496 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6497 force-new dependencies
6498 group also-fetch-heads)
6499 "Parse the news overview data in the server buffer.
6500 Return a list of headers that match SEQUENCE (see
6501 `nntp-retrieve-headers')."
6502 ;; Get the Xref when the users reads the articles since most/some
6503 ;; NNTP servers do not include Xrefs when using XOVER.
6504 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6505 (let ((mail-parse-charset gnus-newsgroup-charset)
6506 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6507 (cur nntp-server-buffer)
6508 (dependencies (or dependencies gnus-newsgroup-dependencies))
6510 ((eq gnus-read-all-available-headers t)
6512 ((and (stringp gnus-read-all-available-headers)
6514 (string-match gnus-read-all-available-headers group))
6517 number headers header)
6518 (with-current-buffer nntp-server-buffer
6519 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6520 ;; Allow the user to mangle the headers before parsing them.
6521 (gnus-run-hooks 'gnus-parse-headers-hook)
6522 (goto-char (point-min))
6523 (gnus-parse-without-error
6524 (while (and (or sequence allp)
6526 (setq number (read cur))
6528 (while (and sequence
6529 (< (car sequence) number))
6530 (setq sequence (cdr sequence))))
6533 (eq number (car sequence))))
6535 (setq sequence (cdr sequence))
6536 (setq header (inline
6537 (gnus-nov-parse-line
6538 number dependencies force-new)))))
6539 (push header headers))
6541 ;; A common bug in inn is that if you have posted an article and
6542 ;; then retrieves the active file, it will answer correctly --
6543 ;; the new article is included. However, a NOV entry for the
6544 ;; article may not have been generated yet, so this may fail.
6545 ;; We work around this problem by retrieving the last few
6546 ;; headers using HEAD.
6547 (if (or (not also-fetch-heads)
6549 ;; We (probably) got all the headers.
6551 (let ((gnus-nov-is-evil t))
6554 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6555 (gnus-get-newsgroup-headers))))))))
6557 (defun gnus-article-get-xrefs ()
6558 "Fill in the Xref value in `gnus-current-headers', if necessary.
6559 This is meant to be called in `gnus-article-internal-prepare-hook'."
6560 (let ((headers (with-current-buffer gnus-summary-buffer
6561 gnus-current-headers)))
6562 (or (not gnus-use-cross-reference)
6564 (and (mail-header-xref headers)
6565 (not (string= (mail-header-xref headers) "")))
6566 (let ((case-fold-search t)
6569 (nnheader-narrow-to-headers)
6570 (goto-char (point-min))
6571 (when (or (and (not (eobp))
6572 (eq (downcase (char-after)) ?x)
6573 (looking-at "Xref:"))
6574 (search-forward "\nXref:" nil t))
6575 (goto-char (1+ (match-end 0)))
6576 (setq xref (buffer-substring (point) (point-at-eol)))
6577 (mail-header-set-xref headers xref)))))))
6579 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6580 "Find article ID and insert the summary line for that article.
6581 OLD-HEADER can either be a header or a line number to insert
6582 the subject line on.
6583 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6584 and OLD-HEADER will be used when the summary line is inserted,
6585 too, instead of trying to fetch new headers."
6586 (let* ((line (and (numberp old-header) old-header))
6587 (old-header (and (vectorp old-header) old-header))
6588 (header (cond ((and old-header use-old-header)
6591 (gnus-number-to-header id))
6592 (gnus-number-to-header id))
6594 (gnus-read-header id))))
6595 (number (and (numberp id) id))
6598 ;; Rebuild the thread that this article is part of and go to the
6599 ;; article we have fetched.
6600 (when (and (not gnus-show-threads)
6603 (setq d (gnus-data-find (mail-header-number old-header))))
6604 (goto-char (gnus-data-pos d))
6610 (gnus-delete-line))))))
6611 ;; Remove list identifiers from subject.
6612 (let ((gnus-newsgroup-headers (list header)))
6613 (gnus-summary-remove-list-identifiers))
6615 (mail-header-set-number header (mail-header-number old-header)))
6616 (setq gnus-newsgroup-sparse
6617 (delq (setq number (mail-header-number header))
6618 gnus-newsgroup-sparse))
6619 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6620 (push number gnus-newsgroup-limit)
6621 (gnus-rebuild-thread (mail-header-id header) line)
6622 (gnus-summary-goto-subject number nil t))
6623 (when (and (numberp number)
6625 ;; We have to update the boundaries even if we can't fetch the
6626 ;; article if ID is a number -- so that the next `P' or `N'
6627 ;; command will fetch the previous (or next) article even
6628 ;; if the one we tried to fetch this time has been canceled.
6629 (when (> number gnus-newsgroup-end)
6630 (setq gnus-newsgroup-end number))
6631 (when (< number gnus-newsgroup-begin)
6632 (setq gnus-newsgroup-begin number))
6633 (setq gnus-newsgroup-unselected
6634 (delq number gnus-newsgroup-unselected)))
6635 ;; Report back a success?
6636 (and header (mail-header-number header))))
6638 ;;; Process/prefix in the summary buffer
6640 (defun gnus-summary-work-articles (n)
6641 "Return a list of articles to be worked upon.
6642 The prefix argument, the list of process marked articles, and the
6643 current article will be taken into consideration."
6644 (with-current-buffer gnus-summary-buffer
6647 ;; A numerical prefix has been given.
6648 (setq n (prefix-numeric-value n))
6649 (let ((backward (< n 0))
6650 (n (abs (prefix-numeric-value n)))
6655 (push (setq article (gnus-summary-article-number))
6658 (gnus-summary-find-prev nil article)
6659 (gnus-summary-find-next nil article)))
6661 (nreverse articles)))
6662 ((and (gnus-region-active-p) (mark))
6663 (message "region active")
6664 ;; Work on the region between point and mark.
6665 (let ((max (max (point) (mark)))
6668 (goto-char (min (point) (mark)))
6671 (push (setq article (gnus-summary-article-number)) articles)
6672 (gnus-summary-find-next nil article)
6674 (nreverse articles))))
6675 (gnus-newsgroup-processable
6676 ;; There are process-marked articles present.
6677 ;; Save current state.
6678 (gnus-summary-save-process-mark)
6680 (reverse gnus-newsgroup-processable))
6682 ;; Just return the current article.
6683 (list (gnus-summary-article-number))))))
6685 (defmacro gnus-summary-iterate (arg &rest forms)
6686 "Iterate over the process/prefixed articles and do FORMS.
6687 ARG is the interactive prefix given to the command. FORMS will be
6688 executed with point over the summary line of the articles."
6689 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6690 `(let ((,articles (gnus-summary-work-articles ,arg)))
6692 (gnus-summary-goto-subject (car ,articles))
6696 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6697 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6699 (defun gnus-summary-save-process-mark ()
6700 "Push the current set of process marked articles on the stack."
6702 (push (copy-sequence gnus-newsgroup-processable)
6703 gnus-newsgroup-process-stack))
6705 (defun gnus-summary-kill-process-mark ()
6706 "Push the current set of process marked articles on the stack and unmark."
6708 (gnus-summary-save-process-mark)
6709 (gnus-summary-unmark-all-processable))
6711 (defun gnus-summary-yank-process-mark ()
6712 "Pop the last process mark state off the stack and restore it."
6714 (unless gnus-newsgroup-process-stack
6715 (error "Empty mark stack"))
6716 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6718 (defun gnus-summary-process-mark-set (set)
6719 "Make SET into the current process marked articles."
6720 (gnus-summary-unmark-all-processable)
6721 (mapc 'gnus-summary-set-process-mark set))
6723 ;;; Searching and stuff
6725 (defun gnus-summary-search-group (&optional backward use-level)
6726 "Search for next unread newsgroup.
6727 If optional argument BACKWARD is non-nil, search backward instead."
6728 (with-current-buffer gnus-group-buffer
6729 (when (gnus-group-search-forward
6730 backward nil (if use-level (gnus-group-group-level) nil))
6731 (gnus-group-group-name))))
6733 (defun gnus-summary-best-group (&optional exclude-group)
6734 "Find the name of the best unread group.
6735 If EXCLUDE-GROUP, do not go to this group."
6736 (with-current-buffer gnus-group-buffer
6738 (gnus-group-best-unread-group exclude-group))))
6740 (defun gnus-summary-find-next (&optional unread article backward)
6742 (gnus-summary-find-prev unread article)
6743 (let* ((dummy (gnus-summary-article-intangible-p))
6744 (article (or article (gnus-summary-article-number)))
6745 (data (gnus-data-find-list article))
6747 (when (and (not dummy)
6748 (or (not gnus-summary-check-current)
6750 (not (gnus-data-unread-p (car data)))))
6751 (setq data (cdr data)))
6756 (unless (memq (gnus-data-number (car data))
6758 ((eq gnus-auto-goto-ignores
6759 'always-undownloaded)
6760 gnus-newsgroup-undownloaded)
6763 ((eq gnus-auto-goto-ignores
6765 gnus-newsgroup-unfetched)
6766 ((eq gnus-auto-goto-ignores
6768 gnus-newsgroup-undownloaded)))
6769 (when (gnus-data-unread-p (car data))
6770 (setq result (car data)
6772 (setq data (cdr data)))
6775 (goto-char (gnus-data-pos result))
6776 (gnus-data-number result)))))
6778 (defun gnus-summary-find-prev (&optional unread article)
6779 (let* ((eobp (eobp))
6780 (article (or article (gnus-summary-article-number)))
6781 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6783 (when (and (not eobp)
6784 (or (not gnus-summary-check-current)
6786 (not (gnus-data-unread-p (car data)))))
6787 (setq data (cdr data)))
6792 (unless (memq (gnus-data-number (car data))
6794 ((eq gnus-auto-goto-ignores
6795 'always-undownloaded)
6796 gnus-newsgroup-undownloaded)
6799 ((eq gnus-auto-goto-ignores
6801 gnus-newsgroup-unfetched)
6802 ((eq gnus-auto-goto-ignores
6804 gnus-newsgroup-undownloaded)))
6805 (when (gnus-data-unread-p (car data))
6806 (setq result (car data)
6808 (setq data (cdr data)))
6811 (goto-char (gnus-data-pos result))
6812 (gnus-data-number result))))
6814 (defun gnus-summary-find-subject (subject &optional unread backward article)
6815 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6816 (article (or article (gnus-summary-article-number)))
6817 (articles (gnus-data-list backward))
6818 (arts (gnus-data-find-list article articles))
6820 (when (or (not gnus-summary-check-current)
6822 (not (gnus-data-unread-p (car arts))))
6823 (setq arts (cdr arts)))
6825 (and (or (not unread)
6826 (gnus-data-unread-p (car arts)))
6827 (vectorp (gnus-data-header (car arts)))
6829 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6830 (setq result (car arts)
6832 (setq arts (cdr arts)))
6834 (goto-char (gnus-data-pos result))
6835 (gnus-data-number result))))
6837 (defun gnus-summary-search-forward (&optional unread subject backward)
6838 "Search forward for an article.
6839 If UNREAD, look for unread articles. If SUBJECT, look for
6840 articles with that subject. If BACKWARD, search backward instead."
6841 (cond (subject (gnus-summary-find-subject subject unread backward))
6842 (backward (gnus-summary-find-prev unread))
6843 (t (gnus-summary-find-next unread))))
6845 (defun gnus-recenter (&optional n)
6846 "Center point in window and redisplay frame.
6847 Also do horizontal recentering."
6849 (when (and gnus-auto-center-summary
6850 (not (eq gnus-auto-center-summary 'vertical)))
6851 (gnus-horizontal-recenter))
6852 (if (fboundp 'recenter-top-bottom)
6853 (recenter-top-bottom n)
6856 (put 'gnus-recenter 'isearch-scroll t)
6858 (defun gnus-forward-line-ignore-invisible (n)
6859 "Move N lines forward (backward if N is negative).
6860 Like forward-line, but skip over (and don't count) invisible lines."
6862 (while (and (> n 0) (not done))
6863 ;; If the following character is currently invisible,
6864 ;; skip all characters with that same `invisible' property value.
6865 (while (gnus-invisible-p (point))
6866 (goto-char (gnus-next-char-property-change (point))))
6871 (while (and (< n 0) (not done))
6873 (if (bobp) (setq done t)
6875 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6876 (goto-char (gnus-previous-char-property-change (point))))))))
6878 (defun gnus-summary-recenter ()
6879 "Center point in the summary window.
6880 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6881 displayed, no centering will be performed."
6882 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6883 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6885 ;; The user has to want it.
6886 (when gnus-auto-center-summary
6887 (let* ((top (cond ((< (window-height) 4) 0)
6888 ((< (window-height) 7) 1)
6889 (t (if (numberp gnus-auto-center-summary)
6890 gnus-auto-center-summary
6891 (/ (1- (window-height)) 2)))))
6892 (height (1- (window-height)))
6893 (bottom (save-excursion
6894 (goto-char (point-max))
6895 (gnus-forward-line-ignore-invisible (- height))
6897 (window (get-buffer-window (current-buffer))))
6898 (when (get-buffer-window gnus-article-buffer)
6899 ;; Only do recentering when the article buffer is displayed,
6900 ;; Set the window start to either `bottom', which is the biggest
6901 ;; possible valid number, or the second line from the top,
6902 ;; whichever is the least.
6903 (let ((top-pos (save-excursion
6904 (gnus-forward-line-ignore-invisible (- top))
6906 (if (> bottom top-pos)
6907 ;; Keep the second line from the top visible
6908 (set-window-start window top-pos)
6909 ;; Try to keep the bottom line visible; if it's partially
6910 ;; obscured, either scroll one more line to make it fully
6911 ;; visible, or revert to using TOP-POS.
6913 (goto-char (point-max))
6914 (gnus-forward-line-ignore-invisible -1)
6915 (let ((last-line-start (point)))
6917 (set-window-start window (point) t)
6918 (when (not (pos-visible-in-window-p last-line-start window))
6919 (gnus-forward-line-ignore-invisible 1)
6920 (set-window-start window (min (point) top-pos) t)))))))
6921 ;; Do horizontal recentering while we're at it.
6922 (when (and (get-buffer-window (current-buffer) t)
6923 (not (eq gnus-auto-center-summary 'vertical)))
6924 (let ((selected (selected-window)))
6925 (select-window (get-buffer-window (current-buffer) t))
6926 (gnus-summary-position-point)
6927 (gnus-horizontal-recenter)
6928 (select-window selected))))))
6930 (defun gnus-summary-jump-to-group (newsgroup)
6931 "Move point to NEWSGROUP in group mode buffer."
6932 ;; Keep update point of group mode buffer if visible.
6933 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6934 (save-window-excursion
6935 ;; Take care of tree window mode.
6936 (when (get-buffer-window gnus-group-buffer)
6937 (pop-to-buffer gnus-group-buffer))
6938 (gnus-group-jump-to-group newsgroup))
6940 ;; Take care of tree window mode.
6941 (if (get-buffer-window gnus-group-buffer 0)
6942 (pop-to-buffer gnus-group-buffer)
6943 (set-buffer gnus-group-buffer))
6944 (gnus-group-jump-to-group newsgroup))))
6946 ;; This function returns a list of article numbers based on the
6947 ;; difference between the ranges of read articles in this group and
6948 ;; the range of active articles.
6949 (defun gnus-list-of-unread-articles (group)
6950 (let* ((read (gnus-info-read (gnus-get-info group)))
6951 (active (or (gnus-active group) (gnus-activate-group group)))
6952 (last (or (cdr active)
6953 (error "Group %s couldn't be activated " group)))
6954 (bottom (if gnus-newsgroup-maximum-articles
6956 (- last gnus-newsgroup-maximum-articles -1))
6959 ;; If none are read, then all are unread.
6962 ;; If the range of read articles is a single range, then the
6963 ;; first unread article is the article after the last read
6964 ;; article. Sounds logical, doesn't it?
6965 (if (and (not (listp (cdr read)))
6966 (or (< (car read) bottom)
6967 (progn (setq read (list read))
6969 (setq first (max bottom (1+ (cdr read))))
6970 ;; `read' is a list of ranges.
6971 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6974 (setq first bottom))
6977 (while (< first nlast)
6978 (setq unread (cons first unread)
6980 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6981 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6982 (setq read (cdr read)))))
6983 ;; And add the last unread articles.
6984 (while (<= first last)
6985 (setq unread (cons first unread)
6987 ;; Return the list of unread articles.
6988 (delq 0 (nreverse unread))))
6990 (defun gnus-list-of-read-articles (group)
6991 "Return a list of unread, unticked and non-dormant articles."
6992 (let* ((info (gnus-get-info group))
6993 (marked (gnus-info-marks info))
6994 (active (gnus-active group)))
6996 (gnus-list-range-difference
6997 (gnus-list-range-difference
6998 (gnus-sorted-complement
6999 (gnus-uncompress-range
7000 (if gnus-newsgroup-maximum-articles
7001 (cons (max (car active)
7003 gnus-newsgroup-maximum-articles
7007 (gnus-list-of-unread-articles group))
7008 (cdr (assq 'dormant marked)))
7009 (cdr (assq 'tick marked))))))
7011 ;; This function returns a sequence of article numbers based on the
7012 ;; difference between the ranges of read articles in this group and
7013 ;; the range of active articles.
7014 (defun gnus-sequence-of-unread-articles (group)
7015 (let* ((read (gnus-info-read (gnus-get-info group)))
7016 (active (or (gnus-active group) (gnus-activate-group group)))
7018 (bottom (if gnus-newsgroup-maximum-articles
7020 (- last gnus-newsgroup-maximum-articles -1))
7023 ;; If none are read, then all are unread.
7026 ;; If the range of read articles is a single range, then the
7027 ;; first unread article is the article after the last read
7028 ;; article. Sounds logical, doesn't it?
7029 (if (and (not (listp (cdr read)))
7030 (or (< (car read) bottom)
7031 (progn (setq read (list read))
7033 (setq first (max bottom (1+ (cdr read))))
7034 ;; `read' is a list of ranges.
7035 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7038 (setq first bottom))
7041 (push (cons first nlast) unread))
7042 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7043 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7044 (setq read (cdr read)))))
7045 ;; And add the last unread articles.
7046 (cond ((not (and first last))
7049 (push (cons first last) unread))
7051 (push first unread)))
7052 ;; Return the sequence of unread articles.
7053 (delq 0 (nreverse unread))))
7055 ;; Various summary commands
7057 (defun gnus-summary-select-article-buffer ()
7058 "Reconfigure windows to show the article buffer.
7059 If `gnus-widen-article-window' is set, show only the article
7062 (if (not (gnus-buffer-live-p gnus-article-buffer))
7063 (error "There is no article buffer for this summary buffer")
7064 (unless (get-buffer-window gnus-article-buffer)
7065 (gnus-summary-show-article))
7066 (gnus-configure-windows
7067 (if gnus-widen-article-window
7071 (select-window (get-buffer-window gnus-article-buffer))))
7073 (defun gnus-summary-universal-argument (arg)
7074 "Perform any operation on all articles that are process/prefixed."
7076 (let ((articles (gnus-summary-work-articles arg))
7083 (substitute-command-keys
7084 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7086 (gnus-error 1 "Undefined key")
7089 (gnus-summary-goto-subject (setq article (pop articles)))
7090 (let (gnus-newsgroup-processable)
7091 (command-execute func))
7092 (gnus-summary-remove-process-mark article)))))
7093 (gnus-summary-position-point))
7095 (defun gnus-summary-toggle-truncation (&optional arg)
7096 "Toggle truncation of summary lines.
7097 With ARG, turn line truncation on if ARG is positive."
7099 (setq truncate-lines
7100 (if (null arg) (not truncate-lines)
7101 (> (prefix-numeric-value arg) 0)))
7104 (defun gnus-summary-find-for-reselect ()
7105 "Return the number of an article to stay on across a reselect.
7106 The current article is considered, then following articles, then previous
7107 articles. An article is sought which is not canceled and isn't a temporary
7108 insertion from another group. If there's no such then return a dummy 0."
7110 (dolist (rev '(nil t))
7111 (unless found ; don't demand the reverse list if we don't need it
7112 (let ((data (gnus-data-find-list
7113 (gnus-summary-article-number) (gnus-data-list rev))))
7114 (while (and data (not found))
7115 (if (and (< 0 (gnus-data-number (car data)))
7116 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7117 (setq found (gnus-data-number (car data))))
7118 (setq data (cdr data))))))
7121 (defun gnus-summary-reselect-current-group (&optional all rescan)
7122 "Exit and then reselect the current newsgroup.
7123 The prefix argument ALL means to select all articles."
7125 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7126 (error "Ephemeral groups can't be reselected"))
7127 (let ((current-subject (gnus-summary-find-for-reselect))
7128 (group gnus-newsgroup-name))
7129 (setq gnus-newsgroup-begin nil)
7130 (gnus-summary-exit nil 'leave-hidden)
7131 ;; We have to adjust the point of group mode buffer because
7132 ;; point was moved to the next unread newsgroup by exiting.
7133 (gnus-summary-jump-to-group group)
7136 (gnus-group-get-new-news-this-group 1)))
7137 (gnus-group-read-group all t)
7138 (gnus-summary-goto-subject current-subject nil t)))
7140 (defun gnus-summary-rescan-group (&optional all)
7141 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7143 (let ((config gnus-current-window-configuration))
7144 (gnus-summary-reselect-current-group all t)
7145 (gnus-configure-windows config)
7146 (when (eq config 'article)
7147 (gnus-summary-select-article))))
7149 (defun gnus-summary-update-info (&optional non-destructive)
7151 (let ((group gnus-newsgroup-name))
7153 (when gnus-newsgroup-kill-headers
7154 (setq gnus-newsgroup-killed
7155 (gnus-compress-sequence
7157 (gnus-list-range-intersection
7158 gnus-newsgroup-unselected gnus-newsgroup-killed)
7159 gnus-newsgroup-unreads)
7161 (unless (listp (cdr gnus-newsgroup-killed))
7162 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7163 (let ((headers gnus-newsgroup-headers)
7164 (ephemeral-p (gnus-ephemeral-group-p group))
7167 (setq info (copy-sequence (gnus-get-info group))
7168 info (delq (gnus-info-params info) info)))
7169 ;; Set the new ranges of read articles.
7170 (with-current-buffer gnus-group-buffer
7171 (gnus-undo-force-boundary))
7172 (gnus-update-read-articles
7173 group (gnus-sorted-union
7174 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7175 ;; Set the current article marks.
7176 (let ((gnus-newsgroup-scored
7177 (if (and (not gnus-save-score)
7178 (not non-destructive))
7180 gnus-newsgroup-scored)))
7182 (gnus-update-marks)))
7183 ;; Do the cross-ref thing.
7184 (when gnus-use-cross-reference
7185 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7186 ;; Do not switch windows but change the buffer to work.
7187 (set-buffer gnus-group-buffer)
7189 (gnus-group-update-group
7192 (setq info (copy-sequence (gnus-get-info group))
7193 info (delq (gnus-info-params info) info))))))))))
7195 (defun gnus-summary-save-newsrc (&optional force)
7196 "Save the current number of read/marked articles in the dribble buffer.
7197 The dribble buffer will then be saved.
7198 If FORCE (the prefix), also save the .newsrc file(s)."
7200 (gnus-summary-update-info t)
7202 (gnus-save-newsrc-file)
7203 (gnus-dribble-save)))
7205 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7207 (defun gnus-summary-exit (&optional temporary leave-hidden)
7208 "Exit reading current newsgroup, and then return to group selection mode.
7209 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7211 (gnus-set-global-variables)
7212 (when (gnus-buffer-live-p gnus-article-buffer)
7213 (with-current-buffer gnus-article-buffer
7214 (mm-destroy-parts gnus-article-mime-handles)
7215 ;; Set it to nil for safety reason.
7216 (setq gnus-article-mime-handle-alist nil)
7217 (setq gnus-article-mime-handles nil)))
7218 (gnus-kill-save-kill-buffer)
7219 (gnus-async-halt-prefetch)
7220 (let* ((group gnus-newsgroup-name)
7221 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7222 (gnus-group-is-exiting-p t)
7223 (article-buffer gnus-article-buffer)
7224 (original-article-buffer gnus-original-article-buffer)
7227 (buf (current-buffer))
7228 ;; `gnus-single-article-buffer' is nil buffer-locally in
7229 ;; ephemeral group of which summary buffer will be killed,
7230 ;; but the global value may be non-nil.
7231 (single-article-buffer gnus-single-article-buffer))
7233 ;; Do adaptive scoring, and possibly save score files.
7234 (when gnus-newsgroup-adaptive
7235 (gnus-score-adaptive))
7236 (when gnus-use-scoring
7238 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7239 (when gnus-use-cache
7240 (gnus-cache-possibly-remove-articles)
7241 (gnus-cache-save-buffers))
7242 (gnus-async-prefetch-remove-group group)
7243 (when gnus-suppress-duplicates
7244 (gnus-dup-enter-articles))
7245 (when gnus-use-trees
7246 (gnus-tree-close group))
7247 (when gnus-use-cache
7248 (gnus-cache-write-active))
7249 ;; Remove entries for this group.
7250 (nnmail-purge-split-history (gnus-group-real-name group))
7251 ;; Make all changes in this group permanent.
7253 (gnus-run-hooks 'gnus-exit-group-hook)
7254 (gnus-summary-update-info))
7255 (gnus-close-group group)
7256 ;; Make sure where we were, and go to next newsgroup.
7257 (set-buffer gnus-group-buffer)
7259 (gnus-group-jump-to-group group))
7260 (gnus-run-hooks 'gnus-summary-exit-hook)
7261 (unless (or quit-config
7262 (not gnus-summary-next-group-on-exit)
7263 ;; If this group has disappeared from the summary
7264 ;; buffer, don't skip forwards.
7265 (not (string= group (gnus-group-group-name))))
7266 (gnus-group-next-unread-group 1))
7267 (setq group-point (point))
7271 (if (not gnus-kill-summary-on-exit)
7273 (gnus-deaden-summary)
7275 (when (get-buffer gnus-article-buffer)
7276 (bury-buffer gnus-article-buffer))
7277 ;; Return to group mode buffer.
7278 (when (eq mode 'gnus-summary-mode)
7279 (gnus-kill-buffer buf)))
7281 (setq gnus-current-select-method gnus-select-method)
7282 (set-buffer gnus-group-buffer)
7284 (gnus-handle-ephemeral-exit quit-config)
7285 (goto-char group-point)
7286 ;; If gnus-group-buffer is already displayed, make sure we also move
7287 ;; the cursor in the window that displays it.
7288 (let ((win (get-buffer-window (current-buffer) 0)))
7289 (if win (set-window-point win (point))))
7290 (unless leave-hidden
7291 (gnus-configure-windows 'group 'force)))
7293 ;; If we have several article buffers, we kill them at exit.
7294 (unless single-article-buffer
7295 (when (gnus-buffer-live-p article-buffer)
7296 (with-current-buffer article-buffer
7297 ;; Don't kill sticky article buffers
7298 (unless (eq major-mode 'gnus-sticky-article-mode)
7299 (gnus-kill-buffer article-buffer)
7300 (setq gnus-article-current nil))))
7301 (gnus-kill-buffer original-article-buffer))
7303 ;; Clear the current group name.
7305 (setq gnus-newsgroup-name nil)))))
7307 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7308 (defun gnus-summary-exit-no-update (&optional no-questions)
7309 "Quit reading current newsgroup without updating read article info."
7311 (let* ((group gnus-newsgroup-name)
7312 (gnus-group-is-exiting-p t)
7313 (gnus-group-is-exiting-without-update-p t)
7314 (quit-config (gnus-group-quit-config group)))
7315 (when (or no-questions
7317 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7318 (gnus-async-halt-prefetch)
7319 (run-hooks 'gnus-summary-prepare-exit-hook)
7320 (when (gnus-buffer-live-p gnus-article-buffer)
7321 (with-current-buffer gnus-article-buffer
7322 (gnus-article-stop-animations)
7323 (mm-destroy-parts gnus-article-mime-handles)
7324 ;; Set it to nil for safety reason.
7325 (setq gnus-article-mime-handle-alist nil)
7326 (setq gnus-article-mime-handles nil)))
7327 ;; If we have several article buffers, we kill them at exit.
7328 (unless gnus-single-article-buffer
7329 (gnus-kill-buffer gnus-article-buffer)
7330 (gnus-kill-buffer gnus-original-article-buffer)
7331 (setq gnus-article-current nil))
7332 ;; Return to the group buffer.
7333 (if (not gnus-kill-summary-on-exit)
7335 (gnus-deaden-summary)
7336 (gnus-configure-windows 'group 'force))
7337 (gnus-configure-windows 'group 'force)
7338 (gnus-close-group group)
7339 (gnus-kill-buffer gnus-summary-buffer))
7340 (unless gnus-single-article-buffer
7341 (setq gnus-article-current nil))
7342 (when gnus-use-trees
7343 (gnus-tree-close group))
7344 (gnus-async-prefetch-remove-group group)
7345 (when (get-buffer gnus-article-buffer)
7346 (bury-buffer gnus-article-buffer))
7347 ;; Clear the current group name.
7348 (setq gnus-newsgroup-name nil)
7349 (unless (gnus-ephemeral-group-p group)
7350 (gnus-group-update-group group nil t))
7351 (when (equal (gnus-group-group-name) group)
7352 (gnus-group-next-unread-group 1))
7354 (gnus-handle-ephemeral-exit quit-config)))))
7356 (defun gnus-handle-ephemeral-exit (quit-config)
7357 "Handle movement when leaving an ephemeral group.
7358 The state which existed when entering the ephemeral is reset."
7359 (if (not (buffer-live-p (car quit-config)))
7360 (gnus-configure-windows 'group 'force)
7361 (set-buffer (car quit-config))
7362 (unless (eq (cdr quit-config) 'group)
7363 (setq gnus-current-select-method
7364 (gnus-find-method-for-group gnus-newsgroup-name)))
7365 (cond ((eq major-mode 'gnus-summary-mode)
7366 (gnus-set-global-variables))
7367 ((eq major-mode 'gnus-article-mode)
7368 (save-current-buffer
7369 ;; The `gnus-summary-buffer' variable may point
7370 ;; to the old summary buffer when using a single
7372 (unless (gnus-buffer-live-p gnus-summary-buffer)
7373 (set-buffer gnus-group-buffer))
7374 (set-buffer gnus-summary-buffer)
7375 (gnus-set-global-variables))))
7376 (if (or (eq (cdr quit-config) 'article)
7377 (eq (cdr quit-config) 'pick))
7378 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7379 (gnus-configure-windows 'pick 'force)
7380 (gnus-configure-windows (cdr quit-config) 'force))
7381 (gnus-configure-windows (cdr quit-config) 'force))
7382 (when (eq major-mode 'gnus-summary-mode)
7383 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7384 next-unread-noselect))
7385 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7387 (gnus-summary-next-subject 1 nil t))
7388 ((eq gnus-auto-select-on-ephemeral-exit
7389 'next-unread-noselect)
7390 (gnus-summary-next-subject 1 t t))))
7391 ;; Hide the article buffer which displays the article different
7392 ;; from the one that the cursor points to in the summary buffer.
7393 (gnus-configure-windows 'summary 'force))
7394 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7395 (gnus-summary-next-subject 1))
7396 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7397 (gnus-summary-next-subject 1 t))))
7398 (gnus-summary-recenter)
7399 (gnus-summary-position-point))))
7403 (defvar gnus-dead-summary-mode-map
7404 (let ((map (make-keymap)))
7405 (suppress-keymap map)
7406 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7407 (dolist (key '("\C-d" "\r" "\177" [delete]))
7408 (define-key map key 'gnus-summary-wake-up-the-dead))
7409 (dolist (key '("q" "Q"))
7410 (define-key map key 'bury-buffer))
7413 (define-minor-mode gnus-dead-summary-mode
7414 "Minor mode for Gnus summary buffers."
7415 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7416 (unless (derived-mode-p 'gnus-summary-mode)
7417 (setq gnus-dead-summary-mode nil)))
7419 (defun gnus-deaden-summary ()
7420 "Make the current summary buffer into a dead summary buffer."
7421 ;; Kill any previous dead summary buffer.
7422 (when (and gnus-dead-summary
7423 (buffer-name gnus-dead-summary))
7424 (with-current-buffer gnus-dead-summary
7425 (when gnus-dead-summary-mode
7426 (kill-buffer (current-buffer)))))
7427 ;; Make this the current dead summary.
7428 (setq gnus-dead-summary (current-buffer))
7429 (gnus-dead-summary-mode 1)
7430 (let ((name (buffer-name)))
7431 (when (string-match "Summary" name)
7433 (concat (substring name 0 (match-beginning 0)) "Dead "
7434 (substring name (match-beginning 0)))
7438 (defun gnus-kill-or-deaden-summary (buffer)
7439 "Kill or deaden the summary BUFFER."
7441 (when (and (buffer-name buffer)
7442 (not gnus-single-article-buffer))
7443 (with-current-buffer buffer
7444 (gnus-kill-buffer gnus-article-buffer)
7445 (gnus-kill-buffer gnus-original-article-buffer)))
7448 (gnus-kill-summary-on-exit
7449 (when (and gnus-use-trees
7450 (gnus-buffer-exists-p buffer))
7451 (with-current-buffer buffer
7452 (gnus-tree-close gnus-newsgroup-name)))
7453 (gnus-kill-buffer buffer))
7454 ;; Deaden the buffer.
7455 ((gnus-buffer-exists-p buffer)
7456 (with-current-buffer buffer
7457 (gnus-deaden-summary))))))
7459 (defun gnus-summary-wake-up-the-dead (&rest args)
7460 "Wake up the dead summary buffer."
7462 (gnus-dead-summary-mode -1)
7463 (let ((name (buffer-name)))
7464 (when (string-match "Dead " name)
7466 (concat (substring name 0 (match-beginning 0))
7467 (substring name (match-end 0)))
7469 (gnus-message 3 "This dead summary is now alive again"))
7471 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7472 (defun gnus-summary-describe-group (&optional force)
7473 "Describe the current newsgroup."
7475 (gnus-group-describe-group force gnus-newsgroup-name))
7477 (defun gnus-summary-describe-briefly ()
7478 "Describe summary mode commands briefly."
7480 (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")))
7482 ;; Walking around group mode buffer from summary mode.
7484 (defun gnus-summary-next-group (&optional no-article target-group backward)
7485 "Exit current newsgroup and then select next unread newsgroup.
7486 If prefix argument NO-ARTICLE is non-nil, no article is selected
7487 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7488 previous group instead."
7490 ;; Stop pre-fetching.
7491 (gnus-async-halt-prefetch)
7492 (let ((current-group gnus-newsgroup-name)
7493 (current-buffer (current-buffer))
7495 ;; First we semi-exit this group to update Xrefs and all variables.
7496 ;; We can't do a real exit, because the window conf must remain
7497 ;; the same in case the user is prompted for info, and we don't
7498 ;; want the window conf to change before that...
7499 (gnus-summary-exit t)
7500 (while (not entered)
7501 ;; Then we find what group we are supposed to enter.
7502 (set-buffer gnus-group-buffer)
7503 (gnus-group-jump-to-group current-group)
7506 (if (eq gnus-keep-same-level 'best)
7507 (gnus-summary-best-group gnus-newsgroup-name)
7508 (gnus-summary-search-group backward gnus-keep-same-level))))
7509 (if (not target-group)
7510 ;; There are no further groups, so we return to the group
7513 (gnus-message 5 "Returning to the group buffer")
7515 (when (gnus-buffer-live-p current-buffer)
7516 (set-buffer current-buffer)
7517 (gnus-summary-exit))
7518 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7519 ;; We try to enter the target group.
7520 (gnus-group-jump-to-group target-group)
7521 (let ((unreads (gnus-group-group-unread)))
7522 (if (and (or (eq t unreads)
7523 (and unreads (not (zerop unreads))))
7524 (gnus-summary-read-group
7525 target-group nil no-article
7526 (and (buffer-name current-buffer) current-buffer)
7529 (setq current-group target-group
7530 target-group nil)))))))
7532 (defun gnus-summary-prev-group (&optional no-article)
7533 "Exit current newsgroup and then select previous unread newsgroup.
7534 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7536 (gnus-summary-next-group no-article nil t))
7538 ;; Walking around summary lines.
7540 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7541 "Go to the first subject satisfying any non-nil constraint.
7542 If UNREAD is non-nil, the article should be unread.
7543 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7544 If UNSEEN is non-nil, the article should be unseen as well as unread.
7545 Returns the article selected or nil if there are no matching articles."
7549 ((null gnus-newsgroup-data)
7550 (gnus-message 3 "No articles in the group")
7552 ;; Pick the first article.
7553 ((not (or unread undownloaded unseen))
7554 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7555 (gnus-data-number (car gnus-newsgroup-data)))
7556 ;; Find the first unread article.
7558 (let ((data gnus-newsgroup-data))
7560 (let ((num (gnus-data-number (car data))))
7561 (or (memq num gnus-newsgroup-unfetched)
7562 (not (or (and unread
7563 (memq num gnus-newsgroup-unreads))
7565 (memq num gnus-newsgroup-undownloaded))
7567 (memq num gnus-newsgroup-unseen)
7568 (memq num gnus-newsgroup-unreads)))))))
7569 (setq data (cdr data)))
7573 (goto-char (gnus-data-pos (car data)))
7574 (gnus-data-number (car data)))
7575 (gnus-message 3 "No more%s articles"
7576 (let* ((r (when unread " unread"))
7577 (d (when undownloaded " undownloaded"))
7578 (s (when unseen " unseen"))
7579 (l (delq nil (list r d s))))
7580 (cond ((= 3 (length l))
7581 (concat r "," d ", or" s))
7583 (concat (car l) ", or" (cadr l)))
7590 (gnus-summary-position-point))))))
7592 (defun gnus-summary-next-subject (n &optional unread dont-display)
7593 "Go to next N'th summary line.
7594 If N is negative, go to the previous N'th subject line.
7595 If UNREAD is non-nil, only unread articles are selected.
7596 The difference between N and the actual number of steps taken is
7599 (let ((backward (< n 0))
7603 (gnus-summary-find-prev unread)
7604 (gnus-summary-find-next unread)))
7605 (unless (zerop (setq n (1- n)))
7606 (gnus-summary-show-thread)))
7608 (gnus-message 7 "No more%s articles"
7609 (if unread " unread" "")))
7610 (unless dont-display
7611 (gnus-summary-recenter)
7612 (gnus-summary-position-point))
7615 (defun gnus-summary-next-unread-subject (n)
7616 "Go to next N'th unread summary line."
7618 (gnus-summary-next-subject n t))
7620 (defun gnus-summary-prev-subject (n &optional unread)
7621 "Go to previous N'th summary line.
7622 If optional argument UNREAD is non-nil, only unread article is selected."
7624 (gnus-summary-next-subject (- n) unread))
7626 (defun gnus-summary-prev-unread-subject (n)
7627 "Go to previous N'th unread summary line."
7629 (gnus-summary-next-subject (- n) t))
7631 (defun gnus-summary-goto-subjects (articles)
7632 "Insert the subject header for ARTICLES in the current buffer."
7634 (dolist (article articles)
7635 (gnus-summary-goto-subject article t)))
7636 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7637 (gnus-summary-position-point))
7639 (defun gnus-summary-goto-subject (article &optional force silent)
7640 "Go to the subject line of ARTICLE.
7641 If FORCE, also allow jumping to articles not currently shown."
7642 (interactive "nArticle number: ")
7643 (unless (numberp article)
7644 (error "Article %s is not a number" article))
7646 (data (gnus-data-find article)))
7647 ;; We read in the article if we have to.
7650 (gnus-summary-insert-subject
7652 (if (or (numberp force) (vectorp force)) force)
7654 (setq data (gnus-data-find article)))
7659 (gnus-message 3 "Can't find article %d" article))
7661 (let ((pt (gnus-data-pos data)))
7663 (gnus-summary-set-article-display-arrow pt))
7664 (gnus-summary-position-point)
7667 ;; Walking around summary lines with displaying articles.
7669 (defun gnus-summary-expand-window (&optional arg)
7670 "Make the summary buffer take up the entire Emacs frame.
7671 Given a prefix, will force an `article' buffer configuration."
7674 (gnus-configure-windows 'article 'force)
7675 (gnus-configure-windows 'summary 'force)))
7677 (defun gnus-summary-display-article (article &optional all-header)
7678 "Display ARTICLE in article buffer."
7679 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7680 (with-current-buffer gnus-article-buffer
7681 (eq major-mode 'gnus-article-mode)))
7682 (gnus-article-setup-buffer))
7683 (gnus-set-global-variables)
7684 (with-current-buffer gnus-article-buffer
7685 (setq gnus-article-charset gnus-newsgroup-charset)
7686 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7687 (mm-enable-multibyte))
7691 (if gnus-summary-display-article-function
7692 (funcall gnus-summary-display-article-function article all-header)
7693 (gnus-article-prepare article all-header))
7694 (gnus-run-hooks 'gnus-select-article-hook)
7695 (when (and gnus-current-article
7696 (not (zerop gnus-current-article)))
7697 (gnus-summary-goto-subject gnus-current-article))
7698 (gnus-summary-recenter)
7699 (when (and gnus-use-trees gnus-show-threads)
7700 (gnus-possibly-generate-tree article)
7701 (gnus-highlight-selected-tree article))
7702 ;; Successfully display article.
7703 (gnus-article-set-window-start
7704 (cdr (assq article gnus-newsgroup-bookmarks))))))
7706 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7707 "Select the current article.
7708 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7709 non-nil, the article will be re-fetched even if it already present in
7710 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7712 ;; Make sure we are in the summary buffer to work around bbdb bug.
7713 (unless (eq major-mode 'gnus-summary-mode)
7714 (set-buffer gnus-summary-buffer))
7715 (let ((article (or article (gnus-summary-article-number)))
7716 (all-headers (not (not all-headers))) ;Must be t or nil.
7717 gnus-summary-display-article-function)
7719 (gnus-summary-article-pseudo-p article)
7720 (error "This is a pseudo-article"))
7721 (with-current-buffer gnus-summary-buffer
7722 (if (or (and gnus-single-article-buffer
7723 (or (null gnus-current-article)
7724 (null gnus-article-current)
7725 (null (get-buffer gnus-article-buffer))
7726 (not (eq article (cdr gnus-article-current)))
7727 (not (equal (car gnus-article-current)
7728 gnus-newsgroup-name))
7729 (not (get-buffer gnus-original-article-buffer))))
7730 (and (not gnus-single-article-buffer)
7731 (or (null gnus-current-article)
7732 (not (get-buffer gnus-original-article-buffer))
7733 (not (eq gnus-current-article article))))
7735 ;; The requested article is different from the current article.
7737 (gnus-summary-display-article article all-headers)
7738 (when (gnus-buffer-live-p gnus-article-buffer)
7739 (with-current-buffer gnus-article-buffer
7740 (if (not gnus-article-decoded-p) ;; a local variable
7741 (mm-disable-multibyte))))
7742 (gnus-article-set-window-start
7743 (cdr (assq article gnus-newsgroup-bookmarks)))
7747 (defun gnus-summary-force-verify-and-decrypt ()
7748 "Display buttons for signed/encrypted parts and verify/decrypt them."
7750 (let ((mm-verify-option 'known)
7751 (mm-decrypt-option 'known)
7752 (gnus-article-emulate-mime t)
7753 (gnus-buttonized-mime-types (append (list "multipart/signed"
7754 "multipart/encrypted")
7755 gnus-buttonized-mime-types)))
7756 (gnus-summary-select-article nil 'force)))
7758 (defun gnus-summary-set-current-mark (&optional current-mark)
7759 "Obsolete function."
7762 (defun gnus-summary-next-article (&optional unread subject backward push)
7763 "Select the next article.
7764 If UNREAD, only unread articles are selected.
7765 If SUBJECT, only articles with SUBJECT are selected.
7766 If BACKWARD, the previous article is selected instead of the next."
7768 ;; Make sure we are in the summary buffer.
7769 (unless (eq major-mode 'gnus-summary-mode)
7770 (set-buffer gnus-summary-buffer))
7772 ;; Is there such an article?
7773 ((and (gnus-summary-search-forward unread subject backward)
7774 (or (gnus-summary-display-article (gnus-summary-article-number))
7775 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7776 (gnus-summary-position-point))
7777 ;; If not, we try the first unread, if that is wanted.
7779 gnus-auto-select-same
7780 (gnus-summary-first-unread-article))
7781 (gnus-summary-position-point)
7782 (gnus-message 6 "Wrapped"))
7783 ;; Try to get next/previous article not displayed in this group.
7784 ((and gnus-auto-extend-newsgroup
7785 (not unread) (not subject))
7786 (gnus-summary-goto-article
7787 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7788 nil (count-lines (point-min) (point))))
7789 ;; Go to next/previous group.
7791 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7792 (gnus-summary-jump-to-group gnus-newsgroup-name))
7793 (let ((cmd (if (featurep 'xemacs)
7795 last-command-event))
7797 (with-current-buffer gnus-group-buffer
7799 (current-summary (current-buffer))
7801 (if (eq gnus-keep-same-level 'best)
7802 (gnus-summary-best-group gnus-newsgroup-name)
7803 (gnus-summary-search-group backward gnus-keep-same-level))))
7804 ;; Select next unread newsgroup automagically.
7806 ((or (not gnus-auto-select-next)
7808 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7809 ((or (eq gnus-auto-select-next 'quietly)
7810 (and (eq gnus-auto-select-next 'slightly-quietly)
7812 (and (eq gnus-auto-select-next 'almost-quietly)
7813 (gnus-summary-last-article-p)))
7815 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7817 (gnus-message 7 "No more%s articles (%s)..."
7818 (if unread " unread" "")
7819 (if group (concat "selecting " group)
7821 (gnus-summary-next-group nil group backward)))
7823 (when (gnus-key-press-event-p last-input-event)
7824 ;; Somehow or other, we may now have selected a different
7825 ;; window. Make point go back to the summary buffer.
7826 (when (eq current-summary (current-buffer))
7827 ;; FIXME: This burps when get-buffer-window returns nil.
7828 (select-window (get-buffer-window current-summary 0)))
7829 (gnus-summary-walk-group-buffer
7830 gnus-newsgroup-name cmd unread backward point))))))))
7832 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7833 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7834 (?\C-p (gnus-group-prev-unread-group 1))))
7835 (cursor-in-echo-area t)
7836 keve key group ended prompt)
7837 (with-current-buffer gnus-group-buffer
7840 (if (eq gnus-keep-same-level 'best)
7841 (gnus-summary-best-group gnus-newsgroup-name)
7842 (gnus-summary-search-group backward gnus-keep-same-level))))
7846 "No more%s articles%s " (if unread " unread" "")
7848 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7849 (format " (Type %s for %s [%s])"
7850 (single-key-description cmd)
7851 (gnus-group-decoded-name group)
7852 (gnus-group-unread group))
7853 (format " (Type %s to exit %s)"
7854 (single-key-description cmd)
7855 (gnus-group-decoded-name gnus-newsgroup-name)))))
7856 ;; Confirm auto selection.
7857 (setq key (car (setq keve (gnus-read-event-char prompt)))
7860 ((assq key keystrokes)
7861 (let ((obuf (current-buffer)))
7862 (switch-to-buffer gnus-group-buffer)
7864 (gnus-group-jump-to-group group))
7865 (eval (cadr (assq key keystrokes)))
7866 (setq group (gnus-group-group-name))
7867 (switch-to-buffer obuf))
7871 (gnus-ephemeral-group-p gnus-newsgroup-name))
7873 (gnus-summary-next-group nil group backward)))
7875 (push (cdr keve) unread-command-events))))))
7877 (defun gnus-summary-next-unread-article ()
7878 "Select unread article after current one."
7880 (gnus-summary-next-article
7881 (or (not (eq gnus-summary-goto-unread 'never))
7882 (gnus-summary-last-article-p (gnus-summary-article-number)))
7883 (and gnus-auto-select-same
7884 (gnus-summary-article-subject))))
7886 (defun gnus-summary-prev-article (&optional unread subject)
7887 "Select the article before the current one.
7888 If UNREAD is non-nil, only unread articles are selected."
7890 (gnus-summary-next-article unread subject t))
7892 (defun gnus-summary-prev-unread-article ()
7893 "Select unread article before current one."
7895 (gnus-summary-prev-article
7896 (or (not (eq gnus-summary-goto-unread 'never))
7897 (gnus-summary-first-article-p (gnus-summary-article-number)))
7898 (and gnus-auto-select-same
7899 (gnus-summary-article-subject))))
7901 (defun gnus-summary-next-page (&optional lines circular stop)
7902 "Show next page of the selected article.
7903 If at the end of the current article, select the next article.
7904 LINES says how many lines should be scrolled up.
7906 If CIRCULAR is non-nil, go to the start of the article instead of
7907 selecting the next article when reaching the end of the current
7910 If STOP is non-nil, just stop when reaching the end of the message.
7912 Also see the variable `gnus-article-skip-boring'."
7914 (setq gnus-summary-buffer (current-buffer))
7915 (gnus-set-global-variables)
7916 (let ((article (gnus-summary-article-number))
7917 (article-window (get-buffer-window gnus-article-buffer t))
7919 ;; If the buffer is empty, we have no article.
7921 (error "No article to select"))
7922 (gnus-configure-windows 'article)
7923 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7924 (if (and (eq gnus-summary-goto-unread 'never)
7925 (not (gnus-summary-last-article-p article)))
7926 (gnus-summary-next-article)
7927 (gnus-summary-next-unread-article))
7928 (if (or (null gnus-current-article)
7929 (null gnus-article-current)
7930 (/= article (cdr gnus-article-current))
7931 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7932 ;; Selected subject is different from current article's.
7933 (gnus-summary-display-article article)
7934 (when article-window
7935 (gnus-eval-in-buffer-window gnus-article-buffer
7936 (setq endp (or (gnus-article-next-page lines)
7937 (gnus-article-only-boring-p))))
7939 (cond ((or stop gnus-summary-stop-at-end-of-message)
7940 (gnus-message 3 "End of message"))
7942 (gnus-summary-beginning-of-article))
7944 (gnus-message 3 "End of message"))
7946 (if (and (eq gnus-summary-goto-unread 'never)
7947 (not (gnus-summary-last-article-p article)))
7948 (gnus-summary-next-article)
7949 (gnus-summary-next-unread-article))))))))
7950 (gnus-summary-recenter)
7951 (gnus-summary-position-point)))
7953 (defun gnus-summary-prev-page (&optional lines move)
7954 "Show previous page of selected article.
7955 Argument LINES specifies lines to be scrolled down.
7956 If MOVE, move to the previous unread article if point is at
7957 the beginning of the buffer."
7959 (let ((article (gnus-summary-article-number))
7960 (article-window (get-buffer-window gnus-article-buffer t))
7962 (gnus-configure-windows 'article)
7963 (if (or (null gnus-current-article)
7964 (null gnus-article-current)
7965 (/= article (cdr gnus-article-current))
7966 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7967 ;; Selected subject is different from current article's.
7968 (gnus-summary-display-article article)
7969 (gnus-summary-recenter)
7970 (when article-window
7971 (gnus-eval-in-buffer-window gnus-article-buffer
7972 (setq endp (gnus-article-prev-page lines)))
7973 (when (and move endp)
7975 (gnus-message 3 "Beginning of message"))
7977 (if (and (eq gnus-summary-goto-unread 'never)
7978 (not (gnus-summary-first-article-p article)))
7979 (gnus-summary-prev-article)
7980 (gnus-summary-prev-unread-article))))))))
7981 (gnus-summary-position-point))
7983 (defun gnus-summary-prev-page-or-article (&optional lines)
7984 "Show previous page of selected article.
7985 Argument LINES specifies lines to be scrolled down.
7986 If at the beginning of the article, go to the next article."
7988 (gnus-summary-prev-page lines t))
7990 (defun gnus-summary-scroll-up (lines)
7991 "Scroll up (or down) one line current article.
7992 Argument LINES specifies lines to be scrolled up (or down if negative).
7993 If no article is selected, then the current article will be selected first."
7995 (gnus-configure-windows 'article)
7996 (gnus-summary-show-thread)
7997 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7998 (gnus-eval-in-buffer-window gnus-article-buffer
8000 (when (gnus-article-next-page lines)
8001 (gnus-message 3 "End of message")))
8003 (gnus-article-prev-page (- lines))))))
8004 (gnus-summary-recenter)
8005 (gnus-summary-position-point))
8007 (defun gnus-summary-scroll-down (lines)
8008 "Scroll down (or up) one line current article.
8009 Argument LINES specifies lines to be scrolled down (or up if negative).
8010 If no article is selected, then the current article will be selected first."
8012 (gnus-summary-scroll-up (- lines)))
8014 (defun gnus-summary-next-same-subject ()
8015 "Select next article which has the same subject as current one."
8017 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8019 (defun gnus-summary-prev-same-subject ()
8020 "Select previous article which has the same subject as current one."
8022 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8024 (defun gnus-summary-next-unread-same-subject ()
8025 "Select next unread article which has the same subject as current one."
8027 (gnus-summary-next-article t (gnus-summary-article-subject)))
8029 (defun gnus-summary-prev-unread-same-subject ()
8030 "Select previous unread article which has the same subject as current one."
8032 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8034 (defun gnus-summary-first-unread-article ()
8035 "Select the first unread article.
8036 Return nil if there are no unread articles."
8039 (when (gnus-summary-first-subject t)
8040 (gnus-summary-show-thread)
8041 (gnus-summary-first-subject t)
8042 (gnus-summary-display-article (gnus-summary-article-number)))
8043 (gnus-summary-position-point)))
8045 (defun gnus-summary-first-unread-subject ()
8046 "Place the point on the subject line of the first unread article.
8047 Return nil if there are no unread articles."
8050 (when (gnus-summary-first-subject t)
8051 (gnus-summary-show-thread)
8052 (gnus-summary-first-subject t))
8053 (gnus-summary-position-point)))
8055 (defun gnus-summary-first-unseen-subject ()
8056 "Place the point on the subject line of the first unseen article.
8057 Return nil if there are no unseen articles."
8060 (when (gnus-summary-first-subject nil nil t)
8061 (gnus-summary-show-thread)
8062 (gnus-summary-first-subject nil nil t))
8063 (gnus-summary-position-point)))
8065 (defun gnus-summary-first-unseen-or-unread-subject ()
8066 "Place the point on the subject line of the first unseen and unread article.
8067 If all article have been seen, on the subject line of the first unread
8071 (unless (when (gnus-summary-first-subject nil nil t)
8072 (gnus-summary-show-thread)
8073 (gnus-summary-first-subject nil nil t))
8074 (when (gnus-summary-first-subject t)
8075 (gnus-summary-show-thread)
8076 (gnus-summary-first-subject t)))
8077 (gnus-summary-position-point)))
8079 (defun gnus-summary-first-article ()
8080 "Select the first article.
8081 Return nil if there are no articles."
8084 (when (gnus-summary-first-subject)
8085 (gnus-summary-show-thread)
8086 (gnus-summary-first-subject)
8087 (gnus-summary-display-article (gnus-summary-article-number)))
8088 (gnus-summary-position-point)))
8090 (defun gnus-summary-best-unread-article (&optional arg)
8091 "Select the unread article with the highest score.
8092 If given a prefix argument, select the next unread article that has a
8093 score higher than the default score."
8095 (let ((article (if arg
8096 (gnus-summary-better-unread-subject)
8097 (gnus-summary-best-unread-subject))))
8099 (gnus-summary-goto-article article)
8100 (error "No unread articles"))))
8102 (defun gnus-summary-best-unread-subject ()
8103 "Select the unread subject with the highest score."
8105 (let ((best -1000000)
8106 (data gnus-newsgroup-data)
8109 (and (gnus-data-unread-p (car data))
8111 (gnus-summary-article-score (gnus-data-number (car data))))
8114 article (gnus-data-number (car data))))
8115 (setq data (cdr data)))
8117 (gnus-summary-goto-subject article))
8118 (gnus-summary-position-point)
8121 (defun gnus-summary-better-unread-subject ()
8122 "Select the first unread subject that has a score over the default score."
8124 (let ((data gnus-newsgroup-data)
8126 (while (and (setq article (gnus-data-number (car data)))
8127 (or (gnus-data-read-p (car data))
8128 (not (> (gnus-summary-article-score article)
8129 gnus-summary-default-score))))
8130 (setq data (cdr data)))
8132 (gnus-summary-goto-subject article))
8133 (gnus-summary-position-point)
8136 (defun gnus-summary-last-subject ()
8137 "Go to the last displayed subject line in the group."
8138 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8140 (gnus-summary-goto-subject article))))
8142 (defun gnus-summary-goto-article (article &optional all-headers force)
8143 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8144 If ALL-HEADERS is non-nil, no header lines are hidden.
8145 If FORCE, go to the article even if it isn't displayed. If FORCE
8146 is a number, it is the line the article is to be displayed on."
8149 (gnus-completing-read
8150 "Article number or Message-ID"
8151 (mapcar 'int-to-string gnus-newsgroup-limit))
8155 (if (and (stringp article)
8156 (string-match "@\\|%40" article))
8157 (gnus-summary-refer-article article)
8158 (when (stringp article)
8159 (setq article (string-to-number article)))
8160 (if (gnus-summary-goto-subject article force)
8161 (gnus-summary-display-article article all-headers)
8162 (gnus-message 4 "Couldn't go to article %s" article) nil))
8163 (gnus-summary-position-point)))
8165 (defun gnus-summary-goto-last-article ()
8166 "Go to the previously read article."
8169 (when gnus-last-article
8170 (gnus-summary-goto-article gnus-last-article nil t))
8171 (gnus-summary-position-point)))
8173 (defun gnus-summary-pop-article (number)
8174 "Pop one article off the history and go to the previous.
8175 NUMBER articles will be popped off."
8178 (setq gnus-newsgroup-history
8179 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8181 (gnus-summary-goto-article (car to) nil t)
8182 (error "Article history empty")))
8183 (gnus-summary-position-point))
8185 ;; Summary commands and functions for limiting the summary buffer.
8187 (defun gnus-summary-limit-to-articles (n)
8188 "Limit the summary buffer to the next N articles.
8189 If not given a prefix, use the process marked articles instead."
8192 (let ((articles (gnus-summary-work-articles n)))
8193 (setq gnus-newsgroup-processable nil)
8194 (gnus-summary-limit articles))
8195 (gnus-summary-position-point)))
8197 (defun gnus-summary-pop-limit (&optional total)
8198 "Restore the previous limit.
8199 If given a prefix, remove all limits."
8202 (setq gnus-newsgroup-limits
8203 (list (mapcar (lambda (h) (mail-header-number h))
8204 gnus-newsgroup-headers))))
8205 (unless gnus-newsgroup-limits
8206 (error "No limit to pop"))
8208 (gnus-summary-limit nil 'pop)
8209 (gnus-summary-position-point)))
8211 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8212 "Limit the summary buffer to articles that have subjects that match a regexp.
8213 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8215 (list (read-string (if current-prefix-arg
8216 "Exclude subject (regexp): "
8217 "Limit to subject (regexp): "))
8218 nil current-prefix-arg))
8220 (setq header "subject"))
8221 (when (not (equal "" subject))
8223 (let ((articles (gnus-summary-find-matching
8224 (or header "subject") subject 'all nil nil
8227 (error "Found no matches for \"%s\"" subject))
8228 (gnus-summary-limit articles))
8229 (gnus-summary-position-point))))
8231 (defun gnus-summary-limit-to-author (from &optional not-matching)
8232 "Limit the summary buffer to articles that have authors that match a regexp.
8233 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8235 (list (read-string (if current-prefix-arg
8236 "Exclude author (regexp): "
8237 "Limit to author (regexp): "))
8238 current-prefix-arg))
8239 (gnus-summary-limit-to-subject from "from" not-matching))
8241 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8242 "Limit the summary buffer to articles with the given RECIPIENT.
8244 If NOT-MATCHING, exclude RECIPIENT.
8246 To and Cc headers are checked. You need to include them in
8247 `nnmail-extra-headers'."
8248 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8250 (list (read-string (format "%s recipient (regexp): "
8251 (if current-prefix-arg "Exclude" "Limit to")))
8252 current-prefix-arg))
8253 (when (not (equal "" recipient))
8255 (if (memq 'To nnmail-extra-headers)
8256 (gnus-summary-find-matching
8257 (cons 'extra 'To) recipient 'all nil nil
8260 1 "`To' isn't present in `nnmail-extra-headers'")
8264 (if (memq 'Cc nnmail-extra-headers)
8265 (gnus-summary-find-matching
8266 (cons 'extra 'Cc) recipient 'all nil nil
8269 1 "`Cc' isn't present in `nnmail-extra-headers'")
8274 ;; We need the numbers that are in both lists:
8276 (and (memq a to) a))
8280 (error "Found no matches for \"%s\"" recipient))
8281 (gnus-summary-limit articles))
8282 (gnus-summary-position-point))))
8284 (defun gnus-summary-limit-to-address (address &optional not-matching)
8285 "Limit the summary buffer to articles with the given ADDRESS.
8287 If NOT-MATCHING, exclude ADDRESS.
8289 To, Cc and From headers are checked. You need to include `To' and `Cc'
8290 in `nnmail-extra-headers'."
8292 (list (read-string (format "%s address (regexp): "
8293 (if current-prefix-arg "Exclude" "Limit to")))
8294 current-prefix-arg))
8295 (when (not (equal "" address))
8297 (if (memq 'To nnmail-extra-headers)
8298 (gnus-summary-find-matching
8299 (cons 'extra 'To) address 'all nil nil
8302 1 "`To' isn't present in `nnmail-extra-headers'")
8306 (if (memq 'Cc nnmail-extra-headers)
8307 (gnus-summary-find-matching
8308 (cons 'extra 'Cc) address 'all nil nil
8311 1 "`Cc' isn't present in `nnmail-extra-headers'")
8315 (gnus-summary-find-matching "from" address
8316 'all nil nil not-matching))
8319 ;; We need the numbers that are in all lists:
8323 (mapcar (lambda (a) (car (memq a from))) to))
8325 (mapcar (lambda (a) (car (memq a from))) cc)
8326 (mapcar (lambda (a) (car (memq a from)))
8327 (mapcar (lambda (a) (car (memq a to)))
8329 (nconc (if (eq to t) nil to)
8330 (if (eq cc t) nil cc)
8333 (error "Found no matches for \"%s\"" address))
8334 (gnus-summary-limit articles))
8335 (gnus-summary-position-point))))
8337 (defun gnus-summary-limit-strange-charsets-predicate (header)
8338 (when (fboundp 'char-charset)
8339 (let ((string (concat (mail-header-subject header)
8340 (mail-header-from header)))
8342 (dotimes (i (1- (length string)))
8343 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8344 (when (string-match "unicode\\|big\\|japanese" charset)
8348 (defun gnus-summary-limit-to-predicate (predicate)
8349 "Limit to articles where PREDICATE returns non-nil.
8350 PREDICATE will be called with the header structures of the
8352 (let ((articles nil)
8353 (case-fold-search t))
8354 (dolist (header gnus-newsgroup-headers)
8355 (when (funcall predicate header)
8356 (push (mail-header-number header) articles)))
8357 (gnus-summary-limit (nreverse articles))))
8359 (defun gnus-summary-limit-to-age (age &optional younger-p)
8360 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8361 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8362 articles that are younger than AGE days."
8364 (let ((younger current-prefix-arg)
8367 (while (not days-got)
8368 (setq days (if younger
8369 (read-string "Limit to articles younger than (in days, older when negative): ")
8371 "Limit to articles older than (in days, younger when negative): ")))
8372 (when (> (length days) 0)
8373 (setq days (read days)))
8378 (setq younger (not younger))
8379 (setq days (* days -1))))
8380 (message "Please enter a number.")
8382 (list days younger)))
8384 (let ((data gnus-newsgroup-data)
8385 (cutoff (days-to-time age))
8386 articles d date is-younger)
8387 (while (setq d (pop data))
8388 (when (and (vectorp (gnus-data-header d))
8389 (setq date (mail-header-date (gnus-data-header d))))
8390 (setq is-younger (time-less-p
8391 (time-since (gnus-date-get-time date))
8396 (push (gnus-data-number d) articles))))
8397 (gnus-summary-limit (nreverse articles)))
8398 (gnus-summary-position-point)))
8400 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8401 "Limit the summary buffer to articles that match an 'extra' header."
8405 (gnus-completing-read
8406 (if current-prefix-arg
8407 "Exclude extra header"
8408 "Limit extra header")
8409 (mapcar 'symbol-name gnus-extra-headers)
8411 (symbol-name (car gnus-extra-headers))))))
8413 (read-string (format "%s header %s (regexp): "
8414 (if current-prefix-arg "Exclude" "Limit to")
8416 current-prefix-arg)))
8417 (when (not (equal "" regexp))
8419 (let ((articles (gnus-summary-find-matching
8420 (cons 'extra header) regexp 'all nil nil
8423 (error "Found no matches for \"%s\"" regexp))
8424 (gnus-summary-limit articles))
8425 (gnus-summary-position-point))))
8427 (defun gnus-summary-limit-to-display-predicate ()
8428 "Limit the summary buffer to the predicated in the `display' group parameter."
8430 (unless gnus-newsgroup-display
8431 (error "There is no `display' group parameter"))
8433 (dolist (gnus-number gnus-newsgroup-articles)
8434 (when (funcall gnus-newsgroup-display)
8435 (push gnus-number articles)))
8436 (gnus-summary-limit articles))
8437 (gnus-summary-position-point))
8439 (defun gnus-summary-limit-to-unread (&optional all)
8440 "Limit the summary buffer to articles that are not marked as read.
8441 If ALL is non-nil, limit strictly to unread articles."
8444 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8445 (gnus-summary-limit-to-marks
8446 ;; Concat all the marks that say that an article is read and have
8448 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8449 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8450 gnus-low-score-mark gnus-expirable-mark
8451 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8452 gnus-duplicate-mark)
8455 (defun gnus-summary-limit-to-headers (match &optional reverse)
8456 "Limit the summary buffer to articles that have headers that match MATCH.
8457 If REVERSE (the prefix), limit to articles that don't match."
8458 (interactive "sMatch headers (regexp): \nP")
8459 (gnus-summary-limit-to-bodies match reverse t))
8461 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8462 "Limit the summary buffer to articles that have bodies that match MATCH.
8463 If REVERSE (the prefix), limit to articles that don't match."
8464 (interactive "sMatch body (regexp): \nP")
8465 (let ((articles nil)
8466 (gnus-select-article-hook nil) ;Disable hook.
8467 (gnus-article-prepare-hook nil)
8468 (gnus-use-article-prefetch nil)
8469 (gnus-keep-backlog nil)
8470 (gnus-break-pages nil)
8471 (gnus-summary-display-arrow nil)
8472 (gnus-updated-mode-lines nil)
8473 (gnus-auto-center-summary nil)
8474 (gnus-display-mime-function nil))
8475 (dolist (data gnus-newsgroup-data)
8476 (let (gnus-mark-article-hook)
8477 (gnus-summary-select-article t t nil (gnus-data-number data)))
8478 (with-current-buffer gnus-article-buffer
8480 (let* ((case-fold-search t)
8482 (re-search-backward match nil t)
8483 (re-search-forward match nil t))))
8484 (when (or (and found
8488 (push (gnus-data-number data) articles)))))
8490 (message "No messages matched")
8491 (gnus-summary-limit articles)))
8492 (gnus-summary-position-point))
8494 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8495 "Limit the summary buffer to articles that aren't part on any thread.
8496 If THREADSP (the prefix), limit to articles that are in threads."
8498 (let ((articles nil)
8501 (dolist (thread gnus-newsgroup-threads)
8502 (if (stringp (car thread))
8503 (dolist (thread (cdr thread))
8504 (push thread threads))
8505 (push thread threads)))
8506 (dolist (thread threads)
8507 (setq thread-articles (gnus-articles-in-thread thread))
8508 (when (or (and threadsp
8509 (> (length thread-articles) 1))
8511 (= (length thread-articles) 1)))
8512 (setq articles (nconc thread-articles articles))))
8514 (message "No messages matched")
8515 (gnus-summary-limit articles))
8516 (gnus-summary-position-point)))
8518 (defun gnus-summary-limit-to-replied (&optional unreplied)
8519 "Limit the summary buffer to replied articles.
8520 If UNREPLIED (the prefix), limit to unreplied articles."
8524 (gnus-set-difference gnus-newsgroup-articles
8525 gnus-newsgroup-replied))
8526 (gnus-summary-limit gnus-newsgroup-replied))
8527 (gnus-summary-position-point))
8529 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8530 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8531 If REVERSE, limit the summary buffer to articles that are marked
8532 with MARKS. MARKS can either be a string of marks or a list of marks.
8533 Returns how many articles were removed."
8534 (interactive "sMarks: ")
8535 (gnus-summary-limit-to-marks marks t))
8537 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8538 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8539 If REVERSE (the prefix), limit the summary buffer to articles that are
8540 not marked with MARKS. MARKS can either be a string of marks or a
8542 Returns how many articles were removed."
8543 (interactive "sMarks: \nP")
8545 (let ((data gnus-newsgroup-data)
8546 (marks (if (listp marks) marks
8547 (append marks nil))) ; Transform to list.
8550 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8551 (memq (gnus-data-mark (car data)) marks))
8552 (push (gnus-data-number (car data)) articles))
8553 (setq data (cdr data)))
8554 (gnus-summary-limit articles))
8555 (gnus-summary-position-point)))
8557 (defun gnus-summary-limit-to-score (score)
8558 "Limit to articles with score at or above SCORE."
8559 (interactive "NLimit to articles with score of at least: ")
8560 (let ((data gnus-newsgroup-data)
8563 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8565 (push (gnus-data-number (car data)) articles))
8566 (setq data (cdr data)))
8568 (gnus-summary-limit articles)
8569 (gnus-summary-position-point))))
8571 (defun gnus-summary-limit-to-unseen ()
8572 "Limit to unseen articles."
8575 (gnus-summary-limit gnus-newsgroup-unseen)
8576 (gnus-summary-position-point)))
8578 (defun gnus-summary-limit-include-thread (id)
8579 "Display all the hidden articles that is in the thread with ID in it.
8580 When called interactively, ID is the Message-ID of the current
8582 (interactive (list (mail-header-id (gnus-summary-article-header))))
8583 (let ((articles (gnus-articles-in-thread
8584 (gnus-id-to-thread (gnus-root-id id))))
8585 ;;we REALLY want the whole thread---this prevents cut-threads
8586 ;;from removing the thread we want to include.
8587 (gnus-fetch-old-headers nil)
8588 (gnus-build-sparse-threads nil))
8590 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8591 (gnus-summary-limit-include-matching-articles
8593 (regexp-quote (gnus-simplify-subject-re
8594 (mail-header-subject (gnus-id-to-header id)))))
8595 (gnus-summary-position-point))))
8597 (defun gnus-summary-limit-include-matching-articles (header regexp)
8598 "Display all the hidden articles that have HEADERs that match REGEXP."
8599 (interactive (list (read-string "Match on header: ")
8600 (read-string "Regexp: ")))
8601 (let ((articles (gnus-find-matching-articles header regexp)))
8603 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8604 (gnus-summary-position-point))))
8606 (defun gnus-summary-insert-dormant-articles ()
8607 "Insert all the dormant articles for this group into the current buffer."
8609 (let ((gnus-verbose (max 6 gnus-verbose)))
8610 (if (not gnus-newsgroup-dormant)
8611 (gnus-message 3 "No dormant articles for this group")
8612 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8614 (defun gnus-summary-insert-ticked-articles ()
8615 "Insert ticked articles for this group into the current buffer."
8617 (let ((gnus-verbose (max 6 gnus-verbose)))
8618 (if (not gnus-newsgroup-marked)
8619 (gnus-message 3 "No ticked articles for this group")
8620 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8622 (defun gnus-summary-limit-include-dormant ()
8623 "Display all the hidden articles that are marked as dormant.
8624 Note that this command only works on a subset of the articles currently
8625 fetched for this group."
8627 (unless gnus-newsgroup-dormant
8628 (error "There are no dormant articles in this group"))
8630 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8631 (gnus-summary-position-point)))
8633 (defun gnus-summary-include-articles (articles)
8634 "Fetch the headers for ARTICLES and then display the summary lines."
8635 (let ((gnus-inhibit-demon t)
8637 (gnus-read-all-available-headers t))
8638 (setq gnus-newsgroup-headers
8640 'list gnus-newsgroup-headers
8641 (gnus-fetch-headers articles nil t)
8642 'gnus-article-sort-by-number))
8643 (setq gnus-newsgroup-articles
8644 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8645 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8647 (defun gnus-summary-limit-exclude-dormant ()
8648 "Hide all dormant articles."
8651 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8652 (gnus-summary-position-point)))
8654 (defun gnus-summary-limit-exclude-childless-dormant ()
8655 "Hide all dormant articles that have no children."
8657 (let ((data (gnus-data-list t))
8658 articles d children)
8659 ;; Find all articles that are either not dormant or have
8661 (while (setq d (pop data))
8662 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8664 (gnus-article-children (gnus-data-number d)))
8667 (when (memq (car children) articles)
8672 (push (gnus-data-number d) articles)))
8675 (gnus-summary-limit articles)
8676 (gnus-summary-position-point))))
8678 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8679 "Mark all unread excluded articles as read.
8680 If ALL, mark even excluded ticked and dormants as read."
8682 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8683 (let ((articles (gnus-sorted-ndifference
8685 (mapcar (lambda (h) (mail-header-number h))
8686 gnus-newsgroup-headers)
8688 gnus-newsgroup-limit))
8690 (setq gnus-newsgroup-unreads
8691 (gnus-sorted-intersection gnus-newsgroup-unreads
8692 gnus-newsgroup-limit))
8694 (setq gnus-newsgroup-dormant nil
8695 gnus-newsgroup-marked nil
8696 gnus-newsgroup-reads
8698 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8699 gnus-newsgroup-reads))
8700 (while (setq article (pop articles))
8701 (unless (or (memq article gnus-newsgroup-dormant)
8702 (memq article gnus-newsgroup-marked))
8703 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8705 (defun gnus-summary-limit (articles &optional pop)
8707 ;; We pop the previous limit off the stack and use that.
8708 (setq articles (car gnus-newsgroup-limits)
8709 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8710 ;; We use the new limit, so we push the old limit on the stack.
8711 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8713 (setq gnus-newsgroup-limit articles)
8714 (let ((total (length gnus-newsgroup-data))
8715 (data (gnus-data-find-list (gnus-summary-article-number)))
8716 (gnus-summary-mark-below nil) ; Inhibit this.
8718 ;; This will do all the work of generating the new summary buffer
8719 ;; according to the new limit.
8720 (gnus-summary-prepare)
8721 ;; Hide any threads, possibly.
8722 (gnus-summary-maybe-hide-threads)
8723 ;; Try to return to the article you were at, or one in the
8726 ;; We try to find some article after the current one.
8728 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8731 (setq data (cdr data))))
8733 ;; If there is no data, that means that we were after the last
8734 ;; article. The same goes when we can't find any articles
8735 ;; after the current one.
8736 (goto-char (point-max))
8737 (gnus-summary-find-prev))
8738 (gnus-set-mode-line 'summary)
8739 ;; We return how many articles were removed from the summary
8740 ;; buffer as a result of the new limit.
8741 (- total (length gnus-newsgroup-data))))
8743 (defsubst gnus-invisible-cut-children (threads)
8746 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8751 (defsubst gnus-cut-thread (thread)
8752 "Go forwards in the thread until we find an article that we want to display."
8753 (when (or (eq gnus-fetch-old-headers 'some)
8754 (eq gnus-fetch-old-headers 'invisible)
8755 (numberp gnus-fetch-old-headers)
8756 (eq gnus-build-sparse-threads 'some)
8757 (eq gnus-build-sparse-threads 'more))
8758 ;; Deal with old-fetched headers and sparse threads.
8762 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8763 (gnus-summary-article-ancient-p
8764 (mail-header-number (car thread))))
8765 (if (or (<= (length (cdr thread)) 1)
8766 (eq gnus-fetch-old-headers 'invisible))
8767 (setq gnus-newsgroup-limit
8768 (delq (mail-header-number (car thread))
8769 gnus-newsgroup-limit)
8770 thread (cadr thread))
8771 (when (gnus-invisible-cut-children (cdr thread))
8772 (let ((th (cdr thread)))
8774 (if (memq (mail-header-number (caar th))
8775 gnus-newsgroup-limit)
8776 (setq thread (car th)
8778 (setq th (cdr th))))))))))
8781 (defun gnus-cut-threads (threads)
8782 "Cut off all uninteresting articles from the beginning of THREADS."
8783 (when (or (eq gnus-fetch-old-headers 'some)
8784 (eq gnus-fetch-old-headers 'invisible)
8785 (numberp gnus-fetch-old-headers)
8786 (eq gnus-build-sparse-threads 'some)
8787 (eq gnus-build-sparse-threads 'more))
8790 (setcar th (gnus-cut-thread (car th)))
8791 (setq th (cdr th)))))
8792 ;; Remove nixed out threads.
8795 (defun gnus-summary-initial-limit (&optional show-if-empty)
8796 "Figure out what the initial limit is supposed to be on group entry.
8797 This entails weeding out unwanted dormants, low-scored articles,
8798 fetch-old-headers verbiage, and so on."
8799 ;; Most groups have nothing to remove.
8800 (unless (or gnus-inhibit-limiting
8801 (and (null gnus-newsgroup-dormant)
8802 (eq gnus-newsgroup-display 'gnus-not-ignore)
8803 (not (eq gnus-fetch-old-headers 'some))
8804 (not (numberp gnus-fetch-old-headers))
8805 (not (eq gnus-fetch-old-headers 'invisible))
8806 (null gnus-summary-expunge-below)
8807 (not (eq gnus-build-sparse-threads 'some))
8808 (not (eq gnus-build-sparse-threads 'more))
8809 (null gnus-thread-expunge-below)))
8810 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8811 (setq gnus-newsgroup-limit nil)
8814 (unless (car (symbol-value node))
8815 ;; These threads have no parents -- they are roots.
8816 (let ((nodes (cdr (symbol-value node)))
8819 (if (and gnus-thread-expunge-below
8820 (< (gnus-thread-total-score (car nodes))
8821 gnus-thread-expunge-below))
8822 (gnus-expunge-thread (pop nodes))
8823 (setq thread (pop nodes))
8824 (gnus-summary-limit-children thread))))))
8825 gnus-newsgroup-dependencies)
8826 ;; If this limitation resulted in an empty group, we might
8827 ;; pop the previous limit and use it instead.
8828 (when (and (not gnus-newsgroup-limit)
8830 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8831 gnus-newsgroup-limit))
8833 (defun gnus-summary-limit-children (thread)
8834 "Return 1 if this subthread is visible and 0 if it is not."
8835 ;; First we get the number of visible children to this thread. This
8836 ;; is done by recursing down the thread using this function, so this
8837 ;; will really go down to a leaf article first, before slowly
8838 ;; working its way up towards the root.
8840 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8843 (apply '+ (mapcar 'gnus-summary-limit-children
8846 (number (mail-header-number (car thread)))
8849 (not (memq number gnus-newsgroup-marked))
8851 ;; If this article is dormant and has absolutely no visible
8852 ;; children, then this article isn't visible.
8853 (and (memq number gnus-newsgroup-dormant)
8855 ;; If this is "fetch-old-headered" and there is no
8856 ;; visible children, then we don't want this article.
8857 (and (or (eq gnus-fetch-old-headers 'some)
8858 (numberp gnus-fetch-old-headers))
8859 (gnus-summary-article-ancient-p number)
8861 ;; If this is "fetch-old-headered" and `invisible', then
8862 ;; we don't want this article.
8863 (and (eq gnus-fetch-old-headers 'invisible)
8864 (gnus-summary-article-ancient-p number))
8865 ;; If this is a sparsely inserted article with no children,
8866 ;; we don't want it.
8867 (and (eq gnus-build-sparse-threads 'some)
8868 (gnus-summary-article-sparse-p number)
8870 ;; If we use expunging, and this article is really
8871 ;; low-scored, then we don't want this article.
8872 (when (and gnus-summary-expunge-below
8874 (or (cdr (assq number gnus-newsgroup-scored))
8875 gnus-summary-default-score))
8876 gnus-summary-expunge-below))
8877 ;; We increase the expunge-tally here, but that has
8878 ;; nothing to do with the limits, really.
8879 (incf gnus-newsgroup-expunged-tally)
8880 ;; We also mark as read here, if that's wanted.
8881 (when (and gnus-summary-mark-below
8882 (< score gnus-summary-mark-below))
8883 (setq gnus-newsgroup-unreads
8884 (delq number gnus-newsgroup-unreads))
8885 (if gnus-newsgroup-auto-expire
8886 (push number gnus-newsgroup-expirable)
8887 (push (cons number gnus-low-score-mark)
8888 gnus-newsgroup-reads)))
8890 ;; Do the `display' group parameter.
8891 (and gnus-newsgroup-display
8892 (let ((gnus-number number))
8893 (not (funcall gnus-newsgroup-display))))))
8894 ;; Nope, invisible article.
8896 ;; Ok, this article is to be visible, so we add it to the limit
8898 (push number gnus-newsgroup-limit)
8901 (defun gnus-expunge-thread (thread)
8902 "Mark all articles in THREAD as read."
8903 (let* ((number (mail-header-number (car thread))))
8904 (incf gnus-newsgroup-expunged-tally)
8905 ;; We also mark as read here, if that's wanted.
8906 (setq gnus-newsgroup-unreads
8907 (delq number gnus-newsgroup-unreads))
8908 (if gnus-newsgroup-auto-expire
8909 (push number gnus-newsgroup-expirable)
8910 (push (cons number gnus-low-score-mark)
8911 gnus-newsgroup-reads)))
8912 ;; Go recursively through all subthreads.
8913 (mapcar 'gnus-expunge-thread (cdr thread)))
8915 ;; Summary article oriented commands
8917 (defun gnus-summary-refer-parent-article (n)
8918 "Refer parent article N times.
8919 If N is negative, go to ancestor -N instead.
8920 The difference between N and the number of articles fetched is returned."
8924 (when (not (natnump n))
8929 (setq header (gnus-summary-article-header))
8930 (if (and (eq (mail-header-number header)
8931 (cdr gnus-article-current))
8932 (equal gnus-newsgroup-name
8933 (car gnus-article-current)))
8934 ;; If we try to find the parent of the currently
8935 ;; displayed article, then we take a look at the actual
8936 ;; References header, since this is slightly more
8937 ;; reliable than the References field we got from the
8939 (with-current-buffer gnus-original-article-buffer
8940 (nnheader-narrow-to-headers)
8941 (unless (setq ref (message-fetch-field "references"))
8942 (when (setq ref (message-fetch-field "in-reply-to"))
8943 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8946 ;; It's not the current article, so we take a bet on
8947 ;; the value we got from the server.
8948 (mail-header-references header)))
8950 (not (equal ref "")))
8951 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8952 (gnus-message 1 "Couldn't find parent"))
8953 (gnus-message 1 "No references in article %d"
8954 (gnus-summary-article-number))
8957 (gnus-summary-position-point)
8960 (defun gnus-summary-refer-references ()
8961 "Fetch all articles mentioned in the References header.
8962 Return the number of articles fetched."
8964 (let ((ref (mail-header-references (gnus-summary-article-header)))
8965 (current (gnus-summary-article-number))
8969 (error "No References in the current article")
8970 ;; For each Message-ID in the References header...
8971 (while (string-match "<[^>]*>" ref)
8973 ;; ... fetch that article.
8974 (gnus-summary-refer-article
8975 (prog1 (match-string 0 ref)
8976 (setq ref (substring ref (match-end 0))))))
8977 (gnus-summary-goto-subject current)
8978 (gnus-summary-position-point)
8981 (defun gnus-delete-duplicate-headers (headers)
8982 ;; First remove leading duplicates.
8983 (while (and (> (length headers) 1)
8984 (= (mail-header-number (car headers))
8985 (mail-header-number (cadr headers))))
8988 (let ((result headers))
8989 (while (> (length headers) 1)
8990 (if (= (mail-header-number (car headers))
8991 (mail-header-number (cadr headers)))
8992 (setcdr headers (cddr headers))
8996 (defun gnus-summary-refer-thread (&optional limit)
8997 "Fetch all articles in the current thread. For backends that
8998 know how to search for threads (currently only 'nnimap) a
8999 non-numeric prefix arg will use nnir to search the entire
9000 server; without a prefix arg only the current group is
9001 searched. If the variable `gnus-refer-thread-use-nnir' is
9002 non-nil the prefix arg has the reverse meaning. If no
9003 backend-specific 'request-thread function is available fetch
9004 LIMIT (the numerical prefix) old headers. If LIMIT is
9005 non-numeric or nil fetch the number specified by the
9006 `gnus-refer-thread-limit' variable."
9008 (gnus-warp-to-article)
9009 (let* ((header (gnus-summary-article-header))
9010 (id (mail-header-id header))
9011 (gnus-inhibit-demon t)
9012 (gnus-summary-ignore-duplicates t)
9013 (gnus-read-all-available-headers t)
9014 (gnus-refer-thread-use-nnir
9015 (if (and (not (null limit)) (listp limit))
9016 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9018 (if (gnus-check-backend-function
9019 'request-thread gnus-newsgroup-name)
9020 (gnus-request-thread header gnus-newsgroup-name)
9021 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9022 gnus-refer-thread-limit))
9023 (last (if (numberp limit)
9024 (min (+ (mail-header-number header)
9026 gnus-newsgroup-highest)
9027 gnus-newsgroup-highest))
9028 (subject (gnus-simplify-subject
9029 (mail-header-subject header)))
9030 (refs (split-string (or (mail-header-references header)
9032 (gnus-parse-headers-hook
9033 `(lambda () (goto-char (point-min))
9035 (regexp-opt ',(append refs (list id subject)))))))
9036 (gnus-fetch-headers (list last) (if (numberp limit)
9037 (* 2 limit) limit) t))))
9039 (when (listp new-headers)
9040 (dolist (header new-headers)
9041 (push (mail-header-number header) article-ids)
9042 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9043 (push (mail-header-number header) gnus-newsgroup-unreads)
9044 (setq gnus-newsgroup-unselected
9045 (delete (mail-header-number header)
9046 gnus-newsgroup-unselected))))
9047 (setq gnus-newsgroup-headers
9048 (gnus-delete-duplicate-headers
9050 'list gnus-newsgroup-headers new-headers
9051 'gnus-article-sort-by-number)))
9052 (setq gnus-newsgroup-articles
9053 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9054 (gnus-summary-limit-include-thread id)))
9055 (gnus-summary-show-thread))
9057 (defun gnus-summary-refer-article (message-id)
9058 "Fetch an article specified by MESSAGE-ID."
9059 (interactive "sMessage-ID: ")
9060 (gnus-warp-to-article)
9061 (when (and (stringp message-id)
9062 (not (zerop (length message-id))))
9063 (setq message-id (gnus-replace-in-string message-id " " ""))
9064 ;; Construct the correct Message-ID if necessary.
9065 ;; Suggested by tale@pawl.rpi.edu.
9066 (unless (string-match "^<" message-id)
9067 (setq message-id (concat "<" message-id)))
9068 (unless (string-match ">$" message-id)
9069 (setq message-id (concat message-id ">")))
9070 ;; People often post MIDs from URLs, so unhex it:
9071 (unless (string-match "@" message-id)
9072 (setq message-id (gnus-url-unhex-string message-id)))
9073 (let* ((header (gnus-id-to-header message-id))
9075 (gnus-summary-article-sparse-p
9076 (mail-header-number header))
9077 (memq (mail-header-number header)
9078 gnus-newsgroup-limit)))
9081 ;; If the article is present in the buffer we just go to it.
9083 (or (not (gnus-summary-article-sparse-p
9084 (mail-header-number header)))
9087 (gnus-summary-goto-article
9088 (mail-header-number header) nil t)
9090 (gnus-summary-update-article (mail-header-number header)))))
9092 ;; We fetch the article.
9094 (dolist (gnus-override-method (gnus-refer-article-methods))
9095 (when (and (gnus-check-server gnus-override-method)
9096 ;; Fetch the header,
9097 (setq number (gnus-summary-insert-subject message-id)))
9098 ;; and display the article.
9099 (gnus-summary-select-article nil nil nil number)
9101 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9103 (defun gnus-refer-article-methods ()
9104 "Return a list of referable methods."
9106 ;; No method, so we default to current and native.
9107 ((null gnus-refer-article-method)
9108 (list gnus-current-select-method gnus-select-method))
9110 ((eq 'current gnus-refer-article-method)
9111 (list gnus-current-select-method))
9112 ;; List of select methods.
9113 ((not (and (symbolp (car gnus-refer-article-method))
9114 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9116 (dolist (method gnus-refer-article-method)
9117 (push (if (eq 'current method)
9118 gnus-current-select-method
9119 (if (eq 'nnir (car method))
9123 (gnus-method-to-server gnus-current-select-method)))
9127 ;; One single select method.
9129 (list gnus-refer-article-method))))
9131 (defun gnus-summary-edit-parameters ()
9132 "Edit the group parameters of the current group."
9134 (gnus-group-edit-group gnus-newsgroup-name 'params))
9136 (defun gnus-summary-customize-parameters ()
9137 "Customize the group parameters of the current group."
9139 (gnus-group-customize gnus-newsgroup-name))
9141 (defun gnus-summary-enter-digest-group (&optional force)
9142 "Enter an nndoc group based on the current article.
9143 If FORCE, force a digest interpretation. If not, try to guess
9144 what the document format is.
9146 To control what happens when you exit the group, see the
9147 `gnus-auto-select-on-ephemeral-exit' variable."
9149 (let ((conf gnus-current-window-configuration))
9150 (save-window-excursion
9152 (let (gnus-article-prepare-hook
9153 gnus-display-mime-function
9155 (gnus-summary-select-article))))
9156 (setq gnus-current-window-configuration conf)
9157 (let* ((name (format "%s-%d"
9158 (gnus-group-prefixed-name
9159 gnus-newsgroup-name (list 'nndoc ""))
9160 (with-current-buffer gnus-summary-buffer
9161 gnus-current-article)))
9162 (ogroup gnus-newsgroup-name)
9163 (params (append (gnus-info-params (gnus-get-info ogroup))
9164 (list (cons 'to-group ogroup))
9165 (list (cons 'parent-group ogroup))
9166 (list (cons 'save-article-group ogroup))))
9167 (case-fold-search t)
9168 (buf (current-buffer))
9170 (with-current-buffer gnus-original-article-buffer
9171 ;; Have the digest group inherit the main mail address of
9172 ;; the parent article.
9173 (when (setq to-address (or (gnus-fetch-field "reply-to")
9174 (gnus-fetch-field "from")))
9177 (list (cons 'to-address
9178 (funcall gnus-decode-encoded-address-function
9180 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9181 (insert-buffer-substring gnus-original-article-buffer)
9182 ;; Remove lines that may lead nndoc to misinterpret the
9185 (goto-char (point-min))
9186 (or (search-forward "\n\n" nil t) (point)))
9187 (goto-char (point-min))
9188 (delete-matching-lines "^Path:\\|^From ")
9191 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
9192 (gnus-newsgroup-ephemeral-ignored-charsets
9193 gnus-newsgroup-ignored-charsets))
9194 (gnus-group-read-ephemeral-group
9195 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9197 ,(if force 'mbox 'guess)))
9199 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9201 ;; Make all postings to this group go to the parent group.
9202 (nconc (gnus-info-params (gnus-get-info name))
9204 ;; Couldn't select this doc group.
9205 (switch-to-buffer buf)
9206 (gnus-set-global-variables)
9207 (gnus-configure-windows 'summary)
9208 (gnus-message 3 "Article couldn't be entered?"))
9209 (kill-buffer dig)))))
9211 (defun gnus-summary-read-document (n)
9212 "Open a new group based on the current article(s).
9213 This will allow you to read digests and other similar
9214 documents as newsgroups.
9215 Obeys the standard process/prefix convention."
9217 (let* ((ogroup gnus-newsgroup-name)
9218 (params (append (gnus-info-params (gnus-get-info ogroup))
9219 (list (cons 'to-group ogroup))))
9220 group egroup groups vgroup)
9221 (dolist (article (gnus-summary-work-articles n))
9222 (setq group (format "%s-%d" gnus-newsgroup-name article))
9223 (gnus-summary-remove-process-mark article)
9224 (when (gnus-summary-display-article article)
9225 (save-excursion ;;What for?
9227 (insert-buffer-substring gnus-original-article-buffer)
9228 ;; Remove some headers that may lead nndoc to make
9230 (message-narrow-to-head)
9231 (goto-char (point-min))
9232 (delete-matching-lines "^Path:\\|^From ")
9235 (gnus-group-read-ephemeral-group
9236 group `(nndoc ,group (nndoc-address ,(current-buffer))
9237 (nndoc-article-type guess))
9240 ;; Make all postings to this group go to the parent group.
9241 (nconc (gnus-info-params (gnus-get-info egroup))
9243 (push egroup groups))
9244 ;; Couldn't select this doc group.
9245 (gnus-error 3 "Article couldn't be entered"))))))
9246 ;; Now we have selected all the documents.
9249 (error "None of the articles could be interpreted as documents"))
9250 ((gnus-group-read-ephemeral-group
9251 (setq vgroup (format
9252 "nnvirtual:%s-%s" gnus-newsgroup-name
9253 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9254 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9256 (cons (current-buffer) 'summary)))
9258 (error "Couldn't select virtual nndoc group")))))
9260 (defun gnus-summary-widget-forward (arg)
9261 "Move point to the next field or button in the article.
9262 With optional ARG, move across that many fields."
9264 (gnus-summary-select-article)
9265 (gnus-configure-windows 'article)
9266 (select-window (gnus-get-buffer-window gnus-article-buffer))
9267 (widget-forward arg))
9269 (defun gnus-summary-widget-backward (arg)
9270 "Move point to the previous field or button in the article.
9271 With optional ARG, move across that many fields."
9273 (gnus-summary-select-article)
9274 (gnus-configure-windows 'article)
9275 (select-window (gnus-get-buffer-window gnus-article-buffer))
9276 (unless (widget-at (point))
9277 (goto-char (point-max)))
9278 (widget-backward arg))
9280 (defun gnus-summary-isearch-article (&optional regexp-p)
9281 "Do incremental search forward on the current article.
9282 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9284 (gnus-summary-select-article)
9285 (gnus-configure-windows 'article)
9286 (gnus-eval-in-buffer-window gnus-article-buffer
9289 (isearch-forward regexp-p))))
9291 (defun gnus-summary-repeat-search-article-forward ()
9292 "Repeat the previous search forwards."
9294 (unless gnus-last-search-regexp
9295 (error "No previous search"))
9296 (gnus-summary-search-article-forward gnus-last-search-regexp))
9298 (defun gnus-summary-repeat-search-article-backward ()
9299 "Repeat the previous search backwards."
9301 (unless gnus-last-search-regexp
9302 (error "No previous search"))
9303 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9305 (defun gnus-summary-search-article-forward (regexp &optional backward)
9306 "Search for an article containing REGEXP forward.
9307 If BACKWARD, search backward instead."
9310 (format "Search article %s (regexp%s): "
9311 (if current-prefix-arg "backward" "forward")
9312 (if gnus-last-search-regexp
9313 (concat ", default " gnus-last-search-regexp)
9315 current-prefix-arg))
9316 (if (string-equal regexp "")
9317 (setq regexp (or gnus-last-search-regexp ""))
9318 (setq gnus-last-search-regexp regexp)
9319 (setq gnus-article-before-search gnus-current-article))
9320 ;; Intentionally set gnus-last-article.
9321 (setq gnus-last-article gnus-article-before-search)
9322 (let ((gnus-last-article gnus-last-article))
9323 (if (gnus-summary-search-article regexp backward)
9324 (gnus-summary-show-thread)
9325 (signal 'search-failed (list regexp)))))
9327 (defun gnus-summary-search-article-backward (regexp)
9328 "Search for an article containing REGEXP backward."
9331 (format "Search article backward (regexp%s): "
9332 (if gnus-last-search-regexp
9333 (concat ", default " gnus-last-search-regexp)
9335 (gnus-summary-search-article-forward regexp 'backward))
9337 (defun gnus-summary-search-article (regexp &optional backward)
9338 "Search for an article containing REGEXP.
9339 Optional argument BACKWARD means do search for backward.
9340 `gnus-select-article-hook' is not called during the search."
9341 ;; We have to require this here to make sure that the following
9342 ;; dynamic binding isn't shadowed by autoloading.
9343 (require 'gnus-async)
9345 (let ((gnus-select-article-hook nil) ;Disable hook.
9346 (gnus-article-prepare-hook nil)
9347 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9348 (gnus-use-article-prefetch nil)
9349 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9350 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9352 (gnus-keep-backlog nil)
9353 (gnus-break-pages nil)
9354 (gnus-summary-display-arrow nil)
9355 (gnus-updated-mode-lines nil)
9356 (gnus-auto-center-summary nil)
9357 (sum (current-buffer))
9358 (gnus-display-mime-function nil)
9361 (gnus-save-hidden-threads
9362 (gnus-summary-select-article)
9363 (set-buffer gnus-article-buffer)
9364 (goto-char (window-point (get-buffer-window (current-buffer))))
9368 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9370 (re-search-backward regexp nil t)
9371 (re-search-forward regexp nil t))
9372 ;; We found the regexp.
9377 (get-buffer-window (current-buffer))
9381 (get-buffer-window (current-buffer))
9384 (setq point (point)))
9385 ;; We didn't find it, so we go to the next article.
9388 (while (eq found 'not)
9389 (if (not (if backward (gnus-summary-find-prev)
9390 (gnus-summary-find-next)))
9391 ;; No more articles.
9393 ;; Select the next article and adjust point.
9394 (unless (gnus-summary-article-sparse-p
9395 (gnus-summary-article-number))
9397 (gnus-summary-select-article)
9398 (set-buffer gnus-article-buffer)
9400 (goto-char (if backward (point-max) (point-min))))))))
9401 (gnus-message 7 ""))
9402 ;; Return whether we found the regexp.
9403 (when (eq found 'found)
9405 (gnus-summary-show-thread)
9406 (gnus-summary-goto-subject gnus-current-article)
9407 (gnus-summary-position-point)
9410 (defun gnus-find-matching-articles (header regexp)
9411 "Return a list of all articles that match REGEXP on HEADER.
9412 This search includes all articles in the current group that Gnus has
9413 fetched headers for, whether they are displayed or not."
9414 (let ((articles nil)
9415 ;; Can't eta-reduce because it's a macro.
9416 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9417 (case-fold-search t))
9418 (dolist (header gnus-newsgroup-headers)
9419 (when (string-match regexp (funcall func header))
9420 (push (mail-header-number header) articles)))
9421 (nreverse articles)))
9423 (defun gnus-summary-find-matching (header regexp &optional backward unread
9424 not-case-fold not-matching)
9425 "Return a list of all articles that match REGEXP on HEADER.
9426 The search stars on the current article and goes forwards unless
9427 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9428 If UNREAD is non-nil, only unread articles will
9429 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9430 in the comparisons. If NOT-MATCHING, return a list of all articles that
9431 not match REGEXP on HEADER."
9432 (let ((case-fold-search (not not-case-fold))
9435 (if (eq (car header) 'extra)
9438 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9440 (error "%s is an invalid header" header))
9441 (unless (fboundp (intern (concat "mail-header-" header)))
9442 (error "%s is not a valid header" header))
9443 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9444 (dolist (d (if (eq backward 'all)
9446 (gnus-data-find-list
9447 (gnus-summary-article-number)
9448 (gnus-data-list backward))))
9449 (when (and (or (not unread) ; We want all articles...
9450 (gnus-data-unread-p d)) ; Or just unreads.
9451 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9455 (funcall func (gnus-data-header d))))
9456 (string-match regexp
9457 (funcall func (gnus-data-header d)))))
9458 (push (gnus-data-number d) articles))) ; Success!
9459 (nreverse articles)))
9461 (defun gnus-summary-execute-command (header regexp command &optional backward)
9462 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9463 If HEADER is an empty string (or nil), the match is done on the entire
9464 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9466 (list (let ((completion-ignore-case t))
9467 (gnus-completing-read
9469 (mapcar 'symbol-name
9471 '(Number Subject From Lines Date
9472 Message-ID Xref References Body)
9473 gnus-extra-headers))
9475 (read-string "Regexp: ")
9476 (read-key-sequence "Command: ")
9477 current-prefix-arg))
9478 (when (equal header "Body")
9480 ;; Hidden thread subtrees must be searched as well.
9481 (gnus-summary-show-all-threads)
9482 ;; We don't want to change current point nor window configuration.
9484 (save-window-excursion
9486 gnus-treat-strip-trailing-blank-lines
9487 gnus-treat-strip-leading-blank-lines
9488 gnus-treat-strip-multiple-blank-lines
9489 gnus-treat-hide-boring-headers
9490 gnus-treat-fold-newsgroups
9491 gnus-article-prepare-hook)
9492 (gnus-message 6 "Executing %s..." (key-description command))
9493 ;; We'd like to execute COMMAND interactively so as to give arguments.
9494 (gnus-execute header regexp
9495 `(call-interactively ',(key-binding command))
9497 (gnus-message 6 "Executing %s...done" (key-description command))))))
9499 (defun gnus-summary-beginning-of-article ()
9500 "Scroll the article back to the beginning."
9502 (gnus-summary-select-article)
9503 (gnus-configure-windows 'article)
9504 (gnus-eval-in-buffer-window gnus-article-buffer
9506 (goto-char (point-min))
9507 (when gnus-break-pages
9508 (gnus-narrow-to-page))))
9510 (defun gnus-summary-end-of-article ()
9511 "Scroll to the end of the article."
9513 (gnus-summary-select-article)
9514 (gnus-configure-windows 'article)
9515 (gnus-eval-in-buffer-window gnus-article-buffer
9517 (goto-char (point-max))
9519 (when gnus-break-pages
9520 (gnus-narrow-to-page))))
9522 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9523 "Truncate to LEN and quote all \"(\"'s in STRING."
9524 (gnus-replace-in-string (if (and len (> (length string) len))
9525 (substring string 0 len)
9529 (defun gnus-summary-print-article (&optional filename n)
9530 "Generate and print a PostScript image of the process-marked (mail) articles.
9532 If used interactively, print the current article if none are
9533 process-marked. With prefix arg, prompt the user for the name of the
9536 When used from Lisp, accept two optional args FILENAME and N. N means
9537 to print the next N articles. If N is negative, print the N previous
9538 articles. If N is nil and articles have been marked with the process
9539 mark, print these instead.
9541 If the optional first argument FILENAME is nil, send the image to the
9542 printer. If FILENAME is a string, save the PostScript image in a file with
9543 that name. If FILENAME is a number, prompt the user for the name of the file
9545 (interactive (list (ps-print-preprint current-prefix-arg)))
9546 (dolist (article (gnus-summary-work-articles n))
9547 (gnus-summary-select-article nil nil 'pseudo article)
9548 (gnus-eval-in-buffer-window gnus-article-buffer
9549 (gnus-print-buffer))
9550 (gnus-summary-remove-process-mark article))
9551 (ps-despool filename))
9553 (defun gnus-print-buffer ()
9554 (let ((ps-left-header
9557 (gnus-summary-print-truncate-and-quote
9558 (mail-header-subject gnus-current-headers)
9561 (gnus-summary-print-truncate-and-quote
9562 (mail-header-from gnus-current-headers)
9566 "/pagenumberstring load"
9568 (mail-header-date gnus-current-headers) ")"))))
9569 (gnus-run-hooks 'gnus-ps-print-hook)
9571 (if ps-print-color-p
9572 (ps-spool-buffer-with-faces)
9573 (ps-spool-buffer)))))
9575 (defun gnus-summary-show-complete-article ()
9576 "Show a complete version of the current article.
9577 This is only useful if you're looking at a partial version of the
9580 (let ((gnus-keep-backlog nil)
9581 (gnus-use-cache nil)
9584 (format "%s-fetch-partial-articles"
9585 (car (gnus-find-method-for-group
9586 gnus-newsgroup-name)))
9591 (setq old-val (symbol-value variable))
9593 (gnus-flush-original-article-buffer)
9594 (gnus-summary-show-article))
9595 (set variable old-val))))
9597 (defun gnus-summary-show-article (&optional arg)
9598 "Force redisplaying of the current article.
9599 If ARG (the prefix) is a number, show the article with the charset
9600 defined in `gnus-summary-show-article-charset-alist', or the charset
9602 If ARG (the prefix) is non-nil and not a number, show the article,
9603 but without running any of the article treatment functions
9604 article. Normally, the keystroke is `C-u g'. When using `C-u
9605 C-u g', show the raw article."
9609 (gnus-summary-show-article t)
9610 (let ((gnus-newsgroup-charset
9611 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9612 (mm-read-coding-system
9613 "View as charset: " ;; actually it is coding system.
9614 (with-current-buffer gnus-article-buffer
9615 (mm-detect-coding-region (point) (point-max))))))
9616 (gnus-newsgroup-ignored-charsets 'gnus-all))
9617 (gnus-summary-select-article nil 'force)
9618 (let ((deps gnus-newsgroup-dependencies)
9620 (with-current-buffer gnus-original-article-buffer
9622 (message-narrow-to-head)
9623 (setq head (buffer-string))
9624 (goto-char (point-min))
9625 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9626 (goto-char (point-max))
9628 (setq lines (1- (count-lines (point) (point-max))))))
9630 (insert (format "211 %d Article retrieved.\n"
9631 (cdr gnus-article-current)))
9633 (if lines (insert (format "Lines: %d\n" lines)))
9635 (let ((nntp-server-buffer (current-buffer)))
9636 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9637 (gnus-data-set-header
9638 (gnus-data-find (cdr gnus-article-current))
9640 (gnus-summary-update-article-line
9641 (cdr gnus-article-current) header)
9642 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9643 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9645 ;; Select the article the normal way.
9646 (if (eq mm-text-html-renderer 'shr)
9649 (let ((shr-ignore-cache t))
9650 (gnus-summary-select-article nil 'force)))
9651 (gnus-summary-select-article nil 'force)))
9654 (let ((gnus-inhibit-article-treatments t))
9655 (gnus-summary-select-article nil 'force)))
9657 ;; We have to require this here to make sure that the following
9658 ;; dynamic binding isn't shadowed by autoloading.
9659 (require 'gnus-async)
9661 ;; Bind the article treatment functions to nil.
9662 (let ((gnus-have-all-headers t)
9663 gnus-article-prepare-hook
9664 gnus-article-decode-hook
9665 gnus-display-mime-function
9667 ;; Destroy any MIME parts.
9668 (when (gnus-buffer-live-p gnus-article-buffer)
9669 (with-current-buffer gnus-article-buffer
9670 (gnus-article-stop-animations)
9671 (mm-destroy-parts gnus-article-mime-handles)
9672 ;; Set it to nil for safety reason.
9673 (setq gnus-article-mime-handle-alist nil)
9674 (setq gnus-article-mime-handles nil)))
9675 (gnus-summary-select-article nil 'force))))
9676 (gnus-summary-goto-subject gnus-current-article)
9677 (gnus-summary-position-point))
9679 (defun gnus-summary-show-raw-article ()
9680 "Show the raw article without any article massaging functions being run."
9682 (gnus-summary-show-article t))
9684 (defun gnus-summary-verbose-headers (&optional arg)
9685 "Toggle permanent full header display.
9686 If ARG is a positive number, turn header display on.
9687 If ARG is a negative number, turn header display off."
9689 (setq gnus-show-all-headers
9690 (cond ((or (not (numberp arg))
9692 (not gnus-show-all-headers))
9695 (gnus-summary-show-article))
9697 (defun gnus-summary-toggle-header (&optional arg)
9698 "Show the headers if they are hidden, or hide them if they are shown.
9699 If ARG is a positive number, show the entire header.
9700 If ARG is a negative number, hide the unwanted header lines."
9702 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9703 (get-buffer-window gnus-article-buffer t))))
9704 (with-current-buffer gnus-article-buffer
9706 (article-narrow-to-head)
9707 (let* ((inhibit-read-only t)
9708 (inhibit-point-motion-hooks t)
9709 (hidden (if (numberp arg)
9711 (or (not (looking-at "[^ \t\n]+:"))
9712 (gnus-article-hidden-text-p 'headers))))
9714 (delete-region (point-min) (point-max))
9715 (with-current-buffer gnus-original-article-buffer
9716 (goto-char (setq s (point-min)))
9717 (setq e (if (search-forward "\n\n" nil t)
9720 (insert-buffer-substring gnus-original-article-buffer s e)
9721 (run-hooks 'gnus-article-decode-hook)
9723 (let ((gnus-treat-hide-headers nil)
9724 (gnus-treat-hide-boring-headers nil))
9725 (gnus-delete-wash-type 'headers)
9726 (gnus-treat-article 'head))
9727 (gnus-treat-article 'head))
9730 (set-window-start window (goto-char (point-min))))
9731 (if gnus-break-pages
9732 (gnus-narrow-to-page)
9733 (when (gnus-visual-p 'page-marker)
9734 (let ((inhibit-read-only t))
9735 (gnus-remove-text-with-property 'gnus-prev)
9736 (gnus-remove-text-with-property 'gnus-next))))
9737 (gnus-set-mode-line 'article)))))
9739 (defun gnus-summary-show-all-headers ()
9740 "Make all header lines visible."
9742 (gnus-summary-toggle-header 1))
9744 (defun gnus-summary-caesar-message (&optional arg)
9745 "Caesar rotate the current article by 13.
9746 With a non-numerical prefix, also rotate headers. A numerical
9747 prefix specifies how many places to rotate each letter forward."
9749 (gnus-summary-select-article)
9750 (let ((mail-header-separator ""))
9751 (gnus-eval-in-buffer-window gnus-article-buffer
9754 (let ((start (window-start))
9755 (inhibit-read-only t))
9756 (if (equal arg '(4))
9757 (message-caesar-buffer-body nil t)
9758 (message-caesar-buffer-body arg))
9759 (set-window-start (get-buffer-window (current-buffer)) start)))))
9760 ;; Create buttons and stuff...
9761 (gnus-treat-article nil))
9763 (declare-function idna-to-unicode "ext:idna" (str))
9765 (defun gnus-summary-idna-message (&optional arg)
9766 "Decode IDNA encoded domain names in the current articles.
9767 IDNA encoded domain names looks like `xn--bar'. If a string
9768 remain unencoded after running this function, it is likely an
9769 invalid IDNA string (`xn--bar' is invalid).
9771 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9772 installed for this command to work."
9774 (if (not (and (condition-case nil (require 'idna)
9776 (mm-coding-system-p 'utf-8)
9777 (executable-find (symbol-value 'idna-program))))
9779 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9780 (gnus-summary-select-article)
9781 (let ((mail-header-separator ""))
9782 (gnus-eval-in-buffer-window gnus-article-buffer
9785 (let ((start (window-start))
9787 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9788 (replace-match (idna-to-unicode (match-string 1))))
9789 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9791 (defun gnus-summary-morse-message (&optional arg)
9792 "Morse decode the current article."
9794 (gnus-summary-select-article)
9795 (let ((mail-header-separator ""))
9796 (gnus-eval-in-buffer-window gnus-article-buffer
9800 (let ((pos (window-start))
9801 (inhibit-read-only t))
9802 (goto-char (point-min))
9803 (when (message-goto-body)
9804 (gnus-narrow-to-body))
9805 (goto-char (point-min))
9806 (while (search-forward "·" (point-max) t)
9807 (replace-match "."))
9808 (unmorse-region (point-min) (point-max))
9810 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9812 (defun gnus-summary-stop-page-breaking ()
9813 "Stop page breaking in the current article."
9815 (gnus-summary-select-article)
9816 (gnus-eval-in-buffer-window gnus-article-buffer
9818 (when (gnus-visual-p 'page-marker)
9819 (let ((inhibit-read-only t))
9820 (gnus-remove-text-with-property 'gnus-prev)
9821 (gnus-remove-text-with-property 'gnus-next))
9822 (setq gnus-page-broken nil))))
9824 (defun gnus-summary-move-article (&optional n to-newsgroup
9825 select-method action)
9826 "Move the current article to a different newsgroup.
9827 If N is a positive number, move the N next articles.
9828 If N is a negative number, move the N previous articles.
9829 If N is nil and any articles have been marked with the process mark,
9830 move those articles instead.
9831 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9832 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9833 re-spool using this method.
9835 When called interactively with TO-NEWSGROUP being nil, the value of
9836 the variable `gnus-move-split-methods' is used for finding a default
9837 for the target newsgroup.
9839 For this function to work, both the current newsgroup and the
9840 newsgroup that you want to move to have to support the `request-move'
9841 and `request-accept' functions.
9843 ACTION can be either `move' (the default), `crosspost' or `copy'."
9846 (setq action 'move))
9847 ;; Check whether the source group supports the required functions.
9848 (cond ((and (eq action 'move)
9849 (not (gnus-check-backend-function
9850 'request-move-article gnus-newsgroup-name)))
9851 (error "The current group does not support article moving"))
9852 ((and (eq action 'crosspost)
9853 (not (gnus-check-backend-function
9854 'request-replace-article gnus-newsgroup-name)))
9855 (error "The current group does not support article editing")))
9856 (let ((articles (gnus-summary-work-articles n))
9857 (prefix (if (gnus-check-backend-function
9858 'request-move-article gnus-newsgroup-name)
9859 (funcall gnus-move-group-prefix-function
9860 gnus-newsgroup-name)
9862 (names '((move "Move" "Moving")
9863 (copy "Copy" "Copying")
9864 (crosspost "Crosspost" "Crossposting")))
9865 (copy-buf (save-excursion
9866 (nnheader-set-temp-buffer " *copy article*")))
9867 art-group to-method new-xref article to-groups
9868 articles-to-update-marks encoded)
9869 (unless (assq action names)
9870 (error "Unknown action %s" action))
9871 ;; Read the newsgroup name.
9872 (when (and (not to-newsgroup)
9873 (not select-method))
9874 (if (and gnus-move-split-methods
9876 (and (memq gnus-current-article articles)
9877 (gnus-buffer-live-p gnus-original-article-buffer))))
9878 ;; When `gnus-move-split-methods' is non-nil, we have to
9879 ;; select an article to give `gnus-read-move-group-name' an
9880 ;; opportunity to suggest an appropriate default. However,
9881 ;; we needn't render or mark the article.
9882 (let ((gnus-display-mime-function nil)
9883 (gnus-article-prepare-hook nil)
9884 (gnus-mark-article-hook nil))
9885 (gnus-summary-select-article nil nil nil (car articles))))
9886 (setq to-newsgroup (gnus-read-move-group-name
9887 (cadr (assq action names))
9889 (intern (format "gnus-current-%s-group" action)))
9891 encoded to-newsgroup
9892 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9893 (set (intern (format "gnus-current-%s-group" action))
9894 (mm-decode-coding-string
9896 (gnus-group-name-charset to-method to-newsgroup))))
9898 (setq to-method (or select-method
9899 (gnus-server-to-method
9900 (gnus-group-method to-newsgroup)))))
9904 (mm-encode-coding-string
9906 (gnus-group-name-charset to-method to-newsgroup)))))
9907 ;; Check the method we are to move this article to...
9908 (unless (gnus-check-backend-function
9909 'request-accept-article (car to-method))
9910 (error "%s does not support article copying" (car to-method)))
9911 (unless (gnus-check-server to-method)
9912 (error "Can't open server %s" (car to-method)))
9913 (gnus-message 6 "%s to %s: %s..."
9914 (caddr (assq action names))
9915 (or (car select-method)
9916 (gnus-group-decoded-name to-newsgroup))
9919 (setq article (pop articles))
9920 ;; Set any marks that may have changed in the summary buffer.
9921 (when gnus-preserve-marks
9922 (gnus-summary-push-marks-to-backend article))
9926 ;; Move the article.
9928 ;; Remove this article from future suppression.
9929 (gnus-dup-unsuppress-article article)
9930 (let* ((from-method (gnus-find-method-for-group
9931 gnus-newsgroup-name))
9932 (to-method (or select-method
9933 (gnus-find-method-for-group to-newsgroup)))
9934 (move-is-internal (gnus-server-equal from-method to-method)))
9935 (gnus-request-move-article
9936 article ; Article to move
9937 gnus-newsgroup-name ; From newsgroup
9938 (nth 1 (gnus-find-method-for-group
9939 gnus-newsgroup-name)) ; Server
9940 (list 'gnus-request-accept-article
9941 to-newsgroup (list 'quote select-method)
9942 (not articles) t) ; Accept form
9943 (not articles) ; Only save nov last time
9944 (and move-is-internal
9945 to-newsgroup ; Not respooling
9946 ; Is this move internal?
9947 (gnus-group-real-name to-newsgroup)))))
9948 ;; Copy the article.
9950 (with-current-buffer copy-buf
9951 (when (gnus-request-article-this-buffer article
9952 gnus-newsgroup-name)
9954 (nnheader-narrow-to-headers)
9955 (dolist (hdr gnus-copy-article-ignored-headers)
9956 (message-remove-header hdr t)))
9957 (gnus-request-accept-article
9958 to-newsgroup select-method (not articles) t))))
9959 ;; Crosspost the article.
9960 ((eq action 'crosspost)
9961 (let ((xref (message-tokenize-header
9962 (mail-header-xref (gnus-summary-article-header
9965 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9966 ":" (number-to-string article)))
9968 (setq xref (list (system-name))))
9971 (mapconcat 'identity
9972 (delete "Xref:" (delete new-xref xref))
9975 (with-current-buffer copy-buf
9976 ;; First put the article in the destination group.
9977 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9978 (when (consp (setq art-group
9979 (gnus-request-accept-article
9980 to-newsgroup select-method (not articles)
9982 (setq new-xref (concat new-xref " " (car art-group)
9984 (number-to-string (cdr art-group))))
9985 ;; Now we have the new Xrefs header, so we insert
9986 ;; it and replace the new article.
9987 (nnheader-replace-header "Xref" new-xref)
9988 (gnus-request-replace-article
9989 (cdr art-group) to-newsgroup (current-buffer) t)
9993 (gnus-message 1 "Couldn't %s article %s: %s"
9994 (cadr (assq action names)) article
9995 (nnheader-get-report (car to-method))))
9996 ((eq art-group 'junk)
9997 (when (eq action 'move)
9998 (gnus-summary-mark-article article gnus-canceled-mark)
9999 (gnus-message 4 "Deleted article %s" article)
10000 ;; run the delete hook
10001 (run-hook-with-args 'gnus-summary-article-delete-hook
10004 (assoc article (gnus-data-list nil)))
10005 gnus-newsgroup-name nil
10008 (let* ((pto-group (gnus-group-prefixed-name
10009 (car art-group) to-method))
10010 (info (gnus-get-info pto-group))
10011 (to-group (gnus-info-group info))
10013 ;; Update the group that has been moved to.
10015 (memq action '(move copy)))
10016 (unless (member to-group to-groups)
10017 (push to-group to-groups))
10019 (when (and (not (memq article gnus-newsgroup-unreads))
10021 (push 'read to-marks)
10022 (gnus-info-set-read
10023 info (gnus-add-to-range (gnus-info-read info)
10024 (list (cdr art-group)))))
10026 ;; See whether the article is to be put in the cache.
10027 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10028 (marks (if expirable
10029 gnus-article-mark-lists
10030 (delete '(expirable . expire)
10032 gnus-article-mark-lists))))
10033 (to-article (cdr art-group)))
10035 ;; Enter the article into the cache in the new group,
10036 ;; if that is required.
10037 (when (and to-article
10039 (gnus-cache-possibly-enter-article
10040 to-group to-article
10041 (memq article gnus-newsgroup-marked)
10042 (memq article gnus-newsgroup-dormant)
10043 (memq article gnus-newsgroup-unreads)))
10045 (when (and gnus-preserve-marks
10047 ;; Copy any marks over to the new group.
10048 (when (and (equal to-group gnus-newsgroup-name)
10049 (not (memq article gnus-newsgroup-unreads)))
10050 ;; Mark this article as read in this group.
10051 (push (cons to-article gnus-read-mark)
10052 gnus-newsgroup-reads)
10053 ;; Increase the active status of this group.
10054 (setcdr (gnus-active to-group) to-article)
10055 (setcdr gnus-newsgroup-active to-article))
10058 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10059 (when (memq article (symbol-value
10060 (intern (format "gnus-newsgroup-%s"
10062 (push (cdar marks) to-marks)
10063 ;; If the other group is the same as this group,
10064 ;; then we have to add the mark to the list.
10065 (when (equal to-group gnus-newsgroup-name)
10066 (set (intern (format "gnus-newsgroup-%s"
10070 (intern (format "gnus-newsgroup-%s"
10072 ;; Copy the marks to other group.
10073 (gnus-add-marked-articles
10074 to-group (cdar marks) (list to-article) info)))
10075 (setq marks (cdr marks)))
10077 (when (and expirable
10078 gnus-mark-copied-or-moved-articles-as-expirable
10079 (not (memq 'expire to-marks)))
10080 ;; Mark this article as expirable.
10081 (push 'expire to-marks)
10082 (when (equal to-group gnus-newsgroup-name)
10083 (push to-article gnus-newsgroup-expirable))
10084 ;; Copy the expirable mark to other group.
10085 (gnus-add-marked-articles
10086 to-group 'expire (list to-article) info))
10088 (when (and to-marks
10089 (or gnus-propagate-marks
10090 (gnus-method-option-p
10091 (gnus-find-method-for-group to-group)
10093 (gnus-request-set-mark
10094 to-group (list (list (list to-article) 'add to-marks)))))
10096 (gnus-dribble-enter
10097 (concat "(gnus-group-set-info '"
10098 (gnus-prin1-to-string (gnus-get-info to-group))
10100 (concat "^(gnus-group-set-info '(\""
10101 (regexp-quote to-group) "\""))))
10103 ;; Update the Xref header in this article to point to
10104 ;; the new crossposted article we have just created.
10105 (when (eq action 'crosspost)
10106 (with-current-buffer copy-buf
10107 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10108 (nnheader-replace-header "Xref" new-xref)
10109 (gnus-request-replace-article
10110 article gnus-newsgroup-name (current-buffer) t)))
10112 ;; run the move/copy/crosspost/respool hook
10113 (run-hook-with-args 'gnus-summary-article-move-hook
10116 (assoc article (gnus-data-list nil)))
10117 gnus-newsgroup-name
10121 ;;;!!!Why is this necessary?
10122 (set-buffer gnus-summary-buffer)
10124 (when (eq action 'move)
10126 (gnus-summary-goto-subject article)
10127 (gnus-summary-mark-article article gnus-canceled-mark)))))
10128 (push article articles-to-update-marks))
10131 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10132 ;; Re-activate all groups that have been moved to.
10133 (with-current-buffer gnus-group-buffer
10134 (let ((gnus-group-marked to-groups))
10135 (gnus-group-get-new-news-this-group nil t)))
10137 (gnus-kill-buffer copy-buf)
10138 (gnus-summary-position-point)
10139 (gnus-set-mode-line 'summary)))
10141 (defun gnus-summary-push-marks-to-backend (article)
10143 (marks gnus-article-mark-lists))
10144 (unless (memq article gnus-newsgroup-unreads)
10147 (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10148 (memq article (symbol-value
10149 (intern (format "gnus-newsgroup-%s"
10151 (push (cdar marks) set))
10153 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)))))
10155 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10156 "Copy the current article to some other group.
10157 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10158 When called interactively, if TO-NEWSGROUP is nil, use the value of
10159 the variable `gnus-move-split-methods' for finding a default target
10161 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10162 re-spool using this method."
10164 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10166 (defun gnus-summary-crosspost-article (&optional n)
10167 "Crosspost the current article to some other group."
10169 (gnus-summary-move-article n nil nil 'crosspost))
10171 (defcustom gnus-summary-respool-default-method nil
10172 "Default method type for respooling an article.
10173 If nil, use to the current newsgroup method."
10175 :group 'gnus-summary-mail)
10177 (defun gnus-summary-respool-article (&optional n method)
10178 "Respool the current article.
10179 The article will be squeezed through the mail spooling process again,
10180 which means that it will be put in some mail newsgroup or other
10181 depending on `nnmail-split-methods'.
10182 If N is a positive number, respool the N next articles.
10183 If N is a negative number, respool the N previous articles.
10184 If N is nil and any articles have been marked with the process mark,
10185 respool those articles instead.
10187 Respooling can be done both from mail groups and \"real\" newsgroups.
10188 In the former case, the articles in question will be moved from the
10189 current group into whatever groups they are destined to. In the
10190 latter case, they will be copied into the relevant groups."
10192 (list current-prefix-arg
10193 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10195 (symbol-name (or gnus-summary-respool-default-method
10196 (car (gnus-find-method-for-group
10197 gnus-newsgroup-name)))))
10199 (gnus-completing-read
10200 "Backend to use when respooling"
10201 methods t nil 'gnus-mail-method-history methname))
10204 ((zerop (length (setq ms (gnus-servers-using-backend
10205 (intern method)))))
10206 (list (intern method) ""))
10210 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10211 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10214 (error "No method given for respooling"))
10215 (if (assoc (symbol-name
10216 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10217 (gnus-methods-using 'respool))
10218 (gnus-summary-move-article n nil method)
10219 (gnus-summary-copy-article n nil method)))
10221 (defun gnus-summary-import-article (file &optional edit)
10222 "Import an arbitrary file into a mail newsgroup."
10223 (interactive "fImport file: \nP")
10224 (let ((group gnus-newsgroup-name)
10225 (now (current-time))
10226 atts lines group-art)
10227 (unless (gnus-check-backend-function 'request-accept-article group)
10228 (error "%s does not support article importing" group))
10229 (or (file-readable-p file)
10230 (not (file-regular-p file))
10231 (error "Can't read %s" file))
10232 (with-current-buffer (gnus-get-buffer-create " *import file*")
10234 (nnheader-insert-file-contents file)
10235 (goto-char (point-min))
10236 (if (nnheader-article-p)
10238 (goto-char (point-min))
10239 (search-forward "\n\n" nil t)
10240 (narrow-to-region (point-min) (1- (point)))
10241 (goto-char (point-min))
10242 (unless (re-search-forward "^date:" nil t)
10243 (goto-char (point-max))
10244 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10245 ;; This doesn't look like an article, so we fudge some headers.
10246 (setq atts (file-attributes file)
10247 lines (count-lines (point-min) (point-max)))
10248 (insert "From: " (read-string "From: ") "\n"
10249 "Subject: " (read-string "Subject: ") "\n"
10250 "Date: " (message-make-date (nth 5 atts)) "\n"
10251 "Message-ID: " (message-make-message-id) "\n"
10252 "Lines: " (int-to-string lines) "\n"
10253 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10254 (setq group-art (gnus-request-accept-article group nil t))
10255 (kill-buffer (current-buffer)))
10256 (setq gnus-newsgroup-active (gnus-activate-group group))
10258 (gnus-summary-goto-article (cdr group-art) nil t)
10260 (gnus-summary-edit-article))))
10262 (defun gnus-summary-create-article ()
10263 "Create an article in a mail newsgroup."
10265 (let ((group gnus-newsgroup-name)
10266 (now (current-time))
10268 (unless (gnus-check-backend-function 'request-accept-article group)
10269 (error "%s does not support article importing" group))
10270 (with-current-buffer (gnus-get-buffer-create " *import file*")
10272 (goto-char (point-min))
10273 ;; This doesn't look like an article, so we fudge some headers.
10274 (insert "From: " (read-string "From: ") "\n"
10275 "Subject: " (read-string "Subject: ") "\n"
10276 "Date: " (message-make-date now) "\n"
10277 "Message-ID: " (message-make-message-id) "\n")
10278 (setq group-art (gnus-request-accept-article group nil t))
10279 (kill-buffer (current-buffer)))
10280 (setq gnus-newsgroup-active (gnus-activate-group group))
10282 (gnus-summary-goto-article (cdr group-art) nil t)
10283 (gnus-summary-edit-article)))
10285 (defun gnus-summary-article-posted-p ()
10286 "Say whether the current (mail) article is available from news as well.
10287 This will be the case if the article has both been mailed and posted."
10289 (let ((id (mail-header-references (gnus-summary-article-header)))
10290 (gnus-override-method (car (gnus-refer-article-methods))))
10291 (if (gnus-request-head id "")
10292 (gnus-message 2 "The current message was found on %s"
10293 gnus-override-method)
10294 (gnus-message 2 "The current message couldn't be found on %s"
10295 gnus-override-method)
10298 (defun gnus-summary-expire-articles (&optional now)
10299 "Expire all articles that are marked as expirable in the current group."
10301 (when (and (not gnus-group-is-exiting-without-update-p)
10302 (gnus-check-backend-function
10303 'request-expire-articles gnus-newsgroup-name))
10304 ;; This backend supports expiry.
10305 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10306 (expirable (if total
10308 ;; We need to update the info for
10309 ;; this group for `gnus-list-of-read-articles'
10310 ;; to give us the right answer.
10311 (gnus-run-hooks 'gnus-exit-group-hook)
10312 (gnus-summary-update-info)
10313 (gnus-list-of-read-articles gnus-newsgroup-name))
10314 (setq gnus-newsgroup-expirable
10315 (sort gnus-newsgroup-expirable '<))))
10316 (expiry-wait (if now 'immediate
10317 (gnus-group-find-parameter
10318 gnus-newsgroup-name 'expiry-wait)))
10319 (nnmail-expiry-target
10320 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10321 nnmail-expiry-target))
10324 ;; There are expirable articles in this group, so we run them
10325 ;; through the expiry process.
10326 (gnus-message 6 "Expiring articles...")
10327 (when (gnus-check-group gnus-newsgroup-name)
10328 ;; The list of articles that weren't expired is returned.
10331 (let ((nnmail-expiry-wait-function nil)
10332 (nnmail-expiry-wait expiry-wait))
10333 (setq es (gnus-request-expire-articles
10334 expirable gnus-newsgroup-name)))
10335 (setq es (gnus-request-expire-articles
10336 expirable gnus-newsgroup-name)))
10338 (setq gnus-newsgroup-expirable es))
10339 ;; We go through the old list of expirable, and mark all
10340 ;; really expired articles as nonexistent.
10341 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10342 (let ((gnus-use-cache nil))
10343 (dolist (article expirable)
10344 (when (and (not (memq article es))
10345 (gnus-data-find article))
10346 (gnus-summary-mark-article article gnus-canceled-mark)
10347 (run-hook-with-args 'gnus-summary-article-expire-hook
10350 (assoc article (gnus-data-list nil)))
10351 gnus-newsgroup-name
10354 (gnus-message 6 "Expiring articles...done")))))
10356 (defun gnus-summary-expire-articles-now ()
10357 "Expunge all expirable articles in the current group.
10358 This means that *all* articles that are marked as expirable will be
10359 deleted forever, right now."
10361 (or gnus-expert-user
10363 "Are you really, really sure you want to delete all expirable messages? ")
10365 (gnus-summary-expire-articles t))
10367 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10368 (defun gnus-summary-delete-article (&optional n)
10369 "Delete the N next (mail) articles.
10370 This command actually deletes articles. This is not a marking
10371 command. The article will disappear forever from your life, never to
10374 If N is negative, delete backwards.
10375 If N is nil and articles have been marked with the process mark,
10376 delete these instead.
10378 If `gnus-novice-user' is non-nil you will be asked for
10379 confirmation before the articles are deleted."
10381 (unless (gnus-check-backend-function 'request-expire-articles
10382 gnus-newsgroup-name)
10383 (error "The current newsgroup does not support article deletion"))
10384 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10385 (error "Couldn't open server"))
10386 ;; Compute the list of articles to delete.
10387 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10388 (nnmail-expiry-target 'delete)
10390 (if (and gnus-novice-user
10391 (not (gnus-yes-or-no-p
10392 (format "Do you really want to delete %s forever? "
10393 (if (> (length articles) 1)
10394 (format "these %s articles" (length articles))
10395 "this article")))))
10397 ;; Delete the articles.
10398 (setq not-deleted (gnus-request-expire-articles
10399 articles gnus-newsgroup-name 'force))
10402 (gnus-summary-remove-process-mark (car articles))
10403 ;; The backend might not have been able to delete the article
10405 (unless (memq (car articles) not-deleted)
10406 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10407 (let* ((article (car articles))
10408 (ghead (gnus-data-header
10409 (assoc article (gnus-data-list nil)))))
10410 (run-hook-with-args 'gnus-summary-article-delete-hook
10411 'delete ghead gnus-newsgroup-name nil
10413 (setq articles (cdr articles))))
10415 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10416 (gnus-summary-position-point)
10417 (gnus-set-mode-line 'summary)
10420 (defun gnus-summary-edit-article (&optional arg)
10421 "Edit the current article.
10422 This will have permanent effect only in mail groups.
10423 If ARG is nil, edit the decoded articles.
10424 If ARG is 1, edit the raw articles.
10425 If ARG is 2, edit the raw articles even in read-only groups.
10426 If ARG is 3, edit the articles with the current handles.
10427 Otherwise, allow editing of articles even in read-only
10430 (let (force raw current-handles)
10439 (setq current-handles
10440 (and (gnus-buffer-live-p gnus-article-buffer)
10441 (with-current-buffer gnus-article-buffer
10443 gnus-article-mime-handles
10444 (setq gnus-article-mime-handles nil))))))
10447 (when (and raw (not force)
10448 (member gnus-newsgroup-name '("nndraft:delayed"
10451 (error "Can't edit the raw article in group %s"
10452 gnus-newsgroup-name))
10453 (with-current-buffer gnus-summary-buffer
10454 (let ((mail-parse-charset gnus-newsgroup-charset)
10455 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10456 (gnus-set-global-variables)
10457 (when (and (not force)
10458 (gnus-group-read-only-p))
10459 (error "The current newsgroup does not support article editing"))
10460 (gnus-summary-show-article t)
10461 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10462 (with-current-buffer gnus-article-buffer
10463 (mm-enable-multibyte)))
10464 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10466 (gnus-article-edit-article
10469 (let ((mbl mml-buffer-list))
10470 (setq mml-buffer-list nil)
10471 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10472 (mime-to-mml ,'current-handles))
10473 (let ((mbl1 mml-buffer-list))
10474 (setq mml-buffer-list mbl)
10475 (set (make-local-variable 'mml-buffer-list) mbl1))
10476 (gnus-make-local-hook 'kill-buffer-hook)
10477 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10478 `(lambda (no-highlight)
10479 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10480 (message-options message-options)
10481 (message-options-set-recipient)
10482 (mail-parse-ignored-charsets
10483 ',gnus-newsgroup-ignored-charsets)
10484 (rfc2047-header-encoding-alist
10485 ',(let ((charset (gnus-group-name-charset
10486 (gnus-find-method-for-group
10487 gnus-newsgroup-name)
10488 gnus-newsgroup-name)))
10489 (append (list (cons "Newsgroups" charset)
10490 (cons "Followup-To" charset)
10491 (cons "Xref" charset))
10492 rfc2047-header-encoding-alist))))
10493 ,(if (not raw) '(progn
10495 (mml-destroy-buffers)
10496 (remove-hook 'kill-buffer-hook
10497 'mml-destroy-buffers t)
10498 (kill-local-variable 'mml-buffer-list)))
10499 (gnus-summary-edit-article-done
10500 ,(or (mail-header-references gnus-current-headers) "")
10501 ,(gnus-group-read-only-p)
10502 ,gnus-summary-buffer no-highlight))))))))
10504 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10506 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10508 "Make edits to the current article permanent."
10511 ;; The buffer restriction contains the entire article if it exists.
10512 (when (article-goto-body)
10513 (let ((lines (count-lines (point) (point-max)))
10514 (length (- (point-max) (point)))
10515 (case-fold-search t)
10516 (body (copy-marker (point))))
10517 (goto-char (point-min))
10518 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10519 (delete-region (match-beginning 1) (match-end 1))
10520 (insert (number-to-string length)))
10521 (goto-char (point-min))
10522 (when (re-search-forward
10523 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10524 (delete-region (match-beginning 1) (match-end 1))
10525 (insert (number-to-string length)))
10526 (goto-char (point-min))
10527 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10528 (delete-region (match-beginning 1) (match-end 1))
10529 (insert (number-to-string lines))))))
10530 ;; Replace the article.
10531 (let ((buf (current-buffer))
10532 (article (cdr gnus-article-current))
10535 (insert-buffer-substring buf)
10536 (if (and (not read-only)
10537 (not (setq replace-result
10538 (gnus-request-replace-article
10539 article (car gnus-article-current)
10540 (current-buffer) t))))
10541 (error "Couldn't replace article")
10542 ;; If we got a number back, then that's the new article number
10543 ;; for this article. Otherwise, the article number didn't change.
10544 (when (numberp replace-result)
10545 (with-current-buffer gnus-summary-buffer
10546 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10547 (gnus-summary-limit gnus-newsgroup-limit)
10548 (setq article replace-result)
10549 (gnus-summary-goto-subject article t)))
10550 ;; Update the summary buffer.
10551 (if (and references
10552 (equal (message-tokenize-header references " ")
10553 (message-tokenize-header
10554 (or (message-fetch-field "references") "") " ")))
10555 ;; We only have to update this line.
10558 (message-narrow-to-head)
10559 (let ((head (buffer-substring-no-properties
10560 (point-min) (point-max)))
10563 (insert (format "211 %d Article retrieved.\n" article))
10566 (let ((nntp-server-buffer (current-buffer)))
10567 (setq header (car (gnus-get-newsgroup-headers nil t))))
10568 (with-current-buffer gnus-summary-buffer
10569 (gnus-data-set-header (gnus-data-find article) header)
10570 (gnus-summary-update-article-line article header)
10571 (if (gnus-summary-goto-subject article nil t)
10572 (gnus-summary-update-secondary-mark article)))))))
10574 (set-buffer (or buffer gnus-summary-buffer))
10575 (gnus-summary-update-article article)
10576 (if (gnus-summary-goto-subject article nil t)
10577 (gnus-summary-update-secondary-mark article)))
10578 ;; Prettify the article buffer again.
10579 (unless no-highlight
10580 (with-current-buffer gnus-article-buffer
10581 ;;!!! Fix this -- article should be rehighlighted.
10582 ;;(gnus-run-hooks 'gnus-article-display-hook)
10583 (set-buffer gnus-original-article-buffer)
10584 (gnus-request-article
10585 article (car gnus-article-current) (current-buffer))))
10586 ;; Prettify the summary buffer line.
10587 (when (gnus-visual-p 'summary-highlight 'highlight)
10588 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10590 (defun gnus-summary-edit-wash (key)
10591 "Perform editing command KEY in the article buffer."
10595 (message "%s" (concat (this-command-keys) "- "))
10598 (gnus-summary-edit-article)
10599 (execute-kbd-macro (concat (this-command-keys) key))
10600 (gnus-article-edit-done))
10604 (defun gnus-summary-respool-query (&optional silent trace)
10605 "Query where the respool algorithm would put this article."
10607 (let (gnus-mark-article-hook)
10608 (gnus-summary-select-article)
10609 (with-current-buffer gnus-original-article-buffer
10610 (let ((groups (nnmail-article-group 'identity trace)))
10613 (message "This message would go to %s"
10614 (mapconcat 'car groups ", "))
10615 (message "This message would go to no groups"))
10618 (defun gnus-summary-respool-trace ()
10619 "Trace where the respool algorithm would put this article.
10620 Display a buffer showing all fancy splitting patterns which matched."
10622 (gnus-summary-respool-query nil t))
10624 ;; Summary marking commands.
10626 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10627 "Mark articles which has the same subject as read, and then select the next.
10628 If UNMARK is positive, remove any kind of mark.
10629 If UNMARK is negative, tick articles."
10632 (setq unmark (prefix-numeric-value unmark)))
10634 (gnus-summary-mark-same-subject
10635 (gnus-summary-article-subject) unmark)))
10636 ;; Select next unread article. If auto-select-same mode, should
10637 ;; select the first unread article.
10638 (gnus-summary-next-article t (and gnus-auto-select-same
10639 (gnus-summary-article-subject)))
10640 (gnus-message 7 "%d article%s marked as %s"
10641 count (if (= count 1) " is" "s are")
10642 (if unmark "unread" "read"))))
10644 (defun gnus-summary-kill-same-subject (&optional unmark)
10645 "Mark articles which has the same subject as read.
10646 If UNMARK is positive, remove any kind of mark.
10647 If UNMARK is negative, tick articles."
10650 (setq unmark (prefix-numeric-value unmark)))
10652 (gnus-summary-mark-same-subject
10653 (gnus-summary-article-subject) unmark)))
10654 ;; If marked as read, go to next unread subject.
10655 (when (null unmark)
10656 ;; Go to next unread subject.
10657 (gnus-summary-next-subject 1 t))
10658 (gnus-message 7 "%d articles are marked as %s"
10659 count (if unmark "unread" "read"))))
10661 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10662 "Mark articles with same SUBJECT as read, and return marked number.
10663 If optional argument UNMARK is positive, remove any kinds of marks.
10664 If optional argument UNMARK is negative, mark articles as unread instead."
10668 ((null unmark) ; Mark as read.
10671 (gnus-summary-mark-article-as-read gnus-killed-mark)
10672 (gnus-summary-show-thread) t)
10673 (gnus-summary-find-subject subject))
10674 (setq count (1+ count))))
10675 ((> unmark 0) ; Tick.
10678 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10679 (gnus-summary-show-thread) t)
10680 (gnus-summary-find-subject subject))
10681 (setq count (1+ count))))
10682 (t ; Mark as unread.
10685 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10686 (gnus-summary-show-thread) t)
10687 (gnus-summary-find-subject subject))
10688 (setq count (1+ count)))))
10689 (gnus-set-mode-line 'summary)
10690 ;; Return the number of marked articles.
10693 (defun gnus-summary-mark-as-processable (n &optional unmark)
10694 "Set the process mark on the next N articles.
10695 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10696 the process mark instead. The difference between N and the actual
10697 number of articles marked is returned."
10699 (if (and (null n) (gnus-region-active-p))
10700 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10701 (setq n (prefix-numeric-value n))
10702 (let ((backward (< n 0))
10707 (gnus-summary-remove-process-mark
10708 (gnus-summary-article-number))
10709 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10710 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10713 (gnus-message 7 "No more articles"))
10714 (gnus-summary-recenter)
10715 (gnus-summary-position-point)
10718 (defun gnus-summary-unmark-as-processable (n)
10719 "Remove the process mark from the next N articles.
10720 If N is negative, unmark backward instead. The difference between N and
10721 the actual number of articles unmarked is returned."
10723 (gnus-summary-mark-as-processable n t))
10725 (defun gnus-summary-unmark-all-processable ()
10726 "Remove the process mark from all articles."
10729 (while gnus-newsgroup-processable
10730 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10731 (gnus-summary-position-point))
10733 (defun gnus-summary-add-mark (article type)
10734 "Mark ARTICLE with a mark of TYPE."
10735 (let ((vtype (car (assq type gnus-article-mark-lists)))
10738 (error "No such mark type: %s" type)
10739 (setq var (intern (format "gnus-newsgroup-%s" type)))
10740 (set var (cons article (symbol-value var)))
10741 (if (memq type '(processable cached replied forwarded recent saved))
10742 (gnus-summary-update-secondary-mark article)
10743 ;;; !!! This is bogus. We should find out what primary
10744 ;;; !!! mark we want to set.
10745 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10747 (defun gnus-summary-mark-as-expirable (n)
10748 "Mark N articles forward as expirable.
10749 If N is negative, mark backward instead. The difference between N and
10750 the actual number of articles marked is returned."
10752 (gnus-summary-mark-forward n gnus-expirable-mark))
10754 (defun gnus-summary-mark-as-spam (n)
10755 "Mark N articles forward as spam.
10756 If N is negative, mark backward instead. The difference between N and
10757 the actual number of articles marked is returned."
10759 (gnus-summary-mark-forward n gnus-spam-mark))
10761 (defun gnus-summary-mark-article-as-replied (article)
10762 "Mark ARTICLE as replied to and update the summary line.
10763 ARTICLE can also be a list of articles."
10764 (interactive (list (gnus-summary-article-number)))
10765 (let ((articles (if (listp article) article (list article))))
10766 (dolist (article articles)
10767 (unless (numberp article)
10768 (error "%s is not a number" article))
10769 (push article gnus-newsgroup-replied)
10770 (let ((inhibit-read-only t))
10771 (when (gnus-summary-goto-subject article nil t)
10772 (gnus-summary-update-secondary-mark article))))))
10774 (defun gnus-summary-mark-article-as-forwarded (article)
10775 "Mark ARTICLE as forwarded and update the summary line.
10776 ARTICLE can also be a list of articles."
10777 (let ((articles (if (listp article) article (list article))))
10778 (dolist (article articles)
10779 (push article gnus-newsgroup-forwarded)
10780 (let ((inhibit-read-only t))
10781 (when (gnus-summary-goto-subject article nil t)
10782 (gnus-summary-update-secondary-mark article))))))
10784 (defun gnus-summary-set-bookmark (article)
10785 "Set a bookmark in current article."
10786 (interactive (list (gnus-summary-article-number)))
10787 (when (or (not (get-buffer gnus-article-buffer))
10788 (not gnus-current-article)
10789 (not gnus-article-current)
10790 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10791 (error "No current article selected"))
10792 ;; Remove old bookmark, if one exists.
10793 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10794 ;; Set the new bookmark, which is on the form
10795 ;; (article-number . line-number-in-body).
10798 (with-current-buffer gnus-article-buffer
10802 (article-goto-body)
10805 gnus-newsgroup-bookmarks)
10806 (gnus-message 6 "A bookmark has been added to the current article."))
10808 (defun gnus-summary-remove-bookmark (article)
10809 "Remove the bookmark from the current article."
10810 (interactive (list (gnus-summary-article-number)))
10811 ;; Remove old bookmark, if one exists.
10812 (if (not (assq article gnus-newsgroup-bookmarks))
10813 (gnus-message 6 "No bookmark in current article.")
10814 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10815 (gnus-message 6 "Removed bookmark.")))
10817 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10818 (defun gnus-summary-mark-as-dormant (n)
10819 "Mark N articles forward as dormant.
10820 If N is negative, mark backward instead. The difference between N and
10821 the actual number of articles marked is returned."
10823 (gnus-summary-mark-forward n gnus-dormant-mark))
10825 (defun gnus-summary-set-process-mark (article)
10826 "Set the process mark on ARTICLE and update the summary line."
10827 (setq gnus-newsgroup-processable
10829 (delq article gnus-newsgroup-processable)))
10830 (when (gnus-summary-goto-subject article)
10831 (gnus-summary-show-thread)
10832 (gnus-summary-goto-subject article)
10833 (gnus-summary-update-secondary-mark article)))
10835 (defun gnus-summary-remove-process-mark (&rest articles)
10836 "Remove the process mark from ARTICLES and update the summary line."
10837 (dolist (article articles)
10838 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10839 (when (gnus-summary-goto-subject article)
10840 (gnus-summary-show-thread)
10841 (gnus-summary-goto-subject article)
10842 (gnus-summary-update-secondary-mark article)))
10845 (defun gnus-summary-set-saved-mark (article)
10846 "Set the process mark on ARTICLE and update the summary line."
10847 (push article gnus-newsgroup-saved)
10848 (when (gnus-summary-goto-subject article)
10849 (gnus-summary-update-secondary-mark article)))
10851 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10852 "Mark N articles as read forwards.
10853 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10854 The difference between N and the actual number of articles marked is
10856 If NO-EXPIRE, auto-expiry will be inhibited."
10858 (gnus-summary-show-thread)
10859 (let ((backward (< n 0))
10860 (gnus-summary-goto-unread
10861 (and gnus-summary-goto-unread
10862 (not (eq gnus-summary-goto-unread 'never))
10863 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10864 gnus-ticked-mark gnus-dormant-mark)))))
10866 (mark (or mark gnus-del-mark)))
10867 (while (and (> n 0)
10868 (gnus-summary-mark-article nil mark no-expire)
10869 (zerop (gnus-summary-next-subject
10871 (and gnus-summary-goto-unread
10872 (not (eq gnus-summary-goto-unread 'never)))
10876 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10877 (gnus-summary-recenter)
10878 (gnus-summary-position-point)
10879 (gnus-set-mode-line 'summary)
10882 (defun gnus-summary-mark-article-as-read (mark)
10883 "Mark the current article quickly as read with MARK."
10884 (let ((article (gnus-summary-article-number)))
10885 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10886 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10887 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10888 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10889 (push (cons article mark) gnus-newsgroup-reads)
10890 ;; Possibly remove from cache, if that is used.
10891 (when gnus-use-cache
10892 (gnus-cache-enter-remove-article article))
10893 ;; Allow the backend to change the mark.
10894 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10895 ;; Check for auto-expiry.
10896 (when (and gnus-newsgroup-auto-expire
10897 (memq mark gnus-auto-expirable-marks))
10898 (setq mark gnus-expirable-mark)
10899 ;; Let the backend know about the mark change.
10900 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10901 (push article gnus-newsgroup-expirable))
10902 ;; Set the mark in the buffer.
10903 (gnus-summary-update-mark mark 'unread)
10906 (defun gnus-summary-mark-article-as-unread (mark)
10907 "Mark the current article quickly as unread with MARK."
10908 (let* ((article (gnus-summary-article-number))
10909 (old-mark (gnus-summary-article-mark article)))
10910 ;; Allow the backend to change the mark.
10911 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10912 (if (eq mark old-mark)
10916 (gnus-error 1 "Can't mark negative article numbers")
10918 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10919 (setq gnus-newsgroup-spam-marked
10920 (delq article gnus-newsgroup-spam-marked))
10921 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10922 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10923 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10924 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10925 (cond ((= mark gnus-ticked-mark)
10926 (setq gnus-newsgroup-marked
10927 (gnus-add-to-sorted-list gnus-newsgroup-marked
10929 ((= mark gnus-spam-mark)
10930 (setq gnus-newsgroup-spam-marked
10931 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10933 ((= mark gnus-dormant-mark)
10934 (setq gnus-newsgroup-dormant
10935 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10938 (setq gnus-newsgroup-unreads
10939 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10941 (gnus-alist-pull article gnus-newsgroup-reads)
10943 ;; See whether the article is to be put in the cache.
10944 (and gnus-use-cache
10945 (vectorp (gnus-summary-article-header article))
10947 (gnus-cache-possibly-enter-article
10948 gnus-newsgroup-name article
10949 (= mark gnus-ticked-mark)
10950 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10953 (gnus-summary-update-mark mark 'unread)
10956 (defun gnus-summary-mark-article (&optional article mark no-expire)
10957 "Mark ARTICLE with MARK. MARK can be any character.
10958 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10959 `??' (dormant) and `?E' (expirable).
10960 If MARK is nil, then the default character `?r' is used.
10961 If ARTICLE is nil, then the article on the current line will be
10963 If NO-EXPIRE, auto-expiry will be inhibited."
10964 ;; The mark might be a string.
10965 (when (stringp mark)
10966 (setq mark (aref mark 0)))
10967 ;; If no mark is given, then we check auto-expiring.
10969 (setq mark gnus-del-mark))
10970 (when (and (not no-expire)
10971 gnus-newsgroup-auto-expire
10972 (memq mark gnus-auto-expirable-marks))
10973 (setq mark gnus-expirable-mark))
10974 (let ((article (or article (gnus-summary-article-number)))
10975 (old-mark (gnus-summary-article-mark article)))
10976 ;; Allow the backend to change the mark.
10977 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10978 (if (eq mark old-mark)
10981 (error "No article on current line"))
10982 (if (not (if (or (= mark gnus-unread-mark)
10983 (= mark gnus-ticked-mark)
10984 (= mark gnus-spam-mark)
10985 (= mark gnus-dormant-mark))
10986 (gnus-mark-article-as-unread article mark)
10987 (gnus-mark-article-as-read article mark)))
10989 ;; See whether the article is to be put in the cache.
10990 (and gnus-use-cache
10991 (not (= mark gnus-canceled-mark))
10992 (vectorp (gnus-summary-article-header article))
10994 (gnus-cache-possibly-enter-article
10995 gnus-newsgroup-name article
10996 (= mark gnus-ticked-mark)
10997 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10999 (when (gnus-summary-goto-subject article nil t)
11000 (let ((inhibit-read-only t))
11001 (gnus-summary-show-thread)
11003 (gnus-summary-update-mark mark 'unread)
11006 (defun gnus-summary-update-secondary-mark (article)
11007 "Update the secondary (read, process, cache) mark."
11008 (gnus-summary-update-mark
11009 (cond ((memq article gnus-newsgroup-processable)
11011 ((memq article gnus-newsgroup-cached)
11013 ((memq article gnus-newsgroup-replied)
11015 ((memq article gnus-newsgroup-forwarded)
11016 gnus-forwarded-mark)
11017 ((memq article gnus-newsgroup-saved)
11019 ((memq article gnus-newsgroup-unseen)
11023 (when (gnus-visual-p 'summary-highlight 'highlight)
11024 (gnus-summary-highlight-line)
11025 (gnus-run-hooks 'gnus-summary-update-hook))
11028 (defun gnus-summary-update-download-mark (article)
11029 "Update the download mark."
11030 (gnus-summary-update-mark
11031 (cond ((memq article gnus-newsgroup-undownloaded)
11032 gnus-undownloaded-mark)
11033 (gnus-newsgroup-agentized
11034 gnus-downloaded-mark)
11038 (gnus-summary-update-line t)
11041 (defun gnus-summary-update-mark (mark type)
11042 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11043 (inhibit-read-only t))
11044 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11046 (when (looking-at "\r")
11048 (when (<= (+ forward (point)) (point-max))
11049 ;; Go to the right position on the line.
11050 (goto-char (+ forward (point)))
11051 ;; Replace the old mark with the new mark.
11053 (mm-subst-char-in-string
11055 (buffer-substring (point) (1+ (point))))))
11056 (delete-region (point) (1+ (point)))
11057 (insert to-insert))
11058 ;; Optionally update the marks by some user rule.
11059 (when (eq type 'unread)
11060 (gnus-data-set-mark
11061 (gnus-data-find (gnus-summary-article-number)) mark)
11062 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11064 (defun gnus-mark-article-as-read (article &optional mark)
11065 "Enter ARTICLE in the pertinent lists and remove it from others."
11066 ;; Make the article expirable.
11067 (let ((mark (or mark gnus-del-mark)))
11068 (setq gnus-newsgroup-expirable
11069 (if (= mark gnus-expirable-mark)
11070 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11071 (delq article gnus-newsgroup-expirable)))
11072 ;; Remove from unread and marked lists.
11073 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11074 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11075 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11076 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11077 (push (cons article mark) gnus-newsgroup-reads)
11078 ;; Possibly remove from cache, if that is used.
11079 (when gnus-use-cache
11080 (gnus-cache-enter-remove-article article))
11083 (defun gnus-mark-article-as-unread (article &optional mark)
11084 "Enter ARTICLE in the pertinent lists and remove it from others."
11085 (let ((mark (or mark gnus-ticked-mark)))
11088 (gnus-error 1 "Can't mark negative article numbers")
11090 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11091 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11092 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11093 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11094 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11096 ;; Unsuppress duplicates?
11097 (when gnus-suppress-duplicates
11098 (gnus-dup-unsuppress-article article))
11100 (cond ((= mark gnus-ticked-mark)
11101 (setq gnus-newsgroup-marked
11102 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11103 ((= mark gnus-spam-mark)
11104 (setq gnus-newsgroup-spam-marked
11105 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11107 ((= mark gnus-dormant-mark)
11108 (setq gnus-newsgroup-dormant
11109 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11111 (setq gnus-newsgroup-unreads
11112 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11113 (gnus-alist-pull article gnus-newsgroup-reads)
11116 (defun gnus-summary-tick-article-forward (n)
11117 "Tick N articles forwards.
11118 If N is negative, tick backwards instead.
11119 The difference between N and the number of articles ticked is returned."
11121 (gnus-summary-mark-forward n gnus-ticked-mark))
11123 (defun gnus-summary-tick-article-backward (n)
11124 "Tick N articles backwards.
11125 The difference between N and the number of articles ticked is returned."
11127 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11129 (defun gnus-summary-tick-article (&optional article clear-mark)
11130 "Mark current article as unread.
11131 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11132 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11134 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11135 gnus-ticked-mark)))
11137 (defun gnus-summary-mark-as-read-forward (n)
11138 "Mark N articles as read forwards.
11139 If N is negative, mark backwards instead.
11140 The difference between N and the actual number of articles marked is
11143 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11145 (defun gnus-summary-mark-as-read-backward (n)
11146 "Mark the N articles as read backwards.
11147 The difference between N and the actual number of articles marked is
11150 (gnus-summary-mark-forward
11151 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11153 (defun gnus-summary-mark-as-read (&optional article mark)
11154 "Mark current article as read.
11155 ARTICLE specifies the article to be marked as read.
11156 MARK specifies a string to be inserted at the beginning of the line."
11157 (gnus-summary-mark-article article mark))
11159 (defun gnus-summary-clear-mark-forward (n)
11160 "Clear marks from N articles forward.
11161 If N is negative, clear backward instead.
11162 The difference between N and the number of marks cleared is returned."
11164 (gnus-summary-mark-forward n gnus-unread-mark))
11166 (defun gnus-summary-clear-mark-backward (n)
11167 "Clear marks from N articles backward.
11168 The difference between N and the number of marks cleared is returned."
11170 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11172 (defun gnus-summary-mark-unread-as-read ()
11173 "Intended to be used by `gnus-mark-article-hook'."
11174 (when (memq gnus-current-article gnus-newsgroup-unreads)
11175 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11177 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11178 "Intended to be used by `gnus-mark-article-hook'."
11179 (let ((mark (gnus-summary-article-mark)))
11180 (when (or (gnus-unread-mark-p mark)
11181 (gnus-read-mark-p mark))
11182 (gnus-summary-mark-article gnus-current-article
11183 (or new-mark gnus-read-mark)))))
11185 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11186 "Intended to be used by `gnus-mark-article-hook'."
11187 (let ((mark (gnus-summary-article-mark)))
11188 (when (or (gnus-unread-mark-p mark)
11189 (gnus-read-mark-p mark))
11190 (gnus-summary-mark-article (gnus-summary-article-number)
11191 (or new-mark gnus-read-mark)))))
11193 (defun gnus-summary-mark-unread-as-ticked ()
11194 "Intended to be used by `gnus-mark-article-hook'."
11195 (when (memq gnus-current-article gnus-newsgroup-unreads)
11196 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11198 (defun gnus-summary-mark-region-as-read (point mark all)
11199 "Mark all unread articles between point and mark as read.
11200 If given a prefix, mark all articles between point and mark as read,
11201 even ticked and dormant ones."
11202 (interactive "r\nP")
11206 (beginning-of-line)
11211 (memq (setq article (gnus-summary-article-number))
11212 gnus-newsgroup-unreads))
11213 (gnus-summary-mark-article article gnus-del-mark))
11215 (gnus-summary-find-next))))))
11217 (defun gnus-summary-mark-below (score mark)
11218 "Mark articles with score less than SCORE with MARK."
11219 (interactive "P\ncMark: ")
11220 (setq score (if score
11221 (prefix-numeric-value score)
11222 (or gnus-summary-default-score 0)))
11223 (with-current-buffer gnus-summary-buffer
11224 (goto-char (point-min))
11227 (and (< (gnus-summary-article-score) score)
11228 (gnus-summary-mark-article nil mark))
11229 (gnus-summary-find-next)))))
11231 (defun gnus-summary-kill-below (&optional score)
11232 "Mark articles with score below SCORE as read."
11234 (gnus-summary-mark-below score gnus-killed-mark))
11236 (defun gnus-summary-clear-above (&optional score)
11237 "Clear all marks from articles with score above SCORE."
11239 (gnus-summary-mark-above score gnus-unread-mark))
11241 (defun gnus-summary-tick-above (&optional score)
11242 "Tick all articles with score above SCORE."
11244 (gnus-summary-mark-above score gnus-ticked-mark))
11246 (defun gnus-summary-mark-above (score mark)
11247 "Mark articles with score over SCORE with MARK."
11248 (interactive "P\ncMark: ")
11249 (setq score (if score
11250 (prefix-numeric-value score)
11251 (or gnus-summary-default-score 0)))
11252 (with-current-buffer gnus-summary-buffer
11253 (goto-char (point-min))
11255 (when (> (gnus-summary-article-score) score)
11256 (gnus-summary-mark-article nil mark))
11258 (gnus-summary-find-next)))))
11260 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11261 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11262 (defun gnus-summary-limit-include-expunged (&optional no-error)
11263 "Display all the hidden articles that were expunged for low scores."
11265 (let ((inhibit-read-only t))
11266 (let ((scored gnus-newsgroup-scored)
11269 (unless (gnus-summary-article-header (caar scored))
11270 (and (setq h (gnus-number-to-header (caar scored)))
11271 (< (cdar scored) gnus-summary-expunge-below)
11273 (setq scored (cdr scored)))
11275 (when (not no-error)
11276 (error "No expunged articles hidden"))
11277 (goto-char (point-min))
11278 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11279 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11280 (dolist (x headers)
11281 (push (mail-header-number x) gnus-newsgroup-limit))
11282 (gnus-summary-prepare-unthreaded (nreverse headers))
11283 (goto-char (point-min))
11284 (gnus-summary-position-point)
11287 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11288 "Mark all unread articles in this newsgroup as read.
11289 If prefix argument ALL is non-nil, ticked and dormant articles will
11290 also be marked as read.
11291 If QUIETLY is non-nil, no questions will be asked.
11293 If TO-HERE is non-nil, it should be a point in the buffer. All
11294 articles before (after, if REVERSE is set) this point will be marked
11297 Note that this function will only catch up the unread article
11298 in the current summary buffer limitation.
11300 The number of articles marked as read is returned."
11305 (not gnus-interactive-catchup) ;Without confirmation?
11309 "Mark absolutely all articles as read? "
11310 "Mark all unread articles as read? ")))
11312 (not gnus-newsgroup-adaptive)
11313 (not gnus-newsgroup-auto-expire)
11314 (not gnus-suppress-duplicates)
11315 (or (not gnus-use-cache)
11316 (eq gnus-use-cache 'passive)))
11319 (setq gnus-newsgroup-marked nil
11320 gnus-newsgroup-spam-marked nil
11321 gnus-newsgroup-dormant nil))
11322 (setq gnus-newsgroup-unreads
11323 (gnus-sorted-nunion
11324 (gnus-sorted-intersection gnus-newsgroup-unreads
11325 gnus-newsgroup-downloadable)
11326 (gnus-sorted-difference gnus-newsgroup-unfetched
11327 gnus-newsgroup-cached))))
11328 ;; We actually mark all articles as canceled, which we
11329 ;; have to do when using auto-expiry or adaptive scoring.
11330 (gnus-summary-show-all-threads)
11331 (if (and to-here reverse)
11333 (goto-char to-here)
11334 (gnus-summary-mark-current-read-and-unread-as-read
11336 (while (gnus-summary-find-next (not all))
11337 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11338 (when (gnus-summary-first-subject (not all))
11340 (if to-here (< (point) to-here) t)
11341 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11342 (gnus-summary-find-next (not all))))))
11343 (gnus-set-mode-line 'summary))
11345 (gnus-summary-position-point)))
11347 (defun gnus-summary-catchup-to-here (&optional all)
11348 "Mark all unticked articles before the current one as read.
11349 If ALL is non-nil, also mark ticked and dormant articles as read."
11352 (gnus-save-hidden-threads
11353 (let ((beg (point)))
11354 ;; We check that there are unread articles.
11355 (when (or all (gnus-summary-find-prev))
11356 (gnus-summary-catchup all t beg)))))
11357 (gnus-summary-position-point))
11359 (defun gnus-summary-catchup-from-here (&optional all)
11360 "Mark all unticked articles after (and including) the current one as read.
11361 If ALL is non-nil, also mark ticked and dormant articles as read."
11364 (gnus-save-hidden-threads
11365 (let ((beg (point)))
11366 ;; We check that there are unread articles.
11367 (when (or all (gnus-summary-find-next))
11368 (gnus-summary-catchup all t beg nil t)))))
11369 (gnus-summary-position-point))
11371 (defun gnus-summary-catchup-all (&optional quietly)
11372 "Mark all articles in this newsgroup as read.
11373 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11374 instead, which marks only unread articles as read."
11376 (gnus-summary-catchup t quietly))
11378 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11379 "Mark all unread articles in this group as read, then exit.
11380 If prefix argument ALL is non-nil, all articles are marked as read.
11381 If QUIETLY is non-nil, no questions will be asked."
11383 (when (gnus-summary-catchup all quietly nil 'fast)
11384 ;; Select next newsgroup or exit.
11385 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11386 (eq gnus-auto-select-next 'quietly))
11387 (gnus-summary-next-group nil)
11388 (gnus-summary-exit))))
11390 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11391 "Mark all articles in this newsgroup as read, and then exit.
11392 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11393 instead, which marks only unread articles as read."
11395 (gnus-summary-catchup-and-exit t quietly))
11397 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11398 "Mark all articles in this group as read and select the next group.
11399 If given a prefix, mark all articles, unread as well as ticked, as
11403 (gnus-summary-catchup all))
11404 (gnus-summary-next-group))
11406 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11407 "Mark all articles in this group as read and select the previous group.
11408 If given a prefix, mark all articles, unread as well as ticked, as
11412 (gnus-summary-catchup all))
11413 (gnus-summary-next-group nil nil t))
11419 (defmacro gnus-with-article (article &rest forms)
11420 "Select ARTICLE and perform FORMS in the original article buffer.
11421 Then replace the article with the result."
11423 ;; We don't want the article to be marked as read.
11424 (let (gnus-mark-article-hook)
11425 (gnus-summary-select-article t t nil ,article))
11426 (set-buffer gnus-original-article-buffer)
11428 (if (not (gnus-check-backend-function
11429 'request-replace-article (car gnus-article-current)))
11430 (gnus-message 5 "Read-only group; not replacing")
11431 (unless (gnus-request-replace-article
11432 ,article (car gnus-article-current)
11433 (current-buffer) t)
11434 (error "Couldn't replace article")))
11435 ;; The cache and backlog have to be flushed somewhat.
11436 (when gnus-keep-backlog
11437 (gnus-backlog-remove-article
11438 (car gnus-article-current) (cdr gnus-article-current)))
11439 (when gnus-use-cache
11440 (gnus-cache-update-article
11441 (car gnus-article-current) (cdr gnus-article-current)))))
11443 (put 'gnus-with-article 'lisp-indent-function 1)
11444 (put 'gnus-with-article 'edebug-form-spec '(form body))
11446 ;; Thread-based commands.
11448 (defun gnus-summary-articles-in-thread (&optional article)
11449 "Return a list of all articles in the current thread.
11450 If ARTICLE is non-nil, return all articles in the thread that starts
11451 with that article."
11452 (let* ((article (or article (gnus-summary-article-number)))
11453 (data (gnus-data-find-list article))
11454 (top-level (gnus-data-level (car data)))
11456 (cond ((null gnus-thread-operation-ignore-subject)
11457 (gnus-simplify-subject-re
11458 (mail-header-subject (gnus-data-header (car data)))))
11459 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11460 (gnus-simplify-subject-fuzzy
11461 (mail-header-subject (gnus-data-header (car data)))))
11463 (end-point (save-excursion
11464 (goto-char (gnus-data-pos (car data)))
11465 (if (gnus-summary-go-to-next-thread)
11466 (point) (point-max))))
11469 (< (gnus-data-pos (car data)) end-point))
11470 (when (or (not top-subject)
11471 (string= top-subject
11472 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11473 (gnus-simplify-subject-fuzzy
11474 (mail-header-subject
11475 (gnus-data-header (car data))))
11476 (gnus-simplify-subject-re
11477 (mail-header-subject
11478 (gnus-data-header (car data)))))))
11479 (push (gnus-data-number (car data)) articles))
11480 (unless (and (setq data (cdr data))
11481 (> (gnus-data-level (car data)) top-level))
11483 ;; Return the list of articles.
11484 (nreverse articles)))
11486 (defun gnus-summary-rethread-current ()
11487 "Rethread the thread the current article is part of."
11489 (let* ((gnus-show-threads t)
11490 (article (gnus-summary-article-number))
11491 (id (mail-header-id (gnus-summary-article-header)))
11492 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11494 (error "No article on the current line"))
11495 (gnus-rebuild-thread id)
11496 (gnus-summary-goto-subject article)))
11498 (defun gnus-summary-reparent-thread ()
11499 "Make the current article child of the marked (or previous) article.
11501 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11502 is non-nil or the Subject: of both articles are the same."
11504 (unless (not (gnus-group-read-only-p))
11505 (error "The current newsgroup does not support article editing"))
11506 (unless (<= (length gnus-newsgroup-processable) 1)
11507 (error "No more than one article may be marked"))
11508 (let ((child (gnus-summary-article-number))
11509 ;; First grab the marked article, otherwise one line up.
11510 (parent (if (not (null gnus-newsgroup-processable))
11511 (car gnus-newsgroup-processable)
11513 (if (eq (forward-line -1) 0)
11514 (gnus-summary-article-number)
11515 (error "Beginning of summary buffer"))))))
11516 (gnus-summary-reparent-children parent (list child))))
11518 (defun gnus-summary-reparent-children (parent children)
11519 "Make PARENT the parent of CHILDREN.
11520 When called interactively, PARENT is the current article and CHILDREN
11521 are the process-marked articles."
11523 (list (gnus-summary-article-number)
11524 (gnus-summary-work-articles nil)))
11525 (dolist (child children)
11526 (save-window-excursion
11527 (let ((gnus-article-buffer " *reparent*"))
11528 (unless (not (eq parent child))
11529 (error "An article may not be self-referential"))
11530 (let ((message-id (mail-header-id
11531 (gnus-summary-article-header parent))))
11532 (unless (and message-id (not (equal message-id "")))
11533 (error "No message-id in desired parent"))
11534 (gnus-with-article child
11536 (goto-char (point-min))
11537 (message-narrow-to-head)
11538 (if (re-search-forward "^References: " nil t)
11540 (re-search-forward "^[^ \t]" nil t)
11543 (insert " " message-id))
11544 (insert "References: " message-id "\n"))))
11545 (set-buffer gnus-summary-buffer)
11546 (gnus-summary-unmark-all-processable)
11547 (gnus-summary-update-article child)
11548 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11549 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11550 (gnus-summary-rethread-current)
11551 (gnus-message 3 "Article %d is now the child of article %d"
11554 (defun gnus-summary-toggle-threads (&optional arg)
11555 "Toggle showing conversation threads.
11556 If ARG is positive number, turn showing conversation threads on."
11558 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11559 (setq gnus-show-threads
11560 (if (null arg) (not gnus-show-threads)
11561 (> (prefix-numeric-value arg) 0)))
11562 (gnus-summary-prepare)
11563 (gnus-summary-goto-subject current)
11564 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11565 (gnus-summary-position-point)))
11568 (if (fboundp 'remove-overlays)
11569 (defalias 'gnus-remove-overlays 'remove-overlays)
11570 (defun gnus-remove-overlays (beg end name val)
11571 "Clear BEG and END of overlays whose property NAME has value VAL.
11572 For compatibility with XEmacs."
11573 (dolist (ov (gnus-overlays-in beg end))
11574 (when (eq (gnus-overlay-get ov name) val)
11575 (gnus-delete-overlay ov))))))
11577 (defun gnus-summary-show-all-threads ()
11578 "Show all threads."
11580 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11581 (gnus-summary-position-point))
11583 (defsubst gnus-summary--inv (p)
11584 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11586 (defun gnus-summary-show-thread ()
11587 "Show thread subtrees.
11588 Returns nil if no thread was there to be shown."
11590 (let* ((orig (point))
11591 (end (point-at-eol))
11592 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11593 ;; Leave point at bol
11594 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11596 (if (fboundp 'next-single-char-property-change)
11597 ;; Note: XEmacs version of n-s-c-p-c may return nil
11598 (or (next-single-char-property-change end 'invisible)
11603 (eq (get-char-property (point) 'invisible)
11607 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11609 (gnus-summary-position-point)
11612 (defun gnus-summary-maybe-hide-threads ()
11613 "If requested, hide the threads that should be hidden."
11614 (when (and gnus-show-threads
11615 gnus-thread-hide-subtree)
11616 (gnus-summary-hide-all-threads
11617 (if (or (consp gnus-thread-hide-subtree)
11618 (functionp gnus-thread-hide-subtree))
11619 (gnus-make-predicate gnus-thread-hide-subtree)
11622 ;;; Hiding predicates.
11624 (defun gnus-article-unread-p (header)
11625 (memq (mail-header-number header) gnus-newsgroup-unreads))
11627 (defun gnus-article-unseen-p (header)
11628 (memq (mail-header-number header) gnus-newsgroup-unseen))
11630 (defun gnus-map-articles (predicate articles)
11631 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11632 (apply 'gnus-or (mapcar predicate
11633 (mapcar (lambda (number)
11634 (gnus-summary-article-header number))
11637 (defun gnus-summary-hide-all-threads (&optional predicate)
11638 "Hide all thread subtrees.
11639 If PREDICATE is supplied, threads that satisfy this predicate
11640 will not be hidden."
11643 (goto-char (point-min))
11648 (when (zerop (mod count 1000))
11649 (message "Hiding all threads... %d" count))
11650 (when (or (not predicate)
11652 predicate (gnus-summary-article-children)))
11653 (gnus-summary-hide-thread))
11654 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11655 (gnus-summary-position-point))
11657 (defun gnus-summary-hide-thread ()
11658 "Hide thread subtrees.
11659 If PREDICATE is supplied, threads that satisfy this predicate
11660 will not be hidden.
11661 Returns nil if no threads were there to be hidden."
11663 (let ((start (point))
11664 (starteol (line-end-position))
11665 (article (gnus-summary-article-number)))
11667 ;; Go forward until either the buffer ends or the subthread ends.
11668 (when (and (not (eobp))
11669 (or (zerop (gnus-summary-next-thread 1 t))
11670 (goto-char (point-max))))
11671 (if (and (> (point) start)
11672 ;; FIXME: this should actually search for a non-invisible \n.
11673 (search-backward "\n" start t))
11675 (when (> (point) starteol)
11676 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11677 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11678 (gnus-overlay-put ol 'invisible 'gnus-sum)
11679 (gnus-overlay-put ol 'evaporate t)))
11680 (gnus-summary-goto-subject article)
11681 (when (> start (point))
11682 (message "Hiding the thread moved us backwards, aborting!")
11683 (goto-char (point-max))))
11687 (defun gnus-summary-go-to-next-thread (&optional previous)
11688 "Go to the same level (or less) next thread.
11689 If PREVIOUS is non-nil, go to previous thread instead.
11690 Return the article number moved to, or nil if moving was impossible."
11691 (let ((level (gnus-summary-thread-level))
11692 (way (if previous -1 1))
11695 (while (and (not (eobp))
11696 (< level (gnus-summary-thread-level)))
11697 (forward-line way))
11704 (gnus-summary-article-number)
11705 (goto-char beg)))))
11707 (defun gnus-summary-next-thread (n &optional silent)
11708 "Go to the same level next N'th thread.
11709 If N is negative, search backward instead.
11710 Returns the difference between N and the number of skips actually
11713 If SILENT, don't output messages."
11715 (let ((backward (< n 0))
11717 (while (and (> n 0)
11718 (gnus-summary-go-to-next-thread backward))
11721 (gnus-summary-position-point))
11722 (when (and (not silent) (/= 0 n))
11723 (gnus-message 7 "No more threads"))
11726 (defun gnus-summary-prev-thread (n)
11727 "Go to the same level previous N'th thread.
11728 Returns the difference between N and the number of skips actually
11731 (gnus-summary-next-thread (- n)))
11733 (defun gnus-summary-go-down-thread ()
11734 "Go down one level in the current thread."
11735 (let ((children (gnus-summary-article-children)))
11737 (gnus-summary-goto-subject (car children)))))
11739 (defun gnus-summary-go-up-thread ()
11740 "Go up one level in the current thread."
11741 (let ((parent (gnus-summary-article-parent)))
11743 (gnus-summary-goto-subject parent))))
11745 (defun gnus-summary-down-thread (n)
11746 "Go down thread N steps.
11747 If N is negative, go up instead.
11748 Returns the difference between N and how many steps down that were
11753 (while (and (> n 0)
11754 (if up (gnus-summary-go-up-thread)
11755 (gnus-summary-go-down-thread)))
11757 (gnus-summary-position-point)
11759 (gnus-message 7 "Can't go further"))
11762 (defun gnus-summary-up-thread (n)
11763 "Go up thread N steps.
11764 If N is negative, go down instead.
11765 Returns the difference between N and how many steps down that were
11768 (gnus-summary-down-thread (- n)))
11770 (defun gnus-summary-top-thread ()
11771 "Go to the top of the thread."
11773 (while (gnus-summary-go-up-thread))
11774 (gnus-summary-article-number))
11776 (defun gnus-summary-expire-thread ()
11777 "Mark articles under current thread as expired."
11779 (gnus-summary-kill-thread 0))
11781 (defun gnus-summary-kill-thread (&optional unmark)
11782 "Mark articles under current thread as read.
11783 If the prefix argument is positive, remove any kinds of marks.
11784 If the prefix argument is zero, mark thread as expired.
11785 If the prefix argument is negative, tick articles instead."
11788 (setq unmark (prefix-numeric-value unmark)))
11789 (let ((articles (gnus-summary-articles-in-thread))
11790 (hide (or (null unmark) (= unmark 0))))
11792 ;; Expand the thread.
11793 (gnus-summary-show-thread)
11794 ;; Mark all the articles.
11796 (gnus-summary-goto-subject (car articles))
11797 (cond ((null unmark)
11798 (gnus-summary-mark-article-as-read gnus-killed-mark))
11800 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11802 (gnus-summary-mark-article nil gnus-expirable-mark))
11804 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11805 (setq articles (cdr articles))))
11806 ;; Hide killed subtrees when hide is true.
11808 gnus-thread-hide-killed
11809 (gnus-summary-hide-thread))
11810 ;; If hide is t, go to next unread subject.
11812 ;; Go to next unread subject.
11813 (gnus-summary-next-subject 1 t)))
11814 (gnus-set-mode-line 'summary))
11816 ;; Summary sorting commands
11818 (defun gnus-summary-sort-by-number (&optional reverse)
11819 "Sort the summary buffer by article number.
11820 Argument REVERSE means reverse order."
11822 (gnus-summary-sort 'number reverse))
11824 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11825 "Sort the summary buffer by most recent article number.
11826 Argument REVERSE means reverse order."
11828 (gnus-summary-sort 'most-recent-number reverse))
11830 (defun gnus-summary-sort-by-random (&optional reverse)
11831 "Randomize the order in the summary buffer.
11832 Argument REVERSE means to randomize in reverse order."
11834 (gnus-summary-sort 'random reverse))
11836 (defun gnus-summary-sort-by-author (&optional reverse)
11837 "Sort the summary buffer by author name alphabetically.
11838 If `case-fold-search' is non-nil, case of letters is ignored.
11839 Argument REVERSE means reverse order."
11841 (gnus-summary-sort 'author reverse))
11843 (defun gnus-summary-sort-by-recipient (&optional reverse)
11844 "Sort the summary buffer by recipient name alphabetically.
11845 If `case-fold-search' is non-nil, case of letters is ignored.
11846 Argument REVERSE means reverse order."
11848 (gnus-summary-sort 'recipient reverse))
11850 (defun gnus-summary-sort-by-subject (&optional reverse)
11851 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11852 If `case-fold-search' is non-nil, case of letters is ignored.
11853 Argument REVERSE means reverse order."
11855 (gnus-summary-sort 'subject reverse))
11857 (defun gnus-summary-sort-by-date (&optional reverse)
11858 "Sort the summary buffer by date.
11859 Argument REVERSE means reverse order."
11861 (gnus-summary-sort 'date reverse))
11863 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11864 "Sort the summary buffer by most recent date.
11865 Argument REVERSE means reverse order."
11867 (gnus-summary-sort 'most-recent-date reverse))
11869 (defun gnus-summary-sort-by-score (&optional reverse)
11870 "Sort the summary buffer by score.
11871 Argument REVERSE means reverse order."
11873 (gnus-summary-sort 'score reverse))
11875 (defun gnus-summary-sort-by-lines (&optional reverse)
11876 "Sort the summary buffer by the number of lines.
11877 Argument REVERSE means reverse order."
11879 (gnus-summary-sort 'lines reverse))
11881 (defun gnus-summary-sort-by-chars (&optional reverse)
11882 "Sort the summary buffer by article length.
11883 Argument REVERSE means reverse order."
11885 (gnus-summary-sort 'chars reverse))
11887 (defun gnus-summary-sort-by-original (&optional reverse)
11888 "Sort the summary buffer using the default sorting method.
11889 Argument REVERSE means reverse order."
11891 (let* ((inhibit-read-only t)
11892 (gnus-summary-prepare-hook nil))
11893 ;; We do the sorting by regenerating the threads.
11894 (gnus-summary-prepare)
11895 ;; Hide subthreads if needed.
11896 (gnus-summary-maybe-hide-threads)))
11898 (defun gnus-summary-sort (predicate reverse)
11899 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11900 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11901 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11902 (gnus-thread-sort-functions
11907 (gnus-sort-gathered-threads-function
11908 gnus-thread-sort-functions)
11909 (gnus-article-sort-functions
11913 (,article t2 t1))))
11914 (inhibit-read-only t)
11915 (gnus-summary-prepare-hook nil))
11916 ;; We do the sorting by regenerating the threads.
11917 (gnus-summary-prepare)
11918 ;; Hide subthreads if needed.
11919 (gnus-summary-maybe-hide-threads)))
11921 ;; Summary saving commands.
11923 (defun gnus-summary-save-article (&optional n not-saved)
11924 "Save the current article using the default saver function.
11925 If N is a positive number, save the N next articles.
11926 If N is a negative number, save the N previous articles.
11927 If N is nil and any articles have been marked with the process mark,
11928 save those articles instead.
11929 The variable `gnus-default-article-saver' specifies the saver function.
11931 If the optional second argument NOT-SAVED is non-nil, articles saved
11932 will not be marked as saved."
11934 (require 'gnus-art)
11935 (let* ((articles (gnus-summary-work-articles n))
11936 (save-buffer (save-excursion
11937 (nnheader-set-temp-buffer " *Gnus Save*")))
11938 (num (length articles))
11939 ;; Whether to save decoded articles or raw articles.
11940 (decode (when gnus-article-save-coding-system
11941 (get gnus-default-article-saver :decode)))
11942 ;; When saving many articles in a single file, use the other
11943 ;; function to save articles other than the first one.
11944 (saver2 (get gnus-default-article-saver :function))
11945 (gnus-prompt-before-saving (if saver2
11947 gnus-prompt-before-saving))
11948 (gnus-default-article-saver gnus-default-article-saver)
11950 (dolist (article articles)
11951 (setq header (gnus-summary-article-header article))
11952 (if (not (vectorp header))
11953 ;; This is a pseudo-article.
11954 (if (assq 'name header)
11955 (gnus-copy-file (cdr (assq 'name header)))
11956 (gnus-message 1 "Article %d is unsavable" article))
11957 ;; This is a real article.
11958 (save-window-excursion
11959 (gnus-summary-select-article decode decode nil article)
11960 (gnus-summary-goto-subject article))
11961 (with-current-buffer save-buffer
11963 (insert-buffer-substring (if decode
11964 gnus-article-buffer
11965 gnus-original-article-buffer)))
11966 (setq file (gnus-article-save save-buffer file num))
11967 (gnus-summary-remove-process-mark article)
11969 (gnus-summary-set-saved-mark article)))
11971 (setq gnus-default-article-saver saver2
11973 (gnus-kill-buffer save-buffer)
11974 (gnus-summary-position-point)
11975 (gnus-set-mode-line 'summary)
11978 (defun gnus-summary-pipe-output (&optional n sym)
11979 "Pipe the current article to a subprocess.
11980 If N is a positive number, pipe the N next articles.
11981 If N is a negative number, pipe the N previous articles.
11982 If N is nil and any articles have been marked with the process mark,
11983 pipe those articles instead.
11984 The default command to which articles are piped is specified by the
11985 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11986 will be prompted for the command.
11988 The properties `:decode' and `:headers' that are put to the function
11989 symbol `gnus-summary-save-in-pipe' control whether this function
11990 decodes articles and what headers to keep (see the doc string for the
11991 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11992 is neither omitted nor the symbol `r', force including all headers
11993 regardless of the `:headers' property. If it is the symbol `r',
11994 articles that are not decoded and include all headers will be piped
11995 no matter what the properties `:decode' and `:headers' are."
11996 (interactive (gnus-interactive "P\ny"))
11997 (require 'gnus-art)
11998 (let* ((articles (gnus-summary-work-articles n))
11999 (result-buffer "*Shell Command Output*")
12000 (all-headers (not (memq sym '(nil r))))
12001 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12003 (headers (get 'gnus-summary-save-in-pipe :headers))
12005 (unless (numberp (car articles))
12006 (error "No article to pipe"))
12007 (setq command (gnus-read-shell-command
12008 (concat "Shell command on "
12010 (format "these %d articles" (length articles))
12013 gnus-summary-pipe-output-default-command))
12014 (when (string-equal command "")
12015 (error "A command is required"))
12017 (put 'gnus-summary-save-in-pipe :headers nil))
12020 (gnus-summary-goto-subject (pop articles))
12021 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12022 (when (and (get-buffer result-buffer)
12023 (not (zerop (buffer-size (get-buffer result-buffer)))))
12024 (setq result (concat result (with-current-buffer result-buffer
12025 (buffer-string))))))
12026 (put 'gnus-summary-save-in-pipe :headers headers))
12027 (unless (zerop (length result))
12028 (if (with-current-buffer (get-buffer-create result-buffer)
12032 (and (= (count-lines (point-min) (point)) 1)
12035 (<= (current-column)
12036 (window-width (minibuffer-window)))))
12037 (goto-char (point-min))))
12038 (message "%s" (substring result 0 -1))
12040 (gnus-configure-windows 'pipe)))))
12042 (defun gnus-summary-save-article-mail (&optional arg)
12043 "Append the current article to a Unix mail box file.
12044 If N is a positive number, save the N next articles.
12045 If N is a negative number, save the N previous articles.
12046 If N is nil and any articles have been marked with the process mark,
12047 save those articles instead."
12049 (require 'gnus-art)
12050 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12051 (gnus-summary-save-article arg)))
12053 (defun gnus-summary-save-article-rmail (&optional arg)
12054 "Append the current article to an rmail file.
12055 If N is a positive number, save the N next articles.
12056 If N is a negative number, save the N previous articles.
12057 If N is nil and any articles have been marked with the process mark,
12058 save those articles instead."
12060 (require 'gnus-art)
12061 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12062 (gnus-summary-save-article arg)))
12064 (defun gnus-summary-save-article-file (&optional arg)
12065 "Append the current article to a file.
12066 If N is a positive number, save the N next articles.
12067 If N is a negative number, save the N previous articles.
12068 If N is nil and any articles have been marked with the process mark,
12069 save those articles instead."
12071 (require 'gnus-art)
12072 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12073 (gnus-summary-save-article arg)))
12075 (defun gnus-summary-write-article-file (&optional arg)
12076 "Write the current article to a file, deleting the previous file.
12077 If N is a positive number, save the N next articles.
12078 If N is a negative number, save the N previous articles.
12079 If N is nil and any articles have been marked with the process mark,
12080 save those articles instead."
12082 (require 'gnus-art)
12083 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12084 (gnus-summary-save-article arg)))
12086 (defun gnus-summary-save-article-body-file (&optional arg)
12087 "Append the current article body to a file.
12088 If N is a positive number, save the N next articles.
12089 If N is a negative number, save the N previous articles.
12090 If N is nil and any articles have been marked with the process mark,
12091 save those articles instead."
12093 (require 'gnus-art)
12094 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12095 (gnus-summary-save-article arg)))
12097 (defun gnus-summary-write-article-body-file (&optional arg)
12098 "Write the current article body to a file, deleting the previous file.
12099 If N is a positive number, save the N next articles.
12100 If N is a negative number, save the N previous articles.
12101 If N is nil and any articles have been marked with the process mark,
12102 save those articles instead."
12104 (require 'gnus-art)
12105 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12106 (gnus-summary-save-article arg)))
12108 (defun gnus-summary-muttprint (&optional arg)
12109 "Print the current article using Muttprint.
12110 If N is a positive number, save the N next articles.
12111 If N is a negative number, save the N previous articles.
12112 If N is nil and any articles have been marked with the process mark,
12113 save those articles instead."
12115 (require 'gnus-art)
12116 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12117 (gnus-summary-save-article arg t)))
12119 (defun gnus-summary-pipe-message (program)
12120 "Pipe the current article through PROGRAM."
12121 (interactive "sProgram: ")
12122 (gnus-summary-select-article)
12123 (let ((mail-header-separator ""))
12124 (gnus-eval-in-buffer-window gnus-article-buffer
12127 (let ((start (window-start))
12128 (inhibit-read-only t))
12129 (message-pipe-buffer-body program)
12130 (set-window-start (get-buffer-window (current-buffer)) start))))))
12132 (defun gnus-get-split-value (methods)
12133 "Return a value based on the split METHODS."
12134 (let (split-name method result match)
12136 (with-current-buffer gnus-original-article-buffer
12138 (nnheader-narrow-to-headers)
12139 (while (and methods (not split-name))
12140 (goto-char (point-min))
12141 (setq method (pop methods))
12142 (setq match (car method))
12145 ;; Regular expression.
12147 (re-search-forward match nil t)))
12152 (setq result (funcall match gnus-newsgroup-name))))
12157 (setq result (eval match)))))
12158 (setq split-name (cdr method))
12159 (cond ((stringp result)
12160 (push (expand-file-name
12161 result gnus-article-save-directory)
12164 (setq split-name (append result split-name)))))))))
12165 (nreverse split-name)))
12167 (defun gnus-valid-move-group-p (group)
12168 (and (symbolp group)
12170 (symbol-name group)
12171 (symbol-value group)
12172 (gnus-get-function (gnus-find-method-for-group
12173 (symbol-name group)) 'request-accept-article t)))
12175 (defun gnus-read-move-group-name (prompt default articles prefix)
12176 "Read a group name."
12177 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12178 (minibuffer-confirm-incomplete nil) ; XEmacs
12182 (if (> (length articles) 1)
12183 (format "these %d articles" (length articles))
12188 (gnus-group-completing-read
12190 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12191 nil prefix nil default))
12192 ((= 1 (length split-name))
12193 (gnus-group-completing-read
12195 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12196 nil prefix 'gnus-group-history (car split-name)))
12198 (gnus-completing-read
12199 prom (nreverse split-name) nil nil 'gnus-group-history))))
12200 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12203 (if (or (string= to-newsgroup "")
12204 (string= to-newsgroup prefix))
12205 (setq to-newsgroup default))
12206 (unless to-newsgroup
12207 (error "No group name entered"))
12208 (setq encoded (mm-encode-coding-string
12210 (gnus-group-name-charset to-method to-newsgroup)))
12211 (or (gnus-active encoded)
12212 (gnus-activate-group encoded nil nil to-method)
12213 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12215 (or (and (gnus-request-create-group encoded to-method)
12216 (gnus-activate-group encoded nil nil to-method)
12217 (gnus-subscribe-group encoded))
12218 (error "Couldn't create group %s" to-newsgroup)))
12219 (error "No such group: %s" to-newsgroup))
12222 (defvar gnus-summary-save-parts-counter)
12223 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12225 (defun gnus-summary-save-parts (type dir n &optional reverse)
12226 "Save parts matching TYPE to DIR.
12227 If REVERSE, save parts that do not match TYPE."
12229 (list (read-string "Save parts of type: "
12230 (or (car gnus-summary-save-parts-type-history)
12231 gnus-summary-save-parts-default-mime)
12232 'gnus-summary-save-parts-type-history)
12233 (setq gnus-summary-save-parts-last-directory
12234 (read-directory-name "Save to directory: "
12235 gnus-summary-save-parts-last-directory
12237 current-prefix-arg))
12238 (gnus-summary-iterate n
12239 (let ((gnus-display-mime-function nil)
12240 gnus-article-prepare-hook
12241 gnus-article-decode-hook
12242 gnus-display-mime-function
12244 (gnus-inhibit-treatment t))
12245 (gnus-summary-select-article))
12246 (with-current-buffer gnus-article-buffer
12247 (let ((handles (or gnus-article-mime-handles
12248 (mm-dissect-buffer nil gnus-article-loose-mime)
12249 (and gnus-article-emulate-mime
12251 (gnus-summary-save-parts-counter 1))
12253 (gnus-summary-save-parts-1 type dir handles reverse)
12254 (unless gnus-article-mime-handles ;; Don't destroy this case.
12255 (mm-destroy-parts handles)))))))
12257 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12258 (if (stringp (car handle))
12259 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12262 (not (string-match type (mm-handle-media-type handle)))
12263 (string-match type (mm-handle-media-type handle)))
12264 (let ((file (expand-file-name
12266 mm-file-name-rewrite-functions
12267 (file-name-nondirectory
12269 (mm-handle-filename handle)
12270 (format "%s.%d.%d" gnus-newsgroup-name
12271 (cdr gnus-article-current)
12272 gnus-summary-save-parts-counter))))
12274 (incf gnus-summary-save-parts-counter)
12275 (unless (file-exists-p file)
12276 (mm-save-part-to-file handle file))))))
12278 ;; Summary extract commands
12280 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12281 (let ((inhibit-read-only t)
12282 (article (gnus-summary-article-number))
12284 (unless (gnus-summary-goto-subject article)
12285 (error "No such article: %d" article))
12286 (gnus-summary-position-point)
12287 ;; If all commands are to be bunched up on one line, we collect
12289 (unless gnus-view-pseudos-separately
12290 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12293 (setq action (cdr (assq 'action (car ps))))
12294 (setq files (list (cdr (assq 'name (car ps)))))
12295 (while (and ps (cdr ps)
12296 (string= (or action "1")
12297 (or (cdr (assq 'action (cadr ps))) "2")))
12298 (push (cdr (assq 'name (cadr ps))) files)
12299 (setcdr ps (cddr ps)))
12301 (when (not (string-match "%s" action))
12304 (when (assq 'execute (car ps))
12305 (setcdr (assq 'execute (car ps))
12306 (funcall (if (string-match "%s" action)
12313 (shell-quote-argument f)))
12315 (setq ps (cdr ps)))))
12316 (if (and gnus-view-pseudos (not not-view))
12318 (when (assq 'execute (car pslist))
12319 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12320 (eq gnus-view-pseudos 'not-confirm)))
12321 (setq pslist (cdr pslist)))
12324 (setq after-article (or (cdr (assq 'article (car pslist)))
12325 (gnus-summary-article-number)))
12326 (gnus-summary-goto-subject after-article)
12329 (insert " " (file-name-nondirectory
12330 (cdr (assq 'name (car pslist))))
12331 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12333 (forward-line -1) ; back to `b'
12334 (gnus-add-text-properties
12335 b (1- e) (list 'gnus-number gnus-reffed-article-number
12336 gnus-mouse-face-prop gnus-mouse-face))
12338 after-article gnus-reffed-article-number
12339 gnus-unread-mark b (car pslist) 0 (- e b))
12340 (setq gnus-newsgroup-unreads
12341 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12342 gnus-reffed-article-number))
12343 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12344 (setq pslist (cdr pslist)))))))
12346 (defun gnus-pseudos< (p1 p2)
12347 (let ((c1 (cdr (assq 'action p1)))
12348 (c2 (cdr (assq 'action p2))))
12349 (and c1 c2 (string< c1 c2))))
12351 (defun gnus-request-pseudo-article (props)
12352 (cond ((assq 'execute props)
12353 (gnus-execute-command (cdr (assq 'execute props)))))
12354 (let ((gnus-current-article (gnus-summary-article-number)))
12355 (gnus-run-hooks 'gnus-mark-article-hook)))
12357 (defun gnus-execute-command (command &optional automatic)
12359 (gnus-article-setup-buffer)
12360 (set-buffer gnus-article-buffer)
12361 (setq buffer-read-only nil)
12362 (let ((command (if automatic command
12363 (read-string "Command: " (cons command 0)))))
12365 (insert "$ " command "\n\n")
12366 (if gnus-view-pseudo-asynchronously
12367 (start-process "gnus-execute" (current-buffer) shell-file-name
12368 shell-command-switch command)
12369 (call-process shell-file-name nil t nil
12370 shell-command-switch command)))))
12372 ;; Summary kill commands.
12374 (defun gnus-summary-edit-global-kill (article)
12375 "Edit the \"global\" kill file."
12376 (interactive (list (gnus-summary-article-number)))
12377 (gnus-group-edit-global-kill article))
12379 (defun gnus-summary-edit-local-kill ()
12380 "Edit a local kill file applied to the current newsgroup."
12382 (setq gnus-current-headers (gnus-summary-article-header))
12383 (gnus-group-edit-local-kill
12384 (gnus-summary-article-number) gnus-newsgroup-name))
12386 ;;; Header reading.
12388 (defun gnus-read-header (id &optional header)
12389 "Read the headers of article ID and enter them into the Gnus system."
12390 (let ((group gnus-newsgroup-name)
12391 (gnus-override-method
12393 gnus-override-method
12394 (and (gnus-news-group-p gnus-newsgroup-name)
12395 (car (gnus-refer-article-methods)))))
12397 ;; First we check to see whether the header in question is already
12400 ;; This is a Message-ID.
12401 (setq header (or header (gnus-id-to-header id)))
12402 ;; This is an article number.
12403 (setq header (or header (gnus-summary-article-header id))))
12405 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12406 ;; We have found the header.
12408 ;; We have to really fetch the header to this article.
12409 (with-current-buffer nntp-server-buffer
12410 (when (setq where (gnus-request-head id group))
12411 (nnheader-fold-continuation-lines)
12412 (goto-char (point-max))
12414 (goto-char (point-min))
12418 ((cdr where) (cdr where))
12419 (header (mail-header-number header))
12420 (t gnus-reffed-article-number))
12422 (insert " Article retrieved.\n"))
12423 (if (or (not where)
12424 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12425 () ; Malformed head.
12426 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12427 (when (and (stringp id)
12429 (not (string= (gnus-group-real-name group)
12431 (not (gnus-server-equal gnus-override-method
12432 (gnus-group-method group)))))
12433 ;; If we fetched by Message-ID and the article came from
12434 ;; a different group (or server), we fudge some bogus
12435 ;; article numbers for this article.
12436 (mail-header-set-number header gnus-reffed-article-number))
12437 (with-current-buffer gnus-summary-buffer
12438 (decf gnus-reffed-article-number)
12439 (gnus-remove-header (mail-header-number header))
12440 (push header gnus-newsgroup-headers)
12441 (setq gnus-current-headers header)
12442 (push (mail-header-number header) gnus-newsgroup-limit)))
12445 (defun gnus-remove-header (number)
12446 "Remove header NUMBER from `gnus-newsgroup-headers'."
12447 (if (and gnus-newsgroup-headers
12448 (= number (mail-header-number (car gnus-newsgroup-headers))))
12449 (pop gnus-newsgroup-headers)
12450 (let ((headers gnus-newsgroup-headers))
12451 (while (and (cdr headers)
12452 (not (= number (mail-header-number (cadr headers)))))
12454 (when (cdr headers)
12455 (setcdr headers (cddr headers))))))
12458 ;;; summary highlights
12461 (defun gnus-highlight-selected-summary ()
12462 "Highlight selected article in summary buffer."
12463 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12464 (when gnus-summary-selected-face
12466 (let* ((beg (point-at-bol))
12467 (end (point-at-eol))
12468 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12469 (from (if (get-text-property beg gnus-mouse-face-prop)
12471 (or (next-single-property-change
12472 beg gnus-mouse-face-prop nil end)
12477 (or (next-single-property-change
12478 from gnus-mouse-face-prop nil end)
12480 ;; If no mouse-face prop on line we will have to = from = end,
12481 ;; so we highlight the entire line instead.
12482 (when (= (+ to 2) from)
12485 (if gnus-newsgroup-selected-overlay
12486 ;; Move old overlay.
12488 gnus-newsgroup-selected-overlay from to (current-buffer))
12489 ;; Create new overlay.
12491 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12492 'face gnus-summary-selected-face))))))
12494 (defvar gnus-summary-highlight-line-cached nil)
12495 (defvar gnus-summary-highlight-line-trigger nil)
12497 (defun gnus-summary-highlight-line-0 ()
12498 (if (and (eq gnus-summary-highlight-line-trigger
12499 gnus-summary-highlight)
12500 gnus-summary-highlight-line-cached)
12501 gnus-summary-highlight-line-cached
12502 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12503 gnus-summary-highlight-line-cached
12504 (let* ((cond (list 'cond))
12506 (list gnus-summary-highlight))
12508 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12512 (gnus-byte-compile (list 'lambda nil cond))))))
12514 (defun gnus-summary-highlight-line ()
12515 "Highlight current line according to `gnus-summary-highlight'."
12516 (let* ((beg (point-at-bol))
12517 (article (or (gnus-summary-article-number) gnus-current-article))
12518 (score (or (cdr (assq article
12519 gnus-newsgroup-scored))
12520 gnus-summary-default-score 0))
12521 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12522 (inhibit-read-only t)
12523 (default gnus-summary-default-score)
12524 (default-high gnus-summary-default-high-score)
12525 (default-low gnus-summary-default-low-score)
12526 (uncached (and gnus-summary-use-undownloaded-faces
12527 (memq article gnus-newsgroup-undownloaded)
12528 (not (memq article gnus-newsgroup-cached)))))
12529 (let ((face (funcall (gnus-summary-highlight-line-0))))
12530 (unless (eq face (get-text-property beg 'face))
12531 (gnus-put-text-property-excluding-characters-with-faces
12532 beg (point-at-eol) 'face
12533 (setq face (if (boundp face) (symbol-value face) face)))
12534 (when gnus-summary-highlight-line-function
12535 (funcall gnus-summary-highlight-line-function article face))))))
12537 (defun gnus-update-read-articles (group unread &optional compute)
12538 "Update the list of read articles in GROUP.
12539 UNREAD is a sorted list."
12540 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12541 (info (gnus-get-info group))
12544 (if (or (not info) (not active))
12545 ;; There is no info on this group if it was, in fact,
12546 ;; killed. Gnus stores no information on killed groups, so
12547 ;; there's nothing to be done.
12548 ;; One could store the information somewhere temporarily,
12549 ;; perhaps... Hmmm...
12551 ;; Remove any negative articles numbers.
12552 (while (and unread (< (car unread) 0))
12553 (setq unread (cdr unread)))
12554 ;; Remove any expired article numbers
12555 (while (and unread (< (car unread) (car active)))
12556 (setq unread (cdr unread)))
12557 ;; Compute the ranges of read articles by looking at the list of
12558 ;; unread articles.
12560 (when (/= (car unread) prev)
12561 (push (if (= prev (1- (car unread))) prev
12562 (cons prev (1- (car unread))))
12564 (setq prev (1+ (car unread)))
12565 (setq unread (cdr unread)))
12566 (when (<= prev (cdr active))
12567 (push (cons prev (cdr active)) read))
12568 (setq read (if (> (length read) 1) (nreverse read) read))
12573 ;; Propagate the read marks to the backend.
12574 (when (and (or gnus-propagate-marks
12575 (gnus-method-option-p
12576 (gnus-find-method-for-group group)
12578 (gnus-check-backend-function 'request-set-mark group))
12579 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12580 (add (gnus-remove-from-range read (gnus-info-read info))))
12582 (unless (gnus-check-group group)
12583 (error "Can't open server for %s" group))
12584 (gnus-request-set-mark
12585 group (delq nil (list (if add (list add 'add '(read)))
12586 (if del (list del 'del '(read))))))
12588 `(gnus-request-set-mark
12591 (if del (list del 'add '(read)))
12592 (if add (list add 'del '(read))))))))))
12593 (set-buffer gnus-group-buffer)
12594 (gnus-undo-register
12596 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12597 (gnus-info-set-read ',info ',(gnus-info-read info))
12598 (gnus-get-unread-articles-in-group ',info
12599 (gnus-active ,group))
12600 (gnus-group-update-group ,group t)
12602 ;; Enter this list into the group info.
12603 (gnus-info-set-read info read)
12604 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12605 (gnus-get-unread-articles-in-group info (gnus-active group))
12608 (defun gnus-offer-save-summaries ()
12609 "Offer to save all active summary buffers."
12611 ;; Go through all buffers and find all summaries.
12612 (dolist (buffer (buffer-list))
12613 (when (and (setq buffer (buffer-name buffer))
12614 (string-match "Summary" buffer)
12615 (with-current-buffer buffer
12616 ;; We check that this is, indeed, a summary buffer.
12617 (and (eq major-mode 'gnus-summary-mode)
12618 ;; Also make sure this isn't bogus.
12619 gnus-newsgroup-prepared
12620 ;; Also make sure that this isn't a
12621 ;; dead summary buffer.
12622 (not gnus-dead-summary-mode))))
12623 (push buffer buffers)))
12624 ;; Go through all these summary buffers and offer to save them.
12627 (if (eq gnus-interactive-exit 'quiet)
12628 (dolist (buffer buffers)
12629 (switch-to-buffer buffer)
12630 (gnus-summary-exit))
12632 "Update summary buffer %s? "
12634 (switch-to-buffer buf)
12635 (gnus-summary-exit))
12638 (defun gnus-summary-setup-default-charset ()
12639 "Setup newsgroup default charset."
12640 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12641 (setq gnus-newsgroup-charset nil)
12642 (let* ((ignored-charsets
12643 (or gnus-newsgroup-ephemeral-ignored-charsets
12645 (and gnus-newsgroup-name
12646 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12647 gnus-newsgroup-ignored-charsets))))
12648 (setq gnus-newsgroup-charset
12649 (or gnus-newsgroup-ephemeral-charset
12650 (and gnus-newsgroup-name
12651 (gnus-parameter-charset gnus-newsgroup-name))
12652 gnus-default-charset))
12653 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12654 ignored-charsets))))
12660 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12661 "Display the current article buffer fully MIME-buttonized.
12662 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12663 treated as multipart/mixed."
12665 (require 'gnus-art)
12666 (let ((gnus-unbuttonized-mime-types nil)
12667 (gnus-mime-display-multipart-as-mixed show-all-parts))
12668 (gnus-summary-show-article)))
12670 (defun gnus-summary-repair-multipart (article)
12671 "Add a Content-Type header to a multipart article without one."
12672 (interactive (list (gnus-summary-article-number)))
12673 (gnus-with-article article
12674 (message-narrow-to-head)
12675 (message-remove-header "Mime-Version")
12676 (goto-char (point-max))
12677 (insert "Mime-Version: 1.0\n")
12679 (when (search-forward "\n--" nil t)
12680 (let ((separator (buffer-substring (point) (point-at-eol))))
12681 (message-narrow-to-head)
12682 (message-remove-header "Content-Type")
12683 (goto-char (point-max))
12684 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12687 (let (gnus-mark-article-hook)
12688 (gnus-summary-select-article t t nil article)))
12690 (defun gnus-summary-toggle-display-buttonized ()
12691 "Toggle the buttonizing of the article buffer."
12693 (require 'gnus-art)
12694 (if (setq gnus-inhibit-mime-unbuttonizing
12695 (not gnus-inhibit-mime-unbuttonizing))
12696 (let ((gnus-unbuttonized-mime-types nil))
12697 (gnus-summary-show-article))
12698 (gnus-summary-show-article)))
12701 ;;; Generic summary marking commands
12704 (defvar gnus-summary-marking-alist
12705 '((read gnus-del-mark "d")
12706 (unread gnus-unread-mark "u")
12707 (ticked gnus-ticked-mark "!")
12708 (dormant gnus-dormant-mark "?")
12709 (expirable gnus-expirable-mark "e"))
12710 "An alist of names/marks/keystrokes.")
12712 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12713 (defvar gnus-summary-mark-map)
12715 (defun gnus-summary-make-all-marking-commands ()
12716 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12717 (dolist (elem gnus-summary-marking-alist)
12718 (apply 'gnus-summary-make-marking-command elem)))
12720 (defun gnus-summary-make-marking-command (name mark keystroke)
12721 (let ((map (make-sparse-keymap)))
12722 (define-key gnus-summary-generic-mark-map keystroke map)
12723 (dolist (lway `((next "next" next nil "n")
12724 (next-unread "next unread" next t "N")
12725 (prev "previous" prev nil "p")
12726 (prev-unread "previous unread" prev t "P")
12727 (nomove "" nil nil ,keystroke)))
12728 (let ((func (gnus-summary-make-marking-command-1
12729 mark (car lway) lway name)))
12730 (setq func (eval func))
12731 (define-key map (nth 4 lway) func)))))
12733 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12735 (format "gnus-summary-put-mark-as-%s%s"
12736 name (if (eq way 'nomove)
12738 (concat "-" (symbol-name way)))))
12741 "Mark the current article as %s%s.
12742 If N, the prefix, then repeat N times.
12743 If N is negative, move in reverse order.
12744 The difference between N and the actual number of articles marked is
12748 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12750 (defun gnus-summary-generic-mark (n mark move unread)
12751 "Mark N articles with MARK."
12752 (unless (eq major-mode 'gnus-summary-mode)
12753 (error "This command can only be used in the summary buffer"))
12754 (gnus-summary-show-thread)
12757 ((eq move 'next) 1)
12758 ((eq move 'prev) -1)
12760 (if (zerop nummove)
12764 nummove (* -1 nummove))))
12765 (while (and (> n 0)
12766 (gnus-summary-mark-article nil mark)
12767 (zerop (gnus-summary-next-subject nummove unread t)))
12770 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12771 (gnus-summary-recenter)
12772 (gnus-summary-position-point)
12773 (gnus-set-mode-line 'summary)
12776 (defun gnus-summary-insert-articles (articles)
12777 (when (setq articles
12778 (gnus-sorted-difference articles
12779 (mapcar (lambda (h)
12780 (mail-header-number h))
12781 gnus-newsgroup-headers)))
12782 (setq gnus-newsgroup-headers
12784 gnus-newsgroup-headers
12785 (gnus-fetch-headers articles)
12786 'gnus-article-sort-by-number))
12787 (setq gnus-newsgroup-articles
12788 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12789 ;; Suppress duplicates?
12790 (when gnus-suppress-duplicates
12791 (gnus-dup-suppress-articles))
12793 (if (and gnus-fetch-old-headers
12794 (eq gnus-headers-retrieved-by 'nov))
12795 ;; We might want to build some more threads first.
12796 (if (eq gnus-fetch-old-headers 'invisible)
12797 (gnus-build-all-threads)
12798 (gnus-build-old-threads))
12799 ;; Mark the inserted articles that are unread as unread.
12800 (setq gnus-newsgroup-unreads
12801 (gnus-sorted-nunion
12802 gnus-newsgroup-unreads
12803 (gnus-sorted-nintersection
12804 (gnus-list-of-unread-articles gnus-newsgroup-name)
12806 ;; Mark the inserted articles as selected so that the information
12807 ;; of the marks having been changed by a user may be updated when
12808 ;; exiting this group. See `gnus-summary-update-info'.
12809 (dolist (art articles)
12810 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12811 ;; Let the Gnus agent mark articles as read.
12813 (gnus-agent-get-undownloaded-list))
12814 ;; Remove list identifiers from subject
12815 (gnus-summary-remove-list-identifiers)
12816 ;; First and last article in this newsgroup.
12817 (when gnus-newsgroup-headers
12818 (setq gnus-newsgroup-begin
12819 (mail-header-number (car gnus-newsgroup-headers))
12821 (mail-header-number
12822 (gnus-last-element gnus-newsgroup-headers))))
12823 (when gnus-use-scoring
12824 (gnus-possibly-score-headers))))
12826 (defun gnus-summary-insert-old-articles (&optional all)
12827 "Insert all old articles in this group.
12828 If ALL is non-nil, already read articles become readable.
12829 If ALL is a number, fetch this number of articles."
12832 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12835 ;; Some nntp servers lie about their active range. When
12836 ;; this happens, the active range can be in the millions.
12837 ;; Use a compressed range to avoid creating a huge list.
12838 (gnus-range-difference (list gnus-newsgroup-active) old))
12839 (setq len (gnus-range-length older))
12844 (let ((older-range (nreverse older)))
12848 (let* ((r (pop older-range))
12849 (min (if (numberp r) r (car r)))
12850 (max (if (numberp r) r (cdr r))))
12851 (while (and (<= min max)
12856 (setq older (gnus-uncompress-range older))))
12858 (setq older (gnus-uncompress-range older)))
12860 (when (and (numberp gnus-large-newsgroup)
12861 (> len gnus-large-newsgroup))
12862 (let* ((cursor-in-echo-area nil)
12863 (initial (gnus-parameter-large-newsgroup-initial
12864 gnus-newsgroup-name))
12868 "How many articles from %s (%s %d): "
12869 (gnus-group-decoded-name gnus-newsgroup-name)
12870 (if initial "max" "default")
12873 (cons (number-to-string initial)
12875 (unless (string-match "^[ \t]*$" input)
12876 (setq all (string-to-number input))
12878 (let ((older-range (nreverse older)))
12882 (let* ((r (pop older-range))
12883 (min (if (numberp r) r (car r)))
12884 (max (if (numberp r) r (cdr r))))
12885 (while (and (<= min max)
12889 max (1- max))))))))))
12890 (setq older (gnus-uncompress-range older))))
12892 (message "No old news.")
12893 (gnus-summary-insert-articles older)
12894 (gnus-summary-limit (gnus-sorted-nunion old older))))
12895 (gnus-summary-position-point)))
12897 (defun gnus-summary-insert-new-articles ()
12898 "Insert all new articles in this group."
12900 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12901 (old-high gnus-newsgroup-highest)
12902 (nnmail-fetched-sources (list t))
12903 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12906 (error "Couldn't fetch new data"))
12907 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12908 (setq i (cdr gnus-newsgroup-active)
12909 gnus-newsgroup-highest i)
12910 (while (> i old-high)
12914 (message "No gnus is bad news")
12915 (gnus-summary-insert-articles new)
12916 (setq gnus-newsgroup-unreads
12917 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12918 (gnus-summary-limit (gnus-sorted-nunion old new))))
12919 (gnus-summary-position-point))
12921 ;;; Bookmark support for Gnus.
12922 (declare-function bookmark-make-record-default
12923 "bookmark" (&optional no-file no-context posn))
12924 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12925 (declare-function bookmark-default-handler "bookmark" (bmk))
12926 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12927 (defvar bookmark-yank-point)
12928 (defvar bookmark-current-buffer)
12930 (defun gnus-summary-bookmark-make-record ()
12931 "Make a bookmark entry for a Gnus summary buffer."
12933 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12934 (save-restriction ; FIXME is it necessary to widen?
12935 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12936 (setq buf "art") ; We are recording bookmark from article buffer.
12937 (setq bookmark-yank-point (point))
12938 (setq bookmark-current-buffer (current-buffer))
12939 (gnus-article-show-summary)) ; Go back in summary buffer.
12940 ;; We are now recording bookmark from summary buffer.
12941 (unless buf (setq buf "sum"))
12942 (let* ((subject (elt (gnus-summary-article-header) 1))
12943 (grp (car gnus-article-current))
12944 (art (cdr gnus-article-current))
12945 (head (gnus-summary-article-header art))
12946 (id (mail-header-id head)))
12948 ,@(condition-case nil
12949 (bookmark-make-record-default 'no-file 'no-context pos)
12950 (wrong-number-of-arguments
12951 (bookmark-make-record-default 'point-only)))
12952 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12953 (group . ,grp) (article . ,art)
12954 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12957 (defun gnus-summary-bookmark-jump (bookmark)
12958 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12959 BOOKMARK is a bookmark name or a bookmark record."
12960 (let ((group (bookmark-prop-get bookmark 'group))
12961 (article (bookmark-prop-get bookmark 'article))
12962 (id (bookmark-prop-get bookmark 'message-id))
12963 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12964 (gnus-fetch-group group (list article))
12965 (gnus-summary-insert-cached-articles)
12966 (gnus-summary-goto-article id nil 'force)
12967 ;; FIXME we have to wait article buffer is ready (only large buffer)
12968 ;; Is there a better solution to know that?
12969 ;; If we don't wait `bookmark-default-handler' will have no chance
12970 ;; to set position. However there is no error, just wrong pos.
12972 (when (string= buf "Gnus-art")
12974 (bookmark-default-handler
12976 (buffer . ,(current-buffer))
12977 . ,(bookmark-get-bookmark-record bookmark)))))
12979 (gnus-summary-make-all-marking-commands)
12981 (gnus-ems-redefine)
12983 (provide 'gnus-sum)
12985 (run-hooks 'gnus-sum-load-hook)
12987 ;; Local Variables:
12988 ;; coding: iso-8859-1
12991 ;;; gnus-sum.el ends here