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 "p" gnus-summary-catchup-and-goto-prev-group
1912 "R" gnus-summary-reselect-current-group
1913 "G" gnus-summary-rescan-group
1914 "N" gnus-summary-next-group
1915 "s" gnus-summary-save-newsrc
1916 "P" gnus-summary-prev-group)
1918 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1919 " " gnus-summary-next-page
1920 "n" gnus-summary-next-page
1921 "\177" gnus-summary-prev-page
1922 [delete] gnus-summary-prev-page
1923 "p" gnus-summary-prev-page
1924 "\r" gnus-summary-scroll-up
1925 "\M-\r" gnus-summary-scroll-down
1926 "<" gnus-summary-beginning-of-article
1927 ">" gnus-summary-end-of-article
1928 "b" gnus-summary-beginning-of-article
1929 "e" gnus-summary-end-of-article
1930 "^" gnus-summary-refer-parent-article
1931 "r" gnus-summary-refer-parent-article
1932 "D" gnus-summary-enter-digest-group
1933 "R" gnus-summary-refer-references
1934 "T" gnus-summary-refer-thread
1935 "g" gnus-summary-show-article
1936 "s" gnus-summary-isearch-article
1937 "P" gnus-summary-print-article
1938 "M" gnus-mailing-list-insinuate
1939 "t" gnus-article-babel)
1941 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1942 "b" gnus-article-add-buttons
1943 "B" gnus-article-add-buttons-to-head
1944 "o" gnus-article-treat-overstrike
1945 "e" gnus-article-emphasize
1946 "w" gnus-article-fill-cited-article
1947 "Q" gnus-article-fill-long-lines
1948 "C" gnus-article-capitalize-sentences
1949 "c" gnus-article-remove-cr
1950 "q" gnus-article-de-quoted-unreadable
1951 "6" gnus-article-de-base64-unreadable
1952 "Z" gnus-article-decode-HZ
1953 "A" gnus-article-treat-ansi-sequences
1954 "h" gnus-article-wash-html
1955 "u" gnus-article-unsplit-urls
1956 "s" gnus-summary-force-verify-and-decrypt
1957 "f" gnus-article-display-x-face
1958 "l" gnus-summary-stop-page-breaking
1959 "r" gnus-summary-caesar-message
1960 "m" gnus-summary-morse-message
1961 "t" gnus-summary-toggle-header
1962 "g" gnus-treat-smiley
1963 "v" gnus-summary-verbose-headers
1964 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1965 "p" gnus-article-verify-x-pgp-sig
1966 "d" gnus-article-treat-dumbquotes
1967 "i" gnus-summary-idna-message)
1969 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1970 ;; mnemonic: deuglif*Y*
1971 "u" gnus-article-outlook-unwrap-lines
1972 "a" gnus-article-outlook-repair-attribution
1973 "c" gnus-article-outlook-rearrange-citation
1974 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1976 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1977 "a" gnus-article-hide
1978 "h" gnus-article-hide-headers
1979 "b" gnus-article-hide-boring-headers
1980 "s" gnus-article-hide-signature
1981 "c" gnus-article-hide-citation
1982 "C" gnus-article-hide-citation-in-followups
1983 "l" gnus-article-hide-list-identifiers
1984 "B" gnus-article-strip-banner
1985 "P" gnus-article-hide-pem
1986 "\C-c" gnus-article-hide-citation-maybe)
1988 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1989 "a" gnus-article-highlight
1990 "h" gnus-article-highlight-headers
1991 "c" gnus-article-highlight-citation
1992 "s" gnus-article-highlight-signature)
1994 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1995 "f" gnus-article-treat-fold-headers
1996 "u" gnus-article-treat-unfold-headers
1997 "n" gnus-article-treat-fold-newsgroups)
1999 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2000 "x" gnus-article-display-x-face
2001 "d" gnus-article-display-face
2002 "s" gnus-treat-smiley
2003 "D" gnus-article-remove-images
2004 "f" gnus-treat-from-picon
2005 "m" gnus-treat-mail-picon
2006 "n" gnus-treat-newsgroups-picon)
2008 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2009 "w" gnus-article-decode-mime-words
2010 "c" gnus-article-decode-charset
2011 "v" gnus-mime-view-all-parts
2012 "b" gnus-article-view-part)
2014 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2015 "z" gnus-article-date-ut
2016 "u" gnus-article-date-ut
2017 "l" gnus-article-date-local
2018 "p" gnus-article-date-english
2019 "e" gnus-article-date-lapsed
2020 "o" gnus-article-date-original
2021 "i" gnus-article-date-iso8601
2022 "s" gnus-article-date-user)
2024 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2025 "t" gnus-article-remove-trailing-blank-lines
2026 "l" gnus-article-strip-leading-blank-lines
2027 "m" gnus-article-strip-multiple-blank-lines
2028 "a" gnus-article-strip-blank-lines
2029 "A" gnus-article-strip-all-blank-lines
2030 "s" gnus-article-strip-leading-space
2031 "e" gnus-article-strip-trailing-space
2032 "w" gnus-article-remove-leading-whitespace)
2034 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2036 "f" gnus-summary-fetch-faq
2037 "d" gnus-summary-describe-group
2038 "h" gnus-summary-describe-briefly
2039 "i" gnus-info-find-node
2040 "c" gnus-group-fetch-charter
2041 "C" gnus-group-fetch-control)
2043 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2044 "e" gnus-summary-expire-articles
2045 "\M-\C-e" gnus-summary-expire-articles-now
2046 "\177" gnus-summary-delete-article
2047 [delete] gnus-summary-delete-article
2048 [backspace] gnus-summary-delete-article
2049 "m" gnus-summary-move-article
2050 "r" gnus-summary-respool-article
2051 "w" gnus-summary-edit-article
2052 "c" gnus-summary-copy-article
2053 "B" gnus-summary-crosspost-article
2054 "q" gnus-summary-respool-query
2055 "t" gnus-summary-respool-trace
2056 "i" gnus-summary-import-article
2057 "I" gnus-summary-create-article
2058 "p" gnus-summary-article-posted-p)
2060 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2061 "o" gnus-summary-save-article
2062 "m" gnus-summary-save-article-mail
2063 "F" gnus-summary-write-article-file
2064 "r" gnus-summary-save-article-rmail
2065 "f" gnus-summary-save-article-file
2066 "b" gnus-summary-save-article-body-file
2067 "h" gnus-summary-save-article-folder
2068 "v" gnus-summary-save-article-vm
2069 "p" gnus-summary-pipe-output
2070 "P" gnus-summary-muttprint
2071 "s" gnus-soup-add-article)
2073 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2074 "b" gnus-summary-display-buttonized
2075 "m" gnus-summary-repair-multipart
2076 "v" gnus-article-view-part
2077 "o" gnus-article-save-part
2078 "O" gnus-article-save-part-and-strip
2079 "r" gnus-article-replace-part
2080 "d" gnus-article-delete-part
2081 "j" gnus-article-jump-to-part
2082 "c" gnus-article-copy-part
2083 "C" gnus-article-view-part-as-charset
2084 "e" gnus-article-view-part-externally
2085 "E" gnus-article-encrypt-body
2086 "i" gnus-article-inline-part
2087 "|" gnus-article-pipe-part)
2089 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2090 "p" gnus-summary-mark-as-processable
2091 "u" gnus-summary-unmark-as-processable
2092 "U" gnus-summary-unmark-all-processable
2093 "v" gnus-uu-mark-over
2094 "s" gnus-uu-mark-series
2095 "r" gnus-uu-mark-region
2096 "g" gnus-uu-unmark-region
2097 "R" gnus-uu-mark-by-regexp
2098 "G" gnus-uu-unmark-by-regexp
2099 "t" gnus-uu-mark-thread
2100 "T" gnus-uu-unmark-thread
2101 "a" gnus-uu-mark-all
2102 "b" gnus-uu-mark-buffer
2103 "S" gnus-uu-mark-sparse
2104 "k" gnus-summary-kill-process-mark
2105 "y" gnus-summary-yank-process-mark
2106 "w" gnus-summary-save-process-mark
2107 "i" gnus-uu-invert-processable)
2109 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2110 ;;"x" gnus-uu-extract-any
2111 "m" gnus-summary-save-parts
2112 "u" gnus-uu-decode-uu
2113 "U" gnus-uu-decode-uu-and-save
2114 "s" gnus-uu-decode-unshar
2115 "S" gnus-uu-decode-unshar-and-save
2116 "o" gnus-uu-decode-save
2117 "O" gnus-uu-decode-save
2118 "b" gnus-uu-decode-binhex
2119 "B" gnus-uu-decode-binhex
2120 "p" gnus-uu-decode-postscript
2121 "P" gnus-uu-decode-postscript-and-save)
2124 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2125 "u" gnus-uu-decode-uu-view
2126 "U" gnus-uu-decode-uu-and-save-view
2127 "s" gnus-uu-decode-unshar-view
2128 "S" gnus-uu-decode-unshar-and-save-view
2129 "o" gnus-uu-decode-save-view
2130 "O" gnus-uu-decode-save-view
2131 "b" gnus-uu-decode-binhex-view
2132 "B" gnus-uu-decode-binhex-view
2133 "p" gnus-uu-decode-postscript-view
2134 "P" gnus-uu-decode-postscript-and-save-view)
2136 (defvar gnus-article-post-menu nil)
2138 (defconst gnus-summary-menu-maxlen 20)
2140 (defun gnus-summary-menu-split (menu)
2141 ;; If we have lots of elements, divide them into groups of 20
2142 ;; and make a pane (or submenu) for each one.
2143 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2144 (let ((menu menu) sublists next
2147 ;; Pull off the next gnus-summary-menu-maxlen elements
2148 ;; and make them the next element of sublist.
2149 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2151 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2153 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2154 (aref (car (last menu)) 0)) menu)
2158 (nreverse sublists))
2159 ;; Few elements--put them all in one pane.
2162 (defun gnus-summary-make-menu-bar ()
2163 (gnus-turn-off-edit-menu 'summary)
2165 (unless (boundp 'gnus-summary-misc-menu)
2168 gnus-summary-kill-menu gnus-summary-mode-map ""
2173 ["Customize" gnus-score-customize t])
2174 (gnus-make-score-map 'increase)
2175 (gnus-make-score-map 'lower)
2177 ["Kill below" gnus-summary-kill-below t]
2178 ["Mark above" gnus-summary-mark-above t]
2179 ["Tick above" gnus-summary-tick-above t]
2180 ["Clear above" gnus-summary-clear-above t])
2181 ["Current score" gnus-summary-current-score t]
2182 ["Set score" gnus-summary-set-score t]
2183 ["Switch current score file..." gnus-score-change-score-file t]
2184 ["Set mark below..." gnus-score-set-mark-below t]
2185 ["Set expunge below..." gnus-score-set-expunge-below t]
2186 ["Edit current score file" gnus-score-edit-current-scores t]
2187 ["Edit score file" gnus-score-edit-file t]
2188 ["Trace score" gnus-score-find-trace t]
2189 ["Find words" gnus-score-find-favourite-words t]
2190 ["Rescore buffer" gnus-summary-rescore t]
2191 ["Increase score..." gnus-summary-increase-score t]
2192 ["Lower score..." gnus-summary-lower-score t]))))
2194 ;; Define both the Article menu in the summary buffer and the
2195 ;; equivalent Commands menu in the article buffer here for
2199 ["All" gnus-article-hide t]
2200 ["Headers" gnus-article-hide-headers t]
2201 ["Signature" gnus-article-hide-signature t]
2202 ["Citation" gnus-article-hide-citation t]
2203 ["List identifiers" gnus-article-hide-list-identifiers t]
2204 ["Banner" gnus-article-strip-banner t]
2205 ["Boring headers" gnus-article-hide-boring-headers t])
2207 ["All" gnus-article-highlight t]
2208 ["Headers" gnus-article-highlight-headers t]
2209 ["Signature" gnus-article-highlight-signature t]
2210 ["Citation" gnus-article-highlight-citation t])
2212 ["Words" gnus-article-decode-mime-words t]
2213 ["Charset" gnus-article-decode-charset t]
2214 ["QP" gnus-article-de-quoted-unreadable t]
2215 ["Base64" gnus-article-de-base64-unreadable t]
2216 ["View MIME buttons" gnus-summary-display-buttonized t]
2217 ["View all" gnus-mime-view-all-parts t]
2218 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2219 ["Encrypt body" gnus-article-encrypt-body
2220 :active (not (gnus-group-read-only-p))
2221 ,@(if (featurep 'xemacs) nil
2222 '(:help "Encrypt the message body on disk"))]
2223 ["Extract all parts..." gnus-summary-save-parts t]
2225 ["Repair multipart" gnus-summary-repair-multipart t]
2226 ["Pipe part..." gnus-article-pipe-part t]
2227 ["Inline part" gnus-article-inline-part t]
2228 ["Encrypt body" gnus-article-encrypt-body
2229 :active (not (gnus-group-read-only-p))
2230 ,@(if (featurep 'xemacs) nil
2231 '(:help "Encrypt the message body on disk"))]
2232 ["View part externally" gnus-article-view-part-externally t]
2233 ["View part with charset..." gnus-article-view-part-as-charset t]
2234 ["Copy part" gnus-article-copy-part t]
2235 ["Save part..." gnus-article-save-part t]
2236 ["View part" gnus-article-view-part t]))
2238 ["Local" gnus-article-date-local t]
2239 ["ISO8601" gnus-article-date-iso8601 t]
2240 ["UT" gnus-article-date-ut t]
2241 ["Original" gnus-article-date-original t]
2242 ["Lapsed" gnus-article-date-lapsed t]
2243 ["User-defined" gnus-article-date-user t])
2245 ["Remove images" gnus-article-remove-images t]
2246 ["Toggle smiley" gnus-treat-smiley t]
2247 ["Show X-Face" gnus-article-display-x-face t]
2248 ["Show picons in From" gnus-treat-from-picon t]
2249 ["Show picons in mail headers" gnus-treat-mail-picon t]
2250 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2251 ("View as different encoding"
2252 ,@(gnus-summary-menu-split
2255 ;; Since easymenu under Emacs doesn't allow
2256 ;; lambda forms for menu commands, we should
2257 ;; provide intern'ed function symbols.
2258 (let ((command (intern (format "\
2259 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2263 (let ((gnus-summary-show-article-charset-alist
2265 (gnus-summary-show-article 1))))
2266 `[,(symbol-name cs) ,command t]))
2267 (sort (if (fboundp 'coding-system-list)
2268 (coding-system-list)
2269 (mapcar 'car mm-mime-mule-charset-alist))
2273 ["Leading" gnus-article-strip-leading-blank-lines t]
2274 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2275 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2276 ["All of the above" gnus-article-strip-blank-lines t]
2277 ["All" gnus-article-strip-all-blank-lines t]
2278 ["Leading space" gnus-article-strip-leading-space t]
2279 ["Trailing space" gnus-article-strip-trailing-space t]
2280 ["Leading space in headers"
2281 gnus-article-remove-leading-whitespace t])
2282 ["Overstrike" gnus-article-treat-overstrike t]
2283 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2284 ["Emphasis" gnus-article-emphasize t]
2285 ["Word wrap" gnus-article-fill-cited-article t]
2286 ["Fill long lines" gnus-article-fill-long-lines t]
2287 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2288 ["Remove CR" gnus-article-remove-cr t]
2289 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2290 ["Base64" gnus-article-de-base64-unreadable t]
2291 ["Rot 13" gnus-summary-caesar-message
2292 ,@(if (featurep 'xemacs) '(t)
2293 '(:help "\"Caesar rotate\" article by 13"))]
2294 ["De-IDNA" gnus-summary-idna-message t]
2295 ["Morse decode" gnus-summary-morse-message t]
2296 ["Unix pipe..." gnus-summary-pipe-message t]
2297 ["Add buttons" gnus-article-add-buttons t]
2298 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2299 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2300 ["Verbose header" gnus-summary-verbose-headers t]
2301 ["Toggle header" gnus-summary-toggle-header t]
2302 ["Unfold headers" gnus-article-treat-unfold-headers t]
2303 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2304 ["Html" gnus-article-wash-html t]
2305 ["Unsplit URLs" gnus-article-unsplit-urls t]
2306 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2307 ["Decode HZ" gnus-article-decode-HZ t]
2308 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2309 ("(Outlook) Deuglify"
2310 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2311 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2312 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2313 ["Full (Outlook) deuglify"
2314 gnus-article-outlook-deuglify-article t])
2317 ["Save in default format..." gnus-summary-save-article
2318 ,@(if (featurep 'xemacs) '(t)
2319 '(:help "Save article using default method"))]
2320 ["Save in file..." gnus-summary-save-article-file
2321 ,@(if (featurep 'xemacs) '(t)
2322 '(:help "Save article in file"))]
2323 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2324 ["Save in MH folder..." gnus-summary-save-article-folder t]
2325 ["Save in VM folder..." gnus-summary-save-article-vm t]
2326 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2327 ["Save body in file..." gnus-summary-save-article-body-file t]
2328 ["Pipe through a filter..." gnus-summary-pipe-output t]
2329 ["Add to SOUP packet" gnus-soup-add-article t]
2330 ["Print with Muttprint..." gnus-summary-muttprint t]
2331 ["Print" gnus-summary-print-article
2332 ,@(if (featurep 'xemacs) '(t)
2333 '(:help "Generate and print a PostScript image"))])
2334 ("Copy, move,... (Backend)"
2335 ,@(if (featurep 'xemacs) nil
2336 '(:help "Copying, moving, expiring articles..."))
2337 ["Respool article..." gnus-summary-respool-article t]
2338 ["Move article..." gnus-summary-move-article
2339 (gnus-check-backend-function
2340 'request-move-article gnus-newsgroup-name)]
2341 ["Copy article..." gnus-summary-copy-article t]
2342 ["Crosspost article..." gnus-summary-crosspost-article
2343 (gnus-check-backend-function
2344 'request-replace-article gnus-newsgroup-name)]
2345 ["Import file..." gnus-summary-import-article
2346 (gnus-check-backend-function
2347 'request-accept-article gnus-newsgroup-name)]
2348 ["Create article..." gnus-summary-create-article
2349 (gnus-check-backend-function
2350 'request-accept-article gnus-newsgroup-name)]
2351 ["Check if posted" gnus-summary-article-posted-p t]
2352 ["Edit article" gnus-summary-edit-article
2353 (not (gnus-group-read-only-p))]
2354 ["Delete article" gnus-summary-delete-article
2355 (gnus-check-backend-function
2356 'request-expire-articles gnus-newsgroup-name)]
2357 ["Query respool" gnus-summary-respool-query t]
2358 ["Trace respool" gnus-summary-respool-trace t]
2359 ["Delete expirable articles" gnus-summary-expire-articles-now
2360 (gnus-check-backend-function
2361 'request-expire-articles gnus-newsgroup-name)])
2363 ["Uudecode" gnus-uu-decode-uu
2364 ,@(if (featurep 'xemacs) '(t)
2365 '(:help "Decode uuencoded article(s)"))]
2366 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2367 ["Unshar" gnus-uu-decode-unshar t]
2368 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2369 ["Save" gnus-uu-decode-save t]
2370 ["Binhex" gnus-uu-decode-binhex t]
2371 ["Postscript" gnus-uu-decode-postscript t]
2372 ["All MIME parts" gnus-summary-save-parts t])
2374 ["Enter article" gnus-cache-enter-article t]
2375 ["Remove article" gnus-cache-remove-article t])
2376 ["Translate" gnus-article-babel t]
2377 ["Select article buffer" gnus-summary-select-article-buffer t]
2378 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2379 ["Isearch article..." gnus-summary-isearch-article t]
2380 ["Beginning of the article" gnus-summary-beginning-of-article t]
2381 ["End of the article" gnus-summary-end-of-article t]
2382 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2383 ["Fetch referenced articles" gnus-summary-refer-references t]
2384 ["Fetch current thread" gnus-summary-refer-thread t]
2385 ["Fetch article with id..." gnus-summary-refer-article t]
2386 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2387 ["Redisplay" gnus-summary-show-article t]
2388 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2390 gnus-summary-article-menu gnus-summary-mode-map ""
2391 (cons "Article" innards))
2393 (if (not (keymapp gnus-summary-article-menu))
2395 gnus-article-commands-menu gnus-article-mode-map ""
2396 (cons "Commands" innards))
2397 ;; in Emacs, don't share menu.
2398 (setq gnus-article-commands-menu
2399 (copy-keymap gnus-summary-article-menu))
2400 (define-key gnus-article-mode-map [menu-bar commands]
2401 (cons "Commands" gnus-article-commands-menu))))
2404 gnus-summary-thread-menu gnus-summary-mode-map ""
2406 ["Find all messages in thread" gnus-summary-refer-thread t]
2407 ["Toggle threading" gnus-summary-toggle-threads t]
2408 ["Hide threads" gnus-summary-hide-all-threads t]
2409 ["Show threads" gnus-summary-show-all-threads t]
2410 ["Hide thread" gnus-summary-hide-thread t]
2411 ["Show thread" gnus-summary-show-thread t]
2412 ["Go to next thread" gnus-summary-next-thread t]
2413 ["Go to previous thread" gnus-summary-prev-thread t]
2414 ["Go down thread" gnus-summary-down-thread t]
2415 ["Go up thread" gnus-summary-up-thread t]
2416 ["Top of thread" gnus-summary-top-thread t]
2417 ["Mark thread as read" gnus-summary-kill-thread t]
2418 ["Lower thread score" gnus-summary-lower-thread t]
2419 ["Raise thread score" gnus-summary-raise-thread t]
2420 ["Rethread current" gnus-summary-rethread-current t]))
2423 gnus-summary-post-menu gnus-summary-mode-map ""
2425 ["Send a message (mail or news)" gnus-summary-post-news
2426 ,@(if (featurep 'xemacs) '(t)
2427 '(:help "Compose a new message (mail or news)"))]
2428 ["Followup" gnus-summary-followup
2429 ,@(if (featurep 'xemacs) '(t)
2430 '(:help "Post followup to this article"))]
2431 ["Followup and yank" gnus-summary-followup-with-original
2432 ,@(if (featurep 'xemacs) '(t)
2433 '(:help "Post followup to this article, quoting its contents"))]
2434 ["Supersede article" gnus-summary-supersede-article t]
2435 ["Cancel article" gnus-summary-cancel-article
2436 ,@(if (featurep 'xemacs) '(t)
2437 '(:help "Cancel an article you posted"))]
2438 ["Reply" gnus-summary-reply t]
2439 ["Reply and yank" gnus-summary-reply-with-original t]
2440 ["Wide reply" gnus-summary-wide-reply t]
2441 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2442 ,@(if (featurep 'xemacs) '(t)
2443 '(:help "Mail a reply, quoting this article"))]
2444 ["Very wide reply" gnus-summary-very-wide-reply t]
2445 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2446 ,@(if (featurep 'xemacs) '(t)
2447 '(:help "Mail a very wide reply, quoting this article"))]
2448 ["Mail forward" gnus-summary-mail-forward t]
2449 ["Post forward" gnus-summary-post-forward t]
2450 ["Digest and mail" gnus-uu-digest-mail-forward t]
2451 ["Digest and post" gnus-uu-digest-post-forward t]
2452 ["Resend message" gnus-summary-resend-message t]
2453 ["Resend message edit" gnus-summary-resend-message-edit t]
2454 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2455 ["Send a mail" gnus-summary-mail-other-window t]
2456 ["Create a local message" gnus-summary-news-other-window t]
2457 ["Uuencode and post" gnus-uu-post-news
2458 ,@(if (featurep 'xemacs) '(t)
2459 '(:help "Post a uuencoded article"))]
2460 ["Followup via news" gnus-summary-followup-to-mail t]
2461 ["Followup via news and yank"
2462 gnus-summary-followup-to-mail-with-original t]
2464 ;;["Send" gnus-summary-send-draft t]
2465 ;;["Send bounced" gnus-resend-bounced-mail t])
2469 ((not (keymapp gnus-summary-post-menu))
2470 (setq gnus-article-post-menu gnus-summary-post-menu))
2471 ((not gnus-article-post-menu)
2472 ;; Don't share post menu.
2473 (setq gnus-article-post-menu
2474 (copy-keymap gnus-summary-post-menu))))
2475 (define-key gnus-article-mode-map [menu-bar post]
2476 (cons "Post" gnus-article-post-menu))
2479 gnus-summary-misc-menu gnus-summary-mode-map ""
2482 ["Mark as read" gnus-summary-mark-as-read-forward t]
2483 ["Mark same subject and select"
2484 gnus-summary-kill-same-subject-and-select t]
2485 ["Mark same subject" gnus-summary-kill-same-subject t]
2486 ["Catchup" gnus-summary-catchup
2487 ,@(if (featurep 'xemacs) '(t)
2488 '(:help "Mark unread articles in this group as read"))]
2489 ["Catchup all" gnus-summary-catchup-all t]
2490 ["Catchup to here" gnus-summary-catchup-to-here t]
2491 ["Catchup from here" gnus-summary-catchup-from-here t]
2492 ["Catchup region" gnus-summary-mark-region-as-read
2493 (gnus-mark-active-p)]
2494 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2496 ["Tick" gnus-summary-tick-article-forward t]
2497 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2498 ["Remove marks" gnus-summary-clear-mark-forward t]
2499 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2500 ["Set bookmark" gnus-summary-set-bookmark t]
2501 ["Remove bookmark" gnus-summary-remove-bookmark t])
2503 ["Marks..." gnus-summary-limit-to-marks t]
2504 ["Subject..." gnus-summary-limit-to-subject t]
2505 ["Author..." gnus-summary-limit-to-author t]
2506 ["Recipient..." gnus-summary-limit-to-recipient t]
2507 ["Age..." gnus-summary-limit-to-age t]
2508 ["Extra..." gnus-summary-limit-to-extra t]
2509 ["Score..." gnus-summary-limit-to-score t]
2510 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2511 ["Unread" gnus-summary-limit-to-unread t]
2512 ["Unseen" gnus-summary-limit-to-unseen t]
2513 ["Replied" gnus-summary-limit-to-replied t]
2514 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2515 ["Next articles" gnus-summary-limit-to-articles t]
2516 ["Pop limit" gnus-summary-pop-limit t]
2517 ["Show dormant" gnus-summary-limit-include-dormant t]
2518 ["Hide childless dormant"
2519 gnus-summary-limit-exclude-childless-dormant t]
2520 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2521 ["Hide marked" gnus-summary-limit-exclude-marks t]
2522 ["Show expunged" gnus-summary-limit-include-expunged t])
2524 ["Set mark" gnus-summary-mark-as-processable t]
2525 ["Remove mark" gnus-summary-unmark-as-processable t]
2526 ["Remove all marks" gnus-summary-unmark-all-processable t]
2527 ["Invert marks" gnus-uu-invert-processable t]
2528 ["Mark above" gnus-uu-mark-over t]
2529 ["Mark series" gnus-uu-mark-series t]
2530 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2531 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2532 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2533 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2534 ["Mark all" gnus-uu-mark-all t]
2535 ["Mark buffer" gnus-uu-mark-buffer t]
2536 ["Mark sparse" gnus-uu-mark-sparse t]
2537 ["Mark thread" gnus-uu-mark-thread t]
2538 ["Unmark thread" gnus-uu-unmark-thread t]
2539 ("Process Mark Sets"
2540 ["Kill" gnus-summary-kill-process-mark t]
2541 ["Yank" gnus-summary-yank-process-mark
2542 gnus-newsgroup-process-stack]
2543 ["Save" gnus-summary-save-process-mark t]
2544 ["Run command on marked..." gnus-summary-universal-argument t]))
2546 ["Page forward" gnus-summary-next-page
2547 ,@(if (featurep 'xemacs) '(t)
2548 '(:help "Show next page of article"))]
2549 ["Page backward" gnus-summary-prev-page
2550 ,@(if (featurep 'xemacs) '(t)
2551 '(:help "Show previous page of article"))]
2552 ["Line forward" gnus-summary-scroll-up t])
2554 ["Next unread article" gnus-summary-next-unread-article t]
2555 ["Previous unread article" gnus-summary-prev-unread-article t]
2556 ["Next article" gnus-summary-next-article t]
2557 ["Previous article" gnus-summary-prev-article t]
2558 ["Next unread subject" gnus-summary-next-unread-subject t]
2559 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2560 ["Next article same subject" gnus-summary-next-same-subject t]
2561 ["Previous article same subject" gnus-summary-prev-same-subject t]
2562 ["First unread article" gnus-summary-first-unread-article t]
2563 ["Best unread article" gnus-summary-best-unread-article t]
2564 ["Go to subject number..." gnus-summary-goto-subject t]
2565 ["Go to article number..." gnus-summary-goto-article t]
2566 ["Go to the last article" gnus-summary-goto-last-article t]
2567 ["Pop article off history" gnus-summary-pop-article t])
2569 ["Sort by number" gnus-summary-sort-by-number t]
2570 ["Sort by author" gnus-summary-sort-by-author t]
2571 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2572 ["Sort by subject" gnus-summary-sort-by-subject t]
2573 ["Sort by date" gnus-summary-sort-by-date t]
2574 ["Sort by score" gnus-summary-sort-by-score t]
2575 ["Sort by lines" gnus-summary-sort-by-lines t]
2576 ["Sort by characters" gnus-summary-sort-by-chars t]
2577 ["Randomize" gnus-summary-sort-by-random t]
2578 ["Original sort" gnus-summary-sort-by-original t])
2580 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2581 ["Describe group" gnus-summary-describe-group t]
2582 ["Fetch charter" gnus-group-fetch-charter
2583 ,@(if (featurep 'xemacs) nil
2584 '(:help "Display the charter of the current group"))]
2585 ["Fetch control message" gnus-group-fetch-control
2586 ,@(if (featurep 'xemacs) nil
2587 '(:help "Display the archived control message for the current group"))]
2588 ["Read manual" gnus-info-find-node t])
2590 ["Pick and read" gnus-pick-mode t]
2591 ["Binary" gnus-binary-mode t])
2593 ["Regenerate" gnus-summary-prepare t]
2594 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2595 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2596 ["Toggle threading" gnus-summary-toggle-threads t])
2597 ["See old articles" gnus-summary-insert-old-articles t]
2598 ["See new articles" gnus-summary-insert-new-articles t]
2599 ["Filter articles..." gnus-summary-execute-command t]
2600 ["Run command on articles..." gnus-summary-universal-argument t]
2601 ["Search articles forward..." gnus-summary-search-article-forward t]
2602 ["Search articles backward..." gnus-summary-search-article-backward t]
2603 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2604 ["Expand window" gnus-summary-expand-window t]
2605 ["Expire expirable articles" gnus-summary-expire-articles
2606 (gnus-check-backend-function
2607 'request-expire-articles gnus-newsgroup-name)]
2608 ["Edit local kill file" gnus-summary-edit-local-kill t]
2609 ["Edit main kill file" gnus-summary-edit-global-kill t]
2610 ["Edit group parameters" gnus-summary-edit-parameters t]
2611 ["Customize group parameters" gnus-summary-customize-parameters t]
2612 ["Send a bug report" gnus-bug t]
2614 ["Catchup and exit" gnus-summary-catchup-and-exit
2615 ,@(if (featurep 'xemacs) '(t)
2616 '(:help "Mark unread articles in this group as read, then exit"))]
2617 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2618 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2619 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2620 ["Exit group" gnus-summary-exit
2621 ,@(if (featurep 'xemacs) '(t)
2622 '(:help "Exit current group, return to group selection mode"))]
2623 ["Exit group without updating" gnus-summary-exit-no-update t]
2624 ["Exit and goto next group" gnus-summary-next-group t]
2625 ["Exit and goto prev group" gnus-summary-prev-group t]
2626 ["Reselect group" gnus-summary-reselect-current-group t]
2627 ["Rescan group" gnus-summary-rescan-group t]
2628 ["Update dribble" gnus-summary-save-newsrc t])))
2630 (gnus-run-hooks 'gnus-summary-menu-hook)))
2632 (defvar gnus-summary-tool-bar-map nil)
2634 ;; Emacs 21 tool bar. Should be no-op otherwise.
2635 (defun gnus-summary-make-tool-bar ()
2636 (if (and (fboundp 'tool-bar-add-item-from-menu)
2637 (default-value 'tool-bar-mode)
2638 (not gnus-summary-tool-bar-map))
2639 (setq gnus-summary-tool-bar-map
2640 (let ((tool-bar-map (make-sparse-keymap))
2641 (load-path (mm-image-load-path)))
2642 (tool-bar-add-item-from-menu
2643 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2644 (tool-bar-add-item-from-menu
2645 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2646 (tool-bar-add-item-from-menu
2647 'gnus-summary-post-news "post" gnus-summary-mode-map)
2648 (tool-bar-add-item-from-menu
2649 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2650 (tool-bar-add-item-from-menu
2651 'gnus-summary-followup "followup" gnus-summary-mode-map)
2652 (tool-bar-add-item-from-menu
2653 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2654 (tool-bar-add-item-from-menu
2655 'gnus-summary-reply "reply" gnus-summary-mode-map)
2656 (tool-bar-add-item-from-menu
2657 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2658 (tool-bar-add-item-from-menu
2659 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2660 (tool-bar-add-item-from-menu
2661 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2662 (tool-bar-add-item-from-menu
2663 'gnus-summary-save-article "save-art" 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-uu-post-news "uu-post" gnus-summary-mode-map)
2668 (tool-bar-add-item-from-menu
2669 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2670 (tool-bar-add-item-from-menu
2671 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2672 (tool-bar-add-item-from-menu
2673 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2675 (if gnus-summary-tool-bar-map
2676 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2678 (defun gnus-score-set-default (var value)
2679 "A version of set that updates the GNU Emacs menu-bar."
2681 ;; It is the message that forces the active status to be updated.
2684 (defun gnus-make-score-map (type)
2685 "Make a summary score map of type TYPE."
2688 (let ((headers '(("author" "from" string)
2689 ("subject" "subject" string)
2690 ("article body" "body" string)
2691 ("article head" "head" string)
2692 ("xref" "xref" string)
2693 ("extra header" "extra" string)
2694 ("lines" "lines" number)
2695 ("followups to author" "followup" string)))
2696 (types '((number ("less than" <)
2699 (string ("substring" s)
2703 (perms '(("temporary" (current-time-string))
2711 (if (eq type 'lower)
2716 (setq header (car headers))
2722 (let ((ts (cdr (assoc (nth 2 header) types)))
2738 'gnus-summary-score-entry
2740 (if (or (string= (nth 1 header)
2742 (string= (nth 1 header)
2745 (list 'gnus-summary-header
2747 (list 'quote (nth 1 (car ts)))
2748 (list 'gnus-score-delta-default
2755 (list (nreverse outp))))
2758 (list (nreverse outt))))
2760 (setq headers (cdr headers)))
2761 (list (nreverse outh))))))))
2765 (defun gnus-summary-mode (&optional group)
2766 "Major mode for reading articles.
2768 All normal editing commands are switched off.
2769 \\<gnus-summary-mode-map>
2770 Each line in this buffer represents one article. To read an
2771 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2772 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2775 You can also post articles and send mail from this buffer. To
2776 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2777 of an article, type `\\[gnus-summary-reply]'.
2779 There are approx. one gazillion commands you can execute in this
2780 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2782 The following commands are available:
2784 \\{gnus-summary-mode-map}"
2786 (kill-all-local-variables)
2787 (when (gnus-visual-p 'summary-menu 'menu)
2788 (gnus-summary-make-menu-bar)
2789 (gnus-summary-make-tool-bar))
2790 (gnus-summary-make-local-variables)
2791 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2792 (gnus-summary-make-local-variables))
2793 (gnus-make-thread-indent-array)
2794 (gnus-simplify-mode-line)
2795 (setq major-mode 'gnus-summary-mode)
2796 (setq mode-name "Summary")
2797 (make-local-variable 'minor-mode-alist)
2798 (use-local-map gnus-summary-mode-map)
2799 (buffer-disable-undo)
2800 (setq buffer-read-only t ;Disable modification
2801 show-trailing-whitespace nil)
2802 (setq truncate-lines t)
2803 (setq selective-display t)
2804 (setq selective-display-ellipses t) ;Display `...'
2805 (gnus-summary-set-display-table)
2806 (gnus-set-default-directory)
2807 (setq gnus-newsgroup-name group)
2808 (make-local-variable 'gnus-summary-line-format)
2809 (make-local-variable 'gnus-summary-line-format-spec)
2810 (make-local-variable 'gnus-summary-dummy-line-format)
2811 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2812 (make-local-variable 'gnus-summary-mark-positions)
2813 (gnus-make-local-hook 'pre-command-hook)
2814 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2815 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2816 (turn-on-gnus-mailing-list-mode)
2817 (mm-enable-multibyte)
2818 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2819 (gnus-update-summary-mark-positions))
2821 (defun gnus-summary-make-local-variables ()
2822 "Make all the local summary buffer variables."
2824 (dolist (local gnus-summary-local-variables)
2827 (if (eq (cdr local) 'global)
2828 ;; Copy the global value of the variable.
2829 (setq global (symbol-value (car local)))
2830 ;; Use the value from the list.
2831 (setq global (eval (cdr local))))
2832 (set (make-local-variable (car local)) global))
2833 ;; Simple nil-valued local variable.
2834 (set (make-local-variable local) nil)))))
2836 (defun gnus-summary-clear-local-variables ()
2837 (let ((locals gnus-summary-local-variables))
2839 (if (consp (car locals))
2840 (and (symbolp (caar locals))
2841 (set (caar locals) nil))
2842 (and (symbolp (car locals))
2843 (set (car locals) nil)))
2844 (setq locals (cdr locals)))))
2846 ;; Summary data functions.
2848 (defmacro gnus-data-number (data)
2851 (defmacro gnus-data-set-number (data number)
2852 `(setcar ,data ,number))
2854 (defmacro gnus-data-mark (data)
2857 (defmacro gnus-data-set-mark (data mark)
2858 `(setcar (nthcdr 1 ,data) ,mark))
2860 (defmacro gnus-data-pos (data)
2863 (defmacro gnus-data-set-pos (data pos)
2864 `(setcar (nthcdr 2 ,data) ,pos))
2866 (defmacro gnus-data-header (data)
2869 (defmacro gnus-data-set-header (data header)
2870 `(setf (nth 3 ,data) ,header))
2872 (defmacro gnus-data-level (data)
2875 (defmacro gnus-data-unread-p (data)
2876 `(= (nth 1 ,data) gnus-unread-mark))
2878 (defmacro gnus-data-read-p (data)
2879 `(/= (nth 1 ,data) gnus-unread-mark))
2881 (defmacro gnus-data-pseudo-p (data)
2882 `(consp (nth 3 ,data)))
2884 (defmacro gnus-data-find (number)
2885 `(assq ,number gnus-newsgroup-data))
2887 (defmacro gnus-data-find-list (number &optional data)
2888 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2889 (memq (assq ,number bdata)
2892 (defmacro gnus-data-make (number mark pos header level)
2893 `(list ,number ,mark ,pos ,header ,level))
2895 (defun gnus-data-enter (after-article number mark pos header level offset)
2896 (let ((data (gnus-data-find-list after-article)))
2898 (error "No such article: %d" after-article))
2899 (setcdr data (cons (gnus-data-make number mark pos header level)
2901 (setq gnus-newsgroup-data-reverse nil)
2902 (gnus-data-update-list (cddr data) offset)))
2904 (defun gnus-data-enter-list (after-article list &optional offset)
2906 (let ((data (and after-article (gnus-data-find-list after-article)))
2910 (let ((odata gnus-newsgroup-data))
2911 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2913 (gnus-data-update-list odata offset)))
2914 ;; Find the last element in the list to be spliced into the main
2916 (setq list (last list))
2919 (setcdr list gnus-newsgroup-data)
2920 (setq gnus-newsgroup-data ilist)
2922 (gnus-data-update-list (cdr list) offset)))
2923 (setcdr list (cdr data))
2926 (gnus-data-update-list (cdr list) offset))))
2927 (setq gnus-newsgroup-data-reverse nil))))
2929 (defun gnus-data-remove (article &optional offset)
2930 (let ((data gnus-newsgroup-data))
2931 (if (= (gnus-data-number (car data)) article)
2933 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2934 gnus-newsgroup-data-reverse nil)
2936 (gnus-data-update-list gnus-newsgroup-data offset)))
2938 (when (= (gnus-data-number (cadr data)) article)
2939 (setcdr data (cddr data))
2941 (gnus-data-update-list (cdr data) offset))
2943 gnus-newsgroup-data-reverse nil))
2944 (setq data (cdr data))))))
2946 (defmacro gnus-data-list (backward)
2948 (or gnus-newsgroup-data-reverse
2949 (setq gnus-newsgroup-data-reverse
2950 (reverse gnus-newsgroup-data)))
2951 gnus-newsgroup-data))
2953 (defun gnus-data-update-list (data offset)
2954 "Add OFFSET to the POS of all data entries in DATA."
2955 (setq gnus-newsgroup-data-reverse nil)
2957 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2958 (setq data (cdr data))))
2960 (defun gnus-summary-article-pseudo-p (article)
2961 "Say whether this article is a pseudo article or not."
2962 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2964 (defmacro gnus-summary-article-sparse-p (article)
2965 "Say whether this article is a sparse article or not."
2966 `(memq ,article gnus-newsgroup-sparse))
2968 (defmacro gnus-summary-article-ancient-p (article)
2969 "Say whether this article is a sparse article or not."
2970 `(memq ,article gnus-newsgroup-ancient))
2972 (defun gnus-article-parent-p (number)
2973 "Say whether this article is a parent or not."
2974 (let ((data (gnus-data-find-list number)))
2975 (and (cdr data) ; There has to be an article after...
2976 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2977 (gnus-data-level (nth 1 data))))))
2979 (defun gnus-article-children (number)
2980 "Return a list of all children to NUMBER."
2981 (let* ((data (gnus-data-find-list number))
2982 (level (gnus-data-level (car data)))
2984 (setq data (cdr data))
2986 (= (gnus-data-level (car data)) (1+ level)))
2987 (push (gnus-data-number (car data)) children)
2988 (setq data (cdr data)))
2991 (defmacro gnus-summary-skip-intangible ()
2992 "If the current article is intangible, then jump to a different article."
2993 '(let ((to (get-text-property (point) 'gnus-intangible)))
2994 (and to (gnus-summary-goto-subject to))))
2996 (defmacro gnus-summary-article-intangible-p ()
2997 "Say whether this article is intangible or not."
2998 '(get-text-property (point) 'gnus-intangible))
3000 (defun gnus-article-read-p (article)
3001 "Say whether ARTICLE is read or not."
3002 (not (or (memq article gnus-newsgroup-marked)
3003 (memq article gnus-newsgroup-spam-marked)
3004 (memq article gnus-newsgroup-unreads)
3005 (memq article gnus-newsgroup-unselected)
3006 (memq article gnus-newsgroup-dormant))))
3008 ;; Some summary mode macros.
3010 (defmacro gnus-summary-article-number ()
3011 "The article number of the article on the current line.
3012 If there isn't an article number here, then we return the current
3015 (gnus-summary-skip-intangible)
3016 (or (get-text-property (point) 'gnus-number)
3017 (gnus-summary-last-subject))))
3019 (defmacro gnus-summary-article-header (&optional number)
3020 "Return the header of article NUMBER."
3021 `(gnus-data-header (gnus-data-find
3022 ,(or number '(gnus-summary-article-number)))))
3024 (defmacro gnus-summary-thread-level (&optional number)
3025 "Return the level of thread that starts with article NUMBER."
3026 `(if (and (eq gnus-summary-make-false-root 'dummy)
3027 (get-text-property (point) 'gnus-intangible))
3029 (gnus-data-level (gnus-data-find
3030 ,(or number '(gnus-summary-article-number))))))
3032 (defmacro gnus-summary-article-mark (&optional number)
3033 "Return the mark of article NUMBER."
3034 `(gnus-data-mark (gnus-data-find
3035 ,(or number '(gnus-summary-article-number)))))
3037 (defmacro gnus-summary-article-pos (&optional number)
3038 "Return the position of the line of article NUMBER."
3039 `(gnus-data-pos (gnus-data-find
3040 ,(or number '(gnus-summary-article-number)))))
3042 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3043 (defmacro gnus-summary-article-subject (&optional number)
3044 "Return current subject string or nil if nothing."
3047 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3048 '(gnus-data-header (assq (gnus-summary-article-number)
3049 gnus-newsgroup-data)))))
3052 (mail-header-subject headers))))
3054 (defmacro gnus-summary-article-score (&optional number)
3055 "Return current article score."
3056 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3057 gnus-newsgroup-scored))
3058 gnus-summary-default-score 0))
3060 (defun gnus-summary-article-children (&optional number)
3061 "Return a list of article numbers that are children of article NUMBER."
3062 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3063 (level (gnus-data-level (car data)))
3065 (while (and (setq data (cdr data))
3066 (> (setq l (gnus-data-level (car data))) level))
3067 (and (= (1+ level) l)
3068 (push (gnus-data-number (car data))
3070 (nreverse children)))
3072 (defun gnus-summary-article-parent (&optional number)
3073 "Return the article number of the parent of article NUMBER."
3074 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3075 (gnus-data-list t)))
3076 (level (gnus-data-level (car data))))
3078 () ; This is a root.
3079 ;; We search until we find an article with a level less than
3080 ;; this one. That function has to be the parent.
3081 (while (and (setq data (cdr data))
3082 (not (< (gnus-data-level (car data)) level))))
3083 (and data (gnus-data-number (car data))))))
3085 (defun gnus-unread-mark-p (mark)
3086 "Say whether MARK is the unread mark."
3087 (= mark gnus-unread-mark))
3089 (defun gnus-read-mark-p (mark)
3090 "Say whether MARK is one of the marks that mark as read.
3091 This is all marks except unread, ticked, dormant, and expirable."
3092 (not (or (= mark gnus-unread-mark)
3093 (= mark gnus-ticked-mark)
3094 (= mark gnus-spam-mark)
3095 (= mark gnus-dormant-mark)
3096 (= mark gnus-expirable-mark))))
3098 (defmacro gnus-article-mark (number)
3099 "Return the MARK of article NUMBER.
3100 This macro should only be used when computing the mark the \"first\"
3101 time; i.e., when generating the summary lines. After that,
3102 `gnus-summary-article-mark' should be used to examine the
3105 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3106 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3107 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3108 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3109 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3110 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3111 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3112 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3113 gnus-ancient-mark))))
3115 ;; Saving hidden threads.
3117 (defmacro gnus-save-hidden-threads (&rest forms)
3118 "Save hidden threads, eval FORMS, and restore the hidden threads."
3119 (let ((config (make-symbol "config")))
3120 `(let ((,config (gnus-hidden-threads-configuration)))
3124 (gnus-restore-hidden-threads-configuration ,config)))))
3125 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3126 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3128 (defun gnus-data-compute-positions ()
3129 "Compute the positions of all articles."
3130 (setq gnus-newsgroup-data-reverse nil)
3131 (let ((data gnus-newsgroup-data))
3133 (gnus-save-hidden-threads
3134 (gnus-summary-show-all-threads)
3135 (goto-char (point-min))
3137 (while (get-text-property (point) 'gnus-intangible)
3139 (gnus-data-set-pos (car data) (+ (point) 3))
3140 (setq data (cdr data))
3141 (forward-line 1))))))
3143 (defun gnus-hidden-threads-configuration ()
3144 "Return the current hidden threads configuration."
3147 (goto-char (point-min))
3148 (while (search-forward "\r" nil t)
3149 (push (1- (point)) config))
3152 (defun gnus-restore-hidden-threads-configuration (config)
3153 "Restore hidden threads configuration from CONFIG."
3155 (let (point buffer-read-only)
3156 (while (setq point (pop config))
3157 (when (and (< point (point-max))
3159 (eq (char-after) ?\n))
3160 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3162 ;; Various summary mode internalish functions.
3164 (defun gnus-mouse-pick-article (e)
3167 (gnus-summary-next-page nil t))
3169 (defun gnus-summary-set-display-table ()
3170 "Change the display table.
3171 Odd characters have a tendency to mess
3172 up nicely formatted displays - we make all possible glyphs
3173 display only a single character."
3175 ;; We start from the standard display table, if any.
3176 (let ((table (or (copy-sequence standard-display-table)
3177 (make-display-table)))
3179 ;; Nix out all the control chars...
3180 (while (>= (setq i (1- i)) 0)
3181 (aset table i [??]))
3182 ;; ... but not newline and cr, of course. (cr is necessary for the
3183 ;; selective display).
3184 (aset table ?\n nil)
3185 (aset table ?\r nil)
3186 ;; We keep TAB as well.
3187 (aset table ?\t nil)
3188 ;; We nix out any glyphs over 126 that are not set already.
3190 (while (>= (setq i (1- i)) 127)
3191 ;; Only modify if the entry is nil.
3192 (unless (aref table i)
3193 (aset table i [??]))))
3194 (setq buffer-display-table table)))
3196 (defun gnus-summary-set-article-display-arrow (pos)
3197 "Update the overlay arrow to point to line at position POS."
3198 (when (and gnus-summary-display-arrow
3199 (boundp 'overlay-arrow-position)
3200 (boundp 'overlay-arrow-string))
3204 (unless overlay-arrow-position
3205 (setq overlay-arrow-position (make-marker)))
3206 (setq overlay-arrow-string "=>"
3207 overlay-arrow-position (set-marker overlay-arrow-position
3209 (current-buffer))))))
3211 (defun gnus-summary-setup-buffer (group)
3212 "Initialize summary buffer."
3213 (let ((buffer (gnus-summary-buffer-name group))
3214 (dead-name (concat "*Dead Summary "
3215 (gnus-group-decoded-name group) "*")))
3216 ;; If a dead summary buffer exists, we kill it.
3217 (when (gnus-buffer-live-p dead-name)
3218 (gnus-kill-buffer dead-name))
3219 (if (get-buffer buffer)
3222 (setq gnus-summary-buffer (current-buffer))
3223 (not gnus-newsgroup-prepared))
3224 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3225 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3226 (gnus-summary-mode group)
3228 (gnus-carpal-setup-buffer 'summary))
3229 (unless gnus-single-article-buffer
3230 (make-local-variable 'gnus-article-buffer)
3231 (make-local-variable 'gnus-article-current)
3232 (make-local-variable 'gnus-original-article-buffer))
3233 (setq gnus-newsgroup-name group)
3234 ;; Set any local variables in the group parameters.
3235 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3238 (defun gnus-set-global-variables ()
3239 "Set the global equivalents of the buffer-local variables.
3240 They are set to the latest values they had. These reflect the summary
3241 buffer that was in action when the last article was fetched."
3242 (when (eq major-mode 'gnus-summary-mode)
3243 (setq gnus-summary-buffer (current-buffer))
3244 (let ((name gnus-newsgroup-name)
3245 (marked gnus-newsgroup-marked)
3246 (spam gnus-newsgroup-spam-marked)
3247 (unread gnus-newsgroup-unreads)
3248 (headers gnus-current-headers)
3249 (data gnus-newsgroup-data)
3250 (summary gnus-summary-buffer)
3251 (article-buffer gnus-article-buffer)
3252 (original gnus-original-article-buffer)
3253 (gac gnus-article-current)
3254 (reffed gnus-reffed-article-number)
3255 (score-file gnus-current-score-file)
3256 (default-charset gnus-newsgroup-charset)
3258 (let ((locals gnus-newsgroup-variables))
3260 (if (consp (car locals))
3261 (push (eval (caar locals)) vlist)
3262 (push (eval (car locals)) vlist))
3263 (setq locals (cdr locals)))
3264 (setq vlist (nreverse vlist)))
3265 (with-current-buffer gnus-group-buffer
3266 (setq gnus-newsgroup-name name
3267 gnus-newsgroup-marked marked
3268 gnus-newsgroup-spam-marked spam
3269 gnus-newsgroup-unreads unread
3270 gnus-current-headers headers
3271 gnus-newsgroup-data data
3272 gnus-article-current gac
3273 gnus-summary-buffer summary
3274 gnus-article-buffer article-buffer
3275 gnus-original-article-buffer original
3276 gnus-reffed-article-number reffed
3277 gnus-current-score-file score-file
3278 gnus-newsgroup-charset default-charset)
3279 (let ((locals gnus-newsgroup-variables))
3281 (if (consp (car locals))
3282 (set (caar locals) (pop vlist))
3283 (set (car locals) (pop vlist)))
3284 (setq locals (cdr locals))))
3285 ;; The article buffer also has local variables.
3286 (when (gnus-buffer-live-p gnus-article-buffer)
3287 (set-buffer gnus-article-buffer)
3288 (setq gnus-summary-buffer summary))))))
3290 (defun gnus-summary-article-unread-p (article)
3291 "Say whether ARTICLE is unread or not."
3292 (memq article gnus-newsgroup-unreads))
3294 (defun gnus-summary-first-article-p (&optional article)
3295 "Return whether ARTICLE is the first article in the buffer."
3296 (if (not (setq article (or article (gnus-summary-article-number))))
3298 (eq article (caar gnus-newsgroup-data))))
3300 (defun gnus-summary-last-article-p (&optional article)
3301 "Return whether ARTICLE is the last article in the buffer."
3302 (if (not (setq article (or article (gnus-summary-article-number))))
3303 ;; All non-existent numbers are the last article. :-)
3305 (not (cdr (gnus-data-find-list article)))))
3307 (defun gnus-make-thread-indent-array ()
3309 (unless (and gnus-thread-indent-array
3310 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3311 (setq gnus-thread-indent-array (make-vector 201 "")
3312 gnus-thread-indent-array-level gnus-thread-indent-level)
3314 (aset gnus-thread-indent-array n
3315 (make-string (* n gnus-thread-indent-level) ? ))
3318 (defun gnus-update-summary-mark-positions ()
3319 "Compute where the summary marks are to go."
3321 (when (gnus-buffer-exists-p gnus-summary-buffer)
3322 (set-buffer gnus-summary-buffer))
3323 (let ((spec gnus-summary-line-format-spec)
3326 (gnus-set-work-buffer)
3327 (let ((gnus-tmp-unread ?Z)
3328 (gnus-replied-mark ?Z)
3329 (gnus-score-below-mark ?Z)
3330 (gnus-score-over-mark ?Z)
3331 (gnus-undownloaded-mark ?Z)
3332 (gnus-summary-line-format-spec spec)
3333 (gnus-newsgroup-downloadable '(0))
3334 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3335 case-fold-search ignores)
3336 ;; Here, all marks are bound to Z.
3337 (gnus-summary-insert-line header
3338 0 nil t gnus-tmp-unread t nil "" nil 1)
3339 (goto-char (point-min))
3340 ;; Memorize the positions of the same characters as dummy marks.
3341 (while (re-search-forward "[A-D]" nil t)
3342 (push (point) ignores))
3344 ;; We use A-D as dummy marks in order to know column positions
3345 ;; where marks should be inserted.
3346 (setq gnus-tmp-unread ?A
3347 gnus-replied-mark ?B
3348 gnus-score-below-mark ?C
3349 gnus-score-over-mark ?C
3350 gnus-undownloaded-mark ?D)
3351 (gnus-summary-insert-line header
3352 0 nil t gnus-tmp-unread t nil "" nil 1)
3353 ;; Ignore characters which aren't dummy marks.
3355 (delete-region (goto-char (1- p)) p)
3357 (goto-char (point-min))
3358 (setq pos (list (cons 'unread
3359 (and (search-forward "A" nil t)
3360 (- (point) (point-min) 1)))))
3361 (goto-char (point-min))
3362 (push (cons 'replied (and (search-forward "B" nil t)
3363 (- (point) (point-min) 1)))
3365 (goto-char (point-min))
3366 (push (cons 'score (and (search-forward "C" nil t)
3367 (- (point) (point-min) 1)))
3369 (goto-char (point-min))
3370 (push (cons 'download (and (search-forward "D" nil t)
3371 (- (point) (point-min) 1)))
3373 (setq gnus-summary-mark-positions pos))))
3375 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3376 "Insert a dummy root in the summary buffer."
3378 (gnus-add-text-properties
3379 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3380 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3382 (defun gnus-summary-extract-address-component (from)
3383 (or (car (funcall gnus-extract-address-components from))
3386 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3387 (let ((mail-parse-charset gnus-newsgroup-charset)
3388 ; Is it really necessary to do this next part for each summary line?
3389 ; Luckily, doesn't seem to slow things down much.
3390 (mail-parse-ignored-charsets
3391 (with-current-buffer gnus-summary-buffer
3392 gnus-newsgroup-ignored-charsets)))
3394 (and gnus-ignored-from-addresses
3395 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3396 (let ((extra-headers (mail-header-extra header))
3400 ((setq to (cdr (assq 'To extra-headers)))
3401 (concat gnus-summary-to-prefix
3403 (gnus-summary-extract-address-component
3404 (funcall gnus-decode-encoded-word-function to)))))
3405 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3406 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3407 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3409 (defun gnus-summary-insert-line (gnus-tmp-header
3410 gnus-tmp-level gnus-tmp-current
3411 undownloaded gnus-tmp-unread gnus-tmp-replied
3412 gnus-tmp-expirable gnus-tmp-subject-or-nil
3413 &optional gnus-tmp-dummy gnus-tmp-score
3415 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3416 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3417 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3418 (gnus-tmp-score-char
3419 (if (or (null gnus-summary-default-score)
3420 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3421 gnus-summary-zcore-fuzz))
3423 (if (< gnus-tmp-score gnus-summary-default-score)
3424 gnus-score-below-mark gnus-score-over-mark)))
3425 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3427 (cond (gnus-tmp-process gnus-process-mark)
3428 ((memq gnus-tmp-current gnus-newsgroup-cached)
3430 (gnus-tmp-replied gnus-replied-mark)
3431 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3432 gnus-forwarded-mark)
3433 ((memq gnus-tmp-current gnus-newsgroup-saved)
3435 ((memq gnus-tmp-number gnus-newsgroup-recent)
3437 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3440 (gnus-tmp-downloaded
3442 gnus-undownloaded-mark)
3443 (gnus-newsgroup-agentized
3444 gnus-downloaded-mark)
3447 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3450 ((string-match "<[^>]+> *$" gnus-tmp-from)
3451 (let ((beg (match-beginning 0)))
3452 (or (and (string-match "^\".+\"" gnus-tmp-from)
3453 (substring gnus-tmp-from 1 (1- (match-end 0))))
3454 (substring gnus-tmp-from 0 beg))))
3455 ((string-match "(.+)" gnus-tmp-from)
3456 (substring gnus-tmp-from
3457 (1+ (match-beginning 0)) (1- (match-end 0))))
3459 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3460 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3461 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3462 (buffer-read-only nil))
3463 (when (string= gnus-tmp-name "")
3464 (setq gnus-tmp-name gnus-tmp-from))
3465 (unless (numberp gnus-tmp-lines)
3466 (setq gnus-tmp-lines -1))
3467 (if (= gnus-tmp-lines -1)
3468 (setq gnus-tmp-lines "?")
3469 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3470 (gnus-put-text-property
3472 (progn (eval gnus-summary-line-format-spec) (point))
3473 'gnus-number gnus-tmp-number)
3474 (when (gnus-visual-p 'summary-highlight 'highlight)
3476 (gnus-run-hooks 'gnus-summary-update-hook)
3479 (defun gnus-summary-update-line (&optional dont-update)
3480 "Update summary line after change."
3481 (when (and gnus-summary-default-score
3482 (not gnus-summary-inhibit-highlight))
3483 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3484 (article (gnus-summary-article-number))
3485 (score (gnus-summary-article-score article)))
3487 (if (and gnus-summary-mark-below
3488 (< (gnus-summary-article-score)
3489 gnus-summary-mark-below))
3490 ;; This article has a low score, so we mark it as read.
3491 (when (memq article gnus-newsgroup-unreads)
3492 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3493 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3494 ;; This article was previously marked as read on account
3495 ;; of a low score, but now it has risen, so we mark it as
3497 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3498 (gnus-summary-update-mark
3499 (if (or (null gnus-summary-default-score)
3500 (<= (abs (- score gnus-summary-default-score))
3501 gnus-summary-zcore-fuzz))
3503 (if (< score gnus-summary-default-score)
3504 gnus-score-below-mark gnus-score-over-mark))
3506 ;; Do visual highlighting.
3507 (when (gnus-visual-p 'summary-highlight 'highlight)
3508 (gnus-run-hooks 'gnus-summary-update-hook)))))
3510 (defvar gnus-tmp-new-adopts nil)
3512 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3513 "Return the number of articles in THREAD.
3514 This may be 0 in some cases -- if none of the articles in
3515 the thread are to be displayed."
3517 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3519 ((not (listp thread))
3521 ((and (consp thread) (cdr thread))
3524 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3527 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3530 (when (and level (zerop level) gnus-tmp-new-adopts)
3533 'gnus-summary-number-of-articles-in-thread
3534 gnus-tmp-new-adopts))))
3536 (if (> number 1) gnus-not-empty-thread-mark
3537 gnus-empty-thread-mark)
3540 (defsubst gnus-summary-line-message-size (head)
3541 "Return pretty-printed version of message size.
3542 This function is intended to be used in
3543 `gnus-summary-line-format-alist'."
3544 (let ((c (or (mail-header-chars head) -1)))
3545 (cond ((< c 0) "n/a") ; chars not available
3546 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3547 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3548 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3549 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3552 (defun gnus-summary-set-local-parameters (group)
3553 "Go through the local params of GROUP and set all variable specs in that list."
3554 (let ((vars '(quit-config))) ; Ignore quit-config.
3555 (dolist (elem (gnus-group-find-parameter group))
3556 (and (consp elem) ; Has to be a cons.
3557 (consp (cdr elem)) ; The cdr has to be a list.
3558 (symbolp (car elem)) ; Has to be a symbol in there.
3559 (not (memq (car elem) vars))
3560 (ignore-errors ; So we set it.
3561 (push (car elem) vars)
3562 (make-local-variable (car elem))
3563 (set (car elem) (eval (nth 1 elem))))))))
3565 (defun gnus-summary-read-group (group &optional show-all no-article
3566 kill-buffer no-display backward
3568 "Start reading news in newsgroup GROUP.
3569 If SHOW-ALL is non-nil, already read articles are also listed.
3570 If NO-ARTICLE is non-nil, no article is selected initially.
3571 If NO-DISPLAY, don't generate a summary buffer."
3575 (let ((gnus-auto-select-next nil))
3576 (or (gnus-summary-read-group-1
3577 group show-all no-article
3578 kill-buffer no-display
3581 select-articles nil)))))
3582 (eq gnus-auto-select-next 'quietly))
3583 (set-buffer gnus-group-buffer)
3584 ;; The entry function called above goes to the next
3585 ;; group automatically, so we go two groups back
3586 ;; if we are searching for the previous group.
3588 (gnus-group-prev-unread-group 2))
3589 (if (not (equal group (gnus-group-group-name)))
3590 (setq group (gnus-group-group-name))
3594 (defun gnus-summary-read-group-1 (group show-all no-article
3595 kill-buffer no-display
3596 &optional select-articles)
3597 ;; Killed foreign groups can't be entered.
3598 ;; (when (and (not (gnus-group-native-p group))
3599 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3600 ;; (error "Dead non-native groups can't be entered"))
3601 (gnus-message 5 "Retrieving newsgroup: %s..."
3602 (gnus-group-decoded-name group))
3603 (let* ((new-group (gnus-summary-setup-buffer group))
3604 (quit-config (gnus-group-quit-config group))
3605 (did-select (and new-group (gnus-select-newsgroup
3606 group show-all select-articles))))
3608 ;; This summary buffer exists already, so we just select it.
3610 (gnus-set-global-variables)
3612 (gnus-kill-or-deaden-summary kill-buffer))
3613 (gnus-configure-windows 'summary 'force)
3614 (gnus-set-mode-line 'summary)
3615 (gnus-summary-position-point)
3618 ;; We couldn't select this group.
3620 (when (and (eq major-mode 'gnus-summary-mode)
3621 (not (equal (current-buffer) kill-buffer)))
3622 (kill-buffer (current-buffer))
3623 (if (not quit-config)
3625 ;; Update the info -- marks might need to be removed,
3627 (gnus-summary-update-info)
3628 (set-buffer gnus-group-buffer)
3629 (gnus-group-jump-to-group group)
3630 (gnus-group-next-unread-group 1))
3631 (gnus-handle-ephemeral-exit quit-config)))
3632 (let ((grpinfo (gnus-get-info group)))
3633 (if (null (gnus-info-read grpinfo))
3634 (gnus-message 3 "Group %s contains no messages"
3635 (gnus-group-decoded-name group))
3636 (gnus-message 3 "Can't select group")))
3638 ;; The user did a `C-g' while prompting for number of articles,
3639 ;; so we exit this group.
3640 ((eq did-select 'quit)
3641 (and (eq major-mode 'gnus-summary-mode)
3642 (not (equal (current-buffer) kill-buffer))
3643 (kill-buffer (current-buffer)))
3645 (gnus-kill-or-deaden-summary kill-buffer))
3646 (if (not quit-config)
3648 (set-buffer gnus-group-buffer)
3649 (gnus-group-jump-to-group group)
3650 (gnus-group-next-unread-group 1)
3651 (gnus-configure-windows 'group 'force))
3652 (gnus-handle-ephemeral-exit quit-config))
3653 ;; Finally signal the quit.
3655 ;; The group was successfully selected.
3657 (gnus-set-global-variables)
3658 ;; Save the active value in effect when the group was entered.
3659 (setq gnus-newsgroup-active
3661 (gnus-active gnus-newsgroup-name)))
3662 ;; You can change the summary buffer in some way with this hook.
3663 (gnus-run-hooks 'gnus-select-group-hook)
3664 (when (memq 'summary (gnus-update-format-specifications
3665 nil 'summary 'summary-mode 'summary-dummy))
3666 ;; The format specification for the summary line was updated,
3667 ;; so we need to update the mark positions as well.
3668 (gnus-update-summary-mark-positions))
3669 ;; Do score processing.
3670 (when gnus-use-scoring
3671 (gnus-possibly-score-headers))
3672 ;; Check whether to fill in the gaps in the threads.
3673 (when gnus-build-sparse-threads
3674 (gnus-build-sparse-threads))
3675 ;; Find the initial limit.
3677 (let ((gnus-newsgroup-dormant nil))
3678 (gnus-summary-initial-limit show-all))
3679 (gnus-summary-initial-limit show-all))
3680 ;; Generate the summary buffer.
3682 (gnus-summary-prepare))
3683 (when gnus-use-trees
3684 (gnus-tree-open group)
3685 (setq gnus-summary-highlight-line-function
3686 'gnus-tree-highlight-article))
3687 ;; If the summary buffer is empty, but there are some low-scored
3688 ;; articles or some excluded dormants, we include these in the
3690 (when (and (zerop (buffer-size))
3692 (cond (gnus-newsgroup-dormant
3693 (gnus-summary-limit-include-dormant))
3694 ((and gnus-newsgroup-scored show-all)
3695 (gnus-summary-limit-include-expunged t))))
3696 ;; Function `gnus-apply-kill-file' must be called in this hook.
3697 (gnus-run-hooks 'gnus-apply-kill-hook)
3698 (if (and (zerop (buffer-size))
3701 ;; This newsgroup is empty.
3702 (gnus-summary-catchup-and-exit nil t)
3703 (gnus-message 6 "No unread news")
3705 (gnus-kill-or-deaden-summary kill-buffer))
3706 ;; Return nil from this function.
3708 ;; Hide conversation thread subtrees. We cannot do this in
3709 ;; gnus-summary-prepare-hook since kill processing may not
3710 ;; work with hidden articles.
3711 (gnus-summary-maybe-hide-threads)
3713 (gnus-kill-or-deaden-summary kill-buffer))
3714 (gnus-summary-auto-select-subject)
3715 ;; Show first unread article if requested.
3716 (if (and (not no-article)
3718 gnus-newsgroup-unreads
3719 gnus-auto-select-first)
3721 (gnus-configure-windows 'summary)
3722 (let ((art (gnus-summary-article-number)))
3723 (unless (and (not gnus-plugged)
3724 (or (memq art gnus-newsgroup-undownloaded)
3725 (memq art gnus-newsgroup-downloadable)))
3726 (gnus-summary-goto-article art))))
3727 ;; Don't select any articles.
3728 (gnus-summary-position-point)
3729 (gnus-configure-windows 'summary 'force)
3730 (gnus-set-mode-line 'summary))
3731 (when (and gnus-auto-center-group
3732 (get-buffer-window gnus-group-buffer t))
3733 ;; Gotta use windows, because recenter does weird stuff if
3734 ;; the current buffer ain't the displayed window.
3735 (let ((owin (selected-window)))
3736 (select-window (get-buffer-window gnus-group-buffer t))
3737 (when (gnus-group-goto-group group)
3739 (select-window owin)))
3740 ;; Mark this buffer as "prepared".
3741 (setq gnus-newsgroup-prepared t)
3742 (gnus-run-hooks 'gnus-summary-prepared-hook)
3743 (unless (gnus-ephemeral-group-p group)
3744 (gnus-group-update-group group))
3747 (defun gnus-summary-auto-select-subject ()
3748 "Select the subject line on initial group entry."
3749 (goto-char (point-min))
3751 ((eq gnus-auto-select-subject 'best)
3752 (gnus-summary-best-unread-subject))
3753 ((eq gnus-auto-select-subject 'unread)
3754 (gnus-summary-first-unread-subject))
3755 ((eq gnus-auto-select-subject 'unseen)
3756 (gnus-summary-first-unseen-subject))
3757 ((eq gnus-auto-select-subject 'unseen-or-unread)
3758 (gnus-summary-first-unseen-or-unread-subject))
3759 ((eq gnus-auto-select-subject 'first)
3762 ((functionp gnus-auto-select-subject)
3763 (funcall gnus-auto-select-subject))))
3765 (defun gnus-summary-prepare ()
3766 "Generate the summary buffer."
3768 (let ((buffer-read-only nil))
3770 (setq gnus-newsgroup-data nil
3771 gnus-newsgroup-data-reverse nil)
3772 (gnus-run-hooks 'gnus-summary-generate-hook)
3773 ;; Generate the buffer, either with threads or without.
3774 (when gnus-newsgroup-headers
3775 (gnus-summary-prepare-threads
3776 (if gnus-show-threads
3777 (gnus-sort-gathered-threads
3778 (funcall gnus-summary-thread-gathering-function
3780 (gnus-cut-threads (gnus-make-threads)))))
3781 ;; Unthreaded display.
3782 (gnus-sort-articles gnus-newsgroup-headers))))
3783 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3784 ;; Call hooks for modifying summary buffer.
3785 (goto-char (point-min))
3786 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3788 (defsubst gnus-general-simplify-subject (subject)
3789 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3792 ;; Truncate the subject.
3793 (gnus-simplify-subject-functions
3794 (gnus-map-function gnus-simplify-subject-functions subject))
3795 ((numberp gnus-summary-gather-subject-limit)
3796 (setq subject (gnus-simplify-subject-re subject))
3797 (if (> (length subject) gnus-summary-gather-subject-limit)
3798 (substring subject 0 gnus-summary-gather-subject-limit)
3800 ;; Fuzzily simplify it.
3801 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3802 (gnus-simplify-subject-fuzzy subject))
3803 ;; Just remove the leading "Re:".
3805 (gnus-simplify-subject-re subject))))
3807 (if (and gnus-summary-gather-exclude-subject
3808 (string-match gnus-summary-gather-exclude-subject subject))
3809 nil ; This article shouldn't be gathered
3812 (defun gnus-summary-simplify-subject-query ()
3813 "Query where the respool algorithm would put this article."
3815 (gnus-summary-select-article)
3816 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3818 (defun gnus-gather-threads-by-subject (threads)
3819 "Gather threads by looking at Subject headers."
3820 (if (not gnus-summary-make-false-root)
3822 (let ((hashtb (gnus-make-hashtable 1024))
3825 subject hthread whole-subject)
3827 (setq subject (gnus-general-simplify-subject
3828 (setq whole-subject (mail-header-subject
3831 (if (setq hthread (gnus-gethash subject hashtb))
3833 ;; We enter a dummy root into the thread, if we
3834 ;; haven't done that already.
3835 (unless (stringp (caar hthread))
3836 (setcar hthread (list whole-subject (car hthread))))
3837 ;; We add this new gathered thread to this gathered
3839 (setcdr (car hthread)
3840 (nconc (cdar hthread) (list (car threads))))
3841 ;; Remove it from the list of threads.
3842 (setcdr prev (cdr threads))
3843 (setq threads prev))
3844 ;; Enter this thread into the hash table.
3845 (gnus-sethash subject
3846 (if gnus-summary-make-false-root-always
3848 ;; If you want a dummy root above all
3850 (setcar threads (list whole-subject
3856 (setq threads (cdr threads)))
3859 (defun gnus-gather-threads-by-references (threads)
3860 "Gather threads by looking at References headers."
3861 (let ((idhashtb (gnus-make-hashtable 1024))
3862 (thhashtb (gnus-make-hashtable 1024))
3865 ids references id gthread gid entered ref)
3867 (when (setq references (mail-header-references (caar threads)))
3868 (setq id (mail-header-id (caar threads))
3869 ids (inline (gnus-split-references references))
3871 (while (setq ref (pop ids))
3872 (setq ids (delete ref ids))
3873 (if (not (setq gid (gnus-gethash ref idhashtb)))
3875 (gnus-sethash ref id idhashtb)
3876 (gnus-sethash id threads thhashtb))
3877 (setq gthread (gnus-gethash gid thhashtb))
3879 ;; We enter a dummy root into the thread, if we
3880 ;; haven't done that already.
3881 (unless (stringp (caar gthread))
3882 (setcar gthread (list (mail-header-subject (caar gthread))
3884 ;; We add this new gathered thread to this gathered
3886 (setcdr (car gthread)
3887 (nconc (cdar gthread) (list (car threads)))))
3888 ;; Add it into the thread hash table.
3889 (gnus-sethash id gthread thhashtb)
3891 ;; Remove it from the list of threads.
3892 (setcdr prev (cdr threads))
3893 (setq threads prev))))
3895 (setq threads (cdr threads)))
3898 (defun gnus-sort-gathered-threads (threads)
3899 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3900 (let ((result threads))
3902 (when (stringp (caar threads))
3903 (setcdr (car threads)
3904 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3905 (setq threads (cdr threads)))
3908 (defun gnus-thread-loop-p (root thread)
3909 "Say whether ROOT is in THREAD."
3910 (let ((stack (list thread))
3913 (while (setq thread (pop stack))
3914 (setq th (cdr thread))
3916 (not (eq (caar th) root)))
3919 ;; We have found a loop.
3921 (setcdr thread (delq (car th) (cdr thread)))
3922 (if (boundp (setq ref-dep (intern "none"
3923 gnus-newsgroup-dependencies)))
3924 (setcdr (symbol-value ref-dep)
3925 (nconc (cdr (symbol-value ref-dep))
3927 (set ref-dep (list nil (car th))))
3930 ;; Push all the subthreads onto the stack.
3931 (push (cdr thread) stack)))
3934 (defun gnus-make-threads ()
3935 "Go through the dependency hashtb and find the roots. Return all threads."
3937 (while (catch 'infloop
3940 ;; Deal with self-referencing References loops.
3941 (when (and (car (symbol-value refs))
3948 (car (symbol-value refs)) thread))
3949 (cdr (symbol-value refs)))))))
3952 (unless (car (symbol-value refs))
3953 ;; These threads do not refer back to any other
3954 ;; articles, so they're roots.
3955 (setq threads (append (cdr (symbol-value refs)) threads))))
3956 gnus-newsgroup-dependencies)))
3959 ;; Build the thread tree.
3960 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3961 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3963 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3964 if it was already present.
3966 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3967 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3968 Message-IDs will be renamed to a unique Message-ID before being
3971 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3972 (let* ((id (mail-header-id header))
3973 (id-dep (and id (intern id dependencies)))
3974 parent-id ref ref-dep ref-header replaced)
3975 ;; Enter this `header' in the `dependencies' table.
3979 ;; The first two cases do the normal part: enter a new `header'
3980 ;; in the `dependencies' table.
3981 ((not (boundp id-dep))
3982 (set id-dep (list header)))
3983 ((null (car (symbol-value id-dep)))
3984 (setcar (symbol-value id-dep) header))
3986 ;; From here the `header' was already present in the
3987 ;; `dependencies' table.
3989 ;; Overrides an existing entry;
3990 ;; just set the header part of the entry.
3991 (setcar (symbol-value id-dep) header)
3994 ;; Renames the existing `header' to a unique Message-ID.
3995 ((not gnus-summary-ignore-duplicates)
3996 ;; An article with this Message-ID has already been seen.
3997 ;; We rename the Message-ID.
3998 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4000 (mail-header-set-id header id))
4002 ;; The last case ignores an existing entry, except it adds any
4003 ;; additional Xrefs (in case the two articles came from different
4005 ;; Also sets `header' to `nil' meaning that the `dependencies'
4006 ;; table was *not* modified.
4008 (mail-header-set-xref
4009 (car (symbol-value id-dep))
4010 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4012 (or (mail-header-xref header) "")))
4015 (when (and header (not replaced))
4016 ;; First check that we are not creating a References loop.
4017 (setq parent-id (gnus-parent-id (mail-header-references header)))
4018 (setq ref parent-id)
4020 (setq ref-dep (intern-soft ref dependencies))
4022 (setq ref-header (car (symbol-value ref-dep))))
4023 (if (string= id ref)
4024 ;; Yuk! This is a reference loop. Make the article be a
4027 (mail-header-set-references (car (symbol-value id-dep)) "none")
4029 (setq parent-id nil))
4030 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4031 (setq ref-dep (intern (or parent-id "none") dependencies))
4032 (if (boundp ref-dep)
4033 (setcdr (symbol-value ref-dep)
4034 (nconc (cdr (symbol-value ref-dep))
4035 (list (symbol-value id-dep))))
4036 (set ref-dep (list nil (symbol-value id-dep)))))
4039 (defun gnus-extract-message-id-from-in-reply-to (string)
4040 (if (string-match "<[^>]+>" string)
4041 (substring string (match-beginning 0) (match-end 0))
4044 (defun gnus-build-sparse-threads ()
4045 (let ((headers gnus-newsgroup-headers)
4046 (mail-parse-charset gnus-newsgroup-charset)
4047 (gnus-summary-ignore-duplicates t)
4048 header references generation relations
4049 subject child end new-child date)
4050 ;; First we create an alist of generations/relations, where
4051 ;; generations is how much we trust the relation, and the relation
4053 (gnus-message 7 "Making sparse threads...")
4055 (nnheader-set-temp-buffer " *gnus sparse threads*")
4056 (while (setq header (pop headers))
4057 (when (and (setq references (mail-header-references header))
4058 (not (string= references "")))
4060 (setq child (mail-header-id header)
4061 subject (mail-header-subject header)
4062 date (mail-header-date header)
4064 (while (search-backward ">" nil t)
4065 (setq end (1+ (point)))
4066 (when (search-backward "<" nil t)
4067 (setq new-child (buffer-substring (point) end))
4068 (push (list (incf generation)
4069 child (setq child new-child)
4073 (push (list (1+ generation) child nil subject) relations))
4075 (kill-buffer (current-buffer)))
4076 ;; Sort over trustworthiness.
4079 (when (gnus-dependencies-add-header
4080 (make-full-mail-header
4081 gnus-reffed-article-number
4082 (nth 3 relation) "" (or (nth 4 relation) "")
4084 (or (nth 2 relation) "") 0 0 "")
4085 gnus-newsgroup-dependencies nil)
4086 (push gnus-reffed-article-number gnus-newsgroup-limit)
4087 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4088 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4089 gnus-newsgroup-reads)
4090 (decf gnus-reffed-article-number)))
4091 (sort relations 'car-less-than-car))
4092 (gnus-message 7 "Making sparse threads...done")))
4094 (defun gnus-build-old-threads ()
4095 ;; Look at all the articles that refer back to old articles, and
4096 ;; fetch the headers for the articles that aren't there. This will
4097 ;; build complete threads - if the roots haven't been expired by the
4099 (let ((mail-parse-charset gnus-newsgroup-charset)
4103 (when (not (car (symbol-value refs)))
4104 (setq heads (cdr (symbol-value refs)))
4106 (if (memq (mail-header-number (caar heads))
4107 gnus-newsgroup-dormant)
4108 (setq heads (cdr heads))
4109 (setq id (symbol-name refs))
4110 (while (and (setq id (gnus-build-get-header id))
4111 (not (car (gnus-id-to-thread id)))))
4112 (setq heads nil)))))
4113 gnus-newsgroup-dependencies)))
4115 (defsubst gnus-remove-odd-characters (string)
4116 "Translate STRING into something that doesn't contain weird characters."
4117 (mm-subst-char-in-string
4119 (mm-subst-char-in-string ?\n ?\- string t) t))
4121 ;; This function has to be called with point after the article number
4122 ;; on the beginning of the line.
4123 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4124 (let ((eol (point-at-eol))
4125 (buffer (current-buffer))
4126 header references in-reply-to)
4128 ;; overview: [num subject from date id refs chars lines misc]
4131 (narrow-to-region (point) eol)
4136 (make-full-mail-header
4138 (condition-case () ; subject
4139 (gnus-remove-odd-characters
4140 (funcall gnus-decode-encoded-word-function
4141 (setq x (nnheader-nov-field))))
4143 (condition-case () ; from
4144 (gnus-remove-odd-characters
4145 (funcall gnus-decode-encoded-word-function
4146 (setq x (nnheader-nov-field))))
4148 (nnheader-nov-field) ; date
4149 (nnheader-nov-read-message-id number) ; id
4150 (setq references (nnheader-nov-field)) ; refs
4151 (nnheader-nov-read-integer) ; chars
4152 (nnheader-nov-read-integer) ; lines
4154 (if (looking-at "Xref: ")
4155 (goto-char (match-end 0)))
4156 (nnheader-nov-field)) ; Xref
4157 (nnheader-nov-parse-extra)))) ; extra
4161 (when (and (string= references "")
4162 (setq in-reply-to (mail-header-extra header))
4163 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4164 (mail-header-set-references
4165 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4167 (when gnus-alter-header-function
4168 (funcall gnus-alter-header-function header))
4169 (gnus-dependencies-add-header header dependencies force-new)))
4171 (defun gnus-build-get-header (id)
4172 "Look through the buffer of NOV lines and find the header to ID.
4173 Enter this line into the dependencies hash table, and return
4174 the id of the parent article (if any)."
4175 (let ((deps gnus-newsgroup-dependencies)
4179 (set-buffer nntp-server-buffer)
4180 (let ((case-fold-search nil))
4181 (goto-char (point-min))
4182 (while (and (not found)
4183 (search-forward id nil t))
4185 (setq found (looking-at
4186 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4187 (regexp-quote id))))
4188 (or found (beginning-of-line 2)))
4192 (setq header (gnus-nov-parse-line
4193 (read (current-buffer)) deps))
4194 (gnus-parent-id (mail-header-references header))))))
4196 (let ((number (mail-header-number header)))
4197 (push number gnus-newsgroup-limit)
4198 (push header gnus-newsgroup-headers)
4199 (if (memq number gnus-newsgroup-unselected)
4201 (setq gnus-newsgroup-unreads
4202 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4204 (setq gnus-newsgroup-unselected
4205 (delq number gnus-newsgroup-unselected)))
4206 (push number gnus-newsgroup-ancient)))))))
4208 (defun gnus-build-all-threads ()
4209 "Read all the headers."
4210 (let ((gnus-summary-ignore-duplicates t)
4211 (mail-parse-charset gnus-newsgroup-charset)
4212 (dependencies gnus-newsgroup-dependencies)
4215 (set-buffer nntp-server-buffer)
4216 (let ((case-fold-search nil))
4217 (goto-char (point-min))
4220 (setq article (read (current-buffer))
4221 header (gnus-nov-parse-line article dependencies)))
4223 (with-current-buffer gnus-summary-buffer
4224 (push header gnus-newsgroup-headers)
4225 (if (memq (setq article (mail-header-number header))
4226 gnus-newsgroup-unselected)
4228 (setq gnus-newsgroup-unreads
4229 (gnus-add-to-sorted-list
4230 gnus-newsgroup-unreads article))
4231 (setq gnus-newsgroup-unselected
4232 (delq article gnus-newsgroup-unselected)))
4233 (push article gnus-newsgroup-ancient)))
4234 (forward-line 1)))))))
4236 (defun gnus-summary-update-article-line (article header)
4237 "Update the line for ARTICLE using HEADER."
4238 (let* ((id (mail-header-id header))
4239 (thread (gnus-id-to-thread id)))
4241 (error "Article in no thread"))
4242 ;; Update the thread.
4243 (setcar thread header)
4244 (gnus-summary-goto-subject article)
4245 (let* ((datal (gnus-data-find-list article))
4247 (buffer-read-only nil)
4248 (level (gnus-summary-thread-level)))
4250 (let ((inserted (- (point)
4252 (gnus-summary-insert-line
4254 (memq article gnus-newsgroup-undownloaded)
4255 (gnus-article-mark article)
4256 (memq article gnus-newsgroup-replied)
4257 (memq article gnus-newsgroup-expirable)
4258 ;; Only insert the Subject string when it's different
4259 ;; from the previous Subject string.
4264 (mail-header-subject
4267 (gnus-data-find-list
4269 (gnus-data-list t)))))
4270 ;; Error on the side of excessive subjects.
4272 (mail-header-subject header)))
4274 (mail-header-subject header))
4275 nil (cdr (assq article gnus-newsgroup-scored))
4276 (memq article gnus-newsgroup-processable))
4279 (gnus-data-update-list
4281 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4283 (defun gnus-summary-update-article (article &optional iheader)
4284 "Update ARTICLE in the summary buffer."
4285 (set-buffer gnus-summary-buffer)
4286 (let* ((header (gnus-summary-article-header article))
4287 (id (mail-header-id header))
4288 (data (gnus-data-find article))
4289 (thread (gnus-id-to-thread id))
4290 (references (mail-header-references header))
4294 (when (and references
4295 (not (equal "" references)))
4298 (buffer-read-only nil)
4304 (delq thread parent)))
4305 (if (gnus-summary-insert-subject id header)
4306 ;; Set the (possibly) new article number in the data structure.
4307 (gnus-data-set-number data (gnus-id-to-article id))
4311 (defun gnus-rebuild-thread (id &optional line)
4312 "Rebuild the thread containing ID.
4313 If LINE, insert the rebuilt thread starting on line LINE."
4314 (let ((buffer-read-only nil)
4315 old-pos current thread data)
4316 (if (not gnus-show-threads)
4317 (setq thread (list (car (gnus-id-to-thread id))))
4318 ;; Get the thread this article is part of.
4319 (setq thread (gnus-remove-thread id)))
4320 (setq old-pos (point-at-bol))
4321 (setq current (save-excursion
4322 (and (re-search-backward "[\r\n]" nil t)
4323 (gnus-summary-article-number))))
4324 ;; If this is a gathered thread, we have to go some re-gathering.
4325 (when (stringp (car thread))
4326 (let ((subject (car thread))
4328 (setq thread (cdr thread))
4330 (unless (memq (setq thr (gnus-id-to-thread
4332 (mail-header-id (caar thread)))))
4335 (setq thread (cdr thread)))
4336 ;; We now have all (unique) roots.
4337 (if (= (length roots) 1)
4338 ;; All the loose roots are now one solid root.
4339 (setq thread (car roots))
4340 (setq thread (cons subject (gnus-sort-threads roots))))))
4342 ;; We then insert this thread into the summary buffer.
4344 (goto-char (point-min))
4345 (forward-line (1- line)))
4346 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4347 (if gnus-show-threads
4348 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4349 (gnus-summary-prepare-unthreaded thread))
4350 (setq data (nreverse gnus-newsgroup-data))
4351 (setq threads gnus-newsgroup-threads))
4352 ;; We splice the new data into the data structure.
4353 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4354 ;;!!! then we want to insert at the beginning of the buffer.
4355 ;;!!! That happens to be true with Gnus now, but that may
4356 ;;!!! change in the future. Perhaps.
4357 (gnus-data-enter-list
4358 (if line nil current) data (- (point) old-pos))
4359 (setq gnus-newsgroup-threads
4360 (nconc threads gnus-newsgroup-threads))
4361 (gnus-data-compute-positions))))
4363 (defun gnus-number-to-header (number)
4364 "Return the header for article NUMBER."
4365 (let ((headers gnus-newsgroup-headers))
4367 (not (= number (mail-header-number (car headers)))))
4372 (defun gnus-parent-headers (in-headers &optional generation)
4373 "Return the headers of the GENERATIONeth parent of HEADERS."
4375 (setq generation 1))
4377 (headers in-headers)
4380 (not (zerop generation))
4381 (setq references (mail-header-references headers)))
4382 (setq headers (if (and references
4383 (setq parent (gnus-parent-id references)))
4384 (car (gnus-id-to-thread parent))
4387 (and (not (eq headers in-headers))
4390 (defun gnus-id-to-thread (id)
4391 "Return the (sub-)thread where ID appears."
4392 (gnus-gethash id gnus-newsgroup-dependencies))
4394 (defun gnus-id-to-article (id)
4395 "Return the article number of ID."
4396 (let ((thread (gnus-id-to-thread id)))
4399 (mail-header-number (car thread)))))
4401 (defun gnus-id-to-header (id)
4402 "Return the article headers of ID."
4403 (car (gnus-id-to-thread id)))
4405 (defun gnus-article-displayed-root-p (article)
4406 "Say whether ARTICLE is a root(ish) article."
4407 (let ((level (gnus-summary-thread-level article))
4408 (refs (mail-header-references (gnus-summary-article-header article)))
4414 ((null (gnus-parent-id refs)) t)
4416 (null (setq particle (gnus-id-to-article
4417 (gnus-parent-id refs))))
4418 (null (gnus-summary-thread-level particle)))))))
4420 (defun gnus-root-id (id)
4421 "Return the id of the root of the thread where ID appears."
4423 (while (and id (setq prev (car (gnus-id-to-thread id))))
4425 id (gnus-parent-id (mail-header-references prev))))
4428 (defun gnus-articles-in-thread (thread)
4429 "Return the list of articles in THREAD."
4430 (cons (mail-header-number (car thread))
4431 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4433 (defun gnus-remove-thread (id &optional dont-remove)
4434 "Remove the thread that has ID in it."
4435 (let (headers thread last-id)
4436 ;; First go up in this thread until we find the root.
4437 (setq last-id (gnus-root-id id)
4438 headers (message-flatten-list (gnus-id-to-thread last-id)))
4439 ;; We have now found the real root of this thread. It might have
4440 ;; been gathered into some loose thread, so we have to search
4441 ;; through the threads to find the thread we wanted.
4442 (let ((threads gnus-newsgroup-threads)
4445 (setq sub (car threads))
4446 (if (stringp (car sub))
4447 ;; This is a gathered thread, so we look at the roots
4448 ;; below it to find whether this article is in this
4451 (setq sub (cdr sub))
4453 (when (member (caar sub) headers)
4454 (setq thread (car threads)
4457 (setq sub (cdr sub))))
4458 ;; It's an ordinary thread, so we check it.
4459 (when (eq (car sub) (car headers))
4462 (setq threads (cdr threads)))
4463 ;; If this article is in no thread, then it's a root.
4466 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4467 (setq thread (gnus-id-to-thread last-id)))
4470 thread ; We return this thread.
4472 (if (stringp (car thread))
4474 ;; If we use dummy roots, then we have to remove the
4475 ;; dummy root as well.
4476 (when (eq gnus-summary-make-false-root 'dummy)
4477 ;; We go to the dummy root by going to
4478 ;; the first sub-"thread", and then one line up.
4479 (gnus-summary-goto-article
4480 (mail-header-number (caadr thread)))
4483 (gnus-data-compute-positions))
4484 (setq thread (cdr thread))
4486 (gnus-remove-thread-1 (car thread))
4487 (setq thread (cdr thread))))
4488 (gnus-remove-thread-1 thread))))))))
4490 (defun gnus-remove-thread-1 (thread)
4491 "Remove the thread THREAD recursively."
4492 (let ((number (mail-header-number (pop thread)))
4494 (setq thread (reverse thread))
4496 (gnus-remove-thread-1 (pop thread)))
4497 (when (setq d (gnus-data-find number))
4498 (goto-char (gnus-data-pos d))
4499 (gnus-summary-show-thread)
4505 (gnus-delete-line)))))))
4507 (defun gnus-sort-threads-1 (threads func)
4508 (sort (mapcar (lambda (thread)
4511 (gnus-sort-threads-1 (cdr thread) func))))
4514 (defun gnus-sort-threads (threads)
4516 (if (not gnus-thread-sort-functions)
4518 (gnus-message 8 "Sorting threads...")
4519 (let ((max-lisp-eval-depth 5000))
4520 (prog1 (gnus-sort-threads-1
4522 (gnus-make-sort-function gnus-thread-sort-functions))
4523 (gnus-message 8 "Sorting threads...done")))))
4525 (defun gnus-sort-articles (articles)
4527 (when gnus-article-sort-functions
4528 (gnus-message 7 "Sorting articles...")
4530 (setq gnus-newsgroup-headers
4531 (sort articles (gnus-make-sort-function
4532 gnus-article-sort-functions)))
4533 (gnus-message 7 "Sorting articles...done"))))
4535 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4536 (defmacro gnus-thread-header (thread)
4537 "Return header of first article in THREAD.
4538 Note that THREAD must never, ever be anything else than a variable -
4539 using some other form will lead to serious barfage."
4540 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4541 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4542 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4545 (defsubst gnus-article-sort-by-number (h1 h2)
4546 "Sort articles by article number."
4547 (< (mail-header-number h1)
4548 (mail-header-number h2)))
4550 (defun gnus-thread-sort-by-number (h1 h2)
4551 "Sort threads by root article number."
4552 (gnus-article-sort-by-number
4553 (gnus-thread-header h1) (gnus-thread-header h2)))
4555 (defsubst gnus-article-sort-by-random (h1 h2)
4556 "Sort articles by article number."
4559 (defun gnus-thread-sort-by-random (h1 h2)
4560 "Sort threads by root article number."
4561 (gnus-article-sort-by-random
4562 (gnus-thread-header h1) (gnus-thread-header h2)))
4564 (defsubst gnus-article-sort-by-lines (h1 h2)
4565 "Sort articles by article Lines header."
4566 (< (mail-header-lines h1)
4567 (mail-header-lines h2)))
4569 (defun gnus-thread-sort-by-lines (h1 h2)
4570 "Sort threads by root article Lines header."
4571 (gnus-article-sort-by-lines
4572 (gnus-thread-header h1) (gnus-thread-header h2)))
4574 (defsubst gnus-article-sort-by-chars (h1 h2)
4575 "Sort articles by octet length."
4576 (< (mail-header-chars h1)
4577 (mail-header-chars h2)))
4579 (defun gnus-thread-sort-by-chars (h1 h2)
4580 "Sort threads by root article octet length."
4581 (gnus-article-sort-by-chars
4582 (gnus-thread-header h1) (gnus-thread-header h2)))
4584 (defsubst gnus-article-sort-by-author (h1 h2)
4585 "Sort articles by root author."
4587 (let ((extract (funcall
4588 gnus-extract-address-components
4589 (mail-header-from h1))))
4590 (or (car extract) (cadr extract) ""))
4591 (let ((extract (funcall
4592 gnus-extract-address-components
4593 (mail-header-from h2))))
4594 (or (car extract) (cadr extract) ""))))
4596 (defun gnus-thread-sort-by-author (h1 h2)
4597 "Sort threads by root author."
4598 (gnus-article-sort-by-author
4599 (gnus-thread-header h1) (gnus-thread-header h2)))
4601 (defsubst gnus-article-sort-by-recipient (h1 h2)
4602 "Sort articles by recipient."
4604 (let ((extract (funcall
4605 gnus-extract-address-components
4606 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4607 (or (car extract) (cadr extract)))
4608 (let ((extract (funcall
4609 gnus-extract-address-components
4610 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4611 (or (car extract) (cadr extract)))))
4613 (defun gnus-thread-sort-by-recipient (h1 h2)
4614 "Sort threads by root recipient."
4615 (gnus-article-sort-by-recipient
4616 (gnus-thread-header h1) (gnus-thread-header h2)))
4618 (defsubst gnus-article-sort-by-subject (h1 h2)
4619 "Sort articles by root subject."
4621 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4622 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4624 (defun gnus-thread-sort-by-subject (h1 h2)
4625 "Sort threads by root subject."
4626 (gnus-article-sort-by-subject
4627 (gnus-thread-header h1) (gnus-thread-header h2)))
4629 (defsubst gnus-article-sort-by-date (h1 h2)
4630 "Sort articles by root article date."
4632 (gnus-date-get-time (mail-header-date h1))
4633 (gnus-date-get-time (mail-header-date h2))))
4635 (defun gnus-thread-sort-by-date (h1 h2)
4636 "Sort threads by root article date."
4637 (gnus-article-sort-by-date
4638 (gnus-thread-header h1) (gnus-thread-header h2)))
4640 (defsubst gnus-article-sort-by-score (h1 h2)
4641 "Sort articles by root article score.
4642 Unscored articles will be counted as having a score of zero."
4643 (> (or (cdr (assq (mail-header-number h1)
4644 gnus-newsgroup-scored))
4645 gnus-summary-default-score 0)
4646 (or (cdr (assq (mail-header-number h2)
4647 gnus-newsgroup-scored))
4648 gnus-summary-default-score 0)))
4650 (defun gnus-thread-sort-by-score (h1 h2)
4651 "Sort threads by root article score."
4652 (gnus-article-sort-by-score
4653 (gnus-thread-header h1) (gnus-thread-header h2)))
4655 (defun gnus-thread-sort-by-total-score (h1 h2)
4656 "Sort threads by the sum of all scores in the thread.
4657 Unscored articles will be counted as having a score of zero."
4658 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4660 (defun gnus-thread-total-score (thread)
4661 ;; This function find the total score of THREAD.
4666 (if (stringp (car thread))
4667 (apply gnus-thread-score-function 0
4668 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4669 (gnus-thread-total-score-1 thread)))
4671 (gnus-thread-total-score-1 (list thread)))))
4673 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4674 "Sort threads such that the thread with the most recently arrived article comes first."
4675 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4677 (defun gnus-thread-highest-number (thread)
4678 "Return the highest article number in THREAD."
4679 (apply 'max (mapcar (lambda (header)
4680 (mail-header-number header))
4681 (message-flatten-list thread))))
4683 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4684 "Sort threads such that the thread with the most recently dated article comes first."
4685 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4687 (defun gnus-thread-latest-date (thread)
4688 "Return the highest article date in THREAD."
4689 (let ((previous-time 0))
4695 (time-to-seconds (mail-header-parse-date
4696 (mail-header-date header)))
4697 (error previous-time))))
4699 (message-flatten-list thread)
4701 (< (mail-header-number h1)
4702 (mail-header-number h2))))))))
4704 (defun gnus-thread-total-score-1 (root)
4705 ;; This function find the total score of the thread below ROOT.
4706 (setq root (car root))
4707 (apply gnus-thread-score-function
4709 (mapcar 'gnus-thread-total-score
4710 (cdr (gnus-id-to-thread (mail-header-id root))))
4711 (when (> (mail-header-number root) 0)
4712 (list (or (cdr (assq (mail-header-number root)
4713 gnus-newsgroup-scored))
4714 gnus-summary-default-score 0))))
4715 (list gnus-summary-default-score)
4718 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4719 (defvar gnus-tmp-prev-subject nil)
4720 (defvar gnus-tmp-false-parent nil)
4721 (defvar gnus-tmp-root-expunged nil)
4722 (defvar gnus-tmp-dummy-line nil)
4724 (eval-when-compile (defvar gnus-tmp-header))
4725 (defun gnus-extra-header (type &optional header)
4726 "Return the extra header of TYPE."
4727 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4730 (defvar gnus-tmp-thread-tree-header-string "")
4732 (defcustom gnus-sum-thread-tree-root "> "
4733 "With %B spec, used for the root of a thread.
4734 If nil, use subject instead."
4736 :type '(radio (const :format "%v " nil) string)
4737 :group 'gnus-thread)
4739 (defcustom gnus-sum-thread-tree-false-root "> "
4740 "With %B spec, used for a false root of a thread.
4741 If nil, use subject instead."
4743 :type '(radio (const :format "%v " nil) string)
4744 :group 'gnus-thread)
4746 (defcustom gnus-sum-thread-tree-single-indent ""
4747 "With %B spec, used for a thread with just one message.
4748 If nil, use subject instead."
4750 :type '(radio (const :format "%v " nil) string)
4751 :group 'gnus-thread)
4753 (defcustom gnus-sum-thread-tree-vertical "| "
4754 "With %B spec, used for drawing a vertical line."
4757 :group 'gnus-thread)
4759 (defcustom gnus-sum-thread-tree-indent " "
4760 "With %B spec, used for indenting."
4763 :group 'gnus-thread)
4765 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4766 "With %B spec, used for a leaf with brothers."
4769 :group 'gnus-thread)
4771 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4772 "With %B spec, used for a leaf without brothers."
4775 :group 'gnus-thread)
4777 (defun gnus-summary-prepare-threads (threads)
4778 "Prepare summary buffer from THREADS and indentation LEVEL.
4779 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4780 or a straight list of headers."
4781 (gnus-message 7 "Generating summary...")
4783 (setq gnus-newsgroup-threads threads)
4786 (let ((gnus-tmp-level 0)
4787 (default-score (or gnus-summary-default-score 0))
4788 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4789 (building-line-count gnus-summary-display-while-building)
4790 (building-count (integerp gnus-summary-display-while-building))
4791 thread number subject stack state gnus-tmp-gathered beg-match
4792 new-roots gnus-tmp-new-adopts thread-end simp-subject
4793 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4794 gnus-tmp-replied gnus-tmp-subject-or-nil
4795 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4796 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4797 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4800 (setq gnus-tmp-prev-subject nil
4801 gnus-tmp-thread-tree-header-string "")
4803 (if (vectorp (car threads))
4804 ;; If this is a straight (sic) list of headers, then a
4805 ;; threaded summary display isn't required, so we just create
4806 ;; an unthreaded one.
4807 (gnus-summary-prepare-unthreaded threads)
4809 ;; Do the threaded display.
4811 (if gnus-summary-display-while-building
4812 (switch-to-buffer (buffer-name)))
4813 (while (or threads stack gnus-tmp-new-adopts new-roots)
4815 (if (and (= gnus-tmp-level 0)
4818 (not gnus-tmp-false-parent)
4819 (or gnus-tmp-new-adopts new-roots))
4820 (if gnus-tmp-new-adopts
4821 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4822 thread (list (car gnus-tmp-new-adopts))
4823 gnus-tmp-header (caar thread)
4824 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4826 (setq thread (list (car new-roots))
4827 gnus-tmp-header (caar thread)
4828 new-roots (cdr new-roots))))
4831 ;; If there are some threads, we do them before the
4832 ;; threads on the stack.
4833 (setq thread threads
4834 gnus-tmp-header (caar thread))
4835 ;; There were no current threads, so we pop something off
4837 (setq state (car stack)
4838 gnus-tmp-level (car state)
4839 tree-stack (cadr state)
4840 thread (caddr state)
4842 gnus-tmp-header (caar thread))))
4844 (setq gnus-tmp-false-parent nil)
4845 (setq gnus-tmp-root-expunged nil)
4846 (setq thread-end nil)
4848 (if (stringp gnus-tmp-header)
4849 ;; The header is a dummy root.
4851 ((eq gnus-summary-make-false-root 'adopt)
4852 ;; We let the first article adopt the rest.
4853 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4855 (setq gnus-tmp-gathered
4857 (lambda (h) (mail-header-number (car h)))
4860 (setq thread (cons (list (caar thread)
4863 (setq gnus-tmp-level -1
4864 gnus-tmp-false-parent t))
4865 ((eq gnus-summary-make-false-root 'empty)
4866 ;; We print adopted articles with empty subject fields.
4867 (setq gnus-tmp-gathered
4869 (lambda (h) (mail-header-number (car h)))
4872 (setq gnus-tmp-level -1))
4873 ((eq gnus-summary-make-false-root 'dummy)
4874 ;; We remember that we probably want to output a dummy
4876 (setq gnus-tmp-dummy-line gnus-tmp-header)
4877 (setq gnus-tmp-prev-subject gnus-tmp-header))
4879 ;; We do not make a root for the gathered
4880 ;; sub-threads at all.
4881 (setq gnus-tmp-level -1)))
4883 (setq number (mail-header-number gnus-tmp-header)
4884 subject (mail-header-subject gnus-tmp-header)
4885 simp-subject (gnus-simplify-subject-fully subject))
4888 ;; If the thread has changed subject, we might want to make
4889 ;; this subthread into a root.
4890 ((and (null gnus-thread-ignore-subject)
4891 (not (zerop gnus-tmp-level))
4892 gnus-tmp-prev-subject
4893 (not (string= gnus-tmp-prev-subject simp-subject)))
4894 (setq new-roots (nconc new-roots (list (car thread)))
4896 gnus-tmp-header nil))
4897 ;; If the article lies outside the current limit,
4898 ;; then we do not display it.
4899 ((not (memq number gnus-newsgroup-limit))
4900 (setq gnus-tmp-gathered
4902 (lambda (h) (mail-header-number (car h)))
4905 (setq gnus-tmp-new-adopts (if (cdar thread)
4906 (append gnus-tmp-new-adopts
4908 gnus-tmp-new-adopts)
4910 gnus-tmp-header nil)
4911 (when (zerop gnus-tmp-level)
4912 (setq gnus-tmp-root-expunged t)))
4913 ;; Perhaps this article is to be marked as read?
4914 ((and gnus-summary-mark-below
4915 (< (or (cdr (assq number gnus-newsgroup-scored))
4917 gnus-summary-mark-below)
4918 ;; Don't touch sparse articles.
4919 (not (gnus-summary-article-sparse-p number))
4920 (not (gnus-summary-article-ancient-p number)))
4921 (setq gnus-newsgroup-unreads
4922 (delq number gnus-newsgroup-unreads))
4923 (if gnus-newsgroup-auto-expire
4924 (setq gnus-newsgroup-expirable
4925 (gnus-add-to-sorted-list
4926 gnus-newsgroup-expirable number))
4927 (push (cons number gnus-low-score-mark)
4928 gnus-newsgroup-reads))))
4930 (when gnus-tmp-header
4931 ;; We may have an old dummy line to output before this
4933 (when (and gnus-tmp-dummy-line
4936 (mail-header-subject gnus-tmp-header)))
4937 (gnus-summary-insert-dummy-line
4938 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4939 (setq gnus-tmp-dummy-line nil))
4941 ;; Compute the mark.
4942 (setq gnus-tmp-unread (gnus-article-mark number))
4944 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4945 gnus-tmp-header gnus-tmp-level)
4946 gnus-newsgroup-data)
4948 ;; Actually insert the line.
4950 gnus-tmp-subject-or-nil
4952 ((and gnus-thread-ignore-subject
4953 gnus-tmp-prev-subject
4954 (not (string= gnus-tmp-prev-subject simp-subject)))
4956 ((zerop gnus-tmp-level)
4957 (if (and (eq gnus-summary-make-false-root 'empty)
4958 (memq number gnus-tmp-gathered)
4959 gnus-tmp-prev-subject
4960 (string= gnus-tmp-prev-subject simp-subject))
4961 gnus-summary-same-subject
4963 (t gnus-summary-same-subject)))
4964 (if (and (eq gnus-summary-make-false-root 'adopt)
4965 (= gnus-tmp-level 1)
4966 (memq number gnus-tmp-gathered))
4967 (setq gnus-tmp-opening-bracket ?\<
4968 gnus-tmp-closing-bracket ?\>)
4969 (setq gnus-tmp-opening-bracket ?\[
4970 gnus-tmp-closing-bracket ?\]))
4972 gnus-tmp-indentation
4973 (aref gnus-thread-indent-array gnus-tmp-level)
4974 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4975 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4976 gnus-summary-default-score 0)
4978 (if (or (null gnus-summary-default-score)
4979 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4980 gnus-summary-zcore-fuzz))
4982 (if (< gnus-tmp-score gnus-summary-default-score)
4983 gnus-score-below-mark gnus-score-over-mark))
4985 (cond ((memq number gnus-newsgroup-processable)
4987 ((memq number gnus-newsgroup-cached)
4989 ((memq number gnus-newsgroup-replied)
4991 ((memq number gnus-newsgroup-forwarded)
4992 gnus-forwarded-mark)
4993 ((memq number gnus-newsgroup-saved)
4995 ((memq number gnus-newsgroup-recent)
4997 ((memq number gnus-newsgroup-unseen)
5001 (cond ((memq number gnus-newsgroup-undownloaded)
5002 gnus-undownloaded-mark)
5003 (gnus-newsgroup-agentized
5004 gnus-downloaded-mark)
5007 gnus-tmp-from (mail-header-from gnus-tmp-header)
5010 ((string-match "<[^>]+> *$" gnus-tmp-from)
5011 (setq beg-match (match-beginning 0))
5012 (or (and (string-match "^\".+\"" gnus-tmp-from)
5013 (substring gnus-tmp-from 1 (1- (match-end 0))))
5014 (substring gnus-tmp-from 0 beg-match)))
5015 ((string-match "(.+)" gnus-tmp-from)
5016 (substring gnus-tmp-from
5017 (1+ (match-beginning 0)) (1- (match-end 0))))
5021 gnus-tmp-thread-tree-header-string
5023 ((not gnus-show-threads) "")
5024 ((zerop gnus-tmp-level)
5025 (cond ((cdar thread)
5026 (or gnus-sum-thread-tree-root subject))
5027 (gnus-tmp-new-adopts
5028 (or gnus-sum-thread-tree-false-root subject))
5030 (or gnus-sum-thread-tree-single-indent subject))))
5032 (concat (apply 'concat
5033 (mapcar (lambda (item)
5035 gnus-sum-thread-tree-vertical
5036 gnus-sum-thread-tree-indent))
5037 (cdr (reverse tree-stack))))
5039 gnus-sum-thread-tree-leaf-with-other
5040 gnus-sum-thread-tree-single-leaf)))))
5041 (when (string= gnus-tmp-name "")
5042 (setq gnus-tmp-name gnus-tmp-from))
5043 (unless (numberp gnus-tmp-lines)
5044 (setq gnus-tmp-lines -1))
5045 (if (= gnus-tmp-lines -1)
5046 (setq gnus-tmp-lines "?")
5047 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5048 (gnus-put-text-property
5050 (progn (eval gnus-summary-line-format-spec) (point))
5051 'gnus-number number)
5054 (gnus-run-hooks 'gnus-summary-update-hook)
5057 (setq gnus-tmp-prev-subject simp-subject)))
5059 (when (nth 1 thread)
5060 (push (list (max 0 gnus-tmp-level)
5061 (copy-sequence tree-stack)
5064 (push (if (nth 1 thread) 1 0) tree-stack)
5065 (incf gnus-tmp-level)
5066 (setq threads (if thread-end nil (cdar thread)))
5067 (if gnus-summary-display-while-building
5070 ;; use a set frequency
5071 (setq building-line-count (1- building-line-count))
5072 (when (= building-line-count 0)
5074 (setq building-line-count
5075 gnus-summary-display-while-building)))
5079 (setq gnus-tmp-level 0)))))
5080 (gnus-message 7 "Generating summary...done"))
5082 (defun gnus-summary-prepare-unthreaded (headers)
5083 "Generate an unthreaded summary buffer based on HEADERS."
5084 (let (header number mark)
5089 ;; We may have to root out some bad articles...
5090 (when (memq (setq number (mail-header-number
5091 (setq header (pop headers))))
5092 gnus-newsgroup-limit)
5093 ;; Mark article as read when it has a low score.
5094 (when (and gnus-summary-mark-below
5095 (< (or (cdr (assq number gnus-newsgroup-scored))
5096 gnus-summary-default-score 0)
5097 gnus-summary-mark-below)
5098 (not (gnus-summary-article-ancient-p number)))
5099 (setq gnus-newsgroup-unreads
5100 (delq number gnus-newsgroup-unreads))
5101 (if gnus-newsgroup-auto-expire
5102 (push number gnus-newsgroup-expirable)
5103 (push (cons number gnus-low-score-mark)
5104 gnus-newsgroup-reads)))
5106 (setq mark (gnus-article-mark number))
5107 (push (gnus-data-make number mark (1+ (point)) header 0)
5108 gnus-newsgroup-data)
5109 (gnus-summary-insert-line
5111 (memq number gnus-newsgroup-undownloaded)
5112 mark (memq number gnus-newsgroup-replied)
5113 (memq number gnus-newsgroup-expirable)
5114 (mail-header-subject header) nil
5115 (cdr (assq number gnus-newsgroup-scored))
5116 (memq number gnus-newsgroup-processable))))))
5118 (defun gnus-summary-remove-list-identifiers ()
5119 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5120 (let ((regexp (if (consp gnus-list-identifiers)
5121 (mapconcat 'identity gnus-list-identifiers " *\\|")
5122 gnus-list-identifiers))
5125 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5126 (dolist (header gnus-newsgroup-headers)
5127 (setq subject (mail-header-subject header)
5129 (while (string-match regexp subject)
5131 (concat (substring subject 0 (match-beginning 1))
5132 (substring subject (match-end 0)))
5135 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5137 (concat (substring subject 0 (match-beginning 1))
5138 (substring subject (match-end 1)))))
5139 (mail-header-set-subject header subject))))))
5141 (defun gnus-fetch-headers (articles)
5142 "Fetch headers of ARTICLES."
5143 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5144 (gnus-message 5 "Fetching headers for %s..." name)
5147 (setq gnus-headers-retrieved-by
5148 (gnus-retrieve-headers
5149 articles gnus-newsgroup-name
5150 ;; We might want to fetch old headers, but
5151 ;; not if there is only 1 article.
5153 (not (eq gnus-fetch-old-headers 'some))
5154 (not (numberp gnus-fetch-old-headers)))
5155 (> (length articles) 1))
5156 gnus-fetch-old-headers))))
5157 (gnus-get-newsgroup-headers-xover
5158 articles nil nil gnus-newsgroup-name t)
5159 (gnus-get-newsgroup-headers))
5160 (gnus-message 5 "Fetching headers for %s...done" name))))
5162 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5163 "Select newsgroup GROUP.
5164 If READ-ALL is non-nil, all articles in the group are selected.
5165 If SELECT-ARTICLES, only select those articles from GROUP."
5166 (let* ((entry (gnus-group-entry group))
5167 ;;!!! Dirty hack; should be removed.
5168 (gnus-summary-ignore-duplicates
5169 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5171 gnus-summary-ignore-duplicates))
5172 (info (nth 2 entry))
5173 articles fetched-articles cached)
5175 (unless (gnus-check-server
5176 (set (make-local-variable 'gnus-current-select-method)
5177 (gnus-find-method-for-group group)))
5178 (error "Couldn't open server"))
5180 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5181 (gnus-activate-group group) ; Or we can activate it...
5182 (progn ; Or we bug out.
5183 (when (equal major-mode 'gnus-summary-mode)
5184 (gnus-kill-buffer (current-buffer)))
5185 (error "Couldn't activate group %s: %s"
5186 group (gnus-status-message group))))
5188 (unless (gnus-request-group group t)
5189 (when (equal major-mode 'gnus-summary-mode)
5190 (gnus-kill-buffer (current-buffer)))
5191 (error "Couldn't request group %s: %s"
5192 group (gnus-status-message group)))
5195 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5197 (setq gnus-summary-use-undownloaded-faces
5198 (gnus-agent-find-parameter
5200 'agent-enable-undownloaded-faces)))
5202 (setq gnus-newsgroup-name group
5203 gnus-newsgroup-unselected nil
5204 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5206 (let ((display (gnus-group-find-parameter group 'display)))
5207 (setq gnus-newsgroup-display
5209 ((not (zerop (or (car-safe read-all) 0)))
5210 ;; The user entered the group with C-u SPC/RET, let's show
5216 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5218 ;; The following is probably the "correct" solution, but
5219 ;; it makes Gnus fetch all headers and then limit the
5220 ;; articles (which is slow), so instead we hack the
5221 ;; select-articles parameter instead. -- Simon Josefsson
5224 ;; (gnus-byte-compile
5225 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5227 (setq select-articles
5228 (gnus-uncompress-range
5229 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5233 (cdr (gnus-active group)))))
5238 (gnus-summary-setup-default-charset)
5240 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5241 (when (gnus-virtual-group-p group)
5242 (setq cached gnus-newsgroup-cached))
5244 (setq gnus-newsgroup-unreads
5245 (gnus-sorted-ndifference
5246 (gnus-sorted-ndifference gnus-newsgroup-unreads
5247 gnus-newsgroup-marked)
5248 gnus-newsgroup-dormant))
5250 (setq gnus-newsgroup-processable nil)
5252 (gnus-update-read-articles group gnus-newsgroup-unreads)
5254 ;; Adjust and set lists of article marks.
5256 (gnus-adjust-marked-articles info))
5257 (if (setq articles select-articles)
5258 (setq gnus-newsgroup-unselected
5259 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5260 (setq articles (gnus-articles-to-read group read-all)))
5264 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5266 ((eq articles 0) nil)
5268 ;; Init the dependencies hash table.
5269 (setq gnus-newsgroup-dependencies
5270 (gnus-make-hashtable (length articles)))
5271 (gnus-set-global-variables)
5272 ;; Retrieve the headers and read them in.
5274 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5276 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5278 (setq gnus-newsgroup-cached cached))
5280 ;; Suppress duplicates?
5281 (when gnus-suppress-duplicates
5282 (gnus-dup-suppress-articles))
5284 ;; Set the initial limit.
5285 (setq gnus-newsgroup-limit (copy-sequence articles))
5286 ;; Remove canceled articles from the list of unread articles.
5287 (setq fetched-articles
5288 (mapcar (lambda (headers) (mail-header-number headers))
5289 gnus-newsgroup-headers))
5290 (setq gnus-newsgroup-articles fetched-articles)
5291 (setq gnus-newsgroup-unreads
5292 (gnus-sorted-nintersection
5293 gnus-newsgroup-unreads fetched-articles))
5294 (gnus-compute-unseen-list)
5296 ;; Removed marked articles that do not exist.
5297 (gnus-update-missing-marks
5298 (gnus-sorted-difference articles fetched-articles))
5299 ;; We might want to build some more threads first.
5300 (when (and gnus-fetch-old-headers
5301 (eq gnus-headers-retrieved-by 'nov))
5302 (if (eq gnus-fetch-old-headers 'invisible)
5303 (gnus-build-all-threads)
5304 (gnus-build-old-threads)))
5305 ;; Let the Gnus agent mark articles as read.
5307 (gnus-agent-get-undownloaded-list))
5308 ;; Remove list identifiers from subject
5309 (when gnus-list-identifiers
5310 (gnus-summary-remove-list-identifiers))
5311 ;; Check whether auto-expire is to be done in this group.
5312 (setq gnus-newsgroup-auto-expire
5313 (gnus-group-auto-expirable-p group))
5314 ;; Set up the article buffer now, if necessary.
5315 (unless gnus-single-article-buffer
5316 (gnus-article-setup-buffer))
5317 ;; First and last article in this newsgroup.
5318 (when gnus-newsgroup-headers
5319 (setq gnus-newsgroup-begin
5320 (mail-header-number (car gnus-newsgroup-headers))
5323 (gnus-last-element gnus-newsgroup-headers))))
5324 ;; GROUP is successfully selected.
5325 (or gnus-newsgroup-headers t)))))
5327 (defun gnus-compute-unseen-list ()
5328 ;; The `seen' marks are treated specially.
5329 (if (not gnus-newsgroup-seen)
5330 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5331 (setq gnus-newsgroup-unseen
5332 (gnus-inverse-list-range-intersection
5333 gnus-newsgroup-articles gnus-newsgroup-seen))))
5335 (defun gnus-summary-display-make-predicate (display)
5336 (require 'gnus-agent)
5337 (when (= (length display) 1)
5338 (setq display (car display)))
5339 (unless gnus-summary-display-cache
5340 (dolist (elem (append '((unread . unread)
5343 gnus-article-mark-lists))
5344 (push (cons (cdr elem)
5346 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5347 gnus-summary-display-cache)))
5348 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5349 (gnus-category-predicate-cache gnus-summary-display-cache))
5350 (gnus-get-predicate display)))
5352 ;; Uses the dynamically bound `number' variable.
5355 (defun gnus-article-marked-p (type &optional article)
5356 (let ((article (or article number)))
5359 (memq article gnus-newsgroup-marked))
5361 (memq article gnus-newsgroup-spam-marked))
5363 (memq article gnus-newsgroup-unsendable))
5364 ((eq type 'undownload)
5365 (memq article gnus-newsgroup-undownloaded))
5366 ((eq type 'download)
5367 (memq article gnus-newsgroup-downloadable))
5369 (memq article gnus-newsgroup-unreads))
5371 (memq article gnus-newsgroup-reads))
5373 (memq article gnus-newsgroup-dormant) )
5375 (memq article gnus-newsgroup-expirable))
5377 (memq article gnus-newsgroup-replied))
5379 (memq article gnus-newsgroup-killed))
5380 ((eq type 'bookmark)
5381 (assq article gnus-newsgroup-bookmarks))
5383 (assq article gnus-newsgroup-scored))
5385 (memq article gnus-newsgroup-saved))
5387 (memq article gnus-newsgroup-cached))
5389 (memq article gnus-newsgroup-forwarded))
5391 (not (memq article gnus-newsgroup-unseen)))
5393 (memq article gnus-newsgroup-recent))
5396 (defun gnus-articles-to-read (group &optional read-all)
5397 "Find out what articles the user wants to read."
5399 ;; Select all articles if `read-all' is non-nil, or if there
5400 ;; are no unread articles.
5402 (and (zerop (length gnus-newsgroup-marked))
5403 (zerop (length gnus-newsgroup-unreads)))
5404 ;; Fetch all if the predicate is non-nil.
5405 gnus-newsgroup-display)
5406 ;; We want to select the headers for all the articles in
5407 ;; the group, so we select either all the active
5408 ;; articles in the group, or (if that's nil), the
5409 ;; articles in the cache.
5411 (gnus-uncompress-range (gnus-active group))
5412 (gnus-cache-articles-in-group group))
5413 ;; Select only the "normal" subset of articles.
5415 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5416 gnus-newsgroup-unreads)))
5417 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5418 (scored (length scored-list))
5419 (number (length articles))
5420 (marked (+ (length gnus-newsgroup-marked)
5421 (length gnus-newsgroup-dormant)))
5426 ((numberp gnus-newsgroup-display)
5427 gnus-newsgroup-display)
5431 ((and (or (<= scored marked) (= scored number))
5432 (numberp gnus-large-newsgroup)
5433 (> number gnus-large-newsgroup))
5434 (let* ((cursor-in-echo-area nil)
5435 (initial (gnus-parameter-large-newsgroup-initial
5436 gnus-newsgroup-name))
5440 "How many articles from %s (%s %d): "
5442 (gnus-group-decoded-name gnus-newsgroup-name)
5444 (if initial "max" "default")
5447 (cons (number-to-string initial)
5449 (if (string-match "^[ \t]*$" input) number input)))
5450 ((and (> scored marked) (< scored number)
5451 (> (- scored number) 20))
5454 (format "%s %s (%d scored, %d total): "
5455 "How many articles from"
5456 (gnus-group-decoded-name group)
5458 (if (string-match "^[ \t]*$" input)
5462 (message "Quit getting the articles to read")
5464 (setq select (if (stringp select) (string-to-number select) select))
5465 (if (or (null select) (zerop select))
5467 (if (and (not (zerop scored)) (<= (abs select) scored))
5469 (setq articles (sort scored-list '<))
5470 (setq number (length articles)))
5471 (setq articles (copy-sequence articles)))
5473 (when (< (abs select) number)
5475 ;; Select the N oldest articles.
5476 (setcdr (nthcdr (1- (abs select)) articles) nil)
5477 ;; Select the N most recent articles.
5478 (setq articles (nthcdr (- number select) articles))))
5479 (setq gnus-newsgroup-unselected
5480 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5481 (when gnus-alter-articles-to-read-function
5484 (funcall gnus-alter-articles-to-read-function
5485 gnus-newsgroup-name articles)
5489 (defun gnus-killed-articles (killed articles)
5492 (when (inline (gnus-member-of-range (car articles) killed))
5493 (push (car articles) out))
5494 (setq articles (cdr articles)))
5497 (defun gnus-uncompress-marks (marks)
5498 "Uncompress the mark ranges in MARKS."
5499 (let ((uncompressed '(score bookmark))
5502 (if (memq (caar marks) uncompressed)
5503 (push (car marks) out)
5504 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5505 (setq marks (cdr marks)))
5508 (defun gnus-article-mark-to-type (mark)
5509 "Return the type of MARK."
5510 (or (cadr (assq mark gnus-article-special-mark-lists))
5513 (defun gnus-article-unpropagatable-p (mark)
5514 "Return whether MARK should be propagated to back end."
5515 (memq mark gnus-article-unpropagated-mark-lists))
5517 (defun gnus-adjust-marked-articles (info)
5518 "Set all article lists and remove all marks that are no longer valid."
5519 (let* ((marked-lists (gnus-info-marks info))
5520 (active (gnus-active (gnus-info-group info)))
5523 (types gnus-article-mark-lists)
5524 marks var articles article mark mark-type
5527 (dolist (marks marked-lists)
5528 (setq mark (car marks)
5529 mark-type (gnus-article-mark-to-type mark)
5530 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5532 ;; We set the variable according to the type of the marks list,
5533 ;; and then adjust the marks to a subset of the active articles.
5535 ;; Adjust "simple" lists - compressed yet unsorted
5536 ((eq mark-type 'list)
5537 ;; Simultaneously uncompress and clip to active range
5538 ;; See gnus-uncompress-range for a description of possible marks
5540 (if (not (cadr marks))
5542 (setq articles (if (numberp (cddr marks))
5548 (while (setq article (pop articles))
5549 (cond ((consp article)
5550 (setq bgn (max (car article) min)
5551 end (min (cdr article) max))
5553 (setq l (setcdr l (cons bgn nil))
5555 ((and (<= min article)
5557 (setq l (setcdr l (cons article nil))))))
5558 (set var (cdr lh)))))
5560 ((eq mark-type 'tuple)
5561 (set var (setq articles (cdr marks)))
5562 (when (not (listp (cdr (symbol-value var))))
5563 (set var (list (symbol-value var))))
5564 (when (not (listp (cdr articles)))
5565 (setq articles (list articles)))
5567 (when (or (not (consp (setq article (pop articles))))
5568 (< (car article) min)
5569 (> (car article) max))
5570 (set var (delq article (symbol-value var))))))
5571 ;; Adjust ranges (sloppily).
5572 ((eq mark-type 'range)
5575 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5576 ;; It should be (seen (NUM1 . NUM2)).
5577 (when (numberp (cddr marks))
5578 (setcdr marks (list (cdr marks))))
5579 (setq articles (cdr marks))
5580 (while (and articles
5581 (or (and (consp (car articles))
5582 (> min (cdar articles)))
5583 (and (numberp (car articles))
5584 (> min (car articles)))))
5586 (set var articles))))))))
5588 (defun gnus-update-missing-marks (missing)
5589 "Go through the list of MISSING articles and remove them from the mark lists."
5592 ;; Go through all types.
5593 (dolist (elem gnus-article-mark-lists)
5594 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5595 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5596 (when (symbol-value var)
5597 ;; This list has articles. So we delete all missing
5598 ;; articles from it.
5601 (set var (delq (pop m) (symbol-value var))))))))))
5603 (defun gnus-update-marks ()
5604 "Enter the various lists of marked articles into the newsgroup info list."
5605 (let ((types gnus-article-mark-lists)
5606 (info (gnus-get-info gnus-newsgroup-name))
5607 type list newmarked symbol delta-marks)
5609 ;; Add all marks lists to the list of marks lists.
5610 (while (setq type (pop types))
5611 (setq list (symbol-value
5613 (intern (format "gnus-newsgroup-%s" (car type))))))
5616 ;; Get rid of the entries of the articles that have the
5618 (when (and (eq (cdr type) 'score)
5622 (prev (cons nil list))
5625 (if (or (not (consp (car arts)))
5626 (= (cdar arts) gnus-summary-default-score))
5627 (setcdr prev (cdr arts))
5629 (setq arts (cdr arts)))
5630 (setq list (cdr all)))))
5632 (when (eq (cdr type) 'seen)
5633 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5635 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5636 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5638 (when (and (gnus-check-backend-function
5639 'request-set-mark gnus-newsgroup-name)
5640 (not (gnus-article-unpropagatable-p (cdr type))))
5641 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5642 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5643 (add (gnus-remove-from-range
5644 (gnus-copy-sequence list) old)))
5646 (push (list add 'add (list (cdr type))) delta-marks))
5648 (push (list del 'del (list (cdr type))) delta-marks))))
5651 (push (cons (cdr type) list) newmarked)))
5654 (unless (gnus-check-group gnus-newsgroup-name)
5655 (error "Can't open server for %s" gnus-newsgroup-name))
5656 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5658 ;; Enter these new marks into the info of the group.
5660 (setcar (nthcdr 3 info) newmarked)
5661 ;; Add the marks lists to the end of the info.
5663 (setcdr (nthcdr 2 info) (list newmarked))))
5665 ;; Cut off the end of the info if there's nothing else there.
5669 (when (nthcdr (decf i) info)
5670 (setcdr (nthcdr i info) nil)))))))
5672 (defun gnus-set-mode-line (where)
5673 "Set the mode line of the article or summary buffers.
5674 If WHERE is `summary', the summary mode line format will be used."
5675 ;; Is this mode line one we keep updated?
5676 (when (and (memq where gnus-updated-mode-lines)
5678 (intern (format "gnus-%s-mode-line-format-spec" where))))
5681 ;; We evaluate this in the summary buffer since these
5682 ;; variables are buffer-local to that buffer.
5683 (set-buffer gnus-summary-buffer)
5684 ;; We bind all these variables that are used in the `eval' form
5686 (let* ((mformat (symbol-value
5688 (format "gnus-%s-mode-line-format-spec" where))))
5689 (gnus-tmp-group-name (gnus-group-decoded-name
5690 gnus-newsgroup-name))
5691 (gnus-tmp-article-number (or gnus-current-article 0))
5692 (gnus-tmp-unread gnus-newsgroup-unreads)
5693 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5694 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5695 (gnus-tmp-unread-and-unselected
5696 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5697 (zerop gnus-tmp-unselected))
5699 ((zerop gnus-tmp-unselected)
5700 (format "{%d more}" gnus-tmp-unread-and-unticked))
5701 (t (format "{%d(+%d) more}"
5702 gnus-tmp-unread-and-unticked
5703 gnus-tmp-unselected))))
5705 (if (and gnus-current-headers
5706 (vectorp gnus-current-headers))
5707 (gnus-mode-string-quote
5708 (mail-header-subject gnus-current-headers))
5710 bufname-length max-len
5711 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5712 (setq mode-string (eval mformat))
5713 (setq bufname-length (if (string-match "%b" mode-string)
5716 (if (eq where 'summary)
5718 (get-buffer gnus-article-buffer))))
5721 (setq max-len (max 4 (if gnus-mode-non-string-length
5723 gnus-mode-non-string-length
5725 (length mode-string))))
5726 ;; We might have to chop a bit of the string off...
5727 (when (> (length mode-string) max-len)
5729 (concat (truncate-string-to-width mode-string (- max-len 3))
5731 ;; Pad the mode string a bit.
5732 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5733 ;; Update the mode line.
5734 (setq mode-line-buffer-identification
5735 (gnus-mode-line-buffer-identification (list mode-string)))
5736 (set-buffer-modified-p t))))
5738 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5739 "Go through the HEADERS list and add all Xrefs to a hash table.
5740 The resulting hash table is returned, or nil if no Xrefs were found."
5741 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5742 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5743 (xref-hashtb (gnus-make-hashtable))
5744 start group entry number xrefs header)
5746 (setq header (pop headers))
5747 (when (and (setq xrefs (mail-header-xref header))
5748 (not (memq (setq number (mail-header-number header))
5751 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5752 (setq start (match-end 0))
5753 (setq group (if prefix
5754 (concat prefix (substring xrefs (match-beginning 1)
5756 (substring xrefs (match-beginning 1) (match-end 1))))
5758 (string-to-number (substring xrefs (match-beginning 2)
5760 (if (setq entry (gnus-gethash group xref-hashtb))
5761 (setcdr entry (cons number (cdr entry)))
5762 (gnus-sethash group (cons number nil) xref-hashtb)))))
5763 (and start xref-hashtb)))
5765 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5766 "Look through all the headers and mark the Xrefs as read."
5767 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5768 name info xref-hashtb idlist method nth4)
5770 (set-buffer gnus-group-buffer)
5771 (when (setq xref-hashtb
5772 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5775 (unless (string= from-newsgroup (setq name (symbol-name group)))
5776 (setq idlist (symbol-value group))
5777 ;; Dead groups are not updated.
5779 (setq info (gnus-get-info name))
5780 (when (stringp (setq nth4 (gnus-info-method info)))
5781 (setq nth4 (gnus-server-to-method nth4))))
5782 ;; Only do the xrefs if the group has the same
5783 ;; select method as the group we have just read.
5784 (or (gnus-methods-equal-p
5785 nth4 (gnus-find-method-for-group from-newsgroup))
5787 (equal nth4 (setq method (gnus-find-method-for-group
5789 (and (equal (car nth4) (car method))
5790 (equal (nth 1 nth4) (nth 1 method))))
5791 gnus-use-cross-reference
5792 (or (not (eq gnus-use-cross-reference t))
5794 ;; Only do cross-references on subscribed
5795 ;; groups, if that is what is wanted.
5796 (<= (gnus-info-level info) gnus-level-subscribed))
5797 (gnus-group-make-articles-read name idlist))))
5800 (defun gnus-compute-read-articles (group articles)
5801 (let* ((entry (gnus-group-entry group))
5802 (info (nth 2 entry))
5803 (active (gnus-active group))
5806 ;; First peel off all invalid article numbers.
5808 (let ((ids articles)
5810 (while (setq id (pop ids))
5811 (when (and first (> id (cdr active)))
5812 ;; We'll end up in this situation in one particular
5813 ;; obscure situation. If you re-scan a group and get
5814 ;; a new article that is cross-posted to a different
5815 ;; group that has not been re-scanned, you might get
5816 ;; crossposted article that has a higher number than
5817 ;; Gnus believes possible. So we re-activate this
5818 ;; group as well. This might mean doing the
5819 ;; crossposting thingy will *increase* the number
5820 ;; of articles in some groups. Tsk, tsk.
5821 (setq active (or (gnus-activate-group group) active)))
5822 (when (or (> id (cdr active))
5823 (< id (car active)))
5824 (setq articles (delq id articles))))))
5825 ;; If the read list is nil, we init it.
5827 (null (gnus-info-read info))
5829 (setq ninfo (cons 1 (1- (car active))))
5830 (setq ninfo (gnus-info-read info)))
5831 ;; Then we add the read articles to the range.
5833 ninfo (setq articles (sort articles '<))))))
5835 (defun gnus-group-make-articles-read (group articles)
5836 "Update the info of GROUP to say that ARTICLES are read."
5838 (entry (gnus-group-entry group))
5839 (info (nth 2 entry))
5840 (active (gnus-active group))
5843 (setq range (gnus-compute-read-articles group articles))
5844 (with-current-buffer gnus-group-buffer
5847 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5848 (gnus-info-set-read ',info ',(gnus-info-read info))
5849 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5850 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5851 (gnus-group-update-group ,group t))))
5852 ;; Add the read articles to the range.
5853 (gnus-info-set-read info range)
5854 (gnus-request-set-mark group (list (list range 'add '(read))))
5855 ;; Then we have to re-compute how many unread
5856 ;; articles there are in this group.
5860 (setq num (- (1+ (cdr active)) (car active))))
5861 ((not (listp (cdr range)))
5862 (setq num (- (cdr active) (- (1+ (cdr range))
5866 (if (numberp (car range))
5868 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5869 (setq range (cdr range)))
5870 (setq num (- (cdr active) num))))
5871 ;; Update the number of unread articles.
5873 ;; Update the group buffer.
5874 (unless (gnus-ephemeral-group-p group)
5875 (gnus-group-update-group group t))))))
5877 (defvar gnus-newsgroup-none-id 0)
5879 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5880 (let ((cur nntp-server-buffer)
5883 (with-current-buffer gnus-summary-buffer
5884 gnus-newsgroup-dependencies)))
5885 headers id end ref number
5886 (mail-parse-charset gnus-newsgroup-charset)
5887 (mail-parse-ignored-charsets
5888 (save-excursion (condition-case nil
5889 (set-buffer gnus-summary-buffer)
5891 gnus-newsgroup-ignored-charsets)))
5893 (set-buffer nntp-server-buffer)
5894 ;; Translate all TAB characters into SPACE characters.
5895 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5896 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5897 (ietf-drums-unfold-fws)
5898 (gnus-run-hooks 'gnus-parse-headers-hook)
5899 (let ((case-fold-search t)
5900 in-reply-to header p lines chars)
5901 (goto-char (point-min))
5902 ;; Search to the beginning of the next header. Error messages
5903 ;; do not begin with 2 or 3.
5904 (while (re-search-forward "^[23][0-9]+ " nil t)
5907 ;; This implementation of this function, with nine
5908 ;; search-forwards instead of the one re-search-forward and
5909 ;; a case (which basically was the old function) is actually
5910 ;; about twice as fast, even though it looks messier. You
5911 ;; can't have everything, I guess. Speed and elegance
5912 ;; doesn't always go hand in hand.
5918 (setq number (read cur))
5921 (narrow-to-region (point)
5922 (or (and (search-forward "\n.\n" nil t)
5928 (if (search-forward "\nsubject:" nil t)
5929 (funcall gnus-decode-encoded-word-function
5930 (nnheader-header-value))
5935 (if (search-forward "\nfrom:" nil t)
5936 (funcall gnus-decode-encoded-word-function
5937 (nnheader-header-value))
5942 (if (search-forward "\ndate:" nil t)
5943 (nnheader-header-value) ""))
5947 (setq id (if (re-search-forward
5948 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5949 ;; We do it this way to make sure the Message-ID
5950 ;; is (somewhat) syntactically valid.
5951 (buffer-substring (match-beginning 1)
5953 ;; If there was no message-id, we just fake one
5954 ;; to make subsequent routines simpler.
5955 (nnheader-generate-fake-message-id number))))
5959 (if (search-forward "\nreferences:" nil t)
5963 (nnheader-header-value)
5968 (search-backward ">" end t)
5971 (search-backward "<" end t)
5973 ;; Get the references from the in-reply-to header if there
5974 ;; were no references and the in-reply-to header looks
5976 (if (and (search-forward "\nin-reply-to:" nil t)
5977 (setq in-reply-to (nnheader-header-value))
5978 (string-match "<[^>]+>" in-reply-to))
5980 (setq ref (substring in-reply-to (match-beginning 0)
5982 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5983 (setq ref2 (substring in-reply-to (match-beginning 0)
5985 (when (> (length ref2) (length ref))
5992 (if (search-forward "\nchars: " nil t)
5993 (if (numberp (setq chars (ignore-errors (read cur))))
5999 (if (search-forward "\nlines: " nil t)
6000 (if (numberp (setq lines (ignore-errors (read cur))))
6006 (and (search-forward "\nxref:" nil t)
6007 (nnheader-header-value)))
6009 (when gnus-extra-headers
6010 (let ((extra gnus-extra-headers)
6014 (when (search-forward
6015 (concat "\n" (symbol-name (car extra)) ":") nil t)
6016 (push (cons (car extra) (nnheader-header-value))
6020 (when (equal id ref)
6023 (when gnus-alter-header-function
6024 (funcall gnus-alter-header-function header)
6025 (setq id (mail-header-id header)
6026 ref (gnus-parent-id (mail-header-references header))))
6029 (gnus-dependencies-add-header
6030 header dependencies force-new))
6031 (push header headers))
6032 (goto-char (point-max))
6034 (nreverse headers)))))
6036 ;; Goes through the xover lines and returns a list of vectors
6037 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6038 force-new dependencies
6039 group also-fetch-heads)
6040 "Parse the news overview data in the server buffer.
6041 Return a list of headers that match SEQUENCE (see
6042 `nntp-retrieve-headers')."
6043 ;; Get the Xref when the users reads the articles since most/some
6044 ;; NNTP servers do not include Xrefs when using XOVER.
6045 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6046 (let ((mail-parse-charset gnus-newsgroup-charset)
6047 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6048 (cur nntp-server-buffer)
6049 (dependencies (or dependencies gnus-newsgroup-dependencies))
6051 ((eq gnus-read-all-available-headers t)
6053 ((stringp gnus-read-all-available-headers)
6054 (string-match gnus-read-all-available-headers group))
6057 number headers header)
6059 (set-buffer nntp-server-buffer)
6060 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6061 ;; Allow the user to mangle the headers before parsing them.
6062 (gnus-run-hooks 'gnus-parse-headers-hook)
6063 (goto-char (point-min))
6064 (gnus-parse-without-error
6065 (while (and (or sequence allp)
6067 (setq number (read cur))
6069 (while (and sequence
6070 (< (car sequence) number))
6071 (setq sequence (cdr sequence))))
6074 (eq number (car sequence))))
6076 (setq sequence (cdr sequence))
6077 (setq header (inline
6078 (gnus-nov-parse-line
6079 number dependencies force-new)))))
6080 (push header headers))
6082 ;; A common bug in inn is that if you have posted an article and
6083 ;; then retrieves the active file, it will answer correctly --
6084 ;; the new article is included. However, a NOV entry for the
6085 ;; article may not have been generated yet, so this may fail.
6086 ;; We work around this problem by retrieving the last few
6087 ;; headers using HEAD.
6088 (if (or (not also-fetch-heads)
6090 ;; We (probably) got all the headers.
6092 (let ((gnus-nov-is-evil t))
6095 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6096 (gnus-get-newsgroup-headers))))))))
6098 (defun gnus-article-get-xrefs ()
6099 "Fill in the Xref value in `gnus-current-headers', if necessary.
6100 This is meant to be called in `gnus-article-internal-prepare-hook'."
6101 (let ((headers (with-current-buffer gnus-summary-buffer
6102 gnus-current-headers)))
6103 (or (not gnus-use-cross-reference)
6105 (and (mail-header-xref headers)
6106 (not (string= (mail-header-xref headers) "")))
6107 (let ((case-fold-search t)
6110 (nnheader-narrow-to-headers)
6111 (goto-char (point-min))
6112 (when (or (and (not (eobp))
6113 (eq (downcase (char-after)) ?x)
6114 (looking-at "Xref:"))
6115 (search-forward "\nXref:" nil t))
6116 (goto-char (1+ (match-end 0)))
6117 (setq xref (buffer-substring (point) (point-at-eol)))
6118 (mail-header-set-xref headers xref)))))))
6120 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6121 "Find article ID and insert the summary line for that article.
6122 OLD-HEADER can either be a header or a line number to insert
6123 the subject line on."
6124 (let* ((line (and (numberp old-header) old-header))
6125 (old-header (and (vectorp old-header) old-header))
6126 (header (cond ((and old-header use-old-header)
6129 (gnus-number-to-header id))
6130 (gnus-number-to-header id))
6132 (gnus-read-header id))))
6133 (number (and (numberp id) id))
6136 ;; Rebuild the thread that this article is part of and go to the
6137 ;; article we have fetched.
6138 (when (and (not gnus-show-threads)
6141 (setq d (gnus-data-find (mail-header-number old-header))))
6142 (goto-char (gnus-data-pos d))
6148 (gnus-delete-line))))))
6149 ;; Remove list identifiers from subject.
6150 (when gnus-list-identifiers
6151 (let ((gnus-newsgroup-headers (list header)))
6152 (gnus-summary-remove-list-identifiers)))
6154 (mail-header-set-number header (mail-header-number old-header)))
6155 (setq gnus-newsgroup-sparse
6156 (delq (setq number (mail-header-number header))
6157 gnus-newsgroup-sparse))
6158 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6159 (push number gnus-newsgroup-limit)
6160 (gnus-rebuild-thread (mail-header-id header) line)
6161 (gnus-summary-goto-subject number nil t))
6162 (when (and (numberp number)
6164 ;; We have to update the boundaries even if we can't fetch the
6165 ;; article if ID is a number -- so that the next `P' or `N'
6166 ;; command will fetch the previous (or next) article even
6167 ;; if the one we tried to fetch this time has been canceled.
6168 (when (> number gnus-newsgroup-end)
6169 (setq gnus-newsgroup-end number))
6170 (when (< number gnus-newsgroup-begin)
6171 (setq gnus-newsgroup-begin number))
6172 (setq gnus-newsgroup-unselected
6173 (delq number gnus-newsgroup-unselected)))
6174 ;; Report back a success?
6175 (and header (mail-header-number header))))
6177 ;;; Process/prefix in the summary buffer
6179 (defun gnus-summary-work-articles (n)
6180 "Return a list of articles to be worked upon.
6181 The prefix argument, the list of process marked articles, and the
6182 current article will be taken into consideration."
6184 (set-buffer gnus-summary-buffer)
6187 ;; A numerical prefix has been given.
6188 (setq n (prefix-numeric-value n))
6189 (let ((backward (< n 0))
6190 (n (abs (prefix-numeric-value n)))
6195 (push (setq article (gnus-summary-article-number))
6198 (gnus-summary-find-prev nil article)
6199 (gnus-summary-find-next nil article)))
6201 (nreverse articles)))
6202 ((and (gnus-region-active-p) (mark))
6203 (message "region active")
6204 ;; Work on the region between point and mark.
6205 (let ((max (max (point) (mark)))
6208 (goto-char (min (min (point) (mark))))
6211 (push (setq article (gnus-summary-article-number)) articles)
6212 (gnus-summary-find-next nil article)
6214 (nreverse articles))))
6215 (gnus-newsgroup-processable
6216 ;; There are process-marked articles present.
6217 ;; Save current state.
6218 (gnus-summary-save-process-mark)
6220 (reverse gnus-newsgroup-processable))
6222 ;; Just return the current article.
6223 (list (gnus-summary-article-number))))))
6225 (defmacro gnus-summary-iterate (arg &rest forms)
6226 "Iterate over the process/prefixed articles and do FORMS.
6227 ARG is the interactive prefix given to the command. FORMS will be
6228 executed with point over the summary line of the articles."
6229 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6230 `(let ((,articles (gnus-summary-work-articles ,arg)))
6232 (gnus-summary-goto-subject (car ,articles))
6236 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6237 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6239 (defun gnus-summary-save-process-mark ()
6240 "Push the current set of process marked articles on the stack."
6242 (push (copy-sequence gnus-newsgroup-processable)
6243 gnus-newsgroup-process-stack))
6245 (defun gnus-summary-kill-process-mark ()
6246 "Push the current set of process marked articles on the stack and unmark."
6248 (gnus-summary-save-process-mark)
6249 (gnus-summary-unmark-all-processable))
6251 (defun gnus-summary-yank-process-mark ()
6252 "Pop the last process mark state off the stack and restore it."
6254 (unless gnus-newsgroup-process-stack
6255 (error "Empty mark stack"))
6256 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6258 (defun gnus-summary-process-mark-set (set)
6259 "Make SET into the current process marked articles."
6260 (gnus-summary-unmark-all-processable)
6261 (mapc 'gnus-summary-set-process-mark set))
6263 ;;; Searching and stuff
6265 (defun gnus-summary-search-group (&optional backward use-level)
6266 "Search for next unread newsgroup.
6267 If optional argument BACKWARD is non-nil, search backward instead."
6269 (set-buffer gnus-group-buffer)
6270 (when (gnus-group-search-forward
6271 backward nil (if use-level (gnus-group-group-level) nil))
6272 (gnus-group-group-name))))
6274 (defun gnus-summary-best-group (&optional exclude-group)
6275 "Find the name of the best unread group.
6276 If EXCLUDE-GROUP, do not go to this group."
6277 (with-current-buffer gnus-group-buffer
6279 (gnus-group-best-unread-group exclude-group))))
6281 (defun gnus-summary-find-next (&optional unread article backward)
6283 (gnus-summary-find-prev unread article)
6284 (let* ((dummy (gnus-summary-article-intangible-p))
6285 (article (or article (gnus-summary-article-number)))
6286 (data (gnus-data-find-list article))
6288 (when (and (not dummy)
6289 (or (not gnus-summary-check-current)
6291 (not (gnus-data-unread-p (car data)))))
6292 (setq data (cdr data)))
6297 (unless (memq (gnus-data-number (car data))
6299 ((eq gnus-auto-goto-ignores
6300 'always-undownloaded)
6301 gnus-newsgroup-undownloaded)
6304 ((eq gnus-auto-goto-ignores
6306 gnus-newsgroup-unfetched)
6307 ((eq gnus-auto-goto-ignores
6309 gnus-newsgroup-undownloaded)))
6310 (when (gnus-data-unread-p (car data))
6311 (setq result (car data)
6313 (setq data (cdr data)))
6316 (goto-char (gnus-data-pos result))
6317 (gnus-data-number result)))))
6319 (defun gnus-summary-find-prev (&optional unread article)
6320 (let* ((eobp (eobp))
6321 (article (or article (gnus-summary-article-number)))
6322 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6324 (when (and (not eobp)
6325 (or (not gnus-summary-check-current)
6327 (not (gnus-data-unread-p (car data)))))
6328 (setq data (cdr data)))
6333 (unless (memq (gnus-data-number (car data))
6335 ((eq gnus-auto-goto-ignores
6336 'always-undownloaded)
6337 gnus-newsgroup-undownloaded)
6340 ((eq gnus-auto-goto-ignores
6342 gnus-newsgroup-unfetched)
6343 ((eq gnus-auto-goto-ignores
6345 gnus-newsgroup-undownloaded)))
6346 (when (gnus-data-unread-p (car data))
6347 (setq result (car data)
6349 (setq data (cdr data)))
6352 (goto-char (gnus-data-pos result))
6353 (gnus-data-number result))))
6355 (defun gnus-summary-find-subject (subject &optional unread backward article)
6356 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6357 (article (or article (gnus-summary-article-number)))
6358 (articles (gnus-data-list backward))
6359 (arts (gnus-data-find-list article articles))
6361 (when (or (not gnus-summary-check-current)
6363 (not (gnus-data-unread-p (car arts))))
6364 (setq arts (cdr arts)))
6366 (and (or (not unread)
6367 (gnus-data-unread-p (car arts)))
6368 (vectorp (gnus-data-header (car arts)))
6370 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6371 (setq result (car arts)
6373 (setq arts (cdr arts)))
6375 (goto-char (gnus-data-pos result))
6376 (gnus-data-number result))))
6378 (defun gnus-summary-search-forward (&optional unread subject backward)
6379 "Search forward for an article.
6380 If UNREAD, look for unread articles. If SUBJECT, look for
6381 articles with that subject. If BACKWARD, search backward instead."
6382 (cond (subject (gnus-summary-find-subject subject unread backward))
6383 (backward (gnus-summary-find-prev unread))
6384 (t (gnus-summary-find-next unread))))
6386 (defun gnus-recenter (&optional n)
6387 "Center point in window and redisplay frame.
6388 Also do horizontal recentering."
6390 (when (and gnus-auto-center-summary
6391 (not (eq gnus-auto-center-summary 'vertical)))
6392 (gnus-horizontal-recenter))
6395 (defun gnus-summary-recenter ()
6396 "Center point in the summary window.
6397 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6398 displayed, no centering will be performed."
6399 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6400 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6402 ;; The user has to want it.
6403 (when gnus-auto-center-summary
6404 (let* ((top (cond ((< (window-height) 4) 0)
6405 ((< (window-height) 7) 1)
6406 (t (if (numberp gnus-auto-center-summary)
6407 gnus-auto-center-summary
6408 (/ (1- (window-height)) 2)))))
6409 (height (1- (window-height)))
6410 (bottom (save-excursion (goto-char (point-max))
6411 (forward-line (- height))
6413 (window (get-buffer-window (current-buffer))))
6414 (when (get-buffer-window gnus-article-buffer)
6415 ;; Only do recentering when the article buffer is displayed,
6416 ;; Set the window start to either `bottom', which is the biggest
6417 ;; possible valid number, or the second line from the top,
6418 ;; whichever is the least.
6419 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6420 (if (> bottom top-pos)
6421 ;; Keep the second line from the top visible
6422 (set-window-start window top-pos t)
6423 ;; Try to keep the bottom line visible; if it's partially
6424 ;; obscured, either scroll one more line to make it fully
6425 ;; visible, or revert to using TOP-POS.
6427 (goto-char (point-max))
6429 (let ((last-line-start (point)))
6431 (set-window-start window (point) t)
6432 (when (not (pos-visible-in-window-p last-line-start window))
6434 (set-window-start window (min (point) top-pos) t)))))))
6435 ;; Do horizontal recentering while we're at it.
6436 (when (and (get-buffer-window (current-buffer) t)
6437 (not (eq gnus-auto-center-summary 'vertical)))
6438 (let ((selected (selected-window)))
6439 (select-window (get-buffer-window (current-buffer) t))
6440 (gnus-summary-position-point)
6441 (gnus-horizontal-recenter)
6442 (select-window selected))))))
6444 (defun gnus-summary-jump-to-group (newsgroup)
6445 "Move point to NEWSGROUP in group mode buffer."
6446 ;; Keep update point of group mode buffer if visible.
6447 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6448 (save-window-excursion
6449 ;; Take care of tree window mode.
6450 (when (get-buffer-window gnus-group-buffer)
6451 (pop-to-buffer gnus-group-buffer))
6452 (gnus-group-jump-to-group newsgroup))
6454 ;; Take care of tree window mode.
6455 (if (get-buffer-window gnus-group-buffer)
6456 (pop-to-buffer gnus-group-buffer)
6457 (set-buffer gnus-group-buffer))
6458 (gnus-group-jump-to-group newsgroup))))
6460 ;; This function returns a list of article numbers based on the
6461 ;; difference between the ranges of read articles in this group and
6462 ;; the range of active articles.
6463 (defun gnus-list-of-unread-articles (group)
6464 (let* ((read (gnus-info-read (gnus-get-info group)))
6465 (active (or (gnus-active group) (gnus-activate-group group)))
6466 (last (or (cdr active)
6467 (error "Group %s couldn't be activated " group)))
6469 ;; If none are read, then all are unread.
6471 (setq first (car active))
6472 ;; If the range of read articles is a single range, then the
6473 ;; first unread article is the article after the last read
6474 ;; article. Sounds logical, doesn't it?
6475 (if (and (not (listp (cdr read)))
6476 (or (< (car read) (car active))
6477 (progn (setq read (list read))
6479 (setq first (max (car active) (1+ (cdr read))))
6480 ;; `read' is a list of ranges.
6481 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6484 (setq first (car active)))
6487 (while (< first nlast)
6488 (setq unread (cons first unread)
6490 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6491 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6492 (setq read (cdr read)))))
6493 ;; And add the last unread articles.
6494 (while (<= first last)
6495 (setq unread (cons first unread)
6497 ;; Return the list of unread articles.
6498 (delq 0 (nreverse unread))))
6500 (defun gnus-list-of-read-articles (group)
6501 "Return a list of unread, unticked and non-dormant articles."
6502 (let* ((info (gnus-get-info group))
6503 (marked (gnus-info-marks info))
6504 (active (gnus-active group)))
6506 (gnus-list-range-difference
6507 (gnus-list-range-difference
6508 (gnus-sorted-complement
6509 (gnus-uncompress-range active)
6510 (gnus-list-of-unread-articles group))
6511 (cdr (assq 'dormant marked)))
6512 (cdr (assq 'tick marked))))))
6514 ;; This function returns a sequence of article numbers based on the
6515 ;; difference between the ranges of read articles in this group and
6516 ;; the range of active articles.
6517 (defun gnus-sequence-of-unread-articles (group)
6518 (let* ((read (gnus-info-read (gnus-get-info group)))
6519 (active (or (gnus-active group) (gnus-activate-group group)))
6522 ;; If none are read, then all are unread.
6524 (setq first (car active))
6525 ;; If the range of read articles is a single range, then the
6526 ;; first unread article is the article after the last read
6527 ;; article. Sounds logical, doesn't it?
6528 (if (and (not (listp (cdr read)))
6529 (or (< (car read) (car active))
6530 (progn (setq read (list read))
6532 (setq first (max (car active) (1+ (cdr read))))
6533 ;; `read' is a list of ranges.
6534 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6537 (setq first (car active)))
6540 (push (cons first nlast) unread))
6541 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6542 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6543 (setq read (cdr read)))))
6544 ;; And add the last unread articles.
6545 (cond ((< first last)
6546 (push (cons first last) unread))
6548 (push first unread)))
6549 ;; Return the sequence of unread articles.
6550 (delq 0 (nreverse unread))))
6552 ;; Various summary commands
6554 (defun gnus-summary-select-article-buffer ()
6555 "Reconfigure windows to show article buffer."
6557 (if (not (gnus-buffer-live-p gnus-article-buffer))
6558 (error "There is no article buffer for this summary buffer")
6559 (gnus-configure-windows 'article)
6560 (select-window (get-buffer-window gnus-article-buffer))))
6562 (defun gnus-summary-universal-argument (arg)
6563 "Perform any operation on all articles that are process/prefixed."
6565 (let ((articles (gnus-summary-work-articles arg))
6572 (substitute-command-keys
6573 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6575 (gnus-error 1 "Undefined key")
6578 (gnus-summary-goto-subject (setq article (pop articles)))
6579 (let (gnus-newsgroup-processable)
6580 (command-execute func))
6581 (gnus-summary-remove-process-mark article)))))
6582 (gnus-summary-position-point))
6584 (defun gnus-summary-toggle-truncation (&optional arg)
6585 "Toggle truncation of summary lines.
6586 With ARG, turn line truncation on if ARG is positive."
6588 (setq truncate-lines
6589 (if (null arg) (not truncate-lines)
6590 (> (prefix-numeric-value arg) 0)))
6593 (defun gnus-summary-find-for-reselect ()
6594 "Return the number of an article to stay on across a reselect.
6595 The current article is considered, then following articles, then previous
6596 articles. An article is sought which is not cancelled and isn't a temporary
6597 insertion from another group. If there's no such then return a dummy 0."
6599 (dolist (rev '(nil t))
6600 (unless found ; don't demand the reverse list if we don't need it
6601 (let ((data (gnus-data-find-list
6602 (gnus-summary-article-number) (gnus-data-list rev))))
6603 (while (and data (not found))
6604 (if (and (< 0 (gnus-data-number (car data)))
6605 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6606 (setq found (gnus-data-number (car data))))
6607 (setq data (cdr data))))))
6610 (defun gnus-summary-reselect-current-group (&optional all rescan)
6611 "Exit and then reselect the current newsgroup.
6612 The prefix argument ALL means to select all articles."
6614 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6615 (error "Ephemeral groups can't be reselected"))
6616 (let ((current-subject (gnus-summary-find-for-reselect))
6617 (group gnus-newsgroup-name))
6618 (setq gnus-newsgroup-begin nil)
6619 (gnus-summary-exit nil 'leave-hidden)
6620 ;; We have to adjust the point of group mode buffer because
6621 ;; point was moved to the next unread newsgroup by exiting.
6622 (gnus-summary-jump-to-group group)
6625 (gnus-group-get-new-news-this-group 1)))
6626 (gnus-group-read-group all t)
6627 (gnus-summary-goto-subject current-subject nil t)))
6629 (defun gnus-summary-rescan-group (&optional all)
6630 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6632 (gnus-summary-reselect-current-group all t))
6634 (defun gnus-summary-update-info (&optional non-destructive)
6636 (let ((group gnus-newsgroup-name))
6638 (when gnus-newsgroup-kill-headers
6639 (setq gnus-newsgroup-killed
6640 (gnus-compress-sequence
6642 (gnus-list-range-intersection
6643 gnus-newsgroup-unselected gnus-newsgroup-killed)
6644 gnus-newsgroup-unreads)
6646 (unless (listp (cdr gnus-newsgroup-killed))
6647 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6648 (let ((headers gnus-newsgroup-headers))
6649 ;; Set the new ranges of read articles.
6650 (with-current-buffer gnus-group-buffer
6651 (gnus-undo-force-boundary))
6652 (gnus-update-read-articles
6653 group (gnus-sorted-union
6654 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6655 ;; Set the current article marks.
6656 (let ((gnus-newsgroup-scored
6657 (if (and (not gnus-save-score)
6658 (not non-destructive))
6660 gnus-newsgroup-scored)))
6662 (gnus-update-marks)))
6663 ;; Do the cross-ref thing.
6664 (when gnus-use-cross-reference
6665 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6666 ;; Do not switch windows but change the buffer to work.
6667 (set-buffer gnus-group-buffer)
6668 (unless (gnus-ephemeral-group-p group)
6669 (gnus-group-update-group group)))))))
6671 (defun gnus-summary-save-newsrc (&optional force)
6672 "Save the current number of read/marked articles in the dribble buffer.
6673 The dribble buffer will then be saved.
6674 If FORCE (the prefix), also save the .newsrc file(s)."
6676 (gnus-summary-update-info t)
6678 (gnus-save-newsrc-file)
6679 (gnus-dribble-save)))
6681 (defun gnus-summary-exit (&optional temporary leave-hidden)
6682 "Exit reading current newsgroup, and then return to group selection mode.
6683 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6685 (gnus-set-global-variables)
6686 (when (gnus-buffer-live-p gnus-article-buffer)
6688 (set-buffer gnus-article-buffer)
6689 (mm-destroy-parts gnus-article-mime-handles)
6690 ;; Set it to nil for safety reason.
6691 (setq gnus-article-mime-handle-alist nil)
6692 (setq gnus-article-mime-handles nil)))
6693 (gnus-kill-save-kill-buffer)
6694 (gnus-async-halt-prefetch)
6695 (let* ((group gnus-newsgroup-name)
6696 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6697 (gnus-group-is-exiting-p t)
6700 (buf (current-buffer)))
6702 ;; Do adaptive scoring, and possibly save score files.
6703 (when gnus-newsgroup-adaptive
6704 (gnus-score-adaptive))
6705 (when gnus-use-scoring
6707 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6708 ;; If we have several article buffers, we kill them at exit.
6709 (unless gnus-single-article-buffer
6710 (gnus-kill-buffer gnus-original-article-buffer)
6711 (setq gnus-article-current nil))
6712 (when gnus-use-cache
6713 (gnus-cache-possibly-remove-articles)
6714 (gnus-cache-save-buffers))
6715 (gnus-async-prefetch-remove-group group)
6716 (when gnus-suppress-duplicates
6717 (gnus-dup-enter-articles))
6718 (when gnus-use-trees
6719 (gnus-tree-close group))
6720 (when gnus-use-cache
6721 (gnus-cache-write-active))
6722 ;; Remove entries for this group.
6723 (nnmail-purge-split-history (gnus-group-real-name group))
6724 ;; Make all changes in this group permanent.
6726 (gnus-run-hooks 'gnus-exit-group-hook)
6727 (gnus-summary-update-info))
6728 (gnus-close-group group)
6729 ;; Make sure where we were, and go to next newsgroup.
6730 (set-buffer gnus-group-buffer)
6732 (gnus-group-jump-to-group group))
6733 (gnus-run-hooks 'gnus-summary-exit-hook)
6734 (unless (or quit-config
6735 ;; If this group has disappeared from the summary
6736 ;; buffer, don't skip forwards.
6737 (not (string= group (gnus-group-group-name))))
6738 (gnus-group-next-unread-group 1))
6739 (setq group-point (point))
6742 ;; If we have several article buffers, we kill them at exit.
6743 (unless gnus-single-article-buffer
6744 (gnus-kill-buffer gnus-article-buffer)
6745 (gnus-kill-buffer gnus-original-article-buffer)
6746 (setq gnus-article-current nil))
6748 (if (not gnus-kill-summary-on-exit)
6750 (gnus-deaden-summary)
6752 ;; We set all buffer-local variables to nil. It is unclear why
6753 ;; this is needed, but if we don't, buffer-local variables are
6754 ;; not garbage-collected, it seems. This would the lead to en
6755 ;; ever-growing Emacs.
6756 (gnus-summary-clear-local-variables)
6757 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6758 (gnus-summary-clear-local-variables))
6759 (when (get-buffer gnus-article-buffer)
6760 (bury-buffer gnus-article-buffer))
6761 ;; Return to group mode buffer.
6762 (when (eq mode 'gnus-summary-mode)
6763 (gnus-kill-buffer buf)))
6764 (setq gnus-current-select-method gnus-select-method)
6765 (set-buffer gnus-group-buffer)
6767 (gnus-handle-ephemeral-exit quit-config)
6768 (goto-char group-point)
6769 ;; If gnus-group-buffer is already displayed, make sure we also move
6770 ;; the cursor in the window that displays it.
6771 (let ((win (get-buffer-window (current-buffer) 0)))
6772 (if win (set-window-point win (point))))
6773 (unless leave-hidden
6774 (gnus-configure-windows 'group 'force)))
6775 ;; Clear the current group name.
6777 (setq gnus-newsgroup-name nil)))))
6779 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6780 (defun gnus-summary-exit-no-update (&optional no-questions)
6781 "Quit reading current newsgroup without updating read article info."
6783 (let* ((group gnus-newsgroup-name)
6784 (gnus-group-is-exiting-p t)
6785 (gnus-group-is-exiting-without-update-p t)
6786 (quit-config (gnus-group-quit-config group)))
6787 (when (or no-questions
6789 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6790 (gnus-async-halt-prefetch)
6791 (run-hooks 'gnus-summary-prepare-exit-hook)
6792 (when (gnus-buffer-live-p gnus-article-buffer)
6794 (set-buffer gnus-article-buffer)
6795 (mm-destroy-parts gnus-article-mime-handles)
6796 ;; Set it to nil for safety reason.
6797 (setq gnus-article-mime-handle-alist nil)
6798 (setq gnus-article-mime-handles nil)))
6799 ;; If we have several article buffers, we kill them at exit.
6800 (unless gnus-single-article-buffer
6801 (gnus-kill-buffer gnus-article-buffer)
6802 (gnus-kill-buffer gnus-original-article-buffer)
6803 (setq gnus-article-current nil))
6804 (if (not gnus-kill-summary-on-exit)
6805 (gnus-deaden-summary)
6806 (gnus-close-group group)
6807 (gnus-summary-clear-local-variables)
6808 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6809 (gnus-summary-clear-local-variables))
6810 (gnus-kill-buffer gnus-summary-buffer))
6811 (unless gnus-single-article-buffer
6812 (setq gnus-article-current nil))
6813 (when gnus-use-trees
6814 (gnus-tree-close group))
6815 (gnus-async-prefetch-remove-group group)
6816 (when (get-buffer gnus-article-buffer)
6817 (bury-buffer gnus-article-buffer))
6818 ;; Return to the group buffer.
6819 (gnus-configure-windows 'group 'force)
6820 ;; Clear the current group name.
6821 (setq gnus-newsgroup-name nil)
6822 (unless (gnus-ephemeral-group-p group)
6823 (gnus-group-update-group group))
6824 (when (equal (gnus-group-group-name) group)
6825 (gnus-group-next-unread-group 1))
6827 (gnus-handle-ephemeral-exit quit-config)))))
6829 (defun gnus-handle-ephemeral-exit (quit-config)
6830 "Handle movement when leaving an ephemeral group.
6831 The state which existed when entering the ephemeral is reset."
6832 (if (not (buffer-name (car quit-config)))
6833 (gnus-configure-windows 'group 'force)
6834 (set-buffer (car quit-config))
6835 (cond ((eq major-mode 'gnus-summary-mode)
6836 (gnus-set-global-variables))
6837 ((eq major-mode 'gnus-article-mode)
6839 ;; The `gnus-summary-buffer' variable may point
6840 ;; to the old summary buffer when using a single
6842 (unless (gnus-buffer-live-p gnus-summary-buffer)
6843 (set-buffer gnus-group-buffer))
6844 (set-buffer gnus-summary-buffer)
6845 (gnus-set-global-variables))))
6846 (if (or (eq (cdr quit-config) 'article)
6847 (eq (cdr quit-config) 'pick))
6849 ;; The current article may be from the ephemeral group
6850 ;; thus it is best that we reload this article
6852 ;; If we're exiting from a large digest, this can be
6853 ;; extremely slow. So, it's better not to reload it. -- jh.
6854 ;;(gnus-summary-show-article)
6855 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6856 (gnus-configure-windows 'pick 'force)
6857 (gnus-configure-windows (cdr quit-config) 'force)))
6858 (gnus-configure-windows (cdr quit-config) 'force))
6859 (when (eq major-mode 'gnus-summary-mode)
6860 (gnus-summary-next-subject 1 nil t)
6861 (gnus-summary-recenter)
6862 (gnus-summary-position-point))))
6866 (defvar gnus-dead-summary-mode-map nil)
6868 (unless gnus-dead-summary-mode-map
6869 (setq gnus-dead-summary-mode-map (make-keymap))
6870 (suppress-keymap gnus-dead-summary-mode-map)
6871 (substitute-key-definition
6872 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6873 (dolist (key '("\C-d" "\r" "\177" [delete]))
6874 (define-key gnus-dead-summary-mode-map
6875 key 'gnus-summary-wake-up-the-dead))
6876 (dolist (key '("q" "Q"))
6877 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6879 (defvar gnus-dead-summary-mode nil
6880 "Minor mode for Gnus summary buffers.")
6882 (defun gnus-dead-summary-mode (&optional arg)
6883 "Minor mode for Gnus summary buffers."
6885 (when (eq major-mode 'gnus-summary-mode)
6886 (make-local-variable 'gnus-dead-summary-mode)
6887 (setq gnus-dead-summary-mode
6888 (if (null arg) (not gnus-dead-summary-mode)
6889 (> (prefix-numeric-value arg) 0)))
6890 (when gnus-dead-summary-mode
6892 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6894 (defun gnus-deaden-summary ()
6895 "Make the current summary buffer into a dead summary buffer."
6896 ;; Kill any previous dead summary buffer.
6897 (when (and gnus-dead-summary
6898 (buffer-name gnus-dead-summary))
6899 (with-current-buffer gnus-dead-summary
6900 (when gnus-dead-summary-mode
6901 (kill-buffer (current-buffer)))))
6902 ;; Make this the current dead summary.
6903 (setq gnus-dead-summary (current-buffer))
6904 (gnus-dead-summary-mode 1)
6905 (let ((name (buffer-name)))
6906 (when (string-match "Summary" name)
6908 (concat (substring name 0 (match-beginning 0)) "Dead "
6909 (substring name (match-beginning 0)))
6913 (defun gnus-kill-or-deaden-summary (buffer)
6914 "Kill or deaden the summary BUFFER."
6916 (when (and (buffer-name buffer)
6917 (not gnus-single-article-buffer))
6918 (with-current-buffer buffer
6919 (gnus-kill-buffer gnus-article-buffer)
6920 (gnus-kill-buffer gnus-original-article-buffer)))
6923 (gnus-kill-summary-on-exit
6924 (when (and gnus-use-trees
6925 (gnus-buffer-exists-p buffer))
6928 (gnus-tree-close gnus-newsgroup-name)))
6929 (gnus-kill-buffer buffer))
6930 ;; Deaden the buffer.
6931 ((gnus-buffer-exists-p buffer)
6934 (gnus-deaden-summary))))))
6936 (defun gnus-summary-wake-up-the-dead (&rest args)
6937 "Wake up the dead summary buffer."
6939 (gnus-dead-summary-mode -1)
6940 (let ((name (buffer-name)))
6941 (when (string-match "Dead " name)
6943 (concat (substring name 0 (match-beginning 0))
6944 (substring name (match-end 0)))
6946 (gnus-message 3 "This dead summary is now alive again"))
6948 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6949 (defun gnus-summary-fetch-faq (&optional faq-dir)
6950 "Fetch the FAQ for the current group.
6951 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6955 (when current-prefix-arg
6957 "FAQ dir: " (and (listp gnus-group-faq-directory)
6959 gnus-group-faq-directory))))))
6960 (let (gnus-faq-buffer)
6961 (when (setq gnus-faq-buffer
6962 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6963 (gnus-configure-windows 'summary-faq))))
6965 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6966 (defun gnus-summary-describe-group (&optional force)
6967 "Describe the current newsgroup."
6969 (gnus-group-describe-group force gnus-newsgroup-name))
6971 (defun gnus-summary-describe-briefly ()
6972 "Describe summary mode commands briefly."
6974 (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")))
6976 ;; Walking around group mode buffer from summary mode.
6978 (defun gnus-summary-next-group (&optional no-article target-group backward)
6979 "Exit current newsgroup and then select next unread newsgroup.
6980 If prefix argument NO-ARTICLE is non-nil, no article is selected
6981 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6982 previous group instead."
6984 ;; Stop pre-fetching.
6985 (gnus-async-halt-prefetch)
6986 (let ((current-group gnus-newsgroup-name)
6987 (current-buffer (current-buffer))
6989 ;; First we semi-exit this group to update Xrefs and all variables.
6990 ;; We can't do a real exit, because the window conf must remain
6991 ;; the same in case the user is prompted for info, and we don't
6992 ;; want the window conf to change before that...
6993 (gnus-summary-exit t)
6994 (while (not entered)
6995 ;; Then we find what group we are supposed to enter.
6996 (set-buffer gnus-group-buffer)
6997 (gnus-group-jump-to-group current-group)
7000 (if (eq gnus-keep-same-level 'best)
7001 (gnus-summary-best-group gnus-newsgroup-name)
7002 (gnus-summary-search-group backward gnus-keep-same-level))))
7003 (if (not target-group)
7004 ;; There are no further groups, so we return to the group
7007 (gnus-message 5 "Returning to the group buffer")
7009 (when (gnus-buffer-live-p current-buffer)
7010 (set-buffer current-buffer)
7011 (gnus-summary-exit))
7012 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7013 ;; We try to enter the target group.
7014 (gnus-group-jump-to-group target-group)
7015 (let ((unreads (gnus-group-group-unread)))
7016 (if (and (or (eq t unreads)
7017 (and unreads (not (zerop unreads))))
7018 (gnus-summary-read-group
7019 target-group nil no-article
7020 (and (buffer-name current-buffer) current-buffer)
7023 (setq current-group target-group
7024 target-group nil)))))))
7026 (defun gnus-summary-prev-group (&optional no-article)
7027 "Exit current newsgroup and then select previous unread newsgroup.
7028 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7030 (gnus-summary-next-group no-article nil t))
7032 ;; Walking around summary lines.
7034 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7035 "Go to the first subject satisfying any non-nil constraint.
7036 If UNREAD is non-nil, the article should be unread.
7037 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7038 If UNSEEN is non-nil, the article should be unseen.
7039 Returns the article selected or nil if there are no matching articles."
7043 ((null gnus-newsgroup-data)
7044 (gnus-message 3 "No articles in the group")
7046 ;; Pick the first article.
7047 ((not (or unread undownloaded unseen))
7048 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7049 (gnus-data-number (car gnus-newsgroup-data)))
7050 ;; Find the first unread article.
7052 (let ((data gnus-newsgroup-data))
7054 (let ((num (gnus-data-number (car data))))
7055 (or (memq num gnus-newsgroup-unfetched)
7056 (not (or (and unread
7057 (memq num gnus-newsgroup-unreads))
7059 (memq num gnus-newsgroup-undownloaded))
7061 (memq num gnus-newsgroup-unseen)))))))
7062 (setq data (cdr data)))
7066 (goto-char (gnus-data-pos (car data)))
7067 (gnus-data-number (car data)))
7068 (gnus-message 3 "No more%s articles"
7069 (let* ((r (when unread " unread"))
7070 (d (when undownloaded " undownloaded"))
7071 (s (when unseen " unseen"))
7072 (l (delq nil (list r d s))))
7073 (cond ((= 3 (length l))
7074 (concat r "," d ", or" s))
7076 (concat (car l) ", or" (cadr l)))
7083 (gnus-summary-position-point))))))
7085 (defun gnus-summary-next-subject (n &optional unread dont-display)
7086 "Go to next N'th summary line.
7087 If N is negative, go to the previous N'th subject line.
7088 If UNREAD is non-nil, only unread articles are selected.
7089 The difference between N and the actual number of steps taken is
7092 (let ((backward (< n 0))
7096 (gnus-summary-find-prev unread)
7097 (gnus-summary-find-next unread)))
7098 (unless (zerop (setq n (1- n)))
7099 (gnus-summary-show-thread)))
7101 (gnus-message 7 "No more%s articles"
7102 (if unread " unread" "")))
7103 (unless dont-display
7104 (gnus-summary-recenter)
7105 (gnus-summary-position-point))
7108 (defun gnus-summary-next-unread-subject (n)
7109 "Go to next N'th unread summary line."
7111 (gnus-summary-next-subject n t))
7113 (defun gnus-summary-prev-subject (n &optional unread)
7114 "Go to previous N'th summary line.
7115 If optional argument UNREAD is non-nil, only unread article is selected."
7117 (gnus-summary-next-subject (- n) unread))
7119 (defun gnus-summary-prev-unread-subject (n)
7120 "Go to previous N'th unread summary line."
7122 (gnus-summary-next-subject (- n) t))
7124 (defun gnus-summary-goto-subjects (articles)
7125 "Insert the subject header for ARTICLES in the current buffer."
7127 (dolist (article articles)
7128 (gnus-summary-goto-subject article t)))
7129 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7130 (gnus-summary-position-point))
7132 (defun gnus-summary-goto-subject (article &optional force silent)
7133 "Go the subject line of ARTICLE.
7134 If FORCE, also allow jumping to articles not currently shown."
7135 (interactive "nArticle number: ")
7136 (unless (numberp article)
7137 (error "Article %s is not a number" article))
7139 (data (gnus-data-find article)))
7140 ;; We read in the article if we have to.
7143 (gnus-summary-insert-subject
7145 (if (or (numberp force) (vectorp force)) force)
7147 (setq data (gnus-data-find article)))
7152 (gnus-message 3 "Can't find article %d" article))
7154 (let ((pt (gnus-data-pos data)))
7156 (gnus-summary-set-article-display-arrow pt))
7157 (gnus-summary-position-point)
7160 ;; Walking around summary lines with displaying articles.
7162 (defun gnus-summary-expand-window (&optional arg)
7163 "Make the summary buffer take up the entire Emacs frame.
7164 Given a prefix, will force an `article' buffer configuration."
7167 (gnus-configure-windows 'article 'force)
7168 (gnus-configure-windows 'summary 'force)))
7170 (defun gnus-summary-display-article (article &optional all-header)
7171 "Display ARTICLE in article buffer."
7172 (when (gnus-buffer-live-p gnus-article-buffer)
7173 (with-current-buffer gnus-article-buffer
7174 (mm-enable-multibyte)))
7175 (gnus-set-global-variables)
7176 (when (gnus-buffer-live-p gnus-article-buffer)
7177 (with-current-buffer gnus-article-buffer
7178 (setq gnus-article-charset gnus-newsgroup-charset)
7179 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7180 (mm-enable-multibyte)))
7184 (if gnus-summary-display-article-function
7185 (funcall gnus-summary-display-article-function article all-header)
7186 (gnus-article-prepare article all-header))
7187 (gnus-run-hooks 'gnus-select-article-hook)
7188 (when (and gnus-current-article
7189 (not (zerop gnus-current-article)))
7190 (gnus-summary-goto-subject gnus-current-article))
7191 (gnus-summary-recenter)
7192 (when (and gnus-use-trees gnus-show-threads)
7193 (gnus-possibly-generate-tree article)
7194 (gnus-highlight-selected-tree article))
7195 ;; Successfully display article.
7196 (gnus-article-set-window-start
7197 (cdr (assq article gnus-newsgroup-bookmarks))))))
7199 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7200 "Select the current article.
7201 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7202 non-nil, the article will be re-fetched even if it already present in
7203 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7205 ;; Make sure we are in the summary buffer to work around bbdb bug.
7206 (unless (eq major-mode 'gnus-summary-mode)
7207 (set-buffer gnus-summary-buffer))
7208 (let ((article (or article (gnus-summary-article-number)))
7209 (all-headers (not (not all-headers))) ;Must be t or nil.
7210 gnus-summary-display-article-function)
7212 (gnus-summary-article-pseudo-p article)
7213 (error "This is a pseudo-article"))
7215 (set-buffer gnus-summary-buffer)
7216 (if (or (and gnus-single-article-buffer
7217 (or (null gnus-current-article)
7218 (null gnus-article-current)
7219 (null (get-buffer gnus-article-buffer))
7220 (not (eq article (cdr gnus-article-current)))
7221 (not (equal (car gnus-article-current)
7222 gnus-newsgroup-name))))
7223 (and (not gnus-single-article-buffer)
7224 (or (null gnus-current-article)
7225 (not (eq gnus-current-article article))))
7227 ;; The requested article is different from the current article.
7229 (gnus-summary-display-article article all-headers)
7230 (when (gnus-buffer-live-p gnus-article-buffer)
7231 (with-current-buffer gnus-article-buffer
7232 (if (not gnus-article-decoded-p) ;; a local variable
7233 (mm-disable-multibyte))))
7234 (gnus-article-set-window-start
7235 (cdr (assq article gnus-newsgroup-bookmarks)))
7239 (defun gnus-summary-force-verify-and-decrypt ()
7240 "Display buttons for signed/encrypted parts and verify/decrypt them."
7242 (let ((mm-verify-option 'known)
7243 (mm-decrypt-option 'known)
7244 (gnus-article-emulate-mime t)
7245 (gnus-buttonized-mime-types (append (list "multipart/signed"
7246 "multipart/encrypted")
7247 gnus-buttonized-mime-types)))
7248 (gnus-summary-select-article nil 'force)))
7250 (defun gnus-summary-set-current-mark (&optional current-mark)
7251 "Obsolete function."
7254 (defun gnus-summary-next-article (&optional unread subject backward push)
7255 "Select the next article.
7256 If UNREAD, only unread articles are selected.
7257 If SUBJECT, only articles with SUBJECT are selected.
7258 If BACKWARD, the previous article is selected instead of the next."
7261 ;; Is there such an article?
7262 ((and (gnus-summary-search-forward unread subject backward)
7263 (or (gnus-summary-display-article (gnus-summary-article-number))
7264 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7265 (gnus-summary-position-point))
7266 ;; If not, we try the first unread, if that is wanted.
7268 gnus-auto-select-same
7269 (gnus-summary-first-unread-article))
7270 (gnus-summary-position-point)
7271 (gnus-message 6 "Wrapped"))
7272 ;; Try to get next/previous article not displayed in this group.
7273 ((and gnus-auto-extend-newsgroup
7274 (not unread) (not subject))
7275 (gnus-summary-goto-article
7276 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7277 nil (count-lines (point-min) (point))))
7278 ;; Go to next/previous group.
7280 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7281 (gnus-summary-jump-to-group gnus-newsgroup-name))
7282 (let ((cmd last-command-char)
7284 (with-current-buffer gnus-group-buffer
7287 (if (eq gnus-keep-same-level 'best)
7288 (gnus-summary-best-group gnus-newsgroup-name)
7289 (gnus-summary-search-group backward gnus-keep-same-level))))
7290 ;; For some reason, the group window gets selected. We change
7292 (select-window (get-buffer-window (current-buffer)))
7293 ;; Select next unread newsgroup automagically.
7295 ((or (not gnus-auto-select-next)
7297 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7298 ((or (eq gnus-auto-select-next 'quietly)
7299 (and (eq gnus-auto-select-next 'slightly-quietly)
7301 (and (eq gnus-auto-select-next 'almost-quietly)
7302 (gnus-summary-last-article-p)))
7304 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7306 (gnus-message 7 "No more%s articles (%s)..."
7307 (if unread " unread" "")
7308 (if group (concat "selecting " group)
7310 (gnus-summary-next-group nil group backward)))
7312 (when (gnus-key-press-event-p last-input-event)
7313 (gnus-summary-walk-group-buffer
7314 gnus-newsgroup-name cmd unread backward point))))))))
7316 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7317 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7318 (?\C-p (gnus-group-prev-unread-group 1))))
7319 (cursor-in-echo-area t)
7320 keve key group ended prompt)
7322 (set-buffer gnus-group-buffer)
7325 (if (eq gnus-keep-same-level 'best)
7326 (gnus-summary-best-group gnus-newsgroup-name)
7327 (gnus-summary-search-group backward gnus-keep-same-level))))
7331 "No more%s articles%s " (if unread " unread" "")
7333 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7334 (format " (Type %s for %s [%s])"
7335 (single-key-description cmd)
7336 (gnus-group-decoded-name group)
7337 (gnus-group-unread group))
7338 (format " (Type %s to exit %s)"
7339 (single-key-description cmd)
7340 (gnus-group-decoded-name gnus-newsgroup-name)))))
7341 ;; Confirm auto selection.
7342 (setq key (car (setq keve (gnus-read-event-char prompt)))
7345 ((assq key keystrokes)
7346 (let ((obuf (current-buffer)))
7347 (switch-to-buffer gnus-group-buffer)
7349 (gnus-group-jump-to-group group))
7350 (eval (cadr (assq key keystrokes)))
7351 (setq group (gnus-group-group-name))
7352 (switch-to-buffer obuf))
7356 (gnus-ephemeral-group-p gnus-newsgroup-name))
7358 (gnus-summary-next-group nil group backward)))
7360 (push (cdr keve) unread-command-events))))))
7362 (defun gnus-summary-next-unread-article ()
7363 "Select unread article after current one."
7365 (gnus-summary-next-article
7366 (or (not (eq gnus-summary-goto-unread 'never))
7367 (gnus-summary-last-article-p (gnus-summary-article-number)))
7368 (and gnus-auto-select-same
7369 (gnus-summary-article-subject))))
7371 (defun gnus-summary-prev-article (&optional unread subject)
7372 "Select the article after the current one.
7373 If UNREAD is non-nil, only unread articles are selected."
7375 (gnus-summary-next-article unread subject t))
7377 (defun gnus-summary-prev-unread-article ()
7378 "Select unread article before current one."
7380 (gnus-summary-prev-article
7381 (or (not (eq gnus-summary-goto-unread 'never))
7382 (gnus-summary-first-article-p (gnus-summary-article-number)))
7383 (and gnus-auto-select-same
7384 (gnus-summary-article-subject))))
7386 (defun gnus-summary-next-page (&optional lines circular stop)
7387 "Show next page of the selected article.
7388 If at the end of the current article, select the next article.
7389 LINES says how many lines should be scrolled up.
7391 If CIRCULAR is non-nil, go to the start of the article instead of
7392 selecting the next article when reaching the end of the current
7395 If STOP is non-nil, just stop when reaching the end of the message.
7397 Also see the variable `gnus-article-skip-boring'."
7399 (setq gnus-summary-buffer (current-buffer))
7400 (gnus-set-global-variables)
7401 (let ((article (gnus-summary-article-number))
7402 (article-window (get-buffer-window gnus-article-buffer t))
7404 ;; If the buffer is empty, we have no article.
7406 (error "No article to select"))
7407 (gnus-configure-windows 'article)
7408 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7409 (if (and (eq gnus-summary-goto-unread 'never)
7410 (not (gnus-summary-last-article-p article)))
7411 (gnus-summary-next-article)
7412 (gnus-summary-next-unread-article))
7413 (if (or (null gnus-current-article)
7414 (null gnus-article-current)
7415 (/= article (cdr gnus-article-current))
7416 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7417 ;; Selected subject is different from current article's.
7418 (gnus-summary-display-article article)
7419 (when article-window
7420 (gnus-eval-in-buffer-window gnus-article-buffer
7421 (setq endp (or (gnus-article-next-page lines)
7422 (gnus-article-only-boring-p))))
7425 (gnus-message 3 "End of message"))
7427 (gnus-summary-beginning-of-article))
7429 (gnus-message 3 "End of message"))
7431 (if (and (eq gnus-summary-goto-unread 'never)
7432 (not (gnus-summary-last-article-p article)))
7433 (gnus-summary-next-article)
7434 (gnus-summary-next-unread-article))))))))
7435 (gnus-summary-recenter)
7436 (gnus-summary-position-point)))
7438 (defun gnus-summary-prev-page (&optional lines move)
7439 "Show previous page of selected article.
7440 Argument LINES specifies lines to be scrolled down.
7441 If MOVE, move to the previous unread article if point is at
7442 the beginning of the buffer."
7444 (let ((article (gnus-summary-article-number))
7445 (article-window (get-buffer-window gnus-article-buffer t))
7447 (gnus-configure-windows 'article)
7448 (if (or (null gnus-current-article)
7449 (null gnus-article-current)
7450 (/= article (cdr gnus-article-current))
7451 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7452 ;; Selected subject is different from current article's.
7453 (gnus-summary-display-article article)
7454 (gnus-summary-recenter)
7455 (when article-window
7456 (gnus-eval-in-buffer-window gnus-article-buffer
7457 (setq endp (gnus-article-prev-page lines)))
7458 (when (and move endp)
7460 (gnus-message 3 "Beginning of message"))
7462 (if (and (eq gnus-summary-goto-unread 'never)
7463 (not (gnus-summary-first-article-p article)))
7464 (gnus-summary-prev-article)
7465 (gnus-summary-prev-unread-article))))))))
7466 (gnus-summary-position-point))
7468 (defun gnus-summary-prev-page-or-article (&optional lines)
7469 "Show previous page of selected article.
7470 Argument LINES specifies lines to be scrolled down.
7471 If at the beginning of the article, go to the next article."
7473 (gnus-summary-prev-page lines t))
7475 (defun gnus-summary-scroll-up (lines)
7476 "Scroll up (or down) one line current article.
7477 Argument LINES specifies lines to be scrolled up (or down if negative)."
7479 (gnus-configure-windows 'article)
7480 (gnus-summary-show-thread)
7481 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7482 (gnus-eval-in-buffer-window gnus-article-buffer
7484 (when (gnus-article-next-page lines)
7485 (gnus-message 3 "End of message")))
7487 (gnus-article-prev-page (- lines))))))
7488 (gnus-summary-recenter)
7489 (gnus-summary-position-point))
7491 (defun gnus-summary-scroll-down (lines)
7492 "Scroll down (or up) one line current article.
7493 Argument LINES specifies lines to be scrolled down (or up if negative)."
7495 (gnus-summary-scroll-up (- lines)))
7497 (defun gnus-summary-next-same-subject ()
7498 "Select next article which has the same subject as current one."
7500 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7502 (defun gnus-summary-prev-same-subject ()
7503 "Select previous article which has the same subject as current one."
7505 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7507 (defun gnus-summary-next-unread-same-subject ()
7508 "Select next unread article which has the same subject as current one."
7510 (gnus-summary-next-article t (gnus-summary-article-subject)))
7512 (defun gnus-summary-prev-unread-same-subject ()
7513 "Select previous unread article which has the same subject as current one."
7515 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7517 (defun gnus-summary-first-unread-article ()
7518 "Select the first unread article.
7519 Return nil if there are no unread articles."
7522 (when (gnus-summary-first-subject t)
7523 (gnus-summary-show-thread)
7524 (gnus-summary-first-subject t)
7525 (gnus-summary-display-article (gnus-summary-article-number)))
7526 (gnus-summary-position-point)))
7528 (defun gnus-summary-first-unread-subject ()
7529 "Place the point on the subject line of the first unread article.
7530 Return nil if there are no unread articles."
7533 (when (gnus-summary-first-subject t)
7534 (gnus-summary-show-thread)
7535 (gnus-summary-first-subject t))
7536 (gnus-summary-position-point)))
7538 (defun gnus-summary-first-unseen-subject ()
7539 "Place the point on the subject line of the first unseen article.
7540 Return nil if there are no unseen articles."
7543 (when (gnus-summary-first-subject nil nil t)
7544 (gnus-summary-show-thread)
7545 (gnus-summary-first-subject nil nil t))
7546 (gnus-summary-position-point)))
7548 (defun gnus-summary-first-unseen-or-unread-subject ()
7549 "Place the point on the subject line of the first unseen article or,
7550 if all article have been seen, on the subject line of the first unread
7554 (unless (when (gnus-summary-first-subject nil nil t)
7555 (gnus-summary-show-thread)
7556 (gnus-summary-first-subject nil nil t))
7557 (when (gnus-summary-first-subject t)
7558 (gnus-summary-show-thread)
7559 (gnus-summary-first-subject t)))
7560 (gnus-summary-position-point)))
7562 (defun gnus-summary-first-article ()
7563 "Select the first article.
7564 Return nil if there are no articles."
7567 (when (gnus-summary-first-subject)
7568 (gnus-summary-show-thread)
7569 (gnus-summary-first-subject)
7570 (gnus-summary-display-article (gnus-summary-article-number)))
7571 (gnus-summary-position-point)))
7573 (defun gnus-summary-best-unread-article (&optional arg)
7574 "Select the unread article with the highest score.
7575 If given a prefix argument, select the next unread article that has a
7576 score higher than the default score."
7578 (let ((article (if arg
7579 (gnus-summary-better-unread-subject)
7580 (gnus-summary-best-unread-subject))))
7582 (gnus-summary-goto-article article)
7583 (error "No unread articles"))))
7585 (defun gnus-summary-best-unread-subject ()
7586 "Select the unread subject with the highest score."
7588 (let ((best -1000000)
7589 (data gnus-newsgroup-data)
7592 (and (gnus-data-unread-p (car data))
7594 (gnus-summary-article-score (gnus-data-number (car data))))
7597 article (gnus-data-number (car data))))
7598 (setq data (cdr data)))
7600 (gnus-summary-goto-subject article))
7601 (gnus-summary-position-point)
7604 (defun gnus-summary-better-unread-subject ()
7605 "Select the first unread subject that has a score over the default score."
7607 (let ((data gnus-newsgroup-data)
7609 (while (and (setq article (gnus-data-number (car data)))
7610 (or (gnus-data-read-p (car data))
7611 (not (> (gnus-summary-article-score article)
7612 gnus-summary-default-score))))
7613 (setq data (cdr data)))
7615 (gnus-summary-goto-subject article))
7616 (gnus-summary-position-point)
7619 (defun gnus-summary-last-subject ()
7620 "Go to the last displayed subject line in the group."
7621 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7623 (gnus-summary-goto-subject article))))
7625 (defun gnus-summary-goto-article (article &optional all-headers force)
7626 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7627 If ALL-HEADERS is non-nil, no header lines are hidden.
7628 If FORCE, go to the article even if it isn't displayed. If FORCE
7629 is a number, it is the line the article is to be displayed on."
7633 "Article number or Message-ID: "
7634 (mapcar (lambda (number) (list (int-to-string number)))
7635 gnus-newsgroup-limit))
7639 (if (and (stringp article)
7640 (string-match "@\\|%40" article))
7641 (gnus-summary-refer-article article)
7642 (when (stringp article)
7643 (setq article (string-to-number article)))
7644 (if (gnus-summary-goto-subject article force)
7645 (gnus-summary-display-article article all-headers)
7646 (gnus-message 4 "Couldn't go to article %s" article) nil))
7647 (gnus-summary-position-point)))
7649 (defun gnus-summary-goto-last-article ()
7650 "Go to the previously read article."
7653 (when gnus-last-article
7654 (gnus-summary-goto-article gnus-last-article nil t))
7655 (gnus-summary-position-point)))
7657 (defun gnus-summary-pop-article (number)
7658 "Pop one article off the history and go to the previous.
7659 NUMBER articles will be popped off."
7662 (setq gnus-newsgroup-history
7663 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7665 (gnus-summary-goto-article (car to) nil t)
7666 (error "Article history empty")))
7667 (gnus-summary-position-point))
7669 ;; Summary commands and functions for limiting the summary buffer.
7671 (defun gnus-summary-limit-to-articles (n)
7672 "Limit the summary buffer to the next N articles.
7673 If not given a prefix, use the process marked articles instead."
7676 (let ((articles (gnus-summary-work-articles n)))
7677 (setq gnus-newsgroup-processable nil)
7678 (gnus-summary-limit articles))
7679 (gnus-summary-position-point)))
7681 (defun gnus-summary-pop-limit (&optional total)
7682 "Restore the previous limit.
7683 If given a prefix, remove all limits."
7686 (setq gnus-newsgroup-limits
7687 (list (mapcar (lambda (h) (mail-header-number h))
7688 gnus-newsgroup-headers))))
7689 (unless gnus-newsgroup-limits
7690 (error "No limit to pop"))
7692 (gnus-summary-limit nil 'pop)
7693 (gnus-summary-position-point)))
7695 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7696 "Limit the summary buffer to articles that have subjects that match a regexp.
7697 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7699 (list (read-string (if current-prefix-arg
7700 "Exclude subject (regexp): "
7701 "Limit to subject (regexp): "))
7702 nil current-prefix-arg))
7704 (setq header "subject"))
7705 (when (not (equal "" subject))
7707 (let ((articles (gnus-summary-find-matching
7708 (or header "subject") subject 'all nil nil
7711 (error "Found no matches for \"%s\"" subject))
7712 (gnus-summary-limit articles))
7713 (gnus-summary-position-point))))
7715 (defun gnus-summary-limit-to-author (from &optional not-matching)
7716 "Limit the summary buffer to articles that have authors that match a regexp.
7717 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7719 (list (read-string (if current-prefix-arg
7720 "Exclude author (regexp): "
7721 "Limit to author (regexp): "))
7722 current-prefix-arg))
7723 (gnus-summary-limit-to-subject from "from" not-matching))
7725 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
7726 "Limit the summary buffer to articles with the given RECIPIENT.
7728 If NOT-MATCHING, exclude RECIPIENT.
7730 To and Cc headers are checked. You need to include them in
7731 `nnmail-extra-headers'."
7732 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
7734 (list (read-string (format "%s recipient (regexp): "
7735 (if current-prefix-arg "Exclude" "Limit to")))
7736 current-prefix-arg))
7737 (when (not (equal "" recipient))
7739 (if (memq 'To nnmail-extra-headers)
7740 (gnus-summary-find-matching
7741 (cons 'extra 'To) recipient 'all nil nil
7744 1 "`To' isn't present in `nnmail-extra-headers'")
7748 (if (memq 'Cc nnmail-extra-headers)
7749 (gnus-summary-find-matching
7750 (cons 'extra 'Cc) recipient 'all nil nil
7753 1 "`Cc' isn't present in `nnmail-extra-headers'")
7758 ;; We need the numbers that are in both lists:
7760 (and (memq a to) a))
7764 (error "Found no matches for \"%s\"" recipient))
7765 (gnus-summary-limit articles))
7766 (gnus-summary-position-point))))
7768 (defun gnus-summary-limit-to-age (age &optional younger-p)
7769 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7770 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7771 articles that are younger than AGE days."
7773 (let ((younger current-prefix-arg)
7776 (while (not days-got)
7777 (setq days (if younger
7778 (read-string "Limit to articles younger than (in days, older when negative): ")
7780 "Limit to articles older than (in days, younger when negative): ")))
7781 (when (> (length days) 0)
7782 (setq days (read days)))
7787 (setq younger (not younger))
7788 (setq days (* days -1))))
7789 (message "Please enter a number.")
7791 (list days younger)))
7793 (let ((data gnus-newsgroup-data)
7794 (cutoff (days-to-time age))
7795 articles d date is-younger)
7796 (while (setq d (pop data))
7797 (when (and (vectorp (gnus-data-header d))
7798 (setq date (mail-header-date (gnus-data-header d))))
7799 (setq is-younger (time-less-p
7800 (time-since (condition-case ()
7807 (push (gnus-data-number d) articles))))
7808 (gnus-summary-limit (nreverse articles)))
7809 (gnus-summary-position-point)))
7811 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7812 "Limit the summary buffer to articles that match an 'extra' header."
7816 (gnus-completing-read-with-default
7817 (symbol-name (car gnus-extra-headers))
7818 (if current-prefix-arg
7819 "Exclude extra header"
7820 "Limit extra header")
7822 (cons (symbol-name x) x))
7827 (read-string (format "%s header %s (regexp): "
7828 (if current-prefix-arg "Exclude" "Limit to")
7830 current-prefix-arg)))
7831 (when (not (equal "" regexp))
7833 (let ((articles (gnus-summary-find-matching
7834 (cons 'extra header) regexp 'all nil nil
7837 (error "Found no matches for \"%s\"" regexp))
7838 (gnus-summary-limit articles))
7839 (gnus-summary-position-point))))
7841 (defun gnus-summary-limit-to-display-predicate ()
7842 "Limit the summary buffer to the predicated in the `display' group parameter."
7844 (unless gnus-newsgroup-display
7845 (error "There is no `display' group parameter"))
7847 (dolist (number gnus-newsgroup-articles)
7848 (when (funcall gnus-newsgroup-display)
7849 (push number articles)))
7850 (gnus-summary-limit articles))
7851 (gnus-summary-position-point))
7853 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7855 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7857 (defun gnus-summary-limit-to-unread (&optional all)
7858 "Limit the summary buffer to articles that are not marked as read.
7859 If ALL is non-nil, limit strictly to unread articles."
7862 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7863 (gnus-summary-limit-to-marks
7864 ;; Concat all the marks that say that an article is read and have
7866 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7867 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7868 gnus-low-score-mark gnus-expirable-mark
7869 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7870 gnus-duplicate-mark gnus-souped-mark)
7873 (defun gnus-summary-limit-to-replied (&optional unreplied)
7874 "Limit the summary buffer to replied articles.
7875 If UNREPLIED (the prefix), limit to unreplied articles."
7879 (gnus-set-difference gnus-newsgroup-articles
7880 gnus-newsgroup-replied))
7881 (gnus-summary-limit gnus-newsgroup-replied))
7882 (gnus-summary-position-point))
7884 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7885 (make-obsolete 'gnus-summary-delete-marked-with
7886 'gnus-summary-limit-exclude-marks)
7888 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7889 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7890 If REVERSE, limit the summary buffer to articles that are marked
7891 with MARKS. MARKS can either be a string of marks or a list of marks.
7892 Returns how many articles were removed."
7893 (interactive "sMarks: ")
7894 (gnus-summary-limit-to-marks marks t))
7896 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7897 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7898 If REVERSE (the prefix), limit the summary buffer to articles that are
7899 not marked with MARKS. MARKS can either be a string of marks or a
7901 Returns how many articles were removed."
7902 (interactive "sMarks: \nP")
7904 (let ((data gnus-newsgroup-data)
7905 (marks (if (listp marks) marks
7906 (append marks nil))) ; Transform to list.
7909 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7910 (memq (gnus-data-mark (car data)) marks))
7911 (push (gnus-data-number (car data)) articles))
7912 (setq data (cdr data)))
7913 (gnus-summary-limit articles))
7914 (gnus-summary-position-point)))
7916 (defun gnus-summary-limit-to-score (score)
7917 "Limit to articles with score at or above SCORE."
7918 (interactive "NLimit to articles with score of at least: ")
7919 (let ((data gnus-newsgroup-data)
7922 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7924 (push (gnus-data-number (car data)) articles))
7925 (setq data (cdr data)))
7927 (gnus-summary-limit articles)
7928 (gnus-summary-position-point))))
7930 (defun gnus-summary-limit-to-unseen ()
7931 "Limit to unseen articles."
7934 (gnus-summary-limit gnus-newsgroup-unseen)
7935 (gnus-summary-position-point)))
7937 (defun gnus-summary-limit-include-thread (id)
7938 "Display all the hidden articles that is in the thread with ID in it.
7939 When called interactively, ID is the Message-ID of the current
7941 (interactive (list (mail-header-id (gnus-summary-article-header))))
7942 (let ((articles (gnus-articles-in-thread
7943 (gnus-id-to-thread (gnus-root-id id)))))
7945 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7946 (gnus-summary-limit-include-matching-articles
7948 (regexp-quote (gnus-simplify-subject-re
7949 (mail-header-subject (gnus-id-to-header id)))))
7950 (gnus-summary-position-point))))
7952 (defun gnus-summary-limit-include-matching-articles (header regexp)
7953 "Display all the hidden articles that have HEADERs that match REGEXP."
7954 (interactive (list (read-string "Match on header: ")
7955 (read-string "Regexp: ")))
7956 (let ((articles (gnus-find-matching-articles header regexp)))
7958 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7959 (gnus-summary-position-point))))
7961 (defun gnus-summary-insert-dormant-articles ()
7962 "Insert all the dormant articles for this group into the current buffer."
7964 (let ((gnus-verbose (max 6 gnus-verbose)))
7965 (if (not gnus-newsgroup-dormant)
7966 (gnus-message 3 "No cached articles for this group")
7967 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7969 (defun gnus-summary-limit-include-dormant ()
7970 "Display all the hidden articles that are marked as dormant.
7971 Note that this command only works on a subset of the articles currently
7972 fetched for this group."
7974 (unless gnus-newsgroup-dormant
7975 (error "There are no dormant articles in this group"))
7977 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7978 (gnus-summary-position-point)))
7980 (defun gnus-summary-limit-exclude-dormant ()
7981 "Hide all dormant articles."
7984 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7985 (gnus-summary-position-point)))
7987 (defun gnus-summary-limit-exclude-childless-dormant ()
7988 "Hide all dormant articles that have no children."
7990 (let ((data (gnus-data-list t))
7991 articles d children)
7992 ;; Find all articles that are either not dormant or have
7994 (while (setq d (pop data))
7995 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7997 (gnus-article-children (gnus-data-number d)))
8000 (when (memq (car children) articles)
8005 (push (gnus-data-number d) articles)))
8008 (gnus-summary-limit articles)
8009 (gnus-summary-position-point))))
8011 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8012 "Mark all unread excluded articles as read.
8013 If ALL, mark even excluded ticked and dormants as read."
8015 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8016 (let ((articles (gnus-sorted-ndifference
8018 (mapcar (lambda (h) (mail-header-number h))
8019 gnus-newsgroup-headers)
8021 gnus-newsgroup-limit))
8023 (setq gnus-newsgroup-unreads
8024 (gnus-sorted-intersection gnus-newsgroup-unreads
8025 gnus-newsgroup-limit))
8027 (setq gnus-newsgroup-dormant nil
8028 gnus-newsgroup-marked nil
8029 gnus-newsgroup-reads
8031 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8032 gnus-newsgroup-reads))
8033 (while (setq article (pop articles))
8034 (unless (or (memq article gnus-newsgroup-dormant)
8035 (memq article gnus-newsgroup-marked))
8036 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8038 (defun gnus-summary-limit (articles &optional pop)
8040 ;; We pop the previous limit off the stack and use that.
8041 (setq articles (car gnus-newsgroup-limits)
8042 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8043 ;; We use the new limit, so we push the old limit on the stack.
8044 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8046 (setq gnus-newsgroup-limit articles)
8047 (let ((total (length gnus-newsgroup-data))
8048 (data (gnus-data-find-list (gnus-summary-article-number)))
8049 (gnus-summary-mark-below nil) ; Inhibit this.
8051 ;; This will do all the work of generating the new summary buffer
8052 ;; according to the new limit.
8053 (gnus-summary-prepare)
8054 ;; Hide any threads, possibly.
8055 (gnus-summary-maybe-hide-threads)
8056 ;; Try to return to the article you were at, or one in the
8059 ;; We try to find some article after the current one.
8061 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8064 (setq data (cdr data))))
8066 ;; If there is no data, that means that we were after the last
8067 ;; article. The same goes when we can't find any articles
8068 ;; after the current one.
8069 (goto-char (point-max))
8070 (gnus-summary-find-prev))
8071 (gnus-set-mode-line 'summary)
8072 ;; We return how many articles were removed from the summary
8073 ;; buffer as a result of the new limit.
8074 (- total (length gnus-newsgroup-data))))
8076 (defsubst gnus-invisible-cut-children (threads)
8079 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8084 (defsubst gnus-cut-thread (thread)
8085 "Go forwards in the thread until we find an article that we want to display."
8086 (when (or (eq gnus-fetch-old-headers 'some)
8087 (eq gnus-fetch-old-headers 'invisible)
8088 (numberp gnus-fetch-old-headers)
8089 (eq gnus-build-sparse-threads 'some)
8090 (eq gnus-build-sparse-threads 'more))
8091 ;; Deal with old-fetched headers and sparse threads.
8095 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8096 (gnus-summary-article-ancient-p
8097 (mail-header-number (car thread))))
8098 (if (or (<= (length (cdr thread)) 1)
8099 (eq gnus-fetch-old-headers 'invisible))
8100 (setq gnus-newsgroup-limit
8101 (delq (mail-header-number (car thread))
8102 gnus-newsgroup-limit)
8103 thread (cadr thread))
8104 (when (gnus-invisible-cut-children (cdr thread))
8105 (let ((th (cdr thread)))
8107 (if (memq (mail-header-number (caar th))
8108 gnus-newsgroup-limit)
8109 (setq thread (car th)
8111 (setq th (cdr th))))))))))
8114 (defun gnus-cut-threads (threads)
8115 "Cut off all uninteresting articles from the beginning of THREADS."
8116 (when (or (eq gnus-fetch-old-headers 'some)
8117 (eq gnus-fetch-old-headers 'invisible)
8118 (numberp gnus-fetch-old-headers)
8119 (eq gnus-build-sparse-threads 'some)
8120 (eq gnus-build-sparse-threads 'more))
8123 (setcar th (gnus-cut-thread (car th)))
8124 (setq th (cdr th)))))
8125 ;; Remove nixed out threads.
8128 (defun gnus-summary-initial-limit (&optional show-if-empty)
8129 "Figure out what the initial limit is supposed to be on group entry.
8130 This entails weeding out unwanted dormants, low-scored articles,
8131 fetch-old-headers verbiage, and so on."
8132 ;; Most groups have nothing to remove.
8133 (if (or gnus-inhibit-limiting
8134 (and (null gnus-newsgroup-dormant)
8135 (eq gnus-newsgroup-display 'gnus-not-ignore)
8136 (not (eq gnus-fetch-old-headers 'some))
8137 (not (numberp gnus-fetch-old-headers))
8138 (not (eq gnus-fetch-old-headers 'invisible))
8139 (null gnus-summary-expunge-below)
8140 (not (eq gnus-build-sparse-threads 'some))
8141 (not (eq gnus-build-sparse-threads 'more))
8142 (null gnus-thread-expunge-below)
8143 (not gnus-use-nocem)))
8145 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8146 (setq gnus-newsgroup-limit nil)
8149 (unless (car (symbol-value node))
8150 ;; These threads have no parents -- they are roots.
8151 (let ((nodes (cdr (symbol-value node)))
8154 (if (and gnus-thread-expunge-below
8155 (< (gnus-thread-total-score (car nodes))
8156 gnus-thread-expunge-below))
8157 (gnus-expunge-thread (pop nodes))
8158 (setq thread (pop nodes))
8159 (gnus-summary-limit-children thread))))))
8160 gnus-newsgroup-dependencies)
8161 ;; If this limitation resulted in an empty group, we might
8162 ;; pop the previous limit and use it instead.
8163 (when (and (not gnus-newsgroup-limit)
8165 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8166 gnus-newsgroup-limit))
8168 (defun gnus-summary-limit-children (thread)
8169 "Return 1 if this subthread is visible and 0 if it is not."
8170 ;; First we get the number of visible children to this thread. This
8171 ;; is done by recursing down the thread using this function, so this
8172 ;; will really go down to a leaf article first, before slowly
8173 ;; working its way up towards the root.
8175 (let* ((max-lisp-eval-depth 5000)
8178 (apply '+ (mapcar 'gnus-summary-limit-children
8181 (number (mail-header-number (car thread)))
8184 (not (memq number gnus-newsgroup-marked))
8186 ;; If this article is dormant and has absolutely no visible
8187 ;; children, then this article isn't visible.
8188 (and (memq number gnus-newsgroup-dormant)
8190 ;; If this is "fetch-old-headered" and there is no
8191 ;; visible children, then we don't want this article.
8192 (and (or (eq gnus-fetch-old-headers 'some)
8193 (numberp gnus-fetch-old-headers))
8194 (gnus-summary-article-ancient-p number)
8196 ;; If this is "fetch-old-headered" and `invisible', then
8197 ;; we don't want this article.
8198 (and (eq gnus-fetch-old-headers 'invisible)
8199 (gnus-summary-article-ancient-p number))
8200 ;; If this is a sparsely inserted article with no children,
8201 ;; we don't want it.
8202 (and (eq gnus-build-sparse-threads 'some)
8203 (gnus-summary-article-sparse-p number)
8205 ;; If we use expunging, and this article is really
8206 ;; low-scored, then we don't want this article.
8207 (when (and gnus-summary-expunge-below
8209 (or (cdr (assq number gnus-newsgroup-scored))
8210 gnus-summary-default-score))
8211 gnus-summary-expunge-below))
8212 ;; We increase the expunge-tally here, but that has
8213 ;; nothing to do with the limits, really.
8214 (incf gnus-newsgroup-expunged-tally)
8215 ;; We also mark as read here, if that's wanted.
8216 (when (and gnus-summary-mark-below
8217 (< score gnus-summary-mark-below))
8218 (setq gnus-newsgroup-unreads
8219 (delq number gnus-newsgroup-unreads))
8220 (if gnus-newsgroup-auto-expire
8221 (push number gnus-newsgroup-expirable)
8222 (push (cons number gnus-low-score-mark)
8223 gnus-newsgroup-reads)))
8225 ;; Do the `display' group parameter.
8226 (and gnus-newsgroup-display
8227 (not (funcall gnus-newsgroup-display)))
8228 ;; Check NoCeM things.
8229 (when (and gnus-use-nocem
8230 (gnus-nocem-unwanted-article-p
8231 (mail-header-id (car thread))))
8232 (setq gnus-newsgroup-unreads
8233 (delq number gnus-newsgroup-unreads))
8235 ;; Nope, invisible article.
8237 ;; Ok, this article is to be visible, so we add it to the limit
8239 (push number gnus-newsgroup-limit)
8242 (defun gnus-expunge-thread (thread)
8243 "Mark all articles in THREAD as read."
8244 (let* ((number (mail-header-number (car thread))))
8245 (incf gnus-newsgroup-expunged-tally)
8246 ;; We also mark as read here, if that's wanted.
8247 (setq gnus-newsgroup-unreads
8248 (delq number gnus-newsgroup-unreads))
8249 (if gnus-newsgroup-auto-expire
8250 (push number gnus-newsgroup-expirable)
8251 (push (cons number gnus-low-score-mark)
8252 gnus-newsgroup-reads)))
8253 ;; Go recursively through all subthreads.
8254 (mapcar 'gnus-expunge-thread (cdr thread)))
8256 ;; Summary article oriented commands
8258 (defun gnus-summary-refer-parent-article (n)
8259 "Refer parent article N times.
8260 If N is negative, go to ancestor -N instead.
8261 The difference between N and the number of articles fetched is returned."
8265 (when (not (natnump n))
8270 (setq header (gnus-summary-article-header))
8271 (if (and (eq (mail-header-number header)
8272 (cdr gnus-article-current))
8273 (equal gnus-newsgroup-name
8274 (car gnus-article-current)))
8275 ;; If we try to find the parent of the currently
8276 ;; displayed article, then we take a look at the actual
8277 ;; References header, since this is slightly more
8278 ;; reliable than the References field we got from the
8281 (set-buffer gnus-original-article-buffer)
8282 (nnheader-narrow-to-headers)
8283 (unless (setq ref (message-fetch-field "references"))
8284 (when (setq ref (message-fetch-field "in-reply-to"))
8285 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8288 ;; It's not the current article, so we take a bet on
8289 ;; the value we got from the server.
8290 (mail-header-references header)))
8292 (not (equal ref "")))
8293 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8294 (gnus-message 1 "Couldn't find parent"))
8295 (gnus-message 1 "No references in article %d"
8296 (gnus-summary-article-number))
8299 (gnus-summary-position-point)
8302 (defun gnus-summary-refer-references ()
8303 "Fetch all articles mentioned in the References header.
8304 Return the number of articles fetched."
8306 (let ((ref (mail-header-references (gnus-summary-article-header)))
8307 (current (gnus-summary-article-number))
8311 (error "No References in the current article")
8312 ;; For each Message-ID in the References header...
8313 (while (string-match "<[^>]*>" ref)
8315 ;; ... fetch that article.
8316 (gnus-summary-refer-article
8317 (prog1 (match-string 0 ref)
8318 (setq ref (substring ref (match-end 0))))))
8319 (gnus-summary-goto-subject current)
8320 (gnus-summary-position-point)
8323 (defun gnus-summary-refer-thread (&optional limit)
8324 "Fetch all articles in the current thread.
8325 If LIMIT (the numerical prefix), fetch that many old headers instead
8326 of what's specified by the `gnus-refer-thread-limit' variable."
8328 (let ((id (mail-header-id (gnus-summary-article-header)))
8329 (limit (if limit (prefix-numeric-value limit)
8330 gnus-refer-thread-limit)))
8331 (unless (eq gnus-fetch-old-headers 'invisible)
8332 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8333 ;; Retrieve the headers and read them in.
8334 (if (eq (if (numberp limit)
8335 (gnus-retrieve-headers
8337 (+ (mail-header-number
8338 (gnus-summary-article-header))
8340 gnus-newsgroup-end))
8341 gnus-newsgroup-name (* limit 2))
8342 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8344 (gnus-retrieve-headers (list gnus-newsgroup-end)
8345 gnus-newsgroup-name limit))
8347 (gnus-build-all-threads)
8348 (error "Can't fetch thread from back ends that don't support NOV"))
8349 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8350 (gnus-summary-limit-include-thread id)))
8352 (defun gnus-summary-refer-article (message-id)
8353 "Fetch an article specified by MESSAGE-ID."
8354 (interactive "sMessage-ID: ")
8355 (when (and (stringp message-id)
8356 (not (zerop (length message-id))))
8357 (setq message-id (gnus-replace-in-string message-id " " ""))
8358 ;; Construct the correct Message-ID if necessary.
8359 ;; Suggested by tale@pawl.rpi.edu.
8360 (unless (string-match "^<" message-id)
8361 (setq message-id (concat "<" message-id)))
8362 (unless (string-match ">$" message-id)
8363 (setq message-id (concat message-id ">")))
8364 ;; People often post MIDs from URLs, so unhex it:
8365 (unless (string-match "@" message-id)
8366 (setq message-id (gnus-url-unhex-string message-id)))
8367 (let* ((header (gnus-id-to-header message-id))
8369 (gnus-summary-article-sparse-p
8370 (mail-header-number header))
8371 (memq (mail-header-number header)
8372 gnus-newsgroup-limit)))
8375 ;; If the article is present in the buffer we just go to it.
8377 (or (not (gnus-summary-article-sparse-p
8378 (mail-header-number header)))
8381 (gnus-summary-goto-article
8382 (mail-header-number header) nil t)
8384 (gnus-summary-update-article (mail-header-number header)))))
8386 ;; We fetch the article.
8388 (dolist (gnus-override-method (gnus-refer-article-methods))
8389 (when (and (gnus-check-server gnus-override-method)
8390 ;; Fetch the header,
8391 (setq number (gnus-summary-insert-subject message-id)))
8392 ;; and display the article.
8393 (gnus-summary-select-article nil nil nil number)
8395 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8397 (defun gnus-refer-article-methods ()
8398 "Return a list of referable methods."
8400 ;; No method, so we default to current and native.
8401 ((null gnus-refer-article-method)
8402 (list gnus-current-select-method gnus-select-method))
8404 ((eq 'current gnus-refer-article-method)
8405 (list gnus-current-select-method))
8406 ;; List of select methods.
8407 ((not (and (symbolp (car gnus-refer-article-method))
8408 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8410 (dolist (method gnus-refer-article-method)
8411 (push (if (eq 'current method)
8412 gnus-current-select-method
8416 ;; One single select method.
8418 (list gnus-refer-article-method))))
8420 (defun gnus-summary-edit-parameters ()
8421 "Edit the group parameters of the current group."
8423 (gnus-group-edit-group gnus-newsgroup-name 'params))
8425 (defun gnus-summary-customize-parameters ()
8426 "Customize the group parameters of the current group."
8428 (gnus-group-customize gnus-newsgroup-name))
8430 (defun gnus-summary-enter-digest-group (&optional force)
8431 "Enter an nndoc group based on the current article.
8432 If FORCE, force a digest interpretation. If not, try
8433 to guess what the document format is."
8435 (let ((conf gnus-current-window-configuration))
8436 (save-window-excursion
8438 (let (gnus-article-prepare-hook
8439 gnus-display-mime-function
8441 (gnus-summary-select-article))))
8442 (setq gnus-current-window-configuration conf)
8443 (let* ((name (format "%s-%d"
8444 (gnus-group-prefixed-name
8445 gnus-newsgroup-name (list 'nndoc ""))
8446 (with-current-buffer gnus-summary-buffer
8447 gnus-current-article)))
8448 (ogroup gnus-newsgroup-name)
8449 (params (append (gnus-info-params (gnus-get-info ogroup))
8450 (list (cons 'to-group ogroup))
8451 (list (cons 'parent-group ogroup))
8452 (list (cons 'save-article-group ogroup))))
8453 (case-fold-search t)
8454 (buf (current-buffer))
8457 (set-buffer gnus-original-article-buffer)
8458 ;; Have the digest group inherit the main mail address of
8459 ;; the parent article.
8460 (when (setq to-address (or (gnus-fetch-field "reply-to")
8461 (gnus-fetch-field "from")))
8462 (setq params (append
8463 (list (cons 'to-address
8464 (funcall gnus-decode-encoded-word-function
8466 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8467 (insert-buffer-substring gnus-original-article-buffer)
8468 ;; Remove lines that may lead nndoc to misinterpret the
8471 (goto-char (point-min))
8472 (or (search-forward "\n\n" nil t) (point)))
8473 (goto-char (point-min))
8474 (delete-matching-lines "^Path:\\|^From ")
8477 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8478 (gnus-newsgroup-ephemeral-ignored-charsets
8479 gnus-newsgroup-ignored-charsets))
8480 (gnus-group-read-ephemeral-group
8481 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8483 ,(if force 'mbox 'guess)))
8485 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8487 ;; Make all postings to this group go to the parent group.
8488 (nconc (gnus-info-params (gnus-get-info name))
8490 ;; Couldn't select this doc group.
8491 (switch-to-buffer buf)
8492 (gnus-set-global-variables)
8493 (gnus-configure-windows 'summary)
8494 (gnus-message 3 "Article couldn't be entered?"))
8495 (kill-buffer dig)))))
8497 (defun gnus-summary-read-document (n)
8498 "Open a new group based on the current article(s).
8499 This will allow you to read digests and other similar
8500 documents as newsgroups.
8501 Obeys the standard process/prefix convention."
8503 (let* ((ogroup gnus-newsgroup-name)
8504 (params (append (gnus-info-params (gnus-get-info ogroup))
8505 (list (cons 'to-group ogroup))))
8506 group egroup groups vgroup)
8507 (dolist (article (gnus-summary-work-articles n))
8508 (setq group (format "%s-%d" gnus-newsgroup-name article))
8509 (gnus-summary-remove-process-mark article)
8510 (when (gnus-summary-display-article article)
8513 (insert-buffer-substring gnus-original-article-buffer)
8514 ;; Remove some headers that may lead nndoc to make
8516 (message-narrow-to-head)
8517 (goto-char (point-min))
8518 (delete-matching-lines "^Path:\\|^From ")
8521 (gnus-group-read-ephemeral-group
8522 group `(nndoc ,group (nndoc-address ,(current-buffer))
8523 (nndoc-article-type guess))
8526 ;; Make all postings to this group go to the parent group.
8527 (nconc (gnus-info-params (gnus-get-info egroup))
8529 (push egroup groups))
8530 ;; Couldn't select this doc group.
8531 (gnus-error 3 "Article couldn't be entered"))))))
8532 ;; Now we have selected all the documents.
8535 (error "None of the articles could be interpreted as documents"))
8536 ((gnus-group-read-ephemeral-group
8537 (setq vgroup (format
8538 "nnvirtual:%s-%s" gnus-newsgroup-name
8539 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8540 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8542 (cons (current-buffer) 'summary)))
8544 (error "Couldn't select virtual nndoc group")))))
8546 (defun gnus-summary-isearch-article (&optional regexp-p)
8547 "Do incremental search forward on the current article.
8548 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8550 (gnus-summary-select-article)
8551 (gnus-configure-windows 'article)
8552 (gnus-eval-in-buffer-window gnus-article-buffer
8555 (isearch-forward regexp-p))))
8557 (defun gnus-summary-search-article-forward (regexp &optional backward)
8558 "Search for an article containing REGEXP forward.
8559 If BACKWARD, search backward instead."
8562 (format "Search article %s (regexp%s): "
8563 (if current-prefix-arg "backward" "forward")
8564 (if gnus-last-search-regexp
8565 (concat ", default " gnus-last-search-regexp)
8567 current-prefix-arg))
8568 (if (string-equal regexp "")
8569 (setq regexp (or gnus-last-search-regexp ""))
8570 (setq gnus-last-search-regexp regexp)
8571 (setq gnus-article-before-search gnus-current-article))
8572 ;; Intentionally set gnus-last-article.
8573 (setq gnus-last-article gnus-article-before-search)
8574 (let ((gnus-last-article gnus-last-article))
8575 (if (gnus-summary-search-article regexp backward)
8576 (gnus-summary-show-thread)
8577 (signal 'search-failed (list regexp)))))
8579 (defun gnus-summary-search-article-backward (regexp)
8580 "Search for an article containing REGEXP backward."
8583 (format "Search article backward (regexp%s): "
8584 (if gnus-last-search-regexp
8585 (concat ", default " gnus-last-search-regexp)
8587 (gnus-summary-search-article-forward regexp 'backward))
8589 (defun gnus-summary-search-article (regexp &optional backward)
8590 "Search for an article containing REGEXP.
8591 Optional argument BACKWARD means do search for backward.
8592 `gnus-select-article-hook' is not called during the search."
8593 ;; We have to require this here to make sure that the following
8594 ;; dynamic binding isn't shadowed by autoloading.
8595 (require 'gnus-async)
8597 (let ((gnus-select-article-hook nil) ;Disable hook.
8598 (gnus-article-prepare-hook nil)
8599 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8600 (gnus-use-article-prefetch nil)
8601 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8602 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8604 (gnus-keep-backlog nil)
8605 (gnus-break-pages nil)
8606 (gnus-summary-display-arrow nil)
8607 (gnus-updated-mode-lines nil)
8608 (gnus-auto-center-summary nil)
8609 (sum (current-buffer))
8610 (gnus-display-mime-function nil)
8613 (gnus-save-hidden-threads
8614 (gnus-summary-select-article)
8615 (set-buffer gnus-article-buffer)
8616 (goto-char (window-point (get-buffer-window (current-buffer))))
8620 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8622 (re-search-backward regexp nil t)
8623 (re-search-forward regexp nil t))
8624 ;; We found the regexp.
8629 (get-buffer-window (current-buffer))
8633 (get-buffer-window (current-buffer))
8636 (setq point (point)))
8637 ;; We didn't find it, so we go to the next article.
8640 (while (eq found 'not)
8641 (if (not (if backward (gnus-summary-find-prev)
8642 (gnus-summary-find-next)))
8643 ;; No more articles.
8645 ;; Select the next article and adjust point.
8646 (unless (gnus-summary-article-sparse-p
8647 (gnus-summary-article-number))
8649 (gnus-summary-select-article)
8650 (set-buffer gnus-article-buffer)
8652 (goto-char (if backward (point-max) (point-min))))))))
8653 (gnus-message 7 ""))
8654 ;; Return whether we found the regexp.
8655 (when (eq found 'found)
8657 (gnus-summary-show-thread)
8658 (gnus-summary-goto-subject gnus-current-article)
8659 (gnus-summary-position-point)
8662 (defun gnus-find-matching-articles (header regexp)
8663 "Return a list of all articles that match REGEXP on HEADER.
8664 This search includes all articles in the current group that Gnus has
8665 fetched headers for, whether they are displayed or not."
8666 (let ((articles nil)
8667 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8668 (case-fold-search t))
8669 (dolist (header gnus-newsgroup-headers)
8670 (when (string-match regexp (funcall func header))
8671 (push (mail-header-number header) articles)))
8672 (nreverse articles)))
8674 (defun gnus-summary-find-matching (header regexp &optional backward unread
8675 not-case-fold not-matching)
8676 "Return a list of all articles that match REGEXP on HEADER.
8677 The search stars on the current article and goes forwards unless
8678 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8679 If UNREAD is non-nil, only unread articles will
8680 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8681 in the comparisons. If NOT-MATCHING, return a list of all articles that
8682 not match REGEXP on HEADER."
8683 (let ((case-fold-search (not not-case-fold))
8686 (if (eq (car header) 'extra)
8689 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8691 (error "%s is an invalid header" header))
8692 (unless (fboundp (intern (concat "mail-header-" header)))
8693 (error "%s is not a valid header" header))
8694 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8695 (dolist (d (if (eq backward 'all)
8697 (gnus-data-find-list
8698 (gnus-summary-article-number)
8699 (gnus-data-list backward))))
8700 (when (and (or (not unread) ; We want all articles...
8701 (gnus-data-unread-p d)) ; Or just unreads.
8702 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8706 (funcall func (gnus-data-header d))))
8707 (string-match regexp
8708 (funcall func (gnus-data-header d)))))
8709 (push (gnus-data-number d) articles))) ; Success!
8710 (nreverse articles)))
8712 (defun gnus-summary-execute-command (header regexp command &optional backward)
8713 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8714 If HEADER is an empty string (or nil), the match is done on the entire
8715 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8717 (list (let ((completion-ignore-case t))
8720 (mapcar (lambda (header) (list (format "%s" header)))
8722 '("Number" "Subject" "From" "Lines" "Date"
8723 "Message-ID" "Xref" "References" "Body")
8724 gnus-extra-headers))
8725 nil 'require-match))
8726 (read-string "Regexp: ")
8727 (read-key-sequence "Command: ")
8728 current-prefix-arg))
8729 (when (equal header "Body")
8731 ;; Hidden thread subtrees must be searched as well.
8732 (gnus-summary-show-all-threads)
8733 ;; We don't want to change current point nor window configuration.
8735 (save-window-excursion
8737 gnus-treat-strip-trailing-blank-lines
8738 gnus-treat-strip-leading-blank-lines
8739 gnus-treat-strip-multiple-blank-lines
8740 gnus-treat-hide-boring-headers
8741 gnus-treat-fold-newsgroups
8742 gnus-article-prepare-hook)
8743 (gnus-message 6 "Executing %s..." (key-description command))
8744 ;; We'd like to execute COMMAND interactively so as to give arguments.
8745 (gnus-execute header regexp
8746 `(call-interactively ',(key-binding command))
8748 (gnus-message 6 "Executing %s...done" (key-description command))))))
8750 (defun gnus-summary-beginning-of-article ()
8751 "Scroll the article back to the beginning."
8753 (gnus-summary-select-article)
8754 (gnus-configure-windows 'article)
8755 (gnus-eval-in-buffer-window gnus-article-buffer
8757 (goto-char (point-min))
8758 (when gnus-break-pages
8759 (gnus-narrow-to-page))))
8761 (defun gnus-summary-end-of-article ()
8762 "Scroll to the end of the article."
8764 (gnus-summary-select-article)
8765 (gnus-configure-windows 'article)
8766 (gnus-eval-in-buffer-window gnus-article-buffer
8768 (goto-char (point-max))
8770 (when gnus-break-pages
8771 (when (re-search-backward page-delimiter nil t)
8772 (narrow-to-region (match-end 0) (point-max)))
8773 (gnus-narrow-to-page))))
8775 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8776 "Truncate to LEN and quote all \"(\"'s in STRING."
8777 (gnus-replace-in-string (if (and len (> (length string) len))
8778 (substring string 0 len)
8782 (defun gnus-summary-print-article (&optional filename n)
8783 "Generate and print a PostScript image of the process-marked (mail) articles.
8785 If used interactively, print the current article if none are
8786 process-marked. With prefix arg, prompt the user for the name of the
8789 When used from Lisp, accept two optional args FILENAME and N. N means
8790 to print the next N articles. If N is negative, print the N previous
8791 articles. If N is nil and articles have been marked with the process
8792 mark, print these instead.
8794 If the optional first argument FILENAME is nil, send the image to the
8795 printer. If FILENAME is a string, save the PostScript image in a file with
8796 that name. If FILENAME is a number, prompt the user for the name of the file
8798 (interactive (list (ps-print-preprint current-prefix-arg)))
8799 (dolist (article (gnus-summary-work-articles n))
8800 (gnus-summary-select-article nil nil 'pseudo article)
8801 (gnus-eval-in-buffer-window gnus-article-buffer
8802 (gnus-print-buffer))
8803 (gnus-summary-remove-process-mark article))
8804 (ps-despool filename))
8806 (defun gnus-print-buffer ()
8807 (let ((buffer (generate-new-buffer " *print*")))
8810 (copy-to-buffer buffer (point-min) (point-max))
8812 (gnus-remove-text-with-property 'gnus-decoration)
8813 (when (gnus-visual-p 'article-highlight 'highlight)
8814 ;; Copy-to-buffer doesn't copy overlay. So redo
8816 (let ((gnus-article-buffer buffer))
8817 (gnus-article-highlight-citation t)
8818 (gnus-article-highlight-signature)
8819 (gnus-article-emphasize)
8820 (gnus-article-delete-invisible-text)))
8821 (let ((ps-left-header
8824 (gnus-summary-print-truncate-and-quote
8825 (mail-header-subject gnus-current-headers)
8828 (gnus-summary-print-truncate-and-quote
8829 (mail-header-from gnus-current-headers)
8833 "/pagenumberstring load"
8835 (mail-header-date gnus-current-headers) ")"))))
8836 (gnus-run-hooks 'gnus-ps-print-hook)
8839 (ps-spool-buffer-with-faces)
8840 (ps-spool-buffer)))))
8841 (kill-buffer buffer))))
8843 (defun gnus-summary-show-article (&optional arg)
8844 "Force redisplaying of the current article.
8845 If ARG (the prefix) is a number, show the article with the charset
8846 defined in `gnus-summary-show-article-charset-alist', or the charset
8848 If ARG (the prefix) is non-nil and not a number, show the raw article
8849 without any article massaging functions being run. Normally, the key
8850 strokes are `C-u g'."
8854 (gnus-summary-show-article t)
8855 (let ((gnus-newsgroup-charset
8856 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8857 (mm-read-coding-system
8858 "View as charset: " ;; actually it is coding system.
8859 (with-current-buffer gnus-article-buffer
8860 (mm-detect-coding-region (point) (point-max))))))
8861 (gnus-newsgroup-ignored-charsets 'gnus-all))
8862 (gnus-summary-select-article nil 'force)
8863 (let ((deps gnus-newsgroup-dependencies)
8866 (set-buffer gnus-original-article-buffer)
8868 (message-narrow-to-head)
8869 (setq head (buffer-string))
8870 (goto-char (point-min))
8871 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8872 (goto-char (point-max))
8874 (setq lines (1- (count-lines (point) (point-max))))))
8876 (insert (format "211 %d Article retrieved.\n"
8877 (cdr gnus-article-current)))
8879 (if lines (insert (format "Lines: %d\n" lines)))
8881 (let ((nntp-server-buffer (current-buffer)))
8882 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8883 (gnus-data-set-header
8884 (gnus-data-find (cdr gnus-article-current))
8886 (gnus-summary-update-article-line
8887 (cdr gnus-article-current) header)
8888 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8889 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8891 ;; Select the article the normal way.
8892 (gnus-summary-select-article nil 'force))
8894 ;; We have to require this here to make sure that the following
8895 ;; dynamic binding isn't shadowed by autoloading.
8896 (require 'gnus-async)
8898 ;; Bind the article treatment functions to nil.
8899 (let ((gnus-have-all-headers t)
8900 gnus-article-prepare-hook
8901 gnus-article-decode-hook
8902 gnus-display-mime-function
8904 ;; Destroy any MIME parts.
8905 (when (gnus-buffer-live-p gnus-article-buffer)
8907 (set-buffer gnus-article-buffer)
8908 (mm-destroy-parts gnus-article-mime-handles)
8909 ;; Set it to nil for safety reason.
8910 (setq gnus-article-mime-handle-alist nil)
8911 (setq gnus-article-mime-handles nil)))
8912 (gnus-summary-select-article nil 'force))))
8913 (gnus-summary-goto-subject gnus-current-article)
8914 (gnus-summary-position-point))
8916 (defun gnus-summary-show-raw-article ()
8917 "Show the raw article without any article massaging functions being run."
8919 (gnus-summary-show-article t))
8921 (defun gnus-summary-verbose-headers (&optional arg)
8922 "Toggle permanent full header display.
8923 If ARG is a positive number, turn header display on.
8924 If ARG is a negative number, turn header display off."
8926 (setq gnus-show-all-headers
8927 (cond ((or (not (numberp arg))
8929 (not gnus-show-all-headers))
8932 (gnus-summary-show-article))
8934 (defun gnus-summary-toggle-header (&optional arg)
8935 "Show the headers if they are hidden, or hide them if they are shown.
8936 If ARG is a positive number, show the entire header.
8937 If ARG is a negative number, hide the unwanted header lines."
8939 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8940 (get-buffer-window gnus-article-buffer t))))
8941 (with-current-buffer gnus-article-buffer
8943 (article-narrow-to-head)
8944 (let* ((buffer-read-only nil)
8945 (inhibit-point-motion-hooks t)
8946 (hidden (if (numberp arg)
8948 (or (not (looking-at "[^ \t\n]+:"))
8949 (gnus-article-hidden-text-p 'headers))))
8951 (delete-region (point-min) (point-max))
8952 (with-current-buffer gnus-original-article-buffer
8953 (goto-char (setq s (point-min)))
8954 (setq e (if (search-forward "\n\n" nil t)
8957 (insert-buffer-substring gnus-original-article-buffer s e)
8958 (run-hooks 'gnus-article-decode-hook)
8960 (let ((gnus-treat-hide-headers nil)
8961 (gnus-treat-hide-boring-headers nil))
8962 (gnus-delete-wash-type 'headers)
8963 (gnus-treat-article 'head))
8964 (gnus-treat-article 'head))
8967 (set-window-start window (goto-char (point-min))))
8968 (if gnus-break-pages
8969 (gnus-narrow-to-page)
8970 (when (gnus-visual-p 'page-marker)
8971 (let ((buffer-read-only nil))
8972 (gnus-remove-text-with-property 'gnus-prev)
8973 (gnus-remove-text-with-property 'gnus-next))))
8974 (gnus-set-mode-line 'article)))))
8976 (defun gnus-summary-show-all-headers ()
8977 "Make all header lines visible."
8979 (gnus-summary-toggle-header 1))
8981 (defun gnus-summary-caesar-message (&optional arg)
8982 "Caesar rotate the current article by 13.
8983 The numerical prefix specifies how many places to rotate each letter
8986 (gnus-summary-select-article)
8987 (let ((mail-header-separator ""))
8988 (gnus-eval-in-buffer-window gnus-article-buffer
8991 (let ((start (window-start))
8993 (message-caesar-buffer-body arg)
8994 (set-window-start (get-buffer-window (current-buffer)) start)))))
8995 ;; Create buttons and stuff...
8996 (gnus-treat-article nil))
8998 (defun gnus-summary-idna-message (&optional arg)
8999 "Decode IDNA encoded domain names in the current articles.
9000 IDNA encoded domain names looks like `xn--bar'. If a string
9001 remain unencoded after running this function, it is likely an
9002 invalid IDNA string (`xn--bar' is invalid).
9004 You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9005 installed for this command to work."
9007 (if (not (and (condition-case nil (require 'idna)
9009 (mm-coding-system-p 'utf-8)
9010 (executable-find (symbol-value 'idna-program))))
9012 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9013 (gnus-summary-select-article)
9014 (let ((mail-header-separator ""))
9015 (gnus-eval-in-buffer-window gnus-article-buffer
9018 (let ((start (window-start))
9020 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9021 (replace-match (idna-to-unicode (match-string 1))))
9022 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9024 (autoload 'unmorse-region "morse"
9025 "Convert morse coded text in region to ordinary ASCII text."
9028 (defun gnus-summary-morse-message (&optional arg)
9029 "Morse decode the current article."
9031 (gnus-summary-select-article)
9032 (let ((mail-header-separator ""))
9033 (gnus-eval-in-buffer-window gnus-article-buffer
9037 (let ((pos (window-start))
9039 (goto-char (point-min))
9040 (when (message-goto-body)
9041 (gnus-narrow-to-body))
9042 (goto-char (point-min))
9043 (while (search-forward "·" (point-max) t)
9044 (replace-match "."))
9045 (unmorse-region (point-min) (point-max))
9047 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9049 (defun gnus-summary-stop-page-breaking ()
9050 "Stop page breaking in the current article."
9052 (gnus-summary-select-article)
9053 (gnus-eval-in-buffer-window gnus-article-buffer
9055 (when (gnus-visual-p 'page-marker)
9056 (let ((buffer-read-only nil))
9057 (gnus-remove-text-with-property 'gnus-prev)
9058 (gnus-remove-text-with-property 'gnus-next))
9059 (setq gnus-page-broken nil))))
9061 (defun gnus-summary-move-article (&optional n to-newsgroup
9062 select-method action)
9063 "Move the current article to a different newsgroup.
9064 If N is a positive number, move the N next articles.
9065 If N is a negative number, move the N previous articles.
9066 If N is nil and any articles have been marked with the process mark,
9067 move those articles instead.
9068 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9069 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9070 re-spool using this method.
9072 When called interactively with TO-NEWSGROUP being nil, the value of
9073 the variable `gnus-move-split-methods' is used for finding a default
9074 for the target newsgroup.
9076 For this function to work, both the current newsgroup and the
9077 newsgroup that you want to move to have to support the `request-move'
9078 and `request-accept' functions.
9080 ACTION can be either `move' (the default), `crosspost' or `copy'."
9083 (setq action 'move))
9084 ;; Check whether the source group supports the required functions.
9085 (cond ((and (eq action 'move)
9086 (not (gnus-check-backend-function
9087 'request-move-article gnus-newsgroup-name)))
9088 (error "The current group does not support article moving"))
9089 ((and (eq action 'crosspost)
9090 (not (gnus-check-backend-function
9091 'request-replace-article gnus-newsgroup-name)))
9092 (error "The current group does not support article editing")))
9093 (let ((articles (gnus-summary-work-articles n))
9094 (prefix (if (gnus-check-backend-function
9095 'request-move-article gnus-newsgroup-name)
9096 (funcall gnus-move-group-prefix-function
9097 gnus-newsgroup-name)
9099 (names '((move "Move" "Moving")
9100 (copy "Copy" "Copying")
9101 (crosspost "Crosspost" "Crossposting")))
9102 (copy-buf (save-excursion
9103 (nnheader-set-temp-buffer " *copy article*")))
9104 art-group to-method new-xref article to-groups articles-to-update-marks)
9105 (unless (assq action names)
9106 (error "Unknown action %s" action))
9107 ;; Read the newsgroup name.
9108 (when (and (not to-newsgroup)
9109 (not select-method))
9110 (if (and gnus-move-split-methods
9112 (and (memq gnus-current-article articles)
9113 (gnus-buffer-live-p gnus-original-article-buffer))))
9114 ;; When `gnus-move-split-methods' is non-nil, we have to
9115 ;; select an article to give `gnus-read-move-group-name' an
9116 ;; opportunity to suggest an appropriate default. However,
9117 ;; we needn't render or mark the article.
9118 (let ((gnus-display-mime-function nil)
9119 (gnus-article-prepare-hook nil)
9120 (gnus-mark-article-hook nil))
9121 (gnus-summary-select-article nil nil nil (car articles))))
9123 (gnus-read-move-group-name
9124 (cadr (assq action names))
9125 (symbol-value (intern (format "gnus-current-%s-group" action)))
9127 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9128 (setq to-method (or select-method
9129 (gnus-server-to-method
9130 (gnus-group-method to-newsgroup))))
9131 ;; Check the method we are to move this article to...
9132 (unless (gnus-check-backend-function
9133 'request-accept-article (car to-method))
9134 (error "%s does not support article copying" (car to-method)))
9135 (unless (gnus-check-server to-method)
9136 (error "Can't open server %s" (car to-method)))
9137 (gnus-message 6 "%s to %s: %s..."
9138 (caddr (assq action names))
9139 (or (car select-method) to-newsgroup) articles)
9141 (setq article (pop articles))
9145 ;; Move the article.
9147 ;; Remove this article from future suppression.
9148 (gnus-dup-unsuppress-article article)
9149 (let* ((from-method (gnus-find-method-for-group
9150 gnus-newsgroup-name))
9151 (to-method (gnus-find-method-for-group
9153 (move-is-internal (gnus-method-equal from-method to-method)))
9154 (gnus-request-move-article
9155 article ; Article to move
9156 gnus-newsgroup-name ; From newsgroup
9157 (nth 1 (gnus-find-method-for-group
9158 gnus-newsgroup-name)) ; Server
9159 (list 'gnus-request-accept-article
9160 to-newsgroup (list 'quote select-method)
9161 (not articles) t) ; Accept form
9162 (not articles) ; Only save nov last time
9163 move-is-internal))) ; is this move internal?
9164 ;; Copy the article.
9167 (set-buffer copy-buf)
9168 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9170 (nnheader-narrow-to-headers)
9171 (dolist (hdr gnus-copy-article-ignored-headers)
9172 (message-remove-header hdr t)))
9173 (gnus-request-accept-article
9174 to-newsgroup select-method (not articles) t))))
9175 ;; Crosspost the article.
9176 ((eq action 'crosspost)
9177 (let ((xref (message-tokenize-header
9178 (mail-header-xref (gnus-summary-article-header article))
9180 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9181 ":" (number-to-string article)))
9183 (setq xref (list (system-name))))
9186 (mapconcat 'identity
9187 (delete "Xref:" (delete new-xref xref))
9191 (set-buffer copy-buf)
9192 ;; First put the article in the destination group.
9193 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9194 (when (consp (setq art-group
9195 (gnus-request-accept-article
9196 to-newsgroup select-method (not articles))))
9197 (setq new-xref (concat new-xref " " (car art-group)
9199 (number-to-string (cdr art-group))))
9200 ;; Now we have the new Xrefs header, so we insert
9201 ;; it and replace the new article.
9202 (nnheader-replace-header "Xref" new-xref)
9203 (gnus-request-replace-article
9204 (cdr art-group) to-newsgroup (current-buffer))
9208 (gnus-message 1 "Couldn't %s article %s: %s"
9209 (cadr (assq action names)) article
9210 (nnheader-get-report (car to-method))))
9211 ((eq art-group 'junk)
9212 (when (eq action 'move)
9213 (gnus-summary-mark-article article gnus-canceled-mark)
9214 (gnus-message 4 "Deleted article %s" article)
9215 ;; run the delete hook
9216 (run-hook-with-args 'gnus-summary-article-delete-hook
9219 (assoc article (gnus-data-list nil)))
9220 gnus-newsgroup-name nil
9223 (let* ((pto-group (gnus-group-prefixed-name
9224 (car art-group) to-method))
9225 (info (gnus-get-info pto-group))
9226 (to-group (gnus-info-group info))
9228 ;; Update the group that has been moved to.
9230 (memq action '(move copy)))
9231 (unless (member to-group to-groups)
9232 (push to-group to-groups))
9234 (unless (memq article gnus-newsgroup-unreads)
9235 (push 'read to-marks)
9237 info (gnus-add-to-range (gnus-info-read info)
9238 (list (cdr art-group)))))
9240 ;; See whether the article is to be put in the cache.
9241 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9242 gnus-article-mark-lists
9243 (delete '(expirable . expire)
9244 (copy-sequence gnus-article-mark-lists))))
9245 (to-article (cdr art-group)))
9247 ;; Enter the article into the cache in the new group,
9248 ;; if that is required.
9249 (when gnus-use-cache
9250 (gnus-cache-possibly-enter-article
9252 (memq article gnus-newsgroup-marked)
9253 (memq article gnus-newsgroup-dormant)
9254 (memq article gnus-newsgroup-unreads)))
9256 (when gnus-preserve-marks
9257 ;; Copy any marks over to the new group.
9258 (when (and (equal to-group gnus-newsgroup-name)
9259 (not (memq article gnus-newsgroup-unreads)))
9260 ;; Mark this article as read in this group.
9261 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9262 (setcdr (gnus-active to-group) to-article)
9263 (setcdr gnus-newsgroup-active to-article))
9266 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9267 (when (memq article (symbol-value
9268 (intern (format "gnus-newsgroup-%s"
9270 (push (cdar marks) to-marks)
9271 ;; If the other group is the same as this group,
9272 ;; then we have to add the mark to the list.
9273 (when (equal to-group gnus-newsgroup-name)
9274 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9277 (intern (format "gnus-newsgroup-%s"
9279 ;; Copy the marks to other group.
9280 (gnus-add-marked-articles
9281 to-group (cdar marks) (list to-article) info)))
9282 (setq marks (cdr marks)))
9284 (gnus-request-set-mark
9285 to-group (list (list (list to-article) 'add to-marks))))
9288 (concat "(gnus-group-set-info '"
9289 (gnus-prin1-to-string (gnus-get-info to-group))
9292 ;; Update the Xref header in this article to point to
9293 ;; the new crossposted article we have just created.
9294 (when (eq action 'crosspost)
9296 (set-buffer copy-buf)
9297 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9298 (nnheader-replace-header "Xref" new-xref)
9299 (gnus-request-replace-article
9300 article gnus-newsgroup-name (current-buffer))))
9302 ;; run the move/copy/crosspost/respool hook
9303 (run-hook-with-args 'gnus-summary-article-move-hook
9306 (assoc article (gnus-data-list nil)))
9311 ;;;!!!Why is this necessary?
9312 (set-buffer gnus-summary-buffer)
9314 (gnus-summary-goto-subject article)
9315 (when (eq action 'move)
9316 (gnus-summary-mark-article article gnus-canceled-mark))))
9317 (push article articles-to-update-marks))
9319 (apply 'gnus-summary-remove-process-mark articles-to-update-marks)
9320 ;; Re-activate all groups that have been moved to.
9322 (set-buffer gnus-group-buffer)
9323 (let ((gnus-group-marked to-groups))
9324 (gnus-group-get-new-news-this-group nil t)))
9326 (gnus-kill-buffer copy-buf)
9327 (gnus-summary-position-point)
9328 (gnus-set-mode-line 'summary)))
9330 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9331 "Copy the current article to some other group.
9332 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9333 When called interactively, if TO-NEWSGROUP is nil, use the value of
9334 the variable `gnus-move-split-methods' for finding a default target
9336 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9337 re-spool using this method."
9339 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9341 (defun gnus-summary-crosspost-article (&optional n)
9342 "Crosspost the current article to some other group."
9344 (gnus-summary-move-article n nil nil 'crosspost))
9346 (defcustom gnus-summary-respool-default-method nil
9347 "Default method type for respooling an article.
9348 If nil, use to the current newsgroup method."
9350 :group 'gnus-summary-mail)
9352 (defcustom gnus-summary-display-while-building nil
9353 "If non-nil, show and update the summary buffer as it's being built.
9354 If the value is t, update the buffer after every line is inserted. If
9355 the value is an integer (N), update the display every N lines."
9358 :type '(choice (const :tag "off" nil)
9360 (const :tag "frequently" t)))
9362 (defun gnus-summary-respool-article (&optional n method)
9363 "Respool the current article.
9364 The article will be squeezed through the mail spooling process again,
9365 which means that it will be put in some mail newsgroup or other
9366 depending on `nnmail-split-methods'.
9367 If N is a positive number, respool the N next articles.
9368 If N is a negative number, respool the N previous articles.
9369 If N is nil and any articles have been marked with the process mark,
9370 respool those articles instead.
9372 Respooling can be done both from mail groups and \"real\" newsgroups.
9373 In the former case, the articles in question will be moved from the
9374 current group into whatever groups they are destined to. In the
9375 latter case, they will be copied into the relevant groups."
9377 (list current-prefix-arg
9378 (let* ((methods (gnus-methods-using 'respool))
9380 (symbol-name (or gnus-summary-respool-default-method
9381 (car (gnus-find-method-for-group
9382 gnus-newsgroup-name)))))
9384 (gnus-completing-read-with-default
9385 methname "Backend to use when respooling"
9386 methods nil t nil 'gnus-mail-method-history))
9389 ((zerop (length (setq ms (gnus-servers-using-backend
9391 (list (intern method) ""))
9395 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9396 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9399 (error "No method given for respooling"))
9400 (if (assoc (symbol-name
9401 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9402 (gnus-methods-using 'respool))
9403 (gnus-summary-move-article n nil method)
9404 (gnus-summary-copy-article n nil method)))
9406 (defun gnus-summary-import-article (file &optional edit)
9407 "Import an arbitrary file into a mail newsgroup."
9408 (interactive "fImport file: \nP")
9409 (let ((group gnus-newsgroup-name)
9410 (now (current-time))
9411 atts lines group-art)
9412 (unless (gnus-check-backend-function 'request-accept-article group)
9413 (error "%s does not support article importing" group))
9414 (or (file-readable-p file)
9415 (not (file-regular-p file))
9416 (error "Can't read %s" file))
9418 (set-buffer (gnus-get-buffer-create " *import file*"))
9420 (nnheader-insert-file-contents file)
9421 (goto-char (point-min))
9422 (if (nnheader-article-p)
9424 (goto-char (point-min))
9425 (search-forward "\n\n" nil t)
9426 (narrow-to-region (point-min) (1- (point)))
9427 (goto-char (point-min))
9428 (unless (re-search-forward "^date:" nil t)
9429 (goto-char (point-max))
9430 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9431 ;; This doesn't look like an article, so we fudge some headers.
9432 (setq atts (file-attributes file)
9433 lines (count-lines (point-min) (point-max)))
9434 (insert "From: " (read-string "From: ") "\n"
9435 "Subject: " (read-string "Subject: ") "\n"
9436 "Date: " (message-make-date (nth 5 atts)) "\n"
9437 "Message-ID: " (message-make-message-id) "\n"
9438 "Lines: " (int-to-string lines) "\n"
9439 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9440 (setq group-art (gnus-request-accept-article group nil t))
9441 (kill-buffer (current-buffer)))
9442 (setq gnus-newsgroup-active (gnus-activate-group group))
9444 (gnus-summary-goto-article (cdr group-art) nil t)
9446 (gnus-summary-edit-article))))
9448 (defun gnus-summary-create-article ()
9449 "Create an article in a mail newsgroup."
9451 (let ((group gnus-newsgroup-name)
9452 (now (current-time))
9454 (unless (gnus-check-backend-function 'request-accept-article group)
9455 (error "%s does not support article importing" group))
9457 (set-buffer (gnus-get-buffer-create " *import file*"))
9459 (goto-char (point-min))
9460 ;; This doesn't look like an article, so we fudge some headers.
9461 (insert "From: " (read-string "From: ") "\n"
9462 "Subject: " (read-string "Subject: ") "\n"
9463 "Date: " (message-make-date now) "\n"
9464 "Message-ID: " (message-make-message-id) "\n")
9465 (setq group-art (gnus-request-accept-article group nil t))
9466 (kill-buffer (current-buffer)))
9467 (setq gnus-newsgroup-active (gnus-activate-group group))
9469 (gnus-summary-goto-article (cdr group-art) nil t)
9470 (gnus-summary-edit-article)))
9472 (defun gnus-summary-article-posted-p ()
9473 "Say whether the current (mail) article is available from news as well.
9474 This will be the case if the article has both been mailed and posted."
9476 (let ((id (mail-header-references (gnus-summary-article-header)))
9477 (gnus-override-method (car (gnus-refer-article-methods))))
9478 (if (gnus-request-head id "")
9479 (gnus-message 2 "The current message was found on %s"
9480 gnus-override-method)
9481 (gnus-message 2 "The current message couldn't be found on %s"
9482 gnus-override-method)
9485 (defun gnus-summary-expire-articles (&optional now)
9486 "Expire all articles that are marked as expirable in the current group."
9488 (when (and (not gnus-group-is-exiting-without-update-p)
9489 (gnus-check-backend-function
9490 'request-expire-articles gnus-newsgroup-name))
9491 ;; This backend supports expiry.
9492 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9493 (expirable (if total
9495 ;; We need to update the info for
9496 ;; this group for `gnus-list-of-read-articles'
9497 ;; to give us the right answer.
9498 (gnus-run-hooks 'gnus-exit-group-hook)
9499 (gnus-summary-update-info)
9500 (gnus-list-of-read-articles gnus-newsgroup-name))
9501 (setq gnus-newsgroup-expirable
9502 (sort gnus-newsgroup-expirable '<))))
9503 (expiry-wait (if now 'immediate
9504 (gnus-group-find-parameter
9505 gnus-newsgroup-name 'expiry-wait)))
9506 (nnmail-expiry-target
9507 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9508 nnmail-expiry-target))
9511 ;; There are expirable articles in this group, so we run them
9512 ;; through the expiry process.
9513 (gnus-message 6 "Expiring articles...")
9514 (unless (gnus-check-group gnus-newsgroup-name)
9515 (error "Can't open server for %s" gnus-newsgroup-name))
9516 ;; The list of articles that weren't expired is returned.
9519 (let ((nnmail-expiry-wait-function nil)
9520 (nnmail-expiry-wait expiry-wait))
9521 (setq es (gnus-request-expire-articles
9522 expirable gnus-newsgroup-name)))
9523 (setq es (gnus-request-expire-articles
9524 expirable gnus-newsgroup-name)))
9526 (setq gnus-newsgroup-expirable es))
9527 ;; We go through the old list of expirable, and mark all
9528 ;; really expired articles as nonexistent.
9529 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9530 (let ((gnus-use-cache nil))
9531 (dolist (article expirable)
9532 (when (and (not (memq article es))
9533 (gnus-data-find article))
9534 (gnus-summary-mark-article article gnus-canceled-mark)
9535 (run-hook-with-args 'gnus-summary-article-expire-hook
9538 (assoc article (gnus-data-list nil)))
9542 (gnus-message 6 "Expiring articles...done")))))
9544 (defun gnus-summary-expire-articles-now ()
9545 "Expunge all expirable articles in the current group.
9546 This means that *all* articles that are marked as expirable will be
9547 deleted forever, right now."
9549 (or gnus-expert-user
9551 "Are you really, really, really sure you want to delete all these messages? ")
9553 (gnus-summary-expire-articles t))
9555 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9556 (defun gnus-summary-delete-article (&optional n)
9557 "Delete the N next (mail) articles.
9558 This command actually deletes articles. This is not a marking
9559 command. The article will disappear forever from your life, never to
9562 If N is negative, delete backwards.
9563 If N is nil and articles have been marked with the process mark,
9564 delete these instead.
9566 If `gnus-novice-user' is non-nil you will be asked for
9567 confirmation before the articles are deleted."
9569 (unless (gnus-check-backend-function 'request-expire-articles
9570 gnus-newsgroup-name)
9571 (error "The current newsgroup does not support article deletion"))
9572 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9573 (error "Couldn't open server"))
9574 ;; Compute the list of articles to delete.
9575 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9576 (nnmail-expiry-target 'delete)
9578 (if (and gnus-novice-user
9579 (not (gnus-yes-or-no-p
9580 (format "Do you really want to delete %s forever? "
9581 (if (> (length articles) 1)
9582 (format "these %s articles" (length articles))
9585 ;; Delete the articles.
9586 (setq not-deleted (gnus-request-expire-articles
9587 articles gnus-newsgroup-name 'force))
9589 (gnus-summary-remove-process-mark (car articles))
9590 ;; The backend might not have been able to delete the article
9592 (unless (memq (car articles) not-deleted)
9593 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9594 (let* ((article (car articles))
9595 (ghead (gnus-data-header
9596 (assoc article (gnus-data-list nil)))))
9597 (run-hook-with-args 'gnus-summary-article-delete-hook
9598 'delete ghead gnus-newsgroup-name nil
9600 (setq articles (cdr articles)))
9602 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9603 (gnus-summary-position-point)
9604 (gnus-set-mode-line 'summary)
9607 (defun gnus-summary-edit-article (&optional arg)
9608 "Edit the current article.
9609 This will have permanent effect only in mail groups.
9610 If ARG is nil, edit the decoded articles.
9611 If ARG is 1, edit the raw articles.
9612 If ARG is 2, edit the raw articles even in read-only groups.
9613 If ARG is 3, edit the articles with the current handles.
9614 Otherwise, allow editing of articles even in read-only
9617 (let (force raw current-handles)
9626 (setq current-handles
9627 (and (gnus-buffer-live-p gnus-article-buffer)
9628 (with-current-buffer gnus-article-buffer
9630 gnus-article-mime-handles
9631 (setq gnus-article-mime-handles nil))))))
9634 (when (and raw (not force)
9635 (member gnus-newsgroup-name '("nndraft:delayed"
9638 (error "Can't edit the raw article in group %s"
9639 gnus-newsgroup-name))
9641 (set-buffer gnus-summary-buffer)
9642 (let ((mail-parse-charset gnus-newsgroup-charset)
9643 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9644 (gnus-set-global-variables)
9645 (when (and (not force)
9646 (gnus-group-read-only-p))
9647 (error "The current newsgroup does not support article editing"))
9648 (gnus-summary-show-article t)
9649 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9650 (with-current-buffer gnus-article-buffer
9651 (mm-enable-multibyte)))
9652 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9654 (gnus-article-edit-article
9657 (let ((mbl mml-buffer-list))
9658 (setq mml-buffer-list nil)
9659 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9660 (mime-to-mml ,'current-handles))
9661 (let ((mbl1 mml-buffer-list))
9662 (setq mml-buffer-list mbl)
9663 (set (make-local-variable 'mml-buffer-list) mbl1))
9664 (gnus-make-local-hook 'kill-buffer-hook)
9665 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9666 `(lambda (no-highlight)
9667 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9668 (message-options message-options)
9669 (message-options-set-recipient)
9670 (mail-parse-ignored-charsets
9671 ',gnus-newsgroup-ignored-charsets))
9672 ,(if (not raw) '(progn
9674 (mml-destroy-buffers)
9675 (remove-hook 'kill-buffer-hook
9676 'mml-destroy-buffers t)
9677 (kill-local-variable 'mml-buffer-list)))
9678 (gnus-summary-edit-article-done
9679 ,(or (mail-header-references gnus-current-headers) "")
9680 ,(gnus-group-read-only-p)
9681 ,gnus-summary-buffer no-highlight))))))))
9683 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9685 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9687 "Make edits to the current article permanent."
9690 ;; The buffer restriction contains the entire article if it exists.
9691 (when (article-goto-body)
9692 (let ((lines (count-lines (point) (point-max)))
9693 (length (- (point-max) (point)))
9694 (case-fold-search t)
9695 (body (copy-marker (point))))
9696 (goto-char (point-min))
9697 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9698 (delete-region (match-beginning 1) (match-end 1))
9699 (insert (number-to-string length)))
9700 (goto-char (point-min))
9701 (when (re-search-forward
9702 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9703 (delete-region (match-beginning 1) (match-end 1))
9704 (insert (number-to-string length)))
9705 (goto-char (point-min))
9706 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9707 (delete-region (match-beginning 1) (match-end 1))
9708 (insert (number-to-string lines))))))
9709 ;; Replace the article.
9710 (let ((buf (current-buffer)))
9712 (insert-buffer-substring buf)
9714 (if (and (not read-only)
9715 (not (gnus-request-replace-article
9716 (cdr gnus-article-current) (car gnus-article-current)
9717 (current-buffer) t)))
9718 (error "Couldn't replace article")
9719 ;; Update the summary buffer.
9721 (equal (message-tokenize-header references " ")
9722 (message-tokenize-header
9723 (or (message-fetch-field "references") "") " ")))
9724 ;; We only have to update this line.
9727 (message-narrow-to-head)
9728 (let ((head (buffer-substring-no-properties
9729 (point-min) (point-max)))
9732 (insert (format "211 %d Article retrieved.\n"
9733 (cdr gnus-article-current)))
9736 (let ((nntp-server-buffer (current-buffer)))
9737 (setq header (car (gnus-get-newsgroup-headers
9740 (set-buffer gnus-summary-buffer)
9741 (gnus-data-set-header
9742 (gnus-data-find (cdr gnus-article-current))
9744 (gnus-summary-update-article-line
9745 (cdr gnus-article-current) header)
9746 (if (gnus-summary-goto-subject
9747 (cdr gnus-article-current) nil t)
9748 (gnus-summary-update-secondary-mark
9749 (cdr gnus-article-current))))))))
9751 (set-buffer (or buffer gnus-summary-buffer))
9752 (gnus-summary-update-article (cdr gnus-article-current))
9753 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9754 (gnus-summary-update-secondary-mark
9755 (cdr gnus-article-current))))
9756 ;; Prettify the article buffer again.
9757 (unless no-highlight
9759 (set-buffer gnus-article-buffer)
9760 ;;;!!! Fix this -- article should be rehighlighted.
9761 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9762 (set-buffer gnus-original-article-buffer)
9763 (gnus-request-article
9764 (cdr gnus-article-current)
9765 (car gnus-article-current) (current-buffer))))
9766 ;; Prettify the summary buffer line.
9767 (when (gnus-visual-p 'summary-highlight 'highlight)
9768 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9770 (defun gnus-summary-edit-wash (key)
9771 "Perform editing command KEY in the article buffer."
9775 (message "%s" (concat (this-command-keys) "- "))
9778 (gnus-summary-edit-article)
9779 (execute-kbd-macro (concat (this-command-keys) key))
9780 (gnus-article-edit-done))
9784 (defun gnus-summary-respool-query (&optional silent trace)
9785 "Query where the respool algorithm would put this article."
9787 (let (gnus-mark-article-hook)
9788 (gnus-summary-select-article)
9790 (set-buffer gnus-original-article-buffer)
9791 (let ((groups (nnmail-article-group 'identity trace)))
9794 (message "This message would go to %s"
9795 (mapconcat 'car groups ", "))
9796 (message "This message would go to no groups"))
9799 (defun gnus-summary-respool-trace ()
9800 "Trace where the respool algorithm would put this article.
9801 Display a buffer showing all fancy splitting patterns which matched."
9803 (gnus-summary-respool-query nil t))
9805 ;; Summary marking commands.
9807 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9808 "Mark articles which has the same subject as read, and then select the next.
9809 If UNMARK is positive, remove any kind of mark.
9810 If UNMARK is negative, tick articles."
9813 (setq unmark (prefix-numeric-value unmark)))
9815 (gnus-summary-mark-same-subject
9816 (gnus-summary-article-subject) unmark)))
9817 ;; Select next unread article. If auto-select-same mode, should
9818 ;; select the first unread article.
9819 (gnus-summary-next-article t (and gnus-auto-select-same
9820 (gnus-summary-article-subject)))
9821 (gnus-message 7 "%d article%s marked as %s"
9822 count (if (= count 1) " is" "s are")
9823 (if unmark "unread" "read"))))
9825 (defun gnus-summary-kill-same-subject (&optional unmark)
9826 "Mark articles which has the same subject as read.
9827 If UNMARK is positive, remove any kind of mark.
9828 If UNMARK is negative, tick articles."
9831 (setq unmark (prefix-numeric-value unmark)))
9833 (gnus-summary-mark-same-subject
9834 (gnus-summary-article-subject) unmark)))
9835 ;; If marked as read, go to next unread subject.
9837 ;; Go to next unread subject.
9838 (gnus-summary-next-subject 1 t))
9839 (gnus-message 7 "%d articles are marked as %s"
9840 count (if unmark "unread" "read"))))
9842 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9843 "Mark articles with same SUBJECT as read, and return marked number.
9844 If optional argument UNMARK is positive, remove any kinds of marks.
9845 If optional argument UNMARK is negative, mark articles as unread instead."
9849 ((null unmark) ; Mark as read.
9852 (gnus-summary-mark-article-as-read gnus-killed-mark)
9853 (gnus-summary-show-thread) t)
9854 (gnus-summary-find-subject subject))
9855 (setq count (1+ count))))
9856 ((> unmark 0) ; Tick.
9859 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9860 (gnus-summary-show-thread) t)
9861 (gnus-summary-find-subject subject))
9862 (setq count (1+ count))))
9863 (t ; Mark as unread.
9866 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9867 (gnus-summary-show-thread) t)
9868 (gnus-summary-find-subject subject))
9869 (setq count (1+ count)))))
9870 (gnus-set-mode-line 'summary)
9871 ;; Return the number of marked articles.
9874 (defun gnus-summary-mark-as-processable (n &optional unmark)
9875 "Set the process mark on the next N articles.
9876 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9877 the process mark instead. The difference between N and the actual
9878 number of articles marked is returned."
9880 (if (and (null n) (gnus-region-active-p))
9881 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9882 (setq n (prefix-numeric-value n))
9883 (let ((backward (< n 0))
9888 (gnus-summary-remove-process-mark
9889 (gnus-summary-article-number))
9890 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9891 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9894 (gnus-message 7 "No more articles"))
9895 (gnus-summary-recenter)
9896 (gnus-summary-position-point)
9899 (defun gnus-summary-unmark-as-processable (n)
9900 "Remove the process mark from the next N articles.
9901 If N is negative, unmark backward instead. The difference between N and
9902 the actual number of articles unmarked is returned."
9904 (gnus-summary-mark-as-processable n t))
9906 (defun gnus-summary-unmark-all-processable ()
9907 "Remove the process mark from all articles."
9910 (while gnus-newsgroup-processable
9911 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9912 (gnus-summary-position-point))
9914 (defun gnus-summary-add-mark (article type)
9915 "Mark ARTICLE with a mark of TYPE."
9916 (let ((vtype (car (assq type gnus-article-mark-lists)))
9919 (error "No such mark type: %s" type)
9920 (setq var (intern (format "gnus-newsgroup-%s" type)))
9921 (set var (cons article (symbol-value var)))
9922 (if (memq type '(processable cached replied forwarded recent saved))
9923 (gnus-summary-update-secondary-mark article)
9924 ;;; !!! This is bogus. We should find out what primary
9925 ;;; !!! mark we want to set.
9926 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9928 (defun gnus-summary-mark-as-expirable (n)
9929 "Mark N articles forward as expirable.
9930 If N is negative, mark backward instead. The difference between N and
9931 the actual number of articles marked is returned."
9933 (gnus-summary-mark-forward n gnus-expirable-mark))
9935 (defun gnus-summary-mark-as-spam (n)
9936 "Mark N articles forward as spam.
9937 If N is negative, mark backward instead. The difference between N and
9938 the actual number of articles marked is returned."
9940 (gnus-summary-mark-forward n gnus-spam-mark))
9942 (defun gnus-summary-mark-article-as-replied (article)
9943 "Mark ARTICLE as replied to and update the summary line.
9944 ARTICLE can also be a list of articles."
9945 (interactive (list (gnus-summary-article-number)))
9946 (let ((articles (if (listp article) article (list article))))
9947 (dolist (article articles)
9948 (unless (numberp article)
9949 (error "%s is not a number" article))
9950 (push article gnus-newsgroup-replied)
9951 (let ((buffer-read-only nil))
9952 (when (gnus-summary-goto-subject article nil t)
9953 (gnus-summary-update-secondary-mark article))))))
9955 (defun gnus-summary-mark-article-as-forwarded (article)
9956 "Mark ARTICLE as forwarded and update the summary line.
9957 ARTICLE can also be a list of articles."
9958 (let ((articles (if (listp article) article (list article))))
9959 (dolist (article articles)
9960 (push article gnus-newsgroup-forwarded)
9961 (let ((buffer-read-only nil))
9962 (when (gnus-summary-goto-subject article nil t)
9963 (gnus-summary-update-secondary-mark article))))))
9965 (defun gnus-summary-set-bookmark (article)
9966 "Set a bookmark in current article."
9967 (interactive (list (gnus-summary-article-number)))
9968 (when (or (not (get-buffer gnus-article-buffer))
9969 (not gnus-current-article)
9970 (not gnus-article-current)
9971 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9972 (error "No current article selected"))
9973 ;; Remove old bookmark, if one exists.
9974 (gnus-pull article gnus-newsgroup-bookmarks)
9975 ;; Set the new bookmark, which is on the form
9976 ;; (article-number . line-number-in-body).
9979 (with-current-buffer gnus-article-buffer
9986 gnus-newsgroup-bookmarks)
9987 (gnus-message 6 "A bookmark has been added to the current article."))
9989 (defun gnus-summary-remove-bookmark (article)
9990 "Remove the bookmark from the current article."
9991 (interactive (list (gnus-summary-article-number)))
9992 ;; Remove old bookmark, if one exists.
9993 (if (not (assq article gnus-newsgroup-bookmarks))
9994 (gnus-message 6 "No bookmark in current article.")
9995 (gnus-pull article gnus-newsgroup-bookmarks)
9996 (gnus-message 6 "Removed bookmark.")))
9998 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9999 (defun gnus-summary-mark-as-dormant (n)
10000 "Mark N articles forward as dormant.
10001 If N is negative, mark backward instead. The difference between N and
10002 the actual number of articles marked is returned."
10004 (gnus-summary-mark-forward n gnus-dormant-mark))
10006 (defun gnus-summary-set-process-mark (article)
10007 "Set the process mark on ARTICLE and update the summary line."
10008 (setq gnus-newsgroup-processable
10010 (delq article gnus-newsgroup-processable)))
10011 (when (gnus-summary-goto-subject article)
10012 (gnus-summary-show-thread)
10013 (gnus-summary-goto-subject article)
10014 (gnus-summary-update-secondary-mark article)))
10016 (defun gnus-summary-remove-process-mark (&rest articles)
10017 "Remove the process mark from ARTICLES and update the summary line."
10018 (dolist (article articles)
10019 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10020 (when (gnus-summary-goto-subject article)
10021 (gnus-summary-show-thread)
10022 (gnus-summary-goto-subject article)
10023 (gnus-summary-update-secondary-mark article))))
10025 (defun gnus-summary-set-saved-mark (article)
10026 "Set the process mark on ARTICLE and update the summary line."
10027 (push article gnus-newsgroup-saved)
10028 (when (gnus-summary-goto-subject article)
10029 (gnus-summary-update-secondary-mark article)))
10031 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10032 "Mark N articles as read forwards.
10033 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10034 The difference between N and the actual number of articles marked is
10036 If NO-EXPIRE, auto-expiry will be inhibited."
10038 (gnus-summary-show-thread)
10039 (let ((backward (< n 0))
10040 (gnus-summary-goto-unread
10041 (and gnus-summary-goto-unread
10042 (not (eq gnus-summary-goto-unread 'never))
10043 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10044 gnus-ticked-mark gnus-dormant-mark)))))
10046 (mark (or mark gnus-del-mark)))
10047 (while (and (> n 0)
10048 (gnus-summary-mark-article nil mark no-expire)
10049 (zerop (gnus-summary-next-subject
10051 (and gnus-summary-goto-unread
10052 (not (eq gnus-summary-goto-unread 'never)))
10056 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10057 (gnus-summary-recenter)
10058 (gnus-summary-position-point)
10059 (gnus-set-mode-line 'summary)
10062 (defun gnus-summary-mark-article-as-read (mark)
10063 "Mark the current article quickly as read with MARK."
10064 (let ((article (gnus-summary-article-number)))
10065 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10066 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10067 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10068 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10069 (push (cons article mark) gnus-newsgroup-reads)
10070 ;; Possibly remove from cache, if that is used.
10071 (when gnus-use-cache
10072 (gnus-cache-enter-remove-article article))
10073 ;; Allow the backend to change the mark.
10074 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10075 ;; Check for auto-expiry.
10076 (when (and gnus-newsgroup-auto-expire
10077 (memq mark gnus-auto-expirable-marks))
10078 (setq mark gnus-expirable-mark)
10079 ;; Let the backend know about the mark change.
10080 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10081 (push article gnus-newsgroup-expirable))
10082 ;; Set the mark in the buffer.
10083 (gnus-summary-update-mark mark 'unread)
10086 (defun gnus-summary-mark-article-as-unread (mark)
10087 "Mark the current article quickly as unread with MARK."
10088 (let* ((article (gnus-summary-article-number))
10089 (old-mark (gnus-summary-article-mark article)))
10090 ;; Allow the backend to change the mark.
10091 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10092 (if (eq mark old-mark)
10096 (gnus-error 1 "Can't mark negative article numbers")
10098 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10099 (setq gnus-newsgroup-spam-marked
10100 (delq article gnus-newsgroup-spam-marked))
10101 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10102 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10103 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10104 (cond ((= mark gnus-ticked-mark)
10105 (setq gnus-newsgroup-marked
10106 (gnus-add-to-sorted-list gnus-newsgroup-marked
10108 ((= mark gnus-spam-mark)
10109 (setq gnus-newsgroup-spam-marked
10110 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10112 ((= mark gnus-dormant-mark)
10113 (setq gnus-newsgroup-dormant
10114 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10117 (setq gnus-newsgroup-unreads
10118 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10120 (gnus-pull article gnus-newsgroup-reads)
10122 ;; See whether the article is to be put in the cache.
10123 (and gnus-use-cache
10124 (vectorp (gnus-summary-article-header article))
10126 (gnus-cache-possibly-enter-article
10127 gnus-newsgroup-name article
10128 (= mark gnus-ticked-mark)
10129 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10132 (gnus-summary-update-mark mark 'unread)
10135 (defun gnus-summary-mark-article (&optional article mark no-expire)
10136 "Mark ARTICLE with MARK. MARK can be any character.
10137 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10138 `??' (dormant) and `?E' (expirable).
10139 If MARK is nil, then the default character `?r' is used.
10140 If ARTICLE is nil, then the article on the current line will be
10142 If NO-EXPIRE, auto-expiry will be inhibited."
10143 ;; The mark might be a string.
10144 (when (stringp mark)
10145 (setq mark (aref mark 0)))
10146 ;; If no mark is given, then we check auto-expiring.
10148 (setq mark gnus-del-mark))
10149 (when (and (not no-expire)
10150 gnus-newsgroup-auto-expire
10151 (memq mark gnus-auto-expirable-marks))
10152 (setq mark gnus-expirable-mark))
10153 (let ((article (or article (gnus-summary-article-number)))
10154 (old-mark (gnus-summary-article-mark article)))
10155 ;; Allow the backend to change the mark.
10156 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10157 (if (eq mark old-mark)
10160 (error "No article on current line"))
10161 (if (not (if (or (= mark gnus-unread-mark)
10162 (= mark gnus-ticked-mark)
10163 (= mark gnus-spam-mark)
10164 (= mark gnus-dormant-mark))
10165 (gnus-mark-article-as-unread article mark)
10166 (gnus-mark-article-as-read article mark)))
10168 ;; See whether the article is to be put in the cache.
10169 (and gnus-use-cache
10170 (not (= mark gnus-canceled-mark))
10171 (vectorp (gnus-summary-article-header article))
10173 (gnus-cache-possibly-enter-article
10174 gnus-newsgroup-name article
10175 (= mark gnus-ticked-mark)
10176 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10178 (when (gnus-summary-goto-subject article nil t)
10179 (let ((buffer-read-only nil))
10180 (gnus-summary-show-thread)
10182 (gnus-summary-update-mark mark 'unread)
10185 (defun gnus-summary-update-secondary-mark (article)
10186 "Update the secondary (read, process, cache) mark."
10187 (gnus-summary-update-mark
10188 (cond ((memq article gnus-newsgroup-processable)
10190 ((memq article gnus-newsgroup-cached)
10192 ((memq article gnus-newsgroup-replied)
10194 ((memq article gnus-newsgroup-forwarded)
10195 gnus-forwarded-mark)
10196 ((memq article gnus-newsgroup-saved)
10198 ((memq article gnus-newsgroup-recent)
10200 ((memq article gnus-newsgroup-unseen)
10204 (when (gnus-visual-p 'summary-highlight 'highlight)
10205 (gnus-run-hooks 'gnus-summary-update-hook))
10208 (defun gnus-summary-update-download-mark (article)
10209 "Update the download mark."
10210 (gnus-summary-update-mark
10211 (cond ((memq article gnus-newsgroup-undownloaded)
10212 gnus-undownloaded-mark)
10213 (gnus-newsgroup-agentized
10214 gnus-downloaded-mark)
10218 (gnus-summary-update-line t)
10221 (defun gnus-summary-update-mark (mark type)
10222 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10223 (buffer-read-only nil))
10224 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10226 (when (looking-at "\r")
10228 (when (<= (+ forward (point)) (point-max))
10229 ;; Go to the right position on the line.
10230 (goto-char (+ forward (point)))
10231 ;; Replace the old mark with the new mark.
10232 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10233 ;; Optionally update the marks by some user rule.
10234 (when (eq type 'unread)
10235 (gnus-data-set-mark
10236 (gnus-data-find (gnus-summary-article-number)) mark)
10237 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10239 (defun gnus-mark-article-as-read (article &optional mark)
10240 "Enter ARTICLE in the pertinent lists and remove it from others."
10241 ;; Make the article expirable.
10242 (let ((mark (or mark gnus-del-mark)))
10243 (setq gnus-newsgroup-expirable
10244 (if (= mark gnus-expirable-mark)
10245 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10246 (delq article gnus-newsgroup-expirable)))
10247 ;; Remove from unread and marked lists.
10248 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10249 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10250 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10251 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10252 (push (cons article mark) gnus-newsgroup-reads)
10253 ;; Possibly remove from cache, if that is used.
10254 (when gnus-use-cache
10255 (gnus-cache-enter-remove-article article))
10258 (defun gnus-mark-article-as-unread (article &optional mark)
10259 "Enter ARTICLE in the pertinent lists and remove it from others."
10260 (let ((mark (or mark gnus-ticked-mark)))
10263 (gnus-error 1 "Can't mark negative article numbers")
10265 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10266 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10267 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10268 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10269 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10271 ;; Unsuppress duplicates?
10272 (when gnus-suppress-duplicates
10273 (gnus-dup-unsuppress-article article))
10275 (cond ((= mark gnus-ticked-mark)
10276 (setq gnus-newsgroup-marked
10277 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10278 ((= mark gnus-spam-mark)
10279 (setq gnus-newsgroup-spam-marked
10280 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10282 ((= mark gnus-dormant-mark)
10283 (setq gnus-newsgroup-dormant
10284 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10286 (setq gnus-newsgroup-unreads
10287 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10288 (gnus-pull article gnus-newsgroup-reads)
10291 (defalias 'gnus-summary-mark-as-unread-forward
10292 'gnus-summary-tick-article-forward)
10293 (make-obsolete 'gnus-summary-mark-as-unread-forward
10294 'gnus-summary-tick-article-forward)
10295 (defun gnus-summary-tick-article-forward (n)
10296 "Tick N articles forwards.
10297 If N is negative, tick backwards instead.
10298 The difference between N and the number of articles ticked is returned."
10300 (gnus-summary-mark-forward n gnus-ticked-mark))
10302 (defalias 'gnus-summary-mark-as-unread-backward
10303 'gnus-summary-tick-article-backward)
10304 (make-obsolete 'gnus-summary-mark-as-unread-backward
10305 'gnus-summary-tick-article-backward)
10306 (defun gnus-summary-tick-article-backward (n)
10307 "Tick N articles backwards.
10308 The difference between N and the number of articles ticked is returned."
10310 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10312 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10313 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10314 (defun gnus-summary-tick-article (&optional article clear-mark)
10315 "Mark current article as unread.
10316 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10317 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10319 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10320 gnus-ticked-mark)))
10322 (defun gnus-summary-mark-as-read-forward (n)
10323 "Mark N articles as read forwards.
10324 If N is negative, mark backwards instead.
10325 The difference between N and the actual number of articles marked is
10328 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10330 (defun gnus-summary-mark-as-read-backward (n)
10331 "Mark the N articles as read backwards.
10332 The difference between N and the actual number of articles marked is
10335 (gnus-summary-mark-forward
10336 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10338 (defun gnus-summary-mark-as-read (&optional article mark)
10339 "Mark current article as read.
10340 ARTICLE specifies the article to be marked as read.
10341 MARK specifies a string to be inserted at the beginning of the line."
10342 (gnus-summary-mark-article article mark))
10344 (defun gnus-summary-clear-mark-forward (n)
10345 "Clear marks from N articles forward.
10346 If N is negative, clear backward instead.
10347 The difference between N and the number of marks cleared is returned."
10349 (gnus-summary-mark-forward n gnus-unread-mark))
10351 (defun gnus-summary-clear-mark-backward (n)
10352 "Clear marks from N articles backward.
10353 The difference between N and the number of marks cleared is returned."
10355 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10357 (defun gnus-summary-mark-unread-as-read ()
10358 "Intended to be used by `gnus-summary-mark-article-hook'."
10359 (when (memq gnus-current-article gnus-newsgroup-unreads)
10360 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10362 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10363 "Intended to be used by `gnus-summary-mark-article-hook'."
10364 (let ((mark (gnus-summary-article-mark)))
10365 (when (or (gnus-unread-mark-p mark)
10366 (gnus-read-mark-p mark))
10367 (gnus-summary-mark-article gnus-current-article
10368 (or new-mark gnus-read-mark)))))
10370 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10371 "Intended to be used by `gnus-summary-mark-article-hook'."
10372 (let ((mark (gnus-summary-article-mark)))
10373 (when (or (gnus-unread-mark-p mark)
10374 (gnus-read-mark-p mark))
10375 (gnus-summary-mark-article (gnus-summary-article-number)
10376 (or new-mark gnus-read-mark)))))
10378 (defun gnus-summary-mark-unread-as-ticked ()
10379 "Intended to be used by `gnus-summary-mark-article-hook'."
10380 (when (memq gnus-current-article gnus-newsgroup-unreads)
10381 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10383 (defun gnus-summary-mark-region-as-read (point mark all)
10384 "Mark all unread articles between point and mark as read.
10385 If given a prefix, mark all articles between point and mark as read,
10386 even ticked and dormant ones."
10387 (interactive "r\nP")
10391 (beginning-of-line)
10396 (memq (setq article (gnus-summary-article-number))
10397 gnus-newsgroup-unreads))
10398 (gnus-summary-mark-article article gnus-del-mark))
10400 (gnus-summary-find-next))))))
10402 (defun gnus-summary-mark-below (score mark)
10403 "Mark articles with score less than SCORE with MARK."
10404 (interactive "P\ncMark: ")
10405 (setq score (if score
10406 (prefix-numeric-value score)
10407 (or gnus-summary-default-score 0)))
10409 (set-buffer gnus-summary-buffer)
10410 (goto-char (point-min))
10413 (and (< (gnus-summary-article-score) score)
10414 (gnus-summary-mark-article nil mark))
10415 (gnus-summary-find-next)))))
10417 (defun gnus-summary-kill-below (&optional score)
10418 "Mark articles with score below SCORE as read."
10420 (gnus-summary-mark-below score gnus-killed-mark))
10422 (defun gnus-summary-clear-above (&optional score)
10423 "Clear all marks from articles with score above SCORE."
10425 (gnus-summary-mark-above score gnus-unread-mark))
10427 (defun gnus-summary-tick-above (&optional score)
10428 "Tick all articles with score above SCORE."
10430 (gnus-summary-mark-above score gnus-ticked-mark))
10432 (defun gnus-summary-mark-above (score mark)
10433 "Mark articles with score over SCORE with MARK."
10434 (interactive "P\ncMark: ")
10435 (setq score (if score
10436 (prefix-numeric-value score)
10437 (or gnus-summary-default-score 0)))
10439 (set-buffer gnus-summary-buffer)
10440 (goto-char (point-min))
10442 (when (> (gnus-summary-article-score) score)
10443 (gnus-summary-mark-article nil mark))
10445 (gnus-summary-find-next)))))
10447 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10448 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10449 (defun gnus-summary-limit-include-expunged (&optional no-error)
10450 "Display all the hidden articles that were expunged for low scores."
10452 (let ((buffer-read-only nil))
10453 (let ((scored gnus-newsgroup-scored)
10456 (unless (gnus-summary-article-header (caar scored))
10457 (and (setq h (gnus-number-to-header (caar scored)))
10458 (< (cdar scored) gnus-summary-expunge-below)
10460 (setq scored (cdr scored)))
10462 (when (not no-error)
10463 (error "No expunged articles hidden"))
10464 (goto-char (point-min))
10465 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10466 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10467 (mapcar (lambda (x) (push (mail-header-number x)
10468 gnus-newsgroup-limit))
10470 (gnus-summary-prepare-unthreaded (nreverse headers))
10471 (goto-char (point-min))
10472 (gnus-summary-position-point)
10475 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10476 "Mark all unread articles in this newsgroup as read.
10477 If prefix argument ALL is non-nil, ticked and dormant articles will
10478 also be marked as read.
10479 If QUIETLY is non-nil, no questions will be asked.
10481 If TO-HERE is non-nil, it should be a point in the buffer. All
10482 articles before (after, if REVERSE is set) this point will be marked
10485 Note that this function will only catch up the unread article
10486 in the current summary buffer limitation.
10488 The number of articles marked as read is returned."
10493 (not gnus-interactive-catchup) ;Without confirmation?
10497 "Mark absolutely all articles as read? "
10498 "Mark all unread articles as read? ")))
10500 (not gnus-newsgroup-adaptive)
10501 (not gnus-newsgroup-auto-expire)
10502 (not gnus-suppress-duplicates)
10503 (or (not gnus-use-cache)
10504 (eq gnus-use-cache 'passive)))
10507 (setq gnus-newsgroup-marked nil
10508 gnus-newsgroup-spam-marked nil
10509 gnus-newsgroup-dormant nil))
10510 (setq gnus-newsgroup-unreads
10511 (gnus-sorted-nunion
10512 (gnus-intersection gnus-newsgroup-unreads
10513 gnus-newsgroup-downloadable)
10514 gnus-newsgroup-unfetched)))
10515 ;; We actually mark all articles as canceled, which we
10516 ;; have to do when using auto-expiry or adaptive scoring.
10517 (gnus-summary-show-all-threads)
10518 (if (and to-here reverse)
10520 (goto-char to-here)
10521 (gnus-summary-mark-current-read-and-unread-as-read
10523 (while (gnus-summary-find-next (not all))
10524 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10525 (when (gnus-summary-first-subject (not all))
10527 (if to-here (< (point) to-here) t)
10528 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10529 (gnus-summary-find-next (not all))))))
10530 (gnus-set-mode-line 'summary))
10532 (gnus-summary-position-point)))
10534 (defun gnus-summary-catchup-to-here (&optional all)
10535 "Mark all unticked articles before the current one as read.
10536 If ALL is non-nil, also mark ticked and dormant articles as read."
10539 (gnus-save-hidden-threads
10540 (let ((beg (point)))
10541 ;; We check that there are unread articles.
10542 (when (or all (gnus-summary-find-prev))
10543 (gnus-summary-catchup all t beg)))))
10544 (gnus-summary-position-point))
10546 (defun gnus-summary-catchup-from-here (&optional all)
10547 "Mark all unticked articles after (and including) the current one as read.
10548 If ALL is non-nil, also mark ticked and dormant articles as read."
10551 (gnus-save-hidden-threads
10552 (let ((beg (point)))
10553 ;; We check that there are unread articles.
10554 (when (or all (gnus-summary-find-next))
10555 (gnus-summary-catchup all t beg nil t)))))
10556 (gnus-summary-position-point))
10558 (defun gnus-summary-catchup-all (&optional quietly)
10559 "Mark all articles in this newsgroup as read.
10560 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10561 instead, which marks only unread articles as read."
10563 (gnus-summary-catchup t quietly))
10565 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10566 "Mark all unread articles in this group as read, then exit.
10567 If prefix argument ALL is non-nil, all articles are marked as read.
10568 If QUIETLY is non-nil, no questions will be asked."
10570 (when (gnus-summary-catchup all quietly nil 'fast)
10571 ;; Select next newsgroup or exit.
10572 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10573 (eq gnus-auto-select-next 'quietly))
10574 (gnus-summary-next-group nil)
10575 (gnus-summary-exit))))
10577 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10578 "Mark all articles in this newsgroup as read, and then exit.
10579 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10580 instead, which marks only unread articles as read."
10582 (gnus-summary-catchup-and-exit t quietly))
10584 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10585 "Mark all articles in this group as read and select the next group.
10586 If given a prefix, mark all articles, unread as well as ticked, as
10590 (gnus-summary-catchup all))
10591 (gnus-summary-next-group))
10593 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
10594 "Mark all articles in this group as read and select the previous group.
10595 If given a prefix, mark all articles, unread as well as ticked, as
10599 (gnus-summary-catchup all))
10600 (gnus-summary-next-group nil nil t))
10606 (defmacro gnus-with-article (article &rest forms)
10607 "Select ARTICLE and perform FORMS in the original article buffer.
10608 Then replace the article with the result."
10610 ;; We don't want the article to be marked as read.
10611 (let (gnus-mark-article-hook)
10612 (gnus-summary-select-article t t nil ,article))
10613 (set-buffer gnus-original-article-buffer)
10615 (if (not (gnus-check-backend-function
10616 'request-replace-article (car gnus-article-current)))
10617 (gnus-message 5 "Read-only group; not replacing")
10618 (unless (gnus-request-replace-article
10619 ,article (car gnus-article-current)
10620 (current-buffer) t)
10621 (error "Couldn't replace article")))
10622 ;; The cache and backlog have to be flushed somewhat.
10623 (when gnus-keep-backlog
10624 (gnus-backlog-remove-article
10625 (car gnus-article-current) (cdr gnus-article-current)))
10626 (when gnus-use-cache
10627 (gnus-cache-update-article
10628 (car gnus-article-current) (cdr gnus-article-current)))))
10630 (put 'gnus-with-article 'lisp-indent-function 1)
10631 (put 'gnus-with-article 'edebug-form-spec '(form body))
10633 ;; Thread-based commands.
10635 (defun gnus-summary-articles-in-thread (&optional article)
10636 "Return a list of all articles in the current thread.
10637 If ARTICLE is non-nil, return all articles in the thread that starts
10638 with that article."
10639 (let* ((article (or article (gnus-summary-article-number)))
10640 (data (gnus-data-find-list article))
10641 (top-level (gnus-data-level (car data)))
10643 (cond ((null gnus-thread-operation-ignore-subject)
10644 (gnus-simplify-subject-re
10645 (mail-header-subject (gnus-data-header (car data)))))
10646 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10647 (gnus-simplify-subject-fuzzy
10648 (mail-header-subject (gnus-data-header (car data)))))
10650 (end-point (save-excursion
10651 (if (gnus-summary-go-to-next-thread)
10652 (point) (point-max))))
10655 (< (gnus-data-pos (car data)) end-point))
10656 (when (or (not top-subject)
10657 (string= top-subject
10658 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10659 (gnus-simplify-subject-fuzzy
10660 (mail-header-subject
10661 (gnus-data-header (car data))))
10662 (gnus-simplify-subject-re
10663 (mail-header-subject
10664 (gnus-data-header (car data)))))))
10665 (push (gnus-data-number (car data)) articles))
10666 (unless (and (setq data (cdr data))
10667 (> (gnus-data-level (car data)) top-level))
10669 ;; Return the list of articles.
10670 (nreverse articles)))
10672 (defun gnus-summary-rethread-current ()
10673 "Rethread the thread the current article is part of."
10675 (let* ((gnus-show-threads t)
10676 (article (gnus-summary-article-number))
10677 (id (mail-header-id (gnus-summary-article-header)))
10678 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10680 (error "No article on the current line"))
10681 (gnus-rebuild-thread id)
10682 (gnus-summary-goto-subject article)))
10684 (defun gnus-summary-reparent-thread ()
10685 "Make the current article child of the marked (or previous) article.
10687 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10688 is non-nil or the Subject: of both articles are the same."
10690 (unless (not (gnus-group-read-only-p))
10691 (error "The current newsgroup does not support article editing"))
10692 (unless (<= (length gnus-newsgroup-processable) 1)
10693 (error "No more than one article may be marked"))
10694 (save-window-excursion
10695 (let ((gnus-article-buffer " *reparent*")
10696 (current-article (gnus-summary-article-number))
10697 ;; First grab the marked article, otherwise one line up.
10698 (parent-article (if (not (null gnus-newsgroup-processable))
10699 (car gnus-newsgroup-processable)
10701 (if (eq (forward-line -1) 0)
10702 (gnus-summary-article-number)
10703 (error "Beginning of summary buffer"))))))
10704 (unless (not (eq current-article parent-article))
10705 (error "An article may not be self-referential"))
10706 (let ((message-id (mail-header-id
10707 (gnus-summary-article-header parent-article))))
10708 (unless (and message-id (not (equal message-id "")))
10709 (error "No message-id in desired parent"))
10710 (gnus-with-article current-article
10712 (goto-char (point-min))
10713 (message-narrow-to-head)
10714 (if (re-search-forward "^References: " nil t)
10716 (re-search-forward "^[^ \t]" nil t)
10719 (insert " " message-id))
10720 (insert "References: " message-id "\n"))))
10721 (set-buffer gnus-summary-buffer)
10722 (gnus-summary-unmark-all-processable)
10723 (gnus-summary-update-article current-article)
10724 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10725 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10726 (gnus-summary-rethread-current)
10727 (gnus-message 3 "Article %d is now the child of article %d"
10728 current-article parent-article)))))
10730 (defun gnus-summary-toggle-threads (&optional arg)
10731 "Toggle showing conversation threads.
10732 If ARG is positive number, turn showing conversation threads on."
10734 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10735 (setq gnus-show-threads
10736 (if (null arg) (not gnus-show-threads)
10737 (> (prefix-numeric-value arg) 0)))
10738 (gnus-summary-prepare)
10739 (gnus-summary-goto-subject current)
10740 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10741 (gnus-summary-position-point)))
10743 (defun gnus-summary-show-all-threads ()
10744 "Show all threads."
10747 (let ((buffer-read-only nil))
10748 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10749 (gnus-summary-position-point))
10751 (defun gnus-summary-show-thread ()
10752 "Show thread subtrees.
10753 Returns nil if no thread was there to be shown."
10755 (let ((buffer-read-only nil)
10757 (end (point-at-eol))
10758 ;; Leave point at bol
10759 (beg (progn (beginning-of-line) (point))))
10761 ;; Any hidden lines here?
10762 (search-forward "\r" end t)
10763 (subst-char-in-region beg end ?\^M ?\n t)
10765 (gnus-summary-position-point))))
10767 (defun gnus-summary-maybe-hide-threads ()
10768 "If requested, hide the threads that should be hidden."
10769 (when (and gnus-show-threads
10770 gnus-thread-hide-subtree)
10771 (gnus-summary-hide-all-threads
10772 (if (or (consp gnus-thread-hide-subtree)
10773 (functionp gnus-thread-hide-subtree))
10774 (gnus-make-predicate gnus-thread-hide-subtree)
10777 ;;; Hiding predicates.
10779 (defun gnus-article-unread-p (header)
10780 (memq (mail-header-number header) gnus-newsgroup-unreads))
10782 (defun gnus-article-unseen-p (header)
10783 (memq (mail-header-number header) gnus-newsgroup-unseen))
10785 (defun gnus-map-articles (predicate articles)
10786 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10787 (apply 'gnus-or (mapcar predicate
10788 (mapcar 'gnus-summary-article-header articles))))
10790 (defun gnus-summary-hide-all-threads (&optional predicate)
10791 "Hide all thread subtrees.
10792 If PREDICATE is supplied, threads that satisfy this predicate
10793 will not be hidden."
10796 (goto-char (point-min))
10799 (when (or (not predicate)
10801 predicate (gnus-summary-article-children)))
10802 (gnus-summary-hide-thread))
10803 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10804 (gnus-summary-position-point))
10806 (defun gnus-summary-hide-thread ()
10807 "Hide thread subtrees.
10808 If PREDICATE is supplied, threads that satisfy this predicate
10809 will not be hidden.
10810 Returns nil if no threads were there to be hidden."
10812 (let ((buffer-read-only nil)
10814 (article (gnus-summary-article-number)))
10816 ;; Go forward until either the buffer ends or the subthread
10818 (when (and (not (eobp))
10819 (or (zerop (gnus-summary-next-thread 1 t))
10820 (goto-char (point-max))))
10822 (if (and (> (point) start)
10823 (search-backward "\n" start t))
10825 (subst-char-in-region start (point) ?\n ?\^M)
10826 (gnus-summary-goto-subject article))
10830 (defun gnus-summary-go-to-next-thread (&optional previous)
10831 "Go to the same level (or less) next thread.
10832 If PREVIOUS is non-nil, go to previous thread instead.
10833 Return the article number moved to, or nil if moving was impossible."
10834 (let ((level (gnus-summary-thread-level))
10835 (way (if previous -1 1))
10838 (while (and (not (eobp))
10839 (< level (gnus-summary-thread-level)))
10840 (forward-line way))
10847 (gnus-summary-article-number)
10848 (goto-char beg)))))
10850 (defun gnus-summary-next-thread (n &optional silent)
10851 "Go to the same level next N'th thread.
10852 If N is negative, search backward instead.
10853 Returns the difference between N and the number of skips actually
10856 If SILENT, don't output messages."
10858 (let ((backward (< n 0))
10860 (while (and (> n 0)
10861 (gnus-summary-go-to-next-thread backward))
10864 (gnus-summary-position-point))
10865 (when (and (not silent) (/= 0 n))
10866 (gnus-message 7 "No more threads"))
10869 (defun gnus-summary-prev-thread (n)
10870 "Go to the same level previous N'th thread.
10871 Returns the difference between N and the number of skips actually
10874 (gnus-summary-next-thread (- n)))
10876 (defun gnus-summary-go-down-thread ()
10877 "Go down one level in the current thread."
10878 (let ((children (gnus-summary-article-children)))
10880 (gnus-summary-goto-subject (car children)))))
10882 (defun gnus-summary-go-up-thread ()
10883 "Go up one level in the current thread."
10884 (let ((parent (gnus-summary-article-parent)))
10886 (gnus-summary-goto-subject parent))))
10888 (defun gnus-summary-down-thread (n)
10889 "Go down thread N steps.
10890 If N is negative, go up instead.
10891 Returns the difference between N and how many steps down that were
10896 (while (and (> n 0)
10897 (if up (gnus-summary-go-up-thread)
10898 (gnus-summary-go-down-thread)))
10900 (gnus-summary-position-point)
10902 (gnus-message 7 "Can't go further"))
10905 (defun gnus-summary-up-thread (n)
10906 "Go up thread N steps.
10907 If N is negative, go down instead.
10908 Returns the difference between N and how many steps down that were
10911 (gnus-summary-down-thread (- n)))
10913 (defun gnus-summary-top-thread ()
10914 "Go to the top of the thread."
10916 (while (gnus-summary-go-up-thread))
10917 (gnus-summary-article-number))
10919 (defun gnus-summary-kill-thread (&optional unmark)
10920 "Mark articles under current thread as read.
10921 If the prefix argument is positive, remove any kinds of marks.
10922 If the prefix argument is negative, tick articles instead."
10925 (setq unmark (prefix-numeric-value unmark)))
10926 (let ((articles (gnus-summary-articles-in-thread)))
10928 ;; Expand the thread.
10929 (gnus-summary-show-thread)
10930 ;; Mark all the articles.
10932 (gnus-summary-goto-subject (car articles))
10933 (cond ((null unmark)
10934 (gnus-summary-mark-article-as-read gnus-killed-mark))
10936 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10938 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10939 (setq articles (cdr articles))))
10940 ;; Hide killed subtrees.
10942 gnus-thread-hide-killed
10943 (gnus-summary-hide-thread))
10944 ;; If marked as read, go to next unread subject.
10945 (when (null unmark)
10946 ;; Go to next unread subject.
10947 (gnus-summary-next-subject 1 t)))
10948 (gnus-set-mode-line 'summary))
10950 ;; Summary sorting commands
10952 (defun gnus-summary-sort-by-number (&optional reverse)
10953 "Sort the summary buffer by article number.
10954 Argument REVERSE means reverse order."
10956 (gnus-summary-sort 'number reverse))
10958 (defun gnus-summary-sort-by-random (&optional reverse)
10959 "Randomize the order in the summary buffer.
10960 Argument REVERSE means to randomize in reverse order."
10962 (gnus-summary-sort 'random reverse))
10964 (defun gnus-summary-sort-by-author (&optional reverse)
10965 "Sort the summary buffer by author name alphabetically.
10966 If `case-fold-search' is non-nil, case of letters is ignored.
10967 Argument REVERSE means reverse order."
10969 (gnus-summary-sort 'author reverse))
10971 (defun gnus-summary-sort-by-recipient (&optional reverse)
10972 "Sort the summary buffer by recipient name alphabetically.
10973 If `case-fold-search' is non-nil, case of letters is ignored.
10974 Argument REVERSE means reverse order."
10976 (gnus-summary-sort 'recipient reverse))
10978 (defun gnus-summary-sort-by-subject (&optional reverse)
10979 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10980 If `case-fold-search' is non-nil, case of letters is ignored.
10981 Argument REVERSE means reverse order."
10983 (gnus-summary-sort 'subject reverse))
10985 (defun gnus-summary-sort-by-date (&optional reverse)
10986 "Sort the summary buffer by date.
10987 Argument REVERSE means reverse order."
10989 (gnus-summary-sort 'date reverse))
10991 (defun gnus-summary-sort-by-score (&optional reverse)
10992 "Sort the summary buffer by score.
10993 Argument REVERSE means reverse order."
10995 (gnus-summary-sort 'score reverse))
10997 (defun gnus-summary-sort-by-lines (&optional reverse)
10998 "Sort the summary buffer by the number of lines.
10999 Argument REVERSE means reverse order."
11001 (gnus-summary-sort 'lines reverse))
11003 (defun gnus-summary-sort-by-chars (&optional reverse)
11004 "Sort the summary buffer by article length.
11005 Argument REVERSE means reverse order."
11007 (gnus-summary-sort 'chars reverse))
11009 (defun gnus-summary-sort-by-original (&optional reverse)
11010 "Sort the summary buffer using the default sorting method.
11011 Argument REVERSE means reverse order."
11013 (let* ((buffer-read-only)
11014 (gnus-summary-prepare-hook nil))
11015 ;; We do the sorting by regenerating the threads.
11016 (gnus-summary-prepare)
11017 ;; Hide subthreads if needed.
11018 (gnus-summary-maybe-hide-threads)))
11020 (defun gnus-summary-sort (predicate reverse)
11021 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11022 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11023 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11024 (gnus-thread-sort-functions
11029 (gnus-sort-gathered-threads-function
11030 gnus-thread-sort-functions)
11031 (gnus-article-sort-functions
11035 (,article t2 t1))))
11037 (gnus-summary-prepare-hook nil))
11038 ;; We do the sorting by regenerating the threads.
11039 (gnus-summary-prepare)
11040 ;; Hide subthreads if needed.
11041 (gnus-summary-maybe-hide-threads)))
11043 ;; Summary saving commands.
11045 (defun gnus-summary-save-article (&optional n not-saved)
11046 "Save the current article using the default saver function.
11047 If N is a positive number, save the N next articles.
11048 If N is a negative number, save the N previous articles.
11049 If N is nil and any articles have been marked with the process mark,
11050 save those articles instead.
11051 The variable `gnus-default-article-saver' specifies the saver function."
11053 (let* ((articles (gnus-summary-work-articles n))
11054 (save-buffer (save-excursion
11055 (nnheader-set-temp-buffer " *Gnus Save*")))
11056 (num (length articles))
11058 (dolist (article articles)
11059 (setq header (gnus-summary-article-header article))
11060 (if (not (vectorp header))
11061 ;; This is a pseudo-article.
11062 (if (assq 'name header)
11063 (gnus-copy-file (cdr (assq 'name header)))
11064 (gnus-message 1 "Article %d is unsaveable" article))
11065 ;; This is a real article.
11066 (save-window-excursion
11067 (let ((gnus-display-mime-function nil)
11068 (gnus-article-prepare-hook nil))
11069 (gnus-summary-select-article t nil nil article)))
11071 (set-buffer save-buffer)
11073 (insert-buffer-substring gnus-original-article-buffer))
11074 (setq file (gnus-article-save save-buffer file num))
11075 (gnus-summary-remove-process-mark article)
11077 (gnus-summary-set-saved-mark article))))
11078 (gnus-kill-buffer save-buffer)
11079 (gnus-summary-position-point)
11080 (gnus-set-mode-line 'summary)
11083 (defun gnus-summary-pipe-output (&optional arg headers)
11084 "Pipe the current article to a subprocess.
11085 If N is a positive number, pipe the N next articles.
11086 If N is a negative number, pipe the N previous articles.
11087 If N is nil and any articles have been marked with the process mark,
11088 pipe those articles instead.
11089 If HEADERS (the symbolic prefix), include the headers, too."
11090 (interactive (gnus-interactive "P\ny"))
11091 (require 'gnus-art)
11092 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11093 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11094 (gnus-summary-save-article arg t))
11095 (let ((buffer (get-buffer "*Shell Command Output*")))
11097 (not (zerop (buffer-size buffer))))
11098 (gnus-configure-windows 'pipe))))
11100 (defun gnus-summary-save-article-mail (&optional arg)
11101 "Append the current article to an mail 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-mail))
11109 (gnus-summary-save-article arg)))
11111 (defun gnus-summary-save-article-rmail (&optional arg)
11112 "Append the current article to an rmail 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-rmail))
11120 (gnus-summary-save-article arg)))
11122 (defun gnus-summary-save-article-file (&optional arg)
11123 "Append the current article to a 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-save-in-file))
11131 (gnus-summary-save-article arg)))
11133 (defun gnus-summary-write-article-file (&optional arg)
11134 "Write the current article to a file, deleting the previous 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-write-to-file))
11142 (gnus-summary-save-article arg)))
11144 (defun gnus-summary-save-article-body-file (&optional arg)
11145 "Append the current article body to a file.
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-save-body-in-file))
11153 (gnus-summary-save-article arg)))
11155 (defun gnus-summary-muttprint (&optional arg)
11156 "Print the current article using Muttprint.
11157 If N is a positive number, save the N next articles.
11158 If N is a negative number, save the N previous articles.
11159 If N is nil and any articles have been marked with the process mark,
11160 save those articles instead."
11162 (require 'gnus-art)
11163 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11164 (gnus-summary-save-article arg t)))
11166 (defun gnus-summary-pipe-message (program)
11167 "Pipe the current article through PROGRAM."
11168 (interactive "sProgram: ")
11169 (gnus-summary-select-article)
11170 (let ((mail-header-separator ""))
11171 (gnus-eval-in-buffer-window gnus-article-buffer
11174 (let ((start (window-start))
11176 (message-pipe-buffer-body program)
11177 (set-window-start (get-buffer-window (current-buffer)) start))))))
11179 (defun gnus-get-split-value (methods)
11180 "Return a value based on the split METHODS."
11181 (let (split-name method result match)
11184 (set-buffer gnus-original-article-buffer)
11186 (nnheader-narrow-to-headers)
11187 (while (and methods (not split-name))
11188 (goto-char (point-min))
11189 (setq method (pop methods))
11190 (setq match (car method))
11193 ;; Regular expression.
11195 (re-search-forward match nil t)))
11200 (setq result (funcall match gnus-newsgroup-name))))
11205 (setq result (eval match)))))
11206 (setq split-name (cdr method))
11207 (cond ((stringp result)
11208 (push (expand-file-name
11209 result gnus-article-save-directory)
11212 (setq split-name (append result split-name)))))))))
11213 (nreverse split-name)))
11215 (defun gnus-valid-move-group-p (group)
11216 (and (boundp group)
11217 (symbol-name group)
11218 (symbol-value group)
11219 (gnus-get-function (gnus-find-method-for-group
11220 (symbol-name group)) 'request-accept-article t)))
11222 (defun gnus-read-move-group-name (prompt default articles prefix)
11223 "Read a group name."
11224 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11225 (minibuffer-confirm-incomplete nil) ; XEmacs
11229 (if (> (length articles) 1)
11230 (format "these %d articles" (length articles))
11235 (gnus-completing-read-with-default
11238 'gnus-valid-move-group-p
11240 'gnus-group-history))
11241 ((= 1 (length split-name))
11242 (gnus-completing-read-with-default
11243 (car split-name) prom
11245 'gnus-valid-move-group-p
11247 'gnus-group-history))
11249 (gnus-completing-read-with-default
11251 (mapcar 'list (nreverse split-name))
11253 'gnus-group-history))))
11254 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11256 (if (or (string= to-newsgroup "")
11257 (string= to-newsgroup prefix))
11258 (setq to-newsgroup default))
11259 (unless to-newsgroup
11260 (error "No group name entered"))
11261 (or (gnus-active to-newsgroup)
11262 (gnus-activate-group to-newsgroup nil nil to-method)
11263 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11265 (or (and (gnus-request-create-group to-newsgroup to-method)
11266 (gnus-activate-group
11267 to-newsgroup nil nil to-method)
11268 (gnus-subscribe-group to-newsgroup))
11269 (error "Couldn't create group %s" to-newsgroup)))
11270 (error "No such group: %s" to-newsgroup)))
11273 (defun gnus-summary-save-parts (type dir n &optional reverse)
11274 "Save parts matching TYPE to DIR.
11275 If REVERSE, save parts that do not match TYPE."
11277 (list (read-string "Save parts of type: "
11278 (or (car gnus-summary-save-parts-type-history)
11279 gnus-summary-save-parts-default-mime)
11280 'gnus-summary-save-parts-type-history)
11281 (setq gnus-summary-save-parts-last-directory
11282 (read-file-name "Save to directory: "
11283 gnus-summary-save-parts-last-directory
11285 current-prefix-arg))
11286 (gnus-summary-iterate n
11287 (let ((gnus-display-mime-function nil)
11288 (gnus-inhibit-treatment t))
11289 (gnus-summary-select-article))
11291 (set-buffer gnus-article-buffer)
11292 (let ((handles (or gnus-article-mime-handles
11293 (mm-dissect-buffer nil gnus-article-loose-mime)
11294 (and gnus-article-emulate-mime
11295 (mm-uu-dissect)))))
11297 (gnus-summary-save-parts-1 type dir handles reverse)
11298 (unless gnus-article-mime-handles ;; Don't destroy this case.
11299 (mm-destroy-parts handles)))))))
11301 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11302 (if (stringp (car handle))
11303 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11306 (not (string-match type (mm-handle-media-type handle)))
11307 (string-match type (mm-handle-media-type handle)))
11308 (let ((file (expand-file-name
11310 mm-file-name-rewrite-functions
11311 (file-name-nondirectory
11313 (mail-content-type-get
11314 (mm-handle-disposition handle) 'filename)
11315 (mail-content-type-get
11316 (mm-handle-type handle) 'name)
11317 (concat gnus-newsgroup-name
11318 "." (number-to-string
11319 (cdr gnus-article-current))))))
11321 (unless (file-exists-p file)
11322 (mm-save-part-to-file handle file))))))
11324 ;; Summary extract commands
11326 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11327 (let ((buffer-read-only nil)
11328 (article (gnus-summary-article-number))
11330 (unless (gnus-summary-goto-subject article)
11331 (error "No such article: %d" article))
11332 (gnus-summary-position-point)
11333 ;; If all commands are to be bunched up on one line, we collect
11335 (unless gnus-view-pseudos-separately
11336 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11339 (setq action (cdr (assq 'action (car ps))))
11340 (setq files (list (cdr (assq 'name (car ps)))))
11341 (while (and ps (cdr ps)
11342 (string= (or action "1")
11343 (or (cdr (assq 'action (cadr ps))) "2")))
11344 (push (cdr (assq 'name (cadr ps))) files)
11345 (setcdr ps (cddr ps)))
11347 (when (not (string-match "%s" action))
11350 (when (assq 'execute (car ps))
11351 (setcdr (assq 'execute (car ps))
11352 (funcall (if (string-match "%s" action)
11359 (shell-quote-argument f)))
11361 (setq ps (cdr ps)))))
11362 (if (and gnus-view-pseudos (not not-view))
11364 (when (assq 'execute (car pslist))
11365 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11366 (eq gnus-view-pseudos 'not-confirm)))
11367 (setq pslist (cdr pslist)))
11370 (setq after-article (or (cdr (assq 'article (car pslist)))
11371 (gnus-summary-article-number)))
11372 (gnus-summary-goto-subject after-article)
11375 (insert " " (file-name-nondirectory
11376 (cdr (assq 'name (car pslist))))
11377 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11379 (forward-line -1) ; back to `b'
11380 (gnus-add-text-properties
11381 b (1- e) (list 'gnus-number gnus-reffed-article-number
11382 gnus-mouse-face-prop gnus-mouse-face))
11384 after-article gnus-reffed-article-number
11385 gnus-unread-mark b (car pslist) 0 (- e b))
11386 (setq gnus-newsgroup-unreads
11387 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11388 gnus-reffed-article-number))
11389 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11390 (setq pslist (cdr pslist)))))))
11392 (defun gnus-pseudos< (p1 p2)
11393 (let ((c1 (cdr (assq 'action p1)))
11394 (c2 (cdr (assq 'action p2))))
11395 (and c1 c2 (string< c1 c2))))
11397 (defun gnus-request-pseudo-article (props)
11398 (cond ((assq 'execute props)
11399 (gnus-execute-command (cdr (assq 'execute props)))))
11400 (let ((gnus-current-article (gnus-summary-article-number)))
11401 (gnus-run-hooks 'gnus-mark-article-hook)))
11403 (defun gnus-execute-command (command &optional automatic)
11405 (gnus-article-setup-buffer)
11406 (set-buffer gnus-article-buffer)
11407 (setq buffer-read-only nil)
11408 (let ((command (if automatic command
11409 (read-string "Command: " (cons command 0)))))
11411 (insert "$ " command "\n\n")
11412 (if gnus-view-pseudo-asynchronously
11413 (start-process "gnus-execute" (current-buffer) shell-file-name
11414 shell-command-switch command)
11415 (call-process shell-file-name nil t nil
11416 shell-command-switch command)))))
11418 ;; Summary kill commands.
11420 (defun gnus-summary-edit-global-kill (article)
11421 "Edit the \"global\" kill file."
11422 (interactive (list (gnus-summary-article-number)))
11423 (gnus-group-edit-global-kill article))
11425 (defun gnus-summary-edit-local-kill ()
11426 "Edit a local kill file applied to the current newsgroup."
11428 (setq gnus-current-headers (gnus-summary-article-header))
11429 (gnus-group-edit-local-kill
11430 (gnus-summary-article-number) gnus-newsgroup-name))
11432 ;;; Header reading.
11434 (defun gnus-read-header (id &optional header)
11435 "Read the headers of article ID and enter them into the Gnus system."
11436 (let ((group gnus-newsgroup-name)
11437 (gnus-override-method
11439 gnus-override-method
11440 (and (gnus-news-group-p gnus-newsgroup-name)
11441 (car (gnus-refer-article-methods)))))
11443 ;; First we check to see whether the header in question is already
11446 ;; This is a Message-ID.
11447 (setq header (or header (gnus-id-to-header id)))
11448 ;; This is an article number.
11449 (setq header (or header (gnus-summary-article-header id))))
11451 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11452 ;; We have found the header.
11454 ;; We have to really fetch the header to this article.
11456 (set-buffer nntp-server-buffer)
11457 (when (setq where (gnus-request-head id group))
11458 (nnheader-fold-continuation-lines)
11459 (goto-char (point-max))
11461 (goto-char (point-min))
11465 ((cdr where) (cdr where))
11466 (header (mail-header-number header))
11467 (t gnus-reffed-article-number))
11469 (insert " Article retrieved.\n"))
11470 (if (or (not where)
11471 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11472 () ; Malformed head.
11473 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11474 (when (and (stringp id)
11475 (not (string= (gnus-group-real-name group)
11477 ;; If we fetched by Message-ID and the article came
11478 ;; from a different group, we fudge some bogus article
11479 ;; numbers for this article.
11480 (mail-header-set-number header gnus-reffed-article-number))
11482 (set-buffer gnus-summary-buffer)
11483 (decf gnus-reffed-article-number)
11484 (gnus-remove-header (mail-header-number header))
11485 (push header gnus-newsgroup-headers)
11486 (setq gnus-current-headers header)
11487 (push (mail-header-number header) gnus-newsgroup-limit)))
11490 (defun gnus-remove-header (number)
11491 "Remove header NUMBER from `gnus-newsgroup-headers'."
11492 (if (and gnus-newsgroup-headers
11493 (= number (mail-header-number (car gnus-newsgroup-headers))))
11494 (pop gnus-newsgroup-headers)
11495 (let ((headers gnus-newsgroup-headers))
11496 (while (and (cdr headers)
11497 (not (= number (mail-header-number (cadr headers)))))
11499 (when (cdr headers)
11500 (setcdr headers (cddr headers))))))
11503 ;;; summary highlights
11506 (defun gnus-highlight-selected-summary ()
11507 "Highlight selected article in summary buffer."
11508 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11509 (when gnus-summary-selected-face
11511 (let* ((beg (point-at-bol))
11512 (end (point-at-eol))
11513 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11514 (from (if (get-text-property beg gnus-mouse-face-prop)
11516 (or (next-single-property-change
11517 beg gnus-mouse-face-prop nil end)
11522 (or (next-single-property-change
11523 from gnus-mouse-face-prop nil end)
11525 ;; If no mouse-face prop on line we will have to = from = end,
11526 ;; so we highlight the entire line instead.
11527 (when (= (+ to 2) from)
11530 (if gnus-newsgroup-selected-overlay
11531 ;; Move old overlay.
11533 gnus-newsgroup-selected-overlay from to (current-buffer))
11534 ;; Create new overlay.
11536 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11537 'face gnus-summary-selected-face))))))
11539 (defvar gnus-summary-highlight-line-cached nil)
11540 (defvar gnus-summary-highlight-line-trigger nil)
11542 (defun gnus-summary-highlight-line-0 ()
11543 (if (and (eq gnus-summary-highlight-line-trigger
11544 gnus-summary-highlight)
11545 gnus-summary-highlight-line-cached)
11546 gnus-summary-highlight-line-cached
11547 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11548 gnus-summary-highlight-line-cached
11549 (let* ((cond (list 'cond))
11551 (list gnus-summary-highlight))
11553 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11557 (gnus-byte-compile (list 'lambda nil cond))))))
11559 (defun gnus-summary-highlight-line ()
11560 "Highlight current line according to `gnus-summary-highlight'."
11561 (let* ((beg (point-at-bol))
11562 (article (or (gnus-summary-article-number) gnus-current-article))
11563 (score (or (cdr (assq article
11564 gnus-newsgroup-scored))
11565 gnus-summary-default-score 0))
11566 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11567 (inhibit-read-only t)
11568 (default gnus-summary-default-score)
11569 (default-high gnus-summary-default-high-score)
11570 (default-low gnus-summary-default-low-score)
11571 (uncached (and gnus-summary-use-undownloaded-faces
11572 (memq article gnus-newsgroup-undownloaded)
11573 (not (memq article gnus-newsgroup-cached)))))
11574 (let ((face (funcall (gnus-summary-highlight-line-0))))
11575 (unless (eq face (get-text-property beg 'face))
11576 (gnus-put-text-property-excluding-characters-with-faces
11577 beg (point-at-eol) 'face
11578 (setq face (if (boundp face) (symbol-value face) face)))
11579 (when gnus-summary-highlight-line-function
11580 (funcall gnus-summary-highlight-line-function article face))))))
11582 (defun gnus-update-read-articles (group unread &optional compute)
11583 "Update the list of read articles in GROUP.
11584 UNREAD is a sorted list."
11585 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11586 (info (gnus-get-info group))
11589 (if (or (not info) (not active))
11590 ;; There is no info on this group if it was, in fact,
11591 ;; killed. Gnus stores no information on killed groups, so
11592 ;; there's nothing to be done.
11593 ;; One could store the information somewhere temporarily,
11594 ;; perhaps... Hmmm...
11596 ;; Remove any negative articles numbers.
11597 (while (and unread (< (car unread) 0))
11598 (setq unread (cdr unread)))
11599 ;; Remove any expired article numbers
11600 (while (and unread (< (car unread) (car active)))
11601 (setq unread (cdr unread)))
11602 ;; Compute the ranges of read articles by looking at the list of
11603 ;; unread articles.
11605 (when (/= (car unread) prev)
11606 (push (if (= prev (1- (car unread))) prev
11607 (cons prev (1- (car unread))))
11609 (setq prev (1+ (car unread)))
11610 (setq unread (cdr unread)))
11611 (when (<= prev (cdr active))
11612 (push (cons prev (cdr active)) read))
11613 (setq read (if (> (length read) 1) (nreverse read) read))
11618 ;; Propagate the read marks to the backend.
11619 (when (gnus-check-backend-function 'request-set-mark group)
11620 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11621 (add (gnus-remove-from-range read (gnus-info-read info))))
11623 (unless (gnus-check-group group)
11624 (error "Can't open server for %s" group))
11625 (gnus-request-set-mark
11626 group (delq nil (list (if add (list add 'add '(read)))
11627 (if del (list del 'del '(read))))))
11629 `(gnus-request-set-mark
11632 (if del (list del 'add '(read)))
11633 (if add (list add 'del '(read))))))))))
11634 (set-buffer gnus-group-buffer)
11635 (gnus-undo-register
11637 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11638 (gnus-info-set-read ',info ',(gnus-info-read info))
11639 (gnus-get-unread-articles-in-group ',info
11640 (gnus-active ,group))
11641 (gnus-group-update-group ,group t)
11643 ;; Enter this list into the group info.
11644 (gnus-info-set-read info read)
11645 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11646 (gnus-get-unread-articles-in-group info (gnus-active group))
11649 (defun gnus-offer-save-summaries ()
11650 "Offer to save all active summary buffers."
11652 ;; Go through all buffers and find all summaries.
11653 (dolist (buffer (buffer-list))
11654 (when (and (setq buffer (buffer-name buffer))
11655 (string-match "Summary" buffer)
11656 (with-current-buffer buffer
11657 ;; We check that this is, indeed, a summary buffer.
11658 (and (eq major-mode 'gnus-summary-mode)
11659 ;; Also make sure this isn't bogus.
11660 gnus-newsgroup-prepared
11661 ;; Also make sure that this isn't a
11662 ;; dead summary buffer.
11663 (not gnus-dead-summary-mode))))
11664 (push buffer buffers)))
11665 ;; Go through all these summary buffers and offer to save them.
11669 "Update summary buffer %s? "
11671 (switch-to-buffer buf)
11672 (gnus-summary-exit))
11675 (defun gnus-summary-setup-default-charset ()
11676 "Setup newsgroup default charset."
11677 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11678 (setq gnus-newsgroup-charset nil)
11679 (let* ((ignored-charsets
11680 (or gnus-newsgroup-ephemeral-ignored-charsets
11682 (and gnus-newsgroup-name
11683 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11684 gnus-newsgroup-ignored-charsets))))
11685 (setq gnus-newsgroup-charset
11686 (or gnus-newsgroup-ephemeral-charset
11687 (and gnus-newsgroup-name
11688 (gnus-parameter-charset gnus-newsgroup-name))
11689 gnus-default-charset))
11690 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11691 ignored-charsets))))
11697 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11698 "Display the current article buffer fully MIME-buttonized.
11699 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11700 treated as multipart/mixed."
11702 (require 'gnus-art)
11703 (let ((gnus-unbuttonized-mime-types nil)
11704 (gnus-mime-display-multipart-as-mixed show-all-parts))
11705 (gnus-summary-show-article)))
11707 (defun gnus-summary-repair-multipart (article)
11708 "Add a Content-Type header to a multipart article without one."
11709 (interactive (list (gnus-summary-article-number)))
11710 (gnus-with-article article
11711 (message-narrow-to-head)
11712 (message-remove-header "Mime-Version")
11713 (goto-char (point-max))
11714 (insert "Mime-Version: 1.0\n")
11716 (when (search-forward "\n--" nil t)
11717 (let ((separator (buffer-substring (point) (point-at-eol))))
11718 (message-narrow-to-head)
11719 (message-remove-header "Content-Type")
11720 (goto-char (point-max))
11721 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11724 (let (gnus-mark-article-hook)
11725 (gnus-summary-select-article t t nil article)))
11727 (defun gnus-summary-toggle-display-buttonized ()
11728 "Toggle the buttonizing of the article buffer."
11730 (require 'gnus-art)
11731 (if (setq gnus-inhibit-mime-unbuttonizing
11732 (not gnus-inhibit-mime-unbuttonizing))
11733 (let ((gnus-unbuttonized-mime-types nil))
11734 (gnus-summary-show-article))
11735 (gnus-summary-show-article)))
11738 ;;; Generic summary marking commands
11741 (defvar gnus-summary-marking-alist
11742 '((read gnus-del-mark "d")
11743 (unread gnus-unread-mark "u")
11744 (ticked gnus-ticked-mark "!")
11745 (dormant gnus-dormant-mark "?")
11746 (expirable gnus-expirable-mark "e"))
11747 "An alist of names/marks/keystrokes.")
11749 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11750 (defvar gnus-summary-mark-map)
11752 (defun gnus-summary-make-all-marking-commands ()
11753 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11754 (dolist (elem gnus-summary-marking-alist)
11755 (apply 'gnus-summary-make-marking-command elem)))
11757 (defun gnus-summary-make-marking-command (name mark keystroke)
11758 (let ((map (make-sparse-keymap)))
11759 (define-key gnus-summary-generic-mark-map keystroke map)
11760 (dolist (lway `((next "next" next nil "n")
11761 (next-unread "next unread" next t "N")
11762 (prev "previous" prev nil "p")
11763 (prev-unread "previous unread" prev t "P")
11764 (nomove "" nil nil ,keystroke)))
11765 (let ((func (gnus-summary-make-marking-command-1
11766 mark (car lway) lway name)))
11767 (setq func (eval func))
11768 (define-key map (nth 4 lway) func)))))
11770 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11772 (format "gnus-summary-put-mark-as-%s%s"
11773 name (if (eq way 'nomove)
11775 (concat "-" (symbol-name way)))))
11778 "Mark the current article as %s%s.
11779 If N, the prefix, then repeat N times.
11780 If N is negative, move in reverse order.
11781 The difference between N and the actual number of articles marked is
11785 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11787 (defun gnus-summary-generic-mark (n mark move unread)
11788 "Mark N articles with MARK."
11789 (unless (eq major-mode 'gnus-summary-mode)
11790 (error "This command can only be used in the summary buffer"))
11791 (gnus-summary-show-thread)
11794 ((eq move 'next) 1)
11795 ((eq move 'prev) -1)
11797 (if (zerop nummove)
11801 nummove (* -1 nummove))))
11802 (while (and (> n 0)
11803 (gnus-summary-mark-article nil mark)
11804 (zerop (gnus-summary-next-subject nummove unread t)))
11807 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11808 (gnus-summary-recenter)
11809 (gnus-summary-position-point)
11810 (gnus-set-mode-line 'summary)
11813 (defun gnus-summary-insert-articles (articles)
11814 (when (setq articles
11815 (gnus-sorted-difference articles
11816 (mapcar (lambda (h)
11817 (mail-header-number h))
11818 gnus-newsgroup-headers)))
11819 (setq gnus-newsgroup-headers
11821 gnus-newsgroup-headers
11822 (gnus-fetch-headers articles)
11823 'gnus-article-sort-by-number))
11824 ;; Suppress duplicates?
11825 (when gnus-suppress-duplicates
11826 (gnus-dup-suppress-articles))
11828 ;; We might want to build some more threads first.
11829 (when (and gnus-fetch-old-headers
11830 (eq gnus-headers-retrieved-by 'nov))
11831 (if (eq gnus-fetch-old-headers 'invisible)
11832 (gnus-build-all-threads)
11833 (gnus-build-old-threads)))
11834 ;; Let the Gnus agent mark articles as read.
11836 (gnus-agent-get-undownloaded-list))
11837 ;; Remove list identifiers from subject
11838 (when gnus-list-identifiers
11839 (gnus-summary-remove-list-identifiers))
11840 ;; First and last article in this newsgroup.
11841 (when gnus-newsgroup-headers
11842 (setq gnus-newsgroup-begin
11843 (mail-header-number (car gnus-newsgroup-headers))
11845 (mail-header-number
11846 (gnus-last-element gnus-newsgroup-headers))))
11847 (when gnus-use-scoring
11848 (gnus-possibly-score-headers))))
11850 (defun gnus-summary-insert-old-articles (&optional all)
11851 "Insert all old articles in this group.
11852 If ALL is non-nil, already read articles become readable.
11853 If ALL is a number, fetch this number of articles."
11856 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11859 ;; Some nntp servers lie about their active range. When
11860 ;; this happens, the active range can be in the millions.
11861 ;; Use a compressed range to avoid creating a huge list.
11862 (gnus-range-difference (list gnus-newsgroup-active) old))
11863 (setq len (gnus-range-length older))
11868 (let ((older-range (nreverse older)))
11872 (let* ((r (pop older-range))
11873 (min (if (numberp r) r (car r)))
11874 (max (if (numberp r) r (cdr r))))
11875 (while (and (<= min max)
11880 (setq older (gnus-uncompress-range older))))
11882 (setq older (gnus-uncompress-range older)))
11884 (when (and (numberp gnus-large-newsgroup)
11885 (> len gnus-large-newsgroup))
11886 (let* ((cursor-in-echo-area nil)
11887 (initial (gnus-parameter-large-newsgroup-initial
11888 gnus-newsgroup-name))
11892 "How many articles from %s (%s %d): "
11894 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11895 (if initial "max" "default")
11898 (cons (number-to-string initial)
11900 (unless (string-match "^[ \t]*$" input)
11901 (setq all (string-to-number input))
11903 (let ((older-range (nreverse older)))
11907 (let* ((r (pop older-range))
11908 (min (if (numberp r) r (car r)))
11909 (max (if (numberp r) r (cdr r))))
11910 (while (and (<= min max)
11914 max (1- max))))))))))
11915 (setq older (gnus-uncompress-range older))))
11917 (message "No old news.")
11918 (gnus-summary-insert-articles older)
11919 (gnus-summary-limit (gnus-sorted-nunion old older))))
11920 (gnus-summary-position-point)))
11922 (defun gnus-summary-insert-new-articles ()
11923 "Insert all new articles in this group."
11926 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11927 (old-active gnus-newsgroup-active)
11928 (nnmail-fetched-sources (list t))
11930 (setq gnus-newsgroup-active
11931 (gnus-activate-group gnus-newsgroup-name 'scan))
11932 (setq i (cdr gnus-newsgroup-active))
11933 (while (> i (cdr old-active))
11937 (message "No gnus is bad news")
11938 (gnus-summary-insert-articles new)
11939 (setq gnus-newsgroup-unreads
11940 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11941 (gnus-summary-limit (gnus-sorted-nunion old new))))
11942 (gnus-summary-position-point)))
11944 (gnus-summary-make-all-marking-commands)
11946 (gnus-ems-redefine)
11948 (provide 'gnus-sum)
11950 (run-hooks 'gnus-sum-load-hook)
11952 ;; Local Variables:
11953 ;; coding: iso-8859-1
11956 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11957 ;;; gnus-sum.el ends here