1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
32 (defvar tool-bar-map))
44 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
45 (autoload 'gnus-cache-write-active "gnus-cache")
46 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
47 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
48 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
49 (autoload 'mm-uu-dissect "mm-uu")
50 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
51 "Deuglify broken Outlook (Express) articles and redisplay."
53 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
54 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
55 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
57 (defcustom gnus-kill-summary-on-exit t
58 "*If non-nil, kill the summary buffer when you exit from it.
59 If nil, the summary will become a \"*Dead Summary*\" buffer, and
60 it will be killed sometime later."
61 :group 'gnus-summary-exit
64 (defcustom gnus-fetch-old-headers nil
65 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
66 If an unread article in the group refers to an older, already read (or
67 just marked as read) article, the old article will not normally be
68 displayed in the Summary buffer. If this variable is t, Gnus
69 will attempt to grab the headers to the old articles, and thereby
70 build complete threads. If it has the value `some', only enough
71 headers to connect otherwise loose threads will be displayed. This
72 variable can also be a number. In that case, no more than that number
73 of old headers will be fetched. If it has the value `invisible', all
74 old headers will be fetched, but none will be displayed.
76 The server has to support NOV for any of this to work."
78 :type '(choice (const :tag "off" nil)
83 (sexp :menu-tag "other" t)))
85 (defcustom gnus-refer-thread-limit 200
86 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
87 If t, fetch all the available old headers."
90 (sexp :menu-tag "other" t)))
92 (defcustom gnus-summary-make-false-root 'adopt
93 "*nil means that Gnus won't gather loose threads.
94 If the root of a thread has expired or been read in a previous
95 session, the information necessary to build a complete thread has been
96 lost. Instead of having many small sub-threads from this original thread
97 scattered all over the summary buffer, Gnus can gather them.
99 If non-nil, Gnus will try to gather all loose sub-threads from an
100 original thread into one large thread.
102 If this variable is non-nil, it should be one of `none', `adopt',
105 If this variable is `none', Gnus will not make a false root, but just
106 present the sub-threads after another.
107 If this variable is `dummy', Gnus will create a dummy root that will
108 have all the sub-threads as children.
109 If this variable is `adopt', Gnus will make one of the \"children\"
110 the parent and mark all the step-children as such.
111 If this variable is `empty', the \"children\" are printed with empty
112 subject fields. (Or rather, they will be printed with a string
113 given by the `gnus-summary-same-subject' variable.)"
115 :type '(choice (const :tag "off" nil)
121 (defcustom gnus-summary-make-false-root-always nil
122 "Always make a false dummy root."
127 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
128 "*A regexp to match subjects to be excluded from loose thread gathering.
129 As loose thread gathering is done on subjects only, that means that
130 there can be many false gatherings performed. By rooting out certain
131 common subjects, gathering might become saner."
135 (defcustom gnus-summary-gather-subject-limit nil
136 "*Maximum length of subject comparisons when gathering loose threads.
137 Use nil to compare full subjects. Setting this variable to a low
138 number will help gather threads that have been corrupted by
139 newsreaders chopping off subject lines, but it might also mean that
140 unrelated articles that have subject that happen to begin with the
141 same few characters will be incorrectly gathered.
143 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
146 :type '(choice (const :tag "off" nil)
148 (sexp :menu-tag "on" t)))
150 (defcustom gnus-simplify-subject-functions nil
151 "List of functions taking a string argument that simplify subjects.
152 The functions are applied recursively.
154 Useful functions to put in this list include:
155 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
156 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
158 :type '(repeat function))
160 (defcustom gnus-simplify-ignored-prefixes nil
161 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
163 :type '(choice (const :tag "off" nil)
166 (defcustom gnus-build-sparse-threads nil
167 "*If non-nil, fill in the gaps in threads.
168 If `some', only fill in the gaps that are needed to tie loose threads
169 together. If `more', fill in all leaf nodes that Gnus can find. If
170 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
172 :type '(choice (const :tag "off" nil)
175 (sexp :menu-tag "all" t)))
177 (defcustom gnus-summary-thread-gathering-function
178 'gnus-gather-threads-by-subject
179 "*Function used for gathering loose threads.
180 There are two pre-defined functions: `gnus-gather-threads-by-subject',
181 which only takes Subjects into consideration; and
182 `gnus-gather-threads-by-references', which compared the References
183 headers of the articles to find matches."
185 :type '(radio (function-item gnus-gather-threads-by-subject)
186 (function-item gnus-gather-threads-by-references)
187 (function :tag "other")))
189 (defcustom gnus-summary-same-subject ""
190 "*String indicating that the current article has the same subject as the previous.
191 This variable will only be used if the value of
192 `gnus-summary-make-false-root' is `empty'."
193 :group 'gnus-summary-format
196 (defcustom gnus-summary-goto-unread t
197 "*If t, many commands will go to the next unread article.
198 This applies to marking commands as well as other commands that
199 \"naturally\" select the next article, like, for instance, `SPC' at
200 the end of an article.
202 If nil, the marking commands do NOT go to the next unread article
203 \(they go to the next article instead). If `never', commands that
204 usually go to the next unread article, will go to the next article,
205 whether it is read or not."
206 :group 'gnus-summary-marks
207 :link '(custom-manual "(gnus)Setting Marks")
208 :type '(choice (const :tag "off" nil)
210 (sexp :menu-tag "on" t)))
212 (defcustom gnus-summary-default-score 0
213 "*Default article score level.
214 All scores generated by the score files will be added to this score.
215 If this variable is nil, scoring will be disabled."
216 :group 'gnus-score-default
217 :type '(choice (const :tag "disable")
220 (defcustom gnus-summary-default-high-score 0
221 "*Default threshold for a high scored article.
222 An article will be highlighted as high scored if its score is greater
225 :group 'gnus-score-default
228 (defcustom gnus-summary-default-low-score 0
229 "*Default threshold for a low scored article.
230 An article will be highlighted as low scored if its score is smaller
233 :group 'gnus-score-default
236 (defcustom gnus-summary-zcore-fuzz 0
237 "*Fuzziness factor for the zcore in the summary buffer.
238 Articles with scores closer than this to `gnus-summary-default-score'
240 :group 'gnus-summary-format
243 (defcustom gnus-simplify-subject-fuzzy-regexp nil
244 "*Strings to be removed when doing fuzzy matches.
245 This can either be a regular expression or list of regular expressions
246 that will be removed from subject strings if fuzzy subject
247 simplification is selected."
249 :type '(repeat regexp))
251 (defcustom gnus-show-threads t
252 "*If non-nil, display threads in summary mode."
256 (defcustom gnus-thread-hide-subtree nil
257 "*If non-nil, hide all threads initially.
258 This can be a predicate specifier which says which threads to hide.
259 If threads are hidden, you have to run the command
260 `gnus-summary-show-thread' by hand or select an article."
262 :type '(radio (sexp :format "Non-nil\n"
263 :match (lambda (widget value)
264 (not (or (consp value) (functionp value))))
267 (sexp :tag "Predicate specifier")))
269 (defcustom gnus-thread-hide-killed t
270 "*If non-nil, hide killed threads automatically."
274 (defcustom gnus-thread-ignore-subject t
275 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
276 If nil, articles that have different subjects from their parents will
277 start separate threads."
281 (defcustom gnus-thread-operation-ignore-subject t
282 "*If non-nil, subjects will be ignored when doing thread commands.
283 This affects commands like `gnus-summary-kill-thread' and
284 `gnus-summary-lower-thread'.
286 If this variable is nil, articles in the same thread with different
287 subjects will not be included in the operation in question. If this
288 variable is `fuzzy', only articles that have subjects that are fuzzily
289 equal will be included."
291 :type '(choice (const :tag "off" nil)
295 (defcustom gnus-thread-indent-level 4
296 "*Number that says how much each sub-thread should be indented."
300 (defcustom gnus-auto-extend-newsgroup t
301 "*If non-nil, extend newsgroup forward and backward when requested."
302 :group 'gnus-summary-choose
305 (defcustom gnus-auto-select-first t
306 "*If non-nil, select the article under point.
307 Which article this is is controlled by the `gnus-auto-select-subject'
310 If you want to prevent automatic selection of articles in some
311 newsgroups, set the variable to nil in `gnus-select-group-hook'."
312 :group 'gnus-group-select
313 :type '(choice (const :tag "none" nil)
314 (sexp :menu-tag "first" t)))
316 (defcustom gnus-auto-select-subject 'unread
317 "*Says what subject to place under point when entering a group.
319 This variable can either be the symbols `first' (place point on the
320 first subject), `unread' (place point on the subject line of the first
321 unread article), `best' (place point on the subject line of the
322 higest-scored article), `unseen' (place point on the subject line of
323 the first unseen article), `unseen-or-unread' (place point on the subject
324 line of the first unseen article or, if all article have been seen, on the
325 subject line of the first unread article), or a function to be called to
326 place point on some subject line."
328 :group 'gnus-group-select
329 :type '(choice (const best)
333 (const unseen-or-unread)))
335 (defcustom gnus-auto-select-next t
336 "*If non-nil, offer to go to the next group from the end of the previous.
337 If the value is t and the next newsgroup is empty, Gnus will exit
338 summary mode and go back to group mode. If the value is neither nil
339 nor t, Gnus will select the following unread newsgroup. In
340 particular, if the value is the symbol `quietly', the next unread
341 newsgroup will be selected without any confirmation, and if it is
342 `almost-quietly', the next group will be selected without any
343 confirmation if you are located on the last article in the group.
344 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
345 will go to the next group without confirmation."
346 :group 'gnus-summary-maneuvering
347 :type '(choice (const :tag "off" nil)
349 (const almost-quietly)
350 (const slightly-quietly)
351 (sexp :menu-tag "on" t)))
353 (defcustom gnus-auto-select-same nil
354 "*If non-nil, select the next article with the same subject.
355 If there are no more articles with the same subject, go to
356 the first unread article."
357 :group 'gnus-summary-maneuvering
360 (defcustom gnus-auto-goto-ignores 'unfetched
361 "*Says how to handle unfetched articles when maneuvering.
363 This variable can either be the symbols nil (maneuver to any
364 article), `undownloaded' (maneuvering while unplugged ignores articles
365 that have not been fetched), `always-undownloaded' (maneuvering always
366 ignores articles that have not been fetched), `unfetched' (maneuvering
367 ignores articles whose headers have not been fetched).
369 NOTE: The list of unfetched articles will always be nil when plugged
370 and, when unplugged, a subset of the undownloaded article list."
372 :group 'gnus-summary-maneuvering
373 :type '(choice (const :tag "None" nil)
374 (const :tag "Undownloaded when unplugged" undownloaded)
375 (const :tag "Undownloaded" always-undownloaded)
376 (const :tag "Unfetched" unfetched)))
378 (defcustom gnus-summary-check-current nil
379 "*If non-nil, consider the current article when moving.
380 The \"unread\" movement commands will stay on the same line if the
381 current article is unread."
382 :group 'gnus-summary-maneuvering
385 (defcustom gnus-auto-center-summary 2
386 "*If non-nil, always center the current summary buffer.
387 In particular, if `vertical' do only vertical recentering. If non-nil
388 and non-`vertical', do both horizontal and vertical recentering."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "none" nil)
392 (integer :tag "height")
393 (sexp :menu-tag "both" t)))
395 (defvar gnus-auto-center-group t
396 "*If non-nil, always center the group buffer.")
398 (defcustom gnus-show-all-headers nil
399 "*If non-nil, don't hide any headers."
400 :group 'gnus-article-hiding
401 :group 'gnus-article-headers
404 (defcustom gnus-summary-ignore-duplicates nil
405 "*If non-nil, ignore articles with identical Message-ID headers."
409 (defcustom gnus-single-article-buffer t
410 "*If non-nil, display all articles in the same buffer.
411 If nil, each group will get its own article buffer."
412 :group 'gnus-article-various
415 (defcustom gnus-break-pages t
416 "*If non-nil, do page breaking on articles.
417 The page delimiter is specified by the `gnus-page-delimiter'
419 :group 'gnus-article-various
422 (defcustom gnus-move-split-methods nil
423 "*Variable used to suggest where articles are to be moved to.
424 It uses the same syntax as the `gnus-split-methods' variable.
425 However, whereas `gnus-split-methods' specifies file names as targets,
426 this variable specifies group names."
427 :group 'gnus-summary-mail
428 :type '(repeat (choice (list :value (fun) function)
429 (cons :value ("" "") regexp (repeat string))
432 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
433 "Function used to compute default prefix for article move/copy/etc prompts.
434 The function should take one argument, a group name, and return a
435 string with the suggested prefix."
436 :group 'gnus-summary-mail
439 ;; FIXME: Although the custom type is `character' for the following variables,
440 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
442 (defcustom gnus-unread-mark ? ;Whitespace
443 "*Mark used for unread articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-ticked-mark ?!
448 "*Mark used for ticked articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-dormant-mark ??
453 "*Mark used for dormant articles."
454 :group 'gnus-summary-marks
457 (defcustom gnus-del-mark ?r
458 "*Mark used for del'd articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-read-mark ?R
463 "*Mark used for read articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-expirable-mark ?E
468 "*Mark used for expirable articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-killed-mark ?K
473 "*Mark used for killed articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-spam-mark ?$
478 "*Mark used for spam articles."
480 :group 'gnus-summary-marks
483 (defcustom gnus-souped-mark ?F
484 "*Mark used for souped articles."
485 :group 'gnus-summary-marks
488 (defcustom gnus-kill-file-mark ?X
489 "*Mark used for articles killed by kill files."
490 :group 'gnus-summary-marks
493 (defcustom gnus-low-score-mark ?Y
494 "*Mark used for articles with a low score."
495 :group 'gnus-summary-marks
498 (defcustom gnus-catchup-mark ?C
499 "*Mark used for articles that are caught up."
500 :group 'gnus-summary-marks
503 (defcustom gnus-replied-mark ?A
504 "*Mark used for articles that have been replied to."
505 :group 'gnus-summary-marks
508 (defcustom gnus-forwarded-mark ?F
509 "*Mark used for articles that have been forwarded."
511 :group 'gnus-summary-marks
514 (defcustom gnus-recent-mark ?N
515 "*Mark used for articles that are recent."
517 :group 'gnus-summary-marks
520 (defcustom gnus-cached-mark ?*
521 "*Mark used for articles that are in the cache."
522 :group 'gnus-summary-marks
525 (defcustom gnus-saved-mark ?S
526 "*Mark used for articles that have been saved."
527 :group 'gnus-summary-marks
530 (defcustom gnus-unseen-mark ?.
531 "*Mark used for articles that haven't been seen."
533 :group 'gnus-summary-marks
536 (defcustom gnus-no-mark ? ;Whitespace
537 "*Mark used for articles that have no other secondary mark."
539 :group 'gnus-summary-marks
542 (defcustom gnus-ancient-mark ?O
543 "*Mark used for ancient articles."
544 :group 'gnus-summary-marks
547 (defcustom gnus-sparse-mark ?Q
548 "*Mark used for sparsely reffed articles."
549 :group 'gnus-summary-marks
552 (defcustom gnus-canceled-mark ?G
553 "*Mark used for canceled articles."
554 :group 'gnus-summary-marks
557 (defcustom gnus-duplicate-mark ?M
558 "*Mark used for duplicate articles."
559 :group 'gnus-summary-marks
562 (defcustom gnus-undownloaded-mark ?-
563 "*Mark used for articles that weren't downloaded."
565 :group 'gnus-summary-marks
568 (defcustom gnus-downloaded-mark ?+
569 "*Mark used for articles that were downloaded."
570 :group 'gnus-summary-marks
573 (defcustom gnus-downloadable-mark ?%
574 "*Mark used for articles that are to be downloaded."
575 :group 'gnus-summary-marks
578 (defcustom gnus-unsendable-mark ?=
579 "*Mark used for articles that won't be sent."
580 :group 'gnus-summary-marks
583 (defcustom gnus-score-over-mark ?+
584 "*Score mark used for articles with high scores."
585 :group 'gnus-summary-marks
588 (defcustom gnus-score-below-mark ?-
589 "*Score mark used for articles with low scores."
590 :group 'gnus-summary-marks
593 (defcustom gnus-empty-thread-mark ? ;Whitespace
594 "*There is no thread under the article."
595 :group 'gnus-summary-marks
598 (defcustom gnus-not-empty-thread-mark ?=
599 "*There is a thread under the article."
600 :group 'gnus-summary-marks
603 (defcustom gnus-view-pseudo-asynchronously nil
604 "*If non-nil, Gnus will view pseudo-articles asynchronously."
605 :group 'gnus-extract-view
608 (defcustom gnus-auto-expirable-marks
609 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
610 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
611 gnus-souped-mark gnus-duplicate-mark)
612 "*The list of marks converted into expiration if a group is auto-expirable."
615 :type '(repeat character))
617 (defcustom gnus-inhibit-user-auto-expire t
618 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
623 (defcustom gnus-view-pseudos nil
624 "*If `automatic', pseudo-articles will be viewed automatically.
625 If `not-confirm', pseudos will be viewed automatically, and the user
626 will not be asked to confirm the command."
627 :group 'gnus-extract-view
628 :type '(choice (const :tag "off" nil)
630 (const not-confirm)))
632 (defcustom gnus-view-pseudos-separately t
633 "*If non-nil, one pseudo-article will be created for each file to be viewed.
634 If nil, all files that use the same viewing command will be given as a
635 list of parameters to that command."
636 :group 'gnus-extract-view
639 (defcustom gnus-insert-pseudo-articles t
640 "*If non-nil, insert pseudo-articles when decoding articles."
641 :group 'gnus-extract-view
644 (defcustom gnus-summary-dummy-line-format
646 "*The format specification for the dummy roots in the summary buffer.
647 It works along the same lines as a normal formatting string,
648 with some simple extensions.
652 General format specifiers can also be used.
653 See `(gnus)Formatting Variables'."
654 :link '(custom-manual "(gnus)Formatting Variables")
655 :group 'gnus-threading
658 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
659 "*The format specification for the summary mode line.
660 It works along the same lines as a normal formatting string,
661 with some simple extensions:
664 %p Unprefixed group name
665 %A Current article number
666 %z Current article score
668 %U Number of unread articles in the group
669 %e Number of unselected articles in the group
670 %Z A string with unread/unselected article counts
671 %g Shortish group name
672 %S Subject of the current article
674 %s Current score file name
675 %d Number of dormant articles
676 %r Number of articles that have been marked as read in this session
677 %E Number of articles expunged by the score files"
678 :group 'gnus-summary-format
681 (defcustom gnus-list-identifiers nil
682 "Regexp that matches list identifiers to be removed from subject.
683 This can also be a list of regexps."
685 :group 'gnus-summary-format
686 :group 'gnus-article-hiding
687 :type '(choice (const :tag "none" nil)
689 (repeat :value (".*") regexp)))
691 (defcustom gnus-summary-mark-below 0
692 "*Mark all articles with a score below this variable as read.
693 This variable is local to each summary buffer and usually set by the
695 :group 'gnus-score-default
698 (defun gnus-widget-reversible-match (widget value)
699 "Ignoring WIDGET, convert VALUE to internal form.
700 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
704 (eq (length value) 2)
705 (eq (nth 0 value) 'not)
706 (symbolp (nth 1 value)))))
708 (defun gnus-widget-reversible-to-internal (widget value)
709 "Ignoring WIDGET, convert VALUE to internal form.
710 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
711 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
715 (list (nth 1 value) t)))
717 (defun gnus-widget-reversible-to-external (widget value)
718 "Ignoring WIDGET, convert VALUE to external form.
719 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
720 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
723 (list 'not (nth 0 value))
726 (define-widget 'gnus-widget-reversible 'group
727 "A `group' that convert values."
728 :match 'gnus-widget-reversible-match
729 :value-to-internal 'gnus-widget-reversible-to-internal
730 :value-to-external 'gnus-widget-reversible-to-external)
732 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
733 "*List of functions used for sorting articles in the summary buffer.
735 Each function takes two articles and returns non-nil if the first
736 article should be sorted before the other. If you use more than one
737 function, the primary sort function should be the last. You should
738 probably always include `gnus-article-sort-by-number' in the list of
739 sorting functions -- preferably first. Also note that sorting by date
740 is often much slower than sorting by number, and the sorting order is
741 very similar. (Sorting by date means sorting by the time the message
742 was sent, sorting by number means sorting by arrival time.)
744 Each item can also be a list `(not F)' where F is a function;
745 this reverses the sort order.
747 Ready-made functions include `gnus-article-sort-by-number',
748 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
749 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
750 and `gnus-article-sort-by-score'.
752 When threading is turned on, the variable `gnus-thread-sort-functions'
753 controls how articles are sorted."
754 :group 'gnus-summary-sort
755 :type '(repeat (gnus-widget-reversible
756 (choice (function-item gnus-article-sort-by-number)
757 (function-item gnus-article-sort-by-author)
758 (function-item gnus-article-sort-by-subject)
759 (function-item gnus-article-sort-by-date)
760 (function-item gnus-article-sort-by-score)
761 (function-item gnus-article-sort-by-random)
762 (function :tag "other"))
763 (boolean :tag "Reverse order"))))
766 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
767 "*List of functions used for sorting threads in the summary buffer.
768 By default, threads are sorted by article number.
770 Each function takes two threads and returns non-nil if the first
771 thread should be sorted before the other. If you use more than one
772 function, the primary sort function should be the last. You should
773 probably always include `gnus-thread-sort-by-number' in the list of
774 sorting functions -- preferably first. Also note that sorting by date
775 is often much slower than sorting by number, and the sorting order is
776 very similar. (Sorting by date means sorting by the time the message
777 was sent, sorting by number means sorting by arrival time.)
779 Each list item can also be a list `(not F)' where F is a
780 function; this specifies reversed sort order.
782 Ready-made functions include `gnus-thread-sort-by-number',
783 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
784 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
785 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
786 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
787 and `gnus-thread-sort-by-total-score' (see
788 `gnus-thread-score-function').
790 When threading is turned off, the variable
791 `gnus-article-sort-functions' controls how articles are sorted."
792 :group 'gnus-summary-sort
794 (gnus-widget-reversible
795 (choice (function-item gnus-thread-sort-by-number)
796 (function-item gnus-thread-sort-by-author)
797 (function-item gnus-thread-sort-by-recipient)
798 (function-item gnus-thread-sort-by-subject)
799 (function-item gnus-thread-sort-by-date)
800 (function-item gnus-thread-sort-by-score)
801 (function-item gnus-thread-sort-by-most-recent-number)
802 (function-item gnus-thread-sort-by-most-recent-date)
803 (function-item gnus-thread-sort-by-random)
804 (function-item gnus-thread-sort-by-total-score)
805 (function :tag "other"))
806 (boolean :tag "Reverse order"))))
808 (defcustom gnus-thread-score-function '+
809 "*Function used for calculating the total score of a thread.
811 The function is called with the scores of the article and each
812 subthread and should then return the score of the thread.
814 Some functions you can use are `+', `max', or `min'."
815 :group 'gnus-summary-sort
818 (defcustom gnus-summary-expunge-below nil
819 "All articles that have a score less than this variable will be expunged.
820 This variable is local to the summary buffers."
821 :group 'gnus-score-default
822 :type '(choice (const :tag "off" nil)
825 (defcustom gnus-thread-expunge-below nil
826 "All threads that have a total score less than this variable will be expunged.
827 See `gnus-thread-score-function' for en explanation of what a
830 This variable is local to the summary buffers."
831 :group 'gnus-threading
832 :group 'gnus-score-default
833 :type '(choice (const :tag "off" nil)
836 (defcustom gnus-summary-mode-hook nil
837 "*A hook for Gnus summary mode.
838 This hook is run before any variables are set in the summary buffer."
839 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
840 :group 'gnus-summary-various
843 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
844 (when (featurep 'xemacs)
845 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
846 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
847 (add-hook 'gnus-summary-mode-hook
848 'gnus-xmas-switch-horizontal-scrollbar-off))
850 (defcustom gnus-summary-menu-hook nil
851 "*Hook run after the creation of the summary mode menu."
852 :group 'gnus-summary-visual
855 (defcustom gnus-summary-exit-hook nil
856 "*A hook called on exit from the summary buffer.
857 It will be called with point in the group buffer."
858 :group 'gnus-summary-exit
861 (defcustom gnus-summary-prepare-hook nil
862 "*A hook called after the summary buffer has been generated.
863 If you want to modify the summary buffer, you can use this hook."
864 :group 'gnus-summary-various
867 (defcustom gnus-summary-prepared-hook nil
868 "*A hook called as the last thing after the summary buffer has been generated."
869 :group 'gnus-summary-various
872 (defcustom gnus-summary-generate-hook nil
873 "*A hook run just before generating the summary buffer.
874 This hook is commonly used to customize threading variables and the
876 :group 'gnus-summary-various
879 (defcustom gnus-select-group-hook nil
880 "*A hook called when a newsgroup is selected.
882 If you'd like to simplify subjects like the
883 `gnus-summary-next-same-subject' command does, you can use the
886 (add-hook gnus-select-group-hook
888 (mapcar (lambda (header)
889 (mail-header-set-subject
891 (gnus-simplify-subject
892 (mail-header-subject header) 're-only)))
893 gnus-newsgroup-headers)))"
894 :group 'gnus-group-select
897 (defcustom gnus-select-article-hook nil
898 "*A hook called when an article is selected."
899 :group 'gnus-summary-choose
900 :options '(gnus-agent-fetch-selected-article)
903 (defcustom gnus-visual-mark-article-hook
904 (list 'gnus-highlight-selected-summary)
905 "*Hook run after selecting an article in the summary buffer.
906 It is meant to be used for highlighting the article in some way. It
907 is not run if `gnus-visual' is nil."
908 :group 'gnus-summary-visual
911 (defcustom gnus-parse-headers-hook nil
912 "*A hook called before parsing the headers."
916 (defcustom gnus-exit-group-hook nil
917 "*A hook called when exiting summary mode.
918 This hook is not called from the non-updating exit commands like `Q'."
922 (defcustom gnus-summary-update-hook
923 (list 'gnus-summary-highlight-line)
924 "*A hook called when a summary line is changed.
925 The hook will not be called if `gnus-visual' is nil.
927 The default function `gnus-summary-highlight-line' will
928 highlight the line according to the `gnus-summary-highlight'
930 :group 'gnus-summary-visual
933 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
934 "*A hook called when an article is selected for the first time.
935 The hook is intended to mark an article as read (or unread)
936 automatically when it is selected."
937 :group 'gnus-summary-choose
940 (defcustom gnus-group-no-more-groups-hook nil
941 "*A hook run when returning to group mode having no more (unread) groups."
942 :group 'gnus-group-select
945 (defcustom gnus-ps-print-hook nil
946 "*A hook run before ps-printing something from Gnus."
950 (defcustom gnus-summary-article-move-hook nil
951 "*A hook called after an article is moved, copied, respooled, or crossposted."
956 (defcustom gnus-summary-article-delete-hook nil
957 "*A hook called after an article is deleted."
962 (defcustom gnus-summary-article-expire-hook nil
963 "*A hook called after an article is expired."
968 (defcustom gnus-summary-display-arrow
969 (and (fboundp 'display-graphic-p)
971 "*If non-nil, display an arrow highlighting the current article."
976 (defcustom gnus-summary-selected-face 'gnus-summary-selected
977 "Face used for highlighting the current article in the summary buffer."
978 :group 'gnus-summary-visual
981 (defvar gnus-tmp-downloaded nil)
983 (defcustom gnus-summary-highlight
984 '(((eq mark gnus-canceled-mark)
985 . gnus-summary-cancelled)
986 ((and uncached (> score default-high))
987 . gnus-summary-high-undownloaded)
988 ((and uncached (< score default-low))
989 . gnus-summary-low-undownloaded)
991 . gnus-summary-normal-undownloaded)
992 ((and (> score default-high)
993 (or (eq mark gnus-dormant-mark)
994 (eq mark gnus-ticked-mark)))
995 . gnus-summary-high-ticked)
996 ((and (< score default-low)
997 (or (eq mark gnus-dormant-mark)
998 (eq mark gnus-ticked-mark)))
999 . gnus-summary-low-ticked)
1000 ((or (eq mark gnus-dormant-mark)
1001 (eq mark gnus-ticked-mark))
1002 . gnus-summary-normal-ticked)
1003 ((and (> score default-high) (eq mark gnus-ancient-mark))
1004 . gnus-summary-high-ancient)
1005 ((and (< score default-low) (eq mark gnus-ancient-mark))
1006 . gnus-summary-low-ancient)
1007 ((eq mark gnus-ancient-mark)
1008 . gnus-summary-normal-ancient)
1009 ((and (> score default-high) (eq mark gnus-unread-mark))
1010 . gnus-summary-high-unread)
1011 ((and (< score default-low) (eq mark gnus-unread-mark))
1012 . gnus-summary-low-unread)
1013 ((eq mark gnus-unread-mark)
1014 . gnus-summary-normal-unread)
1015 ((> score default-high)
1016 . gnus-summary-high-read)
1017 ((< score default-low)
1018 . gnus-summary-low-read)
1020 . gnus-summary-normal-read))
1021 "*Controls the highlighting of summary buffer lines.
1023 A list of (FORM . FACE) pairs. When deciding how a a particular
1024 summary line should be displayed, each form is evaluated. The content
1025 of the face field after the first true form is used. You can change
1026 how those summary lines are displayed, by editing the face field.
1028 You can use the following variables in the FORM field.
1030 score: The article's score
1031 default: The default article score.
1032 default-high: The default score for high scored articles.
1033 default-low: The default score for low scored articles.
1034 below: The score below which articles are automatically marked as read.
1035 mark: The article's mark.
1036 uncached: Non-nil if the article is uncached."
1037 :group 'gnus-summary-visual
1038 :type '(repeat (cons (sexp :tag "Form" nil)
1041 (defcustom gnus-alter-header-function nil
1042 "Function called to allow alteration of article header structures.
1043 The function is called with one parameter, the article header vector,
1044 which it may alter in any way."
1045 :type '(choice (const :tag "None" nil)
1047 :group 'gnus-summary)
1049 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1050 "Variable that says which function should be used to decode a string with encoded words.")
1052 (defcustom gnus-extra-headers '(To Newsgroups)
1053 "*Extra headers to parse."
1055 :group 'gnus-summary
1056 :type '(repeat symbol))
1058 (defcustom gnus-ignored-from-addresses
1059 (and user-mail-address
1060 (not (string= user-mail-address ""))
1061 (regexp-quote user-mail-address))
1062 "*Regexp of From headers that may be suppressed in favor of To headers."
1064 :group 'gnus-summary
1067 (defcustom gnus-summary-to-prefix "-> "
1068 "*String prefixed to the To field in the summary line when
1069 using `gnus-ignored-from-addresses'."
1071 :group 'gnus-summary
1074 (defcustom gnus-summary-newsgroup-prefix "=> "
1075 "*String prefixed to the Newsgroup field in the summary
1076 line when using `gnus-ignored-from-addresses'."
1078 :group 'gnus-summary
1081 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1082 "List of charsets that should be ignored.
1083 When these charsets are used in the \"charset\" parameter, the
1084 default charset will be used instead."
1086 :type '(repeat symbol)
1087 :group 'gnus-charset)
1089 (gnus-define-group-parameter
1093 "Return the ignored charsets of GROUP."
1094 :variable gnus-group-ignored-charsets-alist
1096 '(("alt\\.chinese\\.text" iso-8859-1))
1098 "Alist of regexps (to match group names) and charsets that should be ignored.
1099 When these charsets are used in the \"charset\" parameter, the
1100 default charset will be used instead."
1101 :variable-group gnus-charset
1102 :variable-type '(repeat (cons (regexp :tag "Group")
1104 :parameter-type '(choice :tag "Ignored charsets"
1107 :parameter-document "\
1108 List of charsets that should be ignored.
1110 When these charsets are used in the \"charset\" parameter, the
1111 default charset will be used instead.")
1113 (defcustom gnus-group-highlight-words-alist nil
1114 "Alist of group regexps and highlight regexps.
1115 This variable uses the same syntax as `gnus-emphasis-alist'."
1117 :type '(repeat (cons (regexp :tag "Group")
1118 (repeat (list (regexp :tag "Highlight regexp")
1119 (number :tag "Group for entire word" 0)
1120 (number :tag "Group for displayed part" 0)
1122 gnus-emphasis-highlight-words)))))
1123 :group 'gnus-summary-visual)
1125 (defcustom gnus-summary-show-article-charset-alist
1127 "Alist of number and charset.
1128 The article will be shown with the charset corresponding to the
1130 For example: ((1 . cn-gb-2312) (2 . big5))."
1132 :type '(repeat (cons (number :tag "Argument" 1)
1133 (symbol :tag "Charset")))
1134 :group 'gnus-charset)
1136 (defcustom gnus-preserve-marks t
1137 "Whether marks are preserved when moving, copying and respooling messages."
1140 :group 'gnus-summary-marks)
1142 (defcustom gnus-alter-articles-to-read-function nil
1143 "Function to be called to alter the list of articles to be selected."
1144 :type '(choice (const nil) function)
1145 :group 'gnus-summary)
1147 (defcustom gnus-orphan-score nil
1148 "*All orphans get this score added. Set in the score file."
1149 :group 'gnus-score-default
1150 :type '(choice (const nil)
1153 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1154 "*A regexp to match MIME parts when saving multiple parts of a
1155 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1156 This regexp will be used by default when prompting the user for which
1157 type of files to save."
1158 :group 'gnus-summary
1161 (defcustom gnus-read-all-available-headers nil
1162 "Whether Gnus should parse all headers made available to it.
1163 This is mostly relevant for slow back ends where the user may
1164 wish to widen the summary buffer to include all headers
1165 that were fetched. Say, for nnultimate groups."
1167 :group 'gnus-summary
1168 :type '(choice boolean regexp))
1170 (defcustom gnus-summary-muttprint-program "muttprint"
1171 "Command (and optional arguments) used to run Muttprint."
1173 :group 'gnus-summary
1176 (defcustom gnus-article-loose-mime t
1177 "If non-nil, don't require MIME-Version header.
1178 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1179 supply the MIME-Version header or deliberately strip it from the mail.
1180 If non-nil (the default), Gnus will treat some articles as MIME
1181 even if the MIME-Version header is missing."
1184 :group 'gnus-article-mime)
1186 (defcustom gnus-article-emulate-mime t
1187 "If non-nil, use MIME emulation for uuencode and the like.
1188 This means that Gnus will search message bodies for text that look
1189 like uuencoded bits, yEncoded bits, and so on, and present that using
1190 the normal Gnus MIME machinery."
1193 :group 'gnus-article-mime)
1195 ;;; Internal variables
1197 (defvar gnus-summary-display-cache nil)
1198 (defvar gnus-article-mime-handles nil)
1199 (defvar gnus-article-decoded-p nil)
1200 (defvar gnus-article-charset nil)
1201 (defvar gnus-article-ignored-charsets nil)
1202 (defvar gnus-scores-exclude-files nil)
1203 (defvar gnus-page-broken nil)
1205 (defvar gnus-original-article nil)
1206 (defvar gnus-article-internal-prepare-hook nil)
1207 (defvar gnus-newsgroup-process-stack nil)
1209 (defvar gnus-thread-indent-array nil)
1210 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1211 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1212 "Function called to sort the articles within a thread after it has been gathered together.")
1214 (defvar gnus-summary-save-parts-type-history nil)
1215 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1217 ;; Avoid highlighting in kill files.
1218 (defvar gnus-summary-inhibit-highlight nil)
1219 (defvar gnus-newsgroup-selected-overlay nil)
1220 (defvar gnus-inhibit-limiting nil)
1221 (defvar gnus-newsgroup-adaptive-score-file nil)
1222 (defvar gnus-current-score-file nil)
1223 (defvar gnus-current-move-group nil)
1224 (defvar gnus-current-copy-group nil)
1225 (defvar gnus-current-crosspost-group nil)
1226 (defvar gnus-newsgroup-display nil)
1228 (defvar gnus-newsgroup-dependencies nil)
1229 (defvar gnus-newsgroup-adaptive nil)
1230 (defvar gnus-summary-display-article-function nil)
1231 (defvar gnus-summary-highlight-line-function nil
1232 "Function called after highlighting a summary line.")
1234 (defvar gnus-summary-line-format-alist
1235 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1236 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1237 (?s gnus-tmp-subject-or-nil ?s)
1238 (?n gnus-tmp-name ?s)
1239 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1241 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1243 (?F gnus-tmp-from ?s)
1244 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1245 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1246 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1247 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1248 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1249 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1250 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1251 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1252 (?L gnus-tmp-lines ?s)
1253 (?O gnus-tmp-downloaded ?c)
1254 (?I gnus-tmp-indentation ?s)
1255 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1256 (?R gnus-tmp-replied ?c)
1257 (?\[ gnus-tmp-opening-bracket ?c)
1258 (?\] gnus-tmp-closing-bracket ?c)
1259 (?\> (make-string gnus-tmp-level ? ) ?s)
1260 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1261 (?i gnus-tmp-score ?d)
1262 (?z gnus-tmp-score-char ?c)
1263 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1264 (?U gnus-tmp-unread ?c)
1265 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1267 (?t (gnus-summary-number-of-articles-in-thread
1268 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1270 (?e (gnus-summary-number-of-articles-in-thread
1271 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1273 (?u gnus-tmp-user-defined ?s)
1274 (?P (gnus-pick-line-number) ?d)
1275 (?B gnus-tmp-thread-tree-header-string ?s)
1276 (user-date (gnus-user-date
1277 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1278 "An alist of format specifications that can appear in summary lines.
1279 These are paired with what variables they correspond with, along with
1280 the type of the variable (string, integer, character, etc).")
1282 (defvar gnus-summary-dummy-line-format-alist
1283 `((?S gnus-tmp-subject ?s)
1284 (?N gnus-tmp-number ?d)
1285 (?u gnus-tmp-user-defined ?s)))
1287 (defvar gnus-summary-mode-line-format-alist
1288 `((?G gnus-tmp-group-name ?s)
1289 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1290 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1291 (?A gnus-tmp-article-number ?d)
1292 (?Z gnus-tmp-unread-and-unselected ?s)
1293 (?V gnus-version ?s)
1294 (?U gnus-tmp-unread-and-unticked ?d)
1295 (?S gnus-tmp-subject ?s)
1296 (?e gnus-tmp-unselected ?d)
1297 (?u gnus-tmp-user-defined ?s)
1298 (?d (length gnus-newsgroup-dormant) ?d)
1299 (?t (length gnus-newsgroup-marked) ?d)
1300 (?h (length gnus-newsgroup-spam-marked) ?d)
1301 (?r (length gnus-newsgroup-reads) ?d)
1302 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1303 (?E gnus-newsgroup-expunged-tally ?d)
1304 (?s (gnus-current-score-file-nondirectory) ?s)))
1306 (defvar gnus-last-search-regexp nil
1307 "Default regexp for article search command.")
1309 (defvar gnus-last-shell-command nil
1310 "Default shell command on article.")
1312 (defvar gnus-newsgroup-agentized nil
1313 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1314 (defvar gnus-newsgroup-begin nil)
1315 (defvar gnus-newsgroup-end nil)
1316 (defvar gnus-newsgroup-last-rmail nil)
1317 (defvar gnus-newsgroup-last-mail nil)
1318 (defvar gnus-newsgroup-last-folder nil)
1319 (defvar gnus-newsgroup-last-file nil)
1320 (defvar gnus-newsgroup-auto-expire nil)
1321 (defvar gnus-newsgroup-active nil)
1323 (defvar gnus-newsgroup-data nil)
1324 (defvar gnus-newsgroup-data-reverse nil)
1325 (defvar gnus-newsgroup-limit nil)
1326 (defvar gnus-newsgroup-limits nil)
1327 (defvar gnus-summary-use-undownloaded-faces nil)
1329 (defvar gnus-newsgroup-unreads nil
1330 "Sorted list of unread articles in the current newsgroup.")
1332 (defvar gnus-newsgroup-unselected nil
1333 "Sorted list of unselected unread articles in the current newsgroup.")
1335 (defvar gnus-newsgroup-reads nil
1336 "Alist of read articles and article marks in the current newsgroup.")
1338 (defvar gnus-newsgroup-expunged-tally nil)
1340 (defvar gnus-newsgroup-marked nil
1341 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1343 (defvar gnus-newsgroup-spam-marked nil
1344 "List of ranges of articles that have been marked as spam.")
1346 (defvar gnus-newsgroup-killed nil
1347 "List of ranges of articles that have been through the scoring process.")
1349 (defvar gnus-newsgroup-cached nil
1350 "Sorted list of articles that come from the article cache.")
1352 (defvar gnus-newsgroup-saved nil
1353 "List of articles that have been saved.")
1355 (defvar gnus-newsgroup-kill-headers nil)
1357 (defvar gnus-newsgroup-replied nil
1358 "List of articles that have been replied to in the current newsgroup.")
1360 (defvar gnus-newsgroup-forwarded nil
1361 "List of articles that have been forwarded in the current newsgroup.")
1363 (defvar gnus-newsgroup-recent nil
1364 "List of articles that have are recent in the current newsgroup.")
1366 (defvar gnus-newsgroup-expirable nil
1367 "Sorted list of articles in the current newsgroup that can be expired.")
1369 (defvar gnus-newsgroup-processable nil
1370 "List of articles in the current newsgroup that can be processed.")
1372 (defvar gnus-newsgroup-downloadable nil
1373 "Sorted list of articles in the current newsgroup that can be processed.")
1375 (defvar gnus-newsgroup-unfetched nil
1376 "Sorted list of articles in the current newsgroup whose headers have
1377 not been fetched into the agent.
1379 This list will always be a subset of gnus-newsgroup-undownloaded.")
1381 (defvar gnus-newsgroup-undownloaded nil
1382 "List of articles in the current newsgroup that haven't been downloaded.")
1384 (defvar gnus-newsgroup-unsendable nil
1385 "List of articles in the current newsgroup that won't be sent.")
1387 (defvar gnus-newsgroup-bookmarks nil
1388 "List of articles in the current newsgroup that have bookmarks.")
1390 (defvar gnus-newsgroup-dormant nil
1391 "Sorted list of dormant articles in the current newsgroup.")
1393 (defvar gnus-newsgroup-unseen nil
1394 "List of unseen articles in the current newsgroup.")
1396 (defvar gnus-newsgroup-seen nil
1397 "Range of seen articles in the current newsgroup.")
1399 (defvar gnus-newsgroup-articles nil
1400 "List of articles in the current newsgroup.")
1402 (defvar gnus-newsgroup-scored nil
1403 "List of scored articles in the current newsgroup.")
1405 (defvar gnus-newsgroup-headers nil
1406 "List of article headers in the current newsgroup.")
1408 (defvar gnus-newsgroup-threads nil)
1410 (defvar gnus-newsgroup-prepared nil
1411 "Whether the current group has been prepared properly.")
1413 (defvar gnus-newsgroup-ancient nil
1414 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1416 (defvar gnus-newsgroup-sparse nil)
1418 (defvar gnus-current-article nil)
1419 (defvar gnus-article-current nil)
1420 (defvar gnus-current-headers nil)
1421 (defvar gnus-have-all-headers nil)
1422 (defvar gnus-last-article nil)
1423 (defvar gnus-newsgroup-history nil)
1424 (defvar gnus-newsgroup-charset nil)
1425 (defvar gnus-newsgroup-ephemeral-charset nil)
1426 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1428 (defvar gnus-article-before-search nil)
1430 (defvar gnus-summary-local-variables
1431 '(gnus-newsgroup-name
1432 gnus-newsgroup-begin gnus-newsgroup-end
1433 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1434 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1435 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1436 gnus-newsgroup-unselected gnus-newsgroup-marked
1437 gnus-newsgroup-spam-marked
1438 gnus-newsgroup-reads gnus-newsgroup-saved
1439 gnus-newsgroup-replied gnus-newsgroup-forwarded
1440 gnus-newsgroup-recent
1441 gnus-newsgroup-expirable
1442 gnus-newsgroup-processable gnus-newsgroup-killed
1443 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1444 gnus-newsgroup-unfetched
1445 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1446 gnus-newsgroup-seen gnus-newsgroup-articles
1447 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1448 gnus-newsgroup-headers gnus-newsgroup-threads
1449 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1450 gnus-current-article gnus-current-headers gnus-have-all-headers
1451 gnus-last-article gnus-article-internal-prepare-hook
1452 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1453 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1454 gnus-thread-expunge-below
1455 gnus-score-alist gnus-current-score-file
1456 (gnus-summary-expunge-below . global)
1457 (gnus-summary-mark-below . global)
1458 (gnus-orphan-score . global)
1459 gnus-newsgroup-active gnus-scores-exclude-files
1460 gnus-newsgroup-history gnus-newsgroup-ancient
1461 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1462 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1463 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1464 (gnus-newsgroup-expunged-tally . 0)
1465 gnus-cache-removable-articles gnus-newsgroup-cached
1466 gnus-newsgroup-data gnus-newsgroup-data-reverse
1467 gnus-newsgroup-limit gnus-newsgroup-limits
1468 gnus-newsgroup-charset gnus-newsgroup-display
1469 gnus-summary-use-undownloaded-faces)
1470 "Variables that are buffer-local to the summary buffers.")
1472 (defvar gnus-newsgroup-variables nil
1473 "A list of variables that have separate values in different newsgroups.
1474 A list of newsgroup (summary buffer) local variables, or cons of
1475 variables and their default expressions to be evalled (when the default
1476 values are not nil), that should be made global while the summary buffer
1479 Note: The default expressions will be evaluated (using function `eval')
1480 before assignment to the local variable rather than just assigned to it.
1481 If the default expression is the symbol `global', that symbol will not
1482 be evaluated but the global value of the local variable will be used
1485 These variables can be used to set variables in the group parameters
1486 while still allowing them to affect operations done in other buffers.
1489 \(setq gnus-newsgroup-variables
1490 '(message-use-followup-to
1491 (gnus-visible-headers .
1492 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1495 ;; Byte-compiler warning.
1497 ;; Bind features so that require will believe that gnus-sum has
1498 ;; already been loaded (avoids infinite recursion)
1499 (let ((features (cons 'gnus-sum features)))
1500 ;; Several of the declarations in gnus-sum are needed to load the
1501 ;; following files. Right now, these definitions have been
1502 ;; compiled but not defined (evaluated). We could either do a
1503 ;; eval-and-compile about all of the declarations or evaluate the
1505 (if (boundp 'gnus-newsgroup-variables)
1507 (load "gnus-sum.el" t t t))
1509 (require 'gnus-art)))
1513 (defvar gnus-decode-encoded-word-methods
1514 '(mail-decode-encoded-word-string)
1515 "List of methods used to decode encoded words.
1517 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1518 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1519 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1520 whose names match REGEXP.
1523 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1524 mail-decode-encoded-word-string
1525 (\"chinese\" . rfc1843-decode-string))")
1527 (defvar gnus-decode-encoded-word-methods-cache nil)
1529 (defun gnus-multi-decode-encoded-word-string (string)
1530 "Apply the functions from `gnus-encoded-word-methods' that match."
1531 (unless (and gnus-decode-encoded-word-methods-cache
1532 (eq gnus-newsgroup-name
1533 (car gnus-decode-encoded-word-methods-cache)))
1534 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1537 (nconc gnus-decode-encoded-word-methods-cache (list x))
1538 (if (and gnus-newsgroup-name
1539 (string-match (car x) gnus-newsgroup-name))
1540 (nconc gnus-decode-encoded-word-methods-cache
1542 gnus-decode-encoded-word-methods))
1543 (let ((xlist gnus-decode-encoded-word-methods-cache))
1546 (setq string (funcall (pop xlist) string))))
1549 ;; Subject simplification.
1551 (defun gnus-simplify-whitespace (str)
1552 "Remove excessive whitespace from STR."
1554 (while (string-match "[ \t][ \t]+" str)
1555 (setq str (concat (substring str 0 (match-beginning 0))
1557 (substring str (match-end 0)))))
1559 (when (string-match "^[ \t]+" str)
1560 (setq str (substring str (match-end 0))))
1562 (when (string-match "[ \t]+$" str)
1563 (setq str (substring str 0 (match-beginning 0))))
1566 (defun gnus-simplify-all-whitespace (str)
1567 "Remove all whitespace from STR."
1568 (while (string-match "[ \t\n]+" str)
1569 (setq str (replace-match "" nil nil str)))
1572 (defsubst gnus-simplify-subject-re (subject)
1573 "Remove \"Re:\" from subject lines."
1574 (if (string-match message-subject-re-regexp subject)
1575 (substring subject (match-end 0))
1578 (defun gnus-simplify-subject (subject &optional re-only)
1579 "Remove `Re:' and words in parentheses.
1580 If RE-ONLY is non-nil, strip leading `Re:'s only."
1581 (let ((case-fold-search t)) ;Ignore case.
1582 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1583 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1584 (setq subject (substring subject (match-end 0))))
1585 ;; Remove uninteresting prefixes.
1586 (when (and (not re-only)
1587 gnus-simplify-ignored-prefixes
1588 (string-match gnus-simplify-ignored-prefixes subject))
1589 (setq subject (substring subject (match-end 0))))
1590 ;; Remove words in parentheses from end.
1592 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1593 (setq subject (substring subject 0 (match-beginning 0)))))
1594 ;; Return subject string.
1597 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1599 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1600 (goto-char (point-min))
1601 (while (re-search-forward regexp nil t)
1602 (replace-match (or newtext ""))))
1604 (defun gnus-simplify-buffer-fuzzy ()
1605 "Simplify string in the buffer fuzzily.
1606 The string in the accessible portion of the current buffer is simplified.
1607 It is assumed to be a single-line subject.
1608 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1609 matter is removed. Additional things can be deleted by setting
1610 `gnus-simplify-subject-fuzzy-regexp'."
1611 (let ((case-fold-search t)
1613 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1615 (while (not (eq modified-tick (buffer-modified-tick)))
1616 (setq modified-tick (buffer-modified-tick))
1618 ((listp gnus-simplify-subject-fuzzy-regexp)
1619 (mapcar 'gnus-simplify-buffer-fuzzy-step
1620 gnus-simplify-subject-fuzzy-regexp))
1621 (gnus-simplify-subject-fuzzy-regexp
1622 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1623 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1624 (gnus-simplify-buffer-fuzzy-step
1625 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1626 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1628 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1629 (gnus-simplify-buffer-fuzzy-step " +" " ")
1630 (gnus-simplify-buffer-fuzzy-step " $")
1631 (gnus-simplify-buffer-fuzzy-step "^ +")))
1633 (defun gnus-simplify-subject-fuzzy (subject)
1634 "Simplify a subject string fuzzily.
1635 See `gnus-simplify-buffer-fuzzy' for details."
1637 (gnus-set-work-buffer)
1638 (let ((case-fold-search t))
1639 ;; Remove uninteresting prefixes.
1640 (when (and gnus-simplify-ignored-prefixes
1641 (string-match gnus-simplify-ignored-prefixes subject))
1642 (setq subject (substring subject (match-end 0))))
1644 (inline (gnus-simplify-buffer-fuzzy))
1647 (defsubst gnus-simplify-subject-fully (subject)
1648 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1650 (gnus-simplify-subject-functions
1651 (gnus-map-function gnus-simplify-subject-functions subject))
1652 ((null gnus-summary-gather-subject-limit)
1653 (gnus-simplify-subject-re subject))
1654 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1655 (gnus-simplify-subject-fuzzy subject))
1656 ((numberp gnus-summary-gather-subject-limit)
1657 (gnus-limit-string (gnus-simplify-subject-re subject)
1658 gnus-summary-gather-subject-limit))
1662 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1663 "Check whether two subjects are equal.
1664 If optional argument SIMPLE-FIRST is t, first argument is already
1667 ((null simple-first)
1668 (equal (gnus-simplify-subject-fully s1)
1669 (gnus-simplify-subject-fully s2)))
1672 (gnus-simplify-subject-fully s2)))))
1674 (defun gnus-summary-bubble-group ()
1675 "Increase the score of the current group.
1676 This is a handy function to add to `gnus-summary-exit-hook' to
1677 increase the score of each group you read."
1678 (gnus-group-add-score gnus-newsgroup-name))
1682 ;;; Gnus summary mode
1685 (put 'gnus-summary-mode 'mode-class 'special)
1687 (defvar gnus-article-commands-menu)
1689 ;; Non-orthogonal keys
1691 (gnus-define-keys gnus-summary-mode-map
1692 " " gnus-summary-next-page
1693 "\177" gnus-summary-prev-page
1694 [delete] gnus-summary-prev-page
1695 [backspace] gnus-summary-prev-page
1696 "\r" gnus-summary-scroll-up
1697 "\M-\r" gnus-summary-scroll-down
1698 "n" gnus-summary-next-unread-article
1699 "p" gnus-summary-prev-unread-article
1700 "N" gnus-summary-next-article
1701 "P" gnus-summary-prev-article
1702 "\M-\C-n" gnus-summary-next-same-subject
1703 "\M-\C-p" gnus-summary-prev-same-subject
1704 "\M-n" gnus-summary-next-unread-subject
1705 "\M-p" gnus-summary-prev-unread-subject
1706 "." gnus-summary-first-unread-article
1707 "," gnus-summary-best-unread-article
1708 "\M-s" gnus-summary-search-article-forward
1709 "\M-r" gnus-summary-search-article-backward
1710 "<" gnus-summary-beginning-of-article
1711 ">" gnus-summary-end-of-article
1712 "j" gnus-summary-goto-article
1713 "^" gnus-summary-refer-parent-article
1714 "\M-^" gnus-summary-refer-article
1715 "u" gnus-summary-tick-article-forward
1716 "!" gnus-summary-tick-article-forward
1717 "U" gnus-summary-tick-article-backward
1718 "d" gnus-summary-mark-as-read-forward
1719 "D" gnus-summary-mark-as-read-backward
1720 "E" gnus-summary-mark-as-expirable
1721 "\M-u" gnus-summary-clear-mark-forward
1722 "\M-U" gnus-summary-clear-mark-backward
1723 "k" gnus-summary-kill-same-subject-and-select
1724 "\C-k" gnus-summary-kill-same-subject
1725 "\M-\C-k" gnus-summary-kill-thread
1726 "\M-\C-l" gnus-summary-lower-thread
1727 "e" gnus-summary-edit-article
1728 "#" gnus-summary-mark-as-processable
1729 "\M-#" gnus-summary-unmark-as-processable
1730 "\M-\C-t" gnus-summary-toggle-threads
1731 "\M-\C-s" gnus-summary-show-thread
1732 "\M-\C-h" gnus-summary-hide-thread
1733 "\M-\C-f" gnus-summary-next-thread
1734 "\M-\C-b" gnus-summary-prev-thread
1735 [(meta down)] gnus-summary-next-thread
1736 [(meta up)] gnus-summary-prev-thread
1737 "\M-\C-u" gnus-summary-up-thread
1738 "\M-\C-d" gnus-summary-down-thread
1739 "&" gnus-summary-execute-command
1740 "c" gnus-summary-catchup-and-exit
1741 "\C-w" gnus-summary-mark-region-as-read
1742 "\C-t" gnus-summary-toggle-truncation
1743 "?" gnus-summary-mark-as-dormant
1744 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1745 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1746 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1747 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1748 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1749 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1750 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1751 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1752 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1753 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1754 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1755 "=" gnus-summary-expand-window
1756 "\C-x\C-s" gnus-summary-reselect-current-group
1757 "\M-g" gnus-summary-rescan-group
1758 "w" gnus-summary-stop-page-breaking
1759 "\C-c\C-r" gnus-summary-caesar-message
1760 "f" gnus-summary-followup
1761 "F" gnus-summary-followup-with-original
1762 "C" gnus-summary-cancel-article
1763 "r" gnus-summary-reply
1764 "R" gnus-summary-reply-with-original
1765 "\C-c\C-f" gnus-summary-mail-forward
1766 "o" gnus-summary-save-article
1767 "\C-o" gnus-summary-save-article-mail
1768 "|" gnus-summary-pipe-output
1769 "\M-k" gnus-summary-edit-local-kill
1770 "\M-K" gnus-summary-edit-global-kill
1772 "\C-c\C-d" gnus-summary-describe-group
1773 "q" gnus-summary-exit
1774 "Q" gnus-summary-exit-no-update
1775 "\C-c\C-i" gnus-info-find-node
1776 gnus-mouse-2 gnus-mouse-pick-article
1777 [follow-link] mouse-face
1778 "m" gnus-summary-mail-other-window
1779 "a" gnus-summary-post-news
1780 "i" gnus-summary-news-other-window
1781 "x" gnus-summary-limit-to-unread
1782 "s" gnus-summary-isearch-article
1783 "t" gnus-summary-toggle-header
1784 "g" gnus-summary-show-article
1785 "l" gnus-summary-goto-last-article
1786 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1787 "\C-d" gnus-summary-enter-digest-group
1788 "\M-\C-d" gnus-summary-read-document
1789 "\M-\C-e" gnus-summary-edit-parameters
1790 "\M-\C-a" gnus-summary-customize-parameters
1792 "*" gnus-cache-enter-article
1793 "\M-*" gnus-cache-remove-article
1794 "\M-&" gnus-summary-universal-argument
1795 "\C-l" gnus-recenter
1796 "I" gnus-summary-increase-score
1797 "L" gnus-summary-lower-score
1798 "\M-i" gnus-symbolic-argument
1799 "h" gnus-summary-select-article-buffer
1801 "b" gnus-article-view-part
1802 "\M-t" gnus-summary-toggle-display-buttonized
1804 "V" gnus-summary-score-map
1805 "X" gnus-uu-extract-map
1806 "S" gnus-summary-send-map)
1808 ;; Sort of orthogonal keymap
1809 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1810 "t" gnus-summary-tick-article-forward
1811 "!" gnus-summary-tick-article-forward
1812 "d" gnus-summary-mark-as-read-forward
1813 "r" gnus-summary-mark-as-read-forward
1814 "c" gnus-summary-clear-mark-forward
1815 " " gnus-summary-clear-mark-forward
1816 "e" gnus-summary-mark-as-expirable
1817 "x" gnus-summary-mark-as-expirable
1818 "?" gnus-summary-mark-as-dormant
1819 "b" gnus-summary-set-bookmark
1820 "B" gnus-summary-remove-bookmark
1821 "#" gnus-summary-mark-as-processable
1822 "\M-#" gnus-summary-unmark-as-processable
1823 "S" gnus-summary-limit-include-expunged
1824 "C" gnus-summary-catchup
1825 "H" gnus-summary-catchup-to-here
1826 "h" gnus-summary-catchup-from-here
1827 "\C-c" gnus-summary-catchup-all
1828 "k" gnus-summary-kill-same-subject-and-select
1829 "K" gnus-summary-kill-same-subject
1830 "P" gnus-uu-mark-map)
1832 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1833 "c" gnus-summary-clear-above
1834 "u" gnus-summary-tick-above
1835 "m" gnus-summary-mark-above
1836 "k" gnus-summary-kill-below)
1838 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1839 "/" gnus-summary-limit-to-subject
1840 "n" gnus-summary-limit-to-articles
1841 "w" gnus-summary-pop-limit
1842 "s" gnus-summary-limit-to-subject
1843 "a" gnus-summary-limit-to-author
1844 "u" gnus-summary-limit-to-unread
1845 "m" gnus-summary-limit-to-marks
1846 "M" gnus-summary-limit-exclude-marks
1847 "v" gnus-summary-limit-to-score
1848 "*" gnus-summary-limit-include-cached
1849 "D" gnus-summary-limit-include-dormant
1850 "T" gnus-summary-limit-include-thread
1851 "d" gnus-summary-limit-exclude-dormant
1852 "t" gnus-summary-limit-to-age
1853 "." gnus-summary-limit-to-unseen
1854 "x" gnus-summary-limit-to-extra
1855 "p" gnus-summary-limit-to-display-predicate
1856 "E" gnus-summary-limit-include-expunged
1857 "c" gnus-summary-limit-exclude-childless-dormant
1858 "C" gnus-summary-limit-mark-excluded-as-read
1859 "o" gnus-summary-insert-old-articles
1860 "N" gnus-summary-insert-new-articles
1861 "r" gnus-summary-limit-to-replied
1862 "R" gnus-summary-limit-to-recipient)
1864 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1865 "n" gnus-summary-next-unread-article
1866 "p" gnus-summary-prev-unread-article
1867 "N" gnus-summary-next-article
1868 "P" gnus-summary-prev-article
1869 "\C-n" gnus-summary-next-same-subject
1870 "\C-p" gnus-summary-prev-same-subject
1871 "\M-n" gnus-summary-next-unread-subject
1872 "\M-p" gnus-summary-prev-unread-subject
1873 "f" gnus-summary-first-unread-article
1874 "b" gnus-summary-best-unread-article
1875 "j" gnus-summary-goto-article
1876 "g" gnus-summary-goto-subject
1877 "l" gnus-summary-goto-last-article
1878 "o" gnus-summary-pop-article)
1880 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1881 "k" gnus-summary-kill-thread
1882 "l" gnus-summary-lower-thread
1883 "i" gnus-summary-raise-thread
1884 "T" gnus-summary-toggle-threads
1885 "t" gnus-summary-rethread-current
1886 "^" gnus-summary-reparent-thread
1887 "s" gnus-summary-show-thread
1888 "S" gnus-summary-show-all-threads
1889 "h" gnus-summary-hide-thread
1890 "H" gnus-summary-hide-all-threads
1891 "n" gnus-summary-next-thread
1892 "p" gnus-summary-prev-thread
1893 "u" gnus-summary-up-thread
1894 "o" gnus-summary-top-thread
1895 "d" gnus-summary-down-thread
1896 "#" gnus-uu-mark-thread
1897 "\M-#" gnus-uu-unmark-thread)
1899 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1900 "g" gnus-summary-prepare
1901 "c" gnus-summary-insert-cached-articles
1902 "d" gnus-summary-insert-dormant-articles)
1904 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1905 "c" gnus-summary-catchup-and-exit
1906 "C" gnus-summary-catchup-all-and-exit
1907 "E" gnus-summary-exit-no-update
1908 "Q" gnus-summary-exit
1909 "Z" gnus-summary-exit
1910 "n" gnus-summary-catchup-and-goto-next-group
1911 "R" gnus-summary-reselect-current-group
1912 "G" gnus-summary-rescan-group
1913 "N" gnus-summary-next-group
1914 "s" gnus-summary-save-newsrc
1915 "P" gnus-summary-prev-group)
1917 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1918 " " gnus-summary-next-page
1919 "n" gnus-summary-next-page
1920 "\177" gnus-summary-prev-page
1921 [delete] gnus-summary-prev-page
1922 "p" gnus-summary-prev-page
1923 "\r" gnus-summary-scroll-up
1924 "\M-\r" gnus-summary-scroll-down
1925 "<" gnus-summary-beginning-of-article
1926 ">" gnus-summary-end-of-article
1927 "b" gnus-summary-beginning-of-article
1928 "e" gnus-summary-end-of-article
1929 "^" gnus-summary-refer-parent-article
1930 "r" gnus-summary-refer-parent-article
1931 "D" gnus-summary-enter-digest-group
1932 "R" gnus-summary-refer-references
1933 "T" gnus-summary-refer-thread
1934 "g" gnus-summary-show-article
1935 "s" gnus-summary-isearch-article
1936 "P" gnus-summary-print-article
1937 "M" gnus-mailing-list-insinuate
1938 "t" gnus-article-babel)
1940 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1941 "b" gnus-article-add-buttons
1942 "B" gnus-article-add-buttons-to-head
1943 "o" gnus-article-treat-overstrike
1944 "e" gnus-article-emphasize
1945 "w" gnus-article-fill-cited-article
1946 "Q" gnus-article-fill-long-lines
1947 "C" gnus-article-capitalize-sentences
1948 "c" gnus-article-remove-cr
1949 "q" gnus-article-de-quoted-unreadable
1950 "6" gnus-article-de-base64-unreadable
1951 "Z" gnus-article-decode-HZ
1952 "A" gnus-article-treat-ansi-sequences
1953 "h" gnus-article-wash-html
1954 "u" gnus-article-unsplit-urls
1955 "s" gnus-summary-force-verify-and-decrypt
1956 "f" gnus-article-display-x-face
1957 "l" gnus-summary-stop-page-breaking
1958 "r" gnus-summary-caesar-message
1959 "m" gnus-summary-morse-message
1960 "t" gnus-summary-toggle-header
1961 "g" gnus-treat-smiley
1962 "v" gnus-summary-verbose-headers
1963 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1964 "p" gnus-article-verify-x-pgp-sig
1965 "d" gnus-article-treat-dumbquotes
1966 "i" gnus-summary-idna-message)
1968 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1969 ;; mnemonic: deuglif*Y*
1970 "u" gnus-article-outlook-unwrap-lines
1971 "a" gnus-article-outlook-repair-attribution
1972 "c" gnus-article-outlook-rearrange-citation
1973 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1975 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1976 "a" gnus-article-hide
1977 "h" gnus-article-hide-headers
1978 "b" gnus-article-hide-boring-headers
1979 "s" gnus-article-hide-signature
1980 "c" gnus-article-hide-citation
1981 "C" gnus-article-hide-citation-in-followups
1982 "l" gnus-article-hide-list-identifiers
1983 "B" gnus-article-strip-banner
1984 "P" gnus-article-hide-pem
1985 "\C-c" gnus-article-hide-citation-maybe)
1987 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1988 "a" gnus-article-highlight
1989 "h" gnus-article-highlight-headers
1990 "c" gnus-article-highlight-citation
1991 "s" gnus-article-highlight-signature)
1993 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1994 "f" gnus-article-treat-fold-headers
1995 "u" gnus-article-treat-unfold-headers
1996 "n" gnus-article-treat-fold-newsgroups)
1998 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1999 "x" gnus-article-display-x-face
2000 "d" gnus-article-display-face
2001 "s" gnus-treat-smiley
2002 "D" gnus-article-remove-images
2003 "f" gnus-treat-from-picon
2004 "m" gnus-treat-mail-picon
2005 "n" gnus-treat-newsgroups-picon)
2007 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2008 "w" gnus-article-decode-mime-words
2009 "c" gnus-article-decode-charset
2010 "v" gnus-mime-view-all-parts
2011 "b" gnus-article-view-part)
2013 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2014 "z" gnus-article-date-ut
2015 "u" gnus-article-date-ut
2016 "l" gnus-article-date-local
2017 "p" gnus-article-date-english
2018 "e" gnus-article-date-lapsed
2019 "o" gnus-article-date-original
2020 "i" gnus-article-date-iso8601
2021 "s" gnus-article-date-user)
2023 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2024 "t" gnus-article-remove-trailing-blank-lines
2025 "l" gnus-article-strip-leading-blank-lines
2026 "m" gnus-article-strip-multiple-blank-lines
2027 "a" gnus-article-strip-blank-lines
2028 "A" gnus-article-strip-all-blank-lines
2029 "s" gnus-article-strip-leading-space
2030 "e" gnus-article-strip-trailing-space
2031 "w" gnus-article-remove-leading-whitespace)
2033 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2035 "f" gnus-summary-fetch-faq
2036 "d" gnus-summary-describe-group
2037 "h" gnus-summary-describe-briefly
2038 "i" gnus-info-find-node
2039 "c" gnus-group-fetch-charter
2040 "C" gnus-group-fetch-control)
2042 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2043 "e" gnus-summary-expire-articles
2044 "\M-\C-e" gnus-summary-expire-articles-now
2045 "\177" gnus-summary-delete-article
2046 [delete] gnus-summary-delete-article
2047 [backspace] gnus-summary-delete-article
2048 "m" gnus-summary-move-article
2049 "r" gnus-summary-respool-article
2050 "w" gnus-summary-edit-article
2051 "c" gnus-summary-copy-article
2052 "B" gnus-summary-crosspost-article
2053 "q" gnus-summary-respool-query
2054 "t" gnus-summary-respool-trace
2055 "i" gnus-summary-import-article
2056 "I" gnus-summary-create-article
2057 "p" gnus-summary-article-posted-p)
2059 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2060 "o" gnus-summary-save-article
2061 "m" gnus-summary-save-article-mail
2062 "F" gnus-summary-write-article-file
2063 "r" gnus-summary-save-article-rmail
2064 "f" gnus-summary-save-article-file
2065 "b" gnus-summary-save-article-body-file
2066 "h" gnus-summary-save-article-folder
2067 "v" gnus-summary-save-article-vm
2068 "p" gnus-summary-pipe-output
2069 "P" gnus-summary-muttprint
2070 "s" gnus-soup-add-article)
2072 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2073 "b" gnus-summary-display-buttonized
2074 "m" gnus-summary-repair-multipart
2075 "v" gnus-article-view-part
2076 "o" gnus-article-save-part
2077 "O" gnus-article-save-part-and-strip
2078 "r" gnus-article-replace-part
2079 "d" gnus-article-delete-part
2080 "j" gnus-article-jump-to-part
2081 "c" gnus-article-copy-part
2082 "C" gnus-article-view-part-as-charset
2083 "e" gnus-article-view-part-externally
2084 "E" gnus-article-encrypt-body
2085 "i" gnus-article-inline-part
2086 "|" gnus-article-pipe-part)
2088 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2089 "p" gnus-summary-mark-as-processable
2090 "u" gnus-summary-unmark-as-processable
2091 "U" gnus-summary-unmark-all-processable
2092 "v" gnus-uu-mark-over
2093 "s" gnus-uu-mark-series
2094 "r" gnus-uu-mark-region
2095 "g" gnus-uu-unmark-region
2096 "R" gnus-uu-mark-by-regexp
2097 "G" gnus-uu-unmark-by-regexp
2098 "t" gnus-uu-mark-thread
2099 "T" gnus-uu-unmark-thread
2100 "a" gnus-uu-mark-all
2101 "b" gnus-uu-mark-buffer
2102 "S" gnus-uu-mark-sparse
2103 "k" gnus-summary-kill-process-mark
2104 "y" gnus-summary-yank-process-mark
2105 "w" gnus-summary-save-process-mark
2106 "i" gnus-uu-invert-processable)
2108 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2109 ;;"x" gnus-uu-extract-any
2110 "m" gnus-summary-save-parts
2111 "u" gnus-uu-decode-uu
2112 "U" gnus-uu-decode-uu-and-save
2113 "s" gnus-uu-decode-unshar
2114 "S" gnus-uu-decode-unshar-and-save
2115 "o" gnus-uu-decode-save
2116 "O" gnus-uu-decode-save
2117 "b" gnus-uu-decode-binhex
2118 "B" gnus-uu-decode-binhex
2119 "p" gnus-uu-decode-postscript
2120 "P" gnus-uu-decode-postscript-and-save)
2123 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2124 "u" gnus-uu-decode-uu-view
2125 "U" gnus-uu-decode-uu-and-save-view
2126 "s" gnus-uu-decode-unshar-view
2127 "S" gnus-uu-decode-unshar-and-save-view
2128 "o" gnus-uu-decode-save-view
2129 "O" gnus-uu-decode-save-view
2130 "b" gnus-uu-decode-binhex-view
2131 "B" gnus-uu-decode-binhex-view
2132 "p" gnus-uu-decode-postscript-view
2133 "P" gnus-uu-decode-postscript-and-save-view)
2135 (defvar gnus-article-post-menu nil)
2137 (defconst gnus-summary-menu-maxlen 20)
2139 (defun gnus-summary-menu-split (menu)
2140 ;; If we have lots of elements, divide them into groups of 20
2141 ;; and make a pane (or submenu) for each one.
2142 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2143 (let ((menu menu) sublists next
2146 ;; Pull off the next gnus-summary-menu-maxlen elements
2147 ;; and make them the next element of sublist.
2148 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2150 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2152 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2153 (aref (car (last menu)) 0)) menu)
2157 (nreverse sublists))
2158 ;; Few elements--put them all in one pane.
2161 (defun gnus-summary-make-menu-bar ()
2162 (gnus-turn-off-edit-menu 'summary)
2164 (unless (boundp 'gnus-summary-misc-menu)
2167 gnus-summary-kill-menu gnus-summary-mode-map ""
2172 ["Customize" gnus-score-customize t])
2173 (gnus-make-score-map 'increase)
2174 (gnus-make-score-map 'lower)
2176 ["Kill below" gnus-summary-kill-below t]
2177 ["Mark above" gnus-summary-mark-above t]
2178 ["Tick above" gnus-summary-tick-above t]
2179 ["Clear above" gnus-summary-clear-above t])
2180 ["Current score" gnus-summary-current-score t]
2181 ["Set score" gnus-summary-set-score t]
2182 ["Switch current score file..." gnus-score-change-score-file t]
2183 ["Set mark below..." gnus-score-set-mark-below t]
2184 ["Set expunge below..." gnus-score-set-expunge-below t]
2185 ["Edit current score file" gnus-score-edit-current-scores t]
2186 ["Edit score file" gnus-score-edit-file t]
2187 ["Trace score" gnus-score-find-trace t]
2188 ["Find words" gnus-score-find-favourite-words t]
2189 ["Rescore buffer" gnus-summary-rescore t]
2190 ["Increase score..." gnus-summary-increase-score t]
2191 ["Lower score..." gnus-summary-lower-score t]))))
2193 ;; Define both the Article menu in the summary buffer and the
2194 ;; equivalent Commands menu in the article buffer here for
2198 ["All" gnus-article-hide t]
2199 ["Headers" gnus-article-hide-headers t]
2200 ["Signature" gnus-article-hide-signature t]
2201 ["Citation" gnus-article-hide-citation t]
2202 ["List identifiers" gnus-article-hide-list-identifiers t]
2203 ["Banner" gnus-article-strip-banner t]
2204 ["Boring headers" gnus-article-hide-boring-headers t])
2206 ["All" gnus-article-highlight t]
2207 ["Headers" gnus-article-highlight-headers t]
2208 ["Signature" gnus-article-highlight-signature t]
2209 ["Citation" gnus-article-highlight-citation t])
2211 ["Words" gnus-article-decode-mime-words t]
2212 ["Charset" gnus-article-decode-charset t]
2213 ["QP" gnus-article-de-quoted-unreadable t]
2214 ["Base64" gnus-article-de-base64-unreadable t]
2215 ["View MIME buttons" gnus-summary-display-buttonized t]
2216 ["View all" gnus-mime-view-all-parts t]
2217 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2218 ["Encrypt body" gnus-article-encrypt-body
2219 :active (not (gnus-group-read-only-p))
2220 ,@(if (featurep 'xemacs) nil
2221 '(:help "Encrypt the message body on disk"))]
2222 ["Extract all parts..." gnus-summary-save-parts t]
2224 ["Repair multipart" gnus-summary-repair-multipart t]
2225 ["Pipe part..." gnus-article-pipe-part t]
2226 ["Inline part" gnus-article-inline-part t]
2227 ["Encrypt body" gnus-article-encrypt-body
2228 :active (not (gnus-group-read-only-p))
2229 ,@(if (featurep 'xemacs) nil
2230 '(:help "Encrypt the message body on disk"))]
2231 ["View part externally" gnus-article-view-part-externally t]
2232 ["View part with charset..." gnus-article-view-part-as-charset t]
2233 ["Copy part" gnus-article-copy-part t]
2234 ["Save part..." gnus-article-save-part t]
2235 ["View part" gnus-article-view-part t]))
2237 ["Local" gnus-article-date-local t]
2238 ["ISO8601" gnus-article-date-iso8601 t]
2239 ["UT" gnus-article-date-ut t]
2240 ["Original" gnus-article-date-original t]
2241 ["Lapsed" gnus-article-date-lapsed t]
2242 ["User-defined" gnus-article-date-user t])
2244 ["Remove images" gnus-article-remove-images t]
2245 ["Toggle smiley" gnus-treat-smiley t]
2246 ["Show X-Face" gnus-article-display-x-face t]
2247 ["Show picons in From" gnus-treat-from-picon t]
2248 ["Show picons in mail headers" gnus-treat-mail-picon t]
2249 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2250 ("View as different encoding"
2251 ,@(gnus-summary-menu-split
2254 ;; Since easymenu under Emacs doesn't allow
2255 ;; lambda forms for menu commands, we should
2256 ;; provide intern'ed function symbols.
2257 (let ((command (intern (format "\
2258 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2262 (let ((gnus-summary-show-article-charset-alist
2264 (gnus-summary-show-article 1))))
2265 `[,(symbol-name cs) ,command t]))
2266 (sort (if (fboundp 'coding-system-list)
2267 (coding-system-list)
2268 (mapcar 'car mm-mime-mule-charset-alist))
2272 ["Leading" gnus-article-strip-leading-blank-lines t]
2273 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2274 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2275 ["All of the above" gnus-article-strip-blank-lines t]
2276 ["All" gnus-article-strip-all-blank-lines t]
2277 ["Leading space" gnus-article-strip-leading-space t]
2278 ["Trailing space" gnus-article-strip-trailing-space t]
2279 ["Leading space in headers"
2280 gnus-article-remove-leading-whitespace t])
2281 ["Overstrike" gnus-article-treat-overstrike t]
2282 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2283 ["Emphasis" gnus-article-emphasize t]
2284 ["Word wrap" gnus-article-fill-cited-article t]
2285 ["Fill long lines" gnus-article-fill-long-lines t]
2286 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2287 ["Remove CR" gnus-article-remove-cr t]
2288 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2289 ["Base64" gnus-article-de-base64-unreadable t]
2290 ["Rot 13" gnus-summary-caesar-message
2291 ,@(if (featurep 'xemacs) '(t)
2292 '(:help "\"Caesar rotate\" article by 13"))]
2293 ["De-IDNA" gnus-summary-idna-message t]
2294 ["Morse decode" gnus-summary-morse-message t]
2295 ["Unix pipe..." gnus-summary-pipe-message t]
2296 ["Add buttons" gnus-article-add-buttons t]
2297 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2298 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2299 ["Verbose header" gnus-summary-verbose-headers t]
2300 ["Toggle header" gnus-summary-toggle-header t]
2301 ["Unfold headers" gnus-article-treat-unfold-headers t]
2302 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2303 ["Html" gnus-article-wash-html t]
2304 ["Unsplit URLs" gnus-article-unsplit-urls t]
2305 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2306 ["Decode HZ" gnus-article-decode-HZ t]
2307 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2308 ("(Outlook) Deuglify"
2309 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2310 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2311 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2312 ["Full (Outlook) deuglify"
2313 gnus-article-outlook-deuglify-article t])
2316 ["Save in default format..." gnus-summary-save-article
2317 ,@(if (featurep 'xemacs) '(t)
2318 '(:help "Save article using default method"))]
2319 ["Save in file..." gnus-summary-save-article-file
2320 ,@(if (featurep 'xemacs) '(t)
2321 '(:help "Save article in file"))]
2322 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2323 ["Save in MH folder..." gnus-summary-save-article-folder t]
2324 ["Save in VM folder..." gnus-summary-save-article-vm t]
2325 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2326 ["Save body in file..." gnus-summary-save-article-body-file t]
2327 ["Pipe through a filter..." gnus-summary-pipe-output t]
2328 ["Add to SOUP packet" gnus-soup-add-article t]
2329 ["Print with Muttprint..." gnus-summary-muttprint t]
2330 ["Print" gnus-summary-print-article
2331 ,@(if (featurep 'xemacs) '(t)
2332 '(:help "Generate and print a PostScript image"))])
2333 ("Copy, move,... (Backend)"
2334 ,@(if (featurep 'xemacs) nil
2335 '(:help "Copying, moving, expiring articles..."))
2336 ["Respool article..." gnus-summary-respool-article t]
2337 ["Move article..." gnus-summary-move-article
2338 (gnus-check-backend-function
2339 'request-move-article gnus-newsgroup-name)]
2340 ["Copy article..." gnus-summary-copy-article t]
2341 ["Crosspost article..." gnus-summary-crosspost-article
2342 (gnus-check-backend-function
2343 'request-replace-article gnus-newsgroup-name)]
2344 ["Import file..." gnus-summary-import-article
2345 (gnus-check-backend-function
2346 'request-accept-article gnus-newsgroup-name)]
2347 ["Create article..." gnus-summary-create-article
2348 (gnus-check-backend-function
2349 'request-accept-article gnus-newsgroup-name)]
2350 ["Check if posted" gnus-summary-article-posted-p t]
2351 ["Edit article" gnus-summary-edit-article
2352 (not (gnus-group-read-only-p))]
2353 ["Delete article" gnus-summary-delete-article
2354 (gnus-check-backend-function
2355 'request-expire-articles gnus-newsgroup-name)]
2356 ["Query respool" gnus-summary-respool-query t]
2357 ["Trace respool" gnus-summary-respool-trace t]
2358 ["Delete expirable articles" gnus-summary-expire-articles-now
2359 (gnus-check-backend-function
2360 'request-expire-articles gnus-newsgroup-name)])
2362 ["Uudecode" gnus-uu-decode-uu
2363 ,@(if (featurep 'xemacs) '(t)
2364 '(:help "Decode uuencoded article(s)"))]
2365 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2366 ["Unshar" gnus-uu-decode-unshar t]
2367 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2368 ["Save" gnus-uu-decode-save t]
2369 ["Binhex" gnus-uu-decode-binhex t]
2370 ["Postscript" gnus-uu-decode-postscript t]
2371 ["All MIME parts" gnus-summary-save-parts t])
2373 ["Enter article" gnus-cache-enter-article t]
2374 ["Remove article" gnus-cache-remove-article t])
2375 ["Translate" gnus-article-babel t]
2376 ["Select article buffer" gnus-summary-select-article-buffer t]
2377 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2378 ["Isearch article..." gnus-summary-isearch-article t]
2379 ["Beginning of the article" gnus-summary-beginning-of-article t]
2380 ["End of the article" gnus-summary-end-of-article t]
2381 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2382 ["Fetch referenced articles" gnus-summary-refer-references t]
2383 ["Fetch current thread" gnus-summary-refer-thread t]
2384 ["Fetch article with id..." gnus-summary-refer-article t]
2385 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2386 ["Redisplay" gnus-summary-show-article t]
2387 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2389 gnus-summary-article-menu gnus-summary-mode-map ""
2390 (cons "Article" innards))
2392 (if (not (keymapp gnus-summary-article-menu))
2394 gnus-article-commands-menu gnus-article-mode-map ""
2395 (cons "Commands" innards))
2396 ;; in Emacs, don't share menu.
2397 (setq gnus-article-commands-menu
2398 (copy-keymap gnus-summary-article-menu))
2399 (define-key gnus-article-mode-map [menu-bar commands]
2400 (cons "Commands" gnus-article-commands-menu))))
2403 gnus-summary-thread-menu gnus-summary-mode-map ""
2405 ["Find all messages in thread" gnus-summary-refer-thread t]
2406 ["Toggle threading" gnus-summary-toggle-threads t]
2407 ["Hide threads" gnus-summary-hide-all-threads t]
2408 ["Show threads" gnus-summary-show-all-threads t]
2409 ["Hide thread" gnus-summary-hide-thread t]
2410 ["Show thread" gnus-summary-show-thread t]
2411 ["Go to next thread" gnus-summary-next-thread t]
2412 ["Go to previous thread" gnus-summary-prev-thread t]
2413 ["Go down thread" gnus-summary-down-thread t]
2414 ["Go up thread" gnus-summary-up-thread t]
2415 ["Top of thread" gnus-summary-top-thread t]
2416 ["Mark thread as read" gnus-summary-kill-thread t]
2417 ["Lower thread score" gnus-summary-lower-thread t]
2418 ["Raise thread score" gnus-summary-raise-thread t]
2419 ["Rethread current" gnus-summary-rethread-current t]))
2422 gnus-summary-post-menu gnus-summary-mode-map ""
2424 ["Send a message (mail or news)" gnus-summary-post-news
2425 ,@(if (featurep 'xemacs) '(t)
2426 '(:help "Compose a new message (mail or news)"))]
2427 ["Followup" gnus-summary-followup
2428 ,@(if (featurep 'xemacs) '(t)
2429 '(:help "Post followup to this article"))]
2430 ["Followup and yank" gnus-summary-followup-with-original
2431 ,@(if (featurep 'xemacs) '(t)
2432 '(:help "Post followup to this article, quoting its contents"))]
2433 ["Supersede article" gnus-summary-supersede-article t]
2434 ["Cancel article" gnus-summary-cancel-article
2435 ,@(if (featurep 'xemacs) '(t)
2436 '(:help "Cancel an article you posted"))]
2437 ["Reply" gnus-summary-reply t]
2438 ["Reply and yank" gnus-summary-reply-with-original t]
2439 ["Wide reply" gnus-summary-wide-reply t]
2440 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2441 ,@(if (featurep 'xemacs) '(t)
2442 '(:help "Mail a reply, quoting this article"))]
2443 ["Very wide reply" gnus-summary-very-wide-reply t]
2444 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2445 ,@(if (featurep 'xemacs) '(t)
2446 '(:help "Mail a very wide reply, quoting this article"))]
2447 ["Mail forward" gnus-summary-mail-forward t]
2448 ["Post forward" gnus-summary-post-forward t]
2449 ["Digest and mail" gnus-uu-digest-mail-forward t]
2450 ["Digest and post" gnus-uu-digest-post-forward t]
2451 ["Resend message" gnus-summary-resend-message t]
2452 ["Resend message edit" gnus-summary-resend-message-edit t]
2453 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2454 ["Send a mail" gnus-summary-mail-other-window t]
2455 ["Create a local message" gnus-summary-news-other-window t]
2456 ["Uuencode and post" gnus-uu-post-news
2457 ,@(if (featurep 'xemacs) '(t)
2458 '(:help "Post a uuencoded article"))]
2459 ["Followup via news" gnus-summary-followup-to-mail t]
2460 ["Followup via news and yank"
2461 gnus-summary-followup-to-mail-with-original t]
2463 ;;["Send" gnus-summary-send-draft t]
2464 ;;["Send bounced" gnus-resend-bounced-mail t])
2468 ((not (keymapp gnus-summary-post-menu))
2469 (setq gnus-article-post-menu gnus-summary-post-menu))
2470 ((not gnus-article-post-menu)
2471 ;; Don't share post menu.
2472 (setq gnus-article-post-menu
2473 (copy-keymap gnus-summary-post-menu))))
2474 (define-key gnus-article-mode-map [menu-bar post]
2475 (cons "Post" gnus-article-post-menu))
2478 gnus-summary-misc-menu gnus-summary-mode-map ""
2481 ["Mark as read" gnus-summary-mark-as-read-forward t]
2482 ["Mark same subject and select"
2483 gnus-summary-kill-same-subject-and-select t]
2484 ["Mark same subject" gnus-summary-kill-same-subject t]
2485 ["Catchup" gnus-summary-catchup
2486 ,@(if (featurep 'xemacs) '(t)
2487 '(:help "Mark unread articles in this group as read"))]
2488 ["Catchup all" gnus-summary-catchup-all t]
2489 ["Catchup to here" gnus-summary-catchup-to-here t]
2490 ["Catchup from here" gnus-summary-catchup-from-here t]
2491 ["Catchup region" gnus-summary-mark-region-as-read
2492 (gnus-mark-active-p)]
2493 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2495 ["Tick" gnus-summary-tick-article-forward t]
2496 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2497 ["Remove marks" gnus-summary-clear-mark-forward t]
2498 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2499 ["Set bookmark" gnus-summary-set-bookmark t]
2500 ["Remove bookmark" gnus-summary-remove-bookmark t])
2502 ["Marks..." gnus-summary-limit-to-marks t]
2503 ["Subject..." gnus-summary-limit-to-subject t]
2504 ["Author..." gnus-summary-limit-to-author t]
2505 ["Recipient..." gnus-summary-limit-to-recipient t]
2506 ["Age..." gnus-summary-limit-to-age t]
2507 ["Extra..." gnus-summary-limit-to-extra t]
2508 ["Score..." gnus-summary-limit-to-score t]
2509 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2510 ["Unread" gnus-summary-limit-to-unread t]
2511 ["Unseen" gnus-summary-limit-to-unseen t]
2512 ["Replied" gnus-summary-limit-to-replied t]
2513 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2514 ["Next articles" gnus-summary-limit-to-articles t]
2515 ["Pop limit" gnus-summary-pop-limit t]
2516 ["Show dormant" gnus-summary-limit-include-dormant t]
2517 ["Hide childless dormant"
2518 gnus-summary-limit-exclude-childless-dormant t]
2519 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2520 ["Hide marked" gnus-summary-limit-exclude-marks t]
2521 ["Show expunged" gnus-summary-limit-include-expunged t])
2523 ["Set mark" gnus-summary-mark-as-processable t]
2524 ["Remove mark" gnus-summary-unmark-as-processable t]
2525 ["Remove all marks" gnus-summary-unmark-all-processable t]
2526 ["Invert marks" gnus-uu-invert-processable t]
2527 ["Mark above" gnus-uu-mark-over t]
2528 ["Mark series" gnus-uu-mark-series t]
2529 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2530 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2531 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2532 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2533 ["Mark all" gnus-uu-mark-all t]
2534 ["Mark buffer" gnus-uu-mark-buffer t]
2535 ["Mark sparse" gnus-uu-mark-sparse t]
2536 ["Mark thread" gnus-uu-mark-thread t]
2537 ["Unmark thread" gnus-uu-unmark-thread t]
2538 ("Process Mark Sets"
2539 ["Kill" gnus-summary-kill-process-mark t]
2540 ["Yank" gnus-summary-yank-process-mark
2541 gnus-newsgroup-process-stack]
2542 ["Save" gnus-summary-save-process-mark t]
2543 ["Run command on marked..." gnus-summary-universal-argument t]))
2545 ["Page forward" gnus-summary-next-page
2546 ,@(if (featurep 'xemacs) '(t)
2547 '(:help "Show next page of article"))]
2548 ["Page backward" gnus-summary-prev-page
2549 ,@(if (featurep 'xemacs) '(t)
2550 '(:help "Show previous page of article"))]
2551 ["Line forward" gnus-summary-scroll-up t])
2553 ["Next unread article" gnus-summary-next-unread-article t]
2554 ["Previous unread article" gnus-summary-prev-unread-article t]
2555 ["Next article" gnus-summary-next-article t]
2556 ["Previous article" gnus-summary-prev-article t]
2557 ["Next unread subject" gnus-summary-next-unread-subject t]
2558 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2559 ["Next article same subject" gnus-summary-next-same-subject t]
2560 ["Previous article same subject" gnus-summary-prev-same-subject t]
2561 ["First unread article" gnus-summary-first-unread-article t]
2562 ["Best unread article" gnus-summary-best-unread-article t]
2563 ["Go to subject number..." gnus-summary-goto-subject t]
2564 ["Go to article number..." gnus-summary-goto-article t]
2565 ["Go to the last article" gnus-summary-goto-last-article t]
2566 ["Pop article off history" gnus-summary-pop-article t])
2568 ["Sort by number" gnus-summary-sort-by-number t]
2569 ["Sort by author" gnus-summary-sort-by-author t]
2570 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2571 ["Sort by subject" gnus-summary-sort-by-subject t]
2572 ["Sort by date" gnus-summary-sort-by-date t]
2573 ["Sort by score" gnus-summary-sort-by-score t]
2574 ["Sort by lines" gnus-summary-sort-by-lines t]
2575 ["Sort by characters" gnus-summary-sort-by-chars t]
2576 ["Randomize" gnus-summary-sort-by-random t]
2577 ["Original sort" gnus-summary-sort-by-original t])
2579 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2580 ["Describe group" gnus-summary-describe-group t]
2581 ["Fetch charter" gnus-group-fetch-charter
2582 ,@(if (featurep 'xemacs) nil
2583 '(:help "Display the charter of the current group"))]
2584 ["Fetch control message" gnus-group-fetch-control
2585 ,@(if (featurep 'xemacs) nil
2586 '(:help "Display the archived control message for the current group"))]
2587 ["Read manual" gnus-info-find-node t])
2589 ["Pick and read" gnus-pick-mode t]
2590 ["Binary" gnus-binary-mode t])
2592 ["Regenerate" gnus-summary-prepare t]
2593 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2594 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2595 ["Toggle threading" gnus-summary-toggle-threads t])
2596 ["See old articles" gnus-summary-insert-old-articles t]
2597 ["See new articles" gnus-summary-insert-new-articles t]
2598 ["Filter articles..." gnus-summary-execute-command t]
2599 ["Run command on articles..." gnus-summary-universal-argument t]
2600 ["Search articles forward..." gnus-summary-search-article-forward t]
2601 ["Search articles backward..." gnus-summary-search-article-backward t]
2602 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2603 ["Expand window" gnus-summary-expand-window t]
2604 ["Expire expirable articles" gnus-summary-expire-articles
2605 (gnus-check-backend-function
2606 'request-expire-articles gnus-newsgroup-name)]
2607 ["Edit local kill file" gnus-summary-edit-local-kill t]
2608 ["Edit main kill file" gnus-summary-edit-global-kill t]
2609 ["Edit group parameters" gnus-summary-edit-parameters t]
2610 ["Customize group parameters" gnus-summary-customize-parameters t]
2611 ["Send a bug report" gnus-bug t]
2613 ["Catchup and exit" gnus-summary-catchup-and-exit
2614 ,@(if (featurep 'xemacs) '(t)
2615 '(:help "Mark unread articles in this group as read, then exit"))]
2616 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2617 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2618 ["Exit group" gnus-summary-exit
2619 ,@(if (featurep 'xemacs) '(t)
2620 '(:help "Exit current group, return to group selection mode"))]
2621 ["Exit group without updating" gnus-summary-exit-no-update t]
2622 ["Exit and goto next group" gnus-summary-next-group t]
2623 ["Exit and goto prev group" gnus-summary-prev-group t]
2624 ["Reselect group" gnus-summary-reselect-current-group t]
2625 ["Rescan group" gnus-summary-rescan-group t]
2626 ["Update dribble" gnus-summary-save-newsrc t])))
2628 (gnus-run-hooks 'gnus-summary-menu-hook)))
2630 (defvar gnus-summary-tool-bar-map nil)
2632 ;; Emacs 21 tool bar. Should be no-op otherwise.
2633 (defun gnus-summary-make-tool-bar ()
2634 (if (and (fboundp 'tool-bar-add-item-from-menu)
2635 (default-value 'tool-bar-mode)
2636 (not gnus-summary-tool-bar-map))
2637 (setq gnus-summary-tool-bar-map
2638 (let ((tool-bar-map (make-sparse-keymap))
2639 (load-path (mm-image-load-path)))
2640 (tool-bar-add-item-from-menu
2641 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2642 (tool-bar-add-item-from-menu
2643 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2644 (tool-bar-add-item-from-menu
2645 'gnus-summary-post-news "post" gnus-summary-mode-map)
2646 (tool-bar-add-item-from-menu
2647 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2648 (tool-bar-add-item-from-menu
2649 'gnus-summary-followup "followup" gnus-summary-mode-map)
2650 (tool-bar-add-item-from-menu
2651 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2652 (tool-bar-add-item-from-menu
2653 'gnus-summary-reply "reply" gnus-summary-mode-map)
2654 (tool-bar-add-item-from-menu
2655 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2656 (tool-bar-add-item-from-menu
2657 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2658 (tool-bar-add-item-from-menu
2659 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2660 (tool-bar-add-item-from-menu
2661 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2662 (tool-bar-add-item-from-menu
2663 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2664 (tool-bar-add-item-from-menu
2665 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2666 (tool-bar-add-item-from-menu
2667 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2668 (tool-bar-add-item-from-menu
2669 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2670 (tool-bar-add-item-from-menu
2671 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2673 (if gnus-summary-tool-bar-map
2674 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2676 (defun gnus-score-set-default (var value)
2677 "A version of set that updates the GNU Emacs menu-bar."
2679 ;; It is the message that forces the active status to be updated.
2682 (defun gnus-make-score-map (type)
2683 "Make a summary score map of type TYPE."
2686 (let ((headers '(("author" "from" string)
2687 ("subject" "subject" string)
2688 ("article body" "body" string)
2689 ("article head" "head" string)
2690 ("xref" "xref" string)
2691 ("extra header" "extra" string)
2692 ("lines" "lines" number)
2693 ("followups to author" "followup" string)))
2694 (types '((number ("less than" <)
2697 (string ("substring" s)
2701 (perms '(("temporary" (current-time-string))
2709 (if (eq type 'lower)
2714 (setq header (car headers))
2720 (let ((ts (cdr (assoc (nth 2 header) types)))
2736 'gnus-summary-score-entry
2738 (if (or (string= (nth 1 header)
2740 (string= (nth 1 header)
2743 (list 'gnus-summary-header
2745 (list 'quote (nth 1 (car ts)))
2746 (list 'gnus-score-delta-default
2753 (list (nreverse outp))))
2756 (list (nreverse outt))))
2758 (setq headers (cdr headers)))
2759 (list (nreverse outh))))))))
2763 (defun gnus-summary-mode (&optional group)
2764 "Major mode for reading articles.
2766 All normal editing commands are switched off.
2767 \\<gnus-summary-mode-map>
2768 Each line in this buffer represents one article. To read an
2769 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2770 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2773 You can also post articles and send mail from this buffer. To
2774 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2775 of an article, type `\\[gnus-summary-reply]'.
2777 There are approx. one gazillion commands you can execute in this
2778 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2780 The following commands are available:
2782 \\{gnus-summary-mode-map}"
2784 (kill-all-local-variables)
2785 (when (gnus-visual-p 'summary-menu 'menu)
2786 (gnus-summary-make-menu-bar)
2787 (gnus-summary-make-tool-bar))
2788 (gnus-summary-make-local-variables)
2789 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2790 (gnus-summary-make-local-variables))
2791 (gnus-make-thread-indent-array)
2792 (gnus-simplify-mode-line)
2793 (setq major-mode 'gnus-summary-mode)
2794 (setq mode-name "Summary")
2795 (make-local-variable 'minor-mode-alist)
2796 (use-local-map gnus-summary-mode-map)
2797 (buffer-disable-undo)
2798 (setq buffer-read-only t ;Disable modification
2799 show-trailing-whitespace nil)
2800 (setq truncate-lines t)
2801 (setq selective-display t)
2802 (setq selective-display-ellipses t) ;Display `...'
2803 (gnus-summary-set-display-table)
2804 (gnus-set-default-directory)
2805 (setq gnus-newsgroup-name group)
2806 (make-local-variable 'gnus-summary-line-format)
2807 (make-local-variable 'gnus-summary-line-format-spec)
2808 (make-local-variable 'gnus-summary-dummy-line-format)
2809 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2810 (make-local-variable 'gnus-summary-mark-positions)
2811 (gnus-make-local-hook 'pre-command-hook)
2812 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2813 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2814 (turn-on-gnus-mailing-list-mode)
2815 (mm-enable-multibyte)
2816 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2817 (gnus-update-summary-mark-positions))
2819 (defun gnus-summary-make-local-variables ()
2820 "Make all the local summary buffer variables."
2822 (dolist (local gnus-summary-local-variables)
2825 (if (eq (cdr local) 'global)
2826 ;; Copy the global value of the variable.
2827 (setq global (symbol-value (car local)))
2828 ;; Use the value from the list.
2829 (setq global (eval (cdr local))))
2830 (set (make-local-variable (car local)) global))
2831 ;; Simple nil-valued local variable.
2832 (set (make-local-variable local) nil)))))
2834 (defun gnus-summary-clear-local-variables ()
2835 (let ((locals gnus-summary-local-variables))
2837 (if (consp (car locals))
2838 (and (symbolp (caar locals))
2839 (set (caar locals) nil))
2840 (and (symbolp (car locals))
2841 (set (car locals) nil)))
2842 (setq locals (cdr locals)))))
2844 ;; Summary data functions.
2846 (defmacro gnus-data-number (data)
2849 (defmacro gnus-data-set-number (data number)
2850 `(setcar ,data ,number))
2852 (defmacro gnus-data-mark (data)
2855 (defmacro gnus-data-set-mark (data mark)
2856 `(setcar (nthcdr 1 ,data) ,mark))
2858 (defmacro gnus-data-pos (data)
2861 (defmacro gnus-data-set-pos (data pos)
2862 `(setcar (nthcdr 2 ,data) ,pos))
2864 (defmacro gnus-data-header (data)
2867 (defmacro gnus-data-set-header (data header)
2868 `(setf (nth 3 ,data) ,header))
2870 (defmacro gnus-data-level (data)
2873 (defmacro gnus-data-unread-p (data)
2874 `(= (nth 1 ,data) gnus-unread-mark))
2876 (defmacro gnus-data-read-p (data)
2877 `(/= (nth 1 ,data) gnus-unread-mark))
2879 (defmacro gnus-data-pseudo-p (data)
2880 `(consp (nth 3 ,data)))
2882 (defmacro gnus-data-find (number)
2883 `(assq ,number gnus-newsgroup-data))
2885 (defmacro gnus-data-find-list (number &optional data)
2886 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2887 (memq (assq ,number bdata)
2890 (defmacro gnus-data-make (number mark pos header level)
2891 `(list ,number ,mark ,pos ,header ,level))
2893 (defun gnus-data-enter (after-article number mark pos header level offset)
2894 (let ((data (gnus-data-find-list after-article)))
2896 (error "No such article: %d" after-article))
2897 (setcdr data (cons (gnus-data-make number mark pos header level)
2899 (setq gnus-newsgroup-data-reverse nil)
2900 (gnus-data-update-list (cddr data) offset)))
2902 (defun gnus-data-enter-list (after-article list &optional offset)
2904 (let ((data (and after-article (gnus-data-find-list after-article)))
2908 (let ((odata gnus-newsgroup-data))
2909 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2911 (gnus-data-update-list odata offset)))
2912 ;; Find the last element in the list to be spliced into the main
2914 (setq list (last list))
2917 (setcdr list gnus-newsgroup-data)
2918 (setq gnus-newsgroup-data ilist)
2920 (gnus-data-update-list (cdr list) offset)))
2921 (setcdr list (cdr data))
2924 (gnus-data-update-list (cdr list) offset))))
2925 (setq gnus-newsgroup-data-reverse nil))))
2927 (defun gnus-data-remove (article &optional offset)
2928 (let ((data gnus-newsgroup-data))
2929 (if (= (gnus-data-number (car data)) article)
2931 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2932 gnus-newsgroup-data-reverse nil)
2934 (gnus-data-update-list gnus-newsgroup-data offset)))
2936 (when (= (gnus-data-number (cadr data)) article)
2937 (setcdr data (cddr data))
2939 (gnus-data-update-list (cdr data) offset))
2941 gnus-newsgroup-data-reverse nil))
2942 (setq data (cdr data))))))
2944 (defmacro gnus-data-list (backward)
2946 (or gnus-newsgroup-data-reverse
2947 (setq gnus-newsgroup-data-reverse
2948 (reverse gnus-newsgroup-data)))
2949 gnus-newsgroup-data))
2951 (defun gnus-data-update-list (data offset)
2952 "Add OFFSET to the POS of all data entries in DATA."
2953 (setq gnus-newsgroup-data-reverse nil)
2955 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2956 (setq data (cdr data))))
2958 (defun gnus-summary-article-pseudo-p (article)
2959 "Say whether this article is a pseudo article or not."
2960 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2962 (defmacro gnus-summary-article-sparse-p (article)
2963 "Say whether this article is a sparse article or not."
2964 `(memq ,article gnus-newsgroup-sparse))
2966 (defmacro gnus-summary-article-ancient-p (article)
2967 "Say whether this article is a sparse article or not."
2968 `(memq ,article gnus-newsgroup-ancient))
2970 (defun gnus-article-parent-p (number)
2971 "Say whether this article is a parent or not."
2972 (let ((data (gnus-data-find-list number)))
2973 (and (cdr data) ; There has to be an article after...
2974 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2975 (gnus-data-level (nth 1 data))))))
2977 (defun gnus-article-children (number)
2978 "Return a list of all children to NUMBER."
2979 (let* ((data (gnus-data-find-list number))
2980 (level (gnus-data-level (car data)))
2982 (setq data (cdr data))
2984 (= (gnus-data-level (car data)) (1+ level)))
2985 (push (gnus-data-number (car data)) children)
2986 (setq data (cdr data)))
2989 (defmacro gnus-summary-skip-intangible ()
2990 "If the current article is intangible, then jump to a different article."
2991 '(let ((to (get-text-property (point) 'gnus-intangible)))
2992 (and to (gnus-summary-goto-subject to))))
2994 (defmacro gnus-summary-article-intangible-p ()
2995 "Say whether this article is intangible or not."
2996 '(get-text-property (point) 'gnus-intangible))
2998 (defun gnus-article-read-p (article)
2999 "Say whether ARTICLE is read or not."
3000 (not (or (memq article gnus-newsgroup-marked)
3001 (memq article gnus-newsgroup-spam-marked)
3002 (memq article gnus-newsgroup-unreads)
3003 (memq article gnus-newsgroup-unselected)
3004 (memq article gnus-newsgroup-dormant))))
3006 ;; Some summary mode macros.
3008 (defmacro gnus-summary-article-number ()
3009 "The article number of the article on the current line.
3010 If there isn't an article number here, then we return the current
3013 (gnus-summary-skip-intangible)
3014 (or (get-text-property (point) 'gnus-number)
3015 (gnus-summary-last-subject))))
3017 (defmacro gnus-summary-article-header (&optional number)
3018 "Return the header of article NUMBER."
3019 `(gnus-data-header (gnus-data-find
3020 ,(or number '(gnus-summary-article-number)))))
3022 (defmacro gnus-summary-thread-level (&optional number)
3023 "Return the level of thread that starts with article NUMBER."
3024 `(if (and (eq gnus-summary-make-false-root 'dummy)
3025 (get-text-property (point) 'gnus-intangible))
3027 (gnus-data-level (gnus-data-find
3028 ,(or number '(gnus-summary-article-number))))))
3030 (defmacro gnus-summary-article-mark (&optional number)
3031 "Return the mark of article NUMBER."
3032 `(gnus-data-mark (gnus-data-find
3033 ,(or number '(gnus-summary-article-number)))))
3035 (defmacro gnus-summary-article-pos (&optional number)
3036 "Return the position of the line of article NUMBER."
3037 `(gnus-data-pos (gnus-data-find
3038 ,(or number '(gnus-summary-article-number)))))
3040 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3041 (defmacro gnus-summary-article-subject (&optional number)
3042 "Return current subject string or nil if nothing."
3045 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3046 '(gnus-data-header (assq (gnus-summary-article-number)
3047 gnus-newsgroup-data)))))
3050 (mail-header-subject headers))))
3052 (defmacro gnus-summary-article-score (&optional number)
3053 "Return current article score."
3054 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3055 gnus-newsgroup-scored))
3056 gnus-summary-default-score 0))
3058 (defun gnus-summary-article-children (&optional number)
3059 "Return a list of article numbers that are children of article NUMBER."
3060 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3061 (level (gnus-data-level (car data)))
3063 (while (and (setq data (cdr data))
3064 (> (setq l (gnus-data-level (car data))) level))
3065 (and (= (1+ level) l)
3066 (push (gnus-data-number (car data))
3068 (nreverse children)))
3070 (defun gnus-summary-article-parent (&optional number)
3071 "Return the article number of the parent of article NUMBER."
3072 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3073 (gnus-data-list t)))
3074 (level (gnus-data-level (car data))))
3076 () ; This is a root.
3077 ;; We search until we find an article with a level less than
3078 ;; this one. That function has to be the parent.
3079 (while (and (setq data (cdr data))
3080 (not (< (gnus-data-level (car data)) level))))
3081 (and data (gnus-data-number (car data))))))
3083 (defun gnus-unread-mark-p (mark)
3084 "Say whether MARK is the unread mark."
3085 (= mark gnus-unread-mark))
3087 (defun gnus-read-mark-p (mark)
3088 "Say whether MARK is one of the marks that mark as read.
3089 This is all marks except unread, ticked, dormant, and expirable."
3090 (not (or (= mark gnus-unread-mark)
3091 (= mark gnus-ticked-mark)
3092 (= mark gnus-spam-mark)
3093 (= mark gnus-dormant-mark)
3094 (= mark gnus-expirable-mark))))
3096 (defmacro gnus-article-mark (number)
3097 "Return the MARK of article NUMBER.
3098 This macro should only be used when computing the mark the \"first\"
3099 time; i.e., when generating the summary lines. After that,
3100 `gnus-summary-article-mark' should be used to examine the
3103 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3104 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3105 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3106 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3107 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3108 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3109 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3110 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3111 gnus-ancient-mark))))
3113 ;; Saving hidden threads.
3115 (defmacro gnus-save-hidden-threads (&rest forms)
3116 "Save hidden threads, eval FORMS, and restore the hidden threads."
3117 (let ((config (make-symbol "config")))
3118 `(let ((,config (gnus-hidden-threads-configuration)))
3122 (gnus-restore-hidden-threads-configuration ,config)))))
3123 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3124 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3126 (defun gnus-data-compute-positions ()
3127 "Compute the positions of all articles."
3128 (setq gnus-newsgroup-data-reverse nil)
3129 (let ((data gnus-newsgroup-data))
3131 (gnus-save-hidden-threads
3132 (gnus-summary-show-all-threads)
3133 (goto-char (point-min))
3135 (while (get-text-property (point) 'gnus-intangible)
3137 (gnus-data-set-pos (car data) (+ (point) 3))
3138 (setq data (cdr data))
3139 (forward-line 1))))))
3141 (defun gnus-hidden-threads-configuration ()
3142 "Return the current hidden threads configuration."
3145 (goto-char (point-min))
3146 (while (search-forward "\r" nil t)
3147 (push (1- (point)) config))
3150 (defun gnus-restore-hidden-threads-configuration (config)
3151 "Restore hidden threads configuration from CONFIG."
3153 (let (point buffer-read-only)
3154 (while (setq point (pop config))
3155 (when (and (< point (point-max))
3157 (eq (char-after) ?\n))
3158 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3160 ;; Various summary mode internalish functions.
3162 (defun gnus-mouse-pick-article (e)
3165 (gnus-summary-next-page nil t))
3167 (defun gnus-summary-set-display-table ()
3168 "Change the display table.
3169 Odd characters have a tendency to mess
3170 up nicely formatted displays - we make all possible glyphs
3171 display only a single character."
3173 ;; We start from the standard display table, if any.
3174 (let ((table (or (copy-sequence standard-display-table)
3175 (make-display-table)))
3177 ;; Nix out all the control chars...
3178 (while (>= (setq i (1- i)) 0)
3179 (aset table i [??]))
3180 ;; ... but not newline and cr, of course. (cr is necessary for the
3181 ;; selective display).
3182 (aset table ?\n nil)
3183 (aset table ?\r nil)
3184 ;; We keep TAB as well.
3185 (aset table ?\t nil)
3186 ;; We nix out any glyphs over 126 that are not set already.
3188 (while (>= (setq i (1- i)) 127)
3189 ;; Only modify if the entry is nil.
3190 (unless (aref table i)
3191 (aset table i [??]))))
3192 (setq buffer-display-table table)))
3194 (defun gnus-summary-set-article-display-arrow (pos)
3195 "Update the overlay arrow to point to line at position POS."
3196 (when (and gnus-summary-display-arrow
3197 (boundp 'overlay-arrow-position)
3198 (boundp 'overlay-arrow-string))
3202 (unless overlay-arrow-position
3203 (setq overlay-arrow-position (make-marker)))
3204 (setq overlay-arrow-string "=>"
3205 overlay-arrow-position (set-marker overlay-arrow-position
3207 (current-buffer))))))
3209 (defun gnus-summary-setup-buffer (group)
3210 "Initialize summary buffer."
3211 (let ((buffer (gnus-summary-buffer-name group))
3212 (dead-name (concat "*Dead Summary "
3213 (gnus-group-decoded-name group) "*")))
3214 ;; If a dead summary buffer exists, we kill it.
3215 (when (gnus-buffer-live-p dead-name)
3216 (gnus-kill-buffer dead-name))
3217 (if (get-buffer buffer)
3220 (setq gnus-summary-buffer (current-buffer))
3221 (not gnus-newsgroup-prepared))
3222 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3223 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3224 (gnus-summary-mode group)
3226 (gnus-carpal-setup-buffer 'summary))
3227 (unless gnus-single-article-buffer
3228 (make-local-variable 'gnus-article-buffer)
3229 (make-local-variable 'gnus-article-current)
3230 (make-local-variable 'gnus-original-article-buffer))
3231 (setq gnus-newsgroup-name group)
3232 ;; Set any local variables in the group parameters.
3233 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3236 (defun gnus-set-global-variables ()
3237 "Set the global equivalents of the buffer-local variables.
3238 They are set to the latest values they had. These reflect the summary
3239 buffer that was in action when the last article was fetched."
3240 (when (eq major-mode 'gnus-summary-mode)
3241 (setq gnus-summary-buffer (current-buffer))
3242 (let ((name gnus-newsgroup-name)
3243 (marked gnus-newsgroup-marked)
3244 (spam gnus-newsgroup-spam-marked)
3245 (unread gnus-newsgroup-unreads)
3246 (headers gnus-current-headers)
3247 (data gnus-newsgroup-data)
3248 (summary gnus-summary-buffer)
3249 (article-buffer gnus-article-buffer)
3250 (original gnus-original-article-buffer)
3251 (gac gnus-article-current)
3252 (reffed gnus-reffed-article-number)
3253 (score-file gnus-current-score-file)
3254 (default-charset gnus-newsgroup-charset)
3256 (let ((locals gnus-newsgroup-variables))
3258 (if (consp (car locals))
3259 (push (eval (caar locals)) vlist)
3260 (push (eval (car locals)) vlist))
3261 (setq locals (cdr locals)))
3262 (setq vlist (nreverse vlist)))
3263 (with-current-buffer gnus-group-buffer
3264 (setq gnus-newsgroup-name name
3265 gnus-newsgroup-marked marked
3266 gnus-newsgroup-spam-marked spam
3267 gnus-newsgroup-unreads unread
3268 gnus-current-headers headers
3269 gnus-newsgroup-data data
3270 gnus-article-current gac
3271 gnus-summary-buffer summary
3272 gnus-article-buffer article-buffer
3273 gnus-original-article-buffer original
3274 gnus-reffed-article-number reffed
3275 gnus-current-score-file score-file
3276 gnus-newsgroup-charset default-charset)
3277 (let ((locals gnus-newsgroup-variables))
3279 (if (consp (car locals))
3280 (set (caar locals) (pop vlist))
3281 (set (car locals) (pop vlist)))
3282 (setq locals (cdr locals))))
3283 ;; The article buffer also has local variables.
3284 (when (gnus-buffer-live-p gnus-article-buffer)
3285 (set-buffer gnus-article-buffer)
3286 (setq gnus-summary-buffer summary))))))
3288 (defun gnus-summary-article-unread-p (article)
3289 "Say whether ARTICLE is unread or not."
3290 (memq article gnus-newsgroup-unreads))
3292 (defun gnus-summary-first-article-p (&optional article)
3293 "Return whether ARTICLE is the first article in the buffer."
3294 (if (not (setq article (or article (gnus-summary-article-number))))
3296 (eq article (caar gnus-newsgroup-data))))
3298 (defun gnus-summary-last-article-p (&optional article)
3299 "Return whether ARTICLE is the last article in the buffer."
3300 (if (not (setq article (or article (gnus-summary-article-number))))
3301 ;; All non-existent numbers are the last article. :-)
3303 (not (cdr (gnus-data-find-list article)))))
3305 (defun gnus-make-thread-indent-array ()
3307 (unless (and gnus-thread-indent-array
3308 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3309 (setq gnus-thread-indent-array (make-vector 201 "")
3310 gnus-thread-indent-array-level gnus-thread-indent-level)
3312 (aset gnus-thread-indent-array n
3313 (make-string (* n gnus-thread-indent-level) ? ))
3316 (defun gnus-update-summary-mark-positions ()
3317 "Compute where the summary marks are to go."
3319 (when (gnus-buffer-exists-p gnus-summary-buffer)
3320 (set-buffer gnus-summary-buffer))
3321 (let ((spec gnus-summary-line-format-spec)
3324 (gnus-set-work-buffer)
3325 (let ((gnus-tmp-unread ?Z)
3326 (gnus-replied-mark ?Z)
3327 (gnus-score-below-mark ?Z)
3328 (gnus-score-over-mark ?Z)
3329 (gnus-undownloaded-mark ?Z)
3330 (gnus-summary-line-format-spec spec)
3331 (gnus-newsgroup-downloadable '(0))
3332 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3333 case-fold-search ignores)
3334 ;; Here, all marks are bound to Z.
3335 (gnus-summary-insert-line header
3336 0 nil t gnus-tmp-unread t nil "" nil 1)
3337 (goto-char (point-min))
3338 ;; Memorize the positions of the same characters as dummy marks.
3339 (while (re-search-forward "[A-D]" nil t)
3340 (push (point) ignores))
3342 ;; We use A-D as dummy marks in order to know column positions
3343 ;; where marks should be inserted.
3344 (setq gnus-tmp-unread ?A
3345 gnus-replied-mark ?B
3346 gnus-score-below-mark ?C
3347 gnus-score-over-mark ?C
3348 gnus-undownloaded-mark ?D)
3349 (gnus-summary-insert-line header
3350 0 nil t gnus-tmp-unread t nil "" nil 1)
3351 ;; Ignore characters which aren't dummy marks.
3353 (delete-region (goto-char (1- p)) p)
3355 (goto-char (point-min))
3356 (setq pos (list (cons 'unread
3357 (and (search-forward "A" nil t)
3358 (- (point) (point-min) 1)))))
3359 (goto-char (point-min))
3360 (push (cons 'replied (and (search-forward "B" nil t)
3361 (- (point) (point-min) 1)))
3363 (goto-char (point-min))
3364 (push (cons 'score (and (search-forward "C" nil t)
3365 (- (point) (point-min) 1)))
3367 (goto-char (point-min))
3368 (push (cons 'download (and (search-forward "D" nil t)
3369 (- (point) (point-min) 1)))
3371 (setq gnus-summary-mark-positions pos))))
3373 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3374 "Insert a dummy root in the summary buffer."
3376 (gnus-add-text-properties
3377 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3378 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3380 (defun gnus-summary-extract-address-component (from)
3381 (or (car (funcall gnus-extract-address-components from))
3384 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3385 (let ((mail-parse-charset gnus-newsgroup-charset)
3386 ; Is it really necessary to do this next part for each summary line?
3387 ; Luckily, doesn't seem to slow things down much.
3388 (mail-parse-ignored-charsets
3389 (with-current-buffer gnus-summary-buffer
3390 gnus-newsgroup-ignored-charsets)))
3392 (and gnus-ignored-from-addresses
3393 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3394 (let ((extra-headers (mail-header-extra header))
3398 ((setq to (cdr (assq 'To extra-headers)))
3399 (concat gnus-summary-to-prefix
3401 (gnus-summary-extract-address-component
3402 (funcall gnus-decode-encoded-word-function to)))))
3403 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3404 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3405 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3407 (defun gnus-summary-insert-line (gnus-tmp-header
3408 gnus-tmp-level gnus-tmp-current
3409 undownloaded gnus-tmp-unread gnus-tmp-replied
3410 gnus-tmp-expirable gnus-tmp-subject-or-nil
3411 &optional gnus-tmp-dummy gnus-tmp-score
3413 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3414 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3415 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3416 (gnus-tmp-score-char
3417 (if (or (null gnus-summary-default-score)
3418 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3419 gnus-summary-zcore-fuzz))
3421 (if (< gnus-tmp-score gnus-summary-default-score)
3422 gnus-score-below-mark gnus-score-over-mark)))
3423 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3425 (cond (gnus-tmp-process gnus-process-mark)
3426 ((memq gnus-tmp-current gnus-newsgroup-cached)
3428 (gnus-tmp-replied gnus-replied-mark)
3429 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3430 gnus-forwarded-mark)
3431 ((memq gnus-tmp-current gnus-newsgroup-saved)
3433 ((memq gnus-tmp-number gnus-newsgroup-recent)
3435 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3438 (gnus-tmp-downloaded
3440 gnus-undownloaded-mark)
3441 (gnus-newsgroup-agentized
3442 gnus-downloaded-mark)
3445 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3448 ((string-match "<[^>]+> *$" gnus-tmp-from)
3449 (let ((beg (match-beginning 0)))
3450 (or (and (string-match "^\".+\"" gnus-tmp-from)
3451 (substring gnus-tmp-from 1 (1- (match-end 0))))
3452 (substring gnus-tmp-from 0 beg))))
3453 ((string-match "(.+)" gnus-tmp-from)
3454 (substring gnus-tmp-from
3455 (1+ (match-beginning 0)) (1- (match-end 0))))
3457 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3458 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3459 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3460 (buffer-read-only nil))
3461 (when (string= gnus-tmp-name "")
3462 (setq gnus-tmp-name gnus-tmp-from))
3463 (unless (numberp gnus-tmp-lines)
3464 (setq gnus-tmp-lines -1))
3465 (if (= gnus-tmp-lines -1)
3466 (setq gnus-tmp-lines "?")
3467 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3468 (gnus-put-text-property
3470 (progn (eval gnus-summary-line-format-spec) (point))
3471 'gnus-number gnus-tmp-number)
3472 (when (gnus-visual-p 'summary-highlight 'highlight)
3474 (gnus-run-hooks 'gnus-summary-update-hook)
3477 (defun gnus-summary-update-line (&optional dont-update)
3478 "Update summary line after change."
3479 (when (and gnus-summary-default-score
3480 (not gnus-summary-inhibit-highlight))
3481 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3482 (article (gnus-summary-article-number))
3483 (score (gnus-summary-article-score article)))
3485 (if (and gnus-summary-mark-below
3486 (< (gnus-summary-article-score)
3487 gnus-summary-mark-below))
3488 ;; This article has a low score, so we mark it as read.
3489 (when (memq article gnus-newsgroup-unreads)
3490 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3491 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3492 ;; This article was previously marked as read on account
3493 ;; of a low score, but now it has risen, so we mark it as
3495 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3496 (gnus-summary-update-mark
3497 (if (or (null gnus-summary-default-score)
3498 (<= (abs (- score gnus-summary-default-score))
3499 gnus-summary-zcore-fuzz))
3501 (if (< score gnus-summary-default-score)
3502 gnus-score-below-mark gnus-score-over-mark))
3504 ;; Do visual highlighting.
3505 (when (gnus-visual-p 'summary-highlight 'highlight)
3506 (gnus-run-hooks 'gnus-summary-update-hook)))))
3508 (defvar gnus-tmp-new-adopts nil)
3510 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3511 "Return the number of articles in THREAD.
3512 This may be 0 in some cases -- if none of the articles in
3513 the thread are to be displayed."
3515 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3517 ((not (listp thread))
3519 ((and (consp thread) (cdr thread))
3522 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3525 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3528 (when (and level (zerop level) gnus-tmp-new-adopts)
3531 'gnus-summary-number-of-articles-in-thread
3532 gnus-tmp-new-adopts))))
3534 (if (> number 1) gnus-not-empty-thread-mark
3535 gnus-empty-thread-mark)
3538 (defsubst gnus-summary-line-message-size (head)
3539 "Return pretty-printed version of message size.
3540 This function is intended to be used in
3541 `gnus-summary-line-format-alist'."
3542 (let ((c (or (mail-header-chars head) -1)))
3543 (cond ((< c 0) "n/a") ; chars not available
3544 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3545 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3546 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3547 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3550 (defun gnus-summary-set-local-parameters (group)
3551 "Go through the local params of GROUP and set all variable specs in that list."
3552 (let ((vars '(quit-config))) ; Ignore quit-config.
3553 (dolist (elem (gnus-group-find-parameter group))
3554 (and (consp elem) ; Has to be a cons.
3555 (consp (cdr elem)) ; The cdr has to be a list.
3556 (symbolp (car elem)) ; Has to be a symbol in there.
3557 (not (memq (car elem) vars))
3558 (ignore-errors ; So we set it.
3559 (push (car elem) vars)
3560 (make-local-variable (car elem))
3561 (set (car elem) (eval (nth 1 elem))))))))
3563 (defun gnus-summary-read-group (group &optional show-all no-article
3564 kill-buffer no-display backward
3566 "Start reading news in newsgroup GROUP.
3567 If SHOW-ALL is non-nil, already read articles are also listed.
3568 If NO-ARTICLE is non-nil, no article is selected initially.
3569 If NO-DISPLAY, don't generate a summary buffer."
3573 (let ((gnus-auto-select-next nil))
3574 (or (gnus-summary-read-group-1
3575 group show-all no-article
3576 kill-buffer no-display
3579 select-articles nil)))))
3580 (eq gnus-auto-select-next 'quietly))
3581 (set-buffer gnus-group-buffer)
3582 ;; The entry function called above goes to the next
3583 ;; group automatically, so we go two groups back
3584 ;; if we are searching for the previous group.
3586 (gnus-group-prev-unread-group 2))
3587 (if (not (equal group (gnus-group-group-name)))
3588 (setq group (gnus-group-group-name))
3592 (defun gnus-summary-read-group-1 (group show-all no-article
3593 kill-buffer no-display
3594 &optional select-articles)
3595 ;; Killed foreign groups can't be entered.
3596 ;; (when (and (not (gnus-group-native-p group))
3597 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3598 ;; (error "Dead non-native groups can't be entered"))
3599 (gnus-message 5 "Retrieving newsgroup: %s..."
3600 (gnus-group-decoded-name group))
3601 (let* ((new-group (gnus-summary-setup-buffer group))
3602 (quit-config (gnus-group-quit-config group))
3603 (did-select (and new-group (gnus-select-newsgroup
3604 group show-all select-articles))))
3606 ;; This summary buffer exists already, so we just select it.
3608 (gnus-set-global-variables)
3610 (gnus-kill-or-deaden-summary kill-buffer))
3611 (gnus-configure-windows 'summary 'force)
3612 (gnus-set-mode-line 'summary)
3613 (gnus-summary-position-point)
3616 ;; We couldn't select this group.
3618 (when (and (eq major-mode 'gnus-summary-mode)
3619 (not (equal (current-buffer) kill-buffer)))
3620 (kill-buffer (current-buffer))
3621 (if (not quit-config)
3623 ;; Update the info -- marks might need to be removed,
3625 (gnus-summary-update-info)
3626 (set-buffer gnus-group-buffer)
3627 (gnus-group-jump-to-group group)
3628 (gnus-group-next-unread-group 1))
3629 (gnus-handle-ephemeral-exit quit-config)))
3630 (let ((grpinfo (gnus-get-info group)))
3631 (if (null (gnus-info-read grpinfo))
3632 (gnus-message 3 "Group %s contains no messages"
3633 (gnus-group-decoded-name group))
3634 (gnus-message 3 "Can't select group")))
3636 ;; The user did a `C-g' while prompting for number of articles,
3637 ;; so we exit this group.
3638 ((eq did-select 'quit)
3639 (and (eq major-mode 'gnus-summary-mode)
3640 (not (equal (current-buffer) kill-buffer))
3641 (kill-buffer (current-buffer)))
3643 (gnus-kill-or-deaden-summary kill-buffer))
3644 (if (not quit-config)
3646 (set-buffer gnus-group-buffer)
3647 (gnus-group-jump-to-group group)
3648 (gnus-group-next-unread-group 1)
3649 (gnus-configure-windows 'group 'force))
3650 (gnus-handle-ephemeral-exit quit-config))
3651 ;; Finally signal the quit.
3653 ;; The group was successfully selected.
3655 (gnus-set-global-variables)
3656 ;; Save the active value in effect when the group was entered.
3657 (setq gnus-newsgroup-active
3659 (gnus-active gnus-newsgroup-name)))
3660 ;; You can change the summary buffer in some way with this hook.
3661 (gnus-run-hooks 'gnus-select-group-hook)
3662 (when (memq 'summary (gnus-update-format-specifications
3663 nil 'summary 'summary-mode 'summary-dummy))
3664 ;; The format specification for the summary line was updated,
3665 ;; so we need to update the mark positions as well.
3666 (gnus-update-summary-mark-positions))
3667 ;; Do score processing.
3668 (when gnus-use-scoring
3669 (gnus-possibly-score-headers))
3670 ;; Check whether to fill in the gaps in the threads.
3671 (when gnus-build-sparse-threads
3672 (gnus-build-sparse-threads))
3673 ;; Find the initial limit.
3675 (let ((gnus-newsgroup-dormant nil))
3676 (gnus-summary-initial-limit show-all))
3677 (gnus-summary-initial-limit show-all))
3678 ;; Generate the summary buffer.
3680 (gnus-summary-prepare))
3681 (when gnus-use-trees
3682 (gnus-tree-open group)
3683 (setq gnus-summary-highlight-line-function
3684 'gnus-tree-highlight-article))
3685 ;; If the summary buffer is empty, but there are some low-scored
3686 ;; articles or some excluded dormants, we include these in the
3688 (when (and (zerop (buffer-size))
3690 (cond (gnus-newsgroup-dormant
3691 (gnus-summary-limit-include-dormant))
3692 ((and gnus-newsgroup-scored show-all)
3693 (gnus-summary-limit-include-expunged t))))
3694 ;; Function `gnus-apply-kill-file' must be called in this hook.
3695 (gnus-run-hooks 'gnus-apply-kill-hook)
3696 (if (and (zerop (buffer-size))
3699 ;; This newsgroup is empty.
3700 (gnus-summary-catchup-and-exit nil t)
3701 (gnus-message 6 "No unread news")
3703 (gnus-kill-or-deaden-summary kill-buffer))
3704 ;; Return nil from this function.
3706 ;; Hide conversation thread subtrees. We cannot do this in
3707 ;; gnus-summary-prepare-hook since kill processing may not
3708 ;; work with hidden articles.
3709 (gnus-summary-maybe-hide-threads)
3711 (gnus-kill-or-deaden-summary kill-buffer))
3712 (gnus-summary-auto-select-subject)
3713 ;; Show first unread article if requested.
3714 (if (and (not no-article)
3716 gnus-newsgroup-unreads
3717 gnus-auto-select-first)
3719 (gnus-configure-windows 'summary)
3720 (let ((art (gnus-summary-article-number)))
3721 (unless (and (not gnus-plugged)
3722 (or (memq art gnus-newsgroup-undownloaded)
3723 (memq art gnus-newsgroup-downloadable)))
3724 (gnus-summary-goto-article art))))
3725 ;; Don't select any articles.
3726 (gnus-summary-position-point)
3727 (gnus-configure-windows 'summary 'force)
3728 (gnus-set-mode-line 'summary))
3729 (when (and gnus-auto-center-group
3730 (get-buffer-window gnus-group-buffer t))
3731 ;; Gotta use windows, because recenter does weird stuff if
3732 ;; the current buffer ain't the displayed window.
3733 (let ((owin (selected-window)))
3734 (select-window (get-buffer-window gnus-group-buffer t))
3735 (when (gnus-group-goto-group group)
3737 (select-window owin)))
3738 ;; Mark this buffer as "prepared".
3739 (setq gnus-newsgroup-prepared t)
3740 (gnus-run-hooks 'gnus-summary-prepared-hook)
3741 (unless (gnus-ephemeral-group-p group)
3742 (gnus-group-update-group group))
3745 (defun gnus-summary-auto-select-subject ()
3746 "Select the subject line on initial group entry."
3747 (goto-char (point-min))
3749 ((eq gnus-auto-select-subject 'best)
3750 (gnus-summary-best-unread-subject))
3751 ((eq gnus-auto-select-subject 'unread)
3752 (gnus-summary-first-unread-subject))
3753 ((eq gnus-auto-select-subject 'unseen)
3754 (gnus-summary-first-unseen-subject))
3755 ((eq gnus-auto-select-subject 'unseen-or-unread)
3756 (gnus-summary-first-unseen-or-unread-subject))
3757 ((eq gnus-auto-select-subject 'first)
3760 ((functionp gnus-auto-select-subject)
3761 (funcall gnus-auto-select-subject))))
3763 (defun gnus-summary-prepare ()
3764 "Generate the summary buffer."
3766 (let ((buffer-read-only nil))
3768 (setq gnus-newsgroup-data nil
3769 gnus-newsgroup-data-reverse nil)
3770 (gnus-run-hooks 'gnus-summary-generate-hook)
3771 ;; Generate the buffer, either with threads or without.
3772 (when gnus-newsgroup-headers
3773 (gnus-summary-prepare-threads
3774 (if gnus-show-threads
3775 (gnus-sort-gathered-threads
3776 (funcall gnus-summary-thread-gathering-function
3778 (gnus-cut-threads (gnus-make-threads)))))
3779 ;; Unthreaded display.
3780 (gnus-sort-articles gnus-newsgroup-headers))))
3781 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3782 ;; Call hooks for modifying summary buffer.
3783 (goto-char (point-min))
3784 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3786 (defsubst gnus-general-simplify-subject (subject)
3787 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3790 ;; Truncate the subject.
3791 (gnus-simplify-subject-functions
3792 (gnus-map-function gnus-simplify-subject-functions subject))
3793 ((numberp gnus-summary-gather-subject-limit)
3794 (setq subject (gnus-simplify-subject-re subject))
3795 (if (> (length subject) gnus-summary-gather-subject-limit)
3796 (substring subject 0 gnus-summary-gather-subject-limit)
3798 ;; Fuzzily simplify it.
3799 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3800 (gnus-simplify-subject-fuzzy subject))
3801 ;; Just remove the leading "Re:".
3803 (gnus-simplify-subject-re subject))))
3805 (if (and gnus-summary-gather-exclude-subject
3806 (string-match gnus-summary-gather-exclude-subject subject))
3807 nil ; This article shouldn't be gathered
3810 (defun gnus-summary-simplify-subject-query ()
3811 "Query where the respool algorithm would put this article."
3813 (gnus-summary-select-article)
3814 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3816 (defun gnus-gather-threads-by-subject (threads)
3817 "Gather threads by looking at Subject headers."
3818 (if (not gnus-summary-make-false-root)
3820 (let ((hashtb (gnus-make-hashtable 1024))
3823 subject hthread whole-subject)
3825 (setq subject (gnus-general-simplify-subject
3826 (setq whole-subject (mail-header-subject
3829 (if (setq hthread (gnus-gethash subject hashtb))
3831 ;; We enter a dummy root into the thread, if we
3832 ;; haven't done that already.
3833 (unless (stringp (caar hthread))
3834 (setcar hthread (list whole-subject (car hthread))))
3835 ;; We add this new gathered thread to this gathered
3837 (setcdr (car hthread)
3838 (nconc (cdar hthread) (list (car threads))))
3839 ;; Remove it from the list of threads.
3840 (setcdr prev (cdr threads))
3841 (setq threads prev))
3842 ;; Enter this thread into the hash table.
3843 (gnus-sethash subject
3844 (if gnus-summary-make-false-root-always
3846 ;; If you want a dummy root above all
3848 (setcar threads (list whole-subject
3854 (setq threads (cdr threads)))
3857 (defun gnus-gather-threads-by-references (threads)
3858 "Gather threads by looking at References headers."
3859 (let ((idhashtb (gnus-make-hashtable 1024))
3860 (thhashtb (gnus-make-hashtable 1024))
3863 ids references id gthread gid entered ref)
3865 (when (setq references (mail-header-references (caar threads)))
3866 (setq id (mail-header-id (caar threads))
3867 ids (inline (gnus-split-references references))
3869 (while (setq ref (pop ids))
3870 (setq ids (delete ref ids))
3871 (if (not (setq gid (gnus-gethash ref idhashtb)))
3873 (gnus-sethash ref id idhashtb)
3874 (gnus-sethash id threads thhashtb))
3875 (setq gthread (gnus-gethash gid thhashtb))
3877 ;; We enter a dummy root into the thread, if we
3878 ;; haven't done that already.
3879 (unless (stringp (caar gthread))
3880 (setcar gthread (list (mail-header-subject (caar gthread))
3882 ;; We add this new gathered thread to this gathered
3884 (setcdr (car gthread)
3885 (nconc (cdar gthread) (list (car threads)))))
3886 ;; Add it into the thread hash table.
3887 (gnus-sethash id gthread thhashtb)
3889 ;; Remove it from the list of threads.
3890 (setcdr prev (cdr threads))
3891 (setq threads prev))))
3893 (setq threads (cdr threads)))
3896 (defun gnus-sort-gathered-threads (threads)
3897 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3898 (let ((result threads))
3900 (when (stringp (caar threads))
3901 (setcdr (car threads)
3902 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3903 (setq threads (cdr threads)))
3906 (defun gnus-thread-loop-p (root thread)
3907 "Say whether ROOT is in THREAD."
3908 (let ((stack (list thread))
3911 (while (setq thread (pop stack))
3912 (setq th (cdr thread))
3914 (not (eq (caar th) root)))
3917 ;; We have found a loop.
3919 (setcdr thread (delq (car th) (cdr thread)))
3920 (if (boundp (setq ref-dep (intern "none"
3921 gnus-newsgroup-dependencies)))
3922 (setcdr (symbol-value ref-dep)
3923 (nconc (cdr (symbol-value ref-dep))
3925 (set ref-dep (list nil (car th))))
3928 ;; Push all the subthreads onto the stack.
3929 (push (cdr thread) stack)))
3932 (defun gnus-make-threads ()
3933 "Go through the dependency hashtb and find the roots. Return all threads."
3935 (while (catch 'infloop
3938 ;; Deal with self-referencing References loops.
3939 (when (and (car (symbol-value refs))
3946 (car (symbol-value refs)) thread))
3947 (cdr (symbol-value refs)))))))
3950 (unless (car (symbol-value refs))
3951 ;; These threads do not refer back to any other
3952 ;; articles, so they're roots.
3953 (setq threads (append (cdr (symbol-value refs)) threads))))
3954 gnus-newsgroup-dependencies)))
3957 ;; Build the thread tree.
3958 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3959 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3961 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3962 if it was already present.
3964 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3965 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3966 Message-IDs will be renamed to a unique Message-ID before being
3969 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3970 (let* ((id (mail-header-id header))
3971 (id-dep (and id (intern id dependencies)))
3972 parent-id ref ref-dep ref-header replaced)
3973 ;; Enter this `header' in the `dependencies' table.
3977 ;; The first two cases do the normal part: enter a new `header'
3978 ;; in the `dependencies' table.
3979 ((not (boundp id-dep))
3980 (set id-dep (list header)))
3981 ((null (car (symbol-value id-dep)))
3982 (setcar (symbol-value id-dep) header))
3984 ;; From here the `header' was already present in the
3985 ;; `dependencies' table.
3987 ;; Overrides an existing entry;
3988 ;; just set the header part of the entry.
3989 (setcar (symbol-value id-dep) header)
3992 ;; Renames the existing `header' to a unique Message-ID.
3993 ((not gnus-summary-ignore-duplicates)
3994 ;; An article with this Message-ID has already been seen.
3995 ;; We rename the Message-ID.
3996 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3998 (mail-header-set-id header id))
4000 ;; The last case ignores an existing entry, except it adds any
4001 ;; additional Xrefs (in case the two articles came from different
4003 ;; Also sets `header' to `nil' meaning that the `dependencies'
4004 ;; table was *not* modified.
4006 (mail-header-set-xref
4007 (car (symbol-value id-dep))
4008 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4010 (or (mail-header-xref header) "")))
4013 (when (and header (not replaced))
4014 ;; First check that we are not creating a References loop.
4015 (setq parent-id (gnus-parent-id (mail-header-references header)))
4016 (setq ref parent-id)
4018 (setq ref-dep (intern-soft ref dependencies))
4020 (setq ref-header (car (symbol-value ref-dep))))
4021 (if (string= id ref)
4022 ;; Yuk! This is a reference loop. Make the article be a
4025 (mail-header-set-references (car (symbol-value id-dep)) "none")
4027 (setq parent-id nil))
4028 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4029 (setq ref-dep (intern (or parent-id "none") dependencies))
4030 (if (boundp ref-dep)
4031 (setcdr (symbol-value ref-dep)
4032 (nconc (cdr (symbol-value ref-dep))
4033 (list (symbol-value id-dep))))
4034 (set ref-dep (list nil (symbol-value id-dep)))))
4037 (defun gnus-extract-message-id-from-in-reply-to (string)
4038 (if (string-match "<[^>]+>" string)
4039 (substring string (match-beginning 0) (match-end 0))
4042 (defun gnus-build-sparse-threads ()
4043 (let ((headers gnus-newsgroup-headers)
4044 (mail-parse-charset gnus-newsgroup-charset)
4045 (gnus-summary-ignore-duplicates t)
4046 header references generation relations
4047 subject child end new-child date)
4048 ;; First we create an alist of generations/relations, where
4049 ;; generations is how much we trust the relation, and the relation
4051 (gnus-message 7 "Making sparse threads...")
4053 (nnheader-set-temp-buffer " *gnus sparse threads*")
4054 (while (setq header (pop headers))
4055 (when (and (setq references (mail-header-references header))
4056 (not (string= references "")))
4058 (setq child (mail-header-id header)
4059 subject (mail-header-subject header)
4060 date (mail-header-date header)
4062 (while (search-backward ">" nil t)
4063 (setq end (1+ (point)))
4064 (when (search-backward "<" nil t)
4065 (setq new-child (buffer-substring (point) end))
4066 (push (list (incf generation)
4067 child (setq child new-child)
4071 (push (list (1+ generation) child nil subject) relations))
4073 (kill-buffer (current-buffer)))
4074 ;; Sort over trustworthiness.
4077 (when (gnus-dependencies-add-header
4078 (make-full-mail-header
4079 gnus-reffed-article-number
4080 (nth 3 relation) "" (or (nth 4 relation) "")
4082 (or (nth 2 relation) "") 0 0 "")
4083 gnus-newsgroup-dependencies nil)
4084 (push gnus-reffed-article-number gnus-newsgroup-limit)
4085 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4086 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4087 gnus-newsgroup-reads)
4088 (decf gnus-reffed-article-number)))
4089 (sort relations 'car-less-than-car))
4090 (gnus-message 7 "Making sparse threads...done")))
4092 (defun gnus-build-old-threads ()
4093 ;; Look at all the articles that refer back to old articles, and
4094 ;; fetch the headers for the articles that aren't there. This will
4095 ;; build complete threads - if the roots haven't been expired by the
4097 (let ((mail-parse-charset gnus-newsgroup-charset)
4101 (when (not (car (symbol-value refs)))
4102 (setq heads (cdr (symbol-value refs)))
4104 (if (memq (mail-header-number (caar heads))
4105 gnus-newsgroup-dormant)
4106 (setq heads (cdr heads))
4107 (setq id (symbol-name refs))
4108 (while (and (setq id (gnus-build-get-header id))
4109 (not (car (gnus-id-to-thread id)))))
4110 (setq heads nil)))))
4111 gnus-newsgroup-dependencies)))
4113 (defsubst gnus-remove-odd-characters (string)
4114 "Translate STRING into something that doesn't contain weird characters."
4115 (mm-subst-char-in-string
4117 (mm-subst-char-in-string ?\n ?\- string t) t))
4119 ;; This function has to be called with point after the article number
4120 ;; on the beginning of the line.
4121 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4122 (let ((eol (point-at-eol))
4123 (buffer (current-buffer))
4124 header references in-reply-to)
4126 ;; overview: [num subject from date id refs chars lines misc]
4129 (narrow-to-region (point) eol)
4134 (make-full-mail-header
4136 (condition-case () ; subject
4137 (gnus-remove-odd-characters
4138 (funcall gnus-decode-encoded-word-function
4139 (setq x (nnheader-nov-field))))
4141 (condition-case () ; from
4142 (gnus-remove-odd-characters
4143 (funcall gnus-decode-encoded-word-function
4144 (setq x (nnheader-nov-field))))
4146 (nnheader-nov-field) ; date
4147 (nnheader-nov-read-message-id number) ; id
4148 (setq references (nnheader-nov-field)) ; refs
4149 (nnheader-nov-read-integer) ; chars
4150 (nnheader-nov-read-integer) ; lines
4152 (if (looking-at "Xref: ")
4153 (goto-char (match-end 0)))
4154 (nnheader-nov-field)) ; Xref
4155 (nnheader-nov-parse-extra)))) ; extra
4159 (when (and (string= references "")
4160 (setq in-reply-to (mail-header-extra header))
4161 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4162 (mail-header-set-references
4163 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4165 (when gnus-alter-header-function
4166 (funcall gnus-alter-header-function header))
4167 (gnus-dependencies-add-header header dependencies force-new)))
4169 (defun gnus-build-get-header (id)
4170 "Look through the buffer of NOV lines and find the header to ID.
4171 Enter this line into the dependencies hash table, and return
4172 the id of the parent article (if any)."
4173 (let ((deps gnus-newsgroup-dependencies)
4177 (set-buffer nntp-server-buffer)
4178 (let ((case-fold-search nil))
4179 (goto-char (point-min))
4180 (while (and (not found)
4181 (search-forward id nil t))
4183 (setq found (looking-at
4184 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4185 (regexp-quote id))))
4186 (or found (beginning-of-line 2)))
4190 (setq header (gnus-nov-parse-line
4191 (read (current-buffer)) deps))
4192 (gnus-parent-id (mail-header-references header))))))
4194 (let ((number (mail-header-number header)))
4195 (push number gnus-newsgroup-limit)
4196 (push header gnus-newsgroup-headers)
4197 (if (memq number gnus-newsgroup-unselected)
4199 (setq gnus-newsgroup-unreads
4200 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4202 (setq gnus-newsgroup-unselected
4203 (delq number gnus-newsgroup-unselected)))
4204 (push number gnus-newsgroup-ancient)))))))
4206 (defun gnus-build-all-threads ()
4207 "Read all the headers."
4208 (let ((gnus-summary-ignore-duplicates t)
4209 (mail-parse-charset gnus-newsgroup-charset)
4210 (dependencies gnus-newsgroup-dependencies)
4213 (set-buffer nntp-server-buffer)
4214 (let ((case-fold-search nil))
4215 (goto-char (point-min))
4218 (setq article (read (current-buffer))
4219 header (gnus-nov-parse-line article dependencies)))
4221 (with-current-buffer gnus-summary-buffer
4222 (push header gnus-newsgroup-headers)
4223 (if (memq (setq article (mail-header-number header))
4224 gnus-newsgroup-unselected)
4226 (setq gnus-newsgroup-unreads
4227 (gnus-add-to-sorted-list
4228 gnus-newsgroup-unreads article))
4229 (setq gnus-newsgroup-unselected
4230 (delq article gnus-newsgroup-unselected)))
4231 (push article gnus-newsgroup-ancient)))
4232 (forward-line 1)))))))
4234 (defun gnus-summary-update-article-line (article header)
4235 "Update the line for ARTICLE using HEADER."
4236 (let* ((id (mail-header-id header))
4237 (thread (gnus-id-to-thread id)))
4239 (error "Article in no thread"))
4240 ;; Update the thread.
4241 (setcar thread header)
4242 (gnus-summary-goto-subject article)
4243 (let* ((datal (gnus-data-find-list article))
4245 (buffer-read-only nil)
4246 (level (gnus-summary-thread-level)))
4248 (let ((inserted (- (point)
4250 (gnus-summary-insert-line
4252 (memq article gnus-newsgroup-undownloaded)
4253 (gnus-article-mark article)
4254 (memq article gnus-newsgroup-replied)
4255 (memq article gnus-newsgroup-expirable)
4256 ;; Only insert the Subject string when it's different
4257 ;; from the previous Subject string.
4262 (mail-header-subject
4265 (gnus-data-find-list
4267 (gnus-data-list t)))))
4268 ;; Error on the side of excessive subjects.
4270 (mail-header-subject header)))
4272 (mail-header-subject header))
4273 nil (cdr (assq article gnus-newsgroup-scored))
4274 (memq article gnus-newsgroup-processable))
4277 (gnus-data-update-list
4279 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4281 (defun gnus-summary-update-article (article &optional iheader)
4282 "Update ARTICLE in the summary buffer."
4283 (set-buffer gnus-summary-buffer)
4284 (let* ((header (gnus-summary-article-header article))
4285 (id (mail-header-id header))
4286 (data (gnus-data-find article))
4287 (thread (gnus-id-to-thread id))
4288 (references (mail-header-references header))
4292 (when (and references
4293 (not (equal "" references)))
4296 (buffer-read-only nil)
4302 (delq thread parent)))
4303 (if (gnus-summary-insert-subject id header)
4304 ;; Set the (possibly) new article number in the data structure.
4305 (gnus-data-set-number data (gnus-id-to-article id))
4309 (defun gnus-rebuild-thread (id &optional line)
4310 "Rebuild the thread containing ID.
4311 If LINE, insert the rebuilt thread starting on line LINE."
4312 (let ((buffer-read-only nil)
4313 old-pos current thread data)
4314 (if (not gnus-show-threads)
4315 (setq thread (list (car (gnus-id-to-thread id))))
4316 ;; Get the thread this article is part of.
4317 (setq thread (gnus-remove-thread id)))
4318 (setq old-pos (point-at-bol))
4319 (setq current (save-excursion
4320 (and (re-search-backward "[\r\n]" nil t)
4321 (gnus-summary-article-number))))
4322 ;; If this is a gathered thread, we have to go some re-gathering.
4323 (when (stringp (car thread))
4324 (let ((subject (car thread))
4326 (setq thread (cdr thread))
4328 (unless (memq (setq thr (gnus-id-to-thread
4330 (mail-header-id (caar thread)))))
4333 (setq thread (cdr thread)))
4334 ;; We now have all (unique) roots.
4335 (if (= (length roots) 1)
4336 ;; All the loose roots are now one solid root.
4337 (setq thread (car roots))
4338 (setq thread (cons subject (gnus-sort-threads roots))))))
4340 ;; We then insert this thread into the summary buffer.
4342 (goto-char (point-min))
4343 (forward-line (1- line)))
4344 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4345 (if gnus-show-threads
4346 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4347 (gnus-summary-prepare-unthreaded thread))
4348 (setq data (nreverse gnus-newsgroup-data))
4349 (setq threads gnus-newsgroup-threads))
4350 ;; We splice the new data into the data structure.
4351 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4352 ;;!!! then we want to insert at the beginning of the buffer.
4353 ;;!!! That happens to be true with Gnus now, but that may
4354 ;;!!! change in the future. Perhaps.
4355 (gnus-data-enter-list
4356 (if line nil current) data (- (point) old-pos))
4357 (setq gnus-newsgroup-threads
4358 (nconc threads gnus-newsgroup-threads))
4359 (gnus-data-compute-positions))))
4361 (defun gnus-number-to-header (number)
4362 "Return the header for article NUMBER."
4363 (let ((headers gnus-newsgroup-headers))
4365 (not (= number (mail-header-number (car headers)))))
4370 (defun gnus-parent-headers (in-headers &optional generation)
4371 "Return the headers of the GENERATIONeth parent of HEADERS."
4373 (setq generation 1))
4375 (headers in-headers)
4378 (not (zerop generation))
4379 (setq references (mail-header-references headers)))
4380 (setq headers (if (and references
4381 (setq parent (gnus-parent-id references)))
4382 (car (gnus-id-to-thread parent))
4385 (and (not (eq headers in-headers))
4388 (defun gnus-id-to-thread (id)
4389 "Return the (sub-)thread where ID appears."
4390 (gnus-gethash id gnus-newsgroup-dependencies))
4392 (defun gnus-id-to-article (id)
4393 "Return the article number of ID."
4394 (let ((thread (gnus-id-to-thread id)))
4397 (mail-header-number (car thread)))))
4399 (defun gnus-id-to-header (id)
4400 "Return the article headers of ID."
4401 (car (gnus-id-to-thread id)))
4403 (defun gnus-article-displayed-root-p (article)
4404 "Say whether ARTICLE is a root(ish) article."
4405 (let ((level (gnus-summary-thread-level article))
4406 (refs (mail-header-references (gnus-summary-article-header article)))
4412 ((null (gnus-parent-id refs)) t)
4414 (null (setq particle (gnus-id-to-article
4415 (gnus-parent-id refs))))
4416 (null (gnus-summary-thread-level particle)))))))
4418 (defun gnus-root-id (id)
4419 "Return the id of the root of the thread where ID appears."
4421 (while (and id (setq prev (car (gnus-id-to-thread id))))
4423 id (gnus-parent-id (mail-header-references prev))))
4426 (defun gnus-articles-in-thread (thread)
4427 "Return the list of articles in THREAD."
4428 (cons (mail-header-number (car thread))
4429 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4431 (defun gnus-remove-thread (id &optional dont-remove)
4432 "Remove the thread that has ID in it."
4433 (let (headers thread last-id)
4434 ;; First go up in this thread until we find the root.
4435 (setq last-id (gnus-root-id id)
4436 headers (message-flatten-list (gnus-id-to-thread last-id)))
4437 ;; We have now found the real root of this thread. It might have
4438 ;; been gathered into some loose thread, so we have to search
4439 ;; through the threads to find the thread we wanted.
4440 (let ((threads gnus-newsgroup-threads)
4443 (setq sub (car threads))
4444 (if (stringp (car sub))
4445 ;; This is a gathered thread, so we look at the roots
4446 ;; below it to find whether this article is in this
4449 (setq sub (cdr sub))
4451 (when (member (caar sub) headers)
4452 (setq thread (car threads)
4455 (setq sub (cdr sub))))
4456 ;; It's an ordinary thread, so we check it.
4457 (when (eq (car sub) (car headers))
4460 (setq threads (cdr threads)))
4461 ;; If this article is in no thread, then it's a root.
4464 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4465 (setq thread (gnus-id-to-thread last-id)))
4468 thread ; We return this thread.
4470 (if (stringp (car thread))
4472 ;; If we use dummy roots, then we have to remove the
4473 ;; dummy root as well.
4474 (when (eq gnus-summary-make-false-root 'dummy)
4475 ;; We go to the dummy root by going to
4476 ;; the first sub-"thread", and then one line up.
4477 (gnus-summary-goto-article
4478 (mail-header-number (caadr thread)))
4481 (gnus-data-compute-positions))
4482 (setq thread (cdr thread))
4484 (gnus-remove-thread-1 (car thread))
4485 (setq thread (cdr thread))))
4486 (gnus-remove-thread-1 thread))))))))
4488 (defun gnus-remove-thread-1 (thread)
4489 "Remove the thread THREAD recursively."
4490 (let ((number (mail-header-number (pop thread)))
4492 (setq thread (reverse thread))
4494 (gnus-remove-thread-1 (pop thread)))
4495 (when (setq d (gnus-data-find number))
4496 (goto-char (gnus-data-pos d))
4497 (gnus-summary-show-thread)
4503 (gnus-delete-line)))))))
4505 (defun gnus-sort-threads-1 (threads func)
4506 (sort (mapcar (lambda (thread)
4509 (gnus-sort-threads-1 (cdr thread) func))))
4512 (defun gnus-sort-threads (threads)
4514 (if (not gnus-thread-sort-functions)
4516 (gnus-message 8 "Sorting threads...")
4517 (let ((max-lisp-eval-depth 5000))
4518 (prog1 (gnus-sort-threads-1
4520 (gnus-make-sort-function gnus-thread-sort-functions))
4521 (gnus-message 8 "Sorting threads...done")))))
4523 (defun gnus-sort-articles (articles)
4525 (when gnus-article-sort-functions
4526 (gnus-message 7 "Sorting articles...")
4528 (setq gnus-newsgroup-headers
4529 (sort articles (gnus-make-sort-function
4530 gnus-article-sort-functions)))
4531 (gnus-message 7 "Sorting articles...done"))))
4533 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4534 (defmacro gnus-thread-header (thread)
4535 "Return header of first article in THREAD.
4536 Note that THREAD must never, ever be anything else than a variable -
4537 using some other form will lead to serious barfage."
4538 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4539 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4540 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4543 (defsubst gnus-article-sort-by-number (h1 h2)
4544 "Sort articles by article number."
4545 (< (mail-header-number h1)
4546 (mail-header-number h2)))
4548 (defun gnus-thread-sort-by-number (h1 h2)
4549 "Sort threads by root article number."
4550 (gnus-article-sort-by-number
4551 (gnus-thread-header h1) (gnus-thread-header h2)))
4553 (defsubst gnus-article-sort-by-random (h1 h2)
4554 "Sort articles by article number."
4557 (defun gnus-thread-sort-by-random (h1 h2)
4558 "Sort threads by root article number."
4559 (gnus-article-sort-by-random
4560 (gnus-thread-header h1) (gnus-thread-header h2)))
4562 (defsubst gnus-article-sort-by-lines (h1 h2)
4563 "Sort articles by article Lines header."
4564 (< (mail-header-lines h1)
4565 (mail-header-lines h2)))
4567 (defun gnus-thread-sort-by-lines (h1 h2)
4568 "Sort threads by root article Lines header."
4569 (gnus-article-sort-by-lines
4570 (gnus-thread-header h1) (gnus-thread-header h2)))
4572 (defsubst gnus-article-sort-by-chars (h1 h2)
4573 "Sort articles by octet length."
4574 (< (mail-header-chars h1)
4575 (mail-header-chars h2)))
4577 (defun gnus-thread-sort-by-chars (h1 h2)
4578 "Sort threads by root article octet length."
4579 (gnus-article-sort-by-chars
4580 (gnus-thread-header h1) (gnus-thread-header h2)))
4582 (defsubst gnus-article-sort-by-author (h1 h2)
4583 "Sort articles by root author."
4585 (let ((extract (funcall
4586 gnus-extract-address-components
4587 (mail-header-from h1))))
4588 (or (car extract) (cadr extract) ""))
4589 (let ((extract (funcall
4590 gnus-extract-address-components
4591 (mail-header-from h2))))
4592 (or (car extract) (cadr extract) ""))))
4594 (defun gnus-thread-sort-by-author (h1 h2)
4595 "Sort threads by root author."
4596 (gnus-article-sort-by-author
4597 (gnus-thread-header h1) (gnus-thread-header h2)))
4599 (defsubst gnus-article-sort-by-recipient (h1 h2)
4600 "Sort articles by recipient."
4602 (let ((extract (funcall
4603 gnus-extract-address-components
4604 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4605 (or (car extract) (cadr extract)))
4606 (let ((extract (funcall
4607 gnus-extract-address-components
4608 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4609 (or (car extract) (cadr extract)))))
4611 (defun gnus-thread-sort-by-recipient (h1 h2)
4612 "Sort threads by root recipient."
4613 (gnus-article-sort-by-recipient
4614 (gnus-thread-header h1) (gnus-thread-header h2)))
4616 (defsubst gnus-article-sort-by-subject (h1 h2)
4617 "Sort articles by root subject."
4619 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4620 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4622 (defun gnus-thread-sort-by-subject (h1 h2)
4623 "Sort threads by root subject."
4624 (gnus-article-sort-by-subject
4625 (gnus-thread-header h1) (gnus-thread-header h2)))
4627 (defsubst gnus-article-sort-by-date (h1 h2)
4628 "Sort articles by root article date."
4630 (gnus-date-get-time (mail-header-date h1))
4631 (gnus-date-get-time (mail-header-date h2))))
4633 (defun gnus-thread-sort-by-date (h1 h2)
4634 "Sort threads by root article date."
4635 (gnus-article-sort-by-date
4636 (gnus-thread-header h1) (gnus-thread-header h2)))
4638 (defsubst gnus-article-sort-by-score (h1 h2)
4639 "Sort articles by root article score.
4640 Unscored articles will be counted as having a score of zero."
4641 (> (or (cdr (assq (mail-header-number h1)
4642 gnus-newsgroup-scored))
4643 gnus-summary-default-score 0)
4644 (or (cdr (assq (mail-header-number h2)
4645 gnus-newsgroup-scored))
4646 gnus-summary-default-score 0)))
4648 (defun gnus-thread-sort-by-score (h1 h2)
4649 "Sort threads by root article score."
4650 (gnus-article-sort-by-score
4651 (gnus-thread-header h1) (gnus-thread-header h2)))
4653 (defun gnus-thread-sort-by-total-score (h1 h2)
4654 "Sort threads by the sum of all scores in the thread.
4655 Unscored articles will be counted as having a score of zero."
4656 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4658 (defun gnus-thread-total-score (thread)
4659 ;; This function find the total score of THREAD.
4664 (if (stringp (car thread))
4665 (apply gnus-thread-score-function 0
4666 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4667 (gnus-thread-total-score-1 thread)))
4669 (gnus-thread-total-score-1 (list thread)))))
4671 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4672 "Sort threads such that the thread with the most recently arrived article comes first."
4673 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4675 (defun gnus-thread-highest-number (thread)
4676 "Return the highest article number in THREAD."
4677 (apply 'max (mapcar (lambda (header)
4678 (mail-header-number header))
4679 (message-flatten-list thread))))
4681 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4682 "Sort threads such that the thread with the most recently dated article comes first."
4683 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4685 (defun gnus-thread-latest-date (thread)
4686 "Return the highest article date in THREAD."
4687 (let ((previous-time 0))
4693 (time-to-seconds (mail-header-parse-date
4694 (mail-header-date header)))
4695 (error previous-time))))
4697 (message-flatten-list thread)
4699 (< (mail-header-number h1)
4700 (mail-header-number h2))))))))
4702 (defun gnus-thread-total-score-1 (root)
4703 ;; This function find the total score of the thread below ROOT.
4704 (setq root (car root))
4705 (apply gnus-thread-score-function
4707 (mapcar 'gnus-thread-total-score
4708 (cdr (gnus-id-to-thread (mail-header-id root))))
4709 (when (> (mail-header-number root) 0)
4710 (list (or (cdr (assq (mail-header-number root)
4711 gnus-newsgroup-scored))
4712 gnus-summary-default-score 0))))
4713 (list gnus-summary-default-score)
4716 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4717 (defvar gnus-tmp-prev-subject nil)
4718 (defvar gnus-tmp-false-parent nil)
4719 (defvar gnus-tmp-root-expunged nil)
4720 (defvar gnus-tmp-dummy-line nil)
4722 (eval-when-compile (defvar gnus-tmp-header))
4723 (defun gnus-extra-header (type &optional header)
4724 "Return the extra header of TYPE."
4725 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4728 (defvar gnus-tmp-thread-tree-header-string "")
4730 (defcustom gnus-sum-thread-tree-root "> "
4731 "With %B spec, used for the root of a thread.
4732 If nil, use subject instead."
4734 :type '(radio (const :format "%v " nil) string)
4735 :group 'gnus-thread)
4737 (defcustom gnus-sum-thread-tree-false-root "> "
4738 "With %B spec, used for a false root of a thread.
4739 If nil, use subject instead."
4741 :type '(radio (const :format "%v " nil) string)
4742 :group 'gnus-thread)
4744 (defcustom gnus-sum-thread-tree-single-indent ""
4745 "With %B spec, used for a thread with just one message.
4746 If nil, use subject instead."
4748 :type '(radio (const :format "%v " nil) string)
4749 :group 'gnus-thread)
4751 (defcustom gnus-sum-thread-tree-vertical "| "
4752 "With %B spec, used for drawing a vertical line."
4755 :group 'gnus-thread)
4757 (defcustom gnus-sum-thread-tree-indent " "
4758 "With %B spec, used for indenting."
4761 :group 'gnus-thread)
4763 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4764 "With %B spec, used for a leaf with brothers."
4767 :group 'gnus-thread)
4769 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4770 "With %B spec, used for a leaf without brothers."
4773 :group 'gnus-thread)
4775 (defun gnus-summary-prepare-threads (threads)
4776 "Prepare summary buffer from THREADS and indentation LEVEL.
4777 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4778 or a straight list of headers."
4779 (gnus-message 7 "Generating summary...")
4781 (setq gnus-newsgroup-threads threads)
4784 (let ((gnus-tmp-level 0)
4785 (default-score (or gnus-summary-default-score 0))
4786 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4787 (building-line-count gnus-summary-display-while-building)
4788 (building-count (integerp gnus-summary-display-while-building))
4789 thread number subject stack state gnus-tmp-gathered beg-match
4790 new-roots gnus-tmp-new-adopts thread-end simp-subject
4791 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4792 gnus-tmp-replied gnus-tmp-subject-or-nil
4793 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4794 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4795 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4798 (setq gnus-tmp-prev-subject nil
4799 gnus-tmp-thread-tree-header-string "")
4801 (if (vectorp (car threads))
4802 ;; If this is a straight (sic) list of headers, then a
4803 ;; threaded summary display isn't required, so we just create
4804 ;; an unthreaded one.
4805 (gnus-summary-prepare-unthreaded threads)
4807 ;; Do the threaded display.
4809 (if gnus-summary-display-while-building
4810 (switch-to-buffer (buffer-name)))
4811 (while (or threads stack gnus-tmp-new-adopts new-roots)
4813 (if (and (= gnus-tmp-level 0)
4816 (not gnus-tmp-false-parent)
4817 (or gnus-tmp-new-adopts new-roots))
4818 (if gnus-tmp-new-adopts
4819 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4820 thread (list (car gnus-tmp-new-adopts))
4821 gnus-tmp-header (caar thread)
4822 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4824 (setq thread (list (car new-roots))
4825 gnus-tmp-header (caar thread)
4826 new-roots (cdr new-roots))))
4829 ;; If there are some threads, we do them before the
4830 ;; threads on the stack.
4831 (setq thread threads
4832 gnus-tmp-header (caar thread))
4833 ;; There were no current threads, so we pop something off
4835 (setq state (car stack)
4836 gnus-tmp-level (car state)
4837 tree-stack (cadr state)
4838 thread (caddr state)
4840 gnus-tmp-header (caar thread))))
4842 (setq gnus-tmp-false-parent nil)
4843 (setq gnus-tmp-root-expunged nil)
4844 (setq thread-end nil)
4846 (if (stringp gnus-tmp-header)
4847 ;; The header is a dummy root.
4849 ((eq gnus-summary-make-false-root 'adopt)
4850 ;; We let the first article adopt the rest.
4851 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4853 (setq gnus-tmp-gathered
4855 (lambda (h) (mail-header-number (car h)))
4858 (setq thread (cons (list (caar thread)
4861 (setq gnus-tmp-level -1
4862 gnus-tmp-false-parent t))
4863 ((eq gnus-summary-make-false-root 'empty)
4864 ;; We print adopted articles with empty subject fields.
4865 (setq gnus-tmp-gathered
4867 (lambda (h) (mail-header-number (car h)))
4870 (setq gnus-tmp-level -1))
4871 ((eq gnus-summary-make-false-root 'dummy)
4872 ;; We remember that we probably want to output a dummy
4874 (setq gnus-tmp-dummy-line gnus-tmp-header)
4875 (setq gnus-tmp-prev-subject gnus-tmp-header))
4877 ;; We do not make a root for the gathered
4878 ;; sub-threads at all.
4879 (setq gnus-tmp-level -1)))
4881 (setq number (mail-header-number gnus-tmp-header)
4882 subject (mail-header-subject gnus-tmp-header)
4883 simp-subject (gnus-simplify-subject-fully subject))
4886 ;; If the thread has changed subject, we might want to make
4887 ;; this subthread into a root.
4888 ((and (null gnus-thread-ignore-subject)
4889 (not (zerop gnus-tmp-level))
4890 gnus-tmp-prev-subject
4891 (not (string= gnus-tmp-prev-subject simp-subject)))
4892 (setq new-roots (nconc new-roots (list (car thread)))
4894 gnus-tmp-header nil))
4895 ;; If the article lies outside the current limit,
4896 ;; then we do not display it.
4897 ((not (memq number gnus-newsgroup-limit))
4898 (setq gnus-tmp-gathered
4900 (lambda (h) (mail-header-number (car h)))
4903 (setq gnus-tmp-new-adopts (if (cdar thread)
4904 (append gnus-tmp-new-adopts
4906 gnus-tmp-new-adopts)
4908 gnus-tmp-header nil)
4909 (when (zerop gnus-tmp-level)
4910 (setq gnus-tmp-root-expunged t)))
4911 ;; Perhaps this article is to be marked as read?
4912 ((and gnus-summary-mark-below
4913 (< (or (cdr (assq number gnus-newsgroup-scored))
4915 gnus-summary-mark-below)
4916 ;; Don't touch sparse articles.
4917 (not (gnus-summary-article-sparse-p number))
4918 (not (gnus-summary-article-ancient-p number)))
4919 (setq gnus-newsgroup-unreads
4920 (delq number gnus-newsgroup-unreads))
4921 (if gnus-newsgroup-auto-expire
4922 (setq gnus-newsgroup-expirable
4923 (gnus-add-to-sorted-list
4924 gnus-newsgroup-expirable number))
4925 (push (cons number gnus-low-score-mark)
4926 gnus-newsgroup-reads))))
4928 (when gnus-tmp-header
4929 ;; We may have an old dummy line to output before this
4931 (when (and gnus-tmp-dummy-line
4934 (mail-header-subject gnus-tmp-header)))
4935 (gnus-summary-insert-dummy-line
4936 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4937 (setq gnus-tmp-dummy-line nil))
4939 ;; Compute the mark.
4940 (setq gnus-tmp-unread (gnus-article-mark number))
4942 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4943 gnus-tmp-header gnus-tmp-level)
4944 gnus-newsgroup-data)
4946 ;; Actually insert the line.
4948 gnus-tmp-subject-or-nil
4950 ((and gnus-thread-ignore-subject
4951 gnus-tmp-prev-subject
4952 (not (string= gnus-tmp-prev-subject simp-subject)))
4954 ((zerop gnus-tmp-level)
4955 (if (and (eq gnus-summary-make-false-root 'empty)
4956 (memq number gnus-tmp-gathered)
4957 gnus-tmp-prev-subject
4958 (string= gnus-tmp-prev-subject simp-subject))
4959 gnus-summary-same-subject
4961 (t gnus-summary-same-subject)))
4962 (if (and (eq gnus-summary-make-false-root 'adopt)
4963 (= gnus-tmp-level 1)
4964 (memq number gnus-tmp-gathered))
4965 (setq gnus-tmp-opening-bracket ?\<
4966 gnus-tmp-closing-bracket ?\>)
4967 (setq gnus-tmp-opening-bracket ?\[
4968 gnus-tmp-closing-bracket ?\]))
4970 gnus-tmp-indentation
4971 (aref gnus-thread-indent-array gnus-tmp-level)
4972 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4973 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4974 gnus-summary-default-score 0)
4976 (if (or (null gnus-summary-default-score)
4977 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4978 gnus-summary-zcore-fuzz))
4980 (if (< gnus-tmp-score gnus-summary-default-score)
4981 gnus-score-below-mark gnus-score-over-mark))
4983 (cond ((memq number gnus-newsgroup-processable)
4985 ((memq number gnus-newsgroup-cached)
4987 ((memq number gnus-newsgroup-replied)
4989 ((memq number gnus-newsgroup-forwarded)
4990 gnus-forwarded-mark)
4991 ((memq number gnus-newsgroup-saved)
4993 ((memq number gnus-newsgroup-recent)
4995 ((memq number gnus-newsgroup-unseen)
4999 (cond ((memq number gnus-newsgroup-undownloaded)
5000 gnus-undownloaded-mark)
5001 (gnus-newsgroup-agentized
5002 gnus-downloaded-mark)
5005 gnus-tmp-from (mail-header-from gnus-tmp-header)
5008 ((string-match "<[^>]+> *$" gnus-tmp-from)
5009 (setq beg-match (match-beginning 0))
5010 (or (and (string-match "^\".+\"" gnus-tmp-from)
5011 (substring gnus-tmp-from 1 (1- (match-end 0))))
5012 (substring gnus-tmp-from 0 beg-match)))
5013 ((string-match "(.+)" gnus-tmp-from)
5014 (substring gnus-tmp-from
5015 (1+ (match-beginning 0)) (1- (match-end 0))))
5019 gnus-tmp-thread-tree-header-string
5021 ((not gnus-show-threads) "")
5022 ((zerop gnus-tmp-level)
5023 (cond ((cdar thread)
5024 (or gnus-sum-thread-tree-root subject))
5025 (gnus-tmp-new-adopts
5026 (or gnus-sum-thread-tree-false-root subject))
5028 (or gnus-sum-thread-tree-single-indent subject))))
5030 (concat (apply 'concat
5031 (mapcar (lambda (item)
5033 gnus-sum-thread-tree-vertical
5034 gnus-sum-thread-tree-indent))
5035 (cdr (reverse tree-stack))))
5037 gnus-sum-thread-tree-leaf-with-other
5038 gnus-sum-thread-tree-single-leaf)))))
5039 (when (string= gnus-tmp-name "")
5040 (setq gnus-tmp-name gnus-tmp-from))
5041 (unless (numberp gnus-tmp-lines)
5042 (setq gnus-tmp-lines -1))
5043 (if (= gnus-tmp-lines -1)
5044 (setq gnus-tmp-lines "?")
5045 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5046 (gnus-put-text-property
5048 (progn (eval gnus-summary-line-format-spec) (point))
5049 'gnus-number number)
5052 (gnus-run-hooks 'gnus-summary-update-hook)
5055 (setq gnus-tmp-prev-subject simp-subject)))
5057 (when (nth 1 thread)
5058 (push (list (max 0 gnus-tmp-level)
5059 (copy-sequence tree-stack)
5062 (push (if (nth 1 thread) 1 0) tree-stack)
5063 (incf gnus-tmp-level)
5064 (setq threads (if thread-end nil (cdar thread)))
5065 (if gnus-summary-display-while-building
5068 ;; use a set frequency
5069 (setq building-line-count (1- building-line-count))
5070 (when (= building-line-count 0)
5072 (setq building-line-count
5073 gnus-summary-display-while-building)))
5077 (setq gnus-tmp-level 0)))))
5078 (gnus-message 7 "Generating summary...done"))
5080 (defun gnus-summary-prepare-unthreaded (headers)
5081 "Generate an unthreaded summary buffer based on HEADERS."
5082 (let (header number mark)
5087 ;; We may have to root out some bad articles...
5088 (when (memq (setq number (mail-header-number
5089 (setq header (pop headers))))
5090 gnus-newsgroup-limit)
5091 ;; Mark article as read when it has a low score.
5092 (when (and gnus-summary-mark-below
5093 (< (or (cdr (assq number gnus-newsgroup-scored))
5094 gnus-summary-default-score 0)
5095 gnus-summary-mark-below)
5096 (not (gnus-summary-article-ancient-p number)))
5097 (setq gnus-newsgroup-unreads
5098 (delq number gnus-newsgroup-unreads))
5099 (if gnus-newsgroup-auto-expire
5100 (push number gnus-newsgroup-expirable)
5101 (push (cons number gnus-low-score-mark)
5102 gnus-newsgroup-reads)))
5104 (setq mark (gnus-article-mark number))
5105 (push (gnus-data-make number mark (1+ (point)) header 0)
5106 gnus-newsgroup-data)
5107 (gnus-summary-insert-line
5109 (memq number gnus-newsgroup-undownloaded)
5110 mark (memq number gnus-newsgroup-replied)
5111 (memq number gnus-newsgroup-expirable)
5112 (mail-header-subject header) nil
5113 (cdr (assq number gnus-newsgroup-scored))
5114 (memq number gnus-newsgroup-processable))))))
5116 (defun gnus-summary-remove-list-identifiers ()
5117 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5118 (let ((regexp (if (consp gnus-list-identifiers)
5119 (mapconcat 'identity gnus-list-identifiers " *\\|")
5120 gnus-list-identifiers))
5123 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5124 (dolist (header gnus-newsgroup-headers)
5125 (setq subject (mail-header-subject header)
5127 (while (string-match regexp subject)
5129 (concat (substring subject 0 (match-beginning 1))
5130 (substring subject (match-end 0)))
5133 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5135 (concat (substring subject 0 (match-beginning 1))
5136 (substring subject (match-end 1)))))
5137 (mail-header-set-subject header subject))))))
5139 (defun gnus-fetch-headers (articles)
5140 "Fetch headers of ARTICLES."
5141 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5142 (gnus-message 5 "Fetching headers for %s..." name)
5145 (setq gnus-headers-retrieved-by
5146 (gnus-retrieve-headers
5147 articles gnus-newsgroup-name
5148 ;; We might want to fetch old headers, but
5149 ;; not if there is only 1 article.
5151 (not (eq gnus-fetch-old-headers 'some))
5152 (not (numberp gnus-fetch-old-headers)))
5153 (> (length articles) 1))
5154 gnus-fetch-old-headers))))
5155 (gnus-get-newsgroup-headers-xover
5156 articles nil nil gnus-newsgroup-name t)
5157 (gnus-get-newsgroup-headers))
5158 (gnus-message 5 "Fetching headers for %s...done" name))))
5160 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5161 "Select newsgroup GROUP.
5162 If READ-ALL is non-nil, all articles in the group are selected.
5163 If SELECT-ARTICLES, only select those articles from GROUP."
5164 (let* ((entry (gnus-group-entry group))
5165 ;;!!! Dirty hack; should be removed.
5166 (gnus-summary-ignore-duplicates
5167 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5169 gnus-summary-ignore-duplicates))
5170 (info (nth 2 entry))
5171 articles fetched-articles cached)
5173 (unless (gnus-check-server
5174 (set (make-local-variable 'gnus-current-select-method)
5175 (gnus-find-method-for-group group)))
5176 (error "Couldn't open server"))
5178 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5179 (gnus-activate-group group) ; Or we can activate it...
5180 (progn ; Or we bug out.
5181 (when (equal major-mode 'gnus-summary-mode)
5182 (gnus-kill-buffer (current-buffer)))
5183 (error "Couldn't activate group %s: %s"
5184 group (gnus-status-message group))))
5186 (unless (gnus-request-group group t)
5187 (when (equal major-mode 'gnus-summary-mode)
5188 (gnus-kill-buffer (current-buffer)))
5189 (error "Couldn't request group %s: %s"
5190 group (gnus-status-message group)))
5193 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5195 (setq gnus-summary-use-undownloaded-faces
5196 (gnus-agent-find-parameter
5198 'agent-enable-undownloaded-faces)))
5200 (setq gnus-newsgroup-name group
5201 gnus-newsgroup-unselected nil
5202 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5204 (let ((display (gnus-group-find-parameter group 'display)))
5205 (setq gnus-newsgroup-display
5207 ((not (zerop (or (car-safe read-all) 0)))
5208 ;; The user entered the group with C-u SPC/RET, let's show
5214 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5216 ;; The following is probably the "correct" solution, but
5217 ;; it makes Gnus fetch all headers and then limit the
5218 ;; articles (which is slow), so instead we hack the
5219 ;; select-articles parameter instead. -- Simon Josefsson
5222 ;; (gnus-byte-compile
5223 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5225 (setq select-articles
5226 (gnus-uncompress-range
5227 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5231 (cdr (gnus-active group)))))
5236 (gnus-summary-setup-default-charset)
5238 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5239 (when (gnus-virtual-group-p group)
5240 (setq cached gnus-newsgroup-cached))
5242 (setq gnus-newsgroup-unreads
5243 (gnus-sorted-ndifference
5244 (gnus-sorted-ndifference gnus-newsgroup-unreads
5245 gnus-newsgroup-marked)
5246 gnus-newsgroup-dormant))
5248 (setq gnus-newsgroup-processable nil)
5250 (gnus-update-read-articles group gnus-newsgroup-unreads)
5252 ;; Adjust and set lists of article marks.
5254 (gnus-adjust-marked-articles info))
5255 (if (setq articles select-articles)
5256 (setq gnus-newsgroup-unselected
5257 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5258 (setq articles (gnus-articles-to-read group read-all)))
5262 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5264 ((eq articles 0) nil)
5266 ;; Init the dependencies hash table.
5267 (setq gnus-newsgroup-dependencies
5268 (gnus-make-hashtable (length articles)))
5269 (gnus-set-global-variables)
5270 ;; Retrieve the headers and read them in.
5272 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5274 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5276 (setq gnus-newsgroup-cached cached))
5278 ;; Suppress duplicates?
5279 (when gnus-suppress-duplicates
5280 (gnus-dup-suppress-articles))
5282 ;; Set the initial limit.
5283 (setq gnus-newsgroup-limit (copy-sequence articles))
5284 ;; Remove canceled articles from the list of unread articles.
5285 (setq fetched-articles
5286 (mapcar (lambda (headers) (mail-header-number headers))
5287 gnus-newsgroup-headers))
5288 (setq gnus-newsgroup-articles fetched-articles)
5289 (setq gnus-newsgroup-unreads
5290 (gnus-sorted-nintersection
5291 gnus-newsgroup-unreads fetched-articles))
5292 (gnus-compute-unseen-list)
5294 ;; Removed marked articles that do not exist.
5295 (gnus-update-missing-marks
5296 (gnus-sorted-difference articles fetched-articles))
5297 ;; We might want to build some more threads first.
5298 (when (and gnus-fetch-old-headers
5299 (eq gnus-headers-retrieved-by 'nov))
5300 (if (eq gnus-fetch-old-headers 'invisible)
5301 (gnus-build-all-threads)
5302 (gnus-build-old-threads)))
5303 ;; Let the Gnus agent mark articles as read.
5305 (gnus-agent-get-undownloaded-list))
5306 ;; Remove list identifiers from subject
5307 (when gnus-list-identifiers
5308 (gnus-summary-remove-list-identifiers))
5309 ;; Check whether auto-expire is to be done in this group.
5310 (setq gnus-newsgroup-auto-expire
5311 (gnus-group-auto-expirable-p group))
5312 ;; Set up the article buffer now, if necessary.
5313 (unless gnus-single-article-buffer
5314 (gnus-article-setup-buffer))
5315 ;; First and last article in this newsgroup.
5316 (when gnus-newsgroup-headers
5317 (setq gnus-newsgroup-begin
5318 (mail-header-number (car gnus-newsgroup-headers))
5321 (gnus-last-element gnus-newsgroup-headers))))
5322 ;; GROUP is successfully selected.
5323 (or gnus-newsgroup-headers t)))))
5325 (defun gnus-compute-unseen-list ()
5326 ;; The `seen' marks are treated specially.
5327 (if (not gnus-newsgroup-seen)
5328 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5329 (setq gnus-newsgroup-unseen
5330 (gnus-inverse-list-range-intersection
5331 gnus-newsgroup-articles gnus-newsgroup-seen))))
5333 (defun gnus-summary-display-make-predicate (display)
5334 (require 'gnus-agent)
5335 (when (= (length display) 1)
5336 (setq display (car display)))
5337 (unless gnus-summary-display-cache
5338 (dolist (elem (append '((unread . unread)
5341 gnus-article-mark-lists))
5342 (push (cons (cdr elem)
5344 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5345 gnus-summary-display-cache)))
5346 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5347 (gnus-category-predicate-cache gnus-summary-display-cache))
5348 (gnus-get-predicate display)))
5350 ;; Uses the dynamically bound `number' variable.
5353 (defun gnus-article-marked-p (type &optional article)
5354 (let ((article (or article number)))
5357 (memq article gnus-newsgroup-marked))
5359 (memq article gnus-newsgroup-spam-marked))
5361 (memq article gnus-newsgroup-unsendable))
5362 ((eq type 'undownload)
5363 (memq article gnus-newsgroup-undownloaded))
5364 ((eq type 'download)
5365 (memq article gnus-newsgroup-downloadable))
5367 (memq article gnus-newsgroup-unreads))
5369 (memq article gnus-newsgroup-reads))
5371 (memq article gnus-newsgroup-dormant) )
5373 (memq article gnus-newsgroup-expirable))
5375 (memq article gnus-newsgroup-replied))
5377 (memq article gnus-newsgroup-killed))
5378 ((eq type 'bookmark)
5379 (assq article gnus-newsgroup-bookmarks))
5381 (assq article gnus-newsgroup-scored))
5383 (memq article gnus-newsgroup-saved))
5385 (memq article gnus-newsgroup-cached))
5387 (memq article gnus-newsgroup-forwarded))
5389 (not (memq article gnus-newsgroup-unseen)))
5391 (memq article gnus-newsgroup-recent))
5394 (defun gnus-articles-to-read (group &optional read-all)
5395 "Find out what articles the user wants to read."
5397 ;; Select all articles if `read-all' is non-nil, or if there
5398 ;; are no unread articles.
5400 (and (zerop (length gnus-newsgroup-marked))
5401 (zerop (length gnus-newsgroup-unreads)))
5402 ;; Fetch all if the predicate is non-nil.
5403 gnus-newsgroup-display)
5404 ;; We want to select the headers for all the articles in
5405 ;; the group, so we select either all the active
5406 ;; articles in the group, or (if that's nil), the
5407 ;; articles in the cache.
5409 (gnus-uncompress-range (gnus-active group))
5410 (gnus-cache-articles-in-group group))
5411 ;; Select only the "normal" subset of articles.
5413 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5414 gnus-newsgroup-unreads)))
5415 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5416 (scored (length scored-list))
5417 (number (length articles))
5418 (marked (+ (length gnus-newsgroup-marked)
5419 (length gnus-newsgroup-dormant)))
5424 ((numberp gnus-newsgroup-display)
5425 gnus-newsgroup-display)
5429 ((and (or (<= scored marked) (= scored number))
5430 (numberp gnus-large-newsgroup)
5431 (> number gnus-large-newsgroup))
5432 (let* ((cursor-in-echo-area nil)
5433 (initial (gnus-parameter-large-newsgroup-initial
5434 gnus-newsgroup-name))
5438 "How many articles from %s (%s %d): "
5440 (gnus-group-decoded-name gnus-newsgroup-name)
5442 (if initial "max" "default")
5445 (cons (number-to-string initial)
5447 (if (string-match "^[ \t]*$" input) number input)))
5448 ((and (> scored marked) (< scored number)
5449 (> (- scored number) 20))
5452 (format "%s %s (%d scored, %d total): "
5453 "How many articles from"
5454 (gnus-group-decoded-name group)
5456 (if (string-match "^[ \t]*$" input)
5460 (message "Quit getting the articles to read")
5462 (setq select (if (stringp select) (string-to-number select) select))
5463 (if (or (null select) (zerop select))
5465 (if (and (not (zerop scored)) (<= (abs select) scored))
5467 (setq articles (sort scored-list '<))
5468 (setq number (length articles)))
5469 (setq articles (copy-sequence articles)))
5471 (when (< (abs select) number)
5473 ;; Select the N oldest articles.
5474 (setcdr (nthcdr (1- (abs select)) articles) nil)
5475 ;; Select the N most recent articles.
5476 (setq articles (nthcdr (- number select) articles))))
5477 (setq gnus-newsgroup-unselected
5478 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5479 (when gnus-alter-articles-to-read-function
5482 (funcall gnus-alter-articles-to-read-function
5483 gnus-newsgroup-name articles)
5487 (defun gnus-killed-articles (killed articles)
5490 (when (inline (gnus-member-of-range (car articles) killed))
5491 (push (car articles) out))
5492 (setq articles (cdr articles)))
5495 (defun gnus-uncompress-marks (marks)
5496 "Uncompress the mark ranges in MARKS."
5497 (let ((uncompressed '(score bookmark))
5500 (if (memq (caar marks) uncompressed)
5501 (push (car marks) out)
5502 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5503 (setq marks (cdr marks)))
5506 (defun gnus-article-mark-to-type (mark)
5507 "Return the type of MARK."
5508 (or (cadr (assq mark gnus-article-special-mark-lists))
5511 (defun gnus-article-unpropagatable-p (mark)
5512 "Return whether MARK should be propagated to back end."
5513 (memq mark gnus-article-unpropagated-mark-lists))
5515 (defun gnus-adjust-marked-articles (info)
5516 "Set all article lists and remove all marks that are no longer valid."
5517 (let* ((marked-lists (gnus-info-marks info))
5518 (active (gnus-active (gnus-info-group info)))
5521 (types gnus-article-mark-lists)
5522 marks var articles article mark mark-type
5525 (dolist (marks marked-lists)
5526 (setq mark (car marks)
5527 mark-type (gnus-article-mark-to-type mark)
5528 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5530 ;; We set the variable according to the type of the marks list,
5531 ;; and then adjust the marks to a subset of the active articles.
5533 ;; Adjust "simple" lists - compressed yet unsorted
5534 ((eq mark-type 'list)
5535 ;; Simultaneously uncompress and clip to active range
5536 ;; See gnus-uncompress-range for a description of possible marks
5538 (if (not (cadr marks))
5540 (setq articles (if (numberp (cddr marks))
5546 (while (setq article (pop articles))
5547 (cond ((consp article)
5548 (setq bgn (max (car article) min)
5549 end (min (cdr article) max))
5551 (setq l (setcdr l (cons bgn nil))
5553 ((and (<= min article)
5555 (setq l (setcdr l (cons article nil))))))
5556 (set var (cdr lh)))))
5558 ((eq mark-type 'tuple)
5559 (set var (setq articles (cdr marks)))
5560 (when (not (listp (cdr (symbol-value var))))
5561 (set var (list (symbol-value var))))
5562 (when (not (listp (cdr articles)))
5563 (setq articles (list articles)))
5565 (when (or (not (consp (setq article (pop articles))))
5566 (< (car article) min)
5567 (> (car article) max))
5568 (set var (delq article (symbol-value var))))))
5569 ;; Adjust ranges (sloppily).
5570 ((eq mark-type 'range)
5573 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5574 ;; It should be (seen (NUM1 . NUM2)).
5575 (when (numberp (cddr marks))
5576 (setcdr marks (list (cdr marks))))
5577 (setq articles (cdr marks))
5578 (while (and articles
5579 (or (and (consp (car articles))
5580 (> min (cdar articles)))
5581 (and (numberp (car articles))
5582 (> min (car articles)))))
5584 (set var articles))))))))
5586 (defun gnus-update-missing-marks (missing)
5587 "Go through the list of MISSING articles and remove them from the mark lists."
5590 ;; Go through all types.
5591 (dolist (elem gnus-article-mark-lists)
5592 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5593 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5594 (when (symbol-value var)
5595 ;; This list has articles. So we delete all missing
5596 ;; articles from it.
5599 (set var (delq (pop m) (symbol-value var))))))))))
5601 (defun gnus-update-marks ()
5602 "Enter the various lists of marked articles into the newsgroup info list."
5603 (let ((types gnus-article-mark-lists)
5604 (info (gnus-get-info gnus-newsgroup-name))
5605 type list newmarked symbol delta-marks)
5607 ;; Add all marks lists to the list of marks lists.
5608 (while (setq type (pop types))
5609 (setq list (symbol-value
5611 (intern (format "gnus-newsgroup-%s" (car type))))))
5614 ;; Get rid of the entries of the articles that have the
5616 (when (and (eq (cdr type) 'score)
5620 (prev (cons nil list))
5623 (if (or (not (consp (car arts)))
5624 (= (cdar arts) gnus-summary-default-score))
5625 (setcdr prev (cdr arts))
5627 (setq arts (cdr arts)))
5628 (setq list (cdr all)))))
5630 (when (eq (cdr type) 'seen)
5631 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5633 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5634 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5636 (when (and (gnus-check-backend-function
5637 'request-set-mark gnus-newsgroup-name)
5638 (not (gnus-article-unpropagatable-p (cdr type))))
5639 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5640 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5641 (add (gnus-remove-from-range
5642 (gnus-copy-sequence list) old)))
5644 (push (list add 'add (list (cdr type))) delta-marks))
5646 (push (list del 'del (list (cdr type))) delta-marks))))
5649 (push (cons (cdr type) list) newmarked)))
5652 (unless (gnus-check-group gnus-newsgroup-name)
5653 (error "Can't open server for %s" gnus-newsgroup-name))
5654 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5656 ;; Enter these new marks into the info of the group.
5658 (setcar (nthcdr 3 info) newmarked)
5659 ;; Add the marks lists to the end of the info.
5661 (setcdr (nthcdr 2 info) (list newmarked))))
5663 ;; Cut off the end of the info if there's nothing else there.
5667 (when (nthcdr (decf i) info)
5668 (setcdr (nthcdr i info) nil)))))))
5670 (defun gnus-set-mode-line (where)
5671 "Set the mode line of the article or summary buffers.
5672 If WHERE is `summary', the summary mode line format will be used."
5673 ;; Is this mode line one we keep updated?
5674 (when (and (memq where gnus-updated-mode-lines)
5676 (intern (format "gnus-%s-mode-line-format-spec" where))))
5679 ;; We evaluate this in the summary buffer since these
5680 ;; variables are buffer-local to that buffer.
5681 (set-buffer gnus-summary-buffer)
5682 ;; We bind all these variables that are used in the `eval' form
5684 (let* ((mformat (symbol-value
5686 (format "gnus-%s-mode-line-format-spec" where))))
5687 (gnus-tmp-group-name (gnus-group-decoded-name
5688 gnus-newsgroup-name))
5689 (gnus-tmp-article-number (or gnus-current-article 0))
5690 (gnus-tmp-unread gnus-newsgroup-unreads)
5691 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5692 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5693 (gnus-tmp-unread-and-unselected
5694 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5695 (zerop gnus-tmp-unselected))
5697 ((zerop gnus-tmp-unselected)
5698 (format "{%d more}" gnus-tmp-unread-and-unticked))
5699 (t (format "{%d(+%d) more}"
5700 gnus-tmp-unread-and-unticked
5701 gnus-tmp-unselected))))
5703 (if (and gnus-current-headers
5704 (vectorp gnus-current-headers))
5705 (gnus-mode-string-quote
5706 (mail-header-subject gnus-current-headers))
5708 bufname-length max-len
5709 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5710 (setq mode-string (eval mformat))
5711 (setq bufname-length (if (string-match "%b" mode-string)
5714 (if (eq where 'summary)
5716 (get-buffer gnus-article-buffer))))
5719 (setq max-len (max 4 (if gnus-mode-non-string-length
5721 gnus-mode-non-string-length
5723 (length mode-string))))
5724 ;; We might have to chop a bit of the string off...
5725 (when (> (length mode-string) max-len)
5727 (concat (truncate-string-to-width mode-string (- max-len 3))
5729 ;; Pad the mode string a bit.
5730 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5731 ;; Update the mode line.
5732 (setq mode-line-buffer-identification
5733 (gnus-mode-line-buffer-identification (list mode-string)))
5734 (set-buffer-modified-p t))))
5736 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5737 "Go through the HEADERS list and add all Xrefs to a hash table.
5738 The resulting hash table is returned, or nil if no Xrefs were found."
5739 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5740 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5741 (xref-hashtb (gnus-make-hashtable))
5742 start group entry number xrefs header)
5744 (setq header (pop headers))
5745 (when (and (setq xrefs (mail-header-xref header))
5746 (not (memq (setq number (mail-header-number header))
5749 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5750 (setq start (match-end 0))
5751 (setq group (if prefix
5752 (concat prefix (substring xrefs (match-beginning 1)
5754 (substring xrefs (match-beginning 1) (match-end 1))))
5756 (string-to-number (substring xrefs (match-beginning 2)
5758 (if (setq entry (gnus-gethash group xref-hashtb))
5759 (setcdr entry (cons number (cdr entry)))
5760 (gnus-sethash group (cons number nil) xref-hashtb)))))
5761 (and start xref-hashtb)))
5763 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5764 "Look through all the headers and mark the Xrefs as read."
5765 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5766 name info xref-hashtb idlist method nth4)
5768 (set-buffer gnus-group-buffer)
5769 (when (setq xref-hashtb
5770 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5773 (unless (string= from-newsgroup (setq name (symbol-name group)))
5774 (setq idlist (symbol-value group))
5775 ;; Dead groups are not updated.
5777 (setq info (gnus-get-info name))
5778 (when (stringp (setq nth4 (gnus-info-method info)))
5779 (setq nth4 (gnus-server-to-method nth4))))
5780 ;; Only do the xrefs if the group has the same
5781 ;; select method as the group we have just read.
5782 (or (gnus-methods-equal-p
5783 nth4 (gnus-find-method-for-group from-newsgroup))
5785 (equal nth4 (setq method (gnus-find-method-for-group
5787 (and (equal (car nth4) (car method))
5788 (equal (nth 1 nth4) (nth 1 method))))
5789 gnus-use-cross-reference
5790 (or (not (eq gnus-use-cross-reference t))
5792 ;; Only do cross-references on subscribed
5793 ;; groups, if that is what is wanted.
5794 (<= (gnus-info-level info) gnus-level-subscribed))
5795 (gnus-group-make-articles-read name idlist))))
5798 (defun gnus-compute-read-articles (group articles)
5799 (let* ((entry (gnus-group-entry group))
5800 (info (nth 2 entry))
5801 (active (gnus-active group))
5804 ;; First peel off all invalid article numbers.
5806 (let ((ids articles)
5808 (while (setq id (pop ids))
5809 (when (and first (> id (cdr active)))
5810 ;; We'll end up in this situation in one particular
5811 ;; obscure situation. If you re-scan a group and get
5812 ;; a new article that is cross-posted to a different
5813 ;; group that has not been re-scanned, you might get
5814 ;; crossposted article that has a higher number than
5815 ;; Gnus believes possible. So we re-activate this
5816 ;; group as well. This might mean doing the
5817 ;; crossposting thingy will *increase* the number
5818 ;; of articles in some groups. Tsk, tsk.
5819 (setq active (or (gnus-activate-group group) active)))
5820 (when (or (> id (cdr active))
5821 (< id (car active)))
5822 (setq articles (delq id articles))))))
5823 ;; If the read list is nil, we init it.
5825 (null (gnus-info-read info))
5827 (setq ninfo (cons 1 (1- (car active))))
5828 (setq ninfo (gnus-info-read info)))
5829 ;; Then we add the read articles to the range.
5831 ninfo (setq articles (sort articles '<))))))
5833 (defun gnus-group-make-articles-read (group articles)
5834 "Update the info of GROUP to say that ARTICLES are read."
5836 (entry (gnus-group-entry group))
5837 (info (nth 2 entry))
5838 (active (gnus-active group))
5841 (setq range (gnus-compute-read-articles group articles))
5842 (with-current-buffer gnus-group-buffer
5845 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5846 (gnus-info-set-read ',info ',(gnus-info-read info))
5847 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5848 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5849 (gnus-group-update-group ,group t))))
5850 ;; Add the read articles to the range.
5851 (gnus-info-set-read info range)
5852 (gnus-request-set-mark group (list (list range 'add '(read))))
5853 ;; Then we have to re-compute how many unread
5854 ;; articles there are in this group.
5858 (setq num (- (1+ (cdr active)) (car active))))
5859 ((not (listp (cdr range)))
5860 (setq num (- (cdr active) (- (1+ (cdr range))
5864 (if (numberp (car range))
5866 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5867 (setq range (cdr range)))
5868 (setq num (- (cdr active) num))))
5869 ;; Update the number of unread articles.
5871 ;; Update the group buffer.
5872 (unless (gnus-ephemeral-group-p group)
5873 (gnus-group-update-group group t))))))
5875 (defvar gnus-newsgroup-none-id 0)
5877 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5878 (let ((cur nntp-server-buffer)
5881 (with-current-buffer gnus-summary-buffer
5882 gnus-newsgroup-dependencies)))
5883 headers id end ref number
5884 (mail-parse-charset gnus-newsgroup-charset)
5885 (mail-parse-ignored-charsets
5886 (save-excursion (condition-case nil
5887 (set-buffer gnus-summary-buffer)
5889 gnus-newsgroup-ignored-charsets)))
5891 (set-buffer nntp-server-buffer)
5892 ;; Translate all TAB characters into SPACE characters.
5893 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5894 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5895 (ietf-drums-unfold-fws)
5896 (gnus-run-hooks 'gnus-parse-headers-hook)
5897 (let ((case-fold-search t)
5898 in-reply-to header p lines chars)
5899 (goto-char (point-min))
5900 ;; Search to the beginning of the next header. Error messages
5901 ;; do not begin with 2 or 3.
5902 (while (re-search-forward "^[23][0-9]+ " nil t)
5905 ;; This implementation of this function, with nine
5906 ;; search-forwards instead of the one re-search-forward and
5907 ;; a case (which basically was the old function) is actually
5908 ;; about twice as fast, even though it looks messier. You
5909 ;; can't have everything, I guess. Speed and elegance
5910 ;; doesn't always go hand in hand.
5916 (setq number (read cur))
5919 (narrow-to-region (point)
5920 (or (and (search-forward "\n.\n" nil t)
5926 (if (search-forward "\nsubject:" nil t)
5927 (funcall gnus-decode-encoded-word-function
5928 (nnheader-header-value))
5933 (if (search-forward "\nfrom:" nil t)
5934 (funcall gnus-decode-encoded-word-function
5935 (nnheader-header-value))
5940 (if (search-forward "\ndate:" nil t)
5941 (nnheader-header-value) ""))
5945 (setq id (if (re-search-forward
5946 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5947 ;; We do it this way to make sure the Message-ID
5948 ;; is (somewhat) syntactically valid.
5949 (buffer-substring (match-beginning 1)
5951 ;; If there was no message-id, we just fake one
5952 ;; to make subsequent routines simpler.
5953 (nnheader-generate-fake-message-id number))))
5957 (if (search-forward "\nreferences:" nil t)
5961 (nnheader-header-value)
5966 (search-backward ">" end t)
5969 (search-backward "<" end t)
5971 ;; Get the references from the in-reply-to header if there
5972 ;; were no references and the in-reply-to header looks
5974 (if (and (search-forward "\nin-reply-to:" nil t)
5975 (setq in-reply-to (nnheader-header-value))
5976 (string-match "<[^>]+>" in-reply-to))
5978 (setq ref (substring in-reply-to (match-beginning 0)
5980 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5981 (setq ref2 (substring in-reply-to (match-beginning 0)
5983 (when (> (length ref2) (length ref))
5990 (if (search-forward "\nchars: " nil t)
5991 (if (numberp (setq chars (ignore-errors (read cur))))
5997 (if (search-forward "\nlines: " nil t)
5998 (if (numberp (setq lines (ignore-errors (read cur))))
6004 (and (search-forward "\nxref:" nil t)
6005 (nnheader-header-value)))
6007 (when gnus-extra-headers
6008 (let ((extra gnus-extra-headers)
6012 (when (search-forward
6013 (concat "\n" (symbol-name (car extra)) ":") nil t)
6014 (push (cons (car extra) (nnheader-header-value))
6018 (when (equal id ref)
6021 (when gnus-alter-header-function
6022 (funcall gnus-alter-header-function header)
6023 (setq id (mail-header-id header)
6024 ref (gnus-parent-id (mail-header-references header))))
6027 (gnus-dependencies-add-header
6028 header dependencies force-new))
6029 (push header headers))
6030 (goto-char (point-max))
6032 (nreverse headers)))))
6034 ;; Goes through the xover lines and returns a list of vectors
6035 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6036 force-new dependencies
6037 group also-fetch-heads)
6038 "Parse the news overview data in the server buffer.
6039 Return a list of headers that match SEQUENCE (see
6040 `nntp-retrieve-headers')."
6041 ;; Get the Xref when the users reads the articles since most/some
6042 ;; NNTP servers do not include Xrefs when using XOVER.
6043 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6044 (let ((mail-parse-charset gnus-newsgroup-charset)
6045 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6046 (cur nntp-server-buffer)
6047 (dependencies (or dependencies gnus-newsgroup-dependencies))
6049 ((eq gnus-read-all-available-headers t)
6051 ((stringp gnus-read-all-available-headers)
6052 (string-match gnus-read-all-available-headers group))
6055 number headers header)
6057 (set-buffer nntp-server-buffer)
6058 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6059 ;; Allow the user to mangle the headers before parsing them.
6060 (gnus-run-hooks 'gnus-parse-headers-hook)
6061 (goto-char (point-min))
6062 (gnus-parse-without-error
6063 (while (and (or sequence allp)
6065 (setq number (read cur))
6067 (while (and sequence
6068 (< (car sequence) number))
6069 (setq sequence (cdr sequence))))
6072 (eq number (car sequence))))
6074 (setq sequence (cdr sequence))
6075 (setq header (inline
6076 (gnus-nov-parse-line
6077 number dependencies force-new)))))
6078 (push header headers))
6080 ;; A common bug in inn is that if you have posted an article and
6081 ;; then retrieves the active file, it will answer correctly --
6082 ;; the new article is included. However, a NOV entry for the
6083 ;; article may not have been generated yet, so this may fail.
6084 ;; We work around this problem by retrieving the last few
6085 ;; headers using HEAD.
6086 (if (or (not also-fetch-heads)
6088 ;; We (probably) got all the headers.
6090 (let ((gnus-nov-is-evil t))
6093 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6094 (gnus-get-newsgroup-headers))))))))
6096 (defun gnus-article-get-xrefs ()
6097 "Fill in the Xref value in `gnus-current-headers', if necessary.
6098 This is meant to be called in `gnus-article-internal-prepare-hook'."
6099 (let ((headers (with-current-buffer gnus-summary-buffer
6100 gnus-current-headers)))
6101 (or (not gnus-use-cross-reference)
6103 (and (mail-header-xref headers)
6104 (not (string= (mail-header-xref headers) "")))
6105 (let ((case-fold-search t)
6108 (nnheader-narrow-to-headers)
6109 (goto-char (point-min))
6110 (when (or (and (not (eobp))
6111 (eq (downcase (char-after)) ?x)
6112 (looking-at "Xref:"))
6113 (search-forward "\nXref:" nil t))
6114 (goto-char (1+ (match-end 0)))
6115 (setq xref (buffer-substring (point) (point-at-eol)))
6116 (mail-header-set-xref headers xref)))))))
6118 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6119 "Find article ID and insert the summary line for that article.
6120 OLD-HEADER can either be a header or a line number to insert
6121 the subject line on."
6122 (let* ((line (and (numberp old-header) old-header))
6123 (old-header (and (vectorp old-header) old-header))
6124 (header (cond ((and old-header use-old-header)
6127 (gnus-number-to-header id))
6128 (gnus-number-to-header id))
6130 (gnus-read-header id))))
6131 (number (and (numberp id) id))
6134 ;; Rebuild the thread that this article is part of and go to the
6135 ;; article we have fetched.
6136 (when (and (not gnus-show-threads)
6139 (setq d (gnus-data-find (mail-header-number old-header))))
6140 (goto-char (gnus-data-pos d))
6146 (gnus-delete-line))))))
6147 ;; Remove list identifiers from subject.
6148 (when gnus-list-identifiers
6149 (let ((gnus-newsgroup-headers (list header)))
6150 (gnus-summary-remove-list-identifiers)))
6152 (mail-header-set-number header (mail-header-number old-header)))
6153 (setq gnus-newsgroup-sparse
6154 (delq (setq number (mail-header-number header))
6155 gnus-newsgroup-sparse))
6156 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6157 (push number gnus-newsgroup-limit)
6158 (gnus-rebuild-thread (mail-header-id header) line)
6159 (gnus-summary-goto-subject number nil t))
6160 (when (and (numberp number)
6162 ;; We have to update the boundaries even if we can't fetch the
6163 ;; article if ID is a number -- so that the next `P' or `N'
6164 ;; command will fetch the previous (or next) article even
6165 ;; if the one we tried to fetch this time has been canceled.
6166 (when (> number gnus-newsgroup-end)
6167 (setq gnus-newsgroup-end number))
6168 (when (< number gnus-newsgroup-begin)
6169 (setq gnus-newsgroup-begin number))
6170 (setq gnus-newsgroup-unselected
6171 (delq number gnus-newsgroup-unselected)))
6172 ;; Report back a success?
6173 (and header (mail-header-number header))))
6175 ;;; Process/prefix in the summary buffer
6177 (defun gnus-summary-work-articles (n)
6178 "Return a list of articles to be worked upon.
6179 The prefix argument, the list of process marked articles, and the
6180 current article will be taken into consideration."
6182 (set-buffer gnus-summary-buffer)
6185 ;; A numerical prefix has been given.
6186 (setq n (prefix-numeric-value n))
6187 (let ((backward (< n 0))
6188 (n (abs (prefix-numeric-value n)))
6193 (push (setq article (gnus-summary-article-number))
6196 (gnus-summary-find-prev nil article)
6197 (gnus-summary-find-next nil article)))
6199 (nreverse articles)))
6200 ((and (gnus-region-active-p) (mark))
6201 (message "region active")
6202 ;; Work on the region between point and mark.
6203 (let ((max (max (point) (mark)))
6206 (goto-char (min (min (point) (mark))))
6209 (push (setq article (gnus-summary-article-number)) articles)
6210 (gnus-summary-find-next nil article)
6212 (nreverse articles))))
6213 (gnus-newsgroup-processable
6214 ;; There are process-marked articles present.
6215 ;; Save current state.
6216 (gnus-summary-save-process-mark)
6218 (reverse gnus-newsgroup-processable))
6220 ;; Just return the current article.
6221 (list (gnus-summary-article-number))))))
6223 (defmacro gnus-summary-iterate (arg &rest forms)
6224 "Iterate over the process/prefixed articles and do FORMS.
6225 ARG is the interactive prefix given to the command. FORMS will be
6226 executed with point over the summary line of the articles."
6227 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6228 `(let ((,articles (gnus-summary-work-articles ,arg)))
6230 (gnus-summary-goto-subject (car ,articles))
6234 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6235 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6237 (defun gnus-summary-save-process-mark ()
6238 "Push the current set of process marked articles on the stack."
6240 (push (copy-sequence gnus-newsgroup-processable)
6241 gnus-newsgroup-process-stack))
6243 (defun gnus-summary-kill-process-mark ()
6244 "Push the current set of process marked articles on the stack and unmark."
6246 (gnus-summary-save-process-mark)
6247 (gnus-summary-unmark-all-processable))
6249 (defun gnus-summary-yank-process-mark ()
6250 "Pop the last process mark state off the stack and restore it."
6252 (unless gnus-newsgroup-process-stack
6253 (error "Empty mark stack"))
6254 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6256 (defun gnus-summary-process-mark-set (set)
6257 "Make SET into the current process marked articles."
6258 (gnus-summary-unmark-all-processable)
6259 (mapc 'gnus-summary-set-process-mark set))
6261 ;;; Searching and stuff
6263 (defun gnus-summary-search-group (&optional backward use-level)
6264 "Search for next unread newsgroup.
6265 If optional argument BACKWARD is non-nil, search backward instead."
6267 (set-buffer gnus-group-buffer)
6268 (when (gnus-group-search-forward
6269 backward nil (if use-level (gnus-group-group-level) nil))
6270 (gnus-group-group-name))))
6272 (defun gnus-summary-best-group (&optional exclude-group)
6273 "Find the name of the best unread group.
6274 If EXCLUDE-GROUP, do not go to this group."
6275 (with-current-buffer gnus-group-buffer
6277 (gnus-group-best-unread-group exclude-group))))
6279 (defun gnus-summary-find-next (&optional unread article backward)
6281 (gnus-summary-find-prev unread article)
6282 (let* ((dummy (gnus-summary-article-intangible-p))
6283 (article (or article (gnus-summary-article-number)))
6284 (data (gnus-data-find-list article))
6286 (when (and (not dummy)
6287 (or (not gnus-summary-check-current)
6289 (not (gnus-data-unread-p (car data)))))
6290 (setq data (cdr data)))
6295 (unless (memq (gnus-data-number (car data))
6297 ((eq gnus-auto-goto-ignores
6298 'always-undownloaded)
6299 gnus-newsgroup-undownloaded)
6302 ((eq gnus-auto-goto-ignores
6304 gnus-newsgroup-unfetched)
6305 ((eq gnus-auto-goto-ignores
6307 gnus-newsgroup-undownloaded)))
6308 (when (gnus-data-unread-p (car data))
6309 (setq result (car data)
6311 (setq data (cdr data)))
6314 (goto-char (gnus-data-pos result))
6315 (gnus-data-number result)))))
6317 (defun gnus-summary-find-prev (&optional unread article)
6318 (let* ((eobp (eobp))
6319 (article (or article (gnus-summary-article-number)))
6320 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6322 (when (and (not eobp)
6323 (or (not gnus-summary-check-current)
6325 (not (gnus-data-unread-p (car data)))))
6326 (setq data (cdr data)))
6331 (unless (memq (gnus-data-number (car data))
6333 ((eq gnus-auto-goto-ignores
6334 'always-undownloaded)
6335 gnus-newsgroup-undownloaded)
6338 ((eq gnus-auto-goto-ignores
6340 gnus-newsgroup-unfetched)
6341 ((eq gnus-auto-goto-ignores
6343 gnus-newsgroup-undownloaded)))
6344 (when (gnus-data-unread-p (car data))
6345 (setq result (car data)
6347 (setq data (cdr data)))
6350 (goto-char (gnus-data-pos result))
6351 (gnus-data-number result))))
6353 (defun gnus-summary-find-subject (subject &optional unread backward article)
6354 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6355 (article (or article (gnus-summary-article-number)))
6356 (articles (gnus-data-list backward))
6357 (arts (gnus-data-find-list article articles))
6359 (when (or (not gnus-summary-check-current)
6361 (not (gnus-data-unread-p (car arts))))
6362 (setq arts (cdr arts)))
6364 (and (or (not unread)
6365 (gnus-data-unread-p (car arts)))
6366 (vectorp (gnus-data-header (car arts)))
6368 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6369 (setq result (car arts)
6371 (setq arts (cdr arts)))
6373 (goto-char (gnus-data-pos result))
6374 (gnus-data-number result))))
6376 (defun gnus-summary-search-forward (&optional unread subject backward)
6377 "Search forward for an article.
6378 If UNREAD, look for unread articles. If SUBJECT, look for
6379 articles with that subject. If BACKWARD, search backward instead."
6380 (cond (subject (gnus-summary-find-subject subject unread backward))
6381 (backward (gnus-summary-find-prev unread))
6382 (t (gnus-summary-find-next unread))))
6384 (defun gnus-recenter (&optional n)
6385 "Center point in window and redisplay frame.
6386 Also do horizontal recentering."
6388 (when (and gnus-auto-center-summary
6389 (not (eq gnus-auto-center-summary 'vertical)))
6390 (gnus-horizontal-recenter))
6393 (defun gnus-summary-recenter ()
6394 "Center point in the summary window.
6395 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6396 displayed, no centering will be performed."
6397 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6398 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6400 ;; The user has to want it.
6401 (when gnus-auto-center-summary
6402 (let* ((top (cond ((< (window-height) 4) 0)
6403 ((< (window-height) 7) 1)
6404 (t (if (numberp gnus-auto-center-summary)
6405 gnus-auto-center-summary
6406 (/ (1- (window-height)) 2)))))
6407 (height (1- (window-height)))
6408 (bottom (save-excursion (goto-char (point-max))
6409 (forward-line (- height))
6411 (window (get-buffer-window (current-buffer))))
6412 (when (get-buffer-window gnus-article-buffer)
6413 ;; Only do recentering when the article buffer is displayed,
6414 ;; Set the window start to either `bottom', which is the biggest
6415 ;; possible valid number, or the second line from the top,
6416 ;; whichever is the least.
6417 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6418 (if (> bottom top-pos)
6419 ;; Keep the second line from the top visible
6420 (set-window-start window top-pos t)
6421 ;; Try to keep the bottom line visible; if it's partially
6422 ;; obscured, either scroll one more line to make it fully
6423 ;; visible, or revert to using TOP-POS.
6425 (goto-char (point-max))
6427 (let ((last-line-start (point)))
6429 (set-window-start window (point) t)
6430 (when (not (pos-visible-in-window-p last-line-start window))
6432 (set-window-start window (min (point) top-pos) t)))))))
6433 ;; Do horizontal recentering while we're at it.
6434 (when (and (get-buffer-window (current-buffer) t)
6435 (not (eq gnus-auto-center-summary 'vertical)))
6436 (let ((selected (selected-window)))
6437 (select-window (get-buffer-window (current-buffer) t))
6438 (gnus-summary-position-point)
6439 (gnus-horizontal-recenter)
6440 (select-window selected))))))
6442 (defun gnus-summary-jump-to-group (newsgroup)
6443 "Move point to NEWSGROUP in group mode buffer."
6444 ;; Keep update point of group mode buffer if visible.
6445 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6446 (save-window-excursion
6447 ;; Take care of tree window mode.
6448 (when (get-buffer-window gnus-group-buffer)
6449 (pop-to-buffer gnus-group-buffer))
6450 (gnus-group-jump-to-group newsgroup))
6452 ;; Take care of tree window mode.
6453 (if (get-buffer-window gnus-group-buffer)
6454 (pop-to-buffer gnus-group-buffer)
6455 (set-buffer gnus-group-buffer))
6456 (gnus-group-jump-to-group newsgroup))))
6458 ;; This function returns a list of article numbers based on the
6459 ;; difference between the ranges of read articles in this group and
6460 ;; the range of active articles.
6461 (defun gnus-list-of-unread-articles (group)
6462 (let* ((read (gnus-info-read (gnus-get-info group)))
6463 (active (or (gnus-active group) (gnus-activate-group group)))
6464 (last (or (cdr active)
6465 (error "Group %s couldn't be activated " group)))
6467 ;; If none are read, then all are unread.
6469 (setq first (car active))
6470 ;; If the range of read articles is a single range, then the
6471 ;; first unread article is the article after the last read
6472 ;; article. Sounds logical, doesn't it?
6473 (if (and (not (listp (cdr read)))
6474 (or (< (car read) (car active))
6475 (progn (setq read (list read))
6477 (setq first (max (car active) (1+ (cdr read))))
6478 ;; `read' is a list of ranges.
6479 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6482 (setq first (car active)))
6485 (while (< first nlast)
6486 (setq unread (cons first unread)
6488 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6489 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6490 (setq read (cdr read)))))
6491 ;; And add the last unread articles.
6492 (while (<= first last)
6493 (setq unread (cons first unread)
6495 ;; Return the list of unread articles.
6496 (delq 0 (nreverse unread))))
6498 (defun gnus-list-of-read-articles (group)
6499 "Return a list of unread, unticked and non-dormant articles."
6500 (let* ((info (gnus-get-info group))
6501 (marked (gnus-info-marks info))
6502 (active (gnus-active group)))
6504 (gnus-list-range-difference
6505 (gnus-list-range-difference
6506 (gnus-sorted-complement
6507 (gnus-uncompress-range active)
6508 (gnus-list-of-unread-articles group))
6509 (cdr (assq 'dormant marked)))
6510 (cdr (assq 'tick marked))))))
6512 ;; This function returns a sequence of article numbers based on the
6513 ;; difference between the ranges of read articles in this group and
6514 ;; the range of active articles.
6515 (defun gnus-sequence-of-unread-articles (group)
6516 (let* ((read (gnus-info-read (gnus-get-info group)))
6517 (active (or (gnus-active group) (gnus-activate-group group)))
6520 ;; If none are read, then all are unread.
6522 (setq first (car active))
6523 ;; If the range of read articles is a single range, then the
6524 ;; first unread article is the article after the last read
6525 ;; article. Sounds logical, doesn't it?
6526 (if (and (not (listp (cdr read)))
6527 (or (< (car read) (car active))
6528 (progn (setq read (list read))
6530 (setq first (max (car active) (1+ (cdr read))))
6531 ;; `read' is a list of ranges.
6532 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6535 (setq first (car active)))
6538 (push (cons first nlast) unread))
6539 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6540 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6541 (setq read (cdr read)))))
6542 ;; And add the last unread articles.
6543 (cond ((< first last)
6544 (push (cons first last) unread))
6546 (push first unread)))
6547 ;; Return the sequence of unread articles.
6548 (delq 0 (nreverse unread))))
6550 ;; Various summary commands
6552 (defun gnus-summary-select-article-buffer ()
6553 "Reconfigure windows to show article buffer."
6555 (if (not (gnus-buffer-live-p gnus-article-buffer))
6556 (error "There is no article buffer for this summary buffer")
6557 (gnus-configure-windows 'article)
6558 (select-window (get-buffer-window gnus-article-buffer))))
6560 (defun gnus-summary-universal-argument (arg)
6561 "Perform any operation on all articles that are process/prefixed."
6563 (let ((articles (gnus-summary-work-articles arg))
6570 (substitute-command-keys
6571 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6573 (gnus-error 1 "Undefined key")
6576 (gnus-summary-goto-subject (setq article (pop articles)))
6577 (let (gnus-newsgroup-processable)
6578 (command-execute func))
6579 (gnus-summary-remove-process-mark article)))))
6580 (gnus-summary-position-point))
6582 (defun gnus-summary-toggle-truncation (&optional arg)
6583 "Toggle truncation of summary lines.
6584 With ARG, turn line truncation on if ARG is positive."
6586 (setq truncate-lines
6587 (if (null arg) (not truncate-lines)
6588 (> (prefix-numeric-value arg) 0)))
6591 (defun gnus-summary-find-for-reselect ()
6592 "Return the number of an article to stay on across a reselect.
6593 The current article is considered, then following articles, then previous
6594 articles. An article is sought which is not cancelled and isn't a temporary
6595 insertion from another group. If there's no such then return a dummy 0."
6597 (dolist (rev '(nil t))
6598 (unless found ; don't demand the reverse list if we don't need it
6599 (let ((data (gnus-data-find-list
6600 (gnus-summary-article-number) (gnus-data-list rev))))
6601 (while (and data (not found))
6602 (if (and (< 0 (gnus-data-number (car data)))
6603 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6604 (setq found (gnus-data-number (car data))))
6605 (setq data (cdr data))))))
6608 (defun gnus-summary-reselect-current-group (&optional all rescan)
6609 "Exit and then reselect the current newsgroup.
6610 The prefix argument ALL means to select all articles."
6612 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6613 (error "Ephemeral groups can't be reselected"))
6614 (let ((current-subject (gnus-summary-find-for-reselect))
6615 (group gnus-newsgroup-name))
6616 (setq gnus-newsgroup-begin nil)
6617 (gnus-summary-exit nil 'leave-hidden)
6618 ;; We have to adjust the point of group mode buffer because
6619 ;; point was moved to the next unread newsgroup by exiting.
6620 (gnus-summary-jump-to-group group)
6623 (gnus-group-get-new-news-this-group 1)))
6624 (gnus-group-read-group all t)
6625 (gnus-summary-goto-subject current-subject nil t)))
6627 (defun gnus-summary-rescan-group (&optional all)
6628 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6630 (gnus-summary-reselect-current-group all t))
6632 (defun gnus-summary-update-info (&optional non-destructive)
6634 (let ((group gnus-newsgroup-name))
6636 (when gnus-newsgroup-kill-headers
6637 (setq gnus-newsgroup-killed
6638 (gnus-compress-sequence
6640 (gnus-list-range-intersection
6641 gnus-newsgroup-unselected gnus-newsgroup-killed)
6642 gnus-newsgroup-unreads)
6644 (unless (listp (cdr gnus-newsgroup-killed))
6645 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6646 (let ((headers gnus-newsgroup-headers))
6647 ;; Set the new ranges of read articles.
6648 (with-current-buffer gnus-group-buffer
6649 (gnus-undo-force-boundary))
6650 (gnus-update-read-articles
6651 group (gnus-sorted-union
6652 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6653 ;; Set the current article marks.
6654 (let ((gnus-newsgroup-scored
6655 (if (and (not gnus-save-score)
6656 (not non-destructive))
6658 gnus-newsgroup-scored)))
6660 (gnus-update-marks)))
6661 ;; Do the cross-ref thing.
6662 (when gnus-use-cross-reference
6663 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6664 ;; Do not switch windows but change the buffer to work.
6665 (set-buffer gnus-group-buffer)
6666 (unless (gnus-ephemeral-group-p group)
6667 (gnus-group-update-group group)))))))
6669 (defun gnus-summary-save-newsrc (&optional force)
6670 "Save the current number of read/marked articles in the dribble buffer.
6671 The dribble buffer will then be saved.
6672 If FORCE (the prefix), also save the .newsrc file(s)."
6674 (gnus-summary-update-info t)
6676 (gnus-save-newsrc-file)
6677 (gnus-dribble-save)))
6679 (defun gnus-summary-exit (&optional temporary leave-hidden)
6680 "Exit reading current newsgroup, and then return to group selection mode.
6681 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6683 (gnus-set-global-variables)
6684 (when (gnus-buffer-live-p gnus-article-buffer)
6686 (set-buffer gnus-article-buffer)
6687 (mm-destroy-parts gnus-article-mime-handles)
6688 ;; Set it to nil for safety reason.
6689 (setq gnus-article-mime-handle-alist nil)
6690 (setq gnus-article-mime-handles nil)))
6691 (gnus-kill-save-kill-buffer)
6692 (gnus-async-halt-prefetch)
6693 (let* ((group gnus-newsgroup-name)
6694 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6695 (gnus-group-is-exiting-p t)
6698 (buf (current-buffer)))
6700 ;; Do adaptive scoring, and possibly save score files.
6701 (when gnus-newsgroup-adaptive
6702 (gnus-score-adaptive))
6703 (when gnus-use-scoring
6705 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6706 ;; If we have several article buffers, we kill them at exit.
6707 (unless gnus-single-article-buffer
6708 (gnus-kill-buffer gnus-original-article-buffer)
6709 (setq gnus-article-current nil))
6710 (when gnus-use-cache
6711 (gnus-cache-possibly-remove-articles)
6712 (gnus-cache-save-buffers))
6713 (gnus-async-prefetch-remove-group group)
6714 (when gnus-suppress-duplicates
6715 (gnus-dup-enter-articles))
6716 (when gnus-use-trees
6717 (gnus-tree-close group))
6718 (when gnus-use-cache
6719 (gnus-cache-write-active))
6720 ;; Remove entries for this group.
6721 (nnmail-purge-split-history (gnus-group-real-name group))
6722 ;; Make all changes in this group permanent.
6724 (gnus-run-hooks 'gnus-exit-group-hook)
6725 (gnus-summary-update-info))
6726 (gnus-close-group group)
6727 ;; Make sure where we were, and go to next newsgroup.
6728 (set-buffer gnus-group-buffer)
6730 (gnus-group-jump-to-group group))
6731 (gnus-run-hooks 'gnus-summary-exit-hook)
6732 (unless (or quit-config
6733 ;; If this group has disappeared from the summary
6734 ;; buffer, don't skip forwards.
6735 (not (string= group (gnus-group-group-name))))
6736 (gnus-group-next-unread-group 1))
6737 (setq group-point (point))
6740 ;; If we have several article buffers, we kill them at exit.
6741 (unless gnus-single-article-buffer
6742 (gnus-kill-buffer gnus-article-buffer)
6743 (gnus-kill-buffer gnus-original-article-buffer)
6744 (setq gnus-article-current nil))
6746 (if (not gnus-kill-summary-on-exit)
6748 (gnus-deaden-summary)
6750 ;; We set all buffer-local variables to nil. It is unclear why
6751 ;; this is needed, but if we don't, buffer-local variables are
6752 ;; not garbage-collected, it seems. This would the lead to en
6753 ;; ever-growing Emacs.
6754 (gnus-summary-clear-local-variables)
6755 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6756 (gnus-summary-clear-local-variables))
6757 (when (get-buffer gnus-article-buffer)
6758 (bury-buffer gnus-article-buffer))
6759 ;; Return to group mode buffer.
6760 (when (eq mode 'gnus-summary-mode)
6761 (gnus-kill-buffer buf)))
6762 (setq gnus-current-select-method gnus-select-method)
6763 (set-buffer gnus-group-buffer)
6765 (gnus-handle-ephemeral-exit quit-config)
6766 (goto-char group-point)
6767 ;; If gnus-group-buffer is already displayed, make sure we also move
6768 ;; the cursor in the window that displays it.
6769 (let ((win (get-buffer-window (current-buffer) 0)))
6770 (if win (set-window-point win (point))))
6771 (unless leave-hidden
6772 (gnus-configure-windows 'group 'force)))
6773 ;; Clear the current group name.
6775 (setq gnus-newsgroup-name nil)))))
6777 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6778 (defun gnus-summary-exit-no-update (&optional no-questions)
6779 "Quit reading current newsgroup without updating read article info."
6781 (let* ((group gnus-newsgroup-name)
6782 (gnus-group-is-exiting-p t)
6783 (gnus-group-is-exiting-without-update-p t)
6784 (quit-config (gnus-group-quit-config group)))
6785 (when (or no-questions
6787 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6788 (gnus-async-halt-prefetch)
6789 (run-hooks 'gnus-summary-prepare-exit-hook)
6790 (when (gnus-buffer-live-p gnus-article-buffer)
6792 (set-buffer gnus-article-buffer)
6793 (mm-destroy-parts gnus-article-mime-handles)
6794 ;; Set it to nil for safety reason.
6795 (setq gnus-article-mime-handle-alist nil)
6796 (setq gnus-article-mime-handles nil)))
6797 ;; If we have several article buffers, we kill them at exit.
6798 (unless gnus-single-article-buffer
6799 (gnus-kill-buffer gnus-article-buffer)
6800 (gnus-kill-buffer gnus-original-article-buffer)
6801 (setq gnus-article-current nil))
6802 (if (not gnus-kill-summary-on-exit)
6803 (gnus-deaden-summary)
6804 (gnus-close-group group)
6805 (gnus-summary-clear-local-variables)
6806 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6807 (gnus-summary-clear-local-variables))
6808 (gnus-kill-buffer gnus-summary-buffer))
6809 (unless gnus-single-article-buffer
6810 (setq gnus-article-current nil))
6811 (when gnus-use-trees
6812 (gnus-tree-close group))
6813 (gnus-async-prefetch-remove-group group)
6814 (when (get-buffer gnus-article-buffer)
6815 (bury-buffer gnus-article-buffer))
6816 ;; Return to the group buffer.
6817 (gnus-configure-windows 'group 'force)
6818 ;; Clear the current group name.
6819 (setq gnus-newsgroup-name nil)
6820 (unless (gnus-ephemeral-group-p group)
6821 (gnus-group-update-group group))
6822 (when (equal (gnus-group-group-name) group)
6823 (gnus-group-next-unread-group 1))
6825 (gnus-handle-ephemeral-exit quit-config)))))
6827 (defun gnus-handle-ephemeral-exit (quit-config)
6828 "Handle movement when leaving an ephemeral group.
6829 The state which existed when entering the ephemeral is reset."
6830 (if (not (buffer-name (car quit-config)))
6831 (gnus-configure-windows 'group 'force)
6832 (set-buffer (car quit-config))
6833 (cond ((eq major-mode 'gnus-summary-mode)
6834 (gnus-set-global-variables))
6835 ((eq major-mode 'gnus-article-mode)
6837 ;; The `gnus-summary-buffer' variable may point
6838 ;; to the old summary buffer when using a single
6840 (unless (gnus-buffer-live-p gnus-summary-buffer)
6841 (set-buffer gnus-group-buffer))
6842 (set-buffer gnus-summary-buffer)
6843 (gnus-set-global-variables))))
6844 (if (or (eq (cdr quit-config) 'article)
6845 (eq (cdr quit-config) 'pick))
6847 ;; The current article may be from the ephemeral group
6848 ;; thus it is best that we reload this article
6850 ;; If we're exiting from a large digest, this can be
6851 ;; extremely slow. So, it's better not to reload it. -- jh.
6852 ;;(gnus-summary-show-article)
6853 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6854 (gnus-configure-windows 'pick 'force)
6855 (gnus-configure-windows (cdr quit-config) 'force)))
6856 (gnus-configure-windows (cdr quit-config) 'force))
6857 (when (eq major-mode 'gnus-summary-mode)
6858 (gnus-summary-next-subject 1 nil t)
6859 (gnus-summary-recenter)
6860 (gnus-summary-position-point))))
6864 (defvar gnus-dead-summary-mode-map nil)
6866 (unless gnus-dead-summary-mode-map
6867 (setq gnus-dead-summary-mode-map (make-keymap))
6868 (suppress-keymap gnus-dead-summary-mode-map)
6869 (substitute-key-definition
6870 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6871 (dolist (key '("\C-d" "\r" "\177" [delete]))
6872 (define-key gnus-dead-summary-mode-map
6873 key 'gnus-summary-wake-up-the-dead))
6874 (dolist (key '("q" "Q"))
6875 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6877 (defvar gnus-dead-summary-mode nil
6878 "Minor mode for Gnus summary buffers.")
6880 (defun gnus-dead-summary-mode (&optional arg)
6881 "Minor mode for Gnus summary buffers."
6883 (when (eq major-mode 'gnus-summary-mode)
6884 (make-local-variable 'gnus-dead-summary-mode)
6885 (setq gnus-dead-summary-mode
6886 (if (null arg) (not gnus-dead-summary-mode)
6887 (> (prefix-numeric-value arg) 0)))
6888 (when gnus-dead-summary-mode
6890 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6892 (defun gnus-deaden-summary ()
6893 "Make the current summary buffer into a dead summary buffer."
6894 ;; Kill any previous dead summary buffer.
6895 (when (and gnus-dead-summary
6896 (buffer-name gnus-dead-summary))
6897 (with-current-buffer gnus-dead-summary
6898 (when gnus-dead-summary-mode
6899 (kill-buffer (current-buffer)))))
6900 ;; Make this the current dead summary.
6901 (setq gnus-dead-summary (current-buffer))
6902 (gnus-dead-summary-mode 1)
6903 (let ((name (buffer-name)))
6904 (when (string-match "Summary" name)
6906 (concat (substring name 0 (match-beginning 0)) "Dead "
6907 (substring name (match-beginning 0)))
6911 (defun gnus-kill-or-deaden-summary (buffer)
6912 "Kill or deaden the summary BUFFER."
6914 (when (and (buffer-name buffer)
6915 (not gnus-single-article-buffer))
6916 (with-current-buffer buffer
6917 (gnus-kill-buffer gnus-article-buffer)
6918 (gnus-kill-buffer gnus-original-article-buffer)))
6921 (gnus-kill-summary-on-exit
6922 (when (and gnus-use-trees
6923 (gnus-buffer-exists-p buffer))
6926 (gnus-tree-close gnus-newsgroup-name)))
6927 (gnus-kill-buffer buffer))
6928 ;; Deaden the buffer.
6929 ((gnus-buffer-exists-p buffer)
6932 (gnus-deaden-summary))))))
6934 (defun gnus-summary-wake-up-the-dead (&rest args)
6935 "Wake up the dead summary buffer."
6937 (gnus-dead-summary-mode -1)
6938 (let ((name (buffer-name)))
6939 (when (string-match "Dead " name)
6941 (concat (substring name 0 (match-beginning 0))
6942 (substring name (match-end 0)))
6944 (gnus-message 3 "This dead summary is now alive again"))
6946 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6947 (defun gnus-summary-fetch-faq (&optional faq-dir)
6948 "Fetch the FAQ for the current group.
6949 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6953 (when current-prefix-arg
6955 "FAQ dir: " (and (listp gnus-group-faq-directory)
6957 gnus-group-faq-directory))))))
6958 (let (gnus-faq-buffer)
6959 (when (setq gnus-faq-buffer
6960 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6961 (gnus-configure-windows 'summary-faq))))
6963 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6964 (defun gnus-summary-describe-group (&optional force)
6965 "Describe the current newsgroup."
6967 (gnus-group-describe-group force gnus-newsgroup-name))
6969 (defun gnus-summary-describe-briefly ()
6970 "Describe summary mode commands briefly."
6972 (gnus-message 6 (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")))
6974 ;; Walking around group mode buffer from summary mode.
6976 (defun gnus-summary-next-group (&optional no-article target-group backward)
6977 "Exit current newsgroup and then select next unread newsgroup.
6978 If prefix argument NO-ARTICLE is non-nil, no article is selected
6979 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6980 previous group instead."
6982 ;; Stop pre-fetching.
6983 (gnus-async-halt-prefetch)
6984 (let ((current-group gnus-newsgroup-name)
6985 (current-buffer (current-buffer))
6987 ;; First we semi-exit this group to update Xrefs and all variables.
6988 ;; We can't do a real exit, because the window conf must remain
6989 ;; the same in case the user is prompted for info, and we don't
6990 ;; want the window conf to change before that...
6991 (gnus-summary-exit t)
6992 (while (not entered)
6993 ;; Then we find what group we are supposed to enter.
6994 (set-buffer gnus-group-buffer)
6995 (gnus-group-jump-to-group current-group)
6998 (if (eq gnus-keep-same-level 'best)
6999 (gnus-summary-best-group gnus-newsgroup-name)
7000 (gnus-summary-search-group backward gnus-keep-same-level))))
7001 (if (not target-group)
7002 ;; There are no further groups, so we return to the group
7005 (gnus-message 5 "Returning to the group buffer")
7007 (when (gnus-buffer-live-p current-buffer)
7008 (set-buffer current-buffer)
7009 (gnus-summary-exit))
7010 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7011 ;; We try to enter the target group.
7012 (gnus-group-jump-to-group target-group)
7013 (let ((unreads (gnus-group-group-unread)))
7014 (if (and (or (eq t unreads)
7015 (and unreads (not (zerop unreads))))
7016 (gnus-summary-read-group
7017 target-group nil no-article
7018 (and (buffer-name current-buffer) current-buffer)
7021 (setq current-group target-group
7022 target-group nil)))))))
7024 (defun gnus-summary-prev-group (&optional no-article)
7025 "Exit current newsgroup and then select previous unread newsgroup.
7026 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7028 (gnus-summary-next-group no-article nil t))
7030 ;; Walking around summary lines.
7032 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7033 "Go to the first subject satisfying any non-nil constraint.
7034 If UNREAD is non-nil, the article should be unread.
7035 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7036 If UNSEEN is non-nil, the article should be unseen.
7037 Returns the article selected or nil if there are no matching articles."
7041 ((null gnus-newsgroup-data)
7042 (gnus-message 3 "No articles in the group")
7044 ;; Pick the first article.
7045 ((not (or unread undownloaded unseen))
7046 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7047 (gnus-data-number (car gnus-newsgroup-data)))
7048 ;; Find the first unread article.
7050 (let ((data gnus-newsgroup-data))
7052 (let ((num (gnus-data-number (car data))))
7053 (or (memq num gnus-newsgroup-unfetched)
7054 (not (or (and unread
7055 (memq num gnus-newsgroup-unreads))
7057 (memq num gnus-newsgroup-undownloaded))
7059 (memq num gnus-newsgroup-unseen)))))))
7060 (setq data (cdr data)))
7064 (goto-char (gnus-data-pos (car data)))
7065 (gnus-data-number (car data)))
7066 (gnus-message 3 "No more%s articles"
7067 (let* ((r (when unread " unread"))
7068 (d (when undownloaded " undownloaded"))
7069 (s (when unseen " unseen"))
7070 (l (delq nil (list r d s))))
7071 (cond ((= 3 (length l))
7072 (concat r "," d ", or" s))
7074 (concat (car l) ", or" (cadr l)))
7081 (gnus-summary-position-point))))))
7083 (defun gnus-summary-next-subject (n &optional unread dont-display)
7084 "Go to next N'th summary line.
7085 If N is negative, go to the previous N'th subject line.
7086 If UNREAD is non-nil, only unread articles are selected.
7087 The difference between N and the actual number of steps taken is
7090 (let ((backward (< n 0))
7094 (gnus-summary-find-prev unread)
7095 (gnus-summary-find-next unread)))
7096 (unless (zerop (setq n (1- n)))
7097 (gnus-summary-show-thread)))
7099 (gnus-message 7 "No more%s articles"
7100 (if unread " unread" "")))
7101 (unless dont-display
7102 (gnus-summary-recenter)
7103 (gnus-summary-position-point))
7106 (defun gnus-summary-next-unread-subject (n)
7107 "Go to next N'th unread summary line."
7109 (gnus-summary-next-subject n t))
7111 (defun gnus-summary-prev-subject (n &optional unread)
7112 "Go to previous N'th summary line.
7113 If optional argument UNREAD is non-nil, only unread article is selected."
7115 (gnus-summary-next-subject (- n) unread))
7117 (defun gnus-summary-prev-unread-subject (n)
7118 "Go to previous N'th unread summary line."
7120 (gnus-summary-next-subject (- n) t))
7122 (defun gnus-summary-goto-subjects (articles)
7123 "Insert the subject header for ARTICLES in the current buffer."
7125 (dolist (article articles)
7126 (gnus-summary-goto-subject article t)))
7127 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7128 (gnus-summary-position-point))
7130 (defun gnus-summary-goto-subject (article &optional force silent)
7131 "Go the subject line of ARTICLE.
7132 If FORCE, also allow jumping to articles not currently shown."
7133 (interactive "nArticle number: ")
7134 (unless (numberp article)
7135 (error "Article %s is not a number" article))
7137 (data (gnus-data-find article)))
7138 ;; We read in the article if we have to.
7141 (gnus-summary-insert-subject
7143 (if (or (numberp force) (vectorp force)) force)
7145 (setq data (gnus-data-find article)))
7150 (gnus-message 3 "Can't find article %d" article))
7152 (let ((pt (gnus-data-pos data)))
7154 (gnus-summary-set-article-display-arrow pt))
7155 (gnus-summary-position-point)
7158 ;; Walking around summary lines with displaying articles.
7160 (defun gnus-summary-expand-window (&optional arg)
7161 "Make the summary buffer take up the entire Emacs frame.
7162 Given a prefix, will force an `article' buffer configuration."
7165 (gnus-configure-windows 'article 'force)
7166 (gnus-configure-windows 'summary 'force)))
7168 (defun gnus-summary-display-article (article &optional all-header)
7169 "Display ARTICLE in article buffer."
7170 (when (gnus-buffer-live-p gnus-article-buffer)
7171 (with-current-buffer gnus-article-buffer
7172 (mm-enable-multibyte)))
7173 (gnus-set-global-variables)
7174 (when (gnus-buffer-live-p gnus-article-buffer)
7175 (with-current-buffer gnus-article-buffer
7176 (setq gnus-article-charset gnus-newsgroup-charset)
7177 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7178 (mm-enable-multibyte)))
7182 (if gnus-summary-display-article-function
7183 (funcall gnus-summary-display-article-function article all-header)
7184 (gnus-article-prepare article all-header))
7185 (gnus-run-hooks 'gnus-select-article-hook)
7186 (when (and gnus-current-article
7187 (not (zerop gnus-current-article)))
7188 (gnus-summary-goto-subject gnus-current-article))
7189 (gnus-summary-recenter)
7190 (when (and gnus-use-trees gnus-show-threads)
7191 (gnus-possibly-generate-tree article)
7192 (gnus-highlight-selected-tree article))
7193 ;; Successfully display article.
7194 (gnus-article-set-window-start
7195 (cdr (assq article gnus-newsgroup-bookmarks))))))
7197 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7198 "Select the current article.
7199 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7200 non-nil, the article will be re-fetched even if it already present in
7201 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7203 ;; Make sure we are in the summary buffer to work around bbdb bug.
7204 (unless (eq major-mode 'gnus-summary-mode)
7205 (set-buffer gnus-summary-buffer))
7206 (let ((article (or article (gnus-summary-article-number)))
7207 (all-headers (not (not all-headers))) ;Must be t or nil.
7208 gnus-summary-display-article-function)
7210 (gnus-summary-article-pseudo-p article)
7211 (error "This is a pseudo-article"))
7213 (set-buffer gnus-summary-buffer)
7214 (if (or (and gnus-single-article-buffer
7215 (or (null gnus-current-article)
7216 (null gnus-article-current)
7217 (null (get-buffer gnus-article-buffer))
7218 (not (eq article (cdr gnus-article-current)))
7219 (not (equal (car gnus-article-current)
7220 gnus-newsgroup-name))))
7221 (and (not gnus-single-article-buffer)
7222 (or (null gnus-current-article)
7223 (not (eq gnus-current-article article))))
7225 ;; The requested article is different from the current article.
7227 (gnus-summary-display-article article all-headers)
7228 (when (gnus-buffer-live-p gnus-article-buffer)
7229 (with-current-buffer gnus-article-buffer
7230 (if (not gnus-article-decoded-p) ;; a local variable
7231 (mm-disable-multibyte))))
7232 (gnus-article-set-window-start
7233 (cdr (assq article gnus-newsgroup-bookmarks)))
7237 (defun gnus-summary-force-verify-and-decrypt ()
7238 "Display buttons for signed/encrypted parts and verify/decrypt them."
7240 (let ((mm-verify-option 'known)
7241 (mm-decrypt-option 'known)
7242 (gnus-article-emulate-mime t)
7243 (gnus-buttonized-mime-types (append (list "multipart/signed"
7244 "multipart/encrypted")
7245 gnus-buttonized-mime-types)))
7246 (gnus-summary-select-article nil 'force)))
7248 (defun gnus-summary-set-current-mark (&optional current-mark)
7249 "Obsolete function."
7252 (defun gnus-summary-next-article (&optional unread subject backward push)
7253 "Select the next article.
7254 If UNREAD, only unread articles are selected.
7255 If SUBJECT, only articles with SUBJECT are selected.
7256 If BACKWARD, the previous article is selected instead of the next."
7259 ;; Is there such an article?
7260 ((and (gnus-summary-search-forward unread subject backward)
7261 (or (gnus-summary-display-article (gnus-summary-article-number))
7262 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7263 (gnus-summary-position-point))
7264 ;; If not, we try the first unread, if that is wanted.
7266 gnus-auto-select-same
7267 (gnus-summary-first-unread-article))
7268 (gnus-summary-position-point)
7269 (gnus-message 6 "Wrapped"))
7270 ;; Try to get next/previous article not displayed in this group.
7271 ((and gnus-auto-extend-newsgroup
7272 (not unread) (not subject))
7273 (gnus-summary-goto-article
7274 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7275 nil (count-lines (point-min) (point))))
7276 ;; Go to next/previous group.
7278 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7279 (gnus-summary-jump-to-group gnus-newsgroup-name))
7280 (let ((cmd last-command-char)
7282 (with-current-buffer gnus-group-buffer
7285 (if (eq gnus-keep-same-level 'best)
7286 (gnus-summary-best-group gnus-newsgroup-name)
7287 (gnus-summary-search-group backward gnus-keep-same-level))))
7288 ;; For some reason, the group window gets selected. We change
7290 (select-window (get-buffer-window (current-buffer)))
7291 ;; Select next unread newsgroup automagically.
7293 ((or (not gnus-auto-select-next)
7295 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7296 ((or (eq gnus-auto-select-next 'quietly)
7297 (and (eq gnus-auto-select-next 'slightly-quietly)
7299 (and (eq gnus-auto-select-next 'almost-quietly)
7300 (gnus-summary-last-article-p)))
7302 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7304 (gnus-message 7 "No more%s articles (%s)..."
7305 (if unread " unread" "")
7306 (if group (concat "selecting " group)
7308 (gnus-summary-next-group nil group backward)))
7310 (when (gnus-key-press-event-p last-input-event)
7311 (gnus-summary-walk-group-buffer
7312 gnus-newsgroup-name cmd unread backward point))))))))
7314 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7315 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7316 (?\C-p (gnus-group-prev-unread-group 1))))
7317 (cursor-in-echo-area t)
7318 keve key group ended prompt)
7320 (set-buffer gnus-group-buffer)
7323 (if (eq gnus-keep-same-level 'best)
7324 (gnus-summary-best-group gnus-newsgroup-name)
7325 (gnus-summary-search-group backward gnus-keep-same-level))))
7329 "No more%s articles%s " (if unread " unread" "")
7331 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7332 (format " (Type %s for %s [%s])"
7333 (single-key-description cmd)
7334 (gnus-group-decoded-name group)
7335 (gnus-group-unread group))
7336 (format " (Type %s to exit %s)"
7337 (single-key-description cmd)
7338 (gnus-group-decoded-name gnus-newsgroup-name)))))
7339 ;; Confirm auto selection.
7340 (setq key (car (setq keve (gnus-read-event-char prompt)))
7343 ((assq key keystrokes)
7344 (let ((obuf (current-buffer)))
7345 (switch-to-buffer gnus-group-buffer)
7347 (gnus-group-jump-to-group group))
7348 (eval (cadr (assq key keystrokes)))
7349 (setq group (gnus-group-group-name))
7350 (switch-to-buffer obuf))
7354 (gnus-ephemeral-group-p gnus-newsgroup-name))
7356 (gnus-summary-next-group nil group backward)))
7358 (push (cdr keve) unread-command-events))))))
7360 (defun gnus-summary-next-unread-article ()
7361 "Select unread article after current one."
7363 (gnus-summary-next-article
7364 (or (not (eq gnus-summary-goto-unread 'never))
7365 (gnus-summary-last-article-p (gnus-summary-article-number)))
7366 (and gnus-auto-select-same
7367 (gnus-summary-article-subject))))
7369 (defun gnus-summary-prev-article (&optional unread subject)
7370 "Select the article after the current one.
7371 If UNREAD is non-nil, only unread articles are selected."
7373 (gnus-summary-next-article unread subject t))
7375 (defun gnus-summary-prev-unread-article ()
7376 "Select unread article before current one."
7378 (gnus-summary-prev-article
7379 (or (not (eq gnus-summary-goto-unread 'never))
7380 (gnus-summary-first-article-p (gnus-summary-article-number)))
7381 (and gnus-auto-select-same
7382 (gnus-summary-article-subject))))
7384 (defun gnus-summary-next-page (&optional lines circular stop)
7385 "Show next page of the selected article.
7386 If at the end of the current article, select the next article.
7387 LINES says how many lines should be scrolled up.
7389 If CIRCULAR is non-nil, go to the start of the article instead of
7390 selecting the next article when reaching the end of the current
7393 If STOP is non-nil, just stop when reaching the end of the message.
7395 Also see the variable `gnus-article-skip-boring'."
7397 (setq gnus-summary-buffer (current-buffer))
7398 (gnus-set-global-variables)
7399 (let ((article (gnus-summary-article-number))
7400 (article-window (get-buffer-window gnus-article-buffer t))
7402 ;; If the buffer is empty, we have no article.
7404 (error "No article to select"))
7405 (gnus-configure-windows 'article)
7406 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7407 (if (and (eq gnus-summary-goto-unread 'never)
7408 (not (gnus-summary-last-article-p article)))
7409 (gnus-summary-next-article)
7410 (gnus-summary-next-unread-article))
7411 (if (or (null gnus-current-article)
7412 (null gnus-article-current)
7413 (/= article (cdr gnus-article-current))
7414 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7415 ;; Selected subject is different from current article's.
7416 (gnus-summary-display-article article)
7417 (when article-window
7418 (gnus-eval-in-buffer-window gnus-article-buffer
7419 (setq endp (or (gnus-article-next-page lines)
7420 (gnus-article-only-boring-p))))
7423 (gnus-message 3 "End of message"))
7425 (gnus-summary-beginning-of-article))
7427 (gnus-message 3 "End of message"))
7429 (if (and (eq gnus-summary-goto-unread 'never)
7430 (not (gnus-summary-last-article-p article)))
7431 (gnus-summary-next-article)
7432 (gnus-summary-next-unread-article))))))))
7433 (gnus-summary-recenter)
7434 (gnus-summary-position-point)))
7436 (defun gnus-summary-prev-page (&optional lines move)
7437 "Show previous page of selected article.
7438 Argument LINES specifies lines to be scrolled down.
7439 If MOVE, move to the previous unread article if point is at
7440 the beginning of the buffer."
7442 (let ((article (gnus-summary-article-number))
7443 (article-window (get-buffer-window gnus-article-buffer t))
7445 (gnus-configure-windows 'article)
7446 (if (or (null gnus-current-article)
7447 (null gnus-article-current)
7448 (/= article (cdr gnus-article-current))
7449 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7450 ;; Selected subject is different from current article's.
7451 (gnus-summary-display-article article)
7452 (gnus-summary-recenter)
7453 (when article-window
7454 (gnus-eval-in-buffer-window gnus-article-buffer
7455 (setq endp (gnus-article-prev-page lines)))
7456 (when (and move endp)
7458 (gnus-message 3 "Beginning of message"))
7460 (if (and (eq gnus-summary-goto-unread 'never)
7461 (not (gnus-summary-first-article-p article)))
7462 (gnus-summary-prev-article)
7463 (gnus-summary-prev-unread-article))))))))
7464 (gnus-summary-position-point))
7466 (defun gnus-summary-prev-page-or-article (&optional lines)
7467 "Show previous page of selected article.
7468 Argument LINES specifies lines to be scrolled down.
7469 If at the beginning of the article, go to the next article."
7471 (gnus-summary-prev-page lines t))
7473 (defun gnus-summary-scroll-up (lines)
7474 "Scroll up (or down) one line current article.
7475 Argument LINES specifies lines to be scrolled up (or down if negative)."
7477 (gnus-configure-windows 'article)
7478 (gnus-summary-show-thread)
7479 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7480 (gnus-eval-in-buffer-window gnus-article-buffer
7482 (when (gnus-article-next-page lines)
7483 (gnus-message 3 "End of message")))
7485 (gnus-article-prev-page (- lines))))))
7486 (gnus-summary-recenter)
7487 (gnus-summary-position-point))
7489 (defun gnus-summary-scroll-down (lines)
7490 "Scroll down (or up) one line current article.
7491 Argument LINES specifies lines to be scrolled down (or up if negative)."
7493 (gnus-summary-scroll-up (- lines)))
7495 (defun gnus-summary-next-same-subject ()
7496 "Select next article which has the same subject as current one."
7498 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7500 (defun gnus-summary-prev-same-subject ()
7501 "Select previous article which has the same subject as current one."
7503 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7505 (defun gnus-summary-next-unread-same-subject ()
7506 "Select next unread article which has the same subject as current one."
7508 (gnus-summary-next-article t (gnus-summary-article-subject)))
7510 (defun gnus-summary-prev-unread-same-subject ()
7511 "Select previous unread article which has the same subject as current one."
7513 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7515 (defun gnus-summary-first-unread-article ()
7516 "Select the first unread article.
7517 Return nil if there are no unread articles."
7520 (when (gnus-summary-first-subject t)
7521 (gnus-summary-show-thread)
7522 (gnus-summary-first-subject t)
7523 (gnus-summary-display-article (gnus-summary-article-number)))
7524 (gnus-summary-position-point)))
7526 (defun gnus-summary-first-unread-subject ()
7527 "Place the point on the subject line of the first unread article.
7528 Return nil if there are no unread articles."
7531 (when (gnus-summary-first-subject t)
7532 (gnus-summary-show-thread)
7533 (gnus-summary-first-subject t))
7534 (gnus-summary-position-point)))
7536 (defun gnus-summary-first-unseen-subject ()
7537 "Place the point on the subject line of the first unseen article.
7538 Return nil if there are no unseen articles."
7541 (when (gnus-summary-first-subject nil nil t)
7542 (gnus-summary-show-thread)
7543 (gnus-summary-first-subject nil nil t))
7544 (gnus-summary-position-point)))
7546 (defun gnus-summary-first-unseen-or-unread-subject ()
7547 "Place the point on the subject line of the first unseen article or,
7548 if all article have been seen, on the subject line of the first unread
7552 (unless (when (gnus-summary-first-subject nil nil t)
7553 (gnus-summary-show-thread)
7554 (gnus-summary-first-subject nil nil t))
7555 (when (gnus-summary-first-subject t)
7556 (gnus-summary-show-thread)
7557 (gnus-summary-first-subject t)))
7558 (gnus-summary-position-point)))
7560 (defun gnus-summary-first-article ()
7561 "Select the first article.
7562 Return nil if there are no articles."
7565 (when (gnus-summary-first-subject)
7566 (gnus-summary-show-thread)
7567 (gnus-summary-first-subject)
7568 (gnus-summary-display-article (gnus-summary-article-number)))
7569 (gnus-summary-position-point)))
7571 (defun gnus-summary-best-unread-article (&optional arg)
7572 "Select the unread article with the highest score.
7573 If given a prefix argument, select the next unread article that has a
7574 score higher than the default score."
7576 (let ((article (if arg
7577 (gnus-summary-better-unread-subject)
7578 (gnus-summary-best-unread-subject))))
7580 (gnus-summary-goto-article article)
7581 (error "No unread articles"))))
7583 (defun gnus-summary-best-unread-subject ()
7584 "Select the unread subject with the highest score."
7586 (let ((best -1000000)
7587 (data gnus-newsgroup-data)
7590 (and (gnus-data-unread-p (car data))
7592 (gnus-summary-article-score (gnus-data-number (car data))))
7595 article (gnus-data-number (car data))))
7596 (setq data (cdr data)))
7598 (gnus-summary-goto-subject article))
7599 (gnus-summary-position-point)
7602 (defun gnus-summary-better-unread-subject ()
7603 "Select the first unread subject that has a score over the default score."
7605 (let ((data gnus-newsgroup-data)
7607 (while (and (setq article (gnus-data-number (car data)))
7608 (or (gnus-data-read-p (car data))
7609 (not (> (gnus-summary-article-score article)
7610 gnus-summary-default-score))))
7611 (setq data (cdr data)))
7613 (gnus-summary-goto-subject article))
7614 (gnus-summary-position-point)
7617 (defun gnus-summary-last-subject ()
7618 "Go to the last displayed subject line in the group."
7619 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7621 (gnus-summary-goto-subject article))))
7623 (defun gnus-summary-goto-article (article &optional all-headers force)
7624 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7625 If ALL-HEADERS is non-nil, no header lines are hidden.
7626 If FORCE, go to the article even if it isn't displayed. If FORCE
7627 is a number, it is the line the article is to be displayed on."
7631 "Article number or Message-ID: "
7632 (mapcar (lambda (number) (list (int-to-string number)))
7633 gnus-newsgroup-limit))
7637 (if (and (stringp article)
7638 (string-match "@\\|%40" article))
7639 (gnus-summary-refer-article article)
7640 (when (stringp article)
7641 (setq article (string-to-number article)))
7642 (if (gnus-summary-goto-subject article force)
7643 (gnus-summary-display-article article all-headers)
7644 (gnus-message 4 "Couldn't go to article %s" article) nil))
7645 (gnus-summary-position-point)))
7647 (defun gnus-summary-goto-last-article ()
7648 "Go to the previously read article."
7651 (when gnus-last-article
7652 (gnus-summary-goto-article gnus-last-article nil t))
7653 (gnus-summary-position-point)))
7655 (defun gnus-summary-pop-article (number)
7656 "Pop one article off the history and go to the previous.
7657 NUMBER articles will be popped off."
7660 (setq gnus-newsgroup-history
7661 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7663 (gnus-summary-goto-article (car to) nil t)
7664 (error "Article history empty")))
7665 (gnus-summary-position-point))
7667 ;; Summary commands and functions for limiting the summary buffer.
7669 (defun gnus-summary-limit-to-articles (n)
7670 "Limit the summary buffer to the next N articles.
7671 If not given a prefix, use the process marked articles instead."
7674 (let ((articles (gnus-summary-work-articles n)))
7675 (setq gnus-newsgroup-processable nil)
7676 (gnus-summary-limit articles))
7677 (gnus-summary-position-point)))
7679 (defun gnus-summary-pop-limit (&optional total)
7680 "Restore the previous limit.
7681 If given a prefix, remove all limits."
7684 (setq gnus-newsgroup-limits
7685 (list (mapcar (lambda (h) (mail-header-number h))
7686 gnus-newsgroup-headers))))
7687 (unless gnus-newsgroup-limits
7688 (error "No limit to pop"))
7690 (gnus-summary-limit nil 'pop)
7691 (gnus-summary-position-point)))
7693 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7694 "Limit the summary buffer to articles that have subjects that match a regexp.
7695 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7697 (list (read-string (if current-prefix-arg
7698 "Exclude subject (regexp): "
7699 "Limit to subject (regexp): "))
7700 nil current-prefix-arg))
7702 (setq header "subject"))
7703 (when (not (equal "" subject))
7705 (let ((articles (gnus-summary-find-matching
7706 (or header "subject") subject 'all nil nil
7709 (error "Found no matches for \"%s\"" subject))
7710 (gnus-summary-limit articles))
7711 (gnus-summary-position-point))))
7713 (defun gnus-summary-limit-to-author (from &optional not-matching)
7714 "Limit the summary buffer to articles that have authors that match a regexp.
7715 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7717 (list (read-string (if current-prefix-arg
7718 "Exclude author (regexp): "
7719 "Limit to author (regexp): "))
7720 current-prefix-arg))
7721 (gnus-summary-limit-to-subject from "from" not-matching))
7723 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
7724 "Limit the summary buffer to articles with the given RECIPIENT.
7726 If NOT-MATCHING, exclude RECIPIENT.
7728 To and Cc headers are checked. You need to include them in
7729 `nnmail-extra-headers'."
7730 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
7732 (list (read-string (format "%s recipient (regexp): "
7733 (if current-prefix-arg "Exclude" "Limit to")))
7734 current-prefix-arg))
7735 (when (not (equal "" recipient))
7737 (if (memq 'To nnmail-extra-headers)
7738 (gnus-summary-find-matching
7739 (cons 'extra 'To) recipient 'all nil nil
7742 1 "`To' isn't present in `nnmail-extra-headers'")
7746 (if (memq 'Cc nnmail-extra-headers)
7747 (gnus-summary-find-matching
7748 (cons 'extra 'Cc) recipient 'all nil nil
7751 1 "`Cc' isn't present in `nnmail-extra-headers'")
7756 ;; We need the numbers that are in both lists:
7758 (and (memq a to) a))
7762 (error "Found no matches for \"%s\"" recipient))
7763 (gnus-summary-limit articles))
7764 (gnus-summary-position-point))))
7766 (defun gnus-summary-limit-to-age (age &optional younger-p)
7767 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7768 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7769 articles that are younger than AGE days."
7771 (let ((younger current-prefix-arg)
7774 (while (not days-got)
7775 (setq days (if younger
7776 (read-string "Limit to articles younger than (in days, older when negative): ")
7778 "Limit to articles older than (in days, younger when negative): ")))
7779 (when (> (length days) 0)
7780 (setq days (read days)))
7785 (setq younger (not younger))
7786 (setq days (* days -1))))
7787 (message "Please enter a number.")
7789 (list days younger)))
7791 (let ((data gnus-newsgroup-data)
7792 (cutoff (days-to-time age))
7793 articles d date is-younger)
7794 (while (setq d (pop data))
7795 (when (and (vectorp (gnus-data-header d))
7796 (setq date (mail-header-date (gnus-data-header d))))
7797 (setq is-younger (time-less-p
7798 (time-since (condition-case ()
7805 (push (gnus-data-number d) articles))))
7806 (gnus-summary-limit (nreverse articles)))
7807 (gnus-summary-position-point)))
7809 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7810 "Limit the summary buffer to articles that match an 'extra' header."
7814 (gnus-completing-read-with-default
7815 (symbol-name (car gnus-extra-headers))
7816 (if current-prefix-arg
7817 "Exclude extra header"
7818 "Limit extra header")
7820 (cons (symbol-name x) x))
7825 (read-string (format "%s header %s (regexp): "
7826 (if current-prefix-arg "Exclude" "Limit to")
7828 current-prefix-arg)))
7829 (when (not (equal "" regexp))
7831 (let ((articles (gnus-summary-find-matching
7832 (cons 'extra header) regexp 'all nil nil
7835 (error "Found no matches for \"%s\"" regexp))
7836 (gnus-summary-limit articles))
7837 (gnus-summary-position-point))))
7839 (defun gnus-summary-limit-to-display-predicate ()
7840 "Limit the summary buffer to the predicated in the `display' group parameter."
7842 (unless gnus-newsgroup-display
7843 (error "There is no `display' group parameter"))
7845 (dolist (number gnus-newsgroup-articles)
7846 (when (funcall gnus-newsgroup-display)
7847 (push number articles)))
7848 (gnus-summary-limit articles))
7849 (gnus-summary-position-point))
7851 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7853 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7855 (defun gnus-summary-limit-to-unread (&optional all)
7856 "Limit the summary buffer to articles that are not marked as read.
7857 If ALL is non-nil, limit strictly to unread articles."
7860 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7861 (gnus-summary-limit-to-marks
7862 ;; Concat all the marks that say that an article is read and have
7864 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7865 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7866 gnus-low-score-mark gnus-expirable-mark
7867 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7868 gnus-duplicate-mark gnus-souped-mark)
7871 (defun gnus-summary-limit-to-replied (&optional unreplied)
7872 "Limit the summary buffer to replied articles.
7873 If UNREPLIED (the prefix), limit to unreplied articles."
7877 (gnus-set-difference gnus-newsgroup-articles
7878 gnus-newsgroup-replied))
7879 (gnus-summary-limit gnus-newsgroup-replied))
7880 (gnus-summary-position-point))
7882 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7883 (make-obsolete 'gnus-summary-delete-marked-with
7884 'gnus-summary-limit-exclude-marks)
7886 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7887 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7888 If REVERSE, limit the summary buffer to articles that are marked
7889 with MARKS. MARKS can either be a string of marks or a list of marks.
7890 Returns how many articles were removed."
7891 (interactive "sMarks: ")
7892 (gnus-summary-limit-to-marks marks t))
7894 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7895 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7896 If REVERSE (the prefix), limit the summary buffer to articles that are
7897 not marked with MARKS. MARKS can either be a string of marks or a
7899 Returns how many articles were removed."
7900 (interactive "sMarks: \nP")
7902 (let ((data gnus-newsgroup-data)
7903 (marks (if (listp marks) marks
7904 (append marks nil))) ; Transform to list.
7907 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7908 (memq (gnus-data-mark (car data)) marks))
7909 (push (gnus-data-number (car data)) articles))
7910 (setq data (cdr data)))
7911 (gnus-summary-limit articles))
7912 (gnus-summary-position-point)))
7914 (defun gnus-summary-limit-to-score (score)
7915 "Limit to articles with score at or above SCORE."
7916 (interactive "NLimit to articles with score of at least: ")
7917 (let ((data gnus-newsgroup-data)
7920 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7922 (push (gnus-data-number (car data)) articles))
7923 (setq data (cdr data)))
7925 (gnus-summary-limit articles)
7926 (gnus-summary-position-point))))
7928 (defun gnus-summary-limit-to-unseen ()
7929 "Limit to unseen articles."
7932 (gnus-summary-limit gnus-newsgroup-unseen)
7933 (gnus-summary-position-point)))
7935 (defun gnus-summary-limit-include-thread (id)
7936 "Display all the hidden articles that is in the thread with ID in it.
7937 When called interactively, ID is the Message-ID of the current
7939 (interactive (list (mail-header-id (gnus-summary-article-header))))
7940 (let ((articles (gnus-articles-in-thread
7941 (gnus-id-to-thread (gnus-root-id id)))))
7943 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7944 (gnus-summary-limit-include-matching-articles
7946 (regexp-quote (gnus-simplify-subject-re
7947 (mail-header-subject (gnus-id-to-header id)))))
7948 (gnus-summary-position-point))))
7950 (defun gnus-summary-limit-include-matching-articles (header regexp)
7951 "Display all the hidden articles that have HEADERs that match REGEXP."
7952 (interactive (list (read-string "Match on header: ")
7953 (read-string "Regexp: ")))
7954 (let ((articles (gnus-find-matching-articles header regexp)))
7956 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7957 (gnus-summary-position-point))))
7959 (defun gnus-summary-insert-dormant-articles ()
7960 "Insert all the dormant articles for this group into the current buffer."
7962 (let ((gnus-verbose (max 6 gnus-verbose)))
7963 (if (not gnus-newsgroup-dormant)
7964 (gnus-message 3 "No cached articles for this group")
7965 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7967 (defun gnus-summary-limit-include-dormant ()
7968 "Display all the hidden articles that are marked as dormant.
7969 Note that this command only works on a subset of the articles currently
7970 fetched for this group."
7972 (unless gnus-newsgroup-dormant
7973 (error "There are no dormant articles in this group"))
7975 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7976 (gnus-summary-position-point)))
7978 (defun gnus-summary-limit-exclude-dormant ()
7979 "Hide all dormant articles."
7982 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7983 (gnus-summary-position-point)))
7985 (defun gnus-summary-limit-exclude-childless-dormant ()
7986 "Hide all dormant articles that have no children."
7988 (let ((data (gnus-data-list t))
7989 articles d children)
7990 ;; Find all articles that are either not dormant or have
7992 (while (setq d (pop data))
7993 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7995 (gnus-article-children (gnus-data-number d)))
7998 (when (memq (car children) articles)
8003 (push (gnus-data-number d) articles)))
8006 (gnus-summary-limit articles)
8007 (gnus-summary-position-point))))
8009 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8010 "Mark all unread excluded articles as read.
8011 If ALL, mark even excluded ticked and dormants as read."
8013 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8014 (let ((articles (gnus-sorted-ndifference
8016 (mapcar (lambda (h) (mail-header-number h))
8017 gnus-newsgroup-headers)
8019 gnus-newsgroup-limit))
8021 (setq gnus-newsgroup-unreads
8022 (gnus-sorted-intersection gnus-newsgroup-unreads
8023 gnus-newsgroup-limit))
8025 (setq gnus-newsgroup-dormant nil
8026 gnus-newsgroup-marked nil
8027 gnus-newsgroup-reads
8029 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8030 gnus-newsgroup-reads))
8031 (while (setq article (pop articles))
8032 (unless (or (memq article gnus-newsgroup-dormant)
8033 (memq article gnus-newsgroup-marked))
8034 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8036 (defun gnus-summary-limit (articles &optional pop)
8038 ;; We pop the previous limit off the stack and use that.
8039 (setq articles (car gnus-newsgroup-limits)
8040 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8041 ;; We use the new limit, so we push the old limit on the stack.
8042 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8044 (setq gnus-newsgroup-limit articles)
8045 (let ((total (length gnus-newsgroup-data))
8046 (data (gnus-data-find-list (gnus-summary-article-number)))
8047 (gnus-summary-mark-below nil) ; Inhibit this.
8049 ;; This will do all the work of generating the new summary buffer
8050 ;; according to the new limit.
8051 (gnus-summary-prepare)
8052 ;; Hide any threads, possibly.
8053 (gnus-summary-maybe-hide-threads)
8054 ;; Try to return to the article you were at, or one in the
8057 ;; We try to find some article after the current one.
8059 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8062 (setq data (cdr data))))
8064 ;; If there is no data, that means that we were after the last
8065 ;; article. The same goes when we can't find any articles
8066 ;; after the current one.
8067 (goto-char (point-max))
8068 (gnus-summary-find-prev))
8069 (gnus-set-mode-line 'summary)
8070 ;; We return how many articles were removed from the summary
8071 ;; buffer as a result of the new limit.
8072 (- total (length gnus-newsgroup-data))))
8074 (defsubst gnus-invisible-cut-children (threads)
8077 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8082 (defsubst gnus-cut-thread (thread)
8083 "Go forwards in the thread until we find an article that we want to display."
8084 (when (or (eq gnus-fetch-old-headers 'some)
8085 (eq gnus-fetch-old-headers 'invisible)
8086 (numberp gnus-fetch-old-headers)
8087 (eq gnus-build-sparse-threads 'some)
8088 (eq gnus-build-sparse-threads 'more))
8089 ;; Deal with old-fetched headers and sparse threads.
8093 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8094 (gnus-summary-article-ancient-p
8095 (mail-header-number (car thread))))
8096 (if (or (<= (length (cdr thread)) 1)
8097 (eq gnus-fetch-old-headers 'invisible))
8098 (setq gnus-newsgroup-limit
8099 (delq (mail-header-number (car thread))
8100 gnus-newsgroup-limit)
8101 thread (cadr thread))
8102 (when (gnus-invisible-cut-children (cdr thread))
8103 (let ((th (cdr thread)))
8105 (if (memq (mail-header-number (caar th))
8106 gnus-newsgroup-limit)
8107 (setq thread (car th)
8109 (setq th (cdr th))))))))))
8112 (defun gnus-cut-threads (threads)
8113 "Cut off all uninteresting articles from the beginning of THREADS."
8114 (when (or (eq gnus-fetch-old-headers 'some)
8115 (eq gnus-fetch-old-headers 'invisible)
8116 (numberp gnus-fetch-old-headers)
8117 (eq gnus-build-sparse-threads 'some)
8118 (eq gnus-build-sparse-threads 'more))
8121 (setcar th (gnus-cut-thread (car th)))
8122 (setq th (cdr th)))))
8123 ;; Remove nixed out threads.
8126 (defun gnus-summary-initial-limit (&optional show-if-empty)
8127 "Figure out what the initial limit is supposed to be on group entry.
8128 This entails weeding out unwanted dormants, low-scored articles,
8129 fetch-old-headers verbiage, and so on."
8130 ;; Most groups have nothing to remove.
8131 (if (or gnus-inhibit-limiting
8132 (and (null gnus-newsgroup-dormant)
8133 (eq gnus-newsgroup-display 'gnus-not-ignore)
8134 (not (eq gnus-fetch-old-headers 'some))
8135 (not (numberp gnus-fetch-old-headers))
8136 (not (eq gnus-fetch-old-headers 'invisible))
8137 (null gnus-summary-expunge-below)
8138 (not (eq gnus-build-sparse-threads 'some))
8139 (not (eq gnus-build-sparse-threads 'more))
8140 (null gnus-thread-expunge-below)
8141 (not gnus-use-nocem)))
8143 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8144 (setq gnus-newsgroup-limit nil)
8147 (unless (car (symbol-value node))
8148 ;; These threads have no parents -- they are roots.
8149 (let ((nodes (cdr (symbol-value node)))
8152 (if (and gnus-thread-expunge-below
8153 (< (gnus-thread-total-score (car nodes))
8154 gnus-thread-expunge-below))
8155 (gnus-expunge-thread (pop nodes))
8156 (setq thread (pop nodes))
8157 (gnus-summary-limit-children thread))))))
8158 gnus-newsgroup-dependencies)
8159 ;; If this limitation resulted in an empty group, we might
8160 ;; pop the previous limit and use it instead.
8161 (when (and (not gnus-newsgroup-limit)
8163 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8164 gnus-newsgroup-limit))
8166 (defun gnus-summary-limit-children (thread)
8167 "Return 1 if this subthread is visible and 0 if it is not."
8168 ;; First we get the number of visible children to this thread. This
8169 ;; is done by recursing down the thread using this function, so this
8170 ;; will really go down to a leaf article first, before slowly
8171 ;; working its way up towards the root.
8173 (let* ((max-lisp-eval-depth 5000)
8176 (apply '+ (mapcar 'gnus-summary-limit-children
8179 (number (mail-header-number (car thread)))
8182 (not (memq number gnus-newsgroup-marked))
8184 ;; If this article is dormant and has absolutely no visible
8185 ;; children, then this article isn't visible.
8186 (and (memq number gnus-newsgroup-dormant)
8188 ;; If this is "fetch-old-headered" and there is no
8189 ;; visible children, then we don't want this article.
8190 (and (or (eq gnus-fetch-old-headers 'some)
8191 (numberp gnus-fetch-old-headers))
8192 (gnus-summary-article-ancient-p number)
8194 ;; If this is "fetch-old-headered" and `invisible', then
8195 ;; we don't want this article.
8196 (and (eq gnus-fetch-old-headers 'invisible)
8197 (gnus-summary-article-ancient-p number))
8198 ;; If this is a sparsely inserted article with no children,
8199 ;; we don't want it.
8200 (and (eq gnus-build-sparse-threads 'some)
8201 (gnus-summary-article-sparse-p number)
8203 ;; If we use expunging, and this article is really
8204 ;; low-scored, then we don't want this article.
8205 (when (and gnus-summary-expunge-below
8207 (or (cdr (assq number gnus-newsgroup-scored))
8208 gnus-summary-default-score))
8209 gnus-summary-expunge-below))
8210 ;; We increase the expunge-tally here, but that has
8211 ;; nothing to do with the limits, really.
8212 (incf gnus-newsgroup-expunged-tally)
8213 ;; We also mark as read here, if that's wanted.
8214 (when (and gnus-summary-mark-below
8215 (< score gnus-summary-mark-below))
8216 (setq gnus-newsgroup-unreads
8217 (delq number gnus-newsgroup-unreads))
8218 (if gnus-newsgroup-auto-expire
8219 (push number gnus-newsgroup-expirable)
8220 (push (cons number gnus-low-score-mark)
8221 gnus-newsgroup-reads)))
8223 ;; Do the `display' group parameter.
8224 (and gnus-newsgroup-display
8225 (not (funcall gnus-newsgroup-display)))
8226 ;; Check NoCeM things.
8227 (when (and gnus-use-nocem
8228 (gnus-nocem-unwanted-article-p
8229 (mail-header-id (car thread))))
8230 (setq gnus-newsgroup-unreads
8231 (delq number gnus-newsgroup-unreads))
8233 ;; Nope, invisible article.
8235 ;; Ok, this article is to be visible, so we add it to the limit
8237 (push number gnus-newsgroup-limit)
8240 (defun gnus-expunge-thread (thread)
8241 "Mark all articles in THREAD as read."
8242 (let* ((number (mail-header-number (car thread))))
8243 (incf gnus-newsgroup-expunged-tally)
8244 ;; We also mark as read here, if that's wanted.
8245 (setq gnus-newsgroup-unreads
8246 (delq number gnus-newsgroup-unreads))
8247 (if gnus-newsgroup-auto-expire
8248 (push number gnus-newsgroup-expirable)
8249 (push (cons number gnus-low-score-mark)
8250 gnus-newsgroup-reads)))
8251 ;; Go recursively through all subthreads.
8252 (mapcar 'gnus-expunge-thread (cdr thread)))
8254 ;; Summary article oriented commands
8256 (defun gnus-summary-refer-parent-article (n)
8257 "Refer parent article N times.
8258 If N is negative, go to ancestor -N instead.
8259 The difference between N and the number of articles fetched is returned."
8263 (when (not (natnump n))
8268 (setq header (gnus-summary-article-header))
8269 (if (and (eq (mail-header-number header)
8270 (cdr gnus-article-current))
8271 (equal gnus-newsgroup-name
8272 (car gnus-article-current)))
8273 ;; If we try to find the parent of the currently
8274 ;; displayed article, then we take a look at the actual
8275 ;; References header, since this is slightly more
8276 ;; reliable than the References field we got from the
8279 (set-buffer gnus-original-article-buffer)
8280 (nnheader-narrow-to-headers)
8281 (unless (setq ref (message-fetch-field "references"))
8282 (when (setq ref (message-fetch-field "in-reply-to"))
8283 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8286 ;; It's not the current article, so we take a bet on
8287 ;; the value we got from the server.
8288 (mail-header-references header)))
8290 (not (equal ref "")))
8291 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8292 (gnus-message 1 "Couldn't find parent"))
8293 (gnus-message 1 "No references in article %d"
8294 (gnus-summary-article-number))
8297 (gnus-summary-position-point)
8300 (defun gnus-summary-refer-references ()
8301 "Fetch all articles mentioned in the References header.
8302 Return the number of articles fetched."
8304 (let ((ref (mail-header-references (gnus-summary-article-header)))
8305 (current (gnus-summary-article-number))
8309 (error "No References in the current article")
8310 ;; For each Message-ID in the References header...
8311 (while (string-match "<[^>]*>" ref)
8313 ;; ... fetch that article.
8314 (gnus-summary-refer-article
8315 (prog1 (match-string 0 ref)
8316 (setq ref (substring ref (match-end 0))))))
8317 (gnus-summary-goto-subject current)
8318 (gnus-summary-position-point)
8321 (defun gnus-summary-refer-thread (&optional limit)
8322 "Fetch all articles in the current thread.
8323 If LIMIT (the numerical prefix), fetch that many old headers instead
8324 of what's specified by the `gnus-refer-thread-limit' variable."
8326 (let ((id (mail-header-id (gnus-summary-article-header)))
8327 (limit (if limit (prefix-numeric-value limit)
8328 gnus-refer-thread-limit)))
8329 (unless (eq gnus-fetch-old-headers 'invisible)
8330 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8331 ;; Retrieve the headers and read them in.
8332 (if (eq (if (numberp limit)
8333 (gnus-retrieve-headers
8335 (+ (mail-header-number
8336 (gnus-summary-article-header))
8338 gnus-newsgroup-end))
8339 gnus-newsgroup-name (* limit 2))
8340 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8342 (gnus-retrieve-headers (list gnus-newsgroup-end)
8343 gnus-newsgroup-name limit))
8345 (gnus-build-all-threads)
8346 (error "Can't fetch thread from back ends that don't support NOV"))
8347 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8348 (gnus-summary-limit-include-thread id)))
8350 (defun gnus-summary-refer-article (message-id)
8351 "Fetch an article specified by MESSAGE-ID."
8352 (interactive "sMessage-ID: ")
8353 (when (and (stringp message-id)
8354 (not (zerop (length message-id))))
8355 (setq message-id (gnus-replace-in-string message-id " " ""))
8356 ;; Construct the correct Message-ID if necessary.
8357 ;; Suggested by tale@pawl.rpi.edu.
8358 (unless (string-match "^<" message-id)
8359 (setq message-id (concat "<" message-id)))
8360 (unless (string-match ">$" message-id)
8361 (setq message-id (concat message-id ">")))
8362 ;; People often post MIDs from URLs, so unhex it:
8363 (unless (string-match "@" message-id)
8364 (setq message-id (gnus-url-unhex-string message-id)))
8365 (let* ((header (gnus-id-to-header message-id))
8367 (gnus-summary-article-sparse-p
8368 (mail-header-number header))
8369 (memq (mail-header-number header)
8370 gnus-newsgroup-limit)))
8373 ;; If the article is present in the buffer we just go to it.
8375 (or (not (gnus-summary-article-sparse-p
8376 (mail-header-number header)))
8379 (gnus-summary-goto-article
8380 (mail-header-number header) nil t)
8382 (gnus-summary-update-article (mail-header-number header)))))
8384 ;; We fetch the article.
8386 (dolist (gnus-override-method (gnus-refer-article-methods))
8387 (when (and (gnus-check-server gnus-override-method)
8388 ;; Fetch the header,
8389 (setq number (gnus-summary-insert-subject message-id)))
8390 ;; and display the article.
8391 (gnus-summary-select-article nil nil nil number)
8393 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8395 (defun gnus-refer-article-methods ()
8396 "Return a list of referable methods."
8398 ;; No method, so we default to current and native.
8399 ((null gnus-refer-article-method)
8400 (list gnus-current-select-method gnus-select-method))
8402 ((eq 'current gnus-refer-article-method)
8403 (list gnus-current-select-method))
8404 ;; List of select methods.
8405 ((not (and (symbolp (car gnus-refer-article-method))
8406 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8408 (dolist (method gnus-refer-article-method)
8409 (push (if (eq 'current method)
8410 gnus-current-select-method
8414 ;; One single select method.
8416 (list gnus-refer-article-method))))
8418 (defun gnus-summary-edit-parameters ()
8419 "Edit the group parameters of the current group."
8421 (gnus-group-edit-group gnus-newsgroup-name 'params))
8423 (defun gnus-summary-customize-parameters ()
8424 "Customize the group parameters of the current group."
8426 (gnus-group-customize gnus-newsgroup-name))
8428 (defun gnus-summary-enter-digest-group (&optional force)
8429 "Enter an nndoc group based on the current article.
8430 If FORCE, force a digest interpretation. If not, try
8431 to guess what the document format is."
8433 (let ((conf gnus-current-window-configuration))
8434 (save-window-excursion
8436 (let (gnus-article-prepare-hook
8437 gnus-display-mime-function
8439 (gnus-summary-select-article))))
8440 (setq gnus-current-window-configuration conf)
8441 (let* ((name (format "%s-%d"
8442 (gnus-group-prefixed-name
8443 gnus-newsgroup-name (list 'nndoc ""))
8444 (with-current-buffer gnus-summary-buffer
8445 gnus-current-article)))
8446 (ogroup gnus-newsgroup-name)
8447 (params (append (gnus-info-params (gnus-get-info ogroup))
8448 (list (cons 'to-group ogroup))
8449 (list (cons 'parent-group ogroup))
8450 (list (cons 'save-article-group ogroup))))
8451 (case-fold-search t)
8452 (buf (current-buffer))
8455 (set-buffer gnus-original-article-buffer)
8456 ;; Have the digest group inherit the main mail address of
8457 ;; the parent article.
8458 (when (setq to-address (or (gnus-fetch-field "reply-to")
8459 (gnus-fetch-field "from")))
8460 (setq params (append
8461 (list (cons 'to-address
8462 (funcall gnus-decode-encoded-word-function
8464 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8465 (insert-buffer-substring gnus-original-article-buffer)
8466 ;; Remove lines that may lead nndoc to misinterpret the
8469 (goto-char (point-min))
8470 (or (search-forward "\n\n" nil t) (point)))
8471 (goto-char (point-min))
8472 (delete-matching-lines "^Path:\\|^From ")
8475 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8476 (gnus-newsgroup-ephemeral-ignored-charsets
8477 gnus-newsgroup-ignored-charsets))
8478 (gnus-group-read-ephemeral-group
8479 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8481 ,(if force 'mbox 'guess)))
8483 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8485 ;; Make all postings to this group go to the parent group.
8486 (nconc (gnus-info-params (gnus-get-info name))
8488 ;; Couldn't select this doc group.
8489 (switch-to-buffer buf)
8490 (gnus-set-global-variables)
8491 (gnus-configure-windows 'summary)
8492 (gnus-message 3 "Article couldn't be entered?"))
8493 (kill-buffer dig)))))
8495 (defun gnus-summary-read-document (n)
8496 "Open a new group based on the current article(s).
8497 This will allow you to read digests and other similar
8498 documents as newsgroups.
8499 Obeys the standard process/prefix convention."
8501 (let* ((ogroup gnus-newsgroup-name)
8502 (params (append (gnus-info-params (gnus-get-info ogroup))
8503 (list (cons 'to-group ogroup))))
8504 group egroup groups vgroup)
8505 (dolist (article (gnus-summary-work-articles n))
8506 (setq group (format "%s-%d" gnus-newsgroup-name article))
8507 (gnus-summary-remove-process-mark article)
8508 (when (gnus-summary-display-article article)
8511 (insert-buffer-substring gnus-original-article-buffer)
8512 ;; Remove some headers that may lead nndoc to make
8514 (message-narrow-to-head)
8515 (goto-char (point-min))
8516 (delete-matching-lines "^Path:\\|^From ")
8519 (gnus-group-read-ephemeral-group
8520 group `(nndoc ,group (nndoc-address ,(current-buffer))
8521 (nndoc-article-type guess))
8524 ;; Make all postings to this group go to the parent group.
8525 (nconc (gnus-info-params (gnus-get-info egroup))
8527 (push egroup groups))
8528 ;; Couldn't select this doc group.
8529 (gnus-error 3 "Article couldn't be entered"))))))
8530 ;; Now we have selected all the documents.
8533 (error "None of the articles could be interpreted as documents"))
8534 ((gnus-group-read-ephemeral-group
8535 (setq vgroup (format
8536 "nnvirtual:%s-%s" gnus-newsgroup-name
8537 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8538 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8540 (cons (current-buffer) 'summary)))
8542 (error "Couldn't select virtual nndoc group")))))
8544 (defun gnus-summary-isearch-article (&optional regexp-p)
8545 "Do incremental search forward on the current article.
8546 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8548 (gnus-summary-select-article)
8549 (gnus-configure-windows 'article)
8550 (gnus-eval-in-buffer-window gnus-article-buffer
8553 (isearch-forward regexp-p))))
8555 (defun gnus-summary-search-article-forward (regexp &optional backward)
8556 "Search for an article containing REGEXP forward.
8557 If BACKWARD, search backward instead."
8560 (format "Search article %s (regexp%s): "
8561 (if current-prefix-arg "backward" "forward")
8562 (if gnus-last-search-regexp
8563 (concat ", default " gnus-last-search-regexp)
8565 current-prefix-arg))
8566 (if (string-equal regexp "")
8567 (setq regexp (or gnus-last-search-regexp ""))
8568 (setq gnus-last-search-regexp regexp)
8569 (setq gnus-article-before-search gnus-current-article))
8570 ;; Intentionally set gnus-last-article.
8571 (setq gnus-last-article gnus-article-before-search)
8572 (let ((gnus-last-article gnus-last-article))
8573 (if (gnus-summary-search-article regexp backward)
8574 (gnus-summary-show-thread)
8575 (signal 'search-failed (list regexp)))))
8577 (defun gnus-summary-search-article-backward (regexp)
8578 "Search for an article containing REGEXP backward."
8581 (format "Search article backward (regexp%s): "
8582 (if gnus-last-search-regexp
8583 (concat ", default " gnus-last-search-regexp)
8585 (gnus-summary-search-article-forward regexp 'backward))
8587 (defun gnus-summary-search-article (regexp &optional backward)
8588 "Search for an article containing REGEXP.
8589 Optional argument BACKWARD means do search for backward.
8590 `gnus-select-article-hook' is not called during the search."
8591 ;; We have to require this here to make sure that the following
8592 ;; dynamic binding isn't shadowed by autoloading.
8593 (require 'gnus-async)
8595 (let ((gnus-select-article-hook nil) ;Disable hook.
8596 (gnus-article-prepare-hook nil)
8597 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8598 (gnus-use-article-prefetch nil)
8599 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8600 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8602 (gnus-keep-backlog nil)
8603 (gnus-break-pages nil)
8604 (gnus-summary-display-arrow nil)
8605 (gnus-updated-mode-lines nil)
8606 (gnus-auto-center-summary nil)
8607 (sum (current-buffer))
8608 (gnus-display-mime-function nil)
8611 (gnus-save-hidden-threads
8612 (gnus-summary-select-article)
8613 (set-buffer gnus-article-buffer)
8614 (goto-char (window-point (get-buffer-window (current-buffer))))
8618 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8620 (re-search-backward regexp nil t)
8621 (re-search-forward regexp nil t))
8622 ;; We found the regexp.
8627 (get-buffer-window (current-buffer))
8631 (get-buffer-window (current-buffer))
8634 (setq point (point)))
8635 ;; We didn't find it, so we go to the next article.
8638 (while (eq found 'not)
8639 (if (not (if backward (gnus-summary-find-prev)
8640 (gnus-summary-find-next)))
8641 ;; No more articles.
8643 ;; Select the next article and adjust point.
8644 (unless (gnus-summary-article-sparse-p
8645 (gnus-summary-article-number))
8647 (gnus-summary-select-article)
8648 (set-buffer gnus-article-buffer)
8650 (goto-char (if backward (point-max) (point-min))))))))
8651 (gnus-message 7 ""))
8652 ;; Return whether we found the regexp.
8653 (when (eq found 'found)
8655 (gnus-summary-show-thread)
8656 (gnus-summary-goto-subject gnus-current-article)
8657 (gnus-summary-position-point)
8660 (defun gnus-find-matching-articles (header regexp)
8661 "Return a list of all articles that match REGEXP on HEADER.
8662 This search includes all articles in the current group that Gnus has
8663 fetched headers for, whether they are displayed or not."
8664 (let ((articles nil)
8665 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8666 (case-fold-search t))
8667 (dolist (header gnus-newsgroup-headers)
8668 (when (string-match regexp (funcall func header))
8669 (push (mail-header-number header) articles)))
8670 (nreverse articles)))
8672 (defun gnus-summary-find-matching (header regexp &optional backward unread
8673 not-case-fold not-matching)
8674 "Return a list of all articles that match REGEXP on HEADER.
8675 The search stars on the current article and goes forwards unless
8676 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8677 If UNREAD is non-nil, only unread articles will
8678 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8679 in the comparisons. If NOT-MATCHING, return a list of all articles that
8680 not match REGEXP on HEADER."
8681 (let ((case-fold-search (not not-case-fold))
8684 (if (eq (car header) 'extra)
8687 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8689 (error "%s is an invalid header" header))
8690 (unless (fboundp (intern (concat "mail-header-" header)))
8691 (error "%s is not a valid header" header))
8692 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8693 (dolist (d (if (eq backward 'all)
8695 (gnus-data-find-list
8696 (gnus-summary-article-number)
8697 (gnus-data-list backward))))
8698 (when (and (or (not unread) ; We want all articles...
8699 (gnus-data-unread-p d)) ; Or just unreads.
8700 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8704 (funcall func (gnus-data-header d))))
8705 (string-match regexp
8706 (funcall func (gnus-data-header d)))))
8707 (push (gnus-data-number d) articles))) ; Success!
8708 (nreverse articles)))
8710 (defun gnus-summary-execute-command (header regexp command &optional backward)
8711 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8712 If HEADER is an empty string (or nil), the match is done on the entire
8713 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8715 (list (let ((completion-ignore-case t))
8718 (mapcar (lambda (header) (list (format "%s" header)))
8720 '("Number" "Subject" "From" "Lines" "Date"
8721 "Message-ID" "Xref" "References" "Body")
8722 gnus-extra-headers))
8723 nil 'require-match))
8724 (read-string "Regexp: ")
8725 (read-key-sequence "Command: ")
8726 current-prefix-arg))
8727 (when (equal header "Body")
8729 ;; Hidden thread subtrees must be searched as well.
8730 (gnus-summary-show-all-threads)
8731 ;; We don't want to change current point nor window configuration.
8733 (save-window-excursion
8735 gnus-treat-strip-trailing-blank-lines
8736 gnus-treat-strip-leading-blank-lines
8737 gnus-treat-strip-multiple-blank-lines
8738 gnus-treat-hide-boring-headers
8739 gnus-treat-fold-newsgroups
8740 gnus-article-prepare-hook)
8741 (gnus-message 6 "Executing %s..." (key-description command))
8742 ;; We'd like to execute COMMAND interactively so as to give arguments.
8743 (gnus-execute header regexp
8744 `(call-interactively ',(key-binding command))
8746 (gnus-message 6 "Executing %s...done" (key-description command))))))
8748 (defun gnus-summary-beginning-of-article ()
8749 "Scroll the article back to the beginning."
8751 (gnus-summary-select-article)
8752 (gnus-configure-windows 'article)
8753 (gnus-eval-in-buffer-window gnus-article-buffer
8755 (goto-char (point-min))
8756 (when gnus-break-pages
8757 (gnus-narrow-to-page))))
8759 (defun gnus-summary-end-of-article ()
8760 "Scroll to the end of the article."
8762 (gnus-summary-select-article)
8763 (gnus-configure-windows 'article)
8764 (gnus-eval-in-buffer-window gnus-article-buffer
8766 (goto-char (point-max))
8768 (when gnus-break-pages
8769 (when (re-search-backward page-delimiter nil t)
8770 (narrow-to-region (match-end 0) (point-max)))
8771 (gnus-narrow-to-page))))
8773 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8774 "Truncate to LEN and quote all \"(\"'s in STRING."
8775 (gnus-replace-in-string (if (and len (> (length string) len))
8776 (substring string 0 len)
8780 (defun gnus-summary-print-article (&optional filename n)
8781 "Generate and print a PostScript image of the process-marked (mail) articles.
8783 If used interactively, print the current article if none are
8784 process-marked. With prefix arg, prompt the user for the name of the
8787 When used from Lisp, accept two optional args FILENAME and N. N means
8788 to print the next N articles. If N is negative, print the N previous
8789 articles. If N is nil and articles have been marked with the process
8790 mark, print these instead.
8792 If the optional first argument FILENAME is nil, send the image to the
8793 printer. If FILENAME is a string, save the PostScript image in a file with
8794 that name. If FILENAME is a number, prompt the user for the name of the file
8796 (interactive (list (ps-print-preprint current-prefix-arg)))
8797 (dolist (article (gnus-summary-work-articles n))
8798 (gnus-summary-select-article nil nil 'pseudo article)
8799 (gnus-eval-in-buffer-window gnus-article-buffer
8800 (gnus-print-buffer))
8801 (gnus-summary-remove-process-mark article))
8802 (ps-despool filename))
8804 (defun gnus-print-buffer ()
8805 (let ((buffer (generate-new-buffer " *print*")))
8808 (copy-to-buffer buffer (point-min) (point-max))
8810 (gnus-remove-text-with-property 'gnus-decoration)
8811 (when (gnus-visual-p 'article-highlight 'highlight)
8812 ;; Copy-to-buffer doesn't copy overlay. So redo
8814 (let ((gnus-article-buffer buffer))
8815 (gnus-article-highlight-citation t)
8816 (gnus-article-highlight-signature)
8817 (gnus-article-emphasize)
8818 (gnus-article-delete-invisible-text)))
8819 (let ((ps-left-header
8822 (gnus-summary-print-truncate-and-quote
8823 (mail-header-subject gnus-current-headers)
8826 (gnus-summary-print-truncate-and-quote
8827 (mail-header-from gnus-current-headers)
8831 "/pagenumberstring load"
8833 (mail-header-date gnus-current-headers) ")"))))
8834 (gnus-run-hooks 'gnus-ps-print-hook)
8837 (ps-spool-buffer-with-faces)
8838 (ps-spool-buffer)))))
8839 (kill-buffer buffer))))
8841 (defun gnus-summary-show-article (&optional arg)
8842 "Force redisplaying of the current article.
8843 If ARG (the prefix) is a number, show the article with the charset
8844 defined in `gnus-summary-show-article-charset-alist', or the charset
8846 If ARG (the prefix) is non-nil and not a number, show the raw article
8847 without any article massaging functions being run. Normally, the key
8848 strokes are `C-u g'."
8852 (gnus-summary-show-article t)
8853 (let ((gnus-newsgroup-charset
8854 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8855 (mm-read-coding-system
8856 "View as charset: " ;; actually it is coding system.
8857 (with-current-buffer gnus-article-buffer
8858 (mm-detect-coding-region (point) (point-max))))))
8859 (gnus-newsgroup-ignored-charsets 'gnus-all))
8860 (gnus-summary-select-article nil 'force)
8861 (let ((deps gnus-newsgroup-dependencies)
8864 (set-buffer gnus-original-article-buffer)
8866 (message-narrow-to-head)
8867 (setq head (buffer-string))
8868 (goto-char (point-min))
8869 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8870 (goto-char (point-max))
8872 (setq lines (1- (count-lines (point) (point-max))))))
8874 (insert (format "211 %d Article retrieved.\n"
8875 (cdr gnus-article-current)))
8877 (if lines (insert (format "Lines: %d\n" lines)))
8879 (let ((nntp-server-buffer (current-buffer)))
8880 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8881 (gnus-data-set-header
8882 (gnus-data-find (cdr gnus-article-current))
8884 (gnus-summary-update-article-line
8885 (cdr gnus-article-current) header)
8886 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8887 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8889 ;; Select the article the normal way.
8890 (gnus-summary-select-article nil 'force))
8892 ;; We have to require this here to make sure that the following
8893 ;; dynamic binding isn't shadowed by autoloading.
8894 (require 'gnus-async)
8896 ;; Bind the article treatment functions to nil.
8897 (let ((gnus-have-all-headers t)
8898 gnus-article-prepare-hook
8899 gnus-article-decode-hook
8900 gnus-display-mime-function
8902 ;; Destroy any MIME parts.
8903 (when (gnus-buffer-live-p gnus-article-buffer)
8905 (set-buffer gnus-article-buffer)
8906 (mm-destroy-parts gnus-article-mime-handles)
8907 ;; Set it to nil for safety reason.
8908 (setq gnus-article-mime-handle-alist nil)
8909 (setq gnus-article-mime-handles nil)))
8910 (gnus-summary-select-article nil 'force))))
8911 (gnus-summary-goto-subject gnus-current-article)
8912 (gnus-summary-position-point))
8914 (defun gnus-summary-show-raw-article ()
8915 "Show the raw article without any article massaging functions being run."
8917 (gnus-summary-show-article t))
8919 (defun gnus-summary-verbose-headers (&optional arg)
8920 "Toggle permanent full header display.
8921 If ARG is a positive number, turn header display on.
8922 If ARG is a negative number, turn header display off."
8924 (setq gnus-show-all-headers
8925 (cond ((or (not (numberp arg))
8927 (not gnus-show-all-headers))
8930 (gnus-summary-show-article))
8932 (defun gnus-summary-toggle-header (&optional arg)
8933 "Show the headers if they are hidden, or hide them if they are shown.
8934 If ARG is a positive number, show the entire header.
8935 If ARG is a negative number, hide the unwanted header lines."
8937 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8938 (get-buffer-window gnus-article-buffer t))))
8939 (with-current-buffer gnus-article-buffer
8941 (article-narrow-to-head)
8942 (let* ((buffer-read-only nil)
8943 (inhibit-point-motion-hooks t)
8944 (hidden (if (numberp arg)
8946 (or (not (looking-at "[^ \t\n]+:"))
8947 (gnus-article-hidden-text-p 'headers))))
8949 (delete-region (point-min) (point-max))
8950 (with-current-buffer gnus-original-article-buffer
8951 (goto-char (setq s (point-min)))
8952 (setq e (if (search-forward "\n\n" nil t)
8955 (insert-buffer-substring gnus-original-article-buffer s e)
8956 (run-hooks 'gnus-article-decode-hook)
8958 (let ((gnus-treat-hide-headers nil)
8959 (gnus-treat-hide-boring-headers nil))
8960 (gnus-delete-wash-type 'headers)
8961 (gnus-treat-article 'head))
8962 (gnus-treat-article 'head))
8965 (set-window-start window (goto-char (point-min))))
8966 (if gnus-break-pages
8967 (gnus-narrow-to-page)
8968 (when (gnus-visual-p 'page-marker)
8969 (let ((buffer-read-only nil))
8970 (gnus-remove-text-with-property 'gnus-prev)
8971 (gnus-remove-text-with-property 'gnus-next))))
8972 (gnus-set-mode-line 'article)))))
8974 (defun gnus-summary-show-all-headers ()
8975 "Make all header lines visible."
8977 (gnus-summary-toggle-header 1))
8979 (defun gnus-summary-caesar-message (&optional arg)
8980 "Caesar rotate the current article by 13.
8981 The numerical prefix specifies how many places to rotate each letter
8984 (gnus-summary-select-article)
8985 (let ((mail-header-separator ""))
8986 (gnus-eval-in-buffer-window gnus-article-buffer
8989 (let ((start (window-start))
8991 (message-caesar-buffer-body arg)
8992 (set-window-start (get-buffer-window (current-buffer)) start)))))
8993 ;; Create buttons and stuff...
8994 (gnus-treat-article nil))
8996 (defun gnus-summary-idna-message (&optional arg)
8997 "Decode IDNA encoded domain names in the current articles.
8998 IDNA encoded domain names looks like `xn--bar'. If a string
8999 remain unencoded after running this function, it is likely an
9000 invalid IDNA string (`xn--bar' is invalid).
9002 You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9003 installed for this command to work."
9005 (if (not (and (condition-case nil (require 'idna)
9007 (mm-coding-system-p 'utf-8)
9008 (executable-find (symbol-value 'idna-program))))
9010 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9011 (gnus-summary-select-article)
9012 (let ((mail-header-separator ""))
9013 (gnus-eval-in-buffer-window gnus-article-buffer
9016 (let ((start (window-start))
9018 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9019 (replace-match (idna-to-unicode (match-string 1))))
9020 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9022 (autoload 'unmorse-region "morse"
9023 "Convert morse coded text in region to ordinary ASCII text."
9026 (defun gnus-summary-morse-message (&optional arg)
9027 "Morse decode the current article."
9029 (gnus-summary-select-article)
9030 (let ((mail-header-separator ""))
9031 (gnus-eval-in-buffer-window gnus-article-buffer
9035 (let ((pos (window-start))
9037 (goto-char (point-min))
9038 (when (message-goto-body)
9039 (gnus-narrow-to-body))
9040 (goto-char (point-min))
9041 (while (search-forward "·" (point-max) t)
9042 (replace-match "."))
9043 (unmorse-region (point-min) (point-max))
9045 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9047 (defun gnus-summary-stop-page-breaking ()
9048 "Stop page breaking in the current article."
9050 (gnus-summary-select-article)
9051 (gnus-eval-in-buffer-window gnus-article-buffer
9053 (when (gnus-visual-p 'page-marker)
9054 (let ((buffer-read-only nil))
9055 (gnus-remove-text-with-property 'gnus-prev)
9056 (gnus-remove-text-with-property 'gnus-next))
9057 (setq gnus-page-broken nil))))
9059 (defun gnus-summary-move-article (&optional n to-newsgroup
9060 select-method action)
9061 "Move the current article to a different newsgroup.
9062 If N is a positive number, move the N next articles.
9063 If N is a negative number, move the N previous articles.
9064 If N is nil and any articles have been marked with the process mark,
9065 move those articles instead.
9066 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9067 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9068 re-spool using this method.
9070 When called interactively with TO-NEWSGROUP being nil, the value of
9071 the variable `gnus-move-split-methods' is used for finding a default
9072 for the target newsgroup.
9074 For this function to work, both the current newsgroup and the
9075 newsgroup that you want to move to have to support the `request-move'
9076 and `request-accept' functions.
9078 ACTION can be either `move' (the default), `crosspost' or `copy'."
9081 (setq action 'move))
9082 ;; Check whether the source group supports the required functions.
9083 (cond ((and (eq action 'move)
9084 (not (gnus-check-backend-function
9085 'request-move-article gnus-newsgroup-name)))
9086 (error "The current group does not support article moving"))
9087 ((and (eq action 'crosspost)
9088 (not (gnus-check-backend-function
9089 'request-replace-article gnus-newsgroup-name)))
9090 (error "The current group does not support article editing")))
9091 (let ((articles (gnus-summary-work-articles n))
9092 (prefix (if (gnus-check-backend-function
9093 'request-move-article gnus-newsgroup-name)
9094 (funcall gnus-move-group-prefix-function
9095 gnus-newsgroup-name)
9097 (names '((move "Move" "Moving")
9098 (copy "Copy" "Copying")
9099 (crosspost "Crosspost" "Crossposting")))
9100 (copy-buf (save-excursion
9101 (nnheader-set-temp-buffer " *copy article*")))
9102 art-group to-method new-xref article to-groups articles-to-update-marks)
9103 (unless (assq action names)
9104 (error "Unknown action %s" action))
9105 ;; Read the newsgroup name.
9106 (when (and (not to-newsgroup)
9107 (not select-method))
9108 (if (and gnus-move-split-methods
9110 (and (memq gnus-current-article articles)
9111 (gnus-buffer-live-p gnus-original-article-buffer))))
9112 ;; When `gnus-move-split-methods' is non-nil, we have to
9113 ;; select an article to give `gnus-read-move-group-name' an
9114 ;; opportunity to suggest an appropriate default. However,
9115 ;; we needn't render or mark the article.
9116 (let ((gnus-display-mime-function nil)
9117 (gnus-article-prepare-hook nil)
9118 (gnus-mark-article-hook nil))
9119 (gnus-summary-select-article nil nil nil (car articles))))
9121 (gnus-read-move-group-name
9122 (cadr (assq action names))
9123 (symbol-value (intern (format "gnus-current-%s-group" action)))
9125 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9126 (setq to-method (or select-method
9127 (gnus-server-to-method
9128 (gnus-group-method to-newsgroup))))
9129 ;; Check the method we are to move this article to...
9130 (unless (gnus-check-backend-function
9131 'request-accept-article (car to-method))
9132 (error "%s does not support article copying" (car to-method)))
9133 (unless (gnus-check-server to-method)
9134 (error "Can't open server %s" (car to-method)))
9135 (gnus-message 6 "%s to %s: %s..."
9136 (caddr (assq action names))
9137 (or (car select-method) to-newsgroup) articles)
9139 (setq article (pop articles))
9143 ;; Move the article.
9145 ;; Remove this article from future suppression.
9146 (gnus-dup-unsuppress-article article)
9147 (let* ((from-method (gnus-find-method-for-group
9148 gnus-newsgroup-name))
9149 (to-method (gnus-find-method-for-group
9151 (move-is-internal (gnus-method-equal from-method to-method)))
9152 (gnus-request-move-article
9153 article ; Article to move
9154 gnus-newsgroup-name ; From newsgroup
9155 (nth 1 (gnus-find-method-for-group
9156 gnus-newsgroup-name)) ; Server
9157 (list 'gnus-request-accept-article
9158 to-newsgroup (list 'quote select-method)
9159 (not articles) t) ; Accept form
9160 (not articles) ; Only save nov last time
9161 move-is-internal))) ; is this move internal?
9162 ;; Copy the article.
9165 (set-buffer copy-buf)
9166 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9168 (nnheader-narrow-to-headers)
9169 (dolist (hdr gnus-copy-article-ignored-headers)
9170 (message-remove-header hdr t)))
9171 (gnus-request-accept-article
9172 to-newsgroup select-method (not articles) t))))
9173 ;; Crosspost the article.
9174 ((eq action 'crosspost)
9175 (let ((xref (message-tokenize-header
9176 (mail-header-xref (gnus-summary-article-header article))
9178 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9179 ":" (number-to-string article)))
9181 (setq xref (list (system-name))))
9184 (mapconcat 'identity
9185 (delete "Xref:" (delete new-xref xref))
9189 (set-buffer copy-buf)
9190 ;; First put the article in the destination group.
9191 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9192 (when (consp (setq art-group
9193 (gnus-request-accept-article
9194 to-newsgroup select-method (not articles))))
9195 (setq new-xref (concat new-xref " " (car art-group)
9197 (number-to-string (cdr art-group))))
9198 ;; Now we have the new Xrefs header, so we insert
9199 ;; it and replace the new article.
9200 (nnheader-replace-header "Xref" new-xref)
9201 (gnus-request-replace-article
9202 (cdr art-group) to-newsgroup (current-buffer))
9206 (gnus-message 1 "Couldn't %s article %s: %s"
9207 (cadr (assq action names)) article
9208 (nnheader-get-report (car to-method))))
9209 ((eq art-group 'junk)
9210 (when (eq action 'move)
9211 (gnus-summary-mark-article article gnus-canceled-mark)
9212 (gnus-message 4 "Deleted article %s" article)
9213 ;; run the delete hook
9214 (run-hook-with-args 'gnus-summary-article-delete-hook
9217 (assoc article (gnus-data-list nil)))
9218 gnus-newsgroup-name nil
9221 (let* ((pto-group (gnus-group-prefixed-name
9222 (car art-group) to-method))
9223 (info (gnus-get-info pto-group))
9224 (to-group (gnus-info-group info))
9226 ;; Update the group that has been moved to.
9228 (memq action '(move copy)))
9229 (unless (member to-group to-groups)
9230 (push to-group to-groups))
9232 (unless (memq article gnus-newsgroup-unreads)
9233 (push 'read to-marks)
9235 info (gnus-add-to-range (gnus-info-read info)
9236 (list (cdr art-group)))))
9238 ;; See whether the article is to be put in the cache.
9239 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9240 gnus-article-mark-lists
9241 (delete '(expirable . expire)
9242 (copy-sequence gnus-article-mark-lists))))
9243 (to-article (cdr art-group)))
9245 ;; Enter the article into the cache in the new group,
9246 ;; if that is required.
9247 (when gnus-use-cache
9248 (gnus-cache-possibly-enter-article
9250 (memq article gnus-newsgroup-marked)
9251 (memq article gnus-newsgroup-dormant)
9252 (memq article gnus-newsgroup-unreads)))
9254 (when gnus-preserve-marks
9255 ;; Copy any marks over to the new group.
9256 (when (and (equal to-group gnus-newsgroup-name)
9257 (not (memq article gnus-newsgroup-unreads)))
9258 ;; Mark this article as read in this group.
9259 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9260 (setcdr (gnus-active to-group) to-article)
9261 (setcdr gnus-newsgroup-active to-article))
9264 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9265 (when (memq article (symbol-value
9266 (intern (format "gnus-newsgroup-%s"
9268 (push (cdar marks) to-marks)
9269 ;; If the other group is the same as this group,
9270 ;; then we have to add the mark to the list.
9271 (when (equal to-group gnus-newsgroup-name)
9272 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9275 (intern (format "gnus-newsgroup-%s"
9277 ;; Copy the marks to other group.
9278 (gnus-add-marked-articles
9279 to-group (cdar marks) (list to-article) info)))
9280 (setq marks (cdr marks)))
9282 (gnus-request-set-mark
9283 to-group (list (list (list to-article) 'add to-marks))))
9286 (concat "(gnus-group-set-info '"
9287 (gnus-prin1-to-string (gnus-get-info to-group))
9290 ;; Update the Xref header in this article to point to
9291 ;; the new crossposted article we have just created.
9292 (when (eq action 'crosspost)
9294 (set-buffer copy-buf)
9295 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9296 (nnheader-replace-header "Xref" new-xref)
9297 (gnus-request-replace-article
9298 article gnus-newsgroup-name (current-buffer))))
9300 ;; run the move/copy/crosspost/respool hook
9301 (run-hook-with-args 'gnus-summary-article-move-hook
9304 (assoc article (gnus-data-list nil)))
9309 ;;;!!!Why is this necessary?
9310 (set-buffer gnus-summary-buffer)
9312 (gnus-summary-goto-subject article)
9313 (when (eq action 'move)
9314 (gnus-summary-mark-article article gnus-canceled-mark))))
9315 (push article articles-to-update-marks))
9317 (apply 'gnus-summary-remove-process-mark articles-to-update-marks)
9318 ;; Re-activate all groups that have been moved to.
9320 (set-buffer gnus-group-buffer)
9321 (let ((gnus-group-marked to-groups))
9322 (gnus-group-get-new-news-this-group nil t)))
9324 (gnus-kill-buffer copy-buf)
9325 (gnus-summary-position-point)
9326 (gnus-set-mode-line 'summary)))
9328 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9329 "Copy the current article to some other group.
9330 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9331 When called interactively, if TO-NEWSGROUP is nil, use the value of
9332 the variable `gnus-move-split-methods' for finding a default target
9334 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9335 re-spool using this method."
9337 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9339 (defun gnus-summary-crosspost-article (&optional n)
9340 "Crosspost the current article to some other group."
9342 (gnus-summary-move-article n nil nil 'crosspost))
9344 (defcustom gnus-summary-respool-default-method nil
9345 "Default method type for respooling an article.
9346 If nil, use to the current newsgroup method."
9348 :group 'gnus-summary-mail)
9350 (defcustom gnus-summary-display-while-building nil
9351 "If non-nil, show and update the summary buffer as it's being built.
9352 If the value is t, update the buffer after every line is inserted. If
9353 the value is an integer (N), update the display every N lines."
9356 :type '(choice (const :tag "off" nil)
9358 (const :tag "frequently" t)))
9360 (defun gnus-summary-respool-article (&optional n method)
9361 "Respool the current article.
9362 The article will be squeezed through the mail spooling process again,
9363 which means that it will be put in some mail newsgroup or other
9364 depending on `nnmail-split-methods'.
9365 If N is a positive number, respool the N next articles.
9366 If N is a negative number, respool the N previous articles.
9367 If N is nil and any articles have been marked with the process mark,
9368 respool those articles instead.
9370 Respooling can be done both from mail groups and \"real\" newsgroups.
9371 In the former case, the articles in question will be moved from the
9372 current group into whatever groups they are destined to. In the
9373 latter case, they will be copied into the relevant groups."
9375 (list current-prefix-arg
9376 (let* ((methods (gnus-methods-using 'respool))
9378 (symbol-name (or gnus-summary-respool-default-method
9379 (car (gnus-find-method-for-group
9380 gnus-newsgroup-name)))))
9382 (gnus-completing-read-with-default
9383 methname "Backend to use when respooling"
9384 methods nil t nil 'gnus-mail-method-history))
9387 ((zerop (length (setq ms (gnus-servers-using-backend
9389 (list (intern method) ""))
9393 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9394 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9397 (error "No method given for respooling"))
9398 (if (assoc (symbol-name
9399 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9400 (gnus-methods-using 'respool))
9401 (gnus-summary-move-article n nil method)
9402 (gnus-summary-copy-article n nil method)))
9404 (defun gnus-summary-import-article (file &optional edit)
9405 "Import an arbitrary file into a mail newsgroup."
9406 (interactive "fImport file: \nP")
9407 (let ((group gnus-newsgroup-name)
9408 (now (current-time))
9409 atts lines group-art)
9410 (unless (gnus-check-backend-function 'request-accept-article group)
9411 (error "%s does not support article importing" group))
9412 (or (file-readable-p file)
9413 (not (file-regular-p file))
9414 (error "Can't read %s" file))
9416 (set-buffer (gnus-get-buffer-create " *import file*"))
9418 (nnheader-insert-file-contents file)
9419 (goto-char (point-min))
9420 (if (nnheader-article-p)
9422 (goto-char (point-min))
9423 (search-forward "\n\n" nil t)
9424 (narrow-to-region (point-min) (1- (point)))
9425 (goto-char (point-min))
9426 (unless (re-search-forward "^date:" nil t)
9427 (goto-char (point-max))
9428 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9429 ;; This doesn't look like an article, so we fudge some headers.
9430 (setq atts (file-attributes file)
9431 lines (count-lines (point-min) (point-max)))
9432 (insert "From: " (read-string "From: ") "\n"
9433 "Subject: " (read-string "Subject: ") "\n"
9434 "Date: " (message-make-date (nth 5 atts)) "\n"
9435 "Message-ID: " (message-make-message-id) "\n"
9436 "Lines: " (int-to-string lines) "\n"
9437 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9438 (setq group-art (gnus-request-accept-article group nil t))
9439 (kill-buffer (current-buffer)))
9440 (setq gnus-newsgroup-active (gnus-activate-group group))
9442 (gnus-summary-goto-article (cdr group-art) nil t)
9444 (gnus-summary-edit-article))))
9446 (defun gnus-summary-create-article ()
9447 "Create an article in a mail newsgroup."
9449 (let ((group gnus-newsgroup-name)
9450 (now (current-time))
9452 (unless (gnus-check-backend-function 'request-accept-article group)
9453 (error "%s does not support article importing" group))
9455 (set-buffer (gnus-get-buffer-create " *import file*"))
9457 (goto-char (point-min))
9458 ;; This doesn't look like an article, so we fudge some headers.
9459 (insert "From: " (read-string "From: ") "\n"
9460 "Subject: " (read-string "Subject: ") "\n"
9461 "Date: " (message-make-date now) "\n"
9462 "Message-ID: " (message-make-message-id) "\n")
9463 (setq group-art (gnus-request-accept-article group nil t))
9464 (kill-buffer (current-buffer)))
9465 (setq gnus-newsgroup-active (gnus-activate-group group))
9467 (gnus-summary-goto-article (cdr group-art) nil t)
9468 (gnus-summary-edit-article)))
9470 (defun gnus-summary-article-posted-p ()
9471 "Say whether the current (mail) article is available from news as well.
9472 This will be the case if the article has both been mailed and posted."
9474 (let ((id (mail-header-references (gnus-summary-article-header)))
9475 (gnus-override-method (car (gnus-refer-article-methods))))
9476 (if (gnus-request-head id "")
9477 (gnus-message 2 "The current message was found on %s"
9478 gnus-override-method)
9479 (gnus-message 2 "The current message couldn't be found on %s"
9480 gnus-override-method)
9483 (defun gnus-summary-expire-articles (&optional now)
9484 "Expire all articles that are marked as expirable in the current group."
9486 (when (and (not gnus-group-is-exiting-without-update-p)
9487 (gnus-check-backend-function
9488 'request-expire-articles gnus-newsgroup-name))
9489 ;; This backend supports expiry.
9490 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9491 (expirable (if total
9493 ;; We need to update the info for
9494 ;; this group for `gnus-list-of-read-articles'
9495 ;; to give us the right answer.
9496 (gnus-run-hooks 'gnus-exit-group-hook)
9497 (gnus-summary-update-info)
9498 (gnus-list-of-read-articles gnus-newsgroup-name))
9499 (setq gnus-newsgroup-expirable
9500 (sort gnus-newsgroup-expirable '<))))
9501 (expiry-wait (if now 'immediate
9502 (gnus-group-find-parameter
9503 gnus-newsgroup-name 'expiry-wait)))
9504 (nnmail-expiry-target
9505 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9506 nnmail-expiry-target))
9509 ;; There are expirable articles in this group, so we run them
9510 ;; through the expiry process.
9511 (gnus-message 6 "Expiring articles...")
9512 (unless (gnus-check-group gnus-newsgroup-name)
9513 (error "Can't open server for %s" gnus-newsgroup-name))
9514 ;; The list of articles that weren't expired is returned.
9517 (let ((nnmail-expiry-wait-function nil)
9518 (nnmail-expiry-wait expiry-wait))
9519 (setq es (gnus-request-expire-articles
9520 expirable gnus-newsgroup-name)))
9521 (setq es (gnus-request-expire-articles
9522 expirable gnus-newsgroup-name)))
9524 (setq gnus-newsgroup-expirable es))
9525 ;; We go through the old list of expirable, and mark all
9526 ;; really expired articles as nonexistent.
9527 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9528 (let ((gnus-use-cache nil))
9529 (dolist (article expirable)
9530 (when (and (not (memq article es))
9531 (gnus-data-find article))
9532 (gnus-summary-mark-article article gnus-canceled-mark)
9533 (run-hook-with-args 'gnus-summary-article-expire-hook
9536 (assoc article (gnus-data-list nil)))
9540 (gnus-message 6 "Expiring articles...done")))))
9542 (defun gnus-summary-expire-articles-now ()
9543 "Expunge all expirable articles in the current group.
9544 This means that *all* articles that are marked as expirable will be
9545 deleted forever, right now."
9547 (or gnus-expert-user
9549 "Are you really, really, really sure you want to delete all these messages? ")
9551 (gnus-summary-expire-articles t))
9553 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9554 (defun gnus-summary-delete-article (&optional n)
9555 "Delete the N next (mail) articles.
9556 This command actually deletes articles. This is not a marking
9557 command. The article will disappear forever from your life, never to
9560 If N is negative, delete backwards.
9561 If N is nil and articles have been marked with the process mark,
9562 delete these instead.
9564 If `gnus-novice-user' is non-nil you will be asked for
9565 confirmation before the articles are deleted."
9567 (unless (gnus-check-backend-function 'request-expire-articles
9568 gnus-newsgroup-name)
9569 (error "The current newsgroup does not support article deletion"))
9570 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9571 (error "Couldn't open server"))
9572 ;; Compute the list of articles to delete.
9573 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9574 (nnmail-expiry-target 'delete)
9576 (if (and gnus-novice-user
9577 (not (gnus-yes-or-no-p
9578 (format "Do you really want to delete %s forever? "
9579 (if (> (length articles) 1)
9580 (format "these %s articles" (length articles))
9583 ;; Delete the articles.
9584 (setq not-deleted (gnus-request-expire-articles
9585 articles gnus-newsgroup-name 'force))
9587 (gnus-summary-remove-process-mark (car articles))
9588 ;; The backend might not have been able to delete the article
9590 (unless (memq (car articles) not-deleted)
9591 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9592 (let* ((article (car articles))
9593 (ghead (gnus-data-header
9594 (assoc article (gnus-data-list nil)))))
9595 (run-hook-with-args 'gnus-summary-article-delete-hook
9596 'delete ghead gnus-newsgroup-name nil
9598 (setq articles (cdr articles)))
9600 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9601 (gnus-summary-position-point)
9602 (gnus-set-mode-line 'summary)
9605 (defun gnus-summary-edit-article (&optional arg)
9606 "Edit the current article.
9607 This will have permanent effect only in mail groups.
9608 If ARG is nil, edit the decoded articles.
9609 If ARG is 1, edit the raw articles.
9610 If ARG is 2, edit the raw articles even in read-only groups.
9611 If ARG is 3, edit the articles with the current handles.
9612 Otherwise, allow editing of articles even in read-only
9615 (let (force raw current-handles)
9624 (setq current-handles
9625 (and (gnus-buffer-live-p gnus-article-buffer)
9626 (with-current-buffer gnus-article-buffer
9628 gnus-article-mime-handles
9629 (setq gnus-article-mime-handles nil))))))
9632 (when (and raw (not force)
9633 (member gnus-newsgroup-name '("nndraft:delayed"
9636 (error "Can't edit the raw article in group %s"
9637 gnus-newsgroup-name))
9639 (set-buffer gnus-summary-buffer)
9640 (let ((mail-parse-charset gnus-newsgroup-charset)
9641 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9642 (gnus-set-global-variables)
9643 (when (and (not force)
9644 (gnus-group-read-only-p))
9645 (error "The current newsgroup does not support article editing"))
9646 (gnus-summary-show-article t)
9647 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9648 (with-current-buffer gnus-article-buffer
9649 (mm-enable-multibyte)))
9650 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9652 (gnus-article-edit-article
9655 (let ((mbl mml-buffer-list))
9656 (setq mml-buffer-list nil)
9657 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9658 (mime-to-mml ,'current-handles))
9659 (let ((mbl1 mml-buffer-list))
9660 (setq mml-buffer-list mbl)
9661 (set (make-local-variable 'mml-buffer-list) mbl1))
9662 (gnus-make-local-hook 'kill-buffer-hook)
9663 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9664 `(lambda (no-highlight)
9665 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9666 (message-options message-options)
9667 (message-options-set-recipient)
9668 (mail-parse-ignored-charsets
9669 ',gnus-newsgroup-ignored-charsets))
9670 ,(if (not raw) '(progn
9672 (mml-destroy-buffers)
9673 (remove-hook 'kill-buffer-hook
9674 'mml-destroy-buffers t)
9675 (kill-local-variable 'mml-buffer-list)))
9676 (gnus-summary-edit-article-done
9677 ,(or (mail-header-references gnus-current-headers) "")
9678 ,(gnus-group-read-only-p)
9679 ,gnus-summary-buffer no-highlight))))))))
9681 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9683 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9685 "Make edits to the current article permanent."
9688 ;; The buffer restriction contains the entire article if it exists.
9689 (when (article-goto-body)
9690 (let ((lines (count-lines (point) (point-max)))
9691 (length (- (point-max) (point)))
9692 (case-fold-search t)
9693 (body (copy-marker (point))))
9694 (goto-char (point-min))
9695 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9696 (delete-region (match-beginning 1) (match-end 1))
9697 (insert (number-to-string length)))
9698 (goto-char (point-min))
9699 (when (re-search-forward
9700 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9701 (delete-region (match-beginning 1) (match-end 1))
9702 (insert (number-to-string length)))
9703 (goto-char (point-min))
9704 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9705 (delete-region (match-beginning 1) (match-end 1))
9706 (insert (number-to-string lines))))))
9707 ;; Replace the article.
9708 (let ((buf (current-buffer)))
9710 (insert-buffer-substring buf)
9712 (if (and (not read-only)
9713 (not (gnus-request-replace-article
9714 (cdr gnus-article-current) (car gnus-article-current)
9715 (current-buffer) t)))
9716 (error "Couldn't replace article")
9717 ;; Update the summary buffer.
9719 (equal (message-tokenize-header references " ")
9720 (message-tokenize-header
9721 (or (message-fetch-field "references") "") " ")))
9722 ;; We only have to update this line.
9725 (message-narrow-to-head)
9726 (let ((head (buffer-substring-no-properties
9727 (point-min) (point-max)))
9730 (insert (format "211 %d Article retrieved.\n"
9731 (cdr gnus-article-current)))
9734 (let ((nntp-server-buffer (current-buffer)))
9735 (setq header (car (gnus-get-newsgroup-headers
9738 (set-buffer gnus-summary-buffer)
9739 (gnus-data-set-header
9740 (gnus-data-find (cdr gnus-article-current))
9742 (gnus-summary-update-article-line
9743 (cdr gnus-article-current) header)
9744 (if (gnus-summary-goto-subject
9745 (cdr gnus-article-current) nil t)
9746 (gnus-summary-update-secondary-mark
9747 (cdr gnus-article-current))))))))
9749 (set-buffer (or buffer gnus-summary-buffer))
9750 (gnus-summary-update-article (cdr gnus-article-current))
9751 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9752 (gnus-summary-update-secondary-mark
9753 (cdr gnus-article-current))))
9754 ;; Prettify the article buffer again.
9755 (unless no-highlight
9757 (set-buffer gnus-article-buffer)
9758 ;;;!!! Fix this -- article should be rehighlighted.
9759 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9760 (set-buffer gnus-original-article-buffer)
9761 (gnus-request-article
9762 (cdr gnus-article-current)
9763 (car gnus-article-current) (current-buffer))))
9764 ;; Prettify the summary buffer line.
9765 (when (gnus-visual-p 'summary-highlight 'highlight)
9766 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9768 (defun gnus-summary-edit-wash (key)
9769 "Perform editing command KEY in the article buffer."
9773 (message "%s" (concat (this-command-keys) "- "))
9776 (gnus-summary-edit-article)
9777 (execute-kbd-macro (concat (this-command-keys) key))
9778 (gnus-article-edit-done))
9782 (defun gnus-summary-respool-query (&optional silent trace)
9783 "Query where the respool algorithm would put this article."
9785 (let (gnus-mark-article-hook)
9786 (gnus-summary-select-article)
9788 (set-buffer gnus-original-article-buffer)
9789 (let ((groups (nnmail-article-group 'identity trace)))
9792 (message "This message would go to %s"
9793 (mapconcat 'car groups ", "))
9794 (message "This message would go to no groups"))
9797 (defun gnus-summary-respool-trace ()
9798 "Trace where the respool algorithm would put this article.
9799 Display a buffer showing all fancy splitting patterns which matched."
9801 (gnus-summary-respool-query nil t))
9803 ;; Summary marking commands.
9805 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9806 "Mark articles which has the same subject as read, and then select the next.
9807 If UNMARK is positive, remove any kind of mark.
9808 If UNMARK is negative, tick articles."
9811 (setq unmark (prefix-numeric-value unmark)))
9813 (gnus-summary-mark-same-subject
9814 (gnus-summary-article-subject) unmark)))
9815 ;; Select next unread article. If auto-select-same mode, should
9816 ;; select the first unread article.
9817 (gnus-summary-next-article t (and gnus-auto-select-same
9818 (gnus-summary-article-subject)))
9819 (gnus-message 7 "%d article%s marked as %s"
9820 count (if (= count 1) " is" "s are")
9821 (if unmark "unread" "read"))))
9823 (defun gnus-summary-kill-same-subject (&optional unmark)
9824 "Mark articles which has the same subject as read.
9825 If UNMARK is positive, remove any kind of mark.
9826 If UNMARK is negative, tick articles."
9829 (setq unmark (prefix-numeric-value unmark)))
9831 (gnus-summary-mark-same-subject
9832 (gnus-summary-article-subject) unmark)))
9833 ;; If marked as read, go to next unread subject.
9835 ;; Go to next unread subject.
9836 (gnus-summary-next-subject 1 t))
9837 (gnus-message 7 "%d articles are marked as %s"
9838 count (if unmark "unread" "read"))))
9840 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9841 "Mark articles with same SUBJECT as read, and return marked number.
9842 If optional argument UNMARK is positive, remove any kinds of marks.
9843 If optional argument UNMARK is negative, mark articles as unread instead."
9847 ((null unmark) ; Mark as read.
9850 (gnus-summary-mark-article-as-read gnus-killed-mark)
9851 (gnus-summary-show-thread) t)
9852 (gnus-summary-find-subject subject))
9853 (setq count (1+ count))))
9854 ((> unmark 0) ; Tick.
9857 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9858 (gnus-summary-show-thread) t)
9859 (gnus-summary-find-subject subject))
9860 (setq count (1+ count))))
9861 (t ; Mark as unread.
9864 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9865 (gnus-summary-show-thread) t)
9866 (gnus-summary-find-subject subject))
9867 (setq count (1+ count)))))
9868 (gnus-set-mode-line 'summary)
9869 ;; Return the number of marked articles.
9872 (defun gnus-summary-mark-as-processable (n &optional unmark)
9873 "Set the process mark on the next N articles.
9874 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9875 the process mark instead. The difference between N and the actual
9876 number of articles marked is returned."
9878 (if (and (null n) (gnus-region-active-p))
9879 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9880 (setq n (prefix-numeric-value n))
9881 (let ((backward (< n 0))
9886 (gnus-summary-remove-process-mark
9887 (gnus-summary-article-number))
9888 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9889 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9892 (gnus-message 7 "No more articles"))
9893 (gnus-summary-recenter)
9894 (gnus-summary-position-point)
9897 (defun gnus-summary-unmark-as-processable (n)
9898 "Remove the process mark from the next N articles.
9899 If N is negative, unmark backward instead. The difference between N and
9900 the actual number of articles unmarked is returned."
9902 (gnus-summary-mark-as-processable n t))
9904 (defun gnus-summary-unmark-all-processable ()
9905 "Remove the process mark from all articles."
9908 (while gnus-newsgroup-processable
9909 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9910 (gnus-summary-position-point))
9912 (defun gnus-summary-add-mark (article type)
9913 "Mark ARTICLE with a mark of TYPE."
9914 (let ((vtype (car (assq type gnus-article-mark-lists)))
9917 (error "No such mark type: %s" type)
9918 (setq var (intern (format "gnus-newsgroup-%s" type)))
9919 (set var (cons article (symbol-value var)))
9920 (if (memq type '(processable cached replied forwarded recent saved))
9921 (gnus-summary-update-secondary-mark article)
9922 ;;; !!! This is bogus. We should find out what primary
9923 ;;; !!! mark we want to set.
9924 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9926 (defun gnus-summary-mark-as-expirable (n)
9927 "Mark N articles forward as expirable.
9928 If N is negative, mark backward instead. The difference between N and
9929 the actual number of articles marked is returned."
9931 (gnus-summary-mark-forward n gnus-expirable-mark))
9933 (defun gnus-summary-mark-as-spam (n)
9934 "Mark N articles forward as spam.
9935 If N is negative, mark backward instead. The difference between N and
9936 the actual number of articles marked is returned."
9938 (gnus-summary-mark-forward n gnus-spam-mark))
9940 (defun gnus-summary-mark-article-as-replied (article)
9941 "Mark ARTICLE as replied to and update the summary line.
9942 ARTICLE can also be a list of articles."
9943 (interactive (list (gnus-summary-article-number)))
9944 (let ((articles (if (listp article) article (list article))))
9945 (dolist (article articles)
9946 (unless (numberp article)
9947 (error "%s is not a number" article))
9948 (push article gnus-newsgroup-replied)
9949 (let ((buffer-read-only nil))
9950 (when (gnus-summary-goto-subject article nil t)
9951 (gnus-summary-update-secondary-mark article))))))
9953 (defun gnus-summary-mark-article-as-forwarded (article)
9954 "Mark ARTICLE as forwarded and update the summary line.
9955 ARTICLE can also be a list of articles."
9956 (let ((articles (if (listp article) article (list article))))
9957 (dolist (article articles)
9958 (push article gnus-newsgroup-forwarded)
9959 (let ((buffer-read-only nil))
9960 (when (gnus-summary-goto-subject article nil t)
9961 (gnus-summary-update-secondary-mark article))))))
9963 (defun gnus-summary-set-bookmark (article)
9964 "Set a bookmark in current article."
9965 (interactive (list (gnus-summary-article-number)))
9966 (when (or (not (get-buffer gnus-article-buffer))
9967 (not gnus-current-article)
9968 (not gnus-article-current)
9969 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9970 (error "No current article selected"))
9971 ;; Remove old bookmark, if one exists.
9972 (gnus-pull article gnus-newsgroup-bookmarks)
9973 ;; Set the new bookmark, which is on the form
9974 ;; (article-number . line-number-in-body).
9977 (with-current-buffer gnus-article-buffer
9984 gnus-newsgroup-bookmarks)
9985 (gnus-message 6 "A bookmark has been added to the current article."))
9987 (defun gnus-summary-remove-bookmark (article)
9988 "Remove the bookmark from the current article."
9989 (interactive (list (gnus-summary-article-number)))
9990 ;; Remove old bookmark, if one exists.
9991 (if (not (assq article gnus-newsgroup-bookmarks))
9992 (gnus-message 6 "No bookmark in current article.")
9993 (gnus-pull article gnus-newsgroup-bookmarks)
9994 (gnus-message 6 "Removed bookmark.")))
9996 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9997 (defun gnus-summary-mark-as-dormant (n)
9998 "Mark N articles forward as dormant.
9999 If N is negative, mark backward instead. The difference between N and
10000 the actual number of articles marked is returned."
10002 (gnus-summary-mark-forward n gnus-dormant-mark))
10004 (defun gnus-summary-set-process-mark (article)
10005 "Set the process mark on ARTICLE and update the summary line."
10006 (setq gnus-newsgroup-processable
10008 (delq article gnus-newsgroup-processable)))
10009 (when (gnus-summary-goto-subject article)
10010 (gnus-summary-show-thread)
10011 (gnus-summary-goto-subject article)
10012 (gnus-summary-update-secondary-mark article)))
10014 (defun gnus-summary-remove-process-mark (&rest articles)
10015 "Remove the process mark from ARTICLES and update the summary line."
10016 (dolist (article articles)
10017 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10018 (when (gnus-summary-goto-subject article)
10019 (gnus-summary-show-thread)
10020 (gnus-summary-goto-subject article)
10021 (gnus-summary-update-secondary-mark article))))
10023 (defun gnus-summary-set-saved-mark (article)
10024 "Set the process mark on ARTICLE and update the summary line."
10025 (push article gnus-newsgroup-saved)
10026 (when (gnus-summary-goto-subject article)
10027 (gnus-summary-update-secondary-mark article)))
10029 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10030 "Mark N articles as read forwards.
10031 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10032 The difference between N and the actual number of articles marked is
10034 If NO-EXPIRE, auto-expiry will be inhibited."
10036 (gnus-summary-show-thread)
10037 (let ((backward (< n 0))
10038 (gnus-summary-goto-unread
10039 (and gnus-summary-goto-unread
10040 (not (eq gnus-summary-goto-unread 'never))
10041 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10042 gnus-ticked-mark gnus-dormant-mark)))))
10044 (mark (or mark gnus-del-mark)))
10045 (while (and (> n 0)
10046 (gnus-summary-mark-article nil mark no-expire)
10047 (zerop (gnus-summary-next-subject
10049 (and gnus-summary-goto-unread
10050 (not (eq gnus-summary-goto-unread 'never)))
10054 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10055 (gnus-summary-recenter)
10056 (gnus-summary-position-point)
10057 (gnus-set-mode-line 'summary)
10060 (defun gnus-summary-mark-article-as-read (mark)
10061 "Mark the current article quickly as read with MARK."
10062 (let ((article (gnus-summary-article-number)))
10063 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10064 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10065 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10066 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10067 (push (cons article mark) gnus-newsgroup-reads)
10068 ;; Possibly remove from cache, if that is used.
10069 (when gnus-use-cache
10070 (gnus-cache-enter-remove-article article))
10071 ;; Allow the backend to change the mark.
10072 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10073 ;; Check for auto-expiry.
10074 (when (and gnus-newsgroup-auto-expire
10075 (memq mark gnus-auto-expirable-marks))
10076 (setq mark gnus-expirable-mark)
10077 ;; Let the backend know about the mark change.
10078 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10079 (push article gnus-newsgroup-expirable))
10080 ;; Set the mark in the buffer.
10081 (gnus-summary-update-mark mark 'unread)
10084 (defun gnus-summary-mark-article-as-unread (mark)
10085 "Mark the current article quickly as unread with MARK."
10086 (let* ((article (gnus-summary-article-number))
10087 (old-mark (gnus-summary-article-mark article)))
10088 ;; Allow the backend to change the mark.
10089 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10090 (if (eq mark old-mark)
10094 (gnus-error 1 "Can't mark negative article numbers")
10096 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10097 (setq gnus-newsgroup-spam-marked
10098 (delq article gnus-newsgroup-spam-marked))
10099 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10100 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10101 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10102 (cond ((= mark gnus-ticked-mark)
10103 (setq gnus-newsgroup-marked
10104 (gnus-add-to-sorted-list gnus-newsgroup-marked
10106 ((= mark gnus-spam-mark)
10107 (setq gnus-newsgroup-spam-marked
10108 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10110 ((= mark gnus-dormant-mark)
10111 (setq gnus-newsgroup-dormant
10112 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10115 (setq gnus-newsgroup-unreads
10116 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10118 (gnus-pull article gnus-newsgroup-reads)
10120 ;; See whether the article is to be put in the cache.
10121 (and gnus-use-cache
10122 (vectorp (gnus-summary-article-header article))
10124 (gnus-cache-possibly-enter-article
10125 gnus-newsgroup-name article
10126 (= mark gnus-ticked-mark)
10127 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10130 (gnus-summary-update-mark mark 'unread)
10133 (defun gnus-summary-mark-article (&optional article mark no-expire)
10134 "Mark ARTICLE with MARK. MARK can be any character.
10135 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10136 `??' (dormant) and `?E' (expirable).
10137 If MARK is nil, then the default character `?r' is used.
10138 If ARTICLE is nil, then the article on the current line will be
10140 If NO-EXPIRE, auto-expiry will be inhibited."
10141 ;; The mark might be a string.
10142 (when (stringp mark)
10143 (setq mark (aref mark 0)))
10144 ;; If no mark is given, then we check auto-expiring.
10146 (setq mark gnus-del-mark))
10147 (when (and (not no-expire)
10148 gnus-newsgroup-auto-expire
10149 (memq mark gnus-auto-expirable-marks))
10150 (setq mark gnus-expirable-mark))
10151 (let ((article (or article (gnus-summary-article-number)))
10152 (old-mark (gnus-summary-article-mark article)))
10153 ;; Allow the backend to change the mark.
10154 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10155 (if (eq mark old-mark)
10158 (error "No article on current line"))
10159 (if (not (if (or (= mark gnus-unread-mark)
10160 (= mark gnus-ticked-mark)
10161 (= mark gnus-spam-mark)
10162 (= mark gnus-dormant-mark))
10163 (gnus-mark-article-as-unread article mark)
10164 (gnus-mark-article-as-read article mark)))
10166 ;; See whether the article is to be put in the cache.
10167 (and gnus-use-cache
10168 (not (= mark gnus-canceled-mark))
10169 (vectorp (gnus-summary-article-header article))
10171 (gnus-cache-possibly-enter-article
10172 gnus-newsgroup-name article
10173 (= mark gnus-ticked-mark)
10174 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10176 (when (gnus-summary-goto-subject article nil t)
10177 (let ((buffer-read-only nil))
10178 (gnus-summary-show-thread)
10180 (gnus-summary-update-mark mark 'unread)
10183 (defun gnus-summary-update-secondary-mark (article)
10184 "Update the secondary (read, process, cache) mark."
10185 (gnus-summary-update-mark
10186 (cond ((memq article gnus-newsgroup-processable)
10188 ((memq article gnus-newsgroup-cached)
10190 ((memq article gnus-newsgroup-replied)
10192 ((memq article gnus-newsgroup-forwarded)
10193 gnus-forwarded-mark)
10194 ((memq article gnus-newsgroup-saved)
10196 ((memq article gnus-newsgroup-recent)
10198 ((memq article gnus-newsgroup-unseen)
10202 (when (gnus-visual-p 'summary-highlight 'highlight)
10203 (gnus-run-hooks 'gnus-summary-update-hook))
10206 (defun gnus-summary-update-download-mark (article)
10207 "Update the download mark."
10208 (gnus-summary-update-mark
10209 (cond ((memq article gnus-newsgroup-undownloaded)
10210 gnus-undownloaded-mark)
10211 (gnus-newsgroup-agentized
10212 gnus-downloaded-mark)
10216 (gnus-summary-update-line t)
10219 (defun gnus-summary-update-mark (mark type)
10220 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10221 (buffer-read-only nil))
10222 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10224 (when (looking-at "\r")
10226 (when (<= (+ forward (point)) (point-max))
10227 ;; Go to the right position on the line.
10228 (goto-char (+ forward (point)))
10229 ;; Replace the old mark with the new mark.
10230 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10231 ;; Optionally update the marks by some user rule.
10232 (when (eq type 'unread)
10233 (gnus-data-set-mark
10234 (gnus-data-find (gnus-summary-article-number)) mark)
10235 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10237 (defun gnus-mark-article-as-read (article &optional mark)
10238 "Enter ARTICLE in the pertinent lists and remove it from others."
10239 ;; Make the article expirable.
10240 (let ((mark (or mark gnus-del-mark)))
10241 (setq gnus-newsgroup-expirable
10242 (if (= mark gnus-expirable-mark)
10243 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10244 (delq article gnus-newsgroup-expirable)))
10245 ;; Remove from unread and marked lists.
10246 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10247 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10248 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10249 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10250 (push (cons article mark) gnus-newsgroup-reads)
10251 ;; Possibly remove from cache, if that is used.
10252 (when gnus-use-cache
10253 (gnus-cache-enter-remove-article article))
10256 (defun gnus-mark-article-as-unread (article &optional mark)
10257 "Enter ARTICLE in the pertinent lists and remove it from others."
10258 (let ((mark (or mark gnus-ticked-mark)))
10261 (gnus-error 1 "Can't mark negative article numbers")
10263 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10264 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10265 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10266 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10267 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10269 ;; Unsuppress duplicates?
10270 (when gnus-suppress-duplicates
10271 (gnus-dup-unsuppress-article article))
10273 (cond ((= mark gnus-ticked-mark)
10274 (setq gnus-newsgroup-marked
10275 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10276 ((= mark gnus-spam-mark)
10277 (setq gnus-newsgroup-spam-marked
10278 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10280 ((= mark gnus-dormant-mark)
10281 (setq gnus-newsgroup-dormant
10282 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10284 (setq gnus-newsgroup-unreads
10285 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10286 (gnus-pull article gnus-newsgroup-reads)
10289 (defalias 'gnus-summary-mark-as-unread-forward
10290 'gnus-summary-tick-article-forward)
10291 (make-obsolete 'gnus-summary-mark-as-unread-forward
10292 'gnus-summary-tick-article-forward)
10293 (defun gnus-summary-tick-article-forward (n)
10294 "Tick N articles forwards.
10295 If N is negative, tick backwards instead.
10296 The difference between N and the number of articles ticked is returned."
10298 (gnus-summary-mark-forward n gnus-ticked-mark))
10300 (defalias 'gnus-summary-mark-as-unread-backward
10301 'gnus-summary-tick-article-backward)
10302 (make-obsolete 'gnus-summary-mark-as-unread-backward
10303 'gnus-summary-tick-article-backward)
10304 (defun gnus-summary-tick-article-backward (n)
10305 "Tick N articles backwards.
10306 The difference between N and the number of articles ticked is returned."
10308 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10310 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10311 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10312 (defun gnus-summary-tick-article (&optional article clear-mark)
10313 "Mark current article as unread.
10314 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10315 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10317 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10318 gnus-ticked-mark)))
10320 (defun gnus-summary-mark-as-read-forward (n)
10321 "Mark N articles as read forwards.
10322 If N is negative, mark backwards instead.
10323 The difference between N and the actual number of articles marked is
10326 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10328 (defun gnus-summary-mark-as-read-backward (n)
10329 "Mark the N articles as read backwards.
10330 The difference between N and the actual number of articles marked is
10333 (gnus-summary-mark-forward
10334 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10336 (defun gnus-summary-mark-as-read (&optional article mark)
10337 "Mark current article as read.
10338 ARTICLE specifies the article to be marked as read.
10339 MARK specifies a string to be inserted at the beginning of the line."
10340 (gnus-summary-mark-article article mark))
10342 (defun gnus-summary-clear-mark-forward (n)
10343 "Clear marks from N articles forward.
10344 If N is negative, clear backward instead.
10345 The difference between N and the number of marks cleared is returned."
10347 (gnus-summary-mark-forward n gnus-unread-mark))
10349 (defun gnus-summary-clear-mark-backward (n)
10350 "Clear marks from N articles backward.
10351 The difference between N and the number of marks cleared is returned."
10353 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10355 (defun gnus-summary-mark-unread-as-read ()
10356 "Intended to be used by `gnus-summary-mark-article-hook'."
10357 (when (memq gnus-current-article gnus-newsgroup-unreads)
10358 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10360 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10361 "Intended to be used by `gnus-summary-mark-article-hook'."
10362 (let ((mark (gnus-summary-article-mark)))
10363 (when (or (gnus-unread-mark-p mark)
10364 (gnus-read-mark-p mark))
10365 (gnus-summary-mark-article gnus-current-article
10366 (or new-mark gnus-read-mark)))))
10368 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10369 "Intended to be used by `gnus-summary-mark-article-hook'."
10370 (let ((mark (gnus-summary-article-mark)))
10371 (when (or (gnus-unread-mark-p mark)
10372 (gnus-read-mark-p mark))
10373 (gnus-summary-mark-article (gnus-summary-article-number)
10374 (or new-mark gnus-read-mark)))))
10376 (defun gnus-summary-mark-unread-as-ticked ()
10377 "Intended to be used by `gnus-summary-mark-article-hook'."
10378 (when (memq gnus-current-article gnus-newsgroup-unreads)
10379 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10381 (defun gnus-summary-mark-region-as-read (point mark all)
10382 "Mark all unread articles between point and mark as read.
10383 If given a prefix, mark all articles between point and mark as read,
10384 even ticked and dormant ones."
10385 (interactive "r\nP")
10389 (beginning-of-line)
10394 (memq (setq article (gnus-summary-article-number))
10395 gnus-newsgroup-unreads))
10396 (gnus-summary-mark-article article gnus-del-mark))
10398 (gnus-summary-find-next))))))
10400 (defun gnus-summary-mark-below (score mark)
10401 "Mark articles with score less than SCORE with MARK."
10402 (interactive "P\ncMark: ")
10403 (setq score (if score
10404 (prefix-numeric-value score)
10405 (or gnus-summary-default-score 0)))
10407 (set-buffer gnus-summary-buffer)
10408 (goto-char (point-min))
10411 (and (< (gnus-summary-article-score) score)
10412 (gnus-summary-mark-article nil mark))
10413 (gnus-summary-find-next)))))
10415 (defun gnus-summary-kill-below (&optional score)
10416 "Mark articles with score below SCORE as read."
10418 (gnus-summary-mark-below score gnus-killed-mark))
10420 (defun gnus-summary-clear-above (&optional score)
10421 "Clear all marks from articles with score above SCORE."
10423 (gnus-summary-mark-above score gnus-unread-mark))
10425 (defun gnus-summary-tick-above (&optional score)
10426 "Tick all articles with score above SCORE."
10428 (gnus-summary-mark-above score gnus-ticked-mark))
10430 (defun gnus-summary-mark-above (score mark)
10431 "Mark articles with score over SCORE with MARK."
10432 (interactive "P\ncMark: ")
10433 (setq score (if score
10434 (prefix-numeric-value score)
10435 (or gnus-summary-default-score 0)))
10437 (set-buffer gnus-summary-buffer)
10438 (goto-char (point-min))
10440 (when (> (gnus-summary-article-score) score)
10441 (gnus-summary-mark-article nil mark))
10443 (gnus-summary-find-next)))))
10445 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10446 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10447 (defun gnus-summary-limit-include-expunged (&optional no-error)
10448 "Display all the hidden articles that were expunged for low scores."
10450 (let ((buffer-read-only nil))
10451 (let ((scored gnus-newsgroup-scored)
10454 (unless (gnus-summary-article-header (caar scored))
10455 (and (setq h (gnus-number-to-header (caar scored)))
10456 (< (cdar scored) gnus-summary-expunge-below)
10458 (setq scored (cdr scored)))
10460 (when (not no-error)
10461 (error "No expunged articles hidden"))
10462 (goto-char (point-min))
10463 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10464 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10465 (mapcar (lambda (x) (push (mail-header-number x)
10466 gnus-newsgroup-limit))
10468 (gnus-summary-prepare-unthreaded (nreverse headers))
10469 (goto-char (point-min))
10470 (gnus-summary-position-point)
10473 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10474 "Mark all unread articles in this newsgroup as read.
10475 If prefix argument ALL is non-nil, ticked and dormant articles will
10476 also be marked as read.
10477 If QUIETLY is non-nil, no questions will be asked.
10479 If TO-HERE is non-nil, it should be a point in the buffer. All
10480 articles before (after, if REVERSE is set) this point will be marked
10483 Note that this function will only catch up the unread article
10484 in the current summary buffer limitation.
10486 The number of articles marked as read is returned."
10491 (not gnus-interactive-catchup) ;Without confirmation?
10495 "Mark absolutely all articles as read? "
10496 "Mark all unread articles as read? ")))
10498 (not gnus-newsgroup-adaptive)
10499 (not gnus-newsgroup-auto-expire)
10500 (not gnus-suppress-duplicates)
10501 (or (not gnus-use-cache)
10502 (eq gnus-use-cache 'passive)))
10505 (setq gnus-newsgroup-marked nil
10506 gnus-newsgroup-spam-marked nil
10507 gnus-newsgroup-dormant nil))
10508 (setq gnus-newsgroup-unreads
10509 (gnus-sorted-nunion
10510 (gnus-intersection gnus-newsgroup-unreads
10511 gnus-newsgroup-downloadable)
10512 gnus-newsgroup-unfetched)))
10513 ;; We actually mark all articles as canceled, which we
10514 ;; have to do when using auto-expiry or adaptive scoring.
10515 (gnus-summary-show-all-threads)
10516 (if (and to-here reverse)
10518 (goto-char to-here)
10519 (gnus-summary-mark-current-read-and-unread-as-read
10521 (while (gnus-summary-find-next (not all))
10522 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10523 (when (gnus-summary-first-subject (not all))
10525 (if to-here (< (point) to-here) t)
10526 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10527 (gnus-summary-find-next (not all))))))
10528 (gnus-set-mode-line 'summary))
10530 (gnus-summary-position-point)))
10532 (defun gnus-summary-catchup-to-here (&optional all)
10533 "Mark all unticked articles before the current one as read.
10534 If ALL is non-nil, also mark ticked and dormant articles as read."
10537 (gnus-save-hidden-threads
10538 (let ((beg (point)))
10539 ;; We check that there are unread articles.
10540 (when (or all (gnus-summary-find-prev))
10541 (gnus-summary-catchup all t beg)))))
10542 (gnus-summary-position-point))
10544 (defun gnus-summary-catchup-from-here (&optional all)
10545 "Mark all unticked articles after (and including) the current one as read.
10546 If ALL is non-nil, also mark ticked and dormant articles as read."
10549 (gnus-save-hidden-threads
10550 (let ((beg (point)))
10551 ;; We check that there are unread articles.
10552 (when (or all (gnus-summary-find-next))
10553 (gnus-summary-catchup all t beg nil t)))))
10554 (gnus-summary-position-point))
10556 (defun gnus-summary-catchup-all (&optional quietly)
10557 "Mark all articles in this newsgroup as read.
10558 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10559 instead, which marks only unread articles as read."
10561 (gnus-summary-catchup t quietly))
10563 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10564 "Mark all unread articles in this group as read, then exit.
10565 If prefix argument ALL is non-nil, all articles are marked as read.
10566 If QUIETLY is non-nil, no questions will be asked."
10568 (when (gnus-summary-catchup all quietly nil 'fast)
10569 ;; Select next newsgroup or exit.
10570 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10571 (eq gnus-auto-select-next 'quietly))
10572 (gnus-summary-next-group nil)
10573 (gnus-summary-exit))))
10575 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10576 "Mark all articles in this newsgroup as read, and then exit.
10577 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10578 instead, which marks only unread articles as read."
10580 (gnus-summary-catchup-and-exit t quietly))
10582 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10583 "Mark all articles in this group as read and select the next group.
10584 If given a prefix, mark all articles, unread as well as ticked, as
10588 (gnus-summary-catchup all))
10589 (gnus-summary-next-group))
10595 (defmacro gnus-with-article (article &rest forms)
10596 "Select ARTICLE and perform FORMS in the original article buffer.
10597 Then replace the article with the result."
10599 ;; We don't want the article to be marked as read.
10600 (let (gnus-mark-article-hook)
10601 (gnus-summary-select-article t t nil ,article))
10602 (set-buffer gnus-original-article-buffer)
10604 (if (not (gnus-check-backend-function
10605 'request-replace-article (car gnus-article-current)))
10606 (gnus-message 5 "Read-only group; not replacing")
10607 (unless (gnus-request-replace-article
10608 ,article (car gnus-article-current)
10609 (current-buffer) t)
10610 (error "Couldn't replace article")))
10611 ;; The cache and backlog have to be flushed somewhat.
10612 (when gnus-keep-backlog
10613 (gnus-backlog-remove-article
10614 (car gnus-article-current) (cdr gnus-article-current)))
10615 (when gnus-use-cache
10616 (gnus-cache-update-article
10617 (car gnus-article-current) (cdr gnus-article-current)))))
10619 (put 'gnus-with-article 'lisp-indent-function 1)
10620 (put 'gnus-with-article 'edebug-form-spec '(form body))
10622 ;; Thread-based commands.
10624 (defun gnus-summary-articles-in-thread (&optional article)
10625 "Return a list of all articles in the current thread.
10626 If ARTICLE is non-nil, return all articles in the thread that starts
10627 with that article."
10628 (let* ((article (or article (gnus-summary-article-number)))
10629 (data (gnus-data-find-list article))
10630 (top-level (gnus-data-level (car data)))
10632 (cond ((null gnus-thread-operation-ignore-subject)
10633 (gnus-simplify-subject-re
10634 (mail-header-subject (gnus-data-header (car data)))))
10635 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10636 (gnus-simplify-subject-fuzzy
10637 (mail-header-subject (gnus-data-header (car data)))))
10639 (end-point (save-excursion
10640 (if (gnus-summary-go-to-next-thread)
10641 (point) (point-max))))
10644 (< (gnus-data-pos (car data)) end-point))
10645 (when (or (not top-subject)
10646 (string= top-subject
10647 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10648 (gnus-simplify-subject-fuzzy
10649 (mail-header-subject
10650 (gnus-data-header (car data))))
10651 (gnus-simplify-subject-re
10652 (mail-header-subject
10653 (gnus-data-header (car data)))))))
10654 (push (gnus-data-number (car data)) articles))
10655 (unless (and (setq data (cdr data))
10656 (> (gnus-data-level (car data)) top-level))
10658 ;; Return the list of articles.
10659 (nreverse articles)))
10661 (defun gnus-summary-rethread-current ()
10662 "Rethread the thread the current article is part of."
10664 (let* ((gnus-show-threads t)
10665 (article (gnus-summary-article-number))
10666 (id (mail-header-id (gnus-summary-article-header)))
10667 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10669 (error "No article on the current line"))
10670 (gnus-rebuild-thread id)
10671 (gnus-summary-goto-subject article)))
10673 (defun gnus-summary-reparent-thread ()
10674 "Make the current article child of the marked (or previous) article.
10676 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10677 is non-nil or the Subject: of both articles are the same."
10679 (unless (not (gnus-group-read-only-p))
10680 (error "The current newsgroup does not support article editing"))
10681 (unless (<= (length gnus-newsgroup-processable) 1)
10682 (error "No more than one article may be marked"))
10683 (save-window-excursion
10684 (let ((gnus-article-buffer " *reparent*")
10685 (current-article (gnus-summary-article-number))
10686 ;; First grab the marked article, otherwise one line up.
10687 (parent-article (if (not (null gnus-newsgroup-processable))
10688 (car gnus-newsgroup-processable)
10690 (if (eq (forward-line -1) 0)
10691 (gnus-summary-article-number)
10692 (error "Beginning of summary buffer"))))))
10693 (unless (not (eq current-article parent-article))
10694 (error "An article may not be self-referential"))
10695 (let ((message-id (mail-header-id
10696 (gnus-summary-article-header parent-article))))
10697 (unless (and message-id (not (equal message-id "")))
10698 (error "No message-id in desired parent"))
10699 (gnus-with-article current-article
10701 (goto-char (point-min))
10702 (message-narrow-to-head)
10703 (if (re-search-forward "^References: " nil t)
10705 (re-search-forward "^[^ \t]" nil t)
10708 (insert " " message-id))
10709 (insert "References: " message-id "\n"))))
10710 (set-buffer gnus-summary-buffer)
10711 (gnus-summary-unmark-all-processable)
10712 (gnus-summary-update-article current-article)
10713 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10714 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10715 (gnus-summary-rethread-current)
10716 (gnus-message 3 "Article %d is now the child of article %d"
10717 current-article parent-article)))))
10719 (defun gnus-summary-toggle-threads (&optional arg)
10720 "Toggle showing conversation threads.
10721 If ARG is positive number, turn showing conversation threads on."
10723 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10724 (setq gnus-show-threads
10725 (if (null arg) (not gnus-show-threads)
10726 (> (prefix-numeric-value arg) 0)))
10727 (gnus-summary-prepare)
10728 (gnus-summary-goto-subject current)
10729 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10730 (gnus-summary-position-point)))
10732 (defun gnus-summary-show-all-threads ()
10733 "Show all threads."
10736 (let ((buffer-read-only nil))
10737 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10738 (gnus-summary-position-point))
10740 (defun gnus-summary-show-thread ()
10741 "Show thread subtrees.
10742 Returns nil if no thread was there to be shown."
10744 (let ((buffer-read-only nil)
10746 (end (point-at-eol))
10747 ;; Leave point at bol
10748 (beg (progn (beginning-of-line) (point))))
10750 ;; Any hidden lines here?
10751 (search-forward "\r" end t)
10752 (subst-char-in-region beg end ?\^M ?\n t)
10754 (gnus-summary-position-point))))
10756 (defun gnus-summary-maybe-hide-threads ()
10757 "If requested, hide the threads that should be hidden."
10758 (when (and gnus-show-threads
10759 gnus-thread-hide-subtree)
10760 (gnus-summary-hide-all-threads
10761 (if (or (consp gnus-thread-hide-subtree)
10762 (functionp gnus-thread-hide-subtree))
10763 (gnus-make-predicate gnus-thread-hide-subtree)
10766 ;;; Hiding predicates.
10768 (defun gnus-article-unread-p (header)
10769 (memq (mail-header-number header) gnus-newsgroup-unreads))
10771 (defun gnus-article-unseen-p (header)
10772 (memq (mail-header-number header) gnus-newsgroup-unseen))
10774 (defun gnus-map-articles (predicate articles)
10775 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10776 (apply 'gnus-or (mapcar predicate
10777 (mapcar 'gnus-summary-article-header articles))))
10779 (defun gnus-summary-hide-all-threads (&optional predicate)
10780 "Hide all thread subtrees.
10781 If PREDICATE is supplied, threads that satisfy this predicate
10782 will not be hidden."
10785 (goto-char (point-min))
10788 (when (or (not predicate)
10790 predicate (gnus-summary-article-children)))
10791 (gnus-summary-hide-thread))
10792 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10793 (gnus-summary-position-point))
10795 (defun gnus-summary-hide-thread ()
10796 "Hide thread subtrees.
10797 If PREDICATE is supplied, threads that satisfy this predicate
10798 will not be hidden.
10799 Returns nil if no threads were there to be hidden."
10801 (let ((buffer-read-only nil)
10803 (article (gnus-summary-article-number)))
10805 ;; Go forward until either the buffer ends or the subthread
10807 (when (and (not (eobp))
10808 (or (zerop (gnus-summary-next-thread 1 t))
10809 (goto-char (point-max))))
10811 (if (and (> (point) start)
10812 (search-backward "\n" start t))
10814 (subst-char-in-region start (point) ?\n ?\^M)
10815 (gnus-summary-goto-subject article))
10819 (defun gnus-summary-go-to-next-thread (&optional previous)
10820 "Go to the same level (or less) next thread.
10821 If PREVIOUS is non-nil, go to previous thread instead.
10822 Return the article number moved to, or nil if moving was impossible."
10823 (let ((level (gnus-summary-thread-level))
10824 (way (if previous -1 1))
10827 (while (and (not (eobp))
10828 (< level (gnus-summary-thread-level)))
10829 (forward-line way))
10836 (gnus-summary-article-number)
10837 (goto-char beg)))))
10839 (defun gnus-summary-next-thread (n &optional silent)
10840 "Go to the same level next N'th thread.
10841 If N is negative, search backward instead.
10842 Returns the difference between N and the number of skips actually
10845 If SILENT, don't output messages."
10847 (let ((backward (< n 0))
10849 (while (and (> n 0)
10850 (gnus-summary-go-to-next-thread backward))
10853 (gnus-summary-position-point))
10854 (when (and (not silent) (/= 0 n))
10855 (gnus-message 7 "No more threads"))
10858 (defun gnus-summary-prev-thread (n)
10859 "Go to the same level previous N'th thread.
10860 Returns the difference between N and the number of skips actually
10863 (gnus-summary-next-thread (- n)))
10865 (defun gnus-summary-go-down-thread ()
10866 "Go down one level in the current thread."
10867 (let ((children (gnus-summary-article-children)))
10869 (gnus-summary-goto-subject (car children)))))
10871 (defun gnus-summary-go-up-thread ()
10872 "Go up one level in the current thread."
10873 (let ((parent (gnus-summary-article-parent)))
10875 (gnus-summary-goto-subject parent))))
10877 (defun gnus-summary-down-thread (n)
10878 "Go down thread N steps.
10879 If N is negative, go up instead.
10880 Returns the difference between N and how many steps down that were
10885 (while (and (> n 0)
10886 (if up (gnus-summary-go-up-thread)
10887 (gnus-summary-go-down-thread)))
10889 (gnus-summary-position-point)
10891 (gnus-message 7 "Can't go further"))
10894 (defun gnus-summary-up-thread (n)
10895 "Go up thread N steps.
10896 If N is negative, go down instead.
10897 Returns the difference between N and how many steps down that were
10900 (gnus-summary-down-thread (- n)))
10902 (defun gnus-summary-top-thread ()
10903 "Go to the top of the thread."
10905 (while (gnus-summary-go-up-thread))
10906 (gnus-summary-article-number))
10908 (defun gnus-summary-kill-thread (&optional unmark)
10909 "Mark articles under current thread as read.
10910 If the prefix argument is positive, remove any kinds of marks.
10911 If the prefix argument is negative, tick articles instead."
10914 (setq unmark (prefix-numeric-value unmark)))
10915 (let ((articles (gnus-summary-articles-in-thread)))
10917 ;; Expand the thread.
10918 (gnus-summary-show-thread)
10919 ;; Mark all the articles.
10921 (gnus-summary-goto-subject (car articles))
10922 (cond ((null unmark)
10923 (gnus-summary-mark-article-as-read gnus-killed-mark))
10925 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10927 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10928 (setq articles (cdr articles))))
10929 ;; Hide killed subtrees.
10931 gnus-thread-hide-killed
10932 (gnus-summary-hide-thread))
10933 ;; If marked as read, go to next unread subject.
10934 (when (null unmark)
10935 ;; Go to next unread subject.
10936 (gnus-summary-next-subject 1 t)))
10937 (gnus-set-mode-line 'summary))
10939 ;; Summary sorting commands
10941 (defun gnus-summary-sort-by-number (&optional reverse)
10942 "Sort the summary buffer by article number.
10943 Argument REVERSE means reverse order."
10945 (gnus-summary-sort 'number reverse))
10947 (defun gnus-summary-sort-by-random (&optional reverse)
10948 "Randomize the order in the summary buffer.
10949 Argument REVERSE means to randomize in reverse order."
10951 (gnus-summary-sort 'random reverse))
10953 (defun gnus-summary-sort-by-author (&optional reverse)
10954 "Sort the summary buffer by author name alphabetically.
10955 If `case-fold-search' is non-nil, case of letters is ignored.
10956 Argument REVERSE means reverse order."
10958 (gnus-summary-sort 'author reverse))
10960 (defun gnus-summary-sort-by-recipient (&optional reverse)
10961 "Sort the summary buffer by recipient name alphabetically.
10962 If `case-fold-search' is non-nil, case of letters is ignored.
10963 Argument REVERSE means reverse order."
10965 (gnus-summary-sort 'recipient reverse))
10967 (defun gnus-summary-sort-by-subject (&optional reverse)
10968 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10969 If `case-fold-search' is non-nil, case of letters is ignored.
10970 Argument REVERSE means reverse order."
10972 (gnus-summary-sort 'subject reverse))
10974 (defun gnus-summary-sort-by-date (&optional reverse)
10975 "Sort the summary buffer by date.
10976 Argument REVERSE means reverse order."
10978 (gnus-summary-sort 'date reverse))
10980 (defun gnus-summary-sort-by-score (&optional reverse)
10981 "Sort the summary buffer by score.
10982 Argument REVERSE means reverse order."
10984 (gnus-summary-sort 'score reverse))
10986 (defun gnus-summary-sort-by-lines (&optional reverse)
10987 "Sort the summary buffer by the number of lines.
10988 Argument REVERSE means reverse order."
10990 (gnus-summary-sort 'lines reverse))
10992 (defun gnus-summary-sort-by-chars (&optional reverse)
10993 "Sort the summary buffer by article length.
10994 Argument REVERSE means reverse order."
10996 (gnus-summary-sort 'chars reverse))
10998 (defun gnus-summary-sort-by-original (&optional reverse)
10999 "Sort the summary buffer using the default sorting method.
11000 Argument REVERSE means reverse order."
11002 (let* ((buffer-read-only)
11003 (gnus-summary-prepare-hook nil))
11004 ;; We do the sorting by regenerating the threads.
11005 (gnus-summary-prepare)
11006 ;; Hide subthreads if needed.
11007 (gnus-summary-maybe-hide-threads)))
11009 (defun gnus-summary-sort (predicate reverse)
11010 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11011 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11012 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11013 (gnus-thread-sort-functions
11018 (gnus-sort-gathered-threads-function
11019 gnus-thread-sort-functions)
11020 (gnus-article-sort-functions
11024 (,article t2 t1))))
11026 (gnus-summary-prepare-hook nil))
11027 ;; We do the sorting by regenerating the threads.
11028 (gnus-summary-prepare)
11029 ;; Hide subthreads if needed.
11030 (gnus-summary-maybe-hide-threads)))
11032 ;; Summary saving commands.
11034 (defun gnus-summary-save-article (&optional n not-saved)
11035 "Save the current article using the default saver function.
11036 If N is a positive number, save the N next articles.
11037 If N is a negative number, save the N previous articles.
11038 If N is nil and any articles have been marked with the process mark,
11039 save those articles instead.
11040 The variable `gnus-default-article-saver' specifies the saver function."
11042 (let* ((articles (gnus-summary-work-articles n))
11043 (save-buffer (save-excursion
11044 (nnheader-set-temp-buffer " *Gnus Save*")))
11045 (num (length articles))
11047 (dolist (article articles)
11048 (setq header (gnus-summary-article-header article))
11049 (if (not (vectorp header))
11050 ;; This is a pseudo-article.
11051 (if (assq 'name header)
11052 (gnus-copy-file (cdr (assq 'name header)))
11053 (gnus-message 1 "Article %d is unsaveable" article))
11054 ;; This is a real article.
11055 (save-window-excursion
11056 (let ((gnus-display-mime-function nil)
11057 (gnus-article-prepare-hook nil))
11058 (gnus-summary-select-article t nil nil article)))
11060 (set-buffer save-buffer)
11062 (insert-buffer-substring gnus-original-article-buffer))
11063 (setq file (gnus-article-save save-buffer file num))
11064 (gnus-summary-remove-process-mark article)
11066 (gnus-summary-set-saved-mark article))))
11067 (gnus-kill-buffer save-buffer)
11068 (gnus-summary-position-point)
11069 (gnus-set-mode-line 'summary)
11072 (defun gnus-summary-pipe-output (&optional arg headers)
11073 "Pipe the current article to a subprocess.
11074 If N is a positive number, pipe the N next articles.
11075 If N is a negative number, pipe the N previous articles.
11076 If N is nil and any articles have been marked with the process mark,
11077 pipe those articles instead.
11078 If HEADERS (the symbolic prefix), include the headers, too."
11079 (interactive (gnus-interactive "P\ny"))
11080 (require 'gnus-art)
11081 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11082 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11083 (gnus-summary-save-article arg t))
11084 (let ((buffer (get-buffer "*Shell Command Output*")))
11086 (not (zerop (buffer-size buffer))))
11087 (gnus-configure-windows 'pipe))))
11089 (defun gnus-summary-save-article-mail (&optional arg)
11090 "Append the current article to an mail file.
11091 If N is a positive number, save the N next articles.
11092 If N is a negative number, save the N previous articles.
11093 If N is nil and any articles have been marked with the process mark,
11094 save those articles instead."
11096 (require 'gnus-art)
11097 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11098 (gnus-summary-save-article arg)))
11100 (defun gnus-summary-save-article-rmail (&optional arg)
11101 "Append the current article to an rmail file.
11102 If N is a positive number, save the N next articles.
11103 If N is a negative number, save the N previous articles.
11104 If N is nil and any articles have been marked with the process mark,
11105 save those articles instead."
11107 (require 'gnus-art)
11108 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11109 (gnus-summary-save-article arg)))
11111 (defun gnus-summary-save-article-file (&optional arg)
11112 "Append the current article to a file.
11113 If N is a positive number, save the N next articles.
11114 If N is a negative number, save the N previous articles.
11115 If N is nil and any articles have been marked with the process mark,
11116 save those articles instead."
11118 (require 'gnus-art)
11119 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11120 (gnus-summary-save-article arg)))
11122 (defun gnus-summary-write-article-file (&optional arg)
11123 "Write the current article to a file, deleting the previous file.
11124 If N is a positive number, save the N next articles.
11125 If N is a negative number, save the N previous articles.
11126 If N is nil and any articles have been marked with the process mark,
11127 save those articles instead."
11129 (require 'gnus-art)
11130 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11131 (gnus-summary-save-article arg)))
11133 (defun gnus-summary-save-article-body-file (&optional arg)
11134 "Append the current article body to a file.
11135 If N is a positive number, save the N next articles.
11136 If N is a negative number, save the N previous articles.
11137 If N is nil and any articles have been marked with the process mark,
11138 save those articles instead."
11140 (require 'gnus-art)
11141 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11142 (gnus-summary-save-article arg)))
11144 (defun gnus-summary-muttprint (&optional arg)
11145 "Print the current article using Muttprint.
11146 If N is a positive number, save the N next articles.
11147 If N is a negative number, save the N previous articles.
11148 If N is nil and any articles have been marked with the process mark,
11149 save those articles instead."
11151 (require 'gnus-art)
11152 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11153 (gnus-summary-save-article arg t)))
11155 (defun gnus-summary-pipe-message (program)
11156 "Pipe the current article through PROGRAM."
11157 (interactive "sProgram: ")
11158 (gnus-summary-select-article)
11159 (let ((mail-header-separator ""))
11160 (gnus-eval-in-buffer-window gnus-article-buffer
11163 (let ((start (window-start))
11165 (message-pipe-buffer-body program)
11166 (set-window-start (get-buffer-window (current-buffer)) start))))))
11168 (defun gnus-get-split-value (methods)
11169 "Return a value based on the split METHODS."
11170 (let (split-name method result match)
11173 (set-buffer gnus-original-article-buffer)
11175 (nnheader-narrow-to-headers)
11176 (while (and methods (not split-name))
11177 (goto-char (point-min))
11178 (setq method (pop methods))
11179 (setq match (car method))
11182 ;; Regular expression.
11184 (re-search-forward match nil t)))
11189 (setq result (funcall match gnus-newsgroup-name))))
11194 (setq result (eval match)))))
11195 (setq split-name (cdr method))
11196 (cond ((stringp result)
11197 (push (expand-file-name
11198 result gnus-article-save-directory)
11201 (setq split-name (append result split-name)))))))))
11202 (nreverse split-name)))
11204 (defun gnus-valid-move-group-p (group)
11205 (and (boundp group)
11206 (symbol-name group)
11207 (symbol-value group)
11208 (gnus-get-function (gnus-find-method-for-group
11209 (symbol-name group)) 'request-accept-article t)))
11211 (defun gnus-read-move-group-name (prompt default articles prefix)
11212 "Read a group name."
11213 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11214 (minibuffer-confirm-incomplete nil) ; XEmacs
11218 (if (> (length articles) 1)
11219 (format "these %d articles" (length articles))
11224 (gnus-completing-read-with-default
11227 'gnus-valid-move-group-p
11229 'gnus-group-history))
11230 ((= 1 (length split-name))
11231 (gnus-completing-read-with-default
11232 (car split-name) prom
11234 'gnus-valid-move-group-p
11236 'gnus-group-history))
11238 (gnus-completing-read-with-default
11240 (mapcar 'list (nreverse split-name))
11242 'gnus-group-history))))
11243 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11245 (if (or (string= to-newsgroup "")
11246 (string= to-newsgroup prefix))
11247 (setq to-newsgroup default))
11248 (unless to-newsgroup
11249 (error "No group name entered"))
11250 (or (gnus-active to-newsgroup)
11251 (gnus-activate-group to-newsgroup nil nil to-method)
11252 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11254 (or (and (gnus-request-create-group to-newsgroup to-method)
11255 (gnus-activate-group
11256 to-newsgroup nil nil to-method)
11257 (gnus-subscribe-group to-newsgroup))
11258 (error "Couldn't create group %s" to-newsgroup)))
11259 (error "No such group: %s" to-newsgroup)))
11262 (defun gnus-summary-save-parts (type dir n &optional reverse)
11263 "Save parts matching TYPE to DIR.
11264 If REVERSE, save parts that do not match TYPE."
11266 (list (read-string "Save parts of type: "
11267 (or (car gnus-summary-save-parts-type-history)
11268 gnus-summary-save-parts-default-mime)
11269 'gnus-summary-save-parts-type-history)
11270 (setq gnus-summary-save-parts-last-directory
11271 (read-file-name "Save to directory: "
11272 gnus-summary-save-parts-last-directory
11274 current-prefix-arg))
11275 (gnus-summary-iterate n
11276 (let ((gnus-display-mime-function nil)
11277 (gnus-inhibit-treatment t))
11278 (gnus-summary-select-article))
11280 (set-buffer gnus-article-buffer)
11281 (let ((handles (or gnus-article-mime-handles
11282 (mm-dissect-buffer nil gnus-article-loose-mime)
11283 (and gnus-article-emulate-mime
11284 (mm-uu-dissect)))))
11286 (gnus-summary-save-parts-1 type dir handles reverse)
11287 (unless gnus-article-mime-handles ;; Don't destroy this case.
11288 (mm-destroy-parts handles)))))))
11290 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11291 (if (stringp (car handle))
11292 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11295 (not (string-match type (mm-handle-media-type handle)))
11296 (string-match type (mm-handle-media-type handle)))
11297 (let ((file (expand-file-name
11299 mm-file-name-rewrite-functions
11300 (file-name-nondirectory
11302 (mail-content-type-get
11303 (mm-handle-disposition handle) 'filename)
11304 (mail-content-type-get
11305 (mm-handle-type handle) 'name)
11306 (concat gnus-newsgroup-name
11307 "." (number-to-string
11308 (cdr gnus-article-current))))))
11310 (unless (file-exists-p file)
11311 (mm-save-part-to-file handle file))))))
11313 ;; Summary extract commands
11315 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11316 (let ((buffer-read-only nil)
11317 (article (gnus-summary-article-number))
11319 (unless (gnus-summary-goto-subject article)
11320 (error "No such article: %d" article))
11321 (gnus-summary-position-point)
11322 ;; If all commands are to be bunched up on one line, we collect
11324 (unless gnus-view-pseudos-separately
11325 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11328 (setq action (cdr (assq 'action (car ps))))
11329 (setq files (list (cdr (assq 'name (car ps)))))
11330 (while (and ps (cdr ps)
11331 (string= (or action "1")
11332 (or (cdr (assq 'action (cadr ps))) "2")))
11333 (push (cdr (assq 'name (cadr ps))) files)
11334 (setcdr ps (cddr ps)))
11336 (when (not (string-match "%s" action))
11339 (when (assq 'execute (car ps))
11340 (setcdr (assq 'execute (car ps))
11341 (funcall (if (string-match "%s" action)
11348 (shell-quote-argument f)))
11350 (setq ps (cdr ps)))))
11351 (if (and gnus-view-pseudos (not not-view))
11353 (when (assq 'execute (car pslist))
11354 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11355 (eq gnus-view-pseudos 'not-confirm)))
11356 (setq pslist (cdr pslist)))
11359 (setq after-article (or (cdr (assq 'article (car pslist)))
11360 (gnus-summary-article-number)))
11361 (gnus-summary-goto-subject after-article)
11364 (insert " " (file-name-nondirectory
11365 (cdr (assq 'name (car pslist))))
11366 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11368 (forward-line -1) ; back to `b'
11369 (gnus-add-text-properties
11370 b (1- e) (list 'gnus-number gnus-reffed-article-number
11371 gnus-mouse-face-prop gnus-mouse-face))
11373 after-article gnus-reffed-article-number
11374 gnus-unread-mark b (car pslist) 0 (- e b))
11375 (setq gnus-newsgroup-unreads
11376 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11377 gnus-reffed-article-number))
11378 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11379 (setq pslist (cdr pslist)))))))
11381 (defun gnus-pseudos< (p1 p2)
11382 (let ((c1 (cdr (assq 'action p1)))
11383 (c2 (cdr (assq 'action p2))))
11384 (and c1 c2 (string< c1 c2))))
11386 (defun gnus-request-pseudo-article (props)
11387 (cond ((assq 'execute props)
11388 (gnus-execute-command (cdr (assq 'execute props)))))
11389 (let ((gnus-current-article (gnus-summary-article-number)))
11390 (gnus-run-hooks 'gnus-mark-article-hook)))
11392 (defun gnus-execute-command (command &optional automatic)
11394 (gnus-article-setup-buffer)
11395 (set-buffer gnus-article-buffer)
11396 (setq buffer-read-only nil)
11397 (let ((command (if automatic command
11398 (read-string "Command: " (cons command 0)))))
11400 (insert "$ " command "\n\n")
11401 (if gnus-view-pseudo-asynchronously
11402 (start-process "gnus-execute" (current-buffer) shell-file-name
11403 shell-command-switch command)
11404 (call-process shell-file-name nil t nil
11405 shell-command-switch command)))))
11407 ;; Summary kill commands.
11409 (defun gnus-summary-edit-global-kill (article)
11410 "Edit the \"global\" kill file."
11411 (interactive (list (gnus-summary-article-number)))
11412 (gnus-group-edit-global-kill article))
11414 (defun gnus-summary-edit-local-kill ()
11415 "Edit a local kill file applied to the current newsgroup."
11417 (setq gnus-current-headers (gnus-summary-article-header))
11418 (gnus-group-edit-local-kill
11419 (gnus-summary-article-number) gnus-newsgroup-name))
11421 ;;; Header reading.
11423 (defun gnus-read-header (id &optional header)
11424 "Read the headers of article ID and enter them into the Gnus system."
11425 (let ((group gnus-newsgroup-name)
11426 (gnus-override-method
11428 gnus-override-method
11429 (and (gnus-news-group-p gnus-newsgroup-name)
11430 (car (gnus-refer-article-methods)))))
11432 ;; First we check to see whether the header in question is already
11435 ;; This is a Message-ID.
11436 (setq header (or header (gnus-id-to-header id)))
11437 ;; This is an article number.
11438 (setq header (or header (gnus-summary-article-header id))))
11440 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11441 ;; We have found the header.
11443 ;; We have to really fetch the header to this article.
11445 (set-buffer nntp-server-buffer)
11446 (when (setq where (gnus-request-head id group))
11447 (nnheader-fold-continuation-lines)
11448 (goto-char (point-max))
11450 (goto-char (point-min))
11454 ((cdr where) (cdr where))
11455 (header (mail-header-number header))
11456 (t gnus-reffed-article-number))
11458 (insert " Article retrieved.\n"))
11459 (if (or (not where)
11460 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11461 () ; Malformed head.
11462 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11463 (when (and (stringp id)
11464 (not (string= (gnus-group-real-name group)
11466 ;; If we fetched by Message-ID and the article came
11467 ;; from a different group, we fudge some bogus article
11468 ;; numbers for this article.
11469 (mail-header-set-number header gnus-reffed-article-number))
11471 (set-buffer gnus-summary-buffer)
11472 (decf gnus-reffed-article-number)
11473 (gnus-remove-header (mail-header-number header))
11474 (push header gnus-newsgroup-headers)
11475 (setq gnus-current-headers header)
11476 (push (mail-header-number header) gnus-newsgroup-limit)))
11479 (defun gnus-remove-header (number)
11480 "Remove header NUMBER from `gnus-newsgroup-headers'."
11481 (if (and gnus-newsgroup-headers
11482 (= number (mail-header-number (car gnus-newsgroup-headers))))
11483 (pop gnus-newsgroup-headers)
11484 (let ((headers gnus-newsgroup-headers))
11485 (while (and (cdr headers)
11486 (not (= number (mail-header-number (cadr headers)))))
11488 (when (cdr headers)
11489 (setcdr headers (cddr headers))))))
11492 ;;; summary highlights
11495 (defun gnus-highlight-selected-summary ()
11496 "Highlight selected article in summary buffer."
11497 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11498 (when gnus-summary-selected-face
11500 (let* ((beg (point-at-bol))
11501 (end (point-at-eol))
11502 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11503 (from (if (get-text-property beg gnus-mouse-face-prop)
11505 (or (next-single-property-change
11506 beg gnus-mouse-face-prop nil end)
11511 (or (next-single-property-change
11512 from gnus-mouse-face-prop nil end)
11514 ;; If no mouse-face prop on line we will have to = from = end,
11515 ;; so we highlight the entire line instead.
11516 (when (= (+ to 2) from)
11519 (if gnus-newsgroup-selected-overlay
11520 ;; Move old overlay.
11522 gnus-newsgroup-selected-overlay from to (current-buffer))
11523 ;; Create new overlay.
11525 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11526 'face gnus-summary-selected-face))))))
11528 (defvar gnus-summary-highlight-line-cached nil)
11529 (defvar gnus-summary-highlight-line-trigger nil)
11531 (defun gnus-summary-highlight-line-0 ()
11532 (if (and (eq gnus-summary-highlight-line-trigger
11533 gnus-summary-highlight)
11534 gnus-summary-highlight-line-cached)
11535 gnus-summary-highlight-line-cached
11536 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11537 gnus-summary-highlight-line-cached
11538 (let* ((cond (list 'cond))
11540 (list gnus-summary-highlight))
11542 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11546 (gnus-byte-compile (list 'lambda nil cond))))))
11548 (defun gnus-summary-highlight-line ()
11549 "Highlight current line according to `gnus-summary-highlight'."
11550 (let* ((beg (point-at-bol))
11551 (article (or (gnus-summary-article-number) gnus-current-article))
11552 (score (or (cdr (assq article
11553 gnus-newsgroup-scored))
11554 gnus-summary-default-score 0))
11555 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11556 (inhibit-read-only t)
11557 (default gnus-summary-default-score)
11558 (default-high gnus-summary-default-high-score)
11559 (default-low gnus-summary-default-low-score)
11560 (uncached (and gnus-summary-use-undownloaded-faces
11561 (memq article gnus-newsgroup-undownloaded)
11562 (not (memq article gnus-newsgroup-cached)))))
11563 (let ((face (funcall (gnus-summary-highlight-line-0))))
11564 (unless (eq face (get-text-property beg 'face))
11565 (gnus-put-text-property-excluding-characters-with-faces
11566 beg (point-at-eol) 'face
11567 (setq face (if (boundp face) (symbol-value face) face)))
11568 (when gnus-summary-highlight-line-function
11569 (funcall gnus-summary-highlight-line-function article face))))))
11571 (defun gnus-update-read-articles (group unread &optional compute)
11572 "Update the list of read articles in GROUP.
11573 UNREAD is a sorted list."
11574 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11575 (info (gnus-get-info group))
11578 (if (or (not info) (not active))
11579 ;; There is no info on this group if it was, in fact,
11580 ;; killed. Gnus stores no information on killed groups, so
11581 ;; there's nothing to be done.
11582 ;; One could store the information somewhere temporarily,
11583 ;; perhaps... Hmmm...
11585 ;; Remove any negative articles numbers.
11586 (while (and unread (< (car unread) 0))
11587 (setq unread (cdr unread)))
11588 ;; Remove any expired article numbers
11589 (while (and unread (< (car unread) (car active)))
11590 (setq unread (cdr unread)))
11591 ;; Compute the ranges of read articles by looking at the list of
11592 ;; unread articles.
11594 (when (/= (car unread) prev)
11595 (push (if (= prev (1- (car unread))) prev
11596 (cons prev (1- (car unread))))
11598 (setq prev (1+ (car unread)))
11599 (setq unread (cdr unread)))
11600 (when (<= prev (cdr active))
11601 (push (cons prev (cdr active)) read))
11602 (setq read (if (> (length read) 1) (nreverse read) read))
11607 ;; Propagate the read marks to the backend.
11608 (when (gnus-check-backend-function 'request-set-mark group)
11609 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11610 (add (gnus-remove-from-range read (gnus-info-read info))))
11612 (unless (gnus-check-group group)
11613 (error "Can't open server for %s" group))
11614 (gnus-request-set-mark
11615 group (delq nil (list (if add (list add 'add '(read)))
11616 (if del (list del 'del '(read))))))
11618 `(gnus-request-set-mark
11621 (if del (list del 'add '(read)))
11622 (if add (list add 'del '(read))))))))))
11623 (set-buffer gnus-group-buffer)
11624 (gnus-undo-register
11626 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11627 (gnus-info-set-read ',info ',(gnus-info-read info))
11628 (gnus-get-unread-articles-in-group ',info
11629 (gnus-active ,group))
11630 (gnus-group-update-group ,group t)
11632 ;; Enter this list into the group info.
11633 (gnus-info-set-read info read)
11634 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11635 (gnus-get-unread-articles-in-group info (gnus-active group))
11638 (defun gnus-offer-save-summaries ()
11639 "Offer to save all active summary buffers."
11641 ;; Go through all buffers and find all summaries.
11642 (dolist (buffer (buffer-list))
11643 (when (and (setq buffer (buffer-name buffer))
11644 (string-match "Summary" buffer)
11645 (with-current-buffer buffer
11646 ;; We check that this is, indeed, a summary buffer.
11647 (and (eq major-mode 'gnus-summary-mode)
11648 ;; Also make sure this isn't bogus.
11649 gnus-newsgroup-prepared
11650 ;; Also make sure that this isn't a
11651 ;; dead summary buffer.
11652 (not gnus-dead-summary-mode))))
11653 (push buffer buffers)))
11654 ;; Go through all these summary buffers and offer to save them.
11658 "Update summary buffer %s? "
11660 (switch-to-buffer buf)
11661 (gnus-summary-exit))
11664 (defun gnus-summary-setup-default-charset ()
11665 "Setup newsgroup default charset."
11666 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11667 (setq gnus-newsgroup-charset nil)
11668 (let* ((ignored-charsets
11669 (or gnus-newsgroup-ephemeral-ignored-charsets
11671 (and gnus-newsgroup-name
11672 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11673 gnus-newsgroup-ignored-charsets))))
11674 (setq gnus-newsgroup-charset
11675 (or gnus-newsgroup-ephemeral-charset
11676 (and gnus-newsgroup-name
11677 (gnus-parameter-charset gnus-newsgroup-name))
11678 gnus-default-charset))
11679 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11680 ignored-charsets))))
11686 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11687 "Display the current article buffer fully MIME-buttonized.
11688 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11689 treated as multipart/mixed."
11691 (require 'gnus-art)
11692 (let ((gnus-unbuttonized-mime-types nil)
11693 (gnus-mime-display-multipart-as-mixed show-all-parts))
11694 (gnus-summary-show-article)))
11696 (defun gnus-summary-repair-multipart (article)
11697 "Add a Content-Type header to a multipart article without one."
11698 (interactive (list (gnus-summary-article-number)))
11699 (gnus-with-article article
11700 (message-narrow-to-head)
11701 (message-remove-header "Mime-Version")
11702 (goto-char (point-max))
11703 (insert "Mime-Version: 1.0\n")
11705 (when (search-forward "\n--" nil t)
11706 (let ((separator (buffer-substring (point) (point-at-eol))))
11707 (message-narrow-to-head)
11708 (message-remove-header "Content-Type")
11709 (goto-char (point-max))
11710 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11713 (let (gnus-mark-article-hook)
11714 (gnus-summary-select-article t t nil article)))
11716 (defun gnus-summary-toggle-display-buttonized ()
11717 "Toggle the buttonizing of the article buffer."
11719 (require 'gnus-art)
11720 (if (setq gnus-inhibit-mime-unbuttonizing
11721 (not gnus-inhibit-mime-unbuttonizing))
11722 (let ((gnus-unbuttonized-mime-types nil))
11723 (gnus-summary-show-article))
11724 (gnus-summary-show-article)))
11727 ;;; Generic summary marking commands
11730 (defvar gnus-summary-marking-alist
11731 '((read gnus-del-mark "d")
11732 (unread gnus-unread-mark "u")
11733 (ticked gnus-ticked-mark "!")
11734 (dormant gnus-dormant-mark "?")
11735 (expirable gnus-expirable-mark "e"))
11736 "An alist of names/marks/keystrokes.")
11738 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11739 (defvar gnus-summary-mark-map)
11741 (defun gnus-summary-make-all-marking-commands ()
11742 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11743 (dolist (elem gnus-summary-marking-alist)
11744 (apply 'gnus-summary-make-marking-command elem)))
11746 (defun gnus-summary-make-marking-command (name mark keystroke)
11747 (let ((map (make-sparse-keymap)))
11748 (define-key gnus-summary-generic-mark-map keystroke map)
11749 (dolist (lway `((next "next" next nil "n")
11750 (next-unread "next unread" next t "N")
11751 (prev "previous" prev nil "p")
11752 (prev-unread "previous unread" prev t "P")
11753 (nomove "" nil nil ,keystroke)))
11754 (let ((func (gnus-summary-make-marking-command-1
11755 mark (car lway) lway name)))
11756 (setq func (eval func))
11757 (define-key map (nth 4 lway) func)))))
11759 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11761 (format "gnus-summary-put-mark-as-%s%s"
11762 name (if (eq way 'nomove)
11764 (concat "-" (symbol-name way)))))
11767 "Mark the current article as %s%s.
11768 If N, the prefix, then repeat N times.
11769 If N is negative, move in reverse order.
11770 The difference between N and the actual number of articles marked is
11774 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11776 (defun gnus-summary-generic-mark (n mark move unread)
11777 "Mark N articles with MARK."
11778 (unless (eq major-mode 'gnus-summary-mode)
11779 (error "This command can only be used in the summary buffer"))
11780 (gnus-summary-show-thread)
11783 ((eq move 'next) 1)
11784 ((eq move 'prev) -1)
11786 (if (zerop nummove)
11790 nummove (* -1 nummove))))
11791 (while (and (> n 0)
11792 (gnus-summary-mark-article nil mark)
11793 (zerop (gnus-summary-next-subject nummove unread t)))
11796 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11797 (gnus-summary-recenter)
11798 (gnus-summary-position-point)
11799 (gnus-set-mode-line 'summary)
11802 (defun gnus-summary-insert-articles (articles)
11803 (when (setq articles
11804 (gnus-sorted-difference articles
11805 (mapcar (lambda (h)
11806 (mail-header-number h))
11807 gnus-newsgroup-headers)))
11808 (setq gnus-newsgroup-headers
11810 gnus-newsgroup-headers
11811 (gnus-fetch-headers articles)
11812 'gnus-article-sort-by-number))
11813 ;; Suppress duplicates?
11814 (when gnus-suppress-duplicates
11815 (gnus-dup-suppress-articles))
11817 ;; We might want to build some more threads first.
11818 (when (and gnus-fetch-old-headers
11819 (eq gnus-headers-retrieved-by 'nov))
11820 (if (eq gnus-fetch-old-headers 'invisible)
11821 (gnus-build-all-threads)
11822 (gnus-build-old-threads)))
11823 ;; Let the Gnus agent mark articles as read.
11825 (gnus-agent-get-undownloaded-list))
11826 ;; Remove list identifiers from subject
11827 (when gnus-list-identifiers
11828 (gnus-summary-remove-list-identifiers))
11829 ;; First and last article in this newsgroup.
11830 (when gnus-newsgroup-headers
11831 (setq gnus-newsgroup-begin
11832 (mail-header-number (car gnus-newsgroup-headers))
11834 (mail-header-number
11835 (gnus-last-element gnus-newsgroup-headers))))
11836 (when gnus-use-scoring
11837 (gnus-possibly-score-headers))))
11839 (defun gnus-summary-insert-old-articles (&optional all)
11840 "Insert all old articles in this group.
11841 If ALL is non-nil, already read articles become readable.
11842 If ALL is a number, fetch this number of articles."
11845 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11848 ;; Some nntp servers lie about their active range. When
11849 ;; this happens, the active range can be in the millions.
11850 ;; Use a compressed range to avoid creating a huge list.
11851 (gnus-range-difference (list gnus-newsgroup-active) old))
11852 (setq len (gnus-range-length older))
11857 (let ((older-range (nreverse older)))
11861 (let* ((r (pop older-range))
11862 (min (if (numberp r) r (car r)))
11863 (max (if (numberp r) r (cdr r))))
11864 (while (and (<= min max)
11869 (setq older (gnus-uncompress-range older))))
11871 (setq older (gnus-uncompress-range older)))
11873 (when (and (numberp gnus-large-newsgroup)
11874 (> len gnus-large-newsgroup))
11875 (let* ((cursor-in-echo-area nil)
11876 (initial (gnus-parameter-large-newsgroup-initial
11877 gnus-newsgroup-name))
11881 "How many articles from %s (%s %d): "
11883 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11884 (if initial "max" "default")
11887 (cons (number-to-string initial)
11889 (unless (string-match "^[ \t]*$" input)
11890 (setq all (string-to-number input))
11892 (let ((older-range (nreverse older)))
11896 (let* ((r (pop older-range))
11897 (min (if (numberp r) r (car r)))
11898 (max (if (numberp r) r (cdr r))))
11899 (while (and (<= min max)
11903 max (1- max))))))))))
11904 (setq older (gnus-uncompress-range older))))
11906 (message "No old news.")
11907 (gnus-summary-insert-articles older)
11908 (gnus-summary-limit (gnus-sorted-nunion old older))))
11909 (gnus-summary-position-point)))
11911 (defun gnus-summary-insert-new-articles ()
11912 "Insert all new articles in this group."
11915 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11916 (old-active gnus-newsgroup-active)
11917 (nnmail-fetched-sources (list t))
11919 (setq gnus-newsgroup-active
11920 (gnus-activate-group gnus-newsgroup-name 'scan))
11921 (setq i (cdr gnus-newsgroup-active))
11922 (while (> i (cdr old-active))
11926 (message "No gnus is bad news")
11927 (gnus-summary-insert-articles new)
11928 (setq gnus-newsgroup-unreads
11929 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11930 (gnus-summary-limit (gnus-sorted-nunion old new))))
11931 (gnus-summary-position-point)))
11933 (gnus-summary-make-all-marking-commands)
11935 (gnus-ems-redefine)
11937 (provide 'gnus-sum)
11939 (run-hooks 'gnus-sum-load-hook)
11941 ;; Local Variables:
11942 ;; coding: iso-8859-1
11945 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11946 ;;; gnus-sum.el ends here