1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2012 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
36 (defvar tool-bar-mode)
37 (defvar gnus-tmp-header)
50 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
51 (autoload 'gnus-cache-write-active "gnus-cache")
52 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
54 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
55 (autoload 'mm-uu-dissect "mm-uu")
56 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
59 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
62 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63 (autoload 'nnir-article-group "nnir" nil nil 'macro)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74 See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
77 :version "23.1" ;; No Gnus
80 (defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
87 (defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
89 If an unread article in the group refers to an older, already
90 read (or just marked as read) article, the old article will not
91 normally be displayed in the Summary buffer. If this variable is
92 t, Gnus will attempt to grab the headers to the old articles, and
93 thereby build complete threads. If it has the value `some', all
94 old headers will be fetched but only enough headers to connect
95 otherwise loose threads will be displayed. This variable can
96 also be a number. In that case, no more than that number of old
97 headers will be fetched. If it has the value `invisible', all
98 old headers will be fetched, but none will be displayed.
100 The server has to support NOV for any of this to work.
102 This feature can seriously impact performance it ignores all
103 locally cached header entries. Setting it to t for groups for a
104 server that doesn't expire articles (such as news.gmane.org),
105 leads to very slow summary generation."
107 :type '(choice (const :tag "off" nil)
112 (sexp :menu-tag "other" t)))
114 (defcustom gnus-refer-thread-limit 500
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116 If t, fetch all the available old headers."
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
121 (defcustom gnus-refer-thread-use-nnir nil
122 "*Use nnir to search an entire server when referring threads. A
123 nil value will only search for thread-related articles in the
129 (defcustom gnus-summary-make-false-root 'adopt
130 "*nil means that Gnus won't gather loose threads.
131 If the root of a thread has expired or been read in a previous
132 session, the information necessary to build a complete thread has been
133 lost. Instead of having many small sub-threads from this original thread
134 scattered all over the summary buffer, Gnus can gather them.
136 If non-nil, Gnus will try to gather all loose sub-threads from an
137 original thread into one large thread.
139 If this variable is non-nil, it should be one of `none', `adopt',
142 If this variable is `none', Gnus will not make a false root, but just
143 present the sub-threads after another.
144 If this variable is `dummy', Gnus will create a dummy root that will
145 have all the sub-threads as children.
146 If this variable is `adopt', Gnus will make one of the \"children\"
147 the parent and mark all the step-children as such.
148 If this variable is `empty', the \"children\" are printed with empty
149 subject fields. (Or rather, they will be printed with a string
150 given by the `gnus-summary-same-subject' variable.)"
152 :type '(choice (const :tag "off" nil)
158 (defcustom gnus-summary-make-false-root-always nil
159 "Always make a false dummy root."
164 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
165 "*A regexp to match subjects to be excluded from loose thread gathering.
166 As loose thread gathering is done on subjects only, that means that
167 there can be many false gatherings performed. By rooting out certain
168 common subjects, gathering might become saner."
172 (defcustom gnus-summary-gather-subject-limit nil
173 "*Maximum length of subject comparisons when gathering loose threads.
174 Use nil to compare full subjects. Setting this variable to a low
175 number will help gather threads that have been corrupted by
176 newsreaders chopping off subject lines, but it might also mean that
177 unrelated articles that have subject that happen to begin with the
178 same few characters will be incorrectly gathered.
180 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
183 :type '(choice (const :tag "off" nil)
185 (sexp :menu-tag "on" t)))
187 (defcustom gnus-simplify-subject-functions nil
188 "List of functions taking a string argument that simplify subjects.
189 The functions are applied recursively.
191 Useful functions to put in this list include:
192 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
193 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
195 :type '(repeat function))
197 (defcustom gnus-simplify-ignored-prefixes nil
198 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
200 :type '(choice (const :tag "off" nil)
203 (defcustom gnus-build-sparse-threads nil
204 "*If non-nil, fill in the gaps in threads.
205 If `some', only fill in the gaps that are needed to tie loose threads
206 together. If `more', fill in all leaf nodes that Gnus can find. If
207 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
209 :type '(choice (const :tag "off" nil)
212 (sexp :menu-tag "all" t)))
214 (defcustom gnus-summary-thread-gathering-function
215 'gnus-gather-threads-by-subject
216 "*Function used for gathering loose threads.
217 There are two pre-defined functions: `gnus-gather-threads-by-subject',
218 which only takes Subjects into consideration; and
219 `gnus-gather-threads-by-references', which compared the References
220 headers of the articles to find matches."
222 :type '(radio (function-item gnus-gather-threads-by-subject)
223 (function-item gnus-gather-threads-by-references)
224 (function :tag "other")))
226 (defcustom gnus-summary-same-subject ""
227 "*String indicating that the current article has the same subject as the previous.
228 This variable will only be used if the value of
229 `gnus-summary-make-false-root' is `empty'."
230 :group 'gnus-summary-format
233 (defcustom gnus-summary-goto-unread nil
234 "*If t, many commands will go to the next unread article.
235 This applies to marking commands as well as other commands that
236 \"naturally\" select the next article, like, for instance, `SPC' at
237 the end of an article.
239 If nil, the marking commands do NOT go to the next unread article
240 \(they go to the next article instead). If `never', commands that
241 usually go to the next unread article, will go to the next article,
242 whether it is read or not."
244 :group 'gnus-summary-marks
245 :link '(custom-manual "(gnus)Setting Marks")
246 :type '(choice (const :tag "off" nil)
248 (sexp :menu-tag "on" t)))
250 (defcustom gnus-summary-default-score 0
251 "*Default article score level.
252 All scores generated by the score files will be added to this score.
253 If this variable is nil, scoring will be disabled."
254 :group 'gnus-score-default
255 :type '(choice (const :tag "disable")
258 (defcustom gnus-summary-default-high-score 0
259 "*Default threshold for a high scored article.
260 An article will be highlighted as high scored if its score is greater
263 :group 'gnus-score-default
266 (defcustom gnus-summary-default-low-score 0
267 "*Default threshold for a low scored article.
268 An article will be highlighted as low scored if its score is smaller
271 :group 'gnus-score-default
274 (defcustom gnus-summary-zcore-fuzz 0
275 "*Fuzziness factor for the zcore in the summary buffer.
276 Articles with scores closer than this to `gnus-summary-default-score'
278 :group 'gnus-summary-format
281 (defcustom gnus-simplify-subject-fuzzy-regexp nil
282 "*Strings to be removed when doing fuzzy matches.
283 This can either be a regular expression or list of regular expressions
284 that will be removed from subject strings if fuzzy subject
285 simplification is selected."
287 :type '(repeat regexp))
289 (defcustom gnus-show-threads t
290 "*If non-nil, display threads in summary mode."
294 (defcustom gnus-thread-hide-subtree nil
295 "*If non-nil, hide all threads initially.
296 This can be a predicate specifier which says which threads to hide.
297 If threads are hidden, you have to run the command
298 `gnus-summary-show-thread' by hand or select an article."
300 :type '(radio (sexp :format "Non-nil\n"
301 :match (lambda (widget value)
302 (not (or (consp value) (functionp value))))
305 (sexp :tag "Predicate specifier")))
307 (defcustom gnus-thread-hide-killed t
308 "*If non-nil, hide killed threads automatically."
312 (defcustom gnus-thread-ignore-subject t
313 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
314 If nil, articles that have different subjects from their parents will
315 start separate threads."
319 (defcustom gnus-thread-operation-ignore-subject t
320 "*If non-nil, subjects will be ignored when doing thread commands.
321 This affects commands like `gnus-summary-kill-thread' and
322 `gnus-summary-lower-thread'.
324 If this variable is nil, articles in the same thread with different
325 subjects will not be included in the operation in question. If this
326 variable is `fuzzy', only articles that have subjects that are fuzzily
327 equal will be included."
329 :type '(choice (const :tag "off" nil)
333 (defcustom gnus-thread-indent-level 4
334 "*Number that says how much each sub-thread should be indented."
338 (defcustom gnus-auto-extend-newsgroup t
339 "*If non-nil, extend newsgroup forward and backward when requested."
340 :group 'gnus-summary-choose
343 (defcustom gnus-auto-select-first t
344 "If non-nil, select an article on group entry.
345 An article is selected automatically when entering a group
346 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
347 `gnus-summary-catchup-and-goto-next-group'.
349 Which article is selected is controlled by the variable
350 `gnus-auto-select-subject'.
352 If you want to prevent automatic selection of articles in some
353 newsgroups, set the variable to nil in `gnus-select-group-hook'."
354 ;; Commands include...
355 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
356 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
357 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
358 :group 'gnus-group-select
359 :type '(choice (const :tag "none" nil)
360 (sexp :menu-tag "first" t)))
362 (defcustom gnus-auto-select-subject 'unseen-or-unread
363 "*Says what subject to place under point when entering a group.
365 This variable can either be the symbols `first' (place point on the
366 first subject), `unread' (place point on the subject line of the first
367 unread article), `best' (place point on the subject line of the
368 highest-scored article), `unseen' (place point on the subject line of
369 the first unseen article), `unseen-or-unread' (place point on the subject
370 line of the first unseen article or, if all articles have been seen, on the
371 subject line of the first unread article), or a function to be called to
372 place point on some subject line."
374 :group 'gnus-group-select
375 :type '(choice (const best)
379 (const unseen-or-unread)
380 (function :tag "Function to call")))
382 (defcustom gnus-auto-select-next t
383 "*If non-nil, offer to go to the next group from the end of the previous.
384 If the value is t and the next newsgroup is empty, Gnus will exit
385 summary mode and go back to group mode. If the value is neither nil
386 nor t, Gnus will select the following unread newsgroup. In
387 particular, if the value is the symbol `quietly', the next unread
388 newsgroup will be selected without any confirmation, and if it is
389 `almost-quietly', the next group will be selected without any
390 confirmation if you are located on the last article in the group.
391 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
392 will go to the next group without confirmation."
393 :group 'gnus-summary-maneuvering
394 :type '(choice (const :tag "off" nil)
396 (const almost-quietly)
397 (const slightly-quietly)
398 (sexp :menu-tag "on" t)))
400 (defcustom gnus-auto-select-same nil
401 "*If non-nil, select the next article with the same subject.
402 If there are no more articles with the same subject, go to
403 the first unread article."
404 :group 'gnus-summary-maneuvering
407 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
408 "What article should be selected after exiting an ephemeral group.
409 Valid values include:
412 Select the next article.
414 Select the next unread article.
416 Move the cursor to the next article. This is the default.
417 `next-unread-noselect'
418 Move the cursor to the next unread article.
420 If it has any other value or there is no next (unread) article, the
421 article selected before entering to the ephemeral group will appear."
422 :version "23.1" ;; No Gnus
423 :group 'gnus-summary-maneuvering
424 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
425 (const next) (const next-unread)
426 (const next-noselect) (const next-unread-noselect)
427 (sexp :tag "other" :value nil)))
429 (defcustom gnus-auto-goto-ignores 'unfetched
430 "*Says how to handle unfetched articles when maneuvering.
432 This variable can either be the symbols nil (maneuver to any
433 article), `undownloaded' (maneuvering while unplugged ignores articles
434 that have not been fetched), `always-undownloaded' (maneuvering always
435 ignores articles that have not been fetched), `unfetched' (maneuvering
436 ignores articles whose headers have not been fetched).
438 NOTE: The list of unfetched articles will always be nil when plugged
439 and, when unplugged, a subset of the undownloaded article list."
441 :group 'gnus-summary-maneuvering
442 :type '(choice (const :tag "None" nil)
443 (const :tag "Undownloaded when unplugged" undownloaded)
444 (const :tag "Undownloaded" always-undownloaded)
445 (const :tag "Unfetched" unfetched)))
447 (defcustom gnus-summary-check-current nil
448 "*If non-nil, consider the current article when moving.
449 The \"unread\" movement commands will stay on the same line if the
450 current article is unread."
451 :group 'gnus-summary-maneuvering
454 (defcustom gnus-auto-center-summary 2
455 "*If non-nil, always center the current summary buffer.
456 In particular, if `vertical' do only vertical recentering. If non-nil
457 and non-`vertical', do both horizontal and vertical recentering."
458 :group 'gnus-summary-maneuvering
459 :type '(choice (const :tag "none" nil)
461 (integer :tag "height")
462 (sexp :menu-tag "both" t)))
464 (defcustom gnus-auto-center-group t
465 "If non-nil, always center the group buffer."
466 :group 'gnus-summary-maneuvering
469 (defcustom gnus-show-all-headers nil
470 "*If non-nil, don't hide any headers."
471 :group 'gnus-article-hiding
472 :group 'gnus-article-headers
475 (defcustom gnus-summary-ignore-duplicates nil
476 "*If non-nil, ignore articles with identical Message-ID headers."
480 (defcustom gnus-single-article-buffer nil
481 "*If non-nil, display all articles in the same buffer.
482 If nil, each group will get its own article buffer."
484 :group 'gnus-article-various
487 (defcustom gnus-widen-article-window nil
488 "If non-nil, selecting the article buffer will display only the article buffer."
490 :group 'gnus-article-various
493 (defcustom gnus-break-pages t
494 "*If non-nil, do page breaking on articles.
495 The page delimiter is specified by the `gnus-page-delimiter'
497 :group 'gnus-article-various
500 (defcustom gnus-move-split-methods nil
501 "*Variable used to suggest where articles are to be moved to.
502 It uses the same syntax as the `gnus-split-methods' variable.
503 However, whereas `gnus-split-methods' specifies file names as targets,
504 this variable specifies group names."
505 :group 'gnus-summary-mail
506 :type '(repeat (choice (list :value (fun) function)
507 (cons :value ("" "") regexp (repeat string))
510 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
511 "Function used to compute default prefix for article move/copy/etc prompts.
512 The function should take one argument, a group name, and return a
513 string with the suggested prefix."
514 :group 'gnus-summary-mail
517 ;; FIXME: Although the custom type is `character' for the following variables,
518 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
520 (defcustom gnus-unread-mark ? ;Whitespace
521 "*Mark used for unread articles."
522 :group 'gnus-summary-marks
525 (defcustom gnus-ticked-mark ?!
526 "*Mark used for ticked articles."
527 :group 'gnus-summary-marks
530 (defcustom gnus-dormant-mark ??
531 "*Mark used for dormant articles."
532 :group 'gnus-summary-marks
535 (defcustom gnus-del-mark ?r
536 "*Mark used for del'd articles."
537 :group 'gnus-summary-marks
540 (defcustom gnus-read-mark ?R
541 "*Mark used for read articles."
542 :group 'gnus-summary-marks
545 (defcustom gnus-expirable-mark ?E
546 "*Mark used for expirable articles."
547 :group 'gnus-summary-marks
550 (defcustom gnus-killed-mark ?K
551 "*Mark used for killed articles."
552 :group 'gnus-summary-marks
555 (defcustom gnus-spam-mark ?$
556 "*Mark used for spam articles."
558 :group 'gnus-summary-marks
561 (defcustom gnus-kill-file-mark ?X
562 "*Mark used for articles killed by kill files."
563 :group 'gnus-summary-marks
566 (defcustom gnus-low-score-mark ?Y
567 "*Mark used for articles with a low score."
568 :group 'gnus-summary-marks
571 (defcustom gnus-catchup-mark ?C
572 "*Mark used for articles that are caught up."
573 :group 'gnus-summary-marks
576 (defcustom gnus-replied-mark ?A
577 "*Mark used for articles that have been replied to."
578 :group 'gnus-summary-marks
581 (defcustom gnus-forwarded-mark ?F
582 "*Mark used for articles that have been forwarded."
584 :group 'gnus-summary-marks
587 (defcustom gnus-recent-mark ?N
588 "*Mark used for articles that are recent."
590 :group 'gnus-summary-marks
593 (defcustom gnus-cached-mark ?*
594 "*Mark used for articles that are in the cache."
595 :group 'gnus-summary-marks
598 (defcustom gnus-saved-mark ?S
599 "*Mark used for articles that have been saved."
600 :group 'gnus-summary-marks
603 (defcustom gnus-unseen-mark ?.
604 "*Mark used for articles that haven't been seen."
606 :group 'gnus-summary-marks
609 (defcustom gnus-no-mark ? ;Whitespace
610 "*Mark used for articles that have no other secondary mark."
612 :group 'gnus-summary-marks
615 (defcustom gnus-ancient-mark ?O
616 "*Mark used for ancient articles."
617 :group 'gnus-summary-marks
620 (defcustom gnus-sparse-mark ?Q
621 "*Mark used for sparsely reffed articles."
622 :group 'gnus-summary-marks
625 (defcustom gnus-canceled-mark ?G
626 "*Mark used for canceled articles."
627 :group 'gnus-summary-marks
630 (defcustom gnus-duplicate-mark ?M
631 "*Mark used for duplicate articles."
632 :group 'gnus-summary-marks
635 (defcustom gnus-undownloaded-mark ?-
636 "*Mark used for articles that weren't downloaded."
638 :group 'gnus-summary-marks
641 (defcustom gnus-downloaded-mark ?+
642 "*Mark used for articles that were downloaded."
643 :group 'gnus-summary-marks
646 (defcustom gnus-downloadable-mark ?%
647 "*Mark used for articles that are to be downloaded."
648 :group 'gnus-summary-marks
651 (defcustom gnus-unsendable-mark ?=
652 "*Mark used for articles that won't be sent."
653 :group 'gnus-summary-marks
656 (defcustom gnus-score-over-mark ?+
657 "*Score mark used for articles with high scores."
658 :group 'gnus-summary-marks
661 (defcustom gnus-score-below-mark ?-
662 "*Score mark used for articles with low scores."
663 :group 'gnus-summary-marks
666 (defcustom gnus-empty-thread-mark ? ;Whitespace
667 "*There is no thread under the article."
668 :group 'gnus-summary-marks
671 (defcustom gnus-not-empty-thread-mark ?=
672 "*There is a thread under the article."
673 :group 'gnus-summary-marks
676 (defcustom gnus-view-pseudo-asynchronously nil
677 "*If non-nil, Gnus will view pseudo-articles asynchronously."
678 :group 'gnus-extract-view
681 (defcustom gnus-auto-expirable-marks
682 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
683 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
685 "*The list of marks converted into expiration if a group is auto-expirable."
688 :type '(repeat character))
690 (defcustom gnus-inhibit-user-auto-expire t
691 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
696 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
697 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
698 If nil, the expirable marks will be unchanged except that the marks
699 will be removed when copying or moving articles to a group that has
700 not turned auto-expire on. If non-nil, articles that have been read
701 will be marked as expirable when being copied or moved to a group in
702 which auto-expire is turned on."
705 :group 'gnus-summary-marks)
707 (defcustom gnus-view-pseudos nil
708 "*If `automatic', pseudo-articles will be viewed automatically.
709 If `not-confirm', pseudos will be viewed automatically, and the user
710 will not be asked to confirm the command."
711 :group 'gnus-extract-view
712 :type '(choice (const :tag "off" nil)
714 (const not-confirm)))
716 (defcustom gnus-view-pseudos-separately t
717 "*If non-nil, one pseudo-article will be created for each file to be viewed.
718 If nil, all files that use the same viewing command will be given as a
719 list of parameters to that command."
720 :group 'gnus-extract-view
723 (defcustom gnus-insert-pseudo-articles t
724 "*If non-nil, insert pseudo-articles when decoding articles."
725 :group 'gnus-extract-view
728 (defcustom gnus-summary-dummy-line-format
730 "*The format specification for the dummy roots in the summary buffer.
731 It works along the same lines as a normal formatting string,
732 with some simple extensions.
736 General format specifiers can also be used.
737 See `(gnus)Formatting Variables'."
738 :link '(custom-manual "(gnus)Formatting Variables")
739 :group 'gnus-threading
742 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
743 "*The format specification for the summary mode line.
744 It works along the same lines as a normal formatting string,
745 with some simple extensions:
748 %p Unprefixed group name
749 %A Current article number
750 %z Current article score
752 %U Number of unread articles in the group
753 %e Number of unselected articles in the group
754 %Z A string with unread/unselected article counts
755 %g Shortish group name
756 %S Subject of the current article
758 %s Current score file name
759 %d Number of dormant articles
760 %r Number of articles that have been marked as read in this session
761 %E Number of articles expunged by the score files"
762 :group 'gnus-summary-format
765 (defcustom gnus-list-identifiers nil
766 "Regexp that matches list identifiers to be removed from subject.
767 This can also be a list of regexps."
769 :group 'gnus-summary-format
770 :group 'gnus-article-hiding
771 :type '(choice (const :tag "none" nil)
773 (repeat :value (".*") regexp)))
775 (defcustom gnus-summary-mark-below 0
776 "*Mark all articles with a score below this variable as read.
777 This variable is local to each summary buffer and usually set by the
779 :group 'gnus-score-default
782 (defun gnus-widget-reversible-match (widget value)
783 "Ignoring WIDGET, convert VALUE to internal form.
784 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
788 (eq (length value) 2)
789 (eq (nth 0 value) 'not)
790 (symbolp (nth 1 value)))))
792 (defun gnus-widget-reversible-to-internal (widget value)
793 "Ignoring WIDGET, convert VALUE to internal form.
794 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
795 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
799 (list (nth 1 value) t)))
801 (defun gnus-widget-reversible-to-external (widget value)
802 "Ignoring WIDGET, convert VALUE to external form.
803 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
804 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
807 (list 'not (nth 0 value))
810 (define-widget 'gnus-widget-reversible 'group
811 "A `group' that convert values."
812 :match 'gnus-widget-reversible-match
813 :value-to-internal 'gnus-widget-reversible-to-internal
814 :value-to-external 'gnus-widget-reversible-to-external)
816 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
817 "*List of functions used for sorting articles in the summary buffer.
819 Each function takes two articles and returns non-nil if the first
820 article should be sorted before the other. If you use more than one
821 function, the primary sort function should be the last. You should
822 probably always include `gnus-article-sort-by-number' in the list of
823 sorting functions -- preferably first. Also note that sorting by date
824 is often much slower than sorting by number, and the sorting order is
825 very similar. (Sorting by date means sorting by the time the message
826 was sent, sorting by number means sorting by arrival time.)
828 Each item can also be a list `(not F)' where F is a function;
829 this reverses the sort order.
831 Ready-made functions include `gnus-article-sort-by-number',
832 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
833 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
834 and `gnus-article-sort-by-score'.
836 When threading is turned on, the variable `gnus-thread-sort-functions'
837 controls how articles are sorted."
838 :group 'gnus-summary-sort
839 :type '(repeat (gnus-widget-reversible
840 (choice (function-item gnus-article-sort-by-number)
841 (function-item gnus-article-sort-by-author)
842 (function-item gnus-article-sort-by-subject)
843 (function-item gnus-article-sort-by-date)
844 (function-item gnus-article-sort-by-score)
845 (function-item gnus-article-sort-by-random)
846 (function :tag "other"))
847 (boolean :tag "Reverse order"))))
850 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
851 "*List of functions used for sorting threads in the summary buffer.
852 By default, threads are sorted by article number.
854 Each function takes two threads and returns non-nil if the first
855 thread should be sorted before the other. If you use more than one
856 function, the primary sort function should be the last. You should
857 probably always include `gnus-thread-sort-by-number' in the list of
858 sorting functions -- preferably first. Also note that sorting by date
859 is often much slower than sorting by number, and the sorting order is
860 very similar. (Sorting by date means sorting by the time the message
861 was sent, sorting by number means sorting by arrival time.)
863 Each list item can also be a list `(not F)' where F is a
864 function; this specifies reversed sort order.
866 Ready-made functions include `gnus-thread-sort-by-number',
867 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
868 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
869 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
870 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
871 and `gnus-thread-sort-by-total-score' (see
872 `gnus-thread-score-function').
874 When threading is turned off, the variable
875 `gnus-article-sort-functions' controls how articles are sorted."
876 :group 'gnus-summary-sort
878 (gnus-widget-reversible
879 (choice (function-item gnus-thread-sort-by-number)
880 (function-item gnus-thread-sort-by-author)
881 (function-item gnus-thread-sort-by-recipient)
882 (function-item gnus-thread-sort-by-subject)
883 (function-item gnus-thread-sort-by-date)
884 (function-item gnus-thread-sort-by-score)
885 (function-item gnus-thread-sort-by-most-recent-number)
886 (function-item gnus-thread-sort-by-most-recent-date)
887 (function-item gnus-thread-sort-by-random)
888 (function-item gnus-thread-sort-by-total-score)
889 (function :tag "other"))
890 (boolean :tag "Reverse order"))))
892 (defcustom gnus-thread-score-function '+
893 "*Function used for calculating the total score of a thread.
895 The function is called with the scores of the article and each
896 subthread and should then return the score of the thread.
898 Some functions you can use are `+', `max', or `min'."
899 :group 'gnus-summary-sort
902 (defcustom gnus-summary-expunge-below nil
903 "All articles that have a score less than this variable will be expunged.
904 This variable is local to the summary buffers."
905 :group 'gnus-score-default
906 :type '(choice (const :tag "off" nil)
909 (defcustom gnus-thread-expunge-below nil
910 "All threads that have a total score less than this variable will be expunged.
911 See `gnus-thread-score-function' for en explanation of what a
914 This variable is local to the summary buffers."
915 :group 'gnus-threading
916 :group 'gnus-score-default
917 :type '(choice (const :tag "off" nil)
920 (defcustom gnus-summary-mode-hook nil
921 "*A hook for Gnus summary mode.
922 This hook is run before any variables are set in the summary buffer."
923 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
924 :group 'gnus-summary-various
927 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
928 (when (featurep 'xemacs)
929 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
930 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
931 (add-hook 'gnus-summary-mode-hook
932 'gnus-xmas-switch-horizontal-scrollbar-off))
934 (defcustom gnus-summary-menu-hook nil
935 "*Hook run after the creation of the summary mode menu."
936 :group 'gnus-summary-visual
939 (defcustom gnus-summary-exit-hook nil
940 "*A hook called on exit from the summary buffer.
941 It will be called with point in the group buffer."
942 :group 'gnus-summary-exit
945 (defcustom gnus-summary-prepare-hook nil
946 "*A hook called after the summary buffer has been generated.
947 If you want to modify the summary buffer, you can use this hook."
948 :group 'gnus-summary-various
951 (defcustom gnus-summary-prepared-hook nil
952 "*A hook called as the last thing after the summary buffer has been generated."
953 :group 'gnus-summary-various
956 (defcustom gnus-summary-generate-hook nil
957 "*A hook run just before generating the summary buffer.
958 This hook is commonly used to customize threading variables and the
960 :group 'gnus-summary-various
963 (defcustom gnus-select-group-hook nil
964 "*A hook called when a newsgroup is selected.
966 If you'd like to simplify subjects like the
967 `gnus-summary-next-same-subject' command does, you can use the
970 (add-hook gnus-select-group-hook
972 (mapcar (lambda (header)
973 (mail-header-set-subject
975 (gnus-simplify-subject
976 (mail-header-subject header) 're-only)))
977 gnus-newsgroup-headers)))"
978 :group 'gnus-group-select
981 (defcustom gnus-select-article-hook nil
982 "*A hook called when an article is selected."
983 :group 'gnus-summary-choose
984 :options '(gnus-agent-fetch-selected-article)
987 (defcustom gnus-visual-mark-article-hook
988 (list 'gnus-highlight-selected-summary)
989 "*Hook run after selecting an article in the summary buffer.
990 It is meant to be used for highlighting the article in some way. It
991 is not run if `gnus-visual' is nil."
992 :group 'gnus-summary-visual
995 (defcustom gnus-parse-headers-hook nil
996 "*A hook called before parsing the headers."
1000 (defcustom gnus-exit-group-hook nil
1001 "*A hook called when exiting summary mode.
1002 This hook is not called from the non-updating exit commands like `Q'."
1003 :group 'gnus-various
1006 (defcustom gnus-summary-update-hook nil
1007 "*A hook called when a summary line is changed.
1008 The hook will not be called if `gnus-visual' is nil.
1010 The default function `gnus-summary-highlight-line' will
1011 highlight the line according to the `gnus-summary-highlight'
1013 :group 'gnus-summary-visual
1016 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1017 "*A hook called when an article is selected for the first time.
1018 The hook is intended to mark an article as read (or unread)
1019 automatically when it is selected."
1020 :group 'gnus-summary-choose
1023 (defcustom gnus-group-no-more-groups-hook nil
1024 "*A hook run when returning to group mode having no more (unread) groups."
1025 :group 'gnus-group-select
1028 (defcustom gnus-ps-print-hook nil
1029 "*A hook run before ps-printing something from Gnus."
1030 :group 'gnus-summary
1033 (defcustom gnus-summary-article-move-hook nil
1034 "*A hook called after an article is moved, copied, respooled, or crossposted."
1036 :group 'gnus-summary
1039 (defcustom gnus-summary-article-delete-hook nil
1040 "*A hook called after an article is deleted."
1042 :group 'gnus-summary
1045 (defcustom gnus-summary-article-expire-hook nil
1046 "*A hook called after an article is expired."
1048 :group 'gnus-summary
1051 (defcustom gnus-summary-display-arrow
1052 (and (fboundp 'display-graphic-p)
1053 (display-graphic-p))
1054 "*If non-nil, display an arrow highlighting the current article."
1056 :group 'gnus-summary
1059 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1060 "Face used for highlighting the current article in the summary buffer."
1061 :group 'gnus-summary-visual
1064 (defvar gnus-tmp-downloaded nil)
1066 (defcustom gnus-summary-highlight
1067 '(((eq mark gnus-canceled-mark)
1068 . gnus-summary-cancelled)
1069 ((and uncached (> score default-high))
1070 . gnus-summary-high-undownloaded)
1071 ((and uncached (< score default-low))
1072 . gnus-summary-low-undownloaded)
1074 . gnus-summary-normal-undownloaded)
1075 ((and (> score default-high)
1076 (or (eq mark gnus-dormant-mark)
1077 (eq mark gnus-ticked-mark)))
1078 . gnus-summary-high-ticked)
1079 ((and (< score default-low)
1080 (or (eq mark gnus-dormant-mark)
1081 (eq mark gnus-ticked-mark)))
1082 . gnus-summary-low-ticked)
1083 ((or (eq mark gnus-dormant-mark)
1084 (eq mark gnus-ticked-mark))
1085 . gnus-summary-normal-ticked)
1086 ((and (> score default-high) (eq mark gnus-ancient-mark))
1087 . gnus-summary-high-ancient)
1088 ((and (< score default-low) (eq mark gnus-ancient-mark))
1089 . gnus-summary-low-ancient)
1090 ((eq mark gnus-ancient-mark)
1091 . gnus-summary-normal-ancient)
1092 ((and (> score default-high) (eq mark gnus-unread-mark))
1093 . gnus-summary-high-unread)
1094 ((and (< score default-low) (eq mark gnus-unread-mark))
1095 . gnus-summary-low-unread)
1096 ((eq mark gnus-unread-mark)
1097 . gnus-summary-normal-unread)
1098 ((> score default-high)
1099 . gnus-summary-high-read)
1100 ((< score default-low)
1101 . gnus-summary-low-read)
1103 . gnus-summary-normal-read))
1104 "*Controls the highlighting of summary buffer lines.
1106 A list of (FORM . FACE) pairs. When deciding how a particular
1107 summary line should be displayed, each form is evaluated. The content
1108 of the face field after the first true form is used. You can change
1109 how those summary lines are displayed, by editing the face field.
1111 You can use the following variables in the FORM field.
1113 score: The article's score.
1114 default: The default article score.
1115 default-high: The default score for high scored articles.
1116 default-low: The default score for low scored articles.
1117 below: The score below which articles are automatically marked as read.
1118 mark: The article's mark.
1119 uncached: Non-nil if the article is uncached."
1120 :group 'gnus-summary-visual
1121 :type '(repeat (cons (sexp :tag "Form" nil)
1123 (put 'gnus-summary-highlight 'risky-local-variable t)
1125 (defcustom gnus-alter-header-function nil
1126 "Function called to allow alteration of article header structures.
1127 The function is called with one parameter, the article header vector,
1128 which it may alter in any way."
1129 :type '(choice (const :tag "None" nil)
1131 :group 'gnus-summary)
1133 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1134 "Function used to decode a string with encoded words.")
1136 (defvar gnus-decode-encoded-address-function
1137 'mail-decode-encoded-address-string
1138 "Function used to decode addresses with encoded words.")
1140 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
1141 "*Extra headers to parse."
1142 :version "24.1" ; added Cc Keywords Gcc
1143 :group 'gnus-summary
1144 :type '(repeat symbol))
1146 (defcustom gnus-ignored-from-addresses
1147 (and user-mail-address
1148 (not (string= user-mail-address ""))
1149 (regexp-quote user-mail-address))
1150 "*From headers that may be suppressed in favor of To headers.
1151 This can be a regexp or a list of regexps."
1153 :group 'gnus-summary
1154 :type '(choice regexp
1155 (repeat :tag "Regexp List" regexp)))
1157 (defsubst gnus-ignored-from-addresses ()
1158 (gmm-regexp-concat gnus-ignored-from-addresses))
1160 (defcustom gnus-summary-to-prefix "-> "
1161 "*String prefixed to the To field in the summary line when
1162 using `gnus-ignored-from-addresses'."
1164 :group 'gnus-summary
1167 (defcustom gnus-summary-newsgroup-prefix "=> "
1168 "*String prefixed to the Newsgroup field in the summary
1169 line when using `gnus-ignored-from-addresses'."
1171 :group 'gnus-summary
1174 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1175 "List of charsets that should be ignored.
1176 When these charsets are used in the \"charset\" parameter, the
1177 default charset will be used instead."
1179 :type '(repeat symbol)
1180 :group 'gnus-charset)
1182 (defcustom gnus-newsgroup-maximum-articles nil
1183 "The maximum number of articles a newsgroup.
1184 If this is a number, old articles in a newsgroup exceeding this number
1185 are silently ignored. If it is nil, no article is ignored. Note that
1186 setting this variable to a number might prevent you from reading very
1188 :group 'gnus-group-select
1190 :type '(choice (const :tag "No limit" nil)
1193 (gnus-define-group-parameter
1197 "Return the ignored charsets of GROUP."
1198 :variable gnus-group-ignored-charsets-alist
1200 '(("alt\\.chinese\\.text" iso-8859-1))
1202 "Alist of regexps (to match group names) and charsets that should be ignored.
1203 When these charsets are used in the \"charset\" parameter, the
1204 default charset will be used instead."
1205 :variable-group gnus-charset
1206 :variable-type '(repeat (cons (regexp :tag "Group")
1208 :parameter-type '(choice :tag "Ignored charsets"
1211 :parameter-document "\
1212 List of charsets that should be ignored.
1214 When these charsets are used in the \"charset\" parameter, the
1215 default charset will be used instead.")
1217 (defcustom gnus-group-highlight-words-alist nil
1218 "Alist of group regexps and highlight regexps.
1219 This variable uses the same syntax as `gnus-emphasis-alist'."
1221 :type '(repeat (cons (regexp :tag "Group")
1222 (repeat (list (regexp :tag "Highlight regexp")
1223 (number :tag "Group for entire word" 0)
1224 (number :tag "Group for displayed part" 0)
1226 gnus-emphasis-highlight-words)))))
1227 :group 'gnus-summary-visual)
1229 (defcustom gnus-summary-show-article-charset-alist
1231 "Alist of number and charset.
1232 The article will be shown with the charset corresponding to the
1234 For example: ((1 . cn-gb-2312) (2 . big5))."
1236 :type '(repeat (cons (number :tag "Argument" 1)
1237 (symbol :tag "Charset")))
1238 :group 'gnus-charset)
1240 (defcustom gnus-preserve-marks t
1241 "Whether marks are preserved when moving, copying and respooling messages."
1244 :group 'gnus-summary-marks)
1246 (defcustom gnus-propagate-marks nil
1247 "If non-nil, Gnus will store and retrieve marks from the backends.
1248 This means that marks will be stored both in .newsrc.eld and in
1249 the backend, and will slow operation down somewhat."
1251 :group 'gnus-summary-marks)
1253 (defcustom gnus-alter-articles-to-read-function nil
1254 "Function to be called to alter the list of articles to be selected."
1255 :type '(choice (const nil) function)
1256 :group 'gnus-summary)
1258 (defcustom gnus-orphan-score nil
1259 "*All orphans get this score added. Set in the score file."
1260 :group 'gnus-score-default
1261 :type '(choice (const nil)
1264 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1265 "*A regexp to match MIME parts when saving multiple parts of a
1266 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1267 This regexp will be used by default when prompting the user for which
1268 type of files to save."
1269 :group 'gnus-summary
1272 (defcustom gnus-read-all-available-headers nil
1273 "Whether Gnus should parse all headers made available to it.
1274 This is mostly relevant for slow back ends where the user may
1275 wish to widen the summary buffer to include all headers
1278 :group 'gnus-summary
1279 :type '(choice boolean regexp))
1281 (defcustom gnus-summary-pipe-output-default-command nil
1282 "Command (and optional arguments) used to pipe article to subprocess.
1283 This will be used as the default command if it is non-nil. The value
1284 will be updated if you modify it when executing the command
1285 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1286 :version "23.1" ;; No Gnus
1287 :group 'gnus-summary
1288 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1290 (defcustom gnus-summary-muttprint-program "muttprint"
1291 "Command (and optional arguments) used to run Muttprint.
1292 The value will be updated if you modify it when executing the command
1293 `gnus-summary-muttprint'."
1295 :group 'gnus-summary
1298 (defcustom gnus-article-loose-mime t
1299 "If non-nil, don't require MIME-Version header.
1300 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1301 supply the MIME-Version header or deliberately strip it from the mail.
1302 If non-nil (the default), Gnus will treat some articles as MIME
1303 even if the MIME-Version header is missing."
1306 :group 'gnus-article-mime)
1308 (defcustom gnus-article-emulate-mime t
1309 "If non-nil, use MIME emulation for uuencode and the like.
1310 This means that Gnus will search message bodies for text that look
1311 like uuencoded bits, yEncoded bits, and so on, and present that using
1312 the normal Gnus MIME machinery."
1315 :group 'gnus-article-mime)
1317 ;;; Internal variables
1319 (defvar gnus-summary-display-cache nil)
1320 (defvar gnus-article-mime-handles nil)
1321 (defvar gnus-article-decoded-p nil)
1322 (defvar gnus-article-charset nil)
1323 (defvar gnus-article-ignored-charsets nil)
1324 (defvar gnus-scores-exclude-files nil)
1325 (defvar gnus-page-broken nil)
1327 (defvar gnus-original-article nil)
1328 (defvar gnus-article-internal-prepare-hook nil)
1329 (defvar gnus-newsgroup-process-stack nil)
1331 (defvar gnus-thread-indent-array nil)
1332 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1333 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1334 "Function called to sort the articles within a thread after it has been gathered together.")
1336 (defvar gnus-summary-save-parts-type-history nil)
1337 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1339 ;; Avoid highlighting in kill files.
1340 (defvar gnus-summary-inhibit-highlight nil)
1341 (defvar gnus-newsgroup-selected-overlay nil)
1342 (defvar gnus-inhibit-limiting nil)
1343 (defvar gnus-newsgroup-adaptive-score-file nil)
1344 (defvar gnus-current-score-file nil)
1345 (defvar gnus-current-move-group nil)
1346 (defvar gnus-current-copy-group nil)
1347 (defvar gnus-current-crosspost-group nil)
1348 (defvar gnus-newsgroup-display nil)
1350 (defvar gnus-newsgroup-dependencies nil)
1351 (defvar gnus-newsgroup-adaptive nil)
1352 (defvar gnus-summary-display-article-function nil)
1353 (defvar gnus-summary-highlight-line-function nil
1354 "Function called after highlighting a summary line.")
1356 (defvar gnus-summary-line-format-alist
1357 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1358 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1359 (?s gnus-tmp-subject-or-nil ?s)
1360 (?n gnus-tmp-name ?s)
1361 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1363 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1365 (?F gnus-tmp-from ?s)
1366 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1367 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1368 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1369 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1370 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1371 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1372 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1373 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1374 (?L gnus-tmp-lines ?s)
1375 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1377 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1379 (?g (or (gnus-group-short-name
1380 (nnir-article-group (mail-header-number gnus-tmp-header)))
1382 (?O gnus-tmp-downloaded ?c)
1383 (?I gnus-tmp-indentation ?s)
1384 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1385 (?R gnus-tmp-replied ?c)
1386 (?\[ gnus-tmp-opening-bracket ?c)
1387 (?\] gnus-tmp-closing-bracket ?c)
1388 (?\> (make-string gnus-tmp-level ? ) ?s)
1389 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1390 (?i gnus-tmp-score ?d)
1391 (?z gnus-tmp-score-char ?c)
1392 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1393 (?U gnus-tmp-unread ?c)
1394 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1396 (?t (gnus-summary-number-of-articles-in-thread
1397 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1399 (?e (gnus-summary-number-of-articles-in-thread
1400 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1402 (?u gnus-tmp-user-defined ?s)
1403 (?P (gnus-pick-line-number) ?d)
1404 (?B gnus-tmp-thread-tree-header-string ?s)
1405 (user-date (gnus-user-date
1406 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1407 "An alist of format specifications that can appear in summary lines.
1408 These are paired with what variables they correspond with, along with
1409 the type of the variable (string, integer, character, etc).")
1411 (defvar gnus-summary-dummy-line-format-alist
1412 `((?S gnus-tmp-subject ?s)
1413 (?N gnus-tmp-number ?d)
1414 (?u gnus-tmp-user-defined ?s)))
1416 (defvar gnus-summary-mode-line-format-alist
1417 `((?G gnus-tmp-group-name ?s)
1418 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1419 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1420 (?A gnus-tmp-article-number ?d)
1421 (?Z gnus-tmp-unread-and-unselected ?s)
1422 (?V gnus-version ?s)
1423 (?U gnus-tmp-unread-and-unticked ?d)
1424 (?S gnus-tmp-subject ?s)
1425 (?e gnus-tmp-unselected ?d)
1426 (?u gnus-tmp-user-defined ?s)
1427 (?d (length gnus-newsgroup-dormant) ?d)
1428 (?t (length gnus-newsgroup-marked) ?d)
1429 (?h (length gnus-newsgroup-spam-marked) ?d)
1430 (?r (length gnus-newsgroup-reads) ?d)
1431 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1432 (?E gnus-newsgroup-expunged-tally ?d)
1433 (?s (gnus-current-score-file-nondirectory) ?s)))
1435 ;; This is here rather than in gnus-art for compilation reasons.
1436 (defvar gnus-article-mode-line-format-alist
1437 (nconc '((?w (gnus-article-wash-status) ?s)
1438 (?m (gnus-article-mime-part-status) ?s))
1439 gnus-summary-mode-line-format-alist))
1441 (defvar gnus-last-search-regexp nil
1442 "Default regexp for article search command.")
1444 (defvar gnus-last-shell-command nil
1445 "Default shell command on article.")
1447 (defvar gnus-newsgroup-agentized nil
1448 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1449 (defvar gnus-newsgroup-begin nil)
1450 (defvar gnus-newsgroup-end nil)
1451 (defvar gnus-newsgroup-last-rmail nil)
1452 (defvar gnus-newsgroup-last-mail nil)
1453 (defvar gnus-newsgroup-last-folder nil)
1454 (defvar gnus-newsgroup-last-file nil)
1455 (defvar gnus-newsgroup-last-directory nil)
1456 (defvar gnus-newsgroup-auto-expire nil)
1457 (defvar gnus-newsgroup-active nil)
1458 (defvar gnus-newsgroup-highest nil)
1460 (defvar gnus-newsgroup-data nil)
1461 (defvar gnus-newsgroup-data-reverse nil)
1462 (defvar gnus-newsgroup-limit nil)
1463 (defvar gnus-newsgroup-limits nil)
1464 (defvar gnus-summary-use-undownloaded-faces nil)
1466 (defvar gnus-newsgroup-unreads nil
1467 "Sorted list of unread articles in the current newsgroup.")
1469 (defvar gnus-newsgroup-unselected nil
1470 "Sorted list of unselected unread articles in the current newsgroup.")
1472 (defvar gnus-newsgroup-reads nil
1473 "Alist of read articles and article marks in the current newsgroup.")
1475 (defvar gnus-newsgroup-expunged-tally nil)
1477 (defvar gnus-newsgroup-marked nil
1478 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1480 (defvar gnus-newsgroup-spam-marked nil
1481 "List of ranges of articles that have been marked as spam.")
1483 (defvar gnus-newsgroup-killed nil
1484 "List of ranges of articles that have been through the scoring process.")
1486 (defvar gnus-newsgroup-cached nil
1487 "Sorted list of articles that come from the article cache.")
1489 (defvar gnus-newsgroup-saved nil
1490 "List of articles that have been saved.")
1492 (defvar gnus-newsgroup-kill-headers nil)
1494 (defvar gnus-newsgroup-replied nil
1495 "List of articles that have been replied to in the current newsgroup.")
1497 (defvar gnus-newsgroup-forwarded nil
1498 "List of articles that have been forwarded in the current newsgroup.")
1500 (defvar gnus-newsgroup-expirable nil
1501 "Sorted list of articles in the current newsgroup that can be expired.")
1503 (defvar gnus-newsgroup-processable nil
1504 "List of articles in the current newsgroup that can be processed.")
1506 (defvar gnus-newsgroup-downloadable nil
1507 "Sorted list of articles in the current newsgroup that can be processed.")
1509 (defvar gnus-newsgroup-unfetched nil
1510 "Sorted list of articles in the current newsgroup whose headers have
1511 not been fetched into the agent.
1513 This list will always be a subset of gnus-newsgroup-undownloaded.")
1515 (defvar gnus-newsgroup-undownloaded nil
1516 "List of articles in the current newsgroup that haven't been downloaded.")
1518 (defvar gnus-newsgroup-unsendable nil
1519 "List of articles in the current newsgroup that won't be sent.")
1521 (defvar gnus-newsgroup-bookmarks nil
1522 "List of articles in the current newsgroup that have bookmarks.")
1524 (defvar gnus-newsgroup-dormant nil
1525 "Sorted list of dormant articles in the current newsgroup.")
1527 (defvar gnus-newsgroup-unseen nil
1528 "List of unseen articles in the current newsgroup.")
1530 (defvar gnus-newsgroup-seen nil
1531 "Range of seen articles in the current newsgroup.")
1533 (defvar gnus-newsgroup-unexist nil
1534 "Range of unexistent articles in the current newsgroup.")
1536 (defvar gnus-newsgroup-articles nil
1537 "List of articles in the current newsgroup.")
1539 (defvar gnus-newsgroup-scored nil
1540 "List of scored articles in the current newsgroup.")
1542 (defvar gnus-newsgroup-headers nil
1543 "List of article headers in the current newsgroup.")
1545 (defvar gnus-newsgroup-threads nil)
1547 (defvar gnus-newsgroup-prepared nil
1548 "Whether the current group has been prepared properly.")
1550 (defvar gnus-newsgroup-ancient nil
1551 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1553 (defvar gnus-newsgroup-sparse nil)
1555 (defvar gnus-current-article nil)
1556 (defvar gnus-article-current nil)
1557 (defvar gnus-current-headers nil)
1558 (defvar gnus-have-all-headers nil)
1559 (defvar gnus-last-article nil)
1560 (defvar gnus-newsgroup-history nil)
1561 (defvar gnus-newsgroup-charset nil)
1562 (defvar gnus-newsgroup-ephemeral-charset nil)
1563 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1565 (defvar gnus-article-before-search nil)
1567 (defvar gnus-summary-local-variables
1568 '(gnus-newsgroup-name
1571 gnus-newsgroup-unreads
1572 gnus-newsgroup-unselected
1573 gnus-newsgroup-marked
1574 gnus-newsgroup-spam-marked
1575 gnus-newsgroup-reads
1576 gnus-newsgroup-saved
1577 gnus-newsgroup-replied
1578 gnus-newsgroup-forwarded
1579 gnus-newsgroup-expirable
1580 gnus-newsgroup-killed
1581 gnus-newsgroup-unseen
1583 gnus-newsgroup-cached
1584 gnus-newsgroup-downloadable
1585 gnus-newsgroup-undownloaded
1586 gnus-newsgroup-unsendable
1588 gnus-newsgroup-begin gnus-newsgroup-end
1589 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1590 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1591 gnus-newsgroup-last-directory
1592 gnus-newsgroup-auto-expire
1593 gnus-newsgroup-processable
1594 gnus-newsgroup-unfetched
1595 gnus-newsgroup-articles
1596 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1597 gnus-newsgroup-headers gnus-newsgroup-threads
1598 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1599 gnus-current-article gnus-current-headers gnus-have-all-headers
1600 gnus-last-article gnus-article-internal-prepare-hook
1601 (gnus-summary-article-delete-hook . global)
1602 (gnus-summary-article-move-hook . global)
1603 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1604 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1605 gnus-thread-expunge-below
1606 gnus-score-alist gnus-current-score-file
1607 (gnus-summary-expunge-below . global)
1608 (gnus-summary-mark-below . global)
1609 (gnus-orphan-score . global)
1610 gnus-newsgroup-active gnus-scores-exclude-files
1611 gnus-newsgroup-highest
1612 gnus-newsgroup-history gnus-newsgroup-ancient
1613 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1614 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1615 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1616 (gnus-newsgroup-expunged-tally . 0)
1617 gnus-cache-removable-articles
1618 gnus-newsgroup-data gnus-newsgroup-data-reverse
1619 gnus-newsgroup-limit gnus-newsgroup-limits
1620 gnus-newsgroup-charset gnus-newsgroup-display
1621 gnus-summary-use-undownloaded-faces)
1622 "Variables that are buffer-local to the summary buffers.")
1624 (defvar gnus-newsgroup-variables nil
1625 "A list of variables that have separate values in different newsgroups.
1626 A list of newsgroup (summary buffer) local variables, or cons of
1627 variables and their default expressions to be evalled (when the default
1628 values are not nil), that should be made global while the summary buffer
1631 Note: The default expressions will be evaluated (using function `eval')
1632 before assignment to the local variable rather than just assigned to it.
1633 If the default expression is the symbol `global', that symbol will not
1634 be evaluated but the global value of the local variable will be used
1637 These variables can be used to set variables in the group parameters
1638 while still allowing them to affect operations done in other buffers.
1641 \(setq gnus-newsgroup-variables
1642 '(message-use-followup-to
1643 (gnus-visible-headers .
1644 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1648 ;; Bind features so that require will believe that gnus-sum has
1649 ;; already been loaded (avoids infinite recursion)
1650 (let ((features (cons 'gnus-sum features)))
1651 (require 'gnus-art)))
1655 (defvar gnus-decode-encoded-word-methods
1656 '(mail-decode-encoded-word-string)
1657 "List of methods used to decode encoded words.
1659 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1660 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1661 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1662 whose names match REGEXP.
1665 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1666 mail-decode-encoded-word-string
1667 (\"chinese\" . rfc1843-decode-string))")
1669 (defvar gnus-decode-encoded-word-methods-cache nil)
1671 (defun gnus-multi-decode-encoded-word-string (string)
1672 "Apply the functions from `gnus-encoded-word-methods' that match."
1673 (unless (and gnus-decode-encoded-word-methods-cache
1674 (eq gnus-newsgroup-name
1675 (car gnus-decode-encoded-word-methods-cache)))
1676 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1677 (dolist (method gnus-decode-encoded-word-methods)
1678 (if (symbolp method)
1679 (nconc gnus-decode-encoded-word-methods-cache (list method))
1680 (if (and gnus-newsgroup-name
1681 (string-match (car method) gnus-newsgroup-name))
1682 (nconc gnus-decode-encoded-word-methods-cache
1683 (list (cdr method)))))))
1684 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1685 (setq string (funcall method string))))
1687 ;; Subject simplification.
1689 (defun gnus-simplify-whitespace (str)
1690 "Remove excessive whitespace from STR."
1692 (while (string-match "[ \t][ \t]+" str)
1693 (setq str (concat (substring str 0 (match-beginning 0))
1695 (substring str (match-end 0)))))
1697 (when (string-match "^[ \t]+" str)
1698 (setq str (substring str (match-end 0))))
1700 (when (string-match "[ \t]+$" str)
1701 (setq str (substring str 0 (match-beginning 0))))
1704 (defun gnus-simplify-all-whitespace (str)
1705 "Remove all whitespace from STR."
1706 (while (string-match "[ \t\n]+" str)
1707 (setq str (replace-match "" nil nil str)))
1710 (defsubst gnus-simplify-subject-re (subject)
1711 "Remove \"Re:\" from subject lines."
1712 (if (string-match message-subject-re-regexp subject)
1713 (substring subject (match-end 0))
1716 (defun gnus-simplify-subject (subject &optional re-only)
1717 "Remove `Re:' and words in parentheses.
1718 If RE-ONLY is non-nil, strip leading `Re:'s only."
1719 (let ((case-fold-search t)) ;Ignore case.
1720 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1721 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1722 (setq subject (substring subject (match-end 0))))
1723 ;; Remove uninteresting prefixes.
1724 (when (and (not re-only)
1725 gnus-simplify-ignored-prefixes
1726 (string-match gnus-simplify-ignored-prefixes subject))
1727 (setq subject (substring subject (match-end 0))))
1728 ;; Remove words in parentheses from end.
1730 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1731 (setq subject (substring subject 0 (match-beginning 0)))))
1732 ;; Return subject string.
1735 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1737 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1738 (goto-char (point-min))
1739 (while (re-search-forward regexp nil t)
1740 (replace-match (or newtext ""))))
1742 (defun gnus-simplify-buffer-fuzzy (regexp)
1743 "Simplify string in the buffer fuzzily.
1744 The string in the accessible portion of the current buffer is simplified.
1745 It is assumed to be a single-line subject.
1746 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1747 matter is removed. Additional things can be deleted by setting
1748 `gnus-simplify-subject-fuzzy-regexp'."
1749 (let ((case-fold-search t)
1751 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1753 (while (not (eq modified-tick (buffer-modified-tick)))
1754 (setq modified-tick (buffer-modified-tick))
1757 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1759 (gnus-simplify-buffer-fuzzy-step regexp)))
1760 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1761 (gnus-simplify-buffer-fuzzy-step
1762 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1763 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1765 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1766 (gnus-simplify-buffer-fuzzy-step " +" " ")
1767 (gnus-simplify-buffer-fuzzy-step " $")
1768 (gnus-simplify-buffer-fuzzy-step "^ +")))
1770 (defun gnus-simplify-subject-fuzzy (subject)
1771 "Simplify a subject string fuzzily.
1772 See `gnus-simplify-buffer-fuzzy' for details."
1774 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1775 (gnus-set-work-buffer)
1776 (let ((case-fold-search t))
1777 ;; Remove uninteresting prefixes.
1778 (when (and gnus-simplify-ignored-prefixes
1779 (string-match gnus-simplify-ignored-prefixes subject))
1780 (setq subject (substring subject (match-end 0))))
1782 (inline (gnus-simplify-buffer-fuzzy regexp))
1785 (defsubst gnus-simplify-subject-fully (subject)
1786 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1788 (gnus-simplify-subject-functions
1789 (gnus-map-function gnus-simplify-subject-functions subject))
1790 ((null gnus-summary-gather-subject-limit)
1791 (gnus-simplify-subject-re subject))
1792 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1793 (gnus-simplify-subject-fuzzy subject))
1794 ((numberp gnus-summary-gather-subject-limit)
1795 (truncate-string-to-width (gnus-simplify-subject-re subject)
1796 gnus-summary-gather-subject-limit))
1800 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1801 "Check whether two subjects are equal.
1802 If optional argument SIMPLE-FIRST is t, first argument is already
1805 ((null simple-first)
1806 (equal (gnus-simplify-subject-fully s1)
1807 (gnus-simplify-subject-fully s2)))
1810 (gnus-simplify-subject-fully s2)))))
1812 (defun gnus-summary-bubble-group ()
1813 "Increase the score of the current group.
1814 This is a handy function to add to `gnus-summary-exit-hook' to
1815 increase the score of each group you read."
1816 (gnus-group-add-score gnus-newsgroup-name))
1820 ;;; Gnus summary mode
1823 (put 'gnus-summary-mode 'mode-class 'special)
1825 (defvar gnus-article-commands-menu)
1827 ;; Non-orthogonal keys
1829 (gnus-define-keys gnus-summary-mode-map
1830 " " gnus-summary-next-page
1831 "\177" gnus-summary-prev-page
1832 [delete] gnus-summary-prev-page
1833 [backspace] gnus-summary-prev-page
1834 "\r" gnus-summary-scroll-up
1835 "\M-\r" gnus-summary-scroll-down
1836 "n" gnus-summary-next-unread-article
1837 "p" gnus-summary-prev-unread-article
1838 "N" gnus-summary-next-article
1839 "P" gnus-summary-prev-article
1840 "\M-\C-n" gnus-summary-next-same-subject
1841 "\M-\C-p" gnus-summary-prev-same-subject
1842 "\M-n" gnus-summary-next-unread-subject
1843 "\M-p" gnus-summary-prev-unread-subject
1844 "." gnus-summary-first-unread-article
1845 "," gnus-summary-best-unread-article
1846 "\M-s" gnus-summary-search-article-forward
1847 "\M-r" gnus-summary-search-article-backward
1848 "\M-S" gnus-summary-repeat-search-article-forward
1849 "\M-R" gnus-summary-repeat-search-article-backward
1850 "<" gnus-summary-beginning-of-article
1851 ">" gnus-summary-end-of-article
1852 "j" gnus-summary-goto-article
1853 "^" gnus-summary-refer-parent-article
1854 "\M-^" gnus-summary-refer-article
1855 "u" gnus-summary-tick-article-forward
1856 "!" gnus-summary-tick-article-forward
1857 "U" gnus-summary-tick-article-backward
1858 "d" gnus-summary-mark-as-read-forward
1859 "D" gnus-summary-mark-as-read-backward
1860 "E" gnus-summary-mark-as-expirable
1861 "\M-u" gnus-summary-clear-mark-forward
1862 "\M-U" gnus-summary-clear-mark-backward
1863 "k" gnus-summary-kill-same-subject-and-select
1864 "\C-k" gnus-summary-kill-same-subject
1865 "\M-\C-k" gnus-summary-kill-thread
1866 "\M-\C-l" gnus-summary-lower-thread
1867 "e" gnus-summary-edit-article
1868 "#" gnus-summary-mark-as-processable
1869 "\M-#" gnus-summary-unmark-as-processable
1870 "\M-\C-t" gnus-summary-toggle-threads
1871 "\M-\C-s" gnus-summary-show-thread
1872 "\M-\C-h" gnus-summary-hide-thread
1873 "\M-\C-f" gnus-summary-next-thread
1874 "\M-\C-b" gnus-summary-prev-thread
1875 [(meta down)] gnus-summary-next-thread
1876 [(meta up)] gnus-summary-prev-thread
1877 "\M-\C-u" gnus-summary-up-thread
1878 "\M-\C-d" gnus-summary-down-thread
1879 "&" gnus-summary-execute-command
1880 "c" gnus-summary-catchup-and-exit
1881 "\C-w" gnus-summary-mark-region-as-read
1882 "\C-t" gnus-summary-toggle-truncation
1883 "?" gnus-summary-mark-as-dormant
1884 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1885 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1886 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1887 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1888 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1889 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1890 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1891 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1892 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1893 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1894 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1895 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1896 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1897 "=" gnus-summary-expand-window
1898 "\C-x\C-s" gnus-summary-reselect-current-group
1899 "\M-g" gnus-summary-rescan-group
1900 "\C-c\C-r" gnus-summary-caesar-message
1901 "f" gnus-summary-followup
1902 "F" gnus-summary-followup-with-original
1903 "C" gnus-summary-cancel-article
1904 "r" gnus-summary-reply
1905 "R" gnus-summary-reply-with-original
1906 "\C-c\C-f" gnus-summary-mail-forward
1907 "o" gnus-summary-save-article
1908 "\C-o" gnus-summary-save-article-mail
1909 "|" gnus-summary-pipe-output
1910 "\M-k" gnus-summary-edit-local-kill
1911 "\M-K" gnus-summary-edit-global-kill
1913 "\C-c\C-d" gnus-summary-describe-group
1914 "q" gnus-summary-exit
1915 "Q" gnus-summary-exit-no-update
1916 "\C-c\C-i" gnus-info-find-node
1917 gnus-mouse-2 gnus-mouse-pick-article
1918 [follow-link] mouse-face
1919 "m" gnus-summary-mail-other-window
1920 "a" gnus-summary-post-news
1921 "x" gnus-summary-limit-to-unread
1922 "s" gnus-summary-isearch-article
1923 [tab] gnus-summary-widget-forward
1924 [backtab] gnus-summary-widget-backward
1925 "t" gnus-summary-toggle-header
1926 "g" gnus-summary-show-article
1927 "l" gnus-summary-goto-last-article
1928 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1929 "\C-d" gnus-summary-enter-digest-group
1930 "\M-\C-d" gnus-summary-read-document
1931 "\M-\C-e" gnus-summary-edit-parameters
1932 "\M-\C-a" gnus-summary-customize-parameters
1934 "*" gnus-cache-enter-article
1935 "\M-*" gnus-cache-remove-article
1936 "\M-&" gnus-summary-universal-argument
1937 "\C-l" gnus-recenter
1938 "I" gnus-summary-increase-score
1939 "L" gnus-summary-lower-score
1940 "\M-i" gnus-symbolic-argument
1941 "h" gnus-summary-select-article-buffer
1943 "b" gnus-article-view-part
1944 "\M-t" gnus-summary-toggle-display-buttonized
1946 "V" gnus-summary-score-map
1947 "X" gnus-uu-extract-map
1948 "S" gnus-summary-send-map)
1950 ;; Sort of orthogonal keymap
1951 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1952 "t" gnus-summary-tick-article-forward
1953 "!" gnus-summary-tick-article-forward
1954 "d" gnus-summary-mark-as-read-forward
1955 "r" gnus-summary-mark-as-read-forward
1956 "c" gnus-summary-clear-mark-forward
1957 " " gnus-summary-clear-mark-forward
1958 "e" gnus-summary-mark-as-expirable
1959 "x" gnus-summary-mark-as-expirable
1960 "?" gnus-summary-mark-as-dormant
1961 "b" gnus-summary-set-bookmark
1962 "B" gnus-summary-remove-bookmark
1963 "#" gnus-summary-mark-as-processable
1964 "\M-#" gnus-summary-unmark-as-processable
1965 "S" gnus-summary-limit-include-expunged
1966 "C" gnus-summary-catchup
1967 "H" gnus-summary-catchup-to-here
1968 "h" gnus-summary-catchup-from-here
1969 "\C-c" gnus-summary-catchup-all
1970 "k" gnus-summary-kill-same-subject-and-select
1971 "K" gnus-summary-kill-same-subject
1972 "P" gnus-uu-mark-map)
1974 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1975 "c" gnus-summary-clear-above
1976 "u" gnus-summary-tick-above
1977 "m" gnus-summary-mark-above
1978 "k" gnus-summary-kill-below)
1980 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1981 "/" gnus-summary-limit-to-subject
1982 "n" gnus-summary-limit-to-articles
1983 "b" gnus-summary-limit-to-bodies
1984 "h" gnus-summary-limit-to-headers
1985 "w" gnus-summary-pop-limit
1986 "s" gnus-summary-limit-to-subject
1987 "a" gnus-summary-limit-to-author
1988 "u" gnus-summary-limit-to-unread
1989 "m" gnus-summary-limit-to-marks
1990 "M" gnus-summary-limit-exclude-marks
1991 "v" gnus-summary-limit-to-score
1992 "*" gnus-summary-limit-include-cached
1993 "D" gnus-summary-limit-include-dormant
1994 "T" gnus-summary-limit-include-thread
1995 "d" gnus-summary-limit-exclude-dormant
1996 "t" gnus-summary-limit-to-age
1997 "." gnus-summary-limit-to-unseen
1998 "x" gnus-summary-limit-to-extra
1999 "p" gnus-summary-limit-to-display-predicate
2000 "E" gnus-summary-limit-include-expunged
2001 "c" gnus-summary-limit-exclude-childless-dormant
2002 "C" gnus-summary-limit-mark-excluded-as-read
2003 "o" gnus-summary-insert-old-articles
2004 "N" gnus-summary-insert-new-articles
2005 "S" gnus-summary-limit-to-singletons
2006 "r" gnus-summary-limit-to-replied
2007 "R" gnus-summary-limit-to-recipient
2008 "A" gnus-summary-limit-to-address)
2010 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2011 "n" gnus-summary-next-unread-article
2012 "p" gnus-summary-prev-unread-article
2013 "N" gnus-summary-next-article
2014 "P" gnus-summary-prev-article
2015 "\C-n" gnus-summary-next-same-subject
2016 "\C-p" gnus-summary-prev-same-subject
2017 "\M-n" gnus-summary-next-unread-subject
2018 "\M-p" gnus-summary-prev-unread-subject
2019 "f" gnus-summary-first-unread-article
2020 "b" gnus-summary-best-unread-article
2021 "j" gnus-summary-goto-article
2022 "g" gnus-summary-goto-subject
2023 "l" gnus-summary-goto-last-article
2024 "o" gnus-summary-pop-article)
2026 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2027 "k" gnus-summary-kill-thread
2028 "E" gnus-summary-expire-thread
2029 "l" gnus-summary-lower-thread
2030 "i" gnus-summary-raise-thread
2031 "T" gnus-summary-toggle-threads
2032 "t" gnus-summary-rethread-current
2033 "^" gnus-summary-reparent-thread
2034 "\M-^" gnus-summary-reparent-children
2035 "s" gnus-summary-show-thread
2036 "S" gnus-summary-show-all-threads
2037 "h" gnus-summary-hide-thread
2038 "H" gnus-summary-hide-all-threads
2039 "n" gnus-summary-next-thread
2040 "p" gnus-summary-prev-thread
2041 "u" gnus-summary-up-thread
2042 "o" gnus-summary-top-thread
2043 "d" gnus-summary-down-thread
2044 "#" gnus-uu-mark-thread
2045 "\M-#" gnus-uu-unmark-thread)
2047 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2048 "g" gnus-summary-prepare
2049 "c" gnus-summary-insert-cached-articles
2050 "d" gnus-summary-insert-dormant-articles
2051 "t" gnus-summary-insert-ticked-articles)
2053 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2054 "c" gnus-summary-catchup-and-exit
2055 "C" gnus-summary-catchup-all-and-exit
2056 "E" gnus-summary-exit-no-update
2057 "Q" gnus-summary-exit
2058 "Z" gnus-summary-exit
2059 "n" gnus-summary-catchup-and-goto-next-group
2060 "p" gnus-summary-catchup-and-goto-prev-group
2061 "R" gnus-summary-reselect-current-group
2062 "G" gnus-summary-rescan-group
2063 "N" gnus-summary-next-group
2064 "s" gnus-summary-save-newsrc
2065 "P" gnus-summary-prev-group)
2067 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2068 " " gnus-summary-next-page
2069 "n" gnus-summary-next-page
2070 "\177" gnus-summary-prev-page
2071 [delete] gnus-summary-prev-page
2072 "p" gnus-summary-prev-page
2073 "\r" gnus-summary-scroll-up
2074 "\M-\r" gnus-summary-scroll-down
2075 "<" gnus-summary-beginning-of-article
2076 ">" gnus-summary-end-of-article
2077 "b" gnus-summary-beginning-of-article
2078 "e" gnus-summary-end-of-article
2079 "^" gnus-summary-refer-parent-article
2080 "r" gnus-summary-refer-parent-article
2081 "C" gnus-summary-show-complete-article
2082 "D" gnus-summary-enter-digest-group
2083 "R" gnus-summary-refer-references
2084 "T" gnus-summary-refer-thread
2085 "W" gnus-warp-to-article
2086 "g" gnus-summary-show-article
2087 "s" gnus-summary-isearch-article
2088 [tab] gnus-summary-widget-forward
2089 [backtab] gnus-summary-widget-backward
2090 "P" gnus-summary-print-article
2091 "S" gnus-sticky-article
2092 "M" gnus-mailing-list-insinuate
2093 "t" gnus-article-babel)
2095 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2096 "b" gnus-article-add-buttons
2097 "B" gnus-article-add-buttons-to-head
2098 "o" gnus-article-treat-overstrike
2099 "e" gnus-article-emphasize
2100 "w" gnus-article-fill-cited-article
2101 "Q" gnus-article-fill-long-lines
2102 "L" gnus-article-toggle-truncate-lines
2103 "C" gnus-article-capitalize-sentences
2104 "c" gnus-article-remove-cr
2105 "q" gnus-article-de-quoted-unreadable
2106 "6" gnus-article-de-base64-unreadable
2107 "Z" gnus-article-decode-HZ
2108 "A" gnus-article-treat-ansi-sequences
2109 "h" gnus-article-wash-html
2110 "u" gnus-article-unsplit-urls
2111 "s" gnus-summary-force-verify-and-decrypt
2112 "f" gnus-article-display-x-face
2113 "l" gnus-summary-stop-page-breaking
2114 "r" gnus-summary-caesar-message
2115 "m" gnus-summary-morse-message
2116 "t" gnus-summary-toggle-header
2117 "g" gnus-treat-smiley
2118 "v" gnus-summary-verbose-headers
2119 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2120 "p" gnus-article-verify-x-pgp-sig
2121 "d" gnus-article-treat-dumbquotes
2122 "U" gnus-article-treat-non-ascii
2123 "i" gnus-summary-idna-message)
2125 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2126 ;; mnemonic: deuglif*Y*
2127 "u" gnus-article-outlook-unwrap-lines
2128 "a" gnus-article-outlook-repair-attribution
2129 "c" gnus-article-outlook-rearrange-citation
2130 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2132 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2133 "a" gnus-article-hide
2134 "h" gnus-article-hide-headers
2135 "b" gnus-article-hide-boring-headers
2136 "s" gnus-article-hide-signature
2137 "c" gnus-article-hide-citation
2138 "C" gnus-article-hide-citation-in-followups
2139 "l" gnus-article-hide-list-identifiers
2140 "B" gnus-article-strip-banner
2141 "P" gnus-article-hide-pem
2142 "\C-c" gnus-article-hide-citation-maybe)
2144 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2145 "a" gnus-article-highlight
2146 "h" gnus-article-highlight-headers
2147 "c" gnus-article-highlight-citation
2148 "s" gnus-article-highlight-signature)
2150 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2151 "f" gnus-article-treat-fold-headers
2152 "u" gnus-article-treat-unfold-headers
2153 "n" gnus-article-treat-fold-newsgroups)
2155 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2156 "x" gnus-article-display-x-face
2157 "d" gnus-article-display-face
2158 "s" gnus-treat-smiley
2159 "D" gnus-article-remove-images
2160 "W" gnus-article-show-images
2161 "f" gnus-treat-from-picon
2162 "m" gnus-treat-mail-picon
2163 "n" gnus-treat-newsgroups-picon
2164 "g" gnus-treat-from-gravatar
2165 "h" gnus-treat-mail-gravatar)
2167 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2168 "w" gnus-article-decode-mime-words
2169 "c" gnus-article-decode-charset
2170 "v" gnus-mime-view-all-parts
2171 "b" gnus-article-view-part)
2173 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2174 "z" gnus-article-date-ut
2175 "u" gnus-article-date-ut
2176 "l" gnus-article-date-local
2177 "p" gnus-article-date-english
2178 "e" gnus-article-date-lapsed
2179 "o" gnus-article-date-original
2180 "i" gnus-article-date-iso8601
2181 "s" gnus-article-date-user)
2183 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2184 "t" gnus-article-remove-trailing-blank-lines
2185 "l" gnus-article-strip-leading-blank-lines
2186 "m" gnus-article-strip-multiple-blank-lines
2187 "a" gnus-article-strip-blank-lines
2188 "A" gnus-article-strip-all-blank-lines
2189 "s" gnus-article-strip-leading-space
2190 "e" gnus-article-strip-trailing-space
2191 "w" gnus-article-remove-leading-whitespace)
2193 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2195 "d" gnus-summary-describe-group
2196 "h" gnus-summary-describe-briefly
2197 "i" gnus-info-find-node)
2199 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2200 "e" gnus-summary-expire-articles
2201 "\M-\C-e" gnus-summary-expire-articles-now
2202 "\177" gnus-summary-delete-article
2203 [delete] gnus-summary-delete-article
2204 [backspace] gnus-summary-delete-article
2205 "m" gnus-summary-move-article
2206 "r" gnus-summary-respool-article
2207 "w" gnus-summary-edit-article
2208 "c" gnus-summary-copy-article
2209 "B" gnus-summary-crosspost-article
2210 "q" gnus-summary-respool-query
2211 "t" gnus-summary-respool-trace
2212 "i" gnus-summary-import-article
2213 "I" gnus-summary-create-article
2214 "p" gnus-summary-article-posted-p)
2216 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2217 "o" gnus-summary-save-article
2218 "m" gnus-summary-save-article-mail
2219 "F" gnus-summary-write-article-file
2220 "r" gnus-summary-save-article-rmail
2221 "f" gnus-summary-save-article-file
2222 "b" gnus-summary-save-article-body-file
2223 "B" gnus-summary-write-article-body-file
2224 "h" gnus-summary-save-article-folder
2225 "v" gnus-summary-save-article-vm
2226 "p" gnus-summary-pipe-output
2227 "P" gnus-summary-muttprint)
2229 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2230 "b" gnus-summary-display-buttonized
2231 "m" gnus-summary-repair-multipart
2232 "v" gnus-article-view-part
2233 "o" gnus-article-save-part
2234 "O" gnus-article-save-part-and-strip
2235 "r" gnus-article-replace-part
2236 "d" gnus-article-delete-part
2237 "t" gnus-article-view-part-as-type
2238 "j" gnus-article-jump-to-part
2239 "c" gnus-article-copy-part
2240 "C" gnus-article-view-part-as-charset
2241 "e" gnus-article-view-part-externally
2242 "H" gnus-article-browse-html-article
2243 "E" gnus-article-encrypt-body
2244 "i" gnus-article-inline-part
2245 "|" gnus-article-pipe-part)
2247 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2248 "p" gnus-summary-mark-as-processable
2249 "u" gnus-summary-unmark-as-processable
2250 "U" gnus-summary-unmark-all-processable
2251 "v" gnus-uu-mark-over
2252 "s" gnus-uu-mark-series
2253 "r" gnus-uu-mark-region
2254 "g" gnus-uu-unmark-region
2255 "R" gnus-uu-mark-by-regexp
2256 "G" gnus-uu-unmark-by-regexp
2257 "t" gnus-uu-mark-thread
2258 "T" gnus-uu-unmark-thread
2259 "a" gnus-uu-mark-all
2260 "b" gnus-uu-mark-buffer
2261 "S" gnus-uu-mark-sparse
2262 "k" gnus-summary-kill-process-mark
2263 "y" gnus-summary-yank-process-mark
2264 "w" gnus-summary-save-process-mark
2265 "i" gnus-uu-invert-processable)
2267 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2268 ;;"x" gnus-uu-extract-any
2269 "m" gnus-summary-save-parts
2270 "u" gnus-uu-decode-uu
2271 "U" gnus-uu-decode-uu-and-save
2272 "s" gnus-uu-decode-unshar
2273 "S" gnus-uu-decode-unshar-and-save
2274 "o" gnus-uu-decode-save
2275 "O" gnus-uu-decode-save
2276 "b" gnus-uu-decode-binhex
2277 "B" gnus-uu-decode-binhex
2278 "Y" gnus-uu-decode-yenc
2279 "p" gnus-uu-decode-postscript
2280 "P" gnus-uu-decode-postscript-and-save)
2283 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2284 "u" gnus-uu-decode-uu-view
2285 "U" gnus-uu-decode-uu-and-save-view
2286 "s" gnus-uu-decode-unshar-view
2287 "S" gnus-uu-decode-unshar-and-save-view
2288 "o" gnus-uu-decode-save-view
2289 "O" gnus-uu-decode-save-view
2290 "b" gnus-uu-decode-binhex-view
2291 "B" gnus-uu-decode-binhex-view
2292 "p" gnus-uu-decode-postscript-view
2293 "P" gnus-uu-decode-postscript-and-save-view)
2295 (defvar gnus-article-post-menu nil)
2297 (defconst gnus-summary-menu-maxlen 20)
2299 (defun gnus-summary-menu-split (menu)
2300 ;; If we have lots of elements, divide them into groups of 20
2301 ;; and make a pane (or submenu) for each one.
2302 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2303 (let ((menu menu) sublists next
2306 ;; Pull off the next gnus-summary-menu-maxlen elements
2307 ;; and make them the next element of sublist.
2308 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2310 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2312 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2313 (aref (car (last menu)) 0)) menu)
2317 (nreverse sublists))
2318 ;; Few elements--put them all in one pane.
2321 (defun gnus-summary-make-menu-bar ()
2322 (gnus-turn-off-edit-menu 'summary)
2324 (unless (boundp 'gnus-summary-misc-menu)
2327 gnus-summary-kill-menu gnus-summary-mode-map ""
2332 ["Customize" gnus-score-customize t])
2333 (gnus-make-score-map 'increase)
2334 (gnus-make-score-map 'lower)
2336 ["Kill below" gnus-summary-kill-below t]
2337 ["Mark above" gnus-summary-mark-above t]
2338 ["Tick above" gnus-summary-tick-above t]
2339 ["Clear above" gnus-summary-clear-above t])
2340 ["Current score" gnus-summary-current-score t]
2341 ["Set score" gnus-summary-set-score t]
2342 ["Switch current score file..." gnus-score-change-score-file t]
2343 ["Set mark below..." gnus-score-set-mark-below t]
2344 ["Set expunge below..." gnus-score-set-expunge-below t]
2345 ["Edit current score file" gnus-score-edit-current-scores t]
2346 ["Edit score file..." gnus-score-edit-file t]
2347 ["Trace score" gnus-score-find-trace t]
2348 ["Find words" gnus-score-find-favourite-words t]
2349 ["Rescore buffer" gnus-summary-rescore t]
2350 ["Increase score..." gnus-summary-increase-score t]
2351 ["Lower score..." gnus-summary-lower-score t]))))
2353 ;; Define both the Article menu in the summary buffer and the
2354 ;; equivalent Commands menu in the article buffer here for
2358 ["All" gnus-article-hide t]
2359 ["Headers" gnus-article-hide-headers t]
2360 ["Signature" gnus-article-hide-signature t]
2361 ["Citation" gnus-article-hide-citation t]
2362 ["List identifiers" gnus-article-hide-list-identifiers t]
2363 ["Banner" gnus-article-strip-banner t]
2364 ["Boring headers" gnus-article-hide-boring-headers t])
2366 ["All" gnus-article-highlight t]
2367 ["Headers" gnus-article-highlight-headers t]
2368 ["Signature" gnus-article-highlight-signature t]
2369 ["Citation" gnus-article-highlight-citation t])
2371 ["Words" gnus-article-decode-mime-words t]
2372 ["Charset" gnus-article-decode-charset t]
2373 ["QP" gnus-article-de-quoted-unreadable t]
2374 ["Base64" gnus-article-de-base64-unreadable t]
2375 ["View MIME buttons" gnus-summary-display-buttonized t]
2376 ["View all" gnus-mime-view-all-parts t]
2377 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2378 ["Encrypt body" gnus-article-encrypt-body
2379 :active (not (gnus-group-read-only-p))
2380 ,@(if (featurep 'xemacs) nil
2381 '(:help "Encrypt the message body on disk"))]
2382 ["Extract all parts..." gnus-summary-save-parts t]
2384 ["Repair multipart" gnus-summary-repair-multipart t]
2385 ["Pipe part..." gnus-article-pipe-part t]
2386 ["Inline part" gnus-article-inline-part t]
2387 ["View part as type..." gnus-article-view-part-as-type t]
2388 ["Encrypt body" gnus-article-encrypt-body
2389 :active (not (gnus-group-read-only-p))
2390 ,@(if (featurep 'xemacs) nil
2391 '(:help "Encrypt the message body on disk"))]
2392 ["View part externally" gnus-article-view-part-externally t]
2393 ["View HTML parts in browser" gnus-article-browse-html-article t]
2394 ["View part with charset..." gnus-article-view-part-as-charset t]
2395 ["Copy part" gnus-article-copy-part t]
2396 ["Save part..." gnus-article-save-part t]
2397 ["View part" gnus-article-view-part t]))
2399 ["Local" gnus-article-date-local t]
2400 ["ISO8601" gnus-article-date-iso8601 t]
2401 ["UT" gnus-article-date-ut t]
2402 ["Original" gnus-article-date-original t]
2403 ["Lapsed" gnus-article-date-lapsed t]
2404 ["User-defined" gnus-article-date-user t])
2406 ["Remove images" gnus-article-remove-images t]
2407 ["Toggle smiley" gnus-treat-smiley t]
2408 ["Show X-Face" gnus-article-display-x-face t]
2409 ["Show picons in From" gnus-treat-from-picon t]
2410 ["Show picons in mail headers" gnus-treat-mail-picon t]
2411 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2412 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2413 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2414 ("View as different encoding"
2415 ,@(gnus-summary-menu-split
2418 ;; Since easymenu under Emacs doesn't allow
2419 ;; lambda forms for menu commands, we should
2420 ;; provide intern'ed function symbols.
2421 (let ((command (intern (format "\
2422 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2426 (let ((gnus-summary-show-article-charset-alist
2428 (gnus-summary-show-article 1))))
2429 `[,(symbol-name cs) ,command t]))
2430 (sort (if (fboundp 'coding-system-list)
2431 (coding-system-list)
2432 (mapcar 'car mm-mime-mule-charset-alist))
2436 ["Leading" gnus-article-strip-leading-blank-lines t]
2437 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2438 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2439 ["All of the above" gnus-article-strip-blank-lines t]
2440 ["All" gnus-article-strip-all-blank-lines t]
2441 ["Leading space" gnus-article-strip-leading-space t]
2442 ["Trailing space" gnus-article-strip-trailing-space t]
2443 ["Leading space in headers"
2444 gnus-article-remove-leading-whitespace t])
2445 ["Overstrike" gnus-article-treat-overstrike t]
2446 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2447 ["Non-ASCII" gnus-article-treat-non-ascii t]
2448 ["Emphasis" gnus-article-emphasize t]
2449 ["Word wrap" gnus-article-fill-cited-article t]
2450 ["Fill long lines" gnus-article-fill-long-lines t]
2451 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2452 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2453 ["Remove CR" gnus-article-remove-cr t]
2454 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2455 ["Base64" gnus-article-de-base64-unreadable t]
2456 ["Rot 13" gnus-summary-caesar-message
2457 ,@(if (featurep 'xemacs) '(t)
2458 '(:help "\"Caesar rotate\" article by 13"))]
2459 ["De-IDNA" gnus-summary-idna-message t]
2460 ["Morse decode" gnus-summary-morse-message t]
2461 ["Unix pipe..." gnus-summary-pipe-message t]
2462 ["Add buttons" gnus-article-add-buttons t]
2463 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2464 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2465 ["Verbose header" gnus-summary-verbose-headers t]
2466 ["Toggle header" gnus-summary-toggle-header t]
2467 ["Unfold headers" gnus-article-treat-unfold-headers t]
2468 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2469 ["Html" gnus-article-wash-html t]
2470 ["Unsplit URLs" gnus-article-unsplit-urls t]
2471 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2472 ["Decode HZ" gnus-article-decode-HZ t]
2473 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2474 ("(Outlook) Deuglify"
2475 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2476 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2477 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2478 ["Full (Outlook) deuglify"
2479 gnus-article-outlook-deuglify-article t])
2482 ["Save in default format..." gnus-summary-save-article
2483 ,@(if (featurep 'xemacs) '(t)
2484 '(:help "Save article using default method"))]
2485 ["Save in file..." gnus-summary-save-article-file
2486 ,@(if (featurep 'xemacs) '(t)
2487 '(:help "Save article in file"))]
2488 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2489 ["Save in MH folder..." gnus-summary-save-article-folder t]
2490 ["Save in VM folder..." gnus-summary-save-article-vm t]
2491 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2492 ["Save body in file..." gnus-summary-save-article-body-file t]
2493 ["Pipe through a filter..." gnus-summary-pipe-output t]
2494 ["Print with Muttprint..." gnus-summary-muttprint t]
2495 ["Print" gnus-summary-print-article
2496 ,@(if (featurep 'xemacs) '(t)
2497 '(:help "Generate and print a PostScript image"))])
2498 ("Copy, move,... (Backend)"
2499 ,@(if (featurep 'xemacs) nil
2500 '(:help "Copying, moving, expiring articles..."))
2501 ["Respool article..." gnus-summary-respool-article t]
2502 ["Move article..." gnus-summary-move-article
2503 (gnus-check-backend-function
2504 'request-move-article gnus-newsgroup-name)]
2505 ["Copy article..." gnus-summary-copy-article t]
2506 ["Crosspost article..." gnus-summary-crosspost-article
2507 (gnus-check-backend-function
2508 'request-replace-article gnus-newsgroup-name)]
2509 ["Import file..." gnus-summary-import-article
2510 (gnus-check-backend-function
2511 'request-accept-article gnus-newsgroup-name)]
2512 ["Create article..." gnus-summary-create-article
2513 (gnus-check-backend-function
2514 'request-accept-article gnus-newsgroup-name)]
2515 ["Check if posted" gnus-summary-article-posted-p t]
2516 ["Edit article" gnus-summary-edit-article
2517 (not (gnus-group-read-only-p))]
2518 ["Delete article" gnus-summary-delete-article
2519 (gnus-check-backend-function
2520 'request-expire-articles gnus-newsgroup-name)]
2521 ["Query respool" gnus-summary-respool-query t]
2522 ["Trace respool" gnus-summary-respool-trace t]
2523 ["Delete expirable articles" gnus-summary-expire-articles-now
2524 (gnus-check-backend-function
2525 'request-expire-articles gnus-newsgroup-name)])
2527 ["Uudecode" gnus-uu-decode-uu
2528 ,@(if (featurep 'xemacs) '(t)
2529 '(:help "Decode uuencoded article(s)"))]
2530 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2531 ["Unshar" gnus-uu-decode-unshar t]
2532 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2533 ["Save" gnus-uu-decode-save t]
2534 ["Binhex" gnus-uu-decode-binhex t]
2535 ["PostScript" gnus-uu-decode-postscript t]
2536 ["All MIME parts" gnus-summary-save-parts t])
2538 ["Enter article" gnus-cache-enter-article t]
2539 ["Remove article" gnus-cache-remove-article t])
2540 ["Translate" gnus-article-babel t]
2541 ["Select article buffer" gnus-summary-select-article-buffer t]
2542 ["Make article buffer sticky" gnus-sticky-article t]
2543 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2544 ["Isearch article..." gnus-summary-isearch-article t]
2545 ["Beginning of the article" gnus-summary-beginning-of-article t]
2546 ["End of the article" gnus-summary-end-of-article t]
2547 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2548 ["Fetch referenced articles" gnus-summary-refer-references t]
2549 ["Fetch current thread" gnus-summary-refer-thread t]
2550 ["Fetch article with id..." gnus-summary-refer-article t]
2551 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2552 ["Redisplay" gnus-summary-show-article t]
2553 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2555 gnus-summary-article-menu gnus-summary-mode-map ""
2556 (cons "Article" innards))
2558 (if (not (keymapp gnus-summary-article-menu))
2560 gnus-article-commands-menu gnus-article-mode-map ""
2561 (cons "Commands" innards))
2562 ;; in Emacs, don't share menu.
2563 (setq gnus-article-commands-menu
2564 (copy-keymap gnus-summary-article-menu))
2565 (define-key gnus-article-mode-map [menu-bar commands]
2566 (cons "Commands" gnus-article-commands-menu))))
2569 gnus-summary-thread-menu gnus-summary-mode-map ""
2571 ["Find all messages in thread" gnus-summary-refer-thread t]
2572 ["Toggle threading" gnus-summary-toggle-threads t]
2573 ["Hide threads" gnus-summary-hide-all-threads t]
2574 ["Show threads" gnus-summary-show-all-threads t]
2575 ["Hide thread" gnus-summary-hide-thread t]
2576 ["Show thread" gnus-summary-show-thread t]
2577 ["Go to next thread" gnus-summary-next-thread t]
2578 ["Go to previous thread" gnus-summary-prev-thread t]
2579 ["Go down thread" gnus-summary-down-thread t]
2580 ["Go up thread" gnus-summary-up-thread t]
2581 ["Top of thread" gnus-summary-top-thread t]
2582 ["Mark thread as read" gnus-summary-kill-thread t]
2583 ["Mark thread as expired" gnus-summary-expire-thread t]
2584 ["Lower thread score" gnus-summary-lower-thread t]
2585 ["Raise thread score" gnus-summary-raise-thread t]
2586 ["Rethread current" gnus-summary-rethread-current t]))
2589 gnus-summary-post-menu gnus-summary-mode-map ""
2591 ["Send a message (mail or news)" gnus-summary-post-news
2592 ,@(if (featurep 'xemacs) '(t)
2593 '(:help "Compose a new message (mail or news)"))]
2594 ["Followup" gnus-summary-followup
2595 ,@(if (featurep 'xemacs) '(t)
2596 '(:help "Post followup to this article"))]
2597 ["Followup and yank" gnus-summary-followup-with-original
2598 ,@(if (featurep 'xemacs) '(t)
2599 '(:help "Post followup to this article, quoting its contents"))]
2600 ["Supersede article" gnus-summary-supersede-article t]
2601 ["Cancel article" gnus-summary-cancel-article
2602 ,@(if (featurep 'xemacs) '(t)
2603 '(:help "Cancel an article you posted"))]
2604 ["Reply" gnus-summary-reply t]
2605 ["Reply and yank" gnus-summary-reply-with-original t]
2606 ["Wide reply" gnus-summary-wide-reply t]
2607 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2608 ,@(if (featurep 'xemacs) '(t)
2609 '(:help "Mail a reply, quoting this article"))]
2610 ["Very wide reply" gnus-summary-very-wide-reply t]
2611 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2612 ,@(if (featurep 'xemacs) '(t)
2613 '(:help "Mail a very wide reply, quoting this article"))]
2614 ["Mail forward" gnus-summary-mail-forward t]
2615 ["Post forward" gnus-summary-post-forward t]
2616 ["Digest and mail" gnus-uu-digest-mail-forward t]
2617 ["Digest and post" gnus-uu-digest-post-forward t]
2618 ["Resend message" gnus-summary-resend-message t]
2619 ["Resend message edit" gnus-summary-resend-message-edit t]
2620 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2621 ["Send a mail" gnus-summary-mail-other-window t]
2622 ["Create a local message" gnus-summary-news-other-window t]
2623 ["Uuencode and post" gnus-uu-post-news
2624 ,@(if (featurep 'xemacs) '(t)
2625 '(:help "Post a uuencoded article"))]
2626 ["Followup via news" gnus-summary-followup-to-mail t]
2627 ["Followup via news and yank"
2628 gnus-summary-followup-to-mail-with-original t]
2629 ["Strip signature on reply"
2632 (if (not (memq message-cite-function
2633 '(message-cite-original-without-signature
2634 message-cite-original)))
2635 ;; Stupid workaround for XEmacs not honoring :visible.
2636 (message "Can't toggle this value of `message-cite-function'")
2637 (setq message-cite-function
2638 (if (eq message-cite-function
2639 'message-cite-original-without-signature)
2640 'message-cite-original
2641 'message-cite-original-without-signature))))
2642 ;; XEmacs barfs on :visible.
2643 ,@(if (featurep 'xemacs) nil
2644 '(:visible (memq message-cite-function
2645 '(message-cite-original-without-signature
2646 message-cite-original))))
2648 :selected (eq message-cite-function
2649 'message-cite-original-without-signature)
2650 ,@(if (featurep 'xemacs) nil
2651 '(:help "Strip signature from cited article when replying."))]
2653 ;;["Send" gnus-summary-send-draft t]
2654 ;;["Send bounced" gnus-resend-bounced-mail t])
2658 ((not (keymapp gnus-summary-post-menu))
2659 (setq gnus-article-post-menu gnus-summary-post-menu))
2660 ((not gnus-article-post-menu)
2661 ;; Don't share post menu.
2662 (setq gnus-article-post-menu
2663 (copy-keymap gnus-summary-post-menu))))
2664 (define-key gnus-article-mode-map [menu-bar post]
2665 (cons "Post" gnus-article-post-menu))
2668 gnus-summary-misc-menu gnus-summary-mode-map ""
2671 ["Mark as read" gnus-summary-mark-as-read-forward t]
2672 ["Mark same subject and select"
2673 gnus-summary-kill-same-subject-and-select t]
2674 ["Mark same subject" gnus-summary-kill-same-subject t]
2675 ["Catchup" gnus-summary-catchup
2676 ,@(if (featurep 'xemacs) '(t)
2677 '(:help "Mark unread articles in this group as read"))]
2678 ["Catchup all" gnus-summary-catchup-all t]
2679 ["Catchup to here" gnus-summary-catchup-to-here t]
2680 ["Catchup from here" gnus-summary-catchup-from-here t]
2681 ["Catchup region" gnus-summary-mark-region-as-read
2682 (gnus-mark-active-p)]
2683 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2685 ["Tick" gnus-summary-tick-article-forward t]
2686 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2687 ["Remove marks" gnus-summary-clear-mark-forward t]
2688 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2689 ["Set bookmark" gnus-summary-set-bookmark t]
2690 ["Remove bookmark" gnus-summary-remove-bookmark t])
2692 ["Marks..." gnus-summary-limit-to-marks t]
2693 ["Subject..." gnus-summary-limit-to-subject t]
2694 ["Author..." gnus-summary-limit-to-author t]
2695 ["Recipient..." gnus-summary-limit-to-recipient t]
2696 ["Address..." gnus-summary-limit-to-address t]
2697 ["Age..." gnus-summary-limit-to-age t]
2698 ["Extra..." gnus-summary-limit-to-extra t]
2699 ["Score..." gnus-summary-limit-to-score t]
2700 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2701 ["Unread" gnus-summary-limit-to-unread t]
2702 ["Unseen" gnus-summary-limit-to-unseen t]
2703 ["Singletons" gnus-summary-limit-to-singletons t]
2704 ["Replied" gnus-summary-limit-to-replied t]
2705 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2706 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2707 ["Pop limit" gnus-summary-pop-limit t]
2708 ["Show dormant" gnus-summary-limit-include-dormant t]
2709 ["Hide childless dormant"
2710 gnus-summary-limit-exclude-childless-dormant t]
2711 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2712 ["Hide marked" gnus-summary-limit-exclude-marks t]
2713 ["Show expunged" gnus-summary-limit-include-expunged t])
2715 ["Set mark" gnus-summary-mark-as-processable t]
2716 ["Remove mark" gnus-summary-unmark-as-processable t]
2717 ["Remove all marks" gnus-summary-unmark-all-processable t]
2718 ["Invert marks" gnus-uu-invert-processable t]
2719 ["Mark above" gnus-uu-mark-over t]
2720 ["Mark series" gnus-uu-mark-series t]
2721 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2722 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2723 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2724 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2725 ["Mark all" gnus-uu-mark-all t]
2726 ["Mark buffer" gnus-uu-mark-buffer t]
2727 ["Mark sparse" gnus-uu-mark-sparse t]
2728 ["Mark thread" gnus-uu-mark-thread t]
2729 ["Unmark thread" gnus-uu-unmark-thread t]
2730 ("Process Mark Sets"
2731 ["Kill" gnus-summary-kill-process-mark t]
2732 ["Yank" gnus-summary-yank-process-mark
2733 gnus-newsgroup-process-stack]
2734 ["Save" gnus-summary-save-process-mark t]
2735 ["Run command on marked..." gnus-summary-universal-argument t]))
2738 ["Page forward" gnus-summary-next-page
2739 ,@(if (featurep 'xemacs) '(t)
2740 '(:help "Show next page of article"))]
2741 ["Page backward" gnus-summary-prev-page
2742 ,@(if (featurep 'xemacs) '(t)
2743 '(:help "Show previous page of article"))]
2744 ["Line forward" gnus-summary-scroll-up t])
2746 ["Next unread article" gnus-summary-next-unread-article t]
2747 ["Previous unread article" gnus-summary-prev-unread-article t]
2748 ["Next article" gnus-summary-next-article t]
2749 ["Previous article" gnus-summary-prev-article t]
2750 ["Next unread subject" gnus-summary-next-unread-subject t]
2751 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2752 ["Next article same subject" gnus-summary-next-same-subject t]
2753 ["Previous article same subject" gnus-summary-prev-same-subject t]
2754 ["First unread article" gnus-summary-first-unread-article t]
2755 ["Best unread article" gnus-summary-best-unread-article t]
2756 ["Go to subject number..." gnus-summary-goto-subject t]
2757 ["Go to article number..." gnus-summary-goto-article t]
2758 ["Go to the last article" gnus-summary-goto-last-article t]
2759 ["Pop article off history" gnus-summary-pop-article t])
2761 ["Sort by number" gnus-summary-sort-by-number t]
2762 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2763 ["Sort by author" gnus-summary-sort-by-author t]
2764 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2765 ["Sort by subject" gnus-summary-sort-by-subject t]
2766 ["Sort by date" gnus-summary-sort-by-date t]
2767 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2768 ["Sort by score" gnus-summary-sort-by-score t]
2769 ["Sort by lines" gnus-summary-sort-by-lines t]
2770 ["Sort by characters" gnus-summary-sort-by-chars t]
2771 ["Randomize" gnus-summary-sort-by-random t]
2772 ["Original sort" gnus-summary-sort-by-original t])
2774 ["Describe group" gnus-summary-describe-group t]
2775 ["Read manual" gnus-info-find-node t])
2777 ["Pick and read" gnus-pick-mode t]
2778 ["Binary" gnus-binary-mode t])
2780 ["Regenerate" gnus-summary-prepare t]
2781 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2782 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2783 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2784 ["Toggle threading" gnus-summary-toggle-threads t])
2785 ["See old articles" gnus-summary-insert-old-articles t]
2786 ["See new articles" gnus-summary-insert-new-articles t]
2787 ["Filter articles..." gnus-summary-execute-command t]
2788 ["Run command on articles..." gnus-summary-universal-argument t]
2789 ["Search articles forward..." gnus-summary-search-article-forward t]
2790 ["Search articles backward..." gnus-summary-search-article-backward t]
2791 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2792 ["Expand window" gnus-summary-expand-window t]
2793 ["Expire expirable articles" gnus-summary-expire-articles
2794 (gnus-check-backend-function
2795 'request-expire-articles gnus-newsgroup-name)]
2796 ["Edit local kill file" gnus-summary-edit-local-kill t]
2797 ["Edit main kill file" gnus-summary-edit-global-kill t]
2798 ["Edit group parameters" gnus-summary-edit-parameters t]
2799 ["Customize group parameters" gnus-summary-customize-parameters t]
2800 ["Send a bug report" gnus-bug t]
2802 ["Catchup and exit" gnus-summary-catchup-and-exit
2803 ,@(if (featurep 'xemacs) '(t)
2804 '(:help "Mark unread articles in this group as read, then exit"))]
2805 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2806 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2807 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2808 ["Exit group" gnus-summary-exit
2809 ,@(if (featurep 'xemacs) '(t)
2810 '(:help "Exit current group, return to group selection mode"))]
2811 ["Exit group without updating" gnus-summary-exit-no-update t]
2812 ["Exit and goto next group" gnus-summary-next-group t]
2813 ["Exit and goto prev group" gnus-summary-prev-group t]
2814 ["Reselect group" gnus-summary-reselect-current-group t]
2815 ["Rescan group" gnus-summary-rescan-group t]
2816 ["Update dribble" gnus-summary-save-newsrc t])))
2818 (gnus-run-hooks 'gnus-summary-menu-hook)))
2820 (defvar gnus-summary-tool-bar-map nil)
2822 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2823 ;; affect _new_ message buffers. We might add a function that walks thru all
2824 ;; summary-mode buffers and force the update.
2825 (defun gnus-summary-tool-bar-update (&optional symbol value)
2826 "Update summary mode toolbar.
2827 Setter function for custom variables."
2828 (setq-default gnus-summary-tool-bar-map nil)
2830 ;; When used as ":set" function:
2831 (set-default symbol value))
2832 (when (gnus-buffer-live-p gnus-summary-buffer)
2833 (with-current-buffer gnus-summary-buffer
2834 (gnus-summary-make-tool-bar))))
2836 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2837 'gnus-summary-tool-bar-gnome
2838 'gnus-summary-tool-bar-retro)
2839 "Specifies the Gnus summary tool bar.
2841 It can be either a list or a symbol referring to a list. See
2842 `gmm-tool-bar-from-list' for the format of the list. The
2843 default key map is `gnus-summary-mode-map'.
2845 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2846 `gnus-summary-tool-bar-retro'."
2847 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2848 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2849 (repeat :tag "User defined list" gmm-tool-bar-item)
2851 :version "23.1" ;; No Gnus
2852 :initialize 'custom-initialize-default
2853 :set 'gnus-summary-tool-bar-update
2854 :group 'gnus-summary)
2856 (defcustom gnus-summary-tool-bar-gnome
2857 '((gnus-summary-post-news "mail/compose" nil)
2858 (gnus-summary-insert-new-articles "mail/inbox" nil
2859 :visible (or (not gnus-agent)
2861 (gnus-summary-reply-with-original "mail/reply")
2862 (gnus-summary-reply "mail/reply" nil :visible nil)
2863 (gnus-summary-followup-with-original "mail/reply-all")
2864 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2865 (gnus-summary-mail-forward "mail/forward")
2866 (gnus-summary-save-article "mail/save")
2867 (gnus-summary-search-article-forward "search" nil :visible nil)
2868 (gnus-summary-print-article "print")
2869 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2870 ;; Some new commands that may need more suitable icons:
2871 (gnus-summary-save-newsrc "save" nil :visible nil)
2872 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2873 (gnus-summary-prev-article "left-arrow")
2874 (gnus-summary-next-article "right-arrow")
2875 (gnus-summary-next-page "next-page")
2876 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2878 ;; Maybe some sort-by-... could be added:
2879 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2880 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2881 (gnus-summary-mark-as-expirable
2883 :visible (gnus-check-backend-function 'request-expire-articles
2884 gnus-newsgroup-name))
2885 (gnus-summary-mark-as-spam
2887 :visible (and (fboundp 'spam-group-ham-contents-p)
2888 (spam-group-ham-contents-p gnus-newsgroup-name))
2889 :help "Mark as spam")
2890 (gnus-summary-mark-as-read-forward
2892 :visible (and (fboundp 'spam-group-spam-contents-p)
2893 (spam-group-spam-contents-p gnus-newsgroup-name)))
2895 (gnus-summary-exit "exit")
2896 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2897 (gnus-info-find-node "help"))
2898 "List of functions for the summary tool bar (GNOME style).
2900 See `gmm-tool-bar-from-list' for the format of the list."
2901 :type '(repeat gmm-tool-bar-item)
2902 :version "23.1" ;; No Gnus
2903 :initialize 'custom-initialize-default
2904 :set 'gnus-summary-tool-bar-update
2905 :group 'gnus-summary)
2907 (defcustom gnus-summary-tool-bar-retro
2908 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2909 (gnus-summary-next-unread-article "gnus/next-ur")
2910 (gnus-summary-post-news "gnus/post")
2911 (gnus-summary-followup-with-original "gnus/fuwo")
2912 (gnus-summary-followup "gnus/followup")
2913 (gnus-summary-reply-with-original "gnus/reply-wo")
2914 (gnus-summary-reply "gnus/reply")
2915 (gnus-summary-caesar-message "gnus/rot13")
2916 (gnus-uu-decode-uu "gnus/uu-decode")
2917 (gnus-summary-save-article-file "gnus/save-aif")
2918 (gnus-summary-save-article "gnus/save-art")
2919 (gnus-uu-post-news "gnus/uu-post")
2920 (gnus-summary-catchup "gnus/catchup")
2921 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2922 (gnus-summary-exit "gnus/exit-summ")
2923 ;; Some new command that may need more suitable icons:
2924 (gnus-summary-print-article "gnus/print" nil :visible nil)
2925 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2926 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2927 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2928 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2929 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2930 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2932 (gnus-info-find-node "gnus/help" nil :visible nil))
2933 "List of functions for the summary tool bar (retro look).
2935 See `gmm-tool-bar-from-list' for the format of the list."
2936 :type '(repeat gmm-tool-bar-item)
2937 :version "23.1" ;; No Gnus
2938 :initialize 'custom-initialize-default
2939 :set 'gnus-summary-tool-bar-update
2940 :group 'gnus-summary)
2942 (defcustom gnus-summary-tool-bar-zap-list t
2943 "List of icon items from the global tool bar.
2944 These items are not displayed in the Gnus summary mode tool bar.
2946 See `gmm-tool-bar-from-list' for the format of the list."
2947 :type 'gmm-tool-bar-zap-list
2948 :version "23.1" ;; No Gnus
2949 :initialize 'custom-initialize-default
2950 :set 'gnus-summary-tool-bar-update
2951 :group 'gnus-summary)
2953 (defvar image-load-path)
2954 (defvar tool-bar-map)
2956 (defun gnus-summary-make-tool-bar (&optional force)
2957 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2958 When FORCE, rebuild the tool bar."
2959 (when (and (not (featurep 'xemacs))
2960 (boundp 'tool-bar-mode)
2962 (or (not gnus-summary-tool-bar-map) force))
2964 (gmm-image-load-path-for-library "gnus"
2967 (image-load-path (cons (car load-path)
2968 (when (boundp 'image-load-path)
2970 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2971 gnus-summary-tool-bar-zap-list
2972 'gnus-summary-mode-map)))
2974 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2976 (setq gnus-summary-tool-bar-map map))))
2977 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2979 (defun gnus-score-set-default (var value)
2980 "A version of set that updates the GNU Emacs menu-bar."
2982 ;; It is the message that forces the active status to be updated.
2985 (defun gnus-make-score-map (type)
2986 "Make a summary score map of type TYPE."
2989 (let ((headers '(("author" "from" string)
2990 ("subject" "subject" string)
2991 ("article body" "body" string)
2992 ("article head" "head" string)
2993 ("xref" "xref" string)
2994 ("extra header" "extra" string)
2995 ("lines" "lines" number)
2996 ("followups to author" "followup" string)))
2997 (types '((number ("less than" <)
3000 (string ("substring" s)
3004 (perms '(("temporary" (current-time-string))
3012 (if (eq type 'lower)
3017 (setq header (car headers))
3023 (let ((ts (cdr (assoc (nth 2 header) types)))
3039 'gnus-summary-score-entry
3041 (if (or (string= (nth 1 header)
3043 (string= (nth 1 header)
3046 (list 'gnus-summary-header
3048 (list 'quote (nth 1 (car ts)))
3049 (list 'gnus-score-delta-default
3056 (list (nreverse outp))))
3059 (list (nreverse outt))))
3061 (setq headers (cdr headers)))
3062 (list (nreverse outh))))))))
3065 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3066 (defvar bookmark-make-record-function)
3068 (defvar bidi-paragraph-direction)
3070 (defun gnus-summary-mode (&optional group)
3071 "Major mode for reading articles.
3073 All normal editing commands are switched off.
3074 \\<gnus-summary-mode-map>
3075 Each line in this buffer represents one article. To read an
3076 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3077 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3080 You can also post articles and send mail from this buffer. To
3081 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3082 of an article, type `\\[gnus-summary-reply]'.
3084 There are approx. one gazillion commands you can execute in this
3085 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3087 The following commands are available:
3089 \\{gnus-summary-mode-map}"
3091 (kill-all-local-variables)
3092 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3093 (gnus-summary-make-local-variables))
3094 (gnus-summary-make-local-variables)
3095 (setq gnus-newsgroup-name group)
3096 (when (gnus-visual-p 'summary-menu 'menu)
3097 (gnus-summary-make-menu-bar)
3098 (gnus-summary-make-tool-bar))
3099 (gnus-make-thread-indent-array)
3100 (gnus-simplify-mode-line)
3101 (setq major-mode 'gnus-summary-mode)
3102 (setq mode-name "Summary")
3103 (use-local-map gnus-summary-mode-map)
3104 (buffer-disable-undo)
3105 (setq buffer-read-only t ;Disable modification
3106 show-trailing-whitespace nil)
3107 (setq truncate-lines t)
3108 ;; Force paragraph direction to be left-to-right. Don't make it
3109 ;; bound globally in old Emacsen and XEmacsen.
3110 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3111 (add-to-invisibility-spec '(gnus-sum . t))
3112 (gnus-summary-set-display-table)
3113 (gnus-set-default-directory)
3114 (make-local-variable 'gnus-summary-line-format)
3115 (make-local-variable 'gnus-summary-line-format-spec)
3116 (make-local-variable 'gnus-summary-dummy-line-format)
3117 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3118 (make-local-variable 'gnus-summary-mark-positions)
3119 (gnus-make-local-hook 'pre-command-hook)
3120 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3121 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3122 (turn-on-gnus-mailing-list-mode)
3123 (mm-enable-multibyte)
3124 (set (make-local-variable 'bookmark-make-record-function)
3125 'gnus-summary-bookmark-make-record)
3126 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3127 (gnus-update-summary-mark-positions))
3129 (defun gnus-summary-make-local-variables ()
3130 "Make all the local summary buffer variables."
3132 (dolist (local gnus-summary-local-variables)
3135 (if (eq (cdr local) 'global)
3136 ;; Copy the global value of the variable.
3137 (setq global (symbol-value (car local)))
3138 ;; Use the value from the list.
3139 (setq global (eval (cdr local))))
3140 (set (make-local-variable (car local)) global))
3141 ;; Simple nil-valued local variable.
3142 (set (make-local-variable local) nil)))))
3144 ;; Summary data functions.
3146 (defmacro gnus-data-number (data)
3149 (defmacro gnus-data-set-number (data number)
3150 `(setcar ,data ,number))
3152 (defmacro gnus-data-mark (data)
3155 (defmacro gnus-data-set-mark (data mark)
3156 `(setcar (nthcdr 1 ,data) ,mark))
3158 (defmacro gnus-data-pos (data)
3161 (defmacro gnus-data-set-pos (data pos)
3162 `(setcar (nthcdr 2 ,data) ,pos))
3164 (defmacro gnus-data-header (data)
3167 (defmacro gnus-data-set-header (data header)
3168 `(setf (nth 3 ,data) ,header))
3170 (defmacro gnus-data-level (data)
3173 (defmacro gnus-data-unread-p (data)
3174 `(= (nth 1 ,data) gnus-unread-mark))
3176 (defmacro gnus-data-read-p (data)
3177 `(/= (nth 1 ,data) gnus-unread-mark))
3179 (defmacro gnus-data-pseudo-p (data)
3180 `(consp (nth 3 ,data)))
3182 (defmacro gnus-data-find (number)
3183 `(assq ,number gnus-newsgroup-data))
3185 (defmacro gnus-data-find-list (number &optional data)
3186 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3187 (memq (assq ,number bdata)
3190 (defmacro gnus-data-make (number mark pos header level)
3191 `(list ,number ,mark ,pos ,header ,level))
3193 (defun gnus-data-enter (after-article number mark pos header level offset)
3194 (let ((data (gnus-data-find-list after-article)))
3196 (error "No such article: %d" after-article))
3197 (setcdr data (cons (gnus-data-make number mark pos header level)
3199 (setq gnus-newsgroup-data-reverse nil)
3200 (gnus-data-update-list (cddr data) offset)))
3202 (defun gnus-data-enter-list (after-article list &optional offset)
3204 (let ((data (and after-article (gnus-data-find-list after-article)))
3208 (let ((odata gnus-newsgroup-data))
3209 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3211 (gnus-data-update-list odata offset)))
3212 ;; Find the last element in the list to be spliced into the main
3214 (setq list (last list))
3217 (setcdr list gnus-newsgroup-data)
3218 (setq gnus-newsgroup-data ilist)
3220 (gnus-data-update-list (cdr list) offset)))
3221 (setcdr list (cdr data))
3224 (gnus-data-update-list (cdr list) offset))))
3225 (setq gnus-newsgroup-data-reverse nil))))
3227 (defun gnus-data-remove (article &optional offset)
3228 (let ((data gnus-newsgroup-data))
3229 (if (= (gnus-data-number (car data)) article)
3231 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3232 gnus-newsgroup-data-reverse nil)
3234 (gnus-data-update-list gnus-newsgroup-data offset)))
3236 (when (= (gnus-data-number (cadr data)) article)
3237 (setcdr data (cddr data))
3239 (gnus-data-update-list (cdr data) offset))
3241 gnus-newsgroup-data-reverse nil))
3242 (setq data (cdr data))))))
3244 (defmacro gnus-data-list (backward)
3246 (or gnus-newsgroup-data-reverse
3247 (setq gnus-newsgroup-data-reverse
3248 (reverse gnus-newsgroup-data)))
3249 gnus-newsgroup-data))
3251 (defun gnus-data-update-list (data offset)
3252 "Add OFFSET to the POS of all data entries in DATA."
3253 (setq gnus-newsgroup-data-reverse nil)
3255 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3256 (setq data (cdr data))))
3258 (defun gnus-summary-article-pseudo-p (article)
3259 "Say whether this article is a pseudo article or not."
3260 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3262 (defmacro gnus-summary-article-sparse-p (article)
3263 "Say whether this article is a sparse article or not."
3264 `(memq ,article gnus-newsgroup-sparse))
3266 (defmacro gnus-summary-article-ancient-p (article)
3267 "Say whether this article is a sparse article or not."
3268 `(memq ,article gnus-newsgroup-ancient))
3270 (defun gnus-article-parent-p (number)
3271 "Say whether this article is a parent or not."
3272 (let ((data (gnus-data-find-list number)))
3273 (and (cdr data) ; There has to be an article after...
3274 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3275 (gnus-data-level (nth 1 data))))))
3277 (defun gnus-article-children (number)
3278 "Return a list of all children to NUMBER."
3279 (let* ((data (gnus-data-find-list number))
3280 (level (gnus-data-level (car data)))
3282 (setq data (cdr data))
3284 (= (gnus-data-level (car data)) (1+ level)))
3285 (push (gnus-data-number (car data)) children)
3286 (setq data (cdr data)))
3289 (defmacro gnus-summary-skip-intangible ()
3290 "If the current article is intangible, then jump to a different article."
3291 '(let ((to (get-text-property (point) 'gnus-intangible)))
3292 (and to (gnus-summary-goto-subject to))))
3294 (defmacro gnus-summary-article-intangible-p ()
3295 "Say whether this article is intangible or not."
3296 '(get-text-property (point) 'gnus-intangible))
3298 (defun gnus-article-read-p (article)
3299 "Say whether ARTICLE is read or not."
3300 (not (or (memq article gnus-newsgroup-marked)
3301 (memq article gnus-newsgroup-spam-marked)
3302 (memq article gnus-newsgroup-unreads)
3303 (memq article gnus-newsgroup-unselected)
3304 (memq article gnus-newsgroup-dormant))))
3306 ;; Some summary mode macros.
3308 (defmacro gnus-summary-article-number ()
3309 "The article number of the article on the current line.
3310 If there isn't an article number here, then we return the current
3313 (gnus-summary-skip-intangible)
3314 (or (get-text-property (point) 'gnus-number)
3315 (gnus-summary-last-subject))))
3317 (defmacro gnus-summary-article-header (&optional number)
3318 "Return the header of article NUMBER."
3319 `(gnus-data-header (gnus-data-find
3320 ,(or number '(gnus-summary-article-number)))))
3322 (defmacro gnus-summary-thread-level (&optional number)
3323 "Return the level of thread that starts with article NUMBER."
3324 `(if (and (eq gnus-summary-make-false-root 'dummy)
3325 (get-text-property (point) 'gnus-intangible))
3327 (gnus-data-level (gnus-data-find
3328 ,(or number '(gnus-summary-article-number))))))
3330 (defmacro gnus-summary-article-mark (&optional number)
3331 "Return the mark of article NUMBER."
3332 `(gnus-data-mark (gnus-data-find
3333 ,(or number '(gnus-summary-article-number)))))
3335 (defmacro gnus-summary-article-pos (&optional number)
3336 "Return the position of the line of article NUMBER."
3337 `(gnus-data-pos (gnus-data-find
3338 ,(or number '(gnus-summary-article-number)))))
3340 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3341 (defmacro gnus-summary-article-subject (&optional number)
3342 "Return current subject string or nil if nothing."
3345 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3346 '(gnus-data-header (assq (gnus-summary-article-number)
3347 gnus-newsgroup-data)))))
3350 (mail-header-subject headers))))
3352 (defmacro gnus-summary-article-score (&optional number)
3353 "Return current article score."
3354 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3355 gnus-newsgroup-scored))
3356 gnus-summary-default-score 0))
3358 (defun gnus-summary-article-children (&optional number)
3359 "Return a list of article numbers that are children of article NUMBER."
3360 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3361 (level (gnus-data-level (car data)))
3363 (while (and (setq data (cdr data))
3364 (> (setq l (gnus-data-level (car data))) level))
3365 (and (= (1+ level) l)
3366 (push (gnus-data-number (car data))
3368 (nreverse children)))
3370 (defun gnus-summary-article-parent (&optional number)
3371 "Return the article number of the parent of article NUMBER."
3372 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3373 (gnus-data-list t)))
3374 (level (gnus-data-level (car data))))
3376 () ; This is a root.
3377 ;; We search until we find an article with a level less than
3378 ;; this one. That function has to be the parent.
3379 (while (and (setq data (cdr data))
3380 (not (< (gnus-data-level (car data)) level))))
3381 (and data (gnus-data-number (car data))))))
3383 (defun gnus-unread-mark-p (mark)
3384 "Say whether MARK is the unread mark."
3385 (= mark gnus-unread-mark))
3387 (defun gnus-read-mark-p (mark)
3388 "Say whether MARK is one of the marks that mark as read.
3389 This is all marks except unread, ticked, dormant, and expirable."
3390 (not (or (= mark gnus-unread-mark)
3391 (= mark gnus-ticked-mark)
3392 (= mark gnus-spam-mark)
3393 (= mark gnus-dormant-mark)
3394 (= mark gnus-expirable-mark))))
3396 (defmacro gnus-article-mark (number)
3397 "Return the MARK of article NUMBER.
3398 This macro should only be used when computing the mark the \"first\"
3399 time; i.e., when generating the summary lines. After that,
3400 `gnus-summary-article-mark' should be used to examine the
3403 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3404 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3405 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3406 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3407 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3408 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3409 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3410 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3411 gnus-ancient-mark))))
3413 ;; Saving hidden threads.
3415 (defmacro gnus-save-hidden-threads (&rest forms)
3416 "Save hidden threads, eval FORMS, and restore the hidden threads."
3417 (let ((config (make-symbol "config")))
3418 `(let ((,config (gnus-hidden-threads-configuration)))
3422 (gnus-restore-hidden-threads-configuration ,config)))))
3423 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3424 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3426 (defun gnus-data-compute-positions ()
3427 "Compute the positions of all articles."
3428 (setq gnus-newsgroup-data-reverse nil)
3429 (let ((data gnus-newsgroup-data))
3431 (gnus-save-hidden-threads
3432 (gnus-summary-show-all-threads)
3433 (goto-char (point-min))
3435 (while (get-text-property (point) 'gnus-intangible)
3437 (gnus-data-set-pos (car data) (+ (point) 3))
3438 (setq data (cdr data))
3439 (forward-line 1))))))
3441 (defun gnus-hidden-threads-configuration ()
3442 "Return the current hidden threads configuration."
3445 (goto-char (point-min))
3447 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3448 (push (save-excursion (forward-line 0) (point)) config))
3452 (defun gnus-restore-hidden-threads-configuration (config)
3453 "Restore hidden threads configuration from CONFIG."
3455 (let (point (inhibit-read-only t))
3456 (while (setq point (pop config))
3458 (gnus-summary-hide-thread)))))
3460 ;; Various summary mode internalish functions.
3462 (defun gnus-mouse-pick-article (e)
3465 (gnus-summary-next-page nil t))
3467 (defun gnus-summary-set-display-table ()
3468 "Change the display table.
3469 Odd characters have a tendency to mess
3470 up nicely formatted displays - we make all possible glyphs
3471 display only a single character."
3473 ;; We start from the standard display table, if any.
3474 (let ((table (or (copy-sequence standard-display-table)
3475 (make-display-table)))
3477 ;; Nix out all the control chars...
3478 (while (>= (setq i (1- i)) 0)
3479 (gnus-put-display-table i [??] table))
3480 ;; ... but not newline and cr, of course. (cr is necessary for the
3481 ;; selective display).
3482 (gnus-put-display-table ?\n nil table)
3483 (gnus-put-display-table ?\r nil table)
3484 ;; We keep TAB as well.
3485 (gnus-put-display-table ?\t nil table)
3486 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3487 ;; Emacs 23 (unicode), that are not set already.
3488 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3491 (while (>= (setq i (1- i)) 127)
3492 ;; Only modify if the entry is nil.
3493 (unless (gnus-get-display-table i table)
3494 (gnus-put-display-table i [??] table))))
3495 (setq buffer-display-table table)))
3497 (defun gnus-summary-set-article-display-arrow (pos)
3498 "Update the overlay arrow to point to line at position POS."
3499 (when gnus-summary-display-arrow
3500 (make-local-variable 'overlay-arrow-position)
3501 (make-local-variable 'overlay-arrow-string)
3505 (unless overlay-arrow-position
3506 (setq overlay-arrow-position (make-marker)))
3507 (setq overlay-arrow-string "=>"
3508 overlay-arrow-position (set-marker overlay-arrow-position
3510 (current-buffer))))))
3512 (defun gnus-summary-setup-buffer (group)
3513 "Initialize summary buffer.
3514 If the setup was successful, non-nil is returned."
3515 (let ((buffer (gnus-summary-buffer-name group))
3516 (dead-name (concat "*Dead Summary "
3517 (gnus-group-decoded-name group) "*")))
3518 ;; If a dead summary buffer exists, we kill it.
3519 (when (gnus-buffer-live-p dead-name)
3520 (gnus-kill-buffer dead-name))
3521 (if (get-buffer buffer)
3524 (setq gnus-summary-buffer (current-buffer))
3525 (not gnus-newsgroup-prepared))
3526 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3527 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3528 (gnus-summary-mode group)
3529 (when (gnus-group-quit-config group)
3530 (set (make-local-variable 'gnus-single-article-buffer) nil))
3531 (make-local-variable 'gnus-article-buffer)
3532 (make-local-variable 'gnus-article-current)
3533 (make-local-variable 'gnus-original-article-buffer)
3534 (setq gnus-newsgroup-name group)
3535 ;; Set any local variables in the group parameters.
3536 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3539 (defun gnus-set-global-variables ()
3540 "Set the global equivalents of the buffer-local variables.
3541 They are set to the latest values they had. These reflect the summary
3542 buffer that was in action when the last article was fetched."
3543 (when (eq major-mode 'gnus-summary-mode)
3544 (setq gnus-summary-buffer (current-buffer))
3545 (let ((name gnus-newsgroup-name)
3546 (marked gnus-newsgroup-marked)
3547 (spam gnus-newsgroup-spam-marked)
3548 (unread gnus-newsgroup-unreads)
3549 (headers gnus-current-headers)
3550 (data gnus-newsgroup-data)
3551 (summary gnus-summary-buffer)
3552 (article-buffer gnus-article-buffer)
3553 (original gnus-original-article-buffer)
3554 (gac gnus-article-current)
3555 (reffed gnus-reffed-article-number)
3556 (score-file gnus-current-score-file)
3557 (default-charset gnus-newsgroup-charset)
3559 (let ((locals gnus-newsgroup-variables))
3561 (if (consp (car locals))
3562 (push (eval (caar locals)) vlist)
3563 (push (eval (car locals)) vlist))
3564 (setq locals (cdr locals)))
3565 (setq vlist (nreverse vlist)))
3566 (with-current-buffer gnus-group-buffer
3567 (setq gnus-newsgroup-name name
3568 gnus-newsgroup-marked marked
3569 gnus-newsgroup-spam-marked spam
3570 gnus-newsgroup-unreads unread
3571 gnus-current-headers headers
3572 gnus-newsgroup-data data
3573 gnus-article-current gac
3574 gnus-summary-buffer summary
3575 gnus-article-buffer article-buffer
3576 gnus-original-article-buffer original
3577 gnus-reffed-article-number reffed
3578 gnus-current-score-file score-file
3579 gnus-newsgroup-charset default-charset)
3580 (let ((locals gnus-newsgroup-variables))
3582 (if (consp (car locals))
3583 (set (caar locals) (pop vlist))
3584 (set (car locals) (pop vlist)))
3585 (setq locals (cdr locals))))
3586 ;; The article buffer also has local variables.
3587 (when (gnus-buffer-live-p gnus-article-buffer)
3588 (set-buffer gnus-article-buffer)
3589 (setq gnus-summary-buffer summary))))))
3591 (defun gnus-summary-article-unread-p (article)
3592 "Say whether ARTICLE is unread or not."
3593 (memq article gnus-newsgroup-unreads))
3595 (defun gnus-summary-first-article-p (&optional article)
3596 "Return whether ARTICLE is the first article in the buffer."
3597 (if (not (setq article (or article (gnus-summary-article-number))))
3599 (eq article (caar gnus-newsgroup-data))))
3601 (defun gnus-summary-last-article-p (&optional article)
3602 "Return whether ARTICLE is the last article in the buffer."
3603 (if (not (setq article (or article (gnus-summary-article-number))))
3604 ;; All non-existent numbers are the last article. :-)
3606 (not (cdr (gnus-data-find-list article)))))
3608 (defun gnus-make-thread-indent-array (&optional n)
3610 (progn (setq n 200) nil)
3611 (null gnus-thread-indent-array)
3612 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3613 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3614 gnus-thread-indent-array-level gnus-thread-indent-level)
3616 (aset gnus-thread-indent-array n
3617 (make-string (* n gnus-thread-indent-level) ? ))
3620 (defun gnus-update-summary-mark-positions ()
3621 "Compute where the summary marks are to go."
3623 (when (gnus-buffer-exists-p gnus-summary-buffer)
3624 (set-buffer gnus-summary-buffer))
3625 (let ((spec gnus-summary-line-format-spec)
3628 (gnus-set-work-buffer)
3629 (let ((gnus-tmp-unread ?Z)
3630 (gnus-replied-mark ?Z)
3631 (gnus-score-below-mark ?Z)
3632 (gnus-score-over-mark ?Z)
3633 (gnus-undownloaded-mark ?Z)
3634 (gnus-summary-line-format-spec spec)
3635 (gnus-newsgroup-downloadable '(0))
3636 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3637 case-fold-search ignores)
3638 ;; Here, all marks are bound to Z.
3639 (gnus-summary-insert-line header
3640 0 nil t gnus-tmp-unread t nil "" nil 1)
3641 (goto-char (point-min))
3642 ;; Memorize the positions of the same characters as dummy marks.
3643 (while (re-search-forward "[A-D]" nil t)
3644 (push (point) ignores))
3646 ;; We use A-D as dummy marks in order to know column positions
3647 ;; where marks should be inserted.
3648 (setq gnus-tmp-unread ?A
3649 gnus-replied-mark ?B
3650 gnus-score-below-mark ?C
3651 gnus-score-over-mark ?C
3652 gnus-undownloaded-mark ?D)
3653 (gnus-summary-insert-line header
3654 0 nil t gnus-tmp-unread t nil "" nil 1)
3655 ;; Ignore characters which aren't dummy marks.
3657 (delete-region (goto-char (1- p)) p)
3659 (goto-char (point-min))
3660 (setq pos (list (cons 'unread
3661 (and (search-forward "A" nil t)
3662 (- (point) (point-min) 1)))))
3663 (goto-char (point-min))
3664 (push (cons 'replied (and (search-forward "B" nil t)
3665 (- (point) (point-min) 1)))
3667 (goto-char (point-min))
3668 (push (cons 'score (and (search-forward "C" nil t)
3669 (- (point) (point-min) 1)))
3671 (goto-char (point-min))
3672 (push (cons 'download (and (search-forward "D" nil t)
3673 (- (point) (point-min) 1)))
3675 (setq gnus-summary-mark-positions pos))))
3677 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3678 "Insert a dummy root in the summary buffer."
3680 (gnus-add-text-properties
3681 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3682 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3684 (defun gnus-summary-extract-address-component (from)
3685 (or (car (funcall gnus-extract-address-components from))
3688 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3689 (let ((mail-parse-charset gnus-newsgroup-charset)
3690 (ignored-from-addresses (gnus-ignored-from-addresses))
3691 ; Is it really necessary to do this next part for each summary line?
3692 ; Luckily, doesn't seem to slow things down much.
3693 (mail-parse-ignored-charsets
3694 (with-current-buffer gnus-summary-buffer
3695 gnus-newsgroup-ignored-charsets)))
3697 (and ignored-from-addresses
3698 (string-match ignored-from-addresses gnus-tmp-from)
3699 (let ((extra-headers (mail-header-extra header))
3703 ((setq to (cdr (assq 'To extra-headers)))
3704 (concat gnus-summary-to-prefix
3706 (gnus-summary-extract-address-component
3707 (funcall gnus-decode-encoded-address-function to)))))
3710 (cdr (assq 'Newsgroups extra-headers))
3712 (memq 'Newsgroups gnus-extra-headers)
3713 (eq (car (gnus-find-method-for-group
3714 gnus-newsgroup-name)) 'nntp)
3715 (gnus-group-real-name gnus-newsgroup-name))))
3716 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3717 (gnus-string-mark-left-to-right
3719 (gnus-summary-extract-address-component gnus-tmp-from))))))
3721 (defun gnus-summary-insert-line (gnus-tmp-header
3722 gnus-tmp-level gnus-tmp-current
3723 undownloaded gnus-tmp-unread gnus-tmp-replied
3724 gnus-tmp-expirable gnus-tmp-subject-or-nil
3725 &optional gnus-tmp-dummy gnus-tmp-score
3727 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3728 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3730 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3731 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3732 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3733 (gnus-tmp-score-char
3734 (if (or (null gnus-summary-default-score)
3735 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3736 gnus-summary-zcore-fuzz))
3738 (if (< gnus-tmp-score gnus-summary-default-score)
3739 gnus-score-below-mark gnus-score-over-mark)))
3740 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3742 (cond (gnus-tmp-process gnus-process-mark)
3743 ((memq gnus-tmp-current gnus-newsgroup-cached)
3745 (gnus-tmp-replied gnus-replied-mark)
3746 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3747 gnus-forwarded-mark)
3748 ((memq gnus-tmp-current gnus-newsgroup-saved)
3750 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3753 (gnus-tmp-downloaded
3755 gnus-undownloaded-mark)
3756 (gnus-newsgroup-agentized
3757 gnus-downloaded-mark)
3760 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3763 ((string-match "<[^>]+> *$" gnus-tmp-from)
3764 (let ((beg (match-beginning 0)))
3765 (or (and (string-match "^\".+\"" gnus-tmp-from)
3766 (substring gnus-tmp-from 1 (1- (match-end 0))))
3767 (substring gnus-tmp-from 0 beg))))
3768 ((string-match "(.+)" gnus-tmp-from)
3769 (substring gnus-tmp-from
3770 (1+ (match-beginning 0)) (1- (match-end 0))))
3772 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3773 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3774 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3775 (inhibit-read-only t))
3776 (when (string= gnus-tmp-name "")
3777 (setq gnus-tmp-name gnus-tmp-from))
3778 (unless (numberp gnus-tmp-lines)
3779 (setq gnus-tmp-lines -1))
3780 (if (= gnus-tmp-lines -1)
3781 (setq gnus-tmp-lines "?")
3782 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3784 (gnus-put-text-property
3786 (progn (eval gnus-summary-line-format-spec) (point))
3787 'gnus-number gnus-tmp-number)
3788 (error (gnus-message 5 "Error updating the summary line")))
3789 (when (gnus-visual-p 'summary-highlight 'highlight)
3791 (gnus-summary-highlight-line)
3792 (gnus-run-hooks 'gnus-summary-update-hook)
3795 (defun gnus-summary-update-line (&optional dont-update)
3796 "Update summary line after change."
3797 (when (and gnus-summary-default-score
3798 (not gnus-summary-inhibit-highlight))
3799 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3800 (article (gnus-summary-article-number))
3801 (score (gnus-summary-article-score article)))
3803 (if (and gnus-summary-mark-below
3804 (< (gnus-summary-article-score)
3805 gnus-summary-mark-below))
3806 ;; This article has a low score, so we mark it as read.
3807 (when (memq article gnus-newsgroup-unreads)
3808 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3809 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3810 ;; This article was previously marked as read on account
3811 ;; of a low score, but now it has risen, so we mark it as
3813 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3814 (gnus-summary-update-mark
3815 (if (or (null gnus-summary-default-score)
3816 (<= (abs (- score gnus-summary-default-score))
3817 gnus-summary-zcore-fuzz))
3819 (if (< score gnus-summary-default-score)
3820 gnus-score-below-mark gnus-score-over-mark))
3822 ;; Do visual highlighting.
3823 (when (gnus-visual-p 'summary-highlight 'highlight)
3824 (gnus-summary-highlight-line)
3825 (gnus-run-hooks 'gnus-summary-update-hook)))))
3827 (defvar gnus-tmp-new-adopts nil)
3829 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3830 "Return the number of articles in THREAD.
3831 This may be 0 in some cases -- if none of the articles in
3832 the thread are to be displayed."
3834 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3836 ((not (listp thread))
3838 ((and (consp thread) (cdr thread))
3841 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3844 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3847 (when (and level (zerop level) gnus-tmp-new-adopts)
3850 'gnus-summary-number-of-articles-in-thread
3851 gnus-tmp-new-adopts))))
3853 (if (> number 1) gnus-not-empty-thread-mark
3854 gnus-empty-thread-mark)
3857 (defsubst gnus-summary-line-message-size (head)
3858 "Return pretty-printed version of message size.
3859 This function is intended to be used in
3860 `gnus-summary-line-format-alist'."
3861 (let ((c (or (mail-header-chars head) -1)))
3862 (cond ((< c 0) "n/a") ; chars not available
3863 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3864 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3865 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3866 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3868 (defcustom gnus-user-date-format-alist
3869 '(((gnus-seconds-today) . "Today, %H:%M")
3870 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3871 (604800 . "%A %H:%M") ; That's one week
3872 ((gnus-seconds-month) . "%A %d")
3873 ((gnus-seconds-year) . "%B %d")
3874 (t . "%b %d %Y")) ; This one is used when no other
3876 "Specifies date format depending on age of article.
3877 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3878 seconds) or a Lisp expression evaluating to a number. When the age of
3879 the article is less than this number, then use `format-time-string'
3880 with the corresponding FORMAT for displaying the date of the article.
3881 If AGE is not a number or a Lisp expression evaluating to a
3882 non-number, then the corresponding FORMAT is used as a default value.
3884 Note that the list is processed from the beginning, so it should be
3885 sorted by ascending AGE. Also note that items following the first
3886 non-number AGE will be ignored.
3888 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3889 and `gnus-seconds-year' in the AGE spec. They return the number of
3890 seconds passed since the start of today, of this month, of this year,
3893 :group 'gnus-summary-format
3894 :type '(alist :key-type sexp :value-type string))
3896 (defun gnus-user-date (messy-date)
3897 "Format the messy-date according to `gnus-user-date-format-alist'.
3898 Returns \" ? \" if there's bad input or if another error occurs.
3899 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3901 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3902 (now (gnus-float-time))
3903 ;;If we don't find something suitable we'll use this one
3904 (my-format "%b %d '%y"))
3905 (let* ((difference (- now messy-date))
3906 (templist gnus-user-date-format-alist)
3907 (top (eval (caar templist))))
3908 (while (if (numberp top) (< top difference) (not top))
3910 (setq templist (cdr templist))
3911 (setq top (eval (caar templist)))))
3912 (if (stringp (cdr (car templist)))
3913 (setq my-format (cdr (car templist)))))
3914 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3917 (defun gnus-summary-set-local-parameters (group)
3918 "Go through the local params of GROUP and set all variable specs in that list."
3919 (let ((vars '(quit-config active))) ; Ignore things that aren't
3921 (dolist (elem (gnus-group-find-parameter group))
3922 (and (consp elem) ; Has to be a cons.
3923 (consp (cdr elem)) ; The cdr has to be a list.
3924 (symbolp (car elem)) ; Has to be a symbol in there.
3925 (not (memq (car elem) vars))
3927 (push (car elem) vars)
3928 ;; Variables like `gnus-show-threads' that are globally
3929 ;; bound, if used as group parameters, need to get to be
3930 ;; buffer-local, whereas just parameters like `gcc-self',
3931 ;; `timestamp', etc. should not be bound as variables.
3932 (if (boundp (car elem))
3933 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3934 (eval (nth 1 elem))))))))
3936 (defun gnus-summary-read-group (group &optional show-all no-article
3937 kill-buffer no-display backward
3939 "Start reading news in newsgroup GROUP.
3940 If SHOW-ALL is non-nil, already read articles are also listed.
3941 If NO-ARTICLE is non-nil, no article is selected initially.
3942 If NO-DISPLAY, don't generate the summary buffer contents.
3943 If KILL-BUFFER, it should be a buffer that's killed once the new
3944 summary buffer has been generated.
3945 If BACKWARD, move point to the previous group in the group buffer
3946 If SELECT-ARTICLES, only select those articles from GROUP."
3950 (let ((gnus-auto-select-next nil))
3951 (or (gnus-summary-read-group-1
3952 group show-all no-article
3953 kill-buffer no-display
3956 select-articles nil)))))
3957 (eq gnus-auto-select-next 'quietly))
3958 (set-buffer gnus-group-buffer)
3959 ;; The entry function called above goes to the next
3960 ;; group automatically, so we go two groups back
3961 ;; if we are searching for the previous group.
3963 (gnus-group-prev-unread-group 2))
3964 (if (not (equal group (gnus-group-group-name)))
3965 (setq group (gnus-group-group-name))
3969 (defun gnus-summary-read-group-1 (group show-all no-article
3970 kill-buffer no-display
3971 &optional select-articles)
3972 ;; Killed foreign groups can't be entered.
3973 ;; (when (and (not (gnus-group-native-p group))
3974 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3975 ;; (error "Dead non-native groups can't be entered"))
3976 (gnus-message 7 "Retrieving newsgroup: %s..."
3977 (gnus-group-decoded-name group))
3978 (let* ((new-group (gnus-summary-setup-buffer group))
3979 (quit-config (gnus-group-quit-config group))
3980 (did-select (and new-group (gnus-select-newsgroup
3981 group show-all select-articles))))
3983 ;; This summary buffer exists already, so we just select it.
3985 (gnus-set-global-variables)
3987 (gnus-kill-or-deaden-summary kill-buffer))
3988 (gnus-configure-windows 'summary 'force)
3989 (gnus-set-mode-line 'summary)
3990 (gnus-summary-position-point)
3993 ;; We couldn't select this group.
3995 (when (and (eq major-mode 'gnus-summary-mode)
3996 (not (equal (current-buffer) kill-buffer)))
3997 (kill-buffer (current-buffer))
3998 (if (not quit-config)
4000 ;; Update the info -- marks might need to be removed,
4002 (gnus-summary-update-info)
4003 (set-buffer gnus-group-buffer)
4004 (gnus-group-jump-to-group group)
4005 (gnus-group-next-unread-group 1))
4006 (gnus-handle-ephemeral-exit quit-config)))
4007 (if (null (gnus-list-of-unread-articles group))
4008 (gnus-message 3 "Group %s contains no messages" group)
4009 (gnus-message 3 "Can't select group"))
4011 ;; The user did a `C-g' while prompting for number of articles,
4012 ;; so we exit this group.
4013 ((eq did-select 'quit)
4014 (and (eq major-mode 'gnus-summary-mode)
4015 (not (equal (current-buffer) kill-buffer))
4016 (kill-buffer (current-buffer)))
4018 (gnus-kill-or-deaden-summary kill-buffer))
4019 (if (not quit-config)
4021 (set-buffer gnus-group-buffer)
4022 (gnus-group-jump-to-group group)
4023 (gnus-configure-windows 'group 'force))
4024 (gnus-handle-ephemeral-exit quit-config))
4025 ;; Finally signal the quit.
4027 ;; The group was successfully selected.
4029 (gnus-set-global-variables)
4030 ;; Save the active value in effect when the group was entered.
4031 (setq gnus-newsgroup-active
4033 (gnus-active gnus-newsgroup-name)))
4034 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4035 ;; You can change the summary buffer in some way with this hook.
4036 (gnus-run-hooks 'gnus-select-group-hook)
4037 (when (memq 'summary (gnus-update-format-specifications
4038 nil 'summary 'summary-mode 'summary-dummy))
4039 ;; The format specification for the summary line was updated,
4040 ;; so we need to update the mark positions as well.
4041 (gnus-update-summary-mark-positions))
4042 ;; Do score processing.
4043 (when gnus-use-scoring
4044 (gnus-possibly-score-headers))
4045 ;; Check whether to fill in the gaps in the threads.
4046 (when gnus-build-sparse-threads
4047 (gnus-build-sparse-threads))
4048 ;; Find the initial limit.
4050 (let ((gnus-newsgroup-dormant nil))
4051 (gnus-summary-initial-limit show-all))
4052 (gnus-summary-initial-limit show-all))
4053 ;; Generate the summary buffer.
4055 (gnus-summary-prepare))
4056 (when gnus-use-trees
4057 (gnus-tree-open group)
4058 (setq gnus-summary-highlight-line-function
4059 'gnus-tree-highlight-article))
4060 ;; If the summary buffer is empty, but there are some low-scored
4061 ;; articles or some excluded dormants, we include these in the
4063 (when (and (zerop (buffer-size))
4065 (cond (gnus-newsgroup-dormant
4066 (gnus-summary-limit-include-dormant))
4067 ((and gnus-newsgroup-scored show-all)
4068 (gnus-summary-limit-include-expunged t))))
4069 ;; Function `gnus-apply-kill-file' must be called in this hook.
4070 (gnus-run-hooks 'gnus-apply-kill-hook)
4071 (if (and (zerop (buffer-size))
4074 ;; This newsgroup is empty.
4075 (gnus-summary-catchup-and-exit nil t)
4076 (gnus-message 6 "No unread news")
4078 (gnus-kill-or-deaden-summary kill-buffer))
4079 ;; Return nil from this function.
4081 ;; Hide conversation thread subtrees. We cannot do this in
4082 ;; gnus-summary-prepare-hook since kill processing may not
4083 ;; work with hidden articles.
4084 (gnus-summary-maybe-hide-threads)
4085 (gnus-configure-windows 'summary)
4087 (gnus-kill-or-deaden-summary kill-buffer))
4088 (gnus-summary-auto-select-subject)
4089 ;; Show first unread article if requested.
4090 (if (and (not no-article)
4092 gnus-newsgroup-unreads
4093 gnus-auto-select-first)
4095 (let ((art (gnus-summary-article-number)))
4096 (unless (and (not gnus-plugged)
4097 (or (memq art gnus-newsgroup-undownloaded)
4098 (memq art gnus-newsgroup-downloadable)))
4099 (gnus-summary-goto-article art))))
4100 ;; Don't select any articles.
4101 (gnus-summary-position-point)
4102 (gnus-configure-windows 'summary 'force)
4103 (gnus-set-mode-line 'summary))
4104 (when (and gnus-auto-center-group
4105 (get-buffer-window gnus-group-buffer t))
4106 ;; Gotta use windows, because recenter does weird stuff if
4107 ;; the current buffer ain't the displayed window.
4108 (let ((owin (selected-window)))
4109 (select-window (get-buffer-window gnus-group-buffer t))
4110 (when (gnus-group-goto-group group)
4112 (select-window owin)))
4113 ;; Mark this buffer as "prepared".
4114 (setq gnus-newsgroup-prepared t)
4115 (gnus-run-hooks 'gnus-summary-prepared-hook)
4116 (unless (gnus-ephemeral-group-p group)
4117 (gnus-group-update-group group nil t))
4120 (defun gnus-summary-auto-select-subject ()
4121 "Select the subject line on initial group entry."
4122 (goto-char (point-min))
4124 ((eq gnus-auto-select-subject 'best)
4125 (gnus-summary-best-unread-subject))
4126 ((eq gnus-auto-select-subject 'unread)
4127 (gnus-summary-first-unread-subject))
4128 ((eq gnus-auto-select-subject 'unseen)
4129 (gnus-summary-first-unseen-subject))
4130 ((eq gnus-auto-select-subject 'unseen-or-unread)
4131 (gnus-summary-first-unseen-or-unread-subject))
4132 ((eq gnus-auto-select-subject 'first)
4135 ((functionp gnus-auto-select-subject)
4136 (funcall gnus-auto-select-subject))))
4138 (defun gnus-summary-prepare ()
4139 "Generate the summary buffer."
4141 (let ((inhibit-read-only t))
4143 (setq gnus-newsgroup-data nil
4144 gnus-newsgroup-data-reverse nil)
4145 (gnus-run-hooks 'gnus-summary-generate-hook)
4146 ;; Generate the buffer, either with threads or without.
4147 (when gnus-newsgroup-headers
4148 (gnus-summary-prepare-threads
4149 (if gnus-show-threads
4150 (gnus-sort-gathered-threads
4151 (funcall gnus-summary-thread-gathering-function
4153 (gnus-cut-threads (gnus-make-threads)))))
4154 ;; Unthreaded display.
4155 (gnus-sort-articles gnus-newsgroup-headers))))
4156 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4157 ;; Call hooks for modifying summary buffer.
4158 (goto-char (point-min))
4159 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4161 (defsubst gnus-general-simplify-subject (subject)
4162 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4165 ;; Truncate the subject.
4166 (gnus-simplify-subject-functions
4167 (gnus-map-function gnus-simplify-subject-functions subject))
4168 ((numberp gnus-summary-gather-subject-limit)
4169 (setq subject (gnus-simplify-subject-re subject))
4170 (if (> (length subject) gnus-summary-gather-subject-limit)
4171 (substring subject 0 gnus-summary-gather-subject-limit)
4173 ;; Fuzzily simplify it.
4174 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4175 (gnus-simplify-subject-fuzzy subject))
4176 ;; Just remove the leading "Re:".
4178 (gnus-simplify-subject-re subject))))
4180 (if (and gnus-summary-gather-exclude-subject
4181 (string-match gnus-summary-gather-exclude-subject subject))
4182 nil ; This article shouldn't be gathered
4185 (defun gnus-summary-simplify-subject-query ()
4186 "Query where the respool algorithm would put this article."
4188 (gnus-summary-select-article)
4189 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4191 (defun gnus-gather-threads-by-subject (threads)
4192 "Gather threads by looking at Subject headers."
4193 (if (not gnus-summary-make-false-root)
4195 (let ((hashtb (gnus-make-hashtable 1024))
4198 subject hthread whole-subject)
4200 (setq subject (gnus-general-simplify-subject
4201 (setq whole-subject (mail-header-subject
4204 (if (setq hthread (gnus-gethash subject hashtb))
4206 ;; We enter a dummy root into the thread, if we
4207 ;; haven't done that already.
4208 (unless (stringp (caar hthread))
4209 (setcar hthread (list whole-subject (car hthread))))
4210 ;; We add this new gathered thread to this gathered
4212 (setcdr (car hthread)
4213 (nconc (cdar hthread) (list (car threads))))
4214 ;; Remove it from the list of threads.
4215 (setcdr prev (cdr threads))
4216 (setq threads prev))
4217 ;; Enter this thread into the hash table.
4218 (gnus-sethash subject
4219 (if gnus-summary-make-false-root-always
4221 ;; If you want a dummy root above all
4223 (setcar threads (list whole-subject
4229 (setq threads (cdr threads)))
4232 (defun gnus-gather-threads-by-references (threads)
4233 "Gather threads by looking at References headers."
4234 (let ((idhashtb (gnus-make-hashtable 1024))
4235 (thhashtb (gnus-make-hashtable 1024))
4238 ids references id gthread gid entered ref)
4240 (when (setq references (mail-header-references (caar threads)))
4241 (setq id (mail-header-id (caar threads))
4242 ids (inline (gnus-split-references references))
4244 (while (setq ref (pop ids))
4245 (setq ids (delete ref ids))
4246 (if (not (setq gid (gnus-gethash ref idhashtb)))
4248 (gnus-sethash ref id idhashtb)
4249 (gnus-sethash id threads thhashtb))
4250 (setq gthread (gnus-gethash gid thhashtb))
4252 ;; We enter a dummy root into the thread, if we
4253 ;; haven't done that already.
4254 (unless (stringp (caar gthread))
4255 (setcar gthread (list (mail-header-subject (caar gthread))
4257 ;; We add this new gathered thread to this gathered
4259 (setcdr (car gthread)
4260 (nconc (cdar gthread) (list (car threads)))))
4261 ;; Add it into the thread hash table.
4262 (gnus-sethash id gthread thhashtb)
4264 ;; Remove it from the list of threads.
4265 (setcdr prev (cdr threads))
4266 (setq threads prev))))
4268 (setq threads (cdr threads)))
4271 (defun gnus-sort-gathered-threads (threads)
4272 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4273 (let ((result threads))
4275 (when (stringp (caar threads))
4276 (setcdr (car threads)
4277 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4278 (setq threads (cdr threads)))
4281 (defun gnus-thread-loop-p (root thread)
4282 "Say whether ROOT is in THREAD."
4283 (let ((stack (list thread))
4286 (while (setq thread (pop stack))
4287 (setq th (cdr thread))
4289 (not (eq (caar th) root)))
4292 ;; We have found a loop.
4294 (setcdr thread (delq (car th) (cdr thread)))
4295 (if (boundp (setq ref-dep (intern "none"
4296 gnus-newsgroup-dependencies)))
4297 (setcdr (symbol-value ref-dep)
4298 (nconc (cdr (symbol-value ref-dep))
4300 (set ref-dep (list nil (car th))))
4303 ;; Push all the subthreads onto the stack.
4304 (push (cdr thread) stack)))
4307 (defun gnus-make-threads ()
4308 "Go through the dependency hashtb and find the roots. Return all threads."
4310 (while (catch 'infloop
4313 ;; Deal with self-referencing References loops.
4314 (when (and (car (symbol-value refs))
4321 (car (symbol-value refs)) thread))
4322 (cdr (symbol-value refs)))))))
4325 (unless (car (symbol-value refs))
4326 ;; These threads do not refer back to any other
4327 ;; articles, so they're roots.
4328 (setq threads (append (cdr (symbol-value refs)) threads))))
4329 gnus-newsgroup-dependencies)))
4332 ;; Build the thread tree.
4333 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4334 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4336 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4337 if it was already present.
4339 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4340 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4341 Message-IDs will be renamed to a unique Message-ID before being
4344 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4345 (let* ((id (mail-header-id header))
4346 (id-dep (and id (intern id dependencies)))
4347 parent-id ref ref-dep ref-header replaced)
4348 ;; Enter this `header' in the `dependencies' table.
4352 ;; The first two cases do the normal part: enter a new `header'
4353 ;; in the `dependencies' table.
4354 ((not (boundp id-dep))
4355 (set id-dep (list header)))
4356 ((null (car (symbol-value id-dep)))
4357 (setcar (symbol-value id-dep) header))
4359 ;; From here the `header' was already present in the
4360 ;; `dependencies' table.
4362 ;; Overrides an existing entry;
4363 ;; just set the header part of the entry.
4364 (setcar (symbol-value id-dep) header)
4367 ;; Renames the existing `header' to a unique Message-ID.
4368 ((not gnus-summary-ignore-duplicates)
4369 ;; An article with this Message-ID has already been seen.
4370 ;; We rename the Message-ID.
4371 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4373 (mail-header-set-id header id))
4375 ;; The last case ignores an existing entry, except it adds any
4376 ;; additional Xrefs (in case the two articles came from different
4378 ;; Also sets `header' to `nil' meaning that the `dependencies'
4379 ;; table was *not* modified.
4381 (mail-header-set-xref
4382 (car (symbol-value id-dep))
4383 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4385 (or (mail-header-xref header) "")))
4388 (when (and header (not replaced))
4389 ;; First check that we are not creating a References loop.
4390 (setq parent-id (gnus-parent-id (mail-header-references header)))
4391 (setq ref parent-id)
4393 (setq ref-dep (intern-soft ref dependencies))
4395 (setq ref-header (car (symbol-value ref-dep))))
4396 (if (string= id ref)
4397 ;; Yuk! This is a reference loop. Make the article be a
4400 (mail-header-set-references (car (symbol-value id-dep)) "none")
4402 (setq parent-id nil))
4403 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4404 (setq ref-dep (intern (or parent-id "none") dependencies))
4405 (if (boundp ref-dep)
4406 (setcdr (symbol-value ref-dep)
4407 (nconc (cdr (symbol-value ref-dep))
4408 (list (symbol-value id-dep))))
4409 (set ref-dep (list nil (symbol-value id-dep)))))
4412 (defun gnus-extract-message-id-from-in-reply-to (string)
4413 (if (string-match "<[^>]+>" string)
4414 (substring string (match-beginning 0) (match-end 0))
4417 (defun gnus-build-sparse-threads ()
4418 (let ((headers gnus-newsgroup-headers)
4419 (mail-parse-charset gnus-newsgroup-charset)
4420 (gnus-summary-ignore-duplicates t)
4421 header references generation relations
4422 subject child end new-child date)
4423 ;; First we create an alist of generations/relations, where
4424 ;; generations is how much we trust the relation, and the relation
4426 (gnus-message 7 "Making sparse threads...")
4428 (nnheader-set-temp-buffer " *gnus sparse threads*")
4429 (while (setq header (pop headers))
4430 (when (and (setq references (mail-header-references header))
4431 (not (string= references "")))
4433 (setq child (mail-header-id header)
4434 subject (mail-header-subject header)
4435 date (mail-header-date header)
4437 (while (search-backward ">" nil t)
4438 (setq end (1+ (point)))
4439 (when (search-backward "<" nil t)
4440 (setq new-child (buffer-substring (point) end))
4441 (push (list (incf generation)
4442 child (setq child new-child)
4446 (push (list (1+ generation) child nil subject) relations))
4448 (kill-buffer (current-buffer)))
4449 ;; Sort over trustworthiness.
4450 (dolist (relation (sort relations 'car-less-than-car))
4451 (when (gnus-dependencies-add-header
4452 (make-full-mail-header
4453 gnus-reffed-article-number
4454 (nth 3 relation) "" (or (nth 4 relation) "")
4456 (or (nth 2 relation) "") 0 0 "")
4457 gnus-newsgroup-dependencies nil)
4458 (push gnus-reffed-article-number gnus-newsgroup-limit)
4459 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4460 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4461 gnus-newsgroup-reads)
4462 (decf gnus-reffed-article-number)))
4463 (gnus-message 7 "Making sparse threads...done")))
4465 (defun gnus-build-old-threads ()
4466 ;; Look at all the articles that refer back to old articles, and
4467 ;; fetch the headers for the articles that aren't there. This will
4468 ;; build complete threads - if the roots haven't been expired by the
4470 (let ((mail-parse-charset gnus-newsgroup-charset)
4474 (when (not (car (symbol-value refs)))
4475 (setq heads (cdr (symbol-value refs)))
4477 (if (memq (mail-header-number (caar heads))
4478 gnus-newsgroup-dormant)
4479 (setq heads (cdr heads))
4480 (setq id (symbol-name refs))
4481 (while (and (setq id (gnus-build-get-header id))
4482 (not (car (gnus-id-to-thread id)))))
4483 (setq heads nil)))))
4484 gnus-newsgroup-dependencies)))
4486 (defsubst gnus-remove-odd-characters (string)
4487 "Translate STRING into something that doesn't contain weird characters."
4488 (mm-subst-char-in-string
4490 (mm-subst-char-in-string ?\n ?\- string t) t))
4492 ;; This function has to be called with point after the article number
4493 ;; on the beginning of the line.
4494 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4495 (let ((eol (point-at-eol))
4496 (buffer (current-buffer))
4497 header references in-reply-to)
4499 ;; overview: [num subject from date id refs chars lines misc]
4502 (narrow-to-region (point) eol)
4507 (make-full-mail-header
4509 (condition-case () ; subject
4510 (gnus-remove-odd-characters
4511 (funcall gnus-decode-encoded-word-function
4512 (setq x (nnheader-nov-field))))
4514 (condition-case () ; from
4515 (gnus-remove-odd-characters
4516 (funcall gnus-decode-encoded-address-function
4517 (setq x (nnheader-nov-field))))
4519 (nnheader-nov-field) ; date
4520 (nnheader-nov-read-message-id number) ; id
4521 (setq references (nnheader-nov-field)) ; refs
4522 (nnheader-nov-read-integer) ; chars
4523 (nnheader-nov-read-integer) ; lines
4525 (if (looking-at "Xref: ")
4526 (goto-char (match-end 0)))
4527 (nnheader-nov-field)) ; Xref
4528 (nnheader-nov-parse-extra)))) ; extra
4532 (when (and (string= references "")
4533 (setq in-reply-to (mail-header-extra header))
4534 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4535 (mail-header-set-references
4536 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4538 (when gnus-alter-header-function
4539 (funcall gnus-alter-header-function header))
4540 (gnus-dependencies-add-header header dependencies force-new)))
4542 (defun gnus-build-get-header (id)
4543 "Look through the buffer of NOV lines and find the header to ID.
4544 Enter this line into the dependencies hash table, and return
4545 the id of the parent article (if any)."
4546 (let ((deps gnus-newsgroup-dependencies)
4549 (with-current-buffer nntp-server-buffer
4550 (let ((case-fold-search nil))
4551 (goto-char (point-min))
4552 (while (and (not found)
4553 (search-forward id nil t))
4555 (setq found (looking-at
4556 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4557 (regexp-quote id))))
4558 (or found (beginning-of-line 2)))
4562 (setq header (gnus-nov-parse-line
4563 (read (current-buffer)) deps))
4564 (gnus-parent-id (mail-header-references header))))))
4566 (let ((number (mail-header-number header)))
4567 (push number gnus-newsgroup-limit)
4568 (push header gnus-newsgroup-headers)
4569 (if (memq number gnus-newsgroup-unselected)
4571 (setq gnus-newsgroup-unreads
4572 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4574 (setq gnus-newsgroup-unselected
4575 (delq number gnus-newsgroup-unselected)))
4576 (push number gnus-newsgroup-ancient)))))))
4578 (defun gnus-build-all-threads ()
4579 "Read all the headers."
4580 (let ((gnus-summary-ignore-duplicates t)
4581 (mail-parse-charset gnus-newsgroup-charset)
4582 (dependencies gnus-newsgroup-dependencies)
4584 (with-current-buffer nntp-server-buffer
4585 (let ((case-fold-search nil))
4586 (goto-char (point-min))
4589 (setq article (read (current-buffer))
4590 header (gnus-nov-parse-line article dependencies t)))
4592 (with-current-buffer gnus-summary-buffer
4593 (push header gnus-newsgroup-headers)
4594 (if (memq (setq article (mail-header-number header))
4595 gnus-newsgroup-unselected)
4597 (setq gnus-newsgroup-unreads
4598 (gnus-add-to-sorted-list
4599 gnus-newsgroup-unreads article))
4600 (setq gnus-newsgroup-unselected
4601 (delq article gnus-newsgroup-unselected)))
4602 (push article gnus-newsgroup-ancient)))
4603 (forward-line 1)))))))
4605 (defun gnus-summary-update-article-line (article header)
4606 "Update the line for ARTICLE using HEADER."
4607 (let* ((id (mail-header-id header))
4608 (thread (gnus-id-to-thread id)))
4610 (error "Article in no thread"))
4611 ;; Update the thread.
4612 (setcar thread header)
4613 (gnus-summary-goto-subject article)
4614 (let* ((datal (gnus-data-find-list article))
4616 (inhibit-read-only t)
4617 (level (gnus-summary-thread-level)))
4619 (let ((inserted (- (point)
4621 (gnus-summary-insert-line
4623 (memq article gnus-newsgroup-undownloaded)
4624 (gnus-article-mark article)
4625 (memq article gnus-newsgroup-replied)
4626 (memq article gnus-newsgroup-expirable)
4627 ;; Only insert the Subject string when it's different
4628 ;; from the previous Subject string.
4633 (mail-header-subject
4636 (gnus-data-find-list
4638 (gnus-data-list t)))))
4639 ;; Error on the side of excessive subjects.
4641 (mail-header-subject header)))
4643 (mail-header-subject header))
4644 nil (cdr (assq article gnus-newsgroup-scored))
4645 (memq article gnus-newsgroup-processable))
4648 (gnus-data-update-list
4650 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4652 (defun gnus-summary-update-article (article &optional iheader)
4653 "Update ARTICLE in the summary buffer."
4654 (set-buffer gnus-summary-buffer)
4655 (let* ((header (gnus-summary-article-header article))
4656 (id (mail-header-id header))
4657 (data (gnus-data-find article))
4658 (thread (gnus-id-to-thread id))
4659 (references (mail-header-references header))
4663 (when (and references
4664 (not (equal "" references)))
4667 (inhibit-read-only t)
4673 (delq thread parent)))
4674 (if (gnus-summary-insert-subject id header)
4675 ;; Set the (possibly) new article number in the data structure.
4676 (gnus-data-set-number data (gnus-id-to-article id))
4680 (defun gnus-rebuild-thread (id &optional line)
4681 "Rebuild the thread containing ID.
4682 If LINE, insert the rebuilt thread starting on line LINE."
4683 (let ((inhibit-read-only t)
4684 old-pos current thread data)
4685 (if (not gnus-show-threads)
4686 (setq thread (list (car (gnus-id-to-thread id))))
4687 ;; Get the thread this article is part of.
4688 (setq thread (gnus-remove-thread id)))
4689 (setq old-pos (point-at-bol))
4690 (setq current (save-excursion
4691 (and (re-search-backward "[\r\n]" nil t)
4692 (gnus-summary-article-number))))
4693 ;; If this is a gathered thread, we have to go some re-gathering.
4694 (when (stringp (car thread))
4695 (let ((subject (car thread))
4697 (setq thread (cdr thread))
4699 (unless (memq (setq thr (gnus-id-to-thread
4701 (mail-header-id (caar thread)))))
4704 (setq thread (cdr thread)))
4705 ;; We now have all (unique) roots.
4706 (if (= (length roots) 1)
4707 ;; All the loose roots are now one solid root.
4708 (setq thread (car roots))
4709 (setq thread (cons subject (gnus-sort-threads roots))))))
4711 ;; We then insert this thread into the summary buffer.
4713 (goto-char (point-min))
4714 (forward-line (1- line)))
4715 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4716 (if gnus-show-threads
4717 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4718 (gnus-summary-prepare-unthreaded thread))
4719 (setq data (nreverse gnus-newsgroup-data))
4720 (setq threads gnus-newsgroup-threads))
4721 ;; We splice the new data into the data structure.
4722 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4723 ;;!!! then we want to insert at the beginning of the buffer.
4724 ;;!!! That happens to be true with Gnus now, but that may
4725 ;;!!! change in the future. Perhaps.
4726 (gnus-data-enter-list
4727 (if line nil current) data (- (point) old-pos))
4728 (setq gnus-newsgroup-threads
4729 (nconc threads gnus-newsgroup-threads))
4730 (gnus-data-compute-positions))))
4732 (defun gnus-number-to-header (number)
4733 "Return the header for article NUMBER."
4734 (let ((headers gnus-newsgroup-headers))
4736 (not (= number (mail-header-number (car headers)))))
4741 (defun gnus-parent-headers (in-headers &optional generation)
4742 "Return the headers of the GENERATIONth parent of HEADERS."
4744 (setq generation 1))
4746 (headers in-headers)
4749 (not (zerop generation))
4750 (setq references (mail-header-references headers)))
4751 (setq headers (if (and references
4752 (setq parent (gnus-parent-id references)))
4753 (car (gnus-id-to-thread parent))
4756 (and (not (eq headers in-headers))
4759 (defun gnus-id-to-thread (id)
4760 "Return the (sub-)thread where ID appears."
4761 (gnus-gethash id gnus-newsgroup-dependencies))
4763 (defun gnus-id-to-article (id)
4764 "Return the article number of ID."
4765 (let ((thread (gnus-id-to-thread id)))
4768 (mail-header-number (car thread)))))
4770 (defun gnus-id-to-header (id)
4771 "Return the article headers of ID."
4772 (car (gnus-id-to-thread id)))
4774 (defun gnus-article-displayed-root-p (article)
4775 "Say whether ARTICLE is a root(ish) article."
4776 (let ((level (gnus-summary-thread-level article))
4777 (refs (mail-header-references (gnus-summary-article-header article)))
4783 ((null (gnus-parent-id refs)) t)
4785 (null (setq particle (gnus-id-to-article
4786 (gnus-parent-id refs))))
4787 (null (gnus-summary-thread-level particle)))))))
4789 (defun gnus-root-id (id)
4790 "Return the id of the root of the thread where ID appears."
4792 (while (and id (setq prev (car (gnus-id-to-thread id))))
4794 id (gnus-parent-id (mail-header-references prev))))
4797 (defun gnus-articles-in-thread (thread)
4798 "Return the list of articles in THREAD."
4799 (cons (mail-header-number (car thread))
4800 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4802 (defun gnus-remove-thread (id &optional dont-remove)
4803 "Remove the thread that has ID in it."
4804 (let (headers thread last-id)
4805 ;; First go up in this thread until we find the root.
4806 (setq last-id (gnus-root-id id)
4807 headers (message-flatten-list (gnus-id-to-thread last-id)))
4808 ;; We have now found the real root of this thread. It might have
4809 ;; been gathered into some loose thread, so we have to search
4810 ;; through the threads to find the thread we wanted.
4811 (let ((threads gnus-newsgroup-threads)
4814 (setq sub (car threads))
4815 (if (stringp (car sub))
4816 ;; This is a gathered thread, so we look at the roots
4817 ;; below it to find whether this article is in this
4820 (setq sub (cdr sub))
4822 (when (member (caar sub) headers)
4823 (setq thread (car threads)
4826 (setq sub (cdr sub))))
4827 ;; It's an ordinary thread, so we check it.
4828 (when (eq (car sub) (car headers))
4831 (setq threads (cdr threads)))
4832 ;; If this article is in no thread, then it's a root.
4835 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4836 (setq thread (gnus-id-to-thread last-id)))
4839 thread ; We return this thread.
4841 (if (stringp (car thread))
4843 ;; If we use dummy roots, then we have to remove the
4844 ;; dummy root as well.
4845 (when (eq gnus-summary-make-false-root 'dummy)
4846 ;; We go to the dummy root by going to
4847 ;; the first sub-"thread", and then one line up.
4848 (gnus-summary-goto-article
4849 (mail-header-number (caadr thread)))
4852 (gnus-data-compute-positions))
4853 (setq thread (cdr thread))
4855 (gnus-remove-thread-1 (car thread))
4856 (setq thread (cdr thread))))
4857 (gnus-remove-thread-1 thread))))))))
4859 (defun gnus-remove-thread-1 (thread)
4860 "Remove the thread THREAD recursively."
4861 (let ((number (mail-header-number (pop thread)))
4863 (setq thread (reverse thread))
4865 (gnus-remove-thread-1 (pop thread)))
4866 (when (setq d (gnus-data-find number))
4867 (goto-char (gnus-data-pos d))
4868 (gnus-summary-show-thread)
4874 (gnus-delete-line)))))))
4876 (defun gnus-sort-threads-recursive (threads func)
4877 (sort (mapcar (lambda (thread)
4880 (gnus-sort-threads-recursive (cdr thread) func))))
4883 (defun gnus-sort-threads-loop (threads func)
4884 (let* ((superthread (cons nil threads))
4885 (stack (list (cons superthread threads)))
4886 remaining-threads thread)
4888 (setq remaining-threads (cdr (car stack)))
4889 (if remaining-threads
4890 (progn (setq thread (car remaining-threads))
4891 (setcdr (car stack) (cdr remaining-threads))
4893 (push (cons thread (cdr thread)) stack)))
4894 (setq thread (caar stack))
4895 (setcdr thread (sort (cdr thread) func))
4899 (defun gnus-sort-threads (threads)
4901 (if (not gnus-thread-sort-functions)
4903 (gnus-message 8 "Sorting threads...")
4906 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4907 (gnus-sort-threads-recursive
4908 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4909 ;; Even after binding max-lisp-eval-depth, the recursive
4910 ;; sorter might fail for very long threads. In that case,
4911 ;; try using a (less well-tested) non-recursive sorter.
4912 (error (gnus-message 9 "Sorting threads with loop...")
4913 (gnus-sort-threads-loop
4914 threads (gnus-make-sort-function
4915 gnus-thread-sort-functions))))
4916 (gnus-message 8 "Sorting threads...done"))))
4918 (defun gnus-sort-articles (articles)
4920 (when gnus-article-sort-functions
4921 (gnus-message 7 "Sorting articles...")
4923 (setq gnus-newsgroup-headers
4924 (sort articles (gnus-make-sort-function
4925 gnus-article-sort-functions)))
4926 (gnus-message 7 "Sorting articles...done"))))
4928 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4929 (defmacro gnus-thread-header (thread)
4930 "Return header of first article in THREAD.
4931 Note that THREAD must never, ever be anything else than a variable -
4932 using some other form will lead to serious barfage."
4933 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4934 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4935 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4938 (defsubst gnus-article-sort-by-number (h1 h2)
4939 "Sort articles by article number."
4940 (< (mail-header-number h1)
4941 (mail-header-number h2)))
4943 (defun gnus-thread-sort-by-number (h1 h2)
4944 "Sort threads by root article number."
4945 (gnus-article-sort-by-number
4946 (gnus-thread-header h1) (gnus-thread-header h2)))
4948 (defsubst gnus-article-sort-by-random (h1 h2)
4949 "Sort articles randomly."
4952 (defun gnus-thread-sort-by-random (h1 h2)
4953 "Sort threads randomly."
4954 (gnus-article-sort-by-random
4955 (gnus-thread-header h1) (gnus-thread-header h2)))
4957 (defsubst gnus-article-sort-by-lines (h1 h2)
4958 "Sort articles by article Lines header."
4959 (< (mail-header-lines h1)
4960 (mail-header-lines h2)))
4962 (defun gnus-thread-sort-by-lines (h1 h2)
4963 "Sort threads by root article Lines header."
4964 (gnus-article-sort-by-lines
4965 (gnus-thread-header h1) (gnus-thread-header h2)))
4967 (defsubst gnus-article-sort-by-chars (h1 h2)
4968 "Sort articles by octet length."
4969 (< (mail-header-chars h1)
4970 (mail-header-chars h2)))
4972 (defun gnus-thread-sort-by-chars (h1 h2)
4973 "Sort threads by root article octet length."
4974 (gnus-article-sort-by-chars
4975 (gnus-thread-header h1) (gnus-thread-header h2)))
4977 (defsubst gnus-article-sort-by-author (h1 h2)
4978 "Sort articles by root author."
4980 (let ((extract (funcall
4981 gnus-extract-address-components
4982 (mail-header-from h1))))
4983 (or (car extract) (cadr extract) ""))
4984 (let ((extract (funcall
4985 gnus-extract-address-components
4986 (mail-header-from h2))))
4987 (or (car extract) (cadr extract) ""))))
4989 (defun gnus-thread-sort-by-author (h1 h2)
4990 "Sort threads by root author."
4991 (gnus-article-sort-by-author
4992 (gnus-thread-header h1) (gnus-thread-header h2)))
4994 (defsubst gnus-article-sort-by-recipient (h1 h2)
4995 "Sort articles by recipient."
4997 (let ((extract (funcall
4998 gnus-extract-address-components
4999 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
5000 (or (car extract) (cadr extract)))
5001 (let ((extract (funcall
5002 gnus-extract-address-components
5003 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5004 (or (car extract) (cadr extract)))))
5006 (defun gnus-thread-sort-by-recipient (h1 h2)
5007 "Sort threads by root recipient."
5008 (gnus-article-sort-by-recipient
5009 (gnus-thread-header h1) (gnus-thread-header h2)))
5011 (defsubst gnus-article-sort-by-subject (h1 h2)
5012 "Sort articles by root subject."
5014 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5015 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5017 (defun gnus-thread-sort-by-subject (h1 h2)
5018 "Sort threads by root subject."
5019 (gnus-article-sort-by-subject
5020 (gnus-thread-header h1) (gnus-thread-header h2)))
5022 (defsubst gnus-article-sort-by-date (h1 h2)
5023 "Sort articles by root article date."
5025 (gnus-date-get-time (mail-header-date h1))
5026 (gnus-date-get-time (mail-header-date h2))))
5028 (defun gnus-thread-sort-by-date (h1 h2)
5029 "Sort threads by root article date."
5030 (gnus-article-sort-by-date
5031 (gnus-thread-header h1) (gnus-thread-header h2)))
5033 (defsubst gnus-article-sort-by-score (h1 h2)
5034 "Sort articles by root article score.
5035 Unscored articles will be counted as having a score of zero."
5036 (> (or (cdr (assq (mail-header-number h1)
5037 gnus-newsgroup-scored))
5038 gnus-summary-default-score 0)
5039 (or (cdr (assq (mail-header-number h2)
5040 gnus-newsgroup-scored))
5041 gnus-summary-default-score 0)))
5043 (defun gnus-thread-sort-by-score (h1 h2)
5044 "Sort threads by root article score."
5045 (gnus-article-sort-by-score
5046 (gnus-thread-header h1) (gnus-thread-header h2)))
5048 (defun gnus-thread-sort-by-total-score (h1 h2)
5049 "Sort threads by the sum of all scores in the thread.
5050 Unscored articles will be counted as having a score of zero."
5051 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5053 (defun gnus-thread-total-score (thread)
5054 ;; This function find the total score of THREAD.
5059 (if (stringp (car thread))
5060 (apply gnus-thread-score-function 0
5061 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5062 (gnus-thread-total-score-1 thread)))
5064 (gnus-thread-total-score-1 (list thread)))))
5066 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5067 "Sort articles by number."
5068 (gnus-article-sort-by-number h1 h2))
5070 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5071 "Sort threads such that the thread with the most recently arrived article comes first."
5072 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5074 (defun gnus-thread-highest-number (thread)
5075 "Return the highest article number in THREAD."
5076 (apply 'max (mapcar (lambda (header)
5077 (mail-header-number header))
5078 (message-flatten-list thread))))
5080 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5081 "Sort articles by number."
5082 (gnus-article-sort-by-date h1 h2))
5084 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5085 "Sort threads such that the thread with the most recently dated article comes first."
5086 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5088 ; Since this is called not only to sort the top-level threads, but
5089 ; also in recursive sorts to order the articles within a thread, each
5090 ; article will be processed many times. Thus it speeds things up
5091 ; quite a bit to use gnus-date-get-time, which caches the time value.
5092 (defun gnus-thread-latest-date (thread)
5093 "Return the highest article date in THREAD."
5095 (mapcar (lambda (header) (gnus-float-time
5097 (mail-header-date header))))
5098 (message-flatten-list thread))))
5100 (defun gnus-thread-total-score-1 (root)
5101 ;; This function find the total score of the thread below ROOT.
5102 (setq root (car root))
5103 (apply gnus-thread-score-function
5105 (mapcar 'gnus-thread-total-score
5106 (cdr (gnus-id-to-thread (mail-header-id root))))
5107 (when (> (mail-header-number root) 0)
5108 (list (or (cdr (assq (mail-header-number root)
5109 gnus-newsgroup-scored))
5110 gnus-summary-default-score 0))))
5111 (list gnus-summary-default-score)
5114 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5115 (defvar gnus-tmp-prev-subject nil)
5116 (defvar gnus-tmp-false-parent nil)
5117 (defvar gnus-tmp-root-expunged nil)
5118 (defvar gnus-tmp-dummy-line nil)
5120 (defun gnus-extra-header (type &optional header)
5121 "Return the extra header of TYPE."
5122 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5125 (defvar gnus-tmp-thread-tree-header-string "")
5127 (defcustom gnus-sum-thread-tree-root "> "
5128 "With %B spec, used for the root of a thread.
5129 If nil, use subject instead."
5131 :type '(radio (const :format "%v " nil) string)
5132 :group 'gnus-thread)
5134 (defcustom gnus-sum-thread-tree-false-root "> "
5135 "With %B spec, used for a false root of a thread.
5136 If nil, use subject instead."
5138 :type '(radio (const :format "%v " nil) string)
5139 :group 'gnus-thread)
5141 (defcustom gnus-sum-thread-tree-single-indent ""
5142 "With %B spec, used for a thread with just one message.
5143 If nil, use subject instead."
5145 :type '(radio (const :format "%v " nil) string)
5146 :group 'gnus-thread)
5148 (defcustom gnus-sum-thread-tree-vertical "| "
5149 "With %B spec, used for drawing a vertical line."
5152 :group 'gnus-thread)
5154 (defcustom gnus-sum-thread-tree-indent " "
5155 "With %B spec, used for indenting."
5158 :group 'gnus-thread)
5160 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5161 "With %B spec, used for a leaf with brothers."
5164 :group 'gnus-thread)
5166 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5167 "With %B spec, used for a leaf without brothers."
5170 :group 'gnus-thread)
5172 (defcustom gnus-summary-display-while-building nil
5173 "If non-nil, show and update the summary buffer as it's being built.
5174 If the value is t, update the buffer after every line is inserted. If
5175 the value is an integer (N), update the display every N lines."
5178 :type '(choice (const :tag "off" nil)
5180 (const :tag "frequently" t)))
5182 (defun gnus-summary-prepare-threads (threads)
5183 "Prepare summary buffer from THREADS and indentation LEVEL.
5184 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5185 or a straight list of headers."
5186 (gnus-message 7 "Generating summary...")
5188 (setq gnus-newsgroup-threads threads)
5191 (let ((gnus-tmp-level 0)
5192 (default-score (or gnus-summary-default-score 0))
5193 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5194 (building-line-count gnus-summary-display-while-building)
5195 (building-count (integerp gnus-summary-display-while-building))
5196 thread number subject stack state gnus-tmp-gathered beg-match
5197 new-roots gnus-tmp-new-adopts thread-end simp-subject
5198 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5199 gnus-tmp-replied gnus-tmp-subject-or-nil
5200 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5201 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5202 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5205 (setq gnus-tmp-prev-subject nil
5206 gnus-tmp-thread-tree-header-string "")
5208 (if (vectorp (car threads))
5209 ;; If this is a straight (sic) list of headers, then a
5210 ;; threaded summary display isn't required, so we just create
5211 ;; an unthreaded one.
5212 (gnus-summary-prepare-unthreaded threads)
5214 ;; Do the threaded display.
5216 (if gnus-summary-display-while-building
5217 (switch-to-buffer (buffer-name)))
5218 (while (or threads stack gnus-tmp-new-adopts new-roots)
5220 (if (and (= gnus-tmp-level 0)
5223 (not gnus-tmp-false-parent)
5224 (or gnus-tmp-new-adopts new-roots))
5225 (if gnus-tmp-new-adopts
5226 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5227 thread (list (car gnus-tmp-new-adopts))
5228 gnus-tmp-header (caar thread)
5229 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5231 (setq thread (list (car new-roots))
5232 gnus-tmp-header (caar thread)
5233 new-roots (cdr new-roots))))
5236 ;; If there are some threads, we do them before the
5237 ;; threads on the stack.
5238 (setq thread threads
5239 gnus-tmp-header (caar thread))
5240 ;; There were no current threads, so we pop something off
5242 (setq state (car stack)
5243 gnus-tmp-level (car state)
5244 tree-stack (cadr state)
5245 thread (caddr state)
5247 gnus-tmp-header (caar thread))))
5249 (setq gnus-tmp-false-parent nil)
5250 (setq gnus-tmp-root-expunged nil)
5251 (setq thread-end nil)
5253 (if (stringp gnus-tmp-header)
5254 ;; The header is a dummy root.
5256 ((eq gnus-summary-make-false-root 'adopt)
5257 ;; We let the first article adopt the rest.
5258 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5260 (setq gnus-tmp-gathered
5262 (lambda (h) (mail-header-number (car h)))
5265 (setq thread (cons (list (caar thread)
5268 (setq gnus-tmp-level -1
5269 gnus-tmp-false-parent t))
5270 ((eq gnus-summary-make-false-root 'empty)
5271 ;; We print adopted articles with empty subject fields.
5272 (setq gnus-tmp-gathered
5274 (lambda (h) (mail-header-number (car h)))
5277 (setq gnus-tmp-level -1))
5278 ((eq gnus-summary-make-false-root 'dummy)
5279 ;; We remember that we probably want to output a dummy
5281 (setq gnus-tmp-dummy-line gnus-tmp-header)
5282 (setq gnus-tmp-prev-subject gnus-tmp-header))
5284 ;; We do not make a root for the gathered
5285 ;; sub-threads at all.
5286 (setq gnus-tmp-level -1)))
5288 (setq number (mail-header-number gnus-tmp-header)
5289 subject (mail-header-subject gnus-tmp-header)
5290 simp-subject (gnus-simplify-subject-fully subject))
5293 ;; If the thread has changed subject, we might want to make
5294 ;; this subthread into a root.
5295 ((and (null gnus-thread-ignore-subject)
5296 (not (zerop gnus-tmp-level))
5297 gnus-tmp-prev-subject
5298 (not (string= gnus-tmp-prev-subject simp-subject)))
5299 (setq new-roots (nconc new-roots (list (car thread)))
5301 gnus-tmp-header nil))
5302 ;; If the article lies outside the current limit,
5303 ;; then we do not display it.
5304 ((not (memq number gnus-newsgroup-limit))
5305 (setq gnus-tmp-gathered
5307 (lambda (h) (mail-header-number (car h)))
5310 (setq gnus-tmp-new-adopts (if (cdar thread)
5311 (append gnus-tmp-new-adopts
5313 gnus-tmp-new-adopts)
5315 gnus-tmp-header nil)
5316 (when (zerop gnus-tmp-level)
5317 (setq gnus-tmp-root-expunged t)))
5318 ;; Perhaps this article is to be marked as read?
5319 ((and gnus-summary-mark-below
5320 (< (or (cdr (assq number gnus-newsgroup-scored))
5322 gnus-summary-mark-below)
5323 ;; Don't touch sparse articles.
5324 (not (gnus-summary-article-sparse-p number))
5325 (not (gnus-summary-article-ancient-p number)))
5326 (setq gnus-newsgroup-unreads
5327 (delq number gnus-newsgroup-unreads))
5328 (if gnus-newsgroup-auto-expire
5329 (setq gnus-newsgroup-expirable
5330 (gnus-add-to-sorted-list
5331 gnus-newsgroup-expirable number))
5332 (push (cons number gnus-low-score-mark)
5333 gnus-newsgroup-reads))))
5335 (when gnus-tmp-header
5336 ;; We may have an old dummy line to output before this
5338 (when (and gnus-tmp-dummy-line
5341 (mail-header-subject gnus-tmp-header)))
5342 (gnus-summary-insert-dummy-line
5343 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5344 (setq gnus-tmp-dummy-line nil))
5346 ;; Compute the mark.
5347 (setq gnus-tmp-unread (gnus-article-mark number))
5349 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5350 gnus-tmp-header gnus-tmp-level)
5351 gnus-newsgroup-data)
5353 ;; Actually insert the line.
5355 gnus-tmp-subject-or-nil
5357 ((and gnus-thread-ignore-subject
5358 gnus-tmp-prev-subject
5359 (not (string= gnus-tmp-prev-subject simp-subject)))
5361 ((zerop gnus-tmp-level)
5362 (if (and (eq gnus-summary-make-false-root 'empty)
5363 (memq number gnus-tmp-gathered)
5364 gnus-tmp-prev-subject
5365 (string= gnus-tmp-prev-subject simp-subject))
5366 gnus-summary-same-subject
5368 (t gnus-summary-same-subject)))
5369 (if (and (eq gnus-summary-make-false-root 'adopt)
5370 (= gnus-tmp-level 1)
5371 (memq number gnus-tmp-gathered))
5372 (setq gnus-tmp-opening-bracket ?\<
5373 gnus-tmp-closing-bracket ?\>)
5374 (setq gnus-tmp-opening-bracket ?\[
5375 gnus-tmp-closing-bracket ?\]))
5376 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5377 (gnus-make-thread-indent-array
5378 (max (* 2 (length gnus-thread-indent-array))
5381 gnus-tmp-indentation
5382 (aref gnus-thread-indent-array gnus-tmp-level)
5383 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5384 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5385 gnus-summary-default-score 0)
5387 (if (or (null gnus-summary-default-score)
5388 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5389 gnus-summary-zcore-fuzz))
5391 (if (< gnus-tmp-score gnus-summary-default-score)
5392 gnus-score-below-mark gnus-score-over-mark))
5394 (cond ((memq number gnus-newsgroup-processable)
5396 ((memq number gnus-newsgroup-cached)
5398 ((memq number gnus-newsgroup-replied)
5400 ((memq number gnus-newsgroup-forwarded)
5401 gnus-forwarded-mark)
5402 ((memq number gnus-newsgroup-saved)
5404 ((memq number gnus-newsgroup-unseen)
5408 (cond ((memq number gnus-newsgroup-undownloaded)
5409 gnus-undownloaded-mark)
5410 (gnus-newsgroup-agentized
5411 gnus-downloaded-mark)
5414 gnus-tmp-from (mail-header-from gnus-tmp-header)
5417 ((string-match "<[^>]+> *$" gnus-tmp-from)
5418 (setq beg-match (match-beginning 0))
5419 (or (and (string-match "^\".+\"" gnus-tmp-from)
5420 (substring gnus-tmp-from 1 (1- (match-end 0))))
5421 (substring gnus-tmp-from 0 beg-match)))
5422 ((string-match "(.+)" gnus-tmp-from)
5423 (substring gnus-tmp-from
5424 (1+ (match-beginning 0)) (1- (match-end 0))))
5428 gnus-tmp-thread-tree-header-string
5430 ((not gnus-show-threads) "")
5431 ((zerop gnus-tmp-level)
5432 (cond ((cdar thread)
5433 (or gnus-sum-thread-tree-root subject))
5434 (gnus-tmp-new-adopts
5435 (or gnus-sum-thread-tree-false-root subject))
5437 (or gnus-sum-thread-tree-single-indent subject))))
5439 (concat (apply 'concat
5440 (mapcar (lambda (item)
5442 gnus-sum-thread-tree-vertical
5443 gnus-sum-thread-tree-indent))
5444 (cdr (reverse tree-stack))))
5446 gnus-sum-thread-tree-leaf-with-other
5447 gnus-sum-thread-tree-single-leaf)))))
5448 (when (string= gnus-tmp-name "")
5449 (setq gnus-tmp-name gnus-tmp-from))
5450 (unless (numberp gnus-tmp-lines)
5451 (setq gnus-tmp-lines -1))
5452 (if (= gnus-tmp-lines -1)
5453 (setq gnus-tmp-lines "?")
5454 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5455 (gnus-put-text-property
5457 (progn (eval gnus-summary-line-format-spec) (point))
5458 'gnus-number number)
5461 (gnus-summary-highlight-line)
5462 (when gnus-summary-update-hook
5463 (gnus-run-hooks 'gnus-summary-update-hook))
5466 (setq gnus-tmp-prev-subject simp-subject)))
5468 (when (nth 1 thread)
5469 (push (list (max 0 gnus-tmp-level)
5470 (copy-sequence tree-stack)
5473 (push (if (nth 1 thread) 1 0) tree-stack)
5474 (incf gnus-tmp-level)
5475 (setq threads (if thread-end nil (cdar thread)))
5476 (if gnus-summary-display-while-building
5479 ;; use a set frequency
5480 (setq building-line-count (1- building-line-count))
5481 (when (= building-line-count 0)
5483 (setq building-line-count
5484 gnus-summary-display-while-building)))
5488 (setq gnus-tmp-level 0)))))
5489 (gnus-message 7 "Generating summary...done"))
5491 (defun gnus-summary-prepare-unthreaded (headers)
5492 "Generate an unthreaded summary buffer based on HEADERS."
5493 (let (header number mark)
5498 ;; We may have to root out some bad articles...
5499 (when (memq (setq number (mail-header-number
5500 (setq header (pop headers))))
5501 gnus-newsgroup-limit)
5502 ;; Mark article as read when it has a low score.
5503 (when (and gnus-summary-mark-below
5504 (< (or (cdr (assq number gnus-newsgroup-scored))
5505 gnus-summary-default-score 0)
5506 gnus-summary-mark-below)
5507 (not (gnus-summary-article-ancient-p number)))
5508 (setq gnus-newsgroup-unreads
5509 (delq number gnus-newsgroup-unreads))
5510 (if gnus-newsgroup-auto-expire
5511 (push number gnus-newsgroup-expirable)
5512 (push (cons number gnus-low-score-mark)
5513 gnus-newsgroup-reads)))
5515 (setq mark (gnus-article-mark number))
5516 (push (gnus-data-make number mark (1+ (point)) header 0)
5517 gnus-newsgroup-data)
5518 (gnus-summary-insert-line
5520 (memq number gnus-newsgroup-undownloaded)
5521 mark (memq number gnus-newsgroup-replied)
5522 (memq number gnus-newsgroup-expirable)
5523 (mail-header-subject header) nil
5524 (cdr (assq number gnus-newsgroup-scored))
5525 (memq number gnus-newsgroup-processable))))))
5527 (defun gnus-group-get-list-identifiers (group)
5528 "Get list identifier regexp for GROUP."
5529 (or (gnus-parameter-list-identifier group)
5530 (if (consp gnus-list-identifiers)
5531 (mapconcat 'identity gnus-list-identifiers " *\\|")
5532 gnus-list-identifiers)))
5534 (defun gnus-summary-remove-list-identifiers ()
5535 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5536 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5539 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5540 (dolist (header gnus-newsgroup-headers)
5541 (setq subject (mail-header-subject header)
5543 (while (string-match regexp subject)
5545 (concat (substring subject 0 (match-beginning 1))
5546 (substring subject (match-end 0)))
5549 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5551 (concat (substring subject 0 (match-beginning 1))
5552 (substring subject (match-end 1)))))
5553 (mail-header-set-subject header subject))))))
5555 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5556 "Fetch headers of ARTICLES."
5557 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5558 (gnus-message 7 "Fetching headers for %s..." name)
5561 (setq gnus-headers-retrieved-by
5562 (gnus-retrieve-headers
5563 articles gnus-newsgroup-name
5565 ;; We might want to fetch old headers, but
5566 ;; not if there is only 1 article.
5568 (not (eq gnus-fetch-old-headers 'some))
5569 (not (numberp gnus-fetch-old-headers)))
5570 (> (length articles) 1))
5571 gnus-fetch-old-headers)))))
5572 (gnus-get-newsgroup-headers-xover
5573 articles force-new dependencies gnus-newsgroup-name t)
5574 (gnus-get-newsgroup-headers dependencies force-new))
5575 (gnus-message 7 "Fetching headers for %s...done" name))))
5577 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5578 "Select newsgroup GROUP.
5579 If READ-ALL is non-nil, all articles in the group are selected.
5580 If SELECT-ARTICLES, only select those articles from GROUP."
5581 (let* ((entry (gnus-group-entry group))
5582 ;;!!! Dirty hack; should be removed.
5583 (gnus-summary-ignore-duplicates
5584 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5586 gnus-summary-ignore-duplicates))
5587 (info (nth 2 entry))
5588 charset articles fetched-articles cached)
5590 (unless (gnus-check-server
5591 (set (make-local-variable 'gnus-current-select-method)
5592 (gnus-find-method-for-group group)))
5593 (error "Couldn't open server"))
5594 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5596 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5597 (gnus-activate-group group) ; Or we can activate it...
5598 (progn ; Or we bug out.
5599 (when (equal major-mode 'gnus-summary-mode)
5600 (gnus-kill-buffer (current-buffer)))
5602 "Couldn't activate group %s: %s"
5603 (mm-decode-coding-string group charset)
5604 (mm-decode-coding-string (gnus-status-message group) charset))))
5606 (unless (gnus-request-group group t)
5607 (when (equal major-mode 'gnus-summary-mode)
5608 (gnus-kill-buffer (current-buffer)))
5609 (error "Couldn't request group %s: %s"
5610 (mm-decode-coding-string group charset)
5611 (mm-decode-coding-string (gnus-status-message group) charset)))
5613 (when (and gnus-agent
5614 (gnus-active group))
5615 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5617 (setq gnus-summary-use-undownloaded-faces
5618 (gnus-agent-find-parameter
5620 'agent-enable-undownloaded-faces)))
5622 (setq gnus-newsgroup-name group
5623 gnus-newsgroup-unselected nil
5624 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5626 (let ((display (gnus-group-find-parameter group 'display)))
5627 (setq gnus-newsgroup-display
5629 ((not (zerop (or (car-safe read-all) 0)))
5630 ;; The user entered the group with C-u SPC/RET, let's show
5636 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5638 ;; The following is probably the "correct" solution, but
5639 ;; it makes Gnus fetch all headers and then limit the
5640 ;; articles (which is slow), so instead we hack the
5641 ;; select-articles parameter instead. -- Simon Josefsson
5644 ;; (gnus-byte-compile
5645 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5647 (setq select-articles
5648 (gnus-uncompress-range
5649 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5653 (cdr (gnus-active group)))))
5658 (gnus-summary-setup-default-charset)
5660 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5661 (when (gnus-virtual-group-p group)
5662 (setq cached gnus-newsgroup-cached))
5664 (setq gnus-newsgroup-unreads
5665 (gnus-sorted-ndifference
5666 (gnus-sorted-ndifference gnus-newsgroup-unreads
5667 gnus-newsgroup-marked)
5668 gnus-newsgroup-dormant))
5670 (setq gnus-newsgroup-processable nil)
5672 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5674 ;; Adjust and set lists of article marks.
5676 (gnus-adjust-marked-articles info))
5677 (if (setq articles select-articles)
5678 (setq gnus-newsgroup-unselected
5679 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5680 (setq articles (gnus-articles-to-read group read-all)))
5684 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5686 ((eq articles 0) nil)
5688 ;; Init the dependencies hash table.
5689 (setq gnus-newsgroup-dependencies
5690 (gnus-make-hashtable (length articles)))
5691 (gnus-set-global-variables)
5692 ;; Retrieve the headers and read them in.
5694 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5696 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5698 (setq gnus-newsgroup-cached cached))
5700 ;; Suppress duplicates?
5701 (when gnus-suppress-duplicates
5702 (gnus-dup-suppress-articles))
5704 ;; Set the initial limit.
5705 (setq gnus-newsgroup-limit (copy-sequence articles))
5706 ;; Remove canceled articles from the list of unread articles.
5707 (setq fetched-articles
5708 (mapcar (lambda (headers) (mail-header-number headers))
5709 gnus-newsgroup-headers))
5710 (setq gnus-newsgroup-articles fetched-articles)
5711 (setq gnus-newsgroup-unreads
5712 (gnus-sorted-nintersection
5713 gnus-newsgroup-unreads fetched-articles))
5714 (gnus-compute-unseen-list)
5716 ;; Removed marked articles that do not exist.
5717 (gnus-update-missing-marks
5718 (gnus-sorted-difference articles fetched-articles))
5719 ;; We might want to build some more threads first.
5720 (when (and gnus-fetch-old-headers
5721 (eq gnus-headers-retrieved-by 'nov))
5722 (if (eq gnus-fetch-old-headers 'invisible)
5723 (gnus-build-all-threads)
5724 (gnus-build-old-threads)))
5725 ;; Let the Gnus agent mark articles as read.
5727 (gnus-agent-get-undownloaded-list))
5728 ;; Remove list identifiers from subject
5729 (gnus-summary-remove-list-identifiers)
5730 ;; Check whether auto-expire is to be done in this group.
5731 (setq gnus-newsgroup-auto-expire
5732 (and (gnus-group-auto-expirable-p group)
5733 (not (gnus-group-read-only-p group))))
5734 ;; Set up the article buffer now, if necessary.
5735 (unless (and gnus-single-article-buffer
5736 (equal gnus-article-buffer "*Article*"))
5737 (gnus-article-setup-buffer))
5738 ;; First and last article in this newsgroup.
5739 (when gnus-newsgroup-headers
5740 (setq gnus-newsgroup-begin
5741 (mail-header-number (car gnus-newsgroup-headers))
5744 (gnus-last-element gnus-newsgroup-headers))))
5745 ;; GROUP is successfully selected.
5746 (or gnus-newsgroup-headers t)))))
5748 (defun gnus-compute-unseen-list ()
5749 ;; The `seen' marks are treated specially.
5750 (if (not gnus-newsgroup-seen)
5751 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5752 (setq gnus-newsgroup-unseen
5753 (gnus-inverse-list-range-intersection
5754 gnus-newsgroup-articles gnus-newsgroup-seen))))
5756 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5758 (defun gnus-summary-display-make-predicate (display)
5759 (require 'gnus-agent)
5760 (when (= (length display) 1)
5761 (setq display (car display)))
5762 (unless gnus-summary-display-cache
5763 (dolist (elem (append '((unread . unread)
5766 gnus-article-mark-lists))
5767 (push (cons (cdr elem)
5768 (gnus-byte-compile ;Why bother?
5769 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5770 gnus-summary-display-cache)))
5771 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5772 (gnus-category-predicate-cache gnus-summary-display-cache))
5773 (gnus-get-predicate display)))
5775 ;; Uses the dynamically bound `gnus-number' variable.
5776 (defvar gnus-number)
5777 (defun gnus-article-marked-p (type &optional article)
5778 (let ((article (or article gnus-number)))
5781 (memq article gnus-newsgroup-marked))
5783 (memq article gnus-newsgroup-spam-marked))
5785 (memq article gnus-newsgroup-unsendable))
5786 ((eq type 'undownload)
5787 (memq article gnus-newsgroup-undownloaded))
5788 ((eq type 'download)
5789 (memq article gnus-newsgroup-downloadable))
5791 (memq article gnus-newsgroup-unreads))
5793 (memq article gnus-newsgroup-reads))
5795 (memq article gnus-newsgroup-dormant) )
5797 (memq article gnus-newsgroup-expirable))
5799 (memq article gnus-newsgroup-replied))
5801 (memq article gnus-newsgroup-killed))
5802 ((eq type 'bookmark)
5803 (assq article gnus-newsgroup-bookmarks))
5805 (assq article gnus-newsgroup-scored))
5807 (memq article gnus-newsgroup-saved))
5809 (memq article gnus-newsgroup-cached))
5811 (memq article gnus-newsgroup-forwarded))
5813 (not (memq article gnus-newsgroup-unseen)))
5816 (defun gnus-articles-to-read (group &optional read-all)
5817 "Find out what articles the user wants to read."
5818 (let* ((only-read-p t)
5820 (gnus-list-range-difference
5821 ;; Select all articles if `read-all' is non-nil, or if there
5822 ;; are no unread articles.
5824 (and (zerop (length gnus-newsgroup-marked))
5825 (zerop (length gnus-newsgroup-unreads)))
5826 ;; Fetch all if the predicate is non-nil.
5827 gnus-newsgroup-display)
5828 ;; We want to select the headers for all the articles in
5829 ;; the group, so we select either all the active
5830 ;; articles in the group, or (if that's nil), the
5831 ;; articles in the cache.
5833 (if gnus-newsgroup-maximum-articles
5834 (let ((active (gnus-active group)))
5835 (gnus-uncompress-range
5836 (cons (max (car active)
5838 gnus-newsgroup-maximum-articles
5841 (gnus-uncompress-range (gnus-active group)))
5842 (gnus-cache-articles-in-group group))
5843 ;; Select only the "normal" subset of articles.
5844 (setq only-read-p nil)
5846 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5847 gnus-newsgroup-unreads))
5848 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5849 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5850 (scored (length scored-list))
5851 (number (length articles))
5852 (marked (+ (length gnus-newsgroup-marked)
5853 (length gnus-newsgroup-dormant)))
5858 ((numberp gnus-newsgroup-display)
5859 gnus-newsgroup-display)
5863 ((and (or (<= scored marked) (= scored number))
5864 (numberp gnus-large-newsgroup)
5865 (> number gnus-large-newsgroup))
5866 (let* ((cursor-in-echo-area nil)
5867 (initial (gnus-parameter-large-newsgroup-initial
5868 gnus-newsgroup-name))
5869 (default (if only-read-p
5870 (or initial gnus-large-newsgroup)
5876 "How many articles from %s (available %d, default %d): "
5877 (gnus-group-decoded-name
5878 (gnus-group-real-name gnus-newsgroup-name))
5881 "How many articles from %s (%d default): "
5882 (gnus-group-decoded-name
5883 (gnus-group-real-name gnus-newsgroup-name))
5887 (number-to-string default))))
5888 (if (string-match "^[ \t]*$" input) number input)))
5889 ((and (> scored marked) (< scored number)
5890 (> (- scored number) 20))
5893 (format "%s %s (%d scored, %d total): "
5894 "How many articles from"
5895 (gnus-group-decoded-name
5896 (gnus-group-real-name gnus-newsgroup-name))
5898 (if (string-match "^[ \t]*$" input)
5902 (message "Quit getting the articles to read")
5904 (setq select (if (stringp select) (string-to-number select) select))
5905 (if (or (null select) (zerop select))
5907 (if (and (not (zerop scored)) (<= (abs select) scored))
5909 (setq articles (sort scored-list '<))
5910 (setq number (length articles)))
5911 (setq articles (copy-sequence articles)))
5913 (when (< (abs select) number)
5915 ;; Select the N oldest articles.
5916 (setcdr (nthcdr (1- (abs select)) articles) nil)
5917 ;; Select the N most recent articles.
5918 (setq articles (nthcdr (- number select) articles))))
5919 (setq gnus-newsgroup-unselected
5920 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5921 (when gnus-alter-articles-to-read-function
5924 (funcall gnus-alter-articles-to-read-function
5925 gnus-newsgroup-name articles)
5929 (defun gnus-killed-articles (killed articles)
5932 (when (inline (gnus-member-of-range (car articles) killed))
5933 (push (car articles) out))
5934 (setq articles (cdr articles)))
5937 (defun gnus-uncompress-marks (marks)
5938 "Uncompress the mark ranges in MARKS."
5939 (let ((uncompressed '(score bookmark))
5942 (if (memq (caar marks) uncompressed)
5943 (push (car marks) out)
5944 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5945 (setq marks (cdr marks)))
5948 (defun gnus-article-mark-to-type (mark)
5949 "Return the type of MARK."
5950 (or (cadr (assq mark gnus-article-special-mark-lists))
5953 (defun gnus-article-unpropagatable-p (mark)
5954 "Return whether MARK should be propagated to back end."
5955 (memq mark gnus-article-unpropagated-mark-lists))
5957 (defun gnus-adjust-marked-articles (info)
5958 "Set all article lists and remove all marks that are no longer valid."
5959 (let* ((marked-lists (gnus-info-marks info))
5960 (active (gnus-active (gnus-info-group info)))
5963 (types gnus-article-mark-lists)
5964 marks var articles article mark mark-type
5966 ;; Hack to avoid adjusting marks for imap.
5967 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5971 (dolist (marks marked-lists)
5972 (setq mark (car marks)
5973 mark-type (gnus-article-mark-to-type mark)
5974 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5976 ;; We set the variable according to the type of the marks list,
5977 ;; and then adjust the marks to a subset of the active articles.
5979 ;; Adjust "simple" lists - compressed yet unsorted
5980 ((eq mark-type 'list)
5981 ;; Simultaneously uncompress and clip to active range
5982 ;; See gnus-uncompress-range for a description of possible marks
5984 (if (not (cadr marks))
5986 (setq articles (if (numberp (cddr marks))
5992 (while (setq article (pop articles))
5993 (cond ((consp article)
5994 (setq bgn (max (car article) min)
5995 end (min (cdr article) max))
5997 (setq l (setcdr l (cons bgn nil))
5999 ((and (<= min article)
6001 (setq l (setcdr l (cons article nil))))))
6002 (set var (cdr lh)))))
6004 ((eq mark-type 'tuple)
6005 (set var (setq articles (cdr marks)))
6006 (when (not (listp (cdr (symbol-value var))))
6007 (set var (list (symbol-value var))))
6008 (when (not (listp (cdr articles)))
6009 (setq articles (list articles)))
6011 (when (or (not (consp (setq article (pop articles))))
6012 (< (car article) min)
6013 (> (car article) max))
6014 (set var (delq article (symbol-value var))))))
6015 ;; Adjust ranges (sloppily).
6016 ((eq mark-type 'range)
6019 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6020 ;; It should be (seen (NUM1 . NUM2)).
6021 (when (numberp (cddr marks))
6022 (setcdr marks (list (cdr marks))))
6023 (setq articles (cdr marks))
6024 (while (and articles
6025 (or (and (consp (car articles))
6026 (> min (cdar articles)))
6027 (and (numberp (car articles))
6028 (> min (car articles)))))
6032 (set var (cdr marks)))))))))
6034 (defun gnus-update-missing-marks (missing)
6035 "Go through the list of MISSING articles and remove them from the mark lists."
6038 ;; Go through all types.
6039 (dolist (elem gnus-article-mark-lists)
6040 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6041 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6042 (when (symbol-value var)
6043 ;; This list has articles. So we delete all missing
6044 ;; articles from it.
6047 (set var (delq (pop m) (symbol-value var))))))))))
6049 (defun gnus-update-marks ()
6050 "Enter the various lists of marked articles into the newsgroup info list."
6051 (let ((types gnus-article-mark-lists)
6052 (info (gnus-get-info gnus-newsgroup-name))
6053 type list newmarked symbol delta-marks)
6055 ;; Add all marks lists to the list of marks lists.
6056 (while (setq type (pop types))
6057 (setq list (symbol-value
6059 (intern (format "gnus-newsgroup-%s" (car type))))))
6062 ;; Get rid of the entries of the articles that have the
6064 (when (and (eq (cdr type) 'score)
6068 (prev (cons nil list))
6071 (if (or (not (consp (car arts)))
6072 (= (cdar arts) gnus-summary-default-score))
6073 (setcdr prev (cdr arts))
6075 (setq arts (cdr arts)))
6076 (setq list (cdr all)))))
6078 (when (eq (cdr type) 'seen)
6079 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6081 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6082 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6084 (when (and (gnus-check-backend-function
6085 'request-set-mark gnus-newsgroup-name)
6086 (not (gnus-article-unpropagatable-p (cdr type))))
6087 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6088 ;; Don't do anything about marks for articles we
6089 ;; didn't actually get any headers for.
6091 (gnus-list-range-intersection
6092 gnus-newsgroup-articles
6093 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6095 (gnus-list-range-intersection
6096 gnus-newsgroup-articles
6097 (gnus-remove-from-range
6098 (gnus-copy-sequence list) old))))
6100 (push (list add 'add (list (cdr type))) delta-marks))
6102 ;; Don't delete marks from outside the active range.
6103 ;; This shouldn't happen, but is a sanity check.
6104 (setq del (gnus-sorted-range-intersection
6105 (gnus-active gnus-newsgroup-name) del))
6106 (push (list del 'del (list (cdr type))) delta-marks))))
6109 (push (cons (cdr type) list) newmarked)))
6112 (unless (gnus-check-group gnus-newsgroup-name)
6113 (error "Can't open server for %s" gnus-newsgroup-name))
6114 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6116 ;; Enter these new marks into the info of the group.
6118 (setcar (nthcdr 3 info) newmarked)
6119 ;; Add the marks lists to the end of the info.
6121 (setcdr (nthcdr 2 info) (list newmarked))))
6123 ;; Cut off the end of the info if there's nothing else there.
6127 (when (nthcdr (decf i) info)
6128 (setcdr (nthcdr i info) nil)))))))
6130 (defun gnus-set-mode-line (where)
6131 "Set the mode line of the article or summary buffers.
6132 If WHERE is `summary', the summary mode line format will be used."
6133 ;; Is this mode line one we keep updated?
6134 (when (and (memq where gnus-updated-mode-lines)
6136 (intern (format "gnus-%s-mode-line-format-spec" where))))
6138 ;; We evaluate this in the summary buffer since these
6139 ;; variables are buffer-local to that buffer.
6140 (with-current-buffer gnus-summary-buffer
6141 ;; We bind all these variables that are used in the `eval' form
6143 (let* ((mformat (symbol-value
6145 (format "gnus-%s-mode-line-format-spec" where))))
6146 (gnus-tmp-group-name (gnus-mode-string-quote
6147 (gnus-group-decoded-name
6148 gnus-newsgroup-name)))
6149 (gnus-tmp-article-number (or gnus-current-article 0))
6150 (gnus-tmp-unread gnus-newsgroup-unreads)
6151 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6152 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6153 (gnus-tmp-unread-and-unselected
6154 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6155 (zerop gnus-tmp-unselected))
6157 ((zerop gnus-tmp-unselected)
6158 (format "{%d more}" gnus-tmp-unread-and-unticked))
6159 (t (format "{%d(+%d) more}"
6160 gnus-tmp-unread-and-unticked
6161 gnus-tmp-unselected))))
6163 (if (and gnus-current-headers
6164 (vectorp gnus-current-headers))
6165 (gnus-mode-string-quote
6166 (mail-header-subject gnus-current-headers))
6168 bufname-length max-len
6169 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6170 (setq mode-string (eval mformat))
6171 (setq bufname-length (if (string-match "%b" mode-string)
6174 (if (eq where 'summary)
6176 (get-buffer gnus-article-buffer))))
6179 (setq max-len (max 4 (if gnus-mode-non-string-length
6181 gnus-mode-non-string-length
6183 (length mode-string))))
6184 ;; We might have to chop a bit of the string off...
6185 (when (> (length mode-string) max-len)
6187 (concat (truncate-string-to-width mode-string (- max-len 3))
6189 ;; Update the mode line.
6190 (setq mode-line-buffer-identification
6191 (gnus-mode-line-buffer-identification (list mode-string)))
6192 (set-buffer-modified-p t))))
6194 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6195 "Go through the HEADERS list and add all Xrefs to a hash table.
6196 The resulting hash table is returned, or nil if no Xrefs were found."
6197 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6198 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6199 (xref-hashtb (gnus-make-hashtable))
6200 start group entry number xrefs header)
6202 (setq header (pop headers))
6203 (when (and (setq xrefs (mail-header-xref header))
6204 (not (memq (setq number (mail-header-number header))
6207 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6208 (setq start (match-end 0))
6209 (setq group (if prefix
6210 (concat prefix (substring xrefs (match-beginning 1)
6212 (substring xrefs (match-beginning 1) (match-end 1))))
6214 (string-to-number (substring xrefs (match-beginning 2)
6216 (if (setq entry (gnus-gethash group xref-hashtb))
6217 (setcdr entry (cons number (cdr entry)))
6218 (gnus-sethash group (cons number nil) xref-hashtb)))))
6219 (and start xref-hashtb)))
6221 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6222 "Look through all the headers and mark the Xrefs as read."
6223 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6224 name info xref-hashtb idlist method nth4)
6225 (with-current-buffer gnus-group-buffer
6226 (when (setq xref-hashtb
6227 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6230 (unless (string= from-newsgroup (setq name (symbol-name group)))
6231 (setq idlist (symbol-value group))
6232 ;; Dead groups are not updated.
6234 (setq info (gnus-get-info name))
6235 (when (stringp (setq nth4 (gnus-info-method info)))
6236 (setq nth4 (gnus-server-to-method nth4))))
6237 ;; Only do the xrefs if the group has the same
6238 ;; select method as the group we have just read.
6239 (or (gnus-methods-equal-p
6240 nth4 (gnus-find-method-for-group from-newsgroup))
6242 (equal nth4 (setq method (gnus-find-method-for-group
6244 (and (equal (car nth4) (car method))
6245 (equal (nth 1 nth4) (nth 1 method))))
6246 gnus-use-cross-reference
6247 (or (not (eq gnus-use-cross-reference t))
6249 ;; Only do cross-references on subscribed
6250 ;; groups, if that is what is wanted.
6251 (<= (gnus-info-level info) gnus-level-subscribed))
6252 (gnus-group-make-articles-read name idlist))))
6255 (defun gnus-compute-read-articles (group articles)
6256 (let* ((entry (gnus-group-entry group))
6257 (info (nth 2 entry))
6258 (active (gnus-active group))
6261 ;; First peel off all invalid article numbers.
6263 (let ((ids articles)
6265 (while (setq id (pop ids))
6266 (when (and first (> id (cdr active)))
6267 ;; We'll end up in this situation in one particular
6268 ;; obscure situation. If you re-scan a group and get
6269 ;; a new article that is cross-posted to a different
6270 ;; group that has not been re-scanned, you might get
6271 ;; crossposted article that has a higher number than
6272 ;; Gnus believes possible. So we re-activate this
6273 ;; group as well. This might mean doing the
6274 ;; crossposting thingy will *increase* the number
6275 ;; of articles in some groups. Tsk, tsk.
6276 (setq active (or (gnus-activate-group group) active)))
6277 (when (or (> id (cdr active))
6278 (< id (car active)))
6279 (setq articles (delq id articles))))))
6280 ;; If the read list is nil, we init it.
6282 (null (gnus-info-read info))
6284 (setq ninfo (cons 1 (1- (car active))))
6285 (setq ninfo (gnus-info-read info)))
6286 ;; Then we add the read articles to the range.
6288 ninfo (setq articles (sort articles '<))))))
6290 (defun gnus-group-make-articles-read (group articles)
6291 "Update the info of GROUP to say that ARTICLES are read."
6293 (entry (gnus-group-entry group))
6294 (info (nth 2 entry))
6295 (active (gnus-active group))
6297 (or gnus-propagate-marks
6298 (gnus-method-option-p
6299 (gnus-find-method-for-group group)
6303 ;; Group that Gnus doesn't know exists, but still allow the
6304 ;; backend to set marks.
6306 (gnus-request-set-mark
6307 group (list (list (gnus-compress-sequence (sort articles #'<))
6309 ;; Normal, subscribed groups.
6310 (setq range (gnus-compute-read-articles group articles))
6311 (with-current-buffer gnus-group-buffer
6314 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6315 (gnus-info-set-read ',info ',(gnus-info-read info))
6316 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6318 (gnus-request-set-mark
6319 ,group (list (list ',range 'del '(read)))))
6320 (gnus-group-update-group ,group t))))
6321 ;; Add the read articles to the range.
6322 (gnus-info-set-read info range)
6324 (gnus-request-set-mark group (list (list range 'add '(read)))))
6325 ;; Then we have to re-compute how many unread
6326 ;; articles there are in this group.
6330 (setq num (- (1+ (cdr active)) (car active))))
6331 ((not (listp (cdr range)))
6332 (setq num (- (cdr active) (- (1+ (cdr range))
6336 (if (numberp (car range))
6338 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6339 (setq range (cdr range)))
6340 (setq num (- (cdr active) num))))
6341 ;; Update the number of unread articles.
6343 ;; Update the group buffer.
6344 (unless (gnus-ephemeral-group-p group)
6345 (gnus-group-update-group group t))))))
6347 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6348 (let ((cur nntp-server-buffer)
6351 (with-current-buffer gnus-summary-buffer
6352 gnus-newsgroup-dependencies)))
6353 headers id end ref number
6354 (mail-parse-charset gnus-newsgroup-charset)
6355 (mail-parse-ignored-charsets
6356 (save-current-buffer (condition-case nil
6357 (set-buffer gnus-summary-buffer)
6359 gnus-newsgroup-ignored-charsets)))
6360 (with-current-buffer nntp-server-buffer
6361 ;; Translate all TAB characters into SPACE characters.
6362 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6363 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6364 (ietf-drums-unfold-fws)
6365 (gnus-run-hooks 'gnus-parse-headers-hook)
6366 (let ((case-fold-search t)
6367 in-reply-to header p lines chars)
6368 (goto-char (point-min))
6369 ;; Search to the beginning of the next header. Error messages
6370 ;; do not begin with 2 or 3.
6371 (while (re-search-forward "^[23][0-9]+ " nil t)
6374 ;; This implementation of this function, with nine
6375 ;; search-forwards instead of the one re-search-forward and
6376 ;; a case (which basically was the old function) is actually
6377 ;; about twice as fast, even though it looks messier. You
6378 ;; can't have everything, I guess. Speed and elegance
6379 ;; doesn't always go hand in hand.
6385 (setq number (read cur))
6388 (narrow-to-region (point)
6389 (or (and (search-forward "\n.\n" nil t)
6395 (if (search-forward "\nsubject:" nil t)
6396 (funcall gnus-decode-encoded-word-function
6397 (nnheader-header-value))
6402 (if (search-forward "\nfrom:" nil t)
6403 (funcall gnus-decode-encoded-address-function
6404 (nnheader-header-value))
6409 (if (search-forward "\ndate:" nil t)
6410 (nnheader-header-value) ""))
6414 (setq id (if (re-search-forward
6415 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6416 ;; We do it this way to make sure the Message-ID
6417 ;; is (somewhat) syntactically valid.
6418 (buffer-substring (match-beginning 1)
6420 ;; If there was no message-id, we just fake one
6421 ;; to make subsequent routines simpler.
6422 (nnheader-generate-fake-message-id number))))
6426 (if (search-forward "\nreferences:" nil t)
6430 (nnheader-header-value)
6435 (search-backward ">" end t)
6438 (search-backward "<" end t)
6440 ;; Get the references from the in-reply-to header if there
6441 ;; were no references and the in-reply-to header looks
6443 (if (and (search-forward "\nin-reply-to:" nil t)
6444 (setq in-reply-to (nnheader-header-value))
6445 (string-match "<[^>]+>" in-reply-to))
6447 (setq ref (substring in-reply-to (match-beginning 0)
6449 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6450 (setq ref2 (substring in-reply-to (match-beginning 0)
6452 (when (> (length ref2) (length ref))
6459 (if (search-forward "\nchars: " nil t)
6460 (if (numberp (setq chars (ignore-errors (read cur))))
6466 (if (search-forward "\nlines: " nil t)
6467 (if (numberp (setq lines (ignore-errors (read cur))))
6473 (and (search-forward "\nxref:" nil t)
6474 (nnheader-header-value)))
6476 (when gnus-extra-headers
6477 (let ((extra gnus-extra-headers)
6481 (when (search-forward
6482 (concat "\n" (symbol-name (car extra)) ":") nil t)
6483 (push (cons (car extra) (nnheader-header-value))
6487 (when (equal id ref)
6490 (when gnus-alter-header-function
6491 (funcall gnus-alter-header-function header)
6492 (setq id (mail-header-id header)
6493 ref (gnus-parent-id (mail-header-references header))))
6496 (gnus-dependencies-add-header
6497 header dependencies force-new))
6498 (push header headers))
6499 (goto-char (point-max))
6501 (nreverse headers)))))
6503 ;; Goes through the xover lines and returns a list of vectors
6504 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6505 force-new dependencies
6506 group also-fetch-heads)
6507 "Parse the news overview data in the server buffer.
6508 Return a list of headers that match SEQUENCE (see
6509 `nntp-retrieve-headers')."
6510 ;; Get the Xref when the users reads the articles since most/some
6511 ;; NNTP servers do not include Xrefs when using XOVER.
6512 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6513 (let ((mail-parse-charset gnus-newsgroup-charset)
6514 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6515 (cur nntp-server-buffer)
6516 (dependencies (or dependencies gnus-newsgroup-dependencies))
6518 ((eq gnus-read-all-available-headers t)
6520 ((and (stringp gnus-read-all-available-headers)
6522 (string-match gnus-read-all-available-headers group))
6525 number headers header)
6526 (with-current-buffer nntp-server-buffer
6527 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6528 ;; Allow the user to mangle the headers before parsing them.
6529 (gnus-run-hooks 'gnus-parse-headers-hook)
6530 (goto-char (point-min))
6531 (gnus-parse-without-error
6532 (while (and (or sequence allp)
6534 (setq number (read cur))
6536 (while (and sequence
6537 (< (car sequence) number))
6538 (setq sequence (cdr sequence))))
6541 (eq number (car sequence))))
6543 (setq sequence (cdr sequence))
6544 (setq header (inline
6545 (gnus-nov-parse-line
6546 number dependencies force-new)))))
6547 (push header headers))
6549 ;; A common bug in inn is that if you have posted an article and
6550 ;; then retrieves the active file, it will answer correctly --
6551 ;; the new article is included. However, a NOV entry for the
6552 ;; article may not have been generated yet, so this may fail.
6553 ;; We work around this problem by retrieving the last few
6554 ;; headers using HEAD.
6555 (if (or (not also-fetch-heads)
6557 ;; We (probably) got all the headers.
6559 (let ((gnus-nov-is-evil t))
6562 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6563 (gnus-get-newsgroup-headers))))))))
6565 (defun gnus-article-get-xrefs ()
6566 "Fill in the Xref value in `gnus-current-headers', if necessary.
6567 This is meant to be called in `gnus-article-internal-prepare-hook'."
6568 (let ((headers (with-current-buffer gnus-summary-buffer
6569 gnus-current-headers)))
6570 (or (not gnus-use-cross-reference)
6572 (and (mail-header-xref headers)
6573 (not (string= (mail-header-xref headers) "")))
6574 (let ((case-fold-search t)
6577 (nnheader-narrow-to-headers)
6578 (goto-char (point-min))
6579 (when (or (and (not (eobp))
6580 (eq (downcase (char-after)) ?x)
6581 (looking-at "Xref:"))
6582 (search-forward "\nXref:" nil t))
6583 (goto-char (1+ (match-end 0)))
6584 (setq xref (buffer-substring (point) (point-at-eol)))
6585 (mail-header-set-xref headers xref)))))))
6587 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6588 "Find article ID and insert the summary line for that article.
6589 OLD-HEADER can either be a header or a line number to insert
6590 the subject line on.
6591 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6592 and OLD-HEADER will be used when the summary line is inserted,
6593 too, instead of trying to fetch new headers."
6594 (let* ((line (and (numberp old-header) old-header))
6595 (old-header (and (vectorp old-header) old-header))
6596 (header (cond ((and old-header use-old-header)
6599 (gnus-number-to-header id))
6600 (gnus-number-to-header id))
6602 (gnus-read-header id))))
6603 (number (and (numberp id) id))
6606 ;; Rebuild the thread that this article is part of and go to the
6607 ;; article we have fetched.
6608 (when (and (not gnus-show-threads)
6611 (setq d (gnus-data-find (mail-header-number old-header))))
6612 (goto-char (gnus-data-pos d))
6618 (gnus-delete-line))))))
6619 ;; Remove list identifiers from subject.
6620 (let ((gnus-newsgroup-headers (list header)))
6621 (gnus-summary-remove-list-identifiers))
6623 (mail-header-set-number header (mail-header-number old-header)))
6624 (setq gnus-newsgroup-sparse
6625 (delq (setq number (mail-header-number header))
6626 gnus-newsgroup-sparse))
6627 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6628 (push number gnus-newsgroup-limit)
6629 (gnus-rebuild-thread (mail-header-id header) line)
6630 (gnus-summary-goto-subject number nil t))
6631 (when (and (numberp number)
6633 ;; We have to update the boundaries even if we can't fetch the
6634 ;; article if ID is a number -- so that the next `P' or `N'
6635 ;; command will fetch the previous (or next) article even
6636 ;; if the one we tried to fetch this time has been canceled.
6637 (when (> number gnus-newsgroup-end)
6638 (setq gnus-newsgroup-end number))
6639 (when (< number gnus-newsgroup-begin)
6640 (setq gnus-newsgroup-begin number))
6641 (setq gnus-newsgroup-unselected
6642 (delq number gnus-newsgroup-unselected)))
6643 ;; Report back a success?
6644 (and header (mail-header-number header))))
6646 ;;; Process/prefix in the summary buffer
6648 (defun gnus-summary-work-articles (n)
6649 "Return a list of articles to be worked upon.
6650 The prefix argument, the list of process marked articles, and the
6651 current article will be taken into consideration."
6652 (with-current-buffer gnus-summary-buffer
6655 ;; A numerical prefix has been given.
6656 (setq n (prefix-numeric-value n))
6657 (let ((backward (< n 0))
6658 (n (abs (prefix-numeric-value n)))
6663 (push (setq article (gnus-summary-article-number))
6666 (gnus-summary-find-prev nil article)
6667 (gnus-summary-find-next nil article)))
6669 (nreverse articles)))
6670 ((and (gnus-region-active-p) (mark))
6671 (message "region active")
6672 ;; Work on the region between point and mark.
6673 (let ((max (max (point) (mark)))
6676 (goto-char (min (point) (mark)))
6679 (push (setq article (gnus-summary-article-number)) articles)
6680 (gnus-summary-find-next nil article)
6682 (nreverse articles))))
6683 (gnus-newsgroup-processable
6684 ;; There are process-marked articles present.
6685 ;; Save current state.
6686 (gnus-summary-save-process-mark)
6688 (reverse gnus-newsgroup-processable))
6690 ;; Just return the current article.
6691 (list (gnus-summary-article-number))))))
6693 (defmacro gnus-summary-iterate (arg &rest forms)
6694 "Iterate over the process/prefixed articles and do FORMS.
6695 ARG is the interactive prefix given to the command. FORMS will be
6696 executed with point over the summary line of the articles."
6697 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6698 `(let ((,articles (gnus-summary-work-articles ,arg)))
6700 (gnus-summary-goto-subject (car ,articles))
6704 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6705 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6707 (defun gnus-summary-save-process-mark ()
6708 "Push the current set of process marked articles on the stack."
6710 (push (copy-sequence gnus-newsgroup-processable)
6711 gnus-newsgroup-process-stack))
6713 (defun gnus-summary-kill-process-mark ()
6714 "Push the current set of process marked articles on the stack and unmark."
6716 (gnus-summary-save-process-mark)
6717 (gnus-summary-unmark-all-processable))
6719 (defun gnus-summary-yank-process-mark ()
6720 "Pop the last process mark state off the stack and restore it."
6722 (unless gnus-newsgroup-process-stack
6723 (error "Empty mark stack"))
6724 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6726 (defun gnus-summary-process-mark-set (set)
6727 "Make SET into the current process marked articles."
6728 (gnus-summary-unmark-all-processable)
6729 (mapc 'gnus-summary-set-process-mark set))
6731 ;;; Searching and stuff
6733 (defun gnus-summary-search-group (&optional backward use-level)
6734 "Search for next unread newsgroup.
6735 If optional argument BACKWARD is non-nil, search backward instead."
6736 (with-current-buffer gnus-group-buffer
6737 (when (gnus-group-search-forward
6738 backward nil (if use-level (gnus-group-group-level) nil))
6739 (gnus-group-group-name))))
6741 (defun gnus-summary-best-group (&optional exclude-group)
6742 "Find the name of the best unread group.
6743 If EXCLUDE-GROUP, do not go to this group."
6744 (with-current-buffer gnus-group-buffer
6746 (gnus-group-best-unread-group exclude-group))))
6748 (defun gnus-summary-find-next (&optional unread article backward)
6750 (gnus-summary-find-prev unread article)
6751 (let* ((dummy (gnus-summary-article-intangible-p))
6752 (article (or article (gnus-summary-article-number)))
6753 (data (gnus-data-find-list article))
6755 (when (and (not dummy)
6756 (or (not gnus-summary-check-current)
6758 (not (gnus-data-unread-p (car data)))))
6759 (setq data (cdr data)))
6764 (unless (memq (gnus-data-number (car data))
6766 ((eq gnus-auto-goto-ignores
6767 'always-undownloaded)
6768 gnus-newsgroup-undownloaded)
6771 ((eq gnus-auto-goto-ignores
6773 gnus-newsgroup-unfetched)
6774 ((eq gnus-auto-goto-ignores
6776 gnus-newsgroup-undownloaded)))
6777 (when (gnus-data-unread-p (car data))
6778 (setq result (car data)
6780 (setq data (cdr data)))
6783 (goto-char (gnus-data-pos result))
6784 (gnus-data-number result)))))
6786 (defun gnus-summary-find-prev (&optional unread article)
6787 (let* ((eobp (eobp))
6788 (article (or article (gnus-summary-article-number)))
6789 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6791 (when (and (not eobp)
6792 (or (not gnus-summary-check-current)
6794 (not (gnus-data-unread-p (car data)))))
6795 (setq data (cdr data)))
6800 (unless (memq (gnus-data-number (car data))
6802 ((eq gnus-auto-goto-ignores
6803 'always-undownloaded)
6804 gnus-newsgroup-undownloaded)
6807 ((eq gnus-auto-goto-ignores
6809 gnus-newsgroup-unfetched)
6810 ((eq gnus-auto-goto-ignores
6812 gnus-newsgroup-undownloaded)))
6813 (when (gnus-data-unread-p (car data))
6814 (setq result (car data)
6816 (setq data (cdr data)))
6819 (goto-char (gnus-data-pos result))
6820 (gnus-data-number result))))
6822 (defun gnus-summary-find-subject (subject &optional unread backward article)
6823 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6824 (article (or article (gnus-summary-article-number)))
6825 (articles (gnus-data-list backward))
6826 (arts (gnus-data-find-list article articles))
6828 (when (or (not gnus-summary-check-current)
6830 (not (gnus-data-unread-p (car arts))))
6831 (setq arts (cdr arts)))
6833 (and (or (not unread)
6834 (gnus-data-unread-p (car arts)))
6835 (vectorp (gnus-data-header (car arts)))
6837 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6838 (setq result (car arts)
6840 (setq arts (cdr arts)))
6842 (goto-char (gnus-data-pos result))
6843 (gnus-data-number result))))
6845 (defun gnus-summary-search-forward (&optional unread subject backward)
6846 "Search forward for an article.
6847 If UNREAD, look for unread articles. If SUBJECT, look for
6848 articles with that subject. If BACKWARD, search backward instead."
6849 (cond (subject (gnus-summary-find-subject subject unread backward))
6850 (backward (gnus-summary-find-prev unread))
6851 (t (gnus-summary-find-next unread))))
6853 (defun gnus-recenter (&optional n)
6854 "Center point in window and redisplay frame.
6855 Also do horizontal recentering."
6857 (when (and gnus-auto-center-summary
6858 (not (eq gnus-auto-center-summary 'vertical)))
6859 (gnus-horizontal-recenter))
6860 (if (fboundp 'recenter-top-bottom)
6861 (recenter-top-bottom n)
6864 (put 'gnus-recenter 'isearch-scroll t)
6866 (defun gnus-forward-line-ignore-invisible (n)
6867 "Move N lines forward (backward if N is negative).
6868 Like forward-line, but skip over (and don't count) invisible lines."
6870 (while (and (> n 0) (not done))
6871 ;; If the following character is currently invisible,
6872 ;; skip all characters with that same `invisible' property value.
6873 (while (gnus-invisible-p (point))
6874 (goto-char (gnus-next-char-property-change (point))))
6879 (while (and (< n 0) (not done))
6881 (if (bobp) (setq done t)
6883 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6884 (goto-char (gnus-previous-char-property-change (point))))))))
6886 (defun gnus-summary-recenter ()
6887 "Center point in the summary window.
6888 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6889 displayed, no centering will be performed."
6890 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6891 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6893 ;; The user has to want it.
6894 (when gnus-auto-center-summary
6895 (let* ((top (cond ((< (window-height) 4) 0)
6896 ((< (window-height) 7) 1)
6897 (t (if (numberp gnus-auto-center-summary)
6898 gnus-auto-center-summary
6899 (/ (1- (window-height)) 2)))))
6900 (height (1- (window-height)))
6901 (bottom (save-excursion
6902 (goto-char (point-max))
6903 (gnus-forward-line-ignore-invisible (- height))
6905 (window (get-buffer-window (current-buffer))))
6906 (when (get-buffer-window gnus-article-buffer)
6907 ;; Only do recentering when the article buffer is displayed,
6908 ;; Set the window start to either `bottom', which is the biggest
6909 ;; possible valid number, or the second line from the top,
6910 ;; whichever is the least.
6911 (let ((top-pos (save-excursion
6912 (gnus-forward-line-ignore-invisible (- top))
6914 (if (> bottom top-pos)
6915 ;; Keep the second line from the top visible
6916 (set-window-start window top-pos)
6917 ;; Try to keep the bottom line visible; if it's partially
6918 ;; obscured, either scroll one more line to make it fully
6919 ;; visible, or revert to using TOP-POS.
6921 (goto-char (point-max))
6922 (gnus-forward-line-ignore-invisible -1)
6923 (let ((last-line-start (point)))
6925 (set-window-start window (point) t)
6926 (when (not (pos-visible-in-window-p last-line-start window))
6927 (gnus-forward-line-ignore-invisible 1)
6928 (set-window-start window (min (point) top-pos) t)))))))
6929 ;; Do horizontal recentering while we're at it.
6930 (when (and (get-buffer-window (current-buffer) t)
6931 (not (eq gnus-auto-center-summary 'vertical)))
6932 (let ((selected (selected-window)))
6933 (select-window (get-buffer-window (current-buffer) t))
6934 (gnus-summary-position-point)
6935 (gnus-horizontal-recenter)
6936 (select-window selected))))))
6938 (defun gnus-summary-jump-to-group (newsgroup)
6939 "Move point to NEWSGROUP in group mode buffer."
6940 ;; Keep update point of group mode buffer if visible.
6941 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6942 (save-window-excursion
6943 ;; Take care of tree window mode.
6944 (when (get-buffer-window gnus-group-buffer)
6945 (pop-to-buffer gnus-group-buffer))
6946 (gnus-group-jump-to-group newsgroup))
6948 ;; Take care of tree window mode.
6949 (if (get-buffer-window gnus-group-buffer 0)
6950 (pop-to-buffer gnus-group-buffer)
6951 (set-buffer gnus-group-buffer))
6952 (gnus-group-jump-to-group newsgroup))))
6954 ;; This function returns a list of article numbers based on the
6955 ;; difference between the ranges of read articles in this group and
6956 ;; the range of active articles.
6957 (defun gnus-list-of-unread-articles (group)
6958 (let* ((read (gnus-info-read (gnus-get-info group)))
6959 (active (or (gnus-active group) (gnus-activate-group group)))
6960 (last (or (cdr active)
6961 (error "Group %s couldn't be activated " group)))
6962 (bottom (if gnus-newsgroup-maximum-articles
6964 (- last gnus-newsgroup-maximum-articles -1))
6967 ;; If none are read, then all are unread.
6970 ;; If the range of read articles is a single range, then the
6971 ;; first unread article is the article after the last read
6972 ;; article. Sounds logical, doesn't it?
6973 (if (and (not (listp (cdr read)))
6974 (or (< (car read) bottom)
6975 (progn (setq read (list read))
6977 (setq first (max bottom (1+ (cdr read))))
6978 ;; `read' is a list of ranges.
6979 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6982 (setq first bottom))
6985 (while (< first nlast)
6986 (setq unread (cons first unread)
6988 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6989 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6990 (setq read (cdr read)))))
6991 ;; And add the last unread articles.
6992 (while (<= first last)
6993 (setq unread (cons first unread)
6995 ;; Return the list of unread articles.
6996 (delq 0 (nreverse unread))))
6998 (defun gnus-list-of-read-articles (group)
6999 "Return a list of unread, unticked and non-dormant articles."
7000 (let* ((info (gnus-get-info group))
7001 (marked (gnus-info-marks info))
7002 (active (gnus-active group)))
7004 (gnus-list-range-difference
7005 (gnus-list-range-difference
7006 (gnus-sorted-complement
7007 (gnus-uncompress-range
7008 (if gnus-newsgroup-maximum-articles
7009 (cons (max (car active)
7011 gnus-newsgroup-maximum-articles
7015 (gnus-list-of-unread-articles group))
7016 (cdr (assq 'dormant marked)))
7017 (cdr (assq 'tick marked))))))
7019 ;; This function returns a sequence of article numbers based on the
7020 ;; difference between the ranges of read articles in this group and
7021 ;; the range of active articles.
7022 (defun gnus-sequence-of-unread-articles (group)
7023 (let* ((read (gnus-info-read (gnus-get-info group)))
7024 (active (or (gnus-active group) (gnus-activate-group group)))
7026 (bottom (if gnus-newsgroup-maximum-articles
7028 (- last gnus-newsgroup-maximum-articles -1))
7031 ;; If none are read, then all are unread.
7034 ;; If the range of read articles is a single range, then the
7035 ;; first unread article is the article after the last read
7036 ;; article. Sounds logical, doesn't it?
7037 (if (and (not (listp (cdr read)))
7038 (or (< (car read) bottom)
7039 (progn (setq read (list read))
7041 (setq first (max bottom (1+ (cdr read))))
7042 ;; `read' is a list of ranges.
7043 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7046 (setq first bottom))
7049 (push (cons first nlast) unread))
7050 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7051 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7052 (setq read (cdr read)))))
7053 ;; And add the last unread articles.
7054 (cond ((not (and first last))
7057 (push (cons first last) unread))
7059 (push first unread)))
7060 ;; Return the sequence of unread articles.
7061 (delq 0 (nreverse unread))))
7063 ;; Various summary commands
7065 (defun gnus-summary-select-article-buffer ()
7066 "Reconfigure windows to show the article buffer.
7067 If `gnus-widen-article-window' is set, show only the article
7070 (if (not (gnus-buffer-live-p gnus-article-buffer))
7071 (error "There is no article buffer for this summary buffer")
7072 (unless (get-buffer-window gnus-article-buffer)
7073 (gnus-summary-show-article))
7074 (gnus-configure-windows
7075 (if gnus-widen-article-window
7079 (select-window (get-buffer-window gnus-article-buffer))))
7081 (defun gnus-summary-universal-argument (arg)
7082 "Perform any operation on all articles that are process/prefixed."
7084 (let ((articles (gnus-summary-work-articles arg))
7091 (substitute-command-keys
7092 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7094 (gnus-error 1 "Undefined key")
7097 (gnus-summary-goto-subject (setq article (pop articles)))
7098 (let (gnus-newsgroup-processable)
7099 (command-execute func))
7100 (gnus-summary-remove-process-mark article)))))
7101 (gnus-summary-position-point))
7103 (defun gnus-summary-toggle-truncation (&optional arg)
7104 "Toggle truncation of summary lines.
7105 With ARG, turn line truncation on if ARG is positive."
7107 (setq truncate-lines
7108 (if (null arg) (not truncate-lines)
7109 (> (prefix-numeric-value arg) 0)))
7112 (defun gnus-summary-find-for-reselect ()
7113 "Return the number of an article to stay on across a reselect.
7114 The current article is considered, then following articles, then previous
7115 articles. An article is sought which is not canceled and isn't a temporary
7116 insertion from another group. If there's no such then return a dummy 0."
7118 (dolist (rev '(nil t))
7119 (unless found ; don't demand the reverse list if we don't need it
7120 (let ((data (gnus-data-find-list
7121 (gnus-summary-article-number) (gnus-data-list rev))))
7122 (while (and data (not found))
7123 (if (and (< 0 (gnus-data-number (car data)))
7124 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7125 (setq found (gnus-data-number (car data))))
7126 (setq data (cdr data))))))
7129 (defun gnus-summary-reselect-current-group (&optional all rescan)
7130 "Exit and then reselect the current newsgroup.
7131 The prefix argument ALL means to select all articles."
7133 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7134 (error "Ephemeral groups can't be reselected"))
7135 (let ((current-subject (gnus-summary-find-for-reselect))
7136 (group gnus-newsgroup-name))
7137 (setq gnus-newsgroup-begin nil)
7138 (gnus-summary-exit nil 'leave-hidden)
7139 ;; We have to adjust the point of group mode buffer because
7140 ;; point was moved to the next unread newsgroup by exiting.
7141 (gnus-summary-jump-to-group group)
7144 (gnus-group-get-new-news-this-group 1)))
7145 (gnus-group-read-group all t)
7146 (gnus-summary-goto-subject current-subject nil t)))
7148 (defun gnus-summary-rescan-group (&optional all)
7149 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7151 (let ((config gnus-current-window-configuration))
7152 (gnus-summary-reselect-current-group all t)
7153 (gnus-configure-windows config)
7154 (when (eq config 'article)
7155 (gnus-summary-select-article))))
7157 (defun gnus-summary-update-info (&optional non-destructive)
7159 (let ((group gnus-newsgroup-name))
7161 (when gnus-newsgroup-kill-headers
7162 (setq gnus-newsgroup-killed
7163 (gnus-compress-sequence
7165 (gnus-list-range-intersection
7166 gnus-newsgroup-unselected gnus-newsgroup-killed)
7167 gnus-newsgroup-unreads)
7169 (unless (listp (cdr gnus-newsgroup-killed))
7170 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7171 (let ((headers gnus-newsgroup-headers)
7172 (ephemeral-p (gnus-ephemeral-group-p group))
7175 (setq info (copy-sequence (gnus-get-info group))
7176 info (delq (gnus-info-params info) info)))
7177 ;; Set the new ranges of read articles.
7178 (with-current-buffer gnus-group-buffer
7179 (gnus-undo-force-boundary))
7180 (gnus-update-read-articles
7181 group (gnus-sorted-union
7182 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7183 ;; Set the current article marks.
7184 (let ((gnus-newsgroup-scored
7185 (if (and (not gnus-save-score)
7186 (not non-destructive))
7188 gnus-newsgroup-scored)))
7190 (gnus-update-marks)))
7191 ;; Do the cross-ref thing.
7192 (when gnus-use-cross-reference
7193 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7194 ;; Do not switch windows but change the buffer to work.
7195 (set-buffer gnus-group-buffer)
7197 (gnus-group-update-group
7200 (setq info (copy-sequence (gnus-get-info group))
7201 info (delq (gnus-info-params info) info))))))))))
7203 (defun gnus-summary-save-newsrc (&optional force)
7204 "Save the current number of read/marked articles in the dribble buffer.
7205 The dribble buffer will then be saved.
7206 If FORCE (the prefix), also save the .newsrc file(s)."
7208 (gnus-summary-update-info t)
7210 (gnus-save-newsrc-file)
7211 (gnus-dribble-save)))
7213 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7215 (defun gnus-summary-exit (&optional temporary leave-hidden)
7216 "Exit reading current newsgroup, and then return to group selection mode.
7217 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7219 (gnus-set-global-variables)
7220 (when (gnus-buffer-live-p gnus-article-buffer)
7221 (with-current-buffer gnus-article-buffer
7222 (mm-destroy-parts gnus-article-mime-handles)
7223 ;; Set it to nil for safety reason.
7224 (setq gnus-article-mime-handle-alist nil)
7225 (setq gnus-article-mime-handles nil)))
7226 (gnus-kill-save-kill-buffer)
7227 (gnus-async-halt-prefetch)
7228 (let* ((group gnus-newsgroup-name)
7229 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7230 (gnus-group-is-exiting-p t)
7231 (article-buffer gnus-article-buffer)
7232 (original-article-buffer gnus-original-article-buffer)
7235 (buf (current-buffer))
7236 ;; `gnus-single-article-buffer' is nil buffer-locally in
7237 ;; ephemeral group of which summary buffer will be killed,
7238 ;; but the global value may be non-nil.
7239 (single-article-buffer gnus-single-article-buffer))
7241 ;; Do adaptive scoring, and possibly save score files.
7242 (when gnus-newsgroup-adaptive
7243 (gnus-score-adaptive))
7244 (when gnus-use-scoring
7246 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7247 (when gnus-use-cache
7248 (gnus-cache-possibly-remove-articles)
7249 (gnus-cache-save-buffers))
7250 (gnus-async-prefetch-remove-group group)
7251 (when gnus-suppress-duplicates
7252 (gnus-dup-enter-articles))
7253 (when gnus-use-trees
7254 (gnus-tree-close group))
7255 (when gnus-use-cache
7256 (gnus-cache-write-active))
7257 ;; Remove entries for this group.
7258 (nnmail-purge-split-history (gnus-group-real-name group))
7259 ;; Make all changes in this group permanent.
7261 (gnus-run-hooks 'gnus-exit-group-hook)
7262 (gnus-summary-update-info))
7263 (gnus-close-group group)
7264 ;; Make sure where we were, and go to next newsgroup.
7265 (set-buffer gnus-group-buffer)
7267 (gnus-group-jump-to-group group))
7268 (gnus-run-hooks 'gnus-summary-exit-hook)
7269 (unless (or quit-config
7270 (not gnus-summary-next-group-on-exit)
7271 ;; If this group has disappeared from the summary
7272 ;; buffer, don't skip forwards.
7273 (not (string= group (gnus-group-group-name))))
7274 (gnus-group-next-unread-group 1))
7275 (setq group-point (point))
7279 (if (not gnus-kill-summary-on-exit)
7281 (gnus-deaden-summary)
7283 (when (get-buffer gnus-article-buffer)
7284 (bury-buffer gnus-article-buffer))
7285 ;; Return to group mode buffer.
7286 (when (eq mode 'gnus-summary-mode)
7287 (gnus-kill-buffer buf)))
7289 (setq gnus-current-select-method gnus-select-method)
7290 (set-buffer gnus-group-buffer)
7292 (gnus-handle-ephemeral-exit quit-config)
7293 (goto-char group-point)
7294 ;; If gnus-group-buffer is already displayed, make sure we also move
7295 ;; the cursor in the window that displays it.
7296 (let ((win (get-buffer-window (current-buffer) 0)))
7297 (if win (set-window-point win (point))))
7298 (unless leave-hidden
7299 (gnus-configure-windows 'group 'force)))
7301 ;; If we have several article buffers, we kill them at exit.
7302 (unless single-article-buffer
7303 (when (gnus-buffer-live-p article-buffer)
7304 (with-current-buffer article-buffer
7305 ;; Don't kill sticky article buffers
7306 (unless (eq major-mode 'gnus-sticky-article-mode)
7307 (gnus-kill-buffer article-buffer)
7308 (setq gnus-article-current nil))))
7309 (gnus-kill-buffer original-article-buffer))
7311 ;; Clear the current group name.
7313 (setq gnus-newsgroup-name nil)))))
7315 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7316 (defun gnus-summary-exit-no-update (&optional no-questions)
7317 "Quit reading current newsgroup without updating read article info."
7319 (let* ((group gnus-newsgroup-name)
7320 (gnus-group-is-exiting-p t)
7321 (gnus-group-is-exiting-without-update-p t)
7322 (quit-config (gnus-group-quit-config group)))
7323 (when (or no-questions
7325 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7326 (gnus-async-halt-prefetch)
7327 (run-hooks 'gnus-summary-prepare-exit-hook)
7328 (when (gnus-buffer-live-p gnus-article-buffer)
7329 (with-current-buffer gnus-article-buffer
7330 (gnus-article-stop-animations)
7331 (gnus-stop-downloads)
7332 (mm-destroy-parts gnus-article-mime-handles)
7333 ;; Set it to nil for safety reason.
7334 (setq gnus-article-mime-handle-alist nil)
7335 (setq gnus-article-mime-handles nil)))
7336 ;; If we have several article buffers, we kill them at exit.
7337 (unless gnus-single-article-buffer
7338 (gnus-kill-buffer gnus-article-buffer)
7339 (gnus-kill-buffer gnus-original-article-buffer)
7340 (setq gnus-article-current nil))
7341 ;; Return to the group buffer.
7342 (if (not gnus-kill-summary-on-exit)
7344 (gnus-deaden-summary)
7345 (gnus-configure-windows 'group 'force))
7346 (gnus-configure-windows 'group 'force)
7347 (gnus-close-group group)
7348 (gnus-kill-buffer gnus-summary-buffer))
7349 (unless gnus-single-article-buffer
7350 (setq gnus-article-current nil))
7351 (when gnus-use-trees
7352 (gnus-tree-close group))
7353 (gnus-async-prefetch-remove-group group)
7354 (when (get-buffer gnus-article-buffer)
7355 (bury-buffer gnus-article-buffer))
7356 ;; Clear the current group name.
7357 (setq gnus-newsgroup-name nil)
7358 (unless (gnus-ephemeral-group-p group)
7359 (gnus-group-update-group group nil t))
7360 (when (equal (gnus-group-group-name) group)
7361 (gnus-group-next-unread-group 1))
7363 (gnus-handle-ephemeral-exit quit-config)))))
7365 (defun gnus-handle-ephemeral-exit (quit-config)
7366 "Handle movement when leaving an ephemeral group.
7367 The state which existed when entering the ephemeral is reset."
7368 (if (not (buffer-live-p (car quit-config)))
7369 (gnus-configure-windows 'group 'force)
7370 (set-buffer (car quit-config))
7371 (unless (eq (cdr quit-config) 'group)
7372 (setq gnus-current-select-method
7373 (gnus-find-method-for-group gnus-newsgroup-name)))
7374 (cond ((eq major-mode 'gnus-summary-mode)
7375 (gnus-set-global-variables))
7376 ((eq major-mode 'gnus-article-mode)
7377 (save-current-buffer
7378 ;; The `gnus-summary-buffer' variable may point
7379 ;; to the old summary buffer when using a single
7381 (unless (gnus-buffer-live-p gnus-summary-buffer)
7382 (set-buffer gnus-group-buffer))
7383 (set-buffer gnus-summary-buffer)
7384 (gnus-set-global-variables))))
7385 (if (or (eq (cdr quit-config) 'article)
7386 (eq (cdr quit-config) 'pick))
7387 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7388 (gnus-configure-windows 'pick 'force)
7389 (gnus-configure-windows (cdr quit-config) 'force))
7390 (gnus-configure-windows (cdr quit-config) 'force))
7391 (when (eq major-mode 'gnus-summary-mode)
7392 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7393 next-unread-noselect))
7394 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7396 (gnus-summary-next-subject 1 nil t))
7397 ((eq gnus-auto-select-on-ephemeral-exit
7398 'next-unread-noselect)
7399 (gnus-summary-next-subject 1 t t))))
7400 ;; Hide the article buffer which displays the article different
7401 ;; from the one that the cursor points to in the summary buffer.
7402 (gnus-configure-windows 'summary 'force))
7403 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7404 (gnus-summary-next-subject 1))
7405 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7406 (gnus-summary-next-subject 1 t))))
7407 (gnus-summary-recenter)
7408 (gnus-summary-position-point))))
7412 (defvar gnus-dead-summary-mode-map
7413 (let ((map (make-keymap)))
7414 (suppress-keymap map)
7415 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7416 (dolist (key '("\C-d" "\r" "\177" [delete]))
7417 (define-key map key 'gnus-summary-wake-up-the-dead))
7418 (dolist (key '("q" "Q"))
7419 (define-key map key 'bury-buffer))
7422 (define-minor-mode gnus-dead-summary-mode
7423 "Minor mode for Gnus summary buffers."
7424 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7425 (unless (derived-mode-p 'gnus-summary-mode)
7426 (setq gnus-dead-summary-mode nil)))
7428 (defun gnus-deaden-summary ()
7429 "Make the current summary buffer into a dead summary buffer."
7430 ;; Kill any previous dead summary buffer.
7431 (when (and gnus-dead-summary
7432 (buffer-name gnus-dead-summary))
7433 (with-current-buffer gnus-dead-summary
7434 (when gnus-dead-summary-mode
7435 (kill-buffer (current-buffer)))))
7436 ;; Make this the current dead summary.
7437 (setq gnus-dead-summary (current-buffer))
7438 (gnus-dead-summary-mode 1)
7439 (let ((name (buffer-name)))
7440 (when (string-match "Summary" name)
7442 (concat (substring name 0 (match-beginning 0)) "Dead "
7443 (substring name (match-beginning 0)))
7447 (defun gnus-kill-or-deaden-summary (buffer)
7448 "Kill or deaden the summary BUFFER."
7450 (when (and (buffer-name buffer)
7451 (not gnus-single-article-buffer))
7452 (with-current-buffer buffer
7453 (gnus-kill-buffer gnus-article-buffer)
7454 (gnus-kill-buffer gnus-original-article-buffer)))
7457 (gnus-kill-summary-on-exit
7458 (when (and gnus-use-trees
7459 (gnus-buffer-exists-p buffer))
7460 (with-current-buffer buffer
7461 (gnus-tree-close gnus-newsgroup-name)))
7462 (gnus-kill-buffer buffer))
7463 ;; Deaden the buffer.
7464 ((gnus-buffer-exists-p buffer)
7465 (with-current-buffer buffer
7466 (gnus-deaden-summary))))))
7468 (defun gnus-summary-wake-up-the-dead (&rest args)
7469 "Wake up the dead summary buffer."
7471 (gnus-dead-summary-mode -1)
7472 (let ((name (buffer-name)))
7473 (when (string-match "Dead " name)
7475 (concat (substring name 0 (match-beginning 0))
7476 (substring name (match-end 0)))
7478 (gnus-message 3 "This dead summary is now alive again"))
7480 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7481 (defun gnus-summary-describe-group (&optional force)
7482 "Describe the current newsgroup."
7484 (gnus-group-describe-group force gnus-newsgroup-name))
7486 (defun gnus-summary-describe-briefly ()
7487 "Describe summary mode commands briefly."
7489 (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")))
7491 ;; Walking around group mode buffer from summary mode.
7493 (defun gnus-summary-next-group (&optional no-article target-group backward)
7494 "Exit current newsgroup and then select next unread newsgroup.
7495 If prefix argument NO-ARTICLE is non-nil, no article is selected
7496 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7497 previous group instead."
7499 ;; Stop pre-fetching.
7500 (gnus-async-halt-prefetch)
7501 (let ((current-group gnus-newsgroup-name)
7502 (current-buffer (current-buffer))
7504 ;; First we semi-exit this group to update Xrefs and all variables.
7505 ;; We can't do a real exit, because the window conf must remain
7506 ;; the same in case the user is prompted for info, and we don't
7507 ;; want the window conf to change before that...
7508 (gnus-summary-exit t)
7509 (while (not entered)
7510 ;; Then we find what group we are supposed to enter.
7511 (set-buffer gnus-group-buffer)
7512 (gnus-group-jump-to-group current-group)
7515 (if (eq gnus-keep-same-level 'best)
7516 (gnus-summary-best-group gnus-newsgroup-name)
7517 (gnus-summary-search-group backward gnus-keep-same-level))))
7518 (if (not target-group)
7519 ;; There are no further groups, so we return to the group
7522 (gnus-message 5 "Returning to the group buffer")
7524 (when (gnus-buffer-live-p current-buffer)
7525 (set-buffer current-buffer)
7526 (gnus-summary-exit))
7527 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7528 ;; We try to enter the target group.
7529 (gnus-group-jump-to-group target-group)
7530 (let ((unreads (gnus-group-group-unread)))
7531 (if (and (or (eq t unreads)
7532 (and unreads (not (zerop unreads))))
7533 (gnus-summary-read-group
7534 target-group nil no-article
7535 (and (buffer-name current-buffer) current-buffer)
7538 (setq current-group target-group
7539 target-group nil)))))))
7541 (defun gnus-summary-prev-group (&optional no-article)
7542 "Exit current newsgroup and then select previous unread newsgroup.
7543 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7545 (gnus-summary-next-group no-article nil t))
7547 ;; Walking around summary lines.
7549 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7550 "Go to the first subject satisfying any non-nil constraint.
7551 If UNREAD is non-nil, the article should be unread.
7552 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7553 If UNSEEN is non-nil, the article should be unseen as well as unread.
7554 Returns the article selected or nil if there are no matching articles."
7558 ((null gnus-newsgroup-data)
7559 (gnus-message 3 "No articles in the group")
7561 ;; Pick the first article.
7562 ((not (or unread undownloaded unseen))
7563 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7564 (gnus-data-number (car gnus-newsgroup-data)))
7565 ;; Find the first unread article.
7567 (let ((data gnus-newsgroup-data))
7569 (let ((num (gnus-data-number (car data))))
7570 (or (memq num gnus-newsgroup-unfetched)
7571 (not (or (and unread
7572 (memq num gnus-newsgroup-unreads))
7574 (memq num gnus-newsgroup-undownloaded))
7576 (memq num gnus-newsgroup-unseen)
7577 (memq num gnus-newsgroup-unreads)))))))
7578 (setq data (cdr data)))
7582 (goto-char (gnus-data-pos (car data)))
7583 (gnus-data-number (car data)))
7584 (gnus-message 3 "No more%s articles"
7585 (let* ((r (when unread " unread"))
7586 (d (when undownloaded " undownloaded"))
7587 (s (when unseen " unseen"))
7588 (l (delq nil (list r d s))))
7589 (cond ((= 3 (length l))
7590 (concat r "," d ", or" s))
7592 (concat (car l) ", or" (cadr l)))
7599 (gnus-summary-position-point))))))
7601 (defun gnus-summary-next-subject (n &optional unread dont-display)
7602 "Go to next N'th summary line.
7603 If N is negative, go to the previous N'th subject line.
7604 If UNREAD is non-nil, only unread articles are selected.
7605 The difference between N and the actual number of steps taken is
7608 (let ((backward (< n 0))
7612 (gnus-summary-find-prev unread)
7613 (gnus-summary-find-next unread)))
7614 (unless (zerop (setq n (1- n)))
7615 (gnus-summary-show-thread)))
7617 (gnus-message 7 "No more%s articles"
7618 (if unread " unread" "")))
7619 (unless dont-display
7620 (gnus-summary-recenter)
7621 (gnus-summary-position-point))
7624 (defun gnus-summary-next-unread-subject (n)
7625 "Go to next N'th unread summary line."
7627 (gnus-summary-next-subject n t))
7629 (defun gnus-summary-prev-subject (n &optional unread)
7630 "Go to previous N'th summary line.
7631 If optional argument UNREAD is non-nil, only unread article is selected."
7633 (gnus-summary-next-subject (- n) unread))
7635 (defun gnus-summary-prev-unread-subject (n)
7636 "Go to previous N'th unread summary line."
7638 (gnus-summary-next-subject (- n) t))
7640 (defun gnus-summary-goto-subjects (articles)
7641 "Insert the subject header for ARTICLES in the current buffer."
7643 (dolist (article articles)
7644 (gnus-summary-goto-subject article t)))
7645 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7646 (gnus-summary-position-point))
7648 (defun gnus-summary-goto-subject (article &optional force silent)
7649 "Go to the subject line of ARTICLE.
7650 If FORCE, also allow jumping to articles not currently shown."
7651 (interactive "nArticle number: ")
7652 (unless (numberp article)
7653 (error "Article %s is not a number" article))
7655 (data (gnus-data-find article)))
7656 ;; We read in the article if we have to.
7659 (gnus-summary-insert-subject
7661 (if (or (numberp force) (vectorp force)) force)
7663 (setq data (gnus-data-find article)))
7668 (gnus-message 3 "Can't find article %d" article))
7670 (let ((pt (gnus-data-pos data)))
7672 (gnus-summary-set-article-display-arrow pt))
7673 (gnus-summary-position-point)
7676 ;; Walking around summary lines with displaying articles.
7678 (defun gnus-summary-expand-window (&optional arg)
7679 "Make the summary buffer take up the entire Emacs frame.
7680 Given a prefix, will force an `article' buffer configuration."
7683 (gnus-configure-windows 'article 'force)
7684 (gnus-configure-windows 'summary 'force)))
7686 (defun gnus-summary-display-article (article &optional all-header)
7687 "Display ARTICLE in article buffer."
7688 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7689 (with-current-buffer gnus-article-buffer
7690 (eq major-mode 'gnus-article-mode)))
7691 (gnus-article-setup-buffer))
7692 (gnus-set-global-variables)
7693 (with-current-buffer gnus-article-buffer
7694 (setq gnus-article-charset gnus-newsgroup-charset)
7695 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7696 (mm-enable-multibyte))
7700 (if gnus-summary-display-article-function
7701 (funcall gnus-summary-display-article-function article all-header)
7702 (gnus-article-prepare article all-header))
7703 (gnus-run-hooks 'gnus-select-article-hook)
7704 (when (and gnus-current-article
7705 (not (zerop gnus-current-article)))
7706 (gnus-summary-goto-subject gnus-current-article))
7707 (gnus-summary-recenter)
7708 (when (and gnus-use-trees gnus-show-threads)
7709 (gnus-possibly-generate-tree article)
7710 (gnus-highlight-selected-tree article))
7711 ;; Successfully display article.
7712 (gnus-article-set-window-start
7713 (cdr (assq article gnus-newsgroup-bookmarks))))))
7715 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7716 "Select the current article.
7717 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7718 non-nil, the article will be re-fetched even if it already present in
7719 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7721 ;; Make sure we are in the summary buffer to work around bbdb bug.
7722 (unless (eq major-mode 'gnus-summary-mode)
7723 (set-buffer gnus-summary-buffer))
7724 (let ((article (or article (gnus-summary-article-number)))
7725 (all-headers (not (not all-headers))) ;Must be t or nil.
7726 gnus-summary-display-article-function)
7728 (gnus-summary-article-pseudo-p article)
7729 (error "This is a pseudo-article"))
7730 (with-current-buffer gnus-summary-buffer
7731 (if (or (and gnus-single-article-buffer
7732 (or (null gnus-current-article)
7733 (null gnus-article-current)
7734 (null (get-buffer gnus-article-buffer))
7735 (not (eq article (cdr gnus-article-current)))
7736 (not (equal (car gnus-article-current)
7737 gnus-newsgroup-name))
7738 (not (get-buffer gnus-original-article-buffer))))
7739 (and (not gnus-single-article-buffer)
7740 (or (null gnus-current-article)
7741 (not (get-buffer gnus-original-article-buffer))
7742 (not (eq gnus-current-article article))))
7744 ;; The requested article is different from the current article.
7746 (gnus-summary-display-article article all-headers)
7747 (when (gnus-buffer-live-p gnus-article-buffer)
7748 (with-current-buffer gnus-article-buffer
7749 (if (not gnus-article-decoded-p) ;; a local variable
7750 (mm-disable-multibyte))))
7751 (gnus-article-set-window-start
7752 (cdr (assq article gnus-newsgroup-bookmarks)))
7756 (defun gnus-summary-force-verify-and-decrypt ()
7757 "Display buttons for signed/encrypted parts and verify/decrypt them."
7759 (let ((mm-verify-option 'known)
7760 (mm-decrypt-option 'known)
7761 (gnus-article-emulate-mime t)
7762 (gnus-buttonized-mime-types (append (list "multipart/signed"
7763 "multipart/encrypted")
7764 gnus-buttonized-mime-types)))
7765 (gnus-summary-select-article nil 'force)))
7767 (defun gnus-summary-set-current-mark (&optional current-mark)
7768 "Obsolete function."
7771 (defun gnus-summary-next-article (&optional unread subject backward push)
7772 "Select the next article.
7773 If UNREAD, only unread articles are selected.
7774 If SUBJECT, only articles with SUBJECT are selected.
7775 If BACKWARD, the previous article is selected instead of the next."
7777 ;; Make sure we are in the summary buffer.
7778 (unless (eq major-mode 'gnus-summary-mode)
7779 (set-buffer gnus-summary-buffer))
7781 ;; Is there such an article?
7782 ((and (gnus-summary-search-forward unread subject backward)
7783 (or (gnus-summary-display-article (gnus-summary-article-number))
7784 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7785 (gnus-summary-position-point))
7786 ;; If not, we try the first unread, if that is wanted.
7788 gnus-auto-select-same
7789 (gnus-summary-first-unread-article))
7790 (gnus-summary-position-point)
7791 (gnus-message 6 "Wrapped"))
7792 ;; Try to get next/previous article not displayed in this group.
7793 ((and gnus-auto-extend-newsgroup
7794 (not unread) (not subject))
7795 (gnus-summary-goto-article
7796 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7797 nil (count-lines (point-min) (point))))
7798 ;; Go to next/previous group.
7800 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7801 (gnus-summary-jump-to-group gnus-newsgroup-name))
7802 (let ((cmd (if (featurep 'xemacs)
7804 last-command-event))
7806 (with-current-buffer gnus-group-buffer
7808 (current-summary (current-buffer))
7810 (if (eq gnus-keep-same-level 'best)
7811 (gnus-summary-best-group gnus-newsgroup-name)
7812 (gnus-summary-search-group backward gnus-keep-same-level))))
7813 ;; Select next unread newsgroup automagically.
7815 ((or (not gnus-auto-select-next)
7817 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7818 ((or (eq gnus-auto-select-next 'quietly)
7819 (and (eq gnus-auto-select-next 'slightly-quietly)
7821 (and (eq gnus-auto-select-next 'almost-quietly)
7822 (gnus-summary-last-article-p)))
7824 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7826 (gnus-message 7 "No more%s articles (%s)..."
7827 (if unread " unread" "")
7828 (if group (concat "selecting " group)
7830 (gnus-summary-next-group nil group backward)))
7832 (when (gnus-key-press-event-p last-input-event)
7833 ;; Somehow or other, we may now have selected a different
7834 ;; window. Make point go back to the summary buffer.
7835 (when (eq current-summary (current-buffer))
7836 ;; FIXME: This burps when get-buffer-window returns nil.
7837 (select-window (get-buffer-window current-summary 0)))
7838 (gnus-summary-walk-group-buffer
7839 gnus-newsgroup-name cmd unread backward point))))))))
7841 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7842 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7843 (?\C-p (gnus-group-prev-unread-group 1))))
7844 (cursor-in-echo-area t)
7845 keve key group ended prompt)
7846 (with-current-buffer gnus-group-buffer
7849 (if (eq gnus-keep-same-level 'best)
7850 (gnus-summary-best-group gnus-newsgroup-name)
7851 (gnus-summary-search-group backward gnus-keep-same-level))))
7855 "No more%s articles%s " (if unread " unread" "")
7857 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7858 (format " (Type %s for %s [%s])"
7859 (single-key-description cmd)
7860 (gnus-group-decoded-name group)
7861 (gnus-group-unread group))
7862 (format " (Type %s to exit %s)"
7863 (single-key-description cmd)
7864 (gnus-group-decoded-name gnus-newsgroup-name)))))
7865 ;; Confirm auto selection.
7866 (setq key (car (setq keve (gnus-read-event-char prompt)))
7869 ((assq key keystrokes)
7870 (let ((obuf (current-buffer)))
7871 (switch-to-buffer gnus-group-buffer)
7873 (gnus-group-jump-to-group group))
7874 (eval (cadr (assq key keystrokes)))
7875 (setq group (gnus-group-group-name))
7876 (switch-to-buffer obuf))
7880 (gnus-ephemeral-group-p gnus-newsgroup-name))
7882 (gnus-summary-next-group nil group backward)))
7884 (push (cdr keve) unread-command-events))))))
7886 (defun gnus-summary-next-unread-article ()
7887 "Select unread article after current one."
7889 (gnus-summary-next-article
7890 (or (not (eq gnus-summary-goto-unread 'never))
7891 (gnus-summary-last-article-p (gnus-summary-article-number)))
7892 (and gnus-auto-select-same
7893 (gnus-summary-article-subject))))
7895 (defun gnus-summary-prev-article (&optional unread subject)
7896 "Select the article before the current one.
7897 If UNREAD is non-nil, only unread articles are selected."
7899 (gnus-summary-next-article unread subject t))
7901 (defun gnus-summary-prev-unread-article ()
7902 "Select unread article before current one."
7904 (gnus-summary-prev-article
7905 (or (not (eq gnus-summary-goto-unread 'never))
7906 (gnus-summary-first-article-p (gnus-summary-article-number)))
7907 (and gnus-auto-select-same
7908 (gnus-summary-article-subject))))
7910 (defun gnus-summary-next-page (&optional lines circular stop)
7911 "Show next page of the selected article.
7912 If at the end of the current article, select the next article.
7913 LINES says how many lines should be scrolled up.
7915 If CIRCULAR is non-nil, go to the start of the article instead of
7916 selecting the next article when reaching the end of the current
7919 If STOP is non-nil, just stop when reaching the end of the message.
7921 Also see the variable `gnus-article-skip-boring'."
7923 (setq gnus-summary-buffer (current-buffer))
7924 (gnus-set-global-variables)
7925 (let ((article (gnus-summary-article-number))
7926 (article-window (get-buffer-window gnus-article-buffer t))
7928 ;; If the buffer is empty, we have no article.
7930 (error "No article to select"))
7931 (gnus-configure-windows 'article)
7932 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7933 (if (and (eq gnus-summary-goto-unread 'never)
7934 (not (gnus-summary-last-article-p article)))
7935 (gnus-summary-next-article)
7936 (gnus-summary-next-unread-article))
7937 (if (or (null gnus-current-article)
7938 (null gnus-article-current)
7939 (/= article (cdr gnus-article-current))
7940 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7941 ;; Selected subject is different from current article's.
7942 (gnus-summary-display-article article)
7943 (when article-window
7944 (gnus-eval-in-buffer-window gnus-article-buffer
7945 (setq endp (or (gnus-article-next-page lines)
7946 (gnus-article-only-boring-p))))
7948 (cond ((or stop gnus-summary-stop-at-end-of-message)
7949 (gnus-message 3 "End of message"))
7951 (gnus-summary-beginning-of-article))
7953 (gnus-message 3 "End of message"))
7955 (if (and (eq gnus-summary-goto-unread 'never)
7956 (not (gnus-summary-last-article-p article)))
7957 (gnus-summary-next-article)
7958 (gnus-summary-next-unread-article))))))))
7959 (gnus-summary-recenter)
7960 (gnus-summary-position-point)))
7962 (defun gnus-summary-prev-page (&optional lines move)
7963 "Show previous page of selected article.
7964 Argument LINES specifies lines to be scrolled down.
7965 If MOVE, move to the previous unread article if point is at
7966 the beginning of the buffer."
7968 (let ((article (gnus-summary-article-number))
7969 (article-window (get-buffer-window gnus-article-buffer t))
7971 (gnus-configure-windows 'article)
7972 (if (or (null gnus-current-article)
7973 (null gnus-article-current)
7974 (/= article (cdr gnus-article-current))
7975 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7976 ;; Selected subject is different from current article's.
7977 (gnus-summary-display-article article)
7978 (gnus-summary-recenter)
7979 (when article-window
7980 (gnus-eval-in-buffer-window gnus-article-buffer
7981 (setq endp (gnus-article-prev-page lines)))
7982 (when (and move endp)
7984 (gnus-message 3 "Beginning of message"))
7986 (if (and (eq gnus-summary-goto-unread 'never)
7987 (not (gnus-summary-first-article-p article)))
7988 (gnus-summary-prev-article)
7989 (gnus-summary-prev-unread-article))))))))
7990 (gnus-summary-position-point))
7992 (defun gnus-summary-prev-page-or-article (&optional lines)
7993 "Show previous page of selected article.
7994 Argument LINES specifies lines to be scrolled down.
7995 If at the beginning of the article, go to the next article."
7997 (gnus-summary-prev-page lines t))
7999 (defun gnus-summary-scroll-up (lines)
8000 "Scroll up (or down) one line current article.
8001 Argument LINES specifies lines to be scrolled up (or down if negative).
8002 If no article is selected, then the current article will be selected first."
8004 (gnus-configure-windows 'article)
8005 (gnus-summary-show-thread)
8006 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8007 (gnus-eval-in-buffer-window gnus-article-buffer
8009 (when (gnus-article-next-page lines)
8010 (gnus-message 3 "End of message")))
8012 (gnus-article-prev-page (- lines))))))
8013 (gnus-summary-recenter)
8014 (gnus-summary-position-point))
8016 (defun gnus-summary-scroll-down (lines)
8017 "Scroll down (or up) one line current article.
8018 Argument LINES specifies lines to be scrolled down (or up if negative).
8019 If no article is selected, then the current article will be selected first."
8021 (gnus-summary-scroll-up (- lines)))
8023 (defun gnus-summary-next-same-subject ()
8024 "Select next article which has the same subject as current one."
8026 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8028 (defun gnus-summary-prev-same-subject ()
8029 "Select previous article which has the same subject as current one."
8031 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8033 (defun gnus-summary-next-unread-same-subject ()
8034 "Select next unread article which has the same subject as current one."
8036 (gnus-summary-next-article t (gnus-summary-article-subject)))
8038 (defun gnus-summary-prev-unread-same-subject ()
8039 "Select previous unread article which has the same subject as current one."
8041 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8043 (defun gnus-summary-first-unread-article ()
8044 "Select the first unread article.
8045 Return nil if there are no unread articles."
8048 (when (gnus-summary-first-subject t)
8049 (gnus-summary-show-thread)
8050 (gnus-summary-first-subject t)
8051 (gnus-summary-display-article (gnus-summary-article-number)))
8052 (gnus-summary-position-point)))
8054 (defun gnus-summary-first-unread-subject ()
8055 "Place the point on the subject line of the first unread article.
8056 Return nil if there are no unread articles."
8059 (when (gnus-summary-first-subject t)
8060 (gnus-summary-show-thread)
8061 (gnus-summary-first-subject t))
8062 (gnus-summary-position-point)))
8064 (defun gnus-summary-first-unseen-subject ()
8065 "Place the point on the subject line of the first unseen article.
8066 Return nil if there are no unseen articles."
8069 (when (gnus-summary-first-subject nil nil t)
8070 (gnus-summary-show-thread)
8071 (gnus-summary-first-subject nil nil t))
8072 (gnus-summary-position-point)))
8074 (defun gnus-summary-first-unseen-or-unread-subject ()
8075 "Place the point on the subject line of the first unseen and unread article.
8076 If all article have been seen, on the subject line of the first unread
8080 (unless (when (gnus-summary-first-subject nil nil t)
8081 (gnus-summary-show-thread)
8082 (gnus-summary-first-subject nil nil t))
8083 (when (gnus-summary-first-subject t)
8084 (gnus-summary-show-thread)
8085 (gnus-summary-first-subject t)))
8086 (gnus-summary-position-point)))
8088 (defun gnus-summary-first-article ()
8089 "Select the first article.
8090 Return nil if there are no articles."
8093 (when (gnus-summary-first-subject)
8094 (gnus-summary-show-thread)
8095 (gnus-summary-first-subject)
8096 (gnus-summary-display-article (gnus-summary-article-number)))
8097 (gnus-summary-position-point)))
8099 (defun gnus-summary-best-unread-article (&optional arg)
8100 "Select the unread article with the highest score.
8101 If given a prefix argument, select the next unread article that has a
8102 score higher than the default score."
8104 (let ((article (if arg
8105 (gnus-summary-better-unread-subject)
8106 (gnus-summary-best-unread-subject))))
8108 (gnus-summary-goto-article article)
8109 (error "No unread articles"))))
8111 (defun gnus-summary-best-unread-subject ()
8112 "Select the unread subject with the highest score."
8114 (let ((best -1000000)
8115 (data gnus-newsgroup-data)
8118 (and (gnus-data-unread-p (car data))
8120 (gnus-summary-article-score (gnus-data-number (car data))))
8123 article (gnus-data-number (car data))))
8124 (setq data (cdr data)))
8126 (gnus-summary-goto-subject article))
8127 (gnus-summary-position-point)
8130 (defun gnus-summary-better-unread-subject ()
8131 "Select the first unread subject that has a score over the default score."
8133 (let ((data gnus-newsgroup-data)
8135 (while (and (setq article (gnus-data-number (car data)))
8136 (or (gnus-data-read-p (car data))
8137 (not (> (gnus-summary-article-score article)
8138 gnus-summary-default-score))))
8139 (setq data (cdr data)))
8141 (gnus-summary-goto-subject article))
8142 (gnus-summary-position-point)
8145 (defun gnus-summary-last-subject ()
8146 "Go to the last displayed subject line in the group."
8147 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8149 (gnus-summary-goto-subject article))))
8151 (defun gnus-summary-goto-article (article &optional all-headers force)
8152 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8153 If ALL-HEADERS is non-nil, no header lines are hidden.
8154 If FORCE, go to the article even if it isn't displayed. If FORCE
8155 is a number, it is the line the article is to be displayed on."
8158 (gnus-completing-read
8159 "Article number or Message-ID"
8160 (mapcar 'int-to-string gnus-newsgroup-limit))
8164 (if (and (stringp article)
8165 (string-match "@\\|%40" article))
8166 (gnus-summary-refer-article article)
8167 (when (stringp article)
8168 (setq article (string-to-number article)))
8169 (if (gnus-summary-goto-subject article force)
8170 (gnus-summary-display-article article all-headers)
8171 (gnus-message 4 "Couldn't go to article %s" article) nil))
8172 (gnus-summary-position-point)))
8174 (defun gnus-summary-goto-last-article ()
8175 "Go to the previously read article."
8178 (when gnus-last-article
8179 (gnus-summary-goto-article gnus-last-article nil t))
8180 (gnus-summary-position-point)))
8182 (defun gnus-summary-pop-article (number)
8183 "Pop one article off the history and go to the previous.
8184 NUMBER articles will be popped off."
8187 (setq gnus-newsgroup-history
8188 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8190 (gnus-summary-goto-article (car to) nil t)
8191 (error "Article history empty")))
8192 (gnus-summary-position-point))
8194 ;; Summary commands and functions for limiting the summary buffer.
8196 (defun gnus-summary-limit-to-articles (n)
8197 "Limit the summary buffer to the next N articles.
8198 If not given a prefix, use the process marked articles instead."
8201 (let ((articles (gnus-summary-work-articles n)))
8202 (setq gnus-newsgroup-processable nil)
8203 (gnus-summary-limit articles))
8204 (gnus-summary-position-point)))
8206 (defun gnus-summary-pop-limit (&optional total)
8207 "Restore the previous limit.
8208 If given a prefix, remove all limits."
8211 (setq gnus-newsgroup-limits
8212 (list (mapcar (lambda (h) (mail-header-number h))
8213 gnus-newsgroup-headers))))
8214 (unless gnus-newsgroup-limits
8215 (error "No limit to pop"))
8217 (gnus-summary-limit nil 'pop)
8218 (gnus-summary-position-point)))
8220 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8221 "Limit the summary buffer to articles that have subjects that match a regexp.
8222 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8224 (list (read-string (if current-prefix-arg
8225 "Exclude subject (regexp): "
8226 "Limit to subject (regexp): "))
8227 nil current-prefix-arg))
8229 (setq header "subject"))
8230 (when (not (equal "" subject))
8232 (let ((articles (gnus-summary-find-matching
8233 (or header "subject") subject 'all nil nil
8236 (error "Found no matches for \"%s\"" subject))
8237 (gnus-summary-limit articles))
8238 (gnus-summary-position-point))))
8240 (defun gnus-summary-limit-to-author (from &optional not-matching)
8241 "Limit the summary buffer to articles that have authors that match a regexp.
8242 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8244 (list (read-string (if current-prefix-arg
8245 "Exclude author (regexp): "
8246 "Limit to author (regexp): "))
8247 current-prefix-arg))
8248 (gnus-summary-limit-to-subject from "from" not-matching))
8250 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8251 "Limit the summary buffer to articles with the given RECIPIENT.
8253 If NOT-MATCHING, exclude RECIPIENT.
8255 To and Cc headers are checked. You need to include them in
8256 `nnmail-extra-headers'."
8257 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8259 (list (read-string (format "%s recipient (regexp): "
8260 (if current-prefix-arg "Exclude" "Limit to")))
8261 current-prefix-arg))
8262 (when (not (equal "" recipient))
8264 (if (memq 'To nnmail-extra-headers)
8265 (gnus-summary-find-matching
8266 (cons 'extra 'To) recipient 'all nil nil
8269 1 "`To' isn't present in `nnmail-extra-headers'")
8273 (if (memq 'Cc nnmail-extra-headers)
8274 (gnus-summary-find-matching
8275 (cons 'extra 'Cc) recipient 'all nil nil
8278 1 "`Cc' isn't present in `nnmail-extra-headers'")
8283 ;; We need the numbers that are in both lists:
8285 (and (memq a to) a))
8289 (error "Found no matches for \"%s\"" recipient))
8290 (gnus-summary-limit articles))
8291 (gnus-summary-position-point))))
8293 (defun gnus-summary-limit-to-address (address &optional not-matching)
8294 "Limit the summary buffer to articles with the given ADDRESS.
8296 If NOT-MATCHING, exclude ADDRESS.
8298 To, Cc and From headers are checked. You need to include `To' and `Cc'
8299 in `nnmail-extra-headers'."
8301 (list (read-string (format "%s address (regexp): "
8302 (if current-prefix-arg "Exclude" "Limit to")))
8303 current-prefix-arg))
8304 (when (not (equal "" address))
8306 (if (memq 'To nnmail-extra-headers)
8307 (gnus-summary-find-matching
8308 (cons 'extra 'To) address 'all nil nil
8311 1 "`To' isn't present in `nnmail-extra-headers'")
8315 (if (memq 'Cc nnmail-extra-headers)
8316 (gnus-summary-find-matching
8317 (cons 'extra 'Cc) address 'all nil nil
8320 1 "`Cc' isn't present in `nnmail-extra-headers'")
8324 (gnus-summary-find-matching "from" address
8325 'all nil nil not-matching))
8328 ;; We need the numbers that are in all lists:
8332 (mapcar (lambda (a) (car (memq a from))) to))
8334 (mapcar (lambda (a) (car (memq a from))) cc)
8335 (mapcar (lambda (a) (car (memq a from)))
8336 (mapcar (lambda (a) (car (memq a to)))
8338 (nconc (if (eq to t) nil to)
8339 (if (eq cc t) nil cc)
8342 (error "Found no matches for \"%s\"" address))
8343 (gnus-summary-limit articles))
8344 (gnus-summary-position-point))))
8346 (defun gnus-summary-limit-strange-charsets-predicate (header)
8347 (when (fboundp 'char-charset)
8348 (let ((string (concat (mail-header-subject header)
8349 (mail-header-from header)))
8351 (dotimes (i (1- (length string)))
8352 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8353 (when (string-match "unicode\\|big\\|japanese" charset)
8357 (defun gnus-summary-limit-to-predicate (predicate)
8358 "Limit to articles where PREDICATE returns non-nil.
8359 PREDICATE will be called with the header structures of the
8361 (let ((articles nil)
8362 (case-fold-search t))
8363 (dolist (header gnus-newsgroup-headers)
8364 (when (funcall predicate header)
8365 (push (mail-header-number header) articles)))
8366 (gnus-summary-limit (nreverse articles))))
8368 (defun gnus-summary-limit-to-age (age &optional younger-p)
8369 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8370 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8371 articles that are younger than AGE days."
8373 (let ((younger current-prefix-arg)
8376 (while (not days-got)
8377 (setq days (if younger
8378 (read-string "Limit to articles younger than (in days, older when negative): ")
8380 "Limit to articles older than (in days, younger when negative): ")))
8381 (when (> (length days) 0)
8382 (setq days (read days)))
8387 (setq younger (not younger))
8388 (setq days (* days -1))))
8389 (message "Please enter a number.")
8391 (list days younger)))
8393 (let ((data gnus-newsgroup-data)
8394 (cutoff (days-to-time age))
8395 articles d date is-younger)
8396 (while (setq d (pop data))
8397 (when (and (vectorp (gnus-data-header d))
8398 (setq date (mail-header-date (gnus-data-header d))))
8399 (setq is-younger (time-less-p
8400 (time-since (gnus-date-get-time date))
8405 (push (gnus-data-number d) articles))))
8406 (gnus-summary-limit (nreverse articles)))
8407 (gnus-summary-position-point)))
8409 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8410 "Limit the summary buffer to articles that match an 'extra' header."
8414 (gnus-completing-read
8415 (if current-prefix-arg
8416 "Exclude extra header"
8417 "Limit extra header")
8418 (mapcar 'symbol-name gnus-extra-headers)
8420 (symbol-name (car gnus-extra-headers))))))
8422 (read-string (format "%s header %s (regexp): "
8423 (if current-prefix-arg "Exclude" "Limit to")
8425 current-prefix-arg)))
8426 (when (not (equal "" regexp))
8428 (let ((articles (gnus-summary-find-matching
8429 (cons 'extra header) regexp 'all nil nil
8432 (error "Found no matches for \"%s\"" regexp))
8433 (gnus-summary-limit articles))
8434 (gnus-summary-position-point))))
8436 (defun gnus-summary-limit-to-display-predicate ()
8437 "Limit the summary buffer to the predicated in the `display' group parameter."
8439 (unless gnus-newsgroup-display
8440 (error "There is no `display' group parameter"))
8442 (dolist (gnus-number gnus-newsgroup-articles)
8443 (when (funcall gnus-newsgroup-display)
8444 (push gnus-number articles)))
8445 (gnus-summary-limit articles))
8446 (gnus-summary-position-point))
8448 (defun gnus-summary-limit-to-unread (&optional all)
8449 "Limit the summary buffer to articles that are not marked as read.
8450 If ALL is non-nil, limit strictly to unread articles."
8453 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8454 (gnus-summary-limit-to-marks
8455 ;; Concat all the marks that say that an article is read and have
8457 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8458 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8459 gnus-low-score-mark gnus-expirable-mark
8460 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8461 gnus-duplicate-mark)
8464 (defun gnus-summary-limit-to-headers (match &optional reverse)
8465 "Limit the summary buffer to articles that have headers that match MATCH.
8466 If REVERSE (the prefix), limit to articles that don't match."
8467 (interactive "sMatch headers (regexp): \nP")
8468 (gnus-summary-limit-to-bodies match reverse t))
8470 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8471 "Limit the summary buffer to articles that have bodies that match MATCH.
8472 If REVERSE (the prefix), limit to articles that don't match."
8473 (interactive "sMatch body (regexp): \nP")
8474 (let ((articles nil)
8475 (gnus-select-article-hook nil) ;Disable hook.
8476 (gnus-article-prepare-hook nil)
8477 (gnus-use-article-prefetch nil)
8478 (gnus-keep-backlog nil)
8479 (gnus-break-pages nil)
8480 (gnus-summary-display-arrow nil)
8481 (gnus-updated-mode-lines nil)
8482 (gnus-auto-center-summary nil)
8483 (gnus-display-mime-function nil))
8484 (dolist (data gnus-newsgroup-data)
8485 (let (gnus-mark-article-hook)
8486 (gnus-summary-select-article t t nil (gnus-data-number data)))
8487 (with-current-buffer gnus-article-buffer
8489 (let* ((case-fold-search t)
8491 (re-search-backward match nil t)
8492 (re-search-forward match nil t))))
8493 (when (or (and found
8497 (push (gnus-data-number data) articles)))))
8499 (message "No messages matched")
8500 (gnus-summary-limit articles)))
8501 (gnus-summary-position-point))
8503 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8504 "Limit the summary buffer to articles that aren't part on any thread.
8505 If THREADSP (the prefix), limit to articles that are in threads."
8507 (let ((articles nil)
8510 (dolist (thread gnus-newsgroup-threads)
8511 (if (stringp (car thread))
8512 (dolist (thread (cdr thread))
8513 (push thread threads))
8514 (push thread threads)))
8515 (dolist (thread threads)
8516 (setq thread-articles (gnus-articles-in-thread thread))
8517 (when (or (and threadsp
8518 (> (length thread-articles) 1))
8520 (= (length thread-articles) 1)))
8521 (setq articles (nconc thread-articles articles))))
8523 (message "No messages matched")
8524 (gnus-summary-limit articles))
8525 (gnus-summary-position-point)))
8527 (defun gnus-summary-limit-to-replied (&optional unreplied)
8528 "Limit the summary buffer to replied articles.
8529 If UNREPLIED (the prefix), limit to unreplied articles."
8533 (gnus-set-difference gnus-newsgroup-articles
8534 gnus-newsgroup-replied))
8535 (gnus-summary-limit gnus-newsgroup-replied))
8536 (gnus-summary-position-point))
8538 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8539 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8540 If REVERSE, limit the summary buffer to articles that are marked
8541 with MARKS. MARKS can either be a string of marks or a list of marks.
8542 Returns how many articles were removed."
8543 (interactive "sMarks: ")
8544 (gnus-summary-limit-to-marks marks t))
8546 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8547 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8548 If REVERSE (the prefix), limit the summary buffer to articles that are
8549 not marked with MARKS. MARKS can either be a string of marks or a
8551 Returns how many articles were removed."
8552 (interactive "sMarks: \nP")
8554 (let ((data gnus-newsgroup-data)
8555 (marks (if (listp marks) marks
8556 (append marks nil))) ; Transform to list.
8559 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8560 (memq (gnus-data-mark (car data)) marks))
8561 (push (gnus-data-number (car data)) articles))
8562 (setq data (cdr data)))
8563 (gnus-summary-limit articles))
8564 (gnus-summary-position-point)))
8566 (defun gnus-summary-limit-to-score (score)
8567 "Limit to articles with score at or above SCORE."
8568 (interactive "NLimit to articles with score of at least: ")
8569 (let ((data gnus-newsgroup-data)
8572 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8574 (push (gnus-data-number (car data)) articles))
8575 (setq data (cdr data)))
8577 (gnus-summary-limit articles)
8578 (gnus-summary-position-point))))
8580 (defun gnus-summary-limit-to-unseen ()
8581 "Limit to unseen articles."
8584 (gnus-summary-limit gnus-newsgroup-unseen)
8585 (gnus-summary-position-point)))
8587 (defun gnus-summary-limit-include-thread (id)
8588 "Display all the hidden articles that is in the thread with ID in it.
8589 When called interactively, ID is the Message-ID of the current
8591 (interactive (list (mail-header-id (gnus-summary-article-header))))
8592 (let ((articles (gnus-articles-in-thread
8593 (gnus-id-to-thread (gnus-root-id id))))
8594 ;;we REALLY want the whole thread---this prevents cut-threads
8595 ;;from removing the thread we want to include.
8596 (gnus-fetch-old-headers nil)
8597 (gnus-build-sparse-threads nil))
8599 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8600 (gnus-summary-limit-include-matching-articles
8602 (regexp-quote (gnus-simplify-subject-re
8603 (mail-header-subject (gnus-id-to-header id)))))
8604 (gnus-summary-position-point))))
8606 (defun gnus-summary-limit-include-matching-articles (header regexp)
8607 "Display all the hidden articles that have HEADERs that match REGEXP."
8608 (interactive (list (read-string "Match on header: ")
8609 (read-string "Regexp: ")))
8610 (let ((articles (gnus-find-matching-articles header regexp)))
8612 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8613 (gnus-summary-position-point))))
8615 (defun gnus-summary-insert-dormant-articles ()
8616 "Insert all the dormant articles for this group into the current buffer."
8618 (let ((gnus-verbose (max 6 gnus-verbose)))
8619 (if (not gnus-newsgroup-dormant)
8620 (gnus-message 3 "No dormant articles for this group")
8621 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8623 (defun gnus-summary-insert-ticked-articles ()
8624 "Insert ticked articles for this group into the current buffer."
8626 (let ((gnus-verbose (max 6 gnus-verbose)))
8627 (if (not gnus-newsgroup-marked)
8628 (gnus-message 3 "No ticked articles for this group")
8629 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8631 (defun gnus-summary-limit-include-dormant ()
8632 "Display all the hidden articles that are marked as dormant.
8633 Note that this command only works on a subset of the articles currently
8634 fetched for this group."
8636 (unless gnus-newsgroup-dormant
8637 (error "There are no dormant articles in this group"))
8639 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8640 (gnus-summary-position-point)))
8642 (defun gnus-summary-include-articles (articles)
8643 "Fetch the headers for ARTICLES and then display the summary lines."
8644 (let ((gnus-inhibit-demon t)
8646 (gnus-read-all-available-headers t))
8647 (setq gnus-newsgroup-headers
8649 'list gnus-newsgroup-headers
8650 (gnus-fetch-headers articles nil t)
8651 'gnus-article-sort-by-number))
8652 (setq gnus-newsgroup-articles
8653 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8654 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8656 (defun gnus-summary-limit-exclude-dormant ()
8657 "Hide all dormant articles."
8660 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8661 (gnus-summary-position-point)))
8663 (defun gnus-summary-limit-exclude-childless-dormant ()
8664 "Hide all dormant articles that have no children."
8666 (let ((data (gnus-data-list t))
8667 articles d children)
8668 ;; Find all articles that are either not dormant or have
8670 (while (setq d (pop data))
8671 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8673 (gnus-article-children (gnus-data-number d)))
8676 (when (memq (car children) articles)
8681 (push (gnus-data-number d) articles)))
8684 (gnus-summary-limit articles)
8685 (gnus-summary-position-point))))
8687 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8688 "Mark all unread excluded articles as read.
8689 If ALL, mark even excluded ticked and dormants as read."
8691 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8692 (let ((articles (gnus-sorted-ndifference
8694 (mapcar (lambda (h) (mail-header-number h))
8695 gnus-newsgroup-headers)
8697 gnus-newsgroup-limit))
8699 (setq gnus-newsgroup-unreads
8700 (gnus-sorted-intersection gnus-newsgroup-unreads
8701 gnus-newsgroup-limit))
8703 (setq gnus-newsgroup-dormant nil
8704 gnus-newsgroup-marked nil
8705 gnus-newsgroup-reads
8707 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8708 gnus-newsgroup-reads))
8709 (while (setq article (pop articles))
8710 (unless (or (memq article gnus-newsgroup-dormant)
8711 (memq article gnus-newsgroup-marked))
8712 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8714 (defun gnus-summary-limit (articles &optional pop)
8716 ;; We pop the previous limit off the stack and use that.
8717 (setq articles (car gnus-newsgroup-limits)
8718 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8719 ;; We use the new limit, so we push the old limit on the stack.
8720 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8722 (setq gnus-newsgroup-limit articles)
8723 (let ((total (length gnus-newsgroup-data))
8724 (data (gnus-data-find-list (gnus-summary-article-number)))
8725 (gnus-summary-mark-below nil) ; Inhibit this.
8727 ;; This will do all the work of generating the new summary buffer
8728 ;; according to the new limit.
8729 (gnus-summary-prepare)
8730 ;; Hide any threads, possibly.
8731 (gnus-summary-maybe-hide-threads)
8732 ;; Try to return to the article you were at, or one in the
8735 ;; We try to find some article after the current one.
8737 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8740 (setq data (cdr data))))
8742 ;; If there is no data, that means that we were after the last
8743 ;; article. The same goes when we can't find any articles
8744 ;; after the current one.
8745 (goto-char (point-max))
8746 (gnus-summary-find-prev))
8747 (gnus-set-mode-line 'summary)
8748 ;; We return how many articles were removed from the summary
8749 ;; buffer as a result of the new limit.
8750 (- total (length gnus-newsgroup-data))))
8752 (defsubst gnus-invisible-cut-children (threads)
8755 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8760 (defsubst gnus-cut-thread (thread)
8761 "Go forwards in the thread until we find an article that we want to display."
8762 (when (or (eq gnus-fetch-old-headers 'some)
8763 (eq gnus-fetch-old-headers 'invisible)
8764 (numberp gnus-fetch-old-headers)
8765 (eq gnus-build-sparse-threads 'some)
8766 (eq gnus-build-sparse-threads 'more))
8767 ;; Deal with old-fetched headers and sparse threads.
8771 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8772 (gnus-summary-article-ancient-p
8773 (mail-header-number (car thread))))
8774 (if (or (<= (length (cdr thread)) 1)
8775 (eq gnus-fetch-old-headers 'invisible))
8776 (setq gnus-newsgroup-limit
8777 (delq (mail-header-number (car thread))
8778 gnus-newsgroup-limit)
8779 thread (cadr thread))
8780 (when (gnus-invisible-cut-children (cdr thread))
8781 (let ((th (cdr thread)))
8783 (if (memq (mail-header-number (caar th))
8784 gnus-newsgroup-limit)
8785 (setq thread (car th)
8787 (setq th (cdr th))))))))))
8790 (defun gnus-cut-threads (threads)
8791 "Cut off all uninteresting articles from the beginning of THREADS."
8792 (when (or (eq gnus-fetch-old-headers 'some)
8793 (eq gnus-fetch-old-headers 'invisible)
8794 (numberp gnus-fetch-old-headers)
8795 (eq gnus-build-sparse-threads 'some)
8796 (eq gnus-build-sparse-threads 'more))
8799 (setcar th (gnus-cut-thread (car th)))
8800 (setq th (cdr th)))))
8801 ;; Remove nixed out threads.
8804 (defun gnus-summary-initial-limit (&optional show-if-empty)
8805 "Figure out what the initial limit is supposed to be on group entry.
8806 This entails weeding out unwanted dormants, low-scored articles,
8807 fetch-old-headers verbiage, and so on."
8808 ;; Most groups have nothing to remove.
8809 (unless (or gnus-inhibit-limiting
8810 (and (null gnus-newsgroup-dormant)
8811 (eq gnus-newsgroup-display 'gnus-not-ignore)
8812 (not (eq gnus-fetch-old-headers 'some))
8813 (not (numberp gnus-fetch-old-headers))
8814 (not (eq gnus-fetch-old-headers 'invisible))
8815 (null gnus-summary-expunge-below)
8816 (not (eq gnus-build-sparse-threads 'some))
8817 (not (eq gnus-build-sparse-threads 'more))
8818 (null gnus-thread-expunge-below)))
8819 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8820 (setq gnus-newsgroup-limit nil)
8823 (unless (car (symbol-value node))
8824 ;; These threads have no parents -- they are roots.
8825 (let ((nodes (cdr (symbol-value node)))
8828 (if (and gnus-thread-expunge-below
8829 (< (gnus-thread-total-score (car nodes))
8830 gnus-thread-expunge-below))
8831 (gnus-expunge-thread (pop nodes))
8832 (setq thread (pop nodes))
8833 (gnus-summary-limit-children thread))))))
8834 gnus-newsgroup-dependencies)
8835 ;; If this limitation resulted in an empty group, we might
8836 ;; pop the previous limit and use it instead.
8837 (when (and (not gnus-newsgroup-limit)
8839 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8840 gnus-newsgroup-limit))
8842 (defun gnus-summary-limit-children (thread)
8843 "Return 1 if this subthread is visible and 0 if it is not."
8844 ;; First we get the number of visible children to this thread. This
8845 ;; is done by recursing down the thread using this function, so this
8846 ;; will really go down to a leaf article first, before slowly
8847 ;; working its way up towards the root.
8849 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8852 (apply '+ (mapcar 'gnus-summary-limit-children
8855 (number (mail-header-number (car thread)))
8858 (not (memq number gnus-newsgroup-marked))
8860 ;; If this article is dormant and has absolutely no visible
8861 ;; children, then this article isn't visible.
8862 (and (memq number gnus-newsgroup-dormant)
8864 ;; If this is "fetch-old-headered" and there is no
8865 ;; visible children, then we don't want this article.
8866 (and (or (eq gnus-fetch-old-headers 'some)
8867 (numberp gnus-fetch-old-headers))
8868 (gnus-summary-article-ancient-p number)
8870 ;; If this is "fetch-old-headered" and `invisible', then
8871 ;; we don't want this article.
8872 (and (eq gnus-fetch-old-headers 'invisible)
8873 (gnus-summary-article-ancient-p number))
8874 ;; If this is a sparsely inserted article with no children,
8875 ;; we don't want it.
8876 (and (eq gnus-build-sparse-threads 'some)
8877 (gnus-summary-article-sparse-p number)
8879 ;; If we use expunging, and this article is really
8880 ;; low-scored, then we don't want this article.
8881 (when (and gnus-summary-expunge-below
8883 (or (cdr (assq number gnus-newsgroup-scored))
8884 gnus-summary-default-score))
8885 gnus-summary-expunge-below))
8886 ;; We increase the expunge-tally here, but that has
8887 ;; nothing to do with the limits, really.
8888 (incf gnus-newsgroup-expunged-tally)
8889 ;; We also mark as read here, if that's wanted.
8890 (when (and gnus-summary-mark-below
8891 (< score gnus-summary-mark-below))
8892 (setq gnus-newsgroup-unreads
8893 (delq number gnus-newsgroup-unreads))
8894 (if gnus-newsgroup-auto-expire
8895 (push number gnus-newsgroup-expirable)
8896 (push (cons number gnus-low-score-mark)
8897 gnus-newsgroup-reads)))
8899 ;; Do the `display' group parameter.
8900 (and gnus-newsgroup-display
8901 (let ((gnus-number number))
8902 (not (funcall gnus-newsgroup-display))))))
8903 ;; Nope, invisible article.
8905 ;; Ok, this article is to be visible, so we add it to the limit
8907 (push number gnus-newsgroup-limit)
8910 (defun gnus-expunge-thread (thread)
8911 "Mark all articles in THREAD as read."
8912 (let* ((number (mail-header-number (car thread))))
8913 (incf gnus-newsgroup-expunged-tally)
8914 ;; We also mark as read here, if that's wanted.
8915 (setq gnus-newsgroup-unreads
8916 (delq number gnus-newsgroup-unreads))
8917 (if gnus-newsgroup-auto-expire
8918 (push number gnus-newsgroup-expirable)
8919 (push (cons number gnus-low-score-mark)
8920 gnus-newsgroup-reads)))
8921 ;; Go recursively through all subthreads.
8922 (mapcar 'gnus-expunge-thread (cdr thread)))
8924 ;; Summary article oriented commands
8926 (defun gnus-summary-refer-parent-article (n)
8927 "Refer parent article N times.
8928 If N is negative, go to ancestor -N instead.
8929 The difference between N and the number of articles fetched is returned."
8933 (when (not (natnump n))
8938 (setq header (gnus-summary-article-header))
8939 (if (and (eq (mail-header-number header)
8940 (cdr gnus-article-current))
8941 (equal gnus-newsgroup-name
8942 (car gnus-article-current)))
8943 ;; If we try to find the parent of the currently
8944 ;; displayed article, then we take a look at the actual
8945 ;; References header, since this is slightly more
8946 ;; reliable than the References field we got from the
8948 (with-current-buffer gnus-original-article-buffer
8949 (nnheader-narrow-to-headers)
8950 (unless (setq ref (message-fetch-field "references"))
8951 (when (setq ref (message-fetch-field "in-reply-to"))
8952 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8955 ;; It's not the current article, so we take a bet on
8956 ;; the value we got from the server.
8957 (mail-header-references header)))
8959 (not (equal ref "")))
8960 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8961 (gnus-message 1 "Couldn't find parent"))
8962 (gnus-message 1 "No references in article %d"
8963 (gnus-summary-article-number))
8966 (gnus-summary-position-point)
8969 (defun gnus-summary-refer-references ()
8970 "Fetch all articles mentioned in the References header.
8971 Return the number of articles fetched."
8973 (let ((ref (mail-header-references (gnus-summary-article-header)))
8974 (current (gnus-summary-article-number))
8978 (error "No References in the current article")
8979 ;; For each Message-ID in the References header...
8980 (while (string-match "<[^>]*>" ref)
8982 ;; ... fetch that article.
8983 (gnus-summary-refer-article
8984 (prog1 (match-string 0 ref)
8985 (setq ref (substring ref (match-end 0))))))
8986 (gnus-summary-goto-subject current)
8987 (gnus-summary-position-point)
8990 (defun gnus-delete-duplicate-headers (headers)
8991 ;; First remove leading duplicates.
8992 (while (and (> (length headers) 1)
8993 (= (mail-header-number (car headers))
8994 (mail-header-number (cadr headers))))
8997 (let ((result headers))
8998 (while (> (length headers) 1)
8999 (if (= (mail-header-number (car headers))
9000 (mail-header-number (cadr headers)))
9001 (setcdr headers (cddr headers))
9005 (defun gnus-summary-refer-thread (&optional limit)
9006 "Fetch all articles in the current thread. For backends that
9007 know how to search for threads (currently only 'nnimap) a
9008 non-numeric prefix arg will use nnir to search the entire
9009 server; without a prefix arg only the current group is
9010 searched. If the variable `gnus-refer-thread-use-nnir' is
9011 non-nil the prefix arg has the reverse meaning. If no
9012 backend-specific 'request-thread function is available fetch
9013 LIMIT (the numerical prefix) old headers. If LIMIT is
9014 non-numeric or nil fetch the number specified by the
9015 `gnus-refer-thread-limit' variable."
9017 (gnus-warp-to-article)
9018 (let* ((header (gnus-summary-article-header))
9019 (id (mail-header-id header))
9020 (gnus-inhibit-demon t)
9021 (gnus-summary-ignore-duplicates t)
9022 (gnus-read-all-available-headers t)
9023 (gnus-refer-thread-use-nnir
9024 (if (and (not (null limit)) (listp limit))
9025 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9027 (if (gnus-check-backend-function
9028 'request-thread gnus-newsgroup-name)
9029 (gnus-request-thread header gnus-newsgroup-name)
9030 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9031 gnus-refer-thread-limit))
9032 (last (if (numberp limit)
9033 (min (+ (mail-header-number header)
9035 gnus-newsgroup-highest)
9036 gnus-newsgroup-highest))
9037 (subject (gnus-simplify-subject
9038 (mail-header-subject header)))
9039 (refs (split-string (or (mail-header-references header)
9041 (gnus-parse-headers-hook
9042 `(lambda () (goto-char (point-min))
9044 (regexp-opt ',(append refs (list id subject)))))))
9045 (gnus-fetch-headers (list last) (if (numberp limit)
9046 (* 2 limit) limit) t))))
9048 (when (listp new-headers)
9049 (dolist (header new-headers)
9050 (push (mail-header-number header) article-ids)
9051 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9052 (push (mail-header-number header) gnus-newsgroup-unreads)
9053 (setq gnus-newsgroup-unselected
9054 (delete (mail-header-number header)
9055 gnus-newsgroup-unselected))))
9056 (setq gnus-newsgroup-headers
9057 (gnus-delete-duplicate-headers
9059 'list gnus-newsgroup-headers new-headers
9060 'gnus-article-sort-by-number)))
9061 (setq gnus-newsgroup-articles
9062 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9063 (gnus-summary-limit-include-thread id)))
9064 (gnus-summary-show-thread))
9066 (defun gnus-summary-refer-article (message-id)
9067 "Fetch an article specified by MESSAGE-ID."
9068 (interactive "sMessage-ID: ")
9069 (gnus-warp-to-article)
9070 (when (and (stringp message-id)
9071 (not (zerop (length message-id))))
9072 (setq message-id (gnus-replace-in-string message-id " " ""))
9073 ;; Construct the correct Message-ID if necessary.
9074 ;; Suggested by tale@pawl.rpi.edu.
9075 (unless (string-match "^<" message-id)
9076 (setq message-id (concat "<" message-id)))
9077 (unless (string-match ">$" message-id)
9078 (setq message-id (concat message-id ">")))
9079 ;; People often post MIDs from URLs, so unhex it:
9080 (unless (string-match "@" message-id)
9081 (setq message-id (gnus-url-unhex-string message-id)))
9082 (let* ((header (gnus-id-to-header message-id))
9084 (gnus-summary-article-sparse-p
9085 (mail-header-number header))
9086 (memq (mail-header-number header)
9087 gnus-newsgroup-limit)))
9090 ;; If the article is present in the buffer we just go to it.
9092 (or (not (gnus-summary-article-sparse-p
9093 (mail-header-number header)))
9096 (gnus-summary-goto-article
9097 (mail-header-number header) nil t)
9099 (gnus-summary-update-article (mail-header-number header)))))
9101 ;; We fetch the article.
9103 (dolist (gnus-override-method (gnus-refer-article-methods))
9104 (when (and (gnus-check-server gnus-override-method)
9105 ;; Fetch the header,
9106 (setq number (gnus-summary-insert-subject message-id)))
9107 ;; and display the article.
9108 (gnus-summary-select-article nil nil nil number)
9110 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9112 (defun gnus-refer-article-methods ()
9113 "Return a list of referable methods."
9115 ;; No method, so we default to current and native.
9116 ((null gnus-refer-article-method)
9117 (list gnus-current-select-method gnus-select-method))
9119 ((eq 'current gnus-refer-article-method)
9120 (list gnus-current-select-method))
9121 ;; List of select methods.
9122 ((not (and (symbolp (car gnus-refer-article-method))
9123 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9125 (dolist (method gnus-refer-article-method)
9126 (push (if (eq 'current method)
9127 gnus-current-select-method
9128 (if (eq 'nnir (car method))
9132 (gnus-method-to-server gnus-current-select-method)))
9136 ;; One single select method.
9138 (list gnus-refer-article-method))))
9140 (defun gnus-summary-edit-parameters ()
9141 "Edit the group parameters of the current group."
9143 (gnus-group-edit-group gnus-newsgroup-name 'params))
9145 (defun gnus-summary-customize-parameters ()
9146 "Customize the group parameters of the current group."
9148 (gnus-group-customize gnus-newsgroup-name))
9150 (defun gnus-summary-enter-digest-group (&optional force)
9151 "Enter an nndoc group based on the current article.
9152 If FORCE, force a digest interpretation. If not, try to guess
9153 what the document format is.
9155 To control what happens when you exit the group, see the
9156 `gnus-auto-select-on-ephemeral-exit' variable."
9158 (let ((conf gnus-current-window-configuration))
9159 (save-window-excursion
9161 (let (gnus-article-prepare-hook
9162 gnus-display-mime-function
9164 (gnus-summary-select-article))))
9165 (setq gnus-current-window-configuration conf)
9166 (let* ((name (format "%s-%d"
9167 (gnus-group-prefixed-name
9168 gnus-newsgroup-name (list 'nndoc ""))
9169 (with-current-buffer gnus-summary-buffer
9170 gnus-current-article)))
9171 (ogroup gnus-newsgroup-name)
9172 (params (append (gnus-info-params (gnus-get-info ogroup))
9173 (list (cons 'to-group ogroup))
9174 (list (cons 'parent-group ogroup))
9175 (list (cons 'save-article-group ogroup))))
9176 (case-fold-search t)
9177 (buf (current-buffer))
9179 (with-current-buffer gnus-original-article-buffer
9180 ;; Have the digest group inherit the main mail address of
9181 ;; the parent article.
9182 (when (setq to-address (or (gnus-fetch-field "reply-to")
9183 (gnus-fetch-field "from")))
9186 (list (cons 'to-address
9187 (funcall gnus-decode-encoded-address-function
9189 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9190 (insert-buffer-substring gnus-original-article-buffer)
9191 ;; Remove lines that may lead nndoc to misinterpret the
9194 (goto-char (point-min))
9195 (or (search-forward "\n\n" nil t) (point)))
9196 (goto-char (point-min))
9197 (delete-matching-lines "^Path:\\|^From ")
9200 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
9201 (gnus-newsgroup-ephemeral-ignored-charsets
9202 gnus-newsgroup-ignored-charsets))
9203 (gnus-group-read-ephemeral-group
9204 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9206 ,(if force 'mbox 'guess)))
9208 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9210 ;; Make all postings to this group go to the parent group.
9211 (nconc (gnus-info-params (gnus-get-info name))
9213 ;; Couldn't select this doc group.
9214 (switch-to-buffer buf)
9215 (gnus-set-global-variables)
9216 (gnus-configure-windows 'summary)
9217 (gnus-message 3 "Article couldn't be entered?"))
9218 (kill-buffer dig)))))
9220 (defun gnus-summary-read-document (n)
9221 "Open a new group based on the current article(s).
9222 This will allow you to read digests and other similar
9223 documents as newsgroups.
9224 Obeys the standard process/prefix convention."
9226 (let* ((ogroup gnus-newsgroup-name)
9227 (params (append (gnus-info-params (gnus-get-info ogroup))
9228 (list (cons 'to-group ogroup))))
9229 group egroup groups vgroup)
9230 (dolist (article (gnus-summary-work-articles n))
9231 (setq group (format "%s-%d" gnus-newsgroup-name article))
9232 (gnus-summary-remove-process-mark article)
9233 (when (gnus-summary-display-article article)
9234 (save-excursion ;;What for?
9236 (insert-buffer-substring gnus-original-article-buffer)
9237 ;; Remove some headers that may lead nndoc to make
9239 (message-narrow-to-head)
9240 (goto-char (point-min))
9241 (delete-matching-lines "^Path:\\|^From ")
9244 (gnus-group-read-ephemeral-group
9245 group `(nndoc ,group (nndoc-address ,(current-buffer))
9246 (nndoc-article-type guess))
9249 ;; Make all postings to this group go to the parent group.
9250 (nconc (gnus-info-params (gnus-get-info egroup))
9252 (push egroup groups))
9253 ;; Couldn't select this doc group.
9254 (gnus-error 3 "Article couldn't be entered"))))))
9255 ;; Now we have selected all the documents.
9258 (error "None of the articles could be interpreted as documents"))
9259 ((gnus-group-read-ephemeral-group
9260 (setq vgroup (format
9261 "nnvirtual:%s-%s" gnus-newsgroup-name
9262 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9263 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9265 (cons (current-buffer) 'summary)))
9267 (error "Couldn't select virtual nndoc group")))))
9269 (defun gnus-summary-widget-forward (arg)
9270 "Move point to the next 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 (widget-forward arg))
9278 (defun gnus-summary-widget-backward (arg)
9279 "Move point to the previous field or button in the article.
9280 With optional ARG, move across that many fields."
9282 (gnus-summary-select-article)
9283 (gnus-configure-windows 'article)
9284 (select-window (gnus-get-buffer-window gnus-article-buffer))
9285 (unless (widget-at (point))
9286 (goto-char (point-max)))
9287 (widget-backward arg))
9289 (defun gnus-summary-isearch-article (&optional regexp-p)
9290 "Do incremental search forward on the current article.
9291 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9293 (gnus-summary-select-article)
9294 (gnus-configure-windows 'article)
9295 (gnus-eval-in-buffer-window gnus-article-buffer
9298 (isearch-forward regexp-p))))
9300 (defun gnus-summary-repeat-search-article-forward ()
9301 "Repeat the previous search forwards."
9303 (unless gnus-last-search-regexp
9304 (error "No previous search"))
9305 (gnus-summary-search-article-forward gnus-last-search-regexp))
9307 (defun gnus-summary-repeat-search-article-backward ()
9308 "Repeat the previous search backwards."
9310 (unless gnus-last-search-regexp
9311 (error "No previous search"))
9312 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9314 (defun gnus-summary-search-article-forward (regexp &optional backward)
9315 "Search for an article containing REGEXP forward.
9316 If BACKWARD, search backward instead."
9319 (format "Search article %s (regexp%s): "
9320 (if current-prefix-arg "backward" "forward")
9321 (if gnus-last-search-regexp
9322 (concat ", default " gnus-last-search-regexp)
9324 current-prefix-arg))
9325 (if (string-equal regexp "")
9326 (setq regexp (or gnus-last-search-regexp ""))
9327 (setq gnus-last-search-regexp regexp)
9328 (setq gnus-article-before-search gnus-current-article))
9329 ;; Intentionally set gnus-last-article.
9330 (setq gnus-last-article gnus-article-before-search)
9331 (let ((gnus-last-article gnus-last-article))
9332 (if (gnus-summary-search-article regexp backward)
9333 (gnus-summary-show-thread)
9334 (signal 'search-failed (list regexp)))))
9336 (defun gnus-summary-search-article-backward (regexp)
9337 "Search for an article containing REGEXP backward."
9340 (format "Search article backward (regexp%s): "
9341 (if gnus-last-search-regexp
9342 (concat ", default " gnus-last-search-regexp)
9344 (gnus-summary-search-article-forward regexp 'backward))
9346 (defun gnus-summary-search-article (regexp &optional backward)
9347 "Search for an article containing REGEXP.
9348 Optional argument BACKWARD means do search for backward.
9349 `gnus-select-article-hook' is not called during the search."
9350 ;; We have to require this here to make sure that the following
9351 ;; dynamic binding isn't shadowed by autoloading.
9352 (require 'gnus-async)
9354 (let ((gnus-select-article-hook nil) ;Disable hook.
9355 (gnus-article-prepare-hook nil)
9356 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9357 (gnus-use-article-prefetch nil)
9358 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9359 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9361 (gnus-keep-backlog nil)
9362 (gnus-break-pages nil)
9363 (gnus-summary-display-arrow nil)
9364 (gnus-updated-mode-lines nil)
9365 (gnus-auto-center-summary nil)
9366 (sum (current-buffer))
9367 (gnus-display-mime-function nil)
9370 (gnus-save-hidden-threads
9371 (gnus-summary-select-article)
9372 (set-buffer gnus-article-buffer)
9373 (goto-char (window-point (get-buffer-window (current-buffer))))
9377 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9379 (re-search-backward regexp nil t)
9380 (re-search-forward regexp nil t))
9381 ;; We found the regexp.
9386 (get-buffer-window (current-buffer))
9390 (get-buffer-window (current-buffer))
9393 (setq point (point)))
9394 ;; We didn't find it, so we go to the next article.
9397 (while (eq found 'not)
9398 (if (not (if backward (gnus-summary-find-prev)
9399 (gnus-summary-find-next)))
9400 ;; No more articles.
9402 ;; Select the next article and adjust point.
9403 (unless (gnus-summary-article-sparse-p
9404 (gnus-summary-article-number))
9406 (gnus-summary-select-article)
9407 (set-buffer gnus-article-buffer)
9409 (goto-char (if backward (point-max) (point-min))))))))
9410 (gnus-message 7 ""))
9411 ;; Return whether we found the regexp.
9412 (when (eq found 'found)
9414 (gnus-summary-show-thread)
9415 (gnus-summary-goto-subject gnus-current-article)
9416 (gnus-summary-position-point)
9419 (defun gnus-find-matching-articles (header regexp)
9420 "Return a list of all articles that match REGEXP on HEADER.
9421 This search includes all articles in the current group that Gnus has
9422 fetched headers for, whether they are displayed or not."
9423 (let ((articles nil)
9424 ;; Can't eta-reduce because it's a macro.
9425 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9426 (case-fold-search t))
9427 (dolist (header gnus-newsgroup-headers)
9428 (when (string-match regexp (funcall func header))
9429 (push (mail-header-number header) articles)))
9430 (nreverse articles)))
9432 (defun gnus-summary-find-matching (header regexp &optional backward unread
9433 not-case-fold not-matching)
9434 "Return a list of all articles that match REGEXP on HEADER.
9435 The search stars on the current article and goes forwards unless
9436 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9437 If UNREAD is non-nil, only unread articles will
9438 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9439 in the comparisons. If NOT-MATCHING, return a list of all articles that
9440 not match REGEXP on HEADER."
9441 (let ((case-fold-search (not not-case-fold))
9444 (if (eq (car header) 'extra)
9447 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9449 (error "%s is an invalid header" header))
9450 (unless (fboundp (intern (concat "mail-header-" header)))
9451 (error "%s is not a valid header" header))
9452 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9453 (dolist (d (if (eq backward 'all)
9455 (gnus-data-find-list
9456 (gnus-summary-article-number)
9457 (gnus-data-list backward))))
9458 (when (and (or (not unread) ; We want all articles...
9459 (gnus-data-unread-p d)) ; Or just unreads.
9460 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9464 (funcall func (gnus-data-header d))))
9465 (string-match regexp
9466 (funcall func (gnus-data-header d)))))
9467 (push (gnus-data-number d) articles))) ; Success!
9468 (nreverse articles)))
9470 (defun gnus-summary-execute-command (header regexp command &optional backward)
9471 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9472 If HEADER is an empty string (or nil), the match is done on the entire
9473 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9475 (list (let ((completion-ignore-case t))
9476 (gnus-completing-read
9478 (mapcar 'symbol-name
9480 '(Number Subject From Lines Date
9481 Message-ID Xref References Body)
9482 gnus-extra-headers))
9484 (read-string "Regexp: ")
9485 (read-key-sequence "Command: ")
9486 current-prefix-arg))
9487 (when (equal header "Body")
9489 ;; Hidden thread subtrees must be searched as well.
9490 (gnus-summary-show-all-threads)
9491 ;; We don't want to change current point nor window configuration.
9493 (save-window-excursion
9495 gnus-treat-strip-trailing-blank-lines
9496 gnus-treat-strip-leading-blank-lines
9497 gnus-treat-strip-multiple-blank-lines
9498 gnus-treat-hide-boring-headers
9499 gnus-treat-fold-newsgroups
9500 gnus-article-prepare-hook)
9501 (gnus-message 6 "Executing %s..." (key-description command))
9502 ;; We'd like to execute COMMAND interactively so as to give arguments.
9503 (gnus-execute header regexp
9504 `(call-interactively ',(key-binding command))
9506 (gnus-message 6 "Executing %s...done" (key-description command))))))
9508 (defun gnus-summary-beginning-of-article ()
9509 "Scroll the article back to the beginning."
9511 (gnus-summary-select-article)
9512 (gnus-configure-windows 'article)
9513 (gnus-eval-in-buffer-window gnus-article-buffer
9515 (goto-char (point-min))
9516 (when gnus-break-pages
9517 (gnus-narrow-to-page))))
9519 (defun gnus-summary-end-of-article ()
9520 "Scroll to the end of the article."
9522 (gnus-summary-select-article)
9523 (gnus-configure-windows 'article)
9524 (gnus-eval-in-buffer-window gnus-article-buffer
9526 (goto-char (point-max))
9528 (when gnus-break-pages
9529 (gnus-narrow-to-page))))
9531 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9532 "Truncate to LEN and quote all \"(\"'s in STRING."
9533 (gnus-replace-in-string (if (and len (> (length string) len))
9534 (substring string 0 len)
9538 (defun gnus-summary-print-article (&optional filename n)
9539 "Generate and print a PostScript image of the process-marked (mail) articles.
9541 If used interactively, print the current article if none are
9542 process-marked. With prefix arg, prompt the user for the name of the
9545 When used from Lisp, accept two optional args FILENAME and N. N means
9546 to print the next N articles. If N is negative, print the N previous
9547 articles. If N is nil and articles have been marked with the process
9548 mark, print these instead.
9550 If the optional first argument FILENAME is nil, send the image to the
9551 printer. If FILENAME is a string, save the PostScript image in a file with
9552 that name. If FILENAME is a number, prompt the user for the name of the file
9554 (interactive (list (ps-print-preprint current-prefix-arg)))
9555 (dolist (article (gnus-summary-work-articles n))
9556 (gnus-summary-select-article nil nil 'pseudo article)
9557 (gnus-eval-in-buffer-window gnus-article-buffer
9558 (gnus-print-buffer))
9559 (gnus-summary-remove-process-mark article))
9560 (ps-despool filename))
9562 (defun gnus-print-buffer ()
9563 (let ((ps-left-header
9566 (gnus-summary-print-truncate-and-quote
9567 (mail-header-subject gnus-current-headers)
9570 (gnus-summary-print-truncate-and-quote
9571 (mail-header-from gnus-current-headers)
9575 "/pagenumberstring load"
9577 (mail-header-date gnus-current-headers) ")"))))
9578 (gnus-run-hooks 'gnus-ps-print-hook)
9580 (if ps-print-color-p
9581 (ps-spool-buffer-with-faces)
9582 (ps-spool-buffer)))))
9584 (defun gnus-summary-show-complete-article ()
9585 "Show a complete version of the current article.
9586 This is only useful if you're looking at a partial version of the
9589 (let ((gnus-keep-backlog nil)
9590 (gnus-use-cache nil)
9593 (format "%s-fetch-partial-articles"
9594 (car (gnus-find-method-for-group
9595 gnus-newsgroup-name)))
9600 (setq old-val (symbol-value variable))
9602 (gnus-flush-original-article-buffer)
9603 (gnus-summary-show-article))
9604 (set variable old-val))))
9606 (defun gnus-summary-show-article (&optional arg)
9607 "Force redisplaying of the current article.
9608 If ARG (the prefix) is a number, show the article with the charset
9609 defined in `gnus-summary-show-article-charset-alist', or the charset
9611 If ARG (the prefix) is non-nil and not a number, show the article,
9612 but without running any of the article treatment functions
9613 article. Normally, the keystroke is `C-u g'. When using `C-u
9614 C-u g', show the raw article."
9618 (gnus-summary-show-article t)
9619 (let ((gnus-newsgroup-charset
9620 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9621 (mm-read-coding-system
9622 "View as charset: " ;; actually it is coding system.
9623 (with-current-buffer gnus-article-buffer
9624 (mm-detect-coding-region (point) (point-max))))))
9625 (gnus-newsgroup-ignored-charsets 'gnus-all))
9626 (gnus-summary-select-article nil 'force)
9627 (let ((deps gnus-newsgroup-dependencies)
9629 (with-current-buffer gnus-original-article-buffer
9631 (message-narrow-to-head)
9632 (setq head (buffer-string))
9633 (goto-char (point-min))
9634 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9635 (goto-char (point-max))
9637 (setq lines (1- (count-lines (point) (point-max))))))
9639 (insert (format "211 %d Article retrieved.\n"
9640 (cdr gnus-article-current)))
9642 (if lines (insert (format "Lines: %d\n" lines)))
9644 (let ((nntp-server-buffer (current-buffer)))
9645 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9646 (gnus-data-set-header
9647 (gnus-data-find (cdr gnus-article-current))
9649 (gnus-summary-update-article-line
9650 (cdr gnus-article-current) header)
9651 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9652 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9654 ;; Select the article the normal way.
9655 (if (eq mm-text-html-renderer 'shr)
9658 (let ((shr-ignore-cache t))
9659 (gnus-summary-select-article nil 'force)))
9660 (gnus-summary-select-article nil 'force)))
9663 (let ((gnus-inhibit-article-treatments t))
9664 (gnus-summary-select-article nil 'force)))
9666 ;; We have to require this here to make sure that the following
9667 ;; dynamic binding isn't shadowed by autoloading.
9668 (require 'gnus-async)
9670 ;; Bind the article treatment functions to nil.
9671 (let ((gnus-have-all-headers t)
9672 gnus-article-prepare-hook
9673 gnus-article-decode-hook
9674 gnus-display-mime-function
9676 ;; Destroy any MIME parts.
9677 (when (gnus-buffer-live-p gnus-article-buffer)
9678 (with-current-buffer gnus-article-buffer
9679 (gnus-article-stop-animations)
9680 (gnus-stop-downloads)
9681 (mm-destroy-parts gnus-article-mime-handles)
9682 ;; Set it to nil for safety reason.
9683 (setq gnus-article-mime-handle-alist nil)
9684 (setq gnus-article-mime-handles nil)))
9685 (gnus-summary-select-article nil 'force))))
9686 (gnus-summary-goto-subject gnus-current-article)
9687 (gnus-summary-position-point))
9689 (defun gnus-summary-show-raw-article ()
9690 "Show the raw article without any article massaging functions being run."
9692 (gnus-summary-show-article t))
9694 (defun gnus-summary-verbose-headers (&optional arg)
9695 "Toggle permanent full header display.
9696 If ARG is a positive number, turn header display on.
9697 If ARG is a negative number, turn header display off."
9699 (setq gnus-show-all-headers
9700 (cond ((or (not (numberp arg))
9702 (not gnus-show-all-headers))
9705 (gnus-summary-show-article))
9707 (defun gnus-summary-toggle-header (&optional arg)
9708 "Show the headers if they are hidden, or hide them if they are shown.
9709 If ARG is a positive number, show the entire header.
9710 If ARG is a negative number, hide the unwanted header lines."
9712 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9713 (get-buffer-window gnus-article-buffer t))))
9714 (with-current-buffer gnus-article-buffer
9716 (article-narrow-to-head)
9717 (let* ((inhibit-read-only t)
9718 (inhibit-point-motion-hooks t)
9719 (hidden (if (numberp arg)
9721 (or (not (looking-at "[^ \t\n]+:"))
9722 (gnus-article-hidden-text-p 'headers))))
9724 (delete-region (point-min) (point-max))
9725 (with-current-buffer gnus-original-article-buffer
9726 (goto-char (setq s (point-min)))
9727 (setq e (if (search-forward "\n\n" nil t)
9730 (insert-buffer-substring gnus-original-article-buffer s e)
9731 (run-hooks 'gnus-article-decode-hook)
9733 (let ((gnus-treat-hide-headers nil)
9734 (gnus-treat-hide-boring-headers nil))
9735 (gnus-delete-wash-type 'headers)
9736 (gnus-treat-article 'head))
9737 (gnus-treat-article 'head))
9740 (set-window-start window (goto-char (point-min))))
9741 (if gnus-break-pages
9742 (gnus-narrow-to-page)
9743 (when (gnus-visual-p 'page-marker)
9744 (let ((inhibit-read-only t))
9745 (gnus-remove-text-with-property 'gnus-prev)
9746 (gnus-remove-text-with-property 'gnus-next))))
9747 (gnus-set-mode-line 'article)))))
9749 (defun gnus-summary-show-all-headers ()
9750 "Make all header lines visible."
9752 (gnus-summary-toggle-header 1))
9754 (defun gnus-summary-caesar-message (&optional arg)
9755 "Caesar rotate the current article by 13.
9756 With a non-numerical prefix, also rotate headers. A numerical
9757 prefix specifies how many places to rotate each letter forward."
9759 (gnus-summary-select-article)
9760 (let ((mail-header-separator ""))
9761 (gnus-eval-in-buffer-window gnus-article-buffer
9764 (let ((start (window-start))
9765 (inhibit-read-only t))
9766 (if (equal arg '(4))
9767 (message-caesar-buffer-body nil t)
9768 (message-caesar-buffer-body arg))
9769 (set-window-start (get-buffer-window (current-buffer)) start)))))
9770 ;; Create buttons and stuff...
9771 (gnus-treat-article nil))
9773 (declare-function idna-to-unicode "ext:idna" (str))
9775 (defun gnus-summary-idna-message (&optional arg)
9776 "Decode IDNA encoded domain names in the current articles.
9777 IDNA encoded domain names looks like `xn--bar'. If a string
9778 remain unencoded after running this function, it is likely an
9779 invalid IDNA string (`xn--bar' is invalid).
9781 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9782 installed for this command to work."
9784 (if (not (and (condition-case nil (require 'idna)
9786 (mm-coding-system-p 'utf-8)
9787 (executable-find (symbol-value 'idna-program))))
9789 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9790 (gnus-summary-select-article)
9791 (let ((mail-header-separator ""))
9792 (gnus-eval-in-buffer-window gnus-article-buffer
9795 (let ((start (window-start))
9797 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9798 (replace-match (idna-to-unicode (match-string 1))))
9799 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9801 (defun gnus-summary-morse-message (&optional arg)
9802 "Morse decode the current article."
9804 (gnus-summary-select-article)
9805 (let ((mail-header-separator ""))
9806 (gnus-eval-in-buffer-window gnus-article-buffer
9810 (let ((pos (window-start))
9811 (inhibit-read-only t))
9812 (goto-char (point-min))
9813 (when (message-goto-body)
9814 (gnus-narrow-to-body))
9815 (goto-char (point-min))
9816 (while (search-forward "·" (point-max) t)
9817 (replace-match "."))
9818 (unmorse-region (point-min) (point-max))
9820 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9822 (defun gnus-summary-stop-page-breaking ()
9823 "Stop page breaking in the current article."
9825 (gnus-summary-select-article)
9826 (gnus-eval-in-buffer-window gnus-article-buffer
9828 (when (gnus-visual-p 'page-marker)
9829 (let ((inhibit-read-only t))
9830 (gnus-remove-text-with-property 'gnus-prev)
9831 (gnus-remove-text-with-property 'gnus-next))
9832 (setq gnus-page-broken nil))))
9834 (defun gnus-summary-move-article (&optional n to-newsgroup
9835 select-method action)
9836 "Move the current article to a different newsgroup.
9837 If N is a positive number, move the N next articles.
9838 If N is a negative number, move the N previous articles.
9839 If N is nil and any articles have been marked with the process mark,
9840 move those articles instead.
9841 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9842 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9843 re-spool using this method.
9845 When called interactively with TO-NEWSGROUP being nil, the value of
9846 the variable `gnus-move-split-methods' is used for finding a default
9847 for the target newsgroup.
9849 For this function to work, both the current newsgroup and the
9850 newsgroup that you want to move to have to support the `request-move'
9851 and `request-accept' functions.
9853 ACTION can be either `move' (the default), `crosspost' or `copy'."
9856 (setq action 'move))
9857 ;; Check whether the source group supports the required functions.
9858 (cond ((and (eq action 'move)
9859 (not (gnus-check-backend-function
9860 'request-move-article gnus-newsgroup-name)))
9861 (error "The current group does not support article moving"))
9862 ((and (eq action 'crosspost)
9863 (not (gnus-check-backend-function
9864 'request-replace-article gnus-newsgroup-name)))
9865 (error "The current group does not support article editing")))
9866 (let ((articles (gnus-summary-work-articles n))
9867 (prefix (if (gnus-check-backend-function
9868 'request-move-article gnus-newsgroup-name)
9869 (funcall gnus-move-group-prefix-function
9870 gnus-newsgroup-name)
9872 (names '((move "Move" "Moving")
9873 (copy "Copy" "Copying")
9874 (crosspost "Crosspost" "Crossposting")))
9875 (copy-buf (save-excursion
9876 (nnheader-set-temp-buffer " *copy article*")))
9877 art-group to-method new-xref article to-groups
9878 articles-to-update-marks encoded)
9879 (unless (assq action names)
9880 (error "Unknown action %s" action))
9881 ;; Read the newsgroup name.
9882 (when (and (not to-newsgroup)
9883 (not select-method))
9884 (if (and gnus-move-split-methods
9886 (and (memq gnus-current-article articles)
9887 (gnus-buffer-live-p gnus-original-article-buffer))))
9888 ;; When `gnus-move-split-methods' is non-nil, we have to
9889 ;; select an article to give `gnus-read-move-group-name' an
9890 ;; opportunity to suggest an appropriate default. However,
9891 ;; we needn't render or mark the article.
9892 (let ((gnus-display-mime-function nil)
9893 (gnus-article-prepare-hook nil)
9894 (gnus-mark-article-hook nil))
9895 (gnus-summary-select-article nil nil nil (car articles))))
9896 (setq to-newsgroup (gnus-read-move-group-name
9897 (cadr (assq action names))
9899 (intern (format "gnus-current-%s-group" action)))
9901 encoded to-newsgroup
9902 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9903 (set (intern (format "gnus-current-%s-group" action))
9904 (mm-decode-coding-string
9906 (gnus-group-name-charset to-method to-newsgroup))))
9908 (setq to-method (or select-method
9909 (gnus-server-to-method
9910 (gnus-group-method to-newsgroup)))))
9914 (mm-encode-coding-string
9916 (gnus-group-name-charset to-method to-newsgroup)))))
9917 ;; Check the method we are to move this article to...
9918 (unless (gnus-check-backend-function
9919 'request-accept-article (car to-method))
9920 (error "%s does not support article copying" (car to-method)))
9921 (unless (gnus-check-server to-method)
9922 (error "Can't open server %s" (car to-method)))
9923 (gnus-message 6 "%s to %s: %s..."
9924 (caddr (assq action names))
9925 (or (car select-method)
9926 (gnus-group-decoded-name to-newsgroup))
9929 (setq article (pop articles))
9930 ;; Set any marks that may have changed in the summary buffer.
9931 (when gnus-preserve-marks
9932 (gnus-summary-push-marks-to-backend article))
9936 ;; Move the article.
9938 ;; Remove this article from future suppression.
9939 (gnus-dup-unsuppress-article article)
9940 (let* ((from-method (gnus-find-method-for-group
9941 gnus-newsgroup-name))
9942 (to-method (or select-method
9943 (gnus-find-method-for-group to-newsgroup)))
9944 (move-is-internal (gnus-server-equal from-method to-method)))
9945 (gnus-request-move-article
9946 article ; Article to move
9947 gnus-newsgroup-name ; From newsgroup
9948 (nth 1 (gnus-find-method-for-group
9949 gnus-newsgroup-name)) ; Server
9950 (list 'gnus-request-accept-article
9951 to-newsgroup (list 'quote select-method)
9952 (not articles) t) ; Accept form
9953 (not articles) ; Only save nov last time
9954 (and move-is-internal
9955 to-newsgroup ; Not respooling
9956 ; Is this move internal?
9957 (gnus-group-real-name to-newsgroup)))))
9958 ;; Copy the article.
9960 (with-current-buffer copy-buf
9961 (when (gnus-request-article-this-buffer article
9962 gnus-newsgroup-name)
9964 (nnheader-narrow-to-headers)
9965 (dolist (hdr gnus-copy-article-ignored-headers)
9966 (message-remove-header hdr t)))
9967 (gnus-request-accept-article
9968 to-newsgroup select-method (not articles) t))))
9969 ;; Crosspost the article.
9970 ((eq action 'crosspost)
9971 (let ((xref (message-tokenize-header
9972 (mail-header-xref (gnus-summary-article-header
9975 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9976 ":" (number-to-string article)))
9978 (setq xref (list (system-name))))
9981 (mapconcat 'identity
9982 (delete "Xref:" (delete new-xref xref))
9985 (with-current-buffer copy-buf
9986 ;; First put the article in the destination group.
9987 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9988 (when (consp (setq art-group
9989 (gnus-request-accept-article
9990 to-newsgroup select-method (not articles)
9992 (setq new-xref (concat new-xref " " (car art-group)
9994 (number-to-string (cdr art-group))))
9995 ;; Now we have the new Xrefs header, so we insert
9996 ;; it and replace the new article.
9997 (nnheader-replace-header "Xref" new-xref)
9998 (gnus-request-replace-article
9999 (cdr art-group) to-newsgroup (current-buffer) t)
10003 (gnus-message 1 "Couldn't %s article %s: %s"
10004 (cadr (assq action names)) article
10005 (nnheader-get-report (car to-method))))
10006 ((eq art-group 'junk)
10007 (when (eq action 'move)
10008 (gnus-summary-mark-article article gnus-canceled-mark)
10009 (gnus-message 4 "Deleted article %s" article)
10010 ;; run the delete hook
10011 (run-hook-with-args 'gnus-summary-article-delete-hook
10014 (assoc article (gnus-data-list nil)))
10015 gnus-newsgroup-name nil
10018 (let* ((pto-group (gnus-group-prefixed-name
10019 (car art-group) to-method))
10020 (info (gnus-get-info pto-group))
10021 (to-group (gnus-info-group info))
10023 ;; Update the group that has been moved to.
10025 (memq action '(move copy)))
10026 (unless (member to-group to-groups)
10027 (push to-group to-groups))
10029 (when (and (not (memq article gnus-newsgroup-unreads))
10031 (push 'read to-marks)
10032 (gnus-info-set-read
10033 info (gnus-add-to-range (gnus-info-read info)
10034 (list (cdr art-group)))))
10036 ;; See whether the article is to be put in the cache.
10037 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10038 (marks (if expirable
10039 gnus-article-mark-lists
10040 (delete '(expirable . expire)
10042 gnus-article-mark-lists))))
10043 (to-article (cdr art-group)))
10045 ;; Enter the article into the cache in the new group,
10046 ;; if that is required.
10047 (when (and to-article
10049 (gnus-cache-possibly-enter-article
10050 to-group to-article
10051 (memq article gnus-newsgroup-marked)
10052 (memq article gnus-newsgroup-dormant)
10053 (memq article gnus-newsgroup-unreads)))
10055 (when (and gnus-preserve-marks
10057 ;; Copy any marks over to the new group.
10058 (when (and (equal to-group gnus-newsgroup-name)
10059 (not (memq article gnus-newsgroup-unreads)))
10060 ;; Mark this article as read in this group.
10061 (push (cons to-article gnus-read-mark)
10062 gnus-newsgroup-reads)
10063 ;; Increase the active status of this group.
10064 (setcdr (gnus-active to-group) to-article)
10065 (setcdr gnus-newsgroup-active to-article))
10068 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10069 (when (memq article (symbol-value
10070 (intern (format "gnus-newsgroup-%s"
10072 (push (cdar marks) to-marks)
10073 ;; If the other group is the same as this group,
10074 ;; then we have to add the mark to the list.
10075 (when (equal to-group gnus-newsgroup-name)
10076 (set (intern (format "gnus-newsgroup-%s"
10080 (intern (format "gnus-newsgroup-%s"
10082 ;; Copy the marks to other group.
10083 (gnus-add-marked-articles
10084 to-group (cdar marks) (list to-article) info)))
10085 (setq marks (cdr marks)))
10087 (when (and expirable
10088 gnus-mark-copied-or-moved-articles-as-expirable
10089 (not (memq 'expire to-marks)))
10090 ;; Mark this article as expirable.
10091 (push 'expire to-marks)
10092 (when (equal to-group gnus-newsgroup-name)
10093 (push to-article gnus-newsgroup-expirable))
10094 ;; Copy the expirable mark to other group.
10095 (gnus-add-marked-articles
10096 to-group 'expire (list to-article) info))
10098 (when (and to-marks
10099 (or gnus-propagate-marks
10100 (gnus-method-option-p
10101 (gnus-find-method-for-group to-group)
10103 (gnus-request-set-mark
10104 to-group (list (list (list to-article) 'add to-marks)))))
10106 (gnus-dribble-enter
10107 (concat "(gnus-group-set-info '"
10108 (gnus-prin1-to-string (gnus-get-info to-group))
10110 (concat "^(gnus-group-set-info '(\""
10111 (regexp-quote to-group) "\""))))
10113 ;; Update the Xref header in this article to point to
10114 ;; the new crossposted article we have just created.
10115 (when (eq action 'crosspost)
10116 (with-current-buffer copy-buf
10117 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10118 (nnheader-replace-header "Xref" new-xref)
10119 (gnus-request-replace-article
10120 article gnus-newsgroup-name (current-buffer) t)))
10122 ;; run the move/copy/crosspost/respool hook
10123 (run-hook-with-args 'gnus-summary-article-move-hook
10126 (assoc article (gnus-data-list nil)))
10127 gnus-newsgroup-name
10131 ;;;!!!Why is this necessary?
10132 (set-buffer gnus-summary-buffer)
10134 (when (eq action 'move)
10136 (gnus-summary-goto-subject article)
10137 (gnus-summary-mark-article article gnus-canceled-mark)))))
10138 (push article articles-to-update-marks))
10141 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10142 ;; Re-activate all groups that have been moved to.
10143 (with-current-buffer gnus-group-buffer
10144 (let ((gnus-group-marked to-groups))
10145 (gnus-group-get-new-news-this-group nil t)))
10147 (gnus-kill-buffer copy-buf)
10148 (gnus-summary-position-point)
10149 (gnus-set-mode-line 'summary)))
10151 (defun gnus-summary-push-marks-to-backend (article)
10153 (marks gnus-article-mark-lists))
10154 (unless (memq article gnus-newsgroup-unreads)
10157 (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10158 (memq article (symbol-value
10159 (intern (format "gnus-newsgroup-%s"
10161 (push (cdar marks) set))
10163 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)))))
10165 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10166 "Copy the current article to some other group.
10167 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10168 When called interactively, if TO-NEWSGROUP is nil, use the value of
10169 the variable `gnus-move-split-methods' for finding a default target
10171 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10172 re-spool using this method."
10174 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10176 (defun gnus-summary-crosspost-article (&optional n)
10177 "Crosspost the current article to some other group."
10179 (gnus-summary-move-article n nil nil 'crosspost))
10181 (defcustom gnus-summary-respool-default-method nil
10182 "Default method type for respooling an article.
10183 If nil, use to the current newsgroup method."
10185 :group 'gnus-summary-mail)
10187 (defun gnus-summary-respool-article (&optional n method)
10188 "Respool the current article.
10189 The article will be squeezed through the mail spooling process again,
10190 which means that it will be put in some mail newsgroup or other
10191 depending on `nnmail-split-methods'.
10192 If N is a positive number, respool the N next articles.
10193 If N is a negative number, respool the N previous articles.
10194 If N is nil and any articles have been marked with the process mark,
10195 respool those articles instead.
10197 Respooling can be done both from mail groups and \"real\" newsgroups.
10198 In the former case, the articles in question will be moved from the
10199 current group into whatever groups they are destined to. In the
10200 latter case, they will be copied into the relevant groups."
10202 (list current-prefix-arg
10203 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10205 (symbol-name (or gnus-summary-respool-default-method
10206 (car (gnus-find-method-for-group
10207 gnus-newsgroup-name)))))
10209 (gnus-completing-read
10210 "Backend to use when respooling"
10211 methods t nil 'gnus-mail-method-history methname))
10214 ((zerop (length (setq ms (gnus-servers-using-backend
10215 (intern method)))))
10216 (list (intern method) ""))
10220 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10221 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10224 (error "No method given for respooling"))
10225 (if (assoc (symbol-name
10226 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10227 (gnus-methods-using 'respool))
10228 (gnus-summary-move-article n nil method)
10229 (gnus-summary-copy-article n nil method)))
10231 (defun gnus-summary-import-article (file &optional edit)
10232 "Import an arbitrary file into a mail newsgroup."
10233 (interactive "fImport file: \nP")
10234 (let ((group gnus-newsgroup-name)
10235 (now (current-time))
10236 atts lines group-art)
10237 (unless (gnus-check-backend-function 'request-accept-article group)
10238 (error "%s does not support article importing" group))
10239 (or (file-readable-p file)
10240 (not (file-regular-p file))
10241 (error "Can't read %s" file))
10242 (with-current-buffer (gnus-get-buffer-create " *import file*")
10244 (nnheader-insert-file-contents file)
10245 (goto-char (point-min))
10246 (if (nnheader-article-p)
10248 (goto-char (point-min))
10249 (search-forward "\n\n" nil t)
10250 (narrow-to-region (point-min) (1- (point)))
10251 (goto-char (point-min))
10252 (unless (re-search-forward "^date:" nil t)
10253 (goto-char (point-max))
10254 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10255 ;; This doesn't look like an article, so we fudge some headers.
10256 (setq atts (file-attributes file)
10257 lines (count-lines (point-min) (point-max)))
10258 (insert "From: " (read-string "From: ") "\n"
10259 "Subject: " (read-string "Subject: ") "\n"
10260 "Date: " (message-make-date (nth 5 atts)) "\n"
10261 "Message-ID: " (message-make-message-id) "\n"
10262 "Lines: " (int-to-string lines) "\n"
10263 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10264 (setq group-art (gnus-request-accept-article group nil t))
10265 (kill-buffer (current-buffer)))
10266 (setq gnus-newsgroup-active (gnus-activate-group group))
10268 (gnus-summary-goto-article (cdr group-art) nil t)
10270 (gnus-summary-edit-article))))
10272 (defun gnus-summary-create-article ()
10273 "Create an article in a mail newsgroup."
10275 (let ((group gnus-newsgroup-name)
10276 (now (current-time))
10278 (unless (gnus-check-backend-function 'request-accept-article group)
10279 (error "%s does not support article importing" group))
10280 (with-current-buffer (gnus-get-buffer-create " *import file*")
10282 (goto-char (point-min))
10283 ;; This doesn't look like an article, so we fudge some headers.
10284 (insert "From: " (read-string "From: ") "\n"
10285 "Subject: " (read-string "Subject: ") "\n"
10286 "Date: " (message-make-date now) "\n"
10287 "Message-ID: " (message-make-message-id) "\n")
10288 (setq group-art (gnus-request-accept-article group nil t))
10289 (kill-buffer (current-buffer)))
10290 (setq gnus-newsgroup-active (gnus-activate-group group))
10292 (gnus-summary-goto-article (cdr group-art) nil t)
10293 (gnus-summary-edit-article)))
10295 (defun gnus-summary-article-posted-p ()
10296 "Say whether the current (mail) article is available from news as well.
10297 This will be the case if the article has both been mailed and posted."
10299 (let ((id (mail-header-references (gnus-summary-article-header)))
10300 (gnus-override-method (car (gnus-refer-article-methods))))
10301 (if (gnus-request-head id "")
10302 (gnus-message 2 "The current message was found on %s"
10303 gnus-override-method)
10304 (gnus-message 2 "The current message couldn't be found on %s"
10305 gnus-override-method)
10308 (defun gnus-summary-expire-articles (&optional now)
10309 "Expire all articles that are marked as expirable in the current group."
10311 (when (and (not gnus-group-is-exiting-without-update-p)
10312 (gnus-check-backend-function
10313 'request-expire-articles gnus-newsgroup-name))
10314 ;; This backend supports expiry.
10315 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10316 (expirable (if total
10318 ;; We need to update the info for
10319 ;; this group for `gnus-list-of-read-articles'
10320 ;; to give us the right answer.
10321 (gnus-run-hooks 'gnus-exit-group-hook)
10322 (gnus-summary-update-info)
10323 (gnus-list-of-read-articles gnus-newsgroup-name))
10324 (setq gnus-newsgroup-expirable
10325 (sort gnus-newsgroup-expirable '<))))
10326 (expiry-wait (if now 'immediate
10327 (gnus-group-find-parameter
10328 gnus-newsgroup-name 'expiry-wait)))
10329 (nnmail-expiry-target
10330 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10331 nnmail-expiry-target))
10334 ;; There are expirable articles in this group, so we run them
10335 ;; through the expiry process.
10336 (gnus-message 6 "Expiring articles...")
10337 (when (gnus-check-group gnus-newsgroup-name)
10338 ;; The list of articles that weren't expired is returned.
10341 (let ((nnmail-expiry-wait-function nil)
10342 (nnmail-expiry-wait expiry-wait))
10343 (setq es (gnus-request-expire-articles
10344 expirable gnus-newsgroup-name)))
10345 (setq es (gnus-request-expire-articles
10346 expirable gnus-newsgroup-name)))
10348 (setq gnus-newsgroup-expirable es))
10349 ;; We go through the old list of expirable, and mark all
10350 ;; really expired articles as nonexistent.
10351 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10352 (let ((gnus-use-cache nil))
10353 (dolist (article expirable)
10354 (when (and (not (memq article es))
10355 (gnus-data-find article))
10356 (gnus-summary-mark-article article gnus-canceled-mark)
10357 (run-hook-with-args 'gnus-summary-article-expire-hook
10360 (assoc article (gnus-data-list nil)))
10361 gnus-newsgroup-name
10364 (gnus-message 6 "Expiring articles...done")))))
10366 (defun gnus-summary-expire-articles-now ()
10367 "Expunge all expirable articles in the current group.
10368 This means that *all* articles that are marked as expirable will be
10369 deleted forever, right now."
10371 (or gnus-expert-user
10373 "Are you really, really sure you want to delete all expirable messages? ")
10375 (gnus-summary-expire-articles t))
10377 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10378 (defun gnus-summary-delete-article (&optional n)
10379 "Delete the N next (mail) articles.
10380 This command actually deletes articles. This is not a marking
10381 command. The article will disappear forever from your life, never to
10384 If N is negative, delete backwards.
10385 If N is nil and articles have been marked with the process mark,
10386 delete these instead.
10388 If `gnus-novice-user' is non-nil you will be asked for
10389 confirmation before the articles are deleted."
10391 (unless (gnus-check-backend-function 'request-expire-articles
10392 gnus-newsgroup-name)
10393 (error "The current newsgroup does not support article deletion"))
10394 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10395 (error "Couldn't open server"))
10396 ;; Compute the list of articles to delete.
10397 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10398 (nnmail-expiry-target 'delete)
10400 (if (and gnus-novice-user
10401 (not (gnus-yes-or-no-p
10402 (format "Do you really want to delete %s forever? "
10403 (if (> (length articles) 1)
10404 (format "these %s articles" (length articles))
10405 "this article")))))
10407 ;; Delete the articles.
10408 (setq not-deleted (gnus-request-expire-articles
10409 articles gnus-newsgroup-name 'force))
10412 (gnus-summary-remove-process-mark (car articles))
10413 ;; The backend might not have been able to delete the article
10415 (unless (memq (car articles) not-deleted)
10416 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10417 (let* ((article (car articles))
10418 (ghead (gnus-data-header
10419 (assoc article (gnus-data-list nil)))))
10420 (run-hook-with-args 'gnus-summary-article-delete-hook
10421 'delete ghead gnus-newsgroup-name nil
10423 (setq articles (cdr articles))))
10425 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10426 (gnus-summary-position-point)
10427 (gnus-set-mode-line 'summary)
10430 (defun gnus-summary-edit-article (&optional arg)
10431 "Edit the current article.
10432 This will have permanent effect only in mail groups.
10433 If ARG is nil, edit the decoded articles.
10434 If ARG is 1, edit the raw articles.
10435 If ARG is 2, edit the raw articles even in read-only groups.
10436 If ARG is 3, edit the articles with the current handles.
10437 Otherwise, allow editing of articles even in read-only
10440 (let (force raw current-handles)
10449 (setq current-handles
10450 (and (gnus-buffer-live-p gnus-article-buffer)
10451 (with-current-buffer gnus-article-buffer
10453 gnus-article-mime-handles
10454 (setq gnus-article-mime-handles nil))))))
10457 (when (and raw (not force)
10458 (member gnus-newsgroup-name '("nndraft:delayed"
10461 (error "Can't edit the raw article in group %s"
10462 gnus-newsgroup-name))
10463 (with-current-buffer gnus-summary-buffer
10464 (let ((mail-parse-charset gnus-newsgroup-charset)
10465 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10466 (gnus-set-global-variables)
10467 (when (and (not force)
10468 (gnus-group-read-only-p))
10469 (error "The current newsgroup does not support article editing"))
10470 (gnus-summary-show-article t)
10471 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10472 (with-current-buffer gnus-article-buffer
10473 (mm-enable-multibyte)))
10474 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10476 (gnus-article-edit-article
10479 (let ((mbl mml-buffer-list))
10480 (setq mml-buffer-list nil)
10481 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10482 (mime-to-mml ,'current-handles))
10483 (let ((mbl1 mml-buffer-list))
10484 (setq mml-buffer-list mbl)
10485 (set (make-local-variable 'mml-buffer-list) mbl1))
10486 (gnus-make-local-hook 'kill-buffer-hook)
10487 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10488 `(lambda (no-highlight)
10489 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10490 (message-options message-options)
10491 (message-options-set-recipient)
10492 (mail-parse-ignored-charsets
10493 ',gnus-newsgroup-ignored-charsets)
10494 (rfc2047-header-encoding-alist
10495 ',(let ((charset (gnus-group-name-charset
10496 (gnus-find-method-for-group
10497 gnus-newsgroup-name)
10498 gnus-newsgroup-name)))
10499 (append (list (cons "Newsgroups" charset)
10500 (cons "Followup-To" charset)
10501 (cons "Xref" charset))
10502 rfc2047-header-encoding-alist))))
10503 ,(if (not raw) '(progn
10505 (mml-destroy-buffers)
10506 (remove-hook 'kill-buffer-hook
10507 'mml-destroy-buffers t)
10508 (kill-local-variable 'mml-buffer-list)))
10509 (gnus-summary-edit-article-done
10510 ,(or (mail-header-references gnus-current-headers) "")
10511 ,(gnus-group-read-only-p)
10512 ,gnus-summary-buffer no-highlight))))))))
10514 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10516 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10518 "Make edits to the current article permanent."
10521 ;; The buffer restriction contains the entire article if it exists.
10522 (when (article-goto-body)
10523 (let ((lines (count-lines (point) (point-max)))
10524 (length (- (point-max) (point)))
10525 (case-fold-search t)
10526 (body (copy-marker (point))))
10527 (goto-char (point-min))
10528 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10529 (delete-region (match-beginning 1) (match-end 1))
10530 (insert (number-to-string length)))
10531 (goto-char (point-min))
10532 (when (re-search-forward
10533 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10534 (delete-region (match-beginning 1) (match-end 1))
10535 (insert (number-to-string length)))
10536 (goto-char (point-min))
10537 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10538 (delete-region (match-beginning 1) (match-end 1))
10539 (insert (number-to-string lines))))))
10540 ;; Replace the article.
10541 (let ((buf (current-buffer))
10542 (article (cdr gnus-article-current))
10545 (insert-buffer-substring buf)
10546 (if (and (not read-only)
10547 (not (setq replace-result
10548 (gnus-request-replace-article
10549 article (car gnus-article-current)
10550 (current-buffer) t))))
10551 (error "Couldn't replace article")
10552 ;; If we got a number back, then that's the new article number
10553 ;; for this article. Otherwise, the article number didn't change.
10554 (when (numberp replace-result)
10555 (with-current-buffer gnus-summary-buffer
10556 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10557 (gnus-summary-limit gnus-newsgroup-limit)
10558 (setq article replace-result)
10559 (gnus-summary-goto-subject article t)))
10560 ;; Update the summary buffer.
10561 (if (and references
10562 (equal (message-tokenize-header references " ")
10563 (message-tokenize-header
10564 (or (message-fetch-field "references") "") " ")))
10565 ;; We only have to update this line.
10568 (message-narrow-to-head)
10569 (let ((head (buffer-substring-no-properties
10570 (point-min) (point-max)))
10573 (insert (format "211 %d Article retrieved.\n" article))
10576 (let ((nntp-server-buffer (current-buffer)))
10577 (setq header (car (gnus-get-newsgroup-headers nil t))))
10578 (with-current-buffer gnus-summary-buffer
10579 (gnus-data-set-header (gnus-data-find article) header)
10580 (gnus-summary-update-article-line article header)
10581 (if (gnus-summary-goto-subject article nil t)
10582 (gnus-summary-update-secondary-mark article)))))))
10584 (set-buffer (or buffer gnus-summary-buffer))
10585 (gnus-summary-update-article article)
10586 (if (gnus-summary-goto-subject article nil t)
10587 (gnus-summary-update-secondary-mark article)))
10588 ;; Prettify the article buffer again.
10589 (unless no-highlight
10590 (with-current-buffer gnus-article-buffer
10591 ;;!!! Fix this -- article should be rehighlighted.
10592 ;;(gnus-run-hooks 'gnus-article-display-hook)
10593 (set-buffer gnus-original-article-buffer)
10594 (gnus-request-article
10595 article (car gnus-article-current) (current-buffer))))
10596 ;; Prettify the summary buffer line.
10597 (when (gnus-visual-p 'summary-highlight 'highlight)
10598 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10600 (defun gnus-summary-edit-wash (key)
10601 "Perform editing command KEY in the article buffer."
10605 (message "%s" (concat (this-command-keys) "- "))
10608 (gnus-summary-edit-article)
10609 (execute-kbd-macro (concat (this-command-keys) key))
10610 (gnus-article-edit-done))
10614 (defun gnus-summary-respool-query (&optional silent trace)
10615 "Query where the respool algorithm would put this article."
10617 (let (gnus-mark-article-hook)
10618 (gnus-summary-select-article)
10619 (with-current-buffer gnus-original-article-buffer
10620 (let ((groups (nnmail-article-group 'identity trace)))
10623 (message "This message would go to %s"
10624 (mapconcat 'car groups ", "))
10625 (message "This message would go to no groups"))
10628 (defun gnus-summary-respool-trace ()
10629 "Trace where the respool algorithm would put this article.
10630 Display a buffer showing all fancy splitting patterns which matched."
10632 (gnus-summary-respool-query nil t))
10634 ;; Summary marking commands.
10636 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10637 "Mark articles which has the same subject as read, and then select the next.
10638 If UNMARK is positive, remove any kind of mark.
10639 If UNMARK is negative, tick articles."
10642 (setq unmark (prefix-numeric-value unmark)))
10644 (gnus-summary-mark-same-subject
10645 (gnus-summary-article-subject) unmark)))
10646 ;; Select next unread article. If auto-select-same mode, should
10647 ;; select the first unread article.
10648 (gnus-summary-next-article t (and gnus-auto-select-same
10649 (gnus-summary-article-subject)))
10650 (gnus-message 7 "%d article%s marked as %s"
10651 count (if (= count 1) " is" "s are")
10652 (if unmark "unread" "read"))))
10654 (defun gnus-summary-kill-same-subject (&optional unmark)
10655 "Mark articles which has the same subject as read.
10656 If UNMARK is positive, remove any kind of mark.
10657 If UNMARK is negative, tick articles."
10660 (setq unmark (prefix-numeric-value unmark)))
10662 (gnus-summary-mark-same-subject
10663 (gnus-summary-article-subject) unmark)))
10664 ;; If marked as read, go to next unread subject.
10665 (when (null unmark)
10666 ;; Go to next unread subject.
10667 (gnus-summary-next-subject 1 t))
10668 (gnus-message 7 "%d articles are marked as %s"
10669 count (if unmark "unread" "read"))))
10671 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10672 "Mark articles with same SUBJECT as read, and return marked number.
10673 If optional argument UNMARK is positive, remove any kinds of marks.
10674 If optional argument UNMARK is negative, mark articles as unread instead."
10678 ((null unmark) ; Mark as read.
10681 (gnus-summary-mark-article-as-read gnus-killed-mark)
10682 (gnus-summary-show-thread) t)
10683 (gnus-summary-find-subject subject))
10684 (setq count (1+ count))))
10685 ((> unmark 0) ; Tick.
10688 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10689 (gnus-summary-show-thread) t)
10690 (gnus-summary-find-subject subject))
10691 (setq count (1+ count))))
10692 (t ; Mark as unread.
10695 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10696 (gnus-summary-show-thread) t)
10697 (gnus-summary-find-subject subject))
10698 (setq count (1+ count)))))
10699 (gnus-set-mode-line 'summary)
10700 ;; Return the number of marked articles.
10703 (defun gnus-summary-mark-as-processable (n &optional unmark)
10704 "Set the process mark on the next N articles.
10705 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10706 the process mark instead. The difference between N and the actual
10707 number of articles marked is returned."
10709 (if (and (null n) (gnus-region-active-p))
10710 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10711 (setq n (prefix-numeric-value n))
10712 (let ((backward (< n 0))
10717 (gnus-summary-remove-process-mark
10718 (gnus-summary-article-number))
10719 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10720 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10723 (gnus-message 7 "No more articles"))
10724 (gnus-summary-recenter)
10725 (gnus-summary-position-point)
10728 (defun gnus-summary-unmark-as-processable (n)
10729 "Remove the process mark from the next N articles.
10730 If N is negative, unmark backward instead. The difference between N and
10731 the actual number of articles unmarked is returned."
10733 (gnus-summary-mark-as-processable n t))
10735 (defun gnus-summary-unmark-all-processable ()
10736 "Remove the process mark from all articles."
10739 (while gnus-newsgroup-processable
10740 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10741 (gnus-summary-position-point))
10743 (defun gnus-summary-add-mark (article type)
10744 "Mark ARTICLE with a mark of TYPE."
10745 (let ((vtype (car (assq type gnus-article-mark-lists)))
10748 (error "No such mark type: %s" type)
10749 (setq var (intern (format "gnus-newsgroup-%s" type)))
10750 (set var (cons article (symbol-value var)))
10751 (if (memq type '(processable cached replied forwarded recent saved))
10752 (gnus-summary-update-secondary-mark article)
10753 ;;; !!! This is bogus. We should find out what primary
10754 ;;; !!! mark we want to set.
10755 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10757 (defun gnus-summary-mark-as-expirable (n)
10758 "Mark N articles forward as expirable.
10759 If N is negative, mark backward instead. The difference between N and
10760 the actual number of articles marked is returned."
10762 (gnus-summary-mark-forward n gnus-expirable-mark))
10764 (defun gnus-summary-mark-as-spam (n)
10765 "Mark N articles forward as spam.
10766 If N is negative, mark backward instead. The difference between N and
10767 the actual number of articles marked is returned."
10769 (gnus-summary-mark-forward n gnus-spam-mark))
10771 (defun gnus-summary-mark-article-as-replied (article)
10772 "Mark ARTICLE as replied to and update the summary line.
10773 ARTICLE can also be a list of articles."
10774 (interactive (list (gnus-summary-article-number)))
10775 (let ((articles (if (listp article) article (list article))))
10776 (dolist (article articles)
10777 (unless (numberp article)
10778 (error "%s is not a number" article))
10779 (push article gnus-newsgroup-replied)
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-mark-article-as-forwarded (article)
10785 "Mark ARTICLE as forwarded and update the summary line.
10786 ARTICLE can also be a list of articles."
10787 (let ((articles (if (listp article) article (list article))))
10788 (dolist (article articles)
10789 (push article gnus-newsgroup-forwarded)
10790 (let ((inhibit-read-only t))
10791 (when (gnus-summary-goto-subject article nil t)
10792 (gnus-summary-update-secondary-mark article))))))
10794 (defun gnus-summary-set-bookmark (article)
10795 "Set a bookmark in current article."
10796 (interactive (list (gnus-summary-article-number)))
10797 (when (or (not (get-buffer gnus-article-buffer))
10798 (not gnus-current-article)
10799 (not gnus-article-current)
10800 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10801 (error "No current article selected"))
10802 ;; Remove old bookmark, if one exists.
10803 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10804 ;; Set the new bookmark, which is on the form
10805 ;; (article-number . line-number-in-body).
10808 (with-current-buffer gnus-article-buffer
10812 (article-goto-body)
10815 gnus-newsgroup-bookmarks)
10816 (gnus-message 6 "A bookmark has been added to the current article."))
10818 (defun gnus-summary-remove-bookmark (article)
10819 "Remove the bookmark from the current article."
10820 (interactive (list (gnus-summary-article-number)))
10821 ;; Remove old bookmark, if one exists.
10822 (if (not (assq article gnus-newsgroup-bookmarks))
10823 (gnus-message 6 "No bookmark in current article.")
10824 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10825 (gnus-message 6 "Removed bookmark.")))
10827 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10828 (defun gnus-summary-mark-as-dormant (n)
10829 "Mark N articles forward as dormant.
10830 If N is negative, mark backward instead. The difference between N and
10831 the actual number of articles marked is returned."
10833 (gnus-summary-mark-forward n gnus-dormant-mark))
10835 (defun gnus-summary-set-process-mark (article)
10836 "Set the process mark on ARTICLE and update the summary line."
10837 (setq gnus-newsgroup-processable
10839 (delq article gnus-newsgroup-processable)))
10840 (when (gnus-summary-goto-subject article)
10841 (gnus-summary-show-thread)
10842 (gnus-summary-goto-subject article)
10843 (gnus-summary-update-secondary-mark article)))
10845 (defun gnus-summary-remove-process-mark (&rest articles)
10846 "Remove the process mark from ARTICLES and update the summary line."
10847 (dolist (article articles)
10848 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10849 (when (gnus-summary-goto-subject article)
10850 (gnus-summary-show-thread)
10851 (gnus-summary-goto-subject article)
10852 (gnus-summary-update-secondary-mark article)))
10855 (defun gnus-summary-set-saved-mark (article)
10856 "Set the process mark on ARTICLE and update the summary line."
10857 (push article gnus-newsgroup-saved)
10858 (when (gnus-summary-goto-subject article)
10859 (gnus-summary-update-secondary-mark article)))
10861 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10862 "Mark N articles as read forwards.
10863 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10864 The difference between N and the actual number of articles marked is
10866 If NO-EXPIRE, auto-expiry will be inhibited."
10868 (gnus-summary-show-thread)
10869 (let ((backward (< n 0))
10870 (gnus-summary-goto-unread
10871 (and gnus-summary-goto-unread
10872 (not (eq gnus-summary-goto-unread 'never))
10873 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10874 gnus-ticked-mark gnus-dormant-mark)))))
10876 (mark (or mark gnus-del-mark)))
10877 (while (and (> n 0)
10878 (gnus-summary-mark-article nil mark no-expire)
10879 (zerop (gnus-summary-next-subject
10881 (and gnus-summary-goto-unread
10882 (not (eq gnus-summary-goto-unread 'never)))
10886 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10887 (gnus-summary-recenter)
10888 (gnus-summary-position-point)
10889 (gnus-set-mode-line 'summary)
10892 (defun gnus-summary-mark-article-as-read (mark)
10893 "Mark the current article quickly as read with MARK."
10894 (let ((article (gnus-summary-article-number)))
10895 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10896 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10897 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10898 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10899 (push (cons article mark) gnus-newsgroup-reads)
10900 ;; Possibly remove from cache, if that is used.
10901 (when gnus-use-cache
10902 (gnus-cache-enter-remove-article article))
10903 ;; Allow the backend to change the mark.
10904 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10905 ;; Check for auto-expiry.
10906 (when (and gnus-newsgroup-auto-expire
10907 (memq mark gnus-auto-expirable-marks))
10908 (setq mark gnus-expirable-mark)
10909 ;; Let the backend know about the mark change.
10910 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10911 (push article gnus-newsgroup-expirable))
10912 ;; Set the mark in the buffer.
10913 (gnus-summary-update-mark mark 'unread)
10916 (defun gnus-summary-mark-article-as-unread (mark)
10917 "Mark the current article quickly as unread with MARK."
10918 (let* ((article (gnus-summary-article-number))
10919 (old-mark (gnus-summary-article-mark article)))
10920 ;; Allow the backend to change the mark.
10921 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10922 (if (eq mark old-mark)
10926 (gnus-error 1 "Can't mark negative article numbers")
10928 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10929 (setq gnus-newsgroup-spam-marked
10930 (delq article gnus-newsgroup-spam-marked))
10931 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10932 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10933 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10934 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10935 (cond ((= mark gnus-ticked-mark)
10936 (setq gnus-newsgroup-marked
10937 (gnus-add-to-sorted-list gnus-newsgroup-marked
10939 ((= mark gnus-spam-mark)
10940 (setq gnus-newsgroup-spam-marked
10941 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10943 ((= mark gnus-dormant-mark)
10944 (setq gnus-newsgroup-dormant
10945 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10948 (setq gnus-newsgroup-unreads
10949 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10951 (gnus-alist-pull article gnus-newsgroup-reads)
10953 ;; See whether the article is to be put in the cache.
10954 (and gnus-use-cache
10955 (vectorp (gnus-summary-article-header article))
10957 (gnus-cache-possibly-enter-article
10958 gnus-newsgroup-name article
10959 (= mark gnus-ticked-mark)
10960 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10963 (gnus-summary-update-mark mark 'unread)
10966 (defun gnus-summary-mark-article (&optional article mark no-expire)
10967 "Mark ARTICLE with MARK. MARK can be any character.
10968 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10969 `??' (dormant) and `?E' (expirable).
10970 If MARK is nil, then the default character `?r' is used.
10971 If ARTICLE is nil, then the article on the current line will be
10973 If NO-EXPIRE, auto-expiry will be inhibited."
10974 ;; The mark might be a string.
10975 (when (stringp mark)
10976 (setq mark (aref mark 0)))
10977 ;; If no mark is given, then we check auto-expiring.
10979 (setq mark gnus-del-mark))
10980 (when (and (not no-expire)
10981 gnus-newsgroup-auto-expire
10982 (memq mark gnus-auto-expirable-marks))
10983 (setq mark gnus-expirable-mark))
10984 (let ((article (or article (gnus-summary-article-number)))
10985 (old-mark (gnus-summary-article-mark article)))
10986 ;; Allow the backend to change the mark.
10987 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10988 (if (eq mark old-mark)
10991 (error "No article on current line"))
10992 (if (not (if (or (= mark gnus-unread-mark)
10993 (= mark gnus-ticked-mark)
10994 (= mark gnus-spam-mark)
10995 (= mark gnus-dormant-mark))
10996 (gnus-mark-article-as-unread article mark)
10997 (gnus-mark-article-as-read article mark)))
10999 ;; See whether the article is to be put in the cache.
11000 (and gnus-use-cache
11001 (not (= mark gnus-canceled-mark))
11002 (vectorp (gnus-summary-article-header article))
11004 (gnus-cache-possibly-enter-article
11005 gnus-newsgroup-name article
11006 (= mark gnus-ticked-mark)
11007 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11009 (when (gnus-summary-goto-subject article nil t)
11010 (let ((inhibit-read-only t))
11011 (gnus-summary-show-thread)
11013 (gnus-summary-update-mark mark 'unread)
11016 (defun gnus-summary-update-secondary-mark (article)
11017 "Update the secondary (read, process, cache) mark."
11018 (gnus-summary-update-mark
11019 (cond ((memq article gnus-newsgroup-processable)
11021 ((memq article gnus-newsgroup-cached)
11023 ((memq article gnus-newsgroup-replied)
11025 ((memq article gnus-newsgroup-forwarded)
11026 gnus-forwarded-mark)
11027 ((memq article gnus-newsgroup-saved)
11029 ((memq article gnus-newsgroup-unseen)
11033 (when (gnus-visual-p 'summary-highlight 'highlight)
11034 (gnus-summary-highlight-line)
11035 (gnus-run-hooks 'gnus-summary-update-hook))
11038 (defun gnus-summary-update-download-mark (article)
11039 "Update the download mark."
11040 (gnus-summary-update-mark
11041 (cond ((memq article gnus-newsgroup-undownloaded)
11042 gnus-undownloaded-mark)
11043 (gnus-newsgroup-agentized
11044 gnus-downloaded-mark)
11048 (gnus-summary-update-line t)
11051 (defun gnus-summary-update-mark (mark type)
11052 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11053 (inhibit-read-only t))
11054 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11056 (when (looking-at "\r")
11058 (when (<= (+ forward (point)) (point-max))
11059 ;; Go to the right position on the line.
11060 (goto-char (+ forward (point)))
11061 ;; Replace the old mark with the new mark.
11063 (mm-subst-char-in-string
11065 (buffer-substring (point) (1+ (point))))))
11066 (delete-region (point) (1+ (point)))
11067 (insert to-insert))
11068 ;; Optionally update the marks by some user rule.
11069 (when (eq type 'unread)
11070 (gnus-data-set-mark
11071 (gnus-data-find (gnus-summary-article-number)) mark)
11072 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11074 (defun gnus-mark-article-as-read (article &optional mark)
11075 "Enter ARTICLE in the pertinent lists and remove it from others."
11076 ;; Make the article expirable.
11077 (let ((mark (or mark gnus-del-mark)))
11078 (setq gnus-newsgroup-expirable
11079 (if (= mark gnus-expirable-mark)
11080 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11081 (delq article gnus-newsgroup-expirable)))
11082 ;; Remove from unread and marked lists.
11083 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11084 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11085 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11086 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11087 (push (cons article mark) gnus-newsgroup-reads)
11088 ;; Possibly remove from cache, if that is used.
11089 (when gnus-use-cache
11090 (gnus-cache-enter-remove-article article))
11093 (defun gnus-mark-article-as-unread (article &optional mark)
11094 "Enter ARTICLE in the pertinent lists and remove it from others."
11095 (let ((mark (or mark gnus-ticked-mark)))
11098 (gnus-error 1 "Can't mark negative article numbers")
11100 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11101 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11102 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11103 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11104 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11106 ;; Unsuppress duplicates?
11107 (when gnus-suppress-duplicates
11108 (gnus-dup-unsuppress-article article))
11110 (cond ((= mark gnus-ticked-mark)
11111 (setq gnus-newsgroup-marked
11112 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11113 ((= mark gnus-spam-mark)
11114 (setq gnus-newsgroup-spam-marked
11115 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11117 ((= mark gnus-dormant-mark)
11118 (setq gnus-newsgroup-dormant
11119 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11121 (setq gnus-newsgroup-unreads
11122 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11123 (gnus-alist-pull article gnus-newsgroup-reads)
11126 (defun gnus-summary-tick-article-forward (n)
11127 "Tick N articles forwards.
11128 If N is negative, tick backwards instead.
11129 The difference between N and the number of articles ticked is returned."
11131 (gnus-summary-mark-forward n gnus-ticked-mark))
11133 (defun gnus-summary-tick-article-backward (n)
11134 "Tick N articles backwards.
11135 The difference between N and the number of articles ticked is returned."
11137 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11139 (defun gnus-summary-tick-article (&optional article clear-mark)
11140 "Mark current article as unread.
11141 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11142 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11144 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11145 gnus-ticked-mark)))
11147 (defun gnus-summary-mark-as-read-forward (n)
11148 "Mark N articles as read forwards.
11149 If N is negative, mark backwards instead.
11150 The difference between N and the actual number of articles marked is
11153 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11155 (defun gnus-summary-mark-as-read-backward (n)
11156 "Mark the N articles as read backwards.
11157 The difference between N and the actual number of articles marked is
11160 (gnus-summary-mark-forward
11161 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11163 (defun gnus-summary-mark-as-read (&optional article mark)
11164 "Mark current article as read.
11165 ARTICLE specifies the article to be marked as read.
11166 MARK specifies a string to be inserted at the beginning of the line."
11167 (gnus-summary-mark-article article mark))
11169 (defun gnus-summary-clear-mark-forward (n)
11170 "Clear marks from N articles forward.
11171 If N is negative, clear backward instead.
11172 The difference between N and the number of marks cleared is returned."
11174 (gnus-summary-mark-forward n gnus-unread-mark))
11176 (defun gnus-summary-clear-mark-backward (n)
11177 "Clear marks from N articles backward.
11178 The difference between N and the number of marks cleared is returned."
11180 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11182 (defun gnus-summary-mark-unread-as-read ()
11183 "Intended to be used by `gnus-mark-article-hook'."
11184 (when (memq gnus-current-article gnus-newsgroup-unreads)
11185 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11187 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11188 "Intended to be used by `gnus-mark-article-hook'."
11189 (let ((mark (gnus-summary-article-mark)))
11190 (when (or (gnus-unread-mark-p mark)
11191 (gnus-read-mark-p mark))
11192 (gnus-summary-mark-article gnus-current-article
11193 (or new-mark gnus-read-mark)))))
11195 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11196 "Intended to be used by `gnus-mark-article-hook'."
11197 (let ((mark (gnus-summary-article-mark)))
11198 (when (or (gnus-unread-mark-p mark)
11199 (gnus-read-mark-p mark))
11200 (gnus-summary-mark-article (gnus-summary-article-number)
11201 (or new-mark gnus-read-mark)))))
11203 (defun gnus-summary-mark-unread-as-ticked ()
11204 "Intended to be used by `gnus-mark-article-hook'."
11205 (when (memq gnus-current-article gnus-newsgroup-unreads)
11206 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11208 (defun gnus-summary-mark-region-as-read (point mark all)
11209 "Mark all unread articles between point and mark as read.
11210 If given a prefix, mark all articles between point and mark as read,
11211 even ticked and dormant ones."
11212 (interactive "r\nP")
11216 (beginning-of-line)
11221 (memq (setq article (gnus-summary-article-number))
11222 gnus-newsgroup-unreads))
11223 (gnus-summary-mark-article article gnus-del-mark))
11225 (gnus-summary-find-next))))))
11227 (defun gnus-summary-mark-below (score mark)
11228 "Mark articles with score less than SCORE with MARK."
11229 (interactive "P\ncMark: ")
11230 (setq score (if score
11231 (prefix-numeric-value score)
11232 (or gnus-summary-default-score 0)))
11233 (with-current-buffer gnus-summary-buffer
11234 (goto-char (point-min))
11237 (and (< (gnus-summary-article-score) score)
11238 (gnus-summary-mark-article nil mark))
11239 (gnus-summary-find-next)))))
11241 (defun gnus-summary-kill-below (&optional score)
11242 "Mark articles with score below SCORE as read."
11244 (gnus-summary-mark-below score gnus-killed-mark))
11246 (defun gnus-summary-clear-above (&optional score)
11247 "Clear all marks from articles with score above SCORE."
11249 (gnus-summary-mark-above score gnus-unread-mark))
11251 (defun gnus-summary-tick-above (&optional score)
11252 "Tick all articles with score above SCORE."
11254 (gnus-summary-mark-above score gnus-ticked-mark))
11256 (defun gnus-summary-mark-above (score mark)
11257 "Mark articles with score over SCORE with MARK."
11258 (interactive "P\ncMark: ")
11259 (setq score (if score
11260 (prefix-numeric-value score)
11261 (or gnus-summary-default-score 0)))
11262 (with-current-buffer gnus-summary-buffer
11263 (goto-char (point-min))
11265 (when (> (gnus-summary-article-score) score)
11266 (gnus-summary-mark-article nil mark))
11268 (gnus-summary-find-next)))))
11270 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11271 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11272 (defun gnus-summary-limit-include-expunged (&optional no-error)
11273 "Display all the hidden articles that were expunged for low scores."
11275 (let ((inhibit-read-only t))
11276 (let ((scored gnus-newsgroup-scored)
11279 (unless (gnus-summary-article-header (caar scored))
11280 (and (setq h (gnus-number-to-header (caar scored)))
11281 (< (cdar scored) gnus-summary-expunge-below)
11283 (setq scored (cdr scored)))
11285 (when (not no-error)
11286 (error "No expunged articles hidden"))
11287 (goto-char (point-min))
11288 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11289 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11290 (dolist (x headers)
11291 (push (mail-header-number x) gnus-newsgroup-limit))
11292 (gnus-summary-prepare-unthreaded (nreverse headers))
11293 (goto-char (point-min))
11294 (gnus-summary-position-point)
11297 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11298 "Mark all unread articles in this newsgroup as read.
11299 If prefix argument ALL is non-nil, ticked and dormant articles will
11300 also be marked as read.
11301 If QUIETLY is non-nil, no questions will be asked.
11303 If TO-HERE is non-nil, it should be a point in the buffer. All
11304 articles before (after, if REVERSE is set) this point will be marked
11307 Note that this function will only catch up the unread article
11308 in the current summary buffer limitation.
11310 The number of articles marked as read is returned."
11315 (not gnus-interactive-catchup) ;Without confirmation?
11319 "Mark absolutely all articles as read? "
11320 "Mark all unread articles as read? ")))
11322 (not gnus-newsgroup-adaptive)
11323 (not gnus-newsgroup-auto-expire)
11324 (not gnus-suppress-duplicates)
11325 (or (not gnus-use-cache)
11326 (eq gnus-use-cache 'passive)))
11329 (setq gnus-newsgroup-marked nil
11330 gnus-newsgroup-spam-marked nil
11331 gnus-newsgroup-dormant nil))
11332 (setq gnus-newsgroup-unreads
11333 (gnus-sorted-nunion
11334 (gnus-sorted-intersection gnus-newsgroup-unreads
11335 gnus-newsgroup-downloadable)
11336 (gnus-sorted-difference gnus-newsgroup-unfetched
11337 gnus-newsgroup-cached))))
11338 ;; We actually mark all articles as canceled, which we
11339 ;; have to do when using auto-expiry or adaptive scoring.
11340 (gnus-summary-show-all-threads)
11341 (if (and to-here reverse)
11343 (goto-char to-here)
11344 (gnus-summary-mark-current-read-and-unread-as-read
11346 (while (gnus-summary-find-next (not all))
11347 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11348 (when (gnus-summary-first-subject (not all))
11350 (if to-here (< (point) to-here) t)
11351 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11352 (gnus-summary-find-next (not all))))))
11353 (gnus-set-mode-line 'summary))
11355 (gnus-summary-position-point)))
11357 (defun gnus-summary-catchup-to-here (&optional all)
11358 "Mark all unticked articles before the current one as read.
11359 If ALL is non-nil, also mark ticked and dormant articles as read."
11362 (gnus-save-hidden-threads
11363 (let ((beg (point)))
11364 ;; We check that there are unread articles.
11365 (when (or all (gnus-summary-find-prev))
11366 (gnus-summary-catchup all t beg)))))
11367 (gnus-summary-position-point))
11369 (defun gnus-summary-catchup-from-here (&optional all)
11370 "Mark all unticked articles after (and including) the current one as read.
11371 If ALL is non-nil, also mark ticked and dormant articles as read."
11374 (gnus-save-hidden-threads
11375 (let ((beg (point)))
11376 ;; We check that there are unread articles.
11377 (when (or all (gnus-summary-find-next))
11378 (gnus-summary-catchup all t beg nil t)))))
11379 (gnus-summary-position-point))
11381 (defun gnus-summary-catchup-all (&optional quietly)
11382 "Mark all articles in this newsgroup as read.
11383 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11384 instead, which marks only unread articles as read."
11386 (gnus-summary-catchup t quietly))
11388 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11389 "Mark all unread articles in this group as read, then exit.
11390 If prefix argument ALL is non-nil, all articles are marked as read.
11391 If QUIETLY is non-nil, no questions will be asked."
11393 (when (gnus-summary-catchup all quietly nil 'fast)
11394 ;; Select next newsgroup or exit.
11395 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11396 (eq gnus-auto-select-next 'quietly))
11397 (gnus-summary-next-group nil)
11398 (gnus-summary-exit))))
11400 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11401 "Mark all articles in this newsgroup as read, and then exit.
11402 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11403 instead, which marks only unread articles as read."
11405 (gnus-summary-catchup-and-exit t quietly))
11407 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11408 "Mark all articles in this group as read and select the next group.
11409 If given a prefix, mark all articles, unread as well as ticked, as
11413 (gnus-summary-catchup all))
11414 (gnus-summary-next-group))
11416 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11417 "Mark all articles in this group as read and select the previous group.
11418 If given a prefix, mark all articles, unread as well as ticked, as
11422 (gnus-summary-catchup all))
11423 (gnus-summary-next-group nil nil t))
11429 (defmacro gnus-with-article (article &rest forms)
11430 "Select ARTICLE and perform FORMS in the original article buffer.
11431 Then replace the article with the result."
11433 ;; We don't want the article to be marked as read.
11434 (let (gnus-mark-article-hook)
11435 (gnus-summary-select-article t t nil ,article))
11436 (set-buffer gnus-original-article-buffer)
11438 (if (not (gnus-check-backend-function
11439 'request-replace-article (car gnus-article-current)))
11440 (gnus-message 5 "Read-only group; not replacing")
11441 (unless (gnus-request-replace-article
11442 ,article (car gnus-article-current)
11443 (current-buffer) t)
11444 (error "Couldn't replace article")))
11445 ;; The cache and backlog have to be flushed somewhat.
11446 (when gnus-keep-backlog
11447 (gnus-backlog-remove-article
11448 (car gnus-article-current) (cdr gnus-article-current)))
11449 (when gnus-use-cache
11450 (gnus-cache-update-article
11451 (car gnus-article-current) (cdr gnus-article-current)))))
11453 (put 'gnus-with-article 'lisp-indent-function 1)
11454 (put 'gnus-with-article 'edebug-form-spec '(form body))
11456 ;; Thread-based commands.
11458 (defun gnus-summary-articles-in-thread (&optional article)
11459 "Return a list of all articles in the current thread.
11460 If ARTICLE is non-nil, return all articles in the thread that starts
11461 with that article."
11462 (let* ((article (or article (gnus-summary-article-number)))
11463 (data (gnus-data-find-list article))
11464 (top-level (gnus-data-level (car data)))
11466 (cond ((null gnus-thread-operation-ignore-subject)
11467 (gnus-simplify-subject-re
11468 (mail-header-subject (gnus-data-header (car data)))))
11469 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11470 (gnus-simplify-subject-fuzzy
11471 (mail-header-subject (gnus-data-header (car data)))))
11473 (end-point (save-excursion
11474 (goto-char (gnus-data-pos (car data)))
11475 (if (gnus-summary-go-to-next-thread)
11476 (point) (point-max))))
11479 (< (gnus-data-pos (car data)) end-point))
11480 (when (or (not top-subject)
11481 (string= top-subject
11482 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11483 (gnus-simplify-subject-fuzzy
11484 (mail-header-subject
11485 (gnus-data-header (car data))))
11486 (gnus-simplify-subject-re
11487 (mail-header-subject
11488 (gnus-data-header (car data)))))))
11489 (push (gnus-data-number (car data)) articles))
11490 (unless (and (setq data (cdr data))
11491 (> (gnus-data-level (car data)) top-level))
11493 ;; Return the list of articles.
11494 (nreverse articles)))
11496 (defun gnus-summary-rethread-current ()
11497 "Rethread the thread the current article is part of."
11499 (let* ((gnus-show-threads t)
11500 (article (gnus-summary-article-number))
11501 (id (mail-header-id (gnus-summary-article-header)))
11502 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11504 (error "No article on the current line"))
11505 (gnus-rebuild-thread id)
11506 (gnus-summary-goto-subject article)))
11508 (defun gnus-summary-reparent-thread ()
11509 "Make the current article child of the marked (or previous) article.
11511 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11512 is non-nil or the Subject: of both articles are the same."
11514 (unless (not (gnus-group-read-only-p))
11515 (error "The current newsgroup does not support article editing"))
11516 (unless (<= (length gnus-newsgroup-processable) 1)
11517 (error "No more than one article may be marked"))
11518 (let ((child (gnus-summary-article-number))
11519 ;; First grab the marked article, otherwise one line up.
11520 (parent (if (not (null gnus-newsgroup-processable))
11521 (car gnus-newsgroup-processable)
11523 (if (eq (forward-line -1) 0)
11524 (gnus-summary-article-number)
11525 (error "Beginning of summary buffer"))))))
11526 (gnus-summary-reparent-children parent (list child))))
11528 (defun gnus-summary-reparent-children (parent children)
11529 "Make PARENT the parent of CHILDREN.
11530 When called interactively, PARENT is the current article and CHILDREN
11531 are the process-marked articles."
11533 (list (gnus-summary-article-number)
11534 (gnus-summary-work-articles nil)))
11535 (dolist (child children)
11536 (save-window-excursion
11537 (let ((gnus-article-buffer " *reparent*"))
11538 (unless (not (eq parent child))
11539 (error "An article may not be self-referential"))
11540 (let ((message-id (mail-header-id
11541 (gnus-summary-article-header parent))))
11542 (unless (and message-id (not (equal message-id "")))
11543 (error "No message-id in desired parent"))
11544 (gnus-with-article child
11546 (goto-char (point-min))
11547 (message-narrow-to-head)
11548 (if (re-search-forward "^References: " nil t)
11550 (re-search-forward "^[^ \t]" nil t)
11553 (insert " " message-id))
11554 (insert "References: " message-id "\n"))))
11555 (set-buffer gnus-summary-buffer)
11556 (gnus-summary-unmark-all-processable)
11557 (gnus-summary-update-article child)
11558 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11559 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11560 (gnus-summary-rethread-current)
11561 (gnus-message 3 "Article %d is now the child of article %d"
11564 (defun gnus-summary-toggle-threads (&optional arg)
11565 "Toggle showing conversation threads.
11566 If ARG is positive number, turn showing conversation threads on."
11568 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11569 (setq gnus-show-threads
11570 (if (null arg) (not gnus-show-threads)
11571 (> (prefix-numeric-value arg) 0)))
11572 (gnus-summary-prepare)
11573 (gnus-summary-goto-subject current)
11574 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11575 (gnus-summary-position-point)))
11578 (if (fboundp 'remove-overlays)
11579 (defalias 'gnus-remove-overlays 'remove-overlays)
11580 (defun gnus-remove-overlays (beg end name val)
11581 "Clear BEG and END of overlays whose property NAME has value VAL.
11582 For compatibility with XEmacs."
11583 (dolist (ov (gnus-overlays-in beg end))
11584 (when (eq (gnus-overlay-get ov name) val)
11585 (gnus-delete-overlay ov))))))
11587 (defun gnus-summary-show-all-threads ()
11588 "Show all threads."
11590 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11591 (gnus-summary-position-point))
11593 (defsubst gnus-summary--inv (p)
11594 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11596 (defun gnus-summary-show-thread ()
11597 "Show thread subtrees.
11598 Returns nil if no thread was there to be shown."
11600 (let* ((orig (point))
11601 (end (point-at-eol))
11602 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11603 ;; Leave point at bol
11604 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11606 (if (fboundp 'next-single-char-property-change)
11607 ;; Note: XEmacs version of n-s-c-p-c may return nil
11608 (or (next-single-char-property-change end 'invisible)
11613 (eq (get-char-property (point) 'invisible)
11617 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11619 (gnus-summary-position-point)
11622 (defun gnus-summary-maybe-hide-threads ()
11623 "If requested, hide the threads that should be hidden."
11624 (when (and gnus-show-threads
11625 gnus-thread-hide-subtree)
11626 (gnus-summary-hide-all-threads
11627 (if (or (consp gnus-thread-hide-subtree)
11628 (functionp gnus-thread-hide-subtree))
11629 (gnus-make-predicate gnus-thread-hide-subtree)
11632 ;;; Hiding predicates.
11634 (defun gnus-article-unread-p (header)
11635 (memq (mail-header-number header) gnus-newsgroup-unreads))
11637 (defun gnus-article-unseen-p (header)
11638 (memq (mail-header-number header) gnus-newsgroup-unseen))
11640 (defun gnus-map-articles (predicate articles)
11641 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11642 (apply 'gnus-or (mapcar predicate
11643 (mapcar (lambda (number)
11644 (gnus-summary-article-header number))
11647 (defun gnus-summary-hide-all-threads (&optional predicate)
11648 "Hide all thread subtrees.
11649 If PREDICATE is supplied, threads that satisfy this predicate
11650 will not be hidden."
11653 (goto-char (point-min))
11658 (when (zerop (mod count 1000))
11659 (message "Hiding all threads... %d" count))
11660 (when (or (not predicate)
11662 predicate (gnus-summary-article-children)))
11663 (gnus-summary-hide-thread))
11664 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11665 (gnus-summary-position-point))
11667 (defun gnus-summary-hide-thread ()
11668 "Hide thread subtrees.
11669 If PREDICATE is supplied, threads that satisfy this predicate
11670 will not be hidden.
11671 Returns nil if no threads were there to be hidden."
11673 (let ((start (point))
11674 (starteol (line-end-position))
11675 (article (gnus-summary-article-number)))
11677 ;; Go forward until either the buffer ends or the subthread ends.
11678 (when (and (not (eobp))
11679 (or (zerop (gnus-summary-next-thread 1 t))
11680 (goto-char (point-max))))
11681 (if (and (> (point) start)
11682 ;; FIXME: this should actually search for a non-invisible \n.
11683 (search-backward "\n" start t))
11685 (when (> (point) starteol)
11686 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11687 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11688 (gnus-overlay-put ol 'invisible 'gnus-sum)
11689 (gnus-overlay-put ol 'evaporate t)))
11690 (gnus-summary-goto-subject article)
11691 (when (> start (point))
11692 (message "Hiding the thread moved us backwards, aborting!")
11693 (goto-char (point-max))))
11697 (defun gnus-summary-go-to-next-thread (&optional previous)
11698 "Go to the same level (or less) next thread.
11699 If PREVIOUS is non-nil, go to previous thread instead.
11700 Return the article number moved to, or nil if moving was impossible."
11701 (let ((level (gnus-summary-thread-level))
11702 (way (if previous -1 1))
11705 (while (and (not (eobp))
11706 (< level (gnus-summary-thread-level)))
11707 (forward-line way))
11714 (gnus-summary-article-number)
11715 (goto-char beg)))))
11717 (defun gnus-summary-next-thread (n &optional silent)
11718 "Go to the same level next N'th thread.
11719 If N is negative, search backward instead.
11720 Returns the difference between N and the number of skips actually
11723 If SILENT, don't output messages."
11725 (let ((backward (< n 0))
11727 (while (and (> n 0)
11728 (gnus-summary-go-to-next-thread backward))
11731 (gnus-summary-position-point))
11732 (when (and (not silent) (/= 0 n))
11733 (gnus-message 7 "No more threads"))
11736 (defun gnus-summary-prev-thread (n)
11737 "Go to the same level previous N'th thread.
11738 Returns the difference between N and the number of skips actually
11741 (gnus-summary-next-thread (- n)))
11743 (defun gnus-summary-go-down-thread ()
11744 "Go down one level in the current thread."
11745 (let ((children (gnus-summary-article-children)))
11747 (gnus-summary-goto-subject (car children)))))
11749 (defun gnus-summary-go-up-thread ()
11750 "Go up one level in the current thread."
11751 (let ((parent (gnus-summary-article-parent)))
11753 (gnus-summary-goto-subject parent))))
11755 (defun gnus-summary-down-thread (n)
11756 "Go down thread N steps.
11757 If N is negative, go up instead.
11758 Returns the difference between N and how many steps down that were
11763 (while (and (> n 0)
11764 (if up (gnus-summary-go-up-thread)
11765 (gnus-summary-go-down-thread)))
11767 (gnus-summary-position-point)
11769 (gnus-message 7 "Can't go further"))
11772 (defun gnus-summary-up-thread (n)
11773 "Go up thread N steps.
11774 If N is negative, go down instead.
11775 Returns the difference between N and how many steps down that were
11778 (gnus-summary-down-thread (- n)))
11780 (defun gnus-summary-top-thread ()
11781 "Go to the top of the thread."
11783 (while (gnus-summary-go-up-thread))
11784 (gnus-summary-article-number))
11786 (defun gnus-summary-expire-thread ()
11787 "Mark articles under current thread as expired."
11789 (gnus-summary-kill-thread 0))
11791 (defun gnus-summary-kill-thread (&optional unmark)
11792 "Mark articles under current thread as read.
11793 If the prefix argument is positive, remove any kinds of marks.
11794 If the prefix argument is zero, mark thread as expired.
11795 If the prefix argument is negative, tick articles instead."
11798 (setq unmark (prefix-numeric-value unmark)))
11799 (let ((articles (gnus-summary-articles-in-thread))
11800 (hide (or (null unmark) (= unmark 0))))
11802 ;; Expand the thread.
11803 (gnus-summary-show-thread)
11804 ;; Mark all the articles.
11806 (gnus-summary-goto-subject (car articles))
11807 (cond ((null unmark)
11808 (gnus-summary-mark-article-as-read gnus-killed-mark))
11810 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11812 (gnus-summary-mark-article nil gnus-expirable-mark))
11814 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11815 (setq articles (cdr articles))))
11816 ;; Hide killed subtrees when hide is true.
11818 gnus-thread-hide-killed
11819 (gnus-summary-hide-thread))
11820 ;; If hide is t, go to next unread subject.
11822 ;; Go to next unread subject.
11823 (gnus-summary-next-subject 1 t)))
11824 (gnus-set-mode-line 'summary))
11826 ;; Summary sorting commands
11828 (defun gnus-summary-sort-by-number (&optional reverse)
11829 "Sort the summary buffer by article number.
11830 Argument REVERSE means reverse order."
11832 (gnus-summary-sort 'number reverse))
11834 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11835 "Sort the summary buffer by most recent article number.
11836 Argument REVERSE means reverse order."
11838 (gnus-summary-sort 'most-recent-number reverse))
11840 (defun gnus-summary-sort-by-random (&optional reverse)
11841 "Randomize the order in the summary buffer.
11842 Argument REVERSE means to randomize in reverse order."
11844 (gnus-summary-sort 'random reverse))
11846 (defun gnus-summary-sort-by-author (&optional reverse)
11847 "Sort the summary buffer by author name alphabetically.
11848 If `case-fold-search' is non-nil, case of letters is ignored.
11849 Argument REVERSE means reverse order."
11851 (gnus-summary-sort 'author reverse))
11853 (defun gnus-summary-sort-by-recipient (&optional reverse)
11854 "Sort the summary buffer by recipient name alphabetically.
11855 If `case-fold-search' is non-nil, case of letters is ignored.
11856 Argument REVERSE means reverse order."
11858 (gnus-summary-sort 'recipient reverse))
11860 (defun gnus-summary-sort-by-subject (&optional reverse)
11861 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11862 If `case-fold-search' is non-nil, case of letters is ignored.
11863 Argument REVERSE means reverse order."
11865 (gnus-summary-sort 'subject reverse))
11867 (defun gnus-summary-sort-by-date (&optional reverse)
11868 "Sort the summary buffer by date.
11869 Argument REVERSE means reverse order."
11871 (gnus-summary-sort 'date reverse))
11873 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11874 "Sort the summary buffer by most recent date.
11875 Argument REVERSE means reverse order."
11877 (gnus-summary-sort 'most-recent-date reverse))
11879 (defun gnus-summary-sort-by-score (&optional reverse)
11880 "Sort the summary buffer by score.
11881 Argument REVERSE means reverse order."
11883 (gnus-summary-sort 'score reverse))
11885 (defun gnus-summary-sort-by-lines (&optional reverse)
11886 "Sort the summary buffer by the number of lines.
11887 Argument REVERSE means reverse order."
11889 (gnus-summary-sort 'lines reverse))
11891 (defun gnus-summary-sort-by-chars (&optional reverse)
11892 "Sort the summary buffer by article length.
11893 Argument REVERSE means reverse order."
11895 (gnus-summary-sort 'chars reverse))
11897 (defun gnus-summary-sort-by-original (&optional reverse)
11898 "Sort the summary buffer using the default sorting method.
11899 Argument REVERSE means reverse order."
11901 (let* ((inhibit-read-only t)
11902 (gnus-summary-prepare-hook nil))
11903 ;; We do the sorting by regenerating the threads.
11904 (gnus-summary-prepare)
11905 ;; Hide subthreads if needed.
11906 (gnus-summary-maybe-hide-threads)))
11908 (defun gnus-summary-sort (predicate reverse)
11909 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11910 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11911 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11912 (gnus-thread-sort-functions
11917 (gnus-sort-gathered-threads-function
11918 gnus-thread-sort-functions)
11919 (gnus-article-sort-functions
11923 (,article t2 t1))))
11924 (inhibit-read-only t)
11925 (gnus-summary-prepare-hook nil))
11926 ;; We do the sorting by regenerating the threads.
11927 (gnus-summary-prepare)
11928 ;; Hide subthreads if needed.
11929 (gnus-summary-maybe-hide-threads)))
11931 ;; Summary saving commands.
11933 (defun gnus-summary-save-article (&optional n not-saved)
11934 "Save the current article using the default saver function.
11935 If N is a positive number, save the N next articles.
11936 If N is a negative number, save the N previous articles.
11937 If N is nil and any articles have been marked with the process mark,
11938 save those articles instead.
11939 The variable `gnus-default-article-saver' specifies the saver function.
11941 If the optional second argument NOT-SAVED is non-nil, articles saved
11942 will not be marked as saved."
11944 (require 'gnus-art)
11945 (let* ((articles (gnus-summary-work-articles n))
11946 (save-buffer (save-excursion
11947 (nnheader-set-temp-buffer " *Gnus Save*")))
11948 (num (length articles))
11949 ;; Whether to save decoded articles or raw articles.
11950 (decode (when gnus-article-save-coding-system
11951 (get gnus-default-article-saver :decode)))
11952 ;; When saving many articles in a single file, use the other
11953 ;; function to save articles other than the first one.
11954 (saver2 (get gnus-default-article-saver :function))
11955 (gnus-prompt-before-saving (if saver2
11957 gnus-prompt-before-saving))
11958 (gnus-default-article-saver gnus-default-article-saver)
11960 (dolist (article articles)
11961 (setq header (gnus-summary-article-header article))
11962 (if (not (vectorp header))
11963 ;; This is a pseudo-article.
11964 (if (assq 'name header)
11965 (gnus-copy-file (cdr (assq 'name header)))
11966 (gnus-message 1 "Article %d is unsavable" article))
11967 ;; This is a real article.
11968 (save-window-excursion
11969 (gnus-summary-select-article decode decode nil article)
11970 (gnus-summary-goto-subject article))
11971 (with-current-buffer save-buffer
11973 (insert-buffer-substring (if decode
11974 gnus-article-buffer
11975 gnus-original-article-buffer)))
11976 (setq file (gnus-article-save save-buffer file num))
11977 (gnus-summary-remove-process-mark article)
11979 (gnus-summary-set-saved-mark article)))
11981 (setq gnus-default-article-saver saver2
11983 (gnus-kill-buffer save-buffer)
11984 (gnus-summary-position-point)
11985 (gnus-set-mode-line 'summary)
11988 (defun gnus-summary-pipe-output (&optional n sym)
11989 "Pipe the current article to a subprocess.
11990 If N is a positive number, pipe the N next articles.
11991 If N is a negative number, pipe the N previous articles.
11992 If N is nil and any articles have been marked with the process mark,
11993 pipe those articles instead.
11994 The default command to which articles are piped is specified by the
11995 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11996 will be prompted for the command.
11998 The properties `:decode' and `:headers' that are put to the function
11999 symbol `gnus-summary-save-in-pipe' control whether this function
12000 decodes articles and what headers to keep (see the doc string for the
12001 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12002 is neither omitted nor the symbol `r', force including all headers
12003 regardless of the `:headers' property. If it is the symbol `r',
12004 articles that are not decoded and include all headers will be piped
12005 no matter what the properties `:decode' and `:headers' are."
12006 (interactive (gnus-interactive "P\ny"))
12007 (require 'gnus-art)
12008 (let* ((articles (gnus-summary-work-articles n))
12009 (result-buffer "*Shell Command Output*")
12010 (all-headers (not (memq sym '(nil r))))
12011 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12013 (headers (get 'gnus-summary-save-in-pipe :headers))
12015 (unless (numberp (car articles))
12016 (error "No article to pipe"))
12017 (setq command (gnus-read-shell-command
12018 (concat "Shell command on "
12020 (format "these %d articles" (length articles))
12023 gnus-summary-pipe-output-default-command))
12024 (when (string-equal command "")
12025 (error "A command is required"))
12027 (put 'gnus-summary-save-in-pipe :headers nil))
12030 (gnus-summary-goto-subject (pop articles))
12031 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12032 (when (and (get-buffer result-buffer)
12033 (not (zerop (buffer-size (get-buffer result-buffer)))))
12034 (setq result (concat result (with-current-buffer result-buffer
12035 (buffer-string))))))
12036 (put 'gnus-summary-save-in-pipe :headers headers))
12037 (unless (zerop (length result))
12038 (if (with-current-buffer (get-buffer-create result-buffer)
12042 (and (= (count-lines (point-min) (point)) 1)
12045 (<= (current-column)
12046 (window-width (minibuffer-window)))))
12047 (goto-char (point-min))))
12048 (message "%s" (substring result 0 -1))
12050 (gnus-configure-windows 'pipe)))))
12052 (defun gnus-summary-save-article-mail (&optional arg)
12053 "Append the current article to a Unix mail box file.
12054 If N is a positive number, save the N next articles.
12055 If N is a negative number, save the N previous articles.
12056 If N is nil and any articles have been marked with the process mark,
12057 save those articles instead."
12059 (require 'gnus-art)
12060 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12061 (gnus-summary-save-article arg)))
12063 (defun gnus-summary-save-article-rmail (&optional arg)
12064 "Append the current article to an rmail file.
12065 If N is a positive number, save the N next articles.
12066 If N is a negative number, save the N previous articles.
12067 If N is nil and any articles have been marked with the process mark,
12068 save those articles instead."
12070 (require 'gnus-art)
12071 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12072 (gnus-summary-save-article arg)))
12074 (defun gnus-summary-save-article-file (&optional arg)
12075 "Append the current article to a file.
12076 If N is a positive number, save the N next articles.
12077 If N is a negative number, save the N previous articles.
12078 If N is nil and any articles have been marked with the process mark,
12079 save those articles instead."
12081 (require 'gnus-art)
12082 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12083 (gnus-summary-save-article arg)))
12085 (defun gnus-summary-write-article-file (&optional arg)
12086 "Write the current article to a file, deleting the previous file.
12087 If N is a positive number, save the N next articles.
12088 If N is a negative number, save the N previous articles.
12089 If N is nil and any articles have been marked with the process mark,
12090 save those articles instead."
12092 (require 'gnus-art)
12093 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12094 (gnus-summary-save-article arg)))
12096 (defun gnus-summary-save-article-body-file (&optional arg)
12097 "Append the current article body to a file.
12098 If N is a positive number, save the N next articles.
12099 If N is a negative number, save the N previous articles.
12100 If N is nil and any articles have been marked with the process mark,
12101 save those articles instead."
12103 (require 'gnus-art)
12104 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12105 (gnus-summary-save-article arg)))
12107 (defun gnus-summary-write-article-body-file (&optional arg)
12108 "Write the current article body to a file, deleting the previous file.
12109 If N is a positive number, save the N next articles.
12110 If N is a negative number, save the N previous articles.
12111 If N is nil and any articles have been marked with the process mark,
12112 save those articles instead."
12114 (require 'gnus-art)
12115 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12116 (gnus-summary-save-article arg)))
12118 (defun gnus-summary-muttprint (&optional arg)
12119 "Print the current article using Muttprint.
12120 If N is a positive number, save the N next articles.
12121 If N is a negative number, save the N previous articles.
12122 If N is nil and any articles have been marked with the process mark,
12123 save those articles instead."
12125 (require 'gnus-art)
12126 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12127 (gnus-summary-save-article arg t)))
12129 (defun gnus-summary-pipe-message (program)
12130 "Pipe the current article through PROGRAM."
12131 (interactive "sProgram: ")
12132 (gnus-summary-select-article)
12133 (let ((mail-header-separator ""))
12134 (gnus-eval-in-buffer-window gnus-article-buffer
12137 (let ((start (window-start))
12138 (inhibit-read-only t))
12139 (message-pipe-buffer-body program)
12140 (set-window-start (get-buffer-window (current-buffer)) start))))))
12142 (defun gnus-get-split-value (methods)
12143 "Return a value based on the split METHODS."
12144 (let (split-name method result match)
12146 (with-current-buffer gnus-original-article-buffer
12148 (nnheader-narrow-to-headers)
12149 (while (and methods (not split-name))
12150 (goto-char (point-min))
12151 (setq method (pop methods))
12152 (setq match (car method))
12155 ;; Regular expression.
12157 (re-search-forward match nil t)))
12162 (setq result (funcall match gnus-newsgroup-name))))
12167 (setq result (eval match)))))
12168 (setq split-name (cdr method))
12169 (cond ((stringp result)
12170 (push (expand-file-name
12171 result gnus-article-save-directory)
12174 (setq split-name (append result split-name)))))))))
12175 (nreverse split-name)))
12177 (defun gnus-valid-move-group-p (group)
12178 (and (symbolp group)
12180 (symbol-name group)
12181 (symbol-value group)
12182 (gnus-get-function (gnus-find-method-for-group
12183 (symbol-name group)) 'request-accept-article t)))
12185 (defun gnus-read-move-group-name (prompt default articles prefix)
12186 "Read a group name."
12187 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12188 (minibuffer-confirm-incomplete nil) ; XEmacs
12192 (if (> (length articles) 1)
12193 (format "these %d articles" (length articles))
12198 (gnus-group-completing-read
12200 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12201 nil prefix nil default))
12202 ((= 1 (length split-name))
12203 (gnus-group-completing-read
12205 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12206 nil prefix 'gnus-group-history (car split-name)))
12208 (gnus-completing-read
12209 prom (nreverse split-name) nil nil 'gnus-group-history))))
12210 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12213 (if (or (string= to-newsgroup "")
12214 (string= to-newsgroup prefix))
12215 (setq to-newsgroup default))
12216 (unless to-newsgroup
12217 (error "No group name entered"))
12218 (setq encoded (mm-encode-coding-string
12220 (gnus-group-name-charset to-method to-newsgroup)))
12221 (or (gnus-active encoded)
12222 (gnus-activate-group encoded nil nil to-method)
12223 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12225 (or (and (gnus-request-create-group encoded to-method)
12226 (gnus-activate-group encoded nil nil to-method)
12227 (gnus-subscribe-group encoded))
12228 (error "Couldn't create group %s" to-newsgroup)))
12229 (error "No such group: %s" to-newsgroup))
12232 (defvar gnus-summary-save-parts-counter)
12233 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12235 (defun gnus-summary-save-parts (type dir n &optional reverse)
12236 "Save parts matching TYPE to DIR.
12237 If REVERSE, save parts that do not match TYPE."
12239 (list (read-string "Save parts of type: "
12240 (or (car gnus-summary-save-parts-type-history)
12241 gnus-summary-save-parts-default-mime)
12242 'gnus-summary-save-parts-type-history)
12243 (setq gnus-summary-save-parts-last-directory
12244 (read-directory-name "Save to directory: "
12245 gnus-summary-save-parts-last-directory
12247 current-prefix-arg))
12248 (gnus-summary-iterate n
12249 (let ((gnus-display-mime-function nil)
12250 gnus-article-prepare-hook
12251 gnus-article-decode-hook
12252 gnus-display-mime-function
12254 (gnus-inhibit-treatment t))
12255 (gnus-summary-select-article))
12256 (with-current-buffer gnus-article-buffer
12257 (let ((handles (or gnus-article-mime-handles
12258 (mm-dissect-buffer nil gnus-article-loose-mime)
12259 (and gnus-article-emulate-mime
12261 (gnus-summary-save-parts-counter 1))
12263 (gnus-summary-save-parts-1 type dir handles reverse)
12264 (unless gnus-article-mime-handles ;; Don't destroy this case.
12265 (mm-destroy-parts handles)))))))
12267 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12268 (if (stringp (car handle))
12269 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12272 (not (string-match type (mm-handle-media-type handle)))
12273 (string-match type (mm-handle-media-type handle)))
12274 (let ((file (expand-file-name
12276 mm-file-name-rewrite-functions
12277 (file-name-nondirectory
12279 (mm-handle-filename handle)
12280 (format "%s.%d.%d" gnus-newsgroup-name
12281 (cdr gnus-article-current)
12282 gnus-summary-save-parts-counter))))
12284 (incf gnus-summary-save-parts-counter)
12285 (unless (file-exists-p file)
12286 (mm-save-part-to-file handle file))))))
12288 ;; Summary extract commands
12290 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12291 (let ((inhibit-read-only t)
12292 (article (gnus-summary-article-number))
12294 (unless (gnus-summary-goto-subject article)
12295 (error "No such article: %d" article))
12296 (gnus-summary-position-point)
12297 ;; If all commands are to be bunched up on one line, we collect
12299 (unless gnus-view-pseudos-separately
12300 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12303 (setq action (cdr (assq 'action (car ps))))
12304 (setq files (list (cdr (assq 'name (car ps)))))
12305 (while (and ps (cdr ps)
12306 (string= (or action "1")
12307 (or (cdr (assq 'action (cadr ps))) "2")))
12308 (push (cdr (assq 'name (cadr ps))) files)
12309 (setcdr ps (cddr ps)))
12311 (when (not (string-match "%s" action))
12314 (when (assq 'execute (car ps))
12315 (setcdr (assq 'execute (car ps))
12316 (funcall (if (string-match "%s" action)
12323 (shell-quote-argument f)))
12325 (setq ps (cdr ps)))))
12326 (if (and gnus-view-pseudos (not not-view))
12328 (when (assq 'execute (car pslist))
12329 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12330 (eq gnus-view-pseudos 'not-confirm)))
12331 (setq pslist (cdr pslist)))
12334 (setq after-article (or (cdr (assq 'article (car pslist)))
12335 (gnus-summary-article-number)))
12336 (gnus-summary-goto-subject after-article)
12339 (insert " " (file-name-nondirectory
12340 (cdr (assq 'name (car pslist))))
12341 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12343 (forward-line -1) ; back to `b'
12344 (gnus-add-text-properties
12345 b (1- e) (list 'gnus-number gnus-reffed-article-number
12346 gnus-mouse-face-prop gnus-mouse-face))
12348 after-article gnus-reffed-article-number
12349 gnus-unread-mark b (car pslist) 0 (- e b))
12350 (setq gnus-newsgroup-unreads
12351 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12352 gnus-reffed-article-number))
12353 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12354 (setq pslist (cdr pslist)))))))
12356 (defun gnus-pseudos< (p1 p2)
12357 (let ((c1 (cdr (assq 'action p1)))
12358 (c2 (cdr (assq 'action p2))))
12359 (and c1 c2 (string< c1 c2))))
12361 (defun gnus-request-pseudo-article (props)
12362 (cond ((assq 'execute props)
12363 (gnus-execute-command (cdr (assq 'execute props)))))
12364 (let ((gnus-current-article (gnus-summary-article-number)))
12365 (gnus-run-hooks 'gnus-mark-article-hook)))
12367 (defun gnus-execute-command (command &optional automatic)
12369 (gnus-article-setup-buffer)
12370 (set-buffer gnus-article-buffer)
12371 (setq buffer-read-only nil)
12372 (let ((command (if automatic command
12373 (read-string "Command: " (cons command 0)))))
12375 (insert "$ " command "\n\n")
12376 (if gnus-view-pseudo-asynchronously
12377 (start-process "gnus-execute" (current-buffer) shell-file-name
12378 shell-command-switch command)
12379 (call-process shell-file-name nil t nil
12380 shell-command-switch command)))))
12382 ;; Summary kill commands.
12384 (defun gnus-summary-edit-global-kill (article)
12385 "Edit the \"global\" kill file."
12386 (interactive (list (gnus-summary-article-number)))
12387 (gnus-group-edit-global-kill article))
12389 (defun gnus-summary-edit-local-kill ()
12390 "Edit a local kill file applied to the current newsgroup."
12392 (setq gnus-current-headers (gnus-summary-article-header))
12393 (gnus-group-edit-local-kill
12394 (gnus-summary-article-number) gnus-newsgroup-name))
12396 ;;; Header reading.
12398 (defun gnus-read-header (id &optional header)
12399 "Read the headers of article ID and enter them into the Gnus system."
12400 (let ((group gnus-newsgroup-name)
12401 (gnus-override-method
12403 gnus-override-method
12404 (and (gnus-news-group-p gnus-newsgroup-name)
12405 (car (gnus-refer-article-methods)))))
12407 ;; First we check to see whether the header in question is already
12410 ;; This is a Message-ID.
12411 (setq header (or header (gnus-id-to-header id)))
12412 ;; This is an article number.
12413 (setq header (or header (gnus-summary-article-header id))))
12415 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12416 ;; We have found the header.
12418 ;; We have to really fetch the header to this article.
12419 (with-current-buffer nntp-server-buffer
12420 (when (setq where (gnus-request-head id group))
12421 (nnheader-fold-continuation-lines)
12422 (goto-char (point-max))
12424 (goto-char (point-min))
12428 ((cdr where) (cdr where))
12429 (header (mail-header-number header))
12430 (t gnus-reffed-article-number))
12432 (insert " Article retrieved.\n"))
12433 (if (or (not where)
12434 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12435 () ; Malformed head.
12436 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12437 (when (and (stringp id)
12439 (not (string= (gnus-group-real-name group)
12441 (not (gnus-server-equal gnus-override-method
12442 (gnus-group-method group)))))
12443 ;; If we fetched by Message-ID and the article came from
12444 ;; a different group (or server), we fudge some bogus
12445 ;; article numbers for this article.
12446 (mail-header-set-number header gnus-reffed-article-number))
12447 (with-current-buffer gnus-summary-buffer
12448 (decf gnus-reffed-article-number)
12449 (gnus-remove-header (mail-header-number header))
12450 (push header gnus-newsgroup-headers)
12451 (setq gnus-current-headers header)
12452 (push (mail-header-number header) gnus-newsgroup-limit)))
12455 (defun gnus-remove-header (number)
12456 "Remove header NUMBER from `gnus-newsgroup-headers'."
12457 (if (and gnus-newsgroup-headers
12458 (= number (mail-header-number (car gnus-newsgroup-headers))))
12459 (pop gnus-newsgroup-headers)
12460 (let ((headers gnus-newsgroup-headers))
12461 (while (and (cdr headers)
12462 (not (= number (mail-header-number (cadr headers)))))
12464 (when (cdr headers)
12465 (setcdr headers (cddr headers))))))
12468 ;;; summary highlights
12471 (defun gnus-highlight-selected-summary ()
12472 "Highlight selected article in summary buffer."
12473 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12474 (when gnus-summary-selected-face
12476 (let* ((beg (point-at-bol))
12477 (end (point-at-eol))
12478 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12479 (from (if (get-text-property beg gnus-mouse-face-prop)
12481 (or (next-single-property-change
12482 beg gnus-mouse-face-prop nil end)
12487 (or (next-single-property-change
12488 from gnus-mouse-face-prop nil end)
12490 ;; If no mouse-face prop on line we will have to = from = end,
12491 ;; so we highlight the entire line instead.
12492 (when (= (+ to 2) from)
12495 (if gnus-newsgroup-selected-overlay
12496 ;; Move old overlay.
12498 gnus-newsgroup-selected-overlay from to (current-buffer))
12499 ;; Create new overlay.
12501 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12502 'face gnus-summary-selected-face))))))
12504 (defvar gnus-summary-highlight-line-cached nil)
12505 (defvar gnus-summary-highlight-line-trigger nil)
12507 (defun gnus-summary-highlight-line-0 ()
12508 (if (and (eq gnus-summary-highlight-line-trigger
12509 gnus-summary-highlight)
12510 gnus-summary-highlight-line-cached)
12511 gnus-summary-highlight-line-cached
12512 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12513 gnus-summary-highlight-line-cached
12514 (let* ((cond (list 'cond))
12516 (list gnus-summary-highlight))
12518 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12522 (gnus-byte-compile (list 'lambda nil cond))))))
12524 (defun gnus-summary-highlight-line ()
12525 "Highlight current line according to `gnus-summary-highlight'."
12526 (let* ((beg (point-at-bol))
12527 (article (or (gnus-summary-article-number) gnus-current-article))
12528 (score (or (cdr (assq article
12529 gnus-newsgroup-scored))
12530 gnus-summary-default-score 0))
12531 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12532 (inhibit-read-only t)
12533 (default gnus-summary-default-score)
12534 (default-high gnus-summary-default-high-score)
12535 (default-low gnus-summary-default-low-score)
12536 (uncached (and gnus-summary-use-undownloaded-faces
12537 (memq article gnus-newsgroup-undownloaded)
12538 (not (memq article gnus-newsgroup-cached)))))
12539 (let ((face (funcall (gnus-summary-highlight-line-0))))
12540 (unless (eq face (get-text-property beg 'face))
12541 (gnus-put-text-property-excluding-characters-with-faces
12542 beg (point-at-eol) 'face
12543 (setq face (if (boundp face) (symbol-value face) face)))
12544 (when gnus-summary-highlight-line-function
12545 (funcall gnus-summary-highlight-line-function article face))))))
12547 (defun gnus-update-read-articles (group unread &optional compute)
12548 "Update the list of read articles in GROUP.
12549 UNREAD is a sorted list."
12550 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12551 (info (gnus-get-info group))
12554 (if (or (not info) (not active))
12555 ;; There is no info on this group if it was, in fact,
12556 ;; killed. Gnus stores no information on killed groups, so
12557 ;; there's nothing to be done.
12558 ;; One could store the information somewhere temporarily,
12559 ;; perhaps... Hmmm...
12561 ;; Remove any negative articles numbers.
12562 (while (and unread (< (car unread) 0))
12563 (setq unread (cdr unread)))
12564 ;; Remove any expired article numbers
12565 (while (and unread (< (car unread) (car active)))
12566 (setq unread (cdr unread)))
12567 ;; Compute the ranges of read articles by looking at the list of
12568 ;; unread articles.
12570 (when (/= (car unread) prev)
12571 (push (if (= prev (1- (car unread))) prev
12572 (cons prev (1- (car unread))))
12574 (setq prev (1+ (car unread)))
12575 (setq unread (cdr unread)))
12576 (when (<= prev (cdr active))
12577 (push (cons prev (cdr active)) read))
12578 (setq read (if (> (length read) 1) (nreverse read) read))
12583 ;; Propagate the read marks to the backend.
12584 (when (and (or gnus-propagate-marks
12585 (gnus-method-option-p
12586 (gnus-find-method-for-group group)
12588 (gnus-check-backend-function 'request-set-mark group))
12589 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12590 (add (gnus-remove-from-range read (gnus-info-read info))))
12592 (unless (gnus-check-group group)
12593 (error "Can't open server for %s" group))
12594 (gnus-request-set-mark
12595 group (delq nil (list (if add (list add 'add '(read)))
12596 (if del (list del 'del '(read))))))
12598 `(gnus-request-set-mark
12601 (if del (list del 'add '(read)))
12602 (if add (list add 'del '(read))))))))))
12603 (set-buffer gnus-group-buffer)
12604 (gnus-undo-register
12606 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12607 (gnus-info-set-read ',info ',(gnus-info-read info))
12608 (gnus-get-unread-articles-in-group ',info
12609 (gnus-active ,group))
12610 (gnus-group-update-group ,group t)
12612 ;; Enter this list into the group info.
12613 (gnus-info-set-read info read)
12614 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12615 (gnus-get-unread-articles-in-group info (gnus-active group))
12618 (defun gnus-offer-save-summaries ()
12619 "Offer to save all active summary buffers."
12621 ;; Go through all buffers and find all summaries.
12622 (dolist (buffer (buffer-list))
12623 (when (and (setq buffer (buffer-name buffer))
12624 (string-match "Summary" buffer)
12625 (with-current-buffer buffer
12626 ;; We check that this is, indeed, a summary buffer.
12627 (and (eq major-mode 'gnus-summary-mode)
12628 ;; Also make sure this isn't bogus.
12629 gnus-newsgroup-prepared
12630 ;; Also make sure that this isn't a
12631 ;; dead summary buffer.
12632 (not gnus-dead-summary-mode))))
12633 (push buffer buffers)))
12634 ;; Go through all these summary buffers and offer to save them.
12637 (if (eq gnus-interactive-exit 'quiet)
12638 (dolist (buffer buffers)
12639 (switch-to-buffer buffer)
12640 (gnus-summary-exit))
12642 "Update summary buffer %s? "
12644 (switch-to-buffer buf)
12645 (gnus-summary-exit))
12648 (defun gnus-summary-setup-default-charset ()
12649 "Setup newsgroup default charset."
12650 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12651 (setq gnus-newsgroup-charset nil)
12652 (let* ((ignored-charsets
12653 (or gnus-newsgroup-ephemeral-ignored-charsets
12655 (and gnus-newsgroup-name
12656 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12657 gnus-newsgroup-ignored-charsets))))
12658 (setq gnus-newsgroup-charset
12659 (or gnus-newsgroup-ephemeral-charset
12660 (and gnus-newsgroup-name
12661 (gnus-parameter-charset gnus-newsgroup-name))
12662 gnus-default-charset))
12663 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12664 ignored-charsets))))
12670 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12671 "Display the current article buffer fully MIME-buttonized.
12672 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12673 treated as multipart/mixed."
12675 (require 'gnus-art)
12676 (let ((gnus-unbuttonized-mime-types nil)
12677 (gnus-mime-display-multipart-as-mixed show-all-parts))
12678 (gnus-summary-show-article)))
12680 (defun gnus-summary-repair-multipart (article)
12681 "Add a Content-Type header to a multipart article without one."
12682 (interactive (list (gnus-summary-article-number)))
12683 (gnus-with-article article
12684 (message-narrow-to-head)
12685 (message-remove-header "Mime-Version")
12686 (goto-char (point-max))
12687 (insert "Mime-Version: 1.0\n")
12689 (when (search-forward "\n--" nil t)
12690 (let ((separator (buffer-substring (point) (point-at-eol))))
12691 (message-narrow-to-head)
12692 (message-remove-header "Content-Type")
12693 (goto-char (point-max))
12694 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12697 (let (gnus-mark-article-hook)
12698 (gnus-summary-select-article t t nil article)))
12700 (defun gnus-summary-toggle-display-buttonized ()
12701 "Toggle the buttonizing of the article buffer."
12703 (require 'gnus-art)
12704 (if (setq gnus-inhibit-mime-unbuttonizing
12705 (not gnus-inhibit-mime-unbuttonizing))
12706 (let ((gnus-unbuttonized-mime-types nil))
12707 (gnus-summary-show-article))
12708 (gnus-summary-show-article)))
12711 ;;; Generic summary marking commands
12714 (defvar gnus-summary-marking-alist
12715 '((read gnus-del-mark "d")
12716 (unread gnus-unread-mark "u")
12717 (ticked gnus-ticked-mark "!")
12718 (dormant gnus-dormant-mark "?")
12719 (expirable gnus-expirable-mark "e"))
12720 "An alist of names/marks/keystrokes.")
12722 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12723 (defvar gnus-summary-mark-map)
12725 (defun gnus-summary-make-all-marking-commands ()
12726 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12727 (dolist (elem gnus-summary-marking-alist)
12728 (apply 'gnus-summary-make-marking-command elem)))
12730 (defun gnus-summary-make-marking-command (name mark keystroke)
12731 (let ((map (make-sparse-keymap)))
12732 (define-key gnus-summary-generic-mark-map keystroke map)
12733 (dolist (lway `((next "next" next nil "n")
12734 (next-unread "next unread" next t "N")
12735 (prev "previous" prev nil "p")
12736 (prev-unread "previous unread" prev t "P")
12737 (nomove "" nil nil ,keystroke)))
12738 (let ((func (gnus-summary-make-marking-command-1
12739 mark (car lway) lway name)))
12740 (setq func (eval func))
12741 (define-key map (nth 4 lway) func)))))
12743 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12745 (format "gnus-summary-put-mark-as-%s%s"
12746 name (if (eq way 'nomove)
12748 (concat "-" (symbol-name way)))))
12751 "Mark the current article as %s%s.
12752 If N, the prefix, then repeat N times.
12753 If N is negative, move in reverse order.
12754 The difference between N and the actual number of articles marked is
12758 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12760 (defun gnus-summary-generic-mark (n mark move unread)
12761 "Mark N articles with MARK."
12762 (unless (eq major-mode 'gnus-summary-mode)
12763 (error "This command can only be used in the summary buffer"))
12764 (gnus-summary-show-thread)
12767 ((eq move 'next) 1)
12768 ((eq move 'prev) -1)
12770 (if (zerop nummove)
12774 nummove (* -1 nummove))))
12775 (while (and (> n 0)
12776 (gnus-summary-mark-article nil mark)
12777 (zerop (gnus-summary-next-subject nummove unread t)))
12780 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12781 (gnus-summary-recenter)
12782 (gnus-summary-position-point)
12783 (gnus-set-mode-line 'summary)
12786 (defun gnus-summary-insert-articles (articles)
12787 (when (setq articles
12788 (gnus-sorted-difference articles
12789 (mapcar (lambda (h)
12790 (mail-header-number h))
12791 gnus-newsgroup-headers)))
12792 (setq gnus-newsgroup-headers
12794 gnus-newsgroup-headers
12795 (gnus-fetch-headers articles)
12796 'gnus-article-sort-by-number))
12797 (setq gnus-newsgroup-articles
12798 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12799 ;; Suppress duplicates?
12800 (when gnus-suppress-duplicates
12801 (gnus-dup-suppress-articles))
12803 (if (and gnus-fetch-old-headers
12804 (eq gnus-headers-retrieved-by 'nov))
12805 ;; We might want to build some more threads first.
12806 (if (eq gnus-fetch-old-headers 'invisible)
12807 (gnus-build-all-threads)
12808 (gnus-build-old-threads))
12809 ;; Mark the inserted articles that are unread as unread.
12810 (setq gnus-newsgroup-unreads
12811 (gnus-sorted-nunion
12812 gnus-newsgroup-unreads
12813 (gnus-sorted-nintersection
12814 (gnus-list-of-unread-articles gnus-newsgroup-name)
12816 ;; Mark the inserted articles as selected so that the information
12817 ;; of the marks having been changed by a user may be updated when
12818 ;; exiting this group. See `gnus-summary-update-info'.
12819 (dolist (art articles)
12820 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12821 ;; Let the Gnus agent mark articles as read.
12823 (gnus-agent-get-undownloaded-list))
12824 ;; Remove list identifiers from subject
12825 (gnus-summary-remove-list-identifiers)
12826 ;; First and last article in this newsgroup.
12827 (when gnus-newsgroup-headers
12828 (setq gnus-newsgroup-begin
12829 (mail-header-number (car gnus-newsgroup-headers))
12831 (mail-header-number
12832 (gnus-last-element gnus-newsgroup-headers))))
12833 (when gnus-use-scoring
12834 (gnus-possibly-score-headers))))
12836 (defun gnus-summary-insert-old-articles (&optional all)
12837 "Insert all old articles in this group.
12838 If ALL is non-nil, already read articles become readable.
12839 If ALL is a number, fetch this number of articles."
12842 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12845 ;; Some nntp servers lie about their active range. When
12846 ;; this happens, the active range can be in the millions.
12847 ;; Use a compressed range to avoid creating a huge list.
12848 (gnus-range-difference (list gnus-newsgroup-active) old))
12849 (setq len (gnus-range-length older))
12854 (let ((older-range (nreverse older)))
12858 (let* ((r (pop older-range))
12859 (min (if (numberp r) r (car r)))
12860 (max (if (numberp r) r (cdr r))))
12861 (while (and (<= min max)
12866 (setq older (gnus-uncompress-range older))))
12868 (setq older (gnus-uncompress-range older)))
12870 (when (and (numberp gnus-large-newsgroup)
12871 (> len gnus-large-newsgroup))
12872 (let* ((cursor-in-echo-area nil)
12873 (initial (gnus-parameter-large-newsgroup-initial
12874 gnus-newsgroup-name))
12878 "How many articles from %s (%s %d): "
12879 (gnus-group-decoded-name gnus-newsgroup-name)
12880 (if initial "max" "default")
12884 (cons (number-to-string initial)
12886 (unless (string-match "^[ \t]*$" input)
12887 (setq all (string-to-number input))
12889 (let ((older-range (nreverse older)))
12893 (let* ((r (pop older-range))
12894 (min (if (numberp r) r (car r)))
12895 (max (if (numberp r) r (cdr r))))
12896 (while (and (<= min max)
12900 max (1- max))))))))))
12901 (setq older (gnus-uncompress-range older))))
12903 (message "No old news.")
12904 (gnus-summary-insert-articles older)
12905 (gnus-summary-limit (gnus-sorted-nunion old older))))
12906 (gnus-summary-position-point)))
12908 (defun gnus-summary-insert-new-articles ()
12909 "Insert all new articles in this group."
12911 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12912 (old-high gnus-newsgroup-highest)
12913 (nnmail-fetched-sources (list t))
12914 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12917 (error "Couldn't fetch new data"))
12918 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12919 (setq i (cdr gnus-newsgroup-active)
12920 gnus-newsgroup-highest i)
12921 (while (> i old-high)
12925 (message "No gnus is bad news")
12926 (gnus-summary-insert-articles new)
12927 (setq gnus-newsgroup-unreads
12928 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12929 (gnus-summary-limit (gnus-sorted-nunion old new))))
12930 (gnus-summary-position-point))
12932 ;;; Bookmark support for Gnus.
12933 (declare-function bookmark-make-record-default
12934 "bookmark" (&optional no-file no-context posn))
12935 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12936 (declare-function bookmark-default-handler "bookmark" (bmk))
12937 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12938 (defvar bookmark-yank-point)
12939 (defvar bookmark-current-buffer)
12941 (defun gnus-summary-bookmark-make-record ()
12942 "Make a bookmark entry for a Gnus summary buffer."
12944 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12945 (save-restriction ; FIXME is it necessary to widen?
12946 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12947 (setq buf "art") ; We are recording bookmark from article buffer.
12948 (setq bookmark-yank-point (point))
12949 (setq bookmark-current-buffer (current-buffer))
12950 (gnus-article-show-summary)) ; Go back in summary buffer.
12951 ;; We are now recording bookmark from summary buffer.
12952 (unless buf (setq buf "sum"))
12953 (let* ((subject (elt (gnus-summary-article-header) 1))
12954 (grp (car gnus-article-current))
12955 (art (cdr gnus-article-current))
12956 (head (gnus-summary-article-header art))
12957 (id (mail-header-id head)))
12959 ,@(condition-case nil
12960 (bookmark-make-record-default 'no-file 'no-context pos)
12961 (wrong-number-of-arguments
12962 (bookmark-make-record-default 'point-only)))
12963 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12964 (group . ,grp) (article . ,art)
12965 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12968 (defun gnus-summary-bookmark-jump (bookmark)
12969 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12970 BOOKMARK is a bookmark name or a bookmark record."
12971 (let ((group (bookmark-prop-get bookmark 'group))
12972 (article (bookmark-prop-get bookmark 'article))
12973 (id (bookmark-prop-get bookmark 'message-id))
12974 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12975 (gnus-fetch-group group (list article))
12976 (gnus-summary-insert-cached-articles)
12977 (gnus-summary-goto-article id nil 'force)
12978 ;; FIXME we have to wait article buffer is ready (only large buffer)
12979 ;; Is there a better solution to know that?
12980 ;; If we don't wait `bookmark-default-handler' will have no chance
12981 ;; to set position. However there is no error, just wrong pos.
12983 (when (string= buf "Gnus-art")
12985 (bookmark-default-handler
12987 (buffer . ,(current-buffer))
12988 . ,(bookmark-get-bookmark-record bookmark)))))
12990 (gnus-summary-make-all-marking-commands)
12992 (gnus-ems-redefine)
12994 (provide 'gnus-sum)
12996 (run-hooks 'gnus-sum-load-hook)
12998 ;; Local Variables:
12999 ;; coding: iso-8859-1
13002 ;;; gnus-sum.el ends here