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-alter-articles-to-read-function nil
1247 "Function to be called to alter the list of articles to be selected."
1248 :type '(choice (const nil) function)
1249 :group 'gnus-summary)
1251 (defcustom gnus-orphan-score nil
1252 "*All orphans get this score added. Set in the score file."
1253 :group 'gnus-score-default
1254 :type '(choice (const nil)
1257 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1258 "*A regexp to match MIME parts when saving multiple parts of a
1259 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1260 This regexp will be used by default when prompting the user for which
1261 type of files to save."
1262 :group 'gnus-summary
1265 (defcustom gnus-read-all-available-headers nil
1266 "Whether Gnus should parse all headers made available to it.
1267 This is mostly relevant for slow back ends where the user may
1268 wish to widen the summary buffer to include all headers
1271 :group 'gnus-summary
1272 :type '(choice boolean regexp))
1274 (defcustom gnus-summary-pipe-output-default-command nil
1275 "Command (and optional arguments) used to pipe article to subprocess.
1276 This will be used as the default command if it is non-nil. The value
1277 will be updated if you modify it when executing the command
1278 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1279 :version "23.1" ;; No Gnus
1280 :group 'gnus-summary
1281 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1283 (defcustom gnus-summary-muttprint-program "muttprint"
1284 "Command (and optional arguments) used to run Muttprint.
1285 The value will be updated if you modify it when executing the command
1286 `gnus-summary-muttprint'."
1288 :group 'gnus-summary
1291 (defcustom gnus-article-loose-mime t
1292 "If non-nil, don't require MIME-Version header.
1293 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1294 supply the MIME-Version header or deliberately strip it from the mail.
1295 If non-nil (the default), Gnus will treat some articles as MIME
1296 even if the MIME-Version header is missing."
1299 :group 'gnus-article-mime)
1301 (defcustom gnus-article-emulate-mime t
1302 "If non-nil, use MIME emulation for uuencode and the like.
1303 This means that Gnus will search message bodies for text that look
1304 like uuencoded bits, yEncoded bits, and so on, and present that using
1305 the normal Gnus MIME machinery."
1308 :group 'gnus-article-mime)
1310 ;;; Internal variables
1312 (defvar gnus-summary-display-cache nil)
1313 (defvar gnus-article-mime-handles nil)
1314 (defvar gnus-article-decoded-p nil)
1315 (defvar gnus-article-charset nil)
1316 (defvar gnus-article-ignored-charsets nil)
1317 (defvar gnus-scores-exclude-files nil)
1318 (defvar gnus-page-broken nil)
1320 (defvar gnus-original-article nil)
1321 (defvar gnus-article-internal-prepare-hook nil)
1322 (defvar gnus-newsgroup-process-stack nil)
1324 (defvar gnus-thread-indent-array nil)
1325 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1326 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1327 "Function called to sort the articles within a thread after it has been gathered together.")
1329 (defvar gnus-summary-save-parts-type-history nil)
1330 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1332 ;; Avoid highlighting in kill files.
1333 (defvar gnus-summary-inhibit-highlight nil)
1334 (defvar gnus-newsgroup-selected-overlay nil)
1335 (defvar gnus-inhibit-limiting nil)
1336 (defvar gnus-newsgroup-adaptive-score-file nil)
1337 (defvar gnus-current-score-file nil)
1338 (defvar gnus-current-move-group nil)
1339 (defvar gnus-current-copy-group nil)
1340 (defvar gnus-current-crosspost-group nil)
1341 (defvar gnus-newsgroup-display nil)
1343 (defvar gnus-newsgroup-dependencies nil)
1344 (defvar gnus-newsgroup-adaptive nil)
1345 (defvar gnus-summary-display-article-function nil)
1346 (defvar gnus-summary-highlight-line-function nil
1347 "Function called after highlighting a summary line.")
1349 (defvar gnus-summary-line-format-alist
1350 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1351 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1352 (?s gnus-tmp-subject-or-nil ?s)
1353 (?n gnus-tmp-name ?s)
1354 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1356 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1358 (?F gnus-tmp-from ?s)
1359 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1360 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1361 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1362 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1363 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1364 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1365 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1366 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1367 (?L gnus-tmp-lines ?s)
1368 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1370 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1372 (?g (or (gnus-group-short-name
1373 (nnir-article-group (mail-header-number gnus-tmp-header)))
1375 (?O gnus-tmp-downloaded ?c)
1376 (?I gnus-tmp-indentation ?s)
1377 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1378 (?R gnus-tmp-replied ?c)
1379 (?\[ gnus-tmp-opening-bracket ?c)
1380 (?\] gnus-tmp-closing-bracket ?c)
1381 (?\> (make-string gnus-tmp-level ? ) ?s)
1382 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1383 (?i gnus-tmp-score ?d)
1384 (?z gnus-tmp-score-char ?c)
1385 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1386 (?U gnus-tmp-unread ?c)
1387 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1389 (?t (gnus-summary-number-of-articles-in-thread
1390 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1392 (?e (gnus-summary-number-of-articles-in-thread
1393 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1395 (?u gnus-tmp-user-defined ?s)
1396 (?P (gnus-pick-line-number) ?d)
1397 (?B gnus-tmp-thread-tree-header-string ?s)
1398 (user-date (gnus-user-date
1399 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1400 "An alist of format specifications that can appear in summary lines.
1401 These are paired with what variables they correspond with, along with
1402 the type of the variable (string, integer, character, etc).")
1404 (defvar gnus-summary-dummy-line-format-alist
1405 `((?S gnus-tmp-subject ?s)
1406 (?N gnus-tmp-number ?d)
1407 (?u gnus-tmp-user-defined ?s)))
1409 (defvar gnus-summary-mode-line-format-alist
1410 `((?G gnus-tmp-group-name ?s)
1411 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1412 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1413 (?A gnus-tmp-article-number ?d)
1414 (?Z gnus-tmp-unread-and-unselected ?s)
1415 (?V gnus-version ?s)
1416 (?U gnus-tmp-unread-and-unticked ?d)
1417 (?S gnus-tmp-subject ?s)
1418 (?e gnus-tmp-unselected ?d)
1419 (?u gnus-tmp-user-defined ?s)
1420 (?d (length gnus-newsgroup-dormant) ?d)
1421 (?t (length gnus-newsgroup-marked) ?d)
1422 (?h (length gnus-newsgroup-spam-marked) ?d)
1423 (?r (length gnus-newsgroup-reads) ?d)
1424 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1425 (?E gnus-newsgroup-expunged-tally ?d)
1426 (?s (gnus-current-score-file-nondirectory) ?s)))
1428 ;; This is here rather than in gnus-art for compilation reasons.
1429 (defvar gnus-article-mode-line-format-alist
1430 (nconc '((?w (gnus-article-wash-status) ?s)
1431 (?m (gnus-article-mime-part-status) ?s))
1432 gnus-summary-mode-line-format-alist))
1434 (defvar gnus-last-search-regexp nil
1435 "Default regexp for article search command.")
1437 (defvar gnus-last-shell-command nil
1438 "Default shell command on article.")
1440 (defvar gnus-newsgroup-agentized nil
1441 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1442 (defvar gnus-newsgroup-begin nil)
1443 (defvar gnus-newsgroup-end nil)
1444 (defvar gnus-newsgroup-last-rmail nil)
1445 (defvar gnus-newsgroup-last-mail nil)
1446 (defvar gnus-newsgroup-last-folder nil)
1447 (defvar gnus-newsgroup-last-file nil)
1448 (defvar gnus-newsgroup-last-directory nil)
1449 (defvar gnus-newsgroup-auto-expire nil)
1450 (defvar gnus-newsgroup-active nil)
1451 (defvar gnus-newsgroup-highest nil)
1453 (defvar gnus-newsgroup-data nil)
1454 (defvar gnus-newsgroup-data-reverse nil)
1455 (defvar gnus-newsgroup-limit nil)
1456 (defvar gnus-newsgroup-limits nil)
1457 (defvar gnus-summary-use-undownloaded-faces nil)
1459 (defvar gnus-newsgroup-unreads nil
1460 "Sorted list of unread articles in the current newsgroup.")
1462 (defvar gnus-newsgroup-unselected nil
1463 "Sorted list of unselected unread articles in the current newsgroup.")
1465 (defvar gnus-newsgroup-reads nil
1466 "Alist of read articles and article marks in the current newsgroup.")
1468 (defvar gnus-newsgroup-expunged-tally nil)
1470 (defvar gnus-newsgroup-marked nil
1471 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1473 (defvar gnus-newsgroup-spam-marked nil
1474 "List of ranges of articles that have been marked as spam.")
1476 (defvar gnus-newsgroup-killed nil
1477 "List of ranges of articles that have been through the scoring process.")
1479 (defvar gnus-newsgroup-cached nil
1480 "Sorted list of articles that come from the article cache.")
1482 (defvar gnus-newsgroup-saved nil
1483 "List of articles that have been saved.")
1485 (defvar gnus-newsgroup-kill-headers nil)
1487 (defvar gnus-newsgroup-replied nil
1488 "List of articles that have been replied to in the current newsgroup.")
1490 (defvar gnus-newsgroup-forwarded nil
1491 "List of articles that have been forwarded in the current newsgroup.")
1493 (defvar gnus-newsgroup-expirable nil
1494 "Sorted list of articles in the current newsgroup that can be expired.")
1496 (defvar gnus-newsgroup-processable nil
1497 "List of articles in the current newsgroup that can be processed.")
1499 (defvar gnus-newsgroup-downloadable nil
1500 "Sorted list of articles in the current newsgroup that can be processed.")
1502 (defvar gnus-newsgroup-unfetched nil
1503 "Sorted list of articles in the current newsgroup whose headers have
1504 not been fetched into the agent.
1506 This list will always be a subset of gnus-newsgroup-undownloaded.")
1508 (defvar gnus-newsgroup-undownloaded nil
1509 "List of articles in the current newsgroup that haven't been downloaded.")
1511 (defvar gnus-newsgroup-unsendable nil
1512 "List of articles in the current newsgroup that won't be sent.")
1514 (defvar gnus-newsgroup-bookmarks nil
1515 "List of articles in the current newsgroup that have bookmarks.")
1517 (defvar gnus-newsgroup-dormant nil
1518 "Sorted list of dormant articles in the current newsgroup.")
1520 (defvar gnus-newsgroup-unseen nil
1521 "List of unseen articles in the current newsgroup.")
1523 (defvar gnus-newsgroup-seen nil
1524 "Range of seen articles in the current newsgroup.")
1526 (defvar gnus-newsgroup-unexist nil
1527 "Range of unexistent articles in the current newsgroup.")
1529 (defvar gnus-newsgroup-articles nil
1530 "List of articles in the current newsgroup.")
1532 (defvar gnus-newsgroup-scored nil
1533 "List of scored articles in the current newsgroup.")
1535 (defvar gnus-newsgroup-headers nil
1536 "List of article headers in the current newsgroup.")
1538 (defvar gnus-newsgroup-threads nil)
1540 (defvar gnus-newsgroup-prepared nil
1541 "Whether the current group has been prepared properly.")
1543 (defvar gnus-newsgroup-ancient nil
1544 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1546 (defvar gnus-newsgroup-sparse nil)
1548 (defvar gnus-current-article nil)
1549 (defvar gnus-article-current nil)
1550 (defvar gnus-current-headers nil)
1551 (defvar gnus-have-all-headers nil)
1552 (defvar gnus-last-article nil)
1553 (defvar gnus-newsgroup-history nil)
1554 (defvar gnus-newsgroup-charset nil)
1555 (defvar gnus-newsgroup-ephemeral-charset nil)
1556 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1558 (defvar gnus-article-before-search nil)
1560 (defvar gnus-summary-local-variables
1561 '(gnus-newsgroup-name
1564 gnus-newsgroup-unreads
1565 gnus-newsgroup-unselected
1566 gnus-newsgroup-marked
1567 gnus-newsgroup-spam-marked
1568 gnus-newsgroup-reads
1569 gnus-newsgroup-saved
1570 gnus-newsgroup-replied
1571 gnus-newsgroup-forwarded
1572 gnus-newsgroup-expirable
1573 gnus-newsgroup-killed
1574 gnus-newsgroup-unseen
1576 gnus-newsgroup-unexist
1577 gnus-newsgroup-cached
1578 gnus-newsgroup-downloadable
1579 gnus-newsgroup-undownloaded
1580 gnus-newsgroup-unsendable
1582 gnus-newsgroup-begin gnus-newsgroup-end
1583 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1584 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1585 gnus-newsgroup-last-directory
1586 gnus-newsgroup-auto-expire
1587 gnus-newsgroup-processable
1588 gnus-newsgroup-unfetched
1589 gnus-newsgroup-articles
1590 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1591 gnus-newsgroup-headers gnus-newsgroup-threads
1592 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1593 gnus-current-article gnus-current-headers gnus-have-all-headers
1594 gnus-last-article gnus-article-internal-prepare-hook
1595 (gnus-summary-article-delete-hook . global)
1596 (gnus-summary-article-move-hook . global)
1597 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1598 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1599 gnus-thread-expunge-below
1600 gnus-score-alist gnus-current-score-file
1601 (gnus-summary-expunge-below . global)
1602 (gnus-summary-mark-below . global)
1603 (gnus-orphan-score . global)
1604 gnus-newsgroup-active gnus-scores-exclude-files
1605 gnus-newsgroup-highest
1606 gnus-newsgroup-history gnus-newsgroup-ancient
1607 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1608 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1609 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1610 (gnus-newsgroup-expunged-tally . 0)
1611 gnus-cache-removable-articles
1612 gnus-newsgroup-data gnus-newsgroup-data-reverse
1613 gnus-newsgroup-limit gnus-newsgroup-limits
1614 gnus-newsgroup-charset gnus-newsgroup-display
1615 gnus-summary-use-undownloaded-faces)
1616 "Variables that are buffer-local to the summary buffers.")
1618 (defvar gnus-newsgroup-variables nil
1619 "A list of variables that have separate values in different newsgroups.
1620 A list of newsgroup (summary buffer) local variables, or cons of
1621 variables and their default expressions to be evalled (when the default
1622 values are not nil), that should be made global while the summary buffer
1625 Note: The default expressions will be evaluated (using function `eval')
1626 before assignment to the local variable rather than just assigned to it.
1627 If the default expression is the symbol `global', that symbol will not
1628 be evaluated but the global value of the local variable will be used
1631 These variables can be used to set variables in the group parameters
1632 while still allowing them to affect operations done in other buffers.
1635 \(setq gnus-newsgroup-variables
1636 '(message-use-followup-to
1637 (gnus-visible-headers .
1638 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1642 ;; Bind features so that require will believe that gnus-sum has
1643 ;; already been loaded (avoids infinite recursion)
1644 (let ((features (cons 'gnus-sum features)))
1645 (require 'gnus-art)))
1649 (defvar gnus-decode-encoded-word-methods
1650 '(mail-decode-encoded-word-string)
1651 "List of methods used to decode encoded words.
1653 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1654 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1655 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1656 whose names match REGEXP.
1659 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1660 mail-decode-encoded-word-string
1661 (\"chinese\" . rfc1843-decode-string))")
1663 (defvar gnus-decode-encoded-word-methods-cache nil)
1665 (defun gnus-multi-decode-encoded-word-string (string)
1666 "Apply the functions from `gnus-encoded-word-methods' that match."
1667 (unless (and gnus-decode-encoded-word-methods-cache
1668 (eq gnus-newsgroup-name
1669 (car gnus-decode-encoded-word-methods-cache)))
1670 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1671 (dolist (method gnus-decode-encoded-word-methods)
1672 (if (symbolp method)
1673 (nconc gnus-decode-encoded-word-methods-cache (list method))
1674 (if (and gnus-newsgroup-name
1675 (string-match (car method) gnus-newsgroup-name))
1676 (nconc gnus-decode-encoded-word-methods-cache
1677 (list (cdr method)))))))
1678 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1679 (setq string (funcall method string))))
1681 ;; Subject simplification.
1683 (defun gnus-simplify-whitespace (str)
1684 "Remove excessive whitespace from STR."
1686 (while (string-match "[ \t][ \t]+" str)
1687 (setq str (concat (substring str 0 (match-beginning 0))
1689 (substring str (match-end 0)))))
1691 (when (string-match "^[ \t]+" str)
1692 (setq str (substring str (match-end 0))))
1694 (when (string-match "[ \t]+$" str)
1695 (setq str (substring str 0 (match-beginning 0))))
1698 (defun gnus-simplify-all-whitespace (str)
1699 "Remove all whitespace from STR."
1700 (while (string-match "[ \t\n]+" str)
1701 (setq str (replace-match "" nil nil str)))
1704 (defsubst gnus-simplify-subject-re (subject)
1705 "Remove \"Re:\" from subject lines."
1706 (if (string-match message-subject-re-regexp subject)
1707 (substring subject (match-end 0))
1710 (defun gnus-simplify-subject (subject &optional re-only)
1711 "Remove `Re:' and words in parentheses.
1712 If RE-ONLY is non-nil, strip leading `Re:'s only."
1713 (let ((case-fold-search t)) ;Ignore case.
1714 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1715 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1716 (setq subject (substring subject (match-end 0))))
1717 ;; Remove uninteresting prefixes.
1718 (when (and (not re-only)
1719 gnus-simplify-ignored-prefixes
1720 (string-match gnus-simplify-ignored-prefixes subject))
1721 (setq subject (substring subject (match-end 0))))
1722 ;; Remove words in parentheses from end.
1724 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1725 (setq subject (substring subject 0 (match-beginning 0)))))
1726 ;; Return subject string.
1729 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1731 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1732 (goto-char (point-min))
1733 (while (re-search-forward regexp nil t)
1734 (replace-match (or newtext ""))))
1736 (defun gnus-simplify-buffer-fuzzy (regexp)
1737 "Simplify string in the buffer fuzzily.
1738 The string in the accessible portion of the current buffer is simplified.
1739 It is assumed to be a single-line subject.
1740 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1741 matter is removed. Additional things can be deleted by setting
1742 `gnus-simplify-subject-fuzzy-regexp'."
1743 (let ((case-fold-search t)
1745 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1747 (while (not (eq modified-tick (buffer-modified-tick)))
1748 (setq modified-tick (buffer-modified-tick))
1751 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1753 (gnus-simplify-buffer-fuzzy-step regexp)))
1754 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1755 (gnus-simplify-buffer-fuzzy-step
1756 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1757 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1759 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1760 (gnus-simplify-buffer-fuzzy-step " +" " ")
1761 (gnus-simplify-buffer-fuzzy-step " $")
1762 (gnus-simplify-buffer-fuzzy-step "^ +")))
1764 (defun gnus-simplify-subject-fuzzy (subject)
1765 "Simplify a subject string fuzzily.
1766 See `gnus-simplify-buffer-fuzzy' for details."
1768 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1769 (gnus-set-work-buffer)
1770 (let ((case-fold-search t))
1771 ;; Remove uninteresting prefixes.
1772 (when (and gnus-simplify-ignored-prefixes
1773 (string-match gnus-simplify-ignored-prefixes subject))
1774 (setq subject (substring subject (match-end 0))))
1776 (inline (gnus-simplify-buffer-fuzzy regexp))
1779 (defsubst gnus-simplify-subject-fully (subject)
1780 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1782 (gnus-simplify-subject-functions
1783 (gnus-map-function gnus-simplify-subject-functions subject))
1784 ((null gnus-summary-gather-subject-limit)
1785 (gnus-simplify-subject-re subject))
1786 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1787 (gnus-simplify-subject-fuzzy subject))
1788 ((numberp gnus-summary-gather-subject-limit)
1789 (truncate-string-to-width (gnus-simplify-subject-re subject)
1790 gnus-summary-gather-subject-limit))
1794 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1795 "Check whether two subjects are equal.
1796 If optional argument SIMPLE-FIRST is t, first argument is already
1799 ((null simple-first)
1800 (equal (gnus-simplify-subject-fully s1)
1801 (gnus-simplify-subject-fully s2)))
1804 (gnus-simplify-subject-fully s2)))))
1806 (defun gnus-summary-bubble-group ()
1807 "Increase the score of the current group.
1808 This is a handy function to add to `gnus-summary-exit-hook' to
1809 increase the score of each group you read."
1810 (gnus-group-add-score gnus-newsgroup-name))
1814 ;;; Gnus summary mode
1817 (put 'gnus-summary-mode 'mode-class 'special)
1819 (defvar gnus-article-commands-menu)
1821 ;; Non-orthogonal keys
1823 (gnus-define-keys gnus-summary-mode-map
1824 " " gnus-summary-next-page
1825 "\177" gnus-summary-prev-page
1826 [delete] gnus-summary-prev-page
1827 [backspace] gnus-summary-prev-page
1828 "\r" gnus-summary-scroll-up
1829 "\M-\r" gnus-summary-scroll-down
1830 "n" gnus-summary-next-unread-article
1831 "p" gnus-summary-prev-unread-article
1832 "N" gnus-summary-next-article
1833 "P" gnus-summary-prev-article
1834 "\M-\C-n" gnus-summary-next-same-subject
1835 "\M-\C-p" gnus-summary-prev-same-subject
1836 "\M-n" gnus-summary-next-unread-subject
1837 "\M-p" gnus-summary-prev-unread-subject
1838 "." gnus-summary-first-unread-article
1839 "," gnus-summary-best-unread-article
1840 "\M-s" gnus-summary-search-article-forward
1841 "\M-r" gnus-summary-search-article-backward
1842 "\M-S" gnus-summary-repeat-search-article-forward
1843 "\M-R" gnus-summary-repeat-search-article-backward
1844 "<" gnus-summary-beginning-of-article
1845 ">" gnus-summary-end-of-article
1846 "j" gnus-summary-goto-article
1847 "^" gnus-summary-refer-parent-article
1848 "\M-^" gnus-summary-refer-article
1849 "u" gnus-summary-tick-article-forward
1850 "!" gnus-summary-tick-article-forward
1851 "U" gnus-summary-tick-article-backward
1852 "d" gnus-summary-mark-as-read-forward
1853 "D" gnus-summary-mark-as-read-backward
1854 "E" gnus-summary-mark-as-expirable
1855 "\M-u" gnus-summary-clear-mark-forward
1856 "\M-U" gnus-summary-clear-mark-backward
1857 "k" gnus-summary-kill-same-subject-and-select
1858 "\C-k" gnus-summary-kill-same-subject
1859 "\M-\C-k" gnus-summary-kill-thread
1860 "\M-\C-l" gnus-summary-lower-thread
1861 "e" gnus-summary-edit-article
1862 "#" gnus-summary-mark-as-processable
1863 "\M-#" gnus-summary-unmark-as-processable
1864 "\M-\C-t" gnus-summary-toggle-threads
1865 "\M-\C-s" gnus-summary-show-thread
1866 "\M-\C-h" gnus-summary-hide-thread
1867 "\M-\C-f" gnus-summary-next-thread
1868 "\M-\C-b" gnus-summary-prev-thread
1869 [(meta down)] gnus-summary-next-thread
1870 [(meta up)] gnus-summary-prev-thread
1871 "\M-\C-u" gnus-summary-up-thread
1872 "\M-\C-d" gnus-summary-down-thread
1873 "&" gnus-summary-execute-command
1874 "c" gnus-summary-catchup-and-exit
1875 "\C-w" gnus-summary-mark-region-as-read
1876 "\C-t" gnus-summary-toggle-truncation
1877 "?" gnus-summary-mark-as-dormant
1878 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1879 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1880 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1881 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1882 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1883 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1884 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1885 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1886 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1887 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1888 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1889 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1890 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1891 "=" gnus-summary-expand-window
1892 "\C-x\C-s" gnus-summary-reselect-current-group
1893 "\M-g" gnus-summary-rescan-group
1894 "\C-c\C-r" gnus-summary-caesar-message
1895 "f" gnus-summary-followup
1896 "F" gnus-summary-followup-with-original
1897 "C" gnus-summary-cancel-article
1898 "r" gnus-summary-reply
1899 "R" gnus-summary-reply-with-original
1900 "\C-c\C-f" gnus-summary-mail-forward
1901 "o" gnus-summary-save-article
1902 "\C-o" gnus-summary-save-article-mail
1903 "|" gnus-summary-pipe-output
1904 "\M-k" gnus-summary-edit-local-kill
1905 "\M-K" gnus-summary-edit-global-kill
1907 "\C-c\C-d" gnus-summary-describe-group
1908 "q" gnus-summary-exit
1909 "Q" gnus-summary-exit-no-update
1910 "\C-c\C-i" gnus-info-find-node
1911 gnus-mouse-2 gnus-mouse-pick-article
1912 [follow-link] mouse-face
1913 "m" gnus-summary-mail-other-window
1914 "a" gnus-summary-post-news
1915 "x" gnus-summary-limit-to-unread
1916 "s" gnus-summary-isearch-article
1917 [tab] gnus-summary-widget-forward
1918 [backtab] gnus-summary-widget-backward
1919 "t" gnus-summary-toggle-header
1920 "g" gnus-summary-show-article
1921 "l" gnus-summary-goto-last-article
1922 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1923 "\C-d" gnus-summary-enter-digest-group
1924 "\M-\C-d" gnus-summary-read-document
1925 "\M-\C-e" gnus-summary-edit-parameters
1926 "\M-\C-a" gnus-summary-customize-parameters
1928 "*" gnus-cache-enter-article
1929 "\M-*" gnus-cache-remove-article
1930 "\M-&" gnus-summary-universal-argument
1931 "\C-l" gnus-recenter
1932 "I" gnus-summary-increase-score
1933 "L" gnus-summary-lower-score
1934 "\M-i" gnus-symbolic-argument
1935 "h" gnus-summary-select-article-buffer
1937 "b" gnus-article-view-part
1938 "\M-t" gnus-summary-toggle-display-buttonized
1940 "V" gnus-summary-score-map
1941 "X" gnus-uu-extract-map
1942 "S" gnus-summary-send-map)
1944 ;; Sort of orthogonal keymap
1945 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1946 "t" gnus-summary-tick-article-forward
1947 "!" gnus-summary-tick-article-forward
1948 "d" gnus-summary-mark-as-read-forward
1949 "r" gnus-summary-mark-as-read-forward
1950 "c" gnus-summary-clear-mark-forward
1951 " " gnus-summary-clear-mark-forward
1952 "e" gnus-summary-mark-as-expirable
1953 "x" gnus-summary-mark-as-expirable
1954 "?" gnus-summary-mark-as-dormant
1955 "b" gnus-summary-set-bookmark
1956 "B" gnus-summary-remove-bookmark
1957 "#" gnus-summary-mark-as-processable
1958 "\M-#" gnus-summary-unmark-as-processable
1959 "S" gnus-summary-limit-include-expunged
1960 "C" gnus-summary-catchup
1961 "H" gnus-summary-catchup-to-here
1962 "h" gnus-summary-catchup-from-here
1963 "\C-c" gnus-summary-catchup-all
1964 "k" gnus-summary-kill-same-subject-and-select
1965 "K" gnus-summary-kill-same-subject
1966 "P" gnus-uu-mark-map)
1968 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1969 "c" gnus-summary-clear-above
1970 "u" gnus-summary-tick-above
1971 "m" gnus-summary-mark-above
1972 "k" gnus-summary-kill-below)
1974 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1975 "/" gnus-summary-limit-to-subject
1976 "n" gnus-summary-limit-to-articles
1977 "b" gnus-summary-limit-to-bodies
1978 "h" gnus-summary-limit-to-headers
1979 "w" gnus-summary-pop-limit
1980 "s" gnus-summary-limit-to-subject
1981 "a" gnus-summary-limit-to-author
1982 "u" gnus-summary-limit-to-unread
1983 "m" gnus-summary-limit-to-marks
1984 "M" gnus-summary-limit-exclude-marks
1985 "v" gnus-summary-limit-to-score
1986 "*" gnus-summary-limit-include-cached
1987 "D" gnus-summary-limit-include-dormant
1988 "T" gnus-summary-limit-include-thread
1989 "d" gnus-summary-limit-exclude-dormant
1990 "t" gnus-summary-limit-to-age
1991 "." gnus-summary-limit-to-unseen
1992 "x" gnus-summary-limit-to-extra
1993 "p" gnus-summary-limit-to-display-predicate
1994 "E" gnus-summary-limit-include-expunged
1995 "c" gnus-summary-limit-exclude-childless-dormant
1996 "C" gnus-summary-limit-mark-excluded-as-read
1997 "o" gnus-summary-insert-old-articles
1998 "N" gnus-summary-insert-new-articles
1999 "S" gnus-summary-limit-to-singletons
2000 "r" gnus-summary-limit-to-replied
2001 "R" gnus-summary-limit-to-recipient
2002 "A" gnus-summary-limit-to-address)
2004 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2005 "n" gnus-summary-next-unread-article
2006 "p" gnus-summary-prev-unread-article
2007 "N" gnus-summary-next-article
2008 "P" gnus-summary-prev-article
2009 "\C-n" gnus-summary-next-same-subject
2010 "\C-p" gnus-summary-prev-same-subject
2011 "\M-n" gnus-summary-next-unread-subject
2012 "\M-p" gnus-summary-prev-unread-subject
2013 "f" gnus-summary-first-unread-article
2014 "b" gnus-summary-best-unread-article
2015 "j" gnus-summary-goto-article
2016 "g" gnus-summary-goto-subject
2017 "l" gnus-summary-goto-last-article
2018 "o" gnus-summary-pop-article)
2020 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2021 "k" gnus-summary-kill-thread
2022 "E" gnus-summary-expire-thread
2023 "l" gnus-summary-lower-thread
2024 "i" gnus-summary-raise-thread
2025 "T" gnus-summary-toggle-threads
2026 "t" gnus-summary-rethread-current
2027 "^" gnus-summary-reparent-thread
2028 "\M-^" gnus-summary-reparent-children
2029 "s" gnus-summary-show-thread
2030 "S" gnus-summary-show-all-threads
2031 "h" gnus-summary-hide-thread
2032 "H" gnus-summary-hide-all-threads
2033 "n" gnus-summary-next-thread
2034 "p" gnus-summary-prev-thread
2035 "u" gnus-summary-up-thread
2036 "o" gnus-summary-top-thread
2037 "d" gnus-summary-down-thread
2038 "#" gnus-uu-mark-thread
2039 "\M-#" gnus-uu-unmark-thread)
2041 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2042 "g" gnus-summary-prepare
2043 "c" gnus-summary-insert-cached-articles
2044 "d" gnus-summary-insert-dormant-articles
2045 "t" gnus-summary-insert-ticked-articles)
2047 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2048 "c" gnus-summary-catchup-and-exit
2049 "C" gnus-summary-catchup-all-and-exit
2050 "E" gnus-summary-exit-no-update
2051 "Q" gnus-summary-exit
2052 "Z" gnus-summary-exit
2053 "n" gnus-summary-catchup-and-goto-next-group
2054 "p" gnus-summary-catchup-and-goto-prev-group
2055 "R" gnus-summary-reselect-current-group
2056 "G" gnus-summary-rescan-group
2057 "N" gnus-summary-next-group
2058 "s" gnus-summary-save-newsrc
2059 "P" gnus-summary-prev-group)
2061 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2062 " " gnus-summary-next-page
2063 "n" gnus-summary-next-page
2064 "\177" gnus-summary-prev-page
2065 [delete] gnus-summary-prev-page
2066 "p" gnus-summary-prev-page
2067 "\r" gnus-summary-scroll-up
2068 "\M-\r" gnus-summary-scroll-down
2069 "<" gnus-summary-beginning-of-article
2070 ">" gnus-summary-end-of-article
2071 "b" gnus-summary-beginning-of-article
2072 "e" gnus-summary-end-of-article
2073 "^" gnus-summary-refer-parent-article
2074 "r" gnus-summary-refer-parent-article
2075 "C" gnus-summary-show-complete-article
2076 "D" gnus-summary-enter-digest-group
2077 "R" gnus-summary-refer-references
2078 "T" gnus-summary-refer-thread
2079 "W" gnus-warp-to-article
2080 "g" gnus-summary-show-article
2081 "s" gnus-summary-isearch-article
2082 [tab] gnus-summary-widget-forward
2083 [backtab] gnus-summary-widget-backward
2084 "P" gnus-summary-print-article
2085 "S" gnus-sticky-article
2086 "M" gnus-mailing-list-insinuate
2087 "t" gnus-article-babel)
2089 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2090 "b" gnus-article-add-buttons
2091 "B" gnus-article-add-buttons-to-head
2092 "o" gnus-article-treat-overstrike
2093 "e" gnus-article-emphasize
2094 "w" gnus-article-fill-cited-article
2095 "Q" gnus-article-fill-long-lines
2096 "L" gnus-article-toggle-truncate-lines
2097 "C" gnus-article-capitalize-sentences
2098 "c" gnus-article-remove-cr
2099 "q" gnus-article-de-quoted-unreadable
2100 "6" gnus-article-de-base64-unreadable
2101 "Z" gnus-article-decode-HZ
2102 "A" gnus-article-treat-ansi-sequences
2103 "h" gnus-article-wash-html
2104 "u" gnus-article-unsplit-urls
2105 "s" gnus-summary-force-verify-and-decrypt
2106 "f" gnus-article-display-x-face
2107 "l" gnus-summary-stop-page-breaking
2108 "r" gnus-summary-caesar-message
2109 "m" gnus-summary-morse-message
2110 "t" gnus-summary-toggle-header
2111 "g" gnus-treat-smiley
2112 "v" gnus-summary-verbose-headers
2113 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2114 "p" gnus-article-verify-x-pgp-sig
2115 "d" gnus-article-treat-dumbquotes
2116 "U" gnus-article-treat-non-ascii
2117 "i" gnus-summary-idna-message)
2119 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2120 ;; mnemonic: deuglif*Y*
2121 "u" gnus-article-outlook-unwrap-lines
2122 "a" gnus-article-outlook-repair-attribution
2123 "c" gnus-article-outlook-rearrange-citation
2124 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2126 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2127 "a" gnus-article-hide
2128 "h" gnus-article-hide-headers
2129 "b" gnus-article-hide-boring-headers
2130 "s" gnus-article-hide-signature
2131 "c" gnus-article-hide-citation
2132 "C" gnus-article-hide-citation-in-followups
2133 "l" gnus-article-hide-list-identifiers
2134 "B" gnus-article-strip-banner
2135 "P" gnus-article-hide-pem
2136 "\C-c" gnus-article-hide-citation-maybe)
2138 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2139 "a" gnus-article-highlight
2140 "h" gnus-article-highlight-headers
2141 "c" gnus-article-highlight-citation
2142 "s" gnus-article-highlight-signature)
2144 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2145 "f" gnus-article-treat-fold-headers
2146 "u" gnus-article-treat-unfold-headers
2147 "n" gnus-article-treat-fold-newsgroups)
2149 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2150 "x" gnus-article-display-x-face
2151 "d" gnus-article-display-face
2152 "s" gnus-treat-smiley
2153 "D" gnus-article-remove-images
2154 "W" gnus-article-show-images
2155 "f" gnus-treat-from-picon
2156 "m" gnus-treat-mail-picon
2157 "n" gnus-treat-newsgroups-picon
2158 "g" gnus-treat-from-gravatar
2159 "h" gnus-treat-mail-gravatar)
2161 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2162 "w" gnus-article-decode-mime-words
2163 "c" gnus-article-decode-charset
2164 "v" gnus-mime-view-all-parts
2165 "b" gnus-article-view-part)
2167 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2168 "z" gnus-article-date-ut
2169 "u" gnus-article-date-ut
2170 "l" gnus-article-date-local
2171 "p" gnus-article-date-english
2172 "e" gnus-article-date-lapsed
2173 "o" gnus-article-date-original
2174 "i" gnus-article-date-iso8601
2175 "s" gnus-article-date-user)
2177 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2178 "t" gnus-article-remove-trailing-blank-lines
2179 "l" gnus-article-strip-leading-blank-lines
2180 "m" gnus-article-strip-multiple-blank-lines
2181 "a" gnus-article-strip-blank-lines
2182 "A" gnus-article-strip-all-blank-lines
2183 "s" gnus-article-strip-leading-space
2184 "e" gnus-article-strip-trailing-space
2185 "w" gnus-article-remove-leading-whitespace)
2187 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2189 "d" gnus-summary-describe-group
2190 "h" gnus-summary-describe-briefly
2191 "i" gnus-info-find-node)
2193 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2194 "e" gnus-summary-expire-articles
2195 "\M-\C-e" gnus-summary-expire-articles-now
2196 "\177" gnus-summary-delete-article
2197 [delete] gnus-summary-delete-article
2198 [backspace] gnus-summary-delete-article
2199 "m" gnus-summary-move-article
2200 "r" gnus-summary-respool-article
2201 "w" gnus-summary-edit-article
2202 "c" gnus-summary-copy-article
2203 "B" gnus-summary-crosspost-article
2204 "q" gnus-summary-respool-query
2205 "t" gnus-summary-respool-trace
2206 "i" gnus-summary-import-article
2207 "I" gnus-summary-create-article
2208 "p" gnus-summary-article-posted-p)
2210 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2211 "o" gnus-summary-save-article
2212 "m" gnus-summary-save-article-mail
2213 "F" gnus-summary-write-article-file
2214 "r" gnus-summary-save-article-rmail
2215 "f" gnus-summary-save-article-file
2216 "b" gnus-summary-save-article-body-file
2217 "B" gnus-summary-write-article-body-file
2218 "h" gnus-summary-save-article-folder
2219 "v" gnus-summary-save-article-vm
2220 "p" gnus-summary-pipe-output
2221 "P" gnus-summary-muttprint)
2223 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2224 "b" gnus-summary-display-buttonized
2225 "m" gnus-summary-repair-multipart
2226 "v" gnus-article-view-part
2227 "o" gnus-article-save-part
2228 "O" gnus-article-save-part-and-strip
2229 "r" gnus-article-replace-part
2230 "d" gnus-article-delete-part
2231 "t" gnus-article-view-part-as-type
2232 "j" gnus-article-jump-to-part
2233 "c" gnus-article-copy-part
2234 "C" gnus-article-view-part-as-charset
2235 "e" gnus-article-view-part-externally
2236 "H" gnus-article-browse-html-article
2237 "E" gnus-article-encrypt-body
2238 "i" gnus-article-inline-part
2239 "|" gnus-article-pipe-part)
2241 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2242 "p" gnus-summary-mark-as-processable
2243 "u" gnus-summary-unmark-as-processable
2244 "U" gnus-summary-unmark-all-processable
2245 "v" gnus-uu-mark-over
2246 "s" gnus-uu-mark-series
2247 "r" gnus-uu-mark-region
2248 "g" gnus-uu-unmark-region
2249 "R" gnus-uu-mark-by-regexp
2250 "G" gnus-uu-unmark-by-regexp
2251 "t" gnus-uu-mark-thread
2252 "T" gnus-uu-unmark-thread
2253 "a" gnus-uu-mark-all
2254 "b" gnus-uu-mark-buffer
2255 "S" gnus-uu-mark-sparse
2256 "k" gnus-summary-kill-process-mark
2257 "y" gnus-summary-yank-process-mark
2258 "w" gnus-summary-save-process-mark
2259 "i" gnus-uu-invert-processable)
2261 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2262 ;;"x" gnus-uu-extract-any
2263 "m" gnus-summary-save-parts
2264 "u" gnus-uu-decode-uu
2265 "U" gnus-uu-decode-uu-and-save
2266 "s" gnus-uu-decode-unshar
2267 "S" gnus-uu-decode-unshar-and-save
2268 "o" gnus-uu-decode-save
2269 "O" gnus-uu-decode-save
2270 "b" gnus-uu-decode-binhex
2271 "B" gnus-uu-decode-binhex
2272 "Y" gnus-uu-decode-yenc
2273 "p" gnus-uu-decode-postscript
2274 "P" gnus-uu-decode-postscript-and-save)
2277 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2278 "u" gnus-uu-decode-uu-view
2279 "U" gnus-uu-decode-uu-and-save-view
2280 "s" gnus-uu-decode-unshar-view
2281 "S" gnus-uu-decode-unshar-and-save-view
2282 "o" gnus-uu-decode-save-view
2283 "O" gnus-uu-decode-save-view
2284 "b" gnus-uu-decode-binhex-view
2285 "B" gnus-uu-decode-binhex-view
2286 "p" gnus-uu-decode-postscript-view
2287 "P" gnus-uu-decode-postscript-and-save-view)
2289 (defvar gnus-article-post-menu nil)
2291 (defconst gnus-summary-menu-maxlen 20)
2293 (defun gnus-summary-menu-split (menu)
2294 ;; If we have lots of elements, divide them into groups of 20
2295 ;; and make a pane (or submenu) for each one.
2296 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2297 (let ((menu menu) sublists next
2300 ;; Pull off the next gnus-summary-menu-maxlen elements
2301 ;; and make them the next element of sublist.
2302 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2304 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2306 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2307 (aref (car (last menu)) 0)) menu)
2311 (nreverse sublists))
2312 ;; Few elements--put them all in one pane.
2315 (defun gnus-summary-make-menu-bar ()
2316 (gnus-turn-off-edit-menu 'summary)
2318 (unless (boundp 'gnus-summary-misc-menu)
2321 gnus-summary-kill-menu gnus-summary-mode-map ""
2326 ["Customize" gnus-score-customize t])
2327 (gnus-make-score-map 'increase)
2328 (gnus-make-score-map 'lower)
2330 ["Kill below" gnus-summary-kill-below t]
2331 ["Mark above" gnus-summary-mark-above t]
2332 ["Tick above" gnus-summary-tick-above t]
2333 ["Clear above" gnus-summary-clear-above t])
2334 ["Current score" gnus-summary-current-score t]
2335 ["Set score" gnus-summary-set-score t]
2336 ["Switch current score file..." gnus-score-change-score-file t]
2337 ["Set mark below..." gnus-score-set-mark-below t]
2338 ["Set expunge below..." gnus-score-set-expunge-below t]
2339 ["Edit current score file" gnus-score-edit-current-scores t]
2340 ["Edit score file..." gnus-score-edit-file t]
2341 ["Trace score" gnus-score-find-trace t]
2342 ["Find words" gnus-score-find-favourite-words t]
2343 ["Rescore buffer" gnus-summary-rescore t]
2344 ["Increase score..." gnus-summary-increase-score t]
2345 ["Lower score..." gnus-summary-lower-score t]))))
2347 ;; Define both the Article menu in the summary buffer and the
2348 ;; equivalent Commands menu in the article buffer here for
2352 ["All" gnus-article-hide t]
2353 ["Headers" gnus-article-hide-headers t]
2354 ["Signature" gnus-article-hide-signature t]
2355 ["Citation" gnus-article-hide-citation t]
2356 ["List identifiers" gnus-article-hide-list-identifiers t]
2357 ["Banner" gnus-article-strip-banner t]
2358 ["Boring headers" gnus-article-hide-boring-headers t])
2360 ["All" gnus-article-highlight t]
2361 ["Headers" gnus-article-highlight-headers t]
2362 ["Signature" gnus-article-highlight-signature t]
2363 ["Citation" gnus-article-highlight-citation t])
2365 ["Words" gnus-article-decode-mime-words t]
2366 ["Charset" gnus-article-decode-charset t]
2367 ["QP" gnus-article-de-quoted-unreadable t]
2368 ["Base64" gnus-article-de-base64-unreadable t]
2369 ["View MIME buttons" gnus-summary-display-buttonized t]
2370 ["View all" gnus-mime-view-all-parts t]
2371 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2372 ["Encrypt body" gnus-article-encrypt-body
2373 :active (not (gnus-group-read-only-p))
2374 ,@(if (featurep 'xemacs) nil
2375 '(:help "Encrypt the message body on disk"))]
2376 ["Extract all parts..." gnus-summary-save-parts t]
2378 ["Repair multipart" gnus-summary-repair-multipart t]
2379 ["Pipe part..." gnus-article-pipe-part t]
2380 ["Inline part" gnus-article-inline-part t]
2381 ["View part as type..." gnus-article-view-part-as-type t]
2382 ["Encrypt body" gnus-article-encrypt-body
2383 :active (not (gnus-group-read-only-p))
2384 ,@(if (featurep 'xemacs) nil
2385 '(:help "Encrypt the message body on disk"))]
2386 ["View part externally" gnus-article-view-part-externally t]
2387 ["View HTML parts in browser" gnus-article-browse-html-article t]
2388 ["View part with charset..." gnus-article-view-part-as-charset t]
2389 ["Copy part" gnus-article-copy-part t]
2390 ["Save part..." gnus-article-save-part t]
2391 ["View part" gnus-article-view-part t]))
2393 ["Local" gnus-article-date-local t]
2394 ["ISO8601" gnus-article-date-iso8601 t]
2395 ["UT" gnus-article-date-ut t]
2396 ["Original" gnus-article-date-original t]
2397 ["Lapsed" gnus-article-date-lapsed t]
2398 ["User-defined" gnus-article-date-user t])
2400 ["Remove images" gnus-article-remove-images t]
2401 ["Toggle smiley" gnus-treat-smiley t]
2402 ["Show X-Face" gnus-article-display-x-face t]
2403 ["Show picons in From" gnus-treat-from-picon t]
2404 ["Show picons in mail headers" gnus-treat-mail-picon t]
2405 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2406 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2407 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2408 ("View as different encoding"
2409 ,@(gnus-summary-menu-split
2412 ;; Since easymenu under Emacs doesn't allow
2413 ;; lambda forms for menu commands, we should
2414 ;; provide intern'ed function symbols.
2415 (let ((command (intern (format "\
2416 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2420 (let ((gnus-summary-show-article-charset-alist
2422 (gnus-summary-show-article 1))))
2423 `[,(symbol-name cs) ,command t]))
2424 (sort (if (fboundp 'coding-system-list)
2425 (coding-system-list)
2426 (mapcar 'car mm-mime-mule-charset-alist))
2430 ["Leading" gnus-article-strip-leading-blank-lines t]
2431 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2432 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2433 ["All of the above" gnus-article-strip-blank-lines t]
2434 ["All" gnus-article-strip-all-blank-lines t]
2435 ["Leading space" gnus-article-strip-leading-space t]
2436 ["Trailing space" gnus-article-strip-trailing-space t]
2437 ["Leading space in headers"
2438 gnus-article-remove-leading-whitespace t])
2439 ["Overstrike" gnus-article-treat-overstrike t]
2440 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2441 ["Non-ASCII" gnus-article-treat-non-ascii t]
2442 ["Emphasis" gnus-article-emphasize t]
2443 ["Word wrap" gnus-article-fill-cited-article t]
2444 ["Fill long lines" gnus-article-fill-long-lines t]
2445 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2446 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2447 ["Remove CR" gnus-article-remove-cr t]
2448 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2449 ["Base64" gnus-article-de-base64-unreadable t]
2450 ["Rot 13" gnus-summary-caesar-message
2451 ,@(if (featurep 'xemacs) '(t)
2452 '(:help "\"Caesar rotate\" article by 13"))]
2453 ["De-IDNA" gnus-summary-idna-message t]
2454 ["Morse decode" gnus-summary-morse-message t]
2455 ["Unix pipe..." gnus-summary-pipe-message t]
2456 ["Add buttons" gnus-article-add-buttons t]
2457 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2458 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2459 ["Verbose header" gnus-summary-verbose-headers t]
2460 ["Toggle header" gnus-summary-toggle-header t]
2461 ["Unfold headers" gnus-article-treat-unfold-headers t]
2462 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2463 ["Html" gnus-article-wash-html t]
2464 ["Unsplit URLs" gnus-article-unsplit-urls t]
2465 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2466 ["Decode HZ" gnus-article-decode-HZ t]
2467 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2468 ("(Outlook) Deuglify"
2469 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2470 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2471 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2472 ["Full (Outlook) deuglify"
2473 gnus-article-outlook-deuglify-article t])
2476 ["Save in default format..." gnus-summary-save-article
2477 ,@(if (featurep 'xemacs) '(t)
2478 '(:help "Save article using default method"))]
2479 ["Save in file..." gnus-summary-save-article-file
2480 ,@(if (featurep 'xemacs) '(t)
2481 '(:help "Save article in file"))]
2482 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2483 ["Save in MH folder..." gnus-summary-save-article-folder t]
2484 ["Save in VM folder..." gnus-summary-save-article-vm t]
2485 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2486 ["Save body in file..." gnus-summary-save-article-body-file t]
2487 ["Pipe through a filter..." gnus-summary-pipe-output t]
2488 ["Print with Muttprint..." gnus-summary-muttprint t]
2489 ["Print" gnus-summary-print-article
2490 ,@(if (featurep 'xemacs) '(t)
2491 '(:help "Generate and print a PostScript image"))])
2492 ("Copy, move,... (Backend)"
2493 ,@(if (featurep 'xemacs) nil
2494 '(:help "Copying, moving, expiring articles..."))
2495 ["Respool article..." gnus-summary-respool-article t]
2496 ["Move article..." gnus-summary-move-article
2497 (gnus-check-backend-function
2498 'request-move-article gnus-newsgroup-name)]
2499 ["Copy article..." gnus-summary-copy-article t]
2500 ["Crosspost article..." gnus-summary-crosspost-article
2501 (gnus-check-backend-function
2502 'request-replace-article gnus-newsgroup-name)]
2503 ["Import file..." gnus-summary-import-article
2504 (gnus-check-backend-function
2505 'request-accept-article gnus-newsgroup-name)]
2506 ["Create article..." gnus-summary-create-article
2507 (gnus-check-backend-function
2508 'request-accept-article gnus-newsgroup-name)]
2509 ["Check if posted" gnus-summary-article-posted-p t]
2510 ["Edit article" gnus-summary-edit-article
2511 (not (gnus-group-read-only-p))]
2512 ["Delete article" gnus-summary-delete-article
2513 (gnus-check-backend-function
2514 'request-expire-articles gnus-newsgroup-name)]
2515 ["Query respool" gnus-summary-respool-query t]
2516 ["Trace respool" gnus-summary-respool-trace t]
2517 ["Delete expirable articles" gnus-summary-expire-articles-now
2518 (gnus-check-backend-function
2519 'request-expire-articles gnus-newsgroup-name)])
2521 ["Uudecode" gnus-uu-decode-uu
2522 ,@(if (featurep 'xemacs) '(t)
2523 '(:help "Decode uuencoded article(s)"))]
2524 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2525 ["Unshar" gnus-uu-decode-unshar t]
2526 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2527 ["Save" gnus-uu-decode-save t]
2528 ["Binhex" gnus-uu-decode-binhex t]
2529 ["PostScript" gnus-uu-decode-postscript t]
2530 ["All MIME parts" gnus-summary-save-parts t])
2532 ["Enter article" gnus-cache-enter-article t]
2533 ["Remove article" gnus-cache-remove-article t])
2534 ["Translate" gnus-article-babel t]
2535 ["Select article buffer" gnus-summary-select-article-buffer t]
2536 ["Make article buffer sticky" gnus-sticky-article t]
2537 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2538 ["Isearch article..." gnus-summary-isearch-article t]
2539 ["Beginning of the article" gnus-summary-beginning-of-article t]
2540 ["End of the article" gnus-summary-end-of-article t]
2541 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2542 ["Fetch referenced articles" gnus-summary-refer-references t]
2543 ["Fetch current thread" gnus-summary-refer-thread t]
2544 ["Fetch article with id..." gnus-summary-refer-article t]
2545 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2546 ["Redisplay" gnus-summary-show-article t]
2547 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2549 gnus-summary-article-menu gnus-summary-mode-map ""
2550 (cons "Article" innards))
2552 (if (not (keymapp gnus-summary-article-menu))
2554 gnus-article-commands-menu gnus-article-mode-map ""
2555 (cons "Commands" innards))
2556 ;; in Emacs, don't share menu.
2557 (setq gnus-article-commands-menu
2558 (copy-keymap gnus-summary-article-menu))
2559 (define-key gnus-article-mode-map [menu-bar commands]
2560 (cons "Commands" gnus-article-commands-menu))))
2563 gnus-summary-thread-menu gnus-summary-mode-map ""
2565 ["Find all messages in thread" gnus-summary-refer-thread t]
2566 ["Toggle threading" gnus-summary-toggle-threads t]
2567 ["Hide threads" gnus-summary-hide-all-threads t]
2568 ["Show threads" gnus-summary-show-all-threads t]
2569 ["Hide thread" gnus-summary-hide-thread t]
2570 ["Show thread" gnus-summary-show-thread t]
2571 ["Go to next thread" gnus-summary-next-thread t]
2572 ["Go to previous thread" gnus-summary-prev-thread t]
2573 ["Go down thread" gnus-summary-down-thread t]
2574 ["Go up thread" gnus-summary-up-thread t]
2575 ["Top of thread" gnus-summary-top-thread t]
2576 ["Mark thread as read" gnus-summary-kill-thread t]
2577 ["Mark thread as expired" gnus-summary-expire-thread t]
2578 ["Lower thread score" gnus-summary-lower-thread t]
2579 ["Raise thread score" gnus-summary-raise-thread t]
2580 ["Rethread current" gnus-summary-rethread-current t]))
2583 gnus-summary-post-menu gnus-summary-mode-map ""
2585 ["Send a message (mail or news)" gnus-summary-post-news
2586 ,@(if (featurep 'xemacs) '(t)
2587 '(:help "Compose a new message (mail or news)"))]
2588 ["Followup" gnus-summary-followup
2589 ,@(if (featurep 'xemacs) '(t)
2590 '(:help "Post followup to this article"))]
2591 ["Followup and yank" gnus-summary-followup-with-original
2592 ,@(if (featurep 'xemacs) '(t)
2593 '(:help "Post followup to this article, quoting its contents"))]
2594 ["Supersede article" gnus-summary-supersede-article t]
2595 ["Cancel article" gnus-summary-cancel-article
2596 ,@(if (featurep 'xemacs) '(t)
2597 '(:help "Cancel an article you posted"))]
2598 ["Reply" gnus-summary-reply t]
2599 ["Reply and yank" gnus-summary-reply-with-original t]
2600 ["Wide reply" gnus-summary-wide-reply t]
2601 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2602 ,@(if (featurep 'xemacs) '(t)
2603 '(:help "Mail a reply, quoting this article"))]
2604 ["Very wide reply" gnus-summary-very-wide-reply t]
2605 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2606 ,@(if (featurep 'xemacs) '(t)
2607 '(:help "Mail a very wide reply, quoting this article"))]
2608 ["Mail forward" gnus-summary-mail-forward t]
2609 ["Post forward" gnus-summary-post-forward t]
2610 ["Digest and mail" gnus-uu-digest-mail-forward t]
2611 ["Digest and post" gnus-uu-digest-post-forward t]
2612 ["Resend message" gnus-summary-resend-message t]
2613 ["Resend message edit" gnus-summary-resend-message-edit t]
2614 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2615 ["Send a mail" gnus-summary-mail-other-window t]
2616 ["Create a local message" gnus-summary-news-other-window t]
2617 ["Uuencode and post" gnus-uu-post-news
2618 ,@(if (featurep 'xemacs) '(t)
2619 '(:help "Post a uuencoded article"))]
2620 ["Followup via news" gnus-summary-followup-to-mail t]
2621 ["Followup via news and yank"
2622 gnus-summary-followup-to-mail-with-original t]
2623 ["Strip signature on reply"
2626 (if (not (memq message-cite-function
2627 '(message-cite-original-without-signature
2628 message-cite-original)))
2629 ;; Stupid workaround for XEmacs not honoring :visible.
2630 (message "Can't toggle this value of `message-cite-function'")
2631 (setq message-cite-function
2632 (if (eq message-cite-function
2633 'message-cite-original-without-signature)
2634 'message-cite-original
2635 'message-cite-original-without-signature))))
2636 ;; XEmacs barfs on :visible.
2637 ,@(if (featurep 'xemacs) nil
2638 '(:visible (memq message-cite-function
2639 '(message-cite-original-without-signature
2640 message-cite-original))))
2642 :selected (eq message-cite-function
2643 'message-cite-original-without-signature)
2644 ,@(if (featurep 'xemacs) nil
2645 '(:help "Strip signature from cited article when replying."))]
2647 ;;["Send" gnus-summary-send-draft t]
2648 ;;["Send bounced" gnus-resend-bounced-mail t])
2652 ((not (keymapp gnus-summary-post-menu))
2653 (setq gnus-article-post-menu gnus-summary-post-menu))
2654 ((not gnus-article-post-menu)
2655 ;; Don't share post menu.
2656 (setq gnus-article-post-menu
2657 (copy-keymap gnus-summary-post-menu))))
2658 (define-key gnus-article-mode-map [menu-bar post]
2659 (cons "Post" gnus-article-post-menu))
2662 gnus-summary-misc-menu gnus-summary-mode-map ""
2665 ["Mark as read" gnus-summary-mark-as-read-forward t]
2666 ["Mark same subject and select"
2667 gnus-summary-kill-same-subject-and-select t]
2668 ["Mark same subject" gnus-summary-kill-same-subject t]
2669 ["Catchup" gnus-summary-catchup
2670 ,@(if (featurep 'xemacs) '(t)
2671 '(:help "Mark unread articles in this group as read"))]
2672 ["Catchup all" gnus-summary-catchup-all t]
2673 ["Catchup to here" gnus-summary-catchup-to-here t]
2674 ["Catchup from here" gnus-summary-catchup-from-here t]
2675 ["Catchup region" gnus-summary-mark-region-as-read
2676 (gnus-mark-active-p)]
2677 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2679 ["Tick" gnus-summary-tick-article-forward t]
2680 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2681 ["Remove marks" gnus-summary-clear-mark-forward t]
2682 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2683 ["Set bookmark" gnus-summary-set-bookmark t]
2684 ["Remove bookmark" gnus-summary-remove-bookmark t])
2686 ["Marks..." gnus-summary-limit-to-marks t]
2687 ["Subject..." gnus-summary-limit-to-subject t]
2688 ["Author..." gnus-summary-limit-to-author t]
2689 ["Recipient..." gnus-summary-limit-to-recipient t]
2690 ["Address..." gnus-summary-limit-to-address t]
2691 ["Age..." gnus-summary-limit-to-age t]
2692 ["Extra..." gnus-summary-limit-to-extra t]
2693 ["Score..." gnus-summary-limit-to-score t]
2694 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2695 ["Unread" gnus-summary-limit-to-unread t]
2696 ["Unseen" gnus-summary-limit-to-unseen t]
2697 ["Singletons" gnus-summary-limit-to-singletons t]
2698 ["Replied" gnus-summary-limit-to-replied t]
2699 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2700 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2701 ["Pop limit" gnus-summary-pop-limit t]
2702 ["Show dormant" gnus-summary-limit-include-dormant t]
2703 ["Hide childless dormant"
2704 gnus-summary-limit-exclude-childless-dormant t]
2705 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2706 ["Hide marked" gnus-summary-limit-exclude-marks t]
2707 ["Show expunged" gnus-summary-limit-include-expunged t])
2709 ["Set mark" gnus-summary-mark-as-processable t]
2710 ["Remove mark" gnus-summary-unmark-as-processable t]
2711 ["Remove all marks" gnus-summary-unmark-all-processable t]
2712 ["Invert marks" gnus-uu-invert-processable t]
2713 ["Mark above" gnus-uu-mark-over t]
2714 ["Mark series" gnus-uu-mark-series t]
2715 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2716 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2717 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2718 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2719 ["Mark all" gnus-uu-mark-all t]
2720 ["Mark buffer" gnus-uu-mark-buffer t]
2721 ["Mark sparse" gnus-uu-mark-sparse t]
2722 ["Mark thread" gnus-uu-mark-thread t]
2723 ["Unmark thread" gnus-uu-unmark-thread t]
2724 ("Process Mark Sets"
2725 ["Kill" gnus-summary-kill-process-mark t]
2726 ["Yank" gnus-summary-yank-process-mark
2727 gnus-newsgroup-process-stack]
2728 ["Save" gnus-summary-save-process-mark t]
2729 ["Run command on marked..." gnus-summary-universal-argument t]))
2732 ["Page forward" gnus-summary-next-page
2733 ,@(if (featurep 'xemacs) '(t)
2734 '(:help "Show next page of article"))]
2735 ["Page backward" gnus-summary-prev-page
2736 ,@(if (featurep 'xemacs) '(t)
2737 '(:help "Show previous page of article"))]
2738 ["Line forward" gnus-summary-scroll-up t])
2740 ["Next unread article" gnus-summary-next-unread-article t]
2741 ["Previous unread article" gnus-summary-prev-unread-article t]
2742 ["Next article" gnus-summary-next-article t]
2743 ["Previous article" gnus-summary-prev-article t]
2744 ["Next unread subject" gnus-summary-next-unread-subject t]
2745 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2746 ["Next article same subject" gnus-summary-next-same-subject t]
2747 ["Previous article same subject" gnus-summary-prev-same-subject t]
2748 ["First unread article" gnus-summary-first-unread-article t]
2749 ["Best unread article" gnus-summary-best-unread-article t]
2750 ["Go to subject number..." gnus-summary-goto-subject t]
2751 ["Go to article number..." gnus-summary-goto-article t]
2752 ["Go to the last article" gnus-summary-goto-last-article t]
2753 ["Pop article off history" gnus-summary-pop-article t])
2755 ["Sort by number" gnus-summary-sort-by-number t]
2756 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2757 ["Sort by author" gnus-summary-sort-by-author t]
2758 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2759 ["Sort by subject" gnus-summary-sort-by-subject t]
2760 ["Sort by date" gnus-summary-sort-by-date t]
2761 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2762 ["Sort by score" gnus-summary-sort-by-score t]
2763 ["Sort by lines" gnus-summary-sort-by-lines t]
2764 ["Sort by characters" gnus-summary-sort-by-chars t]
2765 ["Randomize" gnus-summary-sort-by-random t]
2766 ["Original sort" gnus-summary-sort-by-original t])
2768 ["Describe group" gnus-summary-describe-group t]
2769 ["Read manual" gnus-info-find-node t])
2771 ["Pick and read" gnus-pick-mode t]
2772 ["Binary" gnus-binary-mode t])
2774 ["Regenerate" gnus-summary-prepare t]
2775 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2776 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2777 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2778 ["Toggle threading" gnus-summary-toggle-threads t])
2779 ["See old articles" gnus-summary-insert-old-articles t]
2780 ["See new articles" gnus-summary-insert-new-articles t]
2781 ["Filter articles..." gnus-summary-execute-command t]
2782 ["Run command on articles..." gnus-summary-universal-argument t]
2783 ["Search articles forward..." gnus-summary-search-article-forward t]
2784 ["Search articles backward..." gnus-summary-search-article-backward t]
2785 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2786 ["Expand window" gnus-summary-expand-window t]
2787 ["Expire expirable articles" gnus-summary-expire-articles
2788 (gnus-check-backend-function
2789 'request-expire-articles gnus-newsgroup-name)]
2790 ["Edit local kill file" gnus-summary-edit-local-kill t]
2791 ["Edit main kill file" gnus-summary-edit-global-kill t]
2792 ["Edit group parameters" gnus-summary-edit-parameters t]
2793 ["Customize group parameters" gnus-summary-customize-parameters t]
2794 ["Send a bug report" gnus-bug t]
2796 ["Catchup and exit" gnus-summary-catchup-and-exit
2797 ,@(if (featurep 'xemacs) '(t)
2798 '(:help "Mark unread articles in this group as read, then exit"))]
2799 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2800 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2801 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2802 ["Exit group" gnus-summary-exit
2803 ,@(if (featurep 'xemacs) '(t)
2804 '(:help "Exit current group, return to group selection mode"))]
2805 ["Exit group without updating" gnus-summary-exit-no-update t]
2806 ["Exit and goto next group" gnus-summary-next-group t]
2807 ["Exit and goto prev group" gnus-summary-prev-group t]
2808 ["Reselect group" gnus-summary-reselect-current-group t]
2809 ["Rescan group" gnus-summary-rescan-group t]
2810 ["Update dribble" gnus-summary-save-newsrc t])))
2812 (gnus-run-hooks 'gnus-summary-menu-hook)))
2814 (defvar gnus-summary-tool-bar-map nil)
2816 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2817 ;; affect _new_ message buffers. We might add a function that walks thru all
2818 ;; summary-mode buffers and force the update.
2819 (defun gnus-summary-tool-bar-update (&optional symbol value)
2820 "Update summary mode toolbar.
2821 Setter function for custom variables."
2822 (setq-default gnus-summary-tool-bar-map nil)
2824 ;; When used as ":set" function:
2825 (set-default symbol value))
2826 (when (gnus-buffer-live-p gnus-summary-buffer)
2827 (with-current-buffer gnus-summary-buffer
2828 (gnus-summary-make-tool-bar))))
2830 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2831 'gnus-summary-tool-bar-gnome
2832 'gnus-summary-tool-bar-retro)
2833 "Specifies the Gnus summary tool bar.
2835 It can be either a list or a symbol referring to a list. See
2836 `gmm-tool-bar-from-list' for the format of the list. The
2837 default key map is `gnus-summary-mode-map'.
2839 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2840 `gnus-summary-tool-bar-retro'."
2841 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2842 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2843 (repeat :tag "User defined list" gmm-tool-bar-item)
2845 :version "23.1" ;; No Gnus
2846 :initialize 'custom-initialize-default
2847 :set 'gnus-summary-tool-bar-update
2848 :group 'gnus-summary)
2850 (defcustom gnus-summary-tool-bar-gnome
2851 '((gnus-summary-post-news "mail/compose" nil)
2852 (gnus-summary-insert-new-articles "mail/inbox" nil
2853 :visible (or (not gnus-agent)
2855 (gnus-summary-reply-with-original "mail/reply")
2856 (gnus-summary-reply "mail/reply" nil :visible nil)
2857 (gnus-summary-followup-with-original "mail/reply-all")
2858 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2859 (gnus-summary-mail-forward "mail/forward")
2860 (gnus-summary-save-article "mail/save")
2861 (gnus-summary-search-article-forward "search" nil :visible nil)
2862 (gnus-summary-print-article "print")
2863 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2864 ;; Some new commands that may need more suitable icons:
2865 (gnus-summary-save-newsrc "save" nil :visible nil)
2866 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2867 (gnus-summary-prev-article "left-arrow")
2868 (gnus-summary-next-article "right-arrow")
2869 (gnus-summary-next-page "next-page")
2870 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2872 ;; Maybe some sort-by-... could be added:
2873 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2874 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2875 (gnus-summary-mark-as-expirable
2877 :visible (gnus-check-backend-function 'request-expire-articles
2878 gnus-newsgroup-name))
2879 (gnus-summary-mark-as-spam
2881 :visible (and (fboundp 'spam-group-ham-contents-p)
2882 (spam-group-ham-contents-p gnus-newsgroup-name))
2883 :help "Mark as spam")
2884 (gnus-summary-mark-as-read-forward
2886 :visible (and (fboundp 'spam-group-spam-contents-p)
2887 (spam-group-spam-contents-p gnus-newsgroup-name)))
2889 (gnus-summary-exit "exit")
2890 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2891 (gnus-info-find-node "help"))
2892 "List of functions for the summary tool bar (GNOME style).
2894 See `gmm-tool-bar-from-list' for the format of the list."
2895 :type '(repeat gmm-tool-bar-item)
2896 :version "23.1" ;; No Gnus
2897 :initialize 'custom-initialize-default
2898 :set 'gnus-summary-tool-bar-update
2899 :group 'gnus-summary)
2901 (defcustom gnus-summary-tool-bar-retro
2902 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2903 (gnus-summary-next-unread-article "gnus/next-ur")
2904 (gnus-summary-post-news "gnus/post")
2905 (gnus-summary-followup-with-original "gnus/fuwo")
2906 (gnus-summary-followup "gnus/followup")
2907 (gnus-summary-reply-with-original "gnus/reply-wo")
2908 (gnus-summary-reply "gnus/reply")
2909 (gnus-summary-caesar-message "gnus/rot13")
2910 (gnus-uu-decode-uu "gnus/uu-decode")
2911 (gnus-summary-save-article-file "gnus/save-aif")
2912 (gnus-summary-save-article "gnus/save-art")
2913 (gnus-uu-post-news "gnus/uu-post")
2914 (gnus-summary-catchup "gnus/catchup")
2915 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2916 (gnus-summary-exit "gnus/exit-summ")
2917 ;; Some new command that may need more suitable icons:
2918 (gnus-summary-print-article "gnus/print" nil :visible nil)
2919 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2920 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2921 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2922 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2923 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2924 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2926 (gnus-info-find-node "gnus/help" nil :visible nil))
2927 "List of functions for the summary tool bar (retro look).
2929 See `gmm-tool-bar-from-list' for the format of the list."
2930 :type '(repeat gmm-tool-bar-item)
2931 :version "23.1" ;; No Gnus
2932 :initialize 'custom-initialize-default
2933 :set 'gnus-summary-tool-bar-update
2934 :group 'gnus-summary)
2936 (defcustom gnus-summary-tool-bar-zap-list t
2937 "List of icon items from the global tool bar.
2938 These items are not displayed in the Gnus summary mode tool bar.
2940 See `gmm-tool-bar-from-list' for the format of the list."
2941 :type 'gmm-tool-bar-zap-list
2942 :version "23.1" ;; No Gnus
2943 :initialize 'custom-initialize-default
2944 :set 'gnus-summary-tool-bar-update
2945 :group 'gnus-summary)
2947 (defvar image-load-path)
2948 (defvar tool-bar-map)
2950 (defun gnus-summary-make-tool-bar (&optional force)
2951 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2952 When FORCE, rebuild the tool bar."
2953 (when (and (not (featurep 'xemacs))
2954 (boundp 'tool-bar-mode)
2956 (or (not gnus-summary-tool-bar-map) force))
2958 (gmm-image-load-path-for-library "gnus"
2961 (image-load-path (cons (car load-path)
2962 (when (boundp 'image-load-path)
2964 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2965 gnus-summary-tool-bar-zap-list
2966 'gnus-summary-mode-map)))
2968 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2970 (setq gnus-summary-tool-bar-map map))))
2971 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2973 (defun gnus-score-set-default (var value)
2974 "A version of set that updates the GNU Emacs menu-bar."
2976 ;; It is the message that forces the active status to be updated.
2979 (defun gnus-make-score-map (type)
2980 "Make a summary score map of type TYPE."
2983 (let ((headers '(("author" "from" string)
2984 ("subject" "subject" string)
2985 ("article body" "body" string)
2986 ("article head" "head" string)
2987 ("xref" "xref" string)
2988 ("extra header" "extra" string)
2989 ("lines" "lines" number)
2990 ("followups to author" "followup" string)))
2991 (types '((number ("less than" <)
2994 (string ("substring" s)
2998 (perms '(("temporary" (current-time-string))
3006 (if (eq type 'lower)
3011 (setq header (car headers))
3017 (let ((ts (cdr (assoc (nth 2 header) types)))
3033 'gnus-summary-score-entry
3035 (if (or (string= (nth 1 header)
3037 (string= (nth 1 header)
3040 (list 'gnus-summary-header
3042 (list 'quote (nth 1 (car ts)))
3043 (list 'gnus-score-delta-default
3050 (list (nreverse outp))))
3053 (list (nreverse outt))))
3055 (setq headers (cdr headers)))
3056 (list (nreverse outh))))))))
3059 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3060 (defvar bookmark-make-record-function)
3062 (defvar bidi-paragraph-direction)
3064 (defun gnus-summary-mode (&optional group)
3065 "Major mode for reading articles.
3067 All normal editing commands are switched off.
3068 \\<gnus-summary-mode-map>
3069 Each line in this buffer represents one article. To read an
3070 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3071 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3074 You can also post articles and send mail from this buffer. To
3075 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3076 of an article, type `\\[gnus-summary-reply]'.
3078 There are approx. one gazillion commands you can execute in this
3079 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3081 The following commands are available:
3083 \\{gnus-summary-mode-map}"
3085 (kill-all-local-variables)
3086 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3087 (gnus-summary-make-local-variables))
3088 (gnus-summary-make-local-variables)
3089 (setq gnus-newsgroup-name group)
3090 (when (gnus-visual-p 'summary-menu 'menu)
3091 (gnus-summary-make-menu-bar)
3092 (gnus-summary-make-tool-bar))
3093 (gnus-make-thread-indent-array)
3094 (gnus-simplify-mode-line)
3095 (setq major-mode 'gnus-summary-mode)
3096 (setq mode-name "Summary")
3097 (use-local-map gnus-summary-mode-map)
3098 (buffer-disable-undo)
3099 (setq buffer-read-only t ;Disable modification
3100 show-trailing-whitespace nil)
3101 (setq truncate-lines t)
3102 ;; Force paragraph direction to be left-to-right. Don't make it
3103 ;; bound globally in old Emacsen and XEmacsen.
3104 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3105 (add-to-invisibility-spec '(gnus-sum . t))
3106 (gnus-summary-set-display-table)
3107 (gnus-set-default-directory)
3108 (make-local-variable 'gnus-summary-line-format)
3109 (make-local-variable 'gnus-summary-line-format-spec)
3110 (make-local-variable 'gnus-summary-dummy-line-format)
3111 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3112 (make-local-variable 'gnus-summary-mark-positions)
3113 (gnus-make-local-hook 'pre-command-hook)
3114 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3115 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3116 (turn-on-gnus-mailing-list-mode)
3117 (mm-enable-multibyte)
3118 (set (make-local-variable 'bookmark-make-record-function)
3119 'gnus-summary-bookmark-make-record)
3120 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3121 (gnus-update-summary-mark-positions))
3123 (defun gnus-summary-make-local-variables ()
3124 "Make all the local summary buffer variables."
3126 (dolist (local gnus-summary-local-variables)
3129 (if (eq (cdr local) 'global)
3130 ;; Copy the global value of the variable.
3131 (setq global (symbol-value (car local)))
3132 ;; Use the value from the list.
3133 (setq global (eval (cdr local))))
3134 (set (make-local-variable (car local)) global))
3135 ;; Simple nil-valued local variable.
3136 (set (make-local-variable local) nil)))))
3138 ;; Summary data functions.
3140 (defmacro gnus-data-number (data)
3143 (defmacro gnus-data-set-number (data number)
3144 `(setcar ,data ,number))
3146 (defmacro gnus-data-mark (data)
3149 (defmacro gnus-data-set-mark (data mark)
3150 `(setcar (nthcdr 1 ,data) ,mark))
3152 (defmacro gnus-data-pos (data)
3155 (defmacro gnus-data-set-pos (data pos)
3156 `(setcar (nthcdr 2 ,data) ,pos))
3158 (defmacro gnus-data-header (data)
3161 (defmacro gnus-data-set-header (data header)
3162 `(setf (nth 3 ,data) ,header))
3164 (defmacro gnus-data-level (data)
3167 (defmacro gnus-data-unread-p (data)
3168 `(= (nth 1 ,data) gnus-unread-mark))
3170 (defmacro gnus-data-read-p (data)
3171 `(/= (nth 1 ,data) gnus-unread-mark))
3173 (defmacro gnus-data-pseudo-p (data)
3174 `(consp (nth 3 ,data)))
3176 (defmacro gnus-data-find (number)
3177 `(assq ,number gnus-newsgroup-data))
3179 (defmacro gnus-data-find-list (number &optional data)
3180 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3181 (memq (assq ,number bdata)
3184 (defmacro gnus-data-make (number mark pos header level)
3185 `(list ,number ,mark ,pos ,header ,level))
3187 (defun gnus-data-enter (after-article number mark pos header level offset)
3188 (let ((data (gnus-data-find-list after-article)))
3190 (error "No such article: %d" after-article))
3191 (setcdr data (cons (gnus-data-make number mark pos header level)
3193 (setq gnus-newsgroup-data-reverse nil)
3194 (gnus-data-update-list (cddr data) offset)))
3196 (defun gnus-data-enter-list (after-article list &optional offset)
3198 (let ((data (and after-article (gnus-data-find-list after-article)))
3202 (let ((odata gnus-newsgroup-data))
3203 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3205 (gnus-data-update-list odata offset)))
3206 ;; Find the last element in the list to be spliced into the main
3208 (setq list (last list))
3211 (setcdr list gnus-newsgroup-data)
3212 (setq gnus-newsgroup-data ilist)
3214 (gnus-data-update-list (cdr list) offset)))
3215 (setcdr list (cdr data))
3218 (gnus-data-update-list (cdr list) offset))))
3219 (setq gnus-newsgroup-data-reverse nil))))
3221 (defun gnus-data-remove (article &optional offset)
3222 (let ((data gnus-newsgroup-data))
3223 (if (= (gnus-data-number (car data)) article)
3225 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3226 gnus-newsgroup-data-reverse nil)
3228 (gnus-data-update-list gnus-newsgroup-data offset)))
3230 (when (= (gnus-data-number (cadr data)) article)
3231 (setcdr data (cddr data))
3233 (gnus-data-update-list (cdr data) offset))
3235 gnus-newsgroup-data-reverse nil))
3236 (setq data (cdr data))))))
3238 (defmacro gnus-data-list (backward)
3240 (or gnus-newsgroup-data-reverse
3241 (setq gnus-newsgroup-data-reverse
3242 (reverse gnus-newsgroup-data)))
3243 gnus-newsgroup-data))
3245 (defun gnus-data-update-list (data offset)
3246 "Add OFFSET to the POS of all data entries in DATA."
3247 (setq gnus-newsgroup-data-reverse nil)
3249 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3250 (setq data (cdr data))))
3252 (defun gnus-summary-article-pseudo-p (article)
3253 "Say whether this article is a pseudo article or not."
3254 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3256 (defmacro gnus-summary-article-sparse-p (article)
3257 "Say whether this article is a sparse article or not."
3258 `(memq ,article gnus-newsgroup-sparse))
3260 (defmacro gnus-summary-article-ancient-p (article)
3261 "Say whether this article is a sparse article or not."
3262 `(memq ,article gnus-newsgroup-ancient))
3264 (defun gnus-article-parent-p (number)
3265 "Say whether this article is a parent or not."
3266 (let ((data (gnus-data-find-list number)))
3267 (and (cdr data) ; There has to be an article after...
3268 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3269 (gnus-data-level (nth 1 data))))))
3271 (defun gnus-article-children (number)
3272 "Return a list of all children to NUMBER."
3273 (let* ((data (gnus-data-find-list number))
3274 (level (gnus-data-level (car data)))
3276 (setq data (cdr data))
3278 (= (gnus-data-level (car data)) (1+ level)))
3279 (push (gnus-data-number (car data)) children)
3280 (setq data (cdr data)))
3283 (defmacro gnus-summary-skip-intangible ()
3284 "If the current article is intangible, then jump to a different article."
3285 '(let ((to (get-text-property (point) 'gnus-intangible)))
3286 (and to (gnus-summary-goto-subject to))))
3288 (defmacro gnus-summary-article-intangible-p ()
3289 "Say whether this article is intangible or not."
3290 '(get-text-property (point) 'gnus-intangible))
3292 (defun gnus-article-read-p (article)
3293 "Say whether ARTICLE is read or not."
3294 (not (or (memq article gnus-newsgroup-marked)
3295 (memq article gnus-newsgroup-spam-marked)
3296 (memq article gnus-newsgroup-unreads)
3297 (memq article gnus-newsgroup-unselected)
3298 (memq article gnus-newsgroup-dormant))))
3300 ;; Some summary mode macros.
3302 (defmacro gnus-summary-article-number ()
3303 "The article number of the article on the current line.
3304 If there isn't an article number here, then we return the current
3307 (gnus-summary-skip-intangible)
3308 (or (get-text-property (point) 'gnus-number)
3309 (gnus-summary-last-subject))))
3311 (defmacro gnus-summary-article-header (&optional number)
3312 "Return the header of article NUMBER."
3313 `(gnus-data-header (gnus-data-find
3314 ,(or number '(gnus-summary-article-number)))))
3316 (defmacro gnus-summary-thread-level (&optional number)
3317 "Return the level of thread that starts with article NUMBER."
3318 `(if (and (eq gnus-summary-make-false-root 'dummy)
3319 (get-text-property (point) 'gnus-intangible))
3321 (gnus-data-level (gnus-data-find
3322 ,(or number '(gnus-summary-article-number))))))
3324 (defmacro gnus-summary-article-mark (&optional number)
3325 "Return the mark of article NUMBER."
3326 `(gnus-data-mark (gnus-data-find
3327 ,(or number '(gnus-summary-article-number)))))
3329 (defmacro gnus-summary-article-pos (&optional number)
3330 "Return the position of the line of article NUMBER."
3331 `(gnus-data-pos (gnus-data-find
3332 ,(or number '(gnus-summary-article-number)))))
3334 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3335 (defmacro gnus-summary-article-subject (&optional number)
3336 "Return current subject string or nil if nothing."
3339 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3340 '(gnus-data-header (assq (gnus-summary-article-number)
3341 gnus-newsgroup-data)))))
3344 (mail-header-subject headers))))
3346 (defmacro gnus-summary-article-score (&optional number)
3347 "Return current article score."
3348 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3349 gnus-newsgroup-scored))
3350 gnus-summary-default-score 0))
3352 (defun gnus-summary-article-children (&optional number)
3353 "Return a list of article numbers that are children of article NUMBER."
3354 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3355 (level (gnus-data-level (car data)))
3357 (while (and (setq data (cdr data))
3358 (> (setq l (gnus-data-level (car data))) level))
3359 (and (= (1+ level) l)
3360 (push (gnus-data-number (car data))
3362 (nreverse children)))
3364 (defun gnus-summary-article-parent (&optional number)
3365 "Return the article number of the parent of article NUMBER."
3366 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3367 (gnus-data-list t)))
3368 (level (gnus-data-level (car data))))
3370 () ; This is a root.
3371 ;; We search until we find an article with a level less than
3372 ;; this one. That function has to be the parent.
3373 (while (and (setq data (cdr data))
3374 (not (< (gnus-data-level (car data)) level))))
3375 (and data (gnus-data-number (car data))))))
3377 (defun gnus-unread-mark-p (mark)
3378 "Say whether MARK is the unread mark."
3379 (= mark gnus-unread-mark))
3381 (defun gnus-read-mark-p (mark)
3382 "Say whether MARK is one of the marks that mark as read.
3383 This is all marks except unread, ticked, dormant, and expirable."
3384 (not (or (= mark gnus-unread-mark)
3385 (= mark gnus-ticked-mark)
3386 (= mark gnus-spam-mark)
3387 (= mark gnus-dormant-mark)
3388 (= mark gnus-expirable-mark))))
3390 (defmacro gnus-article-mark (number)
3391 "Return the MARK of article NUMBER.
3392 This macro should only be used when computing the mark the \"first\"
3393 time; i.e., when generating the summary lines. After that,
3394 `gnus-summary-article-mark' should be used to examine the
3397 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3398 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3399 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3400 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3401 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3402 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3403 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3404 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3405 gnus-ancient-mark))))
3407 ;; Saving hidden threads.
3409 (defmacro gnus-save-hidden-threads (&rest forms)
3410 "Save hidden threads, eval FORMS, and restore the hidden threads."
3411 (let ((config (make-symbol "config")))
3412 `(let ((,config (gnus-hidden-threads-configuration)))
3416 (gnus-restore-hidden-threads-configuration ,config)))))
3417 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3418 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3420 (defun gnus-data-compute-positions ()
3421 "Compute the positions of all articles."
3422 (setq gnus-newsgroup-data-reverse nil)
3423 (let ((data gnus-newsgroup-data))
3425 (gnus-save-hidden-threads
3426 (gnus-summary-show-all-threads)
3427 (goto-char (point-min))
3429 (while (get-text-property (point) 'gnus-intangible)
3431 (gnus-data-set-pos (car data) (+ (point) 3))
3432 (setq data (cdr data))
3433 (forward-line 1))))))
3435 (defun gnus-hidden-threads-configuration ()
3436 "Return the current hidden threads configuration."
3439 (goto-char (point-min))
3441 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3442 (push (save-excursion (forward-line 0) (point)) config))
3446 (defun gnus-restore-hidden-threads-configuration (config)
3447 "Restore hidden threads configuration from CONFIG."
3449 (let (point (inhibit-read-only t))
3450 (while (setq point (pop config))
3452 (gnus-summary-hide-thread)))))
3454 ;; Various summary mode internalish functions.
3456 (defun gnus-mouse-pick-article (e)
3459 (gnus-summary-next-page nil t))
3461 (defun gnus-summary-set-display-table ()
3462 "Change the display table.
3463 Odd characters have a tendency to mess
3464 up nicely formatted displays - we make all possible glyphs
3465 display only a single character."
3467 ;; We start from the standard display table, if any.
3468 (let ((table (or (copy-sequence standard-display-table)
3469 (make-display-table)))
3471 ;; Nix out all the control chars...
3472 (while (>= (setq i (1- i)) 0)
3473 (gnus-put-display-table i [??] table))
3474 ;; ... but not newline and cr, of course. (cr is necessary for the
3475 ;; selective display).
3476 (gnus-put-display-table ?\n nil table)
3477 (gnus-put-display-table ?\r nil table)
3478 ;; We keep TAB as well.
3479 (gnus-put-display-table ?\t nil table)
3480 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3481 ;; Emacs 23 (unicode), that are not set already.
3482 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3485 (while (>= (setq i (1- i)) 127)
3486 ;; Only modify if the entry is nil.
3487 (unless (gnus-get-display-table i table)
3488 (gnus-put-display-table i [??] table))))
3489 (setq buffer-display-table table)))
3491 (defun gnus-summary-set-article-display-arrow (pos)
3492 "Update the overlay arrow to point to line at position POS."
3493 (when gnus-summary-display-arrow
3494 (make-local-variable 'overlay-arrow-position)
3495 (make-local-variable 'overlay-arrow-string)
3499 (unless overlay-arrow-position
3500 (setq overlay-arrow-position (make-marker)))
3501 (setq overlay-arrow-string "=>"
3502 overlay-arrow-position (set-marker overlay-arrow-position
3504 (current-buffer))))))
3506 (defun gnus-summary-setup-buffer (group)
3507 "Initialize summary buffer.
3508 If the setup was successful, non-nil is returned."
3509 (let ((buffer (gnus-summary-buffer-name group))
3510 (dead-name (concat "*Dead Summary "
3511 (gnus-group-decoded-name group) "*")))
3512 ;; If a dead summary buffer exists, we kill it.
3513 (when (gnus-buffer-live-p dead-name)
3514 (gnus-kill-buffer dead-name))
3515 (if (get-buffer buffer)
3518 (setq gnus-summary-buffer (current-buffer))
3519 (not gnus-newsgroup-prepared))
3520 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3521 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3522 (gnus-summary-mode group)
3523 (when (gnus-group-quit-config group)
3524 (set (make-local-variable 'gnus-single-article-buffer) nil))
3525 (make-local-variable 'gnus-article-buffer)
3526 (make-local-variable 'gnus-article-current)
3527 (make-local-variable 'gnus-original-article-buffer)
3528 (setq gnus-newsgroup-name group)
3529 ;; Set any local variables in the group parameters.
3530 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3533 (defun gnus-set-global-variables ()
3534 "Set the global equivalents of the buffer-local variables.
3535 They are set to the latest values they had. These reflect the summary
3536 buffer that was in action when the last article was fetched."
3537 (when (eq major-mode 'gnus-summary-mode)
3538 (setq gnus-summary-buffer (current-buffer))
3539 (let ((name gnus-newsgroup-name)
3540 (marked gnus-newsgroup-marked)
3541 (spam gnus-newsgroup-spam-marked)
3542 (unread gnus-newsgroup-unreads)
3543 (headers gnus-current-headers)
3544 (data gnus-newsgroup-data)
3545 (summary gnus-summary-buffer)
3546 (article-buffer gnus-article-buffer)
3547 (original gnus-original-article-buffer)
3548 (gac gnus-article-current)
3549 (reffed gnus-reffed-article-number)
3550 (score-file gnus-current-score-file)
3551 (default-charset gnus-newsgroup-charset)
3553 (let ((locals gnus-newsgroup-variables))
3555 (if (consp (car locals))
3556 (push (eval (caar locals)) vlist)
3557 (push (eval (car locals)) vlist))
3558 (setq locals (cdr locals)))
3559 (setq vlist (nreverse vlist)))
3560 (with-current-buffer gnus-group-buffer
3561 (setq gnus-newsgroup-name name
3562 gnus-newsgroup-marked marked
3563 gnus-newsgroup-spam-marked spam
3564 gnus-newsgroup-unreads unread
3565 gnus-current-headers headers
3566 gnus-newsgroup-data data
3567 gnus-article-current gac
3568 gnus-summary-buffer summary
3569 gnus-article-buffer article-buffer
3570 gnus-original-article-buffer original
3571 gnus-reffed-article-number reffed
3572 gnus-current-score-file score-file
3573 gnus-newsgroup-charset default-charset)
3574 (let ((locals gnus-newsgroup-variables))
3576 (if (consp (car locals))
3577 (set (caar locals) (pop vlist))
3578 (set (car locals) (pop vlist)))
3579 (setq locals (cdr locals))))
3580 ;; The article buffer also has local variables.
3581 (when (gnus-buffer-live-p gnus-article-buffer)
3582 (set-buffer gnus-article-buffer)
3583 (setq gnus-summary-buffer summary))))))
3585 (defun gnus-summary-article-unread-p (article)
3586 "Say whether ARTICLE is unread or not."
3587 (memq article gnus-newsgroup-unreads))
3589 (defun gnus-summary-first-article-p (&optional article)
3590 "Return whether ARTICLE is the first article in the buffer."
3591 (if (not (setq article (or article (gnus-summary-article-number))))
3593 (eq article (caar gnus-newsgroup-data))))
3595 (defun gnus-summary-last-article-p (&optional article)
3596 "Return whether ARTICLE is the last article in the buffer."
3597 (if (not (setq article (or article (gnus-summary-article-number))))
3598 ;; All non-existent numbers are the last article. :-)
3600 (not (cdr (gnus-data-find-list article)))))
3602 (defun gnus-make-thread-indent-array (&optional n)
3604 (progn (setq n 200) nil)
3605 (null gnus-thread-indent-array)
3606 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3607 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3608 gnus-thread-indent-array-level gnus-thread-indent-level)
3610 (aset gnus-thread-indent-array n
3611 (make-string (* n gnus-thread-indent-level) ? ))
3614 (defun gnus-update-summary-mark-positions ()
3615 "Compute where the summary marks are to go."
3617 (when (gnus-buffer-exists-p gnus-summary-buffer)
3618 (set-buffer gnus-summary-buffer))
3619 (let ((spec gnus-summary-line-format-spec)
3622 (gnus-set-work-buffer)
3623 (let ((gnus-tmp-unread ?Z)
3624 (gnus-replied-mark ?Z)
3625 (gnus-score-below-mark ?Z)
3626 (gnus-score-over-mark ?Z)
3627 (gnus-undownloaded-mark ?Z)
3628 (gnus-summary-line-format-spec spec)
3629 (gnus-newsgroup-downloadable '(0))
3630 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3631 case-fold-search ignores)
3632 ;; Here, all marks are bound to Z.
3633 (gnus-summary-insert-line header
3634 0 nil t gnus-tmp-unread t nil "" nil 1)
3635 (goto-char (point-min))
3636 ;; Memorize the positions of the same characters as dummy marks.
3637 (while (re-search-forward "[A-D]" nil t)
3638 (push (point) ignores))
3640 ;; We use A-D as dummy marks in order to know column positions
3641 ;; where marks should be inserted.
3642 (setq gnus-tmp-unread ?A
3643 gnus-replied-mark ?B
3644 gnus-score-below-mark ?C
3645 gnus-score-over-mark ?C
3646 gnus-undownloaded-mark ?D)
3647 (gnus-summary-insert-line header
3648 0 nil t gnus-tmp-unread t nil "" nil 1)
3649 ;; Ignore characters which aren't dummy marks.
3651 (delete-region (goto-char (1- p)) p)
3653 (goto-char (point-min))
3654 (setq pos (list (cons 'unread
3655 (and (search-forward "A" nil t)
3656 (- (point) (point-min) 1)))))
3657 (goto-char (point-min))
3658 (push (cons 'replied (and (search-forward "B" nil t)
3659 (- (point) (point-min) 1)))
3661 (goto-char (point-min))
3662 (push (cons 'score (and (search-forward "C" nil t)
3663 (- (point) (point-min) 1)))
3665 (goto-char (point-min))
3666 (push (cons 'download (and (search-forward "D" nil t)
3667 (- (point) (point-min) 1)))
3669 (setq gnus-summary-mark-positions pos))))
3671 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3672 "Insert a dummy root in the summary buffer."
3674 (gnus-add-text-properties
3675 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3676 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3678 (defun gnus-summary-extract-address-component (from)
3679 (or (car (funcall gnus-extract-address-components from))
3682 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3683 (let ((mail-parse-charset gnus-newsgroup-charset)
3684 (ignored-from-addresses (gnus-ignored-from-addresses))
3685 ; Is it really necessary to do this next part for each summary line?
3686 ; Luckily, doesn't seem to slow things down much.
3687 (mail-parse-ignored-charsets
3688 (with-current-buffer gnus-summary-buffer
3689 gnus-newsgroup-ignored-charsets)))
3691 (and ignored-from-addresses
3692 (string-match ignored-from-addresses gnus-tmp-from)
3693 (let ((extra-headers (mail-header-extra header))
3697 ((setq to (cdr (assq 'To extra-headers)))
3698 (concat gnus-summary-to-prefix
3700 (gnus-summary-extract-address-component
3701 (funcall gnus-decode-encoded-address-function to)))))
3704 (cdr (assq 'Newsgroups extra-headers))
3706 (memq 'Newsgroups gnus-extra-headers)
3707 (eq (car (gnus-find-method-for-group
3708 gnus-newsgroup-name)) 'nntp)
3709 (gnus-group-real-name gnus-newsgroup-name))))
3710 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3711 (gnus-string-mark-left-to-right
3713 (gnus-summary-extract-address-component gnus-tmp-from))))))
3715 (defun gnus-summary-insert-line (gnus-tmp-header
3716 gnus-tmp-level gnus-tmp-current
3717 undownloaded gnus-tmp-unread gnus-tmp-replied
3718 gnus-tmp-expirable gnus-tmp-subject-or-nil
3719 &optional gnus-tmp-dummy gnus-tmp-score
3721 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3722 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3724 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3725 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3726 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3727 (gnus-tmp-score-char
3728 (if (or (null gnus-summary-default-score)
3729 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3730 gnus-summary-zcore-fuzz))
3732 (if (< gnus-tmp-score gnus-summary-default-score)
3733 gnus-score-below-mark gnus-score-over-mark)))
3734 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3736 (cond (gnus-tmp-process gnus-process-mark)
3737 ((memq gnus-tmp-current gnus-newsgroup-cached)
3739 (gnus-tmp-replied gnus-replied-mark)
3740 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3741 gnus-forwarded-mark)
3742 ((memq gnus-tmp-current gnus-newsgroup-saved)
3744 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3747 (gnus-tmp-downloaded
3749 gnus-undownloaded-mark)
3750 (gnus-newsgroup-agentized
3751 gnus-downloaded-mark)
3754 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3757 ((string-match "<[^>]+> *$" gnus-tmp-from)
3758 (let ((beg (match-beginning 0)))
3759 (or (and (string-match "^\".+\"" gnus-tmp-from)
3760 (substring gnus-tmp-from 1 (1- (match-end 0))))
3761 (substring gnus-tmp-from 0 beg))))
3762 ((string-match "(.+)" gnus-tmp-from)
3763 (substring gnus-tmp-from
3764 (1+ (match-beginning 0)) (1- (match-end 0))))
3766 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3767 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3768 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3769 (inhibit-read-only t))
3770 (when (string= gnus-tmp-name "")
3771 (setq gnus-tmp-name gnus-tmp-from))
3772 (unless (numberp gnus-tmp-lines)
3773 (setq gnus-tmp-lines -1))
3774 (if (= gnus-tmp-lines -1)
3775 (setq gnus-tmp-lines "?")
3776 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3778 (gnus-put-text-property
3780 (progn (eval gnus-summary-line-format-spec) (point))
3781 'gnus-number gnus-tmp-number)
3782 (error (gnus-message 5 "Error updating the summary line")))
3783 (when (gnus-visual-p 'summary-highlight 'highlight)
3785 (gnus-summary-highlight-line)
3786 (gnus-run-hooks 'gnus-summary-update-hook)
3789 (defun gnus-summary-update-line (&optional dont-update)
3790 "Update summary line after change."
3791 (when (and gnus-summary-default-score
3792 (not gnus-summary-inhibit-highlight))
3793 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3794 (article (gnus-summary-article-number))
3795 (score (gnus-summary-article-score article)))
3797 (if (and gnus-summary-mark-below
3798 (< (gnus-summary-article-score)
3799 gnus-summary-mark-below))
3800 ;; This article has a low score, so we mark it as read.
3801 (when (memq article gnus-newsgroup-unreads)
3802 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3803 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3804 ;; This article was previously marked as read on account
3805 ;; of a low score, but now it has risen, so we mark it as
3807 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3808 (gnus-summary-update-mark
3809 (if (or (null gnus-summary-default-score)
3810 (<= (abs (- score gnus-summary-default-score))
3811 gnus-summary-zcore-fuzz))
3813 (if (< score gnus-summary-default-score)
3814 gnus-score-below-mark gnus-score-over-mark))
3816 ;; Do visual highlighting.
3817 (when (gnus-visual-p 'summary-highlight 'highlight)
3818 (gnus-summary-highlight-line)
3819 (gnus-run-hooks 'gnus-summary-update-hook)))))
3821 (defvar gnus-tmp-new-adopts nil)
3823 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3824 "Return the number of articles in THREAD.
3825 This may be 0 in some cases -- if none of the articles in
3826 the thread are to be displayed."
3828 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3830 ((not (listp thread))
3832 ((and (consp thread) (cdr thread))
3835 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3838 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3841 (when (and level (zerop level) gnus-tmp-new-adopts)
3844 'gnus-summary-number-of-articles-in-thread
3845 gnus-tmp-new-adopts))))
3847 (if (> number 1) gnus-not-empty-thread-mark
3848 gnus-empty-thread-mark)
3851 (defsubst gnus-summary-line-message-size (head)
3852 "Return pretty-printed version of message size.
3853 This function is intended to be used in
3854 `gnus-summary-line-format-alist'."
3855 (let ((c (or (mail-header-chars head) -1)))
3856 (cond ((< c 0) "n/a") ; chars not available
3857 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3858 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3859 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3860 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3862 (defcustom gnus-user-date-format-alist
3863 '(((gnus-seconds-today) . "Today, %H:%M")
3864 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3865 (604800 . "%A %H:%M") ; That's one week
3866 ((gnus-seconds-month) . "%A %d")
3867 ((gnus-seconds-year) . "%B %d")
3868 (t . "%b %d %Y")) ; This one is used when no other
3870 "Specifies date format depending on age of article.
3871 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3872 seconds) or a Lisp expression evaluating to a number. When the age of
3873 the article is less than this number, then use `format-time-string'
3874 with the corresponding FORMAT for displaying the date of the article.
3875 If AGE is not a number or a Lisp expression evaluating to a
3876 non-number, then the corresponding FORMAT is used as a default value.
3878 Note that the list is processed from the beginning, so it should be
3879 sorted by ascending AGE. Also note that items following the first
3880 non-number AGE will be ignored.
3882 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3883 and `gnus-seconds-year' in the AGE spec. They return the number of
3884 seconds passed since the start of today, of this month, of this year,
3887 :group 'gnus-summary-format
3888 :type '(alist :key-type sexp :value-type string))
3890 (defun gnus-user-date (messy-date)
3891 "Format the messy-date according to `gnus-user-date-format-alist'.
3892 Returns \" ? \" if there's bad input or if another error occurs.
3893 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3895 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3896 (now (gnus-float-time))
3897 ;;If we don't find something suitable we'll use this one
3898 (my-format "%b %d '%y"))
3899 (let* ((difference (- now messy-date))
3900 (templist gnus-user-date-format-alist)
3901 (top (eval (caar templist))))
3902 (while (if (numberp top) (< top difference) (not top))
3904 (setq templist (cdr templist))
3905 (setq top (eval (caar templist)))))
3906 (if (stringp (cdr (car templist)))
3907 (setq my-format (cdr (car templist)))))
3908 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3911 (defun gnus-summary-set-local-parameters (group)
3912 "Go through the local params of GROUP and set all variable specs in that list."
3913 (let ((vars '(quit-config active))) ; Ignore things that aren't
3915 (dolist (elem (gnus-group-find-parameter group))
3916 (and (consp elem) ; Has to be a cons.
3917 (consp (cdr elem)) ; The cdr has to be a list.
3918 (symbolp (car elem)) ; Has to be a symbol in there.
3919 (not (memq (car elem) vars))
3921 (push (car elem) vars)
3922 ;; Variables like `gnus-show-threads' that are globally
3923 ;; bound, if used as group parameters, need to get to be
3924 ;; buffer-local, whereas just parameters like `gcc-self',
3925 ;; `timestamp', etc. should not be bound as variables.
3926 (if (boundp (car elem))
3927 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3928 (eval (nth 1 elem))))))))
3930 (defun gnus-summary-read-group (group &optional show-all no-article
3931 kill-buffer no-display backward
3933 "Start reading news in newsgroup GROUP.
3934 If SHOW-ALL is non-nil, already read articles are also listed.
3935 If NO-ARTICLE is non-nil, no article is selected initially.
3936 If NO-DISPLAY, don't generate the summary buffer contents.
3937 If KILL-BUFFER, it should be a buffer that's killed once the new
3938 summary buffer has been generated.
3939 If BACKWARD, move point to the previous group in the group buffer
3940 If SELECT-ARTICLES, only select those articles from GROUP."
3944 (let ((gnus-auto-select-next nil))
3945 (or (gnus-summary-read-group-1
3946 group show-all no-article
3947 kill-buffer no-display
3950 select-articles nil)))))
3951 (eq gnus-auto-select-next 'quietly))
3952 (set-buffer gnus-group-buffer)
3953 ;; The entry function called above goes to the next
3954 ;; group automatically, so we go two groups back
3955 ;; if we are searching for the previous group.
3957 (gnus-group-prev-unread-group 2))
3958 (if (not (equal group (gnus-group-group-name)))
3959 (setq group (gnus-group-group-name))
3963 (defun gnus-summary-read-group-1 (group show-all no-article
3964 kill-buffer no-display
3965 &optional select-articles)
3966 ;; Killed foreign groups can't be entered.
3967 ;; (when (and (not (gnus-group-native-p group))
3968 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3969 ;; (error "Dead non-native groups can't be entered"))
3970 (gnus-message 7 "Retrieving newsgroup: %s..."
3971 (gnus-group-decoded-name group))
3972 (let* ((new-group (gnus-summary-setup-buffer group))
3973 (quit-config (gnus-group-quit-config group))
3974 (did-select (and new-group (gnus-select-newsgroup
3975 group show-all select-articles))))
3977 ;; This summary buffer exists already, so we just select it.
3979 (gnus-set-global-variables)
3981 (gnus-kill-or-deaden-summary kill-buffer))
3982 (gnus-configure-windows 'summary 'force)
3983 (gnus-set-mode-line 'summary)
3984 (gnus-summary-position-point)
3987 ;; We couldn't select this group.
3989 (when (and (eq major-mode 'gnus-summary-mode)
3990 (not (equal (current-buffer) kill-buffer)))
3991 (kill-buffer (current-buffer))
3992 (if (not quit-config)
3994 ;; Update the info -- marks might need to be removed,
3996 (gnus-summary-update-info)
3997 (set-buffer gnus-group-buffer)
3998 (gnus-group-jump-to-group group)
3999 (gnus-group-next-unread-group 1))
4000 (gnus-handle-ephemeral-exit quit-config)))
4001 (if (null (gnus-list-of-unread-articles group))
4002 (gnus-message 3 "Group %s contains no messages" group)
4003 (gnus-message 3 "Can't select group"))
4005 ;; The user did a `C-g' while prompting for number of articles,
4006 ;; so we exit this group.
4007 ((eq did-select 'quit)
4008 (and (eq major-mode 'gnus-summary-mode)
4009 (not (equal (current-buffer) kill-buffer))
4010 (kill-buffer (current-buffer)))
4012 (gnus-kill-or-deaden-summary kill-buffer))
4013 (if (not quit-config)
4015 (set-buffer gnus-group-buffer)
4016 (gnus-group-jump-to-group group)
4017 (gnus-configure-windows 'group 'force))
4018 (gnus-handle-ephemeral-exit quit-config))
4019 ;; Finally signal the quit.
4021 ;; The group was successfully selected.
4023 (gnus-set-global-variables)
4024 ;; Save the active value in effect when the group was entered.
4025 (setq gnus-newsgroup-active
4027 (gnus-active gnus-newsgroup-name)))
4028 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4029 ;; You can change the summary buffer in some way with this hook.
4030 (gnus-run-hooks 'gnus-select-group-hook)
4031 (when (memq 'summary (gnus-update-format-specifications
4032 nil 'summary 'summary-mode 'summary-dummy))
4033 ;; The format specification for the summary line was updated,
4034 ;; so we need to update the mark positions as well.
4035 (gnus-update-summary-mark-positions))
4036 ;; Do score processing.
4037 (when gnus-use-scoring
4038 (gnus-possibly-score-headers))
4039 ;; Check whether to fill in the gaps in the threads.
4040 (when gnus-build-sparse-threads
4041 (gnus-build-sparse-threads))
4042 ;; Find the initial limit.
4044 (let ((gnus-newsgroup-dormant nil))
4045 (gnus-summary-initial-limit show-all))
4046 (gnus-summary-initial-limit show-all))
4047 ;; Generate the summary buffer.
4049 (gnus-summary-prepare))
4050 (when gnus-use-trees
4051 (gnus-tree-open group)
4052 (setq gnus-summary-highlight-line-function
4053 'gnus-tree-highlight-article))
4054 ;; If the summary buffer is empty, but there are some low-scored
4055 ;; articles or some excluded dormants, we include these in the
4057 (when (and (zerop (buffer-size))
4059 (cond (gnus-newsgroup-dormant
4060 (gnus-summary-limit-include-dormant))
4061 ((and gnus-newsgroup-scored show-all)
4062 (gnus-summary-limit-include-expunged t))))
4063 ;; Function `gnus-apply-kill-file' must be called in this hook.
4064 (gnus-run-hooks 'gnus-apply-kill-hook)
4065 (if (and (zerop (buffer-size))
4068 ;; This newsgroup is empty.
4069 (gnus-summary-catchup-and-exit nil t)
4070 (gnus-message 6 "No unread news")
4072 (gnus-kill-or-deaden-summary kill-buffer))
4073 ;; Return nil from this function.
4075 ;; Hide conversation thread subtrees. We cannot do this in
4076 ;; gnus-summary-prepare-hook since kill processing may not
4077 ;; work with hidden articles.
4078 (gnus-summary-maybe-hide-threads)
4079 (gnus-configure-windows 'summary)
4081 (gnus-kill-or-deaden-summary kill-buffer))
4082 (gnus-summary-auto-select-subject)
4083 ;; Show first unread article if requested.
4084 (if (and (not no-article)
4086 gnus-newsgroup-unreads
4087 gnus-auto-select-first)
4089 (let ((art (gnus-summary-article-number)))
4090 (unless (and (not gnus-plugged)
4091 (or (memq art gnus-newsgroup-undownloaded)
4092 (memq art gnus-newsgroup-downloadable)))
4093 (gnus-summary-goto-article art))))
4094 ;; Don't select any articles.
4095 (gnus-summary-position-point)
4096 (gnus-configure-windows 'summary 'force)
4097 (gnus-set-mode-line 'summary))
4098 (when (and gnus-auto-center-group
4099 (get-buffer-window gnus-group-buffer t))
4100 ;; Gotta use windows, because recenter does weird stuff if
4101 ;; the current buffer ain't the displayed window.
4102 (let ((owin (selected-window)))
4103 (select-window (get-buffer-window gnus-group-buffer t))
4104 (when (gnus-group-goto-group group)
4106 (select-window owin)))
4107 ;; Mark this buffer as "prepared".
4108 (setq gnus-newsgroup-prepared t)
4109 (gnus-run-hooks 'gnus-summary-prepared-hook)
4110 (unless (gnus-ephemeral-group-p group)
4111 (gnus-group-update-group group nil t))
4114 (defun gnus-summary-auto-select-subject ()
4115 "Select the subject line on initial group entry."
4116 (goto-char (point-min))
4118 ((eq gnus-auto-select-subject 'best)
4119 (gnus-summary-best-unread-subject))
4120 ((eq gnus-auto-select-subject 'unread)
4121 (gnus-summary-first-unread-subject))
4122 ((eq gnus-auto-select-subject 'unseen)
4123 (gnus-summary-first-unseen-subject))
4124 ((eq gnus-auto-select-subject 'unseen-or-unread)
4125 (gnus-summary-first-unseen-or-unread-subject))
4126 ((eq gnus-auto-select-subject 'first)
4129 ((functionp gnus-auto-select-subject)
4130 (funcall gnus-auto-select-subject))))
4132 (defun gnus-summary-prepare ()
4133 "Generate the summary buffer."
4135 (let ((inhibit-read-only t))
4137 (setq gnus-newsgroup-data nil
4138 gnus-newsgroup-data-reverse nil)
4139 (gnus-run-hooks 'gnus-summary-generate-hook)
4140 ;; Generate the buffer, either with threads or without.
4141 (when gnus-newsgroup-headers
4142 (gnus-summary-prepare-threads
4143 (if gnus-show-threads
4144 (gnus-sort-gathered-threads
4145 (funcall gnus-summary-thread-gathering-function
4147 (gnus-cut-threads (gnus-make-threads)))))
4148 ;; Unthreaded display.
4149 (gnus-sort-articles gnus-newsgroup-headers))))
4150 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4151 ;; Call hooks for modifying summary buffer.
4152 (goto-char (point-min))
4153 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4155 (defsubst gnus-general-simplify-subject (subject)
4156 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4159 ;; Truncate the subject.
4160 (gnus-simplify-subject-functions
4161 (gnus-map-function gnus-simplify-subject-functions subject))
4162 ((numberp gnus-summary-gather-subject-limit)
4163 (setq subject (gnus-simplify-subject-re subject))
4164 (if (> (length subject) gnus-summary-gather-subject-limit)
4165 (substring subject 0 gnus-summary-gather-subject-limit)
4167 ;; Fuzzily simplify it.
4168 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4169 (gnus-simplify-subject-fuzzy subject))
4170 ;; Just remove the leading "Re:".
4172 (gnus-simplify-subject-re subject))))
4174 (if (and gnus-summary-gather-exclude-subject
4175 (string-match gnus-summary-gather-exclude-subject subject))
4176 nil ; This article shouldn't be gathered
4179 (defun gnus-summary-simplify-subject-query ()
4180 "Query where the respool algorithm would put this article."
4182 (gnus-summary-select-article)
4183 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4185 (defun gnus-gather-threads-by-subject (threads)
4186 "Gather threads by looking at Subject headers."
4187 (if (not gnus-summary-make-false-root)
4189 (let ((hashtb (gnus-make-hashtable 1024))
4192 subject hthread whole-subject)
4194 (setq subject (gnus-general-simplify-subject
4195 (setq whole-subject (mail-header-subject
4198 (if (setq hthread (gnus-gethash subject hashtb))
4200 ;; We enter a dummy root into the thread, if we
4201 ;; haven't done that already.
4202 (unless (stringp (caar hthread))
4203 (setcar hthread (list whole-subject (car hthread))))
4204 ;; We add this new gathered thread to this gathered
4206 (setcdr (car hthread)
4207 (nconc (cdar hthread) (list (car threads))))
4208 ;; Remove it from the list of threads.
4209 (setcdr prev (cdr threads))
4210 (setq threads prev))
4211 ;; Enter this thread into the hash table.
4212 (gnus-sethash subject
4213 (if gnus-summary-make-false-root-always
4215 ;; If you want a dummy root above all
4217 (setcar threads (list whole-subject
4223 (setq threads (cdr threads)))
4226 (defun gnus-gather-threads-by-references (threads)
4227 "Gather threads by looking at References headers."
4228 (let ((idhashtb (gnus-make-hashtable 1024))
4229 (thhashtb (gnus-make-hashtable 1024))
4232 ids references id gthread gid entered ref)
4234 (when (setq references (mail-header-references (caar threads)))
4235 (setq id (mail-header-id (caar threads))
4236 ids (inline (gnus-split-references references))
4238 (while (setq ref (pop ids))
4239 (setq ids (delete ref ids))
4240 (if (not (setq gid (gnus-gethash ref idhashtb)))
4242 (gnus-sethash ref id idhashtb)
4243 (gnus-sethash id threads thhashtb))
4244 (setq gthread (gnus-gethash gid thhashtb))
4246 ;; We enter a dummy root into the thread, if we
4247 ;; haven't done that already.
4248 (unless (stringp (caar gthread))
4249 (setcar gthread (list (mail-header-subject (caar gthread))
4251 ;; We add this new gathered thread to this gathered
4253 (setcdr (car gthread)
4254 (nconc (cdar gthread) (list (car threads)))))
4255 ;; Add it into the thread hash table.
4256 (gnus-sethash id gthread thhashtb)
4258 ;; Remove it from the list of threads.
4259 (setcdr prev (cdr threads))
4260 (setq threads prev))))
4262 (setq threads (cdr threads)))
4265 (defun gnus-sort-gathered-threads (threads)
4266 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4267 (let ((result threads))
4269 (when (stringp (caar threads))
4270 (setcdr (car threads)
4271 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4272 (setq threads (cdr threads)))
4275 (defun gnus-thread-loop-p (root thread)
4276 "Say whether ROOT is in THREAD."
4277 (let ((stack (list thread))
4280 (while (setq thread (pop stack))
4281 (setq th (cdr thread))
4283 (not (eq (caar th) root)))
4286 ;; We have found a loop.
4288 (setcdr thread (delq (car th) (cdr thread)))
4289 (if (boundp (setq ref-dep (intern "none"
4290 gnus-newsgroup-dependencies)))
4291 (setcdr (symbol-value ref-dep)
4292 (nconc (cdr (symbol-value ref-dep))
4294 (set ref-dep (list nil (car th))))
4297 ;; Push all the subthreads onto the stack.
4298 (push (cdr thread) stack)))
4301 (defun gnus-make-threads ()
4302 "Go through the dependency hashtb and find the roots. Return all threads."
4304 (while (catch 'infloop
4307 ;; Deal with self-referencing References loops.
4308 (when (and (car (symbol-value refs))
4315 (car (symbol-value refs)) thread))
4316 (cdr (symbol-value refs)))))))
4319 (unless (car (symbol-value refs))
4320 ;; These threads do not refer back to any other
4321 ;; articles, so they're roots.
4322 (setq threads (append (cdr (symbol-value refs)) threads))))
4323 gnus-newsgroup-dependencies)))
4326 ;; Build the thread tree.
4327 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4328 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4330 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4331 if it was already present.
4333 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4334 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4335 Message-IDs will be renamed to a unique Message-ID before being
4338 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4339 (let* ((id (mail-header-id header))
4340 (id-dep (and id (intern id dependencies)))
4341 parent-id ref ref-dep ref-header replaced)
4342 ;; Enter this `header' in the `dependencies' table.
4346 ;; The first two cases do the normal part: enter a new `header'
4347 ;; in the `dependencies' table.
4348 ((not (boundp id-dep))
4349 (set id-dep (list header)))
4350 ((null (car (symbol-value id-dep)))
4351 (setcar (symbol-value id-dep) header))
4353 ;; From here the `header' was already present in the
4354 ;; `dependencies' table.
4356 ;; Overrides an existing entry;
4357 ;; just set the header part of the entry.
4358 (setcar (symbol-value id-dep) header)
4361 ;; Renames the existing `header' to a unique Message-ID.
4362 ((not gnus-summary-ignore-duplicates)
4363 ;; An article with this Message-ID has already been seen.
4364 ;; We rename the Message-ID.
4365 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4367 (mail-header-set-id header id))
4369 ;; The last case ignores an existing entry, except it adds any
4370 ;; additional Xrefs (in case the two articles came from different
4372 ;; Also sets `header' to `nil' meaning that the `dependencies'
4373 ;; table was *not* modified.
4375 (mail-header-set-xref
4376 (car (symbol-value id-dep))
4377 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4379 (or (mail-header-xref header) "")))
4382 (when (and header (not replaced))
4383 ;; First check that we are not creating a References loop.
4384 (setq parent-id (gnus-parent-id (mail-header-references header)))
4385 (setq ref parent-id)
4387 (setq ref-dep (intern-soft ref dependencies))
4389 (setq ref-header (car (symbol-value ref-dep))))
4390 (if (string= id ref)
4391 ;; Yuk! This is a reference loop. Make the article be a
4394 (mail-header-set-references (car (symbol-value id-dep)) "none")
4396 (setq parent-id nil))
4397 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4398 (setq ref-dep (intern (or parent-id "none") dependencies))
4399 (if (boundp ref-dep)
4400 (setcdr (symbol-value ref-dep)
4401 (nconc (cdr (symbol-value ref-dep))
4402 (list (symbol-value id-dep))))
4403 (set ref-dep (list nil (symbol-value id-dep)))))
4406 (defun gnus-extract-message-id-from-in-reply-to (string)
4407 (if (string-match "<[^>]+>" string)
4408 (substring string (match-beginning 0) (match-end 0))
4411 (defun gnus-build-sparse-threads ()
4412 (let ((headers gnus-newsgroup-headers)
4413 (mail-parse-charset gnus-newsgroup-charset)
4414 (gnus-summary-ignore-duplicates t)
4415 header references generation relations
4416 subject child end new-child date)
4417 ;; First we create an alist of generations/relations, where
4418 ;; generations is how much we trust the relation, and the relation
4420 (gnus-message 7 "Making sparse threads...")
4422 (nnheader-set-temp-buffer " *gnus sparse threads*")
4423 (while (setq header (pop headers))
4424 (when (and (setq references (mail-header-references header))
4425 (not (string= references "")))
4427 (setq child (mail-header-id header)
4428 subject (mail-header-subject header)
4429 date (mail-header-date header)
4431 (while (search-backward ">" nil t)
4432 (setq end (1+ (point)))
4433 (when (search-backward "<" nil t)
4434 (setq new-child (buffer-substring (point) end))
4435 (push (list (incf generation)
4436 child (setq child new-child)
4440 (push (list (1+ generation) child nil subject) relations))
4442 (kill-buffer (current-buffer)))
4443 ;; Sort over trustworthiness.
4444 (dolist (relation (sort relations 'car-less-than-car))
4445 (when (gnus-dependencies-add-header
4446 (make-full-mail-header
4447 gnus-reffed-article-number
4448 (nth 3 relation) "" (or (nth 4 relation) "")
4450 (or (nth 2 relation) "") 0 0 "")
4451 gnus-newsgroup-dependencies nil)
4452 (push gnus-reffed-article-number gnus-newsgroup-limit)
4453 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4454 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4455 gnus-newsgroup-reads)
4456 (decf gnus-reffed-article-number)))
4457 (gnus-message 7 "Making sparse threads...done")))
4459 (defun gnus-build-old-threads ()
4460 ;; Look at all the articles that refer back to old articles, and
4461 ;; fetch the headers for the articles that aren't there. This will
4462 ;; build complete threads - if the roots haven't been expired by the
4464 (let ((mail-parse-charset gnus-newsgroup-charset)
4468 (when (not (car (symbol-value refs)))
4469 (setq heads (cdr (symbol-value refs)))
4471 (if (memq (mail-header-number (caar heads))
4472 gnus-newsgroup-dormant)
4473 (setq heads (cdr heads))
4474 (setq id (symbol-name refs))
4475 (while (and (setq id (gnus-build-get-header id))
4476 (not (car (gnus-id-to-thread id)))))
4477 (setq heads nil)))))
4478 gnus-newsgroup-dependencies)))
4480 (defsubst gnus-remove-odd-characters (string)
4481 "Translate STRING into something that doesn't contain weird characters."
4482 (mm-subst-char-in-string
4484 (mm-subst-char-in-string ?\n ?\- string t) t))
4486 ;; This function has to be called with point after the article number
4487 ;; on the beginning of the line.
4488 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4489 (let ((eol (point-at-eol))
4490 (buffer (current-buffer))
4491 header references in-reply-to)
4493 ;; overview: [num subject from date id refs chars lines misc]
4496 (narrow-to-region (point) eol)
4501 (make-full-mail-header
4503 (condition-case () ; subject
4504 (gnus-remove-odd-characters
4505 (funcall gnus-decode-encoded-word-function
4506 (setq x (nnheader-nov-field))))
4508 (condition-case () ; from
4509 (gnus-remove-odd-characters
4510 (funcall gnus-decode-encoded-address-function
4511 (setq x (nnheader-nov-field))))
4513 (nnheader-nov-field) ; date
4514 (nnheader-nov-read-message-id number) ; id
4515 (setq references (nnheader-nov-field)) ; refs
4516 (nnheader-nov-read-integer) ; chars
4517 (nnheader-nov-read-integer) ; lines
4519 (if (looking-at "Xref: ")
4520 (goto-char (match-end 0)))
4521 (nnheader-nov-field)) ; Xref
4522 (nnheader-nov-parse-extra)))) ; extra
4526 (when (and (string= references "")
4527 (setq in-reply-to (mail-header-extra header))
4528 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4529 (mail-header-set-references
4530 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4532 (when gnus-alter-header-function
4533 (funcall gnus-alter-header-function header))
4534 (gnus-dependencies-add-header header dependencies force-new)))
4536 (defun gnus-build-get-header (id)
4537 "Look through the buffer of NOV lines and find the header to ID.
4538 Enter this line into the dependencies hash table, and return
4539 the id of the parent article (if any)."
4540 (let ((deps gnus-newsgroup-dependencies)
4543 (with-current-buffer nntp-server-buffer
4544 (let ((case-fold-search nil))
4545 (goto-char (point-min))
4546 (while (and (not found)
4547 (search-forward id nil t))
4549 (setq found (looking-at
4550 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4551 (regexp-quote id))))
4552 (or found (beginning-of-line 2)))
4556 (setq header (gnus-nov-parse-line
4557 (read (current-buffer)) deps))
4558 (gnus-parent-id (mail-header-references header))))))
4560 (let ((number (mail-header-number header)))
4561 (push number gnus-newsgroup-limit)
4562 (push header gnus-newsgroup-headers)
4563 (if (memq number gnus-newsgroup-unselected)
4565 (setq gnus-newsgroup-unreads
4566 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4568 (setq gnus-newsgroup-unselected
4569 (delq number gnus-newsgroup-unselected)))
4570 (push number gnus-newsgroup-ancient)))))))
4572 (defun gnus-build-all-threads ()
4573 "Read all the headers."
4574 (let ((gnus-summary-ignore-duplicates t)
4575 (mail-parse-charset gnus-newsgroup-charset)
4576 (dependencies gnus-newsgroup-dependencies)
4578 (with-current-buffer nntp-server-buffer
4579 (let ((case-fold-search nil))
4580 (goto-char (point-min))
4583 (setq article (read (current-buffer))
4584 header (gnus-nov-parse-line article dependencies t)))
4586 (with-current-buffer gnus-summary-buffer
4587 (push header gnus-newsgroup-headers)
4588 (if (memq (setq article (mail-header-number header))
4589 gnus-newsgroup-unselected)
4591 (setq gnus-newsgroup-unreads
4592 (gnus-add-to-sorted-list
4593 gnus-newsgroup-unreads article))
4594 (setq gnus-newsgroup-unselected
4595 (delq article gnus-newsgroup-unselected)))
4596 (push article gnus-newsgroup-ancient)))
4597 (forward-line 1)))))))
4599 (defun gnus-summary-update-article-line (article header)
4600 "Update the line for ARTICLE using HEADER."
4601 (let* ((id (mail-header-id header))
4602 (thread (gnus-id-to-thread id)))
4604 (error "Article in no thread"))
4605 ;; Update the thread.
4606 (setcar thread header)
4607 (gnus-summary-goto-subject article)
4608 (let* ((datal (gnus-data-find-list article))
4610 (inhibit-read-only t)
4611 (level (gnus-summary-thread-level)))
4613 (let ((inserted (- (point)
4615 (gnus-summary-insert-line
4617 (memq article gnus-newsgroup-undownloaded)
4618 (gnus-article-mark article)
4619 (memq article gnus-newsgroup-replied)
4620 (memq article gnus-newsgroup-expirable)
4621 ;; Only insert the Subject string when it's different
4622 ;; from the previous Subject string.
4627 (mail-header-subject
4630 (gnus-data-find-list
4632 (gnus-data-list t)))))
4633 ;; Error on the side of excessive subjects.
4635 (mail-header-subject header)))
4637 (mail-header-subject header))
4638 nil (cdr (assq article gnus-newsgroup-scored))
4639 (memq article gnus-newsgroup-processable))
4642 (gnus-data-update-list
4644 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4646 (defun gnus-summary-update-article (article &optional iheader)
4647 "Update ARTICLE in the summary buffer."
4648 (set-buffer gnus-summary-buffer)
4649 (let* ((header (gnus-summary-article-header article))
4650 (id (mail-header-id header))
4651 (data (gnus-data-find article))
4652 (thread (gnus-id-to-thread id))
4653 (references (mail-header-references header))
4657 (when (and references
4658 (not (equal "" references)))
4661 (inhibit-read-only t)
4667 (delq thread parent)))
4668 (if (gnus-summary-insert-subject id header)
4669 ;; Set the (possibly) new article number in the data structure.
4670 (gnus-data-set-number data (gnus-id-to-article id))
4674 (defun gnus-rebuild-thread (id &optional line)
4675 "Rebuild the thread containing ID.
4676 If LINE, insert the rebuilt thread starting on line LINE."
4677 (let ((inhibit-read-only t)
4678 old-pos current thread data)
4679 (if (not gnus-show-threads)
4680 (setq thread (list (car (gnus-id-to-thread id))))
4681 ;; Get the thread this article is part of.
4682 (setq thread (gnus-remove-thread id)))
4683 (setq old-pos (point-at-bol))
4684 (setq current (save-excursion
4685 (and (re-search-backward "[\r\n]" nil t)
4686 (gnus-summary-article-number))))
4687 ;; If this is a gathered thread, we have to go some re-gathering.
4688 (when (stringp (car thread))
4689 (let ((subject (car thread))
4691 (setq thread (cdr thread))
4693 (unless (memq (setq thr (gnus-id-to-thread
4695 (mail-header-id (caar thread)))))
4698 (setq thread (cdr thread)))
4699 ;; We now have all (unique) roots.
4700 (if (= (length roots) 1)
4701 ;; All the loose roots are now one solid root.
4702 (setq thread (car roots))
4703 (setq thread (cons subject (gnus-sort-threads roots))))))
4705 ;; We then insert this thread into the summary buffer.
4707 (goto-char (point-min))
4708 (forward-line (1- line)))
4709 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4710 (if gnus-show-threads
4711 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4712 (gnus-summary-prepare-unthreaded thread))
4713 (setq data (nreverse gnus-newsgroup-data))
4714 (setq threads gnus-newsgroup-threads))
4715 ;; We splice the new data into the data structure.
4716 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4717 ;;!!! then we want to insert at the beginning of the buffer.
4718 ;;!!! That happens to be true with Gnus now, but that may
4719 ;;!!! change in the future. Perhaps.
4720 (gnus-data-enter-list
4721 (if line nil current) data (- (point) old-pos))
4722 (setq gnus-newsgroup-threads
4723 (nconc threads gnus-newsgroup-threads))
4724 (gnus-data-compute-positions))))
4726 (defun gnus-number-to-header (number)
4727 "Return the header for article NUMBER."
4728 (let ((headers gnus-newsgroup-headers))
4730 (not (= number (mail-header-number (car headers)))))
4735 (defun gnus-parent-headers (in-headers &optional generation)
4736 "Return the headers of the GENERATIONth parent of HEADERS."
4738 (setq generation 1))
4740 (headers in-headers)
4743 (not (zerop generation))
4744 (setq references (mail-header-references headers)))
4745 (setq headers (if (and references
4746 (setq parent (gnus-parent-id references)))
4747 (car (gnus-id-to-thread parent))
4750 (and (not (eq headers in-headers))
4753 (defun gnus-id-to-thread (id)
4754 "Return the (sub-)thread where ID appears."
4755 (gnus-gethash id gnus-newsgroup-dependencies))
4757 (defun gnus-id-to-article (id)
4758 "Return the article number of ID."
4759 (let ((thread (gnus-id-to-thread id)))
4762 (mail-header-number (car thread)))))
4764 (defun gnus-id-to-header (id)
4765 "Return the article headers of ID."
4766 (car (gnus-id-to-thread id)))
4768 (defun gnus-article-displayed-root-p (article)
4769 "Say whether ARTICLE is a root(ish) article."
4770 (let ((level (gnus-summary-thread-level article))
4771 (refs (mail-header-references (gnus-summary-article-header article)))
4777 ((null (gnus-parent-id refs)) t)
4779 (null (setq particle (gnus-id-to-article
4780 (gnus-parent-id refs))))
4781 (null (gnus-summary-thread-level particle)))))))
4783 (defun gnus-root-id (id)
4784 "Return the id of the root of the thread where ID appears."
4786 (while (and id (setq prev (car (gnus-id-to-thread id))))
4788 id (gnus-parent-id (mail-header-references prev))))
4791 (defun gnus-articles-in-thread (thread)
4792 "Return the list of articles in THREAD."
4793 (cons (mail-header-number (car thread))
4794 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4796 (defun gnus-remove-thread (id &optional dont-remove)
4797 "Remove the thread that has ID in it."
4798 (let (headers thread last-id)
4799 ;; First go up in this thread until we find the root.
4800 (setq last-id (gnus-root-id id)
4801 headers (message-flatten-list (gnus-id-to-thread last-id)))
4802 ;; We have now found the real root of this thread. It might have
4803 ;; been gathered into some loose thread, so we have to search
4804 ;; through the threads to find the thread we wanted.
4805 (let ((threads gnus-newsgroup-threads)
4808 (setq sub (car threads))
4809 (if (stringp (car sub))
4810 ;; This is a gathered thread, so we look at the roots
4811 ;; below it to find whether this article is in this
4814 (setq sub (cdr sub))
4816 (when (member (caar sub) headers)
4817 (setq thread (car threads)
4820 (setq sub (cdr sub))))
4821 ;; It's an ordinary thread, so we check it.
4822 (when (eq (car sub) (car headers))
4825 (setq threads (cdr threads)))
4826 ;; If this article is in no thread, then it's a root.
4829 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4830 (setq thread (gnus-id-to-thread last-id)))
4833 thread ; We return this thread.
4835 (if (stringp (car thread))
4837 ;; If we use dummy roots, then we have to remove the
4838 ;; dummy root as well.
4839 (when (eq gnus-summary-make-false-root 'dummy)
4840 ;; We go to the dummy root by going to
4841 ;; the first sub-"thread", and then one line up.
4842 (gnus-summary-goto-article
4843 (mail-header-number (caadr thread)))
4846 (gnus-data-compute-positions))
4847 (setq thread (cdr thread))
4849 (gnus-remove-thread-1 (car thread))
4850 (setq thread (cdr thread))))
4851 (gnus-remove-thread-1 thread))))))))
4853 (defun gnus-remove-thread-1 (thread)
4854 "Remove the thread THREAD recursively."
4855 (let ((number (mail-header-number (pop thread)))
4857 (setq thread (reverse thread))
4859 (gnus-remove-thread-1 (pop thread)))
4860 (when (setq d (gnus-data-find number))
4861 (goto-char (gnus-data-pos d))
4862 (gnus-summary-show-thread)
4868 (gnus-delete-line)))))))
4870 (defun gnus-sort-threads-recursive (threads func)
4871 (sort (mapcar (lambda (thread)
4874 (gnus-sort-threads-recursive (cdr thread) func))))
4877 (defun gnus-sort-threads-loop (threads func)
4878 (let* ((superthread (cons nil threads))
4879 (stack (list (cons superthread threads)))
4880 remaining-threads thread)
4882 (setq remaining-threads (cdr (car stack)))
4883 (if remaining-threads
4884 (progn (setq thread (car remaining-threads))
4885 (setcdr (car stack) (cdr remaining-threads))
4887 (push (cons thread (cdr thread)) stack)))
4888 (setq thread (caar stack))
4889 (setcdr thread (sort (cdr thread) func))
4893 (defun gnus-sort-threads (threads)
4895 (if (not gnus-thread-sort-functions)
4897 (gnus-message 8 "Sorting threads...")
4900 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4901 (gnus-sort-threads-recursive
4902 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4903 ;; Even after binding max-lisp-eval-depth, the recursive
4904 ;; sorter might fail for very long threads. In that case,
4905 ;; try using a (less well-tested) non-recursive sorter.
4906 (error (gnus-message 9 "Sorting threads with loop...")
4907 (gnus-sort-threads-loop
4908 threads (gnus-make-sort-function
4909 gnus-thread-sort-functions))))
4910 (gnus-message 8 "Sorting threads...done"))))
4912 (defun gnus-sort-articles (articles)
4914 (when gnus-article-sort-functions
4915 (gnus-message 7 "Sorting articles...")
4917 (setq gnus-newsgroup-headers
4918 (sort articles (gnus-make-sort-function
4919 gnus-article-sort-functions)))
4920 (gnus-message 7 "Sorting articles...done"))))
4922 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4923 (defmacro gnus-thread-header (thread)
4924 "Return header of first article in THREAD.
4925 Note that THREAD must never, ever be anything else than a variable -
4926 using some other form will lead to serious barfage."
4927 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4928 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4929 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4932 (defsubst gnus-article-sort-by-number (h1 h2)
4933 "Sort articles by article number."
4934 (< (mail-header-number h1)
4935 (mail-header-number h2)))
4937 (defun gnus-thread-sort-by-number (h1 h2)
4938 "Sort threads by root article number."
4939 (gnus-article-sort-by-number
4940 (gnus-thread-header h1) (gnus-thread-header h2)))
4942 (defsubst gnus-article-sort-by-random (h1 h2)
4943 "Sort articles randomly."
4946 (defun gnus-thread-sort-by-random (h1 h2)
4947 "Sort threads randomly."
4948 (gnus-article-sort-by-random
4949 (gnus-thread-header h1) (gnus-thread-header h2)))
4951 (defsubst gnus-article-sort-by-lines (h1 h2)
4952 "Sort articles by article Lines header."
4953 (< (mail-header-lines h1)
4954 (mail-header-lines h2)))
4956 (defun gnus-thread-sort-by-lines (h1 h2)
4957 "Sort threads by root article Lines header."
4958 (gnus-article-sort-by-lines
4959 (gnus-thread-header h1) (gnus-thread-header h2)))
4961 (defsubst gnus-article-sort-by-chars (h1 h2)
4962 "Sort articles by octet length."
4963 (< (mail-header-chars h1)
4964 (mail-header-chars h2)))
4966 (defun gnus-thread-sort-by-chars (h1 h2)
4967 "Sort threads by root article octet length."
4968 (gnus-article-sort-by-chars
4969 (gnus-thread-header h1) (gnus-thread-header h2)))
4971 (defsubst gnus-article-sort-by-author (h1 h2)
4972 "Sort articles by root author."
4974 (let ((extract (funcall
4975 gnus-extract-address-components
4976 (mail-header-from h1))))
4977 (or (car extract) (cadr extract) ""))
4978 (let ((extract (funcall
4979 gnus-extract-address-components
4980 (mail-header-from h2))))
4981 (or (car extract) (cadr extract) ""))))
4983 (defun gnus-thread-sort-by-author (h1 h2)
4984 "Sort threads by root author."
4985 (gnus-article-sort-by-author
4986 (gnus-thread-header h1) (gnus-thread-header h2)))
4988 (defsubst gnus-article-sort-by-recipient (h1 h2)
4989 "Sort articles by recipient."
4991 (let ((extract (funcall
4992 gnus-extract-address-components
4993 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4994 (or (car extract) (cadr extract)))
4995 (let ((extract (funcall
4996 gnus-extract-address-components
4997 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4998 (or (car extract) (cadr extract)))))
5000 (defun gnus-thread-sort-by-recipient (h1 h2)
5001 "Sort threads by root recipient."
5002 (gnus-article-sort-by-recipient
5003 (gnus-thread-header h1) (gnus-thread-header h2)))
5005 (defsubst gnus-article-sort-by-subject (h1 h2)
5006 "Sort articles by root subject."
5008 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5009 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5011 (defun gnus-thread-sort-by-subject (h1 h2)
5012 "Sort threads by root subject."
5013 (gnus-article-sort-by-subject
5014 (gnus-thread-header h1) (gnus-thread-header h2)))
5016 (defsubst gnus-article-sort-by-date (h1 h2)
5017 "Sort articles by root article date."
5019 (gnus-date-get-time (mail-header-date h1))
5020 (gnus-date-get-time (mail-header-date h2))))
5022 (defun gnus-thread-sort-by-date (h1 h2)
5023 "Sort threads by root article date."
5024 (gnus-article-sort-by-date
5025 (gnus-thread-header h1) (gnus-thread-header h2)))
5027 (defsubst gnus-article-sort-by-score (h1 h2)
5028 "Sort articles by root article score.
5029 Unscored articles will be counted as having a score of zero."
5030 (> (or (cdr (assq (mail-header-number h1)
5031 gnus-newsgroup-scored))
5032 gnus-summary-default-score 0)
5033 (or (cdr (assq (mail-header-number h2)
5034 gnus-newsgroup-scored))
5035 gnus-summary-default-score 0)))
5037 (defun gnus-thread-sort-by-score (h1 h2)
5038 "Sort threads by root article score."
5039 (gnus-article-sort-by-score
5040 (gnus-thread-header h1) (gnus-thread-header h2)))
5042 (defun gnus-thread-sort-by-total-score (h1 h2)
5043 "Sort threads by the sum of all scores in the thread.
5044 Unscored articles will be counted as having a score of zero."
5045 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5047 (defun gnus-thread-total-score (thread)
5048 ;; This function find the total score of THREAD.
5053 (if (stringp (car thread))
5054 (apply gnus-thread-score-function 0
5055 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5056 (gnus-thread-total-score-1 thread)))
5058 (gnus-thread-total-score-1 (list thread)))))
5060 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5061 "Sort articles by number."
5062 (gnus-article-sort-by-number h1 h2))
5064 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5065 "Sort threads such that the thread with the most recently arrived article comes first."
5066 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5068 (defun gnus-thread-highest-number (thread)
5069 "Return the highest article number in THREAD."
5070 (apply 'max (mapcar (lambda (header)
5071 (mail-header-number header))
5072 (message-flatten-list thread))))
5074 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5075 "Sort articles by number."
5076 (gnus-article-sort-by-date h1 h2))
5078 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5079 "Sort threads such that the thread with the most recently dated article comes first."
5080 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5082 ; Since this is called not only to sort the top-level threads, but
5083 ; also in recursive sorts to order the articles within a thread, each
5084 ; article will be processed many times. Thus it speeds things up
5085 ; quite a bit to use gnus-date-get-time, which caches the time value.
5086 (defun gnus-thread-latest-date (thread)
5087 "Return the highest article date in THREAD."
5089 (mapcar (lambda (header) (gnus-float-time
5091 (mail-header-date header))))
5092 (message-flatten-list thread))))
5094 (defun gnus-thread-total-score-1 (root)
5095 ;; This function find the total score of the thread below ROOT.
5096 (setq root (car root))
5097 (apply gnus-thread-score-function
5099 (mapcar 'gnus-thread-total-score
5100 (cdr (gnus-id-to-thread (mail-header-id root))))
5101 (when (> (mail-header-number root) 0)
5102 (list (or (cdr (assq (mail-header-number root)
5103 gnus-newsgroup-scored))
5104 gnus-summary-default-score 0))))
5105 (list gnus-summary-default-score)
5108 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5109 (defvar gnus-tmp-prev-subject nil)
5110 (defvar gnus-tmp-false-parent nil)
5111 (defvar gnus-tmp-root-expunged nil)
5112 (defvar gnus-tmp-dummy-line nil)
5114 (defun gnus-extra-header (type &optional header)
5115 "Return the extra header of TYPE."
5116 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5119 (defvar gnus-tmp-thread-tree-header-string "")
5121 (defcustom gnus-sum-thread-tree-root "> "
5122 "With %B spec, used for the root of a thread.
5123 If nil, use subject instead."
5125 :type '(radio (const :format "%v " nil) string)
5126 :group 'gnus-thread)
5128 (defcustom gnus-sum-thread-tree-false-root "> "
5129 "With %B spec, used for a false root of a thread.
5130 If nil, use subject instead."
5132 :type '(radio (const :format "%v " nil) string)
5133 :group 'gnus-thread)
5135 (defcustom gnus-sum-thread-tree-single-indent ""
5136 "With %B spec, used for a thread with just one message.
5137 If nil, use subject instead."
5139 :type '(radio (const :format "%v " nil) string)
5140 :group 'gnus-thread)
5142 (defcustom gnus-sum-thread-tree-vertical "| "
5143 "With %B spec, used for drawing a vertical line."
5146 :group 'gnus-thread)
5148 (defcustom gnus-sum-thread-tree-indent " "
5149 "With %B spec, used for indenting."
5152 :group 'gnus-thread)
5154 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5155 "With %B spec, used for a leaf with brothers."
5158 :group 'gnus-thread)
5160 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5161 "With %B spec, used for a leaf without brothers."
5164 :group 'gnus-thread)
5166 (defcustom gnus-summary-display-while-building nil
5167 "If non-nil, show and update the summary buffer as it's being built.
5168 If the value is t, update the buffer after every line is inserted. If
5169 the value is an integer (N), update the display every N lines."
5172 :type '(choice (const :tag "off" nil)
5174 (const :tag "frequently" t)))
5176 (defun gnus-summary-prepare-threads (threads)
5177 "Prepare summary buffer from THREADS and indentation LEVEL.
5178 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5179 or a straight list of headers."
5180 (gnus-message 7 "Generating summary...")
5182 (setq gnus-newsgroup-threads threads)
5185 (let ((gnus-tmp-level 0)
5186 (default-score (or gnus-summary-default-score 0))
5187 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5188 (building-line-count gnus-summary-display-while-building)
5189 (building-count (integerp gnus-summary-display-while-building))
5190 thread number subject stack state gnus-tmp-gathered beg-match
5191 new-roots gnus-tmp-new-adopts thread-end simp-subject
5192 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5193 gnus-tmp-replied gnus-tmp-subject-or-nil
5194 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5195 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5196 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5199 (setq gnus-tmp-prev-subject nil
5200 gnus-tmp-thread-tree-header-string "")
5202 (if (vectorp (car threads))
5203 ;; If this is a straight (sic) list of headers, then a
5204 ;; threaded summary display isn't required, so we just create
5205 ;; an unthreaded one.
5206 (gnus-summary-prepare-unthreaded threads)
5208 ;; Do the threaded display.
5210 (if gnus-summary-display-while-building
5211 (switch-to-buffer (buffer-name)))
5212 (while (or threads stack gnus-tmp-new-adopts new-roots)
5214 (if (and (= gnus-tmp-level 0)
5217 (not gnus-tmp-false-parent)
5218 (or gnus-tmp-new-adopts new-roots))
5219 (if gnus-tmp-new-adopts
5220 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5221 thread (list (car gnus-tmp-new-adopts))
5222 gnus-tmp-header (caar thread)
5223 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5225 (setq thread (list (car new-roots))
5226 gnus-tmp-header (caar thread)
5227 new-roots (cdr new-roots))))
5230 ;; If there are some threads, we do them before the
5231 ;; threads on the stack.
5232 (setq thread threads
5233 gnus-tmp-header (caar thread))
5234 ;; There were no current threads, so we pop something off
5236 (setq state (car stack)
5237 gnus-tmp-level (car state)
5238 tree-stack (cadr state)
5239 thread (caddr state)
5241 gnus-tmp-header (caar thread))))
5243 (setq gnus-tmp-false-parent nil)
5244 (setq gnus-tmp-root-expunged nil)
5245 (setq thread-end nil)
5247 (if (stringp gnus-tmp-header)
5248 ;; The header is a dummy root.
5250 ((eq gnus-summary-make-false-root 'adopt)
5251 ;; We let the first article adopt the rest.
5252 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5254 (setq gnus-tmp-gathered
5256 (lambda (h) (mail-header-number (car h)))
5259 (setq thread (cons (list (caar thread)
5262 (setq gnus-tmp-level -1
5263 gnus-tmp-false-parent t))
5264 ((eq gnus-summary-make-false-root 'empty)
5265 ;; We print adopted articles with empty subject fields.
5266 (setq gnus-tmp-gathered
5268 (lambda (h) (mail-header-number (car h)))
5271 (setq gnus-tmp-level -1))
5272 ((eq gnus-summary-make-false-root 'dummy)
5273 ;; We remember that we probably want to output a dummy
5275 (setq gnus-tmp-dummy-line gnus-tmp-header)
5276 (setq gnus-tmp-prev-subject gnus-tmp-header))
5278 ;; We do not make a root for the gathered
5279 ;; sub-threads at all.
5280 (setq gnus-tmp-level -1)))
5282 (setq number (mail-header-number gnus-tmp-header)
5283 subject (mail-header-subject gnus-tmp-header)
5284 simp-subject (gnus-simplify-subject-fully subject))
5287 ;; If the thread has changed subject, we might want to make
5288 ;; this subthread into a root.
5289 ((and (null gnus-thread-ignore-subject)
5290 (not (zerop gnus-tmp-level))
5291 gnus-tmp-prev-subject
5292 (not (string= gnus-tmp-prev-subject simp-subject)))
5293 (setq new-roots (nconc new-roots (list (car thread)))
5295 gnus-tmp-header nil))
5296 ;; If the article lies outside the current limit,
5297 ;; then we do not display it.
5298 ((not (memq number gnus-newsgroup-limit))
5299 (setq gnus-tmp-gathered
5301 (lambda (h) (mail-header-number (car h)))
5304 (setq gnus-tmp-new-adopts (if (cdar thread)
5305 (append gnus-tmp-new-adopts
5307 gnus-tmp-new-adopts)
5309 gnus-tmp-header nil)
5310 (when (zerop gnus-tmp-level)
5311 (setq gnus-tmp-root-expunged t)))
5312 ;; Perhaps this article is to be marked as read?
5313 ((and gnus-summary-mark-below
5314 (< (or (cdr (assq number gnus-newsgroup-scored))
5316 gnus-summary-mark-below)
5317 ;; Don't touch sparse articles.
5318 (not (gnus-summary-article-sparse-p number))
5319 (not (gnus-summary-article-ancient-p number)))
5320 (setq gnus-newsgroup-unreads
5321 (delq number gnus-newsgroup-unreads))
5322 (if gnus-newsgroup-auto-expire
5323 (setq gnus-newsgroup-expirable
5324 (gnus-add-to-sorted-list
5325 gnus-newsgroup-expirable number))
5326 (push (cons number gnus-low-score-mark)
5327 gnus-newsgroup-reads))))
5329 (when gnus-tmp-header
5330 ;; We may have an old dummy line to output before this
5332 (when (and gnus-tmp-dummy-line
5335 (mail-header-subject gnus-tmp-header)))
5336 (gnus-summary-insert-dummy-line
5337 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5338 (setq gnus-tmp-dummy-line nil))
5340 ;; Compute the mark.
5341 (setq gnus-tmp-unread (gnus-article-mark number))
5343 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5344 gnus-tmp-header gnus-tmp-level)
5345 gnus-newsgroup-data)
5347 ;; Actually insert the line.
5349 gnus-tmp-subject-or-nil
5351 ((and gnus-thread-ignore-subject
5352 gnus-tmp-prev-subject
5353 (not (string= gnus-tmp-prev-subject simp-subject)))
5355 ((zerop gnus-tmp-level)
5356 (if (and (eq gnus-summary-make-false-root 'empty)
5357 (memq number gnus-tmp-gathered)
5358 gnus-tmp-prev-subject
5359 (string= gnus-tmp-prev-subject simp-subject))
5360 gnus-summary-same-subject
5362 (t gnus-summary-same-subject)))
5363 (if (and (eq gnus-summary-make-false-root 'adopt)
5364 (= gnus-tmp-level 1)
5365 (memq number gnus-tmp-gathered))
5366 (setq gnus-tmp-opening-bracket ?\<
5367 gnus-tmp-closing-bracket ?\>)
5368 (setq gnus-tmp-opening-bracket ?\[
5369 gnus-tmp-closing-bracket ?\]))
5370 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5371 (gnus-make-thread-indent-array
5372 (max (* 2 (length gnus-thread-indent-array))
5375 gnus-tmp-indentation
5376 (aref gnus-thread-indent-array gnus-tmp-level)
5377 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5378 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5379 gnus-summary-default-score 0)
5381 (if (or (null gnus-summary-default-score)
5382 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5383 gnus-summary-zcore-fuzz))
5385 (if (< gnus-tmp-score gnus-summary-default-score)
5386 gnus-score-below-mark gnus-score-over-mark))
5388 (cond ((memq number gnus-newsgroup-processable)
5390 ((memq number gnus-newsgroup-cached)
5392 ((memq number gnus-newsgroup-replied)
5394 ((memq number gnus-newsgroup-forwarded)
5395 gnus-forwarded-mark)
5396 ((memq number gnus-newsgroup-saved)
5398 ((memq number gnus-newsgroup-unseen)
5402 (cond ((memq number gnus-newsgroup-undownloaded)
5403 gnus-undownloaded-mark)
5404 (gnus-newsgroup-agentized
5405 gnus-downloaded-mark)
5408 gnus-tmp-from (mail-header-from gnus-tmp-header)
5411 ((string-match "<[^>]+> *$" gnus-tmp-from)
5412 (setq beg-match (match-beginning 0))
5413 (or (and (string-match "^\".+\"" gnus-tmp-from)
5414 (substring gnus-tmp-from 1 (1- (match-end 0))))
5415 (substring gnus-tmp-from 0 beg-match)))
5416 ((string-match "(.+)" gnus-tmp-from)
5417 (substring gnus-tmp-from
5418 (1+ (match-beginning 0)) (1- (match-end 0))))
5422 gnus-tmp-thread-tree-header-string
5424 ((not gnus-show-threads) "")
5425 ((zerop gnus-tmp-level)
5426 (cond ((cdar thread)
5427 (or gnus-sum-thread-tree-root subject))
5428 (gnus-tmp-new-adopts
5429 (or gnus-sum-thread-tree-false-root subject))
5431 (or gnus-sum-thread-tree-single-indent subject))))
5433 (concat (apply 'concat
5434 (mapcar (lambda (item)
5436 gnus-sum-thread-tree-vertical
5437 gnus-sum-thread-tree-indent))
5438 (cdr (reverse tree-stack))))
5440 gnus-sum-thread-tree-leaf-with-other
5441 gnus-sum-thread-tree-single-leaf)))))
5442 (when (string= gnus-tmp-name "")
5443 (setq gnus-tmp-name gnus-tmp-from))
5444 (unless (numberp gnus-tmp-lines)
5445 (setq gnus-tmp-lines -1))
5446 (if (= gnus-tmp-lines -1)
5447 (setq gnus-tmp-lines "?")
5448 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5449 (gnus-put-text-property
5451 (progn (eval gnus-summary-line-format-spec) (point))
5452 'gnus-number number)
5455 (gnus-summary-highlight-line)
5456 (when gnus-summary-update-hook
5457 (gnus-run-hooks 'gnus-summary-update-hook))
5460 (setq gnus-tmp-prev-subject simp-subject)))
5462 (when (nth 1 thread)
5463 (push (list (max 0 gnus-tmp-level)
5464 (copy-sequence tree-stack)
5467 (push (if (nth 1 thread) 1 0) tree-stack)
5468 (incf gnus-tmp-level)
5469 (setq threads (if thread-end nil (cdar thread)))
5470 (if gnus-summary-display-while-building
5473 ;; use a set frequency
5474 (setq building-line-count (1- building-line-count))
5475 (when (= building-line-count 0)
5477 (setq building-line-count
5478 gnus-summary-display-while-building)))
5482 (setq gnus-tmp-level 0)))))
5483 (gnus-message 7 "Generating summary...done"))
5485 (defun gnus-summary-prepare-unthreaded (headers)
5486 "Generate an unthreaded summary buffer based on HEADERS."
5487 (let (header number mark)
5492 ;; We may have to root out some bad articles...
5493 (when (memq (setq number (mail-header-number
5494 (setq header (pop headers))))
5495 gnus-newsgroup-limit)
5496 ;; Mark article as read when it has a low score.
5497 (when (and gnus-summary-mark-below
5498 (< (or (cdr (assq number gnus-newsgroup-scored))
5499 gnus-summary-default-score 0)
5500 gnus-summary-mark-below)
5501 (not (gnus-summary-article-ancient-p number)))
5502 (setq gnus-newsgroup-unreads
5503 (delq number gnus-newsgroup-unreads))
5504 (if gnus-newsgroup-auto-expire
5505 (push number gnus-newsgroup-expirable)
5506 (push (cons number gnus-low-score-mark)
5507 gnus-newsgroup-reads)))
5509 (setq mark (gnus-article-mark number))
5510 (push (gnus-data-make number mark (1+ (point)) header 0)
5511 gnus-newsgroup-data)
5512 (gnus-summary-insert-line
5514 (memq number gnus-newsgroup-undownloaded)
5515 mark (memq number gnus-newsgroup-replied)
5516 (memq number gnus-newsgroup-expirable)
5517 (mail-header-subject header) nil
5518 (cdr (assq number gnus-newsgroup-scored))
5519 (memq number gnus-newsgroup-processable))))))
5521 (defun gnus-group-get-list-identifiers (group)
5522 "Get list identifier regexp for GROUP."
5523 (or (gnus-parameter-list-identifier group)
5524 (if (consp gnus-list-identifiers)
5525 (mapconcat 'identity gnus-list-identifiers " *\\|")
5526 gnus-list-identifiers)))
5528 (defun gnus-summary-remove-list-identifiers ()
5529 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5530 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5533 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5534 (dolist (header gnus-newsgroup-headers)
5535 (setq subject (mail-header-subject header)
5537 (while (string-match regexp subject)
5539 (concat (substring subject 0 (match-beginning 1))
5540 (substring subject (match-end 0)))
5543 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5545 (concat (substring subject 0 (match-beginning 1))
5546 (substring subject (match-end 1)))))
5547 (mail-header-set-subject header subject))))))
5549 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5550 "Fetch headers of ARTICLES."
5551 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5552 (gnus-message 7 "Fetching headers for %s..." name)
5555 (setq gnus-headers-retrieved-by
5556 (gnus-retrieve-headers
5557 articles gnus-newsgroup-name
5559 ;; We might want to fetch old headers, but
5560 ;; not if there is only 1 article.
5562 (not (eq gnus-fetch-old-headers 'some))
5563 (not (numberp gnus-fetch-old-headers)))
5564 (> (length articles) 1))
5565 gnus-fetch-old-headers)))))
5566 (gnus-get-newsgroup-headers-xover
5567 articles force-new dependencies gnus-newsgroup-name t)
5568 (gnus-get-newsgroup-headers dependencies force-new))
5569 (gnus-message 7 "Fetching headers for %s...done" name))))
5571 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5572 "Select newsgroup GROUP.
5573 If READ-ALL is non-nil, all articles in the group are selected.
5574 If SELECT-ARTICLES, only select those articles from GROUP."
5575 (let* ((entry (gnus-group-entry group))
5576 ;;!!! Dirty hack; should be removed.
5577 (gnus-summary-ignore-duplicates
5578 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5580 gnus-summary-ignore-duplicates))
5581 (info (nth 2 entry))
5582 charset articles fetched-articles cached)
5584 (unless (gnus-check-server
5585 (set (make-local-variable 'gnus-current-select-method)
5586 (gnus-find-method-for-group group)))
5587 (error "Couldn't open server"))
5588 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5590 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5591 (gnus-activate-group group) ; Or we can activate it...
5592 (progn ; Or we bug out.
5593 (when (equal major-mode 'gnus-summary-mode)
5594 (gnus-kill-buffer (current-buffer)))
5596 "Couldn't activate group %s: %s"
5597 (mm-decode-coding-string group charset)
5598 (mm-decode-coding-string (gnus-status-message group) charset))))
5600 (unless (gnus-request-group group t)
5601 (when (equal major-mode 'gnus-summary-mode)
5602 (gnus-kill-buffer (current-buffer)))
5603 (error "Couldn't request group %s: %s"
5604 (mm-decode-coding-string group charset)
5605 (mm-decode-coding-string (gnus-status-message group) charset)))
5607 (when (and gnus-agent
5608 (gnus-active group))
5609 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5611 (setq gnus-summary-use-undownloaded-faces
5612 (gnus-agent-find-parameter
5614 'agent-enable-undownloaded-faces)))
5616 (setq gnus-newsgroup-name group
5617 gnus-newsgroup-unselected nil
5618 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5620 (let ((display (gnus-group-find-parameter group 'display)))
5621 (setq gnus-newsgroup-display
5623 ((not (zerop (or (car-safe read-all) 0)))
5624 ;; The user entered the group with C-u SPC/RET, let's show
5630 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5632 ;; The following is probably the "correct" solution, but
5633 ;; it makes Gnus fetch all headers and then limit the
5634 ;; articles (which is slow), so instead we hack the
5635 ;; select-articles parameter instead. -- Simon Josefsson
5638 ;; (gnus-byte-compile
5639 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5641 (setq select-articles
5642 (gnus-uncompress-range
5643 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5647 (cdr (gnus-active group)))))
5652 (gnus-summary-setup-default-charset)
5654 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5655 (when (gnus-virtual-group-p group)
5656 (setq cached gnus-newsgroup-cached))
5658 (setq gnus-newsgroup-unreads
5659 (gnus-sorted-ndifference
5660 (gnus-sorted-ndifference gnus-newsgroup-unreads
5661 gnus-newsgroup-marked)
5662 gnus-newsgroup-dormant))
5664 (setq gnus-newsgroup-processable nil)
5666 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5668 ;; Adjust and set lists of article marks.
5670 (gnus-adjust-marked-articles info))
5671 (if (setq articles select-articles)
5672 (setq gnus-newsgroup-unselected
5673 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5674 (setq articles (gnus-articles-to-read group read-all)))
5678 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5680 ((eq articles 0) nil)
5682 ;; Init the dependencies hash table.
5683 (setq gnus-newsgroup-dependencies
5684 (gnus-make-hashtable (length articles)))
5685 (gnus-set-global-variables)
5686 ;; Retrieve the headers and read them in.
5688 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5690 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5692 (setq gnus-newsgroup-cached cached))
5694 ;; Suppress duplicates?
5695 (when gnus-suppress-duplicates
5696 (gnus-dup-suppress-articles))
5698 ;; Set the initial limit.
5699 (setq gnus-newsgroup-limit (copy-sequence articles))
5700 ;; Remove canceled articles from the list of unread articles.
5701 (setq fetched-articles
5702 (mapcar (lambda (headers) (mail-header-number headers))
5703 gnus-newsgroup-headers))
5704 (setq gnus-newsgroup-articles fetched-articles)
5705 (setq gnus-newsgroup-unreads
5706 (gnus-sorted-nintersection
5707 gnus-newsgroup-unreads fetched-articles))
5708 (gnus-compute-unseen-list)
5710 ;; Removed marked articles that do not exist.
5711 (gnus-update-missing-marks
5712 (gnus-sorted-difference articles fetched-articles))
5713 ;; We might want to build some more threads first.
5714 (when (and gnus-fetch-old-headers
5715 (eq gnus-headers-retrieved-by 'nov))
5716 (if (eq gnus-fetch-old-headers 'invisible)
5717 (gnus-build-all-threads)
5718 (gnus-build-old-threads)))
5719 ;; Let the Gnus agent mark articles as read.
5721 (gnus-agent-get-undownloaded-list))
5722 ;; Remove list identifiers from subject
5723 (gnus-summary-remove-list-identifiers)
5724 ;; Check whether auto-expire is to be done in this group.
5725 (setq gnus-newsgroup-auto-expire
5726 (and (gnus-group-auto-expirable-p group)
5727 (not (gnus-group-read-only-p group))))
5728 ;; Set up the article buffer now, if necessary.
5729 (unless (and gnus-single-article-buffer
5730 (equal gnus-article-buffer "*Article*"))
5731 (gnus-article-setup-buffer))
5732 ;; First and last article in this newsgroup.
5733 (when gnus-newsgroup-headers
5734 (setq gnus-newsgroup-begin
5735 (mail-header-number (car gnus-newsgroup-headers))
5738 (gnus-last-element gnus-newsgroup-headers))))
5739 ;; GROUP is successfully selected.
5740 (or gnus-newsgroup-headers t)))))
5742 (defun gnus-compute-unseen-list ()
5743 ;; The `seen' marks are treated specially.
5744 (if (not gnus-newsgroup-seen)
5745 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5746 (setq gnus-newsgroup-unseen
5747 (gnus-inverse-list-range-intersection
5748 gnus-newsgroup-articles gnus-newsgroup-seen))))
5750 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5752 (defun gnus-summary-display-make-predicate (display)
5753 (require 'gnus-agent)
5754 (when (= (length display) 1)
5755 (setq display (car display)))
5756 (unless gnus-summary-display-cache
5757 (dolist (elem (append '((unread . unread)
5760 gnus-article-mark-lists))
5761 (push (cons (cdr elem)
5762 (gnus-byte-compile ;Why bother?
5763 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5764 gnus-summary-display-cache)))
5765 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5766 (gnus-category-predicate-cache gnus-summary-display-cache))
5767 (gnus-get-predicate display)))
5769 ;; Uses the dynamically bound `gnus-number' variable.
5770 (defvar gnus-number)
5771 (defun gnus-article-marked-p (type &optional article)
5772 (let ((article (or article gnus-number)))
5775 (memq article gnus-newsgroup-marked))
5777 (memq article gnus-newsgroup-spam-marked))
5779 (memq article gnus-newsgroup-unsendable))
5780 ((eq type 'undownload)
5781 (memq article gnus-newsgroup-undownloaded))
5782 ((eq type 'download)
5783 (memq article gnus-newsgroup-downloadable))
5785 (memq article gnus-newsgroup-unreads))
5787 (memq article gnus-newsgroup-reads))
5789 (memq article gnus-newsgroup-dormant) )
5791 (memq article gnus-newsgroup-expirable))
5793 (memq article gnus-newsgroup-replied))
5795 (memq article gnus-newsgroup-killed))
5796 ((eq type 'bookmark)
5797 (assq article gnus-newsgroup-bookmarks))
5799 (assq article gnus-newsgroup-scored))
5801 (memq article gnus-newsgroup-saved))
5803 (memq article gnus-newsgroup-cached))
5805 (memq article gnus-newsgroup-forwarded))
5807 (not (memq article gnus-newsgroup-unseen)))
5810 (defun gnus-articles-to-read (group &optional read-all)
5811 "Find out what articles the user wants to read."
5812 (let* ((only-read-p t)
5814 (gnus-list-range-difference
5815 ;; Select all articles if `read-all' is non-nil, or if there
5816 ;; are no unread articles.
5818 (and (zerop (length gnus-newsgroup-marked))
5819 (zerop (length gnus-newsgroup-unreads)))
5820 ;; Fetch all if the predicate is non-nil.
5821 gnus-newsgroup-display)
5822 ;; We want to select the headers for all the articles in
5823 ;; the group, so we select either all the active
5824 ;; articles in the group, or (if that's nil), the
5825 ;; articles in the cache.
5827 (if gnus-newsgroup-maximum-articles
5828 (let ((active (gnus-active group)))
5829 (gnus-uncompress-range
5830 (cons (max (car active)
5832 gnus-newsgroup-maximum-articles
5835 (gnus-uncompress-range (gnus-active group)))
5836 (gnus-cache-articles-in-group group))
5837 ;; Select only the "normal" subset of articles.
5838 (setq only-read-p nil)
5840 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5841 gnus-newsgroup-unreads))
5842 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5843 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5844 (scored (length scored-list))
5845 (number (length articles))
5846 (marked (+ (length gnus-newsgroup-marked)
5847 (length gnus-newsgroup-dormant)))
5852 ((numberp gnus-newsgroup-display)
5853 gnus-newsgroup-display)
5857 ((and (or (<= scored marked) (= scored number))
5858 (numberp gnus-large-newsgroup)
5859 (> number gnus-large-newsgroup))
5860 (let* ((cursor-in-echo-area nil)
5861 (initial (gnus-parameter-large-newsgroup-initial
5862 gnus-newsgroup-name))
5863 (default (if only-read-p
5864 (or initial gnus-large-newsgroup)
5870 "How many articles from %s (available %d, default %d): "
5871 (gnus-group-decoded-name
5872 (gnus-group-real-name gnus-newsgroup-name))
5875 "How many articles from %s (%d default): "
5876 (gnus-group-decoded-name
5877 (gnus-group-real-name gnus-newsgroup-name))
5881 (number-to-string default))))
5882 (if (string-match "^[ \t]*$" input) number input)))
5883 ((and (> scored marked) (< scored number)
5884 (> (- scored number) 20))
5887 (format "%s %s (%d scored, %d total): "
5888 "How many articles from"
5889 (gnus-group-decoded-name
5890 (gnus-group-real-name gnus-newsgroup-name))
5892 (if (string-match "^[ \t]*$" input)
5896 (message "Quit getting the articles to read")
5898 (setq select (if (stringp select) (string-to-number select) select))
5899 (if (or (null select) (zerop select))
5901 (if (and (not (zerop scored)) (<= (abs select) scored))
5903 (setq articles (sort scored-list '<))
5904 (setq number (length articles)))
5905 (setq articles (copy-sequence articles)))
5907 (when (< (abs select) number)
5909 ;; Select the N oldest articles.
5910 (setcdr (nthcdr (1- (abs select)) articles) nil)
5911 ;; Select the N most recent articles.
5912 (setq articles (nthcdr (- number select) articles))))
5913 (setq gnus-newsgroup-unselected
5914 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5915 (when gnus-alter-articles-to-read-function
5918 (funcall gnus-alter-articles-to-read-function
5919 gnus-newsgroup-name articles)
5923 (defun gnus-killed-articles (killed articles)
5926 (when (inline (gnus-member-of-range (car articles) killed))
5927 (push (car articles) out))
5928 (setq articles (cdr articles)))
5931 (defun gnus-uncompress-marks (marks)
5932 "Uncompress the mark ranges in MARKS."
5933 (let ((uncompressed '(score bookmark))
5936 (if (memq (caar marks) uncompressed)
5937 (push (car marks) out)
5938 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5939 (setq marks (cdr marks)))
5942 (defun gnus-article-mark-to-type (mark)
5943 "Return the type of MARK."
5944 (or (cadr (assq mark gnus-article-special-mark-lists))
5947 (defun gnus-article-unpropagatable-p (mark)
5948 "Return whether MARK should be propagated to back end."
5949 (memq mark gnus-article-unpropagated-mark-lists))
5951 (defun gnus-adjust-marked-articles (info)
5952 "Set all article lists and remove all marks that are no longer valid."
5953 (let* ((marked-lists (gnus-info-marks info))
5954 (active (gnus-active (gnus-info-group info)))
5957 (types gnus-article-mark-lists)
5958 marks var articles article mark mark-type
5960 ;; Hack to avoid adjusting marks for imap.
5961 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5965 (dolist (marks marked-lists)
5966 (setq mark (car marks)
5967 mark-type (gnus-article-mark-to-type mark)
5968 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5969 ;; We set the variable according to the type of the marks list,
5970 ;; and then adjust the marks to a subset of the active articles.
5972 ;; Adjust "simple" lists - compressed yet unsorted
5973 ((eq mark-type 'list)
5974 ;; Simultaneously uncompress and clip to active range
5975 ;; See gnus-uncompress-range for a description of possible marks
5977 (if (not (cadr marks))
5979 (setq articles (if (numberp (cddr marks))
5985 (while (setq article (pop articles))
5986 (cond ((consp article)
5987 (setq bgn (max (car article) min)
5988 end (min (cdr article) max))
5990 (setq l (setcdr l (cons bgn nil))
5992 ((and (<= min article)
5994 (setq l (setcdr l (cons article nil))))))
5995 (set var (cdr lh)))))
5997 ((eq mark-type 'tuple)
5998 (set var (setq articles (cdr marks)))
5999 (when (not (listp (cdr (symbol-value var))))
6000 (set var (list (symbol-value var))))
6001 (when (not (listp (cdr articles)))
6002 (setq articles (list articles)))
6004 (when (or (not (consp (setq article (pop articles))))
6005 (< (car article) min)
6006 (> (car article) max))
6007 (set var (delq article (symbol-value var))))))
6008 ;; Adjust ranges (sloppily).
6009 ((eq mark-type 'range)
6012 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6013 ;; It should be (seen (NUM1 . NUM2)).
6014 (when (numberp (cddr marks))
6015 (setcdr marks (list (cdr marks))))
6016 (setq articles (cdr marks))
6017 (while (and articles
6018 (or (and (consp (car articles))
6019 (> min (cdar articles)))
6020 (and (numberp (car articles))
6021 (> min (car articles)))))
6025 (set var (cdr marks)))))))))
6027 (defun gnus-update-missing-marks (missing)
6028 "Go through the list of MISSING articles and remove them from the mark lists."
6031 ;; Go through all types.
6032 (dolist (elem gnus-article-mark-lists)
6033 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6034 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6035 (when (symbol-value var)
6036 ;; This list has articles. So we delete all missing
6037 ;; articles from it.
6040 (set var (delq (pop m) (symbol-value var))))))))))
6042 (defun gnus-update-marks ()
6043 "Enter the various lists of marked articles into the newsgroup info list."
6044 (let ((types gnus-article-mark-lists)
6045 (info (gnus-get-info gnus-newsgroup-name))
6046 type list newmarked symbol delta-marks)
6048 ;; Add all marks lists to the list of marks lists.
6049 (while (setq type (pop types))
6050 (setq list (symbol-value
6052 (intern (format "gnus-newsgroup-%s" (car type))))))
6055 ;; Get rid of the entries of the articles that have the
6057 (when (and (eq (cdr type) 'score)
6061 (prev (cons nil list))
6064 (if (or (not (consp (car arts)))
6065 (= (cdar arts) gnus-summary-default-score))
6066 (setcdr prev (cdr arts))
6068 (setq arts (cdr arts)))
6069 (setq list (cdr all)))))
6071 (when (eq (cdr type) 'seen)
6072 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6074 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6075 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6077 (when (and (gnus-check-backend-function
6078 'request-set-mark gnus-newsgroup-name)
6079 (not (gnus-article-unpropagatable-p (cdr type))))
6080 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6081 ;; Don't do anything about marks for articles we
6082 ;; didn't actually get any headers for.
6084 (gnus-list-range-intersection
6085 gnus-newsgroup-articles
6086 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6088 (gnus-list-range-intersection
6089 gnus-newsgroup-articles
6090 (gnus-remove-from-range
6091 (gnus-copy-sequence list) old))))
6093 (push (list add 'add (list (cdr type))) delta-marks))
6095 ;; Don't delete marks from outside the active range.
6096 ;; This shouldn't happen, but is a sanity check.
6097 (setq del (gnus-sorted-range-intersection
6098 (gnus-active gnus-newsgroup-name) del))
6099 (push (list del 'del (list (cdr type))) delta-marks))))
6102 (push (cons (cdr type) list) newmarked)))
6105 (unless (gnus-check-group gnus-newsgroup-name)
6106 (error "Can't open server for %s" gnus-newsgroup-name))
6107 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6109 ;; Enter these new marks into the info of the group.
6111 (setcar (nthcdr 3 info) newmarked)
6112 ;; Add the marks lists to the end of the info.
6114 (setcdr (nthcdr 2 info) (list newmarked))))
6116 ;; Cut off the end of the info if there's nothing else there.
6120 (when (nthcdr (decf i) info)
6121 (setcdr (nthcdr i info) nil)))))))
6123 (defun gnus-set-mode-line (where)
6124 "Set the mode line of the article or summary buffers.
6125 If WHERE is `summary', the summary mode line format will be used."
6126 ;; Is this mode line one we keep updated?
6127 (when (and (memq where gnus-updated-mode-lines)
6129 (intern (format "gnus-%s-mode-line-format-spec" where))))
6131 ;; We evaluate this in the summary buffer since these
6132 ;; variables are buffer-local to that buffer.
6133 (with-current-buffer gnus-summary-buffer
6134 ;; We bind all these variables that are used in the `eval' form
6136 (let* ((mformat (symbol-value
6138 (format "gnus-%s-mode-line-format-spec" where))))
6139 (gnus-tmp-group-name (gnus-mode-string-quote
6140 (gnus-group-decoded-name
6141 gnus-newsgroup-name)))
6142 (gnus-tmp-article-number (or gnus-current-article 0))
6143 (gnus-tmp-unread gnus-newsgroup-unreads)
6144 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6145 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6146 (gnus-tmp-unread-and-unselected
6147 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6148 (zerop gnus-tmp-unselected))
6150 ((zerop gnus-tmp-unselected)
6151 (format "{%d more}" gnus-tmp-unread-and-unticked))
6152 (t (format "{%d(+%d) more}"
6153 gnus-tmp-unread-and-unticked
6154 gnus-tmp-unselected))))
6156 (if (and gnus-current-headers
6157 (vectorp gnus-current-headers))
6158 (gnus-mode-string-quote
6159 (mail-header-subject gnus-current-headers))
6161 bufname-length max-len
6162 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6163 (setq mode-string (eval mformat))
6164 (setq bufname-length (if (string-match "%b" mode-string)
6167 (if (eq where 'summary)
6169 (get-buffer gnus-article-buffer))))
6172 (setq max-len (max 4 (if gnus-mode-non-string-length
6174 gnus-mode-non-string-length
6176 (length mode-string))))
6177 ;; We might have to chop a bit of the string off...
6178 (when (> (length mode-string) max-len)
6180 (concat (truncate-string-to-width mode-string (- max-len 3))
6182 ;; Update the mode line.
6183 (setq mode-line-buffer-identification
6184 (gnus-mode-line-buffer-identification (list mode-string)))
6185 (set-buffer-modified-p t))))
6187 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6188 "Go through the HEADERS list and add all Xrefs to a hash table.
6189 The resulting hash table is returned, or nil if no Xrefs were found."
6190 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6191 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6192 (xref-hashtb (gnus-make-hashtable))
6193 start group entry number xrefs header)
6195 (setq header (pop headers))
6196 (when (and (setq xrefs (mail-header-xref header))
6197 (not (memq (setq number (mail-header-number header))
6200 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6201 (setq start (match-end 0))
6202 (setq group (if prefix
6203 (concat prefix (substring xrefs (match-beginning 1)
6205 (substring xrefs (match-beginning 1) (match-end 1))))
6207 (string-to-number (substring xrefs (match-beginning 2)
6209 (if (setq entry (gnus-gethash group xref-hashtb))
6210 (setcdr entry (cons number (cdr entry)))
6211 (gnus-sethash group (cons number nil) xref-hashtb)))))
6212 (and start xref-hashtb)))
6214 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6215 "Look through all the headers and mark the Xrefs as read."
6216 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6217 name info xref-hashtb idlist method nth4)
6218 (with-current-buffer gnus-group-buffer
6219 (when (setq xref-hashtb
6220 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6223 (unless (string= from-newsgroup (setq name (symbol-name group)))
6224 (setq idlist (symbol-value group))
6225 ;; Dead groups are not updated.
6227 (setq info (gnus-get-info name))
6228 (when (stringp (setq nth4 (gnus-info-method info)))
6229 (setq nth4 (gnus-server-to-method nth4))))
6230 ;; Only do the xrefs if the group has the same
6231 ;; select method as the group we have just read.
6232 (or (gnus-methods-equal-p
6233 nth4 (gnus-find-method-for-group from-newsgroup))
6235 (equal nth4 (setq method (gnus-find-method-for-group
6237 (and (equal (car nth4) (car method))
6238 (equal (nth 1 nth4) (nth 1 method))))
6239 gnus-use-cross-reference
6240 (or (not (eq gnus-use-cross-reference t))
6242 ;; Only do cross-references on subscribed
6243 ;; groups, if that is what is wanted.
6244 (<= (gnus-info-level info) gnus-level-subscribed))
6245 (gnus-group-make-articles-read name idlist))))
6248 (defun gnus-compute-read-articles (group articles)
6249 (let* ((entry (gnus-group-entry group))
6250 (info (nth 2 entry))
6251 (active (gnus-active group))
6254 ;; First peel off all invalid article numbers.
6256 (let ((ids articles)
6258 (while (setq id (pop ids))
6259 (when (and first (> id (cdr active)))
6260 ;; We'll end up in this situation in one particular
6261 ;; obscure situation. If you re-scan a group and get
6262 ;; a new article that is cross-posted to a different
6263 ;; group that has not been re-scanned, you might get
6264 ;; crossposted article that has a higher number than
6265 ;; Gnus believes possible. So we re-activate this
6266 ;; group as well. This might mean doing the
6267 ;; crossposting thingy will *increase* the number
6268 ;; of articles in some groups. Tsk, tsk.
6269 (setq active (or (gnus-activate-group group) active)))
6270 (when (or (> id (cdr active))
6271 (< id (car active)))
6272 (setq articles (delq id articles))))))
6273 ;; If the read list is nil, we init it.
6275 (null (gnus-info-read info))
6277 (setq ninfo (cons 1 (1- (car active))))
6278 (setq ninfo (gnus-info-read info)))
6279 ;; Then we add the read articles to the range.
6281 ninfo (setq articles (sort articles '<))))))
6283 (defun gnus-group-make-articles-read (group articles)
6284 "Update the info of GROUP to say that ARTICLES are read."
6286 (entry (gnus-group-entry group))
6287 (info (nth 2 entry))
6288 (active (gnus-active group))
6290 (gnus-method-option-p
6291 (gnus-find-method-for-group group)
6295 ;; Group that Gnus doesn't know exists, but still allow the
6296 ;; backend to set marks.
6298 (gnus-request-set-mark
6299 group (list (list (gnus-compress-sequence (sort articles #'<))
6301 ;; Normal, subscribed groups.
6302 (setq range (gnus-compute-read-articles group articles))
6303 (with-current-buffer gnus-group-buffer
6306 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6307 (gnus-info-set-read ',info ',(gnus-info-read info))
6308 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6310 (gnus-request-set-mark
6311 ,group (list (list ',range 'del '(read)))))
6312 (gnus-group-update-group ,group t))))
6313 ;; Add the read articles to the range.
6314 (gnus-info-set-read info range)
6316 (gnus-request-set-mark group (list (list range 'add '(read)))))
6317 ;; Then we have to re-compute how many unread
6318 ;; articles there are in this group.
6322 (setq num (- (1+ (cdr active)) (car active))))
6323 ((not (listp (cdr range)))
6324 (setq num (- (cdr active) (- (1+ (cdr range))
6328 (if (numberp (car range))
6330 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6331 (setq range (cdr range)))
6332 (setq num (- (cdr active) num))))
6333 ;; Update the number of unread articles.
6335 ;; Update the group buffer.
6336 (unless (gnus-ephemeral-group-p group)
6337 (gnus-group-update-group group t))))))
6339 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6340 (let ((cur nntp-server-buffer)
6343 (with-current-buffer gnus-summary-buffer
6344 gnus-newsgroup-dependencies)))
6345 headers id end ref number
6346 (mail-parse-charset gnus-newsgroup-charset)
6347 (mail-parse-ignored-charsets
6348 (save-current-buffer (condition-case nil
6349 (set-buffer gnus-summary-buffer)
6351 gnus-newsgroup-ignored-charsets)))
6352 (with-current-buffer nntp-server-buffer
6353 ;; Translate all TAB characters into SPACE characters.
6354 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6355 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6356 (ietf-drums-unfold-fws)
6357 (gnus-run-hooks 'gnus-parse-headers-hook)
6358 (let ((case-fold-search t)
6359 in-reply-to header p lines chars)
6360 (goto-char (point-min))
6361 ;; Search to the beginning of the next header. Error messages
6362 ;; do not begin with 2 or 3.
6363 (while (re-search-forward "^[23][0-9]+ " nil t)
6366 ;; This implementation of this function, with nine
6367 ;; search-forwards instead of the one re-search-forward and
6368 ;; a case (which basically was the old function) is actually
6369 ;; about twice as fast, even though it looks messier. You
6370 ;; can't have everything, I guess. Speed and elegance
6371 ;; doesn't always go hand in hand.
6377 (setq number (read cur))
6380 (narrow-to-region (point)
6381 (or (and (search-forward "\n.\n" nil t)
6387 (if (search-forward "\nsubject:" nil t)
6388 (funcall gnus-decode-encoded-word-function
6389 (nnheader-header-value))
6394 (if (search-forward "\nfrom:" nil t)
6395 (funcall gnus-decode-encoded-address-function
6396 (nnheader-header-value))
6401 (if (search-forward "\ndate:" nil t)
6402 (nnheader-header-value) ""))
6406 (setq id (if (re-search-forward
6407 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6408 ;; We do it this way to make sure the Message-ID
6409 ;; is (somewhat) syntactically valid.
6410 (buffer-substring (match-beginning 1)
6412 ;; If there was no message-id, we just fake one
6413 ;; to make subsequent routines simpler.
6414 (nnheader-generate-fake-message-id number))))
6418 (if (search-forward "\nreferences:" nil t)
6422 (nnheader-header-value)
6427 (search-backward ">" end t)
6430 (search-backward "<" end t)
6432 ;; Get the references from the in-reply-to header if there
6433 ;; were no references and the in-reply-to header looks
6435 (if (and (search-forward "\nin-reply-to:" nil t)
6436 (setq in-reply-to (nnheader-header-value))
6437 (string-match "<[^>]+>" in-reply-to))
6439 (setq ref (substring in-reply-to (match-beginning 0)
6441 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6442 (setq ref2 (substring in-reply-to (match-beginning 0)
6444 (when (> (length ref2) (length ref))
6451 (if (search-forward "\nchars: " nil t)
6452 (if (numberp (setq chars (ignore-errors (read cur))))
6458 (if (search-forward "\nlines: " nil t)
6459 (if (numberp (setq lines (ignore-errors (read cur))))
6465 (and (search-forward "\nxref:" nil t)
6466 (nnheader-header-value)))
6468 (when gnus-extra-headers
6469 (let ((extra gnus-extra-headers)
6473 (when (search-forward
6474 (concat "\n" (symbol-name (car extra)) ":") nil t)
6475 (push (cons (car extra) (nnheader-header-value))
6479 (when (equal id ref)
6482 (when gnus-alter-header-function
6483 (funcall gnus-alter-header-function header)
6484 (setq id (mail-header-id header)
6485 ref (gnus-parent-id (mail-header-references header))))
6488 (gnus-dependencies-add-header
6489 header dependencies force-new))
6490 (push header headers))
6491 (goto-char (point-max))
6493 (nreverse headers)))))
6495 ;; Goes through the xover lines and returns a list of vectors
6496 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6497 force-new dependencies
6498 group also-fetch-heads)
6499 "Parse the news overview data in the server buffer.
6500 Return a list of headers that match SEQUENCE (see
6501 `nntp-retrieve-headers')."
6502 ;; Get the Xref when the users reads the articles since most/some
6503 ;; NNTP servers do not include Xrefs when using XOVER.
6504 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6505 (let ((mail-parse-charset gnus-newsgroup-charset)
6506 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6507 (cur nntp-server-buffer)
6508 (dependencies (or dependencies gnus-newsgroup-dependencies))
6510 ((eq gnus-read-all-available-headers t)
6512 ((and (stringp gnus-read-all-available-headers)
6514 (string-match gnus-read-all-available-headers group))
6517 number headers header)
6518 (with-current-buffer nntp-server-buffer
6519 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6520 ;; Allow the user to mangle the headers before parsing them.
6521 (gnus-run-hooks 'gnus-parse-headers-hook)
6522 (goto-char (point-min))
6523 (gnus-parse-without-error
6524 (while (and (or sequence allp)
6526 (setq number (read cur))
6528 (while (and sequence
6529 (< (car sequence) number))
6530 (setq sequence (cdr sequence))))
6533 (eq number (car sequence))))
6535 (setq sequence (cdr sequence))
6536 (setq header (inline
6537 (gnus-nov-parse-line
6538 number dependencies force-new)))))
6539 (push header headers))
6541 ;; A common bug in inn is that if you have posted an article and
6542 ;; then retrieves the active file, it will answer correctly --
6543 ;; the new article is included. However, a NOV entry for the
6544 ;; article may not have been generated yet, so this may fail.
6545 ;; We work around this problem by retrieving the last few
6546 ;; headers using HEAD.
6547 (if (or (not also-fetch-heads)
6549 ;; We (probably) got all the headers.
6551 (let ((gnus-nov-is-evil t))
6554 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6555 (gnus-get-newsgroup-headers))))))))
6557 (defun gnus-article-get-xrefs ()
6558 "Fill in the Xref value in `gnus-current-headers', if necessary.
6559 This is meant to be called in `gnus-article-internal-prepare-hook'."
6560 (let ((headers (with-current-buffer gnus-summary-buffer
6561 gnus-current-headers)))
6562 (or (not gnus-use-cross-reference)
6564 (and (mail-header-xref headers)
6565 (not (string= (mail-header-xref headers) "")))
6566 (let ((case-fold-search t)
6569 (nnheader-narrow-to-headers)
6570 (goto-char (point-min))
6571 (when (or (and (not (eobp))
6572 (eq (downcase (char-after)) ?x)
6573 (looking-at "Xref:"))
6574 (search-forward "\nXref:" nil t))
6575 (goto-char (1+ (match-end 0)))
6576 (setq xref (buffer-substring (point) (point-at-eol)))
6577 (mail-header-set-xref headers xref)))))))
6579 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6580 "Find article ID and insert the summary line for that article.
6581 OLD-HEADER can either be a header or a line number to insert
6582 the subject line on.
6583 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6584 and OLD-HEADER will be used when the summary line is inserted,
6585 too, instead of trying to fetch new headers."
6586 (let* ((line (and (numberp old-header) old-header))
6587 (old-header (and (vectorp old-header) old-header))
6588 (header (cond ((and old-header use-old-header)
6591 (gnus-number-to-header id))
6592 (gnus-number-to-header id))
6594 (gnus-read-header id))))
6595 (number (and (numberp id) id))
6598 ;; Rebuild the thread that this article is part of and go to the
6599 ;; article we have fetched.
6600 (when (and (not gnus-show-threads)
6603 (setq d (gnus-data-find (mail-header-number old-header))))
6604 (goto-char (gnus-data-pos d))
6610 (gnus-delete-line))))))
6611 ;; Remove list identifiers from subject.
6612 (let ((gnus-newsgroup-headers (list header)))
6613 (gnus-summary-remove-list-identifiers))
6615 (mail-header-set-number header (mail-header-number old-header)))
6616 (setq gnus-newsgroup-sparse
6617 (delq (setq number (mail-header-number header))
6618 gnus-newsgroup-sparse))
6619 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6620 (push number gnus-newsgroup-limit)
6621 (gnus-rebuild-thread (mail-header-id header) line)
6622 (gnus-summary-goto-subject number nil t))
6623 (when (and (numberp number)
6625 ;; We have to update the boundaries even if we can't fetch the
6626 ;; article if ID is a number -- so that the next `P' or `N'
6627 ;; command will fetch the previous (or next) article even
6628 ;; if the one we tried to fetch this time has been canceled.
6629 (when (> number gnus-newsgroup-end)
6630 (setq gnus-newsgroup-end number))
6631 (when (< number gnus-newsgroup-begin)
6632 (setq gnus-newsgroup-begin number))
6633 (setq gnus-newsgroup-unselected
6634 (delq number gnus-newsgroup-unselected)))
6635 ;; Report back a success?
6636 (and header (mail-header-number header))))
6638 ;;; Process/prefix in the summary buffer
6640 (defun gnus-summary-work-articles (n)
6641 "Return a list of articles to be worked upon.
6642 The prefix argument, the list of process marked articles, and the
6643 current article will be taken into consideration."
6644 (with-current-buffer gnus-summary-buffer
6647 ;; A numerical prefix has been given.
6648 (setq n (prefix-numeric-value n))
6649 (let ((backward (< n 0))
6650 (n (abs (prefix-numeric-value n)))
6655 (push (setq article (gnus-summary-article-number))
6658 (gnus-summary-find-prev nil article)
6659 (gnus-summary-find-next nil article)))
6661 (nreverse articles)))
6662 ((and (gnus-region-active-p) (mark))
6663 (message "region active")
6664 ;; Work on the region between point and mark.
6665 (let ((max (max (point) (mark)))
6668 (goto-char (min (point) (mark)))
6671 (push (setq article (gnus-summary-article-number)) articles)
6672 (gnus-summary-find-next nil article)
6674 (nreverse articles))))
6675 (gnus-newsgroup-processable
6676 ;; There are process-marked articles present.
6677 ;; Save current state.
6678 (gnus-summary-save-process-mark)
6680 (reverse gnus-newsgroup-processable))
6682 ;; Just return the current article.
6683 (list (gnus-summary-article-number))))))
6685 (defmacro gnus-summary-iterate (arg &rest forms)
6686 "Iterate over the process/prefixed articles and do FORMS.
6687 ARG is the interactive prefix given to the command. FORMS will be
6688 executed with point over the summary line of the articles."
6689 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6690 `(let ((,articles (gnus-summary-work-articles ,arg)))
6692 (gnus-summary-goto-subject (car ,articles))
6696 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6697 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6699 (defun gnus-summary-save-process-mark ()
6700 "Push the current set of process marked articles on the stack."
6702 (push (copy-sequence gnus-newsgroup-processable)
6703 gnus-newsgroup-process-stack))
6705 (defun gnus-summary-kill-process-mark ()
6706 "Push the current set of process marked articles on the stack and unmark."
6708 (gnus-summary-save-process-mark)
6709 (gnus-summary-unmark-all-processable))
6711 (defun gnus-summary-yank-process-mark ()
6712 "Pop the last process mark state off the stack and restore it."
6714 (unless gnus-newsgroup-process-stack
6715 (error "Empty mark stack"))
6716 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6718 (defun gnus-summary-process-mark-set (set)
6719 "Make SET into the current process marked articles."
6720 (gnus-summary-unmark-all-processable)
6721 (mapc 'gnus-summary-set-process-mark set))
6723 ;;; Searching and stuff
6725 (defun gnus-summary-search-group (&optional backward use-level)
6726 "Search for next unread newsgroup.
6727 If optional argument BACKWARD is non-nil, search backward instead."
6728 (with-current-buffer gnus-group-buffer
6729 (when (gnus-group-search-forward
6730 backward nil (if use-level (gnus-group-group-level) nil))
6731 (gnus-group-group-name))))
6733 (defun gnus-summary-best-group (&optional exclude-group)
6734 "Find the name of the best unread group.
6735 If EXCLUDE-GROUP, do not go to this group."
6736 (with-current-buffer gnus-group-buffer
6738 (gnus-group-best-unread-group exclude-group))))
6740 (defun gnus-summary-find-next (&optional unread article backward)
6742 (gnus-summary-find-prev unread article)
6743 (let* ((dummy (gnus-summary-article-intangible-p))
6744 (article (or article (gnus-summary-article-number)))
6745 (data (gnus-data-find-list article))
6747 (when (and (not dummy)
6748 (or (not gnus-summary-check-current)
6750 (not (gnus-data-unread-p (car data)))))
6751 (setq data (cdr data)))
6756 (unless (memq (gnus-data-number (car data))
6758 ((eq gnus-auto-goto-ignores
6759 'always-undownloaded)
6760 gnus-newsgroup-undownloaded)
6763 ((eq gnus-auto-goto-ignores
6765 gnus-newsgroup-unfetched)
6766 ((eq gnus-auto-goto-ignores
6768 gnus-newsgroup-undownloaded)))
6769 (when (gnus-data-unread-p (car data))
6770 (setq result (car data)
6772 (setq data (cdr data)))
6775 (goto-char (gnus-data-pos result))
6776 (gnus-data-number result)))))
6778 (defun gnus-summary-find-prev (&optional unread article)
6779 (let* ((eobp (eobp))
6780 (article (or article (gnus-summary-article-number)))
6781 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6783 (when (and (not eobp)
6784 (or (not gnus-summary-check-current)
6786 (not (gnus-data-unread-p (car data)))))
6787 (setq data (cdr data)))
6792 (unless (memq (gnus-data-number (car data))
6794 ((eq gnus-auto-goto-ignores
6795 'always-undownloaded)
6796 gnus-newsgroup-undownloaded)
6799 ((eq gnus-auto-goto-ignores
6801 gnus-newsgroup-unfetched)
6802 ((eq gnus-auto-goto-ignores
6804 gnus-newsgroup-undownloaded)))
6805 (when (gnus-data-unread-p (car data))
6806 (setq result (car data)
6808 (setq data (cdr data)))
6811 (goto-char (gnus-data-pos result))
6812 (gnus-data-number result))))
6814 (defun gnus-summary-find-subject (subject &optional unread backward article)
6815 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6816 (article (or article (gnus-summary-article-number)))
6817 (articles (gnus-data-list backward))
6818 (arts (gnus-data-find-list article articles))
6820 (when (or (not gnus-summary-check-current)
6822 (not (gnus-data-unread-p (car arts))))
6823 (setq arts (cdr arts)))
6825 (and (or (not unread)
6826 (gnus-data-unread-p (car arts)))
6827 (vectorp (gnus-data-header (car arts)))
6829 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6830 (setq result (car arts)
6832 (setq arts (cdr arts)))
6834 (goto-char (gnus-data-pos result))
6835 (gnus-data-number result))))
6837 (defun gnus-summary-search-forward (&optional unread subject backward)
6838 "Search forward for an article.
6839 If UNREAD, look for unread articles. If SUBJECT, look for
6840 articles with that subject. If BACKWARD, search backward instead."
6841 (cond (subject (gnus-summary-find-subject subject unread backward))
6842 (backward (gnus-summary-find-prev unread))
6843 (t (gnus-summary-find-next unread))))
6845 (defun gnus-recenter (&optional n)
6846 "Center point in window and redisplay frame.
6847 Also do horizontal recentering."
6849 (when (and gnus-auto-center-summary
6850 (not (eq gnus-auto-center-summary 'vertical)))
6851 (gnus-horizontal-recenter))
6852 (if (fboundp 'recenter-top-bottom)
6853 (recenter-top-bottom n)
6856 (put 'gnus-recenter 'isearch-scroll t)
6858 (defun gnus-forward-line-ignore-invisible (n)
6859 "Move N lines forward (backward if N is negative).
6860 Like forward-line, but skip over (and don't count) invisible lines."
6862 (while (and (> n 0) (not done))
6863 ;; If the following character is currently invisible,
6864 ;; skip all characters with that same `invisible' property value.
6865 (while (gnus-invisible-p (point))
6866 (goto-char (gnus-next-char-property-change (point))))
6871 (while (and (< n 0) (not done))
6873 (if (bobp) (setq done t)
6875 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6876 (goto-char (gnus-previous-char-property-change (point))))))))
6878 (defun gnus-summary-recenter ()
6879 "Center point in the summary window.
6880 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6881 displayed, no centering will be performed."
6882 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6883 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6885 ;; The user has to want it.
6886 (when gnus-auto-center-summary
6887 (let* ((top (cond ((< (window-height) 4) 0)
6888 ((< (window-height) 7) 1)
6889 (t (if (numberp gnus-auto-center-summary)
6890 gnus-auto-center-summary
6891 (/ (1- (window-height)) 2)))))
6892 (height (1- (window-height)))
6893 (bottom (save-excursion
6894 (goto-char (point-max))
6895 (gnus-forward-line-ignore-invisible (- height))
6897 (window (get-buffer-window (current-buffer))))
6898 (when (get-buffer-window gnus-article-buffer)
6899 ;; Only do recentering when the article buffer is displayed,
6900 ;; Set the window start to either `bottom', which is the biggest
6901 ;; possible valid number, or the second line from the top,
6902 ;; whichever is the least.
6903 (let ((top-pos (save-excursion
6904 (gnus-forward-line-ignore-invisible (- top))
6906 (if (> bottom top-pos)
6907 ;; Keep the second line from the top visible
6908 (set-window-start window top-pos)
6909 ;; Try to keep the bottom line visible; if it's partially
6910 ;; obscured, either scroll one more line to make it fully
6911 ;; visible, or revert to using TOP-POS.
6913 (goto-char (point-max))
6914 (gnus-forward-line-ignore-invisible -1)
6915 (let ((last-line-start (point)))
6917 (set-window-start window (point) t)
6918 (when (not (pos-visible-in-window-p last-line-start window))
6919 (gnus-forward-line-ignore-invisible 1)
6920 (set-window-start window (min (point) top-pos) t)))))))
6921 ;; Do horizontal recentering while we're at it.
6922 (when (and (get-buffer-window (current-buffer) t)
6923 (not (eq gnus-auto-center-summary 'vertical)))
6924 (let ((selected (selected-window)))
6925 (select-window (get-buffer-window (current-buffer) t))
6926 (gnus-summary-position-point)
6927 (gnus-horizontal-recenter)
6928 (select-window selected))))))
6930 (defun gnus-summary-jump-to-group (newsgroup)
6931 "Move point to NEWSGROUP in group mode buffer."
6932 ;; Keep update point of group mode buffer if visible.
6933 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6934 (save-window-excursion
6935 ;; Take care of tree window mode.
6936 (when (get-buffer-window gnus-group-buffer)
6937 (pop-to-buffer gnus-group-buffer))
6938 (gnus-group-jump-to-group newsgroup))
6940 ;; Take care of tree window mode.
6941 (if (get-buffer-window gnus-group-buffer 0)
6942 (pop-to-buffer gnus-group-buffer)
6943 (set-buffer gnus-group-buffer))
6944 (gnus-group-jump-to-group newsgroup))))
6946 ;; This function returns a list of article numbers based on the
6947 ;; difference between the ranges of read articles in this group and
6948 ;; the range of active articles.
6949 (defun gnus-list-of-unread-articles (group)
6950 (let* ((read (gnus-info-read (gnus-get-info group)))
6951 (active (or (gnus-active group) (gnus-activate-group group)))
6952 (last (or (cdr active)
6953 (error "Group %s couldn't be activated " group)))
6954 (bottom (if gnus-newsgroup-maximum-articles
6956 (- last gnus-newsgroup-maximum-articles -1))
6959 ;; If none are read, then all are unread.
6962 ;; If the range of read articles is a single range, then the
6963 ;; first unread article is the article after the last read
6964 ;; article. Sounds logical, doesn't it?
6965 (if (and (not (listp (cdr read)))
6966 (or (< (car read) bottom)
6967 (progn (setq read (list read))
6969 (setq first (max bottom (1+ (cdr read))))
6970 ;; `read' is a list of ranges.
6971 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6974 (setq first bottom))
6977 (while (< first nlast)
6978 (setq unread (cons first unread)
6980 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6981 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6982 (setq read (cdr read)))))
6983 ;; And add the last unread articles.
6984 (while (<= first last)
6985 (setq unread (cons first unread)
6987 ;; Return the list of unread articles.
6988 (delq 0 (nreverse unread))))
6990 (defun gnus-list-of-read-articles (group)
6991 "Return a list of unread, unticked and non-dormant articles."
6992 (let* ((info (gnus-get-info group))
6993 (marked (gnus-info-marks info))
6994 (active (gnus-active group)))
6996 (gnus-list-range-difference
6997 (gnus-list-range-difference
6998 (gnus-sorted-complement
6999 (gnus-uncompress-range
7000 (if gnus-newsgroup-maximum-articles
7001 (cons (max (car active)
7003 gnus-newsgroup-maximum-articles
7007 (gnus-list-of-unread-articles group))
7008 (cdr (assq 'dormant marked)))
7009 (cdr (assq 'tick marked))))))
7011 ;; This function returns a sequence of article numbers based on the
7012 ;; difference between the ranges of read articles in this group and
7013 ;; the range of active articles.
7014 (defun gnus-sequence-of-unread-articles (group)
7015 (let* ((read (gnus-info-read (gnus-get-info group)))
7016 (active (or (gnus-active group) (gnus-activate-group group)))
7018 (bottom (if gnus-newsgroup-maximum-articles
7020 (- last gnus-newsgroup-maximum-articles -1))
7023 ;; If none are read, then all are unread.
7026 ;; If the range of read articles is a single range, then the
7027 ;; first unread article is the article after the last read
7028 ;; article. Sounds logical, doesn't it?
7029 (if (and (not (listp (cdr read)))
7030 (or (< (car read) bottom)
7031 (progn (setq read (list read))
7033 (setq first (max bottom (1+ (cdr read))))
7034 ;; `read' is a list of ranges.
7035 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7038 (setq first bottom))
7041 (push (cons first nlast) unread))
7042 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7043 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7044 (setq read (cdr read)))))
7045 ;; And add the last unread articles.
7046 (cond ((not (and first last))
7049 (push (cons first last) unread))
7051 (push first unread)))
7052 ;; Return the sequence of unread articles.
7053 (delq 0 (nreverse unread))))
7055 ;; Various summary commands
7057 (defun gnus-summary-select-article-buffer ()
7058 "Reconfigure windows to show the article buffer.
7059 If `gnus-widen-article-window' is set, show only the article
7062 (if (not (gnus-buffer-live-p gnus-article-buffer))
7063 (error "There is no article buffer for this summary buffer")
7064 (unless (get-buffer-window gnus-article-buffer)
7065 (gnus-summary-show-article))
7066 (gnus-configure-windows
7067 (if gnus-widen-article-window
7071 (select-window (get-buffer-window gnus-article-buffer))))
7073 (defun gnus-summary-universal-argument (arg)
7074 "Perform any operation on all articles that are process/prefixed."
7076 (let ((articles (gnus-summary-work-articles arg))
7083 (substitute-command-keys
7084 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7086 (gnus-error 1 "Undefined key")
7089 (gnus-summary-goto-subject (setq article (pop articles)))
7090 (let (gnus-newsgroup-processable)
7091 (command-execute func))
7092 (gnus-summary-remove-process-mark article)))))
7093 (gnus-summary-position-point))
7095 (defun gnus-summary-toggle-truncation (&optional arg)
7096 "Toggle truncation of summary lines.
7097 With ARG, turn line truncation on if ARG is positive."
7099 (setq truncate-lines
7100 (if (null arg) (not truncate-lines)
7101 (> (prefix-numeric-value arg) 0)))
7104 (defun gnus-summary-find-for-reselect ()
7105 "Return the number of an article to stay on across a reselect.
7106 The current article is considered, then following articles, then previous
7107 articles. An article is sought which is not canceled and isn't a temporary
7108 insertion from another group. If there's no such then return a dummy 0."
7110 (dolist (rev '(nil t))
7111 (unless found ; don't demand the reverse list if we don't need it
7112 (let ((data (gnus-data-find-list
7113 (gnus-summary-article-number) (gnus-data-list rev))))
7114 (while (and data (not found))
7115 (if (and (< 0 (gnus-data-number (car data)))
7116 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7117 (setq found (gnus-data-number (car data))))
7118 (setq data (cdr data))))))
7121 (defun gnus-summary-reselect-current-group (&optional all rescan)
7122 "Exit and then reselect the current newsgroup.
7123 The prefix argument ALL means to select all articles."
7125 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7126 (error "Ephemeral groups can't be reselected"))
7127 (let ((current-subject (gnus-summary-find-for-reselect))
7128 (group gnus-newsgroup-name))
7129 (setq gnus-newsgroup-begin nil)
7130 (gnus-summary-exit nil 'leave-hidden)
7131 ;; We have to adjust the point of group mode buffer because
7132 ;; point was moved to the next unread newsgroup by exiting.
7133 (gnus-summary-jump-to-group group)
7136 (gnus-group-get-new-news-this-group 1)))
7137 (gnus-group-read-group all t)
7138 (gnus-summary-goto-subject current-subject nil t)))
7140 (defun gnus-summary-rescan-group (&optional all)
7141 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7143 (let ((config gnus-current-window-configuration))
7144 (gnus-summary-reselect-current-group all t)
7145 (gnus-configure-windows config)
7146 (when (eq config 'article)
7147 (gnus-summary-select-article))))
7149 (defun gnus-summary-update-info (&optional non-destructive)
7151 (let ((group gnus-newsgroup-name))
7153 (when gnus-newsgroup-kill-headers
7154 (setq gnus-newsgroup-killed
7155 (gnus-compress-sequence
7157 (gnus-list-range-intersection
7158 gnus-newsgroup-unselected gnus-newsgroup-killed)
7159 gnus-newsgroup-unreads)
7161 (unless (listp (cdr gnus-newsgroup-killed))
7162 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7163 (let ((headers gnus-newsgroup-headers)
7164 (ephemeral-p (gnus-ephemeral-group-p group))
7167 (setq info (copy-sequence (gnus-get-info group))
7168 info (delq (gnus-info-params info) info)))
7169 ;; Set the new ranges of read articles.
7170 (with-current-buffer gnus-group-buffer
7171 (gnus-undo-force-boundary))
7172 (gnus-update-read-articles
7173 group (gnus-sorted-union
7174 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7175 ;; Set the current article marks.
7176 (let ((gnus-newsgroup-scored
7177 (if (and (not gnus-save-score)
7178 (not non-destructive))
7180 gnus-newsgroup-scored)))
7182 (gnus-update-marks)))
7183 ;; Do the cross-ref thing.
7184 (when gnus-use-cross-reference
7185 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7186 ;; Do not switch windows but change the buffer to work.
7187 (set-buffer gnus-group-buffer)
7189 (gnus-group-update-group
7192 (setq info (copy-sequence (gnus-get-info group))
7193 info (delq (gnus-info-params info) info))))))))))
7195 (defun gnus-summary-save-newsrc (&optional force)
7196 "Save the current number of read/marked articles in the dribble buffer.
7197 The dribble buffer will then be saved.
7198 If FORCE (the prefix), also save the .newsrc file(s)."
7200 (gnus-summary-update-info t)
7202 (gnus-save-newsrc-file)
7203 (gnus-dribble-save)))
7205 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7207 (defun gnus-summary-exit (&optional temporary leave-hidden)
7208 "Exit reading current newsgroup, and then return to group selection mode.
7209 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7211 (gnus-set-global-variables)
7212 (when (gnus-buffer-live-p gnus-article-buffer)
7213 (with-current-buffer gnus-article-buffer
7214 (mm-destroy-parts gnus-article-mime-handles)
7215 ;; Set it to nil for safety reason.
7216 (setq gnus-article-mime-handle-alist nil)
7217 (setq gnus-article-mime-handles nil)))
7218 (gnus-kill-save-kill-buffer)
7219 (gnus-async-halt-prefetch)
7220 (let* ((group gnus-newsgroup-name)
7221 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7222 (gnus-group-is-exiting-p t)
7223 (article-buffer gnus-article-buffer)
7224 (original-article-buffer gnus-original-article-buffer)
7227 (buf (current-buffer))
7228 ;; `gnus-single-article-buffer' is nil buffer-locally in
7229 ;; ephemeral group of which summary buffer will be killed,
7230 ;; but the global value may be non-nil.
7231 (single-article-buffer gnus-single-article-buffer))
7233 ;; Do adaptive scoring, and possibly save score files.
7234 (when gnus-newsgroup-adaptive
7235 (gnus-score-adaptive))
7236 (when gnus-use-scoring
7238 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7239 (when gnus-use-cache
7240 (gnus-cache-possibly-remove-articles)
7241 (gnus-cache-save-buffers))
7242 (gnus-async-prefetch-remove-group group)
7243 (when gnus-suppress-duplicates
7244 (gnus-dup-enter-articles))
7245 (when gnus-use-trees
7246 (gnus-tree-close group))
7247 (when gnus-use-cache
7248 (gnus-cache-write-active))
7249 ;; Remove entries for this group.
7250 (nnmail-purge-split-history (gnus-group-real-name group))
7251 ;; Make all changes in this group permanent.
7253 (gnus-run-hooks 'gnus-exit-group-hook)
7254 (gnus-summary-update-info))
7255 (gnus-close-group group)
7256 ;; Make sure where we were, and go to next newsgroup.
7257 (set-buffer gnus-group-buffer)
7259 (gnus-group-jump-to-group group))
7260 (gnus-run-hooks 'gnus-summary-exit-hook)
7261 (unless (or quit-config
7262 (not gnus-summary-next-group-on-exit)
7263 ;; If this group has disappeared from the summary
7264 ;; buffer, don't skip forwards.
7265 (not (string= group (gnus-group-group-name))))
7266 (gnus-group-next-unread-group 1))
7267 (setq group-point (point))
7271 (if (not gnus-kill-summary-on-exit)
7273 (gnus-deaden-summary)
7275 (when (get-buffer gnus-article-buffer)
7276 (bury-buffer gnus-article-buffer))
7277 ;; Return to group mode buffer.
7278 (when (eq mode 'gnus-summary-mode)
7279 (gnus-kill-buffer buf)))
7281 (setq gnus-current-select-method gnus-select-method)
7282 (set-buffer gnus-group-buffer)
7284 (gnus-handle-ephemeral-exit quit-config)
7285 (goto-char group-point)
7286 ;; If gnus-group-buffer is already displayed, make sure we also move
7287 ;; the cursor in the window that displays it.
7288 (let ((win (get-buffer-window (current-buffer) 0)))
7289 (if win (set-window-point win (point))))
7290 (unless leave-hidden
7291 (gnus-configure-windows 'group 'force)))
7293 ;; If we have several article buffers, we kill them at exit.
7294 (unless single-article-buffer
7295 (when (gnus-buffer-live-p article-buffer)
7296 (with-current-buffer article-buffer
7297 ;; Don't kill sticky article buffers
7298 (unless (eq major-mode 'gnus-sticky-article-mode)
7299 (gnus-kill-buffer article-buffer)
7300 (setq gnus-article-current nil))))
7301 (gnus-kill-buffer original-article-buffer))
7303 ;; Clear the current group name.
7305 (setq gnus-newsgroup-name nil)))))
7307 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7308 (defun gnus-summary-exit-no-update (&optional no-questions)
7309 "Quit reading current newsgroup without updating read article info."
7311 (let* ((group gnus-newsgroup-name)
7312 (gnus-group-is-exiting-p t)
7313 (gnus-group-is-exiting-without-update-p t)
7314 (quit-config (gnus-group-quit-config group)))
7315 (when (or no-questions
7317 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7318 (gnus-async-halt-prefetch)
7319 (run-hooks 'gnus-summary-prepare-exit-hook)
7320 (when (gnus-buffer-live-p gnus-article-buffer)
7321 (with-current-buffer gnus-article-buffer
7322 (gnus-article-stop-animations)
7323 (gnus-stop-downloads)
7324 (mm-destroy-parts gnus-article-mime-handles)
7325 ;; Set it to nil for safety reason.
7326 (setq gnus-article-mime-handle-alist nil)
7327 (setq gnus-article-mime-handles nil)))
7328 ;; If we have several article buffers, we kill them at exit.
7329 (unless gnus-single-article-buffer
7330 (gnus-kill-buffer gnus-article-buffer)
7331 (gnus-kill-buffer gnus-original-article-buffer)
7332 (setq gnus-article-current nil))
7333 ;; Return to the group buffer.
7334 (if (not gnus-kill-summary-on-exit)
7336 (gnus-deaden-summary)
7337 (gnus-configure-windows 'group 'force))
7338 (gnus-configure-windows 'group 'force)
7339 (gnus-close-group group)
7340 (gnus-kill-buffer gnus-summary-buffer))
7341 (unless gnus-single-article-buffer
7342 (setq gnus-article-current nil))
7343 (when gnus-use-trees
7344 (gnus-tree-close group))
7345 (gnus-async-prefetch-remove-group group)
7346 (when (get-buffer gnus-article-buffer)
7347 (bury-buffer gnus-article-buffer))
7348 ;; Clear the current group name.
7349 (setq gnus-newsgroup-name nil)
7350 (unless (gnus-ephemeral-group-p group)
7351 (gnus-group-update-group group nil t))
7352 (when (equal (gnus-group-group-name) group)
7353 (gnus-group-next-unread-group 1))
7355 (gnus-handle-ephemeral-exit quit-config)))))
7357 (defun gnus-handle-ephemeral-exit (quit-config)
7358 "Handle movement when leaving an ephemeral group.
7359 The state which existed when entering the ephemeral is reset."
7360 (if (not (buffer-live-p (car quit-config)))
7361 (gnus-configure-windows 'group 'force)
7362 (set-buffer (car quit-config))
7363 (unless (eq (cdr quit-config) 'group)
7364 (setq gnus-current-select-method
7365 (gnus-find-method-for-group gnus-newsgroup-name)))
7366 (cond ((eq major-mode 'gnus-summary-mode)
7367 (gnus-set-global-variables))
7368 ((eq major-mode 'gnus-article-mode)
7369 (save-current-buffer
7370 ;; The `gnus-summary-buffer' variable may point
7371 ;; to the old summary buffer when using a single
7373 (unless (gnus-buffer-live-p gnus-summary-buffer)
7374 (set-buffer gnus-group-buffer))
7375 (set-buffer gnus-summary-buffer)
7376 (gnus-set-global-variables))))
7377 (if (or (eq (cdr quit-config) 'article)
7378 (eq (cdr quit-config) 'pick))
7379 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7380 (gnus-configure-windows 'pick 'force)
7381 (gnus-configure-windows (cdr quit-config) 'force))
7382 (gnus-configure-windows (cdr quit-config) 'force))
7383 (when (eq major-mode 'gnus-summary-mode)
7384 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7385 next-unread-noselect))
7386 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7388 (gnus-summary-next-subject 1 nil t))
7389 ((eq gnus-auto-select-on-ephemeral-exit
7390 'next-unread-noselect)
7391 (gnus-summary-next-subject 1 t t))))
7392 ;; Hide the article buffer which displays the article different
7393 ;; from the one that the cursor points to in the summary buffer.
7394 (gnus-configure-windows 'summary 'force))
7395 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7396 (gnus-summary-next-subject 1))
7397 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7398 (gnus-summary-next-subject 1 t))))
7399 (gnus-summary-recenter)
7400 (gnus-summary-position-point))))
7404 (defvar gnus-dead-summary-mode-map
7405 (let ((map (make-keymap)))
7406 (suppress-keymap map)
7407 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7408 (dolist (key '("\C-d" "\r" "\177" [delete]))
7409 (define-key map key 'gnus-summary-wake-up-the-dead))
7410 (dolist (key '("q" "Q"))
7411 (define-key map key 'bury-buffer))
7414 (define-minor-mode gnus-dead-summary-mode
7415 "Minor mode for Gnus summary buffers."
7416 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7417 (unless (derived-mode-p 'gnus-summary-mode)
7418 (setq gnus-dead-summary-mode nil)))
7420 (defun gnus-deaden-summary ()
7421 "Make the current summary buffer into a dead summary buffer."
7422 ;; Kill any previous dead summary buffer.
7423 (when (and gnus-dead-summary
7424 (buffer-name gnus-dead-summary))
7425 (with-current-buffer gnus-dead-summary
7426 (when gnus-dead-summary-mode
7427 (kill-buffer (current-buffer)))))
7428 ;; Make this the current dead summary.
7429 (setq gnus-dead-summary (current-buffer))
7430 (gnus-dead-summary-mode 1)
7431 (let ((name (buffer-name)))
7432 (when (string-match "Summary" name)
7434 (concat (substring name 0 (match-beginning 0)) "Dead "
7435 (substring name (match-beginning 0)))
7439 (defun gnus-kill-or-deaden-summary (buffer)
7440 "Kill or deaden the summary BUFFER."
7442 (when (and (buffer-name buffer)
7443 (not gnus-single-article-buffer))
7444 (with-current-buffer buffer
7445 (gnus-kill-buffer gnus-article-buffer)
7446 (gnus-kill-buffer gnus-original-article-buffer)))
7449 (gnus-kill-summary-on-exit
7450 (when (and gnus-use-trees
7451 (gnus-buffer-exists-p buffer))
7452 (with-current-buffer buffer
7453 (gnus-tree-close gnus-newsgroup-name)))
7454 (gnus-kill-buffer buffer))
7455 ;; Deaden the buffer.
7456 ((gnus-buffer-exists-p buffer)
7457 (with-current-buffer buffer
7458 (gnus-deaden-summary))))))
7460 (defun gnus-summary-wake-up-the-dead (&rest args)
7461 "Wake up the dead summary buffer."
7463 (gnus-dead-summary-mode -1)
7464 (let ((name (buffer-name)))
7465 (when (string-match "Dead " name)
7467 (concat (substring name 0 (match-beginning 0))
7468 (substring name (match-end 0)))
7470 (gnus-message 3 "This dead summary is now alive again"))
7472 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7473 (defun gnus-summary-describe-group (&optional force)
7474 "Describe the current newsgroup."
7476 (gnus-group-describe-group force gnus-newsgroup-name))
7478 (defun gnus-summary-describe-briefly ()
7479 "Describe summary mode commands briefly."
7481 (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")))
7483 ;; Walking around group mode buffer from summary mode.
7485 (defun gnus-summary-next-group (&optional no-article target-group backward)
7486 "Exit current newsgroup and then select next unread newsgroup.
7487 If prefix argument NO-ARTICLE is non-nil, no article is selected
7488 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7489 previous group instead."
7491 ;; Stop pre-fetching.
7492 (gnus-async-halt-prefetch)
7493 (let ((current-group gnus-newsgroup-name)
7494 (current-buffer (current-buffer))
7496 ;; First we semi-exit this group to update Xrefs and all variables.
7497 ;; We can't do a real exit, because the window conf must remain
7498 ;; the same in case the user is prompted for info, and we don't
7499 ;; want the window conf to change before that...
7500 (gnus-summary-exit t)
7501 (while (not entered)
7502 ;; Then we find what group we are supposed to enter.
7503 (set-buffer gnus-group-buffer)
7504 (gnus-group-jump-to-group current-group)
7507 (if (eq gnus-keep-same-level 'best)
7508 (gnus-summary-best-group gnus-newsgroup-name)
7509 (gnus-summary-search-group backward gnus-keep-same-level))))
7510 (if (not target-group)
7511 ;; There are no further groups, so we return to the group
7514 (gnus-message 5 "Returning to the group buffer")
7516 (when (gnus-buffer-live-p current-buffer)
7517 (set-buffer current-buffer)
7518 (gnus-summary-exit))
7519 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7520 ;; We try to enter the target group.
7521 (gnus-group-jump-to-group target-group)
7522 (let ((unreads (gnus-group-group-unread)))
7523 (if (and (or (eq t unreads)
7524 (and unreads (not (zerop unreads))))
7525 (gnus-summary-read-group
7526 target-group nil no-article
7527 (and (buffer-name current-buffer) current-buffer)
7530 (setq current-group target-group
7531 target-group nil)))))))
7533 (defun gnus-summary-prev-group (&optional no-article)
7534 "Exit current newsgroup and then select previous unread newsgroup.
7535 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7537 (gnus-summary-next-group no-article nil t))
7539 ;; Walking around summary lines.
7541 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7542 "Go to the first subject satisfying any non-nil constraint.
7543 If UNREAD is non-nil, the article should be unread.
7544 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7545 If UNSEEN is non-nil, the article should be unseen as well as unread.
7546 Returns the article selected or nil if there are no matching articles."
7550 ((null gnus-newsgroup-data)
7551 (gnus-message 3 "No articles in the group")
7553 ;; Pick the first article.
7554 ((not (or unread undownloaded unseen))
7555 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7556 (gnus-data-number (car gnus-newsgroup-data)))
7557 ;; Find the first unread article.
7559 (let ((data gnus-newsgroup-data))
7561 (let ((num (gnus-data-number (car data))))
7562 (or (memq num gnus-newsgroup-unfetched)
7563 (not (or (and unread
7564 (memq num gnus-newsgroup-unreads))
7566 (memq num gnus-newsgroup-undownloaded))
7568 (memq num gnus-newsgroup-unseen)
7569 (memq num gnus-newsgroup-unreads)))))))
7570 (setq data (cdr data)))
7574 (goto-char (gnus-data-pos (car data)))
7575 (gnus-data-number (car data)))
7576 (gnus-message 3 "No more%s articles"
7577 (let* ((r (when unread " unread"))
7578 (d (when undownloaded " undownloaded"))
7579 (s (when unseen " unseen"))
7580 (l (delq nil (list r d s))))
7581 (cond ((= 3 (length l))
7582 (concat r "," d ", or" s))
7584 (concat (car l) ", or" (cadr l)))
7591 (gnus-summary-position-point))))))
7593 (defun gnus-summary-next-subject (n &optional unread dont-display)
7594 "Go to next N'th summary line.
7595 If N is negative, go to the previous N'th subject line.
7596 If UNREAD is non-nil, only unread articles are selected.
7597 The difference between N and the actual number of steps taken is
7600 (let ((backward (< n 0))
7604 (gnus-summary-find-prev unread)
7605 (gnus-summary-find-next unread)))
7606 (unless (zerop (setq n (1- n)))
7607 (gnus-summary-show-thread)))
7609 (gnus-message 7 "No more%s articles"
7610 (if unread " unread" "")))
7611 (unless dont-display
7612 (gnus-summary-recenter)
7613 (gnus-summary-position-point))
7616 (defun gnus-summary-next-unread-subject (n)
7617 "Go to next N'th unread summary line."
7619 (gnus-summary-next-subject n t))
7621 (defun gnus-summary-prev-subject (n &optional unread)
7622 "Go to previous N'th summary line.
7623 If optional argument UNREAD is non-nil, only unread article is selected."
7625 (gnus-summary-next-subject (- n) unread))
7627 (defun gnus-summary-prev-unread-subject (n)
7628 "Go to previous N'th unread summary line."
7630 (gnus-summary-next-subject (- n) t))
7632 (defun gnus-summary-goto-subjects (articles)
7633 "Insert the subject header for ARTICLES in the current buffer."
7635 (dolist (article articles)
7636 (gnus-summary-goto-subject article t)))
7637 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7638 (gnus-summary-position-point))
7640 (defun gnus-summary-goto-subject (article &optional force silent)
7641 "Go to the subject line of ARTICLE.
7642 If FORCE, also allow jumping to articles not currently shown."
7643 (interactive "nArticle number: ")
7644 (unless (numberp article)
7645 (error "Article %s is not a number" article))
7647 (data (gnus-data-find article)))
7648 ;; We read in the article if we have to.
7651 (gnus-summary-insert-subject
7653 (if (or (numberp force) (vectorp force)) force)
7655 (setq data (gnus-data-find article)))
7660 (gnus-message 3 "Can't find article %d" article))
7662 (let ((pt (gnus-data-pos data)))
7664 (gnus-summary-set-article-display-arrow pt))
7665 (gnus-summary-position-point)
7668 ;; Walking around summary lines with displaying articles.
7670 (defun gnus-summary-expand-window (&optional arg)
7671 "Make the summary buffer take up the entire Emacs frame.
7672 Given a prefix, will force an `article' buffer configuration."
7675 (gnus-configure-windows 'article 'force)
7676 (gnus-configure-windows 'summary 'force)))
7678 (defun gnus-summary-display-article (article &optional all-header)
7679 "Display ARTICLE in article buffer."
7680 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7681 (with-current-buffer gnus-article-buffer
7682 (eq major-mode 'gnus-article-mode)))
7683 (gnus-article-setup-buffer))
7684 (gnus-set-global-variables)
7685 (with-current-buffer gnus-article-buffer
7686 (setq gnus-article-charset gnus-newsgroup-charset)
7687 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7688 (mm-enable-multibyte))
7692 (if gnus-summary-display-article-function
7693 (funcall gnus-summary-display-article-function article all-header)
7694 (gnus-article-prepare article all-header))
7695 (gnus-run-hooks 'gnus-select-article-hook)
7696 (when (and gnus-current-article
7697 (not (zerop gnus-current-article)))
7698 (gnus-summary-goto-subject gnus-current-article))
7699 (gnus-summary-recenter)
7700 (when (and gnus-use-trees gnus-show-threads)
7701 (gnus-possibly-generate-tree article)
7702 (gnus-highlight-selected-tree article))
7703 ;; Successfully display article.
7704 (gnus-article-set-window-start
7705 (cdr (assq article gnus-newsgroup-bookmarks))))))
7707 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7708 "Select the current article.
7709 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7710 non-nil, the article will be re-fetched even if it already present in
7711 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7713 ;; Make sure we are in the summary buffer to work around bbdb bug.
7714 (unless (eq major-mode 'gnus-summary-mode)
7715 (set-buffer gnus-summary-buffer))
7716 (let ((article (or article (gnus-summary-article-number)))
7717 (all-headers (not (not all-headers))) ;Must be t or nil.
7718 gnus-summary-display-article-function)
7720 (gnus-summary-article-pseudo-p article)
7721 (error "This is a pseudo-article"))
7722 (with-current-buffer gnus-summary-buffer
7723 (if (or (and gnus-single-article-buffer
7724 (or (null gnus-current-article)
7725 (null gnus-article-current)
7726 (null (get-buffer gnus-article-buffer))
7727 (not (eq article (cdr gnus-article-current)))
7728 (not (equal (car gnus-article-current)
7729 gnus-newsgroup-name))
7730 (not (get-buffer gnus-original-article-buffer))))
7731 (and (not gnus-single-article-buffer)
7732 (or (null gnus-current-article)
7733 (not (get-buffer gnus-original-article-buffer))
7734 (not (eq gnus-current-article article))))
7736 ;; The requested article is different from the current article.
7738 (gnus-summary-display-article article all-headers)
7739 (when (gnus-buffer-live-p gnus-article-buffer)
7740 (with-current-buffer gnus-article-buffer
7741 (if (not gnus-article-decoded-p) ;; a local variable
7742 (mm-disable-multibyte))))
7743 (gnus-article-set-window-start
7744 (cdr (assq article gnus-newsgroup-bookmarks)))
7748 (defun gnus-summary-force-verify-and-decrypt ()
7749 "Display buttons for signed/encrypted parts and verify/decrypt them."
7751 (let ((mm-verify-option 'known)
7752 (mm-decrypt-option 'known)
7753 (gnus-article-emulate-mime t)
7754 (gnus-buttonized-mime-types (append (list "multipart/signed"
7755 "multipart/encrypted")
7756 gnus-buttonized-mime-types)))
7757 (gnus-summary-select-article nil 'force)))
7759 (defun gnus-summary-set-current-mark (&optional current-mark)
7760 "Obsolete function."
7763 (defun gnus-summary-next-article (&optional unread subject backward push)
7764 "Select the next article.
7765 If UNREAD, only unread articles are selected.
7766 If SUBJECT, only articles with SUBJECT are selected.
7767 If BACKWARD, the previous article is selected instead of the next."
7769 ;; Make sure we are in the summary buffer.
7770 (unless (eq major-mode 'gnus-summary-mode)
7771 (set-buffer gnus-summary-buffer))
7773 ;; Is there such an article?
7774 ((and (gnus-summary-search-forward unread subject backward)
7775 (or (gnus-summary-display-article (gnus-summary-article-number))
7776 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7777 (gnus-summary-position-point))
7778 ;; If not, we try the first unread, if that is wanted.
7780 gnus-auto-select-same
7781 (gnus-summary-first-unread-article))
7782 (gnus-summary-position-point)
7783 (gnus-message 6 "Wrapped"))
7784 ;; Try to get next/previous article not displayed in this group.
7785 ((and gnus-auto-extend-newsgroup
7786 (not unread) (not subject))
7787 (gnus-summary-goto-article
7788 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7789 nil (count-lines (point-min) (point))))
7790 ;; Go to next/previous group.
7792 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7793 (gnus-summary-jump-to-group gnus-newsgroup-name))
7794 (let ((cmd (if (featurep 'xemacs)
7796 last-command-event))
7798 (with-current-buffer gnus-group-buffer
7800 (current-summary (current-buffer))
7802 (if (eq gnus-keep-same-level 'best)
7803 (gnus-summary-best-group gnus-newsgroup-name)
7804 (gnus-summary-search-group backward gnus-keep-same-level))))
7805 ;; Select next unread newsgroup automagically.
7807 ((or (not gnus-auto-select-next)
7809 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7810 ((or (eq gnus-auto-select-next 'quietly)
7811 (and (eq gnus-auto-select-next 'slightly-quietly)
7813 (and (eq gnus-auto-select-next 'almost-quietly)
7814 (gnus-summary-last-article-p)))
7816 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7818 (gnus-message 7 "No more%s articles (%s)..."
7819 (if unread " unread" "")
7820 (if group (concat "selecting " group)
7822 (gnus-summary-next-group nil group backward)))
7824 (when (gnus-key-press-event-p last-input-event)
7825 ;; Somehow or other, we may now have selected a different
7826 ;; window. Make point go back to the summary buffer.
7827 (when (eq current-summary (current-buffer))
7828 ;; FIXME: This burps when get-buffer-window returns nil.
7829 (select-window (get-buffer-window current-summary 0)))
7830 (gnus-summary-walk-group-buffer
7831 gnus-newsgroup-name cmd unread backward point))))))))
7833 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7834 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7835 (?\C-p (gnus-group-prev-unread-group 1))))
7836 (cursor-in-echo-area t)
7837 keve key group ended prompt)
7838 (with-current-buffer gnus-group-buffer
7841 (if (eq gnus-keep-same-level 'best)
7842 (gnus-summary-best-group gnus-newsgroup-name)
7843 (gnus-summary-search-group backward gnus-keep-same-level))))
7847 "No more%s articles%s " (if unread " unread" "")
7849 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7850 (format " (Type %s for %s [%s])"
7851 (single-key-description cmd)
7852 (gnus-group-decoded-name group)
7853 (gnus-group-unread group))
7854 (format " (Type %s to exit %s)"
7855 (single-key-description cmd)
7856 (gnus-group-decoded-name gnus-newsgroup-name)))))
7857 ;; Confirm auto selection.
7858 (setq key (car (setq keve (gnus-read-event-char prompt)))
7861 ((assq key keystrokes)
7862 (let ((obuf (current-buffer)))
7863 (switch-to-buffer gnus-group-buffer)
7865 (gnus-group-jump-to-group group))
7866 (eval (cadr (assq key keystrokes)))
7867 (setq group (gnus-group-group-name))
7868 (switch-to-buffer obuf))
7872 (gnus-ephemeral-group-p gnus-newsgroup-name))
7874 (gnus-summary-next-group nil group backward)))
7876 (push (cdr keve) unread-command-events))))))
7878 (defun gnus-summary-next-unread-article ()
7879 "Select unread article after current one."
7881 (gnus-summary-next-article
7882 (or (not (eq gnus-summary-goto-unread 'never))
7883 (gnus-summary-last-article-p (gnus-summary-article-number)))
7884 (and gnus-auto-select-same
7885 (gnus-summary-article-subject))))
7887 (defun gnus-summary-prev-article (&optional unread subject)
7888 "Select the article before the current one.
7889 If UNREAD is non-nil, only unread articles are selected."
7891 (gnus-summary-next-article unread subject t))
7893 (defun gnus-summary-prev-unread-article ()
7894 "Select unread article before current one."
7896 (gnus-summary-prev-article
7897 (or (not (eq gnus-summary-goto-unread 'never))
7898 (gnus-summary-first-article-p (gnus-summary-article-number)))
7899 (and gnus-auto-select-same
7900 (gnus-summary-article-subject))))
7902 (defun gnus-summary-next-page (&optional lines circular stop)
7903 "Show next page of the selected article.
7904 If at the end of the current article, select the next article.
7905 LINES says how many lines should be scrolled up.
7907 If CIRCULAR is non-nil, go to the start of the article instead of
7908 selecting the next article when reaching the end of the current
7911 If STOP is non-nil, just stop when reaching the end of the message.
7913 Also see the variable `gnus-article-skip-boring'."
7915 (setq gnus-summary-buffer (current-buffer))
7916 (gnus-set-global-variables)
7917 (let ((article (gnus-summary-article-number))
7918 (article-window (get-buffer-window gnus-article-buffer t))
7920 ;; If the buffer is empty, we have no article.
7922 (error "No article to select"))
7923 (gnus-configure-windows 'article)
7924 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7925 (if (and (eq gnus-summary-goto-unread 'never)
7926 (not (gnus-summary-last-article-p article)))
7927 (gnus-summary-next-article)
7928 (gnus-summary-next-unread-article))
7929 (if (or (null gnus-current-article)
7930 (null gnus-article-current)
7931 (/= article (cdr gnus-article-current))
7932 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7933 ;; Selected subject is different from current article's.
7934 (gnus-summary-display-article article)
7935 (when article-window
7936 (gnus-eval-in-buffer-window gnus-article-buffer
7937 (setq endp (or (gnus-article-next-page lines)
7938 (gnus-article-only-boring-p))))
7940 (cond ((or stop gnus-summary-stop-at-end-of-message)
7941 (gnus-message 3 "End of message"))
7943 (gnus-summary-beginning-of-article))
7945 (gnus-message 3 "End of message"))
7947 (if (and (eq gnus-summary-goto-unread 'never)
7948 (not (gnus-summary-last-article-p article)))
7949 (gnus-summary-next-article)
7950 (gnus-summary-next-unread-article))))))))
7951 (gnus-summary-recenter)
7952 (gnus-summary-position-point)))
7954 (defun gnus-summary-prev-page (&optional lines move)
7955 "Show previous page of selected article.
7956 Argument LINES specifies lines to be scrolled down.
7957 If MOVE, move to the previous unread article if point is at
7958 the beginning of the buffer."
7960 (let ((article (gnus-summary-article-number))
7961 (article-window (get-buffer-window gnus-article-buffer t))
7963 (gnus-configure-windows 'article)
7964 (if (or (null gnus-current-article)
7965 (null gnus-article-current)
7966 (/= article (cdr gnus-article-current))
7967 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7968 ;; Selected subject is different from current article's.
7969 (gnus-summary-display-article article)
7970 (gnus-summary-recenter)
7971 (when article-window
7972 (gnus-eval-in-buffer-window gnus-article-buffer
7973 (setq endp (gnus-article-prev-page lines)))
7974 (when (and move endp)
7976 (gnus-message 3 "Beginning of message"))
7978 (if (and (eq gnus-summary-goto-unread 'never)
7979 (not (gnus-summary-first-article-p article)))
7980 (gnus-summary-prev-article)
7981 (gnus-summary-prev-unread-article))))))))
7982 (gnus-summary-position-point))
7984 (defun gnus-summary-prev-page-or-article (&optional lines)
7985 "Show previous page of selected article.
7986 Argument LINES specifies lines to be scrolled down.
7987 If at the beginning of the article, go to the next article."
7989 (gnus-summary-prev-page lines t))
7991 (defun gnus-summary-scroll-up (lines)
7992 "Scroll up (or down) one line current article.
7993 Argument LINES specifies lines to be scrolled up (or down if negative).
7994 If no article is selected, then the current article will be selected first."
7996 (gnus-configure-windows 'article)
7997 (gnus-summary-show-thread)
7998 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7999 (gnus-eval-in-buffer-window gnus-article-buffer
8001 (when (gnus-article-next-page lines)
8002 (gnus-message 3 "End of message")))
8004 (gnus-article-prev-page (- lines))))))
8005 (gnus-summary-recenter)
8006 (gnus-summary-position-point))
8008 (defun gnus-summary-scroll-down (lines)
8009 "Scroll down (or up) one line current article.
8010 Argument LINES specifies lines to be scrolled down (or up if negative).
8011 If no article is selected, then the current article will be selected first."
8013 (gnus-summary-scroll-up (- lines)))
8015 (defun gnus-summary-next-same-subject ()
8016 "Select next article which has the same subject as current one."
8018 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8020 (defun gnus-summary-prev-same-subject ()
8021 "Select previous article which has the same subject as current one."
8023 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8025 (defun gnus-summary-next-unread-same-subject ()
8026 "Select next unread article which has the same subject as current one."
8028 (gnus-summary-next-article t (gnus-summary-article-subject)))
8030 (defun gnus-summary-prev-unread-same-subject ()
8031 "Select previous unread article which has the same subject as current one."
8033 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8035 (defun gnus-summary-first-unread-article ()
8036 "Select the first unread article.
8037 Return nil if there are no unread articles."
8040 (when (gnus-summary-first-subject t)
8041 (gnus-summary-show-thread)
8042 (gnus-summary-first-subject t)
8043 (gnus-summary-display-article (gnus-summary-article-number)))
8044 (gnus-summary-position-point)))
8046 (defun gnus-summary-first-unread-subject ()
8047 "Place the point on the subject line of the first unread article.
8048 Return nil if there are no unread articles."
8051 (when (gnus-summary-first-subject t)
8052 (gnus-summary-show-thread)
8053 (gnus-summary-first-subject t))
8054 (gnus-summary-position-point)))
8056 (defun gnus-summary-first-unseen-subject ()
8057 "Place the point on the subject line of the first unseen article.
8058 Return nil if there are no unseen articles."
8061 (when (gnus-summary-first-subject nil nil t)
8062 (gnus-summary-show-thread)
8063 (gnus-summary-first-subject nil nil t))
8064 (gnus-summary-position-point)))
8066 (defun gnus-summary-first-unseen-or-unread-subject ()
8067 "Place the point on the subject line of the first unseen and unread article.
8068 If all article have been seen, on the subject line of the first unread
8072 (unless (when (gnus-summary-first-subject nil nil t)
8073 (gnus-summary-show-thread)
8074 (gnus-summary-first-subject nil nil t))
8075 (when (gnus-summary-first-subject t)
8076 (gnus-summary-show-thread)
8077 (gnus-summary-first-subject t)))
8078 (gnus-summary-position-point)))
8080 (defun gnus-summary-first-article ()
8081 "Select the first article.
8082 Return nil if there are no articles."
8085 (when (gnus-summary-first-subject)
8086 (gnus-summary-show-thread)
8087 (gnus-summary-first-subject)
8088 (gnus-summary-display-article (gnus-summary-article-number)))
8089 (gnus-summary-position-point)))
8091 (defun gnus-summary-best-unread-article (&optional arg)
8092 "Select the unread article with the highest score.
8093 If given a prefix argument, select the next unread article that has a
8094 score higher than the default score."
8096 (let ((article (if arg
8097 (gnus-summary-better-unread-subject)
8098 (gnus-summary-best-unread-subject))))
8100 (gnus-summary-goto-article article)
8101 (error "No unread articles"))))
8103 (defun gnus-summary-best-unread-subject ()
8104 "Select the unread subject with the highest score."
8106 (let ((best -1000000)
8107 (data gnus-newsgroup-data)
8110 (and (gnus-data-unread-p (car data))
8112 (gnus-summary-article-score (gnus-data-number (car data))))
8115 article (gnus-data-number (car data))))
8116 (setq data (cdr data)))
8118 (gnus-summary-goto-subject article))
8119 (gnus-summary-position-point)
8122 (defun gnus-summary-better-unread-subject ()
8123 "Select the first unread subject that has a score over the default score."
8125 (let ((data gnus-newsgroup-data)
8127 (while (and (setq article (gnus-data-number (car data)))
8128 (or (gnus-data-read-p (car data))
8129 (not (> (gnus-summary-article-score article)
8130 gnus-summary-default-score))))
8131 (setq data (cdr data)))
8133 (gnus-summary-goto-subject article))
8134 (gnus-summary-position-point)
8137 (defun gnus-summary-last-subject ()
8138 "Go to the last displayed subject line in the group."
8139 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8141 (gnus-summary-goto-subject article))))
8143 (defun gnus-summary-goto-article (article &optional all-headers force)
8144 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8145 If ALL-HEADERS is non-nil, no header lines are hidden.
8146 If FORCE, go to the article even if it isn't displayed. If FORCE
8147 is a number, it is the line the article is to be displayed on."
8150 (gnus-completing-read
8151 "Article number or Message-ID"
8152 (mapcar 'int-to-string gnus-newsgroup-limit))
8156 (if (and (stringp article)
8157 (string-match "@\\|%40" article))
8158 (gnus-summary-refer-article article)
8159 (when (stringp article)
8160 (setq article (string-to-number article)))
8161 (if (gnus-summary-goto-subject article force)
8162 (gnus-summary-display-article article all-headers)
8163 (gnus-message 4 "Couldn't go to article %s" article) nil))
8164 (gnus-summary-position-point)))
8166 (defun gnus-summary-goto-last-article ()
8167 "Go to the previously read article."
8170 (when gnus-last-article
8171 (gnus-summary-goto-article gnus-last-article nil t))
8172 (gnus-summary-position-point)))
8174 (defun gnus-summary-pop-article (number)
8175 "Pop one article off the history and go to the previous.
8176 NUMBER articles will be popped off."
8179 (setq gnus-newsgroup-history
8180 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8182 (gnus-summary-goto-article (car to) nil t)
8183 (error "Article history empty")))
8184 (gnus-summary-position-point))
8186 ;; Summary commands and functions for limiting the summary buffer.
8188 (defun gnus-summary-limit-to-articles (n)
8189 "Limit the summary buffer to the next N articles.
8190 If not given a prefix, use the process marked articles instead."
8193 (let ((articles (gnus-summary-work-articles n)))
8194 (setq gnus-newsgroup-processable nil)
8195 (gnus-summary-limit articles))
8196 (gnus-summary-position-point)))
8198 (defun gnus-summary-pop-limit (&optional total)
8199 "Restore the previous limit.
8200 If given a prefix, remove all limits."
8203 (setq gnus-newsgroup-limits
8204 (list (mapcar (lambda (h) (mail-header-number h))
8205 gnus-newsgroup-headers))))
8206 (unless gnus-newsgroup-limits
8207 (error "No limit to pop"))
8209 (gnus-summary-limit nil 'pop)
8210 (gnus-summary-position-point)))
8212 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8213 "Limit the summary buffer to articles that have subjects that match a regexp.
8214 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8216 (list (read-string (if current-prefix-arg
8217 "Exclude subject (regexp): "
8218 "Limit to subject (regexp): "))
8219 nil current-prefix-arg))
8221 (setq header "subject"))
8222 (when (not (equal "" subject))
8224 (let ((articles (gnus-summary-find-matching
8225 (or header "subject") subject 'all nil nil
8228 (error "Found no matches for \"%s\"" subject))
8229 (gnus-summary-limit articles))
8230 (gnus-summary-position-point))))
8232 (defun gnus-summary-limit-to-author (from &optional not-matching)
8233 "Limit the summary buffer to articles that have authors that match a regexp.
8234 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8236 (list (read-string (if current-prefix-arg
8237 "Exclude author (regexp): "
8238 "Limit to author (regexp): "))
8239 current-prefix-arg))
8240 (gnus-summary-limit-to-subject from "from" not-matching))
8242 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8243 "Limit the summary buffer to articles with the given RECIPIENT.
8245 If NOT-MATCHING, exclude RECIPIENT.
8247 To and Cc headers are checked. You need to include them in
8248 `nnmail-extra-headers'."
8249 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8251 (list (read-string (format "%s recipient (regexp): "
8252 (if current-prefix-arg "Exclude" "Limit to")))
8253 current-prefix-arg))
8254 (when (not (equal "" recipient))
8256 (if (memq 'To nnmail-extra-headers)
8257 (gnus-summary-find-matching
8258 (cons 'extra 'To) recipient 'all nil nil
8261 1 "`To' isn't present in `nnmail-extra-headers'")
8265 (if (memq 'Cc nnmail-extra-headers)
8266 (gnus-summary-find-matching
8267 (cons 'extra 'Cc) recipient 'all nil nil
8270 1 "`Cc' isn't present in `nnmail-extra-headers'")
8275 ;; We need the numbers that are in both lists:
8277 (and (memq a to) a))
8281 (error "Found no matches for \"%s\"" recipient))
8282 (gnus-summary-limit articles))
8283 (gnus-summary-position-point))))
8285 (defun gnus-summary-limit-to-address (address &optional not-matching)
8286 "Limit the summary buffer to articles with the given ADDRESS.
8288 If NOT-MATCHING, exclude ADDRESS.
8290 To, Cc and From headers are checked. You need to include `To' and `Cc'
8291 in `nnmail-extra-headers'."
8293 (list (read-string (format "%s address (regexp): "
8294 (if current-prefix-arg "Exclude" "Limit to")))
8295 current-prefix-arg))
8296 (when (not (equal "" address))
8298 (if (memq 'To nnmail-extra-headers)
8299 (gnus-summary-find-matching
8300 (cons 'extra 'To) address 'all nil nil
8303 1 "`To' isn't present in `nnmail-extra-headers'")
8307 (if (memq 'Cc nnmail-extra-headers)
8308 (gnus-summary-find-matching
8309 (cons 'extra 'Cc) address 'all nil nil
8312 1 "`Cc' isn't present in `nnmail-extra-headers'")
8316 (gnus-summary-find-matching "from" address
8317 'all nil nil not-matching))
8320 ;; We need the numbers that are in all lists:
8324 (mapcar (lambda (a) (car (memq a from))) to))
8326 (mapcar (lambda (a) (car (memq a from))) cc)
8327 (mapcar (lambda (a) (car (memq a from)))
8328 (mapcar (lambda (a) (car (memq a to)))
8330 (nconc (if (eq to t) nil to)
8331 (if (eq cc t) nil cc)
8334 (error "Found no matches for \"%s\"" address))
8335 (gnus-summary-limit articles))
8336 (gnus-summary-position-point))))
8338 (defun gnus-summary-limit-strange-charsets-predicate (header)
8339 (when (fboundp 'char-charset)
8340 (let ((string (concat (mail-header-subject header)
8341 (mail-header-from header)))
8343 (dotimes (i (1- (length string)))
8344 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8345 (when (string-match "unicode\\|big\\|japanese" charset)
8349 (defun gnus-summary-limit-to-predicate (predicate)
8350 "Limit to articles where PREDICATE returns non-nil.
8351 PREDICATE will be called with the header structures of the
8353 (let ((articles nil)
8354 (case-fold-search t))
8355 (dolist (header gnus-newsgroup-headers)
8356 (when (funcall predicate header)
8357 (push (mail-header-number header) articles)))
8358 (gnus-summary-limit (nreverse articles))))
8360 (defun gnus-summary-limit-to-age (age &optional younger-p)
8361 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8362 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8363 articles that are younger than AGE days."
8365 (let ((younger current-prefix-arg)
8368 (while (not days-got)
8369 (setq days (if younger
8370 (read-string "Limit to articles younger than (in days, older when negative): ")
8372 "Limit to articles older than (in days, younger when negative): ")))
8373 (when (> (length days) 0)
8374 (setq days (read days)))
8379 (setq younger (not younger))
8380 (setq days (* days -1))))
8381 (message "Please enter a number.")
8383 (list days younger)))
8385 (let ((data gnus-newsgroup-data)
8386 (cutoff (days-to-time age))
8387 articles d date is-younger)
8388 (while (setq d (pop data))
8389 (when (and (vectorp (gnus-data-header d))
8390 (setq date (mail-header-date (gnus-data-header d))))
8391 (setq is-younger (time-less-p
8392 (time-since (gnus-date-get-time date))
8397 (push (gnus-data-number d) articles))))
8398 (gnus-summary-limit (nreverse articles)))
8399 (gnus-summary-position-point)))
8401 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8402 "Limit the summary buffer to articles that match an 'extra' header."
8406 (gnus-completing-read
8407 (if current-prefix-arg
8408 "Exclude extra header"
8409 "Limit extra header")
8410 (mapcar 'symbol-name gnus-extra-headers)
8412 (symbol-name (car gnus-extra-headers))))))
8414 (read-string (format "%s header %s (regexp): "
8415 (if current-prefix-arg "Exclude" "Limit to")
8417 current-prefix-arg)))
8418 (when (not (equal "" regexp))
8420 (let ((articles (gnus-summary-find-matching
8421 (cons 'extra header) regexp 'all nil nil
8424 (error "Found no matches for \"%s\"" regexp))
8425 (gnus-summary-limit articles))
8426 (gnus-summary-position-point))))
8428 (defun gnus-summary-limit-to-display-predicate ()
8429 "Limit the summary buffer to the predicated in the `display' group parameter."
8431 (unless gnus-newsgroup-display
8432 (error "There is no `display' group parameter"))
8434 (dolist (gnus-number gnus-newsgroup-articles)
8435 (when (funcall gnus-newsgroup-display)
8436 (push gnus-number articles)))
8437 (gnus-summary-limit articles))
8438 (gnus-summary-position-point))
8440 (defun gnus-summary-limit-to-unread (&optional all)
8441 "Limit the summary buffer to articles that are not marked as read.
8442 If ALL is non-nil, limit strictly to unread articles."
8445 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8446 (gnus-summary-limit-to-marks
8447 ;; Concat all the marks that say that an article is read and have
8449 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8450 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8451 gnus-low-score-mark gnus-expirable-mark
8452 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8453 gnus-duplicate-mark)
8456 (defun gnus-summary-limit-to-headers (match &optional reverse)
8457 "Limit the summary buffer to articles that have headers that match MATCH.
8458 If REVERSE (the prefix), limit to articles that don't match."
8459 (interactive "sMatch headers (regexp): \nP")
8460 (gnus-summary-limit-to-bodies match reverse t))
8462 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8463 "Limit the summary buffer to articles that have bodies that match MATCH.
8464 If REVERSE (the prefix), limit to articles that don't match."
8465 (interactive "sMatch body (regexp): \nP")
8466 (let ((articles nil)
8467 (gnus-select-article-hook nil) ;Disable hook.
8468 (gnus-article-prepare-hook nil)
8469 (gnus-use-article-prefetch nil)
8470 (gnus-keep-backlog nil)
8471 (gnus-break-pages nil)
8472 (gnus-summary-display-arrow nil)
8473 (gnus-updated-mode-lines nil)
8474 (gnus-auto-center-summary nil)
8475 (gnus-display-mime-function nil))
8476 (dolist (data gnus-newsgroup-data)
8477 (let (gnus-mark-article-hook)
8478 (gnus-summary-select-article t t nil (gnus-data-number data)))
8479 (with-current-buffer gnus-article-buffer
8481 (let* ((case-fold-search t)
8483 (re-search-backward match nil t)
8484 (re-search-forward match nil t))))
8485 (when (or (and found
8489 (push (gnus-data-number data) articles)))))
8491 (message "No messages matched")
8492 (gnus-summary-limit articles)))
8493 (gnus-summary-position-point))
8495 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8496 "Limit the summary buffer to articles that aren't part on any thread.
8497 If THREADSP (the prefix), limit to articles that are in threads."
8499 (let ((articles nil)
8502 (dolist (thread gnus-newsgroup-threads)
8503 (if (stringp (car thread))
8504 (dolist (thread (cdr thread))
8505 (push thread threads))
8506 (push thread threads)))
8507 (dolist (thread threads)
8508 (setq thread-articles (gnus-articles-in-thread thread))
8509 (when (or (and threadsp
8510 (> (length thread-articles) 1))
8512 (= (length thread-articles) 1)))
8513 (setq articles (nconc thread-articles articles))))
8515 (message "No messages matched")
8516 (gnus-summary-limit articles))
8517 (gnus-summary-position-point)))
8519 (defun gnus-summary-limit-to-replied (&optional unreplied)
8520 "Limit the summary buffer to replied articles.
8521 If UNREPLIED (the prefix), limit to unreplied articles."
8525 (gnus-set-difference gnus-newsgroup-articles
8526 gnus-newsgroup-replied))
8527 (gnus-summary-limit gnus-newsgroup-replied))
8528 (gnus-summary-position-point))
8530 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8531 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8532 If REVERSE, limit the summary buffer to articles that are marked
8533 with MARKS. MARKS can either be a string of marks or a list of marks.
8534 Returns how many articles were removed."
8535 (interactive "sMarks: ")
8536 (gnus-summary-limit-to-marks marks t))
8538 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8539 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8540 If REVERSE (the prefix), limit the summary buffer to articles that are
8541 not marked with MARKS. MARKS can either be a string of marks or a
8543 Returns how many articles were removed."
8544 (interactive "sMarks: \nP")
8546 (let ((data gnus-newsgroup-data)
8547 (marks (if (listp marks) marks
8548 (append marks nil))) ; Transform to list.
8551 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8552 (memq (gnus-data-mark (car data)) marks))
8553 (push (gnus-data-number (car data)) articles))
8554 (setq data (cdr data)))
8555 (gnus-summary-limit articles))
8556 (gnus-summary-position-point)))
8558 (defun gnus-summary-limit-to-score (score)
8559 "Limit to articles with score at or above SCORE."
8560 (interactive "NLimit to articles with score of at least: ")
8561 (let ((data gnus-newsgroup-data)
8564 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8566 (push (gnus-data-number (car data)) articles))
8567 (setq data (cdr data)))
8569 (gnus-summary-limit articles)
8570 (gnus-summary-position-point))))
8572 (defun gnus-summary-limit-to-unseen ()
8573 "Limit to unseen articles."
8576 (gnus-summary-limit gnus-newsgroup-unseen)
8577 (gnus-summary-position-point)))
8579 (defun gnus-summary-limit-include-thread (id)
8580 "Display all the hidden articles that is in the thread with ID in it.
8581 When called interactively, ID is the Message-ID of the current
8583 (interactive (list (mail-header-id (gnus-summary-article-header))))
8584 (let ((articles (gnus-articles-in-thread
8585 (gnus-id-to-thread (gnus-root-id id))))
8586 ;;we REALLY want the whole thread---this prevents cut-threads
8587 ;;from removing the thread we want to include.
8588 (gnus-fetch-old-headers nil)
8589 (gnus-build-sparse-threads nil))
8591 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8592 (gnus-summary-limit-include-matching-articles
8594 (regexp-quote (gnus-simplify-subject-re
8595 (mail-header-subject (gnus-id-to-header id)))))
8596 (gnus-summary-position-point))))
8598 (defun gnus-summary-limit-include-matching-articles (header regexp)
8599 "Display all the hidden articles that have HEADERs that match REGEXP."
8600 (interactive (list (read-string "Match on header: ")
8601 (read-string "Regexp: ")))
8602 (let ((articles (gnus-find-matching-articles header regexp)))
8604 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8605 (gnus-summary-position-point))))
8607 (defun gnus-summary-insert-dormant-articles ()
8608 "Insert all the dormant articles for this group into the current buffer."
8610 (let ((gnus-verbose (max 6 gnus-verbose)))
8611 (if (not gnus-newsgroup-dormant)
8612 (gnus-message 3 "No dormant articles for this group")
8613 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8615 (defun gnus-summary-insert-ticked-articles ()
8616 "Insert ticked articles for this group into the current buffer."
8618 (let ((gnus-verbose (max 6 gnus-verbose)))
8619 (if (not gnus-newsgroup-marked)
8620 (gnus-message 3 "No ticked articles for this group")
8621 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8623 (defun gnus-summary-limit-include-dormant ()
8624 "Display all the hidden articles that are marked as dormant.
8625 Note that this command only works on a subset of the articles currently
8626 fetched for this group."
8628 (unless gnus-newsgroup-dormant
8629 (error "There are no dormant articles in this group"))
8631 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8632 (gnus-summary-position-point)))
8634 (defun gnus-summary-include-articles (articles)
8635 "Fetch the headers for ARTICLES and then display the summary lines."
8636 (let ((gnus-inhibit-demon t)
8638 (gnus-read-all-available-headers t))
8639 (setq gnus-newsgroup-headers
8641 'list gnus-newsgroup-headers
8642 (gnus-fetch-headers articles nil t)
8643 'gnus-article-sort-by-number))
8644 (setq gnus-newsgroup-articles
8645 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8646 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8648 (defun gnus-summary-limit-exclude-dormant ()
8649 "Hide all dormant articles."
8652 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8653 (gnus-summary-position-point)))
8655 (defun gnus-summary-limit-exclude-childless-dormant ()
8656 "Hide all dormant articles that have no children."
8658 (let ((data (gnus-data-list t))
8659 articles d children)
8660 ;; Find all articles that are either not dormant or have
8662 (while (setq d (pop data))
8663 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8665 (gnus-article-children (gnus-data-number d)))
8668 (when (memq (car children) articles)
8673 (push (gnus-data-number d) articles)))
8676 (gnus-summary-limit articles)
8677 (gnus-summary-position-point))))
8679 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8680 "Mark all unread excluded articles as read.
8681 If ALL, mark even excluded ticked and dormants as read."
8683 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8684 (let ((articles (gnus-sorted-ndifference
8686 (mapcar (lambda (h) (mail-header-number h))
8687 gnus-newsgroup-headers)
8689 gnus-newsgroup-limit))
8691 (setq gnus-newsgroup-unreads
8692 (gnus-sorted-intersection gnus-newsgroup-unreads
8693 gnus-newsgroup-limit))
8695 (setq gnus-newsgroup-dormant nil
8696 gnus-newsgroup-marked nil
8697 gnus-newsgroup-reads
8699 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8700 gnus-newsgroup-reads))
8701 (while (setq article (pop articles))
8702 (unless (or (memq article gnus-newsgroup-dormant)
8703 (memq article gnus-newsgroup-marked))
8704 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8706 (defun gnus-summary-limit (articles &optional pop)
8708 ;; We pop the previous limit off the stack and use that.
8709 (setq articles (car gnus-newsgroup-limits)
8710 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8711 ;; We use the new limit, so we push the old limit on the stack.
8712 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8714 (setq gnus-newsgroup-limit articles)
8715 (let ((total (length gnus-newsgroup-data))
8716 (data (gnus-data-find-list (gnus-summary-article-number)))
8717 (gnus-summary-mark-below nil) ; Inhibit this.
8719 ;; This will do all the work of generating the new summary buffer
8720 ;; according to the new limit.
8721 (gnus-summary-prepare)
8722 ;; Hide any threads, possibly.
8723 (gnus-summary-maybe-hide-threads)
8724 ;; Try to return to the article you were at, or one in the
8727 ;; We try to find some article after the current one.
8729 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8732 (setq data (cdr data))))
8734 ;; If there is no data, that means that we were after the last
8735 ;; article. The same goes when we can't find any articles
8736 ;; after the current one.
8737 (goto-char (point-max))
8738 (gnus-summary-find-prev))
8739 (gnus-set-mode-line 'summary)
8740 ;; We return how many articles were removed from the summary
8741 ;; buffer as a result of the new limit.
8742 (- total (length gnus-newsgroup-data))))
8744 (defsubst gnus-invisible-cut-children (threads)
8747 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8752 (defsubst gnus-cut-thread (thread)
8753 "Go forwards in the thread until we find an article that we want to display."
8754 (when (or (eq gnus-fetch-old-headers 'some)
8755 (eq gnus-fetch-old-headers 'invisible)
8756 (numberp gnus-fetch-old-headers)
8757 (eq gnus-build-sparse-threads 'some)
8758 (eq gnus-build-sparse-threads 'more))
8759 ;; Deal with old-fetched headers and sparse threads.
8763 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8764 (gnus-summary-article-ancient-p
8765 (mail-header-number (car thread))))
8766 (if (or (<= (length (cdr thread)) 1)
8767 (eq gnus-fetch-old-headers 'invisible))
8768 (setq gnus-newsgroup-limit
8769 (delq (mail-header-number (car thread))
8770 gnus-newsgroup-limit)
8771 thread (cadr thread))
8772 (when (gnus-invisible-cut-children (cdr thread))
8773 (let ((th (cdr thread)))
8775 (if (memq (mail-header-number (caar th))
8776 gnus-newsgroup-limit)
8777 (setq thread (car th)
8779 (setq th (cdr th))))))))))
8782 (defun gnus-cut-threads (threads)
8783 "Cut off all uninteresting articles from the beginning of THREADS."
8784 (when (or (eq gnus-fetch-old-headers 'some)
8785 (eq gnus-fetch-old-headers 'invisible)
8786 (numberp gnus-fetch-old-headers)
8787 (eq gnus-build-sparse-threads 'some)
8788 (eq gnus-build-sparse-threads 'more))
8791 (setcar th (gnus-cut-thread (car th)))
8792 (setq th (cdr th)))))
8793 ;; Remove nixed out threads.
8796 (defun gnus-summary-initial-limit (&optional show-if-empty)
8797 "Figure out what the initial limit is supposed to be on group entry.
8798 This entails weeding out unwanted dormants, low-scored articles,
8799 fetch-old-headers verbiage, and so on."
8800 ;; Most groups have nothing to remove.
8801 (unless (or gnus-inhibit-limiting
8802 (and (null gnus-newsgroup-dormant)
8803 (eq gnus-newsgroup-display 'gnus-not-ignore)
8804 (not (eq gnus-fetch-old-headers 'some))
8805 (not (numberp gnus-fetch-old-headers))
8806 (not (eq gnus-fetch-old-headers 'invisible))
8807 (null gnus-summary-expunge-below)
8808 (not (eq gnus-build-sparse-threads 'some))
8809 (not (eq gnus-build-sparse-threads 'more))
8810 (null gnus-thread-expunge-below)))
8811 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8812 (setq gnus-newsgroup-limit nil)
8815 (unless (car (symbol-value node))
8816 ;; These threads have no parents -- they are roots.
8817 (let ((nodes (cdr (symbol-value node)))
8820 (if (and gnus-thread-expunge-below
8821 (< (gnus-thread-total-score (car nodes))
8822 gnus-thread-expunge-below))
8823 (gnus-expunge-thread (pop nodes))
8824 (setq thread (pop nodes))
8825 (gnus-summary-limit-children thread))))))
8826 gnus-newsgroup-dependencies)
8827 ;; If this limitation resulted in an empty group, we might
8828 ;; pop the previous limit and use it instead.
8829 (when (and (not gnus-newsgroup-limit)
8831 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8832 gnus-newsgroup-limit))
8834 (defun gnus-summary-limit-children (thread)
8835 "Return 1 if this subthread is visible and 0 if it is not."
8836 ;; First we get the number of visible children to this thread. This
8837 ;; is done by recursing down the thread using this function, so this
8838 ;; will really go down to a leaf article first, before slowly
8839 ;; working its way up towards the root.
8841 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8844 (apply '+ (mapcar 'gnus-summary-limit-children
8847 (number (mail-header-number (car thread)))
8850 (not (memq number gnus-newsgroup-marked))
8852 ;; If this article is dormant and has absolutely no visible
8853 ;; children, then this article isn't visible.
8854 (and (memq number gnus-newsgroup-dormant)
8856 ;; If this is "fetch-old-headered" and there is no
8857 ;; visible children, then we don't want this article.
8858 (and (or (eq gnus-fetch-old-headers 'some)
8859 (numberp gnus-fetch-old-headers))
8860 (gnus-summary-article-ancient-p number)
8862 ;; If this is "fetch-old-headered" and `invisible', then
8863 ;; we don't want this article.
8864 (and (eq gnus-fetch-old-headers 'invisible)
8865 (gnus-summary-article-ancient-p number))
8866 ;; If this is a sparsely inserted article with no children,
8867 ;; we don't want it.
8868 (and (eq gnus-build-sparse-threads 'some)
8869 (gnus-summary-article-sparse-p number)
8871 ;; If we use expunging, and this article is really
8872 ;; low-scored, then we don't want this article.
8873 (when (and gnus-summary-expunge-below
8875 (or (cdr (assq number gnus-newsgroup-scored))
8876 gnus-summary-default-score))
8877 gnus-summary-expunge-below))
8878 ;; We increase the expunge-tally here, but that has
8879 ;; nothing to do with the limits, really.
8880 (incf gnus-newsgroup-expunged-tally)
8881 ;; We also mark as read here, if that's wanted.
8882 (when (and gnus-summary-mark-below
8883 (< score gnus-summary-mark-below))
8884 (setq gnus-newsgroup-unreads
8885 (delq number gnus-newsgroup-unreads))
8886 (if gnus-newsgroup-auto-expire
8887 (push number gnus-newsgroup-expirable)
8888 (push (cons number gnus-low-score-mark)
8889 gnus-newsgroup-reads)))
8891 ;; Do the `display' group parameter.
8892 (and gnus-newsgroup-display
8893 (let ((gnus-number number))
8894 (not (funcall gnus-newsgroup-display))))))
8895 ;; Nope, invisible article.
8897 ;; Ok, this article is to be visible, so we add it to the limit
8899 (push number gnus-newsgroup-limit)
8902 (defun gnus-expunge-thread (thread)
8903 "Mark all articles in THREAD as read."
8904 (let* ((number (mail-header-number (car thread))))
8905 (incf gnus-newsgroup-expunged-tally)
8906 ;; We also mark as read here, if that's wanted.
8907 (setq gnus-newsgroup-unreads
8908 (delq number gnus-newsgroup-unreads))
8909 (if gnus-newsgroup-auto-expire
8910 (push number gnus-newsgroup-expirable)
8911 (push (cons number gnus-low-score-mark)
8912 gnus-newsgroup-reads)))
8913 ;; Go recursively through all subthreads.
8914 (mapcar 'gnus-expunge-thread (cdr thread)))
8916 ;; Summary article oriented commands
8918 (defun gnus-summary-refer-parent-article (n)
8919 "Refer parent article N times.
8920 If N is negative, go to ancestor -N instead.
8921 The difference between N and the number of articles fetched is returned."
8925 (when (not (natnump n))
8930 (setq header (gnus-summary-article-header))
8931 (if (and (eq (mail-header-number header)
8932 (cdr gnus-article-current))
8933 (equal gnus-newsgroup-name
8934 (car gnus-article-current)))
8935 ;; If we try to find the parent of the currently
8936 ;; displayed article, then we take a look at the actual
8937 ;; References header, since this is slightly more
8938 ;; reliable than the References field we got from the
8940 (with-current-buffer gnus-original-article-buffer
8941 (nnheader-narrow-to-headers)
8942 (unless (setq ref (message-fetch-field "references"))
8943 (when (setq ref (message-fetch-field "in-reply-to"))
8944 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8947 ;; It's not the current article, so we take a bet on
8948 ;; the value we got from the server.
8949 (mail-header-references header)))
8951 (not (equal ref "")))
8952 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8953 (gnus-message 1 "Couldn't find parent"))
8954 (gnus-message 1 "No references in article %d"
8955 (gnus-summary-article-number))
8958 (gnus-summary-position-point)
8961 (defun gnus-summary-refer-references ()
8962 "Fetch all articles mentioned in the References header.
8963 Return the number of articles fetched."
8965 (let ((ref (mail-header-references (gnus-summary-article-header)))
8966 (current (gnus-summary-article-number))
8970 (error "No References in the current article")
8971 ;; For each Message-ID in the References header...
8972 (while (string-match "<[^>]*>" ref)
8974 ;; ... fetch that article.
8975 (gnus-summary-refer-article
8976 (prog1 (match-string 0 ref)
8977 (setq ref (substring ref (match-end 0))))))
8978 (gnus-summary-goto-subject current)
8979 (gnus-summary-position-point)
8982 (defun gnus-delete-duplicate-headers (headers)
8983 ;; First remove leading duplicates.
8984 (while (and (> (length headers) 1)
8985 (= (mail-header-number (car headers))
8986 (mail-header-number (cadr headers))))
8989 (let ((result headers))
8990 (while (> (length headers) 1)
8991 (if (= (mail-header-number (car headers))
8992 (mail-header-number (cadr headers)))
8993 (setcdr headers (cddr headers))
8997 (defun gnus-summary-refer-thread (&optional limit)
8998 "Fetch all articles in the current thread. For backends that
8999 know how to search for threads (currently only 'nnimap) a
9000 non-numeric prefix arg will use nnir to search the entire
9001 server; without a prefix arg only the current group is
9002 searched. If the variable `gnus-refer-thread-use-nnir' is
9003 non-nil the prefix arg has the reverse meaning. If no
9004 backend-specific 'request-thread function is available fetch
9005 LIMIT (the numerical prefix) old headers. If LIMIT is
9006 non-numeric or nil fetch the number specified by the
9007 `gnus-refer-thread-limit' variable."
9009 (gnus-warp-to-article)
9010 (let* ((header (gnus-summary-article-header))
9011 (id (mail-header-id header))
9012 (gnus-inhibit-demon t)
9013 (gnus-summary-ignore-duplicates t)
9014 (gnus-read-all-available-headers t)
9015 (gnus-refer-thread-use-nnir
9016 (if (and (not (null limit)) (listp limit))
9017 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9019 (if (gnus-check-backend-function
9020 'request-thread gnus-newsgroup-name)
9021 (gnus-request-thread header gnus-newsgroup-name)
9022 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9023 gnus-refer-thread-limit))
9024 (last (if (numberp limit)
9025 (min (+ (mail-header-number header)
9027 gnus-newsgroup-highest)
9028 gnus-newsgroup-highest))
9029 (subject (gnus-simplify-subject
9030 (mail-header-subject header)))
9031 (refs (split-string (or (mail-header-references header)
9033 (gnus-parse-headers-hook
9034 `(lambda () (goto-char (point-min))
9036 (regexp-opt ',(append refs (list id subject)))))))
9037 (gnus-fetch-headers (list last) (if (numberp limit)
9038 (* 2 limit) limit) t))))
9040 (when (listp new-headers)
9041 (dolist (header new-headers)
9042 (push (mail-header-number header) article-ids)
9043 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9044 (push (mail-header-number header) gnus-newsgroup-unreads)
9045 (setq gnus-newsgroup-unselected
9046 (delete (mail-header-number header)
9047 gnus-newsgroup-unselected))))
9048 (setq gnus-newsgroup-headers
9049 (gnus-delete-duplicate-headers
9051 'list gnus-newsgroup-headers new-headers
9052 'gnus-article-sort-by-number)))
9053 (setq gnus-newsgroup-articles
9054 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9055 (gnus-summary-limit-include-thread id)))
9056 (gnus-summary-show-thread))
9058 (defun gnus-summary-refer-article (message-id)
9059 "Fetch an article specified by MESSAGE-ID."
9060 (interactive "sMessage-ID: ")
9061 (gnus-warp-to-article)
9062 (when (and (stringp message-id)
9063 (not (zerop (length message-id))))
9064 (setq message-id (gnus-replace-in-string message-id " " ""))
9065 ;; Construct the correct Message-ID if necessary.
9066 ;; Suggested by tale@pawl.rpi.edu.
9067 (unless (string-match "^<" message-id)
9068 (setq message-id (concat "<" message-id)))
9069 (unless (string-match ">$" message-id)
9070 (setq message-id (concat message-id ">")))
9071 ;; People often post MIDs from URLs, so unhex it:
9072 (unless (string-match "@" message-id)
9073 (setq message-id (gnus-url-unhex-string message-id)))
9074 (let* ((header (gnus-id-to-header message-id))
9076 (gnus-summary-article-sparse-p
9077 (mail-header-number header))
9078 (memq (mail-header-number header)
9079 gnus-newsgroup-limit)))
9082 ;; If the article is present in the buffer we just go to it.
9084 (or (not (gnus-summary-article-sparse-p
9085 (mail-header-number header)))
9088 (gnus-summary-goto-article
9089 (mail-header-number header) nil t)
9091 (gnus-summary-update-article (mail-header-number header)))))
9093 ;; We fetch the article.
9095 (dolist (gnus-override-method (gnus-refer-article-methods))
9096 (when (and (gnus-check-server gnus-override-method)
9097 ;; Fetch the header,
9098 (setq number (gnus-summary-insert-subject message-id)))
9099 ;; and display the article.
9100 (gnus-summary-select-article nil nil nil number)
9102 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9104 (defun gnus-refer-article-methods ()
9105 "Return a list of referable methods."
9107 ;; No method, so we default to current and native.
9108 ((null gnus-refer-article-method)
9109 (list gnus-current-select-method gnus-select-method))
9111 ((eq 'current gnus-refer-article-method)
9112 (list gnus-current-select-method))
9113 ;; List of select methods.
9114 ((not (and (symbolp (car gnus-refer-article-method))
9115 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9117 (dolist (method gnus-refer-article-method)
9118 (push (if (eq 'current method)
9119 gnus-current-select-method
9120 (if (eq 'nnir (car method))
9124 (gnus-method-to-server gnus-current-select-method)))
9128 ;; One single select method.
9130 (list gnus-refer-article-method))))
9132 (defun gnus-summary-edit-parameters ()
9133 "Edit the group parameters of the current group."
9135 (gnus-group-edit-group gnus-newsgroup-name 'params))
9137 (defun gnus-summary-customize-parameters ()
9138 "Customize the group parameters of the current group."
9140 (gnus-group-customize gnus-newsgroup-name))
9142 (defun gnus-summary-enter-digest-group (&optional force)
9143 "Enter an nndoc group based on the current article.
9144 If FORCE, force a digest interpretation. If not, try to guess
9145 what the document format is.
9147 To control what happens when you exit the group, see the
9148 `gnus-auto-select-on-ephemeral-exit' variable."
9150 (let ((conf gnus-current-window-configuration))
9151 (save-window-excursion
9153 (let (gnus-article-prepare-hook
9154 gnus-display-mime-function
9156 (gnus-summary-select-article))))
9157 (setq gnus-current-window-configuration conf)
9158 (let* ((name (format "%s-%d"
9159 (gnus-group-prefixed-name
9160 gnus-newsgroup-name (list 'nndoc ""))
9161 (with-current-buffer gnus-summary-buffer
9162 gnus-current-article)))
9163 (ogroup gnus-newsgroup-name)
9164 (params (append (gnus-info-params (gnus-get-info ogroup))
9165 (list (cons 'to-group ogroup))
9166 (list (cons 'parent-group ogroup))
9167 (list (cons 'save-article-group ogroup))))
9168 (case-fold-search t)
9169 (buf (current-buffer))
9171 (with-current-buffer gnus-original-article-buffer
9172 ;; Have the digest group inherit the main mail address of
9173 ;; the parent article.
9174 (when (setq to-address (or (gnus-fetch-field "reply-to")
9175 (gnus-fetch-field "from")))
9178 (list (cons 'to-address
9179 (funcall gnus-decode-encoded-address-function
9181 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9182 (insert-buffer-substring gnus-original-article-buffer)
9183 ;; Remove lines that may lead nndoc to misinterpret the
9186 (goto-char (point-min))
9187 (or (search-forward "\n\n" nil t) (point)))
9188 (goto-char (point-min))
9189 (delete-matching-lines "^Path:\\|^From ")
9192 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
9193 (gnus-newsgroup-ephemeral-ignored-charsets
9194 gnus-newsgroup-ignored-charsets))
9195 (gnus-group-read-ephemeral-group
9196 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9198 ,(if force 'mbox 'guess)))
9200 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9202 ;; Make all postings to this group go to the parent group.
9203 (nconc (gnus-info-params (gnus-get-info name))
9205 ;; Couldn't select this doc group.
9206 (switch-to-buffer buf)
9207 (gnus-set-global-variables)
9208 (gnus-configure-windows 'summary)
9209 (gnus-message 3 "Article couldn't be entered?"))
9210 (kill-buffer dig)))))
9212 (defun gnus-summary-read-document (n)
9213 "Open a new group based on the current article(s).
9214 This will allow you to read digests and other similar
9215 documents as newsgroups.
9216 Obeys the standard process/prefix convention."
9218 (let* ((ogroup gnus-newsgroup-name)
9219 (params (append (gnus-info-params (gnus-get-info ogroup))
9220 (list (cons 'to-group ogroup))))
9221 group egroup groups vgroup)
9222 (dolist (article (gnus-summary-work-articles n))
9223 (setq group (format "%s-%d" gnus-newsgroup-name article))
9224 (gnus-summary-remove-process-mark article)
9225 (when (gnus-summary-display-article article)
9226 (save-excursion ;;What for?
9228 (insert-buffer-substring gnus-original-article-buffer)
9229 ;; Remove some headers that may lead nndoc to make
9231 (message-narrow-to-head)
9232 (goto-char (point-min))
9233 (delete-matching-lines "^Path:\\|^From ")
9236 (gnus-group-read-ephemeral-group
9237 group `(nndoc ,group (nndoc-address ,(current-buffer))
9238 (nndoc-article-type guess))
9241 ;; Make all postings to this group go to the parent group.
9242 (nconc (gnus-info-params (gnus-get-info egroup))
9244 (push egroup groups))
9245 ;; Couldn't select this doc group.
9246 (gnus-error 3 "Article couldn't be entered"))))))
9247 ;; Now we have selected all the documents.
9250 (error "None of the articles could be interpreted as documents"))
9251 ((gnus-group-read-ephemeral-group
9252 (setq vgroup (format
9253 "nnvirtual:%s-%s" gnus-newsgroup-name
9254 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9255 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9257 (cons (current-buffer) 'summary)))
9259 (error "Couldn't select virtual nndoc group")))))
9261 (defun gnus-summary-widget-forward (arg)
9262 "Move point to the next field or button in the article.
9263 With optional ARG, move across that many fields."
9265 (gnus-summary-select-article)
9266 (gnus-configure-windows 'article)
9267 (select-window (gnus-get-buffer-window gnus-article-buffer))
9268 (widget-forward arg))
9270 (defun gnus-summary-widget-backward (arg)
9271 "Move point to the previous field or button in the article.
9272 With optional ARG, move across that many fields."
9274 (gnus-summary-select-article)
9275 (gnus-configure-windows 'article)
9276 (select-window (gnus-get-buffer-window gnus-article-buffer))
9277 (unless (widget-at (point))
9278 (goto-char (point-max)))
9279 (widget-backward arg))
9281 (defun gnus-summary-isearch-article (&optional regexp-p)
9282 "Do incremental search forward on the current article.
9283 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9285 (gnus-summary-select-article)
9286 (gnus-configure-windows 'article)
9287 (gnus-eval-in-buffer-window gnus-article-buffer
9290 (isearch-forward regexp-p))))
9292 (defun gnus-summary-repeat-search-article-forward ()
9293 "Repeat the previous search forwards."
9295 (unless gnus-last-search-regexp
9296 (error "No previous search"))
9297 (gnus-summary-search-article-forward gnus-last-search-regexp))
9299 (defun gnus-summary-repeat-search-article-backward ()
9300 "Repeat the previous search backwards."
9302 (unless gnus-last-search-regexp
9303 (error "No previous search"))
9304 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9306 (defun gnus-summary-search-article-forward (regexp &optional backward)
9307 "Search for an article containing REGEXP forward.
9308 If BACKWARD, search backward instead."
9311 (format "Search article %s (regexp%s): "
9312 (if current-prefix-arg "backward" "forward")
9313 (if gnus-last-search-regexp
9314 (concat ", default " gnus-last-search-regexp)
9316 current-prefix-arg))
9317 (if (string-equal regexp "")
9318 (setq regexp (or gnus-last-search-regexp ""))
9319 (setq gnus-last-search-regexp regexp)
9320 (setq gnus-article-before-search gnus-current-article))
9321 ;; Intentionally set gnus-last-article.
9322 (setq gnus-last-article gnus-article-before-search)
9323 (let ((gnus-last-article gnus-last-article))
9324 (if (gnus-summary-search-article regexp backward)
9325 (gnus-summary-show-thread)
9326 (signal 'search-failed (list regexp)))))
9328 (defun gnus-summary-search-article-backward (regexp)
9329 "Search for an article containing REGEXP backward."
9332 (format "Search article backward (regexp%s): "
9333 (if gnus-last-search-regexp
9334 (concat ", default " gnus-last-search-regexp)
9336 (gnus-summary-search-article-forward regexp 'backward))
9338 (defun gnus-summary-search-article (regexp &optional backward)
9339 "Search for an article containing REGEXP.
9340 Optional argument BACKWARD means do search for backward.
9341 `gnus-select-article-hook' is not called during the search."
9342 ;; We have to require this here to make sure that the following
9343 ;; dynamic binding isn't shadowed by autoloading.
9344 (require 'gnus-async)
9346 (let ((gnus-select-article-hook nil) ;Disable hook.
9347 (gnus-article-prepare-hook nil)
9348 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9349 (gnus-use-article-prefetch nil)
9350 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9351 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9353 (gnus-keep-backlog nil)
9354 (gnus-break-pages nil)
9355 (gnus-summary-display-arrow nil)
9356 (gnus-updated-mode-lines nil)
9357 (gnus-auto-center-summary nil)
9358 (sum (current-buffer))
9359 (gnus-display-mime-function nil)
9362 (gnus-save-hidden-threads
9363 (gnus-summary-select-article)
9364 (set-buffer gnus-article-buffer)
9365 (goto-char (window-point (get-buffer-window (current-buffer))))
9369 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9371 (re-search-backward regexp nil t)
9372 (re-search-forward regexp nil t))
9373 ;; We found the regexp.
9378 (get-buffer-window (current-buffer))
9382 (get-buffer-window (current-buffer))
9385 (setq point (point)))
9386 ;; We didn't find it, so we go to the next article.
9389 (while (eq found 'not)
9390 (if (not (if backward (gnus-summary-find-prev)
9391 (gnus-summary-find-next)))
9392 ;; No more articles.
9394 ;; Select the next article and adjust point.
9395 (unless (gnus-summary-article-sparse-p
9396 (gnus-summary-article-number))
9398 (gnus-summary-select-article)
9399 (set-buffer gnus-article-buffer)
9401 (goto-char (if backward (point-max) (point-min))))))))
9402 (gnus-message 7 ""))
9403 ;; Return whether we found the regexp.
9404 (when (eq found 'found)
9406 (gnus-summary-show-thread)
9407 (gnus-summary-goto-subject gnus-current-article)
9408 (gnus-summary-position-point)
9411 (defun gnus-find-matching-articles (header regexp)
9412 "Return a list of all articles that match REGEXP on HEADER.
9413 This search includes all articles in the current group that Gnus has
9414 fetched headers for, whether they are displayed or not."
9415 (let ((articles nil)
9416 ;; Can't eta-reduce because it's a macro.
9417 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9418 (case-fold-search t))
9419 (dolist (header gnus-newsgroup-headers)
9420 (when (string-match regexp (funcall func header))
9421 (push (mail-header-number header) articles)))
9422 (nreverse articles)))
9424 (defun gnus-summary-find-matching (header regexp &optional backward unread
9425 not-case-fold not-matching)
9426 "Return a list of all articles that match REGEXP on HEADER.
9427 The search stars on the current article and goes forwards unless
9428 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9429 If UNREAD is non-nil, only unread articles will
9430 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9431 in the comparisons. If NOT-MATCHING, return a list of all articles that
9432 not match REGEXP on HEADER."
9433 (let ((case-fold-search (not not-case-fold))
9436 (if (eq (car header) 'extra)
9439 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9441 (error "%s is an invalid header" header))
9442 (unless (fboundp (intern (concat "mail-header-" header)))
9443 (error "%s is not a valid header" header))
9444 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9445 (dolist (d (if (eq backward 'all)
9447 (gnus-data-find-list
9448 (gnus-summary-article-number)
9449 (gnus-data-list backward))))
9450 (when (and (or (not unread) ; We want all articles...
9451 (gnus-data-unread-p d)) ; Or just unreads.
9452 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9456 (funcall func (gnus-data-header d))))
9457 (string-match regexp
9458 (funcall func (gnus-data-header d)))))
9459 (push (gnus-data-number d) articles))) ; Success!
9460 (nreverse articles)))
9462 (defun gnus-summary-execute-command (header regexp command &optional backward)
9463 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9464 If HEADER is an empty string (or nil), the match is done on the entire
9465 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9467 (list (let ((completion-ignore-case t))
9468 (gnus-completing-read
9470 (mapcar 'symbol-name
9472 '(Number Subject From Lines Date
9473 Message-ID Xref References Body)
9474 gnus-extra-headers))
9476 (read-string "Regexp: ")
9477 (read-key-sequence "Command: ")
9478 current-prefix-arg))
9479 (when (equal header "Body")
9481 ;; Hidden thread subtrees must be searched as well.
9482 (gnus-summary-show-all-threads)
9483 ;; We don't want to change current point nor window configuration.
9485 (save-window-excursion
9487 gnus-treat-strip-trailing-blank-lines
9488 gnus-treat-strip-leading-blank-lines
9489 gnus-treat-strip-multiple-blank-lines
9490 gnus-treat-hide-boring-headers
9491 gnus-treat-fold-newsgroups
9492 gnus-article-prepare-hook)
9493 (gnus-message 6 "Executing %s..." (key-description command))
9494 ;; We'd like to execute COMMAND interactively so as to give arguments.
9495 (gnus-execute header regexp
9496 `(call-interactively ',(key-binding command))
9498 (gnus-message 6 "Executing %s...done" (key-description command))))))
9500 (defun gnus-summary-beginning-of-article ()
9501 "Scroll the article back to the beginning."
9503 (gnus-summary-select-article)
9504 (gnus-configure-windows 'article)
9505 (gnus-eval-in-buffer-window gnus-article-buffer
9507 (goto-char (point-min))
9508 (when gnus-break-pages
9509 (gnus-narrow-to-page))))
9511 (defun gnus-summary-end-of-article ()
9512 "Scroll to the end of the article."
9514 (gnus-summary-select-article)
9515 (gnus-configure-windows 'article)
9516 (gnus-eval-in-buffer-window gnus-article-buffer
9518 (goto-char (point-max))
9520 (when gnus-break-pages
9521 (gnus-narrow-to-page))))
9523 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9524 "Truncate to LEN and quote all \"(\"'s in STRING."
9525 (gnus-replace-in-string (if (and len (> (length string) len))
9526 (substring string 0 len)
9530 (defun gnus-summary-print-article (&optional filename n)
9531 "Generate and print a PostScript image of the process-marked (mail) articles.
9533 If used interactively, print the current article if none are
9534 process-marked. With prefix arg, prompt the user for the name of the
9537 When used from Lisp, accept two optional args FILENAME and N. N means
9538 to print the next N articles. If N is negative, print the N previous
9539 articles. If N is nil and articles have been marked with the process
9540 mark, print these instead.
9542 If the optional first argument FILENAME is nil, send the image to the
9543 printer. If FILENAME is a string, save the PostScript image in a file with
9544 that name. If FILENAME is a number, prompt the user for the name of the file
9546 (interactive (list (ps-print-preprint current-prefix-arg)))
9547 (dolist (article (gnus-summary-work-articles n))
9548 (gnus-summary-select-article nil nil 'pseudo article)
9549 (gnus-eval-in-buffer-window gnus-article-buffer
9550 (gnus-print-buffer))
9551 (gnus-summary-remove-process-mark article))
9552 (ps-despool filename))
9554 (defun gnus-print-buffer ()
9555 (let ((ps-left-header
9558 (gnus-summary-print-truncate-and-quote
9559 (mail-header-subject gnus-current-headers)
9562 (gnus-summary-print-truncate-and-quote
9563 (mail-header-from gnus-current-headers)
9567 "/pagenumberstring load"
9569 (mail-header-date gnus-current-headers) ")"))))
9570 (gnus-run-hooks 'gnus-ps-print-hook)
9572 (if ps-print-color-p
9573 (ps-spool-buffer-with-faces)
9574 (ps-spool-buffer)))))
9576 (defun gnus-summary-show-complete-article ()
9577 "Show a complete version of the current article.
9578 This is only useful if you're looking at a partial version of the
9581 (let ((gnus-keep-backlog nil)
9582 (gnus-use-cache nil)
9585 (format "%s-fetch-partial-articles"
9586 (car (gnus-find-method-for-group
9587 gnus-newsgroup-name)))
9592 (setq old-val (symbol-value variable))
9594 (gnus-flush-original-article-buffer)
9595 (gnus-summary-show-article))
9596 (set variable old-val))))
9598 (defun gnus-summary-show-article (&optional arg)
9599 "Force redisplaying of the current article.
9600 If ARG (the prefix) is a number, show the article with the charset
9601 defined in `gnus-summary-show-article-charset-alist', or the charset
9603 If ARG (the prefix) is non-nil and not a number, show the article,
9604 but without running any of the article treatment functions
9605 article. Normally, the keystroke is `C-u g'. When using `C-u
9606 C-u g', show the raw article."
9610 (gnus-summary-show-article t)
9611 (let ((gnus-newsgroup-charset
9612 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9613 (mm-read-coding-system
9614 "View as charset: " ;; actually it is coding system.
9615 (with-current-buffer gnus-article-buffer
9616 (mm-detect-coding-region (point) (point-max))))))
9617 (gnus-newsgroup-ignored-charsets 'gnus-all))
9618 (gnus-summary-select-article nil 'force)
9619 (let ((deps gnus-newsgroup-dependencies)
9621 (with-current-buffer gnus-original-article-buffer
9623 (message-narrow-to-head)
9624 (setq head (buffer-string))
9625 (goto-char (point-min))
9626 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9627 (goto-char (point-max))
9629 (setq lines (1- (count-lines (point) (point-max))))))
9631 (insert (format "211 %d Article retrieved.\n"
9632 (cdr gnus-article-current)))
9634 (if lines (insert (format "Lines: %d\n" lines)))
9636 (let ((nntp-server-buffer (current-buffer)))
9637 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9638 (gnus-data-set-header
9639 (gnus-data-find (cdr gnus-article-current))
9641 (gnus-summary-update-article-line
9642 (cdr gnus-article-current) header)
9643 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9644 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9646 ;; Select the article the normal way.
9647 (if (eq mm-text-html-renderer 'shr)
9650 (let ((shr-ignore-cache t))
9651 (gnus-summary-select-article nil 'force)))
9652 (gnus-summary-select-article nil 'force)))
9655 (let ((gnus-inhibit-article-treatments t))
9656 (gnus-summary-select-article nil 'force)))
9658 ;; We have to require this here to make sure that the following
9659 ;; dynamic binding isn't shadowed by autoloading.
9660 (require 'gnus-async)
9662 ;; Bind the article treatment functions to nil.
9663 (let ((gnus-have-all-headers t)
9664 gnus-article-prepare-hook
9665 gnus-article-decode-hook
9666 gnus-display-mime-function
9668 ;; Destroy any MIME parts.
9669 (when (gnus-buffer-live-p gnus-article-buffer)
9670 (with-current-buffer gnus-article-buffer
9671 (gnus-article-stop-animations)
9672 (gnus-stop-downloads)
9673 (mm-destroy-parts gnus-article-mime-handles)
9674 ;; Set it to nil for safety reason.
9675 (setq gnus-article-mime-handle-alist nil)
9676 (setq gnus-article-mime-handles nil)))
9677 (gnus-summary-select-article nil 'force))))
9678 (gnus-summary-goto-subject gnus-current-article)
9679 (gnus-summary-position-point))
9681 (defun gnus-summary-show-raw-article ()
9682 "Show the raw article without any article massaging functions being run."
9684 (gnus-summary-show-article t))
9686 (defun gnus-summary-verbose-headers (&optional arg)
9687 "Toggle permanent full header display.
9688 If ARG is a positive number, turn header display on.
9689 If ARG is a negative number, turn header display off."
9691 (setq gnus-show-all-headers
9692 (cond ((or (not (numberp arg))
9694 (not gnus-show-all-headers))
9697 (gnus-summary-show-article))
9699 (defun gnus-summary-toggle-header (&optional arg)
9700 "Show the headers if they are hidden, or hide them if they are shown.
9701 If ARG is a positive number, show the entire header.
9702 If ARG is a negative number, hide the unwanted header lines."
9704 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9705 (get-buffer-window gnus-article-buffer t))))
9706 (with-current-buffer gnus-article-buffer
9708 (article-narrow-to-head)
9709 (let* ((inhibit-read-only t)
9710 (inhibit-point-motion-hooks t)
9711 (hidden (if (numberp arg)
9713 (or (not (looking-at "[^ \t\n]+:"))
9714 (gnus-article-hidden-text-p 'headers))))
9716 (delete-region (point-min) (point-max))
9717 (with-current-buffer gnus-original-article-buffer
9718 (goto-char (setq s (point-min)))
9719 (setq e (if (search-forward "\n\n" nil t)
9722 (insert-buffer-substring gnus-original-article-buffer s e)
9723 (run-hooks 'gnus-article-decode-hook)
9725 (let ((gnus-treat-hide-headers nil)
9726 (gnus-treat-hide-boring-headers nil))
9727 (gnus-delete-wash-type 'headers)
9728 (gnus-treat-article 'head))
9729 (gnus-treat-article 'head))
9732 (set-window-start window (goto-char (point-min))))
9733 (if gnus-break-pages
9734 (gnus-narrow-to-page)
9735 (when (gnus-visual-p 'page-marker)
9736 (let ((inhibit-read-only t))
9737 (gnus-remove-text-with-property 'gnus-prev)
9738 (gnus-remove-text-with-property 'gnus-next))))
9739 (gnus-set-mode-line 'article)))))
9741 (defun gnus-summary-show-all-headers ()
9742 "Make all header lines visible."
9744 (gnus-summary-toggle-header 1))
9746 (defun gnus-summary-caesar-message (&optional arg)
9747 "Caesar rotate the current article by 13.
9748 With a non-numerical prefix, also rotate headers. A numerical
9749 prefix specifies how many places to rotate each letter forward."
9751 (gnus-summary-select-article)
9752 (let ((mail-header-separator ""))
9753 (gnus-eval-in-buffer-window gnus-article-buffer
9756 (let ((start (window-start))
9757 (inhibit-read-only t))
9758 (if (equal arg '(4))
9759 (message-caesar-buffer-body nil t)
9760 (message-caesar-buffer-body arg))
9761 (set-window-start (get-buffer-window (current-buffer)) start)))))
9762 ;; Create buttons and stuff...
9763 (gnus-treat-article nil))
9765 (declare-function idna-to-unicode "ext:idna" (str))
9767 (defun gnus-summary-idna-message (&optional arg)
9768 "Decode IDNA encoded domain names in the current articles.
9769 IDNA encoded domain names looks like `xn--bar'. If a string
9770 remain unencoded after running this function, it is likely an
9771 invalid IDNA string (`xn--bar' is invalid).
9773 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9774 installed for this command to work."
9776 (if (not (and (condition-case nil (require 'idna)
9778 (mm-coding-system-p 'utf-8)
9779 (executable-find (symbol-value 'idna-program))))
9781 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9782 (gnus-summary-select-article)
9783 (let ((mail-header-separator ""))
9784 (gnus-eval-in-buffer-window gnus-article-buffer
9787 (let ((start (window-start))
9789 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9790 (replace-match (idna-to-unicode (match-string 1))))
9791 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9793 (defun gnus-summary-morse-message (&optional arg)
9794 "Morse decode the current article."
9796 (gnus-summary-select-article)
9797 (let ((mail-header-separator ""))
9798 (gnus-eval-in-buffer-window gnus-article-buffer
9802 (let ((pos (window-start))
9803 (inhibit-read-only t))
9804 (goto-char (point-min))
9805 (when (message-goto-body)
9806 (gnus-narrow-to-body))
9807 (goto-char (point-min))
9808 (while (search-forward "·" (point-max) t)
9809 (replace-match "."))
9810 (unmorse-region (point-min) (point-max))
9812 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9814 (defun gnus-summary-stop-page-breaking ()
9815 "Stop page breaking in the current article."
9817 (gnus-summary-select-article)
9818 (gnus-eval-in-buffer-window gnus-article-buffer
9820 (when (gnus-visual-p 'page-marker)
9821 (let ((inhibit-read-only t))
9822 (gnus-remove-text-with-property 'gnus-prev)
9823 (gnus-remove-text-with-property 'gnus-next))
9824 (setq gnus-page-broken nil))))
9826 (defun gnus-summary-move-article (&optional n to-newsgroup
9827 select-method action)
9828 "Move the current article to a different newsgroup.
9829 If N is a positive number, move the N next articles.
9830 If N is a negative number, move the N previous articles.
9831 If N is nil and any articles have been marked with the process mark,
9832 move those articles instead.
9833 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9834 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9835 re-spool using this method.
9837 When called interactively with TO-NEWSGROUP being nil, the value of
9838 the variable `gnus-move-split-methods' is used for finding a default
9839 for the target newsgroup.
9841 For this function to work, both the current newsgroup and the
9842 newsgroup that you want to move to have to support the `request-move'
9843 and `request-accept' functions.
9845 ACTION can be either `move' (the default), `crosspost' or `copy'."
9848 (setq action 'move))
9849 ;; Check whether the source group supports the required functions.
9850 (cond ((and (eq action 'move)
9851 (not (gnus-check-backend-function
9852 'request-move-article gnus-newsgroup-name)))
9853 (error "The current group does not support article moving"))
9854 ((and (eq action 'crosspost)
9855 (not (gnus-check-backend-function
9856 'request-replace-article gnus-newsgroup-name)))
9857 (error "The current group does not support article editing")))
9858 (let ((articles (gnus-summary-work-articles n))
9859 (prefix (if (gnus-check-backend-function
9860 'request-move-article gnus-newsgroup-name)
9861 (funcall gnus-move-group-prefix-function
9862 gnus-newsgroup-name)
9864 (names '((move "Move" "Moving")
9865 (copy "Copy" "Copying")
9866 (crosspost "Crosspost" "Crossposting")))
9867 (copy-buf (save-excursion
9868 (nnheader-set-temp-buffer " *copy article*")))
9869 art-group to-method new-xref article to-groups
9870 articles-to-update-marks encoded)
9871 (unless (assq action names)
9872 (error "Unknown action %s" action))
9873 ;; Read the newsgroup name.
9874 (when (and (not to-newsgroup)
9875 (not select-method))
9876 (if (and gnus-move-split-methods
9878 (and (memq gnus-current-article articles)
9879 (gnus-buffer-live-p gnus-original-article-buffer))))
9880 ;; When `gnus-move-split-methods' is non-nil, we have to
9881 ;; select an article to give `gnus-read-move-group-name' an
9882 ;; opportunity to suggest an appropriate default. However,
9883 ;; we needn't render or mark the article.
9884 (let ((gnus-display-mime-function nil)
9885 (gnus-article-prepare-hook nil)
9886 (gnus-mark-article-hook nil))
9887 (gnus-summary-select-article nil nil nil (car articles))))
9888 (setq to-newsgroup (gnus-read-move-group-name
9889 (cadr (assq action names))
9891 (intern (format "gnus-current-%s-group" action)))
9893 encoded to-newsgroup
9894 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9895 (set (intern (format "gnus-current-%s-group" action))
9896 (mm-decode-coding-string
9898 (gnus-group-name-charset to-method to-newsgroup))))
9900 (setq to-method (or select-method
9901 (gnus-server-to-method
9902 (gnus-group-method to-newsgroup)))))
9906 (mm-encode-coding-string
9908 (gnus-group-name-charset to-method to-newsgroup)))))
9909 ;; Check the method we are to move this article to...
9910 (unless (gnus-check-backend-function
9911 'request-accept-article (car to-method))
9912 (error "%s does not support article copying" (car to-method)))
9913 (unless (gnus-check-server to-method)
9914 (error "Can't open server %s" (car to-method)))
9915 (gnus-message 6 "%s to %s: %s..."
9916 (caddr (assq action names))
9917 (or (car select-method)
9918 (gnus-group-decoded-name to-newsgroup))
9921 (setq article (pop articles))
9922 ;; Set any marks that may have changed in the summary buffer.
9923 (when gnus-preserve-marks
9924 (gnus-summary-push-marks-to-backend article))
9928 ;; Move the article.
9930 ;; Remove this article from future suppression.
9931 (gnus-dup-unsuppress-article article)
9932 (let* ((from-method (gnus-find-method-for-group
9933 gnus-newsgroup-name))
9934 (to-method (or select-method
9935 (gnus-find-method-for-group to-newsgroup)))
9936 (move-is-internal (gnus-server-equal from-method to-method)))
9937 (gnus-request-move-article
9938 article ; Article to move
9939 gnus-newsgroup-name ; From newsgroup
9940 (nth 1 (gnus-find-method-for-group
9941 gnus-newsgroup-name)) ; Server
9942 (list 'gnus-request-accept-article
9943 to-newsgroup (list 'quote select-method)
9944 (not articles) t) ; Accept form
9945 (not articles) ; Only save nov last time
9946 (and move-is-internal
9947 to-newsgroup ; Not respooling
9948 ; Is this move internal?
9949 (gnus-group-real-name to-newsgroup)))))
9950 ;; Copy the article.
9952 (with-current-buffer copy-buf
9953 (when (gnus-request-article-this-buffer article
9954 gnus-newsgroup-name)
9956 (nnheader-narrow-to-headers)
9957 (dolist (hdr gnus-copy-article-ignored-headers)
9958 (message-remove-header hdr t)))
9959 (gnus-request-accept-article
9960 to-newsgroup select-method (not articles) t))))
9961 ;; Crosspost the article.
9962 ((eq action 'crosspost)
9963 (let ((xref (message-tokenize-header
9964 (mail-header-xref (gnus-summary-article-header
9967 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9968 ":" (number-to-string article)))
9970 (setq xref (list (system-name))))
9973 (mapconcat 'identity
9974 (delete "Xref:" (delete new-xref xref))
9977 (with-current-buffer copy-buf
9978 ;; First put the article in the destination group.
9979 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9980 (when (consp (setq art-group
9981 (gnus-request-accept-article
9982 to-newsgroup select-method (not articles)
9984 (setq new-xref (concat new-xref " " (car art-group)
9986 (number-to-string (cdr art-group))))
9987 ;; Now we have the new Xrefs header, so we insert
9988 ;; it and replace the new article.
9989 (nnheader-replace-header "Xref" new-xref)
9990 (gnus-request-replace-article
9991 (cdr art-group) to-newsgroup (current-buffer) t)
9995 (gnus-message 1 "Couldn't %s article %s: %s"
9996 (cadr (assq action names)) article
9997 (nnheader-get-report (car to-method))))
9998 ((eq art-group 'junk)
9999 (when (eq action 'move)
10000 (gnus-summary-mark-article article gnus-canceled-mark)
10001 (gnus-message 4 "Deleted article %s" article)
10002 ;; run the delete hook
10003 (run-hook-with-args 'gnus-summary-article-delete-hook
10006 (assoc article (gnus-data-list nil)))
10007 gnus-newsgroup-name nil
10010 (let* ((pto-group (gnus-group-prefixed-name
10011 (car art-group) to-method))
10012 (info (gnus-get-info pto-group))
10013 (to-group (gnus-info-group info))
10015 ;; Update the group that has been moved to.
10017 (memq action '(move copy)))
10018 (unless (member to-group to-groups)
10019 (push to-group to-groups))
10021 (when (and (not (memq article gnus-newsgroup-unreads))
10023 (push 'read to-marks)
10024 (gnus-info-set-read
10025 info (gnus-add-to-range (gnus-info-read info)
10026 (list (cdr art-group)))))
10028 ;; See whether the article is to be put in the cache.
10029 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10030 (marks (if expirable
10031 gnus-article-mark-lists
10032 (delete '(expirable . expire)
10034 gnus-article-mark-lists))))
10035 (to-article (cdr art-group)))
10037 ;; Enter the article into the cache in the new group,
10038 ;; if that is required.
10039 (when (and to-article
10041 (gnus-cache-possibly-enter-article
10042 to-group to-article
10043 (memq article gnus-newsgroup-marked)
10044 (memq article gnus-newsgroup-dormant)
10045 (memq article gnus-newsgroup-unreads)))
10047 (when (and gnus-preserve-marks
10049 ;; Copy any marks over to the new group.
10050 (when (and (equal to-group gnus-newsgroup-name)
10051 (not (memq article gnus-newsgroup-unreads)))
10052 ;; Mark this article as read in this group.
10053 (push (cons to-article gnus-read-mark)
10054 gnus-newsgroup-reads)
10055 ;; Increase the active status of this group.
10056 (setcdr (gnus-active to-group) to-article)
10057 (setcdr gnus-newsgroup-active to-article))
10060 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10061 (when (memq article (symbol-value
10062 (intern (format "gnus-newsgroup-%s"
10064 (push (cdar marks) to-marks)
10065 ;; If the other group is the same as this group,
10066 ;; then we have to add the mark to the list.
10067 (when (equal to-group gnus-newsgroup-name)
10068 (set (intern (format "gnus-newsgroup-%s"
10072 (intern (format "gnus-newsgroup-%s"
10074 ;; Copy the marks to other group.
10075 (gnus-add-marked-articles
10076 to-group (cdar marks) (list to-article) info)))
10077 (setq marks (cdr marks)))
10079 (when (and expirable
10080 gnus-mark-copied-or-moved-articles-as-expirable
10081 (not (memq 'expire to-marks)))
10082 ;; Mark this article as expirable.
10083 (push 'expire to-marks)
10084 (when (equal to-group gnus-newsgroup-name)
10085 (push to-article gnus-newsgroup-expirable))
10086 ;; Copy the expirable mark to other group.
10087 (gnus-add-marked-articles
10088 to-group 'expire (list to-article) info))
10090 (when (and to-marks
10091 (gnus-method-option-p
10092 (gnus-find-method-for-group to-group)
10094 (gnus-request-set-mark
10095 to-group (list (list (list to-article) 'add to-marks)))))
10097 (gnus-dribble-enter
10098 (concat "(gnus-group-set-info '"
10099 (gnus-prin1-to-string (gnus-get-info to-group))
10101 (concat "^(gnus-group-set-info '(\""
10102 (regexp-quote to-group) "\""))))
10104 ;; Update the Xref header in this article to point to
10105 ;; the new crossposted article we have just created.
10106 (when (eq action 'crosspost)
10107 (with-current-buffer copy-buf
10108 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10109 (nnheader-replace-header "Xref" new-xref)
10110 (gnus-request-replace-article
10111 article gnus-newsgroup-name (current-buffer) t)))
10113 ;; run the move/copy/crosspost/respool hook
10114 (run-hook-with-args 'gnus-summary-article-move-hook
10117 (assoc article (gnus-data-list nil)))
10118 gnus-newsgroup-name
10122 ;;;!!!Why is this necessary?
10123 (set-buffer gnus-summary-buffer)
10125 (when (eq action 'move)
10127 (gnus-summary-goto-subject article)
10128 (gnus-summary-mark-article article gnus-canceled-mark)))))
10129 (push article articles-to-update-marks))
10132 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10133 ;; Re-activate all groups that have been moved to.
10134 (with-current-buffer gnus-group-buffer
10135 (let ((gnus-group-marked to-groups))
10136 (gnus-group-get-new-news-this-group nil t)))
10138 (gnus-kill-buffer copy-buf)
10139 (gnus-summary-position-point)
10140 (gnus-set-mode-line 'summary)))
10142 (defun gnus-summary-push-marks-to-backend (article)
10144 (marks gnus-article-mark-lists))
10145 (unless (memq article gnus-newsgroup-unreads)
10148 (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10149 (memq article (symbol-value
10150 (intern (format "gnus-newsgroup-%s"
10152 (push (cdar marks) set))
10154 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)))))
10156 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10157 "Copy the current article to some other group.
10158 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10159 When called interactively, if TO-NEWSGROUP is nil, use the value of
10160 the variable `gnus-move-split-methods' for finding a default target
10162 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10163 re-spool using this method."
10165 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10167 (defun gnus-summary-crosspost-article (&optional n)
10168 "Crosspost the current article to some other group."
10170 (gnus-summary-move-article n nil nil 'crosspost))
10172 (defcustom gnus-summary-respool-default-method nil
10173 "Default method type for respooling an article.
10174 If nil, use to the current newsgroup method."
10176 :group 'gnus-summary-mail)
10178 (defun gnus-summary-respool-article (&optional n method)
10179 "Respool the current article.
10180 The article will be squeezed through the mail spooling process again,
10181 which means that it will be put in some mail newsgroup or other
10182 depending on `nnmail-split-methods'.
10183 If N is a positive number, respool the N next articles.
10184 If N is a negative number, respool the N previous articles.
10185 If N is nil and any articles have been marked with the process mark,
10186 respool those articles instead.
10188 Respooling can be done both from mail groups and \"real\" newsgroups.
10189 In the former case, the articles in question will be moved from the
10190 current group into whatever groups they are destined to. In the
10191 latter case, they will be copied into the relevant groups."
10193 (list current-prefix-arg
10194 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10196 (symbol-name (or gnus-summary-respool-default-method
10197 (car (gnus-find-method-for-group
10198 gnus-newsgroup-name)))))
10200 (gnus-completing-read
10201 "Backend to use when respooling"
10202 methods t nil 'gnus-mail-method-history methname))
10205 ((zerop (length (setq ms (gnus-servers-using-backend
10206 (intern method)))))
10207 (list (intern method) ""))
10211 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10212 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10215 (error "No method given for respooling"))
10216 (if (assoc (symbol-name
10217 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10218 (gnus-methods-using 'respool))
10219 (gnus-summary-move-article n nil method)
10220 (gnus-summary-copy-article n nil method)))
10222 (defun gnus-summary-import-article (file &optional edit)
10223 "Import an arbitrary file into a mail newsgroup."
10224 (interactive "fImport file: \nP")
10225 (let ((group gnus-newsgroup-name)
10226 (now (current-time))
10227 atts lines group-art)
10228 (unless (gnus-check-backend-function 'request-accept-article group)
10229 (error "%s does not support article importing" group))
10230 (or (file-readable-p file)
10231 (not (file-regular-p file))
10232 (error "Can't read %s" file))
10233 (with-current-buffer (gnus-get-buffer-create " *import file*")
10235 (nnheader-insert-file-contents file)
10236 (goto-char (point-min))
10237 (if (nnheader-article-p)
10239 (goto-char (point-min))
10240 (search-forward "\n\n" nil t)
10241 (narrow-to-region (point-min) (1- (point)))
10242 (goto-char (point-min))
10243 (unless (re-search-forward "^date:" nil t)
10244 (goto-char (point-max))
10245 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10246 ;; This doesn't look like an article, so we fudge some headers.
10247 (setq atts (file-attributes file)
10248 lines (count-lines (point-min) (point-max)))
10249 (insert "From: " (read-string "From: ") "\n"
10250 "Subject: " (read-string "Subject: ") "\n"
10251 "Date: " (message-make-date (nth 5 atts)) "\n"
10252 "Message-ID: " (message-make-message-id) "\n"
10253 "Lines: " (int-to-string lines) "\n"
10254 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10255 (setq group-art (gnus-request-accept-article group nil t))
10256 (kill-buffer (current-buffer)))
10257 (setq gnus-newsgroup-active (gnus-activate-group group))
10259 (gnus-summary-goto-article (cdr group-art) nil t)
10261 (gnus-summary-edit-article))))
10263 (defun gnus-summary-create-article ()
10264 "Create an article in a mail newsgroup."
10266 (let ((group gnus-newsgroup-name)
10267 (now (current-time))
10269 (unless (gnus-check-backend-function 'request-accept-article group)
10270 (error "%s does not support article importing" group))
10271 (with-current-buffer (gnus-get-buffer-create " *import file*")
10273 (goto-char (point-min))
10274 ;; This doesn't look like an article, so we fudge some headers.
10275 (insert "From: " (read-string "From: ") "\n"
10276 "Subject: " (read-string "Subject: ") "\n"
10277 "Date: " (message-make-date now) "\n"
10278 "Message-ID: " (message-make-message-id) "\n")
10279 (setq group-art (gnus-request-accept-article group nil t))
10280 (kill-buffer (current-buffer)))
10281 (setq gnus-newsgroup-active (gnus-activate-group group))
10283 (gnus-summary-goto-article (cdr group-art) nil t)
10284 (gnus-summary-edit-article)))
10286 (defun gnus-summary-article-posted-p ()
10287 "Say whether the current (mail) article is available from news as well.
10288 This will be the case if the article has both been mailed and posted."
10290 (let ((id (mail-header-references (gnus-summary-article-header)))
10291 (gnus-override-method (car (gnus-refer-article-methods))))
10292 (if (gnus-request-head id "")
10293 (gnus-message 2 "The current message was found on %s"
10294 gnus-override-method)
10295 (gnus-message 2 "The current message couldn't be found on %s"
10296 gnus-override-method)
10299 (defun gnus-summary-expire-articles (&optional now)
10300 "Expire all articles that are marked as expirable in the current group."
10302 (when (and (not gnus-group-is-exiting-without-update-p)
10303 (gnus-check-backend-function
10304 'request-expire-articles gnus-newsgroup-name))
10305 ;; This backend supports expiry.
10306 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10307 (expirable (if total
10309 ;; We need to update the info for
10310 ;; this group for `gnus-list-of-read-articles'
10311 ;; to give us the right answer.
10312 (gnus-run-hooks 'gnus-exit-group-hook)
10313 (gnus-summary-update-info)
10314 (gnus-list-of-read-articles gnus-newsgroup-name))
10315 (setq gnus-newsgroup-expirable
10316 (sort gnus-newsgroup-expirable '<))))
10317 (expiry-wait (if now 'immediate
10318 (gnus-group-find-parameter
10319 gnus-newsgroup-name 'expiry-wait)))
10320 (nnmail-expiry-target
10321 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10322 nnmail-expiry-target))
10325 ;; There are expirable articles in this group, so we run them
10326 ;; through the expiry process.
10327 (gnus-message 6 "Expiring articles...")
10328 (when (gnus-check-group gnus-newsgroup-name)
10329 ;; The list of articles that weren't expired is returned.
10332 (let ((nnmail-expiry-wait-function nil)
10333 (nnmail-expiry-wait expiry-wait))
10334 (setq es (gnus-request-expire-articles
10335 expirable gnus-newsgroup-name)))
10336 (setq es (gnus-request-expire-articles
10337 expirable gnus-newsgroup-name)))
10339 (setq gnus-newsgroup-expirable es))
10340 ;; We go through the old list of expirable, and mark all
10341 ;; really expired articles as nonexistent.
10342 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10343 (let ((gnus-use-cache nil))
10344 (dolist (article expirable)
10345 (when (and (not (memq article es))
10346 (gnus-data-find article))
10347 (gnus-summary-mark-article article gnus-canceled-mark)
10348 (run-hook-with-args 'gnus-summary-article-expire-hook
10351 (assoc article (gnus-data-list nil)))
10352 gnus-newsgroup-name
10355 (gnus-message 6 "Expiring articles...done")))))
10357 (defun gnus-summary-expire-articles-now ()
10358 "Expunge all expirable articles in the current group.
10359 This means that *all* articles that are marked as expirable will be
10360 deleted forever, right now."
10362 (or gnus-expert-user
10364 "Are you really, really sure you want to delete all expirable messages? ")
10366 (gnus-summary-expire-articles t))
10368 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10369 (defun gnus-summary-delete-article (&optional n)
10370 "Delete the N next (mail) articles.
10371 This command actually deletes articles. This is not a marking
10372 command. The article will disappear forever from your life, never to
10375 If N is negative, delete backwards.
10376 If N is nil and articles have been marked with the process mark,
10377 delete these instead.
10379 If `gnus-novice-user' is non-nil you will be asked for
10380 confirmation before the articles are deleted."
10382 (unless (gnus-check-backend-function 'request-expire-articles
10383 gnus-newsgroup-name)
10384 (error "The current newsgroup does not support article deletion"))
10385 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10386 (error "Couldn't open server"))
10387 ;; Compute the list of articles to delete.
10388 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10389 (nnmail-expiry-target 'delete)
10391 (if (and gnus-novice-user
10392 (not (gnus-yes-or-no-p
10393 (format "Do you really want to delete %s forever? "
10394 (if (> (length articles) 1)
10395 (format "these %s articles" (length articles))
10396 "this article")))))
10398 ;; Delete the articles.
10399 (setq not-deleted (gnus-request-expire-articles
10400 articles gnus-newsgroup-name 'force))
10403 (gnus-summary-remove-process-mark (car articles))
10404 ;; The backend might not have been able to delete the article
10406 (unless (memq (car articles) not-deleted)
10407 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10408 (let* ((article (car articles))
10409 (ghead (gnus-data-header
10410 (assoc article (gnus-data-list nil)))))
10411 (run-hook-with-args 'gnus-summary-article-delete-hook
10412 'delete ghead gnus-newsgroup-name nil
10414 (setq articles (cdr articles))))
10416 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10417 (gnus-summary-position-point)
10418 (gnus-set-mode-line 'summary)
10421 (defun gnus-summary-edit-article (&optional arg)
10422 "Edit the current article.
10423 This will have permanent effect only in mail groups.
10424 If ARG is nil, edit the decoded articles.
10425 If ARG is 1, edit the raw articles.
10426 If ARG is 2, edit the raw articles even in read-only groups.
10427 If ARG is 3, edit the articles with the current handles.
10428 Otherwise, allow editing of articles even in read-only
10431 (let (force raw current-handles)
10440 (setq current-handles
10441 (and (gnus-buffer-live-p gnus-article-buffer)
10442 (with-current-buffer gnus-article-buffer
10444 gnus-article-mime-handles
10445 (setq gnus-article-mime-handles nil))))))
10448 (when (and raw (not force)
10449 (member gnus-newsgroup-name '("nndraft:delayed"
10452 (error "Can't edit the raw article in group %s"
10453 gnus-newsgroup-name))
10454 (with-current-buffer gnus-summary-buffer
10455 (let ((mail-parse-charset gnus-newsgroup-charset)
10456 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10457 (gnus-set-global-variables)
10458 (when (and (not force)
10459 (gnus-group-read-only-p))
10460 (error "The current newsgroup does not support article editing"))
10461 (gnus-summary-show-article t)
10462 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10463 (with-current-buffer gnus-article-buffer
10464 (mm-enable-multibyte)))
10465 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10467 (gnus-article-edit-article
10470 (let ((mbl mml-buffer-list))
10471 (setq mml-buffer-list nil)
10472 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10473 (mime-to-mml ,'current-handles))
10474 (let ((mbl1 mml-buffer-list))
10475 (setq mml-buffer-list mbl)
10476 (set (make-local-variable 'mml-buffer-list) mbl1))
10477 (gnus-make-local-hook 'kill-buffer-hook)
10478 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10479 `(lambda (no-highlight)
10480 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10481 (message-options message-options)
10482 (message-options-set-recipient)
10483 (mail-parse-ignored-charsets
10484 ',gnus-newsgroup-ignored-charsets)
10485 (rfc2047-header-encoding-alist
10486 ',(let ((charset (gnus-group-name-charset
10487 (gnus-find-method-for-group
10488 gnus-newsgroup-name)
10489 gnus-newsgroup-name)))
10490 (append (list (cons "Newsgroups" charset)
10491 (cons "Followup-To" charset)
10492 (cons "Xref" charset))
10493 rfc2047-header-encoding-alist))))
10494 ,(if (not raw) '(progn
10496 (mml-destroy-buffers)
10497 (remove-hook 'kill-buffer-hook
10498 'mml-destroy-buffers t)
10499 (kill-local-variable 'mml-buffer-list)))
10500 (gnus-summary-edit-article-done
10501 ,(or (mail-header-references gnus-current-headers) "")
10502 ,(gnus-group-read-only-p)
10503 ,gnus-summary-buffer no-highlight))))))))
10505 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10507 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10509 "Make edits to the current article permanent."
10512 ;; The buffer restriction contains the entire article if it exists.
10513 (when (article-goto-body)
10514 (let ((lines (count-lines (point) (point-max)))
10515 (length (- (point-max) (point)))
10516 (case-fold-search t)
10517 (body (copy-marker (point))))
10518 (goto-char (point-min))
10519 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10520 (delete-region (match-beginning 1) (match-end 1))
10521 (insert (number-to-string length)))
10522 (goto-char (point-min))
10523 (when (re-search-forward
10524 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10525 (delete-region (match-beginning 1) (match-end 1))
10526 (insert (number-to-string length)))
10527 (goto-char (point-min))
10528 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10529 (delete-region (match-beginning 1) (match-end 1))
10530 (insert (number-to-string lines))))))
10531 ;; Replace the article.
10532 (let ((buf (current-buffer))
10533 (article (cdr gnus-article-current))
10536 (insert-buffer-substring buf)
10537 (if (and (not read-only)
10538 (not (setq replace-result
10539 (gnus-request-replace-article
10540 article (car gnus-article-current)
10541 (current-buffer) t))))
10542 (error "Couldn't replace article")
10543 ;; If we got a number back, then that's the new article number
10544 ;; for this article. Otherwise, the article number didn't change.
10545 (when (numberp replace-result)
10546 (with-current-buffer gnus-summary-buffer
10547 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10548 (gnus-summary-limit gnus-newsgroup-limit)
10549 (setq article replace-result)
10550 (gnus-summary-goto-subject article t)))
10551 ;; Update the summary buffer.
10552 (if (and references
10553 (equal (message-tokenize-header references " ")
10554 (message-tokenize-header
10555 (or (message-fetch-field "references") "") " ")))
10556 ;; We only have to update this line.
10559 (message-narrow-to-head)
10560 (let ((head (buffer-substring-no-properties
10561 (point-min) (point-max)))
10564 (insert (format "211 %d Article retrieved.\n" article))
10567 (let ((nntp-server-buffer (current-buffer)))
10568 (setq header (car (gnus-get-newsgroup-headers nil t))))
10569 (with-current-buffer gnus-summary-buffer
10570 (gnus-data-set-header (gnus-data-find article) header)
10571 (gnus-summary-update-article-line article header)
10572 (if (gnus-summary-goto-subject article nil t)
10573 (gnus-summary-update-secondary-mark article)))))))
10575 (set-buffer (or buffer gnus-summary-buffer))
10576 (gnus-summary-update-article article)
10577 (if (gnus-summary-goto-subject article nil t)
10578 (gnus-summary-update-secondary-mark article)))
10579 ;; Prettify the article buffer again.
10580 (unless no-highlight
10581 (with-current-buffer gnus-article-buffer
10582 ;;!!! Fix this -- article should be rehighlighted.
10583 ;;(gnus-run-hooks 'gnus-article-display-hook)
10584 (set-buffer gnus-original-article-buffer)
10585 (gnus-request-article
10586 article (car gnus-article-current) (current-buffer))))
10587 ;; Prettify the summary buffer line.
10588 (when (gnus-visual-p 'summary-highlight 'highlight)
10589 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10591 (defun gnus-summary-edit-wash (key)
10592 "Perform editing command KEY in the article buffer."
10596 (message "%s" (concat (this-command-keys) "- "))
10599 (gnus-summary-edit-article)
10600 (execute-kbd-macro (concat (this-command-keys) key))
10601 (gnus-article-edit-done))
10605 (defun gnus-summary-respool-query (&optional silent trace)
10606 "Query where the respool algorithm would put this article."
10608 (let (gnus-mark-article-hook)
10609 (gnus-summary-select-article)
10610 (with-current-buffer gnus-original-article-buffer
10611 (let ((groups (nnmail-article-group 'identity trace)))
10614 (message "This message would go to %s"
10615 (mapconcat 'car groups ", "))
10616 (message "This message would go to no groups"))
10619 (defun gnus-summary-respool-trace ()
10620 "Trace where the respool algorithm would put this article.
10621 Display a buffer showing all fancy splitting patterns which matched."
10623 (gnus-summary-respool-query nil t))
10625 ;; Summary marking commands.
10627 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10628 "Mark articles which has the same subject as read, and then select the next.
10629 If UNMARK is positive, remove any kind of mark.
10630 If UNMARK is negative, tick articles."
10633 (setq unmark (prefix-numeric-value unmark)))
10635 (gnus-summary-mark-same-subject
10636 (gnus-summary-article-subject) unmark)))
10637 ;; Select next unread article. If auto-select-same mode, should
10638 ;; select the first unread article.
10639 (gnus-summary-next-article t (and gnus-auto-select-same
10640 (gnus-summary-article-subject)))
10641 (gnus-message 7 "%d article%s marked as %s"
10642 count (if (= count 1) " is" "s are")
10643 (if unmark "unread" "read"))))
10645 (defun gnus-summary-kill-same-subject (&optional unmark)
10646 "Mark articles which has the same subject as read.
10647 If UNMARK is positive, remove any kind of mark.
10648 If UNMARK is negative, tick articles."
10651 (setq unmark (prefix-numeric-value unmark)))
10653 (gnus-summary-mark-same-subject
10654 (gnus-summary-article-subject) unmark)))
10655 ;; If marked as read, go to next unread subject.
10656 (when (null unmark)
10657 ;; Go to next unread subject.
10658 (gnus-summary-next-subject 1 t))
10659 (gnus-message 7 "%d articles are marked as %s"
10660 count (if unmark "unread" "read"))))
10662 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10663 "Mark articles with same SUBJECT as read, and return marked number.
10664 If optional argument UNMARK is positive, remove any kinds of marks.
10665 If optional argument UNMARK is negative, mark articles as unread instead."
10669 ((null unmark) ; Mark as read.
10672 (gnus-summary-mark-article-as-read gnus-killed-mark)
10673 (gnus-summary-show-thread) t)
10674 (gnus-summary-find-subject subject))
10675 (setq count (1+ count))))
10676 ((> unmark 0) ; Tick.
10679 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10680 (gnus-summary-show-thread) t)
10681 (gnus-summary-find-subject subject))
10682 (setq count (1+ count))))
10683 (t ; Mark as unread.
10686 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10687 (gnus-summary-show-thread) t)
10688 (gnus-summary-find-subject subject))
10689 (setq count (1+ count)))))
10690 (gnus-set-mode-line 'summary)
10691 ;; Return the number of marked articles.
10694 (defun gnus-summary-mark-as-processable (n &optional unmark)
10695 "Set the process mark on the next N articles.
10696 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10697 the process mark instead. The difference between N and the actual
10698 number of articles marked is returned."
10700 (if (and (null n) (gnus-region-active-p))
10701 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10702 (setq n (prefix-numeric-value n))
10703 (let ((backward (< n 0))
10708 (gnus-summary-remove-process-mark
10709 (gnus-summary-article-number))
10710 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10711 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10714 (gnus-message 7 "No more articles"))
10715 (gnus-summary-recenter)
10716 (gnus-summary-position-point)
10719 (defun gnus-summary-unmark-as-processable (n)
10720 "Remove the process mark from the next N articles.
10721 If N is negative, unmark backward instead. The difference between N and
10722 the actual number of articles unmarked is returned."
10724 (gnus-summary-mark-as-processable n t))
10726 (defun gnus-summary-unmark-all-processable ()
10727 "Remove the process mark from all articles."
10730 (while gnus-newsgroup-processable
10731 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10732 (gnus-summary-position-point))
10734 (defun gnus-summary-add-mark (article type)
10735 "Mark ARTICLE with a mark of TYPE."
10736 (let ((vtype (car (assq type gnus-article-mark-lists)))
10739 (error "No such mark type: %s" type)
10740 (setq var (intern (format "gnus-newsgroup-%s" type)))
10741 (set var (cons article (symbol-value var)))
10742 (if (memq type '(processable cached replied forwarded recent saved))
10743 (gnus-summary-update-secondary-mark article)
10744 ;;; !!! This is bogus. We should find out what primary
10745 ;;; !!! mark we want to set.
10746 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10748 (defun gnus-summary-mark-as-expirable (n)
10749 "Mark N articles forward as expirable.
10750 If N is negative, mark backward instead. The difference between N and
10751 the actual number of articles marked is returned."
10753 (gnus-summary-mark-forward n gnus-expirable-mark))
10755 (defun gnus-summary-mark-as-spam (n)
10756 "Mark N articles forward as spam.
10757 If N is negative, mark backward instead. The difference between N and
10758 the actual number of articles marked is returned."
10760 (gnus-summary-mark-forward n gnus-spam-mark))
10762 (defun gnus-summary-mark-article-as-replied (article)
10763 "Mark ARTICLE as replied to and update the summary line.
10764 ARTICLE can also be a list of articles."
10765 (interactive (list (gnus-summary-article-number)))
10766 (let ((articles (if (listp article) article (list article))))
10767 (dolist (article articles)
10768 (unless (numberp article)
10769 (error "%s is not a number" article))
10770 (push article gnus-newsgroup-replied)
10771 (let ((inhibit-read-only t))
10772 (when (gnus-summary-goto-subject article nil t)
10773 (gnus-summary-update-secondary-mark article))))))
10775 (defun gnus-summary-mark-article-as-forwarded (article)
10776 "Mark ARTICLE as forwarded and update the summary line.
10777 ARTICLE can also be a list of articles."
10778 (let ((articles (if (listp article) article (list article))))
10779 (dolist (article articles)
10780 (push article gnus-newsgroup-forwarded)
10781 (let ((inhibit-read-only t))
10782 (when (gnus-summary-goto-subject article nil t)
10783 (gnus-summary-update-secondary-mark article))))))
10785 (defun gnus-summary-set-bookmark (article)
10786 "Set a bookmark in current article."
10787 (interactive (list (gnus-summary-article-number)))
10788 (when (or (not (get-buffer gnus-article-buffer))
10789 (not gnus-current-article)
10790 (not gnus-article-current)
10791 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10792 (error "No current article selected"))
10793 ;; Remove old bookmark, if one exists.
10794 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10795 ;; Set the new bookmark, which is on the form
10796 ;; (article-number . line-number-in-body).
10799 (with-current-buffer gnus-article-buffer
10803 (article-goto-body)
10806 gnus-newsgroup-bookmarks)
10807 (gnus-message 6 "A bookmark has been added to the current article."))
10809 (defun gnus-summary-remove-bookmark (article)
10810 "Remove the bookmark from the current article."
10811 (interactive (list (gnus-summary-article-number)))
10812 ;; Remove old bookmark, if one exists.
10813 (if (not (assq article gnus-newsgroup-bookmarks))
10814 (gnus-message 6 "No bookmark in current article.")
10815 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10816 (gnus-message 6 "Removed bookmark.")))
10818 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10819 (defun gnus-summary-mark-as-dormant (n)
10820 "Mark N articles forward as dormant.
10821 If N is negative, mark backward instead. The difference between N and
10822 the actual number of articles marked is returned."
10824 (gnus-summary-mark-forward n gnus-dormant-mark))
10826 (defun gnus-summary-set-process-mark (article)
10827 "Set the process mark on ARTICLE and update the summary line."
10828 (setq gnus-newsgroup-processable
10830 (delq article gnus-newsgroup-processable)))
10831 (when (gnus-summary-goto-subject article)
10832 (gnus-summary-show-thread)
10833 (gnus-summary-goto-subject article)
10834 (gnus-summary-update-secondary-mark article)))
10836 (defun gnus-summary-remove-process-mark (&rest articles)
10837 "Remove the process mark from ARTICLES and update the summary line."
10838 (dolist (article articles)
10839 (setq gnus-newsgroup-processable (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)))
10846 (defun gnus-summary-set-saved-mark (article)
10847 "Set the process mark on ARTICLE and update the summary line."
10848 (push article gnus-newsgroup-saved)
10849 (when (gnus-summary-goto-subject article)
10850 (gnus-summary-update-secondary-mark article)))
10852 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10853 "Mark N articles as read forwards.
10854 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10855 The difference between N and the actual number of articles marked is
10857 If NO-EXPIRE, auto-expiry will be inhibited."
10859 (gnus-summary-show-thread)
10860 (let ((backward (< n 0))
10861 (gnus-summary-goto-unread
10862 (and gnus-summary-goto-unread
10863 (not (eq gnus-summary-goto-unread 'never))
10864 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10865 gnus-ticked-mark gnus-dormant-mark)))))
10867 (mark (or mark gnus-del-mark)))
10868 (while (and (> n 0)
10869 (gnus-summary-mark-article nil mark no-expire)
10870 (zerop (gnus-summary-next-subject
10872 (and gnus-summary-goto-unread
10873 (not (eq gnus-summary-goto-unread 'never)))
10877 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10878 (gnus-summary-recenter)
10879 (gnus-summary-position-point)
10880 (gnus-set-mode-line 'summary)
10883 (defun gnus-summary-mark-article-as-read (mark)
10884 "Mark the current article quickly as read with MARK."
10885 (let ((article (gnus-summary-article-number)))
10886 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10887 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10888 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10889 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10890 (push (cons article mark) gnus-newsgroup-reads)
10891 ;; Possibly remove from cache, if that is used.
10892 (when gnus-use-cache
10893 (gnus-cache-enter-remove-article article))
10894 ;; Allow the backend to change the mark.
10895 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10896 ;; Check for auto-expiry.
10897 (when (and gnus-newsgroup-auto-expire
10898 (memq mark gnus-auto-expirable-marks))
10899 (setq mark gnus-expirable-mark)
10900 ;; Let the backend know about the mark change.
10901 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10902 (push article gnus-newsgroup-expirable))
10903 ;; Set the mark in the buffer.
10904 (gnus-summary-update-mark mark 'unread)
10907 (defun gnus-summary-mark-article-as-unread (mark)
10908 "Mark the current article quickly as unread with MARK."
10909 (let* ((article (gnus-summary-article-number))
10910 (old-mark (gnus-summary-article-mark article)))
10911 ;; Allow the backend to change the mark.
10912 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10913 (if (eq mark old-mark)
10917 (gnus-error 1 "Can't mark negative article numbers")
10919 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10920 (setq gnus-newsgroup-spam-marked
10921 (delq article gnus-newsgroup-spam-marked))
10922 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10923 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10924 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10925 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10926 (cond ((= mark gnus-ticked-mark)
10927 (setq gnus-newsgroup-marked
10928 (gnus-add-to-sorted-list gnus-newsgroup-marked
10930 ((= mark gnus-spam-mark)
10931 (setq gnus-newsgroup-spam-marked
10932 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10934 ((= mark gnus-dormant-mark)
10935 (setq gnus-newsgroup-dormant
10936 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10939 (setq gnus-newsgroup-unreads
10940 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10942 (gnus-alist-pull article gnus-newsgroup-reads)
10944 ;; See whether the article is to be put in the cache.
10945 (and gnus-use-cache
10946 (vectorp (gnus-summary-article-header article))
10948 (gnus-cache-possibly-enter-article
10949 gnus-newsgroup-name article
10950 (= mark gnus-ticked-mark)
10951 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10954 (gnus-summary-update-mark mark 'unread)
10957 (defun gnus-summary-mark-article (&optional article mark no-expire)
10958 "Mark ARTICLE with MARK. MARK can be any character.
10959 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10960 `??' (dormant) and `?E' (expirable).
10961 If MARK is nil, then the default character `?r' is used.
10962 If ARTICLE is nil, then the article on the current line will be
10964 If NO-EXPIRE, auto-expiry will be inhibited."
10965 ;; The mark might be a string.
10966 (when (stringp mark)
10967 (setq mark (aref mark 0)))
10968 ;; If no mark is given, then we check auto-expiring.
10970 (setq mark gnus-del-mark))
10971 (when (and (not no-expire)
10972 gnus-newsgroup-auto-expire
10973 (memq mark gnus-auto-expirable-marks))
10974 (setq mark gnus-expirable-mark))
10975 (let ((article (or article (gnus-summary-article-number)))
10976 (old-mark (gnus-summary-article-mark article)))
10977 ;; Allow the backend to change the mark.
10978 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10979 (if (eq mark old-mark)
10982 (error "No article on current line"))
10983 (if (not (if (or (= mark gnus-unread-mark)
10984 (= mark gnus-ticked-mark)
10985 (= mark gnus-spam-mark)
10986 (= mark gnus-dormant-mark))
10987 (gnus-mark-article-as-unread article mark)
10988 (gnus-mark-article-as-read article mark)))
10990 ;; See whether the article is to be put in the cache.
10991 (and gnus-use-cache
10992 (not (= mark gnus-canceled-mark))
10993 (vectorp (gnus-summary-article-header article))
10995 (gnus-cache-possibly-enter-article
10996 gnus-newsgroup-name article
10997 (= mark gnus-ticked-mark)
10998 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11000 (when (gnus-summary-goto-subject article nil t)
11001 (let ((inhibit-read-only t))
11002 (gnus-summary-show-thread)
11004 (gnus-summary-update-mark mark 'unread)
11007 (defun gnus-summary-update-secondary-mark (article)
11008 "Update the secondary (read, process, cache) mark."
11009 (gnus-summary-update-mark
11010 (cond ((memq article gnus-newsgroup-processable)
11012 ((memq article gnus-newsgroup-cached)
11014 ((memq article gnus-newsgroup-replied)
11016 ((memq article gnus-newsgroup-forwarded)
11017 gnus-forwarded-mark)
11018 ((memq article gnus-newsgroup-saved)
11020 ((memq article gnus-newsgroup-unseen)
11024 (when (gnus-visual-p 'summary-highlight 'highlight)
11025 (gnus-summary-highlight-line)
11026 (gnus-run-hooks 'gnus-summary-update-hook))
11029 (defun gnus-summary-update-download-mark (article)
11030 "Update the download mark."
11031 (gnus-summary-update-mark
11032 (cond ((memq article gnus-newsgroup-undownloaded)
11033 gnus-undownloaded-mark)
11034 (gnus-newsgroup-agentized
11035 gnus-downloaded-mark)
11039 (gnus-summary-update-line t)
11042 (defun gnus-summary-update-mark (mark type)
11043 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11044 (inhibit-read-only t))
11045 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11047 (when (looking-at "\r")
11049 (when (<= (+ forward (point)) (point-max))
11050 ;; Go to the right position on the line.
11051 (goto-char (+ forward (point)))
11052 ;; Replace the old mark with the new mark.
11054 (mm-subst-char-in-string
11056 (buffer-substring (point) (1+ (point))))))
11057 (delete-region (point) (1+ (point)))
11058 (insert to-insert))
11059 ;; Optionally update the marks by some user rule.
11060 (when (eq type 'unread)
11061 (gnus-data-set-mark
11062 (gnus-data-find (gnus-summary-article-number)) mark)
11063 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11065 (defun gnus-mark-article-as-read (article &optional mark)
11066 "Enter ARTICLE in the pertinent lists and remove it from others."
11067 ;; Make the article expirable.
11068 (let ((mark (or mark gnus-del-mark)))
11069 (setq gnus-newsgroup-expirable
11070 (if (= mark gnus-expirable-mark)
11071 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11072 (delq article gnus-newsgroup-expirable)))
11073 ;; Remove from unread and marked lists.
11074 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11075 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11076 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11077 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11078 (push (cons article mark) gnus-newsgroup-reads)
11079 ;; Possibly remove from cache, if that is used.
11080 (when gnus-use-cache
11081 (gnus-cache-enter-remove-article article))
11084 (defun gnus-mark-article-as-unread (article &optional mark)
11085 "Enter ARTICLE in the pertinent lists and remove it from others."
11086 (let ((mark (or mark gnus-ticked-mark)))
11089 (gnus-error 1 "Can't mark negative article numbers")
11091 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11092 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11093 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11094 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11095 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11097 ;; Unsuppress duplicates?
11098 (when gnus-suppress-duplicates
11099 (gnus-dup-unsuppress-article article))
11101 (cond ((= mark gnus-ticked-mark)
11102 (setq gnus-newsgroup-marked
11103 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11104 ((= mark gnus-spam-mark)
11105 (setq gnus-newsgroup-spam-marked
11106 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11108 ((= mark gnus-dormant-mark)
11109 (setq gnus-newsgroup-dormant
11110 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11112 (setq gnus-newsgroup-unreads
11113 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11114 (gnus-alist-pull article gnus-newsgroup-reads)
11117 (defun gnus-summary-tick-article-forward (n)
11118 "Tick N articles forwards.
11119 If N is negative, tick backwards instead.
11120 The difference between N and the number of articles ticked is returned."
11122 (gnus-summary-mark-forward n gnus-ticked-mark))
11124 (defun gnus-summary-tick-article-backward (n)
11125 "Tick N articles backwards.
11126 The difference between N and the number of articles ticked is returned."
11128 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11130 (defun gnus-summary-tick-article (&optional article clear-mark)
11131 "Mark current article as unread.
11132 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11133 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11135 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11136 gnus-ticked-mark)))
11138 (defun gnus-summary-mark-as-read-forward (n)
11139 "Mark N articles as read forwards.
11140 If N is negative, mark backwards instead.
11141 The difference between N and the actual number of articles marked is
11144 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11146 (defun gnus-summary-mark-as-read-backward (n)
11147 "Mark the N articles as read backwards.
11148 The difference between N and the actual number of articles marked is
11151 (gnus-summary-mark-forward
11152 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11154 (defun gnus-summary-mark-as-read (&optional article mark)
11155 "Mark current article as read.
11156 ARTICLE specifies the article to be marked as read.
11157 MARK specifies a string to be inserted at the beginning of the line."
11158 (gnus-summary-mark-article article mark))
11160 (defun gnus-summary-clear-mark-forward (n)
11161 "Clear marks from N articles forward.
11162 If N is negative, clear backward instead.
11163 The difference between N and the number of marks cleared is returned."
11165 (gnus-summary-mark-forward n gnus-unread-mark))
11167 (defun gnus-summary-clear-mark-backward (n)
11168 "Clear marks from N articles backward.
11169 The difference between N and the number of marks cleared is returned."
11171 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11173 (defun gnus-summary-mark-unread-as-read ()
11174 "Intended to be used by `gnus-mark-article-hook'."
11175 (when (memq gnus-current-article gnus-newsgroup-unreads)
11176 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11178 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11179 "Intended to be used by `gnus-mark-article-hook'."
11180 (let ((mark (gnus-summary-article-mark)))
11181 (when (or (gnus-unread-mark-p mark)
11182 (gnus-read-mark-p mark))
11183 (gnus-summary-mark-article gnus-current-article
11184 (or new-mark gnus-read-mark)))))
11186 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11187 "Intended to be used by `gnus-mark-article-hook'."
11188 (let ((mark (gnus-summary-article-mark)))
11189 (when (or (gnus-unread-mark-p mark)
11190 (gnus-read-mark-p mark))
11191 (gnus-summary-mark-article (gnus-summary-article-number)
11192 (or new-mark gnus-read-mark)))))
11194 (defun gnus-summary-mark-unread-as-ticked ()
11195 "Intended to be used by `gnus-mark-article-hook'."
11196 (when (memq gnus-current-article gnus-newsgroup-unreads)
11197 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11199 (defun gnus-summary-mark-region-as-read (point mark all)
11200 "Mark all unread articles between point and mark as read.
11201 If given a prefix, mark all articles between point and mark as read,
11202 even ticked and dormant ones."
11203 (interactive "r\nP")
11207 (beginning-of-line)
11212 (memq (setq article (gnus-summary-article-number))
11213 gnus-newsgroup-unreads))
11214 (gnus-summary-mark-article article gnus-del-mark))
11216 (gnus-summary-find-next))))))
11218 (defun gnus-summary-mark-below (score mark)
11219 "Mark articles with score less than SCORE with MARK."
11220 (interactive "P\ncMark: ")
11221 (setq score (if score
11222 (prefix-numeric-value score)
11223 (or gnus-summary-default-score 0)))
11224 (with-current-buffer gnus-summary-buffer
11225 (goto-char (point-min))
11228 (and (< (gnus-summary-article-score) score)
11229 (gnus-summary-mark-article nil mark))
11230 (gnus-summary-find-next)))))
11232 (defun gnus-summary-kill-below (&optional score)
11233 "Mark articles with score below SCORE as read."
11235 (gnus-summary-mark-below score gnus-killed-mark))
11237 (defun gnus-summary-clear-above (&optional score)
11238 "Clear all marks from articles with score above SCORE."
11240 (gnus-summary-mark-above score gnus-unread-mark))
11242 (defun gnus-summary-tick-above (&optional score)
11243 "Tick all articles with score above SCORE."
11245 (gnus-summary-mark-above score gnus-ticked-mark))
11247 (defun gnus-summary-mark-above (score mark)
11248 "Mark articles with score over SCORE with MARK."
11249 (interactive "P\ncMark: ")
11250 (setq score (if score
11251 (prefix-numeric-value score)
11252 (or gnus-summary-default-score 0)))
11253 (with-current-buffer gnus-summary-buffer
11254 (goto-char (point-min))
11256 (when (> (gnus-summary-article-score) score)
11257 (gnus-summary-mark-article nil mark))
11259 (gnus-summary-find-next)))))
11261 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11262 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11263 (defun gnus-summary-limit-include-expunged (&optional no-error)
11264 "Display all the hidden articles that were expunged for low scores."
11266 (let ((inhibit-read-only t))
11267 (let ((scored gnus-newsgroup-scored)
11270 (unless (gnus-summary-article-header (caar scored))
11271 (and (setq h (gnus-number-to-header (caar scored)))
11272 (< (cdar scored) gnus-summary-expunge-below)
11274 (setq scored (cdr scored)))
11276 (when (not no-error)
11277 (error "No expunged articles hidden"))
11278 (goto-char (point-min))
11279 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11280 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11281 (dolist (x headers)
11282 (push (mail-header-number x) gnus-newsgroup-limit))
11283 (gnus-summary-prepare-unthreaded (nreverse headers))
11284 (goto-char (point-min))
11285 (gnus-summary-position-point)
11288 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11289 "Mark all unread articles in this newsgroup as read.
11290 If prefix argument ALL is non-nil, ticked and dormant articles will
11291 also be marked as read.
11292 If QUIETLY is non-nil, no questions will be asked.
11294 If TO-HERE is non-nil, it should be a point in the buffer. All
11295 articles before (after, if REVERSE is set) this point will be marked
11298 Note that this function will only catch up the unread article
11299 in the current summary buffer limitation.
11301 The number of articles marked as read is returned."
11306 (not gnus-interactive-catchup) ;Without confirmation?
11310 "Mark absolutely all articles as read? "
11311 "Mark all unread articles as read? ")))
11313 (not gnus-newsgroup-adaptive)
11314 (not gnus-newsgroup-auto-expire)
11315 (not gnus-suppress-duplicates)
11316 (or (not gnus-use-cache)
11317 (eq gnus-use-cache 'passive)))
11320 (setq gnus-newsgroup-marked nil
11321 gnus-newsgroup-spam-marked nil
11322 gnus-newsgroup-dormant nil))
11323 (setq gnus-newsgroup-unreads
11324 (gnus-sorted-nunion
11325 (gnus-sorted-intersection gnus-newsgroup-unreads
11326 gnus-newsgroup-downloadable)
11327 (gnus-sorted-difference gnus-newsgroup-unfetched
11328 gnus-newsgroup-cached))))
11329 ;; We actually mark all articles as canceled, which we
11330 ;; have to do when using auto-expiry or adaptive scoring.
11331 (gnus-summary-show-all-threads)
11332 (if (and to-here reverse)
11334 (goto-char to-here)
11335 (gnus-summary-mark-current-read-and-unread-as-read
11337 (while (gnus-summary-find-next (not all))
11338 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11339 (when (gnus-summary-first-subject (not all))
11341 (if to-here (< (point) to-here) t)
11342 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11343 (gnus-summary-find-next (not all))))))
11344 (gnus-set-mode-line 'summary))
11346 (gnus-summary-position-point)))
11348 (defun gnus-summary-catchup-to-here (&optional all)
11349 "Mark all unticked articles before the current one as read.
11350 If ALL is non-nil, also mark ticked and dormant articles as read."
11353 (gnus-save-hidden-threads
11354 (let ((beg (point)))
11355 ;; We check that there are unread articles.
11356 (when (or all (gnus-summary-find-prev))
11357 (gnus-summary-catchup all t beg)))))
11358 (gnus-summary-position-point))
11360 (defun gnus-summary-catchup-from-here (&optional all)
11361 "Mark all unticked articles after (and including) the current one as read.
11362 If ALL is non-nil, also mark ticked and dormant articles as read."
11365 (gnus-save-hidden-threads
11366 (let ((beg (point)))
11367 ;; We check that there are unread articles.
11368 (when (or all (gnus-summary-find-next))
11369 (gnus-summary-catchup all t beg nil t)))))
11370 (gnus-summary-position-point))
11372 (defun gnus-summary-catchup-all (&optional quietly)
11373 "Mark all articles in this newsgroup as read.
11374 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11375 instead, which marks only unread articles as read."
11377 (gnus-summary-catchup t quietly))
11379 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11380 "Mark all unread articles in this group as read, then exit.
11381 If prefix argument ALL is non-nil, all articles are marked as read.
11382 If QUIETLY is non-nil, no questions will be asked."
11384 (when (gnus-summary-catchup all quietly nil 'fast)
11385 ;; Select next newsgroup or exit.
11386 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11387 (eq gnus-auto-select-next 'quietly))
11388 (gnus-summary-next-group nil)
11389 (gnus-summary-exit))))
11391 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11392 "Mark all articles in this newsgroup as read, and then exit.
11393 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11394 instead, which marks only unread articles as read."
11396 (gnus-summary-catchup-and-exit t quietly))
11398 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11399 "Mark all articles in this group as read and select the next group.
11400 If given a prefix, mark all articles, unread as well as ticked, as
11404 (gnus-summary-catchup all))
11405 (gnus-summary-next-group))
11407 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11408 "Mark all articles in this group as read and select the previous 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 nil nil t))
11420 (defmacro gnus-with-article (article &rest forms)
11421 "Select ARTICLE and perform FORMS in the original article buffer.
11422 Then replace the article with the result."
11424 ;; We don't want the article to be marked as read.
11425 (let (gnus-mark-article-hook)
11426 (gnus-summary-select-article t t nil ,article))
11427 (set-buffer gnus-original-article-buffer)
11429 (if (not (gnus-check-backend-function
11430 'request-replace-article (car gnus-article-current)))
11431 (gnus-message 5 "Read-only group; not replacing")
11432 (unless (gnus-request-replace-article
11433 ,article (car gnus-article-current)
11434 (current-buffer) t)
11435 (error "Couldn't replace article")))
11436 ;; The cache and backlog have to be flushed somewhat.
11437 (when gnus-keep-backlog
11438 (gnus-backlog-remove-article
11439 (car gnus-article-current) (cdr gnus-article-current)))
11440 (when gnus-use-cache
11441 (gnus-cache-update-article
11442 (car gnus-article-current) (cdr gnus-article-current)))))
11444 (put 'gnus-with-article 'lisp-indent-function 1)
11445 (put 'gnus-with-article 'edebug-form-spec '(form body))
11447 ;; Thread-based commands.
11449 (defun gnus-summary-articles-in-thread (&optional article)
11450 "Return a list of all articles in the current thread.
11451 If ARTICLE is non-nil, return all articles in the thread that starts
11452 with that article."
11453 (let* ((article (or article (gnus-summary-article-number)))
11454 (data (gnus-data-find-list article))
11455 (top-level (gnus-data-level (car data)))
11457 (cond ((null gnus-thread-operation-ignore-subject)
11458 (gnus-simplify-subject-re
11459 (mail-header-subject (gnus-data-header (car data)))))
11460 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11461 (gnus-simplify-subject-fuzzy
11462 (mail-header-subject (gnus-data-header (car data)))))
11464 (end-point (save-excursion
11465 (goto-char (gnus-data-pos (car data)))
11466 (if (gnus-summary-go-to-next-thread)
11467 (point) (point-max))))
11470 (< (gnus-data-pos (car data)) end-point))
11471 (when (or (not top-subject)
11472 (string= top-subject
11473 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11474 (gnus-simplify-subject-fuzzy
11475 (mail-header-subject
11476 (gnus-data-header (car data))))
11477 (gnus-simplify-subject-re
11478 (mail-header-subject
11479 (gnus-data-header (car data)))))))
11480 (push (gnus-data-number (car data)) articles))
11481 (unless (and (setq data (cdr data))
11482 (> (gnus-data-level (car data)) top-level))
11484 ;; Return the list of articles.
11485 (nreverse articles)))
11487 (defun gnus-summary-rethread-current ()
11488 "Rethread the thread the current article is part of."
11490 (let* ((gnus-show-threads t)
11491 (article (gnus-summary-article-number))
11492 (id (mail-header-id (gnus-summary-article-header)))
11493 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11495 (error "No article on the current line"))
11496 (gnus-rebuild-thread id)
11497 (gnus-summary-goto-subject article)))
11499 (defun gnus-summary-reparent-thread ()
11500 "Make the current article child of the marked (or previous) article.
11502 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11503 is non-nil or the Subject: of both articles are the same."
11505 (unless (not (gnus-group-read-only-p))
11506 (error "The current newsgroup does not support article editing"))
11507 (unless (<= (length gnus-newsgroup-processable) 1)
11508 (error "No more than one article may be marked"))
11509 (let ((child (gnus-summary-article-number))
11510 ;; First grab the marked article, otherwise one line up.
11511 (parent (if (not (null gnus-newsgroup-processable))
11512 (car gnus-newsgroup-processable)
11514 (if (eq (forward-line -1) 0)
11515 (gnus-summary-article-number)
11516 (error "Beginning of summary buffer"))))))
11517 (gnus-summary-reparent-children parent (list child))))
11519 (defun gnus-summary-reparent-children (parent children)
11520 "Make PARENT the parent of CHILDREN.
11521 When called interactively, PARENT is the current article and CHILDREN
11522 are the process-marked articles."
11524 (list (gnus-summary-article-number)
11525 (gnus-summary-work-articles nil)))
11526 (dolist (child children)
11527 (save-window-excursion
11528 (let ((gnus-article-buffer " *reparent*"))
11529 (unless (not (eq parent child))
11530 (error "An article may not be self-referential"))
11531 (let ((message-id (mail-header-id
11532 (gnus-summary-article-header parent))))
11533 (unless (and message-id (not (equal message-id "")))
11534 (error "No message-id in desired parent"))
11535 (gnus-with-article child
11537 (goto-char (point-min))
11538 (message-narrow-to-head)
11539 (if (re-search-forward "^References: " nil t)
11541 (re-search-forward "^[^ \t]" nil t)
11544 (insert " " message-id))
11545 (insert "References: " message-id "\n"))))
11546 (set-buffer gnus-summary-buffer)
11547 (gnus-summary-unmark-all-processable)
11548 (gnus-summary-update-article child)
11549 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11550 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11551 (gnus-summary-rethread-current)
11552 (gnus-message 3 "Article %d is now the child of article %d"
11555 (defun gnus-summary-toggle-threads (&optional arg)
11556 "Toggle showing conversation threads.
11557 If ARG is positive number, turn showing conversation threads on."
11559 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11560 (setq gnus-show-threads
11561 (if (null arg) (not gnus-show-threads)
11562 (> (prefix-numeric-value arg) 0)))
11563 (gnus-summary-prepare)
11564 (gnus-summary-goto-subject current)
11565 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11566 (gnus-summary-position-point)))
11569 (if (fboundp 'remove-overlays)
11570 (defalias 'gnus-remove-overlays 'remove-overlays)
11571 (defun gnus-remove-overlays (beg end name val)
11572 "Clear BEG and END of overlays whose property NAME has value VAL.
11573 For compatibility with XEmacs."
11574 (dolist (ov (gnus-overlays-in beg end))
11575 (when (eq (gnus-overlay-get ov name) val)
11576 (gnus-delete-overlay ov))))))
11578 (defun gnus-summary-show-all-threads ()
11579 "Show all threads."
11581 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11582 (gnus-summary-position-point))
11584 (defsubst gnus-summary--inv (p)
11585 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11587 (defun gnus-summary-show-thread ()
11588 "Show thread subtrees.
11589 Returns nil if no thread was there to be shown."
11591 (let* ((orig (point))
11592 (end (point-at-eol))
11593 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11594 ;; Leave point at bol
11595 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11597 (if (fboundp 'next-single-char-property-change)
11598 ;; Note: XEmacs version of n-s-c-p-c may return nil
11599 (or (next-single-char-property-change end 'invisible)
11604 (eq (get-char-property (point) 'invisible)
11608 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11610 (gnus-summary-position-point)
11613 (defun gnus-summary-maybe-hide-threads ()
11614 "If requested, hide the threads that should be hidden."
11615 (when (and gnus-show-threads
11616 gnus-thread-hide-subtree)
11617 (gnus-summary-hide-all-threads
11618 (if (or (consp gnus-thread-hide-subtree)
11619 (functionp gnus-thread-hide-subtree))
11620 (gnus-make-predicate gnus-thread-hide-subtree)
11623 ;;; Hiding predicates.
11625 (defun gnus-article-unread-p (header)
11626 (memq (mail-header-number header) gnus-newsgroup-unreads))
11628 (defun gnus-article-unseen-p (header)
11629 (memq (mail-header-number header) gnus-newsgroup-unseen))
11631 (defun gnus-map-articles (predicate articles)
11632 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11633 (apply 'gnus-or (mapcar predicate
11634 (mapcar (lambda (number)
11635 (gnus-summary-article-header number))
11638 (defun gnus-summary-hide-all-threads (&optional predicate)
11639 "Hide all thread subtrees.
11640 If PREDICATE is supplied, threads that satisfy this predicate
11641 will not be hidden."
11644 (goto-char (point-min))
11649 (when (zerop (mod count 1000))
11650 (message "Hiding all threads... %d" count))
11651 (when (or (not predicate)
11653 predicate (gnus-summary-article-children)))
11654 (gnus-summary-hide-thread))
11655 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11656 (gnus-summary-position-point))
11658 (defun gnus-summary-hide-thread ()
11659 "Hide thread subtrees.
11660 If PREDICATE is supplied, threads that satisfy this predicate
11661 will not be hidden.
11662 Returns nil if no threads were there to be hidden."
11664 (let ((start (point))
11665 (starteol (line-end-position))
11666 (article (gnus-summary-article-number)))
11668 ;; Go forward until either the buffer ends or the subthread ends.
11669 (when (and (not (eobp))
11670 (or (zerop (gnus-summary-next-thread 1 t))
11671 (goto-char (point-max))))
11672 (if (and (> (point) start)
11673 ;; FIXME: this should actually search for a non-invisible \n.
11674 (search-backward "\n" start t))
11676 (when (> (point) starteol)
11677 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11678 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11679 (gnus-overlay-put ol 'invisible 'gnus-sum)
11680 (gnus-overlay-put ol 'evaporate t)))
11681 (gnus-summary-goto-subject article)
11682 (when (> start (point))
11683 (message "Hiding the thread moved us backwards, aborting!")
11684 (goto-char (point-max))))
11688 (defun gnus-summary-go-to-next-thread (&optional previous)
11689 "Go to the same level (or less) next thread.
11690 If PREVIOUS is non-nil, go to previous thread instead.
11691 Return the article number moved to, or nil if moving was impossible."
11692 (let ((level (gnus-summary-thread-level))
11693 (way (if previous -1 1))
11696 (while (and (not (eobp))
11697 (< level (gnus-summary-thread-level)))
11698 (forward-line way))
11705 (gnus-summary-article-number)
11706 (goto-char beg)))))
11708 (defun gnus-summary-next-thread (n &optional silent)
11709 "Go to the same level next N'th thread.
11710 If N is negative, search backward instead.
11711 Returns the difference between N and the number of skips actually
11714 If SILENT, don't output messages."
11716 (let ((backward (< n 0))
11718 (while (and (> n 0)
11719 (gnus-summary-go-to-next-thread backward))
11722 (gnus-summary-position-point))
11723 (when (and (not silent) (/= 0 n))
11724 (gnus-message 7 "No more threads"))
11727 (defun gnus-summary-prev-thread (n)
11728 "Go to the same level previous N'th thread.
11729 Returns the difference between N and the number of skips actually
11732 (gnus-summary-next-thread (- n)))
11734 (defun gnus-summary-go-down-thread ()
11735 "Go down one level in the current thread."
11736 (let ((children (gnus-summary-article-children)))
11738 (gnus-summary-goto-subject (car children)))))
11740 (defun gnus-summary-go-up-thread ()
11741 "Go up one level in the current thread."
11742 (let ((parent (gnus-summary-article-parent)))
11744 (gnus-summary-goto-subject parent))))
11746 (defun gnus-summary-down-thread (n)
11747 "Go down thread N steps.
11748 If N is negative, go up instead.
11749 Returns the difference between N and how many steps down that were
11754 (while (and (> n 0)
11755 (if up (gnus-summary-go-up-thread)
11756 (gnus-summary-go-down-thread)))
11758 (gnus-summary-position-point)
11760 (gnus-message 7 "Can't go further"))
11763 (defun gnus-summary-up-thread (n)
11764 "Go up thread N steps.
11765 If N is negative, go down instead.
11766 Returns the difference between N and how many steps down that were
11769 (gnus-summary-down-thread (- n)))
11771 (defun gnus-summary-top-thread ()
11772 "Go to the top of the thread."
11774 (while (gnus-summary-go-up-thread))
11775 (gnus-summary-article-number))
11777 (defun gnus-summary-expire-thread ()
11778 "Mark articles under current thread as expired."
11780 (gnus-summary-kill-thread 0))
11782 (defun gnus-summary-kill-thread (&optional unmark)
11783 "Mark articles under current thread as read.
11784 If the prefix argument is positive, remove any kinds of marks.
11785 If the prefix argument is zero, mark thread as expired.
11786 If the prefix argument is negative, tick articles instead."
11789 (setq unmark (prefix-numeric-value unmark)))
11790 (let ((articles (gnus-summary-articles-in-thread))
11791 (hide (or (null unmark) (= unmark 0))))
11793 ;; Expand the thread.
11794 (gnus-summary-show-thread)
11795 ;; Mark all the articles.
11797 (gnus-summary-goto-subject (car articles))
11798 (cond ((null unmark)
11799 (gnus-summary-mark-article-as-read gnus-killed-mark))
11801 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11803 (gnus-summary-mark-article nil gnus-expirable-mark))
11805 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11806 (setq articles (cdr articles))))
11807 ;; Hide killed subtrees when hide is true.
11809 gnus-thread-hide-killed
11810 (gnus-summary-hide-thread))
11811 ;; If hide is t, go to next unread subject.
11813 ;; Go to next unread subject.
11814 (gnus-summary-next-subject 1 t)))
11815 (gnus-set-mode-line 'summary))
11817 ;; Summary sorting commands
11819 (defun gnus-summary-sort-by-number (&optional reverse)
11820 "Sort the summary buffer by article number.
11821 Argument REVERSE means reverse order."
11823 (gnus-summary-sort 'number reverse))
11825 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11826 "Sort the summary buffer by most recent article number.
11827 Argument REVERSE means reverse order."
11829 (gnus-summary-sort 'most-recent-number reverse))
11831 (defun gnus-summary-sort-by-random (&optional reverse)
11832 "Randomize the order in the summary buffer.
11833 Argument REVERSE means to randomize in reverse order."
11835 (gnus-summary-sort 'random reverse))
11837 (defun gnus-summary-sort-by-author (&optional reverse)
11838 "Sort the summary buffer by author name alphabetically.
11839 If `case-fold-search' is non-nil, case of letters is ignored.
11840 Argument REVERSE means reverse order."
11842 (gnus-summary-sort 'author reverse))
11844 (defun gnus-summary-sort-by-recipient (&optional reverse)
11845 "Sort the summary buffer by recipient name alphabetically.
11846 If `case-fold-search' is non-nil, case of letters is ignored.
11847 Argument REVERSE means reverse order."
11849 (gnus-summary-sort 'recipient reverse))
11851 (defun gnus-summary-sort-by-subject (&optional reverse)
11852 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11853 If `case-fold-search' is non-nil, case of letters is ignored.
11854 Argument REVERSE means reverse order."
11856 (gnus-summary-sort 'subject reverse))
11858 (defun gnus-summary-sort-by-date (&optional reverse)
11859 "Sort the summary buffer by date.
11860 Argument REVERSE means reverse order."
11862 (gnus-summary-sort 'date reverse))
11864 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11865 "Sort the summary buffer by most recent date.
11866 Argument REVERSE means reverse order."
11868 (gnus-summary-sort 'most-recent-date reverse))
11870 (defun gnus-summary-sort-by-score (&optional reverse)
11871 "Sort the summary buffer by score.
11872 Argument REVERSE means reverse order."
11874 (gnus-summary-sort 'score reverse))
11876 (defun gnus-summary-sort-by-lines (&optional reverse)
11877 "Sort the summary buffer by the number of lines.
11878 Argument REVERSE means reverse order."
11880 (gnus-summary-sort 'lines reverse))
11882 (defun gnus-summary-sort-by-chars (&optional reverse)
11883 "Sort the summary buffer by article length.
11884 Argument REVERSE means reverse order."
11886 (gnus-summary-sort 'chars reverse))
11888 (defun gnus-summary-sort-by-original (&optional reverse)
11889 "Sort the summary buffer using the default sorting method.
11890 Argument REVERSE means reverse order."
11892 (let* ((inhibit-read-only t)
11893 (gnus-summary-prepare-hook nil))
11894 ;; We do the sorting by regenerating the threads.
11895 (gnus-summary-prepare)
11896 ;; Hide subthreads if needed.
11897 (gnus-summary-maybe-hide-threads)))
11899 (defun gnus-summary-sort (predicate reverse)
11900 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11901 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11902 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11903 (gnus-thread-sort-functions
11908 (gnus-sort-gathered-threads-function
11909 gnus-thread-sort-functions)
11910 (gnus-article-sort-functions
11914 (,article t2 t1))))
11915 (inhibit-read-only t)
11916 (gnus-summary-prepare-hook nil))
11917 ;; We do the sorting by regenerating the threads.
11918 (gnus-summary-prepare)
11919 ;; Hide subthreads if needed.
11920 (gnus-summary-maybe-hide-threads)))
11922 ;; Summary saving commands.
11924 (defun gnus-summary-save-article (&optional n not-saved)
11925 "Save the current article using the default saver function.
11926 If N is a positive number, save the N next articles.
11927 If N is a negative number, save the N previous articles.
11928 If N is nil and any articles have been marked with the process mark,
11929 save those articles instead.
11930 The variable `gnus-default-article-saver' specifies the saver function.
11932 If the optional second argument NOT-SAVED is non-nil, articles saved
11933 will not be marked as saved."
11935 (require 'gnus-art)
11936 (let* ((articles (gnus-summary-work-articles n))
11937 (save-buffer (save-excursion
11938 (nnheader-set-temp-buffer " *Gnus Save*")))
11939 (num (length articles))
11940 ;; Whether to save decoded articles or raw articles.
11941 (decode (when gnus-article-save-coding-system
11942 (get gnus-default-article-saver :decode)))
11943 ;; When saving many articles in a single file, use the other
11944 ;; function to save articles other than the first one.
11945 (saver2 (get gnus-default-article-saver :function))
11946 (gnus-prompt-before-saving (if saver2
11948 gnus-prompt-before-saving))
11949 (gnus-default-article-saver gnus-default-article-saver)
11951 (dolist (article articles)
11952 (setq header (gnus-summary-article-header article))
11953 (if (not (vectorp header))
11954 ;; This is a pseudo-article.
11955 (if (assq 'name header)
11956 (gnus-copy-file (cdr (assq 'name header)))
11957 (gnus-message 1 "Article %d is unsavable" article))
11958 ;; This is a real article.
11959 (save-window-excursion
11960 (gnus-summary-select-article decode decode nil article)
11961 (gnus-summary-goto-subject article))
11962 (with-current-buffer save-buffer
11964 (insert-buffer-substring (if decode
11965 gnus-article-buffer
11966 gnus-original-article-buffer)))
11967 (setq file (gnus-article-save save-buffer file num))
11968 (gnus-summary-remove-process-mark article)
11970 (gnus-summary-set-saved-mark article)))
11972 (setq gnus-default-article-saver saver2
11974 (gnus-kill-buffer save-buffer)
11975 (gnus-summary-position-point)
11976 (gnus-set-mode-line 'summary)
11979 (defun gnus-summary-pipe-output (&optional n sym)
11980 "Pipe the current article to a subprocess.
11981 If N is a positive number, pipe the N next articles.
11982 If N is a negative number, pipe the N previous articles.
11983 If N is nil and any articles have been marked with the process mark,
11984 pipe those articles instead.
11985 The default command to which articles are piped is specified by the
11986 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11987 will be prompted for the command.
11989 The properties `:decode' and `:headers' that are put to the function
11990 symbol `gnus-summary-save-in-pipe' control whether this function
11991 decodes articles and what headers to keep (see the doc string for the
11992 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11993 is neither omitted nor the symbol `r', force including all headers
11994 regardless of the `:headers' property. If it is the symbol `r',
11995 articles that are not decoded and include all headers will be piped
11996 no matter what the properties `:decode' and `:headers' are."
11997 (interactive (gnus-interactive "P\ny"))
11998 (require 'gnus-art)
11999 (let* ((articles (gnus-summary-work-articles n))
12000 (result-buffer "*Shell Command Output*")
12001 (all-headers (not (memq sym '(nil r))))
12002 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12004 (headers (get 'gnus-summary-save-in-pipe :headers))
12006 (unless (numberp (car articles))
12007 (error "No article to pipe"))
12008 (setq command (gnus-read-shell-command
12009 (concat "Shell command on "
12011 (format "these %d articles" (length articles))
12014 gnus-summary-pipe-output-default-command))
12015 (when (string-equal command "")
12016 (error "A command is required"))
12018 (put 'gnus-summary-save-in-pipe :headers nil))
12021 (gnus-summary-goto-subject (pop articles))
12022 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12023 (when (and (get-buffer result-buffer)
12024 (not (zerop (buffer-size (get-buffer result-buffer)))))
12025 (setq result (concat result (with-current-buffer result-buffer
12026 (buffer-string))))))
12027 (put 'gnus-summary-save-in-pipe :headers headers))
12028 (unless (zerop (length result))
12029 (if (with-current-buffer (get-buffer-create result-buffer)
12033 (and (= (count-lines (point-min) (point)) 1)
12036 (<= (current-column)
12037 (window-width (minibuffer-window)))))
12038 (goto-char (point-min))))
12039 (message "%s" (substring result 0 -1))
12041 (gnus-configure-windows 'pipe)))))
12043 (defun gnus-summary-save-article-mail (&optional arg)
12044 "Append the current article to a Unix mail box file.
12045 If N is a positive number, save the N next articles.
12046 If N is a negative number, save the N previous articles.
12047 If N is nil and any articles have been marked with the process mark,
12048 save those articles instead."
12050 (require 'gnus-art)
12051 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12052 (gnus-summary-save-article arg)))
12054 (defun gnus-summary-save-article-rmail (&optional arg)
12055 "Append the current article to an rmail file.
12056 If N is a positive number, save the N next articles.
12057 If N is a negative number, save the N previous articles.
12058 If N is nil and any articles have been marked with the process mark,
12059 save those articles instead."
12061 (require 'gnus-art)
12062 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12063 (gnus-summary-save-article arg)))
12065 (defun gnus-summary-save-article-file (&optional arg)
12066 "Append the current article to a file.
12067 If N is a positive number, save the N next articles.
12068 If N is a negative number, save the N previous articles.
12069 If N is nil and any articles have been marked with the process mark,
12070 save those articles instead."
12072 (require 'gnus-art)
12073 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12074 (gnus-summary-save-article arg)))
12076 (defun gnus-summary-write-article-file (&optional arg)
12077 "Write the current article to a file, deleting the previous file.
12078 If N is a positive number, save the N next articles.
12079 If N is a negative number, save the N previous articles.
12080 If N is nil and any articles have been marked with the process mark,
12081 save those articles instead."
12083 (require 'gnus-art)
12084 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12085 (gnus-summary-save-article arg)))
12087 (defun gnus-summary-save-article-body-file (&optional arg)
12088 "Append the current article body to a file.
12089 If N is a positive number, save the N next articles.
12090 If N is a negative number, save the N previous articles.
12091 If N is nil and any articles have been marked with the process mark,
12092 save those articles instead."
12094 (require 'gnus-art)
12095 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12096 (gnus-summary-save-article arg)))
12098 (defun gnus-summary-write-article-body-file (&optional arg)
12099 "Write the current article body to a file, deleting the previous file.
12100 If N is a positive number, save the N next articles.
12101 If N is a negative number, save the N previous articles.
12102 If N is nil and any articles have been marked with the process mark,
12103 save those articles instead."
12105 (require 'gnus-art)
12106 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12107 (gnus-summary-save-article arg)))
12109 (defun gnus-summary-muttprint (&optional arg)
12110 "Print the current article using Muttprint.
12111 If N is a positive number, save the N next articles.
12112 If N is a negative number, save the N previous articles.
12113 If N is nil and any articles have been marked with the process mark,
12114 save those articles instead."
12116 (require 'gnus-art)
12117 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12118 (gnus-summary-save-article arg t)))
12120 (defun gnus-summary-pipe-message (program)
12121 "Pipe the current article through PROGRAM."
12122 (interactive "sProgram: ")
12123 (gnus-summary-select-article)
12124 (let ((mail-header-separator ""))
12125 (gnus-eval-in-buffer-window gnus-article-buffer
12128 (let ((start (window-start))
12129 (inhibit-read-only t))
12130 (message-pipe-buffer-body program)
12131 (set-window-start (get-buffer-window (current-buffer)) start))))))
12133 (defun gnus-get-split-value (methods)
12134 "Return a value based on the split METHODS."
12135 (let (split-name method result match)
12137 (with-current-buffer gnus-original-article-buffer
12139 (nnheader-narrow-to-headers)
12140 (while (and methods (not split-name))
12141 (goto-char (point-min))
12142 (setq method (pop methods))
12143 (setq match (car method))
12146 ;; Regular expression.
12148 (re-search-forward match nil t)))
12153 (setq result (funcall match gnus-newsgroup-name))))
12158 (setq result (eval match)))))
12159 (setq split-name (cdr method))
12160 (cond ((stringp result)
12161 (push (expand-file-name
12162 result gnus-article-save-directory)
12165 (setq split-name (append result split-name)))))))))
12166 (nreverse split-name)))
12168 (defun gnus-valid-move-group-p (group)
12169 (and (symbolp group)
12171 (symbol-name group)
12172 (symbol-value group)
12173 (gnus-get-function (gnus-find-method-for-group
12174 (symbol-name group)) 'request-accept-article t)))
12176 (defun gnus-read-move-group-name (prompt default articles prefix)
12177 "Read a group name."
12178 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12179 (minibuffer-confirm-incomplete nil) ; XEmacs
12183 (if (> (length articles) 1)
12184 (format "these %d articles" (length articles))
12189 (gnus-group-completing-read
12191 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12192 nil prefix nil default))
12193 ((= 1 (length split-name))
12194 (gnus-group-completing-read
12196 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12197 nil prefix 'gnus-group-history (car split-name)))
12199 (gnus-completing-read
12200 prom (nreverse split-name) nil nil 'gnus-group-history))))
12201 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12204 (if (or (string= to-newsgroup "")
12205 (string= to-newsgroup prefix))
12206 (setq to-newsgroup default))
12207 (unless to-newsgroup
12208 (error "No group name entered"))
12209 (setq encoded (mm-encode-coding-string
12211 (gnus-group-name-charset to-method to-newsgroup)))
12212 (or (gnus-active encoded)
12213 (gnus-activate-group encoded nil nil to-method)
12214 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12216 (or (and (gnus-request-create-group encoded to-method)
12217 (gnus-activate-group encoded nil nil to-method)
12218 (gnus-subscribe-group encoded))
12219 (error "Couldn't create group %s" to-newsgroup)))
12220 (error "No such group: %s" to-newsgroup))
12223 (defvar gnus-summary-save-parts-counter)
12224 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12226 (defun gnus-summary-save-parts (type dir n &optional reverse)
12227 "Save parts matching TYPE to DIR.
12228 If REVERSE, save parts that do not match TYPE."
12230 (list (read-string "Save parts of type: "
12231 (or (car gnus-summary-save-parts-type-history)
12232 gnus-summary-save-parts-default-mime)
12233 'gnus-summary-save-parts-type-history)
12234 (setq gnus-summary-save-parts-last-directory
12235 (read-directory-name "Save to directory: "
12236 gnus-summary-save-parts-last-directory
12238 current-prefix-arg))
12239 (gnus-summary-iterate n
12240 (let ((gnus-display-mime-function nil)
12241 gnus-article-prepare-hook
12242 gnus-article-decode-hook
12243 gnus-display-mime-function
12245 (gnus-inhibit-treatment t))
12246 (gnus-summary-select-article))
12247 (with-current-buffer gnus-article-buffer
12248 (let ((handles (or gnus-article-mime-handles
12249 (mm-dissect-buffer nil gnus-article-loose-mime)
12250 (and gnus-article-emulate-mime
12252 (gnus-summary-save-parts-counter 1))
12254 (gnus-summary-save-parts-1 type dir handles reverse)
12255 (unless gnus-article-mime-handles ;; Don't destroy this case.
12256 (mm-destroy-parts handles)))))))
12258 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12259 (if (stringp (car handle))
12260 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12263 (not (string-match type (mm-handle-media-type handle)))
12264 (string-match type (mm-handle-media-type handle)))
12265 (let ((file (expand-file-name
12267 mm-file-name-rewrite-functions
12268 (file-name-nondirectory
12270 (mm-handle-filename handle)
12271 (format "%s.%d.%d" gnus-newsgroup-name
12272 (cdr gnus-article-current)
12273 gnus-summary-save-parts-counter))))
12275 (incf gnus-summary-save-parts-counter)
12276 (unless (file-exists-p file)
12277 (mm-save-part-to-file handle file))))))
12279 ;; Summary extract commands
12281 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12282 (let ((inhibit-read-only t)
12283 (article (gnus-summary-article-number))
12285 (unless (gnus-summary-goto-subject article)
12286 (error "No such article: %d" article))
12287 (gnus-summary-position-point)
12288 ;; If all commands are to be bunched up on one line, we collect
12290 (unless gnus-view-pseudos-separately
12291 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12294 (setq action (cdr (assq 'action (car ps))))
12295 (setq files (list (cdr (assq 'name (car ps)))))
12296 (while (and ps (cdr ps)
12297 (string= (or action "1")
12298 (or (cdr (assq 'action (cadr ps))) "2")))
12299 (push (cdr (assq 'name (cadr ps))) files)
12300 (setcdr ps (cddr ps)))
12302 (when (not (string-match "%s" action))
12305 (when (assq 'execute (car ps))
12306 (setcdr (assq 'execute (car ps))
12307 (funcall (if (string-match "%s" action)
12314 (shell-quote-argument f)))
12316 (setq ps (cdr ps)))))
12317 (if (and gnus-view-pseudos (not not-view))
12319 (when (assq 'execute (car pslist))
12320 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12321 (eq gnus-view-pseudos 'not-confirm)))
12322 (setq pslist (cdr pslist)))
12325 (setq after-article (or (cdr (assq 'article (car pslist)))
12326 (gnus-summary-article-number)))
12327 (gnus-summary-goto-subject after-article)
12330 (insert " " (file-name-nondirectory
12331 (cdr (assq 'name (car pslist))))
12332 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12334 (forward-line -1) ; back to `b'
12335 (gnus-add-text-properties
12336 b (1- e) (list 'gnus-number gnus-reffed-article-number
12337 gnus-mouse-face-prop gnus-mouse-face))
12339 after-article gnus-reffed-article-number
12340 gnus-unread-mark b (car pslist) 0 (- e b))
12341 (setq gnus-newsgroup-unreads
12342 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12343 gnus-reffed-article-number))
12344 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12345 (setq pslist (cdr pslist)))))))
12347 (defun gnus-pseudos< (p1 p2)
12348 (let ((c1 (cdr (assq 'action p1)))
12349 (c2 (cdr (assq 'action p2))))
12350 (and c1 c2 (string< c1 c2))))
12352 (defun gnus-request-pseudo-article (props)
12353 (cond ((assq 'execute props)
12354 (gnus-execute-command (cdr (assq 'execute props)))))
12355 (let ((gnus-current-article (gnus-summary-article-number)))
12356 (gnus-run-hooks 'gnus-mark-article-hook)))
12358 (defun gnus-execute-command (command &optional automatic)
12360 (gnus-article-setup-buffer)
12361 (set-buffer gnus-article-buffer)
12362 (setq buffer-read-only nil)
12363 (let ((command (if automatic command
12364 (read-string "Command: " (cons command 0)))))
12366 (insert "$ " command "\n\n")
12367 (if gnus-view-pseudo-asynchronously
12368 (start-process "gnus-execute" (current-buffer) shell-file-name
12369 shell-command-switch command)
12370 (call-process shell-file-name nil t nil
12371 shell-command-switch command)))))
12373 ;; Summary kill commands.
12375 (defun gnus-summary-edit-global-kill (article)
12376 "Edit the \"global\" kill file."
12377 (interactive (list (gnus-summary-article-number)))
12378 (gnus-group-edit-global-kill article))
12380 (defun gnus-summary-edit-local-kill ()
12381 "Edit a local kill file applied to the current newsgroup."
12383 (setq gnus-current-headers (gnus-summary-article-header))
12384 (gnus-group-edit-local-kill
12385 (gnus-summary-article-number) gnus-newsgroup-name))
12387 ;;; Header reading.
12389 (defun gnus-read-header (id &optional header)
12390 "Read the headers of article ID and enter them into the Gnus system."
12391 (let ((group gnus-newsgroup-name)
12392 (gnus-override-method
12394 gnus-override-method
12395 (and (gnus-news-group-p gnus-newsgroup-name)
12396 (car (gnus-refer-article-methods)))))
12398 ;; First we check to see whether the header in question is already
12401 ;; This is a Message-ID.
12402 (setq header (or header (gnus-id-to-header id)))
12403 ;; This is an article number.
12404 (setq header (or header (gnus-summary-article-header id))))
12406 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12407 ;; We have found the header.
12409 ;; We have to really fetch the header to this article.
12410 (with-current-buffer nntp-server-buffer
12411 (when (setq where (gnus-request-head id group))
12412 (nnheader-fold-continuation-lines)
12413 (goto-char (point-max))
12415 (goto-char (point-min))
12419 ((cdr where) (cdr where))
12420 (header (mail-header-number header))
12421 (t gnus-reffed-article-number))
12423 (insert " Article retrieved.\n"))
12424 (if (or (not where)
12425 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12426 () ; Malformed head.
12427 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12428 (when (and (stringp id)
12430 (not (string= (gnus-group-real-name group)
12432 (not (gnus-server-equal gnus-override-method
12433 (gnus-group-method group)))))
12434 ;; If we fetched by Message-ID and the article came from
12435 ;; a different group (or server), we fudge some bogus
12436 ;; article numbers for this article.
12437 (mail-header-set-number header gnus-reffed-article-number))
12438 (with-current-buffer gnus-summary-buffer
12439 (decf gnus-reffed-article-number)
12440 (gnus-remove-header (mail-header-number header))
12441 (push header gnus-newsgroup-headers)
12442 (setq gnus-current-headers header)
12443 (push (mail-header-number header) gnus-newsgroup-limit)))
12446 (defun gnus-remove-header (number)
12447 "Remove header NUMBER from `gnus-newsgroup-headers'."
12448 (if (and gnus-newsgroup-headers
12449 (= number (mail-header-number (car gnus-newsgroup-headers))))
12450 (pop gnus-newsgroup-headers)
12451 (let ((headers gnus-newsgroup-headers))
12452 (while (and (cdr headers)
12453 (not (= number (mail-header-number (cadr headers)))))
12455 (when (cdr headers)
12456 (setcdr headers (cddr headers))))))
12459 ;;; summary highlights
12462 (defun gnus-highlight-selected-summary ()
12463 "Highlight selected article in summary buffer."
12464 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12465 (when gnus-summary-selected-face
12467 (let* ((beg (point-at-bol))
12468 (end (point-at-eol))
12469 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12470 (from (if (get-text-property beg gnus-mouse-face-prop)
12472 (or (next-single-property-change
12473 beg gnus-mouse-face-prop nil end)
12478 (or (next-single-property-change
12479 from gnus-mouse-face-prop nil end)
12481 ;; If no mouse-face prop on line we will have to = from = end,
12482 ;; so we highlight the entire line instead.
12483 (when (= (+ to 2) from)
12486 (if gnus-newsgroup-selected-overlay
12487 ;; Move old overlay.
12489 gnus-newsgroup-selected-overlay from to (current-buffer))
12490 ;; Create new overlay.
12492 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12493 'face gnus-summary-selected-face))))))
12495 (defvar gnus-summary-highlight-line-cached nil)
12496 (defvar gnus-summary-highlight-line-trigger nil)
12498 (defun gnus-summary-highlight-line-0 ()
12499 (if (and (eq gnus-summary-highlight-line-trigger
12500 gnus-summary-highlight)
12501 gnus-summary-highlight-line-cached)
12502 gnus-summary-highlight-line-cached
12503 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12504 gnus-summary-highlight-line-cached
12505 (let* ((cond (list 'cond))
12507 (list gnus-summary-highlight))
12509 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12513 (gnus-byte-compile (list 'lambda nil cond))))))
12515 (defun gnus-summary-highlight-line ()
12516 "Highlight current line according to `gnus-summary-highlight'."
12517 (let* ((beg (point-at-bol))
12518 (article (or (gnus-summary-article-number) gnus-current-article))
12519 (score (or (cdr (assq article
12520 gnus-newsgroup-scored))
12521 gnus-summary-default-score 0))
12522 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12523 (inhibit-read-only t)
12524 (default gnus-summary-default-score)
12525 (default-high gnus-summary-default-high-score)
12526 (default-low gnus-summary-default-low-score)
12527 (uncached (and gnus-summary-use-undownloaded-faces
12528 (memq article gnus-newsgroup-undownloaded)
12529 (not (memq article gnus-newsgroup-cached)))))
12530 (let ((face (funcall (gnus-summary-highlight-line-0))))
12531 (unless (eq face (get-text-property beg 'face))
12532 (gnus-put-text-property-excluding-characters-with-faces
12533 beg (point-at-eol) 'face
12534 (setq face (if (boundp face) (symbol-value face) face)))
12535 (when gnus-summary-highlight-line-function
12536 (funcall gnus-summary-highlight-line-function article face))))))
12538 (defun gnus-update-read-articles (group unread &optional compute)
12539 "Update the list of read articles in GROUP.
12540 UNREAD is a sorted list."
12541 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12542 (info (gnus-get-info group))
12545 (if (or (not info) (not active))
12546 ;; There is no info on this group if it was, in fact,
12547 ;; killed. Gnus stores no information on killed groups, so
12548 ;; there's nothing to be done.
12549 ;; One could store the information somewhere temporarily,
12550 ;; perhaps... Hmmm...
12552 ;; Remove any negative articles numbers.
12553 (while (and unread (< (car unread) 0))
12554 (setq unread (cdr unread)))
12555 ;; Remove any expired article numbers
12556 (while (and unread (< (car unread) (car active)))
12557 (setq unread (cdr unread)))
12558 ;; Compute the ranges of read articles by looking at the list of
12559 ;; unread articles.
12561 (when (/= (car unread) prev)
12562 (push (if (= prev (1- (car unread))) prev
12563 (cons prev (1- (car unread))))
12565 (setq prev (1+ (car unread)))
12566 (setq unread (cdr unread)))
12567 (when (<= prev (cdr active))
12568 (push (cons prev (cdr active)) read))
12569 (setq read (if (> (length read) 1) (nreverse read) read))
12574 ;; Propagate the read marks to the backend.
12575 (when (and (gnus-method-option-p
12576 (gnus-find-method-for-group group)
12578 (gnus-check-backend-function 'request-set-mark group))
12579 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12580 (add (gnus-remove-from-range read (gnus-info-read info))))
12582 (unless (gnus-check-group group)
12583 (error "Can't open server for %s" group))
12584 (gnus-request-set-mark
12585 group (delq nil (list (if add (list add 'add '(read)))
12586 (if del (list del 'del '(read))))))
12588 `(gnus-request-set-mark
12591 (if del (list del 'add '(read)))
12592 (if add (list add 'del '(read))))))))))
12593 (set-buffer gnus-group-buffer)
12594 (gnus-undo-register
12596 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12597 (gnus-info-set-read ',info ',(gnus-info-read info))
12598 (gnus-get-unread-articles-in-group ',info
12599 (gnus-active ,group))
12600 (gnus-group-update-group ,group t)
12602 ;; Enter this list into the group info.
12603 (gnus-info-set-read info read)
12604 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12605 (gnus-get-unread-articles-in-group info (gnus-active group))
12608 (defun gnus-offer-save-summaries ()
12609 "Offer to save all active summary buffers."
12611 ;; Go through all buffers and find all summaries.
12612 (dolist (buffer (buffer-list))
12613 (when (and (setq buffer (buffer-name buffer))
12614 (string-match "Summary" buffer)
12615 (with-current-buffer buffer
12616 ;; We check that this is, indeed, a summary buffer.
12617 (and (eq major-mode 'gnus-summary-mode)
12618 ;; Also make sure this isn't bogus.
12619 gnus-newsgroup-prepared
12620 ;; Also make sure that this isn't a
12621 ;; dead summary buffer.
12622 (not gnus-dead-summary-mode))))
12623 (push buffer buffers)))
12624 ;; Go through all these summary buffers and offer to save them.
12627 (if (eq gnus-interactive-exit 'quiet)
12628 (dolist (buffer buffers)
12629 (switch-to-buffer buffer)
12630 (gnus-summary-exit))
12632 "Update summary buffer %s? "
12634 (switch-to-buffer buf)
12635 (gnus-summary-exit))
12638 (defun gnus-summary-setup-default-charset ()
12639 "Setup newsgroup default charset."
12640 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12641 (setq gnus-newsgroup-charset nil)
12642 (let* ((ignored-charsets
12643 (or gnus-newsgroup-ephemeral-ignored-charsets
12645 (and gnus-newsgroup-name
12646 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12647 gnus-newsgroup-ignored-charsets))))
12648 (setq gnus-newsgroup-charset
12649 (or gnus-newsgroup-ephemeral-charset
12650 (and gnus-newsgroup-name
12651 (gnus-parameter-charset gnus-newsgroup-name))
12652 gnus-default-charset))
12653 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12654 ignored-charsets))))
12660 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12661 "Display the current article buffer fully MIME-buttonized.
12662 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12663 treated as multipart/mixed."
12665 (require 'gnus-art)
12666 (let ((gnus-unbuttonized-mime-types nil)
12667 (gnus-mime-display-multipart-as-mixed show-all-parts))
12668 (gnus-summary-show-article)))
12670 (defun gnus-summary-repair-multipart (article)
12671 "Add a Content-Type header to a multipart article without one."
12672 (interactive (list (gnus-summary-article-number)))
12673 (gnus-with-article article
12674 (message-narrow-to-head)
12675 (message-remove-header "Mime-Version")
12676 (goto-char (point-max))
12677 (insert "Mime-Version: 1.0\n")
12679 (when (search-forward "\n--" nil t)
12680 (let ((separator (buffer-substring (point) (point-at-eol))))
12681 (message-narrow-to-head)
12682 (message-remove-header "Content-Type")
12683 (goto-char (point-max))
12684 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12687 (let (gnus-mark-article-hook)
12688 (gnus-summary-select-article t t nil article)))
12690 (defun gnus-summary-toggle-display-buttonized ()
12691 "Toggle the buttonizing of the article buffer."
12693 (require 'gnus-art)
12694 (if (setq gnus-inhibit-mime-unbuttonizing
12695 (not gnus-inhibit-mime-unbuttonizing))
12696 (let ((gnus-unbuttonized-mime-types nil))
12697 (gnus-summary-show-article))
12698 (gnus-summary-show-article)))
12701 ;;; Generic summary marking commands
12704 (defvar gnus-summary-marking-alist
12705 '((read gnus-del-mark "d")
12706 (unread gnus-unread-mark "u")
12707 (ticked gnus-ticked-mark "!")
12708 (dormant gnus-dormant-mark "?")
12709 (expirable gnus-expirable-mark "e"))
12710 "An alist of names/marks/keystrokes.")
12712 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12713 (defvar gnus-summary-mark-map)
12715 (defun gnus-summary-make-all-marking-commands ()
12716 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12717 (dolist (elem gnus-summary-marking-alist)
12718 (apply 'gnus-summary-make-marking-command elem)))
12720 (defun gnus-summary-make-marking-command (name mark keystroke)
12721 (let ((map (make-sparse-keymap)))
12722 (define-key gnus-summary-generic-mark-map keystroke map)
12723 (dolist (lway `((next "next" next nil "n")
12724 (next-unread "next unread" next t "N")
12725 (prev "previous" prev nil "p")
12726 (prev-unread "previous unread" prev t "P")
12727 (nomove "" nil nil ,keystroke)))
12728 (let ((func (gnus-summary-make-marking-command-1
12729 mark (car lway) lway name)))
12730 (setq func (eval func))
12731 (define-key map (nth 4 lway) func)))))
12733 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12735 (format "gnus-summary-put-mark-as-%s%s"
12736 name (if (eq way 'nomove)
12738 (concat "-" (symbol-name way)))))
12741 "Mark the current article as %s%s.
12742 If N, the prefix, then repeat N times.
12743 If N is negative, move in reverse order.
12744 The difference between N and the actual number of articles marked is
12748 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12750 (defun gnus-summary-generic-mark (n mark move unread)
12751 "Mark N articles with MARK."
12752 (unless (eq major-mode 'gnus-summary-mode)
12753 (error "This command can only be used in the summary buffer"))
12754 (gnus-summary-show-thread)
12757 ((eq move 'next) 1)
12758 ((eq move 'prev) -1)
12760 (if (zerop nummove)
12764 nummove (* -1 nummove))))
12765 (while (and (> n 0)
12766 (gnus-summary-mark-article nil mark)
12767 (zerop (gnus-summary-next-subject nummove unread t)))
12770 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12771 (gnus-summary-recenter)
12772 (gnus-summary-position-point)
12773 (gnus-set-mode-line 'summary)
12776 (defun gnus-summary-insert-articles (articles)
12777 (when (setq articles
12778 (gnus-sorted-difference articles
12779 (mapcar (lambda (h)
12780 (mail-header-number h))
12781 gnus-newsgroup-headers)))
12782 (setq gnus-newsgroup-headers
12784 gnus-newsgroup-headers
12785 (gnus-fetch-headers articles)
12786 'gnus-article-sort-by-number))
12787 (setq gnus-newsgroup-articles
12788 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12789 ;; Suppress duplicates?
12790 (when gnus-suppress-duplicates
12791 (gnus-dup-suppress-articles))
12793 (if (and gnus-fetch-old-headers
12794 (eq gnus-headers-retrieved-by 'nov))
12795 ;; We might want to build some more threads first.
12796 (if (eq gnus-fetch-old-headers 'invisible)
12797 (gnus-build-all-threads)
12798 (gnus-build-old-threads))
12799 ;; Mark the inserted articles that are unread as unread.
12800 (setq gnus-newsgroup-unreads
12801 (gnus-sorted-nunion
12802 gnus-newsgroup-unreads
12803 (gnus-sorted-nintersection
12804 (gnus-list-of-unread-articles gnus-newsgroup-name)
12806 ;; Mark the inserted articles as selected so that the information
12807 ;; of the marks having been changed by a user may be updated when
12808 ;; exiting this group. See `gnus-summary-update-info'.
12809 (dolist (art articles)
12810 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12811 ;; Let the Gnus agent mark articles as read.
12813 (gnus-agent-get-undownloaded-list))
12814 ;; Remove list identifiers from subject
12815 (gnus-summary-remove-list-identifiers)
12816 ;; First and last article in this newsgroup.
12817 (when gnus-newsgroup-headers
12818 (setq gnus-newsgroup-begin
12819 (mail-header-number (car gnus-newsgroup-headers))
12821 (mail-header-number
12822 (gnus-last-element gnus-newsgroup-headers))))
12823 (when gnus-use-scoring
12824 (gnus-possibly-score-headers))))
12826 (defun gnus-summary-insert-old-articles (&optional all)
12827 "Insert all old articles in this group.
12828 If ALL is non-nil, already read articles become readable.
12829 If ALL is a number, fetch this number of articles."
12832 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12835 ;; Some nntp servers lie about their active range. When
12836 ;; this happens, the active range can be in the millions.
12837 ;; Use a compressed range to avoid creating a huge list.
12838 (gnus-range-difference (list gnus-newsgroup-active) old))
12839 (setq len (gnus-range-length older))
12844 (let ((older-range (nreverse older)))
12848 (let* ((r (pop older-range))
12849 (min (if (numberp r) r (car r)))
12850 (max (if (numberp r) r (cdr r))))
12851 (while (and (<= min max)
12856 (setq older (gnus-uncompress-range older))))
12858 (setq older (gnus-uncompress-range older)))
12860 (when (and (numberp gnus-large-newsgroup)
12861 (> len gnus-large-newsgroup))
12862 (let* ((cursor-in-echo-area nil)
12863 (initial (gnus-parameter-large-newsgroup-initial
12864 gnus-newsgroup-name))
12868 "How many articles from %s (%s %d): "
12869 (gnus-group-decoded-name gnus-newsgroup-name)
12870 (if initial "max" "default")
12874 (number-to-string initial)))))
12875 (unless (string-match "^[ \t]*$" input)
12876 (setq all (string-to-number input))
12878 (let ((older-range (nreverse older)))
12882 (let* ((r (pop older-range))
12883 (min (if (numberp r) r (car r)))
12884 (max (if (numberp r) r (cdr r))))
12885 (while (and (<= min max)
12889 max (1- max))))))))))
12890 (setq older (gnus-uncompress-range older))))
12892 (message "No old news.")
12893 (gnus-summary-insert-articles older)
12894 (gnus-summary-limit (gnus-sorted-nunion old older))))
12895 (gnus-summary-position-point)))
12897 (defun gnus-summary-insert-new-articles ()
12898 "Insert all new articles in this group."
12900 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12901 (old-high gnus-newsgroup-highest)
12902 (nnmail-fetched-sources (list t))
12903 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12906 (error "Couldn't fetch new data"))
12907 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12908 (setq i (cdr gnus-newsgroup-active)
12909 gnus-newsgroup-highest i)
12910 (while (> i old-high)
12914 (message "No gnus is bad news")
12915 (gnus-summary-insert-articles new)
12916 (setq gnus-newsgroup-unreads
12917 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12918 (gnus-summary-limit (gnus-sorted-nunion old new))))
12919 (gnus-summary-position-point))
12921 ;;; Bookmark support for Gnus.
12922 (declare-function bookmark-make-record-default
12923 "bookmark" (&optional no-file no-context posn))
12924 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12925 (declare-function bookmark-default-handler "bookmark" (bmk))
12926 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12927 (defvar bookmark-yank-point)
12928 (defvar bookmark-current-buffer)
12930 (defun gnus-summary-bookmark-make-record ()
12931 "Make a bookmark entry for a Gnus summary buffer."
12933 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12934 (save-restriction ; FIXME is it necessary to widen?
12935 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12936 (setq buf "art") ; We are recording bookmark from article buffer.
12937 (setq bookmark-yank-point (point))
12938 (setq bookmark-current-buffer (current-buffer))
12939 (gnus-article-show-summary)) ; Go back in summary buffer.
12940 ;; We are now recording bookmark from summary buffer.
12941 (unless buf (setq buf "sum"))
12942 (let* ((subject (elt (gnus-summary-article-header) 1))
12943 (grp (car gnus-article-current))
12944 (art (cdr gnus-article-current))
12945 (head (gnus-summary-article-header art))
12946 (id (mail-header-id head)))
12948 ,@(condition-case nil
12949 (bookmark-make-record-default 'no-file 'no-context pos)
12950 (wrong-number-of-arguments
12951 (bookmark-make-record-default 'point-only)))
12952 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12953 (group . ,grp) (article . ,art)
12954 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12957 (defun gnus-summary-bookmark-jump (bookmark)
12958 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12959 BOOKMARK is a bookmark name or a bookmark record."
12960 (let ((group (bookmark-prop-get bookmark 'group))
12961 (article (bookmark-prop-get bookmark 'article))
12962 (id (bookmark-prop-get bookmark 'message-id))
12963 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12964 (gnus-fetch-group group (list article))
12965 (gnus-summary-insert-cached-articles)
12966 (gnus-summary-goto-article id nil 'force)
12967 ;; FIXME we have to wait article buffer is ready (only large buffer)
12968 ;; Is there a better solution to know that?
12969 ;; If we don't wait `bookmark-default-handler' will have no chance
12970 ;; to set position. However there is no error, just wrong pos.
12972 (when (string= buf "Gnus-art")
12974 (bookmark-default-handler
12976 (buffer . ,(current-buffer))
12977 . ,(bookmark-get-bookmark-record bookmark)))))
12979 (gnus-summary-make-all-marking-commands)
12981 (gnus-ems-redefine)
12983 (provide 'gnus-sum)
12985 (run-hooks 'gnus-sum-load-hook)
12987 ;; Local Variables:
12988 ;; coding: iso-8859-1
12991 ;;; gnus-sum.el ends here